What's new

Game Boy

bcrew1375

New member
refraction: Alot of instructions rely on the last instruction, H and N are assigned values, but never seem to be evaluated, only Z and C. Once I get most things working correctly, I think I'll try not altering the H and N flags, and see what happens.

glVertex3f: The x86 and GB z80 both use little-endian. That means with 16-bit or higher numbers, the lowest byte is stored first. For example: If you have the number 0x7965. In little endian, this would be stored as 65 79.
 
Last edited:

GbaGuy

New member
H and N are used by the DAA instruction.

A game could always do
PUSH AF
POP HL
and then look at L if it really wanted to :)
 

glVertex3f

Crap Cracker
bcrew1375 said:
The x86 and GB z80 both use little-endian. That means with 16-bit or higher numbers, the lowest byte is stored first. For example: If you have the number 0x7965. In little endian, this would be stored as 65 79.

Ok, so you only need to worry about this if you want your emu to be portable onto High endian.

btw, bcrew.. those docs you posted are EXTREMELY useful. ggs :icecream:
 

aprentice

Moderator
Heres some motivation for you gameboy coders out there :p

zelda_la01.gif

zelda_la02.gif


Edit: Forgot to mention I added zip support :p
 
Last edited:

bcrew1375

New member
Well, I finally nailed my problem(even though I'm still not sure what it was :p). Zelda now goes in game, as well as Metroid 2. Both appear to be fully playable, except I'm still having some window display problems.
 

zenogais

New member
Hehe, I've been procrastinating on my Gameboy emu, haven't worked on it since Doom 3 came out :p
 
Last edited:

aprentice

Moderator
zenogais said:
Hehe, I've been procrastinating on my Gameboy emu, haven't work on it since Doom 3 came out :p

don't let doom 3 consume you, fight the urge! :p
I haven't played doom 3 on the other hand, so im safe :p
 

bcrew1375

New member
I haven't seen the game(I'm actually not even interested). Though, my cousin says it has an option that even the most high-end computers can't handle.
 

glVertex3f

Crap Cracker
A few quick questions,

When an op-code wants you to load a register with a 16bit integer, I assume that you get that integer from the current position in memory right?

and

LD (r16), A

Do you just simply load the value of A into the 16bit register?

I know these questions may sound simple but i Just want to make sure about these couple of things.
 

bcrew1375

New member
If it has parentheses, such as (r16), that means store the right operand in memory at the location held in the left operand. So, assuming:

A = 0x16
HL = 0x8000

After the instruction "LD (HL), A", memory location 0x8000 would hold the value 0x16.
 

aprentice

Moderator
glVertex3f said:
A few quick questions,

When an op-code wants you to load a register with a 16bit integer, I assume that you get that integer from the current position in memory right?

and

LD (r16), A

Do you just simply load the value of A into the 16bit register?

I know these questions may sound simple but i Just want to make sure about these couple of things.

I'm gonna keep this post short and sweet, and I hope you won't ask us anymore rediculously easy question after this one, because we aren't going to help you code this emu one line at a time (chip8 comes to mind).

LD (r16),A is basically writing 8 bit register a to a 16 bit address.

Example: mem_write8(mem_read16(regPC),regA);

Edit: bccrew beat me to it :p
 

glVertex3f

Crap Cracker
Thank you,

And I didnt need people to help me write ChipAte one line at a time.
Yes of course I needed help, it was the first time I had ever done emulation and alot of the things that I was doing were very new to me.

Anyways, I'll try not to ask any more simple questions, I usually ask before I think anyway :p
 

bcrew1375

New member
Well, I appear to have solved my window display problem. Now I think I'll go for reconfigurable input, but I'm still not quite sure how to approach it :/. I really want to start using my joypad, the keyboard is starting to get annoying. I could just hardcode it for my joypad, but why not make it reconfigurable for anything :p.
 

aprentice

Moderator
bcrew1375 said:
Well, I appear to have solved my window display problem. Now I think I'll go for reconfigurable input, but I'm still not quite sure how to approach it :/. I really want to start using my joypad, the keyboard is starting to get annoying. I could just hardcode it for my joypad, but why not make it reconfigurable for anything :p.

nice job :p How are you planning to approach sound? Thats suppose to be a nightmare. I don't think i'll touch sound for a long time, and not cause of the gameboy, but because direct sound just looks plain scary :p
 

zenogais

New member
aprentice said:
nice job :p How are you planning to approach sound? Thats suppose to be a nightmare. I don't think i'll touch sound for a long time, and not cause of the gameboy, but because direct sound just looks plain scary :p

DirectSound isn't so bad, but honestly coming from a bit of sound emulation experience, I'd use something like FMOD, its much easier to perform sound emulation tasks using this library. Really though, FMOD works no different than DirectSound, I just found it easier.
 

aprentice

Moderator
zenogais said:
DirectSound isn't so bad, but honestly coming from a bit of sound emulation experience, I'd use something like FMOD, its much easier to perform sound emulation tasks using this library. Really though, FMOD works no different than DirectSound, I just found it easier.

maybe you will be able to help us when we decide to do sound, I don't come from a sound background, and have never really used sound at all in my programming experience :p

is FMOD hard to settup like direct sound? Also, its gonna need to support some sort of streaming since i assume we are gonna have to stream WAVE data generated by the cpu somehow :p

edit: also bccrew, the answers to your question about half carry and negative :p

Bit/Flag/Name/Use
6 n - - Add/Sub-Flag (BCD)
5 h - - Half Carry Flag (BCD)

Found that in another doc i was looking in :p
 

glVertex3f

Crap Cracker
I am so sorry for posting again..
(If you want I'll start my own thread if im disrupting progress)

I just want to make sure I am doing this right before I continue
(No, this isnt something im gonna do on every op-code)

Code:
void ADC_A_HL()
{
	
	unsigned char carry_flag = ((gbReg.F & gbReg.CF) >> 4)
	unsigned char temp_value = gbMemory[gbReg.HL];
	
	gbReg.A += (temp_value + carry_flag);
	
	if(gbReg.A == 0)  SetFlag(gbReg.ZF, 7);
	if(gbReg.A > 15)  SetFlag(gbReg.HF, 5);
	if(gbReg.A > 255) SetFlag(gbReg.CF, 4);
	
	ResetFlag(gbReg.NF, 6);
	
}

gbReg.CF is 0x10, and the SetFlag functions, the first argument is the Flag to be set and the second argument is the bit number.

Now, if this is wrong, I appologize again.. I just need to be pointed in the right direction :eek:
 
Last edited:

bcrew1375

New member
Um, flags are all one bit. You shouldn't need to specify a bit to turn or off, only the flag you're going to turn off or on. Also, the A register and all the other 8-bit registers are all modulated by 255.
 
Last edited:

zenogais

New member
FMOD takes about 5-10 lines to set up depending if you want error checking, and how much detail you want about the error. Of course, it has support for streaming, or else it would even be a decent audio library. The best thing about it is that streaming is very simple. If you look at the PS2SP sources, you'll that I wrote a small wrapper for FMOD, I'm currently working on an updated much cleaner version of the wrapper that I'll be using on my Gameboy Emulator. FMOD is basically a wrapper library, one of the things it wraps being DirectSound.
 

Top