interrupt: first-pass implementation of interrupts
Only manual and V-blank interrupts work, for now. This implements enough to make the EI and DI parts of Blargg's Interrupt test pass.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "gbemu/video.h"
|
||||
#include "gbemu/memory.h"
|
||||
#include "gbemu/interrupt.h"
|
||||
#include "common/common.h"
|
||||
#include "common/bmp.h"
|
||||
|
||||
@@ -9,7 +10,6 @@
|
||||
/* TODO: This whole implementation is very simple.*/
|
||||
/* TODO: Actual graphics output */
|
||||
/* TODO: Implementation of most registers */
|
||||
/* TODO: Interrupts */
|
||||
|
||||
static struct bmp *bmp;
|
||||
|
||||
@@ -28,12 +28,13 @@ static uint8_t color_tbl[4] = {
|
||||
0,
|
||||
};
|
||||
|
||||
void gb_video_init(struct gb_video *video, struct gb_memory *memory)
|
||||
void gb_video_init(struct gb_video *video, struct gb_memory *memory, struct gb_interrupt *interrupt)
|
||||
{
|
||||
memset(video, 0, sizeof(*video));
|
||||
|
||||
video->debug_logging = 0;
|
||||
video->memory = memory;
|
||||
video->interrupt = interrupt;
|
||||
|
||||
bmp = bmp_new(BMP_GRAYSCALE, BUFFER_WIDTH, BUFFER_HEIGHT);
|
||||
}
|
||||
@@ -114,12 +115,15 @@ void gb_video_cycle(struct gb_video *video, int cycles)
|
||||
video->curline += 1;
|
||||
if (video->curline > LCD_Y_MAX) {
|
||||
video->curline = 0;
|
||||
gb_interrupt_clear(video->interrupt, GB_INT_VBLANK);
|
||||
if (video->lcdcont & (1 << 7)) {
|
||||
screenshot_count++;
|
||||
if (screenshot_count % 30 == 0) {
|
||||
gb_video_screenshot(video);
|
||||
}
|
||||
}
|
||||
} else if (video->curline == 144) {
|
||||
gb_interrupt_set(video->interrupt, GB_INT_VBLANK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user