home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / VLA_FONT.ZIP / GCX.INC < prev    next >
Text File  |  1993-09-28  |  22KB  |  1,070 lines

  1. PAGEUP  =   73
  2. PAGEDOWN=   81
  3.  
  4. CSRUP   =   72
  5. CSRDN   =   80
  6. CSRLF   =   75
  7. CSRRT   =   77
  8.  
  9. CSRUPC  =   141
  10. CSRDNC  =   145
  11. CSRLFC  =   115
  12. CSRRTC  =   116
  13. ────────────────────────────────────────────────────────────────────────────
  14. ENLARGEOFFSET = 30*SCRW+1
  15.  
  16. MINX    =   2
  17. MINY    =   2
  18. MAXX    =   38
  19. MAXY    =   38
  20.  
  21. STRUC PalStruc
  22.     R   db  ?
  23.     G   db  ?
  24.     B   db  ?
  25. ENDS
  26.  
  27. STRUC VchHdr
  28.     ID      db  "VGACH"
  29.     From    db  " "
  30.     SizeX   db  5
  31.     SizeY   db  5
  32.     NumChar db  64
  33. ENDS
  34.  
  35. STRUC MsgHdr
  36.     Off     dw  ?
  37.     Xpos    dw  ?
  38.     Ypos    dw  ?
  39. ENDS
  40.  
  41. BLACK   =   0
  42. BLUE    =   255
  43. GREEN   =   254
  44. RED     =   253
  45. GREY1   =   252
  46. GREY2   =   251
  47. GREY3   =   250
  48. GREY4   =   249
  49. GREY5   =   248
  50. RED2    =   247
  51. ────────────────────────────────────────────────────────────────────────────
  52. SCRW    =   80
  53. Split   dw  80
  54. SplitDest db    1   ;0= 400, 1=80
  55.  
  56. OldX    dw  ?
  57. OldY    dw  ?
  58.  
  59. Credits     db  1,BLUE,"  Character Grabber",1,GREEN," by "
  60.             db  1,RED,"Draeden",1,GREEN," of ",1,RED,"VLA",0
  61.  
  62. Curchar db  0
  63. Xpos    dw  0
  64. Ypos    dw  0
  65.  
  66. PSPSeg      dw  ?
  67. FileNameTGA db  120 dup (0)
  68. FileNameVCH db  120 dup (0)
  69. TGAexten    db  ".TGA",0
  70. VCHexten    db  ".VCH",0
  71.  
  72. VCHheader   VCHHDR  <>
  73.  
  74. Palette     PalStruc 256 dup (<>)
  75. DefPal      PalStruc <10,00,00>,<25,25,25>,<35,35,35>,<45,45,45>,<56,56,56>
  76.             PalStruc <63,63,63>,<40,00,00>,<00,40,00>,<00,00,40>
  77.  
  78. Font8x8     db  256*8   dup (0) ;holding place for font
  79.  
  80. TextColor   db  RED
  81.     
  82. PicSeg      dw  ?
  83. CharSeg     dw  ?
  84.         
  85. NumChar     db  64
  86.  
  87. SizeMsg db  1,GREEN,"`-' W:-  H:-  #:  -/    X:  - Y:  - ",0
  88. SizeMsg2 db 1,GREY2," A    12   15    21       252   123",0
  89. ClrSize db  1,BLACK," █    ██   ██   ███ ███   ███   ███",0
  90. INST1   db  1,RED,"^G: Grab Image   ^D: ReDimension       ",0
  91. INST2   db  1,RED,"^S: Save Set     ^Q: Quit              ",0
  92.         
  93. NumMsgs =   7
  94. Messages MsgHdr <offset Credits,1,1>,<Offset FileNameVCH,1,10>
  95.         MsgHdr  <offset Inst1,1,184>,<Offset Inst2,1,192>
  96.         MsgHdr  <offset SizeMsg,1,18>
  97. ReFMsg  MsgHdr  <Offset ClrSize,1,18>
  98.         MsgHdr  <offset SizeMsg2,1,18>
  99.  
  100. DimMsg1 db  1,GREY2,"Select size using arrow keys",0
  101. DimMsg2 db  1,GREY2,"Hit ",1,RED,"[ENTER]",1,GreY2," when finished",0
  102. DimMsg3 db  1,GREY2," Width: "
  103.  Wtext  db  "000",0
  104. DimMsg4 db  1,GREY2,"Height: "
  105.  Htext  db  "000",0
  106. DimMsg5 db  1,GREY2," Chars: "
  107.  Ntext  db  "000",0
  108. DimMsg6 db  1,GREY2,"  From: "
  109.  Ftext  db  "000",0
  110.  
  111. DimMsgE db  1,BLACK,"        ███",0
  112.  
  113. NumDimMsg   = 2
  114. DimMsgH     MsgHdr  <offset DimMsg1,10,60>,<offset DimMsg2,13,120>
  115. DimMsgH2    MsgHdr  <offset DimMsgE,25,80>,<offset DimMsgE,25,90>
  116.             MsgHdr  <offset DimMsgE,25,100>,<offset DimMsgE,25,110>
  117.             MsgHdr  <offset DimMsg3,25,80>,<offset DimMsg4,25,90>
  118.             MsgHdr  <offset DimMsg5,25,100>,<offset DimMsg6,25,110>
  119. ────────────────────────────────────────────────────────────────────────────
  120.     ;DS:BX = Ptr to list
  121.     ;   CX = # of entries
  122. PROC PrintList
  123.     pusha
  124. @@MSgLoop:
  125.     mov     si,[(MsgHdr PTR bx).Off]
  126.     mov     ax,[(MsgHdr PTR bx).Xpos]
  127.     mov     di,[(MsgHdr PTR bx).Ypos]
  128.     call    PrintText
  129.  
  130.     add     bx,(size MsgHdr)
  131.     dec     cx
  132.     jne     @@MsgLoop
  133.     popa
  134.     ret
  135. ENDP
  136.  
  137.     ;di = Ypos
  138.     ;ax = Xpos
  139.     ;ds:si = ptr to zero terminating string
  140. PROC PrintText
  141.     pusha
  142.     push    es
  143.     mov     es,[cs:VGAseg]
  144.  
  145.     imul    di,SCRW
  146.     add     di,ax
  147.  
  148. @@PrintLoop:
  149.     lodsb
  150.     or      al,al
  151.     je      @@Done
  152.     dec     al
  153.     je      @@ColorChange
  154.     dec     al
  155.  
  156.     movzx   bx,al
  157.     shl     bx,3        ;*8
  158.     mov     cl,8
  159.     mov     ch,[cs:TextColor]
  160.     mov     bp,di
  161. @@CopyChar:
  162.     mov     ah,[cs:Font8x8 + bx]
  163.     and     ah,1111b
  164.     @Set_Write_Plane
  165.     mov     [es:bp],ch
  166.     mov     ah,[cs:Font8x8 + bx]
  167.     shr     ah,4
  168.     @Set_Write_Plane
  169.     mov     [es:bp+1],ch
  170.  
  171.     add     bp,SCRW
  172.     inc     bx
  173.  
  174.     dec     cl
  175.     jne     @@CopyChar
  176.  
  177.     add     di,2
  178.     jmp     short @@PrintLoop
  179.  
  180. @@Done:
  181.     pop     es
  182.     popa
  183.     ret
  184. @@ColorChange:
  185.     lodsb
  186.     mov     [cs:TextColor],al
  187.     jmp     @@PrintLoop
  188. ENDP
  189.  
  190. PROC StealFont
  191.     pusha
  192.     push    es ds
  193.     
  194.     mov     ax,0003h
  195.     int     10h             ;set VGA 80x25x16 char
  196.     mov     ax,1112h
  197.     mov     bl,0
  198.     int     10h             ;load 8x8 bios font into bank 0
  199.  
  200.     mov dx,3c4h             ;setup to read memory
  201.     mov ax,00402h
  202.     out dx,ax
  203.     mov ax,00604h
  204.     out dx,ax
  205.     ──
  206.     mov dx,3ceh
  207.     mov ax,00005h
  208.     out dx,ax
  209.     mov ax,00c06h
  210.     out dx,ax
  211.     mov ax,00204h
  212.     out dx,ax
  213.  
  214.     mov     ax,0b800h
  215.     mov     ds,ax
  216.     mov     ax,cs
  217.     mov     es,ax
  218.  
  219.     mov     di,offset Font8x8
  220.     mov     si,64               ;start w/ char #2, not #0 
  221.  
  222.     cld
  223.     mov     dx,255      ;grab 255 chars
  224. @@GrabLoop:
  225.     mov     cx,8
  226. @@UpHere:
  227.     lodsb
  228.     xor     ah,ah    
  229.  
  230.    REPT 8
  231.     shl     al,1
  232.     rcr     ah,1
  233.    ENDM
  234.     mov     al,ah
  235.     stosb
  236.     loop    @@UpHere
  237.     add     si,32-8
  238.     dec     dx
  239.     jne     @@GrabLoop
  240.  
  241.     pop     ds es
  242.     popa
  243.     ret
  244. ENDP
  245.  
  246.     ;Changes the TGA palette to write to the VGA card
  247.     ; IN: DS = CS
  248. PROC Palettesetup
  249.     pusha
  250.  
  251.     xor     di,di
  252.     mov     cx,256
  253. @@FixItLoop:
  254.     mov     al,[di + Palette.R]
  255.     mov     ah,[di + Palette.G]
  256.     mov     bl,[di + Palette.B]
  257.     shr     al,2
  258.     shr     ah,2
  259.     shr     bl,2
  260.     mov     [di + Palette.R],bl     ;swap B & R
  261.     mov     [di + Palette.G],ah
  262.     mov     [di + Palette.B],al
  263.  
  264.     add     di,(size PalStruc)
  265.     dec     cx
  266.     jne     @@FixItLoop
  267.  
  268.     popa
  269.     ret
  270. ENDP
  271.  
  272.     ;Grab 2 copies of the command line w/ different endings...
  273. PROC CaptureFilename
  274.     pusha
  275.     push    es ds
  276.  
  277.     mov     ax,cs
  278.     mov     ds,ax
  279.     mov     es,[PSPseg]
  280.  
  281.     mov     dx,offset FileNameTGA
  282.     mov     bx,offset TGAexten
  283.     mov     bp,1
  284.     call    GetCommandLine
  285.     or      ax,ax
  286.     je      @@NoFile
  287.  
  288.     mov     dx,offset FileNameVCH
  289.     mov     bx,offset VCHexten
  290.     mov     bp,1
  291.     call    GetCommandLine
  292.     clc 
  293.     jmp     short @@Done
  294.  
  295. @@NoFile:
  296.     stc
  297. @@Done:
  298.     pop     ds es
  299.     popa
  300.     ret
  301. ENDP
  302.  
  303. PROC LoadPicture
  304.     pusha
  305.     mov     ax,cs
  306.     mov     ds,ax
  307.     
  308.     cld
  309.     mov     dx,offset FileNameVCH
  310.     mov     ax,3d00h
  311.     int     21h
  312.     jc      @@NoVchFile
  313.     mov     bx,ax
  314.  
  315.     mov     cx,9
  316.     mov     dx,offset VCHHeader
  317.     mov     ah,3fh
  318.     int     21h
  319.     
  320.     mov     al,[VCHheader.SizeX]        ;calc # of bytes to read
  321.     movzx   cx,[VCHheader.NumChar]
  322.     mul     [VCHheader.SizeY]
  323.     mul     cx
  324.  
  325.     mov     cx,ax
  326.  
  327.     push    ds                          ;read in the file
  328.     mov     ds,[CharSeg]
  329.     xor     dx,dx
  330.     mov     ax,3f00h
  331.     int     21h
  332.     pop     ds
  333.  
  334.     mov     ax,3e00h                    ;close the VCH file
  335.     int     21h
  336.     
  337. @@NoVchFile:
  338.     mov     dx,offset FileNameTGA       ;load in 320x200x256 screen
  339.     mov     ax,3d00h
  340.     int     21h
  341.     jc      @@Abort
  342.     mov     bx,ax
  343.  
  344.     sub     cx,cx                       ;18 past beginning
  345.     mov     dx,18
  346.     mov     ax,4200h                    ;move FP rel. to start
  347.     int     21h
  348.  
  349.     mov     cx,768
  350.     mov     dx,offset Palette           ;read in the palette
  351.     mov     ah,3fh
  352.     int     21h
  353.  
  354.     call    PaletteSetup
  355.         
  356.     push    ds
  357.     mov     ax,[PicSeg]
  358.     mov     ds,ax
  359.     mov     cx,64000                    ;read 64000 bytes
  360.     xor     dx,dx
  361.     mov     ah,3fh
  362.     int     21h
  363.     pop     ds
  364.         
  365.     mov     ah,3eh                  ;close source file 
  366.     int     21h                     
  367.  
  368.     popa
  369.     ret
  370. @@Abort:
  371.     stc
  372.     popa
  373.     ret
  374. ENDP
  375.  
  376. PROC ScrollSplit
  377.     cmp     [SplitDest],0
  378.     je      @@GoDown
  379.     cmp     [Split],80
  380.     je      @@Done
  381.     sub     [Split],8
  382.     jmp     short @@Done1
  383. @@GoDown:
  384.     cmp     [Split],400
  385.     je      @@Done
  386.     add     [Split],8
  387. @@Done1:
  388.     @WaitVert
  389.     mov     bx,[Split]
  390.     @Set_Split
  391. @@Done:
  392.     ret
  393. ENDP
  394.  
  395. PROC SetUpStuff
  396.     pusha
  397.     push    ds es
  398.     mov     es,[VGAseg]
  399.     mov     ds,[PicSeg]
  400.  
  401.     mov     bl,00010001b
  402.     xor     bp,bp
  403. @@OuterLoop:
  404.     mov     ah,bl
  405.     @Set_Write_Plane
  406.     mov     cx,64000 /4
  407.     mov     di,240*SCRW
  408.     mov     si,bp
  409. @@inLoop:
  410.     mov     al,[ds:si]
  411.     stosb
  412.     add     si,4
  413.     dec     cx
  414.     jne     @@InLoop
  415.     inc     bp
  416.     shl     bl,1
  417.     jnc     @@OuterLoop
  418.  
  419.     mov     ah,1111b
  420.     @Set_Write_Plane
  421.  
  422.     mov     di,0    ;SCRW*2
  423.     mov     cx,SCRW
  424.     mov     al,GREY5
  425.     rep stosb
  426.     mov     cx,SCRW
  427.     mov     al,GREY4
  428.     rep stosb
  429.     mov     cx,SCRW
  430.     mov     al,GREY3
  431.     rep stosb
  432.     mov     cx,SCRW
  433.     mov     al,GREY2
  434.     rep stosb
  435.     mov     cx,SCRW
  436.     mov     al,GREY1
  437.     rep stosb
  438.     mov     cx,SCRW
  439.     mov     al,GREY2
  440.     rep stosb
  441.     mov     cx,SCRW
  442.     mov     al,GREY3
  443.     rep stosb
  444.     mov     cx,SCRW
  445.     mov     al,GREY4
  446.     rep stosb
  447.     mov     cx,SCRW
  448.     mov     al,GREY5
  449.     rep stosb
  450.     pop     es ds
  451.  
  452.     mov     bx,offset Messages
  453.     mov     cx,NumMsgs
  454.     call    PrintList
  455.     
  456.     popa
  457.     ret
  458. ENDP
  459.  
  460. PROC GetDimensions
  461.     pusha
  462.     push    es
  463.     mov     ax,cs
  464.     mov     es,ax
  465.  
  466.     mov     [SplitDest],1
  467.     
  468.     mov     bx,offset DimMsgH
  469.     mov     cx,NumDimMsg
  470.     call    PrintList
  471. @@Zloop:
  472.     movzx   eax,[VCHheader.SizeX]
  473.     mov     di,offset Wtext
  474.     mov     cx,3
  475.     call    DEC_Print2Mem
  476.     movzx   eax,[VCHheader.SizeY]
  477.     mov     di,offset Htext
  478.     call    DEC_Print2Mem
  479.     movzx   eax,[VCHheader.From]
  480.     mov     di,offset Ftext
  481.     call    DEC_Print2Mem
  482.     movzx   eax,[VCHheader.NumChar]
  483.     mov     di,offset Ntext
  484.     call    DEC_Print2Mem
  485.     
  486.     mov     bx,offset DimMsgH2
  487.     mov     cx,8
  488.     call    PrintList
  489.  
  490. @@GetChar:
  491.     call    ScrollSplit
  492.     mov     ah,11h
  493.     int     16h         ;get a char
  494.     jz      @@GetChar
  495.     mov     ah,10h
  496.     int     16h
  497.  
  498.     cmp     al,13
  499.     je      @@AllDone
  500.     cmp     ah,CSRUP
  501.     je      @@HandleUp
  502.     cmp     ah,CSRDN
  503.     je      @@HandleDown
  504.     cmp     ah,CSRLF
  505.     je      @@HandleLeft
  506.     cmp     ah,CSRRT
  507.     je      @@HandleRight
  508.     cmp     al,"+"
  509.     je      @@MoreChars
  510.     cmp     al,"-"
  511.     je      @@LessChars
  512.     cmp     al,"F"
  513.     je      @@IncFrom
  514.     cmp     al,"f"
  515.     je      @@DecFrom
  516.     jmp     @@Zloop
  517.  
  518. @@IncFrom:
  519.     add     [VCHheader.From],2
  520. @@DecFrom:
  521.     dec     [VCHheader.From]
  522.     jmp     @@Zloop
  523. @@MoreChars:
  524.     inc     [VCHheader.NumChar]
  525.     jnz     @@Zloop
  526.     dec     [VCHheader.NumChar]
  527.     jmp     @@Zloop
  528. @@LessChars:
  529.     dec     [VCHheader.NumChar]
  530.     jnz     @@Zloop
  531.     inc     [VCHheader.NumChar]
  532.     jmp     @@Zloop
  533. @@HandleUp:
  534.     inc     [VCHheader.SizeY]
  535.     cmp     [VCHheader.SizeY],MAXY
  536.     jbe     @@Zloop
  537.     mov     [VCHheader.SizeY],MAXY
  538.     jmp     @@Zloop
  539. @@HandleDown:
  540.     dec     [VCHheader.SizeY]
  541.     cmp     [VCHheader.SizeY],MINY
  542.     jge     @@Zloop
  543.     mov     [VCHheader.SizeY],MINY
  544.     jmp     @@Zloop
  545. @@HandleRight:
  546.     inc     [VCHheader.SizeX]
  547.     cmp     [VCHheader.SizeX],MAXX
  548.     jbe     @@Zloop
  549.     mov     [VCHheader.SizeX],MAXX
  550.     jmp     @@Zloop
  551. @@HandleLeft:
  552.     dec     [VCHheader.SizeX]
  553.     cmp     [VCHheader.SizeX],MINX
  554.     jge     @@Zloop
  555.     mov     [VCHheader.SizeX],MINX
  556.     jmp     @@Zloop
  557. @@AllDone:
  558.     mov     ah,1111b
  559.     @Set_Write_Plane
  560.     mov     es,[VGAseg]
  561.     mov     di,29*SCRW
  562.     mov     cx,153*SCRW/2
  563.     mov     ax,Red2*100h + RED2
  564.     rep     Stosw
  565.  
  566.     mov     [SplitDest],0
  567.     call    RefreshScreen
  568.     
  569.     pop     es
  570.     popa
  571.     ret
  572. ENDP
  573.  
  574. PROC GrabTheChar
  575.     pusha
  576.     push    es ds
  577.  
  578.     mov     si,[Ypos]
  579.     imul    si,320
  580.     add     si,[Xpos]
  581.  
  582.     mov     al,[VCHheader.SizeX]
  583.     mul     [VCHheader.SizeY]
  584.     movzx   cx,[CurChar]
  585.     mul     cx
  586.     mov     di,ax           ;ds:si pts to character
  587.  
  588.     mov     es,[CharSeg]
  589.     mov     ds,[PicSeg]
  590.  
  591.     movzx   bp,[cs:VCHheader.SizeX]
  592.     sub     bp,320
  593.     neg     bp                  ;BP = 320-SizeX
  594.     mov     dl,[cs:VCHheader.SizeY]
  595. @@Loop:    
  596.     movzx   cx,[cs:VCHheader.SizeX]
  597.     rep     movsb
  598.     add     si,bp
  599.     dec     dl
  600.     jne     @@Loop
  601.  
  602.     pop     ds es
  603.     popa
  604.     ret
  605. ENDP
  606.  
  607. PROC CheckKeys
  608.     mov     ah,11h
  609.     int     16h
  610.     jnz     @@DoAKey
  611.     clc
  612.     ret
  613. @@DoAKey:
  614.     mov     ah,10h
  615.     int     16h
  616.  
  617.     cmp     al,17
  618.     je      @@DoQuit
  619.     cmp     ah,PAGEUP
  620.     je      @@DoPU
  621.     cmp     ah,PAGEDOWN
  622.     je      @@DoPD
  623.     cmp     ax,2004h
  624.     je      @@DoReDim
  625.     cmp     ax,1f13h
  626.     je      @@DoSave
  627.     cmp     ah,CSRUP
  628.     je      @@DoUp
  629.     cmp     ah,CSRDN
  630.     je      @@DoDN
  631.     cmp     ah,CSRLF
  632.     je      @@DoLF
  633.     cmp     ah,CSRRT
  634.     je      @@DoRT
  635.     cmp     ah,CSRUPC
  636.     je      @@DoUpC
  637.     cmp     ah,CSRDNC
  638.     je      @@DoDNC
  639.     cmp     ah,CSRLFC
  640.     je      @@DoLFC
  641.     cmp     ah,CSRRTC
  642.     je      @@DoRTC
  643.     cmp     ax,2207h
  644.     je      @@DoGrabIt
  645.     cmp     al,"+"
  646.     je      @@DoPlus
  647.     cmp     al,"-"
  648.     je      @@DoMinus
  649.     
  650.     clc
  651.     ret
  652.  
  653. @@DoPlus:
  654.     inc     [CurChar]
  655.     mov     al,[VCHheader.NumChar]
  656.     cmp     [CurChar],al
  657.     jb      @@Done
  658.     mov     [CurChar],0
  659.     jmp     @@Done
  660. @@DoMinus:
  661.     dec     [CurChar]
  662.     mov     al,[VCHheader.NumChar]
  663.     cmp     [CurChar],al
  664.     jb      @@Done
  665.     dec     al
  666.     mov     [CurChar],al
  667.     jmp     @@Done
  668. @@DoGrabIt:
  669.     call    GrabTheChar
  670.     call    RefreshScreen
  671.     clc
  672.     ret
  673. @@DoUpC:
  674.     movzx   ax,[VCHheader.SizeY]
  675.     dec     ax
  676.     sub     [Ypos],ax
  677.     jmp     @@DoUp
  678. @@DoDNC:
  679.     movzx   ax,[VCHheader.SizeY]
  680.     dec     ax
  681.     add     [Ypos],ax
  682.     jmp     @@DoDN
  683. @@DoLFC:
  684.     movzx   ax,[VCHheader.SizeX]
  685.     dec     ax
  686.     sub     [Xpos],ax
  687.     jmp     @@DoLF
  688. @@DoRTC:
  689.     movzx   ax,[VCHheader.SizeX]
  690.     dec     ax
  691.     add     [Xpos],ax
  692.     jmp     @@DoRT
  693. @@DoUp:
  694.     dec     [Ypos]
  695.     cmp     [Ypos],0
  696.     jge     @@Done
  697.     mov     [Ypos],0
  698.     jmp     @@Done
  699. @@DoDN:
  700.     inc     [Ypos]
  701.     movzx   ax,[VCHheader.SizeY]
  702.     sub     ax,200
  703.     neg     ax
  704.     cmp     [Ypos],ax
  705.     jl      @@Done
  706.     mov     [Ypos],ax
  707.     jmp     @@Done
  708. @@DoLF:
  709.     dec     [Xpos]
  710.     cmp     [Xpos],0
  711.     jge     @@Done
  712.     mov     [Xpos],0
  713.     jmp     @@Done
  714. @@DoRT:
  715.     inc     [Xpos]
  716.     movzx   ax,[VCHheader.SizeX]
  717.     sub     ax,320
  718.     neg     ax
  719.     cmp     [Xpos],ax
  720.     jl      @@Done
  721.     mov     [Xpos],ax
  722.     jmp     @@Done
  723. @@DoSave:
  724.     call    SaveIt
  725.     clc
  726.     ret
  727. @@DoReDim:
  728.     call    GetDimensions
  729.     clc
  730.     ret
  731. @@DoQuit:
  732.     stc
  733.     ret
  734. @@DoPU:
  735.     mov     [SplitDest],1
  736.     clc
  737.     ret
  738. @@DoPD:
  739.     mov     [SplitDest],0
  740.     clc
  741.     ret
  742. @@Done:
  743.     call    RefreshScreen
  744.     clc
  745.     ret
  746. ENDP
  747.  
  748.     ; Draws enlarged & normal sized image
  749.     ;updates x & Y positions, width, height, current char etc..
  750.     ;
  751. PROC RefreshScreen
  752.     pusha
  753.     push    es ds
  754.     mov     ax,cs
  755.     mov     es,ax
  756.     mov     ds,ax
  757.  
  758. ;SizeMsg db  1,GREEN,"`-' W:-  H:-  #:  -/    X:  - Y:  - ",0
  759. ;SizeMsg2 db 1,GREY2," A    12   15    21       252   123",0
  760. ;ClrSize db  1,BLACK," █    ██   ██   ███ ███   ███   ███",0
  761.  
  762.     mov     al,[CurChar]
  763.     add     al,[VCHheader.From]   ;" "
  764.     cmp     al,1
  765.     ja      @@OK
  766.     mov     al," "
  767. @@ok:
  768.     mov     [SizeMsg2+3],al
  769.  
  770.     movzx   eax,[VCHheader.SizeX]
  771.     mov     cx,2
  772.     mov     di,offset SizeMsg2 + 8
  773.     call    DEC_Print2Mem
  774.  
  775.     movzx   eax,[VCHheader.SizeY]
  776.     mov     di,offset SizeMsg2 + 13
  777.     call    DEC_Print2Mem
  778.  
  779.     movzx   eax,[CurChar]
  780.     mov     cx,3
  781.     mov     di,offset SizeMsg2 + 18
  782.     call    DEC_Print2Mem
  783.  
  784.     movzx   eax,[VCHheader.NumChar]
  785.     mov     di,offset SizeMsg2 + 22
  786.     call    DEC_Print2Mem
  787.  
  788.     movzx   eax,[Xpos]
  789.     mov     di,offset SizeMsg2 + 28
  790.     call    DEC_Print2Mem
  791.  
  792.     movzx   eax,[Ypos]
  793.     mov     di,offset SizeMsg2 + 34
  794.     call    DEC_Print2Mem
  795.  
  796.     mov     bx,offset RefMsg
  797.     mov     cx,2
  798.     call    PrintList
  799.  
  800.     mov     es,[VGAseg]
  801.     mov     ds,[CharSeg]
  802.  
  803.     mov     al,[cs:VCHheader.SizeX]
  804.     mul     [cs:VCHheader.SizeY]
  805.     movzx   cx,[cs:CurChar]
  806.     mul     cx
  807.     mov     si,ax           ;ds:si pts to character
  808.  
  809.     mov     ah,1110b
  810.     @Set_Write_Plane
  811.  
  812.     mov     di,ENLARGEOFFSET
  813.     mov     dl,[cs:VCHheader.SizeY]
  814.     mov     bx,SCRW
  815.     sub     bl,[cs:VCHheader.SizeX]
  816. @@BigLoop:
  817.     mov     dh,2
  818.     mov     bp,si
  819.  @@BigLoop2:
  820.     movzx   cx,[cs:VCHheader.SizeX]
  821.     rep movsb
  822.     mov     si,bp
  823.     add     di,bx
  824.     dec     dh
  825.     jne     @@BigLoop2
  826.  
  827.     movzx   cx,[cs:VCHheader.SizeX]
  828.     rep movsb
  829.     add     di,bx
  830.     add     di,SCRW
  831.     
  832.     dec     dl
  833.     jne     @@BigLoop
  834.     ──
  835.     mov     ds,[cs:PicSeg]
  836.  
  837.     mov     ax,[cs:Ypos]
  838.     imul    ax,320 
  839.     add     ax,[cs:Xpos]
  840.     mov     si,ax           ;ds:si pts to character
  841.  
  842.     mov     di,ENLARGEOFFSET+40
  843.     mov     bx,SCRW
  844.     mov     ax,320
  845.     movzx   dx,[cs:VCHheader.SizeX]
  846.     sub     bx,dx
  847.     sub     ax,dx                   ;AX=320-SizeX BX=SCRW-SizeX
  848.     mov     dl,[cs:VCHheader.SizeY]
  849. @@BigLoop3:
  850.     mov     dh,2
  851.     mov     bp,si
  852.  @@BigLoop4:
  853.     movzx   cx,[cs:VCHheader.SizeX]
  854.     rep movsb
  855.     mov     si,bp
  856.     add     di,bx
  857.     dec     dh
  858.     jne     @@BigLoop4
  859.  
  860.     movzx   cx,[cs:VCHheader.SizeX]
  861.     rep movsb
  862.     add     di,bx
  863.     add     di,SCRW
  864.     add     si,ax
  865.     dec     dl
  866.     jne     @@BigLoop3
  867.     ──
  868.     mov     di,[cs:OldY]   ;erase top line
  869.     dec     di
  870.     js      @@SkipEtop
  871.     imul    di,SCRW
  872.     add     di,240*SCRW
  873.  
  874.     mov     si,[cs:OldY]
  875.     dec     si
  876.     imul    si,320
  877.     mov     bl,1
  878.  @@LoLo:
  879.     push    si di
  880.     mov     ah,bl
  881.     @Set_Write_Plane
  882.     mov     cx,SCRW
  883.  @@InLoLo:
  884.     movsb
  885.     add     si,3
  886.     loop    @@InLoLO
  887.     pop     di si
  888.     inc     si
  889.     shl     bl,1
  890.     cmp     bl,10000b
  891.     jb      @@LoLo
  892. @@SkipEtop:
  893.     mov     di,[cs:OldY]   ;erase bottom line
  894.     movzx   ax,[cs:VCHheader.SizeY]
  895.     add     di,ax
  896.     imul    di,SCRW
  897.     add     di,240*SCRW
  898.  
  899.     mov     si,[cs:OldY]
  900.     add     si,ax
  901.     imul    si,320
  902.     mov     bl,1
  903. @@LoLo2:
  904.     push    si di
  905.     mov     ah,bl
  906.     @Set_Write_Plane
  907.     mov     cx,SCRW
  908.  @@InLoLo2:
  909.     movsb
  910.     add     si,3
  911.     loop    @@InLoLO2
  912.     pop     di si
  913.     inc     si
  914.     shl     bl,1
  915.     cmp     bl,10000b
  916.     jb      @@LoLo2
  917.  
  918.     mov     si,[cs:OldX]   ;erase left
  919.     dec     si
  920.     js      @@SkipELeft
  921.     mov     di,si
  922.     mov     cx,di
  923.     and     cl,11b
  924.     mov     ah,1
  925.     shl     ah,cl
  926.     @Set_Write_Plane
  927.     shr     di,2
  928.     add     di,240*SCRW
  929.  
  930.     mov     dx,200
  931. @@LoX:
  932.     movsb
  933.     add     di,SCRW-1
  934.     add     si,320-1
  935.     dec     dx
  936.     jne     @@Lox
  937. @@SkipELeft:
  938.     mov     si,[cs:OldX]   ;erase right
  939.     movzx   ax,[cs:VCHheader.SizeX]
  940.     add     si,ax
  941.     cmp     si,320
  942.     jae     @@SkipEright
  943.     mov     di,si
  944.     mov     cx,di
  945.     and     cl,11b
  946.     mov     ah,1
  947.     shl     ah,cl
  948.     @Set_Write_Plane
  949.     shr     di,2
  950.     add     di,240*SCRW
  951.  
  952.     mov     dx,200
  953. @@LoX2:
  954.     movsb
  955.     add     di,SCRW-1
  956.     add     si,320-1
  957.     dec     dx
  958.     jne     @@Lox2
  959. @@SkipEright:
  960.     mov     ax,[cs:Xpos]
  961.     mov     [cs:OldX],ax
  962.     mov     ax,[cs:Ypos]
  963.     mov     [cs:OldY],ax
  964.  
  965.     mov     ah,1111b
  966.     @Set_write_plane
  967.  
  968.     mov     di,[cs:OldY]   ;draw top line
  969.     dec     di
  970.     js      @@SKipDtop
  971.     imul    di,SCRW
  972.     add     di,240*SCRW
  973.     mov     cx,SCRW
  974.     mov     al,RED
  975.     rep     stosb
  976. @@SKipDtop:
  977.     mov     di,[cs:OldY]   ;draw bottom line
  978.     movzx   ax,[cs:VCHheader.SizeY]
  979.     add     di,ax
  980.     imul    di,SCRW
  981.     add     di,240*SCRW
  982.     mov     cx,SCRW
  983.     mov     al,RED
  984.     rep     stosb
  985.  
  986.     mov     di,[cs:OldX]   ;draw left
  987.     dec     di
  988.     js      @@SKipDLeft
  989.     mov     cx,di
  990.     and     cl,11b
  991.     mov     ah,1
  992.     shl     ah,cl
  993.     @Set_Write_Plane
  994.     shr     di,2
  995.     add     di,240*SCRW
  996.  
  997.     mov     dx,200
  998.     mov     al,RED
  999. @@LoXx:
  1000.     stosb
  1001.     add     di,SCRW-1
  1002.     dec     dx
  1003.     jne     @@Loxx
  1004. @@SKipDLeft:
  1005.     mov     di,[cs:OldX]   ;draw right
  1006.     movzx   ax,[cs:VCHheader.SizeX]
  1007.     add     di,ax
  1008.     cmp     di,320
  1009.     jae     @@SkipDright
  1010.     mov     cx,di
  1011.     and     cl,11b
  1012.     mov     ah,1
  1013.     shl     ah,cl
  1014.     @Set_Write_Plane
  1015.     shr     di,2
  1016.     add     di,240*SCRW
  1017.  
  1018.     mov     dx,200
  1019.     mov     al,RED
  1020. @@LoX2x:
  1021.     stosb
  1022.     add     di,SCRW-1
  1023.     dec     dx
  1024.     jne     @@Lox2x
  1025. @@SkipDright:
  1026.     pop     ds es
  1027.     popa
  1028.     ret
  1029. ENDP
  1030.  
  1031. PROC SaveIt
  1032.     pusha
  1033.     push    ds
  1034.     mov     ax,cs
  1035.     mov     ds,ax
  1036.     
  1037.  
  1038.     mov     dx,offset FileNameVCH
  1039.     sub     cx,cx
  1040.     mov     ah,3ch                  ;open file
  1041.     int     21h
  1042.     jc      @@abort
  1043.     mov     bx,ax
  1044.  
  1045.     mov     dx,offset VCHheader    
  1046.     mov     cx,(size VchHdr)
  1047.     mov     ah,40h
  1048.     int     21h
  1049.  
  1050.     mov     al,[VCHheader.SizeY]           ;figure size
  1051.     mul     [VCHheader.SizeX]
  1052.     movzx   dx,[VCHheader.NumChar]
  1053.     mul     dx
  1054.         
  1055.     mov     cx,ax                   ; the dest file lenght
  1056.     push    ds
  1057.     mov     ds,[CharSeg]
  1058.     mov     ah,40h                  ; function write
  1059.     xor     dx,dx
  1060.     int     21h                     ; write it
  1061.     pop     ds
  1062.  
  1063.     mov     ah,3eh                  ;close source file 
  1064.     int     21h
  1065. @@Abort:
  1066.     pop     ds
  1067.     popa
  1068.     ret
  1069. ENDP
  1070.