Annotation of coherent/d/PS2_KERNEL/io.286/ati.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: ////////
                      7: /
                      8: / Array Technologies Inc - Graphics Solution - Device Driver
                      9: /
                     10: /       Supports 40/80/132 column color text
                     11: /                   80/132 column monochrome text
                     12: /
                     13: / State driven code
                     14: /
                     15: /      Input:  DS:SI - input string
                     16: /              ES:DI - current screen location
                     17: /              SS:BP - terminal information
                     18: /              CX    - input count
                     19: /              BP    - references terminal information
                     20: /              AH    - character attributes
                     21: /              AL    - character
                     22: /              BH    - (usually) kept zeroed for efficiency
                     23: /              DH    - current row
                     24: /              DL    - current column
                     25: /
                     26: / 
                     27: ////////
                     28: 
                     29:        NCB     = 2             / number of horizontal bytes per char
                     30:        NCR     = 1             / number of horizontal lines per char
                     31:        NHB     = 160           / number of horizontal bytes per line
                     32:        NRB     = NCR*NHB       / number of bytes per character row
                     33: 
                     34:        ATTR    = ah            / attribute byte
                     35:        ZERO    = bh            / (almost) always zero
                     36:        ROW     = dh            / currently active vertical position
                     37:        COL     = dl            / currently active horizontal position
                     38:        POS     = di            / currently active display address
                     39: 
                     40:        INTENSE = 0x08          / high intensity attribute bit
                     41:        BLINK   = 0x80          / blinking attribute bit
                     42:        REVERSE = 0x70          / reverse video
                     43: 
                     44: ////////
                     45: /
                     46: / Magic constants from <sys/io.h>
                     47: /
                     48: ////////
                     49: 
                     50:        IO_SEG  = 0
                     51:        IO_IOC  = 2
                     52:        IO_BASE = 8
                     53: 
                     54:        IOSYS   = 0
                     55:        IOUSR   = 1
                     56: 
                     57: ////////
                     58: /
                     59: / Data
                     60: /
                     61: ////////
                     62: 
                     63: MM_FUNC                = 0             / current state
                     64: MM_PORT                = 2             / adapter base i/o port
                     65: MM_BASE                = 4             / adapter base memory address
                     66: MM_ROW         = 6             / screen row
                     67: MM_COL         = 7             / screen column
                     68: MM_POS         = 8             / screen position
                     69: MM_ATTR                = 10            / attributes
                     70: MM_N1          = 11            / numeric argument 1
                     71: MM_N2          = 12            / numeric argument 2
                     72: MM_BROW                = 13            / base row
                     73: MM_EROW                = 14            / end row
                     74: MM_LROW                = 15            / legal row limit
                     75: MM_SROW                = 16            / saved cursor row
                     76: MM_SCOL                = 17            / saved cursor column
                     77: MM_IBROW       = 18            / initial base row
                     78: MM_IEROW       = 19            / initial end row
                     79: MM_INVIS       = 20            / cursor invisible mask
                     80: MM_NCOL                = 22            / number of columns
                     81: MM_DATA                = 24            / pointer to crt data
                     82: MM_MODE                = 26            / mode register [0x21=col80/132,0x20=col40]
                     83: 
                     84: / ASCII characters
                     85: AZERO          = 0x30
                     86: CLOWER         = 0x63
                     87: SEMIC          = 0x3B
                     88: SPACE          = 0x20
                     89: 
                     90:        .prvd
                     91: mmdata:        .word   mminit
                     92:        .word   0x03D4
                     93:        .word   0xB800
                     94:        .byte   0, 0
                     95:        .word   0
                     96:        .byte   0x7, 0, 0, 0, 23, 24, 0, 0, 0, 23
                     97:        .word   0
                     98:        .word   80
                     99:        .word   creg80
                    100:        .byte   0x21, 0x00
                    101:        .shri
                    102: 
                    103: ////////
                    104: /
                    105: / creg40, creg80, creg132 - crt register values for 40/80/132 column color
                    106: /         mreg80, mreg132 - crt register values for 80/132 column monochrome
                    107: /
                    108: ////////
                    109: 
                    110: creg40:        .byte   0x38, 0x28, 0x2D, 0x0A, 0x1F, 0x06, 0x19, 0x1C
                    111:        .byte   0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00
                    112: 
                    113: creg80:        .byte   0x71, 0x50, 0x5A, 0x0A, 0x1F, 0x06, 0x19, 0x1C
                    114:        .byte   0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00
                    115: 
                    116: mreg80:        .byte   0x61, 0x50, 0x52, 0x0F, 0x19, 0x06, 0x19, 0x19
                    117:        .byte   0x02, 0x0D, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00
                    118: 
                    119: #ifdef ATI_132
                    120:        .globl  creg132
                    121: creg132:.byte  0xB5, 0x84, 0x97, 0x0A, 0x1F, 0x06, 0x19, 0x1C
                    122:        .byte   0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00
                    123: 
                    124:        .globl  mreg132
                    125: mreg132:.byte  0x9F, 0x84, 0x89, 0x0F, 0x19, 0x06, 0x19, 0x19
                    126:        .byte   0x02, 0x0D, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00
                    127: #endif
                    128: 
                    129: ////////
                    130: /
                    131: / mmgo( iop )
                    132: / IO *iop;
                    133: /
                    134: ////////
                    135: 
                    136:        .globl  mmgo_
                    137: 
                    138: mmgo_:
                    139:        push    si
                    140:        push    di
                    141:        push    bp
                    142:        mov     bp, sp
                    143:        push    ds
                    144:        push    es
                    145:        cld
                    146:        mov     bx, 8(bp)               / iop
                    147:        mov     si, IO_BASE(bx)         / iop->io_base
                    148:        mov     cx, IO_IOC(bx)          / iop->io_ioc
                    149:        cmp     IO_SEG(bx), $IOSYS
                    150:        je      0f
                    151:        mov     ds, uds_
                    152: 0:     mov     bp, $mmdata
                    153: 
                    154:        mov     dx, MM_PORT(bp)         / turn video off if color board
                    155:        cmp     dx, $0x3B4
                    156:        je      0f
                    157:        add     dx, $4
                    158:        movb    al, MM_MODE(bp)
                    159:        outb    dx, al
                    160: 0:
                    161:        movb    ROW, MM_ROW(bp)
                    162:        movb    COL, MM_COL(bp)
                    163:        mov     es,  MM_BASE(bp)
                    164:        mov     POS, MM_POS(bp)
                    165:        sub     bx, bx
                    166:        movb    ATTR, MM_ATTR(bp)
                    167:        ijmp    MM_FUNC(bp)
                    168: 
                    169: exit:  pop     bx
                    170:        pop     es
                    171:        pop     ds
                    172:        movb    MM_ATTR(bp), ATTR
                    173:        mov     MM_FUNC(bp), bx
                    174:        movb    MM_ROW(bp), ROW         / save row,column
                    175:        movb    MM_COL(bp), COL
                    176:        mov     MM_POS(bp), POS         / save position
                    177: 
                    178:        mov     dx, MM_PORT(bp)         / adjust cursor location
                    179:        mov     bx, POS
                    180:        or      bx, MM_INVIS(bp)
                    181:        shr     bx, $1
                    182: 
                    183:        movb    al, $14
                    184:        outb    dx, al
                    185:        inc     dx
                    186:        movb    al, bh
                    187:        outb    dx, al
                    188:        dec     dx
                    189:        movb    al, $15
                    190:        outb    dx, al
                    191:        inc     dx
                    192:        movb    al, bl
                    193:        outb    dx, al
                    194: 
                    195:        mov     dx, MM_PORT(bp)         / turn video on
                    196:        add     dx, $4
                    197:        movb    al, MM_MODE(bp)
                    198:        orb     al, $0x08
                    199:        outb    dx, al
                    200:        mov     mmvcnt_, $300           / 300 seconds before video disabled
                    201: 
                    202:        mov     bp, sp
                    203:        mov     bx, 8(bp)
                    204:        mov     ax, cx
                    205:        xchg    cx, IO_IOC(bx)
                    206:        sub     cx, IO_IOC(bx)
                    207:        add     IO_BASE(bx), cx
                    208:        pop     bp
                    209:        pop     di
                    210:        pop     si
                    211:        ret
                    212: 
                    213: ////////
                    214: /
                    215: / mminit - initialize screen
                    216: /
                    217: ////////
                    218: 
                    219: mminit:        movb    ss:mmesc_, $CLOWER              / schedule keyboard initialization
                    220:        mov     MM_NCOL(bp), $80        / set 80 column mode
                    221:        movb    MM_MODE(bp), $0x21
                    222:        mov     MM_DATA(bp), $creg80
                    223: 
                    224: #ifdef ATI_132
                    225:        mov     dx, $0x3DF              / clear 132 column color
                    226:        movb    al, $0x00               / in mode select register
                    227:        outb    dx, al
                    228: 
                    229:        mov     dx, $0x3BA              / clear 132 column monochrome
                    230:        movb    al, $0x00               / in mode select register
                    231:        outb    dx, al
                    232: #endif
                    233: 
                    234:        call    int11_                  / read equipment status
                    235:        andb    al, $0x30               / isolate video bits
                    236:        cmpb    al, $0x30               / if monochrome
                    237:        jne     0f
                    238:        mov     MM_DATA(bp), $mreg80    /       set monochrome register info
                    239:        mov     MM_PORT(bp), $0x3B4     /       set monochrome port
                    240:        mov     MM_BASE(bp), $0xB000    /       set monochrome base
                    241:        mov     es, MM_BASE(bp)         /               and extra segment.
                    242: 
                    243: 0:     call    newcrt                  / reprogram crt registers
                    244: 
                    245: reinit:        sub     ax, ax                  / regenerate row table
                    246:        mov     bx, $rowtab
                    247: 1:     mov     ss:(bx), ax
                    248:        add     ax, MM_NCOL(bp)
                    249:        add     ax, MM_NCOL(bp)
                    250:        add     bx, $2
                    251:        cmp     bx, $rowend
                    252:        jb      1b
                    253: 
                    254:        mov     dx, MM_PORT(bp)         / zero display offset
                    255:        movb    al, $12
                    256:        outb    dx, al
                    257:        inc     dx
                    258:        subb    al, al
                    259:        outb    dx, al
                    260:        dec     dx
                    261:        movb    al, $13
                    262:        outb    dx, al
                    263:        inc     dx
                    264:        subb    al, al
                    265:        outb    dx, al
                    266: 
                    267:        mov     dx, MM_PORT(bp)         / reset border to black
                    268:        add     dx, $5
                    269:        subb    al, al
                    270:        outb    dx, al
                    271: 
                    272:        mov     MM_INVIS(bp), $0
                    273:        movb    ATTR, $0x07
                    274:        movb    MM_ATTR(bp), ATTR
                    275:        movb    ROW, MM_IBROW(bp)
                    276:        movb    MM_BROW(bp), ROW
                    277:        movb    bl, MM_IEROW(bp)
                    278:        movb    MM_EROW(bp), bl
                    279:        sub     bx, bx
                    280:        movb    MM_N1(bp), $2
                    281:        jmp     mm_ed
                    282: 
                    283: ////////
                    284: /
                    285: / newcrt -- reload crt registers
                    286: /
                    287: /      Action: Program crt registers with values defined in code space
                    288: /              at offset given by MM_DATA(bp).
                    289: /
                    290: /      Note:   AX, BX, DX, DI trashed on exit.
                    291: /
                    292: ////////
                    293: 
                    294: newcrt:        mov     dx, MM_PORT(bp)         / turn video off
                    295:        add     dx, $4
                    296:        movb    al, MM_MODE(bp)
                    297:        outb    dx, al
                    298: 
                    299:        mov     di, MM_DATA(bp)         / program crt registers, last to first
                    300:        mov     bx, $15                 / [delay between i/o]
                    301:        mov     dx, MM_PORT(bp)         / [NOTE:DI=obsolete screen offset]
                    302: 0:     movb    al, bl
                    303:        outb    dx, al
                    304:        movb    al, cs:(bx,di)
                    305:        inc     dx
                    306:        outb    dx, al
                    307:        dec     dx
                    308:        dec     bx
                    309:        jge     0b
                    310:        ret
                    311: 
                    312: ////////
                    313: /
                    314: / mm_so - stand out - define 40 column attributes
                    315: /
                    316: ////////
                    317: 
                    318: mm_so:
                    319:        cmp     MM_PORT(bp), $0x3D4     / if color card
                    320:        jne     mm_si
                    321: 
                    322:        mov     MM_NCOL(bp), $40        /       setup for 40 column color
                    323:        movb    MM_MODE(bp), $0x20
                    324:        mov     MM_DATA(bp), $creg40
                    325: 
                    326: #ifdef ATI_132
                    327:        mov     dx, $0x3DF              /       clear 132 column color
                    328:        movb    al, $0x00               /       in mode select register
                    329:        outb    dx, al                  /       [delay between i/o]
                    330: #endif
                    331: 
                    332:        call    newcrt                  / program crt registers
                    333:        jmp     reinit
                    334: 
                    335: ////////
                    336: /
                    337: / mm_si - define 80 column attributes
                    338: /
                    339: ////////
                    340: 
                    341: mm_si:
                    342:        cmp     MM_PORT(bp), $0x3D4     / if color card
                    343:        jne     0f
                    344: 
                    345:        mov     MM_NCOL(bp), $80
                    346:        movb    MM_MODE(bp), $0x21
                    347:        mov     MM_DATA(bp), $creg80
                    348: 
                    349: #ifdef ATI_132
                    350:        mov     dx, $0x3DF              /       clear 132 column color
                    351:        movb    al, $0x00               /       in mode select register
                    352:        outb    dx, al                  /       [delay between i/o]
                    353: #endif
                    354: 
                    355:        call    newcrt                  /       reprogram crt registers.
                    356:        jmp     reinit
                    357: 
                    358: 0:     mov     MM_NCOL(bp), $80
                    359:        mov     MM_DATA(bp), $mreg80
                    360:        movb    MM_MODE(bp), $0x21
                    361: 
                    362: #ifdef ATI_132
                    363:        mov     dx, $0x3BA              /       clear 132 column monochrome
                    364:        movb    al, $0x00               /       in mode select register
                    365:        outb    dx, al                  /       [delay between i/o]
                    366: #endif
                    367: 
                    368:        call    newcrt                  /       reprogram crt registers
                    369:        jmp     reinit
                    370: 
                    371: ////////
                    372: /
                    373: / mm_132 - define 132 column attributes
                    374: /
                    375: ////////
                    376: 
                    377: mm_132:
                    378:        cmp     MM_PORT(bp), $0x3D4     / if color card
                    379:        jne     0f
                    380: 
                    381: #ifdef ATI_132
                    382:        mov     MM_DATA(bp), $creg132   /       set color crt values
                    383:        mov     MM_NCOL(bp), $132       /       set columns to 132
                    384:        movb    MM_MODE(bp), $0x21
                    385: 
                    386:        call    newcrt                  /       set 132 column crt values
                    387:                                        /       BEFORE setting mode select reg
                    388: 
                    389:        mov     dx, $0x3DF              /       set 132 columns
                    390:        movb    al, $0x10               /               in mode select register
                    391:        outb    dx, al
                    392: #endif
                    393:        jmp     reinit
                    394: 
                    395: 0:
                    396: #ifdef ATI_132
                    397:        mov     MM_NCOL(bp), $132       /       set columns to 132
                    398:        movb    MM_MODE(bp), $0x21      /       set 80/132 column display mode
                    399:        mov     MM_DATA(bp), $mreg132   /       set monochrome crt values
                    400: 
                    401:        call    newcrt                  /       set 132 column crt values
                    402:                                        /       BEFORE setting mode select reg
                    403: 
                    404:        mov     dx, $0x3BA              /       set 132 columns monochrome
                    405:        movb    al, $0x08               /               in mode select register
                    406:        outb    dx, al
                    407: #endif
                    408:        jmp     reinit
                    409: 
                    410: ////////
                    411: /
                    412: / mmspec - schedule special keyboard function
                    413: /
                    414: ////////
                    415: 
                    416: mmspec:        movb    ss:mmesc_, al
                    417:        jmp     eval
                    418: 
                    419: ////////
                    420: /
                    421: / mmbell - schedule beep
                    422: /
                    423: ////////
                    424: 
                    425: mmbell:        movb    ss:mmbeeps_, $-1
                    426:        jmp     eval
                    427: 
                    428: ////////
                    429: /
                    430: / mm_cnl - cursor next line
                    431: /
                    432: /      Moves the active position to the first column of the next display line.
                    433: /      Scrolls the active display if necessary.
                    434: /
                    435: ////////
                    436: 
                    437: mm_cnl:        subb    COL, COL
                    438:        incb    ROW
                    439:        cmpb    ROW, MM_EROW(bp)
                    440:        jna     repos
                    441:        movb    ROW, MM_EROW(bp)
                    442: /      jmp     scrollup
                    443: 
                    444: ////////
                    445: /
                    446: / scrollup - scroll display upwards
                    447: /
                    448: ////////
                    449: 
                    450: scrollup:
                    451:        push    ds
                    452:        push    si
                    453:        push    cx
                    454:        mov     ds, MM_BASE(bp)
                    455:        movb    bl, MM_BROW(bp)
                    456:        shlb    bl, $1
                    457:        mov     di, ss:rowtab(bx)
                    458:        mov     si, ss:rowtab+2(bx)
                    459:        movb    bl, ROW
                    460:        shlb    bl, $1
                    461:        mov     cx, ss:rowtab(bx)
                    462:        push    cx
                    463:        sub     cx, di
                    464:        shr     cx, $1
                    465:        cld
                    466:        rep
                    467:        movsw
                    468:        movb    al, $SPACE
                    469:        pop     di
                    470:        mov     cx, MM_NCOL(bp)
                    471:        rep
                    472:        stosw
                    473:        pop     cx
                    474:        pop     si
                    475:        pop     ds
                    476:        movb    bl, COL                 / reposition to ROW and COL
                    477:        shlb    bl, $1
                    478:        mov     POS, cs:coltab(bx)
                    479:        movb    bl, ROW
                    480:        shlb    bl, $1
                    481:        add     POS, ss:rowtab(bx)
                    482:        call    exit
                    483:        jmp     eval
                    484: 
                    485: ////////
                    486: /
                    487: / repos - reposition cursor
                    488: /
                    489: ////////
                    490: 
                    491: repos: movb    bl, COL                 / reposition to ROW and COL
                    492:        shl     bx, $1                  / [trash BH]
                    493:        mov     POS, cs:coltab(bx)
                    494:        subb    bh, bh                  / [clear BH]
                    495:        movb    bl, ROW
                    496:        shlb    bl, $1
                    497:        add     POS, ss:rowtab(bx)
                    498: /      jmp     eval
                    499: 
                    500: ////////
                    501: /
                    502: / eval - evaluate input character
                    503: /
                    504: ////////
                    505: 
                    506: eval:  jcxz    ewait
                    507:        dec     cx                              / evaluate next char
                    508:        lodsb
                    509:        movb    bl, al
                    510:        shlb    bl, $1
                    511:        ijmp    cs:asctab(bx)
                    512: 
                    513: ////////
                    514: /
                    515: / mmputc - put character on screen
                    516: /
                    517: ////////
                    518: 
                    519: mmputc:        stosw
                    520:        incb    COL
                    521:        cmpb    COL, MM_NCOL(bp)
                    522:        jnb     0f
                    523:        jcxz    ewait
                    524:        dec     cx
                    525:        lodsb
                    526:        movb    bl, al
                    527:        shlb    bl, $1
                    528:        ijmp    cs:asctab(bx)
                    529: 
                    530: 0:     subb    COL, COL
                    531:        incb    ROW
                    532:        cmpb    ROW, MM_EROW(bp)
                    533:        jg      0f
                    534:        jcxz    ewait
                    535:        dec     cx
                    536:        lodsb
                    537:        movb    bl, al
                    538:        shlb    bl, $1
                    539:        ijmp    cs:asctab(bx)
                    540: 
                    541: 0:     movb    ROW, MM_EROW(bp)
                    542:        jmp     scrollup
                    543: 
                    544: ////////
                    545: /
                    546: / Ewait - wait for next input char to evaluate
                    547: /
                    548: ////////
                    549: 
                    550: ewait: call    exit
                    551:        jcxz    ewait
                    552:        dec     cx
                    553:        lodsb
                    554:        movb    bl, al
                    555:        shlb    bl, $1
                    556:        ijmp    cs:asctab(bx)
                    557: 
                    558: ////////
                    559: /
                    560: / mm_cr - carriage return
                    561: /
                    562: /      Moves the active position to first position of current display line.
                    563: /
                    564: ////////
                    565: 
                    566: mm_cr: subb    COL, COL
                    567:        movb    bl, ROW
                    568:        shlb    bl, $1
                    569:        mov     POS, ss:rowtab(bx)
                    570:        jcxz    ewait
                    571:        dec     cx
                    572:        lodsb
                    573:        movb    bl, al
                    574:        shlb    bl, $1
                    575:        ijmp    cs:asctab(bx)
                    576: 
                    577: ////////
                    578: /
                    579: / mm_cub - cursor backwards
                    580: /
                    581: ////////
                    582: 
                    583: mm_cub:        sub     POS, $2
                    584:        subb    COL, $1
                    585:        jnb     0f
                    586:        movb    COL, MM_NCOL(bp)
                    587:        decb    COL
                    588:        decb    ROW
                    589:        cmpb    ROW, MM_BROW(bp)
                    590:        jge     0f
                    591:        subb    COL, COL
                    592:        movb    ROW, MM_BROW(bp)
                    593:        movb    bl, ROW
                    594:        shlb    bl, $1
                    595:        mov     POS, ss:rowtab(bx)
                    596: 0:     jcxz    ewait
                    597:        dec     cx
                    598:        lodsb
                    599:        movb    bl, al
                    600:        shlb    bl, $1
                    601:        ijmp    cs:asctab(bx)
                    602: 
                    603: ////////
                    604: /
                    605: / Esc state - entered when last char was ESC - transient state.
                    606: /
                    607: ////////
                    608: 
                    609: 0:     call    exit
                    610: mm_esc:        jcxz    0b
                    611:        dec     cx
                    612:        lodsb
                    613:        movb    MM_N1(bp), ZERO
                    614:        movb    MM_N2(bp), ZERO
                    615:        movb    bl, al
                    616:        shlb    bl, $1
                    617:        jc      mmputc
                    618:        ijmp    cs:esctab(bx)
                    619: 
                    620: ////////
                    621: /
                    622: / Csi_n1 state - entered when last two chars were ESC [
                    623: /
                    624: /      Action: Evaluates numeric chars as numeric parameter 1.
                    625: /
                    626: ////////
                    627: 
                    628: 0:     call    exit
                    629: csi_n1:        jcxz    0b
                    630:        dec     cx
                    631:        lodsb
                    632:        cmpb    al, $SEMIC
                    633:        je      csi_n2
                    634:        movb    bl, al
                    635:        subb    bl, $AZERO
                    636:        cmpb    bl, $9
                    637:        ja      csival
                    638:        shlb    MM_N1(bp), $1   / n1 * 2
                    639:        movb    al, MM_N1(bp)   / n1 * 2
                    640:        shlb    al, $1          / n1 * 4
                    641:        shlb    al, $1          / n1 * 8
                    642:        addb    al, MM_N1(bp)   / n1 * 10
                    643:        addb    al, bl          / n1 * 10 + digit
                    644:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
                    645:        jmp     csi_n1
                    646: 
                    647: ////////
                    648: /
                    649: / Csi_n2 state - entered after input sequence ESC [ n ;
                    650: /
                    651: ////////
                    652: 
                    653: 0:     call    exit
                    654: csi_n2:        jcxz    0b
                    655:        dec     cx
                    656:        lodsb
                    657:        movb    bl, al
                    658:        subb    bl, $AZERO
                    659:        cmpb    bl, $9
                    660:        ja      csival
                    661:        shlb    MM_N2(bp), $1   / n2 * 2
                    662:        movb    al, MM_N2(bp)   / n2 * 2
                    663:        shlb    al, $1          / n2 * 4
                    664:        shlb    al, $1          / n2 * 8
                    665:        addb    al, MM_N2(bp)   / n2 * 10
                    666:        addb    al, bl          / n2 * 10 + digit
                    667:        movb    MM_N2(bp), al   / n2 = (n2 * 10) + digit
                    668:        jmp     csi_n2
                    669: 
                    670: csival:        movb    bl, al
                    671:        shlb    bl, $1
                    672:        ijmp    cs:csitab(bx)
                    673: 
                    674: ////////
                    675: /
                    676: / Csi_gt state - entered after input sequence ESC [ >
                    677: /      
                    678: ////////
                    679: 
                    680: 0:     call    exit
                    681: csi_gt:        jcxz    0b
                    682:        dec     cx
                    683:        lodsb
                    684:        movb    bl, al
                    685:        subb    bl, $AZERO
                    686:        cmpb    bl, $9
                    687:        ja      1f
                    688:        shlb    MM_N1(bp), $1   / n1 * 2
                    689:        movb    al, MM_N1(bp)   / n1 * 2
                    690:        shlb    al, $1          / n1 * 4
                    691:        shlb    al, $1          / n1 * 8
                    692:        addb    al, MM_N1(bp)   / n1 * 10
                    693:        addb    al, bl          / n1 * 10 + digit
                    694:        movb    MM_N1(bp), al   / n1 = (n1 * 10) + digit
                    695:        jmp     csi_gt
                    696: 
                    697: 1:     movb    bl, al
                    698:        shlb    bl, $1
                    699:        ijmp    cs:csgtab(bx)
                    700: 
                    701: ////////
                    702: /
                    703: / mm_cbt - cursor backward tabulation
                    704: /
                    705: /      Moves the active position horizontally in the backward direction
                    706: /      to the preceding in a series of predetermined positions.
                    707: /
                    708: ////////
                    709: 
                    710: mm_cbt:        orb     COL, $7                 / calculate next tab stop
                    711:        incb    COL
                    712:        subb    COL, $16                / step back two tab positions
                    713:        jnb     0f
                    714:        subb    COL, COL                / cannot step past column 0
                    715: 0:     jmp     repos                   / reposition cursor
                    716: 
                    717: ////////
                    718: /
                    719: / mm_cgh - process ESC [ > N1 h escape sequence
                    720: /
                    721: /      Recognized sequences:   ESC [ > 13 h    -- Set CRT saver enabled.
                    722: /
                    723: ////////
                    724: 
                    725: mm_cgh:        cmpb    MM_N1(bp), $13
                    726:        jne     0f
                    727:        mov     ss:mmcrtsav_, $1
                    728: 0:     jmp     eval
                    729: 
                    730: ////////
                    731: /
                    732: / mm_cgl - process ESC [ > N1 l escape sequence
                    733: /
                    734: /      Recognized sequences:   ESC [ > 13 l    -- Reset CRT saver.
                    735: /
                    736: ////////
                    737: 
                    738: mm_cgl:        cmpb    MM_N1(bp), $13
                    739:        jne     0f
                    740:        mov     ss:mmcrtsav_, $0
                    741: 0:     jmp     eval
                    742: 
                    743: ////////
                    744: /
                    745: / mm_cha - cursor horizontal absolute
                    746: /
                    747: /      Advances the active position forward or backward along the active line
                    748: /      to the character position specified by the parameter.
                    749: /      A parameter value of zero or one moves the active position to the
                    750: /      first character position of the active line.
                    751: /      A parameter value of N moves the active position to character position
                    752: /      N of the active line.
                    753: /
                    754: ////////
                    755: 
                    756: mm_cha:        movb    COL, MM_N1(bp)
                    757:        orb     COL, COL
                    758:        je      0f
                    759:        decb    COL
                    760: 0:     cmpb    COL, MM_NCOL(bp)
                    761:        jb      0f
                    762:        movb    COL, MM_NCOL(bp)
                    763:        decb    COL
                    764: 0:     jmp     repos                   / reposition cursor
                    765: 
                    766: 
                    767: ////////
                    768: /
                    769: / mm_cht - cursor horizontal tabulation
                    770: /
                    771: /      Advances the active position horizontally to the next or following
                    772: /      in a series of predetermined positions.
                    773: /
                    774: ////////
                    775: 
                    776: mm_cht:        push    cx
                    777:        sub     cx, cx
                    778:        movb    cl, COL
                    779:        orb     cl, $7
                    780:        incb    cl
                    781:        subb    cl, COL
                    782:        addb    COL, cl
                    783:        movb    al, $SPACE
                    784:        rep
                    785:        stosw
                    786:        pop     cx
                    787:        cmpb    COL, MM_NCOL(bp)
                    788:        jb      0f
                    789:        subb    COL, MM_NCOL(bp)
                    790:        incb    ROW
                    791:        cmpb    ROW, MM_EROW(bp)
                    792:        jna     0f
                    793:        movb    ROW, MM_EROW(bp)
                    794:        jmp     scrollup
                    795: 0:     jmp     eval
                    796: 
                    797: ////////
                    798: /
                    799: / mm_cpl - cursor preceding line
                    800: /
                    801: /      Moves the active position to the first position of the preceding
                    802: /      display line.
                    803: /
                    804: ////////
                    805: 
                    806: mm_cpl:        subb    COL, COL
                    807:        decb    ROW
                    808:        cmpb    ROW, MM_BROW(bp)
                    809:        jnb     0f
                    810:        movb    ROW, MM_BROW(bp)
                    811:        jmp     scrolldown
                    812: 0:     jmp     repos                   / reposition cursor
                    813: 
                    814: ////////
                    815: /
                    816: / mm_cud - cursor down
                    817: /
                    818: /      Moves the active position downward without altering the
                    819: /      horizontal position.
                    820: /
                    821: ////////
                    822: 
                    823: mm_cud:        incb    ROW
                    824:        cmpb    ROW, MM_EROW(bp)
                    825:        jna     0f
                    826:        movb    ROW, MM_EROW(bp)
                    827: 0:     jmp     repos                   / reposition cursor
                    828: 
                    829: ////////
                    830: /
                    831: / mm_cuf - cursor forward
                    832: /
                    833: /      Moves the active position in the forward direction.
                    834: /
                    835: ////////
                    836: 
                    837: mm_cuf:        incb    COL
                    838:        cmpb    COL, MM_NCOL(bp)
                    839:        jb      0f
                    840:        subb    COL, MM_NCOL(bp)
                    841:        incb    ROW
                    842:        cmpb    ROW, MM_EROW(bp)
                    843:        jna     0f
                    844:        movb    ROW, MM_EROW(bp)
                    845:        movb    COL, MM_NCOL(bp)
                    846:        decb    COL
                    847: 0:     jmp     repos
                    848: 
                    849: ////////
                    850: /
                    851: / mm_cup - cursor position
                    852: /
                    853: /      Moves the active position to the position specified by two parameters.
                    854: /      The 1st parameter (mm_n1) specifies the vertical   position MM_ROW(bp).
                    855: /      The 2nd parameter (mm_n2) specifies the horizontal position MM_COL(bp).
                    856: /      A parameter value of 0 or 1 for the first or second parameter
                    857: /      moves the active position to the first line or column in the
                    858: /      display respectively.
                    859: /
                    860: ////////
                    861: 
                    862: mm_cup:        movb    ROW, MM_N1(bp)
                    863:        orb     ROW, ROW
                    864:        je      0f
                    865:        decb    ROW
                    866: 0:     addb    ROW, MM_BROW(bp)
                    867:        cmpb    ROW, MM_EROW(bp)
                    868:        jb      0f
                    869:        movb    ROW, MM_EROW(bp)
                    870: 0:     movb    COL, MM_N2(bp)
                    871:        orb     COL, COL
                    872:        je      0f
                    873:        decb    COL
                    874: 0:     cmpb    COL, MM_NCOL(bp)
                    875:        jb      0f
                    876:        movb    COL, MM_NCOL(bp)
                    877:        decb    COL
                    878: 0:     jmp     repos                   / reposition cursor
                    879: 
                    880: ////////
                    881: /
                    882: / mm_cuu - cursor up
                    883: /
                    884: /      Moves the active position upward without altering the horizontal
                    885: /      position.
                    886: /
                    887: ////////
                    888: 
                    889: mm_cuu:        decb    ROW
                    890:        cmpb    ROW, MM_BROW(bp)
                    891:        jge     0f
                    892:        movb    ROW, MM_BROW(bp)
                    893: 0:     jmp     repos                   / reposition cursor
                    894: 
                    895: ////////
                    896: /
                    897: / mm_dl - delete line
                    898: /
                    899: /      Removes the contents of the active line.
                    900: /      The contents of all following lines are shifted in a block
                    901: /      toward the active line.
                    902: /
                    903: ////////
                    904: 
                    905: mm_dl: push    ds
                    906:        push    si
                    907:        push    cx
                    908:        mov     ds, MM_BASE(bp)
                    909:        movb    bl, ROW
                    910:        shlb    bl, $1
                    911:        mov     di, ss:rowtab(bx)
                    912:        mov     si, ss:rowtab+2(bx)
                    913:        movb    bl, MM_EROW(bp)
                    914:        shlb    bl, $1
                    915:        mov     cx, ss:rowtab(bx)
                    916:        sub     cx, di
                    917:        jle     0f
                    918:        shr     cx, $1
                    919:        rep
                    920:        movsw
                    921:        mov     di, ss:rowtab(bx)
                    922:        mov     cx, MM_NCOL(bp)
                    923:        movb    al, $SPACE
                    924:        rep
                    925:        stosw
                    926:        subb    COL, COL
                    927:        movb    bl, ROW
                    928:        shlb    bl, $1
                    929:        mov     di, ss:rowtab(bx)
                    930: 0:     pop     cx
                    931:        pop     si
                    932:        pop     ds
                    933:        call    exit
                    934:        jmp     eval
                    935: 
                    936: ////////
                    937: /
                    938: / mm_dmi - disable manual input
                    939: /
                    940: /      Set flag preventing keyboard input, and causing cursor to vanish.
                    941: /
                    942: ////////
                    943: 
                    944: mm_dmi:
                    945:        mov     ss:islock_, $1
                    946:        jmp     eval
                    947: 
                    948: ////////
                    949: /
                    950: / mm_ea - erase in area
                    951: /
                    952: /      Erase some or all of the characters in the currently active area
                    953: /      according to the parameter:
                    954: /              0 - erase from active position to end inclusive (default)
                    955: /              1 - erase from start to active position inclusive
                    956: /              2 - erase all of active area
                    957: /
                    958: ////////
                    959: 
                    960: mm_ea: movb    al, MM_N1(bp)
                    961:        cmpb    al, $0
                    962:        jne     0f
                    963:        movb    bl, MM_EROW(bp)
                    964:        jmp     mm_e0
                    965: 0:     cmpb    al, $1
                    966:        jne     0f
                    967:        movb    bl, MM_BROW(bp)
                    968:        jmp     mm_e1
                    969: 0:     subb    COL, COL
                    970:        movb    ROW, MM_BROW(bp)
                    971:        movb    bl, ROW
                    972:        shlb    bl, $1
                    973:        mov     POS, ss:rowtab(bx)
                    974:        movb    bl, MM_EROW(bp)
                    975:        subb    bl, ROW
                    976:        jmp     mm_e2
                    977: 
                    978: 
                    979: ////////
                    980: /
                    981: / mm_ed - erase in display
                    982: /
                    983: /      Erase some or all of the characters in the display according to the
                    984: /      parameter
                    985: /              0 - erase from active position to end inclusive (default)
                    986: /              1 - erase from start to active position inclusive
                    987: /              2 - erase all of display
                    988: /
                    989: ////////
                    990: 
                    991: mm_ed: movb    al, MM_N1(bp)
                    992:        cmpb    al, $0
                    993:        jne     0f
                    994:        movb    bl, MM_LROW(bp)
                    995:        jmp     mm_e0
                    996: 0:     cmpb    al, $1
                    997:        jne     0f
                    998:        subb    bl, bl
                    999:        jmp     mm_e1
                   1000: 0:     subb    COL, COL
                   1001:        movb    ROW, MM_BROW(bp)
                   1002:        sub     POS, POS
                   1003:        movb    bl, MM_LROW(bp)
                   1004:        jmp     mm_e2
                   1005: 
                   1006: ////////
                   1007: /
                   1008: / mm_el - erase in line
                   1009: /
                   1010: /      Erase some or all of the characters in the line according to the
                   1011: /      parameter:
                   1012: /              0 - erase from active position to end inclusive (default)
                   1013: /              1 - erase from start to active position inclusive
                   1014: /              2 - erase entire line
                   1015: /
                   1016: ////////
                   1017: 
                   1018: mm_el: movb    al, MM_N1(bp)
                   1019:        movb    bl, ROW
                   1020:        cmpb    al, $0
                   1021:        je      mm_e0
                   1022:        cmpb    al, $1
                   1023:        je      mm_e1
                   1024:        shlb    bl, $1
                   1025:        mov     POS, ss:rowtab(bx)
                   1026:        subb    COL, COL
                   1027:        subb    bl, bl
                   1028: /      jmp     mm_e2
                   1029: 
                   1030: mm_e2: push    cx
                   1031:        movb    al, $SPACE
                   1032: 0:     mov     cx, MM_NCOL(bp)
                   1033:        rep
                   1034:        stosw
                   1035:        decb    bl
                   1036:        jge     0b
                   1037:        pop     cx
                   1038:        jmp     repos
                   1039: 
                   1040: mm_e1: push    cx
                   1041:        mov     cx, POS
                   1042:        shlb    bl, $1
                   1043:        mov     POS, ss:rowtab(bx)
                   1044:        sub     cx, POS
                   1045:        jl      0f
                   1046:        movb    al, $SPACE
                   1047:        shr     cx, $1
                   1048:        rep
                   1049:        stosw
                   1050: 0:     pop     cx
                   1051:        jmp     repos
                   1052: 
                   1053: mm_e0: push    cx
                   1054:        shlb    bl, $1
                   1055:        mov     cx, ss:rowtab+2(bx)
                   1056:        sub     cx, POS
                   1057:        jl      0f
                   1058:        movb    al, $SPACE
                   1059:        shr     cx, $1
                   1060:        rep
                   1061:        stosw
                   1062: 0:     pop     cx
                   1063:        jmp     repos
                   1064: 
                   1065: ////////
                   1066: /
                   1067: / mm_emi - enable manual input
                   1068: /
                   1069: /      Clear flag preventing keyboard input.
                   1070: /
                   1071: ////////
                   1072: 
                   1073: mm_emi:
                   1074:        mov     ss:islock_, $0
                   1075:        jmp     eval
                   1076: 
                   1077: ////////
                   1078: /
                   1079: / mm_il - insert line
                   1080: /
                   1081: /      Insert a erased line at the active line by shifting the contents
                   1082: /      of the active line and all following lines away from the active line.
                   1083: /      The contents of the last line in the scrolling region are removed.
                   1084: /
                   1085: ////////
                   1086: 
                   1087: scrolldown:
                   1088: mm_il: push    ds
                   1089:        push    si
                   1090:        push    cx
                   1091:        mov     ds, MM_BASE(bp)
                   1092:        movb    bl, MM_EROW(bp)
                   1093:        shlb    bl, $1
                   1094:        mov     si, ss:rowtab(bx)
                   1095:        mov     cx, si
                   1096:        sub     si, $2
                   1097:        mov     di, ss:rowtab+2(bx)
                   1098:        sub     di, $2
                   1099:        movb    bl, ROW
                   1100:        shlb    bl, $1
                   1101:        sub     cx, ss:rowtab(bx)
                   1102:        jle     0f
                   1103:        shr     cx, $1
                   1104:        std
                   1105:        rep
                   1106:        movsw
                   1107:        mov     di, ss:rowtab(bx)
                   1108:        mov     cx, MM_NCOL(bp)
                   1109:        movb    al, $SPACE
                   1110:        cld
                   1111:        rep
                   1112:        stosw
                   1113:        subb    COL, COL
                   1114:        movb    bl, ROW
                   1115:        shlb    bl, $1
                   1116:        mov     di, ss:rowtab(bx)
                   1117: 0:     pop     cx
                   1118:        pop     si
                   1119:        pop     ds
                   1120:        call    exit
                   1121:        jmp     eval
                   1122: 
                   1123: ////////
                   1124: /
                   1125: / mm_hpa - horizontal position absolute
                   1126: /
                   1127: /      Moves the active position within the active line to the position
                   1128: /      specified by the parameter.  A parameter value of zero or one
                   1129: /      moves the active position to the first position of the active line.
                   1130: /
                   1131: ////////
                   1132: 
                   1133: mm_hpa:        movb    COL, MM_N1(bp)
                   1134:        orb     COL, COL
                   1135:        je      0f
                   1136:        decb    COL
                   1137: 0:     cmpb    COL, MM_NCOL(bp)
                   1138:        jb      0f
                   1139:        movb    COL, MM_NCOL(bp)
                   1140:        decb    COL
                   1141: 0:     jmp     repos                   / reposition cursor
                   1142: 
                   1143: ////////
                   1144: /
                   1145: / mm_hpr - horizontal position relative
                   1146: /
                   1147: /      Moves the active position forward the number of positions specified
                   1148: /      by the parameter.  A parameter value of zero or one indicates a
                   1149: /      single-position move.
                   1150: /
                   1151: ////////
                   1152: 
                   1153: mm_hpr:        movb    al, MM_N1(bp)
                   1154:        orb     al, al
                   1155:        jne     0f
                   1156:        incb    al
                   1157: 0:     addb    COL, al
                   1158:        cmpb    COL, MM_NCOL(bp)
                   1159:        jb      0f
                   1160:        movb    COL, MM_NCOL(bp)
                   1161:        decb    COL
                   1162: 0:     jmp     repos                   / reposition cursor
                   1163: 
                   1164: ////////
                   1165: /
                   1166: / mm_hvp - horizontal and vertical position
                   1167: /
                   1168: /      Moves the active position to the position specified by two parameters.
                   1169: /      The first parameter specifies the vertical position (MM_ROW(bp)).
                   1170: /      The second parameter specifies the horizontal position (MM_COL(bp)).
                   1171: /      A parameter value of zero or one moves the active position to the
                   1172: /      first line or column in the display.
                   1173: /
                   1174: ////////
                   1175: 
                   1176: mm_hvp:        movb    ROW, MM_N1(bp)
                   1177:        orb     ROW, ROW
                   1178:        je      0f
                   1179:        decb    ROW
                   1180: 0:     cmpb    ROW, MM_LROW(bp)
                   1181:        jna     0f
                   1182:        movb    ROW, MM_LROW(bp)
                   1183: 0:     movb    COL, MM_N2(bp)
                   1184:        orb     COL, COL
                   1185:        je      0f
                   1186:        decb    COL
                   1187: 0:     cmpb    COL, MM_NCOL(bp)
                   1188:        jb      0f
                   1189:        movb    COL, MM_NCOL(bp)
                   1190:        decb    COL
                   1191: 0:     jmp     repos                   / reposition cursor
                   1192: 
                   1193: ////////
                   1194: /
                   1195: / mm_ind - index
                   1196: /
                   1197: /      Causes the active position to move downward one line without changing
                   1198: /      the horizontal position.  Scrolling occurs if below scrolling region.
                   1199: /
                   1200: ////////
                   1201: 
                   1202: mm_ind:        incb    ROW
                   1203:        cmpb    ROW, MM_EROW(bp)
                   1204:        jg      0f
                   1205:        jmp     repos
                   1206: 0:     movb    ROW, MM_EROW(bp)
                   1207:        jmp     scrollup
                   1208: 
                   1209: ////////
                   1210: /
                   1211: / mm_new - save cursor position
                   1212: /
                   1213: ////////
                   1214: 
                   1215: mm_new:        movb    MM_SCOL(bp), COL
                   1216:        movb    MM_SROW(bp), ROW
                   1217:        jmp     eval
                   1218: 
                   1219: ////////
                   1220: /
                   1221: / mm_old - restore old cursor position
                   1222: /
                   1223: ////////
                   1224: 
                   1225: mm_old:        movb    COL, MM_SCOL(bp)
                   1226:        movb    ROW, MM_SROW(bp)
                   1227:        jmp     repos
                   1228: 
                   1229: ////////
                   1230: /
                   1231: / mm_ri - reverse index
                   1232: /
                   1233: /      Moves the active position to the same horizontal position on the
                   1234: /      preceding line.  Scrolling occurs if above scrolling region.
                   1235: /
                   1236: ////////
                   1237: 
                   1238: mm_ri: decb    ROW
                   1239:        cmpb    ROW, MM_BROW(bp)
                   1240:        jge     0f
                   1241:        movb    ROW, MM_BROW(bp)
                   1242:        jmp     scrolldown
                   1243: 0:     jmp     repos
                   1244: 
                   1245: ////////
                   1246: /
                   1247: / mm_scr - select cursor rendition
                   1248: /
                   1249: /      Invokes the cursor rendition specified by the parameter.
                   1250: /
                   1251: /      Recognized renditions are:      0 - cursor visible
                   1252: /                                      1 - cursor invisible
                   1253: ////////
                   1254: 
                   1255: mm_scr:        decb     MM_N1(bp)
                   1256:        je      0f
                   1257:        jg      1f
                   1258:        mov     MM_INVIS(bp), $0
                   1259:        jmp     eval
                   1260: 
                   1261: 0:     mov     MM_INVIS(bp), $-1
                   1262: 1:     jmp     eval
                   1263: 
                   1264: ////////
                   1265: /
                   1266: / mm_sgr - select graphic rendition
                   1267: /
                   1268: /      Invokes the graphic rendition specified by the parameter.
                   1269: /      All following characters in the data stream are rendered
                   1270: /      according to the parameters until the next occurrence of
                   1271: /      SGR in the data stream.
                   1272: /
                   1273: /      Recognized renditions are:      1 - high intensity
                   1274: /                                      4 - underline
                   1275: /                                      5 - slow blink
                   1276: /                                      7 - reverse video
                   1277: /                                      30-37 - foreground color
                   1278: /                                      40-47 - background color
                   1279: /                                      50-57 - border color
                   1280: /
                   1281: ////////
                   1282: 
                   1283: mm_sgr:        movb    al, MM_N1(bp)
                   1284:        cmpb    al, $0
                   1285:        jne     0f
                   1286:        movb    ATTR, $0x07
                   1287: 1:     jmp     eval
                   1288: 0:     cmpb    al, $1          / bold
                   1289:        jne     0f
                   1290:        orb     ATTR, $INTENSE
                   1291:        jmp     1b
                   1292: 0:     cmpb    al, $4          / underline
                   1293:        jne     0f
                   1294:        cmp     MM_PORT(bp), $0x03D4    / color card?
                   1295:        je      1b                      / yes, ignore underline
                   1296:        andb    ATTR, $~0x77
                   1297:        orb     ATTR, $0x01
                   1298:        jmp     1b
                   1299: 0:     cmpb    al, $5          / blinking
                   1300:        jne     0f
                   1301:        orb     ATTR, $BLINK
                   1302:        jmp     1b
                   1303: 0:     cmpb    al, $7          / reverse video
                   1304:        jne     0f
                   1305:        movb    al, $0x70
                   1306:        cmp     MM_PORT(bp), $0x3D4     / color card?
                   1307:        jne     2f
                   1308:        movb    al, ah                  / yes, exchange foreground/background
                   1309:        andb    al, $0x77
                   1310:        rolb    al, $1
                   1311:        rolb    al, $1
                   1312:        rolb    al, $1
                   1313:        rolb    al, $1
                   1314: 2:     andb    ATTR, $~0x77
                   1315:        orb     ATTR, al
                   1316:        jmp     1b
                   1317: 0:     cmp     MM_PORT(bp), $0x03D4    / color card?
                   1318:        jne     1b                      / no, ignore remaining options
                   1319: 0:     subb    al, $30         / foreground color
                   1320:        jl      1f
                   1321:        cmpb    al, $7
                   1322:        jg      0f
                   1323:        movb    bl, al
                   1324:        andb    ATTR, $~0x07
                   1325:        orb     ATTR, cs:fcolor(bx)
                   1326:        jmp     1f
                   1327: 0:     subb    al, $10
                   1328:        jl      1f
                   1329:        cmpb    al, $7
                   1330:        jg      0f
                   1331:        movb    bl, al
                   1332:        andb    ATTR, $~0x70
                   1333:        orb     ATTR, cs:bcolor(bx)
                   1334:        jmp     1f
                   1335: 0:     subb    al, $10
                   1336:        jl      1f
                   1337:        cmpb    al, $7
                   1338:        jg      0f
                   1339:        movb    bl, al
                   1340:        movb    al, cs:fcolor(bx)
                   1341:        push    dx
                   1342:        mov     dx, MM_PORT(bp)
                   1343:        add     dx, $5
                   1344:        outb    dx, al
                   1345:        pop     dx
                   1346: /      jmp     1f
                   1347: 0:
                   1348: 1:     jmp     eval
                   1349: 
                   1350: ////////
                   1351: /
                   1352: / mm_ssr - set scrolling region
                   1353: /
                   1354: ////////
                   1355: 
                   1356: mm_ssr:        movb    al, MM_N1(bp)
                   1357:        decb    al
                   1358:        jge     0f
                   1359:        subb    al, al
                   1360: 0:     cmpb    al, MM_LROW(bp)
                   1361:        ja      1f
                   1362:        movb    bl, MM_N2(bp)
                   1363:        decb    bl
                   1364:        jge     0f
                   1365:        subb    bl, bl
                   1366: 0:     cmpb    bl, MM_LROW(bp)
                   1367:        ja      1f
                   1368:        cmpb    al, bl
                   1369:        ja      1f
                   1370:        movb    MM_BROW(bp), al
                   1371:        movb    MM_EROW(bp), bl
                   1372:        movb    ROW, al
                   1373:        subb    COL, COL
                   1374: 1:     jmp     repos
                   1375: 
                   1376: ////////
                   1377: /
                   1378: / mm_vpa - vertical position absolute
                   1379: /
                   1380: /      Moves the active position to the line specified by the parameter
                   1381: /      without changing the horizontal position.
                   1382: /      A parameter value of 0 or 1 moves the active position vertically
                   1383: /      to the first line.
                   1384: /
                   1385: ////////
                   1386: 
                   1387: mm_vpa:        movb    ROW, MM_N1(bp)
                   1388:        decb    ROW
                   1389:        jg      0f
                   1390:        subb    ROW, ROW
                   1391: 0:     cmpb    ROW, MM_LROW(bp)
                   1392:        jna     0f
                   1393:        movb    ROW, MM_LROW(bp)
                   1394: 0:     jmp     repos                   / reposition cursor
                   1395: 
                   1396: ////////
                   1397: /
                   1398: / mm_vpr - vertical position relative
                   1399: /
                   1400: /      Moves the active position downward the number of lines specified
                   1401: /      by the parameter without changing the horizontal position.
                   1402: /      A parameter value of zero or one moves the active position
                   1403: /      one line downward.
                   1404: /
                   1405: ////////
                   1406: 
                   1407: mm_vpr:        movb    al, MM_N1(bp)
                   1408:        orb     al, al
                   1409:        jne     0f
                   1410:        incb    al
                   1411: 0:     addb    ROW, al
                   1412:        cmpb    ROW, MM_LROW(bp)
                   1413:        jb      0f
                   1414:        movb    ROW, MM_LROW(bp)
                   1415: 0:     jmp     repos                   / reposition cursor
                   1416: 
                   1417: ////////
                   1418: /
                   1419: / asctab - table of functions indexed by ascii characters
                   1420: /
                   1421: ////////
                   1422: 
                   1423: asctab:        .word   eval,   eval,   eval,   eval    /       NUL  SOH  STX  ETX
                   1424:        .word   eval,   eval,   eval,   mmbell  /       EOT  ENQ  ACK  BEL
                   1425:        .word   mm_cub, mm_cht, mm_cnl, mm_ind  /       BS   HT   LF   VT
                   1426:        .word   eval,   mm_cr,  mm_so,  mm_si   /       FF   CR   SO   SI
                   1427:        .word   eval,   eval,   eval,   eval    /       DLE  DC1  DC2  DC3
                   1428: / DEBUG: mm_132 is only inserted temporarily, for testing - 86/05/26
                   1429:        .word   eval,   eval,   eval,   mm_132  /       DC4  NAK  SYN  ETB
                   1430:        .word   eval,   eval,   eval,   mm_esc  /       CAN  EM   SUB  ESC
                   1431:        .word   eval,   eval,   eval,   eval    /       FS   GS   RS   US
                   1432:        .word   mmputc, mmputc, mmputc, mmputc  /         ! dquote # \040 - \043
                   1433:        .word   mmputc, mmputc, mmputc, mmputc  /       $ % & quote \044 - \047
                   1434:        .word   mmputc, mmputc, mmputc, mmputc  /       ( ) * + \050 - \053
                   1435:        .word   mmputc, mmputc, mmputc, mmputc  /       , - . / \054 - \057
                   1436:        .word   mmputc, mmputc, mmputc, mmputc  /       0 1 2 3 \060 - \063
                   1437:        .word   mmputc, mmputc, mmputc, mmputc  /       4 5 6 7 \064 - \067
                   1438:        .word   mmputc, mmputc, mmputc, mmputc  /       8 9 : ; \070 - \073
                   1439:        .word   mmputc, mmputc, mmputc, mmputc  /       < = > ? \074 - \077
                   1440:        .word   mmputc, mmputc, mmputc, mmputc  /       @ A B C \100 - \103
                   1441:        .word   mmputc, mmputc, mmputc, mmputc  /       D E F G \104 - \107
                   1442:        .word   mmputc, mmputc, mmputc, mmputc  /       H I J K \110 - \113
                   1443:        .word   mmputc, mmputc, mmputc, mmputc  /       L M N O \114 - \117
                   1444:        .word   mmputc, mmputc, mmputc, mmputc  /       P Q R S \120 - \123
                   1445:        .word   mmputc, mmputc, mmputc, mmputc  /       T U V W \124 - \127
                   1446:        .word   mmputc, mmputc, mmputc, mmputc  /       X Y Z [ \130 - \133
                   1447:        .word   mmputc, mmputc, mmputc, mmputc  /       \ ] ^ _ \134 - \137
                   1448:        .word   mmputc, mmputc, mmputc, mmputc  /       ` a b c \140 - \143
                   1449:        .word   mmputc, mmputc, mmputc, mmputc  /       d e f g \144 - \147
                   1450:        .word   mmputc, mmputc, mmputc, mmputc  /       h i j k \150 - \153
                   1451:        .word   mmputc, mmputc, mmputc, mmputc  /       l m n o \154 - \157
                   1452:        .word   mmputc, mmputc, mmputc, mmputc  /       p q r s \160 - \163
                   1453:        .word   mmputc, mmputc, mmputc, mmputc  /       t u v w \164 - \167
                   1454:        .word   mmputc, mmputc, mmputc, mmputc  /       x y z { \170 - \173
                   1455:        .word   mmputc, mmputc, mmputc, mmputc  /       | } ~ ? \174 - \177
                   1456: 
                   1457: ////////
                   1458: /
                   1459: / esctab - table of functions indexed by escape characters.
                   1460: /
                   1461: ////////
                   1462: 
                   1463: esctab:        .word   mmputc, mmputc, mmputc, mmputc  /       NUL  SOH  STX  ETX
                   1464:        .word   mmputc, mmputc, mmputc, mmputc  /       EOT  ENQ  ACK  BEL
                   1465:        .word   mmputc, mmputc, mmputc, mmputc  /       BS   HT   LF   VT
                   1466:        .word   mmputc, mmputc, mmputc, mmputc  /       FF   CR   SO   SI
                   1467:        .word   mmputc, mmputc, mmputc, mmputc  /       DLE  DC1  DC2  DC3
                   1468:        .word   mmputc, mmputc, mmputc, mmputc  /       DC4  NAK  SYN  ETB
                   1469:        .word   mmputc, mmputc, mmputc, mmputc  /       CAN  EM   SUB  ESC
                   1470:        .word   mmputc, mmputc, mmputc, mmputc  /       FS   GS   RS   US
                   1471:        .word   eval,   eval,   eval,   eval    /         ! dquote # \040 - \043
                   1472:        .word   eval,   eval,   eval,   eval    /       $ % & quote \044 - \047
                   1473:        .word   eval,   eval,   eval,   eval    /       ( ) * + \050 - \053
                   1474:        .word   eval,   eval,   eval,   eval    /       , - . / \054 - \057
                   1475:        .word   eval,   eval,   eval,   eval    /       0 1 2 3 \060 - \063
                   1476:        .word   eval,   eval,   eval,   mm_new  /       4 5 6 7 \064 - \067
                   1477:        .word   mm_old, eval,   eval,   eval    /       8 9 : ; \070 - \073
                   1478:        .word   eval,   mmspec, mmspec, eval    /       < = > ? \074 - \077
                   1479:        .word   eval,   eval,   eval,   eval    /       @ A B C \100 - \103
                   1480:        .word   mm_ind, mm_cnl, eval,   eval    /       D E F G \104 - \107
                   1481:        .word   eval,   eval,   eval,   eval    /       H I J K \110 - \113
                   1482:        .word   eval,   mm_ri,  eval,   eval    /       L M N O \114 - \117
                   1483:        .word   eval,   eval,   eval,   eval    /       P Q R S \120 - \123
                   1484:        .word   eval,   eval,   eval,   eval    /       T U V W \124 - \127
                   1485:        .word   eval,   eval,   eval,   csi_n1  /       X Y Z [ \130 - \133
                   1486:        .word   eval,   eval,   eval,   eval    /       \ ] ^ _ \134 - \137
                   1487:        .word   mm_dmi, eval,   mm_emi, mminit  /       ` a b c \140 - \143
                   1488:        .word   eval,   eval,   eval,   eval    /       d e f g \144 - \147
                   1489:        .word   eval,   eval,   eval,   eval    /       h i j k \150 - \153
                   1490:        .word   eval,   eval,   eval,   eval    /       l m n o \154 - \157
                   1491:        .word   eval,   eval,   eval,   eval    /       p q r s \160 - \163
                   1492:        .word   mmspec, mmspec, eval,   eval    /       t u v w \164 - \167
                   1493:        .word   eval,   eval,   eval,   eval    /       x y z { \170 - \173
                   1494:        .word   eval,   eval,   eval,   eval    /       | } ~ ? \174 - \177
                   1495: 
                   1496: ////////
                   1497: /
                   1498: / csitab - table of functions indexed by ESC [ characters.
                   1499: /
                   1500: ////////
                   1501: 
                   1502: csitab:        .word   eval,   eval,   eval,   eval    /       NUL  SOH  STX  ETX
                   1503:        .word   eval,   eval,   eval,   eval    /       EOT  ENQ  ACK  BEL
                   1504:        .word   eval,   eval,   eval,   eval    /       BS   HT   LF   VT
                   1505:        .word   eval,   eval,   eval,   eval    /       FF   CR   SO   SI
                   1506:        .word   eval,   eval,   eval,   eval    /       DLE  DC1  DC2  DC3
                   1507:        .word   eval,   eval,   eval,   eval    /       DC4  NAK  SYN  ETB
                   1508:        .word   eval,   eval,   eval,   eval    /       CAN  EM   SUB  ESC
                   1509:        .word   eval,   eval,   eval,   eval    /       FS   GS   RS   US
                   1510:        .word   eval,   eval,   eval,   eval    /         ! dquote # \040 - \043
                   1511:        .word   eval,   eval,   eval,   eval    /       $ % & quote \044 - \047
                   1512:        .word   eval,   eval,   eval,   eval    /       ( ) * + \050 - \053
                   1513:        .word   eval,   eval,   eval,   eval    /       , - . / \054 - \057
                   1514:        .word   eval,   eval,   eval,   eval    /       0 1 2 3 \060 - \063
                   1515:        .word   eval,   eval,   eval,   eval    /       4 5 6 7 \064 - \067
                   1516:        .word   eval,   eval,   eval,   eval    /       8 9 : ; \070 - \073
                   1517:        .word   eval,   eval,   csi_gt, eval    /       < = > ? \074 - \077
                   1518:        .word   eval,   mm_cuu, mm_cud, mm_cuf  /       @ A B C \100 - \103
                   1519:        .word   mm_cub, mm_cnl, mm_cpl, mm_cha  /       D E F G \104 - \107
                   1520:        .word   mm_cup, mm_cht, mm_ed,  mm_el   /       H I J K \110 - \113
                   1521:        .word   mm_il,  mm_dl,  eval,   mm_ea   /       L M N O \114 - \117
                   1522:        .word   eval,   eval,   eval,   mm_ind  /       P Q R S \120 - \123
                   1523:        .word   mm_ri,  eval,   eval,   eval    /       T U V W \124 - \127
                   1524:        .word   eval,   eval,   mm_cbt, eval    /       X Y Z [ \130 - \133
                   1525:        .word   eval,   eval,   eval,   eval    /       \ ] ^ _ \134 - \137
                   1526:        .word   mm_hpa, mm_hpr, eval,   eval    /       ` a b c \140 - \143
                   1527:        .word   mm_vpa, mm_vpr, mm_hvp, mm_cup  /       d e f g \144 - \147
                   1528:        .word   eval,   eval,   eval,   eval    /       h i j k \150 - \153
                   1529:        .word   eval,   mm_sgr, eval,   eval    /       l m n o \154 - \157
                   1530:        .word   eval,   eval,   mm_ssr, eval    /       p q r s \160 - \163
                   1531:        .word   eval,   eval,   mm_scr, eval    /       t u v w \164 - \167
                   1532:        .word   eval,   eval,   eval,   eval    /       x y z { \170 - \173
                   1533:        .word   eval,   eval,   eval,   eval    /       | } ~ ? \174 - \177
                   1534: 
                   1535: ////////
                   1536: /
                   1537: / csgtab - table of functions indexed by ESC [ > characters.
                   1538: /
                   1539: ////////
                   1540: 
                   1541: csgtab:        .word   eval,   eval,   eval,   eval    /       NUL  SOH  STX  ETX
                   1542:        .word   eval,   eval,   eval,   eval    /       EOT  ENQ  ACK  BEL
                   1543:        .word   eval,   eval,   eval,   eval    /       BS   HT   LF   VT
                   1544:        .word   eval,   eval,   eval,   eval    /       FF   CR   SO   SI
                   1545:        .word   eval,   eval,   eval,   eval    /       DLE  DC1  DC2  DC3
                   1546:        .word   eval,   eval,   eval,   eval    /       DC4  NAK  SYN  ETB
                   1547:        .word   eval,   eval,   eval,   eval    /       CAN  EM   SUB  ESC
                   1548:        .word   eval,   eval,   eval,   eval    /       FS   GS   RS   US
                   1549:        .word   eval,   eval,   eval,   eval    /         ! dquote # \040 - \043
                   1550:        .word   eval,   eval,   eval,   eval    /       $ % & quote \044 - \047
                   1551:        .word   eval,   eval,   eval,   eval    /       ( ) * + \050 - \053
                   1552:        .word   eval,   eval,   eval,   eval    /       , - . / \054 - \057
                   1553:        .word   eval,   eval,   eval,   eval    /       0 1 2 3 \060 - \063
                   1554:        .word   eval,   eval,   eval,   eval    /       4 5 6 7 \064 - \067
                   1555:        .word   eval,   eval,   eval,   eval    /       8 9 : ; \070 - \073
                   1556:        .word   eval,   eval,   eval,   eval    /       < = > ? \074 - \077
                   1557:        .word   eval,   eval,   eval,   eval    /       @ A B C \100 - \103
                   1558:        .word   eval,   eval,   eval,   eval    /       D E F G \104 - \107
                   1559:        .word   eval,   eval,   eval,   eval    /       H I J K \110 - \113
                   1560:        .word   eval,   eval,   eval,   eval    /       L M N O \114 - \117
                   1561:        .word   eval,   eval,   eval,   eval    /       P Q R S \120 - \123
                   1562:        .word   eval,   eval,   eval,   eval    /       T U V W \124 - \127
                   1563:        .word   eval,   eval,   eval,   eval    /       X Y Z [ \130 - \133
                   1564:        .word   eval,   eval,   eval,   eval    /       \ ] ^ _ \134 - \137
                   1565:        .word   eval,   eval,   eval,   eval    /       ` a b c \140 - \143
                   1566:        .word   eval,   eval,   eval,   eval    /       d e f g \144 - \147
                   1567:        .word   mm_cgh, eval,   eval,   eval    /       h i j k \150 - \153
                   1568:        .word   mm_cgl, eval,   eval,   eval    /       l m n o \154 - \157
                   1569:        .word   eval,   eval,   eval,   eval    /       p q r s \160 - \163
                   1570:        .word   eval,   eval,   eval,   eval    /       t u v w \164 - \167
                   1571:        .word   eval,   eval,   eval,   eval    /       x y z { \170 - \173
                   1572:        .word   eval,   eval,   eval,   eval    /       | } ~ ? \174 - \177
                   1573: 
                   1574: ////////
                   1575: /
                   1576: / coltab - integer array of offsets to each column - up to 132 columns
                   1577: /
                   1578: ////////
                   1579: 
                   1580: coltab:        .word     0*NCB,   1*NCB,   2*NCB,   3*NCB
                   1581:        .word     4*NCB,   5*NCB,   6*NCB,   7*NCB
                   1582:        .word     8*NCB,   9*NCB,  10*NCB,  11*NCB
                   1583:        .word    12*NCB,  13*NCB,  14*NCB,  15*NCB
                   1584:        .word    16*NCB,  17*NCB,  18*NCB,  19*NCB
                   1585:        .word    20*NCB,  21*NCB,  22*NCB,  23*NCB
                   1586:        .word    24*NCB,  25*NCB,  26*NCB,  27*NCB
                   1587:        .word    28*NCB,  29*NCB,  30*NCB,  31*NCB
                   1588:        .word    32*NCB,  33*NCB,  34*NCB,  35*NCB
                   1589:        .word    36*NCB,  37*NCB,  38*NCB,  39*NCB
                   1590:        .word    40*NCB,  41*NCB,  42*NCB,  43*NCB
                   1591:        .word    44*NCB,  45*NCB,  46*NCB,  47*NCB
                   1592:        .word    48*NCB,  49*NCB,  50*NCB,  51*NCB
                   1593:        .word    52*NCB,  53*NCB,  54*NCB,  55*NCB
                   1594:        .word    56*NCB,  57*NCB,  58*NCB,  59*NCB
                   1595:        .word    60*NCB,  61*NCB,  62*NCB,  63*NCB
                   1596:        .word    64*NCB,  65*NCB,  66*NCB,  67*NCB
                   1597:        .word    68*NCB,  69*NCB,  70*NCB,  71*NCB
                   1598:        .word    72*NCB,  73*NCB,  74*NCB,  75*NCB
                   1599:        .word    76*NCB,  77*NCB,  78*NCB,  79*NCB
                   1600:        .word    80*NCB,  81*NCB,  82*NCB,  83*NCB
                   1601:        .word    84*NCB,  85*NCB,  86*NCB,  87*NCB
                   1602:        .word    88*NCB,  89*NCB,  90*NCB,  91*NCB
                   1603:        .word    92*NCB,  93*NCB,  94*NCB,  95*NCB
                   1604:        .word    96*NCB,  97*NCB,  98*NCB,  99*NCB
                   1605:        .word   100*NCB, 101*NCB, 102*NCB, 103*NCB
                   1606:        .word   104*NCB, 105*NCB, 106*NCB, 107*NCB
                   1607:        .word   108*NCB, 109*NCB, 110*NCB, 111*NCB
                   1608:        .word   112*NCB, 113*NCB, 114*NCB, 115*NCB
                   1609:        .word   116*NCB, 117*NCB, 118*NCB, 119*NCB
                   1610:        .word   120*NCB, 121*NCB, 122*NCB, 123*NCB
                   1611:        .word   124*NCB, 125*NCB, 126*NCB, 127*NCB
                   1612:        .word   128*NCB, 129*NCB, 130*NCB, 131*NCB
                   1613: 
                   1614: ////////
                   1615: /
                   1616: / rowtab - array of offsets to each row - up to 44 rows
                   1617: /         automatically regenerated by reinit().
                   1618: /
                   1619: /      NOTE: In kernel data space to allow modification in protected mode.
                   1620: /
                   1621: ////////
                   1622: 
                   1623:        .shrd
                   1624: rowtab:        .word    0*NRB,  1*NRB,  2*NRB,  3*NRB
                   1625:        .word    4*NRB,  5*NRB,  6*NRB,  7*NRB
                   1626:        .word    8*NRB,  9*NRB, 10*NRB, 11*NRB
                   1627:        .word   12*NRB, 13*NRB, 14*NRB, 15*NRB
                   1628:        .word   16*NRB, 17*NRB, 18*NRB, 19*NRB
                   1629:        .word   20*NRB, 21*NRB, 22*NRB, 23*NRB
                   1630:        .word   24*NRB, 25*NRB, 26*NRB, 27*NRB
                   1631:        .word   28*NRB, 29*NRB, 30*NRB, 31*NRB
                   1632:        .word   32*NRB, 33*NRB, 34*NRB, 35*NRB
                   1633:        .word   36*NRB, 37*NRB, 38*NRB, 39*NRB
                   1634:        .word   40*NRB, 41*NRB, 42*NRB, 43*NRB
                   1635: rowend:
                   1636:        .shri
                   1637: 
                   1638: ////////
                   1639: /
                   1640: / fcolor - foreground color
                   1641: / bcolor - background color
                   1642: /
                   1643: /      indexed by ansi color (black,red,green,brown,blue,magenta,cyan,white)
                   1644: /      yields graphics color (black,blue,green,cyan,red,magenta,brown,white)
                   1645: /              which is properly shifted for installation in attribute byte.
                   1646: /
                   1647: ////////
                   1648: 
                   1649: fcolor:        .byte   0x00, 0x04, 0x02, 0x06, 0x01, 0x05, 0x03, 0x07
                   1650: bcolor:        .byte   0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70
                   1651: 
                   1652: ////////
                   1653: /
                   1654: / mm_voff()    -- Disable video display.
                   1655: /
                   1656: ////////
                   1657:        .globl  mm_voff_
                   1658: mm_voff_:
                   1659:        mov     dx, mmdata+MM_PORT
                   1660:        add     dx, $4
                   1661:        movb    al, mmdata+MM_MODE
                   1662:        outb    dx, al
                   1663:        ret
                   1664: 
                   1665: ////////
                   1666: /
                   1667: / mm_von()     -- Enable video display
                   1668: /
                   1669: ////////
                   1670:        .globl  mm_von_
                   1671: mm_von_:
                   1672:        mov     dx, mmdata+MM_PORT      / enable video display
                   1673:        add     dx, $4
                   1674:        movb    al, mmdata+MM_MODE
                   1675:        orb     al, $0x08
                   1676:        outb    dx, al
                   1677:        mov     mmvcnt_, $300           / 300 seconds before video disabled
                   1678:        ret

unix.superglobalmegacorp.com

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