Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/predef.asm
1270 views
1
Predef::
2
; Call predefined function a.
3
; To preserve other registers, have the
4
; destination call GetPredefRegisters.
5
6
; Save the predef id for GetPredefPointer.
7
ld [wPredefID], a
8
9
; A hack for LoadDestinationWarpPosition.
10
; See LoadTilesetHeader (predef $19).
11
ldh a, [hLoadedROMBank]
12
ld [wPredefParentBank], a
13
14
push af
15
ld a, BANK(GetPredefPointer)
16
ldh [hLoadedROMBank], a
17
ld [rROMB], a
18
19
call GetPredefPointer
20
21
ld a, [wPredefBank]
22
ldh [hLoadedROMBank], a
23
ld [rROMB], a
24
25
ld de, .done
26
push de
27
jp hl
28
.done
29
30
pop af
31
ldh [hLoadedROMBank], a
32
ld [rROMB], a
33
ret
34
35
GetPredefRegisters::
36
; Restore the contents of register pairs
37
; when GetPredefPointer was called.
38
ld a, [wPredefHL]
39
ld h, a
40
ld a, [wPredefHL + 1]
41
ld l, a
42
ld a, [wPredefDE]
43
ld d, a
44
ld a, [wPredefDE + 1]
45
ld e, a
46
ld a, [wPredefBC]
47
ld b, a
48
ld a, [wPredefBC + 1]
49
ld c, a
50
ret
51
52