mirror of https://github.com/mgba-emu/mgba.git
GB: Improve initialization
This commit is contained in:
parent
31b509e033
commit
e019c54aad
|
@ -37,6 +37,8 @@ static void GBInit(struct LR35902Core* cpu, struct LR35902Component* component)
|
|||
|
||||
GBInterruptHandlerInit(&cpu->irqh);
|
||||
GBMemoryInit(gb);
|
||||
|
||||
gb->video.p = gb;
|
||||
GBVideoInit(&gb->video);
|
||||
|
||||
gb->romVf = 0;
|
||||
|
@ -123,9 +125,8 @@ void GBReset(struct LR35902Core* cpu) {
|
|||
gb->yankedRomSize = 0;
|
||||
}
|
||||
GBMemoryReset(gb);
|
||||
|
||||
gb->video.p = gb;
|
||||
GBVideoReset(&gb->video);
|
||||
GBIOReset(gb);
|
||||
}
|
||||
|
||||
void GBUpdateIRQs(struct GB* gb) {
|
||||
|
|
37
src/gb/io.c
37
src/gb/io.c
|
@ -11,6 +11,43 @@ void GBIOInit(struct GB* gb) {
|
|||
memset(gb->memory.io, 0, sizeof(gb->memory.io));
|
||||
}
|
||||
|
||||
void GBIOReset(struct GB* gb) {
|
||||
memset(gb->memory.io, 0, sizeof(gb->memory.io));
|
||||
|
||||
GBIOWrite(gb, 0x05, 0);
|
||||
GBIOWrite(gb, 0x06, 0);
|
||||
GBIOWrite(gb, 0x07, 0);
|
||||
GBIOWrite(gb, 0x10, 0x80);
|
||||
GBIOWrite(gb, 0x11, 0xBF);
|
||||
GBIOWrite(gb, 0x12, 0xF3);
|
||||
GBIOWrite(gb, 0x12, 0xF3);
|
||||
GBIOWrite(gb, 0x14, 0xBF);
|
||||
GBIOWrite(gb, 0x16, 0x3F);
|
||||
GBIOWrite(gb, 0x17, 0x00);
|
||||
GBIOWrite(gb, 0x19, 0xBF);
|
||||
GBIOWrite(gb, 0x1A, 0x7F);
|
||||
GBIOWrite(gb, 0x1B, 0xFF);
|
||||
GBIOWrite(gb, 0x1C, 0x9F);
|
||||
GBIOWrite(gb, 0x1E, 0xBF);
|
||||
GBIOWrite(gb, 0x20, 0xFF);
|
||||
GBIOWrite(gb, 0x21, 0x00);
|
||||
GBIOWrite(gb, 0x22, 0x00);
|
||||
GBIOWrite(gb, 0x23, 0xBF);
|
||||
GBIOWrite(gb, 0x24, 0x77);
|
||||
GBIOWrite(gb, 0x25, 0xF3);
|
||||
GBIOWrite(gb, 0x26, 0xF1);
|
||||
GBIOWrite(gb, 0x40, 0x91);
|
||||
GBIOWrite(gb, 0x42, 0x00);
|
||||
GBIOWrite(gb, 0x43, 0x00);
|
||||
GBIOWrite(gb, 0x45, 0x00);
|
||||
GBIOWrite(gb, 0x47, 0xFC);
|
||||
GBIOWrite(gb, 0x48, 0xFF);
|
||||
GBIOWrite(gb, 0x49, 0xFF);
|
||||
GBIOWrite(gb, 0x4A, 0x00);
|
||||
GBIOWrite(gb, 0x4B, 0x00);
|
||||
GBIOWrite(gb, 0xFF, 0x00);
|
||||
}
|
||||
|
||||
void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) {
|
||||
switch (address) {
|
||||
case REG_IF:
|
||||
|
|
|
@ -145,6 +145,15 @@ void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) && !GBRegisterLCDCIsEnable(value)) {
|
||||
video->mode = 0;
|
||||
video->nextMode = INT_MAX;
|
||||
video->nextEvent = INT_MAX;
|
||||
video->stat = GBRegisterSTATSetMode(video->stat, video->mode);
|
||||
video->p->memory.io[REG_STAT] = video->stat;
|
||||
video->ly = 0;
|
||||
video->p->memory.io[REG_LY] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GBVideoWriteSTAT(struct GBVideo* video, GBRegisterSTAT value) {
|
||||
|
|
Loading…
Reference in New Issue