summaryrefslogtreecommitdiff
path: root/src/home/script.asm
diff options
context:
space:
mode:
authorDaniel Harding <33dannye@gmail.com>2021-09-19 00:21:14 -0500
committerGitHub <noreply@github.com>2021-09-19 00:21:14 -0500
commitdf67aac83b466dadf5f74c881bf84dd9ef19bdfc (patch)
tree47501aced2d256052b8f78bc97328d5af5703add /src/home/script.asm
parente4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff)
parent8dee6b7a11e85d6d4b9f8ec9fb9d53a499fd37dc (diff)
Merge pull request #110 from ElectroDeoxys/master
Split Home bank
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..229eb65
--- /dev/null
+++ b/src/home/script.asm
@@ -0,0 +1,171 @@
+HandleMoveModeAPress:
+ 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:
+ 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:
+ farcall _GetNPCDuelConfigurations
+ ret
+
+; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb
+RunOverworldScript:
+ 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:
+ ldh a, [hBankROM]
+ push af
+ ld a, BANK(_GameLoop)
+ call BankswitchROM
+ call _GameLoop
+ pop af
+ call BankswitchROM
+ ret
+
+Func_3b21:
+ ldh a, [hBankROM]
+ push af
+ ld a, BANK(Func_1c8bc)
+ call BankswitchROM
+ call Func_1c8bc
+ pop af
+ call BankswitchROM
+ ret
+
+Func_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