diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2022-01-18 08:31:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-18 08:31:14 +0800 |
| commit | 05d44488bd5587786f4bd0286fc0f555c79aa46a (patch) | |
| tree | 5740f396d10a9580c3a39ca536544436898ff1b6 /libpsn00b/include | |
| parent | 08de895e8582dbc70b639ae5f511ab9ebfb4d68a (diff) | |
| parent | e9475e283a82665fe6c19bebc3318b5084f15a2e (diff) | |
| download | psn00bsdk-05d44488bd5587786f4bd0286fc0f555c79aa46a.tar.gz | |
Merge pull request #44 from spicyjpeg/actions
GitHub Actions CI, psxcd and libc fixes, new examples
Diffstat (limited to 'libpsn00b/include')
| -rw-r--r-- | libpsn00b/include/dlfcn.h | 101 | ||||
| -rw-r--r-- | libpsn00b/include/psxcd.h | 6 | ||||
| -rw-r--r-- | libpsn00b/include/psxgpu.h | 2 | ||||
| -rw-r--r-- | libpsn00b/include/psxpad.h | 328 | ||||
| -rw-r--r-- | libpsn00b/include/psxspu.h | 4 |
5 files changed, 243 insertions, 198 deletions
diff --git a/libpsn00b/include/dlfcn.h b/libpsn00b/include/dlfcn.h index b3a5cec..6874d06 100644 --- a/libpsn00b/include/dlfcn.h +++ b/libpsn00b/include/dlfcn.h @@ -21,39 +21,39 @@ #define RTLD_DEFAULT ((DLL *) 0) typedef enum _DL_Error { - RTLD_E_NONE = 0, // No error - RTLD_E_FILE_OPEN = 1, // Unable to find or open file - RTLD_E_FILE_ALLOC = 2, // Unable to allocate buffer to load file into - RTLD_E_FILE_READ = 3, // Failed to read file - RTLD_E_NO_MAP = 4, // No symbol map has been loaded yet - RTLD_E_MAP_ALLOC = 5, // Unable to allocate symbol map structures - RTLD_E_NO_SYMBOLS = 6, // No symbols found in symbol map - RTLD_E_DLL_NULL = 7, // Unable to initialize DLL from null pointer - RTLD_E_DLL_ALLOC = 8, // Unable to allocate DLL metadata structures - RTLD_E_DLL_FORMAT = 9, // Unsupported DLL type or format - RTLD_E_NO_FILE_API = 10, // psxetc has been built without file support - RTLD_E_MAP_SYMBOL = 11, // Symbol not found in symbol map - RTLD_E_DLL_SYMBOL = 12, // Symbol not found in DLL - RTLD_E_HASH_LOOKUP = 13 // Hash table lookup failed due to internal error + RTLD_E_NONE = 0, // No error + RTLD_E_FILE_OPEN = 1, // Unable to find or open file + RTLD_E_FILE_ALLOC = 2, // Unable to allocate buffer to load file into + RTLD_E_FILE_READ = 3, // Failed to read file + RTLD_E_NO_MAP = 4, // No symbol map has been loaded yet + RTLD_E_MAP_ALLOC = 5, // Unable to allocate symbol map structures + RTLD_E_NO_SYMBOLS = 6, // No symbols found in symbol map + RTLD_E_DLL_NULL = 7, // Unable to initialize DLL from null pointer + RTLD_E_DLL_ALLOC = 8, // Unable to allocate DLL metadata structures + RTLD_E_DLL_FORMAT = 9, // Unsupported DLL type or format + RTLD_E_MAP_SYMBOL = 10, // Symbol not found in symbol map + RTLD_E_DLL_SYMBOL = 11, // Symbol not found in DLL + RTLD_E_HASH_LOOKUP = 12 // Hash table lookup failed due to internal error } DL_Error; typedef enum _DL_ResolveMode { - RTLD_LAZY = 1, // Resolve functions when they are first called (default) - RTLD_NOW = 2 // Resolve all symbols immediately on load + RTLD_LAZY = 1, // Resolve functions when they are first called (default) + RTLD_NOW = 2, // Resolve all symbols immediately on load + RTLD_FREE_ON_DESTROY = 4 // Automatically free DLL buffer when closing DLL } DL_ResolveMode; // Members of this struct should not be accessed directly in most cases, but // they are intentionally exposed for easier expandability. typedef struct _DLL { - void *ptr; - void *malloc_ptr; - size_t size; - const uint32_t *hash; - uint32_t *got; - Elf32_Sym *symtab; - const char *strtab; - uint16_t symbol_count; - uint16_t got_length; + void *ptr; + void *malloc_ptr; + size_t size; + const uint32_t *hash; + uint32_t *got; + Elf32_Sym *symtab; + const char *strtab; + uint16_t symbol_count; + uint16_t got_length; } DLL; /* API */ @@ -62,8 +62,6 @@ typedef struct _DLL { extern "C" { #endif -// TODO: rewrite these javadoc comments into proper documentation - /** * @brief Reads the symbol table from the provided string buffer (which may or * may not be null-terminated), parses it and stores the parsed entries into a @@ -80,13 +78,14 @@ extern "C" { * file in the appropriate format after building the executable, by using this * command: * - * mipsel-unknown-elf-nm -f posix -l -n executable.elf >executable.map + * mipsel-none-elf-nm -f posix -l -n executable.elf >executable.map * * @param ptr * @param size * @return -1 or number of entries parsed */ int32_t DL_ParseSymbolMap(const char *ptr, size_t size); + /** * @brief File wrapper around DL_ParseSymbolMap(). Allocates a temporary buffer * then loads the specified map file into it (using BIOS APIs) and calls @@ -96,14 +95,16 @@ int32_t DL_ParseSymbolMap(const char *ptr, size_t size); * @param filename Must always contain device name, e.g. "cdrom:MODULE.DLL;1" * @return -1 or number of entries parsed */ -int32_t DL_LoadSymbolMap(const char *filename); +//int32_t DL_LoadSymbolMapFromFile(const char *filename); + /** * @brief Frees internal buffers containing the currently loaded symbol map. * This is automatically done before loading a new symbol map so there is no * need to call this function in most cases, however it can still be useful to * free up space on the heap once the symbol map is no longer needed. */ -void DL_UnloadSymbolMap(void); +void DL_UnloadSymbolMap(void); + /** * @brief Queries the currently loaded symbol map for the symbol with the given * name and returns a pointer to it, which can then be used to directly access @@ -112,7 +113,8 @@ void DL_UnloadSymbolMap(void); * @param name * @return NULL or pointer to symbol (any type) */ -void *DL_GetSymbolByName(const char *name); +void *DL_GetSymbolByName(const char *name); + /** * @brief Sets a custom function to be called for resolving symbols in DLLs. * The function will be given a pointer to the current DLL and the unresolved @@ -123,7 +125,7 @@ void *DL_GetSymbolByName(const char *name); * * @param callback NULL or pointer to callback function */ -void DL_SetResolveCallback(void *(*callback)(DLL *, const char *)); +void DL_SetResolveCallback(void *(*callback)(DLL *, const char *)); /** * @brief Initializes a buffer holding the contents of a dynamically-loaded @@ -131,8 +133,8 @@ void DL_SetResolveCallback(void *(*callback)(DLL *, const char *)); * binary) *in-place*. A new DLL struct is allocated to store metadata but, * unlike DL_ParseSymbolMap(), the DLL's actual code, data and tables are * referenced directly from the provided buffer. The buffer must not be moved - * or deallocated, at least not before calling dlclose() on the DLL struct - * returned by this function. + * or deallocated, at least not before calling DL_DestroyDLL() on the DLL + * struct returned by this function. * * The third argument specifies when symbols in the DLL should be resolved. * Setting it to RTLD_LAZY defers resolution of undefined functions to when @@ -145,7 +147,8 @@ void DL_SetResolveCallback(void *(*callback)(DLL *, const char *)); * @param mode RTLD_LAZY or RTLD_NOW * @return NULL or pointer to a new DLL struct */ -DLL *dlinit(void *ptr, size_t size, DL_ResolveMode mode); +DLL *DL_CreateDLL(void *ptr, size_t size, DL_ResolveMode mode); + /** * @brief File wrapper around dlinit(). Allocates a new buffer, loads the * specified file into it (using BIOS APIs) and calls dlinit() on that. When @@ -153,19 +156,22 @@ DLL *dlinit(void *ptr, size_t size, DL_ResolveMode mode); * automatically destroyed. * * @param filename Must always contain device name, e.g. "cdrom:MODULE.DLL;1" - * @param mode RTLD_LAZY or RTLD_NOW + * @param mode RTLD_LAZY or RTLD_NOW + optionally RTLD_FREE_ON_DESTROY * @return NULL or pointer to a new DLL struct */ -DLL *dlopen(const char *filename, DL_ResolveMode mode); +//DLL *DL_LoadDLLFromFile(const char *filename, DL_ResolveMode mode); + /** * @brief Destroys a loaded DLL by calling its global destructors and freeing - * the buffer it's loaded in. Any pointer passed to dlclose() should no longer - * be used after the call. If the DLL was initialized in-place using dlinit(), - * dlclose() will *NOT* free the buffer initially passed to dlinit(). + * the buffer it's loaded in. Any pointer passed to DL_DestroyDLL() should no + * longer be used after the call. If the DLL was initialized in-place using + * DL_CreateDLL(), DL_DestroyDLL() will only free the buffer initially passed + * to DL_CreateDLL() if RTLD_FREE_ON_DESTROY was used. * * @param dll */ -void dlclose(DLL *dll); +void DL_DestroyDLL(DLL *dll); + /** * @brief Returns a pointer to the DLL symbol with the given name, or null if * it can't be found. If null or RTLD_DEFAULT is passed as first argument, the @@ -176,7 +182,8 @@ void dlclose(DLL *dll); * @param name * @return NULL or pointer to symbol (any type) */ -void *dlsym(DLL *dll, const char *name); +void *DL_GetDLLSymbol(const DLL *dll, const char *name); + /** * @brief Returns a code describing the last error that occurred, or DL_E_NONE * if no error has occurred since the last call to dlerror() (i.e. calling this @@ -184,7 +191,15 @@ void *dlsym(DLL *dll, const char *name); * * @return NULL or member of DL_Error enum */ -DL_Error dlerror(void); +DL_Error DL_GetLastError(void); + +/* POSIX "compatibility" macros */ + +#define dlinit(ptr, size, mode) DL_CreateDLL(ptr, size, mode) +//#define dlopen(filename, mode) DL_LoadDLLFromFile(filename, mode) +#define dlsym(dll, name) DL_GetDLLSymbol(dll, name) +#define dlclose(dll) DL_DestroyDLL(dll) +#define dlerror() DL_GetLastError() #ifdef __cplusplus } diff --git a/libpsn00b/include/psxcd.h b/libpsn00b/include/psxcd.h index ffbe86b..3336963 100644 --- a/libpsn00b/include/psxcd.h +++ b/libpsn00b/include/psxcd.h @@ -132,9 +132,9 @@ CdlLOC* CdIntToPos(int i, CdlLOC *p); int CdPosToInt(CdlLOC *p); int CdGetToc(CdlLOC *toc); -int CdControl(u_char com, u_char *param, u_char *result); -int CdControlB(u_char com, u_char *param, u_char *result); -int CdControlF(u_char com, u_char *param); +int CdControl(u_char com, const void *param, u_char *result); +int CdControlB(u_char com, const void *param, u_char *result); +int CdControlF(u_char com, const void *param); int CdSync(int mode, u_char *result); u_long CdSyncCallback(CdlCB func); diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h index f50b841..f061219 100644 --- a/libpsn00b/include/psxgpu.h +++ b/libpsn00b/include/psxgpu.h @@ -609,7 +609,7 @@ void AddPrim(u_long* ot, void* pri); // Function definitions (C) -int GetTimInfo(u_long *tim, TIM_IMAGE *timimg); /* ORIGINAL */ +int GetTimInfo(const u_long *tim, TIM_IMAGE *timimg); /* ORIGINAL */ DISPENV *SetDefDispEnv(DISPENV *disp, int x, int y, int w, int h); DRAWENV *SetDefDrawEnv(DRAWENV *draw, int x, int y, int w, int h); diff --git a/libpsn00b/include/psxpad.h b/libpsn00b/include/psxpad.h index d152896..9638ec1 100644 --- a/libpsn00b/include/psxpad.h +++ b/libpsn00b/include/psxpad.h @@ -14,43 +14,48 @@ #ifndef _PSXPAD_H #define _PSXPAD_H -// Pad button definitions for digital pad, joystick, dual analog, -// Dualshock and Jogcon -#define PAD_SELECT 1 -#define PAD_L3 2 -#define PAD_R3 4 -#define PAD_START 8 -#define PAD_UP 16 -#define PAD_RIGHT 32 -#define PAD_DOWN 64 -#define PAD_LEFT 128 -#define PAD_L2 256 -#define PAD_R2 512 -#define PAD_L1 1024 -#define PAD_R1 2048 -#define PAD_TRIANGLE 4096 -#define PAD_CIRCLE 8192 -#define PAD_CROSS 16384 -#define PAD_SQUARE 32768 - -// Mouse button definitions -#define MOUSE_RIGHT 1024 -#define MOUSE_LEFT 2048 - -// neGcon button definitions -#define NCON_START 8 -#define NCON_UP 16 -#define NCON_RIGHT 32 -#define NCON_DOWN 64 -#define NCON_LEFT 128 -#define NCON_R 256 -#define NCON_B 512 -#define NCON_A 1024 - -// Guncon button definitions -#define GCON_A 8 -#define GCON_TRIGGER 8192 -#define GCON_B 16384 +#include <stdint.h> + +/* Controller type and button definitions */ + +typedef enum { + // Standard pads, analog joystick, Jogcon + PAD_SELECT = 1 << 0, + PAD_L3 = 1 << 1, + PAD_R3 = 1 << 2, + PAD_START = 1 << 3, + PAD_UP = 1 << 4, + PAD_RIGHT = 1 << 5, + PAD_DOWN = 1 << 6, + PAD_LEFT = 1 << 7, + PAD_L2 = 1 << 8, + PAD_R2 = 1 << 9, + PAD_L1 = 1 << 10, + PAD_R1 = 1 << 11, + PAD_TRIANGLE = 1 << 12, + PAD_CIRCLE = 1 << 13, + PAD_CROSS = 1 << 14, + PAD_SQUARE = 1 << 15, + + // Mouse + MOUSE_LEFT = 1 << 10, + MOUSE_RIGHT = 1 << 11, + + // neGcon + NCON_START = 1 << 3, + NCON_UP = 1 << 4, + NCON_RIGHT = 1 << 5, + NCON_DOWN = 1 << 6, + NCON_LEFT = 1 << 7, + NCON_R = 1 << 8, + NCON_B = 1 << 9, + NCON_A = 1 << 10, + + // Guncon + GCON_A = 1 << 3, + GCON_TRIGGER = 1 << 13, + GCON_B = 1 << 14 +} PadButton; typedef enum { PAD_ID_MOUSE = 0x1, // Sony PS1 mouse @@ -64,9 +69,10 @@ typedef enum { PAD_ID_JOGCON = 0xe, // Namco Jogcon PAD_ID_CONFIG_MODE = 0xf, // Dual Analog/DualShock in config mode (if len == 0x3) PAD_ID_NONE = 0xf // No pad connected (if len == 0xf) -} PAD_TYPEID; +} PadTypeID; + +/* Pad and memory card commands */ -// Controller command definitions typedef enum { PAD_CMD_INIT_PRESSURE = '@', // Initialize DS2 button pressure sensors (in config mode) PAD_CMD_READ = 'B', // Read pad state and set rumble @@ -74,131 +80,155 @@ typedef enum { PAD_CMD_SET_ANALOG = 'D', // Set analog mode/LED state (in config mode) PAD_CMD_GET_ANALOG = 'E', // Get analog mode/LED state (in config mode) PAD_CMD_REQUEST_CONFIG = 'M', // Configure request/unlock vibration (in config mode) - PAD_CMD_RESPONSE_CONFIG = 'O' // Configure response/unlock DS2 pressure (in config mode) -} PAD_COMMAND; + PAD_CMD_RESPONSE_CONFIG = 'O', // Configure response/unlock DS2 pressure (in config mode) -// Memory card command/response definitions -typedef enum { - MCD_CMD_READ = 'R', // Read sector - MCD_CMD_IDENTIFY = 'S', // Retrieve ID and card size information - MCD_CMD_WRITE = 'W' // Write sector -} MCD_COMMAND; + MCD_CMD_READ_SECTOR = 'R', // Read 128-byte sector + MCD_CMD_IDENTIFY = 'S', // Retrieve ID and card size information (Sony cards only) + MCD_CMD_WRITE_SECTOR = 'W' // Erase and write 128-byte sector +} PadCommand; typedef enum { MCD_STAT_OK = 'G', MCD_STAT_BAD_CHECKSUM = 'N', MCD_STAT_BAD_SECTOR = 0xff -} MCD_STATUS; - -#define MCD_CMD_READ_LEN 139 -#define MCD_CMD_IDENTIFY_LEN 9 -#define MCD_CMD_WRITE_LEN 137 - -// Memory card status flags -#define MCD_FLAG_WRITE_ERROR 4 // Last write command failed -#define MCD_FLAG_NOT_WRITTEN 8 // No writes have been issued yet -#define MCD_FLAG_UNKNOWN 16 // Might be set on third-party cards - -// Struct for data returned by controllers -typedef struct _PADTYPE { - union { // Header: - struct __attribute__((packed)) { // When parsing data returned by BIOS: - unsigned char stat; // Status - unsigned char len:4; // Payload length / 2, 0 for multitap - unsigned char type:4; // Device type (PAD_TYPEID) +} MemCardStatus; + +typedef enum { + MCD_FLAG_WRITE_ERROR = 1 << 2, // Last write command failed + MCD_FLAG_NOT_WRITTEN = 1 << 3, // No writes have been issued yet + MCD_FLAG_UNKNOWN = 1 << 4 // Might be set on third-party cards +} MemCardStatusFlag; + +#define MEMCARD_CMD_READ_LEN 139 +#define MEMCARD_CMD_IDENTIFY_LEN 9 +#define MEMCARD_CMD_WRITE_LEN 137 + +/* Controller response as returned by BIOS driver */ + +typedef struct __attribute__((packed)) _PADTYPE { + uint8_t stat; // Status + uint8_t len:4; // Payload length / 2, 0 for multitap + uint8_t type:4; // Device type (PadTypeID) + + uint16_t btn; // Button states + union { + struct { // Analog controller: + uint8_t rs_x,rs_y; // - Right stick coordinates + uint8_t ls_x,ls_y; // - Left stick coordinates + uint8_t press[12]; // - Button pressure (DualShock 2 only) }; - struct __attribute__((packed)) { // When parsing raw controller response: - unsigned char len:4; // Payload length / 2, 0 for multitap - unsigned char type:4; // Device type (PAD_TYPEID) - unsigned char prefix; // Must be 0x5a - } raw; - }; - struct { // Payload: - unsigned short btn; // Button states - union { - struct { // Analog controller: - unsigned char rs_x,rs_y; // Right stick coordinates - unsigned char ls_x,ls_y; // Left stick coordinates - unsigned char press[12]; // Button pressure (DualShock 2 only) - }; - struct { // Mouse: - char x_mov; // X movement of mouse - char y_mov; // Y movement of mouse - }; - struct { // neGcon: - unsigned char twist; // Controller twist - unsigned char btn_i; // I button value - unsigned char btn_ii; // II button value - unsigned char trg_l; // L trigger value - }; - struct { // Jogcon: - unsigned short jog_rot; // Jog rotation - }; - struct { // Guncon: - unsigned short gun_x; // Gun X position in dotclocks - unsigned short gun_y; // Gun Y position in scanlines - }; + struct { // Mouse: + int8_t x_mov; // - X movement of mouse + int8_t y_mov; // - Y movement of mouse + }; + struct { // neGcon: + uint8_t twist; // - Controller twist + uint8_t btn_i; // - I button value + uint8_t btn_ii; // - II button value + uint8_t trg_l; // - L trigger value + }; + struct { // Jogcon: + uint16_t jog_rot; // - Jog rotation + }; + struct { // Guncon: + uint16_t gun_x; // - Gun X position in dotclocks + uint16_t gun_y; // - Gun Y position in scanlines }; }; } PADTYPE; -typedef struct _MCDRESPONSE { - unsigned char flags; // Status flags - unsigned char type1; // Must be 0x5a - unsigned char type2; // Must be 0x5d +//typedef struct _PADTYPE MOUSETYPE; +//typedef struct _PADTYPE NCONTYPE; +//typedef struct _PADTYPE JCONTYPE; +//typedef struct _PADTYPE GCONTYPE; + +/* Raw responses */ + +typedef struct __attribute__((packed)) _PadResponse { + uint8_t len:4; // Payload length / 2, 0 for multitap + uint8_t type:4; // Device type (PadTypeID) + uint8_t prefix; // Must be 0x5a + + uint16_t btn; // Button states + union { + struct { // Analog controller: + uint8_t rs_x,rs_y; // - Right stick coordinates + uint8_t ls_x,ls_y; // - Left stick coordinates + uint8_t press[12]; // - Button pressure (DualShock 2 only) + }; + struct { // Mouse: + int8_t x_mov; // - X movement of mouse + int8_t y_mov; // - Y movement of mouse + }; + struct { // neGcon: + uint8_t twist; // - Controller twist + uint8_t btn_i; // - I button value + uint8_t btn_ii; // - II button value + uint8_t trg_l; // - L trigger value + }; + struct { // Jogcon: + uint16_t jog_rot; // - Jog rotation + }; + struct { // Guncon: + uint16_t gun_x; // - Gun X position in dotclocks + uint16_t gun_y; // - Gun Y position in scanlines + }; + }; +} PadResponse; + +typedef struct __attribute__((packed)) _MemCardResponse { + uint8_t flags; // Status flags (MemCardStatusFlag) + uint8_t type1; // Must be 0x5a + uint8_t type2; // Must be 0x5d + union { - struct { // MCD_CMD_READ response: - unsigned char dummy[2]; - unsigned char ack1; // Must be 0x5c - unsigned char ack2; // Must be 0x5d - unsigned char lba_h; - unsigned char lba_l; - unsigned char data[128]; - unsigned char checksum; // = lba_h ^ lba_l ^ data - unsigned char stat; // Status (MCD_STATUS) + struct { // CMD_READ response: + uint8_t dummy[2]; + uint8_t ack1; // Must be 0x5c + uint8_t ack2; // Must be 0x5d + uint8_t lba_h; + uint8_t lba_l; + uint8_t data[128]; + uint8_t checksum; // = lba_h ^ lba_l ^ data + uint8_t stat; // Status (MemCardStatus) } read; - struct { // MCD_CMD_IDENTIFY response: - unsigned char ack1; // Must be 0x5c - unsigned char ack2; // Must be 0x5d - unsigned char size_h; // Card capacity bits 8-15 (0x04 = 128KB) - unsigned char size_l; // Card capacity bits 0-7 (0x00 = 128KB) - unsigned char blksize_h; // Sector size bits 8-15 (must be 0x00) - unsigned char blksize_l; // Sector size bits 0-7 (must be 0x80) + struct { // CMD_IDENTIFY response: + uint8_t ack1; // Must be 0x5c + uint8_t ack2; // Must be 0x5d + uint8_t size_h; // Card capacity bits 8-15 (0x04 = 128KB) + uint8_t size_l; // Card capacity bits 0-7 (0x00 = 128KB) + uint8_t blksize_h; // Sector size bits 8-15 (must be 0x00) + uint8_t blksize_l; // Sector size bits 0-7 (must be 0x80) } identify; - struct { // MCD_CMD_WRITE response: - unsigned char dummy[131]; - unsigned char ack1; // Must be 0x5c - unsigned char ack2; // Must be 0x5d - unsigned char stat; // Status (MCD_STATUS) + struct { // CMD_WRITE response: + uint8_t dummy[131]; + uint8_t ack1; // Must be 0x5c + uint8_t ack2; // Must be 0x5d + uint8_t stat; // Status (MemCardStatus) } write; }; -} MCDRESPONSE; - -//typedef PADTYPE MOUSETYPE; -//typedef PADTYPE NCONTYPE; -//typedef PADTYPE JCONTYPE; -//typedef PADTYPE GCONTYPE; - -// Structs for raw controller request -typedef struct _PADREQUEST { - unsigned char addr; // Must be 0x01 (or 02/03/04 for multitap pads) - unsigned char cmd; // Command (PAD_COMMAND) - unsigned char tap_mode; // 0x01 to enable multitap response - unsigned char motor_r; // Right motor control (on/off) - unsigned char motor_l; // Left motor control (PWM) - unsigned char dummy[4]; -} PADREQUEST; - -// Structs for raw memory card request -typedef struct _MCDREQUEST { - unsigned char addr; // Must be 0x81 (or 02/03/04 for multitap cards) - unsigned char cmd; // Command (MCD_COMMAND) - unsigned char dummy[2]; - unsigned char lba_h; // Sector address bits 8-15 (dummy for CMD_IDENTIFY) - unsigned char lba_l; // Sector address bits 0-7 (dummy for CMD_IDENTIFY) - unsigned char data[128]; // Sector payload (dummy for CMD_READ/CMD_IDENTIFY) - unsigned char checksum; // = lba_h ^ lba_l ^ data (CMD_WRITE only) - unsigned char dummy2[3]; -} MCDREQUEST; +} MemCardResponse; + +/* Raw requests */ + +typedef struct __attribute__((packed)) _PadRequest { + uint8_t addr; // Must be 0x01 (or 02/03/04 for multitap pads) + uint8_t cmd; // Command (PadCommand) + uint8_t tap_mode; // 0x01 to enable multitap response + uint8_t motor_r; // Right motor control (on/off) + uint8_t motor_l; // Left motor control (PWM) + uint8_t dummy[4]; +} PadRequest; + +typedef struct __attribute__((packed)) _MemCardRequest { + uint8_t addr; // Must be 0x81 (or 02/03/04 for multitap cards) + uint8_t cmd; // Command (MemCardCommand) + uint8_t dummy[2]; + uint8_t lba_h; // Sector address bits 8-15 (dummy for CMD_IDENTIFY) + uint8_t lba_l; // Sector address bits 0-7 (dummy for CMD_IDENTIFY) + uint8_t data[128]; // Sector payload (dummy for CMD_READ/CMD_IDENTIFY) + uint8_t checksum; // = lba_h ^ lba_l ^ data (CMD_WRITE only) + uint8_t dummy2[3]; +} MemCardRequest; #endif
\ No newline at end of file diff --git a/libpsn00b/include/psxspu.h b/libpsn00b/include/psxspu.h index a87e347..da000e3 100644 --- a/libpsn00b/include/psxspu.h +++ b/libpsn00b/include/psxspu.h @@ -115,7 +115,7 @@ extern "C" { void SpuInit(); -void SpuSetVoiceRaw( int voice, SpuVoiceRaw* param ); +void SpuSetVoiceRaw( int voice, const SpuVoiceRaw* param ); void SpuReverbOn( int voice ); void SpuSetReverb(); @@ -128,7 +128,7 @@ void SpuSetKey(int on_off, u_int voice_bit); // SPU transfer functions int SpuSetTransferMode(int mode); int SpuSetTransferStartAddr(int addr); -int SpuWrite(unsigned char* addr, int size); +int SpuWrite(const unsigned char* addr, int size); void SpuWait(); #ifdef __cplusplus |
