diff options
Diffstat (limited to 'home/predef.asm')
-rw-r--r-- | home/predef.asm | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/home/predef.asm b/home/predef.asm index 03f74146..6b478b56 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -1,53 +1,34 @@ -Predef:: ; 2d83 -; Call predefined function a. -; Preserves bc, de, hl and f. - - ld [PredefID], a +Predef:: ; 2e49 (0:2e49) + ld [wPredefID], a ld a, [hROMBank] push af - ld a, BANK(GetPredefPointer) rst Bankswitch - call GetPredefPointer ; stores hl in PredefTemp - -; Switch to the new function's bank + call GetPredefPointer rst Bankswitch - -; Instead of directly calling stuff, -; push it to the stack in reverse. - - ld hl, .Return + ld hl, .return push hl - -; Call the Predef function - ld a, [PredefAddress] + ld a, [wPredefPointerBuffer] ld h, a - ld a, [PredefAddress + 1] + ld a, [wPredefPointerBuffer + 1] ld l, a push hl - -; Get hl back - ld a, [PredefTemp] + ld a, [wPredefHLBuffer] ld h, a - ld a, [PredefTemp + 1] + ld a, [wPredefHLBuffer + 1] ld l, a ret -.Return -; Clean up after the Predef call - +.return ld a, h - ld [PredefTemp], a + ld [wPredefHLBuffer], a ld a, l - ld [PredefTemp+1], a - + ld [wPredefHLBuffer + 1], a pop hl ld a, h rst Bankswitch - - ld a, [PredefTemp] + ld a, [wPredefHLBuffer] ld h, a - ld a, [PredefTemp + 1] + ld a, [wPredefHLBuffer + 1] ld l, a ret -; 2dba |