home *** CD-ROM | disk | FTP | other *** search
/ The Party 1994: Try This At Home / disk_image.bin / source / cbrosrc / main.asm < prev    next >
Assembly Source File  |  1995-03-13  |  27KB  |  997 lines

  1. ;
  2. ; Cosmic Bros
  3. ;
  4. ; I don't usually comment my sources... didnt expect to release this
  5. ; so the code is 'a bit' messy and unoptimized.
  6. ;
  7.  
  8.         ideal
  9.  
  10. frmsize=72*48/2           ; frame size (1728 bytes)  resolution 72x48x16
  11.  
  12. macro   setframerate n
  13.         mov     ax, seg mainvolume
  14.         mov     es, ax
  15.         mov     [es:framespersec], n
  16.         mov     [es:framecounter], 1
  17. endm
  18.  
  19. macro   setfx n
  20.         mov     [cs:anieffect], n
  21. endm
  22.  
  23. macro   setpalette n
  24.         push    cs
  25.         pop     ds
  26.         mov     [cs:palnyt], offset paletit+n*64*3
  27.         call    palettekehiin
  28. endm
  29.  
  30. macro   demo_sequence                   ; useless macro
  31.         setfx 0
  32.         setpalette 0
  33.         setframerate 3
  34.  
  35.         playfade 1415, 7, 1, forward, fadeon
  36.         playfade 1415, 7, 1, forward, fadeoff
  37.         showplane plane1, 3
  38.         setpalette 17
  39.         setframerate 12
  40.  
  41.         setfx 1
  42.         playfade sikio, 25, 1, forward, fadeon
  43.         playvideo (sikio+25), 41, 1, forward
  44.         playfade (sikio+66), 21, 1, forward, fadeoff
  45.         setfx 0
  46.  
  47.         showplane plane2, 3
  48.         setframerate 10
  49.         setpalette 7
  50.         playvideo alku, 57, 1, forward
  51.         setpalette 1
  52.         playvideo (alku+58), 40, 1, forward
  53.  
  54.         setframerate 15
  55.         setpalette 5
  56.         playvideo flight1, 18, 3, forward
  57.  
  58.         setpalette 9
  59.         playvideo savu, 54, 1, forward
  60.         setpalette 0
  61.         playvideo snowbrd2, 60, 1, forward
  62.  
  63.         setpalette 13
  64.         playvideo savu, 54, 1, forward
  65.         setpalette 0
  66.         playvideo (snowbrd2+60), 60, 1, forward
  67.  
  68.         setpalette 5
  69.         playvideo savu, 54, 1, forward
  70.         setpalette 0
  71.         setframerate 12
  72.         playvideo (snowbrd2+120), 55, 1, forward
  73.  
  74.         setframerate 19
  75.         setpalette 14
  76.         playvideo camel, 68, 1, forward
  77.         setframerate 5
  78.         setpalette 7
  79.         playvideo (camel+39), 28, 1, reverse
  80.  
  81.         setframerate 8
  82.         setpalette 11
  83.         playvideo seal3, 91, 1, forward
  84.  
  85.         setframerate 20
  86.         setpalette 8
  87.         playvideo salama, 19, 1, forward
  88.         setframerate 22
  89.         setpalette 3
  90.         playvideo (salama+10), 19, 1, forward
  91.         setframerate 26
  92.         setpalette 0
  93.         playvideo salama, 19, 1, forward
  94.         setframerate 27
  95.         setpalette 5
  96.         playvideo (salama+10), 19, 1, reverse
  97.         setframerate 30
  98.         setpalette 7
  99.         playvideo salama, 29, 1, forward
  100.  
  101.         setpalette 0
  102.         setframerate 4
  103.         setfx 1
  104.         playvideo maa, 7, 2, forward
  105.  
  106.         setfx 0
  107.         setpalette 0
  108.         setframerate 10
  109.         playvideo fingers, 40, 1, forward
  110.         playvideo fingers, 40, 1, reverse
  111.  
  112.         setpalette 8
  113.         setframerate 15
  114.         playvideo seal1, 64, 1, forward
  115.         setpalette 11
  116.         playvideo seal2, 80, 1, forward
  117.         setpalette 8
  118.         playvideo (seal1+17), 160, 1, forward
  119.  
  120.         setframerate 8
  121.         setpalette 0
  122.         playvideo snowbrd1, 47, 1, forward
  123.  
  124.         setframerate 10
  125.         setpalette 10
  126.         playvideo walk_jugi, 20, 1, forward
  127.         setpalette 0
  128.         setframerate 20
  129.         playvideo salama, 20, 1, forward
  130.         setpalette 10
  131.         setframerate 10
  132.         playvideo walk_jugi, 20, 1, forward
  133.         setpalette 6
  134.         setframerate 30
  135.         playvideo (alku+66), 30, 1, reverse
  136.         setpalette 10
  137.         setframerate 10
  138.         playvideo walk_jugi, 20, 1, forward
  139.         setpalette 17
  140.         setframerate 40
  141.         setfx 1
  142.         playvideo (sikio+30), 30, 1, forward
  143.         setfx 0
  144.         setpalette 10
  145.         setframerate 10
  146.         playvideo walk_jugi, 20, 1, forward
  147.         setframerate 25
  148.         setpalette 16
  149.         playvideo rotate, 20, 1, forward
  150.         setpalette 10
  151.         setframerate 10
  152.         playvideo walk_jugi, 20, 1, forward
  153.         setframerate 50
  154.         setpalette 11
  155.         playvideo (seal2+20), 25, 1, reverse
  156.  
  157.         setframerate 37
  158.         setpalette 14
  159.         playvideo camel, 30, 1, forward
  160.         setframerate 10
  161.         setpalette 6
  162.         playvideo (camel+20), 48, 1, reverse
  163.  
  164.         setframerate 12
  165.         setpalette 17
  166.         playvideo (seal1+70), 113, 1, forward
  167.  
  168.         setframerate 15
  169.         setpalette 10
  170.         playvideo snowbrd2, 125, 1, reverse
  171.  
  172.         setframerate 12
  173.         setpalette 17
  174.         playvideo (seal1+0), 150, 1, forward
  175.  
  176.         setfx 1
  177.         setpalette 4
  178.         playvideo salama, 28, 1, forward
  179.         setfx 0
  180.         setpalette 3
  181.         setframerate 11
  182.         playvideo snowbrd1, 47, 1, forward
  183.         setframerate 14
  184.         setpalette 14
  185.         playvideo rotate, 55, 1, forward
  186.         setframerate 10
  187.         setpalette 10
  188.         playvideo haudat, 40, 1, reverse
  189.  
  190.         setframerate 12
  191.         setpalette 11
  192.         playvideo seal2, 120, 1, FORWARD
  193.         setframerate 11
  194.         setpalette 5
  195.         playvideo seal1, 213, 1, reverse
  196.  
  197.         setfx 1
  198.         setframerate 15
  199.         setpalette 10
  200.         playvideo flight1, 18, 3, forward
  201.         setfx 0
  202.  
  203.         setpalette 1
  204.         playvideo savu, 54, 1, forward
  205.         setpalette 12
  206.         setfx 1
  207.         playvideo snowbrd2, 60, 1, forward
  208.         setfx 0
  209.  
  210.         setpalette 14
  211.         playvideo savu, 54, 1, forward
  212.         setpalette 13
  213.         setfx 1
  214.         playvideo (snowbrd2+60), 60, 1, forward
  215.         setfx 0
  216.  
  217.         setpalette 5
  218.         playvideo savu, 54, 1, forward
  219.         setpalette 17
  220.         setfx 1
  221.         playvideo (snowbrd2+120), 55, 1, forward
  222.         setfx 0
  223.  
  224.         setfx 1
  225.         setframerate 19
  226.         setpalette 1
  227.         playvideo camel, 68, 1, forward
  228.         setframerate  9; 5
  229.         setpalette 16
  230.         playvideo (walk_jugi), 51, 1, reverse
  231.  
  232.         setframerate 8
  233.         setpalette 0
  234.         setfx 0
  235.         playvideo seal3, 91, 1, forward
  236.  
  237.         setframerate 24
  238.         setpalette 1
  239.         setfx 1
  240.         playvideo salama, 19, 1, forward
  241.         setfx 0
  242.         setframerate 25
  243.         setpalette 17
  244.         playvideo (salama+10), 19, 1, forward
  245.         setframerate 26
  246.         setpalette 16
  247.         setfx 1
  248.         playvideo salama, 19, 1, forward
  249.         setfx 0
  250.         setframerate 28
  251.         setpalette 12
  252.         playvideo (salama+10), 19, 1, reverse
  253.         setframerate 30
  254.         setpalette 9
  255.         playvideo salama, 29, 1, forward
  256.  
  257.         setpalette 3
  258.         setframerate 6
  259.         playvideo maa, 7, 2, forward
  260.  
  261.         setpalette 1
  262.         setframerate 20
  263.         playvideo seal2, 60, 1, forward
  264.  
  265.         setframerate 24
  266.         setpalette 1
  267.         playvideo sikio, 87, 1, reverse
  268.         setframerate 11
  269.         setpalette 14
  270.         playvideo fingers, 80, 1, forward
  271.         setframerate 13
  272.         setpalette 11
  273.         playvideo haudat, 70, 1, forward
  274.         playvideo fchauta, 118, 1, forward
  275.         playfade (fchauta+111), 8, 4, forward, fadeoff
  276.  
  277.         mov     ax, 13h
  278.         int     10h
  279.         call    vsync
  280.  
  281.         setframerate 5
  282.         setpalette 13
  283.         playfade (fingers+50), 20, 1, forward, fadeon
  284.         playfade (fingers+70), 10, 1, forward, fadeoff
  285. endm
  286.  
  287. ; ----- these are the frame numbers of different video sequences
  288.  
  289. fingers       = 0       ; 80    <- these are approx. lengths, but
  290. flight1       = 81      ; 18       because we dont always play
  291. salama        = 100     ; 29       every sequence to the end, i
  292. snowbrd1      = 129     ; 47       didnt define them as constants
  293. rotate        = 176     ; 55
  294. savu          = 232     ; 54
  295. snowbrd2      = 286     ; 175
  296. walk_jugi     = 462     ; 51
  297. seal1         = 514     ; 213
  298. seal2         = 728     ; 120
  299. seal3         = 848     ; 91
  300. camel         = 938     ; 68
  301. fchauta       = 1008    ; 118
  302. haudat        = 1129    ; 100
  303. sikio         = 1229    ; 87
  304. alku          = 1317    ; 98
  305. maa           = 1415    ; 8
  306.  
  307. forward=1
  308. reverse=-1
  309. fadeon=offset do_fade_on
  310. fadeoff=offset do_fade_off
  311.  
  312. ; video routines are defined as macros... stupid thing to do
  313. ; (takes a lot memory) but we aint short of base memory...
  314.  
  315. macro   playvideo start, frames, looppaus, direction
  316. local @@homodus
  317.         mov     [cs:fadejoulu], offset rettu
  318.         push    cs
  319.         pop     ds
  320.  
  321.         mov     [cs:alphaloop], looppaus
  322.         mov     eax, [cs:xmsaddress]
  323.         add     eax, start*frmsize
  324. if direction eq reverse
  325.         add     eax, frames*frmsize
  326. endif
  327.         mov     [cs:anistart], eax
  328.         mov     [cs:aniframes], frames
  329.         mov     [cs:aniframesize], direction*frmsize
  330. @@homodus:
  331.         call    viewalpha
  332.         dec     [cs:alphaloop]
  333.         jnz     @@homodus
  334. endm
  335.  
  336. ; playvideo with palette fade
  337. macro   playfade start, frames, looppaus, direction, fadet
  338. local @@homodus
  339.         mov     [cs:fadejoulu], fadet
  340.         mov     [cs:fadetus], 0
  341.         mov     [cs:alphaloop], looppaus
  342.         mov     eax, [cs:xmsaddress]
  343.         add     eax, start*frmsize
  344. if direction eq reverse
  345.         add     eax, frames*frmsize
  346. endif
  347.         mov     [cs:anistart], eax
  348.         mov     [cs:aniframes], frames
  349.         mov     [cs:aniframesize], direction*frmsize
  350. @@homodus:
  351.         call    viewalpha
  352.         dec     [cs:alphaloop]
  353.         jnz     @@homodus
  354. endm
  355.  
  356. ; shows logos in the beginning
  357. macro   showplane segu, fariseus
  358. local @@4, @@venaus, @@2, @@puisheti
  359.         cmp     [cs:exitmode], 0
  360.         jnz     @@puisheti
  361.         mov     ax, seg mainvolume
  362.         mov     fs, ax
  363.         mov     [fs:Frames], 0
  364.         xor     bx, bx
  365.         call    vsync
  366.         mov     ax, 12h                         ; init 640*480*16
  367.         int     10h
  368.  
  369.         mov     ax, 0102h                       ; set plane 1
  370.         mov     dx, 3c4h
  371.         out     dx, ax
  372.         call    vsync
  373.         mov     dx, 3c8h
  374.         mov     al, 1
  375.         out     dx, al
  376.         inc     dx
  377.         xor     al, al
  378.         out     dx, al
  379.         out     dx, al
  380.         out     dx, al
  381.  
  382.         mov     ax, segu
  383.         mov     ds, ax
  384.         mov     ax, 0a000h
  385.         mov     es, ax
  386.         xor     si, si
  387.         xor     di, di
  388.         mov     cx, 80*480/4
  389.         rep     movsd                           ; copy plane to screen
  390.  
  391.         mov     cl, 63
  392. @@4:
  393.         rept fariseus
  394.         call    vsync
  395.         endm
  396.  
  397.         mov     dx, 3c8h                        ; fade in
  398.         mov     al, 1
  399.         out     dx, al
  400.         inc     dx
  401.         mov     al, 63
  402.         sub     al, cl
  403.         out     dx, al
  404.         out     dx, al
  405.         out     dx, al
  406.         sub     cl, 2
  407.         jnc     @@4
  408.  
  409.         mov     cx, 70*1                        ; wait
  410. @@venaus:
  411.         call    vsync
  412.         dec     cx
  413.         jnz     @@venaus
  414.  
  415.         mov     cl, 63                          ; fade out
  416. @@2:
  417.         rept fariseus
  418.         call    vsync
  419.         endm
  420.         mov     dx, 3c8h
  421.         mov     al, 1
  422.         out     dx, al
  423.         inc     dx
  424.         mov     al, cl
  425.         out     dx, al
  426.         out     dx, al
  427.         out     dx, al
  428.         sub     cl, 2
  429.         jnc     @@2
  430.  
  431. ;        mov     ax, [fs:framespersec]
  432. ;        shl     ax, 1
  433. ;        cmp     [fs:Frames], ax
  434. ;        ja      @@venaus
  435.         call    vsync
  436.         mov     ax, 13h                         ; back to 320*200*256
  437.         int     10h
  438.         call    vsync
  439.         push    cs
  440.         pop     ds
  441.         mov     si, [cs:palnyt]                 ; restore palette
  442.         call    palettekehiin
  443. @@puisheti:
  444. endm
  445.  
  446.         jumps
  447.         model small
  448.  
  449. ; external definitions for GUSPLAY
  450. Extrn   MainVolume:Word,ChanOn:Word,PatternRow:Word,RealRow:Word,OrderLen:Byte
  451. Extrn   PlayingPattern:Word,RealPPattern:Word,Time:DWord,SampChans:Byte,Syncro:Word
  452. extrn   framespersec:word, framecounter:word, frames:word
  453. Extrn   Bar:Byte,NumChans:Word,BasePort:Word,ErrorCode:Word
  454. Extrn   LoadMod:Far,ClearMem:Far,StartPlaying:Far,StopPlaying:Far,Init:Far
  455. Extrn   InitDevice:Far
  456.  
  457. extrn   flatman:Far                     ; flatman memory "management" :)
  458. extrn   scrolli:Far                     ; text mode greetings scroller
  459.  
  460.         stack 100h                      ; plenty of space so lets waste it
  461.  
  462. segment _code para 'code'
  463.         assume  cs:_code
  464.         jumps
  465.         p386
  466.  
  467. oldint9 dd 0
  468.  
  469. macro   checkesc
  470.         in      al, 60h
  471.         cmp     al, 1
  472.         jz      @@forced_end
  473. endm
  474.  
  475. proc    begin
  476.         mov     ax,4A00h
  477.         mov     bx,220000/16+1          ; needs 220k base memory...
  478.         int     21h
  479.         jc      Stop
  480.  
  481.         mov     ax, 0
  482.         mov     bx, 2450                ; and 2.5 MB of XMS
  483.         call    flatman
  484.         mov     [cs:xmsaddress], eax
  485.  
  486.         push    cs
  487.         pop     ds
  488.         mov     dx, offset texti        ; ask gus port
  489.         mov     ah, 9
  490.         int     21h
  491. venaa:
  492.         mov     ah, 07h
  493.         int     21h
  494.         cmp     al, 3                   ; ^c, go away
  495.         jz      puis
  496.         cmp     al, 13                  ; enter, 220 is ok
  497.         jz      continue
  498.         cmp     al, 27                  ; esc, go away
  499.         jz      puis
  500.         sub     al, '0'                 ; a number maybe...?
  501.         jz      venaa
  502.         cmp     al, 6                   ; noooot, ask a again :)
  503.         ja      venaa
  504.  
  505.         mov     ah, 2
  506.         mov     dl, al
  507.         add     dl, '0'
  508.         int     21h                     ; show number picked
  509.         and     ax, 0fh
  510.         shl     ax, 4
  511.         add     ax, 200h
  512.         mov     bx, seg mainvolume
  513.         mov     ds, bx
  514.         mov     [baseport], ax          ; set gus port properly
  515.         jmp     continue
  516. puis:
  517.         jmp     Stop
  518. continue:
  519.         push    cs
  520.         pop     ds
  521.         mov     dx, offset loading      ; 'loading...'
  522.         mov     ah, 9
  523.         int     21h
  524.  
  525.         call    loadraw                 ; let's do some loading (2.5 MB :)
  526.         call    InitDevice              ; init gusplay
  527.         call    Init
  528.  
  529.         push    cs
  530.         pop     ds
  531.         mov     dx, offset modulename
  532.         call    LoadMod                 ; load 'COSMIC.MOD'
  533.  
  534.         cli
  535.         xor     ax, ax
  536.         mov     es, ax
  537.         mov     ax, [es:9*4]
  538.         mov     [word ptr cs:oldint9], ax
  539.         mov     ax, [es:9*4+2]
  540.         mov     [WORD PTR cs:oldint9+2], ax
  541.         mov     ax, OFFSET cs:intti9
  542.         mov     [es:9*4], ax
  543.         mov     [es:9*4+2], cs          ; stealing the keyboard interrupt
  544.         sti
  545.  
  546.         mov     ax, 13h                 ; init 320*200*256
  547.         int     10h
  548.  
  549.         push    cs
  550.         pop     ds
  551.         call    StartPlaying            ; lets rock
  552.  
  553.         demo_sequence                   ; put our demo macro here
  554. ;        mov     ah, 1
  555. ;        int     16h
  556.         call    scrolli                 ; let's scroll
  557.  
  558. @@forced_end:                           ; keyboard int throws us here...
  559.         cli
  560.         xor     ax, ax
  561.         mov     es, ax
  562.         mov     ax, [word ptr cs:oldint9]
  563.         mov     dx, [word ptr cs:oldint9+2]
  564.         mov     [es:9*4], ax
  565.         mov     [es:9*4+2], dx          ; restore kbd int
  566.         sti
  567.  
  568.         call    StopPlaying             ; stop rock
  569.         call    ClearMem                ; flush rock
  570. Stop:
  571.         mov     ax, 3
  572.         int     10h
  573.         push    cs
  574.         pop     ds
  575.         mov     dx, offset loppujorina
  576.         mov     ah, 9                   ; hahaha very funny
  577.         int     21h
  578.         mov     ax, 1
  579.         call    flatman                 ; release xms
  580.         mov     ah, 4ch                 ; exit dos
  581.         int     21h
  582. endp    begin
  583.  
  584.  
  585. alphaloop dw 0
  586. vrambuf         dw 0, hajoitus
  587. xmsaddress      dd 0
  588. screenie        dd 0
  589. frame           dw 0
  590. handle          dw 0
  591. exitmode        db 0
  592. modulename      db 'cosmic.mod',0
  593. filename        db 'cosmic.dat',0
  594. readbuf         db 4096 dup (0)
  595. flic            dd 0
  596. anistart        dd 0
  597. aniframesize    dd frmsize
  598. aniframes       dw 0
  599. anieffect       db 0
  600. disframe        dw 666
  601. loading         db 0dh,0ah,0ah,'Loading... this will take some time...!',8,'$'
  602.  
  603. proc    palettekehiin                   ; palette setup
  604.         push    cs
  605.         pop     ds
  606.         mov     dx, 3c8h
  607.         xor     al, al
  608.         out     dx, al
  609.         inc     dx
  610.         mov     si, [cs:palnyt]
  611.         mov     cx, 64*3
  612.         outsb                           ; rep outsb sucks
  613.         loop    $-1
  614.         ret
  615. endp
  616.  
  617. proc    loadraw                         ; load datas
  618.         push    0
  619.         pop     es
  620.  
  621.         mov     ax, 3d00h               ; open file
  622.         mov     dx, offset filename
  623.         int     21h
  624.         mov     [cs:handle], ax
  625.  
  626.         mov     edi, [cs:xmsaddress]
  627. @@r1:
  628.         push    cs
  629.         pop     ds
  630.         mov     ah, 3fh
  631.         mov     bx, [cs:handle]
  632.         mov     cx, 4096
  633.         mov     dx, offset readbuf
  634.         int     21h                     ; read 4k to buffer
  635.         jc      puis
  636.         or      ax, ax
  637.         jz      fileread
  638.  
  639.         push    0
  640.         pop     ds
  641.         xor     eax, eax
  642.         xor     esi, esi
  643.         mov     si, cs
  644.         shl     esi, 4
  645.         mov     ax, offset readbuf
  646.         add     esi, eax
  647.  
  648.         mov     cx, 4096/4
  649.         rep     movs [dword ptr es:edi], [dword ds:esi]
  650.         jmp     @@r1
  651. fileread:
  652.  
  653.         mov     ah, 3eh
  654.         mov     bx, [cs:handle]
  655.         int     21h                     ; close file
  656.         ret
  657. endp
  658.  
  659.  
  660. proc    viewalpha                               ; plays video sequence
  661.         mov     ax, seg mainvolume
  662.         mov     es, ax
  663.         mov     [word es:frames], 0
  664.         mov     [word es:disframe], -1
  665.  
  666.         cmp     [cs:exitmode], 0
  667.         jnz     ani_end
  668.         push    0
  669.         pop     ds
  670. ani_repeat:
  671.         mov     esi, [cs:anistart]
  672.         mov     cx, [cs:aniframes]
  673. ani_next:
  674.         cmp     [cs:exitmode], 1
  675.         je      ani_end
  676.  
  677.         push    cx
  678.         push    esi
  679.         call    updatepalette
  680.         pop     esi
  681.         pop     cx
  682.  
  683.         mov     ax, seg mainvolume
  684.         mov     es, ax
  685.         xor     eax, eax
  686.         mov     ax, [es:frames]         ; get frame number from gusplay
  687.         cmp     ax, [cs:disframe]
  688.         jz      ani_next
  689.         mov     [cs:disframe], ax
  690.  
  691.         push    cx
  692.         push    esi
  693.         mul     [cs:aniframesize]
  694.         mov     esi, [cs:anistart]
  695.         add     esi, eax
  696.         call    ani_showframe
  697.         pop     esi
  698.         pop     cx
  699.  
  700.         mov     ax, seg mainvolume
  701.         mov     es, ax
  702.         mov     ax, [es:frames]
  703.         cmp     ax, [cs:aniframes]
  704.         jb      ani_next
  705. ani_end:
  706.         ret
  707. endp
  708.  
  709. fadetus db 0
  710. fadedir db 0
  711. fadejoulu dw offset do_fade_on
  712. palnyt  dw 0
  713.  
  714. proc    do_fade_on
  715.         cmp     [cs:fadetus], 127
  716.         ja      rettu
  717.         mov     dx, 3c8h
  718.         xor     al, al
  719.         out     dx, al
  720.         inc     dx
  721.         mov     cx, 64*3
  722.         mov     bl, [cs:fadetus]
  723. @@zup:
  724.         mov     al, [cs:si]
  725.         shl     al, 1
  726.         mul     bl
  727.         mov     al, ah
  728.         out     dx, al
  729.         inc     si
  730.         dec     cx
  731.         jnz     @@zup
  732.         inc     [cs:fadetus]
  733. rettu:
  734.         ret
  735. endp
  736.  
  737. proc    do_fade_off                             ; fade off
  738.         cmp     [cs:fadetus], 127
  739.         ja      rettu2
  740.         mov     dx, 3c8h
  741.         xor     al, al
  742.         out     dx, al
  743.         inc     dx
  744.         mov     cx, 64*3
  745.         mov     bl, 127
  746.         sub     bl, [cs:fadetus]
  747. @@zup:
  748.         mov     al, [cs:si]
  749.         shl     al, 1
  750.         mul     bl
  751.         mov     al, ah
  752.         out     dx, al
  753.         inc     si
  754.         dec     cx
  755.         jnz     @@zup
  756.         inc     [cs:fadetus]
  757. rettu2:
  758.         ret
  759. endp
  760.  
  761. proc    vsync                                   ; retrace wait
  762.         cmp     [cs:exitmode], 0
  763.         jnz     bomb
  764.         mov     dx, 3dah
  765.         in      al, dx
  766.         test    al, 8
  767.         jz      $-3
  768.         in      al, dx
  769.         test    al, 8
  770.         jnz     $-3
  771. bomb:
  772.         ret
  773. endp
  774.  
  775. proc    updatepalette                           ; palette setting routine
  776.         call    vsync
  777.         push    cs
  778.         pop     ds
  779.         mov     si, [cs:palnyt]
  780.         call    [cs:fadejoulu]
  781.         ret
  782. endp
  783.  
  784. copyframe:                              ; copies frame to screen
  785.         cld
  786.         cmp     [cs:anieffect], 1       ; normal or mirror copy?
  787.         jz      copyframesymm
  788.  
  789.         mov     dx, 3d4h
  790.         mov     ax, 0309h
  791.         out     dx, ax                  ; double pixels in Y direction
  792.  
  793.         lds     si, [dword cs:vrambuf]
  794.         push    0a000h
  795.         pop     es
  796.         mov     di, 5*320+18            ; starting offset
  797.         mov     cx, 90*80
  798.         rep     movsd
  799.  
  800.         xor     eax, eax
  801.         mov     cx, 5*80
  802.         rep     stosd
  803.  
  804.         push    0
  805.         pop     ds
  806.         ret
  807.  
  808. copyframesymm:
  809.         mov     dx, 3d4h
  810.         mov     ax, 0109h
  811.         out     dx, ax                  ; 1*1 pixels
  812.         lds     si, [dword cs:vrambuf]
  813.  
  814.         push    0a000h
  815.         pop     es
  816.         mov     di, 5*320+18           ; starting offset
  817.         xor     eax, eax
  818.         mov     cx, 5*80
  819.         rep     stosd
  820.         mov     bx, 90
  821. copyframesymm1:
  822.         mov     cx, 80                  ; straight copy
  823.         rep     movsd
  824.  
  825.         mov     bp, si                  ; mirror copy
  826.         sub     di, 32+4
  827.         mov     cx, 80
  828. @@symmy:
  829.         sub     bp, 4
  830.         mov     eax, [ds:bp]
  831.         xchg    al, ah                  ; \
  832.         rol     eax, 16                 ;  } bswap   eax
  833.         xchg    al, ah                  ; /
  834.  
  835.         stosd
  836.         dec     cx
  837.         jnz     @@symmy
  838.         add     di, 32+4
  839. ;        add     bp, 320
  840.         dec     bx
  841.         jnz     copyframesymm1
  842.  
  843.         push    0
  844.         pop     ds
  845.         ret
  846. ;
  847. ; this routine scales tiny frames to full screen and interpolates the
  848. ; pixels between... interpolation could/should be done with tables
  849. ; but i was to lazy... :)
  850. ;
  851. ani_showframe:
  852. ;        VGA_border 63
  853.         lds     di, [dword cs:vrambuf]
  854.         push    0
  855.         pop     es
  856.         mov     ch, 46
  857. ani_showframe1:
  858.         mov     cl, 36
  859. ani_showframe2:                         ; horizontal blur
  860.         mov     ax, [es:esi]
  861.         mov     bh, ah
  862.         mov     ah, al
  863.         and     al, 0fh
  864.         shr     ah, 4
  865.         shl     ax, 2
  866.         mov     dx, ax
  867.         add     al, ah
  868.         shr     al, 1   ; al = interpoloitu #2
  869.         mov     ah, dh
  870.         add     ah, al
  871.         shr     ah, 1   ; ah = interpoloitu #3
  872.         mov     bl, al
  873.         shl     eax, 16
  874.         mov     al, dl  ; al = interpoloitu #0
  875.         mov     ah, bl
  876.         add     ah, al
  877.         shr     ah, 1   ; ah = interpoloitu #1
  878.         mov     [ds:di], eax
  879.         mov     ah, bh
  880.         mov     al, dh
  881.         and     ah, 0fh
  882.         shl     ah, 2
  883.         mov     dx, ax
  884.         add     al, ah
  885.         shr     al, 1   ; al = interpoloitu #2
  886.         mov     ah, dh
  887.         add     ah, al
  888.         shr     ah, 1   ; ah = interpoloitu #3
  889.         mov     bl, al
  890.         shl     eax, 16
  891.         mov     al, dl  ; al = interpoloitu #0
  892.         mov     ah, bl
  893.         add     ah, al
  894.         shr     ah, 1   ; ah = interpoloitu #1
  895.         mov     [ds:di+4], eax
  896.         add     esi, 1
  897.         add     di, 8
  898.         dec     cl
  899.         jnz     ani_showframe2
  900.         add     di, 4*8
  901.         add     di, 320
  902.         dec     ch
  903.         jnz     ani_showframe1
  904.  
  905. ;        VGA_border 125
  906.  
  907.         xor     si, si
  908.         mov     edi, 3f3f3f3fh
  909.         mov     ch, 49
  910. verinter1:
  911.         mov     cl, 10
  912. verinter2:
  913.         i=0
  914.         rept 8                          ; this mega proc smooth picture
  915.         mov     eax, [ds:si+i*4]        ; vertically...
  916.         add     eax, [ds:si+320*2+i*4]
  917.         shr     eax, 1
  918.         and     eax, edi
  919.         mov     [ds:si+320*1+i*4], eax
  920.         i=i+1
  921.         endm
  922.         add     si, i*4
  923.         dec     cl
  924.         jnz     verinter2
  925.         add     si, 320
  926.         dec     ch
  927.         jnz     verinter1
  928.  
  929.         mov     cx, 98
  930.         mov     si, 304-19
  931.         xor     eax, eax
  932. @@bug:
  933.         mov     [ds:si], eax
  934.         add     si, 320
  935.         dec     cx
  936.         jnz     @@bug
  937.  
  938.         call    vsync                   ; let's sync it a little
  939.         call    copyframe               ; copy buffer to screen
  940.         ret
  941.  
  942. proc intti9 far                 ; lousy keyboard handler....
  943.         push    ds ax
  944.         mov     al,20h
  945.         out     20h,al
  946.         in      al, 60h
  947. ;        and     al, 7fh
  948.         cmp     al, 1           ; escape hit ?
  949.         jnz     @@ei_esc
  950. ;        or      al, 80h
  951. ;        out     60h, al
  952.         mov     [cs:exitmode], 1        ; done with the demo
  953. @@ei_esc:
  954.         pop     ax ds
  955.         iret
  956. ENDP
  957.  
  958. texti:
  959. db 25 dup (10)
  960. db '                     The Message from The Cosmic Brothers',13,10,10
  961. db 'Please select your Gravis UltraSound port address:',13,10
  962. db '  If you do not have GUS installed, please select some free address.',13,10
  963. db '     <ESCAPE>. IMMEDIATE EXIT',13,10
  964. db '            1. 210h',13,10
  965. db '            2. 220h',13,10
  966. db '            3. 230h',13,10
  967. db '            4. 240h',13,10
  968. db '            5. 250h',13,10
  969. db '            6. 260h',13,10,10
  970. db 'Your selection [enter=220h] : 220h',8,8,8 ; ,13,10
  971. db '$'
  972.  
  973. label paletit                   ; all the different palettes
  974.         include 'pal.inc'
  975.  
  976. loppujorina:                    ; buzz off message
  977. db 'Remember to vote this demo to all possible charts in every diskmag!',0dh,0ah
  978. db '$'
  979.  
  980. ends    _code
  981.  
  982. segment plane1
  983.         db 'planemsg1'                  ; complex production
  984.         db 80*480 dup (0)
  985. ends
  986.  
  987. segment plane2
  988.         db 'planemsg2'                  ; message from ...
  989.         db 80*480 dup (0)
  990. ends
  991.  
  992. segment hajoitus
  993.         db 64400 dup (0)                ; virtual screen buffer
  994. ends
  995.  
  996. end     begin                           ; begin is the starting procedure...
  997.