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", "xtr1common": "c",
"chrono": "c", "chrono": "c",
"interrupts.h": "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; bool active;
u8 byte; u8 byte;
u8 value; u8 value;
u8 value_buffer;
u8 start_delay; u8 start_delay;
bool transferring; bool transferring;
bool dma_waiting;
} dma_context; } dma_context;
typedef struct { typedef struct {

View File

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