OSRDCH  *       &FFE0   ;read character from console to A
OSASCI  *       &FFE3   ;print character in A translating CR to newline
        ORG     &0054   ;parts of language and Econet z.p. workspace
PRES    LDAIM   BOXTAB -CHRTAB  ;point to end of character table
        TAY             ;Y < &7F, print first character once
ROW     TAX             ;make X index into table
CHAR    LDAZX   CHRTAB -&01     ;fetch character
        BMI     DROP    ;if negative then it's a count, so skip
LOOP    JSR     OSASCI  ;else print character, A preserved
        INY             ;increment count towards zero
        BMI     LOOP    ;print characters once, runs until Y = 0
DROP    TAY             ;next count to Y
        DEX             ;work backwards through table
        BNE     CHAR    ;print until start of table
        STXZ    W       ;now Y = -19, X = 0; clear column counter
        CPXZ    H       ;set C on H = 0 (Zs are assembler hints)
        LDAIM   &80:OR:(ROWTAB-CHRTAB)  ;b7 := 1 first column is a line
        ROLA            ;set A.b1 on H = 0 (row is a line)
CELL    ROLA            ;set A.b0 on C = 1 (column is a line)
        TAX             ;make X index into table, 16..19
        LDAZX   BOXTAB-((ROWTAB-CHRTAB):SHL1:2)  ;fetch box character
        JSR     OSASCI  ;print character
        TXA
        LSRA            ;column type to C
        RORZ    W       ;shift C into counter, next column into C
        INY             ;increase column number towards zero
        BNE     CELL    ;print until end of row, then Y = 0 for LOOP
        LSRA            ;row type to C, A := 4 (offset to ROWTAB)
        RORZ    H       ;shift into top of H
        LSRZX   W-((ROWTAB-CHRTAB):SHL1:2)-&01  ;X = 17 or 19
                        ;shift W (= &80) or backslash (3 times)
        BCC     ROW     ;print rows until 1 shifted out of backslash
        JMP     OSRDCH  ;then wait for console, discard char and exit
CHRTAB  =       &ED," ",&F5,&0D ;CR, 11 spaces, set Y := -19
W                       ;column type counter, +2 edge row counter
ROWTAB  =       "/O\ ",&ED,&0D,&FA,&04,&16      ;MODE 4, 6x CR, 19x spc
BOXTAB  =       " !-+"  ;table of box characters
H       =       &00     ;row type counter
        END
