home *** CD-ROM | disk | FTP | other *** search
/ PC Interdit / pc-interdit.iso / trainer / modexlib.asm < prev    next >
Assembly Source File  |  1994-09-20  |  2KB  |  171 lines

  1. .286
  2.   w equ word ptr cs:
  3.   b equ byte ptr cs:
  4. ;code segment public
  5. ;code ends
  6. code segment public
  7. ;gcode group code,arescode
  8. assume cs:code,ds:code
  9. extrn setpal:near
  10. public init_modex,p13_2_modex,squeeze
  11. public vscreen
  12.  
  13. Init_ModeX proc pascal
  14.     mov ax,0013h
  15.   int 10h
  16.  
  17.   mov dx,3c4h
  18.   mov al,4
  19.   out dx,al
  20.   inc dx
  21.   in al,dx
  22.   and al,0f7h
  23.   or al,4h
  24.   out dx,al
  25.   dec dx
  26.   mov ax,0f02h
  27.   out dx,ax
  28.  
  29.     mov ax,0a000h
  30.   mov es,ax
  31.   xor di,di
  32.   xor ax,ax
  33.   mov cx,8000h
  34.   cld
  35.   rep stosw
  36.  
  37.   mov dx,3d4h
  38.   mov al,14h
  39.   out dx,al
  40.   inc dx
  41.   in al,dx
  42.   and al,0bfh
  43.   out dx,al
  44.   dec dx
  45.   mov al,17h
  46.   out dx,al
  47.   inc dx
  48.   in al,dx
  49.   or al,40h
  50.   out dx,al
  51.   ret
  52. Endp
  53.  
  54. plane_l: db 0
  55. plane_pos: dw 0
  56. vscreen: dd 0
  57.  
  58. p13_2_modex proc pascal start,pic_size:word
  59.         mov b plane_l,1
  60.     mov w plane_pos,0
  61.     push ds
  62.     lds si,dword ptr cs:vscreen
  63.     mov w plane_pos,si
  64.     mov ax,0a000h
  65.     mov es,ax
  66.     mov di,start
  67.     mov cx,pic_size
  68. @lpplane:
  69.     mov al,02h
  70.     mov ah,b plane_l
  71.     mov dx,3c4h
  72.     out dx,ax
  73.  
  74.     @lp1:
  75.     movsb
  76.     add si,3
  77.     loop @lp1
  78.  
  79.         mov di,start
  80.     inc w plane_pos
  81.     mov si,w plane_pos
  82.     mov cx,pic_size
  83.     shl b plane_l,1
  84.     cmp b plane_l,10h
  85.     jne @lpplane
  86.  
  87.     pop ds
  88.     ret
  89. Endp
  90. Split proc pascal row:byte
  91.     mov bl,row
  92.   xor bh,bh
  93.     shl bx,1
  94.   mov cx,bx
  95.  
  96.     mov dx,3d4h
  97.   mov al,07h
  98.   out dx,al
  99.   inc dx
  100.   in al,dx
  101.     and al,11101111b
  102.   shr cx,4
  103.   and cl,16
  104.   or al,cl
  105.   out dx,al
  106.  
  107.   dec dx
  108.   mov al,09h
  109.   out dx,al
  110.   inc dx
  111.   in al,dx
  112.   and al,10111111b
  113.   shr bl,3
  114.   and bl,64
  115.   or al,bl
  116.   out dx,al
  117.  
  118.   dec dx
  119.   mov al,18h
  120.   mov ah,row
  121.   shl ah,1
  122.   out dx,ax
  123.   ret
  124. Endp
  125. SetStart proc pascal t:word
  126.     mov dx,3d4h
  127.   mov al,0ch
  128.   mov ah,byte ptr t + 1
  129.   out dx,ax
  130.   mov al,0dh
  131.   mov ah,byte ptr t
  132.   out dx,ax
  133.   ret
  134. Endp
  135. WaitRetrace proc pascal
  136.     mov dx,3dah
  137. @wait1:
  138.     in al,dx
  139.   test al,8h
  140.     jz @wait1
  141. @wait2:
  142.     in al,dx
  143.   test al,8h
  144.   jnz @wait2
  145.     ret
  146. Endp
  147.  
  148. squeeze proc pascal
  149.     mov si,200*80
  150.   mov di,199
  151.   push di
  152.   call split
  153.   push si
  154.   call setstart
  155.   call waitretrace
  156.   call setpal
  157. sqlp:
  158.   call waitretrace
  159.   push di
  160.   call split
  161.   push si
  162.   call setstart
  163.   sub si,2*80
  164.   sub di,2
  165.   cmp di,99d
  166.   jae sqlp
  167.     ret
  168. squeeze endp
  169. code ends
  170. end
  171.