Skip to content

Commit

Permalink
add FillChar routine to support ESC #8
Browse files Browse the repository at this point in the history
  • Loading branch information
ksherlock committed May 27, 2018
1 parent 5c0764e commit 58ab674
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 0 deletions.
137 changes: 137 additions & 0 deletions ansi.asm
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
case on
mcopy ansi.mac

dummy start
end

RDMAINRAM gequ $E0C002 ; Read from main memory
RDCARDRAM gequ $E0C003 ; Read from auxiliary memory
WRMAINRAM gequ $E0C004 ; Write to main memory
WRCARDRAM gequ $E0C005 ; Write to auxiliary memory

tables privdata

;
Expand Down Expand Up @@ -641,6 +647,137 @@ exit anop
end

; FillChar(char, andMask, xorMask)
gen on
FillChar START

using tables

subroutine (2:char,2:andMask,2:xorMask),(16:cdata)

xx equ andMask
yy equ xorMask

lda <char
cmp #$7f
bcs space
sec
sbc #$20
bmi space
asl a ; x2
asl a ; x4
asl a ; x8
asl a ; x16
tax
bra ok


space anop
ldx #0 ; char

ok anop

; pre-calc the char mask to data.

lda CHAR_SPACE,x
eor <xorMask
and <andMask
sta cdata

lda CHAR_SPACE+2,x
eor <xorMask
and <andMask
sta cdata+2

lda CHAR_SPACE+4,x
eor <xorMask
and <andMask
sta cdata+4

lda CHAR_SPACE+6,x
eor <xorMask
and <andMask
sta cdata+6

lda CHAR_SPACE+8,x
eor <xorMask
and <andMask
sta cdata+8

lda CHAR_SPACE+10,x
eor <xorMask
and <andMask
sta cdata+10

lda CHAR_SPACE+12,x
eor <xorMask
and <andMask
sta cdata+12

lda CHAR_SPACE+14,x
eor <xorMask
and <andMask
sta cdata+14


pea $e1e1
plb
plb


lda #24
sta yy

ldx #0*8*160+4*160+$2000
yloop anop

lda cdata+0
jsr one_line

lda cdata+2
jsr one_line

lda cdata+4
jsr one_line

lda cdata+6
jsr one_line

lda cdata+8
jsr one_line

lda cdata+10
jsr one_line

lda cdata+12
jsr one_line

lda cdata+14
jsr one_line

dec yy
bne yloop

exit anop

return

end

one_line private
; a = character data
; x = memory address

ldy #80
loop anop
sta |$0000,x
inx
inx
dey
bne loop
rts
end

HideCursor start
using cursor_data

Expand Down
245 changes: 245 additions & 0 deletions ansi.mac
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
macro
&l _ldy &r
&l anop
aif "&r"="@a",.a
aif "&r"="@x",.x
aif "&r"="@y",.y
ldy &r
ago .y
.a
tay
ago .y
.x
txy
ago .y
.y
mend
macro
&l subroutine &parms,&locals
&l anop
gbla &totallen
gbla &worklen
gbla &returnlen
&worklen seta 0
&totallen seta 0
&returnlen seta 4
lclc &len
lclc &p
lcla &i

phb

aif c:&locals=0,.doparms
.dolocals
&i seta 1
.bb
&p setc &locals(&i)
&len amid &p,2,1
aif "&len"=":",.cc
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .dd
.cc
&len amid &p,1,1
&p amid &p,3,l:&p-2
.dd
&p equ &worklen+1
&worklen seta &worklen+&len
&i seta &i+1
aif &i<=c:&locals,^bb
.doparms

aif c:&parms=0,.e
&i seta 1
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+&returnlen+1+&worklen
&totallen seta &totallen+&len
&i seta &i+1
aif &i<=c:&parms,^b
.e
tsc
aif &worklen=0,.f
sec
sbc #&worklen
tcs
.f
phd
tcd
mend


macro
&l lsubroutine &parms,&locals
&l anop
gbla &totallen
gbla &worklen
gbla &returnlen
&worklen seta 0
&totallen seta 0
&returnlen seta 2
lclc &len
lclc &p
lcla &i

aif c:&locals=0,.doparms
.dolocals
&i seta 1
.bb
&p setc &locals(&i)
&len amid &p,2,1
aif "&len"=":",.cc
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .dd
.cc
&len amid &p,1,1
&p amid &p,3,l:&p-2
.dd
&p equ &worklen+1
&worklen seta &worklen+&len
&i seta &i+1
aif &i<=c:&locals,^bb
.doparms
aif c:&parms=0,.e
&i seta 1
.b
&p setc &parms(&i)
&len amid &p,2,1
aif "&len"=":",.c
&len amid &p,1,2
&p amid &p,4,l:&p-3
ago .d
.c
&len amid &p,1,1
&p amid &p,3,l:&p-2
.d
&p equ &totallen+&return+1+&worklen
&totallen seta &totallen+&len
&i seta &i+1
aif &i<=c:&parms,^b
.e
tsc
aif &worklen=0,.f
sec
sbc #&worklen
tcs
.f
phd
tcd
mend

macro
&l return &r
&l anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
_ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
ldy #&r
ldx #^&r
ago .h
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+3
sta &worklen+&totallen+3
lda &worklen+1
sta &worklen+&totallen+1
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
plb
rtl
mend

macro
&l lreturn &r
&l anop
lclc &len
aif c:&r,.a
lclc &r
&r setc 0
&len setc 0
ago .h
.a
&len amid &r,2,1
aif "&len"=":",.b
&len amid &r,1,2
&r amid &r,4,l:&r-3
ago .c
.b
&len amid &r,1,1
&r amid &r,3,l:&r-2
.c
aif &len<>2,.d
_ldy &r
ago .h
.d
aif &len<>4,.e
ldx &r+2
ldy &r
ago .h
.e
aif &len<>10,.g
ldy #&r
ldx #^&r
ago .h
.g
mnote 'Not a valid return length',16
mexit
.h
aif &totallen=0,.i
lda &worklen+1
sta &worklen+&totallen+1
.i
pld
tsc
clc
adc #&worklen+&totallen
tcs
aif &len=0,.j
tya
.j
rts
mend

Loading

0 comments on commit 58ab674

Please sign in to comment.