home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / dmycon / consim.asm next >
Assembly Source File  |  1990-06-14  |  32KB  |  2,229 lines

  1. ;/****************************************************
  2. ;
  3. ;    FM-TOWNS FM16/FMR50 Console Sim Program
  4. ;
  5. ;    89.9.16 make v1.00        by Ken
  6. ;    89.9.18 bug fix & speed up    by Ken
  7. ;    90.1.15 fully assembled    by YAMA
  8. ;    90.1.27 BIOS supported     by YAMA
  9. ;    90.1.31 optimized          by YAMA
  10. ;
  11. ;***************************************************/
  12.  
  13. .286c
  14.  
  15.     include    msdos.def
  16.  
  17. code    segment
  18.     assume    cs:code,ds:code,es:code,ss:code
  19.  
  20.     org    5Ch
  21. FCB1    label    byte
  22.     org    6Ch
  23. FCB2    label    byte
  24.     org    80h
  25. cmdl    label    byte
  26.  
  27.     org    100h
  28. ;
  29. ;
  30. ;
  31. entry:        jmp    main
  32. ;
  33. ;
  34. ;
  35.  
  36. GVRAM    equ    0C000h
  37. CVRAM    equ    0C800h
  38. KVRAM    equ    0CA00h
  39. ANKCG    equ    0CB00h
  40.  
  41. TRUE    equ    0FFh
  42. FALSE    equ    0
  43. ;ERR     equ    (-1)
  44.  
  45. MAX_X    equ    80
  46. MAX_Y    equ    24
  47. MAX_Y2    equ    25
  48.  
  49. DMYKAN    equ    0FEh
  50. CRCHR    equ    1Fh
  51. TABCHR    equ    09h
  52. TAB    equ    8
  53. CONTRL    equ    FALSE
  54. ;
  55. ;
  56.  
  57. CUR_X    dw    0
  58. CUR_Y    dw    0
  59.  
  60. CUR_C    db    TRUE    ;cursor :DSPLAY
  61. CUR_T    db    10h    ;cursor type
  62. CUR_OFF dw    14
  63. CUR_SIZ dw    2
  64. BAKXY    dw    0
  65. B_COL    db    0
  66.  
  67. BAK_X    dw    0
  68. BAK_Y    dw    0
  69. COLOR    db    7
  70. KANMOD    db    TRUE
  71. BAKCH1    db    0
  72. KANCOD    db    0
  73. EXTFLG    db    FALSE
  74. EXTPRO    dw    ?
  75. ESCCNT    dw    0
  76. ESCPRM    db    16 dup(0)
  77. dmy_ram    dw    (MAX_X*MAX_Y2) dup(0700H)
  78.  
  79. ;    UCHAR    ankfont[];
  80.  
  81. ;*****************************
  82. ;*    割り込みワ-ク
  83. ;*****************************
  84. vct_off    dw    ?
  85. vct_seg    dw    ?
  86. ;*****************************
  87. ;*    タイマ割り込みテ-ブル
  88. ;*****************************
  89. tim_no    db    ?
  90. tim_md    db    00h
  91.     db    00h
  92. tim_off    dw    ?
  93. tim_seg    dw    ?
  94.     dw    0
  95.     dw    7        ; 割り込み間隔 (1 = 10ms)
  96. ;*********************************************
  97. ;*    コンソ-ルBIOSベクタ(int 91h) &
  98. ;*    タイマ割り込みの設定
  99. ;*********************************************
  100. setbios PROC NEAR
  101.     push    ds
  102.     push    es
  103.  
  104.     mov    ax,3591h        ; int 91h
  105.     int    21h
  106.     mov    ax,es
  107.     mov    cs:[vct_seg],ax
  108.     mov    cs:[vct_off],bx
  109.  
  110.     push    cs
  111.     pop    ds
  112.     mov    dx,offset bios_ent
  113.     mov    ax,2591h        ; int 91h
  114.     int    21h
  115.  
  116.     mov    ax,offset cflush
  117.     mov    cs:[tim_off],ax
  118.     mov    ax,cs
  119.     mov    cs:[tim_seg],ax
  120.  
  121.     mov    di,offset tim_md
  122.     push    cs
  123.     pop    ds
  124.     mov    ah,00h
  125.     int    97h
  126.     mov    cs:[tim_no],al
  127.  
  128.     pop    es
  129.     pop    ds
  130.     ret    
  131. setbios ENDP
  132. ;***************************************
  133. ;*    ベクタ及び割り込みの解除 & 終了
  134. ;***************************************
  135. resetbios PROC NEAR
  136.     push    ds
  137.     push    es
  138.  
  139.     mov    ax,cs:[vct_seg]
  140.     mov    ds,ax
  141.     mov    dx,cs:[vct_off]
  142.     mov    ax,2591h
  143.     int    21h
  144.  
  145.     mov    al,cs:[tim_no]
  146.     mov    ah,01h
  147.     int    97h
  148.  
  149.     mov    ah,4ch
  150.     mov    al,00h
  151.     int    21h
  152.  
  153.     pop    es
  154.     pop    ds
  155.     ret    
  156. resetbios ENDP
  157.  
  158. ;
  159. ; colset
  160. ;  ah:color(attr)
  161. ;  di:top address cx:char count
  162. ;
  163.  
  164. colset    proc    near
  165.  
  166.     mov    bx,CVRAM
  167.     mov    es,bx
  168.     sub    al,al
  169.     rep    stosw
  170.  
  171.     ret
  172. colset    endp
  173.  
  174. ;
  175. ; vramcpy1 ( direction:increase )
  176. ;  [ds:si] source address  [es:di] dest address
  177. ;  cx:char count
  178. ;
  179.  
  180. vramcpy1 proc    near
  181.  
  182. v1_l1b: mov    ax,[si+2000h]
  183.         mov    es:[di+2000h],ax
  184.         movsw
  185.     loop    short v1_l1b
  186.     
  187.     ret
  188. vramcpy1 endp
  189.  
  190. ;
  191. ; vramcpy2 ( direction:decrease )
  192. ;  si:source address  di:dest address
  193. ;  cx:char count
  194. ;
  195.  
  196. vramcpy2 proc    near
  197.  
  198.     std
  199.     push    cx
  200.     dec    cx
  201.     shl    cx,1
  202.     add    si,cx
  203.     add    di,cx
  204.     pop    cx
  205.  
  206. v1_l1c: mov    ax,[si+2000h]
  207.         mov    es:[di+2000h],ax
  208.         movsw
  209.     loop    short v1_l1c
  210.  
  211.     cld
  212.     ret
  213. vramcpy2 endp
  214.  
  215. ;
  216. ; Wrt_Ank
  217. ;   al:char ah:attr
  218. ;   cx:x    bx:y
  219. ;
  220.  
  221. Wrt_Ank proc    near
  222.     push    ds
  223.     push    si
  224.     push    es
  225.     push    di
  226.     push    cx
  227.     push    bx
  228.  
  229.     push    ax
  230.     sub    ah,ah        ; char=>ANKCG address [si]
  231.     shl    ax,4
  232.     mov    si,ax
  233.     mov    ax,80*16    ; x + y * 80*16(GVRAM address) [di]
  234.     mul    bx
  235.     add    ax,cx
  236.     mov    di,ax
  237.     pop    ax
  238.  
  239.     mov    bl,ah
  240.     mov    cl,bl        ;cl
  241.     and    bx,7
  242.  
  243.     test    cl,20h        ;cl
  244.     je    $I147
  245.     or    bl,8            ;at
  246.  
  247. $I147:
  248.     test    cl,18h        ;cl
  249.     je    $I148
  250.     mov    bh,0FFh            ;bk
  251. $I148:
  252.     mov    ax,ANKCG
  253.     mov    ds,ax
  254.     mov    ax,GVRAM
  255.     mov    es,ax
  256.     mov    dx,0FF99h
  257.     mov    al,01h
  258.     out    dx,al
  259.  
  260.     mov    al,0Fh
  261.     mov    dx,0FF81h
  262.     out    dx,al
  263.  
  264.     mov    cx,16
  265.     push    di
  266.     sub    al,al
  267. $F151:    mov    es:[di],al
  268.     add    di,80
  269.     loop    $F151
  270.     pop    di
  271.  
  272.     mov    al,bl
  273.     out    dx,al
  274.     mov    cx,16
  275. $F155:    lodsb
  276.     xor    al,bh
  277.     mov    es:[di],al
  278.     add    di,80
  279.     loop    $F155
  280.  
  281.     mov    dx,0FF99h
  282.     xor    al,al
  283.     out    dx,al
  284.  
  285.     pop    bx
  286.     pop    cx
  287.     pop    di
  288.     pop    es
  289.     pop    si
  290.     pop    ds
  291.     ret    
  292. Wrt_Ank    ENDP
  293.  
  294. ;
  295. ; Wrt_Kan
  296. ;   dx:漢字コード ah:attr
  297. ;   cx:x          bx:y
  298. ;
  299.  
  300. Wrt_Kan PROC NEAR
  301.     push    es
  302.     push    di
  303.     push    cx
  304.     push    bx
  305.  
  306.     push    ax
  307.     push    dx
  308.     mov    ax,80*16    ; x + y * 80*16(GVRAM address) [di]
  309.     mul    bx
  310.     add    ax,cx
  311.     mov    di,ax
  312.     pop    dx
  313.     pop    ax
  314.  
  315.     mov    cl,ah
  316.     mov    ax,dx
  317.     mov    dx,0FF94h
  318.     out    dx,al
  319.     inc    dx
  320.     mov    al,ah
  321.     out    dx,al
  322.  
  323.     mov    bl,cl    ;cl
  324.     and    bx,7
  325.  
  326.     test    cl,20h    ;cl
  327.     je    $I247
  328.     or    bl,8            ;at
  329. $I247:
  330.     test    cl,18h    ;cl
  331.     je    $I248
  332.     mov    bh,0FFh            ;bk
  333. $I248:
  334.     mov    al,0Fh
  335.     mov    dx,0FF81h
  336.     out    dx,al
  337.  
  338.     mov    ax,GVRAM
  339.     mov    es,ax
  340.     mov    cx,16
  341.     push    di
  342.     sub    ax,ax
  343. $F251:    mov    es:[di],ax
  344.     add    di,80
  345.     loop    $F251
  346.     pop    di
  347.  
  348.     mov    al,bl
  349.     out    dx,al
  350.     mov    cx,16
  351. $F277:    mov    dx,0FF96h
  352.     in    al,dx
  353.     xor    al,bh
  354.     mov    es:[di],al
  355.     inc    dx
  356.     in    al,dx
  357.     xor    al,bh
  358.     mov    es:[di+1],al
  359.  
  360.     add    di,80
  361.     loop    $F277
  362.  
  363.     pop    bx
  364.     pop    cx
  365.     pop    di
  366.     pop    es
  367.     ret    
  368. Wrt_Kan ENDP
  369.  
  370. ;
  371. ; locate
  372. ;
  373.  
  374. locate    proc    near
  375.  
  376.     mov    cx,cs:[CUR_X]
  377.     mov    bx,cs:[CUR_Y]
  378.     mov    ax,MAX_X
  379.     mul    bx
  380.     add    ax,cx
  381.     shl    ax,1
  382.     add    ax,offset dmy_ram
  383.     mov    di,ax
  384.     xor    byte ptr cs:[di+1],0FFh
  385.  
  386.     shl    bx,4        ; y *= 16
  387.     add    bx,cs:[CUR_OFF]
  388.     mov    ax,80
  389.     mul    bx        ; y *= 80
  390.     add    ax,cx        ; y + x
  391.     mov    di,ax
  392.  
  393.     mov    ax,GVRAM
  394.     mov    es,ax
  395.     mov    dx,0FF81h
  396.     mov    al,00000001b
  397.     call    loca_sub
  398.     mov    al,01000010b
  399.     call    loca_sub
  400.     mov    al,10000100b
  401.     call    loca_sub
  402.     mov    al,11001000b
  403.     call    loca_sub
  404.     ret    
  405.  
  406. loca_sub:
  407.     out    dx,al
  408.     push    di
  409.     mov    cx,cs:[CUR_SIZ]
  410. loca1:    not    byte ptr es:[di]
  411.     add    di,80
  412.     loop    loca1
  413.     pop    di
  414.     ret
  415. locate    ENDP
  416. ;
  417. ; sjisto
  418. ;  ax:shift jis 漢字コード
  419. ;<return> ax:jis 漢字コード
  420. ;
  421.  
  422. sjisto    proc    near
  423.     cmp    ah,9fh
  424.     jbe    sjto1
  425.     sub    ah,0B1h-071h
  426. sjto1:  sub    ah,071h
  427.     shl    ah,1
  428.     inc    ah
  429.     cmp    al,7fh
  430.     jbe    sjto2
  431.     dec    al
  432. sjto2:    cmp    al,9eh
  433.     jb    sjto3
  434.     sub    al,7dh
  435.     inc    ah
  436.     jmp    sjto4
  437. sjto3:    sub    al,1fh
  438. sjto4:    cmp    ah,70h
  439.     jb    short sjito5
  440.     cmp    ah,74h
  441.     ja    short sjito5
  442.     cmp    al,60h
  443.     jb    short sjito5
  444.     cmp    al,7Eh
  445.     add    ax,0C70h
  446. sjito5:    ret
  447.  
  448. sjisto    ENDP
  449.  
  450. ;
  451. ; iskanji
  452. ;  al:shift jis (上位)
  453. ;<return> C flug=1:漢字コード
  454. ;
  455.  
  456. iskanji        proc    near
  457.         cmp    al,81h
  458.         jb     short ik1_ed
  459.         cmp    al,0A0h
  460.         jae    short ik1_sk1
  461.         ret
  462. ik1_sk1:    cmp    al,0E0h
  463.         jb    short ik1_ed
  464.         cmp    al,0FDh
  465.         jae    short ik1_ed
  466.         ret
  467. ik1_ed:        clc
  468.         ret
  469. iskanji     endp
  470.  
  471. ;
  472. ; iskanji2
  473. ;  al:shift jis (下位)
  474. ;<return> C flug=1:漢字コード
  475. ;
  476.  
  477. iskanji2    proc    near
  478.         cmp    al,40h
  479.         jb     short ik2_ed
  480.         cmp    al,7Fh
  481.         jae    short ik2_sk1
  482.         ret
  483. ik2_sk1:    cmp    al,80h
  484.         jb    short ik2_ed
  485.         cmp    al,0FDh
  486.         jae    short ik2_ed
  487.         ret
  488. ik2_ed:        clc
  489.         ret
  490. iskanji2    endp
  491.  
  492. ;
  493. ; SetPal
  494. ;  al:Pallte no.  ah:Color no.
  495. ;
  496.  
  497. SetPal        proc    near
  498.         push    ax
  499.         push    dx
  500.         mov    dx,0FD90h
  501.         out    dx,al
  502.         inc    dx
  503.         inc    dx
  504.         mov    al,7Fh
  505.         shr    ah,1
  506.         jc    short pal_skp1
  507.         xor    al,al
  508. pal_skp1:    out    dx,al
  509.         inc    dx
  510.         inc    dx
  511.         mov    al,7Fh
  512.         shr    ah,1
  513.         jc    short pal_skp2
  514.         xor    al,al
  515. pal_skp2:    out    dx,al
  516.         inc    dx
  517.         inc    dx
  518.         mov    al,7Fh
  519.         shr    ah,1
  520.         jc    short pal_skp3
  521.         xor    al,al
  522. pal_skp3:    out    dx,al
  523.         pop    dx
  524.         pop    ax
  525.         ret
  526. SetPal        endp
  527. ;
  528. ;
  529. ;
  530.  
  531. scrool        proc    near
  532.         push    cx
  533.         push    bx
  534.         mov    di,0
  535.         mov    si,(MAX_X*2)
  536.         mov    cx,MAX_X*(MAX_Y-1)
  537.         push    ds
  538.         mov    ax,CVRAM
  539.         mov    ds,ax
  540.         mov    es,ax
  541. v1_l1h:        mov    ax,[si+2000h]
  542.             mov    es:[di+2000h],ax
  543.             movsw
  544.         loop    short v1_l1h
  545.         pop    ds
  546.         mov    di,(MAX_X*2)*(MAX_Y-1)
  547.         mov    ah,byte ptr[offset COLOR]
  548.         mov    cx,MAX_X
  549.         sub    al,al
  550.             rep    stosw
  551.         pop    bx
  552.         pop    cx
  553.         ret
  554. scrool        endp
  555. ;
  556. ;
  557. ;
  558.  
  559. PutBS        proc    near
  560.         mov    cx,word ptr[offset CUR_X]
  561.         mov    bx,word ptr[offset CUR_Y]
  562.         dec    cl
  563.         jns    short pbs_end
  564.         mov    cl,MAX_X-1
  565.         dec    bl
  566.         jns    short pbs_end
  567.         xor    bl,bl
  568. pbs_end:    mov    word ptr[offset CUR_X],cx
  569.         mov    word ptr[offset CUR_Y],bx
  570.         ret
  571. PutBS        endp
  572. ;
  573. ;
  574. ;
  575.  
  576. PutTAB        proc    near
  577.         mov    ax,word ptr[offset CUR_X]
  578.         add    ax,TAB
  579.         mov    dl,TAB
  580.         div    dl
  581.         xor    ah,ah
  582.         mul    dl
  583.         sub    ax,word ptr[offset CUR_X]
  584.         mov    cx,ax
  585.         mov    ah,byte ptr[offset COLOR]
  586.         mov    al,' '
  587. ptb_lp1:    push    ax
  588.         push    cx
  589.         call    PutChr
  590.         pop    cx
  591.         pop    ax
  592.         loop    short ptb_lp1
  593.         ret
  594. PutTAB        endp
  595. ;
  596. ;
  597. ;
  598.  
  599. PutLF        proc    near
  600.         mov    bx,word ptr[offset CUR_Y]
  601.         inc    bl
  602.         cmp    bl,MAX_Y
  603.         jb    short plf_sk1
  604.         mov    bl,MAX_Y-1
  605.         call    scrool
  606. plf_sk1:    mov    word ptr[offset CUR_Y],bx
  607.         ret
  608. PutLF        endp
  609. ;
  610. ;
  611. ;
  612.  
  613. PutHOME        proc near
  614.         mov    word ptr[offset CUR_X],0
  615.         mov    word ptr[offset CUR_Y],0
  616.         ret
  617. PutHOME        endp
  618. ;
  619. ;
  620. ;
  621.  
  622. PutCLS        proc    near
  623.         push    ax
  624.         push    cx
  625.         push    di
  626.  
  627.         mov    ah,byte ptr[offset COLOR]
  628.         mov    di,0
  629.         mov    cx,MAX_X * MAX_Y
  630.         call    colset
  631.  
  632.         mov    word ptr[offset CUR_X],0
  633.         mov    word ptr[offset CUR_Y],0
  634.  
  635.         pop    di
  636.         pop    cx
  637.         pop    ax
  638.         ret
  639. PutCLS        endp
  640. ;
  641. ;
  642. ;
  643.  
  644. PutCR        proc    near
  645.         mov    word ptr[offset CUR_X],0
  646.         ret
  647. PutCR        endp
  648. ;
  649. ;
  650. ;
  651.  
  652. PutRit        proc    near
  653.         mov    cx,word ptr[offset CUR_X]
  654.         mov    bx,word ptr[offset CUR_Y]
  655.         inc    cl
  656.         cmp    cl,MAX_X
  657.         jb    short pr_sk1
  658.         xor    cl,cl
  659.         inc    bl
  660.         cmp    bl,MAX_Y
  661.         jb    short pr_sk1
  662.         xor    bl,bl
  663. pr_sk1:        mov    word ptr[offset CUR_X],cx
  664.         mov    word ptr[offset CUR_Y],bx
  665.         ret
  666. PutRit        endp
  667. ;
  668. ;
  669. ;
  670.  
  671. PutLft        proc    near
  672.         mov    cx,word ptr[offset CUR_X]
  673.         mov    bx,word ptr[offset CUR_Y]
  674.         dec    cl
  675.         jns    short pl_sk1
  676.         mov    cl,MAX_X-1
  677.         dec    bl
  678.         jns    short pl_sk1
  679.         mov    bl,MAX_Y-1        
  680. pl_sk1:        mov    word ptr[offset CUR_X],cx
  681.         mov    word ptr[offset CUR_Y],bx
  682.         ret
  683. PutLft        endp
  684. ;
  685. ;
  686. ;
  687.  
  688. PutUp        proc    near
  689.         mov    bx,word ptr[offset CUR_Y]
  690.         dec    bl
  691.         jns    short pu_sk1
  692.         mov    bl,MAX_Y-1
  693. pu_sk1:        mov    word ptr[offset CUR_Y],bx
  694.         ret
  695. PutUp        endp
  696. ;
  697. ;
  698. ;
  699.  
  700. PutDwn        proc    near
  701.         mov    bx,word ptr[offset CUR_Y]
  702.         inc    bl
  703.         cmp    bl,MAX_Y
  704.         jb    short pd_sk1
  705.         xor    bl,bl
  706. pd_sk1:        mov    word ptr[offset CUR_Y],bx
  707.         ret
  708. PutDwn        endp
  709. ;
  710. ;
  711. ;
  712.  
  713. SVidAt        proc    near
  714.         and    al,3Fh
  715.         mov    byte ptr[offset COLOR],al
  716.         ret
  717. SVidAt        endp
  718. ;
  719. ;
  720. ;
  721.  
  722. SetDC2_s    proc    near
  723.         xor    ch,ch
  724.         xor    bh,bh
  725.         mov    cl,byte ptr[offset BAKCH1]
  726.         mov    bl,al
  727.         or    cl,cl
  728.         jns    short dc2_sk1
  729.         xor    cl,cl
  730. dc2_sk1:    cmp    cl,MAX_X
  731.         jb    short dc2_sk2
  732.         mov    cl,MAX_X-1
  733. dc2_sk2:    or    bl,bl
  734.         jns    short dc2_sk3
  735.         xor    bl,bl
  736. dc2_sk3:    cmp    bl,MAX_Y
  737.         jb    short dc2_sk4
  738.         mov    bl,MAX_Y-1
  739. dc2_sk4:    mov    word ptr[offset CUR_X],cx
  740.         mov    word ptr[offset CUR_Y],bx
  741.         ret
  742. SetDC2_s    endp
  743. ;
  744.  
  745. SetDC2        proc    near
  746.         mov    byte ptr[offset BAKCH1],al
  747.         mov    byte ptr[offset EXTFLG],TRUE
  748.         mov    word ptr[offset EXTPRO],offset SetDC2_s
  749.         ret
  750. SetDC2        endp
  751. ;
  752. ;
  753. ;
  754.  
  755. SetDC3_s    proc    near
  756.         xor    cx,cx
  757.         mov    cl,byte ptr[offset BAKCH1]
  758.         mov    ah,byte ptr[offset COLOR]
  759.         or    ah,80h
  760. dc3_lp1:    push    ax
  761.         push    cx
  762.         call    PutChr
  763.         pop    cx
  764.         pop    ax
  765.         dec    cx
  766.         jne    short dc3_lp1
  767.         ret
  768. SetDC3_s    endp
  769. ;
  770.  
  771. SetDC3        proc    near
  772.         mov    byte ptr[offset BAKCH1],al
  773.         mov    byte ptr[offset EXTFLG],TRUE
  774.         mov    word ptr[offset EXTPRO],offset SetDC3_s
  775.         ret
  776. SetDC3        endp
  777. ;
  778. ;
  779. ;
  780.  
  781. EraLin        proc    near
  782.         mov    ax,MAX_X
  783.         mul    word ptr [offset CUR_Y]
  784.         add    ax,word ptr[offset CUR_X]
  785.         shl    ax,1
  786.         mov    di,ax
  787.  
  788.         mov    ax,MAX_X
  789.         sub    ax,word ptr[offset CUR_X]
  790.         mov    cx,ax
  791.  
  792.         mov    ah,byte ptr[offset COLOR]
  793.         call    colset
  794.         ret
  795. EraLin        endp
  796. ;
  797. ;
  798. ;
  799.  
  800. EraScr        proc    near
  801.         mov    ax,MAX_X
  802.         mul    word ptr [offset CUR_Y]
  803.         add    ax,word ptr[offset CUR_X]
  804.         mov    dx,ax
  805.         shl    ax,1
  806.         mov    di,ax
  807.  
  808.         mov    ax,MAX_X*MAX_Y
  809.         sub    ax,dx
  810.         mov    cx,ax
  811.  
  812.         mov    ah,byte ptr[offset COLOR]
  813.         call    colset
  814.         ret
  815. EraScr        endp
  816. ;
  817. ;
  818. ;
  819.  
  820. InsLin        proc    near
  821.         mov    word ptr[offset CUR_X],0
  822.         mov    ax,MAX_X
  823.         mul    word ptr[offset CUR_Y]
  824.         mov    si,ax
  825.         shl    si,1
  826.         push    si
  827.  
  828.         add    ax,MAX_X
  829.         mov    di,ax
  830.         shl    di,1
  831.  
  832.         mov    cx,MAX_X*MAX_Y
  833.         sub    cx,ax
  834.  
  835.         push    ds
  836.         mov    ax,CVRAM
  837.         mov    ds,ax
  838.         mov    es,ax
  839.         call    vramcpy2
  840.         pop    ds
  841.  
  842.         pop    di
  843.         mov    ah,byte ptr[offset COLOR]
  844.         mov    cx,MAX_X
  845.         call    colset
  846.         ret
  847. InsLin        endp
  848. ;
  849. ;
  850. ;
  851.  
  852. DelLin        proc    near
  853.         mov    ax,MAX_X
  854.         mul    word ptr[offset CUR_Y]
  855.         mov    di,ax
  856.         shl    di,1
  857.  
  858.         add    ax,MAX_X
  859.         mov    si,ax
  860.         shl    si,1
  861.  
  862.         mov    cx,MAX_X*MAX_Y
  863.         sub    cx,ax
  864.  
  865.         push    ds
  866.         mov    ax,CVRAM
  867.         mov    ds,ax
  868.         mov    es,ax
  869.         call    vramcpy1
  870.         pop    ds
  871.  
  872.         mov    di,2*MAX_X*(MAX_Y-1)
  873.         mov    ah,byte ptr[offset COLOR]
  874.         mov    cx,MAX_X
  875.         call    colset
  876.         ret
  877. DelLin        endp
  878. ;
  879. ;
  880. ;
  881.  
  882. SCurPs_s    proc    near
  883.         xor    ch,ch
  884.         xor    bh,bh
  885.         mov    cl,al
  886.         mov    bl,byte ptr[offset BAKCH1]
  887.         sub    cl,' '
  888.         jns    short scp_sk1
  889.         xor    cl,cl
  890. scp_sk1:    cmp    cl,MAX_X
  891.         jb    short scp_sk2
  892.         mov    cl,MAX_X-1
  893. scp_sk2:    sub    bl,' '
  894.         jns    short scp_sk3
  895.         xor    bl,bl
  896. scp_sk3:    cmp    bl,MAX_Y
  897.         jb    short scp_sk4
  898.         mov    bl,MAX_Y-1
  899. scp_sk4:    mov    word ptr[offset CUR_X],cx
  900.         mov    word ptr[offset CUR_Y],bx
  901.         ret
  902. SCurPs_s    endp
  903. ;
  904.  
  905. SCurPs        proc    near
  906.         mov    byte ptr[offset BAKCH1],al
  907.         mov    byte ptr[offset EXTFLG],TRUE
  908.         mov    word ptr[offset EXTPRO],offset SCurPs_s
  909.         ret
  910. SCurPs        endp
  911. ;
  912. ;
  913. ;
  914.  
  915. CurAtt_s    proc    near
  916.         ret
  917. CurAtt_s    endp
  918. ;
  919.  
  920. CurAtt        proc    near
  921.         mov    byte ptr[offset BAKCH1],al
  922.         mov    byte ptr[offset EXTFLG],TRUE
  923.         mov    word ptr[offset EXTPRO],offset CurAtt_s
  924.         ret
  925. CurAtt        endp
  926. ;
  927. ;
  928. ;
  929.  
  930. AnsiH        proc    near
  931.         xor    bh,bh
  932.         xor    ch,ch
  933.         mov    bl,byte ptr ESCPRM[0]
  934.         mov    cl,byte ptr ESCPRM[1]
  935.         dec    cl
  936.         jns    short ah_sk1
  937.         xor    cl,cl
  938. ah_sk1:        cmp    cl,MAX_X
  939.         jb    short ah_sk2
  940.         mov    cl,MAX_X-1
  941. ah_sk2:        dec    bl
  942.         jns    short ah_sk3
  943.         xor    bl,bl
  944. ah_sk3:        cmp    bl,MAX_Y
  945.         jb    short ah_sk4
  946.         mov    bl,MAX_Y-1
  947. ah_sk4:        mov    word ptr[offset CUR_X],cx
  948.         mov    word ptr[offset CUR_Y],bx
  949.         ret
  950. AnsiH        endp
  951. ;
  952. ;
  953. ;
  954.  
  955. AnsiA        proc    near
  956.         mov    bx,word ptr[offset CUR_Y]
  957.         sub    bl,byte ptr ESCPRM[0]
  958.         jns    short aa_sk1
  959.         xor    bl,bl
  960. aa_sk1:        mov    word ptr[offset CUR_Y],bx
  961.         ret
  962. AnsiA        endp
  963. ;
  964. ;
  965. ;
  966.  
  967. AnsiB        proc    near
  968.         mov    bx,word ptr[offset CUR_Y]
  969.         add    bl,byte ptr ESCPRM[0]
  970.         cmp    bl,MAX_Y
  971.         jb    short ab_sk1
  972.         mov    bl,MAX_Y
  973. ab_sk1:        mov    word ptr[offset CUR_Y],bx
  974.         ret
  975. AnsiB        endp
  976. ;
  977. ;
  978. ;
  979.  
  980. AnsiC        proc    near
  981.         mov    cx,word ptr[offset CUR_X]
  982.         add    cl,byte ptr ESCPRM[0]
  983.         cmp    cl,MAX_X
  984.         jb    short ac_sk1
  985.         mov    cl,MAX_X
  986. ac_sk1:        mov    word ptr[offset CUR_X],cx
  987.         ret
  988. AnsiC        endp
  989. ;
  990. ;
  991. ;
  992.  
  993. AnsiD        proc    near
  994.         mov    cx,word ptr[offset CUR_X]
  995.         sub    cl,byte ptr ESCPRM[0]
  996.         jns    short ad_sk1
  997.         xor    cl,cl
  998. ad_sk1:        mov    word ptr[offset CUR_X],cx
  999.         ret
  1000. AnsiD        endp
  1001. ;
  1002. ;
  1003. ;
  1004.  
  1005. Ansis        proc    near
  1006.         mov    cx,word ptr[offset CUR_X]
  1007.         mov    bx,word ptr[offset CUR_Y]
  1008.         mov    word ptr[offset BAK_X],cx
  1009.         mov    word ptr[offset BAK_Y],bx
  1010.         ret
  1011. Ansis        endp
  1012. ;
  1013. ;
  1014. ;
  1015.  
  1016. Ansiu        proc    near
  1017.         mov    cx,word ptr[offset BAK_X]
  1018.         mov    bx,word ptr[offset BAK_Y]
  1019.         mov    word ptr[offset CUR_X],cx
  1020.         mov    word ptr[offset CUR_Y],bx
  1021.         ret
  1022. Ansiu        endp
  1023. ;
  1024. ;
  1025. ;
  1026.  
  1027. AnsiJ        proc    near
  1028.         mov    al,byte ptr ESCPRM[0]
  1029.         cmp    al,0
  1030.         jne    short aj_skp1
  1031.         call    EraScr
  1032.         ret
  1033. aj_skp1:    cmp    al,1
  1034.         jne    short aj_skp2
  1035.         mov    di,0
  1036.         mov    ax,MAX_X
  1037.         mul    word ptr[offset CUR_Y]
  1038.         add    ax,word ptr[offset CUR_X]
  1039.         inc    ax
  1040.         mov    cx,ax
  1041.         mov    ah,byte ptr[offset COLOR]
  1042.         call    colset
  1043.         ret
  1044. aj_skp2:    cmp    al,2
  1045.         jne    short aj_skp3
  1046.         call    PutCLS
  1047. aj_skp3:    ret
  1048. AnsiJ        endp
  1049. ;
  1050. ;
  1051. ;
  1052.  
  1053. AnsiK        proc    near
  1054.         mov    al,byte ptr ESCPRM[0]
  1055.         cmp    al,0
  1056.         jne    short ak_skp1
  1057.         call    EraLin
  1058.         ret
  1059. ak_skp1:    cmp    al,1
  1060.         jne    short ak_skp2
  1061.         mov    ax,MAX_X*2
  1062.         mul    word ptr [offset CUR_Y]
  1063.         mov    di,ax
  1064.         mov    cx,word ptr[offset CUR_X]
  1065.         mov    ah,byte ptr[offset COLOR]
  1066.         call    colset
  1067.         ret
  1068.  
  1069. ak_skp2:    cmp    al,2
  1070.         jne    short ak_skp3
  1071.         mov    ax,MAX_X*2
  1072.         mul    word ptr [offset CUR_Y]
  1073.         mov    di,ax
  1074.         mov    cx,MAX_X
  1075.         mov    ah,byte ptr[offset COLOR]
  1076.         call    colset
  1077. ak_skp3:    ret
  1078. AnsiK        endp
  1079. ;
  1080. ;
  1081. ;
  1082.  
  1083. AnsiM_l        proc    near
  1084. aml_lp1:    call    DelLin
  1085.         dec    byte ptr ESCPRM[0]
  1086.         jns    short aml_lp1
  1087.         mov    word ptr[offset CUR_X],0
  1088.         ret
  1089. AnsiM_l        endp
  1090. ;
  1091. ;
  1092. ;
  1093.  
  1094. AnsiL        proc    near
  1095. al_lp1:        call    InsLin
  1096.         dec    byte ptr ESCPRM[0]
  1097.         jns    short al_lp1
  1098.         mov    word ptr[offset CUR_X],0
  1099.         ret
  1100. AnsiL        endp
  1101. ;
  1102. ;
  1103. ;
  1104.  
  1105. Ansim_s        proc    near
  1106.         mov    cl,[COLOR]
  1107.         xor    si,si
  1108.         xor    bh,bh
  1109. ams_lp1:    mov    bl,byte ptr ESCPRM[si]
  1110.         cmp    bl,0
  1111.         jne    short ams_skp1
  1112.         mov    cl,7
  1113.         jmp    short ams_lend
  1114.  
  1115. ams_skp1:    cmp    bl,8
  1116.         ja    short ams_skp2
  1117.         or    cl,byte ptr ansiatt[bx]
  1118.         jmp    short ams_lend
  1119.  
  1120. ams_skp2:    cmp    bl,30
  1121.         jb    short ams_skp3
  1122.         cmp    bl,37
  1123.         ja    short ams_skp3
  1124.         and    cl,0F8h
  1125.         or    cl,byte ptr ansicol[bx-30]
  1126.         jmp    short ams_lend
  1127.  
  1128. ams_skp3:    cmp    bl,40
  1129.         jb    short ams_lend
  1130.         cmp    bl,47
  1131.         ja    short ams_lend
  1132.         mov    al,00h
  1133.         mov    ah,byte ptr ansicol[bx-40]
  1134.         mov    byte ptr [offset B_COL],ah
  1135.         call    SetPal
  1136.  
  1137. ams_lend:    inc    si
  1138.         cmp    si,word ptr[offset ESCCNT]
  1139.         jbe    short ams_lp1
  1140.  
  1141.         mov    [COLOR],cl
  1142.         ret
  1143. Ansim_s        endp
  1144.  
  1145. ansiatt        db    00h,20h,00h,00h,00h,10h,00h,08h,00h
  1146. ansicol        db    0,2,4,6,1,3,5,7
  1147. ;
  1148. ;
  1149. ;
  1150.  
  1151. Ansiv        proc    near
  1152.         mov    al,ESCPRM[0]
  1153. CurDsp:        cmp    al,1
  1154.         je    short av_skp1
  1155.         mov    byte ptr cs:[CUR_C],TRUE
  1156.         ret
  1157. av_skp1:    mov    byte ptr cs:[CUR_C],FALSE
  1158.         ret
  1159. Ansiv        endp
  1160. ;
  1161. ;
  1162. ;
  1163.  
  1164. AnsiCom        proc    near
  1165.         cmp    al,';'
  1166.         jne    short ansi_skp1
  1167.         mov    cx,[ESCCNT]
  1168.         cmp    cx,16
  1169.         jae    short ansi_skp1
  1170.         inc    cx
  1171.         mov    [ESCCNT],cx
  1172.         jmp    short ansi_end2
  1173.  
  1174. ansi_skp1:    cmp    al,'0'
  1175.         jb    short ansi_skp2
  1176.         cmp    al,'9'
  1177.         ja    short ansi_skp2
  1178.         sub    al,'0'
  1179.         mov    cl,al
  1180.         xor    ch,ch
  1181.         mov    bx,word ptr[offset ESCCNT]
  1182.         mov    al,10
  1183.         mul    byte ptr ESCPRM[bx]
  1184.         add    ax,cx
  1185.         mov    byte ptr ESCPRM[bx],al
  1186.         jmp    short ansi_end2
  1187.  
  1188. ansi_skp2:    cmp    al,' '
  1189.         je    short ansi_end2
  1190.         mov    di,offset ansi_tbl
  1191.         mov    cx,ansi_tbl_l
  1192.         repnz    scasb
  1193.         jne    short ansi_end
  1194.         sub    di,(offset ansi_tbl+1)
  1195.         shl    di,1
  1196.         mov    di,[offset ansi_j_tbl+di]
  1197.         call    near ptr di
  1198. ansi_end:    ret
  1199.  
  1200. ansi_end2:    mov    byte ptr[offset EXTFLG],TRUE
  1201.         mov    word ptr[offset EXTPRO],offset AnsiCom
  1202.         ret
  1203. AnsiCom        endp
  1204.  
  1205. ansi_tbl    db    'H','f','A','B','C','D','s','u','J','K','m','M','L','v'
  1206. ansi_tbl_l    equ    $-ansi_tbl
  1207. ansi_j_tbl    dw    offset AnsiH
  1208.         dw    offset AnsiH
  1209.         dw    offset AnsiA
  1210.         dw    offset AnsiB
  1211.         dw    offset AnsiC
  1212.         dw    offset AnsiD
  1213.         dw    offset Ansis
  1214.         dw    offset Ansiu
  1215.         dw    offset AnsiJ
  1216.         dw    offset AnsiK
  1217.         dw    offset Ansim_s
  1218.         dw    offset AnsiM_l
  1219.         dw    offset AnsiL
  1220.         dw    offset Ansiv
  1221. ;
  1222. ;
  1223. ;
  1224.  
  1225. AnsiESC        proc    near
  1226.         mov    word ptr[offset ESCCNT],0
  1227.         mov    di,offset ESCPRM
  1228.         mov    cx,16
  1229.         xor    al,al
  1230.         rep    stosb
  1231.         mov    byte ptr[offset EXTFLG],TRUE
  1232.         mov    word ptr[offset EXTPRO],offset AnsiCom
  1233.         ret
  1234. AnsiESC        endp
  1235. ;
  1236. ;
  1237.  
  1238. EscCom        proc    near
  1239.         mov    di,offset esc_tbl
  1240.         mov    cx,esc_tbl_l
  1241.         repnz    scasb
  1242.         jne    short esc_end
  1243.         sub    di,(offset esc_tbl+1)
  1244.         shl    di,1
  1245.         mov    di,[offset esc_j_tbl+di]
  1246.         call    near ptr di
  1247. esc_end:    ret
  1248. EscCom        endp
  1249. ;
  1250. Esc_K        proc    near
  1251.         mov    byte ptr[offset KANMOD],TRUE
  1252.         ret
  1253. Esc_K        endp
  1254. ;
  1255. Esc_C        proc    near
  1256.         mov    byte ptr[offset KANMOD],FALSE
  1257.         ret
  1258. Esc_C        endp
  1259.  
  1260. N_SCurPs    proc    near
  1261.         mov    byte ptr[offset EXTFLG],TRUE
  1262.         mov    word ptr[offset EXTPRO],offset SCurPs
  1263.         ret
  1264. N_SCurPs    endp
  1265. ;
  1266. N_SVidAt    proc    near
  1267.         mov    byte ptr[offset EXTFLG],TRUE
  1268.         mov    word ptr[offset EXTPRO],offset SVidAt
  1269.         ret
  1270. N_SVidAt    endp
  1271. ;
  1272. N_CurAtt    proc    near
  1273.         mov    byte ptr[offset EXTFLG],TRUE
  1274.         mov    word ptr[offset EXTPRO],offset CurAtt
  1275.         ret
  1276. N_CurAtt    endp
  1277.  
  1278. esc_tbl        db    '*','T','Y','E','R','=','G','K','C','.','['
  1279. esc_tbl_l    equ    $-esc_tbl
  1280. esc_j_tbl    dw    offset PutCLS
  1281.         dw    offset EraLin
  1282.         dw    offset EraScr
  1283.         dw    offset InsLin
  1284.         dw    offset DelLin
  1285.         dw    offset N_SCurPs
  1286.         dw    offset N_SVidAt
  1287.         dw    offset Esc_K
  1288.         dw    offset Esc_C
  1289.         dw    offset N_CurAtt
  1290.         dw    offset AnsiESC
  1291. ;
  1292. ;
  1293. ;
  1294.  
  1295. PutCnt        proc    near
  1296.         mov    di,offset cnt_tbl
  1297.         mov    cx,cnt_tbl_l
  1298.         repnz    scasb
  1299.         jne    short pcn_end
  1300.         sub    di,(offset cnt_tbl+1)
  1301.         shl    di,1
  1302.         mov    di,[offset cnt_j_tbl+di]
  1303.         call    near ptr di
  1304. pcn_end:    ret
  1305. PutCnt        endp
  1306. ;
  1307. N_SetDC2    proc    near
  1308.         mov    byte ptr[offset EXTFLG],TRUE
  1309.         mov    word ptr[offset EXTPRO],offset SetDC2
  1310.         ret
  1311. N_SetDC2    endp
  1312. ;
  1313. N_SetDC3    proc    near
  1314.         mov    byte ptr[offset EXTFLG],TRUE
  1315.         mov    word ptr[offset EXTPRO],offset SetDC3
  1316.         ret
  1317. N_SetDC3    endp
  1318.  
  1319. N_EscCom    proc    near
  1320.         mov    byte ptr[offset EXTFLG],TRUE
  1321.         mov    word ptr[offset EXTPRO],offset EscCom
  1322.         ret
  1323. N_EscCom    endp
  1324.  
  1325. cnt_tbl        db    08h,09h,0Ah,0Bh,0Ch,0Dh,12h,13h
  1326.         db    15h,16h,1Bh,1Ch,1Dh,1Eh,1Fh
  1327. cnt_tbl_l    equ    $-cnt_tbl
  1328. cnt_j_tbl    dw    offset PutBS
  1329.         dw    offset PutTAB
  1330.         dw    offset PutLF
  1331.         dw    offset PutHOME
  1332.         dw    offset PutCLS
  1333.         dw    offset PutCR
  1334.         dw    offset N_SetDC2
  1335.         dw    offset N_SetDC3
  1336.         dw    offset PutCLS
  1337.         dw    offset PutCLS
  1338.         dw    offset N_EscCom
  1339.         dw    offset PutRit
  1340.         dw    offset PutLft
  1341.         dw    offset PutUp
  1342.         dw    offset PutDwn
  1343. ;
  1344. ; PutChr
  1345. ;  al:code  ah:attr
  1346. ;  dx:漢字コード
  1347. ;
  1348.  
  1349. PutChr        proc    near
  1350.  
  1351.         mov    bx,CVRAM
  1352.         mov    es,bx
  1353.         push    ax
  1354.         push    dx
  1355.         mov    ax,MAX_X
  1356.         mul    word ptr[offset CUR_Y]
  1357.         add    ax,word ptr[offset CUR_X]
  1358.         shl    ax,1
  1359.         mov    di,ax
  1360.         pop    dx
  1361.         pop    ax
  1362.  
  1363.         mov    es:[di],ax
  1364.         test    ah,40h
  1365.         jz    short pc_sk3
  1366.         xchg    dh,dl
  1367.         mov    es:[di+2000h],dx
  1368.  
  1369. pc_sk3:        mov    cx,word ptr[offset CUR_X]
  1370.         mov    bx,word ptr[offset CUR_Y]
  1371.         inc    cx
  1372.         cmp    cx,MAX_X
  1373.         jb    short pc_sk4
  1374.         xor    cx,cx
  1375.         inc    bx
  1376.         cmp    bx,MAX_Y
  1377.         jb    short pc_sk4
  1378.         mov    bx,MAX_Y-1
  1379.         call    scrool
  1380. pc_sk4:        mov    word ptr[offset CUR_X],cx
  1381.         mov    word ptr[offset CUR_Y],bx
  1382.  
  1383.         ret
  1384. PutChr        endp
  1385.  
  1386. ;
  1387. ; VDB_outchr ( int 91h  fun.1Dh )
  1388. ;  al:char code ( shift jis )
  1389. ;
  1390.  
  1391. VDB_outchr    proc    near
  1392.         mov    bx,cs
  1393.         mov    ds,bx
  1394.         mov    es,bx
  1395.  
  1396.         cmp    byte ptr[EXTFLG],FALSE
  1397.         jne    short Vo_extch
  1398.  
  1399.         cmp    byte ptr[KANMOD],FALSE
  1400.         je    short Vo_ank
  1401.  
  1402.         cmp    byte ptr[KANCOD],0
  1403.         je    short Vo_kan3
  1404.         call    iskanji2
  1405.         jnc    short Vo_kan2
  1406.         cmp    byte ptr[CUR_X],MAX_X-1
  1407.         jne    short Vo_kan1
  1408.         mov    ah,[COLOR]
  1409.         mov    al,DMYKAN
  1410.         call    PutChr
  1411.         call    PutChr
  1412.         mov    byte ptr[KANCOD],0
  1413.         ret
  1414. Vo_kan1:    mov    ah,[KANCOD]
  1415.         call    sjisto
  1416.         mov    dx,ax
  1417.         xor    al,al
  1418.         mov    ah,[COLOR]
  1419.         or    ah,40h
  1420.         call    PutChr
  1421.         mov    ah,[COLOR]
  1422.         or    ah,80h
  1423.         call    PutChr
  1424.         mov    byte ptr[KANCOD],0
  1425.         ret
  1426. Vo_kan2:    mov    ah,[COLOR]
  1427.         push    ax
  1428.         mov    al,[KANCOD]
  1429.         call    PutChr
  1430.         pop    ax
  1431.         call    PutChr
  1432.         ret
  1433. Vo_kan3:    call    iskanji
  1434.         jnc    short Vo_ank
  1435.         mov    [KANCOD],al
  1436.         ret
  1437.  
  1438. Vo_ank:        cmp    al,' '
  1439.         jb    short pc_sk1b
  1440.         cmp    al,7Fh
  1441.         je    short pc_sk1b
  1442.         mov    ah,[COLOR]
  1443.         call    PutChr
  1444.         ret
  1445. pc_sk1b:    call    PutCnt
  1446.         ret
  1447.  
  1448. Vo_extch:    mov    byte ptr[EXTFLG],FALSE
  1449.         mov    dx,[EXTPRO]
  1450.         call    near ptr dx
  1451.         ret
  1452. VDB_outchr    endp
  1453.  
  1454. ;
  1455. ; VDB_setpos ( int 91h  fun.0Dh )
  1456. ;  cx:x (1-80)  bx:y (1-25)
  1457. ;
  1458.  
  1459. VDB_setpos    proc    near
  1460.         dec    cx
  1461.         jns    short Vs_sk1
  1462.         mov    cx,0
  1463. Vs_sk1:        cmp    cx,MAX_X
  1464.         jb    short Vs_sk2
  1465.         mov    cx,MAX_X-1
  1466. Vs_sk2:        dec    bx
  1467.         jns    short Vs_sk3
  1468.         mov    bx,0
  1469. Vs_sk3:        cmp    bx,MAX_Y
  1470.         jb    short Vs_sk4
  1471.         mov    bx,MAX_Y-1
  1472. Vs_sk4:        mov    cs:[offset CUR_X],cx
  1473.         mov    cs:[offset CUR_Y],bx
  1474.         ret
  1475. VDB_setpos    endp
  1476.  
  1477. ;
  1478. ; VDB_string2
  1479. ;  al : 0=文字のみ 1=文字とアトリビュート
  1480. ;  [es:si] 文字コード  [ds:di] 文字属性
  1481. ;
  1482.  
  1483. VDB_string2    proc    near
  1484.         cmp    al,1
  1485.         je    short Vs_l2
  1486.  
  1487. Vs_l1:        mov    bl,es:[si]        ;al=0
  1488.         mov    bh,[di]
  1489.         call    VDB_oc3
  1490.         inc    si
  1491.         inc    di
  1492.         inc    dl
  1493.         loop    short Vs_l1
  1494.         jmp    short Vs_ed
  1495.  
  1496. Vs_l2:        mov    ax,[di+1]        ;al=1
  1497.         and    al,38h
  1498.         and    ah,07h
  1499.         or    ah,al
  1500.         mov    al,1
  1501.         mov    bl,es:[si]
  1502.         mov    bh,[di]
  1503.         call    VDB_oc3
  1504.         inc    si
  1505.         add    di,4
  1506.         inc    dl
  1507.         loop    short Vs_l2
  1508.  
  1509. Vs_ed:        ret
  1510. VDB_string2    endp
  1511.  
  1512. ;
  1513. ; VDB_oc3
  1514. ;  al 0:アトリビュート書換え 1:書き換えない
  1515. ;  ah: アトリビュート
  1516. ;  bl: 文字コード  bh:文字属性
  1517. ;  dl: x(0-79)     dh: y(0-24)
  1518. ;
  1519.  
  1520. VDB_oc3        proc    near
  1521.  
  1522.         push    es
  1523.         push    di
  1524.         push    ax
  1525.         push    bx
  1526.         push    cx
  1527.         push    dx
  1528.  
  1529.         push    ax
  1530.         mov    ax,CVRAM
  1531.         mov    es,ax
  1532.         mov    ax,MAX_X
  1533.         push    dx
  1534.         mov    dl,dh
  1535.         xor    dh,dh
  1536.         mul    dx
  1537.         pop    dx
  1538.         xor    dh,dh
  1539.         add    ax,dx
  1540.         shl    ax,1
  1541.         mov    di,ax
  1542.         pop    ax
  1543.  
  1544.         cmp    al,1
  1545.         jne    short Vo3_sk1b
  1546.         mov    es:[di+1],ah
  1547.  
  1548. Vo3_sk1b:    test    bh,01h
  1549.         jz    short Vo3_sk2
  1550.         test    bh,02h
  1551.         jnz    short Vo3_sk1
  1552.  
  1553.         mov    byte ptr es:[di],DMYKAN
  1554.         mov    es:[di+2000h],bl
  1555.         or    byte ptr es:[di+1],40h
  1556.         jmp    short Vo3_sk3
  1557.  
  1558. Vo3_sk1:    mov    byte ptr es:[di],DMYKAN
  1559.         mov    es:[di+2000h-1],bl
  1560.         and    byte ptr es:[di+1],3Fh
  1561.         jmp    short Vo3_sk3
  1562.  
  1563. Vo3_sk2:    mov    es:[di],bl
  1564.         and    byte ptr es:[di+1],3Fh
  1565.  
  1566.  
  1567. Vo3_sk3:    pop    dx
  1568.         pop    cx
  1569.         pop    bx
  1570.         pop    ax
  1571.         pop    di
  1572.         pop    es
  1573.         ret
  1574. VDB_oc3        endp
  1575.  
  1576. ;
  1577. ; VDB_scroll1
  1578. ;
  1579.  
  1580. VDB_scroll1    proc    near
  1581.         cmp    al,1
  1582.         je    short b1A_r1
  1583.  
  1584.         mov    al,MAX_X
  1585.         mul    dh
  1586.         add    al,dl
  1587.         adc    ah,0
  1588.         shl    ax,1
  1589.         mov    di,ax
  1590.  
  1591.         mov    al,MAX_X*2
  1592.         mul    cl
  1593.         add    ax,di
  1594.         mov    si,ax
  1595.  
  1596.         sub    bh,dh
  1597.         sub    bh,cl
  1598.         inc    bh
  1599.         sub    bl,dl
  1600.         inc    bl
  1601.         mov    dx,cx
  1602.  
  1603.         mov    cl,bl
  1604.         mov    ax,CVRAM
  1605.         mov    ds,ax
  1606.         mov    es,ax
  1607.  
  1608. b1A_l1:        push    di
  1609.         push    si
  1610. v1_l1:         mov    ax,[si+2000h]
  1611.             mov    es:[di+2000h],ax
  1612.             movsw
  1613.         loop    short v1_l1
  1614.         pop    si
  1615.         pop    di
  1616.         
  1617.         add    si,MAX_X*2
  1618.         add    di,MAX_X*2
  1619.         mov    cl,bl
  1620.         dec    bh
  1621.         jne    short b1A_l1
  1622.  
  1623.         mov    ah,cs:[COLOR]
  1624.         xor    al,al
  1625. b1A_l2:        push    di
  1626.         rep    stosw
  1627.         pop    di
  1628.         add    di,MAX_X*2
  1629.         mov    cl,bl
  1630.         dec    dl
  1631.         jne    short b1A_l2
  1632.         ret
  1633.  
  1634. b1A_r1:        mov    al,MAX_X
  1635.         mul    bh
  1636.         add    al,dl
  1637.         adc    ah,0
  1638.         shl    ax,1
  1639.         mov    di,ax
  1640.  
  1641.         mov    al,MAX_X*2
  1642.         mul    cl
  1643.         mov    si,di
  1644.         sub    si,ax
  1645.  
  1646.         sub    bh,dh
  1647.         sub    bh,cl
  1648.         inc    bh
  1649.         sub    bl,dl
  1650.         inc    bl
  1651.         mov    dx,cx
  1652.  
  1653.         mov    cl,bl
  1654.         mov    ax,CVRAM
  1655.         mov    ds,ax
  1656.         mov    es,ax
  1657. b1A_l3:        push    di
  1658.         push    si
  1659. v1_l3:         mov    ax,[si+2000h]
  1660.             mov    es:[di+2000h],ax
  1661.             movsw
  1662.         loop    short v1_l3
  1663.         pop    si
  1664.         pop    di
  1665.         sub    si,MAX_X*2
  1666.         sub    di,MAX_X*2
  1667.         mov    cl,bl
  1668.         dec    bh
  1669.         jne    short b1A_l3
  1670.  
  1671.         mov    ah,cs:[COLOR]
  1672.         xor    al,al
  1673. b1A_l4:        push    di
  1674.         rep    stosw
  1675.         pop    di
  1676.         sub    di,MAX_X*2
  1677.         mov    cl,bl
  1678.         dec    dl
  1679.         jne    short b1A_l4
  1680.         ret
  1681. VDB_scroll1    endp
  1682.  
  1683. ;******************************
  1684. ;*    コンソ-ルBIOS(int 91h)
  1685. ;******************************
  1686.  
  1687. bios_ent proc far
  1688.     push    bp
  1689.     push    es
  1690.     push    ds
  1691.     push    si
  1692.     push    di
  1693.     push    dx
  1694.     push    cx
  1695.     push    bx
  1696.     push    ax
  1697.     sti
  1698.     cld
  1699.  
  1700.     push    ax
  1701.     mov    al,ah
  1702.     xor    ah,ah
  1703.     shl    ax,1
  1704.     mov    si,ax
  1705.     mov    si,cs:[offset bios_tbl + si]
  1706.     pop    ax
  1707.     mov    bp,sp
  1708.     call    near ptr si
  1709.     mov    bp,sp
  1710.     mov    byte ptr[bp+1],0
  1711.  
  1712.     pop    ax
  1713.     pop    bx
  1714.     pop    cx
  1715.     pop    dx
  1716.     pop    di
  1717.     pop    si
  1718.     pop    ds
  1719.     pop    es
  1720.     pop    bp
  1721.     iret
  1722.  
  1723. bios_tbl    dw    offset b00
  1724.         dw    offset b01
  1725.         dw    offset b02
  1726.         dw    offset b03
  1727.         dw    offset b04
  1728.         dw    offset b05
  1729.         dw    offset b06
  1730.         dw    offset b07
  1731.         dw    offset b08
  1732.         dw    offset b09
  1733.         dw    offset b0A
  1734.         dw    offset b0B
  1735.         dw    offset b0C
  1736.         dw    offset b0D
  1737.         dw    offset b0E
  1738.         dw    offset b0F
  1739.         dw    offset b10
  1740.         dw    offset b11
  1741.         dw    offset b12
  1742.         dw    offset b13
  1743.         dw    offset b14
  1744.         dw    offset b15
  1745.         dw    offset b16
  1746.         dw    offset b17
  1747.         dw    offset b18
  1748.         dw    offset b19
  1749.         dw    offset b1A
  1750.         dw    offset b1B
  1751.         dw    offset b1C
  1752.         dw    offset b1D
  1753.         dw    offset b1E
  1754.         dw    offset b1F
  1755.         dw    offset b20
  1756. bios_ent endp
  1757.  
  1758. b00    proc    near
  1759.     ret
  1760. b00    endp
  1761.  
  1762. b01    proc    near
  1763.     ret
  1764. b01    endp
  1765.  
  1766. b02    proc    near
  1767.     ret
  1768. b02    endp
  1769.  
  1770. b03    proc    near
  1771.     ret
  1772. b03    endp
  1773.  
  1774. b04    proc    near
  1775.     mov    dx,1950h
  1776.     mov    [bp+6],dx
  1777.     ret
  1778. b04    endp
  1779.  
  1780. b05    proc    near
  1781.     ret
  1782. b05    endp
  1783.  
  1784. b06    proc    near
  1785.     ret
  1786. b06    endp
  1787.  
  1788. b07    proc    near
  1789.     ret
  1790. b07    endp
  1791.  
  1792. b08    proc    near
  1793.     ret
  1794. b08    endp
  1795.  
  1796. b09    proc    near
  1797.     mov    cs:[CUR_T],al
  1798.     mov    ah,al
  1799.     and    al,0Fh
  1800.     cmp    al,0
  1801.     jne    short b09_s1
  1802.     mov    byte ptr cs:[CUR_OFF],14
  1803.     mov    byte ptr cs:[CUR_SIZ],2
  1804.     jmp    short b09_s3
  1805. b09_s1:    cmp    al,1
  1806.     jne    short b09_s2
  1807.     mov    byte ptr cs:[CUR_OFF],0
  1808.     mov    byte ptr cs:[CUR_SIZ],16
  1809.     jmp    short b09_s3
  1810. b09_s2:    cmp    al,15
  1811.     jne    short b09_s3
  1812.     cmp    dh,0
  1813.     js    short b09_c1
  1814.     cmp    dh,15
  1815.     jbe    short b09_n1
  1816. b09_c1:    mov    dh,15
  1817. b09_n1:    cmp    dl,dh
  1818.     jbe    short b09_c2
  1819.     cmp    dl,15
  1820.     jbe    short b09_n2
  1821. b09_c2:    mov    dl,15
  1822. b09_n2:    sub    dl,dh
  1823.     inc    dl
  1824.     mov    byte ptr cs:[CUR_OFF],dh
  1825.     mov    byte ptr cs:[CUR_SIZ],dl
  1826. b09_s3: and    ah,60h
  1827.     cmp    ah,20h
  1828.     jne    short b09_s4
  1829.     mov    byte ptr cs:[CUR_C],FALSE
  1830.     ret
  1831. b09_s4:    mov    byte ptr cs:[CUR_C],TRUE
  1832.     ret
  1833. b09    endp
  1834.  
  1835. b0A    proc    near
  1836.     mov    al,[CUR_T]
  1837.     mov    dh,byte ptr[CUR_OFF]
  1838.     mov    dl,byte ptr[CUR_SIZ]
  1839.     add    dl,dh
  1840.     dec    dl
  1841.     mov    [bp],al
  1842.     mov    [bp+6],dx
  1843.     ret
  1844. b0A    endp
  1845.  
  1846. b0B    proc    near
  1847.     call    CurDsp
  1848.     ret
  1849. b0B    endp
  1850.  
  1851. b0C    proc    near
  1852.     ret
  1853. b0C    endp
  1854.  
  1855. b0D    proc    near
  1856.     sub    ah,ah
  1857.     mov    al,dh    ;y
  1858.     mov    bx,ax
  1859.     mov    al,dl    ;x
  1860.     mov    cx,ax
  1861.     call    VDB_setpos
  1862.     ret
  1863. b0D    endp
  1864.     
  1865. b0E    proc    near
  1866.     mov    dl,byte ptr cs:[CUR_X]
  1867.     inc    dl
  1868.     mov    dh,byte ptr cs:[CUR_Y]
  1869.     inc    dh
  1870.     mov    [bp+6],dx
  1871.     ret
  1872. b0E    endp
  1873.  
  1874. b0F    proc    near
  1875.     ret
  1876. b0F    endp
  1877.  
  1878. b10    proc    near
  1879.     ret
  1880. b10    endp
  1881.  
  1882. b11    proc    near
  1883.     mov    ax,[di+1]
  1884.     and    al,38h
  1885.     and    ah,07h
  1886.     or    al,ah
  1887.     mov    cs:[COLOR],al
  1888.     ret
  1889. b11    endp
  1890.  
  1891. b12    proc    near
  1892.     mov    al,cs:[COLOR]
  1893.     mov    ah,al
  1894.     and    al,38h
  1895.     and    ah,07h
  1896.     mov    [di+1],ax
  1897.     mov    byte ptr[di+3],0
  1898.     ret
  1899. b12    endp
  1900.  
  1901. b13    proc    near
  1902.     dec    dh
  1903.     dec    dl
  1904.     mov    ah,cs:[COLOR]
  1905.     call    VDB_oc3
  1906.     ret
  1907. b13    endp
  1908.  
  1909. b14    proc    near
  1910.     ret
  1911. b14    endp
  1912.  
  1913. b15    proc near
  1914.     
  1915.     dec    dl
  1916.     dec    dh
  1917.     dec    bl
  1918.     dec    bh
  1919.     push    dx
  1920.     push    bx
  1921.     mov    bp,sp
  1922.  
  1923.     mov    [bp+3],bl
  1924.     sub    [bp+3],dl
  1925.     inc    byte ptr[bp+3]
  1926.     xor    ch,ch
  1927.     mov    cl,[bp+3]
  1928.  
  1929.     push    bx
  1930.     push    dx
  1931.     mov    si,[di]
  1932.     mov    es,[di+2]
  1933.     mov    dx,[di+4]
  1934.     mov    bx,[di+6]
  1935.     mov    di,dx
  1936.     mov    ds,bx
  1937.     pop    dx
  1938.     pop    bx
  1939.  
  1940. b15_l1:    call    VDB_string2
  1941.     mov    cl,[bp+3]
  1942.     mov    dl,[bp+2]
  1943.     inc    dh
  1944.     cmp    dh,[bp+1]
  1945.     jbe    short b15_l1
  1946.  
  1947.     add    sp,4
  1948.     ret
  1949. b15    endp
  1950.  
  1951. b16    proc    near
  1952.     ret
  1953. b16    endp
  1954.  
  1955. b17    proc    near
  1956.     ret
  1957. b17    endp
  1958.  
  1959. b18    proc    near
  1960.     dec    dl
  1961.     dec    dh
  1962.     dec    bl
  1963.     dec    bh
  1964. b18_e1:    push    dx
  1965.     push    bx
  1966.     mov    bp,sp
  1967.  
  1968.     mov    al,1
  1969.     mov    ah,cs:[COLOR]
  1970.     xor    bx,bx
  1971.  
  1972.  
  1973. b18_l1:    call    VDB_oc3
  1974.     inc    dl
  1975.     cmp    dl,[bp]
  1976.     jbe    short b18_l1
  1977.     mov    dl,[bp+2]
  1978.     inc    dh
  1979.     cmp    dh,[bp+1]
  1980.     jbe    short b18_l1
  1981.  
  1982.     add    sp,4
  1983.     ret
  1984. b18    endp
  1985.  
  1986. b19    proc    near
  1987.     ret
  1988. b19    endp
  1989.  
  1990. b1A    proc    near
  1991.     dec    dl
  1992.     dec    dh
  1993.     dec    bl
  1994.     dec    bh
  1995.     cmp    al,2
  1996.     jae    short b1A_s1
  1997.  
  1998. ;    push    bx
  1999. ;    sub    bh,dh
  2000. ;    mov    bl,bh
  2001. ;    xor    bh,bh
  2002. ;    cmp    cx,bx
  2003. ;    pop    bx
  2004. ;    jae    short b18_e1
  2005.  
  2006.     call    VDB_scroll1
  2007. b1A_s1:    ret
  2008. b1A    endp
  2009.  
  2010. b1B    proc    near
  2011.     ret
  2012. b1B    endp
  2013.  
  2014. b1C    proc    near
  2015.     ret
  2016. b1C    endp
  2017.  
  2018. b1D    proc    near
  2019.     call    VDB_outchr
  2020.     ret
  2021. b1D    endp
  2022.  
  2023. b1E    proc    near
  2024. b1E_1:    mov    al,[di]
  2025.     push    ds
  2026.     push    di
  2027.     push    cx
  2028.     call    VDB_outchr
  2029.     pop    cx
  2030.     pop    di
  2031.     pop    ds
  2032.     inc    di
  2033.     loop    b1E_1
  2034.     ret
  2035. b1E    endp
  2036.  
  2037. b1F    proc    near
  2038.     cmp    dl,76
  2039.     jb    short b1F_s1
  2040.     mov    dl,76
  2041.  
  2042. b1F_s1:    dec    dl
  2043.     mov    dh,24
  2044.     push    bx
  2045.     push    dx
  2046.     mov    si,[di]
  2047.     mov    es,[di+2]
  2048.     mov    dx,[di+4]
  2049.     mov    bx,[di+6]
  2050.     mov    di,dx
  2051.     mov    ds,bx
  2052.     pop    dx
  2053.     pop    bx
  2054.     call    VDB_string2
  2055.     ret
  2056. b1F    endp
  2057.  
  2058. b20    proc    near
  2059.     xor    dh,dh
  2060.     mov    dl,cs:[B_COL]
  2061.     mov    [bp+6],dx
  2062.     ret
  2063. b20    endp
  2064.  
  2065. ;
  2066. ;
  2067. ;
  2068.  
  2069. cflush        proc far
  2070.         mov    dx,05C8h
  2071.         in    al,dx
  2072.         sti
  2073.         test    al,80h
  2074.         jnz    short cf_main
  2075.         mov    al,byte ptr cs:[CUR_X]
  2076.         mov    ah,byte ptr cs:[CUR_Y]
  2077.         cmp    ax,word ptr cs:[BAKXY]
  2078.         jne    short cf_chk1
  2079. cf_cend:    ret
  2080.  
  2081. cf_chk1:    mov    word ptr cs:[BAKXY],ax
  2082.         cmp    byte ptr cs:[CUR_C],FALSE
  2083.         je    short cf_cend
  2084.  
  2085. cf_main:    cld
  2086.         mov    ax,CVRAM    ; cp
  2087.         mov    ds,ax
  2088.         xor    si,si
  2089.  
  2090.         mov    ax,cs        ; dp
  2091.         mov    es,ax
  2092.         mov    di,offset dmy_ram
  2093.  
  2094.         xor    cx,cx        ; x:cx
  2095.         xor    bx,bx        ; y:bx
  2096.  
  2097. cf_lp1:        mov    ax,[si]
  2098.         test    ah,40h
  2099.         je    short cf_ank
  2100.  
  2101.         mov    dx,[si+2000h]
  2102.         cmp    dx,es:[di+2]
  2103.         jne    short cf_knj
  2104.         cmp    ah,es:[di+1]
  2105.         je    short cf_ked
  2106. cf_knj:        mov    es:[di],ax
  2107.         mov    es:[di+2],dx
  2108.         call    Wrt_kan
  2109. cf_ked:        add    si,4
  2110.         add    di,4
  2111.         add    cx,2
  2112.         jmp    short cf_end
  2113.  
  2114. cf_ank:        cmp    ax,es:[di]
  2115.         mov    es:[di],ax
  2116.         je    short cf_aed
  2117.         call    Wrt_ank
  2118. cf_aed:        add    si,2
  2119.         add    di,2
  2120.         inc    cx
  2121. cf_end:        cmp    cx,MAX_X
  2122.         jb    short cf_lp1
  2123.         sub    cx,MAX_X
  2124.         inc    bx
  2125.         cmp    bx,MAX_Y2
  2126.         jb    short cf_lp1
  2127.  
  2128.         cmp    byte ptr cs:[CUR_C],FALSE
  2129.         je    short cf_end2
  2130.         call    locate
  2131. cf_end2:    ret
  2132. cflush        endp
  2133. ;
  2134. ;
  2135. ;
  2136.  
  2137. main:        mov    ah,byte ptr[offset COLOR]
  2138.         xor    al,al
  2139.         mov    di,0
  2140.         mov    cx,MAX_X * MAX_Y2
  2141.         call    colset
  2142.         mov    word ptr[offset CUR_X],0
  2143.         mov    word ptr[offset CUR_Y],0
  2144.  
  2145.         call    setbios
  2146.  
  2147.         mov    ax,cs
  2148.         mov    ds,ax
  2149.         mov    es,ax
  2150.  
  2151.         mov    bx,offset para
  2152.         mov    [bx+4],ax
  2153.         mov    [bx+8],ax
  2154.         mov    [bx+12],ax
  2155.         mov    bx,offset mem_end+0Fh
  2156.         shr    bx,4
  2157.         mov    ah,4Ah
  2158.         int    21h
  2159.  
  2160.         cld
  2161.         mov    si,offset cmdl+1
  2162.         mov    di,offset path
  2163. skip_lp1:    lodsb
  2164.         cmp    al,0Dh
  2165.         je    short exit
  2166.         cmp    al,20h
  2167.         jbe    short skip_lp1
  2168.         stosb
  2169. main_lp1:    lodsb
  2170.         cmp    al,0Dh
  2171.         jne    short main_sk1
  2172.         mov    word ptr[offset cmdl],0D00h
  2173.         mov    byte ptr[di],0
  2174.         jmp    short cmd_end
  2175. main_sk1:    cmp    al,20h
  2176.         je    short new_cmdl
  2177.         stosb
  2178.         jmp    short main_lp1
  2179. new_cmdl:    mov    byte ptr[di],0
  2180.         mov    cl,1
  2181.         mov    bx,offset cmdl
  2182.         lea    di,[bx+1]
  2183.         stosb
  2184. main_lp2:    lodsb
  2185.         cmp    al,0Dh
  2186.         je    short end_ncmdl
  2187.         stosb
  2188.         inc    cl
  2189.         jmp    short main_lp2
  2190. end_ncmdl:    mov    byte ptr[di],0Dh
  2191.         mov    [bx],cl
  2192. cmd_end:    mov    si,offset cmdl+1
  2193.         mov    di,offset FCB1
  2194.         mov    ax,2901h
  2195.         int    21h
  2196.         mov    di,offset FCB2
  2197.         mov    ax,2901h
  2198.         int    21h
  2199.         mov    dx,offset path
  2200.         mov    bx,offset para
  2201.         mov    al,0
  2202.         mov    ah,4Bh
  2203.         int    21h
  2204.  
  2205.         call    resetbios
  2206.  
  2207. exit:        xor    al,al
  2208.         msdos    F$Exit;
  2209.  
  2210. ;
  2211. ;
  2212. ;
  2213. path        db    64 dup(?)
  2214. para        dw    0
  2215.         dw    offset cmdl
  2216.         dw    ?
  2217.         dw    offset FCB1
  2218.         dw    ?
  2219.         dw    offset FCB2
  2220.         dw    ?
  2221. ;
  2222. ;
  2223. ;
  2224. mem_end        equ    $
  2225.  
  2226. code        ends
  2227.         end    entry
  2228.