mirror of
https://github.com/libretro/mgba.git
synced 2024-11-24 08:30:30 +00:00
GB Video: Fix timing for vblank IRQs
This commit is contained in:
parent
4d839d03b4
commit
7539742689
@ -143,29 +143,35 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) {
|
||||
case 1:
|
||||
// TODO: One M-cycle delay
|
||||
++video->ly;
|
||||
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);
|
||||
if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS) {
|
||||
if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS + 1) {
|
||||
video->ly = 0;
|
||||
video->p->memory.io[REG_LY] = video->ly;
|
||||
video->nextMode = GB_VIDEO_MODE_2_LENGTH;
|
||||
video->mode = 2;
|
||||
if (GBRegisterSTATIsOAMIRQ(video->stat)) {
|
||||
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
|
||||
GBUpdateIRQs(video->p);
|
||||
}
|
||||
} else {
|
||||
video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH;
|
||||
}
|
||||
if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS - 1) {
|
||||
break;
|
||||
} else if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS) {
|
||||
video->p->memory.io[REG_LY] = 0;
|
||||
video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH - 8;
|
||||
} else if (video->ly == GB_VIDEO_VERTICAL_TOTAL_PIXELS - 1) {
|
||||
video->p->memory.io[REG_LY] = video->ly;
|
||||
video->nextMode = 8;
|
||||
} else {
|
||||
video->p->memory.io[REG_LY] = video->ly;
|
||||
video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH;
|
||||
}
|
||||
if (GBRegisterSTATIsLYCIRQ(video->stat) && lyc == video->ly) {
|
||||
|
||||
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->p->memory.io[REG_LY]);
|
||||
if (GBRegisterSTATIsLYCIRQ(video->stat) && lyc == video->p->memory.io[REG_LY]) {
|
||||
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
|
||||
GBUpdateIRQs(video->p);
|
||||
}
|
||||
if (video->p->memory.mbcType == GB_MBC7 && video->p->memory.rotation && video->p->memory.rotation->sample) {
|
||||
video->p->memory.rotation->sample(video->p->memory.rotation);
|
||||
}
|
||||
GBUpdateIRQs(video->p);
|
||||
break;
|
||||
case 2:
|
||||
_cleanOAM(video, video->ly);
|
||||
|
Loading…
Reference in New Issue
Block a user