mirror of
https://github.com/pret/pokestadium.git
synced 2026-04-25 07:57:01 -05:00
decompile rsp
This commit is contained in:
parent
5c96482eaa
commit
7e8d5acf86
11
Makefile
11
Makefile
|
|
@ -26,7 +26,7 @@ O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.c.o)) \
|
|||
$(foreach file,$(DATA_FILES),$(BUILD_DIR)/$(file:.bin=.bin.o)) \
|
||||
|
||||
SPLAT_YAML := splat.yaml
|
||||
SPLAT = $(PYTHON) tools/n64splat/split.py --target $(BASEROM) --basedir . $(SPLAT_YAML)
|
||||
SPLAT = $(PYTHON) tools/n64splat/split.py $(SPLAT_YAML)
|
||||
|
||||
##################### Compiler Options #######################
|
||||
CROSS = mips-linux-gnu-
|
||||
|
|
@ -43,8 +43,11 @@ CC = tools/ido_recomp/linux/7.1/cc
|
|||
CC_OLD = tools/ido_recomp/linux/5.3/cc
|
||||
|
||||
ASFLAGS = -EB -mtune=vr4300 -march=vr4300 -Iinclude
|
||||
CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Wab,-r4300_mul -D _LANGUAGE_C
|
||||
LDFLAGS = -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/$(TARGET).map --no-check-sections
|
||||
|
||||
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
|
||||
CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Wab,-r4300_mul -D _LANGUAGE_C -woff 649,838,712
|
||||
|
||||
LDFLAGS = -T undefined_syms.txt -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/$(TARGET).map --no-check-sections
|
||||
|
||||
OPTFLAGS := -O2
|
||||
|
||||
|
|
@ -71,7 +74,7 @@ submodules:
|
|||
git submodule update --init --recursive
|
||||
|
||||
split:
|
||||
rm -rf $(DATA_DIRS) $(ASM_DIRS) && ./tools/n64splat/split.py --target baserom.z64 --basedir . $(SPLAT_YAML)
|
||||
rm -rf $(DATA_DIRS) $(ASM_DIRS) && ./tools/n64splat/split.py $(SPLAT_YAML)
|
||||
|
||||
setup: clean submodules split
|
||||
|
||||
|
|
|
|||
280
include/PR/leo.h
Normal file
280
include/PR/leo.h
Normal file
|
|
@ -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 <PR/os.h>
|
||||
#include <PR/leoappli.h>
|
||||
|
||||
#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 */
|
||||
274
include/PR/leoappli.h
Normal file
274
include/PR/leoappli.h
Normal file
|
|
@ -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--------------------------*/
|
||||
|
||||
|
||||
|
|
@ -36,5 +36,6 @@
|
|||
#include <PR/ucode.h>
|
||||
#include <PR/ultraerror.h>
|
||||
#include <PR/ultralog.h>
|
||||
#include <PR/leo.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -310,6 +310,9 @@ segments:
|
|||
- [0x66B50, asm, libultra/os/sethwinterrupt]
|
||||
#- [0x66BC0, asm]
|
||||
- [0x66BC0, bin] # rest of rom part 1
|
||||
|
||||
# Start of .rodata
|
||||
- [0x7BAC0, .rodata, rsp] # rsp.c rodata
|
||||
- [0x7BB10, bin] # rest of rom part 2
|
||||
- [0x7BB10, bin, rom_rodata] # rest of rodata
|
||||
- [0x7F980, bin] # rest of rom part 2
|
||||
- [0x2000000]
|
||||
|
|
|
|||
13
src/main.c
13
src/main.c
|
|
@ -1,10 +1,17 @@
|
|||
#include <ultra64.h>
|
||||
|
||||
extern OSThread D_8007F180;
|
||||
extern OSThread D_8007F730;
|
||||
extern void func_80000460(); // thread 1 function
|
||||
extern void func_8002B330(); // thread 6 function
|
||||
extern u8 D_800818E0[];
|
||||
|
||||
// entry .bss
|
||||
u8 D_8007ED80[0xF180-0xED80]; // unknown, start of .bss
|
||||
OSThread D_8007F180;
|
||||
u8 unk_8007F330[0x400];
|
||||
OSThread D_8007F730;
|
||||
u8 unk_8007F8E0[0x720];
|
||||
u8 D_80080000[0x18E0];
|
||||
u8 D_800818E0[0x18];
|
||||
u8 D_800818F8[0x8];
|
||||
|
||||
void func_80000460(s32 arg0) {
|
||||
osCreateViManager(0xFE);
|
||||
|
|
|
|||
321
src/rsp.c
Normal file
321
src/rsp.c
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
#include <ultra64.h>
|
||||
|
||||
struct UnkStruct800006C4_2 {
|
||||
char unk0;
|
||||
char filler1[0x1B];
|
||||
s32 unk1C;
|
||||
void* unk20;
|
||||
s32 unk24;
|
||||
s32 unk28;
|
||||
};
|
||||
|
||||
struct UnkStruct800006C4_1 {
|
||||
s16 sp20;
|
||||
s8 sp22;
|
||||
OSMesgQueue* sp24;
|
||||
void* sp28;
|
||||
s32 sp2C;
|
||||
s32 sp30;
|
||||
s32 unk34;
|
||||
};
|
||||
|
||||
struct UnkStruct80000A80 {
|
||||
LEOCmd cmd;
|
||||
union {
|
||||
u32 lba;
|
||||
struct {
|
||||
char filler0[0x3];
|
||||
LEOSpdlMode mode;
|
||||
};
|
||||
};
|
||||
void *addr;
|
||||
};
|
||||
|
||||
void func_80057FD0(void *, int);
|
||||
s32 func_8005A990(OSPiHandle*);
|
||||
|
||||
// All from n64 programming manual section 27.2
|
||||
#define SRAM_START_ADDR 0x08000000
|
||||
#define SRAM_SIZE 0x8000
|
||||
#define SRAM_latency 0x5
|
||||
#define SRAM_pulse 0x0c
|
||||
#define SRAM_pageSize 0xd
|
||||
#define SRAM_relDuration 0x2
|
||||
|
||||
struct UnkStruct80083BD0 {
|
||||
OSMesg unk0;
|
||||
u8 unk4[0x18];
|
||||
OSMesgQueue queue1;
|
||||
OSMesgQueue queue2;
|
||||
};
|
||||
|
||||
OSThread D_80081900;
|
||||
u8 unk_80081AB0[0x2000];
|
||||
u8 D_80083AB0[0x9C];
|
||||
OSMesg D_80083B4C;
|
||||
u8 unk_80081B50[0x3C];
|
||||
OSMesg D_80083B8C;
|
||||
u8 unk_80083B90[0x3C];
|
||||
OSMesg D_80083BCC;
|
||||
struct UnkStruct80083BD0 D_80083BD0;
|
||||
//OSMesg D_80083BD0;
|
||||
//u8 D_80083BD4[0x18];
|
||||
//OSMesgQueue D_80083BEC;
|
||||
//OSMesgQueue &D_80083BD0.queue2;
|
||||
s16 D_80083C1C;
|
||||
|
||||
s32 func_800005C0(void) {
|
||||
s32 unused;
|
||||
s32 unused2[6];
|
||||
s32 result;
|
||||
|
||||
result = LeoCJCreateLeoManager(0x95, 0x96, &D_80083B4C, 0x10);
|
||||
if (result == 0) {
|
||||
if (osGetMemSize() >= 0x800000U) {
|
||||
D_80083C1C = 1;
|
||||
}
|
||||
}
|
||||
D_80083C1C = !result;
|
||||
return result;
|
||||
}
|
||||
|
||||
OSPiHandle* func_80000628(void) {
|
||||
static OSPiHandle sramHandle; // D_80083C20
|
||||
|
||||
void* baseAddr = OS_PHYSICAL_TO_K1(SRAM_START_ADDR);
|
||||
if (baseAddr != (void*)sramHandle.baseAddress) {
|
||||
sramHandle.type = DEVICE_TYPE_SRAM;
|
||||
sramHandle.baseAddress = baseAddr;
|
||||
sramHandle.latency = SRAM_latency;
|
||||
sramHandle.pulse = SRAM_pulse;
|
||||
sramHandle.pageSize = SRAM_pageSize;
|
||||
sramHandle.relDuration = SRAM_relDuration;
|
||||
|
||||
sramHandle.domain = PI_DOMAIN2;
|
||||
sramHandle.speed = 0;
|
||||
func_80057FD0(&sramHandle.transferInfo, sizeof(sramHandle.transferInfo));
|
||||
func_8005A990(&sramHandle);
|
||||
}
|
||||
return &sramHandle;
|
||||
}
|
||||
|
||||
s32 func_800006C4(struct UnkStruct800006C4_2* arg0) {
|
||||
struct UnkStruct800006C4_1 unkStruct;
|
||||
s32 unk1C = func_80000628();
|
||||
|
||||
unkStruct.sp22 = 0;
|
||||
unkStruct.sp24 = &D_80083BD0.queue2;
|
||||
unkStruct.sp28 = arg0->unk20;
|
||||
unkStruct.sp2C = arg0->unk1C;
|
||||
unkStruct.sp30 = arg0->unk24;
|
||||
osInvalDCache(arg0->unk20, arg0->unk24);
|
||||
func_8005E0F0(unk1C, &unkStruct.sp20, 0);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_8000074C(struct UnkStruct800006C4_2* arg0) {
|
||||
struct UnkStruct800006C4_1 unkStruct;
|
||||
s32 unk1C = func_80000628();
|
||||
|
||||
unkStruct.sp22 = 0;
|
||||
unkStruct.sp24 = &D_80083BD0.queue2;
|
||||
unkStruct.sp28 = arg0->unk20;
|
||||
unkStruct.sp2C = arg0->unk1C;
|
||||
unkStruct.sp30 = arg0->unk24;
|
||||
osWritebackDCache(arg0->unk20, arg0->unk24);
|
||||
func_8005E0F0(unk1C, &unkStruct.sp20, 1);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_800007D4(struct UnkStruct800006C4_2* arg0, s32 arg1) {
|
||||
struct UnkStruct800006C4_1 unkStruct;
|
||||
OSPiHandle* handle;
|
||||
if(arg1 == 0) {
|
||||
handle = osCartRomInit();
|
||||
} else {
|
||||
handle = osDriveRomInit();
|
||||
}
|
||||
|
||||
unkStruct.sp22 = 0;
|
||||
unkStruct.sp24 = &D_80083BD0.queue2;
|
||||
unkStruct.sp28 = arg0->unk20;
|
||||
unkStruct.sp2C = arg0->unk1C;
|
||||
unkStruct.sp30 = arg0->unk24;
|
||||
osInvalDCache(arg0->unk20, arg0->unk24);
|
||||
func_8005E0F0(handle, &unkStruct.sp20, 0);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_8000087C(struct UnkStruct800006C4_2* arg0) {
|
||||
struct UnkStruct800006C4_1 unkStruct;
|
||||
OSPiHandle* handle;
|
||||
|
||||
handle = osCartRomInit();
|
||||
unkStruct.sp22 = 0;
|
||||
unkStruct.sp24 = &D_80083BD0.queue2;
|
||||
unkStruct.sp28 = arg0->unk20;
|
||||
unkStruct.sp2C = arg0->unk1C;
|
||||
unkStruct.sp30 = arg0->unk24;
|
||||
osWritebackDCache(arg0->unk20, arg0->unk24);
|
||||
func_8005E0F0(handle, &unkStruct.sp20, 1);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_80000904(struct UnkStruct800006C4_2* arg0) {
|
||||
s32 arr[5];
|
||||
s32 sp20;
|
||||
|
||||
osInvalDCache(arg0->unk20, 0x80);
|
||||
func_8000D0B4(&sp20, 0, arg0->unk1C, arg0->unk20, 1, &D_80083BD0.queue2);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_80000974(struct UnkStruct800006C4_2* arg0) {
|
||||
s32 arr[5];
|
||||
s32 sp20_4;
|
||||
s32 sp20_5;
|
||||
|
||||
func_8000CEE4(&sp20_4, 0, arg0->unk20, &D_80083BD0.queue2);
|
||||
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* func_800009C8(void) {
|
||||
void* sp1C;
|
||||
|
||||
osRecvMesg(&D_80083BD0.queue2, &sp1C, 1);
|
||||
return sp1C;
|
||||
}
|
||||
|
||||
void *func_800009F8(struct UnkStruct800006C4_2* arg0) {
|
||||
func_80050FC0(arg0, 0, arg0->unk1C, arg0->unk20, arg0->unk24, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
void *func_80000A3C(struct UnkStruct800006C4_2* arg0) {
|
||||
func_80050FC0(arg0, 1, arg0->unk1C, arg0->unk20, arg0->unk24, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
void *func_80000A80(struct UnkStruct80000A80* arg0) {
|
||||
LeoReadDiskID(&arg0->cmd, arg0->addr, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
void *func_80000AB0(struct UnkStruct80000A80* arg0) {
|
||||
LeoSeek(&arg0->cmd, arg0->lba, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
void *func_80000AE0(struct UnkStruct80000A80* arg0) {
|
||||
LeoSpdlMotor(&arg0->cmd, arg0->mode, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
s32 func_80000B10(struct UnkStruct80000A80* arg0) {
|
||||
s32 temp_v0;
|
||||
|
||||
LeoReadRTC(&arg0->cmd, &D_80083BD0.queue2);
|
||||
temp_v0 = func_800009C8();
|
||||
if (temp_v0 == 0) {
|
||||
*(LEODiskTime*)arg0->addr = arg0->cmd.data.time;
|
||||
}
|
||||
return temp_v0;
|
||||
}
|
||||
|
||||
void *func_80000B74(struct UnkStruct80000A80* arg0) {
|
||||
LeoSetRTC(&arg0->cmd, arg0->addr, &D_80083BD0.queue2);
|
||||
return func_800009C8();
|
||||
}
|
||||
|
||||
void func_80000BA4(void *arg) {
|
||||
struct UnkStruct800006C4_2* sp2C;
|
||||
void* var_v0;
|
||||
|
||||
func_800005C0();
|
||||
func_8000C8F8();
|
||||
while(1) {
|
||||
osRecvMesg(&D_80083BD0.queue1, (void*)&sp2C, 1);
|
||||
switch (sp2C->unk0) {
|
||||
case 0xF0:
|
||||
var_v0 = func_800007D4(sp2C, 0);
|
||||
break;
|
||||
case 0xF1:
|
||||
var_v0 = func_800007D4(sp2C, 1);
|
||||
break;
|
||||
case 0xF2:
|
||||
var_v0 = func_800006C4(sp2C);
|
||||
break;
|
||||
case 0xF3:
|
||||
var_v0 = func_8000074C(sp2C);
|
||||
break;
|
||||
case 0xF4:
|
||||
var_v0 = func_8000087C(sp2C);
|
||||
break;
|
||||
case 0xF5:
|
||||
var_v0 = func_80000904(sp2C);
|
||||
break;
|
||||
case 0xF6:
|
||||
var_v0 = func_80000974(sp2C);
|
||||
break;
|
||||
case 0x5:
|
||||
var_v0 = func_800009F8(sp2C);
|
||||
break;
|
||||
case 0x6:
|
||||
var_v0 = func_80000A3C(sp2C);
|
||||
break;
|
||||
case 0xC:
|
||||
/*
|
||||
* TODO: These castings imply the 2 struct defs are the same struct, but
|
||||
* there is very tenuous aliasing going on due to s16 and u8 overlap where
|
||||
* there should be word loads. What is going on here?
|
||||
*/
|
||||
var_v0 = func_80000A80((struct UnkStruct80000A80 *)sp2C);
|
||||
break;
|
||||
case 0x7:
|
||||
var_v0 = func_80000AB0((struct UnkStruct80000A80 *)sp2C);
|
||||
break;
|
||||
case 0x8:
|
||||
var_v0 = func_80000AE0((struct UnkStruct80000A80 *)sp2C);
|
||||
break;
|
||||
case 0xD:
|
||||
var_v0 = func_80000B10((struct UnkStruct80000A80 *)sp2C);
|
||||
break;
|
||||
case 0xE:
|
||||
var_v0 = func_80000B74((struct UnkStruct80000A80 *)sp2C);
|
||||
break;
|
||||
}
|
||||
if ((OSMesgQueue*)sp2C->unk28 != NULL) {
|
||||
osSendMesg(sp2C->unk28, var_v0, 0);
|
||||
}
|
||||
func_80003004(sp2C);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80000D54(void) {
|
||||
osCreateMesgQueue(&D_80083BD0.queue2, &D_80083BCC, 1);
|
||||
osCreateMesgQueue(&D_80083BD0.queue1, &D_80083B8C, 0x10);
|
||||
func_8005B6A0(0x96, &D_80083BD0.unk4, &D_80083AB0[0x1C], 0x20);
|
||||
osCreateThread(&D_80081900, 0x14, func_80000BA4, NULL, D_80083AB0, 0x5A);
|
||||
osStartThread(&D_80081900);
|
||||
}
|
||||
|
||||
void func_80000DF4(void) {
|
||||
if (D_80083C1C != 0) {
|
||||
LeoReset();
|
||||
D_80083C1C = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void func_80000E2C(void* arg0, s32 arg1) {
|
||||
if (arg1 == 1) {
|
||||
osJamMesg(&D_80083BD0.queue1, arg0, 1);
|
||||
return;
|
||||
}
|
||||
osSendMesg(&D_80083BD0.queue1, arg0, 1);
|
||||
}
|
||||
|
|
@ -2,4 +2,6 @@ D_80078580 = 0x80078580;
|
|||
D_80078584 = 0x80078584;
|
||||
D_8007A860 = 0x8007A860;
|
||||
D_8007A868 = 0x8007A868;
|
||||
__osRunningThread = 0x80079630;
|
||||
__osRunningThread = 0x80079630;
|
||||
D_80080001 = 0x80080001;
|
||||
D_80083ACC = 0x80083ACC;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user