home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / VLA_FONT.ZIP / HSCR8X.ASM < prev    next >
Assembly Source File  |  1993-09-27  |  6KB  |  251 lines

  1.     IDEAL
  2.     DOSSEG
  3.     MODEL SMALL
  4.     STACK 200h
  5.     CODESEG
  6.     p386
  7.     
  8.     ASSUME CS:@CODE, DS:@CODE
  9. ────────────────────────────────────────────────────────────────────────────
  10. STRUC VCHHDR
  11.     Ident   db  "VLACH"
  12.     From    db  ?
  13.     X       db  ?
  14.     Y       db  ?
  15.     NumChar db  ?
  16. ENDS
  17.  
  18. STRUC Pal
  19.     R       db  ?
  20.     G       db  ?
  21.     B       db  ?
  22. ENDS
  23. ────────────────────────────────────────────────────────────────────────────
  24. INCLUDE "MODEX.INC"
  25.  
  26. FileName_VCH    db      "Font5.VCH",0
  27. FileName_PAL    db      "Font5.PAL",0
  28.  
  29. Seg_VCH         dw      0
  30.  
  31. Palette         Pal     256 dup (<>)
  32. VCHHEADER       VCHHDR  <>
  33. CharWidths      db      256 dup (0)
  34.  
  35. TheMessage      db      " THIS IS A REALLY REALLY HUGE SCROLLER!  "
  36.                 db      " EACH PIXEL IS NOW AN 8X8 SQUARE!!       "
  37.                 db      0
  38.  
  39. MsgOff          dw      offset TheMessage
  40. CharOff         dw      0       ;offset to current column to draw of chr
  41. XYsize          dw      ?       ;number of bytes in a char
  42. CurColumn       db      1
  43. DestOff         dw      0
  44. SCReenWidth     =       130
  45. ────────────────────────────────────────────────────────────────────────────
  46.     ────────────────────────────────────────────────────────────────────
  47.     ; Load in the font named in FileName_VCH and loads in the Palette
  48.     ; named in FileName_PAL. 
  49.     ;
  50.     ; Returns CF = 1 if there was an error
  51.     ────────────────────────────────────────────────────────────────────
  52. PROC LoadFont NEAR
  53.     pusha
  54.     push    ds
  55.  
  56.     mov     ax,cs
  57.     mov     ds,ax
  58.     mov     dx,offset FileName_PAL      ;open the palette file
  59.     mov     ax,3d00h
  60.     int     21h
  61.     jc      @@Error
  62.     mov     bx,ax
  63.  
  64.     mov     dx,offset Palette           ;read in the palette
  65.     mov     cx,768
  66.     mov     ah,3fh
  67.     int     21h
  68.  
  69.     mov     ah,3eh                      ;close PAL file
  70.     int     21h
  71.  
  72.     mov     dx,offset FileName_VCH      ;open VCH file
  73.     mov     ax,3d00h
  74.     int     21h
  75.     jc      @@Error
  76.     mov     bx,ax
  77.  
  78.     mov     dx,offset VCHHeader         ;load in the header
  79.     mov     cx,size VCHHDR
  80.     mov     ah,3fh
  81.     int     21h
  82.  
  83.     mov     al,[VCHHEADER.X]            ;calc data size
  84.     mul     [VCHHEADER.Y]
  85.     mov     [XYsize],ax
  86.     movzx   cx,[VCHHEADER.NumChar]
  87.     mul     cx
  88.     mov     cx,ax
  89.  
  90.     mov     ax,[cs:SEG_VCH]             ;move SEG_VCH into DS, but be sure
  91.     or      ax,ax                       ;the segment isn't 0
  92.     stc
  93.     je      @@Error
  94.     mov     ds,ax
  95.     xor     dx,dx                       ;load in the data
  96.     mov     ah,3fh
  97.     int     21h
  98.  
  99.     mov     ax,cs
  100.     mov     ds,ax
  101.     mov     dx,offset CharWidths
  102.     movzx   cx,[VCHheader.NumChar]
  103.     mov     ah,3fh
  104.     int     21h                         ;read in widths of chars
  105.  
  106.     mov     ah,3eh                      ;close VCH file
  107.     int     21h
  108.     clc
  109.  
  110. @@Error:
  111.  
  112.     pop     ds
  113.     popa
  114.     ret
  115. ENDP
  116.     ────────────────────────────────────────────────────────────────────
  117.     ;Starts the next letter in the message
  118.     ────────────────────────────────────────────────────────────────────
  119. PROC NewChar NEAR
  120.     pusha
  121.     push    ds
  122.     mov     ax,cs
  123.     mov     ds,ax
  124.  
  125.     mov     si,[MsgOff]     ;get the offset to the next char
  126. @@MsgLoop:
  127.     lodsb
  128.     or      al,al
  129.     jne     @@IsaChar
  130.     mov     si,offset TheMessage
  131.     jmp short @@MsgLoop
  132.  
  133. @@IsaChar:
  134.     mov     ah,[VCHHEADer.From]
  135.     add     ah,[VCHHEADer.NumChar]
  136.     cmp     al,[VCHHEADer.FROM]
  137.     jb      @@MsgLoop
  138.     cmp     al,ah
  139.     ja      @@MsgLoop
  140.  
  141.     mov     [MsgOff],si
  142.     sub     al,[VCHheader.From]
  143.     movzx   ax,al
  144.     mov     bx,ax
  145.     mul     [XYsize]
  146.     shl     ax,1
  147.     mov     [CharOff],ax
  148.     
  149.     mov     al,[CharWidths + bx]
  150.     shl     al,1
  151.     mov     [CurColumn],al
  152.     
  153.     pop     ds
  154.     popa
  155.     ret
  156. ENDP
  157.     ────────────────────────────────────────────────────────────────────
  158.     ; Draws the Next column onto the screen, calls NewChar if done with
  159.     ; current character
  160.     ────────────────────────────────────────────────────────────────────
  161. PROC DrawColumn NEAR
  162.     pusha
  163.     push    ds es fs
  164.     mov     ax,cs
  165.     mov     ds,ax
  166.  
  167.     mov     bx,[DestOff]
  168.     add     bx,2
  169.     @Set_Start_Offset
  170.  
  171.     dec     [CurColumn]
  172.     jne     @@NoNew
  173.  
  174.     call    NewChar
  175.  
  176. @@NoNew:
  177.     mov     fs,[SEG_VCH]
  178.     mov     es,[VGASEG]
  179.     mov     si,[CharOff]    ;fs:si points to the data
  180.     shr     si,1
  181.     mov     di,[DestOff]
  182.  
  183.     movzx   dx,[VCHheader.X]
  184.     movzx   cx,[VCHheader.Y]
  185.     mov     bp,SCReenWidth         ;screen width
  186.  
  187. @@Zloop:
  188.     mov     al,[fs:si]
  189.     mov     [es:di],al
  190.     mov     [es:di+SCReenWidth/2],al
  191.     add     di,bp
  192.  
  193.     add     si,dx
  194.  
  195.     loop    @@ZLoop
  196.  
  197.     inc     [DestOff]
  198.     cmp     [DestOff],ScreenWidth/2
  199.     jb      @@okok
  200.  
  201.     mov     [DestOff],0
  202.  
  203. @@okok:
  204.     inc     [CharOff]
  205.  
  206.     pop     fs es ds
  207.     popa
  208.     ret
  209. ENDP
  210. ────────────────────────────────────────────────────────────────────────────
  211. START:
  212.     mov     ax,cs
  213.     mov     ds,ax
  214.  
  215.     mov     ax,ss
  216.     mov     bx,sp
  217.     add     bx,15
  218.     shr     bx,4
  219.     add     ax,bx
  220.     mov     [SEG_VCH],ax
  221.  
  222.     @SetModeX m256x200x256, 520
  223.  
  224.     call    LoadFont
  225.     mov     si,offset Palette
  226.     mov     cx,256
  227.     mov     al,0
  228.     @WritePalette
  229.  
  230.     mov     dx,CRTC_Index
  231.     mov     al,9
  232.     mov     ah,15    ;[DaHeight]
  233.     out     dx,ax
  234.  
  235. @@MainLoop:
  236.     @FullVertWait
  237.     call    DrawColumn
  238.  
  239.     mov     ah,1
  240.     int     16h
  241.     jz      @@MainLoop
  242.  
  243.     mov     ah,0
  244.     int     16h
  245.  
  246.     mov     ax,3
  247.     int     10h
  248.     mov     ax,4c00h
  249.     int     21h
  250. END START
  251.