I do this by adding an inverted version of all glyphs in the upper range of the pattern memory. This is a big waste of the pattern space (only one inverted character is needed at once), but it's the simplest way to proceed. I'll change this if I ever need more pattern space. Also, remove _blank. It was wastefully blanking the whole memory. Only the name table needs to be blanked on initialization.master
@@ -16,8 +16,6 @@ CREATE _idat | |||||
0b00000000 C, 0x89 C, ( BG Y scroll ) | 0b00000000 C, 0x89 C, ( BG Y scroll ) | ||||
0b11111111 C, 0x8a C, ( Line counter (why have this?) ) | 0b11111111 C, 0x8a C, ( Line counter (why have this?) ) | ||||
( ----- 603 ) | ( ----- 603 ) | ||||
: _zero ( x -- send 0 _data x times ) | |||||
( x ) 0 DO 0 _data LOOP ; | |||||
( Each row in ~FNT is a row of the glyph and there is 7 of | ( Each row in ~FNT is a row of the glyph and there is 7 of | ||||
them. We insert a blank one at the end of those 7. For each | them. We insert a blank one at the end of those 7. For each | ||||
row we set, we need to send 3 zero-bytes because each pixel in | row we set, we need to send 3 zero-bytes because each pixel in | ||||
@@ -37,7 +35,8 @@ always stay zero. ) | |||||
( set palette bit for at specified pos ) | ( set palette bit for at specified pos ) | ||||
2 * 1+ 0x7800 OR _ctl 0x8 _data ; | 2 * 1+ 0x7800 OR _ctl 0x8 _data ; | ||||
: VDP$ | : VDP$ | ||||
9 0 DO _idat I 2 * + @ _ctl LOOP _blank | |||||
9 0 DO _idat I 2 * + @ _ctl LOOP | |||||
( blank screen ) 0x7800 _ctl COLS LINES * 2 * _zero | |||||
( palettes ) | ( palettes ) | ||||
0xc000 _ctl | 0xc000 _ctl | ||||
( BG ) 1 _zero 0x3f _data 14 _zero | ( BG ) 1 _zero 0x3f _data 14 _zero | ||||
@@ -29,7 +29,7 @@ CURRENT @ XCURRENT ! | |||||
283 335 LOADR ( boot.z80 ) | 283 335 LOADR ( boot.z80 ) | ||||
353 LOAD ( xcomp core low ) | 353 LOAD ( xcomp core low ) | ||||
CREATE ~FNT CPFNT5x7 | CREATE ~FNT CPFNT5x7 | ||||
470 472 LOADR ( VDP ) | |||||
470 472 LOADR ( TMS9918 ) | |||||
402 404 LOADR ( Grid ) | 402 404 LOADR ( Grid ) | ||||
625 626 LOADR ( SMS ports ) | 625 626 LOADR ( SMS ports ) | ||||
620 LOAD ( PAD ) : (ps2kc) (ps2kcA) ; 411 414 LOADR | 620 LOAD ( PAD ) : (ps2kc) (ps2kcA) ; 411 414 LOADR | ||||
@@ -2780,28 +2780,31 @@ CODE _data | |||||
A L LDrr, TMS_DATAPORT OUTiA, | A L LDrr, TMS_DATAPORT OUTiA, | ||||
;CODE | ;CODE | ||||
( ----- 471 ) | ( ----- 471 ) | ||||
CODE _blank ( this is way too slow in Forth ) | |||||
A XORr, TMS_CTLPORT OUTiA, | |||||
A 0x40 LDri, TMS_CTLPORT OUTiA, | |||||
HL 0x4000 LDdi, | |||||
BEGIN, | |||||
A XORr, TMS_DATAPORT OUTiA, | |||||
HL DECd, HLZ, | |||||
JRNZ, AGAIN, | |||||
;CODE | |||||
( ----- 472 ) | |||||
: _zero ( x -- send 0 _data x times ) | |||||
( x ) 0 DO 0 _data LOOP ; | |||||
( Each row in ~FNT is a row of the glyph and there is 7 of | ( Each row in ~FNT is a row of the glyph and there is 7 of | ||||
them. We insert a blank one at the end of those 7. ) | them. We insert a blank one at the end of those 7. ) | ||||
: _sfont ( a -- Send font to TMS ) | : _sfont ( a -- Send font to TMS ) | ||||
7 0 DO C@+ _data LOOP DROP | 7 0 DO C@+ _data LOOP DROP | ||||
( blank row ) 0 _data ; | ( blank row ) 0 _data ; | ||||
: _sfont^ ( a -- Send inverted font to TMS ) | |||||
7 0 DO C@+ 0xff XOR _data LOOP DROP | |||||
( blank row ) 0xff _data ; | |||||
: CELL! ( c pos ) | : CELL! ( c pos ) | ||||
0x7800 OR _ctl ( tilenum ) | 0x7800 OR _ctl ( tilenum ) | ||||
0x20 - ( glyph ) 0x5e MOD _data ; | 0x20 - ( glyph ) 0x5e MOD _data ; | ||||
( ----- 472 ) | |||||
: CURSOR! ( new old -- ) | |||||
0x7800 OR DUP _ctl [ TMS_DATAPORT LITN ] PC@ | |||||
0x7f AND ( new cmd glyph ) SWAP _ctl _data | |||||
0x7800 OR DUP _ctl [ TMS_DATAPORT LITN ] PC@ | |||||
0x80 OR ( cmd glyph ) SWAP _ctl _data ; | |||||
: COLS 40 ; : LINES 24 ; | : COLS 40 ; : LINES 24 ; | ||||
: TMS$ | : TMS$ | ||||
0x8100 _ctl ( blank screen ) _blank | |||||
0x8100 _ctl ( blank screen ) | |||||
0x7800 _ctl COLS LINES * _zero | |||||
0x4000 _ctl 0x5e 0 DO ~FNT I 7 * + _sfont LOOP | 0x4000 _ctl 0x5e 0 DO ~FNT I 7 * + _sfont LOOP | ||||
0x4400 _ctl 0x5e 0 DO ~FNT I 7 * + _sfont^ LOOP | |||||
0x820e _ctl ( name table 0x3800 ) | 0x820e _ctl ( name table 0x3800 ) | ||||
0x8400 _ctl ( pattern table 0x0000 ) | 0x8400 _ctl ( pattern table 0x0000 ) | ||||
0x87f0 _ctl ( colors 0 and 1 ) | 0x87f0 _ctl ( colors 0 and 1 ) | ||||