-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.inc
executable file
·58 lines (53 loc) · 1.27 KB
/
macros.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
macro CHECKSUM(sum) {
origin $00014E
endian msb
dw {sum}
endian lsb
}
variable _currentBank = 1
macro ROMBANK(bank) {
if pc() > $8000 {
evaluate oldBank = _currentBank
evaluate offset = origin()
error "Bank {oldBank} overrun at file offset {offset}"
}
_currentBank = {bank}
origin {bank} << 14
base $4000
}
macro FARCALL_NOSAVE(variable TargetBank, variable Target, variable ReturnBank) {
ld hl,wFarcallParams
ld a,TargetBank
ld (hl+),a
ld a,((Target>>8)&$3F)+$40
ld (hl+),a
ld a,Target
ld (hl+),a
ld a,ReturnBank
ld (hl),a
call Farcall
}
macro FARCALL(variable TargetBank, variable Target, variable ReturnBank) {
push af
push bc
push de
push hl
FARCALL_NOSAVE(TargetBank, Target, ReturnBank)
pop hl
pop de
pop bc
pop af
}
macro FARCALL_NESTED(variable TargetBank, variable Target, variable ReturnBank) {
push af
ld a,(wCurrentBank)
push af
ld a,TargetBank
ld (wCurrentBank),a
ld a,(wFarcallParams+3)
FARCALL(TargetBank, Target, ReturnBank)
ld (wFarcallParams+3),a
pop af
ld (wCurrentBank),a
pop af
}