Move libultra function declarations to libultra headers (#1196)

* Delete unused headers

* Move PR and io to ultra64

* move headers to ultra64

* more cleanups

* more reorganizing

* i think that should be all

* format

* ifdef guards cleanup

* Add IO_READ and IO_WRITE macros for future use

* warnings

* review

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

* warnings again

* warn

* ifdef guards

* fix merge

* fix merge

* fix merge

* bss

* padutils.h

* bss

* bss

* bss

* fix merge

* bss

* bss

* bss

* fix merge

* fixes

* fixes

* bss

* bss

* fix merge

* fix

* fix

* fix includepaths

* fix paths

* bss

* fix

* ultra64/ -> PR/

* header guards

* fix ehader guards

* fix

* fix++

* format

* bss is borken

* prevent 2

* :despair:

* bss

* rename assert to dbg_hungup

* fix

* a

* fix

* bss

* fix

* bss

* bss

---------

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal 2023-09-02 15:34:29 -04:00 committed by GitHub
parent 9cceea48f3
commit 4fa13e4132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
162 changed files with 1058 additions and 906 deletions

View File

@ -1,5 +1,5 @@
#ifndef ULTRA64_ABI_H
#define ULTRA64_ABI_H
#ifndef PR_ABI_H
#define PR_ABI_H
/* Audio commands: */
/*

View File

@ -1,14 +1,14 @@
#ifndef _CONTROLLER_H_
#define _CONTROLLER_H_
#ifndef PR_CONTROLLER_H
#define PR_CONTROLLER_H
#include "PR/ultratypes.h"
#include "PR/pfs.h"
#include "ultratypes.h"
#include "os_cont.h"
#include "os_pfs.h"
#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)
#define SIAccessQueueSize 2
#define BLOCKSIZE 32
#define MAXCONTROLLERS 4
#define PFS_ONE_PAGE 8
#define PFS_PAGE_SIZE (BLOCKSIZE*PFS_ONE_PAGE)
@ -104,27 +104,6 @@
#define PFS_ERR_NOPACK 1
/* controller errors */
#define CONT_NO_RESPONSE_ERROR 0x8
#define CONT_OVERRUN_ERROR 0x4
/* 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
#define CONT_TYPE_VOICE 0x0100
/* Controller status */
#define CONT_CARD_ON 0x01
#define CONT_CARD_PULL 0x02
#define CONT_ADDR_CRC_ER 0x04
#define CONT_EEPROM_BUSY 0x80
// Accessory detection
#define CONT_ADDR_DETECT 0x8000
// Rumble
@ -145,22 +124,6 @@
#define CONT_BLOCK_GB_BANK CONT_BLOCKS(CONT_ADDR_GB_BANK)
#define CONT_BLOCK_GB_STATUS CONT_BLOCKS(CONT_ADDR_GB_STATUS)
/* Buttons */
#define BTN_CRIGHT 0x0001
#define BTN_CLEFT 0x0002
#define BTN_CDOWN 0x0004
#define BTN_CUP 0x0008
#define BTN_R 0x0010
#define BTN_L 0x0020
#define BTN_RESET 0x0080
#define BTN_DRIGHT 0x0100
#define BTN_DLEFT 0x0200
#define BTN_DDOWN 0x0400
#define BTN_DUP 0x0800
#define BTN_START 0x1000
#define BTN_Z 0x2000
#define BTN_B 0x4000
#define BTN_A 0x8000
typedef struct {
/* 0x00 */ u32 ramarray[15];
@ -213,6 +176,28 @@ typedef struct {
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check);
s32 __osGetId(OSPfs* pfs);
u16 __osSumcalc(u8* ptr, s32 length);
s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum);
s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid);
s32 __osCheckPackId(OSPfs *pfs, __OSPackId *check);
s32 __osCheckId(OSPfs* pfs);
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank);
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank);
s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage);
s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 initialPage, u8 bank, __OSInodeUnit *finalPage);
s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* buffer);
s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force);
void __osContGetInitData(u8* pattern, OSContStatus* data);
void __osPackRequestData(u8 poll);
void __osPfsRequestData(u8 poll);
void __osPfsGetInitData(u8* pattern, OSContStatus* contData);
u8 __osContAddressCrc(u16 addr);
u8 __osContDataCrc(u8* data);
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel);
s32 __osContChannelReset(OSMesgQueue* mq, s32 channel);
extern OSPifRam __osContPifRam;
// extern UNK_TYPE1 D_8009CF0C;
extern u8 __osContLastPoll;

View File

@ -1,9 +1,9 @@
#ifndef CONTROLLER_VOICE_H
#define CONTROLLER_VOICE_H
#ifndef PR_CONTROLLER_VOICE_H
#define PR_CONTROLLER_VOICE_H
#include "PR/ultratypes.h"
#include "ultra64/os_voice.h"
#include "ultra64/message.h"
#include "ultratypes.h"
#include "os_voice.h"
#include "os_message.h"
#include "libc/stddef.h"
typedef struct {

View File

@ -1,7 +1,9 @@
#include "mbi.h"
#ifndef _ULTRA64_GBI_H_
#define _ULTRA64_GBI_H_
#ifndef PR_GBI_H
#define PR_GBI_H
#include "ultratypes.h"
/* To enable Fast3DEX grucode support, define F3DEX_GBI. */
@ -1054,6 +1056,16 @@ typedef struct {
unsigned char v[3];
} Tri;
typedef long int Mtx_t[4][4];
typedef union {
Mtx_t m;
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
};
long long int force_structure_alignment;
} Mtx; // size = 0x40
/*
* Viewport
*/

View File

@ -1,5 +1,7 @@
#ifndef GS2DEX_H
#define GS2DEX_H
#ifndef PR_GS2DEX_H
#define PR_GS2DEX_H
#include "ultratypes.h"
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {

View File

@ -1,26 +1,63 @@
#ifndef _GU_H_
#define _GU_H_
#ifndef PR_GU_H
#define PR_GU_H
typedef struct {
/* 0x0 */ unsigned char* base;
/* 0x4 */ int fmt;
/* 0x8 */ int siz;
/* 0xC */ int xsize;
/* 0x10 */ int ysize;
/* 0x14 */ int lsize;
/* 0x18 */ int addr;
/* 0x1C */ int w;
/* 0x20 */ int h;
/* 0x24 */ int s;
/* 0x28 */ int t;
} Image;
#include "ultratypes.h"
#include "gbi.h"
typedef struct {
/* 0x0 */ float col[3];
/* 0xC */ float pos[3];
/* 0x18 */ float a1;
/* 0x1C */ float a2;
} PositionalLight;
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#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)
void guMtxIdent(Mtx* mtx);
void guMtxIdentF(float mf[4][4]);
void guOrtho(Mtx* m, f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale);
void guOrthoF(float m[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale);
void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
void guPerspectiveF(float mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight);
void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight);
void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z);
void guRotateF(float m[4][4], f32 a, f32 x, f32 y, f32 z);
void guScale(Mtx* mtx, f32 x, f32 y, f32 z);
void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z);
void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
void guPositionF(float mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
void guMtxF2L(float mf[4][4], Mtx* m);
void guMtxL2F(float m1[4][4], Mtx* m2);
void guNormalize(float* x, float* y, float* z);
f32 sinf(f32 __x);
f32 cosf(f32 __x);
s16 sins(u16 x);
s16 coss(u16 x);
f32 sqrtf(f32 f);
#ifdef __sgi
#pragma intrinsic(sqrtf);
#endif
#endif

View File

@ -1,6 +1,8 @@
#ifndef _ULTRA64_HARDWARE_H_
#define _ULTRA64_HARDWARE_H_
// TODO: not real libultra header. Refactor to R4300.h
// Segment Wrapper
// Uncached RDRAM
#define KSEG1 0xA0000000 // 0xA0000000 - 0xBFFFFFFF Physical memory, uncached, unmapped

View File

@ -1,5 +1,5 @@
#ifndef _MBI_H_
#define _MBI_H_
#ifndef PR_MBI_H
#define PR_MBI_H
/**************************************************************************
* *

27
include/PR/os.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef PR_OS_H
#define PR_OS_H
#include "os_ai.h"
#include "os_cache.h"
#include "os_cont.h"
#include "os_convert.h"
#include "os_exception.h"
#include "os_flash.h"
#include "os_host.h"
#include "os_internal_error.h"
#include "os_internal_reg.h"
#include "os_internal_si.h"
#include "os_internal.h"
#include "os_libc.h"
#include "os_message.h"
#include "os_pfs.h"
#include "os_pi.h"
#include "os_reg.h"
#include "os_system.h"
#include "os_thread.h"
#include "os_time.h"
#include "os_tlb.h"
#include "os_vi.h"
#include "os_voice.h"
#endif

12
include/PR/os_ai.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef PR_OS_AI_H
#define PR_OS_AI_H
#include "ultratypes.h"
u32 osAiGetLength(void);
s32 osAiSetFrequency(u32 frequency);
s32 osAiSetNextBuffer(void* buf, u32 size);
#endif

12
include/PR/os_cache.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef PR_OS_CACHE_H
#define PR_OS_CACHE_H
#include "ultratypes.h"
#include "libc/stddef.h"
void osInvalDCache(void* vaddr, size_t nbytes);
void osInvalICache(void* vaddr, size_t nbytes);
void osWritebackDCache(void* vaddr, s32 nbytes);
void osWritebackDCacheAll(void);
#endif

79
include/PR/os_cont.h Normal file
View File

@ -0,0 +1,79 @@
#ifndef PR_OS_CONT_H
#define PR_OS_CONT_H
#include "ultratypes.h"
#include "os_message.h"
typedef struct {
/* 0x0 */ u16 type;
/* 0x2 */ u8 status;
/* 0x3 */ u8 errno;
} OSContStatus; // size = 0x4
typedef struct {
/* 0x0 */ u16 button;
/* 0x2 */ s8 stick_x;
/* 0x3 */ s8 stick_y;
/* 0x4 */ u8 errno;
} OSContPad; // size = 0x6
#define MAXCONTROLLERS 4
/* controller errors */
#define CONT_NO_RESPONSE_ERROR 0x8
#define CONT_OVERRUN_ERROR 0x4
/* 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
#define CONT_TYPE_VOICE 0x0100
/* Controller status */
#define CONT_CARD_ON 0x01
#define CONT_CARD_PULL 0x02
#define CONT_ADDR_CRC_ER 0x04
#define CONT_EEPROM_BUSY 0x80
// TODO: use real libultra button defines instead of this
/* Buttons */
#define BTN_CRIGHT 0x0001
#define BTN_CLEFT 0x0002
#define BTN_CDOWN 0x0004
#define BTN_CUP 0x0008
#define BTN_R 0x0010
#define BTN_L 0x0020
#define BTN_RESET 0x0080
#define BTN_DRIGHT 0x0100
#define BTN_DLEFT 0x0200
#define BTN_DDOWN 0x0400
#define BTN_DUP 0x0800
#define BTN_START 0x1000
#define BTN_Z 0x2000
#define BTN_B 0x4000
#define BTN_A 0x8000
#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */
#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */
#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */
#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */
#define CONT_ERR_NOT_READY 12
#define CONT_ERR_VOICE_MEMORY 13
#define CONT_ERR_VOICE_WORD 14
#define CONT_ERR_VOICE_NO_RESPONSE 15
s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data);
s32 osContStartQuery(OSMesgQueue* mq);
s32 osContStartReadData(OSMesgQueue* mq);
s32 osContSetCh(u8 ch);
void osContGetQuery(OSContStatus* data);
void osContGetReadData(OSContPad* data);
#endif

View File

@ -1,5 +1,5 @@
#ifndef ULTRA64_CONVERT_H
#define ULTRA64_CONVERT_H
#ifndef PR_CONVERT_H
#define PR_CONVERT_H
#include "libc/stdint.h"
@ -24,6 +24,5 @@
/* Functions */
extern uintptr_t osVirtualToPhysical(void*);
extern void* osPhysicalToVirtual(uintptr_t);
#endif

21
include/PR/os_exception.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef PR_OS_EXCEPTION_H
#define PR_OS_EXCEPTION_H
#include "ultratypes.h"
typedef u32 OSIntMask;
typedef u32 OSHWIntr;
OSIntMask osGetIntMask(void);
OSIntMask osSetIntMask(OSIntMask im);
// Internal
void __osSetHWIntrRoutine(OSHWIntr idx, OSMesgQueue* queue, OSMesg msg);
void __osGetHWIntrRoutine(OSHWIntr idx, OSMesgQueue** outQueue, OSMesg* outMsg);
void __osSetGlobalIntMask(OSHWIntr mask);
void __osResetGlobalIntMask(OSHWIntr mask);
#endif

23
include/PR/os_flash.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef PR_OS_FLASH_H
#define PR_OS_FLASH_H
#include "ultratypes.h"
#include "os_pi.h"
OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start);
OSPiHandle* osFlashInit(void);
void osFlashReadStatus(u8* flashStatus);
void osFlashReadId(u32* flashType, u32* flashVendor);
void osFlashClearStatus(void);
s32 osFlashAllErase(void);
s32 osFlashSectorErase(u32 pageNum);
s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq);
s32 osFlashWriteArray(u32 pageNum);
s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq);
void osFlashChange(u32 flashNum);
void osFlashAllEraseThrough(void);
void osFlashSectorEraseThrough(u32 pageNum);
s32 osFlashCheckEraseEnd(void);
#endif

9
include/PR/os_host.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PR_OS_HOST_H
#define PR_OS_HOST_H
void __osInitialize_common(void);
void __osInitialize_autodetect(void);
#define osInitialize() __osInitialize_common()
#endif

View File

@ -1,5 +1,10 @@
#ifndef _OS_INTERNAL_H_
#define _OS_INTERNAL_H_
#ifndef PR_OS_INTERNAL_H
#define PR_OS_INTERNAL_H
#include "ultratypes.h"
#include "os_message.h"
#include "os_pi.h"
typedef struct {
/* 0x00 */ OSMesgQueue* queue;

View File

@ -0,0 +1,9 @@
#ifndef PR_OS_INTERNAL_ERROR_H
#define PR_OS_INTERNAL_ERROR_H
#include "os_thread.h"
OSThread* __osGetCurrFaultedThread(void);
#endif

View File

@ -0,0 +1,24 @@
#ifndef PR_OS_INTERNAL_REG
#define PR_OS_INTERNAL_REG
#include "ultratypes.h"
#include "os_exception.h"
u32 __osGetCause(void);
void __osSetCause(u32);
u32 __osGetCompare(void);
void __osSetCompare(u32 value);
u32 __osGetConfig(void);
void __osSetConfig(u32);
u32 __osGetSR(void);
void __osSetSR(u32 value);
OSIntMask __osDisableInt(void);
void __osRestoreInt(OSIntMask im);
u32 __osGetWatchLo(void);
void __osSetWatchLo(u32 value);
u32 __osSetFpcCsr(u32 value);
u32 __osGetFpcCsr(void);
#endif

View File

@ -0,0 +1,13 @@
#ifndef PR_OS_INTERNAL_SI_H
#define PR_OS_INTERNAL_SI_H
#include "ultratypes.h"
#include "libc/stdint.h"
s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data);
s32 __osSiRawReadIo(uintptr_t devAddr, u32* data);
s32 __osSiRawStartDma(s32 direction, void* dramAddr);
#endif

15
include/PR/os_libc.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef PR_OS_LIBC_H
#define PR_OS_LIBC_H
#include "libc/stdarg.h"
void bcopy(void* __src, void* __dest, int __n);
int bcmp(void* __s1, void* __s2, int __n);
void bzero(void* begin, int length);
s32 vsprintf(char* dst, char* fmt, va_list args);
int sprintf(char* dst, const char* fmt, ...);
void osSyncPrintf(const char* fmt, ...);
#endif

View File

@ -1,7 +1,19 @@
#ifndef ULTRA64_MESSAGE_H
#define ULTRA64_MESSAGE_H
#ifndef PR_OS_MESSAGE_H
#define PR_OS_MESSAGE_H
#include "ultra64/thread.h"
#include "os_thread.h"
typedef void* OSMesg;
typedef u32 OSEvent;
typedef struct OSMesgQueue {
/* 0x00 */ OSThread* mtQueue;
/* 0x04 */ OSThread* fullQueue;
/* 0x08 */ s32 validCount;
/* 0x0C */ s32 first;
/* 0x10 */ s32 msgCount;
/* 0x14 */ OSMesg* msg;
} OSMesgQueue; // size = 0x18
#define OS_NUM_EVENTS 15
@ -30,24 +42,20 @@
#define OS_EVENT_RDB_FLUSH_PROF 21
#define OS_EVENT_RDB_ACK_PROF 22
typedef void* OSMesg;
typedef u32 OSEvent;
#define OS_MESG_NOBLOCK 0
#define OS_MESG_BLOCK 1
typedef struct OSMesgQueue {
/* 0x00 */ OSThread* mtQueue;
/* 0x04 */ OSThread* fullQueue;
/* 0x08 */ s32 validCount;
/* 0x0C */ s32 first;
/* 0x10 */ s32 msgCount;
/* 0x14 */ OSMesg* msg;
} OSMesgQueue; // size = 0x18
#define MQ_GET_COUNT(mq) ((mq)->validCount)
#define MQ_COUNT(mq) ((mq)->validCount)
#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0)
#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount)
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msq, s32 count);
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags);
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags);
void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m);
#define MQ_IS_EMPTY(mq) (MQ_COUNT(mq) == 0)
#define MQ_IS_FULL(mq) (MQ_COUNT(mq) >= (mq)->msgCount)
#endif

View File

@ -1,9 +1,9 @@
#ifndef ULTRA64_MOTOR_H
#define ULTRA64_MOTOR_H
#ifndef PR_OS_MOTOR_H
#define PR_OS_MOTOR_H
#include "PR/ultratypes.h"
#include "PR/pfs.h"
#include "ultra64/message.h"
#include "ultratypes.h"
#include "os_pfs.h"
#include "os_message.h"
#define MOTOR_START 1
#define MOTOR_STOP 0

View File

@ -1,5 +1,5 @@
#ifndef _ULTRA64_PFS_H_
#define _ULTRA64_PFS_H_
#ifndef PR_OS_PFS_H
#define PR_OS_PFS_H
#include "os.h"
@ -134,8 +134,16 @@ typedef struct {
/* 0x101 */ u8 map[PFS_INODE_DIST_MAP];
} __OSInodeCache; // size = 0x202
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check);
s32 __osGetId(OSPfs* pfs);
s32 osPfsInitPak(OSMesgQueue* queue, OSPfs* pfs, s32 channel);
s32 osPfsChecker(OSPfs* pfs);
s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo);
s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo);
s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName);
s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data);
s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state);
s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern);
s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes);
#endif

View File

@ -1,10 +1,76 @@
#ifndef _OS_H_
#define _OS_H_
#ifndef PR_OS_PI_H
#define PR_OS_PI_H
#include "ultratypes.h"
#include "os_message.h"
#include "libc/stddef.h"
#include "libc/stdint.h"
#include "libc/stdlib.h"
#include "ultra64/thread.h"
#include "ultra64/message.h"
typedef struct {
/* 0x00 */ u32 errStatus;
/* 0x04 */ void* dramAddr;
/* 0x08 */ void* C2Addr;
/* 0x0C */ u32 sectorSize;
/* 0x10 */ u32 C1ErrNum;
/* 0x14 */ u32 C1ErrSector[4];
} __OSBlockInfo; // size = 0x24
typedef struct {
/* 0x00 */ u32 cmdType;
/* 0x04 */ u16 transferMode;
/* 0x06 */ u16 blockNum;
/* 0x08 */ s32 sectorNum;
/* 0x0C */ uintptr_t devAddr;
/* 0x10 */ u32 bmCtlShadow;
/* 0x14 */ u32 seqCtlShadow;
/* 0x18 */ __OSBlockInfo block[2];
} __OSTranxInfo; // size = 0x60
typedef struct OSPiHandle {
/* 0x00 */ struct OSPiHandle* next;
/* 0x04 */ u8 type;
/* 0x05 */ u8 latency;
/* 0x06 */ u8 pageSize;
/* 0x07 */ u8 relDuration;
/* 0x08 */ u8 pulse;
/* 0x09 */ u8 domain;
/* 0x0C */ uintptr_t baseAddress;
/* 0x10 */ u32 speed;
/* 0x14 */ __OSTranxInfo transferInfo;
} OSPiHandle; // size = 0x74
typedef struct {
/* 0x0 */ u8 type;
/* 0x4 */ uintptr_t address;
} OSPiInfo; // size = 0x8
typedef struct {
/* 0x0 */ u16 type;
/* 0x2 */ u8 pri;
/* 0x3 */ u8 status;
/* 0x4 */ OSMesgQueue* retQueue;
} OSIoMesgHdr; // size = 0x8
typedef struct {
/* 0x00 */ OSIoMesgHdr hdr;
/* 0x08 */ void* dramAddr;
/* 0x0C */ uintptr_t devAddr;
/* 0x10 */ size_t size;
/* 0x14 */ OSPiHandle* piHandle;
} OSIoMesg; // size = 0x88
typedef struct {
/* 0x00 */ s32 active; // u32 maybe? need to check
/* 0x04 */ OSThread* thread;
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* evtQueue;
/* 0x10 */ OSMesgQueue* acsQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t);
} OSDevMgr; // size = 0x1C
#define OS_READ 0
#define OS_WRITE 1
@ -28,118 +94,13 @@
#define OS_MESG_PRI_HIGH 1
typedef u32 OSIntMask;
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt);
typedef u32 OSPageMask;
OSPiHandle* osCartRomInit(void);
typedef struct {
/* 0x00 */ u32 errStatus;
/* 0x04 */ void* dramAddr;
/* 0x08 */ void* C2Addr;
/* 0x0C */ u32 sectorSize;
/* 0x10 */ u32 C1ErrNum;
/* 0x14 */ u32 C1ErrSector[4];
} __OSBlockInfo; // size = 0x24
typedef struct {
/* 0x00 */ u32 cmdType;
/* 0x04 */ u16 transferMode;
/* 0x06 */ u16 blockNum;
/* 0x08 */ s32 sectorNum;
/* 0x0C */ uintptr_t devAddr;
/* 0x10 */ u32 bmCtlShadow;
/* 0x14 */ u32 seqCtlShadow;
/* 0x18 */ __OSBlockInfo block[2];
} __OSTranxInfo; // size = 0x60
typedef struct OSPiHandle {
/* 0x00 */ struct OSPiHandle* next;
/* 0x04 */ u8 type;
/* 0x05 */ u8 latency;
/* 0x06 */ u8 pageSize;
/* 0x07 */ u8 relDuration;
/* 0x08 */ u8 pulse;
/* 0x09 */ u8 domain;
/* 0x0C */ uintptr_t baseAddress;
/* 0x10 */ u32 speed;
/* 0x14 */ __OSTranxInfo transferInfo;
} OSPiHandle; // size = 0x74
typedef struct {
/* 0x0 */ u8 type;
/* 0x4 */ uintptr_t address;
} OSPiInfo; // size = 0x8
typedef struct {
/* 0x0 */ u16 type;
/* 0x2 */ u8 pri;
/* 0x3 */ u8 status;
/* 0x4 */ OSMesgQueue* retQueue;
} OSIoMesgHdr; // size = 0x8
typedef struct {
/* 0x00 */ OSIoMesgHdr hdr;
/* 0x08 */ void* dramAddr;
/* 0x0C */ uintptr_t devAddr;
/* 0x10 */ size_t size;
/* 0x14 */ OSPiHandle* piHandle;
} OSIoMesg; // size = 0x88
typedef struct {
/* 0x00 */ s32 active; // u32 maybe? need to check
/* 0x04 */ OSThread* thread;
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* evtQueue;
/* 0x10 */ OSMesgQueue* acsQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t);
} OSDevMgr; // size = 0x1C
typedef u64 OSTime;
typedef struct OSTimer_s {
/* 0x00 */ struct OSTimer_s* next;
/* 0x04 */ struct OSTimer_s* prev;
/* 0x08 */ OSTime interval;
/* 0x10 */ OSTime value;
/* 0x18 */ OSMesgQueue* mq;
/* 0x1C */ OSMesg msg;
} OSTimer; // size = 0x20
typedef struct {
/* 0x0 */ u16 type;
/* 0x2 */ u8 status;
/* 0x3 */ u8 errno;
} OSContStatus; // size = 0x4
typedef struct {
/* 0x0 */ u16 button;
/* 0x2 */ s8 stick_x;
/* 0x3 */ s8 stick_y;
/* 0x4 */ u8 errno;
} OSContPad; // size = 0x6
typedef struct {
/* 0x00 */ void* address;
/* 0x04 */ u8 databuffer[32];
/* 0x24 */ u8 addressCrc;
/* 0x25 */ u8 dataCrc;
/* 0x26 */ u8 errno;
} OSContRamIo; // size = 0x28
typedef struct {
/* 0x0 */ u16* histo_base;
/* 0x4 */ u32 histo_size;
/* 0x8 */ u32* text_start;
/* 0xC */ u32* text_end;
} OSProf; // size = 0x10
s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data);
s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data);
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);
s32 osEPiLinkHandle(OSPiHandle* handle);
#endif

9
include/PR/os_reg.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PR_OS_REG_H
#define PR_OS_REG_H
#include "ultratypes.h"
u32 osGetCount(void);
#endif

10
include/PR/os_system.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef PR_OS_SYSTEM_H
#define PR_OS_SYSTEM_H
#include "ultratypes.h"
u32 osGetMemSize(void);
s32 osAfterPreNMI(void);
#endif

View File

@ -1,31 +1,7 @@
#ifndef _ULTRA64_THREAD_H_
#define _ULTRA64_THREAD_H_
#ifndef PR_OS_THREAD_H
#define PR_OS_THREAD_H
#include "PR/ultratypes.h"
#define OS_PRIORITY_IDLE 0
#define OS_PRIORITY_MAIN 10
#define OS_PRIORITY_GRAPH 11
#define OS_PRIORITY_AUDIOMGR 12
#define OS_PRIORITY_PADMGR 14
#define OS_PRIORITY_SCHED 15
#define OS_PRIORITY_DMAMGR 16
#define OS_PRIORITY_IRQMGR 17
#define OS_PRIORITY_PIMGR 150
#define OS_PRIORITY_FAULTCLIENT 126
#define OS_PRIORITY_FAULT 127
#define OS_PRIORITY_APPMAX 127
#define OS_PRIORITY_RMONSPIN 200
#define OS_PRIORITY_RMON 250
#define OS_PRIORITY_VIMGR 254
#define OS_PRIORITY_MAX 255
#define OS_PRIORITY_THREADTAIL -1
#define OS_STATE_STOPPED (1 << 0)
#define OS_STATE_RUNNABLE (1 << 1)
#define OS_STATE_RUNNING (1 << 2)
#define OS_STATE_WAITING (1 << 3)
#include "ultratypes.h"
#define OS_FLAG_CPU_BREAK 1
#define OS_FLAG_FAULT 2
@ -71,4 +47,42 @@ typedef struct OSThread {
/* 0x20 */ __OSThreadContext context;
} OSThread; // size = 0x1B0
#define OS_STATE_STOPPED (1 << 0)
#define OS_STATE_RUNNABLE (1 << 1)
#define OS_STATE_RUNNING (1 << 2)
#define OS_STATE_WAITING (1 << 3)
#define OS_PRIORITY_IDLE 0
#define OS_PRIORITY_MAIN 10
#define OS_PRIORITY_GRAPH 11
#define OS_PRIORITY_AUDIOMGR 12
#define OS_PRIORITY_PADMGR 14
#define OS_PRIORITY_SCHED 15
#define OS_PRIORITY_DMAMGR 16
#define OS_PRIORITY_IRQMGR 17
#define OS_PRIORITY_PIMGR 150
#define OS_PRIORITY_FAULTCLIENT 126
#define OS_PRIORITY_FAULT 127
#define OS_PRIORITY_APPMAX 127
#define OS_PRIORITY_RMONSPIN 200
#define OS_PRIORITY_RMON 250
#define OS_PRIORITY_VIMGR 254
#define OS_PRIORITY_MAX 255
#define OS_PRIORITY_THREADTAIL -1
void osCreateThread(OSThread* thread, OSId id, void* entry, void* arg, void* sp, OSPri p);
void osDestroyThread(OSThread* t);
void osYieldThread(void);
void osStartThread(OSThread* t);
void osStopThread(OSThread* t);
OSId osGetThreadId(OSThread* t);
void osSetThreadPri(OSThread* thread, OSPri p);
OSPri osGetThreadPri(OSThread* t);
// internal
OSThread* __osGetActiveQueue(void);
#endif

25
include/PR/os_time.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef PR_OS_TIME_H
#define PR_OS_TIME_H
#include "ultratypes.h"
#include "os_message.h"
typedef u64 OSTime;
typedef struct OSTimer_s {
/* 0x00 */ struct OSTimer_s* next;
/* 0x04 */ struct OSTimer_s* prev;
/* 0x08 */ OSTime interval;
/* 0x10 */ OSTime value;
/* 0x18 */ OSMesgQueue* mq;
/* 0x1C */ OSMesg msg;
} OSTimer; // size = 0x20
OSTime osGetTime(void);
void osSetTime(OSTime ticks);
s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg);
s32 osStopTimer(OSTimer* t);
#endif

9
include/PR/os_tlb.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PR_OS_TLB_H
#define PR_OS_TLB_H
#include "ultratypes.h"
void osMapTLBRdb(void);
void osUnmapTLBAll(void);
#endif

View File

@ -1,8 +1,8 @@
#ifndef _ULTRA64_VI_H_
#define _ULTRA64_VI_H_
#ifndef PR_OS_VI_H
#define PR_OS_VI_H
#include "PR/ultratypes.h"
#include "ultra64/message.h"
#include "PR/os_message.h"
/* Special Features */
#define OS_VI_GAMMA_ON (1 << 0)
@ -52,23 +52,6 @@ typedef struct {
/* 0x24 */ OSViFieldRegs fldRegs[2];
} OSViMode; // size = 0x4C
typedef struct {
/* 0x0 */ f32 factor;
/* 0x4 */ u16 offset;
/* 0x8 */ u32 scale;
} __OSViScale; // size = 0x0C
typedef struct {
/* 0x00 */ u16 state;
/* 0x02 */ u16 retraceCount;
/* 0x04 */ void* buffer;
/* 0x08 */ OSViMode* modep;
/* 0x0C */ u32 features;
/* 0x10 */ OSMesgQueue* mq;
/* 0x14 */ OSMesg* msg;
/* 0x18 */ __OSViScale x;
/* 0x24 */ __OSViScale y;
} __OSViContext; // size = 0x30
#define OS_VI_NTSC_LPN1 0 /* NTSC */
#define OS_VI_NTSC_LPF1 1
@ -135,4 +118,18 @@ typedef struct {
#define OS_TV_MPAL 2
#define OS_VI_UNK28 28
void* osViGetCurrentFramebuffer(void);
void* osViGetNextFramebuffer(void);
void osViSetXScale(f32 value);
void osViSetYScale(f32 value);
void osViExtendVStart(u32 a0);
void osViSetSpecialFeatures(u32 func);
void osViSetMode(OSViMode* modep);
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount);
void osViSwapBuffer(void* frameBufPtr);
void osViBlack(u8 active);
void osCreateViManager(OSPri pri);
#endif

View File

@ -1,8 +1,8 @@
#ifndef OS_VOICE_H
#define OS_VOICE_H
#ifndef PR_OS_VOICE_H
#define PR_OS_VOICE_H
#include "PR/ultratypes.h"
#include "ultra64/message.h"
#include "ultratypes.h"
#include "os_message.h"
typedef enum OsVoiceHandleMode {
/* 0 */ VOICE_HANDLE_MODE_0,
@ -29,14 +29,15 @@ typedef struct {
/* 0x14 */ u16 distance[5]; // Distance value
} OSVoiceData; // size = 0x20
s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* hd, s32 channel);
s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* hd, int channel);
s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word);
s32 osVoiceCheckWord(u8* word);
s32 osVoiceStartReadData(OSVoiceHandle* hd);
s32 osVoiceStopReadData(OSVoiceHandle* hd);
s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result);
s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords);
s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size);
s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, int size);
s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital);
#endif

38
include/PR/osint.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef PR_OSINT_H
#define PR_OSINT_H
#include "ultratypes.h"
#include "os_message.h"
#include "os.h"
#include "os_internal.h"
typedef struct __OSEventState {
/* 0x0 */ OSMesgQueue* messageQueue;
/* 0x4 */ OSMesg message;
} __OSEventState; // size = 0x8
typedef struct __OSThreadTail {
/* 0x0 */ OSThread* next;
/* 0x4 */ OSPri priority;
} __OSThreadTail; // size = 0x8
void __osEnqueueAndYield(OSThread** param_1);
void __osDequeueThread(OSThread** queue, OSThread* t);
void __osEnqueueThread(OSThread** param_1, OSThread* param_2);
OSThread* __osPopThread(OSThread** param_1);
void __osDispatchThread(void);
void __osCleanupThread(void);
void __osSetTimerIntr(OSTime tim);
OSTime __osInsertTimer(OSTimer* t);
void __osTimerInterrupt(void);
u32 __osProbeTLB(void* param_1);
s32 __osSpDeviceBusy(void);
void __osTimerServicesInit(void);
extern __osHwInt __osHwIntTable[];
extern __OSEventState __osEventStateTab[OS_NUM_EVENTS];
#endif

20
include/PR/piint.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PR_PIINT_H
#define PR_PIINT_H
#include "ultratypes.h"
#include "os_pi.h"
#include "libc/stdint.h"
void __osDevMgrMain(void* arg);
void __osPiCreateAccessQueue(void);
void __osPiRelAccess(void);
void __osPiGetAccess(void);
s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size);
s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data);
s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data);
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size);
OSMesgQueue* osPiGetCmdQueue(void);
#endif

View File

@ -1,8 +1,8 @@
#ifndef ULTRA64_R4300_H
#define ULTRA64_R4300_H
#ifndef PR_R4300_H
#define PR_R4300_H
#ifdef _LANGUAGE_C
#include "PR/ultratypes.h"
#include "ultratypes.h"
#define U32(x) ((u32)x)
#define C_REG(x) (x)
#else

View File

@ -1,5 +1,5 @@
#ifndef _ULTRA64_RCP_H_
#define _ULTRA64_RCP_H_
#ifndef PR_RCP_H
#define PR_RCP_H
#define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */
#define VI_PAL_CLOCK 49656530 /* Hz = 49.656530 MHz */
@ -11,7 +11,6 @@
#define DEVICE_TYPE_SRAM 3 /* SRAM */
#define DEVICE_TYPE_INIT 7 /* initial value */
#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */
#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */
#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */
@ -19,4 +18,7 @@
#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */
#define IO_READ(addr) (*(vu32*)PHYS_TO_K1(addr))
#define IO_WRITE(addr,data) (*(vu32*)PHYS_TO_K1(addr)=(u32)(data))
#endif

View File

@ -1,5 +1,5 @@
#ifndef ULTRA64_RDP_H
#define ULTRA64_RDP_H
#ifndef PR_RDP_H
#define PR_RDP_H
/* DP Command Registers */
#define DPC_START_REG 0x04100000
@ -42,4 +42,9 @@
#define DPC_CLR_CMD_CTR (1 << 8)
#define DPC_CLR_CLOCK_CTR (1 << 9)
u32 osDpGetStatus(void);
void osDpSetStatus(u32 data);
#endif

View File

@ -1,5 +1,9 @@
#ifndef _ULTRA64_RSP_H_
#define _ULTRA64_RSP_H_
#ifndef PR_RSP_H
#define PR_RSP_H
#include "ultratypes.h"
#include "libc/stddef.h"
/* SP Status Flags */
#define SP_STATUS_HALT (1 << 0)
@ -44,4 +48,11 @@
#define SP_CLR_SIG7 (1 << 23)
#define SP_SET_SIG7 (1 << 24)
u32 __osSpGetStatus(void);
void __osSpSetStatus(u32 data);
s32 __osSpSetPc(void* pc);
s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size);
#endif

View File

@ -1,9 +1,16 @@
#ifndef SCHED_H
#define SCHED_H
#ifndef PR_SCHED_H
#define PR_SCHED_H
#include "PR/ultratypes.h"
#include "ultra64/vi.h"
#include "ultra64/sptask.h"
#include "PR/os_vi.h"
#include "PR/sptask.h"
#define OS_SC_STACKSIZE 0x2000
#define OS_SC_RETRACE_MSG 1
#define OS_SC_DONE_MSG 2
#define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c
#define OS_SC_PRE_NMI_MSG 4
#define OS_SC_NEEDS_RDP 0x0001
#define OS_SC_NEEDS_RSP 0x0002

12
include/PR/siint.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef PR_SIINT_H
#define PR_SIINT_H
#include "ultratypes.h"
void __osSiGetAccess(void);
void __osSiRelAccess(void);
s32 __osSiDeviceBusy(void);
void __osSiCreateAccessQueue(void);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _SPTASK_H_
#define _SPTASK_H_
#ifndef PR_SPTASK_H
#define PR_SPTASK_H
#include "PR/ultratypes.h"
#include "libc/stddef.h"
@ -109,4 +109,10 @@ typedef union {
typedef u32 OSYieldResult;
void osSpTaskLoad(OSTask* intp);
void osSpTaskStartGo(OSTask* tp);
void osSpTaskYield(void);
OSYieldResult osSpTaskYielded(OSTask* task);
#endif

View File

@ -1,5 +1,5 @@
#ifndef ULTRA64_UCODE_H
#define ULTRA64_UCODE_H
#ifndef PR_UCODE_H
#define PR_UCODE_H
#include "PR/ultratypes.h"

View File

@ -1,5 +1,5 @@
#ifndef _ULTRATYPES_H_
#define _ULTRATYPES_H_
#ifndef PR_ULTRATYPES_H
#define PR_ULTRATYPES_H
typedef signed char s8;
typedef unsigned char u8;
@ -22,27 +22,7 @@ typedef volatile s64 vs64;
typedef float f32;
typedef double f64;
// TODO: move this somewhere else
typedef void* TexturePtr;
typedef long int Mtx_t[4][4];
typedef union {
Mtx_t m;
struct {
u16 intPart[4][4];
u16 fracPart[4][4];
};
long long int forc_structure_alignment;
} Mtx; // size = 0x40
typedef float MtxF_t[4][4];
typedef union {
MtxF_t mf;
struct {
float xx, yx, zx, wx,
xy, yy, zy, wy,
xz, yz, zz, wz,
xw, yw, zw, ww;
};
} MtxF; // size = 0x40
#endif

73
include/PR/viint.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef PR_VIINT_H
#define PR_VIINT_H
#include "ultratypes.h"
#define OS_TV_TYPE_PAL 0
#define OS_TV_TYPE_NTSC 1
#define OS_TV_TYPE_MPAL 2
#define VI_STATE_MODE_UPDATED (1 << 0)
#define VI_STATE_XSCALE_UPDATED (1 << 1)
#define VI_STATE_YSCALE_UPDATED (1 << 2)
#define VI_STATE_CTRL_UPDATED (1 << 3) // related to control regs changing
#define VI_STATE_BUFFER_UPDATED (1 << 4) // swap buffer
#define VI_STATE_BLACK (1 << 5) // probably related to a black screen
#define VI_STATE_REPEATLINE (1 << 6) // repeat line?
#define VI_STATE_FADE (1 << 7) // fade
#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */
#define VI_SCALE_MASK 0xFFF
#define VI_2_10_FPART_MASK 0x3FF
#define VI_SUBPIXEL_SH 0x10
// For use in initializing OSViMode structures
#define BURST(hsync_width, color_width, vsync_width, color_start) \
(((u32)(hsync_width) & 0xFF) | (((u32)(color_width) & 0xFF) << 8) | (((u32)(vsync_width) & 0xF) << 16) | (((u32)(color_start) & 0xFFFF) << 20))
#define WIDTH(v) (v)
#define VSYNC(v) (v)
#define HSYNC(duration, leap) (((u32)(leap) << 16) | ((u32)(duration) & 0xFFFF))
#define LEAP(upper, lower) (((u32)(upper) << 16) | ((u32)(lower) & 0xFFFF))
#define START(start, end) (((u32)(start) << 16) | ((u32)(end) & 0xFFFF))
#define FTOFIX(val, i, f) ((u32)((val) * (f32)(1 << (f))) & ((1 << ((i) + (f))) - 1))
#define F210(val) FTOFIX(val, 2, 10)
#define SCALE(scaleup, off) (F210((1.0f / (f32)(scaleup))) | (F210((f32)(off)) << 16))
#define VCURRENT(v) v
#define ORIGIN(v) v
#define VINTR(v) v
#define HSTART START
typedef struct {
/* 0x0 */ f32 factor;
/* 0x4 */ u16 offset;
/* 0x8 */ u32 scale;
} __OSViScale; // size = 0x0C
typedef struct {
/* 0x00 */ u16 state;
/* 0x02 */ u16 retraceCount;
/* 0x04 */ void* buffer;
/* 0x08 */ OSViMode* modep;
/* 0x0C */ u32 features;
/* 0x10 */ OSMesgQueue* mq;
/* 0x14 */ OSMesg* msg;
/* 0x18 */ __OSViScale x;
/* 0x24 */ __OSViScale y;
} __OSViContext; // size = 0x30
void __osViSwapContext(void);
extern __OSViContext* __osViCurr;
extern __OSViContext* __osViNext;
extern u32 __additional_scanline;
__OSViContext* __osViGetCurrentContext(void);
void __osViInit(void);
#endif

View File

@ -1,6 +1,7 @@
#ifndef _XSTDIO_H_
#define _XSTDIO_H_
#ifndef PR_XSTDIO_H
#define PR_XSTDIO_H
#include "ultratypes.h"
#include "libc/stdarg.h"
typedef struct {
@ -30,4 +31,8 @@ typedef void* (*PrintCallback)(void*, const char*, size_t);
#define FLAGS_HASH 8
#define FLAGS_ZERO 16
s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap);
void _Litob(_Pft* args, u8 type);
void _Ldtob(_Pft* args, u8 type);
#endif

View File

@ -5,9 +5,9 @@
#include "PR/ultratypes.h"
#include "libc/stddef.h"
#include "libc/stdint.h"
#include "ultra64/message.h"
#include "PR/os_message.h"
#include "unk.h"
#include "os.h"
#include "PR/os.h"
struct Sample;

View File

@ -1,4 +0,0 @@
#ifndef _BSTRING_H_
#define _BSTRING_H_
#endif

7
include/debug.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef DEBUG_H
#define DEBUG_H
void _dbg_hungup(const char* file, int lineNum);
void Reset(void);
#endif

View File

@ -5,7 +5,7 @@
#include "unk.h"
#include "libc/stdarg.h"
#include "libc/stdint.h"
#include "io/controller.h"
#include "PR/controller.h"
#include "padmgr.h"
#include "stack.h"

View File

@ -41,7 +41,6 @@ void CIC6105_AddRomInfoFaultPage(void);
void CIC6105_RemoveRomInfoFaultPage(void);
void func_800818F4(void);
void __osSyncVPrintf(const char* fmt, ...);
void osSyncPrintf(const char* fmt, ...);
void rmonPrintf(const char* fmt, ...);
void func_80084940(void);
@ -68,8 +67,6 @@ void PadUtils_UpdateRelXY(Input* input);
void MtxConv_F2L(Mtx* mtx, MtxF* mf);
void MtxConv_L2F(MtxF* mtx, Mtx* mf);
void __assert(const char* file, u32 lineNum);
// void func_800862B4(void);
s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3);
u32 Rand_Next(void);
@ -81,9 +78,6 @@ u32 Rand_Next_Variable(u32* rndNum);
f32 Rand_ZeroOne_Variable(u32* rndNum);
f32 Rand_Centered_Variable(u32* rndNum);
void* proutSprintf(void* dst, const char* fmt, size_t size);
s32 vsprintf(char* dst, char* fmt, va_list args);
s32 sprintf(char* dst, char* fmt, ...);
s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);
s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...);
void Sleep_Cycles(OSTime time);
@ -91,223 +85,7 @@ void Sleep_Nsec(u32 nsec);
void Sleep_Usec(u32 usec);
void Sleep_Msec(u32 ms);
void Sleep_Sec(u32 sec);
// void __osSetCause(void);
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags);
s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes);
void osViExtendVStart(u32 a0);
void osStopThread(OSThread* t);
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags);
OSIntMask osSetIntMask(OSIntMask im);
// OSIntMask osGetIntMask(void);
void guScale(Mtx* mtx, f32 x, f32 y, f32 z);
f32 sinf(f32 __x);
s16 sins(u16 x);
OSTask* _VirtualToPhysicalTask(OSTask* intp);
void osSpTaskLoad(OSTask* intp);
void osSpTaskStartGo(OSTask* tp);
long long __ull_rshift(unsigned long long left, unsigned long long right);
unsigned long long __ull_rem(unsigned long long left, unsigned long long right);
unsigned long long __ull_div(unsigned long long left, unsigned long long right);
long long __ll_lshift(long long left, long long right);
long long __ll_rem(long long left, unsigned long long right);
long long __ll_div(long long left, long long right);
long long __ll_mul(long long left, long long right);
void __ull_divremi(unsigned long long* quotient, unsigned long long* remainder, unsigned long long dividend, unsigned short divisor);
long long __ll_mod(long long left, long long right);
long long __ll_rshift(long long left, long long right);
void __osExceptionPreamble(void);
void __osException(void);
// void send_mesg(void);
// void handle_CpU(void);
void __osEnqueueAndYield(OSThread** param_1);
void __osEnqueueThread(OSThread** param_1, OSThread* param_2);
OSThread* __osPopThread(OSThread** param_1);
// void __osNop(void);
void __osDispatchThread(void);
void __osCleanupThread(void);
void __osDequeueThread(OSThread** queue, OSThread* t);
void osDestroyThread(OSThread* t);
void bzero(void* begin, s32 length);
void __osSiCreateAccessQueue(void);
void __osSiGetAccess(void);
void __osSiRelAccess(void);
s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data);
void __osContGetInitData(u8* pattern, OSContStatus* data);
void __osPackRequestData(u8 poll);
void osCreateThread(OSThread* thread, OSId id, void* entry, void* arg, void* sp, OSPri p);
s32 osContStartReadData(OSMesgQueue* mq);
void osContGetReadData(OSContPad* data);
void __osPackReadData(void);
uintptr_t osVirtualToPhysical(void* virtualAddress);
u32 __osGetSR(void);
void __osSetSR(u32 value);
void osWritebackDCache(void* vaddr, s32 nbytes);
void __createSpeedParam(void);
void osInitialize(void);
void __osInitialize_autodetect(void);
void* osViGetNextFramebuffer(void);
void guPerspectiveF(float mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale);
s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size);
s32 __osSiRawStartDma(s32 direction, void* dramAddr);
s32 osEPiLinkHandle(OSPiHandle* handle);
void osViBlack(u8 active);
s32 __osSiRawReadIo(uintptr_t devAddr, u32* data);
OSId osGetThreadId(OSThread* t);
void osSpTaskYield(void);
s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page);
s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data);
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel);
// void __osPfsRequestOneChannel(void);
// void __osPfsGetOneChannelData(void);
void guMtxIdentF(float mf[4][4]);
void osViSetMode(OSViMode* modep);
// void __osGetConfig(void);
// void __osSetConfig(void);
void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo);
s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage);
s32 osStopTimer(OSTimer* t);
u32 __osProbeTLB(void* param_1);
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt);
void __osPiCreateAccessQueue(void);
void __osPiGetAccess(void);
void __osPiRelAccess(void);
void __osDevMgrMain(void* arg);
// void func_8008C640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16, UNK_TYPE4 param_17, UNK_TYPE4 param_18);
s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size);
u16 __osSumcalc(u8* ptr, s32 length);
s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum);
s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid);
// void __osCheckPackId(void);
s32 __osCheckId(OSPfs* pfs);
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank);
u32 osGetCount(void);
void guMtxL2F(MtxF* m1, Mtx* m2);
u32 osGetMemSize(void);
s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo);
void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m);
f32 sqrtf(f32 f);
s32 osAfterPreNMI(void);
s32 osContStartQuery(OSMesgQueue* mq);
void osContGetQuery(OSContStatus* data);
void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight);
void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight);
s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap);
void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac);
void osUnmapTLBAll(void);
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction);
const char* strchr(const char* s, s32 c);
size_t strlen(const char* s);
void* memcpy(void* s1, const void* s2, size_t n);
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msq, s32 count);
void osInvalICache(void* vaddr, size_t nbytes);
void osInvalDCache(void* vaddr, size_t nbytes);
void __osTimerServicesInit(void);
void __osTimerInterrupt(void);
void __osSetTimerIntr(OSTime tim);
OSTime __osInsertTimer(OSTimer* t);
s32 __osSpDeviceBusy(void);
s32 __osSiDeviceBusy(void);
void guMtxIdent(Mtx* mtx);
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
void osSetThreadPri(OSThread* thread, OSPri p);
OSPri osGetThreadPri(OSThread* t);
s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data);
void osViSwapBuffer(void* frameBufPtr);
void guPositionF(float mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size);
OSYieldResult osSpTaskYielded(OSTask* task);
s32 bcmp(void* __s1, void* __s2, size_t __n);
OSTime osGetTime(void);
void guRotateF(float m[4][4], f32 a, f32 x, f32 y, f32 z);
void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z);
void __osSetGlobalIntMask(u32 mask);
s32 __osContChannelReset(OSMesgQueue* mq, s32 channel);
s32 osAiSetFrequency(u32 frequency);
s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* buffer);
u8 __osContAddressCrc(u16 addr);
u8 __osContDataCrc(u8* data);
OSThread* __osGetActiveQueue(void);
void guNormalize(float* x, float* y, float* z);
void __osSetCompare(u32 value);
// u32 __osGetCompare(void);
u32 osDpGetStatus(void);
void osDpSetStatus(u32 data);
void bcopy(void* __src, void* __dest, size_t __n);
void __osResetGlobalIntMask(u32 mask);
// void osPfsDeleteFile(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
// void __osPfsReleasePages(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
void guOrthoF(float m[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale);
void guOrtho(Mtx* m, f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale);
OSIntMask __osDisableInt(void);
void __osRestoreInt(OSIntMask im);
void __osViInit(void);
void __osViSwapContext(void);
OSMesgQueue* osPiGetCmdQueue(void);
f32 cosf(f32 __x);
s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data);
void osViSetSpecialFeatures(u32 func);
s16 coss(u16 x);
void osSetTime(OSTime ticks);
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount);
s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern);
// void __osPfsRequestData(void);
// void __osPfsGetInitData(void);
OSPiHandle* osCartRomInit(void);
// void guS2DInitBg(void);
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank);
s32 osContSetCh(u8 ch);
u32 __osSetFpcCsr(u32 value);
u32 __osGetFpcCsr(void);
// void osPfsFileState(void);
// void osPfsInitPak(void);
// void __osPfsCheckRamArea(void);
// void osPfsChecker(void);
u32 osAiGetLength(void);
s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data);
void osMapTLBRdb(void);
void osYieldThread(void);
void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z);
u32 __osGetCause(void);
s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force);
s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data);
s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg);
void _Ldtob(_Pft* args, u8 type);
// void _Ldunscale(void);
void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp);
ldiv_t ldiv(long numer, long denom);
lldiv_t lldiv(long long numer, long long denom);
void _Litob(_Pft* args, u8 type);
s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data);
u32 __osSpGetStatus(void);
void __osSpSetStatus(u32 data);
void osCreateViManager(OSPri pri);
// void viMgrMain(OSDevMgr* iParm1);
__OSViContext* __osViGetCurrentContext(void);
void osWritebackDCacheAll(void);
OSThread* __osGetCurrFaultedThread(void);
void guMtxF2L(float mf[4][4], Mtx* m);
void osStartThread(OSThread* t);
void osViSetYScale(f32 value);
void osViSetXScale(f32 value);
long long __d_to_ll(double d);
long long __f_to_ll(float f);
unsigned long long __d_to_ull(double d);
unsigned long long __f_to_ull(float f);
double __ll_to_d(long long s);
float __ll_to_f(long long s);
double __ull_to_d(unsigned long long u);
float __ull_to_f(unsigned long long u);
u32* osViGetCurrentFramebuffer(void);
s32 __osSpSetPc(void* pc);
void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg);
void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg);
u32 __osGetWatchLo(void);
void __osSetWatchLo(u32 value);
f32 fmodf(f32 dividend, f32 divisor);
void* __osMemset(void* ptr, s32 val, size_t size);
s32 __osStrcmp(const char* str1, const char* str2);
@ -1625,22 +1403,6 @@ void SysFlashrom_WriteDataSync(void* addr, u32 pageNum, u32 pageCount);
s32 func_80185F90(u32 arg0);
u32 osFlashGetAddr(u32 pageNum);
OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start);
void osFlashChange(u32 flashNum);
OSPiHandle* osFlashInit(void);
void osFlashReadStatus(u8* flashStatus);
void osFlashReadId(u32* flashType, u32* flashVendor);
void osFlashClearStatus(void);
s32 osFlashAllErase(void);
void osFlashAllEraseThrough(void);
s32 osFlashCheckEraseEnd(void);
s32 osFlashSectorErase(u32 pageNum);
void osFlashSectorEraseThrough(u32 pageNum);
s32 osFlashWriteBuffer(OSIoMesg* mb, s32 priority, void* dramAddr, OSMesgQueue* mq);
s32 osFlashWriteArray(u32 pageNum);
s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u32 pageCount, OSMesgQueue* mq);
Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame);
AudioTask* AudioThread_Update(void);
@ -1661,8 +1423,6 @@ void AudioThread_InitMesgQueues(void);
void Audio_InvalDCache(void* buf, size_t size);
void Audio_WritebackDCache(void* buf, size_t size);
s32 osAiSetNextBuffer(void* buf, u32 size);
void AudioPlayback_NoteDisable(Note* note);
void AudioPlayback_ProcessNotes(void);
TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone);

View File

@ -5,6 +5,7 @@
#include "PR/sched.h"
#include "thga.h"
#include "alignment.h"
#include "unk.h"
struct GameState;

View File

@ -4,7 +4,8 @@
#include "color.h"
#include "PR/gbi.h"
#include "PR/ultratypes.h"
#include "xstdio.h"
#include "PR/xstdio.h"
#include "unk.h"
#define GFXP_UNUSED "\x8E"
#define GFXP_UNUSED_CHAR 0x8E

View File

@ -1,14 +1,8 @@
#ifndef IRQMGR_H
#define IRQMGR_H
#include "PR/sched.h"
#include "os.h"
#include "ultra64.h"
#define OS_SC_RETRACE_MSG 1
#define OS_SC_DONE_MSG 2
#define OS_SC_NMI_MSG 3 // name is made up, 3 is OS_SC_RDP_DONE_MSG in the original sched.c
#define OS_SC_PRE_NMI_MSG 4
#include "PR/sched.h"
typedef struct IrqMgrClient {
/* 0x0 */ struct IrqMgrClient* next;

View File

@ -1,5 +1,5 @@
#ifndef ALLOCA_H
#define ALLOCA_H
#ifndef LIBC_ALLOCA_H
#define LIBC_ALLOCA_H
void* alloca(u32);
#define alloca __builtin_alloca

View File

@ -1,4 +0,0 @@
#ifndef ASSERT_H
#define ASSERT_H
#endif

View File

@ -1,5 +1,5 @@
#ifndef MATH_H
#define MATH_H
#ifndef LIBC_MATH_H
#define LIBC_MATH_H
#include "PR/ultratypes.h"
@ -27,8 +27,10 @@ extern f32 __libm_qnan_f;
float fabsf(float f);
#pragma intrinsic(fabsf)
float sqrtf(float f);
#pragma intrinsic(sqrtf)
#ifdef __GNUC__
#define fabsf(f) __builtin_fabsf((float)(f))
#endif
double sqrt(double d);
#pragma intrinsic(sqrt)

View File

@ -1,7 +1,5 @@
#ifndef STDARG_H
#define STDARG_H
#include "ultra64.h"
#ifndef LIBC_STDARG_H
#define LIBC_STDARG_H
// When building with GCC, use the official vaarg macros to avoid warnings
// and possibly bad codegen.

View File

@ -1,5 +1,5 @@
#ifndef STDBOOL
#define STDBOOL
#ifndef LIBC_STDBOOL_H
#define LIBC_STDBOOL_H
#define __bool_true_false_are_defined 1

View File

@ -1,5 +1,5 @@
#ifndef STDDEF_H
#define STDDEF_H
#ifndef LIBC_STDDEF_H
#define LIBC_STDDEF_H
#include "PR/ultratypes.h"

View File

@ -1,5 +1,5 @@
#ifndef STDINT_H
#define STDINT_H
#ifndef LIBC_STDINT_H
#define LIBC_STDINT_H
#include "PR/ultratypes.h"

View File

@ -1,5 +1,5 @@
#ifndef STDLIB_H
#define STDLIB_H
#ifndef LIBC_STDLIB_H
#define LIBC_STDLIB_H
#include "libc/stddef.h"
@ -22,4 +22,7 @@ typedef int ssize_t;
typedef long wchar_t;
ldiv_t ldiv(long numer, long denom);
lldiv_t lldiv(long long numer, long long denom);
#endif /* STDLIB_H */

12
include/libc/string.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef LIBC_STRING_H
#define LIBC_STRING_H
#include "libc/stddef.h"
const char* strchr(const char* s, int c);
size_t strlen(const char* s);
void* memcpy(void* s1, const void* s2, size_t n);
#endif

View File

@ -2,7 +2,7 @@
#define MACROS_H
#include "libc/stdint.h"
#include "ultra64/convert.h"
#include "PR/os_convert.h"
#include "main.h"
#define SCREEN_WIDTH 320

View File

@ -1,8 +1,8 @@
#ifndef OS_MALLOC
#define OS_MALLOC
#ifndef OS_MALLOC_H
#define OS_MALLOC_H
#include "PR/ultratypes.h"
#include "ultra64/message.h"
#include "PR/os_message.h"
#include "libc/stddef.h"
typedef struct ArenaNode {

View File

@ -1,26 +0,0 @@
#ifndef _OSINT_H_
#define _OSINT_H_
// TODO should be in libultra/os
#include "libc/stdarg.h"
#include "os.h"
#include "os_internal.h"
#include "ultraerror.h"
#include "ultralog.h"
typedef struct {
/* 0x0 */ OSMesgQueue* messageQueue;
/* 0x4 */ OSMesg message;
} __OSEventState;
typedef struct {
/* 0x0 */ OSThread* next;
/* 0x4 */ OSPri priority;
} __OSThreadTail;
extern __osHwInt __osHwIntTable[];
extern __OSEventState __osEventStateTab[];
#endif

View File

@ -2,15 +2,9 @@
#define PADMGR_H
#include "libc/stdbool.h"
#include "io/controller.h"
#include "ultra64.h"
#include "irqmgr.h"
typedef struct Input {
/* 0x00 */ OSContPad cur;
/* 0x06 */ OSContPad prev;
/* 0x0C */ OSContPad press; // X/Y store delta from last frame
/* 0x12 */ OSContPad rel; // X/Y store adjusted
} Input; // size = 0x18
#include "padutils.h"
typedef enum {
/* 0 */ PADMGR_CONT_NONE,

14
include/padutils.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef PADUTILS_H
#define PADUTILS_H
#include "PR/controller.h"
typedef struct Input {
/* 0x00 */ OSContPad cur;
/* 0x06 */ OSContPad prev;
/* 0x0C */ OSContPad press; // X/Y store delta from last frame
/* 0x12 */ OSContPad rel; // X/Y store adjusted
} Input; // size = 0x18
#endif

View File

@ -1,13 +0,0 @@
#ifndef _RAMROM_H_
#define _RAMROM_H_
#include "PR/ultratypes.h"
typedef struct {
/* 0x0 */ long type;
/* 0x4 */ long length;
/* 0x8 */ long magic;
/* 0xC */ unsigned char userdata[24564];
} RamRomBuffer;
#endif

View File

@ -1,10 +0,0 @@
#ifndef _RDB_H_
#define _RDB_H_
typedef struct {
/* 0x0 */ unsigned int type : 2;
/* 0x0 */ unsigned int length : 2;
/* 0x1 */ unsigned char buf[3];
} rdbPacket;
#endif

View File

@ -5,6 +5,8 @@
#define REGS_H
#include "ultra64.h"
#include "unk.h"
#define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc.
#define REG_PAGES 6

View File

@ -1,4 +0,0 @@
#ifndef _RMON_H_
#define _RMON_H_
#endif

View File

@ -3,8 +3,8 @@
#include "PR/ultratypes.h"
#include "PR/sched.h"
#include "ultra64/vi.h"
#include "ultra64/sptask.h"
#include "PR/os_vi.h"
#include "PR/sptask.h"
#include "irqmgr.h"
#define TASK_FRAMEBUFFER(task) ((CfbInfo*)(task)->framebuffer)

View File

@ -1,21 +1,23 @@
#ifndef _ULTRA64_H_
#define _ULTRA64_H_
#ifndef ULTRA64_H
#define ULTRA64_H
#include "PR/ultratypes.h"
#include "PR/gbi.h"
#include "unk.h"
#include "ultra64/controller_voice.h"
#include "ultra64/hardware.h"
#include "ultra64/message.h"
#include "ultra64/sptask.h"
#include "ultra64/thread.h"
#include "ultra64/rcp.h"
#include "ultra64/rdp.h"
#include "ultra64/rsp.h"
#include "ultra64/r4300.h"
#include "ultra64/ucode.h"
#include "ultra64/vi.h"
#include "PR/gu.h"
#include "PR/controller_voice.h"
#include "PR/hardware.h"
#include "PR/os.h"
#include "PR/osint.h"
#include "PR/piint.h"
#include "PR/siint.h"
#include "PR/sptask.h"
#include "PR/rcp.h"
#include "PR/rdp.h"
#include "PR/rsp.h"
#include "PR/r4300.h"
#include "PR/ucode.h"
#include "PR/viint.h"
#include "PR/xstdio.h"
#endif

View File

@ -1,37 +0,0 @@
#ifndef ULTRA64_VIINT_H
#define ULTRA64_VIINT_H
#define VI_STATE_MODE_SET (1 << 0)
#define VI_STATE_XSCALE_SET (1 << 1)
#define VI_STATE_YSCALE_FACTOR_SET (1 << 2)
#define VI_STATE_CTRL_SET (1 << 3)
#define VI_STATE_BUFFER_SET (1 << 4)
#define VI_STATE_BLACK (1 << 5)
#define VI_STATE_REPEATLINE (1 << 6)
#define VI_STATE_FADE (1 << 7)
#define VI_SCALE_MASK 0xFFF
#define VI_2_10_FPART_MASK 0x3FF
#define VI_SUBPIXEL_SH 0x10
// For use in initializing OSViMode structures
#define BURST(hsync_width, color_width, vsync_width, color_start) \
(((u32)(hsync_width) & 0xFF) | (((u32)(color_width) & 0xFF) << 8) | (((u32)(vsync_width) & 0xF) << 16) | (((u32)(color_start) & 0xFFFF) << 20))
#define WIDTH(v) (v)
#define VSYNC(v) (v)
#define HSYNC(duration, leap) (((u32)(leap) << 16) | ((u32)(duration) & 0xFFFF))
#define LEAP(upper, lower) (((u32)(upper) << 16) | ((u32)(lower) & 0xFFFF))
#define START(start, end) (((u32)(start) << 16) | ((u32)(end) & 0xFFFF))
#define FTOFIX(val, i, f) ((u32)((val) * (f32)(1 << (f))) & ((1 << ((i) + (f))) - 1))
#define F210(val) FTOFIX(val, 2, 10)
#define SCALE(scaleup, off) (F210((1.0f / (f32)(scaleup))) | (F210((f32)(off)) << 16))
#define VCURRENT(v) v
#define ORIGIN(v) v
#define VINTR(v) v
#define HSTART START
#endif

View File

@ -1,6 +0,0 @@
#ifndef _ULTRAERROR_H_
#define _ULTRAERROR_H_
typedef void (*OSErrorHandler)(/* ECOFF does not store param types */);
#endif

View File

@ -1,28 +0,0 @@
#ifndef _ULTRALOG_H_
#define _ULTRALOG_H_
#include "PR/ultratypes.h"
typedef struct {
/* 0x0 */ u32 magic;
/* 0x4 */ u32 len;
/* 0x8 */ u32* base;
/* 0xC */ s32 startCount;
/* 0x10 */ s32 writeOffset;
} OSLog;
typedef struct {
/* 0x0 */ u32 magic;
/* 0x4 */ u32 timeStamp;
/* 0x8 */ u16 argCount;
/* 0xA */ u16 eventID;
} OSLogItem;
typedef struct {
/* 0x0 */ u32 magic;
/* 0x4 */ u32 version;
} OSLogFileHdr;
#endif

View File

@ -34,7 +34,6 @@ extern s32 sIrqMgrRetraceCount;
extern OSViMode osViModeNtscHpf1;
extern OSViMode osViModePalLan1;
extern s16 sintable[0x400];
extern __osHwInt __osHwIntTable[];
// extern UNK_TYPE1 D_80097DE4;
// extern UNK_TYPE4 D_80097E08;
extern OSThread* __osThreadTail;
@ -63,14 +62,12 @@ extern s32 __osPfsLastChannel;
extern OSViMode osViModeNtscLan1;
extern OSViMode osViModeMpalLan1;
// extern __OSViContext D_80098060[2];
extern __OSViContext* __osViCurr;
extern __OSViContext* __osViNext;
// extern UNK_TYPE4 sCartRomNeedsInit;
extern OSViMode osViModeFpalLan1;
// extern u8 ldigs[];
// extern u8 udigs[];
// extern OSDevMgr __osViDevMgr;
extern u32 __additional_scanline;
extern char bootThreadName[];
extern char idleThreadName[];
@ -160,7 +157,6 @@ extern OSPiHandle D_8009D1A8;
extern OSMesg D_8009E3F0[1];
extern OSMesgQueue __osPiAccessQueue;
extern __OSInode __osPfsInodeCache;
extern __OSEventState __osEventStateTab[16];
extern OSTimer D_8009E590;
extern OSTime __osCurrentTime;
extern u32 __osBaseCounter;

View File

@ -1,28 +0,0 @@
#ifndef _VIINT_H_
#define _VIINT_H_
// TODO should be in libultra/io
#include "PR/ultratypes.h"
#include "os.h"
// typedef struct {
// /* 0x0 */ f32 factor;
// /* 0x4 */ u16 offset;
// /* 0x8 */ u32 scale;
// } __OSViScale;
typedef struct {
/* 0x0 */ u16 state;
/* 0x2 */ u16 retraceCount;
/* 0x4 */ void* buffer;
/* 0x8 */ OSViMode* modep;
/* 0xC */ u32 control;
/* 0x10 */ OSMesgQueue* msgq;
/* 0x14 */ OSMesg msg;
/* 0x18 */ __OSViScale x;
/* 0x24 */ __OSViScale y;
} __OSViContext; // size = 0x30
#endif

View File

@ -9,14 +9,10 @@
#include "libc/stdlib.h"
#include "ultra64.h"
#include "ultra64/gs2dex.h"
#include "io/controller.h"
#include "osint.h"
#include "os.h"
#include "irqmgr.h"
#include "padmgr.h"
#include "scheduler.h"
#include "xstdio.h"
#include "color.h"
#include "ichain.h"
@ -27,6 +23,7 @@
#include "gfx.h"
#include "gfxprint.h"
#include "padutils.h"
#include "sys_matrix.h"
#include "tha.h"
#include "thga.h"

View File

@ -2,6 +2,7 @@
#define Z64ACTOR_H
#include "PR/ultratypes.h"
#include "padutils.h"
#include "z64math.h"
#include "z64animation.h"
#include "z64collision_check.h"

View File

@ -2,7 +2,8 @@
#define Z64AUDIO_H
#include "PR/ultratypes.h"
#include "ultra64/os_voice.h"
#include "PR/os_voice.h"
#include "audiothread_cmd.h"
#include "libc/stddef.h"
#include "unk.h"
#include "audiothread_cmd.h"

View File

@ -2,9 +2,10 @@
#define Z64BOMBERS_NOTEBOOK_H
#include "ultra64.h"
#include "io/controller.h"
#include "z64dma.h"
struct PlayState;
#define DEFINE_PERSON(enum, _photo, _description, _metEnum, _metMessage, _metFlag) enum,
typedef enum BombersNotebookPerson {
#include "tables/bombers_notebook/person_table.h"

View File

@ -1,15 +1,17 @@
#ifndef Z64FRAMEADVANCE_H
#define Z64FRAMEADVANCE_H
#include "padmgr.h"
#include "ultra64.h"
struct Input;
typedef struct FrameAdvanceContext {
/* 0x0 */ s32 enabled;
/* 0x4 */ s32 timer;
} FrameAdvanceContext; // size = 0x8
void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx);
s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input);
s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, struct Input* input);
#endif

View File

@ -4,9 +4,10 @@
#include "ultra64.h"
#include "libc/stdbool.h"
#include "libc/stdint.h"
#include "io/controller.h"
#include "padutils.h"
#include "tha.h"
#include "padmgr.h"
#include "unk.h"
struct GraphicsContext;
struct GameState;

View File

@ -2,7 +2,7 @@
#define Z64JPEG_H
#include "PR/ultratypes.h"
#include "ultra64/message.h"
#include "PR/os_message.h"
#include "PR/sched.h"
typedef struct {

View File

@ -114,6 +114,17 @@ typedef enum {
/* 2 */ OLIB_DIFF // Sub `a` and `b` to dest
} OlibVec3fDiff;
typedef float MtxF_t[4][4];
typedef union {
MtxF_t mf;
struct {
float xx, yx, zx, wx,
xy, yy, zy, wy,
xz, yz, zz, wz,
xw, yw, zw, ww;
};
} MtxF; // size = 0x40
#define LERPIMP(v0, v1, t) ((v0) + (((v1) - (v0)) * (t)))
#define F32_LERP(v0, v1, t) ((1.0f - (t)) * (f32)(v0) + (t) * (f32)(v1))
#define F32_LERPIMP(v0, v1, t) ((f32)(v0) + (((f32)(v1) - (f32)(v0)) * (t)))

View File

@ -2,7 +2,7 @@
#define Z64PLAYER_H
#include "alignment.h"
#include "os.h"
#include "PR/os.h"
#include "z64actor.h"
struct Player;

View File

@ -2,7 +2,7 @@
#define Z64RUMBLE_H
#include "PR/ultratypes.h"
#include "io/controller.h"
#include "PR/controller.h"
typedef enum RumbleManagerState {
/* 0 */ RUMBLEMANAGER_STATE_WIPE, // Disables the request processing and wipes every request. It can be either set manually or automatically by the system as fail-safe in case the Rumble Pak has been vibrating for 2 minutes

View File

@ -2,9 +2,9 @@
#define Z64SAVE_H
#include "ultra64.h"
#include "PR/os.h"
#include "z64item.h"
#include "z64math.h"
#include "os.h"
struct GameState;
struct PlayState;

2
spec
View File

@ -33,7 +33,7 @@ beginseg
include "build/src/boot_O2/gfxprint.o"
include "build/data/boot/gfxprint.data.o"
include "build/src/boot_O2/mtxuty-cvt.o"
include "build/src/boot_O2/assert.o"
include "build/src/boot_O2/debug.o"
include "build/src/boot_O2/system_heap.o"
include "build/src/boot_O2/padsetup.o"
include "build/src/boot_O2/boot_80086760.o"

View File

@ -1,11 +1,11 @@
#include "global.h"
#include "fault.h"
void __assert(const char* file, u32 lineNum) {
void _dbg_hungup(const char* file, int lineNum) {
osGetThreadId(NULL);
Fault_AddHungupAndCrash(file, lineNum);
}
void func_800862B4(void) {
void Reset(void) {
Fault_AddHungupAndCrash("Reset", 0);
}

View File

@ -9,6 +9,7 @@
* The main difference between them seems to be the lack of vramEnd arguments here.
* Instead they are calculated on the fly.
*/
#include "global.h"
#include "system_malloc.h"
#include "loadfragment.h"

View File

@ -15,5 +15,5 @@ void MtxConv_F2L(Mtx* mtx, MtxF* mf) {
}
void MtxConv_L2F(MtxF* mtx, Mtx* mf) {
guMtxL2F(mtx, mf);
guMtxL2F(mtx->mf, mf);
}

View File

@ -1,4 +1,4 @@
#include "global.h"
#include "padutils.h"
void PadUtils_Init(Input* input) {
bzero(input, sizeof(Input));

View File

@ -44,6 +44,7 @@
#include "fault.h"
#include "global.h"
#include "vt.h"
#include "PR/osint.h"
#include "stackcheck.h"
#include "z64thread.h"

View File

@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "fault.h"

View File

@ -11,6 +11,7 @@
#include "z64vismono.h"
#include "z64viszbuf.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "debug.h"
s32 gFramerateDivisor = 1;
f32 gFramerateDivisorF = 1.0f;
@ -168,7 +169,7 @@ void GameState_InitArena(GameState* gameState, size_t size) {
}
THA_Init(&gameState->heap, NULL, 0);
__assert("../game.c", 1035);
_dbg_hungup("../game.c", 1035);
}
void GameState_Realloc(GameState* gameState, size_t size) {
@ -192,7 +193,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
THA_Init(&gameState->heap, gameArena, size);
} else {
THA_Init(&gameState->heap, NULL, 0);
__assert("../game.c", 1074);
_dbg_hungup("../game.c", 1074);
}
}

View File

@ -32,8 +32,8 @@
*/
#include "global.h"
#include "io/controller.h"
#include "ultra64/motor.h"
#include "PR/controller.h"
#include "PR/os_motor.h"
#include "fault.h"
#define PADMGR_RETRACE_MSG (1 << 0)

View File

@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "fault.h"

View File

@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "fault.h"
#include "fixed_point.h"

Some files were not shown because too many files have changed in this diff Show More