.const BLOCKS_PER_PART = 9
.const BYTES_PER_BLOCK = 208
.label memory_start = $0000
.label memory_start_lo = $0000
.label memory_start_hi = $0001
.label count = $0002
.label p1 = $0003
.label p2 = $0004
.label block_map = $0005
.var C0 = 80
.var C1 = 133
.var C2 = 102
.var C3 = 68
* = $0702
lda @loader_1c00:
sta $1c00
lda
sta $1c02
sta $1c0c
lda
sta $1c0b
tagain: lda $1808
bpl tagain
sec
sbc
ldy $1809
beq tagain
ldx
fill:
sta $1804-$fc, x
sbc
sta $1c04-$fc, x
tya
sta $1805-$fc, x
sta $1c05-$fc, x
ldy
lda
inx
inx
bne fill
lda
j: sta $00, x
inx
bne j
bit $1c01
again:
bit $1c00
bmi *-3
bit $1c01
clv
bvc *
lda $1c01
clv
cmp
bne again
ldy
header: bvc *
lda $1c01
clv
bvc *
eor $1c01
clv
bcc memory
beq again
clc
tax
lda block_map-1, x
bpl header
bmi again
memory: sta memory_start, y
dey
bpl header
ldy
read_block:
bvc *
lda $1c01
adc @constant_c1:
sta.zp p1
adc @constant_c3:
sta.zp p2
inc block_map-1, x
inc block_map-1, x
dey
lda @constant_c0:
adc $1c01
clv
eor.zp p1
sta.abs (memory_start), y
bvc *
lda $1c01
adc @constant_c2:
clv
eor.zp p2
dey
sta.abs (memory_start), y
bne read_block
dec count
bne again
lda $1c00
ora
sta $1c00
eor
ldx
delay2:
ldy
dey
bne *-1
lsr.zp $ff, x
dex
bne delay2
sta $1c00
wait: lda $1c05
beq wait
lda $1c04
bpl wait
sec
sbc $1804
bmi out
cmp
bcs wait
out:
lda $1804
ldy $1805
sta $1808
sty $1809
stx $1805
stx $1c05
lda
sta $1c02
lda
sta $1c0b
dex
txs
jmp ($0700)