SCROLLING_ROUTINES MACRO
 SCfondADD DW 0
 SCADD     DW 0
 SCEMSADD  DW 0
 SChandle  DW 0  
 SCH       DW 0
 SCVES     DW 0
 SCL       DW 0
 SCposX    DW 0
 SCposY    DW 0
 SCofsP    DW 0
 SCofs     DW 0
 SCMAXX    DW 0 
 SCMAXY    DW 0
 SCP       DW 0
 SCFOND    DW 0
 SCECRAN   DW 0

 SCROLL_HORIZONTALE_D:
  INC WORD PTR CS:SCPOSX
  MOV AX,CS:SCMAXX
  CMP CS:SCPOSX,AX
  JB SC_H_D0 
  MOV AX,CS:SCMAXX
  MOV CS:SCPOSX,AX 
 SC_H_D0:
  MOV AX,CS:SCPOSX
  DEC AX
  XOR DX,DX
  MOV BX,320
  DIV BX
  PUSH AX
  INC AX
  PUSH DX
  MOV BX,4
  MUL BX
  PUSH AX
  MOV BX,AX
  MOV AX,4400H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  PUSH BX
  MOV AX,4401H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  PUSH BX
  MOV AX,4402H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  MOV AX,4403H
  MOV DX,CS:SChandle
  INT 67H

  POP DX
  MOV DI,DX
  MOV SI,DX
  MOV AX,CS:SCEMSADD
  MOV GS,AX
  POP AX
  MOV BL,20
  MUL BL
  PUSH AX
  ADD AX,CS:SCADD
  ADD AX,20
  MOV ES,AX
  MOV CS:SCECRAN,AX

  MOV CX,200
 SC_H_D1:
  
  MOV AL,GS:SI
  MOV ES:DI,AL
  ADD DI,320
  ADD SI,320

 LOOP SC_H_D1

  POP AX
  ADD AX,CS:SCFONDADD
  ADD AX,20
  MOV CS:SCFOND,AX
  MOV ES,AX
  MOV DI,DX
  MOV SI,DX
  MOV CX,200
 SC_H_D2:

  MOV AL,GS:SI
  MOV ES:DI,AL
  ADD DI,320
  ADD SI,320

 LOOP SC_H_D2
RET

 SCROLL_HORIZONTALE_G:
  DEC WORD PTR CS:SCPOSX
  MOV AX,0
  CMP CS:SCPOSX,AX
  JNE SC_H_G0 
  MOV AX,1
  MOV CS:SCPOSX,AX 
 SC_H_G0:
  MOV AX,CS:SCPOSX
  XOR DX,DX
  MOV BX,320
  DIV BX
  PUSH AX
  PUSH DX
  MOV BX,4
  MUL BX
  PUSH AX
  MOV BX,AX
  MOV AX,4400H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  PUSH BX
  MOV AX,4401H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  PUSH BX
  MOV AX,4402H
  MOV DX,CS:SChandle
  INT 67H

  POP BX
  INC BX
  MOV AX,4403H
  MOV DX,CS:SChandle
  INT 67H

  POP DX
  MOV DI,DX
  MOV SI,DX
  MOV AX,CS:SCEMSADD
  MOV GS,AX
  POP AX
  MOV BL,20
  MUL BL
  PUSH AX
  ADD AX,CS:SCADD
  MOV CS:SCECRAN,AX
  MOV ES,AX
  

  MOV CX,200
 SC_H_G1:
  
  MOV AL,GS:SI
  MOV ES:DI,AL
  ADD DI,320
  ADD SI,320

 LOOP SC_H_G1

  POP AX
  ADD AX,CS:SCFONDADD
  MOV CS:SCFOND,AX
  MOV ES,AX
  MOV DI,DX
  MOV SI,DX
  MOV CX,200
 SC_H_G2:

  MOV AL,GS:SI
  MOV ES:DI,AL
  ADD DI,320
  ADD SI,320

 LOOP SC_H_G2
RET



 SCROLL_VERTICALE_B:
  MOV AX,CS:SCPOSY
  ADD AX,199
  MOV BX,320
  MUL BX
  MOV BX,16000
  DIV BX
  MOV BX,AX
  MOV AX,4400H
  MOV DX,CS:SChandle
  INT 67H
  
  MOV AX,CS:SCPOSY                ;calculer l'offset dans cette page.
  ADD AX,199
  MOV BX,320
  MUL BX
  MOV BX,16000
  DIV BX
  MOV AX,DX
  MOV CS:SCOFSP,AX

  MOV AX,CS:SCPOSY                ;calculer l'offset dans la page conventionnel.
  MOV BX,20
  MUL BX
  MOV BX,4000
  DIV BX
  MOV AX,DX
  MOV CS:SCVES,AX
  

  MOV CX,80                      ;Copier d'ems en conventionelle.
  PUSH DS
   MOV AX,CS:SCEMSADD
   MOV DS,AX
   MOV SI,CS:SCOFSP
   MOV AX,CS:SCFONDADD            ;d'abord le fond.
   ADD AX,CS:SCVES
   MOV ES,AX
   XOR DI,DI
   REP MOVSD
                                  
   MOV CX,80                      ;puis l'autre page.
   MOV SI,CS:SCOFSP
   XOR DI,DI
   MOV AX,CS:SCADD
   ADD AX,CS:SCVES
   MOV ES,AX
   REP MOVSD
  POP DS

  MOV CX,80                      ;Copier d'ems en conventionelle.
  PUSH DS
   MOV AX,CS:SCEMSADD
   MOV DS,AX
   MOV SI,CS:SCOFSP
   MOV AX,CS:SCFONDADD            ;d'abord le fond.
   ADD AX,CS:SCVES
   ADD AX,4000
   MOV ES,AX
   XOR DI,DI
   REP MOVSD
                                  
   MOV CX,80                      ;puis l'autre page.
   MOV SI,CS:SCOFSP
   XOR DI,DI
   MOV AX,CS:SCADD
   ADD AX,CS:SCVES
   ADD AX,4000
   MOV ES,AX
   REP MOVSD
  POP DS

  MOV AX,CS:SCVES
  ADD AX,20
  MOV DX,CS:SCFONDADD
  MOV BX,CS:SCADD
  ADD DX,AX
  ADD BX,AX
  MOV CS:SCFOND,DX
  MOV CS:SCECRAN,BX

  INC WORD PTR CS:SCPOSY
  MOV AX,CS:SCMAXY
  CMP CS:SCPOSY,AX
  JB SC_V_B_0
  MOV AX,CS:SCMAXY
  MOV CS:SCPOSY,AX 
 
 SC_V_B_0:

 RET

 SCROLL_VERTICALE_H:
  DEC WORD PTR CS:SCPOSY
  CMP CS:SCPOSY,0
  JNE SC_V_B_1
  MOV CS:SCPOSY,1 

 SC_V_B_1:
  MOV AX,CS:SCPOSY
  ADD AX,199
  MOV BX,320
  MUL BX
  MOV BX,16000
  DIV BX
  MOV BX,AX
  SUB BX,4
  MOV AX,4400H
  MOV DX,CS:SChandle
  INT 67H
  
  MOV AX,CS:SCPOSY                ;calculer l'offset dans cette page.
  ADD AX,199
  MOV BX,320
  MUL BX
  MOV BX,16000
  DIV BX
  MOV AX,DX
  MOV CS:SCOFSP,AX

  MOV AX,CS:SCPOSY                ;calculer l'offset dans la page conventionnel.
  MOV BX,20
  MUL BX
  MOV BX,4000
  DIV BX
  MOV AX,DX
  MOV CS:SCVES,AX
  

  MOV CX,80                      ;Copier d'ems en conventionelle.
  PUSH DS
   MOV AX,CS:SCEMSADD
   MOV DS,AX
   MOV SI,CS:SCOFSP
   MOV AX,CS:SCFONDADD            ;d'abord le fond.
   ADD AX,CS:SCVES
   MOV ES,AX
   XOR DI,DI
   REP MOVSD
                                  
   MOV CX,80                      ;puis l'autre page.
   MOV SI,CS:SCOFSP
   XOR DI,DI
   MOV AX,CS:SCADD
   ADD AX,CS:SCVES
   MOV ES,AX
   REP MOVSD
  POP DS

  MOV CX,80                      ;Copier d'ems en conventionelle.
  PUSH DS
   MOV AX,CS:SCEMSADD
   MOV DS,AX
   MOV SI,CS:SCOFSP
   MOV AX,CS:SCFONDADD            ;d'abord le fond.
   ADD AX,CS:SCVES
   ADD AX,4000
   MOV ES,AX
   XOR DI,DI
   REP MOVSD
                                  
   MOV CX,80                      ;puis l'autre page.
   MOV SI,CS:SCOFSP
   XOR DI,DI
   MOV AX,CS:SCADD
   ADD AX,CS:SCVES
   ADD AX,4000
   MOV ES,AX
   REP MOVSD
  POP DS

  MOV AX,CS:SCVES
  MOV DX,CS:SCFONDADD
  MOV BX,CS:SCADD
  ADD DX,AX
  ADD BX,AX
  MOV CS:SCFOND,DX
  MOV CS:SCECRAN,BX
 RET



PLACER_VERT_SC:

CMP AX,200
JA PLACER_VERT_SC_03

  ADD AX,200
  MOV CS:SCPOSY,AX
PLACER_VERT_SC_02:
  MOV CX,200
 PLACER_VERT_SC_00:
  PUSH CX
   CALL SCROLL_VERTICALE_H
  POP CX
 LOOP PLACER_VERT_SC_00

 JMP PLACER_VERT_SC_04
  
PLACER_VERT_SC_03:
  SUB AX,200
  MOV CS:SCPOSY,AX
  MOV CX,200
 PLACER_VERT_SC_01:
  PUSH CX
   CALL SCROLL_VERTICALE_B 
  POP CX
 LOOP PLACER_VERT_SC_01

PLACER_VERT_SC_04:

RET

PLACER_HORIZ_SC:

CMP AX,320
JA PLACER_HORIZ_SC_03
  ADD AX,320
  MOV CS:SCPOSX,AX
PLACER_HORIZ_SC_02:
  MOV CX,320
 PLACER_HORIZ_SC_00:
  PUSH CX
   CALL SCROLL_HORIZONTALE_G
  POP CX
 LOOP PLACER_HORIZ_SC_00

 JMP PLACER_HORIZ_SC_04
  
PLACER_HORIZ_SC_03:
  SUB AX,320
  MOV CS:SCPOSX,AX
  MOV CX,320
 PLACER_HORIZ_SC_01:
  PUSH CX
   CALL SCROLL_HORIZONTALE_D 
  POP CX
 LOOP PLACER_HORIZ_SC_01

PLACER_HORIZ_SC_04:

RET


ENDM

INIT_SCROLL_HORIZONTALE MACRO LARGEUR
 MOV CS:SCH,1
 MOV CS:SCL,largeur
 MOV AH,41H
 INT 67H
 MOV CS:SCEMSADD,BX
 MOV AX,LARGEUR
 MOV BX,4
 MUL BX
 MOV BX,AX
 MOV AH,43H
 INT 67H
 MOV CS:SChandle,dx
 MOV AH,48H
 MOV BX,4000H
 INT 21H
 ADD AX,2000
 MOV CS:SCfondADD,AX
 ADD AX,6000
 MOV CS:SCADD,AX
 MOV WORD PTR CS:SCposX,1
 MOV WORD PTR CS:SCposY,1
 MOV AX,largeur
 MOV BX,320
 MUL BX
 SUB AX,320
 MOV CS:SCMAXX,AX
ENDM


INIT_SCROLL_VERTICALE MACRO Hauteur
 MOV CS:SCH,Hauteur 
 MOV CS:SCL,0
 MOV AH,41H
 INT 67H
 MOV CS:SCEMSADD,BX
 MOV BX,CS:SCH
 MOV AH,43H
 INT 67H
 MOV CS:SChandle,dx
 MOV AH,48H
 MOV BX,3000H
 INT 21H
 ADD AX,2000
 MOV CS:SCfondADD,AX
 MOV AH,48H
 MOV BX,3000H
 INT 21H
 ADD AX,2000
 MOV CS:SCADD,AX
 MOV CS:SCposX,0
 MOV CS:SCposY,1
 MOV AX,Hauteur
 MOV BX,50
 MUL BX
 MOV CS:SCMAXY,AX
 SUB CS:SCMAXY,200
ENDM

ERASE_SCROLL_VERTICALE MACRO
 MOV AX,CS:SCADD
 SUB AX,2000
 MOV ES,AX
 MOV AH,49H
 INT 21H

 MOV AX,CS:SCFONDADD
 SUB AX,2000
 MOV ES,AX
 MOV AH,49H
 INT 21H

 MOV DX,CS:SChandle
 MOV AH,45H
 INT 67H
ENDM

ERASE_SCROLL_HORIZONTALE MACRO
 MOV AX,CS:SCFONDADD
 SUB AX,2000
 MOV ES,AX
 MOV AH,49H
 INT 21H

 MOV DX,CS:SChandle
 MOV AH,45H
 INT 67H
ENDM


SCROLL_VERT_BAS MACRO
 CALL SCROLL_VERTICALE_B
ENDM

SCROLL_VERT_HAUT MACRO
 CALL SCROLL_VERTICALE_H
ENDM

SCROLL_HORIZ_DROITE MACRO
 CALL SCROLL_HORIZONTALE_D
ENDM

SCROLL_HORIZ_GAUCHE MACRO
 CALL SCROLL_HORIZONTALE_G
ENDM

SCROLL_PLACER_VERT MACRO POSITION
 MOV AX,POSITION
 CMP AX,0
 JNE FIN_SCROLL_PLACER_VERT_00
 MOV AX,1
 JMP FIN_SCROLL_PLACER_VERT
 FIN_SCROLL_PLACER_VERT_00:
 CMP AX,CS:SCMAXY
 JB FIN_SCROLL_PLACER_VERT
 MOV AX,CS:SCMAXY
 SUB AX,1

 FIN_SCROLL_PLACER_VERT:
 CALL PLACER_VERT_SC
ENDM

SCROLL_PLACER_HORIZ MACRO POSITION
 MOV AX,POSITION
 CMP AX,0
 JNE FIN_SCROLL_PLACER_HORIZ_00
 MOV AX,1
 JMP FIN_SCROLL_PLACER_HORIZ
 FIN_SCROLL_PLACER_HORIZ_00:
 CMP AX,CS:SCMAXX
 JB FIN_SCROLL_PLACER_HORIZ
 MOV AX,CS:SCMAXX
 SUB AX,1
 FIN_SCROLL_PLACER_HORIZ:
 CALL PLACER_HORIZ_SC
ENDM

AFFICHE_ECRAN_SH MACRO
 MOV AX,0A000H
 MOV ES,AX
 PUSH DS
 XOR DX,DX
 MOV AX,CS:SCposX
 MOV BX,320
 DIV BX
 MOV SI,DX
 MOV BL,20
 MUL BL
 ADD AX,CS:SCADD
 MOV DS,AX
 XOR DI,DI
 CLD
 MOV CX,16000
 REP MOVSD
 POP DS
ENDM

LOAD_SCROLL_HORIZ MACRO NOM,NB
 JMP LOAD_SCH_B1
  NBPL DW 0

 LOAD_SCH_B1:
  MOV CX,NB
  LOAD_SCH_B0:
  PUSH CX

   MOV BX,CS:NBPL
   MOV AH,44H
   MOV AL,0
   MOV DX,CS:SChandle
   INT 67H

   MOV BX,CS:NBPL
   INC BX
   MOV AH,44H
   MOV AL,1
   MOV DX,CS:SChandle
   INT 67H

   MOV BX,CS:NBPL
   ADD BX,2
   MOV AH,44H
   MOV AL,2
   MOV DX,CS:SChandle
   INT 67H

   MOV BX,CS:NBPL
   ADD BX,3
   MOV AH,44H
   MOV AL,3
   MOV DX,CS:SChandle
   INT 67H


   POP CX
   PUSH CX
   LEA SI,NOM
   MOV AL,NB
   SUB AL,CL
   ADD AL,48
   MOV BYTE PTR DS:[SI+3],AL
   LOAD_PCX NOM,CS:SCEMSADD
   MOV AX,4
   ADD CS:NBPL,AX
  POP CX
  LOOP LOAD_SCH_B0

ENDM



LOAD_SCROLL_VERT MACRO NOM,NB
 JMP LOAD_SCROLL01
  LSMEM  DW 0
  LSMEM2 DW 0 
  LSMEM3 DW 0 
  LSNI   DW 0
 LOAD_SCROLL01:
  GET_MEM CS:LSMEM,65000

  MOV CX,NB
  LOAD_SCROLL02:
  PUSH CX
   LEA SI,NOM
   MOV AL,CL
   ADD AL,47
   MOV BYTE PTR DS:[SI+3],AL
   LOAD_PCX NOM,CS:LSMEM
     
   POP CX
   MOV AX,CX
   PUSH CX
   DEC AX
   MOV BL,4
   MUL BL

   MOV BX,AX
   MOV CS:LSNI,AX
   MOV AH,44H
   MOV AL,0
   MOV DX,CS:SChandle
   INT 67H
   MOV AH,44H
   MOV BX,CS:LSNI
   INC BX
   MOV AL,1
   MOV DX,CS:SChandle
   INT 67H
   MOV AH,44H
   MOV BX,CS:LSNI
   ADD BX,2
   MOV AL,2
   MOV DX,CS:SChandle
   INT 67H
   MOV AH,44H
   MOV BX,CS:LSNI
   ADD BX,3
   MOV AL,3
   MOV DX,CS:SChandle
   INT 67H

   MOV AX,CS:LSMEM
   MOV CS:LSMEM2,AX
   MOV AX,CS:SCEMSADD
   MOV CS:LSMEM3,AX
  
   COPY_DWORDS CS:LSMEM2,CS:LSMEM3,4000
   ADD CS:LSMEM2,1000
   ADD CS:LSMEM3,1024
   COPY_DWORDS CS:LSMEM2,CS:LSMEM3,4000
   ADD CS:LSMEM2,1000
   ADD CS:LSMEM3,1024
   COPY_DWORDS CS:LSMEM2,CS:LSMEM3,4000
   ADD CS:LSMEM2,1000
   ADD CS:LSMEM3,1024
   COPY_DWORDS CS:LSMEM2,CS:LSMEM3,4000
 
   POP CX
   DEC CX
   CMP CX,0
   JE LOAD_SCROLL03
   JMP LOAD_SCROLL02
   LOAD_SCROLL03:

  FREE_MEM CS:LSMEM
ENDM
