Gameboy Color address bus

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
Monster704
Posts: 6
Joined: Tue Dec 03, 2013 11:51 am

Gameboy Color address bus

Post by Monster704 »

Hi there,
my friend and I are currently on a project for school. I don't want to get too much into details, but it's about a GPS and air pressure sensor module which sends the data to the gameboy.
Currently we have a simple circuit board, just an EPROM connected to the pins on the Gameboy (can be viewed on attachement).
We already coded some programs (simple games, color text, etc) with the Gameboy Code Editor and the GBDK and transferred it to the EPROM - worked like a charm.
Now comes the tricky part:
For our project, we need to access to the Address Bus (A0 - A15) via the program on the EPROM. That means, we have to be able to set a certain Address line (e.g. A1) to either 1 or 0.
We have been looking for hours, but still couldn't find some commands or hints. We would be very grateful if anyone could provide us some information :D
Many thanks in advance
Attachments
circuit board
circuit board
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Gameboy Color address bus

Post by tepples »

When you read or write an address that ends in 0, 1, 4, 5, 8, 9, C, or D, A1 becomes 0. When you read or write an address that ends in 2, 3, 6, 7, A, B, E, or F, A1 becomes 1.

But if you're trying to control a peripheral based on the address lines alone, remember that all low-order address lines will fluctuate based on reads from ROM and reads from and writes to RAM. You have to decode addresses by matching the values of several address lines at once. What are you trying to do by setting A1 to 0 or 1?
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Gameboy Color address bus

Post by lidnariq »

Monster704 wrote:For our project, we need to access to the Address Bus (A0 - A15) via the program on the EPROM. That means, we have to be able to set a certain Address line (e.g. A1) to either 1 or 0.
Are you saying that you want to use the address bus to both serve as what it is—an address bus—as well as 16 pins of GPIO?

Can't happen, sorry. The gameboy doesn't have the ability (unlike the GBA in ARM mode) to use the address bus as anything other than an 16-bit-address 8-bit-data bus, all the time.

Also, in your board, you really should connect GB /RD to ROM /OE, and GB A15 to ROM /CE. I'm surprised anything else works, since it should be bus conflicting all over the place as-is.

The Gameboy allows 40KiB of its 64KiB memory-address-ability to be used by the cartridge, the bytes from 0x0000 to 0x7FFF and 0xA000 through 0xBFFF. You should be able to add some number of 74'161 or 74'377 (or similar) to get up to 23 different GPIO lines, by connecting /WR and A15 to the latch IC's "CP" and "/E" or "/PE", and any 4 or more lines of A0..A14 D0..D7 to the latch IC's D0..D7. This would let your software write a value to anywhere in the lower 32KiB of memory to put some digital values on the latch outputs.
Monster704
Posts: 6
Joined: Tue Dec 03, 2013 11:51 am

Re: Gameboy Color address bus

Post by Monster704 »

First of all, I want to thank both of you.
tepples wrote:When you read or write an address that ends in 0, 1, 4, 5, 8, 9, C, or D, A1 becomes 0. When you read or write an address that ends in 2, 3, 6, 7, A, B, E, or F, A1 becomes 1.
And if I want A0 become 0 or 1?
tepples wrote:What are you trying to do by setting A1 to 0 or 1?
That is some kind of hard to explain. Our sensor module operates via a I²C bus, so we have to create certain states for the clock and data line of the I²C bus in order to either read or send data.
This invovle some logical operators (NOR, NAND, ...) to decode the address lines A0-A15. Unfortunately we cannot use an inverter, so we need to set some of the address lines (specifically A0 and A1) manually via the program to either 0 or 1 <<< this is required for the circuit with the logical operators.
I am not sure if I explained everything clearly since english is not my native language.
lidnariq wrote:Also, in your board, you really should connect GB /RD to ROM /OE, and GB A15 to ROM /CE. I'm surprised anything else works, since it should be bus conflicting all over the place as-is.
That's quite funny because our first board looked exactly like that and it did NOT work. OE on the IC is inverted, so it has to be set to GND to enable the output. Same goes with CE.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Gameboy Color address bus

Post by lidnariq »

Monster704 wrote:That is some kind of hard to explain. Our sensor module operates via a I²C bus, so we have to create certain states for the clock and data line of the I²C bus in order to either read or send data.
To add an I²C interface to the gameboy, you will want to memory-map a transceiver between the gameboy's Z80 style bus and the I²C side.
Unfortunately, I cannot find a one-or-two 74-series IC solution, although something could be built that used three. (Three: 1- A decoder to memory-map the other registers, 2- a two-or-more bit tristateable buffer to allow reading the status of the I²C lines, 3- a two-or-more bit open-collector latch to allow driving the I²C lines. If this is useful, I could make a schematic for you)
Alternatively, you could look into buying a standalone I²C USART such as the XR20M1280, or use a cheap microcontroller to the same end.
Monster704 wrote:
lidnariq wrote:Also, in your board, you really should connect GB /RD to ROM /OE, and GB A15 to ROM /CE. I'm surprised anything else works, since it should be bus conflicting all over the place as-is.
That's quite funny because our first board looked exactly like that and it did NOT work.
I can't figure out what GB /CE does, but certainly the reference cartridge here connects /RD and A15 as I said, as does a random cartridge I just opened.
Monster704 wrote:OE on the IC is inverted, so it has to be set to GND to enable the output. Same goes with CE.
I assure you that the outputs of the game boy are active low, same as the ROM. If it did not work for you, something else was going wrong.
Monster704
Posts: 6
Joined: Tue Dec 03, 2013 11:51 am

Re: Gameboy Color address bus

Post by Monster704 »

A schematic would be very helpful! Thank you.
Also, we have limited options for our components. Since our project is a degree work, we are not allowed to buy everything (e.g. the I²C USART). We have to come up with our own solutions...
lidnariq wrote:I assure you that the outputs of the game boy are active low, same as the ROM. If it did not work for you, something else was going wrong.
I will check that again.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Gameboy Color address bus

Post by lidnariq »

I'm a little wary of just providing you a solution if this is for your degree work; surely you should be proving you know how to design something here?

Anyway, here's a hint:
Use a 74'138. Connect /RD and /WR to A and B, and connect CPU A15..A13 (and optionally A12) to the other four inputs to be active when reading or writing from 0xA000 through (0xAFFF or 0xBFFF). Only two of the outputs will be useful.
Monster704
Posts: 6
Joined: Tue Dec 03, 2013 11:51 am

Re: Gameboy Color address bus

Post by Monster704 »

lidnariq wrote:I'm a little wary of just providing you a solution if this is for your degree work;
I appreciate your dutifulness :D
Anyway...you guys helped me a lot. Next week I will try out some of the things you told me. If I have some new questions or solutions I will post them here!
Post Reply