home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / KARMA / KARMA.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-11-13  |  28.6 KB  |  1,124 lines

  1. ;******************************************************************
  2. ;* Karma's part: eyes effects --> Express contribution to Wired94 *
  3. ;******************************************************************
  4. ;       Autres includes : sincos.dw , mul320tb.inc , memoire.inc (malloc)
  5. ;       Loade digi.byt (64768 bytes)
  6.  
  7.     INCLUDE  PDFIK.INC
  8.     INCLUDE  VIDEO.INC
  9.         INCLUDE  PLAYINFO.INC
  10.         INCLUDE  KEYBOARD.INC        ; lotsa macros
  11.  
  12. ;--------------------------------------------------------------------------
  13. ;                          Structure mémoire ...
  14. ;--------------------------------------------------------------------------
  15. .386
  16.     DGROUP GROUP _DATA, _BSS
  17.     KARMA_TEXT SEGMENT DWORD PUBLIC USE16 'CODE'
  18.                 ASSUME cs:KARMA_TEXT, ds:_DATA3, fs:DGROUP
  19.     KARMA_TEXT ENDS
  20.     _DATA SEGMENT DWORD PUBLIC USE16 'DATA'
  21.     _DATA ENDS
  22.     _BSS SEGMENT DWORD PUBLIC USE16 'BSS'
  23.     _BSS ENDS
  24.         _DATA3 SEGMENT DWORD PRIVATE USE16 'FAR_DATA'
  25.         _DATA3 ENDS
  26. ;--------------------------------------------------------------------------
  27.  
  28. SC_INDEX       = 3c4h      ;Registre d'index du contrôleur du séquenceur
  29. SC_MAP_MASK    = 2                          ;Numéro du registre Map Mask
  30. SC_MEM_MODE    = 4                   ;Numéro dy registre de mode mémoire
  31. GC_INDEX       = 3ceh          ;Registre d'index du contrôleur graphique
  32. GC_READ_MAP    = 4                          ;Numéro du registre Read Map
  33. GC_GRAPH_MODE  = 5                 ;Numéro du registre de mode graphique
  34. GC_MISCELL     = 6                            ;Numéro du registre divers
  35. CRTC_INDEX     = 3d4h            ;Registre d'index du contrôleur d'écran
  36. CC_MAX_SCAN    = 9     ;Numéro du registre du maximum de lignes balayées
  37. CC_START_HI    = 0Ch                        ;Numéro du registre Hi_Start
  38. CC_UNDERLINE   = 14h                 ;Numéro du registre de soulignement
  39. CC_MODE_CTRL   = 17h             ;Numéro du registre de contrôle de mode
  40. DAC_WRITE_ADR  = 3C8h                                 ;Adresse DAC Write
  41. DAC_READ_ADR   = 3C7h                                  ;Adresse DAC Read
  42. DAC_DATA       = 3C9h                           ;Registre de données DAC
  43. VERT_RETRACE   = 3DAh                       ;registre d'état d'entrée #1
  44. PIXX           = 320                             ;Résolution horizontale
  45.  
  46.   Larg=320
  47.   Haut=200
  48.   Screen1 = 0
  49.   Screen2 = (Larg*Haut/4)
  50.   Screen3 = ((Larg*Haut/4)*2)
  51. ;***************************************************************
  52. _DATA3 segment
  53. ;-----------------------table des sinus/cosinus--------------------
  54. include   sincos.dw
  55. ;--------------donnees mode tweaked--------------------------------
  56. vio_seg dw 0a000h
  57. pv      db 1
  58. pi      db 0
  59. ;--------------table de mul par 320--------------------------------
  60. mul320tb:
  61. include mul320tb.inc
  62. ;--------------donnees disto---------------------------------------
  63. decal1 db 0
  64. decal2 db 64
  65.  
  66. picture DW ?  ; pteur sur segment pic ...
  67. CurStep DW ?  ; step for the distort...
  68. Dest    DW ?  ; working screen
  69.  
  70. ;---- param pour synchro avec zizik ----
  71. EVEN
  72. DebSong  WORD ?
  73. FinSong  WORD ?
  74.  
  75. ;---- param pour fading ----
  76. Timeleft  WORD ?        ; temps restant pour execution
  77. FadeFlag WORD ?        ; flag pour fading
  78. FadePtr1 WORD 2 DUP(?) ; ptr sur palette a fader
  79. FadePtr2 WORD 2 DUP(?)
  80. Delai    WORD ?
  81. Termine  WORD 0 ;?        ; flag pour terminer !!!
  82.  
  83. cumul_step_lo DD 0
  84. cumul_step_hi DD 0
  85. cumul_old_lo  DD 0
  86. cumul_old_hi  DD 0
  87.  
  88. _DATA3 ends
  89.  
  90. _DATA SEGMENT
  91.  
  92. ;-- donnees pattern --
  93. EXTRN _Datafile  : BYTE
  94. EXTRN _OfsinDta  : DWORD
  95. Picname   BYTE 'digi.byt',0  ; nom pic ...
  96. Picparam  PARAM_STRUC<2,DGROUP,OFFSET _Datafile,OFFSET Picname,0,0,0,,,0>
  97.  
  98. EXTRN _BlackPal: BYTE
  99. EXTRN _WhitePal: BYTE
  100.  
  101.  
  102. _DATA ENDS
  103.  
  104. _BSS SEGMENT
  105.  
  106.     EXTRN _FrameCounter     : WORD
  107.     EXTRN _ExitDemo         : WORD
  108.     EXTRN _CPUtime          : WORD
  109.     EXTRN _StartAdr         : WORD
  110.     EXTRN _WorkAdr          : WORD
  111.     EXTRN _NextAdr          : WORD
  112.     EXTRN _Triple           : WORD
  113.     EXTRN _SyncFlag         : WORD
  114.  
  115.         ;!!!!!!!!!! sync music !!!!!!!!!!
  116.         EXTRN _MP               : DWORD ; extern ModulePlayer * MB
  117.         EXTRN _ReplayInfo       : mpInformation
  118.  
  119. EXTRN _TmpPal           : BYTE
  120. EXTRN _FadeON           : WORD
  121.  
  122. _BSS ENDS
  123. ;-----------------*-*-*-*********//////////**********-*-*-*--------
  124. ;******************************************************************
  125. KARMA_TEXT   SEGMENT
  126.      EXTRN _AveragePAL: FAR
  127.  
  128.     PUBLIC _KARMA
  129. ;******************************************************************
  130. INCLUDE MEMOIRE.INC
  131. ALIGN
  132. EVEN
  133. _KARMA      PROC FAR
  134. ;******************************************************************
  135. ;          MAIN--<\<\<\--MAIN--/>/>/>--MAIN                       *
  136. ;               _//// \\     _//// \\                             *
  137. ;              / //<   >\   / //<   >\                            *
  138. ;             <_/<__> <__> <_/<__> <__>                           *
  139. ;******************************************************************
  140.  
  141. FADEPAL MACRO
  142.         LOCAL NewFade,Faddi,lbl1
  143. ;===================== Fade Palette ===========================
  144.  
  145. ;;;;;;;;;; plante pas !!!!!!
  146.  
  147.          cmp     FadeFlag,255
  148.          jb      NewFade
  149.  
  150.          mov     fs:_FadeON,0  ; plus fader ...
  151.  
  152.          cmp     Termine,1    ; Terminer si dernier fade fini
  153.          je      fin
  154.  
  155.          mov     fs:_FadeON,0    ; don't set _TmpPal anymore ...
  156.          jmp     lbl1
  157. NewFade: MPUSH   ax,cx
  158.          mov     ax,FadeFlag  ; average Black-MyPal
  159.          push    ax
  160.          push    fs
  161.          push    OFFSET _TmpPal
  162.          mov     ax,FadePtr1+2
  163.          push    ax         
  164.          mov     ax,FadePtr1
  165.          push    ax
  166.          mov     ax,FadePtr2+2 
  167.          push    ax
  168.          mov     ax,FadePtr2
  169.          push    ax
  170.          call    _AveragePAL
  171.          add     sp,7*2
  172.          mov     fs:_FadeON,1 ;1            ; set new PAL during next VR !!!!
  173.          mov     cx,fs:_FrameCounter
  174.          sub     cx,Delai             ; temps chargement
  175.          mov     Delai,0              ; plus delai ....
  176.          test    cx,cx
  177.          jnz     Faddi
  178.          mov     cx,1
  179. Faddi:   add     FadeFlag,4           ; inc fade ..
  180.          dec     cx
  181.          jnz     Faddi
  182.          MPOP    ax,cx
  183. lbl1:
  184.  
  185. ;;;;;;; plante pas !!!!!!
  186.  
  187. ;==============================================================
  188. ENDM
  189.  
  190. NEXTSTEP MACRO
  191.         LOCAL lbl1
  192.  
  193. ;------------ FrameCounter manip ------------
  194.         MPUSH  eax,ebx,ecx,edx
  195.  
  196.         mov    cx,fs:_FrameCounter
  197.         test   cx,cx
  198.         jnz    lbl1
  199.         mov    cx,1
  200.  
  201. lbl1:   xor    eax,eax
  202.         mov    ah,cl ; frame*256
  203.      ;   mov    ax,384 ;307              ; 1.5*256 = factor
  204.      ;   mul    cx
  205.  
  206.         mov    ecx,cumul_step_lo   ; save old cumulated step (64 bits)
  207.         mov    cumul_old_lo,ecx
  208.         mov    ecx,cumul_step_hi
  209.         mov    cumul_old_hi,ecx   
  210.      
  211.         add    cumul_step_lo,eax   ; multiprecision
  212.         adc    cumul_step_hi,0
  213.  
  214.         mov    ecx,cumul_step_hi
  215.         mov    eax,cumul_step_lo
  216.         shrd   eax,ecx,8           ; / 256
  217.         mov    edx,cumul_old_hi
  218.         mov    ebx,cumul_old_lo
  219.         shrd   ebx,edx,8
  220.  
  221.         sub    eax,ebx
  222. ;        sbb    ecx,edx
  223.  
  224.         mov    CurStep,ax  ; CurStep = factor * FrameCounter
  225.  
  226.         mov    fs:_FrameCounter,0
  227.  
  228.         MPOP   eax,ebx,ecx,edx
  229. ;--------------------------------------------
  230.  
  231. ENDM
  232.  
  233. SHOWTIME MACRO col
  234.         LOCAL lbl1
  235.         test            fs:_CPUtime,1
  236.         jz              lbl1
  237.         COLOR           col
  238. lbl1:
  239.  
  240. ENDM
  241.  
  242. TESTEND MACRO
  243.  
  244.          pushad
  245.          MPUSH    ds,es,fs,gs
  246.  
  247. ;==============================================
  248.          mov      ax,DGROUP
  249.          mov      ds,ax                   ; xchg FS,DS
  250.          mov      ax,_DATA3
  251.          mov      fs,ax
  252.  
  253.          ASSUME   ds:DGROUP,fs:_DATA3
  254.  
  255. ;----------- test if we must finish ... ----------
  256.  
  257.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  258.          
  259.          les     bx,DWORD PTR[_MP]
  260.          push    ds
  261.          push    OFFSET _ReplayInfo
  262.  
  263.          ; _MP->GetInformation(&ReplayInfo)
  264.  
  265.          call    (ModulePlayer PTR es:[bx]).GetInformation
  266.          add     sp,4
  267.  
  268.          mov     ax,_ReplayInfo.pos
  269.          shl     eax,14
  270.          or      ax,_ReplayInfo.row
  271.          or      ah,al
  272.          shr     eax,8
  273.          cmp     ax,WORD PTR fs:[FinSong]; is it time ????
  274.          jb      @F                      ; to fade off ???
  275.  
  276.          mov     fs:Termine,1
  277.  
  278.          cmp     FadePtr2,OFFSET _BlackPal
  279.          je      @F
  280.          mov     fs:FadeFlag,0
  281.          mov     eax,DWORD PTR fs:[FadePtr2]
  282.          mov     DWORD PTR fs:[FadePtr1],eax   ; fade to black !!!!
  283.          mov     ax,ds
  284.          mov     fs:FadePtr2+2,ax
  285.          mov     fs:FadePtr2,OFFSET _BlackPal
  286.  
  287. @@:      xor     eax,eax
  288.  
  289.          ASSUME  ds:_DATA3, fs:DGROUP
  290.  
  291.          MPOP    ds,es,fs,gs
  292.          popad
  293.          nop
  294.  
  295. ENDM
  296.  
  297. LOOPUNTILKEY MACRO lbl
  298.          LOCAL   lbl1,lbl2,lbl3
  299.  
  300.          in      al,60h              ; EXIT ?
  301.          cmp     al,78               ; '+'
  302.          jne     lbl1
  303.          mov     fs:_CPUtime,1       ; set CPUtime Flag to ON ....
  304.          jmp     lbl
  305. lbl1:    cmp     al,74               ; '-'
  306.          jne     lbl2
  307.          mov     fs:_CPUtime,0       ; set CPUtime Flag to OFF ....
  308.          jmp     lbl
  309. lbl2:    cmp     al,39h              ; Space Bar ...
  310.          jne     lbl3
  311.          mov     fs:_SpaceBar,1
  312.          jmp     fin
  313.  
  314. lbl3:
  315.          cmp     al,1                ; Escapff...
  316.          jne     lbl
  317.          mov     fs:_ExitDemo,1      ; exit the whole demo !!!!
  318.  
  319. ENDM
  320.  
  321. ;*********************** REAL CODE ***********************
  322.  
  323.         push        bp
  324.         mov         bp,sp
  325.         pushad
  326.         MPUSH       ds,es,fs,gs
  327.  
  328.         mov             ax,_DATA3
  329.     mov             ds,ax
  330.  
  331.  
  332. ;------- recuperer parametres sur le stack !!!! --------
  333.  
  334.          mov     ax,WORD PTR ss:[bp+6]  ; debut pos
  335.          shl     eax,14
  336.          or      ax,WORD PTR ss:[bp+8]  ; debut row
  337.          or      ah,al
  338.          shr     eax,8
  339.          mov     DebSong,ax
  340.          mov     ax,WORD PTR ss:[bp+10] ; fin pos
  341.          shl     eax,14
  342.          or      ax,WORD PTR ss:[bp+12] ; fin row
  343.          or      ah,al
  344.          shr     eax,8
  345.          mov     FinSong,ax
  346.          xor     eax,eax
  347. ;-------------------------------------------------------
  348.  
  349.         push            ds
  350.     push            m320x200x256p
  351.     call            _SetVGA
  352.     add             sp,2
  353.         pop             ds
  354.  
  355.         mov             si,offset sine
  356.     mov             cx,320
  357.     boucle_sincos:                          ;pour diviser par 2 'sincos'
  358.     sar             word ptr ds:[SI],1
  359.     add             SI,2
  360.         LOOP            boucle_sincos
  361.  
  362. INITpart1:
  363. ; charge le bitmap 'digi.byt' dans le segment referencé dans picture
  364. ; copie d'abord la ch. de car. 'digi.byt',0 dans picture
  365. ;
  366. ;
  367.         push    fs
  368.         push    eax
  369.  
  370.         mov     ax,DGROUP
  371.         mov     fs,ax
  372.  
  373.         mov     eax,fs:_OfsinDta      ; OFFSET in Datafile
  374.         mov     fs:Picparam.OfsInPdf,eax
  375.         mov     ax,DGROUP             ; prepare for PDFIK call
  376.         mov     es,ax
  377.         mov     bx,OFFSET Picparam
  378.         pusha
  379.         call    PDFIK_ASM             ; call function 2 (extract+alloc)
  380.         popa
  381.         mov     ax,fs:Picparam.BufSeg ; where is the file in mem ?
  382.         mov     picture,ax
  383.  
  384.         pop     eax
  385.         pop     fs
  386.  
  387. ;------------ succesfully PDFIKed ;-) -------------
  388.         mov     ax,_DATA3
  389.         mov     ds,ax
  390.  
  391. ;---- wait right position/row in tune ----
  392.  
  393.         pushad
  394.         MPUSH   ds,es,fs,gs
  395.  
  396.         ASSUME  ds:DGROUP
  397.         ASSUME  fs:_DATA3
  398.         mov     ax,DGROUP
  399.         mov     ds,ax
  400.         mov     ax,_DATA3   ; XCHG DS,FS !!!!
  401.         mov     fs,ax
  402.  
  403. ;;;;; attente bonne position music ;;;;; plante ???
  404. WaitPos:
  405.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  406.  
  407.          les     bx,DWORD PTR [_MP]
  408.          push    ds
  409.          push    OFFSET _ReplayInfo
  410.  
  411.          ; _MP->GetInformation(&ReplayInfo)
  412.  
  413.          call    (ModulePlayer PTR es:[bx]).GetInformation
  414.          add     sp,4
  415.  
  416.          mov     ax,_ReplayInfo.pos
  417.          shl     eax,14
  418.          or      ax,_ReplayInfo.row
  419.          or      ah,al
  420.          shr     eax,8
  421.          cmp     ax,WORD PTR fs:[DebSong]  ; is it time ????
  422.          jb      WaitPos
  423.          xor     eax,eax
  424. ;;;;;;;;; plante ???????
  425.          ASSUME  ds:_DATA3
  426.          ASSUME  fs:DGROUP
  427.          MPOP    ds,es,fs,gs
  428.          popad
  429.          nop 
  430. ;------------------------------------------
  431.  
  432. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  433.          mov     ax,DGROUP
  434.          mov     fs,ax
  435.          mov     ax,_DATA3
  436.          mov     ds,ax
  437. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  438.  
  439. ; init ....
  440.           mov     Termine,0
  441.  
  442. ;;;;; plante ???? non !!!
  443.          mov     fs:_FadeON,0
  444.          mov     FadeFlag,0
  445.          mov     FadePtr1,OFFSET _BlackPal  ; Black to pic for the beginning !!!
  446.          mov     ax,fs
  447.          mov     FadePtr1+2,ax
  448.          mov     FadePtr2,64000
  449.          mov     ax,picture
  450.          mov     FadePtr2+2,ax
  451.          mov     ax,fs:_FrameCounter
  452.          mov     Delai,ax
  453. ;;;;; plante ???? non !!!
  454.  
  455.          mov     bx,DGROUP
  456.          mov     fs,bx
  457.  
  458.          mov     bx,fs:_StartAdr
  459.          mov     WORD PTR fs:[bx],Screen1   ; _StartAdr->base = 0
  460.          mov     WORD PTR fs:[bx+2],0       ; _StartAdr->flag = false
  461.          mov     bx,fs:_WorkAdr
  462.          mov     WORD PTR fs:[bx],Screen2   ; _WorkAdr->base
  463.          mov     WORD PTR fs:[bx+2],0       ; _WorkAdr->flag = false
  464.          mov     bx,fs:_NextAdr
  465.          mov     WORD PTR fs:[bx],Screen3   ; _NextAdr->base
  466.          mov     WORD PTR fs:[bx+2],0       ; _NextAdr->flag = false
  467.          mov     fs:_Triple,1               ; triple buffering
  468.  
  469.          call            wait_vbl
  470.  
  471.  
  472. ;===================== MAIN LOOP ========================
  473.  
  474. part1:
  475.  
  476. ;***** 2nd page *****
  477. Do_a_frame:
  478.         mov             di,fs:_WorkAdr
  479.         cmp             WORD PTR fs:[di+2],1 ; _WorkAdr->flag true (previous _NextAdr) ?
  480.         je              NextFrame        ; then construct next frame
  481.  
  482.         mov             ax,_DATA3
  483.         mov             ds,ax
  484.         mov             Dest,di               ; save pointer
  485.  
  486.         mov             si,Dest
  487.         mov             ax,WORD PTR fs:[si]
  488.         shr             ax,4                  ; segment + off. shr 4
  489.         add             ax,0a000h
  490.         mov             vio_seg,ax
  491.  
  492.         FADEPAL                                 ; fade palet !!!
  493.  
  494.         NEXTSTEP                                ; calculate nextstep :-)
  495.  
  496.         SHOWTIME        32
  497.  
  498.     call            disto2
  499.  
  500.         SHOWTIME        0
  501.  
  502.         TESTEND                                  ; test if we must fade out !!
  503.  
  504.         mov    bx,DGROUP
  505.         mov    fs,bx
  506.         mov    bx,_DATA3
  507.         mov    ds,bx
  508.  
  509.         mov    di,fs:_NextAdr         ; save adr of next buffer
  510.  
  511.         mov    bx,Dest
  512.         mov    WORD PTR fs:[bx+2],1    ; _WorkAdr->flag = true
  513.  
  514.         jmp  Nexxxt
  515.  
  516. ;******** 3rd page *********
  517. NextFrame:
  518.          mov  di,fs:_NextAdr
  519.          cmp  WORD PTR fs:[di+2],1 ; _NextAdr true ?
  520.          je   NextFrame
  521.     
  522. Nexxxt:
  523.  
  524.         mov  bx,_DATA3
  525.         mov  ds,bx
  526.         mov  Dest,di               ; save pointer
  527.  
  528.         mov             si,Dest
  529.         mov             ax,WORD PTR fs:[si]
  530.         shr             ax,4                  ; segment + off. shr 4
  531.         add             ax,0a000h
  532.         mov             vio_seg,ax
  533.  
  534.  
  535.         FADEPAL                                 ; fade palet !!!
  536.  
  537.         NEXTSTEP                                ; calculate nextstep :-)
  538.  
  539.         SHOWTIME        32
  540.  
  541.     call            disto2
  542.  
  543.         SHOWTIME        0
  544.  
  545.         TESTEND                                  ; test if we must fade out !!
  546.  
  547.         mov             bx,DGROUP
  548.         mov             fs,bx
  549.         mov             bx,_DATA3
  550.         mov             ds,bx
  551.  
  552.         mov             bx,Dest
  553.         mov             WORD PTR fs:[bx+2],1     ; _NextAdr->flag = true
  554.  
  555.         LOOPUNTILKEY part1                       ; exit if keypressed
  556.  
  557. fin:
  558.         mov     fs:_FadeON,0             ; to be sure ....
  559.     
  560.  
  561. ;==================== END LOOP ==============================
  562.  
  563. ; Libération mémoire
  564.     FREE            picture
  565.  
  566.         mov     ax,0a000h           ; Clear screen
  567.         mov     es,ax
  568.         mov     dx,3c4h
  569.         mov     ax,0f02h
  570.         out     dx,ax
  571.         xor     eax,eax
  572.         xor     di,di
  573.         mov     cx,65536/4
  574.         rep     stosd
  575.  
  576.         MPOP            ds,es,fs,gs
  577.         popad
  578.         nop
  579.         leave
  580.  
  581.     retf
  582. _KARMA    endp
  583. ;********************************************
  584. ;              MAIN END
  585. ;--------------------------------------------
  586. ;********************************************
  587. disto2    proc near
  588. ;
  589. ; cette procedure est la meme que 'disto proc near'
  590. ; mais elle affiche l'image disto au pixel près (><par 4 pix.)
  591. ;
  592. hauteur  = 60 ;80
  593. longueur = 320
  594. xstartbm = 0
  595. ystartbm = 20
  596. screenof = (320*(60+10))/4
  597. speedx   = 2 ;5
  598. speedy   = 1 ;3
  599.  
  600.     mov     ax,picture
  601.     mov     gs,ax
  602.  
  603.     xor ebx,ebx
  604.  
  605.         push    cx
  606.         mov     cx,CurStep       
  607. @@:
  608.     add     decal1,speedy    ; FRAME COUNTER ADJUST 
  609.     add     DECAL2,speedx
  610.  
  611.         dec     cx
  612.         jnz     @B
  613.         pop     cx
  614.  
  615.     mov al,decal1           ;  faire gaffe
  616.     mov bx,offset dec1+2    ;
  617.     mov cs:[BX],al          ;
  618.     mov bx,offset dec3+2    ;
  619.     mov cs:[BX],al          ;
  620.     mov bx,offset dec5+2    ;
  621.     mov cs:[BX],al          ;
  622.     mov bx,offset dec7+2    ;
  623.     mov cs:[BX],al          ;
  624.  
  625.                 ;  AUTOMODIFICATION !!!!
  626.     mov al,decal2           ;
  627.     mov bx,offset dec2+2    ;
  628.     mov cs:[BX],al          ;
  629.     mov bx,offset dec4+2    ;
  630.     mov cs:[BX],al          ;
  631.     mov bx,offset dec6+2    ;
  632.     mov cs:[BX],al          ;
  633.     mov bx,offset dec8+2    ;
  634.     mov cs:[BX],al          ;
  635.  
  636. ;------------plane0
  637.  
  638.     mov     ax,vio_seg
  639.     mov     es,ax
  640.     mov     di,screenof         ; offset (/4) de depart sur l'écran
  641.  
  642.     mov     ah,00000001b        ; 0001
  643.     mov     al,sc_map_mask
  644.     mov     dx,3C4h
  645.     out     dx,ax
  646.  
  647.     mov     bp,xstartbm         ; x de depart sur le bitmap
  648.     mov     cx,longueur/4
  649. oneplane0:
  650.     mov     dx,ystartbm         ; y de depart sur le bitmap
  651.     push    cx
  652.     mov     cx,hauteur
  653. onecol0:
  654.     push    cx
  655.     mov     bx,dx                   ;dx=y
  656.     mov     si,word ptr[mul320tb+2*ebx]
  657.     add     si,bp                   ;bp=x
  658.     mov     bx,bp                   ;decale en Y
  659. dec1:
  660.     add     bl,10         ; AM
  661.     xor     bh,bh
  662.     mov     ax,cosine[2*ebx]
  663.     add     si,ax
  664.     mov     bx,dx                   ;decale en X
  665. dec2:                     ; AM
  666.     add     bl,10
  667.     mov     ax,cosine[2*ebx]
  668.     sar     ax,1
  669.     add     si,ax
  670.     lodsb   gs:[si]
  671.     stosb
  672.     inc     dx
  673.     add     di,79
  674.     pop     cx
  675.     loop    onecol0
  676.     add     bp,4                    ; !!! 4 pour pixel près!
  677.     sub     di,(80*hauteur)-1
  678.     pop     cx
  679.     loop    oneplane0
  680. ;------------plane1
  681.     mov     ax,picture
  682.     mov     gs,ax
  683.     mov     ax,vio_seg
  684.     mov     es,ax
  685.     mov     di,screenof         ; offset (/4) de depart sur l'écran
  686.     mov     ah,00000010b        ; 0010
  687.     mov     al,sc_map_mask
  688.     mov     dx,3C4h
  689.     out     dx,ax
  690.     mov     bp,xstartbm+1       ; x de depart sur le bitmap
  691.     mov     cx,longueur/4
  692. oneplane1:
  693.     mov     dx,ystartbm         ; y de depart sur le bitmap
  694.     push    cx
  695.     mov     cx,hauteur
  696. onecol1:
  697.     push    cx
  698.     mov     bx,dx                   ;dx=y
  699.     mov     si,word ptr[mul320tb+2*ebx]
  700.     add     si,bp                   ;bp=x
  701.     mov     bx,bp                   ;decale en Y
  702. dec3:
  703.     add     bl,10
  704.     xor     bh,bh
  705.     mov     ax,cosine[2*ebx]
  706.     add     si,ax
  707.     mov     bx,dx                   ;decale en X
  708. dec4:
  709.     add     bl,10
  710.     mov     ax,cosine[2*ebx]
  711.     sar     ax,1
  712.     add     si,ax
  713.     lodsb   gs:[si]
  714.     stosb
  715.     inc     dx
  716.     add     di,79
  717.     pop     cx
  718.     loop    onecol1
  719.     add     bp,4                    ; !!! 4 pour pixel près!
  720.     sub     di,(80*hauteur)-1
  721.     pop     cx
  722.     loop    oneplane1
  723. ;------------plane2
  724.     mov     ax,picture
  725.     mov     gs,ax
  726.     mov     ax,vio_seg
  727.     mov     es,ax
  728.     mov     di,screenof         ; offset (/4) de depart sur l'écran
  729.     mov     ah,00000100b        ; 0100
  730.     mov     al,sc_map_mask
  731.     mov     dx,3C4h
  732.     out     dx,ax
  733.     mov     bp,xstartbm+2       ; x de depart sur le bitmap
  734.     mov     cx,longueur/4
  735. oneplane2:
  736.     mov     dx,ystartbm         ; y de depart sur le bitmap
  737.     push    cx
  738.     mov     cx,hauteur
  739. onecol2:
  740.     push    cx
  741.     mov     bx,dx                   ;dx=y
  742.     mov     si,word ptr[mul320tb+2*ebx]
  743.     add     si,bp                   ;bp=x
  744.     mov     bx,bp                   ;decale en Y
  745. dec5:
  746.     add     bl,10
  747.     xor     bh,bh
  748.     mov     ax,cosine[2*ebx]
  749.     add     si,ax
  750.     mov     bx,dx                   ;decale en X
  751. dec6:        
  752.     add     bl,10
  753.     mov     ax,cosine[2*ebx]
  754.     sar     ax,1
  755.     add     si,ax
  756.     lodsb   gs:[si]
  757.     stosb
  758.     inc     dx
  759.     add     di,79
  760.     pop     cx
  761.     loop    onecol2
  762.     add     bp,4                    ; !!! 4 pour pixel près!
  763.     sub     di,(80*hauteur)-1
  764.     pop     cx
  765.     loop    oneplane2
  766. ;------------plane3
  767.     mov     ax,picture
  768.     mov     gs,ax
  769.     mov     ax,vio_seg
  770.     mov     es,ax
  771.     mov     di,screenof         ; offset (/4) de depart sur l'écran
  772.     mov     ah,00001000b        ; 1000
  773.     mov     al,sc_map_mask
  774.     mov     dx,3C4h
  775.     out     dx,ax
  776.     mov     bp,xstartbm+3       ; x de depart sur le bitmap
  777.     mov     cx,longueur/4
  778. oneplane3:        
  779.     mov     dx,ystartbm         ; y de depart sur le bitmap
  780.     push    cx
  781.     mov     cx,hauteur
  782. onecol3:        
  783.     push    cx
  784.  
  785.     mov     bx,dx                   ;dx=y
  786.     mov     si,word ptr[mul320tb+2*ebx]
  787.     add     si,bp                   ;bp=x
  788.     mov     bx,bp                   ;decale en Y
  789. dec7:        
  790.     add     bl,10
  791.     xor     bh,bh
  792.     mov     ax,cosine[2*ebx]
  793.     add     si,ax
  794.     mov     bx,dx                   ;decale en X
  795. dec8:        
  796.     add     bl,10
  797.     mov     ax,cosine[2*ebx]
  798.     sar     ax,1
  799.     add     si,ax
  800.     lodsb   gs:[si]
  801.     stosb
  802.     inc     dx
  803.     add     di,79
  804.     pop     cx
  805.     loop    onecol3
  806.     add     bp,4                    ; !!! 4 pour pixel près!
  807.     sub     di,(80*hauteur)-1
  808.     pop     cx
  809.     loop    oneplane3
  810.  
  811. ret
  812. disto2 endp
  813. ;********************************************
  814. include disk.inc
  815. ;lecture
  816.     ;cx     doit contenir la taille
  817.     ;ds:dx  pointe sur le nom
  818.     ;ds:bp  l'adresse de destination
  819. ;ecriture 
  820.     ;cx      doit contenir la taille 
  821.     ;ds:dx   pointe sur le nom du fichier
  822.     ;bp      doit contenir l'offset d'ecriture DANS le fichier(16bits...)
  823.     ;ds:si   l'adresse de la zone a ecrire
  824.  
  825. ;*************************************************        
  826. _init320200 proc near
  827.  
  828.        ;-- On commence par déclencher le mode 13h pour que le BIOS -----
  829.        ;-- effectue la plus grande partie de l'initialisation ----------
  830.        ;-- Puis on modifie les registres qui n'ont pas encore le -------
  831.        ;-- contenu souhaité. -------------------------------------------
  832.  
  833.        mov   ax,0013h                               ;Appelle le mode 13h
  834.        int   10h
  835.  
  836.        mov   dx,GC_INDEX                  ;Désactive par le bit numéro 4
  837.        mov   al,GC_GRAPH_MODE        ;la séparation des adresses mémoire
  838.        out   dx,al                      ;dans le registre mode graphique
  839.        inc   dx                                 ;du contrôleur graphique
  840.        in    al,dx
  841.        and   al,11101111b
  842.        out   dx,al
  843.        dec   dx
  844.  
  845.        mov   al,GC_MISCELL                 ;idem dans le registre divers
  846.        out   dx,al                                  ;par le bit numéro 1
  847.        inc   dx                                                        ;
  848.        in    al,dx
  849.        and   al,11111101b
  850.        out   dx,al
  851.  
  852.        mov   dx,SC_INDEX            ;Modifie le registre de mode mémoire
  853.        mov   al,SC_MEM_MODE                   ;du contrôleur de séquence
  854.        out   dx,al               ;de façon à mettre fin à la répartition
  855.        inc   dx                ;des adresses mémoire sur plusieurs plans
  856.        in    al,dx                   ;de bits et à fixer le plan courant
  857.        and   al,11110111b           ;par le registre de masquage binaire
  858.        or    al,4                                                      ;
  859.        out   dx,al
  860.  
  861.        mov   ax,vio_seg                ;Remplit les quatre plans de bits
  862.        mov   es,ax                   ;avec le code couleur 00h et efface
  863.        xor   di,di                                              ;l'écran
  864.        mov   ax,di
  865.        mov   cx,8000h
  866.        rep   stosw
  867.  
  868.        mov   dx,CRTC_INDEX                  ;Met fin au mode double -mot
  869.        mov   al,CC_UNDERLINE         ; par le moyen du bit 6 du registre
  870.        out   dx,al               ; de soulignement du contrôleur d'écran
  871.        inc   dx
  872.        in    al,dx
  873.        and   al,10111111b
  874.        out   dx,al
  875.        dec   dx
  876.  
  877.        mov   al,CC_MODE_CTRL        ;Passe du mode mot au mode octet par
  878.        out   dx,al            ;le moyen du bit 6 du registre de contrôle
  879.        inc   dx                           ;de mode du contrôleur d'écran
  880.        in    al,dx
  881.        or    al,01000000b
  882.        out   dx,al
  883.  
  884.        ret                                        ;retourne à l'appelant
  885.  
  886. _init320200 endp                                    ;Fin de la procédure
  887. ;*************************************************        
  888. clear_screens    proc near
  889.     mov             dx,3c4h                 
  890.     mov             al,sc_map_mask          
  891.     mov             ah,00001111b
  892.     out             dx,ax
  893.     mov             ax,vio_seg
  894.     mov             es,ax
  895.     mov             di,0
  896.     mov             ax,00
  897.     mov             cx,64000/4
  898.     rep             stosw
  899.     call            show
  900.     call            set
  901.     mov             ax,vio_seg
  902.     mov             es,ax        
  903.     mov             di,0
  904.     mov             ax,00                  
  905.     mov             cx,64000/4
  906.     rep             stosw
  907. ret
  908. clear_screens endp
  909. ;************************************
  910. ; flippe les 2 pages ecran (0 et 1) *
  911. ;************************************
  912. ;*************************************************
  913. set        proc near
  914.  
  915. cmp     pi,1
  916. je      se2
  917. mov     pi,1
  918. mov     word ptr vio_seg,0a400h      ;
  919. jmp     ok_set                       ; alterne 0e et 1e pages !!
  920. se2:                                 ;
  921. mov     pi,0                         ;
  922. mov     word ptr vio_seg,0a000h      ;
  923. ok_set:
  924. ret
  925.  
  926. set  endp
  927. ;*************************************************
  928. show        proc near
  929. sh1:
  930. cmp   pv,1
  931. je    sh2
  932. mov   pv,1
  933. mov   al,64
  934. jmp   ok_show
  935. sh2:
  936. mov   pv,0
  937. mov   al,0
  938. ;--------------------page visible , non concernee par setpix-----
  939.  
  940. ok_show:
  941. mov   ah,al                         ;Octet fort de l'offset en AH
  942. mov   dx,CRTC_INDEX                ;Adresse du contrôleur d'écran
  943. mov   al,CC_START_HI                    ;Numéro du registre en AL
  944. out   dx,ax                                   ;Effectue la sortie
  945.  
  946. ret
  947. show       endp
  948. ;*************************************************
  949. put_palette     proc    near
  950. ; offset dans ds:si    , 256 couleurs
  951. ; luminance dans bl
  952.     pusha
  953.     mov     ah,0
  954.     mov     al,0                    ;the first color to write is # 0
  955.     
  956.     mov     cx,256*3                ;nb of bytes to write
  957.     
  958.     mov     dx,03c8h                ;VGA PEL address write mode register
  959.     out     dx,al           
  960.     inc     dx                      ;VGA PEL data register (03c9h)
  961.  
  962. paloo:    
  963.     lodsb
  964.     mul     bl
  965.     mov     al,ah
  966.     out     dx,al
  967.     loop    paloo
  968.     popa
  969. ret
  970. put_palette     endp
  971. ;*************************************************
  972. ; pour mettre la couleur du fond en noir et en blanc
  973. ;*************************************************       
  974. black0  proc near
  975.     mov     dx,3c8h
  976.     xor     al,al
  977.     out     dx,al
  978.     mov     dx,3c9h
  979.     xor     al,al
  980.     out     dx,al
  981.     out     dx,al
  982.     out     dx,al
  983.     ret
  984. black0  endp
  985. white0  proc near
  986.     mov     dx,3c8h
  987.     xor     al,al
  988.     out     dx,al
  989.     mov     al,63
  990.     mov     dx,3c9h
  991.     out     dx,al
  992.     xor     al,al
  993.     out     dx,al
  994.     out     dx,al
  995.     ret
  996. white0  endp
  997. gray0   proc near
  998.     mov     dx,3c8h
  999.     xor     al,al
  1000.     out     dx,al
  1001.     mov     al,20
  1002.     mov     dx,3c9h
  1003.     out     dx,al
  1004.     out     dx,al
  1005.     xor     al,al
  1006.     out     dx,al
  1007.     ret
  1008. gray0   endp
  1009.  
  1010. ;**********************************************************        
  1011. ; port 3da bit 3
  1012. wait_vbl        proc    near    ; pour attendre la VBL
  1013.  
  1014.     mov     dx,03DAh
  1015.     in      al,dx
  1016.     jmp     $+2
  1017.     test    al,08h
  1018.     jz      V_Ready
  1019. V_Not_Ready:
  1020.     in      al,dx
  1021.     jmp     $+2
  1022.     test    al,08h
  1023.     jz      V_Not_Ready
  1024. V_Ready:
  1025.     in      al,dx
  1026.     jmp     $+2
  1027.     test    al,08h
  1028.     jz      V_Ready
  1029.     ret
  1030.  
  1031. wait_vbl        endp
  1032.  
  1033. KARMA_TEXT   ENDS
  1034. end
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.