Permalink
Browse files

GB Video: Fix initialization

  • Loading branch information...
endrift committed Jun 28, 2018
1 parent 302d486 commit 746f2b8e6a8a360289f40c6b7425abc1c07d5d91
Showing with 9 additions and 1 deletion.
  1. +2 −0 src/gb/gb.c
  2. +5 −1 src/gb/io.c
  3. +2 −0 src/gb/video.c
View
@@ -547,6 +547,8 @@ void GBSkipBIOS(struct GB* gb) {
mTimingDeschedule(&gb->timing, &gb->timer.event);
mTimingSchedule(&gb->timing, &gb->timer.event, 0);
+ GBIOWrite(gb, REG_LCDC, 0x91);
+
if (gb->biosVf) {
GBUnmapBIOS(gb);
}
View
@@ -182,7 +182,11 @@ void GBIOReset(struct GB* gb) {
GBIOWrite(gb, REG_NR43, 0x00);
GBIOWrite(gb, REG_NR50, 0x77);
GBIOWrite(gb, REG_NR51, 0xF3);
- GBIOWrite(gb, REG_LCDC, 0x91);
+ if (!gb->biosVf) {
+ GBIOWrite(gb, REG_LCDC, 0x91);
+ } else {
+ GBIOWrite(gb, REG_LCDC, 0x00);
+ }
GBIOWrite(gb, REG_SCY, 0x00);
GBIOWrite(gb, REG_SCX, 0x00);
GBIOWrite(gb, REG_LYC, 0x00);
View
@@ -419,6 +419,7 @@ void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
video->mode = 2;
video->modeEvent.callback = _endMode2;
int32_t next = GB_VIDEO_MODE_2_LENGTH - 5; // TODO: Why is this fudge factor needed? Might be related to T-cycles for load/store differing
+ mTimingDeschedule(&video->p->timing, &video->modeEvent);
mTimingSchedule(&video->p->timing, &video->modeEvent, next << video->p->doubleSpeed);
video->ly = 0;
@@ -445,6 +446,7 @@ void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
video->renderer->writePalette(video->renderer, 0, video->dmgPalette[0]);
mTimingDeschedule(&video->p->timing, &video->modeEvent);
+ mTimingDeschedule(&video->p->timing, &video->frameEvent);
mTimingSchedule(&video->p->timing, &video->frameEvent, GB_VIDEO_TOTAL_LENGTH);
}
video->p->memory.io[REG_STAT] = video->stat;

0 comments on commit 746f2b8

Please sign in to comment.