forked from bboxy/bitfire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink_macros_kickass.inc
164 lines (146 loc) · 2.8 KB
/
link_macros_kickass.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
.importonce
//load next file as a raw file (do not decomp on the fly) and jump to .addr
.macro link_load_next_raw_jmp (addr) {
lda #>[addr-1]
pha
lda #<[addr-1]
pha
jmp link_load_next_raw
}
//load file #, then jump to .addr
.macro link_load_raw_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
txa
jmp link_load_raw
}
//load next file and decomp on the fly, then jump to .addr
.macro link_load_next_comp_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
jmp link_load_next_comp
}
//load file # and decomp on the fly, then jump to .addr
.macro link_load_comp_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
txa
jmp link_load_comp
}
//decomp previously loaded file and jump to .addr
.macro link_decomp_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
jmp link_decomp
}
.macro link_decomp_under_io_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
jmp link_decomp_under_io
}
//load next file and decompress on the fly, then load next file raw, disable IO and decompress it, then enable IO again -> a full file that was split into two parts is loaded, with a portion going under IO
.macro link_load_next_double_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
jmp link_load_next_double
}
//load file raw and decomp
.macro link_load_next_raw_decomp_jmp (addr) {
lda #>[addr - 1]
pha
lda #<[addr - 1]
pha
jmp link_load_next_raw_decomp
}
//link irq hook back to base irq
.macro link_player_irq () {
sei
lda #<link_player
sta $fffe
lda #>link_player
sta $ffff
lda #$ff
sta $d012
cli
}
//request next disk side and reset filenum_counter
.macro request_disk (num) {
lda #num + $f0
jsr bitfire_send_byte_
lda #$3f
sta $dd02
}
//wait for given frame counter value
.macro link_wait_syncpoint (part) {
wait:
lda link_syncpoint
cmp #part
bcc wait
}
.macro clear_frame_count () {
lda #$00
sta link_frame_count + 0
sta link_frame_count + 1
}
.macro wait_frame_count (cnt) {
wait:
lda link_frame_count+0
cmp #<cnt
bcc wait
wait2:
lda link_frame_count+1
cmp #>cnt
bcc wait2
}
.macro bus_lock () {
lda #$c7
sta $dd02
}
.macro bus_unlock (bank) {
lda #[bank & 3] | $c0
sta $dd00
lda #$3f
sta $dd02
}
//set start address of the packed file in memory. A=LSB, A=MSB
.macro set_depack_pointers (addr) {
lda #<addr
sta bitfire_lz_sector_ptr1
sta bitfire_lz_sector_ptr2
lda #>addr
sta bitfire_lz_sector_ptr1 + 1
sta bitfire_lz_sector_ptr2 + 1
}
.macro start_music_nmi () {
ldx #<link_player
lda #>link_player
stx $fffa
sta $fffb
lda #$00
sta $dd0e
lda $dd0d
lda #$c7
sta $dd04
lda #$4c
sta $dd05
lda #$81
sta $dd0d
lda #$ff
wait:
cmp $d012
bne wait
lda #$11
sta $dd0e
}