[emulation] hardware emulation trouble?

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

[emulation] hardware emulation trouble?

Post by King Harold »

Ok, so I wrote my own z80 core (everyone does that) and it seems to work alright, but the TI OS doesn't get very far which probably means that I'm emulating some hardware part incorrectly.. (it does not even turn the LCD on, the LCD works at least a bit though - tested with a custom rom, sometimes it makes some garbage, but TIOS leaves it disabled/off)
Could someone list some common pitfalls?

thanks
User avatar
benryves
Maxcoderz Staff
Posts: 3089
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

My biggest problems were getting the timer interrupts right (which I never did, the TIOS keeps locking up).

The first (and easiest) thing to check would be that your Z80 core works properly, before looking at more specific (and complicated) hardware issues.

SMS Power! have a version of ZEXALL (down at the bottom - ZEXALL is rather a misnomer, it's more like ZEXDOC as it only tests documented flags) that can output to an SDSC console. You can implement a very primitive SDSC console for testing, and simply emulate all memory as 64KB of RAM. I used this to develop my core, and it proved invaluable!
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

nice
thanks :)
Spencer
Extreme Poster
Posts: 346
Joined: Mon 17 Jan, 2005 8:56 am
Location: Indiana

Post by Spencer »

An accurate core was our last barrier I think. TIOS relies heavily on the bit operations on index registers, once those were fixed it wasn't a problem. It's never satisfying to code for index registers. I can't think of a way to handle index registers in a z80 core that doesn't feel like a hack.

The minimal set of hardware for TIOS is pretty small. IM 1 and related ports, memory controller, link port, and LCD. I might have forgot some.

http://svn.revsoft.org/wabbitemu/source ... re/83phw.c
(the tabs don't look too great in a browser)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

My index-regs also feel like a hack.. I use HL's property to switch it to IX or IY when those flags are true.
So I guess I'll debug my bit operations on index registers :)

And the link port, since I forgot that/left it out, maybe that's why it keeps looping.... (it's also showing execution in the 0x6XXX range, is that normal?)

Thank you too Spencer
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

nice! :)
Image Image Image
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Execution in 6xxx is definitely normal, that's the switchable rom page.
You know your hexadecimal output routine is broken when it displays the character 'G'.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Good point
seemed odd to me that it wasn't doing anything useful even though it was doing a lot..
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

What are you emulating, 83, 83+, SEs?

For the 83+:

The link port can will work with a register that returns an inverted value of what was written.

The key port can get away with 0xFF

Status can read 0x3B.

Port 3 just needs to be a register as bare minimum. As long as interrupts occur at a steady rate.

Port 4 needs to handle boot mapping. Frequency and what triggered an interrupt not required for TI-OS. ON key being pressed must be emulated.

Port 6 & 7 need to handle memory mapping.

LCD is optional, but you kinda need it to see.

Thats all thats needed to get ti-os running. If I remember correctly, the last big bug we had before ti-os ran as expected was that we forgot to emulate "DI". Out of all the instructions thats the one that we missed.
Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

I was trying a 83+
Thanx for the tips :)
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

My emulator had problems with ld bc,(nnnn) and ld (nnnn),bc having an incorrect address, and that made the TIOS (rightfully!) fail.
You may want to try the Bubble Bobble ROM to see if that works. (This is a TI83 OS, but the ports look like they should match up)
You know your hexadecimal output routine is broken when it displays the character 'G'.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

It hangs on 006A - 006B, does that indicate anything in particular?
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

Thats the interrupt. Once the z80 interrupts it disables interrupts so nothing recurses, you might have it so interrupts aren't disabled and therefore sticks to 006A.
Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Hm, I meant the Bubble Bobble ROM, or does it have the interrupt at the same place?
User avatar
Dwedit
Maxcoderz Staff
Posts: 579
Joined: Wed 15 Dec, 2004 6:06 am
Location: Chicago!
Contact:

Post by Dwedit »

Code: Select all

0092   005E             	;clear memory
0093   005E 21 00 80    	ld hl,$8000
0094   0061 11 01 80    	ld de,$8001
0095   0064 36 00       	ld (hl),0
0096   0066 01 FF 7F    	ld bc,$7FFF
0097   0069 ED B0       	ldir
0098   006B             	;copy appended program
0099   006B 11 27 93    	ld de,$9327
0100   006E 21 BB 00    	ld hl,end
0101   0071 01 00 6C    	ld bc,$6C00
0102   0074 ED B0       	ldir
Sounds like LDIR is broken.
You know your hexadecimal output routine is broken when it displays the character 'G'.
Post Reply