From 32b02147925566bac93bf71b002860335583574c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:51:12 +0100 Subject: Split home bank --- src/home/script.asm | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 src/home/script.asm (limited to 'src/home/script.asm') diff --git a/src/home/script.asm b/src/home/script.asm new file mode 100644 index 0000000..115513c --- /dev/null +++ b/src/home/script.asm @@ -0,0 +1,171 @@ +HandleMoveModeAPress: ; 3a5e (0:3a5e) + ldh a, [hBankROM] + push af + ld l, MAP_SCRIPT_OBJECTS + call GetMapScriptPointer + jr nc, .handleSecondAPressScript + ld a, BANK(FindPlayerMovementFromDirection) + call BankswitchROM + call FindPlayerMovementFromDirection + ld a, BANK(MapScripts) + call BankswitchROM + ld a, [wPlayerDirection] + ld d, a +.findAPressMatchLoop + ld a, [hli] + bit 7, a + jr nz, .handleSecondAPressScript + push bc + push hl + cp d + jr nz, .noMatch + ld a, [hli] + cp b + jr nz, .noMatch + ld a, [hli] + cp c + jr nz, .noMatch + ld a, [hli] + ld [wNextScript], a + ld a, [hli] + ld [wNextScript+1], a + ld a, [hli] + ld [wDefaultObjectText], a + ld a, [hli] + ld [wDefaultObjectText+1], a + ld a, [hli] + ld [wCurrentNPCNameTx], a + ld a, [hli] + ld [wCurrentNPCNameTx+1], a + pop hl + pop bc + pop af + call BankswitchROM + scf + ret +.noMatch + pop hl + ld bc, MAP_OBJECT_SIZE - 1 + add hl, bc + pop bc + jr .findAPressMatchLoop +.handleSecondAPressScript + pop af + call BankswitchROM + ld l, MAP_SCRIPT_PRESSED_A + call CallMapScriptPointerIfExists + ret + +; returns a map script pointer in hl given +; current map in wCurMap and which sub-script in l +; sets c if pointer is found +GetMapScriptPointer: ; 3abd (0:3abd) + push bc + push hl + ld a, [wCurMap] + ld l, a + ld h, $0 + add hl, hl + add hl, hl + add hl, hl + add hl, hl + ld bc, MapScripts + add hl, bc + pop bc + ld b, $0 + add hl, bc + ldh a, [hBankROM] + push af + ld a, BANK(MapScripts) + call BankswitchROM + ld a, [hli] + ld h, [hl] + ld l, a + pop af + call BankswitchROM + ld a, l + or h + jr nz, .asm_3ae5 + scf +.asm_3ae5 + ccf + pop bc + ret + +; loads some configurations for the duel against +; the NPC whose deck ID is stored in wNPCDuelDeckID +; this includes NPC portrait, his/her name text ID, +; and the number of prize cards +; this was used in testing since these configurations +; are stored in the script-related NPC data for normal gameplay +; returns carry if a duel configuration was found +; for the given NPC deck ID +GetNPCDuelConfigurations: ; 3ae8 (0:3ae8) + farcall _GetNPCDuelConfigurations + ret + +; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb +RunOverworldScript: ; 3aed (0:3aed) + ld hl, wScriptPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hli] + ld c, [hl] + inc hl + ld b, [hl] + push bc + rlca + ld c, a + ld b, $0 + ld hl, OverworldScriptTable + add hl, bc + ldh a, [hBankROM] + push af + ld a, BANK(OverworldScriptTable) + call BankswitchROM + ld a, [hli] + ld h, [hl] + ld l, a + pop af + call BankswitchROM + pop bc + jp hl + +Func_3b11: ; 3b11 (0:3b11) + ldh a, [hBankROM] + push af + ld a, BANK(_GameLoop) + call BankswitchROM + call _GameLoop + pop af + call BankswitchROM + ret + +Func_3b21: ; 3b21 (0:3b21) + ldh a, [hBankROM] + push af + ld a, BANK(Func_1c8bc) + call BankswitchROM + call Func_1c8bc + pop af + call BankswitchROM + ret + +Func_3b31: ; 3b31 (0:3b31) + ldh a, [hBankROM] + push af + ld a, BANK(Func_1cb18) + call BankswitchROM + call Func_1cb18 + jr c, .asm_3b45 + xor a + ld [wDoFrameFunction], a + ld [wDoFrameFunction + 1], a +.asm_3b45 + call ZeroObjectPositions + ld a, 1 + ld [wVBlankOAMCopyToggle], a + pop af + call BankswitchROM + ret -- cgit v1.2.3 From 0017fc2d171c87d7bab4c9be90e1069ae95a8071 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:54:29 +0100 Subject: Remove home bank address comments --- src/home/script.asm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/home/script.asm') diff --git a/src/home/script.asm b/src/home/script.asm index 115513c..229eb65 100644 --- a/src/home/script.asm +++ b/src/home/script.asm @@ -1,4 +1,4 @@ -HandleMoveModeAPress: ; 3a5e (0:3a5e) +HandleMoveModeAPress: ldh a, [hBankROM] push af ld l, MAP_SCRIPT_OBJECTS @@ -59,7 +59,7 @@ HandleMoveModeAPress: ; 3a5e (0:3a5e) ; returns a map script pointer in hl given ; current map in wCurMap and which sub-script in l ; sets c if pointer is found -GetMapScriptPointer: ; 3abd (0:3abd) +GetMapScriptPointer: push bc push hl ld a, [wCurMap] @@ -100,12 +100,12 @@ GetMapScriptPointer: ; 3abd (0:3abd) ; are stored in the script-related NPC data for normal gameplay ; returns carry if a duel configuration was found ; for the given NPC deck ID -GetNPCDuelConfigurations: ; 3ae8 (0:3ae8) +GetNPCDuelConfigurations: farcall _GetNPCDuelConfigurations ret ; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb -RunOverworldScript: ; 3aed (0:3aed) +RunOverworldScript: ld hl, wScriptPointer ld a, [hli] ld h, [hl] @@ -132,7 +132,7 @@ RunOverworldScript: ; 3aed (0:3aed) pop bc jp hl -Func_3b11: ; 3b11 (0:3b11) +Func_3b11: ldh a, [hBankROM] push af ld a, BANK(_GameLoop) @@ -142,7 +142,7 @@ Func_3b11: ; 3b11 (0:3b11) call BankswitchROM ret -Func_3b21: ; 3b21 (0:3b21) +Func_3b21: ldh a, [hBankROM] push af ld a, BANK(Func_1c8bc) @@ -152,7 +152,7 @@ Func_3b21: ; 3b21 (0:3b21) call BankswitchROM ret -Func_3b31: ; 3b31 (0:3b31) +Func_3b31: ldh a, [hBankROM] push af ld a, BANK(Func_1cb18) -- cgit v1.2.3