OSRDCH  *       &FFE0   ;read character from console to A
OSASCI  *       &FFE3   ;print character in A translating CR to newline
        ORG     &0047   ;parts of language and Econet z.p. workspace
SNOW    LDAIM   INITAB -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
CELL    PHA             ;now A = Y = -9; push sentinel on stack
        LDAAY   BITMAP +&FF09   ;Y = -9..-1, set A := bitmap[0..8]
H       LDXIM   &F7     ;X := row number (immediate operand modified)
        BEQ     STAR    ;print only stars on horizontal axis
SHIFT   LSRA            ;shift LSB of bitmap into carry flag
        DEX             ;if row number positive, decrement it
        BPL     POSY    ;and test for zero
        INX             ;else negative; undo decrement
        INX             ;and increment towards zero, also setting Z
POSY    BNE     SHIFT   ;shift bits out until X = 0
        LDAIM   " "     ;prepare to print a space
        BCC     PRINT   ;if a 1 is left in the carry flag
STAR    LDAIM   "*"     ;then print an asterisk
PRINT   JSR     OSASCI  ;send character to console
        INY             ;increment column number
        BMI     CELL    ;if negative, read from the bitmap again
        PHA             ;else save character in column -1
        BEQ     STAR    ;if on vertical axis, print only stars
        PLA             ;else throw away last character printed
        PLA             ;print contents of row in reverse order
        BPL     PRINT   ;loop until sentinel popped; now Y = 10
        LDAIM   ROWTAB -CHRTAB  ;prepare to print newline and spaces
        INCZ    H +&01  ;increment row number (Zs are assembler hints)
        CPYZ    H +&01  ;test if row number = 10
        BNE     ROW     ;loop through rows until shape complete
        JMP     OSRDCH  ;then wait for console, discard char and exit
BITMAP  =       &00,&02,&51,&30,&72,&09,&04,&92,&49
CHRTAB  =       &F7," ",&F5,&0D ;CR, 11 spaces, set Y := -9
ROWTAB  =       &FA,&04,&16     ;MODE 4, 6x CR
INITAB                  ;display setup table
        END
