What's new

Game Boy

bcrew1375

New member
If you mean the joypad register, I have a rough idea of how it works(I got the Start button working :p).

Here's an extract from one of the documents:

FF00
Name - P1
Contents - Register for reading joy pad info
and determining system type. (R/W)

Bit 7 - Not used
Bit 6 - Not used
Bit 5 - P15 out port
Bit 4 - P14 out port
Bit 3 - P13 in port
Bit 2 - P12 in port
Bit 1 - P11 in port
Bit 0 - P10 in port

This is the matrix layout for register $FF00:


P14 P15
| |
P10-------O-Right----O-A
| |
P11-------O-Left-----O-B
| |
P12-------O-Up-------O-Select
| |
P13-------O-Down-----O-Start
| |

These are all reversed(0 means on, 1 means off). If bit 5 is 0, that means P15 has been turned on. If P15 is turned on, you take the corresponding buttons and put their on/off status in the appropriate bit.

For instance, if I pressed the Start button and P15 was off. I would turn off the P13 bit(remember, off means on). If I pressed Down while P14 was turned off, the P13 bit would also be turned off. The programs can only get the status of 4 buttons at a time. They usually turn on P15, get the keys, then turn on P14, get the keys, and then combine them. This is how I understand it as of right now. There is also an interrupt that is called, I think it's when P10-P13 change.
 
Last edited:

aprentice

Moderator
I got sprites almost completely done, theres just a bug somewhere that makes some sprites a little screwy (as you can see in the image below).
I also didnt implement priorities or a sprite limiter yet, so 40 sprites could show on the screen at once if they wanted to, but this will be easy to add.

Input however is messed up, I just can't seem to get it right, but
its enough to get into the game, but not to play :p

tetris_sprite.gif

zelda_sprite02.gif

zelda_sprite01.gif
 
Last edited:

bcrew1375

New member
Well, I just got through switching around some of the interrupts. I'm now having the same inverted colors problem you were having :p.
 

aprentice

Moderator
bcrew1375 said:
Well, I just got through switching around some of the interrupts. I'm now having the same inverted colors problem you were having :p.

Make sure you request a vblank interrupt right at the beginning of the vblank period. That should fix your problem almost indefinately :p
 

bcrew1375

New member
I'm doing it immediately after the LY register hits 144. Alot of games seem to be going farther now that I fixed the LCDC interrupt. Unfotunately, the graphics are distorted because of whatever I'm doing wrong :/.
 

aprentice

Moderator
bcrew1375 said:
I'm doing it immediately after the LY register hits 144. Alot of games seem to be going farther now that I fixed the LCDC interrupt. Unfotunately, the graphics are distorted because of whatever I'm doing wrong :/.

distorted graphics aren't caused by interrupts, its caused by cpu bugs in most cases, i'd look over some of your opcodes if i were you. You'd be surprised at the supidest mistakes you can make, I know i was :p
 

bcrew1375

New member
I would agree with you except the games ran right for the most part until I changed the way interrupts are handled. I also added the LCDC interrupt which is probably the main cause.
 

aprentice

Moderator
zenogais said:
Well, I've begun work on my Gameboy emulator. Its not very far atm, but you can check it out here.

cool, great to see another person working on a gameboy emu, I was beginning to think it was just me and bccrew (with the rest of the people disappearing) :p

Keep us up to date on the progress, I need something to read :p
 

glVertex3f

Crap Cracker
You guys are making my mouth water.... I think i'll embark on this journey if I ever get my Chip 8 emu done. Ofcourse i'll be behind again though :)
 

zenogais

New member
Do you guys both already have completed CPU cores? Just curious how you guys dealt with the endianess issues, I'm using macros atm.
 

bcrew1375

New member
Well, I don't think you could call them "complete." Mine definitely has some bugs to work out. The endian-ness, I basically deal with it whenever I need to. Such as: register = ((memory[PC + 1]) << 8) + memory[PC];

BTW, I solved my problem. It had nothing to do with the interrupts. I was accidently denying writes to the display RAM under certain conditions, which was un-needed -_-.
 
Last edited:

zenogais

New member
bcrew1375 said:
Well, I don't think you could call them "complete." Mine definitely has some bugs to work out. The endian-ness, I basically deal with it whenever I need to. Such as: register = ((memory[PC + 1]) << 8) + memory[PC];

Ah right, I just have a predefined macro for dealing with it, so for me that would be:

Code:
register = SWAP_WORD( readMemory16(PC) );

where swap word is defined like so

Code:
#if defined (_HIGH_ENDIAN_)

/// A macro which swaps the least significant byte and most significant byte of a 16-bit word.
#define SWAP_WORD(word) word = (word>>8) | (word<<8)

#else // !defined (_HIGH_ENDIAN_)

#define SWAP_WORD(word)

#endif // _HIGH_ENDIAN_

This way I can just define a preprocessor flag for HIGH_ENDIAN systems (Intel and AMD) and swap the bytes around, or on naturally low endian systems not do anything, this is for a bit more cross-platform compatability. Also, out of curiosity, what are you guys using for graphics? I was planning on using DirectX 9, because I wanna learn how to use the API, but I still might stick with SDL.
 

bcrew1375

New member
SDL for me. I'm still having trouble getting sprites to show. It's strange, the blocks will appear in Tetris after they hit the bottom of the well, but nothing else shows any sprites.
 

zenogais

New member
bcrew1375 said:
SDL for me. I'm still having trouble getting sprites to show. It's strange, the blocks will appear in Tetris after they hit the bottom of the well, but nothing else shows any sprites.

hmm, maybe thats because when it hits the bottom it gets drawn as part of the background?
 

bcrew1375

New member
Oh, hehe :blush:. Well, that was kinda stupid. It does indeed become part of the background once it hits the bottom of the well :p.
 

aprentice

Moderator
bcrew1375 said:
Oh, hehe :blush:. Well, that was kinda stupid. It does indeed become part of the background once it hits the bottom of the well :p.

I use direct draw for gfx and my cpu is complete :p

What I have done so far:

- All CPU Instructions
- Debugger w/ disassembler & logger
- Background GFX
- 90% complete sprite emulation
- SRAM/PRG Banking
- Complete MBC1
- Buggy Controllers
- Timer w/ TAC Freq control
- DIV register
- OBJ0,OBJ1,BG palettes
- 95% complete interrupt system (missing bounce interrupt)

If you guys need help with any of this, feel free to ask :p
 
Last edited:

aprentice

Moderator
bcrew1375 said:
BTW, aprentice, when did you start work on yours?

I've been working on it on and off the last 2 months, in the past 2 weeks I've made the most progress. How about you?
 

Top