What's new

Game Boy

Sagon

New member
GB:
MBC3+RAM+BATTERY: Pokemon Series (Blue,Red)
MBC3+TIMER+RAM+BATTERY: Berutomo Kurabu (J) [!], Bokujou Monogatari GB (J) (V1.0) , Itsudemo Nyanto Wonderful (J) [!], Kandume Monsters (J) .
GBC:
MBC3: Columns DX (PD) [C]
MBC3+RAM: Putty Squad Demo by Thalamus Interactive (PD) [C]
MBC3+TIMER+RAM+BATTERY: Harvest Moon, Pokemon Series

I have only one delay of 6 cycles if VBlank is requested during HBlank, because without it Addams Family 2 and other games will not go in game. Have never got hex scores bug =) And don't have any idea about what may cause it.
 

ShizZy

Emulator Developer
Alrighty, thank you. Another completelly random question, how are you handling video with directx? Are you using some type of pixel drawing function (and then drawing multiple pixels for each gb pixel to scale it) or are you writing directly to the video buffer then scaling the window up? Trying to find the most efficient, fastest, and most compatable drawing method. What I have now works great, but I'm just curious. Thanks.
 

bcrew1375

New member
ShizZie, I don't think my emu is ready to release again yet. There's just not enough changes to it. My method is pretty slow in my opinion. Using SDL, I just draw rectangles to scale the picture. Also, I have a buffer that contains the last frame drawn. I check it against the current screen data, and if a pixel is the same, I don't draw it. I'm not sure if this is faster or not, since I do an "if" on each individual pixel :p.
 

ShizZy

Emulator Developer
Yeah, I previouselly used SDL, using SetRect (or whatever the command was) to draw a rectangle for each pixel. It was kind of slow, and didn't have really any options to do any interesting gfx filters or anything (blur pixels etc) but for some reason I still hold a weird attachment to the API. :p Dark Stalker seems to have it working pretty well for him.
 

Sagon

New member
For the video i have two arrays one for gb colors and one for gbc colors. When screen update is needed i'm locking surface and drawing colors directly to video buffer from one of the arrays and scale it if needed.
 

bcrew1375

New member
Can anyone give an accurate description of the priority bits? I've seen so many conflicting sources and I'm not sure if I'm using them correctly. I'm talking about bit 1 of 0xFF40(The document I have says if the bit is on, the window appears above all sprites, if the bit is off, it appears above sprites with a priority of 1.

The description I have for the sprite bits(Byte 4 of sprite data, bit 7) says that if it's on, the sprites appear under everything except background color 0. If it is off, they appear above the background and behind or above the window depending on bit 1 of 0xFF40.

Is this information correct? I have a feeling I'm not emulating these priorities correctly.

Edit: Can someone that has them working right tell me? I've looked through several documents and tried their methods, but none seem to work properly.
 
Last edited:

bcrew1375

New member
Okay. Messed around with priorities for quite a while, and now I believe I have the right combination. Everything seems happy with it. My emulator is about flawless now except for ONE problem. Donkey Kong still seems to have a one pixel offset problem. All the sprites in this game seem to appear over the very top line. I also notice when Donkey Kong is knocking the scaffold apart, you can see an extra rung on the ladder. Here's some pics:

Edit: It seems to be tied to the LYC interrupt.
 
Last edited:

ShizZy

Emulator Developer
Awesome work bcrew. I don't have priorities right at the moment, but not really worrying about it until I fix a few more bugs (though right now compat is quite good). One thing that's bugging me though, is it's not getting past the title screen to Mario2. Any ideas?

Edit: When do you do an LYC check? I do it each time after LY is incremented (in HBlank) and each time before and after each vblank is called. Don't know if it's right, but it seems to work well for gb mono, and I don't have any issues like the ones you have.
 
Last edited:

bcrew1375

New member
About Mario 2, Dark Stalker mentioned a problem a long while back that fixed it for aprentice. If you're not, keep the STAT mode flag at 0 when the display is disabled.

Hmm, I have a very strong feeling my problem with Donkey Kong is in the way I'm handling the end of the V-Blank. You said you didn't have problems with it, right? Do you think you could post your current code so I could get some ideas? I can't find anything in the docs that suggests I'm doing something wrong.
 

ShizZy

Emulator Developer
Thanks for the fix. Still doesn't get past the title screen, but at least it doesn't crash anymore. Here's my really messy poorly commented stat code, hope it helps. handleSTAT() is called every cpu loop, and I subtract cycles from cpu.timerLCD.

Code:
	void SetSTAT(int mode)
	{
		mem.IOR_STAT=(mem.IOR_STAT&0xFC)|mode;

		switch(mode)
		{
			case STAT_HBLANK: //HBlank 0
				dbg.lcdc_phase=1;
				if(mem.IOR_STAT&BIT3) reqINT(BIT1);
				break;
			case STAT_VBLANK: //VBlank 1
				dbg.lcdc_phase=4;
				if(mem.IOR_STAT&BIT4) reqINT(BIT1);
				break;
			case STAT_OAM: //OAM 2
				dbg.lcdc_phase=2;
				if(mem.IOR_STAT&BIT5) reqINT(BIT1);
				break;
			case STAT_TRANSFER: //Transfer 3
				dbg.lcdc_phase=3;
				if(mem.hdma_on){ // GBC only
					for(int f=0; f<0x10; f++)
					{
						mem.hdma_transfered+=f;

						if(mem.hdma_transfered>mem.hdma_length)
						{mem.hdma_transfered=0; mem.hdma_on=0; break;}

						mem.memory[0x8000+mem.hdma_destination+mem.hdma_transfered]=mem.memory[mem.hdma_source+mem.hdma_transfered];
					}

				}

				break;
		}
	}

	void handleLYC()
	{
		if(mem.IOR_LY==mem.IOR_LYC)
		{
			mem.IOR_STAT|=BIT2;
			if(mem.IOR_STAT&BIT6) reqINT(BIT1);
		}else{
			mem.IOR_STAT&=~BIT2;
		}
	}

	//

	void handleSTAT() // in order - 0, 2, 3 etc until hits VBLANK period (LY>144)
	{
		if(cpu.timerLCD<=0) 
		{
			switch(mem.IOR_STAT&0x3)
			{
				case STAT_HBLANK: // HBLANK 0
					++mem.IOR_LY;
					handleLYC();

					if(mem.IOR_LY==144)
					{ // time for vblank
						SetSTAT(STAT_VBLANK);
						cpu.timerLCD+=CYC_LCD_MODE1;
					}else{ // otherwise goto mode 2
						SetSTAT(STAT_OAM);
						cpu.timerLCD+=CYC_LCD_MODE2;
					}

					break;
				case STAT_VBLANK: // VBLANK 1
					handleLYC();
					switch(mem.IOR_LY)
					{
						case 0: 
							++mem.IOR_LY;
							SetSTAT(STAT_OAM);
							cpu.timerLCD+=CYC_LCD_MODE2;
							break;

						case 144:
							++mem.IOR_LY;
							reqINT(BIT0);
							cpu.timerLCD+=CYC_LCD_MODE1;

							aud.EndFrame();
							break;

						default:
							if(mem.IOR_LY<153)
							{ // repeat mode 1
								++mem.IOR_LY;
								cpu.timerLCD+=CYC_LCD_MODE1;
							}else{ // goto mode 0
								mem.IOR_LY=0;
								cpu.timerLCD+=CYC_LCD_MODE1;
							}
							break;
					}
					handleLYC();

					break;
				case STAT_OAM: // OAM TRANSFER 2
					// goto mode 3
					//handleLYC();
					vid.LCD_DrawScanline();

					SetSTAT(STAT_TRANSFER);
					cpu.timerLCD+=CYC_LCD_MODE3;
					break;
				case STAT_TRANSFER: // TRANSFER 3
					// mode 0
					SetSTAT(STAT_HBLANK);
					cpu.timerLCD+=CYC_LCD_MODE0;
					break;
			}
		}
	}
 

bcrew1375

New member
Hmm, this is weird. It worked, but it had flicker. I changed stuff some more, then decided to put it back the way it was. Now, there is no flicker. What the...? So, if I'm understanding this correctly, V-Blank lasts from LY = 144 to LY = 1? Anyway, big thanks ShizZie! :happy: Now, can anyone suggest some "picky" games I can test? Mono only please.
 
Last edited:

ShizZy

Emulator Developer
NP :)

So, if I'm understanding this correctly, V-Blank lasts from
LY = 144 to LY = 1?
:plain: Hmmm... can't verify whether or not that is correct, no docs seem to support it, but it works best for me. It's probably wrong.

Games to try... "Asteroids & Missile Command" (the combination game). Seems like it would be easy to emulate based on the two games it's made up of, but it's the only game I know of so far to completelly crash my emulator without displaying any real graphics. Alleyway also is giving me some funky results.

As Sagon stated earlier, Motorcross Maniacs uses most of the GB cpu, and is a good one to debug with.
 

bcrew1375

New member
"Motocross Maniacs" and "Asteroids and Missile Command" work without issue, but Alleyway has a joypad problem. It seems to think I'm holding down the Start button, then won't respond to directional keys. I'll look into that. Anymore? :p
 
Last edited:

bcrew1375

New member
Geez, is it just me and ShizZie now? Come on guys, I want to hear if you've made any progress(That means you, Dark Stalker and aprentice :p).
 

Sagon

New member
I'm still working on my emu. I've fixed a tons of bugs with GBC games, and now nearly all are fully playable. But I haven't implemented some priorities that GBC specific, my emu haven't MBC7, MMM01 support cause i haven't any info on it, and i don't 100% sure that games using Rumble works exactly as without it. And i have one stange bug that occurs only in Blaster Master when i press right button wait a little and then press left, the tank will flip on y axis. Shot included. If anybody know what is it, please tell me.
Right now i'm using Blargg GB PAPU Library for sound, but i'm fighting with my sound implementation, hope soon it'll be finished.
 

bcrew1375

New member
Hmm, Anyone else been using the KiGB site for games to test?

I notice a few of the emulators have a graphic glitch with Altered Space where the top half of the screen is left when going from room to room. If you guys have this problem, just clear your screen data and immediately redraw the screen.
 

ShizZy

Emulator Developer
Havn't had a chance to test Altered Space. In fact, havn't had much chance to work on my emu at all latelly... been busy with the holidays/work/school. Hopefully I'll get back to it soon. Been playing it more than working on it :p

@Sagon, awesome job. I'm no where near as complete as you, still have a long ways to go before I'm bug free. My GBC is lame too, I think I'm handling HDMA completelly wrong, and my vbank switching is bad.
 

Sagon

New member
2 bcrew1375, thanks for the good site, now I have more games to test.
2 ShizZie, thanks, my development process is slowed down too because of study, exams are near =))
 

bcrew1375

New member
Has anyone gotten Interrupts Demo (PD) working? According to KiGB it's supposed to have a flashing line half way down the screen. I've never got that to show up. I even tried drawing the screen in blocks of eight instead of a whole line at a time.
 

Top