Esempio n. 1
0
void updateGraphicsTest(struct gameboy * gameboy)
{
	//fill a frame buffer with some simple pixel data and see if it draws correctly
	setLCDStatus(gameboy);
	uint8_t previousMode = getCurrentMode(gameboy);
	requestAnyNewModeInterrupts(gameboy, previousMode);
	if (isLCDEnabled(gameboy)){
		gameboy->screen.scanlineCounter += gameboy->cpu.previousInstruction.cycles;
	}
	else {
		return;
	}
	
	if (gameboy->screen.scanlineCounter >= SCANLINE_CYCLE_TIME){
		gameboy->screen.currentScanline++;
		gameboy->screen.scanlineCounter = 0;
		if (gameboy->screen.currentScanline == Y){
			requestInterrupt(gameboy, int_vblank);
			//printf("start vblank\n");
		}
		else if (gameboy->screen.currentScanline > (Y + NO_OF_INVISIBLE_SCANLINES)){
			gameboy->screen.currentScanline = 0;
			//printf("resetting scanline\n");
		}
		else if (gameboy->screen.currentScanline < Y){
//			printf("drawing scanline %d\n", gameboy->screen.currentScanline);
			drawScanline(gameboy);
		}
		else {
			//printf("In vblank\n");
		}
	}
	
}
Esempio n. 2
0
void Video::updateGraphics(const int &cycles, CPU &cpuTemp)
{
	setLCDStatus(cpuTemp);

	if (isLCDEnabled())
		_scanLineCounter -= cycles;
	else
		return;

	if (_scanLineCounter <= 0)
	{
		// time to move onto next scanline
		_memory->directModification(LY, _memory->read(LY) + 1);
		BYTE currentline = _memory->read(LY);

		_scanLineCounter = 456;

		// we have entered vertical blank period
		if (currentline == 144)
			cpuTemp.requestInterrupt(VBlank);

		// if gone past scanline 153 reset to 0
		else if (currentline > 153)
			_memory->directModification(LY, 0x00);

		// draw the current scanline 
		else if (currentline < 144)
			drawScanLine();
	}
}
Esempio n. 3
0
void updateGraphics(struct gameboy * gameboy)
{
	int cycles = gameboy->cpu.previousInstruction.cycles;
	uint8_t previousMode = getCurrentMode(gameboy);
	setLCDStatus(gameboy);
	requestAnyNewModeInterrupts(gameboy, previousMode);
	doCoincidenceFlag(gameboy);
	if (isLCDEnabled(gameboy)){
		gameboy->screen.scanlineCounter += cycles;
		doScanline(gameboy);
	}
}