oam timings passing.

This commit is contained in:
2025-05-31 09:17:28 -06:00
parent 09775258aa
commit 8ef1a5cd60
3 changed files with 24 additions and 9 deletions

View File

@ -10,6 +10,11 @@
"xtr1common": "c",
"chrono": "c",
"interrupts.h": "c",
"cmath": "c"
"cmath": "c",
"algorithm": "c",
"functional": "c",
"optional": "c",
"system_error": "c",
"xutility": "c"
}
}

View File

@ -6,8 +6,10 @@ typedef struct {
bool active;
u8 byte;
u8 value;
u8 value_buffer;
u8 start_delay;
bool transferring;
bool dma_waiting;
} dma_context;
typedef struct {

View File

@ -8,23 +8,31 @@
static dma_context ctx;
void dma_start(u8 start) {
ctx.start_delay = 1;
ctx.value_buffer = start;
ctx.dma_waiting = true;
}
void dma_begin() {
ctx.active = true;
ctx.byte = 0;
ctx.start_delay = 2;
ctx.value = start;
ctx.transferring = false;
ctx.value = ctx.value_buffer;
ctx.dma_waiting = false;
}
void dma_tick() {
ctx.transferring = false;
if (ctx.start_delay) {
ctx.start_delay--;
} else if(ctx.dma_waiting) {
dma_begin();
}
if (!ctx.active) {
return;
}
if (ctx.start_delay) {
ctx.start_delay--;
return;
}
ctx.transferring = true;
u8 data = 0;
u16 addr = (ctx.value << 8) | ctx.byte;
@ -45,7 +53,7 @@ void dma_tick() {
}
bool dma_transferring() {
return ctx.transferring && ctx.active;
return ctx.transferring;// && ctx.active;
}
void dma_save_state(dma_state* state) {