lib fixes

This commit is contained in:
CrashOveride95
2021-01-24 21:34:11 -05:00
parent 3a9ee0ca7c
commit 5b88275a92
11 changed files with 8 additions and 166 deletions

View File

@@ -146,7 +146,7 @@ ifeq ($(COMPILER),ido)
else ifeq ($(COMPILER),gcc)
NON_MATCHING := 1
MIPSISET := -mips3
OPT_FLAGS := -O2
# OPT_FLAGS := -O2
endif
@@ -822,7 +822,7 @@ $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT)
# Link SM64 ELF file
$(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
$(V)$(LD) -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -lultra_rom -Llib -lhvqm2 -lgcc -lz
$(V)$(LD) -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -lultra_rom -Llib -lgcc -lnustd -lhvqm2 -lz
# Build ROM
$(ROM): $(ELF)

Binary file not shown.

BIN
lib/libnustd.a Normal file

Binary file not shown.

14
sm64.ld
View File

@@ -105,13 +105,6 @@ SECTIONS
/*ASSERT((. <= SEG_MAIN), "Error: buffers segment extended into main")*/
. = _buffersSegmentNoloadEnd;
/* lib/src/__osDevMgrMain.c and lib/src/osCreateViManager.c contain infinite
* loops compiled without -g, which cause the return statements and the .o
* files themselves to be aligned to 32-byte boundaries. But the linker
* Nintendo used did not respect .o file alignment, and aligned the files
* only to 16 bytes, in some cases misaligning them. We force the same to
* happen using the SUBALIGN directive. This is harmless; the alignment is
* just an optimization. */
BEGIN_SEG(main, .) SUBALIGN(16)
{
BUILD_DIR/asm/entry.o(.text);
@@ -130,8 +123,8 @@ SECTIONS
#ifdef YAY0
BUILD_DIR/asm/slidec.o(.text);
#endif
*/libultra_rom.a:*.o(.text);
*/libnustd.a:*.o(.text);
*/libgcc.a:_umoddi3.o(.text);
*/libgcc.a:_udivdi3.o(.text);
*/libgcc.a:_divdi3.o(.text);
@@ -142,8 +135,8 @@ SECTIONS
*/libgcc.a:_fixunssfdi.o(.text);
*/libgcc.a:_fixunsdfdi.o(.text);
*/libgcc.a:_floatdidf.o(.text);
*/libgcc.a:_floatundidf.o(.text);
*/libgcc.a:_floatdisf.o(.text);
*/libgcc.a:_fixunsdfdi.o(.text);
*/libgcc.a:_cmpdi2.o(.text);
#ifdef GZIP
*/libz.a:*.o(.text);
@@ -195,6 +188,9 @@ SECTIONS
*/libgcc.a:_umoddi3.o(.rodata*);
*/libgcc.a:_udivdi3.o(.rodata*);
*/libgcc.a:_divdi3.o(.rodata*);
*/libgcc.a:_clz.o(.rodata*);
*/libgcc.a:_fixunsdfdi.o(.rodata*);
*/libgcc.a:_floatundidf.o(.rodata*);
*/libgcc.a:_moddi3.o(.rodata*);
#ifdef HVQM
*/libhvqm2.a:*.o(.rodata*);

View File

@@ -10,9 +10,6 @@
#include "game/level_update.h"
#include "game/object_list_processor.h"
#include "game/camera.h"
#ifdef UNF
#include "usb/debug.h"
#endif
#include "seq_ids.h"
#include "dialog_ids.h"
@@ -2361,9 +2358,6 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
u8 i;
u8 foundIndex = 0;
#ifdef UNF
debug_printf("Just play them immediately, stopping any old sequence.\n");
#endif
// Except for the background music player, we don't support queued
// sequences. Just play them immediately, stopping any old sequence.
if (player != SEQ_PLAYER_LEVEL) {
@@ -2371,9 +2365,6 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
return;
}
#ifdef UNF
debug_printf("Abort if the queue is already full.\n");
#endif
// Abort if the queue is already full.
if (sBackgroundMusicQueueSize == MAX_BACKGROUND_MUSIC_QUEUE_SIZE) {
return;
@@ -2385,23 +2376,14 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
for (i = 0; i < sBackgroundMusicQueueSize; i++) {
if (sBackgroundMusicQueue[i].seqId == seqId) {
if (i == 0) {
#ifdef UNF
debug_printf("seq_player_play_sequence\n");
#endif
seq_player_play_sequence(SEQ_PLAYER_LEVEL, seqId, fadeTimer);
} else if (!gSequencePlayers[SEQ_PLAYER_LEVEL].enabled) {
#ifdef UNF
debug_printf("stop_background_music\n");
#endif
stop_background_music(sBackgroundMusicQueue[0].seqId);
}
return;
}
}
#ifdef UNF
debug_printf("Find the next sequence slot by priority.\n");
#endif
// Find the next sequence slot by priority.
for (i = 0; i < sBackgroundMusicQueueSize; i++) {
if (sBackgroundMusicQueue[i].priority <= priority) {
@@ -2413,9 +2395,6 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
// If the sequence ends up first in the queue, start it, and make space for
// one more entry in the queue.
if (foundIndex == 0) {
#ifdef UNF
debug_printf("seq_player_play_sequence\n");
#endif
seq_player_play_sequence(SEQ_PLAYER_LEVEL, seqId, fadeTimer);
sBackgroundMusicQueueSize++;
}

View File

@@ -14,9 +14,6 @@
#ifdef GZIP
#include "gzip/gzip.h"
#endif
#ifdef UNF
#include "usb/debug.h"
#endif
// round up to the next multiple
@@ -393,16 +390,10 @@ void load_engine_code_segment(void) {
UNUSED u32 alignedSize = ALIGN16(_engineSegmentRomEnd - _engineSegmentRomStart);
bzero(startAddr, totalSize);
#ifdef UNF
debug_printf("DMA-ing engine segment...");
#endif
osWritebackDCacheAll();
dma_read(startAddr, _engineSegmentRomStart, _engineSegmentRomEnd);
osInvalICache(startAddr, totalSize);
osInvalDCache(startAddr, totalSize);
#ifdef UNF
debug_printf("\rDMA-ing engine segment...Done!\n");
#endif
}
#endif

View File

@@ -7,7 +7,7 @@
// Settings
#define DEBUG_MODE 1 // Enable/Disable debug mode
#define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized
#define DEBUG_INIT_MSG 0 // Print a message when debug mode has initialized
#define USE_FAULTTHREAD 0 // Create a fault detection thread
#define OVERWRITE_OSPRINT 0 // Replaces osSyncPrintf calls with debug_printf
#define MAX_COMMANDS 25 // The max amount of user defined commands possible

View File

@@ -1,34 +0,0 @@
/*
=============================================================================
Copyright (C) 1997-1999 NINTENDO Co.,Ltd.
$RCSfile: memcmp.c,v $
$Revision: 1.1 $
$Date: 1999/04/14 07:18:40 $
=============================================================================
function name: memcmp
-----------------------------------------------------------------------------
format: #include <string.h>
int memcmp(const void *buf1, const void *buf2, size_t count)
argument: buf1 pointer to be compared
buf2 pointer to be compared
count the number of bytes to be compared
return value: if less than 0 buf1 is smaller than buf2
if 0 buf1 is equal to buf2
if more than 0 buf1 is larger than buf2
explanation: compares the contents of pointer buf1 and pointer buf2 by the number of count bytes
-----------------------------------------------------------------------------
*/
#include <string.h>
int memcmp(const void *buf1, const void *buf2, size_t count)
{
char *b1 = (char *)buf1, *b2 = (char *)buf2;
while(count) {
if (*b1 != *b2) return *b1 - *b2;
b1 ++;
b2 ++;
count--;
}
return 0;
}

View File

@@ -1,27 +0,0 @@
/*
=============================================================================
Copyright (C) 1997-1999 NINTENDO Co.,Ltd.
$RCSfile: memset.c,v $
$Revision: 1.1 $
$Date: 1999/04/14 07:18:41 $
=============================================================================
function name: memset
-----------------------------------------------------------------------------
format: #include <string.h>
void *memset(void* dst, int c, size_t count);
argument: dst pointer of destination to be written
c byte data to be written
count the number of characters to be written
return value: pointer of destination to be written, dst
explanation: writes byte data c from the pointer dst indicates by the amount of count
-----------------------------------------------------------------------------
*/
#include <string.h>
void *memset(void* dst, int c, size_t count)
{
char *p = (char *)dst;
while(count--) *p++ = c;
return dst;
}

View File

@@ -1,29 +0,0 @@
/*
=============================================================================
Copyright (C) 1997-1999 NINTENDO Co.,Ltd.
$RCSfile: strcat.c,v $
$Revision: 1.1 $
$Date: 1999/04/14 07:18:41 $
=============================================================================
function name: strcat
-----------------------------------------------------------------------------
format: #include <string.h>
char *strcat(char *str1, const char *str2);
argument: str1 character string buffer to be added
str2 character string buffer to add
return value: pointer of str1
explanation: adds character string, str2 to the end of character string, str1
-----------------------------------------------------------------------------
*/
#include <string.h>
char *strcat(char *str1, const char *str2)
{
char *p;
p = str1;
while(*p) p++;
while(*str2) *p++ = *str2++;
*p = '\0';
return str1;
}

View File

@@ -1,34 +0,0 @@
/*
=============================================================================
Copyright (C) 1997-1999 NINTENDO Co.,Ltd.
$RCSfile: strncmp.c,v $
$Revision: 1.1 $
$Date: 1999/04/14 07:18:42 $
=============================================================================
function name: strncmp
-----------------------------------------------------------------------------
format : #include <string.h>
int strncmp(const char *str1, const char *str2, int n)
argument: str1 character string buffer to be compared
str2 character string buffer to be compared
n character number to be compared
return value: if less than 0, str1 is smaller than str2
if 0 str1 is equal to str2
if more than 0, str1 is larger than str2
explanation: compares character string, str1 with character string, str2 by
n character
-----------------------------------------------------------------------------
*/
#include <string.h>
int strncmp(const char *str1, const char *str2, int n)
{
char c1 = 1,c2;
while(c1 && n--) {
c1=*str1++;
c2=*str2++;
if (c1 != c2) return c1 - c2;
}
return 0;
}