gdma.s
4.59 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
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
*************************************************************************/
/*
* File: gdma.s
* Creator: hsa@sgi.com
* Create Date: Fri Jun 24 13:54:58 PDT 1994
*
* This file holds the top-level of the DMA command processing, and
* related routines.
*
*/
############################################################################
#
# The following code processes the DMA type display list commands.
# Registers on input:
# gfx0 - first word of display list command
# gfx1 - second word of display list command
# in_bufp - where the data has been read into
# dinp - points to the *next* display list command
#
### IMPORTANT!!!: The first instruction here is a branch delay slot
### from grdp.s
.ent doDMA
doDMA:
# $2 is shifted in the delay slot of the branch that
# brought us here...
# 'switch' to correct DMA command:
andi $2, $2, 0x1fe # shifted up 1 for offset
lh $2, DMA_JMP_OFFSET($2)
# 'len' is the same for all commands. But we don't need it here?
# Not double-buffered yet, so we have to wait here for the data...
jal DMAwait
lbu $1, (0-7)(dinp) # pick off first field
jr $2
# this is the same for some commands, so save code space
# and do it here in the delay slot.
andi $6, $1, 0x0f # pick off 'v0' field
.end doDMA
#
#
############################################################################
#ifndef SPRITE2D
############################################################################
#
# Process the G_MTX command.
#
# $1 holds param
# in_bufp holds pointer to data
#
#.name param, $5
# case_G_MTX:
# add param, zero, $1 # move param somewhere safe
#include "gmtx.s"
#.unname param
#
#
#
############################################################################
############################################################################
#
# MOVEMEM handles the VIEWPORT and LIGHT input.
#
.name outptr, $5
.name target, $1
.name buff, $v0
.ent case_G_MOVEMEM
case_G_MOVEMEM:
# $1 (target) holds n (index to target address*2)
# (hi bit set for causing light recomputation)
# in_bufp holds pointer to data
lqv buff[0], 0(in_bufp) # get 4 words
lh outptr,(MOVEMEM_TBL - 0x80)(target) # get target address
j GfxDone # return
sqv buff[0], 0(outptr) # store 4 words
.end case_G_MOVEMEM
.unname outptr
.unname target
.unname buff
#
#
#
############################################################################
############################################################################
#
# Transform, project, & shade as we load into the points buffer.
#
# $1 holds n and v0
# in_bufp holds pointer to data
#
.name tmp, $8
case_G_VTX:
lh tmp,GFXDONE(zero)
sh tmp,RETURNJUMP(zero)
.unname tmp
#include "gvtx.s"
.name tmp, $8
xfm_done:
# NOTE! the first statement here is a branch delay slot
# from the loop in gvtx.s
lh tmp,RETURNJUMP($0)
jr tmp
nop
.unname tmp
#
#
#
############################################################################
#endif /* SPRITE2D */
############################################################################
#
.name stack_sz, $2
.name stack_p, $3
.name tmp, $4
.ent case_G_DL
case_G_DL:
# $1 holds param
# in_bufp holds pointer to data
# check param to see if we need to push
bgtz $1, noPush
# note delay slot...
# if push:
lb stack_sz, RSP_STATE_DL_N(rsp_state)
# check to see if stack is full (10 entries max)
addi tmp, stack_sz, -36
bgtz tmp, GfxDone
# note delay slot
addi stack_p, stack_sz, RSP_DLSTACK_OFFSET
addi stack_sz, stack_sz, 4
sw inp, 0(stack_p) # pointer of DL
sb stack_sz, RSP_STATE_DL_N(rsp_state)
# set some state, prepare to read next list
# set inp to the new pointer, jump to load...
noPush:
jal AddrFixup
add $19, gfx1, zero # delay slot
add inp, $19, zero
j GfxDone
addi dlcount, zero, 0 # delay slot
.end case_G_DL
.unname stack_sz
.unname stack_p
.unname tmp
#
#
#
############################################################################