-
Notifications
You must be signed in to change notification settings - Fork 4
/
screensetup.s
316 lines (262 loc) · 7.49 KB
/
screensetup.s
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
IFND BUILD_WITH_C
vid_MyAllocRaster:
move.l #SCREEN_WIDTH,d0 ; want all planes in one chunk of memory
move.l #(SCREEN_HEIGHT*8)+1,d1
CALLGRAF AllocRaster
tst.l d0
rts
Vid_OpenMainScreen:
jsr Vid_InitC2P
; Allocate Buffer 0
lea vid_MainBitmap0,a0
moveq.l #8,d0
move.l #SCREEN_WIDTH,d1
move.l #SCREEN_HEIGHT,d2
CALLGRAF InitBitMap
bsr vid_MyAllocRaster
; beq exit_closeall
move.l d0,Vid_MyRaster0_l
addq.l #7,d0 ; align to 8 byte for FMOD3
and.l #~7,d0
move.l d0,Vid_Screen1Ptr_l
move.l d0,Vid_TextScreenPtr_l ; FIXME: Vid_TextScreenPtr_l should go
lea vid_MainBitmap0+bm_Planes,a1
moveq.l #7,d1
.storePlanePtr0:
move.l d0,(a1)+
add.l #(SCREEN_HEIGHT*(SCREEN_WIDTH/8)),d0
dbra d1,.storePlanePtr0
; Allocate Buffer 1
lea vid_MainBitmap1,a0
moveq.l #8,d0
move.l #SCREEN_WIDTH,d1
move.l #SCREEN_HEIGHT,d2
CALLGRAF InitBitMap
bsr vid_MyAllocRaster
; beq exit_closeall
move.l d0,Vid_MyRaster1_l
addq.l #7,d0 ; align to 8 byte for FMOD3
and.l #~7,d0
move.l d0,Vid_Screen2Ptr_l
lea vid_MainBitmap1+bm_Planes,a1
moveq.l #7,d1
.storePlanePtr1:
move.l d0,(a1)+
add.l #(SCREEN_HEIGHT*(SCREEN_WIDTH/8)),d0
dbra d1,.storePlanePtr1
lea MainNewScreen,a0
lea vid_MainScreenTags_vl,a1
CALLINT OpenScreenTagList
tst.l d0
; beq exit_closeall
move.l d0,Vid_MainScreen_l
move.l Vid_MainScreen_l,a0
lea vid_MainBitmap0,a1
clr.l d0
CALLINT AllocScreenBuffer
tst.l d0
; beq exit_closeall
move.l d0,Vid_ScreenBuffers_vl+0
move.l Vid_MainScreen_l,a0
lea vid_MainBitmap1,a1
clr.l d0
CALLINT AllocScreenBuffer
tst.l d0
; beq exit_closeall
move.l d0,Vid_ScreenBuffers_vl+4
;CALLEXEC CreateMsgPort
;tst.l d0
;; beq exit_closeall
;move.l d0,vid_SafeMsgPort_l ; FIXME: free upon exit
CALLEXEC CreateMsgPort
tst.l d0
; beq exit_closeall
move.l d0,Vid_DisplayMsgPort_l
YYY:
move.l Vid_ScreenBuffers_vl+0,a0
move.l sb_DBufInfo(a0),a0 ; getDBufInfo ptr
; not using vid_SafeMsgPort_l atm.
; Would need to use it to prevent C2P to write to a bitmap thats
; currently scanned out, but haven't seen issues with that so far
;move.l vid_SafeMsgPort_l,dbi_SafeMessage+MN_REPLYPORT(a0)
move.l Vid_DisplayMsgPort_l,dbi_DispMessage+MN_REPLYPORT(a0)
move.l Vid_ScreenBuffers_vl+4,a0
move.l sb_DBufInfo(a0),a0 ; getDBufInfo ptr
;move.l vid_SafeMsgPort_l,dbi_SafeMessage+MN_REPLYPORT(a0)
move.l Vid_DisplayMsgPort_l,dbi_DispMessage+MN_REPLYPORT(a0)
; need a window to be able to clear out mouse pointer
; may later also serve as IDCMP input source
sub.l a0,a0
lea vid_MainWindowTags_vl,a1
move.l Vid_MainScreen_l,MainWTagScreenPtr-vid_MainWindowTags_vl(a1) ; WA_CustomScreen
CALLINT OpenWindowTagList
tst.l d0
; beq exit_closeall
move.l d0,vid_MainWindow_l
move.l d0,a0
lea emptySprite,a1
moveq #1,d0
moveq #16,d1
move.l d0,d2
move.l d0,d3
CALLINT SetPointer
jsr Vid_LoadMainPalette
move.l vid_MainWindow_l,a0
CALLINT ViewPortAddress
move.l d0,a2
move.l vp_ColorMap(a2),a0
lea vid_VidControlTags_vl,a1
CALLGRAF VideoControl
moveq #ucl_SIZEOF,d0
move.l #MEMF_PUBLIC!MEMF_CLEAR,d1
CALLEXEC AllocMem
move.l d0,vid_MyUCopList_l
; Setup a User copperlist to enable doubleheight rendering
move.l _GfxBase,a6
move.l d0,a2
CINIT a2,116*6+4 ; 232 modulos
*******************************************************************************
;Bplmod: The modulo is usually in aga mode the same as in normal mode minus 8.
;So if your normal modulo = 0 then the agamodulo is -8. (if you use FMODE=3!)
;if you use FMODE =$2 then the modulo is -4.
*******************************************************************************
; FMODE is assumed to be 3, but can I somehow query?
moveq.l #$0,d2
.nextLine:
CWAIT a2,d2,#0
CMOVE a2,bpl1mod,#-40-8 ; repeat the line
CMOVE a2,bpl2mod,#-40-8
addq.w #1,d2
CWAIT a2,d2,#0
CMOVE a2,bpl1mod,#40-8 ; skip line
CMOVE a2,bpl2mod,#40-8
addq.w #1,d2
cmp.w #232,d2
blt .nextLine
CWAIT a2,d2,#0
CMOVE a2,bpl1mod,#0-8
CMOVE a2,bpl2mod,#0-8
CEND a2
rts
Vid_CloseMainScreen:
; Use CloseScreen to get rid of UCpoList (see see C source for details)
move.l vid_MainWindow_l,a0
CALLINT ViewPortAddress
move.l d0,a0
move.l vid_MyUCopList_l,vp_UCopIns(a0)
; CloseWindow
move.l vid_MainWindow_l,a0
CALLINT CloseWindow
; FreeScreenBuffer
move.l Vid_MainScreen_l,a0
move.l Vid_ScreenBuffers_vl+0,a1
CALLINT FreeScreenBuffer
move.l Vid_MainScreen_l,a0
move.l Vid_ScreenBuffers_vl+4,a1
CALLINT FreeScreenBuffer
; DeleteMsgPort
move.l Vid_DisplayMsgPort_l,a0
CALLEXEC DeleteMsgPort
; CloseScreen
move.l Vid_MainScreen_l,a0
CALLINT CloseScreen
; FreeRaster
move.l Vid_FastBufferAllocPtr_l,a1
CALLEXEC FreeVec
move.l Vid_MyRaster0_l,a0
move.w #SCREEN_WIDTH,d0
move.w #SCREEN_HEIGHT*8+1,d1
CALLGRAF FreeRaster
move.l Vid_MyRaster1_l,a0
move.w #SCREEN_WIDTH,d0
move.w #SCREEN_HEIGHT*8+1,d1
CALLGRAF FreeRaster
rts
vid_SetupDoubleheightCopperlist:
; Install copperlist
move.l vid_MainWindow_l,a0
CALLINT ViewPortAddress
move.l d0,a2
CALLEXEC Forbid
tst.b Vid_DoubleHeight_b
beq.s .noDoubleheight
move.l vid_MyUCopList_l,vp_UCopIns(a2)
bra.s .install
.noDoubleheight:
move.l #0,vp_UCopIns(a2)
.install:
CALLEXEC Permit
CALLINT RethinkDisplay
rts
align 4
vid_MainScreenTags_vl:
dc.l SA_Width,SCREEN_WIDTH
dc.l SA_Height,SCREEN_HEIGHT
dc.l SA_Depth,8
dc.l SA_BitMap,vid_MainBitmap0
dc.l SA_Type,CUSTOMSCREEN
dc.l SA_Quiet,1
IFNE SCREEN_TITLEBAR_HACK
dc.l SA_ShowTitle,0
ELSE
dc.l SA_ShowTitle,1
ENDC
dc.l SA_AutoScroll,0
dc.l SA_FullPalette,1
dc.l SA_DisplayID,PAL_MONITOR_ID
dc.l TAG_END,0
align 4
MainNewScreen:
dc.w 0 ; ns_LeftEdge
dc.w 0 ; ns_TopEdge
dc.w SCREEN_WIDTH ; ns_Width
dc.w SCREEN_HEIGHT ; ns_Height
dc.w 8 ; ns_Depth
dc.b 0 ; ns_DetailPen
dc.b 0 ; ns_BlockPen
dc.w 0 ; ns_ViewModes
dc.w CUSTOMSCREEN!SCREENQUIET; ns_Type
dc.l 0 ; ns_Font
dc.l 0 ; ns_DefaultTitle
dc.l 0 ; ns_Gadgets
dc.l 0 ; ns_CustomBitMap
align 4
vid_MainWindowTags_vl:
dc.l WA_Left,0
dc.l WA_Top,0
dc.l WA_Width,SCREEN_WIDTH
dc.l WA_Height,SCREEN_HEIGHT
dc.l WA_CustomScreen
MainWTagScreenPtr:
dc.l 0 ; will fill in screen pointer later
dc.l WA_Activate,1
dc.l WA_Borderless,1
dc.l WA_RMBTrap,1 ; prevent menu rendering
dc.l WA_NoCareRefresh,1
dc.l WA_SimpleRefresh,1
dc.l WA_Backdrop,1
dc.l TAG_END,0
align 4
vid_MainBitmap0:
dc.w SCREEN_WIDTH/8 ; bm_BytesPerRow
dc.w SCREEN_HEIGHT ; bm_Rows
dc.b BMF_DISPLAYABLE ; bm_Flags
dc.b 8 ; bm_Depth
dc.w 0 ; bm_Pad
ds.l 8 ; bm_Planes
align 4
vid_MainBitmap1:
dc.w SCREEN_WIDTH/8 ; bm_BytesPerRow
dc.w SCREEN_HEIGHT ; bm_Rows
dc.b BMF_DISPLAYABLE ; bm_Flags
dc.b 8 ; bm_Depth
dc.w 0 ; bm_Pad
ds.l 8 ; bm_Planes
align 4
vid_MyUCopList_l:
ds.l 1
align 4
vid_VidControlTags_vl:
dc.l VTAG_USERCLIP_SET,1
dc.l VTAG_END_CM,0
ENDIF