Skip to content

Commit

Permalink
Ultralib + Splat update (#53)
Browse files Browse the repository at this point in the history
* Remove old ultralib

* git subrepo clone [email protected]:decompals/ultralib.git lib/ultralib

subrepo:
  subdir:   "lib/ultralib"
  merged:   "2717d45"
upstream:
  origin:   "[email protected]:decompals/ultralib.git"
  branch:   "main"
  commit:   "2717d45"
git-subrepo:
  version:  "0.4.9"
  origin:   "[email protected]:ingydotnet/git-subrepo.git"
  commit:   "ea10886"

* Splat and ultralib fixes
  • Loading branch information
hensldm authored Dec 25, 2024
1 parent 32ee7ea commit 87be831
Show file tree
Hide file tree
Showing 335 changed files with 3,685 additions and 1,918 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ PYTHON ?= $(VENV)/$(VENV_BIN_DIR)/python3
# Emulator w/ flags
N64_EMULATOR ?=

PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))


BASEROM_DIR := baseroms/$(VERSION)
BASEROM := $(BASEROM_DIR)/baserom.z64
Expand Down Expand Up @@ -106,6 +108,7 @@ endif

CC := tools/ido/$(DETECTED_OS)/7.1/cc
CC_OLD := tools/ido/$(DETECTED_OS)/5.3/cc
CC_ULTRALIB := $(PROJECT_DIR)/$(CC_OLD)

AR := ar
AS := $(CROSS)as
Expand Down Expand Up @@ -306,7 +309,7 @@ $(LIBULTRA_LIB): $(ULTRALIB_LIB)
$(LIBDUMP_CMD)

$(ULTRALIB_LIB):
$(MAKE) -C lib/ultralib VERSION=$(ULTRALIB_VERSION) TARGET=$(ULTRALIB_TARGET) FIXUPS=1 CROSS=$(CROSS) CC=../../$(CC_OLD)
$(MAKE) -C lib/ultralib VERSION=$(ULTRALIB_VERSION) TARGET=$(ULTRALIB_TARGET) MODERN_LD=1 CROSS=$(CROSS) COMPILER_DIR=$(dir $(CC_ULTRALIB)) AR=$(AR)

$(BUILD_DIR)/%.ld: %.ld
$(CPP) $(CPPFLAGS) $(BUILD_DEFINES) $(IINC) $< > $@
Expand Down
4 changes: 2 additions & 2 deletions include/gfxprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ void gfxprint_locate8x8(gfxprint* this, s32 x, s32 y);
void gfxprint_setoffset(gfxprint* this, s32 x, s32 y);
void gfxprint_putc1(gfxprint* this, char c);
void gfxprint_putc(gfxprint* this, char c);
void gfxprint_write(gfxprint* this, const void* buffer, s32 size, s32 n);
void gfxprint_write(gfxprint* this, const void* buffer, size_t size, size_t n);
void gfxprint_puts(gfxprint* this, const char* buffer);
void* gfxprint_prout(void* this, const char* buffer, s32 n);
void* gfxprint_prout(void* this, const char* buffer, size_t n);
void gfxprint_init(gfxprint* this);
void gfxprint_cleanup(gfxprint* this);
void gfxprint_open(gfxprint* this, Gfx* gListp);
Expand Down
2 changes: 1 addition & 1 deletion lib/ultralib/.github/workflows/ci_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install package requirements
run: sudo apt-get install -y build-essential python3
run: sudo apt-get install -y binutils-mips-linux-gnu build-essential python3

- name: Get extra dependencies
uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions lib/ultralib/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:decompals/ultralib.git
branch = main
commit = 299d7faf8798cbe75e3247ccdf4e65c09f5270dd
parent = a3476fcc3a0fc47aa0c31f3ef04d08181daf3050
commit = 2717d451b99c336e87a9e8548969bb57e383cfa5
parent = 0f5de4873b7ff6118116e9ddd765fda39b0de474
method = merge
cmdver = 0.4.6
cmdver = 0.4.9
61 changes: 35 additions & 26 deletions lib/ultralib/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
COMPARE ?= 1
FIXUPS ?= 0
MODERN_LD ?= 0
MODERN_GCC ?= 0

ifneq ($(FIXUPS),0)
ifneq ($(MODERN_LD),0)
COMPARE := 0
endif

Expand All @@ -12,6 +13,20 @@ TARGET ?= libgultra_rom
VERSION ?= L
CROSS ?= mips-linux-gnu-

ifeq ($(findstring libgultra,$(TARGET)),libgultra)
COMPILER := gcc
else ifeq ($(findstring libultra,$(TARGET)),libultra)
COMPILER := ido
else
$(error Invalid Target)
endif

ifneq ($(MODERN_GCC),0)
COMPILER := modern_gcc
COMPARE := 0
MODERN_LD := 0
endif

BASE_DIR := extracted/$(VERSION)/$(TARGET)
BASE_AR := base/$(VERSION)/$(TARGET).a
BUILD_ROOT := build
Expand All @@ -21,34 +36,28 @@ BUILD_AR := $(BUILD_DIR)/$(TARGET).a
WORKING_DIR := $(shell pwd)

CPP := cpp -P
AR := ar
AR := $(CROSS)ar

VERSION_D := 1
VERSION_E := 2
VERSION_F := 3
VERSION_G := 4
VERSION_H := 5
VERSION_I := 6
VERSION_J := 7
VERSION_K := 8
VERSION_L := 9

VERSION_DEFINE := -DBUILD_VERSION=$(VERSION_$(VERSION)) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"
VERSION_DEFINE := -DBUILD_VERSION=VERSION_$(VERSION) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"

ifeq ($(findstring _d,$(TARGET)),_d)
DEBUGFLAG := -D_DEBUG
else
DEBUGFLAG := -DNDEBUG
endif

ifeq ($(findstring libgultra,$(TARGET)),libgultra)
-include Makefile.gcc
else ifeq ($(findstring libultra,$(TARGET)),libultra)
-include Makefile.ido
ifeq ($(COMPILER),gcc)
-include makefiles/gcc.mk
else ifeq ($(COMPILER),ido)
-include makefiles/ido.mk
else ifeq ($(COMPILER),modern_gcc)
-include makefiles/modern_gcc.mk
else
$(error Invalid Target)
$(error Invalid Compiler)
endif

export COMPILER_PATH := $(COMPILER_DIR)

ifeq ($(findstring _rom,$(TARGET)),_rom)
CPPFLAGS += -D_FINALROM
endif
Expand Down Expand Up @@ -166,10 +175,10 @@ $(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -DF3D_GBI
$(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE :=
$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE :=
$(BUILD_DIR)/src/voice/%.marker: OPTFLAGS += -DLANG_JAPANESE -I$(WORKING_DIR)/src -I$(WORKING_DIR)/src/voice
$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) -D__BUILD_DIR=$(BUILD_DIR)
$(BUILD_DIR)/src/voice/%.marker: CC := $(WORKING_DIR)/tools/compile_sjis.py -D__CC=$(CC) -D__BUILD_DIR=$(BUILD_DIR)

$(C_MARKER_FILES): $(BUILD_DIR)/%.marker: %.c
cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
cd $(<D) && $(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
Expand All @@ -179,7 +188,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
ifneq ($(FIXUPS),0)
ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
Expand All @@ -188,7 +197,7 @@ endif
@touch $@

$(S_MARKER_FILES): $(BUILD_DIR)/%.marker: %.s
cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
cd $(<D) && $(AS) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
Expand All @@ -198,7 +207,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
ifneq ($(FIXUPS),0)
ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
Expand All @@ -210,7 +219,7 @@ endif
$(MDEBUG_FILES): $(BUILD_DIR)/src/%.marker: src/%.s
cp $(<:.marker=.s) $(dir $@)
mkdir -p $(@:.marker=)
export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o))
export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(AS) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o))
mv $(@:.marker=)/$(<F:.s=.o) $(@:.marker=)/..
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
Expand All @@ -221,7 +230,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
ifneq ($(FIXUPS),0)
ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
Expand Down
14 changes: 10 additions & 4 deletions lib/ultralib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ If building without an target archive, than you can use `COMPARE=0` like the the
note that running setup without `COMPARE=0` and no archive will result in an error,
and only needs to be run once instead of per target flag combination

If building for use with modern linkers, than you can use `FIXUPS=1` like the the following:
If building for use with modern linkers, than you can use `MODERN_LD=1` like the following:

- `make VERSION=L TARGET=libgultra_rom FIXUPS=1 setup`
- `make VERSION=L TARGET=libgultra_rom FIXUPS=1`
- `make VERSION=L TARGET=libgultra_rom MODERN_LD=1 setup`
- `make VERSION=L TARGET=libgultra_rom MODERN_LD=1`

note that running with `FIXUPS=1` will automatically set `COMPARE=0`.
note that running with `MODERN_LD=1` will automatically set `COMPARE=0`.

It is also possible to build archives using modern gcc by using `MODERN_GCC=1` like the following:

- `make VERSION=L TARGET=libgultra_rom MODERN_GCC=1`

note that running with `MODERN_GCC=1` will automatically set `COMPARE=0` and `MODERN_LD=0`.
7 changes: 6 additions & 1 deletion lib/ultralib/include/PR/os_libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ extern "C" {

/* byte string operations */


#ifndef MODERN_CC
extern void bcopy(const void *, void *, int);
extern int bcmp(const void *, const void *, int);
extern void bzero(void *, int);
#else
extern void bcopy(const void *, void *, size_t);
extern int bcmp(const void *, const void *, size_t);
extern void bzero(void *, size_t);
#endif

/* Printf */

Expand Down
9 changes: 5 additions & 4 deletions lib/ultralib/include/PR/rcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,11 @@
#define VI_CTRL_DIVOT_ON 0x00010 /* 4: default = on */
#define VI_CTRL_SERRATE_ON 0x00040 /* 6: on if interlaced */
#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_PIXEL_ADV_MASK 0x01000 /* [15:12] pixel advance mode? */
#define VI_CTRL_ANTIALIAS_MODE_0 0x00000 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, always fetch extra lines */
#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, fetch extra lines as-needed */
#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode: AA disabled, resampling enabled, operate as if everything is covered */
#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode: AA disabled, resampling disabled, replicate pixels */
#define VI_CTRL_PIXEL_ADV_MASK 0x0F000 /* [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_1 0x01000 /* Bit [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_2 0x02000 /* Bit [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_3 0x03000 /* Bit [15:12] pixel advance mode? */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include "PR/os_version.h"
#include "PR/rcp.h"

//should go somewhere else but
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
#include "PRinternal/macros.h"

#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)

typedef struct
{
/* 0x0 */ u32 ramarray[15];
/* 0x3C */ u32 pifstatus;
} OSPifRam;
} OSPifRam ALIGNED(0x10);

typedef struct
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _DBGPROTO_H__
#define _DBGPROTO_H__

#include "dbgdefs.h"
#include "PRinternal/dbgdefs.h"

#define KK_REV 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
#define __attribute__(x)
#endif

#define ALIGN8(val) (((val) + 7) & ~7)

#define STACK(stack, size) \
u64 stack[ALIGN8(size) / sizeof(u64)]

#define STACK_START(stack) \
((u8*)(stack) + sizeof(stack))

#endif
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _RMONINT_H
#define _RMONINT_H

#include "dbgproto.h"
#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"

/* mips */
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#define VI_STATE_REPEATLINE 0x40 // repeat line?
#define VI_STATE_FADE 0x80 // fade

#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */

#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y
#define VI_2_10_FPART_MASK 0x3ff
#define VI_SUBPIXEL_SH 0x10
Expand Down Expand Up @@ -67,5 +63,5 @@ extern __OSViContext *__osViNext;
extern u32 __additional_scanline;
__OSViContext *__osViGetCurrentContext(void);
void __osViInit(void);
extern OSDevMgr __osViDevMgr;
extern OSDevMgr __osViDevMgr;
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/ultralib/include/compiler/modern_gcc/math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Nothing needed here
23 changes: 23 additions & 0 deletions lib/ultralib/include/compiler/modern_gcc/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _MEMORY_H
#define _MEMORY_H
/*
memory.h
*/

#ifndef _SIZE_T_DEF
#define _SIZE_T_DEF
typedef unsigned size_t;
#endif

void *memccpy(void *,void *,int,size_t);
void *memchr(void *,int,size_t);
int memcmp(const void *,const void *,size_t);
void *memcpy(void *,const void *,size_t);
int memicmp(void *,void *,size_t);
void *memmove(void *,void *,size_t);
void *memset(void *,int,size_t);

void movmem(void *,void *,unsigned);
void setmem(void *,unsigned,int);

#endif
44 changes: 44 additions & 0 deletions lib/ultralib/include/compiler/modern_gcc/sgidefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ralf Baechle <[email protected]>.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */

#ifndef _SGIDEFS_H
#define _SGIDEFS_H 1

/*
* Definitions for the ISA level
*/
#define _MIPS_ISA_MIPS1 1
#define _MIPS_ISA_MIPS2 2
#define _MIPS_ISA_MIPS3 3
#define _MIPS_ISA_MIPS4 4
#define _MIPS_ISA_MIPS5 5

/*
* Subprogram calling convention
*
* At the moment only _MIPS_SIM_ABI32 is in use. This will change rsn.
* Until GCC 2.8.0 is released don't rely on this definitions because the
* 64bit code is essentially using the 32bit interface model just with
* 64bit registers.
*/
#define _MIPS_SIM_ABI32 1
#define _MIPS_SIM_NABI32 2
#define _MIPS_SIM_ABI64 3

#endif /* sgidefs.h */
9 changes: 9 additions & 0 deletions lib/ultralib/include/compiler/modern_gcc/stdarg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _STDARG_H
#define _STDARG_H

#define va_list __builtin_va_list
#define va_start __builtin_va_start
#define va_arg __builtin_va_arg
#define va_end __builtin_va_end

#endif
1 change: 1 addition & 0 deletions lib/ultralib/include/compiler/modern_gcc/stdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Nothing needed here
Loading

0 comments on commit 87be831

Please sign in to comment.