mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
There is no audio, but at least goddard is working now <3
This commit is contained in:
@@ -15,6 +15,8 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
|
||||
set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use")
|
||||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
|
||||
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MT>)
|
||||
#add_compile_options(-fsanitize=address)
|
||||
#add_link_options(-fsanitize=address)
|
||||
|
||||
# Add a custom module path to locate additional CMake modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||
|
||||
@@ -39,15 +39,7 @@
|
||||
#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 // CONFIG_H
|
||||
|
||||
@@ -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 // MAKE_CONST_NONCONST_H
|
||||
|
||||
@@ -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
-1
@@ -488,7 +488,7 @@ extern void osViBlack(u8);
|
||||
extern void osViFade(u8, u16);
|
||||
extern void osViRepeatLine(u8);
|
||||
extern void osCreateViManager(OSPri);
|
||||
extern u32 osVirtualToPhysical(void *);
|
||||
extern uintptr_t osVirtualToPhysical(void *addr);
|
||||
extern void * osPhysicalToVirtual(u32);
|
||||
extern void osMapTLB(int32_t a, uint32_t b, void* c, uint32_t d, uint32_t e, uint32_t f);
|
||||
#ifndef TRUE
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
|
||||
// - memory used for temporary sequences
|
||||
// - memory used for temporary banks
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
struct AudioSessionSettings gAudioSessionPresets[18] = {
|
||||
struct AudioSessionSettings gAudioSessionPresets[] = {
|
||||
#ifdef VERSION_JP
|
||||
{ 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
|
||||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
extern struct AudioSessionSettingsEU gAudioSessionPresets[];
|
||||
#else
|
||||
extern struct AudioSessionSettings gAudioSessionPresets[18];
|
||||
extern struct AudioSessionSettings gAudioSessionPresets[];
|
||||
#endif
|
||||
extern u16 D_80332388[128]; // unused
|
||||
|
||||
|
||||
@@ -1087,10 +1087,6 @@ s32 audio_shut_down_and_reset_step(void) {
|
||||
*/
|
||||
void wait_for_audio_frames(s32 frames) {
|
||||
gAudioFrameCount = 0;
|
||||
// Sound thread will update gAudioFrameCount
|
||||
while (gAudioFrameCount < frames) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -302,10 +302,10 @@ struct SequencePlayer {
|
||||
/*0x08C, 0x090*/ u8 *shortNoteDurationTable;
|
||||
/*0x090, 0x094*/ struct NotePool notePool;
|
||||
/*0x0D0, 0x0D4*/ OSMesgQueue seqDmaMesgQueue;
|
||||
/*0x0E8, 0x0EC*/ OSMesg* seqDmaMesg;
|
||||
/*0x0E8, 0x0EC*/ OSMesg seqDmaMesg;
|
||||
/*0x0EC, 0x0F0*/ OSIoMesg seqDmaIoMesg;
|
||||
/*0x100, 0x108*/ OSMesgQueue bankDmaMesgQueue;
|
||||
/*0x118, 0x120*/ OSMesg* bankDmaMesg;
|
||||
/*0x118, 0x120*/ OSMesg bankDmaMesg;
|
||||
/*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg;
|
||||
/*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr;
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
@@ -616,9 +616,6 @@ struct Note {
|
||||
// when needed... This breaks alignment on non-N64 platforms, which we hack
|
||||
// around by skipping the padding in that case.
|
||||
// TODO: use macros or something instead.
|
||||
#ifdef TARGET_N64
|
||||
u8 pad0[12];
|
||||
#endif
|
||||
|
||||
/*0x04, 0x30, 0x30*/ u8 priority;
|
||||
/* 0x31, 0x31*/ u8 waveId;
|
||||
|
||||
+13
-31
@@ -7,6 +7,8 @@
|
||||
#include "heap.h"
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
|
||||
@@ -106,15 +108,16 @@ extern u8 gBankSetsData[]; // bank_sets.s
|
||||
|
||||
ALSeqFile *get_audio_file_header(s32 arg0);
|
||||
|
||||
#include <stdio.h>
|
||||
/**
|
||||
* Performs an immediate DMA copy
|
||||
*/
|
||||
void audio_dma_copy_immediate(uintptr_t devAddr, void *vAddr, size_t nbytes) {
|
||||
eu_stubbed_printf_3("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
|
||||
printf("Romcopy %x -> %x ,size %x\n", devAddr, vAddr, nbytes);
|
||||
osInvalDCache(vAddr, nbytes);
|
||||
osPiStartDma(&gAudioDmaIoMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, vAddr, nbytes,
|
||||
&gAudioDmaMesgQueue);
|
||||
osRecvMesg(&gAudioDmaMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
osRecvMesg(&gAudioDmaMesgQueue, NULL, OS_MESG_NOBLOCK);
|
||||
eu_stubbed_printf_0("Romcopyend\n");
|
||||
}
|
||||
|
||||
@@ -658,7 +661,7 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
mesgQueue = &seqPlayer->bankDmaMesgQueue;
|
||||
osCreateMesgQueue(mesgQueue, &seqPlayer->bankDmaMesg, 1);
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
seqPlayer->bankDmaMesg = NULL;
|
||||
seqPlayer->bankDmaMesg = OS_MESG_PTR(NULL);
|
||||
#endif
|
||||
seqPlayer->bankDmaInProgress = TRUE;
|
||||
audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr,
|
||||
@@ -712,7 +715,7 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
|
||||
mesgQueue = &seqPlayer->seqDmaMesgQueue;
|
||||
osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1);
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
seqPlayer->seqDmaMesg = NULL;
|
||||
seqPlayer->seqDmaMesg = OS_MESG_PTR(NULL);
|
||||
#endif
|
||||
seqPlayer->seqDmaInProgress = TRUE;
|
||||
audio_dma_copy_async((uintptr_t)(seqData + 0x40), (u8 *) ptr + 0x40, seqLength - 0x40, mesgQueue,
|
||||
@@ -941,30 +944,12 @@ void audio_init() {
|
||||
((u64 *) gAudioHeap)[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef TARGET_N64
|
||||
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
|
||||
i = 0;
|
||||
lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
|
||||
ptr64 = &gAudioGlobalsStartMarker - 1;
|
||||
for (k = lim3; k >= 0; k--) {
|
||||
i++;
|
||||
ptr64[i] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
for (i = 0; i < gAudioHeapSize / 8; i++) {
|
||||
((u64 *) gAudioHeap)[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef TARGET_N64
|
||||
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
|
||||
lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
|
||||
ptr64 = &gAudioGlobalsStartMarker;
|
||||
for (k = lim3; k >= 0; k--) {
|
||||
*ptr64++ = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
D_EU_802298D0 = 20.03042f;
|
||||
gRefreshRate = 50;
|
||||
@@ -973,14 +958,6 @@ void audio_init() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_N64
|
||||
eu_stubbed_printf_3(
|
||||
"Clear Workarea %x -%x size %x \n",
|
||||
(uintptr_t) &gAudioGlobalsStartMarker,
|
||||
(uintptr_t) &gAudioGlobalsEndMarker,
|
||||
(uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker
|
||||
);
|
||||
#endif
|
||||
|
||||
eu_stubbed_printf_1("AudioHeap is %x\n", gAudioHeapSize);
|
||||
|
||||
@@ -1016,7 +993,9 @@ void audio_init() {
|
||||
gAudioResetStatus = 1;
|
||||
audio_shut_down_and_reset_step();
|
||||
#else
|
||||
printf("Crashes Here?\n");
|
||||
audio_reset_session(&gAudioSessionPresets[0]);
|
||||
printf("Nope\n");
|
||||
#endif
|
||||
|
||||
// Not sure about these prints
|
||||
@@ -1035,9 +1014,11 @@ void audio_init() {
|
||||
#else
|
||||
size = ALIGN16(gSequenceCount * sizeof(ALSeqData) + 4);
|
||||
#endif
|
||||
printf("Crashes Here?\n");
|
||||
gSeqFileHeader = soundAlloc(&gAudioInitPool, size);
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, size);
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
printf("Nope\n");
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
gAlCtlHeader = (ALSeqFile *) buf;
|
||||
@@ -1060,9 +1041,10 @@ void audio_init() {
|
||||
alSeqFileNew(gAlTbl, gSoundDataRaw);
|
||||
|
||||
// Load bank sets for each sequence
|
||||
printf("Crashes Here on bank sets?\n");
|
||||
gAlBankSets = soundAlloc(&gAudioInitPool, 0x100);
|
||||
audio_dma_copy_immediate((uintptr_t) gBankSetsData, gAlBankSets, 0x100);
|
||||
|
||||
printf("Nope\n");
|
||||
init_sequence_players();
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
// Should probably contain the sizes of the data banks, but those aren't
|
||||
|
||||
@@ -1013,27 +1013,11 @@ void audio_init() {
|
||||
((u64 *) gAudioHeap)[i] = 0;
|
||||
}
|
||||
|
||||
#ifdef TARGET_N64
|
||||
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
|
||||
lim = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
|
||||
ptr64 = &gAudioGlobalsStartMarker;
|
||||
for (k = lim; k >= 0; k--) {
|
||||
*ptr64++ = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
D_EU_802298D0 = 16.713f;
|
||||
gRefreshRate = 60;
|
||||
port_eu_init();
|
||||
|
||||
#ifdef TARGET_N64
|
||||
eu_stubbed_printf_3(
|
||||
"Clear Workarea %x -%x size %x \n",
|
||||
(uintptr_t) &gAudioGlobalsStartMarker,
|
||||
(uintptr_t) &gAudioGlobalsEndMarker,
|
||||
(uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker
|
||||
);
|
||||
#endif
|
||||
|
||||
eu_stubbed_printf_1("AudioHeap is %x\n", gAudioHeapSize);
|
||||
|
||||
|
||||
@@ -2265,7 +2265,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
&seqPlayer->bankDmaIoMesg);
|
||||
}
|
||||
#else
|
||||
if (seqPlayer->bankDmaMesg == NULL) {
|
||||
if (!OS_MESG_VALID(seqPlayer->bankDmaMesg)) {
|
||||
return;
|
||||
}
|
||||
if (seqPlayer->bankDmaRemaining == 0) {
|
||||
@@ -2279,7 +2279,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
gBankLoadStatus[seqPlayer->loadingBankId] = SOUND_LOAD_STATUS_COMPLETE;
|
||||
} else {
|
||||
osCreateMesgQueue(&seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaMesg, 1);
|
||||
seqPlayer->bankDmaMesg = NULL;
|
||||
seqPlayer->bankDmaMesg = OS_MESG_PTR(NULL);
|
||||
audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr,
|
||||
&seqPlayer->bankDmaRemaining, &seqPlayer->bankDmaMesgQueue,
|
||||
&seqPlayer->bankDmaIoMesg);
|
||||
@@ -2294,7 +2294,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) {
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (seqPlayer->seqDmaMesg == NULL) {
|
||||
if (!OS_MESG_VALID(seqPlayer->seqDmaMesg)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
+41
-46
@@ -245,27 +245,22 @@ void make_viewport_clip_rect(Vp *viewport) {
|
||||
* If you plan on using gSPLoadUcode, make sure to add OS_TASK_LOADABLE to the flags member.
|
||||
*/
|
||||
void create_gfx_task_structure(void) {
|
||||
// s32 entries = gDisplayListHead - gGfxPool->buffer;
|
||||
s32 entries = gDisplayListHead - gGfxPool->buffer;
|
||||
|
||||
// gGfxSPTask->msgqueue = &gGfxVblankQueue;
|
||||
// gGfxSPTask->msg = OS_MESG_32(2);
|
||||
// gGfxSPTask->task.t.type = M_GFXTASK;
|
||||
// gGfxSPTask->task.t.ucode_boot = rspF3DBootStart;
|
||||
// gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart);
|
||||
// gGfxSPTask->task.t.flags = 0;
|
||||
// gGfxSPTask->task.t.ucode = rspF3DStart;
|
||||
// gGfxSPTask->task.t.ucode_data = rspF3DDataStart;
|
||||
// gGfxSPTask->task.t.ucode_size = SP_UCODE_SIZE; // (this size is ignored)
|
||||
// gGfxSPTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE;
|
||||
// gGfxSPTask->task.t.dram_stack = (u64 *) gGfxSPTaskStack;
|
||||
// gGfxSPTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8;
|
||||
// gGfxSPTask->task.t.output_buff = gGfxSPTaskOutputBuffer;
|
||||
// gGfxSPTask->task.t.output_buff_size =
|
||||
// (u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer));
|
||||
// gGfxSPTask->task.t.data_ptr = (u64 *) &gGfxPool->buffer;
|
||||
// gGfxSPTask->task.t.data_size = entries * sizeof(Gfx);
|
||||
// gGfxSPTask->task.t.yield_data_ptr = (u64 *) gGfxSPTaskYieldBuffer;
|
||||
// gGfxSPTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE;
|
||||
gGfxSPTask->msgqueue = &gGfxVblankQueue;
|
||||
gGfxSPTask->msg = OS_MESG_32(2);
|
||||
gGfxSPTask->task.t.type = M_GFXTASK;
|
||||
gGfxSPTask->task.t.ucode_size = SP_UCODE_SIZE; // (this size is ignored)
|
||||
gGfxSPTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE;
|
||||
gGfxSPTask->task.t.dram_stack = (u64 *) gGfxSPTaskStack;
|
||||
gGfxSPTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8;
|
||||
gGfxSPTask->task.t.output_buff = gGfxSPTaskOutputBuffer;
|
||||
gGfxSPTask->task.t.output_buff_size =
|
||||
(u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer));
|
||||
gGfxSPTask->task.t.data_ptr = (u64 *) &gGfxPool->buffer;
|
||||
gGfxSPTask->task.t.data_size = entries * sizeof(Gfx);
|
||||
gGfxSPTask->task.t.yield_data_ptr = (u64 *) gGfxSPTaskYieldBuffer;
|
||||
gGfxSPTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,17 +357,17 @@ void select_gfx_pool(void) {
|
||||
*/
|
||||
void display_and_vsync(void) {
|
||||
profiler_log_thread5_time(BEFORE_DISPLAY_LISTS);
|
||||
osRecvMesg(&gGfxVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&gGfxVblankQueue, &gMainReceivedMesg, OS_MESG_NOBLOCK);
|
||||
if (gGoddardVblankCallback != NULL) {
|
||||
gGoddardVblankCallback();
|
||||
gGoddardVblankCallback = NULL;
|
||||
}
|
||||
exec_display_list(&gGfxPool->spTask);
|
||||
profiler_log_thread5_time(AFTER_DISPLAY_LISTS);
|
||||
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_NOBLOCK);
|
||||
osViSwapBuffer((void *) PHYSICAL_TO_VIRTUAL(gPhysicalFramebuffers[sRenderedFramebuffer]));
|
||||
profiler_log_thread5_time(THREAD5_END);
|
||||
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_NOBLOCK);
|
||||
if (++sRenderedFramebuffer == 3) {
|
||||
sRenderedFramebuffer = 0;
|
||||
}
|
||||
@@ -662,37 +657,37 @@ void thread5_game_loop() {
|
||||
|
||||
play_music(SEQ_PLAYER_SFX, SEQUENCE_ARGS(0, SEQ_SOUND_PLAYER), 0);
|
||||
set_sound_mode(save_file_get_sound_mode());
|
||||
render_init();
|
||||
gGlobalTimer++;
|
||||
}
|
||||
|
||||
void thread5_iteration(void){
|
||||
// If the reset timer is active, run the process to reset the game.
|
||||
if (gResetTimer != 0) {
|
||||
draw_reset_bars();
|
||||
return;
|
||||
}
|
||||
profiler_log_thread5_time(THREAD5_START);
|
||||
if (gResetTimer != 0) {
|
||||
draw_reset_bars();
|
||||
return;
|
||||
}
|
||||
profiler_log_thread5_time(THREAD5_START);
|
||||
|
||||
// If any controllers are plugged in, start read the data for when
|
||||
// read_controller_inputs is called later.
|
||||
if (gControllerBits) {
|
||||
// If any controllers are plugged in, start read the data for when
|
||||
// read_controller_inputs is called later.
|
||||
if (gControllerBits) {
|
||||
#if ENABLE_RUMBLE
|
||||
block_until_rumble_pak_free();
|
||||
block_until_rumble_pak_free();
|
||||
#endif
|
||||
osContStartReadData(&gSIEventMesgQueue);
|
||||
}
|
||||
osContStartReadData(&gSIEventMesgQueue);
|
||||
}
|
||||
|
||||
audio_game_loop_tick();
|
||||
select_gfx_pool();
|
||||
read_controller_inputs();
|
||||
addr = level_script_execute(addr);
|
||||
audio_game_loop_tick();
|
||||
select_gfx_pool();
|
||||
read_controller_inputs();
|
||||
addr = level_script_execute(addr);
|
||||
|
||||
display_and_vsync();
|
||||
display_and_vsync();
|
||||
|
||||
// when debug info is enabled, print the "BUF %d" information.
|
||||
if (gShowDebugText) {
|
||||
// subtract the end of the gfx pool with the display list to obtain the
|
||||
// amount of free space remaining.
|
||||
print_text_fmt_int(180, 20, "BUF %d", gGfxPoolEnd - (u8 *) gDisplayListHead);
|
||||
}
|
||||
// when debug info is enabled, print the "BUF %d" information.
|
||||
if (gShowDebugText) {
|
||||
// subtract the end of the gfx pool with the display list to obtain the
|
||||
// amount of free space remaining.
|
||||
print_text_fmt_int(180, 20, "BUF %d", gGfxPoolEnd - (u8 *) gDisplayListHead);
|
||||
}
|
||||
}
|
||||
+2
-14
@@ -11,6 +11,7 @@
|
||||
#include "memory.h"
|
||||
#include "segment_symbols.h"
|
||||
#include "segments.h"
|
||||
#include <string.h>
|
||||
|
||||
// round up to the next multiple
|
||||
#define ALIGN4(val) (((val) + 0x3) & ~0x3)
|
||||
@@ -221,20 +222,7 @@ u32 main_pool_pop_state(void) {
|
||||
* function blocks until completion.
|
||||
*/
|
||||
static void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
u32 size = ALIGN16(srcEnd - srcStart);
|
||||
|
||||
osInvalDCache(dest, size);
|
||||
while (size != 0) {
|
||||
u32 copySize = (size >= 0x1000) ? 0x1000 : size;
|
||||
|
||||
osPiStartDma(&gDmaIoMesg, OS_MESG_PRI_NORMAL, OS_READ, (uintptr_t) srcStart, dest, copySize,
|
||||
&gDmaMesgQueue);
|
||||
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
|
||||
dest += copySize;
|
||||
srcStart += copySize;
|
||||
size -= copySize;
|
||||
}
|
||||
memcpy(dest, srcStart, srcEnd - srcStart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2369,7 +2369,6 @@ void start_view_dl(struct ObjView *view) {
|
||||
uly = lry - 1.0f;
|
||||
}
|
||||
|
||||
gDPSetScissor(next_gfx(), G_SC_NON_INTERLACE, ulx, uly, lrx, lry);
|
||||
gSPClearGeometryMode(next_gfx(), 0xFFFFFFFF);
|
||||
gSPSetGeometryMode(next_gfx(), G_LIGHTING | G_CULL_BACK | G_SHADING_SMOOTH | G_SHADE);
|
||||
if (view->flags & VIEW_ALLOC_ZBUF) {
|
||||
|
||||
+12
-12
@@ -20,7 +20,7 @@ u32 gNumVblanks = 0;
|
||||
s8 gNmiResetBarsTimer = 0;
|
||||
u64 osClockRate = 62500000;
|
||||
|
||||
s8 sAudioEnabled = TRUE;
|
||||
s8 sAudioEnabled = FALSE;
|
||||
s8 gShowProfiler = FALSE;
|
||||
s8 gShowDebugText = FALSE;
|
||||
s8 gDebugLevelSelect = FALSE;
|
||||
@@ -36,10 +36,8 @@ void set_vblank_handler(s32 index, VblankHandler *handler, OSMesgQueue *queue, O
|
||||
void dispatch_audio_sptask(SPTask *spTask) {}
|
||||
|
||||
void alloc_pool(void) {
|
||||
void *start = (void *) SEG_POOL_START;
|
||||
void *end = (void *) SEG_POOL_END;
|
||||
|
||||
main_pool_init(start, end);
|
||||
static u64 pool[0x165000 * sizeof(void *)];
|
||||
main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0]));
|
||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||
}
|
||||
|
||||
@@ -55,15 +53,17 @@ void push_frame(void) {
|
||||
GameEngine_StartFrame();
|
||||
thread5_iteration();
|
||||
|
||||
int samples_left = AudioPlayerBuffered();
|
||||
u32 num_audio_samples = samples_left < AudioPlayerGetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
if(sAudioEnabled) {
|
||||
int samples_left = AudioPlayerBuffered();
|
||||
u32 num_audio_samples = samples_left < AudioPlayerGetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
|
||||
s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2];
|
||||
for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
|
||||
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
|
||||
s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2];
|
||||
for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
|
||||
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
|
||||
}
|
||||
|
||||
AudioPlayerPlayFrame((u8 *) audio_buffer, 2 * num_audio_samples * 4);
|
||||
}
|
||||
|
||||
AudioPlayerPlayFrame((u8*)audio_buffer, 2 * num_audio_samples * 4);
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Globals.h"
|
||||
#include "ImguiUI.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
@@ -16,6 +17,7 @@ GameEngine::GameEngine(){
|
||||
|
||||
void GameEngine_Create(void){
|
||||
GameEngine::Instance = new GameEngine();
|
||||
GameUI::SetupGuiElements();
|
||||
}
|
||||
|
||||
void GameEngine_StartFrame(void){
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "ImguiUI.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <ImGui/imgui.h>
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
#include <ImGui/imgui_internal.h>
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <Fast3D/gfx_pc.h>
|
||||
|
||||
namespace GameUI {
|
||||
std::shared_ptr<LUS::GuiWindow> mConsoleWindow;
|
||||
std::shared_ptr<LUS::GuiWindow> mStatsWindow;
|
||||
std::shared_ptr<LUS::GuiWindow> mInputEditorWindow;
|
||||
|
||||
void SetupGuiElements() {
|
||||
auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui();
|
||||
|
||||
mStatsWindow = gui->GetGuiWindow("Stats");
|
||||
if (mStatsWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find stats window");
|
||||
}
|
||||
|
||||
mConsoleWindow = gui->GetGuiWindow("Console");
|
||||
if (mConsoleWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find console window");
|
||||
}
|
||||
|
||||
mInputEditorWindow = gui->GetGuiWindow("Input Editor");
|
||||
if (mInputEditorWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find input editor window");
|
||||
return;
|
||||
}
|
||||
mInputEditorWindow->ToggleVisibility();
|
||||
}
|
||||
|
||||
void Destroy() {
|
||||
mConsoleWindow = nullptr;
|
||||
mStatsWindow = nullptr;
|
||||
mInputEditorWindow = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace GameUI {
|
||||
void SetupGuiElements();
|
||||
void Destroy();
|
||||
}
|
||||
Reference in New Issue
Block a user