Annotation of coherent/d/PS2_KERNEL/io.286/gras.m, revision 1.1.1.1

1.1       root        1: / (lgl-
                      2: /      COHERENT Driver Kit Version 1.0.0
                      3: /      Copyright (c) 1982, 1990 by Mark Williams Company.
                      4: /      All rights reserved. May not be copied without permission.
                      5: / -lgl)
                      6:        .globl  grread_
                      7:        .globl  grwrite_
                      8:        .globl  mmgo_
                      9: 
                     10: ////////
                     11: /
                     12: / State driven code
                     13: /
                     14: /      Input:  DS:SI - input string
                     15: /              ES:DI - current screen location
                     16: /              SS:BP - terminal attributes
                     17: /              CX    - input count
                     18: /              BP    - references terminal information
                     19: /              AL    - character
                     20: /              BH    - (usually) kept zeroed for efficiency
                     21: /              DH    - current row
                     22: /              DL    - current column
                     23: /
                     24: ////////
                     25: 
                     26: #ifdef HERCULES
                     27:        VSEG    = 0xB000        / Video Display Segment
                     28:        BANKSZ  = 8192          / Size of Display Banks
                     29:        LROW    = 24            / Last legal row
                     30:        NCR     = 8             / number of horizontal lines per char
                     31:        NCR2    = 4             / number of horizontal lines per char / 2
                     32:        NCR4    = 2             / number of horizontal lines per char / 4
                     33:        NHB     = 90            / number of horizontal bytes per line
                     34: #else
                     35: #ifdef TECMAR
                     36:        VSEG    = 0xA000        / Video Display Segment
                     37:        BANKSZ  = 32768         / Size of Display Banks
                     38:        LROW    = 24            / Last legal row
                     39:        NCR     = 16            / number of horizontal lines per char
                     40:        NCR2    = 8             / number of horizontal lines per char / 2
                     41:        NCR4    = 4             / number of horizontal lines per char / 4
                     42:        NHB     = 80            / number of horizontal bytes per line
                     43: #else
                     44:        VSEG    = 0xB800        / Video Display Segment
                     45:        BANKSZ  = 8192          / Size of Display Banks
                     46:        LROW    = 24            / Last legal row
                     47:        NCR     = 8             / number of horizontal lines per char
                     48:        NCR2    = 4             / number of horizontal lines per char / 2
                     49:        NCR4    = 2             / number of horizontal lines per char / 4
                     50:        NHB     = 80            / number of horizontal bytes per line
                     51: #endif
                     52: #endif
                     53: 
                     54:        NRB     = NHB*NCR       / number of bytes per character row
                     55:        NRB2    = NHB*NCR2      / number of bytes per character row / 2
                     56:        NRB4    = NHB*NCR4      / number of bytes per character row / 4
                     57: 
                     58: 
                     59:        ZERO    = bh            / (almost) always zero
                     60:        ROW     = dh            / currently active vertical position
                     61:        COL     = dl            / currently active horizontal position
                     62:        POS     = di            / currently active display address
                     63: 
                     64:        CSR     = 0x3D9         / Color Select Register
                     65:        MSR     = 0x3D8         / Mode Select Register
                     66:        XMSR    = 0x3DA         / Extended Mode Select Register
                     67: 
                     68: 
                     69: ////////
                     70: /
                     71: / Magic constants from <sys/io.h>
                     72: /
                     73: ////////
                     74: 
                     75:        IO_SEG  = 0
                     76:        IO_IOC  = 2
                     77:        IO_SEEK = 4
                     78:        IO_BASE = 8
                     79: 
                     80:        IOSYS   = 0
                     81: 
                     82: ////////
                     83: /
                     84: / Data
                     85: /
                     86: ////////
                     87: 
                     88: MM_FUNC                = 0             / current state
                     89: MM_PORT                = 2             / adapter base i/o port
                     90: MM_BASE                = 4             / adapter base memory address
                     91: MM_ROW         = 6             / screen row
                     92: MM_COL         = 7             / screen column
                     93: MM_POS         = 8             / screen position
                     94: MM_ATTR                = 10            / attributes
                     95: MM_N1          = 11            / numeric argument 1
                     96: MM_N2          = 12            / numeric argument 2
                     97: MM_BROW                = 13            / base row
                     98: MM_EROW                = 14            / end row
                     99: MM_LROW                = 15            / legal row limit
                    100: MM_SROW                = 16            / saved cursor row
                    101: MM_SCOL                = 17            / saved cursor column
                    102: MM_IBROW       = 18            / initial base row
                    103: MM_IEROW       = 19            / initial end row
                    104: MM_FLIP                = 20
                    105: MM_MASK                = 22
                    106: MM_ULINE       = 24
                    107: MM_CURSE       = 26
                    108: MM_VIS         = 28            / set to -1 to make cursor visible
                    109: MM_NCOL                = 30
                    110: MM_WRAP                = 31
                    111: 
                    112: / ASCII characters
                    113: AZERO          = 0x30
                    114: CLOWER         = 0x63
                    115: HLOWER         = 0x68
                    116: LLOWER         = 0x6C
                    117: SEMIC          = 0x3B
                    118: 
                    119:        .prvd
                    120: mmdata:        .word   mminit, 0x03D4, VSEG
                    121:        .byte   0, 0
                    122:        .word   0
                    123:        .byte   0x7, 0, 0, 0, LROW-1, LROW, 0, 0, 0, LROW-1
                    124:        .word   0, -1, 0, 0xff
                    125:        .word   0
                    126:        .byte   80
                    127:        .byte   1
                    128: 
                    129:        .shri
                    130: #ifdef HERCULES
                    131: crtdata:.byte   54,  45,  45,   8,  91,   1,  86,  88
                    132:        .byte     2,   3,  32,   0,   0,   0,   0,   0
                    133: #else
                    134: #ifdef TECMAR
                    135: crtdata:.byte   56,  40,  43,   8, 127,   6, 100, 112
                    136:        .byte     3,   1,  32,   0,   0,   0,   0,   0
                    137: #else
                    138: crtdata:.byte   56,  40,  43,   8, 127,   6, 100, 112
                    139:        .byte     2,   1,  32,   0,   0,   0,   0,   0
                    140: #endif
                    141: #endif
                    142:        .shri
                    143: 
                    144: ////////
                    145: /
                    146: / mmgo( iop )          - Entry point for text stream output
                    147: / IO *iop;
                    148: /
                    149: ////////
                    150: 
                    151: mmgo_:
                    152:        push    si
                    153:        push    di
                    154:        push    bp
                    155:        mov     bp, sp
                    156:        push    ds
                    157:        push    es
                    158:        cld
                    159:        mov     bx, 8(bp)               / iop
                    160:        mov     si, IO_BASE(bx)         / iop->io_base
                    161:        mov     cx, IO_IOC(bx)          / iop->io_ioc
                    162:        cmp     IO_SEG(bx), $IOSYS
                    163:        je      0f
                    164:        mov     bx, uds_
                    165:        mov     ds, bx
                    166: 0:     mov     bp, $mmdata
                    167:        movb    ROW, MM_ROW(bp)
                    168:        movb    COL, MM_COL(bp)
                    169:        mov     es,  MM_BASE(bp)
                    170:        mov     POS, MM_POS(bp)
                    171:        mov     ax, MM_CURSE(bp)
                    172:        and     ax, MM_VIS(bp)
                    173: #ifdef TECMAR
                    174:        xor     es:[NHB*6](POS), ax
                    175:        xor     es:[NHB*6]+BANKSZ(POS), ax
                    176:        xor     es:[NHB*7](POS), ax
                    177:        xor     es:[NHB*7]+BANKSZ(POS), ax
                    178: #else
                    179:        xor     es:[NHB*3](POS), ax     / turn cursor off
                    180:        xor     es:[NHB*3]+BANKSZ(POS), ax
                    181: #endif
                    182:        sub     bx, bx
                    183:        ijmp    MM_FUNC(bp)
                    184: 
                    185: exit:  movb    bl, ROW                 / reposition to ROW and COL
                    186:        shlb    bl, $1
                    187:        mov     POS, cs:rowtab(bx)
                    188:        movb    bl, COL
                    189:        cmpb    MM_NCOL(bp), $40
                    190:        jne     0f
                    191:        shlb    bl, $1
                    192: 0:     add     POS, bx
                    193:        mov     ax, MM_CURSE(bp)
                    194:        and     ax, MM_VIS(bp)
                    195: #ifdef TECMAR
                    196:        xor     es:[NHB*6](POS), ax     / turn cursor on
                    197:        xor     es:[NHB*6]+BANKSZ(POS), ax
                    198:        xor     es:[NHB*7](POS), ax
                    199:        xor     es:[NHB*7]+BANKSZ(POS), ax
                    200: #else
                    201:        xor     es:[NHB*3](POS), ax     / turn cursor on
                    202:        xor     es:[NHB*3]+BANKSZ(POS), ax
                    203: #endif
                    204:        pop     bx
                    205:        pop     es
                    206:        pop     ds
                    207:        mov     MM_FUNC(bp), bx
                    208:        movb    MM_ROW(bp), ROW         / save row,column
                    209:        movb    MM_COL(bp), COL
                    210:        mov     MM_POS(bp), POS         / save position
                    211: 
                    212:        mov     dx, $MSR                / enable video display
                    213:        movb    al, $0x1A
                    214:        outb    dx, al
                    215:        mov     mmvcnt_, $480           / 480 seconds before video disabled
                    216: 
                    217:        mov     bp, sp
                    218:        mov     bx, 8(bp)
                    219:        mov     ax, cx                  / Return the residual count.
                    220:        xchg    cx, IO_IOC(bx)
                    221:        sub     cx, IO_IOC(bx)
                    222:        add     IO_BASE(bx), cx
                    223:        pop     bp
                    224:        pop     di
                    225:        pop     si
                    226:        ret
                    227: 
                    228: ////////
                    229: /
                    230: / mminit - initialize screen
                    231: /
                    232: ////////
                    233: 
                    234: mminit:        movb    ss:mmesc_, $CLOWER              / schedule keyboard initialization
                    235:        mov     dx, $MSR                / disable video display
                    236:        movb    al, $0x12
                    237:        outb    dx, al
                    238: 
                    239:        push    cx                      / program registers, last to first
                    240:        mov     bx, $15
                    241:        mov     dx, MM_PORT(bp)
                    242: 0:     movb    al, bl
                    243:        outb    dx, al
                    244:        inc     dx
                    245:        movb    al, cs:crtdata(bx)
                    246:        outb    dx, al
                    247:        dec     dx
                    248:        dec     bx
                    249:        jge     0b
                    250:        pop     cx
                    251: 
                    252:        mov     dx, $CSR
                    253:        movb    al, $0x0F
                    254:        outb    dx, al
                    255: 
                    256:        mov     dx, $XMSR
                    257: #ifdef TECMAR
                    258:        movb    al, $31
                    259: #else
                    260:        movb    al, $0
                    261: #endif
                    262:        outb    dx, al
                    263: 
                    264: /      mov     dx, $XMSR
                    265: 0:     inb     al, dx          / wait for vertical retrace
                    266:        andb    al, $8
                    267:        je      0b
                    268: 
                    269:        mov     dx, $MSR
                    270:        movb    al, $0x1A       / video display on
                    271:        outb    dx, al
                    272: 
                    273:        mov     MM_VIS(bp), $-1
                    274:        mov     MM_MASK(bp), $0xAAAA
                    275:        mov     MM_FLIP(bp), $0
                    276:        mov     MM_ULINE(bp), $0
                    277:        mov     MM_CURSE(bp), $0x00ff
                    278:        movb    MM_WRAP(bp), $1
                    279:        movb    MM_NCOL(bp), $80
                    280:        subb    COL, COL
                    281:        movb    ROW, MM_IBROW(bp)
                    282:        movb    MM_BROW(bp), ROW
                    283:        movb    bl, MM_IEROW(bp)
                    284:        movb    MM_EROW(bp), bl
                    285:        sub     bx, bx
                    286:        movb    MM_N1(bp), $2
                    287:        jmp     mm_ed
                    288: 
                    289: ////////
                    290: /
                    291: / mmbell - schedule beep
                    292: /
                    293: ////////
                    294: 
                    295: mmbell:        movb    ss:mmbeeps_, $-1
                    296:        jmp     eval
                    297: 
                    298: ////////
                    299: /
                    300: / mmspec - pass special characters on to keyboard routine(s).
                    301: /
                    302: ////////
                    303: 
                    304: mmspec:        movb    ss:mmesc_, al
                    305:        jmp     eval
                    306: 
                    307: ////////
                    308: /
                    309: / mm_cnl - cursor next line
                    310: /
                    311: /      Moves the active position to the first column of the next display line.
                    312: /      Scrolls the active display if necessary.
                    313: /      Returns to mmwrite() to allow flow control on each output line.
                    314: /
                    315: ////////
                    316: 
                    317: mm_cnl:        subb    COL, COL
                    318:        incb    ROW
                    319:        cmpb    ROW, MM_EROW(bp)
                    320:        jle     repos
                    321:        movb    ROW, MM_EROW(bp)
                    322: /      jmp     scrollup
                    323: 
                    324: ////////
                    325: /
                    326: / scrollup - scroll display upwards
                    327: /
                    328: ////////
                    329: 
                    330: scrollup:
                    331:        push    ds
                    332:        push    si
                    333:        push    cx
                    334:        mov     ds, MM_BASE(bp)
                    335:        movb    bl, MM_BROW(bp)
                    336:        shlb    bl, $1
                    337:        mov     di, cs:rowtab(bx)
                    338:        mov     si, cs:rowtab+2(bx)
                    339:        movb    bl, ROW
                    340:        shlb    bl, $1
                    341:        mov     cx, cs:rowtab(bx)
                    342:        push    cx
                    343:        sub     cx, di
                    344:        shr     cx, $1
                    345:        push    si
                    346:        push    di
                    347:        push    cx
                    348:        rep
                    349:        movsw
                    350:        pop     cx
                    351:        pop     di
                    352:        pop     si
                    353:        add     si, $BANKSZ
                    354:        add     di, $BANKSZ
                    355:        rep
                    356:        movsw
                    357:        mov     ax, MM_FLIP(bp)
                    358:        and     ax, MM_MASK(bp)
                    359:        pop     di
                    360:        push    di
                    361:        mov     cx, $NRB4
                    362:        rep
                    363:        stosw
                    364:        pop     di
                    365:        add     di, $BANKSZ
                    366:        mov     cx, $NRB4
                    367:        rep
                    368:        stosw
                    369:        pop     cx
                    370:        pop     si
                    371:        pop     ds
                    372:        jmp     ewait
                    373: 
                    374: ////////
                    375: /
                    376: / repos - reposition cursor
                    377: /
                    378: ////////
                    379: 
                    380: repos: movb    bl, ROW                 / reposition to ROW and COL
                    381:        shlb    bl, $1
                    382:        mov     POS, cs:rowtab(bx)
                    383:        movb    bl, COL
                    384:        cmpb    MM_NCOL(bp), $40
                    385:        jne     0f
                    386:        shlb    bl, $1
                    387: 0:     add     POS, bx
                    388: /      jmp     eval
                    389: 
                    390: ////////
                    391: /
                    392: / eval - evaluate input character
                    393: /
                    394: ////////
                    395: 
                    396: eval:  jcxz    ewait0
                    397:        dec     cx                              / evaluate next char
                    398:        lodsb
                    399:        movb    bl, al
                    400:        shlb    bl, $1
                    401:        ijmp    cs:asctab(bx)
                    402: 
                    403: ewait0:        call    exit
                    404:        jcxz    0b
                    405:        dec     cx
                    406:        lodsb
                    407:        movb    bl, al
                    408:        shlb    bl, $1
                    409:        ijmp    cs:asctab(bx)
                    410: 
                    411: ////////
                    412: /
                    413: / mmputc - put character on screen
                    414: /
                    415: ////////
                    416: 
                    417: mmputc:        cmpb    MM_NCOL(bp), $40
                    418:        jne     putc8
                    419: 
                    420: 
                    421: putc16:        push    ds
                    422:        push    si
                    423:        subb    ah, ah
                    424:        shlb    al, $1
                    425:        shl     ax, $1
                    426:        shl     ax, $1
                    427:        shl     ax, $1
                    428:        add     ax, $fontw_
                    429:        mov     si, ax
                    430:        mov     ax, cs
                    431:        mov     ds, ax
                    432:        mov     bx, $BANKSZ-2
                    433: 
                    434:        lodsw                           / row 0
                    435:        xor     ax, MM_FLIP(bp)
                    436:        and     ax, MM_MASK(bp)
                    437:        stosw
                    438:        push    di                      / save position for next char
                    439: #ifdef TECMAR
                    440:        mov     es:(bx,di), ax
                    441:        add     di, $78
                    442: #endif
                    443:        lodsw                           / row 1
                    444:        xor     ax, MM_FLIP(bp)
                    445:        and     ax, MM_MASK(bp)
                    446: #ifdef TECMAR
                    447:        stosw
                    448: #endif
                    449:        mov     es:(bx,di), ax
                    450:        add     di, $78
                    451: 
                    452:        lodsw                           / row 2
                    453:        xor     ax, MM_FLIP(bp)
                    454:        and     ax, MM_MASK(bp)
                    455:        stosw
                    456: #ifdef TECMAR
                    457:        mov     es:(bx,di), ax
                    458:        add     di, $78
                    459: #endif
                    460: 
                    461:        lodsw                           / row 3
                    462:        xor     ax, MM_FLIP(bp)
                    463:        and     ax, MM_MASK(bp)
                    464: #ifdef TECMAR
                    465:        stosw
                    466: #endif
                    467:        mov     es:(bx,di), ax
                    468:        add     di, $78
                    469: 
                    470:        lodsw                           / row 4
                    471:        xor     ax, MM_FLIP(bp)
                    472:        and     ax, MM_MASK(bp)
                    473:        stosw
                    474: #ifdef TECMAR
                    475:        mov     es:(bx,di), ax
                    476:        add     di, $78
                    477: #endif
                    478: 
                    479:        lodsw                           / row 5
                    480:        xor     ax, MM_FLIP(bp)
                    481:        and     ax, MM_MASK(bp)
                    482: #ifdef TECMAR
                    483:        stosw
                    484: #endif
                    485:        mov     es:(bx,di), ax
                    486:        add     di, $78
                    487: 
                    488:        lodsw                           / row 6
                    489:        xor     ax, MM_FLIP(bp)
                    490:        and     ax, MM_MASK(bp)
                    491:        stosw
                    492: #ifdef TECMAR
                    493:        mov     es:(bx,di), ax
                    494:        add     di, $78
                    495: #endif
                    496:        lodsw                           / row 7
                    497:        or      ax, MM_ULINE(bp)
                    498:        xor     ax, MM_FLIP(bp)
                    499:        and     ax, MM_MASK(bp)
                    500: #ifdef TECMAR
                    501:        stosw
                    502: #endif
                    503:        mov     es:(bx,di), ax
                    504: 
                    505: 
                    506:        pop     di                      / restore position for next char
                    507:        pop     si
                    508:        pop     ds
                    509: 
                    510:        sub     bx, bx
                    511:        incb    COL
                    512:        cmpb    COL, MM_NCOL(bp)
                    513:        jge     0f
                    514:        jcxz    ewait1
                    515:        dec     cx
                    516:        lodsb
                    517:        movb    bl, al
                    518:        shlb    bl, $1
                    519:        ijmp    cs:asctab(bx)
                    520: 
                    521: 0:     subb    COL, COL
                    522:        incb    ROW
                    523:        cmpb    ROW, MM_EROW(bp)
                    524:        jg      0f
                    525:        jmp     repos
                    526: 
                    527: 0:     movb    ROW, MM_EROW(bp)
                    528:        jmp     scrollup
                    529: 
                    530: ewait1:        jmp     ewait
                    531: 
                    532: putc8: push    ds
                    533:        push    si
                    534:        subb    ah, ah
                    535:        shlb    al, $1
                    536:        shl     ax, $1
                    537:        shl     ax, $1
                    538:        add     ax, $0xFA6E
                    539:        mov     si, ax
                    540:        mov     ax, $0xF000
                    541:        mov     ds, ax
                    542:        mov     bx, $BANKSZ-1
                    543: 
                    544:        lodsw
                    545:        xor     ax, MM_FLIP(bp)
                    546:        stosb                           / row 0
                    547:        push    di                      / save position for next char
                    548: #ifdef TECMAR
                    549:        movb    es:(bx,di), al
                    550:        movb    es:79(di), ah           / row 1
                    551:        movb    es:80(bx,di), ah
                    552:        add     di, $79+80
                    553: #else
                    554:        movb    es:(bx,di), ah          / row 1
                    555:        add     di, $79
                    556: #endif
                    557: 
                    558:        lodsw
                    559:        xor     ax, MM_FLIP(bp)
                    560:        stosb                           / row 2
                    561: #ifdef TECMAR
                    562:        movb    es:(bx,di), al
                    563:        movb    es:79(di), ah
                    564:        movb    es:80(bx,di), ah        / row 3
                    565:        add     di, $79+80
                    566: #else
                    567:        movb    es:(bx,di), ah          / row 3
                    568:        add     di, $79
                    569: #endif
                    570: 
                    571:        lodsw
                    572:        xor     ax, MM_FLIP(bp)
                    573:        stosb                           / row 4
                    574: #ifdef TECMAR
                    575:        movb    es:(bx,di), al
                    576:        movb    es:79(di), ah           / row 5
                    577:        movb    es:80(bx,di), ah
                    578:        add     di, $79+80
                    579: #else
                    580:        movb    es:(bx,di), ah          / row 5
                    581:        add     di, $79
                    582: #endif
                    583: 
                    584:        lodsw
                    585:        orb     ah, MM_ULINE(bp)
                    586:        xor     ax, MM_FLIP(bp)
                    587:        stosb                           / row 6
                    588: #ifdef TECMAR
                    589:        movb    es:(bx,di), al
                    590:        movb    es:79(di), ah
                    591:        movb    es:80(bx,di), ah
                    592: #else
                    593:        movb    es:(bx,di), ah          / row 7
                    594: #endif
                    595: 
                    596:        pop     di                      / restore position for next char
                    597:        pop     si
                    598:        pop     ds
                    599: 
                    600:        sub     bx, bx
                    601:        incb    COL
                    602:        cmpb    COL, MM_NCOL(bp)
                    603:        jge     0f
                    604:        jcxz    ewait
                    605:        dec     cx
                    606:        lodsb
                    607:        movb    bl, al
                    608:        shlb    bl, $1
                    609:        ijmp    cs:asctab(bx)
                    610: 
                    611: 0:     subb    COL, COL
                    612:        incb    ROW
                    613:        cmpb    ROW, MM_EROW(bp)
                    614:        jg      0f
                    615:        jmp     repos
                    616: 
                    617: 0:     movb    ROW, MM_EROW(bp)
                    618:        jmp     scrollup
                    619: 
                    620: ////////
                    621: /
                    622: / Ewait - wait for next input char to evaluate
                    623: /
                    624: ////////
                    625: 
                    626: ewait: call    exit
                    627:        jcxz    ewait
                    628:        dec     cx
                    629:        lodsb
                    630:        movb    bl, al
                    631:        shlb    bl, $1
                    632:        ijmp    cs:asctab(bx)
                    633: 
                    634: ////////
                    635: /
                    636: / mm_cr - carriage return
                    637: /
                    638: /      Moves the active position to first position of current display line.
                    639: /
                    640: ////////
                    641: 
                    642: mm_cr: subb    COL, COL
                    643:        movb    bl, ROW
                    644:        shlb    bl, $1
                    645:        mov     POS, cs:rowtab(bx)
                    646:        jcxz    ewait
                    647:        dec     cx
                    648:        lodsb
                    649:        movb    bl, al
                    650:        shlb    bl, $1
                    651:        ijmp    cs:asctab(bx)
                    652: 
                    653: ////////
                    654: /
                    655: / mm_cub - cursor backwards
                    656: /
                    657: ////////
                    658: 
                    659: mm_cub:        decb    COL
                    660:        jge     0f
                    661:        movb    COL, MM_NCOL(bp)
                    662:        decb    COL
                    663:        decb    ROW
                    664:        cmpb    ROW, MM_BROW(bp)
                    665:        jge     0f
                    666:        subb    COL, COL
                    667:        movb    ROW, MM_BROW(bp)
                    668: 0:     jmp     repos
                    669: 
                    670: ////////
                    671: /
                    672: / Esc state - entered when last char was ESC - transient state.
                    673: /
                    674: ////////
                    675: 
                    676: 0:     call    exit
                    677: mm_esc:        jcxz    0b
                    678:        dec     cx
                    679:        lodsb
                    680:        movb    MM_N1(bp), ZERO
                    681:        movb    MM_N2(bp), ZERO
                    682:        movb    bl, al
                    683:        shlb    bl, $1
                    684:        ijmp    cs:esctab(bx)
                    685: 
                    686: ////////
                    687: /
                    688: / Csi_n1 state - entered when last two chars were ESC [
                    689: /
                    690: /      Action: Evaluates numeric chars as numeric parameter 1.
                    691: /
                    692: ////////
                    693: 
                    694: 0:     call    exit
                    695: csi_n1:        jcxz    0b
                    696:        dec     cx
                    697:        lodsb
                    698:        cmpb    al, $SEMIC
                    699:        je      csi_n2
                    700:        movb    bl, al
                    701:        subb    bl, $AZERO
                    702:        cmpb    bl, $9
                    703:        ja      csival
                    704:        shlb    MM_N1(bp), $1   / n1 * 2
                    705:        movb    al, MM_N1(bp)   / n1 * 2
                    706:        shlb    al, $1          / n1 * 4
                    707:        shlb    al, $1          / n1 * 8
                    708:        addb    al, MM_N1(bp)   / n1 * 10
                    709:        addb    al, bl          / n1 * 10 + digit
                    710:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
                    711:        jmp     csi_n1
                    712: 
                    713: ////////
                    714: /
                    715: / Csi_n2 state - entered after input sequence ESC [ n ;
                    716: /
                    717: ////////
                    718: 
                    719: 0:     call    exit
                    720: csi_n2:        jcxz    0b
                    721:        dec     cx
                    722:        lodsb
                    723:        movb    bl, al
                    724:        subb    bl, $AZERO
                    725:        cmpb    bl, $9
                    726:        ja      csival
                    727:        shlb    MM_N2(bp), $1   / n2 * 2
                    728:        movb    al, MM_N2(bp)   / n2 * 2
                    729:        shlb    al, $1          / n2 * 4
                    730:        shlb    al, $1          / n2 * 8
                    731:        addb    al, MM_N2(bp)   / n2 * 10
                    732:        addb    al, bl          / n2 * 10 + digit
                    733:        movb    MM_N2(bp), al   / n2 = (n2 * 10) + digit
                    734:        jmp     csi_n2
                    735: 
                    736: csival:        movb    bl, al
                    737:        shlb    bl, $1
                    738:        ijmp    cs:csitab(bx)
                    739: 
                    740: ////////
                    741: /
                    742: / Csi_gt state - entered after input sequence ESC [ >
                    743: /      
                    744: ////////
                    745: 
                    746: 0:     call    exit
                    747: csi_gt:        jcxz    0b
                    748:        dec     cx
                    749:        lodsb
                    750:        movb    bl, al
                    751:        subb    bl, $AZERO
                    752:        cmpb    bl, $9
                    753:        ja      0f
                    754:        shlb    MM_N1(bp), $1   / n1 * 2
                    755:        movb    al, MM_N1(bp)   / n1 * 2
                    756:        shlb    al, $1          / n1 * 4
                    757:        shlb    al, $1          / n1 * 8
                    758:        addb    al, MM_N1(bp)   / n1 * 10
                    759:        addb    al, bl          / n1 * 10 + digit
                    760:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
                    761:        jmp     csi_gt
                    762: 
                    763: 0:     cmpb    al, $HLOWER
                    764:        je      mm_cgh
                    765:        cmpb    al, $LLOWER
                    766:        je      mm_cgl
                    767:        jmp     eval
                    768: 
                    769: ////////
                    770: /
                    771: / Csi_q state - entered after input sequence ESC [ ?
                    772: /      
                    773: ////////
                    774: 
                    775: 0:     call    exit
                    776: csi_q: jcxz    0b
                    777:        dec     cx
                    778:        lodsb
                    779:        movb    bl, al
                    780:        subb    bl, $AZERO
                    781:        cmpb    bl, $9
                    782:        ja      0f
                    783:        shlb    MM_N1(bp), $1   / n1 * 2
                    784:        movb    al, MM_N1(bp)   / n1 * 2
                    785:        shlb    al, $1          / n1 * 4
                    786:        shlb    al, $1          / n1 * 8
                    787:        addb    al, MM_N1(bp)   / n1 * 10
                    788:        addb    al, bl          / n1 * 10 + digit
                    789:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
                    790:        jmp     csi_q
                    791: 
                    792: 0:     cmpb    al, $HLOWER
                    793:        je      mm_cqh
                    794:        cmpb    al, $LLOWER
                    795:        je      mm_cql
                    796:        jmp     eval
                    797: 
                    798: ////////
                    799: /
                    800: / mm_cbt - cursor backward tabulation
                    801: /
                    802: /      Moves the active position horizontally in the backward direction
                    803: /      to the preceding in a series of predetermined positions.
                    804: /
                    805: ////////
                    806: 
                    807: mm_cbt:        orb     COL, $7                 / calculate next tab stop
                    808:        incb    COL
                    809:        subb    COL, $16                / step back two tab positions
                    810:        jg      0f
                    811:        subb    COL, COL                / cannot step past column 0
                    812: 0:     jmp     repos                   / reposition cursor
                    813: 
                    814: ////////
                    815: /
                    816: / mm_cgh - process ESC [ > N1 h escape sequence
                    817: /
                    818: /      Recognized sequences:   ESC [ > 13 h    -- Set CRT saver enabled.
                    819: /
                    820: ////////
                    821: 
                    822: mm_cgh:        cmpb    MM_N1(bp), $13
                    823:        jne     0f
                    824:        mov     ss:mmcrtsav_, $1
                    825: 0:     jmp     eval
                    826: 
                    827: ////////
                    828: /
                    829: / mm_cgl - process ESC [ > N1 l escape sequence
                    830: /
                    831: /      Recognized sequences:   ESC [ > 13 l    -- Reset CRT saver.
                    832: /
                    833: ////////
                    834: 
                    835: mm_cgl:        cmpb    MM_N1(bp), $13
                    836:        jne     0f
                    837:        mov     ss:mmcrtsav_, $0
                    838: 0:     jmp     eval
                    839: 
                    840: ////////
                    841: /
                    842: / mm_cha - cursor horizontal absolute
                    843: /
                    844: /      Advances the active position forward or backward along the active line
                    845: /      to the character position specified by the parameter.
                    846: /      A parameter value of zero or one moves the active position to the
                    847: /      first character position of the active line.
                    848: /      A parameter value of N moves the active position to character position
                    849: /      N of the active line.
                    850: /
                    851: ////////
                    852: 
                    853: mm_cha:        movb    COL, MM_N1(bp)
                    854:        decb    COL
                    855:        jge     0f
                    856:        subb    COL, COL
                    857: 0:     cmpb    COL, MM_NCOL(bp)
                    858:        jb      0f
                    859:        movb    COL, MM_NCOL(bp)
                    860:        decb    COL
                    861: 0:     jmp     repos                   / reposition cursor
                    862: 
                    863: 
                    864: ////////
                    865: /
                    866: / mm_cht - cursor horizontal tabulation
                    867: /
                    868: /      Advances the active position horizontally to the next or following
                    869: /      in a series of predetermined positions.
                    870: /
                    871: ////////
                    872: 
                    873: mm_cht:        mov     bx, $BANKSZ
                    874:        push    cx
                    875:        push    si
                    876:        sub     cx, cx
                    877:        movb    cl, COL
                    878:        orb     cl, $7
                    879:        incb    cl
                    880:        subb    cl, COL
                    881:        addb    COL, cl
                    882: 
                    883:        mov     si, MM_MASK(bp)
                    884:        cmpb    MM_NCOL(bp), $80
                    885:        jne     0f
                    886:        mov     si, $-1
                    887:        inc     cx
                    888:        shr     cx, $1
                    889: 
                    890: 0:     mov     ax, MM_FLIP(bp)
                    891:        and     ax, si
                    892: #ifdef TECMAR
                    893:        stosw                           / row 0
                    894:        mov     es:[NHB*0]-2(di,bx), ax
                    895:        mov     es:[NHB*1]-2(di), ax    / row 1
                    896:        mov     es:[NHB*1]-2(di,bx), ax
                    897:        mov     es:[NHB*2]-2(di), ax    / row 2
                    898:        mov     es:[NHB*2]-2(di,bx), ax
                    899:        mov     es:[NHB*3]-2(di), ax    / row 3
                    900:        mov     es:[NHB*3]-2(di,bx), ax
                    901:        mov     es:[NHB*4]-2(di), ax    / row 4
                    902:        mov     es:[NHB*4]-2(di,bx), ax
                    903:        mov     es:[NHB*5]-2(di), ax    / row 5
                    904:        mov     es:[NHB*5]-2(di,bx), ax
                    905:        mov     es:[NHB*6]-2(di), ax    / row 6
                    906:        mov     es:[NHB*6]-2(di,bx), ax
                    907:        or      ax, MM_ULINE(bp)
                    908:        and     ax, si
                    909:        mov     es:[NHB*7]-2(di), ax    / row 7
                    910:        mov     es:[NHB*7]-2(di,bx), ax
                    911: #else
                    912:        stosw                           / row 0
                    913:        mov     es:[NHB*0]-2(di,bx), ax / row 1
                    914:        mov     es:[NHB*1]-2(di), ax    / row 2
                    915:        mov     es:[NHB*1]-2(di,bx), ax / row 3
                    916:        mov     es:[NHB*2]-2(di), ax    / row 4
                    917:        mov     es:[NHB*2]-2(di,bx), ax / row 5
                    918:        mov     es:[NHB*3]-2(di), ax    / row 6
                    919:        or      ax, MM_ULINE(bp)
                    920:        and     ax, si
                    921:        mov     es:[NHB*3]-2(di,bx), ax / row 7
                    922: #endif
                    923:        loop    0b
                    924:        sub     bx, bx
                    925:        pop     si
                    926:        pop     cx
                    927:        cmpb    COL, MM_NCOL(bp)
                    928:        jl      0f
                    929:        subb    COL, MM_NCOL(bp)
                    930:        incb    ROW
                    931:        cmpb    ROW, MM_EROW(bp)
                    932:        jle     0f
                    933:        movb    ROW, MM_EROW(bp)
                    934:        jmp     scrollup
                    935: 0:     jmp     repos
                    936: 
                    937: ////////
                    938: /
                    939: / mm_cpl - cursor preceding line
                    940: /
                    941: /      Moves the active position to the first position of the preceding
                    942: /      display line.
                    943: /
                    944: ////////
                    945: 
                    946: mm_cpl:        subb    COL, COL
                    947:        decb    ROW
                    948:        cmpb    ROW, MM_BROW(bp)
                    949:        jnb     0f
                    950:        movb    ROW, MM_BROW(bp)
                    951:        jmp     scrolldown
                    952: 0:     jmp     repos                   / reposition cursor
                    953: 
                    954: ////////
                    955: /
                    956: / mm_cqh - process ESC [ ? N1 h escape sequence
                    957: /
                    958: /      Recognized sequences:   ESC [ ? 7 h     -- Set wraparound.
                    959: /
                    960: ////////
                    961: 
                    962: mm_cqh:
                    963:        cmpb    MM_N1(bp), $7           / Wraparound.
                    964:        jne     0f
                    965:        movb    MM_WRAP(bp), $1
                    966: 0:     jmp     eval
                    967: 
                    968: ////////
                    969: /
                    970: / mm_cql - process ESC [ ? N1 l escape sequence
                    971: /
                    972: /      Recognized sequences:   ESC [ ? 7 l     -- Reset wraparound.
                    973: /
                    974: ////////
                    975: 
                    976: mm_cql:
                    977:        cmpb    MM_N1(bp), $7           / No wraparound.
                    978:        jne     0f
                    979:        movb    MM_WRAP(bp), $0
                    980: 0:     jmp     eval
                    981: 
                    982: ////////
                    983: /
                    984: / mm_cud - cursor down
                    985: /
                    986: /      Moves the active position downward without altering the
                    987: /      horizontal position.
                    988: /
                    989: ////////
                    990: 
                    991: mm_cud:        incb    ROW
                    992:        cmpb    ROW, MM_EROW(bp)
                    993:        jna     0f
                    994:        movb    ROW, MM_EROW(bp)
                    995: 0:     jmp     repos                   / reposition cursor
                    996: 
                    997: ////////
                    998: /
                    999: / mm_cuf - cursor forward
                   1000: /
                   1001: /      Moves the active position in the forward direction.
                   1002: /
                   1003: ////////
                   1004: 
                   1005: mm_cuf:        incb    COL
                   1006:        cmpb    COL, MM_NCOL(bp)
                   1007:        jb      0f
                   1008:        subb    COL, MM_NCOL(bp)
                   1009:        incb    ROW
                   1010:        cmpb    ROW, MM_EROW(bp)
                   1011:        jna     0f
                   1012:        movb    ROW, MM_EROW(bp)
                   1013:        movb    COL, MM_NCOL(bp)
                   1014:        decb    COL
                   1015: 0:     jmp     repos
                   1016: 
                   1017: ////////
                   1018: /
                   1019: / mm_cup - cursor position
                   1020: /
                   1021: /      Moves the active position to the position specified by two parameters.
                   1022: /      The first parameter (mm_n1) specifies the vertical position (MM_ROW(bp)).
                   1023: /      The second parameter (mm_n2) specifies the horizontal position (MM_COL(bp)).
                   1024: /      A parameter value of 0 or 1 for the first or second parameter
                   1025: /      moves the active position to the first line or column in the
                   1026: /      display respectively.
                   1027: /
                   1028: ////////
                   1029: 
                   1030: mm_cup:        movb    ROW, MM_N1(bp)
                   1031:        decb    ROW
                   1032:        jg      0f
                   1033:        subb    ROW, ROW
                   1034: 0:     addb    ROW, MM_BROW(bp)
                   1035:        cmpb    ROW, MM_EROW(bp)
                   1036:        jb      0f
                   1037:        movb    ROW, MM_EROW(bp)
                   1038: 0:     movb    COL, MM_N2(bp)
                   1039:        decb    COL
                   1040:        jg      0f
                   1041:        subb    COL, COL
                   1042: 0:     cmpb    COL, MM_NCOL(bp)
                   1043:        jb      0f
                   1044:        movb    COL, MM_NCOL(bp)
                   1045:        decb    COL
                   1046: 0:     jmp     repos                   / reposition cursor
                   1047: 
                   1048: ////////
                   1049: /
                   1050: / mm_cuu - cursor up
                   1051: /
                   1052: /      Moves the active position upward without altering the horizontal
                   1053: /      position.
                   1054: /
                   1055: ////////
                   1056: 
                   1057: mm_cuu:        decb    ROW
                   1058:        cmpb    ROW, MM_BROW(bp)
                   1059:        jge     0f
                   1060:        movb    ROW, MM_BROW(bp)
                   1061: 0:     jmp     repos                   / reposition cursor
                   1062: 
                   1063: ////////
                   1064: /
                   1065: / mm_dl - delete line
                   1066: /
                   1067: /      Removes the contents of the active line.
                   1068: /      The contents of all following lines are shifted in a block
                   1069: /      toward the active line.
                   1070: /
                   1071: ////////
                   1072: 
                   1073: mm_dl: push    ds
                   1074:        push    si
                   1075:        push    cx
                   1076:        mov     ds, MM_BASE(bp)
                   1077:        movb    bl, ROW
                   1078:        shlb    bl, $1
                   1079:        mov     di, cs:rowtab(bx)
                   1080:        mov     si, cs:rowtab+2(bx)
                   1081:        movb    bl, MM_EROW(bp)
                   1082:        shlb    bl, $1
                   1083:        mov     cx, cs:rowtab(bx)
                   1084:        sub     cx, di
                   1085:        jle     0f
                   1086:        shr     cx, $1
                   1087:        push    si
                   1088:        push    di
                   1089:        push    cx
                   1090:        rep
                   1091:        movsw
                   1092:        pop     cx
                   1093:        pop     di
                   1094:        pop     si
                   1095:        add     si, $BANKSZ
                   1096:        add     di, $BANKSZ
                   1097:        rep
                   1098:        movsw
                   1099:        mov     di, cs:rowtab(bx)
                   1100:        push    di
                   1101:        mov     cx, $NRB4
                   1102:        mov     ax, MM_FLIP(bp)
                   1103:        and     ax, MM_MASK(bp)
                   1104:        rep
                   1105:        stosw
                   1106:        pop     di
                   1107:        add     di, $BANKSZ
                   1108:        mov     cx, $NRB4
                   1109:        rep
                   1110:        stosw
                   1111:        subb    COL, COL
                   1112: 0:     pop     cx
                   1113:        pop     si
                   1114:        pop     ds
                   1115:        jmp     repos
                   1116: 
                   1117: ////////
                   1118: /
                   1119: / mm_dmi - disable manual input
                   1120: /
                   1121: /      Set flag preventing keyboard input.
                   1122: /
                   1123: ////////
                   1124: 
                   1125: mm_dmi:
                   1126:        mov     ss:islock_, $1
                   1127:        jmp     eval
                   1128: 
                   1129: ////////
                   1130: /
                   1131: / mm_ea - erase in area
                   1132: /
                   1133: /      Erase some or all of the characters in the currently active area
                   1134: /      according to the parameter:
                   1135: /              0 - erase from active position to end inclusive (default)
                   1136: /              1 - erase from start to active position inclusive
                   1137: /              2 - erase all of active area
                   1138: /
                   1139: ////////
                   1140: 
                   1141: mm_ea: movb    al, MM_N1(bp)
                   1142:        cmpb    al, $0
                   1143:        jne     0f
                   1144:        movb    bl, MM_EROW(bp)
                   1145:        jmp     mm_e0
                   1146: 0:     cmpb    al, $1
                   1147:        jne     0f
                   1148:        movb    bl, MM_BROW(bp)
                   1149:        jmp     mm_e1
                   1150: 0:     subb    COL, COL
                   1151:        movb    ROW, MM_BROW(bp)
                   1152:        movb    bl, ROW
                   1153:        shlb    bl, $1
                   1154:        mov     POS, cs:rowtab(bx)
                   1155:        movb    bl, MM_EROW(bp)
                   1156:        subb    bl, ROW
                   1157:        jmp     mm_e2
                   1158: 
                   1159: ////////
                   1160: /
                   1161: / mm_ed - erase in display
                   1162: /
                   1163: /      Erase some or all of the characters in the display according to the
                   1164: /      parameter
                   1165: /              0 - erase from active position to end inclusive (default)
                   1166: /              1 - erase from start to active position inclusive
                   1167: /              2 - erase all of display
                   1168: /
                   1169: ////////
                   1170: 
                   1171: mm_ed: movb    al, MM_N1(bp)
                   1172:        cmpb    al, $0
                   1173:        jne     0f
                   1174:        movb    bl, MM_LROW(bp)
                   1175:        jmp     mm_e0
                   1176: 0:     cmpb    al, $1
                   1177:        jne     0f
                   1178:        subb    bl, bl
                   1179:        jmp     mm_e1
                   1180: 0:     subb    COL, COL
                   1181:        movb    ROW, MM_BROW(bp)
                   1182:        sub     POS, POS
                   1183:        movb    bl, MM_LROW(bp)
                   1184:        jmp     mm_e2
                   1185: 
                   1186: ////////
                   1187: /
                   1188: / mm_el - erase in line
                   1189: /
                   1190: /      Erase some or all of the characters in the line according to the
                   1191: /      parameter:
                   1192: /              0 - erase from active position to end inclusive (default)
                   1193: /              1 - erase from start to active position inclusive
                   1194: /              2 - erase entire line
                   1195: /
                   1196: ////////
                   1197: 
                   1198: mm_el: movb    al, MM_N1(bp)
                   1199:        movb    bl, ROW
                   1200:        cmpb    al, $0
                   1201:        je      mm_e0
                   1202:        cmpb    al, $1
                   1203:        je      mm_e1
                   1204:        shlb    bl, $1
                   1205:        mov     POS, cs:rowtab(bx)
                   1206:        subb    COL, COL
                   1207:        subb    bl, bl
                   1208: /      jmp     mm_e2
                   1209: 
                   1210: ////////
                   1211: /
                   1212: / mm_e2 - erase from POS for BL rows (minimum 1 row)
                   1213: /
                   1214: ////////
                   1215: 
                   1216: mm_e2: push    cx
                   1217:        mov     ax, MM_FLIP(bp)
                   1218:        and     ax, MM_MASK(bp)
                   1219: 0:     mov     cx, $NRB4
                   1220:        rep
                   1221:        stosw
                   1222:        add     di, $BANKSZ-NRB2
                   1223:        mov     cx, $NRB4
                   1224:        rep
                   1225:        stosw
                   1226:        sub     di, $BANKSZ
                   1227:        decb    bl
                   1228:        jge     0b
                   1229:        pop     cx
                   1230:        jmp     repos
                   1231: 
                   1232: ////////
                   1233: /
                   1234: / mm_e1 - erase from row BL to current cursor position.
                   1235: /
                   1236: ////////
                   1237: 
                   1238: mm_e1: push    dx
                   1239:        push    cx
                   1240:        push    di
                   1241:        mov     ax, MM_FLIP(bp)
                   1242:        and     ax, MM_MASK(bp)
                   1243:        shlb    bl, $1
                   1244:        mov     di, cs:rowtab(bx)
                   1245:        movb    bl, ROW
                   1246:        shlb    bl, $1
                   1247:        mov     cx, cs:rowtab(bx)
                   1248:        sub     cx, di
                   1249:        jle     0f
                   1250:        shr     cx, $1
                   1251:        push    di
                   1252:        push    cx
                   1253:        rep
                   1254:        stosw
                   1255:        pop     cx
                   1256:        pop     di
                   1257:        add     di, $BANKSZ
                   1258:        rep
                   1259:        stosw
                   1260: 0:     pop     cx
                   1261:        movb    bl, ROW
                   1262:        shlb    bl, $1
                   1263:        mov     di, cs:rowtab(bx)
                   1264:        sub     cx, di
                   1265:        jle     0f
                   1266: 
                   1267:        mov     dx, di
                   1268:        mov     bx, cx
                   1269:        rep                     / erase row 0
                   1270:        stosb
                   1271:        add     dx, $80
                   1272:        mov     di, dx
                   1273:        mov     cx, bx
                   1274: #ifdef TECMAR
                   1275:        rep                     / erase row 1
                   1276:        stosb
                   1277:        add     dx, $80
                   1278:        mov     di, dx
                   1279:        mov     cx, bx
                   1280: #endif
                   1281:        rep                     / erase row 2
                   1282:        stosb
                   1283:        add     dx, $80
                   1284:        mov     di, dx
                   1285:        mov     cx, bx
                   1286: #ifdef TECMAR
                   1287:        rep                     / erase row 3
                   1288:        stosb
                   1289:        add     dx, $80
                   1290:        mov     di, dx
                   1291:        mov     cx, bx
                   1292: #endif
                   1293:        rep                     / erase row 4
                   1294:        stosb
                   1295:        add     dx, $80
                   1296:        mov     di, dx
                   1297:        mov     cx, bx
                   1298: #ifdef TECMAR
                   1299:        rep                     / erase row 5
                   1300:        stosb
                   1301:        add     dx, $80
                   1302:        mov     di, dx
                   1303:        mov     cx, bx
                   1304: #endif
                   1305:        rep                     / erase row 6
                   1306:        stosb
                   1307: #ifdef TECMAR
                   1308:        add     dx, $80
                   1309:        mov     di, dx
                   1310:        mov     cx, bx
                   1311:        rep                     / erase row 7
                   1312:        stosb
                   1313:        add     dx, $BANKSZ-560
                   1314: #else
                   1315:        add     dx, $BANKSZ-240
                   1316: #endif
                   1317:        mov     di, dx
                   1318:        mov     cx, bx
                   1319: #ifdef TECMAR
                   1320:        rep                     / erase row 0
                   1321:        stosb
                   1322:        add     dx, $80
                   1323:        mov     di, dx
                   1324:        mov     cx, bx
                   1325: #endif
                   1326:        rep                     / erase row 1
                   1327:        stosb
                   1328:        add     dx, $80
                   1329:        mov     di, dx
                   1330:        mov     cx, bx
                   1331: #ifdef TECMAR
                   1332:        rep                     / erase row 2
                   1333:        stosb
                   1334:        add     dx, $80
                   1335:        mov     di, dx
                   1336:        mov     cx, bx
                   1337: #endif
                   1338:        rep                     / erase row 3
                   1339:        stosb
                   1340:        add     dx, $80
                   1341:        mov     di, dx
                   1342:        mov     cx, bx
                   1343: #ifdef TECMAR
                   1344:        rep                     / erase row 4
                   1345:        stosb
                   1346:        add     dx, $80
                   1347:        mov     di, dx
                   1348:        mov     cx, bx
                   1349: #endif
                   1350:        rep                     / erase row 5
                   1351:        stosb
                   1352:        add     dx, $80
                   1353:        mov     di, dx
                   1354:        mov     cx, bx
                   1355: #ifdef TECMAR
                   1356:        rep                     / erase row 6
                   1357:        stosb
                   1358:        add     dx, $80
                   1359:        mov     di, dx
                   1360:        mov     cx, bx
                   1361: #endif
                   1362:        rep                     / erase row 7
                   1363:        stosb
                   1364: 1:     sub     bx, bx
                   1365:        pop     cx
                   1366:        pop     dx
                   1367:        jmp     repos
                   1368: 
                   1369: ////////
                   1370: /
                   1371: / mm_e0 - erase from current cursor position to row BL inclusive.
                   1372: /
                   1373: ////////
                   1374: 
                   1375: mm_e0: push    dx
                   1376:        push    cx
                   1377:        push    di
                   1378:        mov     ax, MM_FLIP(bp)
                   1379:        and     ax, MM_MASK(bp)
                   1380:        shlb    bl, $1
                   1381:        mov     cx, cs:rowtab+2(bx)
                   1382:        movb    bl, ROW
                   1383:        shlb    bl, $1
                   1384:        mov     di, cs:rowtab+2(bx)
                   1385:        sub     cx, di
                   1386:        jle     0f
                   1387:        shr     cx, $1
                   1388:        push    di
                   1389:        push    cx
                   1390:        rep
                   1391:        stosw
                   1392:        pop     cx
                   1393:        pop     di
                   1394:        add     di, $BANKSZ
                   1395:        rep
                   1396:        stosw
                   1397: 0:     pop     di
                   1398:        sub     cx, cx
                   1399:        movb    cl, MM_NCOL(bp)
                   1400:        subb    cl, COL
                   1401:        cmpb    MM_NCOL(bp), $40
                   1402:        jne     0f
                   1403:        shlb    cl, $1
                   1404: 0:     mov     dx, di
                   1405:        mov     bx, cx
                   1406:        rep                     / erase row 0
                   1407:        stosb
                   1408:        add     dx, $80
                   1409:        mov     di, dx
                   1410:        mov     cx, bx
                   1411: #ifdef TECMAR
                   1412:        rep                     / erase row 1
                   1413:        stosb
                   1414:        add     dx, $80
                   1415:        mov     di, dx
                   1416:        mov     cx, bx
                   1417: #endif
                   1418:        rep                     / erase row 2
                   1419:        stosb
                   1420:        add     dx, $80
                   1421:        mov     di, dx
                   1422:        mov     cx, bx
                   1423: #ifdef TECMAR
                   1424:        rep                     / erase row 3
                   1425:        stosb
                   1426:        add     dx, $80
                   1427:        mov     di, dx
                   1428:        mov     cx, bx
                   1429: #endif
                   1430:        rep                     / erase row 4
                   1431:        stosb
                   1432:        add     dx, $80
                   1433:        mov     di, dx
                   1434:        mov     cx, bx
                   1435: #ifdef TECMAR
                   1436:        rep                     / erase row 5
                   1437:        stosb
                   1438:        add     dx, $80
                   1439:        mov     di, dx
                   1440:        mov     cx, bx
                   1441: #endif
                   1442:        rep                     / erase row 6
                   1443:        stosb
                   1444: #ifdef TECMAR
                   1445:        add     dx, $80
                   1446:        mov     di, dx
                   1447:        mov     cx, bx
                   1448:        rep                     / erase row 7
                   1449:        stosb
                   1450:        add     dx, $BANKSZ-560
                   1451: #else
                   1452:        add     dx, $BANKSZ-240
                   1453: #endif
                   1454:        mov     di, dx
                   1455:        mov     cx, bx
                   1456: #ifdef TECMAR
                   1457:        rep                     / erase row 0
                   1458:        stosb
                   1459:        add     dx, $80
                   1460:        mov     di, dx
                   1461:        mov     cx, bx
                   1462: #endif
                   1463:        rep                     / erase row 1
                   1464:        stosb
                   1465:        add     dx, $80
                   1466:        mov     di, dx
                   1467:        mov     cx, bx
                   1468: #ifdef TECMAR
                   1469:        rep                     / erase row 2
                   1470:        stosb
                   1471:        add     dx, $80
                   1472:        mov     di, dx
                   1473:        mov     cx, bx
                   1474: #endif
                   1475:        rep                     / erase row 3
                   1476:        stosb
                   1477:        add     dx, $80
                   1478:        mov     di, dx
                   1479:        mov     cx, bx
                   1480: #ifdef TECMAR
                   1481:        rep                     / erase row 4
                   1482:        stosb
                   1483:        add     dx, $80
                   1484:        mov     di, dx
                   1485:        mov     cx, bx
                   1486: #endif
                   1487:        rep                     / erase row 5
                   1488:        stosb
                   1489:        add     dx, $80
                   1490:        mov     di, dx
                   1491:        mov     cx, bx
                   1492: #ifdef TECMAR
                   1493:        rep                     / erase row 6
                   1494:        stosb
                   1495:        add     dx, $80
                   1496:        mov     di, dx
                   1497:        mov     cx, bx
                   1498: #endif
                   1499:        rep                     / erase row 7
                   1500:        stosb
                   1501: 1:     sub     bx, bx
                   1502:        pop     cx
                   1503:        pop     dx
                   1504:        jmp     repos
                   1505: 
                   1506: ////////
                   1507: /
                   1508: / mm_emi - enable manual input
                   1509: /
                   1510: /      Clear flag preventing keyboard input.
                   1511: /
                   1512: ////////
                   1513: 
                   1514: mm_emi:
                   1515:        mov     ss:islock_, $0
                   1516:        jmp     eval
                   1517: 
                   1518: ////////
                   1519: /
                   1520: / mm_il - insert line
                   1521: /
                   1522: /      Insert a erased line at the active line by shifting the contents
                   1523: /      of the active line and all following lines away from the active line.
                   1524: /      The contents of the last line in the scrolling region are removed.
                   1525: /
                   1526: ////////
                   1527: 
                   1528: scrolldown:
                   1529: mm_il: push    ds
                   1530:        push    si
                   1531:        push    cx
                   1532:        mov     ds, MM_BASE(bp)
                   1533:        movb    bl, MM_EROW(bp)
                   1534:        shlb    bl, $1
                   1535:        mov     si, cs:rowtab(bx)
                   1536:        mov     cx, si
                   1537:        sub     si, $2
                   1538:        mov     di, cs:rowtab+2(bx)
                   1539:        sub     di, $2
                   1540:        movb    bl, ROW
                   1541:        shlb    bl, $1
                   1542:        sub     cx, cs:rowtab(bx)
                   1543:        jle     0f
                   1544:        shr     cx, $1
                   1545:        push    si
                   1546:        push    di
                   1547:        push    cx
                   1548:        std
                   1549:        rep
                   1550:        movsw
                   1551:        pop     cx
                   1552:        pop     di
                   1553:        pop     si
                   1554:        add     si, $BANKSZ
                   1555:        add     di, $BANKSZ
                   1556:        rep
                   1557:        movsw
                   1558:        mov     di, cs:rowtab(bx)
                   1559:        push    di
                   1560:        mov     cx, $NRB4
                   1561:        mov     ax, MM_FLIP(bp)
                   1562:        and     ax, MM_MASK(bp)
                   1563:        cld
                   1564:        rep
                   1565:        stosw
                   1566:        pop     di
                   1567:        add     di, $BANKSZ
                   1568:        mov     cx, $NRB4
                   1569:        rep
                   1570:        stosw
                   1571:        subb    COL, COL
                   1572: 0:     pop     cx
                   1573:        pop     si
                   1574:        pop     ds
                   1575:        jmp     repos
                   1576: 
                   1577: ////////
                   1578: /
                   1579: / mm_hpa - horizontal position absolute
                   1580: /
                   1581: /      Moves the active position within the active line to the position
                   1582: /      specified by the parameter.  A parameter value of zero or one
                   1583: /      moves the active position to the first position of the active line.
                   1584: /
                   1585: ////////
                   1586: 
                   1587: mm_hpa:        movb    COL, MM_N1(bp)
                   1588:        decb    COL
                   1589:        jg      0f
                   1590:        subb    COL, COL
                   1591: 0:     cmpb    COL, MM_NCOL(bp)
                   1592:        jb      0f
                   1593:        movb    COL, MM_NCOL(bp)
                   1594:        decb    COL
                   1595: 0:     jmp     repos                   / reposition cursor
                   1596: 
                   1597: ////////
                   1598: /
                   1599: / mm_hpr - horizontal position relative
                   1600: /
                   1601: /      Moves the active position forward the number of positions specified
                   1602: /      by the parameter.  A parameter value of zero or one indicates a
                   1603: /      single-position move.
                   1604: /
                   1605: ////////
                   1606: 
                   1607: mm_hpr:        movb    al, MM_N1(bp)
                   1608:        orb     al, al
                   1609:        jne     0f
                   1610:        incb    al
                   1611: 0:     addb    COL, al
                   1612:        cmpb    COL, MM_NCOL(bp)
                   1613:        jb      0f
                   1614:        movb    COL, MM_NCOL(bp)
                   1615:        decb    COL
                   1616: 0:     jmp     repos                   / reposition cursor
                   1617: 
                   1618: ////////
                   1619: /
                   1620: / mm_hvp - horizontal and vertical position
                   1621: /
                   1622: /      Moves the active position to the position specified by two parameters.
                   1623: /      The first parameter specifies the vertical position (MM_ROW(bp)).
                   1624: /      The second parameter specifies the horizontal position (MM_COL(bp)).
                   1625: /      A parameter value of zero or one moves the active position to the
                   1626: /      first line or column in the display.
                   1627: /
                   1628: ////////
                   1629: 
                   1630: mm_hvp:        movb    ROW, MM_N1(bp)
                   1631:        decb    ROW
                   1632:        jg      0f
                   1633:        subb    ROW, ROW
                   1634: 0:     cmpb    ROW, MM_LROW(bp)
                   1635:        jna     0f
                   1636:        movb    ROW, MM_LROW(bp)
                   1637: 0:     movb    COL, MM_N2(bp)
                   1638:        decb    COL
                   1639:        jg      0f
                   1640:        subb    COL, COL
                   1641: 0:     cmpb    COL, MM_NCOL(bp)
                   1642:        jb      0f
                   1643:        movb    COL, MM_NCOL(bp)
                   1644:        decb    COL
                   1645: 0:     jmp     repos                   / reposition cursor
                   1646: 
                   1647: ////////
                   1648: /
                   1649: / mm_ind - index
                   1650: /
                   1651: /      Causes the active position to move downward one line without changing
                   1652: /      the horizontal position.  Scrolling occurs if below scrolling region.
                   1653: /
                   1654: ////////
                   1655: 
                   1656: mm_ind:        incb    ROW
                   1657:        cmpb    ROW, MM_EROW(bp)
                   1658:        jg      0f
                   1659:        jmp     repos
                   1660: 0:     movb    ROW, MM_EROW(bp)
                   1661:        jmp     scrollup
                   1662: 
                   1663: ////////
                   1664: /
                   1665: / mm_new - save cursor position
                   1666: /
                   1667: ////////
                   1668: 
                   1669: mm_new:        movb    MM_SCOL(bp), COL
                   1670:        movb    MM_SROW(bp), ROW
                   1671:        jmp     eval
                   1672: 
                   1673: ////////
                   1674: /
                   1675: / mm_old - restore old cursor position
                   1676: /
                   1677: ////////
                   1678: 
                   1679: mm_old:        movb    COL, MM_SCOL(bp)
                   1680:        movb    ROW, MM_SROW(bp)
                   1681:        jmp     repos
                   1682: 
                   1683: ////////
                   1684: /
                   1685: / mm_ri - reverse index
                   1686: /
                   1687: /      Moves the active position to the same horizontal position on the
                   1688: /      preceding line.  Scrolling occurs if above scrolling region.
                   1689: /
                   1690: ////////
                   1691: 
                   1692: mm_ri: decb    ROW
                   1693:        cmpb    ROW, MM_BROW(bp)
                   1694:        jge     0f
                   1695:        movb    ROW, MM_BROW(bp)
                   1696:        jmp     scrolldown
                   1697: 0:     jmp     repos
                   1698: 
                   1699: ////////
                   1700: /
                   1701: / mm_scr - select cursor rendition
                   1702: /
                   1703: /      Invokes the cursor rendition specified by the parameter.
                   1704: /
                   1705: /      Recognized renditions are:      0 - cursor visible
                   1706: /                                      1 - cursor invisible
                   1707: ////////
                   1708: 
                   1709: mm_scr:        decb    MM_N1(bp)
                   1710:        je      0f
                   1711:        jg      1f
                   1712:        mov     MM_VIS(bp), $-1
                   1713:        jmp     eval
                   1714: 
                   1715: 0:     mov     MM_VIS(bp), $0
                   1716: 1:     jmp     eval
                   1717: 
                   1718: ////////
                   1719: /
                   1720: / mm_sgr - select graphic rendition
                   1721: /
                   1722: /      Invokes the graphic rendition specified by the parameter.
                   1723: /      All following characters in the data stream are rendered
                   1724: /      according to the parameters until the next occurrence of
                   1725: /      SGR in the data stream.
                   1726: /
                   1727: /      Recognized renditions are:      1 - high intensity
                   1728: /                                      4 - underline
                   1729: /                                      7 - reverse video
                   1730: /
                   1731: ////////
                   1732: 
                   1733: mm_sgr:        movb    al, MM_N1(bp)
                   1734:        cmpb    al, $0
                   1735:        jne     0f
                   1736:        mov     MM_MASK(bp), $0xAAAA
                   1737:        mov     MM_FLIP(bp), $0
                   1738:        mov     MM_ULINE(bp), $0
                   1739:        jmp     1f
                   1740: 0:     cmpb    al, $1          / bold
                   1741:        jne     0f
                   1742:        mov     MM_MASK(bp), $-1
                   1743:        jmp     1f
                   1744: 0:     cmpb    al, $4          / underline
                   1745:        jne     0f
                   1746:        mov     MM_ULINE(bp), $0xFFFF
                   1747:        jmp     1f
                   1748: 0:     cmpb    al, $7          / reverse video
                   1749:        jne     0f
                   1750:        mov     MM_FLIP(bp), $-1
                   1751:        jmp     1f
                   1752: 0:
                   1753: 1:     jmp     eval
                   1754: 
                   1755: ////////
                   1756: /
                   1757: / mm_so - stand out - enter 40 column mode
                   1758: /
                   1759: ////////
                   1760: 
                   1761: mm_so: cmpb    MM_NCOL(bp), $80
                   1762:        jne     0f
                   1763:        movb    MM_NCOL(bp), $40
                   1764:        incb    COL
                   1765:        shrb    COL, $1
                   1766: 0:     mov     MM_CURSE(bp), $0xffff
                   1767:        jmp     repos
                   1768: 
                   1769: ////////
                   1770: /
                   1771: / mm_si - stand in - enter 80 column mode
                   1772: /
                   1773: ////////
                   1774: 
                   1775: mm_si: cmpb    MM_NCOL(bp), $40
                   1776:        jne     0f
                   1777:        movb    MM_NCOL(bp), $80
                   1778:        shlb    COL, $1
                   1779: 0:     mov     MM_CURSE(bp), $0x00ff
                   1780:        jmp     repos
                   1781: 
                   1782: ////////
                   1783: /
                   1784: / mm_ssr - set scrolling region
                   1785: /
                   1786: ////////
                   1787: 
                   1788: mm_ssr:        movb    al, MM_N1(bp)
                   1789:        decb    al
                   1790:        jge     0f
                   1791:        subb    al, al
                   1792: 0:     cmpb    al, MM_LROW(bp)
                   1793:        ja      1f
                   1794:        movb    bl, MM_N2(bp)
                   1795:        decb    bl
                   1796:        jge     0f
                   1797:        subb    bl, bl
                   1798: 0:     cmpb    bl, MM_LROW(bp)
                   1799:        ja      1f
                   1800:        cmpb    al, bl
                   1801:        ja      1f
                   1802:        movb    MM_BROW(bp), al
                   1803:        movb    MM_EROW(bp), bl
                   1804:        movb    ROW, al
                   1805:        subb    COL, COL
                   1806: 1:     jmp     repos
                   1807: 
                   1808: ////////
                   1809: /
                   1810: / mm_vpa - vertical position absolute
                   1811: /
                   1812: /      Moves the active position to the line specified by the parameter
                   1813: /      without changing the horizontal position.
                   1814: /      A parameter value of 0 or 1 moves the active position vertically
                   1815: /      to the first line.
                   1816: /
                   1817: ////////
                   1818: 
                   1819: mm_vpa:        movb    ROW, MM_N1(bp)
                   1820:        decb    ROW
                   1821:        jg      0f
                   1822:        subb    ROW, ROW
                   1823: 0:     cmpb    ROW, MM_LROW(bp)
                   1824:        jna     0f
                   1825:        movb    ROW, MM_LROW(bp)
                   1826: 0:     jmp     repos                   / reposition cursor
                   1827: 
                   1828: ////////
                   1829: /
                   1830: / mm_vpr - vertical position relative
                   1831: /
                   1832: /      Moves the active position downward the number of lines specified
                   1833: /      by the parameter without changing the horizontal position.
                   1834: /      A parameter value of zero or one moves the active position
                   1835: /      one line downward.
                   1836: /
                   1837: ////////
                   1838: 
                   1839: mm_vpr:        movb    al, MM_N1(bp)
                   1840:        orb     al, al
                   1841:        jne     0f
                   1842:        incb    al
                   1843: 0:     addb    ROW, al
                   1844:        cmpb    ROW, MM_LROW(bp)
                   1845:        jb      0f
                   1846:        movb    ROW, MM_LROW(bp)
                   1847: 0:     jmp     repos                   / reposition cursor
                   1848: 
                   1849: ////////
                   1850: /
                   1851: / asctab - table of functions indexed by ascii characters
                   1852: /
                   1853: ////////
                   1854: 
                   1855: asctab:        .word   eval,   eval,   eval,   eval    /* NUL  SOH  STX  ETX  */
                   1856:        .word   eval,   eval,   eval,   mmbell  /* EOT  ENQ  ACK  BEL  */
                   1857:        .word   mm_cub, mm_cht, mm_cnl, mm_ind  /* BS   HT   LF   VT  */
                   1858:        .word   eval,   mm_cr,  mm_so,  mm_si   /* FF   CR   SO   SI  */
                   1859:        .word   eval,   eval,   eval,   eval    /* DLE  DC1  DC2  DC3 */
                   1860:        .word   eval,   eval,   eval,   eval    /* DC4  NAK  SYN  ETB  */
                   1861:        .word   eval,   eval,   eval,   mm_esc  /* CAN  EM   SUB  ESC  */
                   1862:        .word   eval,   eval,   eval,   eval    /* FS   GS   RS   US   */
                   1863:        .word   mmputc, mmputc, mmputc, mmputc  /*   ! " # \040 - \043 */
                   1864:        .word   mmputc, mmputc, mmputc, mmputc  /* $ % & quote \044 - \047 */
                   1865:        .word   mmputc, mmputc, mmputc, mmputc  /* ( ) * + \050 - \053 */
                   1866:        .word   mmputc, mmputc, mmputc, mmputc  /* , - . / \054 - \057 */
                   1867:        .word   mmputc, mmputc, mmputc, mmputc  /* 0 1 2 3 \060 - \063 */
                   1868:        .word   mmputc, mmputc, mmputc, mmputc  /* 4 5 6 7 \064 - \067 */
                   1869:        .word   mmputc, mmputc, mmputc, mmputc  /* 8 9 : ; \070 - \073 */
                   1870:        .word   mmputc, mmputc, mmputc, mmputc  /* < = > ? \074 - \077 */
                   1871:        .word   mmputc, mmputc, mmputc, mmputc  /* @ A B C \100 - \103 */
                   1872:        .word   mmputc, mmputc, mmputc, mmputc  /* D E F G \104 - \107 */
                   1873:        .word   mmputc, mmputc, mmputc, mmputc  /* H I J K \110 - \113 */
                   1874:        .word   mmputc, mmputc, mmputc, mmputc  /* L M N O \114 - \117 */
                   1875:        .word   mmputc, mmputc, mmputc, mmputc  /* P Q R S \120 - \123 */
                   1876:        .word   mmputc, mmputc, mmputc, mmputc  /* T U V W \124 - \127 */
                   1877:        .word   mmputc, mmputc, mmputc, mmputc  /* X Y Z [ \130 - \133 */
                   1878:        .word   mmputc, mmputc, mmputc, mmputc  /* \ ] ^ _ \134 - \137 */
                   1879:        .word   mmputc, mmputc, mmputc, mmputc  /* ` a b c \140 - \143 */
                   1880:        .word   mmputc, mmputc, mmputc, mmputc  /* d e f g \144 - \147 */
                   1881:        .word   mmputc, mmputc, mmputc, mmputc  /* h i j k \150 - \153 */
                   1882:        .word   mmputc, mmputc, mmputc, mmputc  /* l m n o \154 - \157 */
                   1883:        .word   mmputc, mmputc, mmputc, mmputc  /* p q r s \160 - \163 */
                   1884:        .word   mmputc, mmputc, mmputc, mmputc  /* t u v w \164 - \167 */
                   1885:        .word   mmputc, mmputc, mmputc, mmputc  /* x y z { \170 - \173 */
                   1886:        .word   mmputc, mmputc, mmputc, mmputc  /* | } ~ ? \174 - \177 */
                   1887: 
                   1888: ////////
                   1889: /
                   1890: / esctab - table of functions indexed by escape characters.
                   1891: /
                   1892: ////////
                   1893: 
                   1894: esctab:        .word   mmputc, mmputc, mmputc, mmputc  /* NUL  SOH  STX  ETX  */
                   1895:        .word   mmputc, mmputc, mmputc, mmputc  /* EOT  ENQ  ACK  BEL  */
                   1896:        .word   mmputc, mmputc, mmputc, mmputc  /* BS   HT   LF   VT  */
                   1897:        .word   mmputc, mmputc, mmputc, mmputc  /* FF   CR   SO   SI  */
                   1898:        .word   mmputc, mmputc, mmputc, mmputc  /* DLE  DC1  DC2  DC3 */
                   1899:        .word   mmputc, mmputc, mmputc, mmputc  /* DC4  NAK  SYN  ETB  */
                   1900:        .word   mmputc, mmputc, mmputc, mmputc  /* CAN  EM   SUB  ESC  */
                   1901:        .word   mmputc, mmputc, mmputc, mmputc  /* FS   GS   RS   US   */
                   1902:        .word   eval,   eval,   eval,   eval    /*   ! " # \040 - \043 */
                   1903:        .word   eval,   eval,   eval,   eval    /* $ % & quote \044 - \047 */
                   1904:        .word   eval,   eval,   eval,   eval    /* ( ) * + \050 - \053 */
                   1905:        .word   eval,   eval,   eval,   eval    /* , - . / \054 - \057 */
                   1906:        .word   eval,   eval,   eval,   eval    /* 0 1 2 3 \060 - \063 */
                   1907:        .word   eval,   eval,   eval,   mm_new  /* 4 5 6 7 \064 - \067 */
                   1908:        .word   mm_old, eval,   eval,   eval    /* 8 9 : ; \070 - \073 */
                   1909:        .word   eval,   mmspec, mmspec, eval    /* < = > ? \074 - \077 */
                   1910:        .word   eval,   eval,   eval,   eval    /* @ A B C \100 - \103 */
                   1911:        .word   mm_ind, mm_cnl, eval,   eval    /* D E F G \104 - \107 */
                   1912:        .word   eval,   eval,   eval,   eval    /* H I J K \110 - \113 */
                   1913:        .word   eval,   mm_ri,  eval,   eval    /* L M N O \114 - \117 */
                   1914:        .word   eval,   eval,   eval,   eval    /* P Q R S \120 - \123 */
                   1915:        .word   eval,   eval,   eval,   eval    /* T U V W \124 - \127 */
                   1916:        .word   eval,   eval,   eval,   csi_n1  /* X Y Z [ \130 - \133 */
                   1917:        .word   eval,   eval,   eval,   eval    /* \ ] ^ _ \134 - \137 */
                   1918:        .word   mm_dmi, eval,   mm_emi, mminit  /* ` a b c \140 - \143 */
                   1919:        .word   eval,   eval,   eval,   eval    /* d e f g \144 - \147 */
                   1920:        .word   eval,   eval,   eval,   eval    /* h i j k \150 - \153 */
                   1921:        .word   eval,   eval,   eval,   eval    /* l m n o \154 - \157 */
                   1922:        .word   eval,   eval,   eval,   eval    /* p q r s \160 - \163 */
                   1923:        .word   mmspec, mmspec, eval,   eval    /* t u v w \164 - \167 */
                   1924:        .word   eval,   eval,   eval,   eval    /* x y z { \170 - \173 */
                   1925:        .word   eval,   eval,   eval,   eval    /* | } ~ ? \174 - \177 */
                   1926: 
                   1927: ////////
                   1928: /
                   1929: / csitab - table of functions indexed by ESC [ characters.
                   1930: /
                   1931: ////////
                   1932: 
                   1933: csitab:        .word   eval,   eval,   eval,   eval    /* NUL  SOH  STX  ETX  */
                   1934:        .word   eval,   eval,   eval,   eval    /* EOT  ENQ  ACK  BEL  */
                   1935:        .word   eval,   eval,   eval,   eval    /* BS   HT   LF   VT  */
                   1936:        .word   eval,   eval,   eval,   eval    /* FF   CR   SO   SI  */
                   1937:        .word   eval,   eval,   eval,   eval    /* DLE  DC1  DC2  DC3 */
                   1938:        .word   eval,   eval,   eval,   eval    /* DC4  NAK  SYN  ETB  */
                   1939:        .word   eval,   eval,   eval,   eval    /* CAN  EM   SUB  ESC  */
                   1940:        .word   eval,   eval,   eval,   eval    /* FS   GS   RS   US   */
                   1941:        .word   eval,   eval,   eval,   eval    /*   ! " # \040 - \043 */
                   1942:        .word   eval,   eval,   eval,   eval    /* $ % & quote \044 - \047 */
                   1943:        .word   eval,   eval,   eval,   eval    /* ( ) * + \050 - \053 */
                   1944:        .word   eval,   eval,   eval,   eval    /* , - . / \054 - \057 */
                   1945:        .word   eval,   eval,   eval,   eval    /* 0 1 2 3 \060 - \063 */
                   1946:        .word   eval,   eval,   eval,   eval    /* 4 5 6 7 \064 - \067 */
                   1947:        .word   eval,   eval,   eval,   eval    /* 8 9 : ; \070 - \073 */
                   1948:        .word   eval,   eval,   csi_gt, eval    /* < = > ? \074 - \077 */
                   1949:        .word   eval,   mm_cuu, mm_cud, mm_cuf  /* @ A B C \100 - \103 */
                   1950:        .word   mm_cub, mm_cnl, mm_cpl, mm_cha  /* D E F G \104 - \107 */
                   1951:        .word   mm_cup, mm_cht, mm_ed,  mm_el   /* H I J K \110 - \113 */
                   1952:        .word   mm_il,  mm_dl,  eval,   mm_ea   /* L M N O \114 - \117 */
                   1953:        .word   eval,   eval,   eval,   mm_ind  /* P Q R S \120 - \123 */
                   1954:        .word   mm_ri,  eval,   eval,   eval    /* T U V W \124 - \127 */
                   1955:        .word   eval,   eval,   mm_cbt, eval    /* X Y Z [ \130 - \133 */
                   1956:        .word   eval,   eval,   eval,   eval    /* \ ] ^ _ \134 - \137 */
                   1957:        .word   mm_hpa, mm_hpr, eval,   eval    /* ` a b c \140 - \143 */
                   1958:        .word   mm_vpa, mm_vpr, mm_hvp, mm_cup  /* d e f g \144 - \147 */
                   1959:        .word   eval,   eval,   eval,   eval    /* h i j k \150 - \153 */
                   1960:        .word   eval,   mm_sgr, eval,   eval    /* l m n o \154 - \157 */
                   1961:        .word   eval,   eval,   mm_ssr, eval    /* p q r s \160 - \163 */
                   1962:        .word   eval,   eval,   mm_scr, eval    /* t u v w \164 - \167 */
                   1963:        .word   eval,   eval,   eval,   eval    /* x y z { \170 - \173 */
                   1964:        .word   eval,   eval,   eval,   eval    /* | } ~ ? \174 - \177 */
                   1965: 
                   1966: ////////
                   1967: /
                   1968: / rowtab - array of offsets to each row
                   1969: /
                   1970: ////////
                   1971: 
                   1972: rowtab:        .word    0*NRB2,         1*NRB2,         2*NRB2,         3*NRB2
                   1973:        .word    4*NRB2,         5*NRB2,         6*NRB2,         7*NRB2
                   1974:        .word    8*NRB2,         9*NRB2,        10*NRB2,        11*NRB2
                   1975:        .word   12*NRB2,        13*NRB2,        14*NRB2,        15*NRB2
                   1976:        .word   16*NRB2,        17*NRB2,        18*NRB2,        19*NRB2
                   1977:        .word   20*NRB2,        21*NRB2,        22*NRB2,        23*NRB2
                   1978:        .word   24*NRB2,        25*NRB2,        26*NRB2,        27*NRB2
                   1979:        .word   28*NRB2,        29*NRB2,        30*NRB2,        31*NRB2
                   1980:        .word   32*NRB2,        33*NRB2,        34*NRB2,        35*NRB2
                   1981:        .word   36*NRB2,        37*NRB2,        38*NRB2,        39*NRB2
                   1982:        .word   40*NRB2,        41*NRB2,        42*NRB2,        43*NRB2
                   1983:        .word   44*NRB2,        45*NRB2,        46*NRB2,        47*NRB2
                   1984:        .word   48*NRB2,        49*NRB2,        50*NRB2,        51*NRB2
                   1985: 
                   1986: ////////
                   1987: /
                   1988: / grread( dev, iop ) - read graphics display memory
                   1989: /
                   1990: ////////
                   1991: 
                   1992: grread_:
                   1993:        push    si
                   1994:        push    di
                   1995:        push    bp
                   1996:        mov     bp, sp
                   1997:        mov     bp, 10(bp)
                   1998:        push    ds
                   1999:        push    es
                   2000:        cmp     IO_SEG(bp), $IOSYS
                   2001:        je      0f
                   2002:        mov     ax, uds_
                   2003:        mov     es, ax
                   2004: 0:     mov     di, IO_BASE(bp)
                   2005:        mov     ax, $VSEG
                   2006:        mov     ds, ax
                   2007: 
                   2008: #ifndef TECMAR
                   2009:        mov     ax, IO_SEEK(bp)
                   2010:        add     ax, IO_IOC(bp)
                   2011:        cmp     ax, $BANKSZ*2
                   2012:        ja      done
                   2013: #endif
                   2014: 
                   2015:        mov     ax, IO_SEEK(bp)
                   2016:        sub     dx, dx
                   2017:        mov     cx, $NHB
                   2018:        div     cx
                   2019:        mov     si, dx
                   2020:        mov     bx, ax
                   2021:        shr     ax, $1
                   2022:        mul     cx
                   2023:        mov     dx, si
                   2024:        add     si, ax
                   2025:        testb   bl, $1
                   2026:        jne     read2
                   2027: 
                   2028: read1: mov     cx, $NHB
                   2029:        sub     cx, dx
                   2030:        cmp     cx, IO_IOC(bp)
                   2031:        jle     0f
                   2032:        mov     cx, IO_IOC(bp)
                   2033:        jcxz    done
                   2034: 0:     sub     IO_IOC(bp), cx
                   2035:        add     IO_BASE(bp), cx
                   2036:        push    si
                   2037:        rep
                   2038:        movsb
                   2039:        pop     si
                   2040: read2: add     si, $BANKSZ
                   2041:        mov     cx, $NHB
                   2042:        sub     cx, dx
                   2043:        cmp     cx, IO_IOC(bp)
                   2044:        jle     0f
                   2045:        mov     cx, IO_IOC(bp)
                   2046:        jcxz    done
                   2047: 0:     sub     IO_IOC(bp), cx
                   2048:        add     IO_BASE(bp), cx
                   2049:        rep
                   2050:        movsb
                   2051:        sub     si, $BANKSZ
                   2052:        sub     dx, dx
                   2053:        jmp     read1
                   2054: 
                   2055: done:  pop     es
                   2056:        pop     ds
                   2057:        pop     bp
                   2058:        pop     di
                   2059:        pop     si
                   2060:        ret
                   2061: 
                   2062: ////////
                   2063: /
                   2064: / grwrite( dev, iop ) - write graphics display memory
                   2065: /
                   2066: ////////
                   2067: 
                   2068: grwrite_:
                   2069:        push    si
                   2070:        push    di
                   2071:        push    bp
                   2072:        mov     bp, sp
                   2073:        mov     bp, 10(bp)
                   2074:        push    ds
                   2075:        push    es
                   2076:        cmp     IO_SEG(bp), $IOSYS
                   2077:        je      0f
                   2078:        mov     ax, uds_
                   2079:        mov     ds, ax
                   2080: 0:     mov     si, IO_BASE(bp)
                   2081:        mov     ax, $VSEG
                   2082:        mov     es, ax
                   2083: 
                   2084: #ifndef TECMAR
                   2085:        mov     ax, IO_SEEK(bp)
                   2086:        add     ax, IO_IOC(bp)
                   2087:        cmp     ax, $BANKSZ*2
                   2088:        ja      done
                   2089: #endif
                   2090: 
                   2091:        mov     ax, IO_SEEK(bp)
                   2092:        sub     dx, dx
                   2093:        mov     cx, $NHB
                   2094:        div     cx
                   2095:        mov     di, dx
                   2096:        mov     bx, ax
                   2097:        shr     ax, $1
                   2098:        mul     cx
                   2099:        mov     dx, di
                   2100:        add     di, ax
                   2101:        testb   bl, $1
                   2102:        jne     page2
                   2103: 
                   2104: page1: mov     cx, $NHB
                   2105:        sub     cx, dx
                   2106:        cmp     cx, IO_IOC(bp)
                   2107:        jle     0f
                   2108:        mov     cx, IO_IOC(bp)
                   2109:        jcxz    done
                   2110: 0:     sub     IO_IOC(bp), cx
                   2111:        add     IO_BASE(bp), cx
                   2112:        push    di
                   2113:        rep
                   2114:        movsb
                   2115:        pop     di
                   2116: page2: add     di, $BANKSZ
                   2117:        mov     cx, $NHB
                   2118:        sub     cx, dx
                   2119:        cmp     cx, IO_IOC(bp)
                   2120:        jle     0f
                   2121:        mov     cx, IO_IOC(bp)
                   2122:        jcxz    done
                   2123: 0:     sub     IO_IOC(bp), cx
                   2124:        add     IO_BASE(bp), cx
                   2125:        rep
                   2126:        movsb
                   2127:        sub     di, $BANKSZ
                   2128:        sub     dx, dx
                   2129:        jmp     page1
                   2130: 
                   2131: ////////
                   2132: /
                   2133: / mm_voff()    -- Disable video display
                   2134: /
                   2135: ////////
                   2136:        .globl  mm_voff_
                   2137: mm_voff_:
                   2138:        mov     dx, $MSR
                   2139:        movb    al, $0x12
                   2140:        outb    dx, al
                   2141:        ret
                   2142: 
                   2143: ////////
                   2144: /
                   2145: / mm_von()     -- Enable video display
                   2146: /
                   2147: ////////
                   2148:        .globl  mm_von_
                   2149: mm_von_:
                   2150:        mov     dx, $MSR                / enable video display
                   2151:        movb    al, $0x1A
                   2152:        outb    dx, al
                   2153:        mov     ss:mmvcnt_, $480        / 480 seconds before video disabled
                   2154:        ret

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.