summaryrefslogtreecommitdiff
path: root/src/home/script.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/script.asm')
-rw-r--r--src/home/script.asm171
1 files changed, 171 insertions, 0 deletions
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