2014-02-01 17:26:39 -08:00
|
|
|
Predef:: ; 2d83
|
2013-09-08 20:54:12 -07:00
|
|
|
; Call predefined function a.
|
|
|
|
; Preserves bc, de, hl and f.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPredefID], a
|
2013-09-08 20:54:12 -07:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
|
|
|
|
ld a, BANK(GetPredefPointer)
|
|
|
|
rst Bankswitch
|
2018-01-23 14:39:09 -08:00
|
|
|
call GetPredefPointer ; stores hl in wPredefTemp
|
2013-09-08 20:54:12 -07:00
|
|
|
|
|
|
|
; 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
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-09-08 20:54:12 -07:00
|
|
|
; Call the Predef function
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefAddress]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefAddress + 1]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld l, a
|
|
|
|
push hl
|
|
|
|
|
|
|
|
; Get hl back
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefTemp]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefTemp + 1]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Return:
|
2013-09-08 20:54:12 -07:00
|
|
|
; Clean up after the Predef call
|
|
|
|
|
|
|
|
ld a, h
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPredefTemp], a
|
2013-09-08 20:54:12 -07:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPredefTemp+1], a
|
2013-09-08 20:54:12 -07:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, h
|
|
|
|
rst Bankswitch
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefTemp]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld h, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPredefTemp + 1]
|
2013-09-08 20:54:12 -07:00
|
|
|
ld l, a
|
|
|
|
ret
|
|
|
|
; 2dba
|