Finished CPU instructions and created ui window.

This commit is contained in:
2025-01-31 14:39:38 -07:00
parent 83c5a7cbe6
commit 9a6dc67c3e
12 changed files with 265 additions and 33 deletions

34
lib/interrupts.c Normal file
View File

@ -0,0 +1,34 @@
#include <interrupts.h>
#include <stack.h>
void int_handle(cpu_context *ctx, u16 address) {
stack_push16(ctx->regs.pc);
ctx->regs.pc = address;
}
bool int_check(cpu_context *ctx, u16 address, interrupt_type t){
if(ctx->int_flags & t && ctx->ie_register & t) {
int_handle(ctx, address);
ctx->int_flags &= -t;
ctx->halted = false;
ctx->int_master_enabled = false;
return true;
}
return false;
}
void cpu_request_interrupt(interrupt_type t);
void cpu_handle_interrupts(cpu_context *ctx) {
if (int_check(ctx, 0x40, IT_VBLANK)) {
} else if(int_check(ctx, 0x48, IT_LCD_STAT)){
} else if(int_check(ctx, 0x50, IT_TIMER)){
} else if(int_check(ctx, 0x58, IT_SERIAL)){
} else if(int_check(ctx, 0x60, IT_JOYPAD)){
}
}