summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorEmill <emil.lenngren@gmail.com>2022-04-18 11:37:47 +0200
committerGitHub <noreply@github.com>2022-04-18 11:37:47 +0200
commitceef4a94537a9b6fd14b5ff1b58f4605fd4c64fd (patch)
tree41cf0d30b6673c0fc4df4f06e663af6df223ce32 /soh/src/code
parentfe6dbd2a5b38e63db5fde84091a68803892cc0f1 (diff)
Graphics backend enhancements etc. (#163)
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/graph.c29
-rw-r--r--soh/src/code/z_kankyo.c3
-rw-r--r--soh/src/code/z_lights.c38
3 files changed, 41 insertions, 29 deletions
diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c
index 9d2886ef1..34283f342 100644
--- a/soh/src/code/graph.c
+++ b/soh/src/code/graph.c
@@ -468,35 +468,6 @@ static void RunFrame()
{
uint64_t ticksA, ticksB;
ticksA = GetPerfCounter();
-
- OTRSetFrameDivisor(R_UPDATE_RATE);
- //OTRSetFrameDivisor(0);
-
-
- //AudioMgr_ThreadEntry(&gAudioMgr);
- // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333..
- // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528
- #define SAMPLES_HIGH 560
- #define SAMPLES_LOW 528
- // PAL values
- //#define SAMPLES_HIGH 656
- //#define SAMPLES_LOW 624
- #define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 )
- #define NUM_AUDIO_CHANNELS 2
- int samples_left = AudioPlayer_Buffered();
- u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
- // printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
-
- // 3 is the maximum authentic frame divisor.
- s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3];
- for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
- AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples);
- }
- //for (uint32_t i = 0; i < 2 * num_audio_samples; i++) {
- // audio_buffer[i] = Rand_Next() & 0xFF;
- //}
- // printf("Audio samples before submitting: %d\n", audio_api->buffered());
- AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
PadMgr_ThreadEntry(&gPadMgr);
diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c
index afcd0f4fa..f3ac083ab 100644
--- a/soh/src/code/z_kankyo.c
+++ b/soh/src/code/z_kankyo.c
@@ -226,6 +226,9 @@ u16 Environment_GetPixelDepth(s32 x, s32 y) {
void Environment_GraphCallback(GraphicsContext* gfxCtx, void* param) {
GlobalContext* globalCtx = (GlobalContext*)param;
+ OTRGetPixelDepthPrepare(D_8015FD7E, D_8015FD80);
+ Lights_GlowCheckPrepare(globalCtx);
+
D_8011FB44 = Environment_GetPixelDepth(D_8015FD7E, D_8015FD80);
Lights_GlowCheck(globalCtx);
}
diff --git a/soh/src/code/z_lights.c b/soh/src/code/z_lights.c
index 2c7140c73..c9b60ceca 100644
--- a/soh/src/code/z_lights.c
+++ b/soh/src/code/z_lights.c
@@ -323,6 +323,44 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient
return lights;
}
+void Lights_GlowCheckPrepare(GlobalContext* globalCtx) {
+ LightNode* node;
+ LightPoint* params;
+ Vec3f pos;
+ Vec3f multDest;
+ f32 wDest;
+ f32 wX;
+ f32 wY;
+
+ node = globalCtx->lightCtx.listHead;
+
+ while (node != NULL) {
+ params = &node->info->params.point;
+
+ if (node->info->type == LIGHT_POINT_GLOW) {
+ f32 x, y;
+ u32 shrink;
+ uint32_t height;
+
+ pos.x = params->x;
+ pos.y = params->y;
+ pos.z = params->z;
+ func_8002BE04(globalCtx, &pos, &multDest, &wDest);
+ wX = multDest.x * wDest;
+ wY = multDest.y * wDest;
+
+ x = wX * 160 + 160;
+ y = wY * 120 + 120;
+ shrink = ShrinkWindow_GetCurrentVal();
+
+ if ((multDest.z > 1.0f) && y >= shrink && y <= SCREEN_HEIGHT - shrink) {
+ OTRGetPixelDepthPrepare(x, y);
+ }
+ }
+ node = node->next;
+ }
+}
+
void Lights_GlowCheck(GlobalContext* globalCtx) {
LightNode* node;
LightPoint* params;