mirror of
https://github.com/thornAvery/jep-hack.git
synced 2026-02-21 23:12:16 +13:00
First Commit
Upload literally everything from the pokecrystal16 expand-move-ID branch
This commit is contained in:
commit
2f8a41f833
4618 changed files with 480386 additions and 0 deletions
52
home/predef.asm
Normal file
52
home/predef.asm
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
Predef::
|
||||
; Call predefined function a.
|
||||
; Preserves bc, de, hl and f.
|
||||
|
||||
ld [wPredefID], a
|
||||
ldh a, [hROMBank]
|
||||
push af
|
||||
|
||||
ld a, BANK(GetPredefPointer)
|
||||
rst Bankswitch
|
||||
call GetPredefPointer ; stores hl in wPredefHL
|
||||
|
||||
; Switch to the new function's bank
|
||||
rst Bankswitch
|
||||
|
||||
; Instead of directly calling stuff,
|
||||
; push it to the stack in reverse.
|
||||
|
||||
ld hl, .Return
|
||||
push hl
|
||||
|
||||
; Call the Predef function
|
||||
ld a, [wPredefAddress]
|
||||
ld h, a
|
||||
ld a, [wPredefAddress + 1]
|
||||
ld l, a
|
||||
push hl
|
||||
|
||||
; Get hl back
|
||||
ld a, [wPredefHL]
|
||||
ld h, a
|
||||
ld a, [wPredefHL + 1]
|
||||
ld l, a
|
||||
ret
|
||||
|
||||
.Return:
|
||||
; Clean up after the Predef call
|
||||
|
||||
ld a, h
|
||||
ld [wPredefHL], a
|
||||
ld a, l
|
||||
ld [wPredefHL + 1], a
|
||||
|
||||
pop hl
|
||||
ld a, h
|
||||
rst Bankswitch
|
||||
|
||||
ld a, [wPredefHL]
|
||||
ld h, a
|
||||
ld a, [wPredefHL + 1]
|
||||
ld l, a
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue