home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / VLA_FONT.ZIP / VCHED.ASM < prev    next >
Assembly Source File  |  1993-09-15  |  41KB  |  1,670 lines

  1.         dosseg
  2.         Locals
  3.         .286
  4.  
  5.         SCROLLWIDTH = 200
  6.         DISPLAYWIDTH = 160
  7.  
  8. stacks  segment byte stack 'stack'
  9.         thestak         db  256 dup (0h)      ;just need a marker size =500 bytes
  10. stacks  ends
  11.  
  12. code    segment byte public 'code'
  13.         assume  cs:code, ds:code, es:code, ss:stacks
  14.  
  15. start:  
  16.         mov     ax,es
  17.         mov     ds,ax
  18.         mov     cs:[dseg],ax
  19.         mov     si,128
  20.         lodsb
  21.         xor     cx,cx
  22.         mov     cl,al
  23.         cmp     cx,20
  24.         jbe     NotTooMuch
  25.         mov     cx,19
  26. NotTooMuch:
  27.         mov     cs:[inputlength],cx
  28.         mov     ax,cs
  29.         mov     es,ax
  30.         mov     di,offset inputstring
  31.         rep     movsb
  32.  
  33.         mov     ax,cs
  34.         mov     ds,ax
  35.         mov     es,ax
  36.  
  37.         mov     bx,ss
  38.         add     bx,20h
  39.         mov     cs:[Charseg],bx
  40.         add     bx,4000
  41.         mov     cs:[charbakseg],bx
  42.         add     bx,4000
  43.         mov     cs:[scrollseg],bx
  44.  
  45.         jmp     main
  46.         
  47. ;===- data -===
  48.  
  49.         Basex   equ     10
  50.         Basey   equ     20
  51.         Dseg    dw      0
  52.         credits db      13,10,"TGA Palette Grabber",13,10
  53.                 db      "  By Ben Gardner",13,10,"$"
  54.         grabtitle db    "    Character grabber by Ben Gardner$"
  55.  
  56.         cwidth  db      " Width: 00$"
  57.         Height  db      "Height: 00$"  
  58.         HitReturn db    "Hit [RETURN] when done.$"
  59.  
  60.         TopLine db      "C:  B:  "
  61.         Charnum db      "CHAR: - - 00     00x00 W-00$"       ;28 chars
  62.  
  63.         
  64.         colors  db      255
  65.         properuse db    13,10,"VCH Character Editor:",13,10
  66.                 db      " Use: CHREDIT Filename (must be a VCH file)",13,10
  67.                 db      "Directory paths not supported.$",13,10,'$'
  68.  
  69.         inputstring  db 20 dup ('~'),"$","$"
  70.         inputlength  dw 0
  71.                         db      10 dup (0)
  72.  
  73.         VCHname db     "default.VCH",0,0,0,0,0,0,0 ,"$"
  74.  
  75.         ErrorLook dw    offset properuse,offset properuse,offset Nofile
  76.                 dw      offset Nopath,offset Nohandle,OFFSET Noaccess
  77.         presskey db     13,10,"Press any key to return to dos.$"        
  78.         
  79.         nofile          db      10,13,"File not found error.$"
  80.         nopath          db      10,13,"Path not found error.$"
  81.         nohandle        db      10,13,"No handles available.$"
  82.         noaccess        db      10,13,"Access to file denied.$"
  83.         errormes        db      10,13,"Program aborted.$"
  84.         diskfull        db      10,13,"Disk full.$"
  85.         Warning         db      "ALL data may be messed up.",10,13
  86.                         db      "     Resize anyway? (Y/N)$"
  87.  
  88.         NoPal   db      "File not found: "
  89.         PalName  db     "default.Pal",0,0,0,0,0,0,"$"
  90.                 
  91.         HEADLOAD        db      "VGACH" ;R"
  92.         From            db      " "
  93.         sizex           db      10
  94.         sizey           db      10
  95.         NumChars        db      64
  96.  
  97.         CHARWIDTH       db      255 dup(0)
  98.  
  99.         Curchar         db      0
  100.         xpos            db      0
  101.         ypos            db      0
  102.         
  103.         pal     db      768 dup (0)
  104.         PALTMP  DB      768 DUP (0)
  105.  
  106.         Clip    db      1024 dup (0)
  107.  
  108.         borderx dw      0
  109.         bordery dw      0
  110.         borderxsize dw  0
  111.         borderysize dw  0
  112.         bordercolor db  0
  113.         
  114.         vgaseg  dw      0a000h
  115.         Charseg dw      0
  116.         Scrollseg dw    0
  117.         CharbakSeg   dw      0
  118.         
  119.         Fadestep db     0
  120.  
  121.         XYsize  dw      0
  122.  
  123.         Scrollcount dw  DISPLAYWIDTH     ;used to count current stuff
  124.         scrollSpeed dw  1       ;number of bytes to scroll per update
  125.         Scrollletter dw 0       ;offset in scrollmsg for next char
  126.  
  127.         CurrentColor    db      0
  128.         BackgroundColor db      0
  129.  
  130.         messoff dw      offset ScrollMsg2
  131.  
  132.         ScrollMsg db    " HELLO, GUYS! THIS CHARACTER SET EDITOR WAS CREATED BY" 
  133.                 DB      " DRAEDEN...  HERE IS A LITTLE HELP: F1: CUT, F2:PASTE, "
  134.                 DB      "F3: SHIFT LEFT, F4: SHIFT RIGHT, F5: SHIFT UP, F6: DOWN, "
  135.                 DB      "F7: FLIP VERTICLE, F8: FLIP HORIZONTAL, F9: GRAB COLOR UNDER CURSOR, "
  136.                 DB      "F10: RESTORE CURRENT CHAR, CONT-F1: SAVE FONT, [ AND ] CHANGE CURRENT "
  137.                 DB      "COLOR, CONT-[ AND ] CHANGE BACKGROUND COLOR, "
  138.                 DB      "LEFT SHIFT: WRITES CURRENT COLOR, RIGHT SHIFT: WRITES BACKGROUND COLOR, "
  139.                 DB      "CONT-Q: QUIT, "
  140.                 DB      "ARROW KEYS MOVE THE CURSOR, +/- "
  141.                 DB      "CHANGE CURRENT CHAR... SIMPLE ENOUGH... HERE'S THE CHARACTER SET: "
  142.  
  143.         Scrollmsg2 db      255 dup (0),0
  144.  
  145. ;========- SubRoutines -========
  146. Waitkey proc near
  147. here:
  148.         mov  ah,1
  149.         int  16h                         ; has a key been pressed?
  150.         jz   HERE                        ; no, goto HERE
  151.         mov  ah,0
  152.         int  16h                         ; yes, get the character
  153.         ret
  154. waitkey endp
  155.  
  156. CaptureFilename proc near
  157.         mov     ax,cs
  158.         mov     ds,ax
  159.         mov     es,ax
  160.         mov     si,offset inputstring
  161.         mov     di,offset VCHname
  162.         xor     bl,bl
  163. Nospace:
  164.         lodsb
  165.         cmp     al,'~'
  166.         je      capdone
  167.         cmp     al,'.'
  168.         je      capdone
  169.         cmp     al,' '
  170.         je      nospace
  171.         stosb 
  172.         inc     bl
  173.         cmp     bl,8
  174.         jb      nospace
  175. Capdone:
  176.         mov     al,'.'
  177.         stosb
  178.         mov     al,'V'
  179.         stosb
  180.         mov     al,'C'
  181.         stosb
  182.         mov     al,'H'
  183.         stosb
  184.         mov     al,0
  185.         stosb
  186.         mov     al,'$'
  187.         stosb
  188.         mov     di,offset palname
  189.         mov     si,offset VCHname
  190.         mov     cx,14
  191.         rep     movsb
  192.         mov     di,offset palname+1     ;+1 to get past dot
  193.         xor     bh,bh
  194.         add     di,bx                   ;bx = 0 thru 7
  195.         mov     al,'P'
  196.         stosb
  197.         mov     al,'A'
  198.         stosb
  199.         mov     al,'L'
  200.         stosb
  201.         ret
  202. CaptureFileName endp
  203.  
  204. DisplayText proc near
  205.         pusha
  206.         mov     bl,ah           ;ah=xpos
  207.         xor     bh,bh
  208.         mov     cl,[sizey]
  209.         mul     cl
  210.         xor     ch,ch
  211.         imul    ax,ax,320
  212.         mov     di,ax
  213.         mov     al,[sizex]
  214.         mul     bl
  215.         add     di,ax           ;screen location
  216.  
  217.         mov     ax,cs:[vgaseg]
  218.         mov     es,ax
  219.  
  220.         mov     bx,dx           ;string location
  221. displayloop:
  222.         mov     al,cs:[bx]
  223.         or      al,al
  224.         je      Textdone
  225.         sub     al,cs:[From];' '
  226.         cmp     al,cs:[NUmCHARS] 
  227.         ja      skipit
  228.         
  229.         call    putchar         ;al= frame # es:di is dest
  230.         mov     cl,cs:[sizex]
  231.         xor     ch,ch
  232.         add     di,cx
  233. skipit:
  234.         inc     bx
  235.         jmp     displayloop
  236. TextDone:
  237.         popa
  238.         ret
  239. DisplayText endp
  240.  
  241.         ;Destroys AX, DX, CX
  242. PutChar proc near       ;al has char to print
  243.         push    ds
  244.         push    si
  245.         push    di
  246.  
  247.         xor     ah,ah
  248.         mov     dx,cs:[xysize]
  249.         mul     dx
  250.         mov     si,ax
  251.         mov     ax,cs:[charseg]
  252.         mov     ds,ax
  253.         mov     cl,cs:[sizex]
  254.         mov     ch,cs:[sizey]
  255.         push    di
  256. putloop:
  257.         movsb
  258.         dec     cl
  259.         jne     putloop
  260.         mov     cl,cs:[sizex]
  261.         pop     di        
  262.         add     di,SCROLLWIDTH
  263.         push    di
  264.         dec     ch
  265.         jne     putloop
  266.  
  267.         pop     ax
  268.         pop     di
  269.         pop     si
  270.         pop     ds
  271.         ret
  272. PutChar endp
  273.  
  274.         ;ES has segment to clear, al has byte to clear to
  275. ClearVga proc near
  276.         xor     di,di
  277.         mov     ah,al
  278.         mov     cx,32000
  279.         rep     stosw
  280.         ret
  281. ClearVga endp
  282.  
  283. Scroll  proc near
  284.         push    ds
  285.         push    es
  286.         mov     ax,cs:[scrollseg]
  287.         mov     es,ax
  288.         mov     ds,ax
  289.         cld
  290.  
  291.         xor     di,di
  292.         mov     si,cs:[scrollspeed]
  293.         mov     cl,cs:[sizey]
  294.         xor     ch,ch
  295.         imul    cx,cx,SCROLLWIDTH/2
  296.         rep     movsw
  297.  
  298.         mov     ax,cs:[scrollcount]     ;scrollcount-scrollspeed
  299.         sub     ax,cs:[scrollspeed]
  300.         push    ax
  301.         cmp     ax,DISPLAYWIDTH
  302.         ja      donescroll              ;dont need a new char yet
  303.         
  304.         mov     di,ax
  305. tryagain:
  306.         mov     bx,cs:[scrollletter]
  307.         add     bx,cs:[messoff]
  308.         inc     cs:[scrollletter]
  309.         mov     al,cs:[bx]
  310.         or      al,al
  311.         jne     nozero
  312.         mov     cs:[scrollletter],0
  313. nozero:
  314.         sub     al,' '
  315.         cmp     al,cs:[numchars]
  316.         jae     tryagain
  317.         mov     bl,al
  318.         xor     bh,bh
  319.         mov     bl,cS:[CHARWIDTH+BX]
  320.         pop     dx
  321.         add     dx,bx
  322.         mov     cs:[scrollcount],dx
  323.  
  324.         call    putchar
  325.         jmp     byescroll
  326. Donescroll:
  327.         pop     ax
  328.         mov     cs:[scrollcount],ax
  329.  
  330. byescroll:
  331.         mov     ax,cs:[vgaseg]
  332.         mov     es,ax
  333.  
  334.         xor     si,si
  335.         mov     di,320*150+160-8
  336.         
  337.         mov     bl,cs:[sizey]
  338.         mov     cx,160
  339.  
  340.         push    cx
  341. scrcopy:
  342.         pop     cx
  343.         push    cx
  344.         rep     movsb
  345.         add     si,SCROLLWIDTH-DISPLAYWIDTH
  346.         add     di,320-DISPLAYWIDTH
  347.         dec     bl
  348.         jne     scrcopy
  349.         pop     cx
  350.         pop     es
  351.         pop     ds
  352.         ret
  353. scroll endp
  354.  
  355. FadeOut proc near
  356.         push    ds
  357.         push    es
  358.         cld
  359.         mov     ax,cs
  360.         mov     ds,ax
  361.         mov     es,ax
  362.         mov     bx,768
  363. Foloop:
  364.         cmp     [paltmp+bx],0
  365.         je      nodec
  366.         dec     [paltmp+bx]
  367. nodec:
  368.         dec     bx
  369.         jne     Foloop
  370. writetopal:
  371.         mov     dx,03c8h
  372.         mov     al,0
  373.         out     dx,al
  374.         inc     dx
  375.         xor     cx,cx
  376.         mov     si,offset paltmp
  377. fadeem:
  378.         lodsb
  379.         out     dx,al
  380.         inc     cx
  381.         cmp     cx,768
  382.         jbe     fadeem
  383.         
  384.         pop     es
  385.         pop     ds
  386.         ret
  387. FadeOut endp
  388.  
  389. drawdot proc near
  390.         push    es
  391.         push    ax
  392.         push    bx
  393.         push    di
  394.         mov     ax,0a000h
  395.         mov     es,ax
  396.         mov     al,dh
  397.         xor     ah,ah
  398.         xor     bh,bh
  399.         shl     ax,2            ;blocks are 4 high
  400.         add     ax,BASEY
  401.         imul    ax,ax,320
  402.         mov     bl,dl
  403.         shl     bx,2            ;4 wide
  404.         add     ax,bx
  405.         add     ax,BASEx
  406.         mov     di,ax
  407.         mov     ah,cl
  408.         mov     al,ah         
  409.         stosw
  410.         stosw
  411.         add     di,316
  412.         stosw
  413.         stosw
  414.         add     di,316
  415.         stosw
  416.         stosw
  417.         add     di,316
  418.         stosw
  419.         stosw
  420.         mov     al,dh
  421.         xor     ah,ah
  422.         add     ax,12
  423.         imul    ax,ax,320
  424.         add     ax,174
  425.         mov     bl,dl
  426.         xor     bh,bh
  427.         add     ax,bx
  428.         mov     di,ax
  429.         mov     al,cl
  430.         stosb
  431. donedot:
  432.         pop     di
  433.         pop     bx
  434.         pop     ax
  435.         pop     es
  436.  
  437.         ret
  438. drawdot endp
  439.  
  440. LOADDAT proc near
  441.         mov     dx,offset VCHname      ;load in VCH set
  442.         sub     al,al                   
  443.         mov     ah,3dh                  
  444.         int     21h                     
  445.         jnc     noabort22
  446.         jmp     abort
  447. Noabort22:
  448.         mov     bx,ax                   
  449.  
  450.         push    ds
  451.         mov     ax,cs
  452.         mov     ds,ax
  453.         mov     cx,9
  454.         mov     dx,offset HEADLOAD      ;read Header
  455.         mov     ah,3fh
  456.         int     21h
  457.  
  458.         mov     al,cs:[sizex]
  459.         mov     ah,cs:[sizey]
  460.         mul     ah
  461.         mov     dl,cS:[numChars]
  462.         xor     dh,dh
  463.         mul     dx
  464.  
  465.         mov     cx,ax
  466.  
  467.         mov     ax,cs:[Charseg]
  468.         mov     ds,ax
  469.         xor     dx,dx    
  470.         mov     ah,3fh               
  471.         int     21h                  
  472.  
  473.         push    es   
  474.         mov     CL,Cs:[NUMCHARS]
  475.         XOR     CH,CH
  476.         mov     al,cs:[sizex]
  477.         mov     dx,cs
  478.         mov     es,dx
  479.         mov     di,offset CHARWIDTH
  480.         rep     stosb           ;set all charwidth to data sizex
  481.         
  482.         mov     cx,ax
  483.         mov     ax,cS:[charbakseg]
  484.         mov     es,ax
  485.         xor     di,di
  486.         mov     si,di
  487.         rep     movsb
  488.  
  489.         mov     ax,cs
  490.         mov     ds,ax
  491.         mov     cl,cs:[numchars]
  492.         mov     ch,0
  493.         mov     dx,offset CHARWIDTH      ;read Header
  494.         mov     ah,3fh
  495.         int     21h
  496.         
  497.         pop     es
  498.         pop     ds
  499.         
  500.         mov     ah,3eh                  ;close source file 
  501.         int     21h                     
  502.         
  503.         mov     dx,offset Palname       ;Load in Pal
  504.         sub     al,al
  505.         mov     ah,3dh
  506.         int     21h
  507.         jc      abortpal
  508.         mov     bx,ax
  509.  
  510.         push    ds
  511.         mov     ax,cs
  512.         mov     ds,ax
  513.         mov     cx,768
  514.         mov     dx,offset pal
  515.         mov     ah,3fh
  516.         int     21h
  517.         mov     ds:pal[768],63
  518.         mov     ds:pal[767],63
  519.         mov     ds:pal[766],63
  520.         pop     ds
  521.  
  522.         mov     ah,3eh
  523.         int     21h
  524.         ret
  525. abort:
  526.         push    ax
  527.         mov     ah,3eh
  528.         int     21h
  529.         pop     ax
  530.         cmp     ax,6
  531.         jb      displayerror
  532.         pop     bx                      ;get rid of ret address
  533.         jmp     noinput
  534. Abortpal:
  535.         mov     ax,cs
  536.         mov     ds,ax
  537.         mov     dx,offset Nopal
  538.         mov     ah,9
  539.         int     21h
  540.         jmp     byebye2
  541. Displayerror:
  542.         mov     bx,ax
  543.         shl     bx,1
  544.         mov     dx,errorlook[bx]
  545.         mov     ah,9                    ; Print string
  546.         int     21h                     ; 
  547.         mov     ah,9
  548.         mov     dx,offset errormes
  549.         int     21h
  550.         jmp     noinput
  551. loaddat endp
  552.  
  553. header  db      "VGACH 000"
  554.  
  555. SaveDat proc near
  556.         mov     ax,cs
  557.         mov     es,ax
  558.         mov     ds,ax
  559.         mov     al,cs:[sizex]
  560.         mov     cs:[header+6],al        ;xsize
  561.         mov     al,cs:[sizey]
  562.         mov     cs:[header+7],al        ;ysize
  563.         mov     al,cs:[numchars]
  564.         mov     cs:[header+8],al        ;number of chars
  565.  
  566.         mov     dx,offset vChname 
  567.         sub     cx,cx             
  568.         mov     ah,3ch                  ;open file
  569.         int     21h                     
  570.         jc      abort                   
  571.         mov     bx,ax          
  572.                 
  573.         mov     ax,cs                   ;write header
  574.         mov     ds,ax
  575.         mov     dx,offset headload
  576.         mov     cx,9
  577.         mov     ah,40h
  578.         int     21h
  579.  
  580.         mov     al,cs:[sizey]           ;figure size
  581.         mov     ah,cs:[sizex]
  582.         mul     ah
  583.         mov     dl,cS:[numchars]
  584.         xor     dh,dh
  585.         mul     dx
  586.         mov     cx,ax                   ; the dest file
  587.         push    ds
  588.         mov     ax,cs:[charseg]
  589.         mov     ds,ax
  590.         mov     ah,40h                  ; load function write
  591.         xor     dx,dx
  592.         int     21h                     ; write it
  593.  
  594.         mov     ax,cs
  595.         mov     ds,ax
  596.         mov     dx,offset CHARWIDTH
  597.         mov     cl,cs:[numchars]
  598.         mov     ch,0
  599.         mov     ah,40h
  600.         int     21h
  601.  
  602.         pop     ds
  603.         
  604.         cmp     ax,cx
  605.         je      success
  606.         mov     ah,9                    ; disk full error
  607.         mov     dx,offset diskfull      ;
  608.         int     21h                     ; 
  609. success:
  610.         mov     ah,3eh                  ;close source file 
  611.         int     21h
  612.         ret
  613. SaveDat endp
  614.  
  615. Clearscreen proc near
  616.         push    ax
  617.         push    di
  618.         push    es
  619.         push    cx
  620.         mov     ax,0a000h
  621.         mov     es,ax        
  622.         xor     di,di
  623.         mov     cx,32000
  624.         mov     ax,dx
  625.         rep     stosw
  626.         pop     cx
  627.         pop     es
  628.         pop     di
  629.         pop     ax
  630.         ret
  631. Clearscreen endp
  632.  
  633. DisplayMain proc near
  634.         push    es
  635.         push    ds
  636.         mov     ax,cs
  637.         mov     es,ax
  638.         mov     ds,ax
  639.  
  640.         mov     al,cs:[curchar]
  641.         mov     ah,al
  642.         add     ah,cs:[From]    ;' '
  643.         mov     cs:[charnum+7],ah
  644.         xor     ah,ah
  645.         mov     al,cs:[curchar]
  646.         mov     bl,10
  647.         div     bl
  648.         add     al,'0'
  649.         add     ah,'0'
  650.         mov     cs:[charnum+10],al
  651.         mov     cs:[charnum+11],ah
  652.  
  653.         mov     bl,cs:[curchar]
  654.         xor     bh,bh
  655.         mov     al,cs:[CHARWIDTH+bx]
  656.         xor     ah,ah
  657.         mov     bl,10
  658.         div     bl
  659.         add     al,"0"
  660.         add     ah,"0"
  661.         mov     cs:[charnum+25],al
  662.         mov     cs:[charnum+26],ah
  663.         
  664.         mov     ax,1300h
  665.         mov     dx,0000h        
  666.         mov     bl,cs:[colors]
  667.         xor     bh,bh
  668.         mov     cx,35
  669.         push    bp
  670.         mov     bp,offset topline
  671.         int     10h             ;displays "CHAR: -?- 00 ...
  672.  
  673.         pop     bp
  674.  
  675.         call    BigandLittle
  676.         
  677.    ;this puts on all the borders     
  678.         mov     cs:[borderx],basex
  679.         mov     cs:[bordery],basey
  680.         mov     al,cs:[sizex]
  681.         xor     ah,ah
  682.         shl     ax,2
  683.         mov     cs:[borderxsize],ax
  684.         mov     al,cs:[sizey]
  685.         shl     ax,2
  686.         mov     cs:[borderysize],ax
  687.         mov     al,cs:[colors]
  688.         mov     cs:[bordercolor],al
  689.         call    borderit
  690.         
  691.         mov     cs:[borderx],174
  692.         mov     cs:[bordery],12
  693.         shr     cs:[borderxsize],2
  694.         shr     cs:[borderysize],2
  695.         call    borderit
  696.         call    colorbox
  697.  
  698.         pop     ds
  699.         pop     es
  700.         ret
  701. Displaymain endp
  702.             
  703. BigandLittle proc near
  704.         push    ds
  705.         mov     al,cs:[sizex]
  706.         mov     ah,cs:[sizey]
  707.         mul     ah
  708.         mov     bl,cs:[curchar]
  709.         xor     bh,bh
  710.         imul    bx
  711.         mov     si,ax
  712.         mov     ax,cs:[charseg]
  713.         mov     ds,ax
  714.         xor     dx,dx
  715. bigloop:
  716.         mov     cl,ds:[si]
  717.         inc     si
  718.         call    drawdot
  719.         inc     dl
  720.         cmp     dl,cs:[sizex]
  721.         jb      bigloop
  722.         xor     dl,dl
  723.         inc     dh
  724.         cmp     dh,cs:[sizey]
  725.         jb      bigloop
  726.         pop     ds
  727.         ret
  728. BigandLittle endp
  729.  
  730. Grabit proc near        ;gets current char and puts it on the 'CLIP'
  731.         push    ds
  732.         push    es
  733.         mov     ax,cs:[Charseg]
  734.         mov     ds,ax
  735.         mov     ax,cs
  736.         mov     es,ax
  737.  
  738.         mov     ax,cs:[xysize]
  739.         mov     cx,ax
  740.         mov     bl,cs:[curchar]
  741.         xor     bh,bh
  742.         mul     bx
  743.         mov     si,ax
  744.         mov     di,offset clip
  745.  
  746.         rep     movsb
  747.         
  748.         pop     es
  749.         pop     ds
  750.         ret
  751. Grabit endp
  752.  
  753. Pasteit proc near        ;puts 'CLIP' in current char
  754.         push    ds
  755.         push    es
  756.         mov     ax,cs:[Charseg]
  757.         mov     es,ax
  758.         mov     ax,cs
  759.         mov     ds,ax
  760.  
  761.         mov     ax,cs:[xysize]
  762.         mov     cx,ax
  763.         mov     bl,cs:[curchar]
  764.         xor     bh,bh
  765.         mul     bx
  766.         mov     di,ax
  767.         mov     si,offset clip
  768.  
  769.         rep     movsb
  770.         
  771.         pop     es
  772.         pop     ds
  773.         ret
  774. Pasteit endp
  775.  
  776. Borderit proc near
  777.         push    es
  778.         mov     ax,0a000h
  779.         mov     es,ax
  780.         mov     ax,cs:[bordery]
  781.         sub     ax,2            ;width of border
  782.         imul    ax,ax,320
  783.         add     ax,cs:[borderx]
  784.         mov     di,ax
  785.         sub     di,2            ;width of border
  786.         mov     cx,cs:[borderxsize]
  787.         mov     bx,cs:[borderysize]
  788.         add     bx,2
  789.         add     cx,4
  790.         mov     al,cs:[bordercolor]
  791.         push    di
  792.         rep     stosb
  793. borloop:
  794.         pop     di
  795.         add     di,320
  796.         push    di
  797.         stosb
  798.         add     di,cs:[borderxsize]
  799.         add     di,2
  800.         stosb
  801.         dec     bx
  802.         jne     borloop
  803.         pop     di
  804.         add     di,320
  805.         mov     cx,cs:[borderxsize]
  806.         add     cx,4
  807.         rep     stosb
  808.         pop     es
  809.         ret
  810. Borderit endp
  811.         oldxpos db      0
  812.         oldypos db      0
  813.         oldcolor db     0
  814.         cursorcolor db  0
  815.  
  816.  
  817. mOVECURSOR PROC  NEAR
  818.         mov     dl,cs:[oldxpos]
  819.         mov     dh,cs:[oldypos]
  820.         mov     cl,cs:[oldcolor]
  821.         call    drawdot
  822.         inc     cs:[cursorcolor]
  823.         cmp     cs:[cursorcolor],16
  824.         jb      ccok
  825.         mov     cs:[cursorcolor],0
  826. ccok:
  827.         mov     dl,cs:[xpos]
  828.         mov     dh,cs:[ypos]
  829.         mov     cl,cs:[cursorcolor]
  830.         mov     cs:[oldxpos],dl
  831.         mov     cs:[oldypos],dh
  832.         call    drawdot
  833.  
  834.         push    ds
  835.         mov     ax,cs:[charseg]
  836.         mov     ds,ax
  837.         mov     al,cs:[curchar]    ;si= curchar*xsize*ysize+ypos*xsize+xpos
  838.         mov     ah,cs:[sizex]
  839.         mul     ah
  840.         mov     bl,cs:[sizey]
  841.         xor     bh,bh
  842.         mul     bx
  843.         mov     si,ax
  844.         mov     al,cs:[sizex]
  845.         mov     ah,cs:[ypos]
  846.         mul     ah
  847.         add     si,ax
  848.         xor     ah,ah
  849.         mov     al,cs:[xpos]
  850.         add     si,ax
  851.         mov     al,ds:[si]
  852.         pop     ds
  853.         mov     cs:[oldcolor],al
  854.         ret
  855. MoveCursor endp
  856.  
  857. DrawColor proc near
  858.         push    ds
  859.         push    ax
  860.         mov     ax,cs:[charseg]
  861.         mov     ds,ax
  862.         mov     al,cs:[curchar]    ;si= curchar*xsize*ysize+ypos*xsize+xpos
  863.         mov     ah,cs:[sizex]
  864.         mul     ah
  865.         mov     bl,cs:[sizey]
  866.         xor     bh,bh
  867.         mul     bx
  868.         mov     si,ax
  869.         mov     al,cs:[sizex]
  870.         mov     ah,cs:[ypos]
  871.         mul     ah
  872.         add     si,ax
  873.         xor     ah,ah
  874.         mov     al,cs:[xpos]
  875.         add     si,ax
  876.         pop     ax
  877.         mov     ds:[si],al
  878.         pop     ds
  879.         ret
  880. DrawColor endp
  881.               
  882. ColorBox proc near
  883.         mov     ax,0a000h
  884.         mov     es,ax
  885.         mov     di,18
  886.         mov     al,cs:[currentcolor]
  887.         mov     ah,al
  888.         mov     cx,4
  889.         rep     stosw
  890.         add     di,312
  891.         mov     cl,4
  892.         rep     stosw
  893.         add     di,312
  894.         mov     cl,4
  895.         rep     stosw
  896.         add     di,312
  897.         mov     cl,4
  898.         rep     stosw
  899.         add     di,312
  900.         mov     cl,4
  901.         rep     stosw
  902.         add     di,312
  903.         mov     cl,4
  904.         rep     stosw
  905.         add     di,312
  906.         mov     cl,4
  907.         rep     stosw
  908.         add     di,312
  909.         mov     cl,4
  910.         rep     stosw
  911.         mov     di,50
  912.         mov     al,cs:[backgroundcolor]
  913.         mov     ah,al
  914.         mov     cx,4
  915.         rep     stosw
  916.         add     di,312
  917.         mov     cl,4
  918.         rep     stosw
  919.         add     di,312
  920.         mov     cl,4
  921.         rep     stosw
  922.         add     di,312
  923.         mov     cl,4
  924.         rep     stosw
  925.         add     di,312
  926.         mov     cl,4
  927.         rep     stosw
  928.         add     di,312
  929.         mov     cl,4
  930.         rep     stosw
  931.         add     di,312
  932.         mov     cl,4
  933.         rep     stosw
  934.         add     di,312
  935.         mov     cl,4
  936.         rep     stosw
  937.         mov     di,cs:[oldcpalpos]
  938.         xor     ax,ax
  939.         stosw
  940.         add     di,318
  941.         stosw
  942.         add     di,319
  943.         stosb
  944.         mov     di,cs:[oldbpalpos]
  945.         xor     ax,ax
  946.         ;stosw
  947.         add     di,320
  948.         stosw
  949.         add     di,318
  950.         stosb
  951.  
  952.         mov     al,cs:[currentcolor]
  953.         mov     dl,al
  954.         xor     ah,ah
  955.         mov     bh,40
  956.         div     bh      ;al has ypos ah has xpos
  957.         xor     bh,bh
  958.         mov     bl,ah
  959.         xor     ah,ah
  960.         shl     bx,2    ;multiply by 4 to get real xpos
  961.         shl     ax,3    ;multiply by 8 to get real ypos
  962.         add     ax,76
  963.         imul    ax,ax,320
  964.         add     ax,bx
  965.         add     ax,160-10
  966.         mov     di,ax
  967.         mov     cs:[oldcpalpos],di
  968.         mov     al,255
  969.         mov     ah,al
  970.         stosw
  971.         add     di,318
  972.         stosw
  973.         add     di,319
  974.         stosb
  975.         mov     al,cs:[Backgroundcolor]
  976.         mov     dl,al
  977.         mov     bh,40
  978.         xor     ah,ah
  979.         div     bh      ;al has ypos ah has xpos
  980.         xor     bh,bh
  981.         mov     bl,ah
  982.         xor     ah,ah
  983.         shl     bx,2    ;multiply by 4 to get real xpos
  984.         shl     ax,3    ;multiply by 8 to get real ypos
  985.         add     ax,76
  986.         imul    ax,ax,320
  987.         add     ax,bx
  988.         add     ax,160-10
  989.         mov     di,ax
  990.         add     di,2
  991.         mov     cs:[oldbpalpos],di
  992.         mov     al,255
  993.         mov     ah,al
  994.         ;stosw
  995.         add     di,320
  996.         stosw
  997.         add     di,318
  998.         stosb
  999.  
  1000.         ret
  1001. Colorbox endp
  1002.  
  1003.         oldcpalpos dw   0
  1004.         oldbpalpos dw   0
  1005.  
  1006. DisplayPalette proc near
  1007.         mov     ax,0a000h
  1008.         mov     es,ax
  1009.  
  1010.         mov     di,80*320+150
  1011.         xor     ax,ax
  1012.         mov     bl,40
  1013.         mov     dx,di
  1014.         push    di
  1015. Lineit:
  1016.         stosw
  1017.         stosw
  1018.         add     di,316
  1019.         stosw
  1020.         stosw
  1021.         add     di,316
  1022.         stosw
  1023.         stosw
  1024.         add     di,316
  1025.         stosw
  1026.         stosw
  1027.         pop     di
  1028.         add     di,4
  1029.         push    di
  1030.         inc     al
  1031.         or      al,al
  1032.         je      donepal
  1033.         mov     ah,al
  1034.         dec     bl  
  1035.         jne     lineit
  1036.  
  1037.         mov     bl,40
  1038.         pop     di
  1039.         mov     di,dx
  1040.         add     di,320*8
  1041.         mov     dx,di
  1042.         push    di
  1043.         jmp     lineit
  1044.         
  1045. DonePal:
  1046.         pop     di
  1047.         ret
  1048. DisplayPalette endp
  1049.  
  1050. ShLEFT proc near
  1051.         mov     ax,cs:[charseg]
  1052.         mov     ds,ax
  1053.         mov     es,ax
  1054.         mov     ax,cs:[xysize]
  1055.         mov     cl,cs:[curchar]
  1056.         xor     ch,ch
  1057.         mul     cx
  1058.         mov     di,ax
  1059.         mov     si,ax
  1060.         xor     ch,ch
  1061.         mov     dh,cs:[sizey]
  1062. Shlit:
  1063.         lodsb     
  1064.         mov     dl,al
  1065.         mov     cl,cs:[sizex]
  1066.         dec     cx
  1067.         rep     movsb
  1068.         mov     al,dl
  1069.         stosb
  1070.         dec     dh
  1071.         jne     shlit
  1072.         ret
  1073. Shleft endp
  1074.  
  1075. ShRight proc near
  1076.         mov     ax,cs:[charseg]
  1077.         mov     ds,ax
  1078.         mov     es,ax
  1079.         mov     ax,cs:[xysize]
  1080.         mov     cl,cs:[curchar]
  1081.         xor     ch,ch
  1082.         inc     cx
  1083.         mul     cx
  1084.         dec     ax
  1085.         mov     di,ax
  1086.         mov     si,ax
  1087.         xor     ch,ch
  1088.         mov     dh,cs:[sizey]
  1089.         std
  1090. Shrit:
  1091.         lodsb     
  1092.         mov     dl,al
  1093.         mov     cl,cs:[sizex]
  1094.         dec     cx
  1095.         rep     movsb
  1096.         mov     al,dl
  1097.         stosb
  1098.         dec     dh
  1099.         jne     shrit
  1100.         cld
  1101.         ret
  1102. ShRight endp
  1103.  
  1104. Shup proc near
  1105.         mov     ax,cs:[charseg]
  1106.         mov     ds,ax
  1107.         mov     ax,cs
  1108.         mov     es,ax
  1109.         mov     ax,cs:[xysize]
  1110.         mov     bl,cs:[curchar]
  1111.         xor     bh,bh
  1112.         mul     bx
  1113.         push    ax
  1114.         mov     di,offset updownbuff
  1115.         mov     si,ax
  1116.         mov     cl,cs:[sizex]
  1117.         xor     ch,ch
  1118.         rep     movsb
  1119.  
  1120.         pop     di
  1121.         mov     ax,ds
  1122.         mov     es,ax
  1123.         mov     cx,cs:[xysize]
  1124.         mov     bl,cs:[sizex]
  1125.         sub     cx,bx
  1126.         rep     movsb
  1127.         mov     ax,cs
  1128.         mov     ds,ax
  1129.         mov     si,offset updownbuff
  1130.         mov     cl,cs:[sizex]
  1131.         xor     ch,ch
  1132.         rep     movsb
  1133.         ret
  1134. Shup endp
  1135.         upDownBuff db   32 dup (0)
  1136. Shdown proc near
  1137.         mov     ax,cs:[charseg]
  1138.         mov     ds,ax
  1139.         mov     ax,cs
  1140.         mov     es,ax
  1141.  
  1142.         mov     ax,cs:[xysize]
  1143.         mov     bl,cs:[curchar]
  1144.         xor     bh,bh
  1145.         inc     bx
  1146.         mul     bx
  1147.         dec     ax              ;ax points to last byte in char
  1148.         mov     di,offset updownbuff+31
  1149.         mov     si,ax
  1150.         push    ax
  1151.         std
  1152.         mov     cl,cs:[sizex]
  1153.         xor     ch,ch
  1154.         rep     movsb           ;copies bottom row
  1155.  
  1156.         pop     di              ;start write on bottom row
  1157.         mov     si,di           ;si points to 1st byte in 2nd from bottom
  1158.         mov     bl,cs:[sizex]
  1159.         xor     bh,bh
  1160.         sub     si,bx
  1161.  
  1162.         mov     ax,ds
  1163.         mov     es,ax
  1164.         mov     cx,cs:[xysize]
  1165.         mov     bl,cs:[sizex]
  1166.         xor     bh,bh
  1167.         sub     cx,bx
  1168.         rep     movsb           ;repeat xysize-sizex times
  1169.  
  1170.         mov     ax,cs
  1171.         mov     ds,ax
  1172.         mov     si,offset updownbuff+31
  1173.         mov     cl,cs:[sizex]
  1174.         xor     ch,ch
  1175.         mov     ax,cs:[xysize]
  1176.         mov     bl,cs:[curchar]
  1177.         xor     bh,bh
  1178.         mul     bx
  1179.         add     ax,cx
  1180.         mov     di,ax
  1181.         dec     di
  1182.         rep     movsb   ;end of 1st line
  1183.  
  1184.         cld
  1185.         ret
  1186. Shdown endp
  1187.         
  1188. FlipHorz proc near      ;uses updownbuff
  1189.         mov     ax,cs:[charseg]
  1190.         mov     ds,ax
  1191.         mov     ax,cs
  1192.         mov     es,ax
  1193.  
  1194.         mov     di,offset updownbuff
  1195.         mov     ax,cs:[xysize]
  1196.         mov     bl,cs:[curchar]
  1197.         xor     bh,bh
  1198.         mul     bx
  1199.         mov     si,ax
  1200.         mov     dl,cs:[sizey]
  1201.         cld
  1202. revbigloop:
  1203.         push    si
  1204.         mov     cl,cs:[sizex]
  1205.         xor     ch,ch
  1206.         push    cx
  1207.         rep     movsb
  1208.         pop     cx
  1209.         pop     si
  1210.         push    si
  1211.         
  1212.         dec     di
  1213.  
  1214. revloop:
  1215.         mov     al,es:[di]
  1216.         mov     ds:[si],al
  1217.         inc     si
  1218.         dec     di
  1219.         dec     cx
  1220.         jne     revloop
  1221.         pop     si
  1222.         mov     bl,cs:[sizex]
  1223.         xor     bh,bh
  1224.         add     si,bx
  1225.         mov     di,offset updownbuff
  1226.         dec     dl
  1227.         jne     revbigloop
  1228.         ret
  1229. FlipHorz endp
  1230.         Clip2   db 1024 dup (0)
  1231.  
  1232. FlipVert proc near
  1233.         call    fliphorz
  1234.         mov     ax,cs:[charseg]
  1235.         mov     ds,ax
  1236.         mov     ax,cs
  1237.         mov     es,ax
  1238.         mov     ax,cs:[xysize]
  1239.         mov     cx,ax
  1240.         mov     bl,cs:[curchar]
  1241.         xor     bh,bh
  1242.         mul     bx
  1243.         mov     si,ax
  1244.         push    si
  1245.         push    cx
  1246.         mov     di,offset clip2
  1247.         cld
  1248.         rep     movsb
  1249.         pop     cx
  1250.         pop     si
  1251.         dec     di
  1252. flipvloop:
  1253.         mov     al,es:[di]
  1254.         mov     ds:[si],al
  1255.         dec     di
  1256.         inc     si
  1257.         dec     cx
  1258.         jne     flipvloop
  1259.         ret
  1260. Flipvert endp
  1261.  
  1262. RestoreChar proc near
  1263.         pusha
  1264.  
  1265.         MOV     ax,cs:[charseg]
  1266.         mov     es,ax
  1267.         mov     ax,cs:[charbakseg]
  1268.         mov     ds,ax
  1269.  
  1270.         mov     ax,cs:[xysize]
  1271.         mov     cx,ax
  1272.         mov     bl,cs:[curchar]
  1273.         xor     bh,bh
  1274.         mul     bx
  1275.         mov     si,ax
  1276.         mov     di,ax
  1277.         rep     movsb
  1278.  
  1279.         popa
  1280.         ret
  1281. restorechar endp
  1282.  
  1283. Clearchar proc near
  1284.         pusha
  1285.         mov     ax,cs:[charseg]
  1286.         mov     es,ax
  1287.         mov     ax,cs:[xysize]
  1288.         mov     cx,ax
  1289.         mov     bl,cs:[curchar]
  1290.         xor     bh,bh
  1291.         mul     bx
  1292.         mov     di,ax
  1293.         xor     ax,ax
  1294.         rep     stosb
  1295.         popa
  1296.         ret
  1297. Clearchar endp
  1298.  
  1299.         
  1300.  
  1301. ;============================
  1302. Main:
  1303.         cmp     cs:[inputlength],0
  1304.         je      defaultfile
  1305.              
  1306. Gotsome:
  1307.         mov     ax,cs
  1308.         mov     es,ax
  1309.         mov     ds,ax
  1310.         call    capturefilename
  1311. defaultfile:
  1312.         call    loaddat
  1313.         mov     al,cs:[sizex]
  1314.         mov     ah,cs:[sizey]
  1315.         mul     ah
  1316.         mov     cs:[xysize],ax
  1317.  
  1318.         mov     al,cs:[sizex]
  1319.         xor     ah,ah
  1320.         mov     bl,10
  1321.         div     bl
  1322.         add     al,'0'
  1323.         add     ah,'0'
  1324.         mov     cs:[charnum+17],al
  1325.         mov     cs:[charnum+18],ah
  1326.         
  1327.         mov     al,cs:[sizey]
  1328.         xor     ah,ah
  1329.         mov     bl,10
  1330.         div     bl
  1331.         add     al,'0'
  1332.         add     ah,'0'
  1333.         mov     cs:[charnum+20],al
  1334.         mov     cs:[charnum+21],ah
  1335.         
  1336.         mov     ax,0013h                ;put in 320x200x256 VGA mode
  1337.         int     10h
  1338.  
  1339.         cld
  1340.         mov     ax,cs        
  1341.         mov     ds,ax
  1342.         mov     es,ax
  1343.         mov     si,offset pal
  1344.         mov     di,offset paltmp
  1345.         mov     cx,768/2
  1346.         rep     movsw                   ;copy for fade out
  1347.  
  1348.         MOV     AX,cs:[scrollseg]
  1349.         mov     es,ax
  1350.         xor     di,di
  1351.         mov     cx,160*31       ;max scroll area
  1352.         xor     ax,ax
  1353.         rep     stosw           ;clear scroll area
  1354.         
  1355.         mov     ax,cs
  1356.         mov     ds,ax
  1357.         mov     es,ax
  1358.         mov     dx,offset pal
  1359.         mov     ax,1012h                ; WRITE BLOCK 
  1360.         mov     bx,0                    ; READ WOULD BE 1017H
  1361.         mov     cx,256                  ;
  1362.         int     10h                     ; end set up palette
  1363.  
  1364.         mov     dx,0
  1365.         call    Clearscreen
  1366.  
  1367.         call    colorbox
  1368.         call    displaypalette
  1369.  
  1370.         push    es
  1371.         mov     ax,cs
  1372.         mov     es,ax
  1373.         mov     di,offset scrollmsg2
  1374.         mov     cl,cs:[numchars]
  1375.         xor     ch,ch
  1376.         add     di,cx
  1377.         std
  1378. setupmsgloop:
  1379.         mov     al,cl
  1380.         add     al,cs:[From]    ;" "
  1381.         stosb
  1382.         dec     cl
  1383.         jne     setupmsgloop
  1384.         mov     al," "
  1385.         stosb
  1386.         pop     es
  1387.         cld
  1388.  
  1389. NormalStart:
  1390.  
  1391.         call    displaymain
  1392. WaitforKey:
  1393.         mov     dx,03dah
  1394. vr1:    in      al,dx
  1395.         and     al,08
  1396.         jz      vr1
  1397.  
  1398.         call    scroll
  1399.         CALL    MOVECURSOR
  1400.  
  1401.         xor     ax,ax
  1402.         mov     es,ax
  1403.         mov     al,es:[417h]
  1404.         test    al,00000010b    ;checks left shift
  1405.         je     Alton
  1406.         mov     al,cs:[currentcolor]
  1407.         mov     cs:[oldcolor],al
  1408.         call    drawcolor
  1409.         jmp     keystuff
  1410. Alton:
  1411.         test    al,00000001b    ;checks right shift
  1412.         je     keystuff
  1413.         mov     al,cs:[backgroundcolor]
  1414.         mov     cs:[oldcolor],al
  1415.         call    drawcolor
  1416. KeyStuff:
  1417.         mov     ah,1
  1418.         int     16h
  1419.         jz      waitforkey     
  1420.         mov     ah,0
  1421.         int     16h                      
  1422.         
  1423.         or      al,al           ;checks to see if al=0
  1424.         jne     notaux
  1425.         jmp     AuxKeys
  1426. NotAux:
  1427.         cmp     al,17   ;control-Q Quit
  1428.         jne     Chk1
  1429.         mov     cs:[fadestep],64
  1430.         jmp     byebyef
  1431. Chk1:
  1432.         cmp     al,'1'
  1433.         jne     Chk2
  1434.         inc     cs:[scrollspeed]
  1435.         mov     al,cs:[sizex]
  1436.         xor     ah,ah
  1437.         cmp     cs:[scrollspeed],ax
  1438.         jb      @@s
  1439.         dec     ax
  1440.         mov     cs:[scrollspeed],ax
  1441. @@s:
  1442.         jmp     Waitforkey
  1443. Chk2:
  1444. Chk3:
  1445.         cmp     al,'+'
  1446.         jne     Chk4
  1447.         inc     cs:[curchar]
  1448.         mov     al,cs:[numchars]
  1449.         cmp     cs:[curchar],al
  1450.         jb      @@s
  1451.         mov     cs:[curchar],0
  1452. @@s:
  1453.         call    displaymain
  1454.         jmp     waitforkey
  1455. Chk4:
  1456.         cmp     al,'-'
  1457.         jne     Chk5
  1458.         dec     cs:[curchar]
  1459.         mov     al,cs:[numchars]
  1460.         cmp     cs:[curchar],al
  1461.         jb      @@s
  1462.         mov     al,cs:[numchars]
  1463.         dec     al
  1464.         mov     cs:[curchar],al
  1465. @@s:
  1466.         call    displaymain
  1467.         jmp     waitforkey
  1468. Chk5:
  1469.         cmp     al,"*"
  1470.         jne     chk6
  1471.         mov     ax,cS:[messoff]
  1472.         mov     cs:[messoff],offset scrollmsg2
  1473.         cmp     ax,offset scrollmsg
  1474.         je      itsdone
  1475.         mov     cs:[messoff],offset scrollmsg
  1476. itsdone:
  1477.         mov     cs:[scrollletter],0
  1478.         jmp     waitforkey
  1479. chk6:
  1480.         cmp     al,'['
  1481.         jne     chk7
  1482.         dec     cs:[currentcolor]
  1483.         call    colorbox
  1484.         jmp     waitforkey
  1485. chk7:
  1486.         cmp     al,']'
  1487.         jne     chk8
  1488.         inc     cs:[currentcolor]
  1489.         call    colorbox
  1490.         jmp     waitforkey
  1491. chk8:
  1492.         cmp     al,'2'
  1493.         jne     Chk9
  1494.         dec     cs:[scrollspeed]
  1495.         jne     @@s
  1496.         mov     cs:[scrollspeed],1
  1497. @@s:
  1498.         jmp     Waitforkey
  1499. Chk9:
  1500.         cmp     al,27
  1501.         jne     chk10
  1502.         dec     cs:[backgroundcolor]
  1503.         call    colorbox
  1504.         jmp     waitforkey
  1505. chk10:
  1506.         cmp     al,29
  1507.         jne     chk11
  1508.         inc     cs:[backgroundcolor]
  1509.         call    colorbox
  1510.         jmp     waitforkey
  1511. Chk11:
  1512.         cmp     al,"3"
  1513.         jne     chk12
  1514.         mov     bl,cs:[curchar]
  1515.         xor     bh,bh
  1516.         dec     cs:[CHARWIDTH+BX]
  1517.         CALL    displaymain
  1518.         jmp     waitforkey
  1519. chk12:
  1520.         cmp     al,"4"
  1521.         jne     chk13
  1522.         mov     bl,cs:[curchar]
  1523.         xor     bh,bh
  1524.         inc     cs:[charwidth+bx]
  1525.         CALL    displaymain
  1526.         jmp     waitforkey
  1527. chk13:
  1528.         jmp     waitFORkey
  1529.  
  1530. AuxKeys:
  1531.         cmp     ah,72   ;up
  1532.         jne     AChk1
  1533.         dec     cs:[ypos]
  1534.         mov     al,cs:[sizey]
  1535.         cmp     cs:[ypos],al
  1536.         jb      @@s
  1537.         dec     al
  1538.         mov     cs:[ypos],al
  1539. @@s:
  1540.         jmp     waitforkey
  1541. AChk1:
  1542.         cmp     ah,80   ;down
  1543.         jne     AChk2
  1544.         inc     cs:[ypos]
  1545.         mov     al,cs:[sizey]
  1546.         cmp     cs:[ypos],al
  1547.         jb      @@s
  1548.         mov     cs:[ypos],0
  1549. @@s:
  1550.         jmp     waitforkey
  1551. AChk2:
  1552.         cmp     ah,75   ;left
  1553.         jne     Achk3
  1554.         dec     cs:[xpos]
  1555.         mov     al,cs:[sizex]
  1556.         cmp     cs:[xpos],al
  1557.         jb      @@s
  1558.         dec     al
  1559.         mov     cs:[xpos],al
  1560. @@s:
  1561.         jmp     waitforkey
  1562. AChk3:
  1563.         cmp     ah,77   ;right
  1564.         jne     Achk4
  1565.         inc     cs:[xpos]
  1566.         mov     al,cs:[sizex]
  1567.         cmp     cs:[xpos],al
  1568.         jb      @@s
  1569.         mov     cs:[xpos],0
  1570. @@s:
  1571.         jmp     waitforkey
  1572. Achk4:
  1573.         cmp     ah,94   ;c-f1 save
  1574.         jne     Achk5
  1575.         call    SaveDat
  1576.         jmp     NormalStart
  1577. Achk5:  
  1578.         cmp     ah,59   ;F1
  1579.         jne     Achk6
  1580.         call    grabit
  1581.         jmp     NormalStart
  1582. Achk6:
  1583.         cmp     ah,60
  1584.         jne     Achk7
  1585.         call    pasteit
  1586.         jmp     Normalstart
  1587. Achk7:
  1588.         cmp     ah,61
  1589.         jne     Achk8
  1590.         call    shleft
  1591.         jmp     Normalstart
  1592. Achk8:
  1593.         cmp     ah,62
  1594.         jne     Achk9
  1595.         call    shright
  1596.         jmp     NormalStart
  1597. Achk9:
  1598.         cmp     ah,63
  1599.         jne     Achk10
  1600.         call    shup
  1601.         jmp     NormalStart
  1602. Achk10:
  1603.         cmp     ah,64
  1604.         jne     Achk11
  1605.         call    shdown
  1606.         jmp     NormalStart
  1607. Achk11:
  1608.         cmp     ah,65
  1609.         jne     Achk12
  1610.         call    FlipVert
  1611.         jmp     NormalStart
  1612. Achk12:
  1613.         cmp     ah,66
  1614.         jne     Achk13
  1615.         call    FlipHorz
  1616.         jmp     Normalstart
  1617. Achk13:
  1618.         cmp     ah,67
  1619.         jne     Achk14
  1620.         mov     al,cs:[oldcolor]
  1621.         mov     cs:[currentcolor],al
  1622.         jmp     Normalstart
  1623. Achk14:
  1624.         cmp     ah,68   ;F10
  1625.         jne     Achk15
  1626.         call    restorechar
  1627.         jmp     normalstart
  1628. Achk15:
  1629.         cmp     ah,95   ;backspace
  1630.         jne     Achk16
  1631.         call    clearchar
  1632.         jmp     normalstart
  1633. Achk16:
  1634. Nokeypress:
  1635.         jmp     waitforkey
  1636. endit:
  1637. Byebye:
  1638.         mov     ax,0003h                ;reset screen to text
  1639.         int     10h
  1640. byebye2:
  1641.         mov     ax,cs
  1642.         mov     ds,ax
  1643.         mov     ax,4c00h                ; return control to 
  1644.         int     21h                     ; DOS and exit
  1645.  
  1646. Noinput:
  1647.         mov     ax,cs
  1648.         mov     ds,ax
  1649.         mov     es,ax
  1650.         mov     ah,9
  1651.         mov     dx,offset properuse
  1652.         int     21h
  1653.         jmp     byebye2
  1654. byebyef:
  1655.         jmp     ByeBye
  1656.  
  1657.         mov     dx,03dah
  1658. vr2:    in      al,dx
  1659.         and     al,08
  1660.         jz      vr2
  1661.         call    fadeout
  1662.         call    scroll
  1663.         
  1664.         dec     cs:[fadestep]
  1665.         jne     byebyef
  1666.         jmp     byebye
  1667.  
  1668. code    ends
  1669.         end     start
  1670.