-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgpubase.gas
169 lines (137 loc) · 2.97 KB
/
gpubase.gas
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
_gpubase::
.gpu
.org $f03000
RISC_FLAGS .equ $f02100
DIVCONTROL .equ $f0211c
MAIN_STACK .equ $f04000
LOADPOINT .equ $f03100
LE .ccdef 4 ; CC
GT .ccdef 8 ; CS
FP .equr r14
scratch .equr r10
scratch2 .equr r11
RETURNVALUE .equr r29
RETURNPOINT .equr r28
MATH_A .equr r27
MATH_B .equr r26
MATH_C .equr r25
MATH_RTS .equr r24
MATH_SIGN .equr r23
R0_VMODE .equr r0
R0_FLAGS .equr r1
R0_INTSTACK .equr r2
R0_MODEBITS .equr r3
R0_TEMP1 .equr r28
R0_TEMP2 .equr r29
R0_TEMP3 .equr r30
R0_ISRSTACK .equr r31
;==============================================================================
;--------------------
;
; interrupt vectors
;
;--------------------
movei #0,r30 ; cpu int
jump T,(r30)
nop
nop
nop
nop
movei #0,r30 ; dsp int
jump T,(r30)
nop
nop
nop
nop
movei #0,r30 ; timing generator
jump T,(r30)
nop
nop
nop
nop
;
; object processor interrupt
;
load (R0_FLAGS),r29 ; get current flags
move R0_VMODE,r30 ; VMODE
storew R0_MODEBITS,(r30)
subq #2,r30 ; $f00026, OBF
storew r28,(r30) ; restart object processor
bclr #3,r29 ; clear IMASK
bset #12,r29 ; and interrupt latch
load (r31),r28 ; get last instruction address
move R0_INTSTACK,r31 ; reset stack
addq #2,r28 ; point to next instruction to execute
jump T,(r28) ; return
store r29,(R0_FLAGS) ; restore flags
.long
_gpucodestart:: .dc.l 0
_gpufinished:: .dc.l 0
_intstack: .dc.l 0,0,0,0 ; give it some room to be flaky...
;-----------------------------------------------------------------------------
;
; init code
;
;-----------------------------------------------------------------------------
_gpubase_init::
movei #RISC_FLAGS,R0_FLAGS
movei #_intstack+8,R0_INTSTACK
move R0_INTSTACK,r31
movei #$f00028,R0_VMODE
movei #$c1+(3<<9),R0_MODEBITS ; 320 mode
movei #(1<<7)+(1<<14),r9 ; enable OBJ, reg page 1
store r9,(R0_FLAGS)
nop ; wait for the reg page to flip
nop
nop
nop
;--------------------
;
; wait for a load command
;
;--------------------
nothingwaiting:
movei #_gpufinished,r7
moveq #1,r1
store r1,(r7) ; set _gpufinished as completion signal
waitcmd:
movei #_gpucodestart,r2
load (r2),r1
or r1,r1
jr EQ,nothingwaiting
nop
movei #_gpufinished,r7
moveq #0,r0
store r0,(r2) ; gpucodestart = 0
store r0,(r7) ; gpufinished = 0
move r1,r2
subq #4,r2
load (r2),r2 ; length is stored just below start address
shrq #3,r2 ; number of phrases to bopy
movei #LOADPOINT,r0 ; destination for code
move r1,r3
move r0,r4
addq #4,r3
addq #4,r4
loadloop:
load (r1),r5
load (r3),r6
store r5,(r0)
addqt #8,r1
addqt #8,r3
store r6,(r4)
subq #1,r2 ; decrement count
addqt #8,r4
jr PL,loadloop
addqt #8,r0
nop
;
; call it
;
movei #LOADPOINT,r0
movei #waitcmd,RETURNPOINT
movei #MAIN_STACK,r14
jump T,(r0)
nop
.phrase
.68000