audio is getting closer?
This commit is contained in:
20
lib/timer.c
20
lib/timer.c
@ -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(¤t);
|
||||
// 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){
|
||||
|
Reference in New Issue
Block a user