diff --git a/assets/xml/n64dd/error_textures.xml b/assets/xml/misc/n64dd_error_textures.xml similarity index 100% rename from assets/xml/n64dd/error_textures.xml rename to assets/xml/misc/n64dd_error_textures.xml diff --git a/baseroms/ntsc-1.0/config.yml b/baseroms/ntsc-1.0/config.yml index e164590c399..f55ef8b46d4 100644 --- a/baseroms/ntsc-1.0/config.yml +++ b/baseroms/ntsc-1.0/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB600 end_offset: 0xEC088 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC160 end_offset: 0x11D60 - name: misc/link_animetion diff --git a/baseroms/ntsc-1.1/config.yml b/baseroms/ntsc-1.1/config.yml index ee27b55df99..e18ac07d3ed 100644 --- a/baseroms/ntsc-1.1/config.yml +++ b/baseroms/ntsc-1.1/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB7C0 end_offset: 0xEC248 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC140 end_offset: 0x11D40 - name: misc/link_animetion diff --git a/baseroms/ntsc-1.2/config.yml b/baseroms/ntsc-1.2/config.yml index b0c8b18bee1..7db790b9f93 100644 --- a/baseroms/ntsc-1.2/config.yml +++ b/baseroms/ntsc-1.2/config.yml @@ -67,8 +67,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xEB610 end_offset: 0xEC098 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC120 end_offset: 0x11D20 - name: misc/link_animetion diff --git a/baseroms/pal-1.0/config.yml b/baseroms/pal-1.0/config.yml index 2602ed0e7c2..c7522d5c742 100644 --- a/baseroms/pal-1.0/config.yml +++ b/baseroms/pal-1.0/config.yml @@ -73,8 +73,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xE8F20 end_offset: 0xE99A8 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC0E0 end_offset: 0x11CE0 - name: misc/link_animetion diff --git a/baseroms/pal-1.1/config.yml b/baseroms/pal-1.1/config.yml index 4001c620514..9c368020da5 100644 --- a/baseroms/pal-1.1/config.yml +++ b/baseroms/pal-1.1/config.yml @@ -73,8 +73,8 @@ assets: xml_path: assets/xml/code/fbdemo_wipe1.xml start_offset: 0xE8F60 end_offset: 0xE99E8 -- name: n64dd/error_textures - xml_path: assets/xml/n64dd/error_textures.xml +- name: misc/n64dd_error_textures + xml_path: assets/xml/misc/n64dd_error_textures.xml start_offset: 0xC0E0 end_offset: 0x11CE0 - name: misc/link_animetion diff --git a/include/n64dd_internal.h b/include/n64dd_internal.h new file mode 100644 index 00000000000..015c46085b8 --- /dev/null +++ b/include/n64dd_internal.h @@ -0,0 +1,104 @@ +#ifndef N64DD_INTERNAL_H +#define N64DD_INTERNAL_H + +#define BADCASTP (void*) +#define BADCASTI (u32) + +#include "ultra64.h" +#include "n64dd.h" +#include "stack.h" +#include "irqmgr.h" + +extern IrqMgr gIrqMgr; // from main.c + +typedef struct struct_801DA5D0 { + /* 0x00 */ u8 unk0; + /* 0x01 */ char pad1[3]; + /* 0x04 */ s32 unk4; + /* 0x08 */ s8 unk8; + /* 0x09 */ char pad9[3]; + /* 0x0C */ void (*unkC)(s32, s32, s32); + /* 0x10 */ s32 unk10; + /* 0x14 */ void (*unk14)(void*, uintptr_t, size_t); + /* 0x18 */ void* unk18; + union { // different substruct based on struct_801DA5D0.unk0 ? see func_801C8860 + struct { + /* 0x1C */ OSMesgQueue* unk1C; + /* 0x20 */ OSMesgQueue* unk20; + /* 0x24 */ s32 unk24; + /* 0x28 */ void* unk28; + /* 0x2C */ s32 unk2C; + } unk1C_1; + struct { + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; + } unk1C_3_4; + }; +} struct_801DA5D0; // size >= 0x30 + +typedef struct struct_801E1598 { + /* 0x00 */ LEOCmd unk0; + /* 0x1C */ OSMesgQueue unk1C; + /* 0x34 */ char pad34[4]; + /* 0x38 */ LEODiskID unk38; + /* 0x58 */ void* unk58; + /* 0x5C */ s32 unk5C; + /* 0x60 */ s32 unk60; + /* 0x64 */ s8 unk64; + /* 0x65 */ s8 unk65; + /* 0x66 */ u8 unk66; + /* 0x67 */ char pad67[1]; + /* 0x68 */ s32 unk68; // OSMesg + /* 0x6C */ s32 unk6C; +} struct_801E1598; // size >= 0x70 + +s32 func_801C8860(struct_801DA5D0*); +s32 func_801C8A24(void); +void func_801CAA60(u8*, UNK_TYPE, UNK_TYPE, UNK_TYPE, s32, s32, s16*, s32); +void func_801C9318(void); +void func_801CA3C0(s32, void (*)(void*, uintptr_t, size_t)); +s32 func_801C8F9C(struct_801E1598*); + +typedef struct struct_801DA5C8 { + /* 0x000 */ s32 unk0; + /* 0x004 */ s32 unk4; + /* 0x008 */ void* unk8; + /* 0x00C */ void* unkC; + /* 0x010 */ n64ddStruct_80121220* unk10; + /* 0x014 */ char pad14[0x104]; +} struct_801DA5C8; // size = 0x118 +extern s32 D_801D3728; +extern s32 D_801E17E0; +extern s32 D_801E17E4; +typedef struct struct_801C79DC { + /* 0x00 */ OSMesg unk0[30]; + /* 0x78 */ OSMesgQueue unk78; + /* 0x90 */ IrqMgrClient unk90; + /* 0x98 */ IrqMgr* unk98; +} struct_801C79DC; // size >= 0x9C +extern s32 D_801D3720; +typedef struct struct_801E1590 { + /* 0x0 */ OSMesgQueue* unk0; + /* 0x4 */ OSMesgQueue* unk4; +} struct_801E1590; // size >= 8 +extern void (*D_801D3734)(UNK_PTR, UNK_PTR, UNK_PTR); +extern s32 D_801D3710; +void func_801C8B40(struct_801E1598*); +void func_801C8AF8(struct_801E1598*); +UNK_PTR func_801CA800(s32); +UNK_PTR func_801CA698(s32); +UNK_PTR func_801CA86C(void); +UNK_PTR func_801CA8A0(s32); +UNK_PTR func_801CA8E0(void); +UNK_PTR func_801CA730(void); +extern s32 (*D_801D36D4)(struct_801E1598*); +s32 func_801C9BA4(struct_801E1598*); +void func_801CA280(UNK_PTR, UNK_TYPE, const char*); +extern const char* gN64DDLocalizedErrorNumberHeaders[2]; +void func_801C9D68(char*, u16); + +extern u8 gN64DDDiskReadTemporaryBuffer[]; + +extern struct_801E1590 D_801E1590; + +#endif diff --git a/include/ultra64.h b/include/ultra64.h index c7607ac9218..9058adeaef6 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -40,6 +40,8 @@ #include "ultra64/ucode.h" #include "ultra64/version.h" +#include "ultra64/leo.h" + union uObjBg; void __osPiCreateAccessQueue(void); diff --git a/include/ultra64/leo.h b/include/ultra64/leo.h index 3bc8a1dd6e4..7e28ccf45b6 100644 --- a/include/ultra64/leo.h +++ b/include/ultra64/leo.h @@ -1,140 +1,178 @@ -#ifndef ULTRA64_LEO_H -#define ULTRA64_LEO_H + +/*---------------------------------------------------------------------* + 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 "pi.h" #include "leoappli.h" #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -typedef u32 LEOError; - -typedef u8 LEOSpdlMode; - -typedef u8 LEOStatus; - -typedef struct LEOVersion { - /* 0x0 */ u8 driver; // version of sw - /* 0x1 */ u8 drive; // version of hw - /* 0x2 */ u8 deviceType; // dev type, always 00 - /* 0x3 */ u8 nDevices; // # of devices, always 01 -} LEOVersion; // size = 0x4 - -typedef struct LEOCapacity { - /* 0x0 */ u32 startLBA; - /* 0x4 */ u32 endLBA; - /* 0x8 */ u32 nbytes; -} LEOCapacity; // size = 0xC - -typedef struct LEODiskTime { - /* 0x0 */ u8 pad; - /* 0x1 */ u8 yearhi; - /* 0x2 */ u8 yearlo; - /* 0x3 */ u8 month; - /* 0x4 */ u8 day; - /* 0x5 */ u8 hour; - /* 0x6 */ u8 minute; - /* 0x7 */ u8 second; -} LEODiskTime; // size = 0x8 - -typedef struct LEOSerialNum { - /* 0x0 */ u64 lineNumber; - /* 0x8 */ LEODiskTime time; -} LEOSerialNum; // size = 0x10 - -typedef struct LEODiskID { - /* 0x0 */ u8 gameName[4]; - /* 0x4 */ u8 gameVersion; - /* 0x5 */ u8 diskNumber; - /* 0x6 */ u8 ramUsage; - /* 0x7 */ u8 diskUsage; - /* 0x8 */ LEOSerialNum serialNumber; - /* 0x18 */ u8 company[2]; - /* 0x1A */ u8 freeArea[6]; -} LEODiskID; // size = 0x20 - -// Not attempting to number this struct until required since it's scary -typedef struct LEOCmd { - /* 0x00 */ LEOCmdHeader header; - union { - struct { - /* 0x0C */ u32 lba; - /* 0x10 */ u32 transferBlks; - /* 0x14 */ void* buffPtr; - /* 0x18 */ u32 rwBytes; +/************************************************************************** + * + * 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 - /* 0x1C */ u32 size; + u32 size; #endif - } readWrite; - struct { - /* 0x0C */ u32 lba; - } seek; - struct { - /* 0x0C */ void* bufferPointer; - } readdiskid; - /* 0x0C */ LEODiskTime time; - struct { - /* 0x0C */ u8 reserve1; - /* 0x0D */ u8 reserve2; - /* 0x0E */ u8 standbyTime; - /* 0x0F */ u8 sleepTime; - /* 0x10 */ u32 reserve3; - } modeSelect; - } data; -} LEOCmd; // size = 0x1C + } 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; -#define _nbytes readwrite.rwBytes -#define _result header.status +} LEOCmd; -#endif // defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +#define _nbytes readwrite.rw_bytes +#define _result header.status -#define LEO_SW_VERSION 6 // This will be returned by LeoInquiry command -#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR -#define DDROM_FONT_START 0x000A0000 -#define DDROM_WAVEDATA_START 0x00140000 +#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 - -#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 - -#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 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 @@ -150,65 +188,92 @@ typedef struct LEOCmd { #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_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_RAMPACK_NOT_CONNECTED 44 #define LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED 47 -#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 -#define LEO_ERROR_NOT_BOOTED_DISK 45 +/* + * Reserved + */ +#define LEO_ERROR_NOT_BOOTED_DISK 45 #define LEO_ERROR_DIDNOT_CHANGED_DISK_AS_EXPECTED 46 -#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 -#define LEO_ERROR_DIAGNOSTIC_FAILURE_RESET 50 -#define LEO_ERROR_EJECTED_ILLEGALLY_RESET 51 +/* + * 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 LEODiskID leoBootID; -extern OSPiHandle* __osDiskHandle; // For exceptasm to get disk info - -// Initialize routine -s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -s32 LeoCJCreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -s32 LeoCACreateLeoManager(OSPri comPri, OSPri intPri, OSMesg* cmdBuf, s32 cmdMsgCnt); -u32 LeoDriveExist(void); - -// Synchronous functions -s32 LeoClearQueue(void); -s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba); -s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes); -s32 LeoReadCapacity(LEOCapacity* cap, s32 dir); -s32 LeoInquiry(LEOVersion* ver); -s32 LeoTestUnitReady(LEOStatus* status); - -// Asynchronous functions -s32 LeoSpdlMotor(LEOCmd* cmdBlock, LEOSpdlMode mode, OSMesgQueue* mq); -s32 LeoSeek(LEOCmd* cmdBlock, u32 lba, OSMesgQueue* mq); -s32 LeoRezero(LEOCmd* cmdBlock, OSMesgQueue* mq); -s32 LeoReadWrite(LEOCmd* cmdBlock, s32 direction, u32 LBA, void* vAddr, u32 nLBAs, OSMesgQueue* mq); -s32 LeoReadDiskID(LEOCmd* cmdBlock, LEODiskID* vaddr, OSMesgQueue* mq); -s32 LeoSetRTC(LEOCmd* cmdBlock, LEODiskTime* RTCdata, OSMesgQueue* mq); -s32 LeoReadRTC(LEOCmd* cmdBlock, OSMesgQueue* mq); -s32 LeoModeSelectAsync(LEOCmd* cmdBlock, u32 standby, u32 sleep, OSMesgQueue* mq); - -// Font routines -int LeoGetKAdr(int sjis); -int LeoGetAAdr(int code, int* dx, int* dy, int* cy); -int LeoGetAAdr2(u32 ccode, int* dx, int* dy, int* cy); - -// Boot function -void LeoBootGame(void* entry); - -#endif // defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * 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* lba); +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 - +#endif /* !_LEO_H */ diff --git a/include/ultra64/leo_internal.h b/include/ultra64/leo_internal.h new file mode 100644 index 00000000000..eae087776e1 --- /dev/null +++ b/include/ultra64/leo_internal.h @@ -0,0 +1,133 @@ +#ifndef LEO_INTERNAL_H +#define LEO_INTERNAL_H + +#include "ultra64.h" +#include "stack.h" + +#define STATIC + +extern OSPiHandle* LEOPiInfo; +void leointerrupt(void*); +void leomain(void*); +void leoClr_queue(void); +u8 leoChk_asic_ready(u32); +void leoDrive_reset(void); +extern s32 __leoActive; +typedef struct tgt_param_form { + /* 0x0 */ u16 lba; + /* 0x2 */ u16 cylinder; + /* 0x4 */ u16 blk_bytes; + /* 0x6 */ u8 sec_bytes; + /* 0x7 */ u8 head; + /* 0x8 */ u8 zone; + /* 0x9 */ u8 rdwr_blocks; + /* 0xA */ u8 start_block; +} tgt_param_form; +s32 __leoSetReset(void); +s32 __osLeoInterrupt(void); +OSPiHandle* osLeoDiskInit(void); +extern LEOVersion __leoVersion; +extern STACK(leoDiskStack, 0x1000); +extern const u16 LEOBYTE_TBL2[]; +extern const u16 LEOVZONE_TBL[][0x10]; +extern const u8 LEOVZONE_PZONEHD_TBL[][0x10]; +u16 leoLba_to_vzone(u32 lba); +u16 leoLba_to_phys(u32 lba); +u8 leoSeek_i(u16 rwmode); +extern OSMesgQueue LEOc2ctrl_que; +u32 leoChkUnit_atten(void); +u8 leoChk_cur_drvmode(void); +void leoClrUA_RESET(void); +void leoInitUnit_atten(void); +u8 leoRead_system_area(void); +u32 leoRetUnit_atten(void); +u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data); +extern OSIoMesg LEOPiDmaParam; +extern s32 currentCommand; +typedef union leo_sys_form { + /* 0x00 */ struct { + /* 0x00 */ u32 country; + /* 0x04 */ u8 fmt_type; + /* 0x05 */ u8 disk_type; + /* 0x06 */ u16 ipl_load_len; + /* 0x08 */ u8 defect_num[20]; + /* 0x1C */ void* loadptr; + /* 0x20 */ u8 defect_data[192]; + /* 0xE0 */ u16 rom_end_lba; + /* 0xE2 */ u16 ram_start_lba; + /* 0xE4 */ u16 ram_end_lba; + } param; + /* 0x00 */ u64 u64_data[29]; +} leo_sys_form; // size = 0xE8 +void leoRead_common(unsigned int offset); +u32 leoChk_err_retry(u32 sense); +typedef struct block_param_form { + /* 0x0 */ u8* pntr; + /* 0x4 */ u8* c2buff_e; + /* 0x8 */ u8 err_pos[4]; + /* 0xC */ u8 err_num; + /* 0xD */ u8 bytes; + /* 0xE */ u16 blkbytes; +} block_param_form; // size = 0x10 +extern u8 LEOC2_Syndrome[2][0xE8 * 4]; +extern block_param_form LEOc2_param; +void leoSet_mseq(u16 rwmode); +u8 leoDetect_index_w(void); +extern const u16 LEOZONE_SCYL_TBL[]; +extern const u16 LEOZONE_OUTERCYL_TBL[]; +extern const u8 LEOBYTE_TBL1[]; +int leoC2_Correction(void); +u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data); +u8 leoChk_done_status(u32 asic_cmd); +u8 leoWait_mecha_cmd_done(u32 asic_cmd); +u8 leoRecal_w(void); +u8 leoSeek_w(void); +void leoClrUA_MEDIUM_CHANGED(void); +void leoSetUA_MEDIUM_CHANGED(void); +u8 leoAnalize_asic_status(void); +void leoMode_sel(void); +extern u8 LEO_TempBuffer[0xE8]; +void leoTest_unit_rdy(void); +void leoSeek(void); +void leoRd_capacity(void); +extern const u16 LEORAM_START_LBA[]; +extern const u32 LEORAM_BYTE[]; + +void leoClr_reset(void); +void leoInquiry(void); +void leoRead(void); +void leoReadDiskId(void); +void leoReadTimer(void); +void leoRezero(void); +void leoSetTimer(void); +void leoStart_stop(void); +void leoTranslate(void); +void leoWrite(void); + +extern leo_sys_form LEO_sys_data; + +extern OSThread LEOcommandThread; +extern OSThread LEOinterruptThread; +extern STACK(LEOcommandThreadStack, 0x400); +extern STACK(LEOinterruptThreadStack, 0x400); +extern OSMesgQueue LEOcommand_que; +extern OSMesgQueue LEOevent_que; +extern OSMesgQueue LEOcontrol_que; +extern OSMesgQueue LEOdma_que; +extern OSMesgQueue LEOblock_que; +extern OSMesg LEOevent_que_buf; +extern OSMesg LEOcontrol_que_buf; +extern OSMesg LEOdma_que_buf[2]; +extern OSMesg LEOblock_que_buf; +extern u8* LEOwrite_pointer; +extern LEOCmd* LEOcur_command; +extern u32 LEOasic_bm_ctl_shadow; +extern u32 LEOasic_seq_ctl_shadow; +extern u8 LEOdrive_flag; +extern vu8 LEOclr_que_flag; +// extern u16 LEOrw_flags; +extern tgt_param_form LEOtgt_param; +extern u8 LEOdisk_type; +extern u32 LEO_country_code; + +#endif diff --git a/include/ultra64/leoappli.h b/include/ultra64/leoappli.h index ef526ee5a54..31ae29d58ee 100644 --- a/include/ultra64/leoappli.h +++ b/include/ultra64/leoappli.h @@ -1,72 +1,101 @@ -#ifndef ULTRA64_LEOAPPLI_H -#define ULTRA64_LEOAPPLI_H - -#include "thread.h" -#include "message.h" - -#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 - -void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size); -void leoCommand(void* cmd_blk_addr); -void LeoReset(void); -s32 LeoResetClear(void); - -#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) -#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR - -#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 -// should be -// #define LEO_COMMAND_CLEAR_RESET 0x0F - -#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) - -#define LEO_TEST_UNIT_MR 0x01 // MEDIUM REMOVED -#define LEO_TEST_UNIT_RE 0x02 // HEAD RETRACTED -#define LEO_TEST_UNIT_SS 0x04 // SPINDLE STOPPED - -#define LEO_STATUS_GOOD 0x00 -#define LEO_STATUS_CHECK_CONDITION 0x02 -#define LEO_STATUS_BUSY 0x08 +/* + * 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 compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size); +extern void leoCommand(void* cmd_blk_addr); +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 @@ -94,105 +123,152 @@ s32 LeoResetClear(void); #define LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED 47 #define LEO_SENSE_EJECTED_ILLEGALLY_RESUME 49 -typedef struct LEOCmdHeader { - /* 0x0 */ u8 command; - /* 0x1 */ u8 reserve1; - /* 0x2 */ u8 control; - /* 0x3 */ u8 reserve3; - /* 0x4 */ u8 status; - /* 0x5 */ u8 sense; - /* 0x6 */ u8 reserve6; - /* 0x7 */ u8 reserve7; - /* 0x8 */ OSMesgQueue* post; -} LEOCmdHeader; // 0xC - -typedef struct LEOCmdClearQueue { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdClearQueue; // 0xC - -typedef struct LEOCmdInquiry { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 devType; - /* 0x0D */ u8 version; - /* 0x0E */ u8 devNum; - /* 0x0F */ u8 leoBiosVer; - /* 0x10 */ u32 reserve5; -} LEOCmdInquiry; // size = 0x14 - -typedef struct LEOCmdTestUnitReady { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ u8 test; - /* 0xD */ u8 reserve2; - /* 0xE */ u8 reserve3; - /* 0xF */ u8 reserve4; -} LEOCmdTestUnitReady; // size = 0x10 - -typedef struct LEOCmdRezero { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdRezero; // size = 0xC - -typedef struct LEOCmdRead { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 lba; - /* 0x10 */ u32 transferBlks; - /* 0x14 */ void* buffPtr; - /* 0x18 */ u32 rwBytes; -} LEOCmdRead; // size = 0x1C +/*-----------------------------------*/ +/* 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; -typedef struct LEOCmdSeek { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ u32 lba; -} LEOCmdSeek; // size = 0x10 - -typedef struct LEOCmdStartStop { - /* 0x0 */ LEOCmdHeader header; -} LEOCmdStartStop; // size = 0xC - -typedef struct LEOCmdReadCapacity { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 startLba; - /* 0x10 */ u32 endLba; - /* 0x14 */ u32 capaBytes; -} LEOCmdReadCapacity; // size = 0x18 - -typedef struct LEOCmdTranslate { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u32 startLba; - /* 0x10 */ u32 inParam; - /* 0x14 */ u32 outParam; -} LEOCmdTranslate; // size = 0x18 - -typedef struct LEOCmdModeSelect { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 pageCode; - /* 0x0D */ u8 reserve1; - /* 0x0E */ u8 standbyTime; - /* 0x0F */ u8 sleepTime; - /* 0x10 */ u8 ledOnTime; - /* 0x11 */ u8 ledOffTime; - /* 0x12 */ u8 reserve18; - /* 0x13 */ u8 reserve19; -} LEOCmdModeSelect; // size = 0x14 - -typedef struct LEOCmdReadDiskId { - /* 0x0 */ LEOCmdHeader header; - /* 0xC */ void* bufferPointer; -} LEOCmdReadDiskId; // size = 0x10 - -typedef struct LEOCmdReadTimer { - /* 0x00 */ LEOCmdHeader header; - /* 0x0C */ u8 reserve12; - /* 0x0D */ u8 reserve13; - /* 0x0E */ u8 year; - /* 0x0F */ u8 month; - /* 0x10 */ u8 day; - /* 0x11 */ u8 hour; - /* 0x12 */ u8 minute; - /* 0x13 */ u8 second; -} LEOCmdReadTimer; // size = 0x14 +/*-----------------------------------*/ +/* 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; -#endif +/*-------end of leoappli.h--------------------------*/ + + diff --git a/include/ultra64/leodrive.h b/include/ultra64/leodrive.h index fbbbef8e0f2..36b28f4b9ed 100644 --- a/include/ultra64/leodrive.h +++ b/include/ultra64/leodrive.h @@ -1,14 +1,7 @@ #ifndef ULTRA64_LEODRIVE_H #define ULTRA64_LEODRIVE_H -#include "leo.h" -#include "leoappli.h" -#include "message.h" -#include "pi.h" #include "rcp.h" -#include "stack.h" -#include "thread.h" -#include "ultratypes.h" #define ASIC_BASE PI_DOM2_ADDR1 @@ -51,144 +44,4 @@ // ASIC_STATUS read bits #define LEO_STATUS_MECHANIC_INTR 0x02000000 // Mechanic Interrupt Raised -typedef union { - /* 0x0 */ u8 u8_data[4]; - /* 0x0 */ u16 u16_data[2]; - /* 0x0 */ u32 u32_data; -} data_trans_form; // size = 0x4 - -typedef struct { - /* 0x00 */ u8* pntr; - /* 0x04 */ u8* c2buff_e; - /* 0x08 */ u8 err_pos[4]; - /* 0x0C */ u8 err_num; - /* 0x0D */ u8 bytes; - /* 0x0E */ u16 blkbytes; -} block_param_form; // size = 0x10 - -typedef struct { - /* 0x0 */ u16 lba; - /* 0x2 */ u16 cylinder; - /* 0x4 */ u16 blk_bytes; - /* 0x6 */ u8 sec_bytes; - /* 0x7 */ u8 head; - /* 0x8 */ u8 zone; - /* 0x9 */ u8 rdwr_blocks; - /* 0xA */ u8 start_block; -} tgt_param_form; // size = 0xC - -typedef union { - /* 0x00 */ struct { - /* 0x00 */ u32 country; - /* 0x04 */ u8 fmt_type; - /* 0x05 */ u8 disk_type; - /* 0x06 */ u16 ipl_load_len; - /* 0x08 */ u8 defect_num[20]; - /* 0x1C */ void* loadptr; - /* 0x20 */ u8 defect_data[192]; - /* 0xE0 */ u16 rom_end_lba; - /* 0xE2 */ u16 ram_start_lba; - /* 0xE4 */ u16 ram_end_lba; - } param; - /* 0x00 */ u64 u64_data[29]; -} leo_sys_form; // size = 0xE8 - -void leomain(void* arg); -void leointerrupt(void* arg); - -OSPiHandle* osLeoDiskInit(void); -s32 __osLeoInterrupt(void); - -void leoClr_queue(void); -void leoInquiry(void); -void leoTest_unit_rdy(void); -void leoRezero(void); -void leoRead(void); -void leoWrite(void); -void leoSeek(void); -void leoStart_stop(void); -void leoRd_capacity(void); -void leoTranslate(); -void leoMode_sel(void); -void leoReadDiskId(void); -void leoReadTimer(void); -void leoSetTimer(void); -void leoClr_reset(void); - -u16 leoLba_to_phys(u32 lba); -u16 leoLba_to_vzone(u32 lba); - -u8 leoAnalize_asic_status(void); -u8 leoChk_asic_ready(u32 asic_cmd); -u8 leoChk_done_status(u32 asic_cmd); -u8 leoSend_asic_cmd_i(u32 asic_cmd, u32 asic_data); -u8 leoWait_mecha_cmd_done(u32 asic_cmd); -u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data); -u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data); -u8 leoDetect_index_w(void); -u8 leoRecal_i(void); -u8 leoRecal_w(void); -u8 leoSeek_i(u16 rwmode); -u8 leoSeek_w(void); -u8 leoRecv_event_mesg(s32 control); -u32 leoChk_err_retry(u32 sense); -u8 leoChk_cur_drvmode(void); -void leoDrive_reset(void); -u32 leoChkUnit_atten(void); -u32 leoRetUnit_atten(void); -void leoClrUA_RESET(void); -void leoClrUA_MEDIUM_CHANGED(void); -void leoSetUA_MEDIUM_CHANGED(void); -void leoInitUnit_atten(void); - -s32 __leoSetReset(void); - -void leoRead_common(unsigned int offset); - -int leoC2_Correction(void); - -void leoSet_mseq(u16 rwmode); - -extern leo_sys_form LEO_sys_data; -extern OSThread LEOcommandThread; -extern OSThread LEOinterruptThread; -extern STACK(LEOcommandThreadStack, 0x400); -extern STACK(LEOinterruptThreadStack, 0x400); -extern OSMesgQueue LEOcommand_que; -extern OSMesgQueue LEOevent_que; -extern OSMesgQueue LEOcontrol_que; -extern OSMesgQueue LEOdma_que; -extern OSMesgQueue LEOblock_que; -extern OSMesg LEOevent_que_buf[1]; -extern OSMesg LEOcontrol_que_buf[1]; -extern OSMesg LEOdma_que_buf[2]; -extern OSMesg LEOblock_que_buf[1]; -extern u8* LEOwrite_pointer; -extern LEOCmd* LEOcur_command; -extern u32 LEOasic_bm_ctl_shadow; -extern u32 LEOasic_seq_ctl_shadow; -extern u8 LEOdrive_flag; -extern vu8 LEOclr_que_flag; -// needs to not be volatile in some files -// extern vu16 LEOrw_flags; -extern u8 LEOdisk_type; -extern tgt_param_form LEOtgt_param; -extern u32 LEO_country_code; - -extern const char LEOfirmware_rev[]; -extern const u8 LEOBYTE_TBL1[]; -extern const u16 LEOBYTE_TBL2[]; -extern const u16 LEOVZONE_TBL[][0x10]; -extern const u16 LEOZONE_SCYL_TBL[]; -extern const u8 LEOVZONE_PZONEHD_TBL[][0x10]; -extern const u16 LEOZONE_OUTERCYL_TBL[]; -extern const u16 LEORAM_START_LBA[]; -extern const s32 LEORAM_BYTE[]; - -extern s32 __leoActive; -extern LEOVersion __leoVersion; -extern STACK(leoDiskStack, 0x1000); - -extern OSPiHandle* LEOPiInfo; - #endif diff --git a/spec/spec b/spec/spec index 76615133bec..b9a4fdc3455 100644 --- a/spec/spec +++ b/spec/spec @@ -865,16 +865,14 @@ beginseg name "n64dd" compress align 0x40 - include "$(BUILD_DIR)/src/n64dd/z_n64dd.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_data_buffer.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C8000.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C8940.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C9440.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801C9B70.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_headers.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_bodies.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_error_textures.o" - include "$(BUILD_DIR)/src/n64dd/n64dd_801CA0B0.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_0.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_1.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_2.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_3.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_4.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_5.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_6.o" + include "$(BUILD_DIR)/src/n64dd/n64dd_7.o" include "$(BUILD_DIR)/src/libleo/api/readwrite.o" include "$(BUILD_DIR)/src/libleo/leo/leofunc.o" include "$(BUILD_DIR)/src/libleo/leo/leoram.o" @@ -884,16 +882,17 @@ beginseg include "$(BUILD_DIR)/src/libleo/leo/leoread.o" include "$(BUILD_DIR)/src/libleo/api/lbatobyte.o" include "$(BUILD_DIR)/src/libleo/leo/leoinquiry.o" - include "$(BUILD_DIR)/src/libleo/leo/leodiskinit.o" - include "$(BUILD_DIR)/src/libleo/api/seek.o" + include "$(BUILD_DIR)/src/libleo/api/leodiskinit.o" + include "$(BUILD_DIR)/src/libleo/api/readdiskid.o" include "$(BUILD_DIR)/src/libleo/leo/leord_diskid.o" include "$(BUILD_DIR)/src/libleo/leo/leomecha.o" - include "$(BUILD_DIR)/src/libleo/api/spdlmotor.o" - include "$(BUILD_DIR)/src/libleo/leo/leo_tbl.o" include "$(BUILD_DIR)/src/libleo/leo/leotempbuffer.o" include "$(BUILD_DIR)/src/libleo/leo/leoc2_syndrome.o" + include "$(BUILD_DIR)/src/libleo/leo/leo_tbl.o" + include "$(BUILD_DIR)/src/libleo/api/spdlmotor.o" include "$(BUILD_DIR)/src/libleo/leo/leoc2ecc.o" include "$(BUILD_DIR)/src/libleo/leo/leomseq_tbl.o" + include "$(BUILD_DIR)/src/libleo/api/leoglobals.o" include "$(BUILD_DIR)/src/libleo/leo/leomotor.o" include "$(BUILD_DIR)/src/libleo/api/driveexist.o" include "$(BUILD_DIR)/src/libleo/leo/leomode_sel.o" @@ -907,10 +906,9 @@ beginseg include "$(BUILD_DIR)/src/libleo/leo/leotimer.o" include "$(BUILD_DIR)/src/libleo/api/getkadr.o" include "$(BUILD_DIR)/src/libleo/api/getaadr.o" - include "$(BUILD_DIR)/src/libleo/leo/leoglobals.o" include "$(BUILD_DIR)/src/libleo/leo/leowrite.o" include "$(BUILD_DIR)/src/libleo/api/cjcreateleomanager.o" - include "$(BUILD_DIR)/src/libleo/leo/leointerrupt.o" + include "$(BUILD_DIR)/src/libleo/api/leointerrupt.o" include "$(BUILD_DIR)/src/libleo/api/cacreateleomanager.o" include "$(BUILD_DIR)/src/libleo/api/testunitready.o" include "$(BUILD_DIR)/src/libleo/leo/leotestunit.o" diff --git a/src/code/fault_gc.c b/src/code/fault_gc.c index 800eecc52ea..01005d6b8a5 100644 --- a/src/code/fault_gc.c +++ b/src/code/fault_gc.c @@ -41,8 +41,8 @@ * DPad-Down disables sending fault pages over osSyncPrintf. */ -#pragma increment_block_number "gc-eu:160 gc-eu-dbg:160 gc-eu-dbg-2:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160" \ - "gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160 ique-cn:160" +#pragma increment_block_number "gc-eu:96 gc-eu-dbg:96 gc-eu-dbg-2:96 gc-eu-mq:96 gc-eu-mq-dbg:96 gc-jp:96 gc-jp-ce:96" \ + "gc-jp-mq:96 gc-us:96 gc-us-mq:96 ique-cn:64" #include "libc64/sleep.h" #include "libc64/sprintf.h" diff --git a/src/code/fault_n64.c b/src/code/fault_n64.c index 2d31b0f323a..74ae2dcc529 100644 --- a/src/code/fault_n64.c +++ b/src/code/fault_n64.c @@ -13,7 +13,7 @@ #include "thread.h" #include "translation.h" -#pragma increment_block_number "ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:144 pal-1.1:144" +#pragma increment_block_number "ntsc-1.0:96 ntsc-1.1:96 ntsc-1.2:96 pal-1.0:96 pal-1.1:96" typedef struct FaultMgr { OSThread thread; diff --git a/src/code/graph.c b/src/code/graph.c index 826dd71c087..95a7aded995 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -33,8 +33,8 @@ #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 -#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ - "ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" /** * The time at which the previous `Graph_Update` ended. diff --git a/src/code/main.c b/src/code/main.c index f693a5c4992..04f44b77a71 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -2,14 +2,14 @@ #include "ultra64.h" #include "versions.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:0 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" // Declared before including other headers for BSS ordering extern uintptr_t gSegments[NUM_SEGMENTS]; #pragma increment_block_number "gc-eu:252 gc-eu-mq:252 gc-jp:252 gc-jp-ce:252 gc-jp-mq:252 gc-us:252 gc-us-mq:252" \ - "ique-cn:252 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" + "ique-cn:252 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" extern struct PreNmiBuff* gAppNmiBufferPtr; extern struct Scheduler gScheduler; @@ -44,7 +44,7 @@ extern struct IrqMgr gIrqMgr; #include "thread.h" #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:0 ntsc-1.0:51 ntsc-1.1:51 ntsc-1.2:51 pal-1.0:49 pal-1.1:49" + "ique-cn:128 ntsc-1.0:63 ntsc-1.1:63 ntsc-1.2:63 pal-1.0:61 pal-1.1:61" extern u8 _buffersSegmentEnd[]; diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 5f41973ffe0..802bd466f99 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -7,8 +7,8 @@ #include "z_lib.h" #include "z_math.h" -#pragma increment_block_number "gc-eu:76 gc-eu-mq:76 gc-jp:76 gc-jp-ce:76 gc-jp-mq:76 gc-us:76 gc-us-mq:76 ique-cn:66" \ - "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:246" \ + "ntsc-1.0:240 ntsc-1.1:240 ntsc-1.2:240 pal-1.0:240 pal-1.1:240" s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 656bb04b5ba..8a43568aaec 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -14,7 +14,7 @@ #include "player.h" #include "skin_matrix.h" -#pragma increment_block_number "ntsc-1.0:136 ntsc-1.1:136 ntsc-1.2:136" +#pragma increment_block_number "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64" u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList); void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 3baaf6579fc..2713448b15a 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -26,8 +26,8 @@ #include "save.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:64 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags); s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange); @@ -3661,7 +3661,7 @@ s32 Camera_KeepOn3(Camera* camera) { } #pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:73 ntsc-1.1:73 ntsc-1.2:73 pal-1.0:73 pal-1.1:73" + "ique-cn:128 ntsc-1.0:125 ntsc-1.1:125 ntsc-1.2:125 pal-1.0:125 pal-1.1:125" s32 Camera_KeepOn4(Camera* camera) { static Vec3f sAtTarget; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 2b7ed05de04..aff12494b7b 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -16,8 +16,8 @@ #include "overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h" #include "z_lib.h" -#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ique-cn:192 ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:80 pal-1.0:80 pal-1.1:80" typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 358edd32e6f..e74938ee9fd 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:0 gc-us:128 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #include "libu64/gfxprint.h" #include "array_count.h" diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index ca7637214df..f61b56fef0a 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:80 gc-eu-mq:80 gc-jp:80 gc-jp-ce:80 gc-jp-mq:80 gc-us:80 gc-us-mq:80 ique-cn:64" \ - "ntsc-1.0:80 ntsc-1.1:80 ntsc-1.2:80 pal-1.0:80 pal-1.1:80" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:240" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #include "libu64/debug.h" #include "kaleido_manager.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 5a944065b54..3458198e543 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1,5 +1,5 @@ -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ - "ique-cn:224 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:240 pal-1.1:240" +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ + "ique-cn:160 ntsc-1.0:160 ntsc-1.1:160 ntsc-1.2:160 pal-1.0:160 pal-1.1:160" #include "libc64/qrand.h" #include "libu64/gfxprint.h" @@ -243,8 +243,8 @@ s16 sLightningFlashAlpha; s16 sSunDepthTestX; s16 sSunDepthTestY; -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ - "ique-cn:224 ntsc-1.0:208 ntsc-1.1:208 ntsc-1.2:208 pal-1.0:224 pal-1.1:224" +#pragma increment_block_number "gc-eu:208 gc-eu-mq:208 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ + "ique-cn:208 ntsc-1.0:224 ntsc-1.1:224 ntsc-1.2:224 pal-1.0:224 pal-1.1:224" LightNode* sNGameOverLightNode; LightInfo sNGameOverLightInfo; diff --git a/src/libleo/api/bytetolba.c b/src/libleo/api/bytetolba.c index 9b25ac840f0..4e6db7bca84 100644 --- a/src/libleo/api/bytetolba.c +++ b/src/libleo/api/bytetolba.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba) { u32 reslba; diff --git a/src/libleo/api/cacreateleomanager.c b/src/libleo/api/cacreateleomanager.c index 4ae1c7bd9e9..c296a159a12 100644 --- a/src/libleo/api/cacreateleomanager.c +++ b/src/libleo/api/cacreateleomanager.c @@ -1,15 +1,10 @@ -#include "ultra64/asm.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "stdint.h" -#include "attributes.h" - #include "ultra64.h" +#include "ultra64/asm.h" +#include "ultra64/leo_internal.h" -s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) { +s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, void** cmdBuf, s32 cmdMsgCnt) { OSPiHandle* driveRomHandle; - UNUSED OSPiHandle* leoDiskHandle; + OSPiHandle* leoDiskHandle; volatile LEOCmdInquiry cmdBlockInq; volatile LEOCmd cmdBlockID; LEODiskID thisID; @@ -19,65 +14,52 @@ s32 LeoCACreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) if (__leoActive) { return LEO_ERROR_GOOD; } - - if (!LeoDriveExist()) { + if (LeoDriveExist() == 0) { return LEO_ERROR_DEVICE_COMMUNICATION_FAILURE; } - - leoDiskHandle = osLeoDiskInit(); + osLeoDiskInit(); driveRomHandle = osDriveRomInit(); __leoActive = true; - - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); - leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); - - if (osResetType == 1) { // NMI + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); + leoInitialize(comPri, intPri, cmdBuf, (u32)cmdMsgCnt); + if (osResetType == 1) { __leoSetReset(); } - - cmdBlockInq.header.command = 2; + cmdBlockInq.header.command = LEO_COMMAND_INQUIRY; cmdBlockInq.header.reserve1 = 0; cmdBlockInq.header.control = 0; cmdBlockInq.header.reserve3 = 0; leoCommand((void*)&cmdBlockInq); - { - volatile s32 dummy = (uintptr_t)__osSetHWIntrRoutine & 0xA48D3C; + vs32 dummy = (u32)__osSetHWIntrRoutine & 0xA48D3C; while (dummy < 0xE00000) { - dummy += (((uintptr_t)leoCommand & 0xFF) | 0x8A) << 0x10; + dummy += (((s32)leoCommand & 0xFF) | 0x8A) << 16; } } - - while (cmdBlockInq.header.status == 8) {} - + while (cmdBlockInq.header.status == LEO_STATUS_BUSY) {} if (cmdBlockInq.header.status != 0) { - return GET_ERROR(cmdBlockInq); + return cmdBlockInq.header.sense; } - - __leoVersion.driver = cmdBlockInq.version; - __leoVersion.drive = 6; - __leoVersion.deviceType = cmdBlockInq.devType; - __leoVersion.nDevices = cmdBlockInq.devNum; - - stat = __leoVersion.driver & 0xF; - if (stat == 4) { + __leoVersion.drive = cmdBlockInq.version; + __leoVersion.driver = 6; + __leoVersion.deviceType = cmdBlockInq.dev_type; + __leoVersion.ndevices = cmdBlockInq.dev_num; + if ((__leoVersion.drive & 0xF) == 4) { LEO_country_code = 0; - } else if ((stat == 3) || (stat == 1)) { - volatile u32 dummy; + } else if (((__leoVersion.drive & 0xF) == 3) || ((__leoVersion.drive & 0xF) == 1)) { + vu32 dummy; osEPiReadIo(driveRomHandle, 0x9FF00, &data); - data = (data & 0xFF000000) >> 24; + data = ((data & 0xFF000000) >> 24); if (data != 4) { while (true) {} } - dummy = 0x32F8EB20; LEO_country_code = 0x2263EE56; - dummy += (uintptr_t)&__leoActive; + dummy += (u32)&__leoActive; } else { while (true) {} } - return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/cjcreateleomanager.c b/src/libleo/api/cjcreateleomanager.c index 1daf54ca124..1a9e9f57906 100644 --- a/src/libleo/api/cjcreateleomanager.c +++ b/src/libleo/api/cjcreateleomanager.c @@ -1,15 +1,10 @@ -#include "ultra64/asm.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "stdint.h" -#include "attributes.h" - #include "ultra64.h" +#include "ultra64/asm.h" +#include "ultra64/leo_internal.h" -s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) { +s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, void** cmdBuf, s32 cmdMsgCnt) { OSPiHandle* driveRomHandle; - UNUSED OSPiHandle* leoDiskHandle; + OSPiHandle* leoDiskHandle; volatile LEOCmdInquiry cmdBlockInq; volatile LEOCmd cmdBlockID; LEODiskID thisID; @@ -19,66 +14,53 @@ s32 LeoCJCreateLeoManager(s32 comPri, s32 intPri, OSMesg* cmdBuf, s32 cmdMsgCnt) if (__leoActive) { return LEO_ERROR_GOOD; } - - if (!LeoDriveExist()) { + if (LeoDriveExist() == 0) { return LEO_ERROR_DEVICE_COMMUNICATION_FAILURE; } - - leoDiskHandle = osLeoDiskInit(); + osLeoDiskInit(); driveRomHandle = osDriveRomInit(); __leoActive = true; - - __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, (u8*)STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); - leoInitialize(comPri, intPri, cmdBuf, cmdMsgCnt); - - if (osResetType == 1) { // NMI + __osSetHWIntrRoutine(OS_INTR_CART, __osLeoInterrupt, STACK_TOP(leoDiskStack) - FRAMESZ(SZREG * NARGSAVE)); + leoInitialize(comPri, intPri, cmdBuf, (u32)cmdMsgCnt); + if (osResetType == 1) { __leoSetReset(); } - - cmdBlockInq.header.command = 2; + cmdBlockInq.header.command = LEO_COMMAND_INQUIRY; cmdBlockInq.header.reserve1 = 0; cmdBlockInq.header.control = 0; cmdBlockInq.header.reserve3 = 0; leoCommand((void*)&cmdBlockInq); - { - volatile s32 dummy = (uintptr_t)&cmdBlockInq & 0xFFFFFF; + vs32 dummy = (u32)&cmdBlockInq & 0xFFFFFF; while (dummy > 0) { - dummy -= ((uintptr_t)__leoSetReset & 0xFFFFFF) | 0x403DF4; + dummy -= ((s32)__leoSetReset & 0xFFFFFF) | 0x403DF4; } } - - while (cmdBlockInq.header.status == 8) {} - + while (cmdBlockInq.header.status == LEO_STATUS_BUSY) {} if (cmdBlockInq.header.status != 0) { - return GET_ERROR(cmdBlockInq); + return cmdBlockInq.header.sense; } - - __leoVersion.driver = cmdBlockInq.version; - __leoVersion.drive = 6; - __leoVersion.deviceType = cmdBlockInq.devType; - __leoVersion.nDevices = cmdBlockInq.devNum; - - stat = __leoVersion.driver & 0xF; - if (stat == 4) { + __leoVersion.drive = cmdBlockInq.version; + __leoVersion.driver = 6; + __leoVersion.deviceType = cmdBlockInq.dev_type; + __leoVersion.ndevices = cmdBlockInq.dev_num; + if ((__leoVersion.drive & 0xF) == 4) { LEO_country_code = 0; - } else if ((stat == 3) || (stat == 1)) { - volatile u32 dummy; + } else if (((__leoVersion.drive & 0xF) == 3) || ((__leoVersion.drive & 0xF) == 1)) { + vu32 dummy; osEPiReadIo(driveRomHandle, 0x9FF00, &data); - data = (data & 0xFF000000) >> 24; + data = ((u32)(data & 0xFF000000) >> 24); dummy = 0x3ED98F23; if (data != 0xC3) { while (true) {} } - dummy *= data; - dummy -= (uintptr_t)&cmdBlockInq; + dummy -= (u32)&cmdBlockInq; LEO_country_code = 0xE848D316; } else { while (true) {} } - return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/clearqueue.c b/src/libleo/api/clearqueue.c index 1972b6080f6..e665b54491a 100644 --- a/src/libleo/api/clearqueue.c +++ b/src/libleo/api/clearqueue.c @@ -1,20 +1,16 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoClearQueue(void) { - LEOCmdClearQueue cmdBlock; + LEOCmdClearQue cmdBlock; if (!__leoActive) { return -1; } - - cmdBlock.header.command = 1; + cmdBlock.header.command = LEO_COMMAND_CLEAR_QUE; cmdBlock.header.reserve1 = 0; cmdBlock.header.control = 0; cmdBlock.header.reserve3 = 0; - leoCommand(&cmdBlock); return LEO_ERROR_GOOD; } diff --git a/src/libleo/api/driveexist.c b/src/libleo/api/driveexist.c index f658817a3de..ed4759434e0 100644 --- a/src/libleo/api/driveexist.c +++ b/src/libleo/api/driveexist.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" u32 LeoDriveExist(void) { u32 data; @@ -13,29 +11,23 @@ u32 LeoDriveExist(void) { u32 relDuration; __osPiGetAccess(); - - while ((stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {} - + while (((stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} latency = IO_READ(PI_BSD_DOM1_LAT_REG); pageSize = IO_READ(PI_BSD_DOM1_PGS_REG); relDuration = IO_READ(PI_BSD_DOM1_RLS_REG); pulse = IO_READ(PI_BSD_DOM1_PWD_REG); - IO_WRITE(PI_BSD_DOM1_LAT_REG, 0xFF); IO_WRITE(PI_BSD_DOM1_PGS_REG, 0); IO_WRITE(PI_BSD_DOM1_RLS_REG, 3); IO_WRITE(PI_BSD_DOM1_PWD_REG, 0xFF); - - data = IO_READ(0x06001010); // Something in the n64dd address space? - + data = IO_READ(0x06001010); IO_WRITE(PI_BSD_DOM1_LAT_REG, latency); IO_WRITE(PI_BSD_DOM1_PGS_REG, pageSize); IO_WRITE(PI_BSD_DOM1_RLS_REG, relDuration); IO_WRITE(PI_BSD_DOM1_PWD_REG, pulse); - __osPiRelAccess(); if (data == 0x2129FFF8) { - return true; + return 1; } - return false; + return 0; } diff --git a/src/libleo/api/getaadr.s b/src/libleo/api/getaadr.s index 95c1cfb14d6..ea3cc38049e 100644 --- a/src/libleo/api/getaadr.s +++ b/src/libleo/api/getaadr.s @@ -4,10 +4,10 @@ .text LEAF(LeoGetAAdr) - bltz a0, .out_of_range - bge a0, 0x908, .out_of_range + bltz a0, .L801D0498 + bge a0, 0x908, .L801D0498 sll t0, a0, 2 - la v1, asc2tbl + la v1, D_801D04A0 add t1, t0, v1 lbu t8, 2(t1) lhu t9, 0(t1) @@ -25,299 +25,2322 @@ LEAF(LeoGetAAdr) sw v1, (a3) add v0, v0, 0x7EE80 jr ra -.out_of_range: + .L801D0498: li v0, -1 jr ra END(LeoGetAAdr) -DATA(asc2tbl) -.word 0x00009D14, 0x00232A14, 0x00296314, 0x002F8A14, 0x00457E18, 0x0063CA14, 0x0084AA14, 0x00A03314 -.word 0x00A45E14, 0x00BB4E14, 0x00CA6514, 0x00D3770E, 0x00E33302, 0x00E78108, 0x00EB2102, 0x00EC6C14 -.word 0x01008A14, 0x01163A14, 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14 -.word 0x01A58A14, 0x01BB8A14, 0x01D1170E, 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14 -.word 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14 -.word 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, 0x0358CA14, 0x03799A14, 0x0395CA14 -.word 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, 0x0440AA14, 0x045CDA14 -.word 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, 0x050681FA -.word 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10 -.word 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810 -.word 0x066B9B10, 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E -.word 0x0707670E, 0x07138A0E, 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, 0x076C9D14 -.word 0x078F9D14, 0x07B22A0E, 0x07B88B14, 0x07D08A14, 0x07E69816, 0x07FD9A14, 0x08193F16, 0x08296C14 -.word 0x083D5114, 0x0840CA14, 0x08616614, 0x086C650C, 0x0875830A, 0x087D9D14, 0x08A0CA14, 0x08C14114 -.word 0x08C35318, 0x08C98810, 0x08DB9D14, 0x08FE9D14, 0x09213216, 0x09249A0E, 0x09407A14, 0x0956440E -.word 0x095B3302, 0x095F9D14, 0x09826614, 0x098D650C, 0x09960A15, 0x09C2C514, 0x09D4070F, 0x09F47A0E -.word 0x0A0ABE1C, 0x0A37BE1C, 0x0A64BE1C, 0x0A91BD1A, 0x0ABBBD1A, 0x0AE5BE1C, 0x0B12FA14, 0x0B3EBE14 -.word 0x0B6B7E1C, 0x0B897E1C, 0x0BA77E1C, 0x0BC57D1A, 0x0BE13E1C, 0x0BF04E1C, 0x0BFF4E1C, 0x0C0E5D1A -.word 0x0C239D14, 0x0C469D1A, 0x0C69BE1C, 0x0C96BE1C, 0x0CC3BE1C, 0x0CF0BD1A, 0x0D1ABD1A, 0x0D44770E -.word 0x0D54CC16, 0x0D7B8E1C, 0x0D998E1C, 0x0DB77E1C, 0x0DD57D1A, 0x0DF19D14, 0x0E149D14, 0x0E379A14 -.word 0x0E539B16, 0x0E719B16, 0x0E8F9B16, 0x0EAD9B16, 0x0ECB9A14, 0x0EE79B16, 0x0F050811, 0x0F299B10 -.word 0x0F479B16, 0x0F659B16, 0x0F839B16, 0x0FA19A14, 0x0FBD3B16, 0x0FC93A16, 0x0FD44B16, 0x0FE04A14 -.word 0x0FEB7912, 0x0FFF8B16, 0x10179B16, 0x10359B16, 0x10539B16, 0x10719B16, 0x108F9A14, 0x10AB760C -.word 0x10B99910, 0x10D28B16, 0x10EA8B16, 0x11028B16, 0x111A8A14, 0x11309D14, 0x11539D14, 0x11769D14 -.word 0x11996F18, 0x11B13A14, 0x11BC7514, 0x11C88912, 0x11DC9D16, 0x11FFEA14, 0x1226CA14, 0x12474514 -.word 0x124D4D14, 0x125B4D14, 0x12696614, 0x1274870E, 0x12843404, 0x12899108, 0x128E4204, 0x12916C14 -.word 0x12A5AA14, 0x12C17A14, 0x12D79A14, 0x12F3AA14, 0x130FAA14, 0x132B9B16, 0x1349AA14, 0x1365AA14 -.word 0x1381AA14, 0x139DAA14, 0x13B9370E, 0x13C1390E, 0x13CB770E, 0x13DB750C, 0x13E7770E, 0x13F79A14 -.word 0x1413CC14, 0x143ACA14, 0x145BBA14, 0x147CBA14, 0x149DBA14, 0x14BEBA14, 0x14DFBA14, 0x1500BA14 -.word 0x1521CA14, 0x15426A14, 0x1553AA14, 0x156FCA14, 0x1590AA14, 0x15ACFA14, 0x15D8CA14, 0x15F9BA14 -.word 0x161AAA14, 0x1636CE14, 0x1663CA14, 0x16849A14, 0x16A0CA14, 0x16C1BA14, 0x16E2CA14, 0x1703EA14 -.word 0x172ACA14, 0x174BCA14, 0x176CAA14, 0x17883D14, 0x17966C14, 0x17AA3D14, 0x17B85214, 0x17BD92FC -.word 0x17C55F1A, 0x17DD870E, 0x17EDAA14, 0x1809870E, 0x18199A14, 0x1835970E, 0x18497A14, 0x185F9C10 -.word 0x1880BA14, 0x18A15A14, 0x18B26E14, 0x18C9AA14, 0x18E55A14, 0x18F6F70E, 0x1916A70E, 0x192A970E -.word 0x193EAB0E, 0x195C9B0E, 0x197A770E, 0x198A770E, 0x199A6912, 0x19A9A70E, 0x19BDA60E, 0x19CFD70E -.word 0x19EBA70E, 0x19FFAB0E, 0x1A1D870E, 0x1A2D6D14, 0x1A423F16, 0x1A526D14, 0x1A675214, 0x1A6C6F18 -.word 0x1A846F16, 0x1A9C3A0E, 0x1AA78B14, 0x1ABFAA14, 0x1ADB8614, 0x1AE9BA14, 0x1B0A2F16, 0x1B128A14 -.word 0x1B285214, 0x1B2DBB14, 0x1B516614, 0x1B5C860C, 0x1B6A730A, 0x1B726E16, 0x1B89BB14, 0x1BAD5012 -.word 0x1BAF5316, 0x1BB58910, 0x1BC95F18, 0x1BE15F18, 0x1BF95316, 0x1BFFA90C, 0x1C188A14, 0x1C2E540E -.word 0x1C363404, 0x1C3B6D14, 0x1C506614, 0x1C5B860C, 0x1C690913, 0x1C91C512, 0x1CA3D70E, 0x1CBF9A0E -.word 0x1CDBCD1A, 0x1D05CD1A, 0x1D2FCD1A, 0x1D59CD1A, 0x1D83CD1A, 0x1DADCE1C, 0x1DDA2A15, 0x1E0CBD14 -.word 0x1E36BD1A, 0x1E60BD1A, 0x1E8ABD1A, 0x1EB4BC18, 0x1EDB6D1A, 0x1EF06D1A, 0x1F056D1A, 0x1F1A6D1A -.word 0x1F2F5F1A, 0x1F47BD1A, 0x1F71CD1A, 0x1F9BCD1A, 0x1FC5CD1A, 0x1FEFCD1A, 0x2019CD1A, 0x2043970E -.word 0x2057CB14, 0x207BAD1A, 0x209EBD1A, 0x20C8BD1A, 0x20F2BD1A, 0x211C6F1A, 0x21345F1A, 0x214CAA14 -.word 0x21689B16, 0x21869B16, 0x21A49A14, 0x21C0AA14, 0x21DC9A14, 0x21F89B16, 0x2216D70E, 0x22329B0E -.word 0x22508B16, 0x22689B16, 0x22869A14, 0x22A29A14, 0x22BE5B16, 0x22D05B16, 0x22E25A14, 0x22F35A14 -.word 0x23048912, 0x2318AA14, 0x23349B16, 0x23529B16, 0x23709A14, 0x238C9A14, 0x23A89A14, 0x23C49910 -.word 0x23DD9A10, 0x23F9AB16, 0x2417AB16, 0x2435AA14, 0x2451AA14, 0x246D5F18, 0x24855F18, 0x249DAE14 -.word 0x24C39D14, 0x24E62A14, 0x24EC5314, 0x24F28912, 0x25068D16, 0x2522CA14, 0x2543CA14, 0x25642314 -.word 0x25663C14, 0x25733C14, 0x25806514, 0x2589770E, 0x25993302, 0x259D9006, 0x25A03102, 0x25A26C14 -.word 0x25B69A14, 0x25D26A14, 0x25E38A14, 0x25F99A14, 0x26159A14, 0x26318A14, 0x26478A14, 0x265D9912 -.word 0x26769A14, 0x26928A14, 0x26A8260C, 0x26AC480C, 0x26B5870E, 0x26C5740A, 0x26CF770E, 0x26DF8A14 -.word 0x26F5DC14, 0x2723CA14, 0x2744A912, 0x275DAA14, 0x2779B912, 0x2797A912, 0x27B0A912, 0x27C9BA14 -.word 0x27EAC912, 0x28085912, 0x28179912, 0x2830B912, 0x284E9912, 0x2867D912, 0x288AB912, 0x28A8CA14 -.word 0x28C99912, 0x28E2CD14, 0x290CB912, 0x292A9A14, 0x2946A912, 0x295FB912, 0x297DC912, 0x299B0913 -.word 0x29C3C912, 0x29E1B912, 0x29FF9912, 0x2A183B12, 0x2A246C14, 0x2A383B12, 0x2A445214, 0x2A4981FA -.word 0x2A4D9D14, 0x2A70970E, 0x2A849A14, 0x2AA0770E, 0x2AB09A14, 0x2ACC870E, 0x2ADC6A14, 0x2AED9C10 -.word 0x2B0E9A14, 0x2B2A4912, 0x2B346D12, 0x2B499A14, 0x2B655A14, 0x2B76F70E, 0x2B96A70E, 0x2BAA970E -.word 0x2BBE9B0E, 0x2BDCAB0E, 0x2BFA770E, 0x2C0A770E, 0x2C1A6912, 0x2C29A70E, 0x2C3D970E, 0x2C51C70E -.word 0x2C69A70E, 0x2C7D9B0E, 0x2C9B770E, 0x2CAB5C12, 0x2CBF2F16, 0x2CC76C12, 0x2CDB5214, 0x2CE08D14 -.word 0x2CFC9D14, 0x2D1F2A0E, 0x2D257B14, 0x2D3D9A14, 0x2D599714, 0x2D6DB912, 0x2D8B2F16, 0x2D937A14 -.word 0x2DA95112, 0x2DACCB14, 0x2DD07714, 0x2DE0760C, 0x2DEE730A, 0x2DF69D14, 0x2E19BB14, 0x2E3D5112 -.word 0x2E405316, 0x2E468810, 0x2E589D14, 0x2E7B9D14, 0x2E9E4214, 0x2EA19A0C, 0x2EBD7A14, 0x2ED3440E -.word 0x2ED82302, 0x2EDA8D14, 0x2EF66714, 0x2F02760C, 0x2F100A15, 0x2F3CC614, 0x2F51C70E, 0x2F698A0E -.word 0x2F7FCD1A, 0x2FA9CD1A, 0x2FD3BD1A, 0x2FFDCD1A, 0x3027CC18, 0x304ECE1C, 0x307B0913, 0x30A3BD14 -.word 0x30CDAD1A, 0x30F0BD1A, 0x311ABD1A, 0x3144AC18, 0x31654D1A, 0x31734D1A, 0x31814D1A, 0x318F5C18 -.word 0x31A39D14, 0x31C6BD1A, 0x31F0CD1A, 0x321ACD1A, 0x3244CD1A, 0x326ECD1A, 0x3298CC18, 0x32BFA70E -.word 0x32D3BB14, 0x32F7BD1A, 0x3321CD1A, 0x334BBD1A, 0x3375BC18, 0x339C8D14, 0x33B88D14, 0x33D49A14 -.word 0x33F09A14, 0x340C9A14, 0x34289A14, 0x34449A14, 0x34609912, 0x34799B16, 0x3497C70E, 0x34AF7A0E -.word 0x34C58A14, 0x34DB8A14, 0x34F17A14, 0x35077912, 0x351B5A14, 0x352C5A14, 0x353D5A14, 0x354E6912 -.word 0x355D7912, 0x35719A14, 0x358D8A14, 0x35A38A14, 0x35B98A14, 0x35CF8A14, 0x35E58912, 0x35F9870E -.word 0x36099910, 0x3622AA14, 0x363EAA14, 0x365AAA14, 0x36769912, 0x368F8D14, 0x36AB8D14, 0x36C79D12 -.word 0x36EA6F18, 0x37024912, 0x370C7412, 0x37166B14, 0x37288C14, 0x37427912, 0x37568810, 0x37684412 -.word 0x376D5C12, 0x37815C12, 0x37957612, 0x37A39710, 0x37B74404, 0x37BCA108, 0x37C13306, 0x37C57B14 -.word 0x37DD8912, 0x37F17912, 0x38057912, 0x38198912, 0x382D8912, 0x38417912, 0x38557912, 0x38697912 -.word 0x387D8912, 0x38918912, 0x38A5370E, 0x38AD480C, 0x38B69710, 0x38CA940E, 0x38D79710, 0x38EB7912 -.word 0x38FF8B14, 0x3917A912, 0x39309912, 0x39498912, 0x395D8912, 0x39719912, 0x398A9912, 0x39A39912 -.word 0x39BC9912, 0x39D57912, 0x39E99912, 0x3A029912, 0x3A1B9912, 0x3A34A912, 0x3A4D9912, 0x3A669912 -.word 0x3A7F8912, 0x3A939B12, 0x3AB19912, 0x3ACA8912, 0x3ADE8912, 0x3AF29912, 0x3B0B9912, 0x3B24A912 -.word 0x3B3D8912, 0x3B518912, 0x3B657912, 0x3B794C12, 0x3B867B14, 0x3B9E4C12, 0x3BAB6214, 0x3BB0A2FC -.word 0x3BB85F1A, 0x3BD0870E, 0x3BE09912, 0x3BF9870E, 0x3C098912, 0x3C1D870E, 0x3C2D8912, 0x3C419A0E -.word 0x3C5D8912, 0x3C718A14, 0x3C877D14, 0x3CA39912, 0x3CBC8912, 0x3CD0A70E, 0x3CE4970E, 0x3CF8970E -.word 0x3D0C9B0E, 0x3D2AAB0E, 0x3D48970E, 0x3D5C770E, 0x3D6C8912, 0x3D80970E, 0x3D94970E, 0x3DA8A70E -.word 0x3DBC870E, 0x3DCC9A0E, 0x3DE8770E, 0x3DF86D12, 0x3E0D2F16, 0x3E156D12, 0x3E2A6212, 0x3E2F6F16 -.word 0x3E476F16, 0x3E5F4912, 0x3E697A14, 0x3E7F7912, 0x3E938612, 0x3EA19912, 0x3EBA3F16, 0x3ECA8A12 -.word 0x3EE06112, 0x3EE3A812, 0x3EFA7712, 0x3F0A550C, 0x3F13950E, 0x3F226E16, 0x3F399812, 0x3F506112 -.word 0x3F534316, 0x3F578812, 0x3F695F18, 0x3F815F18, 0x3F995214, 0x3F9E9A0E, 0x3FBA7912, 0x3FCE320C -.word 0x3FD14404, 0x3FD66D14, 0x3FEB7712, 0x3FFB650C, 0x40048710, 0x40148310, 0x401C860E, 0x402A7912 -.word 0x403EAC18, 0x405FAC18, 0x4080AC18, 0x40A1AB16, 0x40BFAB16, 0x40DDAD1A, 0x4100B912, 0x411E8C12 -.word 0x41388C18, 0x41529C18, 0x41739C18, 0x41948B16, 0x41AC7C18, 0x41C67C18, 0x41E07C18, 0x41FA7B16 -.word 0x42125F1A, 0x422AAB16, 0x42489C18, 0x42699C18, 0x428A9C18, 0x42AB9B16, 0x42C99B16, 0x42E7870E -.word 0x42F79A12, 0x43139C18, 0x43349C18, 0x4355AC18, 0x4376AB16, 0x43946F1A, 0x43AC5F1A, 0x43C48912 -.word 0x43D88A14, 0x43EE8A14, 0x44049A14, 0x44209912, 0x44398912, 0x444D8B16, 0x4465970E, 0x44798A0E -.word 0x448F8A14, 0x44A58A14, 0x44BB9A14, 0x44D79912, 0x44F08A14, 0x45068A14, 0x451C7A14, 0x45327912 -.word 0x45468912, 0x455A9912, 0x45738A14, 0x45898A14, 0x459F9912, 0x45B89912, 0x45D19912, 0x45EAA912 -.word 0x46039910, 0x461C9A14, 0x46389A14, 0x46548A14, 0x466A9912, 0x46835F18, 0x469B5F18, 0x46B38C12 -.word 0x46CD3C16, 0x46DA3C16, 0x46E77516, 0x46F39A14, 0x470F7E18, 0x472DDC16, 0x475BBC16, 0x47824516 -.word 0x47884F18, 0x47984F18, 0x47A85516, 0x47B1870E, 0x47C15504, 0x47CA810A, 0x47CE4304, 0x47D28F18 -.word 0x47F29C16, 0x48134B16, 0x481F8B16, 0x48378C16, 0x48519B16, 0x486F8C16, 0x48898C16, 0x48A38B16 -.word 0x48BB8C16, 0x48D58C16, 0x48EF380E, 0x48F84A0E, 0x4903970E, 0x4917850C, 0x4923870E, 0x49337C16 -.word 0x494DCC16, 0x4974BB16, 0x49988B16, 0x49B09C16, 0x49D1AB16, 0x49EF7B16, 0x4A077B16, 0x4A1FBC16 -.word 0x4A46AB16, 0x4A643B16, 0x4A706C16, 0x4A849B16, 0x4AA26B16, 0x4AB4DC16, 0x4AE2AC16, 0x4B03CC16 -.word 0x4B2A8B16, 0x4B42CC16, 0x4B698B16, 0x4B818C16, 0x4B9B7B16, 0x4BB39C16, 0x4BD4BC16, 0x4BFBFC16 -.word 0x4C2FAB16, 0x4C4DAB16, 0x4C6B9B16, 0x4C893E18, 0x4C988C18, 0x4CB24E18, 0x4CC16316, 0x4CC781FC -.word 0x4CCB3C16, 0x4CD8880E, 0x4CEA8D18, 0x4D06680E, 0x4D149D18, 0x4D37880E, 0x4D495C18, 0x4D5D8B0E -.word 0x4D757C18, 0x4D8F3B16, 0x4D9B3F16, 0x4DAB8C18, 0x4DC53C18, 0x4DD2B70E, 0x4DEA770E, 0x4DFA980E -.word 0x4E119B0E, 0x4E2F9B0E, 0x4E4D670E, 0x4E59680E, 0x4E674912, 0x4E71780E, 0x4E83980E, 0x4E9AD80E -.word 0x4EBAA70E, 0x4ECE9B0E, 0x4EEC770E, 0x4EFC5F18, 0x4F142C18, 0x4F1B4F18, 0x4F2B7114, 0x4F2F3C16 -.word 0x4F3C3C10, 0x4F493B0E, 0x4F556A14, 0x4F669C16, 0x4F879810, 0x4F9E9B16, 0x4FBC2C18, 0x4FC38E18 -.word 0x4FE16216, 0x4FE6DC16, 0x50146616, 0x501F7710, 0x502F840C, 0x50393C1A, 0x5046DC16, 0x50747116 -.word 0x50784316, 0x507C8912, 0x50903C14, 0x509D3C14, 0x50AA4316, 0x50AE7B0E, 0x50C6AE16, 0x50EC6610 -.word 0x50F75504, 0x51003C18, 0x510D6616, 0x51188710, 0x5128FC16, 0x515CE616, 0x5175D80E, 0x51958B0E -.word 0x51ADCC18, 0x51D4BC18, 0x51FBBC18, 0x5222BC18, 0x5249CC18, 0x5270BC18, 0x5297FB16, 0x52C79E16 -.word 0x52ED6C18, 0x53016C18, 0x53157C18, 0x532F7C18, 0x53494C18, 0x53564C18, 0x53636C18, 0x53777C18 -.word 0x53913C18, 0x539EAD18, 0x53C1CD18, 0x53EBCD18, 0x5415CD18, 0x543FCD18, 0x5469CC18, 0x5490970E -.word 0x54A4CC16, 0x54CB9D18, 0x54EE9D18, 0x55119D18, 0x55349D18, 0x55573C18, 0x55643C18, 0x55719D18 -.word 0x55948C16, 0x55AE9C16, 0x55CF8C16, 0x55E99B14, 0x56078C16, 0x56219C16, 0x5642C80E, 0x565D6A0E -.word 0x566E8C16, 0x56887C16, 0x56A28C16, 0x56BC7C16, 0x56D64B16, 0x56E24B16, 0x56EE6B16, 0x57007B16 -.word 0x57187B16, 0x57307A14, 0x57469C16, 0x57678C16, 0x57818C16, 0x579B9B14, 0x57B99C16, 0x57DA880E -.word 0x57EC980E, 0x58038C16, 0x581D8C16, 0x58378C16, 0x58518C16, 0x586B3C16, 0x58783C16, 0x58859F16 -.word 0x58AD6F18, 0x58C55C16, 0x58D98516, 0x58E59B14, 0x59038E18, 0x5921BC16, 0x5948AC16, 0x59695516 -.word 0x59724F18, 0x59825F18, 0x599A6516, 0x59A3970E, 0x59B75504, 0x59C0810A, 0x59C43304, 0x59C8AF18 -.word 0x59F09C16, 0x5A115B16, 0x5A239B16, 0x5A418C16, 0x5A5B9B16, 0x5A799C16, 0x5A9A9C16, 0x5ABBAC16 -.word 0x5ADC8C16, 0x5AF69C16, 0x5B17480E, 0x5B206A0E, 0x5B31970E, 0x5B45950C, 0x5B54970E, 0x5B687C16 -.word 0x5B82CC16, 0x5BA9BB16, 0x5BCD9B16, 0x5BEB9C16, 0x5C0CBB16, 0x5C309B16, 0x5C4E9B16, 0x5C6CBC16 -.word 0x5C93BB16, 0x5CB75B16, 0x5CC98C16, 0x5CE3BB16, 0x5D077B16, 0x5D1FDC16, 0x5D4DCC16, 0x5D74DC16 -.word 0x5DA29B16, 0x5DC0CC16, 0x5DE79B16, 0x5E059C16, 0x5E268B16, 0x5E3EAC16, 0x5E5FBC16, 0x5E860C17 -.word 0x5EBABB16, 0x5EDEAB16, 0x5EFCBB16, 0x5F205E18, 0x5F376E18, 0x5F4E6E18, 0x5F655316, 0x5F6B91FC -.word 0x5F706F1A, 0x5F88980E, 0x5F9F9D18, 0x5FC2680E, 0x5FD0AD18, 0x5FF3880E, 0x60056C18, 0x60199B0E -.word 0x60378C18, 0x60515B16, 0x60636F16, 0x607B9C18, 0x609C5C18, 0x60B0C70E, 0x60C8870E, 0x60D8880E -.word 0x60EA9B0E, 0x61089B0E, 0x6126770E, 0x6136680E, 0x61446912, 0x6153780E, 0x6165980E, 0x617CD80E -.word 0x619CA70E, 0x61B0AB0E, 0x61CEA70E, 0x61E26F18, 0x61FA4C18, 0x62076F18, 0x621F7114, 0x62236F18 -.word 0x623B6F16, 0x62534B0E, 0x625F7A14, 0x6275AC16, 0x6296A810, 0x62ADAB16, 0x62CB4C18, 0x62D88E18 -.word 0x62F66216, 0x62FBDC16, 0x63297616, 0x63378710, 0x6347940C, 0x63546F18, 0x636CDC16, 0x639A6116 -.word 0x639D4316, 0x63A19912, 0x63BA6F18, 0x63D26F18, 0x63EA5316, 0x63F09B0E, 0x640E9E16, 0x64346610 -.word 0x643F5504, 0x64486F18, 0x64607616, 0x646E8710, 0x647EFA14, 0x64AAD514, 0x64BFC60C, 0x64D47B0E -.word 0x64ECCC18, 0x6513BC18, 0x653ABC18, 0x6561CC18, 0x6588CC18, 0x65AFBC18, 0x65D6FB16, 0x6606AE16 -.word 0x662C8C18, 0x66468C18, 0x66609C18, 0x66819C18, 0x66A25C18, 0x66B66C18, 0x66CA7C18, 0x66E47C18 -.word 0x66FE6F1A, 0x6716CD18, 0x6740DD18, 0x6771CD18, 0x679BCD18, 0x67C5CD18, 0x67EFDD18, 0x6820A70E -.word 0x6834FC16, 0x6868AD18, 0x688BAD18, 0x68AEAD18, 0x68D1AD18, 0x68F46F1A, 0x690C6F1A, 0x69249D18 -.word 0x69479C16, 0x69689C16, 0x69899C16, 0x69AA9B14, 0x69C89C16, 0x69E99C16, 0x6A0AD80E, 0x6A2A7A0E -.word 0x6A408C16, 0x6A5A8C16, 0x6A748C16, 0x6A8E8C16, 0x6AA85B16, 0x6ABA5B16, 0x6ACC6B16, 0x6ADE6B16 -.word 0x6AF07B16, 0x6B089A14, 0x6B248C16, 0x6B3E9C16, 0x6B5F9C16, 0x6B808B14, 0x6B988C16, 0x6BB2980E -.word 0x6BC9980E, 0x6BE08C16, 0x6BFA8C16, 0x6C148C16, 0x6C2E8C16, 0x6C486F18, 0x6C606F18, 0x6C78AF16 -.word 0x6CA06F18, 0x6CB82A14, 0x6CBE4314, 0x6CC29A14, 0x6CDE8D16, 0x6CFADB14, 0x6D249B14, 0x6D422314 -.word 0x6D445D14, 0x6D594D14, 0x6D675414, 0x6D6F870E, 0x6D7F2402, 0x6D829108, 0x6D872102, 0x6D885A14 -.word 0x6D998B14, 0x6DB15A14, 0x6DC28A14, 0x6DD88B14, 0x6DF08A14, 0x6E068B14, 0x6E1E8B14, 0x6E368A14 -.word 0x6E4C8B14, 0x6E648B14, 0x6E7C270E, 0x6E802A0E, 0x6E86970E, 0x6E9A850C, 0x6EA6970E, 0x6EBA7A14 -.word 0x6ED0DB14, 0x6EFAAA14, 0x6F169A14, 0x6F32AB14, 0x6F509A14, 0x6F6C9A14, 0x6F889A14, 0x6FA4AB14 -.word 0x6FC2AA14, 0x6FDE2A14, 0x6FE47B14, 0x6FFC9A14, 0x70188A14, 0x702EBA14, 0x704F9A14, 0x706BBB14 -.word 0x708F9A14, 0x70ABBB14, 0x70CF9A14, 0x70EB9B14, 0x7109AA14, 0x71259B14, 0x7143AA14, 0x715FEA14 -.word 0x7186AA14, 0x71A2AA14, 0x71BE9A14, 0x71DA3D14, 0x71E87A14, 0x71FE4D14, 0x720C5214, 0x721190FC -.word 0x72145F1A, 0x722C8910, 0x72408B14, 0x72588910, 0x726C7C16, 0x72868910, 0x729A6A14, 0x72AB8C10 -.word 0x72C57A14, 0x72DB2A14, 0x72E14E14, 0x72F07A14, 0x73062A14, 0x730CB810, 0x73277810, 0x73398910 -.word 0x734D8C10, 0x73678C10, 0x73815810, 0x738F7910, 0x73A34A12, 0x73AE780E, 0x73C0870E, 0x73D0B70E -.word 0x73E8770E, 0x73F88B0E, 0x7410770E, 0x74205D14, 0x74352A14, 0x743B6D14, 0x74506114, 0x74536F18 -.word 0x746B6F16, 0x74832A0E, 0x74898B12, 0x74A18B14, 0x74B98710, 0x74C99A14, 0x74E52A14, 0x74EB7E14 -.word 0x75094114, 0x750BBA14, 0x752C5414, 0x7534650C, 0x753D840A, 0x75476E16, 0x755EBA14, 0x757F6114 -.word 0x75823316, 0x7586870E, 0x75965F18, 0x75AE5F18, 0x75C64214, 0x75C99B0E, 0x75E78D14, 0x7603430C -.word 0x76072402, 0x760A6D14, 0x761F5414, 0x7627550C, 0x7630FB14, 0x7660C514, 0x7672E80E, 0x76928A0E -.word 0x76A8AD1A, 0x76CBAD1A, 0x76EEAD1A, 0x7711AD1A, 0x7734AD1A, 0x7757AE1C, 0x777DFA14, 0x77A9AD14 -.word 0x77CC8D1A, 0x77E88D1A, 0x78048D1A, 0x78208C18, 0x783A4D1A, 0x78483D1A, 0x78565D1A, 0x786B5D1A -.word 0x78805F1A, 0x7898AD1A, 0x78BBCE1A, 0x78E8BE1A, 0x7915BE1A, 0x7942BE1A, 0x796FCD18, 0x7999870E -.word 0x79A9BB14, 0x79CD9E1A, 0x79F39E1A, 0x7A199E1A, 0x7A3FAE1A, 0x7A656F1A, 0x7A7D5F1A, 0x7A958B14 -.word 0x7AAD8C16, 0x7AC78C16, 0x7AE18C16, 0x7AFB8B14, 0x7B138B14, 0x7B2B8C16, 0x7B45D910, 0x7B687C10 -.word 0x7B828C16, 0x7B9C8C16, 0x7BB68C16, 0x7BD08B14, 0x7BE84B16, 0x7BF44B16, 0x7C005B16, 0x7C124B16 -.word 0x7C1E7B14, 0x7C367A14, 0x7C4C8C16, 0x7C668C16, 0x7C808C16, 0x7C9A8B14, 0x7CB28B14, 0x7CCA870E -.word 0x7CDA8910, 0x7CEE7C16, 0x7D088C16, 0x7D227C16, 0x7D3C7B14, 0x7D545F18, 0x7D6C5F18, 0x7D848E14 -.word 0x7DA26F16, 0x7DBA3A14, 0x7DC56414, 0x7DCD9A14, 0x7DE98D16, 0x7E05EB14, 0x7E2FBB14, 0x7E533414 -.word 0x7E584D14, 0x7E664D14, 0x7E746414, 0x7E7C870E, 0x7E8C3402, 0x7E91920A, 0x7E993102, 0x7E9B7A14 -.word 0x7EB18B14, 0x7EC95A14, 0x7EDA8A14, 0x7EF08B14, 0x7F088A14, 0x7F1E8B14, 0x7F368B14, 0x7F4E8A14 -.word 0x7F648B14, 0x7F7C9B14, 0x7F9A370E, 0x7FA23A0E, 0x7FADA80E, 0x7FC4960C, 0x7FD6980E, 0x7FED9A14 -.word 0x8009DC16, 0x8037BA14, 0x8058AA14, 0x8074BB14, 0x8098AA14, 0x80B49A14, 0x80D09A14, 0x80ECBB14 -.word 0x8110AA14, 0x812C3A14, 0x81378B14, 0x814FAA14, 0x816B9A14, 0x8187BA14, 0x81A8AA14, 0x81C4BB14 -.word 0x81E89A14, 0x8204BB14, 0x8228AA14, 0x8244AB14, 0x8262AA14, 0x827E9B14, 0x829CAA14, 0x82B8FA14 -.word 0x82E4AA14, 0x8300AA14, 0x831C9A14, 0x83384D14, 0x83466A14, 0x83575D14, 0x836C6216, 0x837190FC -.word 0x83745F18, 0x838C8910, 0x83A09B14, 0x83BE8910, 0x83D29B14, 0x83F09910, 0x84095A14, 0x841A8C10 -.word 0x84348A14, 0x844A3A14, 0x84554E14, 0x84648A14, 0x847A2A14, 0x8480C810, 0x849B8810, 0x84AD9910 -.word 0x84C68C10, 0x84E09C10, 0x85015810, 0x850F8910, 0x85235A14, 0x8534880E, 0x8546870E, 0x8556C70E -.word 0x856E870E, 0x857E8B0E, 0x8596870E, 0x85A65D14, 0x85BB3A14, 0x85C66D14, 0x85DB7216, 0x85E16F18 -.word 0x85F96F14, 0x86113A0E, 0x861C8B12, 0x86348B14, 0x864C8710, 0x865C9A14, 0x86783A14, 0x86838D14 -.word 0x869F6114, 0x86A2BA14, 0x86C36514, 0x86CC750C, 0x86D8950C, 0x86E75F16, 0x86FFBA14, 0x87206114 -.word 0x87234318, 0x8727970E, 0x873B5F16, 0x87535F16, 0x876B4114, 0x876DAB0E, 0x878B9D14, 0x87AE430C -.word 0x87B23402, 0x87B76F16, 0x87CF6514, 0x87D8650C, 0x87E1EC14, 0x880FC512, 0x8821E90E, 0x88448A0E -.word 0x885AAD1A, 0x887DBD1A, 0x88A7BD1A, 0x88D1BD1A, 0x88FBAD1A, 0x891EBE1C, 0x894BFA14, 0x8977AE14 -.word 0x899D9D1A, 0x89C09D1A, 0x89E39D1A, 0x8A069D1A, 0x8A294D1A, 0x8A374D1A, 0x8A456D1A, 0x8A5A6D1A -.word 0x8A6F5F18, 0x8A87AD1A, 0x8AAABE1A, 0x8AD7BE1A, 0x8B04BE1A, 0x8B31BE1A, 0x8B5EBE1A, 0x8B8B870E -.word 0x8B9BBB14, 0x8BBF9E1A, 0x8BE59E1A, 0x8C0BAE1A, 0x8C31AE1A, 0x8C575F18, 0x8C6F5F18, 0x8C878B14 -.word 0x8C9F8B14, 0x8CB79B14, 0x8CD58C16, 0x8CEF8C16, 0x8D098B14, 0x8D219D18, 0x8D44D910, 0x8D678C10 -.word 0x8D818B14, 0x8D999B14, 0x8DB79C16, 0x8DD88B14, 0x8DF05A14, 0x8E015A14, 0x8E125A14, 0x8E236A14 -.word 0x8E348B14, 0x8E4C8B16, 0x8E649B14, 0x8E829B14, 0x8EA09C16, 0x8EC19C16, 0x8EE29B14, 0x8F00870E -.word 0x8F10A910, 0x8F298B14, 0x8F418B14, 0x8F598C16, 0x8F738C16, 0x8F8D5F18, 0x8FA55F18, 0x8FBD8F16 -.word 0x8FDD6F16, 0x8FF54A12, 0x90004312, 0x90049A12, 0x90209C14, 0x9041BA12, 0x90628A12, 0x90782312 -.word 0x907A6C12, 0x908E5C12, 0x90A25412, 0x90AA870C, 0x90BA3300, 0x90BE8006, 0x90C02100, 0x90C17A12 -.word 0x90D78A12, 0x90ED5A12, 0x90FE9A12, 0x911A8A12, 0x91308A12, 0x91469A12, 0x91628A12, 0x91788A12 -.word 0x918E8A12, 0x91A47A12, 0x91BA370E, 0x91C24A0E, 0x91CD980E, 0x91E4940A, 0x91F1980E, 0x92087A12 -.word 0x921ECB14, 0x9242AA12, 0x925E9A12, 0x927ABB14, 0x929EAA12, 0x92BABA12, 0x92DBAA12, 0x92F7BB14 -.word 0x931BBA12, 0x933C4A12, 0x93478A12, 0x935DBA12, 0x937E8A12, 0x9394CA12, 0x93B5AA12, 0x93D1BB14 -.word 0x93F5AA12, 0x9411BB14, 0x9435AA12, 0x94519B14, 0x946F9A12, 0x948BAA12, 0x94A7AA12, 0x94C3DA12 -.word 0x94EABA12, 0x950B9A12, 0x9527BA12, 0x95485C12, 0x955C3A12, 0x95675C12, 0x957B5112, 0x957E80FC -.word 0x95803F18, 0x9590780E, 0x95A29A12, 0x95BE880E, 0x95D09A12, 0x95EC880E, 0x95FE5A12, 0x960F9B0E -.word 0x962D8A12, 0x96434A12, 0x964E6D12, 0x96638A12, 0x96794A12, 0x9684C80E, 0x969F880E, 0x96B1880E -.word 0x96C39B0E, 0x96E18B0E, 0x96F9680E, 0x9707780E, 0x97195A12, 0x972A880E, 0x973C880E, 0x974EA80E -.word 0x9765980E, 0x977C9B0E, 0x979A880E, 0x97AC7C12, 0x97C63A12, 0x97D16C12, 0x97E56112, 0x97E86F18 -.word 0x98004F14, 0x98104A0E, 0x981B8A10, 0x98319A12, 0x984D860E, 0x985B9A12, 0x98774A12, 0x98827D12 -.word 0x989E5112, 0x98A1BA12, 0x98C25514, 0x98CB740A, 0x98D5840A, 0x98DF5F14, 0x98F7BA12, 0x99185112 -.word 0x991B3214, 0x991E870C, 0x992E5F16, 0x99465F16, 0x995E3112, 0x9960BB0E, 0x99848C12, 0x999E330C -.word 0x99A22300, 0x99A46F16, 0x99BC5514, 0x99C5640A, 0x99CDFB14, 0x99FDB412, 0x9A0CD80E, 0x9A2C7A0E -.word 0x9A42AD18, 0x9A65AD18, 0x9A889D18, 0x9AABAD18, 0x9ACEAD18, 0x9AF1AE1A, 0x9B17FA12, 0x9B43BE14 -.word 0x9B70BD18, 0x9B9AAD18, 0x9BBDAD18, 0x9BE0AD18, 0x9C035D18, 0x9C186D18, 0x9C2D6D18, 0x9C426D18 -.word 0x9C573F18, 0x9C67BD18, 0x9C91BD18, 0x9CBBBD18, 0x9CE5BD18, 0x9D0FBD18, 0x9D39BD18, 0x9D63980E -.word 0x9D7ADB14, 0x9DA4AD18, 0x9DC7AD18, 0x9DEAAD18, 0x9E0DAD18, 0x9E305F18, 0x9E485F18, 0x9E608A12 -.word 0x9E768B14, 0x9E8E8B14, 0x9EA68B14, 0x9EBE8B14, 0x9ED68A12, 0x9EEC8C16, 0x9F06D80E, 0x9F267B0E -.word 0x9F3E8B14, 0x9F567B14, 0x9F6E8B14, 0x9F868A12, 0x9F9C3B14, 0x9FA85B14, 0x9FBA5B14, 0x9FCC5A12 -.word 0x9FDD8A12, 0x9FF38B14, 0xA00B8B14, 0xA0238B14, 0xA03B8B14, 0xA0538B14, 0xA06B8A12, 0xA081860C -.word 0xA08F980E, 0xA0A67B14, 0xA0BE8B14, 0xA0D68B14, 0xA0EE8A12, 0xA1045E16, 0xA11B5E16, 0xA1329D12 -.word 0xA1556F1A, 0xA16D1B16, 0xA1735316, 0xA1797B16, 0xA1915D18, 0xA1A67B16, 0xA1BE5B16, 0xA1D02316 -.word 0xA1D22F18, 0xA1DA2F18, 0xA1E23316, 0xA1E6540C, 0xA1EE2404, 0xA1F15008, 0xA1F31204, 0xA1F53A16 -.word 0xA2004B16, 0xA20C2B16, 0xA2124B16, 0xA21E5B16, 0xA2304B16, 0xA23C5B16, 0xA24E4B16, 0xA25A5B16 -.word 0xA26C4B16, 0xA2785B16, 0xA28A1710, 0xA28E280E, 0xA2936810, 0xA2A1530C, 0xA2A75810, 0xA2B54B16 -.word 0xA2C17C18, 0xA2DB5B16, 0xA2ED4B16, 0xA2F96C18, 0xA30D5B16, 0xA31F5B16, 0xA3315C18, 0xA3456C18 -.word 0xA3595B16, 0xA36B2A16, 0xA3714B16, 0xA37D6B16, 0xA38F5B16, 0xA3A17B16, 0xA3B96B16, 0xA3CB6C18 -.word 0xA3DF5B16, 0xA3F16D18, 0xA4065C18, 0xA41A6C18, 0xA42E6A16, 0xA43F5B16, 0xA4516B16, 0xA4638C18 -.word 0xA47D5B16, 0xA48F5B16, 0xA4A15B16, 0xA4B32E16, 0xA4BB3A16, 0xA4C62E16, 0xA4CE531A, 0xA4D470FC -.word 0xA4D65F1C, 0xA4EE4810, 0xA4F75B16, 0xA5095912, 0xA5185B16, 0xA52A5810, 0xA5383C18, 0xA5454B10 -.word 0xA5514B16, 0xA55D2B16, 0xA5632E16, 0xA56B4B16, 0xA5772B16, 0xA57D6810, 0xA58B4810, 0xA5945912 -.word 0xA5A34B10, 0xA5AF5B10, 0xA5C13810, 0xA5CA5912, 0xA5D93A14, 0xA5E44810, 0xA5ED5810, 0xA5FB6810 -.word 0xA6094810, 0xA6125B10, 0xA6245810, 0xA6324E16, 0xA6412E16, 0xA6494E16, 0xA6586116, 0xA65B6C18 -.word 0xA66F5E16, 0xA6862B10, 0xA68C5C14, 0xA6A04B16, 0xA6AC5712, 0xA6B84A16, 0xA6C32B16, 0xA6C94E16 -.word 0xA6D83116, 0xA6DA7B16, 0xA6F23618, 0xA6F9650E, 0xA702440C, 0xA7076B16, 0xA7197B16, 0xA7317016 -.word 0xA7332218, 0xA735570E, 0xA7415F1A, 0xA7595F1A, 0xA7712116, 0xA7725B10, 0xA7845E16, 0xA79B230E -.word 0xA79D2300, 0xA79F6D16, 0xA7B43618, 0xA7BB640C, 0xA7C38B16, 0xA7DB7516, 0xA7E78810, 0xA7F95B10 -.word 0xA80B5E1C, 0xA8225E1C, 0xA8395E1C, 0xA8506E1C, 0xA8675D1A, 0xA87C5F1E, 0xA8948B16, 0xA8AC6F18 -.word 0xA8C45F1E, 0xA8DC5E1C, 0xA8F35F1E, 0xA90B5D1A, 0xA9202E1C, 0xA9282E1C, 0xA9305F1E, 0xA9484D1A -.word 0xA9565F1C, 0xA96E6E1C, 0xA9857E1C, 0xA9A37E1C, 0xA9C17F1E, 0xA9E17E1C, 0xA9FF7D1A, 0xAA1B4810 -.word 0xAA246C18, 0xAA386E1C, 0xAA4F6E1C, 0xAA666F1E, 0xAA7E6D1A, 0xAA936F1C, 0xAAAB5F1C, 0xAAC34B16 -.word 0xAACF5B16, 0xAAE15B16, 0xAAF35C18, 0xAB076B16, 0xAB194A14, 0xAB245C18, 0xAB387810, 0xAB4A4B10 -.word 0xAB565B16, 0xAB685B16, 0xAB7A5C18, 0xAB8E4A14, 0xAB992B16, 0xAB9F2B16, 0xABA55B16, 0xABB74A14 -.word 0xABC24B16, 0xABCE6B16, 0xABE05B16, 0xABF25B16, 0xAC045C18, 0xAC186B16, 0xAC2A4A14, 0xAC35560E -.word 0xAC405810, 0xAC4E5B16, 0xAC604B16, 0xAC6C5C18, 0xAC804A14, 0xAC8B5F1A, 0xACA36F1A, 0xACBB4D14 -.word 0xACC96F1A, 0xACE12C18, 0xACE85318, 0xACEE8C18, 0xAD087E18, 0xAD266B16, 0xAD388C18, 0xAD522318 -.word 0xAD543F18, 0xAD643F18, 0xAD745318, 0xAD7A8710, 0xAD8A2302, 0xAD8C710A, 0xAD902102, 0xAD915E1A -.word 0xADA85B16, 0xADBA4B16, 0xADC65B16, 0xADD85B16, 0xADEA7B16, 0xAE025B16, 0xAE145B16, 0xAE267B16 -.word 0xAE3E5B16, 0xAE505B16, 0xAE622710, 0xAE662910, 0xAE6B7A12, 0xAE81740C, 0xAE8B7A12, 0xAEA16C18 -.word 0xAEB58C18, 0xAECF7C18, 0xAEE96C18, 0xAEFD6C18, 0xAF116C18, 0xAF255C18, 0xAF395C18, 0xAF4D6C18 -.word 0xAF616C18, 0xAF752C18, 0xAF7C6C18, 0xAF908C18, 0xAFAA5C18, 0xAFBE8C18, 0xAFD87C18, 0xAFF26C18 -.word 0xB0066C18, 0xB01A7C18, 0xB0346C18, 0xB0486C18, 0xB05C6C18, 0xB0706C18, 0xB0847C18, 0xB09EAC18 -.word 0xB0BF8C18, 0xB0D98C18, 0xB0F36C18, 0xB1073F1C, 0xB1175E1A, 0xB12E3F1C, 0xB13E5216, 0xB14380FC -.word 0xB1455F1C, 0xB15D5912, 0xB16C5C18, 0xB1805810, 0xB18E5C18, 0xB1A25912, 0xB1B14C18, 0xB1BE5C12 -.word 0xB1D25C18, 0xB1E62C18, 0xB1ED4F18, 0xB1FD6C18, 0xB2112C18, 0xB2187912, 0xB22C5912, 0xB23B5912 -.word 0xB24A5C12, 0xB25E5C12, 0xB2725912, 0xB2815A14, 0xB2924B16, 0xB29E5810, 0xB2AC7810, 0xB2BE8810 -.word 0xB2D07810, 0xB2E27A10, 0xB2F85810, 0xB3065E16, 0xB31D1C18, 0xB3245E16, 0xB33B6116, 0xB33E6C18 -.word 0xB3525E16, 0xB3692B10, 0xB36F6C14, 0xB3837B16, 0xB39B7914, 0xB3AF8B16, 0xB3C71C18, 0xB3CE7D16 -.word 0xB3EA4016, 0xB3EB7B16, 0xB4033618, 0xB40AA912, 0xB423820C, 0xB4296B16, 0xB43B7B16, 0xB4538016 -.word 0xB4553218, 0xB4588A14, 0xB46E3418, 0xB4733418, 0xB4783118, 0xB47A8A10, 0xB4906E16, 0xB4A7430E -.word 0xB4AB2302, 0xB4AD3418, 0xB4B23618, 0xB4B9A912, 0xB4D28B16, 0xB4EA8216, 0xB4F08910, 0xB5046B10 -.word 0xB5167E1C, 0xB5347E1C, 0xB5527F1E, 0xB5727E1C, 0xB5907E1C, 0xB5AE7F1E, 0xB5CE8C18, 0xB5E86E18 -.word 0xB5FF5F1E, 0xB6175F1E, 0xB62F5F1E, 0xB6475E1C, 0xB65E3F1E, 0xB66E3F1E, 0xB67E5F1E, 0xB6964E1C -.word 0xB6A57C18, 0xB6BF7E1C, 0xB6DD6F1E, 0xB6F56F1E, 0xB70D6F1E, 0xB7256F1E, 0xB73D6E1C, 0xB7547812 -.word 0xB7668C18, 0xB7806E1C, 0xB7976E1C, 0xB7AE6E1C, 0xB7C56D1A, 0xB7DA8D1A, 0xB7F68E1C, 0xB8146D1A -.word 0xB8295B16, 0xB83B5B16, 0xB84D5C18, 0xB8616B16, 0xB8735A14, 0xB8845C18, 0xB8988912, 0xB8AC5D12 -.word 0xB8C15B16, 0xB8D35B16, 0xB8E55B16, 0xB8F75A14, 0xB9083B16, 0xB9143B16, 0xB9205B16, 0xB9324A14 -.word 0xB93D5B16, 0xB94F6B16, 0xB9615B16, 0xB9735B16, 0xB9855C18, 0xB9996B16, 0xB9AB5A14, 0xB9BC8710 -.word 0xB9CC7B14, 0xB9E45B16, 0xB9F65B16, 0xBA085B16, 0xBA1A5A14, 0xBA2B7C16, 0xBA455C16, 0xBA597B14 -.word 0xBA716F18, 0xBA893B16, 0xBA956414, 0xBA9D6912, 0xBAAC6D16, 0xBAC17B14, 0xBAD97B14, 0xBAF14414 -.word 0xBAF64D16, 0xBB043D16, 0xBB127912, 0xBB266912, 0xBB353302, 0xBB39610A, 0xBB3C3202, 0xBB3F8D16 -.word 0xBB5B6B16, 0xBB6D5B16, 0xBB7F7B16, 0xBB976B16, 0xBBA97B16, 0xBBC17B16, 0xBBD97B16, 0xBBF16B16 -.word 0xBC037B16, 0xBC1B7B16, 0xBC333810, 0xBC3C3910, 0xBC467C18, 0xBC60730E, 0xBC687C18, 0xBC826B16 -.word 0xBC947B16, 0xBCAC7B16, 0xBCC47B16, 0xBCDC6B16, 0xBCEE7B16, 0xBD067B16, 0xBD1E7B16, 0xBD367B16 -.word 0xBD4E8B16, 0xBD665B16, 0xBD786B16, 0xBD8A8B16, 0xBDA27B16, 0xBDBA7B16, 0xBDD27B16, 0xBDEA6B16 -.word 0xBDFC8B16, 0xBE147C16, 0xBE2E7B16, 0xBE466B16, 0xBE587B16, 0xBE707B16, 0xBE887B16, 0xBEA08B16 -.word 0xBEB87B16, 0xBED07B16, 0xBEE87B16, 0xBF003D18, 0xBF0E8D16, 0xBF2A3D18, 0xBF387114, 0xBF3CA0FA -.word 0xBF3F6F1A, 0xBF577810, 0xBF69AB16, 0xBF878810, 0xBF997B16, 0xBFB17810, 0xBFC36B16, 0xBFD58910 -.word 0xBFE97B16, 0xC0015B16, 0xC0134C16, 0xC0208B16, 0xC0384B16, 0xC0447810, 0xC0567810, 0xC0686810 -.word 0xC0767910, 0xC08A7910, 0xC09E6810, 0xC0AC6810, 0xC0BA5A14, 0xC0CB7810, 0xC0DD7810, 0xC0EF8810 -.word 0xC1018810, 0xC1137910, 0xC1276810, 0xC1354D18, 0xC1432D18, 0xC14A4D18, 0xC1585116, 0xC15B6F1C -.word 0xC2276F16, 0xC23F6F16, 0xC1738A16, 0xC189AB16, 0xC2576F16, 0xC1A7C914, 0xC1C52D16, 0xC1CC6A16 -.word 0xC1DD6116, 0xC26F6F16, 0xC2876F16, 0xC1E07D18, 0xC1FCC40C, 0xC20B7D18, 0xC29F6F16, 0xC2B76F16 -.word 0xC2CF4318, 0xC2D3A914, 0xC2ECA912, 0xC305AB16, 0xC4126F18, 0xC323A910, 0xC33C8914, 0xC350430E -.word 0xC3543404, 0xC359DB14, 0xC383A016, 0xC386DB16, 0xC3B0ED18, 0xC3E1ED18, 0xC42A6F18, 0xC4426F18 -.word 0xC45AA20E, 0xC4624306, 0xC4666D18, 0xC47BA810, 0xC4925A18, 0xC4A35A12, 0xC4B46A18, 0xC4C57A12 -.word 0xC4DB5D18, 0xC4F05D18, 0xC5055D18, 0xC51A6D18, 0xC52FD914, 0xC552D914, 0xC575B914, 0xC593E510 -.word 0xC5A8F50E, 0xC5C07D16, 0xC5DC6D16, 0xC5F1EB14, 0xC61BEB14, 0xC645D912, 0xC668D912, 0xC68BAD16 -.word 0xC6AEAD16, 0xC6D1FA14, 0xC6FD9C16, 0xC71E6F16, 0xC7366F16, 0xC74E6F16, 0xC7666F16, 0xC77E6F16 -.word 0xC796E612, 0xC7AFA810, 0xC7C65118, 0xC7C96318, 0xC7CF3418, 0xC7D44810, 0xC7DDD30E, 0xC7EBA30E -.word 0xC7F55D18, 0xC80AC20E, 0xC8138B16, 0xC82BB912, 0xC8496F1A, 0xC8616F1A, 0xC8796F1A, 0xC8916F1A -.word 0xC8A90F17, 0xC8E9960E, 0xC8FB7810, 0xC90D960E, 0xC91F7810, 0xC9319E14, 0xC957F810, 0xC97B9E16 -.word 0xC9A1F810, 0xC9C5CC14, 0xC9ECDC16, 0xCA1ADC14, 0xCA48DC14, 0xCA76EF16, 0xCAAE070F, 0xCACE070F -.word 0xCAEE8F16, 0xCB0EED14, 0xCB3FED14, 0xCB70ED14, 0xCBA1EF16, 0xCBD9CB12, 0xCBFDCB12, 0xCC21CB12 -ENDDATA(asc2tbl) +DATA(D_801D04A0) + .word 0x00009D14 + .word 0x00232A14 + .word 0x00296314 + .word 0x002F8A14 + .word 0x00457E18 + .word 0x0063CA14 + .word 0x0084AA14 + .word 0x00A03314 + .word 0x00A45E14 + .word 0x00BB4E14 + .word 0x00CA6514 + .word 0x00D3770E + .word 0x00E33302 + .word 0x00E78108 + .word 0x00EB2102 + .word 0x00EC6C14 + .word 0x01008A14 + .word 0x01163A14 + .word 0x01217A14 + .word 0x01377A14 + .word 0x014D8A14 + .word 0x01638A14 + .word 0x01798A14 + .word 0x018F7A14 + .word 0x01A58A14 + .word 0x01BB8A14 + .word 0x01D1170E + .word 0x01D5490E + .word 0x01DF770E + .word 0x01EF740A + .word 0x01F9770E + .word 0x02097A14 + .word 0x021FDC16 + .word 0x024DBA14 + .word 0x026E7A14 + .word 0x0284BA14 + .word 0x02A59A14 + .word 0x02C16A14 + .word 0x02D26A14 + .word 0x02E3BA14 + .word 0x03048A14 + .word 0x031A1A14 + .word 0x03206A14 + .word 0x03318A14 + .word 0x03476A14 + .word 0x0358CA14 + .word 0x03799A14 + .word 0x0395CA14 + .word 0x03B67A14 + .word 0x03CCCA14 + .word 0x03ED8A14 + .word 0x04037A14 + .word 0x04196A14 + .word 0x042A8A14 + .word 0x0440AA14 + .word 0x045CDA14 + .word 0x04839A14 + .word 0x049F9A14 + .word 0x04BB7A14 + .word 0x04D14D14 + .word 0x04DF5C14 + .word 0x04F33D14 + .word 0x05015216 + .word 0x050681FA + .word 0x050A9D14 + .word 0x052D9810 + .word 0x05449A14 + .word 0x05609810 + .word 0x05779A14 + .word 0x05939810 + .word 0x05AA5A14 + .word 0x05BB9C10 + .word 0x05DC7A14 + .word 0x05F22A14 + .word 0x05F83D14 + .word 0x06067A14 + .word 0x061C2A14 + .word 0x0622D810 + .word 0x06427810 + .word 0x06549810 + .word 0x066B9B10 + .word 0x06899B10 + .word 0x06A74810 + .word 0x06B06810 + .word 0x06BE5A14 + .word 0x06CF770E + .word 0x06DF870E + .word 0x06EFB70E + .word 0x0707670E + .word 0x07138A0E + .word 0x0729670E + .word 0x07356D14 + .word 0x074A1F16 + .word 0x07526D14 + .word 0x07675216 + .word 0x076C9D14 + .word 0x078F9D14 + .word 0x07B22A0E + .word 0x07B88B14 + .word 0x07D08A14 + .word 0x07E69816 + .word 0x07FD9A14 + .word 0x08193F16 + .word 0x08296C14 + .word 0x083D5114 + .word 0x0840CA14 + .word 0x08616614 + .word 0x086C650C + .word 0x0875830A + .word 0x087D9D14 + .word 0x08A0CA14 + .word 0x08C14114 + .word 0x08C35318 + .word 0x08C98810 + .word 0x08DB9D14 + .word 0x08FE9D14 + .word 0x09213216 + .word 0x09249A0E + .word 0x09407A14 + .word 0x0956440E + .word 0x095B3302 + .word 0x095F9D14 + .word 0x09826614 + .word 0x098D650C + .word 0x09960A15 + .word 0x09C2C514 + .word 0x09D4070F + .word 0x09F47A0E + .word 0x0A0ABE1C + .word 0x0A37BE1C + .word 0x0A64BE1C + .word 0x0A91BD1A + .word 0x0ABBBD1A + .word 0x0AE5BE1C + .word 0x0B12FA14 + .word 0x0B3EBE14 + .word 0x0B6B7E1C + .word 0x0B897E1C + .word 0x0BA77E1C + .word 0x0BC57D1A + .word 0x0BE13E1C + .word 0x0BF04E1C + .word 0x0BFF4E1C + .word 0x0C0E5D1A + .word 0x0C239D14 + .word 0x0C469D1A + .word 0x0C69BE1C + .word 0x0C96BE1C + .word 0x0CC3BE1C + .word 0x0CF0BD1A + .word 0x0D1ABD1A + .word 0x0D44770E + .word 0x0D54CC16 + .word 0x0D7B8E1C + .word 0x0D998E1C + .word 0x0DB77E1C + .word 0x0DD57D1A + .word 0x0DF19D14 + .word 0x0E149D14 + .word 0x0E379A14 + .word 0x0E539B16 + .word 0x0E719B16 + .word 0x0E8F9B16 + .word 0x0EAD9B16 + .word 0x0ECB9A14 + .word 0x0EE79B16 + .word 0x0F050811 + .word 0x0F299B10 + .word 0x0F479B16 + .word 0x0F659B16 + .word 0x0F839B16 + .word 0x0FA19A14 + .word 0x0FBD3B16 + .word 0x0FC93A16 + .word 0x0FD44B16 + .word 0x0FE04A14 + .word 0x0FEB7912 + .word 0x0FFF8B16 + .word 0x10179B16 + .word 0x10359B16 + .word 0x10539B16 + .word 0x10719B16 + .word 0x108F9A14 + .word 0x10AB760C + .word 0x10B99910 + .word 0x10D28B16 + .word 0x10EA8B16 + .word 0x11028B16 + .word 0x111A8A14 + .word 0x11309D14 + .word 0x11539D14 + .word 0x11769D14 + .word 0x11996F18 + .word 0x11B13A14 + .word 0x11BC7514 + .word 0x11C88912 + .word 0x11DC9D16 + .word 0x11FFEA14 + .word 0x1226CA14 + .word 0x12474514 + .word 0x124D4D14 + .word 0x125B4D14 + .word 0x12696614 + .word 0x1274870E + .word 0x12843404 + .word 0x12899108 + .word 0x128E4204 + .word 0x12916C14 + .word 0x12A5AA14 + .word 0x12C17A14 + .word 0x12D79A14 + .word 0x12F3AA14 + .word 0x130FAA14 + .word 0x132B9B16 + .word 0x1349AA14 + .word 0x1365AA14 + .word 0x1381AA14 + .word 0x139DAA14 + .word 0x13B9370E + .word 0x13C1390E + .word 0x13CB770E + .word 0x13DB750C + .word 0x13E7770E + .word 0x13F79A14 + .word 0x1413CC14 + .word 0x143ACA14 + .word 0x145BBA14 + .word 0x147CBA14 + .word 0x149DBA14 + .word 0x14BEBA14 + .word 0x14DFBA14 + .word 0x1500BA14 + .word 0x1521CA14 + .word 0x15426A14 + .word 0x1553AA14 + .word 0x156FCA14 + .word 0x1590AA14 + .word 0x15ACFA14 + .word 0x15D8CA14 + .word 0x15F9BA14 + .word 0x161AAA14 + .word 0x1636CE14 + .word 0x1663CA14 + .word 0x16849A14 + .word 0x16A0CA14 + .word 0x16C1BA14 + .word 0x16E2CA14 + .word 0x1703EA14 + .word 0x172ACA14 + .word 0x174BCA14 + .word 0x176CAA14 + .word 0x17883D14 + .word 0x17966C14 + .word 0x17AA3D14 + .word 0x17B85214 + .word 0x17BD92FC + .word 0x17C55F1A + .word 0x17DD870E + .word 0x17EDAA14 + .word 0x1809870E + .word 0x18199A14 + .word 0x1835970E + .word 0x18497A14 + .word 0x185F9C10 + .word 0x1880BA14 + .word 0x18A15A14 + .word 0x18B26E14 + .word 0x18C9AA14 + .word 0x18E55A14 + .word 0x18F6F70E + .word 0x1916A70E + .word 0x192A970E + .word 0x193EAB0E + .word 0x195C9B0E + .word 0x197A770E + .word 0x198A770E + .word 0x199A6912 + .word 0x19A9A70E + .word 0x19BDA60E + .word 0x19CFD70E + .word 0x19EBA70E + .word 0x19FFAB0E + .word 0x1A1D870E + .word 0x1A2D6D14 + .word 0x1A423F16 + .word 0x1A526D14 + .word 0x1A675214 + .word 0x1A6C6F18 + .word 0x1A846F16 + .word 0x1A9C3A0E + .word 0x1AA78B14 + .word 0x1ABFAA14 + .word 0x1ADB8614 + .word 0x1AE9BA14 + .word 0x1B0A2F16 + .word 0x1B128A14 + .word 0x1B285214 + .word 0x1B2DBB14 + .word 0x1B516614 + .word 0x1B5C860C + .word 0x1B6A730A + .word 0x1B726E16 + .word 0x1B89BB14 + .word 0x1BAD5012 + .word 0x1BAF5316 + .word 0x1BB58910 + .word 0x1BC95F18 + .word 0x1BE15F18 + .word 0x1BF95316 + .word 0x1BFFA90C + .word 0x1C188A14 + .word 0x1C2E540E + .word 0x1C363404 + .word 0x1C3B6D14 + .word 0x1C506614 + .word 0x1C5B860C + .word 0x1C690913 + .word 0x1C91C512 + .word 0x1CA3D70E + .word 0x1CBF9A0E + .word 0x1CDBCD1A + .word 0x1D05CD1A + .word 0x1D2FCD1A + .word 0x1D59CD1A + .word 0x1D83CD1A + .word 0x1DADCE1C + .word 0x1DDA2A15 + .word 0x1E0CBD14 + .word 0x1E36BD1A + .word 0x1E60BD1A + .word 0x1E8ABD1A + .word 0x1EB4BC18 + .word 0x1EDB6D1A + .word 0x1EF06D1A + .word 0x1F056D1A + .word 0x1F1A6D1A + .word 0x1F2F5F1A + .word 0x1F47BD1A + .word 0x1F71CD1A + .word 0x1F9BCD1A + .word 0x1FC5CD1A + .word 0x1FEFCD1A + .word 0x2019CD1A + .word 0x2043970E + .word 0x2057CB14 + .word 0x207BAD1A + .word 0x209EBD1A + .word 0x20C8BD1A + .word 0x20F2BD1A + .word 0x211C6F1A + .word 0x21345F1A + .word 0x214CAA14 + .word 0x21689B16 + .word 0x21869B16 + .word 0x21A49A14 + .word 0x21C0AA14 + .word 0x21DC9A14 + .word 0x21F89B16 + .word 0x2216D70E + .word 0x22329B0E + .word 0x22508B16 + .word 0x22689B16 + .word 0x22869A14 + .word 0x22A29A14 + .word 0x22BE5B16 + .word 0x22D05B16 + .word 0x22E25A14 + .word 0x22F35A14 + .word 0x23048912 + .word 0x2318AA14 + .word 0x23349B16 + .word 0x23529B16 + .word 0x23709A14 + .word 0x238C9A14 + .word 0x23A89A14 + .word 0x23C49910 + .word 0x23DD9A10 + .word 0x23F9AB16 + .word 0x2417AB16 + .word 0x2435AA14 + .word 0x2451AA14 + .word 0x246D5F18 + .word 0x24855F18 + .word 0x249DAE14 + .word 0x24C39D14 + .word 0x24E62A14 + .word 0x24EC5314 + .word 0x24F28912 + .word 0x25068D16 + .word 0x2522CA14 + .word 0x2543CA14 + .word 0x25642314 + .word 0x25663C14 + .word 0x25733C14 + .word 0x25806514 + .word 0x2589770E + .word 0x25993302 + .word 0x259D9006 + .word 0x25A03102 + .word 0x25A26C14 + .word 0x25B69A14 + .word 0x25D26A14 + .word 0x25E38A14 + .word 0x25F99A14 + .word 0x26159A14 + .word 0x26318A14 + .word 0x26478A14 + .word 0x265D9912 + .word 0x26769A14 + .word 0x26928A14 + .word 0x26A8260C + .word 0x26AC480C + .word 0x26B5870E + .word 0x26C5740A + .word 0x26CF770E + .word 0x26DF8A14 + .word 0x26F5DC14 + .word 0x2723CA14 + .word 0x2744A912 + .word 0x275DAA14 + .word 0x2779B912 + .word 0x2797A912 + .word 0x27B0A912 + .word 0x27C9BA14 + .word 0x27EAC912 + .word 0x28085912 + .word 0x28179912 + .word 0x2830B912 + .word 0x284E9912 + .word 0x2867D912 + .word 0x288AB912 + .word 0x28A8CA14 + .word 0x28C99912 + .word 0x28E2CD14 + .word 0x290CB912 + .word 0x292A9A14 + .word 0x2946A912 + .word 0x295FB912 + .word 0x297DC912 + .word 0x299B0913 + .word 0x29C3C912 + .word 0x29E1B912 + .word 0x29FF9912 + .word 0x2A183B12 + .word 0x2A246C14 + .word 0x2A383B12 + .word 0x2A445214 + .word 0x2A4981FA + .word 0x2A4D9D14 + .word 0x2A70970E + .word 0x2A849A14 + .word 0x2AA0770E + .word 0x2AB09A14 + .word 0x2ACC870E + .word 0x2ADC6A14 + .word 0x2AED9C10 + .word 0x2B0E9A14 + .word 0x2B2A4912 + .word 0x2B346D12 + .word 0x2B499A14 + .word 0x2B655A14 + .word 0x2B76F70E + .word 0x2B96A70E + .word 0x2BAA970E + .word 0x2BBE9B0E + .word 0x2BDCAB0E + .word 0x2BFA770E + .word 0x2C0A770E + .word 0x2C1A6912 + .word 0x2C29A70E + .word 0x2C3D970E + .word 0x2C51C70E + .word 0x2C69A70E + .word 0x2C7D9B0E + .word 0x2C9B770E + .word 0x2CAB5C12 + .word 0x2CBF2F16 + .word 0x2CC76C12 + .word 0x2CDB5214 + .word 0x2CE08D14 + .word 0x2CFC9D14 + .word 0x2D1F2A0E + .word 0x2D257B14 + .word 0x2D3D9A14 + .word 0x2D599714 + .word 0x2D6DB912 + .word 0x2D8B2F16 + .word 0x2D937A14 + .word 0x2DA95112 + .word 0x2DACCB14 + .word 0x2DD07714 + .word 0x2DE0760C + .word 0x2DEE730A + .word 0x2DF69D14 + .word 0x2E19BB14 + .word 0x2E3D5112 + .word 0x2E405316 + .word 0x2E468810 + .word 0x2E589D14 + .word 0x2E7B9D14 + .word 0x2E9E4214 + .word 0x2EA19A0C + .word 0x2EBD7A14 + .word 0x2ED3440E + .word 0x2ED82302 + .word 0x2EDA8D14 + .word 0x2EF66714 + .word 0x2F02760C + .word 0x2F100A15 + .word 0x2F3CC614 + .word 0x2F51C70E + .word 0x2F698A0E + .word 0x2F7FCD1A + .word 0x2FA9CD1A + .word 0x2FD3BD1A + .word 0x2FFDCD1A + .word 0x3027CC18 + .word 0x304ECE1C + .word 0x307B0913 + .word 0x30A3BD14 + .word 0x30CDAD1A + .word 0x30F0BD1A + .word 0x311ABD1A + .word 0x3144AC18 + .word 0x31654D1A + .word 0x31734D1A + .word 0x31814D1A + .word 0x318F5C18 + .word 0x31A39D14 + .word 0x31C6BD1A + .word 0x31F0CD1A + .word 0x321ACD1A + .word 0x3244CD1A + .word 0x326ECD1A + .word 0x3298CC18 + .word 0x32BFA70E + .word 0x32D3BB14 + .word 0x32F7BD1A + .word 0x3321CD1A + .word 0x334BBD1A + .word 0x3375BC18 + .word 0x339C8D14 + .word 0x33B88D14 + .word 0x33D49A14 + .word 0x33F09A14 + .word 0x340C9A14 + .word 0x34289A14 + .word 0x34449A14 + .word 0x34609912 + .word 0x34799B16 + .word 0x3497C70E + .word 0x34AF7A0E + .word 0x34C58A14 + .word 0x34DB8A14 + .word 0x34F17A14 + .word 0x35077912 + .word 0x351B5A14 + .word 0x352C5A14 + .word 0x353D5A14 + .word 0x354E6912 + .word 0x355D7912 + .word 0x35719A14 + .word 0x358D8A14 + .word 0x35A38A14 + .word 0x35B98A14 + .word 0x35CF8A14 + .word 0x35E58912 + .word 0x35F9870E + .word 0x36099910 + .word 0x3622AA14 + .word 0x363EAA14 + .word 0x365AAA14 + .word 0x36769912 + .word 0x368F8D14 + .word 0x36AB8D14 + .word 0x36C79D12 + .word 0x36EA6F18 + .word 0x37024912 + .word 0x370C7412 + .word 0x37166B14 + .word 0x37288C14 + .word 0x37427912 + .word 0x37568810 + .word 0x37684412 + .word 0x376D5C12 + .word 0x37815C12 + .word 0x37957612 + .word 0x37A39710 + .word 0x37B74404 + .word 0x37BCA108 + .word 0x37C13306 + .word 0x37C57B14 + .word 0x37DD8912 + .word 0x37F17912 + .word 0x38057912 + .word 0x38198912 + .word 0x382D8912 + .word 0x38417912 + .word 0x38557912 + .word 0x38697912 + .word 0x387D8912 + .word 0x38918912 + .word 0x38A5370E + .word 0x38AD480C + .word 0x38B69710 + .word 0x38CA940E + .word 0x38D79710 + .word 0x38EB7912 + .word 0x38FF8B14 + .word 0x3917A912 + .word 0x39309912 + .word 0x39498912 + .word 0x395D8912 + .word 0x39719912 + .word 0x398A9912 + .word 0x39A39912 + .word 0x39BC9912 + .word 0x39D57912 + .word 0x39E99912 + .word 0x3A029912 + .word 0x3A1B9912 + .word 0x3A34A912 + .word 0x3A4D9912 + .word 0x3A669912 + .word 0x3A7F8912 + .word 0x3A939B12 + .word 0x3AB19912 + .word 0x3ACA8912 + .word 0x3ADE8912 + .word 0x3AF29912 + .word 0x3B0B9912 + .word 0x3B24A912 + .word 0x3B3D8912 + .word 0x3B518912 + .word 0x3B657912 + .word 0x3B794C12 + .word 0x3B867B14 + .word 0x3B9E4C12 + .word 0x3BAB6214 + .word 0x3BB0A2FC + .word 0x3BB85F1A + .word 0x3BD0870E + .word 0x3BE09912 + .word 0x3BF9870E + .word 0x3C098912 + .word 0x3C1D870E + .word 0x3C2D8912 + .word 0x3C419A0E + .word 0x3C5D8912 + .word 0x3C718A14 + .word 0x3C877D14 + .word 0x3CA39912 + .word 0x3CBC8912 + .word 0x3CD0A70E + .word 0x3CE4970E + .word 0x3CF8970E + .word 0x3D0C9B0E + .word 0x3D2AAB0E + .word 0x3D48970E + .word 0x3D5C770E + .word 0x3D6C8912 + .word 0x3D80970E + .word 0x3D94970E + .word 0x3DA8A70E + .word 0x3DBC870E + .word 0x3DCC9A0E + .word 0x3DE8770E + .word 0x3DF86D12 + .word 0x3E0D2F16 + .word 0x3E156D12 + .word 0x3E2A6212 + .word 0x3E2F6F16 + .word 0x3E476F16 + .word 0x3E5F4912 + .word 0x3E697A14 + .word 0x3E7F7912 + .word 0x3E938612 + .word 0x3EA19912 + .word 0x3EBA3F16 + .word 0x3ECA8A12 + .word 0x3EE06112 + .word 0x3EE3A812 + .word 0x3EFA7712 + .word 0x3F0A550C + .word 0x3F13950E + .word 0x3F226E16 + .word 0x3F399812 + .word 0x3F506112 + .word 0x3F534316 + .word 0x3F578812 + .word 0x3F695F18 + .word 0x3F815F18 + .word 0x3F995214 + .word 0x3F9E9A0E + .word 0x3FBA7912 + .word 0x3FCE320C + .word 0x3FD14404 + .word 0x3FD66D14 + .word 0x3FEB7712 + .word 0x3FFB650C + .word 0x40048710 + .word 0x40148310 + .word 0x401C860E + .word 0x402A7912 + .word 0x403EAC18 + .word 0x405FAC18 + .word 0x4080AC18 + .word 0x40A1AB16 + .word 0x40BFAB16 + .word 0x40DDAD1A + .word 0x4100B912 + .word 0x411E8C12 + .word 0x41388C18 + .word 0x41529C18 + .word 0x41739C18 + .word 0x41948B16 + .word 0x41AC7C18 + .word 0x41C67C18 + .word 0x41E07C18 + .word 0x41FA7B16 + .word 0x42125F1A + .word 0x422AAB16 + .word 0x42489C18 + .word 0x42699C18 + .word 0x428A9C18 + .word 0x42AB9B16 + .word 0x42C99B16 + .word 0x42E7870E + .word 0x42F79A12 + .word 0x43139C18 + .word 0x43349C18 + .word 0x4355AC18 + .word 0x4376AB16 + .word 0x43946F1A + .word 0x43AC5F1A + .word 0x43C48912 + .word 0x43D88A14 + .word 0x43EE8A14 + .word 0x44049A14 + .word 0x44209912 + .word 0x44398912 + .word 0x444D8B16 + .word 0x4465970E + .word 0x44798A0E + .word 0x448F8A14 + .word 0x44A58A14 + .word 0x44BB9A14 + .word 0x44D79912 + .word 0x44F08A14 + .word 0x45068A14 + .word 0x451C7A14 + .word 0x45327912 + .word 0x45468912 + .word 0x455A9912 + .word 0x45738A14 + .word 0x45898A14 + .word 0x459F9912 + .word 0x45B89912 + .word 0x45D19912 + .word 0x45EAA912 + .word 0x46039910 + .word 0x461C9A14 + .word 0x46389A14 + .word 0x46548A14 + .word 0x466A9912 + .word 0x46835F18 + .word 0x469B5F18 + .word 0x46B38C12 + .word 0x46CD3C16 + .word 0x46DA3C16 + .word 0x46E77516 + .word 0x46F39A14 + .word 0x470F7E18 + .word 0x472DDC16 + .word 0x475BBC16 + .word 0x47824516 + .word 0x47884F18 + .word 0x47984F18 + .word 0x47A85516 + .word 0x47B1870E + .word 0x47C15504 + .word 0x47CA810A + .word 0x47CE4304 + .word 0x47D28F18 + .word 0x47F29C16 + .word 0x48134B16 + .word 0x481F8B16 + .word 0x48378C16 + .word 0x48519B16 + .word 0x486F8C16 + .word 0x48898C16 + .word 0x48A38B16 + .word 0x48BB8C16 + .word 0x48D58C16 + .word 0x48EF380E + .word 0x48F84A0E + .word 0x4903970E + .word 0x4917850C + .word 0x4923870E + .word 0x49337C16 + .word 0x494DCC16 + .word 0x4974BB16 + .word 0x49988B16 + .word 0x49B09C16 + .word 0x49D1AB16 + .word 0x49EF7B16 + .word 0x4A077B16 + .word 0x4A1FBC16 + .word 0x4A46AB16 + .word 0x4A643B16 + .word 0x4A706C16 + .word 0x4A849B16 + .word 0x4AA26B16 + .word 0x4AB4DC16 + .word 0x4AE2AC16 + .word 0x4B03CC16 + .word 0x4B2A8B16 + .word 0x4B42CC16 + .word 0x4B698B16 + .word 0x4B818C16 + .word 0x4B9B7B16 + .word 0x4BB39C16 + .word 0x4BD4BC16 + .word 0x4BFBFC16 + .word 0x4C2FAB16 + .word 0x4C4DAB16 + .word 0x4C6B9B16 + .word 0x4C893E18 + .word 0x4C988C18 + .word 0x4CB24E18 + .word 0x4CC16316 + .word 0x4CC781FC + .word 0x4CCB3C16 + .word 0x4CD8880E + .word 0x4CEA8D18 + .word 0x4D06680E + .word 0x4D149D18 + .word 0x4D37880E + .word 0x4D495C18 + .word 0x4D5D8B0E + .word 0x4D757C18 + .word 0x4D8F3B16 + .word 0x4D9B3F16 + .word 0x4DAB8C18 + .word 0x4DC53C18 + .word 0x4DD2B70E + .word 0x4DEA770E + .word 0x4DFA980E + .word 0x4E119B0E + .word 0x4E2F9B0E + .word 0x4E4D670E + .word 0x4E59680E + .word 0x4E674912 + .word 0x4E71780E + .word 0x4E83980E + .word 0x4E9AD80E + .word 0x4EBAA70E + .word 0x4ECE9B0E + .word 0x4EEC770E + .word 0x4EFC5F18 + .word 0x4F142C18 + .word 0x4F1B4F18 + .word 0x4F2B7114 + .word 0x4F2F3C16 + .word 0x4F3C3C10 + .word 0x4F493B0E + .word 0x4F556A14 + .word 0x4F669C16 + .word 0x4F879810 + .word 0x4F9E9B16 + .word 0x4FBC2C18 + .word 0x4FC38E18 + .word 0x4FE16216 + .word 0x4FE6DC16 + .word 0x50146616 + .word 0x501F7710 + .word 0x502F840C + .word 0x50393C1A + .word 0x5046DC16 + .word 0x50747116 + .word 0x50784316 + .word 0x507C8912 + .word 0x50903C14 + .word 0x509D3C14 + .word 0x50AA4316 + .word 0x50AE7B0E + .word 0x50C6AE16 + .word 0x50EC6610 + .word 0x50F75504 + .word 0x51003C18 + .word 0x510D6616 + .word 0x51188710 + .word 0x5128FC16 + .word 0x515CE616 + .word 0x5175D80E + .word 0x51958B0E + .word 0x51ADCC18 + .word 0x51D4BC18 + .word 0x51FBBC18 + .word 0x5222BC18 + .word 0x5249CC18 + .word 0x5270BC18 + .word 0x5297FB16 + .word 0x52C79E16 + .word 0x52ED6C18 + .word 0x53016C18 + .word 0x53157C18 + .word 0x532F7C18 + .word 0x53494C18 + .word 0x53564C18 + .word 0x53636C18 + .word 0x53777C18 + .word 0x53913C18 + .word 0x539EAD18 + .word 0x53C1CD18 + .word 0x53EBCD18 + .word 0x5415CD18 + .word 0x543FCD18 + .word 0x5469CC18 + .word 0x5490970E + .word 0x54A4CC16 + .word 0x54CB9D18 + .word 0x54EE9D18 + .word 0x55119D18 + .word 0x55349D18 + .word 0x55573C18 + .word 0x55643C18 + .word 0x55719D18 + .word 0x55948C16 + .word 0x55AE9C16 + .word 0x55CF8C16 + .word 0x55E99B14 + .word 0x56078C16 + .word 0x56219C16 + .word 0x5642C80E + .word 0x565D6A0E + .word 0x566E8C16 + .word 0x56887C16 + .word 0x56A28C16 + .word 0x56BC7C16 + .word 0x56D64B16 + .word 0x56E24B16 + .word 0x56EE6B16 + .word 0x57007B16 + .word 0x57187B16 + .word 0x57307A14 + .word 0x57469C16 + .word 0x57678C16 + .word 0x57818C16 + .word 0x579B9B14 + .word 0x57B99C16 + .word 0x57DA880E + .word 0x57EC980E + .word 0x58038C16 + .word 0x581D8C16 + .word 0x58378C16 + .word 0x58518C16 + .word 0x586B3C16 + .word 0x58783C16 + .word 0x58859F16 + .word 0x58AD6F18 + .word 0x58C55C16 + .word 0x58D98516 + .word 0x58E59B14 + .word 0x59038E18 + .word 0x5921BC16 + .word 0x5948AC16 + .word 0x59695516 + .word 0x59724F18 + .word 0x59825F18 + .word 0x599A6516 + .word 0x59A3970E + .word 0x59B75504 + .word 0x59C0810A + .word 0x59C43304 + .word 0x59C8AF18 + .word 0x59F09C16 + .word 0x5A115B16 + .word 0x5A239B16 + .word 0x5A418C16 + .word 0x5A5B9B16 + .word 0x5A799C16 + .word 0x5A9A9C16 + .word 0x5ABBAC16 + .word 0x5ADC8C16 + .word 0x5AF69C16 + .word 0x5B17480E + .word 0x5B206A0E + .word 0x5B31970E + .word 0x5B45950C + .word 0x5B54970E + .word 0x5B687C16 + .word 0x5B82CC16 + .word 0x5BA9BB16 + .word 0x5BCD9B16 + .word 0x5BEB9C16 + .word 0x5C0CBB16 + .word 0x5C309B16 + .word 0x5C4E9B16 + .word 0x5C6CBC16 + .word 0x5C93BB16 + .word 0x5CB75B16 + .word 0x5CC98C16 + .word 0x5CE3BB16 + .word 0x5D077B16 + .word 0x5D1FDC16 + .word 0x5D4DCC16 + .word 0x5D74DC16 + .word 0x5DA29B16 + .word 0x5DC0CC16 + .word 0x5DE79B16 + .word 0x5E059C16 + .word 0x5E268B16 + .word 0x5E3EAC16 + .word 0x5E5FBC16 + .word 0x5E860C17 + .word 0x5EBABB16 + .word 0x5EDEAB16 + .word 0x5EFCBB16 + .word 0x5F205E18 + .word 0x5F376E18 + .word 0x5F4E6E18 + .word 0x5F655316 + .word 0x5F6B91FC + .word 0x5F706F1A + .word 0x5F88980E + .word 0x5F9F9D18 + .word 0x5FC2680E + .word 0x5FD0AD18 + .word 0x5FF3880E + .word 0x60056C18 + .word 0x60199B0E + .word 0x60378C18 + .word 0x60515B16 + .word 0x60636F16 + .word 0x607B9C18 + .word 0x609C5C18 + .word 0x60B0C70E + .word 0x60C8870E + .word 0x60D8880E + .word 0x60EA9B0E + .word 0x61089B0E + .word 0x6126770E + .word 0x6136680E + .word 0x61446912 + .word 0x6153780E + .word 0x6165980E + .word 0x617CD80E + .word 0x619CA70E + .word 0x61B0AB0E + .word 0x61CEA70E + .word 0x61E26F18 + .word 0x61FA4C18 + .word 0x62076F18 + .word 0x621F7114 + .word 0x62236F18 + .word 0x623B6F16 + .word 0x62534B0E + .word 0x625F7A14 + .word 0x6275AC16 + .word 0x6296A810 + .word 0x62ADAB16 + .word 0x62CB4C18 + .word 0x62D88E18 + .word 0x62F66216 + .word 0x62FBDC16 + .word 0x63297616 + .word 0x63378710 + .word 0x6347940C + .word 0x63546F18 + .word 0x636CDC16 + .word 0x639A6116 + .word 0x639D4316 + .word 0x63A19912 + .word 0x63BA6F18 + .word 0x63D26F18 + .word 0x63EA5316 + .word 0x63F09B0E + .word 0x640E9E16 + .word 0x64346610 + .word 0x643F5504 + .word 0x64486F18 + .word 0x64607616 + .word 0x646E8710 + .word 0x647EFA14 + .word 0x64AAD514 + .word 0x64BFC60C + .word 0x64D47B0E + .word 0x64ECCC18 + .word 0x6513BC18 + .word 0x653ABC18 + .word 0x6561CC18 + .word 0x6588CC18 + .word 0x65AFBC18 + .word 0x65D6FB16 + .word 0x6606AE16 + .word 0x662C8C18 + .word 0x66468C18 + .word 0x66609C18 + .word 0x66819C18 + .word 0x66A25C18 + .word 0x66B66C18 + .word 0x66CA7C18 + .word 0x66E47C18 + .word 0x66FE6F1A + .word 0x6716CD18 + .word 0x6740DD18 + .word 0x6771CD18 + .word 0x679BCD18 + .word 0x67C5CD18 + .word 0x67EFDD18 + .word 0x6820A70E + .word 0x6834FC16 + .word 0x6868AD18 + .word 0x688BAD18 + .word 0x68AEAD18 + .word 0x68D1AD18 + .word 0x68F46F1A + .word 0x690C6F1A + .word 0x69249D18 + .word 0x69479C16 + .word 0x69689C16 + .word 0x69899C16 + .word 0x69AA9B14 + .word 0x69C89C16 + .word 0x69E99C16 + .word 0x6A0AD80E + .word 0x6A2A7A0E + .word 0x6A408C16 + .word 0x6A5A8C16 + .word 0x6A748C16 + .word 0x6A8E8C16 + .word 0x6AA85B16 + .word 0x6ABA5B16 + .word 0x6ACC6B16 + .word 0x6ADE6B16 + .word 0x6AF07B16 + .word 0x6B089A14 + .word 0x6B248C16 + .word 0x6B3E9C16 + .word 0x6B5F9C16 + .word 0x6B808B14 + .word 0x6B988C16 + .word 0x6BB2980E + .word 0x6BC9980E + .word 0x6BE08C16 + .word 0x6BFA8C16 + .word 0x6C148C16 + .word 0x6C2E8C16 + .word 0x6C486F18 + .word 0x6C606F18 + .word 0x6C78AF16 + .word 0x6CA06F18 + .word 0x6CB82A14 + .word 0x6CBE4314 + .word 0x6CC29A14 + .word 0x6CDE8D16 + .word 0x6CFADB14 + .word 0x6D249B14 + .word 0x6D422314 + .word 0x6D445D14 + .word 0x6D594D14 + .word 0x6D675414 + .word 0x6D6F870E + .word 0x6D7F2402 + .word 0x6D829108 + .word 0x6D872102 + .word 0x6D885A14 + .word 0x6D998B14 + .word 0x6DB15A14 + .word 0x6DC28A14 + .word 0x6DD88B14 + .word 0x6DF08A14 + .word 0x6E068B14 + .word 0x6E1E8B14 + .word 0x6E368A14 + .word 0x6E4C8B14 + .word 0x6E648B14 + .word 0x6E7C270E + .word 0x6E802A0E + .word 0x6E86970E + .word 0x6E9A850C + .word 0x6EA6970E + .word 0x6EBA7A14 + .word 0x6ED0DB14 + .word 0x6EFAAA14 + .word 0x6F169A14 + .word 0x6F32AB14 + .word 0x6F509A14 + .word 0x6F6C9A14 + .word 0x6F889A14 + .word 0x6FA4AB14 + .word 0x6FC2AA14 + .word 0x6FDE2A14 + .word 0x6FE47B14 + .word 0x6FFC9A14 + .word 0x70188A14 + .word 0x702EBA14 + .word 0x704F9A14 + .word 0x706BBB14 + .word 0x708F9A14 + .word 0x70ABBB14 + .word 0x70CF9A14 + .word 0x70EB9B14 + .word 0x7109AA14 + .word 0x71259B14 + .word 0x7143AA14 + .word 0x715FEA14 + .word 0x7186AA14 + .word 0x71A2AA14 + .word 0x71BE9A14 + .word 0x71DA3D14 + .word 0x71E87A14 + .word 0x71FE4D14 + .word 0x720C5214 + .word 0x721190FC + .word 0x72145F1A + .word 0x722C8910 + .word 0x72408B14 + .word 0x72588910 + .word 0x726C7C16 + .word 0x72868910 + .word 0x729A6A14 + .word 0x72AB8C10 + .word 0x72C57A14 + .word 0x72DB2A14 + .word 0x72E14E14 + .word 0x72F07A14 + .word 0x73062A14 + .word 0x730CB810 + .word 0x73277810 + .word 0x73398910 + .word 0x734D8C10 + .word 0x73678C10 + .word 0x73815810 + .word 0x738F7910 + .word 0x73A34A12 + .word 0x73AE780E + .word 0x73C0870E + .word 0x73D0B70E + .word 0x73E8770E + .word 0x73F88B0E + .word 0x7410770E + .word 0x74205D14 + .word 0x74352A14 + .word 0x743B6D14 + .word 0x74506114 + .word 0x74536F18 + .word 0x746B6F16 + .word 0x74832A0E + .word 0x74898B12 + .word 0x74A18B14 + .word 0x74B98710 + .word 0x74C99A14 + .word 0x74E52A14 + .word 0x74EB7E14 + .word 0x75094114 + .word 0x750BBA14 + .word 0x752C5414 + .word 0x7534650C + .word 0x753D840A + .word 0x75476E16 + .word 0x755EBA14 + .word 0x757F6114 + .word 0x75823316 + .word 0x7586870E + .word 0x75965F18 + .word 0x75AE5F18 + .word 0x75C64214 + .word 0x75C99B0E + .word 0x75E78D14 + .word 0x7603430C + .word 0x76072402 + .word 0x760A6D14 + .word 0x761F5414 + .word 0x7627550C + .word 0x7630FB14 + .word 0x7660C514 + .word 0x7672E80E + .word 0x76928A0E + .word 0x76A8AD1A + .word 0x76CBAD1A + .word 0x76EEAD1A + .word 0x7711AD1A + .word 0x7734AD1A + .word 0x7757AE1C + .word 0x777DFA14 + .word 0x77A9AD14 + .word 0x77CC8D1A + .word 0x77E88D1A + .word 0x78048D1A + .word 0x78208C18 + .word 0x783A4D1A + .word 0x78483D1A + .word 0x78565D1A + .word 0x786B5D1A + .word 0x78805F1A + .word 0x7898AD1A + .word 0x78BBCE1A + .word 0x78E8BE1A + .word 0x7915BE1A + .word 0x7942BE1A + .word 0x796FCD18 + .word 0x7999870E + .word 0x79A9BB14 + .word 0x79CD9E1A + .word 0x79F39E1A + .word 0x7A199E1A + .word 0x7A3FAE1A + .word 0x7A656F1A + .word 0x7A7D5F1A + .word 0x7A958B14 + .word 0x7AAD8C16 + .word 0x7AC78C16 + .word 0x7AE18C16 + .word 0x7AFB8B14 + .word 0x7B138B14 + .word 0x7B2B8C16 + .word 0x7B45D910 + .word 0x7B687C10 + .word 0x7B828C16 + .word 0x7B9C8C16 + .word 0x7BB68C16 + .word 0x7BD08B14 + .word 0x7BE84B16 + .word 0x7BF44B16 + .word 0x7C005B16 + .word 0x7C124B16 + .word 0x7C1E7B14 + .word 0x7C367A14 + .word 0x7C4C8C16 + .word 0x7C668C16 + .word 0x7C808C16 + .word 0x7C9A8B14 + .word 0x7CB28B14 + .word 0x7CCA870E + .word 0x7CDA8910 + .word 0x7CEE7C16 + .word 0x7D088C16 + .word 0x7D227C16 + .word 0x7D3C7B14 + .word 0x7D545F18 + .word 0x7D6C5F18 + .word 0x7D848E14 + .word 0x7DA26F16 + .word 0x7DBA3A14 + .word 0x7DC56414 + .word 0x7DCD9A14 + .word 0x7DE98D16 + .word 0x7E05EB14 + .word 0x7E2FBB14 + .word 0x7E533414 + .word 0x7E584D14 + .word 0x7E664D14 + .word 0x7E746414 + .word 0x7E7C870E + .word 0x7E8C3402 + .word 0x7E91920A + .word 0x7E993102 + .word 0x7E9B7A14 + .word 0x7EB18B14 + .word 0x7EC95A14 + .word 0x7EDA8A14 + .word 0x7EF08B14 + .word 0x7F088A14 + .word 0x7F1E8B14 + .word 0x7F368B14 + .word 0x7F4E8A14 + .word 0x7F648B14 + .word 0x7F7C9B14 + .word 0x7F9A370E + .word 0x7FA23A0E + .word 0x7FADA80E + .word 0x7FC4960C + .word 0x7FD6980E + .word 0x7FED9A14 + .word 0x8009DC16 + .word 0x8037BA14 + .word 0x8058AA14 + .word 0x8074BB14 + .word 0x8098AA14 + .word 0x80B49A14 + .word 0x80D09A14 + .word 0x80ECBB14 + .word 0x8110AA14 + .word 0x812C3A14 + .word 0x81378B14 + .word 0x814FAA14 + .word 0x816B9A14 + .word 0x8187BA14 + .word 0x81A8AA14 + .word 0x81C4BB14 + .word 0x81E89A14 + .word 0x8204BB14 + .word 0x8228AA14 + .word 0x8244AB14 + .word 0x8262AA14 + .word 0x827E9B14 + .word 0x829CAA14 + .word 0x82B8FA14 + .word 0x82E4AA14 + .word 0x8300AA14 + .word 0x831C9A14 + .word 0x83384D14 + .word 0x83466A14 + .word 0x83575D14 + .word 0x836C6216 + .word 0x837190FC + .word 0x83745F18 + .word 0x838C8910 + .word 0x83A09B14 + .word 0x83BE8910 + .word 0x83D29B14 + .word 0x83F09910 + .word 0x84095A14 + .word 0x841A8C10 + .word 0x84348A14 + .word 0x844A3A14 + .word 0x84554E14 + .word 0x84648A14 + .word 0x847A2A14 + .word 0x8480C810 + .word 0x849B8810 + .word 0x84AD9910 + .word 0x84C68C10 + .word 0x84E09C10 + .word 0x85015810 + .word 0x850F8910 + .word 0x85235A14 + .word 0x8534880E + .word 0x8546870E + .word 0x8556C70E + .word 0x856E870E + .word 0x857E8B0E + .word 0x8596870E + .word 0x85A65D14 + .word 0x85BB3A14 + .word 0x85C66D14 + .word 0x85DB7216 + .word 0x85E16F18 + .word 0x85F96F14 + .word 0x86113A0E + .word 0x861C8B12 + .word 0x86348B14 + .word 0x864C8710 + .word 0x865C9A14 + .word 0x86783A14 + .word 0x86838D14 + .word 0x869F6114 + .word 0x86A2BA14 + .word 0x86C36514 + .word 0x86CC750C + .word 0x86D8950C + .word 0x86E75F16 + .word 0x86FFBA14 + .word 0x87206114 + .word 0x87234318 + .word 0x8727970E + .word 0x873B5F16 + .word 0x87535F16 + .word 0x876B4114 + .word 0x876DAB0E + .word 0x878B9D14 + .word 0x87AE430C + .word 0x87B23402 + .word 0x87B76F16 + .word 0x87CF6514 + .word 0x87D8650C + .word 0x87E1EC14 + .word 0x880FC512 + .word 0x8821E90E + .word 0x88448A0E + .word 0x885AAD1A + .word 0x887DBD1A + .word 0x88A7BD1A + .word 0x88D1BD1A + .word 0x88FBAD1A + .word 0x891EBE1C + .word 0x894BFA14 + .word 0x8977AE14 + .word 0x899D9D1A + .word 0x89C09D1A + .word 0x89E39D1A + .word 0x8A069D1A + .word 0x8A294D1A + .word 0x8A374D1A + .word 0x8A456D1A + .word 0x8A5A6D1A + .word 0x8A6F5F18 + .word 0x8A87AD1A + .word 0x8AAABE1A + .word 0x8AD7BE1A + .word 0x8B04BE1A + .word 0x8B31BE1A + .word 0x8B5EBE1A + .word 0x8B8B870E + .word 0x8B9BBB14 + .word 0x8BBF9E1A + .word 0x8BE59E1A + .word 0x8C0BAE1A + .word 0x8C31AE1A + .word 0x8C575F18 + .word 0x8C6F5F18 + .word 0x8C878B14 + .word 0x8C9F8B14 + .word 0x8CB79B14 + .word 0x8CD58C16 + .word 0x8CEF8C16 + .word 0x8D098B14 + .word 0x8D219D18 + .word 0x8D44D910 + .word 0x8D678C10 + .word 0x8D818B14 + .word 0x8D999B14 + .word 0x8DB79C16 + .word 0x8DD88B14 + .word 0x8DF05A14 + .word 0x8E015A14 + .word 0x8E125A14 + .word 0x8E236A14 + .word 0x8E348B14 + .word 0x8E4C8B16 + .word 0x8E649B14 + .word 0x8E829B14 + .word 0x8EA09C16 + .word 0x8EC19C16 + .word 0x8EE29B14 + .word 0x8F00870E + .word 0x8F10A910 + .word 0x8F298B14 + .word 0x8F418B14 + .word 0x8F598C16 + .word 0x8F738C16 + .word 0x8F8D5F18 + .word 0x8FA55F18 + .word 0x8FBD8F16 + .word 0x8FDD6F16 + .word 0x8FF54A12 + .word 0x90004312 + .word 0x90049A12 + .word 0x90209C14 + .word 0x9041BA12 + .word 0x90628A12 + .word 0x90782312 + .word 0x907A6C12 + .word 0x908E5C12 + .word 0x90A25412 + .word 0x90AA870C + .word 0x90BA3300 + .word 0x90BE8006 + .word 0x90C02100 + .word 0x90C17A12 + .word 0x90D78A12 + .word 0x90ED5A12 + .word 0x90FE9A12 + .word 0x911A8A12 + .word 0x91308A12 + .word 0x91469A12 + .word 0x91628A12 + .word 0x91788A12 + .word 0x918E8A12 + .word 0x91A47A12 + .word 0x91BA370E + .word 0x91C24A0E + .word 0x91CD980E + .word 0x91E4940A + .word 0x91F1980E + .word 0x92087A12 + .word 0x921ECB14 + .word 0x9242AA12 + .word 0x925E9A12 + .word 0x927ABB14 + .word 0x929EAA12 + .word 0x92BABA12 + .word 0x92DBAA12 + .word 0x92F7BB14 + .word 0x931BBA12 + .word 0x933C4A12 + .word 0x93478A12 + .word 0x935DBA12 + .word 0x937E8A12 + .word 0x9394CA12 + .word 0x93B5AA12 + .word 0x93D1BB14 + .word 0x93F5AA12 + .word 0x9411BB14 + .word 0x9435AA12 + .word 0x94519B14 + .word 0x946F9A12 + .word 0x948BAA12 + .word 0x94A7AA12 + .word 0x94C3DA12 + .word 0x94EABA12 + .word 0x950B9A12 + .word 0x9527BA12 + .word 0x95485C12 + .word 0x955C3A12 + .word 0x95675C12 + .word 0x957B5112 + .word 0x957E80FC + .word 0x95803F18 + .word 0x9590780E + .word 0x95A29A12 + .word 0x95BE880E + .word 0x95D09A12 + .word 0x95EC880E + .word 0x95FE5A12 + .word 0x960F9B0E + .word 0x962D8A12 + .word 0x96434A12 + .word 0x964E6D12 + .word 0x96638A12 + .word 0x96794A12 + .word 0x9684C80E + .word 0x969F880E + .word 0x96B1880E + .word 0x96C39B0E + .word 0x96E18B0E + .word 0x96F9680E + .word 0x9707780E + .word 0x97195A12 + .word 0x972A880E + .word 0x973C880E + .word 0x974EA80E + .word 0x9765980E + .word 0x977C9B0E + .word 0x979A880E + .word 0x97AC7C12 + .word 0x97C63A12 + .word 0x97D16C12 + .word 0x97E56112 + .word 0x97E86F18 + .word 0x98004F14 + .word 0x98104A0E + .word 0x981B8A10 + .word 0x98319A12 + .word 0x984D860E + .word 0x985B9A12 + .word 0x98774A12 + .word 0x98827D12 + .word 0x989E5112 + .word 0x98A1BA12 + .word 0x98C25514 + .word 0x98CB740A + .word 0x98D5840A + .word 0x98DF5F14 + .word 0x98F7BA12 + .word 0x99185112 + .word 0x991B3214 + .word 0x991E870C + .word 0x992E5F16 + .word 0x99465F16 + .word 0x995E3112 + .word 0x9960BB0E + .word 0x99848C12 + .word 0x999E330C + .word 0x99A22300 + .word 0x99A46F16 + .word 0x99BC5514 + .word 0x99C5640A + .word 0x99CDFB14 + .word 0x99FDB412 + .word 0x9A0CD80E + .word 0x9A2C7A0E + .word 0x9A42AD18 + .word 0x9A65AD18 + .word 0x9A889D18 + .word 0x9AABAD18 + .word 0x9ACEAD18 + .word 0x9AF1AE1A + .word 0x9B17FA12 + .word 0x9B43BE14 + .word 0x9B70BD18 + .word 0x9B9AAD18 + .word 0x9BBDAD18 + .word 0x9BE0AD18 + .word 0x9C035D18 + .word 0x9C186D18 + .word 0x9C2D6D18 + .word 0x9C426D18 + .word 0x9C573F18 + .word 0x9C67BD18 + .word 0x9C91BD18 + .word 0x9CBBBD18 + .word 0x9CE5BD18 + .word 0x9D0FBD18 + .word 0x9D39BD18 + .word 0x9D63980E + .word 0x9D7ADB14 + .word 0x9DA4AD18 + .word 0x9DC7AD18 + .word 0x9DEAAD18 + .word 0x9E0DAD18 + .word 0x9E305F18 + .word 0x9E485F18 + .word 0x9E608A12 + .word 0x9E768B14 + .word 0x9E8E8B14 + .word 0x9EA68B14 + .word 0x9EBE8B14 + .word 0x9ED68A12 + .word 0x9EEC8C16 + .word 0x9F06D80E + .word 0x9F267B0E + .word 0x9F3E8B14 + .word 0x9F567B14 + .word 0x9F6E8B14 + .word 0x9F868A12 + .word 0x9F9C3B14 + .word 0x9FA85B14 + .word 0x9FBA5B14 + .word 0x9FCC5A12 + .word 0x9FDD8A12 + .word 0x9FF38B14 + .word 0xA00B8B14 + .word 0xA0238B14 + .word 0xA03B8B14 + .word 0xA0538B14 + .word 0xA06B8A12 + .word 0xA081860C + .word 0xA08F980E + .word 0xA0A67B14 + .word 0xA0BE8B14 + .word 0xA0D68B14 + .word 0xA0EE8A12 + .word 0xA1045E16 + .word 0xA11B5E16 + .word 0xA1329D12 + .word 0xA1556F1A + .word 0xA16D1B16 + .word 0xA1735316 + .word 0xA1797B16 + .word 0xA1915D18 + .word 0xA1A67B16 + .word 0xA1BE5B16 + .word 0xA1D02316 + .word 0xA1D22F18 + .word 0xA1DA2F18 + .word 0xA1E23316 + .word 0xA1E6540C + .word 0xA1EE2404 + .word 0xA1F15008 + .word 0xA1F31204 + .word 0xA1F53A16 + .word 0xA2004B16 + .word 0xA20C2B16 + .word 0xA2124B16 + .word 0xA21E5B16 + .word 0xA2304B16 + .word 0xA23C5B16 + .word 0xA24E4B16 + .word 0xA25A5B16 + .word 0xA26C4B16 + .word 0xA2785B16 + .word 0xA28A1710 + .word 0xA28E280E + .word 0xA2936810 + .word 0xA2A1530C + .word 0xA2A75810 + .word 0xA2B54B16 + .word 0xA2C17C18 + .word 0xA2DB5B16 + .word 0xA2ED4B16 + .word 0xA2F96C18 + .word 0xA30D5B16 + .word 0xA31F5B16 + .word 0xA3315C18 + .word 0xA3456C18 + .word 0xA3595B16 + .word 0xA36B2A16 + .word 0xA3714B16 + .word 0xA37D6B16 + .word 0xA38F5B16 + .word 0xA3A17B16 + .word 0xA3B96B16 + .word 0xA3CB6C18 + .word 0xA3DF5B16 + .word 0xA3F16D18 + .word 0xA4065C18 + .word 0xA41A6C18 + .word 0xA42E6A16 + .word 0xA43F5B16 + .word 0xA4516B16 + .word 0xA4638C18 + .word 0xA47D5B16 + .word 0xA48F5B16 + .word 0xA4A15B16 + .word 0xA4B32E16 + .word 0xA4BB3A16 + .word 0xA4C62E16 + .word 0xA4CE531A + .word 0xA4D470FC + .word 0xA4D65F1C + .word 0xA4EE4810 + .word 0xA4F75B16 + .word 0xA5095912 + .word 0xA5185B16 + .word 0xA52A5810 + .word 0xA5383C18 + .word 0xA5454B10 + .word 0xA5514B16 + .word 0xA55D2B16 + .word 0xA5632E16 + .word 0xA56B4B16 + .word 0xA5772B16 + .word 0xA57D6810 + .word 0xA58B4810 + .word 0xA5945912 + .word 0xA5A34B10 + .word 0xA5AF5B10 + .word 0xA5C13810 + .word 0xA5CA5912 + .word 0xA5D93A14 + .word 0xA5E44810 + .word 0xA5ED5810 + .word 0xA5FB6810 + .word 0xA6094810 + .word 0xA6125B10 + .word 0xA6245810 + .word 0xA6324E16 + .word 0xA6412E16 + .word 0xA6494E16 + .word 0xA6586116 + .word 0xA65B6C18 + .word 0xA66F5E16 + .word 0xA6862B10 + .word 0xA68C5C14 + .word 0xA6A04B16 + .word 0xA6AC5712 + .word 0xA6B84A16 + .word 0xA6C32B16 + .word 0xA6C94E16 + .word 0xA6D83116 + .word 0xA6DA7B16 + .word 0xA6F23618 + .word 0xA6F9650E + .word 0xA702440C + .word 0xA7076B16 + .word 0xA7197B16 + .word 0xA7317016 + .word 0xA7332218 + .word 0xA735570E + .word 0xA7415F1A + .word 0xA7595F1A + .word 0xA7712116 + .word 0xA7725B10 + .word 0xA7845E16 + .word 0xA79B230E + .word 0xA79D2300 + .word 0xA79F6D16 + .word 0xA7B43618 + .word 0xA7BB640C + .word 0xA7C38B16 + .word 0xA7DB7516 + .word 0xA7E78810 + .word 0xA7F95B10 + .word 0xA80B5E1C + .word 0xA8225E1C + .word 0xA8395E1C + .word 0xA8506E1C + .word 0xA8675D1A + .word 0xA87C5F1E + .word 0xA8948B16 + .word 0xA8AC6F18 + .word 0xA8C45F1E + .word 0xA8DC5E1C + .word 0xA8F35F1E + .word 0xA90B5D1A + .word 0xA9202E1C + .word 0xA9282E1C + .word 0xA9305F1E + .word 0xA9484D1A + .word 0xA9565F1C + .word 0xA96E6E1C + .word 0xA9857E1C + .word 0xA9A37E1C + .word 0xA9C17F1E + .word 0xA9E17E1C + .word 0xA9FF7D1A + .word 0xAA1B4810 + .word 0xAA246C18 + .word 0xAA386E1C + .word 0xAA4F6E1C + .word 0xAA666F1E + .word 0xAA7E6D1A + .word 0xAA936F1C + .word 0xAAAB5F1C + .word 0xAAC34B16 + .word 0xAACF5B16 + .word 0xAAE15B16 + .word 0xAAF35C18 + .word 0xAB076B16 + .word 0xAB194A14 + .word 0xAB245C18 + .word 0xAB387810 + .word 0xAB4A4B10 + .word 0xAB565B16 + .word 0xAB685B16 + .word 0xAB7A5C18 + .word 0xAB8E4A14 + .word 0xAB992B16 + .word 0xAB9F2B16 + .word 0xABA55B16 + .word 0xABB74A14 + .word 0xABC24B16 + .word 0xABCE6B16 + .word 0xABE05B16 + .word 0xABF25B16 + .word 0xAC045C18 + .word 0xAC186B16 + .word 0xAC2A4A14 + .word 0xAC35560E + .word 0xAC405810 + .word 0xAC4E5B16 + .word 0xAC604B16 + .word 0xAC6C5C18 + .word 0xAC804A14 + .word 0xAC8B5F1A + .word 0xACA36F1A + .word 0xACBB4D14 + .word 0xACC96F1A + .word 0xACE12C18 + .word 0xACE85318 + .word 0xACEE8C18 + .word 0xAD087E18 + .word 0xAD266B16 + .word 0xAD388C18 + .word 0xAD522318 + .word 0xAD543F18 + .word 0xAD643F18 + .word 0xAD745318 + .word 0xAD7A8710 + .word 0xAD8A2302 + .word 0xAD8C710A + .word 0xAD902102 + .word 0xAD915E1A + .word 0xADA85B16 + .word 0xADBA4B16 + .word 0xADC65B16 + .word 0xADD85B16 + .word 0xADEA7B16 + .word 0xAE025B16 + .word 0xAE145B16 + .word 0xAE267B16 + .word 0xAE3E5B16 + .word 0xAE505B16 + .word 0xAE622710 + .word 0xAE662910 + .word 0xAE6B7A12 + .word 0xAE81740C + .word 0xAE8B7A12 + .word 0xAEA16C18 + .word 0xAEB58C18 + .word 0xAECF7C18 + .word 0xAEE96C18 + .word 0xAEFD6C18 + .word 0xAF116C18 + .word 0xAF255C18 + .word 0xAF395C18 + .word 0xAF4D6C18 + .word 0xAF616C18 + .word 0xAF752C18 + .word 0xAF7C6C18 + .word 0xAF908C18 + .word 0xAFAA5C18 + .word 0xAFBE8C18 + .word 0xAFD87C18 + .word 0xAFF26C18 + .word 0xB0066C18 + .word 0xB01A7C18 + .word 0xB0346C18 + .word 0xB0486C18 + .word 0xB05C6C18 + .word 0xB0706C18 + .word 0xB0847C18 + .word 0xB09EAC18 + .word 0xB0BF8C18 + .word 0xB0D98C18 + .word 0xB0F36C18 + .word 0xB1073F1C + .word 0xB1175E1A + .word 0xB12E3F1C + .word 0xB13E5216 + .word 0xB14380FC + .word 0xB1455F1C + .word 0xB15D5912 + .word 0xB16C5C18 + .word 0xB1805810 + .word 0xB18E5C18 + .word 0xB1A25912 + .word 0xB1B14C18 + .word 0xB1BE5C12 + .word 0xB1D25C18 + .word 0xB1E62C18 + .word 0xB1ED4F18 + .word 0xB1FD6C18 + .word 0xB2112C18 + .word 0xB2187912 + .word 0xB22C5912 + .word 0xB23B5912 + .word 0xB24A5C12 + .word 0xB25E5C12 + .word 0xB2725912 + .word 0xB2815A14 + .word 0xB2924B16 + .word 0xB29E5810 + .word 0xB2AC7810 + .word 0xB2BE8810 + .word 0xB2D07810 + .word 0xB2E27A10 + .word 0xB2F85810 + .word 0xB3065E16 + .word 0xB31D1C18 + .word 0xB3245E16 + .word 0xB33B6116 + .word 0xB33E6C18 + .word 0xB3525E16 + .word 0xB3692B10 + .word 0xB36F6C14 + .word 0xB3837B16 + .word 0xB39B7914 + .word 0xB3AF8B16 + .word 0xB3C71C18 + .word 0xB3CE7D16 + .word 0xB3EA4016 + .word 0xB3EB7B16 + .word 0xB4033618 + .word 0xB40AA912 + .word 0xB423820C + .word 0xB4296B16 + .word 0xB43B7B16 + .word 0xB4538016 + .word 0xB4553218 + .word 0xB4588A14 + .word 0xB46E3418 + .word 0xB4733418 + .word 0xB4783118 + .word 0xB47A8A10 + .word 0xB4906E16 + .word 0xB4A7430E + .word 0xB4AB2302 + .word 0xB4AD3418 + .word 0xB4B23618 + .word 0xB4B9A912 + .word 0xB4D28B16 + .word 0xB4EA8216 + .word 0xB4F08910 + .word 0xB5046B10 + .word 0xB5167E1C + .word 0xB5347E1C + .word 0xB5527F1E + .word 0xB5727E1C + .word 0xB5907E1C + .word 0xB5AE7F1E + .word 0xB5CE8C18 + .word 0xB5E86E18 + .word 0xB5FF5F1E + .word 0xB6175F1E + .word 0xB62F5F1E + .word 0xB6475E1C + .word 0xB65E3F1E + .word 0xB66E3F1E + .word 0xB67E5F1E + .word 0xB6964E1C + .word 0xB6A57C18 + .word 0xB6BF7E1C + .word 0xB6DD6F1E + .word 0xB6F56F1E + .word 0xB70D6F1E + .word 0xB7256F1E + .word 0xB73D6E1C + .word 0xB7547812 + .word 0xB7668C18 + .word 0xB7806E1C + .word 0xB7976E1C + .word 0xB7AE6E1C + .word 0xB7C56D1A + .word 0xB7DA8D1A + .word 0xB7F68E1C + .word 0xB8146D1A + .word 0xB8295B16 + .word 0xB83B5B16 + .word 0xB84D5C18 + .word 0xB8616B16 + .word 0xB8735A14 + .word 0xB8845C18 + .word 0xB8988912 + .word 0xB8AC5D12 + .word 0xB8C15B16 + .word 0xB8D35B16 + .word 0xB8E55B16 + .word 0xB8F75A14 + .word 0xB9083B16 + .word 0xB9143B16 + .word 0xB9205B16 + .word 0xB9324A14 + .word 0xB93D5B16 + .word 0xB94F6B16 + .word 0xB9615B16 + .word 0xB9735B16 + .word 0xB9855C18 + .word 0xB9996B16 + .word 0xB9AB5A14 + .word 0xB9BC8710 + .word 0xB9CC7B14 + .word 0xB9E45B16 + .word 0xB9F65B16 + .word 0xBA085B16 + .word 0xBA1A5A14 + .word 0xBA2B7C16 + .word 0xBA455C16 + .word 0xBA597B14 + .word 0xBA716F18 + .word 0xBA893B16 + .word 0xBA956414 + .word 0xBA9D6912 + .word 0xBAAC6D16 + .word 0xBAC17B14 + .word 0xBAD97B14 + .word 0xBAF14414 + .word 0xBAF64D16 + .word 0xBB043D16 + .word 0xBB127912 + .word 0xBB266912 + .word 0xBB353302 + .word 0xBB39610A + .word 0xBB3C3202 + .word 0xBB3F8D16 + .word 0xBB5B6B16 + .word 0xBB6D5B16 + .word 0xBB7F7B16 + .word 0xBB976B16 + .word 0xBBA97B16 + .word 0xBBC17B16 + .word 0xBBD97B16 + .word 0xBBF16B16 + .word 0xBC037B16 + .word 0xBC1B7B16 + .word 0xBC333810 + .word 0xBC3C3910 + .word 0xBC467C18 + .word 0xBC60730E + .word 0xBC687C18 + .word 0xBC826B16 + .word 0xBC947B16 + .word 0xBCAC7B16 + .word 0xBCC47B16 + .word 0xBCDC6B16 + .word 0xBCEE7B16 + .word 0xBD067B16 + .word 0xBD1E7B16 + .word 0xBD367B16 + .word 0xBD4E8B16 + .word 0xBD665B16 + .word 0xBD786B16 + .word 0xBD8A8B16 + .word 0xBDA27B16 + .word 0xBDBA7B16 + .word 0xBDD27B16 + .word 0xBDEA6B16 + .word 0xBDFC8B16 + .word 0xBE147C16 + .word 0xBE2E7B16 + .word 0xBE466B16 + .word 0xBE587B16 + .word 0xBE707B16 + .word 0xBE887B16 + .word 0xBEA08B16 + .word 0xBEB87B16 + .word 0xBED07B16 + .word 0xBEE87B16 + .word 0xBF003D18 + .word 0xBF0E8D16 + .word 0xBF2A3D18 + .word 0xBF387114 + .word 0xBF3CA0FA + .word 0xBF3F6F1A + .word 0xBF577810 + .word 0xBF69AB16 + .word 0xBF878810 + .word 0xBF997B16 + .word 0xBFB17810 + .word 0xBFC36B16 + .word 0xBFD58910 + .word 0xBFE97B16 + .word 0xC0015B16 + .word 0xC0134C16 + .word 0xC0208B16 + .word 0xC0384B16 + .word 0xC0447810 + .word 0xC0567810 + .word 0xC0686810 + .word 0xC0767910 + .word 0xC08A7910 + .word 0xC09E6810 + .word 0xC0AC6810 + .word 0xC0BA5A14 + .word 0xC0CB7810 + .word 0xC0DD7810 + .word 0xC0EF8810 + .word 0xC1018810 + .word 0xC1137910 + .word 0xC1276810 + .word 0xC1354D18 + .word 0xC1432D18 + .word 0xC14A4D18 + .word 0xC1585116 + .word 0xC15B6F1C + .word 0xC2276F16 + .word 0xC23F6F16 + .word 0xC1738A16 + .word 0xC189AB16 + .word 0xC2576F16 + .word 0xC1A7C914 + .word 0xC1C52D16 + .word 0xC1CC6A16 + .word 0xC1DD6116 + .word 0xC26F6F16 + .word 0xC2876F16 + .word 0xC1E07D18 + .word 0xC1FCC40C + .word 0xC20B7D18 + .word 0xC29F6F16 + .word 0xC2B76F16 + .word 0xC2CF4318 + .word 0xC2D3A914 + .word 0xC2ECA912 + .word 0xC305AB16 + .word 0xC4126F18 + .word 0xC323A910 + .word 0xC33C8914 + .word 0xC350430E + .word 0xC3543404 + .word 0xC359DB14 + .word 0xC383A016 + .word 0xC386DB16 + .word 0xC3B0ED18 + .word 0xC3E1ED18 + .word 0xC42A6F18 + .word 0xC4426F18 + .word 0xC45AA20E + .word 0xC4624306 + .word 0xC4666D18 + .word 0xC47BA810 + .word 0xC4925A18 + .word 0xC4A35A12 + .word 0xC4B46A18 + .word 0xC4C57A12 + .word 0xC4DB5D18 + .word 0xC4F05D18 + .word 0xC5055D18 + .word 0xC51A6D18 + .word 0xC52FD914 + .word 0xC552D914 + .word 0xC575B914 + .word 0xC593E510 + .word 0xC5A8F50E + .word 0xC5C07D16 + .word 0xC5DC6D16 + .word 0xC5F1EB14 + .word 0xC61BEB14 + .word 0xC645D912 + .word 0xC668D912 + .word 0xC68BAD16 + .word 0xC6AEAD16 + .word 0xC6D1FA14 + .word 0xC6FD9C16 + .word 0xC71E6F16 + .word 0xC7366F16 + .word 0xC74E6F16 + .word 0xC7666F16 + .word 0xC77E6F16 + .word 0xC796E612 + .word 0xC7AFA810 + .word 0xC7C65118 + .word 0xC7C96318 + .word 0xC7CF3418 + .word 0xC7D44810 + .word 0xC7DDD30E + .word 0xC7EBA30E + .word 0xC7F55D18 + .word 0xC80AC20E + .word 0xC8138B16 + .word 0xC82BB912 + .word 0xC8496F1A + .word 0xC8616F1A + .word 0xC8796F1A + .word 0xC8916F1A + .word 0xC8A90F17 + .word 0xC8E9960E + .word 0xC8FB7810 + .word 0xC90D960E + .word 0xC91F7810 + .word 0xC9319E14 + .word 0xC957F810 + .word 0xC97B9E16 + .word 0xC9A1F810 + .word 0xC9C5CC14 + .word 0xC9ECDC16 + .word 0xCA1ADC14 + .word 0xCA48DC14 + .word 0xCA76EF16 + .word 0xCAAE070F + .word 0xCACE070F + .word 0xCAEE8F16 + .word 0xCB0EED14 + .word 0xCB3FED14 + .word 0xCB70ED14 + .word 0xCBA1EF16 + .word 0xCBD9CB12 + .word 0xCBFDCB12 + .word 0xCC21CB12 +ENDDATA(D_801D04A0) diff --git a/src/libleo/api/getkadr.s b/src/libleo/api/getkadr.s index d71719525a2..85169a26f97 100644 --- a/src/libleo/api/getkadr.s +++ b/src/libleo/api/getkadr.s @@ -3,210 +3,703 @@ .text -/** - * int LeoGetKAdr(int sjis); - * - * Returns the storage offset address into the N64 Disk Drive mask ROM for - * a kanji character corresponding to a given 2-byte Shift-JIS codepoint. - * An error value -1 will be returned if `sjis` is outside the range 0x8140 to 0x9872. - * - * A nice Shift-JIS codepoint table: https://uic.io/en/charset/show/shift_jis/ - * The Mask ROM contains the 'Level 1' kanji (0x889F-0x9872), and a reworked - * version of the non-kanji section that includes extra English and Hylian glyphs. - * - * @param sjis Shift-JIS Codepoint of glyph. - * @return int Storage offset address into the N64 Disk Drive mask ROM. - */ LEAF(LeoGetKAdr) - /* Check if the codepoint is in the range 0x8140 to 0x9872. */ - blt a0, 0x8140, .out_of_range - bge a0, 0x9873, .out_of_range - /* Characters with codepoints >= 0x8800 are kanji. Arrangement is regular, - * so convert index directly. */ + blt a0, 0x8140, .L801CF9E0 + bge a0, 0x9873, .L801CF9E0 li a2, 0xBC - blt a0, 0x8800, .nonkanji - /* 0xBC is number of glyphs in one block in the `kanji` file: - * 0x100 possible codepoints with the same byte1 - * - 0x40 unused at beginning - * - 1 unused at 0x7F - * - 3 unused at 0xFD, 0xFE, 0xFF */ - /* Get byte1 and adjust so starts at 0 */ + blt a0, 0x8800, .L801CF994 srl a1, a0, 8 addi a1, a1, -0x88 mul a2, a2, a1 - /* Get byte2 and adjust so starts at 0 */ andi a3, a0, 0xFF addi a3, a3, -0x40 - /* 0x__7F is always empty and elided in the file, so decrement if larger */ - blt a3, 0x40, .kanji_lower_halfblock + blt a3, 0x40, .L801CF984 addi a3, a3, -1 -.kanji_lower_halfblock: + .L801CF984: mflo a2 addi a3, a3, 0x30A add a3, a3, a2 - sll v0, a3, 7 + sll v0, a3, 7 jr ra - /* returns (0x30A + (adjusted byte2) + (adjusted byte1) * 0xBC) * FONT_CHAR_TEX_SIZE */ - -/* Non-kanji are arranged with irregular gaps, use the lookup table. */ -.nonkanji: - /* Get byte1 and adjust so starts at 0 */ + .L801CF994: srl a1, a0, 8 addi a1, a1, -0x81 mul a2, a2, a1 - /* Get byte2 and adjust so starts at 0 */ andi a3, a0, 0xFF addi a3, a3, -0x40 - /* 0x__7F is always empty and elided in the file, so decrement if larger */ - blt a3, 0x40, .nonkanji_lower_halfblock + blt a3, 0x40, .L801CF9C0 addi a3, a3, -1 -.nonkanji_lower_halfblock: + .L801CF9C0: mflo a2 add a3, a3, a2 sll a3, a3, 1 - la a2, kantbl + la a2, D_801CF9E8 add a3, a3, a2 lh a2, (a3) sll v0, a2, 7 jr ra - /* returns kantbl[(adjusted byte2) + (adjusted byte1) * 0xBC] * FONT_CHAR_TEX_SIZE */ -.out_of_range: + .L801CF9E0: li v0, -1 jr ra END(LeoGetKAdr) -/** - * Nearly equivalent C code (Equivalent for all valid input, will behave differently on overflow due to the use of `add` in the original): - * - * extern u16 kantbl[]; - * - * int LeoGetKAdr(int sjis) { - * u32 byte1; - * u32 byte2; - * - * if (sjis < 0x8140 || sjis > 0x9872) { - * return -1; - * } - * - * byte1 = (u32)sjis >> 8; - * byte2 = sjis & 0xFF; - * - * byte2 -= 0x40; - * if (byte2 >= 0x40) { - * byte2--; - * } - * - * if (sjis >= 0x8800) { - * byte1 -= 0x88; - * return (0x30A + byte2 + byte1 * 0xBC) * FONT_CHAR_TEX_SIZE; - * } else { - * byte1 -= 0x81; - * return kantbl[byte2 + byte1 * 0xBC] * FONT_CHAR_TEX_SIZE; - * } - * } - */ - -/** - * Index table, formatting follows conventional Shift-JIS character table layout, - * with space for the missing 0x__7F,0x__FD,0x__FE,0x__FF entries, and split - * into blocks by high byte. - */ -DATA(kantbl) -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x814_ */ .half 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F -/* 0x815_ */ .half 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F -/* 0x816_ */ .half 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F -/* 0x817_ */ .half 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E -/* 0x818_ */ .half 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E -/* 0x819_ */ .half 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E -/* 0x81A_ */ .half 0x005F, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x0000, 0x0000, 0x0000 -/* 0x81B_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073 -/* 0x81C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0000 -/* 0x81D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F -/* 0x81E_ */ .half 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x81F_ */ .half 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0000, 0x0000, 0x0000, 0x0000, 0x0091 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x824_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0092 -/* 0x825_ */ .half 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x826_ */ .half 0x009C, 0x009D, 0x009E, 0x009F, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB -/* 0x827_ */ .half 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x828_ */ .half 0x0000, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4 -/* 0x829_ */ .half 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0000, 0x0000, 0x0000, 0x0000, 0x00D0 -/* 0x82A_ */ .half 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0 -/* 0x82B_ */ .half 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0 -/* 0x82C_ */ .half 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100 -/* 0x82D_ */ .half 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0109, 0x010A, 0x010B, 0x010C, 0x010D, 0x010E, 0x010F, 0x0110 -/* 0x82E_ */ .half 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x0119, 0x011A, 0x011B, 0x011C, 0x011D, 0x011E, 0x011F, 0x0120 -/* 0x82F_ */ .half 0x0121, 0x0122, 0x0123, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x834_ */ .half 0x0124, 0x0125, 0x0126, 0x0127, 0x0128, 0x0129, 0x012A, 0x012B, 0x012C, 0x012D, 0x012E, 0x012F, 0x0130, 0x0131, 0x0132, 0x0133 -/* 0x835_ */ .half 0x0134, 0x0135, 0x0136, 0x0137, 0x0138, 0x0139, 0x013A, 0x013B, 0x013C, 0x013D, 0x013E, 0x013F, 0x0140, 0x0141, 0x0142, 0x0143 -/* 0x836_ */ .half 0x0144, 0x0145, 0x0146, 0x0147, 0x0148, 0x0149, 0x014A, 0x014B, 0x014C, 0x014D, 0x014E, 0x014F, 0x0150, 0x0151, 0x0152, 0x0153 -/* 0x837_ */ .half 0x0154, 0x0155, 0x0156, 0x0157, 0x0158, 0x0159, 0x015A, 0x015B, 0x015C, 0x015D, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162 -/* 0x838_ */ .half 0x0163, 0x0164, 0x0165, 0x0166, 0x0167, 0x0168, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F, 0x0170, 0x0171, 0x0172 -/* 0x839_ */ .half 0x0173, 0x0174, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x017A -/* 0x83A_ */ .half 0x017B, 0x017C, 0x017D, 0x017E, 0x017F, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018A -/* 0x83B_ */ .half 0x018B, 0x018C, 0x018D, 0x018E, 0x018F, 0x0190, 0x0191, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192 -/* 0x83C_ */ .half 0x0193, 0x0194, 0x0195, 0x0196, 0x0197, 0x0198, 0x0199, 0x019A, 0x019B, 0x019C, 0x019D, 0x019E, 0x019F, 0x01A0, 0x01A1, 0x01A2 -/* 0x83D_ */ .half 0x01A3, 0x01A4, 0x01A5, 0x01A6, 0x01A7, 0x01A8, 0x01A9, 0x01AA, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x83E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x83F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x844_ */ .half 0x01AB, 0x01AC, 0x01AD, 0x01AE, 0x01AF, 0x01B0, 0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0x01B7, 0x01B8, 0x01B9, 0x01BA -/* 0x845_ */ .half 0x01BB, 0x01BC, 0x01BD, 0x01BE, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C4, 0x01C5, 0x01C6, 0x01C7, 0x01C8, 0x01C9, 0x01CA -/* 0x846_ */ .half 0x01CB, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x847_ */ .half 0x01CC, 0x01CD, 0x01CE, 0x01CF, 0x01D0, 0x01D1, 0x01D2, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7, 0x01D8, 0x01D9, 0x01DA -/* 0x848_ */ .half 0x01DB, 0x01DC, 0x01DD, 0x01DE, 0x01DF, 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E4, 0x01E5, 0x01E6, 0x01E7, 0x01E8, 0x01E9, 0x01EA -/* 0x849_ */ .half 0x01EB, 0x01EC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x01ED -/* 0x84A_ */ .half 0x01EE, 0x01EF, 0x01F0, 0x01F1, 0x01F2, 0x01F3, 0x01F4, 0x01F5, 0x01F6, 0x01F7, 0x01F8, 0x01F9, 0x01FA, 0x01FB, 0x01FC, 0x01FD -/* 0x84B_ */ .half 0x01FE, 0x01FF, 0x0200, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x020B, 0x020C, 0x020D -/* 0x84C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x84F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x854_ */ .half 0x020E, 0x020F, 0x0210, 0x0211, 0x0212, 0x0213, 0x0214, 0x0215, 0x0216, 0x0217, 0x0218, 0x0219, 0x021A, 0x021B, 0x021C, 0x021D -/* 0x855_ */ .half 0x021E, 0x021F, 0x0220, 0x0221, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0222, 0x0223 -/* 0x856_ */ .half 0x0224, 0x0225, 0x0226, 0x0227, 0x0228, 0x0229, 0x022A, 0x022B, 0x022C, 0x022D, 0x022E, 0x022F, 0x0230, 0x0231, 0x0232, 0x0233 -/* 0x857_ */ .half 0x0234, 0x0235, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0236, 0x0237, 0x0238 -/* 0x858_ */ .half 0x0239, 0x023A, 0x023B, 0x023C, 0x023D, 0x023E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x859_ */ .half 0x0000, 0x023F, 0x0240, 0x0241, 0x0242, 0x0243, 0x0244, 0x0245, 0x0246, 0x0247, 0x0248, 0x0000, 0x0000, 0x0000, 0x0000, 0x0249 -/* 0x85A_ */ .half 0x024A, 0x024B, 0x024C, 0x024D, 0x024E, 0x024F, 0x0250, 0x0251, 0x0252, 0x0253, 0x0254, 0x0255, 0x0256, 0x0257, 0x0000, 0x0000 -/* 0x85B_ */ .half 0x0000, 0x0000, 0x0000, 0x0258, 0x0259, 0x025A, 0x025B, 0x025C, 0x025D, 0x025E, 0x025F, 0x0260, 0x0261, 0x0262, 0x0263, 0x0264 -/* 0x85C_ */ .half 0x0265, 0x0266, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x85D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0267, 0x0268, 0x0269, 0x026A, 0x026B -/* 0x85E_ */ .half 0x026C, 0x026D, 0x026E, 0x026F, 0x0270, 0x0271, 0x0272, 0x0273, 0x0274, 0x0275, 0x0276, 0x0277, 0x0278, 0x0279, 0x027A, 0x027B -/* 0x85F_ */ .half 0x027C, 0x027D, 0x027E, 0x027F, 0x0280, 0x0281, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x864_ */ .half 0x0282, 0x0283, 0x0284, 0x0285, 0x0286, 0x0287, 0x0288, 0x0289, 0x028A, 0x028B, 0x028C, 0x028D, 0x028E, 0x028F, 0x0290, 0x0291 -/* 0x865_ */ .half 0x0292, 0x0293, 0x0294, 0x0295, 0x0296, 0x0297, 0x0298, 0x0299, 0x029A, 0x029B, 0x029C, 0x029D, 0x029E, 0x029F, 0x0000, 0x0000 -/* 0x866_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x867_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x868_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x869_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02A0, 0x02A1, 0x02A2, 0x02A3, 0x02A4 -/* 0x86A_ */ .half 0x02A5, 0x02A6, 0x02A7, 0x02A8, 0x02A9, 0x02AA, 0x02AB, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86B_ */ .half 0x0000, 0x0000, 0x0000, 0x02AC, 0x02AD, 0x02AE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86C_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02AF, 0x02B0, 0x02B1, 0x02B2, 0x02B3, 0x02B4, 0x02B5, 0x02B6, 0x02B7 -/* 0x86D_ */ .half 0x02B8, 0x02B9, 0x02BA, 0x02BB, 0x02BC, 0x02BD, 0x02BE, 0x02BF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x86F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 - -/* 0x___0 0x___1 0x___2 0x___3 0x___4 0x___5 0x___6 0x___7 0x___8 0x___9 0x___A 0x___B 0x___C 0x___D 0x___E 0x___F */ -/* 0x874_ */ .half 0x02C0, 0x02C1, 0x02C2, 0x02C3, 0x02C4, 0x02C5, 0x02C6, 0x02C7, 0x02C8, 0x02C9, 0x02CA, 0x02CB, 0x02CC, 0x02CD, 0x02CE, 0x02CF -/* 0x875_ */ .half 0x02D0, 0x02D1, 0x02D2, 0x02D3, 0x02D4, 0x02D5, 0x02D6, 0x02D7, 0x02D8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x876_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x877_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x878_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x879_ */ .half 0x0000, 0x02D9, 0x02DA, 0x02DB, 0x02DC, 0x02DD, 0x02DE, 0x02DF, 0x02E0, 0x02E1, 0x02E2, 0x02E3, 0x02E4, 0x02E5, 0x02E6, 0x02E7 -/* 0x87A_ */ .half 0x02E8, 0x02E9, 0x02EA, 0x02EB, 0x02EC, 0x02ED, 0x02EE, 0x02EF, 0x02F0, 0x02F1, 0x02F2, 0x02F3, 0x02F4, 0x02F5, 0x02F6, 0x02F7 -/* 0x87B_ */ .half 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC, 0x02FD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02FE, 0x02FF, 0x0300 -/* 0x87C_ */ .half 0x0301, 0x0302, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87D_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87E_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0303, 0x0304, 0x0305, 0x0306, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 -/* 0x87F_ */ .half 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0307, 0x0308, 0x0309 -ENDDATA(kantbl) +DATA(D_801CF9E8) + .word 0x00000001 + .word 0x00020003 + .word 0x00040005 + .word 0x00060007 + .word 0x00080009 + .word 0x000A000B + .word 0x000C000D + .word 0x000E000F + .word 0x00100011 + .word 0x00120013 + .word 0x00140015 + .word 0x00160017 + .word 0x00180019 + .word 0x001A001B + .word 0x001C001D + .word 0x001E001F + .word 0x00200021 + .word 0x00220023 + .word 0x00240025 + .word 0x00260027 + .word 0x00280029 + .word 0x002A002B + .word 0x002C002D + .word 0x002E002F + .word 0x00300031 + .word 0x00320033 + .word 0x00340035 + .word 0x00360037 + .word 0x00380039 + .word 0x003A003B + .word 0x003C003D + .word 0x003E003F + .word 0x00400041 + .word 0x00420043 + .word 0x00440045 + .word 0x00460047 + .word 0x00480049 + .word 0x004A004B + .word 0x004C004D + .word 0x004E004F + .word 0x00500051 + .word 0x00520053 + .word 0x00540055 + .word 0x00560057 + .word 0x00580059 + .word 0x005A005B + .word 0x005C005D + .word 0x005E005F + .word 0x00600061 + .word 0x00620063 + .word 0x00640065 + .word 0x00660067 + .word 0x00680069 + .word 0x006A006B + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x0000006C + .word 0x006D006E + .word 0x006F0070 + .word 0x00710072 + .word 0x00730000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000074 + .word 0x00750076 + .word 0x00770078 + .word 0x0079007A + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x007B007C + .word 0x007D007E + .word 0x007F0080 + .word 0x00810082 + .word 0x00830084 + .word 0x00850086 + .word 0x00870088 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000089 + .word 0x008A008B + .word 0x008C008D + .word 0x008E008F + .word 0x00900000 + .word 0x00000000 + .word 0x00000091 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000092 + .word 0x00930094 + .word 0x00950096 + .word 0x00970098 + .word 0x0099009A + .word 0x009B0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x009C009D + .word 0x009E009F + .word 0x00A000A1 + .word 0x00A200A3 + .word 0x00A400A5 + .word 0x00A600A7 + .word 0x00A800A9 + .word 0x00AA00AB + .word 0x00AC00AD + .word 0x00AE00AF + .word 0x00B000B1 + .word 0x00B200B3 + .word 0x00B400B5 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00B600B7 + .word 0x00B800B9 + .word 0x00BA00BB + .word 0x00BC00BD + .word 0x00BE00BF + .word 0x00C000C1 + .word 0x00C200C3 + .word 0x00C400C5 + .word 0x00C600C7 + .word 0x00C800C9 + .word 0x00CA00CB + .word 0x00CC00CD + .word 0x00CE00CF + .word 0x00000000 + .word 0x00000000 + .word 0x00D000D1 + .word 0x00D200D3 + .word 0x00D400D5 + .word 0x00D600D7 + .word 0x00D800D9 + .word 0x00DA00DB + .word 0x00DC00DD + .word 0x00DE00DF + .word 0x00E000E1 + .word 0x00E200E3 + .word 0x00E400E5 + .word 0x00E600E7 + .word 0x00E800E9 + .word 0x00EA00EB + .word 0x00EC00ED + .word 0x00EE00EF + .word 0x00F000F1 + .word 0x00F200F3 + .word 0x00F400F5 + .word 0x00F600F7 + .word 0x00F800F9 + .word 0x00FA00FB + .word 0x00FC00FD + .word 0x00FE00FF + .word 0x01000101 + .word 0x01020103 + .word 0x01040105 + .word 0x01060107 + .word 0x01080109 + .word 0x010A010B + .word 0x010C010D + .word 0x010E010F + .word 0x01100111 + .word 0x01120113 + .word 0x01140115 + .word 0x01160117 + .word 0x01180119 + .word 0x011A011B + .word 0x011C011D + .word 0x011E011F + .word 0x01200121 + .word 0x01220123 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01240125 + .word 0x01260127 + .word 0x01280129 + .word 0x012A012B + .word 0x012C012D + .word 0x012E012F + .word 0x01300131 + .word 0x01320133 + .word 0x01340135 + .word 0x01360137 + .word 0x01380139 + .word 0x013A013B + .word 0x013C013D + .word 0x013E013F + .word 0x01400141 + .word 0x01420143 + .word 0x01440145 + .word 0x01460147 + .word 0x01480149 + .word 0x014A014B + .word 0x014C014D + .word 0x014E014F + .word 0x01500151 + .word 0x01520153 + .word 0x01540155 + .word 0x01560157 + .word 0x01580159 + .word 0x015A015B + .word 0x015C015D + .word 0x015E015F + .word 0x01600161 + .word 0x01620163 + .word 0x01640165 + .word 0x01660167 + .word 0x01680169 + .word 0x016A016B + .word 0x016C016D + .word 0x016E016F + .word 0x01700171 + .word 0x01720173 + .word 0x01740175 + .word 0x01760177 + .word 0x01780179 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x017A017B + .word 0x017C017D + .word 0x017E017F + .word 0x01800181 + .word 0x01820183 + .word 0x01840185 + .word 0x01860187 + .word 0x01880189 + .word 0x018A018B + .word 0x018C018D + .word 0x018E018F + .word 0x01900191 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01920193 + .word 0x01940195 + .word 0x01960197 + .word 0x01980199 + .word 0x019A019B + .word 0x019C019D + .word 0x019E019F + .word 0x01A001A1 + .word 0x01A201A3 + .word 0x01A401A5 + .word 0x01A601A7 + .word 0x01A801A9 + .word 0x01AA0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01AB01AC + .word 0x01AD01AE + .word 0x01AF01B0 + .word 0x01B101B2 + .word 0x01B301B4 + .word 0x01B501B6 + .word 0x01B701B8 + .word 0x01B901BA + .word 0x01BB01BC + .word 0x01BD01BE + .word 0x01BF01C0 + .word 0x01C101C2 + .word 0x01C301C4 + .word 0x01C501C6 + .word 0x01C701C8 + .word 0x01C901CA + .word 0x01CB0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01CC01CD + .word 0x01CE01CF + .word 0x01D001D1 + .word 0x01D201D3 + .word 0x01D401D5 + .word 0x01D601D7 + .word 0x01D801D9 + .word 0x01DA01DB + .word 0x01DC01DD + .word 0x01DE01DF + .word 0x01E001E1 + .word 0x01E201E3 + .word 0x01E401E5 + .word 0x01E601E7 + .word 0x01E801E9 + .word 0x01EA01EB + .word 0x01EC0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x01ED01EE + .word 0x01EF01F0 + .word 0x01F101F2 + .word 0x01F301F4 + .word 0x01F501F6 + .word 0x01F701F8 + .word 0x01F901FA + .word 0x01FB01FC + .word 0x01FD01FE + .word 0x01FF0200 + .word 0x02010202 + .word 0x02030204 + .word 0x02050206 + .word 0x02070208 + .word 0x0209020A + .word 0x020B020C + .word 0x020D0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x020E020F + .word 0x02100211 + .word 0x02120213 + .word 0x02140215 + .word 0x02160217 + .word 0x02180219 + .word 0x021A021B + .word 0x021C021D + .word 0x021E021F + .word 0x02200221 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02220223 + .word 0x02240225 + .word 0x02260227 + .word 0x02280229 + .word 0x022A022B + .word 0x022C022D + .word 0x022E022F + .word 0x02300231 + .word 0x02320233 + .word 0x02340235 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02360237 + .word 0x02380239 + .word 0x023A023B + .word 0x023C023D + .word 0x023E0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x023F0240 + .word 0x02410242 + .word 0x02430244 + .word 0x02450246 + .word 0x02470248 + .word 0x00000000 + .word 0x00000000 + .word 0x0249024A + .word 0x024B024C + .word 0x024D024E + .word 0x024F0250 + .word 0x02510252 + .word 0x02530254 + .word 0x02550256 + .word 0x02570000 + .word 0x00000000 + .word 0x00000000 + .word 0x02580259 + .word 0x025A025B + .word 0x025C025D + .word 0x025E025F + .word 0x02600261 + .word 0x02620263 + .word 0x02640265 + .word 0x02660000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02670268 + .word 0x0269026A + .word 0x026B026C + .word 0x026D026E + .word 0x026F0270 + .word 0x02710272 + .word 0x02730274 + .word 0x02750276 + .word 0x02770278 + .word 0x0279027A + .word 0x027B027C + .word 0x027D027E + .word 0x027F0280 + .word 0x02810000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02820283 + .word 0x02840285 + .word 0x02860287 + .word 0x02880289 + .word 0x028A028B + .word 0x028C028D + .word 0x028E028F + .word 0x02900291 + .word 0x02920293 + .word 0x02940295 + .word 0x02960297 + .word 0x02980299 + .word 0x029A029B + .word 0x029C029D + .word 0x029E029F + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02A002A1 + .word 0x02A202A3 + .word 0x02A402A5 + .word 0x02A602A7 + .word 0x02A802A9 + .word 0x02AA02AB + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02AC02AD + .word 0x02AE0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02AF02B0 + .word 0x02B102B2 + .word 0x02B302B4 + .word 0x02B502B6 + .word 0x02B702B8 + .word 0x02B902BA + .word 0x02BB02BC + .word 0x02BD02BE + .word 0x02BF0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02C002C1 + .word 0x02C202C3 + .word 0x02C402C5 + .word 0x02C602C7 + .word 0x02C802C9 + .word 0x02CA02CB + .word 0x02CC02CD + .word 0x02CE02CF + .word 0x02D002D1 + .word 0x02D202D3 + .word 0x02D402D5 + .word 0x02D602D7 + .word 0x02D80000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02D902DA + .word 0x02DB02DC + .word 0x02DD02DE + .word 0x02DF02E0 + .word 0x02E102E2 + .word 0x02E302E4 + .word 0x02E502E6 + .word 0x02E702E8 + .word 0x02E902EA + .word 0x02EB02EC + .word 0x02ED02EE + .word 0x02EF02F0 + .word 0x02F102F2 + .word 0x02F302F4 + .word 0x02F502F6 + .word 0x02F702F8 + .word 0x02F902FA + .word 0x02FB02FC + .word 0x02FD0000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x02FE02FF + .word 0x03000301 + .word 0x03020000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x03030304 + .word 0x03050306 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000307 + .word 0x03080309 +ENDDATA(D_801CF9E8) diff --git a/src/libleo/api/lbatobyte.c b/src/libleo/api/lbatobyte.c index e260fced18c..e705b46dc3c 100644 --- a/src/libleo/api/lbatobyte.c +++ b/src/libleo/api/lbatobyte.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes) { u32 resbytes; diff --git a/src/libleo/leo/leodiskinit.c b/src/libleo/api/leodiskinit.c similarity index 73% rename from src/libleo/leo/leodiskinit.c rename to src/libleo/api/leodiskinit.c index 92020029eaf..733857a6e94 100644 --- a/src/libleo/leo/leodiskinit.c +++ b/src/libleo/api/leodiskinit.c @@ -1,10 +1,7 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" -extern OSPiHandle* __osPiTable; - OSPiHandle __LeoDiskHandle; OSPiHandle* __osDiskHandle; @@ -12,22 +9,18 @@ OSPiHandle* osLeoDiskInit(void) { u32 saveMask; __LeoDiskHandle.type = DEVICE_TYPE_64DD; - __LeoDiskHandle.baseAddress = (u32)OS_PHYSICAL_TO_K1(ASIC_C2_BUFF); + __LeoDiskHandle.baseAddress = PHYS_TO_K1(ASIC_BASE); __LeoDiskHandle.latency = 3; __LeoDiskHandle.pulse = 6; __LeoDiskHandle.pageSize = 6; __LeoDiskHandle.relDuration = 2; __LeoDiskHandle.domain = PI_DOMAIN2; __LeoDiskHandle.speed = 0; - - bzero(&__LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo)); + bzero(&__LeoDiskHandle.transferInfo, sizeof(__LeoDiskHandle.transferInfo)); saveMask = __osDisableInt(); - __LeoDiskHandle.next = __osPiTable; __osPiTable = &__LeoDiskHandle; __osDiskHandle = &__LeoDiskHandle; - __osRestoreInt(saveMask); - return &__LeoDiskHandle; } diff --git a/src/libleo/api/leoglobals.c b/src/libleo/api/leoglobals.c new file mode 100644 index 00000000000..377c6e87590 --- /dev/null +++ b/src/libleo/api/leoglobals.c @@ -0,0 +1,5 @@ +#include "ultra64.h" +#include "ultra64/leo_internal.h" + +s32 __leoActive = 0; +LEOVersion __leoVersion; diff --git a/src/libleo/api/leointerrupt.c b/src/libleo/api/leointerrupt.c new file mode 100644 index 00000000000..74c1a6ae61a --- /dev/null +++ b/src/libleo/api/leointerrupt.c @@ -0,0 +1,194 @@ +#include "ultra64.h" +#include "ultra64/leo_internal.h" +#include "ultra64/leodrive.h" +#include "ultra64/internal.h" +#include "ultra64/pi.h" + +void __osLeoAbnormalResume(void); +void __osLeoResume(void); + +STACK(leoDiskStack, 0x1000); + +s32 __osLeoInterrupt(void) { + u32 stat; + volatile u32 pi_stat; + u32 bm_stat; + __OSTranxInfo* info; + __OSBlockInfo* blockInfo; + + info = &__osDiskHandle->transferInfo; + blockInfo = &info->block[info->blockNum]; + pi_stat = IO_READ(PI_STATUS_REG); + if (pi_stat & PI_STATUS_DMA_BUSY) { + __OSGlobalIntMask &= ~(OS_IM_CART & ~OS_IM_RCP); + blockInfo->errStatus = 29; + __osLeoResume(); + return 1; + } + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + stat = IO_READ(ASIC_STATUS); + if (stat & LEO_STATUS_MECHANIC_INTR) { + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | LEO_BM_CLR_MECHANIC_INTR); + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + return 0; + } + if (info->cmdType == 2) { + return 1; + } + if (stat & 0x08000000) { + pi_stat = IO_READ(PI_STATUS_REG); + while ((pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) { + pi_stat = IO_READ(PI_STATUS_REG); + } + IO_READ(ASIC_STATUS); + blockInfo->errStatus = LEO_SENSE_WRITE_FAULT; + __osLeoResume(); + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + return 1; + } + if (info->cmdType == 1) { + if (!(stat & 0x40000000)) { + if ((info->sectorNum + 1) != (info->transferMode * 0x55)) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + } else { + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoResume(); + } + } else { + blockInfo->dramAddr = (u8*)blockInfo->dramAddr + blockInfo->sectorSize; + info->sectorNum += 1; + __osEPiRawStartDma(__osDiskHandle, OS_WRITE, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); + } + return 1; + } + if (info->cmdType == 0) { + if (info->transferMode == 3) { + if ((s32)(blockInfo->C1ErrNum + 0x11) < info->sectorNum) { + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoAbnormalResume(); + return 1; + } + if (!(stat & 0x40000000)) { + blockInfo->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } else { + blockInfo->dramAddr = (u8*)blockInfo->dramAddr + blockInfo->sectorSize; + } + bm_stat = IO_READ(ASIC_BM_STATUS); + if (((bm_stat & 0x00200000) && (bm_stat & 0x00400000)) || (bm_stat & 0x02000000)) { + if (blockInfo->C1ErrNum >= 4) { + if ((info->transferMode != 3) || (info->sectorNum >= 0x53)) { + blockInfo->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } else { + int errNum; + + errNum = blockInfo->C1ErrNum; + blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; + } + blockInfo->C1ErrNum += 1; + } + if (stat & 0x10000000) { + if (info->sectorNum != 0x57) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + } else { + if ((info->transferMode == 2) && (info->blockNum == 0)) { + info->blockNum = 1; + info->sectorNum = -1; + info->block[1].dramAddr = (u8*)info->block[1].dramAddr - info->block[1].sectorSize; + blockInfo->errStatus = LEO_SENSE_WRITE_FAULT; + } else { + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; + info->cmdType = 2; + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + } + __osEPiRawStartDma(__osDiskHandle, OS_READ, ASIC_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4); + } + return 1; + } + if ((info->sectorNum == -1) && (info->transferMode == 2) && (info->blockNum == 1)) { + __OSBlockInfo* bptr = info->block; + + if (info->block[0].C1ErrNum == 0) { + if ((((u32*)bptr->C2Addr)[0] | ((u32*)bptr->C2Addr)[1] | ((u32*)bptr->C2Addr)[2] | + ((u32*)bptr->C2Addr)[3]) != 0) { + bptr->errStatus = LEO_SENSE_UNRECOVERED_READ_ERROR; + __osLeoAbnormalResume(); + return 1; + } + } + info->block[0].errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + __osLeoResume(); + } + info->sectorNum += 1; + if (stat & 0x40000000) { + if (info->sectorNum >= 0x55) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + return 1; + } + __osEPiRawStartDma(__osDiskHandle, OS_READ, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); + blockInfo->errStatus = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + return 1; + } + if (info->sectorNum < 0x55) { + blockInfo->errStatus = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; + __osLeoAbnormalResume(); + return 1; + } + return 1; + } + blockInfo->errStatus = LEO_SENSE_DATA_PHASE_ERROR; + __osLeoAbnormalResume(); + return 1; +} + +void __osLeoAbnormalResume(void) { + __OSTranxInfo* info; + u32 pi_stat; + + info = &__osDiskHandle->transferInfo; + while (((pi_stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | LEO_BM_RESET); + while (((pi_stat = IO_READ(PI_STATUS_REG)) & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) != 0) {} + IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow); + __osLeoResume(); + IO_WRITE(PI_STATUS_REG, PI_STATUS_CLR_INTR); + __OSGlobalIntMask |= OS_IM_PI; +} + +void __osLeoResume(void) { + __OSEventState* es; + OSMesgQueue* mq; + s32 last; + + es = &__osEventStateTab[OS_EVENT_PI]; + mq = es->queue; + if (mq != NULL) { + if (mq->validCount < mq->msgCount) { + last = (mq->first + mq->validCount) % mq->msgCount; + mq->msg[last] = es->msg; + mq->validCount++; + if (mq->mtqueue->next != NULL) { + __osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue)); + } + } + } +} diff --git a/src/libleo/api/seek.c b/src/libleo/api/readdiskid.c similarity index 63% rename from src/libleo/api/seek.c rename to src/libleo/api/readdiskid.c index 8abbb0f0a56..1200c5f6aa4 100644 --- a/src/libleo/api/seek.c +++ b/src/libleo/api/readdiskid.c @@ -1,24 +1,19 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" -s32 LeoSeek(LEOCmd* cmdBlock, u32 lba, OSMesgQueue* mq) { +s32 LeoReadDiskID(LEOCmd* cmdBlock, LEODiskID* vaddr, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - cmdBlock->header.command = LEO_COMMAND_READ_DISK_ID; cmdBlock->header.reserve1 = 0; cmdBlock->header.control = 0; cmdBlock->header.reserve3 = 0; - cmdBlock->data.readWrite.lba = lba; - + cmdBlock->data.readdiskid.buffer_pointer = vaddr; if (mq != NULL) { cmdBlock->header.control |= LEO_CONTROL_POST; cmdBlock->header.post = mq; } - leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/readwrite.c b/src/libleo/api/readwrite.c index 570b94b203a..c92839e3151 100644 --- a/src/libleo/api/readwrite.c +++ b/src/libleo/api/readwrite.c @@ -1,33 +1,26 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoReadWrite(LEOCmd* cmdBlock, s32 direction, u32 LBA, void* vAddr, u32 nLBAs, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - if (direction == OS_READ) { - cmdBlock->header.command = 5; + cmdBlock->header.command = LEO_COMMAND_READ; } else { - cmdBlock->header.command = 6; + cmdBlock->header.command = LEO_COMMAND_WRITE; } - cmdBlock->header.reserve1 = 0; - if (mq != NULL) { - cmdBlock->header.control = 0x80; + cmdBlock->header.control = LEO_CONTROL_POST; } else { cmdBlock->header.control = 0; } - cmdBlock->header.reserve3 = 0; cmdBlock->header.post = mq; - cmdBlock->data.readWrite.lba = LBA; - cmdBlock->data.readWrite.transferBlks = nLBAs; - cmdBlock->data.readWrite.buffPtr = vAddr; - + cmdBlock->data.readwrite.lba = LBA; + cmdBlock->data.readwrite.xfer_blks = nLBAs; + cmdBlock->data.readwrite.buff_ptr = vAddr; leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/spdlmotor.c b/src/libleo/api/spdlmotor.c index 21ef2b02235..94f487f3899 100644 --- a/src/libleo/api/spdlmotor.c +++ b/src/libleo/api/spdlmotor.c @@ -1,38 +1,31 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" s32 LeoSpdlMotor(LEOCmd* cmdBlock, u8 mode, OSMesgQueue* mq) { if (!__leoActive) { return -1; } - - cmdBlock->header.command = 8; + cmdBlock->header.command = LEO_COMMAND_START_STOP; cmdBlock->header.reserve1 = 0; - switch (mode) { - case LEO_MOTOR_ACTIVE: + case 0: cmdBlock->header.control = 1; break; - case LEO_MOTOR_STANDBY: - cmdBlock->header.control = 2; + case 1: + cmdBlock->header.control = LEO_CONTROL_STBY; break; - case LEO_MOTOR_SLEEP: + case 2: cmdBlock->header.control = 0; break; - case LEO_MOTOR_BRAKE: - cmdBlock->header.control = 4; + case 4: + cmdBlock->header.control = LEO_CONTROL_BRAKE; break; } - cmdBlock->header.reserve3 = 0; - if (mq != NULL) { cmdBlock->header.post = mq; - cmdBlock->header.control |= 0x80; + cmdBlock->header.control |= LEO_CONTROL_POST; } - leoCommand(cmdBlock); - return LEO_ERROR_GOOD; + return 0; } diff --git a/src/libleo/api/testunitready.c b/src/libleo/api/testunitready.c index 2116bc9e2af..e7f6b4519b0 100644 --- a/src/libleo/api/testunitready.c +++ b/src/libleo/api/testunitready.c @@ -1,28 +1,21 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" -s32 LeoTestUnitReady(u8* status) { +s32 LeoTestUnitReady(LEOStatus* status) { volatile LEOCmdTestUnitReady cmdBlock; if (!__leoActive) { return -1; } - if (IO_READ(PI_STATUS_REG) & PI_STATUS_DMA_BUSY) { return LEO_ERROR_BUSY; } - - cmdBlock.header.command = 3; + cmdBlock.header.command = LEO_COMMAND_TEST_UNIT_READY; cmdBlock.header.reserve1 = 0; cmdBlock.header.control = 0; cmdBlock.header.reserve3 = 0; - leoCommand((void*)&cmdBlock); - - while (cmdBlock.header.status == 8) {} - + while (cmdBlock.header.status == LEO_STATUS_BUSY) {} *status = cmdBlock.test; - return GET_ERROR(cmdBlock); + return cmdBlock.header.sense; } diff --git a/src/libleo/leo/leo_tbl.c b/src/libleo/leo/leo_tbl.c index 083fabb728c..280dbfaa144 100644 --- a/src/libleo/leo/leo_tbl.c +++ b/src/libleo/leo/leo_tbl.c @@ -1,58 +1,29 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" const char LEOfirmware_rev[] = "B014A26"; -const u8 LEOBYTE_TBL1[] = { - 0xE8, 0xD8, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, 0x70, +const u8 LEOBYTE_TBL1[0xC] = { 0xE8, 0xD8, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, 0x70, 0, 0, 0 }; +const u16 LEOBYTE_TBL2[9] = { 0x4D08, 0x47B8, 0x4510, 0x3FC0, 0x3A70, 0x3520, 0x2FD0, 0x2A80, 0x2530 }; +const u16 LEOVZONE_TBL[7][0x10] = { + { 0x124, 0x248, 0x35A, 0x47E, 0x5A2, 0x6B4, 0x7C6, 0x8D8, 0x9EA, 0xAB6, 0xB82, 0xC94, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x6A2, 0x7C6, 0x8D8, 0x9EA, 0xAFC, 0xBC8, 0xC94, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8C6, 0x9EA, 0xAFC, 0xC0E, 0xCDA, 0xDA6, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8B4, 0x9C6, 0xAEA, 0xC0E, 0xD20, 0xDEC, 0xEB8, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x8B4, 0x9C6, 0xAD8, 0xBEA, 0xD0E, 0xE32, 0xEFE, 0xFCA, 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x86E, 0x980, 0xA92, 0xBA4, 0xCB6, 0xDC8, 0xEEC, 0x1010, + 0x10DC }, + { 0x124, 0x248, 0x35A, 0x46C, 0x57E, 0x690, 0x7A2, 0x86E, 0x93A, 0xA4C, 0xB5E, 0xC70, 0xD82, 0xE94, 0xFB8, 0x10DC }, +}; +const u16 LEOZONE_SCYL_TBL[0x10] = { + 0, 0x9E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425, 0x91, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A, }; - -const u16 LEOBYTE_TBL2[] = { - 0x4D08, 0x47B8, 0x4510, 0x3FC0, 0x3A70, 0x3520, 0x2FD0, 0x2A80, 0x2530, -}; - -const u16 LEOVZONE_TBL[][0x10] = { - { 0x0124, 0x0248, 0x035A, 0x047E, 0x05A2, 0x06B4, 0x07C6, 0x08D8, 0x09EA, 0x0AB6, 0x0B82, 0x0C94, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x06A2, 0x07C6, 0x08D8, 0x09EA, 0x0AFC, 0x0BC8, 0x0C94, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08C6, 0x09EA, 0x0AFC, 0x0C0E, 0x0CDA, 0x0DA6, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE, - 0x0FCA, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC, - 0x1010, 0x10DC }, - { 0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, - 0x0FB8, 0x10DC }, -}; - -const u16 LEOZONE_SCYL_TBL[] = { - 0x0000, 0x009E, 0x013C, 0x01D1, 0x0266, 0x02FB, 0x0390, 0x0425, - 0x0091, 0x012F, 0x01C4, 0x0259, 0x02EE, 0x0383, 0x0418, 0x048A, -}; - const u8 LEOVZONE_PZONEHD_TBL[][0x10] = { - { 0x00, 0x01, 0x02, 0x09, 0x08, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A }, - { 0x00, 0x01, 0x02, 0x03, 0x0A, 0x09, 0x08, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x0B, 0x0A, 0x09, 0x08, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x06, 0x07, 0x0F, 0x0E, 0x0D }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x0F, 0x0E }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x0F }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }, -}; - -const u16 LEOZONE_OUTERCYL_TBL[] = { - 0x0000, 0x009E, 0x013C, 0x01D1, 0x0266, 0x02FB, 0x0390, 0x0425, -}; - -const u16 LEORAM_START_LBA[] = { - 0x05A2, 0x07C6, 0x09EA, 0x0C0E, 0x0E32, 0x1010, 0x10DC, -}; - -const s32 LEORAM_BYTE[] = { - 0x024A9DC0, 0x01C226C0, 0x01450F00, 0x00D35680, 0x006CFD40, 0x001DA240, 0x00000000, -}; + { 0, 1, 2, 9, 8, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10 }, { 0, 1, 2, 3, 10, 9, 8, 4, 5, 6, 7, 15, 14, 13, 12, 11 }, + { 0, 1, 2, 3, 4, 11, 10, 9, 8, 5, 6, 7, 15, 14, 13, 12 }, { 0, 1, 2, 3, 4, 5, 12, 11, 10, 9, 8, 6, 7, 15, 14, 13 }, + { 0, 1, 2, 3, 4, 5, 6, 13, 12, 11, 10, 9, 8, 7, 15, 14 }, { 0, 1, 2, 3, 4, 5, 6, 7, 14, 13, 12, 11, 10, 9, 8, 15 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 15, 14, 13, 12, 11, 10, 9, 8 }, +}; +const u16 LEOZONE_OUTERCYL_TBL[8] = { 0, 0x9E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425 }; +const u16 LEORAM_START_LBA[8] = { 0x5A2, 0x7C6, 0x9EA, 0xC0E, 0xE32, 0x1010, 0x10DC, 0 }; +const u32 LEORAM_BYTE[0xA] = { 0x024A9DC0, 0x01C226C0, 0x01450F00, 0xD35680, 0x6CFD40, 0x1DA240, 0, 0, 0, 0 }; diff --git a/src/libleo/leo/leoc2_syndrome.c b/src/libleo/leo/leoc2_syndrome.c index fe72a3e89ef..cf0dec7805e 100644 --- a/src/libleo/leo/leoc2_syndrome.c +++ b/src/libleo/leo/leoc2_syndrome.c @@ -1,3 +1,4 @@ -#include "n64dd.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" u8 LEOC2_Syndrome[2][0xE8 * 4]; diff --git a/src/libleo/leo/leoc2ecc.c b/src/libleo/leo/leoc2ecc.c index 5b770b138db..573fdf543b1 100644 --- a/src/libleo/leo/leoc2ecc.c +++ b/src/libleo/leo/leoc2ecc.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoC2_single_ecc(void); void leoC2_double_ecc(void); @@ -10,8 +8,6 @@ void leoC2_4_ecc(void); int leoAlpha_mult(int i, int k); int leoAlpha_div(int i, int k); -extern u8 LEO_TempBuffer[0xE8]; - const u8 ganlog[512] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1D, 0x3A, 0x74, 0xE8, 0xCD, 0x87, 0x13, 0x26, 0x4C, 0x98, 0x2D, 0x5A, 0xB4, 0x75, 0xEA, 0xC9, 0x8F, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x9D, 0x27, 0x4E, 0x9C, 0x25, 0x4A, @@ -96,8 +92,7 @@ int leoC2_Correction(void) { return 0; } -// static -void leoC2_single_ecc(void) { +STATIC void leoC2_single_ecc(void) { u8* pointer; unsigned int byte; u8* p_s; @@ -113,8 +108,7 @@ void leoC2_single_ecc(void) { } } -// static -void leoC2_double_ecc(void) { +STATIC void leoC2_double_ecc(void) { unsigned int s0; unsigned int error_k; u8* pointer1; @@ -140,7 +134,6 @@ void leoC2_double_ecc(void) { goto c2_2_1; } return; - c2_2_2: pointer2 = &LEOc2_param.pntr[(LEOc2_param.err_pos[1] + 1) * byte]; c2_2_1: @@ -167,8 +160,7 @@ void leoC2_double_ecc(void) { } while (--byte != 0); } -// static -void leoC2_3_ecc(void) { +STATIC void leoC2_3_ecc(void) { unsigned int s0; unsigned int error_i; unsigned int error_j; @@ -235,7 +227,6 @@ void leoC2_3_ecc(void) { goto c2_3_1; } return; - c2_3_3: pointer3 = &LEOc2_param.pntr[(LEOc2_param.err_pos[2] + 1) * byte]; c2_3_2: @@ -284,8 +275,7 @@ void leoC2_3_ecc(void) { } while (--byte != 0); } -// static -void leoC2_4_ecc(void) { +STATIC void leoC2_4_ecc(void) { unsigned int s0; unsigned int R0; unsigned int R1; @@ -478,16 +468,14 @@ void leoC2_4_ecc(void) { } while (--byte != 0); } -// static -int leoAlpha_mult(int i, int k) { +STATIC int leoAlpha_mult(int i, int k) { if (i == 0 || k == 0) { return 0; } return ganlog[glog[i] + glog[k]]; } -// static -int leoAlpha_div(int i, int k) { +STATIC int leoAlpha_div(int i, int k) { if (i == 0 || k == 0) { return 0; } diff --git a/src/libleo/leo/leocmdex.c b/src/libleo/leo/leocmdex.c index d7887d4944e..16bfb7561f9 100644 --- a/src/libleo/leo/leocmdex.c +++ b/src/libleo/leo/leocmdex.c @@ -1,30 +1,23 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - -extern vu16 LEOrw_flags; +extern u16 LEOrw_flags; -static void (*cmd_tbl[16])(void) = { +void (*cmd_tbl[])(void) = { NULL, leoClr_queue, leoInquiry, leoTest_unit_rdy, leoRezero, leoRead, leoWrite, leoSeek, leoStart_stop, leoRd_capacity, leoTranslate, leoMode_sel, leoReadDiskId, leoReadTimer, leoSetTimer, leoClr_reset, }; +const LEOCmdRead system_read_cmd = { { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, NULL }, 0xC, 1, NULL, 0 }; -static LEOCmdRead system_read_cmd = { - { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, 0 }, 12, 1, 0, 0, -}; - -static const u8 system_lba[8] = { 0, 1, 8, 9, 0, 0, 0, 0 }; +const u8 system_lba[] = { 0, 1, 8, 9, 0, 0, 0, 0 }; OSPiHandle* LEOPiInfo; OSIoMesg LEOPiDmaParam; s32 currentCommand; -u8 leoRead_system_area(void); - void leomain(void* arg0) { u32 cur_status; u32 sense_code; @@ -44,8 +37,10 @@ void leomain(void* arg0) { LEOPiDmaParam.hdr.pri = 1; LEOPiDmaParam.hdr.retQueue = &LEOdma_que; osEPiReadIo(LEOPiInfo, ASIC_STATUS, &cur_status); - if (!(cur_status & 0x400000) && (cur_status & 0x06800000)) { - leoDrive_reset(); + if (!(cur_status & 0x400000)) { + if ((cur_status & 0x06800000) != 0) { + leoDrive_reset(); + } } while (true) { @@ -62,19 +57,19 @@ void leomain(void* arg0) { do { if (cur_status == 0) { - if (sense_code == 0) { + if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { continue; } } else { switch (sense_code) { - case 3: - case 37: - case 41: - case 43: + case LEO_SENSE_COMMAND_PHASE_ERROR: + case LEO_SENSE_WAITING_NMI: + case LEO_SENSE_DEVICE_COMMUNICATION_FAILURE: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: break; - case 49: - if (leoRetUnit_atten() == 43) { - sense_code = 43; + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: + if (leoRetUnit_atten() == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED) { + sense_code = LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } break; default: @@ -83,38 +78,38 @@ void leomain(void* arg0) { } switch (sense_code) { - case 47: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: switch (LEOcur_command->header.command) { - case 2: - case 8: - case 11: - case 12: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_START_STOP: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_DISK_ID: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: continue; } break; - case 49: + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: switch (LEOcur_command->header.command) { - case 2: - case 11: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: continue; default: sense_code = 42; } break; - case 43: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: switch (LEOcur_command->header.command) { - case 15: + case 0xF: leoClrUA_RESET(); FALLTHROUGH; - case 2: - case 13: - case 14: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: continue; } break; @@ -122,23 +117,23 @@ void leomain(void* arg0) { /* empty */; } - if (LEOcur_command->header.command == 3) { - LEOcur_command->data.modeSelect.reserve1 = leoChk_cur_drvmode(); + if (LEOcur_command->header.command == LEO_COMMAND_TEST_UNIT_READY) { + LEOcur_command->data.modeselect.reserve1 = leoChk_cur_drvmode(); } LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } while (0); if (LEOdrive_flag == 0) { switch (LEOcur_command->header.command) { - case 2: - case 3: - case 8: - case 11: - case 13: - case 14: - case 15: + case LEO_COMMAND_INQUIRY: + case LEO_COMMAND_TEST_UNIT_READY: + case LEO_COMMAND_START_STOP: + case LEO_COMMAND_MODE_SELECT: + case LEO_COMMAND_READ_TIMER: + case LEO_COMMAND_SET_TIMER: + case 0xF: break; default: if (LEO_country_code == 0) { @@ -149,13 +144,14 @@ void leomain(void* arg0) { } if (leoRead_system_area() != 0) { - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } if ((LEOcur_command->header.sense = - leoSend_asic_cmd_w(0xB0001, LEO_sys_data.param.disk_type << 16)) != 0) { - LEOcur_command->header.status = 2; + leoSend_asic_cmd_w(0xB0001, LEO_sys_data.param.disk_type << 16)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } @@ -163,11 +159,11 @@ void leomain(void* arg0) { goto invalid_disktype; } - LEOdisk_type = (LEO_sys_data.param.disk_type & 0xF); + LEOdisk_type = LEO_sys_data.param.disk_type & 0xF; if (LEOdisk_type >= 7) { invalid_disktype: - LEOcur_command->header.sense = 0xBU; - LEOcur_command->header.status = 2; + LEOcur_command->header.sense = 11; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; goto post_exe; } @@ -178,8 +174,8 @@ void leomain(void* arg0) { cmd_tbl[LEOcur_command->header.command](); post_exe: - if (LEOcur_command->header.control & 0x80) { - osSendMesg(LEOcur_command->header.post, (void*)(s32)LEOcur_command->header.sense, OS_MESG_BLOCK); + if (LEOcur_command->header.control & LEO_CONTROL_POST) { + osSendMesg(LEOcur_command->header.post, (OSMesg)(s32)LEOcur_command->header.sense, OS_MESG_BLOCK); } if (LEOclr_que_flag != 0) { leoClr_queue(); @@ -204,7 +200,7 @@ u8 leoRead_system_area(void) { LEO_sys_data.param.defect_num[0] = 0; LEOrw_flags = 0x3000; dummy_cmd = system_read_cmd; - dummy_cmd.buffPtr = &LEO_sys_data; + dummy_cmd.buff_ptr = &LEO_sys_data; if (read_mode == 0) { // read System LBA 12 (+0, this is an offset value for leoRead_common) @@ -242,10 +238,10 @@ u8 leoRead_system_area(void) { } system_retry: - if (leoChk_err_retry(dummy_cmd.header.sense) != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + if (leoChk_err_retry(dummy_cmd.header.sense) != 0) { break; } - if (retry_cntr++ >= 0x40U) { + if (retry_cntr++ >= 64) { break; } if ((retry_cntr & 7) == 0) { @@ -260,5 +256,5 @@ u8 leoRead_system_area(void) { sys_read_end: LEOcur_command = backup_pointer; LEOcur_command->header.sense = dummy_cmd.header.sense; - return GET_ERROR(*LEOcur_command); + return LEOcur_command->header.sense; } diff --git a/src/libleo/leo/leofunc.c b/src/libleo/leo/leofunc.c index 35ba14005f5..a01ba5326c7 100644 --- a/src/libleo/leo/leofunc.c +++ b/src/libleo/leo/leofunc.c @@ -1,14 +1,14 @@ +#include "ultra64.h" #include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" #include "array_count.h" -#include "ultra64.h" +#include "ultra64/message.h" -static s32 __leoResetCalled = false; -static s32 __leoQueuesCreated = false; +s32 __leoResetCalled = 0; +s32 __leoQueuesCreated = 0; -static OSMesgQueue LEOpost_que; -static OSMesg LEOpost_que_buf[1]; +OSMesgQueue LEOpost_que; +OSMesg LEOpost_que_buf; void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size) { u32 savedMask; @@ -21,87 +21,81 @@ void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_ } else { pri = intpri; } - oldPri = -1; - myPri = osGetThreadPri(NULL); if (myPri < pri) { oldPri = myPri; osSetThreadPri(NULL, pri); } - savedMask = __osDisableInt(); - - __leoQueuesCreated = true; + __leoQueuesCreated = 1; osCreateMesgQueue(&LEOcommand_que, command_que_buf, cmd_buff_size); - osCreateMesgQueue(&LEOcontrol_que, LEOcontrol_que_buf, ARRAY_COUNT(LEOcontrol_que_buf)); - osCreateMesgQueue(&LEOevent_que, LEOevent_que_buf, ARRAY_COUNT(LEOevent_que_buf)); + osCreateMesgQueue(&LEOcontrol_que, &LEOcontrol_que_buf, 1); + osCreateMesgQueue(&LEOevent_que, &LEOevent_que_buf, 1); osCreateMesgQueue(&LEOdma_que, LEOdma_que_buf, ARRAY_COUNT(LEOdma_que_buf)); - osCreateMesgQueue(&LEOblock_que, LEOblock_que_buf, ARRAY_COUNT(LEOblock_que_buf)); - osCreateMesgQueue(&LEOpost_que, LEOpost_que_buf, ARRAY_COUNT(LEOpost_que_buf)); + osCreateMesgQueue(&LEOblock_que, &LEOblock_que_buf, 1); + osCreateMesgQueue(&LEOpost_que, &LEOpost_que_buf, 1); osCreateThread(&LEOcommandThread, 1, leomain, NULL, STACK_TOP(LEOcommandThreadStack), compri); osStartThread(&LEOcommandThread); osCreateThread(&LEOinterruptThread, 1, leointerrupt, NULL, STACK_TOP(LEOinterruptThreadStack), intpri); osStartThread(&LEOinterruptThread); - osSetEventMesg(2, &LEOevent_que, (OSMesg)0x30000); + osSetEventMesg(OS_EVENT_CART, &LEOevent_que, (OSMesg)0x30000); osSendMesg(&LEOblock_que, NULL, OS_MESG_NOBLOCK); __osRestoreInt(savedMask); - if (oldPri != -1) { osSetThreadPri(NULL, oldPri); } } void leoCommand(void* cmd_blk_addr) { + LEOCmdHeader* header = cmd_blk_addr; + if (__leoResetCalled != 0) { - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_WAITING_NMI; - if ((((LEOCmd*)cmd_blk_addr)->header.control & LEO_CONTROL_POST) != 0) { - osSendMesg(((LEOCmd*)cmd_blk_addr)->header.post, (OSMesg)LEO_SENSE_WAITING_NMI, OS_MESG_BLOCK); + header->status = LEO_STATUS_CHECK_CONDITION; + header->sense = LEO_SENSE_WAITING_NMI; + if (header->control & LEO_CONTROL_POST) { + osSendMesg(header->post, (OSMesg)LEO_ERROR_WAITING_NMI, OS_MESG_BLOCK); } - return; - } - osRecvMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_BUSY; - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; - - switch (((LEOCmd*)cmd_blk_addr)->header.command) { - case 1: - LEOclr_que_flag = 0xFF; - leoClr_queue(); - LEOclr_que_flag = 0; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_GOOD; - if (((LEOCmd*)cmd_blk_addr)->header.control & LEO_CONTROL_POST) { - osSendMesg(((LEOCmd*)cmd_blk_addr)->header.post, (OSMesg)0, OS_MESG_BLOCK); - } - break; - - case 5: - case 6: - ((LEOCmd*)cmd_blk_addr)->data.readWrite.rwBytes = 0; - goto cmd_queing; - - default: - if ((u32)(((LEOCmd*)cmd_blk_addr)->header.command - 1) >= 0xE) { - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_INVALID_COMMAND_OPERATION_CODE; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; + } else { + osRecvMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); + header->status = LEO_STATUS_BUSY; + header->sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + switch (header->command) { + case LEO_COMMAND_CLEAR_QUE: + LEOclr_que_flag = 0xFF; + leoClr_queue(); + LEOclr_que_flag = 0; + header->status = LEO_STATUS_GOOD; + if (header->control & LEO_CONTROL_POST) { + osSendMesg(header->post, (OSMesg)LEO_ERROR_GOOD, OS_MESG_BLOCK); + } break; - } - - cmd_queing: - if (osSendMesg(&LEOcommand_que, (OSMesg)cmd_blk_addr, OS_MESG_NOBLOCK) != 0) { - ((LEOCmd*)cmd_blk_addr)->header.sense = LEO_SENSE_QUEUE_FULL; - ((LEOCmd*)cmd_blk_addr)->header.status = LEO_STATUS_CHECK_CONDITION; - } + case LEO_COMMAND_READ: + case LEO_COMMAND_WRITE: + ((LEOCmdRead*)cmd_blk_addr)->rw_bytes = 0; + goto cmd_queing; + default: + if ((u32)(header->command - 1) >= 0xE) { + header->sense = LEO_SENSE_INVALID_COMMAND_OPERATION_CODE; + header->status = LEO_STATUS_CHECK_CONDITION; + } else { + cmd_queing: + if (osSendMesg(&LEOcommand_que, cmd_blk_addr, OS_MESG_NOBLOCK) != 0) { + header->sense = LEO_SENSE_QUEUE_FULL; + header->status = LEO_STATUS_CHECK_CONDITION; + } + } + break; + } + osSendMesg(&LEOblock_que, NULL, OS_MESG_BLOCK); } - osSendMesg(&LEOblock_que, (OSMesg)0, OS_MESG_BLOCK); } -static const u8 zero[] = { 0 }; +const u8 zero[] = { 0 }; void LeoReset(void) { - __leoResetCalled = true; - if (__leoQueuesCreated) { + __leoResetCalled = 1; + if (__leoQueuesCreated != 0) { LEOclr_que_flag = 0xFF; leoClr_queue(); LEOclr_que_flag = 0; @@ -116,20 +110,20 @@ s32 __leoSetReset(void) { return 0; } -// SENSE or ERROR? s32 LeoResetClear(void) { LEOCmdHeader resetclear; resetclear.command = 0xF; resetclear.control = LEO_CONTROL_POST; - resetclear.status = 0; + resetclear.status = LEO_STATUS_GOOD; resetclear.post = &LEOpost_que; - if (osSendMesg(&LEOcommand_que, &resetclear.command, OS_MESG_NOBLOCK) != 0) { + if (osSendMesg(&LEOcommand_que, &resetclear, OS_MESG_NOBLOCK) != 0) { return LEO_SENSE_QUEUE_FULL; } osRecvMesg(&LEOpost_que, NULL, OS_MESG_BLOCK); if (resetclear.status == LEO_STATUS_GOOD) { return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; + } else { + return resetclear.sense; } - return resetclear.sense; } diff --git a/src/libleo/leo/leoglobals.c b/src/libleo/leo/leoglobals.c deleted file mode 100644 index 28a99f626d2..00000000000 --- a/src/libleo/leo/leoglobals.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" - -s32 __leoActive = false; - -LEOVersion __leoVersion; diff --git a/src/libleo/leo/leoinquiry.c b/src/libleo/leo/leoinquiry.c index b23a9ab4548..8dac7892115 100644 --- a/src/libleo/leo/leoinquiry.c +++ b/src/libleo/leo/leoinquiry.c @@ -1,6 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" void leoInquiry(void) { @@ -8,16 +7,15 @@ void leoInquiry(void) { u32 asic_data; osEPiReadIo(LEOPiInfo, ASIC_ID_REG, &asic_id); - if (leoSend_asic_cmd_w(0x1B0000, 0) == 0) { + if (leoSend_asic_cmd_w(0x1B0000, 0) == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { osEPiReadIo(LEOPiInfo, ASIC_DATA, &asic_data); if (asic_data & 0x10000) { asic_id |= 0x100000; } } - - ((LEOCmdInquiry*)LEOcur_command)->devType = 0; - ((LEOCmdInquiry*)LEOcur_command)->version = asic_id >> 0x10; - ((LEOCmdInquiry*)LEOcur_command)->devNum = 1; - ((LEOCmdInquiry*)LEOcur_command)->leoBiosVer = 0; + LEOcur_command->data.time.pad = 0; + LEOcur_command->data.time.yearhi = (u8)(asic_id >> 16); + LEOcur_command->data.time.yearlo = 1; + LEOcur_command->data.time.month = 0; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leoint.c b/src/libleo/leo/leoint.c index 33ac3d2010d..5922d10e630 100644 --- a/src/libleo/leo/leoint.c +++ b/src/libleo/leo/leoint.c @@ -1,32 +1,28 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" +#include "ultra64/pi.h" extern vu16 LEOrw_flags; -extern u8 LEOC2_Syndrome[2][0xE8 * 4]; -extern OSIoMesg LEOPiDmaParam; -extern block_param_form LEOc2_param; - -u8 LEOc2ctrl_que_buf[8]; -OSMesgQueue LEOc2ctrl_que; - u32 read_write_track(void); u32 leoChk_mecha_int(void); void leosetup_BM(void); u32 leochk_err_reg(void); +OSMesg LEOc2ctrl_que_buf; +OSMesgQueue LEOc2ctrl_que; + void leointerrupt(void* arg) { u32 result; u32 tg_blocks; - osCreateMesgQueue(&LEOc2ctrl_que, (OSMesg*)&LEOc2ctrl_que_buf, 1); + osCreateMesgQueue(&LEOc2ctrl_que, &LEOc2ctrl_que_buf, 1); - while (true) { + while (1) { osStopThread(&LEOinterruptThread); - tg_blocks = LEOcur_command->data.readWrite.transferBlks; - LEOwrite_pointer = LEOcur_command->data.readWrite.buffPtr; + tg_blocks = LEOcur_command->data.readwrite.xfer_blks; + LEOwrite_pointer = LEOcur_command->data.readwrite.buff_ptr; do { leoLba_to_phys(LEOtgt_param.lba); @@ -35,11 +31,9 @@ void leointerrupt(void* arg) { } else { result = leoSeek_i(0); } - - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto complete; } - if (LEOrw_flags & 0x2000) { LEOtgt_param.rdwr_blocks = 1; } else if (LEOtgt_param.rdwr_blocks > tg_blocks) { @@ -48,20 +42,19 @@ void leointerrupt(void* arg) { LEOtgt_param.lba += LEOtgt_param.rdwr_blocks; tg_blocks -= LEOtgt_param.rdwr_blocks; result = read_write_track(); - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto complete; } - - LEOcur_command->data.readWrite.rwBytes = LEOwrite_pointer - (u8*)LEOcur_command->data.readWrite.buffPtr; + LEOcur_command->data.readwrite.rw_bytes = + (uintptr_t)LEOwrite_pointer - (uintptr_t)LEOcur_command->data.readwrite.buff_ptr; } while (tg_blocks != 0); - result = 0x90000; // Inaccessible? + result = 0x90000; complete: osSendMesg(&LEOcontrol_que, (OSMesg)result, OS_MESG_BLOCK); } } -// static u32 read_write_track(void) { u32 message; u32 block; @@ -96,7 +89,7 @@ u32 read_write_track(void) { LEOPiInfo->transferInfo.block[1] = LEOPiInfo->transferInfo.block[0]; LEOPiInfo->transferInfo.block[1].C2Addr = &LEOC2_Syndrome[1]; LEOPiInfo->transferInfo.block[1].dramAddr = - ((u8*)LEOPiInfo->transferInfo.block[1].dramAddr + block_param.blkbytes); + (u8*)LEOPiInfo->transferInfo.block[1].dramAddr + block_param.blkbytes; } message = leoChk_mecha_int(); if (message == 0) { @@ -115,13 +108,13 @@ u32 read_write_track(void) { LEOPiInfo->transferInfo.cmdType = 1; osWritebackDCache(block_param.pntr, block_param.blkbytes * LEOtgt_param.rdwr_blocks); - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 1); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_WRITE); osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); LEOasic_bm_ctl_shadow = LEOPiInfo->transferInfo.bmCtlShadow; LEOasic_seq_ctl_shadow = LEOPiInfo->transferInfo.seqCtlShadow; bnum = LEOPiInfo->transferInfo.blockNum; message = LEOPiInfo->transferInfo.block[bnum].errStatus; - if (message == 0) { + if (message == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return message; } goto track_end; @@ -132,7 +125,7 @@ u32 read_write_track(void) { } LEOPiInfo->transferInfo.cmdType = 0; osInvalDCache(block_param.pntr, block_param.blkbytes * LEOtgt_param.rdwr_blocks); - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 0); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_READ); block = 0; while (LEOtgt_param.rdwr_blocks != 0) { osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); @@ -153,7 +146,7 @@ u32 read_write_track(void) { if (LEOtgt_param.rdwr_blocks == 1) { osEPiReadIo(LEOPiInfo, ASIC_ERR_SECTOR, &message); if (message & 0x10000000) { - message = 4; + message = LEO_SENSE_DATA_PHASE_ERROR; goto track_end; } } @@ -180,7 +173,7 @@ u32 read_write_track(void) { if (LEOtgt_param.rdwr_blocks == 1) { if ((*(u32*)&LEOC2_Syndrome[block][0x00] | *(u32*)&LEOC2_Syndrome[block][0x04] | *(u32*)&LEOC2_Syndrome[block][0x08] | *(u32*)&LEOC2_Syndrome[block][0x0C]) != 0) { - message = 0x17; + message = LEO_SENSE_UNRECOVERED_READ_ERROR; goto track_end; } } @@ -194,22 +187,23 @@ u32 read_write_track(void) { return 0; } track_end: - if (message == 0x16) { + if (message == LEO_SENSE_WRITE_FAULT) { message = leochk_err_reg(); } do_retry: - if (leoChk_err_retry(message) || (LEOrw_flags & 0x1000) || retry_cntr++ == 0x40) { + if ((leoChk_err_retry(message) != 0) || (LEOrw_flags & 0x1000) || (retry_cntr++ == 64)) { break; } if ((retry_cntr & 7) == 0) { message = leoSend_asic_cmd_w(0x30001, 0); - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } - if (message == 0x18 || (message == 0x17 && retry_cntr == 0x20)) { + if ((message == LEO_SENSE_NO_REFERENCE_POSITION_FOUND) || + ((message == LEO_SENSE_UNRECOVERED_READ_ERROR) && (retry_cntr == 32))) { message = leoDetect_index_w(); - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } @@ -218,81 +212,69 @@ u32 read_write_track(void) { } else { message = leoSeek_i(0); } - if (message != 0) { + if (message != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { goto do_retry; } } return message; } -// static u32 leoChk_mecha_int(void) { - u32 stat = leoWait_mecha_cmd_done(0x10001); + u32 stat; u32 index_stat; - if (stat == 0) { + stat = leoWait_mecha_cmd_done(0x10001); + if (stat == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { osEPiReadIo(LEOPiInfo, ASIC_CUR_TK, &index_stat); if ((index_stat & 0x60000000) != 0x60000000) { - stat = 0x18; + stat = LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } } return stat; } -// static void leosetup_BM(void) { - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | 0x10000000); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); - + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | LEO_BM_RESET); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); if (LEOtgt_param.start_block != 0) { - LEOasic_bm_ctl_shadow = 0x5A0000; + LEOasic_bm_ctl_shadow = 0x005A0000; } else { LEOasic_bm_ctl_shadow = 0; } - if (!(LEOrw_flags & 0x8000)) { - LEOasic_bm_ctl_shadow |= 0x40000000; + LEOasic_bm_ctl_shadow |= LEO_BM_MODE; } - if (LEOtgt_param.rdwr_blocks == 2) { - LEOasic_bm_ctl_shadow |= 0x02000000; + LEOasic_bm_ctl_shadow |= LEO_BM_XFER_BLOCK; } - - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); } -// static u32 leochk_err_reg(void) { u32 sense; u32 index_status; osEPiReadIo(LEOPiInfo, ASIC_ERR_SECTOR, &sense); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | 0x10000000); - osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow); - + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, LEOasic_bm_ctl_shadow | LEO_BM_RESET); + osEPiWriteIo(LEOPiInfo, ASIC_BM_CTL, (u32)LEOasic_bm_ctl_shadow); if (sense & 0x04000000) { - return LEO_ERROR_EJECTED_ILLEGALLY_RESUME; + return LEO_SENSE_EJECTED_ILLEGALLY_RESUME; } - if (sense & 0x10000000) { - return LEO_ERROR_DATA_PHASE_ERROR; + return LEO_SENSE_DATA_PHASE_ERROR; } - - if (sense & (0x40000000 | 0x2000000)) { + if (sense & 0x42000000) { if (LEOrw_flags & 0x8000) { - return LEO_ERROR_WRITE_FAULT; + return LEO_SENSE_WRITE_FAULT; } - return LEO_ERROR_UNRECOVERED_READ_ERROR; + return LEO_SENSE_UNRECOVERED_READ_ERROR; } - if (sense & 0x80000000) { - return LEO_ERROR_NO_REFERENCE_POSITION_FOUND; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } - osEPiReadIo(LEOPiInfo, ASIC_CUR_TK, &index_status); if ((index_status & 0x60000000) == 0x60000000) { - return LEO_ERROR_TRACK_FOLLOWING_ERROR; + return LEO_SENSE_TRACK_FOLLOWING_ERROR; } - - return LEO_ERROR_NO_REFERENCE_POSITION_FOUND; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } diff --git a/src/libleo/leo/leointerrupt.c b/src/libleo/leo/leointerrupt.c deleted file mode 100644 index fc547cfd5c7..00000000000 --- a/src/libleo/leo/leointerrupt.c +++ /dev/null @@ -1,208 +0,0 @@ -#include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "ultra64/internal.h" - -extern OSThread* __osRunQueue; -extern OSIntMask __OSGlobalIntMask; -void __osLeoAbnormalResume(void); -void __osLeoResume(void); - -STACK(leoDiskStack, 0x1000); - -s32 __osLeoInterrupt(void) { - u32 stat = 0; - volatile u32 pi_stat; - u32 bm_stat; - __OSTranxInfo* info = &__osDiskHandle->transferInfo; - __OSBlockInfo* blockInfo = &info->block[info->blockNum]; - - pi_stat = IO_READ(PI_STATUS_REG); - if (pi_stat & PI_STATUS_DMA_BUSY) { - __OSGlobalIntMask &= ~0x800; - blockInfo->errStatus = 0x1D; - __osLeoResume(); - return 1; - } - - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - stat = IO_READ(ASIC_STATUS); - if (stat & 0x2000000) { - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | 0x1000000); - blockInfo->errStatus = 0; - return 0; - } - if (info->cmdType == 2) { - return 1; - } - if (stat & 0x8000000) { - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - stat = IO_READ(ASIC_STATUS); - blockInfo->errStatus = 0x16; - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - return 1; - } - if (info->cmdType == 1) { - if (!(stat & 0x40000000)) { - if ((info->sectorNum + 1) != (info->transferMode * 0x55)) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - blockInfo->errStatus = 0; - __osLeoResume(); - return 1; - } else { - blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; - info->sectorNum++; - __osEPiRawStartDma(__osDiskHandle, 1, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - return 1; - } - } else if (info->cmdType == 0) { - if (info->transferMode == 3) { - if (((s32)blockInfo->C1ErrNum + 0x11) < info->sectorNum) { - blockInfo->errStatus = 0; - __osLeoAbnormalResume(); - return 1; - } - if ((stat & 0x40000000) == 0) { - blockInfo->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } else { - blockInfo->dramAddr = (u8*)(blockInfo->dramAddr) + blockInfo->sectorSize; - } - - bm_stat = IO_READ(ASIC_BM_STATUS); - if (((bm_stat & 0x200000) && (bm_stat & 0x400000)) || (bm_stat & 0x2000000)) { - if (blockInfo->C1ErrNum >= 4) { - if ((info->transferMode != 3) || (info->sectorNum >= 0x53)) { - blockInfo->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } else { - int errNum = blockInfo->C1ErrNum; - - blockInfo->C1ErrSector[errNum] = info->sectorNum + 1; - } - blockInfo->C1ErrNum++; - } - - if (stat & 0x10000000) { - if (info->sectorNum != 0x57) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - if ((info->transferMode == 2) && (info->blockNum == 0)) { - info->blockNum = 1; - info->sectorNum = -1; - info->block[1].dramAddr = (u8*)(info->block[1].dramAddr) - info->block[1].sectorSize; - blockInfo->errStatus = 0x16; - } else { - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; - info->cmdType = 2; - blockInfo->errStatus = 0; - } - __osEPiRawStartDma(__osDiskHandle, 0, ASIC_C2_BUFF, blockInfo->C2Addr, blockInfo->sectorSize * 4); - return 1; - } - if ((info->sectorNum == -1) && (info->transferMode == 2) && (info->blockNum == 1)) { - __OSBlockInfo* bptr = info->block; - - if (bptr->C1ErrNum == 0) { - if (((u32*)bptr->C2Addr)[0] | ((u32*)bptr->C2Addr)[1] | ((u32*)bptr->C2Addr)[2] | - ((u32*)bptr->C2Addr)[3]) { - bptr->errStatus = 0x17; - __osLeoAbnormalResume(); - return 1; - } - } - bptr->errStatus = 0; - __osLeoResume(); - } - info->sectorNum++; - if (stat & 0x40000000) { - if (info->sectorNum >= 0x55) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - __osEPiRawStartDma(__osDiskHandle, 0, ASIC_SECTOR_BUFF, blockInfo->dramAddr, blockInfo->sectorSize); - blockInfo->errStatus = 0; - return 1; - } else if (info->sectorNum < 0x55) { - blockInfo->errStatus = 0x18; - __osLeoAbnormalResume(); - return 1; - } - return 1; - } else { - blockInfo->errStatus = 4; - __osLeoAbnormalResume(); - return 1; - } -} - -// static -void __osLeoAbnormalResume(void) { - __OSTranxInfo* info; - u32 pi_stat; - - info = &__osDiskHandle->transferInfo; - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow | 0x10000000); - pi_stat = IO_READ(PI_STATUS_REG); - while (pi_stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) { - pi_stat = IO_READ(PI_STATUS_REG); - } - - IO_WRITE(ASIC_BM_CTL, info->bmCtlShadow); - __osLeoResume(); - IO_WRITE(PI_STATUS_REG, 2); - __OSGlobalIntMask |= 0x100401; -} - -// static -void __osLeoResume(void) { - __OSEventState* es; - OSMesgQueue* mq; - s32 last; - - es = &__osEventStateTab[8]; - mq = es->queue; - if ((mq == 0) || (mq->validCount >= mq->msgCount)) { - return; - } - last = (mq->first + mq->validCount) % mq->msgCount; - mq->msg[last] = es->msg; - mq->validCount++; - if (mq->mtqueue->next != NULL) { - __osEnqueueThread(&__osRunQueue, __osPopThread(&mq->mtqueue)); - } -} diff --git a/src/libleo/leo/leomecha.c b/src/libleo/leo/leomecha.c index d0804f033c2..5b436c1812b 100644 --- a/src/libleo/leo/leomecha.c +++ b/src/libleo/leo/leomecha.c @@ -1,194 +1,179 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - -extern s32 currentCommand; +u8 leoRecv_event_mesg(s32 control); -static u32 asic_cur_status; -static u32 unit_atten; +u32 asic_cur_status; +u32 unit_atten; u8 leoAnalize_asic_status(void) { u32 curr_stat; osEPiReadIo(LEOPiInfo, ASIC_STATUS, &asic_cur_status); - curr_stat = asic_cur_status ^ 0x1000000; - - // 0xFE3C0000? - if (curr_stat & 0x1C3FFFF) { - // 0xFE3E0000? - if (curr_stat & 0x1C1FFFF) { + curr_stat = asic_cur_status ^ 0x01000000; + if ((curr_stat & 0x01C3FFFF) != 0) { + if ((curr_stat & 0x01C1FFFF) != 0) { LEOdrive_flag = 0; } if (curr_stat & 0xFFFF) { - return 41; + return LEO_SENSE_DEVICE_COMMUNICATION_FAILURE; } - if ((curr_stat & 0xC00000) == 0x800000) { - return 3; + if ((curr_stat & 0x00C00000) == 0x00800000) { + return LEO_SENSE_COMMAND_PHASE_ERROR; } - if (curr_stat & 0x400000) { + if (curr_stat & 0x00400000) { unit_atten |= 2; - return 43; + return LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } - if (curr_stat & 0x1000000) { - return 49; + if (curr_stat & 0x01000000) { + return LEO_SENSE_EJECTED_ILLEGALLY_RESUME; } - if (curr_stat & 0x10000) { + if (curr_stat & 0x00010000) { unit_atten |= 1; - return 47; + return LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED; } - if (curr_stat & 0x20000) { - return 21; + if (curr_stat & 0x00020000) { + return LEO_SENSE_NO_SEEK_COMPLETE; } } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoChk_asic_ready(u32 asic_cmd) { - u32 sense_code = leoAnalize_asic_status(); + u32 sense_code; + sense_code = leoAnalize_asic_status(); switch (sense_code) { - case 47: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: if (asic_cmd == 0x80000) { - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } FALLTHROUGH; - case 43: + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: if (!(asic_cur_status & 0x800000)) { if (asic_cmd == 0x90000) { - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x90000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } } - FALLTHROUGH; - default: break; - - case 49: + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: if (asic_cmd & 1) { break; } FALLTHROUGH; - case 21: + case LEO_SENSE_NO_SEEK_COMPLETE: return 0; + default: + break; } return sense_code; } -// Which of LEO_ERROR or LEO_SENSE should be used where? u8 leoChk_done_status(u32 asic_cmd) { u32 asic_data; - u32 code = leoAnalize_asic_status(); + u32 code; + code = leoAnalize_asic_status(); switch (code) { - case 43: - case 47: - if (!(asic_cur_status & 0x800000)) { + case LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED: + case LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED: + if (!(asic_cur_status & 0x00800000)) { if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - - osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x90000); + osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x00090000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } } break; - - case 49: - if (asic_cmd & 1) { - break; + default: + break; + case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: + if (!(asic_cmd & 1)) { + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } - return 0; - - case 21: + break; + case LEO_SENSE_NO_SEEK_COMPLETE: osEPiWriteIo(LEOPiInfo, ASIC_DATA, 0); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - - osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0xC0000); + osEPiWriteIo(LEOPiInfo, ASIC_CMD, 0x000C0000); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 37; + return LEO_SENSE_WAITING_NMI; } - osEPiReadIo(LEOPiInfo, ASIC_DATA, &asic_data); - code = leoChk_asic_ready(0xC0000); - if (code != 0) { + code = leoChk_asic_ready(0x000C0000); + if (code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return code; } - if (asic_data & 0x10000) { - return 2; + return LEO_SENSE_DIAGNOSTIC_FAILURE; } if (asic_data & 0x20000) { - return 24; + return LEO_SENSE_NO_REFERENCE_POSITION_FOUND; } if (asic_data & 0x40000) { - return 1; + return LEO_SENSE_DRIVE_NOT_READY; } if (asic_data & 0x80000) { - return 21; + return LEO_SENSE_NO_SEEK_COMPLETE; } if (asic_data & 0x200000) { return 11; } - return 41; - - default: - break; + return LEO_SENSE_DEVICE_COMMUNICATION_FAILURE; } - return code; } u8 leoSend_asic_cmd_i(u32 asic_cmd, u32 asic_data) { - u8 status = leoChk_asic_ready(asic_cmd); + u8 status; - if (status != 0) { - return LEOcur_command->header.sense = status; + status = leoChk_asic_ready(asic_cmd); + if (status != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.sense = status; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_DATA, asic_data); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return LEOcur_command->header.sense = 37; + LEOcur_command->header.sense = LEO_SENSE_WAITING_NMI; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_CMD, asic_cmd); - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } -// Is this using the sense defines? u8 leoWait_mecha_cmd_done(u32 asic_cmd) { u32 done_stat; - if (leoRecv_event_mesg(OS_MESG_BLOCK)) { - return 37; + if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { + return LEO_SENSE_WAITING_NMI; } - done_stat = leoChk_done_status(asic_cmd); - if (done_stat != 0) { + if (done_stat != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return done_stat; } - - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoSend_asic_cmd_w(u32 asic_cmd, u32 asic_data) { - u32 wstatus = leoSend_asic_cmd_i(asic_cmd, asic_data); + u32 wstatus; + wstatus = leoSend_asic_cmd_i(asic_cmd, asic_data); if (wstatus != 0) { return wstatus; } - return leoWait_mecha_cmd_done(asic_cmd); } @@ -197,26 +182,24 @@ u8 leoSend_asic_cmd_w_nochkDiskChange(u32 asic_cmd, u32 asic_data) { u32 done_stat; status = leoChk_asic_ready(asic_cmd); - if ((status != 0x2F) && (status != 0)) { - return LEOcur_command->header.sense = status; + if ((status != LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED) && (status != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) { + LEOcur_command->header.sense = status; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_DATA, asic_data); if (leoRecv_event_mesg(OS_MESG_NOBLOCK) != 0) { - return LEOcur_command->header.sense = 0x25; + LEOcur_command->header.sense = LEO_SENSE_WAITING_NMI; + return LEOcur_command->header.sense; } - osEPiWriteIo(LEOPiInfo, ASIC_CMD, asic_cmd); if (leoRecv_event_mesg(OS_MESG_BLOCK) != 0) { - return 0x25; + return LEO_SENSE_WAITING_NMI; } - done_stat = leoChk_done_status(asic_cmd); - if ((done_stat != 0x2F) && (done_stat != 0)) { + if ((done_stat != LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED) && (done_stat != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) { return done_stat; } - - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } u8 leoDetect_index_w(void) { @@ -232,35 +215,32 @@ u8 leoRecal_w(void) { } u8 leoSeek_i(u16 rwmode) { - u32 tgt_tk = ((LEOtgt_param.head << 0xC) + LEOtgt_param.cylinder) << 0x10; + s32 tgt_tk; - if (rwmode == 0) { + tgt_tk = ((LEOtgt_param.head << 12) + LEOtgt_param.cylinder) << 16; + if (!rwmode) { return leoSend_asic_cmd_i(0x10001, tgt_tk); - } else { - return leoSend_asic_cmd_i(0x20001, tgt_tk); } + return leoSend_asic_cmd_i(0x20001, tgt_tk); } u8 leoSeek_w(void) { - u8 sksense = leoSeek_i(0); + u8 sksense; + sksense = leoSeek_i(0); if (sksense != 0) { return sksense; } - return leoWait_mecha_cmd_done(0x10001); } u8 leoRecv_event_mesg(s32 control) { - u32 done_mesg; + OSMesg done_mesg; - if (osRecvMesg(&LEOevent_que, (OSMesg*)&done_mesg, control) == 0) { - if (done_mesg == 0xA0000) { - leoDrive_reset(); - return -1; - } + if ((osRecvMesg(&LEOevent_que, &done_mesg, control) == 0) && (done_mesg == (OSMesg)0xA0000)) { + leoDrive_reset(); + return 0xFF; } - return 0; } @@ -277,7 +257,9 @@ u32 leoChk_err_retry(u32 sense) { case LEO_SENSE_MEDIUM_NOT_PRESENT: case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: LEOdrive_flag = 0; - return -1; + return -1U; + default: + break; } } else { switch (sense) { @@ -294,17 +276,19 @@ u32 leoChk_err_retry(u32 sense) { case LEO_SENSE_MEDIUM_NOT_PRESENT: case LEO_SENSE_EJECTED_ILLEGALLY_RESUME: LEOdrive_flag = 0; - return -1; + return -1U; + default: + break; } } - return 0; } u8 leoChk_cur_drvmode(void) { - u8 devstat = 0; + u8 devstat; - if (!(asic_cur_status & 0x1000000)) { + devstat = 0; + if (!(asic_cur_status & 0x01000000)) { devstat |= 1; } if (asic_cur_status & 0x80000) { @@ -316,7 +300,7 @@ u8 leoChk_cur_drvmode(void) { return devstat; } -void leoDrive_reset() { +void leoDrive_reset(void) { osEPiWriteIo(LEOPiInfo, ASIC_HARD_RESET, 0xAAAA0000); } @@ -326,12 +310,12 @@ u32 leoChkUnit_atten(void) { u32 leoRetUnit_atten(void) { if (unit_atten & 2) { - return 43; + return LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED; } if (unit_atten & 1) { - return 47; + return LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED; } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } void leoClrUA_RESET(void) { diff --git a/src/libleo/leo/leomode_sel.c b/src/libleo/leo/leomode_sel.c index fe36bc16afc..09d607c1ce8 100644 --- a/src/libleo/leo/leomode_sel.c +++ b/src/libleo/leo/leomode_sel.c @@ -1,27 +1,19 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoMode_sel(void) { - u32 sense; + u8 sense; - sense = leoSend_asic_cmd_w_nochkDiskChange(0x60000, LEOcur_command->data.time.yearlo << 0x10); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - goto mselerror; - } - sense = leoSend_asic_cmd_w_nochkDiskChange(0x70000, LEOcur_command->data.time.month << 0x10); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - goto mselerror; - } - sense = leoSend_asic_cmd_w_nochkDiskChange(0x150000, LEOcur_command->data.readWrite.transferBlks); - if (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { - mselerror: + sense = leoSend_asic_cmd_w_nochkDiskChange(0x60000, LEOcur_command->data.time.yearlo << 16); + if ((sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) || + (sense = leoSend_asic_cmd_w_nochkDiskChange(0x70000, LEOcur_command->data.time.month << 16), + (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION)) || + (sense = leoSend_asic_cmd_w_nochkDiskChange(0x150000, LEOcur_command->data.readwrite.xfer_blks), + (sense != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION))) { LEOcur_command->header.sense = sense; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - LEOcur_command->header.sense = sense; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leomotor.c b/src/libleo/leo/leomotor.c index 652b626ee05..6455306d531 100644 --- a/src/libleo/leo/leomotor.c +++ b/src/libleo/leo/leomotor.c @@ -1,36 +1,34 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoStart_stop(void) { u32 send_cmd; u8 sense_code; - u8 retry_cntr = 8; + u8 retry_cntr; u32 send_data; + retry_cntr = 8; do { send_data = 0; - if ((LEOcur_command->header.control & 1)) { + if (LEOcur_command->header.control & 1) { send_cmd = 0x50001; - } else if ((LEOcur_command->header.control & 2)) { + } else if (LEOcur_command->header.control & LEO_CONTROL_STBY) { send_cmd = 0xD0000; } else { - if ((LEOcur_command->header.control & 4)) { + if (LEOcur_command->header.control & LEO_CONTROL_BRAKE) { send_data = 0x10000; } send_cmd = 0x40000; } sense_code = leoSend_asic_cmd_w_nochkDiskChange(send_cmd, send_data); - if (sense_code == 0) { - LEOcur_command->header.status = 0; + if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code)) { + if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = 2; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leomseq_tbl.c b/src/libleo/leo/leomseq_tbl.c index f94979f623c..1bf0a391d47 100644 --- a/src/libleo/leo/leomseq_tbl.c +++ b/src/libleo/leo/leomseq_tbl.c @@ -1,22 +1,18 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" -extern OSIoMesg LEOPiDmaParam; extern vu16 LEOrw_flags; -// bss -static u32 mseq_tbl[0x10]; +STATIC s32 mseq_tbl[0x10]; -// rodata -static const u32 rd_mseq_code[0x10] = { - 0x00010000, 0x00020200, 0x80030100, 0x82040000, 0xA8050000, 0xA0060600, 0x31760000, 0x00020300, - 0, 0, 0, 0, 0, 0, 0, 0x4060000, +STATIC const u32 rd_mseq_code[0x10] = { + 0x10000, 0x20200, 0x80030100, 0x82040000, 0xA8050000, 0xA0060600, 0x31760000, 0x20300, + 0, 0, 0, 0, 0, 0, 0, 0x04060000, }; -static const u32 wt_mseq_code[0x10] = { - 0x40020000, 0x00020000, 0x40130B00, 0x42140100, 0x68050000, 0x50060600, 0x401702FF, 0x01870000, - 0x40020000, 0, 0, 0, 0, 0, 0, 0x40F0000, +STATIC const u32 wt_mseq_code[0x10] = { + 0x40020000, 0x20000, 0x40130B00, 0x42140100, 0x68050000, 0x50060600, 0x401702FF, 0x01870000, + 0x40020000, 0, 0, 0, 0, 0, 0, 0x040F0000, }; void leoSet_mseq(u16 rwmode) { @@ -25,7 +21,7 @@ void leoSet_mseq(u16 rwmode) { u32 sct_byte_u; u8 i; - LEOasic_seq_ctl_shadow &= 0xBFFFFFFF; + LEOasic_seq_ctl_shadow &= ~0x40000000; osEPiWriteIo(LEOPiInfo, ASIC_SEQ_CTL, LEOasic_seq_ctl_shadow); if (rwmode == 1) { tbl = wt_mseq_code; @@ -35,25 +31,21 @@ void leoSet_mseq(u16 rwmode) { for (i = 0; i < 0x10; i++, tbl++) { mseq_tbl[i] = *tbl; } - sct_byte_x = sct_byte_u = LEOtgt_param.sec_bytes - 1; sct_byte_u += 7; sct_byte_x <<= 8; mseq_tbl[4] |= sct_byte_x; - osWritebackDCache(mseq_tbl, 0x40); LEOPiDmaParam.dramAddr = mseq_tbl; LEOPiDmaParam.devAddr = MSEQ_RAM_ADDR; LEOPiDmaParam.size = 0x40; LEOPiInfo->transferInfo.cmdType = 2; - osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, 1); + osEPiStartDma(LEOPiInfo, &LEOPiDmaParam, OS_WRITE); osRecvMesg(&LEOdma_que, NULL, OS_MESG_BLOCK); - osEPiWriteIo(LEOPiInfo, ASIC_SEC_BYTE, (sct_byte_u | 0x5900) << 0x10); - + osEPiWriteIo(LEOPiInfo, ASIC_SEC_BYTE, (sct_byte_u | 0x5900) << 16); if (LEOrw_flags & 0x800) { sct_byte_x += 0x100; } - osEPiWriteIo(LEOPiInfo, ASIC_HOST_SECBYTE, sct_byte_x << 8); LEOasic_seq_ctl_shadow |= 0x40000000; osEPiWriteIo(LEOPiInfo, ASIC_SEQ_CTL, LEOasic_seq_ctl_shadow); diff --git a/src/libleo/leo/leoram.c b/src/libleo/leo/leoram.c index 159aaaae279..e295d472a57 100644 --- a/src/libleo/leo/leoram.c +++ b/src/libleo/leo/leoram.c @@ -1,41 +1,29 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" +// should be in another file leosysdata.c but alignment prevents that leo_sys_form LEO_sys_data; OSThread LEOcommandThread; OSThread LEOinterruptThread; - STACK(LEOcommandThreadStack, 0x400); STACK(LEOinterruptThreadStack, 0x400); - OSMesgQueue LEOcommand_que; OSMesgQueue LEOevent_que; OSMesgQueue LEOcontrol_que; OSMesgQueue LEOdma_que; OSMesgQueue LEOblock_que; - -OSMesg LEOevent_que_buf[1]; -OSMesg LEOcontrol_que_buf[1]; +OSMesg LEOevent_que_buf; +OSMesg LEOcontrol_que_buf; OSMesg LEOdma_que_buf[2]; -OSMesg LEOblock_que_buf[1]; - +OSMesg LEOblock_que_buf; u8* LEOwrite_pointer; LEOCmd* LEOcur_command; - u32 LEOasic_bm_ctl_shadow; u32 LEOasic_seq_ctl_shadow; - u8 LEOdrive_flag; vu8 LEOclr_que_flag; - -// volatile? -vu16 LEOrw_flags; - +u16 LEOrw_flags; u8 LEOdisk_type; - tgt_param_form LEOtgt_param; - u32 LEO_country_code; diff --git a/src/libleo/leo/leord_capa.c b/src/libleo/leo/leord_capa.c index 86b71ac903e..7dc0c3ddb47 100644 --- a/src/libleo/leo/leord_capa.c +++ b/src/libleo/leo/leord_capa.c @@ -1,17 +1,15 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoRd_capacity(void) { - if (LEOcur_command->header.control & LEO_CONTROL_WRT) { // Possibly LEO_CONTROL_TBL - LEOcur_command->data.readWrite.lba = LEORAM_START_LBA[LEOdisk_type] - 0x18; - LEOcur_command->data.readWrite.transferBlks = 0x10C3; - LEOcur_command->data.readWrite.buffPtr = (void*)LEORAM_BYTE[LEOdisk_type]; + if (LEOcur_command->header.control & 1) { + LEOcur_command->data.readwrite.lba = LEORAM_START_LBA[LEOdisk_type] - 0x18; + LEOcur_command->data.readwrite.xfer_blks = 0x10C3; + LEOcur_command->data.readwrite.buff_ptr = (void*)LEORAM_BYTE[LEOdisk_type]; } else { - LEOcur_command->data.readWrite.lba = 0; - LEOcur_command->data.readWrite.transferBlks = 0x10C3; - LEOcur_command->data.readWrite.buffPtr = (void*)0x3D78F40; // Total capacity, approx. 64.45 MB + LEOcur_command->data.readwrite.lba = 0; + LEOcur_command->data.readwrite.xfer_blks = 0x10C3; + LEOcur_command->data.readwrite.buff_ptr = (void*)0x03D78F40; } LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leord_diskid.c b/src/libleo/leo/leord_diskid.c index df4d6bf24b9..715723a850b 100644 --- a/src/libleo/leo/leord_diskid.c +++ b/src/libleo/leo/leord_diskid.c @@ -1,16 +1,11 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" extern vu16 LEOrw_flags; -extern u8 LEO_TempBuffer[0xE8]; -const u8 leo_disk_id_lba[] = { 14, 15 }; +STATIC const LEOCmdRead read_id_cmd = { { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, NULL }, 0xE, 1, LEO_TempBuffer, 0 }; -LEOCmdRead read_id_cmd = { - { LEO_COMMAND_READ, 0, 0, 0, 0, 0, 0, 0, 0 }, 14, 1, LEO_TempBuffer, 0, -}; +STATIC const u8 leo_disk_id_lba[2] = { 0xE, 0xF }; void leoReadDiskId(void) { LEOCmdRead dummy_cmd; @@ -22,7 +17,7 @@ void leoReadDiskId(void) { // Read Disk ID to Temp Buffer LEOcur_command = (LEOCmd*)&dummy_cmd; - for (cntr = 0; cntr < (sizeof(leo_disk_id_lba)); cntr++) { + for (cntr = 0; cntr < 2; cntr++) { LEOrw_flags = 0x2000; dummy_cmd = read_id_cmd; dummy_cmd.lba = leo_disk_id_lba[cntr]; @@ -36,7 +31,7 @@ void leoReadDiskId(void) { LEOcur_command = (LEOCmd*)temp_pointer; // Copy Disk ID to buffer pointed by ReadDiskID command - temp_pointer = (u8*)LEOcur_command->data.readdiskid.bufferPointer; + temp_pointer = (u8*)LEOcur_command->data.readdiskid.buffer_pointer; for (cntr = 0; cntr < (sizeof(LEODiskID)); cntr += sizeof(u32)) { *(u32*)temp_pointer = *((u32*)&LEO_TempBuffer[cntr]); temp_pointer += sizeof(u32); diff --git a/src/libleo/leo/leoread.c b/src/libleo/leo/leoread.c index 11dc28c41c0..c50d26e9944 100644 --- a/src/libleo/leo/leoread.c +++ b/src/libleo/leo/leoread.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" extern vu16 LEOrw_flags; @@ -10,26 +8,24 @@ void leoRead(void) { leoRead_common(0x18); } -extern OSMesgQueue LEOc2ctrl_que; - void leoRead_common(unsigned int offset) { - u32 tg_lba = LEOcur_command->data.readWrite.lba; - u32 tg_blocks = LEOcur_command->data.readWrite.transferBlks; + u32 tg_lba; + u32 tg_blocks; u32 message; u16 retry_cnt; - if ((tg_lba | tg_blocks) & 0xFFFF0000) { + tg_lba = LEOcur_command->data.readwrite.lba; + tg_blocks = LEOcur_command->data.readwrite.xfer_blks; + if (((tg_lba | tg_blocks) & 0xFFFF0000) != 0) { goto invalid_lba; } - tg_lba += offset; - if ((tg_lba + tg_blocks) > 0x10DC) { // Unclear what this number represents + if ((tg_lba + tg_blocks) >= 0x10DD) { invalid_lba: LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if (tg_blocks == 0) { if (tg_lba >= 0x10DC) { goto invalid_lba; @@ -38,32 +34,28 @@ void leoRead_common(unsigned int offset) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - LEOtgt_param.lba = tg_lba; LEOrw_flags &= ~0xC000; osSendMesg(&LEOc2ctrl_que, NULL, OS_MESG_NOBLOCK); osStartThread(&LEOinterruptThread); - for (;;) { + while (1) { osRecvMesg(&LEOcontrol_que, (OSMesg*)&message, OS_MESG_BLOCK); - switch (message) { case 0x90000: goto read_complete; - case 0x80000: leoC2_Correction(); LEOrw_flags &= ~0x4000; + if (LEOcur_command) {} osSendMesg(&LEOc2ctrl_que, NULL, OS_MESG_NOBLOCK); break; - default: - LEOcur_command->header.sense = message; + LEOcur_command->header.sense = (u8)message; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } } - read_complete: LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; diff --git a/src/libleo/leo/leoreset.c b/src/libleo/leo/leoreset.c index 40eb56482c5..db3a427aacc 100644 --- a/src/libleo/leo/leoreset.c +++ b/src/libleo/leo/leoreset.c @@ -1,25 +1,24 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoClr_queue(void) { OSMesg clr_cmd; while (osRecvMesg(&LEOcommand_que, &clr_cmd, OS_MESG_NOBLOCK) == 0) { - ((LEOCmd*)clr_cmd)->header.sense = LEO_SENSE_COMMAND_TERMINATED; - ((LEOCmd*)clr_cmd)->header.status = LEO_STATUS_CHECK_CONDITION; - if (((LEOCmd*)clr_cmd)->header.control & LEO_CONTROL_POST) { - osSendMesg(((LEOCmd*)clr_cmd)->header.post, (OSMesg)LEO_SENSE_COMMAND_TERMINATED, OS_MESG_BLOCK); + ((LEOCmdHeader*)clr_cmd)->sense = LEO_SENSE_COMMAND_TERMINATED; + ((LEOCmdHeader*)clr_cmd)->status = LEO_STATUS_CHECK_CONDITION; + if (((LEOCmdHeader*)clr_cmd)->control & LEO_CONTROL_POST) { + osSendMesg(((LEOCmdHeader*)clr_cmd)->post, (OSMesg)LEO_ERROR_COMMAND_TERMINATED, OS_MESG_BLOCK); } } } void leoClr_reset(void) { - u32 code = leoAnalize_asic_status(); + u32 code; - if ((code == LEO_SENSE_COMMAND_PHASE_ERROR) || (code == LEO_SENSE_DEVICE_COMMUNICATION_FAILURE) || - (code == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED)) { + code = leoAnalize_asic_status(); + if (code == LEO_SENSE_COMMAND_PHASE_ERROR || code == LEO_SENSE_DEVICE_COMMUNICATION_FAILURE || + code == LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED) { LEOcur_command->header.sense = code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } else { diff --git a/src/libleo/leo/leorezero.c b/src/libleo/leo/leorezero.c index 9e28bf13a3c..ebbf6899280 100644 --- a/src/libleo/leo/leorezero.c +++ b/src/libleo/leo/leorezero.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoRezero(void) { u8 sense_code; @@ -9,7 +7,6 @@ void leoRezero(void) { do { sense_code = leoRecal_w(); - if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOtgt_param.cylinder = 0; LEOtgt_param.head = 0; @@ -17,12 +14,10 @@ void leoRezero(void) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leoseek.c b/src/libleo/leo/leoseek.c index 2f530ac726f..e55b6032921 100644 --- a/src/libleo/leo/leoseek.c +++ b/src/libleo/leo/leoseek.c @@ -1,33 +1,27 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoSeek(void) { - u32 tgt_tk; // Unused + u32 tgt_tk; u8 sense_code; u8 retry_cntr = 20; - if (LEOcur_command->data.seek.lba > LEO_LBA_MAX) { + if (LEOcur_command->data.readwrite.lba >= 0x10C4) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - leoLba_to_phys(LEOcur_command->data.seek.lba + 0x18); - + leoLba_to_phys(LEOcur_command->data.readwrite.lba + 0x18); do { sense_code = leoSeek_w(); if (sense_code == LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - if (leoChk_err_retry(sense_code) != 0) { break; } } while (retry_cntr--); - LEOcur_command->header.sense = sense_code; - LEOcur_command->header.status = LEO_SENSE_DIAGNOSTIC_FAILURE; + LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; } diff --git a/src/libleo/leo/leotempbuffer.c b/src/libleo/leo/leotempbuffer.c index 5016051caff..2115409c43b 100644 --- a/src/libleo/leo/leotempbuffer.c +++ b/src/libleo/leo/leotempbuffer.c @@ -1,3 +1,4 @@ -#include "n64dd.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" u8 LEO_TempBuffer[0xE8]; diff --git a/src/libleo/leo/leotestunit.c b/src/libleo/leo/leotestunit.c index 4c81d7970a4..88a045f3e4c 100644 --- a/src/libleo/leo/leotestunit.c +++ b/src/libleo/leo/leotestunit.c @@ -1,10 +1,8 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoTest_unit_rdy(void) { - ((LEOCmdTestUnitReady*)LEOcur_command)->test = leoChk_cur_drvmode(); + LEOcur_command->data.time.pad = leoChk_cur_drvmode(); LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leotimer.c b/src/libleo/leo/leotimer.c index f6c7fdfc05f..d1995a44a85 100644 --- a/src/libleo/leo/leotimer.c +++ b/src/libleo/leo/leotimer.c @@ -1,10 +1,8 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" +#include "ultra64.h" +#include "ultra64/leo_internal.h" #include "ultra64/leodrive.h" #include "attributes.h" -#include "ultra64.h" - typedef struct { /* 0x0 */ u8 year; /* 0x1 */ u8 month; @@ -12,13 +10,14 @@ typedef struct { /* 0x3 */ u8 hour; /* 0x4 */ u8 minute; /* 0x5 */ u8 second; -} __LOCTime; +} __LOCTime; // size = 0x6 u8 __locReadTimer(__LOCTime* time); u8 __locSetTimer(__LOCTime* time); -static const u8 ymdupper[6] = { 99, 12, 31, 23, 59, 59 }; -static const u8 dayupper[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +STATIC const u8 ymdupper[] = { 99, 12, 31, 23, 59, 59 }; + +STATIC const u8 dayupper[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; void leoReadTimer(void) { u8* rdparam; @@ -33,17 +32,17 @@ void leoReadTimer(void) { LEOcur_command->data.time.hour = time.hour; LEOcur_command->data.time.minute = time.minute; LEOcur_command->data.time.second = time.second; - if (sense_code != 0) { + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.sense = sense_code; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if ((u8)LEOcur_command->data.time.yearlo >= 0x96U) { + if (LEOcur_command->data.time.yearlo >= 0x96U) { LEOcur_command->data.time.yearhi = 0x19; } else { LEOcur_command->data.time.yearhi = 0x20; } - LEOcur_command->header.status = 0; + LEOcur_command->header.status = LEO_STATUS_GOOD; } void leoSetTimer(void) { @@ -115,7 +114,7 @@ void leoSetTimer(void) { // Set the new time result = __locSetTimer(&time); - if (result != 0) { + if (result != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { LEOcur_command->header.sense = result; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; @@ -138,55 +137,55 @@ void leoSetTimer(void) { LEOcur_command->header.status = LEO_STATUS_GOOD; } -// static -u8 __locReadTimer(__LOCTime* time) { +STATIC u8 __locReadTimer(__LOCTime* time) { u32 data; u8 sense_code; - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x140000, 0U); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x140000, 0); if (sense_code != 0) { return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - time->minute = (u8)((u32)(data & 0xFF000000) >> 0x18); - time->second = (s8)((u32)(data & 0xFF0000) >> 0x10); - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x130000, 0U); - if (sense_code != 0) { - time->minute = (u8)(time->minute & 0xFF7F); + time->minute = (u8)((u32)(data & 0xFF000000) >> 24); + time->second = (s8)((u32)(data & 0xFF0000) >> 16); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x130000, 0); + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + time->minute &= ~0x80; return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - time->day = (s8)((u32)(data & 0xFF000000) >> 0x18); - time->hour = (s8)((u32)(data & 0xFF0000) >> 0x10); - sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x120000, 0U); - if (sense_code != 0) { - time->minute = (u8)(time->minute & 0xFF7F); + time->day = (s8)((u32)(data & 0xFF000000) >> 24); + time->hour = (s8)((u32)(data & 0xFF0000) >> 16); + sense_code = leoSend_asic_cmd_w_nochkDiskChange(0x120000, 0); + if (sense_code != LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { + time->minute &= ~0x80; return sense_code; } osEPiReadIo(LEOPiInfo, ASIC_DATA, &data); - sense_code = time->minute; - time->year = (s8)((u32)(data & 0xFF000000) >> 0x18); - time->month = (s8)((u32)(data & 0xFF0000) >> 0x10); - if (sense_code & 0x80) { - time->minute = (u8)(sense_code & 0xFF7F); - return 5; + time->year = (s8)((u32)(data & 0xFF000000) >> 24); + time->month = (s8)((u32)(data & 0xFF0000) >> 16); + if (time->minute & 0x80) { + time->minute &= ~0x80; + return LEO_SENSE_REAL_TIME_CLOCK_FAILURE; } - return 0; + return LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; } -// static -u8 __locSetTimer(__LOCTime* time) { +STATIC u8 __locSetTimer(__LOCTime* time) { u32 YearMonthX10000h; u32 DayHourX10000h; u32 MinuteSecondX10000h; u8 result; - YearMonthX10000h = (time->year << 0x18) + (time->month << 0x10); - DayHourX10000h = (time->day << 0x18) + (time->hour << 0x10); - MinuteSecondX10000h = (time->minute << 0x18) + (time->second << 0x10); - if ((result = leoSend_asic_cmd_w_nochkDiskChange(0xF0000, YearMonthX10000h)) != 0 || - (result = leoSend_asic_cmd_w_nochkDiskChange(0x100000, DayHourX10000h)) != 0 || - (result = leoSend_asic_cmd_w_nochkDiskChange(0x110000, MinuteSecondX10000h)) != 0) { + YearMonthX10000h = (time->year << 24) + (time->month << 16); + DayHourX10000h = (time->day << 24) + (time->hour << 16); + MinuteSecondX10000h = (time->minute << 24) + (time->second << 16); + if ((result = leoSend_asic_cmd_w_nochkDiskChange(0xF0000, YearMonthX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION || + (result = leoSend_asic_cmd_w_nochkDiskChange(0x100000, DayHourX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION || + (result = leoSend_asic_cmd_w_nochkDiskChange(0x110000, MinuteSecondX10000h)) != + LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION) { return result; } return 0; diff --git a/src/libleo/leo/leotranslat.c b/src/libleo/leo/leotranslat.c index 6eb2011367b..e779b83c7f0 100644 --- a/src/libleo/leo/leotranslat.c +++ b/src/libleo/leo/leotranslat.c @@ -1,7 +1,5 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" void leoTranslate(void) { u32 lba; @@ -10,32 +8,28 @@ void leoTranslate(void) { u32 byte_p_blk; u16 zone; u16 vzone; - u8 flag; // boolean + u8 flag; - if (LEOcur_command->data.readWrite.lba >= NUM_LBAS) { + if (LEOcur_command->data.readwrite.lba >= 0x10C4) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - lba = LEOcur_command->data.readWrite.lba + 0x18; + lba = LEOcur_command->data.readwrite.lba + 0x18; calc_blks = 0; calc_bytes = 0; flag = vzone = 1; - - if (LEOcur_command->header.control & LEO_CONTROL_TBL) { - calc_bytes = LEOcur_command->data.readWrite.transferBlks; - + if (LEOcur_command->header.control & 1) { + calc_bytes = LEOcur_command->data.readwrite.xfer_blks; while (calc_bytes != 0) { - if (flag || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { + if ((flag != 0) || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { vzone = leoLba_to_vzone(lba); zone = LEOVZONE_PZONEHD_TBL[LEOdisk_type][vzone]; - if (zone >= 8) { + if (zone > 7) { zone -= 7; } byte_p_blk = LEOBYTE_TBL2[zone]; } - if (calc_bytes < byte_p_blk) { calc_bytes = 0; } else { @@ -43,41 +37,36 @@ void leoTranslate(void) { } calc_blks++; lba++; - if ((calc_bytes != 0) && (lba >= 0x10DC)) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - flag = false; + flag = 0; } - LEOcur_command->data.readWrite.buffPtr = (void*)calc_blks; + LEOcur_command->data.readwrite.buff_ptr = (void*)calc_blks; } else { - calc_blks = LEOcur_command->data.readWrite.transferBlks; - + calc_blks = LEOcur_command->data.readwrite.xfer_blks; while (calc_blks != 0) { - if (flag || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { + if ((flag != 0) || (LEOVZONE_TBL[LEOdisk_type][vzone] == lba)) { vzone = leoLba_to_vzone(lba); zone = LEOVZONE_PZONEHD_TBL[LEOdisk_type][vzone]; - if (zone >= 8) { + if (zone > 7) { zone -= 7; } byte_p_blk = LEOBYTE_TBL2[zone]; } - calc_bytes += byte_p_blk; calc_blks--; lba++; - if ((calc_blks != 0) && (lba >= 0x10DC)) { LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - flag = false; + flag = 0; } - LEOcur_command->data.readWrite.buffPtr = (void*)calc_bytes; + LEOcur_command->data.readwrite.buff_ptr = (void*)calc_bytes; } - LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/libleo/leo/leoutil.c b/src/libleo/leo/leoutil.c index e90ea1f678e..5c4e2a0a081 100644 --- a/src/libleo/leo/leoutil.c +++ b/src/libleo/leo/leoutil.c @@ -1,8 +1,6 @@ -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" -#include "array_count.h" #include "ultra64.h" +#include "ultra64/leo_internal.h" +#include "array_count.h" u16 leoLba_to_phys(u32 lba) { u16 vzone_num; diff --git a/src/libleo/leo/leowrite.c b/src/libleo/leo/leowrite.c index 91b2163f0be..f9ff9a30c50 100644 --- a/src/libleo/leo/leowrite.c +++ b/src/libleo/leo/leowrite.c @@ -1,54 +1,45 @@ #include "ultra64.h" -#include "ultra64/leo.h" -#include "ultra64/leoappli.h" -#include "ultra64/leodrive.h" +#include "ultra64/leo_internal.h" -extern u16 LEOrw_flags; // N.B. NOT volatile in this file! +extern u16 LEOrw_flags; void leoWrite(void) { u32 message; u32 start_lba; u32 xfer_blk; - u32 write_bytes = 0; - u8 retry_count = 0; + u32 temp_v1; - start_lba = LEOcur_command->data.readWrite.lba; - xfer_blk = LEOcur_command->data.readWrite.transferBlks; - if (((start_lba | xfer_blk) & 0xFFFF0000) != 0) { + start_lba = LEOcur_command->data.readwrite.lba; + xfer_blk = LEOcur_command->data.readwrite.xfer_blks; + if ((((u32)(LEOcur_command->data.readwrite.lba | xfer_blk) >> 16) != 0)) { goto invalid_lba; } - - start_lba += 0x18; - if ((start_lba >= 0x10DC) || (start_lba + xfer_blk > 0x10DC)) { + temp_v1 = start_lba + 0x18; + if ((temp_v1 >= 0x10DC) || ((u32)(temp_v1 + xfer_blk) >= 0x10DD)) { invalid_lba: LEOcur_command->header.sense = LEO_SENSE_LBA_OUT_OF_RANGE; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - - if (start_lba < LEORAM_START_LBA[LEOdisk_type]) { + if (temp_v1 < (u16)LEORAM_START_LBA[LEOdisk_type]) { LEOcur_command->header.sense = LEO_SENSE_WRITE_PROTECT_ERROR; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - if (xfer_blk == 0) { LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; return; } - LEOrw_flags = 0x8000; - LEOtgt_param.lba = start_lba; + LEOtgt_param.lba = temp_v1; osStartThread(&LEOinterruptThread); osRecvMesg(&LEOcontrol_que, (OSMesg*)&message, OS_MESG_BLOCK); - if (message != 0x90000) { - LEOcur_command->header.sense = message; + LEOcur_command->header.sense = (u8)message; LEOcur_command->header.status = LEO_STATUS_CHECK_CONDITION; return; } - LEOcur_command->header.sense = LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION; LEOcur_command->header.status = LEO_STATUS_GOOD; } diff --git a/src/n64dd/n64dd_0.c b/src/n64dd/n64dd_0.c new file mode 100644 index 00000000000..750bc86db1f --- /dev/null +++ b/src/n64dd/n64dd_0.c @@ -0,0 +1,553 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/sleep.h" +#include "array_count.h" +#include "fault.h" +#include "gfx.h" +#include "stackcheck.h" +#include "sys_freeze.h" +#include "versions.h" +#include "audio.h" +#include "line_numbers.h" + +#pragma increment_block_number "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" + +s32 func_801C8310(struct_801E1598* arg0); + +void* D_801D36D0 = gN64DDDiskReadTemporaryBuffer; +s32 (*D_801D36D4)(struct_801E1598*) = func_801C8310; + +struct_801C79DC D_801DA410; +struct_801DA5C8 D_801DA4B0; +struct_801DA5C8* D_801DA5C8; +struct_801DA5D0 D_801DA5D0; +OSMesgQueue D_801DA600; +OSMesgQueue D_801DA618; +OSMesg D_801DA630; +OSMesg D_801DA634; +vu8 D_801DA638; +volatile OSTime D_801DA640; +s32 D_801DA648; +s32 D_801DA64C; +s32 D_801DA650; +s32 D_801DA654; +OSThread D_801DA658; +STACK(D_801DA808, 0x1000); +StackEntry D_801DB808; +STACK(D_801DB828, 0x1000); +StackEntry D_801DC828; +s32 D_801DC844; + +u32 func_801C6E80(void) { +#if OOT_NTSC + return LeoDriveExist(); +#else + return 0; +#endif +} + +void func_801C6EA0(Gfx** gfxP) { +} + +void func_801C776C(void) { + if (D_80121214 == 0) { + func_800F6BDC(); + D_80121214 = 1; + } +} + +s32 func_801C77B0(void) { + return D_80121214 != 0; +} + +s32 func_801C77C8(void) { + if (D_80121214 != 0) { + return 1; + } + return 1; +} + +void func_801C77F0(void) { + func_801C776C(); + while (func_801C77C8() == 0) { + Sleep_Usec(1000000 / 60); + } +} + +void func_801C7838(void) { + if (D_80121214 != 0) { + D_80121214 = 0; + func_800F6B3C(); + } +} + +s32 func_801C786C(void) { + if (D_80121213 == 0) { + return 0; + } + D_80121213 = 0; + return 1; +} + +void func_801C7898(void) { + while (func_801C786C() == 0) { + Sleep_Usec(1000000 / 60); + } +} + +void func_801C78D8(void) { + if (D_80121213 != 0) { + Fault_AddHungupAndCrash("../z_n64dd.c", LN2(503, 551, 573)); + } + D_80121213 = 1; +} + +s32 func_801C7924(void) { + s32 (*p)(struct_801DA5D0*); + + D_801DA5D0.unk0 = 5; + p = func_801C8860; + return p(&D_801DA5D0); +} + +s32 func_801C7958(void) { + s32 sp1C; + s32 (*p)(struct_801DA5D0*); + +#if OOT_VERSION < PAL_1_0 + if (1) {} +#endif + + D_801DA5D0.unk0 = 0xA; + p = func_801C8860; + sp1C = p(&D_801DA5D0); + if (sp1C < 0) { + Freeze_CurrentThread(); + } + return sp1C; +} + +s32 func_801C79A4(void) { + return D_801DA648 == 1; +} + +s32 func_801C70FC(void) { + return func_801C79A4(); +} + +void func_801C79DC(void* arg) { + static void* D_801DC848; + + struct_801C79DC* arg0 = arg; + OSMesg sp58; + s32 var_s0; + void* temp_v0; + + sp58 = NULL; + arg0->unk98 = &gIrqMgr; + osCreateMesgQueue(&arg0->unk78, arg0->unk0, ARRAY_COUNT(arg0->unk0)); + IrqMgr_AddClient(arg0->unk98, &arg0->unk90, &arg0->unk78); + var_s0 = 0; + while (var_s0 == 0) { + osRecvMesg(&arg0->unk78, &sp58, OS_MESG_BLOCK); + switch (*(s16*)sp58) { + case 1: + temp_v0 = osViGetNextFramebuffer(); + if (D_801DC848 != temp_v0) { + D_801DC848 = temp_v0; + D_801DA638 = 1; + } + func_801C9318(); + break; + case 4: + LeoReset(); + break; + case 3: + var_s0 = 1; + break; + } + } + IrqMgr_RemoveClient(arg0->unk98, &arg0->unk90); +} + +LEODiskID D_801DC850; +s32 D_801DC870; + +#if OOT_VERSION >= NTSC_1_1 +void func_801C7B28(void) { + s32 temp_v1_2; + + if (D_801DA640 != 0) { + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +} +#endif + +void func_801C7268(void) { + s32 pad; + s32 sp18; + + sp18 = func_801C77B0(); + if (sp18 == 0) { + func_801C77F0(); + } + D_801DA638 = 1; + D_801DA640 = 0; + if (func_801C7924() == 1) { + func_801C7958(); + } else if (D_801DA648 != 0) { + D_801DA648 = 0; + } +#if OOT_VERSION == NTSC_1_0 + if (D_801DA640 != 0) { + s32 temp_v1_2; + + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + + (void)(osGetTime() - D_801DA640); + (void)OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + (void)OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +#else + if ((D_801D3728 == 1) || (D_801E17E0 == 1) || (D_801E17E4 == 1)) { + D_801DA640 = osGetTime(); + } + func_801C7B28(); +#endif + if (sp18 == 0) { + func_801C7838(); + } +} + +void func_801C7CB8(u16* arg0) { + u16* var_v0; + + var_v0 = arg0; + while (var_v0 < (arg0 + (SCREEN_WIDTH * SCREEN_HEIGHT))) { + *var_v0 = 1; + var_v0++; + } +} + +void func_801C7CEC(s32 arg0, s32 arg1, s32 arg2) { + s32 sp2C; + + if ((arg0 != 0) || (arg1 != 0) || (arg2 != 0)) { + sp2C = (intptr_t)osViGetNextFramebuffer() + 0x20000000; + if ((sp2C & 0xFFFFFF) != 0) { + if (D_801DA638 != 0) { + D_801DA638 = 0; + func_801C7CB8((u16*)sp2C); + D_801DA640 = osGetTime(); + } + if (arg0 != 0) { + func_801CAA60(BADCASTP arg0, 0x60, 0x20, 0xC0, 0x10, 0xB, BADCASTP sp2C, 0x140); + } + if (arg1 != 0) { + func_801CAA60(BADCASTP arg1, 0, 0x50, 0x140, 0x40, 0xB, BADCASTP sp2C, 0x140); + } + if (arg2 != 0) { + func_801CAA60(BADCASTP arg2, 0, 0xB0, 0x140, 0x20, 0xB, BADCASTP sp2C, 0x140); + } +#if OOT_VERSION < PAL_1_0 + osViBlack(0); +#endif + } + } +} + +void func_801C7E34(s32 arg0, s32 arg1, s32 arg2) { + if ((arg0 == 0) && (arg1 == 0) && (arg2 == 0)) { + return; + } + if (D_801DA638) {} + if (arg0 != 0) { + D_801DA64C = arg0; + } + if (arg1 != 0) { + D_801DA650 = arg1; + } + if (arg2 != 0) { + D_801DA654 = arg2; + } + func_801C7CEC(arg0, arg1, arg2); +} + +void func_801C7E94(void) { + Sleep_Msec(100); + func_801C7CEC(D_801DA64C, D_801DA650, D_801DA654); +} + +s32 func_801C7658(void) { + if (D_80121212 != 0) { + return 0; + } +#if OOT_VERSION < PAL_1_0 + StackCheck_Init(&D_801DB808, D_801DA808, STACK_TOP(D_801DA808), 0, 0x100, "ddmsg"); + osCreateThread(&D_801DA658, 9, func_801C79DC, &D_801DA410, STACK_TOP(D_801DA808), 0xD); + osStartThread(&D_801DA658); +#endif + osCreateMesgQueue(&D_801DA600, &D_801DA630, 1); + osCreateMesgQueue(&D_801DA618, &D_801DA634, 1); + StackCheck_Init(&D_801DC828, D_801DB828, STACK_TOP(D_801DB828), 0, 0x100, "n64dd"); + D_801DA5D0.unk1C_1.unk1C = &D_801DA600; + D_801DA5D0.unk1C_1.unk20 = &D_801DA618; + D_801DA5D0.unk1C_1.unk24 = 8; + D_801DA5D0.unk1C_1.unk28 = STACK_TOP(D_801DB828); + D_801DA5D0.unk1C_1.unk2C = 0xD; + D_801DA5D0.unk0 = 1; + (&func_801C8860)(&D_801DA5D0); + D_80121213 = 1; + func_801C7898(); + D_801DA5D0.unk0 = 2; + D_801DA5D0.unk10 = 6; + D_801DA5D0.unk14 = DmaMgr_DmaFromDriveRom; + D_801DA5D0.unkC = func_801C7E34; + (&func_801C8860)(&D_801DA5D0); + D_801DA5D0.unk0 = 0xD; + (&func_801C8860)(&D_801DA5D0); +#if OOT_VERSION >= PAL_1_0 + StackCheck_Init(&D_801DB808, D_801DA808, STACK_TOP(D_801DA808), 0, 0x100, "ddmsg"); + osCreateThread(&D_801DA658, 9, func_801C79DC, &D_801DA410, STACK_TOP(D_801DA808), 0xD); + osStartThread(&D_801DA658); +#endif + return 0; +} + +s32 func_801C7818(void) { + s32 (*p)(struct_801DA5D0*) = func_801C8860; + +#if OOT_VERSION >= NTSC_1_1 + D_801DA638 = 1; + D_801DA640 = 0; +#endif + D_801DA5D0.unk0 = 0xC; + p(&D_801DA5D0); + while (func_801C8A24() == 0) { + Sleep_Usec(1000000 / 60); + } +#if OOT_VERSION >= NTSC_1_1 + if ((D_801D3728 == 1) || (D_801E17E0 == 1) || (D_801E17E4 == 1)) { + D_801DA640 = osGetTime(); + } + func_801C7B28(); +#endif + if (func_801C8A24() != 2) { + func_801C7E94(); + Freeze_CurrentThread(); + return -3; + } + func_801C78D8(); + D_80121212 = 1; + return 0; +} + +s32 func_801C81AC(void) { + s32 var_v1; + + var_v1 = func_801C7658(); + if (var_v1 == 0) { + var_v1 = func_801C7818(); + } + return var_v1; +} + +void func_801C81E4(void) { + D_801DA5D0.unk0 = 0; + (&func_801C8860)(&D_801DA5D0); +} + +void func_801C8214(s32 arg0, void* arg1, s32 arg2) { + s32 (*p)(struct_801DA5D0*) = func_801C8860; + + D_801DA5D0.unk18 = arg1; + D_801DA5D0.unk1C_3_4.unk1C = arg0; + D_801DA5D0.unk1C_3_4.unk20 = arg2; + D_801DA5D0.unk0 = 3; + p(&D_801DA5D0); + osGetTime(); + D_801DA5D0.unk0 = 6; + while (p(&D_801DA5D0) != 0) { + Sleep_Usec(1000000 / 60); + } + D_801DA5D0.unk0 = 7; + if (p(&D_801DA5D0) != 0) { + Freeze_CurrentThread(); + } +} + +void func_801C82C0(void* arg0, s32 arg1, s32 arg2) { + D_801DA5D0.unk18 = arg0; + D_801DA5D0.unk1C_3_4.unk1C = arg1; + D_801DA5D0.unk1C_3_4.unk20 = arg2; + D_801DA5D0.unk0 = 4; + (&func_801C8860)(&D_801DA5D0); +} + +void func_801C8304(LEODiskID* arg0) { +} + +s32 func_801C8310(struct_801E1598* arg0) { + func_801C8304(&arg0->unk38); + if (D_801DC870 == 0) { + if ( +#if OOT_NTSC + (bcmp(&arg0->unk38, "EZLJ", 4) == 0) || (bcmp(&arg0->unk38, "EZLE", 4) == 0) +#else + (bcmp(&arg0->unk38, "EZLP", 4) == 0) +#endif + ) { + D_801DC850 = arg0->unk38; + D_801DC870 = 1; + D_801DA648 = 1; + } else { + D_801DA648 = 2; + } + } else if (bcmp(&D_801DC850, &arg0->unk38, 0x20) == 0) { + D_801DA648 = 1; + } else { + D_801DA648 = 2; + } + return D_801DA648 == 1; +} + +s32 func_801C843C(s32 arg0, s32* arg1, s32* arg2) { + s32 sp2C; + s32 pad; + u32 sp24; + s32 sp20; + s32 v; + + v = LeoByteToLBA(1, arg0 + 1, &sp2C); + if (v != LEO_ERROR_GOOD) { + return v; + } + sp24 = sp2C - 1; + if (sp2C == 1) { + sp20 = 0; + } else { + v = LeoLBAToByte(1, sp24, &sp20); + if (v != LEO_ERROR_GOOD) { + return v; + } + } + *arg1 = sp24 + 1; + *arg2 = arg0 - sp20; + return LEO_ERROR_GOOD; +} + +s32 func_801C84E0(s32 arg0) { + s32 sp1C; + + if (LeoLBAToByte(arg0, 1, &sp1C) == LEO_ERROR_GOOD) { + return sp1C; + } else { + return 0; + } +} + +void func_801C7C1C(void* dest, s32 offset, s32 size) { + s32 sp44; + s32 sp40; + s32 sp3C; + s32 sp38; + void* sp34; + s32 temp_v0; + s32 var_s0; + s32 var_s1; + + func_801C7898(); + func_801C77F0(); + D_801DA638 = 1; + D_801DA640 = 0; + func_801C843C(offset, &sp44, &sp3C); + func_801C843C(offset + size, &sp40, &sp38); + sp34 = D_801D36D0; + if (sp44 == sp40) { + func_801C8214(sp44, sp34, func_801C84E0(sp44)); + bcopy((u8*)sp34 + sp3C, dest, size); + } else { + var_s1 = 0; + func_801C8214(sp44, sp34, func_801C84E0(sp44)); + bcopy((u8*)sp34 + sp3C, dest, func_801C84E0(sp44) - sp3C); + temp_v0 = sp44 + 1; + if (temp_v0 < sp40) { + var_s0 = temp_v0; + while (var_s0 < sp40) { + var_s1 += func_801C84E0(var_s0); + var_s0 += 1; + } + func_801C8214(sp44 + 1, (void*)((func_801C84E0(sp44) + (s32)dest) - sp3C), var_s1); + } + if (sp38 > 0) { + func_801C8214(sp40, sp34, func_801C84E0(sp40)); + bcopy(sp34, (void*)(((func_801C84E0(sp44) + (s32)dest) - sp3C) + var_s1), sp38); + } + } +#if OOT_VERSION == NTSC_1_0 + if (D_801DA640 != 0) { + s32 temp_v1_2; + + temp_v1_2 = OS_CYCLES_TO_USEC(osGetTime() - D_801DA640); + if ((1000000 - temp_v1_2) > 0) { + Sleep_Usec(1000000 - temp_v1_2); + } + } +#else + func_801C7B28(); +#endif + func_801C78D8(); + func_801C7838(); +} + +void func_801C7E78(void) { +} + +s32 func_801C86F8(void) { + s32 sp24; + s32 sp20; + s32 pad; + void* sp18; + + if (D_801DA5C8 != NULL) { + return -1; + } + D_801DA5C8 = &D_801DA4B0; + func_801C7C1C(D_801DA5C8, 0x1060, sizeof(*D_801DA5C8)); + sp24 = D_801DA5C8->unk4 - D_801DA5C8->unk0; + sp20 = (char*)D_801DA5C8->unkC - (char*)D_801DA5C8->unk8; + sp18 = (char*)D_801DA5C8->unk8 + sp24; + func_801C7C1C(D_801DA5C8->unk8, D_801DA5C8->unk0, sp24); + bzero(sp18, sp20 - sp24); + func_800AD4C0(D_801DA5C8->unk10); + return 0; +} + +s32 func_801C879C(void) { + if (D_801DA5C8 == NULL) { + return -1; + } + func_800AD51C(); + bzero(D_801DA5C8->unk8, (char*)D_801DA5C8->unkC - (char*)D_801DA5C8->unk8); + bzero(D_801DA5C8, sizeof(*D_801DA5C8)); + D_801DA5C8 = NULL; + return 0; +} + +void n64dd_SetDiskVersion(s32 arg0) { + if (arg0 != 0) { + if (D_801DA5C8 == 0) { + func_801C86F8(); + } + } else if (D_801DA5C8 != 0) { + func_801C879C(); + } +} diff --git a/src/n64dd/n64dd_data_buffer.c b/src/n64dd/n64dd_1.c similarity index 87% rename from src/n64dd/n64dd_data_buffer.c rename to src/n64dd/n64dd_1.c index 00a09a69b61..4b05443c758 100644 --- a/src/n64dd/n64dd_data_buffer.c +++ b/src/n64dd/n64dd_1.c @@ -1,4 +1,6 @@ +#include "ultra64.h" #include "n64dd.h" +#include "n64dd_internal.h" /** * Buffer used during the process of reading from the disk diff --git a/src/n64dd/n64dd_2.c b/src/n64dd/n64dd_2.c new file mode 100644 index 00000000000..823cc3d050a --- /dev/null +++ b/src/n64dd/n64dd_2.c @@ -0,0 +1,333 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "array_count.h" +#include "region.h" +#include "z_locale.h" + +#pragma increment_block_number "" + +void func_801C8A4C(struct_801E1598*); +void func_801C8B8C(struct_801E1598*); +void func_801C8C00(struct_801E1598*); +void func_801C8C74(struct_801E1598*); +s32 func_801C9A50(struct_801E1598*); +s32 func_801C9AD0(struct_801E1598*); +s32 func_801C9C34(struct_801E1598*); +void func_801C8DB4(void); +void func_801C8DD8(OSMesgQueue*, OSMesgQueue*, s32, void*, s32); +void func_801C8E98(void (*)(s32, s32, s32), s32, void (*)(void*, uintptr_t, size_t)); +void func_801C8EEC(void*, s32, s32, u8); +s8 func_801C8FD0(void); +s32 func_801C9020(void); +s32 func_801C905C(void); +s32 func_801C90A4(void); +s32 func_801C90BC(void); +s32 func_801C9114(void); +s32 func_801C916C(void); + +s32 D_801D36E0 = 0; +s32 D_801D36E4 = 0; +struct { + void (*unk0)(struct_801E1598*); + s32 (*unk4)(struct_801E1598*); +} D_801D36E8[5] = { + { func_801C8A4C, func_801C9A50 }, { func_801C8B8C, func_801C9AD0 }, { func_801C8C00, func_801C9AD0 }, + { func_801C8C74, func_801C9BA4 }, { func_801C8C74, func_801C9C34 }, +}; +s32 D_801D3710 = 0; + +struct_801E1590 D_801E1590; +struct_801E1598 D_801E1598; +OSMesg D_801E1608; +OSMesg D_801E1610[8]; +OSThread D_801E1630; + +s32 func_801C8860(struct_801DA5D0* arg0) { + s32 temp_v0_2; + s8 temp_v0; + + switch (arg0->unk0) { + case 0: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8DB4(); + return 0; + case 1: + func_801C8DD8(arg0->unk1C_1.unk1C, arg0->unk1C_1.unk20, arg0->unk1C_1.unk24, arg0->unk1C_1.unk28, + arg0->unk1C_1.unk2C); + return 0; + case 2: + func_801C8E98(arg0->unkC, arg0->unk10, arg0->unk14); + return 0; + case 3: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8EEC(arg0->unk18, arg0->unk1C_3_4.unk1C, arg0->unk1C_3_4.unk20, 1); + return 0; + case 4: + if (func_801C90A4() != 0) { + return 1; + } + func_801C8EEC(arg0->unk18, arg0->unk1C_3_4.unk1C, arg0->unk1C_3_4.unk20, 2); + return 0; + case 5: + temp_v0 = func_801C8FD0(); + arg0->unk8 = temp_v0; + return temp_v0 & 0xFF; + case 7: + return func_801C905C(); + case 6: + return func_801C90A4(); + case 8: + temp_v0_2 = func_801C9020(); + arg0->unk4 = temp_v0_2; + return temp_v0_2; + case 9: + return func_801C90BC(); + case 10: + return func_801C9114(); + case 11: + return func_801C916C(); + case 12: + D_801D3720 = 0; + break; + case 13: + D_801D3720 = 1; + break; + } + return 0; +} + +void func_801C89FC(s32 arg0) { + if (arg0 != 0) { + D_801D36E0 = 1; + return; + } + D_801D36E0 = 2; +} + +s32 func_801C8A24(void) { + return D_801D36E0; +} + +s32 func_801C8A34(void) { + return D_801D36E4 == 1; +} + +void func_801C8A4C(struct_801E1598* arg0) { + osCreateMesgQueue(&arg0->unk1C, &D_801E1608, 1); + if (gCurrentRegion == REGION_JP) { + arg0->unk68 = LeoCJCreateLeoManager(149, 150, D_801E1610, ARRAY_COUNT(D_801E1610)); + } else { + arg0->unk68 = LeoCACreateLeoManager(149, 150, D_801E1610, ARRAY_COUNT(D_801E1610)); + } + if ((arg0->unk68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) || (arg0->unk68 == LEO_ERROR_GOOD)) { + D_801D36E4 = 1; + } +} + +void func_801C8AF8(struct_801E1598* arg0) { + LEOCmd sp1C; + + LeoReadDiskID(&sp1C, &arg0->unk38, &arg0->unk1C); + osRecvMesg(&arg0->unk1C, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); +} + +void func_801C8B40(struct_801E1598* arg0) { + LEOCmd sp1C; + + LeoSpdlMotor(&sp1C, 4, &arg0->unk1C); + osRecvMesg(&arg0->unk1C, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); +} + +void func_801C8B8C(struct_801E1598* arg0) { + s32 sp34; + s32 sp30; + OSMesgQueue* sp28; + + sp30 = arg0->unk5C; + if (LeoByteToLBA(sp30, (u32)arg0->unk60, &sp34) == 0) { + sp28 = &arg0->unk1C; + LeoReadWrite(&arg0->unk0, OS_READ, (u32)sp30, arg0->unk58, (u32)sp34, sp28); + osRecvMesg(sp28, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); + } +} + +void func_801C8C00(struct_801E1598* arg0) { + s32 sp34; + void* sp30; + OSMesgQueue* sp28; + + sp30 = arg0->unk58; + if (LeoByteToLBA((s32)sp30, (u32)arg0->unk60, &sp34) == LEO_ERROR_GOOD) { + sp28 = &arg0->unk1C; + LeoReadWrite(&arg0->unk0, OS_WRITE, (u32)sp30, (void*)arg0->unk5C, (u32)sp34, sp28); + osRecvMesg(sp28, (OSMesg*)&arg0->unk68, OS_MESG_BLOCK); + } +} + +void func_801C8C74(struct_801E1598* arg0) { + arg0->unk68 = 9; +} + +void func_801C8C84(struct_801E1598* arg0) { + s32 (*temp_s2)(struct_801E1598*); + s32 temp_v0_2; + void (*temp_s1)(struct_801E1598*); + + arg0->unk68 = -1; + if ((func_801C8A34() != 0) || ((u8)arg0->unk64 == 0)) { + arg0->unk66 = 1; + temp_s1 = D_801D36E8[(u8)arg0->unk64].unk0; + temp_s2 = D_801D36E8[(u8)arg0->unk64].unk4; + do { + temp_s1(arg0); + temp_v0_2 = temp_s2(arg0); + } while (temp_v0_2 == 2); + arg0->unk6C = temp_v0_2; + if ((u8)arg0->unk64 == 0) { + func_801C89FC(temp_v0_2); + } + arg0->unk66 = 0; + } +} + +void func_801C8D34(void* arg0) { + void* sp24; + + while (true) { + osRecvMesg(D_801E1590.unk0, &sp24, OS_MESG_BLOCK); + func_801C8C84(sp24); + osSendMesg(D_801E1590.unk4, NULL, OS_MESG_BLOCK); + } +} + +void func_801C8DB4(void) { + osDestroyThread(&D_801E1630); +} + +void func_801C8DD8(OSMesgQueue* arg0, OSMesgQueue* arg1, s32 arg2, void* arg3, s32 arg4) { + D_801E1590.unk0 = arg0; + D_801E1590.unk4 = arg1; + osCreateThread(&D_801E1630, arg2, func_801C8D34, NULL, arg3, arg4); + osStartThread(&D_801E1630); +} + +void func_801C8E50(struct_801E1598* arg0, s32 arg1) { + if (arg1 == 1) { + func_801C8C84(arg0); + return; + } + osSendMesg(D_801E1590.unk0, arg0, OS_MESG_BLOCK); +} + +void func_801C8E98(void (*arg0)(s32, s32, s32), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)) { + struct_801E1598* ptr = &D_801E1598; + + func_801CA3C0(arg1, arg2); + D_801D3734 = BADCASTP arg0; + ptr->unk64 = 0; + ptr->unk65 = 0; + func_801C8E50(ptr, 0); +} + +void func_801C8EEC(void* arg0, s32 arg1, s32 arg2, u8 arg3) { + struct_801E1598* var = &D_801E1598; + + if (D_801D3710 == 1) { + D_801D3710 = 0; + var->unk64 = 4; + func_801C8E50(var, 1); + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return; + } + } + var->unk58 = arg0; + var->unk5C = arg1; + var->unk60 = arg2; + var->unk64 = arg3; + func_801C8E50(var, 0); +} + +s32 func_801C8F9C(struct_801E1598* arg0) { + u8 sp1F; + + arg0->unk68 = LeoTestUnitReady(&sp1F); + return (sp1F & 1) == 0; +} + +s8 func_801C8FD0(void) { + s32 temp_v0; + + temp_v0 = func_801C8F9C(&D_801E1598); + if (D_801E1598.unk68 == LEO_ERROR_BUSY) { + return 0; + } + if (temp_v0 == 0) { + return 2; + } + return 1; +} + +s32 func_801C9020(void) { + if ((func_801C90A4() == 0) && (D_801E1598.unk68 != LEO_ERROR_GOOD)) { + return D_801E1598.unk68; + } + return -1; +} + +s32 func_801C905C(void) { + s32* new_var; + + new_var = &D_801E1598.unk6C; + if ((func_801C90A4() == 0) && ((*new_var == 3) || (*new_var == 4))) { + return D_801E1598.unk68; + } + return 0; +} + +s32 func_801C90A4(void) { + return D_801E1598.unk66 == 1; +} + +s32 func_801C90BC(void) { + D_801E1598.unk64 = 3; + func_801C8E50(&D_801E1598, 1); +#if OOT_VERSION >= NTSC_1_1 + D_801D3710 = 0; +#endif + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return -1; + } else { + return D_801E1598.unk6C == 0; + } +} + +s32 func_801C9114(void) { + D_801E1598.unk64 = 4; + func_801C8E50(&D_801E1598, 1); +#if OOT_VERSION >= NTSC_1_1 + D_801D3710 = 0; +#endif + if ((D_801E1598.unk6C == 3) || (D_801E1598.unk6C == 4)) { + return -1; + } else { + return D_801E1598.unk6C == 0; + } +} + +s32 func_801C916C(void) { + s32 var_v1; + + if (LeoDriveExist() != 0) { + var_v1 = 8; + } else { + var_v1 = 0; + } + if (var_v1 == 0) {} + D_801E1598.unk68 = var_v1; + return var_v1 == 0; +} diff --git a/src/n64dd/n64dd_3.c b/src/n64dd/n64dd_3.c new file mode 100644 index 00000000000..11d90ae39c5 --- /dev/null +++ b/src/n64dd/n64dd_3.c @@ -0,0 +1,382 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/sleep.h" +#include "attributes.h" + +s32 D_801D3720 = 0; +void* D_801D3724 = NULL; +s32 D_801D3728 = 0; +void* D_801D372C = NULL; +void* D_801D3730 = NULL; +void (*D_801D3734)(void*, void*, void*) = NULL; + +s32 D_801E17E0; +s32 D_801E17E4; + +void func_801C91B0(s32 arg0) { + D_801D3724 = func_801CA698(arg0); + D_801D3728 = 1; +} + +void func_801C91E4(void) { + if (D_801D3728 == 1) { + D_801D3724 = func_801CA730(); + D_801D3728 = 0; + } +} + +void func_801C9228(s32 arg0) { + D_801D372C = func_801CA800(arg0); + D_801E17E0 = 1; +} + +void func_801C925C(void) { + if (D_801E17E0 == 1) { + D_801D372C = func_801CA86C(); + D_801E17E0 = 0; + } +} + +void func_801C92A0(s32 arg0) { + D_801D3730 = func_801CA8A0(arg0); + D_801E17E4 = 1; +} + +void func_801C92D4(void) { + if (D_801E17E4 == 1) { + D_801D3730 = func_801CA8E0(); + D_801E17E4 = 0; + } +} + +void func_801C9318(void) { + u32 temp_v0; + UNK_PTR sp20; + UNK_PTR sp1C; + UNK_PTR sp18; + + osRecvMesg(D_801E1590.unk4, NULL, OS_MESG_NOBLOCK); + if ((D_801D3734 != NULL) && (D_801D3720 == 0)) { + temp_v0 = osSetIntMask(OS_IM_NONE); + sp20 = D_801D3724; + sp1C = D_801D372C; + sp18 = D_801D3730; + D_801D3724 = NULL; + D_801D372C = NULL; + D_801D3730 = NULL; + osSetIntMask(temp_v0); + D_801D3734(sp20, sp1C, sp18); + } +} + +void func_801C93C8(s32 arg0, s32 arg1, s32 arg2) { + func_801C91B0(arg0); + func_801C9228(arg1); + func_801C92A0(arg2); +} + +void func_801C9400(void) { + func_801C91E4(); + func_801C925C(); + func_801C92D4(); +} + +s32 func_801C9430(struct_801E1598* arg0) { + if (((arg0->unk68 <= LEO_ERROR_ILLEGAL_TIMER_VALUE) || (arg0->unk68 >= LEO_ERROR_DEVICE_COMMUNICATION_FAILURE)) && + (arg0->unk68 != LEO_ERROR_INVALID_COMMAND_OPERATION_CODE) && (arg0->unk68 != LEO_ERROR_LBA_OUT_OF_RANGE)) { + func_801C91B0(arg0->unk68); + func_801C9228(3); + } + LeoClearQueue(); + return 4; +} + +s32 func_801C948C(struct_801E1598* arg0) { + s32 var_s0; + + while (true) { + var_s0 = 0; + Sleep_Msec(60); + func_801C8B40(arg0); + switch (arg0->unk68) { + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C92D4(); + return 0; + case LEO_ERROR_COMMAND_TERMINATED: + func_801C92D4(); + LeoClearQueue(); + return 3; + case LEO_ERROR_GOOD: + func_801C92A0(6); + FALLTHROUGH; + case LEO_ERROR_QUEUE_FULL: + var_s0 = 1; + FALLTHROUGH; + default: + if (var_s0 == 0) { + func_801C92D4(); + return func_801C9430(arg0); + } + break; + } + var_s0 = 1; //! FAKE + } +} + +s32 func_801C955C(struct_801E1598* arg0) { + switch (arg0->unk68) { + case LEO_ERROR_COMMAND_TERMINATED: + func_801C9400(); + LeoClearQueue(); + return 3; + case LEO_ERROR_DIAGNOSTIC_FAILURE: + func_801C91B0(arg0->unk68); + func_801C92A0(5); + return 9; + case LEO_ERROR_GOOD: + func_801C9400(); + return 0; + case LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED: + if ((u8)arg0->unk65 == 0) { + func_801C9400(); + arg0->unk65 = 2; + return 1; + } + FALLTHROUGH; + default: + func_801C9400(); + return func_801C9430(arg0); + case LEO_ERROR_QUEUE_FULL: + return 9; + } +} + +s32 func_801C9630(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + func_801C8AF8(arg0); + switch (arg0->unk68) { + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + func_801C91B0(arg0->unk68); + func_801C9228(2); + return 5; + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C9400(); + return 5; + default: + temp_v0 = func_801C955C(arg0); + if (temp_v0 != 9) { + return temp_v0; + } + Sleep_Msec(60); + break; + } + } +} + +s32 func_801C96E0(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + Sleep_Msec(60); + func_801C8AF8(arg0); + switch (arg0->unk68) { + case LEO_ERROR_QUEUE_FULL: + continue; + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + func_801C91B0(arg0->unk68); + func_801C9228(2); + FALLTHROUGH; + case LEO_ERROR_MEDIUM_NOT_PRESENT: + func_801C92A0(4); + continue; + } + temp_v0 = func_801C955C(arg0); + if (temp_v0 != 9) { + return temp_v0; + } + } +} + +s32 func_801C978C(struct_801E1598* arg0) { + if (D_801D36D4 != NULL) { + return D_801D36D4(arg0); + } + return 1; +} + +s32 func_801C97C8(struct_801E1598* arg0) { + s32 temp_v0; + s32 temp_v0_2; + + while (true) { + temp_v0_2 = func_801C96E0(arg0); + if ((temp_v0_2 == 3) || (temp_v0_2 == 4)) { + return temp_v0_2; + } else if ((temp_v0_2 & 0xFFFFFFFF) == 0) { + if (func_801C978C(arg0) != 0) { + return 2; + } + func_801C9228(1); + temp_v0 = func_801C948C(arg0); + if (temp_v0 != 0) { + return temp_v0; + } + func_801C925C(); + } + } +} + +s32 func_801C9870(struct_801E1598* arg0) { + s32 temp_v0_3; + s32 var_s0; + + while (true) { + var_s0 = func_801C96E0(arg0); + if ((var_s0 == 3) || (var_s0 == 4)) { + return var_s0; + } + + if ((var_s0 & 0xFFFFFFFF) == 0) { + func_801C9400(); + temp_v0_3 = func_801C978C(arg0); + if (temp_v0_3 != 0) { + return 2; + } + + if (var_s0 == 3) {} + if (var_s0 == 4) {} + if (var_s0 == 3) {} + if (var_s0 == 4) {} + func_801C9228(1); + + var_s0 = func_801C948C(arg0); + if (var_s0 != 0) { + return var_s0; + } + func_801C925C(); + if (temp_v0_3 != 0) { + return var_s0; + } + } + } +} + +s32 func_801C9934(struct_801E1598* arg0) { + func_801C91B0(arg0->unk68); + func_801C9228(2); + return func_801C9870(arg0); +} + +s32 func_801C996C(struct_801E1598* arg0) { + func_801C91B0(arg0->unk68); + return func_801C9870(arg0); +} + +s32 func_801C999C(struct_801E1598* arg0) { + s32 temp_v0; + s32 var_s0 = 0; + + while (true) { + LeoResetClear(); + temp_v0 = func_801C9630(arg0); + if ((temp_v0 == 3) || (temp_v0 == 4)) { + return temp_v0; + } + if (temp_v0 != 1) { + if (temp_v0 == 0) { + return temp_v0; + } + return temp_v0; + } + if (1) {} + Sleep_Msec(250); + if (var_s0++ < 0x1E) { + } else { + return func_801C9430(arg0); + } + } +} + +s32 func_801C9A50(struct_801E1598* arg0) { + if (arg0->unk68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) { + return func_801C9430(arg0); + } + if (osMemSize < 0x800000) { + func_801C93C8(0x2C, 0, 3); + return 4; + } + if (func_801C999C(arg0) == 0) { + D_801D3710 = 1; + } + return 0; +} + +s32 func_801C9AD0(struct_801E1598* arg0) { + s32 temp_v0; + + switch (arg0->unk68) { + case LEO_ERROR_UNRECOVERED_READ_ERROR: + func_801C8F9C(arg0); + temp_v0 = func_801C948C(arg0); + if (temp_v0 != 0) { + return temp_v0; + } + func_801C9400(); + return 2; + case LEO_ERROR_DIAGNOSTIC_FAILURE: + return func_801C97C8(arg0); + case LEO_ERROR_COMMAND_TERMINATED: + LeoClearQueue(); + return 3; + case LEO_ERROR_EJECTED_ILLEGALLY_RESUME: + return func_801C9934(arg0); + case LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED: + return func_801C9870(arg0); + case LEO_ERROR_MEDIUM_NOT_PRESENT: + return func_801C996C(arg0); + case LEO_ERROR_GOOD: + return 0; + case LEO_ERROR_QUEUE_FULL: + return 2; + default: + return func_801C9430(arg0); + } +} + +s32 func_801C9BA4(struct_801E1598* arg0) { + s32 temp_v0; + + while (true) { + if (1) {} + temp_v0 = func_801C9630(arg0); + if ((temp_v0 == 3) || (temp_v0 == 4) || (temp_v0 == 5)) { + return temp_v0; + } + if ((temp_v0 & 0xFFFFFFFF) == 0) { + if (func_801C978C(arg0) != 0) { + return 0; + } + return 7; + } + } +} + +s32 func_801C9C34(struct_801E1598* arg0) { + s32 v; + + while (true) { + v = func_801C9BA4(arg0); + if (v != 7) { + return v; + } + func_801C9228(1); + v = func_801C948C(arg0); + if (v != 0) { + return v; + } + func_801C925C(); + } +} diff --git a/src/n64dd/n64dd_4.c b/src/n64dd/n64dd_4.c new file mode 100644 index 00000000000..1bbc413cce0 --- /dev/null +++ b/src/n64dd/n64dd_4.c @@ -0,0 +1,230 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" + +void (*D_801D3740)(void*, uintptr_t, size_t) = NULL; + +s32 D_801E17F0; + +int func_801C9CB0(const char* arg0) { + if (((*arg0 >= 0x8E) && (*arg0 < 0xFF)) || ((*arg0 != 0x8F) && (*arg0 != 0xA0))) { + arg0++; + return (*arg0 >= 0xA0) && (*arg0 < 0xFF); + } + return 0; +} + +int func_801C9D04(u8* arg0) { + if (((*arg0 >= 0x81) && (*arg0 < 0xA0)) || ((*arg0 >= 0xE0) && (*arg0 < 0xFD))) { + arg0++; + return (*arg0 >= 0x40) && (*arg0 < 0xFD) && (*arg0 != 0x7F); + } + return 0; +} + +void func_801C9D68(char* arg0, u16 arg1) { + arg0[0] = arg1 >> 8; + arg0[1] = arg1 & 0xFF; +} + +u16 func_801C9D84(u16 arg0) { + return arg0 - 0x8080; +} + +u16 func_801C9DA4(u16 arg0) { + u8 temp_a2; + u8 temp_v0; + + temp_v0 = (arg0 >> 8) & 0xFF; + temp_a2 = arg0 & 0xFF; + if (temp_v0 & 1) { + temp_a2 += 0x1F; + if (temp_a2 >= 0x7F) { + temp_a2 += 1; + } + } else { + temp_a2 += 0x7E; + } + temp_v0 = ((temp_v0 - 0x21) / 2) + 0x81; + if (temp_v0 >= 0xA0) { + temp_v0 += 0x40; + } + return (temp_v0 << 8) + temp_a2; +} + +void func_801C9E30(void* arg0, uintptr_t arg1, size_t arg2) { + if (D_801D3740 != NULL) { + D_801D3740(arg0, arg1, arg2); + } +} + +s32 func_801C9E60(const char* arg0) { + return LeoGetKAdr(func_801C9DA4(func_801C9D84(((arg0[0] << 8) | arg0[1])))) + 0xA0000; +} + +s32 func_801C9EAC(s32* arg0, int* arg1, int* arg2, int* arg3, char arg4) { + u16 v; + s32 temp_v0; + + v = arg4 - 0x20; + v += D_801E17F0 * 0xC0; + temp_v0 = LeoGetAAdr(v, arg1, arg2, arg3); + *arg0 = (temp_v0 - (temp_v0 & 0xF)) + 0xA0000; + return temp_v0 & 0xF; +} + +s32 func_801C9F0C(void* arg0, int* arg1, int* arg2, int* arg3, const char* arg4) { + s32 sp24; + s32 var_v1; + + if (func_801C9CB0(arg4) != 0) { + sp24 = func_801C9E60(arg4); + *arg1 = 0x10; + var_v1 = 0; + *arg2 = 0x10; + *arg3 = 0xB; + } else { + var_v1 = func_801C9EAC(&sp24, arg1, arg2, arg3, *arg4); + } + func_801C9E30(arg0, sp24, 0x80); + return var_v1; +} + +s32 func_801C9FB0(u8* arg0, s32 arg1, u8 arg2) { + if (arg1 == 1) { + *arg0 = arg2 * 0x10; + return 0; + } else { + *arg0 |= arg2; + return 1; + } +} + +void* func_801C9FE8(void* arg0, s32* arg1, s32 arg2) { + arg0 = BADCASTP((uintptr_t)arg0 + (arg2 >> 1)); + if (((*arg1 == 1) && ((arg2 & 1) == 0)) || ((*arg1 == 0) && ((arg2 & 1) != 0))) { + arg0 = BADCASTP((uintptr_t)arg0 + (arg2 & 1)); + *arg1 = 1; + } else { + *arg1 = 0; + } + return arg0; +} + +s32 func_801CA034(void** arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u8* arg5, s32 arg6, s32 arg7, s32 arg8) { + s32 var_s0; + s32 var_s1; + s32 var_s3; + void* var_fp; + s32 sp4C; + s32 var_s4; + s32 sp44; + + sp4C = arg2; + var_s4 = 1; + sp44 = arg6 + arg3 + arg4; + var_fp = func_801C9FE8(*arg0, &sp4C, arg3); + arg1 >>= 1; + var_fp = BADCASTP((s32)var_fp + ((0xB - arg8) * arg1)); + if (arg6 & 1) { + arg6 += 1; + } + + while (arg7--) { + var_s0 = BADCASTI var_fp; + var_s1 = sp4C; + + for (var_s3 = 0; var_s3 < arg6; var_s3++, var_s4 ^= 1, var_s1 ^= 1) { + if (var_s4 == 1) { + if (func_801C9FB0(BADCASTP var_s0, var_s1, (*arg5) >> 4) != 0) { + var_s0++; + } + } else { + if (func_801C9FB0(BADCASTP var_s0, var_s1, (*arg5) & 0xF) != 0) { + var_s0++; + } + arg5++; + } + } + var_fp = BADCASTP((s32)var_fp + arg1); + } + + *arg0 = func_801C9FE8(*arg0, &arg2, sp44); + return arg2; +} + +void func_801CA1C4(const char* arg0, s32* arg1, s32* arg2) { + char v1, v2; + + if (func_801C9CB0(arg0) != 0) { + *arg2 = 0; + *arg1 = 0; + return; + } + *arg2 = 0; + *arg1 = 0; + v1 = arg0[-1]; + v2 = arg0[1]; + switch ((u8)arg0[0]) { + case 0x20: + *arg2 = 0; + *arg1 = 0; + return; + case 0x49: + case 0x69: +#if OOT_NTSC + *arg2 = 2; + if (1) {} +#endif + *arg1 = 2; + *arg2 = 2; + if (v1 == 0x20) { + *arg1 = 0; + } + if (v2 == 0x20) { + *arg2 = 0; + } + return; + } +#if OOT_NTSC + *arg2 = 1; + if (1) {} +#endif + *arg1 = 1; + *arg2 = 1; +} + +void func_801CA280(void* arg0, s32 arg1, const char* arg2) { + u8 megatemp[0xA0]; + u8* temp_s1 = (u8*)(((((u32)megatemp + 0xF)) >> 4) << 4); // align to 0x10 on the stack + int sp78; + int sp74; + int sp70; + u8* var_s0; + s32 sp68; + s32 sp64; + s32 temp_v1; + s32 var_s2 = 1; + + if (arg2 == NULL) { + return; + } + + while (*arg2 != 0) { + func_801CA1C4(arg2, &sp68, &sp64); + temp_v1 = func_801C9F0C(temp_s1, &sp78, &sp74, &sp70, arg2); + if (sp78 & 1) { + sp78++; + } + var_s2 = func_801CA034(&arg0, arg1, var_s2, sp68, sp64, &temp_s1[temp_v1], sp78, sp74, sp70); + if (func_801C9CB0(arg2) != 0) { + arg2++; + } + arg2++; + } +} + +void func_801CA3C0(s32 arg0, void (*arg1)(void*, uintptr_t, size_t)) { + D_801E17F0 = arg0; + D_801D3740 = arg1; +} diff --git a/src/n64dd/n64dd_error_headers.c b/src/n64dd/n64dd_5.c similarity index 83% rename from src/n64dd/n64dd_error_headers.c rename to src/n64dd/n64dd_5.c index bac2f97b957..7630eebe666 100644 --- a/src/n64dd/n64dd_error_headers.c +++ b/src/n64dd/n64dd_5.c @@ -1,6 +1,6 @@ +#include "ultra64.h" #include "n64dd.h" - -// Padding in .rodata suggests that this array is in a separate file +#include "n64dd_internal.h" /** * Region-specific "error number" headers used in N64DD error handling. diff --git a/src/n64dd/n64dd_6.c b/src/n64dd/n64dd_6.c new file mode 100644 index 00000000000..9d373efd6ad --- /dev/null +++ b/src/n64dd/n64dd_6.c @@ -0,0 +1,271 @@ +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "region.h" +#include "tex_len.h" +#include "z_locale.h" + +#pragma increment_block_number "" + +const char* D_801D3760[2][8][4] = { + { + { + "  メモリー拡張パックが正しく差し込", + "  んでありますか?        ", + NULL, + NULL, + }, + { + "  間違ったディスクが差し込まれてい", + "  る可能性があります。正しいディス", + "  クに交換してください。     ", + NULL, + }, + { + "  注意:アクセスランプ点滅中にディ", + "  スクを抜かないでください。詳しく", + "  は、取扱説明書をお読みください。", + NULL, + }, + { + "  詳しくは、取扱説明書をお読みくだ", + "  さい。             ", + NULL, + NULL, + }, + { + "   ディスクを差し込んでください。", + NULL, + NULL, + NULL, + }, + { + "  ディスクを差し込み直してください。", + NULL, + NULL, + NULL, + }, + { + "   ディスクを取り出してください。", + NULL, + NULL, + NULL, + }, + { + NULL, + NULL, + NULL, + NULL, + }, + }, + { + { + " Are you sure the Expansion", + " Pak is inserted correctly?", + NULL, + NULL, + }, + { + " Check to see if the proper", + " disk is inserted.", + " Please insert the disk the", + " correct disk.", + }, + { + " Do not remove the disk when", + " the access light is flashing.", + " Please read the instruction", + " manual for details.", + }, + { + " Please read the instruction", + " manual for details.", + NULL, + NULL, + }, + { + " Please insert a disk.", + NULL, + NULL, + NULL, + }, + { + " Please insert the disk again.", + NULL, + NULL, + NULL, + }, + { + " Please remove the disk.", + NULL, + NULL, + NULL, + }, + { + NULL, + NULL, + NULL, + NULL, + }, + }, +}; +u64 D_801D3860[2][TEX_LEN(u64, 192, 16, 4)] = { + { +#include "assets/misc/n64dd_error_textures/gN64DDError41JPNTex.i4.inc.c" + }, + { +#include "assets/misc/n64dd_error_textures/gN64DDError41ENGTex.i4.inc.c" + }, +}; +u64 D_801D4460[2][TEX_LEN(u64, 320, 64, 4)] = { + { +#include "assets/misc/n64dd_error_textures/gN64DDPleaseReadManualJPNTex.i4.inc.c" + }, + { +#include "assets/misc/n64dd_error_textures/gN64DDPleaseReadManualENGTex.i4.inc.c" + }, +}; + +u8 D_801E1800[0x600]; +u8 D_801E1E00[0x2800]; +u8 D_801E4600[0x1400]; + +s32 func_801CA3E0(s32 arg0) { + s32 temp_t6; + s32 var_a1; + s32 var_a2; + s32 var_a2_2; + s32 var_v0; + s32 var_v1; + + var_v0 = 0; + var_v1 = 0; + if (arg0 < 0xA) { + return arg0; + } + var_a1 = 1; + if (arg0 >= 0xA) { + var_a2_2 = 0xA; + do { + var_a1 = var_a2_2; + var_v0 += 1; + var_a2_2 *= 0xA; + } while (arg0 >= var_a2_2); + } + var_a2 = arg0; + while (var_v0--) { + temp_t6 = var_a2 / var_a1; + var_v1 = (var_v1 | temp_t6) * 0x10; + var_a2 = var_a2 % var_a1; + var_a1 = var_a1 / 10; + } + return var_v1 + var_a2; +} + +s32 func_801CA4B8(void) { + return gCurrentRegion == REGION_JP ? 0 : 1; +} + +void func_801CA4E4(u8* arg0, u8 arg1, s32 arg2) { + while (arg2--) { + *arg0++ = arg1; + } +} + +const char* func_801CA514(void) { + return gN64DDLocalizedErrorNumberHeaders[func_801CA4B8()]; +} + +void func_801CA544(const char* arg0, s32 arg1) { + s32 temp_v0; + u16 var_a1; + + temp_v0 = func_801CA3E0(arg1); + if (arg1 >= 0xA) { + var_a1 = ((temp_v0 >> 4) + 0xA3B0); + } else { + var_a1 = 0xA1A1; + } + func_801C9D68((char*)arg0, var_a1); + arg0 += 2; + func_801C9D68((char*)arg0, ((temp_v0 & 0xF) + 0xA3B0)); +} + +void func_801CA5C4(char* arg0, s32 arg1) { + s32 temp_v0; + + temp_v0 = func_801CA3E0(arg1); + if (arg1 >= 0xA) { + *arg0 = (temp_v0 >> 4) + 0x30; + } else { + *arg0 = 0x20; + } + arg0++; + *arg0 = (temp_v0 & 0xF) + 0x30; +} + +void func_801CA628(void* arg0, s32 arg1) { + const char* temp_v0; + + temp_v0 = func_801CA514(); + if (gCurrentRegion == REGION_JP) { + func_801CA544((char*)(temp_v0 + 0xC), arg1); + } else { + func_801CA5C4((char*)(temp_v0 + 0xD), arg1); + } + func_801CA280(arg0, 0xC0, temp_v0); +} + +void* func_801CA698(s32 arg0) { + func_801CA730(); + if (arg0 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) { + return D_801D3860[func_801CA4B8()]; + } + if (((arg0 >= LEO_ERROR_WAITING_NMI) && (arg0 < LEO_ERROR_DEVICE_COMMUNICATION_FAILURE)) || + (arg0 == LEO_ERROR_INVALID_COMMAND_OPERATION_CODE) || (arg0 == LEO_ERROR_LBA_OUT_OF_RANGE)) { + return D_801E1800; + } else { + func_801CA628(D_801E1800, arg0); + return D_801E1800; + } +} + +void* func_801CA730(void) { + func_801CA4E4(D_801E1800, 0, sizeof(D_801E1800)); + return D_801E1800; +} + +void func_801CA764(void* arg0, s32 arg1, s32 arg2) { + s32 var_s0; + + for (var_s0 = 0; var_s0 < arg2; var_s0++) { + func_801CA280(arg0, 0x140, D_801D3760[func_801CA4B8()][arg1][var_s0]); + arg0 = (char*)arg0 + 0xA00; + if (1) {} + } +} + +void* func_801CA800(s32 arg0) { + func_801CA86C(); + if (arg0 == 3) { + return D_801D4460[func_801CA4B8()]; + } + func_801CA764(D_801E1E00, arg0, 4); + return D_801E1E00; +} + +void* func_801CA86C(void) { + func_801CA4E4(D_801E1E00, 0, sizeof(D_801E1E00)); + return D_801E1E00; +} + +UNK_PTR func_801CA8A0(s32 arg0) { + func_801CA8E0(); + func_801CA764(D_801E4600, arg0, 2); + return D_801E4600; +} + +void* func_801CA8E0(void) { + func_801CA4E4(D_801E4600, 0, sizeof(D_801E4600)); + return D_801E4600; +} diff --git a/src/n64dd/n64dd_7.c b/src/n64dd/n64dd_7.c new file mode 100644 index 00000000000..6c4244d6ee0 --- /dev/null +++ b/src/n64dd/n64dd_7.c @@ -0,0 +1,243 @@ +/** + * Some sort of GfxPrint like utility? + */ + +#include "ultra64.h" +#include "n64dd.h" +#include "n64dd_internal.h" +#include "libc64/aprintf.h" +#include "attributes.h" +#include "color.h" + +typedef struct struct_801CAF10 { + /* 0x00 */ PrintCallback callback; + /* 0x04 */ u8* unk4; + /* 0x08 */ u16 unk8; + /* 0x0A */ u16 posX; + /* 0x0C */ u16 posY; + /* 0x0E */ char padE[2]; + /* 0x10 */ Color_RGBA8_u32 color; + /* 0x14 */ u16 baseX; + /* 0x16 */ u16 baseY; + /* 0x18 */ u16 unk18; + /* 0x1A */ u16 unk1A; + /* 0x1C */ u8 unk1C; + /* 0x1D */ char pad1D[3]; + /* 0x20 */ s16* unk20; + /* 0x24 */ u16 unk24; + /* 0x26 */ u16 unk26; +} struct_801CAF10; /* size = 0x28 */ + +u32 D_801D9460[0x5F] = { + 0x9D14, 0x232A14, 0x296314, 0x2F8A14, 0x457E18, 0x63CA14, 0x84AA14, 0xA03314, 0xA45E14, + 0xBB4E14, 0xCA6514, 0xD3770E, 0xE33302, 0xE78108, 0xEB2102, 0xEC6C14, 0x01008A14, 0x01163A14, + 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14, 0x01A58A14, 0x01BB8A14, 0x01D1170E, + 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14, 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, + 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14, 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, + 0x0358CA14, 0x03799A14, 0x0395CA14, 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, + 0x0440AA14, 0x045CDA14, 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, + 0x050681FA, 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10, + 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810, 0x066B9B10, + 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E, 0x0707670E, 0x07138A0E, + 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, +}; + +s32 func_801CA920(s32 arg0, u8* arg1, int* arg2, int* arg3, int* arg4) { + s32 var_s0; + OSPiHandle* sp58; + OSMesgQueue sp40; + void* sp3C; + OSIoMesg sp24; + + sp58 = osDriveRomInit(); + if ((arg0 >= 0x20) && (arg0 < 0x7F)) { + var_s0 = LeoGetAAdr2(D_801D9460[arg0 - 0x20], arg2, arg3, arg4); + } else if (arg0 >= 0x8140) { + var_s0 = LeoGetKAdr(arg0); + *arg2 = 0x10; + *arg3 = 0x10; + *arg4 = 0xB; + } else { + return -1; + } + osCreateMesgQueue(&sp40, &sp3C, 1); + // clang-format off + sp24.hdr.retQueue = &sp40; sp24.devAddr = var_s0 + 0xA0000; sp24.dramAddr = (void*)arg1; sp24.hdr.pri = 0; sp24.size = 0x80; + // clang-format on + sp58->transferInfo.cmdType = 2; + osEPiStartDma(sp58, &sp24, OS_READ); + osRecvMesg(&sp40, NULL, OS_MESG_BLOCK); + return 0; +} + +const u16 D_801D9C10[0x10] = { + 0x0001, 0x1085, 0x2109, 0x318D, 0x4211, 0x5295, 0x6319, 0x739D, + 0x8C63, 0x9CE7, 0xAD6B, 0xBDEF, 0xCE73, 0xDEF7, 0xEF7B, 0xFFFF, +}; + +u16 func_801CAA44(s32 arg0) { + return D_801D9C10[arg0 & 0xF]; +} + +void func_801CAA60(u8* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s16* arg6, s32 arg7) { + s32 var_a0; + s32 var_s0; + u8* var_s1; + s32 var_s5; + s16* var_s2; + + var_s1 = arg0; + var_s2 = arg6; + for (var_s5 = 0; var_s5 < arg4; var_s5++) { + for (var_s0 = 0; var_s0 < arg3; var_s0++) { + if (!(var_s0 & 1)) { + var_a0 = (s32)*var_s1 >> 4; + } else { + var_a0 = *var_s1 & 0xF; + var_s1 += 1; + } + var_s2[arg1 + (((arg2 - arg5) + var_s5 + 0xB) * arg7) + var_s0] = func_801CAA44(var_a0); + } + if (arg3 & 1) { + var_s1 += 1; + } + } +} + +void func_801CAB68(struct_801CAF10* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + arg0->color.r = arg1; + arg0->color.g = arg2; + arg0->color.b = arg3; + arg0->color.a = arg4; +} + +void func_801CAB84(struct_801CAF10* arg0, s32 arg1, s32 arg2) { + arg0->posX = (s16)(arg0->baseX + arg1); + arg0->posY = (s16)(arg0->baseY + arg2); +} + +void func_801CABA4(struct_801CAF10* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + arg0->baseX = (u16)arg1; + arg0->baseY = (u16)arg2; + arg0->unk18 = (u16)arg3; + arg0->unk1A = (u16)arg4; +} + +void func_801CABC0(struct_801CAF10* arg0, s16* arg1, s32 arg2, s32 arg3) { + arg0->unk20 = (s16*)((uintptr_t)arg1 + 0x20000000); + arg0->unk24 = (u16)arg2; + arg0->unk26 = (u16)arg3; + func_801CABA4(arg0, 0, 0, arg2 - 1, arg3 - 1); +} + +void func_801CAC24(struct_801CAF10* arg0, u8* arg1, s32 arg2) { + arg0->unk4 = (u8*)((uintptr_t)arg1 + 0x20000000); + arg0->unk8 = arg2; +} + +void func_801CAC3C(struct_801CAF10* arg0, u8 arg1) { + s32 var_a0; + int sp48; + int sp44; + int sp40; + s32 var_v0; + + if (arg0->unk1C != 0) { + var_a0 = (arg0->unk1C << 8) | arg1; + } else { + if ((arg1 >= 0x80) && (arg1 < 0x99)) { + arg0->unk1C = (u8)arg1; + return; + } + var_a0 = arg1; + } + arg0->unk1C = 0; + if (func_801CA920(var_a0, arg0->unk4, &sp48, &sp44, &sp40) == 0) { + if ((s32)arg0->unk18 < (arg0->posX + sp48)) { + arg0->posX = arg0->baseX; + if ((s32)arg0->unk1A < arg0->posY + 0x10) { + arg0->posY = arg0->baseY; + } else { + arg0->posY = arg0->posY + 0x10; + } + } + func_801CAA60(arg0->unk4, arg0->posX, arg0->posY, sp48, sp44, sp40, arg0->unk20, (s32)arg0->unk24); + if (sp48 == 0x10) { + var_v0 = sp48; + } else { + var_v0 = sp48 + 2; + } + arg0->posX += var_v0; + } +} + +void func_801CAD64(struct_801CAF10* arg0, u8 arg1) { + if ((arg1 >= 0x20) && (arg1 < 0x100)) { + func_801CAC3C(arg0, arg1); + } else { + switch (arg1) { + case 0: + break; + case 0xA: + arg0->posY += 0x20; + FALLTHROUGH; + case 0xD: + arg0->posX = arg0->baseX; + break; + case 9: + do { + func_801CAC3C(arg0, 0x20); + } while ((arg0->posX - arg0->baseX) % 256); + break; + } + } +} + +void func_801CAE2C(struct_801CAF10* arg0, const char* arg1, s32 arg2, size_t arg3) { + const char* var_s0; + s32 var_s1; + + var_s0 = arg1; + for (var_s1 = arg2 * arg3; var_s1 != 0; var_s1--) { + func_801CAD64(arg0, *var_s0++); + } +} + +void func_801CAE88(struct_801CAF10* arg0, u8* arg1) { + while (*arg1 != 0) { + func_801CAD64(arg0, *arg1++); + } +} + +void* func_801CAEE0(void* arg0, const char* arg1, size_t arg2) { + func_801CAE2C(arg0, arg1, 1, arg2); + return arg0; +} + +void func_801CAF10(struct_801CAF10* arg0) { + arg0->callback = func_801CAEE0; + arg0->posX = 0; + arg0->posY = 0; + arg0->baseX = 0; + arg0->baseY = 0; + arg0->unk18 = 0; + arg0->unk1A = 0; + arg0->color.rgba = 0; + arg0->unk1C = 0; + arg0->unk4 = 0; +} + +void func_801CAF48(struct_801CAF10* arg0) { +} + +void func_801CAF54(struct_801CAF10* arg0, const char* arg1, va_list arg2) { + PrintUtils_VPrintf(&arg0->callback, arg1, arg2); +} + +void func_801CAF74(struct_801CAF10* arg0, const char* arg1, ...) { + va_list varargs; + + va_start(varargs, arg1); + func_801CAF54(arg0, arg1, varargs); + va_end(varargs); +} diff --git a/src/n64dd/n64dd_801C8000.c b/src/n64dd/n64dd_801C8000.c deleted file mode 100644 index 2212fe43fb4..00000000000 --- a/src/n64dd/n64dd_801C8000.c +++ /dev/null @@ -1,348 +0,0 @@ -// Does some command processing - -#include "n64dd.h" - -#include "array_count.h" -#include "versions.h" -#include "z_locale.h" - -void func_801C8554(void); -void func_801C8578(void* arg0, void* arg1, OSId id, void* sp, OSPri pri); -void func_801C8638(void (*arg0)(void*, void*, void*), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)); -void func_801C868C(void* arg0, void* arg1, void* arg2, u8 arg3); -s8 func_801C8770(void); -s32 func_801C87C0(void); -s32 func_801C87FC(void); -s32 func_801C8844(void); -s32 func_801C885C(void); -s32 func_801C88AC(void); -s32 func_801C88FC(void); - -s32 D_801D2E60 = 0; -s32 D_801D2E64 = 0; - -typedef struct struct_801D2E68 { - /* 0x0 */ void (*unk_0)(struct_801E0D18*); - /* 0x4 */ s32 (*unk_4)(struct_801E0D18*); -} struct_801D2E68; // size = 0x8 - -struct_801D2E68 D_801D2E68[5] = { - { func_801C81EC, func_801C91E0 }, { func_801C832C, func_801C9260 }, { func_801C83A0, func_801C9260 }, - { func_801C8414, func_801C9334 }, { func_801C8414, func_801C93C4 }, -}; - -s32 D_801D2E90 = 0; - -OSMesgQueue* B_801E0D10[2]; -struct_801E0D18 B_801E0D18; -OSMesg B_801E0D88[1]; -OSMesg B_801E0D90[8]; -OSThread B_801E0DB0; - -s32 func_801C8000(struct_801D9D50* arg0) { - switch (arg0->unk_00) { - case 0: - if (func_801C8844() != 0) { - return 1; - } - func_801C8554(); - break; - case 1: - func_801C8578(arg0->unk_1C, arg0->unk_20, arg0->unk_24, arg0->unk_28, arg0->unk_2C); - break; - case 2: - func_801C8638(arg0->unk_0C, arg0->unk_10, arg0->unk_14); - break; - case 3: - if (func_801C8844() != 0) { - return 1; - } - func_801C868C(arg0->unk_18, arg0->unk_1C, arg0->unk_20, 1); - break; - case 4: - if (func_801C8844() != 0) { - return 1; - } - func_801C868C(arg0->unk_18, arg0->unk_1C, arg0->unk_20, 2); - break; - case 5: - arg0->unk_08 = func_801C8770(); - return arg0->unk_08; - case 7: - return func_801C87FC(); - case 6: - return func_801C8844(); - case 8: - arg0->unk_04 = func_801C87C0(); - return arg0->unk_04; - case 9: - return func_801C885C(); - case 10: - return func_801C88AC(); - case 11: - return func_801C88FC(); - case 12: - D_801D2EA0 = 0; - break; - case 13: - D_801D2EA0 = 1; - break; - } - return 0; -} - -void func_801C819C(UNK_TYPE arg0) { - if (arg0 != 0) { - D_801D2E60 = 1; - } else { - D_801D2E60 = 2; - } -} - -s32 func_801C81C4(void) { - return D_801D2E60; -} - -s32 func_801C81D4(void) { - return D_801D2E64 == 1; -} - -void func_801C81EC(struct_801E0D18* arg0) { - osCreateMesgQueue(&arg0->unk_1C, B_801E0D88, ARRAY_COUNT(B_801E0D88)); - - if (gCurrentRegion == 1) { - arg0->unk_68 = LeoCJCreateLeoManager(LEO_PRIORITY_WRK, LEO_PRIORITY_INT, B_801E0D90, ARRAY_COUNT(B_801E0D90)); - } else { - arg0->unk_68 = LeoCACreateLeoManager(LEO_PRIORITY_WRK, LEO_PRIORITY_INT, B_801E0D90, ARRAY_COUNT(B_801E0D90)); - } - - if ((arg0->unk_68 == LEO_ERROR_DEVICE_COMMUNICATION_FAILURE) || (arg0->unk_68 == LEO_ERROR_GOOD)) { - D_801D2E64 = 1; - } -} - -void func_801C8298(struct_801E0D18* arg0) { - LEOCmd sp1C; - - // TODO: passing a pointer as a logical block address? - LeoSeek(&sp1C, (u32)&arg0->diskId, &arg0->unk_1C); - osRecvMesg(&arg0->unk_1C, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); -} - -void func_801C82E0(struct_801E0D18* arg0) { - LEOCmd sp1C; - - LeoSpdlMotor(&sp1C, 4, &arg0->unk_1C); - osRecvMesg(&arg0->unk_1C, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); -} - -void func_801C832C(struct_801E0D18* arg0) { - s32 sp34; - s32 startLBA = arg0->unk_5C; - - if (LeoByteToLBA(startLBA, arg0->unk_60, &sp34) == LEO_ERROR_GOOD) { - OSMesgQueue* sp28 = &arg0->unk_1C; - - LeoReadWrite(&arg0->unk_00, OS_READ, startLBA, (void*)arg0->unk_58, sp34, sp28); - osRecvMesg(sp28, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); - } -} - -void func_801C83A0(struct_801E0D18* arg0) { - s32 sp34; - s32 startLBA = arg0->unk_58; - - if (LeoByteToLBA(startLBA, arg0->unk_60, &sp34) == LEO_ERROR_GOOD) { - OSMesgQueue* sp28 = &arg0->unk_1C; - - LeoReadWrite(&arg0->unk_00, OS_WRITE, startLBA, (void*)arg0->unk_5C, sp34, sp28); - osRecvMesg(sp28, (OSMesg*)&arg0->unk_68, OS_MESG_BLOCK); - } -} - -void func_801C8414(struct_801E0D18* arg0) { - arg0->unk_68 = 9; -} - -void func_801C8424(struct_801E0D18* arg0) { - struct_801D2E68* temp_v0; - s32 (*temp_s2)(struct_801E0D18*); - void (*aux)(struct_801E0D18*); - s32 temp_v0_2; - - arg0->unk_68 = -1; - if ((func_801C81D4() != 0) || (arg0->unk_64 == 0)) { - arg0->unk_66 = 1; - temp_v0 = &D_801D2E68[arg0->unk_64]; - aux = temp_v0->unk_0; - temp_s2 = temp_v0->unk_4; - do { - aux(arg0); - temp_v0_2 = temp_s2(arg0); - } while (temp_v0_2 == 2); - arg0->unk_6C = temp_v0_2; - if (arg0->unk_64 == 0) { - func_801C819C(temp_v0_2); - } - arg0->unk_66 = 0; - } -} - -void func_801C84D4(void* arg) { - while (true) { - struct_801E0D18* sp24; - - osRecvMesg(B_801E0D10[0], (OSMesg*)&sp24, OS_MESG_BLOCK); - func_801C8424(sp24); - osSendMesg(B_801E0D10[1], NULL, OS_MESG_BLOCK); - } -} - -void func_801C8554(void) { - osDestroyThread(&B_801E0DB0); -} - -void func_801C8578(void* arg0, void* arg1, OSId id, void* sp, OSPri pri) { - B_801E0D10[0] = (OSMesgQueue*)arg0; - B_801E0D10[1] = (OSMesgQueue*)arg1; - osCreateThread(&B_801E0DB0, id, &func_801C84D4, NULL, sp, pri); - osStartThread(&B_801E0DB0); -} - -void func_801C85F0(struct_801E0D18* arg0, s32 arg1) { - if (arg1 == 1) { - func_801C8424(arg0); - } else { - osSendMesg(B_801E0D10[0], arg0, OS_MESG_BLOCK); - } -} - -void func_801C8638(void (*arg0)(void*, void*, void*), s32 arg1, void (*arg2)(void*, uintptr_t, size_t)) { - s32 var0 = 0; - - func_801C9B50(arg1, arg2); - D_801D2EB4 = arg0; - B_801E0D18.unk_64 = var0; - B_801E0D18.unk_65 = var0; - func_801C85F0(&B_801E0D18, 0); -} - -void func_801C868C(void* arg0, void* arg1, void* arg2, u8 arg3) { - s32 var0 = (s32)arg0; - s32 var1 = (s32)arg1; - s32 var2 = (s32)arg2; - s32 var3 = arg3; - s32 var4 = 4; - - if (D_801D2E90 == 1) { - D_801D2E90 = 0; - B_801E0D18.unk_64 = var4; - func_801C85F0(&B_801E0D18, 1); - if (B_801E0D18.unk_6C == 3 || B_801E0D18.unk_6C == 4) { - return; - } - } - - B_801E0D18.unk_58 = var0; - B_801E0D18.unk_5C = var1; - B_801E0D18.unk_60 = var2; - B_801E0D18.unk_64 = var3; - func_801C85F0(&B_801E0D18, 0); -} - -s32 func_801C873C(struct_801E0D18* arg0) { - u8 sp1F; - - arg0->unk_68 = LeoTestUnitReady(&sp1F); - return !(sp1F & LEO_TEST_UNIT_MR); -} - -s8 func_801C8770(void) { - s32 temp = func_801C873C(&B_801E0D18); - - if (B_801E0D18.unk_68 == LEO_ERROR_BUSY) { - return 0; - } - - if (!temp) { - return 2; - } - - return 1; -} - -s32 func_801C87C0(void) { - if (func_801C8844() == 0) { - if (B_801E0D18.unk_68 != 0) { - return B_801E0D18.unk_68; - } - } - - return -1; -} - -s32 func_801C87FC(void) { - s32* new_var = &B_801E0D18.unk_68; - s32 temp_v0; - - if (func_801C8844() == 0) { - temp_v0 = B_801E0D18.unk_6C; - - if ((temp_v0 == 3) || (temp_v0 == 4)) { - return *new_var; - } - } - - return 0; -} - -s32 func_801C8844(void) { - return B_801E0D18.unk_66 == 1; -} - -s32 func_801C885C(void) { - B_801E0D18.unk_64 = 3; - func_801C85F0(&B_801E0D18, 1); - -#if OOT_VERSION >= NTSC_1_1 - D_801D2E90 = 0; -#endif - - if ((B_801E0D18.unk_6C == 3) || (B_801E0D18.unk_6C == 4)) { - return -1; - } - return B_801E0D18.unk_6C == 0; -} - -s32 func_801C88AC(void) { - s32 phi_v0; - - B_801E0D18.unk_64 = 4; - func_801C85F0(&B_801E0D18, 1); - -#if OOT_VERSION >= NTSC_1_1 - D_801D2E90 = 0; -#endif - - if ((B_801E0D18.unk_6C == 3) || (B_801E0D18.unk_6C == 4)) { - return -1; - } - return B_801E0D18.unk_6C == 0; -} - -s32 func_801C88FC(void) { - s32 temp = 0; - s32 phi_v1; - - if (LeoDriveExist()) { - phi_v1 = 8; - } else { - phi_v1 = 0; - } - - temp = phi_v1 == temp; - - B_801E0D18.unk_68 = phi_v1; - - return temp; -} diff --git a/src/n64dd/n64dd_801C8940.c b/src/n64dd/n64dd_801C8940.c deleted file mode 100644 index 132222b689e..00000000000 --- a/src/n64dd/n64dd_801C8940.c +++ /dev/null @@ -1,400 +0,0 @@ -// Lower-level command processing in a background thread -#include "n64dd.h" - -#include "libc64/sleep.h" -#include "attributes.h" - -s32 D_801D2EA0 = 0; -u8* D_801D2EA4 = NULL; -s32 D_801D2EA8 = 0; -u8* D_801D2EAC = NULL; -u8* D_801D2EB0 = NULL; -void (*D_801D2EB4)(void*, void*, void*) = NULL; - -s32 B_801E0F60; -s32 B_801E0F64; - -// Set error message title texture? -void func_801C8940(s32 errorNum) { - D_801D2EA4 = func_801C9E28(errorNum); - D_801D2EA8 = 1; -} - -// Clear error message title texture? -void func_801C8974(void) { - if (D_801D2EA8 == 1) { - D_801D2EA4 = func_801C9EC0(); - D_801D2EA8 = 0; - } -} - -// Set error message something -void func_801C89B8(s32 errorNum) { - D_801D2EAC = func_801C9F90(errorNum); - B_801E0F60 = 1; -} - -// Clear error message something -void func_801C89EC(void) { - if (B_801E0F60 == 1) { - D_801D2EAC = func_801C9FFC(); - B_801E0F60 = 0; - } -} - -// Set error message something -void func_801C8A30(s32 errorNum) { - D_801D2EB0 = func_801CA030(errorNum); - B_801E0F64 = 1; -} - -// Clear error message something -void func_801C8A64(void) { - if (B_801E0F64 == 1) { - D_801D2EB0 = func_801CA070(); - B_801E0F64 = 0; - } -} - -void func_801C8AA8(void) { - osRecvMesg(B_801E0D10[1], NULL, OS_MESG_NOBLOCK); - - if ((D_801D2EB4 != NULL) && (D_801D2EA0 == 0)) { - u32 temp_v0 = osSetIntMask(OS_IM_NONE); - void* sp20 = D_801D2EA4; - void* sp1C = D_801D2EAC; - void* sp18 = D_801D2EB0; - - D_801D2EA4 = NULL; - D_801D2EAC = NULL; - D_801D2EB0 = NULL; - osSetIntMask(temp_v0); - D_801D2EB4(sp20, sp1C, sp18); - } -} - -void func_801C8B58(s32 arg0, s32 arg1, s32 arg2) { - func_801C8940(arg0); - func_801C89B8(arg1); - func_801C8A30(arg2); -} - -void func_801C8B90(void) { - func_801C8974(); - func_801C89EC(); - func_801C8A64(); -} - -s32 func_801C8BC0(struct_801E0D18* arg0) { - if ((arg0->unk_68 < 0x25) || (arg0->unk_68 >= 0x29)) { - if ((arg0->unk_68 != 0x1F) && (arg0->unk_68 != 0x20)) { - func_801C8940(arg0->unk_68); - func_801C89B8(3); - } - } - LeoClearQueue(); - return 4; -} - -s32 func_801C8C1C(struct_801E0D18* arg0) { - s32 var_s0; - - do { - var_s0 = 0; - Sleep_Msec(60); - func_801C82E0(arg0); - - switch (arg0->unk_68) { - case 0x2A: - func_801C8A64(); - return 0; - case 0x22: - func_801C8A64(); - LeoClearQueue(); - return 3; - case 0: - func_801C8A30(6); - FALLTHROUGH; - case 0x23: - var_s0 = 1; - break; - } - } while (var_s0 != 0); - - func_801C8A64(); - return func_801C8BC0(arg0); -} - -s32 func_801C8CEC(struct_801E0D18* arg0) { - switch (arg0->unk_68) { - case 0x22: - func_801C8B90(); - LeoClearQueue(); - return 3; - case 0x2: - func_801C8940(arg0->unk_68); - func_801C8A30(5); - return 9; - case 0x0: - func_801C8B90(); - return 0; - case 0x2B: - if (arg0->unk_65 == 0) { - func_801C8B90(); - arg0->unk_65 = 2; - return 1; - } - FALLTHROUGH; - default: - func_801C8B90(); - return func_801C8BC0(arg0); - case 0x23: - return 9; - } -} - -s32 func_801C8DC0(struct_801E0D18* arg0) { - s32 temp_v0; - - while (true) { - func_801C8298(arg0); - switch (arg0->unk_68) { - case 0x31: - func_801C8940(arg0->unk_68); - func_801C89B8(2); - return 5; - case 0x2A: - func_801C8B90(); - return 5; - } - temp_v0 = func_801C8CEC(arg0); - if (temp_v0 != 9) { - return temp_v0; - } - Sleep_Msec(60); - } -} - -s32 func_801C8E70(struct_801E0D18* arg0) { - s32 temp_a0; - s32 temp_v0; - - while (true) { - Sleep_Msec(60); - func_801C8298(arg0); - - switch (arg0->unk_68) { - case 0x23: - continue; - case 0x31: - func_801C8940(arg0->unk_68); - func_801C89B8(2); - FALLTHROUGH; - case 0x2A: - func_801C8A30(4); - continue; - } - - temp_v0 = func_801C8CEC(arg0); - if (temp_v0 != 9) { - return temp_v0; - } - } -} - -s32 func_801C8F1C(struct_801E0D18* arg0) { - if (D_801D2E54 != NULL) { - return D_801D2E54(arg0); - } - return 1; -} - -s32 func_801C8F58(struct_801E0D18* arg0) { - s32 temp_v0; - - while (true) { - temp_v0 = func_801C8E70(arg0); - if (temp_v0 == 3 || temp_v0 == 4) { - return temp_v0; - } - - // Fake match? - if ((temp_v0 & 0xFFFFFFFF) == 0) { - if (func_801C8F1C(arg0) != 0) { - return 2; - } - func_801C89B8(1); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C89EC(); - } - } -} - -s32 func_801C9000(struct_801E0D18* arg0) { - s32 phi_s0; - s32 temp_s4; - - while (true) { - phi_s0 = func_801C8E70(arg0); - if (phi_s0 == 3 || phi_s0 == 4) { - return phi_s0; - } - - // Fake match? - if ((phi_s0 & 0xFFFFFFFF) == 0) { - func_801C8B90(); - - temp_s4 = func_801C8F1C(arg0); - if (temp_s4 == 3 || temp_s4 == 4) {} - if (temp_s4 != 0) { - return 2; - } - - func_801C89B8(1); - - phi_s0 = func_801C8C1C(arg0); - if (phi_s0 == 3 || phi_s0 == 4) {} - if (phi_s0 != 0) { - return phi_s0; - } - - func_801C89EC(); - if (temp_s4 != 0) { - return phi_s0; - } - } - } -} - -s32 func_801C90C4(struct_801E0D18* arg0) { - func_801C8940(arg0->unk_68); - func_801C89B8(2); - return func_801C9000(arg0); -} - -s32 func_801C90FC(struct_801E0D18* arg0) { - func_801C8940(arg0->unk_68); - return func_801C9000(arg0); -} - -s32 func_801C912C(struct_801E0D18* arg0) { - s32 i = 0; - s32 temp_v0; - - do { - LeoResetClear(); - - temp_v0 = func_801C8DC0(arg0); - if (temp_v0 == 3 || temp_v0 == 4) { - return temp_v0; - } - if (temp_v0 != 1) { - if (temp_v0 == 0) { - return temp_v0; - } else { - return temp_v0; - } - } - - Sleep_Msec(250); - } while (i++ < 30); - - return func_801C8BC0(arg0); -} - -s32 func_801C91E0(struct_801E0D18* arg0) { - if (arg0->unk_68 == 0x29) { - return func_801C8BC0(arg0); - } - - if (osMemSize < 0x800000) { - // LEO_ERROR_RAMPACK_NOT_CONNECTED? - func_801C8B58(0x2C, 0, 3); - return 4; - } - - if (func_801C912C(arg0) == 0) { - D_801D2E90 = 1; - } - return 0; -} - -s32 func_801C9260(struct_801E0D18* arg0) { - s32 temp_v0; - - switch (arg0->unk_68) { - case 0x17: - func_801C873C(arg0); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C8B90(); - return 2; - - case 0x2: - return func_801C8F58(arg0); - - case 0x22: - LeoClearQueue(); - return 3; - - case 0x31: - return func_801C90C4(arg0); - - case 0x2F: - return func_801C9000(arg0); - - case 0x2A: - return func_801C90FC(arg0); - - case 0x0: - return 0; - - case 0x23: - return 2; - } - - return func_801C8BC0(arg0); -} - -s32 func_801C9334(struct_801E0D18* arg0) { - while (true) { - u32 temp_v0 = func_801C8DC0(arg0); - - if (temp_v0 == 3 || temp_v0 == 4 || temp_v0 == 5) { - return temp_v0; - } - - // Fake match? - if ((temp_v0 & 0xFFFFFFFF) == 0) { - if (func_801C8F1C(arg0) != 0) { - return 0; - } - return 7; - } - - if (1) {} - } -} - -s32 func_801C93C4(struct_801E0D18* arg0) { - s32 temp_v0; - s32 temp_v0_2; - - while (true) { - temp_v0_2 = func_801C9334(arg0); - if (temp_v0_2 != 7) { - return temp_v0_2; - } - func_801C89B8(1); - temp_v0 = func_801C8C1C(arg0); - if (temp_v0 != 0) { - return temp_v0; - } - func_801C89EC(); - } -} diff --git a/src/n64dd/n64dd_801C9440.c b/src/n64dd/n64dd_801C9440.c deleted file mode 100644 index ecab855d4ae..00000000000 --- a/src/n64dd/n64dd_801C9440.c +++ /dev/null @@ -1,263 +0,0 @@ -// Some text-handling functions -#include "n64dd.h" -#include "versions.h" - -void (*D_801D2EC0)(void*, uintptr_t, size_t) = NULL; - -s32 B_801E0F70; - -/** - * Seems to work out if a pair of bytes is a valid EUC-JP character, although there may be additions to the font that - * make the strange first check make more sense. - * - * @param bytes Array 2 bytes to test - * @return boolean - */ -int func_801C9440(u8* bytes) { - // This is every possible first byte. May make more sense what was intended with the font files? - if (((*bytes >= 0x8E) && (*bytes <= 0xFE)) || ((*bytes != 0x8F) && (*bytes != 0xA0))) { - bytes++; - return (*bytes >= 0xA0) && (*bytes <= 0xFE); - } - return false; -} - -/** - * A crude check for a valid 2-byte Shift-JIS character - * - * @param bytes Array containing a pair of bytes to test - * @return boolean - */ -int func_801C9494(u8* bytes) { - // Allowable first bytes. - if (((*bytes >= 0x81) && (*bytes <= 0x9F)) || ((*bytes >= 0xE0) && (*bytes <= 0xFC))) { - bytes++; - // Allowable second bytes. - return (*bytes >= 0x40) && (*bytes <= 0xFC) && *bytes != 0x7F; - } - return false; -} - -// Extracts 2 bytes from a bytepacked big-endian short. -void func_801C94F8(u8* arg0, u16 arg1) { - arg0[0] = arg1 >> 8; - arg0[1] = arg1 & 0xFF; -} - -// Convert EUC-JP to JIS X 0208 -u16 func_801C9514(u16 eucjpCh) { - return eucjpCh - 0x8080; -} - -/** - * Converts a JIS X 0208 codepoint to a Shift-JIS one. - * - * @param jisCodepoint Two bytes, each between 0x21 and 0x7E, packed big-endian into a short. - * @return u16 Shift-JIS character representation (expected to be big-endian) - */ -u16 func_801C9534(u16 jisCodepoint) { - u8 hiByte = (jisCodepoint >> 8) & 0xFF; - u8 loByte = jisCodepoint & 0xFF; - - if (hiByte & 1) { - loByte += 0x1F; - if (loByte >= 0x7F) { - loByte++; - } - } else { - loByte += 0x7E; - } - - hiByte = (hiByte - 0x21) / 2 + 0x81; - if (hiByte >= 0xA0) { - hiByte += 0x40; - } - - return (hiByte << 8) + loByte; -} - -void func_801C95C0(void* arg0, uintptr_t arg1, size_t arg2) { - if (D_801D2EC0 != NULL) { - D_801D2EC0(arg0, arg1, arg2); - } -} - -s32 func_801C95F0(u8* arg0) { - return LeoGetKAdr(func_801C9534(func_801C9514((arg0[0] << 8) | arg0[1]))) + DDROM_FONT_START; -} - -s32 func_801C963C(s32* arg0, int* dx, int* dy, int* cy, u8 arg4) { - s32 temp_v0; - s32 temp_v1; - - u16 temp = arg4 - 0x20; - temp += 0xC0 * B_801E0F70; - - temp_v0 = LeoGetAAdr(temp, dx, dy, cy); - temp_v1 = temp_v0 & 0xF; - *arg0 = (temp_v0 - temp_v1) + DDROM_FONT_START; - return temp_v1; -} - -s32 func_801C969C(void* arg0, int* dx, int* dy, int* cy, u8* arg4) { - s32 sp24; - s32 phi_v1; - - if (func_801C9440(arg4)) { - sp24 = func_801C95F0(arg4); - *dx = 16; - *dy = 16; - *cy = 11; - phi_v1 = 0; - } else { - phi_v1 = func_801C963C(&sp24, dx, dy, cy, *arg4); - } - - func_801C95C0(arg0, sp24, 0x80); - return phi_v1; -} - -// return boolean -s32 func_801C9740(u8* arg0, s32 arg1, u8 arg2) { - if (arg1 == 1) { - *arg0 = arg2 << 4; - return false; - } else { - *arg0 |= arg2; - return true; - } -} - -u8* func_801C9778(u8* arg0, s32* arg1, s32 arg2) { - arg0 += (arg2 >> 1); - - if (((*arg1 == 1) && !(arg2 & 1)) || ((*arg1 == 0) && (arg2 & 1))) { - arg0 += arg2 & 1; - *arg1 = 1; - } else { - *arg1 = 0; - } - return arg0; -} - -s32 func_801C97C4(u8** arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, u8* arg5, s32 dx, s32 dy, s32 cy) { - u8* var_fp; - u8* var_s0; - s32 var_s1; - s32 x; - s32 sp4C; - s32 var_s4; - s32 sp44; - - sp4C = arg2; - sp44 = dx + arg3 + arg4; - var_s4 = 1; - var_fp = func_801C9778(*arg0, &sp4C, arg3); - arg1 >>= 1; - var_fp += ((11 - cy) * arg1); - if (dx & 1) { - dx++; - } - while (dy--) { - var_s0 = var_fp; - var_s1 = sp4C; - for (x = 0; x < dx; x++) { - if (var_s4 == 1) { - if (func_801C9740(var_s0, var_s1, *arg5 >> 4)) { - var_s0++; - } - } else { - if (func_801C9740(var_s0, var_s1, *arg5 & 0xF)) { - var_s0++; - } - arg5++; - } - var_s4 ^= 1; - var_s1 ^= 1; - } - var_fp += arg1; - } - *arg0 = func_801C9778(*arg0, &arg2, sp44); - return arg2; -} - -void func_801C9954(u8* bytes, s32* arg1, s32* arg2) { - u8 prevCh; - u8 nextCh; - - if (func_801C9440(bytes)) { - *arg1 = *arg2 = 0; - return; - } - - *arg1 = *arg2 = 0; - - prevCh = bytes[-1]; - nextCh = bytes[1]; - - switch (bytes[0]) { - case ' ': - *arg1 = *arg2 = 0; - return; - - case 'I': - case 'i': -#if OOT_NTSC - *arg2 = 2; - if (1) {} -#endif - - *arg1 = 2; - *arg2 = 2; - - if (prevCh == ' ') { - *arg1 = 0; - } - if (nextCh == ' ') { - *arg2 = 0; - } - return; - } - -#if OOT_NTSC - *arg2 = 1; - if (1) {} -#endif - - *arg1 = 1; - *arg2 = 1; -} - -void func_801C9A10(u8* arg0, s32 arg1, u8* str) { - u8 sp80[0xA0]; - u8* temp_s1; - int dx; - int dy; - int cy; - s32 var_s2; - s32 sp68; - s32 sp64; - s32 temp_v1; - - temp_s1 = (u8*)((((uintptr_t)&sp80 + 0xF) / 0x10) * 0x10); - var_s2 = 1; - if (str != NULL) { - while (*str != '\0') { - func_801C9954(str, &sp68, &sp64); - temp_v1 = func_801C969C(temp_s1, &dx, &dy, &cy, str); - if (dx & 1) { - dx++; - } - var_s2 = func_801C97C4(&arg0, arg1, var_s2, sp68, sp64, &temp_s1[temp_v1], dx, dy, cy); - if (func_801C9440(str)) { - str++; - } - str++; - } - } -} - -void func_801C9B50(s32 arg0, void (*arg1)(void*, uintptr_t, size_t)) { - B_801E0F70 = arg0; - D_801D2EC0 = arg1; -} diff --git a/src/n64dd/n64dd_801C9B70.c b/src/n64dd/n64dd_801C9B70.c deleted file mode 100644 index 79f205c7771..00000000000 --- a/src/n64dd/n64dd_801C9B70.c +++ /dev/null @@ -1,172 +0,0 @@ -// User-facing error handling -#include "n64dd.h" -#include "z_locale.h" - -u8 B_801E0F80[0x600]; -u8 B_801E1580[0x2800]; -u8 B_801E3D80[0x1400]; - -/** - * Converts a number in decimal to a hexadecimal number with the same digits, e.g. 1234 -> 0x1234. - * - * Will only work on nonnegative numbers. - * - * @param decNumber Number in decimal to convert, e.g. 1234 - * @return s32 Hexadecimal number with the same digits as decNumber, e.g. 0x1234 - */ -s32 func_801C9B70(s32 decNumber) { - s32 currPlaceValue; - s32 currExponent = 0; - s32 accumulatedHexDigits = 0; - s32 remainingDecDigits; - - // Nothing to do if only one digit. - if (decNumber < 10) { - return decNumber; - } - - // Find the place value / exponent of the most significant digit in decNumber. - for (currPlaceValue = 1; 10 * currPlaceValue <= decNumber; currPlaceValue *= 10) { - currExponent++; - } - - remainingDecDigits = decNumber; - - // Transfer the digits to hex one at a time. - while (currExponent--) { - // Place the most significant remaining digit at the end of the hex output. - accumulatedHexDigits |= remainingDecDigits / currPlaceValue; - accumulatedHexDigits *= 0x10; // Shift left one hex digit. - - remainingDecDigits %= currPlaceValue; // Remove most significant of the remaining digits. - - currPlaceValue /= 10; - } - - accumulatedHexDigits += remainingDecDigits; // Only one digit left in the remainingDecDigits. - return accumulatedHexDigits; -} - -// n64ddError_GetLanguage -s32 func_801C9C48(void) { - return (gCurrentRegion == 1) ? 0 : 1; -} - -// n64ddError_Memset -void func_801C9C74(u8* dest, u8 value, u32 count) { - while (count--) { - *dest++ = value; - } -} - -// n64ddError_GetErrorHeader -const char* func_801C9CA4(void) { - return gN64DDLocalizedErrorNumberHeaders[func_801C9C48()]; -} - -// n64ddError_WriteNumberJP -// Writes a 2-digit number to the char buffer provided -// Character indices for numbers in the error code (EUC-JP) -void func_801C9CD4(u8* buf, s32 number) { - s32 temp_v0 = func_801C9B70(number); - u16 character; - - if (number >= 10) { - character = ((temp_v0 >> 4) + 0xA3B0); // '0' - } else { - character = 0xA1A1; // ' ' - } - - func_801C94F8(buf, character); - buf += 2; - func_801C94F8(buf, ((temp_v0 & 0xF) + 0xA3B0)); // '0' -} - -// n64ddError_WriteNumberEN -// Writes a 2-digit number to the char buffer provided -// Character indices for numbers in the error code (ASCII) -void func_801C9D54(u8* buf, s32 number) { - s32 temp_v0 = func_801C9B70(number); - - if (number >= 10) { - *buf = (temp_v0 >> 4) + '0'; - } else { - *buf = ' '; - } - buf++; - *buf = (temp_v0 & 0xF) + '0'; -} - -void func_801C9DB8(u8* arg0, s32 errorNum) { - u8* errorHeader = (u8*)func_801C9CA4(); - - //! @bug: both of these functions will write to the pointer target, but errorHeader points to a string literal, - //! which is meant to be const. - if (gCurrentRegion == 1) { - func_801C9CD4(&errorHeader[12], errorNum); - } else { - func_801C9D54(&errorHeader[13], errorNum); - } - func_801C9A10(arg0, 192, errorHeader); -} - -u8* func_801C9E28(s32 errorNum) { - func_801C9EC0(); - - if (errorNum == 41) { - return (u8*)gN64DDError41Texs[func_801C9C48()]; - } - - // 31,32, 37,38,39,40 - if (((errorNum >= 37) && (errorNum < 41)) || (errorNum == 31) || (errorNum == 32)) { - return B_801E0F80; - } else { - func_801C9DB8(B_801E0F80, errorNum); - return B_801E0F80; - } -} - -// Clear something -u8* func_801C9EC0(void) { - func_801C9C74(B_801E0F80, 0, 0x600); - return B_801E0F80; -} - -// Prints the error message body (?) -void func_801C9EF4(u8* arg0, s32 errorNum, s32 lineCount) { - s32 i; - - for (i = 0; i < lineCount; i++, arg0 += 0xA00) { - u8* line = (u8*)D_801D2EE0[func_801C9C48()][errorNum][i]; - - if (1) {} - func_801C9A10(arg0, 320, line); - } -} - -u8* func_801C9F90(s32 errorNum) { - func_801C9FFC(); - if (errorNum == 3) { - return (u8*)gN64DDPleaseReadManualTexs[func_801C9C48()]; - } - func_801C9EF4(B_801E1580, errorNum, 4); - return B_801E1580; -} - -// Clear something -u8* func_801C9FFC(void) { - func_801C9C74(B_801E1580, 0, 0x2800); - return B_801E1580; -} - -u8* func_801CA030(s32 errorNum) { - func_801CA070(); - func_801C9EF4(B_801E3D80, errorNum, 2); - return B_801E3D80; -} - -// Clear something -u8* func_801CA070(void) { - func_801C9C74(B_801E3D80, 0, 0x1400); - return B_801E3D80; -} diff --git a/src/n64dd/n64dd_801CA0B0.c b/src/n64dd/n64dd_801CA0B0.c deleted file mode 100644 index 8252def9e54..00000000000 --- a/src/n64dd/n64dd_801CA0B0.c +++ /dev/null @@ -1,247 +0,0 @@ -#include "n64dd.h" - -#include "libc64/aprintf.h" -#include "attributes.h" -#include "array_count.h" -#include "color.h" - -// Draws text to framebuffer -typedef struct struct_801CA704 { - /* 0x00 */ PrintCallback callback; - /* 0x04 */ void* charTexBuf; - /* 0x08 */ u16 unk_08; - /* 0x0A */ u16 posX; - /* 0x0C */ u16 posY; - /* 0x10 */ Color_RGBA8_u32 color; - /* 0x14 */ u16 baseX; - /* 0x16 */ u16 baseY; - /* 0x18 */ u16 endX; - /* 0x1A */ u16 endY; - /* 0x1C */ u8 sjisPrevByte; - /* 0x20 */ void* frameBuf; - /* 0x24 */ u16 screenWidth; - /* 0x26 */ u16 screenHeight; -} struct_801CA704; - -// clang-format off -u32 D_801D8BE0[0x5F] = { - 0x00009D14, 0x00232A14, 0x00296314, 0x002F8A14, 0x00457E18, 0x0063CA14, 0x0084AA14, 0x00A03314, - 0x00A45E14, 0x00BB4E14, 0x00CA6514, 0x00D3770E, 0x00E33302, 0x00E78108, 0x00EB2102, 0x00EC6C14, - 0x01008A14, 0x01163A14, 0x01217A14, 0x01377A14, 0x014D8A14, 0x01638A14, 0x01798A14, 0x018F7A14, - 0x01A58A14, 0x01BB8A14, 0x01D1170E, 0x01D5490E, 0x01DF770E, 0x01EF740A, 0x01F9770E, 0x02097A14, - 0x021FDC16, 0x024DBA14, 0x026E7A14, 0x0284BA14, 0x02A59A14, 0x02C16A14, 0x02D26A14, 0x02E3BA14, - 0x03048A14, 0x031A1A14, 0x03206A14, 0x03318A14, 0x03476A14, 0x0358CA14, 0x03799A14, 0x0395CA14, - 0x03B67A14, 0x03CCCA14, 0x03ED8A14, 0x04037A14, 0x04196A14, 0x042A8A14, 0x0440AA14, 0x045CDA14, - 0x04839A14, 0x049F9A14, 0x04BB7A14, 0x04D14D14, 0x04DF5C14, 0x04F33D14, 0x05015216, 0x050681FA, - 0x050A9D14, 0x052D9810, 0x05449A14, 0x05609810, 0x05779A14, 0x05939810, 0x05AA5A14, 0x05BB9C10, - 0x05DC7A14, 0x05F22A14, 0x05F83D14, 0x06067A14, 0x061C2A14, 0x0622D810, 0x06427810, 0x06549810, - 0x066B9B10, 0x06899B10, 0x06A74810, 0x06B06810, 0x06BE5A14, 0x06CF770E, 0x06DF870E, 0x06EFB70E, - 0x0707670E, 0x07138A0E, 0x0729670E, 0x07356D14, 0x074A1F16, 0x07526D14, 0x07675216, -}; -// clang-format on - -// Loads character texture to buffer -s32 func_801CA0B0(s32 charCode, void* charTexBuf, int* dx, int* dy, int* cy) { - s32 offset; - OSPiHandle* handle; - OSMesgQueue queue; - OSMesg msgBuf[1]; - OSIoMesg mesg; - - handle = osDriveRomInit(); - if (charCode >= 0x20 && charCode < 0x7F) { // ASCII - offset = LeoGetAAdr2(D_801D8BE0[charCode - 0x20], dx, dy, cy); - } else if (charCode >= 0x8140) { // Shift-JIS - offset = LeoGetKAdr(charCode); - *dx = 16; - *dy = 16; - *cy = 11; - } else { - return -1; - } - - osCreateMesgQueue(&queue, msgBuf, ARRAY_COUNT(msgBuf)); - - // clang-format off - mesg.hdr.retQueue = &queue; \ - mesg.devAddr = offset + DDROM_FONT_START; \ - mesg.dramAddr = charTexBuf; \ - mesg.size = 0x80; \ - mesg.hdr.pri = 0; - // clang-format on - - handle->transferInfo.cmdType = 2; - osEPiStartDma(handle, &mesg, 0); - osRecvMesg(&queue, NULL, OS_MESG_BLOCK); - - return 0; -} - -const u16 D_801D9390[16] = { - 0x0001, 0x1085, 0x2109, 0x318D, 0x4211, 0x5295, 0x6319, 0x739D, - 0x8C63, 0x9CE7, 0xAD6B, 0xBDEF, 0xCE73, 0xDEF7, 0xEF7B, 0xFFFF, -}; - -// Maps 4-bit intensity to a 16-bit color -u16 func_801CA1D4(u32 arg0) { - return D_801D9390[arg0 % ARRAY_COUNT(D_801D9390)]; -} - -void func_801CA1F0(void* charTexBuf, s32 posX, s32 posY, s32 dx, s32 dy, s32 cy, void* frameBuf, s32 screenWidth) { - s32 intensity; - s32 x; - s32 y; - u8* src = charTexBuf; - u16* dst = frameBuf; - - for (y = 0; y < dy; y++) { - for (x = 0; x < dx; x++) { - if (!(x & 1)) { - intensity = *src >> 4; - } else { - intensity = *src & 0xF; - src++; - } - dst[posX + x + ((posY + (11 - cy) + y) * screenWidth)] = func_801CA1D4(intensity); - } - if (dx & 1) { - src++; - } - } -} - -void func_801CA2F8(struct_801CA704* arg0, u32 r, u32 g, u32 b, u32 a) { - arg0->color.r = r; - arg0->color.g = g; - arg0->color.b = b; - arg0->color.a = a; -} - -void func_801CA314(struct_801CA704* arg0, s32 arg1, s32 arg2) { - arg0->posX = arg0->baseX + arg1; - arg0->posY = arg0->baseY + arg2; -} - -void func_801CA334(struct_801CA704* arg0, s32 baseX, s32 baseY, s32 endX, s32 endY) { - arg0->baseX = baseX; - arg0->baseY = baseY; - arg0->endX = endX; - arg0->endY = endY; -} - -void func_801CA350(struct_801CA704* arg0, void* frameBuf, s32 screenWidth, s32 screenHeight) { - arg0->frameBuf = (u8*)frameBuf + 0x20000000; - arg0->screenWidth = screenWidth; - arg0->screenHeight = screenHeight; - func_801CA334(arg0, 0, 0, screenWidth - 1, screenHeight - 1); -} - -void func_801CA3B4(struct_801CA704* arg0, void* charTexBuf, s32 arg2) { - arg0->charTexBuf = (u8*)charTexBuf + 0x20000000; - arg0->unk_08 = arg2; -} - -void func_801CA3CC(struct_801CA704* arg0, char c) { - s32 charCode; - int dx; - int dy; - int cy; - - if (arg0->sjisPrevByte != 0) { - charCode = (arg0->sjisPrevByte << 8) | c; - } else { - if (c >= 0x80 && c < 0x99) { - arg0->sjisPrevByte = c; - return; - } - charCode = c; - } - - arg0->sjisPrevByte = 0; - if (func_801CA0B0(charCode, arg0->charTexBuf, &dx, &dy, &cy) == 0) { - if (arg0->posX + dx > arg0->endX) { - arg0->posX = arg0->baseX; - if (arg0->posY + 16 > arg0->endY) { - arg0->posY = arg0->baseY; - } else { - arg0->posY += 16; - } - } - func_801CA1F0(arg0->charTexBuf, arg0->posX, arg0->posY, dx, dy, cy, arg0->frameBuf, arg0->screenWidth); - arg0->posX += (dx == 16 ? dx : dx + 2); - } -} - -void func_801CA4F4(struct_801CA704* arg0, char c) { - if (c >= ' ' && c <= 0xFF) { - func_801CA3CC(arg0, c); - } else { - switch (c) { - case '\n': - arg0->posY += 32; - FALLTHROUGH; - case '\r': - arg0->posX = arg0->baseX; - break; - case '\t': - do { - func_801CA3CC(arg0, ' '); - } while ((arg0->posX - arg0->baseX) % 256); - break; - case '\0': - break; - } - } -} - -void func_801CA5BC(struct_801CA704* arg0, const char* str, s32 arg2, size_t count) { - const char* s = str; - s32 n = arg2 * count; - - while (n != 0) { - func_801CA4F4(arg0, *s++); - n--; - } -} - -void func_801CA618(struct_801CA704* arg0, const char* str) { - while (*str != 0) { - func_801CA4F4(arg0, *str++); - } -} - -void* func_801CA670(void* arg, const char* str, size_t count) { - func_801CA5BC(arg, str, 1, count); - return arg; -} - -void func_801CA6A0(struct_801CA704* arg0) { - arg0->callback = &func_801CA670; - arg0->posX = 0; - arg0->posY = 0; - arg0->baseX = 0; - arg0->baseY = 0; - arg0->endX = 0; - arg0->endY = 0; - arg0->color.rgba = 0; - arg0->sjisPrevByte = 0; - arg0->charTexBuf = NULL; -} - -void func_801CA6D8(struct_801CA704* arg0) { -} - -s32 func_801CA6E4(struct_801CA704* arg0, const char* fmt, va_list args) { - return PrintUtils_VPrintf(&arg0->callback, fmt, args); -} - -s32 func_801CA704(struct_801CA704* arg0, const char* fmt, ...) { - s32 ret; - va_list args; - - va_start(args, fmt); - ret = func_801CA6E4(arg0, fmt, args); - va_end(args); - - return ret; -} diff --git a/src/n64dd/n64dd_error_bodies.c b/src/n64dd/n64dd_error_bodies.c deleted file mode 100644 index 9c990d76bf0..00000000000 --- a/src/n64dd/n64dd_error_bodies.c +++ /dev/null @@ -1,46 +0,0 @@ -#include "n64dd.h" - -const char* D_801D2EE0[2][8][4] = { - { - { "  メモリー拡張パックが正しく差し込", "  んでありますか?        ", NULL, NULL }, - { "  間違ったディスクが差し込まれてい", "  る可能性があります。正しいディス", - "  クに交換してください。     ", NULL }, - { "  注意:アクセスランプ点滅中にディ", "  スクを抜かないでください。詳しく", - "  は、取扱説明書をお読みください。", NULL }, - { "  詳しくは、取扱説明書をお読みくだ", "  さい。             ", NULL, NULL }, - { "   ディスクを差し込んでください。", NULL, NULL, NULL }, - { "  ディスクを差し込み直してください。", NULL, NULL, NULL }, - { "   ディスクを取り出してください。", NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL }, - }, - { - { - " Are you sure the Expansion", - " Pak is inserted correctly?", - NULL, - NULL, - }, - { - " Check to see if the proper", - " disk is inserted.", - " Please insert the disk the", - " correct disk.", - }, - { - " Do not remove the disk when", - " the access light is flashing.", - " Please read the instruction", - " manual for details.", - }, - { - " Please read the instruction", - " manual for details.", - NULL, - NULL, - }, - { " Please insert a disk.", NULL, NULL, NULL }, - { " Please insert the disk again.", NULL, NULL, NULL }, - { " Please remove the disk.", NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL }, - }, -}; diff --git a/src/n64dd/n64dd_error_textures.c b/src/n64dd/n64dd_error_textures.c deleted file mode 100644 index 38b42de363e..00000000000 --- a/src/n64dd/n64dd_error_textures.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "ultra64.h" - -u64 gN64DDError41Texs[2][0x600 / sizeof(u64)] = { - { -#include "assets/n64dd/error_textures/gN64DDError41JPNTex.i4.inc.c" - }, - { -#include "assets/n64dd/error_textures/gN64DDError41ENGTex.i4.inc.c" - }, -}; - -u64 gN64DDPleaseReadManualTexs[2][0x2800 / sizeof(u64)] = { - { -#include "assets/n64dd/error_textures/gN64DDPleaseReadManualJPNTex.i4.inc.c" - }, - { -#include "assets/n64dd/error_textures/gN64DDPleaseReadManualENGTex.i4.inc.c" - }, -}; diff --git a/src/n64dd/z_n64dd.c b/src/n64dd/z_n64dd.c deleted file mode 100644 index c05bf3ad8b5..00000000000 --- a/src/n64dd/z_n64dd.c +++ /dev/null @@ -1,591 +0,0 @@ -// Main interface for the 64DD from the rest of the game. Starts background -// threads and provides functions to submit commands to them. - -#include "n64dd.h" - -#include "libc64/sleep.h" -#include "array_count.h" -#include "fault.h" -#include "gfx.h" -#include "irqmgr.h" -#include "line_numbers.h" -#include "stack.h" -#include "stackcheck.h" -#include "sys_freeze.h" -#include "versions.h" -#include "audio.h" -#include "thread.h" - -#pragma increment_block_number "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" - -typedef struct struct_801D9C30 { - /* 0x000 */ s32 unk_000; // disk start - /* 0x004 */ s32 unk_004; // disk end - /* 0x008 */ uintptr_t unk_008; // ram start - /* 0x00C */ uintptr_t unk_00C; // ram end - /* 0x010 */ UNK_PTR unk_010; - /* 0x014 */ char unk_014[0x104]; -} struct_801D9C30; // size = 0x118 - -typedef struct struct_801D9B90 { - /* 0x00 */ OSMesg unk_00[30]; - /* 0x78 */ OSMesgQueue unk_78; - /* 0x90 */ IrqMgrClient unk_90; - /* 0x98 */ IrqMgr* unk_98; -} struct_801D9B90; // size = 0x9C - -s32 func_801C7A1C(struct_801E0D18* arg0); - -void* D_801D2E50 = &gN64DDDiskReadTemporaryBuffer; -s32 (*D_801D2E54)(struct_801E0D18*) = func_801C7A1C; - -struct_801D9B90 B_801D9B90; -struct_801D9C30 B_801D9C30; -struct_801D9C30* B_801D9D48; -struct_801D9D50 B_801D9D50; -OSMesgQueue B_801D9D80; -OSMesgQueue B_801D9D98; -OSMesg B_801D9DB0[1]; -OSMesg B_801D9DB4[1]; -volatile u8 B_801D9DB8; -volatile OSTime B_801D9DC0; -s32 B_801D9DC8; // 1 if disk gameName is correct, 2 otherwise -void* B_801D9DCC; -void* B_801D9DD0; -void* B_801D9DD4; -OSThread B_801D9DD8; -STACK(B_801D9F88, 0x1000); -StackEntry B_801DAF88; -STACK(B_801DAFA8, 0x1000); -StackEntry B_801DBFA8; -UNK_TYPE B_801DBFC4; // unused? - -u32 func_801C6E80(void) { -#if OOT_NTSC - return LeoDriveExist(); -#else - return 0; -#endif -} - -void func_801C6EA0(Gfx** gfxP) { -} - -void func_801C6EAC(void) { - if (D_80121214 == 0) { - func_800F6BDC(); - D_80121214 = 1; - } -} - -s32 func_801C6EF0(void) { - return D_80121214 != 0; -} - -s32 func_801C6F08(void) { - if (D_80121214 != 0) { - return 1; - } - return 1; -} - -void func_801C6F30(void) { - func_801C6EAC(); - while (func_801C6F08() == 0) { - Sleep_Usec(16666); // 100000 / 6 - } -} - -void func_801C6F78(void) { - if (D_80121214 != 0) { - D_80121214 = 0; - func_800F6B3C(); - } -} - -// boolean -s32 func_801C6FAC(void) { - if (D_80121213 == 0) { - return false; - } else { - D_80121213 = 0; - return true; - } -} - -void func_801C6FD8(void) { - while (!func_801C6FAC()) { - Sleep_Usec(16666); // 100000 / 6 - } -} - -// Adds a HungupAndCrash -void func_801C7018(void) { - if (D_80121213 != 0) { - Fault_AddHungupAndCrash("../z_n64dd.c", LN2(503, 551, 573)); - } - - D_80121213 = 1; -} - -s32 func_801C7064(void) { - B_801D9D50.unk_00 = 5; - return (&func_801C8000)(&B_801D9D50); -} - -s32 func_801C7098(void) { - s32 phi_v1; - -#if OOT_VERSION < PAL_1_0 - if (0) {} -#endif - - B_801D9D50.unk_00 = 10; - phi_v1 = (&func_801C8000)(&B_801D9D50); - if (phi_v1 < 0) { - Freeze_CurrentThread(); - } - return phi_v1; -} - -s32 func_801C70E4(void) { - return B_801D9DC8 == 1; -} - -// Used by EnMag and FileChoose -s32 func_801C70FC(void) { - return func_801C70E4(); -} - -void func_801C711C(void* arg) { - static void* B_801DBFC8; - struct_801D9B90* arg0 = (struct_801D9B90*)arg; - s16* sp58; - s32 var_s0; - void* temp_v0; - - sp58 = NULL; - arg0->unk_98 = &gIrqMgr; - osCreateMesgQueue(&arg0->unk_78, arg0->unk_00, ARRAY_COUNT(arg0->unk_00)); - IrqMgr_AddClient(arg0->unk_98, &arg0->unk_90, &arg0->unk_78); - var_s0 = 0; - do { - osRecvMesg(&arg0->unk_78, (OSMesg*)&sp58, OS_MESG_BLOCK); - switch (*sp58) { - case 1: - temp_v0 = osViGetNextFramebuffer(); - if (B_801DBFC8 != temp_v0) { - B_801DBFC8 = temp_v0; - B_801D9DB8 = 1; - } - func_801C8AA8(); - break; - case 4: - LeoReset(); - break; - case 3: - var_s0 = 1; - break; - } - } while (var_s0 == 0); - IrqMgr_RemoveClient(arg0->unk_98, &arg0->unk_90); -} - -#if OOT_VERSION >= NTSC_1_1 -void func_801C7B28_ne2(void) { - s32 temp; - - if (B_801D9DC0 != 0) { - temp = (osGetTime() - B_801D9DC0) * 64 / 3000; - if (1000000 - temp > 0) { - Sleep_Usec(1000000 - temp); - } - } -} -#endif - -void func_801C7268(void) { - s32 pad; - s32 sp20; - s32 sp1C; - - sp20 = func_801C6EF0(); - if (sp20 == 0) { - func_801C6F30(); - } - B_801D9DB8 = 1; - B_801D9DC0 = 0; - if (func_801C7064() == 1) { - func_801C7098(); - } else if (B_801D9DC8 != 0) { - B_801D9DC8 = 0; - } -#if OOT_VERSION < NTSC_1_1 - if (B_801D9DC0 != 0) { - sp1C = (osGetTime() - B_801D9DC0) * 64 / 3000; - - // Remnants from debug statements? - (void)(osGetTime() - B_801D9DC0); - (void)((osGetTime() - B_801D9DC0) * 64 / 3000); - (void)((osGetTime() - B_801D9DC0) * 64 / 3000); - - if (1000000 - sp1C > 0) { - Sleep_Usec(1000000 - sp1C); - } - } -#else - if (D_801D2EA8 == 1 || B_801E0F60 == 1 || B_801E0F64 == 1) { - B_801D9DC0 = osGetTime(); - } - func_801C7B28_ne2(); -#endif - if (sp20 == 0) { - func_801C6F78(); - } -} - -// Clears framebuffer -void func_801C7438(void* arg0) { - u16* var_v0; - - for (var_v0 = (u16*)arg0; var_v0 < (u16*)arg0 + SCREEN_WIDTH * SCREEN_HEIGHT; var_v0++) { - *var_v0 = 1; - } -} - -void func_801C746C(void* arg0, void* arg1, void* arg2) { - void* sp2C; - - if (arg0 != NULL || arg1 != NULL || arg2 != NULL) { - sp2C = (u8*)osViGetNextFramebuffer() + 0x20000000; - if ((u32)sp2C & 0xFFFFFF) { - if (B_801D9DB8 != 0) { - B_801D9DB8 = 0; - func_801C7438(sp2C); - B_801D9DC0 = osGetTime(); - } - if (arg0 != NULL) { - func_801CA1F0(arg0, 96, 32, 192, 16, 11, sp2C, SCREEN_WIDTH); - } - if (arg1 != NULL) { - func_801CA1F0(arg1, 0, 80, 320, 64, 11, sp2C, SCREEN_WIDTH); - } - if (arg2 != NULL) { - func_801CA1F0(arg2, 0, 176, 320, 32, 11, sp2C, SCREEN_WIDTH); - } -#if OOT_VERSION < PAL_1_0 - osViBlack(0); -#endif - } - } -} - -void func_801C75BC(void* arg0, void* arg1, void* arg2) { - s32 temp; - - if (arg0 == NULL && arg1 == NULL && arg2 == NULL) { - return; - } - - if (B_801D9DB8) {} - - if (arg0 != 0) { - B_801D9DCC = arg0; - } - if (arg1 != 0) { - B_801D9DD0 = arg1; - } - if (arg2 != 0) { - B_801D9DD4 = arg2; - } - func_801C746C(arg0, arg1, arg2); -} - -void func_801C761C(void) { - Sleep_Msec(100); - func_801C746C(B_801D9DCC, B_801D9DD0, B_801D9DD4); -} - -s32 func_801C7658(void) { - if (D_80121212 != 0) { - return 0; - } - -#if OOT_VERSION < PAL_1_0 - StackCheck_Init(&B_801DAF88, B_801D9F88, STACK_TOP(B_801D9F88), 0, 0x100, "ddmsg"); - osCreateThread(&B_801D9DD8, THREAD_ID_DDMSG, &func_801C711C, &B_801D9B90, STACK_TOP(B_801D9F88), THREAD_PRI_DDMSG); - osStartThread(&B_801D9DD8); -#endif - - osCreateMesgQueue(&B_801D9D80, B_801D9DB0, ARRAY_COUNT(B_801D9DB0)); - osCreateMesgQueue(&B_801D9D98, B_801D9DB4, ARRAY_COUNT(B_801D9DB4)); - - StackCheck_Init(&B_801DBFA8, B_801DAFA8, STACK_TOP(B_801DAFA8), 0, 0x100, "n64dd"); - - B_801D9D50.unk_1C = &B_801D9D80; - B_801D9D50.unk_20 = &B_801D9D98; - B_801D9D50.unk_24 = THREAD_ID_N64DD; - B_801D9D50.unk_28 = STACK_TOP(B_801DAFA8); - B_801D9D50.unk_2C = THREAD_PRI_N64DD; - B_801D9D50.unk_00 = 1; - - (&func_801C8000)(&B_801D9D50); - - D_80121213 = 1; - func_801C6FD8(); - - B_801D9D50.unk_00 = 2; - B_801D9D50.unk_10 = 6; - B_801D9D50.unk_14 = &DmaMgr_DmaFromDriveRom; - B_801D9D50.unk_0C = &func_801C75BC; - (&func_801C8000)(&B_801D9D50); - - B_801D9D50.unk_00 = 13; - (&func_801C8000)(&B_801D9D50); - -#if OOT_VERSION >= PAL_1_0 - StackCheck_Init(&B_801DAF88, B_801D9F88, STACK_TOP(B_801D9F88), 0, 0x100, "ddmsg"); - osCreateThread(&B_801D9DD8, THREAD_ID_DDMSG, &func_801C711C, &B_801D9B90, STACK_TOP(B_801D9F88), THREAD_PRI_DDMSG); - osStartThread(&B_801D9DD8); -#endif - - return 0; -} - -s32 func_801C7818(void) { -#if OOT_VERSION >= NTSC_1_1 - B_801D9DB8 = 1; - B_801D9DC0 = 0; -#endif - - B_801D9D50.unk_00 = 12; - (&func_801C8000)(&B_801D9D50); - - while (func_801C81C4() == 0) { - // the number 16666 sounds like it could be 1 frame (at 60 frames per second) - Sleep_Usec(1000000 * 1 / 60); - } - -#if OOT_VERSION >= NTSC_1_1 - if (D_801D2EA8 == 1 || B_801E0F60 == 1 || B_801E0F64 == 1) { - B_801D9DC0 = osGetTime(); - } - func_801C7B28_ne2(); -#endif - - if (func_801C81C4() != 2) { - func_801C761C(); - Freeze_CurrentThread(); - return -3; - } - - func_801C7018(); - D_80121212 = 1; - return 0; -} - -s32 func_801C78B8(void) { - s32 phi_v1 = func_801C7658(); - - if (phi_v1 == 0) { - phi_v1 = func_801C7818(); - } - return phi_v1; -} - -s32 func_801C78F0(void) { - B_801D9D50.unk_00 = 0; - return (&func_801C8000)(&B_801D9D50); -} - -void func_801C7920(s32 arg0, void* arg1, s32 arg2) { - B_801D9D50.unk_18 = arg1; - B_801D9D50.unk_1C = (void*)arg0; - B_801D9D50.unk_20 = (void*)arg2; - B_801D9D50.unk_00 = 3; - (&func_801C8000)(&B_801D9D50); - osGetTime(); - B_801D9D50.unk_00 = 6; - while ((&func_801C8000)(&B_801D9D50) != 0) { - Sleep_Usec(16666); // 100000 / 6 - } - B_801D9D50.unk_00 = 7; - if ((&func_801C8000)(&B_801D9D50) != 0) { - Freeze_CurrentThread(); - } -} - -void func_801C79CC(void* arg0, s32 arg1, s32 arg2) { - B_801D9D50.unk_18 = arg0; - B_801D9D50.unk_1C = (void*)arg1; - B_801D9D50.unk_20 = (void*)arg2; - B_801D9D50.unk_00 = 4; - (&func_801C8000)(&B_801D9D50); -} - -void func_801C7A10(LEODiskID* arg0) { -} - -// Checks diskId, sets B_801D9DC8 and returns true if diskId is correct -s32 func_801C7A1C(struct_801E0D18* arg0) { - static LEODiskID B_801DBFD0; - static s32 B_801DBFF0; // bool - - func_801C7A10(&arg0->diskId); - if (!B_801DBFF0) { -#if OOT_NTSC - if (bcmp(arg0->diskId.gameName, "EZLJ", 4) == 0 || bcmp(arg0->diskId.gameName, "EZLE", 4) == 0) -#else - if (bcmp(arg0->diskId.gameName, "EZLP", 4) == 0) -#endif - { - B_801DBFD0 = arg0->diskId; - B_801DBFF0 = true; - B_801D9DC8 = 1; - } else { - B_801D9DC8 = 2; - } - } else if (bcmp(&B_801DBFD0, &arg0->diskId, sizeof(LEODiskID)) == 0) { - B_801D9DC8 = 1; - } else { - B_801D9DC8 = 2; - } - return B_801D9DC8 == 1; -} - -// Translates byte position to LBA and byte offset -s32 func_801C7B48(s32 arg0, s32* arg1, s32* arg2) { - s32 sp2C; - s32 temp_v0_2; - s32 sp24; - s32 sp20; - s32 temp_v0; - - temp_v0_2 = LeoByteToLBA(1, arg0 + 1, &sp2C); - if (temp_v0_2 != LEO_ERROR_GOOD) { - return temp_v0_2; - } - sp24 = sp2C - 1; - if (sp2C == 1) { - sp20 = 0; - } else { - temp_v0 = LeoLBAToByte(1, sp24, &sp20); - if (temp_v0 != LEO_ERROR_GOOD) { - return temp_v0; - } - } - *arg1 = sp24 + 1; - *arg2 = arg0 - sp20; - return LEO_ERROR_GOOD; -} - -s32 func_801C7BEC(s32 startLBA) { - s32 bytes; - - if (LeoLBAToByte(startLBA, 1, &bytes) == LEO_ERROR_GOOD) { - return bytes; - } - return 0; -} - -// Copies bytes from disk to arg0 -void func_801C7C1C(void* dest, s32 offset, s32 size) { - s32 sp5C; - s32 sp58; - s32 sp54; - s32 sp50; - void* sp4C; - s32 var_s0; - s32 var_s1; - s32 temp_v1_2; - - func_801C6FD8(); - func_801C6F30(); - B_801D9DB8 = 1; - B_801D9DC0 = 0; - func_801C7B48(offset, &sp5C, &sp54); - func_801C7B48(offset + size, &sp58, &sp50); - sp4C = D_801D2E50; - if (sp5C == sp58) { - func_801C7920(sp5C, sp4C, func_801C7BEC(sp5C)); - bcopy((u8*)sp4C + sp54, dest, size); - } else { - var_s1 = 0; - func_801C7920(sp5C, sp4C, func_801C7BEC(sp5C)); - bcopy((u8*)sp4C + sp54, dest, func_801C7BEC(sp5C) - sp54); - if (sp5C + 1 < sp58) { - for (var_s0 = sp5C + 1; var_s0 < sp58; var_s0++) { - var_s1 += func_801C7BEC(var_s0); - } - func_801C7920(sp5C + 1, (u8*)dest + func_801C7BEC(sp5C) - sp54, var_s1); - } - if (sp50 > 0) { - func_801C7920(sp58, sp4C, func_801C7BEC(sp58)); - bcopy((u8*)sp4C, (u8*)dest + func_801C7BEC(sp5C) - sp54 + var_s1, sp50); - } - } -#if OOT_VERSION < NTSC_1_1 - if (B_801D9DC0 != 0) { - temp_v1_2 = (osGetTime() - B_801D9DC0) * 64 / 3000; - if (1000000 - temp_v1_2 > 0) { - Sleep_Usec(1000000 - temp_v1_2); - } - } -#else - func_801C7B28_ne2(); -#endif - func_801C7018(); - func_801C6F78(); -} - -void func_801C7E78(void) { -} - -s32 func_801C7E80(void) { - s32 sp24; - s32 sp20; - s32 sp1C; - uintptr_t sp18; - - if (B_801D9D48 != NULL) { - return -1; - } - B_801D9D48 = &B_801D9C30; - func_801C7C1C(B_801D9D48, 0x1060, 0x118); - sp24 = B_801D9D48->unk_004 - B_801D9D48->unk_000; - sp20 = B_801D9D48->unk_00C - B_801D9D48->unk_008; - sp18 = B_801D9D48->unk_008 + sp24; - func_801C7C1C((void*)B_801D9D48->unk_008, B_801D9D48->unk_000, sp24); - bzero((void*)sp18, sp20 - sp24); - func_800AD4C0(B_801D9D48->unk_010); - return 0; -} - -s32 func_801C7F24(void) { - uintptr_t temp_a0; - struct_801D9C30* temp_v0; - - if (B_801D9D48 == 0) { - return -1; - } - - // Function from code - func_800AD51C(); - - temp_v0 = B_801D9D48; - temp_a0 = temp_v0->unk_008; - bzero((void*)temp_a0, temp_v0->unk_00C - temp_a0); - bzero(B_801D9D48, sizeof(struct_801D9C30)); - B_801D9D48 = 0; - return 0; -} - -void n64dd_SetDiskVersion(s32 arg0) { - if (arg0 != 0) { - if (B_801D9D48 == 0) { - func_801C7E80(); - } - } else if (B_801D9D48 != 0) { - func_801C7F24(); - } -} diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index 2e9f2cf6ab2..5f2a2e958a4 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -125,8 +125,8 @@ static ColliderCylinderInit sLightBallCylinderInit = { static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 }; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" static EnGanonMant* sCape; diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 5401b389d25..f5e0fd16b13 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -27,7 +27,7 @@ #include "assets/objects/object_tw/object_tw.h" #pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:128" \ - "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" + "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS \ (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED | \ diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index ed7821156e2..cf8bb016f9c 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -29,7 +29,7 @@ #include "assets/objects/gameplay_keep/gameplay_keep_0x55DB0.h" #include "assets/objects/object_bv/object_bv.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \ +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:0" \ "ntsc-1.1:0 ntsc-1.2:0 pal-1.0:128 pal-1.1:128" #define FLAGS \ diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index b2aa276ec77..05350fbb902 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -33,8 +33,8 @@ #include "assets/scenes/indoors/tokinoma/tokinoma_scene.h" #include "assets/scenes/dungeons/ice_doukutu/ice_doukutu_scene.h" -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ - "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED @@ -1415,8 +1415,8 @@ void func_80B3F3D8(void) { Sfx_PlaySfxCentered2(NA_SE_PL_SKIP); } -#pragma increment_block_number "gc-eu:64 gc-eu-mq:64 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64 ique-cn:64" \ - "ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \ + "ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" void EnXc_PlayDiveSFX(Vec3f* src, PlayState* play) { static Vec3f D_80B42DA0; diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index f1e41b80e70..8458e9db24b 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -38,7 +38,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:224 gc-eu-mq:224 gc-jp:224 gc-jp-ce:224 gc-jp-mq:224 gc-us:224 gc-us-mq:224" \ +#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160 gc-us-mq:160" \ "ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128" #define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 84dd1e6f522..658e51db172 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -364,15 +364,15 @@ void Player_Action_CsAction(Player* this, PlayState* play); // .bss part 1 -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:64 gc-jp-ce:64 gc-jp-mq:64 gc-us:64 gc-us-mq:64" \ - "ique-cn:128 ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64" +#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ique-cn:0" \ + "ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0" static s32 D_80858AA0; // TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving // data around. It would be easier if we had more options for controlling BSS ordering in debug. -#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ - "ique-cn:128 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" +#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \ + "ique-cn:192 ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192" static s32 sSavedCurrentMask; static Vec3f sInteractWallCheckResult;