-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.i
192 lines (154 loc) · 4.07 KB
/
startup.i
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
INTENASET = %1100000000100000
; ab-------cdefg--
; a: SET/CLR Bit
; b: Master Bit
; c: Blitter Int
; d: Vert Blank Int
; e: Copper Int
; f: IO Ports/Timers
; g: Software Int
DMASET = %1000001111000000
; a----bcdefghi--j
; a: SET/CLR Bit
; b: Blitter Priority
; c: Enable DMA
; d: Bit Plane DMA
; e: Copper DMA
; f: Blitter DMA
; g: Sprite DMA
; h: Disk DMA
; i..j: Audio Channel 0-3
; PRINTT
; PRINTT "MINI STARTUP BY STINGRAY/[S]CARAB^SCOOPEX"
; PRINTT " .oO LAST CHANGE: THU, 02-JAN-2020 Oo."
; PRINTT
***************************************************
*** MACRO DEFINITION ***
***************************************************
WAITBLIT MACRO
tst.b $02(a6)
.\@ btst #6,$02(a6)
bne.b .\@
ENDM
***************************************************
*** CLOSE DOWN SYSTEM - INIT PROGRAM ***
***************************************************
START movem.l d0-a6,-(a7)
move.l $4.w,a6
lea .VARS_HW(pc),a5
move.l a5,a1
moveq #0,d0
jsr -552(a6) ; OpenLibrary()
move.l d0,.GFXbase-.VARS_HW(a5)
beq.b .END
move.l d0,a6
move.l 34(a6),.OldView-.VARS_HW(a5)
sub.l a1,a1
bsr.w .DoView
move.l $26(a6),.OldCop1-.VARS_HW(a5) ; Store old CL 1
move.l $32(a6),.OldCop2-.VARS_HW(a5) ; Store old CL 2
bsr .GetVBR
move.l d0,.VBRptr-.VARS_HW(a5)
move.l d0,a0
*** Store Custom Regs ***
lea $dff000,a6 ; base address
move.w $10(a6),.ADK-.VARS_HW(a5) ; Store old ADKCON
move.w $1C(a6),.INTENA-.VARS_HW(a5) ; Store old INTENA
move.w $02(a6),.DMA-.VARS_HW(a5) ; Store old DMA
move.w #$7FFF,d0
bsr WaitRaster
move.w d0,$9A(a6) ; Disable Interrupts
move.w d0,$96(a6) ; Clear all DMA channels
move.w d0,$9C(a6) ; Clear all INT requests
move.l $6c(a0),.OldVBI-.VARS_HW(a5)
lea .NewVBI(pc),a1
move.l a1,$6c(a0)
; move.w #INTENASET!$C000,$9A(a6) ; set Interrupts+ BIT 14/15
; move.w #DMASET!$8200,$96(a6) ; set DMA + BIT 09/15
bsr MAIN
***************************************************
*** Restore Sytem Parameter etc. ***
***************************************************
.END lea .VARS_HW(pc),a5
lea $dff000,a6
clr.l VBIptr-.VARS_HW(a5)
move.w #$8000,d0
or.w d0,.INTENA-.VARS_HW(a5) ; SET/CLR-Bit to 1
or.w d0,.DMA-.VARS_HW(a5) ; SET/CLR-Bit to 1
or.w d0,.ADK-.VARS_HW(a5) ; SET/CLR-Bit to 1
subq.w #1,d0
bsr WaitRaster
move.w d0,$9A(a6) ; Clear all INT bits
move.w d0,$96(a6) ; Clear all DMA channels
move.w d0,$9C(a6) ; Clear all INT requests
move.l .VBRptr(pc),a0
move.l .OldVBI(pc),$6c(a0)
move.l .OldCop1(pc),$80(a6) ; Restore old CL 1
move.l .OldCop2(pc),$84(a6) ; Restore old CL 2
move.w d0,$88(a6) ; start copper1
move.w .INTENA(pc),$9A(a6) ; Restore INTENA
move.w .DMA(pc),$96(a6) ; Restore DMAcon
move.w .ADK(pc),$9E(a6) ; Restore ADKcon
move.l .GFXbase(pc),a6
move.l .OldView(pc),a1 ; restore old viewport
bsr.b .DoView
move.l a6,a1
move.l $4.w,a6
jsr -414(a6) ; Closelibrary()
movem.l (a7)+,d0-a6
moveq #0,d0
rts
.DoView jsr -222(a6) ; LoadView()
jsr -270(a6) ; WaitTOF()
jmp -270(a6)
*******************************************
*** Get Address of the VBR ***
*******************************************
.GetVBR move.l a5,-(a7)
moveq #0,d0 ; default at $0
move.l $4.w,a6
btst #0,296+1(a6) ; 68010+?
beq.b .is68k ; nope.
lea .getit(pc),a5
jsr -30(a6) ; SuperVisor()
.is68k move.l (a7)+,a5
rts
.getit movec vbr,d0
rte ; back to user state code
*******************************************
*** VERTICAL BLANK (VBI) ***
*******************************************
.NewVBI movem.l d0-a6,-(a7)
move.l VBIptr(pc),d0
beq.b .noVBI
move.l d0,a0
jsr (a0)
.noVBI lea $dff09c,a6
moveq #$20,d0
move.w d0,(a6)
move.w d0,(a6) ; twice to avoid a4k hw bug
movem.l (a7)+,d0-a6
rte
*******************************************
*** DATA AREA FAST ***
*******************************************
.VARS_HW
.GFXname dc.b 'graphics.library',0,0
.GFXbase dc.l 0
.OldView dc.l 0
.OldCop1 dc.l 0
.OldCop2 dc.l 0
.VBRptr dc.l 0
.OldVBI dc.l 0
.ADK dc.w 0
.INTENA dc.w 0
.DMA dc.w 0
VBIptr dc.l 0
WaitRaster
.wait btst #0,$dff004+1
bne.b .wait
rts
WaitRasterEnd
.wait btst #0,$dff004+1
beq.b .wait
rts