home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CONTRSRC.ZIP / SRC / TYPEONE / TITLE.ASM < prev    next >
Assembly Source File  |  1994-11-04  |  10KB  |  389 lines

  1.  
  2. ;*************************************************
  3. ; CONTRAST TITLE (C) 1994 Type One / TFL-TDV Prod.
  4. ; GFX by Zoltan & Fred
  5. ;*************************************************
  6.  
  7. INCLUDE PDFIK.INC ; DataFile Manager
  8. INCLUDE VIDEO.INC ; Flamoot VGA SetUp
  9. INCLUDE PLAYINFO.INC ; Player structures
  10. INCLUDE KEYBOARD.INC ; Keyboard macros
  11.  
  12. ;-----------------------------------------
  13. ; Déclaration modèle mémoire
  14. .386
  15. DGROUP GROUP _DATA,_BSS
  16. TITLE_TEXT  SEGMENT DWORD PUBLIC USE16 'CODE'
  17.             ASSUME CS:TITLE_TEXT,DS:DGROUP
  18. TITLE_TEXT  ENDS
  19. _DATA  SEGMENT DWORD PUBLIC USE16 'DATA'
  20. _DATA  ENDS
  21. _BSS   SEGMENT DWORD PUBLIC USE16 'BSS'
  22. _BSS   ENDS
  23. ;-----------------------------------------
  24.  
  25. _DATA SEGMENT
  26.  
  27.  
  28. ;-- donnees pattern --
  29. EXTRN _Datafile  : BYTE
  30. EXTRN _OfsinDta  : DWORD
  31. Picname   BYTE 'ctrtitle.raw',0
  32. Picparam  PARAM_STRUC<2,_DATA,OFFSET _Datafile,OFFSET Picname,0,0,0,,,0>
  33.  
  34.  
  35. EXTRN _BlackPal: BYTE
  36. EXTRN _WhitePal: BYTE
  37.  
  38. _DATA ENDS
  39.  
  40. ;données non initialisées
  41. _BSS SEGMENT
  42.  
  43. EXTRN _FrameCounter     : WORD
  44. EXTRN _StartAdr         : WORD
  45. EXTRN _WorkAdr          : WORD
  46. EXTRN _NextAdr          : WORD
  47. EXTRN _Triple           : WORD
  48. EXTRN _SyncFlag         : WORD
  49. EXTRN _TmpPal           : BYTE
  50. EXTRN _FadeON           : WORD
  51. ;!!!!!!!!!! synchro avec music !!!!!!!!!!!!
  52. EXTRN _MP               : DWORD ; extern ModulePlayer * MB
  53. EXTRN _ReplayInfo       : mpInformation
  54.  
  55. ;---- param pour synchro avec zizik ----
  56. EVEN
  57. DebSong  WORD ?
  58. FinSong  WORD ?
  59.  
  60.  
  61.  
  62. EVEN
  63. Picseg    WORD ?        ; seg for pattern
  64.  
  65. FadeFlag WORD ?        ; flag pour fading
  66. FadePtr1 WORD 2 DUP(?) ; ptr sur palette a fader
  67. FadePtr2 WORD 2 DUP(?)
  68. Delai    WORD ?
  69. Termine  WORD ?        ; flag pour terminer !!!
  70.  
  71.  
  72. _BSS ENDS
  73.  
  74. TITLE_TEXT SEGMENT
  75.      PUBLIC _StartTitle
  76.      EXTRN _AveragePAL : FAR
  77.  
  78.  
  79. ; Point d'entrée de l'intro !!!!!
  80. ;---------------------------------
  81. ALIGN
  82. EVEN
  83. _StartTitle PROC FAR
  84.  
  85.          push    bp                  ; bâtit le cadre de pile
  86.          mov     bp,sp
  87.  
  88.          pushad
  89.          MPUSH ds,es,fs,gs
  90.  
  91.          STARTUP
  92. ;------- recuperer parametres sur le stack !!!! --------
  93.  
  94.          mov     ax,WORD PTR ss:[bp+6]  ; debut pos
  95.          shl     eax,14
  96.          or      ax,WORD PTR ss:[bp+8]  ; debut row
  97.          or      ah,al
  98.          shr     eax,8
  99.          mov     DebSong,ax
  100.          mov     ax,WORD PTR ss:[bp+10] ; fin pos
  101.          shl     eax,14
  102.          or      ax,WORD PTR ss:[bp+12] ; fin row
  103.          or      ah,al
  104.          shr     eax,8
  105.          mov     FinSong,ax
  106.          xor     eax,eax
  107. ;-------------------------------------------------------
  108.  
  109.          push    m320x200x256c   ; set 320x200x256 col/chained 60hz
  110.          call    _SetVGA
  111.          add     sp,2
  112.  
  113.          STARTUP
  114. ;--------------------------------------
  115.          call    DoTitle             ; !!!!! title part !!!!!
  116. ;--------------------------------------
  117.  
  118.          mov  ax,0a000h              ; clear screen
  119.          mov  es,ax
  120.          xor  eax,eax
  121.          xor  di,di
  122.          mov  cx,65536/4
  123.          rep  stosd
  124.  
  125.          MPOP ds,es,fs,gs
  126.          popad
  127.          nop
  128.  
  129.          leave                       ; restore stack
  130.                                      ; mov sp,bp + pop bp
  131.          retf
  132.  
  133. _StartTitle ENDP
  134.  
  135. ;==============================================================================
  136. ;============================ Title part ======================================
  137. ;==============================================================================
  138.  
  139. ALIGN
  140. EVEN
  141. DoTitle PROC NEAR
  142.  
  143.  
  144. ;------------------------------------------------------------------------------
  145.          pushad
  146.  
  147.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  148.          mov     Picparam.OfsInPdf,eax
  149.          mov     ax,_DATA              ; prepare for PDFIK call
  150.          mov     es,ax
  151.          mov     bx,OFFSET Picparam
  152.          pusha
  153.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  154.          popa
  155.          mov     ax,Picparam.BufSeg ; where is the file in mem ?
  156.          mov     Picseg,ax
  157.  
  158.          push    ds
  159.          push    es
  160.          mov     ax,Picseg
  161.          mov     ds,ax                 ; 32 bytes for Alchemy Header
  162.          mov     si,32                 ; palette offset
  163.          mov     es,ax
  164.          mov     di,32
  165.  
  166.          mov     cx,768                ; 256*3 components
  167. @@:      lodsb
  168.          shr     al,2                  ; 8 to 6 bits conversion
  169.          stosb
  170.          dec     cx
  171.          jnz     @B
  172.  
  173.          pop     es
  174.          pop     ds
  175.  
  176. ;---------------
  177.  
  178.          STARTUP
  179.  
  180.  
  181.          call    PutTitle              ; transfert bitmap in vidmem and
  182.                                        ; set pal to black !!!!
  183.  
  184.  
  185. ;---- wait right position/row in tune ----
  186.  
  187. WaitPos:
  188.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  189.  
  190.          les     bx,DWORD PTR[_MP]
  191.          push    ds
  192.          push    OFFSET _ReplayInfo
  193.  
  194.          ; _MP->GetInformation(&ReplayInfo)
  195.  
  196.          call    (ModulePlayer PTR es:[bx]).GetInformation
  197.          add     sp,4
  198.  
  199.          mov     ax,_ReplayInfo.pos
  200.          shl     eax,14
  201.          or      ax,_ReplayInfo.row
  202.          or      ah,al
  203.          shr     eax,8
  204.          cmp     ax,WORD PTR[DebSong]  ; is it time ????
  205.          jb      WaitPos
  206.  
  207.          xor     eax,eax
  208. ;------------------------------------------
  209.  
  210.          mov     Termine,0 ; pas encore terminer !!!
  211.  
  212.          mov     _FadeON,0
  213.          mov     FadeFlag,0
  214.          mov     FadePtr1,OFFSET _BlackPal  ; Black to pic for the beginning !!!
  215.          mov     ax,ds
  216.          mov     FadePtr1+2,ax
  217.          mov     FadePtr2,32
  218.          mov     ax,Picseg
  219.          mov     FadePtr2+2,ax
  220.          mov     ax,_FrameCounter
  221.          mov     Delai,ax
  222.  
  223.  
  224.          mov     bx,_StartAdr
  225.          mov     WORD PTR[bx],0         ; _StartAdr->base = 0
  226.          mov     WORD PTR[bx+2],0       ; _StartAdr->flag = false
  227.          mov     bx,_WorkAdr
  228.          mov     WORD PTR[bx],0         ; _WorkAdr->base
  229.          mov     WORD PTR[bx+2],0       ; _WorkAdr->flag = false
  230.          mov     _Triple,0              ; "faux" double buffering
  231.          mov     _SyncFlag,1
  232.          VSYNC
  233.  
  234.  
  235. EVEN
  236. Main: ; -= VSYNC =-
  237.  
  238. wait_for_VBL:                       ; wait for Sync Flag
  239.          cmp     _SyncFlag,1
  240.          jne      wait_for_VBL
  241.          mov     _SyncFlag,0
  242.  
  243.  
  244.          cmp     FadeFlag,255
  245.          jb      BNewFade2
  246.          cmp     Termine,1    ; Terminer si dernier fade fini
  247.          je      GoOut
  248.  
  249.          mov     _FadeON,0    ; don't set _TmpPal anymore ...
  250.          jmp     @F
  251. BNewFade2:mov     ax,FadeFlag  ; average Black-MyPal
  252.          push    ax
  253.          push    ds
  254.          push    OFFSET _TmpPal
  255.          mov     ax,FadePtr1+2
  256.          push    ax
  257.          mov     ax,FadePtr1
  258.          push    ax
  259.          mov     ax,FadePtr2+2
  260.          push    ax
  261.          mov     ax,FadePtr2
  262.          push    ax
  263.          call    _AveragePAL
  264.          add     sp,7*2
  265.          mov     _FadeON,1            ; set new PAL during next VR !!!
  266.          mov     cx,_FrameCounter
  267.          sub     cx,Delai             ; temps chargement
  268.          mov     Delai,0              ; plus delai ....
  269.          test    cx,cx
  270.          jnz     BFaddi
  271.          inc     cx
  272. BFaddi:  add     FadeFlag,4           ; inc fade ..
  273.          dec     cx
  274.          jnz     BFaddi
  275. @@:
  276.  
  277. ;----------- test if we must finish ... ----------
  278.          mov     ax,_FrameCounter
  279.          mov     _FrameCounter,0 ; set counter to NULL
  280.  
  281.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  282.  
  283.          les     bx,DWORD PTR[_MP]
  284.          push    ds
  285.          push    OFFSET _ReplayInfo
  286.  
  287.          ; _MP->GetInformation(&ReplayInfo)
  288.  
  289.          call    (ModulePlayer PTR es:[bx]).GetInformation
  290.          add     sp,4
  291.  
  292.          mov     ax,_ReplayInfo.pos
  293.          shl     eax,14
  294.          or      ax,_ReplayInfo.row
  295.          or      ah,al
  296.          shr     eax,8
  297.  
  298.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  299.          jb      @F                      ; to fade off ???
  300.  
  301.          mov     Termine,1
  302.  
  303.          cmp     FadePtr2,OFFSET _BlackPal
  304.          je      @F
  305.          mov     FadeFlag,0
  306.          mov     eax,DWORD PTR[FadePtr2]
  307.          mov     DWORD PTR[FadePtr1],eax   ; fade to black !!!!
  308.          mov     ax,ds
  309.          mov     FadePtr2+2,ax
  310.          mov     FadePtr2,OFFSET _BlackPal
  311.  
  312. @@:      xor     eax,eax
  313. ;--------------------------------------------------------------------
  314.  
  315.          SHOWTIME 32
  316.  
  317.          SHOWTIME 0
  318.  
  319.          mov     bx,_WorkAdr
  320.          mov     WORD PTR[bx+2],1
  321.  
  322.          LOOP_UNTIL_KEY Main
  323.  
  324. ;===============================================================
  325.  
  326. GoOut:
  327.  
  328.         FLUSH_KEYBUF                  ; Flush keyboard buffer !!! ;-)
  329.  
  330.         mov     _FadeON,0             ; to be sure ....
  331.  
  332. ;----- EXIT -----
  333.  
  334.         STARTUP
  335.         mov     ax,Picseg             ; segment to free
  336.         mov     es,ax
  337.         mov     ah,49h                ; MFREE
  338.         int     21h
  339.  
  340.         popad
  341.         nop
  342.         ret
  343.  
  344. DoTitle   ENDP
  345.  
  346.  
  347. PutTitle PROC NEAR                    ; put bitmap and set pal to black !!!
  348.  
  349.  
  350.         MPUSH ax,cx,dx,si,di,ds,es
  351.  
  352.         mov   dx,3c8h                 ; pal reg.
  353.         xor   al,al
  354.         out   dx,al
  355.         inc   dl
  356.         mov   cx,768
  357. @@:     out   dx,al                   ; black ....
  358.         dec   cx
  359.         jnz   @B
  360.  
  361.  
  362.         mov   ax,Picseg
  363.         add   ax,(768+32) SHR 4       ; segment of Title pic "ConTrast"
  364.         mov   ds,ax
  365.         mov   ax,0a000h               ; video mem
  366.         mov   es,ax
  367.  
  368.         xor   si,si                  ; skip alchemy header ...
  369.         xor   di,di
  370.  
  371.         cld
  372.         mov   cx,320*200/4
  373.         rep   movsd                   ; copy to screen
  374.  
  375.  
  376.  
  377.         MPOP  ax,cx,dx,si,di,ds,es
  378.         ret
  379.  
  380. PutTitle ENDP
  381.  
  382.  
  383. ;==============================================================================
  384.  
  385. TITLE_TEXT ENDS
  386.  
  387.      END
  388.  
  389.