diff options
author | yenatch <yenatch@gmail.com> | 2018-04-09 21:30:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-09 21:30:24 -0400 |
commit | 40b537d45b4b8937038126f7e5d2d21ccee460c0 (patch) | |
tree | 881a090b80b2c22985fc6d1231b03c6721a83462 /home/stone_queue.asm | |
parent | e4b41fad4fd3787ca2e61adb5377ba8f68fca7ef (diff) | |
parent | 53ff57ca663dc5bf9c3731022b0eb0dc73f2207f (diff) |
Merge pull request #503 from Rangi42/master
Factor wMisc into meaningful parts; move most code out of home.asm
Diffstat (limited to 'home/stone_queue.asm')
-rw-r--r-- | home/stone_queue.asm | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/home/stone_queue.asm b/home/stone_queue.asm new file mode 100644 index 000000000..d41db6fd7 --- /dev/null +++ b/home/stone_queue.asm @@ -0,0 +1,143 @@ +HandleStoneQueue:: ; 3567 + ld a, [hROMBank] + push af + + call SwitchToMapScriptsBank + call .WarpAction + + pop bc + ld a, b + rst Bankswitch + ret +; 3574 + +.WarpAction: ; 3574 + ld hl, OBJECT_MAP_OBJECT_INDEX + add hl, de + ld a, [hl] + cp $ff + jr z, .nope + + ld l, a + push hl + call .IsObjectOnWarp + pop hl + jr nc, .nope + ld d, a + ld e, l + call .IsObjectInStoneTable + jr nc, .nope + call CallMapScript + farcall EnableScriptMode + scf + ret + +.nope + and a + ret +; 3599 + +.IsObjectOnWarp: ; 3599 + push de + + ld hl, OBJECT_NEXT_MAP_X + add hl, de + ld a, [hl] + ld hl, OBJECT_NEXT_MAP_Y + add hl, de + ld e, [hl] + + sub 4 + ld d, a + ld a, e + sub 4 + ld e, a + call .check_on_warp + + pop de + ret +; 35b0 + +.check_on_warp ; 35b0 + ld hl, wCurrMapWarpsPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wCurrMapWarpCount] + and a + jr z, .nope2 + +.loop + push af + ld a, [hl] + cp e + jr nz, .not_on_warp + inc hl + ld a, [hld] + cp d + jr nz, .not_on_warp + jr .found_warp + +.not_on_warp + ld a, 5 + add l + ld l, a + jr nc, .no_carry + inc h +.no_carry + + pop af + dec a + jr nz, .loop + +.nope2 + and a + ret + +.found_warp + pop af + ld d, a + ld a, [wCurrMapWarpCount] + sub d + inc a + scf + ret +; 35de + +.IsObjectInStoneTable: ; 35de + inc e + ld hl, CMDQUEUE_ADDR + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a +.loop2 + ld a, [hli] + cp $ff + jr z, .nope3 + cp d + jr nz, .next_inc3 + ld a, [hli] + cp e + jr nz, .next_inc2 + ld a, [hli] + ld h, [hl] + ld l, a + jr .yes + +.next_inc3 + inc hl + +.next_inc2 + inc hl + inc hl + jr .loop2 + +.nope3 + and a + ret + +.yes + scf + ret +; 3600 |