source: trunk/BOOTCODE/SPECIAL/FX.ASM@ 31

Last change on this file since 31 was 30, checked in by Ben Rietbroek, 15 years ago

AiR-BOOT v1.07 -- As released with eCS v2.1. [2011-05-06]
Signature-date: 2006-03-13. (incorrect)
Trunk contains buildable v1.07 version as distributed with eCS v2.1.
Directory 'tags' contains v1.06 & v1.07 reference versions
built for all languages. Note that language ID for 'Dutch' changed
from 'DT' to 'NL' in v1.07 and that the v1.06 reference version also
uses 'NL' for 'Dutch'.
Also note that helper programs like the installer and setaboot are
are only modified for the OS/2 versions in v1.07.
The signature-date for v1.07 incorrectly states the same
date as for v1.06. The signature-version is correct.
Removed other binaries. (cd-rom images, old releases, etc.)
The tags serve as reference versions:

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