diff options
| author | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-01 18:45:02 -0400 | 
|---|---|---|
| committer | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-01 18:50:25 -0400 | 
| commit | 9fa0a7f1da1b70bee995f53c6c96c43189018772 (patch) | |
| tree | 114548896790eaff23cdca84a025281de86bbb51 /src/Dolphin/si/SISamplingRate.c | |
| parent | 2ba3289286bbfcf9fcc13fd135d976058d8b6c2e (diff) | |
global: Import Dolphin SDK
This version comes from the Metroid Prime decompilation project.
https://github.com/PrimeDecomp/prime
Diffstat (limited to 'src/Dolphin/si/SISamplingRate.c')
| -rw-r--r-- | src/Dolphin/si/SISamplingRate.c | 54 | 
1 files changed, 54 insertions, 0 deletions
| diff --git a/src/Dolphin/si/SISamplingRate.c b/src/Dolphin/si/SISamplingRate.c new file mode 100644 index 0000000..c9b96ca --- /dev/null +++ b/src/Dolphin/si/SISamplingRate.c @@ -0,0 +1,54 @@ +#include "dolphin/sipriv.h" +#include "dolphin/vi.h" +#pragma dont_inline on +static u32 SamplingRate; + +typedef struct XY { +  u16 line; +  u8 count; +} XY; + +static XY XYNTSC[12] = { +    {263 - 17, 2}, {15, 18}, {30, 9}, {44, 6},  {52, 5},  {65, 4}, +    {87, 3},       {87, 3}, {87, 3}, {131, 2}, {131, 2}, {131, 2}, +}; + +static XY XYPAL[12] = { +    {313 - 17, 2}, {15, 21}, {29, 11}, {45, 7},  {52, 6},  {63, 5}, +    {78, 4},       {104, 3}, {104, 3}, {104, 3}, {104, 3}, {156, 2}, +}; + +void SISetSamplingRate(u32 msec) { +  XY* xy; +  BOOL enabled; + +  if (msec > 11) { +    msec = 11; +  } + +  enabled = OSDisableInterrupts(); + +  SamplingRate = msec; + +  switch (VIGetTvFormat()) { +  case VI_NTSC: +  case VI_MPAL: +  case VI_EURGB60: +    xy = XYNTSC; +    break; +  case VI_PAL: +    xy = XYPAL; +    break; +  default: +    OSReport("SISetSamplingRate: unknown TV format. Use default."); +    msec = 0; +    xy = XYNTSC; +    break; +  } + +  SISetXY((__VIRegs[54] & 1 ? 2u : 1u) * xy[msec].line, xy[msec].count); +  OSRestoreInterrupts(enabled); +} + +void SIRefreshSamplingRate() { SISetSamplingRate(SamplingRate); } +#pragma dont_inline reset | 
