diff --git a/.gitignore b/.gitignore index 9b111cc61..66f299b7a 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,9 @@ build/* !/sound/**/*custom*/**/*.aiff !/assets/**/*custom*.bin !/assets/**/*custom*/**/*.bin +# libultra + +!/lib/*.a + +!/lib/PR/hvqm/*.o + diff --git a/Makefile b/Makefile index 5c8f35d71..b5fe5805d 100644 --- a/Makefile +++ b/Makefile @@ -38,22 +38,22 @@ $(eval $(call validate-option,VERSION,jp us eu sh)) ifeq ($(VERSION),jp) DEFINES += VERSION_JP=1 OPT_FLAGS := -g - GRUCODE ?= f3d_old + GRUCODE ?= f3dzex VERSION_JP_US ?= true else ifeq ($(VERSION),us) DEFINES += VERSION_US=1 OPT_FLAGS := -g - GRUCODE ?= f3d_old + GRUCODE ?= f3dzex VERSION_JP_US ?= true else ifeq ($(VERSION),eu) DEFINES += VERSION_EU=1 OPT_FLAGS := -O2 - GRUCODE ?= f3d_new + GRUCODE ?= f3dzex VERSION_JP_US ?= false else ifeq ($(VERSION),sh) DEFINES += VERSION_SH=1 OPT_FLAGS := -O2 - GRUCODE ?= f3d_new + GRUCODE ?= f3dzex VERSION_JP_US ?= false endif @@ -66,6 +66,7 @@ TARGET := sm64.$(VERSION) # f3dex - # f3dex2 - # f3dzex - newer, experimental microcode used in Animal Crossing +# super3d - extremely experimental version of Fast3D lacking many features for speed $(eval $(call validate-option,GRUCODE,f3d_old f3dex f3dex2 f3d_new f3dzex)) ifeq ($(GRUCODE),f3d_old) @@ -74,11 +75,13 @@ else ifeq ($(GRUCODE),f3d_new) # Fast3D 2.0H DEFINES += F3D_NEW=1 else ifeq ($(GRUCODE),f3dex) # Fast3DEX DEFINES += F3DEX_GBI=1 F3DEX_GBI_SHARED=1 -else ifeq ($(GRUCODE), f3dex2) # Fast3DEX2 +else ifeq ($(GRUCODE),f3dex2) # Fast3DEX2 DEFINES += F3DEX_GBI_2=1 F3DEX_GBI_SHARED=1 -else ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.0J / Animal Forest - Dōbutsu no Mori) - $(warning Fast3DZEX is experimental. Try at your own risk.) +else ifeq ($(GRUCODE),f3dzex) # Fast3DZEX (2.08J / Animal Forest - Dōbutsu no Mori) DEFINES += F3DZEX_GBI_2=1 F3DEX_GBI_2=1 F3DEX_GBI_SHARED=1 +else ifeq ($(GRUCODE),super3d) # Super3D + $(warning Super3D is experimental. Try at your own risk.) + DEFINES += SUPER3D_GBI=1 F3D_NEW=1 endif @@ -108,7 +111,7 @@ endif # NON_MATCHING - whether to build a matching, identical copy of the ROM # 1 - enable some alternate, more portable code that does not produce a matching ROM # 0 - build a matching ROM -NON_MATCHING ?= 0 +NON_MATCHING ?= 1 $(eval $(call validate-option,NON_MATCHING,0 1)) ifeq ($(TARGET_N64),0) @@ -168,6 +171,9 @@ endif TOOLS_DIR := tools +# Location of official N64 libraries +N64_LIBS_DIR ?= lib + # (This is a bit hacky, but a lot of rules implicitly depend # on tools and assets, and we use directory globs further down # in the makefile that we want should cover assets.) @@ -205,9 +211,8 @@ BUILD_DIR_BASE := build BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION) ROM := $(BUILD_DIR)/$(TARGET).z64 ELF := $(BUILD_DIR)/$(TARGET).elf -LIBULTRA := $(BUILD_DIR)/libultra.a LD_SCRIPT := sm64.ld -MIO0_DIR := $(BUILD_DIR)/bin +YAY0_DIR := $(BUILD_DIR)/bin SOUND_BIN_DIR := $(BUILD_DIR)/sound TEXTURE_DIR := textures ACTOR_DIR := actors @@ -217,9 +222,6 @@ LEVEL_DIRS := $(patsubst levels/%,%,$(dir $(wildcard levels/*/header.h))) SRC_DIRS := src src/engine src/game src/audio src/menu src/buffers actors levels bin data assets asm lib sound BIN_DIRS := bin bin/$(VERSION) -ULTRA_SRC_DIRS := lib/src lib/src/math lib/asm lib/data -ULTRA_BIN_DIRS := lib/bin - GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists # File dependencies and variables for specific files @@ -288,6 +290,8 @@ else $(error Unable to detect a suitable MIPS toolchain installed) endif +export LD_LIBRARY_PATH=./tools + AS := $(CROSS)as ifeq ($(COMPILER),gcc) CC := $(CROSS)gcc @@ -310,7 +314,7 @@ ifneq (,$(call find-command,cpp-10)) else CPP := cpp endif -LD := $(CROSS)ld +LD := tools/mips64-elf-ld AR := $(CROSS)ar OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy @@ -362,7 +366,7 @@ export LANG := C #==============================================================================# # N64 tools -MIO0TOOL := $(TOOLS_DIR)/mio0 +YAY0TOOL := $(TOOLS_DIR)/slienc N64CKSUM := $(TOOLS_DIR)/n64cksum N64GRAPHICS := $(TOOLS_DIR)/n64graphics N64GRAPHICS_CI := $(TOOLS_DIR)/n64graphics_ci @@ -469,7 +473,7 @@ else endif endif -ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) rsp include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION) +ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(GODDARD_SRC_DIRS) $(ULTRA_SRC_DIRS) $(ULTRA_BIN_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) rsp include) $(YAY0_DIR) $(addprefix $(YAY0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION) # Make sure build directory exists before compiling anything DUMMY != mkdir -p $(ALL_DIRS) @@ -529,13 +533,13 @@ $(BUILD_DIR)/levels/%/leveldata.bin: $(BUILD_DIR)/levels/%/leveldata.elf $(V)$(EXTRACT_DATA_FOR_MIO) $< $@ # Compress binary file -$(BUILD_DIR)/%.mio0: $(BUILD_DIR)/%.bin +$(BUILD_DIR)/%.szp: $(BUILD_DIR)/%.bin $(call print,Compressing:,$<,$@) - $(V)$(MIO0TOOL) $< $@ + $(V)$(YAY0TOOL) $< $@ -# convert binary mio0 to object file -$(BUILD_DIR)/%.mio0.o: $(BUILD_DIR)/%.mio0 - $(call print,Converting MIO0 to ELF:,$<,$@) +# convert binary szp to object file +$(BUILD_DIR)/%.szp.o: $(BUILD_DIR)/%.szp + $(call print,Converting YAY0 to ELF:,$<,$@) $(V)printf ".section .data\n\n.incbin \"$<\"\n" | $(AS) $(ASFLAGS) -o $@ @@ -744,9 +748,9 @@ $(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES) $(V)$(AR) rcs -o $@ $(GODDARD_O_FILES) # Link SM64 ELF file -$(ELF): $(O_FILES) $(MIO0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a +$(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libultra.a $(BUILD_DIR)/libgoddard.a @$(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) -lultra -lgoddard + $(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 $(N64_LIBS_DIR) -lultra_rom -lgoddard # Build ROM $(ROM): $(ELF) @@ -759,7 +763,7 @@ $(BUILD_DIR)/$(TARGET).objdump: $(ELF) -.PHONY: all clean distclean default diff test load libultra +.PHONY: all clean distclean default diff test load # with no prerequisites, .SECONDARY causes no intermediate target to be removed .SECONDARY: diff --git a/Makefile.split b/Makefile.split index 050361195..e700db264 100644 --- a/Makefile.split +++ b/Makefile.split @@ -44,12 +44,12 @@ SEG_FILES := \ $(ACTOR_GROUPS:%=$(BUILD_DIR)/actors/%.elf) \ $(LEVEL_FILES:%=$(BUILD_DIR)/levels/%.elf) -MIO0_FILES := \ - $(SEGMENTS:%=$(BUILD_DIR)/bin/%.mio0) \ - $(ACTOR_GROUPS:%=$(BUILD_DIR)/actors/%.mio0) \ - $(LEVEL_FILES:%=$(BUILD_DIR)/levels/%.mio0) +YAY0_FILES := \ + $(SEGMENTS:%=$(BUILD_DIR)/bin/%.szp) \ + $(ACTOR_GROUPS:%=$(BUILD_DIR)/actors/%.szp) \ + $(LEVEL_FILES:%=$(BUILD_DIR)/levels/%.szp) -MIO0_OBJ_FILES := $(MIO0_FILES:.mio0=.mio0.o) +YAY0_OBJ_FILES := $(YAY0_FILES:.szp=.szp.o) # -------------------------------------- diff --git a/asm/decompress.s b/asm/decompress.s deleted file mode 100644 index 1399179de..000000000 --- a/asm/decompress.s +++ /dev/null @@ -1,149 +0,0 @@ -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -# This file is handwritten. - -glabel decompress -.if VERSION_SH == 1 - lw $a3, 8($a0) - lw $t9, 0xc($a0) - lw $t8, 4($a0) - add $a3, $a3, $a0 - add $t9, $t9, $a0 - move $a2, $zero - addi $a0, $a0, 0x10 - add $t8, $t8, $a1 -.L802772C0: - bnel $a2, $zero, .L802772D8 - slt $t1, $t0, $zero - lw $t0, ($a0) - li $a2, 32 - addi $a0, $a0, 4 - slt $t1, $t0, $zero -.L802772D8: - beql $t1, $zero, .L802772F8 - lhu $t2, ($a3) - lb $t2, ($t9) - addi $t9, $t9, 1 - addi $a1, $a1, 1 - b .L80277324 - sb $t2, -1($a1) - lhu $t2, ($a3) -.L802772F8: - addi $a3, $a3, 2 - srl $t3, $t2, 0xc - andi $t2, $t2, 0xfff - sub $t1, $a1, $t2 - addi $t3, $t3, 3 -.L8027730C: - lb $t2, -1($t1) - addi $t3, $t3, -1 - addi $t1, $t1, 1 - addi $a1, $a1, 1 - bnez $t3, .L8027730C - sb $t2, -1($a1) -.L80277324: - sll $t0, $t0, 1 - bne $a1, $t8, .L802772C0 - addi $a2, $a2, -1 - jr $ra - nop -.elseif VERSION_EU == 1 - lw $a3, 8($a0) - lw $t9, 0xc($a0) - lw $t8, 4($a0) - add $a3, $a3, $a0 - add $t9, $t9, $a0 - move $a2, $zero - addi $a0, $a0, 0x10 - add $t8, $t8, $a1 -.L8026ED80: - bnezl $a2, .L8026ED98 - slt $t1, $t0, $zero - lw $t0, ($a0) - li $a2, 32 - addi $a0, $a0, 4 - slt $t1, $t0, $zero -.L8026ED98: - beql $t1, $zero, .L8026EDB8 - lhu $t2, ($a3) - lb $t2, ($t9) - addi $t9, $t9, 1 - addi $a1, $a1, 1 - b .L8026EDE4 - sb $t2, -1($a1) - lhu $t2, ($a3) -.L8026EDB8: - addi $a3, $a3, 2 - srl $t3, $t2, 0xc - andi $t2, $t2, 0xfff - sub $t1, $a1, $t2 - addi $t3, $t3, 3 -.L8026EDCC: - lb $t2, -1($t1) - addi $t3, $t3, -1 - addi $t1, $t1, 1 - addi $a1, $a1, 1 - bnez $t3, .L8026EDCC - sb $t2, -1($a1) -.L8026EDE4: - sll $t0, $t0, 1 - bne $a1, $t8, .L8026ED80 - addi $a2, $a2, -1 - jr $ra - nop -.else - lw $t8, 4($a0) - lw $a3, 8($a0) - lw $t9, 0xc($a0) - move $a2, $zero - add $t8, $t8, $a1 - add $a3, $a3, $a0 - add $t9, $t9, $a0 - addi $a0, $a0, 0x10 -.L8027EF50: - bnez $a2, .L8027EF64 - nop - lw $t0, ($a0) - li $a2, 32 - addi $a0, $a0, 4 -.L8027EF64: - slt $t1, $t0, $zero - beqz $t1, .L8027EF88 - nop - lb $t2, ($t9) - addi $t9, $t9, 1 - sb $t2, ($a1) - addi $a1, $a1, 1 - b .L8027EFBC - nop -.L8027EF88: - lhu $t2, ($a3) - addi $a3, $a3, 2 - srl $t3, $t2, 0xc - andi $t2, $t2, 0xfff - sub $t1, $a1, $t2 - addi $t3, $t3, 3 -.L8027EFA0: - lb $t2, -1($t1) - addi $t3, $t3, -1 - addi $t1, $t1, 1 - sb $t2, ($a1) - addi $a1, $a1, 1 - bnez $t3, .L8027EFA0 - nop -.L8027EFBC: - sll $t0, $t0, 1 - addi $a2, $a2, -1 - bne $a1, $t8, .L8027EF50 - nop - jr $ra - nop -.endif diff --git a/lib/asm/llmuldiv_gcc.s b/asm/llmuldiv_gcc.s similarity index 100% rename from lib/asm/llmuldiv_gcc.s rename to asm/llmuldiv_gcc.s diff --git a/asm/slidec.s b/asm/slidec.s new file mode 100644 index 000000000..5c9c4fcdf --- /dev/null +++ b/asm/slidec.s @@ -0,0 +1,59 @@ +/****************************** + * Data Decompress Ver1.10 * + * Programmed By Melody-Yoshi * + ******************************/ +/* How to use this function. + void slidstart(unsigned char *,unsigned char *); + first argument is top address of compress data.(align 4) + next argument is top address of decompress. +*/ + + .align 4 + + .text + .globl slidstart + .ent slidstart + .set reorder +/* ===== START! ===== */ +slidstart: lw $24,4($4) ## R24=Output size + lw $7,8($4) + lw $25,12($4) + move $6,$0 ## flags=0 + add $24,$5 + add $7,$4 + add $25,$4 + add $4,16 +/* ===== MAIN LOOP ===== */ +slidemain2: bne $6,$0,codecheck2 + lw $8,($4) + li $6,32 + add $4,4 +codecheck2: slt $9,$8,$0 ## Check MSB + beq $9,$0,pressdata2 + lb $10,($25) + add $25,1 + sb $10,($5) + add $5,1 + b loopend2 +pressdata2: lhu $10,($7) + add $7,2 + srl $11,$10,12 + and $10,0xfff + sub $9,$5,$10 ## R9=DIST + beq $11,$0,pressloop3 + add $11,2 +pressloop2: lb $10,-1($9) + sub $11,1 + add $9,1 + sb $10,($5) + add $5,1 + bne $11,$0,pressloop2 +loopend2: sll $8,1 + sub $6,1 + bne $5,$24,slidemain2 + jr $31 +pressloop3: lbu $11,($25) + add $25,1 + add $11,18 + b pressloop2 + .end diff --git a/enhancements/mem_error_screen.patch b/enhancements/mem_error_screen.patch index b4a82e0b2..2b1ff0349 100644 --- a/enhancements/mem_error_screen.patch +++ b/enhancements/mem_error_screen.patch @@ -110,7 +110,7 @@ index a130cc04..926c0d09 100644 +const LevelScript level_intro_entry_error_screen[] = { + INIT_LEVEL(), + FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), -+ LOAD_MIO0(/*seg*/ 0x07, _intro_segment_7SegmentRomStart, _intro_segment_7SegmentRomEnd), ++ LOAD_YAY0(/*seg*/ 0x07, _intro_segment_7SegmentRomStart, _intro_segment_7SegmentRomEnd), + ALLOC_LEVEL_POOL(), + + AREA(/*index*/ 1, intro_geo_error_screen), diff --git a/include/PR/PRimage.h b/include/PR/PRimage.h new file mode 100644 index 000000000..aacc65677 --- /dev/null +++ b/include/PR/PRimage.h @@ -0,0 +1,126 @@ +/************************************************************************** + * + * $Revision: 1.4 $ + * $Date: 1997/11/26 00:30:50 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/PRimage.h,v $ + * + **************************************************************************/ + +#ifndef __GL_IMAGE_H__ +#define __GL_IMAGE_H__ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Defines for image files . . . . + * + * Paul Haeberli - 1984 + * Look in /usr/people/4Dgifts/iristools/imgtools for example code! + * + */ + +#include + +#define IMAGIC 0732 + +/* colormap of images */ +#define CM_NORMAL 0 /* file contains rows of values which + * are either RGB values (zsize == 3) + * or greyramp values (zsize == 1) */ +#define CM_DITHERED 1 +#define CM_SCREEN 2 /* file contains data which is a screen + * image; getrow returns buffer which + * can be displayed directly with + * writepixels */ +#define CM_COLORMAP 3 /* a colormap file */ + +#define TYPEMASK 0xff00 +#define BPPMASK 0x00ff +#define ITYPE_VERBATIM 0x0000 +#define ITYPE_RLE 0x0100 +#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) +#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) +#define BPP(type) ((type) & BPPMASK) +#define RLE(bpp) (ITYPE_RLE | (bpp)) +#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) +#define IBUFSIZE(pixels) (((pixels)+((pixels)>>6))<<2) +#define RLE_NOP 0x00 + +#define ierror(p) (((p)->flags&_IOERR)!=0) +#define ifileno(p) ((p)->file) +#define getpix(p) (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p)) +#define putpix(p,x) (--(p)->cnt>=0 \ + ? ((int)(*(p)->ptr++=(unsigned)(x))) \ + : iflsbuf(p,(unsigned)(x))) + +typedef struct { + unsigned short imagic; /* stuff saved on disk . . */ + unsigned short type; + unsigned short dim; + unsigned short xsize; + unsigned short ysize; + unsigned short zsize; + unsigned long min; + unsigned long max; + unsigned long wastebytes; + char name[80]; + unsigned long colormap; + + long file; /* stuff used in core only */ + unsigned short flags; + short dorev; + short x; + short y; + short z; + short cnt; + unsigned short *ptr; + unsigned short *base; + unsigned short *tmpbuf; + unsigned long offset; + unsigned long rleend; /* for rle images */ + unsigned long *rowstart; /* for rle images */ + long *rowsize; /* for rle images */ +} IMAGE; + +IMAGE *icreate(); +/* + * IMAGE *iopen(char *file, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * IMAGE *fiopen(int f, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * + * ...while iopen and fiopen can take an extended set of parameters, the + * last five are optional, so a more correct prototype would be: + * + */ +IMAGE *iopen(char *file, char *mode, ...); +IMAGE *fiopen(int f, char *mode, ...); + +/* + * + * unsigned short *ibufalloc(IMAGE *image); + * int ifilbuf(IMAGE *image); + * int iflush(IMAGE *image); + * unsigned int iflsbuf(IMAGE *image, unsigned int c); + * void isetname(IMAGE *image, char *name); + * void isetcolormap(IMAGE *image, int colormap); + */ + +int iclose(IMAGE *image); +int putrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); +int getrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); + +/* +IMAGE *iopen(); +IMAGE *icreate(); +*/ + +unsigned short *ibufalloc(); + +#define IMAGEDEF /* for backwards compatibility */ +#ifdef __cplusplus +} +#endif +#endif /* !__GL_IMAGE_H__ */ diff --git a/include/PR/R4300.h b/include/PR/R4300.h index 932694d3f..fd70d07fa 100644 --- a/include/PR/R4300.h +++ b/include/PR/R4300.h @@ -14,7 +14,7 @@ * * $Revision: 1.13 $ * $Date: 1997/02/11 08:15:34 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/R4300.h,v $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/R4300.h,v $ * **************************************************************************/ diff --git a/include/PR/abi.h b/include/PR/abi.h index 2631214f0..07ff777f5 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -1,16 +1,16 @@ #ifndef _ABI_H_ -#define _ABI_H_ +#define _ABI_H_ /************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * * These coded instructions, statements, and computer programs contain * * unpublished proprietary information of Silicon Graphics, Inc., and * * are protected by Federal copyright law. They may not be disclosed * * to third parties or copied or duplicated in any form, in whole or * * in part, without the prior written consent of Silicon Graphics, Inc. * - * * + * * **************************************************************************/ /************************************************************************** @@ -24,69 +24,47 @@ /* * Header file for the Audio Binary Interface. * This is included in the Media Binary Interface file - * mbi.h. + * mbi.h. * * This file follows the framework used for graphics. - * + * */ /* Audio commands: */ -#define A_SPNOOP 0 -#define A_ADPCM 1 -#define A_CLEARBUFF 2 -#define A_RESAMPLE 5 -#define A_SETBUFF 8 +#define A_SPNOOP 0 +#define A_ADPCM 1 +#define A_CLEARBUFF 2 +#define A_ENVMIXER 3 +#define A_LOADBUFF 4 +#define A_RESAMPLE 5 +#define A_SAVEBUFF 6 +#define A_SEGMENT 7 +#define A_SETBUFF 8 +#define A_SETVOL 9 #define A_DMEMMOVE 10 #define A_LOADADPCM 11 -#define A_MIXER 12 +#define A_MIXER 12 #define A_INTERLEAVE 13 -#define A_SETLOOP 15 - -#ifndef VERSION_SH - -#define A_ENVMIXER 3 -#define A_LOADBUFF 4 -#define A_RESAMPLE 5 -#define A_SAVEBUFF 6 -#define A_SEGMENT 7 -#define A_SETVOL 9 #define A_POLEF 14 - -#else - -#define A_ADDMIXER 4 -#define A_RESAMPLE_ZOH 6 -#define A_INTERL 17 -#define A_ENVSETUP1 18 -#define A_ENVMIXER 19 -#define A_LOADBUFF 20 -#define A_SAVEBUFF 21 -#define A_ENVSETUP2 22 -#define A_UNK_23 23 -#define A_HILOGAIN 24 -#define A_UNK_25 25 -#define A_DUPLICATE 26 -#define A_FILTER 27 - -#endif +#define A_SETLOOP 15 #define ACMD_SIZE 32 /* * Audio flags */ -#define A_INIT 0x01 -#define A_CONTINUE 0x00 +#define A_INIT 0x01 +#define A_CONTINUE 0x00 #define A_LOOP 0x02 #define A_OUT 0x02 -#define A_LEFT 0x02 -#define A_RIGHT 0x00 -#define A_VOL 0x04 -#define A_RATE 0x00 -#define A_AUX 0x08 -#define A_NOAUX 0x00 -#define A_MAIN 0x00 -#define A_MIX 0x10 +#define A_LEFT 0x02 +#define A_RIGHT 0x00 +#define A_VOL 0x04 +#define A_RATE 0x00 +#define A_AUX 0x08 +#define A_NOAUX 0x00 +#define A_MAIN 0x00 +#define A_MIX 0x10 /* * BEGIN C-specific section: (typedef's) @@ -98,173 +76,173 @@ */ typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int addr; } Aadpcm; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int addr; } Apolef; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; } Aenvelope; typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int dmem:16; - unsigned int pad2:16; - unsigned int count:16; + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int dmem:16; + unsigned int pad2:16; + unsigned int count:16; } Aclearbuff; typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int pad2:16; - unsigned int inL:16; - unsigned int inR:16; + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int pad2:16; + unsigned int inL:16; + unsigned int inR:16; } Ainterleave; typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int addr; + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int addr; } Aloadbuff; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; } Aenvmixer; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int gain:16; - unsigned int dmemi:16; - unsigned int dmemo:16; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int gain:16; + unsigned int dmemi:16; + unsigned int dmemo:16; } Amixer; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int dmem2:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int dmem2:16; + unsigned int addr; } Apan; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pitch:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pitch:16; + unsigned int addr; } Aresample; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int pad1:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int pad1:16; + unsigned int addr; } Areverb; typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int addr; + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int addr; } Asavebuff; typedef struct { - unsigned int cmd:8; - unsigned int pad1:24; - unsigned int pad2:2; - unsigned int number:4; - unsigned int base:24; + unsigned int cmd:8; + unsigned int pad1:24; + unsigned int pad2:2; + unsigned int number:4; + unsigned int base:24; } Asegment; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int dmemin:16; - unsigned int dmemout:16; - unsigned int count:16; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int dmemin:16; + unsigned int dmemout:16; + unsigned int count:16; } Asetbuff; typedef struct { - unsigned int cmd:8; - unsigned int flags:8; - unsigned int vol:16; - unsigned int voltgt:16; - unsigned int volrate:16; + unsigned int cmd:8; + unsigned int flags:8; + unsigned int vol:16; + unsigned int voltgt:16; + unsigned int volrate:16; } Asetvol; typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int dmemin:16; - unsigned int dmemout:16; - unsigned int count:16; + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int dmemin:16; + unsigned int dmemout:16; + unsigned int count:16; } Admemmove; typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int count:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int count:16; + unsigned int addr; } Aloadadpcm; typedef struct { - unsigned int cmd:8; - unsigned int pad1:8; - unsigned int pad2:16; - unsigned int addr; + unsigned int cmd:8; + unsigned int pad1:8; + unsigned int pad2:16; + unsigned int addr; } Asetloop; - + /* * Generic Acmd Packet */ typedef struct { - uintptr_t w0; - uintptr_t w1; + unsigned int w0; + unsigned int w1; } Awords; typedef union { - Awords words; -#if IS_BIG_ENDIAN && !IS_64_BIT - Aadpcm adpcm; - Apolef polef; - Aclearbuff clearbuff; - Aenvelope envelope; - Ainterleave interleave; - Aloadbuff loadbuff; - Aenvmixer envmixer; - Aresample resample; - Areverb reverb; - Asavebuff savebuff; - Asegment segment; - Asetbuff setbuff; - Asetvol setvol; - Admemmove dmemmove; - Aloadadpcm loadadpcm; - Amixer mixer; - Asetloop setloop; -#endif - long long int force_union_align; /* dummy, force alignment */ + Awords words; + Aadpcm adpcm; + Apolef polef; + Aclearbuff clearbuff; + Aenvelope envelope; + Ainterleave interleave; + Aloadbuff loadbuff; + Aenvmixer envmixer; + Aresample resample; + Areverb reverb; + Asavebuff savebuff; + Asegment segment; + Asetbuff setbuff; + Asetvol setvol; + Admemmove dmemmove; + Aloadadpcm loadadpcm; + Amixer mixer; + Asetloop setloop; + long long int force_union_align; /* dummy, force alignment */ } Acmd; /* * ADPCM State */ -typedef short ADPCM_STATE[16]; +#define ADPCMVSIZE 8 +#define ADPCMFSIZE 16 +typedef short ADPCM_STATE[ADPCMFSIZE]; /* * Pole filter state @@ -280,7 +258,7 @@ typedef short RESAMPLE_STATE[16]; * Resampler constants */ #define UNITY_PITCH 0x8000 -#define MAX_RATIO 1.99996 /* within .03 cents of +1 octave */ +#define MAX_RATIO 1.99996 /* within .03 cents of +1 octave */ /* * Enveloper/Mixer state @@ -291,551 +269,144 @@ typedef short ENVMIX_STATE[40]; * Macros to assemble the audio command list */ -/* - * Info about parameters: - * - * A "count" in the following macros is always measured in bytes. - * - * All volumes/gains are in Q1.15 signed fixed point numbers: - * 0x8000 is the minimum volume (-100%), negating the audio curve. - * 0x0000 is silent. - * 0x7fff is maximum volume (99.997%). - * - * All DRAM addresses refer to segmented addresses. A segment table shall - * first be set up by calling aSegment for each segment. When a DRAM - * address is later used as parameter, the 8 high bits will be an index - * to the segment table and the lower 24 bits are added to the base address - * stored in the segment table for this entry. The result is the physical address. - * - * Transfers to/from DRAM are executed using DMA and hence follow these restrictions: - * All DRAM addresses should be aligned by 8 bytes, or they will be - * rounded down to the nearest multiple of 8 bytes. - * All DRAM lengths should be aligned by 8 bytes, or they will be - * rounded up to the nearest multiple of 8 bytes. - */ - -/* - * Decompresses ADPCM data. - * Possible flags: A_INIT and A_LOOP. - * - * First set up internal data in DMEM: - * aLoadADPCM(cmd++, nEntries * 16, physicalAddressOfBook) - * aSetLoop(cmd++, physicalAddressOfLoopState) (if A_LOOP is set) - * - * Then before this command, call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * Note: count will be rounded up to the nearest multiple of 32 bytes. - * - * ADPCM decompression works on a block of 16 (uncompressed) samples. - * The previous 2 samples and 9 bytes of input are decompressed to - * 16 new samples using the code book previously loaded. - * - * Before the algorithm starts, the previous 16 samples are loaded according to flag: - * A_INIT: all zeros - * A_LOOP: the address set by aSetLoop - * no flags: the DRAM address in the s parameter - * These 16 samples are immediately copied to the destination address. - * - * The result of "count" bytes will be written after these 16 initial samples. - * The last 16 samples written to the destination will also be written to - * the state address in DRAM. - */ -#define aADPCMdec(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aADPCMdec(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ } -#define aADPCM_23(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_UNK_23, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aPoleFilter(pkt, f, g, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ } -/* - * Not used in SM64. - */ -#define aPoleFilter(pkt, f, g, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aClearBuffer(pkt, d, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ + _a->words.w1 = (unsigned int)(c); \ } -/* - * Clears DMEM data, where d is address and c is count, by writing zeros. - * - * Note: c is rounded up to the nearest multiple of 16 bytes. - */ -#define aClearBuffer(pkt, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ - _a->words.w1 = (uintptr_t)(c); \ +#define aEnvMixer(pkt, f, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ + _a->words.w1 = (unsigned int)(s); \ } -/* - * Mixes an envelope with mono sound into 2 or 4 channels. - * Possible flags: A_INIT, A_AUX (indicates that 4 channels should be used). - * - * Before this command, call: - * aSetBuffer(cmd++, 0, inBuf, dryLeft, count) - * aSetBuffer(cmd++, A_AUX, dryRight, wetLeft, wetRight) - * - * The first time (A_INIT is set), volume also needs to be set: - * aSetVolume(cmd++, A_VOL | A_LEFT, initialVolumeLeft, 0, 0) - * aSetVolume(cmd++, A_VOL | A_RIGHT, initialVolumeRight, 0, 0) - * aSetVolume32(cmd++, A_RATE | A_LEFT, targetVolumeLeft, rampLeft) - * aSetVolume32(cmd++, A_RATE | A_RIGHT, targetVolumeRight, rampRight) - * aSetVolume(cmd++, A_AUX, dryVolume, 0, wetVolume) - * - * This command will now mix samples in inBuf into the destination buffers (dry and wet), - * but with the volume increased (or decreased) from initial volumes to target volumes, - * with the specified ramp rate. Once the target volume is reached, the volume stays - * at that level. Before the samples are finally mixed (added) into the destination - * buffers (dry and wet), the volume is changed according to dryVolume and wetVolume. - * - * Note: count will be rounded up to the nearest multiple of 16 bytes. - * Note: the wet channels are used for reverb. - * - */ -#define aEnvMixer(pkt, f, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aInterleave(pkt, l, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ + _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ } -/* - * Interleaves two mono channels into stereo. - * - * First call: - * aSetBuffer(cmd++, 0, 0, output, count) - * - * The count refers to the size of each input. Hence 2 * count bytes will be written out. - * A left sample will be placed before the right sample. - * - * Note: count will be rounded up to the nearest multiple of 16 bytes. - */ -#define aInterleave(pkt, l, r) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ +#define aLoadBuffer(pkt, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ + _a->words.w1 = (unsigned int)(s); \ } -/* - * Loads a buffer from DRAM to DMEM. - * - * First call: - * aSetBuffer(cmd++, 0, in, 0, count) - * - * The in parameter to aSetBuffer is the destination in DMEM and the - * s parameter to this command is the source in DRAM. - */ -#define aLoadBuffer(pkt, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aMix(pkt, f, g, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \ } -/* - * Mixes audio. - * Possible flags: no flags used, although parameter present. - * - * First call: - * aSetBuffer(cmd++, 0, 0, 0, count) - * - * Input and output addresses are taken from the i and o parameters. - * The volume with which the input is changed is taken from the g parameter. - * After the volume of the input samples have been changed, the result - * is added to the output. - * - * Note: count will be rounded up to the nearest multiple of 32 bytes. - */ -#define aMix(pkt, f, g, i, o) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \ +#define aPan(pkt, f, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(d, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ } -// Not present in the audio microcode. -#define aPan(pkt, f, d, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(d, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aResample(pkt, f, p, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\ + _SHIFTL(p, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ } -/* - * Resamples audio. - * Possible flags: A_INIT, A_OUT? (not used in SM64). - * - * First call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * This command resamples the audio using the given frequency ratio (pitch) - * using a filter that uses a window of 4 source samples. This can be used - * either for just resampling audio to be able to be played back at a different - * sample rate, or to change the pitch if the result is played back at - * the same sample rate as the input. - * - * The frequency ratio is given in UQ1.15 fixed point format. - * For no change in frequency, use pitch 0x8000. - * For 1 octave up or downsampling to (roughly) half number of samples, use pitch 0xffff. - * For 1 octave down or upsampling to double as many samples, use pitch 0x4000. - * - * Note: count represents the number of output sample bytes and is rounded up to - * the nearest multiple of 16 bytes. - * - * The state consists of the four following source samples when the algorithm stopped as - * well as a fractional position, and is initialized to all zeros if A_INIT is given. - * Otherwise it is loaded from DRAM at address s. - * - * The algorithm starts by writing the four source samples from the state (or zero) - * to just before the input address given. It then creates one output sample by examining - * the four next source samples and then moving the source position zero or more - * samples forward. The first output sample (when A_INIT is given) is always 0. - * - * When "count" bytes have been written, the following four source samples - * are written to the state in DRAM as well as a fractional position. - */ -#define aResample(pkt, f, p, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\ - _SHIFTL(p, 0, 16)); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aSaveBuffer(pkt, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ + _a->words.w1 = (unsigned int)(s); \ } -/* - * Stores a buffer in DMEM to DRAM. - * - * First call: - * aSetBuffer(cmd++, 0, 0, out, count) - * - * The out parameter to aSetBuffer is the source in DMEM and the - * s parameter to this command is the destination in DRAM. - */ -#define aSaveBuffer(pkt, s) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \ - _a->words.w1 = (uintptr_t)(s); \ +#define aSegment(pkt, s, b) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ + _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ } -/* - * Sets up an entry in the segment table. - * - * The s parameter is a segment index, 0 to 15. - * The b parameter is the base offset. - */ -#define aSegment(pkt, s, b) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \ - _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \ +#define aSetBuffer(pkt, f, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(i, 0, 16)); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ } -/* - * Sets internal DMEM buffer addresses used for later commands. - * See each command for how to use aSetBuffer. - */ -#define aSetBuffer(pkt, f, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(i, 0, 16)); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +#define aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ } -#define aInterl(pkt, f, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_INTERL, 24, 8) | _SHIFTL(f, 16, 8) | \ - _SHIFTL(i, 0, 16)); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ -} +#define aSetVolume32(pkt, f, v, tr) aSetVolume(pkt, f, v, (int16_t)((tr) >> 16), (int16_t)(tr)) -/* - * Sets internal volume parameters. - * See aEnvMixer for more info. - */ -#define aSetVolume(pkt, f, v, t, r) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ -} - -/* - * Sets the address to ADPCM loop state. - * - * The a parameter is a DRAM address. - * See aADPCMdec for more info. - */ #define aSetLoop(pkt, a) \ { \ Acmd *_a = (Acmd *)pkt; \ _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \ - _a->words.w1 = (uintptr_t)(a); \ + _a->words.w1 = (unsigned int)(a); \ +} + +#define aDMEMMove(pkt, i, o, c) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ + _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ } -/* - * Copies memory in DMEM. - * - * Copies c bytes from address i to address o. - * - * Note: count is rounded up to the nearest multiple of 16 bytes. - * - * Note: This acts as memcpy where 16 bytes are moved at a time, therefore - * if input and output overlap, output address should be less than input address. - */ -#define aDMEMMove(pkt, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \ - _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \ +#define aLoadADPCM(pkt, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ + _a->words.w1 = (unsigned int) d; \ } -/* - * Loads ADPCM book from DRAM into DMEM. - * - * This command loads ADPCM table entries from DRAM to DMEM. - * - * The count parameter c should be a multiple of 16 bytes. - * The d parameter is a DRAM address. - */ -#define aLoadADPCM(pkt, c, d) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ - _a->words.w1 = (uintptr_t) (d); \ -} - -// This is a version of aSetVolume which takes a single 32-bit parameter -// instead of two 16-bit ones. According to AziAudio, it is used to set -// ramping values when neither bit 4 nor bit 8 is set in the flags parameter. -// It does not appear in the official abi.h header. -/* - * Sets internal volume parameters. - * See aEnvMixer for more info. - */ -#define aSetVolume32(pkt, f, v, tr) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - _a->words.w1 = (uintptr_t)(tr); \ -} - -#ifdef VERSION_SH -#undef aLoadBuffer -#undef aSaveBuffer -#undef aMix -#undef aEnvMixer -#undef aInterleave - -/* - * Mix two tracks by simple clamped addition. - * - * s: DMEM source track 1 - * d: DMEM source track 2 and destination - * c: number of bytes to write (rounded down to 16 byte alignment) - */ -#define aAddMixer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ADDMIXER, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(0x7fff, 0, 16)); \ - _a->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(d, 0, 16)); \ -} - -/* - * Loads a buffer from DRAM to DMEM. - * - * s: DRAM source - * d: DMEM destination - * c: number of bytes to copy (rounded down to 16 byte alignment) - */ -#define aLoadBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ - _a->words.w1 = (uintptr_t)(s); \ -} - -/* - * Stores a buffer from DMEM to DRAM. - * - * s: DMEM source - * d: DRAM destination - * c: number of bytes to copy (rounded down to 16 byte alignment) - */ -#define aSaveBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ - _a->words.w1 = (uintptr_t)(d); \ -} - -/* - * Duplicates 128 bytes of data a number of times. - * - * 128 bytes are read from source DMEM address s. - * Then c identical copies of these bytes are written to DMEM address d. - */ -#define aDuplicate(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ - _SHIFTL(c, 16, 8) | _SHIFTL(s, 0, 16)); \ - _a->words.w1 = (_SHIFTL(d, 16, 16) | _SHIFTL(0x80, 0, 16)); \ -} - -/* - * Fast resample. - * - * Before this command, call: - * aSetBuffer(cmd++, 0, in, out, count) - * - * This works like the other resample command but just takes the "nearest" sample, - * instead of a function of the four nearest samples. - */ -#define aResampleZoh(pkt, pitch, start_fract) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_RESAMPLE_ZOH, 24, 8) | \ - _SHIFTL(pitch, 0, 16)); \ - _a->words.w1 = _SHIFTL(start_fract, 0, 16); \ -} - -/* - * Mixes audio. - * - * Input and output addresses are taken from the i and o parameters. - * The volume with which the input is changed is taken from the g parameter. - * After the volume of the input samples have been changed, the result - * is added to the output. - * - * Note: count is first rounded down to the nearest multiple of 16 bytes - * and then rounded up to the nearest multiple of 32 bytes. - */ -#define aMix(pkt, g, i, o, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(g, 0, 16)); \ - _a->words.w1 = _SHIFTL(i, 16, 16) | _SHIFTL(o, 0, 16); \ -} - -#define aEnvSetup1(pkt, a, b, c, d) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ENVSETUP1, 24, 8) | \ - _SHIFTL(a, 16, 8) | _SHIFTL(b, 0, 16)); \ - _a->words.w1 = _SHIFTL(c, 16, 16) | _SHIFTL(d, 0, 16); \ -} - -#define aEnvSetup2(pkt, volLeft, volRight) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); \ - _a->words.w1 = _SHIFTL(volLeft, 16, 16) | \ - _SHIFTL(volRight, 0, 16); \ -} - -#define aEnvMixer(pkt, inBuf, nSamples, bit1, bit2, bit3, dryLeft, dryRight, wetLeft, wetRight) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | \ - _SHIFTL((inBuf) >> 4, 16, 8) | \ - _SHIFTL(nSamples, 8, 8)) | \ - _SHIFTL(bit1, 2, 1) | _SHIFTL(bit2, 1, 1) | \ - _SHIFTL(bit3, 0, 1); \ - _a->words.w1 = _SHIFTL((dryLeft) >> 4, 24, 8) | \ - _SHIFTL((dryRight) >> 4, 16, 8) | \ - _SHIFTL((wetLeft) >> 4, 8, 8) | \ - _SHIFTL((wetRight) >> 4, 0, 8); \ -} - -#define aInterleave(pkt, o, l, r, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(o, 0, 16); \ - _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \ -} - -// countOrBuf meaning depends on flag -#define aFilter(pkt, f, countOrBuf, addr) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_FILTER, 24, 8) | _SHIFTL((f), 16, 8) | \ - _SHIFTL((countOrBuf), 0, 16); \ - _a->words.w1 = (uintptr_t)(addr); \ -} - -#define aHilogain(pkt, id, buflen, i) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_HILOGAIN, 24, 8) | \ - _SHIFTL((id), 16, 8) | _SHIFTL((buflen), 0, 16); \ - _a->words.w1 = _SHIFTL((i), 16, 16); \ -} - -#define aUnknown25(pkt, f, g, i, o) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_UNK_25, 24, 8) | \ - _SHIFTL((f), 16, 8) | _SHIFTL((g), 0, 16)); \ - _a->words.w1 = _SHIFTL((i), 16, 16) | _SHIFTL((o), 0, 16); \ -} - -#endif - #endif /* _LANGUAGE_C */ #endif /* !_ABI_H_ */ + + + diff --git a/include/PR/gbi-poslight.h b/include/PR/gbi-poslight.h new file mode 100644 index 000000000..7b93aea01 --- /dev/null +++ b/include/PR/gbi-poslight.h @@ -0,0 +1,129 @@ +#ifndef _GBI_POSLIGHT_H_ +#define _GBI_POSLIGHT_H_ + +/* version 990705 */ +#define G_LIGHTING_POSITIONAL 0x00400000 +#ifdef _LANGUAGE_ASSEMBLY +#define G_LIGHTING_POSITIONAL_H (G_LIGHTING_POSITIONAL/0x10000) +#endif + +typedef struct { + unsigned char col[3]; /* diffuse light value (rgba) */ + unsigned char kc; /* positional lighting enable flag & constant attenuation Kc */ + unsigned char colc[3]; /* copy of diffuse light value (rgba) */ + unsigned char kl; /* linear attenuation Kl */ + short pos[3]; /* light position x, y, z */ + unsigned char kq; /* quadratic attenuation Kq */ + char reserved1; +} PosLight_t; + +typedef union { + PosLight_t p; + Light_t l; + long long int force_structure_alignment[2]; +} PosLight; + +typedef struct { + Ambient a; + PosLight l[7]; +} PosLightsn; + +typedef struct { + Ambient a; + PosLight l[1]; +} PosLights0; + +typedef struct { + Ambient a; + PosLight l[1]; +} PosLights1; + +typedef struct { + Ambient a; + PosLight l[2]; +} PosLights2; + +typedef struct { + Ambient a; + PosLight l[3]; +} PosLights3; + +typedef struct { + Ambient a; + PosLight l[4]; +} PosLights4; + +typedef struct { + Ambient a; + PosLight l[5]; +} PosLights5; + +typedef struct { + Ambient a; + PosLight l[6]; +} PosLights6; + +typedef struct { + Ambient a; + PosLight l[7]; +} PosLights7; + +#define _gSPLightColor2(pkt, n, col1, col2) \ +{\ + gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_a##n, col1);\ + gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_b##n, col2);\ +} +#define _gsSPLightColor2(n, col1, col2) \ + gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##n, col1),\ + gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##n, col2) + +#define _gdSPDefAmbient(ar,ag,ab) {{ {ar,ag,ab},0,{ar,ag,ab},0}} +#define _gdSPDefPosLight(r,g,b,x,y,z,c,l,q) {{ {r,g,b},c,{r,g,b},l,{x,y,z},q,0 }} +#define _gdSPDefInfLight(r,g,b,x,y,z) {{ {r,g,b},0,{r,g,b},0,{((x)<<8)|((y)&0xff),(z)<<8,0},0,0}} +#define gdSPDefPosLights0(ar,ag,ab) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(0,0,0,0,0,0,0,0,0)} } +#define gdSPDefPosLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1)} } +#define gdSPDefPosLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2)} } +#define gdSPDefPosLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2,r3,g3,b3,x3,y3,z3,c3,l3,q3) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2), \ + _gdSPDefPosLight(r3,g3,b3,x3,y3,z3,c3,l3,q3)} } +#define gdSPDefPosLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2,r3,g3,b3,x3,y3,z3,c3,l3,q3,r4,g4,b4,x4,y4,z4,c4,l4,q4) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2), \ + _gdSPDefPosLight(r3,g3,b3,x3,y3,z3,c3,l3,q3), \ + _gdSPDefPosLight(r4,g4,b4,x4,y4,z4,c4,l4,q4)} } +#define gdSPDefPosLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2,r3,g3,b3,x3,y3,z3,c3,l3,q3,r4,g4,b4,x4,y4,z4,c4,l4,q4,r5,g5,b5,x5,y5,z5,c5,l5,q5) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2), \ + _gdSPDefPosLight(r3,g3,b3,x3,y3,z3,c3,l3,q3), \ + _gdSPDefPosLight(r4,g4,b4,x4,y4,z4,c4,l4,q4), \ + _gdSPDefPosLight(r5,g5,b5,x5,y5,z5,c5,l5,q5)} } +#define gdSPDefPosLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2,r3,g3,b3,x3,y3,z3,c3,l3,q3,r4,g4,b4,x4,y4,z4,c4,l4,q4,r5,g5,b5,x5,y5,z5,c5,l5,q5,r6,g6,b6,x6,y6,z6,c6,l6,q6) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2), \ + _gdSPDefPosLight(r3,g3,b3,x3,y3,z3,c3,l3,q3), \ + _gdSPDefPosLight(r4,g4,b4,x4,y4,z4,c4,l4,q4), \ + _gdSPDefPosLight(r5,g5,b5,x5,y5,z5,c5,l5,q5), \ + _gdSPDefPosLight(r6,g6,b6,x6,y6,z6,c6,l6,q6)} } +#define gdSPDefPosLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,c1,l1,q1,r2,g2,b2,x2,y2,z2,c2,l2,q2,r3,g3,b3,x3,y3,z3,c3,l3,q3,r4,g4,b4,x4,y4,z4,c4,l4,q4,r5,g5,b5,x5,y5,z5,c5,l5,q5,r6,g6,b6,x6,y6,z6,c6,l6,q6,r7,g7,b7,x7,y7,z7,c7,l7,q7) \ + { _gdSPDefAmbient(ar,ag,ab), \ + { _gdSPDefPosLight(r1,g1,b1,x1,y1,z1,c1,l1,q1), \ + _gdSPDefPosLight(r2,g2,b2,x2,y2,z2,c2,l2,q2), \ + _gdSPDefPosLight(r3,g3,b3,x3,y3,z3,c3,l3,q3), \ + _gdSPDefPosLight(r4,g4,b4,x4,y4,z4,c4,l4,q4), \ + _gdSPDefPosLight(r5,g5,b5,x5,y5,z5,c5,l5,q5), \ + _gdSPDefPosLight(r6,g6,b6,x6,y6,z6,c6,l6,q6), \ + _gdSPDefPosLight(r7,g7,b7,x7,y7,z7,c7,l7,q7)} } + +#endif /* _GBI_POSLIGHT_H_ */ diff --git a/include/PR/gbi.h b/include/PR/gbi.h index ebfab07e0..eea18d5b7 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -2477,11 +2477,11 @@ typedef union { gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) #define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gsSPLoadUcode(OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #endif #ifdef F3DEX_GBI_2 @@ -4795,6 +4795,10 @@ typedef union { #define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag) #define gsDPNoOpTag(tag) gsDPParam(G_NOOP, tag) +#if defined(F3DZEX_GBI_2) || defined(F3DZEX_NON_GBI_2) || defined(L3DZEX_GBI) +#include "gbi-poslight.h" +#endif + #endif /* _LANGUAGE_C */ diff --git a/include/PR/gt.h b/include/PR/gt.h new file mode 100644 index 000000000..09b6ba2d5 --- /dev/null +++ b/include/PR/gt.h @@ -0,0 +1,365 @@ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * + * UNPUBLISHED -- Rights reserved under the copyright laws of the United + * States. Use of a copyright notice is precautionary only and does not + * imply publication or disclosure. + * + * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or + * in similar or successor clauses in the FAR, or the DOD or NASA FAR + * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., + * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. + * + * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY + * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, + * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY + * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON + * GRAPHICS, INC. + * + */ + +/* + * File: gt.h + * Creator: hsa@sgi.com + * Create Date: Thu Oct 12 15:48:14 PDT 1995 + * + * This file defines the GBI for the TURBO 3D graphics microcode. + * The turbo microcode is a special FEATURE-LIMITED microcode designed + * for specific applications. It is not for general use. + * + * (see XXX for more information) + * + */ + +/************************************************************************** + * + * $Revision: 1.16 $ + * $Date: 1998/05/28 00:14:50 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gt.h,v $ + * + **************************************************************************/ + +#ifndef _GT_H_ +#define _GT_H_ + +/* this file should be #included AFTER gbi.h */ + +#include "sptask.h" + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +#include + +/* the following #defines seem out of order, but we need them + * for the microcode. + */ + +/* + * object state field: rendState + * + * This flag word is built up out of the bits from a + * subset of the G_SETGEOMETRYMODE flags from gbi.h. + * + * When each of these bits is '1', the comments below explain + * the effect on the triangles. + */ +#define GT_ZBUFFER G_ZBUFFER +#define GT_TEXTURE G_TEXTURE_ENABLE /* texture ON */ +#define GT_CULL_BACK G_CULL_BACK /* reject backfaces */ +#define GT_SHADING_SMOOTH G_SHADING_SMOOTH /* smooth shade ON */ + +/* + * object state field: textureState + * + * The lower 3 bits of this flag word contain the texture tile number + * to be used. All triangles of an object are rendered with the same + * texture tile. + */ + +/* + * object state field: flag + * + * This is a group of what would be pad bits. We use them for some + * flag bits. + */ +#define GT_FLAG_NOMTX 0x01 /* don't load the matrix */ +#define GT_FLAG_NO_XFM 0x02 /* load vtx, use verbatim */ +#define GT_FLAG_XFM_ONLY 0x04 /* xform vtx, write to *TriN */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* turbo 3D ucode: */ +extern long long int gspTurbo3DTextStart[], gspTurbo3DTextEnd[]; +extern long long int gspTurbo3DDataStart[], gspTurbo3DDataEnd[]; +extern long long int gspTurbo3D_dramTextStart[], gspTurbo3D_dramTextEnd[]; +extern long long int gspTurbo3D_dramDataStart[], gspTurbo3D_dramDataEnd[]; +extern long long int gspTurbo3D_fifoTextStart[], gspTurbo3D_fifoTextEnd[]; +extern long long int gspTurbo3D_fifoDataStart[], gspTurbo3D_fifoDataEnd[]; + +/* + * This is the global state structure. It's definition carefully + * matches the ucode, so if this structure changes, you must also change + * the ucode. + */ +typedef struct { + u16 perspNorm; /* persp normalization */ + u16 pad0; + u32 flag; + Gfx rdpOthermode; + u32 segBases[16]; /* table of segment base addrs (SEE NOTE!) */ + Vp viewport; /* the viewport to use */ + Gfx *rdpCmds; /* block of RDP data, process if !NULL + * block terminated by gDPEndDisplayList() + * (This is a segment address) + */ +} gtGlobState_t; + +/* NOTE: + * Although there are 16 segment table entries, the first one (segment 0) + * is reserved for physical memory mapping. You should not segment 0 + * to anything other than 0x0. + */ + +typedef union { + gtGlobState_t sp; + long long int force_structure_alignment; +} gtGlobState; + + +/* + * This is the 'state' structure associated with each object + * to be rendered. It's definition carefully matches the + * ucode, so if this structure changes, you must also change + * the gtoff.c tool and the ucode. + */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; + Mtx transform; /* the transform matrix to use */ +} gtState_t; + +typedef union { + gtState_t sp; + long long int force_structure_alignment; +} gtState; + +/* gtStateLite : same as gtState, but no matrix (see flags below) */ +/* this structure must be identical to gtState! (bad) */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; +} gtStateL_t; + +typedef union { + gtStateL_t sp; + long long int force_structure_alignment; +} gtStateL; + +/* + * The vertex list for the turbo display list uses the + * Vtx struct in gbi.h + * + */ + + +/* + * This structure represents a single triangle, part of the + * triangle list of the object to be rendered. + * + * NOTE: The triangle list MUST be aligned to an 8-byte boundary. + * Since this structure is only 4 bytes, we are REQUIRING that + * this structure only be used as an array of triangles, and we + * depend on the MIPS C compiler (which always aligns arrays to + * 8-byte boundaries). THIS IS DANGEROUS!!!! + * + */ +typedef struct { + u8 v0, v1, v2, flag; /* flag is which one for flat shade */ +} gtTriN; + + +/* + * This structure represents the transformed points. It is the format + * of the points written out when GT_FLAG_XFM_ONLY is set, as well as + * the format expected when GT_FLAG_NO_XFM is used. + * + * NOTE: The size and layout of these points is very similar to Vtx, + * except the screen coordinates overwrite the x,y,z,pad fields. + * (we could consider adding to the Vtx union, but we want to keep + * turbo stuff out of gbi.h) + * + * NOTE: The z is a special format. It can be used to compare vertices + * for sorting, but it should not be used for other purposes. If modified, + * the z-buffer hardware might not understand the data. + * + */ +typedef struct { + short int xscrn; /* x,y screen coordinates are SSSS10.2 */ + short int yscrn; + int zscrn; /* z screen is S15.16 */ + + short int s; /* transformed texture coord, S10.5 */ + short int t; + + u8 r; /* color (or normal) */ + u8 g; + u8 b; + u8 a; +} gtVtxOut_t; + +/* see "Data Structure" comment in gbi.h for information about why + * we use this union. + */ +typedef union { + gtVtxOut_t v; + long long int force_structure_alignment; +} gtVtxOut; + + + +/* + * state field: rdpOthermode + * + * This is one of the trickier state fields. The turbo interface + * requires the RDP othermode command to be cached by the host, + * therefore we provide a different interface in libultra to help cache + * this in the gt state (this word is just bits, you could pack them + * on your own). + * + * gtStateSetOthermode() accomplishs this, taking as arguments + * the state, one of the following mode enums, and a piece of data + * (othermode parameters from gbi.h). + * + * By definition, the othermode word from the gt state structure is sent + * to the RDP *before* any RDP commands from the rdpCmds[] field. The + * othermode is *always* sent. + * + * Stated another way, NONE of the gbi RDP othermode commands equivalent + * to those listed here are allowed in the rdpCmd[] field of the + * gt state structure. + * + * Notice also that many of these commands do not make sense for + * the turbo ucode (they control features not supported, like mip-mapping). + * They are only included here for completeness. + * + */ +typedef enum { + GT_CLEAR, /* special gt mode, clears othermode state */ + GT_ALPHACOMPARE, + GT_ZSRCSEL, + GT_RENDERMODE, + GT_ALPHADITHER, + GT_RGBDITHER, + GT_COMBKEY, + GT_TEXTCONV, + GT_TEXTFILT, + GT_TEXTLUT, + GT_TEXTLOD, + GT_TEXTDETAIL, + GT_TEXTPERSP, + GT_CYCLETYPE, + GT_PIPELINE +} gtStateOthermode_t; + +/* + * This call builds up an othermode command word. The 'mode' is one of + * the above modes, the 'data' field comes from gbi.h, it is the data + * field for the equivalent gbi setothermode macro. + */ +extern void gtStateSetOthermode(Gfx *om, gtStateOthermode_t mode, int data); + +/* + * This call dumps a turbo display list for use with gbi2mem and RSPSIM + */ +#define GT_DUMPTURBO_HANGAFTER 64 +#define GT_DUMPTURBO_NOTEXTURES 128 +extern void gtDumpTurbo(OSTask *tp,u8 flags); + +/* + * Special macros to init othermode words to all 0's, a good default + * value. + */ +#define gDPClearOtherMode(pkt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE, 24, 8); \ + _g->words.w1 = 0x0; \ +} + +#define gsDPClearOtherMode() \ +{ \ + _SHIFTL(G_RDPSETOTHERMODE, 24, 8), 0x0 \ +} + +/* + * Special macros to end DP blocks (see above). These commands + * generate all 0's, which the turbo ucode looks for. They *aren't* + * real DP commands! + */ +#define gDPEndDisplayList(pkt) gSPNoOp(pkt) +#define gsDPEndDisplayList() gsSPNoOp() + +/* + * This structure is a turbo 'object', the turbo display list is + * simply a list of these. + * + * NOTE: All pointers are segment addresses + * + * NOTE: If (statep->flag & GT_FLAG_XFM_ONLY), the trip field is + * interpreted as a pointer to gtVtxOut[] that can be used to store + * the transformed points. (statep->triCount should be 0, else bad + * things could happen...) + * + * NOTE: If (statep->flag & GT_FLAG_NO_XFM), the vtxp field is + * interpreted as a pointer to gtVtxOut[] that can be used to load + * pre-transformed points. + * + */ +typedef struct { + gtGlobState *gstatep; /* global state, usually NULL */ + gtState *statep; /* if this is NULL, end object processing */ + Vtx *vtxp; /* if this is NULL, use points in buffer */ + gtTriN *trip; /* if this is NULL, use tris in buffer */ +} gtGfx_t; + +typedef union { + gtGfx_t obj; + long long int force_structure_alignment; +} gtGfx; + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_ASSEMBLY +#include +#endif /* _LANGUAGE_ASSEMBLY */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +#ifdef _LANGUAGE_MAKEROM +#endif /* _LANGUAGE_MAKEROM */ + +#endif /* _GT_H_ */ diff --git a/include/PR/gtoff.h b/include/PR/gtoff.h new file mode 100644 index 000000000..0564fa2bd --- /dev/null +++ b/include/PR/gtoff.h @@ -0,0 +1,12 @@ +/* GENERATED FILE, DO NOT EDIT! */ + +/* gtState_t structure offsets for assembly language: */ +#define GT_STATE_SIZE 176 +#define GT_STATE_OFF_RENDSTATE 0x00 +#define GT_STATE_OFF_TEXSTATE 0x08 +#define GT_STATE_OFF_VTXCOUNT 0x10 +#define GT_STATE_OFF_VTXV0 0x11 +#define GT_STATE_OFF_TRICOUNT 0x12 +#define GT_STATE_OFF_RDPCMDS 0x18 +#define GT_STATE_OFF_OTHERMODE 0x20 +#define GT_STATE_OFF_TRANSFORM 0x30 diff --git a/include/PR/gu.h b/include/PR/gu.h index 6527777d9..aa83ba08a 100644 --- a/include/PR/gu.h +++ b/include/PR/gu.h @@ -1,29 +1,269 @@ -#ifndef _ULTRA64_GU_H_ -#define _ULTRA64_GU_H_ +#ifndef _GU_H_ +#define _GU_H_ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.48 $ + * $Date: 1999/07/13 08:00:20 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gu.h,v $ + * + **************************************************************************/ #include #include +#include -#define GU_PI 3.1415926 -/* Functions */ - -void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, - float near, float far, float scale); -void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, - float far, float scale); -void guOrtho(Mtx *m, float left, float right, float bottom, float top, - float near, float far, float scale); -void guTranslate(Mtx *m, float x, float y, float z); -void guRotate(Mtx *m, float a, float x, float y, float z); -void guScale(Mtx *m, float x, float y, float z); -void guMtxF2L(float mf[4][4], Mtx *m); -void guMtxIdent(Mtx *m); -void guMtxIdentF(float mf[4][4]); -void guMtxL2F(float mf[4][4], Mtx *m); -void guNormalize(float *, float *, float *); - -/* Used only in Fast3DEX2 */ -void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, - float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp); +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) #endif +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#define M_PI 3.14159265358979323846 +#define M_DTOR (3.14159265358979323846/180.0) + +#define FTOFIX32(x) (long)((x) * (float)0x00010000) +#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000)) +#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff) + +#define FILTER_WRAP 0 +#define FILTER_CLAMP 1 + +#define RAND(x) (guRandom()%x) /* random number between 0 to x */ + +/* + * Data Structures + */ +typedef struct { + unsigned char *base; + int fmt, siz; + int xsize, ysize; + int lsize; + /* current tile info */ + int addr; + int w, h; + int s, t; +} Image; + +typedef struct { + float col[3]; + float pos[3]; + float a1, a2; /* actual color = col/(a1*dist + a2) */ +} PositionalLight; + + +/* + * Function Prototypes + */ + +extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im, + unsigned char startTile, unsigned char pal, unsigned char cms, + unsigned char cmt, unsigned char masks, unsigned char maskt, + unsigned char shifts, unsigned char shiftt, unsigned char cfs, + unsigned char cft); + +extern int guGetDPLoadTextureTileSz (int ult, int lrt); +extern void guDPLoadTextureTile (Gfx *glistp, void *timg, + int texl_fmt, int texl_size, + int img_width, int img_height, + int uls, int ult, int lrs, int lrt, + int palette, + int cms, int cmt, + int masks, int maskt, + int shifts, int shiftt); + + +/* + * matrix operations: + * + * The 'F' version is floating point, in case the application wants + * to do matrix manipulations and convert to fixed-point at the last + * minute. + */ +extern void guMtxIdent(Mtx *m); +extern void guMtxIdentF(float mf[4][4]); +extern void guOrtho(Mtx *m, float l, float r, float b, float t, + float n, float f, float scale); +extern void guOrthoF(float mf[4][4], float l, float r, float b, float t, + float n, float f, float scale); +extern void guFrustum(Mtx *m, float l, float r, float b, float t, + float n, float f, float scale); +extern void guFrustumF(float mf[4][4], float l, float r, float b, float t, + float n, float f, float scale); +extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy, + float aspect, float near, float far, float scale); +extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, + float aspect, float near, float far, float scale); +extern void guLookAt(Mtx *m, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtReflect(Mtx *m, LookAt *l, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtReflectF(float mf[4][4], LookAt *l, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtHilite(Mtx *m, LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float xl1, float yl1, float zl1, + float xl2, float yl2, float zl2, + int twidth, int theight); +extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float xl1, float yl1, float zl1, + float xl2, float yl2, float zl2, + int twidth, int theight); +extern void guLookAtStereo(Mtx *m, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float eyedist); +extern void guLookAtStereoF(float mf[4][4], + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float eyedist); +extern void guRotate(Mtx *m, float a, float x, float y, float z); +extern void guRotateF(float mf[4][4], float a, float x, float y, float z); +extern void guRotateRPY(Mtx *m, float r, float p, float y); +extern void guRotateRPYF(float mf[4][4], float r, float p, float h); +extern void guAlign(Mtx *m, float a, float x, float y, float z); +extern void guAlignF(float mf[4][4], float a, float x, float y, float z); +extern void guScale(Mtx *m, float x, float y, float z); +extern void guScaleF(float mf[4][4], float x, float y, float z); +extern void guTranslate(Mtx *m, float x, float y, float z); +extern void guTranslateF(float mf[4][4], float x, float y, float z); +extern void guPosition(Mtx *m, float r, float p, float h, float s, + float x, float y, float z); +extern void guPositionF(float mf[4][4], float r, float p, float h, float s, + float x, float y, float z); +extern void guMtxF2L(float mf[4][4], Mtx *m); +extern void guMtxL2F(float mf[4][4], Mtx *m); +extern void guMtxCatF(float m[4][4], float n[4][4], float r[4][4]); +extern void guMtxCatL(Mtx *m, Mtx *n, Mtx *res); +extern void guMtxXFMF(float mf[4][4], float x, float y, float z, + float *ox, float *oy, float *oz); +extern void guMtxXFML(Mtx *m, float x, float y, float z, + float *ox, float *oy, float *oz); + +/* vector utility: */ +extern void guNormalize(float *x, float *y, float *z); + +/* light utilities: */ +void guPosLight(PositionalLight *pl, Light *l, + float xOb, float yOb, float zOb); +void guPosLightHilite(PositionalLight *pl1, PositionalLight *pl2, + Light *l1, Light *l2, + LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xOb, float yOb, float zOb, + float xUp, float yUp, float zUp, + int twidth, int theight); +extern int guRandom(void); + +/* + * Math functions + */ +extern float sinf(float angle); +extern float cosf(float angle); +extern signed short sins (unsigned short angle); +extern signed short coss (unsigned short angle); +extern float sqrtf(float value); +#ifdef __sgi +#pragma intrinsic(sqrtf); +#endif + +/* + * Dump routines for low-level display lists + */ +/* flag values for guParseRdpDL() */ +#define GU_PARSERDP_VERBOSE 1 +#define GU_PARSERDP_PRAREA 2 +#define GU_PARSERDP_PRHISTO 4 +#define GU_PARSERDP_DUMPONLY 32 /* doesn't need to be same as */ + /* GU_PARSEGBI_DUMPOLNY, but this */ + /* allows app to use interchangeably */ + +extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags); +extern void guParseString(char *StringPointer, u64 nbytes); + +/* + * NO LONGER SUPPORTED, + * use guParseRdpDL with GU_PARSERDP_DUMPONLY flags + */ +/* extern void guDumpRawRdpDL(u64 *rdp_dl, u64 nbytes); */ + +/* flag values for guBlinkRdpDL() */ +#define GU_BLINKRDP_HILITE 1 +#define GU_BLINKRDP_EXTRACT 2 + +extern void +guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in, + u64 *rdp_dl_out, u64 *nbytes_out, + u32 x, u32 y, u32 radius, + u8 red, u8 green, u8 blue, + u8 flags); + +/* flag values for guParseGbiDL() */ +#define GU_PARSEGBI_ROWMAJOR 1 +#define GU_PARSEGBI_NONEST 2 +#define GU_PARSEGBI_FLTMTX 4 +#define GU_PARSEGBI_SHOWDMA 8 +#define GU_PARSEGBI_ALLMTX 16 +#define GU_PARSEGBI_DUMPONLY 32 +/* +#define GU_PARSEGBI_HANGAFTER 64 +#define GU_PARSEGBI_NOTEXTURES 128 +*/ +extern void guParseGbiDL(u64 *gbi_dl, u32 nbytes, u8 flags); +extern void guDumpGbiDL(OSTask *tp,u8 flags); + +#define GU_PARSE_GBI_TYPE 1 +#define GU_PARSE_RDP_TYPE 2 +#define GU_PARSE_READY 3 +#define GU_PARSE_MEM_BLOCK 4 +#define GU_PARSE_ABI_TYPE 5 +#define GU_PARSE_STRING_TYPE 6 + +typedef struct { + int dataSize; + int dlType; + int flags; + u32 paddr; +} guDLPrintCB; + +void guSprite2DInit(uSprite *SpritePointer, + void *SourceImagePointer, + void *TlutPointer, + int Stride, + int SubImageWidth, + int SubImageHeight, + int SourceImageType, + int SourceImageBitSize, + int SourceImageOffsetS, + int SourceImageOffsetT); + +#endif /* !_GU_H_ */ diff --git a/include/PR/gzsort.h b/include/PR/gzsort.h new file mode 100644 index 000000000..eaa67ebfe --- /dev/null +++ b/include/PR/gzsort.h @@ -0,0 +1,631 @@ +/*---------------------------------------------------------------------* + Copyright (C) 1997-1998, Nintendo. + + File gzsort.h + Coded by Yoshitaka Yasumoto. Jun 16, 1997. + + $Id: gzsort.h,v 1.11 1998/01/06 01:28:21 yasu Exp $ + *---------------------------------------------------------------------*/ +#ifndef _GZSORT_H_ +#define _GZSORT_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +/*===========================================================================* + * GBI Commands for ZSort microcode + *===========================================================================*/ +/* GBI Header */ +#define G_ZS_ZOBJ 0x80 +#define G_ZS_RDPCMD 0x81 +#define G_ZS_MOVEMEM 0xdc +#define G_ZS_SENDSIGNAL 0xda +#define G_ZS_WAITSIGNAL 0xd9 +#define G_ZS_SETSUBDL 0xd8 +#define G_ZS_LINKSUBDL 0xd7 +#define G_ZS_MULT_MPMTX 0xd6 +#define G_ZS_MTXCAT 0xd5 +#define G_ZS_MTXTRNSP 0xd4 +#define G_ZS_LIGHTING_L 0xd3 /* Not use */ +#define G_ZS_LIGHTING 0xd2 +#define G_ZS_XFMLIGHT 0xd1 +#define G_ZS_INTERPOLATE 0xd0 + +/*------------------------------------------------------------------------* + * case_G_ZOBJ + * +--------+--------+--------+--------+ + * | Pointr for zobj0:32 | + * +--------+--------+--------+--------+ + * | Pointr for zobj1:32 | + * +--------+--------+--------+--------+ + * Draw zobject links + */ +#define gSPZObject(pkt, objA, objB) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (unsigned int)(objA); \ + _g->words.w1 = (unsigned int)(objB); \ +} + +#define gsSPZObject(objA, objB) \ +{ \ + (unsigned int)(objA), (unsigned int)(objB) \ +} + +/*------------------------------------------------------------------------* + * case_G_RDPCMD + * +--------+--------+--------+--------+ + * | RDPCMD | 0 | + * +--------+--------+--------+--------+ + * | Pointr for rdpcmd:32 | + * +--------+--------+--------+--------+ + * Submit rdp cmd + */ +#define gSPZRdpCmd(pkt, cmd) gImmp1((pkt), G_ZS_RDPCMD, (cmd)) +#define gsSPZRdpCmd(cmd) gsImmp1(G_ZS_RDPCMD, (cmd)) + +/*------------------------------------------------------------------------* + * case_G_MOVEMEM + * +--------+--------++-------+-+----+-+ + * |MOVEMEM | Len:9 | Ofs:9 |ID:5|F| + * +--------+--------++-------+-+----+-+ + * | Pointr for RDRAM:32 | + * +--------+--------+--------+--------+ + * Read/Write DMEM + */ +#define GZM_USER0 0 +#define GZM_USER1 2 +#define GZM_MMTX 4 +#define GZM_PMTX 6 +#define GZM_MPMTX 8 +#define GZM_OTHERMODE 10 +#define GZM_VIEWPORT 12 +#define GZF_LOAD 0 +#define GZF_SAVE 1 + +#define gSPZMoveMem(pkt, id, ofs, len, buffer, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_MOVEMEM, 24, 8)| \ + _SHIFTL(((len)-1)>>3, 15, 9)| \ + _SHIFTL((ofs)>>3, 6, 9)|(id)|(flag); \ + _g->words.w1 = (unsigned int)(buffer); \ +} + +#define gsSPZMoveMem(id, ofs, len, buffer, flag) \ +{ \ + _SHIFTL(G_ZS_MOVEMEM, 24, 8)| \ + _SHIFTL(((len)-1)>>3, 15, 9)| \ + _SHIFTL((ofs)>>3, 6, 9)|(id)|(flag), \ + (unsigned int)(buffer) \ +} + +/*------------------------------------------------------------------------*/ +#define gSPZSetUMem(pkt, umem, size, adrs) \ + gSPZMoveMem((pkt),GZM_USER0,(umem),(size),(adrs),GZF_LOAD) +#define gsSPZSetUMem(umem, size, adrs) \ + gsSPZMoveMem(GZM_USER0,(umem),(size),(adrs),GZF_LOAD) + +#define gSPZGetUMem(pkt, umem, size, adrs) \ + gSPZMoveMem((pkt),GZM_USER0,(umem),(size),(adrs),GZF_SAVE) +#define gsSPZGetUMem(umem, size, adrs) \ + gsSPZMoveMem(GZM_USER0,(umem),(size),(adrs),GZF_SAVE) + +/*------------------------------------------------------------------------*/ +#define gSPZSetMtx(pkt, mid, mp) \ + gSPZMoveMem((pkt), (mid), 0, sizeof(Mtx), (mp), GZF_LOAD) +#define gsSPZSetMtx(mid, mp) \ + gsSPZMoveMem((mid), 0, sizeof(Mtx), (mp), GZF_LOAD) + +/*------------------------------------------------------------------------*/ +#define gSPZGetMtx(pkt, mid, mp) \ + gSPZMoveMem((pkt), (mid), 0, sizeof(Mtx), (mp), GZF_SAVE) +#define gsSPZGetMtx(mid, mp) \ + gsSPZMoveMem((mid), 0, sizeof(Mtx), (mp), GZF_SAVE) + +/*------------------------------------------------------------------------*/ +#define gSPZSetAmbient(pkt, umem, lights) \ + gSPZSetUMem((pkt),(umem),ZSIZE_AMBIENT,(lights)) +#define gsSPZSetAmbient(umem, lights) \ + gsSPZSetUMem((umem),ZSIZE_AMBIENT,(lights)) + +/*------------------------------------------------------------------------*/ +#define gSPZSetDefuse(pkt, umem, lid, lights) \ + gSPZSetUMem((pkt),(umem)+ZSIZE_AMBIENT+(lid)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, (lights)) +#define gsSPZSetDefuse(umem, lid, lights) \ + gsSPZSetUMem((umem)+ZSIZE_AMBIENT+(lid)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, (lights)) + +/*------------------------------------------------------------------------*/ +#define gSPZSetLookAt(pkt, umem, lid, lookat) \ +{ gSPZSetUMem((pkt), (umem)+ZSIZE_AMBIENT+((lid)+0)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, \ + ((u32)(lookat))+sizeof(Light)*0); \ + gSPZSetUMem((pkt), (umem)+ZSIZE_AMBIENT+((lid)+1)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, \ + ((u32)(lookat))+sizeof(Light)*1); } +#define gsSPZSetLookAt(umem, lid, lookat) \ + gsSPZSetUMem((umem)+ZSIZE_AMBIENT+((lid)+0)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, \ + ((u32)(lookat))+sizeof(Light)*0), \ + gsSPZSetUMem((umem)+ZSIZE_AMBIENT+((lid)+1)*ZSIZE_LIGHT, \ + ZSIZE_DEFUSE, \ + ((u32)(lookat))+sizeof(Light)*1) + +/*------------------------------------------------------------------------*/ +#define gSPZViewport(pkt, v) \ + gSPZMoveMem((pkt), GZM_VIEWPORT, 0, 16, (v), GZF_LOAD) +#define gsSPZViewport(v) \ + gsSPZMoveMem(GZM_VIEWPORT, 0, 16, (v), GZF_LOAD) + +#define GZ_VIEWPORT_FOG_S(in, out) (0x400000/((out)-(in))) +#define GZ_VIEWPORT_FOG_T(in, out) ((0x200*(out))/((in)-(out))) + +/*------------------------------------------------------------------------* + * case_G_SENDSIGNAL + * +--------+--------+--------+--------+ + * |Send SIG| Parameter1:24 | + * +--------+--------+--------+--------+ + * | Parameter2:32 | + * +--------+--------+--------+--------+ + * Send signal to CPU + */ +#define GZ_INTR_SPBRK1 SP_STATUS_RSPSIGNAL +#define GZ_INTR_SPBRK2 \ + (SP_SET_RSPSIGNAL|SP_CLR_TASKDONE|SP_CLR_YIELDED|SP_SET_INTR) + +#define gSPZSendMessage(pkt) \ + gDma0p((pkt), G_ZS_SENDSIGNAL, GZ_INTR_SPBRK2, GZ_INTR_SPBRK1) +#define gsSPZSendMessage() \ + gsDma0p(G_ZS_SENDSIGNAL, GZ_INTR_SPBRK2, GZ_INTR_SPBRK1) + +/*------------------------------------------------------------------------* + * case_G_WAITSIGNAL + * +--------+--------+--------+--------+ + * |Wait SIG| Phy Adrs of signal buf:24| + * +--------+--------+--------+--------+ + * | Parameter:32 | + * +--------+--------+--------+--------+ + * Wait signal from CPU + */ +#define gSPZWaitSignal(pkt, adrs, param) \ + gDma0p((pkt), G_ZS_WAITSIGNAL, (param), (adrs)) + +#define gsSPZWaitSignal(adrs, param) \ +{ \ + (unsigned int)((char *)(adrs)+((G_ZS_WAITSIGNAL-0x80)<<24)), \ + (unsigned int)(param) \ +} + +#define GZ_SENDSIGNAL(adrs,val) { \ + IO_WRITE(&(((zSignal *)(adrs))->t.signal), (val)); \ + IO_WRITE(SP_STATUS_REG, SP_SET_CPUSIGNAL); \ +} + +/*------------------------------------------------------------------------* + * case_G_SETSUBDL + * +--------+--------+--------+--------+ + * |SETSUBDL| 0 | + * +--------+--------+--------+--------+ + * | DL:32 | + * +--------+--------+--------+--------+ + */ +#define gSPZSetSubDL(pkt, dl) gImmp1((pkt), G_ZS_SETSUBDL, (u32)(dl)) +#define gsSPZSetSubDL(dl) gsImmp1(G_ZS_SETSUBDL, (u32)(dl)) + +/*------------------------------------------------------------------------* + * case_G_LINKSUBDL + * +--------+--------+--------+--------+ + * |LINKSUBD| 0 | + * +--------+--------+--------+--------+ + * | 0 | + * +--------+--------+--------+--------+ + */ +#define gSPZLinkSubDL(pkt) gImmp0((pkt), G_ZS_LINKSUBDL) +#define gsSPZLinkSubDL() gsImmp0(G_ZS_LINKSUBDL) + +/*------------------------------------------------------------------------* + * case_G_MULT_MPMTX + * +--------+--------+--------+--------+ + * |MULT_MPM| 0 | Mid:8 | + * +--------+--------+----+---+--------+ + * | Num:8 | Src:12 | Dest:12 | + * +--------+-------------+------------+ + */ +#define gSPZMultMPMtx(pkt, mid, src, num, dest) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_MULT_MPMTX,24,8)|_SHIFTL((mid),0,8); \ + _g->words.w1 = _SHIFTL(((num)-1), 24, 8)| \ + _SHIFTL((src)+1024,12,12)|_SHIFTL((dest)+1024, 0,12); \ +} + +#define gsSPZMultMPMtx(mid, src, num, dest) \ +{ \ + _SHIFTL(G_ZS_MULT_MPMTX,24,8)|_SHIFTL((mid),0, 8), \ + _SHIFTL(((num)-1), 24, 8)| \ + _SHIFTL((src)+1024,12,12)|_SHIFTL((dest)+1024,0,12) \ +} + +/*------------------------------------------------------------------------* + * case_G_MTXCAT + * +--------+--------+--------+--------+ + * | MTXCAT | 0 | 0 | MidS:8 | + * +--------+--------+--------+--------+ + * | 0 | MidT:8 | 0 | MidD:8 | + * +--------+--------+--------+--------+ + */ +#define gSPZMtxCat(pkt, midS, midT, midD) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_MTXCAT,24,8)|_SHIFTL((midS), 0,8); \ + _g->words.w1 = _SHIFTL((midT), 16,8)|_SHIFTL((midD), 0,8); \ +} + +#define gsSPZMtxCat(midS, midT, midD) \ +{ \ + _SHIFTL(G_ZS_MTXCAT,24,8)|_SHIFTL((midS), 0,8), \ + _SHIFTL((midT), 16,8)|_SHIFTL((midD), 0,8) \ +} + +/*------------------------------------------------------------------------* + * case_G_MTXTRNSP + * +--------+--------+--------+--------+ + * |MTXTRNSP| 0 | 0 | 0 | + * +--------+--------+--------+--------+ + * | 0 | 0 | 0 | Mid:8 | + * +--------+--------+--------+--------+ + */ +#define gSPZMtxTrnsp3x3(pkt, mid) gImmp1((pkt), G_ZS_MTXTRNSP, (mid)) +#define gsSPZMtxTrnsp3x3(mid) gsImmp1(G_ZS_MTXTRNSP, (mid)) + +/*------------------------------------------------------------------------* + * case_G_XFMLIGHT + * +--------+--------+--------+--------+ + * |XFMLIGHT| 0 | Mid:8 | + * +--------+----+---+----+---+--------+ + * | 0 | Lnum:8 | Lptr:12 | + * +--------+----+---+----+---+--------+ + */ +#define gSPZXfmLights(pkt, mid, umem, lnum) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_XFMLIGHT,24,8)|(mid); \ + _g->words.w1 = _SHIFTL((lnum)-1,12,8)|_SHIFTL((umem)+1024, 0,12); \ +} + +#define gsSPZXfmLights(mid, umem, lnum) \ +{ \ + _SHIFTL(G_ZS_XFMLIGHT,24,8)|(mid), \ + _SHIFTL((lnum)-1,12,8)|_SHIFTL((umem)+1024, 0,12) \ +} + +/*------------------------------------------------------------------------* + * case_G_LIGHTING + * +--------+-------------+------------+ + * |LIGHTING| Color:12 | Norm:12 | + * +--------+-------------+------------+ + * | Num:8 | DestColor:12| DestTxtr:12| + * +--------+-------------+------------+ + * gSPZLight/gSPZLightMaterial + */ +#define gSPZLightMaterial(pkt, csrc, nsrc, num, cdest, tdest) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_LIGHTING,24,8)| \ + _SHIFTL((csrc)+1024, 12,12)|_SHIFTL((nsrc) +1024,0,12);\ + _g->words.w1 = _SHIFTL((num)-1, 24, 8)| \ + _SHIFTL((cdest)+1024,12,12)|_SHIFTL((tdest)+1024,0,12);\ +} + +#define gsSPZLightMaterial(csrc, nsrc, num, cdest, tdest) \ +{ \ + _SHIFTL(G_ZS_LIGHTING,24,8)| \ + _SHIFTL((csrc)+1024, 12,12)|_SHIFTL((nsrc) +1024,0,12), \ + _SHIFTL((num)-1, 24, 8)| \ + _SHIFTL((cdest)+1024,12,12)|_SHIFTL((tdest)+1024,0,12) \ +} + +#define gSPZLight(pkt, nsrc, num, cdest, tdest) \ + gSPZLightMaterial((pkt),-16,(nsrc),(num),(cdest),(tdest)) +#define gsSPZLight(nsrc, num, cdest, tdest) \ + gsSPZLightMaterial(-16,(nsrc),(num),(cdest),(tdest)) + +/*------------------------------------------------------------------------* + * case_G_INTERPOLATE + * +--------+--------+-----------------+ + * |INTERPLT| Type:8 | Factor:16 | + * +--------+--------+----+------------+ + * | Num:8 | Src1/Dest:12| Src2:12 | + * +--------+-------------+------------+ + */ +#define GZ_INTRP_S16 0 +#define GZ_INTRP_S8 2 +#define GZ_INTRP_U8 4 + +#define gSPZMix(pkt, src1, src2, num, factor, type) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_ZS_INTERPOLATE,24,8)| \ + _SHIFTL((type),16, 8)|_SHIFTL((factor),0,16); \ + _g->words.w1 = _SHIFTL((num)/8-1,24,8)| \ + _SHIFTL((src1),12,12)|_SHIFTL((src2), 0,12); \ +} + +#define gsSPZMix(src1, src2, num, factor, type) \ +{ \ + _SHIFTL(G_ZS_INTERPOLATE,24,8)| \ + _SHIFTL((type),16, 8)|_SHIFTL((factor),0,16), \ + _SHIFTL(((num)-1)/8,24,8)| \ + _SHIFTL((src1),12,12)|_SHIFTL((src2), 0,12) \ +} + +#define gSPZMixS16(pkt, src1, src2, num, factor) \ + gSPZMix((pkt), (src1), (src2), (num), (factor), GZ_INTRP_S16) +#define gSPZMixS8(pkt, src1, src2, num, factor) \ + gSPZMix((pkt), (src1), (src2), (num), (factor), GZ_INTRP_S8) +#define gSPZMixU8(pkt, src1, src2, num, factor) \ + gSPZMix((pkt), (src1), (src2), (num), (factor), GZ_INTRP_U8) + +#define gsSPZMixS16(src1, src2, num, factor) \ + gsSPZMix((src1), (src2), (num), (factor), GZ_INTRP_S16) +#define gsSPZMixS8(src1, src2, num, factor) \ + gsSPZMix((src1), (src2), (num), (factor), GZ_INTRP_S8) +#define gsSPZMixU8(src1, src2, num, factor) \ + gsSPZMix((src1), (src2), (num), (factor), GZ_INTRP_U8) + +/*------------------------------------------------------------------------* + * Compatible GBIs + *------------------------------------------------------------------------*/ +#define gSPZSegment(pkt, segment, base) gSPSegment((pkt), (segment), (base)) +#define gsSPZSegment(segment, base) gsSPSegment((segment), (base)) +#define gSPZPerspNormalize(pkt, s) gSPPerspNormalize((pkt), (s)) +#define gsSPZPerspNormalize(s) gsSPPerspNormalize(s) +#define gSPZDisplayList(pkt, dl) gSPDisplayList((pkt), (dl)) +#define gsSPZDisplayList(dl) gsSPDisplayList(dl) +#define gSPZEndDisplayList(pkt) gSPEndDisplayList(pkt) +#define gsSPZEndDisplayList() gsSPEndDisplayList() + +/*===========================================================================* + * Data structures for ZSort microcode + *===========================================================================*/ + +#define G_ZOBJ_NONE 0x80000000 + +/* ZObject IDs */ +#define ZH_NULL 0 +#define ZH_SHTRI 1 +#define ZH_TXTRI 2 +#define ZH_SHQUAD 3 +#define ZH_TXQUAD 4 +#define ZHDR(pointer, type) ((type)+((u32)(pointer))) + +/*===========================================================================* + * Useful MACRO + *===========================================================================*/ +#define guZFixLookAt(lp) \ + { (lp)->l[1].l.col[1] = (lp)->l[1].l.colc[1] = 0x00; } + +#if (defined(_LANGUAGE_C)||defined(_LANGUAGE_C_PLUS_PLUS)) +/*------------------------------------------------------------------------*/ +/* ZMath: Vertex structure format */ + +/*-----------------------------------------------------*/ +#define ZSIZE_VSRC 6 + +typedef struct { s16 x,y,z; } zVtxSrc; + +/*-----------------------------------------------------*/ +#define ZSIZE_VDEST 16 + +typedef struct { + s16 sx, sy; + s32 invw; + s16 xi, yi; + u8 cc; + u8 fog; + s16 wi; +} zVtxDest; + +#define GZ_CC_RIGHT 0x01 +#define GZ_CC_TOP 0x02 +#define GZ_CC_NEAR 0x04 +#define GZ_CC_LEFT 0x10 +#define GZ_CC_BOTTOM 0x20 +#define GZ_CC_FAR 0x40 + +/*-----------------------------------------------------*/ +#define ZSIZE_NSRC 3 + +typedef struct { s8 nx,ny,nz; } zNorm; + +/*-----------------------------------------------------*/ +#define ZSIZE_CSRC 4 +#define ZSIZE_CDEST 4 + +typedef struct { u8 r, g, b, a; } zColor_t; +typedef union { + zColor_t n; + u32 w; +} zColor; + +/*-----------------------------------------------------*/ +#define ZSIZE_TDEST 4 + +typedef struct { s16 s, t; } zTxtr_t; +typedef union { + zTxtr_t n; + u32 w; +} zTxtr; + +/*-----------------------------------------------------*/ +#define ZSIZE_LIGHT 24 +#define ZSIZE_DEFUSE 16 +#define ZSIZE_AMBIENT 8 + +/*------------------------------------------------------------------------*/ +/* ZObject: Common header */ +typedef struct { + u32 header; + Gfx *rdpcmd1; +} zHeader_t; + +typedef union { + zHeader_t t; + u64 force_structure_alignment; +} zHeader; + +/*------------------------------------------------------------------------*/ +/* ZObject: Null Node */ +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + Gfx *rdpcmd2; + Gfx *rdpcmd3; +} zNull_t; + +typedef union { + zNull_t t; + u64 force_structure_alignment; +} zNull; + +/*------------------------------------------------------------------------*/ +/* ZObject: Smooth Shaded Triangle */ +typedef struct { + s16 x, y; + u8 r, g, b, a; +} zShVtx; + +/*------------------------------------------------------------------------*/ +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + zShVtx v[3]; +} zShTri_t; + +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + u32 xy0, clr0; + u32 xy1, clr1; + u32 xy2, clr2; +} zShTri_w; + +typedef union { + zShTri_t t; + zShTri_w w; + u64 force_structure_alignment; +} zShTri; + +/*------------------------------------------------------------------------*/ +/* ZObject: Smooth Shaded Quadrangle */ +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + zShVtx v[4]; +} zShQuad_t; + +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + u32 xy0, clr0; + u32 xy1, clr1; + u32 xy2, clr2; + u32 xy3, clr3; +} zShQuad_w; + +typedef union { + zShQuad_t t; + zShQuad_w w; + u64 force_structure_alignment; +} zShQuad; + +/*------------------------------------------------------------------------*/ +/* ZObject: Smooth Shaded and Texture Mapped Triangle */ +typedef struct { + s16 x, y; + u8 r, g, b, a; + s16 s, t; + s32 invw; +} zTxVtx; + +/*------------------------------------------------------------------------*/ +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + Gfx *rdpcmd2; + Gfx *rdpcmd3; + zTxVtx v[3]; +} zTxTri_t; + +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + Gfx *rdpcmd2; + Gfx *rdpcmd3; + u32 xy0, clr0, st0, invw0; + u32 xy1, clr1, st1, invw1; + u32 xy2, clr2, st2, invw2; +} zTxTri_w; + +typedef union { + zTxTri_t t; + zTxTri_w w; + u64 force_structure_alignment; +} zTxTri; + +/*------------------------------------------------------------------------*/ +/* ZObject: Smooth Shaded and Texture Mapped Quadrangle */ +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + Gfx *rdpcmd2; + Gfx *rdpcmd3; + zTxVtx v[4]; +} zTxQuad_t; + +typedef struct { + zHeader *header; + Gfx *rdpcmd1; + Gfx *rdpcmd2; + Gfx *rdpcmd3; + u32 xy0, clr0, st0, invw0; + u32 xy1, clr1, st1, invw1; + u32 xy2, clr2, st2, invw2; + u32 xy3, clr3, st3, invw3; +} zTxQuad_w; + +typedef union { + zTxQuad_t t; + zTxQuad_w w; + u64 force_structure_alignment; +} zTxQuad; + +/*------------------------------------------------------------------------*/ +typedef struct { + u32 signal; + u32 padding; +} zSignal_t; + +typedef union { + zSignal_t t; + u64 force_structure_alignment; +} zSignal; + +/*===========================================================================* + * External functions + *===========================================================================*/ +extern u64 gspZSort_fifoTextStart[], gspZSort_fifoTextEnd[]; +extern u64 gspZSort_fifoDataStart[], gspZSort_fifoDataEnd[]; +extern u64 gspZSort_pl_fifoTextStart[], gspZSort_pl_fifoTextEnd[]; +extern u64 gspZSort_pl_fifoDataStart[], gspZSort_pl_fifoDataEnd[]; +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _GZSORT_H_ */ + +/*======== End of gzsort.h ========*/ diff --git a/include/PR/leo.h b/include/PR/leo.h new file mode 100644 index 000000000..96f2edd1d --- /dev/null +++ b/include/PR/leo.h @@ -0,0 +1,280 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: leo.h,v $ + $Revision: 1.29 $ + $Date: 1998/12/21 07:30:15 $ + *---------------------------------------------------------------------*/ + +#ifndef _LEO_H_ +#define _LEO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ +typedef u32 LEOError; + +typedef u8 LEOSpdlMode; + +typedef u8 LEOStatus; + +typedef struct +{ + u8 drive; /* version of hw */ + u8 driver; /* version of sw */ + u8 deviceType; /* dev type, always 00 */ + u8 ndevices; /* # of devices, always 01 */ +} LEOVersion; + +typedef struct +{ + u32 startLBA; + u32 endLBA; + u32 nbytes; +} LEOCapacity; + +typedef struct +{ + u8 pad; + u8 yearhi; + u8 yearlo; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEODiskTime; + +typedef struct +{ + u64 lineNumber; + LEODiskTime time; +} LEOSerialNum; + +typedef struct +{ + u8 gameName[4]; + u8 gameVersion; + u8 diskNumber; + u8 ramUsage; + u8 diskUsage; + LEOSerialNum serialNumber; + u8 company[2]; + u8 freeArea[6]; +} LEODiskID; + +typedef struct +{ + LEOCmdHeader header; + union + { + struct + { + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; +#ifdef _LONGCMD + u32 size; +#endif + } readwrite; + struct + { + u32 lba; + } seek; + struct + { + void *buffer_pointer; + } readdiskid; + LEODiskTime time; + struct + { + u8 reserve1; + u8 reserve2; + u8 standby_time; + u8 sleep_time; + u32 reserve3; + } modeselect; + + } data; + +} LEOCmd; + + +#define _nbytes readwrite.rw_bytes +#define _result header.status + + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ +#define LEO_SW_VERSION 6 /* This will be returned by */ + /* LeoInquiry command */ + +#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR + +/* + * Drive Rom offset address + */ +#define DDROM_FONT_START 0x000a0000 +#define DDROM_WAVEDATA_START 0x00140000 + +/* + * Definition for osLeoSpdlMotor() + */ +#define ACTIVE 0 +#define STANDBY 1 +#define SLEEP 2 +#define BRAKE 4 + +#define LEO_MOTOR_ACTIVE 0 +#define LEO_MOTOR_STANDBY 1 +#define LEO_MOTOR_SLEEP 2 +#define LEO_MOTOR_BRAKE 4 + +#define NUM_LBAS 4292 /* total number of LBAs */ + +#define BLK_SIZE_ZONE0 19720 +#define BLK_SIZE_ZONE1 18360 +#define BLK_SIZE_ZONE2 17680 +#define BLK_SIZE_ZONE3 16320 +#define BLK_SIZE_ZONE4 14960 +#define BLK_SIZE_ZONE5 13600 +#define BLK_SIZE_ZONE6 12240 +#define BLK_SIZE_ZONE7 10880 +#define BLK_SIZE_ZONE8 9520 + +#define MAX_BLK_SIZE BLK_SIZE_ZONE0 +#define MIN_BLK_SIZE BLK_SIZE_ZONE8 + +/* + * Error codes + */ +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_DRIVE_NOT_READY 1 +#define LEO_ERROR_DIAGNOSTIC_FAILURE 2 +#define LEO_ERROR_COMMAND_PHASE_ERROR 3 +#define LEO_ERROR_DATA_PHASE_ERROR 4 +#define LEO_ERROR_REAL_TIME_CLOCK_FAILURE 5 +#define LEO_ERROR_BUSY 8 +#define LEO_ERROR_INCOMPATIBLE_MEDIUM_INSTALLED 11 +#define LEO_ERROR_UNKNOWN_FORMAT 11 +#define LEO_ERROR_NO_SEEK_COMPLETE 21 +#define LEO_ERROR_WRITE_FAULT 22 +#define LEO_ERROR_UNRECOVERED_READ_ERROR 23 +#define LEO_ERROR_NO_REFERENCE_POSITION_FOUND 24 +#define LEO_ERROR_TRACK_FOLLOWING_ERROR 25 +#define LEO_ERROR_TRACKING_OR_SPDL_SERVO_FAILURE 25 +#define LEO_ERROR_INVALID_COMMAND_OPERATION_CODE 31 +#define LEO_ERROR_LBA_OUT_OF_RANGE 32 +#define LEO_ERROR_WRITE_PROTECT_ERROR 33 +#define LEO_ERROR_COMMAND_CLEARED_BY_HOST 34 +#define LEO_ERROR_COMMAND_TERMINATED 34 +#define LEO_ERROR_QUEUE_FULL 35 +#define LEO_ERROR_ILLEGAL_TIMER_VALUE 36 +#define LEO_ERROR_WAITING_NMI 37 +#define LEO_ERROR_DEVICE_COMMUNICATION_FAILURE 41 +#define LEO_ERROR_MEDIUM_NOT_PRESENT 42 +#define LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED 43 +#define LEO_ERROR_RAMPACK_NOT_CONNECTED 44 +#define LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED 47 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 + +/* + * Reserved + */ +#define LEO_ERROR_NOT_BOOTED_DISK 45 +#define LEO_ERROR_DIDNOT_CHANGED_DISK_AS_EXPECTED 46 + +/* + * Error codes only used in IPL + */ +#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 +#define LEO_ERROR_DIAGNOSTIC_FAILURE_RESET 50 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESET 51 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ +#define GET_ERROR(x) ((x).header.sense) + + +/************************************************************************** + * + * Extern variables + * + */ +extern LEODiskID leoBootID; +extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ + + +/************************************************************************** + * + * Function prototypes + * + */ +/* Initialize routine */ +extern s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCJCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCACreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern u32 LeoDriveExist(void); + +/* Synchronous functions */ +extern s32 LeoClearQueue(void); +extern s32 LeoByteToLBA(s32 startLBA, u32 nbytes, s32 *lbas); +extern s32 LeoLBAToByte(s32 startLBA, u32 nLBAs, s32 *bytes); +extern s32 LeoReadCapacity(LEOCapacity *cap, s32 dir); +extern s32 LeoInquiry(LEOVersion *ver); +extern s32 LeoTestUnitReady(LEOStatus *status); + +/* Asynchronous functions */ +extern s32 LeoSpdlMotor(LEOCmd *cmdBlock, LEOSpdlMode mode, OSMesgQueue *mq); +extern s32 LeoSeek(LEOCmd *cmdBlock, u32 lba, OSMesgQueue *mq); +extern s32 LeoRezero(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoReadWrite(LEOCmd *cmdBlock, s32 direction, + u32 LBA, void *vAddr, u32 nLBAs, OSMesgQueue *mq); +extern s32 LeoReadDiskID(LEOCmd *cmdBlock, LEODiskID *vaddr, OSMesgQueue *mq); +extern s32 LeoSetRTC(LEOCmd *cmdBlock, LEODiskTime *RTCdata, OSMesgQueue *mq); +extern s32 LeoReadRTC(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoModeSelectAsync(LEOCmd *cmdBlock, u32 standby, + u32 sleep, OSMesgQueue *mq); + +/* Font routines */ +extern int LeoGetKAdr(int sjis); +extern int LeoGetAAdr(int code,int *dx,int *dy, int *cy); +extern int LeoGetAAdr2(u32 ccode,int *dx,int *dy, int *cy); + +/* Boot function */ +extern void LeoBootGame(void *entry); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_LEO_H */ diff --git a/include/PR/leoappli.h b/include/PR/leoappli.h new file mode 100644 index 000000000..619fbc083 --- /dev/null +++ b/include/PR/leoappli.h @@ -0,0 +1,274 @@ +/* + * F i l e N a m e : l e o a p p l i . h + * + **************************************************************************** + * (C) Copyright ALPS Electric Co., Ltd. 1995-1997 + **************************************************************************** + * Version + * + * ver Date + * ---- -------- + * 1.01 '97-11-18 Add MOTOR BRAKE definition for control bit. + **************************************************************************** +*/ +/*-----------------------------------*/ +/* DRIVE PARAMETER */ +/*-----------------------------------*/ +#define LEO_DISK_TYPE_MIN 0 +#define LEO_DISK_TYPE_MAX 6 + +#define LEO_LBA_MIN 0 +#define LEO_LBA_MAX 4291 + +#define LEO_LBA_ROM_TOP LEO_LBA_MIN +#define LEO_LBA_ROM_END0 1417 +#define LEO_LBA_ROM_END1 1965 +#define LEO_LBA_ROM_END2 2513 +#define LEO_LBA_ROM_END3 3061 +#define LEO_LBA_ROM_END4 3609 +#define LEO_LBA_ROM_END5 4087 +#define LEO_LBA_ROM_END6 LEO_LBA_MAX +#define LEO_LBA_RAM_TOP0 (LEO_LBA_ROM_END0+1) +#define LEO_LBA_RAM_TOP1 (LEO_LBA_ROM_END1+1) +#define LEO_LBA_RAM_TOP2 (LEO_LBA_ROM_END2+1) +#define LEO_LBA_RAM_TOP3 (LEO_LBA_ROM_END3+1) +#define LEO_LBA_RAM_TOP4 (LEO_LBA_ROM_END4+1) +#define LEO_LBA_RAM_TOP5 (LEO_LBA_ROM_END5+1) +#define LEO_LBA_RAM_TOP6 (LEO_LBA_ROM_END6+1) +#define LEO_LBA_RAM_END6 LEO_LBA_MAX + +/*-----------------------------------*/ +/* LEO FUNCTION DEFINITIONS */ +/*-----------------------------------*/ +extern void leoInitialize(OSPri PRI_WRK, OSPri PRI_INT, OSMesg *command_que_buf, u32 cmd_buff_size); +extern void leoCommand(void *CDB); +extern void LeoReset(void); +extern s32 LeoResetClear(void); + +/*-----------------------------------*/ +/* THREAD PRIORITY */ +/*-----------------------------------*/ +#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) +#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR + +/*-----------------------------------*/ +/* COMMAND CODE */ +/*-----------------------------------*/ +#define LEO_COMMAND_CLEAR_QUE 0x01 +#define LEO_COMMAND_INQUIRY 0x02 +#define LEO_COMMAND_TEST_UNIT_READY 0x03 +#define LEO_COMMAND_REZERO 0x04 +#define LEO_COMMAND_READ 0x05 +#define LEO_COMMAND_WRITE 0x06 +#define LEO_COMMAND_SEEK 0x07 +#define LEO_COMMAND_START_STOP 0x08 +#define LEO_COMMAND_READ_CAPACITY 0x09 +#define LEO_COMMAND_TRANSLATE 0x0a +#define LEO_COMMAND_MODE_SELECT 0x0b +#define LEO_COMMAND_READ_DISK_ID 0x0c +#define LEO_COMMAND_READ_TIMER 0x0d +#define LEO_COMMAND_SET_TIMER 0x0e + +/*-----------------------------------*/ +/* CONTROL BIT */ +/*-----------------------------------*/ +#define LEO_CONTROL_POST 0x80 /* ENABLE POST QUEUE */ +#define LEO_CONTROL_START 0x01 /* START COMMAND */ +#define LEO_CONTROL_STBY 0x02 /* STAND-BY MODE(NOT SLEEP MODE) */ +#define LEO_CONTROL_WRT 0x01 /* READ RE-WRITE-ABLE CAPACITY */ +#define LEO_CONTROL_TBL 0x01 /* TRANSLATE BYTE TO LBA */ +#define LEO_CONTROL_BRAKE 0x04 /* SLEEP MODE(BRAKE ON) */ + +/*-----------------------------------*/ +/* BIT FIELD PARAMETER */ +/*-----------------------------------*/ +#define LEO_TEST_UNIT_MR 0x01 /* MEDIUM REMOVED */ +#define LEO_TEST_UNIT_RE 0x02 /* HEAD RETRACTED */ +#define LEO_TEST_UNIT_SS 0x04 /* SPINDLE STOPPED */ + +/*-----------------------------------*/ +/* STATUS */ +/*-----------------------------------*/ +#define LEO_STATUS_GOOD 0x00 +#define LEO_STATUS_CHECK_CONDITION 0x02 +#define LEO_STATUS_BUSY 0x08 + +/*-----------------------------------*/ +/* SENSE CODE */ +/*-----------------------------------*/ +#define LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION 00 +#define LEO_SENSE_DRIVE_NOT_READY 01 +#define LEO_SENSE_DIAGNOSTIC_FAILURE 02 +#define LEO_SENSE_COMMAND_PHASE_ERROR 03 +#define LEO_SENSE_DATA_PHASE_ERROR 04 +#define LEO_SENSE_REAL_TIME_CLOCK_FAILURE 05 +#define LEO_SENSE_INCOMPATIBLE_MEDIUM_INSTALLED 11 +#define LEO_SENSE_UNKNOWN_FORMAT 11 +#define LEO_SENSE_NO_SEEK_COMPLETE 21 +#define LEO_SENSE_WRITE_FAULT 22 +#define LEO_SENSE_UNRECOVERED_READ_ERROR 23 +#define LEO_SENSE_NO_REFERENCE_POSITION_FOUND 24 +#define LEO_SENSE_TRACK_FOLLOWING_ERROR 25 +#define LEO_SENSE_TRACKING_OR_SPDL_SERVO_FAILURE 25 +#define LEO_SENSE_INVALID_COMMAND_OPERATION_CODE 31 +#define LEO_SENSE_LBA_OUT_OF_RANGE 32 +#define LEO_SENSE_WRITE_PROTECT_ERROR 33 +#define LEO_SENSE_COMMAND_TERMINATED 34 +#define LEO_SENSE_QUEUE_FULL 35 +#define LEO_SENSE_ILLEGAL_TIMER_VALUE 36 +#define LEO_SENSE_WAITING_NMI 37 +#define LEO_SENSE_DEVICE_COMMUNICATION_FAILURE 41 +#define LEO_SENSE_MEDIUM_NOT_PRESENT 42 +#define LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED 43 +#define LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED 47 +#define LEO_SENSE_EJECTED_ILLEGALLY_RESUME 49 + +/*-----------------------------------*/ +/* Command Block Header */ +/*-----------------------------------*/ +typedef struct{ + u8 command; + u8 reserve1; + u8 control; + u8 reserve3; + u8 status; + u8 sense; + u8 reserve6; + u8 reserve7; + OSMesgQueue *post; +} LEOCmdHeader; + +/*-----------------------------------*/ +/* CLEAR QUEUE(01H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdClearQue; + +/*-----------------------------------*/ +/* INQUIRY(02H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 dev_type; + u8 version; + u8 dev_num; + u8 leo_bios_ver; + u32 reserve5; +} LEOCmdInquiry; + +/*-----------------------------------*/ +/* TEST UNIT READY(03H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 test; + u8 reserve2; + u8 reserve3; + u8 reserve4; +} LEOCmdTestUnitReady; + +/*-----------------------------------*/ +/* REZERO(04H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdRezero; + +/*-----------------------------------*/ +/* READ(05H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; +} LEOCmdRead; + +/*-----------------------------------*/ +/* WRITE(06H) command */ +/*-----------------------------------*/ +typedef LEOCmdRead LEOCmdWrite; + +/*-----------------------------------*/ +/* SEEK(07H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; +} LEOCmdSeek; + +/*-----------------------------------*/ +/* START/STOP(08H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdStartStop; + +/*-----------------------------------*/ +/* READ CAPACITY(09H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 end_lba; + u32 capa_bytes; +} LEOCmdReadCapacity; + +/*-----------------------------------*/ +/* TRANSLATE(0AH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 in_param; + u32 out_param; +} LEOCmdTranslate; + +/*-----------------------------------*/ +/* MODE SELECT(0BH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 page_code; + u8 reserve1; + u8 standby_time; + u8 sleep_time; + u8 led_on_time; + u8 led_off_time; + u8 reserve18; + u8 reserve19; +} LEOCmdModeSelect; + +/*-----------------------------------*/ +/* READ DISK ID(0CH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + void *buffer_pointer; +} LEOCmdReadDiskId; + +/*-----------------------------------*/ +/* READ TIMER(0DH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 reserve12; + u8 reserve13; + u8 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEOCmdReadTimer; + +/*-----------------------------------*/ +/* SET TIMER(0EH) command */ +/*-----------------------------------*/ +typedef LEOCmdReadTimer LEOCmdSetTimer; + +/*-------end of leoappli.h--------------------------*/ + + diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index 3fffe9c0d..b5d636092 100644 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -1,12 +1,281 @@ -#ifndef _ULTRA64_LIBAUDIO_H_ -#define _ULTRA64_LIBAUDIO_H_ +/*==================================================================== + * libaudio.h + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ -#include "abi.h" +/************************************************************************** + * + * $Revision: 1.173 $ + * $Date: 1997/12/01 12:42:21 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/libaudio.h,v $ + * + **************************************************************************/ -typedef struct -{ - u8 *offset; - s32 len; +#ifndef __LIB_AUDIO__ +#define __LIB_AUDIO__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +/*********************************************************************** + * misc defines + ***********************************************************************/ +#ifndef _EMULATOR +# ifdef AUD_PROFILE + +#define PROFILE_AUD(num, cnt, max, min) \ +{ \ + u32 currCnt = osGetCount(); \ + currCnt -= lastCnt[cnt_index]; \ + cnt_index--; \ + cnt += currCnt; \ + num++; \ + \ + if ( currCnt > max ) max = currCnt; \ + if ( currCnt < min ) min = currCnt; \ +} + +# endif /* AUD_PROFILE */ +#endif /* EMULATOR */ + +#ifndef NULL +#define NULL 0 +#endif + +#define AL_FX_BUFFER_SIZE 8192 +#define AL_FRAME_INIT -1 +#define AL_USEC_PER_FRAME 16000 +#define AL_MAX_PRIORITY 127 +#define AL_GAIN_CHANGE_TIME 1000 + +typedef s32 ALMicroTime; +typedef u8 ALPan; + +#define AL_PAN_CENTER 64 +#define AL_PAN_LEFT 0 +#define AL_PAN_RIGHT 127 +#define AL_VOL_FULL 127 +#define AL_KEY_MIN 0 +#define AL_KEY_MAX 127 +#define AL_DEFAULT_FXMIX 0 +#define AL_SUSTAIN 63 + +/*********************************************************************** + * Error handling + ***********************************************************************/ + +#ifdef _DEBUG +#define ALFailIf(condition, error) \ + if (condition) { \ + __osError(error, 0); \ + return; } + +#else +#define ALFailIf(condition, error) \ + if (condition) { \ + return; } +#endif + +#ifdef _DEBUG +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + if(flag) __osError(error, 0); \ + return; } + +#else +#define ALFlagFailIf(condition, flag, error) \ + if (condition) { \ + return; } +#endif + +/*********************************************************************** + * Audio Library global routines + ***********************************************************************/ +typedef struct ALLink_s { + struct ALLink_s *next; + struct ALLink_s *prev; +} ALLink; + +void alUnlink(ALLink *element); +void alLink(ALLink *element, ALLink *after); + +typedef s32 (*ALDMAproc)(s32 addr, s32 len, void *state); +typedef ALDMAproc (*ALDMANew)(void *state); + +void alCopy(void *src, void *dest, s32 len); + +typedef struct { + u8 *base; + u8 *cur; + s32 len; + s32 count; +} ALHeap; + +#define AL_HEAP_DEBUG 1 +#define AL_HEAP_MAGIC 0x20736a73 +#define AL_HEAP_INIT 0 + +void alHeapInit(ALHeap *hp, u8 *base, s32 len); +void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); +s32 alHeapCheck(ALHeap *hp); + +#ifdef _DEBUG +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc((u8 *) __FILE__,__LINE__,(hp),(elem),(size)) +#else +#define alHeapAlloc(hp, elem ,size) alHeapDBAlloc(0, 0,(hp),(elem),(size)) +#endif + +/*********************************************************************** + * FX Stuff + ***********************************************************************/ +#define AL_FX_NONE 0 +#define AL_FX_SMALLROOM 1 +#define AL_FX_BIGROOM 2 +#define AL_FX_CHORUS 3 +#define AL_FX_FLANGE 4 +#define AL_FX_ECHO 5 +#define AL_FX_CUSTOM 6 + +typedef u8 ALFxId; +typedef void *ALFxRef; + +/*********************************************************************** + * data structures for sound banks + ***********************************************************************/ + +#define AL_BANK_VERSION 0x4231 /* 'B1' */ + +/* Possible wavetable types */ +enum {AL_ADPCM_WAVE = 0, + AL_RAW16_WAVE}; + +typedef struct { + s32 order; + s32 npredictors; + s16 book[1]; /* Actually variable size. Must be 8-byte aligned */ +} ALADPCMBook; + +typedef struct { + u32 start; + u32 end; + u32 count; + ADPCM_STATE state; +} ALADPCMloop; + +typedef struct { + u32 start; + u32 end; + u32 count; +} ALRawLoop; + +typedef struct { + ALMicroTime attackTime; + ALMicroTime decayTime; + ALMicroTime releaseTime; + u8 attackVolume; + u8 decayVolume; +} ALEnvelope; + +typedef struct { + u8 velocityMin; + u8 velocityMax; + u8 keyMin; + u8 keyMax; + u8 keyBase; + s8 detune; +} ALKeyMap; + +typedef struct { + ALADPCMloop *loop; + ALADPCMBook *book; +} ALADPCMWaveInfo; + +typedef struct { + ALRawLoop *loop; +} ALRAWWaveInfo; + +typedef struct ALWaveTable_s { + u8 *base; /* ptr to start of wave data */ + s32 len; /* length of data in bytes */ + u8 type; /* compression type */ + u8 flags; /* offset/address flags */ + union { + ALADPCMWaveInfo adpcmWave; + ALRAWWaveInfo rawWave; + } waveInfo; +} ALWaveTable; + +typedef struct ALSound_s { + ALEnvelope *envelope; + ALKeyMap *keyMap; + ALWaveTable *wavetable; /* offset to wavetable struct */ + ALPan samplePan; + u8 sampleVolume; + u8 flags; +} ALSound; + +typedef struct { + u8 volume; /* overall volume for this instrument */ + ALPan pan; /* 0 = hard left, 127 = hard right */ + u8 priority; /* voice priority for this instrument */ + u8 flags; + u8 tremType; /* the type of tremelo osc. to use */ + u8 tremRate; /* the rate of the tremelo osc. */ + u8 tremDepth; /* the depth of the tremelo osc */ + u8 tremDelay; /* the delay for the tremelo osc */ + u8 vibType; /* the type of tremelo osc. to use */ + u8 vibRate; /* the rate of the tremelo osc. */ + u8 vibDepth; /* the depth of the tremelo osc */ + u8 vibDelay; /* the delay for the tremelo osc */ + s16 bendRange; /* pitch bend range in cents */ + s16 soundCount; /* number of sounds in this array */ + ALSound *soundArray[1]; +} ALInstrument; + +typedef struct ALBank_s { + s16 instCount; /* number of programs in this bank */ + u8 flags; + u8 pad; + s32 sampleRate; /* e.g. 44100, 22050, etc... */ + ALInstrument *percussion; /* default percussion for GM */ + ALInstrument *instArray[1]; /* ARRAY of instruments */ +} ALBank; + +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 bankCount; /* number of banks */ + ALBank *bankArray[1]; /* ARRAY of bank offsets */ +} ALBankFile; + +void alBnkfNew(ALBankFile *f, u8 *table); + +/*********************************************************************** + * Sequence Files + ***********************************************************************/ +#define AL_SEQBANK_VERSION 'S1' + +typedef struct { + u8 *offset; + s32 len; #ifdef VERSION_SH s8 magic[2]; // tbl: 0x0204, otherwise: 0x0203 @@ -29,20 +298,675 @@ typedef struct #endif } ALSeqData; -typedef struct -{ -#ifndef VERSION_SH - s16 revision; -#endif - s16 seqCount; +typedef struct { /* Note: sizeof won't be correct */ + s16 revision; /* format revision of this file */ + s16 seqCount; /* number of sequences */ #ifdef VERSION_SH s16 unk2; u8 *data; s32 pad[2]; #endif - ALSeqData seqArray[1]; + ALSeqData seqArray[1]; /* ARRAY of sequence info */ } ALSeqFile; -void alSeqFileNew(ALSeqFile *f, u8 *base); +void alSeqFileNew(ALSeqFile *f, u8 *base); +/*********************************************************************** + * Synthesis driver stuff + ***********************************************************************/ +typedef ALMicroTime (*ALVoiceHandler)(void *); + +typedef struct { + s32 maxVVoices; /* obsolete */ + s32 maxPVoices; + s32 maxUpdates; + s32 maxFXbusses; + void *dmaproc; + ALHeap *heap; + s32 outputRate; /* output sample rate */ + ALFxId fxType; + s32 *params; +} ALSynConfig; + +typedef struct ALPlayer_s { + struct ALPlayer_s *next; + void *clientData; /* storage for client callback */ + ALVoiceHandler handler; /* voice handler for player */ + ALMicroTime callTime; /* usec requested callback */ + s32 samplesLeft; /* usec remaining to callback */ +} ALPlayer; + +typedef struct ALVoice_s { + ALLink node; + struct PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} ALVoice; + +typedef struct ALVoiceConfig_s { + s16 priority; /* voice priority */ + s16 fxBus; /* bus assignment */ + u8 unityPitch; /* unity pitch flag */ +} ALVoiceConfig; + +typedef struct { + ALPlayer *head; /* client list head */ + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + + struct ALParam_s *paramList; + + struct ALMainBus_s *mainBus; + struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ + struct ALFilter_s *outputFilter; /* last filter in the filter chain */ + + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; /* output sample rate */ + s32 maxOutSamples; /* Maximum samples rsp can generate + at one time at output rate */ +} ALSynth; + +void alSynNew(ALSynth *s, ALSynConfig *config); +void alSynDelete(ALSynth *s); + +void alSynAddPlayer(ALSynth *s, ALPlayer *client); +void alSynRemovePlayer(ALSynth *s, ALPlayer *client); + +s32 alSynAllocVoice(ALSynth *s, ALVoice *v, ALVoiceConfig *vc); +void alSynFreeVoice(ALSynth *s, ALVoice *voice); + +void alSynStartVoice(ALSynth *s, ALVoice *voice, ALWaveTable *w); +void alSynStartVoiceParams(ALSynth *s, ALVoice *voice, ALWaveTable *w, + f32 pitch, s16 vol, ALPan pan, u8 fxmix, + ALMicroTime t); +void alSynStopVoice(ALSynth *s, ALVoice *voice); + +void alSynSetVol(ALSynth *s, ALVoice *v, s16 vol, ALMicroTime delta); +void alSynSetPitch(ALSynth *s, ALVoice *voice, f32 ratio); +void alSynSetPan(ALSynth *s, ALVoice *voice, ALPan pan); +void alSynSetFXMix(ALSynth *s, ALVoice *voice, u8 fxmix); +void alSynSetPriority(ALSynth *s, ALVoice *voice, s16 priority); +s16 alSynGetPriority(ALSynth *s, ALVoice *voice); + +ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp); +ALFxRef alSynGetFXRef(ALSynth *s, s16 bus, s16 index); +void alSynFreeFX(ALSynth *s, ALFxRef *fx); +void alSynSetFXParam(ALSynth *s, ALFxRef fx, s16 paramID, void *param); + +/*********************************************************************** + * Audio Library (AL) stuff + ***********************************************************************/ +typedef struct { + ALSynth drvr; +} ALGlobals; + +extern ALGlobals *alGlobals; + +void alInit(ALGlobals *glob, ALSynConfig *c); +void alClose(ALGlobals *glob); + +Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); + +/*********************************************************************** + * Sequence Player stuff + ***********************************************************************/ + +/* + * Play states + */ +#define AL_STOPPED 0 +#define AL_PLAYING 1 +#define AL_STOPPING 2 + +#define AL_DEFAULT_PRIORITY 5 +#define AL_DEFAULT_VOICE 0 +#define AL_MAX_CHANNELS 16 + +/* + * Audio Library event type definitions + */ +enum ALMsg { + AL_SEQ_REF_EVT, /* Reference to a pending event in the sequence. */ + AL_SEQ_MIDI_EVT, + AL_SEQP_MIDI_EVT, + AL_TEMPO_EVT, + AL_SEQ_END_EVT, + AL_NOTE_END_EVT, + AL_SEQP_ENV_EVT, + AL_SEQP_META_EVT, + AL_SEQP_PROG_EVT, + AL_SEQP_API_EVT, + AL_SEQP_VOL_EVT, + AL_SEQP_LOOP_EVT, + AL_SEQP_PRIORITY_EVT, + AL_SEQP_SEQ_EVT, + AL_SEQP_BANK_EVT, + AL_SEQP_PLAY_EVT, + AL_SEQP_STOP_EVT, + AL_SEQP_STOPPING_EVT, + AL_TRACK_END, + AL_CSP_LOOPSTART, + AL_CSP_LOOPEND, + AL_CSP_NOTEOFF_EVT, + AL_TREM_OSC_EVT, + AL_VIB_OSC_EVT +}; + +/* + * Midi event definitions + */ +#define AL_EVTQ_END 0x7fffffff + +enum AL_MIDIstatus { + /* For distinguishing channel number from status */ + AL_MIDI_ChannelMask = 0x0F, + AL_MIDI_StatusMask = 0xF0, + + /* Channel voice messages */ + AL_MIDI_ChannelVoice = 0x80, + AL_MIDI_NoteOff = 0x80, + AL_MIDI_NoteOn = 0x90, + AL_MIDI_PolyKeyPressure = 0xA0, + AL_MIDI_ControlChange = 0xB0, + AL_MIDI_ChannelModeSelect = 0xB0, + AL_MIDI_ProgramChange = 0xC0, + AL_MIDI_ChannelPressure = 0xD0, + AL_MIDI_PitchBendChange = 0xE0, + + /* System messages */ + AL_MIDI_SysEx = 0xF0, /* System Exclusive */ + + /* System common */ + AL_MIDI_SystemCommon = 0xF1, + AL_MIDI_TimeCodeQuarterFrame = 0xF1, + AL_MIDI_SongPositionPointer = 0xF2, + AL_MIDI_SongSelect = 0xF3, + AL_MIDI_Undefined1 = 0xF4, + AL_MIDI_Undefined2 = 0xF5, + AL_MIDI_TuneRequest = 0xF6, + AL_MIDI_EOX = 0xF7, /* End of System Exclusive */ + + /* System real time */ + AL_MIDI_SystemRealTime = 0xF8, + AL_MIDI_TimingClock = 0xF8, + AL_MIDI_Undefined3 = 0xF9, + AL_MIDI_Start = 0xFA, + AL_MIDI_Continue = 0xFB, + AL_MIDI_Stop = 0xFC, + AL_MIDI_Undefined4 = 0xFD, + AL_MIDI_ActiveSensing = 0xFE, + AL_MIDI_SystemReset = 0xFF, + AL_MIDI_Meta = 0xFF /* MIDI Files only */ +}; + +enum AL_MIDIctrl { + AL_MIDI_VOLUME_CTRL = 0x07, + AL_MIDI_PAN_CTRL = 0x0A, + AL_MIDI_PRIORITY_CTRL = 0x10, /* use general purpose controller for priority */ + AL_MIDI_FX_CTRL_0 = 0x14, + AL_MIDI_FX_CTRL_1 = 0x15, + AL_MIDI_FX_CTRL_2 = 0x16, + AL_MIDI_FX_CTRL_3 = 0x17, + AL_MIDI_FX_CTRL_4 = 0x18, + AL_MIDI_FX_CTRL_5 = 0x19, + AL_MIDI_FX_CTRL_6 = 0x1A, + AL_MIDI_FX_CTRL_7 = 0x1B, + AL_MIDI_FX_CTRL_8 = 0x1C, + AL_MIDI_FX_CTRL_9 = 0x1D, + AL_MIDI_SUSTAIN_CTRL = 0x40, + AL_MIDI_FX1_CTRL = 0x5B, + AL_MIDI_FX3_CTRL = 0x5D +}; + +enum AL_MIDImeta { + AL_MIDI_META_TEMPO = 0x51, + AL_MIDI_META_EOT = 0x2f +}; + + +#define AL_CMIDI_BLOCK_CODE 0xFE +#define AL_CMIDI_LOOPSTART_CODE 0x2E +#define AL_CMIDI_LOOPEND_CODE 0x2D +#define AL_CMIDI_CNTRL_LOOPSTART 102 +#define AL_CMIDI_CNTRL_LOOPEND 103 +#define AL_CMIDI_CNTRL_LOOPCOUNT_SM 104 +#define AL_CMIDI_CNTRL_LOOPCOUNT_BIG 105 + +typedef struct { + u8 *curPtr; /* ptr to the next event */ + s32 lastTicks; /* sequence clock ticks (used by alSeqSetLoc) */ + s32 curTicks; /* sequence clock ticks of next event (used by loop end test) */ + s16 lastStatus; /* the last status msg */ +} ALSeqMarker; + +typedef struct { + s32 ticks; /* MIDI, Tempo and End events must start with ticks */ + u8 status; + u8 byte1; + u8 byte2; + u32 duration; +} ALMIDIEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; + u8 byte1; + u8 byte2; + u8 byte3; +} ALTempoEvent; + +typedef struct { + s32 ticks; + u8 status; + u8 type; + u8 len; +} ALEndEvent; + +typedef struct { + struct ALVoice_s *voice; +} ALNoteEvent; + +typedef struct { + struct ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} ALVolumeEvent; + +typedef struct { + s16 vol; +} ALSeqpVolEvent; + +typedef struct { + ALSeqMarker *start; + ALSeqMarker *end; + s32 count; +} ALSeqpLoopEvent; + +typedef struct { + u8 chan; + u8 priority; +} ALSeqpPriorityEvent; + +typedef struct { + void *seq; /* pointer to a seq (could be an ALSeq or an ALCSeq). */ +} ALSeqpSeqEvent; + +typedef struct { + ALBank *bank; +} ALSeqpBankEvent; + +typedef struct { + struct ALVoiceState_s *vs; + void *oscState; + u8 chan; +} ALOscEvent; + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + ALNoteEvent note; + ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + ALOscEvent osc; + } msg; +} ALEvent; + +typedef struct { + ALLink node; + ALMicroTime delta; + ALEvent evt; +} ALEventListItem; + +typedef struct { + ALLink freeList; + ALLink allocList; + s32 eventCount; +} ALEventQueue; + +void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, + s32 itemCount); +ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); +void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, + ALMicroTime delta); +void alEvtqFlush(ALEventQueue *evtq); +void alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +#define AL_PHASE_ATTACK 0 +#define AL_PHASE_NOTEON 0 +#define AL_PHASE_DECAY 1 +#define AL_PHASE_SUSTAIN 2 +#define AL_PHASE_RELEASE 3 +#define AL_PHASE_SUSTREL 4 + +typedef struct ALVoiceState_s { + struct ALVoiceState_s *next;/* MUST be first */ + ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ +} ALVoiceState; + +typedef struct { + ALInstrument *instrument; /* instrument assigned to this chan */ + s16 bendRange; /* pitch bend range in cents */ + ALFxId fxId; /* type of fx assigned to this chan */ + ALPan pan; /* overall pan for this chan */ + u8 priority; /* priority for this chan */ + u8 vol; /* current volume for this chan */ + u8 fxmix; /* current fx mix for this chan */ + u8 sustain; /* current sustain pedal state */ + f32 pitchBend; /* current pitch bend val in cents */ +} ALChanState; + +typedef struct ALSeq_s { + u8 *base; /* ptr to start of sequence file */ + u8 *trackStart; /* ptr to first MIDI event */ + u8 *curPtr; /* ptr to next event to read */ + s32 lastTicks; /* MIDI ticks for last event */ + s32 len; /* length of sequence in bytes */ + f32 qnpt; /* qrter notes / tick (1/division) */ + s16 division; /* ticks per quarter note */ + s16 lastStatus; /* for running status */ +} ALSeq; + +typedef struct { + u32 trackOffset[16]; + u32 division; +} ALCMidiHdr; + +typedef struct ALCSeq_s { + ALCMidiHdr *base; /* ptr to start of sequence file */ + u32 validTracks; /* set of flags, showing valid tracks */ + f32 qnpt; /* qrter notes / tick (1/division) */ + u32 lastTicks; /* keep track of ticks incase app wants */ + u32 lastDeltaTicks; /* number of delta ticks of last event */ + u32 deltaFlag; /* flag: set if delta's not subtracted */ + u8 *curLoc[16]; /* ptr to current track location, */ + /* may point to next event, or may point */ + /* to a backup code */ + u8 *curBUPtr[16]; /* ptr to next event if in backup mode */ + u8 curBULen[16]; /* if > 0, then in backup mode */ + u8 lastStatus[16]; /* for running status */ + u32 evtDeltaTicks[16]; /* delta time to next event */ +} ALCSeq; + +typedef struct { + u32 validTracks; + s32 lastTicks; + u32 lastDeltaTicks; + u8 *curLoc[16]; + u8 *curBUPtr[16]; + u8 curBULen[16]; + u8 lastStatus[16]; + u32 evtDeltaTicks[16]; +} ALCSeqMarker; + +#define NO_SOUND_ERR_MASK 0x01 +#define NOTE_OFF_ERR_MASK 0x02 +#define NO_VOICE_ERR_MASK 0x04 + +typedef struct { + s32 maxVoices; /* max number of voices to alloc */ + s32 maxEvents; /* max internal events to support */ + u8 maxChannels; /* max MIDI channels to support (16)*/ + u8 debugFlags; /* control which error get reported */ + ALHeap *heap; /* ptr to initialized heap */ + void *initOsc; + void *updateOsc; + void *stopOsc; +} ALSeqpConfig; + +typedef ALMicroTime (*ALOscInit)(void **oscState,f32 *initVal, u8 oscType, + u8 oscRate, u8 oscDepth, u8 oscDelay); +typedef ALMicroTime (*ALOscUpdate)(void *oscState, f32 *updateVal); +typedef void (*ALOscStop)(void *oscState); + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + ALVoiceState *vAllocHead; /* list head for allocated voices */ + ALVoiceState *vAllocTail; /* list tail for allocated voices */ + ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; +} ALCSPlayer; + +/* + * Sequence data representation routines + */ +void alSeqNew(ALSeq *seq, u8 *ptr, s32 len); +void alSeqNextEvent(ALSeq *seq, ALEvent *event); +s32 alSeqGetTicks(ALSeq *seq); +f32 alSeqTicksToSec(ALSeq *seq, s32 ticks, u32 tempo); +u32 alSeqSecToTicks(ALSeq *seq, f32 sec, u32 tempo); +void alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); +void alSeqSetLoc(ALSeq *seq, ALSeqMarker *marker); +void alSeqGetLoc(ALSeq *seq, ALSeqMarker *marker); +/* + * Compact Sequence data representation routines + */ +void alCSeqNew(ALCSeq *seq, u8 *ptr); +void alCSeqNextEvent(ALCSeq *seq,ALEvent *evt); +s32 alCSeqGetTicks(ALCSeq *seq); +f32 alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo); +u32 alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo); +void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); +void alCSeqSetLoc(ALCSeq *seq, ALCSeqMarker *marker); +void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *marker); + +/* + * Sequence Player routines + */ +f32 alCents2Ratio(s32 cents); + +void alSeqpNew(ALSeqPlayer *seqp, ALSeqpConfig *config); +void alSeqpDelete(ALSeqPlayer *seqp); +void alSeqpSetSeq(ALSeqPlayer *seqp, ALSeq *seq); +ALSeq *alSeqpGetSeq(ALSeqPlayer *seqp); +void alSeqpPlay(ALSeqPlayer *seqp); +void alSeqpStop(ALSeqPlayer *seqp); +s32 alSeqpGetState(ALSeqPlayer *seqp); +void alSeqpSetBank(ALSeqPlayer *seqp, ALBank *b); +void alSeqpSetTempo(ALSeqPlayer *seqp, s32 tempo); +s32 alSeqpGetTempo(ALSeqPlayer *seqp); +s16 alSeqpGetVol(ALSeqPlayer *seqp); /* Master volume control */ +void alSeqpSetVol(ALSeqPlayer *seqp, s16 vol); +void alSeqpLoop(ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + +void alSeqpSetChlProgram(ALSeqPlayer *seqp, u8 chan, u8 prog); +s32 alSeqpGetChlProgram(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlFXMix(ALSeqPlayer *seqp, u8 chan, u8 fxmix); +u8 alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlVol(ALSeqPlayer *seqp, u8 chan, u8 vol); +u8 alSeqpGetChlVol(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPan(ALSeqPlayer *seqp, u8 chan, ALPan pan); +ALPan alSeqpGetChlPan(ALSeqPlayer *seqp, u8 chan); +void alSeqpSetChlPriority(ALSeqPlayer *seqp, u8 chan, u8 priority); +u8 alSeqpGetChlPriority(ALSeqPlayer *seqp, u8 chan); +void alSeqpSendMidi(ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alSeqpSetProgram alSeqpSetChlProgram +#define alSeqpGetProgram alSeqpGetChlProgram +#define alSeqpSetFXMix alSeqpSetChlFXMix +#define alSeqpGetFXMix alSeqpGetChlFXMix +#define alSeqpSetPan alSeqpSetChlPan +#define alSeqpGetPan alSeqpGetChlPan +#define alSeqpSetChannelPriority alSeqpSetChlPriority +#define alSeqpGetChannelPriority alSeqpGetChlPriority + + + +/* + * Compressed Sequence Player routines + */ +void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); +void alCSPDelete(ALCSPlayer *seqp); +void alCSPSetSeq(ALCSPlayer *seqp, ALCSeq *seq); +ALCSeq *alCSPGetSeq(ALCSPlayer *seqp); +void alCSPPlay(ALCSPlayer *seqp); +void alCSPStop(ALCSPlayer *seqp); +s32 alCSPGetState(ALCSPlayer *seqp); +void alCSPSetBank(ALCSPlayer *seqp, ALBank *b); +void alCSPSetTempo(ALCSPlayer *seqp, s32 tempo); +s32 alCSPGetTempo(ALCSPlayer *seqp); +s16 alCSPGetVol(ALCSPlayer *seqp); +void alCSPSetVol(ALCSPlayer *seqp, s16 vol); + +void alCSPSetChlProgram(ALCSPlayer *seqp, u8 chan, u8 prog); +s32 alCSPGetChlProgram(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlFXMix(ALCSPlayer *seqp, u8 chan, u8 fxmix); +u8 alCSPGetChlFXMix(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPan(ALCSPlayer *seqp, u8 chan, ALPan pan); +ALPan alCSPGetChlPan(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlVol(ALCSPlayer *seqp, u8 chan, u8 vol); +u8 alCSPGetChlVol(ALCSPlayer *seqp, u8 chan); +void alCSPSetChlPriority(ALCSPlayer *seqp, u8 chan, u8 priority); +u8 alCSPGetChlPriority(ALCSPlayer *seqp, u8 chan); +void alCSPSendMidi(ALCSPlayer *seqp, s32 ticks, u8 status, + u8 byte1, u8 byte2); + + +/* Maintain backwards compatibility with old routine names. */ +#define alCSPSetProgram alCSPSetChlProgram +#define alCSPGetProgram alCSPGetChlProgram +#define alCSPSetFXMix alCSPSetChlFXMix +#define alCSPGetFXMix alCSPGetChlFXMix +#define alCSPSetPan alCSPSetChlPan +#define alCSPGetPan alCSPGetChlPan +#define alCSPSetChannelPriority alCSPSetChlPriority +#define alCSPGetChannelPriority alCSPGetChlPriority + + + +/*********************************************************************** + * Sound Player stuff + ***********************************************************************/ + +typedef struct { + s32 maxSounds; + s32 maxEvents; + ALHeap *heap; +} ALSndpConfig; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + ALEvent nextEvent; + ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} ALSndPlayer; + +typedef s16 ALSndId; + +void alSndpNew(ALSndPlayer *sndp, ALSndpConfig *c); +void alSndpDelete(ALSndPlayer *sndp); + +ALSndId alSndpAllocate(ALSndPlayer *sndp, ALSound *sound); +void alSndpDeallocate(ALSndPlayer *sndp, ALSndId id); + +void alSndpSetSound(ALSndPlayer *sndp, ALSndId id); +ALSndId alSndpGetSound(ALSndPlayer *sndp); + +void alSndpPlay(ALSndPlayer *sndp); +void alSndpPlayAt(ALSndPlayer *sndp, ALMicroTime delta); +void alSndpStop(ALSndPlayer *sndp); + +void alSndpSetVol(ALSndPlayer *sndp, s16 vol); +void alSndpSetPitch(ALSndPlayer *sndp, f32 pitch); +void alSndpSetPan(ALSndPlayer *sndp, ALPan pan); +void alSndpSetPriority(ALSndPlayer *sndp, ALSndId id, u8 priority); + +void alSndpSetFXMix(ALSndPlayer *sndp, u8 mix); +s32 alSndpGetState(ALSndPlayer *sndp); + +#ifndef _FINALROM +void alParseAbiCL(Acmd *cmdList, u32 nbytes); #endif +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !__LIB_AUDIO__ */ + + + diff --git a/include/PR/libultra.h b/include/PR/libultra.h deleted file mode 100644 index f0dab415f..000000000 --- a/include/PR/libultra.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _LIBULTRA_H -#define _LIBULTRA_H - -#define TV_TYPE_NTSC 1 -#define TV_TYPE_PAL 0 -#define TV_TYPE_MPAL 2 - -#define RESET_TYPE_COLD_RESET 0 -#define RESET_TYPE_NMI 1 -#define RESET_TYPE_BOOT_DISK 2 - -extern u32 osTvType; -extern u32 osRomBase; -extern u32 osResetType; -extern u32 osMemSize; -extern u8 osAppNmiBuffer[64]; - -#endif /* _LIBULTRA_H */ diff --git a/include/PR/mbi.h b/include/PR/mbi.h index 6b3cebfe4..ac900a549 100644 --- a/include/PR/mbi.h +++ b/include/PR/mbi.h @@ -1,8 +1,6 @@ #ifndef _MBI_H_ #define _MBI_H_ -#include "platform_info.h" - /************************************************************************** * * * Copyright (C) 1994, Silicon Graphics, Inc. * @@ -19,7 +17,7 @@ * * $Revision: 1.136 $ * $Date: 1999/01/05 13:04:00 $ - * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/mbi.h,v $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/mbi.h,v $ * **************************************************************************/ diff --git a/include/PR/n_libaudio.h b/include/PR/n_libaudio.h new file mode 100644 index 000000000..90ac3144c --- /dev/null +++ b/include/PR/n_libaudio.h @@ -0,0 +1,352 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_LIBAUDIO__ +#define __N_LIBAUDIO__ + +#include + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + + +/* + * Synthesis driver stuff + */ +typedef struct N_ALVoice_s { + ALLink node; + struct N_PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} N_ALVoice; + +typedef struct { + ALPlayer *head; /* client list head */ + ALPlayer *n_seqp1; /* for fade in / fade out */ + ALPlayer *n_seqp2; + ALPlayer *n_sndp; + + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + struct ALParam_s *paramList; + struct N_ALMainBus_s *mainBus; + struct N_ALAuxBus_s *auxBus; + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; + s32 maxOutSamples; + s32 sv_dramout; + s32 sv_first; +} N_ALSynth; + + +void n_alSynAddPlayer(ALPlayer *client); +void n_alSynAddSndPlayer(ALPlayer *client); +void n_alSynAddSeqPlayer(ALPlayer *client); + +ALFxRef n_alSynAllocFX( s16 bus,ALSynConfig *c, ALHeap *hp); +s32 n_alSynAllocVoice( N_ALVoice *voice, ALVoiceConfig *vc); + + +void n_alSynFreeVoice(N_ALVoice *voice); +ALFxRef n_alSynGetFXRef( s16 bus, s16 index); +s16 n_alSynGetPriority( N_ALVoice *voice); +void n_alSynRemovePlayer( ALPlayer *client); +void n_alSynSetFXMix(N_ALVoice *v, u8 fxmix); +void n_alSynSetFXParam(ALFxRef fx, s16 paramID, void *param); +void n_alSynFreeFX(ALFxRef *fx); +void n_alSynSetPan(N_ALVoice *v, u8 pan); +void n_alSynSetPitch( N_ALVoice *v, f32 pitch); +void n_alSynSetPriority( N_ALVoice *voice, s16 priority); +void n_alSynSetVol( N_ALVoice *v, s16 volume, ALMicroTime t); +void n_alSynStartVoice(N_ALVoice *v, ALWaveTable *table); +void n_alSynStartVoiceParams(N_ALVoice *v, ALWaveTable *w,f32 pitch, s16 vol, + ALPan pan, u8 fxmix, ALMicroTime t); +void n_alSynStopVoice( N_ALVoice *v); + +void n_alSynNew(ALSynConfig *c); +void n_alSynDelete(void); + + +/* + * Audio Library (AL) stuff + */ +typedef struct { + N_ALSynth drvr; +} N_ALGlobals; + +extern N_ALGlobals *n_alGlobals; +extern N_ALSynth *n_syn; + +void n_alInit(N_ALGlobals *g, ALSynConfig *c); +void n_alClose(N_ALGlobals *glob); +Acmd *n_alAudioFrame(Acmd *cmdList, s32 *cmdLen, + s16 *outBuf, s32 outLen); + + +/* + * Sequence Player stuff + */ +typedef struct { + struct N_ALVoice_s *voice; +} N_ALNoteEvent; + + +typedef struct { + struct N_ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} N_ALVolumeEvent; + + +typedef struct { + struct N_ALVoiceState_s *vs; + void *oscState; + u8 chan; +} N_ALOscEvent; + + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + N_ALNoteEvent note; + N_ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + N_ALOscEvent osc; + } msg; +} N_ALEvent; + + +typedef struct { + ALLink node; + ALMicroTime delta; + N_ALEvent evt; +} N_ALEventListItem; + +void n_alEvtqNew(ALEventQueue *evtq, N_ALEventListItem *items, s32 itemCount); +ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, N_ALEvent *evt); +void n_alEvtqPostEvent(ALEventQueue *evtq, N_ALEvent *evt, ALMicroTime delta); +void n_alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +typedef struct N_ALVoiceState_s { + struct N_ALVoiceState_s *next;/* MUST be first */ + N_ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ +} N_ALVoiceState; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} N_ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; +} N_ALCSPlayer; + + +/* + * Sequence data representation routines + */ +void n_alSeqNextEvent(ALSeq *seq, N_ALEvent *event); +void n_alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); + +void n_alCSeqNew(ALCSeq *seq, u8 *ptr); +void n_alCSeqNextEvent(ALCSeq *seq, N_ALEvent *evt); +void n_alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); + + +/* + * Sequence Player routines + */ +void n_alSeqpNew(N_ALSeqPlayer *seqp, ALSeqpConfig *config); +void n_alSeqpDelete(N_ALSeqPlayer *seqp); +u8 n_alSeqpGetChlVol(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlFXMix(N_ALSeqPlayer *seqp, u8 chan); +ALPan n_alSeqpGetChlPan(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlPriority(N_ALSeqPlayer *seqp, u8 chan); +s32 n_alSeqpGetChlProgram(N_ALSeqPlayer *seqp, u8 chan); +ALSeq *n_alSeqpGetSeq(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetState(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetTempo(N_ALSeqPlayer *seqp); +s16 n_alSeqpGetVol(N_ALSeqPlayer *seqp); /* Master volume control */ +void n_alSeqpPlay(N_ALSeqPlayer *seqp); +void n_alSeqpSendMidi(N_ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alSeqpSetBank(N_ALSeqPlayer *seqp, ALBank *b); +void n_alSeqpSetChlVol(N_ALSeqPlayer *seqp, u8 chan, u8 vol); +void n_alSeqpSetChlFXMix(N_ALSeqPlayer *seqp, u8 chan, u8 fxmix); +void n_alSeqpSetChlPan(N_ALSeqPlayer *seqp, u8 chan, ALPan pan); +void n_alSeqpSetChlPriority(N_ALSeqPlayer *seqp, u8 chan, u8 priority); +void n_alSeqpSetChlProgram(N_ALSeqPlayer *seqp, u8 chan, u8 prog); +void n_alSeqpSetSeq(N_ALSeqPlayer *seqp, ALSeq *seq); +void n_alSeqpSetTempo(N_ALSeqPlayer *seqp, s32 tempo); +void n_alSeqpSetVol(N_ALSeqPlayer *seqp, s16 vol); +void n_alSeqpStop(N_ALSeqPlayer *seqp); +void n_alSeqpLoop(N_ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + + +/* + * Compressed Sequence Player routines + */ +void n_alCSPNew(N_ALCSPlayer *seqp, ALSeqpConfig *config); +void n_alCSPDelete(N_ALCSPlayer *seqp); +u8 n_alCSPGetChlVol(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlFXMix(N_ALCSPlayer *seqp, u8 chan); +ALPan n_alCSPGetChlPan(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlPriority(N_ALCSPlayer *seqp, u8 chan); +s32 n_alCSPGetChlProgram(N_ALCSPlayer *seqp, u8 chan); +ALCSeq *n_alCSPGetSeq(N_ALCSPlayer *seqp); +s32 n_alCSPGetState(N_ALCSPlayer *seqp); +s32 n_alCSPGetTempo(N_ALCSPlayer *seqp); +s16 n_alCSPGetVol(N_ALCSPlayer *seqp); +void n_alCSPPlay(N_ALCSPlayer *seqp); +void n_alCSPSendMidi(N_ALCSPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alCSPSetBank(N_ALCSPlayer *seqp, ALBank *b); +void n_alCSPSetChlVol(N_ALCSPlayer *seqp, u8 chan, u8 vol); +void n_alCSPSetChlFXMix(N_ALCSPlayer *seqp, u8 chan, u8 fxmix); +void n_alCSPSetChlPan(N_ALCSPlayer *seqp, u8 chan, ALPan pan); +void n_alCSPSetChlPriority(N_ALCSPlayer *seqp, u8 chan, u8 priority); +void n_alCSPSetChlProgram(N_ALCSPlayer *seqp, u8 chan, u8 prog); +void n_alCSPSetSeq(N_ALCSPlayer *seqp, ALCSeq *seq); +void n_alCSPSetTempo(N_ALCSPlayer *seqp, s32 tempo); +void n_alCSPSetVol(N_ALCSPlayer *seqp, s16 vol); +void n_alCSPStop(N_ALCSPlayer *seqp); + + +/* + * Sound Player stuff + */ +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + N_ALEvent nextEvent; + N_ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} N_ALSndPlayer; + +void n_alSndpNew(N_ALSndPlayer *sndp, ALSndpConfig *c); +void n_alSndpDelete(void); +ALSndId n_alSndpAllocate(ALSound *sound); +void n_alSndpDeallocate(ALSndId id); +s32 n_alSndpGetState(void); +void n_alSndpPlay(void); +void n_alSndpPlayAt(ALMicroTime delta); +void n_alSndpSetFXMix(u8 mix); +void n_alSndpSetPan(ALPan pan); +void n_alSndpSetPitch(f32 pitch); +void n_alSndpSetPriority(ALSndId id, u8 priority); +void n_alSndpSetVol(s16 vol); +void n_alSndpStop(void); +ALSndId n_alSndpGetSound(void); +void n_alSndpSetSound(ALSndId id); + + +/* + * for n_audio micro code + */ +extern long long int n_aspMainTextStart[], n_aspMainTextEnd[]; +extern long long int n_aspMainDataStart[], n_aspMainDataEnd[]; + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __N_LIBAUDIO__ */ diff --git a/include/PR/n_libaudio_s_to_n.h b/include/PR/n_libaudio_s_to_n.h new file mode 100644 index 000000000..de3e0f9cb --- /dev/null +++ b/include/PR/n_libaudio_s_to_n.h @@ -0,0 +1,120 @@ +#define ALVoice N_ALVoice +#define ALSynth N_ALSynth +#define ALGlobals N_ALGlobals + +#define alSynAddPlayer( a, b) n_alSynAddPlayer( b) +#define alSynAllocFX( a, b, c, d) n_alSynAllocFX( b, c, d) +#define alSynAllocVoice( a, b, c) n_alSynAllocVoice( b, c) +#define alSynDelete( a) n_alSynDelete() +#define alSynFreeVoice( a, b) n_alSynFreeVoice( b) +#define alSynGetFXRef( a, b, c) n_alSynGetFXRef( b, c) +#define alSynGetPriority( a, b) n_alSynGetPriority( b) +#define alSynRemovePlayer( a, b) n_alSynRemovePlayer( b) +#define alSynSetFXMix( a, b, c) n_alSynSetFXMix( b, c) +#define alSynSetFXParam( a, b, c, d) n_alSynSetFXParam( b, c, d) +#define alSynFreeFX( a, b) n_alSynFreeFX( b) +#define alSynSetPan( a, b, c) n_alSynSetPan( b, c) +#define alSynSetPitch( a, b, c) n_alSynSetPitch( b, c) +#define alSynSetPriority( a, b, c) n_alSynSetPriority( b, c) +#define alSynSetVol( a, b, c, d) n_alSynSetVol( b, c, d) +#define alSynStartVoice( a, b, c) n_alSynStartVoice( b, c) +#define alSynStartVoiceParams( a, b, c, d, e, f, g, h) \ + n_alSynStartVoiceParams( b, c, d, e, f, g, h) +#define alSynStopVoice( a, b) n_alSynStopVoice( b) +#define alSynNew( a, b) n_alSynNew( b) + +#define alInit n_alInit +#define alClose n_alClose +#define alAudioFrame n_alAudioFrame + +#define ALVoiceState N_ALVoiceState +#define ALSeqPlayer N_ALSeqPlayer +#define ALCSPlayer N_ALCSPlayer + +#define alSeqNextEvent n_alSeqNextEvent +#define alSeqNewMarker n_alSeqNewMarker + +#define alCSeqNew n_alCSeqNew +#define alCSeqNextEvent n_alCSeqNextEvent +#define alCSeqNewMarker n_alCSeqNewMarker + +#define alSeqpNew n_alSeqpNew +#define alSeqpDelete n_alSeqpDelete +#define alSeqpGetChlVol n_alSeqpGetChlVol +#define alSeqpGetChlFXMix n_alSeqpGetChlFXMix +#define alSeqpGetChlPan n_alSeqpGetChlPan +#define alSeqpGetChlPriority n_alSeqpGetChlPriority +#define alSeqpGetChlProgram n_alSeqpGetChlProgram +#define alSeqpGetSeq n_alSeqpGetSeq +#define alSeqpGetState n_alSeqpGetState +#define alSeqpGetTempo n_alSeqpGetTempo +#define alSeqpGetVol n_alSeqpGetVol +#define alSeqpPlay n_alSeqpPlay +#define alSeqpSendMidi n_alSeqpSendMidi +#define alSeqpSetBank n_alSeqpSetBank +#define alSeqpSetChlVol n_alSeqpSetChlVol +#define alSeqpSetChlFXMix n_alSeqpSetChlFXMix +#define alSeqpSetChlPan n_alSeqpSetChlPan +#define alSeqpSetChlPriority n_alSeqpSetChlPriority +#define alSeqpSetChlProgram n_alSeqpSetChlProgram +#define alSeqpSetSeq n_alSeqpSetSeq +#define alSeqpSetTempo n_alSeqpSetTempo +#define alSeqpSetVol n_alSeqpSetVol +#define alSeqpStop n_alSeqpStop +#define alSeqpLoop n_alSeqpLoop + +#define alCSPNew n_alCSPNew +#define alCSPDelete n_alCSPDelete +#define alCSPGetChlVol n_alCSPGetChlVol +#define alCSPGetChlFXMix n_alCSPGetChlFXMix +#define alCSPGetChlPan n_alCSPGetChlPan +#define alCSPGetChlPriority n_alCSPGetChlPriority +#define alCSPGetChlProgram n_alCSPGetChlProgram +#define alCSPGetSeq n_alCSPGetSeq +#define alCSPGetState n_alCSPGetState +#define alCSPGetTempo n_alCSPGetTempo +#define alCSPGetVol n_alCSPGetVol +#define alCSPPlay n_alCSPPlay +#define alCSPSendMidi n_alCSPSendMidi +#define alCSPSetBank n_alCSPSetBank +#define alCSPSetChlVol n_alCSPSetChlVol +#define alCSPSetChlFXMix n_alCSPSetChlFXMix +#define alCSPSetChlPan n_alCSPSetChlPan +#define alCSPSetChlPriority n_alCSPSetChlPriority +#define alCSPSetChlProgram n_alCSPSetChlProgram +#define alCSPSetSeq n_alCSPSetSeq +#define alCSPSetTempo n_alCSPSetTempo +#define alCSPSetVol n_alCSPSetVol +#define alCSPStop n_alCSPStop + +#define ALSoundState N_ALSoundState +#define ALSndpEvent N_ALSndpEvent +#define ALSndPlayer N_ALSndPlayer + +#define alSndpNew( a, b) n_alSndpNew( a, b) +#define alSndpDelete( a) n_alSndpDelete() +#define alSndpAllocate( a, b) n_alSndpAllocate( b) +#define alSndpDeallocate( a, b) n_alSndpDeallocate( b) +#define alSndpGetState( a) n_alSndpGetState() +#define alSndpPlay( a) n_alSndpPlay() +#define alSndpPlayAt( a, b) n_alSndpPlayAt( b) +#define alSndpSetFXMix( a, b) n_alSndpSetFXMix( b) +#define alSndpSetPan( a, b) n_alSndpSetPan( b) +#define alSndpSetPitch( a, b) n_alSndpSetPitch( b) +#define alSndpSetPriority( a, b, c) n_alSndpSetPriority( b, c) +#define alSndpSetVol( a, b) n_alSndpSetVol( b) +#define alSndpStop( a) n_alSndpStop() +#define alSndpGetSound( a) n_alSndpGetSound() +#define alSndpSetSound( a, b) n_alSndpSetSound( b) + +#define alEvtqNew n_alEvtqNew +#define alEvtqNextEvent n_alEvtqNextEvent +#define alEvtqPostEvent n_alEvtqPostEvent +#define alEvtqFlushType n_alEvtqFlushType +#define alEvtqPrintEvtQueue n_alEvtqPrintEvtQueue +#define alEvtqPrintAllocEvts n_alEvtqPrintAllocEvts + + + + + diff --git a/include/PR/os.h b/include/PR/os.h new file mode 100644 index 000000000..4b52dfb2c --- /dev/null +++ b/include/PR/os.h @@ -0,0 +1,108 @@ + +/*==================================================================== + * os.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os.h,v $ + $Revision: 1.168 $ + $Date: 2000/06/15 06:24:52 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_H_ +#define _OS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), + * SIM (SI Manager) + * + */ +#define OS_PIM_STACKSIZE 4096 +#define OS_VIM_STACKSIZE 4096 +#define OS_SIM_STACKSIZE 4096 + +#define OS_MIN_STACKSIZE 72 + +/* + * Leo Disk + */ + +/* transfer mode */ + +#define LEO_BLOCK_MODE 1 +#define LEO_TRACK_MODE 2 +#define LEO_SECTOR_MODE 3 + +/* + * Boot addresses + */ +#define BOOT_ADDRESS_ULTRA 0x80000400 +#define BOOT_ADDRESS_COSIM 0x80002000 +#define BOOT_ADDRESS_EMU 0x20010000 +#define BOOT_ADDRESS_INDY 0x88100000 + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/include/PR/os_cache.h b/include/PR/os_cache.h index 93d53c5f1..54ed92300 100644 --- a/include/PR/os_cache.h +++ b/include/PR/os_cache.h @@ -81,9 +81,9 @@ extern "C" { /* Cache operations and macros */ -extern void osInvalDCache(void *, size_t); -extern void osInvalICache(void *, size_t); -extern void osWritebackDCache(void *, size_t); +extern void osInvalDCache(void *, s32); +extern void osInvalICache(void *, s32); +extern void osWritebackDCache(void *, s32); extern void osWritebackDCacheAll(void); diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h index 15ee60f3f..a2bd87073 100644 --- a/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -53,22 +53,22 @@ extern "C" { typedef struct { u16 type; /* Controller Type */ u8 status; /* Controller status */ - u8 errnum; + u8 error; }OSContStatus; typedef struct { u16 button; s8 stick_x; /* -80 <= stick_x <= 80 */ s8 stick_y; /* -80 <= stick_y <= 80 */ - u8 errnum; + u8 error; } OSContPad; typedef struct { void *address; /* Ram pad Address: 11 bits */ u8 databuffer[32]; /* address of the data buffer */ - u8 addressCrc; /* CRC code for address */ + u8 addressCrc; /* CRC code for address */ u8 dataCrc; /* CRC code for data */ - u8 errnum; + u8 error; } OSContRamIo; diff --git a/include/PR/os_convert.h b/include/PR/os_convert.h new file mode 100644 index 000000000..0a5da10a8 --- /dev/null +++ b/include/PR/os_convert.h @@ -0,0 +1,111 @@ + +/*==================================================================== + * os_convert.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_convert.h,v $ + $Revision: 1.2 $ + $Date: 1999/04/21 02:53:11 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_CONVERT_H_ +#define _OS_CONVERT_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +#define OS_CLOCK_RATE 62500000LL +#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) +#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) +#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) +#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) + +/* OS_K?_TO_PHYSICAL macro bug fix for CodeWarrior */ +#ifndef __MWERKS__ +#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) +#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) +#else +#define OS_K0_TO_PHYSICAL(x) ((char *)(x)-0x80000000) +#define OS_K1_TO_PHYSICAL(x) ((char *)(x)-0xa0000000) +#endif + +#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) +#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Address translation routines and macros */ + +extern u32 osVirtualToPhysical(void *); +extern void * osPhysicalToVirtual(u32); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_CONVERT_H_ */ diff --git a/include/PR/os_debug.h b/include/PR/os_debug.h new file mode 100644 index 000000000..076c40208 --- /dev/null +++ b/include/PR/os_debug.h @@ -0,0 +1,118 @@ + +/*==================================================================== + * os_debug.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_debug.h,v $ + $Revision: 1.4 $ + $Date: 1999/06/30 03:04:08 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_DEBUG_H_ +#define _OS_DEBUG_H_ + + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for Profiler + */ +typedef struct { + u16 *histo_base; /* histogram base */ + u32 histo_size; /* histogram size */ + u32 *text_start; /* start of text segment */ + u32 *text_end; /* end of text segment */ +} OSProf; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Profiler constants + */ +#define PROF_MIN_INTERVAL 50 /* microseconds */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Profiler Interface */ + +extern void osProfileInit(OSProf *, u32 profcnt); +extern void osProfileStart(u32); +extern void osProfileFlush(void); +extern void osProfileStop(void); + +/* Thread Profiler Interface */ +extern void osThreadProfileClear(OSId); +extern void osThreadProfileInit(void); +extern void osThreadProfileStart(void); +extern void osThreadProfileStop(void); +extern u32 osThreadProfileReadCount(OSId); +extern u32 osThreadProfileReadCountTh(OSThread*); +extern OSTime osThreadProfileReadTime(OSId); +extern OSTime osThreadProfileReadTimeTh(OSThread*); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_DEBUG_H_ */ diff --git a/include/PR/os_error.h b/include/PR/os_error.h new file mode 100644 index 000000000..f4c3b83c5 --- /dev/null +++ b/include/PR/os_error.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_error.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_error.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:06 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_ERROR_H_ +#define _OS_ERROR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_ERROR_H_ */ diff --git a/include/PR/os_flash.h b/include/PR/os_flash.h new file mode 100644 index 000000000..4e0a129b8 --- /dev/null +++ b/include/PR/os_flash.h @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_flash.h,v $ + $Revision: 1.1 $ + $Date: 2000/06/15 06:24:55 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_FLASH_H_ +#define _OS_FLASH_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* + * defines for FLASH + */ +#define FLASH_START_ADDR 0x08000000 + +#define FLASH_SIZE 0x20000 +#define FLASH_LATENCY 0x5 +#define FLASH_PULSE 0x0c +#define FLASH_PAGE_SIZE 0xf +#define FLASH_REL_DURATION 0x2 +#define DEVICE_TYPE_FLASH 8 + +#define FLASH_VERSION_MX_PROTO_A 0x00c20000 +#define FLASH_VERSION_MX_A 0x00c20001 +#define FLASH_VERSION_MX_C 0x00c2001e +#define FLASH_VERSION_MX_B_AND_D 0x00c2001d +#define FLASH_VERSION_MEI 0x003200f1 + +#define OLD_FLASH 0 +#define NEW_FLASH 1 +/* OLD_FLASH is MX_PROTO_A, MX_A and MX_C */ +/* NEW_FLASH is MX_B_AND_D and MATSUSHITA flash */ + +#define FLASH_STATUS_ERASE_BUSY 2 +#define FLASH_STATUS_ERASE_ERROR -1 +#define FLASH_STATUS_ERASE_OK 0 + +extern OSPiHandle *osFlashReInit(u8 latency, u8 pulse, + u8 page_size, u8 rel_duration, u32 start); +extern OSPiHandle *osFlashInit(void); +extern void osFlashReadStatus(u8 *flash_status); +extern void osFlashReadId(u32 *flash_type, u32 *flash_maker); +extern void osFlashClearStatus(void); +extern s32 osFlashAllErase(void); +extern s32 osFlashSectorErase(u32 page_num); +extern s32 osFlashWriteBuffer(OSIoMesg *mb, s32 priority, + void *dramAddr, OSMesgQueue *mq); +extern s32 osFlashWriteArray(u32 page_num); +extern s32 osFlashReadArray(OSIoMesg *mb, s32 priority, u32 page_num, + void *dramAddr, u32 n_pages, OSMesgQueue *mq); +extern void osFlashChange(u32 flash_num); +extern void osFlashAllEraseThrough(void); +extern void osFlashSectorEraseThrough(u32 page_num); +extern s32 osFlashCheckEraseEnd(void); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_FLASH_H_ */ diff --git a/include/PR/os_gbpak.h b/include/PR/os_gbpak.h new file mode 100644 index 000000000..0a9999450 --- /dev/null +++ b/include/PR/os_gbpak.h @@ -0,0 +1,107 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_gbpak.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:07 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_GBPAK_H_ +#define _OS_GBPAK_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" +#include "os_pfs.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef struct { + u16 fixed1; + u16 start_address; + u8 nintendo_chr[0x30]; + u8 game_title[16]; + u16 company_code; + u8 body_code; + u8 cart_type; + u8 rom_size; + u8 ram_size; + u8 country_code; + u8 fixed2; + u8 version; + u8 isum; + u16 sum; +} OSGbpakId; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* definition for 64GB-PAK */ + +#define OS_GBPAK_POWER 0x01 +#define OS_GBPAK_RSTB_DETECTION 0x04 +#define OS_GBPAK_RSTB_STATUS 0x08 +#define OS_GBPAK_GBCART_PULL 0x40 +#define OS_GBPAK_GBCART_ON 0x80 + +#define OS_GBPAK_POWER_OFF 0x00 /* power of 64GB-PAK */ +#define OS_GBPAK_POWER_ON 0x01 + +#define OS_GBPAK_ROM_ID_SIZE 0x50 /* ID size of GB cartridge */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* 64GB-PAK */ +extern s32 osGbpakInit(OSMesgQueue *, OSPfs *, int); +extern s32 osGbpakPower(OSPfs *, s32); +extern s32 osGbpakGetStatus(OSPfs *, u8 *); +extern s32 osGbpakReadWrite(OSPfs *, u16, u16, u8 *, u16); +extern s32 osGbpakReadId(OSPfs *, OSGbpakId *, u8 *); +extern s32 osGbpakCheckConnector(OSPfs *, u8 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_GBPAK_H_ */ diff --git a/include/PR/os_gio.h b/include/PR/os_gio.h new file mode 100644 index 000000000..ad3c020fa --- /dev/null +++ b/include/PR/os_gio.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_gio.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_gio.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:08 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_GIO_H_ +#define _OS_GIO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_GIO_H_ */ diff --git a/include/PR/os_host.h b/include/PR/os_host.h new file mode 100644 index 000000000..0cc1ae5b9 --- /dev/null +++ b/include/PR/os_host.h @@ -0,0 +1,161 @@ + +/*==================================================================== + * os_host.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_host.h,v $ + $Revision: 1.3 $ + $Date: 1999/06/24 09:23:06 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_HOST_H_ +#define _OS_HOST_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +extern void __osInitialize_common(void); + +#if defined(_FINALROM) + +#define osInitialize() __osInitialize_common() + +#else + +/* PARTNER-N64 */ +#if defined(PTN64) +extern void __osInitialize_kmc(void); +#define osReadHost osReadHost_pt +#define osWriteHost osWriteHost_pt +#define osInitialize() \ +{ \ + __osInitialize_common(); \ + __osInitialize_kmc(); \ +} + +/* MONEGI SMART PACK A */ +#elif defined(MWN64) +extern void __osInitialize_msp(void); +#define osReadHost osReadHost_pt +#define osWriteHost osWriteHost_pt +#define osInitialize() \ +{ \ + __osInitialize_common(); \ + __osInitialize_msp(); \ +} + +/* IS-Viewer(for Debugger) */ +#elif defined(ISV64) +extern void __osInitialize_isv(void); +#define osInitialize() \ +{ \ + __osInitialize_common(); \ + __osInitialize_isv(); \ +} + +/* Emulation board for INDY */ +#elif defined(EMU64) +extern void __osInitialize_emu(void); +#define osInitialize() \ +{ \ + __osInitialize_common(); \ + __osInitialize_emu(); \ +} + +#else +/* Default (auto detect) */ +extern void __osInitialize_autodetect(void); +extern void __osInitialize_msp(void); +extern void __osInitialize_kmc(void); +extern void __osInitialize_isv(void); +extern void __osInitialize_emu(void); +#define osInitialize() \ +{ \ + __osInitialize_common(); \ + __osInitialize_autodetect(); \ +} +#endif + +#endif /* _FINAL_ROM */ + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Game <> Host data transfer functions */ + +extern s32 osTestHost(void); +extern void osReadHost(void *, u32); +extern void osWriteHost(void *, u32); +extern void osAckRamromRead(void); +extern void osAckRamromWrite(void); + +/* RDB port operations */ + +extern void osInitRdb(u8 *sendBuf, u32 sendSize); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_HOST_H_ */ diff --git a/include/PR/os_internal.h b/include/PR/os_internal.h index 889048fb1..754d1ee29 100644 --- a/include/PR/os_internal.h +++ b/include/PR/os_internal.h @@ -1,19 +1,49 @@ -#ifndef _ULTRA64_OS_INTERNAL_H_ -#define _ULTRA64_OS_INTERNAL_H_ -#include "PR/os_message.h" +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ -/* Internal functions used by the operating system */ -/* Do not include this header in application code */ +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal.h,v $ + $Revision: 1.20 $ + $Date: 1998/10/09 08:01:09 $ + *---------------------------------------------------------------------*/ -/* Variables */ - -//extern u64 osClockRate; - -/* Functions */ - -/*u32 __osProbeTLB(void *); -u32 __osDisableInt(void); -void __osRestoreInt(u32);*/ -OSThread *__osGetCurrFaultedThread(void); +#ifndef _OS_INTERNAL_H_ +#define _OS_INTERNAL_H_ +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { #endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +#include "os_internal_reg.h" +#include "os_internal_exception.h" +#include "os_internal_tlb.h" +#include "os_internal_si.h" +#include "os_internal_rsp.h" +#include "os_internal_error.h" +#include "os_internal_gio.h" +#include "os_internal_thread.h" +#include "os_internal_debug.h" +#include "os_internal_host.h" + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_H */ diff --git a/include/PR/os_internal_debug.h b/include/PR/os_internal_debug.h new file mode 100644 index 000000000..7b307d6e3 --- /dev/null +++ b/include/PR/os_internal_debug.h @@ -0,0 +1,43 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_debug.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:09 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_DEBUG_H_ +#define _OS_INTERNAL_DEBUG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Debug port */ +extern void __osSyncPutChars(int, int, const char *); +extern int __osAtomicDec(unsigned int *p); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_DEBUG_H */ diff --git a/include/PR/os_internal_error.h b/include/PR/os_internal_error.h new file mode 100644 index 000000000..de188d239 --- /dev/null +++ b/include/PR/os_internal_error.h @@ -0,0 +1,45 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_error.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:10 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_ERROR_H_ +#define _OS_INTERNAL_ERROR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Error handling */ + +extern void __osError(s16, s16, ...); +extern OSThread * __osGetCurrFaultedThread(void); +extern OSThread * __osGetNextFaultedThread(OSThread *); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_ERROR_H */ diff --git a/include/PR/os_internal_exception.h b/include/PR/os_internal_exception.h new file mode 100644 index 000000000..730dc9352 --- /dev/null +++ b/include/PR/os_internal_exception.h @@ -0,0 +1,49 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_exception.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:10 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_EXCEPTION_H_ +#define _OS_INTERNAL_EXCEPTION_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routine for HW interrupt "handler" */ +extern void __osSetHWIntrRoutine(OSHWIntr interrupt, + s32 (*handler)(void), void *stackEnd); +extern void __osGetHWIntrRoutine(OSHWIntr interrupt, + s32 (**handler)(void), void **stackEnd); + +/* Routine for global interrupt mask */ +extern void __osSetGlobalIntMask(OSHWIntr); +extern void __osResetGlobalIntMask(OSHWIntr); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_EXCEPTION_H */ diff --git a/include/PR/os_internal_gio.h b/include/PR/os_internal_gio.h new file mode 100644 index 000000000..ff133850f --- /dev/null +++ b/include/PR/os_internal_gio.h @@ -0,0 +1,45 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_gio.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:11 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_GIO_H_ +#define _OS_INTERNAL_GIO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Development board functions */ + +extern void __osGIOInit(s32); +extern void __osGIOInterrupt(s32); +extern void __osGIORawInterrupt(s32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_GIO_H */ diff --git a/include/PR/os_internal_host.h b/include/PR/os_internal_host.h new file mode 100644 index 000000000..b6d195130 --- /dev/null +++ b/include/PR/os_internal_host.h @@ -0,0 +1,42 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_host.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:11 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_HOST_H_ +#define _OS_INTERNAL_HOST_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* routine for rdb port */ +extern u32 __osRdbSend(u8 *buf, u32 size, u32 type); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_HOST_H */ diff --git a/include/PR/os_internal_reg.h b/include/PR/os_internal_reg.h new file mode 100644 index 000000000..a16199811 --- /dev/null +++ b/include/PR/os_internal_reg.h @@ -0,0 +1,59 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_reg.h,v $ + $Revision: 1.2 $ + $Date: 1999/03/10 12:19:14 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_REG_H_ +#define _OS_INTERNAL_REG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routines to get/fetch coprocessor 0 registers */ + +extern u32 __osGetCause(void); +extern void __osSetCause(u32); +extern u32 __osGetCompare(void); +extern void __osSetCompare(u32); +extern u32 __osGetConfig(void); +extern void __osSetConfig(u32); +extern void __osSetCount(u32); +extern u32 __osGetSR(void); +extern void __osSetSR(u32); +extern u32 __osDisableInt(void); +extern void __osRestoreInt(u32); +extern u32 __osGetWatchLo(void); +extern void __osSetWatchLo(u32); + +/* Routines to get/set floating-point control and status register */ +extern u32 __osSetFpcCsr(u32); +extern u32 __osGetFpcCsr(void); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_REG_H */ diff --git a/include/PR/os_internal_rsp.h b/include/PR/os_internal_rsp.h new file mode 100644 index 000000000..646e66796 --- /dev/null +++ b/include/PR/os_internal_rsp.h @@ -0,0 +1,48 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_rsp.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:12 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_RSP_H_ +#define _OS_INTERNAL_RSP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Signal processor interface (Sp) */ + +extern u32 __osSpGetStatus(void); +extern void __osSpSetStatus(u32); +extern s32 __osSpSetPc(u32); +extern s32 __osSpRawWriteIo(u32, u32); +extern s32 __osSpRawReadIo(u32, u32 *); +extern s32 __osSpRawStartDma(s32, u32, void *, u32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_RSP_H */ diff --git a/include/PR/os_internal_si.h b/include/PR/os_internal_si.h new file mode 100644 index 000000000..d0eeedccb --- /dev/null +++ b/include/PR/os_internal_si.h @@ -0,0 +1,46 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_si.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:13 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_SI_H_ +#define _OS_INTERNAL_SI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Serial interface (Si) */ + +extern u32 __osSiGetStatus(void); +extern s32 __osSiRawWriteIo(u32, u32); +extern s32 __osSiRawReadIo(u32, u32 *); +extern s32 __osSiRawStartDma(s32, void *); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_SI_H */ diff --git a/include/PR/os_internal_thread.h b/include/PR/os_internal_thread.h new file mode 100644 index 000000000..1305eb58b --- /dev/null +++ b/include/PR/os_internal_thread.h @@ -0,0 +1,43 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_thread.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:13 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_THREAD_H_ +#define _OS_INTERNAL_THREAD_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* For debugger use */ + +extern OSThread * __osGetActiveQueue(void); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_THREAD_H */ diff --git a/include/PR/os_internal_tlb.h b/include/PR/os_internal_tlb.h new file mode 100644 index 000000000..b92918ffe --- /dev/null +++ b/include/PR/os_internal_tlb.h @@ -0,0 +1,47 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_tlb.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:14 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_TLB_H_ +#define _OS_INTERNAL_TLB_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routines for fetch TLB info */ + +extern u32 __osGetTLBASID(void); +extern u32 __osGetTLBPageMask(s32); +extern u32 __osGetTLBHi(s32); +extern u32 __osGetTLBLo0(s32); +extern u32 __osGetTLBLo1(s32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_TLB_H */ diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 94111c0b6..ae7281fca 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -1,10 +1,100 @@ + +/*==================================================================== + * os_libc.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_libc.h,v $ + $Revision: 1.3 $ + $Date: 1999/07/13 01:43:47 $ + *---------------------------------------------------------------------*/ + #ifndef _OS_LIBC_H_ -#define _OS_LIBC_H_ +#define _OS_LIBC_H_ -#include "ultratypes.h" +#include "os_pfs.h" -// Old deprecated functions from strings.h, replaced by memcpy/memset. -extern void bcopy(const void *, void *, size_t); -extern void bzero(void *, size_t); +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* byte string operations */ + +#ifdef TARGET_N64 + extern void bcopy(const void *, void *, int); + extern int bcmp(const void *, const void *, int); + extern void bzero(void *, int); +#endif +/* Printf */ + +extern int sprintf(char *s, const char *fmt, ...); +extern void osSyncPrintf(const char *fmt, ...); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif #endif /* !_OS_LIBC_H_ */ diff --git a/include/PR/os_message.h b/include/PR/os_message.h index 71e769866..5bc565e36 100644 --- a/include/PR/os_message.h +++ b/include/PR/os_message.h @@ -35,7 +35,6 @@ extern "C" { #endif #include -#include #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) diff --git a/include/PR/os_misc.h b/include/PR/os_misc.h deleted file mode 100644 index 71e111f13..000000000 --- a/include/PR/os_misc.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _ULTRA64_OS_MISC_H_ -#define _ULTRA64_OS_MISC_H_ -#include -/* Miscellaneous OS functions */ - -void osInitialize(void); -u32 osGetCount(void); - -uintptr_t osVirtualToPhysical(void *); - -#endif diff --git a/include/PR/os_motor.h b/include/PR/os_motor.h new file mode 100644 index 000000000..f8dcbd5a3 --- /dev/null +++ b/include/PR/os_motor.h @@ -0,0 +1,83 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_motor.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:15 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_MOTOR_H_ +#define _OS_MOTOR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" +#include "os_pfs.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Rumble PAK interface */ + +extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); +#if 1 +#define MOTOR_START 1 +#define MOTOR_STOP 0 +#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) +#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) +extern s32 __osMotorAccess(OSPfs *, s32); +#else +extern s32 osMotorStop(OSPfs *); +extern s32 osMotorStart(OSPfs *); +#endif + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_MOTOR_H_ */ diff --git a/include/PR/os_pfs.h b/include/PR/os_pfs.h new file mode 100644 index 000000000..188f9d281 --- /dev/null +++ b/include/PR/os_pfs.h @@ -0,0 +1,174 @@ + +/*==================================================================== + * os_pfs.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_pfs.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:16 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_PFS_H_ +#define _OS_PFS_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for file system + */ +typedef struct { + int status; + OSMesgQueue *queue; + int channel; + u8 id[32]; + u8 label[32]; + int version; + int dir_size; + int inode_table; /* block location */ + int minode_table; /* mirrioring inode_table */ + int dir_table; /* block location */ + int inode_start_page; /* page # */ + u8 banks; + u8 activebank; +} OSPfs; + +typedef struct { + u32 file_size; /* bytes */ + u32 game_code; + u16 company_code; + char ext_name[4]; + char game_name[16]; +} OSPfsState; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* File System size */ +#define OS_PFS_VERSION 0x0200 +#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) +#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) + +#define PFS_FILE_NAME_LEN 16 +#define PFS_FILE_EXT_LEN 4 +#define BLOCKSIZE 32 /* bytes */ +#define PFS_ONE_PAGE 8 /* blocks */ +#define PFS_MAX_BANKS 62 + +/* File System flag */ + +#define PFS_READ 0 +#define PFS_WRITE 1 +#define PFS_CREATE 2 + +/* File System status */ +#define PFS_INITIALIZED 0x1 +#define PFS_CORRUPTED 0x2 /* File system was corrupted */ +#define PFS_ID_BROKEN 0x4 +#define PFS_MOTOR_INITIALIZED 0x8 +#define PFS_GBPAK_INITIALIZED 0x10 + +/* File System error number */ + +#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ +#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */ + /* different one */ +#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ +#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR +#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ +#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ +#define PFS_DATA_FULL 7 /* no free pages on ram pack */ +#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ +#define PFS_ERR_EXIST 9 /* file exists */ +#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ +#define PFS_ERR_DEVICE 11 /* wrong device type*/ +#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */ +#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* file system interface */ + +extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); +extern s32 osPfsRepairId(OSPfs *); +extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); +extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); +extern s32 osPfsChecker(OSPfs *); +extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); +extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); +extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); +extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); +extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); +extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); +extern s32 osPfsSetLabel(OSPfs *, u8 *); +extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); +extern s32 osPfsFreeBlocks(OSPfs *, s32 *); +extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_PFS_H_ */ diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h index 8da37e257..0c7459784 100644 --- a/include/PR/os_pi.h +++ b/include/PR/os_pi.h @@ -1,88 +1,224 @@ -#ifndef _ULTRA64_PI_H_ -#define _ULTRA64_PI_H_ -#include -/* Ultra64 Parallel Interface */ +/*==================================================================== + * os_pi.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ -/* Types */ +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_pi.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:16 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_PI_H_ +#define _OS_PI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_thread.h" +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for Enhanced PI interface + */ + +/* + * OSTranxInfo is set up for Leo Disk DMA. This info will be maintained + * by exception handler. This is how the PIMGR and the ISR communicate. + */ typedef struct { -#if !defined(VERSION_EU) - u32 errStatus; -#endif - void *dramAddr; - void *C2Addr; - u32 sectorSize; - u32 C1ErrNum; - u32 C1ErrSector[4]; + u32 errStatus; /* error status */ + void *dramAddr; /* RDRAM buffer address (DMA) */ + void *C2Addr; /* C2 buffer address */ + u32 sectorSize; /* size of transfering sector */ + u32 C1ErrNum; /* total # of C1 errors */ + u32 C1ErrSector[4]; /* error sectors */ } __OSBlockInfo; typedef struct { - u32 cmdType; // 0 - u16 transferMode; // 4 - u16 blockNum; // 6 - s32 sectorNum; // 8 - uintptr_t devAddr; // c -#if defined(VERSION_EU) - u32 errStatus; //error status added moved to blockinfo -#endif - u32 bmCtlShadow; // 10 - u32 seqCtlShadow; // 14 - __OSBlockInfo block[2]; // 18 + u32 cmdType; /* for disk only */ + u16 transferMode; /* Block, Track, or sector? */ + u16 blockNum; /* which block is transfering */ + s32 sectorNum; /* which sector is transfering */ + u32 devAddr; /* Device buffer address */ + u32 bmCtlShadow; /* asic bm_ctl(510) register shadow ram */ + u32 seqCtlShadow; /* asic seq_ctl(518) register shadow ram */ + __OSBlockInfo block[2]; /* bolck transfer info */ } __OSTranxInfo; + typedef struct OSPiHandle_s { - struct OSPiHandle_s *next; - u8 type; - u8 latency; - u8 pageSize; - u8 relDuration; - u8 pulse; - u8 domain; - u32 baseAddress; - u32 speed; - __OSTranxInfo transferInfo; + struct OSPiHandle_s *next; /* point to next handle on the table */ + u8 type; /* DEVICE_TYPE_BULK for disk */ + u8 latency; /* domain latency */ + u8 pageSize; /* domain page size */ + u8 relDuration; /* domain release duration */ + u8 pulse; /* domain pulse width */ + u8 domain; /* which domain */ + u32 baseAddress; /* Domain address */ + u32 speed; /* for roms only */ + /* The following are "private" elements" */ + __OSTranxInfo transferInfo; /* for disk only */ } OSPiHandle; typedef struct { - u8 type; - uintptr_t address; + u8 type; + u32 address; } OSPiInfo; +/* + * Structure for I/O message block + */ typedef struct { - u16 type; - u8 pri; - u8 status; - OSMesgQueue *retQueue; + u16 type; /* Message type */ + u8 pri; /* Message priority (High or Normal) */ + u8 status; /* Return status */ + OSMesgQueue *retQueue; /* Return message queue to notify I/O + * completion */ } OSIoMesgHdr; typedef struct { - /*0x00*/ OSIoMesgHdr hdr; - /*0x08*/ void *dramAddr; - /*0x0C*/ uintptr_t devAddr; - /*0x10*/ size_t size; -#if defined(VERSION_EU) || defined(VERSION_SH) - OSPiHandle *piHandle; // from the official definition -#endif + OSIoMesgHdr hdr; /* Message header */ + void * dramAddr; /* RDRAM buffer address (DMA) */ + u32 devAddr; /* Device buffer address (DMA) */ + u32 size; /* DMA transfer size in bytes */ + OSPiHandle *piHandle; /* PI device handle */ } OSIoMesg; -/* Definitions */ +/* + * Structure for device manager block + */ +typedef struct { + s32 active; /* Status flag */ + OSThread *thread; /* Calling thread */ + OSMesgQueue *cmdQueue; /* Command queue */ + OSMesgQueue *evtQueue; /* Event queue */ + OSMesgQueue *acsQueue; /* Access queue */ + /* Raw DMA routine */ + s32 (*dma)(s32, u32, void *, u32); + s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); +} OSDevMgr; -#define OS_READ 0 // device -> RDRAM -#define OS_WRITE 1 // device <- RDRAM -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ -/* Functions */ +/************************************************************************** + * + * Global definitions + * + */ -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, - size_t nbytes, OSMesgQueue *mq); -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt); -OSMesgQueue *osPiGetCmdQueue(void); -s32 osPiWriteIo(uintptr_t devAddr, u32 data); -s32 osPiReadIo(uintptr_t devAddr, u32 *data); +/* Flags to indicate direction of data transfer */ -s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size); -s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size); +#define OS_READ 0 /* device -> RDRAM */ +#define OS_WRITE 1 /* device <- RDRAM */ +#define OS_OTHERS 2 /* for Leo disk only */ + +/* + * I/O message types + */ +#define OS_MESG_TYPE_BASE (10) +#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) +#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) +#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) +#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) +#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) +#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) +#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) + +/* + * I/O message priority + */ +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +/* + * PI/EPI + */ +#define PI_DOMAIN1 0 +#define PI_DOMAIN2 1 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Peripheral interface (Pi) */ +extern u32 osPiGetStatus(void); +extern s32 osPiGetDeviceType(void); +extern s32 osPiWriteIo(u32, u32); +extern s32 osPiReadIo(u32, u32 *); +extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, + OSMesgQueue *); +extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); + +/* Enhanced PI interface */ + +extern OSPiHandle *osCartRomInit(void); +extern OSPiHandle *osLeoDiskInit(void); +extern OSPiHandle *osDriveRomInit(void); + +extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); +extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); +extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); +extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); +extern s32 osEPiLinkHandle(OSPiHandle *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} #endif + +#endif /* !_OS_PI_H_ */ diff --git a/include/PR/os_reg.h b/include/PR/os_reg.h new file mode 100644 index 000000000..50aa21881 --- /dev/null +++ b/include/PR/os_reg.h @@ -0,0 +1,90 @@ + +/*==================================================================== + * os_reg.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_reg.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:17 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_REG_H_ +#define _OS_REG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Miscellaneous operations */ + +extern u32 osGetCount(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_REG_H_ */ diff --git a/include/PR/os_rsp.h b/include/PR/os_rsp.h new file mode 100644 index 000000000..12116053e --- /dev/null +++ b/include/PR/os_rsp.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_rsp.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_rsp.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:17 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_RSP_H_ +#define _OS_RSP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_RSP_H_ */ diff --git a/include/PR/os_si.h b/include/PR/os_si.h new file mode 100644 index 000000000..23b07c078 --- /dev/null +++ b/include/PR/os_si.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_si.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_si.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:18 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_SI_H_ +#define _OS_SI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_SI_H_ */ diff --git a/include/PR/os_system.h b/include/PR/os_system.h new file mode 100644 index 000000000..1179189a2 --- /dev/null +++ b/include/PR/os_system.h @@ -0,0 +1,118 @@ + +/*==================================================================== + * os_system.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_system.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:18 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_SYSTEM_H_ +#define _OS_SYSTEM_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Values for osTvType + */ +#define OS_TV_PAL 0 +#define OS_TV_NTSC 1 +#define OS_TV_MPAL 2 + +/* + * Size of buffer the retains contents after NMI + */ +#define OS_APP_NMI_BUFSIZE 64 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ +extern void *osRomBase; /* Rom base address of the game image */ +extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ +extern s32 osResetType; /* 0 = cold reset, 1 = NMI */ +extern s32 osCicId; +extern s32 osVersion; +extern u32 osMemSize; /* Memory Size */ +extern s32 osAppNMIBuffer[]; + +extern u64 osClockRate; + +extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +extern void osInitialize(void); +extern void osExit(void); +extern u32 osGetMemSize(void); + +/* pre-NMI */ +extern s32 osAfterPreNMI(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_SYSTEM_H_ */ diff --git a/include/PR/os_thread.h b/include/PR/os_thread.h index 76e528b50..7b82dc79f 100644 --- a/include/PR/os_thread.h +++ b/include/PR/os_thread.h @@ -1,75 +1,154 @@ -#ifndef _ULTRA64_THREAD_H_ -#define _ULTRA64_THREAD_H_ -#include "ultratypes.h" -/* Recommended priorities for system threads */ -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 -#define OS_STATE_STOPPED 1 -#define OS_STATE_RUNNABLE 2 -#define OS_STATE_RUNNING 4 -#define OS_STATE_WAITING 8 +/*==================================================================== + * os_thread.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ -/* Types */ +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_thread.h,v $ + $Revision: 1.3 $ + $Date: 1999/06/15 12:39:40 $ + *---------------------------------------------------------------------*/ -typedef s32 OSPri; -typedef s32 OSId; +#ifndef _OS_THREAD_H_ +#define _OS_THREAD_H_ -typedef union -{ - struct {f32 f_odd; f32 f_even;} f; -} __OSfp; +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif -typedef struct -{ - /* registers */ - /*0x20*/ u64 at, v0, v1, a0, a1, a2, a3; - /*0x58*/ u64 t0, t1, t2, t3, t4, t5, t6, t7; - /*0x98*/ u64 s0, s1, s2, s3, s4, s5, s6, s7; - /*0xD8*/ u64 t8, t9, gp, sp, s8, ra; - /*0x108*/ u64 lo, hi; - /*0x118*/ u32 sr, pc, cause, badvaddr, rcp; - /*0x12C*/ u32 fpcsr; - __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; - __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef s32 OSPri; +typedef s32 OSId; +typedef union { struct { f32 f_odd; f32 f_even; } f; f64 d; } __OSfp; + +typedef struct { + u64 at, v0, v1, a0, a1, a2, a3; + u64 t0, t1, t2, t3, t4, t5, t6, t7; + u64 s0, s1, s2, s3, s4, s5, s6, s7; + u64 t8, t9, gp, sp, s8, ra; + u64 lo, hi; + u32 sr, pc, cause, badvaddr, rcp; + u32 fpcsr; + __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; + __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; } __OSThreadContext; -typedef struct -{ +typedef struct { u32 flag; u32 count; u64 time; } __OSThreadprofile_s; -typedef struct OSThread_s -{ - /*0x00*/ struct OSThread_s *next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread_s **queue; - /*0x0C*/ struct OSThread_s *tlnext; - /*0x10*/ u16 state; - /*0x12*/ u16 flags; - /*0x14*/ OSId id; - /*0x18*/ int fp; - /*0x1C*/ __OSThreadprofile_s *thprof; - /*0x20*/ __OSThreadContext context; +typedef struct OSThread_s { + struct OSThread_s *next; /* run/mesg queue link */ + OSPri priority; /* run/mesg queue priority */ + struct OSThread_s **queue; /* queue thread is on */ + struct OSThread_s *tlnext; /* all threads queue link */ + u16 state; /* OS_STATE_* */ + u16 flags; /* flags for rmon */ + OSId id; /* id for debugging */ + int fp; /* thread has used fp unit */ + __OSThreadprofile_s *thprof; /* workarea for thread profiler */ + __OSThreadContext context; /* register/interrupt mask */ } OSThread; -/* Functions */ +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ -void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), - void *arg, void *sp, OSPri pri); -OSId osGetThreadId(OSThread *thread); -OSPri osGetThreadPri(OSThread *thread); -void osSetThreadPri(OSThread *thread, OSPri pri); -void osStartThread(OSThread *thread); -void osStopThread(OSThread *thread); +/************************************************************************** + * + * Global definitions + * + */ +/* Thread states */ + +#define OS_STATE_STOPPED 1 +#define OS_STATE_RUNNABLE 2 +#define OS_STATE_RUNNING 4 +#define OS_STATE_WAITING 8 + +/* Recommended thread priorities for the system threads */ + +#define OS_PRIORITY_MAX 255 +#define OS_PRIORITY_VIMGR 254 +#define OS_PRIORITY_RMON 250 +#define OS_PRIORITY_RMONSPIN 200 +#define OS_PRIORITY_PIMGR 150 +#define OS_PRIORITY_SIMGR 140 +#define OS_PRIORITY_APPMAX 127 +#define OS_PRIORITY_IDLE 0 /* Must be 0 */ + +/* for thread profiler */ +#define THPROF_IDMAX 64 +#define THPROF_STACKSIZE 256 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Thread operations */ + +extern void osCreateThread(OSThread *, OSId, void (*)(void *), + void *, void *, OSPri); +extern void osDestroyThread(OSThread *); +extern void osYieldThread(void); +extern void osStartThread(OSThread *); +extern void osStopThread(OSThread *); +extern OSId osGetThreadId(OSThread *); +extern void osSetThreadPri(OSThread *, OSPri); +extern OSPri osGetThreadPri(OSThread *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} #endif + +#endif /* !_OS_THREAD_H_ */ diff --git a/include/PR/os_time.h b/include/PR/os_time.h index ecb05d625..deaec659c 100644 --- a/include/PR/os_time.h +++ b/include/PR/os_time.h @@ -1,27 +1,114 @@ -#ifndef _ULTRA64_TIME_H_ -#define _ULTRA64_TIME_H_ + +/*==================================================================== + * os_time.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_time.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:19 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_TIME_H_ +#define _OS_TIME_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif #include -#include +#include "os_message.h" -/* Types */ -typedef struct OSTimer_str -{ - struct OSTimer_str *next; - struct OSTimer_str *prev; - u64 interval; - u64 remaining; - OSMesgQueue *mq; - OSMesg *msg; +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for time value + */ +typedef u64 OSTime; + +/* + * Structure for interval timer + */ +typedef struct OSTimer_s { + struct OSTimer_s *next; /* point to next timer in list */ + struct OSTimer_s *prev; /* point to previous timer in list */ + OSTime interval; /* duration set by user */ + OSTime value; /* time remaining before */ + /* timer fires */ + OSMesgQueue *mq; /* Message Queue */ + OSMesg msg; /* Message to send */ } OSTimer; -typedef u64 OSTime; -/* Functions */ +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ -OSTime osGetTime(void); -void osSetTime(OSTime time); -u32 osSetTimer(OSTimer *, OSTime, OSTime, OSMesgQueue *, OSMesg); +/************************************************************************** + * + * Global definitions + * + */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Timer interface */ + +extern OSTime osGetTime(void); +extern void osSetTime(OSTime); +extern int osSetTimer(OSTimer *, OSTime, OSTime, + OSMesgQueue *, OSMesg); +extern int osStopTimer(OSTimer *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} #endif + +#endif /* !_OS_TIME_H_ */ diff --git a/include/PR/os_version.h b/include/PR/os_version.h new file mode 100644 index 000000000..c485a4382 --- /dev/null +++ b/include/PR/os_version.h @@ -0,0 +1,16 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_version.h,v $ + $Revision: 1.2 $ + $Date: 1999/06/17 01:33:01 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VERSION_H_ +#define _OS_VERSION_H_ + +#define OS_MAJOR_VERSION "2.0K" /* major version */ +#define OS_MINOR_VERSION 0 /* patch level */ + +#endif /* !_OS_VERSION_H_ */ diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h index 98fb4ed31..5a17f2587 100644 --- a/include/PR/os_vi.h +++ b/include/PR/os_vi.h @@ -1,86 +1,101 @@ -#ifndef _ULTRA64_VI_H_ -#define _ULTRA64_VI_H_ + +/*==================================================================== + * os_vi.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_vi.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:20 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VI_H_ +#define _OS_VI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif #include -#include - -/* Ultra64 Video Interface */ +#include "os_thread.h" +#include "os_message.h" -/* Special Features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -#define OS_VI_GAMMA 0x08 -#define OS_VI_GAMMA_DITHER 0x04 -#define OS_VI_DIVOT 0x10 -#define OS_VI_DITHER_FILTER 0x10000 -#define OS_VI_UNK200 0x200 -#define OS_VI_UNK100 0x100 +/************************************************************************** + * + * Type definitions + * + */ - -/* Types */ - -typedef struct -{ - u32 ctrl; - u32 width; - u32 burst; - u32 vSync; - u32 hSync; - u32 leap; - u32 hStart; - u32 xScale; - u32 vCurrent; +/* + * Structure to store VI register values that remain the same between 2 fields + */ +typedef struct { + u32 ctrl; + u32 width; + u32 burst; + u32 vSync; + u32 hSync; + u32 leap; + u32 hStart; + u32 xScale; + u32 vCurrent; } OSViCommonRegs; -typedef struct -{ - u32 origin; - u32 yScale; - u32 vStart; - u32 vBurst; - u32 vIntr; + +/* + * Structure to store VI register values that change between fields + */ +typedef struct { + u32 origin; + u32 yScale; + u32 vStart; + u32 vBurst; + u32 vIntr; } OSViFieldRegs; -typedef struct -{ - u8 type; - OSViCommonRegs comRegs; - OSViFieldRegs fldRegs[2]; + +/* + * Structure for VI mode + */ +typedef struct { + u8 type; /* Mode type */ + OSViCommonRegs comRegs; /* Common registers for both fields */ + OSViFieldRegs fldRegs[2]; /* Registers for Field 1 & 2 */ } OSViMode; -typedef struct -{ - /* 0x00 */ u16 unk00; //some kind of flags. swap buffer sets to 0x10 - /* 0x02 */ u16 retraceCount; - /* 0x04 */ void* buffer; - /* 0x08 */ OSViMode *modep; - /* 0x0c */ u32 features; - /* 0x10 */ OSMesgQueue *mq; - /* 0x14 */ OSMesg *msg; - /* 0x18 */ u32 unk18; - /* 0x1c */ u32 unk1c; - /* 0x20 */ u32 unk20; - /* 0x24 */ f32 unk24; - /* 0x28 */ u16 unk28; - /* 0x2c */ u32 unk2c; -} OSViContext; -void osCreateViManager(OSPri pri); -void osViSetMode(OSViMode *mode); -void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount); -void osViBlack(u8 active); -void osViSetSpecialFeatures(u32 func); -void osViSwapBuffer(void *vaddr); +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ +/************************************************************************** + * + * Global definitions + * + */ +/* + * Video Interface (VI) mode type + */ #define OS_VI_NTSC_LPN1 0 /* NTSC */ #define OS_VI_NTSC_LPF1 1 #define OS_VI_NTSC_LAN1 2 @@ -111,7 +126,173 @@ void osViSwapBuffer(void *vaddr); #define OS_VI_PAL_HPN2 26 #define OS_VI_PAL_HPF2 27 +#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ +#define OS_VI_MPAL_LPF1 29 +#define OS_VI_MPAL_LAN1 30 +#define OS_VI_MPAL_LAF1 31 +#define OS_VI_MPAL_LPN2 32 +#define OS_VI_MPAL_LPF2 33 +#define OS_VI_MPAL_LAN2 34 +#define OS_VI_MPAL_LAF2 35 +#define OS_VI_MPAL_HPN1 36 +#define OS_VI_MPAL_HPF1 37 +#define OS_VI_MPAL_HAN1 38 +#define OS_VI_MPAL_HAF1 39 +#define OS_VI_MPAL_HPN2 40 +#define OS_VI_MPAL_HPF2 41 + +#define OS_VI_FPAL_LPN1 42 /* FPAL - Full screen PAL */ +#define OS_VI_FPAL_LPF1 43 +#define OS_VI_FPAL_LAN1 44 +#define OS_VI_FPAL_LAF1 45 +#define OS_VI_FPAL_LPN2 46 +#define OS_VI_FPAL_LPF2 47 +#define OS_VI_FPAL_LAN2 48 +#define OS_VI_FPAL_LAF2 49 +#define OS_VI_FPAL_HPN1 50 +#define OS_VI_FPAL_HPF1 51 +#define OS_VI_FPAL_HAN1 52 +#define OS_VI_FPAL_HAF1 53 +#define OS_VI_FPAL_HPN2 54 +#define OS_VI_FPAL_HPF2 55 + +/* + * Video Interface (VI) special features + */ +#define OS_VI_GAMMA_ON 0x0001 +#define OS_VI_GAMMA_OFF 0x0002 +#define OS_VI_GAMMA_DITHER_ON 0x0004 +#define OS_VI_GAMMA_DITHER_OFF 0x0008 +#define OS_VI_DIVOT_ON 0x0010 +#define OS_VI_DIVOT_OFF 0x0020 +#define OS_VI_DITHER_FILTER_ON 0x0040 +#define OS_VI_DITHER_FILTER_OFF 0x0080 + +/* + * Video Interface (VI) mode attribute bit + */ +#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ +#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ +#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ +#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ +#define OS_VI_BIT_ANTIALIAS 0x0010 +#define OS_VI_BIT_POINTSAMPLE 0x0020 +#define OS_VI_BIT_16PIXEL 0x0040 +#define OS_VI_BIT_32PIXEL 0x0080 +#define OS_VI_BIT_LORES 0x0100 +#define OS_VI_BIT_HIRES 0x0200 +#define OS_VI_BIT_NTSC 0x0400 +#define OS_VI_BIT_PAL 0x0800 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + extern OSViMode osViModeTable[]; /* Global VI mode table */ +extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ +extern OSViMode osViModeNtscLpf1; +extern OSViMode osViModeNtscLan1; +extern OSViMode osViModeNtscLaf1; +extern OSViMode osViModeNtscLpn2; +extern OSViMode osViModeNtscLpf2; +extern OSViMode osViModeNtscLan2; +extern OSViMode osViModeNtscLaf2; +extern OSViMode osViModeNtscHpn1; +extern OSViMode osViModeNtscHpf1; +extern OSViMode osViModeNtscHan1; +extern OSViMode osViModeNtscHaf1; +extern OSViMode osViModeNtscHpn2; +extern OSViMode osViModeNtscHpf2; +extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ +extern OSViMode osViModePalLpf1; +extern OSViMode osViModePalLan1; +extern OSViMode osViModePalLaf1; +extern OSViMode osViModePalLpn2; +extern OSViMode osViModePalLpf2; +extern OSViMode osViModePalLan2; +extern OSViMode osViModePalLaf2; +extern OSViMode osViModePalHpn1; +extern OSViMode osViModePalHpf1; +extern OSViMode osViModePalHan1; +extern OSViMode osViModePalHaf1; +extern OSViMode osViModePalHpn2; +extern OSViMode osViModePalHpf2; + +extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ +extern OSViMode osViModeMpalLpf1; +extern OSViMode osViModeMpalLan1; +extern OSViMode osViModeMpalLaf1; +extern OSViMode osViModeMpalLpn2; +extern OSViMode osViModeMpalLpf2; +extern OSViMode osViModeMpalLan2; +extern OSViMode osViModeMpalLaf2; +extern OSViMode osViModeMpalHpn1; +extern OSViMode osViModeMpalHpf1; +extern OSViMode osViModeMpalHan1; +extern OSViMode osViModeMpalHaf1; +extern OSViMode osViModeMpalHpn2; +extern OSViMode osViModeMpalHpf2; + +extern OSViMode osViModeFpalLpn1; /* Individual VI FPAL modes */ +extern OSViMode osViModeFpalLpf1; +extern OSViMode osViModeFpalLan1; +extern OSViMode osViModeFpalLaf1; +extern OSViMode osViModeFpalLpn2; +extern OSViMode osViModeFpalLpf2; +extern OSViMode osViModeFpalLan2; +extern OSViMode osViModeFpalLaf2; +extern OSViMode osViModeFpalHpn1; +extern OSViMode osViModeFpalHpf1; +extern OSViMode osViModeFpalHan1; +extern OSViMode osViModeFpalHaf1; +extern OSViMode osViModeFpalHpn2; +extern OSViMode osViModeFpalHpf2; + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Video interface (Vi) */ +extern u32 osViGetStatus(void); +extern u32 osViGetCurrentMode(void); +extern u32 osViGetCurrentLine(void); +extern u32 osViGetCurrentField(void); +extern void *osViGetCurrentFramebuffer(void); +extern void *osViGetNextFramebuffer(void); +extern void osViSetXScale(f32); +extern void osViSetYScale(f32); +extern void osViExtendVStart(u32); +extern void osViSetSpecialFeatures(u32); +extern void osViSetMode(OSViMode *); +extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); +extern void osViSwapBuffer(void *); +extern void osViBlack(u8); +extern void osViFade(u8, u16); +extern void osViRepeatLine(u8); +extern void osCreateViManager(OSPri); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} #endif + +#endif /* !_OS_VI_H_ */ diff --git a/include/PR/os_voice.h b/include/PR/os_voice.h new file mode 100644 index 000000000..4e3cf6ec4 --- /dev/null +++ b/include/PR/os_voice.h @@ -0,0 +1,108 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_voice.h,v $ + $Revision: 1.2 $ + $Date: 1999/07/13 08:36:42 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VOICE_H_ +#define _OS_VOICE_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef struct { /* Voice Recognition System */ + OSMesgQueue *__mq; /* SI Message Queue */ + int __channel; /* Controller Port # */ + s32 __mode; + u8 cmd_status; /* Command Status */ +} OSVoiceHandle; + +typedef struct { /* Voice Recognition System */ + u16 warning; + u16 answer_num; /* 0...5 */ + u16 voice_level; + u16 voice_sn; + u16 voice_time; + u16 answer[5]; + u16 distance[5]; +} OSVoiceData; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* definition for Voice Recognition System */ + +#define VOICE_WARN_TOO_SMALL 0x0400 +#define VOICE_WARN_TOO_LARGE 0x0800 +#define VOICE_WARN_NOT_FIT 0x4000 +#define VOICE_WARN_TOO_NOISY 0x8000 + +#define VOICE_STATUS_READY 0 +#define VOICE_STATUS_START 1 +#define VOICE_STATUS_CANCEL 3 +#define VOICE_STATUS_BUSY 5 +#define VOICE_STATUS_END 7 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Voice Recognition System */ +extern s32 osVoiceInit(OSMesgQueue *, OSVoiceHandle *, int); +extern s32 osVoiceCheckWord(u8 *data); +extern s32 osVoiceClearDictionary(OSVoiceHandle *, u8); +extern s32 osVoiceControlGain(OSVoiceHandle *, s32, s32); +extern s32 osVoiceSetWord(OSVoiceHandle *, u8 *); +extern s32 osVoiceStartReadData(OSVoiceHandle *); +extern s32 osVoiceStopReadData(OSVoiceHandle *); +extern s32 osVoiceGetReadData(OSVoiceHandle *, OSVoiceData *); +extern s32 osVoiceMaskDictionary(OSVoiceHandle *, u8 *, int); +extern void osVoiceCountSyllables(u8 *, u32 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_VOICE_H_ */ diff --git a/include/PR/ramrom.h b/include/PR/ramrom.h new file mode 100644 index 000000000..42e5c2d59 --- /dev/null +++ b/include/PR/ramrom.h @@ -0,0 +1,113 @@ +#ifndef _RAMROM_H +#define _RAMROM_H + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.20 $ + * $Date: 1997/02/11 08:26:47 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ramrom.h,v $ + * + **************************************************************************/ + +/* + * Defines for the GIO card in the Nintendo Development Station + * + * The RAM on the GIO card acts as ROM for the game + * Interrupts available between the game and the Indy host + * + * The last part of the ramrom is used for communication between + * game and host. There are 6 4K buffers defined: + * log, printf, rmon to indy, rmon from indy, app to indy, app from indy + * The last 8 bytes of the buffer are used in the emulator environment + */ + +#define RAMROM_SIZE (0x1000000) + +#define RAMROM_BUF_SIZE (4096) +#define RAMROM_MSG_SIZE (RAMROM_BUF_SIZE*6) +#define RAMROM_MSG_ADDR (RAMROM_SIZE - RAMROM_MSG_SIZE) +#define RAMROM_MSG_HDR_SIZE (3*sizeof(long)) +#define RAMROM_USER_DATA_SIZE (RAMROM_MSG_SIZE-RAMROM_MSG_HDR_SIZE) + +#define RAMROM_APP_READ_ADDR (RAMROM_MSG_ADDR + (0*RAMROM_BUF_SIZE)) +#define RAMROM_APP_WRITE_ADDR (RAMROM_MSG_ADDR + (1*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_READ_ADDR (RAMROM_MSG_ADDR + (2*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_WRITE_ADDR (RAMROM_MSG_ADDR + (3*RAMROM_BUF_SIZE)) +#define RAMROM_PRINTF_ADDR (RAMROM_MSG_ADDR + (4*RAMROM_BUF_SIZE)) +#define RAMROM_LOG_ADDR (RAMROM_MSG_ADDR + (5*RAMROM_BUF_SIZE)) + +/*#define RAMROM_GIO_INTERRUPT (RAMROM_MSG_ADDR + RAMROM_MSG_SIZE - 4)*/ + +/* + * For the initial round of PIF bringup, we will load in a bootstrap loader + * 0x400 bytes into the ramrom, and the rom will be loaded at 0x2000 + */ +#ifndef _HW_VERSION_1 +#define RAMROM_BOOTSTRAP_OFFSET 0x40 +#define RAMROM_GAME_OFFSET 0x1000 +#define RAMROM_FONTDATA_OFFSET 0xb70 +#define RAMROM_FONTDATA_SIZE 1152 +#else +#define RAMROM_BOOTSTRAP_OFFSET 0x400 +#define RAMROM_GAME_OFFSET 0x2000 +#endif +#define RAMROM_CLOCKRATE_OFFSET 0x4 +#define RAMROM_CLOCKRATE_MASK 0xfffffff0 +#define RAMROM_BOOTADDR_OFFSET 0x8 +#define RAMROM_RELEASE_OFFSET 0xc +/* + * Second version of the PIF jumps to location 0x1000, and we'll put a jump to + * location 0x400 into the ramrom (for backwards compatibility). + */ +#define RAMROM_PIF2BOOTSTRAP_OFFSET 0x1000 + +typedef struct { + long type; + long length; /* in bytes of userdata */ + long magic; + char userdata[RAMROM_USER_DATA_SIZE]; +} RamRomBuffer; + +/* + * Interrupt values (must fit in 6 bits!) + * values are used for both request & response + * Transactions initiated by the host start with HOST + * and those initiated by the target start with GAME. + */ + +#define HOST_PIACCESS_REQ 1 +#define HOST_DBG_CMD_READY 2 +#define GAME_DBG_DATA_SEND 3 +#define HOST_DBG_DATA_ACK 4 +#define GAME_PRINTF_SEND 5 +#define HOST_PRINTF_ACK 6 +#define GAME_LOG_SEND 7 +#define HOST_LOG_ACK 8 +#define HOST_APP_CMD_READY 9 +#define GAME_APP_DATA_READY 10 +#define HOST_PROF_REQ 11 +#define GAME_PROF_SEND 12 +#define HOST_PROF_ACK 13 +#define GAME_FAULT_SEND 14 +#define HOST_FAULT_ACK 15 +#define GAME_EXIT 16 +#define HOST_DATA_ACK 17 + +#ifdef _EMULATOR +void __RamRomInit(int key, void *romaddr); +void __RamRomDestroy(int key); +#endif /* _EMULATOR */ + +#endif /* !_RAMROM_H */ diff --git a/include/PR/rcp.h b/include/PR/rcp.h index 68ce9682d..980f21f0f 100644 --- a/include/PR/rcp.h +++ b/include/PR/rcp.h @@ -18,9 +18,9 @@ * File: rcp.h * * This file contains register and bit definitions for RCP memory map. - * $Revision: 1.20 $ - * $Date: 1997/07/23 08:35:21 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ + * $Revision: 1.22 $ + * $Date: 1999/05/20 03:01:49 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rcp.h,v $ * **************************************************************************/ @@ -161,6 +161,9 @@ The Indy development board use cartridge domain 1: #define DEVICE_TYPE_BULK 1 /* ROM bulk */ #define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ #define DEVICE_TYPE_SRAM 3 /* SRAM */ +/* 4-6 are reserved */ +#define DEVICE_TYPE_INIT 7 /* initial value */ +/* 8-14 are reserved */ /************************************************************************* * SP Memory @@ -879,3 +882,4 @@ The Indy development board use cartridge domain 1: #endif #endif /* _RCP_H_ */ + diff --git a/include/PR/rdb.h b/include/PR/rdb.h new file mode 100644 index 000000000..e08974935 --- /dev/null +++ b/include/PR/rdb.h @@ -0,0 +1,93 @@ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:29:31 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rdb.h,v $ + * + **************************************************************************/ + +#ifndef _RDB_H +#define _RDB_H + +/* U64 side address */ +#define RDB_BASE_REG 0xc0000000 +#define RDB_WRITE_INTR_REG (RDB_BASE_REG + 0x8) +#define RDB_READ_INTR_REG (RDB_BASE_REG + 0xc) +#define RDB_BASE_VIRTUAL_ADDR 0x80000000 + +/* packet type Have six bits, so can have up to 63 types */ +#define RDB_TYPE_INVALID 0 +#define RDB_TYPE_GtoH_PRINT 1 +#define RDB_TYPE_GtoH_FAULT 2 +#define RDB_TYPE_GtoH_LOG_CT 3 +#define RDB_TYPE_GtoH_LOG 4 +#define RDB_TYPE_GtoH_READY_FOR_DATA 5 +#define RDB_TYPE_GtoH_DATA_CT 6 +#define RDB_TYPE_GtoH_DATA 7 +#define RDB_TYPE_GtoH_DEBUG 8 +#define RDB_TYPE_GtoH_RAMROM 9 +#define RDB_TYPE_GtoH_DEBUG_DONE 10 +#define RDB_TYPE_GtoH_DEBUG_READY 11 +#define RDB_TYPE_GtoH_KDEBUG 12 +#define RDB_TYPE_GtoH_PROF_DATA 22 + + +#define RDB_TYPE_HtoG_LOG_DONE 13 +#define RDB_TYPE_HtoG_DEBUG 14 +#define RDB_TYPE_HtoG_DEBUG_CT 15 +#define RDB_TYPE_HtoG_DATA 16 +#define RDB_TYPE_HtoG_DATA_DONE 17 +#define RDB_TYPE_HtoG_REQ_RAMROM 18 +#define RDB_TYPE_HtoG_FREE_RAMROM 19 +#define RDB_TYPE_HtoG_KDEBUG 20 +#define RDB_TYPE_HtoG_PROF_SIGNAL 21 + + +#define RDB_PROF_ACK_SIG 1 +#define RDB_PROF_FLUSH_SIG 2 +#define PROF_BLOCK_SIZE 2048 + +#define RDB_LOG_MAX_BLOCK_SIZE 0x8000 +#define RDB_DATA_MAX_BLOCK_SIZE 0x8000 + + +/* GIO side address */ +#define GIO_RDB_BASE_REG 0xbf480000 +#define GIO_RDB_WRITE_INTR_REG (GIO_RDB_BASE_REG + 0x8) +#define GIO_RDB_READ_INTR_REG (GIO_RDB_BASE_REG + 0xc) + +/* minor device number */ +#define GIO_RDB_PRINT_MINOR 1 +#define GIO_RDB_DEBUG_MINOR 2 + +/* interrupt bit */ +#define GIO_RDB_WRITE_INTR_BIT 0x80000000 +#define GIO_RDB_READ_INTR_BIT 0x40000000 + +/* debug command */ +#define DEBUG_COMMAND_NULL 0 +#define DEBUG_COMMAND_MEMORY 1 +#define DEBUG_COMMAND_REGISTER 2 +#define DEBUG_COMMAND_INVALID 255 + +/* debug state */ +#define DEBUG_STATE_NULL 0 +#define DEBUG_STATE_RECEIVE 1 +#define DEBUG_STATE_INVALID 255 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Structure for debug port */ +typedef struct { + unsigned type : 6; /* 0: invalid, 1: print, 2: debug */ + unsigned length : 2; /* 1, 2, or 3 */ + char buf[3]; /* character buffer */ +} rdbPacket; + +extern unsigned int __osRdbWriteOK; +extern unsigned int __osRdbSendMessage; + +#endif /* _LANGUAGE_C */ + +#endif /* !_RDB_H */ diff --git a/include/PR/region.h b/include/PR/region.h new file mode 100644 index 000000000..0ac8a253e --- /dev/null +++ b/include/PR/region.h @@ -0,0 +1,123 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Module: region.h + * + * $Revision: 1.8 $ + * $Date: 1997/11/26 00:30:56 $ + * $Author: mitu $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/region.h,v $ + * + * Description: + * This file contains macros and structure definitions for the region + * library. + * + **************************************************************************/ + + +#ifndef _REGION_H_ +#define _REGION_H_ + + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + + +/*************************************** + * + * Global defines + * + */ + /* Alignment sizes */ +#define ALIGNSZ (sizeof(long long)) /* 8 bytes */ +#define ALIGNOFFST (ALIGNSZ-1) + + /* size for storing index to free buffer */ +#define BUF_CTRL_SIZE ALIGNSZ + + /* Max bufcount = 32K */ +#define MAX_BUFCOUNT 0x8000 + /* code for last free buffer */ +#define BUF_FREE_WO_NEXT 0x8000 + +/* + * Global defines for alignment size (default is 8-byte alignment) + */ +#define OS_RG_ALIGN_2B 2 /* 2 bytes = 16-bit alignment */ +#define OS_RG_ALIGN_4B 4 /* 4 bytes = 32-bit alignment */ +#define OS_RG_ALIGN_8B 8 /* 8 bytes = 64-bit alignment */ +#define OS_RG_ALIGN_16B 16 /* 16 bytes = 128-bit alignment */ + +#define OS_RG_ALIGN_DEFAULT OS_RG_ALIGN_8B + + +/*************************************** + * + * Macro definitions + * + */ + +/* Perform alignment on input 's' */ +#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) + + +/*************************************** + * + * Typedefs & structure definitions + * + */ +/* + * Structure for region header/control area + */ +typedef struct _Region_s { + u8 *r_startBufferAddress; /* start address to data buffer */ + u8 *r_endAddress; /* end address of region */ + s32 r_bufferSize; /* size of buffers for this region */ + s32 r_bufferCount; /* up to 32K entries; MSB is used for + setting end-of-list/used */ + u16 r_freeList; /* point to array index of first + available memory buffer */ + u16 r_alignSize; /* alignment size (# of bytes) */ +} OSRegion; + +/* + * Macro to simplify accessing region header structure + */ +#define RP(x) rp->r_##x + + +/*************************************** + * + * Function prototypes + * + */ +extern void *osCreateRegion(void *, u32, u32, u32); +extern void *osMalloc(void *); +extern void osFree(void *, void *); +extern s32 osGetRegionBufCount(void *); +extern s32 osGetRegionBufSize(void *); + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + + +#endif /* _REGION_H_ */ + + diff --git a/include/PR/rmon.h b/include/PR/rmon.h new file mode 100644 index 000000000..199e56993 --- /dev/null +++ b/include/PR/rmon.h @@ -0,0 +1,39 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:30:08 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rmon.h,v $ + * + **************************************************************************/ + +#ifndef _RMON_H_ +#define _RMON_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#define RMON_DBG_BUF_SIZE 2048 +#define RMON_STACKSIZE 0x1000 + +extern void rmonMain( void * ); +extern void rmonPrintf( const char *, ... ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/include/PR/rsp.h b/include/PR/rsp.h new file mode 100644 index 000000000..16f5ca341 --- /dev/null +++ b/include/PR/rsp.h @@ -0,0 +1,85 @@ + +/* + * rsp.h + * + * Mon Mar 21 21:15:39 PST 1994 + * + * This file is some common definitions for RSP code. + * It enforces the programming model for the task lists. + * + */ + +/************************************************************************** + * + * $Revision: 1.1.1.2 $ + * $Date: 2002/10/29 08:06:34 $ + * $Source: /home/ryzen/cvsaaaa/depot/rf/sw/n64os20l/include/rsp.h,v $ + * + **************************************************************************/ + +#ifndef _RSP_H_ +#define _RSP_H_ 1 + +#define RSP_DMEM_BASE 0x04000000 +#define RSP_IMEM_BASE 0x04001000 + +#define RSP_SCRATCH_BASE 0x20000000 /* for sim use only */ + +#define DCACHEBASEHI 0x0400 +#define DCACHEBASELO 0x0000 + +#define RSPBOOTBASEHI 0x0400 +#define RSPBOOTBASELO 0x1000 + +#define TASKBASEHI 0x0400 +#define TASKBASELO 0x1080 + +#define HOSTSEMADDRHI 0x0000 # semaphore address +#define HOSTSEMADDRLO 0x1ffc # semaphore address + +/* for now, we'll just copy all the output somewhere out-of-the-way... */ +#define RDP_BUFF_HI 0x2000 +#define RDP_BUFF_LO 0x0000 + +/* for now, we'll just fix some DRAM stack (for matrices, etc.) */ +#define DRAM_STACK_HI 0x001f +#define DRAM_STACK_LO 0xfc00 /* a 1K stack... */ + +/* + * this is a hack; we need a place in DRAM for the RSP to + * use as a stack. + */ +#define rsp_DRAM_STACK_HI 0x0020 +#define rsp_DRAM_STACK_LO 0x0000 + + /* where is the trig ROM? */ +#define rsp_TRIG_BASE 0x10010000 +#define rsp_TRIG_BASEHI 0x1001 +#define rsp_TRIG_BASELO 0x0000 + +#ifdef _LANGUAGE_ASSEMBLY + + .symbol RSPBOOTBASE, RSP_IMEM_BASE # start of rsp bootstrap + .symbol TASKBASE, (RSP_IMEM_BASE+0x80) # 32 inst. for bootstrap + + .name DMA_CACHE, $c0 # these are CP0 registers + .name DMA_DRAM, $c1 # + .name DMA_READ_LENGTH, $c2 + .name DMA_WRITE_LENGTH, $c3 + .name SP_STATUS, $c4 + .name DMA_FULL, $c5 + .name DMA_BUSY, $c6 + .name SP_RESERVED, $c7 + .name CMD_START, $c8 + .name CMD_END, $c9 + .name CMD_CURRENT, $c10 + .name CMD_STATUS, $c11 + .name CMD_CLOCK, $c12 + .name CMD_BUSY, $c13 + .name CMD_PIPE_BUSY, $c14 + .name CMD_TMEM_BUSY, $c15 + +#endif + + +#endif diff --git a/include/PR/rsp_ipc.h b/include/PR/rsp_ipc.h new file mode 100644 index 000000000..af1a54d3b --- /dev/null +++ b/include/PR/rsp_ipc.h @@ -0,0 +1,69 @@ + +/* + * rsp_ipc.h + * + * Mon Mar 13 10:24:35 PST 1995 + * + * + */ + +/************************************************************************** + * + * $Revision: 1.1.1.2 $ + * $Date: 2002/10/29 08:06:34 $ + * $Source: /home/ryzen/cvsaaaa/depot/rf/sw/n64os20l/include/rsp_ipc.h,v $ + * + **************************************************************************/ + +#ifndef _RSP_IPC_H_ +#define _RSP_IPC_H_ 1 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +typedef enum +{ + CMD_NULL, + CMD_CMD, + CMD_QUIT, + CMD_DMA_READ, + CMD_DMA_WRITE, + CMD_READ_WORD, + CMD_WRITE_WORD, + CMD_LAST +} rsp_shm_cmd_t; + +typedef struct +{ + unsigned long int dram[(2048 * 1024)>>2]; /* share DRAM */ + /* + * howardc - Keep buff right after the dram to keep it 64b aligned. This + * is the fake DMA IPC buffer to communicate to rspsim. If 64b aligned, the + * _emAlign64b (64bit alignment checking code) will properly check for + * alignment. + */ + unsigned long int buff[1024]; /* could be IMEM or DMEM */ + char string[256]; /* pass command string */ + rsp_shm_cmd_t cmd; /* what to do */ + int reg; /* which register */ + unsigned long int addr; /* RSP memory address for copy */ + unsigned long int length; /* length of data to be copied */ +} rsp_shm_buf_t; + + +/* + * simple semaphore interface, stolen from Stevens' Networking book. + * + * Tue Feb 7 13:38:49 PST 1995 + * + */ +extern int sem_create(key_t key, int initval); +extern int sem_open(key_t key); +extern int sem_rm(int id); +extern int sem_close(int id); +extern int sem_wait(int id); +extern int sem_signal(int id); +extern int sem_op(int id, int value); + +#endif + +#endif diff --git a/include/PR/sched.h b/include/PR/sched.h new file mode 100644 index 000000000..2d305a2e0 --- /dev/null +++ b/include/PR/sched.h @@ -0,0 +1,115 @@ +/*==================================================================== + * sched.h + * + * Synopsis: + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.7 $ + * $Date: 1997/02/11 08:32:02 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sched.h,v $ + * + **************************************************************************/ + +#ifndef __sched__ +#define __sched__ + +#include + +#define OS_SC_STACKSIZE 0x2000 + +#define OS_SC_RETRACE_MSG 1 +#define OS_SC_DONE_MSG 2 +#define OS_SC_RDP_DONE_MSG 3 +#define OS_SC_PRE_NMI_MSG 4 +#define OS_SC_LAST_MSG 4 /* this should have highest number */ +#define OS_SC_MAX_MESGS 8 + +typedef struct { + short type; + char misc[30]; +} OSScMsg; + +typedef struct OSScTask_s { + struct OSScTask_s *next; /* note: this must be first */ + u32 state; + u32 flags; + void *framebuffer; /* used by graphics tasks */ + + OSTask list; + OSMesgQueue *msgQ; + OSMesg msg; +#ifndef _FINALROM /* all #ifdef items should */ + OSTime startTime; /* remain at the end!!, or */ + OSTime totalTime; /* possible conflict if */ +#endif /* FINALROM library used with */ +} OSScTask; /* non FINALROM code */ + +/* + * OSScTask flags: + */ +#define OS_SC_NEEDS_RDP 0x0001 /* uses the RDP */ +#define OS_SC_NEEDS_RSP 0x0002 /* uses the RSP */ +#define OS_SC_DRAM_DLIST 0x0004 /* SP & DP communicate through DRAM */ +#define OS_SC_PARALLEL_TASK 0x0010 /* must be first gfx task on list */ +#define OS_SC_LAST_TASK 0x0020 /* last task in queue for frame */ +#define OS_SC_SWAPBUFFER 0x0040 /* swapbuffers when gfx task done */ + +#define OS_SC_RCP_MASK 0x0003 /* mask for needs bits */ +#define OS_SC_TYPE_MASK 0x0007 /* complete type mask */ +/* + * OSScClient: + * + * Data structure used by threads that wish to communicate to the + * scheduling thread + * + */ +typedef struct SCClient_s { + struct SCClient_s *next; /* next client in the list */ + OSMesgQueue *msgQ; /* where to send the frame msg */ +} OSScClient; + +typedef struct { + OSScMsg retraceMsg; + OSScMsg prenmiMsg; + OSMesgQueue interruptQ; + OSMesg intBuf[OS_SC_MAX_MESGS]; + OSMesgQueue cmdQ; + OSMesg cmdMsgBuf[OS_SC_MAX_MESGS]; + OSThread thread; + OSScClient *clientList; + OSScTask *audioListHead; + OSScTask *gfxListHead; + OSScTask *audioListTail; + OSScTask *gfxListTail; + OSScTask *curRSPTask; + OSScTask *curRDPTask; + u32 frameCount; + s32 doAudio; +} OSSched; + +void osCreateScheduler(OSSched *s, void *stack, OSPri priority, + u8 mode, u8 numFields); +void osScAddClient(OSSched *s, OSScClient *c, OSMesgQueue *msgQ); +void osScRemoveClient(OSSched *s, OSScClient *c); +OSMesgQueue *osScGetCmdQ(OSSched *s); + +#endif + diff --git a/include/PR/sp.h b/include/PR/sp.h new file mode 100644 index 000000000..8167ca234 --- /dev/null +++ b/include/PR/sp.h @@ -0,0 +1,196 @@ +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Sprite library include file + * + * $Revision: 1.16 $ + * $Date: 1998/04/17 05:03:46 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sp.h,v $ + * + **************************************************************************/ + +#ifndef _SP_H_ +#define _SP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +struct bitmap { + s16 width; /* Size across to draw in texels */ + /* Done if width = 0 */ + + s16 width_img; /* Size across of bitmap in texels */ + /* Done if width = 0 */ + + s16 s; /* Horizontal offset into bitmap */ + /* if (s > width), then load only! */ + + s16 t; /* Vertical offset into base */ + + void *buf; /* Pointer to bitmap data */ + /* Don't re-load if new buf */ + /* is the same as the old one */ + /* Skip if NULL */ + + s16 actualHeight; /* True Height of this bitmap piece */ + + s16 LUToffset; /* LUT base index */ +}; + +typedef struct bitmap Bitmap; + +struct sprite { + s16 x,y; /* Target position */ + + s16 width, height; /* Target size */ + + f32 scalex, scaley; /* Texel to Pixel scale factor */ + + s16 expx, expy; /* Explosion spacing */ + + u16 attr; /* Attribute Flags */ + s16 zdepth; /* Z Depth */ + + u8 red; /* Red component */ + u8 green; /* Green component */ + u8 blue; /* Blue component */ + u8 alpha; /* Alpha component */ + + s16 startTLUT; /* Lookup Table Entry Starting index */ + s16 nTLUT; /* Total number of Lookup Table Entries */ + + int *LUT; /* Pointer to Lookup Table */ + + s16 istart; /* Starting bitmap index */ + s16 istep; /* Bitmaps index step (see SP_INCY) */ + /* if 0, then variable width bitmaps */ + + s16 nbitmaps; /* Total number of bitmaps */ + s16 ndisplist; /* Total number of display-list words */ + + s16 bmheight; /* Bitmap Texel height (Used) */ + s16 bmHreal; /* Bitmap Texel height (Real) */ + u8 bmfmt; /* Bitmap Format */ + u8 bmsiz; /* Bitmap Texel Size */ + + Bitmap *bitmap; /* Pointer to first bitmap */ + + Gfx *rsp_dl; /* Pointer to RSP display list */ + + Gfx *rsp_dl_next; /* Pointer to next RSP display entry */ + + s16 frac_s, /* Fractional Texture offsets */ + frac_t; /* These have 5 fraction bits */ +}; + +typedef struct sprite Sprite; + +/* + * DANGER! + * This is bad programming. Where the *heck* do these numbers come + * from? + * + * They are obviously 'maximums' from the sprite library, but since + * the sprite library is built on top of gbi.h, which includes macros + * that decode into multiple macros, etc., it is nearly impossible to + * know what these maximums should be. + * + * Worse, there are some gbi macros (texture alignment mostly) that + * decode into *many* macros, so if we choose that as a maximum, we + * are wasting TONS of space... + * + * These numbers work for "reasonable" sprite library usage, and + * there is an assert() in the library to detect when they aren't + * enough. (use the debug version) + */ +#define DL_BM_OVERHEAD (12) +#define DL_SPRITE_OVERHEAD (24) + +#define NUM_DL(nb) ((nb)*DL_BM_OVERHEAD +DL_SPRITE_OVERHEAD) + +/* + * Misc constants + */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +/* + * For sprite->attr + */ + +#define SP_TRANSPARENT 0x00000001 +#define SP_CUTOUT 0x00000002 +#define SP_HIDDEN 0x00000004 +#define SP_Z 0x00000008 +#define SP_SCALE 0x00000010 +#define SP_FASTCOPY 0x00000020 +#define SP_OVERLAP 0x00000040 +#define SP_TEXSHIFT 0x00000080 +#define SP_FRACPOS 0x00000100 +#define SP_TEXSHUF 0x00000200 +#define SP_EXTERN 0x00000400 + +/* + * Function wrapper + */ +#if defined(F3DEX_GBI_2) +#define spMove spX2Move +#define spSetZ spX2SetZ +#define spScissor spX2Scissor +#define spDraw spX2Draw +#define spInit spX2Init +#define spFinish spX2Finish +#elif defined(F3DEX_GBI) +#define spMove spXMove +#define spSetZ spXSetZ +#define spScissor spXScissor +#define spDraw spXDraw +#define spInit spXInit +#define spFinish spXFinish +#endif + +/* + * Function prototypes + */ + +void spSetAttribute (Sprite *sp, s32 attr); +void spClearAttribute (Sprite *sp, s32 attr); +void spMove (Sprite *sp, s32 x, s32 y); +void spScale (Sprite *sp, f32 sx, f32 sy); +void spSetZ (Sprite *sp, s32 z ); +void spColor (Sprite *sp, u8 red, u8 green, u8 blue, u8 alpha); +Gfx *spDraw (Sprite *sp); +void spInit( Gfx **glistp ); +void spScissor( s32 xmin, s32 xmax, s32 ymin, s32 ymax ); +void spFinish( Gfx **glistp ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* _SP_H_ */ diff --git a/include/PR/sptask.h b/include/PR/sptask.h index ec443ef42..960cab9b0 100644 --- a/include/PR/sptask.h +++ b/include/PR/sptask.h @@ -1,116 +1,201 @@ -#ifndef _ULTRA64_SPTASK_H_ -#define _ULTRA64_SPTASK_H_ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ -/* Task Types */ -#define M_GFXTASK 1 -#define M_AUDTASK 2 -#define M_VIDTASK 3 -#define M_HVQTASK 6 -#define M_HVQMTASK 7 +/************************************************************************** + * + * $Revision: 1.9 $ + * $Date: 1998/03/05 06:40:29 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sptask.h,v $ + * + **************************************************************************/ -#if (defined(F3DEX_GBI) || defined(F3DLP_GBI) || defined(F3DEX_GBI_2)) -#define OS_YIELD_DATA_SIZE 0xc00 -#else -#define OS_YIELD_DATA_SIZE 0x900 -#endif -#define OS_YIELD_AUDIO_SIZE 0x400 +#ifndef _SPTASK_H_ +#define _SPTASK_H_ -/* Flags */ -#define M_TASK_FLAG0 1 -#define M_TASK_FLAG1 2 -#ifdef VERSION_SH -#define M_TASK_FLAG2 4 +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { #endif -/* SpStatus */ -#define SPSTATUS_CLEAR_HALT 0x00000001 -#define SPSTATUS_SET_HALT 0x00000002 -#define SPSTATUS_CLEAR_BROKE 0x00000004 -#define SPSTATUS_CLEAR_INTR 0x00000008 -#define SPSTATUS_SET_INTR 0x00000010 -#define SPSTATUS_CLEAR_SSTEP 0x00000020 -#define SPSTATUS_SET_SSTEP 0x00000040 -#define SPSTATUS_CLEAR_INTR_ON_BREAK 0x00000080 -#define SPSTATUS_SET_INTR_ON_BREAK 0x00000100 -#define SPSTATUS_CLEAR_SIGNAL0 0x00000200 -#define SPSTATUS_SET_SIGNAL0 0x00000400 -#define SPSTATUS_CLEAR_SIGNAL1 0x00000800 -#define SPSTATUS_SET_SIGNAL1 0x00001000 -#define SPSTATUS_CLEAR_SIGNAL2 0x00002000 -#define SPSTATUS_SET_SIGNAL2 0x00004000 -#define SPSTATUS_CLEAR_SIGNAL3 0x00008000 -#define SPSTATUS_SET_SIGNAL3 0x00010000 -#define SPSTATUS_CLEAR_SIGNAL4 0x00020000 -#define SPSTATUS_SET_SIGNAL4 0x00040000 -#define SPSTATUS_CLEAR_SIGNAL5 0x00080000 -#define SPSTATUS_SET_SIGNAL5 0x00100000 -#define SPSTATUS_CLEAR_SIGNAL6 0x00200000 -#define SPSTATUS_SET_SIGNAL6 0x00800000 -#define SPSTATUS_CLEAR_SIGNAL7 0x01000000 -#define SPSTATUS_SET_SIGNAL7 0x02000000 +#include -#define SPSTATUS_HALT 0x0001 -#define SPSTATUS_BROKE 0x0002 -#define SPSTATUS_DMA_BUSY 0x0004 -#define SPSTATUS_DMA_FULL 0x0008 -#define SPSTATUS_IO_FULL 0x0010 -#define SPSTATUS_SINGLE_STEP 0x0020 -#define SPSTATUS_INTERRUPT_ON_BREAK 0x0040 -#define SPSTATUS_SIGNAL0_SET 0x0080 -#define SPSTATUS_SIGNAL1_SET 0x0100 -#define SPSTATUS_SIGNAL2_SET 0x0200 -#define SPSTATUS_SIGNAL3_SET 0x0400 -#define SPSTATUS_SIGNAL4_SET 0x0800 -#define SPSTATUS_SIGNAL5_SET 0x1000 -#define SPSTATUS_SIGNAL6_SET 0x2000 -#define SPSTATUS_SIGNAL7_SET 0x4000 +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -/* Types */ -/* Types */ +/************************************************************************** + * + * Type definitions + * + */ -typedef struct -{ - /*0x00*/ u32 type; - /*0x04*/ u32 flags; +/* + * Task List Structure. + * + * Things an app might pass to the SP via the task list. + * Not every task ucode would need/use every field, but + * + * - type (audio, gfx, video, ...) + * - flags + * - wait for DP to drain before running new task + * - SEE BIT DEFINITIONS UNDER "Task Flags field" + * - pointer to boot ucode + * - size of boot ucode + * - pointer to ucode + * - size of ucode + * - pointer to initial DMEM data + * - size of initial DMEM data + * - pointer to DRAM stack + * - size of DRAM stack (max) + * - pointer to output buffer + * - pointer to store output buffer length + * - generic data pointer (for display list, etc.) + * - generic data length (for display list, etc.) + * - pointer to buffer where to store saved DMEM (in yield case) + * - size of buffer to store saved DMEM. + * + * IMPORTANT!!! Watch alignment issues. + * + * IMPORTANT!!! Watch data cache issues. The RCP may write data into the + * dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas. + * These buffers should be cache aligned and use the entire line (16 bytes) to + * avoid corruption by writebacks by the CPU (cache tearing). + * + * IMPORTANT!!! all addresses are virtual addresses. Library does + * any necessary translation. + * + */ +typedef struct { + u32 type; + u32 flags; - /*0x08*/ u64 *ucode_boot; - /*0x0C*/ u32 ucode_boot_size; + u64 *ucode_boot; + u32 ucode_boot_size; - /*0x10*/ u64 *ucode; - /*0x14*/ u32 ucode_size; + u64 *ucode; + u32 ucode_size; - /*0x18*/ u64 *ucode_data; - /*0x1C*/ u32 ucode_data_size; + u64 *ucode_data; + u32 ucode_data_size; - /*0x20*/ u64 *dram_stack; - /*0x24*/ u32 dram_stack_size; + u64 *dram_stack; + u32 dram_stack_size; - /*0x28*/ u64 *output_buff; - /*0x2C*/ u64 *output_buff_size; + u64 *output_buff; + u64 *output_buff_size; - /*0x30*/ u64 *data_ptr; - /*0x34*/ u32 data_size; + u64 *data_ptr; + u32 data_size; - /*0x38*/ u64 *yield_data_ptr; - /*0x3C*/ u32 yield_data_size; -} OSTask_t; // size = 0x40 + u64 *yield_data_ptr; + u32 yield_data_size; + +} OSTask_t; typedef union { - OSTask_t t; - long long int force_structure_alignment; + OSTask_t t; + long long int force_structure_alignment; } OSTask; typedef u32 OSYieldResult; -/* Functions */ +#endif /* _LANGUAGE_C */ -#define osSpTaskStart(p) \ - osSpTaskLoad(p); \ - osSpTaskStartGo(p); +#ifdef _LANGUAGE_ASSEMBLY -void osSpTaskLoad(OSTask *task); -void osSpTaskStartGo(OSTask *task); -void osSpTaskYield(void); -OSYieldResult osSpTaskYielded(OSTask *task); +/* + * For the RSP ucode: + * offsets into the task structure + */ + +#include #endif + +/* + * Task Flags field + */ +#define OS_TASK_YIELDED 0x0001 +#define OS_TASK_DP_WAIT 0x0002 +#define OS_TASK_LOADABLE 0x0004 +#define OS_TASK_SP_ONLY 0x0008 +#define OS_TASK_USR0 0x0010 +#define OS_TASK_USR1 0x0020 +#define OS_TASK_USR2 0x0040 +#define OS_TASK_USR3 0x0080 + +/* + * Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a + * buffer of this size. (The size is in bytes). ONLY If the task will NEVER + * yield it may be a null pointer. The buffer must be aligned to a 64 bit + * boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the + * buffer BEFORE the task is started. + */ +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)||defined(F3DEX_GBI_2)) +#define OS_YIELD_DATA_SIZE 0xc00 +#else +#define OS_YIELD_DATA_SIZE 0x900 +#endif +#define OS_YIELD_AUDIO_SIZE 0x400 + +/************************************************************************** + * + * Global definitions + * + */ + + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * this macro simulates atomic action. + */ +#define osSpTaskStart(tp) \ + { \ + osSpTaskLoad((tp)); \ + osSpTaskStartGo((tp)); \ + } + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* + * break this up into two steps for debugging. + */ +extern void osSpTaskLoad(OSTask *tp); +extern void osSpTaskStartGo(OSTask *tp); + +extern void osSpTaskYield(void); +extern OSYieldResult osSpTaskYielded(OSTask *tp); + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_SPTASK_H */ diff --git a/include/PR/sptaskoff.h b/include/PR/sptaskoff.h new file mode 100644 index 000000000..12267af84 --- /dev/null +++ b/include/PR/sptaskoff.h @@ -0,0 +1,17 @@ +#define OS_TASK_SIZE 128 +#define OS_TASK_OFF_TYPE 0 +#define OS_TASK_OFF_FLAGS 8 +#define OS_TASK_OFF_UBOOT 16 +#define OS_TASK_OFF_UBOOT_SZ 24 +#define OS_TASK_OFF_UCODE 32 +#define OS_TASK_OFF_UCODE_SZ 40 +#define OS_TASK_OFF_UDATA 48 +#define OS_TASK_OFF_UDATA_SZ 56 +#define OS_TASK_OFF_STACK 64 +#define OS_TASK_OFF_STACK_SZ 72 +#define OS_TASK_OFF_OUTBUFF 80 +#define OS_TASK_OFF_OUTBUFF_SZ 88 +#define OS_TASK_OFF_DATA 96 +#define OS_TASK_OFF_DATA_SZ 104 +#define OS_TASK_OFF_YIELD 112 +#define OS_TASK_OFF_YIELD_SZ 120 diff --git a/include/PR/trace.h b/include/PR/trace.h new file mode 100644 index 000000000..dc64a1a52 --- /dev/null +++ b/include/PR/trace.h @@ -0,0 +1,82 @@ +#ifndef _TRACE_H_ +#define _TRACE_H_ + + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + + +/************************************************************************** + * + * Module: trace.h + * + * $Revision: 1.1.1.2 $ + * $Date: 2002/10/29 08:06:34 $ + * $Author: blythe $ + * $Source: /home/ryzen/cvsaaaa/depot/rf/sw/n64os20l/include/trace.h,v $ + * + * Description: + * This file contains debbuging and tracing macros + * + **************************************************************************/ + + +/*************************************** + * + * Macro definitions + * + */ + +/* Debug macros */ + +#ifdef _TRACE +#undef _TRACE +#endif + +#ifdef _DEBUG + +#if defined( _EMULATOR ) || ( _INDY_TARGET ) +extern unsigned long Dflags; /* Global debug flag */ + + /* Debug flag settings */ +#define DALL 0xFFFFFFFF /* Turn on all debug types */ +#define DERROR 0x00000001 /* Turn on error tracing */ +#define DTHREAD 0x00000002 /* Turn on thread tracing */ +#define DTIMER 0x00000004 /* Turn on timer tracing */ +#define DMESSAGE 0x00000008 /* Turn on message tracing */ +#define DMEMORY 0x00000010 /* Turn on memory tracing */ +#define DREGION 0x00000020 /* Turn on region tracing */ + +#define _TRACE(type, code) { if (Dflags & (type)) \ + { printf("%s, %d: ", __FILE__, __LINE__); code; } } +#else + +#define _TRACE(type, code) + +#endif /* _EMULATOR | _INDY_TARGET */ + +#else + +#define _TRACE(type, code) + +#endif /* _DEBUG */ + + +/*************************************** + * + * Extern function prototypes + * + */ + + +#endif /* _TRACE_H_ */ + diff --git a/include/PR/ucode.h b/include/PR/ucode.h index 37fd19775..9916fdd03 100644 --- a/include/PR/ucode.h +++ b/include/PR/ucode.h @@ -1,12 +1,242 @@ -#ifndef _ULTRA64_UCODE_H_ -#define _ULTRA64_UCODE_H_ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ -#define SP_DRAM_STACK_SIZE8 0x400 -#define SP_UCODE_SIZE 0x1000 -#define SP_UCODE_DATA_SIZE 0x800 +/************************************************************************** + * + * $Revision: 1.15 $ + * $Date: 1998/03/31 07:58:57 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ucode.h,v $ + * + **************************************************************************/ -// standard boot ucode -extern u64 rspF3DBootStart[], rspF3DBootEnd[]; +#ifndef _UCODE_H_ +#define _UCODE_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * This is the recommended size of the SP DRAM stack area, used + * by the graphics ucode. This stack is used primarily for the + * matrix stack, so it needs to be AT LEAST (10 * 64bytes) in size. + */ +#define SP_DRAM_STACK_SIZE8 (1024) +#define SP_DRAM_STACK_SIZE64 (SP_DRAM_STACK_SIZE8 >> 3) + +/* + * This is the size of the IMEM, which is also the size of the + * graphics microcode. (other ucode might be less) + * This value is used in apps to tell the OS how much ucode to + * load. + */ +#define SP_UCODE_SIZE 4096 + +/* + * This is 1/2 the size of DMEM, which is the maximum amount of + * initialized DMEM data any of the ucode tasks need to start up. + * This value is dependent on all of the task ucodes, and is therefore + * fixed per release. + */ +#define SP_UCODE_DATA_SIZE 2048 + + +/************************************************************************** + * + * Extern variables + * + */ + +/* + * Symbols generated by "rsp2elf", included by "makerom" that indicate + * the location and size of the SP microcode objects. The ucode objects + * are loaded as part of the codesegment (arbitrary, could do other + * ways) + * + */ + +/* standard boot ucode: */ +extern u64 rspbootTextStart[], rspbootTextEnd[]; + +/* standard 3D ucode: */ +extern u64 gspFast3DTextStart[], gspFast3DTextEnd[]; +extern u64 gspFast3DDataStart[], gspFast3DDataEnd[]; + +/* 3D ucode with output to DRAM: */ +extern u64 gspFast3D_dramTextStart[], gspFast3D_dramTextEnd[]; +extern u64 gspFast3D_dramDataStart[], gspFast3D_dramDataEnd[]; + +/* 3D ucode with output through DRAM FIFO to RDP: */ +extern u64 gspFast3D_fifoTextStart[], gspFast3D_fifoTextEnd[]; +extern u64 gspFast3D_fifoDataStart[], gspFast3D_fifoDataEnd[]; + +/* 3D ucode without nearclip: */ +extern u64 gspF3DNoNTextStart[], gspF3DNoNTextEnd[]; +extern u64 gspF3DNoNDataStart[], gspF3DNoNDataEnd[]; + +/* 3D ucode without nearclip with output to DRAM: */ +extern u64 gspF3DNoN_dramTextStart[]; +extern u64 gspF3DNoN_dramTextEnd[]; +extern u64 gspF3DNoN_dramDataStart[]; +extern u64 gspF3DNoN_dramDataEnd[]; + +/* 3D ucode without nearclip with output through DRAM FIFO to RDP: */ +extern u64 gspF3DNoN_fifoTextStart[]; +extern u64 gspF3DNoN_fifoTextEnd[]; +extern u64 gspF3DNoN_fifoDataStart[]; +extern u64 gspF3DNoN_fifoDataEnd[]; + +/* 3D line ucode: */ +extern u64 gspLine3DTextStart[], gspLine3DTextEnd[]; +extern u64 gspLine3DDataStart[], gspLine3DDataEnd[]; + +/* 3D line ucode with output to DRAM: */ +extern u64 gspLine3D_dramTextStart[], gspLine3D_dramTextEnd[]; +extern u64 gspLine3D_dramDataStart[], gspLine3D_dramDataEnd[]; + +/* 3D line ucode with output through DRAM FIFO to RDP: */ +extern u64 gspLine3D_fifoTextStart[], gspLine3D_fifoTextEnd[]; +extern u64 gspLine3D_fifoDataStart[], gspLine3D_fifoDataEnd[]; + +/* super 3D ucode: */ +extern long long int gspSuper3DTextStart[], gspSuper3DTextEnd[]; +extern long long int gspSuper3DDataStart[], gspSuper3DDataEnd[]; + +/* 3D ucode with output to DRAM: */ +extern long long int gspSuper3D_dramTextStart[], gspSuper3D_dramTextEnd[]; +extern long long int gspSuper3D_dramDataStart[], gspSuper3D_dramDataEnd[]; + +/* 3D ucode with output through DRAM FIFO to RDP: */ +extern long long int gspSuper3D_fifoTextStart[], gspSuper3D_fifoTextEnd[]; +extern long long int gspSuper3D_fifoDataStart[], gspSuper3D_fifoDataEnd[]; + + +/* 2D sprite ucode: */ +extern u64 gspSprite2DTextStart[], gspSprite2DTextEnd[]; +extern u64 gspSprite2DDataStart[], gspSprite2DDataEnd[]; + +/* 2D sprite ucode with output to DRAM: */ +extern u64 gspSprite2D_dramTextStart[], gspSprite2D_dramTextEnd[]; +extern u64 gspSprite2D_dramDataStart[], gspSprite2D_dramDataEnd[]; + +/* 2D sprite ucode with output through DRAM FIFO to RDP: */ +extern u64 gspSprite2D_fifoTextStart[], gspSprite2D_fifoTextEnd[]; +extern u64 gspSprite2D_fifoDataStart[], gspSprite2D_fifoDataEnd[]; + +/* basic audio ucode: */ +extern u64 aspMainTextStart[], aspMainTextEnd[]; +extern u64 aspMainDataStart[], aspMainDataEnd[]; + +/*========== F3DEX/F3DLX/F3DLP/L3DEX ==========*/ +/* FIFO version only */ +extern u64 gspF3DEX_fifoTextStart[], gspF3DEX_fifoTextEnd[]; +extern u64 gspF3DEX_fifoDataStart[], gspF3DEX_fifoDataEnd[]; +extern u64 gspF3DEX_NoN_fifoTextStart[], gspF3DEX_NoN_fifoTextEnd[]; +extern u64 gspF3DEX_NoN_fifoDataStart[], gspF3DEX_NoN_fifoDataEnd[]; + +extern u64 gspF3DLX_fifoTextStart[], gspF3DLX_fifoTextEnd[]; +extern u64 gspF3DLX_fifoDataStart[], gspF3DLX_fifoDataEnd[]; +extern u64 gspF3DLX_NoN_fifoTextStart[], gspF3DLX_NoN_fifoTextEnd[]; +extern u64 gspF3DLX_NoN_fifoDataStart[], gspF3DLX_NoN_fifoDataEnd[]; +extern u64 gspF3DLX_Rej_fifoTextStart[], gspF3DLX_Rej_fifoTextEnd[]; +extern u64 gspF3DLX_Rej_fifoDataStart[], gspF3DLX_Rej_fifoDataEnd[]; + +extern u64 gspF3DLP_Rej_fifoTextStart[], gspF3DLP_Rej_fifoTextEnd[]; +extern u64 gspF3DLP_Rej_fifoDataStart[], gspF3DLP_Rej_fifoDataEnd[]; +extern u64 gspL3DEX_fifoTextStart[], gspL3DEX_fifoTextEnd[]; +extern u64 gspL3DEX_fifoDataStart[], gspL3DEX_fifoDataEnd[]; + +/*========== F3DEX2/F3DLX2/F3DLP2/L3DEX2 ==========*/ +/* FIFO version */ +extern u64 gspF3DEX2_fifoTextStart[], gspF3DEX2_fifoTextEnd[]; +extern u64 gspF3DEX2_fifoDataStart[], gspF3DEX2_fifoDataEnd[]; +extern u64 gspF3DEX2_NoN_fifoTextStart[],gspF3DEX2_NoN_fifoTextEnd[]; +extern u64 gspF3DEX2_NoN_fifoDataStart[],gspF3DEX2_NoN_fifoDataEnd[]; +extern u64 gspF3DEX2_Rej_fifoTextStart[],gspF3DEX2_Rej_fifoTextEnd[]; +extern u64 gspF3DEX2_Rej_fifoDataStart[],gspF3DEX2_Rej_fifoDataEnd[]; +extern u64 gspF3DLX2_Rej_fifoTextStart[],gspF3DLX2_Rej_fifoTextEnd[]; +extern u64 gspF3DLX2_Rej_fifoDataStart[],gspF3DLX2_Rej_fifoDataEnd[]; +extern u64 gspL3DEX2_fifoTextStart[], gspL3DEX2_fifoTextEnd[]; +extern u64 gspL3DEX2_fifoDataStart[], gspL3DEX2_fifoDataEnd[]; + +/* XBUS version */ +extern u64 gspF3DEX2_xbusTextStart[], gspF3DEX2_xbusTextEnd[]; +extern u64 gspF3DEX2_xbusDataStart[], gspF3DEX2_xbusDataEnd[]; +extern u64 gspF3DEX2_NoN_xbusTextStart[],gspF3DEX2_NoN_xbusTextEnd[]; +extern u64 gspF3DEX2_NoN_xbusDataStart[],gspF3DEX2_NoN_xbusDataEnd[]; +extern u64 gspF3DEX2_Rej_xbusTextStart[],gspF3DEX2_Rej_xbusTextEnd[]; +extern u64 gspF3DEX2_Rej_xbusDataStart[],gspF3DEX2_Rej_xbusDataEnd[]; +extern u64 gspF3DLX2_Rej_xbusTextStart[],gspF3DLX2_Rej_xbusTextEnd[]; +extern u64 gspF3DLX2_Rej_xbusDataStart[],gspF3DLX2_Rej_xbusDataEnd[]; +extern u64 gspL3DEX2_xbusTextStart[], gspL3DEX2_xbusTextEnd[]; +extern u64 gspL3DEX2_xbusDataStart[], gspL3DEX2_xbusDataEnd[]; + +/*========== F3DZEX2/L3DZEX2 ==========*/ +/* FIFO version */ +extern u64 gspF3DZEX2_fifoTextStart[], + gspF3DZEX2_fifoTextEnd[]; +extern u64 gspF3DZEX2_fifoDataStart[], + gspF3DZEX2_fifoDataEnd[]; +extern u64 gspF3DZEX2_NoN_fifoTextStart[], + gspF3DZEX2_NoN_fifoTextEnd[]; +extern u64 gspF3DZEX2_NoN_fifoDataStart[], + gspF3DZEX2_NoN_fifoDataEnd[]; +extern u64 gspL3DZEX2_fifoTextStart[], + gspL3DZEX2_fifoTextEnd[]; +extern u64 gspL3DZEX2_fifoDataStart[], + gspL3DZEX2_fifoDataEnd[]; +/* XBUS version */ +extern u64 gspF3DZEX2_xbusTextStart[], + gspF3DZEX2_xbusTextEnd[]; +extern u64 gspF3DZEX2_xbusDataStart[], + gspF3DZEX2_xbusDataEnd[]; +extern u64 gspF3DZEX2_NoN_xbusTextStart[], + gspF3DZEX2_NoN_xbusTextEnd[]; +extern u64 gspF3DZEX2_NoN_xbusDataStart[], + gspF3DZEX2_NoN_xbusDataEnd[]; +extern u64 gspL3DZEX2_xbusTextStart[], + gspL3DZEX2_xbusTextEnd[]; +extern u64 gspL3DZEX2_xbusDataStart[], + gspL3DZEX2_xbusDataEnd[]; + +/*========== F3DZEX2/L3DZEX2 ==========*/ +extern u64 gspF3DZEX2_PosLight_fifoTextStart[], + gspF3DZEX2_PosLight_fifoTextEnd[]; +extern u64 gspF3DZEX2_PosLight_fifoDataStart[], + gspF3DZEX2_PosLight_fifoDataEnd[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[], + gspF3DZEX2_NoN_PosLight_fifoTextEnd[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[], + gspF3DZEX2_NoN_PosLight_fifoDataEnd[]; +extern u64 gspL3DZEX2_PosLight_fifoTextStart[], + gspL3DZEX2_PosLight_fifoTextEnd[]; +extern u64 gspL3DZEX2_PosLight_fifoDataStart[], + gspL3DZEX2_PosLight_fifoDataEnd[]; + +/************************************************************************** + * + * decomp ucode names + * + */ // F3D ucode extern u64 rspF3DStart[], rspF3DEnd[]; @@ -14,10 +244,17 @@ extern u64 rspF3DStart[], rspF3DEnd[]; // F3D ucode data extern u64 rspF3DDataStart[], rspF3DDataEnd[]; -// aspMain (audio) ucode -extern u64 rspAspMainStart[], rspAspMainEnd[]; -// aspMain ucode data -extern u64 rspAspMainDataStart[], rspAspMainDataEnd[]; +/************************************************************************** + * + * Function prototypes + * + */ +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} #endif + +#endif /* !_UCODE_H */ diff --git a/include/PR/ucode_debug.h b/include/PR/ucode_debug.h new file mode 100644 index 000000000..189a7f218 --- /dev/null +++ b/include/PR/ucode_debug.h @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------* + Copyright (C) 1998, Nintendo. + + File ucode_debug.h + Coded by Yoshitaka Yasumoto. Nov 15, 1998. + + $Id: ucode_debug.h,v 1.1 1998/12/25 01:06:21 has Exp $ + *---------------------------------------------------------------------*/ +#ifndef _UCODE_DEBUG_H_ +#define _UCODE_DEBUG_H_ + +#define DEBUG_DL_PTR() IO_READ(SP_DMEM_START+0xfc0) + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +/*========== F3DEX2/F3DLX2/L3DEX2/S2DEX2 ==========*/ +/* FIFO version */ +extern long long int gspF3DEX2d_fifoTextStart[], gspF3DEX2d_fifoTextEnd[]; +extern long long int gspF3DEX2d_fifoDataStart[], gspF3DEX2d_fifoDataEnd[]; +extern long long int gspF3DEX2d_NoN_fifoTextStart[],gspF3DEX2d_NoN_fifoTextEnd[]; +extern long long int gspF3DEX2d_NoN_fifoDataStart[],gspF3DEX2d_NoN_fifoDataEnd[]; +extern long long int gspF3DEX2d_Rej_fifoTextStart[],gspF3DEX2d_Rej_fifoTextEnd[]; +extern long long int gspF3DEX2d_Rej_fifoDataStart[],gspF3DEX2d_Rej_fifoDataEnd[]; +extern long long int gspF3DLX2d_Rej_fifoTextStart[],gspF3DLX2d_Rej_fifoTextEnd[]; +extern long long int gspF3DLX2d_Rej_fifoDataStart[],gspF3DLX2d_Rej_fifoDataEnd[]; +extern long long int gspL3DEX2d_fifoTextStart[], gspL3DEX2d_fifoTextEnd[]; +extern long long int gspL3DEX2d_fifoDataStart[], gspL3DEX2d_fifoDataEnd[]; +extern long long int gspS2DEX2d_fifoTextStart[], gspS2DEX2d_fifoTextEnd[]; +extern long long int gspS2DEX2d_fifoDataStart[], gspS2DEX2d_fifoDataEnd[]; + +/* XBUS version */ +extern long long int gspF3DEX2d_xbusTextStart[], gspF3DEX2d_xbusTextEnd[]; +extern long long int gspF3DEX2d_xbusDataStart[], gspF3DEX2d_xbusDataEnd[]; +extern long long int gspF3DEX2d_NoN_xbusTextStart[],gspF3DEX2d_NoN_xbusTextEnd[]; +extern long long int gspF3DEX2d_NoN_xbusDataStart[],gspF3DEX2d_NoN_xbusDataEnd[]; +extern long long int gspF3DEX2d_Rej_xbusTextStart[],gspF3DEX2d_Rej_xbusTextEnd[]; +extern long long int gspF3DEX2d_Rej_xbusDataStart[],gspF3DEX2d_Rej_xbusDataEnd[]; +extern long long int gspF3DLX2d_Rej_xbusTextStart[],gspF3DLX2d_Rej_xbusTextEnd[]; +extern long long int gspF3DLX2d_Rej_xbusDataStart[],gspF3DLX2d_Rej_xbusDataEnd[]; +extern long long int gspL3DEX2d_xbusTextStart[], gspL3DEX2d_xbusTextEnd[]; +extern long long int gspL3DEX2d_xbusDataStart[], gspL3DEX2d_xbusDataEnd[]; +extern long long int gspS2DEX2d_xbusTextStart[], gspS2DEX2d_xbusTextEnd[]; +extern long long int gspS2DEX2d_xbusDataStart[], gspS2DEX2d_xbusDataEnd[]; + +#endif /* _LANGUAGE_C */ +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* !_UCODE_DEBUG_H */ + +/*======== End of ucode_debug.h ========*/ diff --git a/include/PR/ultraerror.h b/include/PR/ultraerror.h new file mode 100644 index 000000000..b05b24a68 --- /dev/null +++ b/include/PR/ultraerror.h @@ -0,0 +1,179 @@ +/*==================================================================== + * ultraerror.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.27 $ + * $Date: 1999/07/14 02:44:00 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultraerror.h,v $ + * + **************************************************************************/ + +#ifndef __ULTRAERROR_H__ +#define __ULTRAERROR_H__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_ERROR_FMT "/usr/lib/PR/error.fmt" +#define OS_ERROR_MAGIC 0x6b617479 + +/* OS error codes */ + +#define ERR_OSCREATETHREAD_SP 1 +#define ERR_OSCREATETHREAD_PRI 2 +#define ERR_OSSTARTTHREAD 3 +#define ERR_OSSETTHREADPRI 4 +#define ERR_OSCREATEMESGQUEUE 5 +#define ERR_OSSENDMESG 6 +#define ERR_OSJAMMESG 7 +#define ERR_OSRECVMESG 8 +#define ERR_OSSETEVENTMESG 9 +#define ERR_OSMAPTLB_INDEX 10 +#define ERR_OSMAPTLB_ASID 11 +#define ERR_OSUNMAPTLB 12 +#define ERR_OSSETTLBASID 13 +#define ERR_OSAISETFREQUENCY 14 +#define ERR_OSAISETNEXTBUFFER_ADDR 15 +#define ERR_OSAISETNEXTBUFFER_SIZE 16 +#define ERR_OSDPSETNEXTBUFFER_ADDR 17 +#define ERR_OSDPSETNEXTBUFFER_SIZE 18 +#define ERR_OSPIRAWREADIO 19 +#define ERR_OSPIRAWWRITEIO 20 +#define ERR_OSPIRAWSTARTDMA_DIR 21 +#define ERR_OSPIRAWSTARTDMA_DEVADDR 22 +#define ERR_OSPIRAWSTARTDMA_ADDR 23 +#define ERR_OSPIRAWSTARTDMA_SIZE 24 +#define ERR_OSPIRAWSTARTDMA_RANGE 25 +#define ERR_OSPIREADIO 26 +#define ERR_OSPIWRITEIO 27 +#define ERR_OSPISTARTDMA_PIMGR 28 +#define ERR_OSPISTARTDMA_PRI 29 +#define ERR_OSPISTARTDMA_DIR 30 +#define ERR_OSPISTARTDMA_DEVADDR 31 +#define ERR_OSPISTARTDMA_ADDR 32 +#define ERR_OSPISTARTDMA_SIZE 33 +#define ERR_OSPISTARTDMA_RANGE 34 +#define ERR_OSCREATEPIMANAGER 35 +#define ERR_OSVIGETCURRENTMODE 36 +#define ERR_OSVIGETCURRENTFRAMEBUFFER 37 +#define ERR_OSVIGETNEXTFRAMEBUFFER 38 +#define ERR_OSVISETXSCALE_VALUE 39 +#define ERR_OSVISETXSCALE_VIMGR 40 +#define ERR_OSVISETYSCALE_VALUE 41 +#define ERR_OSVISETYSCALE_VIMGR 42 +#define ERR_OSVISETSPECIAL_VALUE 43 +#define ERR_OSVISETSPECIAL_VIMGR 44 +#define ERR_OSVISETMODE 45 +#define ERR_OSVISETEVENT 46 +#define ERR_OSVISWAPBUFFER_ADDR 47 +#define ERR_OSVISWAPBUFFER_VIMGR 48 +#define ERR_OSCREATEVIMANAGER 49 +#define ERR_OSCREATEREGION_ALIGN 50 +#define ERR_OSCREATEREGION_SIZE 51 +#define ERR_OSMALLOC 52 +#define ERR_OSFREE_REGION 53 +#define ERR_OSFREE_ADDR 54 +#define ERR_OSGETREGIONBUFCOUNT 55 +#define ERR_OSGETREGIONBUFSIZE 56 +#define ERR_OSSPTASKLOAD_DRAM 57 +#define ERR_OSSPTASKLOAD_OUT 58 +#define ERR_OSSPTASKLOAD_OUTSIZE 59 +#define ERR_OSSPTASKLOAD_YIELD 60 +#define ERR_OSPROFILEINIT_STR 61 +#define ERR_OSPROFILEINIT_CNT 62 +#define ERR_OSPROFILEINIT_ALN 63 +#define ERR_OSPROFILEINIT_ORD 64 +#define ERR_OSPROFILEINIT_SIZ 65 +#define ERR_OSPROFILESTART_TIME 66 +#define ERR_OSPROFILESTART_FLAG 67 +#define ERR_OSPROFILESTOP_FLAG 68 +#define ERR_OSPROFILESTOP_TIMER 69 +#define ERR_OSREADHOST_ADDR 70 +#define ERR_OSREADHOST_SIZE 71 +#define ERR_OSWRITEHOST_ADDR 72 +#define ERR_OSWRITEHOST_SIZE 73 +#define ERR_OSGETTIME 74 +#define ERR_OSSETTIME 75 +#define ERR_OSSETTIMER 76 +#define ERR_OSSTOPTIMER 77 +#define ERR_ALSEQP_NO_SOUND 100 +#define ERR_ALSEQP_NO_VOICE 101 +#define ERR_ALSEQP_MAP_VOICE 102 +#define ERR_ALSEQP_OFF_VOICE 103 +#define ERR_ALSEQP_POLY_VOICE 104 +#define ERR_ALSNDP_NO_VOICE 105 +#define ERR_ALSYN_NO_UPDATE 106 +#define ERR_ALSNDPDEALLOCATE 107 +#define ERR_ALSNDPDELETE 108 +#define ERR_ALSNDPPLAY 109 +#define ERR_ALSNDPSETSOUND 110 +#define ERR_ALSNDPSETPRIORITY 111 +#define ERR_ALSNDPSETPAR 112 +#define ERR_ALBNKFNEW 113 +#define ERR_ALSEQNOTMIDI 114 +#define ERR_ALSEQNOTMIDI0 115 +#define ERR_ALSEQNUMTRACKS 116 +#define ERR_ALSEQTIME 117 +#define ERR_ALSEQTRACKHDR 118 +#define ERR_ALSEQSYSEX 119 +#define ERR_ALSEQMETA 120 +#define ERR_ALSEQPINVALIDPROG 121 +#define ERR_ALSEQPUNKNOWNMIDI 122 +#define ERR_ALSEQPUNMAP 123 +#define ERR_ALEVENTNOFREE 124 +#define ERR_ALHEAPNOFREE 125 +#define ERR_ALHEAPCORRUPT 126 +#define ERR_ALHEAPFIRSTBLOCK 127 +#define ERR_ALCSEQZEROSTATUS 128 +#define ERR_ALCSEQZEROVEL 129 +#define ERR_ALCSPVNOTFREE 130 +#define ERR_ALSEQOVERRUN 131 +#define ERR_OSAISETNEXTBUFFER_ENDADDR 132 +#define ERR_ALMODDELAYOVERFLOW 133 +#define ERR_OSVIEXTENDVSTART_VIMGR 134 +#define ERR_OSVIEXTENDVSTART_VALUE 135 +#define ERR_OSTHPROFILESTART_FLAG 136 +#define ERR_OSTHPROFILESTART_START 137 +#define ERR_OSTHPROFILESTOP_FLAG 138 +#define ERR_OSTHPROFILEREADCOUNT_FLAG 139 +#define ERR_OSTHPROFILEREADTIME_FLAG 140 +#define ERR_OSTHPROFILEREADCOUNTTH_FLAG 141 +#define ERR_OSTHPROFILEREADTIMETH_FLAG 142 +#define ERR_OSTHPROFILEREADCOUNT_LAR 143 +#define ERR_OSTHPROFILEREADTIME_LAR 144 +#define ERR_OSTHPROFILEREADCOUNTTH_LAR 145 +#define ERR_OSTHPROFILEREADTIMETH_LAR 146 +#define ERR_OSTHPROFILESTOP_LAR 147 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +typedef void (*OSErrorHandler)(s16, s16, ...); + +OSErrorHandler osSetErrorHandler(OSErrorHandler); +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __ULTRAERROR_H__ */ diff --git a/include/PR/ultralog.h b/include/PR/ultralog.h new file mode 100644 index 000000000..48b84b978 --- /dev/null +++ b/include/PR/ultralog.h @@ -0,0 +1,74 @@ +/*==================================================================== + * ultralog.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:39:05 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultralog.h,v $ + * + **************************************************************************/ + +#ifndef __log__ +#define __log__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_LOG_MAX_ARGS 16 +#define OS_LOG_MAGIC 0x20736a73 +#define OS_LOG_FLOAT(x) (*(int *) &(x)) +#define OS_LOG_VERSION 1 + +typedef struct { + u32 magic; /* log identifier */ + u32 len; /* length of log data + log structure */ + u32 *base; /* starting addr array */ + s32 startCount; /* read offset from dataBase */ + s32 writeOffset; /* write offset from dataBase */ +} OSLog; + +typedef struct { + u32 magic; + u32 timeStamp; + u16 argCount; + u16 eventID; +} OSLogItem; + +typedef struct { + u32 magic; /* log identifier */ + u32 version; /* 1 */ +} OSLogFileHdr; + +void osCreateLog(OSLog *log, u32 *base, s32 len); +void osLogEvent(OSLog *log, s16 code, s16 numArgs, ...); +void osFlushLog(OSLog *log); +u32 osLogFloat(f32); + +extern void osDelay(int count); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index 8a00490a7..057d6ffd1 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -1,12 +1,37 @@ -#ifndef _ULTRA64_TYPES_H_ -#define _ULTRA64_TYPES_H_ +#ifndef _ULTRATYPES_H_ +#define _ULTRATYPES_H_ -#ifndef NULL -#define NULL (void *)0 -#endif -#define TRUE 1 -#define FALSE 0 +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + + +/************************************************************************* + * + * File: ultratypes.h + * + * This file contains various types used in Ultra64 interfaces. + * + * $Revision: 1.6 $ + * $Date: 1997/12/17 04:02:06 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultratypes.h,v $ + * + **************************************************************************/ + + + +/********************************************************************** + * General data types for R4300 + */ typedef signed char s8; typedef unsigned char u8; @@ -14,8 +39,34 @@ typedef signed short int s16; typedef unsigned short int u16; typedef signed int s32; typedef unsigned int u32; + +typedef float f32; +typedef double f64; + +#ifdef TARGET_N64 typedef signed long long int s64; typedef unsigned long long int u64; +typedef u32 size_t; +typedef s32 ssize_t; +typedef u32 uintptr_t; +typedef s32 intptr_t; +typedef s32 ptrdiff_t; + +typedef s8 int8_t; +typedef u8 uint8_t; +typedef s16 int16_t; +typedef u16 uint16_t; +typedef s32 int32_t; +typedef u32 uint32_t; +typedef s64 int64_t; +typedef u64 uint64_t; +#else +#include +#include +typedef ptrdiff_t ssize_t; +typedef int64_t s64; +typedef uint64_t u64; +#endif typedef volatile u8 vu8; typedef volatile u16 vu16; @@ -26,19 +77,21 @@ typedef volatile s16 vs16; typedef volatile s32 vs32; 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 -#include -typedef ptrdiff_t ssize_t; +/************************************************************************* + * Common definitions + */ +#ifndef TRUE +#define TRUE 1 #endif +#ifndef FALSE +#define FALSE 0 #endif + +#ifndef NULL +#define NULL (void *)0 +#endif + +#endif /* _ULTRATYPES_H_ */ + diff --git a/include/PR/uportals.h b/include/PR/uportals.h new file mode 100644 index 000000000..129c47ceb --- /dev/null +++ b/include/PR/uportals.h @@ -0,0 +1,134 @@ +/*==================================================================== + * uportals.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * uportals.h - header file for the ultraportals library + * + * $Revision: 1.12 $ + * $Date: 1997/02/11 08:40:49 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/uportals.h,v $ + * + **************************************************************************/ + + + +#ifndef __ULTRAPORTALS_H__ +#define __ULTRAPORTALS_H__ + +#include +#include "matrix.h" +#include "vector.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ENABLEPORTALS +#define ENABLEPORTALS +#endif + +#define UP_MAXPVERTS 16 /* max number of portal verts */ +#define UP_MAXCELLS 50 /* max number of cells */ +#define UP_CELLNL 32 /* max length of cell names */ +#define UP_OBNL 32 /* max length of obejct names */ + +typedef struct +{ + vec3 min, max; /* min and max pts of the box */ +} upBox; + +typedef struct _upPortalData * _portalptr; +typedef struct _upCellData * _cellptr; +typedef struct _upObjectData * _objectptr; + +typedef struct _upPortalData +{ + int numverts; /* number of verts in the portal*/ + _cellptr attached_cell; /* cell on the 'other side' */ + vec3 verts[UP_MAXPVERTS]; /* the actual vertices */ +#ifdef MVTVIEW + int mvt_id; /* if has mvt, this is the id */ +#endif +} upPortalData; + +typedef struct _upCellData +{ + int numportals; /* number of portals */ + int numobjects; /* number of objects */ + int rendered; /* last frame number rendered */ + _portalptr *portals; /* array for the actual portals */ + _objectptr *objects; /* array for 'detail' objects */ + upBox bbox; /* bounding box of the cell */ + Gfx *dlist; /* associated display list */ + char name[UP_CELLNL]; /* name of the cell */ + float eyeheight; /* height to constrain eyept to */ + int zone; /* current zone number */ +} upCellData; + +typedef struct _upObjectData +{ + int rendered; /* last frame number rendered */ + upBox bbox; /* bounding box for the object */ + Gfx *dlist; /* associated display list */ + char name[UP_OBNL]; /* name of the object */ +} upObjectData; + +typedef struct +{ + int numcells; /* how many cells are there? */ + upCellData cells[UP_MAXCELLS]; /* the actual cells */ + Gfx *rootdlist; /* display list for all cells */ + vec2 portalmin, portalmax; /* XY bbox used by upCheckCells */ + float near, far; /* near, far clipping planes */ + FMatrix viewmat; /* viewing matrix (world->eye) */ + FMatrix projmat; /* proj matrix (eye->screen) */ + FMatrix compmat; /* view * proj (world->screen) */ + int portaldepth; /* depth of the portal stack */ + int framecount; /* current frame number */ +} upLocateData; + +/* + * Functions: + */ +extern void upInit(); /* generated automatically by flt2walk */ +extern Gfx *upAddVisibleCells(Gfx * glistp, vec3 eyept); +extern void upTogglePortalBounds(); +extern void upToggleScissorBox(); + +/* + * Globals: + */ +extern upLocateData upLocator; /* also extern by test_portals.h */ + +/* + * Macros: + */ +#define UP_HUGEVAL 3.40282347e+37 +#define PT_IN_BOX(p,box) ((p)[0] > (box).min[0] && (p)[0] < (box).max[0] &&\ + (p)[1] > (box).min[1] && (p)[1] < (box).max[1] &&\ + (p)[2] > (box).min[2] && (p)[2] < (box).max[2]) + + +#ifdef __Cplusplus +} +#endif + +#endif diff --git a/include/level_commands.h b/include/level_commands.h index f2490fe1c..4a69b4c97 100644 --- a/include/level_commands.h +++ b/include/level_commands.h @@ -144,7 +144,7 @@ CMD_PTR(NULL), \ CMD_PTR(NULL) -#define LOAD_MIO0(seg, romStart, romEnd) \ +#define LOAD_YAY0(seg, romStart, romEnd) \ CMD_BBH(0x18, 0x0C, 0x0000), \ CMD_PTR(NULL), \ CMD_PTR(NULL) @@ -160,7 +160,7 @@ CMD_PTR(romStart), \ CMD_PTR(romEnd) -#define LOAD_MIO0(seg, romStart, romEnd) \ +#define LOAD_YAY0(seg, romStart, romEnd) \ CMD_BBH(0x18, 0x0C, seg), \ CMD_PTR(romStart), \ CMD_PTR(romEnd) @@ -170,12 +170,12 @@ CMD_BBH(0x19, 0x04, sethead) #ifdef NO_SEGMENTED_MEMORY -#define LOAD_MIO0_TEXTURE(seg, romStart, romEnd) \ +#define LOAD_YAY0_TEXTURE(seg, romStart, romEnd) \ CMD_BBH(0x1A, 0x0C, 0x0000), \ CMD_PTR(NULL), \ CMD_PTR(NULL) #else -#define LOAD_MIO0_TEXTURE(seg, romStart, romEnd) \ +#define LOAD_YAY0_TEXTURE(seg, romStart, romEnd) \ CMD_BBH(0x1A, 0x0C, seg), \ CMD_PTR(romStart), \ CMD_PTR(romEnd) diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 306a998f3..42cf2c415 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -7,7 +7,7 @@ extern u8 _##name##SegmentRomEnd[]; #define DECLARE_ACTOR_SEGMENT(name) \ - DECLARE_SEGMENT(name##_mio0) \ + DECLARE_SEGMENT(name##_yay0) \ DECLARE_SEGMENT(name##_geo) #define DECLARE_LEVEL_SEGMENT(name) \ @@ -59,40 +59,40 @@ DECLARE_LEVEL_SEGMENT(ending) #undef STUB_LEVEL #undef DEFINE_LEVEL -DECLARE_SEGMENT(segment2_mio0) +DECLARE_SEGMENT(segment2_yay0) -DECLARE_SEGMENT(water_skybox_mio0) -DECLARE_SEGMENT(ccm_skybox_mio0) -DECLARE_SEGMENT(clouds_skybox_mio0) -DECLARE_SEGMENT(bitfs_skybox_mio0) -DECLARE_SEGMENT(wdw_skybox_mio0) -DECLARE_SEGMENT(cloud_floor_skybox_mio0) -DECLARE_SEGMENT(ssl_skybox_mio0) -DECLARE_SEGMENT(bbh_skybox_mio0) -DECLARE_SEGMENT(bidw_skybox_mio0) -DECLARE_SEGMENT(bits_skybox_mio0) +DECLARE_SEGMENT(water_skybox_yay0) +DECLARE_SEGMENT(ccm_skybox_yay0) +DECLARE_SEGMENT(clouds_skybox_yay0) +DECLARE_SEGMENT(bitfs_skybox_yay0) +DECLARE_SEGMENT(wdw_skybox_yay0) +DECLARE_SEGMENT(cloud_floor_skybox_yay0) +DECLARE_SEGMENT(ssl_skybox_yay0) +DECLARE_SEGMENT(bbh_skybox_yay0) +DECLARE_SEGMENT(bidw_skybox_yay0) +DECLARE_SEGMENT(bits_skybox_yay0) -DECLARE_SEGMENT(fire_mio0) -DECLARE_SEGMENT(spooky_mio0) -DECLARE_SEGMENT(generic_mio0) -DECLARE_SEGMENT(water_mio0) -DECLARE_SEGMENT(sky_mio0) -DECLARE_SEGMENT(snow_mio0) -DECLARE_SEGMENT(cave_mio0) -DECLARE_SEGMENT(machine_mio0) -DECLARE_SEGMENT(mountain_mio0) -DECLARE_SEGMENT(grass_mio0) -DECLARE_SEGMENT(outside_mio0) -DECLARE_SEGMENT(inside_mio0) -DECLARE_SEGMENT(effect_mio0) -DECLARE_SEGMENT(title_screen_bg_mio0) +DECLARE_SEGMENT(fire_yay0) +DECLARE_SEGMENT(spooky_yay0) +DECLARE_SEGMENT(generic_yay0) +DECLARE_SEGMENT(water_yay0) +DECLARE_SEGMENT(sky_yay0) +DECLARE_SEGMENT(snow_yay0) +DECLARE_SEGMENT(cave_yay0) +DECLARE_SEGMENT(machine_yay0) +DECLARE_SEGMENT(mountain_yay0) +DECLARE_SEGMENT(grass_yay0) +DECLARE_SEGMENT(outside_yay0) +DECLARE_SEGMENT(inside_yay0) +DECLARE_SEGMENT(effect_yay0) +DECLARE_SEGMENT(title_screen_bg_yay0) -DECLARE_SEGMENT(debug_level_select_mio0) +DECLARE_SEGMENT(debug_level_select_yay0) #ifdef VERSION_EU -DECLARE_SEGMENT(translation_de_mio0) -DECLARE_SEGMENT(translation_en_mio0) -DECLARE_SEGMENT(translation_fr_mio0) +DECLARE_SEGMENT(translation_de_yay0) +DECLARE_SEGMENT(translation_en_yay0) +DECLARE_SEGMENT(translation_fr_yay0) #endif #endif diff --git a/include/ultra64.h b/include/ultra64.h index 409a3cf76..053db38ee 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -1,33 +1,40 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + *************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.10 $ + * $Date: 1997/02/11 08:37:33 $ + * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultra64.h,v $ + * + **************************************************************************/ + #ifndef _ULTRA64_H_ #define _ULTRA64_H_ -#include - -#ifndef _LANGUAGE_C -#define _LANGUAGE_C -#endif - #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include #endif diff --git a/levels/bbh/script.c b/levels/bbh/script.c index bfa043340..8c13b2eaf 100644 --- a/levels/bbh/script.c +++ b/levels/bbh/script.c @@ -78,14 +78,14 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_bbh_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _bbh_segment_7SegmentRomStart, _bbh_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _bbh_skybox_mio0SegmentRomStart, _bbh_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _spooky_mio0SegmentRomStart, _spooky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group9_mio0SegmentRomStart, _group9_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bbh_segment_7SegmentRomStart, _bbh_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bbh_skybox_yay0SegmentRomStart, _bbh_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _spooky_yay0SegmentRomStart, _spooky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group9_yay0SegmentRomStart, _group9_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group9_geoSegmentRomStart, _group9_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bitdw/script.c b/levels/bitdw/script.c index 5e14a7ee1..60bfc624f 100644 --- a/levels/bitdw/script.c +++ b/levels/bitdw/script.c @@ -45,14 +45,14 @@ static const LevelScript script_func_local_3[] = { const LevelScript level_bitdw_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _bitdw_segment_7SegmentRomStart, _bitdw_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _bidw_skybox_mio0SegmentRomStart, _bidw_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group11_mio0SegmentRomStart, _group11_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bitdw_segment_7SegmentRomStart, _bitdw_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bidw_skybox_yay0SegmentRomStart, _bidw_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group11_yay0SegmentRomStart, _group11_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group11_geoSegmentRomStart, _group11_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bitfs/script.c b/levels/bitfs/script.c index 56b108dcf..008d75479 100644 --- a/levels/bitfs/script.c +++ b/levels/bitfs/script.c @@ -52,15 +52,15 @@ static const LevelScript script_func_local_3[] = { const LevelScript level_bitfs_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _bitfs_segment_7SegmentRomStart, _bitfs_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _bitfs_skybox_mio0SegmentRomStart, _bitfs_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group2_mio0SegmentRomStart, _group2_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bitfs_segment_7SegmentRomStart, _bitfs_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bitfs_skybox_yay0SegmentRomStart, _bitfs_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group2_yay0SegmentRomStart, _group2_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group2_geoSegmentRomStart, _group2_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bits/script.c b/levels/bits/script.c index 2d1bd872d..3232dbc6f 100644 --- a/levels/bits/script.c +++ b/levels/bits/script.c @@ -45,12 +45,12 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_bits_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _bits_segment_7SegmentRomStart, _bits_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _bits_skybox_mio0SegmentRomStart, _bits_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group14_mio0SegmentRomStart, _group14_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bits_segment_7SegmentRomStart, _bits_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bits_skybox_yay0SegmentRomStart, _bits_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group14_yay0SegmentRomStart, _group14_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group14_geoSegmentRomStart, _group14_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bob/script.c b/levels/bob/script.c index ce7bf54c4..cdf8e14cc 100644 --- a/levels/bob/script.c +++ b/levels/bob/script.c @@ -55,14 +55,14 @@ static const LevelScript script_func_local_3[] = { const LevelScript level_bob_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _bob_segment_7SegmentRomStart, _bob_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _generic_mio0SegmentRomStart, _generic_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group3_mio0SegmentRomStart, _group3_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bob_segment_7SegmentRomStart, _bob_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _generic_yay0SegmentRomStart, _generic_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group3_yay0SegmentRomStart, _group3_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group3_geoSegmentRomStart, _group3_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group14_mio0SegmentRomStart, _group14_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group14_yay0SegmentRomStart, _group14_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group14_geoSegmentRomStart, _group14_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bowser_1/script.c b/levels/bowser_1/script.c index e70de9995..6c4bdd532 100644 --- a/levels/bowser_1/script.c +++ b/levels/bowser_1/script.c @@ -18,9 +18,9 @@ const LevelScript level_bowser_1_entry[] = { INIT_LEVEL(), - LOAD_MIO0(/*seg*/ 0x07, _bowser_1_segment_7SegmentRomStart, _bowser_1_segment_7SegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x0A, _bidw_skybox_mio0SegmentRomStart, _bidw_skybox_mio0SegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x06, _group12_mio0SegmentRomStart, _group12_mio0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x07, _bowser_1_segment_7SegmentRomStart, _bowser_1_segment_7SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x0A, _bidw_skybox_yay0SegmentRomStart, _bidw_skybox_yay0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x06, _group12_yay0SegmentRomStart, _group12_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group12_geoSegmentRomStart, _group12_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bowser_2/script.c b/levels/bowser_2/script.c index b848c00c6..0511bf1c5 100644 --- a/levels/bowser_2/script.c +++ b/levels/bowser_2/script.c @@ -26,11 +26,11 @@ static const LevelScript script_func_local_1[] = { const LevelScript level_bowser_2_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x0A, _bitfs_skybox_mio0SegmentRomStart, _bitfs_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _fire_mio0SegmentRomStart, _fire_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x07, _bowser_2_segment_7SegmentRomStart, _bowser_2_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group12_mio0SegmentRomStart, _group12_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bitfs_skybox_yay0SegmentRomStart, _bitfs_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _fire_yay0SegmentRomStart, _fire_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _bowser_2_segment_7SegmentRomStart, _bowser_2_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group12_yay0SegmentRomStart, _group12_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group12_geoSegmentRomStart, _group12_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/bowser_3/script.c b/levels/bowser_3/script.c index 756ef81b5..3d6df9bf7 100644 --- a/levels/bowser_3/script.c +++ b/levels/bowser_3/script.c @@ -36,10 +36,10 @@ static const LevelScript script_func_local_1[] = { const LevelScript level_bowser_3_entry[] = { INIT_LEVEL(), - LOAD_MIO0(/*seg*/ 0x07, _bowser_3_segment_7SegmentRomStart, _bowser_3_segment_7SegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x06, _group12_mio0SegmentRomStart, _group12_mio0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x07, _bowser_3_segment_7SegmentRomStart, _bowser_3_segment_7SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x06, _group12_yay0SegmentRomStart, _group12_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group12_geoSegmentRomStart, _group12_geoSegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x0A, _bits_skybox_mio0SegmentRomStart, _bits_skybox_mio0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x0A, _bits_skybox_yay0SegmentRomStart, _bits_skybox_yay0SegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), JUMP_LINK(script_func_global_13), diff --git a/levels/castle_courtyard/script.c b/levels/castle_courtyard/script.c index c17cc21a4..a532c56a4 100644 --- a/levels/castle_courtyard/script.c +++ b/levels/castle_courtyard/script.c @@ -31,12 +31,12 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_castle_courtyard_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _castle_courtyard_segment_7SegmentRomStart, _castle_courtyard_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _outside_mio0SegmentRomStart, _outside_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group9_mio0SegmentRomStart, _group9_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _castle_courtyard_segment_7SegmentRomStart, _castle_courtyard_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _outside_yay0SegmentRomStart, _outside_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group9_yay0SegmentRomStart, _group9_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group9_geoSegmentRomStart, _group9_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/castle_grounds/script.c b/levels/castle_grounds/script.c index 626bece4c..6e44620b4 100644 --- a/levels/castle_grounds/script.c +++ b/levels/castle_grounds/script.c @@ -94,14 +94,14 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_castle_grounds_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _castle_grounds_segment_7SegmentRomStart, _castle_grounds_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _outside_mio0SegmentRomStart, _outside_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group10_mio0SegmentRomStart, _group10_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _castle_grounds_segment_7SegmentRomStart, _castle_grounds_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _outside_yay0SegmentRomStart, _outside_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group10_yay0SegmentRomStart, _group10_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group10_geoSegmentRomStart, _group10_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group15_mio0SegmentRomStart, _group15_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group15_yay0SegmentRomStart, _group15_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group15_geoSegmentRomStart, _group15_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/castle_inside/script.c b/levels/castle_inside/script.c index 5d9ae4fb5..001156030 100644 --- a/levels/castle_inside/script.c +++ b/levels/castle_inside/script.c @@ -221,9 +221,9 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_castle_inside_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _castle_inside_segment_7SegmentRomStart, _castle_inside_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _inside_mio0SegmentRomStart, _inside_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group15_mio0SegmentRomStart, _group15_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _castle_inside_segment_7SegmentRomStart, _castle_inside_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _inside_yay0SegmentRomStart, _inside_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group15_yay0SegmentRomStart, _group15_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group15_geoSegmentRomStart, _group15_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ccm/script.c b/levels/ccm/script.c index c43f78913..e57d33c42 100644 --- a/levels/ccm/script.c +++ b/levels/ccm/script.c @@ -51,15 +51,15 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_ccm_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _ccm_segment_7SegmentRomStart, _ccm_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _snow_mio0SegmentRomStart, _snow_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _ccm_skybox_mio0SegmentRomStart, _ccm_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group7_mio0SegmentRomStart, _group7_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _ccm_segment_7SegmentRomStart, _ccm_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _snow_yay0SegmentRomStart, _snow_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _ccm_skybox_yay0SegmentRomStart, _ccm_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group7_yay0SegmentRomStart, _group7_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group7_geoSegmentRomStart, _group7_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group16_mio0SegmentRomStart, _group16_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group16_yay0SegmentRomStart, _group16_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group16_geoSegmentRomStart, _group16_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/cotmc/script.c b/levels/cotmc/script.c index 118136ce6..149a11b2e 100644 --- a/levels/cotmc/script.c +++ b/levels/cotmc/script.c @@ -30,13 +30,13 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_cotmc_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _cotmc_segment_7SegmentRomStart, _cotmc_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _cave_mio0SegmentRomStart, _cave_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group8_mio0SegmentRomStart, _group8_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _cotmc_segment_7SegmentRomStart, _cotmc_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _cave_yay0SegmentRomStart, _cave_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group8_yay0SegmentRomStart, _group8_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group8_geoSegmentRomStart, _group8_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ddd/script.c b/levels/ddd/script.c index 759a26273..12d839d2b 100644 --- a/levels/ddd/script.c +++ b/levels/ddd/script.c @@ -62,15 +62,15 @@ static const LevelScript script_func_local_5[] = { const LevelScript level_ddd_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _ddd_segment_7SegmentRomStart, _ddd_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _water_mio0SegmentRomStart, _water_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group4_mio0SegmentRomStart, _group4_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _ddd_segment_7SegmentRomStart, _ddd_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _water_yay0SegmentRomStart, _water_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group4_yay0SegmentRomStart, _group4_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group4_geoSegmentRomStart, _group4_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group13_mio0SegmentRomStart, _group13_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group13_yay0SegmentRomStart, _group13_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group13_geoSegmentRomStart, _group13_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ending/script.c b/levels/ending/script.c index ad3d73865..301faa587 100644 --- a/levels/ending/script.c +++ b/levels/ending/script.c @@ -18,7 +18,7 @@ const LevelScript level_ending_entry[] = { /*0*/ INIT_LEVEL(), - /*1*/ LOAD_MIO0(/*seg*/ 0x07, _ending_segment_7SegmentRomStart, _ending_segment_7SegmentRomEnd), + /*1*/ LOAD_YAY0(/*seg*/ 0x07, _ending_segment_7SegmentRomStart, _ending_segment_7SegmentRomEnd), /*4*/ ALLOC_LEVEL_POOL(), /*5*/ AREA(/*index*/ 1, ending_geo_000050), diff --git a/levels/hmc/script.c b/levels/hmc/script.c index 06198229a..a38c1fb17 100644 --- a/levels/hmc/script.c +++ b/levels/hmc/script.c @@ -70,13 +70,13 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_hmc_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _hmc_segment_7SegmentRomStart, _hmc_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _cave_mio0SegmentRomStart, _cave_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group6_mio0SegmentRomStart, _group6_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _hmc_segment_7SegmentRomStart, _hmc_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _cave_yay0SegmentRomStart, _cave_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group6_yay0SegmentRomStart, _group6_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group6_geoSegmentRomStart, _group6_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/intro/script.c b/levels/intro/script.c index a130cc04e..9a2642692 100644 --- a/levels/intro/script.c +++ b/levels/intro/script.c @@ -22,7 +22,7 @@ const LevelScript level_intro_splash_screen[] = { INIT_LEVEL(), FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x07, _intro_segment_7SegmentRomStart, _intro_segment_7SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x07, _intro_segment_7SegmentRomStart, _intro_segment_7SegmentRomEnd), // Load "Super Mario 64" logo ALLOC_LEVEL_POOL(), @@ -49,7 +49,7 @@ const LevelScript level_intro_mario_head_regular[] = { FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), LOAD_MARIO_HEAD(/*loadHeadID*/ REGULAR_FACE), LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_mio0SegmentRomStart, _title_screen_bg_mio0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_yay0SegmentRomStart, _title_screen_bg_yay0SegmentRomEnd), ALLOC_LEVEL_POOL(), AREA(/*index*/ 1, intro_geo_mario_head_regular), @@ -74,7 +74,7 @@ const LevelScript level_intro_mario_head_dizzy[] = { FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), LOAD_MARIO_HEAD(/*loadHeadID*/ DIZZY_FACE), LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_mio0SegmentRomStart, _title_screen_bg_mio0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_yay0SegmentRomStart, _title_screen_bg_yay0SegmentRomEnd), ALLOC_LEVEL_POOL(), AREA(/*index*/ 1, intro_geo_mario_head_dizzy), @@ -96,8 +96,8 @@ const LevelScript level_intro_mario_head_dizzy[] = { const LevelScript level_intro_entry_4[] = { INIT_LEVEL(), LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_mio0SegmentRomStart, _title_screen_bg_mio0SegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x07, _debug_level_select_mio0SegmentRomStart, _debug_level_select_mio0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_yay0SegmentRomStart, _title_screen_bg_yay0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x07, _debug_level_select_yay0SegmentRomStart, _debug_level_select_yay0SegmentRomEnd), FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), ALLOC_LEVEL_POOL(), diff --git a/levels/jrb/script.c b/levels/jrb/script.c index 754028673..3af6c1535 100644 --- a/levels/jrb/script.c +++ b/levels/jrb/script.c @@ -114,15 +114,15 @@ static const LevelScript script_func_local_5[] = { const LevelScript level_jrb_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _jrb_segment_7SegmentRomStart, _jrb_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _water_mio0SegmentRomStart, _water_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _clouds_skybox_mio0SegmentRomStart, _clouds_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group4_mio0SegmentRomStart, _group4_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _jrb_segment_7SegmentRomStart, _jrb_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _water_yay0SegmentRomStart, _water_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _clouds_skybox_yay0SegmentRomStart, _clouds_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group4_yay0SegmentRomStart, _group4_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group4_geoSegmentRomStart, _group4_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group13_mio0SegmentRomStart, _group13_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group13_yay0SegmentRomStart, _group13_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group13_geoSegmentRomStart, _group13_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/lll/script.c b/levels/lll/script.c index 1322d6c20..b39541f36 100644 --- a/levels/lll/script.c +++ b/levels/lll/script.c @@ -118,15 +118,15 @@ static const LevelScript script_func_local_7[] = { const LevelScript level_lll_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _lll_segment_7SegmentRomStart, _lll_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _fire_mio0SegmentRomStart, _fire_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _bitfs_skybox_mio0SegmentRomStart, _bitfs_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group2_mio0SegmentRomStart, _group2_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _lll_segment_7SegmentRomStart, _lll_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _fire_yay0SegmentRomStart, _fire_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _bitfs_skybox_yay0SegmentRomStart, _bitfs_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group2_yay0SegmentRomStart, _group2_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group2_geoSegmentRomStart, _group2_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/menu/script.c b/levels/menu/script.c index f6db65c98..00d8d957e 100644 --- a/levels/menu/script.c +++ b/levels/menu/script.c @@ -21,7 +21,7 @@ const LevelScript level_main_menu_entry_1[] = { INIT_LEVEL(), FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x07, _menu_segment_7SegmentRomStart, _menu_segment_7SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x07, _menu_segment_7SegmentRomStart, _menu_segment_7SegmentRomEnd), LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), ALLOC_LEVEL_POOL(), LOAD_MODEL_FROM_GEO(MODEL_MAIN_MENU_MARIO_SAVE_BUTTON, geo_menu_mario_save_button), @@ -62,7 +62,7 @@ const LevelScript level_main_menu_entry_2[] = { /*2*/ JUMP_IF(/*op*/ OP_EQ, /*arg*/ 0, level_main_menu_entry_2 + 42), /*5*/ INIT_LEVEL(), /*6*/ FIXED_LOAD(/*loadAddr*/ _goddardSegmentStart, /*romStart*/ _goddardSegmentRomStart, /*romEnd*/ _goddardSegmentRomEnd), - /*10*/ LOAD_MIO0(/*seg*/ 0x07, _menu_segment_7SegmentRomStart, _menu_segment_7SegmentRomEnd), + /*10*/ LOAD_YAY0(/*seg*/ 0x07, _menu_segment_7SegmentRomStart, _menu_segment_7SegmentRomEnd), /*13*/ ALLOC_LEVEL_POOL(), /*14*/ AREA(/*index*/ 2, geo_menu_act_selector_strings), diff --git a/levels/pss/script.c b/levels/pss/script.c index 3547bf6b3..bae599039 100644 --- a/levels/pss/script.c +++ b/levels/pss/script.c @@ -17,11 +17,11 @@ const LevelScript level_pss_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _pss_segment_7SegmentRomStart, _pss_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _mountain_mio0SegmentRomStart, _mountain_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group8_mio0SegmentRomStart, _group8_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _pss_segment_7SegmentRomStart, _pss_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _mountain_yay0SegmentRomStart, _mountain_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group8_yay0SegmentRomStart, _group8_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group8_geoSegmentRomStart, _group8_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/rr/script.c b/levels/rr/script.c index 85f925e13..c4dc6d702 100644 --- a/levels/rr/script.c +++ b/levels/rr/script.c @@ -70,12 +70,12 @@ static const LevelScript script_func_local_3[] = { const LevelScript level_rr_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _rr_segment_7SegmentRomStart, _rr_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _cloud_floor_skybox_mio0SegmentRomStart, _cloud_floor_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group11_mio0SegmentRomStart, _group11_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _rr_segment_7SegmentRomStart, _rr_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _cloud_floor_skybox_yay0SegmentRomStart, _cloud_floor_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group11_yay0SegmentRomStart, _group11_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group11_geoSegmentRomStart, _group11_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/sa/script.c b/levels/sa/script.c index 264d5825d..575edac56 100644 --- a/levels/sa/script.c +++ b/levels/sa/script.c @@ -28,13 +28,13 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_sa_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _sa_segment_7SegmentRomStart, _sa_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _inside_mio0SegmentRomStart, _inside_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _cloud_floor_skybox_mio0SegmentRomStart, _cloud_floor_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group4_mio0SegmentRomStart, _group4_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _sa_segment_7SegmentRomStart, _sa_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _inside_yay0SegmentRomStart, _inside_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _cloud_floor_skybox_yay0SegmentRomStart, _cloud_floor_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group4_yay0SegmentRomStart, _group4_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group4_geoSegmentRomStart, _group4_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group13_mio0SegmentRomStart, _group13_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group13_yay0SegmentRomStart, _group13_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group13_geoSegmentRomStart, _group13_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/scripts.c b/levels/scripts.c index 3067162ce..66197cba7 100644 --- a/levels/scripts.c +++ b/levels/scripts.c @@ -59,8 +59,8 @@ static const LevelScript script_L5[4]; #undef STUB_LEVEL const LevelScript level_main_scripts_entry[] = { - LOAD_MIO0(/*seg*/ 0x04, _group0_mio0SegmentRomStart, _group0_mio0SegmentRomEnd), - LOAD_MIO0(/*seg*/ 0x03, _common1_mio0SegmentRomStart, _common1_mio0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x04, _group0_yay0SegmentRomStart, _group0_yay0SegmentRomEnd), + LOAD_YAY0(/*seg*/ 0x03, _common1_yay0SegmentRomStart, _common1_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x17, _group0_geoSegmentRomStart, _group0_geoSegmentRomEnd), LOAD_RAW( /*seg*/ 0x16, _common1_geoSegmentRomStart, _common1_geoSegmentRomEnd), LOAD_RAW( /*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), diff --git a/levels/sl/script.c b/levels/sl/script.c index 47e1338cf..f937ddd18 100644 --- a/levels/sl/script.c +++ b/levels/sl/script.c @@ -44,15 +44,15 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_sl_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _sl_segment_7SegmentRomStart, _sl_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _snow_mio0SegmentRomStart, _snow_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0B, _effect_mio0SegmentRomStart, _effect_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _ccm_skybox_mio0SegmentRomStart, _ccm_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group7_mio0SegmentRomStart, _group7_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _sl_segment_7SegmentRomStart, _sl_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _snow_yay0SegmentRomStart, _snow_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0B, _effect_yay0SegmentRomStart, _effect_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _ccm_skybox_yay0SegmentRomStart, _ccm_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group7_yay0SegmentRomStart, _group7_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group7_geoSegmentRomStart, _group7_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group16_mio0SegmentRomStart, _group16_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group16_yay0SegmentRomStart, _group16_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group16_geoSegmentRomStart, _group16_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ssl/script.c b/levels/ssl/script.c index 65aec7514..05725d14f 100644 --- a/levels/ssl/script.c +++ b/levels/ssl/script.c @@ -69,12 +69,12 @@ static const LevelScript script_func_local_6[] = { const LevelScript level_ssl_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _ssl_segment_7SegmentRomStart, _ssl_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _ssl_skybox_mio0SegmentRomStart, _ssl_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _generic_mio0SegmentRomStart, _generic_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group5_mio0SegmentRomStart, _group5_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _ssl_segment_7SegmentRomStart, _ssl_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _ssl_skybox_yay0SegmentRomStart, _ssl_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _generic_yay0SegmentRomStart, _generic_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group5_yay0SegmentRomStart, _group5_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group5_geoSegmentRomStart, _group5_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/thi/script.c b/levels/thi/script.c index dcddbc4eb..82d371c2d 100644 --- a/levels/thi/script.c +++ b/levels/thi/script.c @@ -79,14 +79,14 @@ static const LevelScript script_func_local_8[] = { const LevelScript level_thi_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _thi_segment_7SegmentRomStart, _thi_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _grass_mio0SegmentRomStart, _grass_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group11_mio0SegmentRomStart, _group11_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _thi_segment_7SegmentRomStart, _thi_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _grass_yay0SegmentRomStart, _grass_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group11_yay0SegmentRomStart, _group11_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group11_geoSegmentRomStart, _group11_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group14_mio0SegmentRomStart, _group14_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group14_yay0SegmentRomStart, _group14_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group14_geoSegmentRomStart, _group14_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/totwc/script.c b/levels/totwc/script.c index d0172c763..ea322edee 100644 --- a/levels/totwc/script.c +++ b/levels/totwc/script.c @@ -28,12 +28,12 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_totwc_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _totwc_segment_7SegmentRomStart, _totwc_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _cloud_floor_skybox_mio0SegmentRomStart, _cloud_floor_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group8_mio0SegmentRomStart, _group8_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _totwc_segment_7SegmentRomStart, _totwc_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _cloud_floor_skybox_yay0SegmentRomStart, _cloud_floor_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group8_yay0SegmentRomStart, _group8_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group8_geoSegmentRomStart, _group8_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ttc/script.c b/levels/ttc/script.c index 4b93de860..70c9f781c 100644 --- a/levels/ttc/script.c +++ b/levels/ttc/script.c @@ -33,11 +33,11 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_ttc_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _ttc_segment_7SegmentRomStart, _ttc_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _machine_mio0SegmentRomStart, _machine_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group1_mio0SegmentRomStart, _group1_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _ttc_segment_7SegmentRomStart, _ttc_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _machine_yay0SegmentRomStart, _machine_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group1_yay0SegmentRomStart, _group1_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group1_geoSegmentRomStart, _group1_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/ttm/script.c b/levels/ttm/script.c index bc593aac8..899aef619 100644 --- a/levels/ttm/script.c +++ b/levels/ttm/script.c @@ -82,12 +82,12 @@ static const LevelScript script_func_local_7[] = { const LevelScript level_ttm_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _ttm_segment_7SegmentRomStart, _ttm_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _mountain_mio0SegmentRomStart, _mountain_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _water_skybox_mio0SegmentRomStart, _water_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group6_mio0SegmentRomStart, _group6_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _ttm_segment_7SegmentRomStart, _ttm_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _mountain_yay0SegmentRomStart, _mountain_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _water_skybox_yay0SegmentRomStart, _water_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group6_yay0SegmentRomStart, _group6_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group6_geoSegmentRomStart, _group6_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/vcutm/script.c b/levels/vcutm/script.c index fb52c9569..9122799d7 100644 --- a/levels/vcutm/script.c +++ b/levels/vcutm/script.c @@ -39,11 +39,11 @@ static const LevelScript script_func_local_3[] = { const LevelScript level_vcutm_entry[] = { INIT_LEVEL(), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _outside_mio0SegmentRomStart, _outside_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x07, _vcutm_segment_7SegmentRomStart, _vcutm_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group8_mio0SegmentRomStart, _group8_mio0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _outside_yay0SegmentRomStart, _outside_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _vcutm_segment_7SegmentRomStart, _vcutm_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group8_yay0SegmentRomStart, _group8_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group8_geoSegmentRomStart, _group8_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/wdw/script.c b/levels/wdw/script.c index 0c4b59802..e647ec140 100644 --- a/levels/wdw/script.c +++ b/levels/wdw/script.c @@ -69,14 +69,14 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_wdw_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _wdw_segment_7SegmentRomStart, _wdw_segment_7SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _grass_mio0SegmentRomStart, _grass_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _wdw_skybox_mio0SegmentRomStart, _wdw_skybox_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group1_mio0SegmentRomStart, _group1_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _wdw_segment_7SegmentRomStart, _wdw_segment_7SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _grass_yay0SegmentRomStart, _grass_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _wdw_skybox_yay0SegmentRomStart, _wdw_skybox_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group1_yay0SegmentRomStart, _group1_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group1_geoSegmentRomStart, _group1_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group13_mio0SegmentRomStart, _group13_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group13_yay0SegmentRomStart, _group13_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group13_geoSegmentRomStart, _group13_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/wf/script.c b/levels/wf/script.c index 6697b4973..57105e5d9 100644 --- a/levels/wf/script.c +++ b/levels/wf/script.c @@ -93,14 +93,14 @@ static const LevelScript script_func_local_4[] = { const LevelScript level_wf_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _wf_segment_7SegmentRomStart, _wf_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _cloud_floor_skybox_mio0SegmentRomStart, _cloud_floor_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _grass_mio0SegmentRomStart, _grass_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group1_mio0SegmentRomStart, _group1_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _wf_segment_7SegmentRomStart, _wf_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _cloud_floor_skybox_yay0SegmentRomStart, _cloud_floor_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _grass_yay0SegmentRomStart, _grass_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group1_yay0SegmentRomStart, _group1_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group1_geoSegmentRomStart, _group1_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group14_mio0SegmentRomStart, _group14_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group14_yay0SegmentRomStart, _group14_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group14_geoSegmentRomStart, _group14_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/levels/wmotr/script.c b/levels/wmotr/script.c index dfbaae27a..dcd8363c1 100644 --- a/levels/wmotr/script.c +++ b/levels/wmotr/script.c @@ -32,14 +32,14 @@ static const LevelScript script_func_local_2[] = { const LevelScript level_wmotr_entry[] = { INIT_LEVEL(), - LOAD_MIO0( /*seg*/ 0x07, _wmotr_segment_7SegmentRomStart, _wmotr_segment_7SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x0A, _cloud_floor_skybox_mio0SegmentRomStart, _cloud_floor_skybox_mio0SegmentRomEnd), - LOAD_MIO0_TEXTURE(/*seg*/ 0x09, _sky_mio0SegmentRomStart, _sky_mio0SegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x05, _group2_mio0SegmentRomStart, _group2_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x07, _wmotr_segment_7SegmentRomStart, _wmotr_segment_7SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x0A, _cloud_floor_skybox_yay0SegmentRomStart, _cloud_floor_skybox_yay0SegmentRomEnd), + LOAD_YAY0_TEXTURE(/*seg*/ 0x09, _sky_yay0SegmentRomStart, _sky_yay0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x05, _group2_yay0SegmentRomStart, _group2_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0C, _group2_geoSegmentRomStart, _group2_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x06, _group17_mio0SegmentRomStart, _group17_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x06, _group17_yay0SegmentRomStart, _group17_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0D, _group17_geoSegmentRomStart, _group17_geoSegmentRomEnd), - LOAD_MIO0( /*seg*/ 0x08, _common0_mio0SegmentRomStart, _common0_mio0SegmentRomEnd), + LOAD_YAY0( /*seg*/ 0x08, _common0_yay0SegmentRomStart, _common0_yay0SegmentRomEnd), LOAD_RAW( /*seg*/ 0x0F, _common0_geoSegmentRomStart, _common0_geoSegmentRomEnd), ALLOC_LEVEL_POOL(), MARIO(/*model*/ MODEL_MARIO, /*behParam*/ 0x00000001, /*beh*/ bhvMario), diff --git a/lib/PR/audio/aspMain.bin b/lib/PR/audio/aspMain.bin new file mode 100644 index 000000000..6fe732ddb Binary files /dev/null and b/lib/PR/audio/aspMain.bin differ diff --git a/lib/PR/audio/aspMain_data.bin b/lib/PR/audio/aspMain_data.bin new file mode 100644 index 000000000..1e74134e9 Binary files /dev/null and b/lib/PR/audio/aspMain_data.bin differ diff --git a/lib/PR/audio/n_aspMain.bin b/lib/PR/audio/n_aspMain.bin new file mode 100644 index 000000000..397ecec4b Binary files /dev/null and b/lib/PR/audio/n_aspMain.bin differ diff --git a/lib/PR/audio/n_aspMain_data.bin b/lib/PR/audio/n_aspMain_data.bin new file mode 100644 index 000000000..66d1cab9d Binary files /dev/null and b/lib/PR/audio/n_aspMain_data.bin differ diff --git a/lib/PR/f3dzex/F3DZEX.bin b/lib/PR/f3dzex/F3DZEX.bin new file mode 100644 index 000000000..9c4c345f3 Binary files /dev/null and b/lib/PR/f3dzex/F3DZEX.bin differ diff --git a/lib/PR/f3dex2/F3DZEX_NoN.bin b/lib/PR/f3dzex/F3DZEX_NoN.bin similarity index 100% rename from lib/PR/f3dex2/F3DZEX_NoN.bin rename to lib/PR/f3dzex/F3DZEX_NoN.bin diff --git a/lib/PR/f3dex2/F3DZEX_NoN_data.bin b/lib/PR/f3dzex/F3DZEX_NoN_data.bin similarity index 100% rename from lib/PR/f3dex2/F3DZEX_NoN_data.bin rename to lib/PR/f3dzex/F3DZEX_NoN_data.bin diff --git a/lib/PR/f3dzex/F3DZEX_data.bin b/lib/PR/f3dzex/F3DZEX_data.bin new file mode 100644 index 000000000..23c589b26 Binary files /dev/null and b/lib/PR/f3dzex/F3DZEX_data.bin differ diff --git a/lib/PR/f3dzex/L3DZEX.bin b/lib/PR/f3dzex/L3DZEX.bin new file mode 100644 index 000000000..bddd61d57 Binary files /dev/null and b/lib/PR/f3dzex/L3DZEX.bin differ diff --git a/lib/PR/f3dzex/L3DZEX_data.bin b/lib/PR/f3dzex/L3DZEX_data.bin new file mode 100644 index 000000000..6181ed67e Binary files /dev/null and b/lib/PR/f3dzex/L3DZEX_data.bin differ diff --git a/lib/PR/hvqm/hvqm2sp1.o b/lib/PR/hvqm/hvqm2sp1.o new file mode 100644 index 000000000..b66b4896f Binary files /dev/null and b/lib/PR/hvqm/hvqm2sp1.o differ diff --git a/lib/PR/hvqm/hvqm2sp2.o b/lib/PR/hvqm/hvqm2sp2.o new file mode 100644 index 000000000..ede3d16c7 Binary files /dev/null and b/lib/PR/hvqm/hvqm2sp2.o differ diff --git a/lib/PR/s2dex2/S2DEX2.bin b/lib/PR/s2dex2/S2DEX2.bin new file mode 100644 index 000000000..d535e14f5 Binary files /dev/null and b/lib/PR/s2dex2/S2DEX2.bin differ diff --git a/lib/PR/s2dex2/S2DEX2_data.bin b/lib/PR/s2dex2/S2DEX2_data.bin new file mode 100644 index 000000000..95dde46a7 Binary files /dev/null and b/lib/PR/s2dex2/S2DEX2_data.bin differ diff --git a/lib/PR/super3d/Super3D.bin b/lib/PR/super3d/Super3D.bin new file mode 100644 index 000000000..54921e02f Binary files /dev/null and b/lib/PR/super3d/Super3D.bin differ diff --git a/lib/PR/super3d/Super3D_data.bin b/lib/PR/super3d/Super3D_data.bin new file mode 100644 index 000000000..4be455167 Binary files /dev/null and b/lib/PR/super3d/Super3D_data.bin differ diff --git a/lib/asm/__osDisableInt.s b/lib/asm/__osDisableInt.s deleted file mode 100644 index 4c759b4c9..000000000 --- a/lib/asm/__osDisableInt.s +++ /dev/null @@ -1,18 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - - -glabel __osDisableInt - mfc0 $t0, $12 - and $t1, $t0, -2 - mtc0 $t1, $12 - andi $v0, $t0, 1 - nop - jr $ra - nop - diff --git a/lib/asm/__osExceptionPreamble.s b/lib/asm/__osExceptionPreamble.s deleted file mode 100644 index e14928ce0..000000000 --- a/lib/asm/__osExceptionPreamble.s +++ /dev/null @@ -1,833 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - -.ifdef VERSION_EU -.set VERSION_EU_SH, 1 -.endif -.ifdef VERSION_SH -.set VERSION_EU_SH, 1 -.endif - -.section .text, "ax" - -.ifdef AVOID_UB -.set D_80334890, D_80334890_fix -.endif - -glabel __osExceptionPreamble - lui $k0, %hi(__osException) - addiu $k0, %lo(__osException) - jr $k0 - nop - -glabel __osException - lui $k0, %hi(gInterruptedThread) - addiu $k0, %lo(gInterruptedThread) - sd $at, 0x20($k0) - mfc0 $k1, $12 - sw $k1, 0x118($k0) - li $at, -4 - and $k1, $k1, $at - mtc0 $k1, $12 - sd $t0, 0x58($k0) - sd $t1, 0x60($k0) - sd $t2, 0x68($k0) - sw $zero, 0x18($k0) - mfc0 $t0, $13 -.ifndef VERSION_EU_SH - andi $t1, $t0, 0x7c - li $t2, 0 - bne $t1, $t2, .L80326750 - nop - and $t1, $k1, $t0 - andi $t2, $t1, 0x4000 - beqz $t2, .L80326734 - nop - li $t1, 1 - lui $at, %hi(D_80334934) - b .L80326794 - sw $t1, %lo(D_80334934)($at) -.L80326734: - andi $t2, $t1, 0x2000 - beqz $t2, .L80326750 - nop - li $t1, 1 - lui $at, %hi(D_80334938) - b .L80326794 - sw $t1, %lo(D_80334938)($at) -.L80326750: - lui $at, %hi(D_80334934) - sw $zero, %lo(D_80334934)($at) - lui $at, %hi(D_80334938) -.endif - move $t0, $k0 -.ifndef VERSION_EU_SH - sw $zero, %lo(D_80334938)($at) -.endif - lui $k0, %hi(D_80334890 + 0x10) - lw $k0, %lo(D_80334890 + 0x10)($k0) - ld $t1, 0x20($t0) - sd $t1, 0x20($k0) - ld $t1, 0x118($t0) - sd $t1, 0x118($k0) - ld $t1, 0x58($t0) - sd $t1, 0x58($k0) - ld $t1, 0x60($t0) - sd $t1, 0x60($k0) - ld $t1, 0x68($t0) - sd $t1, 0x68($k0) -.ifdef VERSION_EU_SH - lw $k1, 0x118($k0) -.else -.L80326794: -.endif - mflo $t0 - sd $t0, 0x108($k0) - mfhi $t0 -.ifdef VERSION_EU_SH - andi $t1, $k1, 0xff00 -.endif - sd $v0, 0x28($k0) - sd $v1, 0x30($k0) - sd $a0, 0x38($k0) - sd $a1, 0x40($k0) - sd $a2, 0x48($k0) - sd $a3, 0x50($k0) - sd $t3, 0x70($k0) - sd $t4, 0x78($k0) - sd $t5, 0x80($k0) - sd $t6, 0x88($k0) - sd $t7, 0x90($k0) - sd $s0, 0x98($k0) - sd $s1, 0xa0($k0) - sd $s2, 0xa8($k0) - sd $s3, 0xb0($k0) - sd $s4, 0xb8($k0) - sd $s5, 0xc0($k0) - sd $s6, 0xc8($k0) - sd $s7, 0xd0($k0) - sd $t8, 0xd8($k0) - sd $t9, 0xe0($k0) - sd $gp, 0xe8($k0) - sd $sp, 0xf0($k0) - sd $fp, 0xf8($k0) - sd $ra, 0x100($k0) -.ifdef VERSION_EU_SH - beqz $t1, .L802F3A18 - sd $t0, 0x110($k0) - lui $t0, %hi(__OSGlobalIntMask) - addiu $t0, %lo(__OSGlobalIntMask) - lw $t0, ($t0) - li $at, -1 -.ifdef VERSION_EU - xor $t0, $t0, $at -.else - xor $t2, $t0, $at -.endif - lui $at, (0xFFFF00FF >> 16) -.ifdef VERSION_EU - andi $t0, $t0, 0xFF00 -.else - andi $t2, $t2, 0xFF00 -.endif - ori $at, (0xFFFF00FF & 0xFFFF) -.ifdef VERSION_EU - or $t1, $t1, $t0 - and $k1, $k1, $at - or $k1, $k1, $t1 - sw $k1, 0x118($k0) -.else - or $t4, $t1, $t2 - and $t3, $k1, $at - andi $t0, $t0, 0xFF00 - or $t3, $t3, $t4 - and $t1, $t1, $t0 - and $k1, $k1, $at - sw $t3, 0x118($k0) - or $k1, $k1, $t1 -.endif - -.L802F3A18: - lui $t1, %hi(MI_INTR_MASK_REG) - lw $t1, %lo(MI_INTR_MASK_REG)($t1) - beqz $t1, .L802F3A50 - nop - lui $t0, %hi(__OSGlobalIntMask) - addiu $t0, %lo(__OSGlobalIntMask) - lw $t0, ($t0) - lw $t4, 0x128($k0) - li $at, -1 - srl $t0, $t0, 0x10 - xor $t0, $t0, $at - andi $t0, $t0, 0x3f - and $t0, $t0, $t4 - or $t1, $t1, $t0 -.L802F3A50: - sw $t1, 0x128($k0) -.else - sd $t0, 0x110($k0) -.endif - mfc0 $t0, $14 - sw $t0, 0x11c($k0) - lw $t0, 0x18($k0) - beqz $t0, .L80326868 - nop - cfc1 $t0, $31 - nop - sw $t0, 0x12c($k0) - sdc1 $f0, 0x130($k0) - sdc1 $f2, 0x138($k0) - sdc1 $f4, 0x140($k0) - sdc1 $f6, 0x148($k0) - sdc1 $f8, 0x150($k0) - sdc1 $f10, 0x158($k0) - sdc1 $f12, 0x160($k0) - sdc1 $f14, 0x168($k0) - sdc1 $f16, 0x170($k0) - sdc1 $f18, 0x178($k0) - sdc1 $f20, 0x180($k0) - sdc1 $f22, 0x188($k0) - sdc1 $f24, 0x190($k0) - sdc1 $f26, 0x198($k0) - sdc1 $f28, 0x1a0($k0) - sdc1 $f30, 0x1a8($k0) -.L80326868: - mfc0 $t0, $13 - sw $t0, 0x120($k0) -.ifndef VERSION_EU_SH - lui $t1, %hi(MI_INTR_MASK_REG) - lw $t1, %lo(MI_INTR_MASK_REG)($t1) - sw $t1, 0x128($k0) -.endif - li $t1, 2 - sh $t1, 0x10($k0) -.ifndef VERSION_EU_SH - lui $t1, %hi(D_80334934) - lw $t1, %lo(D_80334934)($t1) - beqz $t1, .L803268B4 - nop - lui $t2, %hi(D_C0000008) - sw $zero, %lo(D_C0000008)($t2) - lui $a0, %hi(D_C0000000) - addiu $t2, %lo(D_C0000008) - jal kdebugserver - lw $a0, %lo(D_C0000000)($a0) - b .L80326E08 - nop -.L803268B4: - lui $t1, %hi(D_80334938) - lw $t1, %lo(D_80334938)($t1) - beqz $t1, .L80326900 - nop - lui $t2, %hi(D_C000000C) - sw $zero, %lo(D_C000000C)($t2) - lui $t1, %hi(D_80334A40) - lw $t1, %lo(D_80334A40)($t1) - addiu $t2, %lo(D_C000000C) - beqz $t1, .L803268E8 - nop - jal send_mesg - li $a0, 120 -.L803268E8: - lui $t1, %hi(D_80334A44) - lw $t1, %lo(D_80334A44)($t1) - lui $at, %hi(D_80334A44) - addi $t1, $t1, 1 - b .L80326E08 - sw $t1, %lo(D_80334A44)($at) -.L80326900: -.endif - andi $t1, $t0, 0x7c - li $t2, 36 - beq $t1, $t2, .L80326B84 - nop - li $t2, 44 - beq $t1, $t2, .L80326CCC - nop - li $t2, 0 - bne $t1, $t2, .L80326BE8 - nop - and $s0, $k1, $t0 -.L8032692C: - andi $t1, $s0, 0xff00 - srl $t2, $t1, 0xc - bnez $t2, .L80326944 - nop - srl $t2, $t1, 8 - addi $t2, $t2, 0x10 -.L80326944: - lui $at, %hi(D_80338610) - addu $at, $at, $t2 - lbu $t2, %lo(D_80338610)($at) - lui $at, %hi(jtbl_80338630) - addu $at, $at, $t2 - lw $t2, %lo(jtbl_80338630)($at) - jr $t2 - nop -.ifdef VERSION_EU_SH -glabel L802F3B28 - li $at, -8193 - b .L8032692C - and $s0, $s0, $at -glabel L802F3B34 - li $at, -16385 - b .L8032692C - and $s0, $s0, $at -.endif -glabel L80326964 - mfc0 $t1, $11 - mtc0 $t1, $11 - jal send_mesg - li $a0, 24 - lui $at, (0xFFFF7FFF >> 16) - ori $at, (0xFFFF7FFF & 0xFFFF) - b .L8032692C - and $s0, $s0, $at -glabel L80326984 -.ifdef VERSION_EU_SH - li $at, -2049 - and $s0, $s0, $at -.endif - li $t2, 4 - lui $at, %hi(D_80334920) - addu $at, $at, $t2 - lw $t2, %lo(D_80334920)($at) -.ifdef VERSION_EU_SH - lui $sp, %hi(leoDiskStack) - addiu $sp, %lo(leoDiskStack) - li $a0, 16 - beqz $t2, .L803269A4 - addiu $sp, $sp, 0xff0 -.else - beqz $t2, .L803269A4 - nop -.endif - jalr $t2 - nop -.ifdef VERSION_EU_SH - beqz $v0, .L803269A4 -.ifdef VERSION_SH - li $a0, 0x10 -.else - nop -.endif - b .L80326B9C - nop -.endif -.L803269A4: - jal send_mesg -.ifdef VERSION_EU_SH - nop - b .L8032692C - nop -.else - li $a0, 16 - li $at, -2049 - b .L8032692C - and $s0, $s0, $at -.endif -glabel L803269B8 -.ifdef VERSION_EU_SH - lui $t0, %hi(__OSGlobalIntMask) - addiu $t0, %lo(__OSGlobalIntMask) - lw $t0, ($t0) -.endif - lui $s1, %hi(MI_INTR_REG) - lw $s1, %lo(MI_INTR_REG)($s1) -.ifdef VERSION_EU_SH - srl $t0, $t0, 0x10 - and $s1, $s1, $t0 -.else - andi $s1, $s1, 0x3f -.endif - andi $t1, $s1, 1 - beqz $t1, .L80326A18 - nop - lui $t4, %hi(SP_STATUS_REG) - lw $t4, %lo(SP_STATUS_REG)($t4) - li $t1, 8 - lui $at, %hi(SP_STATUS_REG) - andi $t4, $t4, 0x300 - andi $s1, $s1, 0x3e - beqz $t4, .L80326A08 - sw $t1, %lo(SP_STATUS_REG)($at) - jal send_mesg - li $a0, 32 - beqz $s1, .L80326ADC - nop - b .L80326A18 - nop -.L80326A08: - jal send_mesg - li $a0, 88 - beqz $s1, .L80326ADC - nop -.L80326A18: - andi $t1, $s1, 8 - beqz $t1, .L80326A3C - lui $at, %hi(VI_CURRENT_REG) - andi $s1, $s1, 0x37 - sw $zero, %lo(VI_CURRENT_REG)($at) - jal send_mesg - li $a0, 56 - beqz $s1, .L80326ADC - nop -.L80326A3C: - andi $t1, $s1, 4 - beqz $t1, .L80326A68 - nop - li $t1, 1 - lui $at, %hi(AI_STATUS_REG) - andi $s1, $s1, 0x3b - sw $t1, %lo(AI_STATUS_REG)($at) - jal send_mesg - li $a0, 48 - beqz $s1, .L80326ADC - nop -.L80326A68: - andi $t1, $s1, 2 - beqz $t1, .L80326A8C - lui $at, %hi(SI_STATUS_REG) - andi $s1, $s1, 0x3d - sw $zero, %lo(SI_STATUS_REG)($at) - jal send_mesg - li $a0, 40 - beqz $s1, .L80326ADC - nop -.L80326A8C: - andi $t1, $s1, 0x10 - beqz $t1, .L80326AB8 - nop - li $t1, 2 - lui $at, %hi(PI_STATUS_REG) - andi $s1, $s1, 0x2f - sw $t1, %lo(PI_STATUS_REG)($at) - jal send_mesg - li $a0, 64 - beqz $s1, .L80326ADC - nop -.L80326AB8: - andi $t1, $s1, 0x20 - beqz $t1, .L80326ADC - nop - li $t1, 2048 - lui $at, %hi(MI_MODE_REG) - andi $s1, $s1, 0x1f - sw $t1, %lo(MI_MODE_REG)($at) - jal send_mesg - li $a0, 72 -.L80326ADC: - li $at, -1025 - b .L8032692C - and $s0, $s0, $at -glabel L80326AE8 - lw $k1, 0x118($k0) - li $at, -4097 - lui $t1, %hi(D_80334808) - and $k1, $k1, $at - sw $k1, 0x118($k0) - addiu $t1, %lo(D_80334808) - lw $t2, ($t1) - beqz $t2, .L80326B14 - li $at, -4097 - b .L80326B9C - and $s0, $s0, $at -.L80326B14: - li $t2, 1 - sw $t2, ($t1) - jal send_mesg - li $a0, 112 - lui $t2, %hi(D_80334890 + 0x8) - lw $t2, %lo(D_80334890 + 0x8)($t2) - li $at, -4097 - and $s0, $s0, $at - lw $k1, 0x118($t2) - and $k1, $k1, $at - b .L80326B9C - sw $k1, 0x118($t2) -glabel L80326B44 - li $at, -513 - and $t0, $t0, $at - mtc0 $t0, $13 - jal send_mesg - li $a0, 8 - li $at, -513 - b .L8032692C - and $s0, $s0, $at -glabel L80326B64 - li $at, -257 - and $t0, $t0, $at - mtc0 $t0, $13 - jal send_mesg - li $a0, 0 - li $at, -257 - b .L8032692C - and $s0, $s0, $at -.L80326B84: - li $t1, 1 - sh $t1, 0x12($k0) - jal send_mesg - li $a0, 80 - b .L80326B9C - nop - -.L80326B9C: -glabel L80326B9C - lui $t2, %hi(D_80334890 + 0x8) - lw $t2, %lo(D_80334890 + 0x8)($t2) - lw $t1, 4($k0) - lw $t3, 4($t2) - slt $at, $t1, $t3 - beqz $at, .L80326BD0 - nop - lui $a0, %hi(D_80334890 + 0x8) - move $a1, $k0 - jal __osEnqueueThread - addiu $a0, %lo(D_80334890 + 0x8) - j __osDispatchThread - nop - -.L80326BD0: - lui $t1, %hi(D_80334890 + 0x8) - addiu $t1, %lo(D_80334890 + 0x8) - lw $t2, ($t1) - sw $t2, ($k0) - j __osDispatchThread - sw $k0, ($t1) - -.L80326BE8: -glabel L80326BE8 - lui $at, %hi(D_80334890 + 0x14) - sw $k0, %lo(D_80334890 + 0x14)($at) - li $t1, 1 - sh $t1, 0x10($k0) - li $t1, 2 - sh $t1, 0x12($k0) - mfc0 $t2, $8 - sw $t2, 0x124($k0) - jal send_mesg - li $a0, 96 - j __osDispatchThread - nop - -glabel send_mesg - lui $t2, %hi(__osEventStateTab) - addiu $t2, %lo(__osEventStateTab) - addu $t2, $t2, $a0 - lw $t1, ($t2) - move $s2, $ra - beqz $t1, .L80326CC4 - nop - lw $t3, 8($t1) - lw $t4, 0x10($t1) - slt $at, $t3, $t4 - beqz $at, .L80326CC4 - nop - lw $t5, 0xc($t1) - addu $t5, $t5, $t3 - div $zero, $t5, $t4 - bnez $t4, .L80326C60 - nop - break 7 -.L80326C60: - li $at, -1 - bne $t4, $at, .L80326C78 - lui $at, 0x8000 - bne $t5, $at, .L80326C78 - nop - break 6 -.L80326C78: - lw $t4, 0x14($t1) - mfhi $t5 - sll $t5, $t5, 2 - addu $t4, $t4, $t5 - lw $t5, 4($t2) - addiu $t2, $t3, 1 - sw $t5, ($t4) - sw $t2, 8($t1) - lw $t2, ($t1) - lw $t3, ($t2) - beqz $t3, .L80326CC4 - nop - jal __osPopThread - move $a0, $t1 - move $t2, $v0 - lui $a0, %hi(D_80334890 + 0x8) - move $a1, $t2 - jal __osEnqueueThread - addiu $a0, %lo(D_80334890 + 0x8) -.L80326CC4: - jr $s2 - nop -.L80326CCC: - lui $at, 0x3000 - and $t1, $t0, $at - srl $t1, $t1, 0x1c - li $t2, 1 - bne $t1, $t2, .L80326BE8 - nop - lw $k1, 0x118($k0) - lui $at, 0x2000 - li $t1, 1 - or $k1, $k1, $at - sw $t1, 0x18($k0) - b .L80326BD0 - sw $k1, 0x118($k0) - - -glabel __osEnqueueAndYield - lui $a1, %hi(D_80334890 + 0x10) - lw $a1, %lo(D_80334890 + 0x10)($a1) - mfc0 $t0, $12 - lw $k1, 0x18($a1) - ori $t0, $t0, 2 - sw $t0, 0x118($a1) - sd $s0, 0x98($a1) - sd $s1, 0xa0($a1) - sd $s2, 0xa8($a1) - sd $s3, 0xb0($a1) - sd $s4, 0xb8($a1) - sd $s5, 0xc0($a1) - sd $s6, 0xc8($a1) - sd $s7, 0xd0($a1) - sd $gp, 0xe8($a1) - sd $sp, 0xf0($a1) - sd $fp, 0xf8($a1) - sd $ra, 0x100($a1) - beqz $k1, .L80326D70 - sw $ra, 0x11c($a1) - cfc1 $k1, $31 - sdc1 $f20, 0x180($a1) - sdc1 $f22, 0x188($a1) - sdc1 $f24, 0x190($a1) - sdc1 $f26, 0x198($a1) - sdc1 $f28, 0x1a0($a1) - sdc1 $f30, 0x1a8($a1) - sw $k1, 0x12c($a1) - -.L80326D70: -.ifdef VERSION_EU_SH - lw $k1, 0x118($a1) - andi $t1, $k1, 0xff00 - beqz $t1, .L802F3FBC - nop - lui $t0, %hi(__OSGlobalIntMask) - addiu $t0, %lo(__OSGlobalIntMask) - lw $t0, ($t0) - li $at, -1 - xor $t0, $t0, $at - lui $at, (0xFFFF00FF >> 16) - andi $t0, $t0, 0xff00 - ori $at, (0xFFFF00FF & 0xFFFF) - or $t1, $t1, $t0 - and $k1, $k1, $at - or $k1, $k1, $t1 - sw $k1, 0x118($a1) -.L802F3FBC: -.endif - lui $k1, %hi(MI_INTR_MASK_REG) - lw $k1, %lo(MI_INTR_MASK_REG)($k1) -.ifdef VERSION_EU_SH - beqz $k1, .L802F3FF4 - nop - lui $k0, %hi(__OSGlobalIntMask) - addiu $k0, %lo(__OSGlobalIntMask) - lw $k0, ($k0) - lw $t0, 0x128($a1) - li $at, -1 - srl $k0, $k0, 0x10 - xor $k0, $k0, $at - andi $k0, $k0, 0x3f - and $k0, $k0, $t0 - or $k1, $k1, $k0 -.L802F3FF4: -.endif - beqz $a0, .L80326D88 - sw $k1, 0x128($a1) - jal __osEnqueueThread - nop -.L80326D88: - j __osDispatchThread - nop - -#enqueue and pop look like compiled functions? but there's no easy way to extract them -glabel __osEnqueueThread - lw $t8, ($a0) - lw $t7, 4($a1) - move $t9, $a0 - lw $t6, 4($t8) - slt $at, $t6, $t7 - bnez $at, .L80326DC4 - nop -.L80326DAC: - move $t9, $t8 - lw $t8, ($t8) - lw $t6, 4($t8) - slt $at, $t6, $t7 - beqz $at, .L80326DAC - nop -.L80326DC4: - lw $t8, ($t9) - sw $t8, ($a1) - sw $a1, ($t9) - jr $ra - sw $a0, 8($a1) - -glabel __osPopThread - lw $v0, ($a0) - lw $t9, ($v0) - jr $ra - sw $t9, ($a0) - -glabel __osDispatchThread - lui $a0, %hi(D_80334890 + 0x8) - jal __osPopThread - addiu $a0, %lo(D_80334890 + 0x8) - lui $at, %hi(D_80334890 + 0x10) - sw $v0, %lo(D_80334890 + 0x10)($at) - li $t0, 4 - sh $t0, 0x10($v0) - move $k0, $v0 -.ifdef VERSION_EU_SH - lui $t0, %hi(__OSGlobalIntMask) - lw $k1, 0x118($k0) - addiu $t0, %lo(__OSGlobalIntMask) - lw $t0, ($t0) - lui $at, (0xFFFF00FF >> 16) - andi $t1, $k1, 0xff00 - ori $at, (0xFFFF00FF & 0xFFFF) - andi $t0, $t0, 0xff00 - and $t1, $t1, $t0 - and $k1, $k1, $at - or $k1, $k1, $t1 - mtc0 $k1, $12 -.endif -.L80326E08: - ld $k1, 0x108($k0) - ld $at, 0x20($k0) - ld $v0, 0x28($k0) - mtlo $k1 - ld $k1, 0x110($k0) - ld $v1, 0x30($k0) - ld $a0, 0x38($k0) - ld $a1, 0x40($k0) - ld $a2, 0x48($k0) - ld $a3, 0x50($k0) - ld $t0, 0x58($k0) - ld $t1, 0x60($k0) - ld $t2, 0x68($k0) - ld $t3, 0x70($k0) - ld $t4, 0x78($k0) - ld $t5, 0x80($k0) - ld $t6, 0x88($k0) - ld $t7, 0x90($k0) - ld $s0, 0x98($k0) - ld $s1, 0xa0($k0) - ld $s2, 0xa8($k0) - ld $s3, 0xb0($k0) - ld $s4, 0xb8($k0) - ld $s5, 0xc0($k0) - ld $s6, 0xc8($k0) - ld $s7, 0xd0($k0) - ld $t8, 0xd8($k0) - ld $t9, 0xe0($k0) - ld $gp, 0xe8($k0) - mthi $k1 - ld $sp, 0xf0($k0) - ld $fp, 0xf8($k0) - ld $ra, 0x100($k0) - lw $k1, 0x11c($k0) - mtc0 $k1, $14 -.ifndef VERSION_EU_SH - lw $k1, 0x118($k0) - mtc0 $k1, $12 -.endif - lw $k1, 0x18($k0) - beqz $k1, .L80326EF0 - nop - lw $k1, 0x12c($k0) - ctc1 $k1, $31 - ldc1 $f0, 0x130($k0) - ldc1 $f2, 0x138($k0) - ldc1 $f4, 0x140($k0) - ldc1 $f6, 0x148($k0) - ldc1 $f8, 0x150($k0) - ldc1 $f10, 0x158($k0) - ldc1 $f12, 0x160($k0) - ldc1 $f14, 0x168($k0) - ldc1 $f16, 0x170($k0) - ldc1 $f18, 0x178($k0) - ldc1 $f20, 0x180($k0) - ldc1 $f22, 0x188($k0) - ldc1 $f24, 0x190($k0) - ldc1 $f26, 0x198($k0) - ldc1 $f28, 0x1a0($k0) - ldc1 $f30, 0x1a8($k0) -.L80326EF0: - lw $k1, 0x128($k0) -.ifdef VERSION_EU_SH - lui $k0, %hi(__OSGlobalIntMask) - addiu $k0, %lo(__OSGlobalIntMask) - lw $k0, ($k0) - srl $k0, $k0, 0x10 - and $k1, $k1, $k0 -.endif - sll $k1, $k1, 1 - lui $k0, %hi(D_803386D0) - addiu $k0, %lo(D_803386D0) - addu $k1, $k1, $k0 - lhu $k1, ($k1) - lui $k0, %hi(MI_INTR_MASK_REG) - addiu $k0, %lo(MI_INTR_MASK_REG) - sw $k1, ($k0) - nop - nop - nop - nop - eret -glabel __osCleanupThread - jal osDestroyThread - move $a0, $zero - -.section .data - -glabel D_80334920 - .word 0 - .word 0 - .word 0 - .word 0 - .word 0 - -glabel D_80334934 - .word 0 - -glabel D_80334938 - .word 0 - .word 0 - -.section .rodata - -glabel D_80338610 - .byte 0x00,0x14,0x18,0x18,0x1C,0x1C,0x1C,0x1C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x04,0x08,0x08,0x0C,0x0C,0x0C,0x0C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10 - -glabel jtbl_80338630 - .word L80326B9C - .word L80326B64 - .word L80326B44 - .word L803269B8 - .word L80326984 - .word L80326AE8 -.ifdef VERSION_EU_SH - .word L802F3B28 - .word L802F3B34 -.else - .word L80326BE8 - .word L80326BE8 -.endif - .word L80326964 - .word 0 - .word 0 - .word 0 diff --git a/lib/asm/__osGetCause.s b/lib/asm/__osGetCause.s deleted file mode 100644 index 13fff167e..000000000 --- a/lib/asm/__osGetCause.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osGetCause - mfc0 $v0, $13 - jr $ra - nop - - nop - diff --git a/lib/asm/__osGetSR.s b/lib/asm/__osGetSR.s deleted file mode 100644 index e2f74c76b..000000000 --- a/lib/asm/__osGetSR.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osGetSR - mfc0 $v0, $12 - jr $ra - nop - - nop - diff --git a/lib/asm/__osProbeTLB.s b/lib/asm/__osProbeTLB.s deleted file mode 100644 index fe83ea164..000000000 --- a/lib/asm/__osProbeTLB.s +++ /dev/null @@ -1,64 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osProbeTLB - mfc0 $t0, $10 - andi $t1, $t0, 0xff - li $at, -8192 - and $t2, $a0, $at - or $t1, $t1, $t2 - mtc0 $t1, $10 - nop - nop - nop - tlbp - nop - nop - mfc0 $t3, $0 - lui $at, 0x8000 - and $t3, $t3, $at - bnez $t3, .L8032A0D8 - nop - tlbr - nop - nop - nop - mfc0 $t3, $5 - addi $t3, $t3, 0x2000 - srl $t3, $t3, 1 - and $t4, $t3, $a0 - bnez $t4, .L8032A0A8 - addi $t3, $t3, -1 - mfc0 $v0, $2 - b .L8032A0AC - nop -.L8032A0A8: - mfc0 $v0, $3 -.L8032A0AC: - andi $t5, $v0, 2 - beqz $t5, .L8032A0D8 - nop - lui $at, (0x3FFFFFC0 >> 16) # lui $at, 0x3fff - ori $at, (0x3FFFFFC0 & 0xFFFF) # ori $at, $at, 0xffc0 - and $v0, $v0, $at - sll $v0, $v0, 6 - and $t5, $a0, $t3 - add $v0, $v0, $t5 - b .L8032A0DC - nop -.L8032A0D8: - li $v0, -1 -.L8032A0DC: - mtc0 $t0, $10 - jr $ra - nop - - nop - nop - diff --git a/lib/asm/__osRestoreInt.s b/lib/asm/__osRestoreInt.s deleted file mode 100644 index f6ab98ef1..000000000 --- a/lib/asm/__osRestoreInt.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osRestoreInt - mfc0 $t0, $12 - or $t0, $t0, $a0 - mtc0 $t0, $12 - nop - nop - jr $ra - nop - - nop - diff --git a/lib/asm/__osSetCompare.s b/lib/asm/__osSetCompare.s deleted file mode 100644 index a1dab9319..000000000 --- a/lib/asm/__osSetCompare.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osSetCompare - mtc0 $a0, $11 - jr $ra - nop - - nop - diff --git a/lib/asm/__osSetFpcCsr.s b/lib/asm/__osSetFpcCsr.s deleted file mode 100644 index e644bc74e..000000000 --- a/lib/asm/__osSetFpcCsr.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osSetFpcCsr - cfc1 $v0, $31 - ctc1 $a0, $31 - jr $ra - nop - diff --git a/lib/asm/__osSetSR.s b/lib/asm/__osSetSR.s deleted file mode 100644 index 3fba3e668..000000000 --- a/lib/asm/__osSetSR.s +++ /dev/null @@ -1,14 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel __osSetSR - mtc0 $a0, $12 - nop - jr $ra - nop - diff --git a/lib/asm/__os_eu_802ef550.s b/lib/asm/__os_eu_802ef550.s deleted file mode 100644 index 99b328e25..000000000 --- a/lib/asm/__os_eu_802ef550.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 -.set noat - -.include "macros.inc" - - -.section .text, "ax" -# cache related -glabel __os_eu_802ef550 - lui $t0,0x8000 - li $t2,0x2000 - addu $t1,$t0,$t2 - addiu $t1,$t1,-0x10 -.L: cache 0x1,0($t0) - sltu $at,$t0,$t1 - bnez $at,.L - addiu $t0,$t0,0x10 - jr $ra - nop - nop - nop diff --git a/lib/asm/bcopy.s b/lib/asm/bcopy.s deleted file mode 100644 index 953a3d3c0..000000000 --- a/lib/asm/bcopy.s +++ /dev/null @@ -1,232 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel bcopy - beqz $a2, .L80323A4C - move $a3, $a1 - beq $a0, $a1, .L80323A4C - slt $at, $a1, $a0 - bnezl $at, .L80323A14 - slti $at, $a2, 0x10 - add $v0, $a0, $a2 - slt $at, $a1, $v0 - beql $at, $zero, .L80323A14 - slti $at, $a2, 0x10 - b .L80323B78 - slti $at, $a2, 0x10 - slti $at, $a2, 0x10 -.L80323A14: - bnez $at, .L80323A2C - nop - andi $v0, $a0, 3 - andi $v1, $a1, 3 - beq $v0, $v1, .L80323A54 - nop -.L80323A2C: - beqz $a2, .L80323A4C - nop - addu $v1, $a0, $a2 -.L80323A38: - lb $v0, ($a0) - addiu $a0, $a0, 1 - addiu $a1, $a1, 1 - bne $a0, $v1, .L80323A38 - sb $v0, -1($a1) -.L80323A4C: - jr $ra - move $v0, $a3 - -.L80323A54: - beqz $v0, .L80323AB8 - li $at, 1 - beq $v0, $at, .L80323A9C - li $at, 2 - beql $v0, $at, .L80323A88 - lh $v0, ($a0) - lb $v0, ($a0) - addiu $a0, $a0, 1 - addiu $a1, $a1, 1 - addiu $a2, $a2, -1 - b .L80323AB8 - sb $v0, -1($a1) - lh $v0, ($a0) -.L80323A88: - addiu $a0, $a0, 2 - addiu $a1, $a1, 2 - addiu $a2, $a2, -2 - b .L80323AB8 - sh $v0, -2($a1) -.L80323A9C: - lb $v0, ($a0) - lh $v1, 1($a0) - addiu $a0, $a0, 3 - addiu $a1, $a1, 3 - addiu $a2, $a2, -3 - sb $v0, -3($a1) - sh $v1, -2($a1) -.L80323AB8: - slti $at, $a2, 0x20 - bnezl $at, .L80323B18 - slti $at, $a2, 0x10 - lw $v0, ($a0) - lw $v1, 4($a0) - lw $t0, 8($a0) - lw $t1, 0xc($a0) - lw $t2, 0x10($a0) - lw $t3, 0x14($a0) - lw $t4, 0x18($a0) - lw $t5, 0x1c($a0) - addiu $a0, $a0, 0x20 - addiu $a1, $a1, 0x20 - addiu $a2, $a2, -0x20 - sw $v0, -0x20($a1) - sw $v1, -0x1c($a1) - sw $t0, -0x18($a1) - sw $t1, -0x14($a1) - sw $t2, -0x10($a1) - sw $t3, -0xc($a1) - sw $t4, -8($a1) - b .L80323AB8 - sw $t5, -4($a1) -.L80323B14: - slti $at, $a2, 0x10 -.L80323B18: - bnezl $at, .L80323B54 - slti $at, $a2, 4 - lw $v0, ($a0) - lw $v1, 4($a0) - lw $t0, 8($a0) - lw $t1, 0xc($a0) - addiu $a0, $a0, 0x10 - addiu $a1, $a1, 0x10 - addiu $a2, $a2, -0x10 - sw $v0, -0x10($a1) - sw $v1, -0xc($a1) - sw $t0, -8($a1) - b .L80323B14 - sw $t1, -4($a1) -.L80323B50: - slti $at, $a2, 4 -.L80323B54: - bnez $at, .L80323A2C - nop - lw $v0, ($a0) - addiu $a0, $a0, 4 - addiu $a1, $a1, 4 - addiu $a2, $a2, -4 - b .L80323B50 - sw $v0, -4($a1) - slti $at, $a2, 0x10 -.L80323B78: - add $a0, $a0, $a2 - bnez $at, .L80323B94 - add $a1, $a1, $a2 - andi $v0, $a0, 3 - andi $v1, $a1, 3 - beq $v0, $v1, .L80323BC4 - nop -.L80323B94: - beqz $a2, .L80323A4C - nop - addiu $a0, $a0, -1 - addiu $a1, $a1, -1 - subu $v1, $a0, $a2 -.L80323BA8: - lb $v0, ($a0) - addiu $a0, $a0, -1 - addiu $a1, $a1, -1 - bne $a0, $v1, .L80323BA8 - sb $v0, 1($a1) - jr $ra - move $v0, $a3 - -.L80323BC4: - beqz $v0, .L80323C28 - li $at, 3 - beq $v0, $at, .L80323C0C - li $at, 2 - beql $v0, $at, .L80323BF8 - lh $v0, -2($a0) - lb $v0, -1($a0) - addiu $a0, $a0, -1 - addiu $a1, $a1, -1 - addiu $a2, $a2, -1 - b .L80323C28 - sb $v0, ($a1) - lh $v0, -2($a0) -.L80323BF8: - addiu $a0, $a0, -2 - addiu $a1, $a1, -2 - addiu $a2, $a2, -2 - b .L80323C28 - sh $v0, ($a1) -.L80323C0C: - lb $v0, -1($a0) - lh $v1, -3($a0) - addiu $a0, $a0, -3 - addiu $a1, $a1, -3 - addiu $a2, $a2, -3 - sb $v0, 2($a1) - sh $v1, ($a1) -.L80323C28: - slti $at, $a2, 0x20 - bnezl $at, .L80323C88 - slti $at, $a2, 0x10 - lw $v0, -4($a0) - lw $v1, -8($a0) - lw $t0, -0xc($a0) - lw $t1, -0x10($a0) - lw $t2, -0x14($a0) - lw $t3, -0x18($a0) - lw $t4, -0x1c($a0) - lw $t5, -0x20($a0) - addiu $a0, $a0, -0x20 - addiu $a1, $a1, -0x20 - addiu $a2, $a2, -0x20 - sw $v0, 0x1c($a1) - sw $v1, 0x18($a1) - sw $t0, 0x14($a1) - sw $t1, 0x10($a1) - sw $t2, 0xc($a1) - sw $t3, 8($a1) - sw $t4, 4($a1) - b .L80323C28 - sw $t5, ($a1) -.L80323C84: - slti $at, $a2, 0x10 -.L80323C88: - bnezl $at, .L80323CC4 - slti $at, $a2, 4 - lw $v0, -4($a0) - lw $v1, -8($a0) - lw $t0, -0xc($a0) - lw $t1, -0x10($a0) - addiu $a0, $a0, -0x10 - addiu $a1, $a1, -0x10 - addiu $a2, $a2, -0x10 - sw $v0, 0xc($a1) - sw $v1, 8($a1) - sw $t0, 4($a1) - b .L80323C84 - sw $t1, ($a1) -.L80323CC0: - slti $at, $a2, 4 -.L80323CC4: - bnez $at, .L80323B94 - nop - lw $v0, -4($a0) - addiu $a0, $a0, -4 - addiu $a1, $a1, -4 - addiu $a2, $a2, -4 - b .L80323CC0 - sw $v0, ($a1) - nop - nop - nop - diff --git a/lib/asm/bzero.s b/lib/asm/bzero.s deleted file mode 100644 index 37053b7e2..000000000 --- a/lib/asm/bzero.s +++ /dev/null @@ -1,53 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - -#this file is probably handwritten - -.section .text, "ax" - -glabel bzero - blt $a1, 0xc, .L803236BC - negu $v1, $a0 - andi $v1, $v1, 3 - beqz $v1, .L80323660 - subu $a1, $a1, $v1 - swl $zero, ($a0) - addu $a0, $a0, $v1 -.L80323660: - and $a3, $a1, -32 - beqz $a3, .L8032369C - subu $a1, $a1, $a3 - addu $a3, $a3, $a0 -.L80323674: - addiu $a0, $a0, 0x20 - sw $zero, -0x20($a0) - sw $zero, -0x1c($a0) - sw $zero, -0x18($a0) - sw $zero, -0x14($a0) - sw $zero, -0x10($a0) - sw $zero, -0xc($a0) - sw $zero, -8($a0) - bne $a0, $a3, .L80323674 - sw $zero, -4($a0) -.L8032369C: - and $a3, $a1, -4 - beqz $a3, .L803236BC - subu $a1, $a1, $a3 - addu $a3, $a3, $a0 -.L803236B0: - addiu $a0, $a0, 4 - bne $a0, $a3, .L803236B0 - sw $zero, -4($a0) -.L803236BC: - blez $a1, .L803236D4 - nop - addu $a1, $a1, $a0 -.L803236C8: - addiu $a0, $a0, 1 - bne $a0, $a1, .L803236C8 - sb $zero, -1($a0) -.L803236D4: - jr $ra - diff --git a/lib/asm/osGetCount.s b/lib/asm/osGetCount.s deleted file mode 100644 index 58bd36299..000000000 --- a/lib/asm/osGetCount.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osGetCount - mfc0 $v0, $9 - jr $ra - nop - - nop - diff --git a/lib/asm/osInvalDCache.s b/lib/asm/osInvalDCache.s deleted file mode 100644 index 452c4dd32..000000000 --- a/lib/asm/osInvalDCache.s +++ /dev/null @@ -1,59 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osInvalDCache - blez $a1, .L80323500 - nop - li $t3, 8192 - sltu $at, $a1, $t3 - beqz $at, .L80323508 - nop - move $t0, $a0 - addu $t1, $a0, $a1 - sltu $at, $t0, $t1 - beqz $at, .L80323500 - nop - andi $t2, $t0, 0xf - beqz $t2, .L803234D0 - addiu $t1, $t1, -0x10 - subu $t0, $t0, $t2 - cache 0x15, ($t0) - sltu $at, $t0, $t1 - beqz $at, .L80323500 - nop - addiu $t0, $t0, 0x10 -.L803234D0: - andi $t2, $t1, 0xf - beqz $t2, .L803234F0 - nop - subu $t1, $t1, $t2 - cache 0x15, 0x10($t1) - sltu $at, $t1, $t0 - bnez $at, .L80323500 - nop -.L803234F0: - cache 0x11, ($t0) - sltu $at, $t0, $t1 - bnez $at, .L803234F0 - addiu $t0, $t0, 0x10 -.L80323500: - jr $ra - nop - -.L80323508: - li $t0, K0BASE - addu $t1, $t0, $t3 - addiu $t1, $t1, -0x10 -.L80323514: - cache 1, ($t0) - sltu $at, $t0, $t1 - bnez $at, .L80323514 - addiu $t0, $t0, 0x10 - jr $ra - nop diff --git a/lib/asm/osInvalICache.s b/lib/asm/osInvalICache.s deleted file mode 100644 index 8b8a03f09..000000000 --- a/lib/asm/osInvalICache.s +++ /dev/null @@ -1,44 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osInvalICache - blez $a1, .L80323728 - nop - li $t3, 16384 - sltu $at, $a1, $t3 - beqz $at, .L80323730 - nop - move $t0, $a0 - addu $t1, $a0, $a1 - sltu $at, $t0, $t1 - beqz $at, .L80323728 - nop - andi $t2, $t0, 0x1f - addiu $t1, $t1, -0x20 - subu $t0, $t0, $t2 -.L80323718: - cache 0x10, ($t0) - sltu $at, $t0, $t1 - bnez $at, .L80323718 - addiu $t0, $t0, 0x20 -.L80323728: - jr $ra - nop - -.L80323730: - li $t0, K0BASE - addu $t1, $t0, $t3 - addiu $t1, $t1, -0x20 -.L8032373C: - cache 0, ($t0) - sltu $at, $t0, $t1 - bnez $at, .L8032373C - addiu $t0, $t0, 0x20 - jr $ra - nop diff --git a/lib/asm/osMapTLB.s b/lib/asm/osMapTLB.s deleted file mode 100644 index b9ee43643..000000000 --- a/lib/asm/osMapTLB.s +++ /dev/null @@ -1,63 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -# This file is handwritten - -#void osMapTLB(s32 index, OSPageMask pm, void *vaddr, u32 evenpaddr, u32 oddpaddr, s32 asid); -glabel osMapTLB - mfc0 $t0, $10 - mtc0 $a0, $0 - mtc0 $a1, $5 - lw $t1, 0x14($sp) #asid - beq $t1, -1, .L803214D8 - li $t4, 1 - li $t2, 30 - b .L803214DC - or $a2, $a2, $t1 #vaddr -.L803214D8: - li $t2, 31 -.L803214DC: - mtc0 $a2, $10 #vaddr - beq $a3, -1, .L80321500 #even paddr - nop - srl $t3, $a3, 6 #evenpaddr - or $t3, $t3, $t2 - mtc0 $t3, $2 - b .L80321504 - nop -.L80321500: - mtc0 $t4, $2 -.L80321504: - lw $t3, 0x10($sp) #oddpaddr - beq $t3, -1, .L80321528 - nop - srl $t3, $t3, 6 - or $t3, $t3, $t2 - mtc0 $t3, $3 - b .L80321540 - nop -.L80321528: - mtc0 $t4, $3 - bne $a3, -1, .L80321540 #evenpaddr - nop - lui $t3, 0x8000 - mtc0 $t3, $10 -.L80321540: - nop - tlbwi - nop - nop - nop - nop - mtc0 $t0, $10 - jr $ra - nop #file gets padded but - nop - nop - nop - diff --git a/lib/asm/osMapTLBRdb.s b/lib/asm/osMapTLBRdb.s deleted file mode 100644 index 6753280d6..000000000 --- a/lib/asm/osMapTLBRdb.s +++ /dev/null @@ -1,36 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osMapTLBRdb - mfc0 $t0, $10 - li $t1, 31 - mtc0 $t1, $0 - mtc0 $zero, $5 - li $t2, 23 - lui $t1, 0xc000 - mtc0 $t1, $10 - lui $t1, 0x8000 - srl $t3, $t1, 6 - or $t3, $t3, $t2 - mtc0 $t3, $2 - li $t1, 1 - mtc0 $t1, $3 - nop - tlbwi - nop - nop - nop - nop - mtc0 $t0, $10 - jr $ra - nop - - nop - nop - diff --git a/lib/asm/osSetIntMask.s b/lib/asm/osSetIntMask.s deleted file mode 100644 index ce1c884de..000000000 --- a/lib/asm/osSetIntMask.s +++ /dev/null @@ -1,145 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - -.eqv MI_INTR_MASK_REG, 0xA430000C - -.ifdef VERSION_EU -.set VERSION_EU_SH, 1 -.endif -.ifdef VERSION_SH -.set VERSION_EU_SH, 1 -.endif - -.section .text, "ax" - -glabel osSetIntMask -.ifdef VERSION_EU_SH - mfc0 $t4, $12 - andi $v0, $t4, 0xff01 - lui $t0, %hi(__OSGlobalIntMask) # $t0, 0x8030 - addiu $t0, %lo(__OSGlobalIntMask) # addiu $t0, $t0, 0x208c - lw $t3, ($t0) - li $at, -1 - xor $t0, $t3, $at - andi $t0, $t0, 0xff00 - or $v0, $v0, $t0 -.else - mfc0 $t1, $12 - andi $v0, $t1, 0xff01 -.endif - lui $t2, %hi(MI_INTR_MASK_REG) # $t2, 0xa430 - lw $t2, %lo(MI_INTR_MASK_REG)($t2) -.ifdef VERSION_EU_SH - beqz $t2, .L80200074 - srl $t1, $t3, 0x10 - li $at, -1 - xor $t1, $t1, $at - andi $t1, $t1, 0x3f - or $t2, $t2, $t1 -.L80200074: -.endif - sll $t2, $t2, 0x10 - or $v0, $v0, $t2 - lui $at, 0x3f - and $t0, $a0, $at -.ifdef VERSION_EU_SH - and $t0, $t0, $t3 -.endif - srl $t0, $t0, 0xf - lui $t2, %hi(D_803386D0) - addu $t2, $t2, $t0 - lhu $t2, %lo(D_803386D0)($t2) - lui $at, %hi(MI_INTR_MASK_REG) # $at, 0xa430 - sw $t2, %lo(MI_INTR_MASK_REG)($at) - andi $t0, $a0, 0xff01 -.ifdef VERSION_EU_SH - andi $t1, $t3, 0xff00 - and $t0, $t0, $t1 -.endif - lui $at, (0xFFFF00FF >> 16) # lui $at, 0xffff - ori $at, (0xFFFF00FF & 0xFFFF) # ori $at, $at, 0xff -.ifdef VERSION_EU_SH - and $t4, $t4, $at - or $t4, $t4, $t0 - mtc0 $t4, $12 -.else - and $t1, $t1, $at - or $t1, $t1, $t0 - mtc0 $t1, $12 -.endif - nop - nop - jr $ra - nop - - -.section .rodata - -glabel D_803386D0 -.half 0x0555 -.half 0x0556 -.half 0x0559 -.half 0x055A -.half 0x0565 -.half 0x0566 -.half 0x0569 -.half 0x056A -.half 0x0595 -.half 0x0596 -.half 0x0599 -.half 0x059A -.half 0x05A5 -.half 0x05A6 -.half 0x05A9 -.half 0x05AA -.half 0x0655 -.half 0x0656 -.half 0x0659 -.half 0x065A -.half 0x0665 -.half 0x0666 -.half 0x0669 -.half 0x066A -.half 0x0695 -.half 0x0696 -.half 0x0699 -.half 0x069A -.half 0x06A5 -.half 0x06A6 -.half 0x06A9 -.half 0x06AA -.half 0x0955 -.half 0x0956 -.half 0x0959 -.half 0x095A -.half 0x0965 -.half 0x0966 -.half 0x0969 -.half 0x096A -.half 0x0995 -.half 0x0996 -.half 0x0999 -.half 0x099A -.half 0x09A5 -.half 0x09A6 -.half 0x09A9 -.half 0x09AA -.half 0x0A55 -.half 0x0A56 -.half 0x0A59 -.half 0x0A5A -.half 0x0A65 -.half 0x0A66 -.half 0x0A69 -.half 0x0A6A -.half 0x0A95 -.half 0x0A96 -.half 0x0A99 -.half 0x0A9A -.half 0x0AA5 -.half 0x0AA6 -.half 0x0AA9 -.half 0x0AAA diff --git a/lib/asm/osUnmapTLBAll.s b/lib/asm/osUnmapTLBAll.s deleted file mode 100644 index 0bd9ad278..000000000 --- a/lib/asm/osUnmapTLBAll.s +++ /dev/null @@ -1,32 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osUnmapTLBAll - mfc0 $t0, $10 - li $t1, 31 - lui $t2, 0x8000 - mtc0 $t2, $10 - mtc0 $zero, $2 - mtc0 $zero, $3 -.L80321588: - mtc0 $t1, $0 - nop - tlbwi - nop - nop - addi $t1, $t1, -1 - bnezl $t1, .L80321588 #bnezl, bnez but with likely hint - nop - mtc0 $t0, $10 - jr $ra - nop - - nop - nop - nop - diff --git a/lib/asm/osWritebackDCache.s b/lib/asm/osWritebackDCache.s deleted file mode 100644 index 8e870168a..000000000 --- a/lib/asm/osWritebackDCache.s +++ /dev/null @@ -1,39 +0,0 @@ -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osWritebackDCache - blez $a1, .osWritebackDCacheReturn - nop - li $t3, 8192 - bgeu $a1, $t3, .L80324E40 - nop - move $t0, $a0 - addu $t1, $a0, $a1 - bgeu $t0, $t1, .osWritebackDCacheReturn - nop - andi $t2, $t0, 0xf - addiu $t1, $t1, -0x10 - subu $t0, $t0, $t2 -.L80324E28: - cache 0x19, ($t0) - bltu $t0, $t1, .L80324E28 - addiu $t0, $t0, 0x10 -.osWritebackDCacheReturn: - jr $ra - nop - -.L80324E40: - lui $t0, 0x8000 - addu $t1, $t0, $t3 - addiu $t1, $t1, -0x10 -.L80324E4C: - cache 1, ($t0) - bltu $t0, $t1, .L80324E4C - addiu $t0, 0x10 # addiu $t0, $t0, 0x10 - jr $ra - nop diff --git a/lib/asm/osWritebackDCacheAll.s b/lib/asm/osWritebackDCacheAll.s deleted file mode 100644 index 887076043..000000000 --- a/lib/asm/osWritebackDCacheAll.s +++ /dev/null @@ -1,24 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - - -.section .text, "ax" - -glabel osWritebackDCacheAll - li $t0, K0BASE - li $t2, 8192 - addu $t1, $t0, $t2 - addiu $t1, $t1, -0x10 -.L80322020: - cache 1, ($t0) - sltu $at, $t0, $t1 - bnez $at, .L80322020 - addiu $t0, $t0, 0x10 - jr $ra - nop - - nop - nop diff --git a/lib/asm/parameters.s b/lib/asm/parameters.s deleted file mode 100644 index 0314d41f3..000000000 --- a/lib/asm/parameters.s +++ /dev/null @@ -1,28 +0,0 @@ -.macro gsymbol sym addr -.global \sym -.set \sym, \addr -.ifndef VERSION_JP -nop -nop -.endif -.endm - -.text -gsymbol osTvType 0x80000300 -gsymbol osRomType 0x80000304 -gsymbol osRomBase 0x80000308 -gsymbol osResetType 0x8000030C -gsymbol osCiCId 0x80000310 -gsymbol osVersion 0x80000314 -gsymbol osMemSize 0x80000318 -gsymbol osAppNmiBuffer 0x8000031C -.ifdef VERSION_SH -nop -nop -nop -nop -nop -nop -nop -nop -.endif \ No newline at end of file diff --git a/lib/asm/sqrtf.s b/lib/asm/sqrtf.s deleted file mode 100644 index a3ce7756d..000000000 --- a/lib/asm/sqrtf.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 - -.include "macros.inc" - -.section .text, "ax" - -glabel sqrtf - jr $ra - sqrt.s $f0, $f12 diff --git a/lib/libhvqm2.a b/lib/libhvqm2.a new file mode 100644 index 000000000..42f829454 Binary files /dev/null and b/lib/libhvqm2.a differ diff --git a/lib/libultra.a b/lib/libultra.a new file mode 100644 index 000000000..21f58e963 Binary files /dev/null and b/lib/libultra.a differ diff --git a/lib/libultra_d.a b/lib/libultra_d.a new file mode 100644 index 000000000..4fe141cd4 Binary files /dev/null and b/lib/libultra_d.a differ diff --git a/lib/libultra_rom.a b/lib/libultra_rom.a new file mode 100644 index 000000000..f8cf8b66e Binary files /dev/null and b/lib/libultra_rom.a differ diff --git a/lib/rsp.s b/lib/rsp.s index bfc598755..c00c2e568 100644 --- a/lib/rsp.s +++ b/lib/rsp.s @@ -4,35 +4,47 @@ .section .text .balign 16 -glabel rspF3DBootStart +glabel rspbootTextStart .incbin "rsp/rspboot.bin" .balign 16 -glabel rspF3DBootEnd +glabel rspbootTextEnd .balign 16 .ifndef F3DEX_GBI_SHARED -glabel rspF3DStart /* Use regular Fast3D bins (default) */ +.if SUPER3D_GBI == 1 +glabel gspSuper3D_fifoTextStart + .incbin "lib/PR/super3d/Super3D.bin" +glabel gspSuper3D_fifoTextEnd +.else +glabel gspFast3D_fifoTextStart /* Use regular Fast3D bins (default) */ .incbin "rsp/fast3d.bin" -glabel rspF3DEnd +glabel gspFast3D_fifoTextEnd +.endif .else /* Use one of the Fast3DEX series grucodes. */ -glabel rspF3DStart - .if F3DZEX_GBI_2 == 1 - .incbin "lib/PR/f3dex2/F3DZEX_NoN.bin" - .elseif F3DEX_GBI == 1 - .incbin "lib/PR/f3dex/F3DEX.bin" - .elseif F3DEX_GBI_2 == 1 + .ifndef F3DZEX_GBI_2 + .if F3DEX_GBI_2 == 1 + glabel gspF3DEX2_fifoTextStart .incbin "lib/PR/f3dex2/F3DEX2.bin" + glabel gspF3DEX2_fifoTextEnd + .elseif F3DEX_GBI == 1 + glabel gspF3DEX_fifoTextStart + .incbin "lib/PR/f3dex/F3DEX.bin" + glabel gspF3DEX_fifoTextEnd + .endif + .else /* Fast3DZEX */ + glabel gspF3DZEX2_PosLight_fifoTextStart + .incbin "lib/PR/f3dzex/F3DZEX.bin" + glabel gspF3DZEX2_PosLight_fifoTextEnd .endif -glabel rspF3DEnd .endif /* Audio Bins */ .balign 16 -glabel rspAspMainStart - .incbin "rsp/audio.bin" -glabel rspAspMainEnd +glabel aspMainTextStart + .incbin "lib/PR/audio/aspMain.bin" +glabel aspMainTextEnd /* * LESS COMMON MICROCODES @@ -41,49 +53,49 @@ glabel rspAspMainEnd /* Fast3DEX NoN Text */ .ifdef F3DEX_NON_GBI -glabel rspF3DEXNoNStart +glabel gspF3DEX_NoN_fifoTextStart .balign 16 .incbin "lib/PR/f3dex/F3DEX_NoN.bin" -glabel rspF3DEXNoNEnd +glabel gspF3DEX_NoN_fifoTextEnd .endif /* Fast3DLX Text */ .ifdef F3DLX_GBI -glabel rspF3DLXStart +glabel gspF3DLX_fifoTextStart .incbin "lib/PR/f3dex/F3DLX.bin" -glabel rspF3DLXEnd +glabel gspF3DLX_fifoTextEnd .endif /* Fast3DLX NoN Text */ .ifdef F3DLX_NON_GBI -glabel rspF3DLXNoNStart +glabel gspF3DLX_NoN_fifoTextStart .balign 16 .incbin "lib/PR/f3dex/F3DLX_NoN.bin" -glabel rspF3DLXNoNEnd +glabel gspF3DLX_NoN_fifoTextEnd .endif /* Fast3DLX Rej Text */ .ifdef F3DLX_REJ_GBI -glabel rspF3DLXRejStart +glabel gspF3DLX_Rej_fifoTextStart .balign 16 .incbin "lib/PR/f3dex/F3DLX_Rej.bin" -glabel rspF3DLXRejEnd +glabel gspF3DLX_Rej_fifoTextEnd .endif /* Line3DEX Text */ .ifdef L3DEX_GBI -glabel rspL3DEXStart +glabel gspL3DEX_fifoTextStart .balign 16 .incbin "lib/PR/f3dex/L3DEX.bin" -glabel rspL3DEXEnd +glabel gspL3DEX_fifoTextEnd .endif /* S2DEX Text */ .ifdef S2DEX_GBI -glabel rspS2DEXStart +glabel gspS2DEX_fifoTextStart .balign 16 .incbin "lib/PR/s2dex/S2DEX.bin" -glabel rspS2DEXEnd +glabel gspS2DEX_fifoTextEnd .endif /* Fast3DEX2 series */ @@ -91,33 +103,49 @@ glabel rspS2DEXEnd /* Fast3DEX2 NoN Text */ .ifdef F3DEX2_NON_GBI .balign 16 -glabel rspF3DEX2NoNStart +glabel gspF3DEX2_NoN_fifoTextStart .incbin "lib/PR/f3dex2/F3DEX2_NoN.bin" -glabel rspF3DEX2NoNEnd +glabel gspF3DEX2_NoN_fifoTextEnd +.endif + +/* Fast3DZEX NoN Text */ +.ifdef F3DZEX_NON_GBI_2 +.balign 16 +glabel gspF3DZEX2_NoN_PosLight_fifoTextStart + .incbin "lib/PR/f3dzex/F3DZEX_NoN.bin" +glabel gspF3DZEX2_NoN_PosLight_fifoTextEnd .endif /* Fast3DEX2 Rej Text */ .ifdef F3DEX2_REJ_GBI .balign 16 -glabel rspF3DEX2RejStart +glabel gspF3DEX2_Rej_fifoTextStart .incbin "lib/PR/f3dex2/F3DEX2_Rej.bin" -glabel rspF3DEX2RejEnd +glabel gspF3DEX2_Rej_fifoTextEnd .endif /* Line3DEX2 Text */ .ifdef L3DEX2_GBI .balign 16 -glabel rspL3DEX2Start +glabel gspL3DEX2_fifoTextStart .incbin "lib/PR/f3dex2/L3DEX2.bin" -glabel rspL3DEX2End +glabel gspL3DEX2_fifoTextEnd +.endif + +/* Line3DZEX Text */ +.ifdef L3DZEX_GBI +.balign 16 +glabel gspL3DZEX2_PosLight_fifoTextStart + .incbin "lib/PR/f3dzex/L3DZEX.bin" +glabel gspL3DZEX2_PosLight_fifoTextEnd .endif /* S2DEX2 Text */ .ifdef S2DEX_GBI_2 .balign 16 -glabel rspS2DEXStart - .incbin "lib/PR/s2dex/S2DEX2.bin" -glabel rspS2DEXEnd +glabel gspS2DEX2_fifoTextStart + .incbin "lib/PR/s2dex2/S2DEX2.bin" +glabel gspS2DEX2_fifoTextEnd .endif /* DATA SECTION START */ @@ -126,28 +154,40 @@ glabel rspS2DEXEnd .balign 16 .ifndef F3DEX_GBI_SHARED /* Use regular Fast3D data (default) */ -glabel rspF3DDataStart + .if SUPER3D_GBI == 1 +glabel gspSuper3D_fifoDataStart + .incbin "lib/PR/super3d/Super3D_data.bin" +glabel gspSuper3D_fifoDataEnd +.else +glabel gspFast3D_fifoDataStart .incbin "rsp/fast3d_data.bin" -glabel rspF3DDataEnd +glabel gspFast3D_fifoDataEnd +.endif .else /* Using one of the Fast3DEX series grucodes */ -glabel rspF3DDataStart - .if F3DZEX_GBI_2 == 1 - .incbin "lib/PR/f3dex2/F3DZEX_NoN_data.bin" - .elseif F3DEX_GBI == 1 - .incbin "lib/PR/f3dex/F3DEX_data.bin" - .elseif F3DEX_GBI_2 == 1 + .ifndef F3DZEX_GBI_2 + .if F3DEX_GBI_2 == 1 + glabel gspF3DEX2_fifoDataStart .incbin "lib/PR/f3dex2/F3DEX2_data.bin" + glabel gspF3DEX2_fifoDataEnd + .elseif F3DEX_GBI == 1 + glabel gspF3DEX_fifoDataStart + .incbin "lib/PR/f3dex/F3DEX_data.bin" + glabel gspF3DEX_fifoDataEnd + .endif + .else /* Fast3DZEX */ + glabel gspF3DZEX2_PosLight_fifoDataStart + .incbin "lib/PR/f3dzex/F3DZEX_data.bin" + glabel gspF3DZEX2_PosLight_fifoDataEnd .endif -glabel rspF3DDataEnd .endif /* Audio Data */ .balign 16 -glabel rspAspMainDataStart - .incbin "rsp/audio_data.bin" -glabel rspAspMainDataEnd +glabel aspMainDataStart + .incbin "lib/PR/audio/aspMain_data.bin" +glabel aspMainDataEnd /* LESS COMMON MICROCODES */ @@ -156,49 +196,49 @@ glabel rspAspMainDataEnd /* Fast3DEX NoN Data */ .ifdef F3DEX_NON_GBI .balign 16 -glabel rspF3DEXNoNDataStart +glabel gspF3DEX_NoN_fifoDataStart .incbin "lib/PR/f3dex/F3DEX_NoN_data.bin" -glabel rspF3DEXNoNDataEnd +glabel gspF3DEX_NoN_fifoDataEnd .endif /* Fast3DLX Data */ .ifdef F3DLX_GBI .balign 16 -glabel rspF3DLXDataStart +glabel gspF3DLX_fifoDataStart .incbin "lib/PR/f3dex/F3DLX_data.bin" -glabel rspF3DLXDataEnd +glabel gspF3DLX_fifoDataEnd .endif /* Fast3DLX NoN Data */ .ifdef F3DLX_NON_GBI .balign 16 -glabel rspF3DLXNoNDataStart +glabel gspF3DLX_NoN_fifoDataStart .incbin "lib/PR/f3dex/F3DLX_NoN_data.bin" -glabel rspF3DLXNoNDataEnd +glabel gspF3DLX_NoN_fifoDataEnd .endif /* Fast3DLX Rej Data */ .ifdef F3DLX_REJ_GBI .balign 16 -glabel rspF3DLXRejDataStart +glabel gspF3DLX_Rej_fifoDataStart .incbin "lib/PR/f3dex/F3DLX_Rej_data.bin" -glabel rspF3DLXRejDataEnd +glabel gspF3DLX_Rej_fifoDataEnd .endif /* Line3DEX Data */ .ifdef L3DEX_GBI .balign 16 -glabel rspL3DEXDataStart +glabel gspL3DEX_fifoDataStart .incbin "lib/PR/f3dex/L3DEX_data.bin" -glabel rspL3DEXDataEnd +glabel gspL3DEX_fifoDataEnd .endif /* S2DEX Data */ .ifdef S2DEX_GBI .balign 16 -glabel rspS2DEXDataStart +glabel gspS2DEX_fifoDataStart .incbin "lib/PR/s2dex/S2DEX_data.bin" -glabel rspS2DEXDataEnd +glabel gspS2DEX_fifoDataEnd .endif /* Fast3DEX2 Series */ @@ -206,31 +246,47 @@ glabel rspS2DEXDataEnd /* Fast3DEX2 NoN Data */ .ifdef F3DEX2_NON_GBI .balign 16 -glabel rspF3DEX2NoNStart +glabel gspF3DEX2_NoN_fifoDataStart .incbin "lib/PR/f3dex2/F3DEX2_NoN_data.bin" -glabel rspF3DEX2NoNEnd +glabel gspF3DEX2_NoN_fifoDataEnd +.endif + +/* Fast3DZEX NoN Data */ +.ifdef F3DZEX_NON_GBI_2 +.balign 16 +glabel gspF3DZEX2_NoN_PosLight_fifoDataStart + .incbin "lib/PR/f3dzex/F3DZEX_NoN_data.bin" +glabel gspF3DZEX2_NoN_PosLight_fifoDataEnd .endif /* Fast3DEX2 Rej Data */ .ifdef F3DEX2_REJ_GBI .balign 16 -glabel rspF3DEX2RejStart +glabel gspF3DEX2_Rej_fifoDataStart .incbin "lib/PR/f3dex2/F3DEX2_Rej_data.bin" -glabel rspF3DEX2RejEnd +glabel gspF3DEX2_Rej_fifoDataEnd .endif /* Line3DEX2 Data */ .ifdef L3DEX2_GBI .balign 16 -glabel rspL3DEX2Start +glabel gspL3DEX2_fifoDataStart .incbin "lib/PR/f3dex2/L3DEX2_data.bin" -glabel rspL3DEX2End +glabel gspL3DEX2_fifoDataEnd +.endif + +/* Line3DZEX Text */ +.ifdef L3DZEX_GBI +.balign 16 +glabel gspL3DZEX2_PosLight_fifoDataStart + .incbin "lib/PR/f3dzex/L3DZEX_data.bin" +glabel gspL3DZEX2_PosLight_fifoDataEnd .endif /* S2DEX2 Data */ .ifdef S2DEX_GBI_2 .balign 16 -glabel rspS2DEXStart - .incbin "lib/PR/s2dex/S2DEX2_data.bin" -glabel rspS2DEXEnd +glabel gspS2DEX2_fifoDataStart + .incbin "lib/PR/s2dex2/S2DEX2_data.bin" +glabel gspS2DEX2_fifoDataEnd .endif diff --git a/lib/src/D_802F4380.c b/lib/src/D_802F4380.c deleted file mode 100644 index bc7fce244..000000000 --- a/lib/src/D_802F4380.c +++ /dev/null @@ -1,148 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" -#include "new_func.h" -#include "macros.h" - -#if defined(VERSION_EU) -u32 D_802F4380() { - u32 sp3c; - u32 sp38; - u32 sp34; - __OSTranxInfo *sp30; - __OSBlockInfo *sp2c; - u32 sp28; - UNUSED __OSBlockInfo *sp24; - if (!EU_D_80302090) { - return 0; - } - sp30 = &__osDiskHandle->transferInfo; - sp2c = &sp30->block[sp30->blockNum]; - sp38 = HW_REG(PI_STATUS_REG, u32); - if (sp38 & PI_STATUS_BUSY) { - HW_REG(PI_STATUS_REG, u32) = PI_STATUS_RESET_CONTROLLER | PI_STATUS_CLEAR_INTR; - WAIT_ON_IOBUSY(sp38); - sp3c = HW_REG(ASIC_STATUS, u32); - if (sp3c & MECHANIC_INTERRUPT) { - WAIT_ON_IOBUSY(sp38); - HW_REG(ASIC_BM_CTL, u32) = sp30->bmCtlShadow | MECHANIC_INTERRUPT_RESET; - } - sp30->errStatus = 75; - func_802F4A20(); - return 1; - } - WAIT_ON_IOBUSY(sp38); - sp3c = HW_REG(ASIC_STATUS, u32); - if (sp3c & MECHANIC_INTERRUPT) { - WAIT_ON_IOBUSY(sp38); - HW_REG(ASIC_BM_CTL, u32) = sp30->bmCtlShadow | MECHANIC_INTERRUPT_RESET; - sp30->errStatus = 0; - return 0; - } - if (sp3c & BUFFER_MANAGER_ERROR) { - sp30->errStatus = 3; - func_802F4A20(); - return 1; - } - if (sp30->cmdType == 1) { - if ((sp3c & DATA_REQUEST) == 0) { - if (sp30->sectorNum + 1 != sp30->transferMode * 85) { - sp30->errStatus = 6; - func_802F4A20(); - return 1; - } - HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; - __OSGlobalIntMask |= 0x00100401; - sp30->errStatus = 0; - func_802F4B08(); - return 1; - } - sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize); - sp30->sectorNum += 1; - osEPiRawStartDma(__osDiskHandle, 1, 0x05000400, sp2c->dramAddr, sp2c->sectorSize); - return 1; - } - if (sp30->cmdType == 0) { - if (sp30->transferMode == 3) { - if ((s32)(sp2c->C1ErrNum + 17) < sp30->sectorNum) { - sp30->errStatus = 0; - func_802F4A20(); - return 1; - } - if ((sp3c & DATA_REQUEST) == 0) { - sp30->errStatus = 17; - func_802F4A20(); - return 1; - } - } else { - sp2c->dramAddr = (void *) ((u32) sp2c->dramAddr + sp2c->sectorSize); - } - sp34 = HW_REG(ASIC_BM_STATUS, u32); - if (((C1_SINGLE & sp34) && (C1_DOUBLE & sp34)) || (sp34 & MICRO_STATUS)) - { - if (sp2c->C1ErrNum > 3) { - if (sp30->transferMode != 3 || sp30->sectorNum > 0x52) { - sp30->errStatus = 17; - func_802F4A20(); - return 1; - } - } else { - sp28 = sp2c->C1ErrNum; - sp2c->C1ErrSector[sp28] = sp30->sectorNum + 1; - } - sp2c->C1ErrNum += 1; - } - if (sp3c & C2_TRANSFER) { - if (sp30->sectorNum != 87) { - sp30->errStatus = 6; - func_802F4A20(); - } - if (sp30->transferMode == 2 && sp30->blockNum == 0) { - sp30->blockNum = 1; - sp30->sectorNum = -1; - sp30->block[1].dramAddr = - (void *) ((u32) sp30->block[1].dramAddr - sp30->block[1].sectorSize); - } else { - HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; - __OSGlobalIntMask |= 0x00100401; - } - osEPiRawStartDma(__osDiskHandle, 0, 0x5000000, sp2c->C2Addr, sp2c->sectorSize * 4); - sp30->errStatus = 0; - return 1; - } - - if (sp30->sectorNum == -1 && sp30->transferMode == 2 && sp30->blockNum == 1) { - sp24 = &sp30->block[0]; - if (sp30->block[0].C1ErrNum == 0) { - if (((u32 *) sp30->block[0].C2Addr)[0] | ((u32 *) sp30->block[0].C2Addr)[1] - | ((u32 *) sp30->block[0].C2Addr)[2] | ((u32 *) sp30->block[0].C2Addr)[3]) { - sp30->errStatus = 6; - func_802F4A20(); - return 1; - } - } - sp30->errStatus = 0; - func_802F4B08(); - } - sp30->sectorNum += 1; - if (sp3c & DATA_REQUEST) { - if (sp30->sectorNum > 0x54) { - sp30->errStatus = 6; - func_802F4A20(); - return 1; - } - osEPiRawStartDma(__osDiskHandle, 0, 0x05000400, sp2c->dramAddr, sp2c->sectorSize); - sp30->errStatus = 0; - return 1; - } - if (sp30->sectorNum <= 0x54) { - sp30->errStatus = 6; - func_802F4A20(); - return 1; - } - return 1; - } - sp30->errStatus = 75; - func_802F4A20(); - return 1; -} -#endif diff --git a/lib/src/EU_D_802f4330.c b/lib/src/EU_D_802f4330.c deleted file mode 100644 index ad9b3bacf..000000000 --- a/lib/src/EU_D_802f4330.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "libultra_internal.h" - -// an array of pointers to functions taking no arguments and returning u32... -// this is only referenced in the exception handler and here. this function is called with a0=1 and -// then the same memory address is loaded. it's definitely an array access though.. -extern u32 (*D_80334920[8])(void) ; - -void EU_D_802f4330(u32 a0, u32 a1(void)) { - register u32 int_disabled = __osDisableInt(); - D_80334920[a0] = a1; - __osRestoreInt(int_disabled); -} diff --git a/lib/src/NaN.c b/lib/src/NaN.c deleted file mode 100644 index 05f4031cd..000000000 --- a/lib/src/NaN.c +++ /dev/null @@ -1,5 +0,0 @@ -typedef union { - int i; - float f; -} fu; -const fu NAN = { 0x7f810000 }; diff --git a/lib/src/__osAiDeviceBusy.c b/lib/src/__osAiDeviceBusy.c deleted file mode 100644 index 261fcbaba..000000000 --- a/lib/src/__osAiDeviceBusy.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osAiDeviceBusy(void) { - register s32 status = HW_REG(AI_STATUS_REG, u32); - if ((status & AI_STATUS_AI_FULL) != 0) { - return 1; - } else { - return 0; - } -} diff --git a/lib/src/__osAtomicDec.c b/lib/src/__osAtomicDec.c deleted file mode 100644 index 87ff265eb..000000000 --- a/lib/src/__osAtomicDec.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libultra_internal.h" - -s32 __osAtomicDec(u32 *a0) { - s32 sp1c; - s32 sp18; - sp1c = __osDisableInt(); - - if (*a0 != 0) { - (*a0)--; - sp18 = 1; - } else { - sp18 = 0; - } - - __osRestoreInt(sp1c); - return sp18; -} diff --git a/lib/src/__osDequeueThread.c b/lib/src/__osDequeueThread.c deleted file mode 100644 index 087583786..000000000 --- a/lib/src/__osDequeueThread.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "libultra_internal.h" - -// these don't feel like they belong here -// but it makes the most logical since there was printf data before -#ifndef AVOID_UB -OSThread *D_80334890 = NULL; -u32 D_80334894 = -1; -OSThread *D_80334898 = (OSThread *) &D_80334890; -OSThread *D_8033489C = (OSThread *) &D_80334890; -OSThread *D_803348A0 = NULL; -u32 D_803348A4 = 0; // UNKNOWN -#else -OSThread_ListHead D_80334890_fix = {NULL, -1, (OSThread *) &D_80334890_fix, (OSThread *) &D_80334890_fix, NULL, 0}; -#endif - -void __osDequeueThread(OSThread **queue, OSThread *thread) { - register OSThread **a2; - register OSThread *a3; - a2 = queue; - a3 = *a2; - while (a3 != NULL) { - if (a3 == thread) { - *a2 = thread->next; - return; - } - a2 = &a3->next; - a3 = *a2; - } -} diff --git a/lib/src/__osDevMgrMain.c b/lib/src/__osDevMgrMain.c deleted file mode 100644 index 3f48e8fc8..000000000 --- a/lib/src/__osDevMgrMain.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "libultra_internal.h" -#include "macros.h" - -#if defined(VERSION_EU) || defined(VERSION_SH) -#include "new_func.h" - -void __osDevMgrMain(void *args) { - OSIoMesg *mb; - OSMesg em; - OSMesg dummy; - s32 ret; - OSMgrArgs *sp34; -#ifndef VERSION_SH - UNUSED u32 sp30; -#endif - u32 sp2c; - __OSBlockInfo *sp28; - __OSTranxInfo *sp24; -#ifdef VERSION_SH - u32 tmp; -#endif -#ifndef VERSION_SH - sp30 = 0; -#endif - sp2c = 0; - mb = NULL; - ret = 0; - sp34 = (OSMgrArgs *) args; - while (TRUE) { - osRecvMesg(sp34->cmdQueue, (OSMesg) &mb, OS_MESG_BLOCK); - if (mb->piHandle != NULL && mb->piHandle->type == 2 - && (mb->piHandle->transferInfo.cmdType == 0 - || mb->piHandle->transferInfo.cmdType == 1)) { - sp24 = &mb->piHandle->transferInfo; - sp28 = &sp24->block[sp24->blockNum]; - sp24->sectorNum = -1; - if (sp24->transferMode != 3) { - sp28->dramAddr = (void *) ((u32) sp28->dramAddr - sp28->sectorSize); - } - if (sp24->transferMode == 2 && mb->piHandle->transferInfo.cmdType == 0) { - sp2c = 1; - } else { - sp2c = 0; - } - osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - __osResetGlobalIntMask(0x00100401); // remove magic constant! - __osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000)); - while (TRUE) { - osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK); -#ifdef VERSION_SH - sp24 = &mb->piHandle->transferInfo; - sp28 = &sp24->block[sp24->blockNum]; - if (sp28->errStatus == 0x1D) { - __osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x10000000); - __osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow); - __osEPiRawReadIo(mb->piHandle, 0x5000508, &tmp); - if ((tmp & 0x2000000) != 0) { - __osEPiRawWriteIo(mb->piHandle, 0x5000510, sp24->bmCtlShadow | 0x1000000); - } - sp28->errStatus = 4; - HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; - __osSetGlobalIntMask(0x100C01); - } - osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); - if (sp2c != 1 || mb->piHandle->transferInfo.block[0].errStatus != 0) { - break; - } -#else - sp30 = osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); - if (sp2c != 1 || mb->piHandle->transferInfo.errStatus != 0) { - break; - } -#endif - sp2c = 0; - } - osSendMesg(sp34->accessQueue, NULL, OS_MESG_NOBLOCK); - if (mb->piHandle->transferInfo.blockNum == 1) { - func_802F71F0(); - } - } else { - switch (mb->hdr.type) { - case 11: - osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->dma_func(OS_READ, mb->devAddr, mb->dramAddr, mb->size); - break; - case 12: - osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->dma_func(OS_WRITE, mb->devAddr, mb->dramAddr, mb->size); - break; - case 15: - osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->edma_func(mb->piHandle, OS_READ, mb->devAddr, mb->dramAddr, - mb->size); - break; - case 16: - osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); - ret = sp34->edma_func(mb->piHandle, OS_WRITE, mb->devAddr, mb->dramAddr, - mb->size); - break; - case 10: - osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); - ret = -1; - break; - break; - default: - ret = -1; - break; - } - if (ret == 0) { - osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK); -#ifndef VERSION_SH - sp30 = -#endif - osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); - osSendMesg(sp34->accessQueue, NULL, OS_MESG_NOBLOCK); - } - } - } -} -#else -void __osDevMgrMain(void *args) { - OSIoMesg *sp34; - OSMesg sp30; - OSMesg sp2c; - s32 sp28; - OSMgrArgs *sp24; - sp34 = NULL; - sp28 = 0; - sp24 = (OSMgrArgs *) args; - while (TRUE) { - osRecvMesg(sp24->cmdQueue, (OSMesg) &sp34, OS_MESG_BLOCK); - switch (sp34->hdr.type) { - case 11: - osRecvMesg(sp24->accessQueue, &sp2c, OS_MESG_BLOCK); - sp28 = sp24->dma_func(OS_READ, sp34->devAddr, sp34->dramAddr, sp34->size); - break; - case 12: - osRecvMesg(sp24->accessQueue, &sp2c, OS_MESG_BLOCK); - sp28 = sp24->dma_func(OS_WRITE, sp34->devAddr, sp34->dramAddr, sp34->size); - break; - case 10: - osSendMesg(sp34->hdr.retQueue, sp34, OS_MESG_NOBLOCK); - sp28 = -1; - break; - default: - sp28 = -1; - break; - } - if (sp28 == 0) { - osRecvMesg(sp24->eventQueue, &sp30, OS_MESG_BLOCK); - osSendMesg(sp34->hdr.retQueue, sp34, OS_MESG_NOBLOCK); - osSendMesg(sp24->accessQueue, NULL, OS_MESG_NOBLOCK); - } - } -} -#endif diff --git a/lib/src/__osEPiRawReadIo.c b/lib/src/__osEPiRawReadIo.c deleted file mode 100644 index 28c403a28..000000000 --- a/lib/src/__osEPiRawReadIo.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osEPiRawReadIo(OSPiHandle *arg0, u32 devAddr, u32 *data) { - register s32 stat; - while (stat = HW_REG(PI_STATUS_REG, s32), stat & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { - ; - } - *data = HW_REG(arg0->baseAddress | devAddr, s32); - return 0; -} diff --git a/lib/src/__osEPiRawWriteIo.c b/lib/src/__osEPiRawWriteIo.c deleted file mode 100644 index 539a5c65c..000000000 --- a/lib/src/__osEPiRawWriteIo.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osEPiRawWriteIo(OSPiHandle *a0, u32 a1, u32 a2) { - register u32 a3 = HW_REG(PI_STATUS_REG, u32); - while (a3 & PI_STATUS_ERROR) - a3 = HW_REG(PI_STATUS_REG, u32); - HW_REG(a0->baseAddress | a1, u32) = a2; - return 0; -} -/* -/ 0B69A0 802F71A0 3C0EA460 / lui $t6, %hi(PI_STATUS_REG) # $t6, 0xa460 -/ 0B69A4 802F71A4 8DC70010 / lw $a3, %lo(PI_STATUS_REG)($t6) -/ 0B69A8 802F71A8 27BDFFF8 / addiu $sp, $sp, -8 -/ 0B69AC 802F71AC 30EF0003 / andi $t7, $a3, 3 - -/ 0B69B0 802F71B0 11E00006 / beqz $t7, .L802F71CC -/ 0B69B4 802F71B4 00000000 / nop -.L802F71B8: -/ 0B69B8 802F71B8 3C18A460 / lui $t8, %hi(PI_STATUS_REG) # $t8, 0xa460 -/ 0B69BC 802F71BC 8F070010 / lw $a3, %lo(PI_STATUS_REG)($t8) -/ 0B69C0 802F71C0 30F90003 / andi $t9, $a3, 3 -/ 0B69C4 802F71C4 1720FFFC / bnez $t9, .L802F71B8 -/ 0B69C8 802F71C8 00000000 / nop -.L802F71CC: -/ 0B69CC 802F71CC 8C88000C / lw $t0, 0xc($a0) -/ 0B69D0 802F71D0 3C01A000 / lui $at, 0xa000 -/ 0B69D4 802F71D4 27BD0008 / addiu $sp, $sp, 8 -/ 0B69D8 802F71D8 01054825 / or $t1, $t0, $a1 -/ 0B69DC 802F71DC 01215025 / or $t2, $t1, $at -/ 0B69E0 802F71E0 AD460000 / sw $a2, ($t2) -/ 0B69E4 802F71E4 03E00008 / jr $ra -/ 0B69E8 802F71E8 00001025 / move $v0, $zero - -/ 0B69EC 802F71EC 00000000 / nop */ diff --git a/lib/src/__osGetCurrFaultedThread.c b/lib/src/__osGetCurrFaultedThread.c deleted file mode 100644 index f4951ff1e..000000000 --- a/lib/src/__osGetCurrFaultedThread.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "libultra_internal.h" - -OSThread *__osGetCurrFaultedThread() { - return D_8033489C; // 80302efc -} diff --git a/lib/src/__osPiCreateAccessQueue.c b/lib/src/__osPiCreateAccessQueue.c deleted file mode 100644 index 90d4c86ab..000000000 --- a/lib/src/__osPiCreateAccessQueue.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "libultra_internal.h" - -#define PIAccessQueueSize 2 - -OSMesg osPiMesgBuff[PIAccessQueueSize]; -OSMesgQueue gOsPiMessageQueue; -u32 gOsPiAccessQueueCreated = 0; - -void __osPiCreateAccessQueue(void) { - gOsPiAccessQueueCreated = 1; - osCreateMesgQueue(&gOsPiMessageQueue, &osPiMesgBuff[0], PIAccessQueueSize - 1); - osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK); -} - -void __osPiGetAccess(void) { - OSMesg sp1c; - if (!gOsPiAccessQueueCreated) { - __osPiCreateAccessQueue(); - } - osRecvMesg(&gOsPiMessageQueue, &sp1c, OS_MESG_BLOCK); -} - -void __osPiRelAccess(void) { - osSendMesg(&gOsPiMessageQueue, NULL, OS_MESG_NOBLOCK); -} diff --git a/lib/src/__osResetGlobalIntMask.c b/lib/src/__osResetGlobalIntMask.c deleted file mode 100644 index e6b0de27d..000000000 --- a/lib/src/__osResetGlobalIntMask.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "libultra_internal.h" -#include "new_func.h" - -void __osResetGlobalIntMask(u32 mask) { - register u32 prev; - prev = __osDisableInt(); - __OSGlobalIntMask &= ~(-0x402 & mask); - __osRestoreInt(prev); -} diff --git a/lib/src/__osSetGlobalIntMask.c b/lib/src/__osSetGlobalIntMask.c deleted file mode 100644 index c800bb334..000000000 --- a/lib/src/__osSetGlobalIntMask.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" -#include "new_func.h" - -void __osSetGlobalIntMask(s32 arg0) { - register u32 prev = __osDisableInt(); - __OSGlobalIntMask |= arg0; - __osRestoreInt(prev); -} diff --git a/lib/src/__osSiCreateAccessQueue.c b/lib/src/__osSiCreateAccessQueue.c deleted file mode 100644 index 069177747..000000000 --- a/lib/src/__osSiCreateAccessQueue.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "libultra_internal.h" - -#define SIAccessQueueSize 2 - -OSMesg osSiMesgBuff[SIAccessQueueSize]; -OSMesgQueue gOsSiMessageQueue; -u32 gOsSiAccessQueueCreated = 0; - -void __osSiCreateAccessQueue() { - gOsSiAccessQueueCreated = 1; - osCreateMesgQueue(&gOsSiMessageQueue, &osSiMesgBuff[0], SIAccessQueueSize - 1); - osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK); -} - -void __osSiGetAccess(void) { - OSMesg sp1c; - if (!gOsSiAccessQueueCreated) { - __osSiCreateAccessQueue(); - } - osRecvMesg(&gOsSiMessageQueue, &sp1c, OS_MESG_BLOCK); -} - -void __osSiRelAccess(void) { - osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK); -} diff --git a/lib/src/__osSiDeviceBusy.c b/lib/src/__osSiDeviceBusy.c deleted file mode 100644 index 5872f1344..000000000 --- a/lib/src/__osSiDeviceBusy.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSiDeviceBusy() { - register u32 status; - status = HW_REG(SI_STATUS_REG, u32); - if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { - return 1; - } else { - return 0; - } -} diff --git a/lib/src/__osSiRawReadIo.c b/lib/src/__osSiRawReadIo.c deleted file mode 100644 index 03654dab2..000000000 --- a/lib/src/__osSiRawReadIo.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSiRawReadIo(void *a0, u32 *a1) { - if (__osSiDeviceBusy()) { - return -1; - } - *a1 = HW_REG((uintptr_t) a0, u32); - return 0; -} diff --git a/lib/src/__osSiRawStartDma.c b/lib/src/__osSiRawStartDma.c deleted file mode 100644 index 965b71879..000000000 --- a/lib/src/__osSiRawStartDma.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSiRawStartDma(s32 dir, void *addr) { - if (__osSiDeviceBusy()) { - return -1; - } - - if (dir == OS_WRITE) { - osWritebackDCache(addr, 64); - } - - HW_REG(SI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(addr); - - if (dir == OS_READ) { - HW_REG(SI_PIF_ADDR_RD64B_REG, u32) = 0x1FC007C0; - } else { - HW_REG(SI_PIF_ADDR_WR64B_REG, u32) = 0x1FC007C0; - } - - if (dir == OS_READ) { - osInvalDCache(addr, 64); - } - return 0; -} diff --git a/lib/src/__osSiRawWriteIo.c b/lib/src/__osSiRawWriteIo.c deleted file mode 100644 index 8da0a3d65..000000000 --- a/lib/src/__osSiRawWriteIo.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSiRawWriteIo(void *a0, u32 a1) { - if (__osSiDeviceBusy()) { - return -1; - } - HW_REG((uintptr_t) a0, u32) = a1; - return 0; -} diff --git a/lib/src/__osSpDeviceBusy.c b/lib/src/__osSpDeviceBusy.c deleted file mode 100644 index a40c402a2..000000000 --- a/lib/src/__osSpDeviceBusy.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSpDeviceBusy() { - register u32 status = HW_REG(SP_STATUS_REG, u32); - if (status & (SPSTATUS_IO_FULL | SPSTATUS_DMA_FULL | SPSTATUS_DMA_BUSY)) { - return 1; - } - return 0; -} diff --git a/lib/src/__osSpGetStatus.c b/lib/src/__osSpGetStatus.c deleted file mode 100644 index a3be17e66..000000000 --- a/lib/src/__osSpGetStatus.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -u32 __osSpGetStatus() { - return HW_REG(SP_STATUS_REG, u32); -} diff --git a/lib/src/__osSpRawStartDma.c b/lib/src/__osSpRawStartDma.c deleted file mode 100644 index 3768a5fa4..000000000 --- a/lib/src/__osSpRawStartDma.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size) { - if (__osSpDeviceBusy()) { - return -1; - } - HW_REG(SP_MEM_ADDR_REG, void *) = sp_ptr; - HW_REG(SP_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_ptr); - if (dir == 0) { - HW_REG(SP_WR_LEN_REG, u32) = size - 1; - } else { - HW_REG(SP_RD_LEN_REG, u32) = size - 1; - } - return 0; -} diff --git a/lib/src/__osSpSetPc.c b/lib/src/__osSpSetPc.c deleted file mode 100644 index d074590c9..000000000 --- a/lib/src/__osSpSetPc.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -s32 __osSpSetPc(void *pc) { - register u32 status = HW_REG(SP_STATUS_REG, u32); - if (!(status & SPSTATUS_HALT)) { - return -1; - } else { - HW_REG(SP_PC_REG, void *) = pc; - return 0; - } -} diff --git a/lib/src/__osSpSetStatus.c b/lib/src/__osSpSetStatus.c deleted file mode 100644 index d63ac4cea..000000000 --- a/lib/src/__osSpSetStatus.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -void __osSpSetStatus(u32 status) { - HW_REG(SP_STATUS_REG, u32) = status; -} diff --git a/lib/src/__osSyncPutChars.c b/lib/src/__osSyncPutChars.c deleted file mode 100644 index a27ef60f8..000000000 --- a/lib/src/__osSyncPutChars.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "libultra_internal.h" - -typedef struct { - u8 unk00 : 2; - u8 pad : 4; - u8 unk01 : 2; - u8 unk2[3]; -} unkStruct; - -u32 D_80334A40 = 0; -u32 D_80334A44 = 1; - -void __osSyncPutChars(s32 a0, s32 a1, u8 *a2) { - unkStruct sp24; - s32 sp20; - u32 sp1c; - sp24.unk00 = a0; - sp24.unk01 = a1; - - for (sp20 = 0; sp20 < a1; sp20++) { - sp24.unk2[sp20] = a2[sp20]; - } - - while (!__osAtomicDec(&D_80334A44)) { - ; - } - - sp1c = __osDisableInt(); - - *(u32 *) 0xC0000000 = *(u32 *) &sp24; - while (!(__osGetCause() & 0x2000)) { - ; - } - *(u32 *) 0xC000000C = 0; - D_80334A44++; - - __osRestoreInt(sp1c); -} diff --git a/lib/src/__osViGetCurrentContext.c b/lib/src/__osViGetCurrentContext.c deleted file mode 100644 index 0f7cf3a95..000000000 --- a/lib/src/__osViGetCurrentContext.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViCurr; - -OSViContext *__osViGetCurrentContext() { - return __osViCurr; -} diff --git a/lib/src/__osViInit.c b/lib/src/__osViInit.c deleted file mode 100644 index 980c7b89f..000000000 --- a/lib/src/__osViInit.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -#ifdef VERSION_SH -extern s32 D_SH_80000300; // Potentially a TV type -#endif - -#ifndef VERSION_JP -extern u32 osTvType; -#endif - -OSViContext sViContexts[2] = { 0 }; -OSViContext *__osViCurr = &sViContexts[0]; -OSViContext *__osViNext = &sViContexts[1]; -#ifdef VERSION_EU -u32 osViClock = 0x02E6D354; // used for audio frequency calculations -u32 sTvType = TV_TYPE_PAL; -#elif !defined(VERSION_SH) -u32 sTvType = TV_TYPE_NTSC; -u32 osViClock = 0x02E6D354; -#endif - -extern OSViMode D_80334990; -extern OSViMode D_803349E0; -#if defined(VERSION_EU) || defined(VERSION_SH) -extern OSViMode D_80302FD0; -#endif - -void __osViInit(void) { -//#ifdef VERSION_JP -#ifdef VERSION_US - sTvType = osTvType; -#endif - bzero(sViContexts, sizeof(sViContexts)); - __osViCurr = &sViContexts[0]; - __osViNext = &sViContexts[1]; - __osViNext->retraceCount = 1; - __osViCurr->retraceCount = 1; - -#if defined(VERSION_EU) - - if (osTvType == TV_TYPE_PAL) { - __osViNext->modep = &D_80334990; - osViClock = 0x02F5B2D2; - } else if (osTvType == TV_TYPE_MPAL) { - __osViNext->modep = &D_803349E0; - osViClock = 0x02E6025C; - } else { - __osViNext->modep = &D_80302FD0; - osViClock = 0x02E6D354; - } - -#elif defined(VERSION_SH) - - __osViNext->buffer = (void *) 0x80000000; - __osViCurr->buffer = (void *) 0x80000000; - if (osTvType == TV_TYPE_PAL) { - __osViNext->modep = &D_80334990; - } else if (osTvType == TV_TYPE_MPAL) { - __osViNext->modep = &D_803349E0; - } else { - __osViNext->modep = &D_80302FD0; - } - -#else - -#ifdef VERSION_JP - if (sTvType != TV_TYPE_PAL) -#else - if (sTvType == TV_TYPE_NTSC) -#endif - { - __osViNext->modep = &D_80334990; - osViClock = 0x02E6D354; - } else { - __osViNext->modep = &D_803349E0; -#if defined(VERSION_JP) - osViClock = 0x02F5B2D2; -#elif defined(VERSION_US) - osViClock = 0x02E6025C; -#endif - } -#endif - - __osViNext->unk00 = 0x20; - __osViNext->features = __osViNext->modep->comRegs.ctrl; -#ifndef VERSION_JP - while (HW_REG(VI_CURRENT_REG, u32) > 0xa) { - ; - } - HW_REG(VI_STATUS_REG, u32) = 0; -#endif - __osViSwapContext(); -} diff --git a/lib/src/__osViSwapContext.c b/lib/src/__osViSwapContext.c deleted file mode 100644 index 990cb11fd..000000000 --- a/lib/src/__osViSwapContext.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -extern OSViContext *__osViNext; -extern OSViContext *__osViCurr; - -void __osViSwapContext() { - register OSViMode *s0; - register OSViContext *s1; - u32 origin; - u32 hStart; - u32 sp34; - u32 field; - register u32 s2; - field = 0; - s1 = __osViNext; - s0 = s1->modep; - field = HW_REG(VI_V_CURRENT_LINE_REG, u32) & 1; - s2 = osVirtualToPhysical(s1->buffer); - origin = (s0->fldRegs[field].origin) + s2; - if (s1->unk00 & 2) { - s1->unk20 |= s0->comRegs.xScale & ~0xfff; - } else { - s1->unk20 = s0->comRegs.xScale; - } - if (s1->unk00 & 4) { - sp34 = (u32)(s0->fldRegs[field].yScale & 0xfff); - s1->unk2c = s1->unk24 * sp34; - s1->unk2c |= s0->fldRegs[field].yScale & ~0xfff; - } else { - s1->unk2c = s0->fldRegs[field].yScale; - } - hStart = s0->comRegs.hStart; - if (s1->unk00 & 0x20) { - hStart = 0; - } - if (s1->unk00 & 0x40) { - s1->unk2c = 0; - origin = osVirtualToPhysical(s1->buffer); - } - if (s1->unk00 & 0x80) { - s1->unk2c = (s1->unk28 << 0x10) & 0x3ff0000; - origin = osVirtualToPhysical(s1->buffer); - } - HW_REG(VI_ORIGIN_REG, u32) = origin; - HW_REG(VI_WIDTH_REG, u32) = s0->comRegs.width; - HW_REG(VI_BURST_REG, u32) = s0->comRegs.burst; - HW_REG(VI_V_SYNC_REG, u32) = s0->comRegs.vSync; - HW_REG(VI_H_SYNC_REG, u32) = s0->comRegs.hSync; - HW_REG(VI_LEAP_REG, u32) = s0->comRegs.leap; - HW_REG(VI_H_START_REG, u32) = hStart; - HW_REG(VI_V_START_REG, u32) = s0->fldRegs[field].vStart; - HW_REG(VI_V_BURST_REG, u32) = s0->fldRegs[field].vBurst; - HW_REG(VI_INTR_REG, u32) = s0->fldRegs[field].vIntr; - HW_REG(VI_X_SCALE_REG, u32) = s1->unk20; - HW_REG(VI_Y_SCALE_REG, u32) = s1->unk2c; - HW_REG(VI_CONTROL_REG, u32) = s1->features; - __osViNext = __osViCurr; - __osViCurr = s1; - *__osViNext = *__osViCurr; -} diff --git a/lib/src/alBnkfNew.c b/lib/src/alBnkfNew.c deleted file mode 100644 index 11db85bd8..000000000 --- a/lib/src/alBnkfNew.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "libultra_internal.h" -#include "libaudio_internal.h" - -#define PATCH(SRC, BASE, TYPE) SRC = (TYPE)((uintptr_t) SRC + (uintptr_t) BASE) - -void alSeqFileNew(ALSeqFile *f, u8 *base) { - int i; - for (i = 0; i < f->seqCount; i++) { - PATCH(f->seqArray[i].offset, base, u8 *); - } -} - -static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table) { - int i; - ALSound *sound; - ALWaveTable *wavetable; - u8 *table2; - - if (inst->flags) { - return; - } - - inst->flags = 1; - - for (i = 0; i < inst->soundCount; i++) { - PATCH(inst->soundArray[i], f, ALSound *); - sound = inst->soundArray[i]; - if (sound->flags) { - continue; - } - - table2 = table; - - sound->flags = 1; - PATCH(sound->envelope, f, ALEnvelope *); - PATCH(sound->keyMap, f, ALKeyMap *); - PATCH(sound->wavetable, f, ALWaveTable *); - wavetable = sound->wavetable; - if (wavetable->flags) { - continue; - } - - wavetable->flags = 1; - PATCH(wavetable->base, table2, u8 *); - if (wavetable->type == 0) { - PATCH(wavetable->waveInfo.adpcmWave.book, f, ALADPCMBook *); - if (wavetable->waveInfo.adpcmWave.loop != NULL) { - PATCH(wavetable->waveInfo.adpcmWave.loop, f, ALADPCMloop *); - } - } else if (wavetable->type == 1) { - if (wavetable->waveInfo.rawWave.loop != NULL) { - PATCH(wavetable->waveInfo.rawWave.loop, f, ALRawLoop *); - } - } - } -} - -// Force adding another jr $ra. Has to be called or it doesn't get put in the -// right place. -static void unused(void) { -} - -void alBnkfNew(ALBankFile *f, u8 *table) { - ALBank *bank; - int i; - int j; - unused(); - if (f->revision != AL_BANK_VERSION) { - return; - } - - for (i = 0; i < f->bankCount; i++) { - PATCH(f->bankArray[i], f, ALBank *); - if (f->bankArray[i] == NULL) { - continue; - } - - bank = f->bankArray[i]; - if (bank->flags == 0) { - bank->flags = 1; - if (bank->percussion != NULL) { - PATCH(bank->percussion, f, ALInstrument *); - _bnkfPatchBank(bank->percussion, f, table); - } - for (j = 0; j < bank->instCount; j++) { - PATCH(bank->instArray[j], f, ALInstrument *); - if (bank->instArray[j] != NULL) { - _bnkfPatchBank(bank->instArray[j], f, table); - } - } - } - } -} diff --git a/lib/src/bstring.h b/lib/src/bstring.h deleted file mode 100644 index 01486d99e..000000000 --- a/lib/src/bstring.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __BSTRING_H__ -#define __BSTRING_H__ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * bstring(3C) -- byte string operations - * - * Copyright 1990, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; - * the contents of this file may not be disclosed to third parties, copied or - * duplicated in any form, in whole or in part, without the prior written - * permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to restrictions - * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data - * and Computer Software clause at DFARS 252.227-7013, and/or in similar or - * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - - * rights reserved under the Copyright Laws of the United States. - */ - -#ident "$Revision: 1.4 $" - -extern void bcopy(const void *, void *, size_t); -extern int bcmp(const void *, const void *, int); -extern void bzero(void *, size_t); -extern void blkclr(void *, int); - -#ifdef __cplusplus -} -#endif -#endif /* !__BSTRING_H__ */ diff --git a/lib/src/contramread.c b/lib/src/contramread.c deleted file mode 100644 index 3043f71a7..000000000 --- a/lib/src/contramread.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "libultra_internal.h" -#include "PR/rcp.h" -#include "controller.h" - -#ifdef VERSION_SH -extern s32 func_8030A5C0(OSMesgQueue *, s32); -void __osPackRamReadData(int channel, u16 address); - -s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer) { - s32 ret; - int i; - u8 *ptr; - __OSContRamReadFormat ramreadformat; - int retry; - ret = 0; - ptr = (u8 *)&__osPfsPifRam; - retry = 2; - __osSiGetAccess(); - _osLastSentSiCmd = CONT_CMD_READ_MEMPACK; - __osPackRamReadData(channel, address); - ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - do { - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - ptr = (u8 *)&__osPfsPifRam; - if (channel != 0) { - for (i = 0; i < channel; i++) { - ptr++; - } - } - ramreadformat = *(__OSContRamReadFormat *)ptr; - ret = CHNL_ERR(ramreadformat); - if (ret == 0) { - u8 c; - c = __osContDataCrc((u8*)&ramreadformat.data); - if (c != ramreadformat.datacrc) { - ret = func_8030A5C0(mq, channel); - if (ret != 0) { - __osSiRelAccess(); - return ret; - } - ret = PFS_ERR_CONTRFAIL; - } else { - for (i = 0; i < ARRLEN(ramreadformat.data); i++) { - *buffer++ = ramreadformat.data[i]; - } - } - } else { - ret = PFS_ERR_NOPACK; - } - if (ret != PFS_ERR_CONTRFAIL) { - break; - } - } while (retry-- >= 0); - __osSiRelAccess(); - return ret; -} - -void __osPackRamReadData(int channel, u16 address) { - u8 *ptr; - __OSContRamReadFormat ramreadformat; - int i; - - ptr = (u8 *)__osPfsPifRam.ramarray; - - for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus - __osPfsPifRam.ramarray[i] = 0; - } - - __osPfsPifRam.pifstatus = CONT_CMD_EXE; - ramreadformat.dummy = CONT_CMD_NOP; - ramreadformat.txsize = CONT_CMD_READ_MEMPACK_TX; - ramreadformat.rxsize = CONT_CMD_READ_MEMPACK_RX; - ramreadformat.cmd = CONT_CMD_READ_MEMPACK; - ramreadformat.address = (address << 0x5) | __osContAddressCrc(address); - ramreadformat.datacrc = CONT_CMD_NOP; - for (i = 0; i < ARRLEN(ramreadformat.data); i++) { - ramreadformat.data[i] = CONT_CMD_NOP; - } - if (channel != 0) { - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } - } - *(__OSContRamReadFormat *)ptr = ramreadformat; - ptr += sizeof(__OSContRamReadFormat); - ptr[0] = CONT_CMD_END; -} -#endif diff --git a/lib/src/contramwrite.c b/lib/src/contramwrite.c deleted file mode 100644 index 6b83dae34..000000000 --- a/lib/src/contramwrite.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "libultra_internal.h" -#include "PR/rcp.h" -#include "controller.h" - -#ifdef VERSION_SH -extern s32 func_8030A5C0(OSMesgQueue *, s32); -void __osPackRamWriteData(int channel, u16 address, u8 *buffer); - -s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force) { - s32 ret; - int i; - u8 *ptr; - __OSContRamReadFormat ramreadformat; - int retry; - - ret = 0; - ptr = (u8 *)&__osPfsPifRam; - retry = 2; - if (force != 1 && address < 7 && address != 0) { - return 0; - } - __osSiGetAccess(); - _osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK; - __osPackRamWriteData(channel, address, buffer); - ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - do { - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - ptr = (u8 *)&__osPfsPifRam; - if (channel != 0) { - for (i = 0; i < channel; i++) { - ptr++; - } - } - - ramreadformat = *(__OSContRamReadFormat *)ptr; - - ret = CHNL_ERR(ramreadformat); - if (ret == 0) { - if (__osContDataCrc(buffer) != ramreadformat.datacrc) { - ret = func_8030A5C0(mq, channel); - if (ret != 0) { - __osSiRelAccess(); - return ret; - } - ret = PFS_ERR_CONTRFAIL; - } - } else { - ret = PFS_ERR_NOPACK; - } - if (ret != PFS_ERR_CONTRFAIL) { - break; - } - } while ((retry-- >= 0)); - __osSiRelAccess(); - return ret; -} - -void __osPackRamWriteData(int channel, u16 address, u8 *buffer) { - u8 *ptr; - __OSContRamReadFormat ramreadformat; - int i; - - ptr = (u8 *)__osPfsPifRam.ramarray; - - for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus - __osPfsPifRam.ramarray[i] = 0; - } - - __osPfsPifRam.pifstatus = CONT_CMD_EXE; - ramreadformat.dummy = CONT_CMD_NOP; - ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX; - ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX; - ramreadformat.cmd = CONT_CMD_WRITE_MEMPACK; - ramreadformat.address = (address << 0x5) | __osContAddressCrc(address); - ramreadformat.datacrc = CONT_CMD_NOP; - for (i = 0; i < ARRLEN(ramreadformat.data); i++) { - ramreadformat.data[i] = *buffer++; - } - if (channel != 0) { - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } - } - *(__OSContRamReadFormat *)ptr = ramreadformat; - ptr += sizeof(__OSContRamReadFormat); - ptr[0] = CONT_CMD_END; -} -#endif diff --git a/lib/src/controller.h b/lib/src/controller.h deleted file mode 100644 index 67182b410..000000000 --- a/lib/src/controller.h +++ /dev/null @@ -1,208 +0,0 @@ -#ifndef _CONTROLLER_H -#define _CONTROLLER_H -#include "PR/os_internal.h" -#include "os.h" -#include "PR/rcp.h" - -//should go somewhere else but -#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) -#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4) - -typedef struct -{ - /* 0x0 */ u32 ramarray[15]; - /* 0x3C */ u32 pifstatus; -} OSPifRam; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u16 button; - /* 0x6 */ s8 stick_x; - /* 0x7 */ s8 stick_y; -} __OSContReadFormat; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u8 typeh; - /* 0x5 */ u8 typel; - /* 0x6 */ u8 status; - /* 0x7 */ u8 dummy1; -} __OSContRequesFormat; - -typedef struct -{ - /* 0x0 */ u8 txsize; - /* 0x1 */ u8 rxsize; - /* 0x2 */ u8 cmd; - /* 0x3 */ u8 typeh; - /* 0x4 */ u8 typel; - /* 0x5 */ u8 status; -} __OSContRequesFormatShort; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u16 address; - /* 0x6 */ u8 data[BLOCKSIZE]; - /* 0x26 */ u8 datacrc; -} __OSContRamReadFormat; - -typedef union { - /* 0x0 */ struct - { - /* 0x0 */ u8 bank; - /* 0x1 */ u8 page; - } inode_t; - /* 0x0 */ u16 ipage; -} __OSInodeUnit; - -typedef struct -{ - /* 0x0 */ u32 game_code; - /* 0x4 */ u16 company_code; - /* 0x6 */ __OSInodeUnit start_page; - /* 0x8 */ u8 status; - /* 0x9 */ s8 reserved; - /* 0xA */ u16 data_sum; - /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN]; - /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; -} __OSDir; - -typedef struct -{ - /* 0x0 */ __OSInodeUnit inode_page[128]; -} __OSInode; - -typedef struct -{ - /* 0x0 */ u32 repaired; - /* 0x4 */ u32 random; - /* 0x8 */ u64 serial_mid; - /* 0x10 */ u64 serial_low; - /* 0x18 */ u16 deviceid; - /* 0x1A */ u8 banks; - /* 0x1B */ u8 version; - /* 0x1C */ u16 checksum; - /* 0x1E */ u16 inverted_checksum; -} __OSPackId; - -typedef struct -{ - /* 0x0 */ u8 txsize; - /* 0x1 */ u8 rxsize; - /* 0x2 */ u8 cmd; - /* 0x3 */ u8 address; - /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE]; -} __OSContEepromFormat; - -//from: http://en64.shoutwiki.com/wiki/SI_Registers_Detailed#CONT_CMD_Usage -#define CONT_CMD_REQUEST_STATUS 0 -#define CONT_CMD_READ_BUTTON 1 -#define CONT_CMD_READ_MEMPACK 2 -#define CONT_CMD_WRITE_MEMPACK 3 -#define CONT_CMD_READ_EEPROM 4 -#define CONT_CMD_WRITE_EEPROM 5 -#define CONT_CMD_RESET 0xff - -#define CONT_CMD_REQUEST_STATUS_TX 1 -#define CONT_CMD_READ_BUTTON_TX 1 -#define CONT_CMD_READ_MEMPACK_TX 3 -#define CONT_CMD_WRITE_MEMPACK_TX 35 -#define CONT_CMD_READ_EEPROM_TX 2 -#define CONT_CMD_WRITE_EEPROM_TX 10 -#define CONT_CMD_RESET_TX 1 - -#define CONT_CMD_REQUEST_STATUS_RX 3 -#define CONT_CMD_READ_BUTTON_RX 4 -#define CONT_CMD_READ_MEMPACK_RX 33 -#define CONT_CMD_WRITE_MEMPACK_RX 1 -#define CONT_CMD_READ_EEPROM_RX 8 -#define CONT_CMD_WRITE_EEPROM_RX 1 -#define CONT_CMD_RESET_RX 3 - -#define CONT_CMD_NOP 0xff -#define CONT_CMD_END 0xfe //indicates end of a command -#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command - -#define DIR_STATUS_EMPTY 0 -#define DIR_STATUS_UNKNOWN 1 -#define DIR_STATUS_OCCUPIED 2 - - -typedef struct -{ - /* 0x0 */ __OSInode inode; - /* 0x100 */ u8 bank; - /* 0x101 */ u8 map[256]; -} __OSInodeCache; - -extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *); -u16 __osSumcalc(u8 *ptr, int length); -s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); -s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); -s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); -s32 __osGetId(OSPfs *pfs); -s32 __osCheckId(OSPfs *pfs); -s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank); -s32 __osPfsSelectBank(OSPfs *pfs); -s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page); -s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u8 bank, __OSInodeUnit *last_page, int flag); -s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank); -s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer); -s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force); -void __osContGetInitData(u8 *pattern, OSContStatus *data); -void __osPackRequestData(u8 cmd); -void __osPfsRequestData(u8 cmd); -void __osPfsGetInitData(u8* pattern, OSContStatus* data); -u8 __osContAddressCrc(u16 addr); -u8 __osContDataCrc(u8 *data); -s32 __osPfsGetStatus(OSMesgQueue *queue, int channel); - -extern u8 _osLastSentSiCmd; -extern OSTimer __osEepromTimer; -extern OSMesg __osEepromTimerMsg; -extern OSMesgQueue __osEepromTimerQ; -extern OSPifRam __osEepPifRam; -extern OSPifRam __osContPifRam; -extern OSPifRam __osPfsPifRam; -extern u8 _osContNumControllers; - -//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0 -#define ERRCK(fn) \ - ret = fn; \ - if (ret != 0) \ - return ret; - -#define SET_ACTIVEBANK_TO_ZERO \ - if (pfs->activebank != 0) \ - { \ - pfs->activebank = 0; \ - ERRCK(__osPfsSelectBank(pfs)) \ - } - -#define PFS_CHECK_ID \ - if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ - return PFS_ERR_NEW_PACK; -#endif - -#define PFS_CHECK_STATUS \ - if ((pfs->status & PFS_INITIALIZED) == 0) \ - return PFS_ERR_INVALID; - -#define PFS_GET_STATUS \ - __osSiGetAccess(); \ - ret = __osPfsGetStatus(queue, channel); \ - __osSiRelAccess(); \ - if (ret != 0) \ - return ret; diff --git a/lib/src/crc.c b/lib/src/crc.c deleted file mode 100644 index f18dc6327..000000000 --- a/lib/src/crc.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "libultra_internal.h" - -#ifdef VERSION_SH -u8 __osContAddressCrc(u16 addr) { - u8 temp; - u8 temp2; - int i; - temp = 0; - for (i = 0; i < 16; i++) { - if (temp & 0x10) { - temp2 = 21; - } else { - temp2 = 0; - } - - temp <<= 1; - temp |= (u8)((addr & 0x400) ? 1 : 0); - addr <<= 1; - temp ^= temp2; - } - return temp & 0x1f; -} - -u8 __osContDataCrc(u8 *data) { - u8 temp; - u8 temp2; - int i; - int j; - temp = 0; - for (i = 0; i <= 32; i++, data++) { - for (j = 7; j >= 0; j--) { - if (temp & 0x80) { - temp2 = 133; - } else { - temp2 = 0; - } - temp <<= 1; - if (i == 32) { - temp &= -1; - } else { - temp |= ((*data & (1 << j)) ? 1 : 0); - } - temp ^= temp2; - } - } - return temp; -} -#endif diff --git a/lib/src/epidma.c b/lib/src/epidma.c deleted file mode 100644 index cc46a4d47..000000000 --- a/lib/src/epidma.c +++ /dev/null @@ -1,24 +0,0 @@ -#ifdef VERSION_SH -#include "PR/os_internal.h" -#include "piint.h" - -s32 osEPiStartDma(OSPiHandle *pihandle, OSIoMesg *mb, s32 direction) { - register s32 ret; - - if (!__osPiDevMgr.active) { - return -1; - } - mb->piHandle = pihandle; - if (direction == OS_READ) { - mb->hdr.type = OS_MESG_TYPE_EDMAREAD; - } else { - mb->hdr.type = OS_MESG_TYPE_EDMAWRITE; - } - if (mb->hdr.pri == OS_MESG_PRI_HIGH) { - ret = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); - } else { - ret = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); - } - return ret; -} -#endif diff --git a/lib/src/func_802F4A20.c b/lib/src/func_802F4A20.c deleted file mode 100644 index c38c23a47..000000000 --- a/lib/src/func_802F4A20.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "new_func.h" - -void func_802F4A20(void) { - __OSTranxInfo *sp1c; - volatile u32 sp18; - sp1c = &__osDiskHandle->transferInfo; - WAIT_ON_IOBUSY(sp18); - HW_REG(ASIC_BM_CTL, u32) = BUFFER_MANAGER_RESET | sp1c->bmCtlShadow; //should be unk10?? - WAIT_ON_IOBUSY(sp18); - HW_REG(ASIC_BM_CTL, u32) = sp1c->bmCtlShadow; - func_802F4B08(); - HW_REG(PI_STATUS_REG, u32) = PI_STATUS_CLEAR_INTR; - __OSGlobalIntMask |= 0x00100401; // TODO: fix magic numbers -} - -typedef struct OSEventMessageStruct_0_s { - OSMesgQueue *queue; - OSMesg msg; -} OSEventMessageStruct_0; - -extern OSEventMessageStruct_0 __osEventStateTab[16]; // should be OS_NUM_EVENTS + 1 I think - -void func_802F4B08(void) { - OSEventMessageStruct_0 *sp2c; - OSMesgQueue *sp28; - u32 sp24; - register OSThread *s0; - sp2c = &__osEventStateTab[OS_EVENT_PI]; - sp28 = sp2c->queue; - if (!sp28 || sp28->validCount >= sp28->msgCount) { - return; - } - sp24 = (sp28->first + sp28->validCount) % sp28->msgCount; - sp28->msg[sp24] = sp2c->msg; - sp28->validCount += 1; - if (sp28->mtqueue->next != NULL) { - s0 = __osPopThread(&sp28->mtqueue); - __osEnqueueThread(&D_80334898, s0); - } -} diff --git a/lib/src/func_802F71F0.c b/lib/src/func_802F71F0.c deleted file mode 100644 index e829ae470..000000000 --- a/lib/src/func_802F71F0.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "libultra_internal.h" - -void func_802F71F0(void) { - register u32 s0 = __osDisableInt(); - D_803348A0->state = OS_STATE_RUNNABLE; - __osEnqueueAndYield(&D_80334898); - __osRestoreInt(s0); -} diff --git a/lib/src/guLookAtRef.c b/lib/src/guLookAtRef.c deleted file mode 100644 index 4e65a49a3..000000000 --- a/lib/src/guLookAtRef.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file originates from the standard Nintendo 64 SDK libultra src - * directory, and it used exclusively when building with the Fast3DEX2 - * microcode. Not not using it breaks environment mapping. - * - * Apart from the modifications listed below, this file is unmodified. - */ - -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/* Minor modifications */ -#include -#define FTOFRAC8(x) ((int) MIN(((x) * (128.0)), 127.0) & 0xff) - -void guLookAtReflectF(float mf[4][4], LookAt *l, float xEye, float yEye, float zEye, float xAt, - float yAt, float zAt, float xUp, float yUp, float zUp) { - float len, xLook, yLook, zLook, xRight, yRight, zRight; - - guMtxIdentF(mf); - - xLook = xAt - xEye; - yLook = yAt - yEye; - zLook = zAt - zEye; - - /* Negate because positive Z is behind us: */ - len = -1.0 / sqrtf(xLook * xLook + yLook * yLook + zLook * zLook); - xLook *= len; - yLook *= len; - zLook *= len; - - /* Right = Up x Look */ - - xRight = yUp * zLook - zUp * yLook; - yRight = zUp * xLook - xUp * zLook; - zRight = xUp * yLook - yUp * xLook; - len = 1.0 / sqrtf(xRight * xRight + yRight * yRight + zRight * zRight); - xRight *= len; - yRight *= len; - zRight *= len; - - /* Up = Look x Right */ - - xUp = yLook * zRight - zLook * yRight; - yUp = zLook * xRight - xLook * zRight; - zUp = xLook * yRight - yLook * xRight; - len = 1.0 / sqrtf(xUp * xUp + yUp * yUp + zUp * zUp); - xUp *= len; - yUp *= len; - zUp *= len; - - /* reflectance vectors = Up and Right */ - - l->l[0].l.dir[0] = FTOFRAC8(xRight); - l->l[0].l.dir[1] = FTOFRAC8(yRight); - l->l[0].l.dir[2] = FTOFRAC8(zRight); - l->l[1].l.dir[0] = FTOFRAC8(xUp); - l->l[1].l.dir[1] = FTOFRAC8(yUp); - l->l[1].l.dir[2] = FTOFRAC8(zUp); - l->l[0].l.col[0] = 0x00; - l->l[0].l.col[1] = 0x00; - l->l[0].l.col[2] = 0x00; - l->l[0].l.pad1 = 0x00; - l->l[0].l.colc[0] = 0x00; - l->l[0].l.colc[1] = 0x00; - l->l[0].l.colc[2] = 0x00; - l->l[0].l.pad2 = 0x00; - l->l[1].l.col[0] = 0x00; - l->l[1].l.col[1] = 0x80; - l->l[1].l.col[2] = 0x00; - l->l[1].l.pad1 = 0x00; - l->l[1].l.colc[0] = 0x00; - l->l[1].l.colc[1] = 0x80; - l->l[1].l.colc[2] = 0x00; - l->l[1].l.pad2 = 0x00; - - mf[0][0] = xRight; - mf[1][0] = yRight; - mf[2][0] = zRight; - mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight); - - mf[0][1] = xUp; - mf[1][1] = yUp; - mf[2][1] = zUp; - mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp); - - mf[0][2] = xLook; - mf[1][2] = yLook; - mf[2][2] = zLook; - mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook); - - mf[0][3] = 0; - mf[1][3] = 0; - mf[2][3] = 0; - mf[3][3] = 1; -} - -void guLookAtReflect(Mtx *m, LookAt *l, float xEye, float yEye, float zEye, float xAt, float yAt, - float zAt, float xUp, float yUp, float zUp) { - float mf[4][4]; - - guLookAtReflectF(mf, l, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); - - guMtxF2L(mf, m); -} diff --git a/lib/src/guMtxF2L.c b/lib/src/guMtxF2L.c deleted file mode 100644 index 2b9d93592..000000000 --- a/lib/src/guMtxF2L.c +++ /dev/null @@ -1,70 +0,0 @@ -#include "libultra_internal.h" -#ifdef GBI_FLOATS -#include -#endif - -#ifndef GBI_FLOATS -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; - for (r = 0; r < 4; r++) { - for (c = 0; c < 4; c++) { - if (r == c) { - mf[r][c] = 1.0f; - } else { - mf[r][c] = 0.0f; - } - } - } -} - -void guMtxIdent(Mtx *m) { -#ifndef GBI_FLOATS - float mf[4][4]; - guMtxIdentF(mf); - guMtxF2L(mf, m); -#else - guMtxIdentF(m->m); -#endif -} diff --git a/lib/src/guNormalize.c b/lib/src/guNormalize.c deleted file mode 100644 index 3ac2f00bd..000000000 --- a/lib/src/guNormalize.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "libultra_internal.h" - -void guNormalize(f32 *x, f32 *y, f32 *z) { - f32 tmp = 1.0f / sqrtf(*x * *x + *y * *y + *z * *z); - *x = *x * tmp; - *y = *y * tmp; - *z = *z * tmp; -} diff --git a/lib/src/guOrthoF.c b/lib/src/guOrthoF.c deleted file mode 100644 index bf15b06c4..000000000 --- a/lib/src/guOrthoF.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "libultra_internal.h" - -void guOrthoF(float m[4][4], float left, float right, float bottom, float top, float near, float far, - float scale) { - int row; - int col; - guMtxIdentF(m); - m[0][0] = 2 / (right - left); - m[1][1] = 2 / (top - bottom); - m[2][2] = -2 / (far - near); - m[3][0] = -(right + left) / (right - left); - m[3][1] = -(top + bottom) / (top - bottom); - m[3][2] = -(far + near) / (far - near); - m[3][3] = 1; - for (row = 0; row < 4; row++) { - for (col = 0; col < 4; col++) { - m[row][col] *= scale; - } - } -} - -void guOrtho(Mtx *m, float left, float right, float bottom, float top, float near, float far, - float scale) { - float sp28[4][4]; - guOrthoF(sp28, left, right, bottom, top, near, far, scale); - guMtxF2L(sp28, m); -} diff --git a/lib/src/guPerspectiveF.c b/lib/src/guPerspectiveF.c deleted file mode 100644 index f56fbb8f6..000000000 --- a/lib/src/guPerspectiveF.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "libultra_internal.h" - -void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, - float scale) { - float yscale; - int row; - int col; - guMtxIdentF(mf); - fovy *= GU_PI / 180.0; - yscale = cosf(fovy / 2) / sinf(fovy / 2); - mf[0][0] = yscale / aspect; - mf[1][1] = yscale; - mf[2][2] = (near + far) / (near - far); - mf[2][3] = -1; - mf[3][2] = 2 * near * far / (near - far); - mf[3][3] = 0.0f; - for (row = 0; row < 4; row++) { - for (col = 0; col < 4; col++) { - mf[row][col] *= scale; - } - } - if (perspNorm != NULL) { - if (near + far <= 2.0) { - *perspNorm = 65535; - } else { - *perspNorm = (double) (1 << 17) / (near + far); - if (*perspNorm <= 0) { - *perspNorm = 1; - } - } - } -} - -void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, - float scale) { - float mat[4][4]; - guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale); - guMtxF2L(mat, m); -} diff --git a/lib/src/guRotateF.c b/lib/src/guRotateF.c deleted file mode 100644 index c71093aee..000000000 --- a/lib/src/guRotateF.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "libultra_internal.h" - -void guRotateF(float m[4][4], float a, float x, float y, float z) { - float sin_a; - float cos_a; - float sp2c; - float sp28; - float sp24; - float xx, yy, zz; - static float D_80365D70 = GU_PI / 180; - - guNormalize(&x, &y, &z); - - a = a * D_80365D70; - - sin_a = sinf(a); - cos_a = cosf(a); - - sp2c = x * y * (1 - cos_a); - sp28 = y * z * (1 - cos_a); - sp24 = z * x * (1 - cos_a); - - guMtxIdentF(m); - xx = x * x; - m[0][0] = (1 - xx) * cos_a + xx; - m[2][1] = sp28 - x * sin_a; - m[1][2] = sp28 + x * sin_a; - yy = y * y; - m[1][1] = (1 - yy) * cos_a + yy; - m[2][0] = sp24 + y * sin_a; - m[0][2] = sp24 - y * sin_a; - zz = z * z; - m[2][2] = (1 - zz) * cos_a + zz; - m[1][0] = sp2c - z * sin_a; - m[0][1] = sp2c + z * sin_a; -} - -void guRotate(Mtx *m, float a, float x, float y, float z) { - float mf[4][4]; - guRotateF(mf, a, x, y, z); - guMtxF2L(mf, m); -} diff --git a/lib/src/guScaleF.c b/lib/src/guScaleF.c deleted file mode 100644 index 15de4c693..000000000 --- a/lib/src/guScaleF.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "libultra_internal.h" - -void guScaleF(float mf[4][4], float x, float y, float z) { - guMtxIdentF(mf); - mf[0][0] = x; - mf[1][1] = y; - mf[2][2] = z; - mf[3][3] = 1.0; -} - -void guScale(Mtx *m, float x, float y, float z) { - float mf[4][4]; - guScaleF(mf, x, y, z); - guMtxF2L(mf, m); -} diff --git a/lib/src/guTranslateF.c b/lib/src/guTranslateF.c deleted file mode 100644 index 179a6a7d1..000000000 --- a/lib/src/guTranslateF.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "libultra_internal.h" - -void guTranslateF(float m[4][4], float x, float y, float z) { - guMtxIdentF(m); - m[3][0] = x; - m[3][1] = y; - m[3][2] = z; -} - -void guTranslate(Mtx *m, float x, float y, float z) { - float mf[4][4]; - guTranslateF(mf, x, y, z); - guMtxF2L(mf, m); -} diff --git a/lib/src/hardware.h b/lib/src/hardware.h deleted file mode 100644 index 14848ca86..000000000 --- a/lib/src/hardware.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef _HARDWARE_H_ -#define _HARDWARE_H_ - -#define HW_REG(reg, type) *(volatile type *)(uintptr_t)(reg | 0xa0000000) - -#define AI_DRAM_ADDR_REG 0x04500000 -#define AI_LEN_REG 0x04500004 -#define AI_CONTROL_REG 0x04500008 -#define AI_STATUS_REG 0x0450000C -#define AI_STATUS_AI_FULL (1 << 31) -#define AI_STATUS_AI_BUSY (1 << 30) -#define AI_DACRATE_REG 0x04500010 -#define AI_BITRATE_REG 0x04500014 - -#define VI_STATUS_REG 0x04400000 -#define VI_CONTROL_REG 0x04400000 -#define VI_ORIGIN_REG 0x04400004 -#define VI_DRAM_ADDR_REG 0x04400004 -#define VI_WIDTH_REG 0x04400008 -#define VI_H_WIDTH_REG 0x04400008 -#define VI_INTR_REG 0x0440000C -#define VI_V_INTER_REG 0x0440000C -#define VI_CURRENT_REG 0x04400010 -#define VI_V_CURRENT_LINE_REG 0x04400010 -#define VI_BURST_REG 0x04400014 -#define VI_TIMING_REG 0x04400014 -#define VI_V_SYNC_REG 0x04400018 //VI vertical sync -#define VI_H_SYNC_REG 0x0440001C //VI horizontal sync -#define VI_LEAP_REG 0x04400020 //VI horizontal sync leap -#define VI_H_SYNC_LEAP_REG 0x04400020 -#define VI_H_START_REG 0x04400024 //VI horizontal video -#define VI_H_VIDEO_REG 0x04400024 -#define VI_V_START_REG 0x04400028 //VI vertical video -#define VI_V_VIDEO_REG 0x04400028 -#define VI_V_BURST_REG 0x0440002C //VI vertical burst -#define VI_X_SCALE_REG 0x04400030 //VI x-scale -#define VI_Y_SCALE_REG 0x04400034 //VI y-scale - -#define SP_IMEM_START 0x04001000 -#define SP_DMEM_START 0x04000000 - -#define SP_MEM_ADDR_REG 0x04040000 -#define SP_DRAM_ADDR_REG 0x04040004 -#define SP_RD_LEN_REG 0x04040008 -#define SP_WR_LEN_REG 0x0404000C -#define SP_STATUS_REG 0x04040010 -#define SP_PC_REG 0x04080000 - -#define PI_DRAM_ADDR_REG 0x04600000 //PI DRAM address -#define PI_CART_ADDR_REG 0x04600004 //PI pbus (cartridge) address -#define PI_RD_LEN_REG 0x04600008 //PI read length -#define PI_WR_LEN_REG 0x0460000C //PI write length -#define PI_STATUS_REG 0x04600010 //PI status -#define PI_BSD_DOM1_LAT_REG 0x04600014 //PI dom1 latency -#define PI_DOMAIN1_REG 0x04600014 -#define PI_BSD_DOM1_PWD_REG 0x04600018 //PI dom1 pulse width -#define PI_BSD_DOM1_PGS_REG 0x0460001C //PI dom1 page size -#define PI_BSD_DOM1_RLS_REG 0x04600020 //PI dom1 release -#define PI_BSD_DOM2_LAT_REG 0x04600024 //PI dom2 latency -#define PI_DOMAIN2_REG 0x04600024 -#define PI_BSD_DOM2_PWD_REG 0x04600028 //PI dom2 pulse width -#define PI_BSD_DOM2_PGS_REG 0x0460002C //PI dom2 page size -#define PI_BSD_DOM2_RLS_REG 0x04600030 //PI dom2 release - -#define PI_STATUS_BUSY 0x1 -#define PI_STATUS_IOBUSY 0x2 -#define PI_STATUS_ERROR 0x3 - -#define PI_STATUS_RESET_CONTROLLER 0x1 -#define PI_STATUS_CLEAR_INTR 0x2 - -#define SI_DRAM_ADDR_REG 0x04800000 -#define SI_PIF_ADDR_RD64B_REG 0x04800004 -#define SI_PIF_ADDR_WR64B_REG 0x04800010 -#define SI_STATUS_REG 0x04800018 - -#define SI_STATUS_DMA_BUSY 0x1 -#define SI_STATUS_IO_READ_BUSY 0x2 -#define SI_STATUS_DMA_ERROR 0x8 -#define SI_STATUS_INTERRUPT (1 << 12) - -#define MI_INIT_MODE_REG 0x04300000 -#define MI_MODE_REG MI_INIT_MODE_REG -#define MI_VERSION_REG 0x04300004 -#define MI_INTR_REG 0x04300008 -#define MI_INTR_MASK_REG 0x0430000C - -//https://github.com/LuigiBlood/64dd/wiki/Registers -#define ASIC_STATUS 0x05000508 - -#define DATA_REQUEST 0x40000000 -#define C2_TRANSFER 0x10000000 -#define BUFFER_MANAGER_ERROR 0x08000000 -#define BUFFER_MANAGER_INTERRUPT 0x04000000 -#define MECHANIC_INTERRUPT 0x02000000 -#define DISK_PRESENT 0x01000000 -#define BUSY_STATE 0x00800000 -#define RESET_STATE 0x00400000 -#define MOTOR_NOT_SPINNING 0x00100000 -#define HEAD_RETRACTED 0x00080000 -#define WRITE_PROTECT_ERROR 0x00040000 -#define MECHANIC_ERROR 0x00020000 -#define DISK_CHANGE 0x00010000 - -#define _64DD_PRESENT_MASK 0xFFFF - - -//ro -#define ASIC_BM_STATUS 0x05000510 - -#define MICRO_STATUS 0x02000000 -#define C1_DOUBLE 0x00400000 -#define C1_SINGLE 0x00200000 - -//wo -#define ASIC_BM_CTL 0x05000510 -#define BUFFER_MANAGER_RESET 0x10000000 -#define MECHANIC_INTERRUPT_RESET 0x01000000 -/*- Start Buffer Manager (0x80000000) -- Buffer Manager Mode (0x40000000) -- BM Interrupt Mask (0x20000000) -- Buffer Manager Reset (0x10000000) -- Disable OR Check? (0x08000000) -- Disable C1 Correction (0x04000000) -- Block Transfer (0x02000000) -- Mechanic Interrupt Reset (0x01000000)*/ -#endif diff --git a/lib/src/kdebugserver.c b/lib/src/kdebugserver.c deleted file mode 100644 index f35b67d31..000000000 --- a/lib/src/kdebugserver.c +++ /dev/null @@ -1,133 +0,0 @@ -#include "libultra_internal.h" - -typedef struct { - u8 unk00 : 2; - u8 pad : 4; - u8 unk01 : 2; - u8 unk2[3]; -} unkStruct; - -extern u32 D_80334A44; - -u32 D_80334A30 = 0; -u32 D_80334A34 = 0; -s32 D_80334A38 = 0; - -extern u8 D_80365E40[0x100]; - -OSThread gInterruptedThread; - -void u32_to_string(u32 i, u8 *str) { - str[0] = (i >> 0x18) & 0xff; - str[1] = (i >> 0x10) & 0xff; - str[2] = (i >> 0x8) & 0xff; - str[3] = i & 0xff; -} - -u32 string_to_u32(u8 *str) { - u32 i; - i = (str[0] & 0xff) << 0x18; - i |= (str[1] & 0xff) << 0x10; - i |= (str[2] & 0xff) << 0x8; - i |= (str[3] & 0xff); - return i; -} - -void send_packet(u8 *a0, s32 a1) { - unkStruct sp1c; - s32 i; - sp1c.unk00 = 2; - for (sp1c.unk01 = a1, i = 0; i < a1; i++) { - sp1c.unk2[i] = a0[i]; - } - *(volatile u32 *) 0xc0000000 = *(u32 *) &sp1c; - while (!(__osGetCause() & 0x2000)) { - ; - } - *(volatile u32 *) 0xc000000c = 0; -} - -void send(u8 *buff, s32 len) { - s32 i; - s32 end; - s32 rem; - if (!D_80334A44) { - while (!(__osGetCause() & 0x2000)) { - ; - } - *(volatile u32 *) 0xc000000c = 0; - D_80334A44 = 1; - } - i = 0; - rem = len % 3; - end = len - rem; - for (; i < end; i += 3) { - send_packet(&buff[i], 3); - } - if (rem > 0) { - send_packet(&buff[end], rem); - } -} - -void process_command_memory(void) { - u32 sp1c; - u32 sp18; - sp1c = string_to_u32(&D_80365E40[1]); - sp18 = string_to_u32(&D_80365E40[5]); - send((u8 *) (uintptr_t) sp1c, sp18); -} - -void process_command_register(void) { - send((u8 *) &gInterruptedThread.context, sizeof(__OSThreadContext)); -} - -void kdebugserver(u32 a0) { - u32 sp2c; - unkStruct sp28; - *(u32 *) &sp28 = a0; - for (sp2c = 0; sp2c < sp28.unk01; sp2c++) { - D_80365E40[D_80334A34] = sp28.unk2[sp2c]; - D_80334A34++; - } - D_80334A38 -= sp28.unk01; - switch (D_80334A30) { - case 0: - switch (sp28.unk2[0]) { - case 1: - D_80334A30 = 1; - D_80334A38 = 9 - sp28.unk01; - break; - case 2: - process_command_register(); - D_80334A30 = 0; - D_80334A34 = 0; - D_80334A38 = 0; - break; - default: - D_80334A30 = 0; - D_80334A34 = 0; - D_80334A38 = 0; - break; - } - break; - case 1: - if (D_80334A38 <= 0) { - if (D_80365E40[0] == 1) { - process_command_memory(); - D_80334A30 = 0; - D_80334A34 = 0; - D_80334A38 = 0; - } else { - D_80334A30 = 0; - D_80334A34 = 0; - D_80334A38 = 0; - } - } - break; - default: - D_80334A30 = 0; - D_80334A34 = 0; - D_80334A38 = 0; - break; - } -} diff --git a/lib/src/kdebugserver_stack.c b/lib/src/kdebugserver_stack.c deleted file mode 100644 index 148e0d3f5..000000000 --- a/lib/src/kdebugserver_stack.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "libultra_internal.h" - -#if !defined(VERSION_SH) && !defined(VERSION_EU) -u8 D_80365E40[0x100]; -#endif diff --git a/lib/src/ldiv.c b/lib/src/ldiv.c deleted file mode 100644 index 01b04be2e..000000000 --- a/lib/src/ldiv.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "libultra_internal.h" -#include - -lldiv_t lldiv(long long num, long long denom) { - lldiv_t ret; - - ret.quot = num / denom; - ret.rem = num - denom * ret.quot; - if (ret.quot < 0 && ret.rem > 0) { - ret.quot++; - ret.rem -= denom; - } - - return ret; -} - -ldiv_t ldiv(long num, long denom) { - ldiv_t ret; - - ret.quot = num / denom; - ret.rem = num - denom * ret.quot; - if (ret.quot < 0 && ret.rem > 0) { - ret.quot++; - ret.rem -= denom; - } - - return ret; -} diff --git a/lib/src/leointerrupt.c b/lib/src/leointerrupt.c deleted file mode 100644 index 2aeea1e5e..000000000 --- a/lib/src/leointerrupt.c +++ /dev/null @@ -1,182 +0,0 @@ -#include "libultra_internal.h" -#include "PR/rcp.h" -#include "bstring.h" -#include "piint.h" -#include "osint.h" - -u8 leoDiskStack[OS_PIM_STACKSIZE]; //technically should have a OS_LEO_STACKSIZE or something.. - -#ifdef VERSION_SH -// TODO: so many magic constants :'( -static void __osLeoResume(void); -static void __osLeoAbnormalResume(void); - -s32 __osLeoInterrupt() { - u32 stat; - volatile u32 pi_stat; - u32 bm_stat; - __OSTranxInfo *info; - __OSBlockInfo *blockInfo; - stat = 0; - info = &__osDiskHandle->transferInfo; - blockInfo = &info->block[info->blockNum]; - pi_stat = IO_READ(PI_STATUS_REG); - if (pi_stat & PI_STATUS_DMA_BUSY) { - __OSGlobalIntMask = __OSGlobalIntMask & ~SR_IBIT4; //cartridge interrupt - blockInfo->errStatus = LEO_ERROR_29; - __osLeoResume(); - return 1; - } - WAIT_ON_IOBUSY(pi_stat); - stat = IO_READ(LEO_STATUS); - if (stat & LEO_STATUS_MECHANIC_INTERRUPT) { - WAIT_ON_IOBUSY(pi_stat); - IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR); - blockInfo->errStatus = LEO_ERROR_GOOD; - return 0; - } - if (info->cmdType == LEO_CMD_TYPE_2) { - return 1; - } - if (stat & LEO_STATUS_BUFFER_MANAGER_ERROR) { - WAIT_ON_IOBUSY(pi_stat); - stat = IO_READ(LEO_STATUS); - blockInfo->errStatus = LEO_ERROR_22; - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); - __OSGlobalIntMask |= OS_IM_PI; - return 1; - } - if (info->cmdType == LEO_CMD_TYPE_1) { - if ((stat & LEO_STATUS_DATA_REQUEST) == 0) { - if (info->sectorNum + 1 != info->transferMode * 85) { - blockInfo->errStatus = LEO_ERROR_24; - __osLeoAbnormalResume(); - return 1; - } - IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); - __OSGlobalIntMask |= OS_IM_PI; - blockInfo->errStatus = LEO_ERROR_GOOD; - __osLeoResume(); - return 1; - } - blockInfo->dramAddr = (void *)((u32)blockInfo->dramAddr + blockInfo->sectorSize); - info->sectorNum++; - osEPiRawStartDma(__osDiskHandle, OS_WRITE, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - return 1; - } - if (info->cmdType == LEO_CMD_TYPE_0) { - if (info->transferMode == LEO_SECTOR_MODE) { - if ((s32)blockInfo->C1ErrNum + 17 < info->sectorNum) { - blockInfo->errStatus = LEO_ERROR_GOOD; - __osLeoAbnormalResume(); - return 1; - } - if ((stat & LEO_STATUS_DATA_REQUEST) == 0) { - blockInfo->errStatus = LEO_ERROR_23; - __osLeoAbnormalResume(); - return 1; - } - } else { - blockInfo->dramAddr = (void *)((u32)blockInfo->dramAddr + blockInfo->sectorSize); - } - bm_stat = IO_READ(LEO_BM_STATUS); - if ((bm_stat & LEO_BM_STATUS_C1SINGLE && bm_stat & LEO_BM_STATUS_C1DOUBLE) || bm_stat & LEO_BM_STATUS_MICRO) { - if (blockInfo->C1ErrNum > 3) { - if (info->transferMode != LEO_SECTOR_MODE || info->sectorNum > 0x52) { - blockInfo->errStatus = LEO_ERROR_23; - __osLeoAbnormalResume(); - return 1; - } - } else { - int errNum = blockInfo->C1ErrNum; - blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; - } - blockInfo->C1ErrNum += 1; - } - if (stat & LEO_STATUS_C2_TRANSFER) { - if (info->sectorNum != 87) { - blockInfo->errStatus = LEO_ERROR_24; - __osLeoAbnormalResume(); - } - if (info->transferMode == LEO_TRACK_MODE && info->blockNum == 0) { - info->blockNum = 1; - info->sectorNum = -1; - info->block[1].dramAddr = (void *)((u32)info->block[1].dramAddr - info->block[1].sectorSize); - - blockInfo->errStatus = LEO_ERROR_22; - } else { - IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); - __OSGlobalIntMask |= OS_IM_PI; - info->cmdType = LEO_CMD_TYPE_2; - blockInfo->errStatus = LEO_ERROR_GOOD; - } - osEPiRawStartDma(__osDiskHandle, OS_READ, LEO_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4); - return 1; - } - - if (info->sectorNum == -1 && info->transferMode == LEO_TRACK_MODE && info->blockNum == 1) { - __OSBlockInfo *bptr = &info->block[0]; - if (bptr->C1ErrNum == 0) { - if (((u32 *)bptr->C2Addr)[0] | ((u32 *)bptr->C2Addr)[1] | ((u32 *)bptr->C2Addr)[2] | ((u32 *)bptr->C2Addr)[3]) { - bptr->errStatus = LEO_ERROR_24; - __osLeoAbnormalResume(); - return 1; - } - } - bptr->errStatus = 0; - __osLeoResume(); - } - info->sectorNum++; - if (stat & LEO_STATUS_DATA_REQUEST) { - if (info->sectorNum > 0x54) { - blockInfo->errStatus = LEO_ERROR_24; - __osLeoAbnormalResume(); - return 1; - } - osEPiRawStartDma(__osDiskHandle, 0, LEO_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - blockInfo->errStatus = LEO_ERROR_GOOD; - return 1; - } - if (info->sectorNum <= 0x54) { - blockInfo->errStatus = LEO_ERROR_24; - __osLeoAbnormalResume(); - return 1; - } - return 1; - } - blockInfo->errStatus = LEO_ERROR_4; - __osLeoAbnormalResume(); - return 1; -} - -static void __osLeoAbnormalResume(void) { - __OSTranxInfo *info; - u32 pi_stat; - info = &__osDiskHandle->transferInfo; - WAIT_ON_IOBUSY(pi_stat); - IO_WRITE(LEO_BM_CTL, info->bmCtlShadow | LEO_BM_CTL_RESET); - WAIT_ON_IOBUSY(pi_stat); - IO_WRITE(LEO_BM_CTL, info->bmCtlShadow); - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); - __OSGlobalIntMask |= OS_IM_PI; -} - -static void __osLeoResume(void) { - __OSEventState *es; - OSMesgQueue *mq; - s32 last; - es = &__osEventStateTab[OS_EVENT_PI]; - mq = es->messageQueue; - if (mq == NULL || MQ_IS_FULL(mq)) { - return; - } - last = (mq->first + mq->validCount) % mq->msgCount; - mq->msg[last] = es->message; - mq->validCount++; - if (mq->mtqueue->next != NULL) { - __osEnqueueThread(&D_80334898, __osPopThread(&mq->mtqueue)); - } -} -#endif diff --git a/lib/src/libaudio_internal.h b/lib/src/libaudio_internal.h deleted file mode 100644 index ea63322c1..000000000 --- a/lib/src/libaudio_internal.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef _LIBAUDIO_INTERNAL_H_ -#define _LIBAUDIO_INTERNAL_H_ -#include -#define AL_BANK_VERSION 0x4231 /* 'B1' */ - -typedef u8 ALPan; -typedef s32 ALMicroTime; - -/* Possible wavetable types */ -enum -{ - AL_ADPCM_WAVE = 0, - AL_RAW16_WAVE -}; - -typedef struct -{ - u32 start; - u32 end; - u32 count; -} ALRawLoop; - -typedef struct -{ - u32 start; - u32 end; - u32 count; - ADPCM_STATE state; -} ALADPCMloop; - -typedef struct -{ - s32 order; - s32 npredictors; - s16 book[1]; // variable size, 8-byte aligned -} ALADPCMBook; - -typedef struct -{ - ALMicroTime attackTime; - ALMicroTime decayTime; - ALMicroTime releaseTime; - u8 attackVolume; - u8 decayVolume; -} ALEnvelope; - -typedef struct -{ - u8 velocityMin; - u8 velocityMax; - u8 keyMin; - u8 keyMax; - u8 keyBase; - s8 detune; -} ALKeyMap; - -typedef struct -{ - ALADPCMloop *loop; - ALADPCMBook *book; -} ALADPCMWaveInfo; - -typedef struct -{ - ALRawLoop *loop; -} ALRAWWaveInfo; - -typedef struct ALWaveTable_s -{ - u8 *base; /* ptr to start of wave data */ - s32 len; /* length of data in bytes */ - u8 type; /* compression type */ - u8 flags; /* offset/address flags */ - union { - ALADPCMWaveInfo adpcmWave; - ALRAWWaveInfo rawWave; - } waveInfo; -} ALWaveTable; - -typedef struct ALSound_s -{ - ALEnvelope *envelope; - ALKeyMap *keyMap; - ALWaveTable *wavetable; /* offset to wavetable struct */ - ALPan samplePan; - u8 sampleVolume; - u8 flags; -} ALSound; - -typedef struct -{ - u8 volume; /* overall volume for this instrument */ - ALPan pan; /* 0 = hard left, 127 = hard right */ - u8 priority; /* voice priority for this instrument */ - u8 flags; - u8 tremType; /* the type of tremelo osc. to use */ - u8 tremRate; /* the rate of the tremelo osc. */ - u8 tremDepth; /* the depth of the tremelo osc */ - u8 tremDelay; /* the delay for the tremelo osc */ - u8 vibType; /* the type of tremelo osc. to use */ - u8 vibRate; /* the rate of the tremelo osc. */ - u8 vibDepth; /* the depth of the tremelo osc */ - u8 vibDelay; /* the delay for the tremelo osc */ - s16 bendRange; /* pitch bend range in cents */ - s16 soundCount; /* number of sounds in this array */ - ALSound *soundArray[1]; -} ALInstrument; - -typedef struct ALBank_s -{ - s16 instCount; /* number of programs in this bank */ - u8 flags; - u8 pad; - s32 sampleRate; /* e.g. 44100, 22050, etc... */ - ALInstrument *percussion; /* default percussion for GM */ - ALInstrument *instArray[1]; /* ARRAY of instruments */ -} ALBank; - -typedef struct -{ /* Note: sizeof won't be correct */ - s16 revision; /* format revision of this file */ - s16 bankCount; /* number of banks */ - ALBank *bankArray[1]; /* ARRAY of bank offsets */ -} ALBankFile; - -void alBnkfNew(ALBankFile *f, u8 *table); -#endif diff --git a/lib/src/libultra_internal.h b/lib/src/libultra_internal.h deleted file mode 100644 index 5639c6ac8..000000000 --- a/lib/src/libultra_internal.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef _LIBULTRA_INTERNAL_H_ -#define _LIBULTRA_INTERNAL_H_ -#include - -/* - * This define is needed because the original definitions in __osDequeueThread.c are declared - * seperately instead of part of a single struct, however some code alises over this memory - * assuming a unified structure. To fix this, we declare the full type here and then alias the - * symbol names to the correct members in AVOID_UB. - */ -#ifdef AVOID_UB -typedef struct OSThread_ListHead_s -{ - /*0x00*/ struct OSThread_s *next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread_s *queue; - /*0x0C*/ struct OSThread_s *tlnext; - /*0x10*/ struct OSThread_s *unk10; - /*0x14*/ u32 unk14; -} OSThread_ListHead; - -// Now fix the symbols to the new one. -extern OSThread_ListHead D_80334890_fix; - -#define D_80334890 D_80334890_fix.next -#define D_80334894 D_80334890_fix.priority -#define D_80334898 D_80334890_fix.queue -#define D_8033489C D_80334890_fix.tlnext -#define D_803348A0 D_80334890_fix.unk10 - -// Fix for the EEPROM array. -extern u32 D_80365E00[16]; - -// alias the last array element correctly -#define D_80365E3C D_80365E00[15] -#else -// Original OSThread_ListHead definitions -extern OSThread *D_80334890; -extern u32 D_80334894; -extern OSThread *D_80334898; -extern OSThread *D_8033489C; -extern OSThread *D_803348A0; - -// Original EEPROM definitions -extern u32 D_80365E00[15]; -extern u32 D_80365E3C; -#endif - -typedef struct { - u32 initialized; // probably something like initialized? - OSThread *mgrThread; - OSMesgQueue *cmdQueue; - OSMesgQueue *eventQueue; - OSMesgQueue *accessQueue; - s32 (*dma_func)(s32, u32, void *, size_t); -#if defined(VERSION_EU) || defined(VERSION_SH) - s32 (*edma_func)(OSPiHandle*, s32, u32, void *, size_t); -#else - u64 force_align; -#endif -} OSMgrArgs; - -s32 __osDisableInt(void); -void __osRestoreInt(s32); -void __osEnqueueAndYield(OSThread **); -void __osDequeueThread(OSThread **, OSThread *); -void __osEnqueueThread(OSThread **, OSThread *); -OSThread *__osPopThread(OSThread **); -s32 __osSiRawStartDma(s32, void *); -void __osSiCreateAccessQueue(void); -void __osSiGetAccess(void); -void __osSiRelAccess(void); -u32 __osProbeTLB(void *); -void __osPiCreateAccessQueue(void); -void __osPiGetAccess(void); -void __osSetSR(u32); -u32 __osGetSR(void); -void __osSetFpcCsr(u32); -s32 __osSiRawReadIo(void *, u32 *); -s32 __osSiRawWriteIo(void *, u32); -s32 osPiRawReadIo(u32 a0, u32 *a1); -void __osSpSetStatus(u32); -u32 __osSpGetStatus(void); -s32 __osSpSetPc(void *); -s32 __osSpDeviceBusy(void); -s32 __osSiDeviceBusy(void); -s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size); -void __osViInit(void); -OSViContext *__osViGetCurrentContext(void); -OSViContext *__osViGetCurrentContext2(void); -void __osViSwapContext(void); -void __osSetTimerIntr(u64); -u64 __osInsertTimer(OSTimer *); -void __osSetCompare(u32); -s32 __osAiDeviceBusy(void); -void __osDispatchThread(void); -u32 __osGetCause(void); -s32 __osAtomicDec(u32 *); -#endif diff --git a/lib/src/math/cosf.c b/lib/src/math/cosf.c deleted file mode 100644 index 2b01c12a5..000000000 --- a/lib/src/math/cosf.c +++ /dev/null @@ -1,94 +0,0 @@ - -// These unions are necessary to put the constants in .rodata rather than .data. -// TODO: is it possible to remove them somehow? - -typedef union { - /* 0x0 */ double d; - /* 0x0 */ struct - { - /* 0x0 */ unsigned int hi; - /* 0x4 */ unsigned int lo; - } word; -} du; - -typedef union { - /* 0x0 */ float f; - /* 0x0 */ unsigned int i; -} fu; - -static const du P[5] = {{1.0}, - {-0.16666659550427756}, - {0.008333066246082155}, - {-1.980960290193795E-4}, - {2.605780637968037E-6}}; - -static const du rpi = {0.3183098861837907}; - -static const du pihi = { - 3.1415926218032837}; - -static const du pilo = { - 3.178650954705639E-8}; - -static const fu zero = {0.0}; -extern const fu NAN; - -float cosf(float x) -{ - double dx; // double x - double xsq; // x squared - double poly; - double dn; - float xabs; - int n; - double result; - int ix; // int x - int xpt; - ix = *(int *)&x; - xpt = (ix >> 22) & 0x1FF; - - if (xpt < 310) - { - if (0 < x) - xabs = x; - else - xabs = -x; - dx = xabs; - - dn = dx * rpi.d + .5; - if (0 <= dn) - { - - n = dn + .5; - } - else - { - n = dn - .5; - } - dn = n; - - dx -= (dn - .5) * pihi.d; - dx -= (dn - .5) * pilo.d; - xsq = dx * dx; - - poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d; - - result = ((dx * xsq) * poly) + dx; - - if ((n & 0x1) == 0) - { - return result; - } - else - { - return -(float)result; - } - } - - if (x != x) - { - return NAN.f; - } - - return zero.f; -} diff --git a/lib/src/math/llconv.c b/lib/src/math/llconv.c deleted file mode 100644 index 3cf941c14..000000000 --- a/lib/src/math/llconv.c +++ /dev/null @@ -1,34 +0,0 @@ -typedef signed long long int s64; -typedef unsigned long long int u64; -s64 __d_to_ll(double d) -{ - return d; -} -s64 __f_to_ll(float f) -{ - return f; -} -u64 __d_to_ull(double d) -{ - return d; -} -u64 __f_to_ull(float f) -{ - return f; -} -double __ll_to_d(s64 s) -{ - return s; -} -float __ll_to_f(s64 s) -{ - return s; -} -double __ull_to_d(u64 u) -{ - return u; -} -float __ull_to_f(u64 u) -{ - return u; -} diff --git a/lib/src/math/llmuldiv.c b/lib/src/math/llmuldiv.c deleted file mode 100644 index e64b9d0c8..000000000 --- a/lib/src/math/llmuldiv.c +++ /dev/null @@ -1,53 +0,0 @@ -unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) -{ - return a0 >> a1; -} -unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1) -{ - return a0 % a1; -} -unsigned long long __ull_div(unsigned long long a0, unsigned long long a1) -{ - return a0 / a1; -} - -unsigned long long __ll_lshift(unsigned long long a0, unsigned long long a1) -{ - return a0 << a1; -} - -long long __ll_rem(unsigned long long a0, long long a1) -{ - return a0 % a1; -} - -long long __ll_div(long long a0, long long a1) -{ - return a0 / a1; -} - -unsigned long long __ll_mul(unsigned long long a0, unsigned long long a1) -{ - return a0 * a1; -} - -void __ull_divremi(unsigned long long *div, unsigned long long *rem, unsigned long long a2, unsigned short a3) -{ - *div = a2 / a3; - *rem = a2 % a3; -} -long long __ll_mod(long long a0, long long a1) -{ - long long tmp = a0 % a1; - if ((tmp < 0 && a1 > 0) || (tmp > 0 && a1 < 0)) - { - - tmp += a1; - } - return tmp; -} - -long long __ll_rshift(long long a0, long long a1) -{ - return a0 >> a1; -} diff --git a/lib/src/math/sinf.c b/lib/src/math/sinf.c deleted file mode 100644 index bdc83168e..000000000 --- a/lib/src/math/sinf.c +++ /dev/null @@ -1,111 +0,0 @@ - -// These unions are necessary to put the constants in .rodata rather than .data. -// TODO: is it possible to remove them somehow? - -typedef union { - /* 0x0 */ double d; - /* 0x0 */ struct - { - /* 0x0 */ unsigned int hi; - /* 0x4 */ unsigned int lo; - } word; -} du; - -typedef union { - /* 0x0 */ float f; - /* 0x0 */ unsigned int i; -} fu; - -static const du P[5] = {{1.0}, - {-0.16666659550427756}, - {0.008333066246082155}, - {-1.980960290193795E-4}, - {2.605780637968037E-6}}; - -static const du rpi = {0.3183098861837907}; - -static const du pihi = { - 3.1415926218032837}; - -static const du pilo = { - 3.178650954705639E-8}; - -static const fu zero = {0.0}; -extern const fu NAN; - -float sinf(float x) -{ - double dx; // double x - double xsq; // x squared - double poly; - double dn; - int n; - double result; - int ix; // int x - int xpt; - - ix = *(int *)&x; - xpt = (ix >> 22) & 0x1FF; - - if (xpt < 255) - { - dx = x; - if (xpt >= 230) - { - xsq = dx * dx; - - poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d; - - result = ((dx * xsq) * poly) + dx; - - return result; - } - else - { - return x; - } - } - - if (xpt < 310) - { - dx = x; - - dn = dx * rpi.d; - - if (dn >= 0) - { - n = dn + 0.5; - } - else - { - n = dn - 0.5; - } - - dn = n; - - dx -= dn * pihi.d; - dx -= dn * pilo.d; - - xsq = dx * dx; - - poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d; - - result = ((dx * xsq) * poly) + dx; - - if ((n & 0x1) == 0) - { - return result; - } - else - { - return -(float)result; - } - } - - if (x != x) - { - return NAN.f; - } - - return zero.f; -} diff --git a/lib/src/motor.c b/lib/src/motor.c deleted file mode 100644 index 3183fe222..000000000 --- a/lib/src/motor.c +++ /dev/null @@ -1,178 +0,0 @@ -#include "PR/os_message.h" -#include "PR/os_pi.h" -#include "libultra_internal.h" -#include "controller.h" - -void _MakeMotorData(int channel, u16 address, u8 *buffer, OSPifRam *mdata); -u32 __osMotorinitialized[MAXCONTROLLERS] = { 0, 0, 0, 0 }; -OSPifRam _MotorStopData[MAXCONTROLLERS]; -OSPifRam _MotorStartData[MAXCONTROLLERS]; -u8 _motorstopbuf[32]; -u8 _motorstartbuf[32]; - -s32 osMotorStop(OSPfs *pfs) { - int i; - s32 ret; - u8 *ptr; - __OSContRamReadFormat ramreadformat; - ptr = (u8 *) &__osPfsPifRam; - - if (!__osMotorinitialized[pfs->channel]) { - return PFS_ERR_INVALID; - } - __osSiGetAccess(); - - _osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK; - __osSiRawStartDma(OS_WRITE, &_MotorStopData[pfs->channel]); - osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - ptr = (u8 *) &__osPfsPifRam; - - if (pfs->channel != 0) { - for (i = 0; i < pfs->channel; i++) { - ptr++; - } - } - - ramreadformat = *(__OSContRamReadFormat *) ptr; - ret = CHNL_ERR(ramreadformat); - if (ret == 0 && ramreadformat.datacrc != __osContDataCrc((u8 *) &_motorstopbuf)) { - ret = PFS_ERR_CONTRFAIL; - } - __osSiRelAccess(); - return ret; -} - -s32 osMotorStart(OSPfs *pfs) { - int i; - s32 ret; - u8 *ptr; - __OSContRamReadFormat ramreadformat; - - ptr = (u8 *) &__osPfsPifRam; - - if (!__osMotorinitialized[pfs->channel]) { - return PFS_ERR_INVALID; - } - - __osSiGetAccess(); - - _osLastSentSiCmd = CONT_CMD_WRITE_MEMPACK; - __osSiRawStartDma(OS_WRITE, &_MotorStartData[pfs->channel]); - osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(pfs->queue, NULL, OS_MESG_BLOCK); - ptr = (u8 *) &__osPfsPifRam; - - if (pfs->channel != 0) { - for (i = 0; i < pfs->channel; i++) { - ptr++; - } - } - - ramreadformat = *(__OSContRamReadFormat *) ptr; - ret = CHNL_ERR(ramreadformat); - if (ret == 0 && ramreadformat.datacrc != __osContDataCrc((u8 *) &_motorstartbuf)) { - ret = PFS_ERR_CONTRFAIL; - } - __osSiRelAccess(); - return ret; -} - -void _MakeMotorData(int channel, u16 address, u8 *buffer, OSPifRam *mdata) { - u8 *ptr; - __OSContRamReadFormat ramreadformat; - int i; - - ptr = (u8 *) mdata->ramarray; - for (i = 0; i < ARRLEN(mdata->ramarray); i++) { - mdata->ramarray[i] = 0; - } - mdata->pifstatus = CONT_CMD_EXE; - ramreadformat.dummy = CONT_CMD_NOP; - ramreadformat.txsize = CONT_CMD_WRITE_MEMPACK_TX; - ramreadformat.rxsize = CONT_CMD_WRITE_MEMPACK_RX; - ramreadformat.cmd = CONT_CMD_WRITE_MEMPACK; - - ramreadformat.address = (address << 0x5) | __osContAddressCrc(address); - ramreadformat.datacrc = CONT_CMD_NOP; - for (i = 0; i < ARRLEN(ramreadformat.data); i++) { - ramreadformat.data[i] = *buffer++; - } - if (channel != 0) { - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } - } - *(__OSContRamReadFormat *) ptr = ramreadformat; - ptr += sizeof(__OSContRamReadFormat); - ptr[0] = CONT_CMD_END; -} - -s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int channel) { - int i; - s32 ret; - u8 temp[32]; - pfs->queue = mq; - pfs->channel = channel; - pfs->status = 0; - pfs->activebank = 128; - - for (i = 0; i < ARRLEN(temp); i++) { - temp[i] = 254; - } - - ret = __osContRamWrite(mq, channel, 1024, temp, FALSE); - if (ret == 2) { // TODO: remove magic constant - ret = __osContRamWrite(mq, channel, 1024, temp, FALSE); - } - if (ret != 0) { - return ret; - } - - ret = __osContRamRead(mq, channel, 1024, temp); - if (ret == 2) { - ret = PFS_ERR_CONTRFAIL; // is this right? - } - if (ret != 0) { - return ret; - } - if (temp[31] == 254) { - return PFS_ERR_DEVICE; - } - - for (i = 0; i < ARRLEN(temp); i++) { - temp[i] = 128; - } - - ret = __osContRamWrite(mq, channel, 1024, temp, FALSE); - if (ret == 2) { - ret = __osContRamWrite(mq, channel, 1024, temp, FALSE); - } - if (ret != 0) { - return ret; - } - - ret = __osContRamRead(mq, channel, 1024, temp); - if (ret == 2) { - ret = PFS_ERR_CONTRFAIL; - } - if (ret != 0) { - return ret; - } - if (temp[31] != 128) { - return PFS_ERR_DEVICE; - } - - if (!__osMotorinitialized[channel]) { - for (i = 0; i < ARRLEN(_motorstartbuf); i++) { - _motorstartbuf[i] = 1; - _motorstopbuf[i] = 0; - } - _MakeMotorData(channel, 1536, _motorstartbuf, &_MotorStartData[channel]); - _MakeMotorData(channel, 1536, _motorstopbuf, &_MotorStopData[channel]); - __osMotorinitialized[channel] = 1; - } - return 0; -} diff --git a/lib/src/new_func.h b/lib/src/new_func.h deleted file mode 100644 index f966f6d31..000000000 --- a/lib/src/new_func.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef NEW_FUNC_H -#define NEW_FUNC_H - -#include "libultra_internal.h" -#include "hardware.h" - -#define WAIT_ON_IOBUSY(var) \ - var = HW_REG(PI_STATUS_REG, u32); \ - while (var & PI_STATUS_IOBUSY) \ - var = HW_REG(PI_STATUS_REG, u32); - -extern u32 EU_D_80302090; - -extern OSPiHandle *__osDiskHandle; //possibly __osPiTable - -extern volatile u32 __OSGlobalIntMask; -s32 osEPiRawStartDma(OSPiHandle *arg0, s32 dir, u32 cart_addr, void *dram_addr, u32 size); -void func_802F4B08(void); -void func_802F4A20(void); -void __osResetGlobalIntMask(u32 mask); -void __osEPiRawWriteIo(OSPiHandle*, u32, u32); -void func_802F71F0(void); -#ifdef VERSION_SH -void __osSetGlobalIntMask(s32 arg0); -s32 __osEPiRawReadIo(OSPiHandle *arg0, u32 devAddr, u32 *arg2); -#endif - -#endif diff --git a/lib/src/os.h b/lib/src/os.h deleted file mode 100644 index 3126f4817..000000000 --- a/lib/src/os.h +++ /dev/null @@ -1,800 +0,0 @@ - -/*==================================================================== - * os.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/************************************************************************** - * - * $Revision: 1.149 $ - * $Date: 1997/12/15 04:30:52 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/os.h,v $ - * - **************************************************************************/ - - -#ifndef _OS_H_ -#define _OS_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for device manager block - */ -typedef struct { - s32 active; /* Status flag */ - OSThread *thread; /* Calling thread */ - OSMesgQueue *cmdQueue; /* Command queue */ - OSMesgQueue *evtQueue; /* Event queue */ - OSMesgQueue *acsQueue; /* Access queue */ - /* Raw DMA routine */ - s32 (*dma)(s32, u32, void *, u32); - s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); -} OSDevMgr; - -/* - * Structure for file system - */ - - - -typedef struct { - int status; - OSMesgQueue *queue; - int channel; - u8 id[32]; - u8 label[32]; - int version; - int dir_size; - int inode_table; /* block location */ - int minode_table; /* mirrioring inode_table */ - int dir_table; /* block location */ - int inode_start_page; /* page # */ - u8 banks; - u8 activebank; -} OSPfs; - - -typedef struct { - u32 file_size; /* bytes */ - u32 game_code; - u16 company_code; - char ext_name[4]; - char game_name[16]; -} OSPfsState; - -/* - * Structure for Profiler - */ -typedef struct { - u16 *histo_base; /* histogram base */ - u32 histo_size; /* histogram size */ - u32 *text_start; /* start of text segment */ - u32 *text_end; /* end of text segment */ -} OSProf; - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Thread states */ - -#define OS_STATE_STOPPED 1 -#define OS_STATE_RUNNABLE 2 -#define OS_STATE_RUNNING 4 -#define OS_STATE_WAITING 8 - -/* Events */ -#ifdef _FINALROM -#define OS_NUM_EVENTS 15 -#else -#define OS_NUM_EVENTS 23 -#endif - -#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ -#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ -#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ -#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ -#define OS_EVENT_SP 4 /* SP task done interrupt */ -#define OS_EVENT_SI 5 /* SI (controller) interrupt */ -#define OS_EVENT_AI 6 /* AI interrupt */ -#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ -#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ -#define OS_EVENT_DP 9 /* DP full sync interrupt */ -#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ -#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ -#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ -#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ -#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ -#ifndef _FINALROM -#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ -#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ -#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ -#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ -#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ -#define OS_EVENT_RDB_DBG_DONE 20 -#define OS_EVENT_RDB_FLUSH_PROF 21 -#define OS_EVENT_RDB_ACK_PROF 22 -#endif - -/* Flags for debugging purpose */ - -#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ -#define OS_FLAG_FAULT 2 /* CPU fault has occurred */ - -/* Interrupt masks */ - -#define OS_IM_NONE 0x00000001 -#define OS_IM_SW1 0x00000501 -#define OS_IM_SW2 0x00000601 -#define OS_IM_CART 0x00000c01 -#define OS_IM_PRENMI 0x00001401 -#define OS_IM_RDBWRITE 0x00002401 -#define OS_IM_RDBREAD 0x00004401 -#define OS_IM_COUNTER 0x00008401 -#define OS_IM_CPU 0x0000ff01 -#define OS_IM_SP 0x00010401 -#define OS_IM_SI 0x00020401 -#define OS_IM_AI 0x00040401 -#define OS_IM_VI 0x00080401 -#define OS_IM_PI 0x00100401 -#define OS_IM_DP 0x00200401 -#define OS_IM_ALL 0x003fff01 -#define RCP_IMASK 0x003f0000 -#define RCP_IMASKSHIFT 16 - -/* Recommended thread priorities for the system threads */ - -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 /* Must be 0 */ - - -/* Flags to turn blocking on/off when sending/receiving message */ - -#define OS_MESG_NOBLOCK 0 -#define OS_MESG_BLOCK 1 - -/* Flags to indicate direction of data transfer */ - -#define OS_READ 0 /* device -> RDRAM */ -#define OS_WRITE 1 /* device <- RDRAM */ -#define OS_OTHERS 2 /* for Leo disk only */ - -/* - * I/O message types - */ -#define OS_MESG_TYPE_BASE (10) -#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) -#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) -#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) -#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) -#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) -#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) -#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) - -/* - * I/O message priority - */ -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 - -/* - * Page size argument for TLB routines - */ -#define OS_PM_4K 0x0000000 -#define OS_PM_16K 0x0006000 -#define OS_PM_64K 0x001e000 -#define OS_PM_256K 0x007e000 -#define OS_PM_1M 0x01fe000 -#define OS_PM_4M 0x07fe000 -#define OS_PM_16M 0x1ffe000 - -/* - * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), - * SIM (SI Manager) - * - */ -#define OS_PIM_STACKSIZE 4096 -#define OS_VIM_STACKSIZE 4096 -#define OS_SIM_STACKSIZE 4096 - -#define OS_MIN_STACKSIZE 72 - -/* - * Values for osTvType - */ -#define OS_TV_PAL 0 -#define OS_TV_NTSC 1 -#define OS_TV_MPAL 2 - -/* - * Video Interface (VI) mode type - */ -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ -#define OS_VI_MPAL_LPF1 29 -#define OS_VI_MPAL_LAN1 30 -#define OS_VI_MPAL_LAF1 31 -#define OS_VI_MPAL_LPN2 32 -#define OS_VI_MPAL_LPF2 33 -#define OS_VI_MPAL_LAN2 34 -#define OS_VI_MPAL_LAF2 35 -#define OS_VI_MPAL_HPN1 36 -#define OS_VI_MPAL_HPF1 37 -#define OS_VI_MPAL_HAN1 38 -#define OS_VI_MPAL_HAF1 39 -#define OS_VI_MPAL_HPN2 40 -#define OS_VI_MPAL_HPF2 41 - -/* - * Video Interface (VI) special features - */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 - -/* - * Video Interface (VI) mode attribute bit - */ -#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ -#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ -#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ -#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ -#define OS_VI_BIT_ANTIALIAS 0x0010 -#define OS_VI_BIT_POINTSAMPLE 0x0020 -#define OS_VI_BIT_16PIXEL 0x0040 -#define OS_VI_BIT_32PIXEL 0x0080 -#define OS_VI_BIT_LORES 0x0100 -#define OS_VI_BIT_HIRES 0x0200 -#define OS_VI_BIT_NTSC 0x0400 -#define OS_VI_BIT_PAL 0x0800 - -/* - * Leo Disk - */ - -/* transfer mode */ - -#define LEO_BLOCK_MODE 1 -#define LEO_TRACK_MODE 2 -#define LEO_SECTOR_MODE 3 - -/* - * Controllers number - */ - -#ifndef _HW_VERSION_1 -#define MAXCONTROLLERS 4 -#else -#define MAXCONTROLLERS 6 -#endif - -/* controller errors */ -#define CONT_NO_RESPONSE_ERROR 0x8 -#define CONT_OVERRUN_ERROR 0x4 -#ifdef _HW_VERSION_1 -#define CONT_FRAME_ERROR 0x2 -#define CONT_COLLISION_ERROR 0x1 -#endif - -/* Controller type */ - -#define CONT_ABSOLUTE 0x0001 -#define CONT_RELATIVE 0x0002 -#define CONT_JOYPORT 0x0004 -#define CONT_EEPROM 0x8000 -#define CONT_EEP16K 0x4000 -#define CONT_TYPE_MASK 0x1f07 -#define CONT_TYPE_NORMAL 0x0005 -#define CONT_TYPE_MOUSE 0x0002 - -/* Controller status */ - -#define CONT_CARD_ON 0x01 -#define CONT_CARD_PULL 0x02 -#define CONT_ADDR_CRC_ER 0x04 -#define CONT_EEPROM_BUSY 0x80 - -/* EEPROM TYPE */ - -#define EEPROM_TYPE_4K 0x01 -#define EEPROM_TYPE_16K 0x02 - -/* Buttons */ - -#define CONT_A 0x8000 -#define CONT_B 0x4000 -#define CONT_G 0x2000 -#define CONT_START 0x1000 -#define CONT_UP 0x0800 -#define CONT_DOWN 0x0400 -#define CONT_LEFT 0x0200 -#define CONT_RIGHT 0x0100 -#define CONT_L 0x0020 -#define CONT_R 0x0010 -#define CONT_E 0x0008 -#define CONT_D 0x0004 -#define CONT_C 0x0002 -#define CONT_F 0x0001 - -/* Nintendo's official button names */ - -#define A_BUTTON CONT_A -#define B_BUTTON CONT_B -#define L_TRIG CONT_L -#define R_TRIG CONT_R -#define Z_TRIG CONT_G -#define START_BUTTON CONT_START -#define U_JPAD CONT_UP -#define L_JPAD CONT_LEFT -#define R_JPAD CONT_RIGHT -#define D_JPAD CONT_DOWN -#define U_CBUTTONS CONT_E -#define L_CBUTTONS CONT_C -#define R_CBUTTONS CONT_F -#define D_CBUTTONS CONT_D - -/* File System size */ -#define OS_PFS_VERSION 0x0200 -#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) -#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) - -#define PFS_FILE_NAME_LEN 16 -#define PFS_FILE_EXT_LEN 4 -#define BLOCKSIZE 32 /* bytes */ -#define PFS_ONE_PAGE 8 /* blocks */ -#define PFS_MAX_BANKS 62 - -/* File System flag */ - -#define PFS_READ 0 -#define PFS_WRITE 1 -#define PFS_CREATE 2 - -/* File System status */ -#define PFS_INITIALIZED 0x1 -#define PFS_CORRUPTED 0x2 /* File system was corrupted */ - -/* File System error number */ - -#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ -#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */ - /* different one */ -#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ -#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR -#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ -#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ -#define PFS_DATA_FULL 7 /* no free pages on ram pack */ -#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ -#define PFS_ERR_EXIST 9 /* file exists */ -#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ -#define PFS_ERR_DEVICE 11 /* wrong device type*/ - -/* definition for EEPROM */ - -#define EEPROM_MAXBLOCKS 64 -#define EEP16K_MAXBLOCKS 256 -#define EEPROM_BLOCK_SIZE 8 - -/* - * PI/EPI - */ -#define PI_DOMAIN1 0 -#define PI_DOMAIN2 1 - -/* - * Profiler constants - */ -#define PROF_MIN_INTERVAL 50 /* microseconds */ - -/* - * Boot addresses - */ -#define BOOT_ADDRESS_ULTRA 0x80000400 -#define BOOT_ADDRESS_COSIM 0x80002000 -#define BOOT_ADDRESS_EMU 0x20010000 -#define BOOT_ADDRESS_INDY 0x88100000 - -/* - * Size of buffer the retains contents after NMI - */ -#define OS_APP_NMI_BUFSIZE 64 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -/* PARTNER-N64 */ -#ifdef PTN64 -#define osReadHost osReadHost_pt -#define osWriteHost osWriteHost_pt -#endif - -/* Get count of valid messages in queue */ -#define MQ_GET_COUNT(mq) ((mq)->validCount) - -/* Figure out if message queue is empty or full */ -#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) -#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) - -/* - * CPU counter increments at 3/4 of bus clock rate: - * - * Bus Clock Proc Clock Counter (1/2 Proc Clock) - * --------- ---------- ------------------------ - * 62.5 Mhz 93.75 Mhz 46.875 Mhz - */ -extern u64 osClockRate; - -#define OS_CLOCK_RATE 62500000LL -#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) -#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) -#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) -#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) -#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) - -/************************************************************************** - * - * Extern variables - * - */ -extern OSViMode osViModeTable[]; /* Global VI mode table */ - -extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ -extern OSViMode osViModeNtscLpf1; -extern OSViMode osViModeNtscLan1; -extern OSViMode osViModeNtscLaf1; -extern OSViMode osViModeNtscLpn2; -extern OSViMode osViModeNtscLpf2; -extern OSViMode osViModeNtscLan2; -extern OSViMode osViModeNtscLaf2; -extern OSViMode osViModeNtscHpn1; -extern OSViMode osViModeNtscHpf1; -extern OSViMode osViModeNtscHan1; -extern OSViMode osViModeNtscHaf1; -extern OSViMode osViModeNtscHpn2; -extern OSViMode osViModeNtscHpf2; - -extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ -extern OSViMode osViModePalLpf1; -extern OSViMode osViModePalLan1; -extern OSViMode osViModePalLaf1; -extern OSViMode osViModePalLpn2; -extern OSViMode osViModePalLpf2; -extern OSViMode osViModePalLan2; -extern OSViMode osViModePalLaf2; -extern OSViMode osViModePalHpn1; -extern OSViMode osViModePalHpf1; -extern OSViMode osViModePalHan1; -extern OSViMode osViModePalHaf1; -extern OSViMode osViModePalHpn2; -extern OSViMode osViModePalHpf2; - -extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ -extern OSViMode osViModeMpalLpf1; -extern OSViMode osViModeMpalLan1; -extern OSViMode osViModeMpalLaf1; -extern OSViMode osViModeMpalLpn2; -extern OSViMode osViModeMpalLpf2; -extern OSViMode osViModeMpalLan2; -extern OSViMode osViModeMpalLaf2; -extern OSViMode osViModeMpalHpn1; -extern OSViMode osViModeMpalHpf1; -extern OSViMode osViModeMpalHan1; -extern OSViMode osViModeMpalHaf1; -extern OSViMode osViModeMpalHpn2; -extern OSViMode osViModeMpalHpf2; - -extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ -extern u32 osRomBase; /* Rom base address of the game image */ -extern u32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ -extern u32 osResetType; /* 0 = cold reset, 1 = NMI */ -extern s32 osCicId; -extern s32 osVersion; -extern u32 osMemSize; /* Memory Size */ -extern s32 osAppNMIBuffer[]; - -extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ -extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ -extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ - - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Thread operations */ - -extern void osCreateThread(OSThread *, OSId, void (*)(void *), - void *, void *, OSPri); -extern void osDestroyThread(OSThread *); -extern void osYieldThread(void); -extern void osStartThread(OSThread *); -extern void osStopThread(OSThread *); -extern OSId osGetThreadId(OSThread *); -extern void osSetThreadPri(OSThread *, OSPri); -extern OSPri osGetThreadPri(OSThread *); - -/* Message operations */ - -extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); -extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); - -/* Event operations */ - -extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); - -/* Interrupt operations */ - -extern OSIntMask osGetIntMask(void); -extern OSIntMask osSetIntMask(OSIntMask); - -/* RDB port operations */ - -extern void osInitRdb(u8 *sendBuf, u32 sendSize); - -/* Cache operations and macros */ - -extern void osInvalDCache(void *, size_t); -extern void osInvalICache(void *, size_t); -extern void osWritebackDCache(void *, size_t); -extern void osWritebackDCacheAll(void); - -#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) -#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) - -/* TLB management routines */ - -extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); -extern void osMapTLBRdb(void); -extern void osUnmapTLB(s32); -extern void osUnmapTLBAll(void); -extern void osSetTLBASID(s32); - -/* Address translation routines and macros */ - -extern u32 osVirtualToPhysical(void *); -extern void * osPhysicalToVirtual(u32); - -#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) -#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) - -#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) -#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) - -/* I/O operations */ - -/* Audio interface (Ai) */ -extern u32 osAiGetStatus(void); -extern u32 osAiGetLength(void); -extern s32 osAiSetFrequency(u32); -extern s32 osAiSetNextBuffer(void *, u32); - -/* Display processor interface (Dp) */ -extern u32 osDpGetStatus(void); -extern void osDpSetStatus(u32); -extern void osDpGetCounters(u32 *); -extern s32 osDpSetNextBuffer(void *, u64); - -/* Peripheral interface (Pi) */ -extern u32 osPiGetStatus(void); -extern s32 osPiGetDeviceType(void); -extern s32 osPiRawWriteIo(u32, u32); -extern s32 osPiRawReadIo(u32, u32 *); -extern s32 osPiRawStartDma(s32, u32, void *, u32); -extern s32 osPiWriteIo(u32, u32); -extern s32 osPiReadIo(u32, u32 *); -extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, - OSMesgQueue *); -extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); - -/* Video interface (Vi) */ -extern u32 osViGetStatus(void); -extern u32 osViGetCurrentMode(void); -extern u32 osViGetCurrentLine(void); -extern u32 osViGetCurrentField(void); -extern void *osViGetCurrentFramebuffer(void); -extern void *osViGetNextFramebuffer(void); -extern void osViSetXScale(f32); -extern void osViSetYScale(f32); -extern void osViSetSpecialFeatures(u32); -extern void osViSetMode(OSViMode *); -extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); -extern void osViSwapBuffer(void *); -extern void osViBlack(u8); -extern void osViFade(u8, u16); -extern void osViRepeatLine(u8); -extern void osCreateViManager(OSPri); - -/* Timer interface */ - -extern OSTime osGetTime(void); -extern void osSetTime(OSTime); -extern u32 osSetTimer(OSTimer *, OSTime, OSTime, - OSMesgQueue *, OSMesg); -extern int osStopTimer(OSTimer *); - -/* Controller interface */ - -extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); -extern s32 osContReset(OSMesgQueue *, OSContStatus *); -extern s32 osContStartQuery(OSMesgQueue *); -extern s32 osContStartReadData(OSMesgQueue *); -#ifndef _HW_VERSION_1 -extern s32 osContSetCh(u8); -#endif -extern void osContGetQuery(OSContStatus *); -extern void osContGetReadData(OSContPad *); - -/* file system interface */ - -extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsRepairId(OSPfs *); -extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); -extern s32 osPfsChecker(OSPfs *); -extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); -extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); -extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); -extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); -extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); -extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); -extern s32 osPfsSetLabel(OSPfs *, u8 *); -extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); -extern s32 osPfsFreeBlocks(OSPfs *, s32 *); -extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); - -/* EEPROM interface */ - -extern s32 osEepromProbe(OSMesgQueue *); -extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); -extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); -extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); -extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); - -/* MOTOR interface */ - -extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); -extern s32 osMotorStop(OSPfs *); -extern s32 osMotorStart(OSPfs *); - -/* Enhanced PI interface */ - -extern OSPiHandle *osCartRomInit(void); -extern OSPiHandle *osLeoDiskInit(void); -extern OSPiHandle *osDriveRomInit(void); - -extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); -extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32); -extern s32 osEPiRawReadIo(OSPiHandle *, u32 , u32 *); -extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); -extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); -extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); -extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); -extern s32 osEPiLinkHandle(OSPiHandle *); - -/* Profiler Interface */ - -extern void osProfileInit(OSProf *, u32 profcnt); -extern void osProfileStart(u32); -extern void osProfileFlush(void); -extern void osProfileStop(void); - -/* Game <> Host data transfer functions */ - -extern s32 osTestHost(void); -extern void osReadHost(void *, u32); -extern void osWriteHost(void *, u32); -extern void osAckRamromRead(void); -extern void osAckRamromWrite(void); - - -/* byte string operations */ - -extern void bcopy(const void *, void *, size_t); -extern int bcmp(const void *, const void *, int); -extern void bzero(void *, size_t); - -/* Miscellaneous operations */ - -extern void osInitialize(void); -extern u32 osGetCount(void); -extern void osExit(void); -extern u32 osGetMemSize(void); - -/* Printf */ - -extern int sprintf(char *s, const char *fmt, ...); -extern void osSyncPrintf(const char *fmt, ...); -extern void osAsyncPrintf(const char *fmt, ...); -extern int osSyncGetChars(char *buf); -extern int osAsyncGetChars(char *buf); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_H */ diff --git a/lib/src/osAi.h b/lib/src/osAi.h deleted file mode 100644 index 276fa071a..000000000 --- a/lib/src/osAi.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _OSAI_H_ -#define _OSAI_H_ - -s32 osAiSetFrequency(u32); -s32 osAiSetNextBuffer(void *, u32); -u32 osAiGetLength(void); -#endif diff --git a/lib/src/osAiGetLength.c b/lib/src/osAiGetLength.c deleted file mode 100644 index 08458a7ab..000000000 --- a/lib/src/osAiGetLength.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "libultra_internal.h" -#include "osAi.h" -#include "hardware.h" - -u32 osAiGetLength() { - return HW_REG(AI_LEN_REG, u32); -} diff --git a/lib/src/osAiSetFrequency.c b/lib/src/osAiSetFrequency.c deleted file mode 100644 index 4b32658eb..000000000 --- a/lib/src/osAiSetFrequency.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "libultra_internal.h" -#include "osAi.h" -#include "hardware.h" - -extern s32 osViClock; - -s32 osAiSetFrequency(u32 freq) { - register u32 a1; - register s32 a2; - register float ftmp; - ftmp = osViClock / (float) freq + .5f; - - a1 = ftmp; - - if (a1 < 0x84) { - return -1; - } - - a2 = (a1 / 66) & 0xff; - if (a2 > 16) { - a2 = 16; - } - - HW_REG(AI_DACRATE_REG, u32) = a1 - 1; - HW_REG(AI_BITRATE_REG, u32) = a2 - 1; - HW_REG(AI_CONTROL_REG, u32) = 1; // enable dma - return osViClock / (s32) a1; -} - -#ifndef VERSION_SH -// put some extra jr $ra's down there please -static void filler1(void) { -} - -static void filler2(void) { -} -#endif diff --git a/lib/src/osAiSetNextBuffer.c b/lib/src/osAiSetNextBuffer.c deleted file mode 100644 index cc27ae4c9..000000000 --- a/lib/src/osAiSetNextBuffer.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "libultra_internal.h" -#include "osAi.h" -#include "hardware.h" - -u8 D_80334820 = 0; - -/** - * It is worth noting that a previous hardware bug has been fixed by a software - * patch in osAiSetNextBuffer. This bug occurred when the address of the end of the - * buffer specified by osAiSetNextBuffer was at a specific value. This value - * occurred when the following was true: - * - * (vaddr + nbytes) & 0x00003FFF == 0x00002000 - * - * (when the buffer ends with address of lower 14 bits 0x2000) In this case, the - * DMA transfer does not complete successfully. This can cause clicks and pops in - * the audio output. This bug no longer requires special handling by the application - * because it is now patched by osAiSetNextBuffer. - */ - -s32 osAiSetNextBuffer(void *buff, u32 len) { - u8 *sp1c = buff; - if (D_80334820 != 0) { - sp1c -= 0x2000; - } - - if ((((uintptr_t) buff + len) & 0x3fff) == 0x2000) { - D_80334820 = 1; - } else { - D_80334820 = 0; - } - - if (__osAiDeviceBusy()) { - return -1; - } - - HW_REG(AI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(sp1c); - HW_REG(AI_LEN_REG, u32) = len; - return 0; -} diff --git a/lib/src/osCartRomInit.c b/lib/src/osCartRomInit.c deleted file mode 100644 index 51602f696..000000000 --- a/lib/src/osCartRomInit.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "PR/os_internal.h" -#include "PR/R4300.h" -#include "PR/rcp.h" -#include "PR/os_pi.h" -#include "os.h" - -#ifdef VERSION_SH -OSPiHandle CartRomHandle; - -OSPiHandle *osCartRomInit(void) { - u32 domain; - u32 saveMask; - - domain = 0; - - if (CartRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR2)) { - return &CartRomHandle; - } - - CartRomHandle.type = DEVICE_TYPE_CART; - CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2); - osPiRawReadIo(0, &domain); - CartRomHandle.latency = domain & 0xff; - CartRomHandle.pulse = (domain >> 8) & 0xff; - CartRomHandle.pageSize = (domain >> 0x10) & 0xf; - CartRomHandle.relDuration = (domain >> 0x14) & 0xf; - CartRomHandle.domain = PI_DOMAIN1; - //CartRomHandle.speed = 0; - - bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo)); - - saveMask = __osDisableInt(); - CartRomHandle.next = __osPiTable; - __osPiTable = &CartRomHandle; - __osRestoreInt(saveMask); - - return &CartRomHandle; -} -#endif diff --git a/lib/src/osContInit.c b/lib/src/osContInit.c deleted file mode 100644 index d54540087..000000000 --- a/lib/src/osContInit.c +++ /dev/null @@ -1,99 +0,0 @@ -#include "libultra_internal.h" -#include "osContInternal.h" - -void __osPackRequestData(u8); -void __osContGetInitData(u8 *, OSContStatus *); - -u32 _osContInitialized = 0; // probably initialized - -extern u64 osClockRate; - -// these probably belong in EEPROMlongread or something -u8 _osLastSentSiCmd; -u8 _osContNumControllers; -OSTimer D_80365D28; -OSMesgQueue _osContMesgQueue; -OSMesg _osContMesgBuff[4]; -s32 osContInit(OSMesgQueue *mq, u8 *bitpattern, OSContStatus *status) { - OSMesg mesg; - u32 ret = 0; - OSTime currentTime; - OSTimer timer; - OSMesgQueue timerMesgQueue; - - if (_osContInitialized) { - return 0; - } - _osContInitialized = 1; - currentTime = osGetTime(); - if (500000 * osClockRate / 1000000 > currentTime) { - osCreateMesgQueue(&timerMesgQueue, &mesg, 1); - osSetTimer(&timer, 500000 * osClockRate / 1000000 - currentTime, 0, &timerMesgQueue, &mesg); - osRecvMesg(&timerMesgQueue, &mesg, OS_MESG_BLOCK); - } - _osContNumControllers = 4; // TODO: figure out what it means -#if defined(VERSION_EU) || defined(VERSION_SH) - __osPackRequestData(0); -#else - __osPackRequestData(255); -#endif - ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf); - osRecvMesg(mq, &mesg, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); - osRecvMesg(mq, &mesg, OS_MESG_BLOCK); - __osContGetInitData(bitpattern, status); -#if defined(VERSION_EU) || defined(VERSION_SH) - _osLastSentSiCmd = 0; -#else - _osLastSentSiCmd = 255; -#endif - __osSiCreateAccessQueue(); - osCreateMesgQueue(&_osContMesgQueue, _osContMesgBuff, 1); - return ret; -} -void __osContGetInitData(u8 *bitpattern, OSContStatus *status) { - OSContPackedRequest *cmdBufPtr; - OSContPackedRequest response; - s32 i; - u8 sp7; - - sp7 = 0; - cmdBufPtr = &(_osContCmdBuf[0].request); - for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, status++) { - response = *(OSContPackedRequest *) cmdBufPtr; - status->errnum = (response.rxLen & 0xc0) >> 4; - if (status->errnum == 0) { - status->type = response.data2 << 8 | response.data1; - status->status = response.data3; - - sp7 |= 1 << i; - } - } - *bitpattern = sp7; -} -void __osPackRequestData(u8 command) { - OSContPackedRequest *cmdBufPtr; - OSContPackedRequest request; - s32 i; - - // some kind of weird zeroing code - for (i = 0; i < 0x10; i++) { - *((u32 *) &_osContCmdBuf + i) = 0; - } - - _osContPifCtrl = 1; - cmdBufPtr = &_osContCmdBuf[0].request; - request.padOrEnd = 255; - request.txLen = 1; - request.rxLen = 3; - request.command = command; - request.data1 = 255; - request.data2 = 255; - request.data3 = 255; - request.data4 = 255; - - for (i = 0; i < _osContNumControllers; i++) { - *cmdBufPtr++ = request; - } - cmdBufPtr->padOrEnd = 254; -} diff --git a/lib/src/osContInternal.h b/lib/src/osContInternal.h deleted file mode 100644 index 0f628205b..000000000 --- a/lib/src/osContInternal.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _ULTRA64_CONTROLLER_INTERNAL_H_ -#define _ULTRA64_CONTROLLER_INTERNAL_H_ - -#include - -typedef struct -{ - u8 padOrEnd; - u8 txLen; - u8 rxLen; //includes errno - u8 command; - u16 button; - s8 rawStickX; - s8 rawStickY; -} OSContPackedRead; - -typedef struct -{ - u8 padOrEnd; - u8 txLen; - u8 rxLen; - u8 command; - u8 data1; - u8 data2; - u8 data3; - u8 data4; -} OSContPackedRequest; - -typedef union { - OSContPackedRead read; - OSContPackedRequest request; - u32 as_raw[2]; -} OSContPackedStruct; - -#ifdef AVOID_UB -// Fix the OSContPackedStruct array -extern OSContPackedStruct _osContCmdBuf[8]; - -// And fix the last element -#define _osContPifCtrl _osContCmdBuf[7].as_raw[1] -#else -// Original OSContPackedStruct definitions -extern OSContPackedStruct _osContCmdBuf[7]; -extern u32 _osContPifCtrl; -#endif - -#endif diff --git a/lib/src/osContStartReadData.c b/lib/src/osContStartReadData.c deleted file mode 100644 index 4362223a0..000000000 --- a/lib/src/osContStartReadData.c +++ /dev/null @@ -1,73 +0,0 @@ -#include "libultra_internal.h" -#include "osContInternal.h" -#include - -#ifndef AVOID_UB -ALIGNED8 OSContPackedStruct _osContCmdBuf[7]; -UNUSED static u32 unused; // padding between these two variables -u32 _osContPifCtrl; -#else -// Reordered gcc vars above will disturb the aliasing done to access all 8 members of this array, hence AVOID_UB. -ALIGNED8 OSContPackedStruct _osContCmdBuf[8]; -#endif - -extern u8 _osLastSentSiCmd; -extern u8 _osContNumControllers; - -void __osPackReadData(void); -s32 osContStartReadData(OSMesgQueue *mesg) { - s32 ret = 0; - s32 i; - __osSiGetAccess(); - if (_osLastSentSiCmd != 1) { - __osPackReadData(); - ret = __osSiRawStartDma(OS_WRITE, _osContCmdBuf); - osRecvMesg(mesg, NULL, OS_MESG_BLOCK); - } - for (i = 0; i < 0x10; i++) { - *((u32 *) &_osContCmdBuf + i) = 255; - } - - _osContPifCtrl = 0; - ret = __osSiRawStartDma(OS_READ, _osContCmdBuf); - _osLastSentSiCmd = 1; - __osSiRelAccess(); - return ret; -} -void osContGetReadData(OSContPad *pad) { - OSContPackedRead *cmdBufPtr; - OSContPackedRead response; - s32 i; - cmdBufPtr = &_osContCmdBuf[0].read; - for (i = 0; i < _osContNumControllers; i++, cmdBufPtr++, pad++) { - response = *cmdBufPtr; - pad->errnum = (response.rxLen & 0xc0) >> 4; - if (pad->errnum == 0) { - pad->button = response.button; - pad->stick_x = response.rawStickX; - pad->stick_y = response.rawStickY; - } - }; -} -void __osPackReadData() { - OSContPackedRead *cmdBufPtr; - OSContPackedRead request; - s32 i; - cmdBufPtr = &_osContCmdBuf[0].read; - for (i = 0; i < 0x10; i++) { - *((u32 *) &_osContCmdBuf + i) = 0; - } - - _osContPifCtrl = 1; - request.padOrEnd = 255; - request.txLen = 1; - request.rxLen = 4; - request.command = 1; - request.button = 65535; - request.rawStickX = -1; - request.rawStickY = -1; - for (i = 0; i < _osContNumControllers; i++) { - *cmdBufPtr++ = request; - } - cmdBufPtr->padOrEnd = 254; -} diff --git a/lib/src/osCreateMesgQueue.c b/lib/src/osCreateMesgQueue.c deleted file mode 100644 index 727c0af73..000000000 --- a/lib/src/osCreateMesgQueue.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" - -void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count) { - mq->mtqueue = (OSThread *) &D_80334890; //? - mq->fullqueue = (OSThread *) &D_80334890; - mq->validCount = 0; - mq->first = 0; - mq->msgCount = count; - mq->msg = msgBuf; - return; -} diff --git a/lib/src/osCreatePiManager.c b/lib/src/osCreatePiManager.c deleted file mode 100644 index 7e182b748..000000000 --- a/lib/src/osCreatePiManager.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "libultra_internal.h" - -#define OS_PI_MGR_MESG_BUFF_SIZE 1 - -#ifdef VERSION_SH // TODO: In libreultra this is in an include -extern OSPiHandle *CartRomHandle; -extern OSPiHandle *LeoDiskHandle; -#endif - -OSMgrArgs __osPiDevMgr = { 0 }; -#if defined(VERSION_EU) || defined(VERSION_SH) -OSPiHandle *__osPiTable = NULL; -#endif -#ifdef VERSION_SH -OSPiHandle *__osCurrentHandle[2] = { &CartRomHandle, &LeoDiskHandle }; -#endif -OSThread piMgrThread; -u32 piMgrStack[0x400]; // stack bottom -OSMesgQueue __osPiMesgQueue; -OSMesg piMgrMesgBuff[OS_PI_MGR_MESG_BUFF_SIZE + 1]; - -extern u32 gOsPiAccessQueueCreated; -extern OSMesgQueue gOsPiMessageQueue; -void __osDevMgrMain(void *); - -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt) { - u32 int_disabled; - OSPri newPri; - OSPri currentPri; - - if (!__osPiDevMgr.initialized) { - osCreateMesgQueue(cmdQ, cmdBuf, cmdMsgCnt); - osCreateMesgQueue(&__osPiMesgQueue, &piMgrMesgBuff[0], OS_PI_MGR_MESG_BUFF_SIZE); - if (!gOsPiAccessQueueCreated) { - __osPiCreateAccessQueue(); - } // what is this constant geez - osSetEventMesg(OS_EVENT_PI, &__osPiMesgQueue, (void *) 0x22222222); - newPri = -1; - currentPri = osGetThreadPri(NULL); - if (currentPri < pri) { - newPri = currentPri; - osSetThreadPri(NULL, pri); - } - int_disabled = __osDisableInt(); - __osPiDevMgr.initialized = TRUE; - __osPiDevMgr.mgrThread = &piMgrThread; - __osPiDevMgr.cmdQueue = cmdQ; - __osPiDevMgr.eventQueue = &__osPiMesgQueue; - __osPiDevMgr.accessQueue = &gOsPiMessageQueue; - __osPiDevMgr.dma_func = osPiRawStartDma; -#if defined(VERSION_EU) || defined(VERSION_SH) - __osPiDevMgr.edma_func = osEPiRawStartDma; -#endif - osCreateThread(&piMgrThread, 0, __osDevMgrMain, (void *) &__osPiDevMgr, &piMgrStack[0x400], pri); - osStartThread(&piMgrThread); - __osRestoreInt(int_disabled); - if (newPri != -1) { - osSetThreadPri(NULL, newPri); - } - } -} diff --git a/lib/src/osCreateThread.c b/lib/src/osCreateThread.c deleted file mode 100644 index b4e283f27..000000000 --- a/lib/src/osCreateThread.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "libultra_internal.h" - -void __osCleanupThread(void); - -// Don't warn about pointer->u64 cast -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - -void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri pri) { - register u32 int_disabled; - u32 tmp; - thread->id = id; - thread->priority = pri; - thread->next = NULL; - thread->queue = NULL; - thread->context.pc = (u32) entry; - thread->context.a0 = (u64) arg; - thread->context.sp = (u64) sp - 16; - thread->context.ra = (u64) __osCleanupThread; - tmp = OS_IM_ALL; - thread->context.sr = 65283; - thread->context.rcp = (tmp & 0x3f0000) >> 16; - thread->context.fpcsr = (u32) 0x01000800; - thread->fp = 0; - thread->state = OS_STATE_STOPPED; - thread->flags = 0; - int_disabled = __osDisableInt(); - thread->tlnext = D_8033489C; - - D_8033489C = thread; - __osRestoreInt(int_disabled); -} - -#pragma GCC diagnostic pop diff --git a/lib/src/osCreateViManager.c b/lib/src/osCreateViManager.c deleted file mode 100644 index 7c9718262..000000000 --- a/lib/src/osCreateViManager.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "libultra_internal.h" - -#define OS_VI_MANAGER_MESSAGE_BUFF_SIZE 5 - -OSMgrArgs viMgrMainArgs = { 0 }; -static OSThread viMgrThread; -static u32 viMgrStack[0x400]; // stack bottom -static OSMesgQueue __osViMesgQueue; -static OSMesg viMgrMesgBuff[OS_VI_MANAGER_MESSAGE_BUFF_SIZE]; - -static OSIoMesg viEventViMesg; -static OSIoMesg viEventCounterMesg; - -extern void __osTimerServicesInit(void); -extern void __osTimerInterrupt(void); -extern OSTime _osCurrentTime; -extern u32 D_80365DA8; -extern u32 __osViIntrCount; -void viMgrMain(void *); - -void osCreateViManager(OSPri pri) { - u32 int_disabled; - OSPri newPri; - OSPri currentPri; - if (!viMgrMainArgs.initialized) { - __osTimerServicesInit(); - osCreateMesgQueue(&__osViMesgQueue, &viMgrMesgBuff[0], OS_VI_MANAGER_MESSAGE_BUFF_SIZE); - viEventViMesg.hdr.type = 13; - viEventViMesg.hdr.pri = 0; - viEventViMesg.hdr.retQueue = 0; - viEventCounterMesg.hdr.type = 14; - viEventCounterMesg.hdr.pri = 0; - viEventCounterMesg.hdr.retQueue = 0; - osSetEventMesg(OS_EVENT_VI, &__osViMesgQueue, &viEventViMesg); - osSetEventMesg(OS_EVENT_COUNTER, &__osViMesgQueue, &viEventCounterMesg); - newPri = -1; - currentPri = osGetThreadPri(NULL); - if (currentPri < pri) { - newPri = currentPri; - osSetThreadPri(NULL, pri); - } - int_disabled = __osDisableInt(); - viMgrMainArgs.initialized = TRUE; - viMgrMainArgs.mgrThread = &viMgrThread; - viMgrMainArgs.cmdQueue = &__osViMesgQueue; - viMgrMainArgs.eventQueue = &__osViMesgQueue; - viMgrMainArgs.accessQueue = NULL; - viMgrMainArgs.dma_func = NULL; -#if defined(VERSION_EU) || defined(VERSION_SH) - viMgrMainArgs.edma_func = NULL; -#endif - - osCreateThread(&viMgrThread, 0, viMgrMain, (void *) &viMgrMainArgs, &viMgrStack[0x400], pri); - __osViInit(); - osStartThread(&viMgrThread); - __osRestoreInt(int_disabled); - if (newPri != -1) { - osSetThreadPri(NULL, newPri); - } - } -} - -void viMgrMain(void *vargs) { - static u16 retrace; - OSViContext *context; - OSMgrArgs *args; - OSMesg mesg; - u32 sp28; // always 0 - u32 sp24; // time related - mesg = NULL; - sp28 = FALSE; - context = __osViGetCurrentContext(); - - if ((retrace = context->retraceCount) == 0) { - retrace = 1; - } - - args = (OSMgrArgs *) vargs; - - while (TRUE) { - osRecvMesg(args->eventQueue, &mesg, OS_MESG_BLOCK); - switch (*(u16 *) mesg) { - case 13: - __osViSwapContext(); - if (!--retrace) { - context = __osViGetCurrentContext(); - if (context->mq != NULL) { - osSendMesg(context->mq, context->msg, OS_MESG_NOBLOCK); - } - retrace = context->retraceCount; - } - __osViIntrCount++; - if (sp28) { - sp24 = osGetCount(); - _osCurrentTime = sp24; - sp28 = 0; - } - sp24 = D_80365DA8; - D_80365DA8 = osGetCount(); - sp24 = D_80365DA8 - sp24; - _osCurrentTime = _osCurrentTime + sp24; - break; - - case 14: - __osTimerInterrupt(); - break; - } - } -} diff --git a/lib/src/osDestroyThread.c b/lib/src/osDestroyThread.c deleted file mode 100644 index 215ce0737..000000000 --- a/lib/src/osDestroyThread.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "libultra_internal.h" - -void osDestroyThread(OSThread *thread) { - register s32 int_disabled; - register OSThread *s1; - register OSThread *s2; - - int_disabled = __osDisableInt(); - - if (thread == NULL) { - thread = D_803348A0; - } else if (thread->state != OS_STATE_STOPPED) { - __osDequeueThread(thread->queue, thread); - } - - if (D_8033489C == thread) { - D_8033489C = D_8033489C->tlnext; - } else { - s1 = D_8033489C; - s2 = s1->tlnext; - while (s2 != NULL) { - if (s2 == thread) { - s1->tlnext = thread->tlnext; - break; - } else { - s1 = s2; - s2 = s1->tlnext; - } - } - } - - if (thread == D_803348A0) { - __osDispatchThread(); - } - - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osDriveRomInit.c b/lib/src/osDriveRomInit.c deleted file mode 100644 index 930e5613e..000000000 --- a/lib/src/osDriveRomInit.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "libultra_internal.h" -#include "PR/os_pi.h" -#include "PR/rcp.h" -#include "bstring.h" -#include - -extern OSPiHandle *__osPiTable; -extern OSPiHandle DriveRomHandle; - -OSPiHandle *osDriveRomInit() { // Why is this compiled with -g??? - UNUSED s32 sp1c = 0; - u32 saveMask; - - DriveRomHandle.type = DEVICE_TYPE_BULK; - DriveRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR1); - DriveRomHandle.latency = 64; - DriveRomHandle.pulse = 7; - DriveRomHandle.pageSize = 7; - DriveRomHandle.relDuration = 2; - - IO_WRITE(PI_BSD_DOM1_LAT_REG, DriveRomHandle.latency); - IO_WRITE(PI_BSD_DOM1_PWD_REG, DriveRomHandle.pulse); - IO_WRITE(PI_BSD_DOM1_PGS_REG, DriveRomHandle.pageSize); - IO_WRITE(PI_BSD_DOM1_RLS_REG, DriveRomHandle.relDuration); - - bzero(&DriveRomHandle.transferInfo, sizeof(__OSTranxInfo)); - - saveMask = __osDisableInt(); - DriveRomHandle.next = __osPiTable; - __osPiTable = &DriveRomHandle; - __osRestoreInt(saveMask); - - return &DriveRomHandle; -} - diff --git a/lib/src/osEPiRawStartDma.c b/lib/src/osEPiRawStartDma.c deleted file mode 100644 index 0ca8aef96..000000000 --- a/lib/src/osEPiRawStartDma.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" -#include "new_func.h" -#include "PR/R4300.h" -// TODO: This define is from piint.h, but including that causes problems... -#define UPDATE_REG(reg, var) \ - if (cHandle->var != pihandle->var) \ - IO_WRITE(reg, pihandle->var); -// TODO: This define is from os.h, but including that causes problems... -#define PI_DOMAIN1 0 -// TODO: These defines are from PR/rcp.h, but including that causes problems... -#define IO_WRITE(addr, data) (*(vu32 *) PHYS_TO_K1(addr) = (u32)(data)) - -#ifdef VERSION_SH -extern OSPiHandle *__osCurrentHandle[2]; -#endif - -s32 osEPiRawStartDma(OSPiHandle *pihandle, s32 dir, u32 cart_addr, void *dram_addr, u32 size) { -#ifdef VERSION_SH - u32 status; - u32 domain; -#else - register int status; -#endif - - status = HW_REG(PI_STATUS_REG, u32); - while (status & PI_STATUS_ERROR) - status = HW_REG(PI_STATUS_REG, u32); -#ifdef VERSION_SH // TODO: This is the EPI_SYNC macro - domain = pihandle->domain; - if (__osCurrentHandle[domain] != pihandle) { - OSPiHandle *cHandle = __osCurrentHandle[domain]; - if (domain == PI_DOMAIN1) { - UPDATE_REG(PI_BSD_DOM1_LAT_REG, latency); - UPDATE_REG(PI_BSD_DOM1_PGS_REG, pageSize); - UPDATE_REG(PI_BSD_DOM1_RLS_REG, relDuration); - UPDATE_REG(PI_BSD_DOM1_PWD_REG, pulse); - } else { - UPDATE_REG(PI_BSD_DOM2_LAT_REG, latency); - UPDATE_REG(PI_BSD_DOM2_PGS_REG, pageSize); - UPDATE_REG(PI_BSD_DOM2_RLS_REG, relDuration); - UPDATE_REG(PI_BSD_DOM2_PWD_REG, pulse); - } - __osCurrentHandle[domain] = pihandle; - } -#endif - HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr); - HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) pihandle->baseAddress | cart_addr) & 0x1fffffff); - - switch (dir) { - case OS_READ: - HW_REG(PI_WR_LEN_REG, u32) = size - 1; - break; - case OS_WRITE: - HW_REG(PI_RD_LEN_REG, u32) = size - 1; - break; - default: - return -1; - } - return 0; -} diff --git a/lib/src/osEepromLongRead.c b/lib/src/osEepromLongRead.c deleted file mode 100644 index b9884abf7..000000000 --- a/lib/src/osEepromLongRead.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "libultra_internal.h" - -extern u64 osClockRate; -extern u8 D_80365D20; -extern u8 _osContNumControllers; -extern OSTimer D_80365D28; // not sure what this is yet -extern OSMesgQueue _osContMesgQueue; -extern OSMesg _osContMesgBuff[4]; - -s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { - s32 status = 0; - if (address > 0x40) { - return -1; - } - - while (nbytes > 0) { - status = osEepromRead(mq, address, buffer); - if (status != 0) { - return status; - } - - nbytes -= 8; - address += 1; - buffer += 8; - osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); - osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); - } - - return status; -} diff --git a/lib/src/osEepromLongWrite.c b/lib/src/osEepromLongWrite.c deleted file mode 100644 index ef09fa92b..000000000 --- a/lib/src/osEepromLongWrite.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "libultra_internal.h" - -extern u64 osClockRate; -extern u8 D_80365D20; -extern u8 _osContNumControllers; -extern OSTimer D_80365D28; -extern OSMesgQueue _osContMesgQueue; -extern OSMesg _osContMesgBuff[4]; -// exactly the same as osEepromLongRead except for osEepromWrite call - -s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { - s32 result = 0; - if (address > 0x40) { - return -1; - } - - while (nbytes > 0) { - result = osEepromWrite(mq, address, buffer); - if (result != 0) { - return result; - } - - nbytes -= 8; - address += 1; - buffer += 8; - osSetTimer(&D_80365D28, 12000 * osClockRate / 1000000, 0, &_osContMesgQueue, _osContMesgBuff); - osRecvMesg(&_osContMesgQueue, NULL, OS_MESG_BLOCK); - } - - return result; -} diff --git a/lib/src/osEepromProbe.c b/lib/src/osEepromProbe.c deleted file mode 100644 index d550b8464..000000000 --- a/lib/src/osEepromProbe.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "libultra_internal.h" - -// TODO: merge with osEepromWrite -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; - -s32 __osEepStatus(OSMesgQueue *, unkStruct *); -s32 osEepromProbe(OSMesgQueue *mq) { - s32 status = 0; - unkStruct sp18; - - __osSiGetAccess(); - status = __osEepStatus(mq, &sp18); - if (status == 0 && (sp18.unk00 & 0x8000) != 0) { - status = 1; - } else { - status = 0; - } - __osSiRelAccess(); - return status; -} diff --git a/lib/src/osEepromRead.c b/lib/src/osEepromRead.c deleted file mode 100644 index ea784b2cc..000000000 --- a/lib/src/osEepromRead.c +++ /dev/null @@ -1,99 +0,0 @@ -#include "libultra_internal.h" - -extern u8 _osLastSentSiCmd; - -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; -typedef struct { - u8 unk00; - u8 unk01; - u8 unk02; - u8 unk03; - u8 unk04; - u8 unk05; - u8 unk06; - u8 unk07; -} unkStruct3; - -typedef struct { - u8 unk00; - u8 unk01; - u8 unk02; - u8 unk03; - unkStruct3 unk04; -} unkStruct2; - -s32 __osEepStatus(OSMesgQueue *, unkStruct *); -s32 __osPackEepReadData(u8); - -s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer) { - s32 sp34; - s32 sp30; - u8 *sp2c; - unkStruct sp28; - unkStruct2 sp20; - sp34 = 0; - sp30 = 0; - sp2c = (u8 *) &D_80365E00; - if (address > 0x40) { - return -1; - } - __osSiGetAccess(); - sp34 = __osEepStatus(mq, &sp28); - if (sp34 != 0 || sp28.unk00 != 0x8000) { - - return 8; - } - while (sp28.unk02 & 0x80) { - __osEepStatus(mq, &sp28); - } - __osPackEepReadData(address); - sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 0x10; sp30++) { - (D_80365E00)[sp30] = 255; - } - D_80365E3C = 0; - sp34 = __osSiRawStartDma(OS_READ, D_80365E00); - _osLastSentSiCmd = 4; - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - for (sp30 = 0; sp30 < 4; sp30++) { - sp2c++; - } - sp20 = *(unkStruct2 *) sp2c; - sp34 = (sp20.unk01 & 0xc0) >> 4; - if (sp34 == 0) { - for (sp30 = 0; sp30 < 8; sp30++) { - *buffer++ = ((u8 *) &sp20.unk04)[sp30]; - } - } - __osSiRelAccess(); - return sp34; -} - -s32 __osPackEepReadData(u8 address) { - u8 *sp14; - unkStruct2 sp8; - s32 sp4; - sp14 = (u8 *) &D_80365E00; - for (sp4 = 0; sp4 < 0x10; sp4++) { - D_80365E00[sp4] = 255; - } - D_80365E3C = 1; - sp8.unk00 = 2; - sp8.unk01 = 8; - sp8.unk02 = 4; - sp8.unk03 = address; - for (sp4 = 0; sp4 < 8; sp4++) { - ((u8 *) &sp8.unk04)[sp4] = 0; - } - for (sp4 = 0; sp4 < 4; sp4++) { - *sp14++ = 0; - } - *(unkStruct2 *) sp14 = sp8; - sp14 += 0xc; - *sp14 = 254; -} diff --git a/lib/src/osEepromWrite.c b/lib/src/osEepromWrite.c deleted file mode 100644 index 1a86477be..000000000 --- a/lib/src/osEepromWrite.c +++ /dev/null @@ -1,167 +0,0 @@ -#include "libultra_internal.h" -#include "osContInternal.h" - -#ifndef AVOID_UB -ALIGNED8 u32 D_80365E00[15]; -u32 D_80365E3C; -#else -// Certain code accesses the 16th element (D_80365E3C) in this array, making a seperate -// definition UB when gcc rearranges those. -ALIGNED8 u32 D_80365E00[16]; -#endif -extern u8 _osLastSentSiCmd; - -typedef struct { - u16 unk00; - u8 unk02; - u8 unk03; -} unkStruct; -typedef struct { - u8 unk00; - u8 unk01; - u8 unk02; - u8 unk03; - u8 unk04; - u8 unk05; - u8 unk06; - u8 unk07; -} unkStruct3; - -typedef struct { - u8 unk00; - u8 unk01; - u8 unk02; - u8 unk03; - unkStruct3 unk04; -} unkStruct2; - -s32 __osEepStatus(OSMesgQueue *, unkStruct *); -s32 __osPackEepWriteData(u8, u8 *); - -s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer) { - s32 sp34; - s32 sp30; - u8 *sp2c; - unkStruct2 sp20; - unkStruct sp1c; - sp34 = 0; - sp2c = (u8 *) &D_80365E00; - - if (address > 0x40) { - return -1; - } - - __osSiGetAccess(); - sp34 = __osEepStatus(mq, &sp1c); - - if (sp34 != 0 || sp1c.unk00 != 0x8000) { - return 8; - } - - while (sp1c.unk02 & 0x80) { - __osEepStatus(mq, &sp1c); - } - - __osPackEepWriteData(address, buffer); - - sp34 = __osSiRawStartDma(OS_WRITE, &D_80365E00); - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - - for (sp30 = 0; sp30 < 0x10; sp30++) { - (D_80365E00)[sp30] = 255; - } - - D_80365E3C = 0; - sp34 = __osSiRawStartDma(OS_READ, D_80365E00); - _osLastSentSiCmd = 5; - osRecvMesg(mq, NULL, OS_MESG_BLOCK); - - for (sp30 = 0; sp30 < 4; sp30++) { - sp2c++; - } - - sp20 = *(unkStruct2 *) sp2c; - sp34 = (sp20.unk01 & 0xc0) >> 4; - __osSiRelAccess(); - return sp34; -} - -s32 __osPackEepWriteData(u8 address, u8 *buffer) { - u8 *sp14; - unkStruct2 sp8; - s32 sp4; - sp14 = (u8 *) &D_80365E00; - for (sp4 = 0; sp4 < 0x10; sp4++) { - D_80365E00[sp4] = 255; - } - D_80365E3C = 1; - sp8.unk00 = 10; - sp8.unk01 = 1; - sp8.unk02 = 5; - sp8.unk03 = address; - for (sp4 = 0; sp4 < 8; sp4++) { - ((u8 *) &sp8.unk04)[sp4] = *buffer++; - } - for (sp4 = 0; sp4 < 4; sp4++) { - *sp14++ = 0; - } - *(unkStruct2 *) sp14 = sp8; - sp14 += 0xc; - *sp14 = 254; -} - -s32 __osEepStatus(OSMesgQueue *a0, unkStruct *a1) { - u32 sp2c = 0; - s32 sp28; - u8 *sp24 = (u8 *) D_80365E00; - unkStruct3 sp1c; - - for (sp28 = 0; sp28 < 0x10; sp28++) { - D_80365E00[sp28] = 0; - } - - D_80365E3C = 1; - sp24 = (u8 *) D_80365E00; - for (sp28 = 0; sp28 < 4; sp28++) { - *sp24++ = 0; - } - - sp1c.unk00 = 255; - sp1c.unk01 = 1; - sp1c.unk02 = 3; - sp1c.unk03 = 0; - sp1c.unk04 = 255; - sp1c.unk05 = 255; - sp1c.unk06 = 255; - sp1c.unk07 = 255; - *(unkStruct3 *) sp24 = sp1c; - - sp24 += 8; - sp24[0] = 254; - - sp2c = __osSiRawStartDma(OS_WRITE, D_80365E00); - osRecvMesg(a0, NULL, OS_MESG_BLOCK); - - _osLastSentSiCmd = 5; - - sp2c = __osSiRawStartDma(OS_READ, D_80365E00); - osRecvMesg(a0, NULL, OS_MESG_BLOCK); - - if (sp2c != 0) { - return sp2c; - } - - sp24 = (u8 *) D_80365E00; - for (sp28 = 0; sp28 < 4; sp28++) { - *sp24++ = 0; - } - - sp1c = *(unkStruct3 *) sp24; - a1->unk03 = (sp1c.unk02 & 0xc0) >> 4; - a1->unk00 = (sp1c.unk05 << 8) | sp1c.unk04; - a1->unk02 = sp1c.unk06; - if (a1->unk03 != 0) { - return a1->unk03; - } - return 0; -} diff --git a/lib/src/osGetThreadPri.c b/lib/src/osGetThreadPri.c deleted file mode 100644 index 7b5b58c4f..000000000 --- a/lib/src/osGetThreadPri.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "libultra_internal.h" - -OSPri osGetThreadPri(OSThread *thread) { - if (thread == NULL) { - thread = D_803348A0; - } - return thread->priority; -} diff --git a/lib/src/osGetTime.c b/lib/src/osGetTime.c deleted file mode 100644 index 93dc8cbe0..000000000 --- a/lib/src/osGetTime.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libultra_internal.h" - -extern OSTime _osCurrentTime; -extern u32 D_80365DA8; - -OSTime osGetTime() { - u32 sp34; - u32 sp30; - OSTime sp28; - register u32 int_disabled; - int_disabled = __osDisableInt(); - sp34 = osGetCount(); - sp30 = sp34 - D_80365DA8; - sp28 = _osCurrentTime; - __osRestoreInt(int_disabled); - return sp28 + sp30; -} diff --git a/lib/src/osInitialize.c b/lib/src/osInitialize.c deleted file mode 100644 index ba73024b5..000000000 --- a/lib/src/osInitialize.c +++ /dev/null @@ -1,101 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" -#include - -#define PIF_ADDR_START (void *) 0x1FC007FC - -typedef struct { - u32 instr00; - u32 instr01; - u32 instr02; - u32 instr03; -} exceptionPreamble; - -#if defined(VERSION_EU) || defined(VERSION_SH) -extern u32 EU_D_802f4330(u32, void (*)); -extern void D_802F4380(); - -#endif -u32 D_80365CD0; // maybe initialized? -u64 osClockRate = 62500000; - -#ifdef VERSION_SH -u32 osViClock = 0x02E6D354; -#endif - -u32 D_80334808 = 0; // used in __osException - -#if defined(VERSION_EU) || defined(VERSION_SH) -u32 EU_D_80336C40; -u32 EU_D_80336C44; - -u32 __OSGlobalIntMask = OS_IM_ALL; -u32 EU_D_80302090 = 0; -u8 EU_unusedZeroes[8] = { 0 }; -#endif - -#define EXCEPTION_TLB_MISS 0x80000000 -#define EXCEPTION_XTLB_MISS 0x80000080 -#define EXCEPTION_CACHE_ERROR 0x80000100 -#define EXCEPTION_GENERAL 0x80000180 - -extern u32 osResetType; -extern exceptionPreamble __osExceptionPreamble; - -void osInitialize(void) { - u32 sp34; - u32 sp30 = 0; - -#if defined(VERSION_EU) - UNUSED u32 eu_sp34; - UNUSED u32 eu_sp30; -#endif - UNUSED u32 sp2c; - D_80365CD0 = TRUE; - __osSetSR(__osGetSR() | 0x20000000); - __osSetFpcCsr(0x01000800); - while (__osSiRawReadIo(PIF_ADDR_START, &sp34)) { - ; - } - while (__osSiRawWriteIo(PIF_ADDR_START, sp34 | 8)) { - ; - } - *(exceptionPreamble *) EXCEPTION_TLB_MISS = __osExceptionPreamble; - *(exceptionPreamble *) EXCEPTION_XTLB_MISS = __osExceptionPreamble; - *(exceptionPreamble *) EXCEPTION_CACHE_ERROR = __osExceptionPreamble; - *(exceptionPreamble *) EXCEPTION_GENERAL = __osExceptionPreamble; - osWritebackDCache((void *) 0x80000000, - EXCEPTION_GENERAL + sizeof(exceptionPreamble) - EXCEPTION_TLB_MISS); - osInvalICache((void *) 0x80000000, - EXCEPTION_GENERAL + sizeof(exceptionPreamble) - EXCEPTION_TLB_MISS); - osMapTLBRdb(); - osPiRawReadIo(4, &sp30); - sp30 &= ~0xf; - if (sp30) { - osClockRate = sp30; - } - osClockRate = osClockRate * 3 / 4; - if (osResetType == RESET_TYPE_COLD_RESET) { - bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer)); - } -#if defined(VERSION_SH) - if (osTvType == TV_TYPE_PAL) { - osViClock = 0x02F5B2D2; - } else if (osTvType == TV_TYPE_MPAL) { - osViClock = 0x02E6025C; - } else { - osViClock = 0x02E6D354; - } -#elif defined(VERSION_EU) - eu_sp30 = HW_REG(PI_STATUS_REG, u32); - while (eu_sp30 & PI_STATUS_ERROR) { - eu_sp30 = HW_REG(PI_STATUS_REG, u32); - }; - if (!((eu_sp34 = HW_REG(ASIC_STATUS, u32)) & _64DD_PRESENT_MASK)) { - EU_D_80302090 = 1; - EU_D_802f4330(1, D_802F4380); - } else { - EU_D_80302090 = 0; - } -#endif -} diff --git a/lib/src/osJamMesg.c b/lib/src/osJamMesg.c deleted file mode 100644 index 725131355..000000000 --- a/lib/src/osJamMesg.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "libultra_internal.h" - -s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { - register s32 int_disabled; - int_disabled = __osDisableInt(); - while (mq->validCount >= mq->msgCount) { - if (flag == OS_MESG_BLOCK) { - D_803348A0->state = OS_STATE_WAITING; - __osEnqueueAndYield(&mq->fullqueue); - } else { - __osRestoreInt(int_disabled); - return -1; - } - } - - mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount; - mq->msg[mq->first] = msg; - mq->validCount++; - if (mq->mtqueue->next != NULL) { - osStartThread(__osPopThread(&mq->mtqueue)); - } - __osRestoreInt(int_disabled); - return 0; -} diff --git a/lib/src/osLeoDiskInit.c b/lib/src/osLeoDiskInit.c deleted file mode 100644 index 0507de6a4..000000000 --- a/lib/src/osLeoDiskInit.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -// this file must include some globally referenced data because it is not called anywhere -// data, comes shortly before _Ldtob I think, before crash_screen - -extern OSPiHandle *__osPiTable; -// bss -OSPiHandle LeoDiskHandle; -OSPiHandle *__osDiskHandle; - -// some kind of piHandle init function, maybe osDriveRomInit or osCartRomInit -OSPiHandle *osLeoDiskInit(void) { - s32 sp1c; - LeoDiskHandle.type = 2; - LeoDiskHandle.baseAddress = (0xa0000000 | 0x05000000); - LeoDiskHandle.latency = 3; - LeoDiskHandle.pulse = 6; - LeoDiskHandle.pageSize = 6; - LeoDiskHandle.relDuration = 2; -#ifdef VERSION_SH - LeoDiskHandle.domain = 1; -#endif - HW_REG(PI_BSD_DOM2_LAT_REG, u32) = LeoDiskHandle.latency; - HW_REG(PI_BSD_DOM2_PWD_REG, u32) = LeoDiskHandle.pulse; - HW_REG(PI_BSD_DOM2_PGS_REG, u32) = LeoDiskHandle.pageSize; - HW_REG(PI_BSD_DOM2_RLS_REG, u32) = LeoDiskHandle.relDuration; - bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo)); - sp1c = __osDisableInt(); - LeoDiskHandle.next = __osPiTable; - __osPiTable = &LeoDiskHandle; - __osDiskHandle = &LeoDiskHandle; - __osRestoreInt(sp1c); - return &LeoDiskHandle; -} diff --git a/lib/src/osPfsIsPlug.c b/lib/src/osPfsIsPlug.c deleted file mode 100644 index 9611c977d..000000000 --- a/lib/src/osPfsIsPlug.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "PR/os_pi.h" -#include "controller.h" -//#include "siint.h" - -#ifdef VERSION_SH -OSPifRam __osPfsPifRam; - -s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) { - s32 ret; - OSMesg dummy; - u8 bitpattern; - OSContStatus data[MAXCONTROLLERS]; - int channel; - u8 bits; - int crc_error_cnt; - ret = 0; - bits = 0; - crc_error_cnt = 3; - __osSiGetAccess(); - while (TRUE) { - __osPfsRequestData(CONT_CMD_REQUEST_STATUS); - ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); - osRecvMesg(queue, &dummy, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(queue, &dummy, OS_MESG_BLOCK); - __osPfsGetInitData(&bitpattern, data); - for (channel = 0; channel < _osContNumControllers; channel++) { - if ((data[channel].status & CONT_ADDR_CRC_ER) == 0) { - crc_error_cnt--; - break; - } - } - if (_osContNumControllers == channel) { - crc_error_cnt = 0; - } - if (crc_error_cnt < 1) { - for (channel = 0; channel < _osContNumControllers; channel++) { - if (data[channel].errnum == 0 && (data[channel].status & CONT_CARD_ON) != 0) { - bits |= 1 << channel; - } - } - __osSiRelAccess(); - *pattern = bits; - return ret; - } - } -} - -void __osPfsRequestData(u8 cmd) { - u8 *ptr; - __OSContRequesFormat requestformat; - int i; - - _osLastSentSiCmd = cmd; - - for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus - __osPfsPifRam.ramarray[i] = 0; - } - - __osPfsPifRam.pifstatus = CONT_CMD_EXE; - - ptr = (u8 *)&__osPfsPifRam; - requestformat.dummy = CONT_CMD_NOP; - requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX; - requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX; - requestformat.cmd = cmd; - requestformat.typeh = CONT_CMD_NOP; - requestformat.typel = CONT_CMD_NOP; - requestformat.status = CONT_CMD_NOP; - requestformat.dummy1 = CONT_CMD_NOP; - for (i = 0; i < _osContNumControllers; i++) { - *(__OSContRequesFormat *)ptr = requestformat; - ptr += sizeof(__OSContRequesFormat); - } - *ptr = CONT_CMD_END; -} - -void __osPfsGetInitData(u8 *pattern, OSContStatus *data) { - u8 *ptr; - __OSContRequesFormat requestformat; - int i; - u8 bits; - bits = 0; - ptr = (u8 *)&__osPfsPifRam; - for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(__OSContRequesFormat)) { - requestformat = *(__OSContRequesFormat *)ptr; - data->errnum = CHNL_ERR(requestformat); - if (data->errnum == 0) { - data->type = (requestformat.typel << 8) | (requestformat.typeh); - data->status = requestformat.status; - bits |= 1 << i; - } - data++; - } - *pattern = bits; -} -#endif diff --git a/lib/src/osPiGetCmdQueue.c b/lib/src/osPiGetCmdQueue.c deleted file mode 100644 index 457abc650..000000000 --- a/lib/src/osPiGetCmdQueue.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "libultra_internal.h" - -extern OSMgrArgs __osPiDevMgr; - -OSMesgQueue *osPiGetCmdQueue(void) { - if (!__osPiDevMgr.initialized) { - return NULL; - } - return __osPiDevMgr.cmdQueue; -} diff --git a/lib/src/osPiRawReadIo.c b/lib/src/osPiRawReadIo.c deleted file mode 100644 index 07270788b..000000000 --- a/lib/src/osPiRawReadIo.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -extern u32 osRomBase; - -s32 osPiRawReadIo(u32 a0, u32 *a1) { - register int status; - status = HW_REG(PI_STATUS_REG, u32); - while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { - status = HW_REG(PI_STATUS_REG, u32); - } - *a1 = HW_REG(osRomBase | a0, u32); - return 0; -} diff --git a/lib/src/osPiRawStartDma.c b/lib/src/osPiRawStartDma.c deleted file mode 100644 index ca6044e6e..000000000 --- a/lib/src/osPiRawStartDma.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" - -extern u32 osRomBase; // TODO: figure out why this is like this - -s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size) { - register int status; - status = HW_REG(PI_STATUS_REG, u32); - while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { - status = HW_REG(PI_STATUS_REG, u32); - } - - HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr); - - HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) osRomBase | cart_addr) & 0x1fffffff); - - switch (dir) { - case 0: - HW_REG(PI_WR_LEN_REG, u32) = size - 1; - break; - case 1: - HW_REG(PI_RD_LEN_REG, u32) = size - 1; - break; - default: - return -1; - break; - } - return 0; -} - -#ifdef VERSION_EU -/*s32 osPiRawStartDma_2(s32 dir, u32 cart_addr, void *dram_addr, size_t size) { - register int status; - status = HW_REG(PI_STATUS_REG, u32); - while (status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY | PI_STATUS_ERROR)) { - status = HW_REG(PI_STATUS_REG, u32); - } - - HW_REG(PI_DRAM_ADDR_REG, void *) = (void *) osVirtualToPhysical(dram_addr); - - HW_REG(PI_CART_ADDR_REG, void *) = (void *) (((uintptr_t) osRomBase | cart_addr) & 0x1fffffff); - - switch (dir) { - case 0: - HW_REG(PI_WR_LEN_REG, u32) = size - 1; - break; - case 1: - HW_REG(PI_RD_LEN_REG, u32) = size - 1; - break; - default: - return -1; - break; - } - return 0; -}*/ -#endif diff --git a/lib/src/osPiStartDma.c b/lib/src/osPiStartDma.c deleted file mode 100644 index f71d9e23c..000000000 --- a/lib/src/osPiStartDma.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "libultra_internal.h" - -extern OSMgrArgs __osPiDevMgr; - -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, - size_t nbytes, OSMesgQueue *mq) { - register s32 result; - register OSMesgQueue *cmdQueue; - if (!__osPiDevMgr.initialized) { - return -1; - } - - // TODO: name magic constants - if (direction == OS_READ) { - mb->hdr.type = 11; - } else { - mb->hdr.type = 12; - } - - mb->hdr.pri = priority; - mb->hdr.retQueue = mq; - mb->dramAddr = vAddr; - mb->devAddr = devAddr; - mb->size = nbytes; -#if defined(VERSION_EU) || defined(VERSION_SH) - mb->piHandle = NULL; -#endif - - if (priority == OS_MESG_PRI_HIGH) { - cmdQueue = osPiGetCmdQueue(); - result = osJamMesg(cmdQueue, mb, OS_MESG_NOBLOCK); - } else { - cmdQueue = osPiGetCmdQueue(); - result = osSendMesg(cmdQueue, mb, OS_MESG_NOBLOCK); - } - return result; -} diff --git a/lib/src/osRecvMesg.c b/lib/src/osRecvMesg.c deleted file mode 100644 index 057ec9f05..000000000 --- a/lib/src/osRecvMesg.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "libultra_internal.h" - -s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag) { - register u32 int_disabled; - register OSThread *thread; - int_disabled = __osDisableInt(); - - while (!mq->validCount) { - if (!flag) { - __osRestoreInt(int_disabled); - return -1; - } - D_803348A0->state = OS_STATE_WAITING; - __osEnqueueAndYield(&mq->mtqueue); - } - - if (msg != NULL) { - *msg = *(mq->first + mq->msg); - } - - mq->first = (mq->first + 1) % mq->msgCount; - mq->validCount--; - - if (mq->fullqueue->next != NULL) { - thread = __osPopThread(&mq->fullqueue); - osStartThread(thread); - } - - __osRestoreInt(int_disabled); - return 0; -} diff --git a/lib/src/osSendMesg.c b/lib/src/osSendMesg.c deleted file mode 100644 index f0d02fff9..000000000 --- a/lib/src/osSendMesg.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "libultra_internal.h" - -s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { - register u32 int_disabled; - register s32 index; - register OSThread *s2; - int_disabled = __osDisableInt(); - - while (mq->validCount >= mq->msgCount) { - if (flag == OS_MESG_BLOCK) { - D_803348A0->state = 8; - __osEnqueueAndYield(&mq->fullqueue); - } else { - __osRestoreInt(int_disabled); - return -1; - } - } - - index = (mq->first + mq->validCount) % mq->msgCount; - mq->msg[index] = msg; - mq->validCount++; - - if (mq->mtqueue->next != NULL) { - s2 = __osPopThread(&mq->mtqueue); - osStartThread(s2); - } - - __osRestoreInt(int_disabled); - return 0; -} diff --git a/lib/src/osSetEventMesg.c b/lib/src/osSetEventMesg.c deleted file mode 100644 index 4610b4b1e..000000000 --- a/lib/src/osSetEventMesg.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "libultra_internal.h" - -typedef struct OSEventMessageStruct_0_s { - OSMesgQueue *queue; - OSMesg msg; -} OSEventMessageStruct_0; - -OSEventMessageStruct_0 __osEventStateTab[16]; - -void osSetEventMesg(OSEvent e, OSMesgQueue *mq, OSMesg msg) { - register u32 int_disabled; - OSEventMessageStruct_0 *msgs; - int_disabled = __osDisableInt(); - msgs = __osEventStateTab + e; - msgs->queue = mq; - msgs->msg = msg; - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osSetThreadPri.c b/lib/src/osSetThreadPri.c deleted file mode 100644 index 1c7825341..000000000 --- a/lib/src/osSetThreadPri.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "libultra_internal.h" - -void osSetThreadPri(OSThread *thread, OSPri pri) { - register u32 int_disabled = __osDisableInt(); - if (thread == NULL) { - thread = D_803348A0; - } - - if (thread->priority != pri) { - thread->priority = pri; - if (thread != D_803348A0) { - if (thread->state != OS_STATE_STOPPED) { - __osDequeueThread(thread->queue, thread); - __osEnqueueThread(thread->queue, thread); - } - } - if (D_803348A0->priority < D_80334898->priority) { - D_803348A0->state = OS_STATE_RUNNABLE; - __osEnqueueAndYield(&D_80334898); - } - } - - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osSetTime.c b/lib/src/osSetTime.c deleted file mode 100644 index ba906b693..000000000 --- a/lib/src/osSetTime.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "libultra_internal.h" - -extern OSTime _osCurrentTime; - -void osSetTime(OSTime time) { - _osCurrentTime = time; -} diff --git a/lib/src/osSetTimer.c b/lib/src/osSetTimer.c deleted file mode 100644 index f7003b673..000000000 --- a/lib/src/osSetTimer.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "libultra_internal.h" - -extern OSTimer *D_80334830; -extern u64 __osInsertTimer(OSTimer *); - -u32 osSetTimer(OSTimer *a0, OSTime a1, u64 a2, OSMesgQueue *a3, OSMesg a4) { - u64 sp18; - a0->next = NULL; - a0->prev = NULL; - a0->interval = a2; - if (a1 != 0) { - a0->remaining = a1; - } else { - a0->remaining = a2; - } - a0->mq = a3; - a0->msg = a4; - sp18 = __osInsertTimer(a0); - if (D_80334830->next == a0) { - __osSetTimerIntr(sp18); - } - return 0; -} diff --git a/lib/src/osSpTaskLoadGo.c b/lib/src/osSpTaskLoadGo.c deleted file mode 100644 index 88392c0bb..000000000 --- a/lib/src/osSpTaskLoadGo.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "libultra_internal.h" -#include "hardware.h" -#include - -#define _osVirtualToPhysical(ptr) \ - if (ptr != NULL) { \ - ptr = (void *) osVirtualToPhysical(ptr); \ - } - -OSTask D_803638B0; -OSTask *_VirtualToPhysicalTask(OSTask *task) { - OSTask *physicalTask; - physicalTask = &D_803638B0; - bcopy(task, physicalTask, sizeof(OSTask)); - _osVirtualToPhysical(physicalTask->t.ucode); - _osVirtualToPhysical(physicalTask->t.ucode_data); - _osVirtualToPhysical(physicalTask->t.dram_stack); - _osVirtualToPhysical(physicalTask->t.output_buff); - _osVirtualToPhysical(physicalTask->t.output_buff_size); - _osVirtualToPhysical(physicalTask->t.data_ptr); - _osVirtualToPhysical(physicalTask->t.yield_data_ptr); - return physicalTask; -} - -void osSpTaskLoad(OSTask *task) { - OSTask *physicalTask; - physicalTask = _VirtualToPhysicalTask(task); - if (physicalTask->t.flags & M_TASK_FLAG0) { - physicalTask->t.ucode_data = physicalTask->t.yield_data_ptr; - physicalTask->t.ucode_data_size = physicalTask->t.yield_data_size; - task->t.flags &= ~M_TASK_FLAG0; -#ifdef VERSION_SH - if (physicalTask->t.flags & M_TASK_FLAG2) { - physicalTask->t.ucode = HW_REG((uintptr_t)task->t.yield_data_ptr + 0xBFC, u64*); - } -#endif - } - osWritebackDCache(physicalTask, sizeof(OSTask)); - __osSpSetStatus(SPSTATUS_CLEAR_SIGNAL0 | SPSTATUS_CLEAR_SIGNAL1 | SPSTATUS_CLEAR_SIGNAL2 - | SPSTATUS_SET_INTR_ON_BREAK); - while (__osSpSetPc((void *) SP_IMEM_START) == -1) { - ; - } - while (__osSpRawStartDma(1, (void *) (SP_IMEM_START - sizeof(*physicalTask)), physicalTask, - sizeof(OSTask)) - == -1) { - ; - } - while (__osSpDeviceBusy()) { - ; - } - while (__osSpRawStartDma(1, (void *) SP_IMEM_START, physicalTask->t.ucode_boot, - physicalTask->t.ucode_boot_size) - == -1) { - ; - } -} - -void osSpTaskStartGo(UNUSED OSTask *task) { - while (__osSpDeviceBusy()) { - ; - } - __osSpSetStatus(SPSTATUS_SET_INTR_ON_BREAK | SPSTATUS_CLEAR_SSTEP | SPSTATUS_CLEAR_BROKE - | SPSTATUS_CLEAR_HALT); -} diff --git a/lib/src/osSpTaskYield.c b/lib/src/osSpTaskYield.c deleted file mode 100644 index 92546a8fe..000000000 --- a/lib/src/osSpTaskYield.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "libultra_internal.h" - -void osSpTaskYield(void) { - __osSpSetStatus(SPSTATUS_SET_SIGNAL0); -} diff --git a/lib/src/osSpTaskYielded.c b/lib/src/osSpTaskYielded.c deleted file mode 100644 index fa0dcbc2e..000000000 --- a/lib/src/osSpTaskYielded.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libultra_internal.h" - -OSYieldResult osSpTaskYielded(OSTask *task) { - s32 status; - u32 int_disabledult; - status = __osSpGetStatus(); - if (status & SPSTATUS_SIGNAL1_SET) { - int_disabledult = 1; - } else { - int_disabledult = 0; - } - if (status & SPSTATUS_SIGNAL0_SET) { - task->t.flags |= int_disabledult; - task->t.flags &= ~(M_TASK_FLAG1); - } - return int_disabledult; -} diff --git a/lib/src/osStartThread.c b/lib/src/osStartThread.c deleted file mode 100644 index c241e3885..000000000 --- a/lib/src/osStartThread.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "libultra_internal.h" - -void osStartThread(OSThread *thread) { - register u32 int_disabled; - register uintptr_t state; - int_disabled = __osDisableInt(); - state = thread->state; - - if (state != OS_STATE_STOPPED) { - if (state == OS_STATE_WAITING) { - do { - } while (0); - thread->state = OS_STATE_RUNNABLE; - __osEnqueueThread(&D_80334898, thread); - } - } else { - if (thread->queue == NULL || thread->queue == &D_80334898) { - thread->state = OS_STATE_RUNNABLE; - - __osEnqueueThread(&D_80334898, thread); - } else { - thread->state = OS_STATE_WAITING; - __osEnqueueThread(thread->queue, thread); - state = (uintptr_t) __osPopThread(thread->queue); - __osEnqueueThread(&D_80334898, (OSThread *) state); - } - } - if (D_803348A0 == NULL) { - __osDispatchThread(); - } else { - if (D_803348A0->priority < D_80334898->priority) { - D_803348A0->state = OS_STATE_RUNNABLE; - __osEnqueueAndYield(&D_80334898); - } - } - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osTimer.c b/lib/src/osTimer.c deleted file mode 100644 index ffd0255f4..000000000 --- a/lib/src/osTimer.c +++ /dev/null @@ -1,88 +0,0 @@ -#include "libultra_internal.h" - -// TODO: document -OSTimer D_80365D80; -OSTimer *D_80334830 = &D_80365D80; -OSTime _osCurrentTime; -u32 D_80365DA8; -u32 __osViIntrCount; -u32 D_80365DB0; - -void __osTimerServicesInit(void) { - _osCurrentTime = 0; - D_80365DA8 = 0; - __osViIntrCount = 0; - D_80334830->prev = D_80334830; - D_80334830->next = D_80334830->prev; - D_80334830->remaining = 0; - D_80334830->interval = D_80334830->remaining; - D_80334830->mq = NULL; - D_80334830->msg = NULL; -} - -void __osTimerInterrupt(void) { - OSTimer *sp24; - u32 sp20; - u32 sp1c; - if (D_80334830->next == D_80334830) { - return; - } - while (TRUE) { - sp24 = D_80334830->next; - if (sp24 == D_80334830) { - __osSetCompare(0); - D_80365DB0 = 0; - break; - } - sp20 = osGetCount(); - sp1c = sp20 - D_80365DB0; - D_80365DB0 = sp20; - if (sp1c < sp24->remaining) { - sp24->remaining -= sp1c; - __osSetTimerIntr(sp24->remaining); - return; - } else { - sp24->prev->next = sp24->next; - sp24->next->prev = sp24->prev; - sp24->next = NULL; - sp24->prev = NULL; - if (sp24->mq != NULL) { - osSendMesg(sp24->mq, sp24->msg, OS_MESG_NOBLOCK); - } - if (sp24->interval != 0) { - sp24->remaining = sp24->interval; - __osInsertTimer(sp24); - } - } - } -} - -void __osSetTimerIntr(u64 a0) { - u64 tmp; - s32 intDisabled = __osDisableInt(); - D_80365DB0 = osGetCount(); - tmp = a0 + D_80365DB0; - __osSetCompare(tmp); - __osRestoreInt(intDisabled); -} - -u64 __osInsertTimer(OSTimer *a0) { - OSTimer *sp34; - u64 sp28; - s32 intDisabled; - intDisabled = __osDisableInt(); - for (sp34 = D_80334830->next, sp28 = a0->remaining; sp34 != D_80334830 && sp28 > sp34->remaining; - sp28 -= sp34->remaining, sp34 = sp34->next) { - ; - } - a0->remaining = sp28; - if (sp34 != D_80334830) { - sp34->remaining -= sp28; - } - a0->next = sp34; - a0->prev = sp34->prev; - sp34->prev->next = a0; - sp34->prev = a0; - __osRestoreInt(intDisabled); - return sp28; -} diff --git a/lib/src/osViBlack.c b/lib/src/osViBlack.c deleted file mode 100644 index 277dfedb2..000000000 --- a/lib/src/osViBlack.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViNext; - -// TODO: name magic constants -void osViBlack(u8 active) { - register u32 int_disabled = __osDisableInt(); - if (active) { - __osViNext->unk00 |= 0x20; - } else { - __osViNext->unk00 &= ~0x20; - } - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osViData.c b/lib/src/osViData.c deleted file mode 100644 index 6f3921062..000000000 --- a/lib/src/osViData.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "libultra_internal.h" - -#if defined(VERSION_EU) || defined(VERSION_SH) -OSViMode D_80334990 = { - /*type*/ 16, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, -#ifdef VERSION_EU - /*burst*/ 67380026, -#else - /*burst*/ 72621626, -#endif - /*vSync*/ 625, -#ifdef VERSION_EU - /*hSync*/ 1379433, - /*leap*/ 208604270, -#else - /*hSync*/ 1510505, - /*leap*/ 208604269, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } -}; - -OSViMode D_803349E0 = { - /*type*/ 30, //osViModePalLan1 - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 525, - /*hSync*/ 265233, - /*leap*/ 202968090, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } -}; - -OSViMode D_80302FD0 = { - /*type*/ 2, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } -}; -#else -OSViMode D_80334990 = { - /*type*/ 2, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } -}; - -OSViMode D_803349E0 = { - /*type*/ 16, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 67380026, - /*vSync*/ 625, - /*hSync*/ 1379433, - /*leap*/ 208604270, - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } -}; -#endif diff --git a/lib/src/osViSetEvent.c b/lib/src/osViSetEvent.c deleted file mode 100644 index 6969ec8f5..000000000 --- a/lib/src/osViSetEvent.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViNext; - -void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount) { - register u32 int_disabled = __osDisableInt(); - (__osViNext)->mq = mq; - (__osViNext)->msg = msg; - (__osViNext)->retraceCount = retraceCount; - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osViSetMode.c b/lib/src/osViSetMode.c deleted file mode 100644 index 716596fb5..000000000 --- a/lib/src/osViSetMode.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViNext; - -void osViSetMode(OSViMode *mode) { - register u32 int_disabled = __osDisableInt(); - __osViNext->modep = mode; - __osViNext->unk00 = 1; - __osViNext->features = __osViNext->modep->comRegs.ctrl; - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osViSetSpecialFeatures.c b/lib/src/osViSetSpecialFeatures.c deleted file mode 100644 index c1bf52b63..000000000 --- a/lib/src/osViSetSpecialFeatures.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViNext; - -void osViSetSpecialFeatures(u32 func) { - register u32 int_disabled = __osDisableInt(); - if (func & OS_VI_GAMMA_ON) { - __osViNext->features |= OS_VI_GAMMA; - } - if (func & OS_VI_GAMMA_OFF) { - __osViNext->features &= ~OS_VI_GAMMA; - } - if (func & OS_VI_GAMMA_DITHER_ON) { - __osViNext->features |= OS_VI_GAMMA_DITHER; - } - if (func & OS_VI_GAMMA_DITHER_OFF) { - __osViNext->features &= ~OS_VI_GAMMA_DITHER; - } - if (func & OS_VI_DIVOT_ON) { - __osViNext->features |= OS_VI_DIVOT; - } - if (func & OS_VI_DIVOT_OFF) { - __osViNext->features &= ~OS_VI_DIVOT; - } - if (func & OS_VI_DITHER_FILTER_ON) { - __osViNext->features |= OS_VI_DITHER_FILTER; - __osViNext->features &= ~(OS_VI_UNK200 | OS_VI_UNK100); - } - if (func & OS_VI_DITHER_FILTER_OFF) { - __osViNext->features &= ~OS_VI_DITHER_FILTER; - __osViNext->features |= __osViNext->modep->comRegs.ctrl & (OS_VI_UNK200 | OS_VI_UNK100); - } - __osViNext->unk00 |= 8; - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osViSwapBuffer.c b/lib/src/osViSwapBuffer.c deleted file mode 100644 index c2cb1d506..000000000 --- a/lib/src/osViSwapBuffer.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "libultra_internal.h" - -extern OSViContext *__osViNext; - -void osViSwapBuffer(void *vaddr) { - u32 int_disabled = __osDisableInt(); - __osViNext->buffer = vaddr; - __osViNext->unk00 |= 0x10; // TODO: figure out what this flag means - __osRestoreInt(int_disabled); -} diff --git a/lib/src/osViTable.c b/lib/src/osViTable.c deleted file mode 100644 index 424f7ccac..000000000 --- a/lib/src/osViTable.c +++ /dev/null @@ -1,1101 +0,0 @@ -#include "libultra_internal.h" - -OSViMode osViModeTable[] = { - /*osViModeNtscLpn1*/ - { /*type*/ 0, - /*comRegs*/ - { /*ctrl*/ 12814, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLpf1*/ - { /*type*/ 1, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLan1*/ - { /*type*/ 2, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLaf1*/ - { /*type*/ 3, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLpn2*/ - { /*type*/ 4, - /*comRegs*/ - { /*ctrl*/ 13071, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLpf2*/ - { /*type*/ 5, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLan2*/ - { /*type*/ 6, - /*comRegs*/ - { /*ctrl*/ 12319, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 525, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscLaf2*/ - { /*type*/ 7, - /*comRegs*/ - { /*ctrl*/ 12383, - /*width*/ 320, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHpn1*/ - { /*type*/ 8, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 1280, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHpf1*/ - { /*type*/ 9, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 640, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHan1*/ - { /*type*/ 10, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 1280, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHaf1*/ - { /*type*/ 11, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 640, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHpn2*/ - { /*type*/ 12, - /*comRegs*/ - { /*ctrl*/ 13135, - /*width*/ 1280, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModeNtscHpf2*/ - { /*type*/ 13, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 640, - /*burst*/ 65348153, - /*vSync*/ 524, - /*hSync*/ 3093, - /*leap*/ 202705941, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - -#if defined(VERSION_JP) || defined(VERSION_EU) || defined(VERSION_SH) - /*osViModePalLpn1*/ - { /*type*/ 14, - /*comRegs*/ - { /*ctrl*/ 12814, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 625, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } }, - /*osViModePalLpf1*/ - { /*type*/ 15, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalLan1*/ - { /*type*/ 16, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 625, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } }, - /*osViModePalLaf1*/ - { /*type*/ 17, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalLpn2*/ - { /*type*/ 18, - /*comRegs*/ - { /*ctrl*/ 13071, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 625, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } }, - /*osViModePalLpf2*/ - { /*type*/ 19, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalLan2*/ - { /*type*/ 20, - /*comRegs*/ - { /*ctrl*/ 12319, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 625, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 590443, - /*vIntr*/ 2 } } }, - /*osViModePalLaf2*/ - { /*type*/ 21, - /*comRegs*/ - { /*ctrl*/ 12383, - /*width*/ 320, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHpn1*/ - { /*type*/ 22, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 1280, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHpf1*/ - { /*type*/ 23, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 640, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHan1*/ - { /*type*/ 24, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 1280, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHaf1*/ - { /*type*/ 25, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 640, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHpn2*/ - { /*type*/ 26, - /*comRegs*/ - { /*ctrl*/ 13135, - /*width*/ 1280, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 1024, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, - /*osViModePalHpf2*/ - { /*type*/ 27, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 640, -#ifdef VERSION_SH - /*burst*/ 72621626, -#else - /*burst*/ 67380026, -#endif - /*vSync*/ 624, -#ifdef VERSION_SH - /*hSync*/ 1510505, - /*leap*/ 208604269, -#else - /*hSync*/ 1379433, - /*leap*/ 208604270, -#endif - /*hStart*/ 8389376, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 6095415, - /*vBurst*/ 590443, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 33556480, - /*vStart*/ 6226489, - /*vBurst*/ 852585, - /*vIntr*/ 2 } } }, -#endif -#if defined(VERSION_US) || defined(VERSION_EU) || defined (VERSION_SH) - /*osViModePalLpn1*/ - { /*type*/ 28, - /*comRegs*/ - { /*ctrl*/ 12814, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 525, - /*hSync*/ 265233, - /*leap*/ 202968090, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLpf1*/ - { /*type*/ 29, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLan1*/ - { /*type*/ 30, - /*comRegs*/ - { /*ctrl*/ 12574, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 525, - /*hSync*/ 265233, - /*leap*/ 202968090, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLaf1*/ - { /*type*/ 31, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 640, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 640, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLpn2*/ - { /*type*/ 32, - /*comRegs*/ - { /*ctrl*/ 13071, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 525, - /*hSync*/ 265233, - /*leap*/ 202968090, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLpf2*/ - { /*type*/ 33, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLan2*/ - { /*type*/ 34, - /*comRegs*/ - { /*ctrl*/ 12319, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 525, - /*hSync*/ 265233, - /*leap*/ 202968090, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalLaf2*/ - { /*type*/ 35, - /*comRegs*/ - { /*ctrl*/ 12383, - /*width*/ 320, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 512, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 16778240, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 1280, - /*yScale*/ 50332672, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHpn1*/ - { /*type*/ 36, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 1280, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHpf1*/ - { /*type*/ 37, - /*comRegs*/ - { /*ctrl*/ 12878, - /*width*/ 640, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHan1*/ - { /*type*/ 38, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 1280, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHaf1*/ - { /*type*/ 39, - /*comRegs*/ - { /*ctrl*/ 12382, - /*width*/ 640, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 1280, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHpn2*/ - { /*type*/ 40, - /*comRegs*/ - { /*ctrl*/ 13135, - /*width*/ 1280, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 1024, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 1024, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } }, - /*osViModePalHpf2*/ - { /*type*/ 41, - /*comRegs*/ - { /*ctrl*/ 12879, - /*width*/ 640, - /*burst*/ 73735737, - /*vSync*/ 524, - /*hSync*/ 3088, - /*leap*/ 203164700, - /*hStart*/ 7078636, - /*xScale*/ 1024, - /*vCurrent*/ 0 }, - /*fldRegs*/ - { { /*origin*/ 2560, - /*yScale*/ 33556480, - /*vStart*/ 2294269, - /*vBurst*/ 721410, - /*vIntr*/ 2 }, - { /*origin*/ 5120, - /*yScale*/ 33556480, - /*vStart*/ 2425343, - /*vBurst*/ 918020, - /*vIntr*/ 2 } } } -#endif -}; diff --git a/lib/src/osVirtualToPhysical.c b/lib/src/osVirtualToPhysical.c deleted file mode 100644 index b1fb1a55d..000000000 --- a/lib/src/osVirtualToPhysical.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "libultra_internal.h" - -uintptr_t osVirtualToPhysical(void *addr) { - if ((uintptr_t) addr >= 0x80000000 && (uintptr_t) addr < 0xa0000000) { - return ((uintptr_t) addr & 0x1fffffff); - } else if ((uintptr_t) addr >= 0xa0000000 && (uintptr_t) addr < 0xc0000000) { - return ((uintptr_t) addr & 0x1fffffff); - } else { - return __osProbeTLB(addr); - } -} diff --git a/lib/src/osint.h b/lib/src/osint.h deleted file mode 100644 index ba5d7db57..000000000 --- a/lib/src/osint.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _OSINT_H -#define _OSINT_H -#include "libultra_internal.h" - -typedef struct __OSEventState -{ - OSMesgQueue *messageQueue; - OSMesg message; -} __OSEventState; -extern struct __osThreadTail -{ - OSThread *next; - OSPri priority; -} __osThreadTail; - -//maybe should be in exceptasm.h? -extern void __osEnqueueAndYield(OSThread **); -extern void __osDequeueThread(OSThread **, OSThread *); -extern void __osEnqueueThread(OSThread **, OSThread *); -extern OSThread *__osPopThread(OSThread **); -extern void __osDispatchThread(void); - -extern void __osSetTimerIntr(OSTime); -extern OSTime __osInsertTimer(OSTimer *); -extern void __osTimerInterrupt(void); -extern u32 __osProbeTLB(void *); -extern int __osSpDeviceBusy(void); - -#ifdef AVOID_UB -extern OSThread_ListHead D_80334890_fix; -#else -extern OSThread *__osRunningThread; -extern OSThread *D_8033489C; -extern OSThread *__osFaultedThread; -extern OSThread *D_80334898; -#endif - -extern OSTimer *__osTimerList; -extern OSTimer __osBaseTimer; -extern OSTime __osCurrentTime; -extern u32 __osBaseCounter; -extern u32 __osViIntrCount; -extern u32 __osTimerCounter; - -extern __OSEventState __osEventStateTab[OS_NUM_EVENTS]; - - -//not sure if this should be here -extern s32 osViClock; -extern void __osTimerServicesInit(void); -extern s32 __osAiDeviceBusy(void); -extern int __osDpDeviceBusy(void); -#endif diff --git a/lib/src/pfsgetstatus.c b/lib/src/pfsgetstatus.c deleted file mode 100644 index 3497bfa3b..000000000 --- a/lib/src/pfsgetstatus.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "libultra_internal.h" -#include "controller.h" - -void __osPfsRequestOneChannel(int channel); -void __osPfsGetOneChannelData(int channel, OSContStatus *data); - -s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) { - s32 ret; - OSMesg dummy; - OSContStatus data; - ret = 0; - __osPfsRequestOneChannel(channel); - ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); - osRecvMesg(queue, &dummy, OS_MESG_BLOCK); - ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam); - osRecvMesg(queue, &dummy, OS_MESG_BLOCK); - __osPfsGetOneChannelData(channel, &data); - if (((data.status & CONT_CARD_ON) != 0) && ((data.status & CONT_CARD_PULL) != 0)) { - return PFS_ERR_NEW_PACK; - } - if ((data.errnum != 0) || ((data.status & CONT_CARD_ON) == 0)) { - return PFS_ERR_NOPACK; - } - if ((data.status & CONT_ADDR_CRC_ER) != 0) { - return PFS_ERR_CONTRFAIL; - } - return ret; -} - -void __osPfsRequestOneChannel(int channel) { - u8 *ptr; - __OSContRequesFormatShort requestformat; - int i; - - _osLastSentSiCmd = CONT_CMD_REQUEST_STATUS; - __osPfsPifRam.pifstatus = CONT_CMD_EXE; - ptr = (u8 *)&__osPfsPifRam; - - requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX; - requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX; - requestformat.cmd = CONT_CMD_REQUEST_STATUS; - requestformat.typeh = CONT_CMD_NOP; - requestformat.typel = CONT_CMD_NOP; - requestformat.status = CONT_CMD_NOP; - for (i = 0; i < channel; i++) { - *ptr++ = 0; - } - - *(__OSContRequesFormatShort *)ptr = requestformat; - ptr += sizeof(__OSContRequesFormatShort); - *ptr = CONT_CMD_END; -} - -void __osPfsGetOneChannelData(int channel, OSContStatus *data) { - u8 *ptr; - __OSContRequesFormatShort requestformat; - int i; - ptr = (u8*)&__osPfsPifRam; - for (i = 0; i < channel; i++) { - ptr++; - } - requestformat = *(__OSContRequesFormatShort *)ptr; - data->errnum = CHNL_ERR(requestformat); - if (data->errnum == 0) { - data->type = (requestformat.typel << 8) | (requestformat.typeh); - data->status = requestformat.status; - } -} diff --git a/lib/src/piint.h b/lib/src/piint.h deleted file mode 100644 index b3fee34e5..000000000 --- a/lib/src/piint.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef _PIINT_H -#define _PIINT_H -#include "PR/os_internal.h" -#include "PR/rcp.h" -#include "PR/os_pi.h" -#include "os.h" - -//https://github.com/LuigiBlood/64dd/wiki/Memory-Map - -#define LEO_BASE_REG 0x05000000 - -#define LEO_CMD (LEO_BASE_REG + 0x508) -#define LEO_STATUS (LEO_BASE_REG + 0x508) - -#define LEO_BM_CTL (LEO_BASE_REG + 0x510) -#define LEO_BM_STATUS (LEO_BASE_REG + 0x510) - -#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518) -#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518) - -#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer -#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer -#define LEO_DATA (LEO_BASE_REG + 0x500) //Data -#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register -#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track -#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status -#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector -#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset -#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1 -#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes) -#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1 -#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size -#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1 -#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1 -#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address? -#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID -#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read -#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write -#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM - -#define LEO_STATUS_PRESENCE_MASK 0xFFFF - -#define LEO_STATUS_DATA_REQUEST 0x40000000 -#define LEO_STATUS_C2_TRANSFER 0x10000000 -#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000 -#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000 -#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000 -#define LEO_STATUS_DISK_PRESENT 0x01000000 -#define LEO_STATUS_BUSY_STATE 0x00800000 -#define LEO_STATUS_RESET_STATE 0x00400000 -#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000 -#define LEO_STATUS_HEAD_RETRACTED 0x00080000 -#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000 -#define LEO_STATUS_MECHANIC_ERROR 0x00020000 -#define LEO_STATUS_DISK_CHANGE 0x00010000 - -#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_ACTIVE 0 - -#define LEO_CUR_TK_INDEX_LOCK 0x60000000 - -#define LEO_BM_STATUS_RUNNING 0x80000000 //Running -#define LEO_BM_STATUS_ERROR 0x04000000 //Error -#define LEO_BM_STATUS_MICRO 0x02000000 //Micro Status? -#define LEO_BM_STATUS_BLOCK 0x01000000 //Block Transfer -#define LEO_BM_STATUS_C1CORRECTION 0x00800000 //C1 Correction -#define LEO_BM_STATUS_C1DOUBLE 0x00400000 //C1 Double -#define LEO_BM_STATUS_C1SINGLE 0x00200000 //C1 Single -#define LEO_BM_STATUS_C1ERROR 0x00010000 //C1 Error - -#define LEO_BM_CTL_START 0x80000000 //Start Buffer Manager -#define LEO_BM_CTL_MODE 0x40000000 //Buffer Manager Mode -#define LEO_BM_CTL_IMASK 0x20000000 //BM Interrupt Mask -#define LEO_BM_CTL_RESET 0x10000000 //Buffer Manager Reset -#define LEO_BM_CTL_DISABLE_OR 0x08000000 //Disable OR Check? -#define LEO_BM_CTL_DISABLE_C1 0x04000000 //Disable C1 Correction -#define LEO_BM_CTL_BLOCK 0x02000000 //Block Transfer -#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 //Mechanic Interrupt Reset - -#define LEO_BM_CTL_CONTROL_MASK 0xFF000000 -#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000 -#define LEO_BM_CTL_SECTOR_SHIFT 16 - -#define LEO_CMD_TYPE_0 0 //TODO: name -#define LEO_CMD_TYPE_1 1 //TODO: name -#define LEO_CMD_TYPE_2 2 //TODO: name - -#define LEO_ERROR_GOOD 0 -#define LEO_ERROR_4 4 //maybe busy? -#define LEO_ERROR_22 22 // -#define LEO_ERROR_23 23 //unrecovered read error? -#define LEO_ERROR_24 24 //no reference position found? -#define LEO_ERROR_29 29 // - -extern OSDevMgr __osPiDevMgr; -extern OSPiHandle *__osCurrentHandle[2]; -extern OSPiHandle CartRomHandle; -extern OSPiHandle LeoDiskHandle; -extern OSMesgQueue __osPiAccessQueue; -extern u32 __osPiAccessQueueEnabled; - -int __osPiDeviceBusy(void); -void __osDevMgrMain(void *); -void __osPiCreateAccessQueue(void); -void __osPiRelAccess(void); -void __osPiGetAccess(void); -OSMesgQueue *osPiGetCmdQueue(void); - -#define OS_RAMROM_STACKSIZE 1024 - -#define WAIT_ON_IOBUSY(stat) \ - stat = IO_READ(PI_STATUS_REG); \ - while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ - stat = IO_READ(PI_STATUS_REG); - -#define UPDATE_REG(reg, var) \ - if (cHandle->var != pihandle->var) \ - IO_WRITE(reg, pihandle->var); - -#define EPI_SYNC(pihandle, stat, domain) \ - \ - WAIT_ON_IOBUSY(stat) \ - \ - domain = pihandle->domain; \ - if (__osCurrentHandle[domain] != pihandle) \ - { \ - OSPiHandle *cHandle = __osCurrentHandle[domain]; \ - if (domain == PI_DOMAIN1) \ - { \ - UPDATE_REG(PI_BSD_DOM1_LAT_REG, latency); \ - UPDATE_REG(PI_BSD_DOM1_PGS_REG, pageSize); \ - UPDATE_REG(PI_BSD_DOM1_RLS_REG, relDuration); \ - UPDATE_REG(PI_BSD_DOM1_PWD_REG, pulse); \ - } \ - else \ - { \ - UPDATE_REG(PI_BSD_DOM2_LAT_REG, latency); \ - UPDATE_REG(PI_BSD_DOM2_PGS_REG, pageSize); \ - UPDATE_REG(PI_BSD_DOM2_RLS_REG, relDuration); \ - UPDATE_REG(PI_BSD_DOM2_PWD_REG, pulse); \ - } \ - __osCurrentHandle[domain] = pihandle; \ - } - -#endif diff --git a/lib/src/sprintf.c b/lib/src/sprintf.c deleted file mode 100644 index 8450fbc53..000000000 --- a/lib/src/sprintf.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "libultra_internal.h" -#include "printf.h" -#include - -char *proutSprintf(char *dst, const char *src, size_t count); - -int sprintf(char *dst, const char *fmt, ...) { - s32 written; - va_list args; - va_start(args, fmt); - written = _Printf(proutSprintf, dst, fmt, args); - if (written >= 0) { - dst[written] = 0; - } - return written; -} - -char *proutSprintf(char *dst, const char *src, size_t count) { - return (char *) memcpy((u8 *) dst, (u8 *) src, count) + count; -} diff --git a/lib/src/string.c b/lib/src/string.c deleted file mode 100644 index dbffaa1d3..000000000 --- a/lib/src/string.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "libultra_internal.h" -#include - -void *memcpy(void *dst, const void *src, size_t size) { - u8 *_dst = dst; - const u8 *_src = src; - while (size > 0) { - *_dst++ = *_src++; - size--; - } - return dst; -} - -size_t strlen(const char *str) { - const u8 *ptr = (const u8 *) str; - while (*ptr) { - ptr++; - } - return (const char *) ptr - str; -} - -char *strchr(const char *str, s32 ch) { - u8 c = ch; - while (*(u8 *)str != c) { - if (*(u8 *)str == 0) { - return NULL; - } - str++; - } - return (char *) str; -} diff --git a/lib/src/unk_shindou_file_3.c b/lib/src/unk_shindou_file_3.c deleted file mode 100644 index 318e4068e..000000000 --- a/lib/src/unk_shindou_file_3.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "libultra_internal.h" -#include "controller.h" - -#ifdef VERSION_SH -s32 func_8030A5C0(OSMesgQueue *arg0, s32 arg1) { // TODO: This is almost certainly __osPfsGetStatus. - s32 sp34 = 0; - OSMesg sp30; - u8 sp2f; - OSContStatus sp1c[4]; - __osPfsRequestData(0); - sp34 = __osSiRawStartDma(1, &__osPfsPifRam); - osRecvMesg(arg0, &sp30, 1); - sp34 = __osSiRawStartDma(0, &__osPfsPifRam); - osRecvMesg(arg0, &sp30, 1); - __osPfsGetInitData(&sp2f, sp1c); - if (sp1c[arg1].status & CONT_CARD_ON && sp1c[arg1].status & CONT_CARD_PULL) { - return 2; - } - if (sp1c[arg1].errnum || !(sp1c[arg1].status & CONT_CARD_ON)) { - return 1; - } - if (sp1c[arg1].status & CONT_ADDR_CRC_ER) { - return 4; - } - return sp34; - -} -#endif diff --git a/sm64.ld b/sm64.ld index aabeba8ae..cbc7d919e 100755 --- a/sm64.ld +++ b/sm64.ld @@ -21,26 +21,26 @@ OUTPUT_ARCH (mips) #define END_NOLOAD(name) \ _##name##SegmentNoloadEnd = ADDR(.name.noload) + SIZEOF(.name.noload); -#define MIO0_SEG(name, segAddr) \ - BEGIN_SEG(name##_mio0, segAddr) \ +#define YAY0_SEG(name, segAddr) \ + BEGIN_SEG(name##_yay0, segAddr) \ { \ - BUILD_DIR/bin/name.mio0.o(.data); \ + BUILD_DIR/bin/name.szp.o(.data); \ . = ALIGN(0x10); \ } \ - END_SEG(name##_mio0) + END_SEG(name##_yay0) -#define MIO0_EU_SEG(name, segAddr) \ - BEGIN_SEG(name##_mio0, segAddr) \ +#define YAY0_EU_SEG(name, segAddr) \ + BEGIN_SEG(name##_yay0, segAddr) \ { \ - BUILD_DIR/bin/eu/name.mio0.o(.data); \ + BUILD_DIR/bin/eu/name.szp.o(.data); \ . = ALIGN(0x10); \ } \ - END_SEG(name##_mio0) + END_SEG(name##_yay0) #define STANDARD_LEVEL(name) \ BEGIN_SEG(name##_segment_7, 0x07000000) \ { \ - BUILD_DIR/levels/name/leveldata.mio0.o(.data); \ + BUILD_DIR/levels/name/leveldata.szp.o(.data); \ . = ALIGN(0x10); \ } \ END_SEG(name##_segment_7) \ @@ -52,12 +52,12 @@ OUTPUT_ARCH (mips) END_SEG(name) #define STANDARD_OBJECTS(name, segAddr, geoAddr) \ - BEGIN_SEG(name##_mio0, segAddr) \ + BEGIN_SEG(name##_yay0, segAddr) \ { \ - BUILD_DIR/actors/name.mio0.o(.data); \ + BUILD_DIR/actors/name.szp.o(.data); \ . = ALIGN(0x10); \ } \ - END_SEG(name##_mio0) \ + END_SEG(name##_yay0) \ BEGIN_SEG(name##_geo, geoAddr) \ { \ BUILD_DIR/actors/name##_geo.o(.data); \ @@ -114,653 +114,55 @@ SECTIONS BEGIN_SEG(main, .) SUBALIGN(16) { BUILD_DIR/asm/entry.o(.text); - BUILD_DIR/src/game/crash_screen.o(.text); - BUILD_DIR/src/game/main.o(.text); - BUILD_DIR/src/game/game_init.o(.text); - BUILD_DIR/src/game/sound_init.o(.text); -#ifdef VERSION_SH - BUILD_DIR/src/game/rumble_init.o(.text); -#endif - BUILD_DIR/src/game/level_update.o(.text); - BUILD_DIR/src/game/interaction.o(.text); - BUILD_DIR/src/game/mario.o(.text); - BUILD_DIR/src/game/mario_step.o(.text); - BUILD_DIR/src/game/mario_actions_cutscene.o(.text); - BUILD_DIR/src/game/mario_actions_automatic.o(.text); - BUILD_DIR/src/game/mario_actions_stationary.o(.text); - BUILD_DIR/src/game/mario_actions_moving.o(.text); - BUILD_DIR/src/game/mario_actions_airborne.o(.text); - BUILD_DIR/src/game/mario_actions_submerged.o(.text); - BUILD_DIR/src/game/mario_actions_object.o(.text); - BUILD_DIR/src/game/level_geo.o(.text); - BUILD_DIR/src/game/mario_misc.o(.text); - BUILD_DIR/src/game/memory.o(.text); - BUILD_DIR/src/game/save_file.o(.text); - BUILD_DIR/src/game/area.o(.text); - BUILD_DIR/src/game/rendering_graph_node.o(.text); - BUILD_DIR/src/game/profiler.o(.text); - BUILD_DIR/asm/decompress.o(.text); - BUILD_DIR/src/game/camera.o(.text); - BUILD_DIR/src/game/debug_course.o(.text); - BUILD_DIR/src/game/object_list_processor.o(.text); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_helpers.o(.text); -#endif - BUILD_DIR/src/game/behavior_actions.o(.text); - BUILD_DIR/src/game/platform_displacement.o(.text); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.text); - BUILD_DIR/src/game/spawn_object.o(.text); -#endif - BUILD_DIR/src/game/spawn_sound.o(.text); - BUILD_DIR/src/game/debug.o(.text); - BUILD_DIR/src/game/screen_transition.o(.text); - BUILD_DIR/src/game/shadow.o(.text); - BUILD_DIR/src/game/skybox.o(.text); - BUILD_DIR/src/game/moving_texture.o(.text); - BUILD_DIR/src/game/geo_misc.o(.text); - BUILD_DIR/src/game/paintings.o(.text); - BUILD_DIR/src/game/print.o(.text); - BUILD_DIR/src/game/ingame_menu.o(.text); - BUILD_DIR/src/game/envfx_snow.o(.text); - BUILD_DIR/src/game/envfx_bubbles.o(.text); - BUILD_DIR/src/game/macro_special_objects.o(.text); - BUILD_DIR/src/game/hud.o(.text); - BUILD_DIR/src/game/obj_behaviors.o(.text); - BUILD_DIR/src/game/obj_behaviors_2.o(.text); - BUILD_DIR/src/audio/synthesis.o(.text); - BUILD_DIR/src/audio/heap.o(.text); - BUILD_DIR/src/audio/load.o(.text); -#ifdef VERSION_SH - BUILD_DIR/src/audio/unk_shindou_audio_file.o(.text); -#endif - BUILD_DIR/src/audio/playback.o(.text); - BUILD_DIR/src/audio/effects.o(.text); - BUILD_DIR/src/audio/seqplayer.o(.text); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osDriveRomInit.o(.text); -#endif - BUILD_DIR/src/audio/external.o(.text); - BUILD_DIR/src/audio/port_eu.o(.text); -#if defined(VERSION_EU) || defined(VERSION_SH) - BUILD_DIR/libultra.a:string.o(.text); - BUILD_DIR/libultra.a:_Printf.o(.text); - BUILD_DIR/libultra.a:llmuldiv.o(.text); - BUILD_DIR/libultra.a:osInitialize.o(.text); - BUILD_DIR/libultra.a:osSetTime.o(.text); - BUILD_DIR/libultra.a:osGetTime.o(.text); - BUILD_DIR/libultra.a:osWritebackDCacheAll.o(.text); - BUILD_DIR/libultra.a:osViBlack.o(.text); - BUILD_DIR/libultra.a:osViSwapBuffer.o(.text); - BUILD_DIR/libultra.a:__osGetCurrFaultedThread.o(.text); - BUILD_DIR/libultra.a:osSetEventMesg.o(.text); - BUILD_DIR/libultra.a:osRecvMesg.o(.text); - BUILD_DIR/libultra.a:parameters.o(.text); - BUILD_DIR/libultra.a:osCreateMesgQueue.o(.text); - BUILD_DIR/libultra.a:osCreateThread.o(.text); - BUILD_DIR/libultra.a:osStartThread.o(.text); - BUILD_DIR/libultra.a:osMapTLB.o(.text); - BUILD_DIR/libultra.a:osUnmapTLBAll.o(.text); - BUILD_DIR/libultra.a:sprintf.o(.text); - BUILD_DIR/libultra.a:osViSetEvent.o(.text); - BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.text); - BUILD_DIR/libultra.a:osSpTaskYield.o(.text); - BUILD_DIR/libultra.a:osSendMesg.o(.text); - BUILD_DIR/libultra.a:osSpTaskYielded.o(.text); - BUILD_DIR/libultra.a:osCreateViManager.o(.text); - BUILD_DIR/libultra.a:osViSetMode.o(.text); - BUILD_DIR/libultra.a:osViSetSpecialFeatures.o(.text); - BUILD_DIR/libultra.a:osCreatePiManager.o(.text); - BUILD_DIR/libultra.a:osSetThreadPri.o(.text); - BUILD_DIR/libultra.a:osViSwapBuffer.o(.text); - BUILD_DIR/libultra.a:sqrtf.o(.text); - BUILD_DIR/libultra.a:osContStartReadData.o(.text); - BUILD_DIR/libultra.a:osContInit.o(.text); - BUILD_DIR/libultra.a:osEepromProbe.o(.text); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:motor.o(.text); -#endif - BUILD_DIR/libultra.a:osInvalDCache.o(.text); - BUILD_DIR/libultra.a:osPiStartDma.o(.text); - BUILD_DIR/libultra.a:bzero.o(.text) - BUILD_DIR/libultra.a:osInvalICache.o(.text) - BUILD_DIR/libultra.a:osEepromLongRead.o(.text) - BUILD_DIR/libultra.a:osEepromLongWrite.o(.text) - BUILD_DIR/libultra.a:bcopy.o(.text) - BUILD_DIR/libultra.a:guOrthoF.o(.text) - BUILD_DIR/libultra.a:guPerspectiveF.o(.text) - BUILD_DIR/libultra.a:llconv.o(.text) - BUILD_DIR/libultra.a:cosf.o(.text) - BUILD_DIR/libultra.a:sinf.o(.text) - BUILD_DIR/libultra.a:guTranslateF.o(.text) - BUILD_DIR/libultra.a:guRotateF.o(.text) - BUILD_DIR/libultra.a:guScaleF.o(.text) - BUILD_DIR/libultra.a:osAiSetFrequency.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osCartRomInit.o(.text) - BUILD_DIR/libultra.a:epidma.o(.text) -#else - BUILD_DIR/libultra.a:alBnkfNew.o(.text) -#endif - BUILD_DIR/libultra.a:osAiGetLength.o(.text) - BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osGetCount.o(.text) - BUILD_DIR/libultra.a:__osDisableInt.o(.text) - BUILD_DIR/libultra.a:__osRestoreInt.o(.text) -#endif - BUILD_DIR/libultra.a:_Litob.o(.text) - BUILD_DIR/libultra.a:_Ldtob.o(.text) - BUILD_DIR/libultra.a:__osSetSR.o(.text) - BUILD_DIR/libultra.a:__osGetSR.o(.text) - BUILD_DIR/libultra.a:__osSetFpcCsr.o(.text) - BUILD_DIR/libultra.a:__osSiRawReadIo.o(.text) - BUILD_DIR/libultra.a:__osSiRawWriteIo.o(.text) - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.text) - BUILD_DIR/libultra.a:osWritebackDCache.o(.text) - BUILD_DIR/libultra.a:osMapTLBRdb.o(.text) - BUILD_DIR/libultra.a:osPiRawReadIo.o(.text) - BUILD_DIR/libultra.a:EU_D_802f4330.o(.text) - BUILD_DIR/libultra.a:D_802F4380.o(.text) - BUILD_DIR/libultra.a:func_802F4A20.o(.text) - BUILD_DIR/libultra.a:osTimer.o(.text) -#ifdef VERSION_EU - BUILD_DIR/libultra.a:__osDisableInt.o(.text) - BUILD_DIR/libultra.a:__osRestoreInt.o(.text) - BUILD_DIR/libultra.a:osGetCount.o(.text) -#endif - BUILD_DIR/libultra.a:__osViInit.o(.text) - BUILD_DIR/libultra.a:__osDequeueThread.o(.text) - BUILD_DIR/libultra.a:osVirtualToPhysical.o(.text) - BUILD_DIR/libultra.a:__osSpSetStatus.o(.text) - BUILD_DIR/libultra.a:__osSpSetPc.o(.text) - BUILD_DIR/libultra.a:__osSpRawStartDma.o(.text) - BUILD_DIR/libultra.a:__osSpDeviceBusy.o(.text) - BUILD_DIR/libultra.a:__osSpGetStatus.o(.text) - BUILD_DIR/libultra.a:osGetThreadPri.o(.text) - BUILD_DIR/libultra.a:__osViGetCurrentContext.o(.text); - BUILD_DIR/libultra.a:__osViSwapContext.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osLeoDiskInit.o(.text) -#endif - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.text) - BUILD_DIR/libultra.a:osPiRawStartDma.o(.text) - BUILD_DIR/libultra.a:osEPiRawStartDma.o(.text) - BUILD_DIR/libultra.a:__osDevMgrMain.o(.text) - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.text) - BUILD_DIR/libultra.a:__osSiRawStartDma.o(.text) - BUILD_DIR/libultra.a:osSetTimer.o(.text) - BUILD_DIR/libultra.a:osEepromWrite.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osPfsIsPlug.o(.text) - BUILD_DIR/libultra.a:crc.o(.text) - BUILD_DIR/libultra.a:contramwrite.o(.text) - BUILD_DIR/libultra.a:contramread.o(.text) -#endif - BUILD_DIR/libultra.a:osJamMesg.o(.text) - BUILD_DIR/libultra.a:osPiGetCmdQueue.o(.text) - BUILD_DIR/libultra.a:osEepromRead.o(.text) - BUILD_DIR/libultra.a:guMtxF2L.o(.text) - BUILD_DIR/libultra.a:guNormalize.o(.text) - BUILD_DIR/libultra.a:__osAiDeviceBusy.o(.text); - BUILD_DIR/libultra.a:ldiv.o(.text) - BUILD_DIR/libultra.a:__osSiDeviceBusy.o(.text); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:leointerrupt.o(.text) -#endif - BUILD_DIR/libultra.a:osSetIntMask.o(.text) - BUILD_DIR/libultra.a:osDestroyThread.o(.text) -#ifndef VERSION_SH - BUILD_DIR/libultra.a:osLeoDiskInit.o(.text) -#endif - BUILD_DIR/libultra.a:__osSetCompare.o(.text) - BUILD_DIR/libultra.a:__osDequeueThread.o(.text) - BUILD_DIR/libultra.a:__osProbeTLB.o(.text) - BUILD_DIR/libultra.a:__osResetGlobalIntMask.o(.text) - BUILD_DIR/libultra.a:__osEPiRawWriteIo.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:__osEPiRawReadIo.o(.text) - BUILD_DIR/libultra.a:__osSetGlobalIntMask.o(.text) -#endif - BUILD_DIR/libultra.a:func_802F71F0.o(.text) -#ifdef VERSION_SH - BUILD_DIR/libultra.a:unk_shindou_file_3.o(.text) -#endif - BUILD_DIR/lib/rsp.o(.text); -#else BUILD_DIR/src/game*.o(.text); BUILD_DIR/src/audio*.o(.text); - BUILD_DIR/libultra.a:parameters.o(.text); - BUILD_DIR/libultra.a:osSetTime.o(.text); - BUILD_DIR/libultra.a:osMapTLB.o(.text); - BUILD_DIR/libultra.a:osUnmapTLBAll.o(.text); - BUILD_DIR/libultra.a:sprintf.o(.text); - BUILD_DIR/libultra.a:osCreateMesgQueue.o(.text); - BUILD_DIR/libultra.a:osSetEventMesg.o(.text); - BUILD_DIR/libultra.a:osViSetEvent.o(.text); - BUILD_DIR/libultra.a:osCreateThread.o(.text); - BUILD_DIR/libultra.a:osRecvMesg.o(.text); - BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.text); - BUILD_DIR/libultra.a:osSpTaskYield.o(.text); - BUILD_DIR/libultra.a:osSendMesg.o(.text); - BUILD_DIR/libultra.a:osSpTaskYielded.o(.text); - BUILD_DIR/libultra.a:osStartThread.o(.text); - BUILD_DIR/libultra.a:osWritebackDCacheAll.o(.text); - BUILD_DIR/libultra.a:osCreateViManager.o(.text); - BUILD_DIR/libultra.a:osViSetMode.o(.text); - BUILD_DIR/libultra.a:osViBlack.o(.text); - BUILD_DIR/libultra.a:osViSetSpecialFeatures.o(.text); - BUILD_DIR/libultra.a:osCreatePiManager.o(.text); - BUILD_DIR/libultra.a:osSetThreadPri.o(.text); - BUILD_DIR/libultra.a:osInitialize.o(.text); - BUILD_DIR/libultra.a:osViSwapBuffer.o(.text); - BUILD_DIR/libultra.a:sqrtf.o(.text); - BUILD_DIR/libultra.a:osContStartReadData.o(.text); - BUILD_DIR/libultra.a:osContInit.o(.text); - BUILD_DIR/libultra.a:osEepromProbe.o(.text); - BUILD_DIR/libultra.a:llmuldiv.o(.text); - BUILD_DIR/libultra.a:llmuldiv_gcc.o(.text); - BUILD_DIR/libultra.a:osInvalDCache.o(.text); - BUILD_DIR/libultra.a:osPiStartDma.o(.text); - BUILD_DIR/libultra.a:bzero.o(.text); - BUILD_DIR/libultra.a:osInvalICache.o(.text); - BUILD_DIR/libultra.a:osEepromLongRead.o(.text); - BUILD_DIR/libultra.a:osEepromLongWrite.o(.text); - BUILD_DIR/libultra.a:bcopy.o(.text); - BUILD_DIR/libultra.a:guOrthoF.o(.text); - BUILD_DIR/libultra.a:guPerspectiveF.o(.text); - BUILD_DIR/libultra.a:osGetTime.o(.text); - BUILD_DIR/libultra.a:llconv.o(.text); - BUILD_DIR/libultra.a:cosf.o(.text); - BUILD_DIR/libultra.a:sinf.o(.text); - BUILD_DIR/libultra.a:guTranslateF.o(.text); - BUILD_DIR/libultra.a:guRotateF.o(.text); - BUILD_DIR/libultra.a:guScaleF.o(.text); - BUILD_DIR/libultra.a:osAiSetFrequency.o(.text); - BUILD_DIR/libultra.a:alBnkfNew.o(.text); - BUILD_DIR/libultra.a:osWritebackDCache.o(.text); - BUILD_DIR/libultra.a:osAiGetLength.o(.text); - BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.text); - BUILD_DIR/libultra.a:osTimer.o(.text); - BUILD_DIR/libultra.a:_Printf.o(.text); - BUILD_DIR/libultra.a:string.o(.text); - BUILD_DIR/libultra.a:__osDequeueThread.o(.text); - BUILD_DIR/libultra.a:__osDisableInt.o(.text); - BUILD_DIR/libultra.a:__osRestoreInt.o(.text); - BUILD_DIR/libultra.a:__osViInit.o(.text); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.text); - BUILD_DIR/libultra.a:osVirtualToPhysical.o(.text); - BUILD_DIR/libultra.a:__osSpSetStatus.o(.text); - BUILD_DIR/libultra.a:__osSpSetPc.o(.text); - BUILD_DIR/libultra.a:__osSpRawStartDma.o(.text); - BUILD_DIR/libultra.a:__osSpDeviceBusy.o(.text); - BUILD_DIR/libultra.a:__osSpGetStatus.o(.text); - BUILD_DIR/libultra.a:osGetThreadPri.o(.text); - BUILD_DIR/libultra.a:__osViGetCurrentContext.o(.text); - BUILD_DIR/libultra.a:__osViSwapContext.o(.text); - BUILD_DIR/libultra.a:osGetCount.o(.text); - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.text); - BUILD_DIR/libultra.a:osPiRawStartDma.o(.text); - BUILD_DIR/libultra.a:__osDevMgrMain.o(.text); - BUILD_DIR/libultra.a:__osSetSR.o(.text); - BUILD_DIR/libultra.a:__osGetSR.o(.text); - BUILD_DIR/libultra.a:__osSetFpcCsr.o(.text); - BUILD_DIR/libultra.a:__osSiRawReadIo.o(.text); - BUILD_DIR/libultra.a:__osSiRawWriteIo.o(.text); - BUILD_DIR/libultra.a:osMapTLBRdb.o(.text); - BUILD_DIR/libultra.a:osPiRawReadIo.o(.text); -#ifdef VERSION_JP - . += 0x40; -#endif - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.text); - BUILD_DIR/libultra.a:__osSiRawStartDma.o(.text); - BUILD_DIR/libultra.a:osSetTimer.o(.text); - BUILD_DIR/libultra.a:osEepromWrite.o(.text); - BUILD_DIR/libultra.a:osJamMesg.o(.text); - BUILD_DIR/libultra.a:osPiGetCmdQueue.o(.text); - BUILD_DIR/libultra.a:osEepromRead.o(.text); - BUILD_DIR/libultra.a:guMtxF2L.o(.text); - BUILD_DIR/libultra.a:guMtxIdentF.o(.text); - BUILD_DIR/libultra.a:guNormalize.o(.text); - BUILD_DIR/libultra.a:__osAiDeviceBusy.o(.text); - BUILD_DIR/libultra.a:__osSetCompare.o(.text); - BUILD_DIR/libultra.a:_Litob.o(.text); - BUILD_DIR/libultra.a:_Ldtob.o(.text); - BUILD_DIR/libultra.a:kdebugserver.o(.text); - BUILD_DIR/libultra.a:__osSyncPutChars.o(.text); - BUILD_DIR/libultra.a:osSetIntMask.o(.text); - BUILD_DIR/libultra.a:osDestroyThread.o(.text); - BUILD_DIR/libultra.a:__osProbeTLB.o(.text); - BUILD_DIR/libultra.a:__osSiDeviceBusy.o(.text); - BUILD_DIR/libultra.a:ldiv.o(.text); - BUILD_DIR/libultra.a:__osGetCause.o(.text); - BUILD_DIR/libultra.a:__osAtomicDec.o(.text); - BUILD_DIR/libultra.a:guLookAtRef.o(.text); /* Fast3DEX2 only */ - BUILD_DIR/lib/rsp.o(.text); -#endif + BUILD_DIR/asm/llmuldiv_gcc.o(.text); + BUILD_DIR/asm/slidec.o(.text); + + */libultra_rom.a:*.o(.text); + */libhvqm2.a:*.o(.text); + + BUILD_DIR/lib/rsp.o(.text); + lib/PR/hvqm/hvqm2sp1.o(.text); + lib/PR/hvqm/hvqm2sp2.o(.text); /* data */ - BUILD_DIR/src/game/crash_screen.o(.data*); - BUILD_DIR/src/game/main.o(.data*); - BUILD_DIR/src/game/game_init.o(.data*); - BUILD_DIR/src/game/sound_init.o(.data*); -#ifdef VERSION_SH - BUILD_DIR/src/game/rumble_init.o(.data*); -#endif - BUILD_DIR/src/game/level_update.o(.data*); - BUILD_DIR/src/game/interaction.o(.data*); - BUILD_DIR/src/game/mario.o(.data*); - BUILD_DIR/src/game/mario_step.o(.data*); - BUILD_DIR/src/game/mario_actions_cutscene.o(.data*); - BUILD_DIR/src/game/mario_actions_moving.o(.data*); - BUILD_DIR/src/game/mario_actions_submerged.o(.data*); - BUILD_DIR/src/game/mario_actions_object.o(.data*); - BUILD_DIR/src/game/mario_misc.o(.data*); - BUILD_DIR/src/game/memory.o(.data*); - BUILD_DIR/src/game/save_file.o(.data*); - BUILD_DIR/src/game/area.o(.data*); - BUILD_DIR/src/game/rendering_graph_node.o(.data*); - BUILD_DIR/src/game/profiler.o(.data*); - BUILD_DIR/src/game/camera.o(.data*); - BUILD_DIR/src/game/object_list_processor.o(.data*); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_helpers.o(.data*); -#endif - BUILD_DIR/src/game/behavior_actions.o(.data*); - BUILD_DIR/src/game/platform_displacement.o(.data*); - BUILD_DIR/src/game/spawn_sound.o(.data*); - BUILD_DIR/src/game/debug.o(.data*); - BUILD_DIR/src/game/screen_transition.o(.data*); - BUILD_DIR/src/game/shadow.o(.data*); - BUILD_DIR/src/game/skybox.o(.data*); - BUILD_DIR/src/game/moving_texture.o(.data*); - BUILD_DIR/src/game/geo_misc.o(.data*); - BUILD_DIR/src/game/paintings.o(.data*); - BUILD_DIR/src/game/print.o(.data*); - BUILD_DIR/src/game/ingame_menu.o(.data*); - BUILD_DIR/src/game/envfx_snow.o(.data*); - BUILD_DIR/src/game/envfx_bubbles.o(.data*); - BUILD_DIR/src/game/macro_special_objects.o(.data*); - BUILD_DIR/src/game/hud.o(.data*); - BUILD_DIR/src/game/obj_behaviors.o(.data*); - BUILD_DIR/src/game/obj_behaviors_2.o(.data*); -#ifndef VERSION_EU - /* wildcard doesn't match on EU due to files being moved to engine/ */ BUILD_DIR/src/game*.o(.data*); -#endif - BUILD_DIR/src/audio/synthesis.o(.data*); - BUILD_DIR/src/audio/heap.o(.data*); -#ifndef VERSION_SH - BUILD_DIR/src/audio/load.o(.data*); -#endif - BUILD_DIR/src/audio/playback.o(.data*); - BUILD_DIR/src/audio/effects.o(.data*); - BUILD_DIR/src/audio/seqplayer.o(.data*); -#ifdef VERSION_SH - BUILD_DIR/src/audio/data.o(.data*); - BUILD_DIR/src/audio/shindou_debug_prints.o(.data*); - BUILD_DIR/src/audio/unk_shindou_audio_file.o(.data*); - BUILD_DIR/src/audio/external.o(.data*); - BUILD_DIR/src/audio/audio_session_presets_sh.o(.data*); -#else - BUILD_DIR/src/audio/external.o(.data*); - BUILD_DIR/src/audio/port_eu.o(.data*); - BUILD_DIR/src/audio/data.o(.data*); -#endif + BUILD_DIR/src/game*.o(.sdata*); + BUILD_DIR/src/audio*.o(.data*); + BUILD_DIR/src/audio*.o(.sdata*); -#if defined(VERSION_EU) || defined(VERSION_SH) - BUILD_DIR/libultra.a:_Printf.o(.data*); - BUILD_DIR/libultra.a:osInitialize.o(.data*); - BUILD_DIR/libultra.a:osCreateViManager.o(.data*); - BUILD_DIR/libultra.a:osViTable.o(.data*); - BUILD_DIR/libultra.a:osCreatePiManager.o(.data*); - BUILD_DIR/libultra.a:osContInit.o(.data*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:motor.o(.data*); -#endif - BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.data*); - BUILD_DIR/libultra.a:_Litob.o(.data*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.data*); - BUILD_DIR/libultra.a:osTimer.o(.data*); - BUILD_DIR/libultra.a:__osViInit.o(.data*); - BUILD_DIR/libultra.a:__osDequeueThread.o(.data*); - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.data*); - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.data*); - BUILD_DIR/libultra.a:osViData.o(.data*); -#else - BUILD_DIR/libultra.a:osViTable.o(.data*); - BUILD_DIR/libultra.a:osCreateViManager.o(.data*); - BUILD_DIR/libultra.a:osCreatePiManager.o(.data*); - BUILD_DIR/libultra.a:osInitialize.o(.data*); - BUILD_DIR/libultra.a:osContInit.o(.data*); - BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.data*); - BUILD_DIR/libultra.a:osTimer.o(.data*); - BUILD_DIR/libultra.a:_Printf.o(.data*); - BUILD_DIR/libultra.a:__osDequeueThread.o(.data*); - BUILD_DIR/libultra.a:__osViInit.o(.data*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.data*); - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.data*); - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.data*); - BUILD_DIR/libultra.a:_Litob.o(.data*); - BUILD_DIR/libultra.a:_Ldtob.o(.data*); - BUILD_DIR/libultra.a:osViData.o(.data*); - BUILD_DIR/libultra.a:kdebugserver.o(.data*); - BUILD_DIR/libultra.a:__osSyncPutChars.o(.data*); - BUILD_DIR/libultra.a:guRotateF.o(.data*); - BUILD_DIR/libultra.a:*.o(.data*); -#endif + */libultra_rom.a:*.o(.data*); + */libultra_rom.a:*.o(.sdata*); + */libhvqm2.a:*.o(.data*); + + BUILD_DIR/lib/rsp.o(.data*); + lib/PR/hvqm/hvqm2sp1.o(.data*); + lib/PR/hvqm/hvqm2sp2.o(.data*); /* rodata */ - BUILD_DIR/src/game/crash_screen.o(.rodata*); - BUILD_DIR/src/game/main.o(.rodata*); - BUILD_DIR/src/game/game_init.o(.rodata*); - BUILD_DIR/src/game/sound_init.o(.rodata*); - BUILD_DIR/src/game/level_update.o(.rodata*); - BUILD_DIR/src/game/interaction.o(.rodata*); - BUILD_DIR/src/game/mario.o(.rodata*); - BUILD_DIR/src/game/mario_step.o(.rodata*); - BUILD_DIR/src/game/mario_actions_cutscene.o(.rodata*); - BUILD_DIR/src/game/mario_actions_automatic.o(.rodata*); - BUILD_DIR/src/game/mario_actions_stationary.o(.rodata*); - BUILD_DIR/src/game/mario_actions_moving.o(.rodata*); - BUILD_DIR/src/game/mario_actions_airborne.o(.rodata*); - BUILD_DIR/src/game/mario_actions_submerged.o(.rodata*); - BUILD_DIR/src/game/mario_actions_object.o(.rodata*); - BUILD_DIR/src/game/mario_misc.o(.rodata*); - BUILD_DIR/src/game/area.o(.rodata*); - BUILD_DIR/src/game/rendering_graph_node.o(.rodata*); - BUILD_DIR/src/game/camera.o(.rodata*); - BUILD_DIR/src/game/object_list_processor.o(.rodata*); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_helpers.o(.rodata*); -#endif - BUILD_DIR/src/game/behavior_actions.o(.rodata*); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.rodata*); - BUILD_DIR/src/game/spawn_object.o(.rodata*); -#endif - BUILD_DIR/libultra.a:__osDisableInt.o(.text) - BUILD_DIR/libultra.a:__osRestoreInt.o(.text) - BUILD_DIR/src/game/spawn_sound.o(.rodata*); - BUILD_DIR/src/game/debug.o(.rodata*); - BUILD_DIR/src/game/screen_transition.o(.rodata*); - BUILD_DIR/src/game/shadow.o(.rodata*); - BUILD_DIR/src/game/skybox.o(.rodata*); - BUILD_DIR/src/game/moving_texture.o(.rodata*); - BUILD_DIR/src/game/geo_misc.o(.rodata*); - BUILD_DIR/src/game/paintings.o(.rodata*); - BUILD_DIR/src/game/print.o(.rodata*); - BUILD_DIR/src/game/ingame_menu.o(.rodata*); - BUILD_DIR/src/game/envfx_snow.o(.rodata*); - BUILD_DIR/src/game/envfx_bubbles.o(.rodata*); - BUILD_DIR/src/game/macro_special_objects.o(.rodata*); - BUILD_DIR/src/game/hud.o(.rodata*); - BUILD_DIR/src/game/obj_behaviors.o(.rodata*); - BUILD_DIR/src/game/obj_behaviors_2.o(.rodata*); -#if defined(VERSION_JP) || defined(VERSION_US) BUILD_DIR/src/game*.o(.rodata*); -#endif - BUILD_DIR/src/audio/synthesis.o(.rodata*); - BUILD_DIR/src/audio/heap.o(.rodata*); - BUILD_DIR/src/audio/load.o(.rodata*); -#ifdef VERSION_SH - BUILD_DIR/src/audio/unk_shindou_audio_file.o(.rodata*); -#endif - BUILD_DIR/src/audio/playback.o(.rodata*); - BUILD_DIR/src/audio/effects.o(.rodata*); - BUILD_DIR/src/audio/seqplayer.o(.rodata*); - BUILD_DIR/src/audio/external.o(.rodata*); - BUILD_DIR/src/audio/port_eu.o(.rodata*); BUILD_DIR/src/audio*.o(.rodata*); -#if defined(VERSION_EU) || defined(VERSION_SH) - BUILD_DIR/libultra.a:_Printf.o(.rodata*); -#endif + */libultra_rom.a:*.o(.rodata*); + */libhvqm2.a:*.o(.rodata*); - BUILD_DIR/libultra.a:guPerspectiveF.o(.rodata*); - BUILD_DIR/libultra.a:llconv.o(.rodata*); - BUILD_DIR/libultra.a:cosf.o(.rodata*); - BUILD_DIR/libultra.a:sinf.o(.rodata*); - BUILD_DIR/libultra.a:guRotateF.o(.rodata*); - -#if defined(VERSION_EU) || defined(VERSION_SH) - BUILD_DIR/libultra.a:_Litob.o(.rodata*); - BUILD_DIR/libultra.a:_Ldtob.o(.rodata*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.rodata*); - BUILD_DIR/libultra.a:__osDevMgrMain.o(.rodata*); - BUILD_DIR/libultra.a:NaN.o(.rodata*); -#else - BUILD_DIR/libultra.a:_Printf.o(.rodata*); - BUILD_DIR/libultra.a:__osExceptionPreamble.o(.rodata*); - BUILD_DIR/libultra.a:NaN.o(.rodata*); - BUILD_DIR/libultra.a:_Litob.o(.rodata*); - BUILD_DIR/libultra.a:_Ldtob.o(.rodata*); -#endif - - BUILD_DIR/libultra.a:osSetIntMask.o(.rodata*); - BUILD_DIR/libultra.a:guLookAtRef.o(.rodata*); /* Fast3DEX2 only */ -#ifndef VERSION_EU - BUILD_DIR/libultra.a:*.o(.rodata*); -#endif -#ifdef VERSION_SH - BUILD_DIR/src/audio/load.o(.data*); -#endif BUILD_DIR/lib/rsp.o(.rodata*); + lib/PR/hvqm/hvqm2sp1.o(.rodata*); + lib/PR/hvqm/hvqm2sp2.o(.rodata*); } END_SEG(main) BEGIN_NOLOAD(main) { - BUILD_DIR/src/game/crash_screen.o(.bss*); - BUILD_DIR/src/game/main.o(.bss*); - BUILD_DIR/src/game/game_init.o(.bss*); - BUILD_DIR/src/game/sound_init.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/src/game/rumble_init.o(.bss*); -#endif - BUILD_DIR/src/game/level_update.o(.bss*); - BUILD_DIR/src/game/interaction.o(.bss*); - BUILD_DIR/src/game/mario.o(.bss*); - BUILD_DIR/src/game/mario_actions_cutscene.o(.bss*); - BUILD_DIR/src/game/mario_actions_moving.o(.bss*); - BUILD_DIR/src/game/mario_actions_submerged.o(.bss*); - BUILD_DIR/src/game/mario_misc.o(.bss*); - BUILD_DIR/src/game/memory.o(.bss*); - BUILD_DIR/src/game/save_file.o(.bss*); - BUILD_DIR/src/game/area.o(.bss*); - BUILD_DIR/src/game/rendering_graph_node.o(.bss*); - BUILD_DIR/src/game/profiler.o(.bss*); - BUILD_DIR/src/game/camera.o(.bss*); - BUILD_DIR/src/game/object_list_processor.o(.bss*); -#ifndef VERSION_EU - BUILD_DIR/src/game/object_helpers.o(.bss*); -#endif - BUILD_DIR/src/game/behavior_actions.o(.bss*); - BUILD_DIR/src/game/debug.o(.bss*); - BUILD_DIR/src/game/shadow.o(.bss*); - BUILD_DIR/src/game/skybox.o(.bss*); - BUILD_DIR/src/game/moving_texture.o(.bss*); - BUILD_DIR/src/game/geo_misc.o(.bss*); - BUILD_DIR/src/game/paintings.o(.bss*); - BUILD_DIR/src/game/print.o(.bss*); - BUILD_DIR/src/game/ingame_menu.o(.bss*); - BUILD_DIR/src/game/envfx_snow.o(.bss*); - BUILD_DIR/src/game/envfx_bubbles.o(.bss*); - BUILD_DIR/src/game/macro_special_objects.o(.bss*) - BUILD_DIR/src/game/hud.o(.bss*); - BUILD_DIR/src/game/obj_behaviors.o(.bss*); - BUILD_DIR/src/game/obj_behaviors_2.o(.bss*); -#ifndef VERSION_EU BUILD_DIR/src/game*.o(.bss*); -#endif - BUILD_DIR/src/audio/external.o(.bss*); -#ifdef VERSION_EU - BUILD_DIR/src/audio/port_eu.o(.bss*); -#endif -#ifdef VERSION_SH - BUILD_DIR/src/audio/globals_start.o(.bss*); - BUILD_DIR/src/audio/synthesis.o(.bss*); - BUILD_DIR/src/audio/heap.o(.bss*); - BUILD_DIR/src/audio/load.o(.bss*); - BUILD_DIR/src/audio/data.o(.bss*); -#endif + BUILD_DIR/src/game*.o(.sbss*); + BUILD_DIR/src/audio*.o(.bss*); + BUILD_DIR/src/audio*.o(.sbss*); + + */libultra_rom.a:*.o(.bss*); + */libultra_rom.a:*.o(.sbss*); -#if defined(VERSION_EU) || defined(VERSION_SH) - BUILD_DIR/libultra.a:osInitialize.o(.bss*); - BUILD_DIR/libultra.a:osSetEventMesg.o(.bss*); - BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.bss*); - BUILD_DIR/libultra.a:osCreateViManager.o(.bss*); - BUILD_DIR/libultra.a:osCreatePiManager.o(.bss*); - BUILD_DIR/libultra.a:osContStartReadData.o(.bss*); - BUILD_DIR/libultra.a:osContInit.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:motor.o(.bss*); -#endif - BUILD_DIR/libultra.a:guRotateF.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osCartRomInit.o(.bss*); -#endif -#ifndef VERSION_SH - BUILD_DIR/libultra.a:leointerrupt.o(.bss*); -#endif - BUILD_DIR/libultra.a:osTimer.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osLeoDiskInit.o(.bss*) -#endif - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.bss*); - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:osPfsIsPlug.o(.bss*); -#endif - BUILD_DIR/libultra.a:osEepromWrite.o(.bss*); - BUILD_DIR/libultra.a:kdebugserver.o(.bss*); -#ifdef VERSION_SH - BUILD_DIR/libultra.a:leointerrupt.o(.bss*); -#endif -#ifndef VERSION_SH - BUILD_DIR/libultra.a:osLeoDiskInit.o(.bss*) -#endif - BUILD_DIR/libultra.a:_Printf.o(.bss*); - BUILD_DIR/libultra.a:osAiSetNextBuffer.o(.bss*); - BUILD_DIR/libultra.a:EU_D_802f4330.o(.bss*); -#else - BUILD_DIR/libultra.a:osSetEventMesg.o(.bss*); - BUILD_DIR/libultra.a:osSpTaskLoadGo.o(.bss*); - BUILD_DIR/libultra.a:osCreateViManager.o(.bss*); - BUILD_DIR/libultra.a:osCreatePiManager.o(.bss*); - BUILD_DIR/libultra.a:osInitialize.o(.bss*); - BUILD_DIR/libultra.a:osContStartReadData.o(.bss*); - BUILD_DIR/libultra.a:osContInit.o(.bss*); - BUILD_DIR/libultra.a:guRotateF.o(.bss*); - BUILD_DIR/libultra.a:osTimer.o(.bss*); - BUILD_DIR/libultra.a:_Printf.o(.bss*); - BUILD_DIR/libultra.a:__osPiCreateAccessQueue.o(.bss*); - BUILD_DIR/libultra.a:__osSiCreateAccessQueue.o(.bss*); - BUILD_DIR/libultra.a:osEepromWrite.o(.bss*); - BUILD_DIR/libultra.a:kdebugserver_stack.o(.bss*); - BUILD_DIR/libultra.a:kdebugserver.o(.bss*); -#endif - BUILD_DIR/libultra.a:*.o(.bss*); . = ALIGN(0x8); } END_NOLOAD(main) @@ -773,61 +175,18 @@ SECTIONS BEGIN_SEG(engine, .) { - BUILD_DIR/src/engine/math_util.o(.text); - BUILD_DIR/src/engine/graph_node.o(.text); - BUILD_DIR/src/engine/graph_node_manager.o(.text); - BUILD_DIR/src/engine/geo_layout.o(.text); - BUILD_DIR/src/engine/level_script.o(.text); - BUILD_DIR/src/engine/surface_collision.o(.text); - BUILD_DIR/src/engine/surface_load.o(.text); - BUILD_DIR/src/engine/behavior_script.o(.text); -#ifdef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.text); - BUILD_DIR/src/game/spawn_object.o(.text); - BUILD_DIR/src/game/object_helpers.o(.text); -#endif BUILD_DIR/src/engine*.o(.text); /* data */ - BUILD_DIR/src/engine/graph_node.o(.data*); - BUILD_DIR/src/engine/graph_node_manager.o(.data*); - BUILD_DIR/src/engine/math_util.o(.data*); - BUILD_DIR/src/engine/geo_layout.o(.data*); - BUILD_DIR/src/engine/level_script.o(.data*); - BUILD_DIR/src/engine/behavior_script.o(.data*); -#ifdef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.data*); - BUILD_DIR/src/game/spawn_object.o(.data*); - BUILD_DIR/src/game/object_helpers.o(.data*); -#endif BUILD_DIR/src/engine*.o(.data*); + BUILD_DIR/src/engine*.o(.sdata*); /* rodata */ - BUILD_DIR/src/engine/math_util.o(.rodata*); - BUILD_DIR/src/engine/level_script.o(.rodata*); - BUILD_DIR/src/engine/surface_collision.o(.rodata*); - BUILD_DIR/src/engine/surface_load.o(.rodata*); -#ifdef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.rodata*); - BUILD_DIR/src/game/spawn_object.o(.rodata*); - BUILD_DIR/src/game/object_helpers.o(.rodata*); -#endif BUILD_DIR/src/engine*.o(.rodata*); } END_SEG(engine) BEGIN_NOLOAD(engine) { - BUILD_DIR/src/engine/math_util.o(.bss*); - BUILD_DIR/src/engine/geo_layout.o(.bss*); - BUILD_DIR/src/engine/level_script.o(.bss*); - BUILD_DIR/src/engine/surface_collision.o(.bss*); - BUILD_DIR/src/engine/surface_load.o(.bss*); - BUILD_DIR/src/engine/behavior_script.o(.bss*); -#ifdef VERSION_EU - BUILD_DIR/src/game/object_collision.o(.bss*); - BUILD_DIR/src/game/spawn_object.o(.bss*); - BUILD_DIR/src/game/object_helpers.o(.bss*); -#endif BUILD_DIR/src/engine*.o(.bss*); - . = ALIGN(0x40); + . = ALIGN(0x100); } END_NOLOAD(engine) @@ -853,12 +212,12 @@ SECTIONS } END_SEG(entry) - /* load MIO0 and level data */ - MIO0_SEG(segment2, 0x02000000) + /* load YAY0 and level data */ + YAY0_SEG(segment2, 0x02000000) #ifdef VERSION_EU - MIO0_EU_SEG(translation_en, 0x19000000) - MIO0_EU_SEG(translation_fr, 0x19000000) - MIO0_EU_SEG(translation_de, 0x19000000) + YAY0_EU_SEG(translation_en, 0x19000000) + YAY0_EU_SEG(translation_fr, 0x19000000) + YAY0_EU_SEG(translation_de, 0x19000000) #endif /* mario actor group */ @@ -991,13 +350,13 @@ SECTIONS END_SEG(intro) BEGIN_SEG(intro_segment_7, 0x07000000) { - BUILD_DIR/levels/intro/leveldata.mio0.o(.data); + BUILD_DIR/levels/intro/leveldata.szp.o(.data); . = ALIGN(0x10); } END_SEG(intro_segment_7) - MIO0_SEG(debug_level_select, 0x07000000) - MIO0_SEG(title_screen_bg, 0x0A000000) + YAY0_SEG(debug_level_select, 0x07000000) + YAY0_SEG(title_screen_bg, 0x0A000000) /* 271B20-2A42A0 [32780] */ BEGIN_SEG(gd_dynlists, 0x04000000) @@ -1032,7 +391,7 @@ SECTIONS END_SEG(menu) BEGIN_SEG(menu_segment_7, 0x07000000) { - BUILD_DIR/levels/menu/leveldata.mio0.o(.data); + BUILD_DIR/levels/menu/leveldata.szp.o(.data); . = ALIGN(0x10); } END_SEG(menu_segment_7) @@ -1043,31 +402,31 @@ SECTIONS } END_SEG(scripts) - MIO0_SEG(water_skybox, 0x0A000000) - MIO0_SEG(ccm_skybox, 0x0A000000) - MIO0_SEG(clouds_skybox, 0x0A000000) - MIO0_SEG(bitfs_skybox, 0x0A000000) - MIO0_SEG(wdw_skybox, 0x0A000000) - MIO0_SEG(cloud_floor_skybox, 0x0A000000) - MIO0_SEG(ssl_skybox, 0x0A000000) - MIO0_SEG(bbh_skybox, 0x0A000000) - MIO0_SEG(bidw_skybox, 0x0A000000) - MIO0_SEG(bits_skybox, 0x0A000000) + YAY0_SEG(water_skybox, 0x0A000000) + YAY0_SEG(ccm_skybox, 0x0A000000) + YAY0_SEG(clouds_skybox, 0x0A000000) + YAY0_SEG(bitfs_skybox, 0x0A000000) + YAY0_SEG(wdw_skybox, 0x0A000000) + YAY0_SEG(cloud_floor_skybox, 0x0A000000) + YAY0_SEG(ssl_skybox, 0x0A000000) + YAY0_SEG(bbh_skybox, 0x0A000000) + YAY0_SEG(bidw_skybox, 0x0A000000) + YAY0_SEG(bits_skybox, 0x0A000000) // Texture bins - MIO0_SEG(fire, 0x09000000) - MIO0_SEG(spooky, 0x09000000) - MIO0_SEG(generic, 0x09000000) - MIO0_SEG(water, 0x09000000) - MIO0_SEG(sky, 0x09000000) - MIO0_SEG(snow, 0x09000000) - MIO0_SEG(cave, 0x09000000) - MIO0_SEG(machine, 0x09000000) - MIO0_SEG(mountain, 0x09000000) - MIO0_SEG(grass, 0x09000000) - MIO0_SEG(outside, 0x09000000) - MIO0_SEG(inside, 0x09000000) - MIO0_SEG(effect, 0x0B000000) + YAY0_SEG(fire, 0x09000000) + YAY0_SEG(spooky, 0x09000000) + YAY0_SEG(generic, 0x09000000) + YAY0_SEG(water, 0x09000000) + YAY0_SEG(sky, 0x09000000) + YAY0_SEG(snow, 0x09000000) + YAY0_SEG(cave, 0x09000000) + YAY0_SEG(machine, 0x09000000) + YAY0_SEG(mountain, 0x09000000) + YAY0_SEG(grass, 0x09000000) + YAY0_SEG(outside, 0x09000000) + YAY0_SEG(inside, 0x09000000) + YAY0_SEG(effect, 0x0B000000) #define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8) #define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) STANDARD_LEVEL(folder) diff --git a/src/audio/external.c b/src/audio/external.c index eb5c3d7e1..9a9536cc4 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -374,7 +374,6 @@ s32 D_SH_80343CF0; s8 D_SH_80343CF8_pad[0x8]; struct UnkStruct80343D00 D_SH_80343D00; s8 D_SH_8034DC8_pad[0x8]; -OSPiHandle DriveRomHandle; // used in osDriveRomInit.c. Why here? s8 D_SH_80343E48_pad[0x8]; #endif @@ -788,12 +787,12 @@ struct SPTask *create_next_audio_frame_task(void) { 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_boot = rspbootTextStart; + task->ucode_boot_size = (u8 *) rspbootTextEnd - (u8 *) rspbootTextStart; + task->ucode = aspMainTextStart; task->ucode_size = 0x800; // (this size is ignored) - task->ucode_data = rspAspMainDataStart; - task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64); + task->ucode_data = aspMainDataStart; + task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * sizeof(u64); task->dram_stack = NULL; task->dram_stack_size = 0; task->output_buff = NULL; diff --git a/src/audio/load.c b/src/audio/load.c index ba3323b4b..b1d9cbade 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1255,9 +1255,6 @@ s32 func_sh_802f3dd0(OSIoMesg *m, s32 pri, s32 direction, uintptr_t devAddr, voi case 2: handle = osCartRomInit(); break; - case 3: - handle = osDriveRomInit(); - break; default: return 0; } diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index 636d0143d..3cabfc1aa 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -114,12 +114,12 @@ struct SPTask *create_next_audio_frame_task(void) { 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_data = rspAspMainDataStart; + task->ucode_boot = rspbootTextStart; + task->ucode_boot_size = (u8 *) rspbootTextEnd - (u8 *) rspbootTextStart; + task->ucode = aspMainTextStart; + task->ucode_data = aspMainDataStart; task->ucode_size = 0x800; // (this size is ignored) - task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64); + task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * sizeof(u64); task->dram_stack = NULL; task->dram_stack_size = 0; task->output_buff = NULL; diff --git a/src/audio/unk_shindou_audio_file.c b/src/audio/unk_shindou_audio_file.c index c2ed31590..5e7908bd0 100644 --- a/src/audio/unk_shindou_audio_file.c +++ b/src/audio/unk_shindou_audio_file.c @@ -115,12 +115,12 @@ struct SPTask *func_sh_802f5a80(void) { task = &gAudioTask->task.t; task->type = M_AUDTASK; task->flags = flags; - task->ucode_boot = rspF3DBootStart; - task->ucode_boot_size = (u8 *) rspF3DStart - (u8 *) rspF3DBootStart; - task->ucode = rspAspMainStart; - task->ucode_data = rspAspMainDataStart; + task->ucode_boot = rspbootTextStart; + task->ucode_boot_size = (u8 *) rspbootTextEnd - (u8 *) rspbootTextStart; + task->ucode = aspMainTextStart; + task->ucode_data = aspMainDataStart; task->ucode_size = 0x1000; - task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64); + task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * sizeof(u64); task->dram_stack = NULL; task->dram_stack_size = 0; task->output_buff = NULL; diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 884e9b459..c1aa68b4a 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -275,7 +275,7 @@ static void level_cmd_load_raw(void) { sCurrentCmd = CMD_NEXT; } -static void level_cmd_load_mio0(void) { +static void level_cmd_load_yay0(void) { load_segment_decompress(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8)); sCurrentCmd = CMD_NEXT; } @@ -295,7 +295,7 @@ static void level_cmd_load_mario_head(void) { sCurrentCmd = CMD_NEXT; } -static void level_cmd_load_mio0_texture(void) { +static void level_cmd_load_yay0_texture(void) { load_segment_decompress_heap(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8)); sCurrentCmd = CMD_NEXT; } @@ -779,9 +779,9 @@ static void (*LevelScriptJumpTable[])(void) = { /*15*/ level_cmd_pop_pool_state, /*16*/ level_cmd_load_to_fixed_address, /*17*/ level_cmd_load_raw, - /*18*/ level_cmd_load_mio0, + /*18*/ level_cmd_load_yay0, /*19*/ level_cmd_load_mario_head, - /*1A*/ level_cmd_load_mio0_texture, + /*1A*/ level_cmd_load_yay0_texture, /*1B*/ level_cmd_init_level, /*1C*/ level_cmd_clear_level, /*1D*/ level_cmd_alloc_level_pool, diff --git a/lib/src/_Ldtob.c b/src/game/_Ldtob.c similarity index 99% rename from lib/src/_Ldtob.c rename to src/game/_Ldtob.c index 3656bd45a..182a5e7bd 100644 --- a/lib/src/_Ldtob.c +++ b/src/game/_Ldtob.c @@ -1,4 +1,3 @@ -#include "libultra_internal.h" #include #include #include diff --git a/lib/src/_Litob.c b/src/game/_Litob.c similarity index 97% rename from lib/src/_Litob.c rename to src/game/_Litob.c index 58ed081ff..3eb3f880c 100644 --- a/lib/src/_Litob.c +++ b/src/game/_Litob.c @@ -1,4 +1,3 @@ -#include "libultra_internal.h" #include #include #include "printf.h" diff --git a/lib/src/_Printf.c b/src/game/_Printf.c similarity index 96% rename from lib/src/_Printf.c rename to src/game/_Printf.c index e42bf0428..6851013dc 100644 --- a/lib/src/_Printf.c +++ b/src/game/_Printf.c @@ -1,4 +1,3 @@ -#include "libultra_internal.h" #include #include #include "printf.h" @@ -43,19 +42,9 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char sp78.size = 0; while (TRUE) { fmt_ptr = (u8 *) fmt; -#ifdef VERSION_SH - // new version: don't point fmt_ptr beyond NUL character while ((c = *fmt_ptr) != 0 && c != '%') { fmt_ptr++; } -#else - while ((c = *fmt_ptr++) > 0) { - if (c == '%') { - fmt_ptr--; - break; - } - } -#endif _PROUT(dst, fmt, fmt_ptr - (u8 *) fmt); if (c == 0) { return sp78.size; diff --git a/src/game/crash_screen.c b/src/game/crash_screen.c index 5f384de48..3f1a20dd3 100644 --- a/src/game/crash_screen.c +++ b/src/game/crash_screen.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -6,7 +7,7 @@ #if defined(TARGET_N64) && (defined(VERSION_EU) || defined(VERSION_SH)) -#include "lib/src/printf.h" +#include "printf.h" u8 gCrashScreenCharToGlyph[128] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, diff --git a/src/game/decompress.h b/src/game/decompress.h deleted file mode 100644 index 653b1cd13..000000000 --- a/src/game/decompress.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef DECOMPRESS_H -#define DECOMPRESS_H - -void decompress(void *mio0, void *dest); - -#endif // DECOMPRESS_H diff --git a/src/game/game_init.c b/src/game/game_init.c index b63346881..2c0da171a 100644 --- a/src/game/game_init.c +++ b/src/game/game_init.c @@ -221,11 +221,25 @@ void create_task_structure(void) { gGfxSPTask->msgqueue = &D_80339CB8; gGfxSPTask->msg = (OSMesg) 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.ucode_boot = rspbootTextStart; + gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspbootTextEnd - (u8 *) rspbootTextStart); gGfxSPTask->task.t.flags = 0; - gGfxSPTask->task.t.ucode = rspF3DStart; - gGfxSPTask->task.t.ucode_data = rspF3DDataStart; +#ifdef F3DZEX_GBI_2 + gGfxSPTask->task.t.ucode = gspF3DZEX2_PosLight_fifoTextStart; + gGfxSPTask->task.t.ucode_data = gspF3DZEX2_PosLight_fifoDataStart; +#elif F3DEX_GBI_2 + gGfxSPTask->task.t.ucode = gspF3DEX2_fifoTextStart; + gGfxSPTask->task.t.ucode_data = gspF3DEX2_fifoDataStart; +#elif F3DEX_GBI + gGfxSPTask->task.t.ucode = gspF3DEX_fifoTextStart; + gGfxSPTask->task.t.ucode_data = gspF3DEX_fifoDataStart; +#elif SUPER3D_GBI + gGfxSPTask->task.t.ucode = gspSuper3D_fifoTextStart; + gGfxSPTask->task.t.ucode_data = gspSuper3D_fifoDataStart; +#else + gGfxSPTask->task.t.ucode = gspFast3D_fifoTextStart; + gGfxSPTask->task.t.ucode_data = gspFast3D_fifoDataStart; +#endif 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; @@ -576,7 +590,7 @@ void setup_game_memory(void) { set_segment_base_addr(24, (void *) D_80339CF4); func_80278A78(&gDemo, gDemoInputs, D_80339CF4); load_segment(0x10, _entrySegmentRomStart, _entrySegmentRomEnd, MEMORY_POOL_LEFT); - load_segment_decompress(2, _segment2_mio0SegmentRomStart, _segment2_mio0SegmentRomEnd); + load_segment_decompress(2, _segment2_yay0SegmentRomStart, _segment2_yay0SegmentRomEnd); } // main game loop thread. runs forever as long as the game diff --git a/src/game/level_update.c b/src/game/level_update.c index 4ecb90243..1be745dcb 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1253,16 +1253,16 @@ s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) { s16 var = eu_get_language(); switch (var) { case LANGUAGE_ENGLISH: - load_segment_decompress(0x19, _translation_en_mio0SegmentRomStart, - _translation_en_mio0SegmentRomEnd); + load_segment_decompress(0x19, _translation_en_yay0SegmentRomStart, + _translation_en_yay0SegmentRomEnd); break; case LANGUAGE_FRENCH: - load_segment_decompress(0x19, _translation_fr_mio0SegmentRomStart, - _translation_fr_mio0SegmentRomEnd); + load_segment_decompress(0x19, _translation_fr_yay0SegmentRomStart, + _translation_fr_yay0SegmentRomEnd); break; case LANGUAGE_GERMAN: - load_segment_decompress(0x19, _translation_de_mio0SegmentRomStart, - _translation_de_mio0SegmentRomEnd); + load_segment_decompress(0x19, _translation_de_yay0SegmentRomStart, + _translation_de_yay0SegmentRomEnd); break; } #endif diff --git a/src/game/main.c b/src/game/main.c index 3a7a364d7..d73863935 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -1,4 +1,5 @@ #include +#include #include #include "sm64.h" @@ -415,22 +416,22 @@ void turn_off_audio(void) { * Initialize hardware, start main thread, then idle. */ void thread1_idle(UNUSED void *arg) { -#if defined(VERSION_US) || defined(VERSION_SH) - s32 sp24 = osTvType; -#endif osCreateViManager(OS_PRIORITY_VIMGR); -#if defined(VERSION_US) || defined(VERSION_SH) - if (sp24 == TV_TYPE_NTSC) { + switch ( osTvType ) { + case OS_TV_NTSC: + // NTSC osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]); - } else { - osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]); - } -#elif defined(VERSION_JP) - osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]); -#else // VERSION_EU - osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]); -#endif + break; + case OS_TV_MPAL: + // MPAL + osViSetMode(&osViModeTable[OS_VI_MPAL_LAN1]); + break; + case OS_TV_PAL: + // PAL + osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]); + break; + } osViBlack(TRUE); osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON); osViSetSpecialFeatures(OS_VI_GAMMA_OFF); diff --git a/src/game/main.h b/src/game/main.h index 58bd659e1..a3e1e92d3 100644 --- a/src/game/main.h +++ b/src/game/main.h @@ -27,7 +27,7 @@ extern OSThread gSoundThread; #ifdef VERSION_SH extern OSThread gRumblePakThread; -extern s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet +extern OSPfs gRumblePakPfs; #endif extern OSMesgQueue gPIMesgQueue; diff --git a/src/game/memory.c b/src/game/memory.c index cea8e45fd..31b68bde3 100644 --- a/src/game/memory.c +++ b/src/game/memory.c @@ -5,7 +5,7 @@ #define INCLUDED_FROM_MEMORY_C #include "buffers/buffers.h" -#include "decompress.h" +#include "slidec.h" #include "game_init.h" #include "main.h" #include "memory.h" @@ -332,7 +332,7 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) { dma_read(compressed, srcStart, srcEnd); dest = main_pool_alloc(*size, MEMORY_POOL_LEFT); if (dest != NULL) { - decompress(compressed, dest); + slidstart(compressed, dest); set_segment_base_addr(segment, dest); main_pool_free(compressed); } else { @@ -350,7 +350,7 @@ void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) { if (compressed != NULL) { dma_read(compressed, srcStart, srcEnd); - decompress(compressed, gDecompressionHeap); + slidstart(compressed, gDecompressionHeap); set_segment_base_addr(segment, gDecompressionHeap); main_pool_free(compressed); } else { diff --git a/src/game/print.c b/src/game/print.c index e59722715..e1f9ec267 100644 --- a/src/game/print.c +++ b/src/game/print.c @@ -1,5 +1,4 @@ -#include -#include +#include #include "config.h" #include "game_init.h" diff --git a/lib/src/printf.h b/src/game/printf.h similarity index 100% rename from lib/src/printf.h rename to src/game/printf.h diff --git a/src/game/profiler.c b/src/game/profiler.c index 9f968c6a7..c834d739e 100644 --- a/src/game/profiler.c +++ b/src/game/profiler.c @@ -1,6 +1,4 @@ -#include -#include -#include +#include #include "sm64.h" #include "profiler.h" diff --git a/src/game/rumble_init.c b/src/game/rumble_init.c index a708a5c19..effbf0bc5 100644 --- a/src/game/rumble_init.c +++ b/src/game/rumble_init.c @@ -9,7 +9,7 @@ OSThread gRumblePakThread; -s32 gRumblePakPfs; // Actually an OSPfs but we don't have that header yet +OSPfs gRumblePakPfs; s8 D_SH_8031D8F8[0x60]; @@ -26,11 +26,6 @@ s32 sRumblePakActive = 0; s32 sRumblePakErrorCount = 0; s32 gRumblePakTimer = 0; -// These void* are OSPfs* but we don't have that header -extern s32 osMotorStop(void *); -extern s32 osMotorStart(void *); -extern u32 osMotorInit(OSMesgQueue *, void *, s32); - void init_rumble_pak_scheduler_queue(void) { osCreateMesgQueue(&gRumblePakSchedulerMesgQueue, gRumblePakSchedulerMesgBuf, 1); osSendMesg(&gRumblePakSchedulerMesgQueue, (OSMesg) 0, OS_MESG_NOBLOCK); diff --git a/src/game/slidec.h b/src/game/slidec.h new file mode 100644 index 000000000..ae05384e2 --- /dev/null +++ b/src/game/slidec.h @@ -0,0 +1,6 @@ +#ifndef SLIDEC_H +#define SLIDEC_H + +void slidstart(unsigned char*, unsigned char *); + +#endif // SLIDEC_H diff --git a/tools/Makefile b/tools/Makefile index ef5a9909f..1761c641f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -7,7 +7,7 @@ CC := gcc CXX := g++ CFLAGS := -I . -Wall -Wextra -Wno-unused-parameter -pedantic -O2 -s LDFLAGS := -lm -ALL_PROGRAMS := armips n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv +ALL_PROGRAMS := armips n64graphics n64graphics_ci mio0 slienc n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv LIBAUDIOFILE := audiofile/libaudiofile.a # Only build armips from tools if it is not found on the system @@ -27,6 +27,9 @@ n64graphics_ci_SOURCES := n64graphics_ci_dir/n64graphics_ci.c n64graphics_ci_dir mio0_SOURCES := libmio0.c mio0_CFLAGS := -DMIO0_STANDALONE +slienc_SOURCES := slienc.c +slienc_CFLAGS := + n64cksum_SOURCES := n64cksum.c utils.c n64cksum_CFLAGS := -DN64CKSUM_STANDALONE diff --git a/tools/mips64-elf-ld b/tools/mips64-elf-ld new file mode 100755 index 000000000..d5f52b075 Binary files /dev/null and b/tools/mips64-elf-ld differ diff --git a/tools/slienc b/tools/slienc new file mode 100755 index 000000000..fedaa169b Binary files /dev/null and b/tools/slienc differ diff --git a/tools/slienc.c b/tools/slienc.c new file mode 100644 index 000000000..e10fefbae --- /dev/null +++ b/tools/slienc.c @@ -0,0 +1,319 @@ +#include +#include +#include + +// Yay0 "slienc" compression tool +// originally decompiled by SimonTime + +int main(int argc, const char **argv, const char **envp); +void encode(); +void search(unsigned int a1, int a2, int *a3, unsigned int *a4); +int mischarsearch(unsigned char *a1, int a2, unsigned char *a3, int a4); +void initskip(unsigned char *a1, int a2); +void writeshort(short a1); +void writeint4(int a1); + +unsigned short skip[256]; // idb +int cp; // weak +int ndp; // weak +FILE *fp; // idb +unsigned char *def; +unsigned short *pol; +int pp; // weak +int insize; // idb +int ncp; // weak +int npp; // weak +unsigned char *bz; +int dp; // idb +unsigned int *cmd; + +int main(int argc, const char **argv, const char **envp) +{ + char src[999]; + char dest[999]; + + + if (argc < 3) + { + fprintf(stderr, "slienc [infile] [outfile]\n"); + return 1; + } + + strcpy(src, argv[1]); + strcpy(dest, argv[2]); + + if ((fp = fopen(src, "rb")) == NULL) + { + fprintf(stderr, "FILE OPEN ERROR![%s]\n", src); + return 1; + } + + fseek(fp, 0, SEEK_END); + insize = ftell(fp); + fseek(fp, 0, SEEK_SET); + + bz = malloc(insize); + fread(bz, 1, insize, fp); + fclose(fp); + + for (int i = 0; src[i]; i++) + { + if (src[i] == '.') + { + src[i] = 0; + break; + } + } + + if ((fp = fopen(dest, "wb")) == NULL) + { + fprintf(stderr, "FILE CREATE ERROR![%s]\n", dest); + exit(1); + } + + encode(); + + fprintf(fp, "Yay0"); + + writeint4(insize); + + writeint4(4 * cp + 16); + writeint4(2 * pp + 4 * cp + 16); + + for (int i = 0; i < cp; i++) + writeint4(cmd[i]); + + for (int i = 0; i < pp; i++) + writeshort(pol[i]); + + fwrite(def, 1u, dp, fp); + fclose(fp); + + return 0; +} + +void encode() +{ + unsigned int v0; // esi + unsigned int v1; // edi + int v2; // edx + int v3; // ebx + int v4; // edx + char v5; // [esp+Ch] [ebp-18h] + unsigned int v6; // [esp+10h] [ebp-14h] + unsigned int v7; // [esp+14h] [ebp-10h] + int v8; // [esp+18h] [ebp-Ch] + unsigned int a4; // [esp+1Ch] [ebp-8h] + int a3; // [esp+20h] [ebp-4h] + + dp = 0; + pp = 0; + cp = 0; + npp = 4096; + ndp = 4096; + ncp = 4096; + cmd = calloc(0x4000u, 1u); + pol = malloc(2 * npp); + def = malloc(4 * ndp); + v0 = 0; + v6 = 1024; + v1 = 2147483648; + while ( insize > v0 ) + { + if ( v6 < v0 ) + v6 += 1024; + search(v0, insize, &a3, &a4); + if ( a4 <= 2 ) + { + cmd[cp] |= v1; + def[dp++] = bz[v0++]; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + } + else + { + search(v0 + 1, insize, &v8, &v7); + if ( v7 > a4 + 1 ) + { + cmd[cp] |= v1; + def[dp++] = bz[v0++]; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + v1 >>= 1; + if ( !v1 ) + { + v1 = 2147483648; + v2 = cp++; + if ( cp == ncp ) + { + ncp = v2 + 1025; + cmd = realloc(cmd, 4 * (v2 + 1025)); + } + cmd[cp] = 0; + } + a4 = v7; + a3 = v8; + } + v3 = v0 - a3 - 1; + a3 = v0 - a3 - 1; + v5 = a4; + if ( a4 > 0x11 ) + { + pol[pp++] = v3; + def[dp++] = v5 - 18; + if ( ndp == dp ) + { + ndp = dp + 4096; + def = realloc(def, dp + 4096); + } + } + else + { + pol[pp++] = v3 | (((short)a4 - 2) << 12); + } + if ( npp == pp ) + { + npp = pp + 4096; + pol = realloc(pol, 2 * (pp + 4096)); + } + v0 += a4; + } + v1 >>= 1; + if ( !v1 ) + { + v1 = 2147483648; + v4 = cp++; + if ( cp == ncp ) + { + ncp = v4 + 1025; + cmd = realloc(cmd, 4 * (v4 + 1025)); + } + cmd[cp] = 0; + } + } + if ( v1 != 0x80000000 ) + ++cp; + fprintf(stderr, "IN=%d OUT=%d\n", insize, dp + 2 * pp + 4 * cp + 16); +} + +void search(unsigned int a1, int a2, int *a3, unsigned int *a4) +{ + unsigned int v4; // ebx + unsigned int v5; // esi + unsigned int *v6; // edi + unsigned int v7; // [esp+Ch] [ebp-10h] + int v8; // [esp+14h] [ebp-8h] + unsigned int v9; // [esp+18h] [ebp-4h] + + v4 = 3; + v5 = 0; + if ( a1 > 0x1000 ) + v5 = a1 - 4096; + v9 = 273; + if ( a2 - a1 <= 0x111 ) + v9 = a2 - a1; + if ( v9 > 2 ) + { + while ( a1 > v5 ) + { + v7 = mischarsearch(&bz[a1], v4, &bz[v5], v4 + a1 - v5); + if ( v7 >= a1 - v5 ) + break; + for ( ; v9 > v4; ++v4 ) + { + if ( bz[v4 + v5 + v7] != bz[v4 + a1] ) + break; + } + if ( v9 == v4 ) + { + *a3 = v7 + v5; + goto LABEL_17; + } + v8 = v5 + v7; + ++v4; + v5 += v7 + 1; + } + *a3 = v8; + if ( v4 > 3 ) + { + --v4; +LABEL_17: + *a4 = v4; + return; + } + v6 = a4; + } + else + { + *a4 = 0; + v6 = a3; + } + *v6 = 0; +} + +int mischarsearch(unsigned char *pattern, int patternlen, unsigned char *data, int datalen) +{ + int result; // eax + int i; // ebx + int v6; // eax + int j; // ecx + + result = datalen; + if ( patternlen <= datalen ) + { + initskip(pattern, patternlen); + for ( i = patternlen - 1; ; i += v6 ) + { + if ( pattern[patternlen - 1] == data[i] ) + { + --i; + j = patternlen - 2; + if ( patternlen - 2 < 0 ) + return i + 1; + while ( pattern[j] == data[i] ) + { + --i; + if ( --j < 0 ) + return i + 1; + } + v6 = patternlen - j; + if ( skip[data[i]] > patternlen - j ) + v6 = skip[data[i]]; + } + else + { + v6 = skip[data[i]]; + } + } + } + return result; +} + +void initskip(unsigned char *pattern, int len) +{ + for (int i = 0; i < 256; i++) + skip[i] = len; + + for (int i = 0; i < len; i++) + skip[pattern[i]] = len - i - 1; +} + +void writeshort(short val) +{ + fputc((val & 0xff00) >> 8, fp); + fputc((val & 0x00ff) >> 0, fp); +} + +void writeint4(int val) +{ + fputc((val & 0x00ff000000) >> 24, fp); + fputc((val & 0x0000ff0000) >> 16, fp); + fputc((val & 0x000000ff00) >> 8, fp); + fputc((val & 0x00000000ff) >> 0, fp); +}