Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/macros/farcall.asm
2019 views
1
; Far calls to another bank
2
3
; There is no difference between `farcall` and `callfar`, except the arbitrary
4
; order in which they set `b` and `hl` before calling `FarCall`.
5
; We use the more natural name "farcall" for the more common order.
6
; The same goes for `farjp` and `jpfar`.
7
8
MACRO farcall
9
ld b, BANK(\1)
10
ld hl, \1
11
call Bankswitch
12
ENDM
13
14
MACRO callfar
15
ld hl, \1
16
ld b, BANK(\1)
17
call Bankswitch
18
ENDM
19
20
MACRO farjp
21
ld b, BANK(\1)
22
ld hl, \1
23
jp Bankswitch
24
ENDM
25
26
MACRO jpfar
27
ld hl, \1
28
ld b, BANK(\1)
29
jp Bankswitch
30
ENDM
31
32
MACRO homecall
33
ldh a, [hLoadedROMBank]
34
push af
35
ld a, BANK(\1)
36
ldh [hLoadedROMBank], a
37
ld [rROMB], a
38
call \1
39
pop af
40
ldh [hLoadedROMBank], a
41
ld [rROMB], a
42
ENDM
43
44
MACRO homecall_sf ; homecall but save flags by popping into bc instead of af
45
ldh a, [hLoadedROMBank]
46
push af
47
ld a, BANK(\1)
48
ldh [hLoadedROMBank], a
49
ld [rROMB], a
50
call \1
51
pop bc
52
ld a, b
53
ldh [hLoadedROMBank], a
54
ld [rROMB], a
55
ENDM
56
57