
;*************************
;*** NOM :  demo       ***
;*** DEBUTE  6/96      ***
;*** DER MODIF 6/96    ***
;*************************


DOSSEG
.MODEL SMALL
STACK 100H
.486

INCLUDE GENERALE.INC
INCLUDE VIDEO.INC
INCLUDE CLAVIER.INC
INCLUDE EMS.INC
INCLUDE SPRITE4.INC
INCLUDE GRAPH.INC
INCLUDE MATH.INC
INCLUDE 3D.INC


VAR
 Hold_mode DB 0

 Fich_balle DB 'BAllE.SPR',0
 Fich_pal   DB 'OMF1.img',0
 Fich_fond  DB 'OMF1.img',0

 TAB_cosinus
 TAB_sinus

 Variable_3d
 Sprite_balle DW 0
 Page_ DW 0
 x dw 160
 y dw 200
 ang dw 0
 d db 0

DEBUT
 SAVE_MODE Hold_mode          ;sauve l'ancien mode video
 MODE_4P 19 ;05fh                   ;passe en mode 4 pages.
 GO_400

 NEW_KEY                      ;nouveau gestionnaire de clavier.

 GET_MEM BUFFER_fond,128*1024        ;r‚serve le buffer pour le fond de l'‚cran.
 Load_sprite Fich_balle,Sprite_balle ;charge les sprite.
 Load_palette Fich_pal               ;Charge la palette.
 Load_img Fich_fond,buffer_fond      ;Charge l'image de fond.
 ADD Buffer_fond,4000
 Load_img Fich_fond,buffer_fond
 SUB Buffer_fond,4000


 PUT_MEM_RAM Buffer_fond,page1,64000 ; Copy dans la ram video l'image
 PUT_MEM_RAM Buffer_fond,page2,64000 ; du fond.
 PUT_MEM_RAM Buffer_fond,page3,64000 ;  
 PUT_MEM_RAM Buffer_fond,page4,64000 ;



 SELECT_PAGE Page_                     ;Selectionne la page.

overscan 10
;deprot_crtc



Boucle0:


cmp d,0

jz suit
mov dx,crtc_index
mov al,000h
out dx,al
inc dx
in al,dx
sub al,1
out dx,al

mov dx,crtc_index
mov al,01h
out dx,al
inc dx
in al,dx
sub al,1
out dx,al

mov dx,crtc_index
mov al,04h
out dx,al
inc dx
in al,dx
sub al,1
out dx,al


mov dx,crtc_index
mov al,05h
out dx,al
inc dx
in al,dx
and al,10000000b
or al,00111111b
out dx,al

suit:

key 2
je sui2
mov d,1
sui2:

key 3
je sui3
mov d,0
sui3:

;Fixe diff‚rent registre du controleur graphique pour obtenir un effet video.

 MOV DX,3ceh
 MOV AL,03
 MOV AH,00000b      ;Fixe le registre function select.
 OUT DX,AX
 MOV AL,01          ;Fixe le registre enable set reset.
 MOV AH,0000b
 OUT DX,AX
 MOV AL,0
 MOV AH,1111b             ;Fixe le registre set reset.
 OUT DX,AX
 MOV AL,08
 MOV AH,00001111b                  ;Fixe le registre map masq
 OUT DX,AX

  add ang,1
  mov ax,ang
  xor dx,dx
  mov bx,360
  div bx
  mov ang,dx





  lea di,cos
  add di,ang
  mov cx,x
  mov al,ds:di
  xor ah,ah
  add cx,ax
  sub cx,100

  lea di,sin
  add di,ang
  mov dx,y
  mov al,ds:di
  xor ah,ah
  shr ax,1
  sub dx,ax
  add dx,50



  put_sprite_3d sprite_balle,0,cx,dx,0



  lea di,cos
  add di,ang
  mov cx,x
  mov al,ds:di
  xor ah,ah
  shr ax,2
  add cx,ax
  sub cx,25

  lea di,sin
  add di,ang
  mov dx,y
  mov al,ds:di
  xor ah,ah
  sub dx,ax
  add dx,100



  put_sprite_3d sprite_balle,0,cx,dx,0

  put_sprite_3d sprite_balle,0,x,y,0







  XOR PAGE_,10b           ;Inverse le premier bit de la variable PAGE_.
  SELECT_PAGE Page_       ;Selectionne la page(page_).
  WAIT_faisceau           ;Attend le retour du faisceau verticale.
  Montre_page Page_       ;Montre la page(page_).

;Fixe diff‚rent registre du controleur graphique pour enlever l'effet video.

 MOV DX,3ceh
 MOV AL,03
 MOV AH,00000b      ;Fixe le registre function select.
 OUT DX,AX
 MOV AL,01          ;Fixe le registre enable set reset.
 MOV AH,0000b
 OUT DX,AX
 MOV AL,08
 MOV AH,11111111b                  ;Fixe le registre map masq
 OUT DX,AX


 MASK_ALL_sprite       ;Efface les sprites affich‚ sur la page non-active.
  

KEY 1                  ;Touche break actionn‚?
 JE BOUCLEfin          ;non on continue.
  JMP Boucle0          ;oui on sort.
 BOUCLEfin:


 FREE_MEM BUFFER_fond           ;lib‚re la memoire utilis‚ pour le fond de l'image.
 Detruit_sprite sprite_balle    ;lib‚re la memoire pour les sprites.
 HOLD_KEY                       ;restore le gestionnaire de clavier.
 MODE Hold_mode                 ;restore le mode video.

ROUTINES
 IMAGES_ROUTINES          ;implementation des routine images.
 SPRITES_ROUTINES         ;implementation des routines sprites.
 GRAPH_ROUTINES
 _3d_Routine
FIN
