1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:58:06 +11:00

sms: fix cursor mis-display in text mode

In CURSOR!, I was using a write commande to read from VRAM and the
emulator didn't properly behave and did as if everything was fine.

The result on a real SMS was that the cursor would contain the
inverted glyph of the contents of the *old* cursor position.
This commit is contained in:
Virgil Dupras 2020-11-16 13:10:04 -05:00
parent c8be290b88
commit 57fd14b0b3
3 changed files with 13 additions and 10 deletions

11
blk.fs
View File

@ -2769,7 +2769,8 @@ CODE TICKS 1 chkPS, ( n=100us )
( ----- 470 )
( Z80 driver for TMS9918. Implements grid protocol. Requires
TMS_CTLPORT, TMS_DATAPORT and ~FNT from the Font compiler at
B520. Load range B470-472 )
B520. Patterns are at addr 0x0000, Names are at 0x3800.
Load range B470-472 )
CODE _ctl ( a -- sends LSB then MSB )
HL POP, chkPS,
A L LDrr, TMS_CTLPORT OUTiA,
@ -2795,10 +2796,10 @@ them. We insert a blank one at the end of those 7. )
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 ;
DUP 0x3800 OR _ctl [ TMS_DATAPORT LITN ] PC@
0x7f AND ( new old glyph ) SWAP 0x7800 OR _ctl _data
DUP 0x3800 OR _ctl [ TMS_DATAPORT LITN ] PC@
0x80 OR ( new glyph ) SWAP 0x7800 OR _ctl _data ;
: COLS 40 ; : LINES 24 ;
: TMS$
0x8100 _ctl ( blank screen )

View File

@ -27,6 +27,7 @@ void tms_init(TMS9918 *tms)
memset(tms->regs, 0, 0x10);
tms->has_cmdlsb = false;
tms->curaddr = 0;
tms->databuf = 0;
tms->width = 40*6;
tms->height = 24*8;
}
@ -50,20 +51,20 @@ void tms_cmd_wr(TMS9918 *tms, uint8_t val)
} else {
// VRAM
tms->curaddr = ((val&0x3f) << 8) + tms->cmdlsb;
if ((val & 0x40) == 0) { // reading VRAM
tms->databuf = tms->vram[tms->curaddr];
}
}
}
uint8_t tms_data_rd(TMS9918 *tms)
{
if (tms->curaddr < TMS_VRAM_SIZE) {
return tms->vram[tms->curaddr++];
} else {
return 0;
}
return tms->databuf;
}
void tms_data_wr(TMS9918 *tms, uint8_t val)
{
tms->databuf = val;
if (tms->curaddr < TMS_VRAM_SIZE) {
tms->vram[tms->curaddr++] = val;
}

View File

@ -13,6 +13,7 @@ typedef struct {
uint8_t cmdlsb;
bool has_cmdlsb;
uint16_t curaddr;
uint8_t databuf;
uint16_t width; // in pixels
uint16_t height; // in pixels
} TMS9918;