mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-21 16:47:07 -04:00
5c23113592
* libultra from sm64 integrated; 3 libultra functions matched * All of libultra done! authored-by: farisawan-2000 <farisawan.2000@gmail.com>
29 lines
542 B
C
29 lines
542 B
C
#include "libultra_internal.h"
|
|
#include "osAi.h"
|
|
#include "hardware.h"
|
|
|
|
extern s32 osViClock;
|
|
|
|
s32 osAiSetFrequency(u32 freq) {
|
|
register u32 a1;
|
|
register s32 a2;
|
|
register float ftmp;
|
|
ftmp = osViClock / (float) freq + .5f;
|
|
|
|
a1 = ftmp;
|
|
|
|
if (a1 < 0x84) {
|
|
return -1;
|
|
}
|
|
|
|
a2 = (a1 / 66) & 0xff;
|
|
if (a2 > 16) {
|
|
a2 = 16;
|
|
}
|
|
|
|
HW_REG(AI_DACRATE_REG, u32) = a1 - 1;
|
|
HW_REG(AI_BITRATE_REG, u32) = a2 - 1;
|
|
HW_REG(AI_CONTROL_REG, u32) = 1; // enable dma
|
|
return osViClock / (s32) a1;
|
|
}
|