-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrawdec.macros
125 lines (107 loc) · 1.72 KB
/
rawdec.macros
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
macro
loopBody320 &iters
lcla &n
.top320
ldx |2*&n,Y
lda >BCT320,X
ldx destOfst
sta >destBuf+&n,X
&n seta &n+1
aif &n<&iters,.top320
mend
macro
loopBody640 &iters
lcla &n
.top640
ldx |4*&n,Y
lda >BCT640A,X
ldx |4*&n+2,Y
ora >BCT640B,X
ldx destOfst
sta >destBuf+&n,X
&n seta &n+1
aif &n<&iters,.top640
mend
macro
rawDec &mode,&unroll
lclc &loopBdy
lcla &bytePix
&loopBdy setc 'loopBody'+&mode
&bytePix seta &mode/160
tdc
tax
lda |dpPtr
tcd set new direct page
stx oldDP save direct page on entry
phb
phb
pla
sta oldDB save data bank on entry
lda 10,S
pha leaves extra byte: clean up later
plb initialize data bank=bank of lineDataPtr
lda 8+1,S initialize y = lineDataPtr (low 16 bits)
tay
pla move return address to proper position
sta 8-1,S
pla
sta 10-3,S
plx
stx destOfst initialize x = destOfst = startOffset
pla
sta endOfst initialize endOfst = endOffset
sec
sbc #&unroll-1
bcs doLoop1 if endOffset-7 did not underflow...
jmp test2
doLoop1 sta loop1End initialize loop1End = endOffset - 7
txa a = startOffset
jmp test1
loop1 anop
sep #$20
longa off
&loopBdy &unroll
rep #$20
longa on
tya
adc #&unroll*&bytePix carry must be clear
tay
bcs incDB1
cont1 txa
adc #&unroll carry must be clear
sta destOfst
test1 cmp loop1End
bge check2
jmp loop1
check2 cmp endOfst
bge end
loop2 anop
&loopBdy 1
inx
stx destOfst
tya
adc #&bytePix carry must be clear
tay
bcs incDB2
test2 cpx endOfst
blt loop2
end phb
plx x = old DB (high byte of lineDataPtr)
pei (oldDB)
plb restore data bank
plb
lda oldDP
tcd restore direct page
tya a = lineDataPtr (low 16 bits)
rtl
incDB1 pea cont1-1
bra incDB
incDB2 pea test2-1
incDB phb
pla
inc A
pha
plb
clc
rts
mend