Reading from the LCD - emulators get it wrong

A General Discussion forum for TI calculators

Moderator: MaxCoderz Staff

Post Reply
Goplat
New Member
Posts: 12
Joined: Mon 16 Jul, 2007 2:46 pm

Reading from the LCD - emulators get it wrong

Post by Goplat »

It's well known that when reading LCD data from port $11, you have to do an extra "dummy read" first before you can start getting the actual data you want. Emulators just return 0 for this dummy read (or 17 on wabbitemu). But on my calc I've found I can get it to return any value I want. It looks like the dummy read is, to the LCD driver, just like any other read - but whenever you read from port $11, it reads from the current coordinates, but returns the value of the previous read.

Here's the program I used for testing. It displays 170 ($AA) on a real TI-83+.

Code: Select all

	di
	b_call($42B5)	; set X-increment mode

	call	top
	ld	a,$aa
	out	($11),a
	call	top
	in	a,($11)	; reads $aa, sends previous read to CPU

	call	top
	ld	a,$ff
	out	($11),a
	call	top
	in	a,($11) ; reads $ff, sends $aa to CPU

	ld	h,0
	ld	l,a
	b_call(_DispHL)
	ei
	ret
top:	call	$000b
	ld	a,$20
	call	$+5
	ld	a,$80
	out	($10),a
	jp	$000b
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Post by Spencer »

I've modified Wabbitemu to return a value according to your findings. Who can verify the other models?
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Wow, that was the way I designed my emulator's LCD (just save the last value read and read that next time), not only is it the simplest way to emulate the requirement of the garbage read, it also turns out to be the correct way to do it!
You know your hexadecimal output routine is broken when it displays the character 'G'.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

Dwedit wrote:Wow, that was the way I designed my emulator's LCD (just save the last value read and read that next time), not only is it the simplest way to emulate the requirement of the garbage read, it also turns out to be the correct way to do it!
Of course it makes sense, since that makes the simplest circuit in reality too. For instance, only when I wrote my own Z80 core I understood why the byte order for DDCB/FDCB instructions defines the opcode of the actual operation to come after the relative address (just like above, it saves a register in the circuit).
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Well, I would have thought it would have returned the last byte either read from or written to, not just read from.
You know your hexadecimal output routine is broken when it displays the character 'G'.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

Interesting find Goplat, and welcome to the forums btw :).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
Post Reply