-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsh2_draw4b.s
More file actions
226 lines (206 loc) · 7.14 KB
/
sh2_draw4b.s
File metadata and controls
226 lines (206 loc) · 7.14 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
! Original code by Chilly Willy
.section .sdata
.equ DOOMTLS_COLORMAP, 16
! Draw a vertical column of pixels from a projected wall texture.
! Source is the top of the column to scale.
!
!void I_Draw4bColumn(int dc_x, int dc_yl, int dc_yh, int light, fixed_t frac,
! fixed_t fracstep, inpixel_t *dc_source, int dc_texheight)
.align 4
.global _I_Draw4bColumnA
_I_Draw4bColumnA:
add #1,r6
0:
cmp/ge r6,r5
bf/s 1f
sub r5,r6 /* count = dc_yh - dc_yl */
/* dc_yl >= dc_yh, exit */
rts
nop
1:
mov.l r8,@-r15
mov.l r9,@-r15
mov.l @(DOOMTLS_COLORMAP, gbr),r0
shlr2 r7 /* light >>= 3 */
shlr r7
add r0,r7 /* dc_colormap = colormap + light */
mov.l draw_fb,r8
mov.l @r8,r8 /* frame buffer start */
add r4,r8 /* fb += dc_x */
shll8 r5
add r5,r8
shlr2 r5
add r5,r8 /* fb += (dc_yl*256 + dc_yl*64) */
mov.l @(8,r15),r2 /* frac */
mov.l @(12,r15),r3 /* fracstep */
mov.l @(16,r15),r5 /* dc_source */
mov.l @(20,r15),r4
mov.l draw_width,r1
add #-1,r4 /* heightmask = texheight - 1 */
swap.w r2,r0 /* (frac >> 16) */
sub r1,r8 /* fb -= SCREENWIDTH */
/* test if count & 1 */
shlr r6
movt r9 /* 1 if count was odd */
bt/s do_col4b_loop_odd
add r9,r6
.p2alignw 1, 0x0009
do_col4b_loop:
and r4,r0 /* (frac >> 16) & heightmask */
shlr r0 /* convert nibble to byte */
mov.b @(r0,r5),r0 /* pix = dc_source[(frac >> 16) & heightmask] */
add r3,r2 /* frac += fracstep */
# byte to nibble
# note that the upper and lower nibbles are pre-swapped
# in the texture data to avoid doing more address math here
bt/s do_col4b_loop_noshift
add r1,r8 /* fb += SCREENWIDTH */
shlr2 r0
shlr2 r0
do_col4b_loop_noshift:
and #15,r0
add r0,r0
mov.b @(r0,r7),r9 /* dpix = dc_colormap[pix] */
swap.w r2,r0 /* (frac >> 16) */
mov.b r9,@r8 /* *fb = dpix */
do_col4b_loop_odd:
and r4,r0 /* (frac >> 16) & heightmask */
shlr r0 /* convert nibble to byte */
mov.b @(r0,r5),r0 /* pix = dc_source[(frac >> 16) & heightmask] */
add r3,r2 /* frac += fracstep */
# byte to nibble
# note that the upper and lower nibbles are pre-swapped
# in the texture data to avoid doing more address math here
bt/s do_col4b_loop_odd_noshift
add r1,r8 /* fb += SCREENWIDTH */
shlr2 r0
shlr2 r0
do_col4b_loop_odd_noshift:
and #15,r0
add r0,r0
mov.b @(r0,r7),r9 /* dpix = dc_colormap[pix] */
dt r6
mov.b r9,@r8 /* *fb = dpix */
bf/s do_col4b_loop
swap.w r2,r0 /* (frac >> 16) */
mov.l @r15+,r9
rts
mov.l @r15+,r8
! Draw a vertical column of pixels from a projected wall texture.
! Non-power of 2 texture height.
!
!void I_Draw4bColumnNPO2(int dc_x, int dc_yl, int dc_yh, int light, fixed_t frac,
! fixed_t fracstep, inpixel_t *dc_source, int dc_texheight)
.align 4
.global _I_Draw4bColumnNPo2A
_I_Draw4bColumnNPo2A:
add #1,r6
0:
cmp/ge r6,r5
bf/s 1f
sub r5,r6 /* count = dc_yh - dc_yl */
/* dc_yl >= dc_yh, exit */
rts
nop
1:
mov.l r8,@-r15
mov.l @(DOOMTLS_COLORMAP, gbr),r0
shlr2 r7 /* light >>= 3 */
shlr r7
add r0,r7 /* dc_colormap = colormap + light */
mov.l draw_fb,r8
mov.l @r8,r8 /* frame buffer start */
add r4,r8 /* fb += dc_x */
shll8 r5
add r5,r8
shlr2 r5
add r5,r8 /* fb += (dc_yl*256 + dc_yl*64) */
mov.l @(4,r15),r2 /* frac */
mov.l @(8,r15),r3 /* fracstep */
mov.l @(12,r15),r5 /* dc_source */
mov.l @(16,r15),r4
shll16 r4 /* heightmask = texheight << FRACBITS */
mov #0,r0
cmp/ge r0,r2
bt 3f
/* if (frac < 0) */
2:
add r4,r2 /* frac += heightmask */
cmp/ge r0,r2
bf 2b
bt 5f
3:
cmp/ge r4,r2
bf 5f
/* if (frac >= heightmask) */
4:
sub r4,r2 /* frac -= heightmask */
cmp/ge r4,r2
bt 4b
5:
mov.l draw_width,r1
sub r1,r8 /* fb -= SCREENWIDTH */
mov r2,r0
/* test if count & 1 */
shlr r6
movt r0 /* 1 if count was odd */
bt/s do_cnp4b_loop_odd
add r0,r6
.p2alignw 1, 0x0009
do_cnp4b_loop:
shlr16 r0 /* frac >> 16 */
shlr r0 /* convert nibble to byte */
mov.b @(r0,r5),r0 /* pix = dc_source[frac >> 16] */
# byte to nibble
# note that the upper and lower nibbles are pre-swapped
# in the texture data to avoid doing more address math here
add r3,r2 /* frac += fracstep */
bt/s do_cnp4b_loop_noshift
add r1,r8 /* fb += SCREENWIDTH */
shlr2 r0
shlr2 r0
do_cnp4b_loop_noshift:
and #15,r0
add r0,r0
mov.b @(r0,r7),r0 /* dpix = dc_colormap[pix] */
cmp/ge r4,r2
bf 1f
/* if (frac >= heightmask) */
sub r4,r2 /* frac -= heightmask */
1:
mov.b r0,@r8 /* *fb = dpix */
mov r2,r0
do_cnp4b_loop_odd:
shlr16 r0 /* frac >> 16 */
shlr r0 /* convert nibble to byte */
mov.b @(r0,r5),r0 /* pix = dc_source[frac >> 16] */
# byte to nibble
# note that the upper and lower nibbles are pre-swapped
# in the texture data to avoid doing more address math here
add r3,r2 /* frac += fracstep */
bt/s do_cnp4b_loop_odd_noshift
add r1,r8 /* fb += SCREENWIDTH */
shlr2 r0
shlr2 r0
do_cnp4b_loop_odd_noshift:
and #15,r0
add r0,r0
mov.b @(r0,r7),r0 /* dpix = dc_colormap[pix] */
cmp/ge r4,r2
bf 2f
/* if (frac >= heightmask) */
sub r4,r2 /* frac -= heightmask */
2:
mov.b r0,@r8 /* *fb = dpix */
dt r6 /* count-- */
bf/s do_cnp4b_loop
mov r2,r0
rts
mov.l @r15+,r8
.align 2
draw_fb:
.long _viewportbuffer
draw_width:
.long 320
draw_height:
.long _viewportHeight