mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-31 12:00:25 -07:00
Graphics backend enhancements etc. (#163)
This commit is contained in:
parent
fe6dbd2a5b
commit
ceef4a9453
21 changed files with 872 additions and 588 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue