audio is getting closer?

This commit is contained in:
2025-02-02 20:36:32 -07:00
parent 243e13b19e
commit 8493ff5fea
5 changed files with 355 additions and 46 deletions

View File

@ -1,15 +1,31 @@
#include <Windows.h>
#include <timer.h>
#include <interrupts.h>
#include <audio.h>
#include <profileapi.h>
static timer_context ctx = {0};
long long counts_per_cycle;
long long last;
long long now;
void timer_init() {
ctx.div = 0XAC00;
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
counts_per_cycle = freq.QuadPart / (1 << 19);
}
void timer_tick() {
//while(now - last < counts_per_cycle){
// LARGE_INTEGER current;
// QueryPerformanceCounter(&current);
// now = current.QuadPart;
// //printf("Last-now: %lld, counts: %lld\n", now - last, counts_per_cycle);
//}
last = now;
u16 prev_div = ctx.div;
ctx.div++;
bool timer_update = false;
@ -42,6 +58,10 @@ void timer_tick() {
if((prev_div & (1 << 12)) && (!(ctx.div & (1 << 12)))){
audio_tick();
}
if((prev_div & (1 << 1)) && (!(ctx.div & (1 << 1)))){
audio_period_tick();
}
}
void timer_write(u16 address, u8 value){