What's new

Game Boy

Greevy

Resident Emusician
Hey guys pretty good progress on your emulators ! :)

One of the most interesting thread I've read in a while. Frankly.
 

glVertex3f

Crap Cracker
I finally decided to get back to work on my emu,

A really easy question here (sorry aprentice! :) )
Since there are no opcodes for drawing.. I assume it is done through interrupts?
So, a certain interrupt will occur every few loops, and you draw the screen when the interrupt occurs?
 

aprentice

Moderator
glVertex3f said:
I finally decided to get back to work on my emu,

A really easy question here (sorry aprentice! :) )
Since there are no opcodes for drawing.. I assume it is done through interrupts?
So, a certain interrupt will occur every few loops, and you draw the screen when the interrupt occurs?

you draw the screen when LY hits 144.
 

glVertex3f

Crap Cracker
Oh, snap and fo shizzle.... I guess I missed that in the docs... argh.. I feel like I have a frekin learning disorder sometimes I swear.

Thank you aprentice.
 

zenogais

New member
Here's the quote from GB.pdf page 55:

"The LY can take on any value between 0 through 153. The values between 144 and 153 indicate the V-Blank period."
 

glVertex3f

Crap Cracker
Ow wow, you spoil me.... now I dont have to find it myself YAY!

If you were a chick i'd kiss you!

Or, not... cuz that sounds wierd and stuff...
 

aprentice

Moderator
Not much activity going on with this thread lately, besides glVertex posting and deleting his posts :p

Anyway, I'd like to hear a summary of everyones status, just cause im bored (and curious) :p

Ive been pretty lazy the past week, so I haven't done much work, but I have added huge cpu optimizations, fps counter, and support for 16,24, and 32 bit modes :p

Heres my emus status:

- Full Z80 CPU emulation
- MBC 1, 2, 5 implamented
- VRAM/WRAM/PRG/SRAM Banking
- Save State/Battery Pak Support
- DIV/TAC/TIMA Timers
- Full Input Support
- GBC Palette Support (for BG)
- CPU Speed Switching (for GBC)
- Zip Support
- Incomplete GBC DMA emulation

Edit: Also, i'd like to hear about some optimization techniques you guys have used to make your emulator faster :p
 

smcd

Active member
My progress is, I've still not started. :p School & work are keeping me tied up something fierce, so until it settles down, no time for fun stuff, unfortunately. I'm taking a class in C# this semester so it might be interesting to learn C# better while being the first to do an emulator in C# (that I'm aware of, if there are some in existence in C# already let me know?). Though I'll probably just do a chip8 in C# since I don't know it so well yet.
 

glVertex3f

Crap Cracker
Heh, the reason I deleted my post is that for somereason my picture disapeared...

I figured that a mod took it out because of the rom name and stuff.

But heres my progress.

I have done all the opcodes (I'll probably have to redo them)
I have implemented a rom info Dialog and I am working on a debug dialog.

I am also reading various docs about the LCDC and how it works. I would love to get some actual visual progression.

But other than that Ive been playing around with the tile format.. (the 'A' example in the docs) Havent figured out the nintendo logo yet... :p
 

aprentice

Moderator
glVertex3f said:
Heh, the reason I deleted my post is that for somereason my picture disapeared...

I figured that a mod took it out because of the rom name and stuff.

But heres my progress.

I have done all the opcodes (I'll probably have to redo them)
I have implemented a rom info Dialog and I am working on a debug dialog.

I am also reading various docs about the LCDC and how it works. I would love to get some actual visual progression.

But other than that Ive been playing around with the tile format.. (the 'A' example in the docs) Havent figured out the nintendo logo yet... :p

noone removed your picture, you had it hosted on your own server, so your server must have been down at that time. I thought you removed it cause you got embarassed about loving pokemon games :p
 

glVertex3f

Crap Cracker
rofl, Thats the only rom I could find.. Well, I had that and tetris but the tetris was a fakie.

And actually in their time those pokemon games were really good. I bet I invested over 600 hours into those babies...


I had the image hosted at ImageShack. Its done that to me a couple of times now.. guess i'll have to go somewhere else :p
 

bcrew1375

New member
My current progress... Well, I'm still trying to find bugs in the CPU emulation, alot of games have really strange errors. What was the opcode giving you problems, aprentice? Maybe mine is the same one :p. Anyway, I've been kind of lazy lately, so just trying to kink some bugs out every once in a while. About optimization, I'm favoring readability over speed. There are plenty of fast Gameboy emulators, but I don't think I've seen one with source that is easy on the eyes, at least not to me :p.
 

aprentice

Moderator
bcrew1375 said:
My current progress... Well, I'm still trying to find bugs in the CPU emulation, alot of games have really strange errors. What was the opcode giving you problems, aprentice? Maybe mine is the same one :p. Anyway, I've been kind of lazy lately, so just trying to kink some bugs out every once in a while. About optimization, I'm favoring readability over speed. There are plenty of fast Gameboy emulators, but I don't think I've seen one with source that is easy on the eyes, at least not to me :p.

The opcodes that gave me problems where the shift right and left, at that time, i misunderstood what to do with the flags etc and it caused problems, when i fixed that, problems were gone, if you want, paste those opcodes and i'll have a look at them, i've went over those opcodes with a fine needle, and even threw situations at them and traced em to death till I knew it was 100% accurate :p

Right now, the compat in my emu is like 90% games playable for mbc1, since about 9 out of 10 games i threw at it worked :p I think i may have a bug somewhere in my emu still that i haven't caught onto yet.
 

bcrew1375

New member
Well, I don't know if there is a problem with them or not, but here they are:

Code:
void z80_SLA_reg8(unsigned char *reg)
{
	// Put *reg's old bit 7 data in Carry flag.
	if (*reg & 0x80)
		regs.F |= FLAG_C_ON;
	else
		regs.F &= FLAG_C_OFF;

	// Shift *reg left once.  0 is shifted in from right.
	*reg <<= 1;

	// If the result was 0, set flag Z, otherwise reset it.
	if (*reg == 0)
		regs.F |= FLAG_Z_ON;
	else
		regs.F &= FLAG_Z_OFF;

	// Flags H and N are reset.
	regs.F &= (FLAG_Z_ON | FLAG_C_ON);

	// Machine cycles used is dependant on opcode.
	if (opcode == 0x26)
		cycles += 4;
	else
		cycles += 2;
}

void z80_SRA_reg8(unsigned char *reg)
{
	// Put *reg's old bit 0 data in Carry flag.
	if (*reg & 0x01)
		regs.F |= FLAG_C_ON;
	else
		regs.F &= FLAG_C_OFF;

	// Shift *reg right once.  0 is shifted in from left.  If bit 7
	// is set, make sure it stays set.
	if (*reg & 0x80)
		*reg = (*reg >> 1) + 0x80;
	else
		*reg >>= 1;

	// If the result was 0, set flag Z, otherwise reset it.
	if (*reg == 0)
		regs.F |= FLAG_Z_ON;
	else
		regs.F &= FLAG_Z_OFF;

	// Flags H and N are reset.
	regs.F &= (FLAG_Z_ON | FLAG_C_ON);

	// Machine cycles used is dependant on opcode.
	if (opcode == 0x2E)
		cycles += 4;
	else
		cycles += 2;
}

void z80_SRL_reg8(unsigned char *reg)
{
	// Put *reg's old bit 0 data in Carry flag.
	if (*reg & 0x01)
		regs.F |= FLAG_C_ON;
	else
		regs.F &= FLAG_C_OFF;

	// Shift *reg right once.  0 is shifted in from right.
	*reg >>= 1;

	// If the result was 0, set flag Z, otherwise reset it.
	if (*reg == 0)
		regs.F |= FLAG_Z_ON;
	else
		regs.F &= FLAG_Z_OFF;

	// Flags H and N are reset.
	regs.F &= (FLAG_Z_ON | FLAG_C_ON);

	// Machine cycles used is dependant on opcode.
	if (opcode == 0x3E)
		cycles += 4;
	else
		cycles += 2;
}

If you can't understand the variables, I'll explain them.
 

zenogais

New member
Well here's a summary of my progress so far:

  • Full Z80 emulation - only partially tested.
  • Partially Finished GUI.
  • Partial Video Support.

Right now I've been very busy since I've gone back to school. I'm taking one Advanced Placement course (AP English) as well as a college-prep algebra II class, so I've been kinda swamped with homework thus far. When I do find some time to work on it, I'll probably work on cleaning up the CPU emulation core. I was also playing around with some stuff involving the "Observer" pattern in order to pass data between the various components i.e. Video, Sound, and CPU/Memory. I'm just looking forward to trying out some cool new ideas for this project, but first I want to clean it up. 'll get back to you guys when I have a chance to work on it.
 

aprentice

Moderator
zenogais said:
I was also playing around with some stuff involving the "Observer" pattern in order to pass data between the various components i.e. Video, Sound, and CPU/Memory. I'm just looking forward to trying out some cool new ideas for this project, but first I want to clean it up. 'll get back to you guys when I have a chance to work on it.

What exactly is the "observer" pattern you speak of? I'm into doing things that haven't been done before. In my CPU i deployed a feature that hasn't been implemented in any gameboy emu, which so far produced amazing results. I'll explain in detail once i finalize my work :p
 

bcrew1375

New member
Hmm, I compared the shift instructions between the current version of my emu and a backup. The backup uses some older code. The shift instructions are the same, yet the current version screws some things up, like text, and the backup version doesn't. Considering both are using the same shifting instructions, I highly doubt they are the problem :p. I'm now going through the code of both to see what is different, and what is the same. It'll be a pain, but hopefully I can squash this annoying bug, or bugs.
 

aprentice

Moderator
bcrew1375 said:
Well, I don't know if there is a problem with them or not, but here they are:

Code:
void z80_SLA_reg8(unsigned char *reg)

If you can't understand the variables, I'll explain them.

Did you check to make sure the flags are getting reset like they should?

and change if (*reg & 0x80) to if(reg & 0x80) because reg is already pointing at an address
 
Last edited:

GbaGuy

New member
aprentice said:
Did you check to make sure the flags are getting reset like they should?

and change if (*reg & 0x80) to if(reg & 0x80) because reg is already pointing at an address

But the code is supposed to & 0x80 with the value, not the address, so
you need the dereference, right? Or have I totally confused myself?
 

Top