source: trunk/AIR-BOOT/SOURCE/SPECIAL/FX.ASM@ 10

Last change on this file since 10 was 8, checked in by kiewitz, 23 years ago

Added AiR-BOOT Images and support for other languages.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 17.1 KB
Line 
1
2; Disclaimer:
3;=============
4; The sourcecode is released via www.netlabs.org CVS *ONLY*.
5; You MUST NOT upload it to other servers nor republish it in any way.
6; The sourcecode is still COPYRIGHTED and NOT YET RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2002 by Martin Kiewitz.
8; You may recompile the source and do *PRIVATE* modifications, but please keep
9; in mind that modifying this code needs at least *some* assembly skill. If
10; you mess up your system, because you needed to hack your way through, don't
11; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
12; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
13; idea about new functionality *before* developing the code, otherwise I will
14; definitely reject it. Also please accept, that I have some basic design
15; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
16; another GRUB.
17
18;---------------------------------------------------------------------------
19; AiR-BOOT / F/X
20;---------------------------------------------------------------------------
21
22; There you go. Some nice old-school demo coder effects :)
23; If you rip this code, I will ./ your ass. =]
24
25Include SPECIAL\FXTABLES.asm
26
27FX_MaxScanLine equ 384
28FX_TotalCooperBars equ 7
29
30FX_CalculateTables Proc Near Uses
31 ; Calculate the Cooper-Bar Color-Table -> FX_CooperColors
32 mov di, offset FX_CooperColors
33 mov ax, 000Fh ; Red
34 call FX_MakeCooperBarColors
35 mov ax, 0FF0h ; Pink
36 call FX_MakeCooperBarColors
37 mov ax, 0F0Fh ; Bright Blue
38 call FX_MakeCooperBarColors
39 mov ax, 0F00h ; Blue
40 call FX_MakeCooperBarColors
41 mov ax, 00FFh ; Yellow
42 call FX_MakeCooperBarColors
43 mov ax, 00F0h ; Green
44 call FX_MakeCooperBarColors
45 mov ax, 0FFFh ; White
46 call FX_MakeCooperBarColors
47 ret
48FX_CalculateTables EndP
49
50; This routine will dump a color-table to ES:[DI]. Total of 96 bytes.
51; In: AX - Color-Separator (RGB, per value 4 bit)
52; DI - Pointer to Buffer for Color-Table
53; Out: *none*
54; Destroyed: DI - updated, +96
55FX_MakeCooperBarColors Proc Near Uses
56 mov bh, ah
57 shl bh, 4
58 or bh, ah ; BH - Blue-Value, now 00h or FFh
59 mov dh, al
60 mov bl, al
61 shr dh, 4
62 and bl, 0F0h
63 or dh, bl ; DH - Green-Value, now 00h or FFh
64 mov dl, al
65 and al, 00Fh
66 shl dl, 4
67 or dl, al ; DL - Red-Value, now 00h or FFh
68 mov ax, 1111h
69 mov bl, 11h ; Start-Values
70 mov cx, 15
71 FX_MCBC_BuildColorLoop1:
72 add ax, 0303h
73 add bl, 03h
74 and ax, dx
75 and bl, bh
76 mov es:[di], ax
77 mov es:[di+2], bl
78 add di, 3
79 loop FX_MCBC_BuildColorLoop1
80 push ax bx
81 add ax, 0101h
82 add bl, 01h
83 and ax, dx
84 and bl, bh
85 mov es:[di], ax
86 mov es:[di+2], bl
87 mov es:[di+3], ax
88 mov es:[di+5], bl
89 add di, 6
90 pop bx ax
91 mov cx, 15
92 FX_MCBC_BuildColorLoop2:
93 and ax, dx
94 and bl, bh
95 mov es:[di], ax
96 mov es:[di+2], bl
97 add di, 3
98 sub ax, 0303h
99 sub bl, 03h
100 loop FX_MCBC_BuildColorLoop2
101 ret
102FX_MakeCooperBarColors EndP
103
104; This is called just before a new screen is generated
105; If FX is active, we will modify the base segment for videoio to page 2,
106; so the screen will be generated there instead of the current page.
107FX_StartScreen Proc Near Uses
108 test CFG_CooperBars, 1
109 jz FXSS_NoFX
110 mov VideoIO_Segment, VideoIO_Page2
111 FXSS_NoFX:
112 ret
113FX_StartScreen EndP
114
115; This is called, when a new screen was done
116; If FX is active, we will copy the new screen to scroll area, do the FX,
117; copy the new screen to Page 0 and activate it.
118FX_EndScreenLeft Proc Near Uses
119 test CFG_CooperBars, 1
120 jnz FXESL_Go
121 ret
122 FXESL_Go:
123 pusha
124 mov ax, VideoIO_Page2
125 mov bx, VideoIO_Page0
126 mov dx, 160
127 xor di, di
128 call FX_InterleaveCopy
129 call FX_ScrollScreenLeft
130
131 mov ax, VideoIO_Page2
132 call VideoIO_RestoreFrom
133 mov VideoIO_Segment, VideoIO_Page0
134 call FX_EndScreenInternalCleanUp
135 popa
136 ret
137FX_EndScreenLeft EndP
138
139FX_ScrollScreenLeft Proc Near Uses
140 mov FX_WideScrollerCurPos, 640
141 mov FX_WideScrollerDirection, 0
142 mov FX_WideScrollerAbsDirection, 0
143 call FX_EndScreenInternalGo
144 ret
145FX_ScrollScreenLeft EndP
146
147FX_EndScreenRight Proc Near Uses
148 test CFG_CooperBars, 1
149 jnz FXESR_Go
150 ret
151 FXESR_Go:
152 pusha
153 mov ax, VideoIO_Page0
154 mov bx, VideoIO_Page2
155 mov dx, 160
156 xor di, di
157 call FX_InterleaveCopy
158 call FX_ScrollScreenRight
159
160 mov ax, VideoIO_Page2
161 call VideoIO_RestoreFrom
162 mov VideoIO_Segment, VideoIO_Page0
163 call FX_EndScreenInternalCleanUp
164 popa
165 ret
166FX_EndScreenRight EndP
167
168FX_ScrollScreenRight Proc Near Uses
169 mov FX_WideScrollerCurPos, 0
170 mov FX_WideScrollerDirection, 1
171 mov FX_WideScrollerAbsDirection, 1
172 call FX_EndScreenInternalGo
173 ret
174FX_ScrollScreenRight EndP
175
176FX_EndScreenInternalGo Proc Near Uses
177 mov FX_WideScrollerSpeed, 1
178 mov FX_WideScrollerSpeedState, 1
179 mov FX_WideScrollerBounceSpeed, 25
180 ; Check, if this is 1st time call...
181 inc FX_UseCount
182 cmp FX_UseCount, 1
183 jne FX_ES_NotFirstTime
184 mov FX_OverallTimer, 220
185 mov FX_WideScrollerTimer, 93
186 mov FX_CooperBarsTimer, 1
187 jmp FX_ES_NowGoMagic
188 FX_ES_NotFirstTime:
189 mov FX_OverallTimer, 127
190 mov FX_WideScrollerTimer, 1
191 mov FX_CooperBarsTimer, -1 ; Disable coopers on further goes
192 FX_ES_NowGoMagic:
193 call FX_MakeMagicalStuff
194 ret
195FX_EndScreenInternalGo EndP
196
197FX_EndScreenInternalCleanUp Proc Near Uses
198 mov ax, -1
199 call FX_SetVideoStart
200 call FX_WaitRetrace
201 mov ax, 80
202 call FX_SetWideLength
203 ret
204FX_EndScreenInternalCleanUp EndP
205
206; In: AX - 1st Page Segment
207; BX - 2nd Page Segment
208; DX - Space to interleave
209; DI - Destination offset for Page 4
210; Out: Both pages interleaved to Page 4
211; Destroyed: AX, CX, SI, DI
212FX_InterleaveCopy Proc Near
213 push di
214 call FX_InterleaveCopyPage
215 pop di
216 add di, dx
217 mov ax, bx
218 call FX_InterleaveCopyPage
219 ret
220FX_InterleaveCopy EndP
221
222FX_InterleaveCopyPage Proc Near Uses ds es
223 mov ds, ax
224 mov ax, VideoIO_Page4
225 mov es, ax
226 xor si, si
227 FXIC_CopyLoop:
228 mov cx, 80
229 rep movsw
230 add di, dx
231 cmp si, 1000h
232 jb FXIC_CopyLoop
233 ret
234FX_InterleaveCopyPage EndP
235
236FX_MakeMagicalStuff Proc Near Uses es
237 ; Initiate Cooper-Variables...
238 push ds
239 pop es
240 mov di, offset FX_CooperState
241 mov cx, 7
242 xor al, al
243 rep stosb ; Initiates FX_CooperState
244 mov cx, 7
245 dec al ; AX = 255
246 rep stosb ; Initiates FX_SinusPos
247 mov si, offset FX_StartCooperPos
248 mov cx, 7
249 rep movsw ; Initiates FX_CooperPos
250
251 call FX_WaitRetrace
252 FX_MMS_RetraceLoop:
253 mov dx, 3C8h
254 xor al, al
255 out dx, al
256 inc dx
257 out dx, al
258 out dx, al
259 call FX_WaitRetrace
260 mov dx, 3C9h
261 xor al, al
262 out dx, al ; Really set background color now
263
264 xor di, di ; DI - Cur Scan-Line Counter
265 FX_MCS_VerticalLoop:
266 call FX_ColorUpVLine
267 inc di
268 cmp di, FX_MaxScanLine
269 jb FX_MCS_VerticalLoop
270
271 mov ax, FX_CooperBarsTimer
272 dec ax
273 jnz FX_MMS_CooperBarsPending
274 ; Here we need to calculate the movements of the Coopers...at last
275 call FX_CalculateCoopers
276 mov ax, 1
277 FX_MMS_CooperBarsPending:
278 mov FX_CooperBarsTimer, ax
279
280 mov ax, FX_WideScrollerTimer
281 dec ax
282 jnz FX_MMS_WideScrollerPending
283 call FX_CalculateWideScroller
284 mov ax, 1
285 FX_MMS_WideScrollerPending:
286 mov FX_WideScrollerTimer, ax
287
288 dec FX_OverallTimer
289 jnz FX_MMS_RetraceLoop
290 ret
291FX_MakeMagicalStuff EndP
292
293; This routine is called per VRetrace, it will look for a CooperBar to display
294; and color the Vertical Screen Line in the specified color
295; In: DI - Vertical Line Counter
296; Out: *none*
297; Destroyed: all, but DI
298FX_ColorUpVLine Proc Near Uses di
299 add di, 256 ; Real-Scanlines begin at 256 here
300 mov si, offset FX_CooperPos
301 xor cx, cx
302 FX_CUVL_SearchCooperLoop:
303 lodsw
304 mov dx, ax ; AX - First VRLine used by Cooper
305 add dx, 32 ; DX - Last VRLine used by Cooper
306 cmp di, ax
307 jb FX_CUVL_CooperNoHit
308 cmp di, dx
309 jb FX_CUVL_CooperGotHit
310 FX_CUVL_CooperNoHit:
311 inc cx
312 cmp cx, FX_TotalCooperBars
313 jb FX_CUVL_SearchCooperLoop
314 FX_CUVL_CooperNotVisible:
315 xor bx, bx
316 xor cl, cl ; No Cooper -> So use Color [0/0/0]
317 jmp FX_CUVL_ColorLine
318
319 ; Okay, we got a cooper...now calculate color and done...
320 FX_CUVL_CooperGotHit:
321 mov dx, di
322 sub dx, ax ; DX - Relative Pos within cooper
323 mov bx, cx
324 shl bx, 5 ; * 32
325 mov ax, bx
326 add bx, bx
327 add bx, ax ; BX = CurCooper*96
328 add bx, dx
329 add bx, dx
330 add bx, dx ; Plus RelativePos * 3
331 mov cl, bptr ds:[FX_CooperColors+bx+2]
332 mov bx, wptr ds:[FX_CooperColors+bx]
333
334 FX_CUVL_ColorLine:
335 mov dx, 3C8h
336 xor al, al
337 out dx, al
338 inc dx
339 mov al, bl
340 out dx, al
341 mov al, bh
342 out dx, al
343 call FX_WaitVRetrace
344 mov dx, 3C9h
345 mov al, cl
346 out dx, al ; Colord on VRetrace...
347 ret
348FX_ColorUpVLine EndP
349
350; This routine is called to move the cooper bars on screen... It's called on
351; every Retrace.
352; In: *none*
353; Out: *none*
354; Destroyed: all
355FX_CalculateCoopers Proc Near Uses
356 ; Logic: When Intro-State: Increase CooperPos by 1 till 256 -> then active
357 ; Active-State: Use SinusTable, till SinusPos=7Fh -> then Extro
358 ; Extro-State: Decrease CooperPos by 1 till 0
359
360 xor si, si
361 FX_CC_CalcLoop:
362 cmp bptr ds:[FX_CooperState+si], 1
363 jb FX_CC_IntroState
364 je FX_CC_ActiveState
365 ja FX_CC_ExtroState
366 jmp FX_CC_CalcLoopEnd
367 FX_CC_IntroState:
368 mov bx, si
369 shl bx, 1
370 mov ax, wptr ds:[FX_CooperPos+bx]
371 inc ax
372 mov wptr ds:[FX_CooperPos+bx], ax
373 cmp ax, 256 ; Got into Active-State ?
374 jb FX_CC_CalcLoopEnd
375 inc bptr ds:[FX_CooperState+si]
376 jmp FX_CC_CalcLoopEnd
377 FX_CC_ExtroState:
378 mov bx, si
379 shl bx, 1
380 mov ax, wptr ds:[FX_CooperPos+bx]
381 dec ax
382 jz FX_CC_CalcLoopEnd
383 mov wptr ds:[FX_CooperPos+bx], ax
384 jmp FX_CC_CalcLoopEnd
385
386 FX_CC_ActiveState:
387 ; increment SinusPos by 1
388 movzx bx, bptr ds:[FX_SinusPos+si]
389 inc bx
390 mov bptr ds:[FX_SinusPos+si], bl
391 cmp bl, 7Fh
392 jne FX_CC_ActiveNoStateChange
393 inc bptr ds:[FX_CooperState+si]
394 FX_CC_ActiveNoStateChange:
395 ; Get SinusTab-Value for [BX] and put it to CooperPos-Table for easy xs
396 and bx, 7Fh
397 shl bx, 1
398 mov ax, wptr es:[FX_SinusTab+bx]
399 mov bx, si
400 shl bx, 1
401 mov wptr ds:[FX_CooperPos+bx], ax
402 FX_CC_CalcLoopEnd:
403 inc si
404 cmp si, FX_TotalCooperBars
405 jb FX_CC_CalcLoop
406 ret
407FX_CalculateCoopers EndP
408
409FX_CalculateWideScroller Proc Near Uses
410 mov bx, FX_WideScrollerCurPos
411 movzx cx, FX_WideScrollerSpeed
412 test FX_WideScrollerAbsDirection, 1
413 jnz FXCWS_RIGHT
414 jmp FXCWS_LEFT
415
416 ; ================================================== WideScroll: LEFT CALC
417 FXCWS_LEFT:
418 test FX_WideScrollerSpeedState, 1
419 jz FXCWS_LEFT_Bouncing
420 or bx, bx
421 jz FXCWS_LEFT_BounceNOW
422 jmp FXCWS_DoSpeedThing
423
424 FXCWS_LEFT_Bouncing:
425 or cx, cx
426 jnz FXCWS_DoSpeedThing
427 mov FX_WideScrollerSpeedState, 1
428 mov FX_WideScrollerDirection, 0
429 mov dl, FX_WideScrollerBounceSpeed
430 shr dl,1
431 mov FX_WideScrollerBounceSpeed, dl
432 jmp FXCWS_DoSpeedThing
433
434 FXCWS_LEFT_BounceNOW:
435 mov cl, FX_WideScrollerBounceSpeed
436 mov FX_WideScrollerSpeedState, 0
437 mov FX_WideScrollerDirection, 1
438 jmp FXCWS_DoSpeedThing
439
440 ; ================================================= WideScroll: RIGHT CALC
441 FXCWS_RIGHT:
442 test FX_WideScrollerSpeedState, 1
443 jz FXCWS_RIGHT_Bouncing
444 cmp bx, 640 ; 1280
445 jae FXCWS_RIGHT_BounceNOW
446 jmp FXCWS_DoSpeedThing
447
448 FXCWS_RIGHT_Bouncing:
449 or cl, cl
450 jnz FXCWS_DoSpeedThing
451 mov FX_WideScrollerSpeedState, 1
452 mov FX_WideScrollerDirection, 1
453 mov dl, FX_WideScrollerBounceSpeed
454 shr dl, 1
455 mov FX_WideScrollerBounceSpeed, dl
456 jmp FXCWS_DoSpeedThing
457
458 FXCWS_RIGHT_BounceNOW:
459 mov cl, FX_WideScrollerBounceSpeed
460 mov FX_WideScrollerSpeedState, 0
461 mov FX_WideScrollerDirection, 0
462 jmp FXCWS_DoSpeedThing
463
464 ; ================================================= WideScroll: SPEED CALC
465 FXCWS_DoSpeedThing:
466 test FX_WideScrollerSpeedState, 1
467 jnz FXCWS_SpeedUp
468 FXCWS_SpeedDown:
469 or cl, cl
470 jz FXCWS_WideScrollNOW
471 dec cl
472 jmp FXCWS_WideScrollNOW
473
474 FXCWS_SpeedUp:
475 cmp cl, 25
476 jge FXCWS_WideScrollNOW
477 inc cl
478 jmp FXCWS_WideScrollNOW
479
480 ; ================================================== WideScroll: DO SCROLL
481 FXCWS_WideScrollNOW:
482 xor ch, ch
483 test FX_WideScrollerDirection, 1
484 jnz FXCWS_ScrollRIGHT
485 sub bx, cx
486 jmp FXCWS_Continue
487 FXCWS_ScrollRIGHT:
488 add bx, cx
489 FXCWS_Continue:
490 cmp bx, 5555h ; Zu gross <g>
491 jb FXCWS_NotToSmall
492 mov bx, 0
493 FXCWS_NotToSmall:
494 cmp bx, 640 ; 1280
495 jb FXCWS_NotToBig
496 mov bx, 640 ; 1280
497 FXCWS_NotToBig:
498 mov FX_WideScrollerCurPos, bx
499 mov FX_WideScrollerSpeed, cl
500 mov ax, 160
501 call FX_SetWideLength
502 mov ax, bx
503 call FX_SetVideoStart
504 ret
505FX_CalculateWideScroller EndP
506
507FX_WaitRetrace Proc Near Uses
508 mov dx, 3DAh
509 FX_WR1:
510 in al,dx
511 test al,8
512 jnz FX_WR1
513 FX_WR2:
514 in al,dx
515 test al,8
516 jz FX_WR2
517 ret
518FX_WaitRetrace EndP
519
520FX_WaitVRetrace Proc Near Uses
521 mov dx, 3DAh
522 FX_WVR1:
523 in al,dx
524 test al,1
525 jnz FX_WVR1
526 FX_WVR2:
527 in al,dx
528 test al,1
529 jz FX_WVR2
530 ret
531FX_WaitVRetrace EndP
532
533FX_SetVideoStart Proc Near Uses bx cx dx
534 cmp ax, -1
535 je FXSVS_Reset
536 mov bx, ax
537 mov cl, al
538 shr bx, 3
539 and cl, 7
540 add bx, 2000h ; Start at BC00h (Offset 4000h)
541 or cl, cl
542 jnz FXSVS_SetValues
543 mov cl, 31 ; BX - StartAddr, CL - ShiftReg
544 jmp FXSVS_SetValues
545 FXSVS_Reset:
546 xor bx, bx ; StartAddr==0, ShiftReg==31
547 mov cl, 31
548 FXSVS_SetValues:
549 mov dx, 3D4h
550 mov al, 0Ch
551 mov ah, bh
552 out dx, ax ; Set Start-Address
553 inc al
554 mov ah, bl
555 out dx, ax
556
557 mov dx, 3C0h
558 mov al, 33h
559 out dx, al
560 mov al, cl
561 out dx, al ; Set Shift-Register
562 ret
563FX_SetVideoStart EndP
564
565FX_SetWideLength Proc Near Uses dx
566 shr ax, 1 ; Divide by 2
567 mov ah, al
568 mov dx, 3D4h
569 mov al, 13h
570 out dx, ax
571 ret
572FX_SetWideLength EndP
Note: See TracBrowser for help on using the repository browser.