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
static void requestAnyNewModeInterrupts(struct gameboy * gameboy, uint8_t previousMode)
{
	bool enabled = gameboy->screen.currentLCDInterruptEnabled;
	uint8_t currentMode = getCurrentMode(gameboy);
	if (enabled && (currentMode != previousMode)){
		requestInterrupt(gameboy, lcdStat);
	}
	
}
Esempio n. 3
0
static void handleCurrentScanline(struct gameboy * gameboy)
{
	uint8_t currentScanline = gameboy->screen.currentScanline;
	if (currentScanline == Y){
		requestInterrupt(gameboy, int_vblank);
	}
	else if (currentScanline > (Y + NO_OF_INVISIBLE_SCANLINES)){
		gameboy->screen.currentScanline = 0; //reset
	}
	else {
		drawScanline(gameboy);
	}
}
Esempio n. 4
0
static void doCoincidenceFlag(struct gameboy * gameboy)
{
	if (gameboy->screen.currentScanline == readByte(gameboy, LY_COMPARE)){
		//current scanline == the values stored at 0xFF45
		//if this is true, set bit 2 of the status reg. Otherwise, reset it.
		setBit(&gameboy->screen.status, COINCIDENCE_BIT, true);
		if (isBitSet(gameboy->screen.status, COINCIDENCE_ENABLE_BIT)){
			requestInterrupt(gameboy, lcdStat);
		}
	}
	else {
		setBit(&gameboy->screen.status, COINCIDENCE_BIT, false);
	}
			
}
Esempio n. 5
0
void Emu::Cpu::updateTimer(uint16_t m) {
    uint8_t tmc = emu->mmu->rb(0xFF07);
    bool timerEnabled = ((tmc & 0x04) != 0);
    if (timerEnabled) {
        timerClocks -= m;
        if (timerClocks <= 0) {
            setTimerFreq();
            if(emu->mmu->rb(0xFF05) == 0xFF) {
                emu->mmu->wb(0xFF05, emu->mmu->rb(0xFF06));
                requestInterrupt(Timer);
            } else {
                emu->mmu->wb(0xFF05, emu->mmu->rb(0xFF05) + 1);
            }
        }
    }
}
Esempio n. 6
0
void serialFunc(int value) {
    ioRam[0x01] = packetData;
    requestInterrupt(SERIAL);
    ioRam[0x02] &= ~0x80;
}