From a87dbf03cf544a7878a0ee658b38494614ccaf8a Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 19 Feb 2022 02:37:19 -0600 Subject: [PATCH] ecs: resources have their own labels, auto-find resources --- src/codemirror/ecs.js | 2 +- src/common/ecs/ecs.ts | 32 +++++++++++++++++++++----------- test/ecs/narrow1.txt | 1 + test/ecs/score.ecs | 3 --- test/ecs/score.txt | 20 ++++++++++++++++++-- test/ecs/sprites.txt | 13 +++++++++++++ test/ecs/sprites1.txt | 13 +++++++++++++ test/ecs/superman.txt | 19 +++++++++++++++++++ test/ecs/titles.txt | 9 +++++++++ test/ecs/vcs1.txt | 10 ++++++++++ test/ecs/vcslib.txt | 11 +++++++++++ 11 files changed, 116 insertions(+), 17 deletions(-) diff --git a/src/codemirror/ecs.js b/src/codemirror/ecs.js index 8e504c53..1a893b4c 100644 --- a/src/codemirror/ecs.js +++ b/src/codemirror/ecs.js @@ -17,7 +17,7 @@ var keywords1, keywords2; var directives_list = [ - 'end', 'component', 'system', 'entity', 'scope', 'using', 'demo', 'decode', + 'end', 'component', 'system', 'entity', 'scope', 'using', 'demo', 'decode', 'resource', 'const', 'locals', 'var', 'on', 'do', 'emit', 'limit', 'once', 'foreach', 'with', 'join', 'if', diff --git a/src/common/ecs/ecs.ts b/src/common/ecs/ecs.ts index 6ffbce44..8324d94b 100644 --- a/src/common/ecs/ecs.ts +++ b/src/common/ecs/ecs.ts @@ -624,9 +624,12 @@ class ActionEval { this.label = `${this.instance.system.name}__${action.event}__${this.em.seq++}`; } begin() { - let state = this.scope.state = Object.assign({}, this.scope.state); + let state = this.scope.state = Object.assign(new ActionCPUState(), this.scope.state); // TODO: generalize to other cpus/langs switch (this.action.select) { + case 'once': + state.xreg = state.yreg = null; + break; case 'foreach': if (state.xreg && state.yreg) throw new ECSError('no more index registers', this.action); if (state.xreg) state.yreg = new IndexRegister(this.scope, this.qr); @@ -674,14 +677,12 @@ class ActionEval { if (this.entities.length == 0 && allowEmpty.includes(this.action.select)) return ''; - let action = this.action; - let sys = this.instance.system; - let { code, props } = this.getCodeAndProps(action); + let { code, props } = this.getCodeAndProps(this.action); // replace @labels code = this.replaceLabels(code, this.label); // replace {{...}} tags // TODO: use nodes instead - code = this.replaceTags(code, action, props); + code = this.replaceTags(code, this.action, props); return code; } private getCodeAndProps(action: Action) { @@ -839,8 +840,9 @@ class ActionEval { return `${this.tmplabel}+${tempinc}`; } __arg(args: string[]) { - let index = parseInt(args[0] || '0'); - return this.eventargs[index] || ''; + let argindex = parseInt(args[0] || '0'); + let argvalue = this.eventargs[argindex] || ''; + return argvalue; } __bss_init(args: string[]) { return this.scope.allocateInitData(this.scope.bss); @@ -1042,6 +1044,9 @@ export class EntityScope implements SourceLocated { newSystemInstanceWithDefaults(system: System) { return this.newSystemInstance({ system, params: {}, id:0 }); } + getSystemInstanceNamed(name: string) { + return this.instances.find(sys => sys.system.name == name); + } getEntityByName(name: string) { return this.entities.find(e => e.name == name); } @@ -1259,7 +1264,7 @@ export class EntityScope implements SourceLocated { isConstOrInit(component: ComponentType, fieldName: string) : 'const' | 'init' { return this.fieldtypes[mksymbol(component, fieldName)]; } - generateCodeForEvent(event: string, args?: string[]): string { + generateCodeForEvent(event: string, args?: string[], codelabel?: string): string { // find systems that respond to event // and have entities in this scope let systems = this.em.event2systems[event]; @@ -1271,8 +1276,8 @@ export class EntityScope implements SourceLocated { } this.eventSeq++; // generate code - let code = this.dialect.code(); - //s += `\n; event ${event}\n`; + let code = this.dialect.code() + '\n'; + if (codelabel) { code += this.dialect.label(codelabel) + '\n'; } let eventCount = 0; let instances = this.instances.filter(inst => systems.includes(inst.system)); for (let inst of instances) { @@ -1384,7 +1389,12 @@ export class EntityScope implements SourceLocated { } this.code.addCodeFragment(start); for (let sub of Array.from(this.resources.values())) { - let code = this.generateCodeForEvent(sub); + if (!this.getSystemInstanceNamed(sub)) { + let sys = this.em.getSystemByName(sub); + if (!sys) throw new ECSError(`cannot find resource named "${sub}"`); + this.newSystemInstanceWithDefaults(sys); + } + let code = this.generateCodeForEvent(sub, [], sub); this.code.addCodeFragment(code); } //this.showStats(); diff --git a/test/ecs/narrow1.txt b/test/ecs/narrow1.txt index 0f91204b..4aef92c2 100644 --- a/test/ecs/narrow1.txt +++ b/test/ecs/narrow1.txt @@ -9,6 +9,7 @@ Xpos_x_b0: __Start: .code + ;;; start action move 1 start ldx #0 diff --git a/test/ecs/score.ecs b/test/ecs/score.ecs index b3ae2924..ec467f77 100644 --- a/test/ecs/score.ecs +++ b/test/ecs/score.ecs @@ -137,7 +137,6 @@ end resource FontTable --- ; Font table for digits 0-9 (8x8 pixels) -FontTable: ;;{w:8,h:8,count:10,brev:1,flip:1};; .byte $00,$3c,$66,$66,$76,$6e,$66,$3c,$00,$7e,$18,$18,$18,$38,$18,$18 .byte $00,$7e,$60,$30,$0c,$06,$66,$3c,$00,$3c,$66,$06,$1c,$06,$66,$3c @@ -211,7 +210,6 @@ end resource FontTablePF --- ; Font table for digits 0-9 (4x8 pixels) -FontTablePF: ;;{w:8,h:8,count:10,brev:1,flip:1};; .byte $00,$00,$EE,$AA,$AA,$AA,$EE,$00 .byte $00,$00,$22,$22,$22,$22,$22,$00 @@ -228,7 +226,6 @@ FontTablePF: resource FontTablePFFancy --- ; Font table for digits 0-9 (4x8 pixels) -FontTablePFFancy: ;;{w:8,h:8,count:10,brev:1,flip:1};; .byte $00,$44,$AA,$AA,$AA,$AA,$AA,$44 .byte $00,$EE,$44,$44,$44,$44,$CC,$44 diff --git a/test/ecs/score.txt b/test/ecs/score.txt index 8bd03d7f..3151d0b1 100644 --- a/test/ecs/score.txt +++ b/test/ecs/score.txt @@ -50,6 +50,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 9 main_init .include "vcs-ca65.h" @@ -68,12 +69,14 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action Kernel6Digit 2 preframe Digit0 = Kernel6Digit__2__tmp+0 @@ -127,6 +130,7 @@ Kernel6Digit__preframe__3__Loop: KERNEL_START .code + ;;; start action Kernel6Digit 2 kernel lda PFColor_pfcolor_b0 @@ -220,6 +224,7 @@ Kernel2Digit__kernel__7__Loop: sta WSYNC .code + ;;; start action Kernel2Digit 4 compute2digit lda Kernel2Digit__4__tmp+1 ; load 1st pf @@ -233,6 +238,7 @@ Kernel2Digit__kernel__7__Loop: asl .code + ;;; start action Kernel2Digit 4 fetchdigit adc Kernel2Digit__4__tmp+0 @@ -252,6 +258,7 @@ Kernel2Digit__kernel__7__Loop: sty PF1 ; store 2nd pf .code + ;;; start action Kernel2Digit 4 fetchdigit adc Kernel2Digit__4__tmp+0 @@ -270,6 +277,7 @@ Kernel2Digit__kernel__7__Loop: inx .code + ;;; start action Kernel2Digit 4 compute2digit lda Kernel2Digit__4__tmp+1 ; load 1st pf @@ -283,6 +291,7 @@ Kernel2Digit__kernel__7__Loop: asl .code + ;;; start action Kernel2Digit 4 fetchdigit adc Kernel2Digit__4__tmp+0 @@ -302,6 +311,7 @@ Kernel2Digit__kernel__7__Loop: sty PF1 ; store 2nd pf .code + ;;; start action Kernel2Digit 4 fetchdigit adc Kernel2Digit__4__tmp+0 @@ -328,16 +338,19 @@ Kernel2Digit__kernel__7__Loop: KERNEL_END .code + ;;; start action JoyButton 6 postframe lda INPT4 ;read button input bmi JoyButton__postframe__14__NotPressed .code + ;;; start action IncScore 8 joybutton .code + ;;; start action BCDMath 7 AddBCD4 .ifnblank $0210 @@ -371,6 +384,7 @@ JoyButton__postframe__14__NotPressed: FRAME_END .code + jmp FrameLoop__start__2__NextFrame ; loop to next frame ;;; end action FrameLoop 1 start @@ -385,10 +399,11 @@ VecBRK: .word Main::__BRK .code +FontTable: + ;;; start action FontTable 3 FontTable ; Font table for digits 0-9 (8x8 pixels) -FontTable: ;;{w:8,h:8,count:10,brev:1,flip:1};; .byte $00,$3c,$66,$66,$76,$6e,$66,$3c,$00,$7e,$18,$18,$18,$38,$18,$18 .byte $00,$7e,$60,$30,$0c,$06,$66,$3c,$00,$3c,$66,$06,$1c,$06,$66,$3c @@ -400,10 +415,11 @@ FontTable: .code +FontTablePF: + ;;; start action FontTablePF 5 FontTablePF ; Font table for digits 0-9 (4x8 pixels) -FontTablePF: ;;{w:8,h:8,count:10,brev:1,flip:1};; .byte $00,$00,$EE,$AA,$AA,$AA,$EE,$00 .byte $00,$00,$22,$22,$22,$22,$22,$00 diff --git a/test/ecs/sprites.txt b/test/ecs/sprites.txt index 04821ad8..a75688af 100644 --- a/test/ecs/sprites.txt +++ b/test/ecs/sprites.txt @@ -117,6 +117,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 10 main_init .include "vcs-ca65.h" @@ -135,12 +136,14 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action Kernel2Sprite 2 preframe .define KLINES #192 @@ -255,6 +258,7 @@ SetXPos__preframe__9____each: lda HasXpos_xpos_b0,x .code + ;;; start action SetHorizPos 7 SetHorizPos ; SetHorizPos routine @@ -298,6 +302,7 @@ SetXPos__preframe__9____exit: KERNEL_START .code + ;;; start action Kernel2Sprite 2 kernel ldy #0 @@ -313,6 +318,7 @@ SetXPos__preframe__9____exit: Kernel2Sprite__kernel__14__LVScan: .code + ;;; start action Kernel2Sprite 2 scanline ; draw player 0 @@ -350,6 +356,7 @@ Kernel2Sprite__scanline__15__DoDraw2: dey ; next scanline .code + ;;; start action Kernel2Sprite 2 scanline ; draw player 0 @@ -402,6 +409,7 @@ Kernel2Sprite__scanline__17__DoDraw2: KERNEL_END .code + ;;; start action Joystick 3 postframe ; 2 control inputs share a single byte, 4 bits each @@ -419,6 +427,7 @@ Joystick__postframe__21____each: bcs Joystick__postframe__21__SkipMoveRight .code + ;;; start action MoveJoyX 4 joyright lda HasXpos_xpos_b0,x @@ -436,6 +445,7 @@ Joystick__postframe__21__SkipMoveRight: bcs Joystick__postframe__21__SkipMoveLeft .code + ;;; start action MoveJoyX 4 joyleft lda HasXpos_xpos_b0,x @@ -452,6 +462,7 @@ Joystick__postframe__21__SkipMoveLeft: bcs Joystick__postframe__21__SkipMoveDown .code + ;;; start action MoveJoyY 5 joydown lda HasYpos_ypos_b0,x @@ -469,6 +480,7 @@ Joystick__postframe__21__SkipMoveDown: bcs Joystick__postframe__21__SkipMoveUp .code + ;;; start action MoveJoyY 5 joyup lda HasYpos_ypos_b0,x @@ -549,6 +561,7 @@ SpriteHider__postframe__28____exit: FRAME_END .code + jmp FrameLoop__start__2__NextFrame ; loop to next frame ;;; end action FrameLoop 1 start diff --git a/test/ecs/sprites1.txt b/test/ecs/sprites1.txt index 0022430d..fec16295 100644 --- a/test/ecs/sprites1.txt +++ b/test/ecs/sprites1.txt @@ -117,6 +117,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 10 main_init .include "vcs-ca65.h" @@ -135,12 +136,14 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action Kernel2Sprite 2 preframe .define KLINES #192 @@ -240,6 +243,7 @@ SetXPos__preframe__9____each: lda HasXpos_xpos_b0,x .code + ;;; start action SetHorizPos 7 SetHorizPos ; SetHorizPos routine @@ -283,6 +287,7 @@ SetXPos__preframe__9____exit: KERNEL_START .code + ;;; start action Kernel2Sprite 2 kernel ldy #0 @@ -329,6 +334,7 @@ DoDraw2: Kernel2Sprite__kernel__14__LVScan: .code + ;;; start action Kernel2Sprite 2 scanline1 ;;; end action Kernel2Sprite 2 scanline1 @@ -337,6 +343,7 @@ Kernel2Sprite__kernel__14__LVScan: dey ; next scanline .code + Kernel2Sprite__kernel__14__DrawLine 0 ; macro: draw scanline no WSYNC dey ; next scanline bne Kernel2Sprite__kernel__14__LVScan ; repeat until out of lines @@ -356,6 +363,7 @@ Kernel2Sprite__kernel__14__LVScan: KERNEL_END .code + ;;; start action Joystick 3 postframe ; 2 control inputs share a single byte, 4 bits each @@ -373,6 +381,7 @@ Joystick__postframe__18____each: bcs Joystick__postframe__18__SkipMoveRight .code + ;;; start action MoveJoyX 4 joyright lda HasXpos_xpos_b0,x @@ -390,6 +399,7 @@ Joystick__postframe__18__SkipMoveRight: bcs Joystick__postframe__18__SkipMoveLeft .code + ;;; start action MoveJoyX 4 joyleft lda HasXpos_xpos_b0,x @@ -406,6 +416,7 @@ Joystick__postframe__18__SkipMoveLeft: bcs Joystick__postframe__18__SkipMoveDown .code + ;;; start action MoveJoyY 5 joydown lda HasYpos_ypos_b0,x @@ -423,6 +434,7 @@ Joystick__postframe__18__SkipMoveDown: bcs Joystick__postframe__18__SkipMoveUp .code + ;;; start action MoveJoyY 5 joyup lda HasYpos_ypos_b0,x @@ -503,6 +515,7 @@ SpriteHider__postframe__25____exit: FRAME_END .code + jmp FrameLoop__start__2__NextFrame ; loop to next frame ;;; end action FrameLoop 1 start diff --git a/test/ecs/superman.txt b/test/ecs/superman.txt index 1f41dd4a..c236fb13 100644 --- a/test/ecs/superman.txt +++ b/test/ecs/superman.txt @@ -629,6 +629,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 11 main_init .include "vcs-ca65.h" @@ -647,12 +648,14 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action Kernel2Sprite 2 preframe .define KLINES #192 @@ -767,6 +770,7 @@ SetXPos__preframe__9____each: lda HasXpos_xpos_b0,x .code + ;;; start action SetHorizPos 9 SetHorizPos ; SetHorizPos routine @@ -822,6 +826,7 @@ SetXPos__preframe__9____exit: KERNEL_START .code + ;;; start action Kernel2Sprite 2 kernel ldy #0 @@ -837,6 +842,7 @@ SetXPos__preframe__9____exit: Kernel2Sprite__kernel__15__LVScan: .code + ;;; start action Kernel2Sprite 2 scanline ; draw player 0 @@ -892,6 +898,7 @@ Kernel2Sprite__scanline__16__DoDraw2: dey ; next scanline .code + ;;; start action Kernel2Sprite 2 scanline ; draw player 0 @@ -962,6 +969,7 @@ Kernel2Sprite__scanline__20__DoDraw2: KERNEL_END .code + ;;; start action Joystick 3 postframe ; 2 control inputs share a single byte, 4 bits each @@ -976,6 +984,7 @@ Kernel2Sprite__scanline__20__DoDraw2: bcs Joystick__postframe__26__SkipMoveRight .code + ;;; start action JoyFaceDirection 4 joyright lda Sprite_plyrflags_b0 @@ -993,6 +1002,7 @@ Kernel2Sprite__scanline__20__DoDraw2: jcc SuperFly__joyright__28__nomove .code + ;;; start action SuperFly 5 goeast ldy Location_room_b0 @@ -1012,6 +1022,7 @@ Joystick__postframe__26__SkipMoveRight: bcs Joystick__postframe__26__SkipMoveLeft .code + ;;; start action JoyFaceDirection 4 joyleft lda Sprite_plyrflags_b0 @@ -1028,6 +1039,7 @@ Joystick__postframe__26__SkipMoveRight: jcs SuperFly__joyleft__31__nomove .code + ;;; start action SuperFly 5 gowest ldy Location_room_b0 @@ -1047,6 +1059,7 @@ Joystick__postframe__26__SkipMoveLeft: bcs Joystick__postframe__26__SkipMoveDown .code + ;;; start action SuperFly 5 joydown lda HasYpos_ypos_b0 @@ -1056,6 +1069,7 @@ Joystick__postframe__26__SkipMoveLeft: jcc SuperFly__joydown__33__nomove .code + ;;; start action SuperFly 5 gosouth ldy Location_room_b0 @@ -1075,6 +1089,7 @@ Joystick__postframe__26__SkipMoveDown: bcs Joystick__postframe__26__SkipMoveUp .code + ;;; start action SuperFly 5 joyup lda HasYpos_ypos_b0 @@ -1083,6 +1098,7 @@ Joystick__postframe__26__SkipMoveDown: jcs SuperFly__joyup__35__nomove .code + ;;; start action SuperFly 5 gonorth ldy Location_room_b0 @@ -1108,6 +1124,7 @@ BadMove__postframe__37____each: .code + ;;; start action JoyFaceDirection 4 joyright lda Sprite_plyrflags_b0+1,x @@ -1125,6 +1142,7 @@ BadMove__postframe__37____each: jcc SuperFly__joyright__39__nomove .code + ;;; start action SuperFly 5 goeast ldy Location_room_b0+1,x @@ -1183,6 +1201,7 @@ RoomShuffle__postframe__41__exit: FRAME_END .code + jmp FrameLoop__start__2__NextFrame ; loop to next frame ;;; end action FrameLoop 1 start diff --git a/test/ecs/titles.txt b/test/ecs/titles.txt index 11290f5d..f3011e68 100644 --- a/test/ecs/titles.txt +++ b/test/ecs/titles.txt @@ -144,6 +144,7 @@ Bitmap48_height_b0: __Start: .code + ;;; start action Init 4 main_init .include "vcs-ca65.h" @@ -156,16 +157,19 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action StaticKernel 3 preframe .code + ;;; start action Kernel48Pixel 2 kernelsetup ;;; end action Kernel48Pixel 2 kernelsetup @@ -195,6 +199,7 @@ FrameLoop__start__2__NextFrame: KERNEL_START .code + ;;; start action StaticKernel 3 kernel ldx #0 @@ -203,6 +208,7 @@ StaticKernel__kernel__9____each: sta WSYNC .code + ;;; start action Kernel48Pixel 2 kernelsetup cpx #2+1 @@ -288,6 +294,7 @@ StaticKernel__kernelsetup__13____skipxhi: .code + ;;; start action Kernel48Pixel 2 kerneldraw cpx #2+1 @@ -350,9 +357,11 @@ StaticKernel__kernel__9____exit: KERNEL_END .code + FRAME_END .code + jmp FrameLoop__start__2__NextFrame ; loop to next frame ;;; end action FrameLoop 1 start diff --git a/test/ecs/vcs1.txt b/test/ecs/vcs1.txt index db7d7db8..3dc89aae 100644 --- a/test/ecs/vcs1.txt +++ b/test/ecs/vcs1.txt @@ -46,6 +46,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 7 main_init .include "vcs-ca65.h" @@ -63,16 +64,19 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action StaticKernel 4 preframe .code + ;;; start action StaticKernel 4 kernelsetup lda #24 @@ -94,6 +98,7 @@ FrameLoop__start__2__NextFrame: KERNEL_START .code + ;;; start action StaticKernel 4 kernel ldx #0 @@ -102,6 +107,7 @@ StaticKernel__kernel__7____each: sta WSYNC .code + ;;; start action StaticKernel 4 kernelsetup lda BGColor_bgcolor_b0,x @@ -160,12 +166,14 @@ StaticKernel__kernel__7____exit: KERNEL_END .code + ;;; start action JoyButton 5 postframe lda INPT4 ;read button input bmi JoyButton__postframe__11__NotPressed .code + ;;; start action Local 6 joybutton inc Local__6__tmp+0 @@ -180,12 +188,14 @@ JoyButton__postframe__11__NotPressed: FRAME_END .code + ;;; start action ResetSwitch 2 nextframe lsr SWCHB ; test Game Reset switch bcs ResetSwitch__nextframe__13__NoStart .code + ;;; start action ResetConsole 3 resetswitch jmp Main::__Reset ; jump to Reset handler diff --git a/test/ecs/vcslib.txt b/test/ecs/vcslib.txt index 1f58b892..4b73be8e 100644 --- a/test/ecs/vcslib.txt +++ b/test/ecs/vcslib.txt @@ -46,6 +46,7 @@ Main__INITDATA: __Start: .code + ;;; start action Init 7 main_init .include "vcs-ca65.h" @@ -64,16 +65,19 @@ __BRK: ; initialize data segment .code + ;;; start action FrameLoop 1 start FrameLoop__start__2__NextFrame: FRAME_START .code + ;;; start action StaticKernel 4 preframe .code + ;;; start action StaticKernel 4 kernelsetup lda #24 @@ -95,6 +99,7 @@ FrameLoop__start__2__NextFrame: KERNEL_START .code + ;;; start action StaticKernel 4 kernel ldx #0 @@ -103,6 +108,7 @@ StaticKernel__kernel__7____each: sta WSYNC .code + ;;; start action StaticKernel 4 kernelsetup lda BGColor_bgcolor_b0,x @@ -145,6 +151,7 @@ StaticKernel__kernelsetup__10____skipxlo: .code + ;;; start action StaticKernel 4 kerneldraw ldy KernelSection_lines_b0,x @@ -168,12 +175,14 @@ StaticKernel__kernel__7____exit: KERNEL_END .code + ;;; start action JoyButton 5 postframe lda INPT4 ;read button input bmi JoyButton__postframe__12__NotPressed .code + ;;; start action Local 6 joybutton inc Local__6__tmp+0 @@ -188,12 +197,14 @@ JoyButton__postframe__12__NotPressed: FRAME_END .code + ;;; start action ResetSwitch 2 nextframe lsr SWCHB ; test Game Reset switch bcs ResetSwitch__nextframe__14__NoStart .code + ;;; start action ResetConsole 3 resetswitch jmp Main::__Reset ; jump to Reset handler