It is currently Mon Dec 18, 2017 2:17 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Basic MBC interface?
PostPosted: Wed Aug 25, 2010 11:53 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
I've got a gameboy cartridge connector attached to an arduino and I'm having some problems. I can get the game's name from 0x0134 and read up to 0x4000, but I can't switch banks or read RAM.

I think my problem is that I'm not understanding the documents about the MBCs. They are all from the point of view of a gameboy and I don't know what addresses are gameboy specific ports.

On some MBC1 games, if I read from 0x4000 I get garbage. If I write anything to 0x2000 and then read 0x4000, I get data from 0x#C000. The most significant part of the address changes from game to game.

I know it's not easy to debug from that. So, if someone could give me non-gameboy specific instructions I could at least rule some things out.

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 2:39 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
For the purposes of GB bankswitching, nothing is internal to the gameboy. They are all addresses in the cartridge ROM area of the memory map. (0000-7FFF)

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 9:53 am 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2806
Are you aware of MBC1's "Mode" setting at $6000?

If Mode is 0, $0000 shifted left 5 places combines with what you write to $2000 for the ROM Bank that appears at $4000 - $7FFF. If Mode is 1, just $2000 is used for ROM Bank and $4000 selects a Cartridge RAM Bank.

Hope that helps. Oh one more thing, MBC1 cannot select Bank 0 to appear at $4000-$7FFF. If you try, it will effectively be changed to show Bank 1 the second bank in rom.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 11:01 am 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
Dwedit wrote:
For the purposes of GB bankswitching, nothing is internal to the gameboy. They are all addresses in the cartridge ROM area of the memory map. (0000-7FFF)

Ok, that's good to know. One document showed a gameboy memory map and I got frightened.


MottZilla are you referring to this?
Quote:
The MBC1 defaults to 16Mbit ROM/8KByte RAM mode
on power up. Writing a value (XXXXXXXS - X = Don't
care, S = Memory model select) into 6000-7FFF area
will select the memory model to use. S = 0 selects
16/8 mode. S = 1 selects 4/32 mode.


I tried writing all 256 values to 0x2000 after setting 4/32 mode, but I never read different data. On a 128K game I should read new data multiple times right? Assuming they didn't repeat things at different addresses.

Maybe I just swapped some address lines or something.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 11:07 am 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2806
Well, 4 mbit would be 512kb. Gives you 32 banks. 16 mbit would be 2048kb and gives you 128 banks. I'm not sure if any MBC1 game is really that big.

I would definitely double check your wiring. Although if MBC3/MBC5 carts read back fine I'm not sure.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 11:19 am 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
Well I never get new data much less multiple.
I never said I got MBC3/5 working. I just detailed how MBC1 wasn't working. :P

EDIT: The wiring looks fine.

What else could be wrong? Timing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 3:25 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
I found a Donkey Kong Land III cart to play with. My cart reader detects it as this:

Code:
DONKEYKONGLAND
Cart Type: 3 : ROM+MBC1+RAM+BATT
ROM Size: 4 : 512KByte
RAM Size: 2 : 8KByte


I have played and saved multiple games to it. So the RAM isn't blank.

I've written 0x01 to 0x6000; 0x00 to 0x4000 and 0x0A to 0x0000.
I set WR=1, RD=0, CS=0 then I read from 0xA000 to 0xBFFF. With pull up resistors I get all 0xFF. Without I get long strings of the same few numbers.
This same process works perfectly for addresses 0x0000-0x3FFF.

What am I missing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 4:36 pm 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2806
I'm not sure that you are missing anything from the GB MBC register angle. Perhaps your error is related to something else.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 5:54 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
Nothing to see here. Now move along.


Last edited by Skidlz on Thu Aug 26, 2010 6:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 6:21 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
I deleted the post because I realized I was being stupid, you were trying to read SRAM, not ROM.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 6:24 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
Well I'm sorry I brought your post back from the dead then. I'll go remove it.

I bet if I could bankswitch ROM I'd be a lot closer to reading RAM. Any thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 6:35 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
Pull up a copy of Pandocs or something, that has lots of nice information about the GB's mappers.

Looks like the sequence for reading the SRAM is:

Ram Enable: write 0A to 0000

And that's probably all you need to do to enable the SRAM.
I don't think you need to do 6000 = 01 or 4000 = 00, because you aren't switching the 8K ram page to something else, so you'd just see mirrors of the same ram regardless of what page is selected. But selecting page 0 shouldn't hurt either.

But that's also exactly what you did. So I have no clue why it's not working. What clock speed are you accessing the RAM at?

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 6:44 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
Oooh pretty document! More coherent that what I've been reading.

The clock speed of the arduino board is 16MHz but I don't have a way to count cycles as it's in pseudo-C.
I scattered in some 1 micro second delays and put two 10 microsecond delays in the write loop. I know that's probably orders of magnitude more time than it needs but I wanted to be sure. You can't run too slowly can you?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2010 11:30 pm 
Offline
User avatar

Joined: Sun Nov 11, 2007 5:24 pm
Posts: 50
I got it to work! I was trying to be crafty and have my shift register's clock and WR on the same GPIO. I split them up and it started working.

Thanks for input everyone. It helped narrow down where to look for problems.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2010 10:32 am 
Offline
User avatar

Joined: Wed Dec 06, 2006 8:18 pm
Posts: 2806
Glad to hear you got it working. And also that it wasn't a MBC register issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group