mirror of
https://github.com/izzy2lost/sm64-izzys-port-android.git
synced 2026-07-05 15:19:31 -07:00
Removed majority of TARGET_N64 logic from code
This commit is contained in:
+4
-22
@@ -2499,41 +2499,23 @@ static const Lights1 segment2_lights_unused = gdSPDefLights1(
|
||||
|
||||
// 0x02014470 - 0x020144B0
|
||||
static const Mtx matrix_identity = {
|
||||
#ifdef TARGET_N64
|
||||
{{0x00010000, 0x00000000,
|
||||
0x00000001, 0x00000000},
|
||||
{0x00000000, 0x00010000,
|
||||
0x00000000, 0x00000001},
|
||||
{0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000},
|
||||
{0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000}}
|
||||
#else
|
||||
|
||||
{{1.0f, 0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 1.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f}}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 0x020144B0 - 0x020144F0
|
||||
static const Mtx matrix_fullscreen = {
|
||||
#if TARGET_N64
|
||||
{{0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000},
|
||||
{0x00000000, 0xffff0000,
|
||||
0xffffffff, 0xffff0001},
|
||||
{((65536 * 2 / SCREEN_WIDTH) << 16) | 0, 0x00000000,
|
||||
(0 << 16) | (65536 * 2 / SCREEN_HEIGHT), 0x00000000},
|
||||
{0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000}}
|
||||
#else
|
||||
|
||||
{{2.0f / SCREEN_WIDTH, 0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 2.0f / SCREEN_HEIGHT, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, -1.0f, 0.0f},
|
||||
{-1.0f, -1.0f, -1.0f, 1.0f}}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1109,11 +1109,7 @@
|
||||
* Vertex (set up for use with colors)
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef TARGET_N64
|
||||
short ob[3]; /* x, y, z */
|
||||
#else
|
||||
float ob[3]; /* x, y, z */
|
||||
#endif
|
||||
unsigned short flag;
|
||||
short tc[2]; /* texture coord */
|
||||
unsigned char cn[4]; /* color & alpha */
|
||||
@@ -1123,11 +1119,7 @@ typedef struct {
|
||||
* Vertex (set up for use with normals)
|
||||
*/
|
||||
typedef struct {
|
||||
#ifdef TARGET_N64
|
||||
short ob[3]; /* x, y, z */
|
||||
#else
|
||||
float ob[3]; /* x, y, z */
|
||||
#endif
|
||||
unsigned short flag;
|
||||
short tc[2]; /* texture coord */
|
||||
signed char n[3]; /* normal */
|
||||
@@ -1176,23 +1168,9 @@ typedef struct {
|
||||
unsigned char v[3];
|
||||
} Tri;
|
||||
|
||||
#ifdef TARGET_N64
|
||||
/*
|
||||
* 4x4 matrix, fixed point s15.16 format.
|
||||
* First 8 words are integer portion of the 4x4 matrix
|
||||
* Last 8 words are the fraction portion of the 4x4 matrix
|
||||
*/
|
||||
typedef s32 Mtx_t[4][4];
|
||||
|
||||
typedef union {
|
||||
Mtx_t m;
|
||||
long long int force_structure_alignment;
|
||||
} Mtx;
|
||||
#else
|
||||
typedef struct {
|
||||
float m[4][4];
|
||||
} Mtx;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Viewport
|
||||
|
||||
@@ -29,16 +29,9 @@ typedef volatile s64 vs64;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
#ifdef TARGET_N64
|
||||
typedef u32 size_t;
|
||||
typedef s32 ssize_t;
|
||||
typedef u32 uintptr_t;
|
||||
typedef s32 intptr_t;
|
||||
typedef s32 ptrdiff_t;
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
typedef ptrdiff_t ssize_t;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+3
-6
@@ -1,4 +1,5 @@
|
||||
#ifndef CONFIG_H
|
||||
|
||||
#define CONFIG_H
|
||||
|
||||
/**
|
||||
@@ -28,15 +29,11 @@
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
||||
// Border Height Define for NTSC Versions
|
||||
#ifdef TARGET_N64
|
||||
#ifndef VERSION_EU
|
||||
#define BORDER_HEIGHT 8
|
||||
#else
|
||||
|
||||
#define BORDER_HEIGHT 1
|
||||
#endif
|
||||
|
||||
#else
|
||||
// What's the point of having a border?
|
||||
#define BORDER_HEIGHT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef GFX_DIMENSIONS_H
|
||||
#define GFX_DIMENSIONS_H
|
||||
|
||||
#ifndef TARGET_N64
|
||||
#include <math.h>
|
||||
#include "pc/gfx/gfx_pc.h"
|
||||
#define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * gfx_current_dimensions.aspect_ratio + (v))
|
||||
@@ -9,12 +8,5 @@
|
||||
#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v))
|
||||
#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v))
|
||||
#define GFX_DIMENSIONS_ASPECT_RATIO (gfx_current_dimensions.aspect_ratio)
|
||||
#else
|
||||
#define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (v)
|
||||
#define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH - (v))
|
||||
#define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) (v)
|
||||
#define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH - (v))
|
||||
#define GFX_DIMENSIONS_ASPECT_RATIO (4.0f / 3.0f)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,20 +46,9 @@
|
||||
#define ALIGNED16
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_N64
|
||||
// convert a virtual address to physical.
|
||||
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr) & 0x1FFFFFFF)
|
||||
|
||||
// convert a physical address to virtual.
|
||||
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) | 0x80000000)
|
||||
|
||||
// another way of converting virtual to physical
|
||||
#define VIRTUAL_TO_PHYSICAL2(addr) ((u8 *)(addr) - 0x80000000U)
|
||||
#else
|
||||
// no conversion for pc port other than cast
|
||||
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr))
|
||||
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr))
|
||||
#define VIRTUAL_TO_PHYSICAL2(addr) ((void *)(addr))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
#ifndef MAKE_CONST_NONCONST_H
|
||||
#define MAKE_CONST_NONCONST_H
|
||||
|
||||
#ifdef TARGET_N64
|
||||
// IDO sometimes puts const variables in .rodata and sometimes in .data, which breaks ordering.
|
||||
// This makes sure all variables are put into the same section (.data). We need to do this for
|
||||
// both IDO and gcc for TARGET_N64.
|
||||
#define const
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#ifndef PLATFORM_INFO_H
|
||||
#define PLATFORM_INFO_H
|
||||
|
||||
#ifdef TARGET_N64
|
||||
#define IS_64_BIT 0
|
||||
#define IS_BIG_ENDIAN 1
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define IS_64_BIT (UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFU)
|
||||
#define IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
#endif
|
||||
|
||||
#define DOUBLE_SIZE_ON_64_BIT(size) ((size) * (sizeof(void *) / 4))
|
||||
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
#ifndef SEGMENT_SYMBOLS_H
|
||||
#define SEGMENT_SYMBOLS_H
|
||||
|
||||
#ifdef TARGET_N64
|
||||
#define DECLARE_SEGMENT(name) \
|
||||
extern u8 _##name##SegmentRomStart[]; \
|
||||
extern u8 _##name##SegmentRomEnd[];
|
||||
#else
|
||||
#define DECLARE_SEGMENT(name) \
|
||||
static u8 _##name##SegmentRomStart[1]; \
|
||||
static u8 _##name##SegmentRomEnd[1];
|
||||
#endif
|
||||
|
||||
#define DECLARE_ACTOR_SEGMENT(name) \
|
||||
DECLARE_SEGMENT(name##_mio0) \
|
||||
@@ -43,11 +37,7 @@ DECLARE_ACTOR_SEGMENT(group17)
|
||||
DECLARE_SEGMENT(behavior)
|
||||
DECLARE_SEGMENT(scripts)
|
||||
DECLARE_SEGMENT(goddard)
|
||||
#ifdef TARGET_N64
|
||||
extern u8 _goddardSegmentStart[];
|
||||
#else
|
||||
static u8 _goddardSegmentStart[1];
|
||||
#endif
|
||||
|
||||
DECLARE_LEVEL_SEGMENT(menu)
|
||||
DECLARE_LEVEL_SEGMENT(intro)
|
||||
|
||||
@@ -72,19 +72,16 @@ const LevelScript level_main_menu_entry_2[] = {
|
||||
|
||||
/*25*/ FREE_LEVEL_POOL(),
|
||||
/*26*/ LOAD_AREA(/*area*/ 2),
|
||||
#ifndef TARGET_N64
|
||||
|
||||
// sVisibleStars is set to 0 during FIXED_LOAD above on N64, but not on PC-port.
|
||||
// lvl_init_act_selector_values_and_stars must be called here otherwise the
|
||||
// previous value is retained and causes incorrect drawing during the 16 transition
|
||||
// frames.
|
||||
CALL(/*arg*/ 0, /*func*/ lvl_init_act_selector_values_and_stars),
|
||||
#endif
|
||||
|
||||
/*27*/ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_COLOR, /*time*/ 16, /*color*/ 0xFF, 0xFF, 0xFF),
|
||||
/*29*/ SLEEP(/*frames*/ 16),
|
||||
/*30*/ SET_MENU_MUSIC(/*seq*/ 0x000D),
|
||||
#ifdef TARGET_N64
|
||||
/*31*/ CALL(/*arg*/ 0, /*func*/ lvl_init_act_selector_values_and_stars),
|
||||
#endif
|
||||
/*33*/ CALL_LOOP(/*arg*/ 0, /*func*/ lvl_update_obj_and_load_act_button_actions),
|
||||
/*35*/ GET_OR_SET(/*op*/ OP_SET, /*var*/ VAR_CURR_ACT_NUM),
|
||||
/*36*/ STOP_MUSIC(/*fadeOutTime*/ 0x00BE),
|
||||
|
||||
+3
-46
@@ -1,49 +1,9 @@
|
||||
#include "libultra_internal.h"
|
||||
#ifndef TARGET_N64
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_N64
|
||||
void guMtxF2L(float mf[4][4], Mtx *m) {
|
||||
int r, c;
|
||||
s32 tmp1;
|
||||
s32 tmp2;
|
||||
s32 *m1 = &m->m[0][0];
|
||||
s32 *m2 = &m->m[2][0];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 2; c++) {
|
||||
tmp1 = mf[r][2 * c] * 65536.0f;
|
||||
tmp2 = mf[r][2 * c + 1] * 65536.0f;
|
||||
*m1++ = (tmp1 & 0xffff0000) | ((tmp2 >> 0x10) & 0xffff);
|
||||
*m2++ = ((tmp1 << 0x10) & 0xffff0000) | (tmp2 & 0xffff);
|
||||
}
|
||||
}
|
||||
}
|
||||
void guMtxL2F(float mf[4][4], Mtx *m) {
|
||||
int r, c;
|
||||
u32 tmp1;
|
||||
u32 tmp2;
|
||||
u32 *m1;
|
||||
u32 *m2;
|
||||
s32 stmp1, stmp2;
|
||||
m1 = (u32 *) &m->m[0][0];
|
||||
m2 = (u32 *) &m->m[2][0];
|
||||
for (r = 0; r < 4; r++) {
|
||||
for (c = 0; c < 2; c++) {
|
||||
tmp1 = (*m1 & 0xffff0000) | ((*m2 >> 0x10) & 0xffff);
|
||||
tmp2 = ((*m1++ << 0x10) & 0xffff0000) | (*m2++ & 0xffff);
|
||||
stmp1 = *(s32 *) &tmp1;
|
||||
stmp2 = *(s32 *) &tmp2;
|
||||
mf[r][c * 2 + 0] = stmp1 / 65536.0f;
|
||||
mf[r][c * 2 + 1] = stmp2 / 65536.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void guMtxF2L(float mf[4][4], Mtx *m) {
|
||||
memcpy(m, mf, sizeof(Mtx));
|
||||
}
|
||||
#endif
|
||||
|
||||
void guMtxIdentF(float mf[4][4]) {
|
||||
int r, c;
|
||||
@@ -58,11 +18,8 @@ void guMtxIdentF(float mf[4][4]) {
|
||||
}
|
||||
}
|
||||
void guMtxIdent(Mtx *m) {
|
||||
#ifdef TARGET_N64
|
||||
float mf[4][4];
|
||||
guMtxIdentF(mf);
|
||||
guMtxF2L(mf, m);
|
||||
#else
|
||||
|
||||
guMtxIdentF(m->m);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
+4
-106
@@ -738,6 +738,7 @@ void func_8031D838(s32 player, FadeT fadeInTime, u8 targetVolume) {
|
||||
}
|
||||
seqPlayer->fadeVelocity =
|
||||
(((f32)(FLOAT_CAST(targetVolume) / EU_FLOAT(127.0)) - seqPlayer->fadeVolume) / (f32) fadeInTime);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->state = 0;
|
||||
#else
|
||||
@@ -764,117 +765,15 @@ void func_eu_802e9bec(s32 player, s32 channel, s32 arg2) {
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#ifdef TARGET_N64
|
||||
struct SPTask *create_next_audio_frame_task(void) {
|
||||
u32 samplesRemainingInAI;
|
||||
s32 writtenCmds;
|
||||
s32 index;
|
||||
OSTask_t *task;
|
||||
s32 oldDmaCount;
|
||||
s32 flags;
|
||||
|
||||
gAudioFrameCount++;
|
||||
if (gAudioLoadLock != AUDIO_LOCK_NOT_LOADING) {
|
||||
stubbed_printf("DAC:Lost 1 Frame.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gAudioTaskIndex ^= 1;
|
||||
gCurrAiBufferIndex++;
|
||||
gCurrAiBufferIndex %= NUMAIBUFFERS;
|
||||
index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS;
|
||||
samplesRemainingInAI = osAiGetLength() / 4;
|
||||
|
||||
// Audio is triple buffered; the audio interface reads from two buffers
|
||||
// while the third is being written by the RSP. More precisely, the
|
||||
// lifecycle is:
|
||||
// - this function computes an audio command list
|
||||
// - wait for vblank
|
||||
// - the command list is sent to the RSP (we could have sent it to the
|
||||
// RSP before the vblank, but that gives the RSP less time to finish)
|
||||
// - wait for vblank
|
||||
// - the RSP is now expected to be finished, and we can send its output
|
||||
// on to the AI
|
||||
// Here we thus send to the AI the sound that was generated two frames ago.
|
||||
if (gAiBufferLengths[index] != 0) {
|
||||
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
|
||||
}
|
||||
|
||||
oldDmaCount = gCurrAudioFrameDmaCount;
|
||||
// There has to be some sort of no-op if here, but it's not exactly clear
|
||||
// how it should look... It's also very unclear why gCurrAudioFrameDmaQueue
|
||||
// isn't read from here, despite gCurrAudioFrameDmaCount being reset.
|
||||
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) {
|
||||
stubbed_printf("DMA: Request queue over.( %d )\n", oldDmaCount);
|
||||
}
|
||||
gCurrAudioFrameDmaCount = 0;
|
||||
|
||||
gAudioTask = &gAudioTasks[gAudioTaskIndex];
|
||||
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
|
||||
|
||||
index = gCurrAiBufferIndex;
|
||||
gCurrAiBuffer = gAiBuffers[index];
|
||||
gAiBufferLengths[index] = ((gSamplesPerFrameTarget - samplesRemainingInAI +
|
||||
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE;
|
||||
if (gAiBufferLengths[index] < gMinAiBufferLength) {
|
||||
gAiBufferLengths[index] = gMinAiBufferLength;
|
||||
}
|
||||
if (gAiBufferLengths[index] > gSamplesPerFrameTarget + SAMPLES_TO_OVERPRODUCE) {
|
||||
gAiBufferLengths[index] = gSamplesPerFrameTarget + SAMPLES_TO_OVERPRODUCE;
|
||||
}
|
||||
|
||||
if (sGameLoopTicked != 0) {
|
||||
update_game_sound();
|
||||
sGameLoopTicked = 0;
|
||||
}
|
||||
|
||||
// For the function to match we have to preserve some arbitrary variable
|
||||
// across this function call.
|
||||
flags = 0;
|
||||
gAudioCmd = synthesis_execute(gAudioCmd, &writtenCmds, gCurrAiBuffer, gAiBufferLengths[index]);
|
||||
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
|
||||
|
||||
index = gAudioTaskIndex;
|
||||
gAudioTask->msgqueue = NULL;
|
||||
gAudioTask->msg = NULL;
|
||||
|
||||
task = &gAudioTask->task.t;
|
||||
task->type = M_AUDTASK;
|
||||
task->flags = flags;
|
||||
task->ucode_boot = rspF3DBootStart;
|
||||
task->ucode_boot_size = (u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart;
|
||||
task->ucode = rspAspMainStart;
|
||||
task->ucode_size = 0x800; // (this size is ignored)
|
||||
task->ucode_data = rspAspMainDataStart;
|
||||
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
|
||||
task->dram_stack = NULL;
|
||||
task->dram_stack_size = 0;
|
||||
task->output_buff = NULL;
|
||||
task->output_buff_size = NULL;
|
||||
task->data_ptr = gAudioCmdBuffers[index];
|
||||
task->data_size = writtenCmds * sizeof(u64);
|
||||
|
||||
// The audio task never yields, so having a yield buffer is pointless.
|
||||
// This wastefulness was fixed in US.
|
||||
#ifdef VERSION_JP
|
||||
task->yield_data_ptr = (u64 *) gAudioSPTaskYieldBuffer;
|
||||
task->yield_data_size = OS_YIELD_AUDIO_SIZE;
|
||||
#else
|
||||
task->yield_data_ptr = NULL;
|
||||
task->yield_data_size = 0;
|
||||
// Stubbed N64-US/JP audio code
|
||||
// continue;
|
||||
#endif
|
||||
|
||||
decrease_sample_dma_ttls();
|
||||
return gAudioTask;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef TARGET_N64
|
||||
struct SPTask *create_next_audio_frame_task(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void create_next_audio_buffer(s16 *samples, u32 num_samples) {
|
||||
gAudioFrameCount++;
|
||||
if (sGameLoopTicked != 0) {
|
||||
@@ -886,7 +785,6 @@ void create_next_audio_buffer(s16 *samples, u32 num_samples) {
|
||||
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
|
||||
decrease_sample_dma_ttls();
|
||||
}
|
||||
#endif
|
||||
|
||||
void play_sound(s32 soundBits, f32 *pos) {
|
||||
sSoundRequests[sSoundRequestCount].soundBits = soundBits;
|
||||
|
||||
+1
-6
@@ -651,12 +651,7 @@ s32 audio_shut_down_and_reset_step(void) {
|
||||
*/
|
||||
void wait_for_audio_frames(s32 frames) {
|
||||
gAudioFrameCount = 0;
|
||||
#ifdef TARGET_N64
|
||||
// Sound thread will update gAudioFrameCount
|
||||
while (gAudioFrameCount < frames) {
|
||||
// spin
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -507,9 +507,6 @@ struct Note
|
||||
/* U/J, EU */
|
||||
/*0xA4, 0x00*/ struct AudioListItem listItem;
|
||||
/* 0x10*/ struct NoteSynthesisState synthesisState;
|
||||
#ifdef TARGET_N64
|
||||
u8 pad0[12];
|
||||
#endif
|
||||
/*0x04, 0x30*/ u8 priority;
|
||||
/* 0x31*/ u8 waveId;
|
||||
/* 0x32*/ u8 sampleCountIndex;
|
||||
|
||||
@@ -34,107 +34,6 @@ void decrease_sample_dma_ttls(void);
|
||||
s32 audio_shut_down_and_reset_step(void);
|
||||
void func_802ad7ec(u32);
|
||||
|
||||
#ifdef TARGET_N64
|
||||
struct SPTask *create_next_audio_frame_task(void) {
|
||||
u32 samplesRemainingInAI;
|
||||
s32 writtenCmds;
|
||||
s32 index;
|
||||
OSTask_t *task;
|
||||
s32 flags;
|
||||
u16 *currAiBuffer;
|
||||
s32 oldDmaCount;
|
||||
OSMesg sp30;
|
||||
OSMesg sp2C;
|
||||
|
||||
gAudioFrameCount++;
|
||||
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0) {
|
||||
stubbed_printf("DAC:Lost 1 Frame.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
osSendMesg(OSMesgQueues[0], (OSMesg) gAudioFrameCount, 0);
|
||||
|
||||
gAudioTaskIndex ^= 1;
|
||||
gCurrAiBufferIndex++;
|
||||
gCurrAiBufferIndex %= NUMAIBUFFERS;
|
||||
index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS;
|
||||
samplesRemainingInAI = osAiGetLength() / 4;
|
||||
|
||||
if (gAiBufferLengths[index] != 0) {
|
||||
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
|
||||
}
|
||||
|
||||
oldDmaCount = gCurrAudioFrameDmaCount;
|
||||
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) {
|
||||
stubbed_printf("DMA: Request queue over.( %d )\n", oldDmaCount);
|
||||
}
|
||||
gCurrAudioFrameDmaCount = 0;
|
||||
|
||||
decrease_sample_dma_ttls();
|
||||
if (osRecvMesg(OSMesgQueues[2], &sp30, 0) != -1) {
|
||||
gAudioResetPresetIdToLoad = (u8) (s32) sp30;
|
||||
gAudioResetStatus = 5;
|
||||
}
|
||||
|
||||
if (gAudioResetStatus != 0) {
|
||||
if (audio_shut_down_and_reset_step() == 0) {
|
||||
if (gAudioResetStatus == 0) {
|
||||
osSendMesg(OSMesgQueues[3], (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gAudioTask = &gAudioTasks[gAudioTaskIndex];
|
||||
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
|
||||
index = gCurrAiBufferIndex;
|
||||
currAiBuffer = gAiBuffers[index];
|
||||
|
||||
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI +
|
||||
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE;
|
||||
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
|
||||
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
|
||||
}
|
||||
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
|
||||
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
|
||||
}
|
||||
|
||||
if (osRecvMesg(OSMesgQueues[1], &sp2C, OS_MESG_NOBLOCK) != -1) {
|
||||
func_802ad7ec((u32) sp2C);
|
||||
}
|
||||
|
||||
flags = 0;
|
||||
gAudioCmd = synthesis_execute(gAudioCmd, &writtenCmds, currAiBuffer, gAiBufferLengths[index]);
|
||||
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
|
||||
gAudioRandom = gAudioRandom + writtenCmds / 8;
|
||||
|
||||
index = gAudioTaskIndex;
|
||||
gAudioTask->msgqueue = NULL;
|
||||
gAudioTask->msg = NULL;
|
||||
|
||||
task = &gAudioTask->task.t;
|
||||
task->type = M_AUDTASK;
|
||||
task->flags = flags;
|
||||
#if TARGET_N64
|
||||
task->ucode_boot = rspF3DBootStart;
|
||||
task->ucode_boot_size = (u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart;
|
||||
task->ucode = rspAspMainStart;
|
||||
task->ucode_data = rspAspMainDataStart;
|
||||
task->ucode_size = 0x800; // (this size is ignored)
|
||||
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
|
||||
#endif
|
||||
task->dram_stack = NULL;
|
||||
task->dram_stack_size = 0;
|
||||
task->output_buff = NULL;
|
||||
task->output_buff_size = NULL;
|
||||
task->data_ptr = gAudioCmdBuffers[index];
|
||||
task->data_size = writtenCmds * sizeof(u64);
|
||||
task->yield_data_ptr = NULL;
|
||||
task->yield_data_size = 0;
|
||||
return gAudioTask;
|
||||
}
|
||||
#endif
|
||||
|
||||
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
|
||||
s32 i;
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@
|
||||
#include "seqplayer.h"
|
||||
#include "external.h"
|
||||
|
||||
|
||||
#ifndef TARGET_N64
|
||||
#include "../pc/mixer.h"
|
||||
#endif
|
||||
|
||||
#define DMEM_ADDR_TEMP 0x0
|
||||
#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x180
|
||||
|
||||
@@ -27,11 +27,8 @@ extern struct SaveBuffer gSaveBuffer;
|
||||
|
||||
extern u8 gGfxSPTaskStack[];
|
||||
|
||||
#ifdef TARGET_N64
|
||||
#define GFX_NUM_POOLS 2
|
||||
#else
|
||||
#define GFX_NUM_POOLS 1
|
||||
#endif
|
||||
|
||||
extern struct GfxPool gGfxPools[GFX_NUM_POOLS];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <ultra64.h>
|
||||
#ifndef TARGET_N64
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "sm64.h"
|
||||
#include "audio/external.h"
|
||||
@@ -605,9 +604,7 @@ static void level_cmd_set_gamma(void) {
|
||||
|
||||
static void level_cmd_set_terrain_data(void) {
|
||||
if (sCurrAreaIndex != -1) {
|
||||
#ifdef TARGET_N64
|
||||
gAreas[sCurrAreaIndex].terrainData = segmented_to_virtual(CMD_GET(void *, 4));
|
||||
#else
|
||||
|
||||
Collision *data;
|
||||
u32 size;
|
||||
|
||||
@@ -615,7 +612,7 @@ static void level_cmd_set_terrain_data(void) {
|
||||
size = get_area_terrain_size(data) * sizeof(Collision);
|
||||
gAreas[sCurrAreaIndex].terrainData = alloc_only_pool_alloc(sLevelPool, size);
|
||||
memcpy(gAreas[sCurrAreaIndex].terrainData, data, size);
|
||||
#endif
|
||||
|
||||
}
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
@@ -629,9 +626,7 @@ static void level_cmd_set_rooms(void) {
|
||||
|
||||
static void level_cmd_set_macro_objects(void) {
|
||||
if (sCurrAreaIndex != -1) {
|
||||
#ifdef TARGET_N64
|
||||
gAreas[sCurrAreaIndex].macroObjects = segmented_to_virtual(CMD_GET(void *, 4));
|
||||
#else
|
||||
|
||||
MacroObject *data = segmented_to_virtual(CMD_GET(void *, 4));
|
||||
s32 len = 0;
|
||||
while (data[len++] != 0x001E) {
|
||||
@@ -639,7 +634,7 @@ static void level_cmd_set_macro_objects(void) {
|
||||
}
|
||||
gAreas[sCurrAreaIndex].macroObjects = alloc_only_pool_alloc(sLevelPool, len * sizeof(MacroObject));
|
||||
memcpy(gAreas[sCurrAreaIndex].macroObjects, data, len * sizeof(MacroObject));
|
||||
#endif
|
||||
|
||||
}
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
|
||||
@@ -533,7 +533,6 @@ void alloc_surface_pools(void) {
|
||||
reset_red_coins_collected();
|
||||
}
|
||||
|
||||
#ifndef TARGET_N64
|
||||
/**
|
||||
* Get the size of the terrain data, to get the correct size when copying later.
|
||||
*/
|
||||
@@ -581,8 +580,6 @@ u32 get_area_terrain_size(s16 *data) {
|
||||
|
||||
return data - startPos;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Process the level file, loading in vertices, surfaces, some objects, and environmental
|
||||
|
||||
@@ -28,9 +28,9 @@ extern struct Surface *sSurfacePool;
|
||||
extern s16 sSurfacePoolSize;
|
||||
|
||||
void alloc_surface_pools(void);
|
||||
#ifndef TARGET_N64
|
||||
|
||||
u32 get_area_terrain_size(s16 *data);
|
||||
#endif
|
||||
|
||||
void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects);
|
||||
void clear_dynamic_surfaces(void);
|
||||
void load_object_collision_model(void);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user