diff --git a/Makefile b/Makefile index c755c62e..1355d17d 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,12 @@ clean: rebuild: clean all +format: + find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -i + +format-check: + @! find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -style=file -output-replacements-xml | grep "/dev/null + #special recipe for compiling and dumping obj to subfolder $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.c | $(EE_OBJS_DIR) @echo -e "\033[1m CC - $@\033[0m" diff --git a/include/SMB_test.h b/include/SMB_test.h index 9947be33..ff5ca511 100644 --- a/include/SMB_test.h +++ b/include/SMB_test.h @@ -1,23 +1,23 @@ //--------------------------------------------------------------------------- -//File name: SMB_test.h +// File name: SMB_test.h //--------------------------------------------------------------------------- #define SERVERLIST_MAX 16 typedef struct { // size = 1148 - char Server_IP[16]; //IP address of this server - int Server_Port; //IP port for use with this server - char Username[256]; //Username for login to this server (NUL if anonymous) - char Password[256]; //Password for login to this server (ignore if anonymous) + char Server_IP[16]; // IP address of this server + int Server_Port; // IP port for use with this server + char Username[256]; // Username for login to this server (NUL if anonymous) + char Password[256]; // Password for login to this server (ignore if anonymous) int PasswordType; // PLAINTEXT_PASSWORD or HASHED_PASSWORD or NO_PASSWORD - u8 PassHash[32]; //Hashed password for this server (unused if anonymous) - int PassHash_f; //Flags hashing already performed if non-zero - int Server_Logon_f; //Flags successful logon to this server - char Client_ID[256]; //Unit name of ps2, in SMB traffic with this server - char Server_ID[256]; //Unit name of this server, as defined for SMB traffic - char Server_FBID[64]; //Name of this server for display in FileBrowser -} smbServerList_t; //uLE SMB ServerList entry type + u8 PassHash[32]; // Hashed password for this server (unused if anonymous) + int PassHash_f; // Flags hashing already performed if non-zero + int Server_Logon_f; // Flags successful logon to this server + char Client_ID[256]; // Unit name of ps2, in SMB traffic with this server + char Server_ID[256]; // Unit name of this server, as defined for SMB traffic + char Server_FBID[64]; // Name of this server for display in FileBrowser +} smbServerList_t; // uLE SMB ServerList entry type int smbCurrentServer; int smbServerListCount; diff --git a/include/launchelf.h b/include/launchelf.h index 3e1f59b2..720667ed 100644 --- a/include/launchelf.h +++ b/include/launchelf.h @@ -52,13 +52,13 @@ #include #ifdef SIO_DEBUG - #define DPRINTF(format, args...) \ - sio_printf(format, ##args) +#define DPRINTF(format, args...) \ + sio_printf(format, ##args) #elif defined(TTY2SIOR) || defined(COMMON_PRINTF) || defined(UDPTTY) - #define DPRINTF(format, args...) \ - printf("\033[1;94;40m"format"\033[m", ##args) +#define DPRINTF(format, args...) \ + printf("\033[1;94;40m" format "\033[m", ##args) #else - #define DPRINTF(format, args...) // strip away printf from consumer builds +#define DPRINTF(format, args...) // strip away printf from consumer builds #endif #define TRUE 1 @@ -132,7 +132,7 @@ enum SETTING_LK { SETTING_LK_BTN_COUNT, - //Special paths + // Special paths SETTING_LK_ESR = SETTING_LK_BTN_COUNT, SETTING_LK_OSDSYS, @@ -212,7 +212,7 @@ extern char LaunchElfDir[MAX_PATH], LastDir[MAX_NAME]; extern int TV_mode; extern int swapKeys; extern int GUI_active; // Skin and Main Skin switch -extern int cdmode; //Last detected disc type +extern int cdmode; // Last detected disc type extern u8 console_is_PSX; void load_vmc_fs(void); @@ -282,8 +282,8 @@ int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int); char *transcpy_sjis(char *d, const unsigned char *s); void loadIcon(void); int loadFont(char *path_arg); -//Comment out WriteFont_C when not used (also requires patch in draw.c) -//int WriteFont_C(char *pathname); +// Comment out WriteFont_C when not used (also requires patch in draw.c) +// int WriteFont_C(char *pathname); /* pad.c */ #define PAD_R3_V0 0x010000 @@ -298,7 +298,7 @@ int loadFont(char *path_arg); extern u32 joy_value; extern u32 new_pad; #ifdef DS34 -extern int semRunning,semFinish; +extern int semRunning, semFinish; extern int isRunning; #endif int setupPad(void); @@ -322,12 +322,12 @@ enum TV_mode { extern char PathPad[30][MAX_PATH]; extern SETTING *setting; void initConfig(void); -int loadConfig(char *, char *); //0==OK, -1==load failed +int loadConfig(char *, char *); // 0==OK, -1==load failed void config(char *, char *); int get_CNF_string(char **CNF_p_p, char **name_p_p, - char **value_p_p); //main CNF name,value parser -char *preloadCNF(char *path); //loads file into RAM it allocates + char **value_p_p); // main CNF name,value parser +char *preloadCNF(char *path); // loads file into RAM it allocates /* filer.c */ typedef struct @@ -341,9 +341,9 @@ typedef struct extern char mountedParty[MOUNT_LIMIT][MAX_NAME]; extern int latestMount; extern int vmcMounted[2]; -extern int vmc_PartyIndex[2]; //PFS index for each VMC, unless -1 -extern int Party_vmcIndex[MOUNT_LIMIT]; //VMC index for each PFS, unless -1 -extern int nparties; //Clearing this causes FileBrowser to refresh party list +extern int vmc_PartyIndex[2]; // PFS index for each VMC, unless -1 +extern int Party_vmcIndex[MOUNT_LIMIT]; // VMC index for each PFS, unless -1 +extern int nparties; // Clearing this causes FileBrowser to refresh party list extern unsigned char *elisaFnt; char *PathPad_menu(const char *path); int getFilePath(char *out, const int cnfmode); @@ -418,26 +418,26 @@ void Load_External_Language(void); extern unsigned char font_uLE[]; enum { - //0x100-0x109 are 5 double width characters for D-Pad buttons, which are accessed as: + // 0x100-0x109 are 5 double width characters for D-Pad buttons, which are accessed as: //"ÿ0"==Circle "ÿ1"==Cross "ÿ2"==Square "ÿ3"==Triangle "ÿ4"==filled Square - RIGHT_CUR = 0x10A, //Triangle pointing left, for use to the right of an item - LEFT_CUR = 0x10B, //Triangle pointing right, for use to the left of an item - UP_ARROW = 0x10C, //Arrow pointing up - DN_ARROW = 0x10D, //Arrow pointing up - LT_ARROW = 0x10E, //Arrow pointing up - RT_ARROW = 0x10F, //Arrow pointing up - TEXT_CUR = 0x110, //Vertical bar, for use between two text characters - UL_ARROW = 0x111, //Arrow pointing up and to the left, from a vertical start. - BR_SPLIT = 0x112, //Splits rectangle from BL to TR with BR portion filled - BL_SPLIT = 0x113, //Splits rectangle from TL to BR with BL portion filled - //0x114-0x11B are 4 double width characters for D-Pad buttons, which are accessed as: - //"ÿ:"==Right "ÿ;"==Down "ÿ<"==Left "ÿ="==Up - //0x11C-0x123 are 4 doubled characters used as normal/marked folder/file icons + RIGHT_CUR = 0x10A, // Triangle pointing left, for use to the right of an item + LEFT_CUR = 0x10B, // Triangle pointing right, for use to the left of an item + UP_ARROW = 0x10C, // Arrow pointing up + DN_ARROW = 0x10D, // Arrow pointing up + LT_ARROW = 0x10E, // Arrow pointing up + RT_ARROW = 0x10F, // Arrow pointing up + TEXT_CUR = 0x110, // Vertical bar, for use between two text characters + UL_ARROW = 0x111, // Arrow pointing up and to the left, from a vertical start. + BR_SPLIT = 0x112, // Splits rectangle from BL to TR with BR portion filled + BL_SPLIT = 0x113, // Splits rectangle from TL to BR with BL portion filled + // 0x114-0x11B are 4 double width characters for D-Pad buttons, which are accessed as: + //"ÿ:"==Right "ÿ;"==Down "ÿ<"==Left "ÿ="==Up + // 0x11C-0x123 are 4 doubled characters used as normal/marked folder/file icons ICON_FOLDER = 0x11C, ICON_M_FOLDER = 0x11E, ICON_FILE = 0x120, ICON_M_FILE = 0x122, - FONT_COUNT = 0x124 //Total number of characters in font + FONT_COUNT = 0x124 // Total number of characters in font }; /* makeicon.c */ @@ -445,7 +445,7 @@ int make_icon(char *icontext, char *filename); int make_iconsys(char *title, char *iconname, char *filename); -//vmcfs definitions +// vmcfs definitions // The devctl commands: 0x56 == V, 0x4D == M, 0x43 == C, 0x01, 0x02, ... == command number. #define DEVCTL_VMCFS_CLEAN 0x564D4301 // Set as free all fat cluster corresponding to a none existing object. ( Object are just marked as none existing but not removed from fat table when rmdir or remove fonctions are call. This allow to recover a deleted file. ) @@ -464,7 +464,7 @@ typedef enum { // chkesr_rpc.c extern int Check_ESR_Disc(void); -//USB_mass definitions for multiple drive usage +// USB_mass definitions for multiple drive usage #define USB_MASS_MAX_DRIVES 10 @@ -472,6 +472,6 @@ extern char USB_mass_ix[10]; extern int USB_mass_max_drives; extern u64 USB_mass_scan_time; extern int USB_mass_scanned; -extern int USB_mass_loaded; //0==none, 1==internal, 2==external +extern int USB_mass_loaded; // 0==none, 1==internal, 2==external #endif diff --git a/iop/AllowDVDV/AllowDVDV.c b/iop/AllowDVDV/AllowDVDV.c index 98c8b4ab..607d6177 100644 --- a/iop/AllowDVDV/AllowDVDV.c +++ b/iop/AllowDVDV/AllowDVDV.c @@ -10,12 +10,17 @@ static u8 buf[137] __attribute((aligned(16))); static u8 psxver[11] __attribute((aligned(16))) = "rom0:PSXVER"; -static u8 Header[32] __attribute((aligned(16))) = {0x01, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x4A, 0x00, 0x01, 0x02, 0x19, 0x00, 0x00, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0x2C, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00}; +// clang-format off +static u8 Header[32] __attribute((aligned(16))) = { + 0x01, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x4A, 0x00, 0x01, 0x02, 0x19, 0x00, 0x00, 0x00, 0x56, + 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0x2C, 0x02, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 +}; -static u8 ps2Part1[8] __attribute((aligned(16))) = {0xFA, 0xA2, 0x47, 0xE9, 0xFA, 0x20, 0x89, 0x19}; +static u8 ps2Part1[8] __attribute((aligned(16))) = { + 0xFA, 0xA2, 0x47, 0xE9, 0xFA, 0x20, 0x89, 0x19 +}; static u8 ps2Part2[49] __attribute((aligned(16))) = { 0x25, 0xD1, 0x26, 0x8E, 0x3E, 0xB5, 0x38, 0xC2, 0x87, 0xC0, 0xA9, 0xD6, 0xD5, 0x7B, 0x56, 0x87, 0x7B, 0x95, 0x6E, 0x17, 0xF6, 0xBD, 0x76, 0x51, @@ -24,7 +29,10 @@ static u8 ps2Part2[49] __attribute((aligned(16))) = { }; -static u8 psxPart1[8] __attribute((aligned(16))) = {0x98, 0xF7, 0x5C, 0x84, 0x38, 0xC5, 0xBD, 0x3C}; +static u8 psxPart1[8] __attribute((aligned(16))) = { + 0x98, 0xF7, 0x5C, 0x84, 0x38, 0xC5, 0xBD, 0x3C +}; + static u8 psxPart2[49] __attribute((aligned(16))) = { 0x2F, 0xDC, 0xA6, 0x35, 0x8D, 0xE7, 0x5B, 0x77, 0x02, 0x47, 0xD9, 0xD2, 0x6E, 0xCC, 0x4D, 0x60, 0x07, 0xBC, 0xCC, 0x1A, 0x7C, 0x55, 0x0E, 0x48, @@ -36,6 +44,7 @@ static u8 CT[16] __attribute((aligned(16))) = { 0xDE, 0xF0, 0x76, 0x8C, 0x1B, 0x36, 0xF8, 0x07, 0xE0, 0x4B, 0x39, 0x33, 0xF9, 0x6D, 0x4F, 0xFF, }; +// clang-format on int _start() @@ -79,4 +88,4 @@ int _start() //------------------------------------------------------------------------- DECLARE_IMPORT_TABLE(secrman, 1, 0) DECLARE_IMPORT(13, SecrDiskBootFile) -END_IMPORT_TABLE +END_IMPORT_TABLE \ No newline at end of file diff --git a/iop/ds34bt/ee/libds34bt.c b/iop/ds34bt/ee/libds34bt.c index ac63ee35..4749c22c 100644 --- a/iop/ds34bt/ee/libds34bt.c +++ b/iop/ds34bt/ee/libds34bt.c @@ -3,16 +3,16 @@ #include #include "libds34bt.h" -#define DS34BT_INIT 1 +#define DS34BT_INIT 1 #define DS34BT_INIT_CHARGING 2 -#define DS34BT_GET_STATUS 3 -#define DS34BT_GET_BDADDR 4 -#define DS34BT_SET_RUMBLE 5 -#define DS34BT_SET_LED 6 -#define DS34BT_GET_DATA 7 -#define DS34BT_RESET 8 -#define DS34BT_GET_VERSION 9 -#define DS34BT_GET_FEATURES 10 +#define DS34BT_GET_STATUS 3 +#define DS34BT_GET_BDADDR 4 +#define DS34BT_SET_RUMBLE 5 +#define DS34BT_SET_LED 6 +#define DS34BT_GET_DATA 7 +#define DS34BT_RESET 8 +#define DS34BT_GET_VERSION 9 +#define DS34BT_GET_FEATURES 10 #define DS34BT_BIND_RPC_ID 0x18E3878F @@ -24,150 +24,150 @@ static u8 ds34bt_inited = 0; int ds34bt_init() { - ds34bt.server = NULL; + ds34bt.server = NULL; - do { - if (SifBindRpc(&ds34bt, DS34BT_BIND_RPC_ID, 0) < 0) - return 0; + do { + if (SifBindRpc(&ds34bt, DS34BT_BIND_RPC_ID, 0) < 0) + return 0; - nopdelay(); - } while (!ds34bt.server); + nopdelay(); + } while (!ds34bt.server); - ds34bt_inited = 1; + ds34bt_inited = 1; - return 1; + return 1; } int ds34bt_deinit() { - ds34bt_inited = 0; - return 1; + ds34bt_inited = 0; + return 1; } int ds34bt_reinit_ports(u8 ports) { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - rpcbuf[0] = ports; - return (SifCallRpc(&ds34bt, DS34BT_INIT, 0, rpcbuf, 1, NULL, 0, NULL, NULL) == 0); + rpcbuf[0] = ports; + return (SifCallRpc(&ds34bt, DS34BT_INIT, 0, rpcbuf, 1, NULL, 0, NULL, NULL) == 0); } int ds34bt_init_charging() { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - return (SifCallRpc(&ds34bt, DS34BT_INIT_CHARGING, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34bt, DS34BT_INIT_CHARGING, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); } int ds34bt_get_status(int port) { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - if (SifCallRpc(&ds34bt, DS34BT_GET_STATUS, 0, rpcbuf, 1, rpcbuf, 1, NULL, NULL) == 0) - return rpcbuf[0]; + if (SifCallRpc(&ds34bt, DS34BT_GET_STATUS, 0, rpcbuf, 1, rpcbuf, 1, NULL, NULL) == 0) + return rpcbuf[0]; - return 0; + return 0; } int ds34bt_get_bdaddr(u8 *bdaddr) { - int ret = 0; + int ret = 0; - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - if (SifCallRpc(&ds34bt, DS34BT_GET_BDADDR, 0, NULL, 0, rpcbuf, 7, NULL, NULL) == 0) { - memcpy(bdaddr, rpcbuf, 6); + if (SifCallRpc(&ds34bt, DS34BT_GET_BDADDR, 0, NULL, 0, rpcbuf, 7, NULL, NULL) == 0) { + memcpy(bdaddr, rpcbuf, 6); - ret = rpcbuf[6]; - } + ret = rpcbuf[6]; + } - return ret; + return ret; } int ds34bt_set_rumble(int port, u8 lrum, u8 rrum) { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - rpcbuf[0] = port; - rpcbuf[1] = lrum; - rpcbuf[2] = rrum; + rpcbuf[0] = port; + rpcbuf[1] = lrum; + rpcbuf[2] = rrum; - return (SifCallRpc(&ds34bt, DS34BT_SET_RUMBLE, 0, rpcbuf, 3, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34bt, DS34BT_SET_RUMBLE, 0, rpcbuf, 3, NULL, 0, NULL, NULL) == 0); } int ds34bt_set_led(int port, u8 *led) { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - rpcbuf[0] = port; - rpcbuf[1] = led[0]; - rpcbuf[2] = led[1]; - rpcbuf[3] = led[2]; - rpcbuf[4] = 0; + rpcbuf[0] = port; + rpcbuf[1] = led[0]; + rpcbuf[2] = led[1]; + rpcbuf[3] = led[2]; + rpcbuf[4] = 0; - return (SifCallRpc(&ds34bt, DS34BT_SET_LED, 0, rpcbuf, 5, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34bt, DS34BT_SET_LED, 0, rpcbuf, 5, NULL, 0, NULL, NULL) == 0); } int ds34bt_get_data(int port, u8 *data) { - int ret; + int ret; - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - ret = (SifCallRpc(&ds34bt, DS34BT_GET_DATA, 0, rpcbuf, 1, rpcbuf, 18, NULL, NULL) == 0); + ret = (SifCallRpc(&ds34bt, DS34BT_GET_DATA, 0, rpcbuf, 1, rpcbuf, 18, NULL, NULL) == 0); - memcpy(data, rpcbuf, 18); + memcpy(data, rpcbuf, 18); - return ret; + return ret; } int ds34bt_reset() { - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - return (SifCallRpc(&ds34bt, DS34BT_RESET, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34bt, DS34BT_RESET, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); } int ds34bt_get_version(hci_information_t *info) { - int ret = 0; + int ret = 0; - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - if (SifCallRpc(&ds34bt, DS34BT_GET_VERSION, 0, NULL, 0, rpcbuf, 1 + sizeof(hci_information_t), NULL, NULL) == 0) { - memcpy(info, rpcbuf, sizeof(hci_information_t)); + if (SifCallRpc(&ds34bt, DS34BT_GET_VERSION, 0, NULL, 0, rpcbuf, 1 + sizeof(hci_information_t), NULL, NULL) == 0) { + memcpy(info, rpcbuf, sizeof(hci_information_t)); - ret = rpcbuf[sizeof(hci_information_t)]; - } + ret = rpcbuf[sizeof(hci_information_t)]; + } - return ret; + return ret; } int ds34bt_get_features(u8 *info) { - int ret = 0; + int ret = 0; - if (!ds34bt_inited) - return 0; + if (!ds34bt_inited) + return 0; - if (SifCallRpc(&ds34bt, DS34BT_GET_FEATURES, 0, NULL, 0, rpcbuf, 9, NULL, NULL) == 0) { - memcpy(info, rpcbuf, 8); + if (SifCallRpc(&ds34bt, DS34BT_GET_FEATURES, 0, NULL, 0, rpcbuf, 9, NULL, NULL) == 0) { + memcpy(info, rpcbuf, 8); - ret = rpcbuf[8]; - } + ret = rpcbuf[8]; + } - return ret; + return ret; } diff --git a/iop/ds34bt/ee/libds34bt.h b/iop/ds34bt/ee/libds34bt.h index ba687d6b..fe2d7036 100644 --- a/iop/ds34bt/ee/libds34bt.h +++ b/iop/ds34bt/ee/libds34bt.h @@ -1,22 +1,22 @@ enum eDS34BTStatus { - DS34BT_STATE_USB_DISCONNECTED = 0x00, - DS34BT_STATE_USB_AUTHORIZED = 0x01, - DS34BT_STATE_USB_CONFIGURED = 0x02, - DS34BT_STATE_CONNECTED = 0x04, - DS34BT_STATE_RUNNING = 0x08, + DS34BT_STATE_USB_DISCONNECTED = 0x00, + DS34BT_STATE_USB_AUTHORIZED = 0x01, + DS34BT_STATE_USB_CONFIGURED = 0x02, + DS34BT_STATE_CONNECTED = 0x04, + DS34BT_STATE_RUNNING = 0x08, }; typedef struct { - u8 hci_ver; // Version of the Current HCI in the BR/EDR Controller - u16 hci_rev; // Revision of the Current HCI in the BR/EDR Controller - u8 lmp_ver; // Version of the Current LMP or PAL in the Controller - u16 mf_name; // Manufacturer Name of the BR/EDR Controller - u16 lmp_subver; // Subversion of the Current LMP or PAL in the Controller - u16 vid; - u16 pid; - u16 rev; + u8 hci_ver; // Version of the Current HCI in the BR/EDR Controller + u16 hci_rev; // Revision of the Current HCI in the BR/EDR Controller + u8 lmp_ver; // Version of the Current LMP or PAL in the Controller + u16 mf_name; // Manufacturer Name of the BR/EDR Controller + u16 lmp_subver; // Subversion of the Current LMP or PAL in the Controller + u16 vid; + u16 pid; + u16 rev; } __attribute__((packed)) hci_information_t; int ds34bt_init(); diff --git a/iop/ds34bt/iop/ds34bt.c b/iop/ds34bt/iop/ds34bt.c index f8cecf1b..9ceb4a36 100644 --- a/iop/ds34bt/iop/ds34bt.c +++ b/iop/ds34bt/iop/ds34bt.c @@ -38,201 +38,201 @@ static void ds34pad_init(); static int bt_probe(int devId) { - UsbDeviceDescriptor *device = NULL; - UsbConfigDescriptor *config = NULL; - UsbInterfaceDescriptor *intf = NULL; + UsbDeviceDescriptor *device = NULL; + UsbConfigDescriptor *config = NULL; + UsbInterfaceDescriptor *intf = NULL; - DPRINTF("DS34BT: probe: devId=%i\n", devId); + DPRINTF("DS34BT: probe: devId=%i\n", devId); - if ((bt_dev.devId > 0) && (bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) { - DPRINTF("DS34BT: Error - only one device allowed !\n"); - return 0; - } + if ((bt_dev.devId > 0) && (bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) { + DPRINTF("DS34BT: Error - only one device allowed !\n"); + return 0; + } - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - if (device == NULL) { - DPRINTF("DS34BT: Error - Couldn't get device descriptor\n"); - return 0; - } + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + if (device == NULL) { + DPRINTF("DS34BT: Error - Couldn't get device descriptor\n"); + return 0; + } - if (device->bNumConfigurations < 1) - return 0; + if (device->bNumConfigurations < 1) + return 0; - config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); - if (config == NULL) { - DPRINTF("DS34BT: Error - Couldn't get configuration descriptor\n"); - return 0; - } + config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); + if (config == NULL) { + DPRINTF("DS34BT: Error - Couldn't get configuration descriptor\n"); + return 0; + } - if ((config->bNumInterfaces < 1) || (config->wTotalLength < (sizeof(UsbConfigDescriptor) + sizeof(UsbInterfaceDescriptor)))) { - DPRINTF("DS34BT: Error - No interfaces available\n"); - return 0; - } + if ((config->bNumInterfaces < 1) || (config->wTotalLength < (sizeof(UsbConfigDescriptor) + sizeof(UsbInterfaceDescriptor)))) { + DPRINTF("DS34BT: Error - No interfaces available\n"); + return 0; + } - intf = (UsbInterfaceDescriptor *)((char *)config + config->bLength); + intf = (UsbInterfaceDescriptor *)((char *)config + config->bLength); - DPRINTF("DS34BT: bInterfaceClass %X bInterfaceSubClass %X bInterfaceProtocol %X\n", intf->bInterfaceClass, intf->bInterfaceSubClass, intf->bInterfaceProtocol); + DPRINTF("DS34BT: bInterfaceClass %X bInterfaceSubClass %X bInterfaceProtocol %X\n", intf->bInterfaceClass, intf->bInterfaceSubClass, intf->bInterfaceProtocol); - if ((intf->bInterfaceClass != USB_CLASS_WIRELESS_CONTROLLER) || - (intf->bInterfaceSubClass != USB_SUBCLASS_RF_CONTROLLER) || - (intf->bInterfaceProtocol != USB_PROTOCOL_BLUETOOTH_PROG) || - (intf->bNumEndpoints < 3)) { - return 0; - } + if ((intf->bInterfaceClass != USB_CLASS_WIRELESS_CONTROLLER) || + (intf->bInterfaceSubClass != USB_SUBCLASS_RF_CONTROLLER) || + (intf->bInterfaceProtocol != USB_PROTOCOL_BLUETOOTH_PROG) || + (intf->bNumEndpoints < 3)) { + return 0; + } - return 1; + return 1; } static int bt_connect(int devId) { - int epCount; - UsbDeviceDescriptor *device; - UsbConfigDescriptor *config; - UsbInterfaceDescriptor *interface; - UsbEndpointDescriptor *endpoint; + int epCount; + UsbDeviceDescriptor *device; + UsbConfigDescriptor *config; + UsbInterfaceDescriptor *interface; + UsbEndpointDescriptor *endpoint; - DPRINTF("DS34BT: connect: devId=%i\n", devId); + DPRINTF("DS34BT: connect: devId=%i\n", devId); - if (bt_dev.devId != -1) { - DPRINTF("DS34BT: Error - only one device allowed !\n"); - return 1; - } + if (bt_dev.devId != -1) { + DPRINTF("DS34BT: Error - only one device allowed !\n"); + return 1; + } - bt_dev.status = DS34BT_STATE_USB_DISCONNECTED; + bt_dev.status = DS34BT_STATE_USB_DISCONNECTED; - bt_dev.interruptEndp = -1; - bt_dev.inEndp = -1; - bt_dev.outEndp = -1; + bt_dev.interruptEndp = -1; + bt_dev.inEndp = -1; + bt_dev.outEndp = -1; - bt_dev.controlEndp = UsbOpenEndpoint(devId, NULL); + bt_dev.controlEndp = UsbOpenEndpoint(devId, NULL); - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); - interface = (UsbInterfaceDescriptor *)((char *)config + config->bLength); + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); + interface = (UsbInterfaceDescriptor *)((char *)config + config->bLength); - bt_dev.vid = device->idVendor; - bt_dev.pid = device->idProduct; - bt_dev.rev = device->bcdDevice; + bt_dev.vid = device->idVendor; + bt_dev.pid = device->idProduct; + bt_dev.rev = device->bcdDevice; - epCount = interface->bNumEndpoints - 1; + epCount = interface->bNumEndpoints - 1; - DPRINTF("DS34BT: Endpoint Count %d \n", epCount + 1); + DPRINTF("DS34BT: Endpoint Count %d \n", epCount + 1); - endpoint = (UsbEndpointDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_ENDPOINT); + endpoint = (UsbEndpointDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_ENDPOINT); - do { + do { - if (endpoint->bmAttributes == USB_ENDPOINT_XFER_BULK) { - if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT && bt_dev.outEndp < 0) { - bt_dev.outEndp = UsbOpenEndpointAligned(devId, endpoint); - DPRINTF("DS34BT: register Output endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.outEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); - } else if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && bt_dev.inEndp < 0) { - bt_dev.inEndp = UsbOpenEndpointAligned(devId, endpoint); - DPRINTF("DS34BT: register Input endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.inEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); - } - } else if (endpoint->bmAttributes == USB_ENDPOINT_XFER_INT) { - if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && bt_dev.interruptEndp < 0) { - bt_dev.interruptEndp = UsbOpenEndpoint(devId, endpoint); - DPRINTF("DS34BT: register Interrupt endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.interruptEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); - } - } + if (endpoint->bmAttributes == USB_ENDPOINT_XFER_BULK) { + if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT && bt_dev.outEndp < 0) { + bt_dev.outEndp = UsbOpenEndpointAligned(devId, endpoint); + DPRINTF("DS34BT: register Output endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.outEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); + } else if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && bt_dev.inEndp < 0) { + bt_dev.inEndp = UsbOpenEndpointAligned(devId, endpoint); + DPRINTF("DS34BT: register Input endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.inEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); + } + } else if (endpoint->bmAttributes == USB_ENDPOINT_XFER_INT) { + if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && bt_dev.interruptEndp < 0) { + bt_dev.interruptEndp = UsbOpenEndpoint(devId, endpoint); + DPRINTF("DS34BT: register Interrupt endpoint id =%i addr=%02X packetSize=%i\n", bt_dev.interruptEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); + } + } - endpoint = (UsbEndpointDescriptor *)((char *)endpoint + endpoint->bLength); + endpoint = (UsbEndpointDescriptor *)((char *)endpoint + endpoint->bLength); - } while (epCount--); + } while (epCount--); - if (bt_dev.interruptEndp < 0 || bt_dev.inEndp < 0 || bt_dev.outEndp < 0) { - DPRINTF("DS34BT: Error - connect failed: not enough endpoints! \n"); - return -1; - } + if (bt_dev.interruptEndp < 0 || bt_dev.inEndp < 0 || bt_dev.outEndp < 0) { + DPRINTF("DS34BT: Error - connect failed: not enough endpoints! \n"); + return -1; + } - bt_dev.devId = devId; - bt_dev.status = DS34BT_STATE_USB_AUTHORIZED; + bt_dev.devId = devId; + bt_dev.status = DS34BT_STATE_USB_AUTHORIZED; - UsbSetDeviceConfiguration(bt_dev.controlEndp, config->bConfigurationValue, bt_config_set, NULL); + UsbSetDeviceConfiguration(bt_dev.controlEndp, config->bConfigurationValue, bt_config_set, NULL); - return 0; + return 0; } static int bt_disconnect(int devId) { - DPRINTF("DS34BT: disconnect: devId=%i\n", devId); + DPRINTF("DS34BT: disconnect: devId=%i\n", devId); - if (bt_dev.status & DS34BT_STATE_USB_AUTHORIZED) { + if (bt_dev.status & DS34BT_STATE_USB_AUTHORIZED) { - if (bt_dev.interruptEndp >= 0) - UsbCloseEndpoint(bt_dev.interruptEndp); + if (bt_dev.interruptEndp >= 0) + UsbCloseEndpoint(bt_dev.interruptEndp); - if (bt_dev.inEndp >= 0) - UsbCloseEndpoint(bt_dev.inEndp); + if (bt_dev.inEndp >= 0) + UsbCloseEndpoint(bt_dev.inEndp); - if (bt_dev.outEndp >= 0) - UsbCloseEndpoint(bt_dev.outEndp); + if (bt_dev.outEndp >= 0) + UsbCloseEndpoint(bt_dev.outEndp); - bt_dev.devId = -1; - bt_dev.interruptEndp = -1; - bt_dev.inEndp = -1; - bt_dev.outEndp = -1; - bt_dev.controlEndp = -1; - bt_dev.status = DS34BT_STATE_USB_DISCONNECTED; + bt_dev.devId = -1; + bt_dev.interruptEndp = -1; + bt_dev.inEndp = -1; + bt_dev.outEndp = -1; + bt_dev.controlEndp = -1; + bt_dev.status = DS34BT_STATE_USB_DISCONNECTED; - ds34pad_init(); - SignalSema(bt_dev.hid_sema); - } + ds34pad_init(); + SignalSema(bt_dev.hid_sema); + } - return 0; + return 0; } int chrg_probe(int devId) { - UsbDeviceDescriptor *device = NULL; + UsbDeviceDescriptor *device = NULL; - DPRINTF("DS34CHRG: probe: devId=%i\n", devId); + DPRINTF("DS34CHRG: probe: devId=%i\n", devId); - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - if (device == NULL) { - DPRINTF("DS34CHRG: Error - Couldn't get device descriptor\n"); - return 0; - } + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + if (device == NULL) { + DPRINTF("DS34CHRG: Error - Couldn't get device descriptor\n"); + return 0; + } - if (device->idVendor == DS34_VID && (device->idProduct == DS3_PID || device->idProduct == DS4_PID || device->idProduct == DS4_PID_SLIM)) - return 1; + if (device->idVendor == DS34_VID && (device->idProduct == DS3_PID || device->idProduct == DS4_PID || device->idProduct == DS4_PID_SLIM)) + return 1; - return 0; + return 0; } int chrg_connect(int devId) { - int chrg_end; - UsbDeviceDescriptor *device; - UsbConfigDescriptor *config; + int chrg_end; + UsbDeviceDescriptor *device; + UsbConfigDescriptor *config; - DPRINTF("DS34CHRG: connect: devId=%i\n", devId); + DPRINTF("DS34CHRG: connect: devId=%i\n", devId); - if (chrg_dev != -1) { - DPRINTF("DS34CHRG: Error - only one device allowed !\n"); - return 1; - } + if (chrg_dev != -1) { + DPRINTF("DS34CHRG: Error - only one device allowed !\n"); + return 1; + } - chrg_dev = devId; + chrg_dev = devId; - chrg_end = UsbOpenEndpoint(devId, NULL); + chrg_end = UsbOpenEndpoint(devId, NULL); - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); - UsbSetDeviceConfiguration(chrg_end, config->bConfigurationValue, NULL, NULL); + UsbSetDeviceConfiguration(chrg_end, config->bConfigurationValue, NULL, NULL); - return 0; + return 0; } int chrg_disconnect(int devId) { - DPRINTF("DS34CHRG: disconnect: devId=%i\n", devId); + DPRINTF("DS34CHRG: disconnect: devId=%i\n", devId); - chrg_dev = -1; + chrg_dev = -1; - return 0; + return 0; } static u8 output_01_report[] = @@ -340,7 +340,7 @@ static u8 GenuineMacAddress[][3] = // fake with AirohaTechnologyCorp's Chip {0x0C, 0xFC, 0x83}}; -#define REQ_HCI_OUT (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) +#define REQ_HCI_OUT (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) #define HCI_COMMAND_REQ 0 #define MAX_PADS 2 @@ -374,15 +374,15 @@ static int hci_reset(); static void bt_config_set(int result, int count, void *arg) { - PollSema(bt_dev.hid_sema); + PollSema(bt_dev.hid_sema); - UsbInterruptTransfer(bt_dev.interruptEndp, hci_buf, MAX_BUFFER_SIZE, hci_event_cb, NULL); - UsbBulkTransfer(bt_dev.inEndp, l2cap_buf, MAX_BUFFER_SIZE, l2cap_event_cb, NULL); + UsbInterruptTransfer(bt_dev.interruptEndp, hci_buf, MAX_BUFFER_SIZE, hci_event_cb, NULL); + UsbBulkTransfer(bt_dev.inEndp, l2cap_buf, MAX_BUFFER_SIZE, l2cap_event_cb, NULL); - ds34pad_init(); - hci_reset(); + ds34pad_init(); + hci_reset(); - SignalSema(bt_dev.hid_sema); + SignalSema(bt_dev.hid_sema); } /************************************************************/ @@ -391,442 +391,442 @@ static void bt_config_set(int result, int count, void *arg) static int HCI_Command(int nbytes, u8 *dataptr) { - return UsbControlTransfer(bt_dev.controlEndp, REQ_HCI_OUT, HCI_COMMAND_REQ, 0, 0, nbytes, dataptr, NULL, NULL); + return UsbControlTransfer(bt_dev.controlEndp, REQ_HCI_OUT, HCI_COMMAND_REQ, 0, 0, nbytes, dataptr, NULL, NULL); } static int hci_reset() { - hci_cmd_buf[0] = HCI_OCF_RESET; - hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND; - hci_cmd_buf[2] = 0x00; // Parameter Total Length = 0 + hci_cmd_buf[0] = HCI_OCF_RESET; + hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND; + hci_cmd_buf[2] = 0x00; // Parameter Total Length = 0 - return HCI_Command(3, hci_cmd_buf); + return HCI_Command(3, hci_cmd_buf); } static int hci_write_scan_enable(u8 conf) { - hci_cmd_buf[0] = HCI_OCF_WRITE_SCAN_ENABLE; - hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND; - hci_cmd_buf[2] = 0x01; - hci_cmd_buf[3] = conf; + hci_cmd_buf[0] = HCI_OCF_WRITE_SCAN_ENABLE; + hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND; + hci_cmd_buf[2] = 0x01; + hci_cmd_buf[3] = conf; - return HCI_Command(4, hci_cmd_buf); + return HCI_Command(4, hci_cmd_buf); } static int hci_accept_connection(u8 *bdaddr) { - hci_cmd_buf[0] = HCI_OCF_ACCEPT_CONNECTION; // HCI OCF = 9 - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 - hci_cmd_buf[2] = 0x07; // parameter length 7 - hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address - hci_cmd_buf[4] = *(bdaddr + 1); - hci_cmd_buf[5] = *(bdaddr + 2); - hci_cmd_buf[6] = *(bdaddr + 3); - hci_cmd_buf[7] = *(bdaddr + 4); - hci_cmd_buf[8] = *(bdaddr + 5); - hci_cmd_buf[9] = 0x01; // switch role to (slave = 1 / master = 0) - - return HCI_Command(10, hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_ACCEPT_CONNECTION; // HCI OCF = 9 + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 + hci_cmd_buf[2] = 0x07; // parameter length 7 + hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address + hci_cmd_buf[4] = *(bdaddr + 1); + hci_cmd_buf[5] = *(bdaddr + 2); + hci_cmd_buf[6] = *(bdaddr + 3); + hci_cmd_buf[7] = *(bdaddr + 4); + hci_cmd_buf[8] = *(bdaddr + 5); + hci_cmd_buf[9] = 0x01; // switch role to (slave = 1 / master = 0) + + return HCI_Command(10, hci_cmd_buf); } static int hci_remote_name(u8 *bdaddr) { - hci_cmd_buf[0] = HCI_OCF_REMOTE_NAME; // HCI OCF = 19 - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 - hci_cmd_buf[2] = 0x0A; // parameter length = 10 - hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address - hci_cmd_buf[4] = *(bdaddr + 1); - hci_cmd_buf[5] = *(bdaddr + 2); - hci_cmd_buf[6] = *(bdaddr + 3); - hci_cmd_buf[7] = *(bdaddr + 4); - hci_cmd_buf[8] = *(bdaddr + 5); - hci_cmd_buf[9] = 0x01; // Page Scan Repetition Mode - hci_cmd_buf[10] = 0x00; // Reserved - hci_cmd_buf[11] = 0x00; // Clock offset - low byte - hci_cmd_buf[12] = 0x00; // Clock offset - high byte - - return HCI_Command(13, hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_REMOTE_NAME; // HCI OCF = 19 + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 + hci_cmd_buf[2] = 0x0A; // parameter length = 10 + hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address + hci_cmd_buf[4] = *(bdaddr + 1); + hci_cmd_buf[5] = *(bdaddr + 2); + hci_cmd_buf[6] = *(bdaddr + 3); + hci_cmd_buf[7] = *(bdaddr + 4); + hci_cmd_buf[8] = *(bdaddr + 5); + hci_cmd_buf[9] = 0x01; // Page Scan Repetition Mode + hci_cmd_buf[10] = 0x00; // Reserved + hci_cmd_buf[11] = 0x00; // Clock offset - low byte + hci_cmd_buf[12] = 0x00; // Clock offset - high byte + + return HCI_Command(13, hci_cmd_buf); } static int hci_reject_connection(u8 *bdaddr) { - hci_cmd_buf[0] = HCI_OCF_REJECT_CONNECTION; // HCI OCF = A - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 - hci_cmd_buf[2] = 0x07; // parameter length 7 - hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address - hci_cmd_buf[4] = *(bdaddr + 1); - hci_cmd_buf[5] = *(bdaddr + 2); - hci_cmd_buf[6] = *(bdaddr + 3); - hci_cmd_buf[7] = *(bdaddr + 4); - hci_cmd_buf[8] = *(bdaddr + 5); - hci_cmd_buf[9] = 0x09; // reason max connection - - return HCI_Command(10, hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_REJECT_CONNECTION; // HCI OCF = A + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 + hci_cmd_buf[2] = 0x07; // parameter length 7 + hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address + hci_cmd_buf[4] = *(bdaddr + 1); + hci_cmd_buf[5] = *(bdaddr + 2); + hci_cmd_buf[6] = *(bdaddr + 3); + hci_cmd_buf[7] = *(bdaddr + 4); + hci_cmd_buf[8] = *(bdaddr + 5); + hci_cmd_buf[9] = 0x09; // reason max connection + + return HCI_Command(10, hci_cmd_buf); } static int hci_disconnect(u16 handle) { - hci_cmd_buf[0] = HCI_OCF_DISCONNECT; // HCI OCF = 6 - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 - hci_cmd_buf[2] = 0x03; // parameter length = 3 - hci_cmd_buf[3] = (u8)(handle & 0xFF); // connection handle - low byte - hci_cmd_buf[4] = (u8)((handle >> 8) & 0x0F); // connection handle - high byte - hci_cmd_buf[5] = 0x13; // reason - - return HCI_Command(6, hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_DISCONNECT; // HCI OCF = 6 + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 + hci_cmd_buf[2] = 0x03; // parameter length = 3 + hci_cmd_buf[3] = (u8)(handle & 0xFF); // connection handle - low byte + hci_cmd_buf[4] = (u8)((handle >> 8) & 0x0F); // connection handle - high byte + hci_cmd_buf[5] = 0x13; // reason + + return HCI_Command(6, hci_cmd_buf); } static int hci_change_connection_type(u16 handle) { - hci_cmd_buf[0] = HCI_OCF_CHANGE_CONNECTION_TYPE; - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; - hci_cmd_buf[2] = 0x04; // parameter length 4 - hci_cmd_buf[3] = (u8)(handle & 0xFF); // connection handle - low byte - hci_cmd_buf[4] = (u8)((handle >> 8) & 0x0F); // connection handle - high byte - hci_cmd_buf[5] = 0x18; // Packet Type: 0xcc18 - hci_cmd_buf[6] = 0xcc; - - return HCI_Command(7, hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_CHANGE_CONNECTION_TYPE; + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; + hci_cmd_buf[2] = 0x04; // parameter length 4 + hci_cmd_buf[3] = (u8)(handle & 0xFF); // connection handle - low byte + hci_cmd_buf[4] = (u8)((handle >> 8) & 0x0F); // connection handle - high byte + hci_cmd_buf[5] = 0x18; // Packet Type: 0xcc18 + hci_cmd_buf[6] = 0xcc; + + return HCI_Command(7, hci_cmd_buf); } static int hci_read_bdaddr() { - hci_cmd_buf[0] = HCI_OCF_READ_BDADDR; // HCI OCF = 9 - hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 - hci_cmd_buf[2] = 0x00; + hci_cmd_buf[0] = HCI_OCF_READ_BDADDR; // HCI OCF = 9 + hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 + hci_cmd_buf[2] = 0x00; - return HCI_Command(3, hci_cmd_buf); + return HCI_Command(3, hci_cmd_buf); } static int hci_read_local_version_information() { - hci_cmd_buf[0] = HCI_OCF_READ_VERSION; // HCI OCF = 9 - hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 - hci_cmd_buf[2] = 0x00; + hci_cmd_buf[0] = HCI_OCF_READ_VERSION; // HCI OCF = 9 + hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 + hci_cmd_buf[2] = 0x00; - return HCI_Command(3, hci_cmd_buf); + return HCI_Command(3, hci_cmd_buf); } static int hci_read_local_supported_features() { - hci_cmd_buf[0] = HCI_OCF_READ_FEATURES; // HCI OCF = 9 - hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 - hci_cmd_buf[2] = 0x00; + hci_cmd_buf[0] = HCI_OCF_READ_FEATURES; // HCI OCF = 9 + hci_cmd_buf[1] = HCI_OGF_INFO_PARAM; // HCI OGF = 4 + hci_cmd_buf[2] = 0x00; - return HCI_Command(3, hci_cmd_buf); + return HCI_Command(3, hci_cmd_buf); } static int hci_link_key_request_reply(u8 *bdaddr) { - hci_cmd_buf[0] = HCI_OCF_LINK_KEY_REQUEST_REPLY; // HCI OCF = 0E - hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 - hci_cmd_buf[2] = 0x06 + sizeof(link_key); // parameter length 6 - hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address - hci_cmd_buf[4] = *(bdaddr + 1); - hci_cmd_buf[5] = *(bdaddr + 2); - hci_cmd_buf[6] = *(bdaddr + 3); - hci_cmd_buf[7] = *(bdaddr + 4); - hci_cmd_buf[8] = *(bdaddr + 5); - - mips_memcpy(&hci_cmd_buf[9], link_key, sizeof(link_key)); - - return HCI_Command(9 + sizeof(link_key), hci_cmd_buf); + hci_cmd_buf[0] = HCI_OCF_LINK_KEY_REQUEST_REPLY; // HCI OCF = 0E + hci_cmd_buf[1] = HCI_OGF_LINK_CNTRL; // HCI OGF = 1 + hci_cmd_buf[2] = 0x06 + sizeof(link_key); // parameter length 6 + hci_cmd_buf[3] = *bdaddr; // 6 octet bluetooth address + hci_cmd_buf[4] = *(bdaddr + 1); + hci_cmd_buf[5] = *(bdaddr + 2); + hci_cmd_buf[6] = *(bdaddr + 3); + hci_cmd_buf[7] = *(bdaddr + 4); + hci_cmd_buf[8] = *(bdaddr + 5); + + mips_memcpy(&hci_cmd_buf[9], link_key, sizeof(link_key)); + + return HCI_Command(9 + sizeof(link_key), hci_cmd_buf); } static void HCI_event_task(int result) { - int i, pad; - - if (!result) { - /* buf[0] = Event Code */ - /* buf[1] = Parameter Total Length */ - /* buf[n] = Event Parameters based on each event */ - DPRINTF("HCI event = 0x%02X \n", hci_buf[0]); - switch (hci_buf[0]) { // switch on event type - case HCI_EVENT_COMMAND_COMPLETE: - DPRINTF("HCI Command Complete = 0x%02X \n", hci_buf[3]); - DPRINTF("\tReturned = 0x%02X \n", hci_buf[5]); - if ((hci_buf[3] == HCI_OCF_RESET) && (hci_buf[4] == HCI_OGF_CTRL_BBAND)) { - if (hci_buf[5] == 0) { - hci_read_bdaddr(); - } else { - DelayThread(500); - hci_reset(); - } - } else if ((hci_buf[3] == HCI_OCF_READ_BDADDR) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { - if (hci_buf[5] == 0) { - mips_memcpy(bt_bdaddr, &hci_buf[6], 6); - hci_read_local_version_information(); - } else { - DelayThread(500); - hci_reset(); - } - } else if ((hci_buf[3] == HCI_OCF_READ_VERSION) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { - if (hci_buf[5] == 0) { - mips_memcpy(&bt_version, &hci_buf[6], sizeof(hci_information_t)); - hci_read_local_supported_features(); - } else { - DelayThread(500); - hci_reset(); - } - } else if ((hci_buf[3] == HCI_OCF_READ_FEATURES) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { - if (hci_buf[5] == 0) { - mips_memcpy(bt_features, &hci_buf[6], sizeof(bt_features)); - hci_write_scan_enable(SCAN_ENABLE_NOINQ_ENPAG); - } else { - DelayThread(500); - hci_reset(); - } - } else if ((hci_buf[3] == HCI_OCF_WRITE_SCAN_ENABLE) && (hci_buf[4] == HCI_OGF_CTRL_BBAND)) { - if (hci_buf[5] == 0) { - bt_dev.status |= DS34BT_STATE_USB_CONFIGURED; - } else { - DelayThread(500); - hci_reset(); - } - } - break; - - case HCI_EVENT_COMMAND_STATUS: - if (hci_buf[2]) // show status on serial if not OK - { - DPRINTF("HCI Command Failed: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - DPRINTF("\t Command_OpCode(OGF) = 0x%02X \n", ((hci_buf[5] & 0xFC) >> 2)); - DPRINTF("\t Command_OpCode(OCF) = 0x%02X 0x%02X \n", (hci_buf[5] & 0x03), hci_buf[4]); - } - break; - - case HCI_EVENT_CONNECT_COMPLETE: - DPRINTF("HCI event Connect Complete: \n"); - if (!hci_buf[2]) // check if connected OK - { - DPRINTF("\t Connection_Handle 0x%02X \n", hci_buf[3] | ((hci_buf[4] & 0x0F) << 8)); - DPRINTF("\t Requested by BD_ADDR: \n\t"); - for (i = 0; i < 6; i++) { - DPRINTF("0x%02X", hci_buf[5 + i]); - if (i < 5) - DPRINTF(":"); - } - DPRINTF("\n"); - for (i = 0; i < MAX_PADS; i++) { - if (memcmp(ds34pad[i].bdaddr, hci_buf + 5, 6) == 0) { - // store the handle for the ACL connection - ds34pad[i].hci_handle = hci_buf[3] | ((hci_buf[4] & 0x0F) << 8); - break; - } - } - if (i >= MAX_PADS) { - break; - } - pad_status_set(DS34BT_STATE_CONNECTED, i); - hci_remote_name(ds34pad[i].bdaddr); - } else { - DPRINTF("\t Error 0x%02X \n", hci_buf[2]); - } - break; - - case HCI_EVENT_NUM_COMPLETED_PKT: - DPRINTF("HCI Number Of Completed Packets Event: \n"); - DPRINTF("\t Number_of_Handles = 0x%02X \n", hci_buf[2]); - for (i = 0; i < hci_buf[2]; i++) { - DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3 + i] | ((hci_buf[4 + i] & 0x0F) << 8))); - } - break; - - case HCI_EVENT_QOS_SETUP_COMPLETE: - break; - - case HCI_EVENT_DISCONN_COMPLETE: - DPRINTF("HCI Disconnection Complete Event: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); - DPRINTF("\t Reason = 0x%02X \n", hci_buf[5]); - for (i = 0; i < MAX_PADS; i++) { // detect pad - if (ds34pad[i].hci_handle == (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))) { - break; - } - } - ds34pad_clear(i); - break; - - case HCI_EVENT_AUTHENTICATION_COMPLETE: - DPRINTF("HCI Authentication Complete Event: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); - if (!hci_buf[2]) { - DPRINTF("\t Success \n"); - } else { - DPRINTF("\t Failed \n"); - } - break; - - case HCI_EVENT_REMOTE_NAME_COMPLETE: - DPRINTF("HCI Remote Name Requested Complete Event: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - if (!hci_buf[2]) { - for (i = 0; i < MAX_PADS; i++) { - if (memcmp(ds34pad[i].bdaddr, hci_buf + 3, 6) == 0) { - break; - } - } - if (i >= MAX_PADS) { - break; - } - if (memcmp(hci_buf + 9, "Wireless Controller", 19) == 0) { - ds34pad[i].type = DS4; - ds34pad[i].isfake = 0; - DPRINTF("\t Type: Dualshock 4 \n"); - } else { - ds34pad[i].type = DS3; - DPRINTF("\t Type: Dualshock 3 \n"); - } - hci_change_connection_type(ds34pad[i].hci_handle); - if (ds34pad[i].type == DS4) { - identifier++; - l2cap_connection_request(ds34pad[i].hci_handle, identifier, 0x0070, L2CAP_PSM_CTRL); - } - } - break; - - case HCI_EVENT_ENCRYPTION_CHANGE: - DPRINTF("HCI Encryption Change Event: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); - DPRINTF("\t Encryption_Enabled = 0x%02X \n", hci_buf[5]); - break; - - case HCI_EVENT_CONNECT_REQUEST: - DPRINTF("HCI Connection Requested by BD_ADDR: \n\t"); - for (i = 0; i < 6; i++) { - DPRINTF("0x%02X", hci_buf[2 + i]); - if (i < 5) - DPRINTF(":"); - } - DPRINTF("\n\t Link = 0x%02X \n", hci_buf[11]); - DPRINTF("\t Class = 0x%02X 0x%02X 0x%02X \n", hci_buf[8], hci_buf[9], hci_buf[10]); - for (i = 0; i < MAX_PADS; i++) // find free slot - { - if (!pad_status_check(DS34BT_STATE_RUNNING, i) && ds34pad[i].enabled) { - if (pad_status_check(DS34BT_STATE_CONNECTED, i)) { - if (pad_status_check(DS34BT_STATE_DISCONNECTING, i)) // if we're waiting for hci disconnect event - continue; - else - hci_disconnect(ds34pad[i].hci_handle); // try to disconnect - } - break; - } - } - if (i >= MAX_PADS) // no free slot - { - hci_reject_connection(hci_buf + 2); - break; - } - pad = i; - mips_memcpy(ds34pad[pad].bdaddr, hci_buf + 2, 6); - ds34pad[pad].isfake = 0; - if (!disable_fake) { - ds34pad[pad].isfake = 1; // fake ds3 - for (i = 0; i < sizeof(GenuineMacAddress) / 3; i++) // check if ds3 is genuine - { - if (ds34pad[pad].bdaddr[5] == GenuineMacAddress[i][0] && - ds34pad[pad].bdaddr[4] == GenuineMacAddress[i][1] && - ds34pad[pad].bdaddr[3] == GenuineMacAddress[i][2]) { - ds34pad[pad].isfake = 0; - break; - } - } - } - pad_status_clear(DS34BT_STATE_CONNECTED, pad); - pad_status_clear(DS34BT_STATE_RUNNING, pad); - pad_status_clear(DS34BT_STATE_DISCONNECTING, pad); - hci_accept_connection(ds34pad[pad].bdaddr); - break; - - case HCI_EVENT_ROLE_CHANGED: - DPRINTF("HCI Role Change Event: \n"); - DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); - DPRINTF("\t BD_ADDR: "); - for (i = 0; i < 6; i++) { - DPRINTF("0x%02X", hci_buf[3 + i]); - if (i < 5) - DPRINTF(":"); - } - DPRINTF("\n\t Role 0x%02X \n", hci_buf[9]); - break; - - case HCI_EVENT_MAX_SLOT_CHANGE: - DPRINTF("HCI Max Slot Change Event: \n"); - DPRINTF("\t Connection_Handle = 0x%x \n", (hci_buf[2] | ((hci_buf[3] & 0x0F) << 8))); - DPRINTF("\t LMP Max Slots = 0x%x \n", hci_buf[5]); - break; - - case HCI_EVENT_PIN_CODE_REQUEST: - DPRINTF("HCI Pin Code Request Event \n"); - break; - - case HCI_EVENT_LINK_KEY_REQUEST: - DPRINTF("HCI Link Key Request Event by BD_ADDR: \n\t"); - for (i = 0; i < 6; i++) { - DPRINTF("0x%02X", hci_buf[2 + i]); - if (i < 5) - DPRINTF(":"); - } - DPRINTF("\n"); - hci_link_key_request_reply(hci_buf + 2); - break; - - case HCI_EVENT_CHANGED_CONNECTION_TYPE: - DPRINTF("Packet Type Changed STATUS: 0x%x \n", hci_buf[2]); - DPRINTF("\t Type = %x \n", (hci_buf[5] | (hci_buf[6] << 8))); - break; - - case HCI_EVENT_PAGE_SR_CHANGED: - break; - - default: - DPRINTF("Unmanaged Event: 0x%02X \n", hci_buf[0]); - break; - } // switch (buf[0]) - } + int i, pad; + + if (!result) { + /* buf[0] = Event Code */ + /* buf[1] = Parameter Total Length */ + /* buf[n] = Event Parameters based on each event */ + DPRINTF("HCI event = 0x%02X \n", hci_buf[0]); + switch (hci_buf[0]) { // switch on event type + case HCI_EVENT_COMMAND_COMPLETE: + DPRINTF("HCI Command Complete = 0x%02X \n", hci_buf[3]); + DPRINTF("\tReturned = 0x%02X \n", hci_buf[5]); + if ((hci_buf[3] == HCI_OCF_RESET) && (hci_buf[4] == HCI_OGF_CTRL_BBAND)) { + if (hci_buf[5] == 0) { + hci_read_bdaddr(); + } else { + DelayThread(500); + hci_reset(); + } + } else if ((hci_buf[3] == HCI_OCF_READ_BDADDR) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { + if (hci_buf[5] == 0) { + mips_memcpy(bt_bdaddr, &hci_buf[6], 6); + hci_read_local_version_information(); + } else { + DelayThread(500); + hci_reset(); + } + } else if ((hci_buf[3] == HCI_OCF_READ_VERSION) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { + if (hci_buf[5] == 0) { + mips_memcpy(&bt_version, &hci_buf[6], sizeof(hci_information_t)); + hci_read_local_supported_features(); + } else { + DelayThread(500); + hci_reset(); + } + } else if ((hci_buf[3] == HCI_OCF_READ_FEATURES) && (hci_buf[4] == HCI_OGF_INFO_PARAM)) { + if (hci_buf[5] == 0) { + mips_memcpy(bt_features, &hci_buf[6], sizeof(bt_features)); + hci_write_scan_enable(SCAN_ENABLE_NOINQ_ENPAG); + } else { + DelayThread(500); + hci_reset(); + } + } else if ((hci_buf[3] == HCI_OCF_WRITE_SCAN_ENABLE) && (hci_buf[4] == HCI_OGF_CTRL_BBAND)) { + if (hci_buf[5] == 0) { + bt_dev.status |= DS34BT_STATE_USB_CONFIGURED; + } else { + DelayThread(500); + hci_reset(); + } + } + break; + + case HCI_EVENT_COMMAND_STATUS: + if (hci_buf[2]) // show status on serial if not OK + { + DPRINTF("HCI Command Failed: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + DPRINTF("\t Command_OpCode(OGF) = 0x%02X \n", ((hci_buf[5] & 0xFC) >> 2)); + DPRINTF("\t Command_OpCode(OCF) = 0x%02X 0x%02X \n", (hci_buf[5] & 0x03), hci_buf[4]); + } + break; + + case HCI_EVENT_CONNECT_COMPLETE: + DPRINTF("HCI event Connect Complete: \n"); + if (!hci_buf[2]) // check if connected OK + { + DPRINTF("\t Connection_Handle 0x%02X \n", hci_buf[3] | ((hci_buf[4] & 0x0F) << 8)); + DPRINTF("\t Requested by BD_ADDR: \n\t"); + for (i = 0; i < 6; i++) { + DPRINTF("0x%02X", hci_buf[5 + i]); + if (i < 5) + DPRINTF(":"); + } + DPRINTF("\n"); + for (i = 0; i < MAX_PADS; i++) { + if (memcmp(ds34pad[i].bdaddr, hci_buf + 5, 6) == 0) { + // store the handle for the ACL connection + ds34pad[i].hci_handle = hci_buf[3] | ((hci_buf[4] & 0x0F) << 8); + break; + } + } + if (i >= MAX_PADS) { + break; + } + pad_status_set(DS34BT_STATE_CONNECTED, i); + hci_remote_name(ds34pad[i].bdaddr); + } else { + DPRINTF("\t Error 0x%02X \n", hci_buf[2]); + } + break; + + case HCI_EVENT_NUM_COMPLETED_PKT: + DPRINTF("HCI Number Of Completed Packets Event: \n"); + DPRINTF("\t Number_of_Handles = 0x%02X \n", hci_buf[2]); + for (i = 0; i < hci_buf[2]; i++) { + DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3 + i] | ((hci_buf[4 + i] & 0x0F) << 8))); + } + break; + + case HCI_EVENT_QOS_SETUP_COMPLETE: + break; + + case HCI_EVENT_DISCONN_COMPLETE: + DPRINTF("HCI Disconnection Complete Event: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); + DPRINTF("\t Reason = 0x%02X \n", hci_buf[5]); + for (i = 0; i < MAX_PADS; i++) { // detect pad + if (ds34pad[i].hci_handle == (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))) { + break; + } + } + ds34pad_clear(i); + break; + + case HCI_EVENT_AUTHENTICATION_COMPLETE: + DPRINTF("HCI Authentication Complete Event: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); + if (!hci_buf[2]) { + DPRINTF("\t Success \n"); + } else { + DPRINTF("\t Failed \n"); + } + break; + + case HCI_EVENT_REMOTE_NAME_COMPLETE: + DPRINTF("HCI Remote Name Requested Complete Event: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + if (!hci_buf[2]) { + for (i = 0; i < MAX_PADS; i++) { + if (memcmp(ds34pad[i].bdaddr, hci_buf + 3, 6) == 0) { + break; + } + } + if (i >= MAX_PADS) { + break; + } + if (memcmp(hci_buf + 9, "Wireless Controller", 19) == 0) { + ds34pad[i].type = DS4; + ds34pad[i].isfake = 0; + DPRINTF("\t Type: Dualshock 4 \n"); + } else { + ds34pad[i].type = DS3; + DPRINTF("\t Type: Dualshock 3 \n"); + } + hci_change_connection_type(ds34pad[i].hci_handle); + if (ds34pad[i].type == DS4) { + identifier++; + l2cap_connection_request(ds34pad[i].hci_handle, identifier, 0x0070, L2CAP_PSM_CTRL); + } + } + break; + + case HCI_EVENT_ENCRYPTION_CHANGE: + DPRINTF("HCI Encryption Change Event: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + DPRINTF("\t Connection_Handle = 0x%04X \n", (hci_buf[3] | ((hci_buf[4] & 0x0F) << 8))); + DPRINTF("\t Encryption_Enabled = 0x%02X \n", hci_buf[5]); + break; + + case HCI_EVENT_CONNECT_REQUEST: + DPRINTF("HCI Connection Requested by BD_ADDR: \n\t"); + for (i = 0; i < 6; i++) { + DPRINTF("0x%02X", hci_buf[2 + i]); + if (i < 5) + DPRINTF(":"); + } + DPRINTF("\n\t Link = 0x%02X \n", hci_buf[11]); + DPRINTF("\t Class = 0x%02X 0x%02X 0x%02X \n", hci_buf[8], hci_buf[9], hci_buf[10]); + for (i = 0; i < MAX_PADS; i++) // find free slot + { + if (!pad_status_check(DS34BT_STATE_RUNNING, i) && ds34pad[i].enabled) { + if (pad_status_check(DS34BT_STATE_CONNECTED, i)) { + if (pad_status_check(DS34BT_STATE_DISCONNECTING, i)) // if we're waiting for hci disconnect event + continue; + else + hci_disconnect(ds34pad[i].hci_handle); // try to disconnect + } + break; + } + } + if (i >= MAX_PADS) // no free slot + { + hci_reject_connection(hci_buf + 2); + break; + } + pad = i; + mips_memcpy(ds34pad[pad].bdaddr, hci_buf + 2, 6); + ds34pad[pad].isfake = 0; + if (!disable_fake) { + ds34pad[pad].isfake = 1; // fake ds3 + for (i = 0; i < sizeof(GenuineMacAddress) / 3; i++) // check if ds3 is genuine + { + if (ds34pad[pad].bdaddr[5] == GenuineMacAddress[i][0] && + ds34pad[pad].bdaddr[4] == GenuineMacAddress[i][1] && + ds34pad[pad].bdaddr[3] == GenuineMacAddress[i][2]) { + ds34pad[pad].isfake = 0; + break; + } + } + } + pad_status_clear(DS34BT_STATE_CONNECTED, pad); + pad_status_clear(DS34BT_STATE_RUNNING, pad); + pad_status_clear(DS34BT_STATE_DISCONNECTING, pad); + hci_accept_connection(ds34pad[pad].bdaddr); + break; + + case HCI_EVENT_ROLE_CHANGED: + DPRINTF("HCI Role Change Event: \n"); + DPRINTF("\t Status = 0x%02X \n", hci_buf[2]); + DPRINTF("\t BD_ADDR: "); + for (i = 0; i < 6; i++) { + DPRINTF("0x%02X", hci_buf[3 + i]); + if (i < 5) + DPRINTF(":"); + } + DPRINTF("\n\t Role 0x%02X \n", hci_buf[9]); + break; + + case HCI_EVENT_MAX_SLOT_CHANGE: + DPRINTF("HCI Max Slot Change Event: \n"); + DPRINTF("\t Connection_Handle = 0x%x \n", (hci_buf[2] | ((hci_buf[3] & 0x0F) << 8))); + DPRINTF("\t LMP Max Slots = 0x%x \n", hci_buf[5]); + break; + + case HCI_EVENT_PIN_CODE_REQUEST: + DPRINTF("HCI Pin Code Request Event \n"); + break; + + case HCI_EVENT_LINK_KEY_REQUEST: + DPRINTF("HCI Link Key Request Event by BD_ADDR: \n\t"); + for (i = 0; i < 6; i++) { + DPRINTF("0x%02X", hci_buf[2 + i]); + if (i < 5) + DPRINTF(":"); + } + DPRINTF("\n"); + hci_link_key_request_reply(hci_buf + 2); + break; + + case HCI_EVENT_CHANGED_CONNECTION_TYPE: + DPRINTF("Packet Type Changed STATUS: 0x%x \n", hci_buf[2]); + DPRINTF("\t Type = %x \n", (hci_buf[5] | (hci_buf[6] << 8))); + break; + + case HCI_EVENT_PAGE_SR_CHANGED: + break; + + default: + DPRINTF("Unmanaged Event: 0x%02X \n", hci_buf[0]); + break; + } // switch (buf[0]) + } } static void ds34pad_clear(int pad) { - if (pad >= MAX_PADS) - return; - - ds34pad[pad].hci_handle = 0x0FFF; - ds34pad[pad].control_scid = 0; - ds34pad[pad].interrupt_scid = 0; - mips_memset(ds34pad[pad].bdaddr, 0, 6); - ds34pad[pad].status = bt_dev.status; - ds34pad[pad].isfake = 0; - ds34pad[pad].type = 0; - ds34pad[pad].data[0] = 0xFF; - ds34pad[pad].data[1] = 0xFF; - mips_memset(&ds34pad[pad].data[2], 0x7F, 4); - mips_memset(&ds34pad[pad].data[6], 0x00, 12); + if (pad >= MAX_PADS) + return; + + ds34pad[pad].hci_handle = 0x0FFF; + ds34pad[pad].control_scid = 0; + ds34pad[pad].interrupt_scid = 0; + mips_memset(ds34pad[pad].bdaddr, 0, 6); + ds34pad[pad].status = bt_dev.status; + ds34pad[pad].isfake = 0; + ds34pad[pad].type = 0; + ds34pad[pad].data[0] = 0xFF; + ds34pad[pad].data[1] = 0xFF; + mips_memset(&ds34pad[pad].data[2], 0x7F, 4); + mips_memset(&ds34pad[pad].data[6], 0x00, 12); } static void ds34pad_init() { - int i; + int i; - for (i = 0; i < MAX_PADS; i++) { - ds34pad_clear(i); - } + for (i = 0; i < MAX_PADS; i++) { + ds34pad_clear(i); + } - press_emu = 0; - identifier = 0; + press_emu = 0; + identifier = 0; } static void hci_event_cb(int resultCode, int bytes, void *arg) { - PollSema(bt_dev.hid_sema); - HCI_event_task(resultCode); - UsbInterruptTransfer(bt_dev.interruptEndp, hci_buf, MAX_BUFFER_SIZE, hci_event_cb, NULL); - SignalSema(bt_dev.hid_sema); + PollSema(bt_dev.hid_sema); + HCI_event_task(resultCode); + UsbInterruptTransfer(bt_dev.interruptEndp, hci_buf, MAX_BUFFER_SIZE, hci_event_cb, NULL); + SignalSema(bt_dev.hid_sema); } /************************************************************/ @@ -835,330 +835,330 @@ static void hci_event_cb(int resultCode, int bytes, void *arg) static int L2CAP_Command(u16 handle, u8 *data, u8 length) { - l2cap_cmd_buf[0] = (u8)(handle & 0xff); // HCI handle with PB,BC flag - l2cap_cmd_buf[1] = (u8)(((handle >> 8) & 0x0f) | 0x20); - l2cap_cmd_buf[2] = (u8)((4 + length) & 0xff); // HCI ACL total data length - l2cap_cmd_buf[3] = (u8)((4 + length) >> 8); - l2cap_cmd_buf[4] = (u8)(length & 0xff); // L2CAP header: Length - l2cap_cmd_buf[5] = (u8)(length >> 8); - l2cap_cmd_buf[6] = 0x01; // L2CAP header: Channel ID - l2cap_cmd_buf[7] = 0x00; // L2CAP Signalling channel over ACL-U logical link - - mips_memcpy(&l2cap_cmd_buf[8], data, length); - - // output on endpoint 2 - return UsbBulkTransfer(bt_dev.outEndp, l2cap_cmd_buf, (8 + length), NULL, NULL); + l2cap_cmd_buf[0] = (u8)(handle & 0xff); // HCI handle with PB,BC flag + l2cap_cmd_buf[1] = (u8)(((handle >> 8) & 0x0f) | 0x20); + l2cap_cmd_buf[2] = (u8)((4 + length) & 0xff); // HCI ACL total data length + l2cap_cmd_buf[3] = (u8)((4 + length) >> 8); + l2cap_cmd_buf[4] = (u8)(length & 0xff); // L2CAP header: Length + l2cap_cmd_buf[5] = (u8)(length >> 8); + l2cap_cmd_buf[6] = 0x01; // L2CAP header: Channel ID + l2cap_cmd_buf[7] = 0x00; // L2CAP Signalling channel over ACL-U logical link + + mips_memcpy(&l2cap_cmd_buf[8], data, length); + + // output on endpoint 2 + return UsbBulkTransfer(bt_dev.outEndp, l2cap_cmd_buf, (8 + length), NULL, NULL); } static int l2cap_connection_request(u16 handle, u8 rxid, u16 scid, u16 psm) { - u8 cmd_buf[8]; - - cmd_buf[0] = L2CAP_CMD_CONNECTION_REQUEST; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x04; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(psm & 0xff); // PSM - cmd_buf[5] = (u8)(psm >> 8); - cmd_buf[6] = (u8)(scid & 0xff); // Source CID (PS Remote) - cmd_buf[7] = (u8)(scid >> 8); - - return L2CAP_Command(handle, cmd_buf, 8); + u8 cmd_buf[8]; + + cmd_buf[0] = L2CAP_CMD_CONNECTION_REQUEST; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x04; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(psm & 0xff); // PSM + cmd_buf[5] = (u8)(psm >> 8); + cmd_buf[6] = (u8)(scid & 0xff); // Source CID (PS Remote) + cmd_buf[7] = (u8)(scid >> 8); + + return L2CAP_Command(handle, cmd_buf, 8); } static int l2cap_connection_response(u16 handle, u8 rxid, u16 dcid, u16 scid, u8 result) { - u8 cmd_buf[12]; - - cmd_buf[0] = L2CAP_CMD_CONNECTION_RESPONSE; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x08; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID (Our) - cmd_buf[5] = (u8)(dcid >> 8); - cmd_buf[6] = (u8)(scid & 0xff); // Source CID (PS Remote) - cmd_buf[7] = (u8)(scid >> 8); - cmd_buf[8] = result; // Result - cmd_buf[9] = 0x00; - cmd_buf[10] = 0x00; // Status - cmd_buf[11] = 0x00; - - if (result != 0) - cmd_buf[10] = 0x01; // Authentication pending - - return L2CAP_Command(handle, cmd_buf, 12); + u8 cmd_buf[12]; + + cmd_buf[0] = L2CAP_CMD_CONNECTION_RESPONSE; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x08; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID (Our) + cmd_buf[5] = (u8)(dcid >> 8); + cmd_buf[6] = (u8)(scid & 0xff); // Source CID (PS Remote) + cmd_buf[7] = (u8)(scid >> 8); + cmd_buf[8] = result; // Result + cmd_buf[9] = 0x00; + cmd_buf[10] = 0x00; // Status + cmd_buf[11] = 0x00; + + if (result != 0) + cmd_buf[10] = 0x01; // Authentication pending + + return L2CAP_Command(handle, cmd_buf, 12); } static int l2cap_config_request(u16 handle, u8 rxid, u16 dcid) { - u8 cmd_buf[12]; - - cmd_buf[0] = L2CAP_CMD_CONFIG_REQUEST; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x08; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID - cmd_buf[5] = (u8)(dcid >> 8); - cmd_buf[6] = 0x00; // Flags - cmd_buf[7] = 0x00; - cmd_buf[8] = 0x01; // Config Opt: type = MTU (Maximum Transmission Unit) - cmd_buf[9] = 0x02; // Config Opt: length - // cmd_buf[10] = 0x96; // Config Opt: data - // cmd_buf[11] = 0x00; - - // this setting disable hid cmd reports from ds3 - cmd_buf[10] = 0xFF; // Config Opt: data - cmd_buf[11] = 0xFF; - - return L2CAP_Command(handle, cmd_buf, 12); + u8 cmd_buf[12]; + + cmd_buf[0] = L2CAP_CMD_CONFIG_REQUEST; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x08; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID + cmd_buf[5] = (u8)(dcid >> 8); + cmd_buf[6] = 0x00; // Flags + cmd_buf[7] = 0x00; + cmd_buf[8] = 0x01; // Config Opt: type = MTU (Maximum Transmission Unit) + cmd_buf[9] = 0x02; // Config Opt: length + // cmd_buf[10] = 0x96; // Config Opt: data + // cmd_buf[11] = 0x00; + + // this setting disable hid cmd reports from ds3 + cmd_buf[10] = 0xFF; // Config Opt: data + cmd_buf[11] = 0xFF; + + return L2CAP_Command(handle, cmd_buf, 12); } static int l2cap_config_response(u16 handle, u8 rxid, u16 scid) { - u8 cmd_buf[14]; - - cmd_buf[0] = L2CAP_CMD_CONFIG_RESPONSE; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x0A; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(scid & 0xff); // Source CID - cmd_buf[5] = (u8)(scid >> 8); - cmd_buf[6] = 0x00; // Result - cmd_buf[7] = 0x00; - cmd_buf[8] = 0x00; // Config - cmd_buf[9] = 0x00; - cmd_buf[10] = 0x01; // Config - cmd_buf[11] = 0x02; - cmd_buf[12] = 0xA0; - cmd_buf[13] = 0x02; - - return L2CAP_Command(handle, cmd_buf, 14); + u8 cmd_buf[14]; + + cmd_buf[0] = L2CAP_CMD_CONFIG_RESPONSE; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x0A; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(scid & 0xff); // Source CID + cmd_buf[5] = (u8)(scid >> 8); + cmd_buf[6] = 0x00; // Result + cmd_buf[7] = 0x00; + cmd_buf[8] = 0x00; // Config + cmd_buf[9] = 0x00; + cmd_buf[10] = 0x01; // Config + cmd_buf[11] = 0x02; + cmd_buf[12] = 0xA0; + cmd_buf[13] = 0x02; + + return L2CAP_Command(handle, cmd_buf, 14); } static int l2cap_disconnection_request(u16 handle, u8 rxid, u16 dcid, u16 scid) { - u8 cmd_buf[8]; - - cmd_buf[0] = L2CAP_CMD_DISCONNECT_REQUEST; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x04; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID - cmd_buf[5] = (u8)(dcid >> 8); - cmd_buf[6] = (u8)(scid & 0xff); // Source CID - cmd_buf[7] = (u8)(scid >> 8); - - return L2CAP_Command(handle, cmd_buf, 8); + u8 cmd_buf[8]; + + cmd_buf[0] = L2CAP_CMD_DISCONNECT_REQUEST; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x04; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID + cmd_buf[5] = (u8)(dcid >> 8); + cmd_buf[6] = (u8)(scid & 0xff); // Source CID + cmd_buf[7] = (u8)(scid >> 8); + + return L2CAP_Command(handle, cmd_buf, 8); } static int l2cap_disconnection_response(u16 handle, u8 rxid, u16 scid, u16 dcid) { - u8 cmd_buf[8]; - - cmd_buf[0] = L2CAP_CMD_DISCONNECT_RESPONSE; // Code - cmd_buf[1] = rxid; // Identifier - cmd_buf[2] = 0x04; // Length - cmd_buf[3] = 0x00; - cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID - cmd_buf[5] = (u8)(dcid >> 8); - cmd_buf[6] = (u8)(scid & 0xff); // Source CID - cmd_buf[7] = (u8)(scid >> 8); - - return L2CAP_Command(handle, cmd_buf, 8); + u8 cmd_buf[8]; + + cmd_buf[0] = L2CAP_CMD_DISCONNECT_RESPONSE; // Code + cmd_buf[1] = rxid; // Identifier + cmd_buf[2] = 0x04; // Length + cmd_buf[3] = 0x00; + cmd_buf[4] = (u8)(dcid & 0xff); // Destination CID + cmd_buf[5] = (u8)(dcid >> 8); + cmd_buf[6] = (u8)(scid & 0xff); // Source CID + cmd_buf[7] = (u8)(scid >> 8); + + return L2CAP_Command(handle, cmd_buf, 8); } #define CMD_DELAY 2 static int L2CAP_event_task(int result, int bytes) { - int pad = -1; - u16 control_dcid = 0x0040; // Channel endpoint on command source - u16 interrupt_dcid = 0x0041; // Channel endpoint on interrupt source - - if (!result) { - for (pad = 0; pad < MAX_PADS; pad++) { - if (l2cap_handle_ok(ds34pad[pad].hci_handle)) - break; - } - - if (pad >= MAX_PADS) { - DPRINTF("L2CAP Wrong Handle = 0x%04X\n", ((l2cap_buf[0] | (l2cap_buf[1] << 8)))); - return pad; - } - - if (l2cap_handle_ok(ds34pad[pad].hci_handle)) { - if (ds34pad[pad].type == DS4) { - control_dcid = 0x0070; - interrupt_dcid = 0x0071; - } - - if (l2cap_control_channel) { - DPRINTF("L2CAP Signaling Command = 0x%02X, pad %d \n", l2cap_buf[8], pad); - - switch (l2cap_buf[8]) { - case L2CAP_CMD_COMMAND_REJECT: - DPRINTF("Command Reject ID = 0x%02X \n", l2cap_buf[9]); - DPRINTF("\t Reason = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - DPRINTF("\t DATA = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); - break; - - case L2CAP_CMD_CONNECTION_REQUEST: - DPRINTF("Connection Request ID = 0x%02X \n", l2cap_buf[9]); - DPRINTF("\t PSM = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); - - if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == L2CAP_PSM_CTRL) { - ds34pad[pad].control_scid = l2cap_buf[14] | (l2cap_buf[15] << 8); - l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid, PENDING); - DelayThread(CMD_DELAY); - l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid, SUCCESSFUL); - DelayThread(CMD_DELAY); - identifier++; - l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid); - } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == L2CAP_PSM_INTR) { - ds34pad[pad].interrupt_scid = l2cap_buf[14] | (l2cap_buf[15] << 8); - l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid, PENDING); - DelayThread(CMD_DELAY); - l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid, SUCCESSFUL); - DelayThread(CMD_DELAY); - identifier++; - l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].interrupt_scid); - } - break; - - case L2CAP_CMD_CONNECTION_RESPONSE: - DPRINTF("Connection Response ID = 0x%02X \n", l2cap_buf[9]); - DPRINTF("\t PSM = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); - DPRINTF("\t RESULT = 0x%04X \n", (l2cap_buf[16] | (l2cap_buf[17] << 8))); - - if (((l2cap_buf[16] | (l2cap_buf[17] << 8)) == 0x0000) && ((l2cap_buf[18] | (l2cap_buf[19] << 8)) == 0x0000)) { - if ((l2cap_buf[14] | (l2cap_buf[15] << 8)) == control_dcid) { - ds34pad[pad].control_scid = l2cap_buf[12] | (l2cap_buf[13] << 8); - identifier++; - l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid); - } else if ((l2cap_buf[14] | (l2cap_buf[15] << 8)) == interrupt_dcid) { - ds34pad[pad].interrupt_scid = l2cap_buf[12] | (l2cap_buf[13] << 8); - identifier++; - l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].interrupt_scid); - } - } - break; - - case L2CAP_CMD_CONFIG_REQUEST: - DPRINTF("Configuration Request ID = 0x%02X \n", l2cap_buf[9]); - DPRINTF("\t LEN = 0x%04X \n", (l2cap_buf[10] | (l2cap_buf[11] << 8))); - DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - DPRINTF("\t FLAG = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); - - if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { - l2cap_config_response(ds34pad[pad].hci_handle, l2cap_buf[9], ds34pad[pad].control_scid); - } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { - l2cap_config_response(ds34pad[pad].hci_handle, l2cap_buf[9], ds34pad[pad].interrupt_scid); - } - break; - - case L2CAP_CMD_CONFIG_RESPONSE: - DPRINTF("Configuration Response ID = 0x%02X \n", l2cap_buf[9]); - DPRINTF("\t LEN = 0x%04X \n", (l2cap_buf[10] | (l2cap_buf[11] << 8))); - DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - DPRINTF("\t FLAG = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); - DPRINTF("\t RESULT = 0x%04X \n", (l2cap_buf[16] | (l2cap_buf[17] << 8))); - - if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { - identifier++; - l2cap_connection_request(ds34pad[pad].hci_handle, identifier, interrupt_dcid, L2CAP_PSM_INTR); - } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { - hid_initDS34(pad); - if (ds34pad[pad].type == DS3) { - ds34pad[pad].oldled[0] = led_patterns[pad][1]; - ds34pad[pad].oldled[3] = 0; - } else if (ds34pad[pad].type == DS4) { - ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; - ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; - ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; - ds34pad[pad].oldled[3] = 0; - } - DelayThread(CMD_DELAY); - hid_LEDRumble(ds34pad[pad].oldled, 0, 0, pad); - pad_status_set(DS34BT_STATE_RUNNING, pad); - } - break; - - case L2CAP_CMD_DISCONNECT_REQUEST: - DPRINTF("Disconnect Request SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - - if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { - pad_status_set(DS34BT_STATE_DISCONNECTING, pad); - l2cap_disconnection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid); - } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { - pad_status_set(DS34BT_STATE_DISCONNECTING, pad); - l2cap_disconnection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid); - } - break; - - case L2CAP_CMD_DISCONNECT_RESPONSE: - DPRINTF("Disconnect Response SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); - - if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == ds34pad[pad].control_scid) { - pad_status_set(DS34BT_STATE_DISCONNECTING, pad); - hci_disconnect(ds34pad[pad].hci_handle); - } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == ds34pad[pad].interrupt_scid) { - pad_status_set(DS34BT_STATE_DISCONNECTING, pad); - identifier++; - l2cap_disconnection_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid, control_dcid); - } - break; - - default: - break; - } - } else if (l2cap_interrupt_channel) { - hid_readReport(l2cap_buf, bytes, pad); - } else if (l2cap_command_channel) { - DPRINTF("HID command status 0x%02X \n", l2cap_buf[8]); - pad = MAX_PADS; - } - } // acl_handle_ok - } // !rcode - - return pad; + int pad = -1; + u16 control_dcid = 0x0040; // Channel endpoint on command source + u16 interrupt_dcid = 0x0041; // Channel endpoint on interrupt source + + if (!result) { + for (pad = 0; pad < MAX_PADS; pad++) { + if (l2cap_handle_ok(ds34pad[pad].hci_handle)) + break; + } + + if (pad >= MAX_PADS) { + DPRINTF("L2CAP Wrong Handle = 0x%04X\n", ((l2cap_buf[0] | (l2cap_buf[1] << 8)))); + return pad; + } + + if (l2cap_handle_ok(ds34pad[pad].hci_handle)) { + if (ds34pad[pad].type == DS4) { + control_dcid = 0x0070; + interrupt_dcid = 0x0071; + } + + if (l2cap_control_channel) { + DPRINTF("L2CAP Signaling Command = 0x%02X, pad %d \n", l2cap_buf[8], pad); + + switch (l2cap_buf[8]) { + case L2CAP_CMD_COMMAND_REJECT: + DPRINTF("Command Reject ID = 0x%02X \n", l2cap_buf[9]); + DPRINTF("\t Reason = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + DPRINTF("\t DATA = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); + break; + + case L2CAP_CMD_CONNECTION_REQUEST: + DPRINTF("Connection Request ID = 0x%02X \n", l2cap_buf[9]); + DPRINTF("\t PSM = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); + + if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == L2CAP_PSM_CTRL) { + ds34pad[pad].control_scid = l2cap_buf[14] | (l2cap_buf[15] << 8); + l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid, PENDING); + DelayThread(CMD_DELAY); + l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid, SUCCESSFUL); + DelayThread(CMD_DELAY); + identifier++; + l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid); + } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == L2CAP_PSM_INTR) { + ds34pad[pad].interrupt_scid = l2cap_buf[14] | (l2cap_buf[15] << 8); + l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid, PENDING); + DelayThread(CMD_DELAY); + l2cap_connection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid, SUCCESSFUL); + DelayThread(CMD_DELAY); + identifier++; + l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].interrupt_scid); + } + break; + + case L2CAP_CMD_CONNECTION_RESPONSE: + DPRINTF("Connection Response ID = 0x%02X \n", l2cap_buf[9]); + DPRINTF("\t PSM = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); + DPRINTF("\t RESULT = 0x%04X \n", (l2cap_buf[16] | (l2cap_buf[17] << 8))); + + if (((l2cap_buf[16] | (l2cap_buf[17] << 8)) == 0x0000) && ((l2cap_buf[18] | (l2cap_buf[19] << 8)) == 0x0000)) { + if ((l2cap_buf[14] | (l2cap_buf[15] << 8)) == control_dcid) { + ds34pad[pad].control_scid = l2cap_buf[12] | (l2cap_buf[13] << 8); + identifier++; + l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid); + } else if ((l2cap_buf[14] | (l2cap_buf[15] << 8)) == interrupt_dcid) { + ds34pad[pad].interrupt_scid = l2cap_buf[12] | (l2cap_buf[13] << 8); + identifier++; + l2cap_config_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].interrupt_scid); + } + } + break; + + case L2CAP_CMD_CONFIG_REQUEST: + DPRINTF("Configuration Request ID = 0x%02X \n", l2cap_buf[9]); + DPRINTF("\t LEN = 0x%04X \n", (l2cap_buf[10] | (l2cap_buf[11] << 8))); + DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + DPRINTF("\t FLAG = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); + + if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { + l2cap_config_response(ds34pad[pad].hci_handle, l2cap_buf[9], ds34pad[pad].control_scid); + } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { + l2cap_config_response(ds34pad[pad].hci_handle, l2cap_buf[9], ds34pad[pad].interrupt_scid); + } + break; + + case L2CAP_CMD_CONFIG_RESPONSE: + DPRINTF("Configuration Response ID = 0x%02X \n", l2cap_buf[9]); + DPRINTF("\t LEN = 0x%04X \n", (l2cap_buf[10] | (l2cap_buf[11] << 8))); + DPRINTF("\t SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + DPRINTF("\t FLAG = 0x%04X \n", (l2cap_buf[14] | (l2cap_buf[15] << 8))); + DPRINTF("\t RESULT = 0x%04X \n", (l2cap_buf[16] | (l2cap_buf[17] << 8))); + + if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { + identifier++; + l2cap_connection_request(ds34pad[pad].hci_handle, identifier, interrupt_dcid, L2CAP_PSM_INTR); + } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { + hid_initDS34(pad); + if (ds34pad[pad].type == DS3) { + ds34pad[pad].oldled[0] = led_patterns[pad][1]; + ds34pad[pad].oldled[3] = 0; + } else if (ds34pad[pad].type == DS4) { + ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; + ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; + ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; + ds34pad[pad].oldled[3] = 0; + } + DelayThread(CMD_DELAY); + hid_LEDRumble(ds34pad[pad].oldled, 0, 0, pad); + pad_status_set(DS34BT_STATE_RUNNING, pad); + } + break; + + case L2CAP_CMD_DISCONNECT_REQUEST: + DPRINTF("Disconnect Request SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + + if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == control_dcid) { + pad_status_set(DS34BT_STATE_DISCONNECTING, pad); + l2cap_disconnection_response(ds34pad[pad].hci_handle, l2cap_buf[9], control_dcid, ds34pad[pad].control_scid); + } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == interrupt_dcid) { + pad_status_set(DS34BT_STATE_DISCONNECTING, pad); + l2cap_disconnection_response(ds34pad[pad].hci_handle, l2cap_buf[9], interrupt_dcid, ds34pad[pad].interrupt_scid); + } + break; + + case L2CAP_CMD_DISCONNECT_RESPONSE: + DPRINTF("Disconnect Response SCID = 0x%04X \n", (l2cap_buf[12] | (l2cap_buf[13] << 8))); + + if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == ds34pad[pad].control_scid) { + pad_status_set(DS34BT_STATE_DISCONNECTING, pad); + hci_disconnect(ds34pad[pad].hci_handle); + } else if ((l2cap_buf[12] | (l2cap_buf[13] << 8)) == ds34pad[pad].interrupt_scid) { + pad_status_set(DS34BT_STATE_DISCONNECTING, pad); + identifier++; + l2cap_disconnection_request(ds34pad[pad].hci_handle, identifier, ds34pad[pad].control_scid, control_dcid); + } + break; + + default: + break; + } + } else if (l2cap_interrupt_channel) { + hid_readReport(l2cap_buf, bytes, pad); + } else if (l2cap_command_channel) { + DPRINTF("HID command status 0x%02X \n", l2cap_buf[8]); + pad = MAX_PADS; + } + } // acl_handle_ok + } // !rcode + + return pad; } static void l2cap_event_cb(int resultCode, int bytes, void *arg) { - int ret; - u16 interrupt_dcid = 0x0041; - - PollSema(bt_dev.hid_sema); - - ret = L2CAP_event_task(resultCode, bytes); - - if (ret < MAX_PADS) { - if (pad_status_check(DS34BT_STATE_RUNNING, ret)) { - if (pad_status_check(DS34BT_STATE_DISCONNECT_REQUEST, ret)) { - if (!ds34pad[ret].isfake) { - if (ds34pad[ret].type == DS4) { - interrupt_dcid = 0x0071; - } - identifier++; - l2cap_disconnection_request(ds34pad[ret].hci_handle, identifier, ds34pad[ret].interrupt_scid, interrupt_dcid); - } else { - hci_disconnect(ds34pad[ret].hci_handle); - } - pad_status_clear(DS34BT_STATE_DISCONNECT_REQUEST, ret); - } else if (ds34pad[ret].update_rum) { - hid_LEDRumble(ds34pad[ret].oldled, ds34pad[ret].lrum, ds34pad[ret].rrum, ret); - ds34pad[ret].update_rum = 0; - } - } else { - if (!ds34pad[ret].isfake && ds34pad[ret].type == DS3) - DelayThread(42000); // fix for some bt adapters - } - } - - UsbBulkTransfer(bt_dev.inEndp, l2cap_buf, MAX_BUFFER_SIZE + 23, l2cap_event_cb, arg); - SignalSema(bt_dev.hid_sema); + int ret; + u16 interrupt_dcid = 0x0041; + + PollSema(bt_dev.hid_sema); + + ret = L2CAP_event_task(resultCode, bytes); + + if (ret < MAX_PADS) { + if (pad_status_check(DS34BT_STATE_RUNNING, ret)) { + if (pad_status_check(DS34BT_STATE_DISCONNECT_REQUEST, ret)) { + if (!ds34pad[ret].isfake) { + if (ds34pad[ret].type == DS4) { + interrupt_dcid = 0x0071; + } + identifier++; + l2cap_disconnection_request(ds34pad[ret].hci_handle, identifier, ds34pad[ret].interrupt_scid, interrupt_dcid); + } else { + hci_disconnect(ds34pad[ret].hci_handle); + } + pad_status_clear(DS34BT_STATE_DISCONNECT_REQUEST, ret); + } else if (ds34pad[ret].update_rum) { + hid_LEDRumble(ds34pad[ret].oldled, ds34pad[ret].lrum, ds34pad[ret].rrum, ret); + ds34pad[ret].update_rum = 0; + } + } else { + if (!ds34pad[ret].isfake && ds34pad[ret].type == DS3) + DelayThread(42000); // fix for some bt adapters + } + } + + UsbBulkTransfer(bt_dev.inEndp, l2cap_buf, MAX_BUFFER_SIZE + 23, l2cap_event_cb, arg); + SignalSema(bt_dev.hid_sema); } /************************************************************/ @@ -1167,279 +1167,279 @@ static void l2cap_event_cb(int resultCode, int bytes, void *arg) static int HID_command(u16 handle, u16 scid, u8 *data, u8 length, int pad) { - l2cap_cmd_buf[0] = (u8)(handle & 0xff); // HCI handle with PB,BC flag - l2cap_cmd_buf[1] = (u8)(((handle >> 8) & 0x0f) | 0x20); - l2cap_cmd_buf[2] = (u8)((4 + length) & 0xff); // HCI ACL total data length - l2cap_cmd_buf[3] = (u8)((4 + length) >> 8); - l2cap_cmd_buf[4] = (u8)(length & 0xff); // L2CAP header: Length - l2cap_cmd_buf[5] = (u8)(length >> 8); - l2cap_cmd_buf[6] = (u8)(scid & 0xff); // L2CAP header: Channel ID - l2cap_cmd_buf[7] = (u8)(scid >> 8); - - mips_memcpy(&l2cap_cmd_buf[8], data, length); - - // output on endpoint 2 - return UsbBulkTransfer(bt_dev.outEndp, l2cap_cmd_buf, (8 + length), NULL, NULL); + l2cap_cmd_buf[0] = (u8)(handle & 0xff); // HCI handle with PB,BC flag + l2cap_cmd_buf[1] = (u8)(((handle >> 8) & 0x0f) | 0x20); + l2cap_cmd_buf[2] = (u8)((4 + length) & 0xff); // HCI ACL total data length + l2cap_cmd_buf[3] = (u8)((4 + length) >> 8); + l2cap_cmd_buf[4] = (u8)(length & 0xff); // L2CAP header: Length + l2cap_cmd_buf[5] = (u8)(length >> 8); + l2cap_cmd_buf[6] = (u8)(scid & 0xff); // L2CAP header: Channel ID + l2cap_cmd_buf[7] = (u8)(scid >> 8); + + mips_memcpy(&l2cap_cmd_buf[8], data, length); + + // output on endpoint 2 + return UsbBulkTransfer(bt_dev.outEndp, l2cap_cmd_buf, (8 + length), NULL, NULL); } static int hid_initDS34(int pad) { - u8 init_buf[PS3_F4_REPORT_LEN + 2]; - u8 size = 2; - - if (ds34pad[pad].type == DS3) { - init_buf[0] = HID_THDR_SET_REPORT_FEATURE; // THdr - init_buf[1] = PS3_F4_REPORT_ID; // Report ID - init_buf[2] = 0x42; - init_buf[3] = 0x03; - init_buf[4] = 0x00; - init_buf[5] = 0x00; - size += PS3_F4_REPORT_LEN; - } else if (ds34pad[pad].type == DS4) { - init_buf[0] = HID_THDR_GET_REPORT_FEATURE; // THdr - init_buf[1] = PS4_02_REPORT_ID; // Report ID - } - - return HID_command(ds34pad[pad].hci_handle, ds34pad[pad].control_scid, init_buf, size, pad); + u8 init_buf[PS3_F4_REPORT_LEN + 2]; + u8 size = 2; + + if (ds34pad[pad].type == DS3) { + init_buf[0] = HID_THDR_SET_REPORT_FEATURE; // THdr + init_buf[1] = PS3_F4_REPORT_ID; // Report ID + init_buf[2] = 0x42; + init_buf[3] = 0x03; + init_buf[4] = 0x00; + init_buf[5] = 0x00; + size += PS3_F4_REPORT_LEN; + } else if (ds34pad[pad].type == DS4) { + init_buf[0] = HID_THDR_GET_REPORT_FEATURE; // THdr + init_buf[1] = PS4_02_REPORT_ID; // Report ID + } + + return HID_command(ds34pad[pad].hci_handle, ds34pad[pad].control_scid, init_buf, size, pad); } static int hid_LEDRumble(u8 *led, u8 lrum, u8 rrum, int pad) { - u8 led_buf[PS4_11_REPORT_LEN + 2]; - u8 size = 2; - - if (ds34pad[pad].type == DS3) { - if (ds34pad[pad].isfake) - led_buf[0] = 0xA2; // THdr - else - led_buf[0] = HID_THDR_SET_REPORT_OUTPUT; // THdr - - led_buf[1] = PS3_01_REPORT_ID; // Report ID - - mips_memcpy(&led_buf[2], output_01_report, sizeof(output_01_report)); // PS3_01_REPORT_LEN); - - if (ds34pad[pad].isfake) { - if (rrum < 5) - rrum = 0; - } - - led_buf[3] = 0xFE; // rt - led_buf[4] = rrum; // rp - led_buf[5] = 0xFE; // lt - led_buf[6] = lrum; // lp - - led_buf[11] = led[0] & 0x7F; // LED Conf - - if (led[3]) // means charging, so blink - { - led_buf[15] = 0x32; - led_buf[20] = 0x32; - led_buf[25] = 0x32; - led_buf[30] = 0x32; - } - - size += sizeof(output_01_report); - } else if (ds34pad[pad].type == DS4) { - mips_memset(led_buf, 0, PS3_01_REPORT_LEN + 2); - - led_buf[0] = HID_THDR_SET_REPORT_OUTPUT; // THdr - led_buf[1] = PS4_11_REPORT_ID; // Report ID - led_buf[2] = 0x80; // update rate 1000Hz - led_buf[4] = 0xFF; - - led_buf[7] = rrum; - led_buf[8] = lrum; - - led_buf[9] = led[0]; // r - led_buf[10] = led[1]; // g - led_buf[11] = led[2]; // b - - if (led[3]) // means charging, so blink - { - led_buf[12] = 0x80; // Time to flash bright (255 = 2.5 seconds) - led_buf[13] = 0x80; // Time to flash dark (255 = 2.5 seconds) - } - - size += PS4_11_REPORT_LEN; - } - - ds34pad[pad].oldled[0] = led[0]; - ds34pad[pad].oldled[1] = led[1]; - ds34pad[pad].oldled[2] = led[2]; - ds34pad[pad].oldled[3] = led[3]; - ds34pad[pad].lrum = lrum; - ds34pad[pad].rrum = rrum; - - return HID_command(ds34pad[pad].hci_handle, ds34pad[pad].control_scid, led_buf, size, pad); + u8 led_buf[PS4_11_REPORT_LEN + 2]; + u8 size = 2; + + if (ds34pad[pad].type == DS3) { + if (ds34pad[pad].isfake) + led_buf[0] = 0xA2; // THdr + else + led_buf[0] = HID_THDR_SET_REPORT_OUTPUT; // THdr + + led_buf[1] = PS3_01_REPORT_ID; // Report ID + + mips_memcpy(&led_buf[2], output_01_report, sizeof(output_01_report)); // PS3_01_REPORT_LEN); + + if (ds34pad[pad].isfake) { + if (rrum < 5) + rrum = 0; + } + + led_buf[3] = 0xFE; // rt + led_buf[4] = rrum; // rp + led_buf[5] = 0xFE; // lt + led_buf[6] = lrum; // lp + + led_buf[11] = led[0] & 0x7F; // LED Conf + + if (led[3]) // means charging, so blink + { + led_buf[15] = 0x32; + led_buf[20] = 0x32; + led_buf[25] = 0x32; + led_buf[30] = 0x32; + } + + size += sizeof(output_01_report); + } else if (ds34pad[pad].type == DS4) { + mips_memset(led_buf, 0, PS3_01_REPORT_LEN + 2); + + led_buf[0] = HID_THDR_SET_REPORT_OUTPUT; // THdr + led_buf[1] = PS4_11_REPORT_ID; // Report ID + led_buf[2] = 0x80; // update rate 1000Hz + led_buf[4] = 0xFF; + + led_buf[7] = rrum; + led_buf[8] = lrum; + + led_buf[9] = led[0]; // r + led_buf[10] = led[1]; // g + led_buf[11] = led[2]; // b + + if (led[3]) // means charging, so blink + { + led_buf[12] = 0x80; // Time to flash bright (255 = 2.5 seconds) + led_buf[13] = 0x80; // Time to flash dark (255 = 2.5 seconds) + } + + size += PS4_11_REPORT_LEN; + } + + ds34pad[pad].oldled[0] = led[0]; + ds34pad[pad].oldled[1] = led[1]; + ds34pad[pad].oldled[2] = led[2]; + ds34pad[pad].oldled[3] = led[3]; + ds34pad[pad].lrum = lrum; + ds34pad[pad].rrum = rrum; + + return HID_command(ds34pad[pad].hci_handle, ds34pad[pad].control_scid, led_buf, size, pad); } static void hid_readReport(u8 *data, int bytes, int pad) { - if (data[8] == HID_THDR_DATA_INPUT) { - if (data[9] == PS3_01_REPORT_ID) { - struct ds3report *report; - - report = (struct ds3report *)&data[11]; - - if (report->RightStickX == 0 && report->RightStickY == 0) // ledrumble cmd causes null report sometime - return; - - ds34pad[pad].data[0] = ~report->ButtonStateL; - ds34pad[pad].data[1] = ~report->ButtonStateH; - - ds34pad[pad].data[2] = report->RightStickX; // rx - ds34pad[pad].data[3] = report->RightStickY; // ry - ds34pad[pad].data[4] = report->LeftStickX; // lx - ds34pad[pad].data[5] = report->LeftStickY; // ly - - if (bytes == 21 && !press_emu) - press_emu = 1; - - if (press_emu) { // needs emulating pressure buttons - ds34pad[pad].data[6] = report->Right * 255; // right - ds34pad[pad].data[7] = report->Left * 255; // left - ds34pad[pad].data[8] = report->Up * 255; // up - ds34pad[pad].data[9] = report->Down * 255; // down - - ds34pad[pad].data[10] = report->Triangle * 255; // triangle - ds34pad[pad].data[11] = report->Circle * 255; // circle - ds34pad[pad].data[12] = report->Cross * 255; // cross - ds34pad[pad].data[13] = report->Square * 255; // square - - ds34pad[pad].data[14] = report->L1 * 255; // L1 - ds34pad[pad].data[15] = report->R1 * 255; // R1 - ds34pad[pad].data[16] = report->L2 * 255; // L2 - ds34pad[pad].data[17] = report->R2 * 255; // R2 - - report->Power = 0x05; - } else { - ds34pad[pad].data[6] = report->PressureRight; // right - ds34pad[pad].data[7] = report->PressureLeft; // left - ds34pad[pad].data[8] = report->PressureUp; // up - ds34pad[pad].data[9] = report->PressureDown; // down - - ds34pad[pad].data[10] = report->PressureTriangle; // triangle - ds34pad[pad].data[11] = report->PressureCircle; // circle - ds34pad[pad].data[12] = report->PressureCross; // cross - ds34pad[pad].data[13] = report->PressureSquare; // square - - ds34pad[pad].data[14] = report->PressureL1; // L1 - ds34pad[pad].data[15] = report->PressureR1; // R1 - ds34pad[pad].data[16] = report->PressureL2; // L2 - ds34pad[pad].data[17] = report->PressureR2; // R2 - } - - if (report->PSButtonState && report->Power != 0xEE) // display battery level - ds34pad[pad].oldled[0] = power_level[report->Power]; - else - ds34pad[pad].oldled[0] = led_patterns[pad][1]; - - if (report->Power == 0xEE) // charging - ds34pad[pad].oldled[3] = 1; - else - ds34pad[pad].oldled[3] = 0; - - } else if (data[9] == PS4_11_REPORT_ID) { - struct ds4report *report; - u8 up = 0, down = 0, left = 0, right = 0; - - report = (struct ds4report *)&data[11]; - - switch (report->Dpad) { - case 0: - up = 1; - break; - case 1: - up = 1; - right = 1; - break; - case 2: - right = 1; - break; - case 3: - down = 1; - right = 1; - break; - case 4: - down = 1; - break; - case 5: - down = 1; - left = 1; - break; - case 6: - left = 1; - break; - case 7: - up = 1; - left = 1; - break; - case 8: - up = 0; - down = 0; - left = 0; - right = 0; - break; - } - - if (bytes > 63 && report->TPad) { - if (!report->Finger1Active) { - if (report->Finger1X < 960) - report->Share = 1; - else - report->Option = 1; - } - - if (!report->Finger2Active) { - if (report->Finger2X < 960) - report->Share = 1; - else - report->Option = 1; - } - } - - ds34pad[pad].data[0] = ~(report->Share | report->L3 << 1 | report->R3 << 2 | report->Option << 3 | up << 4 | right << 5 | down << 6 | left << 7); - ds34pad[pad].data[1] = ~(report->L2 | report->R2 << 1 | report->L1 << 2 | report->R1 << 3 | report->Triangle << 4 | report->Circle << 5 | report->Cross << 6 | report->Square << 7); - - ds34pad[pad].data[2] = report->RightStickX; // rx - ds34pad[pad].data[3] = report->RightStickY; // ry - ds34pad[pad].data[4] = report->LeftStickX; // lx - ds34pad[pad].data[5] = report->LeftStickY; // ly - - ds34pad[pad].data[6] = right * 255; // right - ds34pad[pad].data[7] = left * 255; // left - ds34pad[pad].data[8] = up * 255; // up - ds34pad[pad].data[9] = down * 255; // down - - ds34pad[pad].data[10] = report->Triangle * 255; // triangle - ds34pad[pad].data[11] = report->Circle * 255; // circle - ds34pad[pad].data[12] = report->Cross * 255; // cross - ds34pad[pad].data[13] = report->Square * 255; // square - - ds34pad[pad].data[14] = report->L1 * 255; // L1 - ds34pad[pad].data[15] = report->R1 * 255; // R1 - ds34pad[pad].data[16] = report->PressureL2; // L2 - ds34pad[pad].data[17] = report->PressureR2; // R2 - - if (report->PSButton) { // display battery level - ds34pad[pad].oldled[0] = report->Battery; - ds34pad[pad].oldled[1] = 0; - ds34pad[pad].oldled[2] = 0; - } else { - ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; - ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; - ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; - } - - if (report->Power != 0xB && report->Usb_plugged) // charging - ds34pad[pad].oldled[3] = 1; - else - ds34pad[pad].oldled[3] = 0; - } - } else { - DPRINTF("Unmanaged Input Report: THDR 0x%02X ", data[8]); - DPRINTF(" ID 0x%02X \n", data[9]); - } + if (data[8] == HID_THDR_DATA_INPUT) { + if (data[9] == PS3_01_REPORT_ID) { + struct ds3report *report; + + report = (struct ds3report *)&data[11]; + + if (report->RightStickX == 0 && report->RightStickY == 0) // ledrumble cmd causes null report sometime + return; + + ds34pad[pad].data[0] = ~report->ButtonStateL; + ds34pad[pad].data[1] = ~report->ButtonStateH; + + ds34pad[pad].data[2] = report->RightStickX; // rx + ds34pad[pad].data[3] = report->RightStickY; // ry + ds34pad[pad].data[4] = report->LeftStickX; // lx + ds34pad[pad].data[5] = report->LeftStickY; // ly + + if (bytes == 21 && !press_emu) + press_emu = 1; + + if (press_emu) { // needs emulating pressure buttons + ds34pad[pad].data[6] = report->Right * 255; // right + ds34pad[pad].data[7] = report->Left * 255; // left + ds34pad[pad].data[8] = report->Up * 255; // up + ds34pad[pad].data[9] = report->Down * 255; // down + + ds34pad[pad].data[10] = report->Triangle * 255; // triangle + ds34pad[pad].data[11] = report->Circle * 255; // circle + ds34pad[pad].data[12] = report->Cross * 255; // cross + ds34pad[pad].data[13] = report->Square * 255; // square + + ds34pad[pad].data[14] = report->L1 * 255; // L1 + ds34pad[pad].data[15] = report->R1 * 255; // R1 + ds34pad[pad].data[16] = report->L2 * 255; // L2 + ds34pad[pad].data[17] = report->R2 * 255; // R2 + + report->Power = 0x05; + } else { + ds34pad[pad].data[6] = report->PressureRight; // right + ds34pad[pad].data[7] = report->PressureLeft; // left + ds34pad[pad].data[8] = report->PressureUp; // up + ds34pad[pad].data[9] = report->PressureDown; // down + + ds34pad[pad].data[10] = report->PressureTriangle; // triangle + ds34pad[pad].data[11] = report->PressureCircle; // circle + ds34pad[pad].data[12] = report->PressureCross; // cross + ds34pad[pad].data[13] = report->PressureSquare; // square + + ds34pad[pad].data[14] = report->PressureL1; // L1 + ds34pad[pad].data[15] = report->PressureR1; // R1 + ds34pad[pad].data[16] = report->PressureL2; // L2 + ds34pad[pad].data[17] = report->PressureR2; // R2 + } + + if (report->PSButtonState && report->Power != 0xEE) // display battery level + ds34pad[pad].oldled[0] = power_level[report->Power]; + else + ds34pad[pad].oldled[0] = led_patterns[pad][1]; + + if (report->Power == 0xEE) // charging + ds34pad[pad].oldled[3] = 1; + else + ds34pad[pad].oldled[3] = 0; + + } else if (data[9] == PS4_11_REPORT_ID) { + struct ds4report *report; + u8 up = 0, down = 0, left = 0, right = 0; + + report = (struct ds4report *)&data[11]; + + switch (report->Dpad) { + case 0: + up = 1; + break; + case 1: + up = 1; + right = 1; + break; + case 2: + right = 1; + break; + case 3: + down = 1; + right = 1; + break; + case 4: + down = 1; + break; + case 5: + down = 1; + left = 1; + break; + case 6: + left = 1; + break; + case 7: + up = 1; + left = 1; + break; + case 8: + up = 0; + down = 0; + left = 0; + right = 0; + break; + } + + if (bytes > 63 && report->TPad) { + if (!report->Finger1Active) { + if (report->Finger1X < 960) + report->Share = 1; + else + report->Option = 1; + } + + if (!report->Finger2Active) { + if (report->Finger2X < 960) + report->Share = 1; + else + report->Option = 1; + } + } + + ds34pad[pad].data[0] = ~(report->Share | report->L3 << 1 | report->R3 << 2 | report->Option << 3 | up << 4 | right << 5 | down << 6 | left << 7); + ds34pad[pad].data[1] = ~(report->L2 | report->R2 << 1 | report->L1 << 2 | report->R1 << 3 | report->Triangle << 4 | report->Circle << 5 | report->Cross << 6 | report->Square << 7); + + ds34pad[pad].data[2] = report->RightStickX; // rx + ds34pad[pad].data[3] = report->RightStickY; // ry + ds34pad[pad].data[4] = report->LeftStickX; // lx + ds34pad[pad].data[5] = report->LeftStickY; // ly + + ds34pad[pad].data[6] = right * 255; // right + ds34pad[pad].data[7] = left * 255; // left + ds34pad[pad].data[8] = up * 255; // up + ds34pad[pad].data[9] = down * 255; // down + + ds34pad[pad].data[10] = report->Triangle * 255; // triangle + ds34pad[pad].data[11] = report->Circle * 255; // circle + ds34pad[pad].data[12] = report->Cross * 255; // cross + ds34pad[pad].data[13] = report->Square * 255; // square + + ds34pad[pad].data[14] = report->L1 * 255; // L1 + ds34pad[pad].data[15] = report->R1 * 255; // R1 + ds34pad[pad].data[16] = report->PressureL2; // L2 + ds34pad[pad].data[17] = report->PressureR2; // R2 + + if (report->PSButton) { // display battery level + ds34pad[pad].oldled[0] = report->Battery; + ds34pad[pad].oldled[1] = 0; + ds34pad[pad].oldled[2] = 0; + } else { + ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; + ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; + ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; + } + + if (report->Power != 0xB && report->Usb_plugged) // charging + ds34pad[pad].oldled[3] = 1; + else + ds34pad[pad].oldled[3] = 0; + } + } else { + DPRINTF("Unmanaged Input Report: THDR 0x%02X ", data[8]); + DPRINTF(" ID 0x%02X \n", data[9]); + } } /************************************************************/ @@ -1448,159 +1448,159 @@ static void hid_readReport(u8 *data, int bytes, int pad) void ds34bt_set_rumble(u8 lrum, u8 rrum, int port) { - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) - return; + if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) + return; - WaitSema(bt_dev.hid_sema); + WaitSema(bt_dev.hid_sema); - ds34pad[port].update_rum = 1; - ds34pad[port].lrum = lrum; - ds34pad[port].rrum = rrum; + ds34pad[port].update_rum = 1; + ds34pad[port].lrum = lrum; + ds34pad[port].rrum = rrum; - SignalSema(bt_dev.hid_sema); + SignalSema(bt_dev.hid_sema); } void ds34bt_set_led(u8 *led, int port) { - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) - return; + if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) + return; - WaitSema(bt_dev.hid_sema); + WaitSema(bt_dev.hid_sema); - ds34pad[port].update_rum = 1; - ds34pad[port].oldled[0] = led[0]; - ds34pad[port].oldled[1] = led[1]; - ds34pad[port].oldled[2] = led[2]; - ds34pad[port].oldled[3] = led[3]; + ds34pad[port].update_rum = 1; + ds34pad[port].oldled[0] = led[0]; + ds34pad[port].oldled[1] = led[1]; + ds34pad[port].oldled[2] = led[2]; + ds34pad[port].oldled[3] = led[3]; - SignalSema(bt_dev.hid_sema); + SignalSema(bt_dev.hid_sema); } int ds34bt_get_bdaddr(u8 *data) { - if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) - return 0; + if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) + return 0; - mips_memcpy(data, bt_bdaddr, 6); + mips_memcpy(data, bt_bdaddr, 6); - return 1; + return 1; } int ds34bt_get_ver(u8 *data) { - if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) - return 0; + if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) + return 0; - bt_version.vid = bt_dev.vid; - bt_version.pid = bt_dev.pid; - bt_version.rev = bt_dev.rev; + bt_version.vid = bt_dev.vid; + bt_version.pid = bt_dev.pid; + bt_version.rev = bt_dev.rev; - mips_memcpy(data, &bt_version, sizeof(hci_information_t)); + mips_memcpy(data, &bt_version, sizeof(hci_information_t)); - return 1; + return 1; } int ds34bt_get_feat(u8 *data) { - if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) - return 0; + if (!(bt_dev.status & DS34BT_STATE_USB_CONFIGURED)) + return 0; - mips_memcpy(data, bt_features, sizeof(bt_features)); + mips_memcpy(data, bt_features, sizeof(bt_features)); - return 1; + return 1; } void ds34bt_get_data(char *dst, int size, int port) { - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) - return; + if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) + return; - WaitSema(bt_dev.hid_sema); + WaitSema(bt_dev.hid_sema); - mips_memcpy(dst, ds34pad[port].data, size); + mips_memcpy(dst, ds34pad[port].data, size); - SignalSema(bt_dev.hid_sema); + SignalSema(bt_dev.hid_sema); } void ds34bt_reset() { - int pad; - - if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) - return; - - for (pad = 0; pad < MAX_PADS; pad++) { - WaitSema(bt_dev.hid_sema); - pad_status_set(DS34BT_STATE_DISCONNECT_REQUEST, pad); - SignalSema(bt_dev.hid_sema); - while (1) { - DelayThread(500); - WaitSema(bt_dev.hid_sema); - if (!pad_status_check(DS34BT_STATE_RUNNING, pad)) { - SignalSema(bt_dev.hid_sema); - break; - } - SignalSema(bt_dev.hid_sema); - } - } - - DelayThread(1000000); + int pad; + + if (!(bt_dev.status & DS34BT_STATE_USB_AUTHORIZED)) + return; + + for (pad = 0; pad < MAX_PADS; pad++) { + WaitSema(bt_dev.hid_sema); + pad_status_set(DS34BT_STATE_DISCONNECT_REQUEST, pad); + SignalSema(bt_dev.hid_sema); + while (1) { + DelayThread(500); + WaitSema(bt_dev.hid_sema); + if (!pad_status_check(DS34BT_STATE_RUNNING, pad)) { + SignalSema(bt_dev.hid_sema); + break; + } + SignalSema(bt_dev.hid_sema); + } + } + + DelayThread(1000000); } int ds34bt_get_status(int port) { - int status = bt_dev.status; + int status = bt_dev.status; - if ((status & DS34BT_STATE_USB_AUTHORIZED) && (port < MAX_PADS)) { - WaitSema(bt_dev.hid_sema); - status |= ds34pad[port].status; - SignalSema(bt_dev.hid_sema); - } + if ((status & DS34BT_STATE_USB_AUTHORIZED) && (port < MAX_PADS)) { + WaitSema(bt_dev.hid_sema); + status |= ds34pad[port].status; + SignalSema(bt_dev.hid_sema); + } - return status; + return status; } int ds34bt_init(u8 pads) { - int i; + int i; - WaitSema(bt_dev.hid_sema); + WaitSema(bt_dev.hid_sema); - for (i = 0; i < MAX_PADS; i++) - ds34pad[i].enabled = (pads >> i) & 1; + for (i = 0; i < MAX_PADS; i++) + ds34pad[i].enabled = (pads >> i) & 1; - ds34pad_init(); - hci_reset(); + ds34pad_init(); + hci_reset(); - SignalSema(bt_dev.hid_sema); + SignalSema(bt_dev.hid_sema); - return 1; + return 1; } static u8 chrg_inited = 0; void ds34bt_init_charging() { - int ret; - - if (!chrg_inited) { - ret = UsbRegisterDriver(&chrg_driver); - if (ret != USB_RC_OK) { - DPRINTF("DS34BT: Error registering charging 0x%02X \n", ret); - chrg_inited = 0; - } else { - chrg_inited = 1; - } - } + int ret; + + if (!chrg_inited) { + ret = UsbRegisterDriver(&chrg_driver); + if (ret != USB_RC_OK) { + DPRINTF("DS34BT: Error registering charging 0x%02X \n", ret); + chrg_inited = 0; + } else { + chrg_inited = 1; + } + } } static void rpc_thread(void *data); @@ -1611,109 +1611,109 @@ static SifRpcServerData_t rpc_svr __attribute__((aligned(16))); static int rpc_buf[64] __attribute((aligned(16))); -#define DS34BT_INIT 1 +#define DS34BT_INIT 1 #define DS34BT_INIT_CHARGING 2 -#define DS34BT_GET_STATUS 3 -#define DS34BT_GET_BDADDR 4 -#define DS34BT_SET_RUMBLE 5 -#define DS34BT_SET_LED 6 -#define DS34BT_GET_DATA 7 -#define DS34BT_RESET 8 -#define DS34BT_GET_VERSION 9 -#define DS34BT_GET_FEATURES 10 +#define DS34BT_GET_STATUS 3 +#define DS34BT_GET_BDADDR 4 +#define DS34BT_SET_RUMBLE 5 +#define DS34BT_SET_LED 6 +#define DS34BT_GET_DATA 7 +#define DS34BT_RESET 8 +#define DS34BT_GET_VERSION 9 +#define DS34BT_GET_FEATURES 10 #define DS34BT_BIND_RPC_ID 0x18E3878F void rpc_thread(void *data) { - SifInitRpc(0); - SifSetRpcQueue(&rpc_que, GetThreadId()); - SifRegisterRpc(&rpc_svr, DS34BT_BIND_RPC_ID, rpc_sf, rpc_buf, NULL, NULL, &rpc_que); - SifRpcLoop(&rpc_que); + SifInitRpc(0); + SifSetRpcQueue(&rpc_que, GetThreadId()); + SifRegisterRpc(&rpc_svr, DS34BT_BIND_RPC_ID, rpc_sf, rpc_buf, NULL, NULL, &rpc_que); + SifRpcLoop(&rpc_que); } void *rpc_sf(int cmd, void *data, int size) { - switch (cmd) { - case DS34BT_INIT: - ds34bt_init(*(u8 *)data); - break; - case DS34BT_INIT_CHARGING: - ds34bt_init_charging(); - break; - case DS34BT_GET_STATUS: - *(u8 *)data = ds34bt_get_status(*(u8 *)data); - break; - case DS34BT_GET_BDADDR: - *(u8 *)(data + 6) = ds34bt_get_bdaddr((u8 *)data); - break; - case DS34BT_SET_RUMBLE: - ds34bt_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); - break; - case DS34BT_SET_LED: - ds34bt_set_led((u8 *)(data + 1), *(u8 *)data); - break; - case DS34BT_GET_DATA: - ds34bt_get_data((char *)data, 18, *(u8 *)data); - break; - case DS34BT_RESET: - ds34bt_reset(); - break; - case DS34BT_GET_VERSION: - *(u8 *)(data + sizeof(hci_information_t)) = ds34bt_get_ver((u8 *)data); - break; - case DS34BT_GET_FEATURES: - *(u8 *)(data + 8) = ds34bt_get_feat((u8 *)data); - break; - default: - break; - } - - return data; + switch (cmd) { + case DS34BT_INIT: + ds34bt_init(*(u8 *)data); + break; + case DS34BT_INIT_CHARGING: + ds34bt_init_charging(); + break; + case DS34BT_GET_STATUS: + *(u8 *)data = ds34bt_get_status(*(u8 *)data); + break; + case DS34BT_GET_BDADDR: + *(u8 *)(data + 6) = ds34bt_get_bdaddr((u8 *)data); + break; + case DS34BT_SET_RUMBLE: + ds34bt_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); + break; + case DS34BT_SET_LED: + ds34bt_set_led((u8 *)(data + 1), *(u8 *)data); + break; + case DS34BT_GET_DATA: + ds34bt_get_data((char *)data, 18, *(u8 *)data); + break; + case DS34BT_RESET: + ds34bt_reset(); + break; + case DS34BT_GET_VERSION: + *(u8 *)(data + sizeof(hci_information_t)) = ds34bt_get_ver((u8 *)data); + break; + case DS34BT_GET_FEATURES: + *(u8 *)(data + 8) = ds34bt_get_feat((u8 *)data); + break; + default: + break; + } + + return data; } int _start(int argc, char *argv[]) { - int ret, i; - u8 enable = 0xFF; + int ret, i; + u8 enable = 0xFF; - if (argc > 1) { - enable = argv[1][0]; - } + if (argc > 1) { + enable = argv[1][0]; + } - for (i = 0; i < MAX_PADS; i++) - ds34pad[i].enabled = (enable >> i) & 1; + for (i = 0; i < MAX_PADS; i++) + ds34pad[i].enabled = (enable >> i) & 1; - ds34pad_init(); + ds34pad_init(); - bt_dev.hid_sema = CreateMutex(IOP_MUTEX_UNLOCKED); + bt_dev.hid_sema = CreateMutex(IOP_MUTEX_UNLOCKED); - if (bt_dev.hid_sema < 0) { - DPRINTF("DS34BT: Failed to allocate I/O semaphore.\n"); - return MODULE_NO_RESIDENT_END; - } + if (bt_dev.hid_sema < 0) { + DPRINTF("DS34BT: Failed to allocate I/O semaphore.\n"); + return MODULE_NO_RESIDENT_END; + } - ret = UsbRegisterDriver(&bt_driver); + ret = UsbRegisterDriver(&bt_driver); - if (ret != USB_RC_OK) { - DPRINTF("DS34BT: Error registering BT devices 0x%02X \n", ret); - return MODULE_NO_RESIDENT_END; - } + if (ret != USB_RC_OK) { + DPRINTF("DS34BT: Error registering BT devices 0x%02X \n", ret); + return MODULE_NO_RESIDENT_END; + } - iop_thread_t rpc_th; + iop_thread_t rpc_th; - rpc_th.attr = TH_C; - rpc_th.thread = rpc_thread; - rpc_th.priority = 40; - rpc_th.stacksize = 0x800; - rpc_th.option = 0; + rpc_th.attr = TH_C; + rpc_th.thread = rpc_thread; + rpc_th.priority = 40; + rpc_th.stacksize = 0x800; + rpc_th.option = 0; - int thid = CreateThread(&rpc_th); + int thid = CreateThread(&rpc_th); - if (thid > 0) { - StartThread(thid, NULL); - return MODULE_RESIDENT_END; - } + if (thid > 0) { + StartThread(thid, NULL); + return MODULE_RESIDENT_END; + } - return MODULE_NO_RESIDENT_END; + return MODULE_NO_RESIDENT_END; } diff --git a/iop/ds34bt/iop/ds34bt.h b/iop/ds34bt/iop/ds34bt.h index 2bc19290..75bb5642 100644 --- a/iop/ds34bt/iop/ds34bt.h +++ b/iop/ds34bt/iop/ds34bt.h @@ -4,12 +4,12 @@ #include "irx.h" #define USB_CLASS_WIRELESS_CONTROLLER 0xE0 -#define USB_SUBCLASS_RF_CONTROLLER 0x01 -#define USB_PROTOCOL_BLUETOOTH_PROG 0x01 +#define USB_SUBCLASS_RF_CONTROLLER 0x01 +#define USB_PROTOCOL_BLUETOOTH_PROG 0x01 -#define DS34_VID 0x054C // Sony Corporation -#define DS3_PID 0x0268 // PS3 Controller -#define DS4_PID 0x05C4 // PS4 Controller +#define DS34_VID 0x054C // Sony Corporation +#define DS3_PID 0x0268 // PS3 Controller +#define DS4_PID 0x05C4 // PS4 Controller #define DS4_PID_SLIM 0x09CC // PS4 Slim Controller #define DS3 0 @@ -17,356 +17,356 @@ #define MAX_BUFFER_SIZE 64 // Size of general purpose data buffer -#define PENDING 1 +#define PENDING 1 #define SUCCESSFUL 0 typedef struct { - int devId; - int hid_sema; - int controlEndp; - int interruptEndp; - int inEndp; - int outEndp; - u8 status; - u16 vid; - u16 pid; - u16 rev; + int devId; + int hid_sema; + int controlEndp; + int interruptEndp; + int inEndp; + int outEndp; + u8 status; + u16 vid; + u16 pid; + u16 rev; } bt_device; typedef struct { - u16 hci_handle; // hci connection handle - u16 control_scid; // Channel endpoint on command destination - u16 interrupt_scid; // Channel endpoint on interrupt destination - u8 hci_state; // current state of bluetooth HCI connection - u8 bdaddr[6]; - u8 enabled; - u8 status; - u8 isfake; - u8 type; // 0 - ds3, 1 - ds4 - u8 oldled[4]; // rgb for ds4 and blink - u8 lrum; - u8 rrum; - u8 update_rum; - u8 data[18]; + u16 hci_handle; // hci connection handle + u16 control_scid; // Channel endpoint on command destination + u16 interrupt_scid; // Channel endpoint on interrupt destination + u8 hci_state; // current state of bluetooth HCI connection + u8 bdaddr[6]; + u8 enabled; + u8 status; + u8 isfake; + u8 type; // 0 - ds3, 1 - ds4 + u8 oldled[4]; // rgb for ds4 and blink + u8 lrum; + u8 rrum; + u8 update_rum; + u8 data[18]; } ds34bt_pad_t; typedef struct { - u8 hci_ver; // Version of the Current HCI in the BR/EDR Controller - u16 hci_rev; // Revision of the Current HCI in the BR/EDR Controller - u8 lmp_ver; // Version of the Current LMP or PAL in the Controller - u16 mf_name; // Manufacturer Name of the BR/EDR Controller - u16 lmp_subver; // Subversion of the Current LMP or PAL in the Controller - u16 vid; - u16 pid; - u16 rev; + u8 hci_ver; // Version of the Current HCI in the BR/EDR Controller + u16 hci_rev; // Revision of the Current HCI in the BR/EDR Controller + u8 lmp_ver; // Version of the Current LMP or PAL in the Controller + u16 mf_name; // Manufacturer Name of the BR/EDR Controller + u16 lmp_subver; // Subversion of the Current LMP or PAL in the Controller + u16 vid; + u16 pid; + u16 rev; } __attribute__((packed)) hci_information_t; enum eDS34BTStatus { - DS34BT_STATE_USB_DISCONNECTED = 0x00, - DS34BT_STATE_USB_AUTHORIZED = 0x01, - DS34BT_STATE_USB_CONFIGURED = 0x02, - DS34BT_STATE_CONNECTED = 0x04, - DS34BT_STATE_RUNNING = 0x08, - DS34BT_STATE_DISCONNECTING = 0x10, - DS34BT_STATE_DISCONNECT_REQUEST = 0x20, + DS34BT_STATE_USB_DISCONNECTED = 0x00, + DS34BT_STATE_USB_AUTHORIZED = 0x01, + DS34BT_STATE_USB_CONFIGURED = 0x02, + DS34BT_STATE_CONNECTED = 0x04, + DS34BT_STATE_RUNNING = 0x08, + DS34BT_STATE_DISCONNECTING = 0x10, + DS34BT_STATE_DISCONNECT_REQUEST = 0x20, }; #define pad_status_clear(flag, pad) ds34pad[pad].status &= ~flag -#define pad_status_set(flag, pad) ds34pad[pad].status |= flag +#define pad_status_set(flag, pad) ds34pad[pad].status |= flag #define pad_status_check(flag, pad) (ds34pad[pad].status & flag) #define hci_event_flag_clear(flag) hci_event_flag &= ~flag -#define hci_event_flag_set(flag) hci_event_flag |= flag +#define hci_event_flag_set(flag) hci_event_flag |= flag #define hci_event_flag_check(flag) (hci_event_flag & flag) enum eHCI { - // {{{ - /* Bluetooth HCI states for HCI_task() */ - HCI_INIT_STATE = 0, - HCI_RESET_STATE, - HCI_READBDADDR_STATE, - HCI_READVERSION_STATE, - HCI_READFEATURES_STATE, - HCI_CONNECT_IN_STATE, - HCI_REMOTE_NAME_STATE, - HCI_CHANGE_CONNECTION, - HCI_READ_REMOTE_SUPPORTED_FEATURES, - HCI_CONNECTED_STATE, - - /* HCI OpCode Group Field (OGF) */ - HCI_OGF_LINK_CNTRL = (0x01 << 2), // OGF: Link Control Commands - HCI_OGF_LINK_POLICY = (0x02 << 2), // OGF: Link Policy Commands - HCI_OGF_CTRL_BBAND = (0x03 << 2), // OGF: Controller & Baseband Commands - HCI_OGF_INFO_PARAM = (0x04 << 2), // OGF: Informational Parameters - - /* HCI OpCode Command Field (OCF) */ - HCI_OCF_DISCONNECT = 0x06, // OGF = 0x01 - HCI_OCF_ACCEPT_CONNECTION = 0x09, // OGF = 0x01 - HCI_OCF_REJECT_CONNECTION = 0x0A, // OGF = 0x01 - HCI_OCF_CHANGE_CONNECTION_TYPE = 0x0F, // OGF = 0x01 - HCI_OCF_REMOTE_NAME = 0x19, // OGF = 0x01 - HCI_OCF_LINK_KEY_REQUEST_REPLY = 0x0B, // OGF = 0x01 - - HCI_OCF_RESET = 0x03, // OGF = 0x03 - HCI_OCF_WRITE_ACCEPT_TIMEOUT = 0x16, // OGF = 0x03 - HCI_OCF_WRITE_SCAN_ENABLE = 0x1A, // OGF = 0x03 - - HCI_OCF_READ_BDADDR = 0x09, // OGF = 0x04 - HCI_OCF_READ_VERSION = 0x01, // OGF = 0x04 - HCI_OCF_READ_FEATURES = 0x03, // OGF = 0x04 - - /* HCI events managed */ - HCI_EVENT_CONNECT_COMPLETE = 0x03, - HCI_EVENT_CONNECT_REQUEST = 0x04, - HCI_EVENT_DISCONN_COMPLETE = 0x05, - HCI_EVENT_AUTHENTICATION_COMPLETE = 0x06, - HCI_EVENT_REMOTE_NAME_COMPLETE = 0x07, - HCI_EVENT_ENCRYPTION_CHANGE = 0x08, - HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE = 0x0B, - HCI_EVENT_QOS_SETUP_COMPLETE = 0x0d, // do nothing - HCI_EVENT_COMMAND_COMPLETE = 0x0e, - HCI_EVENT_COMMAND_STATUS = 0x0f, - HCI_EVENT_ROLE_CHANGED = 0x12, - HCI_EVENT_NUM_COMPLETED_PKT = 0x13, // do nothing - HCI_EVENT_PIN_CODE_REQUEST = 0x16, - HCI_EVENT_LINK_KEY_REQUEST = 0x17, - HCI_EVENT_CHANGED_CONNECTION_TYPE = 0x1D, - HCI_EVENT_PAGE_SR_CHANGED = 0x20, - HCI_EVENT_MAX_SLOT_CHANGE = 0x1B, // Max Slots Change event - - /* HCI event flags for hci_event_flag */ - HCI_FLAG_COMMAND_COMPLETE = 0x0001, - HCI_FLAG_COMMAND_STATUS = 0x0002, - HCI_FLAG_CONNECT_COMPLETE = 0x0004, - HCI_FLAG_DISCONN_COMPLETE = 0x0008, - HCI_FLAG_INCOMING_REQUEST = 0x0010, - HCI_FLAG_READ_BDADDR = 0x0020, - HCI_FLAG_REMOTE_NAME_COMPLETE = 0x0040, - HCI_FLAG_READ_VERSION = 0x0080, - HCI_FLAG_READ_FEATURES = 0x0100, - - /* HCI Scan Enable Parameters */ - SCAN_ENABLE_NOINQ_NOPAG = 0x00, - SCAN_ENABLE_ENINQ_NOPAG = 0x01, - SCAN_ENABLE_NOINQ_ENPAG = 0x02, - SCAN_ENABLE_ENINQ_ENPAG = 0x03, - // }}} + // {{{ + /* Bluetooth HCI states for HCI_task() */ + HCI_INIT_STATE = 0, + HCI_RESET_STATE, + HCI_READBDADDR_STATE, + HCI_READVERSION_STATE, + HCI_READFEATURES_STATE, + HCI_CONNECT_IN_STATE, + HCI_REMOTE_NAME_STATE, + HCI_CHANGE_CONNECTION, + HCI_READ_REMOTE_SUPPORTED_FEATURES, + HCI_CONNECTED_STATE, + + /* HCI OpCode Group Field (OGF) */ + HCI_OGF_LINK_CNTRL = (0x01 << 2), // OGF: Link Control Commands + HCI_OGF_LINK_POLICY = (0x02 << 2), // OGF: Link Policy Commands + HCI_OGF_CTRL_BBAND = (0x03 << 2), // OGF: Controller & Baseband Commands + HCI_OGF_INFO_PARAM = (0x04 << 2), // OGF: Informational Parameters + + /* HCI OpCode Command Field (OCF) */ + HCI_OCF_DISCONNECT = 0x06, // OGF = 0x01 + HCI_OCF_ACCEPT_CONNECTION = 0x09, // OGF = 0x01 + HCI_OCF_REJECT_CONNECTION = 0x0A, // OGF = 0x01 + HCI_OCF_CHANGE_CONNECTION_TYPE = 0x0F, // OGF = 0x01 + HCI_OCF_REMOTE_NAME = 0x19, // OGF = 0x01 + HCI_OCF_LINK_KEY_REQUEST_REPLY = 0x0B, // OGF = 0x01 + + HCI_OCF_RESET = 0x03, // OGF = 0x03 + HCI_OCF_WRITE_ACCEPT_TIMEOUT = 0x16, // OGF = 0x03 + HCI_OCF_WRITE_SCAN_ENABLE = 0x1A, // OGF = 0x03 + + HCI_OCF_READ_BDADDR = 0x09, // OGF = 0x04 + HCI_OCF_READ_VERSION = 0x01, // OGF = 0x04 + HCI_OCF_READ_FEATURES = 0x03, // OGF = 0x04 + + /* HCI events managed */ + HCI_EVENT_CONNECT_COMPLETE = 0x03, + HCI_EVENT_CONNECT_REQUEST = 0x04, + HCI_EVENT_DISCONN_COMPLETE = 0x05, + HCI_EVENT_AUTHENTICATION_COMPLETE = 0x06, + HCI_EVENT_REMOTE_NAME_COMPLETE = 0x07, + HCI_EVENT_ENCRYPTION_CHANGE = 0x08, + HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE = 0x0B, + HCI_EVENT_QOS_SETUP_COMPLETE = 0x0d, // do nothing + HCI_EVENT_COMMAND_COMPLETE = 0x0e, + HCI_EVENT_COMMAND_STATUS = 0x0f, + HCI_EVENT_ROLE_CHANGED = 0x12, + HCI_EVENT_NUM_COMPLETED_PKT = 0x13, // do nothing + HCI_EVENT_PIN_CODE_REQUEST = 0x16, + HCI_EVENT_LINK_KEY_REQUEST = 0x17, + HCI_EVENT_CHANGED_CONNECTION_TYPE = 0x1D, + HCI_EVENT_PAGE_SR_CHANGED = 0x20, + HCI_EVENT_MAX_SLOT_CHANGE = 0x1B, // Max Slots Change event + + /* HCI event flags for hci_event_flag */ + HCI_FLAG_COMMAND_COMPLETE = 0x0001, + HCI_FLAG_COMMAND_STATUS = 0x0002, + HCI_FLAG_CONNECT_COMPLETE = 0x0004, + HCI_FLAG_DISCONN_COMPLETE = 0x0008, + HCI_FLAG_INCOMING_REQUEST = 0x0010, + HCI_FLAG_READ_BDADDR = 0x0020, + HCI_FLAG_REMOTE_NAME_COMPLETE = 0x0040, + HCI_FLAG_READ_VERSION = 0x0080, + HCI_FLAG_READ_FEATURES = 0x0100, + + /* HCI Scan Enable Parameters */ + SCAN_ENABLE_NOINQ_NOPAG = 0x00, + SCAN_ENABLE_ENINQ_NOPAG = 0x01, + SCAN_ENABLE_NOINQ_ENPAG = 0x02, + SCAN_ENABLE_ENINQ_ENPAG = 0x03, + // }}} }; enum eL2CAP { - // {{{ - /* Bluetooth L2CAP PSM */ - L2CAP_PSM_SDP = 0x01, - L2CAP_PSM_CTRL = 0x11, // HID_Control - L2CAP_PSM_INTR = 0x13, // HID_Interrupt - - /* Bluetooth L2CAP states for L2CAP_task() */ - L2CAP_DOWN_STATE = 0, - L2CAP_INIT_STATE, - L2CAP_CONTROL_CONNECTING_STATE, - L2CAP_CONTROL_REQUEST_STATE, - L2CAP_CONTROL_CONFIGURING_STATE, - L2CAP_INTERRUPT_CONNECTING_STATE, - L2CAP_INTERRUPT_REQUEST_STATE, - L2CAP_INTERRUPT_CONFIGURING_STATE, - L2CAP_CONNECTED_STATE, - L2CAP_LED_STATE, - L2CAP_LED_STATE_END, - L2CAP_READY_STATE, - L2CAP_DISCONNECT_STATE, - - /* L2CAP event flags */ - L2CAP_EV_COMMAND_CONNECTED = 0x01, - L2CAP_EV_COMMAND_CONFIG_REQ = 0x02, - L2CAP_EV_COMMAND_CONFIGURED = 0x04, - L2CAP_EV_COMMAND_DISCONNECT_REQ = 0x08, - L2CAP_EV_INTERRUPT_CONNECTED = 0x10, - L2CAP_EV_INTERRUPT_CONFIG_REQ = 0x20, - L2CAP_EV_INTERRUPT_CONFIGURED = 0x40, - L2CAP_EV_INTERRUPT_DISCONNECT_REQ = 0x80, - - /* L2CAP signaling command */ - L2CAP_CMD_COMMAND_REJECT = 0x01, - L2CAP_CMD_CONNECTION_REQUEST = 0x02, - L2CAP_CMD_CONNECTION_RESPONSE = 0x03, - L2CAP_CMD_CONFIG_REQUEST = 0x04, - L2CAP_CMD_CONFIG_RESPONSE = 0x05, - L2CAP_CMD_DISCONNECT_REQUEST = 0x06, - L2CAP_CMD_DISCONNECT_RESPONSE = 0x07, - - /* HCI ACL Data Packet - * - * buf[0] buf[1] buf[2] buf[3] - * 0 4 8 11 12 16 24 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | HCI Handle |PB |BC | Data Total Length | HCI ACL Data Packet - * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * - * buf[4] buf[5] buf[6] buf[7] - * 0 8 16 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | Length | Channel ID | Basic L2CAP header - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * - * buf[8] buf[9] buf[10] buf[11] - * 0 8 16 31 MSB - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. - * | Code | Identifier | Length | Control frame (C-frame) - * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. (signaling packet format) - */ - // }}} + // {{{ + /* Bluetooth L2CAP PSM */ + L2CAP_PSM_SDP = 0x01, + L2CAP_PSM_CTRL = 0x11, // HID_Control + L2CAP_PSM_INTR = 0x13, // HID_Interrupt + + /* Bluetooth L2CAP states for L2CAP_task() */ + L2CAP_DOWN_STATE = 0, + L2CAP_INIT_STATE, + L2CAP_CONTROL_CONNECTING_STATE, + L2CAP_CONTROL_REQUEST_STATE, + L2CAP_CONTROL_CONFIGURING_STATE, + L2CAP_INTERRUPT_CONNECTING_STATE, + L2CAP_INTERRUPT_REQUEST_STATE, + L2CAP_INTERRUPT_CONFIGURING_STATE, + L2CAP_CONNECTED_STATE, + L2CAP_LED_STATE, + L2CAP_LED_STATE_END, + L2CAP_READY_STATE, + L2CAP_DISCONNECT_STATE, + + /* L2CAP event flags */ + L2CAP_EV_COMMAND_CONNECTED = 0x01, + L2CAP_EV_COMMAND_CONFIG_REQ = 0x02, + L2CAP_EV_COMMAND_CONFIGURED = 0x04, + L2CAP_EV_COMMAND_DISCONNECT_REQ = 0x08, + L2CAP_EV_INTERRUPT_CONNECTED = 0x10, + L2CAP_EV_INTERRUPT_CONFIG_REQ = 0x20, + L2CAP_EV_INTERRUPT_CONFIGURED = 0x40, + L2CAP_EV_INTERRUPT_DISCONNECT_REQ = 0x80, + + /* L2CAP signaling command */ + L2CAP_CMD_COMMAND_REJECT = 0x01, + L2CAP_CMD_CONNECTION_REQUEST = 0x02, + L2CAP_CMD_CONNECTION_RESPONSE = 0x03, + L2CAP_CMD_CONFIG_REQUEST = 0x04, + L2CAP_CMD_CONFIG_RESPONSE = 0x05, + L2CAP_CMD_DISCONNECT_REQUEST = 0x06, + L2CAP_CMD_DISCONNECT_RESPONSE = 0x07, + + /* HCI ACL Data Packet + * + * buf[0] buf[1] buf[2] buf[3] + * 0 4 8 11 12 16 24 31 MSB + * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. + * | HCI Handle |PB |BC | Data Total Length | HCI ACL Data Packet + * .-+-+-+-+-+-+-+-|-+-+-+-|-+-|-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. + * + * buf[4] buf[5] buf[6] buf[7] + * 0 8 16 31 MSB + * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. + * | Length | Channel ID | Basic L2CAP header + * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. + * + * buf[8] buf[9] buf[10] buf[11] + * 0 8 16 31 MSB + * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. + * | Code | Identifier | Length | Control frame (C-frame) + * .-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-|-+-+-+-+-+-+-+-. (signaling packet format) + */ + // }}} }; #define l2cap_handle_ok(handle) (((u16)(l2cap_buf[0] | (l2cap_buf[1] << 8)) & 0x0FFF) == (u16)(handle & 0x0FFF)) -#define l2cap_control_channel ((l2cap_buf[6] | (l2cap_buf[7] << 8)) == 0x0001) // Channel ID for ACL-U +#define l2cap_control_channel ((l2cap_buf[6] | (l2cap_buf[7] << 8)) == 0x0001) // Channel ID for ACL-U #define l2cap_interrupt_channel ((l2cap_buf[6] | (l2cap_buf[7] << 8)) == interrupt_dcid) -#define l2cap_command_channel ((l2cap_buf[6] | (l2cap_buf[7] << 8)) == control_dcid) +#define l2cap_command_channel ((l2cap_buf[6] | (l2cap_buf[7] << 8)) == control_dcid) enum eHID { - // {{{ - /* HID event flag */ - HID_FLAG_STATUS_REPORTED = 0x01, - HID_FLAG_BUTTONS_CHANGED = 0x02, - HID_FLAG_EXTENSION = 0x04, - HID_FLAG_COMMAND_SUCCESS = 0x08, - - /* Bluetooth HID Transaction Header (THdr) */ - HID_THDR_GET_REPORT_FEATURE = 0x43, - HID_THDR_SET_REPORT_OUTPUT = 0x52, - HID_THDR_SET_REPORT_FEATURE = 0x53, - HID_THDR_DATA_INPUT = 0xa1, - - /* Defines of various parameters for PS3 Game controller reports */ - PS3_F4_REPORT_ID = 0xF4, - PS3_F4_REPORT_LEN = 0x04, - - PS3_01_REPORT_ID = 0x01, - PS3_01_REPORT_LEN = 0x30, - - PS4_02_REPORT_ID = 0x02, - PS4_11_REPORT_ID = 0x11, - PS4_11_REPORT_LEN = 0x4D, - - // }}} + // {{{ + /* HID event flag */ + HID_FLAG_STATUS_REPORTED = 0x01, + HID_FLAG_BUTTONS_CHANGED = 0x02, + HID_FLAG_EXTENSION = 0x04, + HID_FLAG_COMMAND_SUCCESS = 0x08, + + /* Bluetooth HID Transaction Header (THdr) */ + HID_THDR_GET_REPORT_FEATURE = 0x43, + HID_THDR_SET_REPORT_OUTPUT = 0x52, + HID_THDR_SET_REPORT_FEATURE = 0x53, + HID_THDR_DATA_INPUT = 0xa1, + + /* Defines of various parameters for PS3 Game controller reports */ + PS3_F4_REPORT_ID = 0xF4, + PS3_F4_REPORT_LEN = 0x04, + + PS3_01_REPORT_ID = 0x01, + PS3_01_REPORT_LEN = 0x30, + + PS4_02_REPORT_ID = 0x02, + PS4_11_REPORT_ID = 0x11, + PS4_11_REPORT_LEN = 0x4D, + + // }}} }; struct ds3report { - union - { - u8 ButtonStateL; // Main buttons Low - struct - { - u8 Select : 1; - u8 L3 : 1; - u8 R3 : 1; - u8 Start : 1; - u8 Up : 1; - u8 Right : 1; - u8 Down : 1; - u8 Left : 1; - }; - }; - union - { - u8 ButtonStateH; // Main buttons High - struct - { - u8 L2 : 1; - u8 R2 : 1; - u8 L1 : 1; - u8 R1 : 1; - u8 Triangle : 1; - u8 Circle : 1; - u8 Cross : 1; - u8 Square : 1; - }; - }; - u8 PSButtonState; // PS button - u8 Reserved1; // Unknown - u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid - u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid - u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid - u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid - u8 Reserved2[4]; // Unknown - u8 PressureUp; // digital Pad Up button Pressure 0 - 255 - u8 PressureRight; // digital Pad Right button Pressure 0 - 255 - u8 PressureDown; // digital Pad Down button Pressure 0 - 255 - u8 PressureLeft; // digital Pad Left button Pressure 0 - 255 - u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 - u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 - u8 PressureL1; // digital Pad L1 button Pressure 0 - 255 - u8 PressureR1; // digital Pad R1 button Pressure 0 - 255 - u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255 - u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255 - u8 PressureCross; // digital Pad Cross button Pressure 0 - 255 - u8 PressureSquare; // digital Pad Square button Pressure 0 - 255 - u8 Reserved3[3]; // Unknown - u8 Charge; // charging status ? 02 = charge, 03 = normal - u8 Power; // Battery status ? 05=full - 02=dying, 01=just before shutdown, EE=charging - u8 Connection; // Connection Type ? 14 when operating by bluetooth, 10 when operating by bluetooth with cable plugged in, 16 when bluetooh and rumble - u8 Reserved4[9]; // Unknown - s16 AccelX; - s16 AccelY; - s16 AccelZ; - s16 GyroZ; + union + { + u8 ButtonStateL; // Main buttons Low + struct + { + u8 Select : 1; + u8 L3 : 1; + u8 R3 : 1; + u8 Start : 1; + u8 Up : 1; + u8 Right : 1; + u8 Down : 1; + u8 Left : 1; + }; + }; + union + { + u8 ButtonStateH; // Main buttons High + struct + { + u8 L2 : 1; + u8 R2 : 1; + u8 L1 : 1; + u8 R1 : 1; + u8 Triangle : 1; + u8 Circle : 1; + u8 Cross : 1; + u8 Square : 1; + }; + }; + u8 PSButtonState; // PS button + u8 Reserved1; // Unknown + u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid + u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid + u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid + u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid + u8 Reserved2[4]; // Unknown + u8 PressureUp; // digital Pad Up button Pressure 0 - 255 + u8 PressureRight; // digital Pad Right button Pressure 0 - 255 + u8 PressureDown; // digital Pad Down button Pressure 0 - 255 + u8 PressureLeft; // digital Pad Left button Pressure 0 - 255 + u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 + u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 + u8 PressureL1; // digital Pad L1 button Pressure 0 - 255 + u8 PressureR1; // digital Pad R1 button Pressure 0 - 255 + u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255 + u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255 + u8 PressureCross; // digital Pad Cross button Pressure 0 - 255 + u8 PressureSquare; // digital Pad Square button Pressure 0 - 255 + u8 Reserved3[3]; // Unknown + u8 Charge; // charging status ? 02 = charge, 03 = normal + u8 Power; // Battery status ? 05=full - 02=dying, 01=just before shutdown, EE=charging + u8 Connection; // Connection Type ? 14 when operating by bluetooth, 10 when operating by bluetooth with cable plugged in, 16 when bluetooh and rumble + u8 Reserved4[9]; // Unknown + s16 AccelX; + s16 AccelY; + s16 AccelZ; + s16 GyroZ; } __attribute__((packed)); struct ds4report { - u8 ReportID; - u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid - u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid - u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid - u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid - u8 Dpad : 4; // hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW - u8 Square : 1; - u8 Cross : 1; - u8 Circle : 1; - u8 Triangle : 1; - u8 L1 : 1; - u8 R1 : 1; - u8 L2 : 1; - u8 R2 : 1; - u8 Share : 1; - u8 Option : 1; - u8 L3 : 1; - u8 R3 : 1; - u8 PSButton : 1; - u8 TPad : 1; - u8 Counter1 : 6; // counts up by 1 per report - u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 - u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 - u8 Counter2; - u8 Counter3; - u8 Battery; // battery level from 0x00 to 0xff - s16 AccelX; - s16 AccelY; - s16 AccelZ; - s16 GyroZ; - s16 GyroY; - s16 GyroX; - u8 Reserved1[5]; // Unknown - u8 Power : 4; // from 0x0 to 0xA - charging, 0xB - charged - u8 Usb_plugged : 1; - u8 Headphones : 1; - u8 Microphone : 1; - u8 Padding : 1; - u8 Reserved2[2]; // Unknown - u8 TPpack; // number of trackpad packets (0x00 to 0x04) - u8 PackCounter; // packet counter - u8 Finger1ID : 7; // counter - u8 Finger1Active : 1; // 0 - active, 1 - unactive - u16 Finger1X : 12; // finger 1 coordinates resolution 1920x943 - u16 Finger1Y : 12; - u8 Finger2ID : 7; - u8 Finger2Active : 1; - u16 Finger2X : 12; // finger 2 coordinates resolution 1920x943 - u16 Finger2Y : 12; + u8 ReportID; + u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid + u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid + u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid + u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid + u8 Dpad : 4; // hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW + u8 Square : 1; + u8 Cross : 1; + u8 Circle : 1; + u8 Triangle : 1; + u8 L1 : 1; + u8 R1 : 1; + u8 L2 : 1; + u8 R2 : 1; + u8 Share : 1; + u8 Option : 1; + u8 L3 : 1; + u8 R3 : 1; + u8 PSButton : 1; + u8 TPad : 1; + u8 Counter1 : 6; // counts up by 1 per report + u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 + u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 + u8 Counter2; + u8 Counter3; + u8 Battery; // battery level from 0x00 to 0xff + s16 AccelX; + s16 AccelY; + s16 AccelZ; + s16 GyroZ; + s16 GyroY; + s16 GyroX; + u8 Reserved1[5]; // Unknown + u8 Power : 4; // from 0x0 to 0xA - charging, 0xB - charged + u8 Usb_plugged : 1; + u8 Headphones : 1; + u8 Microphone : 1; + u8 Padding : 1; + u8 Reserved2[2]; // Unknown + u8 TPpack; // number of trackpad packets (0x00 to 0x04) + u8 PackCounter; // packet counter + u8 Finger1ID : 7; // counter + u8 Finger1Active : 1; // 0 - active, 1 - unactive + u16 Finger1X : 12; // finger 1 coordinates resolution 1920x943 + u16 Finger1Y : 12; + u8 Finger2ID : 7; + u8 Finger2Active : 1; + u16 Finger2X : 12; // finger 2 coordinates resolution 1920x943 + u16 Finger2Y : 12; } __attribute__((packed)); diff --git a/iop/ds34usb/ee/libds34usb.c b/iop/ds34usb/ee/libds34usb.c index 89b27e92..f053a6c9 100644 --- a/iop/ds34usb/ee/libds34usb.c +++ b/iop/ds34usb/ee/libds34usb.c @@ -2,14 +2,14 @@ #include #include -#define DS34USB_INIT 1 +#define DS34USB_INIT 1 #define DS34USB_GET_STATUS 2 #define DS34USB_GET_BDADDR 3 #define DS34USB_SET_BDADDR 4 #define DS34USB_SET_RUMBLE 5 -#define DS34USB_SET_LED 6 -#define DS34USB_GET_DATA 7 -#define DS34USB_RESET 8 +#define DS34USB_SET_LED 6 +#define DS34USB_GET_DATA 7 +#define DS34USB_RESET 8 #define DS34USB_BIND_RPC_ID 0x18E3878E @@ -21,125 +21,125 @@ static u8 ds34usb_inited = 0; int ds34usb_init() { - ds34usb.server = NULL; + ds34usb.server = NULL; - do { - if (SifBindRpc(&ds34usb, DS34USB_BIND_RPC_ID, 0) < 0) - return 0; + do { + if (SifBindRpc(&ds34usb, DS34USB_BIND_RPC_ID, 0) < 0) + return 0; - nopdelay(); - } while (!ds34usb.server); + nopdelay(); + } while (!ds34usb.server); - ds34usb_inited = 1; + ds34usb_inited = 1; - return 1; + return 1; } int ds34usb_deinit() { - ds34usb_inited = 0; - return 1; + ds34usb_inited = 0; + return 1; } int ds34usb_reinit_ports(u8 ports) { - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = ports; - return (SifCallRpc(&ds34usb, DS34USB_INIT, 0, rpcbuf, 1, NULL, 0, NULL, NULL) == 0); + rpcbuf[0] = ports; + return (SifCallRpc(&ds34usb, DS34USB_INIT, 0, rpcbuf, 1, NULL, 0, NULL, NULL) == 0); } int ds34usb_get_status(int port) { - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - if (SifCallRpc(&ds34usb, DS34USB_GET_STATUS, 0, rpcbuf, 1, rpcbuf, 1, NULL, NULL) == 0) - return rpcbuf[0]; + if (SifCallRpc(&ds34usb, DS34USB_GET_STATUS, 0, rpcbuf, 1, rpcbuf, 1, NULL, NULL) == 0) + return rpcbuf[0]; - return 0; + return 0; } int ds34usb_get_bdaddr(int port, u8 *bdaddr) { - int i, ret; + int i, ret; - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - ret = (SifCallRpc(&ds34usb, DS34USB_GET_BDADDR, 0, rpcbuf, 1, rpcbuf, 7, NULL, NULL) == 0); + ret = (SifCallRpc(&ds34usb, DS34USB_GET_BDADDR, 0, rpcbuf, 1, rpcbuf, 7, NULL, NULL) == 0); - ret &= rpcbuf[0]; + ret &= rpcbuf[0]; - for (i = 0; i < 6; i++) - bdaddr[i] = rpcbuf[i + 1]; + for (i = 0; i < 6; i++) + bdaddr[i] = rpcbuf[i + 1]; - return ret; + return ret; } int ds34usb_set_bdaddr(int port, u8 *bdaddr) { - int i; + int i; - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - for (i = 0; i < 6; i++) - rpcbuf[i + 1] = bdaddr[i]; + for (i = 0; i < 6; i++) + rpcbuf[i + 1] = bdaddr[i]; - return (SifCallRpc(&ds34usb, DS34USB_SET_BDADDR, 0, rpcbuf, 7, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34usb, DS34USB_SET_BDADDR, 0, rpcbuf, 7, NULL, 0, NULL, NULL) == 0); } int ds34usb_set_rumble(int port, u8 lrum, u8 rrum) { - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; - rpcbuf[1] = lrum; - rpcbuf[2] = rrum; + rpcbuf[0] = port; + rpcbuf[1] = lrum; + rpcbuf[2] = rrum; - return (SifCallRpc(&ds34usb, DS34USB_SET_RUMBLE, 0, rpcbuf, 3, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34usb, DS34USB_SET_RUMBLE, 0, rpcbuf, 3, NULL, 0, NULL, NULL) == 0); } int ds34usb_set_led(int port, u8 led) { - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; - rpcbuf[1] = led; + rpcbuf[0] = port; + rpcbuf[1] = led; - return (SifCallRpc(&ds34usb, DS34USB_SET_LED, 0, rpcbuf, 2, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34usb, DS34USB_SET_LED, 0, rpcbuf, 2, NULL, 0, NULL, NULL) == 0); } int ds34usb_get_data(int port, u8 *data) { - int ret; + int ret; - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - rpcbuf[0] = port; + rpcbuf[0] = port; - ret = (SifCallRpc(&ds34usb, DS34USB_GET_DATA, 0, rpcbuf, 1, rpcbuf, 18, NULL, NULL) == 0); + ret = (SifCallRpc(&ds34usb, DS34USB_GET_DATA, 0, rpcbuf, 1, rpcbuf, 18, NULL, NULL) == 0); - memcpy(data, rpcbuf, 18); + memcpy(data, rpcbuf, 18); - return ret; + return ret; } int ds34usb_reset() { - if (!ds34usb_inited) - return 0; + if (!ds34usb_inited) + return 0; - return (SifCallRpc(&ds34usb, DS34USB_RESET, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); + return (SifCallRpc(&ds34usb, DS34USB_RESET, 0, NULL, 0, NULL, 0, NULL, NULL) == 0); } diff --git a/iop/ds34usb/ee/libds34usb.h b/iop/ds34usb/ee/libds34usb.h index 7def4654..0935c7ea 100644 --- a/iop/ds34usb/ee/libds34usb.h +++ b/iop/ds34usb/ee/libds34usb.h @@ -1,10 +1,10 @@ enum eDS34USBStatus { - DS34USB_STATE_DISCONNECTED = 0x00, - DS34USB_STATE_AUTHORIZED = 0x01, - DS34USB_STATE_CONFIGURED = 0x02, - DS34USB_STATE_CONNECTED = 0x04, - DS34USB_STATE_RUNNING = 0x08, + DS34USB_STATE_DISCONNECTED = 0x00, + DS34USB_STATE_AUTHORIZED = 0x01, + DS34USB_STATE_CONFIGURED = 0x02, + DS34USB_STATE_CONNECTED = 0x04, + DS34USB_STATE_RUNNING = 0x08, }; int ds34usb_init(); diff --git a/iop/ds34usb/iop/ds34usb.c b/iop/ds34usb/iop/ds34usb.c index 0af53600..43d988c2 100644 --- a/iop/ds34usb/iop/ds34usb.c +++ b/iop/ds34usb/iop/ds34usb.c @@ -15,7 +15,7 @@ IRX_ID("ds34usb", 1, 1); #define DPRINTF(x...) #define REQ_USB_OUT (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) -#define REQ_USB_IN (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) +#define REQ_USB_IN (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) #define MAX_PADS 2 @@ -79,604 +79,604 @@ ds34usb_device ds34pad[MAX_PADS]; int usb_probe(int devId) { - UsbDeviceDescriptor *device = NULL; + UsbDeviceDescriptor *device = NULL; - DPRINTF("DS34USB: probe: devId=%i\n", devId); + DPRINTF("DS34USB: probe: devId=%i\n", devId); - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - if (device == NULL) { - DPRINTF("DS34USB: Error - Couldn't get device descriptor\n"); - return 0; - } + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + if (device == NULL) { + DPRINTF("DS34USB: Error - Couldn't get device descriptor\n"); + return 0; + } - if (device->idVendor == DS34_VID && (device->idProduct == DS3_PID || device->idProduct == DS4_PID || device->idProduct == DS4_PID_SLIM)) - return 1; + if (device->idVendor == DS34_VID && (device->idProduct == DS3_PID || device->idProduct == DS4_PID || device->idProduct == DS4_PID_SLIM)) + return 1; - return 0; + return 0; } int usb_connect(int devId) { - int pad, epCount; - UsbDeviceDescriptor *device; - UsbConfigDescriptor *config; - UsbInterfaceDescriptor *interface; - UsbEndpointDescriptor *endpoint; + int pad, epCount; + UsbDeviceDescriptor *device; + UsbConfigDescriptor *config; + UsbInterfaceDescriptor *interface; + UsbEndpointDescriptor *endpoint; - DPRINTF("DS34USB: connect: devId=%i\n", devId); + DPRINTF("DS34USB: connect: devId=%i\n", devId); - for (pad = 0; pad < MAX_PADS; pad++) { - if (ds34pad[pad].devId == -1 && ds34pad[pad].enabled) - break; - } + for (pad = 0; pad < MAX_PADS; pad++) { + if (ds34pad[pad].devId == -1 && ds34pad[pad].enabled) + break; + } - if (pad >= MAX_PADS) { - DPRINTF("DS34USB: Error - only %d device allowed !\n", MAX_PADS); - return 1; - } + if (pad >= MAX_PADS) { + DPRINTF("DS34USB: Error - only %d device allowed !\n", MAX_PADS); + return 1; + } - PollSema(ds34pad[pad].sema); + PollSema(ds34pad[pad].sema); - ds34pad[pad].devId = devId; + ds34pad[pad].devId = devId; - ds34pad[pad].status = DS34USB_STATE_AUTHORIZED; + ds34pad[pad].status = DS34USB_STATE_AUTHORIZED; - ds34pad[pad].controlEndp = UsbOpenEndpoint(devId, NULL); + ds34pad[pad].controlEndp = UsbOpenEndpoint(devId, NULL); - device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); - config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); - interface = (UsbInterfaceDescriptor *)((char *)config + config->bLength); + device = (UsbDeviceDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_DEVICE); + config = (UsbConfigDescriptor *)UsbGetDeviceStaticDescriptor(devId, device, USB_DT_CONFIG); + interface = (UsbInterfaceDescriptor *)((char *)config + config->bLength); - if (device->idProduct == DS3_PID) { - ds34pad[pad].type = DS3; - epCount = interface->bNumEndpoints - 1; - } else { - ds34pad[pad].type = DS4; - epCount = 20; // ds4 v2 returns interface->bNumEndpoints as 0 - } + if (device->idProduct == DS3_PID) { + ds34pad[pad].type = DS3; + epCount = interface->bNumEndpoints - 1; + } else { + ds34pad[pad].type = DS4; + epCount = 20; // ds4 v2 returns interface->bNumEndpoints as 0 + } - endpoint = (UsbEndpointDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_ENDPOINT); + endpoint = (UsbEndpointDescriptor *)UsbGetDeviceStaticDescriptor(devId, NULL, USB_DT_ENDPOINT); - do { - if (endpoint->bmAttributes == USB_ENDPOINT_XFER_INT) { - if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && ds34pad[pad].interruptEndp < 0) { - ds34pad[pad].interruptEndp = UsbOpenEndpointAligned(devId, endpoint); - DPRINTF("DS34USB: register Event endpoint id =%i addr=%02X packetSize=%i\n", ds34pad[pad].interruptEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); - } - if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT && ds34pad[pad].outEndp < 0) { - ds34pad[pad].outEndp = UsbOpenEndpointAligned(devId, endpoint); - DPRINTF("DS34USB: register Output endpoint id =%i addr=%02X packetSize=%i\n", ds34pad[pad].outEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); - } - } + do { + if (endpoint->bmAttributes == USB_ENDPOINT_XFER_INT) { + if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN && ds34pad[pad].interruptEndp < 0) { + ds34pad[pad].interruptEndp = UsbOpenEndpointAligned(devId, endpoint); + DPRINTF("DS34USB: register Event endpoint id =%i addr=%02X packetSize=%i\n", ds34pad[pad].interruptEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); + } + if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT && ds34pad[pad].outEndp < 0) { + ds34pad[pad].outEndp = UsbOpenEndpointAligned(devId, endpoint); + DPRINTF("DS34USB: register Output endpoint id =%i addr=%02X packetSize=%i\n", ds34pad[pad].outEndp, endpoint->bEndpointAddress, (unsigned short int)endpoint->wMaxPacketSizeHB << 8 | endpoint->wMaxPacketSizeLB); + } + } - endpoint = (UsbEndpointDescriptor *)((char *)endpoint + endpoint->bLength); + endpoint = (UsbEndpointDescriptor *)((char *)endpoint + endpoint->bLength); - } while (epCount--); + } while (epCount--); - if (ds34pad[pad].interruptEndp < 0 || ds34pad[pad].outEndp < 0) { - usb_release(pad); - return 1; - } + if (ds34pad[pad].interruptEndp < 0 || ds34pad[pad].outEndp < 0) { + usb_release(pad); + return 1; + } - ds34pad[pad].status |= DS34USB_STATE_CONNECTED; + ds34pad[pad].status |= DS34USB_STATE_CONNECTED; - UsbSetDeviceConfiguration(ds34pad[pad].controlEndp, config->bConfigurationValue, usb_config_set, (void *)pad); - SignalSema(ds34pad[pad].sema); + UsbSetDeviceConfiguration(ds34pad[pad].controlEndp, config->bConfigurationValue, usb_config_set, (void *)pad); + SignalSema(ds34pad[pad].sema); - return 0; + return 0; } int usb_disconnect(int devId) { - u8 pad; + u8 pad; - DPRINTF("DS34USB: disconnect: devId=%i\n", devId); + DPRINTF("DS34USB: disconnect: devId=%i\n", devId); - for (pad = 0; pad < MAX_PADS; pad++) { - if (ds34pad[pad].devId == devId) - break; - } + for (pad = 0; pad < MAX_PADS; pad++) { + if (ds34pad[pad].devId == devId) + break; + } - if (pad < MAX_PADS) - usb_release(pad); + if (pad < MAX_PADS) + usb_release(pad); - return 0; + return 0; } static void usb_release(int pad) { - PollSema(ds34pad[pad].sema); + PollSema(ds34pad[pad].sema); - if (ds34pad[pad].interruptEndp >= 0) - UsbCloseEndpoint(ds34pad[pad].interruptEndp); + if (ds34pad[pad].interruptEndp >= 0) + UsbCloseEndpoint(ds34pad[pad].interruptEndp); - if (ds34pad[pad].outEndp >= 0) - UsbCloseEndpoint(ds34pad[pad].outEndp); + if (ds34pad[pad].outEndp >= 0) + UsbCloseEndpoint(ds34pad[pad].outEndp); - ds34pad[pad].controlEndp = -1; - ds34pad[pad].interruptEndp = -1; - ds34pad[pad].outEndp = -1; - ds34pad[pad].devId = -1; - ds34pad[pad].status = DS34USB_STATE_DISCONNECTED; + ds34pad[pad].controlEndp = -1; + ds34pad[pad].interruptEndp = -1; + ds34pad[pad].outEndp = -1; + ds34pad[pad].devId = -1; + ds34pad[pad].status = DS34USB_STATE_DISCONNECTED; - SignalSema(ds34pad[pad].sema); + SignalSema(ds34pad[pad].sema); } static int usb_resulCode; static void usb_data_cb(int resultCode, int bytes, void *arg) { - int pad = (int)arg; + int pad = (int)arg; - // DPRINTF("DS34USB: usb_data_cb: res %d, bytes %d, arg %p \n", resultCode, bytes, arg); + // DPRINTF("DS34USB: usb_data_cb: res %d, bytes %d, arg %p \n", resultCode, bytes, arg); - usb_resulCode = resultCode; + usb_resulCode = resultCode; - SignalSema(ds34pad[pad].sema); + SignalSema(ds34pad[pad].sema); } static void usb_cmd_cb(int resultCode, int bytes, void *arg) { - int pad = (int)arg; + int pad = (int)arg; - // DPRINTF("DS34USB: usb_cmd_cb: res %d, bytes %d, arg %p \n", resultCode, bytes, arg); + // DPRINTF("DS34USB: usb_cmd_cb: res %d, bytes %d, arg %p \n", resultCode, bytes, arg); - SignalSema(ds34pad[pad].cmd_sema); + SignalSema(ds34pad[pad].cmd_sema); } static void usb_config_set(int result, int count, void *arg) { - int pad = (int)arg; - u8 led[4]; + int pad = (int)arg; + u8 led[4]; - PollSema(ds34pad[pad].sema); + PollSema(ds34pad[pad].sema); - ds34pad[pad].status |= DS34USB_STATE_CONFIGURED; + ds34pad[pad].status |= DS34USB_STATE_CONFIGURED; - if (ds34pad[pad].type == DS3) { - DS3USB_init(pad); - DelayThread(10000); - led[0] = led_patterns[pad][1]; - led[3] = 0; - } else if (ds34pad[pad].type == DS4) { - led[0] = rgbled_patterns[pad][1][0]; - led[1] = rgbled_patterns[pad][1][1]; - led[2] = rgbled_patterns[pad][1][2]; - led[3] = 0; - } + if (ds34pad[pad].type == DS3) { + DS3USB_init(pad); + DelayThread(10000); + led[0] = led_patterns[pad][1]; + led[3] = 0; + } else if (ds34pad[pad].type == DS4) { + led[0] = rgbled_patterns[pad][1][0]; + led[1] = rgbled_patterns[pad][1][1]; + led[2] = rgbled_patterns[pad][1][2]; + led[3] = 0; + } - LEDRumble(led, 0, 0, pad); - DelayThread(20000); + LEDRumble(led, 0, 0, pad); + DelayThread(20000); - ds34pad[pad].status |= DS34USB_STATE_RUNNING; + ds34pad[pad].status |= DS34USB_STATE_RUNNING; - SignalSema(ds34pad[pad].sema); + SignalSema(ds34pad[pad].sema); } static void DS3USB_init(int pad) { - usb_buf[0] = 0x42; - usb_buf[1] = 0x0c; - usb_buf[2] = 0x00; - usb_buf[3] = 0x00; + usb_buf[0] = 0x42; + usb_buf[1] = 0x0c; + usb_buf[2] = 0x00; + usb_buf[3] = 0x00; - UsbControlTransfer(ds34pad[pad].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF4, 0, 4, usb_buf, NULL, NULL); + UsbControlTransfer(ds34pad[pad].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF4, 0, 4, usb_buf, NULL, NULL); } static void readReport(u8 *data, int pad) { - if (data[0]) { - - if (ds34pad[pad].type == DS3) { - struct ds3report *report; - - report = (struct ds3report *)&data[2]; - - ds34pad[pad].data[0] = ~report->ButtonStateL; - ds34pad[pad].data[1] = ~report->ButtonStateH; - - ds34pad[pad].data[2] = report->RightStickX; // rx - ds34pad[pad].data[3] = report->RightStickY; // ry - ds34pad[pad].data[4] = report->LeftStickX; // lx - ds34pad[pad].data[5] = report->LeftStickY; // ly - - ds34pad[pad].data[6] = report->PressureRight; // right - ds34pad[pad].data[7] = report->PressureLeft; // left - ds34pad[pad].data[8] = report->PressureUp; // up - ds34pad[pad].data[9] = report->PressureDown; // down - - ds34pad[pad].data[10] = report->PressureTriangle; // triangle - ds34pad[pad].data[11] = report->PressureCircle; // circle - ds34pad[pad].data[12] = report->PressureCross; // cross - ds34pad[pad].data[13] = report->PressureSquare; // square - - ds34pad[pad].data[14] = report->PressureL1; // L1 - ds34pad[pad].data[15] = report->PressureR1; // R1 - ds34pad[pad].data[16] = report->PressureL2; // L2 - ds34pad[pad].data[17] = report->PressureR2; // R2 - - if (report->PSButtonState && report->Power != 0xEE) // display battery level - ds34pad[pad].oldled[0] = power_level[report->Power]; - else - ds34pad[pad].oldled[0] = led_patterns[pad][1]; - - if (report->Power == 0xEE) // charging - ds34pad[pad].oldled[3] = 1; - else - ds34pad[pad].oldled[3] = 0; - - } else if (ds34pad[pad].type == DS4) { - struct ds4report *report; - u8 up = 0, down = 0, left = 0, right = 0; - - report = (struct ds4report *)data; - - switch (report->Dpad) { - case 0: - up = 1; - break; - case 1: - up = 1; - right = 1; - break; - case 2: - right = 1; - break; - case 3: - down = 1; - right = 1; - break; - case 4: - down = 1; - break; - case 5: - down = 1; - left = 1; - break; - case 6: - left = 1; - break; - case 7: - up = 1; - left = 1; - break; - case 8: - up = 0; - down = 0; - left = 0; - right = 0; - break; - } - - if (report->TPad) { - if (!report->Finger1Active) { - if (report->Finger1X < 960) - report->Share = 1; - else - report->Option = 1; - } - - if (!report->Finger2Active) { - if (report->Finger2X < 960) - report->Share = 1; - else - report->Option = 1; - } - } - - ds34pad[pad].data[0] = ~(report->Share | report->L3 << 1 | report->R3 << 2 | report->Option << 3 | up << 4 | right << 5 | down << 6 | left << 7); - ds34pad[pad].data[1] = ~(report->L2 | report->R2 << 1 | report->L1 << 2 | report->R1 << 3 | report->Triangle << 4 | report->Circle << 5 | report->Cross << 6 | report->Square << 7); - - ds34pad[pad].data[2] = report->RightStickX; // rx - ds34pad[pad].data[3] = report->RightStickY; // ry - ds34pad[pad].data[4] = report->LeftStickX; // lx - ds34pad[pad].data[5] = report->LeftStickY; // ly - - ds34pad[pad].data[6] = right * 255; // right - ds34pad[pad].data[7] = left * 255; // left - ds34pad[pad].data[8] = up * 255; // up - ds34pad[pad].data[9] = down * 255; // down - - ds34pad[pad].data[10] = report->Triangle * 255; // triangle - ds34pad[pad].data[11] = report->Circle * 255; // circle - ds34pad[pad].data[12] = report->Cross * 255; // cross - ds34pad[pad].data[13] = report->Square * 255; // square - - ds34pad[pad].data[14] = report->L1 * 255; // L1 - ds34pad[pad].data[15] = report->R1 * 255; // R1 - ds34pad[pad].data[16] = report->PressureL2; // L2 - ds34pad[pad].data[17] = report->PressureR2; // R2 - - if (report->PSButton) { // display battery level - ds34pad[pad].oldled[0] = report->Battery; - ds34pad[pad].oldled[1] = 0; - ds34pad[pad].oldled[2] = 0; - } else { - ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; - ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; - ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; - } - - if (report->Power != 0xB && report->Usb_plugged) // charging - ds34pad[pad].oldled[3] = 1; - else - ds34pad[pad].oldled[3] = 0; - } - } + if (data[0]) { + + if (ds34pad[pad].type == DS3) { + struct ds3report *report; + + report = (struct ds3report *)&data[2]; + + ds34pad[pad].data[0] = ~report->ButtonStateL; + ds34pad[pad].data[1] = ~report->ButtonStateH; + + ds34pad[pad].data[2] = report->RightStickX; // rx + ds34pad[pad].data[3] = report->RightStickY; // ry + ds34pad[pad].data[4] = report->LeftStickX; // lx + ds34pad[pad].data[5] = report->LeftStickY; // ly + + ds34pad[pad].data[6] = report->PressureRight; // right + ds34pad[pad].data[7] = report->PressureLeft; // left + ds34pad[pad].data[8] = report->PressureUp; // up + ds34pad[pad].data[9] = report->PressureDown; // down + + ds34pad[pad].data[10] = report->PressureTriangle; // triangle + ds34pad[pad].data[11] = report->PressureCircle; // circle + ds34pad[pad].data[12] = report->PressureCross; // cross + ds34pad[pad].data[13] = report->PressureSquare; // square + + ds34pad[pad].data[14] = report->PressureL1; // L1 + ds34pad[pad].data[15] = report->PressureR1; // R1 + ds34pad[pad].data[16] = report->PressureL2; // L2 + ds34pad[pad].data[17] = report->PressureR2; // R2 + + if (report->PSButtonState && report->Power != 0xEE) // display battery level + ds34pad[pad].oldled[0] = power_level[report->Power]; + else + ds34pad[pad].oldled[0] = led_patterns[pad][1]; + + if (report->Power == 0xEE) // charging + ds34pad[pad].oldled[3] = 1; + else + ds34pad[pad].oldled[3] = 0; + + } else if (ds34pad[pad].type == DS4) { + struct ds4report *report; + u8 up = 0, down = 0, left = 0, right = 0; + + report = (struct ds4report *)data; + + switch (report->Dpad) { + case 0: + up = 1; + break; + case 1: + up = 1; + right = 1; + break; + case 2: + right = 1; + break; + case 3: + down = 1; + right = 1; + break; + case 4: + down = 1; + break; + case 5: + down = 1; + left = 1; + break; + case 6: + left = 1; + break; + case 7: + up = 1; + left = 1; + break; + case 8: + up = 0; + down = 0; + left = 0; + right = 0; + break; + } + + if (report->TPad) { + if (!report->Finger1Active) { + if (report->Finger1X < 960) + report->Share = 1; + else + report->Option = 1; + } + + if (!report->Finger2Active) { + if (report->Finger2X < 960) + report->Share = 1; + else + report->Option = 1; + } + } + + ds34pad[pad].data[0] = ~(report->Share | report->L3 << 1 | report->R3 << 2 | report->Option << 3 | up << 4 | right << 5 | down << 6 | left << 7); + ds34pad[pad].data[1] = ~(report->L2 | report->R2 << 1 | report->L1 << 2 | report->R1 << 3 | report->Triangle << 4 | report->Circle << 5 | report->Cross << 6 | report->Square << 7); + + ds34pad[pad].data[2] = report->RightStickX; // rx + ds34pad[pad].data[3] = report->RightStickY; // ry + ds34pad[pad].data[4] = report->LeftStickX; // lx + ds34pad[pad].data[5] = report->LeftStickY; // ly + + ds34pad[pad].data[6] = right * 255; // right + ds34pad[pad].data[7] = left * 255; // left + ds34pad[pad].data[8] = up * 255; // up + ds34pad[pad].data[9] = down * 255; // down + + ds34pad[pad].data[10] = report->Triangle * 255; // triangle + ds34pad[pad].data[11] = report->Circle * 255; // circle + ds34pad[pad].data[12] = report->Cross * 255; // cross + ds34pad[pad].data[13] = report->Square * 255; // square + + ds34pad[pad].data[14] = report->L1 * 255; // L1 + ds34pad[pad].data[15] = report->R1 * 255; // R1 + ds34pad[pad].data[16] = report->PressureL2; // L2 + ds34pad[pad].data[17] = report->PressureR2; // R2 + + if (report->PSButton) { // display battery level + ds34pad[pad].oldled[0] = report->Battery; + ds34pad[pad].oldled[1] = 0; + ds34pad[pad].oldled[2] = 0; + } else { + ds34pad[pad].oldled[0] = rgbled_patterns[pad][1][0]; + ds34pad[pad].oldled[1] = rgbled_patterns[pad][1][1]; + ds34pad[pad].oldled[2] = rgbled_patterns[pad][1][2]; + } + + if (report->Power != 0xB && report->Usb_plugged) // charging + ds34pad[pad].oldled[3] = 1; + else + ds34pad[pad].oldled[3] = 0; + } + } } static int LEDRumble(u8 *led, u8 lrum, u8 rrum, int pad) { - int ret = 0; + int ret = 0; - PollSema(ds34pad[pad].cmd_sema); + PollSema(ds34pad[pad].cmd_sema); - mips_memset(usb_buf, 0, sizeof(usb_buf)); + mips_memset(usb_buf, 0, sizeof(usb_buf)); - if (ds34pad[pad].type == DS3) { - mips_memcpy(usb_buf, output_01_report, sizeof(output_01_report)); + if (ds34pad[pad].type == DS3) { + mips_memcpy(usb_buf, output_01_report, sizeof(output_01_report)); - usb_buf[1] = 0xFE; // rt - usb_buf[2] = rrum; // rp - usb_buf[3] = 0xFE; // lt - usb_buf[4] = lrum; // lp + usb_buf[1] = 0xFE; // rt + usb_buf[2] = rrum; // rp + usb_buf[3] = 0xFE; // lt + usb_buf[4] = lrum; // lp - usb_buf[9] = led[0] & 0x7F; // LED Conf + usb_buf[9] = led[0] & 0x7F; // LED Conf - if (led[3]) { // means charging, so blink - usb_buf[13] = 0x32; - usb_buf[18] = 0x32; - usb_buf[23] = 0x32; - usb_buf[28] = 0x32; - } + if (led[3]) { // means charging, so blink + usb_buf[13] = 0x32; + usb_buf[18] = 0x32; + usb_buf[23] = 0x32; + usb_buf[28] = 0x32; + } - ret = UsbControlTransfer(ds34pad[pad].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_SET_REPORT_OUTPUT << 8) | 0x01, 0, sizeof(output_01_report), usb_buf, usb_cmd_cb, (void *)pad); - } else if (ds34pad[pad].type == DS4) { - usb_buf[0] = 0x05; - usb_buf[1] = 0xFF; + ret = UsbControlTransfer(ds34pad[pad].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_SET_REPORT_OUTPUT << 8) | 0x01, 0, sizeof(output_01_report), usb_buf, usb_cmd_cb, (void *)pad); + } else if (ds34pad[pad].type == DS4) { + usb_buf[0] = 0x05; + usb_buf[1] = 0xFF; - usb_buf[4] = rrum; // ds4 has full control - usb_buf[5] = lrum; + usb_buf[4] = rrum; // ds4 has full control + usb_buf[5] = lrum; - usb_buf[6] = led[0]; // r - usb_buf[7] = led[1]; // g - usb_buf[8] = led[2]; // b + usb_buf[6] = led[0]; // r + usb_buf[7] = led[1]; // g + usb_buf[8] = led[2]; // b - if (led[3]) { // means charging, so blink - usb_buf[9] = 0x80; // Time to flash bright (255 = 2.5 seconds) - usb_buf[10] = 0x80; // Time to flash dark (255 = 2.5 seconds) - } + if (led[3]) { // means charging, so blink + usb_buf[9] = 0x80; // Time to flash bright (255 = 2.5 seconds) + usb_buf[10] = 0x80; // Time to flash dark (255 = 2.5 seconds) + } - ret = UsbInterruptTransfer(ds34pad[pad].outEndp, usb_buf, 32, usb_cmd_cb, (void *)pad); - } + ret = UsbInterruptTransfer(ds34pad[pad].outEndp, usb_buf, 32, usb_cmd_cb, (void *)pad); + } - ds34pad[pad].oldled[0] = led[0]; - ds34pad[pad].oldled[1] = led[1]; - ds34pad[pad].oldled[2] = led[2]; - ds34pad[pad].oldled[3] = led[3]; + ds34pad[pad].oldled[0] = led[0]; + ds34pad[pad].oldled[1] = led[1]; + ds34pad[pad].oldled[2] = led[2]; + ds34pad[pad].oldled[3] = led[3]; - ds34pad[pad].lrum = lrum; - ds34pad[pad].rrum = rrum; + ds34pad[pad].lrum = lrum; + ds34pad[pad].rrum = rrum; - return ret; + return ret; } static unsigned int timeout(void *arg) { - int sema = (int)arg; - iSignalSema(sema); - return 0; + int sema = (int)arg; + iSignalSema(sema); + return 0; } static void TransferWait(int sema) { - iop_sys_clock_t cmd_timeout; + iop_sys_clock_t cmd_timeout; - cmd_timeout.lo = 200000; - cmd_timeout.hi = 0; + cmd_timeout.lo = 200000; + cmd_timeout.hi = 0; - if (SetAlarm(&cmd_timeout, timeout, (void *)sema) == 0) { - WaitSema(sema); - CancelAlarm(timeout, NULL); - } + if (SetAlarm(&cmd_timeout, timeout, (void *)sema) == 0) { + WaitSema(sema); + CancelAlarm(timeout, NULL); + } } static int LEDRUM(u8 *led, u8 lrum, u8 rrum, int pad) { - int ret = 0; + int ret = 0; - WaitSema(ds34pad[pad].sema); + WaitSema(ds34pad[pad].sema); - if (ds34pad[pad].update_rum) { - ret = LEDRumble(led, lrum, rrum, pad); + if (ds34pad[pad].update_rum) { + ret = LEDRumble(led, lrum, rrum, pad); - if (ret == USB_RC_OK) - TransferWait(ds34pad[pad].cmd_sema); - else - DPRINTF("DS34USB: LEDRUM usb transfer error 0x%02X\n", ret); - } + if (ret == USB_RC_OK) + TransferWait(ds34pad[pad].cmd_sema); + else + DPRINTF("DS34USB: LEDRUM usb transfer error 0x%02X\n", ret); + } - SignalSema(ds34pad[pad].sema); + SignalSema(ds34pad[pad].sema); - return ret; + return ret; } static int LED(u8 *led, int pad) { - return LEDRUM(led, ds34pad[pad].lrum, ds34pad[pad].rrum, pad); + return LEDRUM(led, ds34pad[pad].lrum, ds34pad[pad].rrum, pad); } static int Rumble(u8 lrum, u8 rrum, int pad) { - return LEDRUM(ds34pad[pad].oldled, lrum, rrum, pad); + return LEDRUM(ds34pad[pad].oldled, lrum, rrum, pad); } void ds34usb_set_rumble(u8 lrum, u8 rrum, int port) { - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - Rumble(lrum, rrum, port); + Rumble(lrum, rrum, port); } void ds34usb_set_led(u8 *led, int port) { - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - LED(led, port); + LED(led, port); } void ds34usb_get_data(char *dst, int size, int port) { - int ret; + int ret; - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - WaitSema(ds34pad[port].sema); + WaitSema(ds34pad[port].sema); - PollSema(ds34pad[port].sema); + PollSema(ds34pad[port].sema); - ret = UsbInterruptTransfer(ds34pad[port].interruptEndp, usb_buf, MAX_BUFFER_SIZE, usb_data_cb, (void *)port); + ret = UsbInterruptTransfer(ds34pad[port].interruptEndp, usb_buf, MAX_BUFFER_SIZE, usb_data_cb, (void *)port); - if (ret == USB_RC_OK) { - TransferWait(ds34pad[port].sema); - if (!usb_resulCode) - readReport(usb_buf, port); + if (ret == USB_RC_OK) { + TransferWait(ds34pad[port].sema); + if (!usb_resulCode) + readReport(usb_buf, port); - usb_resulCode = 1; - } else { - DPRINTF("DS34USB: ds34usb_get_data usb transfer error %d\n", ret); - } + usb_resulCode = 1; + } else { + DPRINTF("DS34USB: ds34usb_get_data usb transfer error %d\n", ret); + } - mips_memcpy(dst, ds34pad[port].data, size); + mips_memcpy(dst, ds34pad[port].data, size); - SignalSema(ds34pad[port].sema); + SignalSema(ds34pad[port].sema); } int ds34usb_get_bdaddr(u8 *data, int port) { - int i, ret; + int i, ret; - if (port >= MAX_PADS) - return 0; + if (port >= MAX_PADS) + return 0; - if (ds34pad[port].update_rum) { - ds34pad[port].update_rum = 0; - return 0; - } + if (ds34pad[port].update_rum) { + ds34pad[port].update_rum = 0; + return 0; + } - WaitSema(ds34pad[port].sema); + WaitSema(ds34pad[port].sema); - PollSema(ds34pad[port].cmd_sema); + PollSema(ds34pad[port].cmd_sema); - if (ds34pad[port].type == DS3) { - ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_IN, USB_REQ_GET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF5, 0, 8, usb_buf, usb_cmd_cb, (void *)port); + if (ds34pad[port].type == DS3) { + ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_IN, USB_REQ_GET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF5, 0, 8, usb_buf, usb_cmd_cb, (void *)port); - if (ret == USB_RC_OK) { - TransferWait(ds34pad[port].cmd_sema); + if (ret == USB_RC_OK) { + TransferWait(ds34pad[port].cmd_sema); - for (i = 0; i < 6; i++) - data[5 - i] = usb_buf[2 + i]; + for (i = 0; i < 6; i++) + data[5 - i] = usb_buf[2 + i]; - ret = 1; - } else { - DPRINTF("DS34USB: ds3usb_get_bdaddr usb transfer error %d\n", ret); - ret = 0; - } - } else { - ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_IN, USB_REQ_GET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0x12, 0, 16, usb_buf, usb_cmd_cb, (void *)port); + ret = 1; + } else { + DPRINTF("DS34USB: ds3usb_get_bdaddr usb transfer error %d\n", ret); + ret = 0; + } + } else { + ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_IN, USB_REQ_GET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0x12, 0, 16, usb_buf, usb_cmd_cb, (void *)port); - if (ret == USB_RC_OK) { - TransferWait(ds34pad[port].cmd_sema); + if (ret == USB_RC_OK) { + TransferWait(ds34pad[port].cmd_sema); - for (i = 0; i < 6; i++) - data[5 - i] = usb_buf[15 - i]; + for (i = 0; i < 6; i++) + data[5 - i] = usb_buf[15 - i]; - ret = 1; - } else { - DPRINTF("DS34USB: ds3usb_get_bdaddr usb transfer error %d\n", ret); - ret = 0; - } - } + ret = 1; + } else { + DPRINTF("DS34USB: ds3usb_get_bdaddr usb transfer error %d\n", ret); + ret = 0; + } + } - ds34pad[port].update_rum = 1; - SignalSema(ds34pad[port].sema); + ds34pad[port].update_rum = 1; + SignalSema(ds34pad[port].sema); - return ret; + return ret; } void ds34usb_set_bdaddr(u8 *data, int port) { - int i, ret; + int i, ret; - if (port >= MAX_PADS) - return; + if (port >= MAX_PADS) + return; - WaitSema(ds34pad[port].sema); + WaitSema(ds34pad[port].sema); - PollSema(ds34pad[port].cmd_sema); + PollSema(ds34pad[port].cmd_sema); - if (ds34pad[port].type == DS3) { - usb_buf[0] = 0x01; - usb_buf[1] = 0x00; + if (ds34pad[port].type == DS3) { + usb_buf[0] = 0x01; + usb_buf[1] = 0x00; - for (i = 0; i < 6; i++) - usb_buf[i + 2] = data[5 - i]; + for (i = 0; i < 6; i++) + usb_buf[i + 2] = data[5 - i]; - ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF5, 0, 8, usb_buf, usb_cmd_cb, (void *)port); - } else { - usb_buf[0] = 0x13; + ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0xF5, 0, 8, usb_buf, usb_cmd_cb, (void *)port); + } else { + usb_buf[0] = 0x13; - for (i = 0; i < 6; i++) - usb_buf[i + 1] = data[i]; + for (i = 0; i < 6; i++) + usb_buf[i + 1] = data[i]; - for (i = 0; i < sizeof(link_key); i++) - usb_buf[i + 7] = link_key[i]; + for (i = 0; i < sizeof(link_key); i++) + usb_buf[i + 7] = link_key[i]; - ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0x13, 0, 24, usb_buf, usb_cmd_cb, (void *)port); - } + ret = UsbControlTransfer(ds34pad[port].controlEndp, REQ_USB_OUT, USB_REQ_SET_REPORT, (HID_USB_GET_REPORT_FEATURE << 8) | 0x13, 0, 24, usb_buf, usb_cmd_cb, (void *)port); + } - if (ret == USB_RC_OK) - TransferWait(ds34pad[port].cmd_sema); - else - DPRINTF("DS34USB: ds3usb_set_bdaddr usb transfer error %d\n", ret); + if (ret == USB_RC_OK) + TransferWait(ds34pad[port].cmd_sema); + else + DPRINTF("DS34USB: ds3usb_set_bdaddr usb transfer error %d\n", ret); - SignalSema(ds34pad[port].sema); + SignalSema(ds34pad[port].sema); } void ds34usb_reset() { - int pad; + int pad; - for (pad = 0; pad < MAX_PADS; pad++) - usb_release(pad); + for (pad = 0; pad < MAX_PADS; pad++) + usb_release(pad); } int ds34usb_get_status(int port) { - int ret; + int ret; - if (port >= MAX_PADS) - return 0; + if (port >= MAX_PADS) + return 0; - WaitSema(ds34pad[port].sema); - ret = ds34pad[port].status; - SignalSema(ds34pad[port].sema); + WaitSema(ds34pad[port].sema); + ret = ds34pad[port].status; + SignalSema(ds34pad[port].sema); - return ret; + return ret; } void ds34usb_init(u8 pads) { - u8 pad; + u8 pad; - for (pad = 0; pad < MAX_PADS; pad++) { - WaitSema(ds34pad[pad].sema); - ds34pad[pad].enabled = (pads >> pad) & 1; - SignalSema(ds34pad[pad].sema); - } + for (pad = 0; pad < MAX_PADS; pad++) { + WaitSema(ds34pad[pad].sema); + ds34pad[pad].enabled = (pads >> pad) & 1; + SignalSema(ds34pad[pad].sema); + } } static void rpc_thread(void *data); @@ -687,120 +687,120 @@ static SifRpcServerData_t rpc_svr __attribute__((aligned(16))); static int rpc_buf[64] __attribute((aligned(16))); -#define DS34USB_INIT 1 +#define DS34USB_INIT 1 #define DS34USB_GET_STATUS 2 #define DS34USB_GET_BDADDR 3 #define DS34USB_SET_BDADDR 4 #define DS34USB_SET_RUMBLE 5 -#define DS34USB_SET_LED 6 -#define DS34USB_GET_DATA 7 -#define DS34USB_RESET 8 +#define DS34USB_SET_LED 6 +#define DS34USB_GET_DATA 7 +#define DS34USB_RESET 8 #define DS34USB_BIND_RPC_ID 0x18E3878E void rpc_thread(void *data) { - SifInitRpc(0); - SifSetRpcQueue(&rpc_que, GetThreadId()); - SifRegisterRpc(&rpc_svr, DS34USB_BIND_RPC_ID, rpc_sf, rpc_buf, NULL, NULL, &rpc_que); - SifRpcLoop(&rpc_que); + SifInitRpc(0); + SifSetRpcQueue(&rpc_que, GetThreadId()); + SifRegisterRpc(&rpc_svr, DS34USB_BIND_RPC_ID, rpc_sf, rpc_buf, NULL, NULL, &rpc_que); + SifRpcLoop(&rpc_que); } void *rpc_sf(int cmd, void *data, int size) { - switch (cmd) { - case DS34USB_INIT: - ds34usb_init(*(u8 *)data); - break; - case DS34USB_GET_STATUS: - *(u8 *)data = ds34usb_get_status(*(u8 *)data); - break; - case DS34USB_GET_BDADDR: - *(u8 *)data = ds34usb_get_bdaddr((u8 *)(data + 1), *(u8 *)data); - break; - case DS34USB_SET_BDADDR: - ds34usb_set_bdaddr((u8 *)(data + 1), *(u8 *)data); - break; - case DS34USB_SET_RUMBLE: - ds34usb_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); - break; - case DS34USB_SET_LED: - ds34usb_set_led((u8 *)(data + 1), *(u8 *)data); - break; - case DS34USB_GET_DATA: - ds34usb_get_data((char *)data, 18, *(u8 *)data); - break; - case DS34USB_RESET: - ds34usb_reset(); - break; - default: - break; - } - - return data; + switch (cmd) { + case DS34USB_INIT: + ds34usb_init(*(u8 *)data); + break; + case DS34USB_GET_STATUS: + *(u8 *)data = ds34usb_get_status(*(u8 *)data); + break; + case DS34USB_GET_BDADDR: + *(u8 *)data = ds34usb_get_bdaddr((u8 *)(data + 1), *(u8 *)data); + break; + case DS34USB_SET_BDADDR: + ds34usb_set_bdaddr((u8 *)(data + 1), *(u8 *)data); + break; + case DS34USB_SET_RUMBLE: + ds34usb_set_rumble(*(u8 *)(data + 1), *(u8 *)(data + 2), *(u8 *)data); + break; + case DS34USB_SET_LED: + ds34usb_set_led((u8 *)(data + 1), *(u8 *)data); + break; + case DS34USB_GET_DATA: + ds34usb_get_data((char *)data, 18, *(u8 *)data); + break; + case DS34USB_RESET: + ds34usb_reset(); + break; + default: + break; + } + + return data; } int _start(int argc, char *argv[]) { - int pad; - u8 enable = 0xFF; - - if (argc > 1) { - enable = argv[1][0]; - } - - for (pad = 0; pad < MAX_PADS; pad++) { - ds34pad[pad].status = 0; - ds34pad[pad].devId = -1; - ds34pad[pad].oldled[0] = 0; - ds34pad[pad].oldled[1] = 0; - ds34pad[pad].oldled[2] = 0; - ds34pad[pad].oldled[3] = 0; - ds34pad[pad].lrum = 0; - ds34pad[pad].rrum = 0; - ds34pad[pad].update_rum = 1; - ds34pad[pad].sema = -1; - ds34pad[pad].cmd_sema = -1; - ds34pad[pad].controlEndp = -1; - ds34pad[pad].interruptEndp = -1; - ds34pad[pad].outEndp = -1; - ds34pad[pad].enabled = (enable >> pad) & 1; - ds34pad[pad].type = 0; - - ds34pad[pad].data[0] = 0xFF; - ds34pad[pad].data[1] = 0xFF; - - mips_memset(&ds34pad[pad].data[2], 0x7F, 4); - mips_memset(&ds34pad[pad].data[6], 0x00, 12); - - ds34pad[pad].sema = CreateMutex(IOP_MUTEX_UNLOCKED); - ds34pad[pad].cmd_sema = CreateMutex(IOP_MUTEX_UNLOCKED); - - if (ds34pad[pad].sema < 0 || ds34pad[pad].cmd_sema < 0) { - DPRINTF("DS34USB: Failed to allocate I/O semaphore.\n"); - return MODULE_NO_RESIDENT_END; - } - } - - if (UsbRegisterDriver(&usb_driver) != USB_RC_OK) { - DPRINTF("DS34USB: Error registering USB devices\n"); - return MODULE_NO_RESIDENT_END; - } - - iop_thread_t rpc_th; - - rpc_th.attr = TH_C; - rpc_th.thread = rpc_thread; - rpc_th.priority = 40; - rpc_th.stacksize = 0x800; - rpc_th.option = 0; - - int thid = CreateThread(&rpc_th); - - if (thid > 0) { - StartThread(thid, NULL); - return MODULE_RESIDENT_END; - } - - return MODULE_NO_RESIDENT_END; + int pad; + u8 enable = 0xFF; + + if (argc > 1) { + enable = argv[1][0]; + } + + for (pad = 0; pad < MAX_PADS; pad++) { + ds34pad[pad].status = 0; + ds34pad[pad].devId = -1; + ds34pad[pad].oldled[0] = 0; + ds34pad[pad].oldled[1] = 0; + ds34pad[pad].oldled[2] = 0; + ds34pad[pad].oldled[3] = 0; + ds34pad[pad].lrum = 0; + ds34pad[pad].rrum = 0; + ds34pad[pad].update_rum = 1; + ds34pad[pad].sema = -1; + ds34pad[pad].cmd_sema = -1; + ds34pad[pad].controlEndp = -1; + ds34pad[pad].interruptEndp = -1; + ds34pad[pad].outEndp = -1; + ds34pad[pad].enabled = (enable >> pad) & 1; + ds34pad[pad].type = 0; + + ds34pad[pad].data[0] = 0xFF; + ds34pad[pad].data[1] = 0xFF; + + mips_memset(&ds34pad[pad].data[2], 0x7F, 4); + mips_memset(&ds34pad[pad].data[6], 0x00, 12); + + ds34pad[pad].sema = CreateMutex(IOP_MUTEX_UNLOCKED); + ds34pad[pad].cmd_sema = CreateMutex(IOP_MUTEX_UNLOCKED); + + if (ds34pad[pad].sema < 0 || ds34pad[pad].cmd_sema < 0) { + DPRINTF("DS34USB: Failed to allocate I/O semaphore.\n"); + return MODULE_NO_RESIDENT_END; + } + } + + if (UsbRegisterDriver(&usb_driver) != USB_RC_OK) { + DPRINTF("DS34USB: Error registering USB devices\n"); + return MODULE_NO_RESIDENT_END; + } + + iop_thread_t rpc_th; + + rpc_th.attr = TH_C; + rpc_th.thread = rpc_thread; + rpc_th.priority = 40; + rpc_th.stacksize = 0x800; + rpc_th.option = 0; + + int thid = CreateThread(&rpc_th); + + if (thid > 0) { + StartThread(thid, NULL); + return MODULE_RESIDENT_END; + } + + return MODULE_NO_RESIDENT_END; } diff --git a/iop/ds34usb/iop/ds34usb.h b/iop/ds34usb/iop/ds34usb.h index b9c3d045..23adf4f2 100644 --- a/iop/ds34usb/iop/ds34usb.h +++ b/iop/ds34usb/iop/ds34usb.h @@ -3,9 +3,9 @@ #include "irx.h" -#define DS34_VID 0x054C // Sony Corporation -#define DS3_PID 0x0268 // PS3 Controller -#define DS4_PID 0x05C4 // PS4 Controller +#define DS34_VID 0x054C // Sony Corporation +#define DS3_PID 0x0268 // PS3 Controller +#define DS4_PID 0x05C4 // PS4 Controller #define DS4_PID_SLIM 0x09CC // PS4 Slim Controller #define DS3 0 @@ -15,170 +15,170 @@ typedef struct _usb_ds34 { - int devId; - int sema; - int cmd_sema; - int controlEndp; - int interruptEndp; - int outEndp; - u8 status; - u8 enabled; - u8 lrum; - u8 rrum; - u8 update_rum; - u8 oldled[4]; // rgb for ds4 and blink - u8 data[18]; - u8 type; + int devId; + int sema; + int cmd_sema; + int controlEndp; + int interruptEndp; + int outEndp; + u8 status; + u8 enabled; + u8 lrum; + u8 rrum; + u8 update_rum; + u8 oldled[4]; // rgb for ds4 and blink + u8 data[18]; + u8 type; } ds34usb_device; enum eDS34USBStatus { - DS34USB_STATE_DISCONNECTED = 0x00, - DS34USB_STATE_AUTHORIZED = 0x01, - DS34USB_STATE_CONFIGURED = 0x02, - DS34USB_STATE_CONNECTED = 0x04, - DS34USB_STATE_RUNNING = 0x08, + DS34USB_STATE_DISCONNECTED = 0x00, + DS34USB_STATE_AUTHORIZED = 0x01, + DS34USB_STATE_CONFIGURED = 0x02, + DS34USB_STATE_CONNECTED = 0x04, + DS34USB_STATE_RUNNING = 0x08, }; enum eHID { - // {{{ - /* HID event flag */ - HID_FLAG_STATUS_REPORTED = 0x01, - HID_FLAG_BUTTONS_CHANGED = 0x02, - HID_FLAG_EXTENSION = 0x04, - HID_FLAG_COMMAND_SUCCESS = 0x08, - - /* USB HID Transaction Header (THdr) */ - HID_USB_GET_REPORT_FEATURE = 0x03, - HID_USB_SET_REPORT_OUTPUT = 0x02, - HID_USB_DATA_INPUT = 0x01, - - /* Defines of various parameters for PS3 Game controller reports */ - PS3_F4_REPORT_ID = 0xF4, - PS3_F4_REPORT_LEN = 0x04, - - PS3_01_REPORT_ID = 0x01, - PS3_01_REPORT_LEN = 0x30, - - PS4_02_REPORT_ID = 0x02, - PS4_11_REPORT_ID = 0x11, - PS4_11_REPORT_LEN = 0x4D, - // }}} + // {{{ + /* HID event flag */ + HID_FLAG_STATUS_REPORTED = 0x01, + HID_FLAG_BUTTONS_CHANGED = 0x02, + HID_FLAG_EXTENSION = 0x04, + HID_FLAG_COMMAND_SUCCESS = 0x08, + + /* USB HID Transaction Header (THdr) */ + HID_USB_GET_REPORT_FEATURE = 0x03, + HID_USB_SET_REPORT_OUTPUT = 0x02, + HID_USB_DATA_INPUT = 0x01, + + /* Defines of various parameters for PS3 Game controller reports */ + PS3_F4_REPORT_ID = 0xF4, + PS3_F4_REPORT_LEN = 0x04, + + PS3_01_REPORT_ID = 0x01, + PS3_01_REPORT_LEN = 0x30, + + PS4_02_REPORT_ID = 0x02, + PS4_11_REPORT_ID = 0x11, + PS4_11_REPORT_LEN = 0x4D, + // }}} }; struct ds3report { - union - { - u8 ButtonStateL; // Main buttons Low - struct - { - u8 Select : 1; - u8 L3 : 1; - u8 R3 : 1; - u8 Start : 1; - u8 Up : 1; - u8 Right : 1; - u8 Down : 1; - u8 Left : 1; - }; - }; - union - { - u8 ButtonStateH; // Main buttons High - struct - { - u8 L2 : 1; - u8 R2 : 1; - u8 L1 : 1; - u8 R1 : 1; - u8 Triangle : 1; - u8 Circle : 1; - u8 Cross : 1; - u8 Square : 1; - }; - }; - u8 PSButtonState; // PS button - u8 Reserved1; // Unknown - u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid - u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid - u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid - u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid - u8 Reserved2[4]; // Unknown - u8 PressureUp; // digital Pad Up button Pressure 0 - 255 - u8 PressureRight; // digital Pad Right button Pressure 0 - 255 - u8 PressureDown; // digital Pad Down button Pressure 0 - 255 - u8 PressureLeft; // digital Pad Left button Pressure 0 - 255 - u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 - u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 - u8 PressureL1; // digital Pad L1 button Pressure 0 - 255 - u8 PressureR1; // digital Pad R1 button Pressure 0 - 255 - u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255 - u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255 - u8 PressureCross; // digital Pad Cross button Pressure 0 - 255 - u8 PressureSquare; // digital Pad Square button Pressure 0 - 255 - u8 Reserved3[3]; // Unknown - u8 Charge; // charging status ? 02 = charge, 03 = normal - u8 Power; // Battery status ? 05=full - 02=dying, 01=just before shutdown, EE=charging - u8 Connection; // Connection Type ? 14 when operating by bluetooth, 10 when operating by bluetooth with cable plugged in, 16 when bluetooh and rumble - u8 Reserved4[9]; // Unknown - s16 AccelX; - s16 AccelY; - s16 AccelZ; - s16 GyroZ; + union + { + u8 ButtonStateL; // Main buttons Low + struct + { + u8 Select : 1; + u8 L3 : 1; + u8 R3 : 1; + u8 Start : 1; + u8 Up : 1; + u8 Right : 1; + u8 Down : 1; + u8 Left : 1; + }; + }; + union + { + u8 ButtonStateH; // Main buttons High + struct + { + u8 L2 : 1; + u8 R2 : 1; + u8 L1 : 1; + u8 R1 : 1; + u8 Triangle : 1; + u8 Circle : 1; + u8 Cross : 1; + u8 Square : 1; + }; + }; + u8 PSButtonState; // PS button + u8 Reserved1; // Unknown + u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid + u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid + u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid + u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid + u8 Reserved2[4]; // Unknown + u8 PressureUp; // digital Pad Up button Pressure 0 - 255 + u8 PressureRight; // digital Pad Right button Pressure 0 - 255 + u8 PressureDown; // digital Pad Down button Pressure 0 - 255 + u8 PressureLeft; // digital Pad Left button Pressure 0 - 255 + u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 + u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 + u8 PressureL1; // digital Pad L1 button Pressure 0 - 255 + u8 PressureR1; // digital Pad R1 button Pressure 0 - 255 + u8 PressureTriangle; // digital Pad Triangle button Pressure 0 - 255 + u8 PressureCircle; // digital Pad Circle button Pressure 0 - 255 + u8 PressureCross; // digital Pad Cross button Pressure 0 - 255 + u8 PressureSquare; // digital Pad Square button Pressure 0 - 255 + u8 Reserved3[3]; // Unknown + u8 Charge; // charging status ? 02 = charge, 03 = normal + u8 Power; // Battery status ? 05=full - 02=dying, 01=just before shutdown, EE=charging + u8 Connection; // Connection Type ? 14 when operating by bluetooth, 10 when operating by bluetooth with cable plugged in, 16 when bluetooh and rumble + u8 Reserved4[9]; // Unknown + s16 AccelX; + s16 AccelY; + s16 AccelZ; + s16 GyroZ; } __attribute__((packed)); struct ds4report { - u8 ReportID; - u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid - u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid - u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid - u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid - u8 Dpad : 4; // hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW - u8 Square : 1; - u8 Cross : 1; - u8 Circle : 1; - u8 Triangle : 1; - u8 L1 : 1; - u8 R1 : 1; - u8 L2 : 1; - u8 R2 : 1; - u8 Share : 1; - u8 Option : 1; - u8 L3 : 1; - u8 R3 : 1; - u8 PSButton : 1; - u8 TPad : 1; - u8 Counter1 : 6; // counts up by 1 per report - u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 - u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 - u8 Counter2; - u8 Counter3; - u8 Battery; // battery level from 0x00 to 0xff - s16 AccelX; - s16 AccelY; - s16 AccelZ; - s16 GyroZ; - s16 GyroY; - s16 GyroX; - u8 Reserved1[5]; // Unknown - u8 Power : 4; // from 0x0 to 0xA - charging, 0xB - charged - u8 Usb_plugged : 1; - u8 Headphones : 1; - u8 Microphone : 1; - u8 Padding : 1; - u8 Reserved2[2]; // Unknown - u8 TPpack; // number of trackpad packets (0x00 to 0x04) - u8 PackCounter; // packet counter - u8 Finger1ID : 7; // counter - u8 Finger1Active : 1; // 0 - active, 1 - unactive - u16 Finger1X : 12; // finger 1 coordinates resolution 1920x943 - u16 Finger1Y : 12; - u8 Finger2ID : 7; - u8 Finger2Active : 1; - u16 Finger2X : 12; // finger 2 coordinates resolution 1920x943 - u16 Finger2Y : 12; + u8 ReportID; + u8 LeftStickX; // left Joystick X axis 0 - 255, 128 is mid + u8 LeftStickY; // left Joystick Y axis 0 - 255, 128 is mid + u8 RightStickX; // right Joystick X axis 0 - 255, 128 is mid + u8 RightStickY; // right Joystick Y axis 0 - 255, 128 is mid + u8 Dpad : 4; // hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW + u8 Square : 1; + u8 Cross : 1; + u8 Circle : 1; + u8 Triangle : 1; + u8 L1 : 1; + u8 R1 : 1; + u8 L2 : 1; + u8 R2 : 1; + u8 Share : 1; + u8 Option : 1; + u8 L3 : 1; + u8 R3 : 1; + u8 PSButton : 1; + u8 TPad : 1; + u8 Counter1 : 6; // counts up by 1 per report + u8 PressureL2; // digital Pad L2 button Pressure 0 - 255 + u8 PressureR2; // digital Pad R2 button Pressure 0 - 255 + u8 Counter2; + u8 Counter3; + u8 Battery; // battery level from 0x00 to 0xff + s16 AccelX; + s16 AccelY; + s16 AccelZ; + s16 GyroZ; + s16 GyroY; + s16 GyroX; + u8 Reserved1[5]; // Unknown + u8 Power : 4; // from 0x0 to 0xA - charging, 0xB - charged + u8 Usb_plugged : 1; + u8 Headphones : 1; + u8 Microphone : 1; + u8 Padding : 1; + u8 Reserved2[2]; // Unknown + u8 TPpack; // number of trackpad packets (0x00 to 0x04) + u8 PackCounter; // packet counter + u8 Finger1ID : 7; // counter + u8 Finger1Active : 1; // 0 - active, 1 - unactive + u16 Finger1X : 12; // finger 1 coordinates resolution 1920x943 + u16 Finger1Y : 12; + u8 Finger2ID : 7; + u8 Finger2Active : 1; + u16 Finger2X : 12; // finger 2 coordinates resolution 1920x943 + u16 Finger2Y : 12; } __attribute__((packed)); diff --git a/iop/hdl_info/apa.c b/iop/hdl_info/apa.c index 8aabdc97..921c3aff 100644 --- a/iop/hdl_info/apa.c +++ b/iop/hdl_info/apa.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: apa.c +// File name: apa.c //-------------------------------------------------------------- #include #include @@ -22,8 +22,8 @@ typedef struct ps2_partition_run_type u_long size_in_mb; } ps2_partition_run_t; -//Remove this line, and uncomment the next line, to reactivate 'apa_check' -//static int apa_check(const apa_partition_table_t *table); +// Remove this line, and uncomment the next line, to reactivate 'apa_check' +// static int apa_check(const apa_partition_table_t *table); //-------------------------------------------------------------- u_long apa_partition_checksum(const ps2_partition_header_t *part) @@ -36,7 +36,7 @@ u_long apa_partition_checksum(const ps2_partition_header_t *part) return sum; } //------------------------------ -//endfunc apa_partition_checksum +// endfunc apa_partition_checksum //-------------------------------------------------------------- static apa_partition_table_t *apa_ptable_alloc(void) { @@ -46,7 +46,7 @@ static apa_partition_table_t *apa_ptable_alloc(void) return table; } //------------------------------ -//endfunc apa_ptable_alloc +// endfunc apa_ptable_alloc //-------------------------------------------------------------- void apa_ptable_free(apa_partition_table_t *table) { @@ -59,7 +59,7 @@ void apa_ptable_free(apa_partition_table_t *table) } } //------------------------------ -//endfunc apa_ptable_free +// endfunc apa_ptable_free //-------------------------------------------------------------- static int apa_part_add(apa_partition_table_t *table, const ps2_partition_header_t *part, int existing, int linked) { @@ -86,7 +86,7 @@ static int apa_part_add(apa_partition_table_t *table, const ps2_partition_header return 0; } //------------------------------ -//endfunc apa_part_add +// endfunc apa_part_add //-------------------------------------------------------------- /* //Remove this line and a similar one below to reactivate 'apa_setup_statistics' static int apa_setup_statistics(apa_partition_table_t *table) @@ -132,9 +132,10 @@ static int apa_setup_statistics(apa_partition_table_t *table) } else return -2; } -*/ //Remove this line and a similar one below to reactivate 'apa_setup_statistics' +*/ +// Remove this line and a similar one below to reactivate 'apa_setup_statistics' //------------------------------ -//endfunc apa_setup_statistics +// endfunc apa_setup_statistics //-------------------------------------------------------------- int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) { @@ -143,7 +144,7 @@ int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) if (result == 0) { u_long total_sectors; // limit HDD size to 128GB - 1KB; that is: exclude the last 128MB chunk - //if (size_in_kb > 128 * 1024 * 1024 - 1) + // if (size_in_kb > 128 * 1024 * 1024 - 1) // size_in_kb = 128 * 1024 * 1024 - 1; total_sectors = size_in_kb * 2; /* 1KB = 2 sectors of 512 bytes, each */ @@ -173,17 +174,17 @@ int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) result = 1; } /* TODO: check whether next partition is not loaded already -- - * do not deadlock; that is a quick-and-dirty hack */ + * do not deadlock; that is a quick-and-dirty hack */ if ((*table)->part_count > 10000) result = 7; } while (result == 0 && sector != 0); if (result == 0) { (*table)->device_size_in_mb = size_in_kb / 1024; - //NB: uncommenting the next lines requires changes elsewhere too - //result = apa_setup_statistics (*table); - //if (result == 0) - //result = apa_check (*table); + // NB: uncommenting the next lines requires changes elsewhere too + // result = apa_setup_statistics (*table); + // if (result == 0) + // result = apa_check (*table); } if (result != 0) { @@ -196,7 +197,7 @@ int apa_ptable_read_ex(hio_t *hio, apa_partition_table_t **table) return result; } //------------------------------ -//endfunc apa_ptable_read_ex +// endfunc apa_ptable_read_ex //-------------------------------------------------------------- /* //Remove this line and a similar one below to reactivate 'apa_check' static int apa_check (const apa_partition_table_t *table) { @@ -272,9 +273,10 @@ static int apa_check (const apa_partition_table_t *table) { return 0; } -*/ //Remove this line and a similar one above to reactivate 'apa_check' +*/ +// Remove this line and a similar one above to reactivate 'apa_check' //------------------------------ -//endfunc apa_check +// endfunc apa_check //-------------------------------------------------------------- u_long get_u32(const void *buffer) { @@ -285,7 +287,7 @@ u_long get_u32(const void *buffer) (((u_long)p[0]) << 0)); } //------------------------------ -//endfunc get_u32 +// endfunc get_u32 //-------------------------------------------------------------- void set_u32(void *buffer, u_long val) { @@ -296,7 +298,7 @@ void set_u32(void *buffer, u_long val) p[0] = (u_char)(val >> 0); } //------------------------------ -//endfunc set_u32 +// endfunc set_u32 //-------------------------------------------------------------- u_short get_u16(const void *buffer) { @@ -305,7 +307,7 @@ u_short get_u16(const void *buffer) (((u_short)p[0]) << 0)); } //------------------------------ -//endfunc get_u16 +// endfunc get_u16 //-------------------------------------------------------------- void set_u16(void *buffer, u_short val) { @@ -314,7 +316,7 @@ void set_u16(void *buffer, u_short val) p[0] = (u_char)(val >> 0); } //------------------------------ -//endfunc set_u16 +// endfunc set_u16 //-------------------------------------------------------------- -//End of file: apa.c +// End of file: apa.c //-------------------------------------------------------------- diff --git a/iop/hdl_info/hdd.c b/iop/hdl_info/hdd.c index 46b43e84..35c7d050 100644 --- a/iop/hdl_info/hdd.c +++ b/iop/hdl_info/hdd.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: hdd.c +// File name: hdd.c //-------------------------------------------------------------- #include #include @@ -25,7 +25,7 @@ static int iop_stat(hio_t *hio, u_long *size_in_kb) return 0; } //------------------------------ -//endfunc iop_stat +// endfunc iop_stat //-------------------------------------------------------------- static int iop_read(hio_t *hio, u_long start_sector, u_long num_sectors, void *output, u_long *bytes) { @@ -38,7 +38,7 @@ static int iop_read(hio_t *hio, u_long start_sector, u_long num_sectors, void *o return -1; } //------------------------------ -//endfunc iop_read +// endfunc iop_read //-------------------------------------------------------------- static int iop_write(hio_t *hio, u_long start_sector, u_long num_sectors, const void *input, u_long *bytes) { @@ -51,7 +51,7 @@ static int iop_write(hio_t *hio, u_long start_sector, u_long num_sectors, const return -1; } //------------------------------ -//endfunc iop_write +// endfunc iop_write //-------------------------------------------------------------- static int iop_flush(hio_t *hio) { @@ -60,7 +60,7 @@ static int iop_flush(hio_t *hio) return result; } //------------------------------ -//endfunc iop_flush +// endfunc iop_flush //-------------------------------------------------------------- static int iop_close(hio_t *hio) { @@ -68,16 +68,16 @@ static int iop_close(hio_t *hio) return 0; } //------------------------------ -//endfunc iop_close +// endfunc iop_close //-------------------------------------------------------------- static int iop_poweroff(hio_t *hio) -{ //Prerequisites: all files on the HDD must be saved & all partitions unmounted. - dev9Shutdown(); //Power off DEV9 - PoweroffShutdown(); //Power off PlayStation 2 +{ // Prerequisites: all files on the HDD must be saved & all partitions unmounted. + dev9Shutdown(); // Power off DEV9 + PoweroffShutdown(); // Power off PlayStation 2 return 0; } //------------------------------ -//endfunc iop_poweroff +// endfunc iop_poweroff //-------------------------------------------------------------- static hio_t *iop_alloc(int unit, size_t size_in_sectors) { @@ -96,7 +96,7 @@ static hio_t *iop_alloc(int unit, size_t size_in_sectors) return ((hio_t *)iop); } //------------------------------ -//endfunc iop_alloc +// endfunc iop_alloc //-------------------------------------------------------------- int hio_iop_probe(const char *path, hio_t **hio) { @@ -119,7 +119,7 @@ int hio_iop_probe(const char *path, hio_t **hio) return 14; } //------------------------------ -//endfunc hio_iop_probe +// endfunc hio_iop_probe //-------------------------------------------------------------- int HdlGetGameInfo(char *PartName, GameInfo *GameInf) { @@ -142,18 +142,18 @@ int HdlGetGameInfo(char *PartName, GameInfo *GameInf) strcpy(GameInf->Name, game->name); strcpy(GameInf->Startup, game->startup); GameInf->Is_Dvd = game->is_dvd; - return 0; //Return flag for no error + return 0; // Return flag for no error } ++count; } /* for */ - return -3; //Return error flag for 'Game not found' + return -3; // Return error flag for 'Game not found' } /* if */ - return err; //Return error flag for 'hdl_glist_read failed' + return err; // Return error flag for 'hdl_glist_read failed' } /* if */ - return -1; //Return error flag for 'hio_iop_probe failed' + return -1; // Return error flag for 'hio_iop_probe failed' } //------------------------------ -//endfunc HdlGetGameInfo +// endfunc HdlGetGameInfo //-------------------------------------------------------------- int HdlRenameGame(void *Data) @@ -179,20 +179,20 @@ int HdlRenameGame(void *Data) printf("Renaming Game %s To %s.\n", game->name, Packet->NewName); strcpy(game->name, Packet->NewName); if ((err = hdl_glist_write(hio, game)) == 0) - return 0; //Return flag for no error + return 0; // Return flag for no error else - return err; //Return error flag for 'hdl_glist_write failed' + return err; // Return error flag for 'hdl_glist_write failed' } ++count; } /* for */ - return -3; //Return error flag for 'Game not found' + return -3; // Return error flag for 'Game not found' } /* if */ - return err; //Return error flag for 'hdl_glist_read failed' + return err; // Return error flag for 'hdl_glist_read failed' } /* if */ - return -1; //Return error flag for 'hio_iop_probe failed' + return -1; // Return error flag for 'hio_iop_probe failed' } //------------------------------ -//endfunc HdlRenameGame +// endfunc HdlRenameGame //-------------------------------------------------------------- -//End of file: hdd.c +// End of file: hdd.c //-------------------------------------------------------------- diff --git a/iop/hdl_info/hdl.c b/iop/hdl_info/hdl.c index 9ef134a0..7f303793 100644 --- a/iop/hdl_info/hdl.c +++ b/iop/hdl_info/hdl.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: hdl.c +// File name: hdl.c //-------------------------------------------------------------- #include #include @@ -22,14 +22,14 @@ void hdl_glist_free(hdl_games_list_t *glist) } } //------------------------------ -//endfunc hdl_glist_free +// endfunc hdl_glist_free //-------------------------------------------------------------- static int hdl_ginfo_read(hio_t *hio, const ps2_partition_header_t *part, hdl_game_info_t *ginfo) { u_long i, size; /* data we're interested in starts @ 0x101000 and is header - * plus information for up to 65 partitions - * (1 main + 64 sub) by 12 bytes each */ + * plus information for up to 65 partitions + * (1 main + 64 sub) by 12 bytes each */ const u_long offset = 0x101000; char buffer[1024]; int result; @@ -57,7 +57,7 @@ static int hdl_ginfo_read(hio_t *hio, const ps2_partition_header_t *part, hdl_ga return (result); } //------------------------------ -//endfunc hdl_ginfo_read +// endfunc hdl_ginfo_read //-------------------------------------------------------------- int hdl_glist_read(hio_t *hio, hdl_games_list_t **glist) { @@ -98,12 +98,12 @@ int hdl_glist_read(hio_t *hio, hdl_games_list_t **glist) result = -2; apa_ptable_free(ptable); - } else { //apa_ptable_read_ex failed + } else { // apa_ptable_read_ex failed } return result; } //------------------------------ -//endfunc hdl_glist_read +// endfunc hdl_glist_read //-------------------------------------------------------------- static int hdl_ginfo_write(hio_t *hio, const ps2_partition_header_t *part, hdl_game_info_t *ginfo) { @@ -122,7 +122,7 @@ static int hdl_ginfo_write(hio_t *hio, const ps2_partition_header_t *part, hdl_g return result; } //------------------------------ -//endfunc hdl_ginfo_write +// endfunc hdl_ginfo_write //-------------------------------------------------------------- int hdl_glist_write(hio_t *hio, hdl_game_info_t *ginfo) { @@ -172,7 +172,7 @@ int hdl_glist_write(hio_t *hio, hdl_game_info_t *ginfo) return result; } //------------------------------ -//endfunc hdl_glist_write +// endfunc hdl_glist_write //-------------------------------------------------------------- -//End of file: hdl.c +// End of file: hdl.c //-------------------------------------------------------------- diff --git a/iop/hdl_info/main.c b/iop/hdl_info/main.c index d17a25f2..479b8f17 100644 --- a/iop/hdl_info/main.c +++ b/iop/hdl_info/main.c @@ -61,10 +61,10 @@ void rpcMainThread(void *param) void *rpcCommandHandler(int command, void *Data, int Size) { switch (command) { - case 4: //HDL Get Game Info + case 4: // HDL Get Game Info ((int *)Data)[0] = HdlGetGameInfo((char *)Data, (GameInfo *)(Data + 4)); break; - case 5: //HDL Rename Game + case 5: // HDL Rename Game ((int *)Data)[0] = HdlRenameGame((char *)Data); break; default: diff --git a/iop/hdl_info/main.h b/iop/hdl_info/main.h index 78660847..c8f56dbd 100644 --- a/iop/hdl_info/main.h +++ b/iop/hdl_info/main.h @@ -1,3 +1,3 @@ -//Memory allocation helpers +// Memory allocation helpers void *malloc(int size); void free(void *ptr); diff --git a/iop/oldlibs/libcdvd/iop/cdvd_iop.c b/iop/oldlibs/libcdvd/iop/cdvd_iop.c index bec88759..8a85d5e9 100644 --- a/iop/oldlibs/libcdvd/iop/cdvd_iop.c +++ b/iop/oldlibs/libcdvd/iop/cdvd_iop.c @@ -28,7 +28,7 @@ enum PathMatch { #define MAX_DIR_CACHE_SECTORS 32 -//static u8 cdVolDescriptor[2048]; +// static u8 cdVolDescriptor[2048]; static sceCdRMode cdReadMode; int lastsector; @@ -222,8 +222,8 @@ void CDVD_Thread(void *param); /******************** -* Optimised CD Read * -********************/ + * Optimised CD Read * + ********************/ int ReadSect(u32 lsn, u32 sectors, void *buf, sceCdRMode *mode) { @@ -274,8 +274,8 @@ int ReadSect(u32 lsn, u32 sectors, void *buf, sceCdRMode *mode) } /*********************************************** -* Determines if there is a valid disc inserted * -***********************************************/ + * Determines if there is a valid disc inserted * + ***********************************************/ int isValidDisc(void) { int result; @@ -296,10 +296,10 @@ int isValidDisc(void) } /************************************************************* -* The functions below are the normal file-system operations, * -* used to provide a standard filesystem interface. There is * -* no need to export these functions for calling via RPC * -*************************************************************/ + * The functions below are the normal file-system operations, * + * used to provide a standard filesystem interface. There is * + * no need to export these functions for calling via RPC * + *************************************************************/ int dummy() { #ifdef DEBUG @@ -639,10 +639,10 @@ int _start(int argc, char **argv) } /************************************************************** -* The functions below are not exported for normal file-system * -* operations, but are used by the file-system operations, and * -* may also be exported for use via RPC * -**************************************************************/ + * The functions below are not exported for normal file-system * + * operations, but are used by the file-system operations, and * + * may also be exported for use via RPC * + **************************************************************/ int CDVD_GetVolumeDescriptor(void) @@ -820,7 +820,7 @@ int CDVD_findfile(const char *fname, struct TocEntry *tocEntry) CDVD_Cache_Dir(pathname, CACHE_NEXT); } -// we've run out of dir blocks to cache, and still not found it, so fail + // we've run out of dir blocks to cache, and still not found it, so fail #ifdef DEBUG printf("CDVD_findfile: could not find file\n"); @@ -873,8 +873,8 @@ int CDVD_Cache_Dir(const char *pathname, enum Cache_getMode getMode) CachedDirInfo.valid = TRUE; return TRUE; } else { -// Requested cache of start of the directory, but thats not what's cached -// so re-cache the start of the directory + // Requested cache of start of the directory, but thats not what's cached + // so re-cache the start of the directory #ifdef DEBUG printf(" but dir isn't cached from start, so re-cache existing dir from start\n"); @@ -1629,7 +1629,7 @@ void *CDVDRpc_Getdir(unsigned int *sbuff) sbuff[1152 / 4], // CDVD_getMode (struct TocEntry *)sbuff[1156 / 4], // pointer to array of TocEntry structures in EE mem sbuff[1160 / 4] // requested number of entries - ); + ); sbuff[0] = ret; strcpy((char *)&sbuff[1], CachedDirInfo.pathname); @@ -1643,9 +1643,9 @@ void *CDVDRpc_GetSize(unsigned int *sbuff) } /************************************************* -* The functions below are for internal use only, * -* and are not to be exported * -*************************************************/ + * The functions below are for internal use only, * + * and are not to be exported * + *************************************************/ void CDVD_Thread(void *param) { @@ -1777,7 +1777,7 @@ int TocEntryCompare(char *filename, const char *extensions) } // Used in findfile -//int tolower(int c); +// int tolower(int c); int strcasecmp(const char *s1, const char *s2) { while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) { diff --git a/iop/oldlibs/ps2ftpd/src/FileSystem.c b/iop/oldlibs/ps2ftpd/src/FileSystem.c index 8109d98a..63ca38c4 100644 --- a/iop/oldlibs/ps2ftpd/src/FileSystem.c +++ b/iop/oldlibs/ps2ftpd/src/FileSystem.c @@ -274,7 +274,8 @@ int FileSystem_ReadDir(FSContext *pContext, FSFileInfo *pInfo) if (stat(buffer, &s) < 0) return -1; - pInfo->m_eType = S_ISDIR(s.st_mode) ? FT_DIRECTORY : S_ISLNK(s.st_mode) ? FT_LINK : FT_FILE; + pInfo->m_eType = S_ISDIR(s.st_mode) ? FT_DIRECTORY : S_ISLNK(s.st_mode) ? FT_LINK : + FT_FILE; pInfo->m_iSize = s.st_size; t = localtime(&s.st_mtime); @@ -352,11 +353,11 @@ int FileSystem_ReadDir(FSContext *pContext, FSFileInfo *pInfo) printf( "Modified: \t%02i/%02i/%i \t", ent.stat.mtime[5], ent.stat.mtime[4], (ent.stat.mtime[7] << 8) + ent.stat.mtime[6] ); printf( "%02i:%02i:%02i\n", ent.stat.mtime[3], ent.stat.mtime[2], ent.stat.mtime[1] ); if( !strcmp(pContext->m_kFile.device->name, "mass") ) - printf( "Accessed: \t%02i/%02i/%i\n", ent.stat.atime[5], ent.stat.atime[4], (ent.stat.atime[7] << 8) + ent.stat.atime[6] ); + printf( "Accessed: \t%02i/%02i/%i\n", ent.stat.atime[5], ent.stat.atime[4], (ent.stat.atime[7] << 8) + ent.stat.atime[6] ); else if( strcmp(pContext->m_kFile.device->name, "mc") ) { - printf( "Accessed: \t%02i/%02i/%i \t", ent.stat.atime[5], ent.stat.atime[4], (ent.stat.atime[7] << 8) + ent.stat.atime[6] ); - printf( "%02i:%02i:%02i\n", ent.stat.atime[3], ent.stat.atime[2], ent.stat.atime[1] ); + printf( "Accessed: \t%02i/%02i/%i \t", ent.stat.atime[5], ent.stat.atime[4], (ent.stat.atime[7] << 8) + ent.stat.atime[6] ); + printf( "%02i:%02i:%02i\n", ent.stat.atime[3], ent.stat.atime[2], ent.stat.atime[1] ); } printf( "System time: \t%02i/%02i/%i \t", tm.month, tm.day, tm.year ); printf( "%02i:%02i:%02i (%i days between)\n\n", tm.hour, tm.min, tm.sec, pInfo->m_iDaysBetween ); diff --git a/iop/oldlibs/ps2ftpd/src/FtpClient.c b/iop/oldlibs/ps2ftpd/src/FtpClient.c index 0912668d..f17437d5 100644 --- a/iop/oldlibs/ps2ftpd/src/FtpClient.c +++ b/iop/oldlibs/ps2ftpd/src/FtpClient.c @@ -286,7 +286,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) FtpClient_OnCmdList(pClient, "", 1); } break; - // these all share the same setup + // these all share the same setup case FTPCMD_TYPE: case FTPCMD_RETR: @@ -358,7 +358,7 @@ void FtpClient_OnCommand(FtpClient *pClient, const char *pString) } else FtpClient_Send(pClient, 501, pClient->m_pMessages[FTPMSG_REQUIRES_PARAMETERS]); } break; - // TYPE + // TYPE case FTPCMD_PWD: case FTPCMD_XPWD: { @@ -432,8 +432,8 @@ void FtpClient_OnDataConnect(FtpClient *pClient, int *ip, int port) if( fcntl( s, F_SETFL, O_NONBLOCK ) < 0 ) { - FtpClient_OnDataFailed(pClient,NULL); - return; + FtpClient_OnDataFailed(pClient,NULL); + return; } */ @@ -580,7 +580,8 @@ void FtpClient_OnDataWrite(FtpClient *pClient) char size[21] = " "; /* UNIX-style LIST format */ - strcat(buffer, (FT_DIRECTORY == pInfo->m_eType) ? "d" : (FT_LINK == pInfo->m_eType) ? "l" : "-"); + strcat(buffer, (FT_DIRECTORY == pInfo->m_eType) ? "d" : (FT_LINK == pInfo->m_eType) ? "l" : + "-"); for (i = 0; i < 9; i++) { if (pInfo->m_iProtection & (1 << (8 - i))) { switch (i % 3) { @@ -671,52 +672,52 @@ void FtpClient_OnDataWrite(FtpClient *pClient) } // end of UNIX-style LIST format - /* MS-style LIST format: To use uncomment this format after commenting out UNIX-style LIST format - and making changes to FtpCommands.c's method FtpClient_OnCmdSyst + /* MS-style LIST format: To use uncomment this format after commenting out UNIX-style LIST format + and making changes to FtpCommands.c's method FtpClient_OnCmdSyst i = pInfo->m_TS.m_iMonth; if( i > 12 ) - i = 1; + i = 1; if( i < 10 ) - strcat( buffer, "0" ); + strcat( buffer, "0" ); itoa( buffer + strlen(buffer), i ); strcat( buffer, "-" ); if( pInfo->m_TS.m_iDay < 10 ) - strcat( buffer, "0" ); + strcat( buffer, "0" ); itoa( buffer + strlen(buffer), pInfo->m_TS.m_iDay ); strcat( buffer, "-" ); if( pInfo->m_TS.m_iYear%100 < 10 ) - strcat( buffer, "0" ); + strcat( buffer, "0" ); itoa( buffer + strlen(buffer), pInfo->m_TS.m_iYear%100 ); strcat( buffer, " " ); i = pInfo->m_TS.m_iHour; if( i > 12 ) - i -= 12; + i -= 12; if( i == 0 ) - i = 12; + i = 12; if( i < 10 ) - strcat( buffer, "0" ); + strcat( buffer, "0" ); itoa( buffer + strlen(buffer), i ); strcat( buffer, ":" ); if( pInfo->m_TS.m_iMinute < 10 ) - strcat( buffer, "0" ); + strcat( buffer, "0" ); itoa( buffer + strlen(buffer), pInfo->m_TS.m_iMinute ); if( pInfo->m_TS.m_iHour < 12 ) - strcat( buffer, "AM " ); + strcat( buffer, "AM " ); else - strcat( buffer, "PM " ); + strcat( buffer, "PM " ); if( FT_DIRECTORY == pInfo->m_eType ) - strcat( buffer, " " ); + strcat( buffer, " " ); else { - uitoa( size, pInfo->m_iSize ); - for( i = 0; (i < 14 - strlen(size)) && (strlen(size) < 15); i++ ) - strcat( buffer, " " ); - strcat( buffer, size ); + uitoa( size, pInfo->m_iSize ); + for( i = 0; (i < 14 - strlen(size)) && (strlen(size) < 15); i++ ) + strcat( buffer, " " ); + strcat( buffer, size ); } strcat( buffer, " " ); */ diff --git a/iop/oldlibs/ps2ftpd/src/FtpClient.h b/iop/oldlibs/ps2ftpd/src/FtpClient.h index 83b9c827..1908adfc 100644 --- a/iop/oldlibs/ps2ftpd/src/FtpClient.h +++ b/iop/oldlibs/ps2ftpd/src/FtpClient.h @@ -86,9 +86,9 @@ enum { // possible commands, we'll implement them if it become necessary - //FTPCMD_FEAT = FCOMMAND('f','e','a','t'), - //FTPCMD_STAT = FCOMMAND('s','t','a','t'), - //FTPCMD_HELP = FCOMMAND('h','e','l','p'), + // FTPCMD_FEAT = FCOMMAND('f','e','a','t'), + // FTPCMD_STAT = FCOMMAND('s','t','a','t'), + // FTPCMD_HELP = FCOMMAND('h','e','l','p'), }; enum { diff --git a/iop/oldlibs/ps2ftpd/src/FtpCommands.c b/iop/oldlibs/ps2ftpd/src/FtpCommands.c index 6f95f8f3..1e838585 100644 --- a/iop/oldlibs/ps2ftpd/src/FtpCommands.c +++ b/iop/oldlibs/ps2ftpd/src/FtpCommands.c @@ -166,8 +166,8 @@ void FtpClient_OnCmdPasv(FtpClient *pClient) strcat(buf, ")."); /* sprintf( buffer, "Entering passive mode (%d,%d,%d,%d,%d,%d).", - (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff, - port>>8,port&0xff ); + (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8)&0xff, addr&0xff, + port>>8,port&0xff ); */ FtpClient_Send(pClient, 227, buffer); @@ -201,8 +201,8 @@ void FtpClient_OnCmdSyst(FtpClient *pClient) /* UNIX-style LIST format */ FtpClient_Send(pClient, 215, "UNIX Type: L8"); - /* MS-style LIST format: To use uncomment this format after commenting out UNIX-style LIST format - and making changes in FtpClient.c's FtpClient_OnDataWrite + /* MS-style LIST format: To use uncomment this format after commenting out UNIX-style LIST format + and making changes in FtpClient.c's FtpClient_OnDataWrite FtpClient_Send( pClient, 215, "Windows_NT version 5.0" ); */ } diff --git a/iop/oldlibs/ps2ftpd/src/FtpServer.c b/iop/oldlibs/ps2ftpd/src/FtpServer.c index 9c7b593f..57069f90 100644 --- a/iop/oldlibs/ps2ftpd/src/FtpServer.c +++ b/iop/oldlibs/ps2ftpd/src/FtpServer.c @@ -81,12 +81,12 @@ int FtpServer_Start(FtpServer *pServer) // make a few settings /* SP193: Is this necessary? If it is, a custom build of LWIP is required (SO_REUSE is disabled by default at compile-time) - opt = 1; - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { - disconnect(s); - printf("ps2ftpd: Could not change socket options.\n"); - return -1; - } */ + opt = 1; + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { + disconnect(s); + printf("ps2ftpd: Could not change socket options.\n"); + return -1; + } */ // try to bind socket @@ -248,7 +248,7 @@ int FtpServer_HandleEvents(FtpServer *pServer) pClient->m_CommandBuffer[cmdlen] = '\0'; -// execute command + // execute command #ifdef DEBUG printf("%08x << %s\r\n", (unsigned int)pClient, pClient->m_CommandBuffer); diff --git a/iop/ps2host/hostlink.h b/iop/ps2host/hostlink.h index 2f5a0e6c..9c839476 100644 --- a/iop/ps2host/hostlink.h +++ b/iop/ps2host/hostlink.h @@ -33,8 +33,8 @@ #define PKO_RMDIR_CMD 0xbabe01B1 #define PKO_RMDIR_RLY 0xbabe01B2 -#define PKO_IOCTL_CMD 0xbabe01C1 //dlanor: Added for Rename capability -#define PKO_IOCTL_RLY 0xbabe01C2 //dlanor: Added for Rename capability +#define PKO_IOCTL_CMD 0xbabe01C1 // dlanor: Added for Rename capability +#define PKO_IOCTL_RLY 0xbabe01C2 // dlanor: Added for Rename capability #define PKO_RESET_CMD 0xbabe0201 #define PKO_EXECIOP_CMD 0xbabe0202 diff --git a/iop/ps2host/net_fsys.c b/iop/ps2host/net_fsys.c index 4f891022..f6ab0a5b 100644 --- a/iop/ps2host/net_fsys.c +++ b/iop/ps2host/net_fsys.c @@ -17,7 +17,7 @@ #include "net_fio.h" -#define IOCTL_RENAME 0xFEEDC0DE //dlanor: Used for the Ioctl request code => Rename +#define IOCTL_RENAME 0xFEEDC0DE // dlanor: Used for the Ioctl request code => Rename #ifdef DEBUG #define dbgprintf(args...) printf(args) @@ -41,11 +41,11 @@ struct filedesc_info int device_id; // the X in hostX int own_fd; }; -//dlanor: In fact this struct is declared elsewhere as iop_file_t, with -//dlanor: well known fields. The one declared as "int own_fd;" above is -//dlanor: there declared as "void *privdata;" but it doesn't matter, as -//dlanor: it is up to each driver how to use that field. So using it as -//dlanor: a simple "int" instead of a pointer will work fine. +// dlanor: In fact this struct is declared elsewhere as iop_file_t, with +// dlanor: well known fields. The one declared as "int own_fd;" above is +// dlanor: there declared as "void *privdata;" but it doesn't matter, as +// dlanor: it is up to each driver how to use that field. So using it as +// dlanor: a simple "int" instead of a pointer will work fine. //---------------------------------------------------------------------------- @@ -56,18 +56,18 @@ static int fsys_sema; static int fsys_pid = 0; //---------------------------------------------------------------------------- -//dlanor: We need variables to remember a file/folder descriptor used -//dlanor: with the Ioctl Rename function, so that we can avoid passing -//dlanor: the following fioClose call to PC, where it's already closed. -//dlanor: We also need a flag to note when we must ignore an Mkdir call -//dlanor: because it is caused by the bug IOMAN.IRX has for fioRemove. +// dlanor: We need variables to remember a file/folder descriptor used +// dlanor: with the Ioctl Rename function, so that we can avoid passing +// dlanor: the following fioClose call to PC, where it's already closed. +// dlanor: We also need a flag to note when we must ignore an Mkdir call +// dlanor: because it is caused by the bug IOMAN.IRX has for fioRemove. // -int lastopen_fd; //descriptor of the most recently opened file/folder -int renamed_fd; //descriptor of renamed file/folder awaiting closure -int remove_flag = 0; //Set in fsysRemove, cleared by all other fsysXXXXX -int remove_result; //Set in fsysRemove, so fsysMkdir can use it for bug +int lastopen_fd; // descriptor of the most recently opened file/folder +int renamed_fd; // descriptor of renamed file/folder awaiting closure +int remove_flag = 0; // Set in fsysRemove, cleared by all other fsysXXXXX +int remove_result; // Set in fsysRemove, so fsysMkdir can use it for bug -typedef void (*th_func_p)(void *); //dlanor: added to suppress warnings +typedef void (*th_func_p)(void *); // dlanor: added to suppress warnings //---------------------------------------------------------------------------- static void fsysInit(iop_device_t *driver) @@ -392,21 +392,21 @@ static int dummyChstat() iop_device_ops_t fsys_functarray = {(void *)fsysInit, (void *)fsysDestroy, - (void *)dummyFormat, //init, deinit, format + (void *)dummyFormat, // init, deinit, format (void *)fsysOpen, (void *)fsysClose, - (void *)fsysRead, //open, close, read, + (void *)fsysRead, // open, close, read, (void *)fsysWrite, (void *)fsysLseek, - (void *)fsysIoctl, //write, lseek, ioctl + (void *)fsysIoctl, // write, lseek, ioctl (void *)fsysRemove, (void *)fsysMkdir, - (void *)fsysRmdir, //remove, mkdir, rmdir + (void *)fsysRmdir, // remove, mkdir, rmdir (void *)fsysDopen, (void *)fsysDclose, - (void *)fsysDread, //dopen, dclose, dread + (void *)fsysDread, // dopen, dclose, dread (void *)dummyGetstat, - (void *)dummyChstat}; //getstat, chstat + (void *)dummyChstat}; // getstat, chstat iop_device_t fsys_driver = {fsname, 16, 1, "fsys driver", &fsys_functarray}; @@ -435,5 +435,5 @@ int fsysUnmount(void) return 0; } //---------------------------------------------------------------------------- -//End of file: net_fsys.c +// End of file: net_fsys.c //---------------------------------------------------------------------------- diff --git a/iop/vmc_fs/vmc.h b/iop/vmc_fs/vmc.h index 0e434c83..198d27a2 100644 --- a/iop/vmc_fs/vmc.h +++ b/iop/vmc_fs/vmc.h @@ -15,7 +15,7 @@ // The debugging functions, very very handy #ifdef DEBUG #define DEBUGPRINT(level, fmt, args...) \ - if (DEBUG >= level) \ + if (DEBUG >= level) \ printf(MODNAME ": " fmt, ##args) #else #define DEBUGPRINT(args...) @@ -98,15 +98,15 @@ typedef enum { #ifdef PROFILING void profilerStart(iop_sys_clock_t *iopclock); void profilerEnd(const char *function, const char *name, iop_sys_clock_t *iopclock1); -//This creates 2 variables with the names name1/name2, and starts the profiler +// This creates 2 variables with the names name1/name2, and starts the profiler #define PROF_START(name) \ iop_sys_clock_t name; \ profilerStart(&name); -//this takes the 2 variable names and ends the profiler, printing the time taken +// this takes the 2 variable names and ends the profiler, printing the time taken #define PROF_END(name) \ profilerEnd(__func__, #name, &name); #else -//define away the profiler functions +// define away the profiler functions #define PROF_START(args) ; #define PROF_END(args) ; #endif diff --git a/iop/vmc_fs/vmc_io.c b/iop/vmc_fs/vmc_io.c index a58c30fe..097fe3f2 100644 --- a/iop/vmc_fs/vmc_io.c +++ b/iop/vmc_fs/vmc_io.c @@ -1720,7 +1720,7 @@ int Vmc_Mount(iop_file_t *f, const char *fsname, const char *devname, int flag, goto mountAbort; } - //Reaching this point means we have a valid PS2 image + // Reaching this point means we have a valid PS2 image DEBUGPRINT(4, " Image file Info: Vmc card type : %s MemoryCard.\n", (g_Vmc_Image[f->unit].header.mc_type == PSX_MEMORYCARD ? "PSX" : (g_Vmc_Image[f->unit].header.mc_type == PS2_MEMORYCARD ? "PS2" : "PDA"))); g_Vmc_Image[f->unit].total_pages = g_Vmc_Image[f->unit].header.pages_per_cluster * g_Vmc_Image[f->unit].header.clusters_per_card; diff --git a/iop/vmc_fs/vmc_misc.c b/iop/vmc_fs/vmc_misc.c index 30cfceec..4a795835 100644 --- a/iop/vmc_fs/vmc_misc.c +++ b/iop/vmc_fs/vmc_misc.c @@ -553,6 +553,7 @@ int getPs2Time(vmc_datetime *tm) //---------------------------------------------------------------------------- // XOR table use for Error Correcting Code ( ECC ) calculation. //---------------------------------------------------------------------------- +// clang-format off const unsigned char ECC_XOR_Table[256] = { 0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00, @@ -587,7 +588,7 @@ const unsigned char ECC_XOR_Table[256] = { 0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00, }; - +// clang-format on //---------------------------------------------------------------------------- // Calculate ECC for a 128 bytes chunk of data diff --git a/loader/loader.c b/loader/loader.c index c52aacb3..d0a557f1 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -1,11 +1,11 @@ //-------------------------------------------------------------- -//File name: loader.c +// File name: loader.c //-------------------------------------------------------------- -//dlanor: This subprogram has been modified to minimize the code -//dlanor: size of the resident loader portion. Some of the parts -//dlanor: that were moved into the main program include loading -//dlanor: of all IRXs and mounting pfs0: for ELFs on hdd. -//dlanor: Another change was to skip threading in favor of ExecPS2 +// dlanor: This subprogram has been modified to minimize the code +// dlanor: size of the resident loader portion. Some of the parts +// dlanor: that were moved into the main program include loading +// dlanor: of all IRXs and mounting pfs0: for ELFs on hdd. +// dlanor: Another change was to skip threading in favor of ExecPS2 /*================================================================== == == == Copyright(c)2004 Adam Metcalf(gamblore_@hotmail.com) == @@ -37,9 +37,9 @@ //-------------------------------------------------------------- //-------------------------------------------------------------- -//End of data declarations +// End of data declarations //-------------------------------------------------------------- -//Start of function code: +// Start of function code: //-------------------------------------------------------------- // Clear user memory // PS2Link (C) 2003 Tord Lindstrom (pukko@home.se) @@ -58,7 +58,7 @@ static void wipeUserMem(void) } //-------------------------------------------------------------- -//End of func: void wipeUserMem(void) +// End of func: void wipeUserMem(void) //-------------------------------------------------------------- // *** MAIN *** //-------------------------------------------------------------- @@ -81,19 +81,19 @@ int main(int argc, char *argv[]) target = argv[0]; path = argv[1]; - //Writeback data cache before loading ELF. + // Writeback data cache before loading ELF. FlushCache(0); ret = SifLoadElf(target, &elfdata); if (ret == 0) { args[0] = path; if (strncmp(path, "hdd", 3) == 0 && (path[3] >= '0' && path[3] <= ':')) { /* Final IOP reset, to fill the IOP with the default modules. - It appears that it was once a thing for the booting software to leave the IOP with the required IOP modules. - This can be seen in OSDSYS v1.0x (no IOP reboot) and the mechanism to boot DVD player updates (OSDSYS will get LoadExecPS2 to load SIO2 modules). - However, it changed with the introduction of the HDD unit, as the software booted may be built with a different SDK revision. + It appears that it was once a thing for the booting software to leave the IOP with the required IOP modules. + This can be seen in OSDSYS v1.0x (no IOP reboot) and the mechanism to boot DVD player updates (OSDSYS will get LoadExecPS2 to load SIO2 modules). + However, it changed with the introduction of the HDD unit, as the software booted may be built with a different SDK revision. - Reboot the IOP, to leave it in a clean & consistent state. - But do not do that for boot targets on other devices, for backward-compatibility with older (homebrew) software. */ + Reboot the IOP, to leave it in a clean & consistent state. + But do not do that for boot targets on other devices, for backward-compatibility with older (homebrew) software. */ while (!SifIopReset("", 0)) { }; while (!SifIopSync()) { @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) } } //-------------------------------------------------------------- -//End of func: int main(int argc, char *argv[]) +// End of func: int main(int argc, char *argv[]) //-------------------------------------------------------------- -//End of file: loader.c +// End of file: loader.c //-------------------------------------------------------------- diff --git a/src/SMB_test.c b/src/SMB_test.c index 98db6f66..757decfd 100644 --- a/src/SMB_test.c +++ b/src/SMB_test.c @@ -1,14 +1,14 @@ //--------------------------------------------------------------------------- -//File name: SMB_test.c +// File name: SMB_test.c //--------------------------------------------------------------------------- -smbServerList_t smbServerList[SERVERLIST_MAX]; //List of active servers +smbServerList_t smbServerList[SERVERLIST_MAX]; // List of active servers -int smbServerListCount = 0; //Count of valid server entries in ServerList -int smbCurrentServer = -1; //Index of server for current traffic (-1 if none) +int smbServerListCount = 0; // Count of valid server entries in ServerList +int smbCurrentServer = -1; // Index of server for current traffic (-1 if none) //--------------------------------------------------------------------------- -//Function to log on to an index selected server +// Function to log on to an index selected server //------------------------------ int smbLogon_Server(int Index) { @@ -22,23 +22,23 @@ int smbLogon_Server(int Index) return -1; } - if (smbServerList[Index].Username[0] == 0) //if Username invalid + if (smbServerList[Index].Username[0] == 0) // if Username invalid strcpy(smbServerList[Index].Username, "GUEST"); - if ((smbServerList[Index].PasswordType > 0) //if hashing wanted + if ((smbServerList[Index].PasswordType > 0) // if hashing wanted && (smbServerList[Index].PassHash_f == 0)) { ret = fileXioDevctl("smb:", SMB_DEVCTL_GETPASSWORDHASHES, (void *)&smbServerList[Index].Password, sizeof(smbServerList[Index].Password), (void *)&smbServerList[Index].PassHash, sizeof(smbServerList[Index].PassHash)); if (ret) { DPRINTF("smbLogon_Server: PassHash error %d\n", ret); return -1; } - smbServerList[Index].PassHash_f = 1; //PassHash is now valid for future use + smbServerList[Index].PassHash_f = 1; // PassHash is now valid for future use } strcpy(logon.serverIP, smbServerList[Index].Server_IP); logon.serverPort = smbServerList[Index].Server_Port; strcpy(logon.User, smbServerList[Index].Username); - if (smbServerList[Index].PasswordType > 0) //if hashing wanted + if (smbServerList[Index].PasswordType > 0) // if hashing wanted memcpy((void *)logon.Password, (void *)smbServerList[Index].PassHash, sizeof(smbServerList[Index].PassHash)); else strcpy(logon.Password, smbServerList[Index].Password); @@ -51,28 +51,28 @@ int smbLogon_Server(int Index) } smbServerList[Index].Server_Logon_f = 1; DPRINTF("smbLogon_Server: Logon succeeded!\n"); - return 0; //Here basic Logon has been achieved + return 0; // Here basic Logon has been achieved } //------------------------------ -//endfunc smbLogon_CurrentServer +// endfunc smbLogon_CurrentServer //--------------------------------------------------------------------------- -//Function to log on to a currently selected SMB server +// Function to log on to a currently selected SMB server //------------------------------ int smbLogon_CurrentServer() { return smbLogon_Server(smbCurrentServer); } //------------------------------ -//endfunc smbLogon_CurrentServer +// endfunc smbLogon_CurrentServer //--------------------------------------------------------------------------- -//storeSMBCNF will save SMB specific settings to a pre-allocated RAM area +// storeSMBCNF will save SMB specific settings to a pre-allocated RAM area //------------------------------ size_t storeSMBCNF(char *cnf_buf) { size_t CNF_size, size_step; int i; - for (CNF_size = 0, i = 0; i < smbServerListCount; i++) { //loop for each SMB server in the list + for (CNF_size = 0, i = 0; i < smbServerListCount; i++) { // loop for each SMB server in the list sprintf(cnf_buf + CNF_size, "smbIndex = %d\r\n" "smbServer_IP = %s\r\n" @@ -84,7 +84,7 @@ size_t storeSMBCNF(char *cnf_buf) "smbServer_ID = %s\r\n" "smbServer_FBID = %s\r\n" "%n", // %n causes NO output, but only a measurement - i, //smbIndex + i, // smbIndex smbServerList[i].Server_IP, smbServerList[i].Server_Port, smbServerList[i].Username, @@ -94,40 +94,40 @@ size_t storeSMBCNF(char *cnf_buf) smbServerList[i].Server_ID, smbServerList[i].Server_FBID, &size_step // This measures the size of sprintf data - ); + ); CNF_size += size_step; } return CNF_size; } //------------------------------ -//endfunc storeSMBCNF +// endfunc storeSMBCNF //--------------------------------------------------------------------------- -//saveSMBCNF will save SMB specific settings to an SMB CNF file +// saveSMBCNF will save SMB specific settings to an SMB CNF file //------------------------------ int saveSMBCNF(char *CNFpath) { int ret, fd; - char tmp[SERVERLIST_MAX * 1500]; //Must have room for entire SMB CNF file + char tmp[SERVERLIST_MAX * 1500]; // Must have room for entire SMB CNF file char cnf_path[MAX_PATH]; size_t CNF_size; CNF_size = storeSMBCNF(tmp); - ret = genFixPath(CNFpath, cnf_path); //Fix raw path argument + ret = genFixPath(CNFpath, cnf_path); // Fix raw path argument if ((ret < 0) || ((fd = genOpen(cnf_path, O_CREAT | O_WRONLY | O_TRUNC)) < 0)) { - return -1; //Failed open + return -1; // Failed open } ret = genWrite(fd, &tmp, CNF_size); if (ret != CNF_size) - ret = -2; //Failed writing + ret = -2; // Failed writing genClose(fd); return ret; } //----------------------------- -//endfunc saveSMBCNF +// endfunc saveSMBCNF //--------------------------------------------------------------------------- -//scanSMBCNF will check for SMB specific variables of an SMB CNF in RAM +// scanSMBCNF will check for SMB specific variables of an SMB CNF in RAM //------------------------------ int scanSMBCNF(unsigned char *name, unsigned char *value) { @@ -161,13 +161,13 @@ int scanSMBCNF(unsigned char *name, unsigned char *value) else if (!strcmp(name, "smbServer_FBID")) strcpy(smbServerList[smbCurrentServer].Server_FBID, value); else - return 0; //when no SMB variable - return 1; //when SMB variable found + return 0; // when no SMB variable + return 1; // when SMB variable found } //------------------------------ -//endfunc scanSMBCNF +// endfunc scanSMBCNF //--------------------------------------------------------------------------- -//loadSMBCNF will load SMB specific settings from an SMB CNF file +// loadSMBCNF will load SMB specific settings from an SMB CNF file //------------------------------ int loadSMBCNF(char *path) { @@ -183,7 +183,7 @@ int loadSMBCNF(char *path) return 0; } //------------------------------ -//endfunc loadSMBCNF +// endfunc loadSMBCNF //--------------------------------------------------------------------------- // End of file //--------------------------------------------------------------------------- diff --git a/src/chkesr.c b/src/chkesr.c index cb9d3091..a53b244d 100644 --- a/src/chkesr.c +++ b/src/chkesr.c @@ -1,26 +1,26 @@ -/* - _____ ___ ____ +/* + _____ ___ ____ ____| | ____| PS2 Open Source Project - | ___| |____ - + | ___| |____ + --------------------------------------------------------------------------- - Copyright (C) 2008 - Neme & jimmikaelkael (www.psx-scene.com) + Copyright (C) 2008 - Neme & jimmikaelkael (www.psx-scene.com) This program is free software; you can redistribute it and/or modify it under the terms of the Free McBoot License. - - This program and any related documentation is provided "as is" - WITHOUT ANY WARRANTIES, either express or implied, including, but not - limited to, implied warranties of fitness for a particular purpose. The - entire risk arising out of use or performance of the software remains - with you. - In no event shall the author be liable for any damages whatsoever - (including, without limitation, damages to your hardware or equipment, - environmental damage, loss of health, or any kind of pecuniary loss) - arising out of the use of or inability to use this software or - documentation, even if the author has been advised of the possibility of - such damages. + + This program and any related documentation is provided "as is" + WITHOUT ANY WARRANTIES, either express or implied, including, but not + limited to, implied warranties of fitness for a particular purpose. The + entire risk arising out of use or performance of the software remains + with you. + In no event shall the author be liable for any damages whatsoever + (including, without limitation, damages to your hardware or equipment, + environmental damage, loss of health, or any kind of pecuniary loss) + arising out of the use of or inability to use this software or + documentation, even if the author has been advised of the possibility of + such damages. You should have received a copy of the Free McBoot License along with this program; if not, please report at psx-scene : diff --git a/src/config.c b/src/config.c index 6658b6ce..745e3081 100644 --- a/src/config.c +++ b/src/config.c @@ -8,28 +8,28 @@ enum { DEF_TIMEOUT = 10, DEF_HIDE_PATHS = TRUE, #ifdef CUSTOM_COLORS - DEF_COLOR1 = GS_SETREG_RGBA(0, 0, 0, 0), //Backgr - DEF_COLOR2 = GS_SETREG_RGBA(160, 160, 160, 0), //Frame + DEF_COLOR1 = GS_SETREG_RGBA(0, 0, 0, 0), // Backgr + DEF_COLOR2 = GS_SETREG_RGBA(160, 160, 160, 0), // Frame #ifdef DVRP DEF_COLOR3 = GS_SETREG_RGBA(0x7a, 0, 0xbe, 0), #else - DEF_COLOR3 = GS_SETREG_RGBA(0, 204, 255, 0), //Select + DEF_COLOR3 = GS_SETREG_RGBA(0, 204, 255, 0), // Select #endif - DEF_COLOR4 = GS_SETREG_RGBA(255, 255, 255, 0), //Text - DEF_COLOR5 = GS_SETREG_RGBA(255, 255, 0, 0), //Graph1 - DEF_COLOR6 = GS_SETREG_RGBA(0, 255, 0, 0), //Graph2 - DEF_COLOR7 = GS_SETREG_RGBA(64, 64, 64, 0), //Graph3 - DEF_COLOR8 = GS_SETREG_RGBA(128, 128, 128, 0), //Graph4 + DEF_COLOR4 = GS_SETREG_RGBA(255, 255, 255, 0), // Text + DEF_COLOR5 = GS_SETREG_RGBA(255, 255, 0, 0), // Graph1 + DEF_COLOR6 = GS_SETREG_RGBA(0, 255, 0, 0), // Graph2 + DEF_COLOR7 = GS_SETREG_RGBA(64, 64, 64, 0), // Graph3 + DEF_COLOR8 = GS_SETREG_RGBA(128, 128, 128, 0), // Graph4 #else - DEF_COLOR1 = GS_SETREG_RGBA(128, 128, 128, 0), //Backgr - DEF_COLOR2 = GS_SETREG_RGBA(64, 64, 64, 0), //Frame - DEF_COLOR3 = GS_SETREG_RGBA(96, 0, 0, 0), //Select - DEF_COLOR4 = GS_SETREG_RGBA(0, 0, 0, 0), //Text - DEF_COLOR5 = GS_SETREG_RGBA(96, 96, 0, 0), //Graph1 - DEF_COLOR6 = GS_SETREG_RGBA(0, 96, 0, 0), //Graph2 - DEF_COLOR7 = GS_SETREG_RGBA(224, 224, 224, 0), //Graph3 - DEF_COLOR8 = GS_SETREG_RGBA(0, 0, 0, 0), //Graph4 -#endif //CUSTOM_COLORS + DEF_COLOR1 = GS_SETREG_RGBA(128, 128, 128, 0), // Backgr + DEF_COLOR2 = GS_SETREG_RGBA(64, 64, 64, 0), // Frame + DEF_COLOR3 = GS_SETREG_RGBA(96, 0, 0, 0), // Select + DEF_COLOR4 = GS_SETREG_RGBA(0, 0, 0, 0), // Text + DEF_COLOR5 = GS_SETREG_RGBA(96, 96, 0, 0), // Graph1 + DEF_COLOR6 = GS_SETREG_RGBA(0, 96, 0, 0), // Graph2 + DEF_COLOR7 = GS_SETREG_RGBA(224, 224, 224, 0), // Graph3 + DEF_COLOR8 = GS_SETREG_RGBA(0, 0, 0, 0), // Graph4 +#endif // CUSTOM_COLORS DEF_MENU_FRAME = TRUE, DEF_MENU = TRUE, DEF_NUMCNF = 1, @@ -63,9 +63,9 @@ static const char LK_ID[SETTING_LK_COUNT][10] = { "L3", "R3", "Start", - "Select", //Predefined for "CONFIG" - "Left", //Predefined for "LOAD CONFIG--" - "Right", //Predefined for "LOAD CONFIG++" + "Select", // Predefined for "CONFIG" + "Left", // Predefined for "LOAD CONFIG--" + "Right", // Predefined for "LOAD CONFIG++" "ESR", "OSDSYS"}; @@ -88,47 +88,47 @@ int get_CNF_string(char **CNF_p_p, start_line: while ((*tp <= ' ') && (*tp > '\0')) - tp += 1; //Skip leading whitespace, if any + tp += 1; // Skip leading whitespace, if any if (*tp == '\0') - return false; //but exit at EOF - np = tp; //Current pos is potential name - if (*tp < 'A') //but may be a comment line - { //We must skip a comment line + return false; // but exit at EOF + np = tp; // Current pos is potential name + if (*tp < 'A') // but may be a comment line + { // We must skip a comment line while ((*tp != '\r') && (*tp != '\n') && (*tp > '\0')) - tp += 1; //Seek line end - goto start_line; //Go back to try next line + tp += 1; // Seek line end + goto start_line; // Go back to try next line } while ((*tp >= 'A') || ((*tp >= '0') && (*tp <= '9'))) - tp += 1; //Seek name end + tp += 1; // Seek name end if (*tp == '\0') - return false; //but exit at EOF + return false; // but exit at EOF while ((*tp <= ' ') && (*tp > '\0')) - *tp++ = '\0'; //zero&skip post-name whitespace + *tp++ = '\0'; // zero&skip post-name whitespace if (*tp != '=') - return false; //exit (syntax error) if '=' missing - *tp++ = '\0'; //zero '=' (possibly terminating name) + return false; // exit (syntax error) if '=' missing + *tp++ = '\0'; // zero '=' (possibly terminating name) - while ((*tp <= ' ') && (*tp > '\0') //Skip pre-value whitespace, if any + while ((*tp <= ' ') && (*tp > '\0') // Skip pre-value whitespace, if any && (*tp != '\r') && (*tp != '\n')) - tp += 1; //but do not pass the end of the line + tp += 1; // but do not pass the end of the line if (*tp == '\0') - return false; //but exit at EOF - vp = tp; //Current pos is potential value + return false; // but exit at EOF + vp = tp; // Current pos is potential value while ((*tp != '\r') && (*tp != '\n') && (*tp != '\0')) - tp += 1; //Seek line end + tp += 1; // Seek line end if (*tp != '\0') - *tp++ = '\0'; //terminate value (passing if not EOF) + *tp++ = '\0'; // terminate value (passing if not EOF) while ((*tp <= ' ') && (*tp > '\0')) - tp += 1; //Skip following whitespace, if any + tp += 1; // Skip following whitespace, if any - *CNF_p_p = tp; //return new CNF file position - *name_p_p = np; //return found variable name - *value_p_p = vp; //return found variable value - return true; //return control to caller -} //Ends get_CNF_string + *CNF_p_p = tp; // return new CNF file position + *name_p_p = np; // return found variable name + *value_p_p = vp; // return found variable value + return true; // return control to caller +} // Ends get_CNF_string //--------------------------------------------------------------------------- int CheckMC(void) @@ -161,7 +161,7 @@ unsigned long hextoul(char *string) return value; } //--------------------------------------------------------------------------- -//storeSkinCNF will save most cosmetic settings to a RAM area +// storeSkinCNF will save most cosmetic settings to a RAM area //------------------------------ static size_t storeSkinCNF(char *cnf_buf) { @@ -186,31 +186,31 @@ static size_t storeSkinCNF(char *cnf_buf) "Menu_Frame = %d\r\n" "Show_Menu = %d\r\n" "%n", // %n causes NO output, but only a measurement - (u32)setting->color[COLOR_BACKGR], //Col_1 - (u32)setting->color[COLOR_FRAME], //Col_2 - (u32)setting->color[COLOR_SELECT], //Col_3 - (u32)setting->color[COLOR_TEXT], //Col_4 - (u32)setting->color[COLOR_GRAPH1], //Col_5 - (u32)setting->color[COLOR_GRAPH2], //Col_6 - (u32)setting->color[COLOR_GRAPH3], //Col_7 - (u32)setting->color[COLOR_GRAPH4], //Col_8 - setting->skin, //SKIN_FILE - setting->GUI_skin, //GUI_SKIN_FILE - setting->Brightness, //SKIN_Brightness - setting->TV_mode, //TV_mode - setting->screen_x, //Screen_X - setting->screen_y, //Screen_Y - setting->Popup_Opaque, //Popup_Opaque - setting->Menu_Frame, //Menu_Frame - setting->Show_Menu, //Show_Menu + (u32)setting->color[COLOR_BACKGR], // Col_1 + (u32)setting->color[COLOR_FRAME], // Col_2 + (u32)setting->color[COLOR_SELECT], // Col_3 + (u32)setting->color[COLOR_TEXT], // Col_4 + (u32)setting->color[COLOR_GRAPH1], // Col_5 + (u32)setting->color[COLOR_GRAPH2], // Col_6 + (u32)setting->color[COLOR_GRAPH3], // Col_7 + (u32)setting->color[COLOR_GRAPH4], // Col_8 + setting->skin, // SKIN_FILE + setting->GUI_skin, // GUI_SKIN_FILE + setting->Brightness, // SKIN_Brightness + setting->TV_mode, // TV_mode + setting->screen_x, // Screen_X + setting->screen_y, // Screen_Y + setting->Popup_Opaque, // Popup_Opaque + setting->Menu_Frame, // Menu_Frame + setting->Show_Menu, // Show_Menu &CNF_size // This variable measures the size of sprintf data - ); + ); return CNF_size; } //------------------------------ -//endfunc storeSkinCNF +// endfunc storeSkinCNF //--------------------------------------------------------------------------- -//saveSkinCNF will save most cosmetic settings to a skin CNF file +// saveSkinCNF will save most cosmetic settings to a skin CNF file //------------------------------ static int saveSkinCNF(char *CNF) { @@ -223,19 +223,19 @@ static int saveSkinCNF(char *CNF) ret = genFixPath(CNF, cnf_path); if ((ret < 0) || ((fd = genOpen(cnf_path, O_CREAT | O_WRONLY | O_TRUNC)) < 0)) { - return -1; //Failed open + return -1; // Failed open } ret = genWrite(fd, &tmp, CNF_size); if (ret != CNF_size) - ret = -2; //Failed writing + ret = -2; // Failed writing genClose(fd); return ret; } //----------------------------- -//endfunc saveSkinCNF +// endfunc saveSkinCNF //--------------------------------------------------------------------------- -//saveSkinBrowser will save most cosmetic settings to browsed skin CNF file +// saveSkinBrowser will save most cosmetic settings to browsed skin CNF file //------------------------------ static void saveSkinBrowser(void) { @@ -253,12 +253,12 @@ static void saveSkinBrowser(void) drawMsg(LNG(Enter_File_Name)); tmp[0] = 0; - if (tst > 0) { //if an existing file was selected, use its name - p = strrchr(path, '/'); //find separator between path and name + if (tst > 0) { // if an existing file was selected, use its name + p = strrchr(path, '/'); // find separator between path and name if (p != NULL) { strcpy(tmp, p + 1); p[1] = '\0'; - } else //if we got a pathname without separator, something is wrong + } else // if we got a pathname without separator, something is wrong goto abort; } if ((tst >= 0) && (keyboard(tmp, 36) > 0)) @@ -288,9 +288,9 @@ static void saveSkinBrowser(void) drawMsg(tmp); } //----------------------------- -//endfunc saveSkinBrowser +// endfunc saveSkinBrowser //--------------------------------------------------------------------------- -//preloadCNF loads an entire CNF file into RAM it allocates +// preloadCNF loads an entire CNF file into RAM it allocates //------------------------------ char *preloadCNF(char *path) { @@ -314,15 +314,15 @@ char *preloadCNF(char *path) genClose(fd); goto failed_load; } - genRead(fd, RAM_p, CNF_size); //Read CNF as one long string + genRead(fd, RAM_p, CNF_size); // Read CNF as one long string genClose(fd); - RAM_p[CNF_size] = '\0'; //Terminate the CNF string + RAM_p[CNF_size] = '\0'; // Terminate the CNF string return RAM_p; } //------------------------------ -//endfunc preloadCNF +// endfunc preloadCNF //--------------------------------------------------------------------------- -//scanSkinCNF will check for most cosmetic variables of a CNF +// scanSkinCNF will check for most cosmetic variables of a CNF //------------------------------ int scanSkinCNF(char *name, char *value) { @@ -364,13 +364,13 @@ int scanSkinCNF(char *name, char *value) else if (!strcmp(name, "Show_Menu")) setting->Show_Menu = atoi(value); else - return 0; //when no skin variable - return 1; //when skin variable found + return 0; // when no skin variable + return 1; // when skin variable found } //------------------------------ -//endfunc scanSkinCNF +// endfunc scanSkinCNF //--------------------------------------------------------------------------- -//loadSkinCNF will load most cosmetic settings from CNF file +// loadSkinCNF will load most cosmetic settings from CNF file //------------------------------ int loadSkinCNF(char *path) { @@ -389,9 +389,9 @@ int loadSkinCNF(char *path) return 0; } //------------------------------ -//endfunc loadSkinCNF +// endfunc loadSkinCNF //--------------------------------------------------------------------------- -//loadSkinBrowser will load most cosmetic settings from browsed skin CNF file +// loadSkinBrowser will load most cosmetic settings from browsed skin CNF file //------------------------------ void loadSkinBrowser(void) { @@ -409,7 +409,7 @@ void loadSkinBrowser(void) drawMsg(mess); } //------------------------------ -//endfunc loadSkinBrowser +// endfunc loadSkinBrowser //--------------------------------------------------------------------------- // Save LAUNCHELF.CNF (or LAUNCHELFx.CNF with multiple pages) // sincro: ADD save USBD_FILE string @@ -423,9 +423,9 @@ void saveConfig(char *mainMsg, char *CNF) char cnf_path[MAX_PATH]; size_t CNF_size, CNF_step; - sprintf(tmp, "CNF_version = 3\r\n%n", &CNF_size); //Start CNF with version header + sprintf(tmp, "CNF_version = 3\r\n%n", &CNF_size); // Start CNF with version header - for (i = 0; i < SETTING_LK_COUNT; i++) { //Loop to save the ELF paths for launch keys + for (i = 0; i < SETTING_LK_COUNT; i++) { // Loop to save the ELF paths for launch keys if ((i <= SETTING_LK_SELECT) || (setting->LK_Flag[i] != 0)) { sprintf(tmp + CNF_size, "LK_%s_E1 = %s\r\n" @@ -433,10 +433,10 @@ void saveConfig(char *mainMsg, char *CNF) LK_ID[i], setting->LK_Path[i], &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; } - } //ends for + } // ends for i = strlen(setting->Misc); sprintf(tmp + CNF_size, @@ -480,7 +480,7 @@ void saveConfig(char *mainMsg, char *CNF) setting->Misc_Show_Build_Info + i, setting->Misc_OSDSYS + i, &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; CNF_size += storeSkinCNF(tmp + CNF_size); @@ -511,75 +511,75 @@ void saveConfig(char *mainMsg, char *CNF) "PSU_NoOverwrite = %d\r\n" "FB_NoIcons = %d\r\n" "%n", // %n causes NO output, but only a measurement - setting->timeout, //auto_Timer - setting->Hide_Paths, //Menu_Hide_Paths - setting->numCNF, //Menu_Pages - setting->swapKeys, //GUI_Swap_Keys - setting->usbd_file, //USBD_FILE - setting->HOSTwrite, //NET_HOST_write - setting->Menu_Title, //Menu_Title - setting->Init_Delay, //Init_Delay - setting->usbkbd_used, //USBKBD_USED - setting->usbkbd_file, //USBKBD_FILE - setting->kbdmap_file, //KBDMAP_FILE - setting->Show_Titles, //Menu_Show_Titles - setting->PathPad_Lock, //PathPad_Lock - setting->CNF_Path, //CNF_Path - setting->usbmass_file, //USBMASS_FILE - setting->lang_file, //LANG_FILE - setting->font_file, //FONT_FILE - setting->JpgView_Timer, //JpgView_Timer - setting->JpgView_Trans, //JpgView_Trans - setting->JpgView_Full, //JpgView_Full - setting->PSU_HugeNames, //PSU_HugeNames - setting->PSU_DateNames, //PSU_DateNames - setting->PSU_NoOverwrite, //PSU_NoOverwrite - setting->FB_NoIcons, //FB_NoIcons + setting->timeout, // auto_Timer + setting->Hide_Paths, // Menu_Hide_Paths + setting->numCNF, // Menu_Pages + setting->swapKeys, // GUI_Swap_Keys + setting->usbd_file, // USBD_FILE + setting->HOSTwrite, // NET_HOST_write + setting->Menu_Title, // Menu_Title + setting->Init_Delay, // Init_Delay + setting->usbkbd_used, // USBKBD_USED + setting->usbkbd_file, // USBKBD_FILE + setting->kbdmap_file, // KBDMAP_FILE + setting->Show_Titles, // Menu_Show_Titles + setting->PathPad_Lock, // PathPad_Lock + setting->CNF_Path, // CNF_Path + setting->usbmass_file, // USBMASS_FILE + setting->lang_file, // LANG_FILE + setting->font_file, // FONT_FILE + setting->JpgView_Timer, // JpgView_Timer + setting->JpgView_Trans, // JpgView_Trans + setting->JpgView_Full, // JpgView_Full + setting->PSU_HugeNames, // PSU_HugeNames + setting->PSU_DateNames, // PSU_DateNames + setting->PSU_NoOverwrite, // PSU_NoOverwrite + setting->FB_NoIcons, // FB_NoIcons &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; - for (i = 0; i < SETTING_LK_BTN_COUNT; i++) { //Loop to save user defined launch key titles - if (setting->LK_Title[i][0]) { //Only save non-empty strings + for (i = 0; i < SETTING_LK_BTN_COUNT; i++) { // Loop to save user defined launch key titles + if (setting->LK_Title[i][0]) { // Only save non-empty strings sprintf(tmp + CNF_size, "LK_%s_Title = %s\r\n" "%n", // %n causes NO output, but only a measurement LK_ID[i], setting->LK_Title[i], &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; - } //ends if - } //ends for + } // ends if + } // ends for sprintf(tmp + CNF_size, "PathPad_Lock = %d\r\n" "%n", // %n causes NO output, but only a measurement - setting->PathPad_Lock, //PathPad_Lock + setting->PathPad_Lock, // PathPad_Lock &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; - for (i = 0; i < MAX_PATH_PAD; i++) { //Loop to save non-empty PathPad entries - if (PathPad[i][0]) { //Only save non-empty strings + for (i = 0; i < MAX_PATH_PAD; i++) { // Loop to save non-empty PathPad entries + if (PathPad[i][0]) { // Only save non-empty strings sprintf(tmp + CNF_size, "PathPad[%02d] = %s\r\n" "%n", // %n causes NO output, but only a measurement i, PathPad[i], &CNF_step // This variable measures the size of sprintf data - ); + ); CNF_size += CNF_step; - } //ends if - } //ends for + } // ends if + } // ends for strcpy(c, LaunchElfDir); strcat(c, CNF); ret = genFixPath(c, cnf_path); if ((ret >= 0) && ((fd = genOpen(cnf_path, O_RDONLY)) >= 0)) genClose(fd); - else { //Start of clause for failure to use LaunchElfDir - if (setting->CNF_Path[0] == 0) { //if NO CNF Path override defined + else { // Start of clause for failure to use LaunchElfDir + if (setting->CNF_Path[0] == 0) { // if NO CNF Path override defined if (!strncmp(LaunchElfDir, "mc", 2)) sprintf(c, "mc%d:/SYS-CONF", LaunchElfDir[2] - '0'); else @@ -594,7 +594,7 @@ void saveConfig(char *mainMsg, char *CNF) strcat(c, CNF); } } - } //End of clause for failure to use LaunchElfDir + } // End of clause for failure to use LaunchElfDir ret = genFixPath(c, cnf_path); if ((ret < 0) || ((fd = genOpen(cnf_path, O_CREAT | O_WRONLY | O_TRUNC)) < 0)) { @@ -695,8 +695,8 @@ void initConfig(void) setting->usbkbd_used = DEF_USBKBD_USED; setting->Show_Titles = DEF_SHOW_TITLES; setting->PathPad_Lock = DEF_PATHPAD_LOCK; - setting->JpgView_Timer = -1; //only used to detect missing variable - setting->JpgView_Trans = -1; //only used to detect missing variable + setting->JpgView_Timer = -1; // only used to detect missing variable + setting->JpgView_Trans = -1; // only used to detect missing variable setting->JpgView_Full = DEF_JPGVIEW_FULL; setting->PSU_HugeNames = DEF_PSU_HUGENAMES; setting->PSU_DateNames = DEF_PSU_DATENAMES; @@ -704,7 +704,7 @@ void initConfig(void) setting->FB_NoIcons = DEF_FB_NOICONS; } //------------------------------ -//endfunc initConfig +// endfunc initConfig //--------------------------------------------------------------------------- // Load LAUNCHELF.CNF (or LAUNCHELFx.CNF with multiple pages) // sincro: ADD load USBD_FILE string @@ -734,13 +734,13 @@ int loadConfig(char *mainMsg, char *CNF) char strtmp[MAX_PATH], *p; int pos; - p = strrchr(path, '.'); //make p point to extension - if (*(p - 1) != 'F') //is this an indexed CNF - p--; //then make p point to index + p = strrchr(path, '.'); // make p point to extension + if (*(p - 1) != 'F') // is this an indexed CNF + p--; // then make p point to index pos = (p - path); strcpy(strtmp, path); - strcpy(strtmp + pos - 9, "LNCHELF"); //Replace LAUNCHELF with LNCHELF (for CD) - strcpy(strtmp + pos - 2, path + pos); //Add index+extension too + strcpy(strtmp + pos - 9, "LNCHELF"); // Replace LAUNCHELF with LNCHELF (for CD) + strcpy(strtmp + pos - 2, path + pos); // Add index+extension too if ((tst = genFixPath(strtmp, cnf_path)) >= 0) fd = genOpen(cnf_path, O_RDONLY); if (fd < 0) { @@ -770,9 +770,9 @@ int loadConfig(char *mainMsg, char *CNF) goto failed_load; CNF_p = RAM_p; - //RA NB: in the code below, the 'LK_' variables have been implemented such that - // any _Ex suffix will be accepted, with identical results. This will need - // to be modified when more execution methods are implemented. + // RA NB: in the code below, the 'LK_' variables have been implemented such that + // any _Ex suffix will be accepted, with identical results. This will need + // to be modified when more execution methods are implemented. CNF_version = 0; // The CNF version is still unidentified for (var_cnt = 0; get_CNF_string(&CNF_p, &name, &value); var_cnt++) { // A variable was found, now we dispose of its value. @@ -796,7 +796,7 @@ int loadConfig(char *mainMsg, char *CNF) if (i < SETTING_LK_COUNT) continue; //---------- - //In the next group, the Misc device must be defined before its subprograms + // In the next group, the Misc device must be defined before its subprograms //---------- else if (!strcmp(name, "Misc")) sprintf(setting->Misc, "%s/", value); @@ -908,7 +908,7 @@ int loadConfig(char *mainMsg, char *CNF) } } } - } //ends for + } // ends for for (i = 0; i < SETTING_LK_BTN_COUNT; i++) setting->LK_Title[i][MAX_ELF_TITLE - 1] = 0; free(RAM_p); @@ -920,7 +920,7 @@ int loadConfig(char *mainMsg, char *CNF) return 0; } //------------------------------ -//endfunc loadConfig +// endfunc loadConfig //--------------------------------------------------------------------------- // Polo: ADD Skin Menu with Skin preview // suloku: ADD Main skin selection @@ -957,78 +957,78 @@ static void Config_Skin(void) current_preview = PREVIEW_PIC; s = CONFIG_SKIN_FIRST; - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_SKIN_FIRST) s--; else s = max_s; } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != max_s) s++; else s = CONFIG_SKIN_FIRST; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_SKIN_FIRST) s = CONFIG_SKIN_FIRST; else s = max_s; } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != max_s) s = max_s; else s = CONFIG_SKIN_FIRST; } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command - if (s == CONFIG_SKIN_PATH) { //Command == Cancel Skin Path + event |= 2; // event |= valid pad command + if (s == CONFIG_SKIN_PATH) { // Command == Cancel Skin Path setting->skin[0] = '\0'; loadSkin(PREVIEW_PIC, 0, 0); current_preview = PREVIEW_PIC; - } else if (s == CONFIG_SKIN_BRIGHTNESS) { //Command == Decrease Brightness + } else if (s == CONFIG_SKIN_BRIGHTNESS) { // Command == Decrease Brightness if ((Brightness > 0) && (testsetskin == 1)) { Brightness--; } - } else if (s == CONFIG_SKIN_GUI_PATH) { //Command == Cancel GUI Skin Path + } else if (s == CONFIG_SKIN_GUI_PATH) { // Command == Cancel GUI Skin Path setting->GUI_skin[0] = '\0'; loadSkin(PREVIEW_GUI, 0, 0); current_preview = PREVIEW_GUI; } } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command - if (s == CONFIG_SKIN_PATH) { //Command == Set Skin Path + event |= 2; // event |= valid pad command + if (s == CONFIG_SKIN_PATH) { // Command == Set Skin Path getFilePath(setting->skin, SKIN_CNF); loadSkin(PREVIEW_PIC, 0, 0); current_preview = PREVIEW_PIC; - } else if (s == CONFIG_SKIN_APPLY) { //Command == Apply New Skin + } else if (s == CONFIG_SKIN_APPLY) { // Command == Apply New Skin GUI_active = 0; loadSkin(BACKGROUND_PIC, 0, 0); setting->Brightness = Brightness; strcpy(skinSave, setting->skin); loadSkin(PREVIEW_PIC, 0, 0); current_preview = PREVIEW_PIC; - } else if (s == CONFIG_SKIN_BRIGHTNESS) { //Command == Increase Brightness + } else if (s == CONFIG_SKIN_BRIGHTNESS) { // Command == Increase Brightness if ((Brightness < 100) && (testsetskin == 1)) { Brightness++; } - } else if (s == CONFIG_SKIN_GUI_PATH) { //Command == Set GUI Skin Path + } else if (s == CONFIG_SKIN_GUI_PATH) { // Command == Set GUI Skin Path getFilePath(setting->GUI_skin, GUI_SKIN_CNF); loadSkin(PREVIEW_GUI, 0, 0); current_preview = PREVIEW_GUI; - } else if (s == CONFIG_SKIN_GUI_APPLY) { //Command == Apply GUI Skin + } else if (s == CONFIG_SKIN_GUI_APPLY) { // Command == Apply GUI Skin strcpy(GUI_Save, setting->GUI_skin); loadSkin(PREVIEW_GUI, 0, 0); current_preview = PREVIEW_GUI; - } else if (s == CONFIG_SKIN_GUI_SHOW_MENU) { //Command == Show GUI Menu + } else if (s == CONFIG_SKIN_GUI_SHOW_MENU) { // Command == Show GUI Menu setting->Show_Menu = !setting->Show_Menu; - } else if (s == CONFIG_SKIN_RETURN) { //Command == RETURN + } else if (s == CONFIG_SKIN_RETURN) { // Command == RETURN setting->skin[0] = '\0'; strcpy(setting->skin, skinSave); setting->GUI_skin[0] = '\0'; @@ -1042,11 +1042,11 @@ static void Config_Skin(void) strcpy(setting->GUI_skin, GUI_Save); return; } - } //end if(readpad()) + } // end if(readpad()) - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); if (testsetskin == 1) { @@ -1115,11 +1115,11 @@ static void Config_Skin(void) strcat(c, LNG(Skin_Preview)); printXY(c, SCREEN_WIDTH / 4, (SCREEN_HEIGHT / 4) + 78 - FONT_HEIGHT, setting->color[COLOR_TEXT], TRUE, 0); - //Cursor positioning section + // Cursor positioning section y = Menu_start_y + s * (FONT_HEIGHT); drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); - //Tooltip section + // Tooltip section if ((s == 1) || (s == 4)) { if (swapKeys) len = sprintf(c, "\xFF" @@ -1131,7 +1131,7 @@ static void Config_Skin(void) "0:%s \xFF" "1:%s", LNG(Edit), LNG(Clear)); - } else if (s == 3) { //if cursor at a colour component or a screen offset + } else if (s == 3) { // if cursor at a colour component or a screen offset if (swapKeys) len = sprintf(c, "\xFF" "1:%s \xFF" @@ -1165,13 +1165,13 @@ static void Config_Skin(void) "3:%s", LNG(Return)); setScrTmp("", c); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while -} //ends Config_Skin + } // ends while +} // ends Config_Skin //--------------------------------------------------------------------------- enum CONFIG_SCREEN { @@ -1203,7 +1203,7 @@ enum CONFIG_SCREEN { CONFIG_SCREEN_COL_GRAPH4_G, CONFIG_SCREEN_COL_GRAPH4_B, - //First option after colour selectors + // First option after colour selectors CONFIG_SCREEN_AFT_COLORS, CONFIG_SCREEN_TV_MODE = CONFIG_SCREEN_AFT_COLORS, CONFIG_SCREEN_TV_STARTX, @@ -1226,7 +1226,7 @@ enum CONFIG_SCREEN { static void Config_Screen(void) { int i; - int s, max_s = CONFIG_SCREEN_COUNT - 1; //define cursor index and its max value + int s, max_s = CONFIG_SCREEN_COUNT - 1; // define cursor index and its max value int x, y; int len; int event, post_event = 0; @@ -1234,7 +1234,7 @@ static void Config_Screen(void) char c[MAX_PATH]; int space = ((SCREEN_WIDTH - SCREEN_MARGIN - 4 * FONT_WIDTH) - (Menu_start_x + 2 * FONT_WIDTH)) / 8; - event = 1; //event = initial entry + event = 1; // event = initial entry for (i = 0; i < COLOR_COUNT; i++) { rgb[i][0] = setting->color[i] & 0xFF; @@ -1244,11 +1244,11 @@ static void Config_Screen(void) s = CONFIG_SCREEN_FIRST; while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s == CONFIG_SCREEN_FIRST) s = max_s; else if (s == CONFIG_SCREEN_AFT_COLORS) @@ -1256,7 +1256,7 @@ static void Config_Screen(void) else s--; } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((s < CONFIG_SCREEN_AFT_COLORS) && (s % 3 == 2)) s = CONFIG_SCREEN_AFT_COLORS; else if (s == max_s) @@ -1264,7 +1264,7 @@ static void Config_Screen(void) else s++; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s >= CONFIG_SCREEN_RETURN) s = CONFIG_SCREEN_MENU_FRAME; @@ -1275,13 +1275,13 @@ static void Config_Screen(void) else if (s >= CONFIG_SCREEN_SKIN) s = CONFIG_SCREEN_TV_MODE; else if (s >= CONFIG_SCREEN_TV_STARTX) - s = CONFIG_SCREEN_TV_MODE; //at or + s = CONFIG_SCREEN_TV_MODE; // at or else if (s >= CONFIG_SCREEN_AFT_COLORS) - s = CONFIG_SCREEN_COL_LAST; //if s beyond color settings + s = CONFIG_SCREEN_COL_LAST; // if s beyond color settings else if (s >= CONFIG_SCREEN_COL_FIRST + 3) - s -= 3; //if s in a color beyond the first colour, step to preceding color + s -= 3; // if s in a color beyond the first colour, step to preceding color } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s >= CONFIG_SCREEN_MENU_FRAME) s = CONFIG_SCREEN_RETURN; else if (s >= CONFIG_SCREEN_MENU_TITLE) @@ -1293,11 +1293,11 @@ static void Config_Screen(void) else if (s >= CONFIG_SCREEN_TV_MODE) s = CONFIG_SCREEN_TV_STARTX; else if (s >= CONFIG_SCREEN_COL_LAST) - s = CONFIG_SCREEN_AFT_COLORS; //if s in the last colour, move it to the first control after colour selection. + s = CONFIG_SCREEN_AFT_COLORS; // if s in the last colour, move it to the first control after colour selection. else s += 3; - } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { //User pressed CANCEL=>Subtract/Clear - event |= 2; //event |= valid pad command + } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { // User pressed CANCEL=>Subtract/Clear + event |= 2; // event |= valid pad command if (s < CONFIG_SCREEN_AFT_COLORS) { if (rgb[s / 3][s % 3] > 0) { rgb[s / 3][s % 3]--; @@ -1314,11 +1314,11 @@ static void Config_Screen(void) setting->screen_y--; updateScreenMode(); } - } else if (s == CONFIG_SCREEN_MENU_TITLE) { //cursor is at Menu_Title + } else if (s == CONFIG_SCREEN_MENU_TITLE) { // cursor is at Menu_Title setting->Menu_Title[0] = '\0'; } - } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { //User pressed OK=>Add/Ok/Edit - event |= 2; //event |= valid pad command + } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { // User pressed OK=>Add/Ok/Edit + event |= 2; // event |= valid pad command if (s < CONFIG_SCREEN_AFT_COLORS) { if (rgb[s / 3][s % 3] < 255) { rgb[s / 3][s % 3]++; @@ -1326,7 +1326,7 @@ static void Config_Screen(void) GS_SETREG_RGBA(rgb[s / 3][0], rgb[s / 3][1], rgb[s / 3][2], 0); } } else if (s == CONFIG_SCREEN_TV_MODE) { - setting->TV_mode = (setting->TV_mode + 1) % TV_mode_COUNT; //Change between the various modes + setting->TV_mode = (setting->TV_mode + 1) % TV_mode_COUNT; // Change between the various modes updateScreenMode(); } else if (s == CONFIG_SCREEN_TV_STARTX) { if (setting->screen_x < gsGlobal->StartX) { @@ -1344,7 +1344,7 @@ static void Config_Screen(void) loadSkinBrowser(); } else if (s == CONFIG_SCREEN_SAVE_SKIN_BROWSER) { saveSkinBrowser(); - } else if (s == CONFIG_SCREEN_MENU_TITLE) { //cursor is at Menu_Title + } else if (s == CONFIG_SCREEN_MENU_TITLE) { // cursor is at Menu_Title char tmp[MAX_MENU_TITLE + 1]; strcpy(tmp, setting->Menu_Title); if (keyboard(tmp, MAX_MENU_TITLE) >= 0) @@ -1353,9 +1353,9 @@ static void Config_Screen(void) setting->Menu_Frame = !setting->Menu_Frame; } else if (s == CONFIG_SCREEN_POPUP_OPAQUE) { setting->Popup_Opaque = !setting->Popup_Opaque; - } else if (s == CONFIG_SCREEN_RETURN) { //Always put 'RETURN' next to last + } else if (s == CONFIG_SCREEN_RETURN) { // Always put 'RETURN' next to last return; - } else if (s == CONFIG_SCREEN_DEFAULT) { //Always put 'DEFAULT SCREEN SETTINGS' last + } else if (s == CONFIG_SCREEN_DEFAULT) { // Always put 'DEFAULT SCREEN SETTINGS' last setting->skin[0] = '\0'; setting->GUI_skin[0] = '\0'; loadSkin(BACKGROUND_PIC, 0, 0); @@ -1386,9 +1386,9 @@ static void Config_Screen(void) return; } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); x = Menu_start_x; @@ -1426,7 +1426,7 @@ static void Config_Screen(void) sprintf(c, "\xFF" "4"); printXY(c, x + (space * (i + 1)) - FONT_WIDTH, y, setting->color[i], TRUE, 0); - } //ends loop for colour RGB values + } // ends loop for colour RGB values y += FONT_HEIGHT * 2; sprintf(c, " %s: ", LNG(TV_mode)); if (setting->TV_mode == TV_mode_NTSC) @@ -1492,35 +1492,35 @@ static void Config_Screen(void) printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0); y += FONT_HEIGHT; - //Cursor positioning section + // Cursor positioning section x = Menu_start_x; y = Menu_start_y; - if (s < CONFIG_SCREEN_AFT_COLORS) { //if cursor indicates a colour component + if (s < CONFIG_SCREEN_AFT_COLORS) { // if cursor indicates a colour component int colnum = s / 3; int comnum = s - colnum * 3; x += (space * (colnum + 1)) - (FONT_WIDTH * 4); y += (2 + comnum) * FONT_HEIGHT; - } else { //if cursor indicates anything after colour components - y += (s - CONFIG_SCREEN_AFT_COLORS + 6) * FONT_HEIGHT + FONT_HEIGHT / 2; //adjust y for cursor beyond colours - //Here y is almost correct, except for additional group spacing - if (s >= CONFIG_SCREEN_AFT_COLORS) //if cursor at or beyond TV mode choice - y += FONT_HEIGHT / 2; //adjust for half-row space below colours - if (s >= CONFIG_SCREEN_TV_STARTX) //if cursor at or beyond screen offsets - y += FONT_HEIGHT / 2; //adjust for half-row space below TV mode choice - if (s >= CONFIG_SCREEN_SKIN) //if cursor at or beyond 'SKIN SETTINGS' - y += FONT_HEIGHT / 2; //adjust for half-row space below screen offsets - if (s >= CONFIG_SCREEN_MENU_TITLE) //if cursor at or beyond 'Menu Title' - y += FONT_HEIGHT / 2; //adjust for half-row space below 'SKIN SETTINGS' - if (s >= CONFIG_SCREEN_MENU_FRAME) //if cursor at or beyond 'Menu Frame' - y += FONT_HEIGHT / 2; //adjust for half-row space below 'Menu Title' - if (s >= CONFIG_SCREEN_RETURN) //if cursor at or beyond 'RETURN' - y += FONT_HEIGHT / 2; //adjust for half-row space below 'Popups Opaque' + } else { // if cursor indicates anything after colour components + y += (s - CONFIG_SCREEN_AFT_COLORS + 6) * FONT_HEIGHT + FONT_HEIGHT / 2; // adjust y for cursor beyond colours + // Here y is almost correct, except for additional group spacing + if (s >= CONFIG_SCREEN_AFT_COLORS) // if cursor at or beyond TV mode choice + y += FONT_HEIGHT / 2; // adjust for half-row space below colours + if (s >= CONFIG_SCREEN_TV_STARTX) // if cursor at or beyond screen offsets + y += FONT_HEIGHT / 2; // adjust for half-row space below TV mode choice + if (s >= CONFIG_SCREEN_SKIN) // if cursor at or beyond 'SKIN SETTINGS' + y += FONT_HEIGHT / 2; // adjust for half-row space below screen offsets + if (s >= CONFIG_SCREEN_MENU_TITLE) // if cursor at or beyond 'Menu Title' + y += FONT_HEIGHT / 2; // adjust for half-row space below 'SKIN SETTINGS' + if (s >= CONFIG_SCREEN_MENU_FRAME) // if cursor at or beyond 'Menu Frame' + y += FONT_HEIGHT / 2; // adjust for half-row space below 'Menu Title' + if (s >= CONFIG_SCREEN_RETURN) // if cursor at or beyond 'RETURN' + y += FONT_HEIGHT / 2; // adjust for half-row space below 'Popups Opaque' } - drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); //draw cursor + drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); // draw cursor - //Tooltip section - if (s < CONFIG_SCREEN_AFT_COLORS || s == CONFIG_SCREEN_TV_STARTX || s == CONFIG_SCREEN_TV_STARTY) { //if cursor at a colour component or a screen offset + // Tooltip section + if (s < CONFIG_SCREEN_AFT_COLORS || s == CONFIG_SCREEN_TV_STARTX || s == CONFIG_SCREEN_TV_STARTY) { // if cursor at a colour component or a screen offset if (swapKeys) len = sprintf(c, "\xFF" "1:%s \xFF" @@ -1532,7 +1532,7 @@ static void Config_Screen(void) "1:%s", LNG(Add), LNG(Subtract)); } else if (s == CONFIG_SCREEN_TV_MODE || s == CONFIG_SCREEN_MENU_FRAME || s == CONFIG_SCREEN_POPUP_OPAQUE) { - //if cursor at 'TV mode', 'Menu Frame' or 'Popups Opaque' + // if cursor at 'TV mode', 'Menu Frame' or 'Popups Opaque' if (swapKeys) len = sprintf(c, "\xFF" "1:%s", @@ -1541,7 +1541,7 @@ static void Config_Screen(void) len = sprintf(c, "\xFF" "0:%s", LNG(Change)); - } else if (s == CONFIG_SCREEN_SKIN || s == CONFIG_SCREEN_LOAD_SKIN_BROWSER || s == CONFIG_SCREEN_SAVE_SKIN_BROWSER) { //if cursor at 'SKIN SETTINGS' + } else if (s == CONFIG_SCREEN_SKIN || s == CONFIG_SCREEN_LOAD_SKIN_BROWSER || s == CONFIG_SCREEN_SAVE_SKIN_BROWSER) { // if cursor at 'SKIN SETTINGS' if (swapKeys) len = sprintf(c, "\xFF" "1:%s", @@ -1550,7 +1550,7 @@ static void Config_Screen(void) len = sprintf(c, "\xFF" "0:%s", LNG(OK)); - } else if (s == CONFIG_SCREEN_MENU_TITLE) { //if cursor at Menu_Title + } else if (s == CONFIG_SCREEN_MENU_TITLE) { // if cursor at Menu_Title if (swapKeys) len = sprintf(c, "\xFF" "1:%s \xFF" @@ -1561,7 +1561,7 @@ static void Config_Screen(void) "0:%s \xFF" "1:%s", LNG(Edit), LNG(Clear)); - } else { //if cursor at 'RETURN' or 'DEFAULT' options + } else { // if cursor at 'RETURN' or 'DEFAULT' options if (swapKeys) len = sprintf(c, "\xFF" "1:%s", @@ -1575,13 +1575,13 @@ static void Config_Screen(void) "3:%s", LNG(Return)); setScrTmp("", c); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while -} //ends Config_Screen + } // ends while +} // ends Config_Screen //--------------------------------------------------------------------------- // Other settings by EP // sincro: ADD USBD SELECTOR MENU @@ -1611,44 +1611,44 @@ enum CONFIG_STARTUP { static void Config_Startup(void) { - int s, max_s = CONFIG_STARTUP_COUNT - 1; //define cursor index and its max value + int s, max_s = CONFIG_STARTUP_COUNT - 1; // define cursor index and its max value int x, y; int len; int event, post_event = 0; char c[MAX_PATH]; - event = 1; //event = initial entry + event = 1; // event = initial entry s = CONFIG_STARTUP_FIRST; while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_STARTUP_FIRST) s--; else s = max_s; } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != max_s) s++; else s = CONFIG_STARTUP_FIRST; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != max_s) s = max_s; else s = CONFIG_STARTUP_FIRST; } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != max_s) s = max_s; else s = CONFIG_STARTUP_FIRST; } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s == CONFIG_STARTUP_CNF_COUNT && setting->numCNF > 1) setting->numCNF--; else if (s == CONFIG_STARTUP_USBD) @@ -1671,15 +1671,15 @@ static void Config_Startup(void) } else if (s == CONFIG_STARTUP_FONT) { setting->font_file[0] = '\0'; loadFont(""); - } else if (s == CONFIG_STARTUP_ESR) { //clear ESR file choice + } else if (s == CONFIG_STARTUP_ESR) { // clear ESR file choice setting->LK_Path[SETTING_LK_ESR][0] = 0; setting->LK_Flag[SETTING_LK_ESR] = 0; - } else if (s == CONFIG_STARTUP_OSDSYS) { //clear OSDSYS file choice + } else if (s == CONFIG_STARTUP_OSDSYS) { // clear OSDSYS file choice setting->LK_Path[SETTING_LK_OSDSYS][0] = 0; setting->LK_Flag[SETTING_LK_OSDSYS] = 0; } } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s == CONFIG_STARTUP_CNF_COUNT) setting->numCNF++; else if (s == CONFIG_STARTUP_SELECT_BTN) @@ -1711,7 +1711,7 @@ static void Config_Startup(void) getFilePath(setting->font_file, FONT_CNF); if (loadFont(setting->font_file) == 0) setting->font_file[0] = '\0'; - } else if (s == CONFIG_STARTUP_CNF) { //Make ESR file choice + } else if (s == CONFIG_STARTUP_CNF) { // Make ESR file choice getFilePath(setting->LK_Path[SETTING_LK_ESR], LK_ELF_CNF); if (!strncmp(setting->LK_Path[SETTING_LK_ESR], "mc0", 3) || !strncmp(setting->LK_Path[SETTING_LK_ESR], "mc1", 3)) { @@ -1720,7 +1720,7 @@ static void Config_Startup(void) } if (setting->LK_Path[SETTING_LK_ESR][0]) setting->LK_Flag[SETTING_LK_ESR] = 1; - } else if (s == CONFIG_STARTUP_OSDSYS) { //Make OSDSYS file choice + } else if (s == CONFIG_STARTUP_OSDSYS) { // Make OSDSYS file choice getFilePath(setting->LK_Path[SETTING_LK_OSDSYS], TEXT_CNF); if (!strncmp(setting->LK_Path[SETTING_LK_OSDSYS], "mc0", 3) || !strncmp(setting->LK_Path[SETTING_LK_OSDSYS], "mc1", 3)) { @@ -1735,9 +1735,9 @@ static void Config_Startup(void) return; } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); x = Menu_start_x; @@ -1847,15 +1847,15 @@ static void Config_Startup(void) printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0); y += FONT_HEIGHT; - //Cursor positioning section + // Cursor positioning section y = Menu_start_y + s * FONT_HEIGHT + FONT_HEIGHT / 2; if (s >= max_s) y += FONT_HEIGHT / 2; drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); - //Tooltip section - if ((s == CONFIG_STARTUP_SELECT_BTN) || (s == CONFIG_STARTUP_KEYBOARD)) { //usbkbd_used + // Tooltip section + if ((s == CONFIG_STARTUP_SELECT_BTN) || (s == CONFIG_STARTUP_KEYBOARD)) { // usbkbd_used if (swapKeys) len = sprintf(c, "\xFF" "1:%s", @@ -1864,7 +1864,7 @@ static void Config_Startup(void) len = sprintf(c, "\xFF" "0:%s", LNG(Change)); - } else if ((s == CONFIG_STARTUP_CNF_COUNT) || (s == CONFIG_STARTUP_INIT_DELAY) || (s == CONFIG_STARTUP_TIMEOUT)) { //numCNF || Init_Delay || timeout + } else if ((s == CONFIG_STARTUP_CNF_COUNT) || (s == CONFIG_STARTUP_INIT_DELAY) || (s == CONFIG_STARTUP_TIMEOUT)) { // numCNF || Init_Delay || timeout if (swapKeys) len = sprintf(c, "\xFF" "1:%s \xFF" @@ -1876,8 +1876,8 @@ static void Config_Startup(void) "1:%s", LNG(Add), LNG(Subtract)); } else if ((s == CONFIG_STARTUP_USBD) || (s == CONFIG_STARTUP_USBKBD) || (s == CONFIG_STARTUP_KBDMAP) || (s == CONFIG_STARTUP_CNF) || (s == CONFIG_STARTUP_USBHDFSD) - //usbd_file||usbkbd_file||kbdmap_file||CNF_Path||usbmass_file - //Language||Fontfile||ESR_elf||OSDSYS_kelf + // usbd_file||usbkbd_file||kbdmap_file||CNF_Path||usbmass_file + // Language||Fontfile||ESR_elf||OSDSYS_kelf || (s == CONFIG_STARTUP_LANG) || (s == CONFIG_STARTUP_FONT) || (s == CONFIG_STARTUP_ESR) || (s == CONFIG_STARTUP_OSDSYS)) { if (swapKeys) len = sprintf(c, "\xFF" @@ -1903,13 +1903,13 @@ static void Config_Startup(void) "3:%s", LNG(Return)); setScrTmp("", c); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while -} //ends Config_Startup + } // ends while +} // ends Config_Startup //--------------------------------------------------------------------------- // Network settings GUI by Slam-Tilt //--------------------------------------------------------------------------- @@ -1959,7 +1959,7 @@ static void saveNetworkSettings(char *Message) /*for (i = 0; (ipconfigfile[i] != 0 && i <= size); i++) { - // DPRINTF("%i-%c\n\r",i,ipconfigfile[i]); + // DPRINTF("%i-%c\n\r",i,ipconfigfile[i]); }*/ sizeleft = size - i; @@ -1968,7 +1968,7 @@ static void saveNetworkSettings(char *Message) } else { port = CheckMC(); if (port < 0) - port = 0; //Default to mc0, if it fails. + port = 0; // Default to mc0, if it fails. sprintf(path, "mc%d:/SYS-CONF/IPCONFIG.DAT", port); } @@ -2038,7 +2038,7 @@ enum CONFIG_NET { CONFIG_NET_NM, CONFIG_NET_GW, - //Settings after IP addresses + // Settings after IP addresses CONFIG_NET_AFT_IP, CONFIG_NET_SAVE = CONFIG_NET_AFT_IP, CONFIG_NET_RETURN, @@ -2062,17 +2062,17 @@ static void Config_Network(void) char NetMsg[MAX_PATH] = ""; char path[MAX_PATH]; - event = 1; //event = initial entry + event = 1; // event = initial entry s = CONFIG_NET_FIRST; l = 1; ipdata = BuildOctets(ip, netmask, gw); while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_NET_FIRST) s--; else { @@ -2080,7 +2080,7 @@ static void Config_Network(void) l = 1; } } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_NET_COUNT - 1) s++; else @@ -2088,17 +2088,17 @@ static void Config_Network(void) if (s >= CONFIG_NET_AFT_IP) l = 1; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s < CONFIG_NET_AFT_IP) if (l > 1) l--; } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s < CONFIG_NET_AFT_IP) if (l < 5) l++; } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((s < CONFIG_NET_AFT_IP) && (l > 1)) { if (s == CONFIG_NET_IP) { if (ipdata.ip[l - 2] > 0) { @@ -2115,7 +2115,7 @@ static void Config_Network(void) } } } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((s < CONFIG_NET_AFT_IP) && (l > 1)) { if (s == CONFIG_NET_IP) { if (ipdata.ip[l - 2] < 255) { @@ -2139,15 +2139,15 @@ static void Config_Network(void) sprintf(gw, "%i.%i.%i.%i", ipdata.gw[0], ipdata.gw[1], ipdata.gw[2], ipdata.gw[3]); saveNetworkSettings(NetMsg); - } else //s == CONFIG_NET_RETURN + } else // s == CONFIG_NET_RETURN return; } else if (new_pad & PAD_TRIANGLE) return; } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); x = Menu_start_x; @@ -2182,7 +2182,7 @@ static void Config_Network(void) y += FONT_HEIGHT / 2; - uLE_related(path, "uLE:/IPCONFIG.DAT"); //Get save target. + uLE_related(path, "uLE:/IPCONFIG.DAT"); // Get save target. sprintf(c, " %s \"%s\"", LNG(Save_to), path); printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0); y += FONT_HEIGHT; @@ -2192,7 +2192,7 @@ static void Config_Network(void) printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0); y += FONT_HEIGHT; - //Cursor positioning section + // Cursor positioning section y = Menu_start_y + s * FONT_HEIGHT + FONT_HEIGHT / 2; if (s >= CONFIG_NET_AFT_IP) @@ -2203,7 +2203,7 @@ static void Config_Network(void) x += (len - 1) * FONT_WIDTH - 1 + (l - 2) * 6 * FONT_WIDTH; drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); - //Tooltip section + // Tooltip section if ((s < CONFIG_NET_AFT_IP) && (l == 1)) { len = sprintf(c, "%s", LNG(Right_DPad_to_Edit)); } else if (s < CONFIG_NET_AFT_IP) { @@ -2240,13 +2240,13 @@ static void Config_Network(void) "3:%s", LNG(Return)); setScrTmp(NetMsg, c); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while -} //ends Config_Network + } // ends while +} // ends Config_Network //--------------------------------------------------------------------------- // Configuration menu //--------------------------------------------------------------------------- @@ -2266,7 +2266,7 @@ enum CONFIG_MAIN { CONFIG_MAIN_BTN_R3, CONFIG_MAIN_BTN_START, - //After button settings + // After button settings CONFIG_MAIN_AFT_BTNS, CONFIG_MAIN_SHOW_TITLES = CONFIG_MAIN_AFT_BTNS, CONFIG_MAIN_FILENAME, @@ -2296,49 +2296,49 @@ void config(char *mainMsg, char *CNF) setting = (SETTING *)malloc(sizeof(SETTING)); *setting = *tmpsetting; - event = 1; //event = initial entry + event = 1; // event = initial entry s = CONFIG_MAIN_FIRST; while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_MAIN_FIRST) s--; else s = CONFIG_MAIN_COUNT - 1; } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s != CONFIG_MAIN_COUNT - 1) s++; else s = 0; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s > CONFIG_MAIN_LAST) s = CONFIG_MAIN_AFT_BTNS; else s = CONFIG_MAIN_FIRST; } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s < CONFIG_MAIN_AFT_BTNS) s = CONFIG_MAIN_AFT_BTNS; else if (s <= CONFIG_MAIN_LAST) s = CONFIG_MAIN_OK; } else if ((new_pad & PAD_SQUARE) && (s < CONFIG_MAIN_AFT_BTNS)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command strcpy(title_tmp, setting->LK_Title[s]); if (keyboard(title_tmp, MAX_ELF_TITLE) >= 0) strcpy(setting->LK_Title[s], title_tmp); } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s < CONFIG_MAIN_AFT_BTNS) { setting->LK_Path[s][0] = 0; setting->LK_Title[s][0] = 0; } } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (s < CONFIG_MAIN_AFT_BTNS) { getFilePath(setting->LK_Path[s], TRUE); if (!strncmp(setting->LK_Path[s], "mc0", 3) || @@ -2379,11 +2379,11 @@ void config(char *mainMsg, char *CNF) mainMsg[0] = 0; break; } - } //end if(readpad()) + } // end if(readpad()) - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); if (s < CONFIG_MAIN_AFT_BTNS) @@ -2475,13 +2475,13 @@ void config(char *mainMsg, char *CNF) sprintf(c, " %s", LNG(Cancel)); printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, 0); - //Cursor positioning section + // Cursor positioning section y = Menu_start_y + (s + 1) * FONT_HEIGHT; if (s >= CONFIG_MAIN_AFT_BTNS) y += FONT_HEIGHT / 2; drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); - //Tooltip section + // Tooltip section if (s < CONFIG_MAIN_AFT_BTNS) { if (swapKeys) len = sprintf(c, "\xFF" @@ -2518,13 +2518,13 @@ void config(char *mainMsg, char *CNF) "3:%s", LNG(Return)); setScrTmp(localMsg, c); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while -} //ends config + } // ends while +} // ends config //--------------------------------------------------------------------------- // End of file: config.c //--------------------------------------------------------------------------- diff --git a/src/draw.c b/src/draw.c index f5abe09a..9d05ece1 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: draw.c +// File name: draw.c //-------------------------------------------------------------- #include "launchelf.h" @@ -8,29 +8,29 @@ GSTEXTURE TexSkin, TexPreview, TexPicture, TexThumb[MAX_ENTRY], TexIcon[2]; int testskin, testsetskin, testjpg, testthumb; int SCREEN_WIDTH = 640; int SCREEN_HEIGHT = 448; -//dlanor: values shown above are defaults for NTSC mode +// dlanor: values shown above are defaults for NTSC mode u64 BrightColor; -int updateScr_1; //dlanor: flags screen updates for drawScr() -int updateScr_2; //dlanor: used for anti-flicker delay in drawScr() -u64 updateScr_t = 0; //dlanor: exit time of last drawScr() +int updateScr_1; // dlanor: flags screen updates for drawScr() +int updateScr_2; // dlanor: used for anti-flicker delay in drawScr() +u64 updateScr_t = 0; // dlanor: exit time of last drawScr() char LastMessage[MAX_TEXT_LINE + 2]; int Menu_start_x = SCREEN_MARGIN + LINE_THICKNESS + FONT_WIDTH; int Menu_title_y = SCREEN_MARGIN; int Menu_message_y = SCREEN_MARGIN + FONT_HEIGHT; -int Frame_start_y = SCREEN_MARGIN + 2 * FONT_HEIGHT + 2; //First line of menu frame +int Frame_start_y = SCREEN_MARGIN + 2 * FONT_HEIGHT + 2; // First line of menu frame int Menu_start_y = SCREEN_MARGIN + 2 * FONT_HEIGHT + LINE_THICKNESS + 5; -//dlanor: Menu_start_y is the 1st pixel line that may be used for main content of a menu -//dlanor: values below are only calculated when a rez is activated -int Menu_end_y; //Normal menu display should not use pixels at this line or beyond -int Frame_end_y; //first line of frame bottom -int Menu_tooltip_y; //Menus may also use this row for tooltips +// dlanor: Menu_start_y is the 1st pixel line that may be used for main content of a menu +// dlanor: values below are only calculated when a rez is activated +int Menu_end_y; // Normal menu display should not use pixels at this line or beyond +int Frame_end_y; // first line of frame bottom +int Menu_tooltip_y; // Menus may also use this row for tooltips -//The font file ELISA100.FNT is needed to display MC save titles in japanese -//and the arrays defined here are needed to find correct data in that file +// The font file ELISA100.FNT is needed to display MC save titles in japanese +// and the arrays defined here are needed to find correct data in that file const u16 font404[] = { 0xA2AF, 11, 0xA2C2, 8, @@ -474,11 +474,11 @@ void drawPopSprite(u64 color, int x1, int y1, int x2, int y2) } } //-------------------------------------------------------------- -//drawOpSprite exists only to eliminate the use of primitive sprite functions -//that are specific to the graphics lib used (currently gsKit). So normally -//it will merely be a 'wrapper' function for one of the lib calls, except -//that it will also perform any coordinate adjustments (if any)implemented for -//the functions drawSprite and drawPopSprite, to keep all of them compatible. +// drawOpSprite exists only to eliminate the use of primitive sprite functions +// that are specific to the graphics lib used (currently gsKit). So normally +// it will merely be a 'wrapper' function for one of the lib calls, except +// that it will also perform any coordinate adjustments (if any)implemented for +// the functions drawSprite and drawPopSprite, to keep all of them compatible. // void drawOpSprite(u64 color, int x1, int y1, int x2, int y2) { @@ -559,8 +559,8 @@ void setupGS(void) // GS Init gsGlobal = gsKit_init_global(); - if (New_TV_mode == TV_mode_AUTO) { //If no forced request - New_TV_mode = uLE_InitializeRegion(); //Let console region decide TV_mode + if (New_TV_mode == TV_mode_AUTO) { // If no forced request + New_TV_mode = uLE_InitializeRegion(); // Let console region decide TV_mode } // Screen display mode @@ -610,8 +610,8 @@ void updateScreenMode(void) int setGS_flag = 0; int New_TV_mode = setting->TV_mode; - if (New_TV_mode == TV_mode_AUTO) { //If no forced request - New_TV_mode = uLE_InitializeRegion(); //Let console region decide TV_mode + if (New_TV_mode == TV_mode_AUTO) { // If no forced request + New_TV_mode = uLE_InitializeRegion(); // Let console region decide TV_mode } if (New_TV_mode != TV_mode) { @@ -799,7 +799,7 @@ void loadSkin(int Picture, char *Path, int ThumbNum) testthumb = 1; } /* end if */ } /* end else */ - jpgClose(Jpg); //This really should be moved, but jpg funcs may object + jpgClose(Jpg); // This really should be moved, but jpg funcs may object } /* end if((jpgReadImage(...)) != -1) */ free(ImgData); free(ImgData1); @@ -815,8 +815,8 @@ void loadSkin(int Picture, char *Path, int ThumbNum) if (!strncmp(tmpPath, "hdd0:/", 6)) unmountParty(0); #ifdef DVRP - if (!strncmp(tmpPath, "dvr_hdd0:/", 10)) - unmountDVRPParty(0); + if (!strncmp(tmpPath, "dvr_hdd0:/", 10)) + unmountDVRPParty(0); #endif } //-------------------------------------------------------------- @@ -884,7 +884,7 @@ int loadFont(char *path_arg) return 0; } //------------------------------ -//endfunc loadFont +// endfunc loadFont //-------------------------------------------------------------- // Set Skin Brightness void setBrightness(int Brightness) @@ -923,31 +923,31 @@ void clrScr(u64 color) //-------------------------------------------------------------- void drawScr(void) { - if (updateScr_2) { //Did we render anything last time + if (updateScr_2) { // Did we render anything last time while (Timer() < updateScr_t + 5) - ; //if so, delay to complete rendering + ; // if so, delay to complete rendering } - gsKit_sync_flip(gsGlobal); //Await sync and flip buffers - gsKit_queue_exec(gsGlobal); //Start rendering recent transfers for NEXT time - updateScr_t = Timer(); //Note the time when the rendering started - updateScr_2 = updateScr_1; //Note if this rendering had expected updates - updateScr_1 = 0; //Note that we've nothing expected for next time -} //NB: Apparently the GS keeps rendering while we continue with other work + gsKit_sync_flip(gsGlobal); // Await sync and flip buffers + gsKit_queue_exec(gsGlobal); // Start rendering recent transfers for NEXT time + updateScr_t = Timer(); // Note the time when the rendering started + updateScr_2 = updateScr_1; // Note if this rendering had expected updates + updateScr_1 = 0; // Note that we've nothing expected for next time +} // NB: Apparently the GS keeps rendering while we continue with other work //-------------------------------------------------------------- void drawFrame(int x1, int y1, int x2, int y2, u64 color) { updateScr_1 = 1; - //Top horizontal edge + // Top horizontal edge gsKit_prim_sprite(gsGlobal, x1, y1, x2, y1 + LINE_THICKNESS - 1, 1, color); - //Bottom horizontal + // Bottom horizontal gsKit_prim_sprite(gsGlobal, x1, y2 - LINE_THICKNESS + 1, x2, y2, 1, color); - //Left vertical edge + // Left vertical edge gsKit_prim_sprite(gsGlobal, x1, y1, x1 + LINE_THICKNESS - 1, y2, 1, color); - //Right vertical edge + // Right vertical edge gsKit_prim_sprite(gsGlobal, x2 - LINE_THICKNESS + 1, y1, x2, y2, 1, color); } @@ -962,29 +962,29 @@ void drawChar(unsigned int c, int x, int y, u64 colour) if (c >= FONT_COUNT) c = '_'; - if (c > 0xFF) //if char is beyond normal ascii range + if (c > 0xFF) // if char is beyond normal ascii range cm = &font_uLE[c * 16]; // cm points to special char def in default font - else //else char is inside normal ascii range + else // else char is inside normal ascii range cm = &FontBuffer[c * 16]; // cm points to normal char def in active font pixMask = 0x80; - for (i = 0; i < 8; i++) { //for i == each pixel column + for (i = 0; i < 8; i++) { // for i == each pixel column pixBase = -1; - for (j = 0; j < 16; j++) { //for j == each pixel row - if ((pixBase < 0) && (cm[j] & pixMask)) { //if start of sequence + for (j = 0; j < 16; j++) { // for j == each pixel row + if ((pixBase < 0) && (cm[j] & pixMask)) { // if start of sequence pixBase = j; - } else if ((pixBase > -1) && !(cm[j] & pixMask)) { //if end of sequence + } else if ((pixBase > -1) && !(cm[j] & pixMask)) { // if end of sequence gsKit_prim_sprite(gsGlobal, x + i, y + pixBase - 1, x + i + 1, y + j - 1, 1, colour); pixBase = -1; } - } //ends for j == each pixel row - if (pixBase > -1) //if end of sequence including final row + } // ends for j == each pixel row + if (pixBase > -1) // if end of sequence including final row gsKit_prim_sprite(gsGlobal, x + i, y + pixBase - 1, x + i + 1, y + j - 1, 1, colour); pixMask >>= 1; - } //ends for i == each pixel column + } // ends for i == each pixel column } //------------------------------ -//endfunc drawChar +// endfunc drawChar //-------------------------------------------------------------- // draw a char using the ELISA font (16x16) void drawChar2(int n, int x, int y, u64 colour) @@ -1005,7 +1005,7 @@ void drawChar2(int n, int x, int y, u64 colour) } } //------------------------------ -//endfunc drawChar2 +// endfunc drawChar2 //-------------------------------------------------------------- // draw a string of characters, without shift-JIS support int printXY(const char *s, int x, int y, u64 colour, int draw, int space) @@ -1033,7 +1033,7 @@ int printXY(const char *s, int x, int y, u64 colour, int draw, int space) if (x > SCREEN_WIDTH - SCREEN_MARGIN - FONT_WIDTH) break; continue; - } //End if for normal character + } // End if for normal character // Here we got a sequence starting with 0xFF ('�') if ((c2 = (unsigned char)s[i++]) == 0) break; @@ -1041,7 +1041,7 @@ int printXY(const char *s, int x, int y, u64 colour, int draw, int space) continue; c1 = (c2 - '0') * 2 + 0x100; if (draw) { - //expand sequence �0=Circle �1=Cross �2=Square �3=Triangle �4=FilledBox + // expand sequence �0=Circle �1=Cross �2=Square �3=Triangle �4=FilledBox //"�:"=Pad_Right "�;"=Pad_Down "�<"=Pad_Left "�="=Pad_Up drawChar(c1, x, y, colour); x += 8; @@ -1056,7 +1056,7 @@ int printXY(const char *s, int x, int y, u64 colour, int draw, int space) return x; } //------------------------------ -//endfunc printXY +// endfunc printXY //-------------------------------------------------------------- // draw a string of characters, with shift-JIS support (only for gamesave titles) int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int draw) @@ -1068,7 +1068,7 @@ int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int draw) i = 0; while (s[i]) { - if ((s[i] & 0x80) && s[i + 1]) { //we have top bit and some more char ? + if ((s[i] & 0x80) && s[i + 1]) { // we have top bit and some more char ? // SJIS code = s[i++]; code = (code << 8) + s[i++]; @@ -1156,7 +1156,7 @@ int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int draw) drawChar('_', x, y, colour); x += 8; } - } else { //elisa font is not available + } else { // elisa font is not available ascii = 0xFF; if (code >> 8 == 0x81) ascii = sjis_lookup_81[code & 0x00FF]; @@ -1173,23 +1173,23 @@ int printXY_sjis(const unsigned char *s, int x, int y, u64 colour, int draw) } break; } - } else { //First char does not have top bit set or no following char + } else { // First char does not have top bit set or no following char if (draw) drawChar(s[i], x, y, colour); i++; x += 8; } if (x > SCREEN_WIDTH - SCREEN_MARGIN - FONT_WIDTH) { - //x=16; y=y+8; + // x=16; y=y+8; return x; } } return x; } //------------------------------ -//endfunc printXY_sjis +// endfunc printXY_sjis //-------------------------------------------------------------- -//translate a string from shift-JIS to ascii (for gamesave titles) +// translate a string from shift-JIS to ascii (for gamesave titles) char *transcpy_sjis(char *d, const unsigned char *s) { u8 ascii; @@ -1198,7 +1198,7 @@ char *transcpy_sjis(char *d, const unsigned char *s) for (i = 0, j = 0; s[i];) { code1 = s[i++]; - if ((code1 & 0x80) && s[i]) { //we have top bit and some more char (SJIS) ? + if ((code1 & 0x80) && s[i]) { // we have top bit and some more char (SJIS) ? // SJIS code2 = s[i++]; ascii = 0xFF; @@ -1211,73 +1211,73 @@ char *transcpy_sjis(char *d, const unsigned char *s) } else { d[j++] = '_'; } - } else { //First char lacks top bit set or no following char (non-SJIS) + } else { // First char lacks top bit set or no following char (non-SJIS) d[j++] = (char)code1; } - } //ends for - d[j] = '\0'; //terminate result string + } // ends for + d[j] = '\0'; // terminate result string return d; } //------------------------------ -//endfunc transcpy_sjis +// endfunc transcpy_sjis //-------------------------------------------------------------- -//WriteFont_C is used to save the current font as C source code -//Comment it out if not used +// WriteFont_C is used to save the current font as C source code +// Comment it out if not used /* int WriteFont_C(char *path_arg) { - u8 path[MAX_PATH]; - u8 text[80*2], char_info[80]; - u8 *p; - int ret, tst, i, fd=-1; - - ret=-1; tst=genFixPath(path_arg, path); - if(tst < 0) goto finish; - ret=-2; tst=genOpen(path,O_CREAT|O_WRONLY|O_TRUNC); - if(tst < 0) goto finish; - fd = tst; - sprintf(text, "unsigned char font_uLE[] = {\r\n"); - ret=-3; tst = genWrite(fd, text, strlen(text)); - if(tst != strlen(text)) goto finish; - for(i=0x000; i<0x10A; i++){ - p = font_uLE + i*16; - text[0] = '\0'; - if((i & 0x07) == 0) - sprintf(text, "//Font position 0x%03X\r\n", i); - if((i < 0x20) || (i>0x80 && i<0xA0)) - sprintf(char_info, "//char 0x%03X == '_' (free for use)", i); - else if(i < 0x100) - sprintf(char_info, "//char 0x%03X == '%c'", i, i); - else //(i > 0x0FF) - sprintf(char_info, "//char 0x%03X == special for uLE", i); - sprintf(text+strlen(text), - " 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, %s\r\n" - " 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X" - , p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7], char_info - , p[8],p[9], p[10],p[11], p[12],p[13], p[14],p[15] - ); - if(i<0x109) strcat(text, ","); - strcat(text, "\r\n"); - ret=-4; tst = genWrite(fd, text, strlen(text)); - if(tst != strlen(text)) break; - ret = 0; - } //ends for - if(ret == 0){ - sprintf(text, - "//Font position 0x%03X\r\n" - "}; //ends font_uLE\r\n", i); - ret=-5; tst = genWrite(fd, text, strlen(text)); - if(tst == strlen(text)) ret = 0; - } + u8 path[MAX_PATH]; + u8 text[80*2], char_info[80]; + u8 *p; + int ret, tst, i, fd=-1; + + ret=-1; tst=genFixPath(path_arg, path); + if(tst < 0) goto finish; + ret=-2; tst=genOpen(path,O_CREAT|O_WRONLY|O_TRUNC); + if(tst < 0) goto finish; + fd = tst; + sprintf(text, "unsigned char font_uLE[] = {\r\n"); + ret=-3; tst = genWrite(fd, text, strlen(text)); + if(tst != strlen(text)) goto finish; + for(i=0x000; i<0x10A; i++){ + p = font_uLE + i*16; + text[0] = '\0'; + if((i & 0x07) == 0) + sprintf(text, "//Font position 0x%03X\r\n", i); + if((i < 0x20) || (i>0x80 && i<0xA0)) + sprintf(char_info, "//char 0x%03X == '_' (free for use)", i); + else if(i < 0x100) + sprintf(char_info, "//char 0x%03X == '%c'", i, i); + else //(i > 0x0FF) + sprintf(char_info, "//char 0x%03X == special for uLE", i); + sprintf(text+strlen(text), + " 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, %s\r\n" + " 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X" + , p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7], char_info + , p[8],p[9], p[10],p[11], p[12],p[13], p[14],p[15] + ); + if(i<0x109) strcat(text, ","); + strcat(text, "\r\n"); + ret=-4; tst = genWrite(fd, text, strlen(text)); + if(tst != strlen(text)) break; + ret = 0; + } //ends for + if(ret == 0){ + sprintf(text, + "//Font position 0x%03X\r\n" + "}; //ends font_uLE\r\n", i); + ret=-5; tst = genWrite(fd, text, strlen(text)); + if(tst == strlen(text)) ret = 0; + } finish: - if(fd >= 0) genClose(fd); - sprintf(text,"Saving %s => %d\nChoose either option to continue", path, ret); - ynDialog(text); - return ret; + if(fd >= 0) genClose(fd); + sprintf(text,"Saving %s => %d\nChoose either option to continue", path, ret); + ynDialog(text); + return ret; } */ //------------------------------ -//endfunc WriteFont_C +// endfunc WriteFont_C //-------------------------------------------------------------- -//End of file: draw.c +// End of file: draw.c //-------------------------------------------------------------- diff --git a/src/editor.c b/src/editor.c index 957769db..bdb0519f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: editor.c +// File name: editor.c //-------------------------------------------------------------- #include "launchelf.h" @@ -94,7 +94,7 @@ static char *KEY = " 01ABCDEFGHIJKLM:; " " 67nopqrstuvwxyz[] " " 89+-=!#\\/?$%&@_^' "; // Virtual KeyBoard Matrix. -//Function Prototypes +// Function Prototypes static int MenuEditor(void); static void Virt_KeyBoard_Entry(void); static int KeyBoard_Entry(void); @@ -125,12 +125,12 @@ static int MenuEditor(void) menu_len = strlen(LNG(Windows)) > menu_len ? strlen(LNG(Windows)) : menu_len; menu_len = strlen(LNG(Exit)) > menu_len ? strlen(LNG(Exit)) : menu_len; - int menu_ch_w = menu_len + 1; //Total characters in longest menu string. - int menu_ch_h = NUM_MENU; //Total number of menu lines. - int mSprite_Y1 = 64; //Top edge of sprite. - int mSprite_X2 = SCREEN_WIDTH - 35; //Right edge of sprite. - int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; //Left edge of sprite - int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; //Bottom edge of sprite + int menu_ch_w = menu_len + 1; // Total characters in longest menu string. + int menu_ch_h = NUM_MENU; // Total number of menu lines. + int mSprite_Y1 = 64; // Top edge of sprite. + int mSprite_X2 = SCREEN_WIDTH - 35; // Right edge of sprite. + int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; // Left edge of sprite + int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; // Bottom edge of sprite memset(enable, TRUE, NUM_MENU); @@ -149,20 +149,20 @@ static int MenuEditor(void) if (enable[Menu_Sel] == TRUE) break; - event = 1; //event = initial entry. + event = 1; // event = initial entry. while (1) { - //Pad response section. + // Pad response section. waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP && Menu_Sel < NUM_MENU) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. do { Menu_Sel--; if (Menu_Sel < 0) Menu_Sel = NUM_MENU - 1; } while (!enable[Menu_Sel]); } else if (new_pad & PAD_DOWN && Menu_Sel < NUM_MENU) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. do { Menu_Sel++; if (Menu_Sel == NUM_MENU) @@ -171,14 +171,14 @@ static int MenuEditor(void) } else if ((new_pad & PAD_TRIANGLE) || (!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { return -1; } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event. + if (event || post_event) { // NB: We need to update two frame buffers per event. - //Display section. + // Display section. drawPopSprite(setting->color[COLOR_BACKGR], mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2); @@ -211,7 +211,7 @@ static int MenuEditor(void) if (Menu_Sel < NUM_MENU) drawChar(LEFT_CUR, mSprite_X1 + FONT_WIDTH, mSprite_Y1 + (FONT_HEIGHT / 2 + Menu_Sel * FONT_HEIGHT), setting->color[COLOR_TEXT]); - //Tooltip section. + // Tooltip section. x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], @@ -230,13 +230,13 @@ static int MenuEditor(void) "3:%s", LNG(OK), LNG(Cancel), LNG(Back)); printXY(tmp, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event). + } // ends if(event||post_event). drawScr(); post_event = event; event = 0; - } //ends while. + } // ends while. return Menu_Sel; -} //ends menu. +} // ends menu. //-------------------------------------------------------------- static void Virt_KeyBoard_Entry(void) { @@ -253,7 +253,7 @@ static void Virt_KeyBoard_Entry(void) if ((KeyBoard_Cur -= WFONTS) < 0) KeyBoard_Cur = 0; } - //ends Virtual KeyBoard move up. + // ends Virtual KeyBoard move up. } else if (new_pad & PAD_DOWN) { // Virtual KeyBoard move down. if (KeyBoard_Cur == WFONTS * HFONTS - 1) KeyBoard_Cur = WFONTS - 1; @@ -263,19 +263,19 @@ static void Virt_KeyBoard_Entry(void) if ((KeyBoard_Cur += WFONTS) > WFONTS * HFONTS - 1) KeyBoard_Cur = WFONTS * HFONTS - 1; } - //ends Virtual KeyBoard move down. + // ends Virtual KeyBoard move down. } else if (new_pad & PAD_LEFT) { // Virtual KeyBoard move left. if (!KeyBoard_Cur) KeyBoard_Cur = WFONTS * HFONTS - 1; else KeyBoard_Cur--; - //ends Virtual KeyBoard move left. + // ends Virtual KeyBoard move left. } else if (new_pad & PAD_RIGHT) { // Virtual KeyBoard move right. if (KeyBoard_Cur == WFONTS * HFONTS - 1) KeyBoard_Cur = 0; else KeyBoard_Cur++; - //ends Virtual KeyBoard move right. + // ends Virtual KeyBoard move right. } else if (new_pad & PAD_L2) { // Text move left. if (Editor_Cur > 0) Editor_Cur--; @@ -288,7 +288,7 @@ static void Virt_KeyBoard_Entry(void) } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { // Virtual KeyBoard Backspace if (Editor_Cur > 0) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Backspace at LF of CRLF must work after LF instead + Editor_Cur += 1; // Backspace at LF of CRLF must work after LF instead } if (Mark[MARK_ON]) { Mark[MARK_OUT] = Editor_Cur; @@ -302,19 +302,19 @@ static void Virt_KeyBoard_Entry(void) del1 = -Mark[MARK_SIZE], del2 = 0, del3 = -Mark[MARK_SIZE], del4 = -Mark[MARK_SIZE]; Mark[MARK_ON] = 0; } else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur - 1] == '\n' && Editor_Cur > 1 && TextBuffer[Active_Window][Editor_Cur - 2] == '\r') { - del1 = -2, del2 = 0, del3 = -2, del4 = -2; //Backspace CRLF + del1 = -2, del2 = 0, del3 = -2, del4 = -2; // Backspace CRLF } else { - del1 = -1, del2 = 0, del3 = -1, del4 = -1; //Backspace single char + del1 = -1, del2 = 0, del3 = -1, del4 = -1; // Backspace single char } Operation = -1; } - //ends Virtual KeyBoard Backspace + // ends Virtual KeyBoard Backspace } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { // Virtual KeyBoard Select. if (!KeyBoard_Cur) { // Virtual KeyBoard MARK. Mark[MARK_ON] = !Mark[MARK_ON]; if (Mark[MARK_ON]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Marking at LF of CRLF must start at CR instead + Editor_Cur -= 1; // Marking at LF of CRLF must start at CR instead } if (Mark[MARK_COPY] || Mark[MARK_CUT]) free(TextBuffer[EDIT]); @@ -324,11 +324,11 @@ static void Virt_KeyBoard_Entry(void) Mark[MARK_IN] = Mark[MARK_OUT] = Editor_Cur; } Mark[MARK_START] = 1; - //ends Virtual KeyBoard MARK. + // ends Virtual KeyBoard MARK. } else if (KeyBoard_Cur == WFONTS) { // Virtual KeyBoard COPY. if (Mark[MARK_ON]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Mark end at LF of CRLF must include LF as well + Editor_Cur += 1; // Mark end at LF of CRLF must include LF as well } Mark[MARK_OUT] = Editor_Cur; if (Mark[MARK_OUT] < Mark[MARK_IN]) { @@ -345,11 +345,11 @@ static void Virt_KeyBoard_Entry(void) TextBuffer[EDIT][i] = TextBuffer[Active_Window][i + Mark[MARK_IN]]; Mark[MARK_COPY] = 1, Mark[MARK_CUT] = 0, Mark[MARK_ON] = 0; } - //ends Virtual KeyBoard COPY. + // ends Virtual KeyBoard COPY. } else if (KeyBoard_Cur == 2 * WFONTS) { // Virtual KeyBoard CUT. if (Mark[MARK_ON]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Mark end at LF of CRLF must include LF as well + Editor_Cur += 1; // Mark end at LF of CRLF must include LF as well } Mark[MARK_OUT] = Editor_Cur; if (Mark[MARK_OUT] < Mark[MARK_IN]) { @@ -370,7 +370,7 @@ static void Virt_KeyBoard_Entry(void) } abort: Mark[MARK_TMP] = 0; // just for compiler warning. - //ends Virtual KeyBoard CUT. + // ends Virtual KeyBoard CUT. } else if (KeyBoard_Cur == 3 * WFONTS) { // Virtual KeyBoard PASTE. if (Mark[MARK_COPY] || Mark[MARK_CUT]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n') { @@ -380,7 +380,7 @@ static void Virt_KeyBoard_Entry(void) ins1 = Mark[MARK_SIZE], ins2 = Mark[MARK_SIZE], ins3 = Mark[MARK_SIZE], ins4 = 0, ins5 = Mark[MARK_SIZE]; Operation = 1; } - //ends Virtual KeyBoard PASTE. + // ends Virtual KeyBoard PASTE. } else if (KeyBoard_Cur == 4 * WFONTS) { // Virtual KeyBoard HOME. Editor_Home = 1; } else if (KeyBoard_Cur == 1) { // Virtual KeyBoard LINE UP. @@ -405,37 +405,37 @@ static void Virt_KeyBoard_Entry(void) } else if (KeyBoard_Cur == 5 * WFONTS - 1) { // Virtual KeyBoard RETURN. if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Entry at LF of CRLF must work at CR instead + Editor_Cur -= 1; // Entry at LF of CRLF must work at CR instead } if (Editor_Insert || TextBuffer[Active_Window][Editor_Cur] == '\0') if (Editor_RetMode == OTHER) - ins1 = 2, ins2 = 0, ins3 = 2, ins4 = 0, ins5 = 2; //Insert CRLF + ins1 = 2, ins2 = 0, ins3 = 2, ins4 = 0, ins5 = 2; // Insert CRLF else - ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; //Insert LF/CR - else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { //OWrite Return at CRLF + ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; // Insert LF/CR + else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { // OWrite Return at CRLF if (Editor_RetMode == OTHER) - ins1 = 0, ins2 = 0, ins3 = 2, ins4 = 2, ins5 = 2; //OWrite CRLF at CRLF + ins1 = 0, ins2 = 0, ins3 = 2, ins4 = 2, ins5 = 2; // OWrite CRLF at CRLF else - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; //OWrite LF/CR at CRLF - } else { //OWrite return at normal char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; // OWrite LF/CR at CRLF + } else { // OWrite return at normal char if (Editor_RetMode == OTHER) - ins1 = 1, ins2 = 0, ins3 = 2, ins4 = 1, ins5 = 2; //OWrite CRLF at char + ins1 = 1, ins2 = 0, ins3 = 2, ins4 = 1, ins5 = 2; // OWrite CRLF at char else - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; //OWrite LF/CR at char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; // OWrite LF/CR at char } Operation = 2; - //ends Virtual KeyBoard RETURN. + // ends Virtual KeyBoard RETURN. } else { // Virtual KeyBoard Any other char + Space + Tabulation. if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Entry at LF of CRLF must work at CR instead + Editor_Cur -= 1; // Entry at LF of CRLF must work at CR instead } if (Editor_Insert || TextBuffer[Active_Window][Editor_Cur] == '\0') { - ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; //Insert char normally + ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; // Insert char normally } else { - if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { //OWrite char at CRLF - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; //OWrite at CR of CRLF - } else { //OWrite return at normal char - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; //OWrite normal char + if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { // OWrite char at CRLF + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; // OWrite at CR of CRLF + } else { // OWrite return at normal char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; // OWrite normal char } } if (KeyBoard_Cur == 3 * WFONTS - 1) // Tabulation. @@ -445,13 +445,13 @@ static void Virt_KeyBoard_Entry(void) else // Any other char. Operation = 5; } - //ends Virtual KeyBoard Select. + // ends Virtual KeyBoard Select. } if (Operation > 0) { // Perform Add Char / Paste. Can Be Simplify??? TextBuffer[TMP] = malloc(TextSize[Active_Window] + ins1 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[TMP], TextBuffer[Active_Window]); - //memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); + // memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); TextBuffer[Active_Window] = malloc(TextSize[Active_Window] + ins1 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[Active_Window], TextBuffer[TMP]); } @@ -465,11 +465,11 @@ static void Virt_KeyBoard_Entry(void) TextBuffer[Active_Window][Editor_Cur + del1] = '\0'; strcat(TextBuffer[Active_Window], TextBuffer[TMP] + (Editor_Cur + del2)); strcpy(TextBuffer[TMP], TextBuffer[Active_Window]); - //memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); TextBuffer[Active_Window] = malloc(TextSize[Active_Window] + del3 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[Active_Window], TextBuffer[TMP]); - //memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[TMP]); Editor_Cur += del3, TextSize[Active_Window] += del4; t = 0; @@ -500,7 +500,7 @@ static void Virt_KeyBoard_Entry(void) common: TextBuffer[Active_Window][Editor_Cur + ins3] = '\0'; strcat(TextBuffer[Active_Window], TextBuffer[TMP] + (Editor_Cur + ins4)); - //memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[TMP]); Editor_Cur += ins5, TextSize[Active_Window] += ins1; t = 0; @@ -508,7 +508,7 @@ static void Virt_KeyBoard_Entry(void) } } //------------------------------ -//endfunc Virt_KeyBoard_Entry +// endfunc Virt_KeyBoard_Entry //-------------------------------------------------------------- static int KeyBoard_Entry(void) { @@ -517,7 +517,7 @@ static int KeyBoard_Entry(void) Operation = 0; - if (PS2KbdRead(&KeyPress)) { //KeyBoard Response Section. + if (PS2KbdRead(&KeyPress)) { // KeyBoard Response Section. ret = 1; // Equal To event |= pad command. @@ -552,7 +552,7 @@ static int KeyBoard_Entry(void) else if (KeyPress == 0x26) { // Key Delete. if (Editor_Cur < Editor_nChar) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Delete at LF of CRLF must work at CR instead + Editor_Cur -= 1; // Delete at LF of CRLF must work at CR instead } if (Mark[MARK_ON]) { Mark[MARK_OUT] = Editor_Cur; @@ -565,12 +565,12 @@ static int KeyBoard_Entry(void) Mark[MARK_SIZE] = Mark[MARK_OUT] - Mark[MARK_IN]; del1 = -Mark[MARK_SIZE], del2 = 0, del3 = -Mark[MARK_SIZE], del4 = -Mark[MARK_SIZE]; Mark[MARK_ON] = 0; - } else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { //Delete at CRLF - del1 = 0, del2 = 2, del3 = 0, del4 = -2; //delete CRLF + } else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { // Delete at CRLF + del1 = 0, del2 = 2, del3 = 0, del4 = -2; // delete CRLF } else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n') { del1 = -1, del2 = 1, del3 = -1, del4 = -2; } else { - del1 = 0, del2 = 1, del3 = 0, del4 = -1; //delete single char + del1 = 0, del2 = 1, del3 = 0, del4 = -1; // delete single char } Operation = -1; } @@ -587,7 +587,7 @@ static int KeyBoard_Entry(void) Mark[MARK_ON] = !Mark[MARK_ON]; if (Mark[MARK_ON]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Marking at LF of CRLF must start at CR instead + Editor_Cur -= 1; // Marking at LF of CRLF must start at CR instead } if (Mark[MARK_COPY] || Mark[MARK_CUT]) free(TextBuffer[EDIT]); @@ -597,10 +597,10 @@ static int KeyBoard_Entry(void) Mark[MARK_IN] = Mark[MARK_OUT] = Editor_Cur; } Mark[MARK_START] = 1; - //ends Key Ctrl+b MARK. + // ends Key Ctrl+b MARK. } else if (KeyPress == 0x03) { // Key Ctrl+c COPY. if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Mark end at LF of CRLF must include LF as well + Editor_Cur += 1; // Mark end at LF of CRLF must include LF as well } if (Mark[MARK_ON]) { Mark[MARK_OUT] = Editor_Cur; @@ -618,11 +618,11 @@ static int KeyBoard_Entry(void) TextBuffer[EDIT][i] = TextBuffer[Active_Window][i + Mark[MARK_IN]]; Mark[MARK_COPY] = 1, Mark[MARK_CUT] = 0, Mark[MARK_ON] = 0, Mark[MARK_TMP] = 0; } - //ends Key Ctrl+c COPY. + // ends Key Ctrl+c COPY. } else if (KeyPress == 0x18) { // Key Ctrl+x CUT. if (Mark[MARK_ON]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Mark end at LF of CRLF must include LF as well + Editor_Cur += 1; // Mark end at LF of CRLF must include LF as well } Mark[MARK_OUT] = Editor_Cur; if (Mark[MARK_OUT] < Mark[MARK_IN]) { @@ -641,7 +641,7 @@ static int KeyBoard_Entry(void) Mark[MARK_CUT] = 1, Mark[MARK_COPY] = 0, Mark[MARK_ON] = 0, Mark[MARK_TMP] = 0; Operation = -2; } - //ends Key Ctrl+x CUT. + // ends Key Ctrl+x CUT. } else if (KeyPress == 0x16) { // Key Ctrl+v PASTE. if (Mark[MARK_COPY] || Mark[MARK_CUT]) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n') { @@ -651,11 +651,11 @@ static int KeyBoard_Entry(void) ins1 = Mark[MARK_SIZE], ins2 = Mark[MARK_SIZE], ins3 = Mark[MARK_SIZE], ins4 = 0, ins5 = Mark[MARK_SIZE]; Operation = 1; } - //ends Key Ctrl+v PASTE. + // ends Key Ctrl+v PASTE. } else if (KeyPress == 0x07) { // Key BackSpace. if (Editor_Cur > 0) { if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur += 1; //Backspace at LF of CRLF must work after LF + Editor_Cur += 1; // Backspace at LF of CRLF must work after LF } if (Mark[MARK_ON]) { Mark[MARK_OUT] = Editor_Cur; @@ -669,47 +669,47 @@ static int KeyBoard_Entry(void) del1 = -Mark[MARK_SIZE], del2 = 0, del3 = -Mark[MARK_SIZE], del4 = -Mark[MARK_SIZE]; Mark[MARK_ON] = 0; } else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur - 1] == '\n' && Editor_Cur > 1 && TextBuffer[Active_Window][Editor_Cur - 2] == '\r') { - del1 = -2, del2 = 0, del3 = -2, del4 = -2; //Backspace CRLF + del1 = -2, del2 = 0, del3 = -2, del4 = -2; // Backspace CRLF } else { - del1 = -1, del2 = 0, del3 = -1, del4 = -1; //Backspace single char + del1 = -1, del2 = 0, del3 = -1, del4 = -1; // Backspace single char } Operation = -3; } - //ends Key BackSpace. + // ends Key BackSpace. } else if (KeyPress == 0x0A) { // Key Return. if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Entry at LF of CRLF must work at CR instead + Editor_Cur -= 1; // Entry at LF of CRLF must work at CR instead } if (Editor_Insert || TextBuffer[Active_Window][Editor_Cur] == '\0') if (Editor_RetMode == OTHER) - ins1 = 2, ins2 = 0, ins3 = 2, ins4 = 0, ins5 = 2; //Insert CRLF + ins1 = 2, ins2 = 0, ins3 = 2, ins4 = 0, ins5 = 2; // Insert CRLF else - ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; //Insert LF/CR - else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { //OWrite Return at CRLF + ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; // Insert LF/CR + else if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { // OWrite Return at CRLF if (Editor_RetMode == OTHER) - ins1 = 0, ins2 = 0, ins3 = 2, ins4 = 2, ins5 = 2; //OWrite CRLF at CRLF + ins1 = 0, ins2 = 0, ins3 = 2, ins4 = 2, ins5 = 2; // OWrite CRLF at CRLF else - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; //OWrite LF/CR at CRLF - } else { //OWrite return at normal char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; // OWrite LF/CR at CRLF + } else { // OWrite return at normal char if (Editor_RetMode == OTHER) - ins1 = 1, ins2 = 0, ins3 = 2, ins4 = 1, ins5 = 2; //OWrite CRLF at char + ins1 = 1, ins2 = 0, ins3 = 2, ins4 = 1, ins5 = 2; // OWrite CRLF at char else - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; //OWrite LF/CR at char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; // OWrite LF/CR at char } Operation = 2; - //ends Key Return. + // ends Key Return. } else { // All Other Keys. if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\n' && Editor_Cur > 0 && TextBuffer[Active_Window][Editor_Cur - 1] == '\r') { - Editor_Cur -= 1; //Entry at LF of CRLF must work at CR instead + Editor_Cur -= 1; // Entry at LF of CRLF must work at CR instead } if (Editor_Insert || TextBuffer[Active_Window][Editor_Cur] == '\0') { - ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; //Insert char normally + ins1 = 1, ins2 = 0, ins3 = 1, ins4 = 0, ins5 = 1; // Insert char normally } else { - if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { //OWrite char at CRLF - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; //OWrite at CR of CRLF - } else { //OWrite return at normal char - ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; //OWrite normal char + if (TextMode[Active_Window] == OTHER && TextBuffer[Active_Window][Editor_Cur] == '\r' && TextBuffer[Active_Window][Editor_Cur + 1] == '\n') { // OWrite char at CRLF + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 2, ins5 = 1; // OWrite at CR of CRLF + } else { // OWrite return at normal char + ins1 = 0, ins2 = 0, ins3 = 1, ins4 = 1, ins5 = 1; // OWrite normal char } } Operation = 3; @@ -719,7 +719,7 @@ static int KeyBoard_Entry(void) if (Operation > 0) { // Perform Add Char / Paste. Can Be Simplify??? TextBuffer[TMP] = malloc(TextSize[Active_Window] + ins1 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[TMP], TextBuffer[Active_Window]); - //memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); + // memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); TextBuffer[Active_Window] = malloc(TextSize[Active_Window] + ins1 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[Active_Window], TextBuffer[TMP]); } @@ -735,11 +735,11 @@ static int KeyBoard_Entry(void) TextBuffer[Active_Window][Editor_Cur + del1] = '\0'; strcat(TextBuffer[Active_Window], TextBuffer[TMP] + (Editor_Cur + del2)); strcpy(TextBuffer[TMP], TextBuffer[Active_Window]); - //memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[Active_Window], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Active_Window]); TextBuffer[Active_Window] = malloc(TextSize[Active_Window] + del3 + 256); // 256 To Avoid Crash 256??? strcpy(TextBuffer[Active_Window], TextBuffer[TMP]); - //memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[TMP]); Editor_Cur += del3, TextSize[Active_Window] += del4; t = 0; @@ -763,7 +763,7 @@ static int KeyBoard_Entry(void) common: TextBuffer[Active_Window][Editor_Cur + ins3] = '\0'; strcat(TextBuffer[Active_Window], TextBuffer[TMP] + (Editor_Cur + ins4)); - //memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[TMP], 0, TextSize[Active_Window]+256); // 256 To Avoid Crash 256??? free(TextBuffer[TMP]); Editor_Cur += ins5, TextSize[Active_Window] += ins1; t = 0; @@ -772,11 +772,11 @@ static int KeyBoard_Entry(void) abort: KeyPress = '\0'; - } //ends if(PS2KbdRead(&KeyPress)). + } // ends if(PS2KbdRead(&KeyPress)). return ret; } //------------------------------ -//endfunc KeyBoard_Entry +// endfunc KeyBoard_Entry //-------------------------------------------------------------- static void Editor_Rules(void) { @@ -900,39 +900,39 @@ static int Windows_Selector(void) int x, y, i, Window_Sel = Active_Window; int event, post_event = 0; - int Window_ch_w = 36; //Total characters in longest Window Name. - int Window_ch_h = 10; //Total number of Window Menu lines. - int wSprite_Y1 = 200; //Top edge of sprite. - int wSprite_X2 = SCREEN_WIDTH - 35; //Right edge of sprite. - int wSprite_X1 = wSprite_X2 - (Window_ch_w + 3) * FONT_WIDTH - 3; //Left edge of sprite. - int wSprite_Y2 = wSprite_Y1 + (Window_ch_h + 1) * FONT_HEIGHT + 3; //Bottom edge of sprite. + int Window_ch_w = 36; // Total characters in longest Window Name. + int Window_ch_h = 10; // Total number of Window Menu lines. + int wSprite_Y1 = 200; // Top edge of sprite. + int wSprite_X2 = SCREEN_WIDTH - 35; // Right edge of sprite. + int wSprite_X1 = wSprite_X2 - (Window_ch_w + 3) * FONT_WIDTH - 3; // Left edge of sprite. + int wSprite_Y2 = wSprite_Y1 + (Window_ch_h + 1) * FONT_HEIGHT + 3; // Bottom edge of sprite. char tmp[64]; - event = 1; //event = initial entry. + event = 1; // event = initial entry. while (1) { - //Pad response section. + // Pad response section. waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. if ((Window_Sel--) <= 0) Window_Sel = 9; } else if (new_pad & PAD_DOWN) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. if ((Window_Sel++) >= 9) Window_Sel = 0; } else if ((new_pad & PAD_TRIANGLE) || (!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { return -1; } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event. + if (event || post_event) { // NB: We need to update two frame buffers per event. - //Display section. + // Display section. drawPopSprite(setting->color[COLOR_BACKGR], wSprite_X1, wSprite_Y1, wSprite_X2, wSprite_Y2); @@ -957,7 +957,7 @@ static int Windows_Selector(void) if (Window_Sel <= 10) drawChar(LEFT_CUR, wSprite_X1 + FONT_WIDTH, wSprite_Y1 + (FONT_HEIGHT / 2 + Window_Sel * FONT_HEIGHT), setting->color[COLOR_TEXT]); - //Tooltip section. + // Tooltip section. x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], @@ -976,13 +976,13 @@ static int Windows_Selector(void) "3:%s", LNG(OK), LNG(Cancel), LNG(Back)); printXY(tmp, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event). + } // ends if(event||post_event). drawScr(); post_event = event; event = 0; - } //ends while. + } // ends while. return Window_Sel; -} //ends Window_Selector. +} // ends Window_Selector. //-------------------------------------------------------------- static void Init(void) { @@ -1115,7 +1115,7 @@ static void Close(int Win) { char msg[MAX_PATH]; - //memset(TextBuffer[Win], 0, TextSize[Win]+256); // 256 To Avoid Crash 256??? + // memset(TextBuffer[Win], 0, TextSize[Win]+256); // 256 To Avoid Crash 256??? free(TextBuffer[Win]); if (Window[Win][CREATED]) @@ -1198,10 +1198,10 @@ static void Save_As(int Win) drawMsg(LNG(Enter_File_Name)); if (keyboard(tmp, 36) > 0) { - //strcat(Path[Win], tmp); //This is what we want, but malfunctions for MC! - //sprintf(&Path[Win][strlen(Path[Win])], "%s", tmp); //This always works - strcpy(&Path[Win][strlen(Path[Win])], tmp); //And this one works too - //Note that the strcat call SHOULD have done the same thing, but won't. + // strcat(Path[Win], tmp); //This is what we want, but malfunctions for MC! + // sprintf(&Path[Win][strlen(Path[Win])], "%s", tmp); //This always works + strcpy(&Path[Win][strlen(Path[Win])], tmp); // And this one works too + // Note that the strcat call SHOULD have done the same thing, but won't. } else goto abort; @@ -1274,7 +1274,7 @@ void TextEditor(char *path) t = 0; - event = 1; //event = initial entry. + event = 1; // event = initial entry. Rows_Width = (SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS - 26 - Menu_start_x) / FONT_WIDTH; Rows_Num = (Menu_end_y - Menu_start_y) / FONT_HEIGHT; @@ -1297,11 +1297,11 @@ void TextEditor(char *path) while (1) { - //Pad response section. + // Pad response section. waitPadReady(0, 0); if (readpad_no_KB()) { if (new_pad) { - event |= 2; //event |= pad command. + event |= 2; // event |= pad command. } if (!KeyBoard_Active) { // Pad Response Without KeyBoard. if (new_pad & PAD_UP) { // Text move up. @@ -1441,7 +1441,7 @@ void TextEditor(char *path) goto exit; } } - } //ends pad response section. + } // ends pad response section. if (!Num_Window) Editor_Start++; @@ -1466,11 +1466,11 @@ void TextEditor(char *path) t++; if (t & 0x0F) - event |= 4; //repetitive timer event. + event |= 4; // repetitive timer event. - if (event || post_event) { //NB: We need to update two frame buffers per event. + if (event || post_event) { // NB: We need to update two frame buffers per event. - //Display section. + // Display section. clrScr(setting->color[COLOR_BACKGR]); if (TextSize[Active_Window] == 0) @@ -1480,7 +1480,7 @@ void TextEditor(char *path) SCREEN_MARGIN, Frame_start_y, SCREEN_WIDTH - SCREEN_MARGIN, Frame_end_y); - if (KeyBoard_Active) { //Display Virtual KeyBoard Section. + if (KeyBoard_Active) { // Display Virtual KeyBoard Section. drawPopSprite(setting->color[COLOR_BACKGR], SCREEN_MARGIN, KEY_Y + 6, @@ -1560,7 +1560,7 @@ void TextEditor(char *path) setting->color[COLOR_TEXT]); } - //Virtual KeyBoard Cursor positioning section. + // Virtual KeyBoard Cursor positioning section. if (!KeyBoard_Cur || KeyBoard_Cur % WFONTS == 0) x = KEY_X + 2 + 4 - 128; else if (KeyBoard_Cur == 1 || (KeyBoard_Cur - 1) % WFONTS == 0) @@ -1585,7 +1585,7 @@ void TextEditor(char *path) for (j = 0; j < Editor_nRowsWidth[i]; j++) { Mark[MARK_COLOR] = 0; - if (Mark[MARK_ON] && Mark[MARK_PRINT] > 0) { //Mark Text. + if (Mark[MARK_ON] && Mark[MARK_PRINT] > 0) { // Mark Text. if (Mark[MARK_SIZE] > 0) { if (Top_Width + tmpLen + j == (Editor_Cur - Mark[MARK_PRINT])) { drawOpSprite(COL_MARK_BG, x, y - 1, x + FONT_WIDTH, y + FONT_HEIGHT - 1); @@ -1602,7 +1602,7 @@ void TextEditor(char *path) } } // end mark. - if (Top_Width + tmpLen + j == Editor_Cur) { //Text Cursor. + if (Top_Width + tmpLen + j == Editor_Cur) { // Text Cursor. if (Editor_Insert) color = COL_CUR_INSERT; else @@ -1626,7 +1626,7 @@ void TextEditor(char *path) Editor_TextEnd = 1; } else { ch = TextBuffer[Active_Window][Top_Width + tmpLen + j]; - if (Mark[MARK_ON] && Mark[MARK_COLOR]) //Text Color Black / White If Mark. + if (Mark[MARK_ON] && Mark[MARK_COLOR]) // Text Color Black / White If Mark. color = COL_MARK_TEXT; else color = COL_NORM_TEXT; @@ -1645,9 +1645,9 @@ void TextEditor(char *path) x = Menu_start_x; y += FONT_HEIGHT; - } //ends for, so all editor Rows_Num were fixed above. + } // ends for, so all editor Rows_Num were fixed above. end: - if (Editor_nRowsNum > Rows_Num) { //if more lines than available Rows_Num, use scrollbar. + if (Editor_nRowsNum > Rows_Num) { // if more lines than available Rows_Num, use scrollbar. if (KeyBoard_Active) { drawFrame(SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 8, Frame_start_y, SCREEN_WIDTH - SCREEN_MARGIN, KEY_Y + 6, setting->color[COLOR_FRAME]); @@ -1664,12 +1664,12 @@ void TextEditor(char *path) drawOpSprite(setting->color[COLOR_FRAME], SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 6, (y0 + Menu_start_y - 2), SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 2, (y1 + Menu_start_y - 6)); - } //ends clause for scrollbar with KeyBoard. - } //ends clause for scrollbar. + } // ends clause for scrollbar with KeyBoard. + } // ends clause for scrollbar. - //Tooltip section. + // Tooltip section. tmp[0] = '\0', tmp1[0] = '\0', tmp2[0] = '\0'; - if (KeyBoard_Active) { //Display Virtual KeyBoard Tooltip. + if (KeyBoard_Active) { // Display Virtual KeyBoard Tooltip. if (swapKeys) sprintf(tmp1, "R1:%s \xFF" "3:%s \xFF" @@ -1684,7 +1684,7 @@ void TextEditor(char *path) "1:%s L2:%s R2:%s Sel:%s", LNG(Menu), LNG(Exit), LNG(Sel), LNG(BackSpace), LNG(Left), LNG(Right), LNG(Close_KB)); - } else if (setting->usbkbd_used) { //Display KeyBoard Tooltip. + } else if (setting->usbkbd_used) { // Display KeyBoard Tooltip. if (Window[Active_Window][OPENED]) { if (Mark[MARK_ON]) sprintf(tmp1, "F1/R1:%s Esc/\xFF" @@ -1712,7 +1712,7 @@ void TextEditor(char *path) sprintf(tmp1, "F1/R1:%s Esc/\xFF" "3:%s", LNG(Menu), LNG(Exit)); - } else { //Display Basic Tooltip. + } else { // Display Basic Tooltip. if (Window[Active_Window][OPENED]) sprintf(tmp1, "R1:%s \xFF" "3:%s Select:%s", @@ -1729,14 +1729,14 @@ void TextEditor(char *path) else strcpy(tmp, LNG(PS2_TEXT_EDITOR)); setScrTmp(tmp, tmp1); - } //ends if(event||post_event). + } // ends if(event||post_event). drawScr(); post_event = event; event = 0; - } //ends while. + } // ends while. return; } //-------------------------------------------------------------- -//End of file: editor.c +// End of file: editor.c //-------------------------------------------------------------- diff --git a/src/elf.c b/src/elf.c index 59ee669b..ace0d824 100644 --- a/src/elf.c +++ b/src/elf.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: elf.c +// File name: elf.c //-------------------------------------------------------------- #include "launchelf.h" @@ -43,9 +43,9 @@ typedef struct u32 align; } elf_pheader_t; //-------------------------------------------------------------- -//End of data declarations +// End of data declarations //-------------------------------------------------------------- -//Start of function code +// Start of function code //-------------------------------------------------------------- // checkELFheader Tests for valid ELF file // Modified version of loader from Independence @@ -61,7 +61,7 @@ int checkELFheader(char *path) strcpy(fullpath, path); if (!strncmp(fullpath, "mc", 2) || !strncmp(fullpath, "vmc", 3) || !strncmp(fullpath, "rom", 3) || !strncmp(fullpath, "cdrom", 5) || !strncmp(fullpath, "cdfs", 4)) { - ; //fullpath is already correct + ; // fullpath is already correct } else if (!strncmp(fullpath, "hdd0:", 5)) { p = &path[5]; if (*p == '/') @@ -96,7 +96,7 @@ int checkELFheader(char *path) if (path[5] == '/') strcpy(fullpath + 5, path + 6); } else { - return 0; //return 0 for unrecognized device + return 0; // return 0 for unrecognized device } if ((fd = genOpen(fullpath, O_RDONLY)) < 0) goto error; @@ -112,12 +112,12 @@ int checkELFheader(char *path) if ((_lw((u32)&eh->ident) != ELF_MAGIC) || eh->type != 2) goto error; - return 1; //return 1 for successful check + return 1; // return 1 for successful check error: - return -1; //return -1 for failed check + return -1; // return -1 for failed check } //------------------------------ -//End of func: int checkELFheader(const char *path) +// End of func: int checkELFheader(const char *path) //-------------------------------------------------------------- // RunLoaderElf loads LOADER.ELF from program memory and passes // args of selected ELF and partition to it @@ -135,14 +135,14 @@ void RunLoaderElf(char *filename, char *party) if ((!strncmp(party, "hdd0:", 5)) && (!strncmp(filename, "pfs0:", 5))) { if (0 > fileXioMount("pfs0:", party, FIO_MT_RDONLY)) { - //Some error occurred, it could be due to something else having used pfs0 - unmountParty(0); //So we try unmounting pfs0, to try again + // Some error occurred, it could be due to something else having used pfs0 + unmountParty(0); // So we try unmounting pfs0, to try again if (0 > fileXioMount("pfs0:", party, FIO_MT_RDONLY)) - return; //If it still fails, we have to give up... + return; // If it still fails, we have to give up... } - //If a path to a file on PFS is specified, change it to the standard format. - //hdd0:partition:pfs:path/to/file + // If a path to a file on PFS is specified, change it to the standard format. + // hdd0:partition:pfs:path/to/file if (strncmp(filename, "pfs0:", 5) == 0) { sprintf(bootpath, "%s:pfs:%s", party, &filename[5]); } else { @@ -154,14 +154,14 @@ void RunLoaderElf(char *filename, char *party) #ifdef DVRP } else if ((!strncmp(party, "dvr_hdd0:", 9)) && (!strncmp(filename, "dvr_pfs0:", 9))) { if (0 > fileXioMount("dvr_pfs0:", party, FIO_MT_RDONLY)) { - //Some error occurred, it could be due to something else having used pfs0 - unmountDVRPParty(0); //So we try unmounting pfs0, to try again + // Some error occurred, it could be due to something else having used pfs0 + unmountDVRPParty(0); // So we try unmounting pfs0, to try again if (0 > fileXioMount("dvr_pfs0:", party, FIO_MT_RDONLY)) - return; //If it still fails, we have to give up... + return; // If it still fails, we have to give up... } - //If a path to a file on PFS is specified, change it to the standard format. - //dvr_hdd0:partition:pfs:path/to/file + // If a path to a file on PFS is specified, change it to the standard format. + // dvr_hdd0:partition:pfs:path/to/file if (strncmp(filename, "dvr_pfs0:", 9) == 0) { sprintf(bootpath, "%s:pfs:%s", party, &filename[9]); } else { @@ -184,7 +184,7 @@ void RunLoaderElf(char *filename, char *party) eph = (elf_pheader_t *)(boot_elf + eh->phoff); /* Scan through the ELF's program headers and copy them into RAM, then - zero out any non-loaded regions. */ + zero out any non-loaded regions. */ for (i = 0; i < eh->phnum; i++) { if (eph[i].type != ELF_PT_LOAD) continue; @@ -205,7 +205,7 @@ void RunLoaderElf(char *filename, char *party) ExecPS2((void *)eh->entry, NULL, 2, argv); } //------------------------------ -//End of func: void RunLoaderElf(char *filename, char *party) +// End of func: void RunLoaderElf(char *filename, char *party) //-------------------------------------------------------------- -//End of file: elf.c +// End of file: elf.c //-------------------------------------------------------------- diff --git a/src/filer.c b/src/filer.c index ef1d1be7..8bbf7c78 100644 --- a/src/filer.c +++ b/src/filer.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: filer.c +// File name: filer.c //-------------------------------------------------------------- #include "launchelf.h" @@ -14,15 +14,15 @@ typedef struct unsigned short year; // date/time (year) } PS2TIME __attribute__((aligned(2))); -#define MC_SFI 0xFEED //flag value used for mcSetFileInfo at MC file restoration +#define MC_SFI 0xFEED // flag value used for mcSetFileInfo at MC file restoration -#define MC_ATTR_norm_folder 0x8427 //Normal folder on PS2 MC -#define MC_ATTR_prot_folder 0x842F //Protected folder on PS2 MC -#define MC_ATTR_PS1_folder 0x9027 //PS1 save folder on PS2 MC -#define MC_ATTR_norm_file 0x8497 //file (PS2/PS1) on PS2 MC -#define MC_ATTR_PS1_file 0x9417 //PS1 save file on PS1 MC +#define MC_ATTR_norm_folder 0x8427 // Normal folder on PS2 MC +#define MC_ATTR_prot_folder 0x842F // Protected folder on PS2 MC +#define MC_ATTR_PS1_folder 0x9027 // PS1 save folder on PS2 MC +#define MC_ATTR_norm_file 0x8497 // file (PS2/PS1) on PS2 MC +#define MC_ATTR_PS1_file 0x9417 // PS1 save file on PS1 MC -#define IOCTL_RENAME 0xFEEDC0DE //Ioctl request code for Rename function +#define IOCTL_RENAME 0xFEEDC0DE // Ioctl request code for Rename function enum { COPY, @@ -42,30 +42,30 @@ enum { NUM_MENU } R1_menu_enum; -#define PM_NORMAL 0 //PasteMode value for normal copies -#define PM_MC_BACKUP 1 //PasteMode value for gamesave backup from MC -#define PM_MC_RESTORE 2 //PasteMode value for gamesave restore to MC -#define PM_PSU_BACKUP 3 //PasteMode value for gamesave backup from MC to PSU -#define PM_PSU_RESTORE 4 //PasteMode value for gamesave restore to MC from PSU -#define PM_RENAME 5 //PasteMode value for normal copies with new names -#define MAX_RECURSE 16 //Maximum folder recursion for MC Backup/Restore +#define PM_NORMAL 0 // PasteMode value for normal copies +#define PM_MC_BACKUP 1 // PasteMode value for gamesave backup from MC +#define PM_MC_RESTORE 2 // PasteMode value for gamesave restore to MC +#define PM_PSU_BACKUP 3 // PasteMode value for gamesave backup from MC to PSU +#define PM_PSU_RESTORE 4 // PasteMode value for gamesave restore to MC from PSU +#define PM_RENAME 5 // PasteMode value for normal copies with new names +#define MAX_RECURSE 16 // Maximum folder recursion for MC Backup/Restore -int PasteProgress_f = 0; //Flags progress report having been made in Pasting -int PasteMode; //Top-level PasteMode flag -int PM_flag[MAX_RECURSE]; //PasteMode flag for each 'copy' recursion level -int PM_file[MAX_RECURSE]; //PasteMode attribute file descriptors +int PasteProgress_f = 0; // Flags progress report having been made in Pasting +int PasteMode; // Top-level PasteMode flag +int PM_flag[MAX_RECURSE]; // PasteMode flag for each 'copy' recursion level +int PM_file[MAX_RECURSE]; // PasteMode attribute file descriptors char mountedParty[MOUNT_LIMIT][MAX_NAME]; int latestMount = -1; -int vmcMounted[2] = {0, 0}; //flags true for mounted VMC false for unmounted -int vmc_PartyIndex[2] = {-1, -1}; //PFS index for each VMC, unless -1 -int Party_vmcIndex[MOUNT_LIMIT] = {-1, -1, -1, -1}; //VMC for each PFS, unless -1 +int vmcMounted[2] = {0, 0}; // flags true for mounted VMC false for unmounted +int vmc_PartyIndex[2] = {-1, -1}; // PFS index for each VMC, unless -1 +int Party_vmcIndex[MOUNT_LIMIT] = {-1, -1, -1, -1}; // VMC for each PFS, unless -1 unsigned char *elisaFnt = NULL; -int elisa_failed = FALSE; //Set at failure to load font, cleared at browser entry +int elisa_failed = FALSE; // Set at failure to load font, cleared at browser entry u64 freeSpace; int mcfreeSpace; -int mctype_PSx; //dlanor: Needed for proper scaling of mcfreespace -int vfreeSpace; //flags validity of freespace value +int mctype_PSx; // dlanor: Needed for proper scaling of mcfreespace +int vfreeSpace; // flags validity of freespace value int browser_cut; int nclipFiles, nmarks, nparties; #ifdef DVRP @@ -75,14 +75,14 @@ int latestDVRPMount = -1; #endif #ifdef MX4SIO -int mx4sio_idx = -1; // To keep track of wich mass#:/ device represents MX4SIO +int mx4sio_idx = -1; // To keep track of wich mass#:/ device represents MX4SIO #endif -int file_show = 1; //dlanor: 0==name_only, 1==name+size+time, 2==title+size+time -int file_sort = 1; //dlanor: 0==none, 1==name, 2==title, 3==mtime +int file_show = 1; // dlanor: 0==name_only, 1==name+size+time, 2==title+size+time +int file_sort = 1; // dlanor: 0==none, 1==name, 2==title, 3==mtime int size_valid = 0; int time_valid = 0; -char parties[MAX_PARTITIONS][MAX_PART_NAME+1]; +char parties[MAX_PARTITIONS][MAX_PART_NAME + 1]; char clipPath[MAX_PATH], LastDir[MAX_NAME], marks[MAX_ENTRY]; FILEINFO clipFiles[MAX_ENTRY]; int fileMode = FIO_S_IRUSR | FIO_S_IWUSR | FIO_S_IXUSR | FIO_S_IRGRP | FIO_S_IWGRP | FIO_S_IXGRP | FIO_S_IROTH | FIO_S_IWOTH | FIO_S_IXOTH; @@ -126,10 +126,10 @@ char cnfmode_extL[CNFMODE_CNT][4] = { int host_ready = 0; int host_error = 0; int host_elflist = 0; -int host_use_Bsl = 1; //By default assume that host paths use backslash +int host_use_Bsl = 1; // By default assume that host paths use backslash #endif -unsigned long written_size; //Used for pasting progress report -u64 PasteTime; //Used for pasting progress report +unsigned long written_size; // Used for pasting progress report +u64 PasteTime; // Used for pasting progress report typedef struct { @@ -143,43 +143,43 @@ typedef struct } ps2time; typedef struct -{ //Offs: Example content - ps2time cTime; //0x00: 8 bytes creation timestamp (struct above) - ps2time mTime; //0x08: 8 bytes modification timestamp (struct above) - u32 size; //0x10: file size - u16 attr; //0x14: 0x8427 (=normal folder, 8497 for normal file) - u16 unknown_1_u16; //0x16: 2 zero bytes - u64 unknown_2_u64; //0x18: 8 zero bytes - u8 name[32]; //0x20: 32 name bytes, padded with zeroes +{ // Offs: Example content + ps2time cTime; // 0x00: 8 bytes creation timestamp (struct above) + ps2time mTime; // 0x08: 8 bytes modification timestamp (struct above) + u32 size; // 0x10: file size + u16 attr; // 0x14: 0x8427 (=normal folder, 8497 for normal file) + u16 unknown_1_u16; // 0x16: 2 zero bytes + u64 unknown_2_u64; // 0x18: 8 zero bytes + u8 name[32]; // 0x20: 32 name bytes, padded with zeroes } mcT_header __attribute__((aligned(64))); typedef struct -{ //Offs: Example content - u16 attr; //0x00: 0x8427 (=normal folder, 8497 for normal file) - u16 unknown_1_u16; //0x02: 2 zero bytes - u32 size; //0x04: header_count-1, file size, 0 for pseudo - ps2time cTime; //0x08: 8 bytes creation timestamp (struct above) - u64 EMS_used_u64; //0x10: 8 zero bytes (but used by EMS) - ps2time mTime; //0x18: 8 bytes modification timestamp (struct above) - u64 unknown_2_u64; //0x20: 8 bytes from mcTable - u8 unknown_3_24_bytes[24]; //0x28: 24 zero bytes - u8 name[32]; //0x40: 32 name bytes, padded with zeroes - u8 unknown_4_416_bytes[0x1A0]; //0x60: zero byte padding to reach 0x200 size -} psu_header; //0x200: End of psu_header struct - -int PSU_content; //Used to count PSU content headers for the main header - -//USB_mass definitions for multiple drive usage +{ // Offs: Example content + u16 attr; // 0x00: 0x8427 (=normal folder, 8497 for normal file) + u16 unknown_1_u16; // 0x02: 2 zero bytes + u32 size; // 0x04: header_count-1, file size, 0 for pseudo + ps2time cTime; // 0x08: 8 bytes creation timestamp (struct above) + u64 EMS_used_u64; // 0x10: 8 zero bytes (but used by EMS) + ps2time mTime; // 0x18: 8 bytes modification timestamp (struct above) + u64 unknown_2_u64; // 0x20: 8 bytes from mcTable + u8 unknown_3_24_bytes[24]; // 0x28: 24 zero bytes + u8 name[32]; // 0x40: 32 name bytes, padded with zeroes + u8 unknown_4_416_bytes[0x1A0]; // 0x60: zero byte padding to reach 0x200 size +} psu_header; // 0x200: End of psu_header struct + +int PSU_content; // Used to count PSU content headers for the main header + +// USB_mass definitions for multiple drive usage char USB_mass_ix[10] = {'0', 0, 0, 0, 0, 0, 0, 0, 0, 0}; int USB_mass_max_drives = USB_MASS_MAX_DRIVES; u64 USB_mass_scan_time = 0; -int USB_mass_scanned = 0; //0==Not_found_OR_No_Multi 1==found_Multi_mass_once -int USB_mass_loaded = 0; //0==none, 1==internal, 2==external +int USB_mass_scanned = 0; // 0==Not_found_OR_No_Multi 1==found_Multi_mass_once +int USB_mass_loaded = 0; // 0==none, 1==internal, 2==external -//char debugs[4096]; //For debug display strings. Comment it out when unused +// char debugs[4096]; //For debug display strings. Comment it out when unused //-------------------------------------------------------------- -//executable code +// executable code //-------------------------------------------------------------- void clear_mcTable(sceMcTblGetDir *mcT) { @@ -211,7 +211,7 @@ void pad_psu_header(psu_header *psu) // pfs index), and this is then followed by the path within that partition. // Note that despite the name 'dir', this is also used for files. //----- -//NB: From the first slash character those two strings are identical when +// NB: From the first slash character those two strings are identical when // both are used, but either pointer may be set to NULL in the function call, // as an indication that the caller isn't interested in that part. //-------------------------------------------------------------- @@ -244,19 +244,19 @@ int mountParty(const char *party) int i, j; char pfs_str[6]; - for (i = 0; i < MOUNT_LIMIT; i++) { //Here we check already mounted PFS indexes + for (i = 0; i < MOUNT_LIMIT; i++) { // Here we check already mounted PFS indexes if (!strcmp(party, mountedParty[i])) goto return_i; } - for (i = 0, j = -1; i < MOUNT_LIMIT; i++) { //Here we search for a free PFS index + for (i = 0, j = -1; i < MOUNT_LIMIT; i++) { // Here we search for a free PFS index if (mountedParty[i][0] == 0) { j = i; break; } } - if (j == -1) { //Here we search for a suitable PFS index to unmount + if (j == -1) { // Here we search for a suitable PFS index to unmount for (i = 0; i < MOUNT_LIMIT; i++) { if ((i != latestMount) && (Party_vmcIndex[i] < 0)) { j = i; @@ -265,30 +265,30 @@ int mountParty(const char *party) } unmountParty(j); } - //Here j is the index of a free PFS mountpoint - //But 'free' only means that the main uLE program isn't using it - //If the ftp server is running, that may have used the mountpoints + // Here j is the index of a free PFS mountpoint + // But 'free' only means that the main uLE program isn't using it + // If the ftp server is running, that may have used the mountpoints - //RA NB: The old code to reclaim FTP partitions was seriously bugged... + // RA NB: The old code to reclaim FTP partitions was seriously bugged... i = j; strcpy(pfs_str, "pfs0:"); pfs_str[3] = '0' + i; - if (fileXioMount(pfs_str, party, FIO_MT_RDWR) < 0) { //if FTP stole it - for (i = 0; i <= 4; i++) { //for loop to kill FTP partition mountpoints - if ((i != latestMount) && (Party_vmcIndex[i] < 0)) { //if unneeded by uLE - unmountParty(i); //unmount partition mountpoint - pfs_str[3] = '0' + i; //prepare to reuse that mountpoint + if (fileXioMount(pfs_str, party, FIO_MT_RDWR) < 0) { // if FTP stole it + for (i = 0; i <= 4; i++) { // for loop to kill FTP partition mountpoints + if ((i != latestMount) && (Party_vmcIndex[i] < 0)) { // if unneeded by uLE + unmountParty(i); // unmount partition mountpoint + pfs_str[3] = '0' + i; // prepare to reuse that mountpoint if (fileXioMount(pfs_str, party, FIO_MT_RDWR) >= 0) - break; //break from the loop on successful mount - } //ends if unneeded by uLE - } //ends for loop to kill FTP partition mountpoints - //Here i indicates what happened above with the following meanings: - //0..4==Success after trying i mountpoints, 5==Failure + break; // break from the loop on successful mount + } // ends if unneeded by uLE + } // ends for loop to kill FTP partition mountpoints + // Here i indicates what happened above with the following meanings: + // 0..4==Success after trying i mountpoints, 5==Failure if (i > 4) return -1; - } //ends if clause for mountpoints stolen by FTP + } // ends if clause for mountpoints stolen by FTP strcpy(mountedParty[i], party); return_i: latestMount = i; @@ -302,7 +302,7 @@ void unmountParty(int party_ix) strcpy(pfs_str, "pfs0:"); pfs_str[3] += party_ix; if (fileXioUmount(pfs_str) < 0) - return; //leave variables unchanged if unmount failed (remember true state) + return; // leave variables unchanged if unmount failed (remember true state) if (party_ix < MOUNT_LIMIT) { mountedParty[party_ix][0] = 0; } @@ -341,12 +341,12 @@ int mountDVRPParty(const char *party) { int i, j; - for (i = 0; i < MOUNT_LIMIT; i++) { //Here we check already mounted PFS indexes + for (i = 0; i < MOUNT_LIMIT; i++) { // Here we check already mounted PFS indexes if (!strcmp(party, mountedDVRPParty[i])) goto return_i; } - for (i = 0, j = -1; i < MOUNT_LIMIT; i++) { //Here we search for a free PFS index + for (i = 0, j = -1; i < MOUNT_LIMIT; i++) { // Here we search for a free PFS index if (mountedDVRPParty[i][0] == 0) { j = i; break; @@ -422,7 +422,7 @@ void unmountAll(void) } latestDVRPMount = -1; #endif -} //ends unmountAll +} // ends unmountAll //-------------------------------------------------------------- int ynDialog(const char *message) { @@ -434,17 +434,17 @@ int ynDialog(const char *message) strcpy(msg, message); - for (i = 0, n = 1; msg[i] != 0; i++) { //start with one string at pos zero - if (msg[i] == '\n') { //line separator at current pos ? - msg[i] = 0; //split old line to separate string - n++; //increment string count + for (i = 0, n = 1; msg[i] != 0; i++) { // start with one string at pos zero + if (msg[i] == '\n') { // line separator at current pos ? + msg[i] = 0; // split old line to separate string + n++; // increment string count } - } //loop back for next character pos - for (i = len = tw = 0; i < n; i++) { //start with string 0, assume 0 length & width - ret = printXY(&msg[len], 0, 0, 0, FALSE, 0); //get width of current string + } // loop back for next character pos + for (i = len = tw = 0; i < n; i++) { // start with string 0, assume 0 length & width + ret = printXY(&msg[len], 0, 0, 0, FALSE, 0); // get width of current string if (ret > tw) - tw = ret; //tw = largest text width of strings so far - len += strlen(&msg[len]) + 1; //len = pos of next string start + tw = ret; // tw = largest text width of strings so far + len += strlen(&msg[len]) + 1; // len = pos of next string start } if (tw < 96) tw = 96; @@ -455,16 +455,16 @@ int ynDialog(const char *message) dy = (SCREEN_HEIGHT - dh) / 2; // printf("tw=%d\ndh=%d\ndw=%d\ndx=%d\ndy=%d\n", tw,dh,dw,dx,dy); - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command sel = 0; } else if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command sel = 1; } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { ret = -1; @@ -478,9 +478,9 @@ int ynDialog(const char *message) } } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], dx, dy, dx + dw, (dy + dh)); @@ -490,7 +490,7 @@ int ynDialog(const char *message) len += strlen(&msg[len]) + 1; } - //Cursor positioning section + // Cursor positioning section x = (tw - 96) / 4; printXY(LNG(OK), dx + a + x + FONT_WIDTH, (dy + a + b + 2 + n * FONT_HEIGHT), setting->color[COLOR_TEXT], TRUE, 0); @@ -501,11 +501,11 @@ int ynDialog(const char *message) else drawChar(LEFT_CUR, dx + dw - x - (strlen(LNG(CANCEL)) + 2) * FONT_WIDTH - 1, (dy + a + b + 2 + n * FONT_HEIGHT), setting->color[COLOR_TEXT]); - } //ends if(event||post_event) + } // ends if(event||post_event) drawLastMsg(); post_event = event; event = 0; - } //ends while + } // ends while drawSprite(setting->color[COLOR_BACKGR], dx, dy, dx + dw + 1, (dy + dh) + 1); drawScr(); drawSprite(setting->color[COLOR_BACKGR], dx, dy, dx + dw + 1, (dy + dh) + 1); @@ -513,16 +513,16 @@ int ynDialog(const char *message) return ret; } //------------------------------ -//endfunc ynDialog +// endfunc ynDialog //-------------------------------------------------------------- void nonDialog(char *message) { - char msg[80 * 30]; //More than this can't be shown on screen, even in PAL - static int dh, dw, dx, dy; //These are static, to allow cleanup + char msg[80 * 30]; // More than this can't be shown on screen, even in PAL + static int dh, dw, dx, dy; // These are static, to allow cleanup int a = 6, b = 4, c = 2, n, tw; int i, len, ret; - if (message == NULL) { //NULL message means cleanup for last nonDialog + if (message == NULL) { // NULL message means cleanup for last nonDialog drawSprite(setting->color[COLOR_BACKGR], dx, dy, dx + dw, (dy + dh)); @@ -531,17 +531,17 @@ void nonDialog(char *message) strcpy(msg, message); - for (i = 0, n = 1; msg[i] != 0; i++) { //start with one string at pos zero - if (msg[i] == '\n') { //line separator at current pos ? - msg[i] = 0; //split old line to separate string - n++; //increment string count + for (i = 0, n = 1; msg[i] != 0; i++) { // start with one string at pos zero + if (msg[i] == '\n') { // line separator at current pos ? + msg[i] = 0; // split old line to separate string + n++; // increment string count } - } //loop back for next character pos - for (i = len = tw = 0; i < n; i++) { //start with string 0, assume 0 length & width - ret = printXY(&msg[len], 0, 0, 0, FALSE, 0); //get width of current string + } // loop back for next character pos + for (i = len = tw = 0; i < n; i++) { // start with string 0, assume 0 length & width + ret = printXY(&msg[len], 0, 0, 0, FALSE, 0); // get width of current string if (ret > tw) - tw = ret; //tw = largest text width of strings so far - len += strlen(&msg[len]) + 1; //len = pos of next string start + tw = ret; // tw = largest text width of strings so far + len += strlen(&msg[len]) + 1; // len = pos of next string start } if (tw < 96) tw = 96; @@ -550,7 +550,7 @@ void nonDialog(char *message) dw = 2 * 2 + a * 2 + tw; dx = (SCREEN_WIDTH - dw) / 2; dy = (SCREEN_HEIGHT - dh) / 2; - //printf("tw=%d\ndh=%d\ndw=%d\ndx=%d\ndy=%d\n", tw,dh,dw,dx,dy); + // printf("tw=%d\ndh=%d\ndw=%d\ndx=%d\ndy=%d\n", tw,dh,dw,dx,dy); drawPopSprite(setting->color[COLOR_BACKGR], dx, dy, @@ -562,7 +562,7 @@ void nonDialog(char *message) } } //------------------------------ -//endfunc nonDialog +// endfunc nonDialog //-------------------------------------------------------------- // cmpFile below returns negative if the 'a' entry is 'lower' // than the 'b' entry, normally meaning that 'a' should be in @@ -570,13 +570,13 @@ void nonDialog(char *message) // return value causes the calling sort routine to adjust the // entry order, which does not occur for other return values. //-------------------------------------------------------------- -int cmpFile(FILEINFO *a, FILEINFO *b) //Used for directory sort +int cmpFile(FILEINFO *a, FILEINFO *b) // Used for directory sort { char ca, cb; int i, n, ret, aElf = FALSE, bElf = FALSE, t = (file_sort == 2); if (file_sort == 0) - return 0; //return 0 for unsorted mode + return 0; // return 0 for unsorted mode if ((a->stats.AttrFile & MC_ATTR_OBJECT) == (b->stats.AttrFile & MC_ATTR_OBJECT)) { if (a->stats.AttrFile & sceMcFileAttrFile) { @@ -589,13 +589,13 @@ int cmpFile(FILEINFO *a, FILEINFO *b) //Used for directory sort else if (!aElf && bElf) return 1; } - if (file_sort == 3) { //Sort by timestamp - t = (file_show == 2); //Set secondary sort criterion + if (file_sort == 3) { // Sort by timestamp + t = (file_show == 2); // Set secondary sort criterion if (time_valid) { u64 time_a = *(u64 *)&a->stats._Modify; u64 time_b = *(u64 *)&b->stats._Modify; if (time_a > time_b) - return -1; //NB: reversed comparison for falling order + return -1; // NB: reversed comparison for falling order if (time_a < time_b) return 1; } @@ -670,7 +670,7 @@ int readMC(const char *path, FILEINFO *info, int max) mcGetInfo(path[2] - '0', 0, &mctype_PSx, NULL, NULL); mcSync(0, NULL, &ret); - if (mctype_PSx == 2) //PS2 MC ? + if (mctype_PSx == 2) // PS2 MC ? time_valid = 1; size_valid = 1; @@ -682,7 +682,7 @@ int readMC(const char *path, FILEINFO *info, int max) for (i = j = 0; i < ret; i++) { if (mcDir[i].AttrFile & sceMcFileAttrSubdir && (!strcmp((char *)mcDir[i].EntryName, ".") || !strcmp((char *)mcDir[i].EntryName, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[j].name, (char *)mcDir[i].EntryName); info[j].stats = mcDir[i]; j++; @@ -691,7 +691,7 @@ int readMC(const char *path, FILEINFO *info, int max) return j; } //------------------------------ -//endfunc readMC +// endfunc readMC //-------------------------------------------------------------- int readCD(const char *path, FILEINFO *info, int max) { @@ -722,7 +722,7 @@ int readCD(const char *path, FILEINFO *info, int max) if (TocEntryList[i].fileProperties & 0x02 && (!strcmp(TocEntryList[i].filename, ".") || !strcmp(TocEntryList[i].filename, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[j].name, TocEntryList[i].filename); clear_mcTable(&info[j].stats); if (TocEntryList[i].fileProperties & 0x02) { @@ -730,7 +730,7 @@ int readCD(const char *path, FILEINFO *info, int max) } else { info[j].stats.AttrFile = MC_ATTR_norm_file; info[j].stats.FileSizeByte = TocEntryList[i].fileSize; - info[j].stats.Reserve2 = 0; //Assuming a CD can't have a single 4GB file + info[j].stats.Reserve2 = 0; // Assuming a CD can't have a single 4GB file } j++; } @@ -740,7 +740,7 @@ int readCD(const char *path, FILEINFO *info, int max) return j; } //------------------------------ -//endfunc readCD +// endfunc readCD //-------------------------------------------------------------- void setPartyList(void) { @@ -757,22 +757,22 @@ void setPartyList(void) if ((dirEnt.stat.attr != ATTR_MAIN_PARTITION) || (dirEnt.stat.mode != FS_TYPE_PFS)) continue; - //Patch this to see if new CB versions use valid PFS format - //NB: All CodeBreaker versions up to v9.3 use invalid formats + // Patch this to see if new CB versions use valid PFS format + // NB: All CodeBreaker versions up to v9.3 use invalid formats /* if(!strncmp(dirEnt.name, "PP.",3)){ - int len = strlen(dirEnt.name); - if(!strcmp(dirEnt.name+len-4, ".PCB")) - continue; + int len = strlen(dirEnt.name); + if(!strcmp(dirEnt.name+len-4, ".PCB")) + continue; } if(!strncmp(dirEnt.name, "__", 2) && - strcmp(dirEnt.name, "__boot") && - strcmp(dirEnt.name, "__net") && - strcmp(dirEnt.name, "__system") && - strcmp(dirEnt.name, "__sysconf") && - strcmp(dirEnt.name, "__contents") && // this is where PSBBN used to store it's downloaded contents. Adding it is useful. - strcmp(dirEnt.name, "__common")) - continue; + strcmp(dirEnt.name, "__boot") && + strcmp(dirEnt.name, "__net") && + strcmp(dirEnt.name, "__system") && + strcmp(dirEnt.name, "__sysconf") && + strcmp(dirEnt.name, "__contents") && // this is where PSBBN used to store it's downloaded contents. Adding it is useful. + strcmp(dirEnt.name, "__common")) + continue; */ strncpy(parties[nparties], dirEnt.name, MAX_PART_NAME); parties[nparties++][MAX_PART_NAME] = '\0'; @@ -795,21 +795,21 @@ void setDVRPPartyList(void) if ((dirEnt.stat.attr != ATTR_MAIN_PARTITION) || (dirEnt.stat.mode != FS_TYPE_PFS)) continue; - //Patch this to see if new CB versions use valid PFS format - //NB: All CodeBreaker versions up to v9.3 use invalid formats + // Patch this to see if new CB versions use valid PFS format + // NB: All CodeBreaker versions up to v9.3 use invalid formats /* if(!strncmp(dirEnt.name, "PP.",3)){ - int len = strlen(dirEnt.name); - if(!strcmp(dirEnt.name+len-4, ".PCB")) - continue; + int len = strlen(dirEnt.name); + if(!strcmp(dirEnt.name+len-4, ".PCB")) + continue; } if(!strncmp(dirEnt.name, "__", 2) && - strcmp(dirEnt.name, "__boot") && - strcmp(dirEnt.name, "__net") && - strcmp(dirEnt.name, "__system") && - strcmp(dirEnt.name, "__sysconf") && - strcmp(dirEnt.name, "__contents") && // this is where PSBBN used to store it's downloaded contents. Adding it is useful. - strcmp(dirEnt.name, "__common")) - continue; + strcmp(dirEnt.name, "__boot") && + strcmp(dirEnt.name, "__net") && + strcmp(dirEnt.name, "__system") && + strcmp(dirEnt.name, "__sysconf") && + strcmp(dirEnt.name, "__contents") && // this is where PSBBN used to store it's downloaded contents. Adding it is useful. + strcmp(dirEnt.name, "__common")) + continue; */ strncpy(parties[ndvrpparties], dirEnt.name, MAX_PART_NAME); parties[ndvrpparties++][MAX_PART_NAME] = '\0'; @@ -835,41 +835,41 @@ void setDVRPPartyList(void) void genLimObjName(char *uLE_path, int reserve) { char *p, *q, *r; - int limit = 256; //enforce a generic limit of 256 characters - int folder_flag = (uLE_path[strlen(uLE_path) - 1] == '/'); //flag folder object + int limit = 256; // enforce a generic limit of 256 characters + int folder_flag = (uLE_path[strlen(uLE_path) - 1] == '/'); // flag folder object int overflow; if (!strncmp(uLE_path, "mc", 2) || !strncmp(uLE_path, "vmc", 3)) - limit = 32; //enforce MC limit of 32 characters + limit = 32; // enforce MC limit of 32 characters - if (folder_flag) //if path ends with path separator + if (folder_flag) // if path ends with path separator uLE_path[strlen(uLE_path) - 1] = 0; // remove final path separator (temporarily) - p = uLE_path; //initially assume a pure object name (quite insanely :)) - if ((q = strchr(p, ':')) != NULL) //if a drive separator is present + p = uLE_path; // initially assume a pure object name (quite insanely :)) + if ((q = strchr(p, ':')) != NULL) // if a drive separator is present p = q + 1; // object name may start after drive separator - if ((q = strrchr(p, '/')) != NULL) //If there's any path separator in the string + if ((q = strrchr(p, '/')) != NULL) // If there's any path separator in the string p = q + 1; // object name starts after last path separator - limit -= reserve; //lower limit by reserved character space - overflow = strlen(p) - limit; //Calculate length of string to remove (if positive) - if ((limit <= 0) || (overflow <= 0)) //if limit invalid, or not exceeded + limit -= reserve; // lower limit by reserved character space + overflow = strlen(p) - limit; // Calculate length of string to remove (if positive) + if ((limit <= 0) || (overflow <= 0)) // if limit invalid, or not exceeded goto limited; // no further limitation is needed - if ((q = strrchr(p, '.')) == NULL) //if there's no extension separator - goto limit_end; //limitation must be done at end of full name - r = q - overflow; //r is the place to recopy file extension - if (r > p) { //if this place is above string start - strcpy(r, q); //remove overflow from end of prefix part - goto limited; //which concludes the limitation - } //if we fall through here, the prefix part was too short for the limitation needed + if ((q = strrchr(p, '.')) == NULL) // if there's no extension separator + goto limit_end; // limitation must be done at end of full name + r = q - overflow; // r is the place to recopy file extension + if (r > p) { // if this place is above string start + strcpy(r, q); // remove overflow from end of prefix part + goto limited; // which concludes the limitation + } // if we fall through here, the prefix part was too short for the limitation needed limit_end: p[limit] = 0; // remove overflow from end of full name limited: - if (folder_flag) //if original path ended with path separator + if (folder_flag) // if original path ended with path separator strcat(uLE_path, "/"); // reappend final path separator after name } //------------------------------ -//endfunc genLimObjName +// endfunc genLimObjName //-------------------------------------------------------------- int genFixPath(const char *inp_path, char *gen_path) { @@ -877,76 +877,76 @@ int genFixPath(const char *inp_path, char *gen_path) char *pathSep; int part_ix; - part_ix = 99; //Assume valid non-HDD path + part_ix = 99; // Assume valid non-HDD path if (!uLE_related(uLE_path, inp_path)) - part_ix = -99; //Assume invalid uLE_related path - strcpy(gen_path, uLE_path); //Assume no path patching needed + part_ix = -99; // Assume invalid uLE_related path + strcpy(gen_path, uLE_path); // Assume no path patching needed pathSep = strchr(uLE_path, '/'); - if (!strncmp(uLE_path, "cdfs", 4)) { //if using CD or DVD disc path + if (!strncmp(uLE_path, "cdfs", 4)) { // if using CD or DVD disc path CDVD_FlushCache(); CDVD_DiskReady(0); - //end of clause for using a CD or DVD path + // end of clause for using a CD or DVD path - } else if (!strncmp(uLE_path, "mass", 4)) { //if using USB mass: path + } else if (!strncmp(uLE_path, "mass", 4)) { // if using USB mass: path if (pathSep && (pathSep - uLE_path < 7) && pathSep[-1] == ':') strcpy(gen_path + (pathSep - uLE_path), pathSep + 1); - //end of clause for using a USB mass: path + // end of clause for using a USB mass: path - } else if (!strncmp(uLE_path, "hdd0:/", 6)) { //If using HDD path - //Get path on HDD unit, LaunchELF's format (e.g. hdd0:/partition/path/to/file) + } else if (!strncmp(uLE_path, "hdd0:/", 6)) { // If using HDD path + // Get path on HDD unit, LaunchELF's format (e.g. hdd0:/partition/path/to/file) strcpy(loc_path, uLE_path + 6); if ((p = strchr(loc_path, '/')) != NULL) { - //Extract path to file within partition. Make a new path, relative to the filesystem root. - //hdd0:/partition/path/to/file becomes pfs0:/path/to/file. + // Extract path to file within partition. Make a new path, relative to the filesystem root. + // hdd0:/partition/path/to/file becomes pfs0:/path/to/file. sprintf(gen_path, "pfs0:%s", p); - *p = 0; //null-terminate the block device path (hdd0:/partition). + *p = 0; // null-terminate the block device path (hdd0:/partition). } else { - //Otherwise, default to / + // Otherwise, default to / strcpy(gen_path, "pfs0:/"); } - //Generate standard path to the block device (i.e. hdd0:/partition results in hdd0:partition) + // Generate standard path to the block device (i.e. hdd0:/partition results in hdd0:partition) sprintf(party, "hdd0:%s", loc_path); if (nparties == 0) { - //No partitions recognized? Load modules & populate partition list. + // No partitions recognized? Load modules & populate partition list. loadHddModules(); setPartyList(); } - //Mount the partition. + // Mount the partition. if ((part_ix = mountParty(party)) >= 0) gen_path[3] = part_ix + '0'; #ifdef DVRP - } else if (!strncmp(uLE_path, "dvr_hdd0:/", 10)) { //If using DVRP HDD path - //Get path on DVR HDD unit, LaunchELF's format (e.g. dvr_hdd0:/partition/path/to/file) + } else if (!strncmp(uLE_path, "dvr_hdd0:/", 10)) { // If using DVRP HDD path + // Get path on DVR HDD unit, LaunchELF's format (e.g. dvr_hdd0:/partition/path/to/file) strcpy(loc_path, uLE_path + 10); if ((p = strchr(loc_path, '/')) != NULL) { - //Extract path to file within partition. Make a new path, relative to the filesystem root. - //dvr_hdd0:/partition/path/to/file becomes dvr_pfs0:/path/to/file. + // Extract path to file within partition. Make a new path, relative to the filesystem root. + // dvr_hdd0:/partition/path/to/file becomes dvr_pfs0:/path/to/file. sprintf(gen_path, "dvr_pfs0:%s", p); - *p = 0; //null-terminate the block device path (dvr_hdd0:/partition). + *p = 0; // null-terminate the block device path (dvr_hdd0:/partition). } else { - //Otherwise, default to / + // Otherwise, default to / strcpy(gen_path, "dvr_pfs0:/"); } - //Generate standard path to the block device (i.e. dvr_hdd0:/partition results in hdd0:partition) + // Generate standard path to the block device (i.e. dvr_hdd0:/partition results in hdd0:partition) sprintf(party, "dvr_hdd0:%s", loc_path); if (ndvrpparties == 0) { - //No partitions recognized? Load modules & populate partition list. + // No partitions recognized? Load modules & populate partition list. loadDVRPHddModules(); setDVRPPartyList(); } - //Mount the partition. + // Mount the partition. if ((part_ix = mountDVRPParty(party)) >= 0) gen_path[7] = part_ix + '0'; - //end of clause for using an HDD path + // end of clause for using an HDD path #endif } genLimObjName(gen_path, 0); return part_ix; - //non-HDD Path => 99, Good HDD Path => 0-3, Bad Path => negative + // non-HDD Path => 99, Good HDD Path => 0-3, Bad Path => negative } //------------------------------ -//endfunc genFixPath +// endfunc genFixPath //-------------------------------------------------------------- int genRmdir(char *path) { @@ -959,7 +959,7 @@ int genRmdir(char *path) return ret; } //------------------------------ -//endfunc genRmdir +// endfunc genRmdir //-------------------------------------------------------------- int genRemove(char *path) { @@ -972,7 +972,7 @@ int genRemove(char *path) return ret; } //------------------------------ -//endfunc genRemove +// endfunc genRemove //-------------------------------------------------------------- int genOpen(char *path, int mode) { @@ -980,7 +980,7 @@ int genOpen(char *path, int mode) return fileXioOpen(path, mode, fileMode); } //------------------------------ -//endfunc genOpen +// endfunc genOpen //-------------------------------------------------------------- int genDopen(char *path) { @@ -1000,42 +1000,42 @@ int genDopen(char *path) return fd; } //------------------------------ -//endfunc genDopen +// endfunc genDopen //-------------------------------------------------------------- int genLseek(int fd, int where, int how) { return fileXioLseek(fd, where, how); } //------------------------------ -//endfunc genLseek +// endfunc genLseek //-------------------------------------------------------------- int genRead(int fd, void *buf, int size) { return fileXioRead(fd, buf, size); } //------------------------------ -//endfunc genRead +// endfunc genRead //-------------------------------------------------------------- int genWrite(int fd, void *buf, int size) { return fileXioWrite(fd, buf, size); } //------------------------------ -//endfunc genWrite +// endfunc genWrite //-------------------------------------------------------------- int genClose(int fd) { return fileXioClose(fd); } //------------------------------ -//endfunc genClose +// endfunc genClose //-------------------------------------------------------------- int genDclose(int fd) { return fileXioDclose(fd); } //------------------------------ -//endfunc genDclose +// endfunc genDclose //-------------------------------------------------------------- int genCmpFileExt(const char *filename, const char *extension) { @@ -1045,7 +1045,7 @@ int genCmpFileExt(const char *filename, const char *extension) return (p != NULL && !stricmp(p + 1, extension)); } //------------------------------ -//endfunc genDclose +// endfunc genDclose //-------------------------------------------------------------- int readVMC(const char *path, FILEINFO *info, int max) { @@ -1059,16 +1059,16 @@ int readVMC(const char *path, FILEINFO *info, int max) while (fileXioDread(fd, &dirbuf) > 0) { // if(dirbuf.stat.mode & FIO_S_IFDIR && //NB: normal usage (non-vmcfs) - if (dirbuf.stat.mode & sceMcFileAttrSubdir && //NB: nonstandard usage of vmcfs + if (dirbuf.stat.mode & sceMcFileAttrSubdir && // NB: nonstandard usage of vmcfs (!strcmp(dirbuf.name, ".") || !strcmp(dirbuf.name, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[i].name, dirbuf.name); clear_mcTable(&info[i].stats); // if(dirbuf.stat.mode & FIO_S_IFDIR){ //NB: normal usage (non-vmcfs) // info[i].stats.attrFile = MC_ATTR_norm_folder; // } - if (dirbuf.stat.mode & sceMcFileAttrSubdir) { //NB: vmcfs usage + if (dirbuf.stat.mode & sceMcFileAttrSubdir) { // NB: vmcfs usage info[i].stats.AttrFile = dirbuf.stat.mode; } // else if(dirbuf.stat.mode & FIO_S_IFREG){ //NB: normal usage (non-vmcfs) @@ -1076,12 +1076,12 @@ int readVMC(const char *path, FILEINFO *info, int max) // info[i].stats.fileSizeByte = dirbuf.stat.size; // info[i].stats.unknown4[0] = dirbuf.stat.hisize; // } - else if (dirbuf.stat.mode & sceMcFileAttrFile) { //NB: vmcfs usage + else if (dirbuf.stat.mode & sceMcFileAttrFile) { // NB: vmcfs usage info[i].stats.AttrFile = dirbuf.stat.mode; info[i].stats.FileSizeByte = dirbuf.stat.size; info[i].stats.Reserve2 = dirbuf.stat.hisize; } else - continue; //Skip entry which is neither a file nor a folder + continue; // Skip entry which is neither a file nor a folder strncpy((char *)info[i].stats.EntryName, info[i].name, 32); memcpy((void *)&info[i].stats._Create, dirbuf.stat.ctime, 8); memcpy((void *)&info[i].stats._Modify, dirbuf.stat.mtime, 8); @@ -1098,7 +1098,7 @@ int readVMC(const char *path, FILEINFO *info, int max) return i; } //------------------------------ -//endfunc readVMC +// endfunc readVMC //-------------------------------------------------------------- int readHDD(const char *path, FILEINFO *info, int max) { @@ -1131,7 +1131,7 @@ int readHDD(const char *path, FILEINFO *info, int max) while (fileXioDread(fd, &dirbuf) > 0) { if (dirbuf.stat.mode & FIO_S_IFDIR && (!strcmp(dirbuf.name, ".") || !strcmp(dirbuf.name, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[i].name, dirbuf.name); clear_mcTable(&info[i].stats); @@ -1142,7 +1142,7 @@ int readHDD(const char *path, FILEINFO *info, int max) info[i].stats.FileSizeByte = dirbuf.stat.size; info[i].stats.Reserve2 = dirbuf.stat.hisize; } else - continue; //Skip entry which is neither a file nor a folder + continue; // Skip entry which is neither a file nor a folder strncpy((char *)info[i].stats.EntryName, info[i].name, 32); memcpy((void *)&info[i].stats._Create, dirbuf.stat.ctime, 8); memcpy((void *)&info[i].stats._Modify, dirbuf.stat.mtime, 8); @@ -1159,7 +1159,7 @@ int readHDD(const char *path, FILEINFO *info, int max) return i; } //------------------------------ -//endfunc readHDD +// endfunc readHDD //-------------------------------------------------------------- #ifdef DVRP int readHDDDVRP(const char *path, FILEINFO *info, int max) @@ -1193,7 +1193,7 @@ int readHDDDVRP(const char *path, FILEINFO *info, int max) while (fileXioDread(fd, &dirbuf) > 0) { if (dirbuf.stat.mode & FIO_S_IFDIR && (!strcmp(dirbuf.name, ".") || !strcmp(dirbuf.name, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[i].name, dirbuf.name); clear_mcTable(&info[i].stats); @@ -1204,7 +1204,7 @@ int readHDDDVRP(const char *path, FILEINFO *info, int max) info[i].stats.FileSizeByte = dirbuf.stat.size; info[i].stats.Reserve2 = dirbuf.stat.hisize; } else - continue; //Skip entry which is neither a file nor a folder + continue; // Skip entry which is neither a file nor a folder strncpy((char *)info[i].stats.EntryName, info[i].name, 32); memcpy((void *)&info[i].stats._Create, dirbuf.stat.ctime, 8); memcpy((void *)&info[i].stats._Modify, dirbuf.stat.mtime, 8); @@ -1221,7 +1221,7 @@ int readHDDDVRP(const char *path, FILEINFO *info, int max) return i; } //------------------------------ -//endfunc readHDDDVRP +// endfunc readHDDDVRP //-------------------------------------------------------------- #endif #ifdef XFROM @@ -1230,13 +1230,12 @@ int readXFROM(const char *path, FILEINFO *info, int max) iox_dirent_t dirbuf; char dir[MAX_PATH]; int i = 0, fd; - //volatile int j; + // volatile int j; loadFlashModules(); strcpy(dir, path); - if ((fd = fileXioDopen(path)) < 0) - { + if ((fd = fileXioDopen(path)) < 0) { DPRINTF("ERROR: Cannot open path '%s'\n", path); return 0; } @@ -1244,7 +1243,7 @@ int readXFROM(const char *path, FILEINFO *info, int max) while (fileXioDread(fd, &dirbuf) > 0) { if (dirbuf.stat.mode & FIO_S_IFDIR && (!strcmp(dirbuf.name, ".") || !strcmp(dirbuf.name, ".."))) - continue; //Skip pseudopaths "." and ".." + continue; // Skip pseudopaths "." and ".." strcpy(info[i].name, dirbuf.name); clear_mcTable(&info[i].stats); @@ -1254,11 +1253,10 @@ int readXFROM(const char *path, FILEINFO *info, int max) info[i].stats.AttrFile = MC_ATTR_norm_file; info[i].stats.FileSizeByte = dirbuf.stat.size; info[i].stats.Reserve2 = dirbuf.stat.hisize; - } else - { - DPRINTF("ERROR: Skipping entry wich is neither file or folder '%s'\n", path); - continue; //Skip entry which is neither a file nor a folder - } + } else { + DPRINTF("ERROR: Skipping entry wich is neither file or folder '%s'\n", path); + continue; // Skip entry which is neither a file nor a folder + } strncpy((char *)info[i].stats.EntryName, info[i].name, 32); memcpy((void *)&info[i].stats._Create, dirbuf.stat.ctime, 8); memcpy((void *)&info[i].stats._Modify, dirbuf.stat.mtime, 8); @@ -1276,7 +1274,7 @@ int readXFROM(const char *path, FILEINFO *info, int max) } #endif //------------------------------ -//endfunc readXFROM +// endfunc readXFROM //-------------------------------------------------------------- #ifndef USBMASS_IOCTL_GET_DRIVERNAME #define USBMASS_IOCTL_GET_DRIVERNAME 0x0003 @@ -1289,12 +1287,12 @@ void scan_USB_mass(void) int i, dd; iox_stat_t chk_stat; char mass_path[8] = "mass0:/"; - if ((USB_mass_max_drives < 2) //No need for dynamic lists with only one drive + if ((USB_mass_max_drives < 2) // No need for dynamic lists with only one drive || (USB_mass_scanned && ((Timer() - USB_mass_scan_time) < 5000))) return; #ifdef MX4SIO - mx4sio_idx = -1; //assume none is mx4sio // this MUST ALWAYS be after the USB_mass_scan_time check + mx4sio_idx = -1; // assume none is mx4sio // this MUST ALWAYS be after the USB_mass_scan_time check #endif for (i = 0; i < USB_mass_max_drives; i++) { @@ -1304,24 +1302,23 @@ void scan_USB_mass(void) continue; } #ifdef MX4SIO - if ((dd = fileXioDopen(mass_path)) >= 0) { - int *intptr_ctl = (int *)DEVID; - *intptr_ctl = fileXioIoctl(dd, USBMASS_IOCTL_GET_DRIVERNAME, ""); - fileXioDclose(dd); - if (!strncmp(DEVID, "sdc", 3)) - { - mx4sio_idx = i; - DPRINTF("%s: Found MX4SIO device at mass%d:/\n", __func__, i); + if ((dd = fileXioDopen(mass_path)) >= 0) { + int *intptr_ctl = (int *)DEVID; + *intptr_ctl = fileXioIoctl(dd, USBMASS_IOCTL_GET_DRIVERNAME, ""); + fileXioDclose(dd); + if (!strncmp(DEVID, "sdc", 3)) { + mx4sio_idx = i; + DPRINTF("%s: Found MX4SIO device at mass%d:/\n", __func__, i); + } } - } #endif USB_mass_ix[i] = '0' + i; USB_mass_scanned = 1; USB_mass_scan_time = Timer(); - } //ends for loop + } // ends for loop } //------------------------------ -//endfunc scan_USB_mass +// endfunc scan_USB_mass //-------------------------------------------------------------- int readMASS(const char *path, FILEINFO *info, int max) { @@ -1332,10 +1329,10 @@ int readMASS(const char *path, FILEINFO *info, int max) scan_USB_mass(); if ((dd = fileXioDopen(path)) < 0) - goto exit; //exit if error opening directory + goto exit; // exit if error opening directory while (fileXioDread(dd, &record) > 0) { if ((FIO_S_ISDIR(record.stat.mode)) && (!strcmp(record.name, ".") || !strcmp(record.name, ".."))) - continue; //Skip entry if pseudo-folder "." or ".." + continue; // Skip entry if pseudo-folder "." or ".." strcpy(info[n].name, record.name); clear_mcTable(&info[n].stats); @@ -1346,24 +1343,24 @@ int readMASS(const char *path, FILEINFO *info, int max) info[n].stats.FileSizeByte = record.stat.size; info[n].stats.Reserve2 = record.stat.hisize; } else - continue; //Skip entry which is neither a file nor a folder + continue; // Skip entry which is neither a file nor a folder strncpy((char *)info[n].stats.EntryName, info[n].name, 32); memcpy((void *)&info[n].stats._Create, record.stat.ctime, 8); memcpy((void *)&info[n].stats._Modify, record.stat.mtime, 8); n++; if (n == max) break; - } //ends while + } // ends while size_valid = 1; time_valid = 1; exit: if (dd >= 0) - fileXioDclose(dd); //Close directory if opened above + fileXioDclose(dd); // Close directory if opened above return n; } //------------------------------ -//endfunc readMASS +// endfunc readMASS //-------------------------------------------------------------- #ifdef ETH char *makeHostPath(char *dp, char *sp) @@ -1474,7 +1471,7 @@ int readHOST(const char *path, FILEINFO *info, int max) free(elflisttxt); return hostcount - 1; } - //This point is only reached if elflist.txt is NOT to be used + // This point is only reached if elflist.txt is NOT to be used if ((hfd = fileXioDopen(makeHostPath(Win_path, host_path))) < 0) return 0; @@ -1487,13 +1484,13 @@ int readHOST(const char *path, FILEINFO *info, int max) strcpy(info[hostcount].name, hostcontent.name); clear_mcTable(&info[hostcount].stats); - if (!(hostcontent.stat.mode & FIO_S_IFDIR)) //if not a directory + if (!(hostcontent.stat.mode & FIO_S_IFDIR)) // if not a directory info[hostcount].stats.AttrFile = MC_ATTR_norm_file; else info[hostcount].stats.AttrFile = MC_ATTR_norm_folder; info[hostcount].stats.FileSizeByte = hostcontent.stat.size; - info[hostcount].stats.Reserve2 = hostcontent.stat.hisize; //taking an unused(?) unknown for the high bits + info[hostcount].stats.Reserve2 = hostcontent.stat.hisize; // taking an unused(?) unknown for the high bits memcpy((void *)&info[hostcount].stats._Create, hostcontent.stat.ctime, 8); info[hostcount].stats._Create.Year += 1900; memcpy((void *)&info[hostcount].stats._Modify, hostcontent.stat.mtime, 8); @@ -1509,7 +1506,7 @@ int readHOST(const char *path, FILEINFO *info, int max) } #endif //------------------------------ -//endfunc readHOST +// endfunc readHOST //-------------------------------------------------------------- int getDir(const char *path, FILEINFO *info) { @@ -1559,9 +1556,9 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o psu_header PSU_head; int i, tst, PSU_content, psu_pad_pos; - out[0] = '\0'; //Start by making an empty result string, for failures + out[0] = '\0'; // Start by making an empty result string, for failures - //Avoid title usage in browser root or partition list + // Avoid title usage in browser root or partition list if (path[0] == 0 || !strcmp(path, "hdd0:/") || !strcmp(path, "dvr_hdd0:/")) return -1; @@ -1584,24 +1581,24 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o strcat(dir, "/"); } - ret = -1; //Assume that result will be failure, to simplify aborts + ret = -1; // Assume that result will be failure, to simplify aborts if ((file->stats.AttrFile & sceMcFileAttrSubdir) == 0) { - //Here we know that the object needing a title is a file - strcpy(tmpdir, dir); //Copy the pathname for file access - if (!genCmpFileExt(tmpdir, "psu")) //Find the extension, if any. If it's anything other than a PSU file - goto get_PS1_GameTitle; //then it may be a PS1 save - //Here we know that the object needing a title is a PSU file + // Here we know that the object needing a title is a file + strcpy(tmpdir, dir); // Copy the pathname for file access + if (!genCmpFileExt(tmpdir, "psu")) // Find the extension, if any. If it's anything other than a PSU file + goto get_PS1_GameTitle; // then it may be a PS1 save + // Here we know that the object needing a title is a PSU file if ((fd = genOpen(tmpdir, O_RDONLY)) < 0) - goto finish; //Abort if open fails + goto finish; // Abort if open fails tst = genRead(fd, (void *)&PSU_head, sizeof(PSU_head)); if (tst != sizeof(PSU_head)) - goto finish; //Abort if read fails + goto finish; // Abort if read fails PSU_content = PSU_head.size; for (i = 0; i < PSU_content; i++) { tst = genRead(fd, (void *)&PSU_head, sizeof(PSU_head)); if (tst != sizeof(PSU_head)) - goto finish; //Abort if read fails + goto finish; // Abort if read fails PSU_head.name[sizeof(PSU_head.name) - 1] = '\0'; if (!strcmp((char *)PSU_head.name, "icon.sys")) { genLseek(fd, 0xC0, SEEK_CUR); @@ -1611,14 +1608,14 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o psu_pad_pos = (PSU_head.size + 0x3FF) & -0x400; genLseek(fd, psu_pad_pos, SEEK_CUR); } - //Here the PSU file pointer is positioned for reading next header - } //ends for - //Coming here means that the search for icon.sys failed - goto finish; //So go finish off this function - } //ends if clause for files needing a title - - //Here we know that the object needing a title is a folder - //First try to find a valid PS2 icon.sys file inside the folder + // Here the PSU file pointer is positioned for reading next header + } // ends for + // Coming here means that the search for icon.sys failed + goto finish; // So go finish off this function + } // ends if clause for files needing a title + + // Here we know that the object needing a title is a folder + // First try to find a valid PS2 icon.sys file inside the folder strcpy(tmpdir, dir); strcat(tmpdir, "icon.sys"); if ((fd = genOpen(tmpdir, O_RDONLY)) >= 0) { @@ -1627,21 +1624,21 @@ static int getGameTitle(const char *path, const FILEINFO *file, unsigned char *o genLseek(fd, 0xC0, SEEK_SET); goto read_title; } - //Next try to find a valid PS1 savefile inside the folder instead + // Next try to find a valid PS1 savefile inside the folder instead strcpy(tmpdir, dir); - strcat(tmpdir, file->name); //PS1 save file should have same name as folder + strcat(tmpdir, file->name); // PS1 save file should have same name as folder get_PS1_GameTitle: if ((fd = genOpen(tmpdir, O_RDONLY)) < 0) - goto finish; //PS1 gamesave file needed + goto finish; // PS1 gamesave file needed if ((size = genLseek(fd, 0, SEEK_END)) < 0x2000) - goto finish; //Min size is 8K + goto finish; // Min size is 8K if (size & 0x1FFF) - goto finish; //Size must be a multiple of 8K + goto finish; // Size must be a multiple of 8K genLseek(fd, 0, SEEK_SET); genRead(fd, out, 2); if (strncmp((const char *)out, "SC", 2)) - goto finish; //PS1 gamesaves always start with "SC" + goto finish; // PS1 gamesaves always start with "SC" genLseek(fd, 4, SEEK_SET); read_title: @@ -1676,32 +1673,32 @@ int menu(const char *path, FILEINFO *file) menu_len = strlen(LNG(Get_Size)) > menu_len ? strlen(LNG(Get_Size)) : menu_len; menu_len = strlen(LNG(mcPaste)) > menu_len ? strlen(LNG(mcPaste)) : menu_len; menu_len = strlen(LNG(psuPaste)) > menu_len ? strlen(LNG(psuPaste)) : menu_len; - menu_len = strlen(LNG(time_manip)) > menu_len ? strlen(LNG(time_manip)) : menu_len; - menu_len = strlen(LNG(title_cfg)) > menu_len ? strlen(LNG(title_cfg)) : menu_len; + menu_len = strlen(LNG(time_manip)) > menu_len ? strlen(LNG(time_manip)) : menu_len; + menu_len = strlen(LNG(title_cfg)) > menu_len ? strlen(LNG(title_cfg)) : menu_len; menu_len = (strlen(LNG(Mount)) + 6) > menu_len ? (strlen(LNG(Mount)) + 6) : menu_len; - - int menu_ch_w = menu_len + 1; //Total characters in longest menu string - int menu_ch_h = NUM_MENU; //Total number of menu lines - int mSprite_Y1 = 64; //Top edge of sprite - int mSprite_X2 = SCREEN_WIDTH - 35; //Right edge of sprite - int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; //Left edge of sprite - int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; //Bottom edge of sprite - memset(enable, TRUE, NUM_MENU); //Assume that all menu items are legal by default + int menu_ch_w = menu_len + 1; // Total characters in longest menu string + int menu_ch_h = NUM_MENU; // Total number of menu lines + int mSprite_Y1 = 64; // Top edge of sprite + int mSprite_X2 = SCREEN_WIDTH - 35; // Right edge of sprite + int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; // Left edge of sprite + int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; // Bottom edge of sprite + + memset(enable, TRUE, NUM_MENU); // Assume that all menu items are legal by default - //identify cases where write access is illegal, and disable menu items accordingly - if ((!strncmp(path, "cdfs", 4)) //Writing is always illegal for CDVD drive + // identify cases where write access is illegal, and disable menu items accordingly + if ((!strncmp(path, "cdfs", 4)) // Writing is always illegal for CDVD drive #ifdef ETH - || ((!strncmp(path, "host", 4)) //host: has special cases - && ((!setting->HOSTwrite) //host: Writing is illegal if not enabled in CNF - || (host_elflist && !strcmp(path, "host:/")) //it's also illegal in elflist.txt + || ((!strncmp(path, "host", 4)) // host: has special cases + && ((!setting->HOSTwrite) // host: Writing is illegal if not enabled in CNF + || (host_elflist && !strcmp(path, "host:/")) // it's also illegal in elflist.txt )) #endif - ) + ) write_disabled = 1; - if ((!strcmp(path, "hdd0:/") || !strcmp(path, "dvr_hdd0:/")) || path[0] == 0) //No menu cmds in partition/device lists + if ((!strcmp(path, "hdd0:/") || !strcmp(path, "dvr_hdd0:/")) || path[0] == 0) // No menu cmds in partition/device lists menu_disabled = 1; if (menu_disabled) { @@ -1710,21 +1707,22 @@ int menu(const char *path, FILEINFO *file) enable[MOUNTVMC1] = FALSE; enable[GETSIZE] = FALSE; } -//#ifdef TMANIP - if ( //if - (file->stats.AttrFile & sceMcFileAttrSubdir) && //pointing to a folder - (strcmp(file->name, "..")) && //it isnt the ".." option - ((!strcmp(path, "mc0:/")) || (!strcmp(path, "mc1:/"))) //we're on Memory card roots + //#ifdef TMANIP + if ( // if + (file->stats.AttrFile & sceMcFileAttrSubdir) && // pointing to a folder + (strcmp(file->name, "..")) && // it isnt the ".." option + ((!strcmp(path, "mc0:/")) || (!strcmp(path, "mc1:/"))) // we're on Memory card roots ) { enable[TIMEMANIP] = TRUE; } else { enable[TIMEMANIP] = FALSE; - } -//#endif //TMANIP - if ( (genCmpFileExt(file->name, "ELF")) && ( (!strncmp(path, "mass", 4)) || (!strncmp(path, "hdd0:/", 6) && !menu_disabled) ) ) - { + } + //#endif //TMANIP + if ((genCmpFileExt(file->name, "ELF")) && ((!strncmp(path, "mass", 4)) || (!strncmp(path, "hdd0:/", 6) && !menu_disabled))) { enable[TITLE_CFG] = TRUE; - } else {enable[TITLE_CFG] = FALSE;} + } else { + enable[TITLE_CFG] = FALSE; + } if (write_disabled || menu_disabled) { @@ -1752,46 +1750,46 @@ int menu(const char *path, FILEINFO *file) } if ((file->stats.AttrFile & sceMcFileAttrSubdir) || !strncmp(path, "vmc", 3) || !strncmp(path, "mc", 2)) { - enable[MOUNTVMC0] = FALSE; //forbid insane VMC mounting - enable[MOUNTVMC1] = FALSE; //forbid insane VMC mounting + enable[MOUNTVMC0] = FALSE; // forbid insane VMC mounting + enable[MOUNTVMC1] = FALSE; // forbid insane VMC mounting } if (nclipFiles == 0) { - //Nothing in clipboard + // Nothing in clipboard enable[PASTE] = FALSE; enable[MCPASTE] = FALSE; enable[PSUPASTE] = FALSE; } else { - //Something in clipboard + // Something in clipboard if (!strncmp(path, "mc", 2) || !strncmp(path, "vmc", 3)) { if (!strncmp(clipPath, "mc", 2) || !strncmp(clipPath, "vmc", 3)) { - enable[MCPASTE] = FALSE; //No mcPaste if both src and dest are MC + enable[MCPASTE] = FALSE; // No mcPaste if both src and dest are MC enable[PSUPASTE] = FALSE; } } else if (strncmp(clipPath, "mc", 2) && strncmp(clipPath, "vmc", 3)) { - enable[MCPASTE] = FALSE; //No mcPaste if both src and dest non-MC + enable[MCPASTE] = FALSE; // No mcPaste if both src and dest non-MC enable[PSUPASTE] = FALSE; } } - for (sel = 0; sel < NUM_MENU; sel++) //loop to preselect the first enabled menu entry + for (sel = 0; sel < NUM_MENU; sel++) // loop to preselect the first enabled menu entry if (enable[sel] == TRUE) - break; //break loop if sel is at an enabled menu entry + break; // break loop if sel is at an enabled menu entry - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP && sel < NUM_MENU) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command do { sel--; if (sel < 0) sel = NUM_MENU - 1; } while (!enable[sel]); } else if (new_pad & PAD_DOWN && sel < NUM_MENU) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command do { sel++; if (sel == NUM_MENU) @@ -1800,17 +1798,17 @@ int menu(const char *path, FILEINFO *file) } else if ((new_pad & PAD_TRIANGLE) || (!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { return -1; } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; } else if (new_pad & PAD_SQUARE && sel == PASTE) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2); @@ -1843,11 +1841,11 @@ int menu(const char *path, FILEINFO *file) strcpy(tmp, LNG(Get_Size)); else if (i == TITLE_CFG) strcpy(tmp, LNG(title_cfg)); - #ifdef TMANIP +#ifdef TMANIP else if (i == TIMEMANIP) strcpy(tmp, LNG(time_manip)); - #endif //TMANIP - +#endif // TMANIP + if (enable[i]) color = setting->color[COLOR_TEXT]; else @@ -1859,7 +1857,7 @@ int menu(const char *path, FILEINFO *file) if (sel < NUM_MENU) drawChar(LEFT_CUR, mSprite_X1 + FONT_WIDTH, mSprite_Y1 + (FONT_HEIGHT / 2 + sel * FONT_HEIGHT), setting->color[COLOR_TEXT]); - //Tooltip section + // Tooltip section x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], @@ -1883,13 +1881,13 @@ int menu(const char *path, FILEINFO *file) "3:%s", LNG(Back)); printXY(tmp, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while return sel; -} //ends menu +} // ends menu //-------------------------------------------------------------- char *PathPad_menu(const char *path) { @@ -1900,22 +1898,22 @@ char *PathPad_menu(const char *path) int event, post_event = 0; char textrow[80], tmp[64]; - th = 10 * FONT_HEIGHT; //Height in pixels of text area - tw = 68 * FONT_WIDTH; //Width in pixels of max text row - dh = th + 2 * 2 + a + b + c; //Height in pixels of entire frame - dw = tw + 2 * 2 + a * 2; //Width in pixels of entire frame - dx = (SCREEN_WIDTH - dw) / 2; //X position of frame (centred) - dy = (SCREEN_HEIGHT - dh) / 2; //Y position of frame (centred) + th = 10 * FONT_HEIGHT; // Height in pixels of text area + tw = 68 * FONT_WIDTH; // Width in pixels of max text row + dh = th + 2 * 2 + a + b + c; // Height in pixels of entire frame + dw = tw + 2 * 2 + a * 2; // Width in pixels of entire frame + dx = (SCREEN_WIDTH - dw) / 2; // X position of frame (centred) + dy = (SCREEN_HEIGHT - dh) / 2; // Y position of frame (centred) sel_x = 0; sel_y = 0; - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (new_pad & PAD_UP) { sel_y--; if (sel_y < 0) @@ -1940,23 +1938,23 @@ char *PathPad_menu(const char *path) sel_x++; if (sel_x > 2) sel_x = 0; - } else if (new_pad & PAD_TRIANGLE) { //Pushed 'Back' + } else if (new_pad & PAD_TRIANGLE) { // Pushed 'Back' return NULL; - } else if (!setting->PathPad_Lock //if PathPad changes allowed ? - && ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE))) { //Pushed 'Clear' + } else if (!setting->PathPad_Lock // if PathPad changes allowed ? + && ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE))) { // Pushed 'Clear' PathPad[sel_x * 10 + sel_y][0] = '\0'; - } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { //Pushed 'Use' + } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { // Pushed 'Use' return PathPad[sel_x * 10 + sel_y]; - } else if (!setting->PathPad_Lock && (new_pad & PAD_SQUARE)) { //Pushed 'Set' + } else if (!setting->PathPad_Lock && (new_pad & PAD_SQUARE)) { // Pushed 'Set' strncpy(PathPad[sel_x * 10 + sel_y], path, MAX_PATH - 1); PathPad[sel_x * 10 + sel_y][MAX_PATH - 1] = '\0'; } - } //ends 'if(new_pad)' - } //ends 'if(readpad())' + } // ends 'if(new_pad)' + } // ends 'if(readpad())' - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawSprite(setting->color[COLOR_BACKGR], 0, (Menu_message_y - 1), SCREEN_WIDTH, (Frame_start_y)); @@ -1975,7 +1973,7 @@ char *PathPad_menu(const char *path) printXY(textrow, dx + 2 + a, (dy + a + 2 + i * FONT_HEIGHT), color, TRUE, 0); } - //Tooltip section + // Tooltip section x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], 0, y - 1, SCREEN_WIDTH, y + FONT_HEIGHT); @@ -2008,14 +2006,14 @@ char *PathPad_menu(const char *path) LNG(Back), LNG(Page_leftright)); strcat(textrow, tmp); printXY(textrow, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while } //------------------------------ -//endfunc PathPad_menu +// endfunc PathPad_menu //-------------------------------------------------------------- u64 getFileSize(const char *path, const FILEINFO *file) { @@ -2025,24 +2023,24 @@ u64 getFileSize(const char *path, const FILEINFO *file) char dir[MAX_PATH], party[MAX_NAME]; int nfiles, i, ret; - if (file->stats.AttrFile & sceMcFileAttrSubdir) { //Folder object to size up + if (file->stats.AttrFile & sceMcFileAttrSubdir) { // Folder object to size up sprintf(dir, "%s%s/", path, file->name); nfiles = getDir(dir, files); for (i = size = 0; i < nfiles; i++) { - filesize = getFileSize(dir, &files[i]); //recurse for each object in folder + filesize = getFileSize(dir, &files[i]); // recurse for each object in folder if (filesize < 0) return -1; else size += filesize; } - } else { //File object to size up + } else { // File object to size up if (!strncmp(path, "hdd", 3)) { getHddParty(path, file, party, dir); ret = mountParty(party); if (ret < 0) return 0; dir[3] = ret + '0'; -#ifdef DVRP +#ifdef DVRP } if (!strncmp(path, "dvr_hdd", 7)) { getHddDVRPParty(path, file, party, dir); @@ -2063,65 +2061,66 @@ u64 getFileSize(const char *path, const FILEINFO *file) return size; } //------------------------------ -//endfunc getFileSize +// endfunc getFileSize //-------------------------------------------------------------- // -//this function will allow you to force the date of any memory-card save file... +// this function will allow you to force the date of any memory-card save file... //... into the highest date available for a ps2 (1 second before year 2100) // ----------=====args=====---------- // path: mc0:/ or mc1:/ // const FILEINFO *file = the FILEINFO struct for that save, however, this function only cares about folder name //_msg0 = pointer to msg0 to report what happened to the user (uLaunchELF only) //#ifdef TMANIP - void time_manip(const char *path, const FILEINFO *file, char **_msg0) - { - int rett; //this var will be used to store the result of mcSetFileInfo() - int slot; - slot = path[2] - '0'; - #define ARRAY_ENTRIES 64 - static sceMcTblGetDir mcDirAAA[ARRAY_ENTRIES] __attribute__((aligned(64))); // save file properties - static sceMcStDateTime new_mtime; //manipulated struct for savefile properties, this will be used to change the date of the save file properties - //char *result,*end; - /*=====================================================================================================*/ +void time_manip(const char *path, const FILEINFO *file, char **_msg0) +{ + int rett; // this var will be used to store the result of mcSetFileInfo() + int slot; + slot = path[2] - '0'; +#define ARRAY_ENTRIES 64 + static sceMcTblGetDir mcDirAAA[ARRAY_ENTRIES] __attribute__((aligned(64))); // save file properties + static sceMcStDateTime new_mtime; // manipulated struct for savefile properties, this will be used to change the date of the save file properties + // char *result,*end; + /*=====================================================================================================*/ /* #ifdef TMANIP_MORON - McGetDir(slot, 0, HACK_FOLDER, 0x2, ARRAY_ENTRIES, &mcDirAAA); + McGetDir(slot, 0, HACK_FOLDER, 0x2, ARRAY_ENTRIES, &mcDirAAA); #else - McGetDir(slot, 0, file->name, 0x2, ARRAY_ENTRIES, &mcDirAAA); - #endif*/ //till i find the real name of this func on ps2dev:1.0 - new_mtime.Resv2 = 0; - new_mtime.Sec = 59; - new_mtime.Min = 59; - new_mtime.Hour = 23; - new_mtime.Day = 31; - new_mtime.Month = 12; - new_mtime.Year = 2099; - mcDirAAA->_Modify = new_mtime; - mcDirAAA->_Create = new_mtime; - /*=====================================================================================================*/ - - #ifdef TMANIP_MORON - rett = mcSetFileInfo(slot, 0, HACK_FOLDER, mcDirAAA, 0x02); - if (rett == 0) - sprintf(_msg0, "success, folder [%s] Mc Slot [%d] .", HACK_FOLDER, slot); - if (rett < 0) - sprintf(_msg0, "error [%d], folder[%s] Mc Slot=[%d] .", rett, HACK_FOLDER, slot); - #else - rett = mcSetFileInfo(slot, 0, file->name, mcDirAAA, 0x02); - if (rett == 0) - sprintf(_msg0, "success, folder [%s] Mc Slot [%d] .", file->name, slot); - if (rett < 0) - sprintf(_msg0, "error [%d], folder[%s] Mc Slot=[%d] .", rett, file->name, slot); - #endif //TMANIP_MORON - - - - mcSync(0, NULL, &rett); - } // TIMEMANIP - //------------------------------ - //endfunc time_manip - //-------------------------------------------------------------- - // + McGetDir(slot, 0, file->name, 0x2, ARRAY_ENTRIES, &mcDirAAA); + #endif*/ + // till i find the real name of this func on ps2dev:1.0 + new_mtime.Resv2 = 0; + new_mtime.Sec = 59; + new_mtime.Min = 59; + new_mtime.Hour = 23; + new_mtime.Day = 31; + new_mtime.Month = 12; + new_mtime.Year = 2099; + mcDirAAA->_Modify = new_mtime; + mcDirAAA->_Create = new_mtime; + /*=====================================================================================================*/ + +#ifdef TMANIP_MORON + rett = mcSetFileInfo(slot, 0, HACK_FOLDER, mcDirAAA, 0x02); + if (rett == 0) + sprintf(_msg0, "success, folder [%s] Mc Slot [%d] .", HACK_FOLDER, slot); + if (rett < 0) + sprintf(_msg0, "error [%d], folder[%s] Mc Slot=[%d] .", rett, HACK_FOLDER, slot); +#else + rett = mcSetFileInfo(slot, 0, file->name, mcDirAAA, 0x02); + if (rett == 0) + sprintf(_msg0, "success, folder [%s] Mc Slot [%d] .", file->name, slot); + if (rett < 0) + sprintf(_msg0, "error [%d], folder[%s] Mc Slot=[%d] .", rett, file->name, slot); +#endif // TMANIP_MORON + + + + mcSync(0, NULL, &rett); +} // TIMEMANIP + //------------------------------ + // endfunc time_manip +//-------------------------------------------------------------- +// //#endif //TMANIP void make_title_cfg(const char *path, const FILEINFO *file, char **_msg0) @@ -2129,22 +2128,21 @@ void make_title_cfg(const char *path, const FILEINFO *file, char **_msg0) int fd; char title_cfg_buffer[128], ELF_NAME[64]; strcpy(ELF_NAME, file->name); - ELF_NAME[strlen(ELF_NAME)-4] = '\0';//kill extension, we can do this freely without checking string length because feature is only enabled on .ELF files - sprintf(title_cfg_buffer,"title=%s\nboot=%s", ELF_NAME, file->name); + ELF_NAME[strlen(ELF_NAME) - 4] = '\0'; // kill extension, we can do this freely without checking string length because feature is only enabled on .ELF files + sprintf(title_cfg_buffer, "title=%s\nboot=%s", ELF_NAME, file->name); char new_title_cfg[MAX_PATH]; - strcpy(new_title_cfg,path); + strcpy(new_title_cfg, path); strcat(new_title_cfg, "title.cfg"); if ((fd = genOpen(new_title_cfg, O_CREAT | O_WRONLY | O_TRUNC)) < 0) { - sprintf(_msg0, "Error opening title.cfg"); - return; - } else { - genWrite(fd, title_cfg_buffer, strlen(title_cfg_buffer)); - genClose(fd); - } - + sprintf(_msg0, "Error opening title.cfg"); + return; + } else { + genWrite(fd, title_cfg_buffer, strlen(title_cfg_buffer)); + genClose(fd); + } } //------------------------------ -//endfunc make_title_cfg +// endfunc make_title_cfg //-------------------------------------------------------------- int delete (const char *path, const FILEINFO *file) { @@ -2173,11 +2171,11 @@ int delete (const char *path, const FILEINFO *file) if (!strncmp(dir, "host:/", 6)) makeHostPath(dir + 5, dir + 6); #endif - if (file->stats.AttrFile & sceMcFileAttrSubdir) { //Is the object to delete a folder ? + if (file->stats.AttrFile & sceMcFileAttrSubdir) { // Is the object to delete a folder ? strcat(dir, "/"); nfiles = getDir(dir, files); for (i = 0; i < nfiles; i++) { - ret = delete (dir, &files[i]); //recursively delete contents of folder + ret = delete (dir, &files[i]); // recursively delete contents of folder if (ret < 0) return -1; } @@ -2192,11 +2190,11 @@ int delete (const char *path, const FILEINFO *file) ret = fileXioRmdir(dir); fileXioDevctl("vmc0:", DEVCTL_VMCFS_CLEAN, NULL, 0, NULL, 0); - } else { //For all other devices + } else { // For all other devices sprintf(dir, "%s%s", path, file->name); ret = fileXioRmdir(dir); } - } else { //The object to delete is a file + } else { // The object to delete is a file if (!strncmp(path, "mc", 2)) { mcSync(0, NULL, NULL); mcDelete(dir[2] - '0', 0, &dir[4]); @@ -2206,7 +2204,7 @@ int delete (const char *path, const FILEINFO *file) } else if (!strncmp(path, "vmc", 3)) { ret = fileXioRemove(dir); fileXioDevctl("vmc0:", DEVCTL_VMCFS_CLEAN, NULL, 0, NULL, 0); - } else { //For all other devices + } else { // For all other devices ret = fileXioRemove(dir); } } @@ -2247,24 +2245,24 @@ int Rename(const char *path, const FILEINFO *file, const char *name) } else if (!strncmp(path, "mc", 2)) { sprintf(oldPath, "%s%s", path, file->name); sprintf(newPath, "%s%s", path, name); - if ((test = fileXioDopen(newPath)) >= 0) { //Does folder of same name exist ? + if ((test = fileXioDopen(newPath)) >= 0) { // Does folder of same name exist ? fileXioDclose(test); ret = -EEXIST; - } else if ((test = fileXioOpen(newPath, O_RDONLY)) >= 0) { //Does file of same name exist ? + } else if ((test = fileXioOpen(newPath, O_RDONLY)) >= 0) { // Does file of same name exist ? fileXioClose(test); ret = -EEXIST; - } else { //No file/folder of the same name exists + } else { // No file/folder of the same name exists mcGetInfo(path[2] - '0', 0, &mctype_PSx, NULL, NULL); mcSync(0, NULL, &test); - if (mctype_PSx == 2) //PS2 MC ? + if (mctype_PSx == 2) // PS2 MC ? strncpy((void *)file->stats.EntryName, name, 32); - mcSetFileInfo(path[2] - '0', 0, oldPath + 4, &file->stats, 0x0010); //Fix file stats + mcSetFileInfo(path[2] - '0', 0, oldPath + 4, &file->stats, 0x0010); // Fix file stats mcSync(0, NULL, &test); if (ret == -4) ret = -EEXIST; - else { //PS1 MC ! + else { // PS1 MC ! strncpy((void *)file->stats.EntryName, name, 32); - mcSetFileInfo(path[2] - '0', 0, oldPath + 4, &file->stats, 0x0010); //Fix file stats + mcSetFileInfo(path[2] - '0', 0, oldPath + 4, &file->stats, 0x0010); // Fix file stats mcSync(0, NULL, &test); if (ret == -4) ret = -EEXIST; @@ -2280,22 +2278,22 @@ int Rename(const char *path, const FILEINFO *file, const char *name) strcpy(newPath, oldPath + 5); strcat(oldPath, file->name); strcat(newPath, name); - if (file->stats.AttrFile & sceMcFileAttrSubdir) { //Rename a folder ? + if (file->stats.AttrFile & sceMcFileAttrSubdir) { // Rename a folder ? ret = (temp_fd = fileXioDopen(oldPath)); if (temp_fd >= 0) { ret = fileXioIoctl(temp_fd, IOCTL_RENAME, (void *)newPath); fileXioDclose(temp_fd); } - } else if (file->stats.AttrFile & sceMcFileAttrFile) { //Rename a file ? + } else if (file->stats.AttrFile & sceMcFileAttrFile) { // Rename a file ? ret = (temp_fd = fileXioOpen(oldPath, O_RDONLY)); if (temp_fd >= 0) { ret = fileXioIoctl(temp_fd, IOCTL_RENAME, (void *)newPath); fileXioClose(temp_fd); } - } else //This was neither a folder nor a file !!! + } else // This was neither a folder nor a file !!! return -1; #endif - } else { //For all other devices + } else { // For all other devices sprintf(oldPath, "%s%s", path, file->name); sprintf(newPath, "%s%s", path, name); ret = fileXioRename(oldPath, newPath); @@ -2336,7 +2334,7 @@ int newdir(const char *path, const char *name) genLimObjName(dir, 0); if ((ret = fileXioDopen(dir)) >= 0) { fileXioDclose(ret); - ret = -EEXIST; //return fileXio error code for pre-existing folder + ret = -EEXIST; // return fileXio error code for pre-existing folder } else { ret = fileXioMkdir(dir, fileMode); } @@ -2347,7 +2345,7 @@ int newdir(const char *path, const char *name) mcMkDir(path[2] - '0', 0, dir); mcSync(0, NULL, &ret); if (ret == -4) - ret = -EEXIST; //return fileXio error code for pre-existing folder + ret = -EEXIST; // return fileXio error code for pre-existing folder #ifdef ETH } else if (!strncmp(path, "host", 4)) { strcpy(dir, path); @@ -2357,12 +2355,12 @@ int newdir(const char *path, const char *name) makeHostPath(dir + 5, dir + 6); if ((ret = fileXioDopen(dir)) >= 0) { fileXioDclose(ret); - ret = -EEXIST; //return fileXio error code for pre-existing folder + ret = -EEXIST; // return fileXio error code for pre-existing folder } else { - ret = fileXioMkdir(dir, fileMode); //Create the new folder + ret = fileXioMkdir(dir, fileMode); // Create the new folder } #endif - } else { //For all other devices + } else { // For all other devices strcpy(dir, path); strcat(dir, name); genLimObjName(dir, 0); @@ -2371,10 +2369,10 @@ int newdir(const char *path, const char *name) return ret; } //-------------------------------------------------------------- -//The function 'copy' below is called to copy a single object, -//indicated by 'file' from 'inPath' to 'outPath', but this may -//be either a single file or a folder. In the latter case the -//folder contents should also be copied, recursively. +// The function 'copy' below is called to copy a single object, +// indicated by 'file' from 'inPath' to 'outPath', but this may +// be either a single file or a folder. In the latter case the +// folder contents should also be copied, recursively. //-------------------------------------------------------------- int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) { @@ -2398,19 +2396,19 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) int psu_pad_size = 0, PSU_restart_f = 0; char *cp, *np; - PM_flag[recurses + 1] = PM_NORMAL; //assume normal mode for next level - PM_file[recurses + 1] = -1; //assume that no special file is needed + PM_flag[recurses + 1] = PM_NORMAL; // assume normal mode for next level + PM_file[recurses + 1] = -1; // assume that no special file is needed -restart_copy: //restart point for PM_PSU_RESTORE to reprocess modified arguments +restart_copy: // restart point for PM_PSU_RESTORE to reprocess modified arguments - newfile = file; //assume that no renaming is to be done + newfile = file; // assume that no renaming is to be done - if (PasteMode == PM_RENAME && recurses == 0) { //if renaming requested and valid - if (keyboard(newfile.name, 36) <= 0) //if name entered by user made the result invalid + if (PasteMode == PM_RENAME && recurses == 0) { // if renaming requested and valid + if (keyboard(newfile.name, 36) <= 0) // if name entered by user made the result invalid strcpy(newfile.name, file.name); // recopy newname from file.name - } //ends if clause for renaming name entry - //Here the struct 'newfile' is FILEINFO for destination, regardless of renaming - //for non-renaming cases this is always identical to the struct 'file' + } // ends if clause for renaming name entry + // Here the struct 'newfile' is FILEINFO for destination, regardless of renaming + // for non-renaming cases this is always identical to the struct 'file' if (!strncmp(inPath, "hdd", 3)) { getHddParty(inPath, &file, inParty, in); @@ -2440,29 +2438,29 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) sprintf(out, "%s%s", outPath, newfile.name); if (!strcmp(in, out)) - return 0; //if in and out are identical our work is done. + return 0; // if in and out are identical our work is done. - //Here 'in' and 'out' are complete pathnames for the object to copy - //patched to contain appropriate 'pfs' refs where args used 'hdd' - //The physical device specifiers remain in 'inPath' and 'outPath' + // Here 'in' and 'out' are complete pathnames for the object to copy + // patched to contain appropriate 'pfs' refs where args used 'hdd' + // The physical device specifiers remain in 'inPath' and 'outPath' - //Here we have an object to copy, which may be either a file or a folder + // Here we have an object to copy, which may be either a file or a folder if (file.stats.AttrFile & sceMcFileAttrSubdir) { - //Here we have a folder to copy, starting with an attempt to create it - //This is where we must act differently for PSU backup, creating a PSU file instead + // Here we have a folder to copy, starting with an attempt to create it + // This is where we must act differently for PSU backup, creating a PSU file instead if (PasteMode == PM_PSU_BACKUP) { if (recurses) - return -1; //abort, as subfolders are not copied to PSU backups + return -1; // abort, as subfolders are not copied to PSU backups i = strlen(out) - 1; if (out[i] == '/') out[i] = 0; strcpy(tmp, out); - np = tmp + strlen(tmp) - strlen(file.name); //np = start of the pure filename - cp = tmp + strlen(tmp); //cp = end of the pure filename + np = tmp + strlen(tmp) - strlen(file.name); // np = start of the pure filename + cp = tmp + strlen(tmp); // cp = end of the pure filename if (!setting->PSU_HugeNames) - cp = np; //cp = start of the pure filename + cp = np; // cp = start of the pure filename - if ((file_show == 2) || setting->PSU_HugeNames) { //at request, use game title + if ((file_show == 2) || setting->PSU_HugeNames) { // at request, use game title ret = getGameTitle(inPath, &file, file.title); if ((ret == 0) && file.title[0] && setting->PSU_HugeNames) { *cp++ = '_'; @@ -2470,50 +2468,50 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) } transcpy_sjis(cp, file.title); } - //Here game title has been used for the name if requested, either alone - //or combined with the original folder name (for PSU_HugeNames) + // Here game title has been used for the name if requested, either alone + // or combined with the original folder name (for PSU_HugeNames) - if (np[0] == 0) //If name is now empty (bad gamesave title) - strcpy(np, file.name); //revert to normal folder name + if (np[0] == 0) // If name is now empty (bad gamesave title) + strcpy(np, file.name); // revert to normal folder name for (i = 0; np[i];) { - i = strcspn(np, "\"\\/:*?<>|"); //Filter out illegal name characters + i = strcspn(np, "\"\\/:*?<>|"); // Filter out illegal name characters if (np[i]) np[i] = '_'; } - //Here illegal characters, from either title or original folder name - //have been filtered out (replaced by underscore) to ensure compatibility + // Here illegal characters, from either title or original folder name + // have been filtered out (replaced by underscore) to ensure compatibility - cp = tmp + strlen(tmp); //set cp pointing to the end of the filename - if (setting->PSU_DateNames) { //at request, append modification timestamp string + cp = tmp + strlen(tmp); // set cp pointing to the end of the filename + if (setting->PSU_DateNames) { // at request, append modification timestamp string sprintf(cp, "_%04d-%02d-%02d_%02d-%02d-%02d", mcT_head_p->mTime.year, mcT_head_p->mTime.month, mcT_head_p->mTime.day, mcT_head_p->mTime.hour, mcT_head_p->mTime.min, mcT_head_p->mTime.sec); } - //Here a timestamp has been added to the name if requested by PSU_DateNames + // Here a timestamp has been added to the name if requested by PSU_DateNames - genLimObjName(tmp, 4); //Limit name to leave room for 4 characters more - strcat(tmp, ".psu"); //add the PSU file extension + genLimObjName(tmp, 4); // Limit name to leave room for 4 characters more + strcat(tmp, ".psu"); // add the PSU file extension #ifdef ETH if (!strncmp(tmp, "host:/", 6)) makeHostPath(tmp + 5, tmp + 6); #endif if (setting->PSU_DateNames && setting->PSU_NoOverwrite) { - if (0 <= (out_fd = genOpen(tmp, O_RDONLY))) { //Name conflict ? + if (0 <= (out_fd = genOpen(tmp, O_RDONLY))) { // Name conflict ? genClose(out_fd); out_fd = -1; return 0; } } - //here tmp is the name of an existing file, to be removed before making new one + // here tmp is the name of an existing file, to be removed before making new one genRemove(tmp); if (0 > (out_fd = genOpen(tmp, O_WRONLY | O_TRUNC | O_CREAT))) - return -1; //return error on failure to create PSU file + return -1; // return error on failure to create PSU file PM_file[recurses + 1] = out_fd; - PM_flag[recurses + 1] = PM_PSU_BACKUP; //Set PSU backup mode for next level + PM_flag[recurses + 1] = PM_PSU_BACKUP; // Set PSU backup mode for next level clear_psu_header(&PSU_head); - PSU_content = 2; //2 content headers minimum, for empty PSU + PSU_content = 2; // 2 content headers minimum, for empty PSU PSU_head.attr = mcT_head_p->attr; PSU_head.size = PSU_content; PSU_head.cTime = mcT_head_p->cTime; @@ -2528,20 +2526,20 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) return -1; } clear_psu_header(&PSU_head); - PSU_head.attr = 0x8427; //Standard folder attr, for pseudo "." and ".." + PSU_head.attr = 0x8427; // Standard folder attr, for pseudo "." and ".." PSU_head.cTime = mcT_head_p->cTime; PSU_head.mTime = mcT_head_p->mTime; - PSU_head.name[0] = '.'; //Set name entry to "." + PSU_head.name[0] = '.'; // Set name entry to "." size = genWrite(out_fd, (void *)&PSU_head, sizeof(PSU_head)); if (size != sizeof(PSU_head)) goto PSU_error; - PSU_head.name[1] = '.'; //Change name entry to ".." + PSU_head.name[1] = '.'; // Change name entry to ".." size = genWrite(out_fd, (void *)&PSU_head, sizeof(PSU_head)); if (size != sizeof(PSU_head)) goto PSU_error; - } else { //any other PasteMode than PM_PSU_BACKUP + } else { // any other PasteMode than PM_PSU_BACKUP ret = newdir(outPath, newfile.name); - if (ret == -17) { //NB: 'newdir' must return -17 for ALL pre-existing folder cases + if (ret == -17) { // NB: 'newdir' must return -17 for ALL pre-existing folder cases ret = getGameTitle(outPath, &newfile, newfile.title); transcpy_sjis(tmp, newfile.title); sprintf(progress, @@ -2560,7 +2558,7 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) if (ynDialog(progress) < 0) return -1; if ((PasteMode == PM_MC_BACKUP) || (PasteMode == PM_MC_RESTORE) || (PasteMode == PM_PSU_RESTORE)) { - ret = delete (outPath, &newfile); //Attempt recursive delete + ret = delete (outPath, &newfile); // Attempt recursive delete if (ret < 0) return -1; if (newdir(outPath, newfile.name) < 0) @@ -2568,11 +2566,11 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) } drawMsg(LNG(Pasting)); } else if (ret < 0) { - return -1; //return error for failure to create destination folder + return -1; // return error for failure to create destination folder } } - //Here a destination folder, or a PSU file exists, ready to receive files - if (PasteMode == PM_MC_BACKUP) { //MC Backup mode folder paste preparation + // Here a destination folder, or a PSU file exists, ready to receive files + if (PasteMode == PM_MC_BACKUP) { // MC Backup mode folder paste preparation sprintf(tmp, "%s/PS2_MC_Backup_Attributes.BUP.bin", out); genRemove(tmp); out_fd = genOpen(tmp, O_WRONLY | O_CREAT); @@ -2585,7 +2583,7 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) } else genClose(PM_file[recurses + 1]); } - } else if (PasteMode == PM_MC_RESTORE) { //MC Restore mode folder paste preparation + } else if (PasteMode == PM_MC_RESTORE) { // MC Restore mode folder paste preparation sprintf(tmp, "%s/PS2_MC_Backup_Attributes.BUP.bin", in); #ifdef ETH if (!strncmp(tmp, "host:/", 6)) @@ -2594,7 +2592,7 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) in_fd = genOpen(tmp, O_RDONLY); if (in_fd >= 0) { - size = genRead(in_fd, (void *)&file.stats, 64); //Read stats for the save folder + size = genRead(in_fd, (void *)&file.stats, 64); // Read stats for the save folder if (size == 64) { PM_file[recurses + 1] = in_fd; PM_flag[recurses + 1] = PM_MC_RESTORE; @@ -2602,32 +2600,32 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) genClose(PM_file[recurses + 1]); } } - if (PM_flag[recurses + 1] == PM_NORMAL) { //Normal mode folder paste preparation + if (PM_flag[recurses + 1] == PM_NORMAL) { // Normal mode folder paste preparation } - sprintf(in, "%s%s/", inPath, file.name); //restore phys dev spec to 'in' - sprintf(out, "%s%s", outPath, newfile.name); //restore phys dev spec to 'out' - genLimObjName(out, 0); //Limit dest folder name - strcat(out, "/"); //Separate dest folder name + sprintf(in, "%s%s/", inPath, file.name); // restore phys dev spec to 'in' + sprintf(out, "%s%s", outPath, newfile.name); // restore phys dev spec to 'out' + genLimObjName(out, 0); // Limit dest folder name + strcat(out, "/"); // Separate dest folder name if (PasteMode == PM_PSU_RESTORE && PSU_restart_f) { nfiles = PSU_content; for (i = 0; i < nfiles; i++) { size = genRead(PM_file[recurses + 1], (void *)&PSU_head, sizeof(PSU_head)); - if (size != sizeof(PSU_head)) { //Break with error on read failure + if (size != sizeof(PSU_head)) { // Break with error on read failure ret = -1; break; } - if ((PSU_head.size == 0) && (PSU_head.attr & sceMcFileAttrSubdir)) //Dummy/Pseudo folder entry ? - continue; //Just ignore dummies - if (PSU_head.attr & sceMcFileAttrSubdir) { //break with error on weird folder in PSU + if ((PSU_head.size == 0) && (PSU_head.attr & sceMcFileAttrSubdir)) // Dummy/Pseudo folder entry ? + continue; // Just ignore dummies + if (PSU_head.attr & sceMcFileAttrSubdir) { // break with error on weird folder in PSU ret = -1; break; } - if (PSU_head.size & 0x3FF) //Check if file is padded in PSU + if (PSU_head.size & 0x3FF) // Check if file is padded in PSU psu_pad_size = 0x400 - (PSU_head.size & 0x3FF); else psu_pad_size = 0; - //here we need to create a proper FILEINFO struct for PSU-contained file + // here we need to create a proper FILEINFO struct for PSU-contained file mcT_files_p->attr = PSU_head.attr; mcT_files_p->size = PSU_head.size; mcT_files_p->cTime = PSU_head.cTime; @@ -2637,33 +2635,33 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) mcT_files_p->unknown_2_u64 = PSU_head.unknown_2_u64; memcpy(files[0].name, PSU_head.name, sizeof(PSU_head.name)); files[0].name[sizeof(PSU_head.name)] = 0; - //Finally we can make the recursive call + // Finally we can make the recursive call if ((ret = copy(out, in, files[0], recurses + 1)) < 0) break; - //We must also step past any file padding, for next header + // We must also step past any file padding, for next header if (psu_pad_size) genLseek(PM_file[recurses + 1], psu_pad_size, SEEK_CUR); - //finally, we must adjust attributes of the new file copy, to ensure - //correct timestamps and attributes (requires MC-specific functions) + // finally, we must adjust attributes of the new file copy, to ensure + // correct timestamps and attributes (requires MC-specific functions) strcpy(tmp, out); strncat(tmp, (const char *)files[0].stats.EntryName, 32); - mcGetInfo(tmp[2] - '0', 0, &dummy, &dummy, &dummy); //Wakeup call + mcGetInfo(tmp[2] - '0', 0, &dummy, &dummy, &dummy); // Wakeup call mcSync(0, NULL, &dummy); - mcSetFileInfo(tmp[2] - '0', 0, &tmp[4], &files[0].stats, MC_SFI); //Fix file stats + mcSetFileInfo(tmp[2] - '0', 0, &tmp[4], &files[0].stats, MC_SFI); // Fix file stats mcSync(0, NULL, &dummy); - } //ends main for loop of valid PM_PSU_RESTORE mode - genClose(PM_file[recurses + 1]); //Close the PSU file - //Finally fix the stats of the containing folder - //It has to be done last, as timestamps would change when fixing files + } // ends main for loop of valid PM_PSU_RESTORE mode + genClose(PM_file[recurses + 1]); // Close the PSU file + // Finally fix the stats of the containing folder + // It has to be done last, as timestamps would change when fixing files //--- This has been moved to a later clause, shared with PM_MC_RESTORE --- - } else { //Any other mode than a valid PM_PSU_RESTORE + } else { // Any other mode than a valid PM_PSU_RESTORE nfiles = getDir(in, files); for (i = 0; i < nfiles; i++) { if ((ret = copy(out, in, files[i], recurses + 1)) < 0) break; - } //ends main for loop for all modes other than valid PM_PSU_RESTORE + } // ends main for loop for all modes other than valid PM_PSU_RESTORE } - //folder contents are copied by the recursive call above, with error handling below + // folder contents are copied by the recursive call above, with error handling below if (ret < 0) { if (PM_flag[recurses + 1] == PM_PSU_BACKUP) goto PSU_error; @@ -2671,12 +2669,12 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) return -1; } - //Here folder contents have been copied error-free, but we also need to copy - //attributes and timestamps, and close the attribute/PSU file if such was used - //Lots of stuff need to be done here to make PSU operations work properly - if (PM_flag[recurses + 1] == PM_MC_BACKUP) { //MC Backup mode folder paste closure + // Here folder contents have been copied error-free, but we also need to copy + // attributes and timestamps, and close the attribute/PSU file if such was used + // Lots of stuff need to be done here to make PSU operations work properly + if (PM_flag[recurses + 1] == PM_MC_BACKUP) { // MC Backup mode folder paste closure genClose(PM_file[recurses + 1]); - } else if (PM_flag[recurses + 1] == PM_PSU_BACKUP) { //PSU Backup mode folder paste closure + } else if (PM_flag[recurses + 1] == PM_PSU_BACKUP) { // PSU Backup mode folder paste closure genLseek(PM_file[recurses + 1], 0, SEEK_SET); clear_psu_header(&PSU_head); PSU_head.attr = mcT_head_p->attr; @@ -2689,50 +2687,50 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) size = genWrite(PM_file[recurses + 1], (void *)&PSU_head, sizeof(PSU_head)); genLseek(PM_file[recurses + 1], 0, SEEK_END); genClose(PM_file[recurses + 1]); - } else if (PM_flag[recurses + 1] == PM_MC_RESTORE) { //MC Restore mode folder paste closure + } else if (PM_flag[recurses + 1] == PM_MC_RESTORE) { // MC Restore mode folder paste closure in_fd = PM_file[recurses + 1]; for (size = 64, i = 0; size == 64;) { size = genRead(in_fd, (void *)&stats, 64); if (size == 64) { strcpy(tmp, out); strncat(tmp, (const char *)stats.EntryName, 32); - mcGetInfo(tmp[2] - '0', 0, &dummy, &dummy, &dummy); //Wakeup call + mcGetInfo(tmp[2] - '0', 0, &dummy, &dummy, &dummy); // Wakeup call mcSync(0, NULL, &dummy); - mcSetFileInfo(tmp[2] - '0', 0, &tmp[4], &stats, MC_SFI); //Fix file stats + mcSetFileInfo(tmp[2] - '0', 0, &tmp[4], &stats, MC_SFI); // Fix file stats mcSync(0, NULL, &dummy); } else { genClose(in_fd); } } - //Finally fix the stats of the containing folder - //It has to be done last, as timestamps would change when fixing files + // Finally fix the stats of the containing folder + // It has to be done last, as timestamps would change when fixing files //--- This has been moved to a later clause, shared with PM_PSU_RESTORE --- - } else if (PM_flag[recurses + 1] == PM_NORMAL) { //Normal mode folder paste closure - if (!strncmp(out, "mc", 2)) { //Handle folder copied to MC - mcGetInfo(out[2] - '0', 0, &dummy, &dummy, &dummy); //Wakeup call + } else if (PM_flag[recurses + 1] == PM_NORMAL) { // Normal mode folder paste closure + if (!strncmp(out, "mc", 2)) { // Handle folder copied to MC + mcGetInfo(out[2] - '0', 0, &dummy, &dummy, &dummy); // Wakeup call mcSync(0, NULL, &dummy); - ret = MC_SFI; //default request for changing entire mcTable - if (strncmp(in, "mc", 2)) { //Handle file copied from non-MC to MC - file.stats.AttrFile = MC_ATTR_norm_folder; //normalize MC folder attribute + ret = MC_SFI; // default request for changing entire mcTable + if (strncmp(in, "mc", 2)) { // Handle file copied from non-MC to MC + file.stats.AttrFile = MC_ATTR_norm_folder; // normalize MC folder attribute #ifdef ETH - if (!strncmp(in, "host", 4)) { //Handle folder copied from host: to MC - ret = 4; //request change only of main attribute for host: - } //ends host: source clause + if (!strncmp(in, "host", 4)) { // Handle folder copied from host: to MC + ret = 4; // request change only of main attribute for host: + } // ends host: source clause #endif - } //ends non-MC source clause + } // ends non-MC source clause mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, ret); mcSync(0, NULL, &dummy); - } else { //Handle folder copied to non-MC - if (!strncmp(out, "host", 4)) { //for files copied to host: we skip Chstat - } else if (!strncmp(out, "mass", 4)) { //for files copied to mass: we skip Chstat - } else { //for other devices we use fileXio_ stuff + } else { // Handle folder copied to non-MC + if (!strncmp(out, "host", 4)) { // for files copied to host: we skip Chstat + } else if (!strncmp(out, "mass", 4)) { // for files copied to mass: we skip Chstat + } else { // for other devices we use fileXio_ stuff memcpy(iox_stat.ctime, (void *)&file.stats._Create, 8); memcpy(iox_stat.mtime, (void *)&file.stats._Modify, 8); memcpy(iox_stat.atime, iox_stat.mtime, 8); - ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; //Request timestamp stat change + ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; // Request timestamp stat change #ifdef ETH - if (!strncmp(in, "host", 4)) { //Handle folder copied from host: - ret = 0; //Request NO stat change + if (!strncmp(in, "host", 4)) { // Handle folder copied from host: + ret = 0; // Request NO stat change } #endif dummy = fileXioChStat(out, &iox_stat, ret); @@ -2740,23 +2738,23 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) } } if ((PM_flag[recurses + 1] == PM_MC_RESTORE) || (PM_flag[recurses + 1] == PM_PSU_RESTORE)) { - //Finally fix the stats of the containing folder - //It has to be done last, as timestamps would change when fixing files - mcGetInfo(out[2] - '0', 0, &dummy, &dummy, &dummy); //Wakeup call + // Finally fix the stats of the containing folder + // It has to be done last, as timestamps would change when fixing files + mcGetInfo(out[2] - '0', 0, &dummy, &dummy, &dummy); // Wakeup call mcSync(0, NULL, &dummy); - mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, MC_SFI); //Fix folder stats + mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, MC_SFI); // Fix folder stats mcSync(0, NULL, &dummy); } - //the return code below is used if there were no errors copying a folder + // the return code below is used if there were no errors copying a folder return 0; } - //Here we know that the object to copy is a file, not a folder - //But in PSU Restore mode we must treat PSU files as special folders, at level 0. - //and recursively call copy with higher recurse level to process the contents + // Here we know that the object to copy is a file, not a folder + // But in PSU Restore mode we must treat PSU files as special folders, at level 0. + // and recursively call copy with higher recurse level to process the contents if (PasteMode == PM_PSU_RESTORE && recurses == 0) { if (!genCmpFileExt(in, "psu")) - goto non_PSU_RESTORE_init; //if not a PSU file, go do normal pasting + goto non_PSU_RESTORE_init; // if not a PSU file, go do normal pasting in_fd = genOpen(in, O_RDONLY); @@ -2767,11 +2765,11 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) genClose(in_fd); return -1; } - PM_file[recurses + 1] = in_fd; //File descriptor for PSU - PM_flag[recurses + 1] = PM_PSU_RESTORE; //Mode flag for recursive entry - //Here we need to prep the file struct to appear like a normal MC folder - //before 'restarting' this 'copy' to handle creation of destination folder - //as well as the copying of files from the PSU into that folder + PM_file[recurses + 1] = in_fd; // File descriptor for PSU + PM_flag[recurses + 1] = PM_PSU_RESTORE; // Mode flag for recursive entry + // Here we need to prep the file struct to appear like a normal MC folder + // before 'restarting' this 'copy' to handle creation of destination folder + // as well as the copying of files from the PSU into that folder mcT_head_p->attr = PSU_head.attr; PSU_content = PSU_head.size; mcT_head_p->size = 0; @@ -2786,17 +2784,17 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) goto restart_copy; } non_PSU_RESTORE_init: - //In MC Restore mode we must here avoid copying the attribute file + // In MC Restore mode we must here avoid copying the attribute file if (PM_flag[recurses] == PM_MC_RESTORE) if (!strcmp(file.name, "PS2_MC_Backup_Attributes.BUP.bin")) return 0; - //It is now time to open the input file, indicated by 'in_fd' - //But in PSU Restore mode we must use the already open PSU file instead + // It is now time to open the input file, indicated by 'in_fd' + // But in PSU Restore mode we must use the already open PSU file instead if (PM_flag[recurses] == PM_PSU_RESTORE) { in_fd = PM_file[recurses]; size = mcT_head_p->size; - } else { //Any other mode than PM_PSU_RESTORE + } else { // Any other mode than PM_PSU_RESTORE #ifdef ETH if (!strncmp(in, "host:/", 6)) makeHostPath(in + 5, in + 6); @@ -2808,9 +2806,9 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) genLseek(in_fd, 0, SEEK_SET); } - //Here the input file has been opened, indicated by 'in_fd' - //It is now time to open the output file, indicated by 'out_fd' - //except in the case of a PSU backup, when we must add a header to PSU instead + // Here the input file has been opened, indicated by 'in_fd' + // It is now time to open the output file, indicated by 'out_fd' + // except in the case of a PSU backup, when we must add a header to PSU instead if (PM_flag[recurses] == PM_PSU_BACKUP) { out_fd = PM_file[recurses]; clear_psu_header(&PSU_head); @@ -2824,43 +2822,43 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) psu_pad_size = 0x400 - (PSU_head.size & 0x3FF); else psu_pad_size = 0; - PSU_content++; //Increase PSU content header count - } else { //Any other PasteMode than PM_PSU_BACKUP needs a new output file + PSU_content++; // Increase PSU content header count + } else { // Any other PasteMode than PM_PSU_BACKUP needs a new output file #ifdef ETH if (!strncmp(out, "host:/", 6)) makeHostPath(out + 5, out + 6); #endif - genLimObjName(out, 0); //Limit dest file name - genRemove(out); //Remove old file if present - out_fd = genOpen(out, O_WRONLY | O_TRUNC | O_CREAT); //Create new file + genLimObjName(out, 0); // Limit dest file name + genRemove(out); // Remove old file if present + out_fd = genOpen(out, O_WRONLY | O_TRUNC | O_CREAT); // Create new file if (out_fd < 0) goto copy_file_exit; } - //Here the output file has been opened, indicated by 'out_fd' + // Here the output file has been opened, indicated by 'out_fd' /* Determine the block size. Since LaunchELF is single-threaded, - using a large block size with a slow device will result in an unresponsive UI. - To prevent a loss in performance, these values must each be in a multiple of the device's sector/page size. - They must also be in multiples of 64, to prevent FILEIO from doing alignment correction in software. */ - buffSize = 0x100000; //First assume buffer size = 1MB (good for HDD) + using a large block size with a slow device will result in an unresponsive UI. + To prevent a loss in performance, these values must each be in a multiple of the device's sector/page size. + They must also be in multiples of 64, to prevent FILEIO from doing alignment correction in software. */ + buffSize = 0x100000; // First assume buffer size = 1MB (good for HDD) if (!strncmp(out, "mc", 2) || !strncmp(out, "mass", 4) || !strncmp(out, "vmc", 3)) - buffSize = 131072; //Use 128KB if writing to USB (Flash RAM writes) or MC (pretty slow). - //VMC contents should use the same size, as VMCs will often be stored on USB + buffSize = 131072; // Use 128KB if writing to USB (Flash RAM writes) or MC (pretty slow). + // VMC contents should use the same size, as VMCs will often be stored on USB else if (!strncmp(in, "mc", 2)) - buffSize = 262144; //Use 256KB if reading from MC (still pretty slow) + buffSize = 262144; // Use 256KB if reading from MC (still pretty slow) #ifdef ETH else if (!strncmp(out, "host", 4)) - buffSize = 393216; //Use 384KB if writing to HOST (acceptable) + buffSize = 393216; // Use 384KB if writing to HOST (acceptable) #endif else if ((!strncmp(in, "mass", 4)) || (!strncmp(in, "host", 4))) - buffSize = 524288; //Use 512KB reading from USB or HOST (acceptable) + buffSize = 524288; // Use 512KB reading from USB or HOST (acceptable) if (size < buffSize) buffSize = size; - buff = (char *)memalign(64, buffSize); //Attempt buffer allocation - if (buff == NULL) { //if allocation fails + buff = (char *)memalign(64, buffSize); // Attempt buffer allocation + if (buff == NULL) { // if allocation fails ret = -ENOMEM; genClose(out_fd); out_fd = -1; @@ -2869,27 +2867,27 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) goto copy_file_exit_mem_err; } - old_size = written_size; //Note initial progress data pos - OldTime = Timer(); //Note initial progress time + old_size = written_size; // Note initial progress data pos + OldTime = Timer(); // Note initial progress time while (size > 0) { // ----- The main copying loop starts here ----- if (size < buffSize) - buffSize = size; //Adjust effective buffer size to remaining data + buffSize = size; // Adjust effective buffer size to remaining data TimeDiff = Timer() - OldTime; OldTime = Timer(); SizeDiff = written_size - old_size; old_size = written_size; - if (SizeDiff) { //if anything was written this time - speed = (SizeDiff * 1000) / TimeDiff; //calc real speed - remain_time = size / speed; //calc time remaining for that speed - } else if (TimeDiff) { //if nothing written though time passed - speed = 0; //set speed as zero - remain_time = -1; //set time remaining as unknown - } else { //if nothing written and no time passed - speed = -1; //set speed as unknown - remain_time = -1; //set time remaining as unknown + if (SizeDiff) { // if anything was written this time + speed = (SizeDiff * 1000) / TimeDiff; // calc real speed + remain_time = size / speed; // calc time remaining for that speed + } else if (TimeDiff) { // if nothing written though time passed + speed = 0; // set speed as zero + remain_time = -1; // set time remaining as unknown + } else { // if nothing written and no time passed + speed = -1; // set speed as unknown + remain_time = -1; // set time remaining as unknown } sprintf(progress, "%s : %s", LNG(Pasting_file), file.name); @@ -2909,7 +2907,7 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) else if (speed <= 1024) sprintf(tmp, "%d %s/sec", speed, LNG(bytes)); // bytes/sec else - sprintf(tmp, "%d %s/sec", speed / 1024, LNG(Kbytes)); //Kbytes/sec + sprintf(tmp, "%d %s/sec", speed / 1024, LNG(Kbytes)); // Kbytes/sec strcat(progress, tmp); sprintf(tmp, "\n%s : ", LNG(Remain_Time)); @@ -2926,7 +2924,7 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) sprintf(tmp, "\n\n%s: ", LNG(Written_Total)); strcat(progress, tmp); - sprintf(tmp, "%lu %s", written_size / 1024, LNG(Kbytes)); //Kbytes + sprintf(tmp, "%lu %s", written_size / 1024, LNG(Kbytes)); // Kbytes strcat(progress, tmp); sprintf(tmp, "\n%s: ", LNG(Average_Speed)); @@ -2935,18 +2933,18 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) if (TimeDiff == 0) strcpy(tmp, LNG(Unknown)); else { - speed = (written_size * 1000) / TimeDiff; //calc real speed + speed = (written_size * 1000) / TimeDiff; // calc real speed if (speed <= 1024) sprintf(tmp, "%d %s/sec", speed, LNG(bytes)); // bytes/sec else - sprintf(tmp, "%d %s/sec", speed / 1024, LNG(Kbytes)); //Kbytes/sec + sprintf(tmp, "%d %s/sec", speed / 1024, LNG(Kbytes)); // Kbytes/sec } strcat(progress, tmp); - if (PasteProgress_f) //if progress report was used earlier in this pasting - nonDialog(NULL); //order cleanup for that screen area - nonDialog(progress); //Make new progress report - PasteProgress_f = 1; //and note that it was done for next time + if (PasteProgress_f) // if progress report was used earlier in this pasting + nonDialog(NULL); // order cleanup for that screen area + nonDialog(progress); // Make new progress report + PasteProgress_f = 1; // and note that it was done for next time drawMsg(file.name); #ifdef DS34 if (readpad() && new_pad) { @@ -2976,9 +2974,9 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) written_size += buffSize; } // ends while(size>0), ----- The main copying loop ends here ----- ret = 0; - //Here the file has been copied. without error, as indicated by 'ret' above - //but we also need to copy attributes and timestamps (as yet only for MC) - //For PSU backup output padding may be needed, but not output file closure + // Here the file has been copied. without error, as indicated by 'ret' above + // but we also need to copy attributes and timestamps (as yet only for MC) + // For PSU backup output padding may be needed, but not output file closure if (PM_flag[recurses] == PM_PSU_BACKUP) { if (psu_pad_size) { pad_psu_header(&PSU_head); @@ -2989,60 +2987,60 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) if (psu_pad_size) genWrite(out_fd, (void *)&PSU_head, psu_pad_size); } - out_fd = -1; //prevent output file closure below + out_fd = -1; // prevent output file closure below goto copy_file_exit; } - if (PM_flag[recurses] == PM_MC_BACKUP) { //MC Backup mode file paste closure + if (PM_flag[recurses] == PM_MC_BACKUP) { // MC Backup mode file paste closure size = genWrite(PM_file[recurses], (void *)&file.stats, 64); if (size != 64) - return -1; //Abort if attribute file crashed + return -1; // Abort if attribute file crashed } if (out_fd >= 0) { genClose(out_fd); - out_fd = -1; //prevent dual closure attempt + out_fd = -1; // prevent dual closure attempt } - if (!strncmp(out, "mc", 2)) { //Handle file copied to MC - mcGetInfo(out[2] - '0', 0, &mctype_PSx, &dummy, &dummy); //Wakeup call & MC type check + if (!strncmp(out, "mc", 2)) { // Handle file copied to MC + mcGetInfo(out[2] - '0', 0, &mctype_PSx, &dummy, &dummy); // Wakeup call & MC type check mcSync(0, NULL, &dummy); - ret = MC_SFI; //default request for changing entire mcTable - if (strncmp(in, "mc", 2)) { //Handle file copied from non-MC to MC - file.stats.AttrFile = MC_ATTR_norm_file; //normalize MC file attribute + ret = MC_SFI; // default request for changing entire mcTable + if (strncmp(in, "mc", 2)) { // Handle file copied from non-MC to MC + file.stats.AttrFile = MC_ATTR_norm_file; // normalize MC file attribute #ifdef ETH - if (!strncmp(in, "host", 4)) { //Handle folder copied from host: to MC - ret = 4; //request change only of main attribute for host: - } //ends host: source clause + if (!strncmp(in, "host", 4)) { // Handle folder copied from host: to MC + ret = 4; // request change only of main attribute for host: + } // ends host: source clause #endif - } //ends non-MC source clause - if (mctype_PSx == 2) { //if copying to a PS2 MC + } // ends non-MC source clause + if (mctype_PSx == 2) { // if copying to a PS2 MC mcSetFileInfo(out[2] - '0', 0, &out[4], &file.stats, ret); mcSync(0, NULL, &dummy); } - } else { //Handle file copied to non-MC - if (!strncmp(out, "host", 4)) { //for files copied to host: we skip Chstat - } else if (!strncmp(out, "mass", 4)) { //for files copied to mass: we skip Chstat - } else { //for other devices we use fileXio_ stuff + } else { // Handle file copied to non-MC + if (!strncmp(out, "host", 4)) { // for files copied to host: we skip Chstat + } else if (!strncmp(out, "mass", 4)) { // for files copied to mass: we skip Chstat + } else { // for other devices we use fileXio_ stuff memcpy(iox_stat.ctime, (void *)&file.stats._Create, 8); memcpy(iox_stat.mtime, (void *)&file.stats._Modify, 8); memcpy(iox_stat.atime, iox_stat.mtime, 8); - ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; //Request timestamp stat change + ret = FIO_CST_CT | FIO_CST_AT | FIO_CST_MT; // Request timestamp stat change #ifdef ETH - if (!strncmp(in, "host", 4)) { //Handle file copied from host: - ret = 0; //Request NO stat change + if (!strncmp(in, "host", 4)) { // Handle file copied from host: + ret = 0; // Request NO stat change } #endif dummy = fileXioChStat(out, &iox_stat, ret); } } -//The code below is also used for all errors in copying a file, -//but those cases are distinguished by a negative value in 'ret' +// The code below is also used for all errors in copying a file, +// but those cases are distinguished by a negative value in 'ret' copy_file_exit: free(buff); copy_file_exit_mem_err: - if (PM_flag[recurses] != PM_PSU_RESTORE) { //Avoid closing PSU file here for PSU Restore + if (PM_flag[recurses] != PM_PSU_RESTORE) { // Avoid closing PSU file here for PSU Restore if (in_fd >= 0) { genClose(in_fd); } @@ -3053,13 +3051,13 @@ int copy(char *outPath, const char *inPath, FILEINFO file, int recurses) return ret; } //------------------------------ -//endfunc copy +// endfunc copy //-------------------------------------------------------------- -//dlanor: For v3.64 the virtual keyboard function is modified to -//allow entry of empty strings. The function now returns string -//length, except if you use 'CANCEL' when it returns -1 instead. -//Routines that require a non-empty string (eg: Rename, Newdir) -//must test with '>' now, instead of '>=' as used previously. +// dlanor: For v3.64 the virtual keyboard function is modified to +// allow entry of empty strings. The function now returns string +// length, except if you use 'CANCEL' when it returns -1 instead. +// Routines that require a non-empty string (eg: Rename, Newdir) +// must test with '>' now, instead of '>=' as used previously. //-------------------------------------------------------------- int keyboard(char *out, int max) { @@ -3090,13 +3088,13 @@ int keyboard(char *out, int max) cur = (int)(p - out); KEY_LEN = strlen(KEY); - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad_no_KB()) { if (new_pad) - event |= 2; //event |= pad command + event |= 2; // event |= pad command if (new_pad & PAD_UP) { if (sel <= WFONTS * HFONTS) { if (sel >= WFONTS) @@ -3136,7 +3134,7 @@ int keyboard(char *out, int max) cur--; t = 0; } - } else if (new_pad & PAD_SQUARE) { //Square => space + } else if (new_pad & PAD_SQUARE) { // Square => space i = strlen(out); if (i < max && i < 33) { strcpy(tmp, out); @@ -3148,7 +3146,7 @@ int keyboard(char *out, int max) } } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { i = strlen(out); - if (sel < WFONTS * HFONTS) { //Any char in matrix selected ? + if (sel < WFONTS * HFONTS) { // Any char in matrix selected ? if (i < max && i < 33) { strcpy(tmp, out); out[cur] = KEY[sel]; @@ -3158,18 +3156,18 @@ int keyboard(char *out, int max) t = 0; } } else if (sel == WFONTS * HFONTS) { //'OK' exit-button selected ? - break; //break out of loop with i==strlen - } else //Must be 'CANCEL' exit-button + break; // break out of loop with i==strlen + } else // Must be 'CANCEL' exit-button return -1; } else if (new_pad & PAD_TRIANGLE) { return -1; } } - //Kbd response section + // Kbd response section if (setting->usbkbd_used && PS2KbdRead(&KeyPress)) { - event |= 2; //event |= pad command + event |= 2; // event |= pad command if (KeyPress == PS2KBD_ESCAPE_KEY) { PS2KbdRead(&KeyPress); @@ -3221,16 +3219,16 @@ int keyboard(char *out, int max) } } KeyPress = '\0'; - } //ends if(setting->usbkbd_used && PS2KbdRead(&KeyPress)) + } // ends if(setting->usbkbd_used && PS2KbdRead(&KeyPress)) t++; if (t & 0x0F) - event |= 4; //repetitive timer event + event |= 4; // repetitive timer event - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], KEY_X, KEY_Y, KEY_X + KEY_W - 1, KEY_Y + KEY_H - 1); @@ -3259,7 +3257,7 @@ int keyboard(char *out, int max) KEY_X + KEY_W - 1 - (strlen(LNG(CANCEL)) + 2) * FONT_WIDTH, KEY_Y + LINE_THICKNESS + 1 + FONT_HEIGHT + 1 + LINE_THICKNESS + 8 + HFONTS * FONT_HEIGHT, setting->color[COLOR_TEXT], TRUE, 0); - //Cursor positioning section + // Cursor positioning section if (sel <= WFONTS * HFONTS) x = KEY_X + LINE_THICKNESS + 12 + (sel % WFONTS) * (FONT_WIDTH + 12) - 8; else @@ -3267,7 +3265,7 @@ int keyboard(char *out, int max) y = KEY_Y + LINE_THICKNESS + 1 + FONT_HEIGHT + 1 + LINE_THICKNESS + 8 + (sel / WFONTS) * FONT_HEIGHT; drawChar(LEFT_CUR, x, y, setting->color[COLOR_SELECT]); - //Tooltip section + // Tooltip section x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], 0, y - 1, SCREEN_WIDTH, y + FONT_HEIGHT); @@ -3288,184 +3286,184 @@ int keyboard(char *out, int max) "3:%s", LNG(BackSpace), LNG(SPACE), LNG(Left), LNG(Right), LNG(Enter), LNG(Exit)); printXY(tmp, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while return strlen(out); } //------------------------------ -//endfunc keyboard +// endfunc keyboard //-------------------------------------------------------------- -//keyboard2 below is used for testing output from a USB keyboard -//it can be commented out when not used by the programmer. -//When using it for tests, simply replace the call to 'keyboard' -//somewhere (Rename routine is a good choice) with a call to +// keyboard2 below is used for testing output from a USB keyboard +// it can be commented out when not used by the programmer. +// When using it for tests, simply replace the call to 'keyboard' +// somewhere (Rename routine is a good choice) with a call to //'keyboard2' instead. It uses the old routines for virtual keys -//via gamepad, so you can still enter proper strings that way, -//but each key pressed on the USB keyboard will be expanded to a -//sequence corresponding to sprintf(somestring," %02X ", key). -//Thus four characters are added to the output string for each -//such key, and after character 32 the cursor loops back to the -//first character again. +// via gamepad, so you can still enter proper strings that way, +// but each key pressed on the USB keyboard will be expanded to a +// sequence corresponding to sprintf(somestring," %02X ", key). +// Thus four characters are added to the output string for each +// such key, and after character 32 the cursor loops back to the +// first character again. //-------------------------------------------------------------- /* int keyboard2(char *out, int max) { - int event, post_event=0; - const int KEY_W=276, - KEY_H=168, - KEY_X=(SCREEN_WIDTH - KEY_W)/2, - KEY_Y=((SCREEN_HEIGHT - KEY_H)/2), - WFONTS=13, - HFONTS=7; - char *KEY="ABCDEFGHIJKLM" - "NOPQRSTUVWXYZ" - "abcdefghijklm" - "nopqrstuvwxyz" - "0123456789 " - "()[]!#$%&@; " - "=+-'^.,_ "; - int KEY_LEN; - int cur=0, sel=0, i=0, x, y, t=0; - char tmp[256], *p; - unsigned char KeyPress; - - p=strrchr(out, '.'); - if(p==NULL) cur=strlen(out); - else cur=(int)(p-out); - KEY_LEN = strlen(KEY); - - event = 1; //event = initial entry - while(1){ - //Pad response section - waitPadReady(0, 0); - if(readpad_no_KB()){ - if(new_pad) - event |= 2; //event |= pad command - if(new_pad & PAD_UP){ - if(sel<=WFONTS*HFONTS){ - if(sel>=WFONTS) sel-=WFONTS; - }else{ - sel-=4; - } - }else if(new_pad & PAD_DOWN){ - if(sel/WFONTS == HFONTS-1){ - if(sel%WFONTS < 5) sel=WFONTS*HFONTS; - else sel=WFONTS*HFONTS+1; - }else if(sel/WFONTS <= HFONTS-2) - sel+=WFONTS; - }else if(new_pad & PAD_LEFT){ - if(sel>0) sel--; - }else if(new_pad & PAD_RIGHT){ - if(sel<=WFONTS*HFONTS) sel++; - }else if(new_pad & PAD_START){ - sel = WFONTS*HFONTS; - }else if(new_pad & PAD_L1){ - if(cur>0) cur--; - t=0; - }else if(new_pad & PAD_R1){ - if(cur0){ - strcpy(tmp, out); - out[cur-1]=0; - strcat(out, &tmp[cur]); - cur--; - t=0; - } - }else if((swapKeys && new_pad & PAD_CROSS) - || (!swapKeys && new_pad & PAD_CIRCLE) ){ - i=strlen(out); - if(sel < WFONTS*HFONTS){ //Any char in matrix selected ? - if(i=31) - cur=0; - t=0; - } //ends if(PS2KbdRead(&KeyPress)) - - t++; - - if(t & 0x0F) event |= 4; //repetitive timer event - - if(event||post_event){ //NB: We need to update two frame buffers per event - - //Display section - drawPopSprite(setting->color[COLOR_BACKGR], - KEY_X, KEY_Y, - KEY_X+KEY_W, KEY_Y+KEY_H); - drawFrame( - KEY_X, KEY_Y, - KEY_X+KEY_W, KEY_Y+KEY_H, setting->color[COLOR_FRAME]); - drawOpSprite(setting->color[COLOR_FRAME], - KEY_X, KEY_Y+20, - KEY_X+KEY_W, KEY_Y+20+LINE_THICKNESS); - printXY(out, KEY_X+2+3, KEY_Y+3, setting->color[COLOR_TEXT], TRUE, 0); - if(((event|post_event)&4) && (t & 0x10)){ - printXY("|", - KEY_X+cur*8+1, KEY_Y+3, setting->color[COLOR_TEXT], TRUE, 0); - } - for(i=0; icolor[COLOR_TEXT]); - printXY("OK CANCEL", - KEY_X+2+4 + 20 - 12, KEY_Y+28 + HFONTS*16, setting->color[COLOR_TEXT], TRUE, 0); - - //Cursor positioning section - if(sel<=WFONTS*HFONTS) - x = KEY_X+2+4 + (sel%WFONTS+1)*20 - 20; - else - x = KEY_X+2+4 + 25*8; - y = KEY_Y+28 + (sel/WFONTS)*16; - drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); - - //Tooltip section - x = SCREEN_MARGIN; - y = Menu_tooltip_y; - drawSprite(setting->color[COLOR_BACKGR], 0, y-1, SCREEN_WIDTH, y+FONT_HEIGHT); - - if (swapKeys) - printXY("\xFF""1:OK \xFF""0:Back L1:Left R1:Right START:Enter", - x, y, setting->color[COLOR_SELECT], TRUE, 0); - else - printXY("\xFF""0:OK \xFF""1:Back L1:Left R1:Right START:Enter", - x, y, setting->color[COLOR_SELECT], TRUE, 0); - }//ends if(event||post_event) - drawScr(); - post_event = event; - event = 0; - }//ends while - return i; + int event, post_event=0; + const int KEY_W=276, + KEY_H=168, + KEY_X=(SCREEN_WIDTH - KEY_W)/2, + KEY_Y=((SCREEN_HEIGHT - KEY_H)/2), + WFONTS=13, + HFONTS=7; + char *KEY="ABCDEFGHIJKLM" + "NOPQRSTUVWXYZ" + "abcdefghijklm" + "nopqrstuvwxyz" + "0123456789 " + "()[]!#$%&@; " + "=+-'^.,_ "; + int KEY_LEN; + int cur=0, sel=0, i=0, x, y, t=0; + char tmp[256], *p; + unsigned char KeyPress; + + p=strrchr(out, '.'); + if(p==NULL) cur=strlen(out); + else cur=(int)(p-out); + KEY_LEN = strlen(KEY); + + event = 1; //event = initial entry + while(1){ + //Pad response section + waitPadReady(0, 0); + if(readpad_no_KB()){ + if(new_pad) + event |= 2; //event |= pad command + if(new_pad & PAD_UP){ + if(sel<=WFONTS*HFONTS){ + if(sel>=WFONTS) sel-=WFONTS; + }else{ + sel-=4; + } + }else if(new_pad & PAD_DOWN){ + if(sel/WFONTS == HFONTS-1){ + if(sel%WFONTS < 5) sel=WFONTS*HFONTS; + else sel=WFONTS*HFONTS+1; + }else if(sel/WFONTS <= HFONTS-2) + sel+=WFONTS; + }else if(new_pad & PAD_LEFT){ + if(sel>0) sel--; + }else if(new_pad & PAD_RIGHT){ + if(sel<=WFONTS*HFONTS) sel++; + }else if(new_pad & PAD_START){ + sel = WFONTS*HFONTS; + }else if(new_pad & PAD_L1){ + if(cur>0) cur--; + t=0; + }else if(new_pad & PAD_R1){ + if(cur0){ + strcpy(tmp, out); + out[cur-1]=0; + strcat(out, &tmp[cur]); + cur--; + t=0; + } + }else if((swapKeys && new_pad & PAD_CROSS) + || (!swapKeys && new_pad & PAD_CIRCLE) ){ + i=strlen(out); + if(sel < WFONTS*HFONTS){ //Any char in matrix selected ? + if(i=31) + cur=0; + t=0; + } //ends if(PS2KbdRead(&KeyPress)) + + t++; + + if(t & 0x0F) event |= 4; //repetitive timer event + + if(event||post_event){ //NB: We need to update two frame buffers per event + + //Display section + drawPopSprite(setting->color[COLOR_BACKGR], + KEY_X, KEY_Y, + KEY_X+KEY_W, KEY_Y+KEY_H); + drawFrame( + KEY_X, KEY_Y, + KEY_X+KEY_W, KEY_Y+KEY_H, setting->color[COLOR_FRAME]); + drawOpSprite(setting->color[COLOR_FRAME], + KEY_X, KEY_Y+20, + KEY_X+KEY_W, KEY_Y+20+LINE_THICKNESS); + printXY(out, KEY_X+2+3, KEY_Y+3, setting->color[COLOR_TEXT], TRUE, 0); + if(((event|post_event)&4) && (t & 0x10)){ + printXY("|", + KEY_X+cur*8+1, KEY_Y+3, setting->color[COLOR_TEXT], TRUE, 0); + } + for(i=0; icolor[COLOR_TEXT]); + printXY("OK CANCEL", + KEY_X+2+4 + 20 - 12, KEY_Y+28 + HFONTS*16, setting->color[COLOR_TEXT], TRUE, 0); + + //Cursor positioning section + if(sel<=WFONTS*HFONTS) + x = KEY_X+2+4 + (sel%WFONTS+1)*20 - 20; + else + x = KEY_X+2+4 + 25*8; + y = KEY_Y+28 + (sel/WFONTS)*16; + drawChar(LEFT_CUR, x, y, setting->color[COLOR_TEXT]); + + //Tooltip section + x = SCREEN_MARGIN; + y = Menu_tooltip_y; + drawSprite(setting->color[COLOR_BACKGR], 0, y-1, SCREEN_WIDTH, y+FONT_HEIGHT); + + if (swapKeys) + printXY("\xFF""1:OK \xFF""0:Back L1:Left R1:Right START:Enter", + x, y, setting->color[COLOR_SELECT], TRUE, 0); + else + printXY("\xFF""0:OK \xFF""1:Back L1:Left R1:Right START:Enter", + x, y, setting->color[COLOR_SELECT], TRUE, 0); + }//ends if(event||post_event) + drawScr(); + post_event = event; + event = 0; + }//ends while + return i; } */ //------------------------------ -//endfunc keyboard2 (commented out except in testing) +// endfunc keyboard2 (commented out except in testing) //-------------------------------------------------------------- int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) { @@ -3476,8 +3474,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) nfiles = 0; if (path[0] == 0) { //-- Start case for browser root pseudo folder with device links -- - if (USB_mass_scanned) //if mass drives were scanned in earlier browsing - scan_USB_mass(); //then allow another scan here (timer dependent) + if (USB_mass_scanned) // if mass drives were scanned in earlier browsing + scan_USB_mass(); // then allow another scan here (timer dependent) strcpy(files[nfiles].name, "mc0:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; @@ -3486,15 +3484,13 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) strcpy(files[nfiles].name, "hdd0:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; #ifdef DVRP - if (console_is_PSX) - { - strcpy(files[nfiles].name, "dvr_hdd0:"); - files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; + if (console_is_PSX) { + strcpy(files[nfiles].name, "dvr_hdd0:"); + files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; } #endif #ifdef XFROM - if (console_is_PSX) - { + if (console_is_PSX) { strcpy(files[nfiles].name, "xfrom0:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; } @@ -3502,7 +3498,7 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) strcpy(files[nfiles].name, "cdfs:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; if ((cnfmode != USBD_IRX_CNF) && (cnfmode != USBKBD_IRX_CNF) && (cnfmode != USBMASS_IRX_CNF)) { - //The condition above blocks selecting USB drivers from USB devices + // The condition above blocks selecting USB drivers from USB devices if (USB_mass_ix[0] || !USB_mass_scanned) { strcpy(files[nfiles].name, "mass:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; @@ -3516,8 +3512,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) } } if (!cnfmode || (cnfmode == JPG_CNF)) { - //This condition blocks selecting any CONFIG items on PC - //or in a virtual memory card + // This condition blocks selecting any CONFIG items on PC + // or in a virtual memory card #ifdef ETH strcpy(files[nfiles].name, "host:"); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; @@ -3532,8 +3528,8 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) } } if (cnfmode < 2) { - //This condition blocks use of MISC pseudo-device for drivers and skins - //And allows this device only for launch keys and for normal browsing + // This condition blocks use of MISC pseudo-device for drivers and skins + // And allows this device only for launch keys and for normal browsing strcpy(files[nfiles].name, LNG(MISC)); files[nfiles].stats.AttrFile = sceMcFileAttrSubdir; nfiles++; @@ -3547,7 +3543,7 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) nfiles = 0; strcpy(files[nfiles].name, ".."); files[nfiles++].stats.AttrFile = sceMcFileAttrSubdir; - if (cnfmode) { //Stop recursive FileBrowser entry, only allow it for launch keys + if (cnfmode) { // Stop recursive FileBrowser entry, only allow it for launch keys strcpy(files[nfiles].name, LNG(FileBrowser)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; } @@ -3555,10 +3551,10 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(PS2Disc)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; - #ifdef ETH +#ifdef ETH strcpy(files[nfiles].name, LNG(PS2Net)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; - #endif +#endif strcpy(files[nfiles].name, LNG(PS2PowerOff)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(HddManager)); @@ -3577,7 +3573,7 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(Load_CNF)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; - //Next 2 lines add an optional font test routine + // Next 2 lines add an optional font test routine strcpy(files[nfiles].name, LNG(ShowFont)); files[nfiles++].stats.AttrFile = sceMcFileAttrFile; strcpy(files[nfiles].name, LNG(Debug_Info)); @@ -3623,7 +3619,7 @@ int setFileList(const char *path, const char *ext, FILEINFO *files, int cnfmode) return nfiles; } //------------------------------ -//endfunc setFileList +// endfunc setFileList //-------------------------------------------------------------- int BrowserModePopup(void) { @@ -3650,10 +3646,10 @@ int BrowserModePopup(void) menu_len = i; if (menu_len < (i = strlen(LNG(Back_to_Browser)))) menu_len = i; - menu_len += 3; //All of the above strings are indented 3 spaces, for tooltips + menu_len += 3; // All of the above strings are indented 3 spaces, for tooltips - int menu_ch_w = menu_len + 1; //Total characters in longest menu string - int menu_ch_h = 14; //Total number of menu lines + int menu_ch_w = menu_len + 1; // Total characters in longest menu string + int menu_ch_h = 14; // Total number of menu lines int mSprite_w = (menu_ch_w + 3) * FONT_WIDTH; int mSprite_h = (menu_ch_h + 1) * FONT_HEIGHT; int mSprite_X1 = SCREEN_WIDTH / 2 - mSprite_w / 2; @@ -3667,42 +3663,42 @@ int BrowserModePopup(void) minuses_s[i] = '-'; minuses_s[80] = '\0'; - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { switch (new_pad) { case PAD_RIGHT: file_sort = 0; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_DOWN: file_sort = 1; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_LEFT: file_sort = 2; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_UP: file_sort = 3; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_CIRCLE: file_show = 0; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_CROSS: file_show = 1; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; case PAD_SQUARE: file_show = 2; - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((file_show == 2) && (elisaFnt == NULL) && (elisa_failed == FALSE)) { int fd, res; - elisa_failed = TRUE; //Default to FAILED. If it succeeds, then this status will be cleared. + elisa_failed = TRUE; // Default to FAILED. If it succeeds, then this status will be cleared. res = genFixPath("uLE:/ELISA100.FNT", tmp); if (!strncmp(tmp, "cdrom", 5)) @@ -3725,12 +3721,12 @@ int BrowserModePopup(void) break; case PAD_TRIANGLE: return (file_show != entry_file_show) || (file_sort != entry_file_sort); - } //ends switch(new_pad) - } //ends if(readpad()) + } // ends switch(new_pad) + } // ends if(readpad()) - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2); @@ -3781,27 +3777,27 @@ int BrowserModePopup(void) tmp[0] = 0; printXY(tmp, mSprite_X1 + 2 * FONT_WIDTH, y, setting->color[COLOR_TEXT], TRUE, 0); - //Display marker for current modes + // Display marker for current modes if ((file_show == i - 2) || (file_sort == i - 8)) drawChar(LEFT_CUR, mSprite_X1 + FONT_WIDTH / 2, y, setting->color[COLOR_SELECT]); y += FONT_HEIGHT; - } //ends for loop handling one text row per loop + } // ends for loop handling one text row per loop - //Tooltip section - // x = SCREEN_MARGIN; + // Tooltip section + // x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], 0, y - 1, SCREEN_WIDTH, y + FONT_HEIGHT); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while } //------------------------------ -//endfunc BrowserModePopup +// endfunc BrowserModePopup //-------------------------------------------------------------- // get_FilePath is the main browser function. // It also contains the menu handler for the R1 submenu @@ -3836,12 +3832,12 @@ int getFilePath(char *out, int cnfmode) FILEINFO files[MAX_ENTRY]; int top = 0, rows; int x, y, y0, y1; - int i, j, ret, rv = -1; //NB: rv is for return value of this function + int i, j, ret, rv = -1; // NB: rv is for return value of this function int event, post_event = 0; int font_height; int iconbase, iconcolr; - elisa_failed = FALSE; //set at failure to load font, cleared at each browser entry + elisa_failed = FALSE; // set at failure to load font, cleared at each browser entry browser_cd = TRUE; browser_up = FALSE; @@ -3853,11 +3849,11 @@ int getFilePath(char *out, int cnfmode) strcpy(ext, cnfmode_extL[cnfmode]); if ((cnfmode == USBD_IRX_CNF) || (cnfmode == USBKBD_IRX_CNF) || (cnfmode == USBMASS_IRX_CNF) || ((!strncmp(LastDir, setting->Misc, strlen(setting->Misc))) && (cnfmode > LK_ELF_CNF))) - path[0] = '\0'; //start in main root if recent folder unreasonable + path[0] = '\0'; // start in main root if recent folder unreasonable else - strcpy(path, LastDir); //If reasonable, start in recent folder + strcpy(path, LastDir); // If reasonable, start in recent folder - unmountAll(); //unmount all uLE-used mountpoints + unmountAll(); // unmount all uLE-used mountpoints clipPath[0] = 0; nclipFiles = 0; @@ -3871,15 +3867,15 @@ int getFilePath(char *out, int cnfmode) font_height = FONT_HEIGHT + 2; rows = (Menu_end_y - Menu_start_y) / font_height; - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad) { browser_pushed = TRUE; - event |= 2; //event |= pad command + event |= 2; // event |= pad command } if (new_pad & PAD_UP) browser_sel--; @@ -3891,9 +3887,9 @@ int getFilePath(char *out, int cnfmode) browser_sel += rows / 2; else if (new_pad & PAD_TRIANGLE) browser_up = TRUE; - else if ((swapKeys && (new_pad & PAD_CROSS)) || (!swapKeys && (new_pad & PAD_CIRCLE))) { //Pushed OK + else if ((swapKeys && (new_pad & PAD_CROSS)) || (!swapKeys && (new_pad & PAD_CIRCLE))) { // Pushed OK if (files[browser_sel].stats.AttrFile & sceMcFileAttrSubdir) { - //pushed OK for a folder + // pushed OK for a folder if (!strcmp(files[browser_sel].name, "..")) browser_up = TRUE; else { @@ -3902,7 +3898,7 @@ int getFilePath(char *out, int cnfmode) browser_cd = TRUE; } } else { - //pushed OK for a file + // pushed OK for a file sprintf(out, "%s%s", path, files[browser_sel].name); // Must to include a function for check IRX Header if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (!IsSupportedFileType(out))) { @@ -3911,23 +3907,23 @@ int getFilePath(char *out, int cnfmode) out[0] = 0; } else { strcpy(LastDir, path); - rv = 1; //flag pathname selected + rv = 1; // flag pathname selected break; } } - } else if (new_pad & PAD_R3) { //New clause for uLE-relative paths + } else if (new_pad & PAD_R3) { // New clause for uLE-relative paths if (files[browser_sel].stats.AttrFile & sceMcFileAttrSubdir) { - //pushed R3 for a folder (navigate to uLE CNF folder) + // pushed R3 for a folder (navigate to uLE CNF folder) strcpy(path, LaunchElfDir); - if ((p = strchr(path, ':'))) { //device separator ? - if (p[1] != '/') { //missing path separator ? (mass: & host:) - p[1] = '/'; //insert path separator - strcpy(p + 2, LaunchElfDir + (p - path) + 1); //append rest of pathname + if ((p = strchr(path, ':'))) { // device separator ? + if (p[1] != '/') { // missing path separator ? (mass: & host:) + p[1] = '/'; // insert path separator + strcpy(p + 2, LaunchElfDir + (p - path) + 1); // append rest of pathname } } browser_cd = TRUE; } else { - //pushed R3 for a file (treat as uLE-related) + // pushed R3 for a file (treat as uLE-related) sprintf(out, "%s%s", path, files[browser_sel].name); // Must to include a function for check IRX Header if (((cnfmode == LK_ELF_CNF) || (cnfmode == NON_CNF)) && (checkELFheader(out) < 0)) { @@ -3937,7 +3933,7 @@ int getFilePath(char *out, int cnfmode) } else { strcpy(LastDir, path); sprintf(out, "%s%s", "uLE:/", files[browser_sel].name); - rv = 1; //flag pathname selected + rv = 1; // flag pathname selected break; } } @@ -3952,42 +3948,42 @@ int getFilePath(char *out, int cnfmode) } else if (new_pad & PAD_L1) { browser_cd = BrowserModePopup(); } - //pad checks above are for commands common to all browser modes - //pad checks below are for commands that differ depending on cnfmode + // pad checks above are for commands common to all browser modes + // pad checks below are for commands that differ depending on cnfmode if (cnfmode == DIR_CNF) { if (new_pad & PAD_START) { strcpy(out, path); strcpy(LastDir, path); - rv = 0; //flag pathname selected + rv = 0; // flag pathname selected break; } - } else if (cnfmode == SAVE_CNF) { //Generic Save commands + } else if (cnfmode == SAVE_CNF) { // Generic Save commands if (new_pad & PAD_START) { if (files[browser_sel].stats.AttrFile & sceMcFileAttrSubdir) { - //no file was highlighted, so prep to save with empty filename + // no file was highlighted, so prep to save with empty filename strcpy(out, path); - rv = 0; //flag pure path selected + rv = 0; // flag pure path selected } else { - //a file was highlighted, so prep to save with that filename + // a file was highlighted, so prep to save with that filename sprintf(out, "%s%s", path, files[browser_sel].name); - rv = 1; //flag pathname selected + rv = 1; // flag pathname selected } strcpy(LastDir, path); break; } } - if (cnfmode) { //A file is to be selected, not in normal browser mode + if (cnfmode) { // A file is to be selected, not in normal browser mode if (new_pad & PAD_SQUARE) { if (!strcmp(ext, "*")) strcpy(ext, cnfmode_extL[cnfmode]); else strcpy(ext, "*"); browser_cd = TRUE; - } else if ((!swapKeys && (new_pad & PAD_CROSS)) || (swapKeys && (new_pad & PAD_CIRCLE))) { //Cancel command ? + } else if ((!swapKeys && (new_pad & PAD_CROSS)) || (swapKeys && (new_pad & PAD_CIRCLE))) { // Cancel command ? unmountAll(); return rv; } - } else { //cnfmode == FALSE + } else { // cnfmode == FALSE if (new_pad & PAD_R1) { ret = menu(path, &files[browser_sel]); if (ret == COPY || ret == CUT) { @@ -4006,9 +4002,9 @@ int getFilePath(char *out, int cnfmode) browser_cut = TRUE; else browser_cut = FALSE; - } //ends COPY and CUT + } // ends COPY and CUT else if (ret == DELETE) { - if (nmarks == 0) { //dlanor: using title was inappropriate here (filesystem op) + if (nmarks == 0) { // dlanor: using title was inappropriate here (filesystem op) sprintf(tmp, "%s", files[browser_sel].name); if (files[browser_sel].stats.AttrFile & sceMcFileAttrSubdir) strcat(tmp, "/"); @@ -4031,8 +4027,8 @@ int getFilePath(char *out, int cnfmode) } else { for (i = 0; i < browser_nfiles; i++) { if (marks[i]) { - if (!first_deleted) //if this is the first mark - first_deleted = i; //then memorize it for cursor positioning + if (!first_deleted) // if this is the first mark + first_deleted = i; // then memorize it for cursor positioning strcpy(tmp, files[i].name); if (files[i].stats.AttrFile & sceMcFileAttrSubdir) strcat(tmp, "/"); @@ -4058,7 +4054,7 @@ int getFilePath(char *out, int cnfmode) browser_cd = TRUE; browser_repos = TRUE; } - } //ends DELETE + } // ends DELETE else if (ret == RENAME) { strcpy(tmp, files[browser_sel].name); if (keyboard(tmp, 36) > 0) { @@ -4068,7 +4064,7 @@ int getFilePath(char *out, int cnfmode) } else browser_cd = TRUE; } - } //ends RENAME + } // ends RENAME else if (ret == PASTE) submenu_func_Paste(msg0, path); else if (ret == MCPASTE) @@ -4085,7 +4081,7 @@ int getFilePath(char *out, int cnfmode) } else if (ret < 0) { strcpy(msg0, LNG(NewDir_Failed)); browser_pushed = FALSE; - } else { //dlanor: modified for similarity to PC browsers + } else { // dlanor: modified for similarity to PC browsers sprintf(msg0, "%s: ", LNG(Created_folder)); strcat(msg0, tmp); browser_pushed = FALSE; @@ -4094,14 +4090,14 @@ int getFilePath(char *out, int cnfmode) browser_cd = TRUE; } } - } //ends NEWDIR + } // ends NEWDIR else if (ret == NEWICON) { strcpy(tmp, LNG(Icon_Title)); if (keyboard(tmp, 36) <= 0) goto DoneIcon; genFixPath(path, tmp1); strcat(tmp1, "icon.sys"); - if ((ret = genOpen(tmp1, O_RDONLY)) >= 0) { //if old "icon.sys" file exists + if ((ret = genOpen(tmp1, O_RDONLY)) >= 0) { // if old "icon.sys" file exists genClose(ret); sprintf(msg1, "\n\"icon.sys\" %s.\n\n%s ?", LNG(file_alredy_exists), @@ -4116,7 +4112,7 @@ int getFilePath(char *out, int cnfmode) keyboard(tmp, 36); genFixPath(path, tmp1); strcat(tmp1, "icon.icn"); - if ((ret = genOpen(tmp1, O_RDONLY)) >= 0) { //if old "icon.icn" file exists + if ((ret = genOpen(tmp1, O_RDONLY)) >= 0) { // if old "icon.icn" file exists genClose(ret); sprintf(msg1, "\n\"icon.icn\" %s.\n\n%s ?", LNG(file_alredy_exists), @@ -4127,8 +4123,8 @@ int getFilePath(char *out, int cnfmode) } make_icon(tmp, tmp1); DoneIcon: - strcpy(tmp, tmp1); //Dummy code to make 'goto DoneIcon' legal for gcc - } //ends NEWICON + strcpy(tmp, tmp1); // Dummy code to make 'goto DoneIcon' legal for gcc + } // ends NEWICON else if ((ret == MOUNTVMC0) || (ret == MOUNTVMC1)) { i = ret - MOUNTVMC0; load_vmc_fs(); @@ -4165,35 +4161,34 @@ int getFilePath(char *out, int cnfmode) LNG(Mount), i, tmp2, x); (void)ynDialog(msg1); } - } //ends MOUNTVMCx + } // ends MOUNTVMCx else if (ret == GETSIZE) { submenu_func_GetSize(msg0, path, files); - } //ends GETSIZE -//#ifdef TMANIP + } // ends GETSIZE + //#ifdef TMANIP else if (ret == TIMEMANIP) { #ifdef TMANIP_MORON sprintf(msg1, "\n\n %s [%s] ?\n", LNG(change_timestamp_of), HACK_FOLDER); #else sprintf(msg1, "\n\n %s [%s] ?\n", LNG(change_timestamp_of), files[browser_sel].name); -#endif //TMANIP_MORON +#endif // TMANIP_MORON if (ynDialog(msg1) > 0) { time_manip(path, &files[browser_sel], &msg0); browser_pushed = FALSE; browser_repos = TRUE; // TEST - browser_cd = TRUE; //TEST + browser_cd = TRUE; // TEST } } -//#endif //TMANIP - - else if (ret == TITLE_CFG) - { + //#endif //TMANIP + + else if (ret == TITLE_CFG) { make_title_cfg(path, &files[browser_sel], &msg0); browser_pushed = FALSE; browser_repos = TRUE; // TEST - browser_cd = TRUE; //TEST + browser_cd = TRUE; // TEST } - //R1 menu handling is completed above + // R1 menu handling is completed above } else if ((!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { if (browser_sel != 0 && path[0] != 0 && (strcmp(path, "hdd0:/") && strcmp(path, "dvr_hdd0:/"))) { if (marks[browser_sel]) { @@ -4217,14 +4212,14 @@ int getFilePath(char *out, int cnfmode) } } } - } else if (new_pad & PAD_SELECT) { //Leaving the browser ? + } else if (new_pad & PAD_SELECT) { // Leaving the browser ? unmountAll(); return rv; } } - } //ends pad response section + } // ends pad response section - //browser path adjustment section + // browser path adjustment section if (browser_up) { if ((p = strrchr(path, '/')) != NULL) *p = 0; @@ -4238,11 +4233,11 @@ int getFilePath(char *out, int cnfmode) } browser_cd = TRUE; browser_repos = TRUE; - } //ends 'if(browser_up)' + } // ends 'if(browser_up)' //----- Process newly entered directory here (incl initial entry) if (browser_cd) { browser_nfiles = setFileList(path, ext, files, cnfmode); - if (!cnfmode) { //Calculate free space (unless configuring) + if (!cnfmode) { // Calculate free space (unless configuring) if (!strncmp(path, "mc", 2)) { mcGetInfo(path[2] - '0', 0, &mctype_PSx, &mcfreeSpace, NULL); mcSync(0, NULL, &ret); @@ -4272,7 +4267,7 @@ int getFilePath(char *out, int cnfmode) pfs_str[7] += latestMount; ZoneFree = fileXioDevctl(pfs_str, PFSCTL_GET_ZONE_FREE, NULL, 0, NULL, 0); ZoneSize = fileXioDevctl(pfs_str, PFSCTL_GET_ZONE_SIZE, NULL, 0, NULL, 0); - //printf("ZoneFree==%d ZoneSize==%d\r\n", ZoneFree, ZoneSize); + // printf("ZoneFree==%d ZoneSize==%d\r\n", ZoneFree, ZoneSize); freeSpace = ZoneFree * ZoneSize; vfreeSpace = TRUE; #endif @@ -4289,12 +4284,12 @@ int getFilePath(char *out, int cnfmode) break; } } - } //ends if(browser_repos) + } // ends if(browser_repos) nmarks = 0; memset(marks, 0, MAX_ENTRY); browser_cd = FALSE; browser_up = FALSE; - } //ends if(browser_cd) + } // ends if(browser_cd) if (!strncmp(path, "cdfs", 4)) uLE_cdStop(); if (top > browser_nfiles - rows) @@ -4310,9 +4305,9 @@ int getFilePath(char *out, int cnfmode) if (browser_sel < top) top = browser_sel; - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); x = Menu_start_x; @@ -4324,15 +4319,15 @@ int getFilePath(char *out, int cnfmode) } rows = (Menu_end_y - Menu_start_y) / font_height; - for (i = 0; i < rows; i++) //Repeat loop for each browser text row + for (i = 0; i < rows; i++) // Repeat loop for each browser text row { - mcTitle = NULL; //Assume that normal file/folder names are to be displayed - int name_limit = 0; //Assume that no name length problems exist + mcTitle = NULL; // Assume that normal file/folder names are to be displayed + int name_limit = 0; // Assume that no name length problems exist if (top + i >= browser_nfiles) break; if (top + i == browser_sel) - color = setting->color[COLOR_SELECT]; //Highlight cursor line + color = setting->color[COLOR_SELECT]; // Highlight cursor line else color = setting->color[COLOR_TEXT]; @@ -4341,35 +4336,35 @@ int getFilePath(char *out, int cnfmode) else if ((file_show == 2) && files[top + i].title[0] != 0) { mcTitle = files[top + i].title; - } else { //Show normal file/folder names + } else { // Show normal file/folder names #ifdef MX4SIO - if (path[0] == 0) { // we are on root. apply the unique "alias" here - if ((!strncmp(files[top + i].name, "mass", 4)) // - && (files[top + i].name[4] == ('0' + mx4sio_idx) || (mx4sio_idx == 0 && files[top + i].name[4] == ':')) //index corresponds to mx4sio index, also assume that if device path index 4 is equal to ':' then it is index 0 + if (path[0] == 0) { // we are on root. apply the unique "alias" here + if ((!strncmp(files[top + i].name, "mass", 4)) // + && (files[top + i].name[4] == ('0' + mx4sio_idx) || (mx4sio_idx == 0 && files[top + i].name[4] == ':')) // index corresponds to mx4sio index, also assume that if device path index 4 is equal to ':' then it is index 0 ) strcpy(tmp, "mx4sio:"); - else + else strcpy(tmp, files[top + i].name); - } else { - strcpy(tmp, files[top + i].name); - } + } else { + strcpy(tmp, files[top + i].name); + } #else - strcpy(tmp, files[top + i].name); + strcpy(tmp, files[top + i].name); #endif - if (file_show > 0) { //Does display mode include file details ? + if (file_show > 0) { // Does display mode include file details ? name_limit = 43 * 8; - } else { //Filenames are shown without file details + } else { // Filenames are shown without file details name_limit = 71 * 8; } } - if (name_limit) { //Do we need to check name length ? - int name_end = name_limit / 7; //Max string length for acceptable spacing + if (name_limit) { // Do we need to check name length ? + int name_end = name_limit / 7; // Max string length for acceptable spacing if (files[top + i].stats.AttrFile & sceMcFileAttrSubdir) - name_end -= 1; //For folders, reserve one character for final '/' - if (strlen(tmp) > name_end) { //Is name too long for clean display ? - tmp[name_end - 1] = '~'; //indicate filename abbreviation - tmp[name_end] = 0; //abbreviate name length to make room for details + name_end -= 1; // For folders, reserve one character for final '/' + if (strlen(tmp) > name_end) { // Is name too long for clean display ? + tmp[name_end - 1] = '~'; // indicate filename abbreviation + tmp[name_end] = 0; // abbreviate name length to make room for details } } @@ -4382,7 +4377,7 @@ int getFilePath(char *out, int cnfmode) if (file_show > 0) { // unsigned int size = files[top+i].stats.fileSizeByte; unsigned long long size = ((unsigned long long)files[top + i].stats.Reserve2 << 32) | files[top + i].stats.FileSizeByte; - int scale = 0; //0==Bytes, 1==KBytes, 2==MBytes, 3==GB + int scale = 0; // 0==Bytes, 1==KBytes, 2==MBytes, 3==GB char scale_s[6] = " KMGTP"; PS2TIME timestamp = *(PS2TIME *)&files[top + i].stats._Modify; @@ -4399,7 +4394,7 @@ int getFilePath(char *out, int cnfmode) size /= 1024; } // sprintf(tmp, "%5u%cB", size, scale_s[scale]); - //size shouldn't be over 99999, and seems sprintf doesn't support unsigned long long (%llu crashes) + // size shouldn't be over 99999, and seems sprintf doesn't support unsigned long long (%llu crashes) sprintf(tmp, "%5u%cB", (unsigned)size, scale_s[scale]); } @@ -4417,10 +4412,10 @@ int getFilePath(char *out, int cnfmode) printXY(tmp, x + 4 + 44 * FONT_WIDTH, y, color, TRUE, 0); } - if (setting->FB_NoIcons) { //if FileBrowser should not use icons + if (setting->FB_NoIcons) { // if FileBrowser should not use icons if (marks[top + i]) drawChar('*', x - 6, y, setting->color[COLOR_TEXT]); - } else { //if Icons must be used in front of file/folder names + } else { // if Icons must be used in front of file/folder names if (files[top + i].stats.AttrFile & sceMcFileAttrSubdir) { iconbase = ICON_FOLDER; iconcolr = COLOR_GRAPH1; @@ -4429,14 +4424,13 @@ int getFilePath(char *out, int cnfmode) if (genCmpFileExt(files[top + i].name, "ELF")) iconcolr = COLOR_GRAPH2; else if ( - genCmpFileExt(files[top + i].name, "TXT") || - genCmpFileExt(files[top + i].name, "CFG") || - genCmpFileExt(files[top + i].name, "CNF") || - genCmpFileExt(files[top + i].name, "INI") || - genCmpFileExt(files[top + i].name, "CHT") || - genCmpFileExt(files[top + i].name, "JPG") || - genCmpFileExt(files[top + i].name, "JPEG") - ) + genCmpFileExt(files[top + i].name, "TXT") || + genCmpFileExt(files[top + i].name, "CFG") || + genCmpFileExt(files[top + i].name, "CNF") || + genCmpFileExt(files[top + i].name, "INI") || + genCmpFileExt(files[top + i].name, "CHT") || + genCmpFileExt(files[top + i].name, "JPG") || + genCmpFileExt(files[top + i].name, "JPEG")) iconcolr = COLOR_GRAPH4; else iconcolr = COLOR_GRAPH3; @@ -4447,8 +4441,8 @@ int getFilePath(char *out, int cnfmode) drawChar(iconbase + 1, x - 3, y, setting->color[iconcolr]); } y += font_height; - } //ends for, so all browser rows were fixed above - if (browser_nfiles > rows) { //if more files than available rows, use scrollbar + } // ends for, so all browser rows were fixed above + if (browser_nfiles > rows) { // if more files than available rows, use scrollbar drawFrame(SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 8, Frame_start_y, SCREEN_WIDTH - SCREEN_MARGIN, Frame_end_y, setting->color[COLOR_FRAME]); y0 = (Menu_end_y - Menu_start_y + 8) * ((double)top / browser_nfiles); @@ -4456,25 +4450,25 @@ int getFilePath(char *out, int cnfmode) drawOpSprite(setting->color[COLOR_FRAME], SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 6, (y0 + Menu_start_y - 4), SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 2, (y1 + Menu_start_y - 4)); - } //ends clause for scrollbar - if (nclipFiles) { //if Something in clipboard, emulate LED indicator + } // ends clause for scrollbar + if (nclipFiles) { // if Something in clipboard, emulate LED indicator u64 LED_colour, RIM_colour = GS_SETREG_RGBA(0, 0, 0, 0); int RIM_w = 4, LED_w = 6, indicator_w = LED_w + 2 * RIM_w; int x2 = SCREEN_WIDTH - SCREEN_MARGIN - 2, x1 = x2 - indicator_w; int y1 = Frame_start_y + 2, y2 = y1 + indicator_w; if (browser_cut) - LED_colour = GS_SETREG_RGBA(0xC0, 0, 0, 0); //Red LED == CUT + LED_colour = GS_SETREG_RGBA(0xC0, 0, 0, 0); // Red LED == CUT else - LED_colour = GS_SETREG_RGBA(0, 0xC0, 0, 0); //Green LED == COPY + LED_colour = GS_SETREG_RGBA(0, 0xC0, 0, 0); // Green LED == COPY drawOpSprite(RIM_colour, x1, y1, x2, y2); drawOpSprite(LED_colour, x1 + RIM_w, y1 + RIM_w, x2 - RIM_w, y2 - RIM_w); - } //ends clause for clipboard indicator + } // ends clause for clipboard indicator if (browser_pushed) sprintf(msg0, "%s: %s", LNG(Path), path); - //Tooltip section - if (cnfmode) { //cnfmode indicates configurable file selection + // Tooltip section + if (cnfmode) { // cnfmode indicates configurable file selection if (swapKeys) sprintf(msg1, "\xFF" "1:%s \xFF" @@ -4496,7 +4490,7 @@ int getFilePath(char *out, int cnfmode) strcat(msg1, "->*"); sprintf(tmp, " R2:%s", LNG(PathPad)); strcat(msg1, tmp); - if ((cnfmode == DIR_CNF) || (cnfmode == SAVE_CNF)) { //modes using Start + if ((cnfmode == DIR_CNF) || (cnfmode == SAVE_CNF)) { // modes using Start sprintf(tmp, " Start:%s", LNG(Choose)); strcat(msg1, tmp); } @@ -4535,18 +4529,18 @@ int getFilePath(char *out, int cnfmode) (Menu_message_y), setting->color[COLOR_SELECT], TRUE, 0); } - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while - //Leaving the browser + // Leaving the browser unmountAll(); return rv; } //------------------------------ -//endfunc getFilePath +// endfunc getFilePath //-------------------------------------------------------------- void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) { @@ -4563,12 +4557,12 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) drawMsg(LNG(Checking_Size)); if (nmarks == 0) { size = getFileSize(path, &files[browser_sel]); - sel = browser_sel; //for stat checking + sel = browser_sel; // for stat checking } else { for (i = size = 0; i < browser_nfiles; i++) { if (marks[i]) { size += getFileSize(path, &files[i]); - sel = i; //for stat checking + sel = i; // for stat checking } if (size < 0) size = -1; @@ -4597,7 +4591,7 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) printf("path =\"%s\"\r\n", path); printf("file =\"%s\"\r\n", files[sel].name); if (!strncmp(filepath, "host:/", 6)) - makeHostPath(filepath+5, filepath+6); + makeHostPath(filepath+5, filepath+6); test = fileXioGetStat(filepath, &stats); printf("test = %d\r\n", test); printf("mode = %08X\r\n", stats.mode); @@ -4605,16 +4599,16 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) printf("size = %08X\r\n", stats.size); time = (PS2TIME *) stats.ctime; printf("ctime = %04d.%02d.%02d %02d:%02d:%02d.%02d\r\n", - time->year,time->month,time->day, - time->hour,time->min,time->sec,time->unknown); + time->year,time->month,time->day, + time->hour,time->min,time->sec,time->unknown); time = (PS2TIME *) stats.atime; printf("atime = %04d.%02d.%02d %02d:%02d:%02d.%02d\r\n", - time->year,time->month,time->day, - time->hour,time->min,time->sec,time->unknown); + time->year,time->month,time->day, + time->hour,time->min,time->sec,time->unknown); time = (PS2TIME *) stats.mtime; printf("mtime = %04d.%02d.%02d %02d:%02d:%02d.%02d\r\n", - time->year,time->month,time->day, - time->hour,time->min,time->sec,time->unknown); + time->year,time->month,time->day, + time->hour,time->min,time->sec,time->unknown); */ //----- End of section for debug display of attributes ----- sprintf(mess + text_pos, " m=%04X %04d.%02d.%02d %02d:%02d:%02d%n", @@ -4633,9 +4627,9 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) sprintf(mess + text_pos, " %s=%d%n", LNG(mctype), mctype_PSx, &text_inc); text_pos += text_inc; } - //sprintf(mess+text_pos, " mcTsz=%d%n", files[sel].stats.fileSizeByte, &text_inc); + // sprintf(mess+text_pos, " mcTsz=%d%n", files[sel].stats.fileSizeByte, &text_inc); unsigned long long size = ((unsigned long long)files[sel].stats.Reserve2 << 32) | files[sel].stats.FileSizeByte; - //Max length is 20 characters+NULL + // Max length is 20 characters+NULL char sizeC[21] = {0}; char *sizeP = &sizeC[21]; do { @@ -4648,7 +4642,7 @@ void submenu_func_GetSize(char *mess, char *path, FILEINFO *files) browser_pushed = FALSE; } //------------------------------ -//endfunc submenu_func_GetSize +// endfunc submenu_func_GetSize //-------------------------------------------------------------- void subfunc_Paste(char *mess, char *path) { @@ -4656,7 +4650,7 @@ void subfunc_Paste(char *mess, char *path) int i, ret = -1; written_size = 0; - PasteTime = Timer(); //Note initial pasting time + PasteTime = Timer(); // Note initial pasting time drawMsg(LNG(Pasting)); if (!strcmp(path, clipPath)) goto finished; @@ -4668,8 +4662,8 @@ void subfunc_Paste(char *mess, char *path) sprintf(tmp1, " %s", LNG(pasting)); strcat(tmp, tmp1); drawMsg(tmp); - PM_flag[0] = PM_NORMAL; //Always use normal mode at top level - PM_file[0] = -1; //Thus no attribute file is used here + PM_flag[0] = PM_NORMAL; // Always use normal mode at top level + PM_file[0] = -1; // Thus no attribute file is used here ret = copy(path, clipPath, clipFiles[i], 0); if (ret < 0) break; @@ -4680,7 +4674,7 @@ void subfunc_Paste(char *mess, char *path) } } -// unmountAll(); //disabled to avoid interference with VMC implementation + // unmountAll(); //disabled to avoid interference with VMC implementation finished: if (ret < 0) { @@ -4691,7 +4685,7 @@ void subfunc_Paste(char *mess, char *path) browser_cd = TRUE; } //------------------------------ -//endfunc subfunc_Paste +// endfunc subfunc_Paste //-------------------------------------------------------------- void submenu_func_Paste(char *mess, char *path) { @@ -4702,7 +4696,7 @@ void submenu_func_Paste(char *mess, char *path) subfunc_Paste(mess, path); } //------------------------------ -//endfunc submenu_func_Paste +// endfunc submenu_func_Paste //-------------------------------------------------------------- void submenu_func_mcPaste(char *mess, char *path) { @@ -4714,7 +4708,7 @@ void submenu_func_mcPaste(char *mess, char *path) subfunc_Paste(mess, path); } //------------------------------ -//endfunc submenu_func_mcPaste +// endfunc submenu_func_mcPaste //-------------------------------------------------------------- void submenu_func_psuPaste(char *mess, char *path) { @@ -4726,7 +4720,7 @@ void submenu_func_psuPaste(char *mess, char *path) subfunc_Paste(mess, path); } //------------------------------ -//endfunc submenu_func_psuPaste +// endfunc submenu_func_psuPaste //-------------------------------------------------------------- -//End of file: filer.c +// End of file: filer.c //-------------------------------------------------------------- diff --git a/src/font_uLE.c b/src/font_uLE.c index 1d80d565..7dad3460 100644 --- a/src/font_uLE.c +++ b/src/font_uLE.c @@ -1,652 +1,652 @@ //--------------------------------------------------------------------------- -//File name: font_uLE.c //Holds FontBuffer and font_uLE (default font) +// File name: font_uLE.c //Holds FontBuffer and font_uLE (default font) //--------------------------------------------------------------------------- -unsigned char FontBuffer[256 * 16]; //This holds either default or external font +unsigned char FontBuffer[256 * 16]; // This holds either default or external font unsigned char font_uLE[] = { - //Font position 0x000 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x000 == '_' (free for use) + // Font position 0x000 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x000 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x001 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x001 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x002 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x002 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x003 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x003 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x004 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x004 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x005 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x005 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x006 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x006 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x007 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x007 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x008 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x008 == '_' (free for use) + // Font position 0x008 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x008 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x009 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x009 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00A == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00A == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00B == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00B == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00C == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00C == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00D == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00D == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00E == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00E == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x00F == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x00F == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x010 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x010 == '_' (free for use) + // Font position 0x010 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x010 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x011 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x011 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x012 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x012 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x013 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x013 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x014 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x014 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x015 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x015 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x016 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x016 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x017 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x017 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x018 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x018 == '_' (free for use) + // Font position 0x018 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x018 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x019 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x019 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01A == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01A == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01B == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01B == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01C == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01C == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01D == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01D == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01E == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01E == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x01F == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x01F == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x020 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x020 == ' ' + // Font position 0x020 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x020 == ' ' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //char 0x021 == '!' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // char 0x021 == '!' 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, //char 0x022 == '"' + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, // char 0x022 == '"' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0xFF, 0xFF, 0x66, 0x66, //char 0x023 == '#' + 0x00, 0x00, 0x66, 0x66, 0xFF, 0xFF, 0x66, 0x66, // char 0x023 == '#' 0x66, 0x66, 0xFF, 0xFF, 0x66, 0x66, 0x00, 0x00, - 0x18, 0x18, 0x3E, 0x3E, 0x60, 0x60, 0x3C, 0x3C, //char 0x024 == '$' + 0x18, 0x18, 0x3E, 0x3E, 0x60, 0x60, 0x3C, 0x3C, // char 0x024 == '$' 0x06, 0x06, 0x7C, 0x7C, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x6C, 0x6C, 0x18, 0x18, //char 0x025 == '%' + 0x00, 0x00, 0x66, 0x66, 0x6C, 0x6C, 0x18, 0x18, // char 0x025 == '%' 0x30, 0x30, 0x66, 0x66, 0x46, 0x46, 0x00, 0x00, - 0x1C, 0x1C, 0x36, 0x36, 0x1C, 0x1C, 0x38, 0x38, //char 0x026 == '&' + 0x1C, 0x1C, 0x36, 0x36, 0x1C, 0x1C, 0x38, 0x38, // char 0x026 == '&' 0x6F, 0x6F, 0x66, 0x66, 0x3B, 0x3B, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //char 0x027 == ''' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // char 0x027 == ''' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //Font position 0x028 - 0x00, 0x00, 0x0E, 0x0E, 0x1C, 0x1C, 0x18, 0x18, //char 0x028 == '(' + // Font position 0x028 + 0x00, 0x00, 0x0E, 0x0E, 0x1C, 0x1C, 0x18, 0x18, // char 0x028 == '(' 0x18, 0x18, 0x1C, 0x1C, 0x0E, 0x0E, 0x00, 0x00, - 0x00, 0x00, 0x70, 0x70, 0x38, 0x38, 0x18, 0x18, //char 0x029 == ')' + 0x00, 0x00, 0x70, 0x70, 0x38, 0x38, 0x18, 0x18, // char 0x029 == ')' 0x18, 0x18, 0x38, 0x38, 0x70, 0x70, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0xFF, 0xFF, //char 0x02A == '*' + 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0xFF, 0xFF, // char 0x02A == '*' 0x3C, 0x3C, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x7E, //char 0x02B == '+' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x7E, // char 0x02B == '+' 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x02C == ',' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x02C == ',' 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x30, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, //char 0x02D == '-' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, // char 0x02D == '-' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x02E == '.' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x02E == '.' 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, //char 0x02F == '/' + 0x00, 0x00, 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, // char 0x02F == '/' 0x30, 0x30, 0x60, 0x60, 0x40, 0x40, 0x00, 0x00, - //Font position 0x030 - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x6E, 0x6E, //char 0x030 == '0' + // Font position 0x030 + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x6E, 0x6E, // char 0x030 == '0' 0x76, 0x76, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x18, 0x18, //char 0x031 == '1' + 0x00, 0x00, 0x18, 0x18, 0x38, 0x38, 0x18, 0x18, // char 0x031 == '1' 0x18, 0x18, 0x18, 0x18, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x0C, 0x0C, //char 0x032 == '2' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x0C, 0x0C, // char 0x032 == '2' 0x18, 0x18, 0x30, 0x30, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, 0x18, 0x18, //char 0x033 == '3' + 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, 0x18, 0x18, // char 0x033 == '3' 0x0C, 0x0C, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x0C, 0x0C, 0x1C, 0x1C, 0x3C, 0x3C, //char 0x034 == '4' + 0x00, 0x00, 0x0C, 0x0C, 0x1C, 0x1C, 0x3C, 0x3C, // char 0x034 == '4' 0x6C, 0x6C, 0x7E, 0x7E, 0x0C, 0x0C, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x7C, 0x7C, //char 0x035 == '5' + 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x7C, 0x7C, // char 0x035 == '5' 0x06, 0x06, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x60, 0x60, 0x7C, 0x7C, //char 0x036 == '6' + 0x00, 0x00, 0x3C, 0x3C, 0x60, 0x60, 0x7C, 0x7C, // char 0x036 == '6' 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x06, 0x06, 0x0C, 0x0C, //char 0x037 == '7' + 0x00, 0x00, 0x7E, 0x7E, 0x06, 0x06, 0x0C, 0x0C, // char 0x037 == '7' 0x18, 0x18, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, - //Font position 0x038 - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x3C, 0x3C, //char 0x038 == '8' + // Font position 0x038 + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x3C, 0x3C, // char 0x038 == '8' 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x3E, 0x3E, //char 0x039 == '9' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x3E, 0x3E, // char 0x039 == '9' 0x06, 0x06, 0x0C, 0x0C, 0x38, 0x38, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, //char 0x03A == ':' + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, // char 0x03A == ':' 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, //char 0x03B == ';' + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, // char 0x03B == ';' 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x30, 0x30, - 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, 0x30, 0x30, //char 0x03C == '<' + 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, 0x30, 0x30, // char 0x03C == '<' 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x00, 0x00, //char 0x03D == '=' + 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x00, 0x00, // char 0x03D == '=' 0x00, 0x00, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, - 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0C, 0x0C, //char 0x03E == '>' + 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0C, 0x0C, // char 0x03E == '>' 0x18, 0x18, 0x30, 0x30, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x0C, 0x0C, //char 0x03F == '?' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x0C, 0x0C, // char 0x03F == '?' 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - //Font position 0x040 - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x6E, 0x6E, //char 0x040 == '@' + // Font position 0x040 + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x6E, 0x6E, // char 0x040 == '@' 0x6E, 0x6E, 0x60, 0x60, 0x3E, 0x3E, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x66, //char 0x041 == 'A' + 0x00, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x66, // char 0x041 == 'A' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, 0x66, 0x7C, //char 0x042 == 'B' + 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, 0x66, 0x7C, // char 0x042 == 'B' 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x7C, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x60, 0x60, //char 0x043 == 'C' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x60, 0x60, // char 0x043 == 'C' 0x60, 0x60, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x78, 0x78, 0x6C, 0x6C, 0x66, 0x66, //char 0x044 == 'D' + 0x00, 0x00, 0x78, 0x78, 0x6C, 0x6C, 0x66, 0x66, // char 0x044 == 'D' 0x66, 0x66, 0x6C, 0x6C, 0x78, 0x78, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x60, 0x7C, //char 0x045 == 'E' + 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x60, 0x7C, // char 0x045 == 'E' 0x7C, 0x60, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x60, 0x7C, //char 0x046 == 'F' + 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, 0x60, 0x7C, // char 0x046 == 'F' 0x7C, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x60, 0x60, 0x60, //char 0x047 == 'G' + 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x60, 0x60, 0x60, // char 0x047 == 'G' 0x6E, 0x6E, 0x66, 0x66, 0x3E, 0x3E, 0x00, 0x00, - //Font position 0x048 - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7E, //char 0x048 == 'H' + // Font position 0x048 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7E, // char 0x048 == 'H' 0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x18, 0x18, 0x18, 0x18, //char 0x049 == 'I' + 0x00, 0x00, 0x7E, 0x7E, 0x18, 0x18, 0x18, 0x18, // char 0x049 == 'I' 0x18, 0x18, 0x18, 0x18, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, //char 0x04A == 'J' + 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, // char 0x04A == 'J' 0x06, 0x06, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x6C, 0x6C, 0x78, 0x78, //char 0x04B == 'K' + 0x00, 0x00, 0x66, 0x66, 0x6C, 0x6C, 0x78, 0x78, // char 0x04B == 'K' 0x78, 0x78, 0x6C, 0x6C, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, //char 0x04C == 'L' + 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, // char 0x04C == 'L' 0x60, 0x60, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x63, 0x63, 0x77, 0x77, 0x7F, 0x7F, //char 0x04D == 'M' + 0x00, 0x00, 0x63, 0x63, 0x77, 0x77, 0x7F, 0x7F, // char 0x04D == 'M' 0x6B, 0x6B, 0x63, 0x63, 0x63, 0x63, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x76, 0x76, 0x7E, 0x7E, //char 0x04E == 'N' + 0x00, 0x00, 0x66, 0x66, 0x76, 0x76, 0x7E, 0x7E, // char 0x04E == 'N' 0x7E, 0x7E, 0x6E, 0x6E, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x66, 0x66, //char 0x04F == 'O' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x66, 0x66, // char 0x04F == 'O' 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - //Font position 0x050 - 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, 0x66, 0x7C, //char 0x050 == 'P' + // Font position 0x050 + 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, 0x66, 0x7C, // char 0x050 == 'P' 0x7C, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x66, 0x66, //char 0x051 == 'Q' + 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x66, 0x66, // char 0x051 == 'Q' 0x66, 0x66, 0x6C, 0x6C, 0x36, 0x36, 0x00, 0x00, - 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66, 0x7E, //char 0x052 == 'R' + 0x00, 0x00, 0x7C, 0x7E, 0x66, 0x66, 0x66, 0x7E, // char 0x052 == 'R' 0x7C, 0x78, 0x68, 0x6C, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x3E, 0x60, 0x60, 0x60, 0x3C, //char 0x053 == 'S' + 0x00, 0x00, 0x3C, 0x3E, 0x60, 0x60, 0x60, 0x3C, // char 0x053 == 'S' 0x3C, 0x06, 0x06, 0x06, 0x7C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x18, 0x18, 0x18, 0x18, //char 0x054 == 'T' + 0x00, 0x00, 0x7E, 0x7E, 0x18, 0x18, 0x18, 0x18, // char 0x054 == 'T' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, //char 0x055 == 'U' + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, // char 0x055 == 'U' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, //char 0x056 == 'V' + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, // char 0x056 == 'V' 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, 0x6B, 0x6B, //char 0x057 == 'W' + 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, 0x6B, 0x6B, // char 0x057 == 'W' 0x7F, 0x7F, 0x77, 0x77, 0x63, 0x63, 0x00, 0x00, - //Font position 0x058 - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, //char 0x058 == 'X' + // Font position 0x058 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, // char 0x058 == 'X' 0x3C, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, //char 0x059 == 'Y' + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, // char 0x059 == 'Y' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, 0x18, 0x18, //char 0x05A == 'Z' + 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, 0x18, 0x18, // char 0x05A == 'Z' 0x30, 0x30, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, //char 0x05B == '[' + 0x00, 0x00, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, // char 0x05B == '[' 0x18, 0x18, 0x18, 0x18, 0x1E, 0x1E, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x40, 0x60, 0x60, 0x30, 0x30, //char 0x05C == '\' + 0x00, 0x00, 0x40, 0x40, 0x60, 0x60, 0x30, 0x30, // char 0x05C == '\' 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x78, 0x78, 0x18, 0x18, 0x18, 0x18, //char 0x05D == ']' + 0x00, 0x00, 0x78, 0x78, 0x18, 0x18, 0x18, 0x18, // char 0x05D == ']' 0x18, 0x18, 0x18, 0x18, 0x78, 0x78, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x08, 0x1C, 0x1C, 0x36, 0x36, //char 0x05E == '^' + 0x00, 0x00, 0x08, 0x08, 0x1C, 0x1C, 0x36, 0x36, // char 0x05E == '^' 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x05F == '_' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x05F == '_' 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x060 - 0x00, 0x00, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, //char 0x060 == '`' + // Font position 0x060 + 0x00, 0x00, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, // char 0x060 == '`' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x06, 0x06, //char 0x061 == 'a' + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x06, 0x06, // char 0x061 == 'a' 0x3E, 0x3E, 0x66, 0x66, 0x3E, 0x3E, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x7C, //char 0x062 == 'b' + 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x7C, // char 0x062 == 'b' 0x66, 0x66, 0x66, 0x66, 0x7C, 0x7C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x60, 0x60, //char 0x063 == 'c' + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x60, 0x60, // char 0x063 == 'c' 0x60, 0x60, 0x60, 0x60, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x3E, 0x3E, //char 0x064 == 'd' + 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x3E, 0x3E, // char 0x064 == 'd' 0x66, 0x66, 0x66, 0x66, 0x3E, 0x3E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, //char 0x065 == 'e' + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, // char 0x065 == 'e' 0x7E, 0x7E, 0x60, 0x60, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x0E, 0x0E, 0x18, 0x18, 0x3E, 0x3E, //char 0x066 == 'f' + 0x00, 0x00, 0x0E, 0x0E, 0x18, 0x18, 0x3E, 0x3E, // char 0x066 == 'f' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x66, 0x66, //char 0x067 == 'g' + 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x66, 0x66, // char 0x067 == 'g' 0x66, 0x66, 0x3E, 0x3E, 0x06, 0x06, 0x7C, 0x7C, - //Font position 0x068 - 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x7C, //char 0x068 == 'h' + // Font position 0x068 + 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x7C, // char 0x068 == 'h' 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x38, 0x38, //char 0x069 == 'i' + 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x38, 0x38, // char 0x069 == 'i' 0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, //char 0x06A == 'j' + 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x06, 0x06, // char 0x06A == 'j' 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3C, 0x3C, - 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x6C, 0x6C, //char 0x06B == 'k' + 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x6C, 0x6C, // char 0x06B == 'k' 0x78, 0x78, 0x6C, 0x6C, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x38, 0x38, 0x18, 0x18, 0x18, 0x18, //char 0x06C == 'l' + 0x00, 0x00, 0x38, 0x38, 0x18, 0x18, 0x18, 0x18, // char 0x06C == 'l' 0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x7F, 0x7F, //char 0x06D == 'm' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x7F, 0x7F, // char 0x06D == 'm' 0x7F, 0x7F, 0x6B, 0x6B, 0x63, 0x63, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, //char 0x06E == 'n' + 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, // char 0x06E == 'n' 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, //char 0x06F == 'o' + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, // char 0x06F == 'o' 0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x00, 0x00, - //Font position 0x070 - 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, //char 0x070 == 'p' + // Font position 0x070 + 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, // char 0x070 == 'p' 0x66, 0x66, 0x7C, 0x7C, 0x60, 0x60, 0x60, 0x60, - 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x66, 0x66, //char 0x071 == 'q' + 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x66, 0x66, // char 0x071 == 'q' 0x66, 0x66, 0x3E, 0x3E, 0x06, 0x06, 0x06, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, //char 0x072 == 'r' + 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x66, 0x66, // char 0x072 == 'r' 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x60, //char 0x073 == 's' + 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x60, // char 0x073 == 's' 0x3C, 0x3C, 0x06, 0x06, 0x7C, 0x7C, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x7E, 0x7E, 0x18, 0x18, //char 0x074 == 't' + 0x00, 0x00, 0x18, 0x18, 0x7E, 0x7E, 0x18, 0x18, // char 0x074 == 't' 0x18, 0x18, 0x18, 0x18, 0x0E, 0x0E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x075 == 'u' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x075 == 'u' 0x66, 0x66, 0x66, 0x66, 0x3E, 0x3E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x076 == 'v' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x076 == 'v' 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x6B, 0x6B, //char 0x077 == 'w' + 0x00, 0x00, 0x00, 0x00, 0x63, 0x63, 0x6B, 0x6B, // char 0x077 == 'w' 0x7F, 0x7F, 0x3E, 0x3E, 0x36, 0x36, 0x00, 0x00, - //Font position 0x078 - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, //char 0x078 == 'x' + // Font position 0x078 + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, // char 0x078 == 'x' 0x18, 0x18, 0x3C, 0x3C, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x079 == 'y' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x079 == 'y' 0x66, 0x66, 0x3E, 0x3E, 0x0C, 0x0C, 0x78, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, //char 0x07A == 'z' + 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x0C, 0x0C, // char 0x07A == 'z' 0x18, 0x18, 0x30, 0x30, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x0E, 0x18, 0x18, 0x18, 0x30, //char 0x07B == '{' + 0x00, 0x00, 0x06, 0x0E, 0x18, 0x18, 0x18, 0x30, // char 0x07B == '{' 0x30, 0x18, 0x18, 0x18, 0x0E, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //char 0x07C == '|' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // char 0x07C == '|' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x60, 0x70, 0x18, 0x18, 0x18, 0x0C, //char 0x07D == '}' + 0x00, 0x00, 0x60, 0x70, 0x18, 0x18, 0x18, 0x0C, // char 0x07D == '}' 0x0C, 0x18, 0x18, 0x18, 0x70, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x70, 0x52, //char 0x07E == '~' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x70, 0x52, // char 0x07E == '~' 0x4A, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, //char 0x07F == '' + 0xFF, 0xFF, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, // char 0x07F == '' 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xFF, 0xFF, - //Font position 0x080 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x080 == '€' + // Font position 0x080 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x080 == '€' 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x081 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x081 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x082 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x082 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x083 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x083 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x084 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x084 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x085 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x085 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x086 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x086 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x087 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x087 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x088 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x088 == '_' (free for use) + // Font position 0x088 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x088 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x089 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x089 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08A == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08A == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08B == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08B == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08C == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08C == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08D == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08D == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08E == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08E == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x08F == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x08F == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x090 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x090 == '_' (free for use) + // Font position 0x090 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x090 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x091 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x091 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x092 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x092 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x093 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x093 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x094 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x094 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x095 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x095 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x096 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x096 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x097 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x097 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x098 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x098 == '_' (free for use) + // Font position 0x098 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x098 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x099 == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x099 == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09A == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09A == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09B == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09B == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09C == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09C == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09D == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09D == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09E == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09E == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x09F == '_' (free for use) + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x09F == '_' (free for use) 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - //Font position 0x0A0 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x0A0 == ' ' + // Font position 0x0A0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x0A0 == ' ' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, //char 0x0A1 == '¡' + 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, // char 0x0A1 == '¡' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x06, 0x7F, 0x7F, 0xCC, 0xD8, //char 0x0A2 == '¢' + 0x00, 0x00, 0x03, 0x06, 0x7F, 0x7F, 0xCC, 0xD8, // char 0x0A2 == '¢' 0xD8, 0xF0, 0x7F, 0x7F, 0x60, 0xC0, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, 0x60, 0xFC, //char 0x0A3 == '£' + 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, 0x60, 0xFC, // char 0x0A3 == '£' 0xFC, 0x60, 0x60, 0x60, 0xFE, 0xFE, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0xFF, 0x66, //char 0x0A4 == '¤' + 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0xFF, 0x66, // char 0x0A4 == '¤' 0x66, 0xFF, 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xC3, 0xC3, 0x66, 0x66, 0x3C, 0xFF, //char 0x0A5 == '¥' + 0x00, 0x00, 0xC3, 0xC3, 0x66, 0x66, 0x3C, 0xFF, // char 0x0A5 == '¥' 0xFF, 0x18, 0xFF, 0xFF, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, //char 0x0A6 == '¦' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, // char 0x0A6 == '¦' 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x60, 0x3C, 0x66, //char 0x0A7 == '§' + 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x60, 0x3C, 0x66, // char 0x0A7 == '§' 0x66, 0x3C, 0x06, 0x66, 0x7E, 0x3C, 0x00, 0x00, - //Font position 0x0A8 - 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, //char 0x0A8 == '¨' + // Font position 0x0A8 + 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, // char 0x0A8 == '¨' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0xFF, 0xC3, 0xDB, 0xDB, 0xD3, //char 0x0A9 == '©' + 0x00, 0x00, 0x7E, 0xFF, 0xC3, 0xDB, 0xDB, 0xD3, // char 0x0A9 == '©' 0xD3, 0xDB, 0xDB, 0xC3, 0xFF, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0x3E, 0x06, 0x3E, 0x36, 0x3E, //char 0x0AA == 'ª' + 0x00, 0x00, 0x3E, 0x3E, 0x06, 0x3E, 0x36, 0x3E, // char 0x0AA == 'ª' 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1B, 0x36, 0x6C, 0x6C, 0xD8, //char 0x0AB == '«' + 0x00, 0x00, 0x00, 0x1B, 0x36, 0x6C, 0x6C, 0xD8, // char 0x0AB == '«' 0xD8, 0x6C, 0x6C, 0x36, 0x1B, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x06, //char 0x0AC == '¬' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x06, // char 0x0AC == '¬' 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, //char 0x0AD == '­' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, // char 0x0AD == '­' 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7E, 0xFF, 0xC3, 0xDD, 0xD5, 0xDD, //char 0x0AE == '®' + 0x00, 0x00, 0x7E, 0xFF, 0xC3, 0xDD, 0xD5, 0xDD, // char 0x0AE == '®' 0xDD, 0xD5, 0xD5, 0xC3, 0xFF, 0x7E, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x0AF == '¯' + 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x0AF == '¯' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //Font position 0x0B0 - 0x00, 0x00, 0x08, 0x1C, 0x36, 0x36, 0x1C, 0x08, //char 0x0B0 == '°' + // Font position 0x0B0 + 0x00, 0x00, 0x08, 0x1C, 0x36, 0x36, 0x1C, 0x08, // char 0x0B0 == '°' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x7E, 0x7E, 0x18, //char 0x0B1 == '±' + 0x00, 0x00, 0x18, 0x18, 0x18, 0x7E, 0x7E, 0x18, // char 0x0B1 == '±' 0x18, 0x18, 0x00, 0x00, 0x7E, 0x7E, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0x3E, 0x0E, 0x0C, 0x38, 0x3E, //char 0x0B2 == '²' + 0x00, 0x00, 0x3E, 0x3E, 0x0E, 0x0C, 0x38, 0x3E, // char 0x0B2 == '²' 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3E, 0x3E, 0x0E, 0x1C, 0x0C, 0x3E, //char 0x0B3 == '³' + 0x00, 0x00, 0x3E, 0x3E, 0x0E, 0x1C, 0x0C, 0x3E, // char 0x0B3 == '³' 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0E, 0x1C, 0x38, 0x00, 0x00, 0x00, //char 0x0B4 == '´' + 0x00, 0x00, 0x0E, 0x1C, 0x38, 0x00, 0x00, 0x00, // char 0x0B4 == '´' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0B5 == 'µ' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0B5 == 'µ' 0x7E, 0x7E, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x3F, 0x3F, 0x7F, 0x7F, 0x3B, 0x3B, //char 0x0B6 == '¶' + 0x00, 0x00, 0x3F, 0x3F, 0x7F, 0x7F, 0x3B, 0x3B, // char 0x0B6 == '¶' 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, //char 0x0B7 == '·' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, // char 0x0B7 == '·' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //Font position 0x0B8 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //char 0x0B8 == '¸' + // Font position 0x0B8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // char 0x0B8 == '¸' 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0C, 0x0C, 0x1C, 0x3C, 0x3C, 0x0C, //char 0x0B9 == '¹' + 0x00, 0x00, 0x0C, 0x0C, 0x1C, 0x3C, 0x3C, 0x0C, // char 0x0B9 == '¹' 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, 0x66, 0x7E, //char 0x0BA == 'º' + 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, 0x66, 0x7E, // char 0x0BA == 'º' 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36, 0x36, 0x1B, //char 0x0BB == '»' + 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36, 0x36, 0x1B, // char 0x0BB == '»' 0x1B, 0x36, 0x36, 0x6C, 0xD8, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x60, 0xE0, 0xE3, 0x66, 0x6C, 0x18, //char 0x0BC == '¼' + 0x00, 0x00, 0x60, 0xE0, 0xE3, 0x66, 0x6C, 0x18, // char 0x0BC == '¼' 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x60, 0xE0, 0xE3, 0x66, 0x6C, 0x18, //char 0x0BD == '½' + 0x00, 0x00, 0x60, 0xE0, 0xE3, 0x66, 0x6C, 0x18, // char 0x0BD == '½' 0x18, 0x37, 0x6F, 0xC7, 0x18, 0x1F, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0x60, 0xE3, 0x66, 0xEC, 0x18, //char 0x0BE == '¾' + 0x00, 0x00, 0xE0, 0x60, 0xE3, 0x66, 0xEC, 0x18, // char 0x0BE == '¾' 0x18, 0x33, 0x67, 0xCF, 0x1F, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, //char 0x0BF == '¿' + 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, // char 0x0BF == '¿' 0x18, 0x30, 0x30, 0x36, 0x3E, 0x3E, 0x00, 0x00, - //Font position 0x0C0 - 0x30, 0x18, 0x0C, 0x18, 0x3C, 0x66, 0x66, 0x66, //char 0x0C0 == 'À' + // Font position 0x0C0 + 0x30, 0x18, 0x0C, 0x18, 0x3C, 0x66, 0x66, 0x66, // char 0x0C0 == 'À' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x18, 0x3C, 0x66, 0x66, 0x66, //char 0x0C1 == 'Á' + 0x0C, 0x18, 0x30, 0x18, 0x3C, 0x66, 0x66, 0x66, // char 0x0C1 == 'Á' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x66, 0x66, //char 0x0C2 == 'Â' + 0x18, 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x66, 0x66, // char 0x0C2 == 'Â' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x18, 0x3C, 0x66, 0x66, //char 0x0C3 == 'Ã' + 0x36, 0x7E, 0x6C, 0x00, 0x18, 0x3C, 0x66, 0x66, // char 0x0C3 == 'Ã' 0x66, 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, //char 0x0C4 == 'Ä' + 0x66, 0x66, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, // char 0x0C4 == 'Ä' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x3C, 0x3C, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, //char 0x0C5 == 'Å' + 0x3C, 0x3C, 0x00, 0x18, 0x3C, 0x66, 0x66, 0x66, // char 0x0C5 == 'Å' 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x37, 0x7F, 0xCC, 0xCC, 0xCC, //char 0x0C6 == 'Æ' + 0x00, 0x00, 0x00, 0x37, 0x7F, 0xCC, 0xCC, 0xCC, // char 0x0C6 == 'Æ' 0xFF, 0xFF, 0xCC, 0xCC, 0xCF, 0xCF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x60, //char 0x0C7 == 'Ç' + 0x00, 0x00, 0x00, 0x3C, 0x3C, 0x66, 0x66, 0x60, // char 0x0C7 == 'Ç' 0x60, 0x66, 0x66, 0x3C, 0x3C, 0x08, 0x38, 0x38, - //Font position 0x0C8 - 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x7E, 0x60, 0x60, //char 0x0C8 == 'È' + // Font position 0x0C8 + 0x30, 0x18, 0x0C, 0x00, 0x7E, 0x7E, 0x60, 0x60, // char 0x0C8 == 'È' 0x7C, 0x7C, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x7E, 0x60, 0x60, //char 0x0C9 == 'É' + 0x0C, 0x18, 0x30, 0x00, 0x7E, 0x7E, 0x60, 0x60, // char 0x0C9 == 'É' 0x7C, 0x7C, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x7E, 0x7E, 0x60, 0x60, //char 0x0CA == 'Ê' + 0x18, 0x3C, 0x66, 0x00, 0x7E, 0x7E, 0x60, 0x60, // char 0x0CA == 'Ê' 0x7C, 0x7C, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, //char 0x0CB == 'Ë' + 0x66, 0x66, 0x00, 0x00, 0x7E, 0x7E, 0x60, 0x60, // char 0x0CB == 'Ë' 0x7C, 0x7C, 0x60, 0x60, 0x7E, 0x7E, 0x00, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x18, 0x18, 0x18, 0x18, //char 0x0CC == 'Ì' + 0x30, 0x18, 0x0C, 0x00, 0x18, 0x18, 0x18, 0x18, // char 0x0CC == 'Ì' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x18, 0x18, 0x18, 0x18, //char 0x0CD == 'Í' + 0x0C, 0x18, 0x30, 0x00, 0x18, 0x18, 0x18, 0x18, // char 0x0CD == 'Í' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, //char 0x0CE == 'Î' + 0x18, 0x3C, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, // char 0x0CE == 'Î' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, //char 0x0CF == 'Ï' + 0x66, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, // char 0x0CF == 'Ï' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - //Font position 0x0D0 - 0x00, 0x00, 0x78, 0x7C, 0x66, 0x66, 0x66, 0xF6, //char 0x0D0 == 'Ð' + // Font position 0x0D0 + 0x00, 0x00, 0x78, 0x7C, 0x66, 0x66, 0x66, 0xF6, // char 0x0D0 == 'Ð' 0xF6, 0x66, 0x66, 0x66, 0x7C, 0x78, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x66, 0x66, 0x76, 0x76, //char 0x0D1 == 'Ñ' + 0x36, 0x7E, 0x6C, 0x00, 0x66, 0x66, 0x76, 0x76, // char 0x0D1 == 'Ñ' 0x7E, 0x7E, 0x6E, 0x6E, 0x66, 0x66, 0x00, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0D2 == 'Ò' + 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0D2 == 'Ò' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0D3 == 'Ó' + 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0D3 == 'Ó' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0D4 == 'Ô' + 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0D4 == 'Ô' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0D5 == 'Õ' + 0x36, 0x7E, 0x6C, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0D5 == 'Õ' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0D6 == 'Ö' + 0x66, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0D6 == 'Ö' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, //char 0x0D7 == '×' + 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, // char 0x0D7 == '×' 0x18, 0x18, 0x3C, 0x66, 0x66, 0x00, 0x00, 0x00, - //Font position 0x0D8 - 0x00, 0x03, 0x06, 0x3E, 0x7E, 0x6E, 0x6E, 0x7E, //char 0x0D8 == 'Ø' + // Font position 0x0D8 + 0x00, 0x03, 0x06, 0x3E, 0x7E, 0x6E, 0x6E, 0x7E, // char 0x0D8 == 'Ø' 0x7E, 0x7E, 0x76, 0x76, 0x7E, 0xFC, 0xC0, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0D9 == 'Ù' + 0x30, 0x18, 0x0C, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0D9 == 'Ù' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0DA == 'Ú' + 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0DA == 'Ú' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0DB == 'Û' + 0x18, 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0DB == 'Û' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0DC == 'Ü' + 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0DC == 'Ü' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0E, 0x38, 0x00, 0x00, 0x66, 0x66, 0x66, 0x7E, //char 0x0DD == 'Ý' + 0x0E, 0x38, 0x00, 0x00, 0x66, 0x66, 0x66, 0x7E, // char 0x0DD == 'Ý' 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x60, 0x7C, 0x7E, 0x63, //char 0x0DE == 'Þ' + 0x00, 0x00, 0x00, 0x60, 0x60, 0x7C, 0x7E, 0x63, // char 0x0DE == 'Þ' 0x63, 0x63, 0x7E, 0x7C, 0x60, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x1C, 0x3E, 0x66, 0x66, 0x6E, //char 0x0DF == 'ß' + 0x00, 0x00, 0x00, 0x1C, 0x3E, 0x66, 0x66, 0x6E, // char 0x0DF == 'ß' 0x6C, 0x6E, 0x63, 0x63, 0x6E, 0x6C, 0x00, 0x00, - //Font position 0x0E0 - 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E0 == 'à' + // Font position 0x0E0 + 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E0 == 'à' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E1 == 'á' + 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E1 == 'á' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E2 == 'â' + 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E2 == 'â' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E3 == 'ã' + 0x36, 0x7E, 0x6C, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E3 == 'ã' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E4 == 'ä' + 0x66, 0x66, 0x00, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E4 == 'ä' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x3C, 0x3C, 0x00, 0x00, 0x3C, 0x3E, 0x06, 0x06, //char 0x0E5 == 'å' + 0x3C, 0x3C, 0x00, 0x00, 0x3C, 0x3E, 0x06, 0x06, // char 0x0E5 == 'å' 0x3E, 0x7E, 0x66, 0x66, 0x7E, 0x3E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x76, 0xFF, 0x1B, 0x1B, //char 0x0E6 == 'æ' + 0x00, 0x00, 0x00, 0x00, 0x76, 0xFF, 0x1B, 0x1B, // char 0x0E6 == 'æ' 0x7F, 0xFF, 0xD8, 0xD8, 0xFF, 0x6E, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x60, //char 0x0E7 == 'ç' + 0x00, 0x00, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x60, // char 0x0E7 == 'ç' 0x60, 0x60, 0x66, 0x7E, 0x3C, 0x18, 0x78, 0x78, - //Font position 0x0E8 - 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0E8 == 'è' + // Font position 0x0E8 + 0x30, 0x18, 0x0C, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0E8 == 'è' 0x7E, 0x7E, 0x60, 0x60, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0E9 == 'é' + 0x0C, 0x18, 0x30, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0E9 == 'é' 0x7E, 0x7E, 0x60, 0x60, 0x7E, 0x3C, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0EA == 'ê' + 0x18, 0x3C, 0x66, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0EA == 'ê' 0x7E, 0x7E, 0x60, 0x60, 0x7E, 0x3C, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, //char 0x0EB == 'ë' + 0x66, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, 0x66, // char 0x0EB == 'ë' 0x7E, 0x7E, 0x60, 0x60, 0x7E, 0x3C, 0x00, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x00, 0x18, 0x18, 0x18, //char 0x0EC == 'ì' + 0x30, 0x18, 0x0C, 0x00, 0x00, 0x18, 0x18, 0x18, // char 0x0EC == 'ì' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x00, 0x18, 0x18, 0x18, //char 0x0ED == 'í' + 0x0C, 0x18, 0x30, 0x00, 0x00, 0x18, 0x18, 0x18, // char 0x0ED == 'í' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, //char 0x0EE == 'î' + 0x18, 0x3C, 0x66, 0x00, 0x00, 0x18, 0x18, 0x18, // char 0x0EE == 'î' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, //char 0x0EF == 'ï' + 0x66, 0x66, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, // char 0x0EF == 'ï' 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, - //Font position 0x0F0 - 0x64, 0x38, 0x58, 0x0C, 0x3C, 0x7E, 0x66, 0x66, //char 0x0F0 == 'ð' + // Font position 0x0F0 + 0x64, 0x38, 0x58, 0x0C, 0x3C, 0x7E, 0x66, 0x66, // char 0x0F0 == 'ð' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x60, 0x7E, 0x7E, 0x66, //char 0x0F1 == 'ñ' + 0x36, 0x7E, 0x6C, 0x00, 0x60, 0x7E, 0x7E, 0x66, // char 0x0F1 == 'ñ' 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x00, 0x3C, 0x7E, 0x66, //char 0x0F2 == 'ò' + 0x30, 0x18, 0x0C, 0x00, 0x00, 0x3C, 0x7E, 0x66, // char 0x0F2 == 'ò' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x00, 0x3C, 0x7E, 0x66, //char 0x0F3 == 'ó' + 0x0C, 0x18, 0x30, 0x00, 0x00, 0x3C, 0x7E, 0x66, // char 0x0F3 == 'ó' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, //char 0x0F4 == 'ô' + 0x18, 0x3C, 0x66, 0x00, 0x00, 0x3C, 0x7E, 0x66, // char 0x0F4 == 'ô' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x36, 0x7E, 0x6C, 0x00, 0x00, 0x3C, 0x7E, 0x66, //char 0x0F5 == 'õ' + 0x36, 0x7E, 0x6C, 0x00, 0x00, 0x3C, 0x7E, 0x66, // char 0x0F5 == 'õ' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x00, 0x3C, 0x7E, 0x66, //char 0x0F6 == 'ö' + 0x66, 0x66, 0x00, 0x00, 0x00, 0x3C, 0x7E, 0x66, // char 0x0F6 == 'ö' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x7E, //char 0x0F7 == '÷' + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x7E, // char 0x0F7 == '÷' 0x7E, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, - //Font position 0x0F8 - 0x00, 0x00, 0x03, 0x06, 0x3E, 0x7E, 0x6E, 0x6E, //char 0x0F8 == 'ø' + // Font position 0x0F8 + 0x00, 0x00, 0x03, 0x06, 0x3E, 0x7E, 0x6E, 0x6E, // char 0x0F8 == 'ø' 0x7E, 0x7E, 0x76, 0x76, 0x7E, 0x7C, 0xC0, 0x00, - 0x30, 0x18, 0x0C, 0x00, 0x00, 0x66, 0x66, 0x66, //char 0x0F9 == 'ù' + 0x30, 0x18, 0x0C, 0x00, 0x00, 0x66, 0x66, 0x66, // char 0x0F9 == 'ù' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x00, 0x66, 0x66, 0x66, //char 0x0FA == 'ú' + 0x0C, 0x18, 0x30, 0x00, 0x00, 0x66, 0x66, 0x66, // char 0x0FA == 'ú' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x18, 0x3C, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, //char 0x0FB == 'û' + 0x18, 0x3C, 0x66, 0x00, 0x00, 0x66, 0x66, 0x66, // char 0x0FB == 'û' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, //char 0x0FC == 'ü' + 0x66, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, // char 0x0FC == 'ü' 0x66, 0x66, 0x66, 0x66, 0x7E, 0x3C, 0x00, 0x00, - 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0FD == 'ý' + 0x0C, 0x18, 0x30, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0FD == 'ý' 0x7E, 0x3C, 0x18, 0x18, 0x18, 0x70, 0x70, 0x00, - 0x00, 0x00, 0x60, 0x60, 0x6C, 0x7E, 0x7E, 0x66, //char 0x0FE == 'þ' + 0x00, 0x00, 0x60, 0x60, 0x6C, 0x7E, 0x7E, 0x66, // char 0x0FE == 'þ' 0x66, 0x7E, 0x7E, 0x6C, 0x60, 0x60, 0x60, 0x00, - 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, //char 0x0FF == 'ÿ' + 0x00, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, // char 0x0FF == 'ÿ' 0x7E, 0x3C, 0x18, 0x18, 0x18, 0x70, 0x70, 0x00, - //Font position 0x100 - 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x18, 0x18, //char 0x100 == special for uLE - 0x18, 0x18, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x00, //Left half of Circle == SJIS 0x819B) - 0x00, 0x00, 0xC0, 0xC0, 0x30, 0x30, 0x18, 0x18, //char 0x101 == special for uLE - 0x18, 0x18, 0x30, 0x30, 0xC0, 0xC0, 0x00, 0x00, //Right half of Circle - 0x00, 0x00, 0x18, 0x18, 0x0E, 0x0E, 0x03, 0x03, //char 0x102 == special for uLE - 0x03, 0x03, 0x0E, 0x0E, 0x18, 0x18, 0x00, 0x00, //Left half of Cross == SJIS 0x817E) - 0x00, 0x00, 0x18, 0x18, 0x70, 0x70, 0xC0, 0xC0, //char 0x103 == special for uLE - 0xC0, 0xC0, 0x70, 0x70, 0x18, 0x18, 0x00, 0x00, //Right half of Cross - 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18, 0x18, //char 0x104 == special for uLE - 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, //Left half of Square == SJIS 0x81A0) - 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, //char 0x105 == special for uLE - 0x18, 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, //Right half of Square - 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x06, 0x06, //char 0x106 == special for uLE - 0x0C, 0x0C, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, //Left half of Triangle == SJIS 0x81A2) - 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0x60, 0x60, //char 0x107 == special for uLE - 0x30, 0x30, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, //Right half of Triangle - //Font position 0x108 - 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, //char 0x108 == special for uLE - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, //Left half of filledSq == SJIS 0x81A1) - 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, //char 0x109 == special for uLE - 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00, //Right half of filledSq - //Font position 0x10A - 0x08, 0x08, 0x18, 0x18, 0x38, 0x38, 0x78, 0x78, //char 0x10A == Triangle pointing left + // Font position 0x100 + 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x18, 0x18, // char 0x100 == special for uLE + 0x18, 0x18, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x00, // Left half of Circle == SJIS 0x819B) + 0x00, 0x00, 0xC0, 0xC0, 0x30, 0x30, 0x18, 0x18, // char 0x101 == special for uLE + 0x18, 0x18, 0x30, 0x30, 0xC0, 0xC0, 0x00, 0x00, // Right half of Circle + 0x00, 0x00, 0x18, 0x18, 0x0E, 0x0E, 0x03, 0x03, // char 0x102 == special for uLE + 0x03, 0x03, 0x0E, 0x0E, 0x18, 0x18, 0x00, 0x00, // Left half of Cross == SJIS 0x817E) + 0x00, 0x00, 0x18, 0x18, 0x70, 0x70, 0xC0, 0xC0, // char 0x103 == special for uLE + 0xC0, 0xC0, 0x70, 0x70, 0x18, 0x18, 0x00, 0x00, // Right half of Cross + 0x00, 0x00, 0x1F, 0x1F, 0x18, 0x18, 0x18, 0x18, // char 0x104 == special for uLE + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, // Left half of Square == SJIS 0x81A0) + 0x00, 0x00, 0xF8, 0xF8, 0x18, 0x18, 0x18, 0x18, // char 0x105 == special for uLE + 0x18, 0x18, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, // Right half of Square + 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x06, 0x06, // char 0x106 == special for uLE + 0x0C, 0x0C, 0x18, 0x18, 0x1F, 0x1F, 0x00, 0x00, // Left half of Triangle == SJIS 0x81A2) + 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0, 0x60, 0x60, // char 0x107 == special for uLE + 0x30, 0x30, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, // Right half of Triangle + // Font position 0x108 + 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, // char 0x108 == special for uLE + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, // Left half of filledSq == SJIS 0x81A1) + 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, // char 0x109 == special for uLE + 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00, // Right half of filledSq + // Font position 0x10A + 0x08, 0x08, 0x18, 0x18, 0x38, 0x38, 0x78, 0x78, // char 0x10A == Triangle pointing left 0x38, 0x38, 0x18, 0x18, 0x08, 0x08, 0x00, 0x00, //--this used to be 0x07E - 0x10, 0x10, 0x18, 0x18, 0x1C, 0x1C, 0x1E, 0x1E, //char 0x10B == Triangle pointing right + 0x10, 0x10, 0x18, 0x18, 0x1C, 0x1C, 0x1E, 0x1E, // char 0x10B == Triangle pointing right 0x1C, 0x1C, 0x18, 0x18, 0x10, 0x10, 0x00, 0x00, //--this used to be 0x07F - 0x00, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x7E, 0x7E, //char 0x10C == Arrow pointing up + 0x00, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x7E, 0x7E, // char 0x10C == Arrow pointing up 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, //--this used to be 0x09C - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //char 0x10D == Arrow pointing down + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // char 0x10D == Arrow pointing down 0x7E, 0x7E, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x00, //--this used to be 0x09D - 0x00, 0x00, 0x18, 0x18, 0x30, 0x30, 0x7E, 0x7E, //char 0x10E == Arrow pointing left + 0x00, 0x00, 0x18, 0x18, 0x30, 0x30, 0x7E, 0x7E, // char 0x10E == Arrow pointing left 0x30, 0x30, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, //--this used to be 0x09E - 0x00, 0x00, 0x18, 0x18, 0x0C, 0x0C, 0x7E, 0x7E, //char 0x10F == Arrow pointing right + 0x00, 0x00, 0x18, 0x18, 0x0C, 0x0C, 0x7E, 0x7E, // char 0x10F == Arrow pointing right 0x0C, 0x0C, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, //--this used to be 0x09F - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //char 0x110 == Vertical bar + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // char 0x110 == Vertical bar 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, //--this used to be 0x07C - 0x00, 0x00, 0x7E, 0x7E, 0x78, 0x78, 0x7C, 0x7C, //char 0x111 == Arrow pointing up+left + 0x00, 0x00, 0x7E, 0x7E, 0x78, 0x78, 0x7C, 0x7C, // char 0x111 == Arrow pointing up+left 0x6E, 0x6E, 0x66, 0x66, 0x06, 0x06, 0x00, 0x00, //--this used to be 0x07D - 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, //char 0x112 == diagonal split BR-filled + 0x01, 0x01, 0x03, 0x03, 0x07, 0x07, 0x0F, 0x0F, // char 0x112 == diagonal split BR-filled 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, //--this used to be 0x088 - 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, //char 0x113 == diagonal split BL-filled + 0x80, 0x80, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xF0, // char 0x113 == diagonal split BL-filled 0xF8, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, //--this used to be 0x08A - //Font position 0x114 == Fat arrow Right + // Font position 0x114 == Fat arrow Right 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x3F, 0x30, 0x30, 0x30, 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xB0, 0x98, 0x0C, 0x06, 0x0C, 0x98, 0xB0, 0xE0, 0xC0, 0x80, 0x00, - //Font position 0x116 == Fat arrow Down + // Font position 0x116 == Fat arrow Down 0x00, 0x00, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x3E, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x30, 0x30, 0x30, 0x30, 0x3E, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, - //Font position 0x118 == Fat arrow Left + // Font position 0x118 == Fat arrow Left 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0x80, 0x80, 0x80, 0x00, - //Font position 0x11A == Fat arrow Up + // Font position 0x11A == Fat arrow Up 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x3E, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x3E, 0x30, 0x30, 0x30, 0x30, 0xF0, 0xF0, 0x00, - //Font position 0x11C == Folder icon unselected + // Font position 0x11C == Folder icon unselected 0x00, 0x3C, 0x7E, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF0, 0x00, 0x00, 0x00, - //Font position 0x11E == Folder icon selected + // Font position 0x11E == Folder icon selected 0x00, 0x3C, 0x7E, 0x7F, 0x7F, 0x3E, 0x3C, 0x38, 0x38, 0x3C, 0x3E, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF8, 0x7C, 0x3C, 0x1C, 0x1C, 0x3C, 0x7C, 0xF8, 0xF0, 0x00, 0x00, 0x00, - //Font position 0x120 == File icon unselected + // Font position 0x120 == File icon unselected 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x00, 0x00, - //Font position 0x122 == File icon selected + // Font position 0x122 == File icon selected 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1E, 0x1C, 0x18, 0x18, 0x1C, 0x1E, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0x78, 0x38, 0x18, 0x18, 0x38, 0x78, 0xF8, 0xF8, 0xF8, 0x00, 0x00, //--------------------------------------------------------------------------- - //dlanor: The old methods of accessing these special characters all relied - //on using some character that is invisible in Windows, which is a bad idea. - //so my new routines filter some escape sequences to achieve this, using the - //visible character 0xFF ('ÿ') as escape flag, and the characters "01234" - //to select which of the five special characters to expand. Thus we get: + // dlanor: The old methods of accessing these special characters all relied + // on using some character that is invisible in Windows, which is a bad idea. + // so my new routines filter some escape sequences to achieve this, using the + // visible character 0xFF ('ÿ') as escape flag, and the characters "01234" + // to select which of the five special characters to expand. Thus we get: //"ÿ0"=>Circle "ÿ1"=>Cross "ÿ2"=>Square "ÿ3"=>Triangle "ÿ4"=>FilledBox - //An extra benefit of this is that the method can be used regardless of - //the position in the character set used for these special characters + // An extra benefit of this is that the method can be used regardless of + // the position in the character set used for these special characters // - //The ÿ character should be written as "\xFF", to ensure that its value remains the same - //regardless of the codepage of the operating system. - //The C parser is also greedy; it will always grab as many digits as possible. - //So if you have a number after the sequence that should not be considered part of the - //sequence, break up the numbers by ending the string after the sequence: + // The ÿ character should be written as "\xFF", to ensure that its value remains the same + // regardless of the codepage of the operating system. + // The C parser is also greedy; it will always grab as many digits as possible. + // So if you have a number after the sequence that should not be considered part of the + // sequence, break up the numbers by ending the string after the sequence: // ("\xFF01234\n"); should be written ("\xFF0""1234\n"); -}; //ends font_uLE +}; // ends font_uLE //--------------------------------------------------------------------------- -//End of file: font_uLE.c +// End of file: font_uLE.c //--------------------------------------------------------------------------- diff --git a/src/hdd.c b/src/hdd.c index 41626d24..030bd74e 100644 --- a/src/hdd.c +++ b/src/hdd.c @@ -1,10 +1,10 @@ //-------------------------------------------------------------- -//File name: hdd.c +// File name: hdd.c //-------------------------------------------------------------- #include "launchelf.h" -#define MAX_PARTGB 128 //Partition MAX in GB -#define MAX_PARTMB (MAX_PARTGB * 1024) //Partition MAX in MB +#define MAX_PARTGB 128 // Partition MAX in GB +#define MAX_PARTMB (MAX_PARTGB * 1024) // Partition MAX in MB typedef struct { @@ -13,20 +13,20 @@ typedef struct u64 TotalSize; u64 FreeSize; u64 UsedSize; - GameInfo Game; //Intended for HDL game info, implemented through IRX module + GameInfo Game; // Intended for HDL game info, implemented through IRX module int Count; int Treatment; } PARTYINFO; -enum { //For Treatment codes - TREAT_PFS = 0, //PFS partition for normal file access - TREAT_HDL_RAW, //HDL game partition before reading GameInfo data - TREAT_HDL_GAME, //HDL game partition after reading GameInfo data - TREAT_SYSTEM, //System partition that must never be modified (__mbr) - TREAT_NOACCESS //Inaccessible partition, in fact all other partitions +enum { // For Treatment codes + TREAT_PFS = 0, // PFS partition for normal file access + TREAT_HDL_RAW, // HDL game partition before reading GameInfo data + TREAT_HDL_GAME, // HDL game partition after reading GameInfo data + TREAT_SYSTEM, // System partition that must never be modified (__mbr) + TREAT_NOACCESS // Inaccessible partition, in fact all other partitions }; -enum { //For menu commands +enum { // For menu commands CREATE = 0, REMOVE, RENAME, @@ -35,7 +35,7 @@ enum { //For menu commands NUM_MENU }; -#define SECTORS_PER_MB 2048 //Divide by this to convert from sector count to MB +#define SECTORS_PER_MB 2048 // Divide by this to convert from sector count to MB #define MB 1048576 static PARTYINFO PartyInfo[MAX_PARTITIONS]; @@ -61,34 +61,34 @@ void DebugDisp(char *Message) } //*/ //------------------------------ -//endfunc DebugDisp +// endfunc DebugDisp //-------------------------------------------------------------- /* void DebugDispStat(iox_dirent_t *p) { - char buf[MAX_TEXT_LINE*24]=""; - int stp, pos, i; - unsigned int *ip = &p->stat.private_0; - int *cp = (int *) p->stat.ctime; - int *ap = (int *) p->stat.atime; - int *mp = (int *) p->stat.mtime; - - pos = 0; - sprintf(buf+pos,"dirent.name == \"%s\"\n%n", p->name, &stp); pos+=stp; - sprintf(buf+pos,"dirent.unknown == %d\n%n", p->unknown, &stp); pos+=stp; - sprintf(buf+pos," mode == 0x%08X, attr == 0x%08X\n%n",p->stat.mode,p->stat.attr,&stp); pos+=stp; - sprintf(buf+pos,"hisize == 0x%08X, size == 0x%08X\n%n",p->stat.hisize,p->stat.size,&stp); pos+=stp; - sprintf(buf+pos,"ctime == 0x%08X%08X \n%n", cp[1],cp[0], &stp); pos+=stp; - sprintf(buf+pos,"atime == 0x%08X%08X\n%n", ap[1],ap[0], &stp); pos+=stp; - sprintf(buf+pos,"mtime == 0x%08X%08X\n%n", mp[1],mp[0], &stp); pos+=stp; - for(i=0; i<6; i++){ - sprintf(buf+pos,"private_%d == 0x%08X\n%n", i, ip[i], &stp); pos+=stp; - } - DebugDisp(buf); + char buf[MAX_TEXT_LINE*24]=""; + int stp, pos, i; + unsigned int *ip = &p->stat.private_0; + int *cp = (int *) p->stat.ctime; + int *ap = (int *) p->stat.atime; + int *mp = (int *) p->stat.mtime; + + pos = 0; + sprintf(buf+pos,"dirent.name == \"%s\"\n%n", p->name, &stp); pos+=stp; + sprintf(buf+pos,"dirent.unknown == %d\n%n", p->unknown, &stp); pos+=stp; + sprintf(buf+pos," mode == 0x%08X, attr == 0x%08X\n%n",p->stat.mode,p->stat.attr,&stp); pos+=stp; + sprintf(buf+pos,"hisize == 0x%08X, size == 0x%08X\n%n",p->stat.hisize,p->stat.size,&stp); pos+=stp; + sprintf(buf+pos,"ctime == 0x%08X%08X \n%n", cp[1],cp[0], &stp); pos+=stp; + sprintf(buf+pos,"atime == 0x%08X%08X\n%n", ap[1],ap[0], &stp); pos+=stp; + sprintf(buf+pos,"mtime == 0x%08X%08X\n%n", mp[1],mp[0], &stp); pos+=stp; + for(i=0; i<6; i++){ + sprintf(buf+pos,"private_%d == 0x%08X\n%n", i, ip[i], &stp); pos+=stp; + } + DebugDisp(buf); } //*/ //------------------------------ -//endfunc DebugDispStat +// endfunc DebugDispStat //-------------------------------------------------------------- void GetHddInfo(void) { @@ -125,20 +125,20 @@ void GetHddInfo(void) if ((hddFd = fileXioDopen("hdd0:")) < 0) return; - while (fileXioDread(hddFd, &infoDirEnt) > 0) { //Starts main while loop + while (fileXioDread(hddFd, &infoDirEnt) > 0) { // Starts main while loop u64 found_size = infoDirEnt.stat.size / SECTORS_PER_MB; - //DebugDispStat(&infoDirEnt); + // DebugDispStat(&infoDirEnt); if (infoDirEnt.stat.mode == APA_TYPE_FREE) continue; hddUsed += found_size; - for (i = 0; i < numParty; i++) //Check with previous partitions + for (i = 0; i < numParty; i++) // Check with previous partitions if (!strcmp(infoDirEnt.name, PartyInfo[i].Name)) break; - if (i < numParty) { //found another reference to an old name - PartyInfo[i].RawSize += found_size; //Add new segment to old size - } else { //Starts clause for finding brand new name for PartyInfo[numParty] + if (i < numParty) { // found another reference to an old name + PartyInfo[i].RawSize += found_size; // Add new segment to old size + } else { // Starts clause for finding brand new name for PartyInfo[numParty] if (numParty >= MAX_PARTITIONS) { tooManyPartitions = 1; break; @@ -150,10 +150,10 @@ void GetHddInfo(void) memset(&PartyInfo[numParty], 0, sizeof(PARTYINFO)); strncpy(PartyInfo[numParty].Name, infoDirEnt.name, MAX_PART_NAME); PartyInfo[numParty].Name[MAX_PART_NAME] = '\0'; - PartyInfo[numParty].RawSize = found_size; //Store found segment size + PartyInfo[numParty].RawSize = found_size; // Store found segment size PartyInfo[numParty].Count = numParty; - if (infoDirEnt.stat.mode == APA_TYPE_MBR) //New test of partition type by 'mode' + if (infoDirEnt.stat.mode == APA_TYPE_MBR) // New test of partition type by 'mode' Treat = TREAT_SYSTEM; else if (infoDirEnt.stat.mode == 0x1337) Treat = TREAT_HDL_RAW; @@ -163,7 +163,7 @@ void GetHddInfo(void) Treat = TREAT_NOACCESS; PartyInfo[numParty].Treatment = Treat; - if (Treat == TREAT_PFS) { //Starts clause for TREAT_PFS + if (Treat == TREAT_PFS) { // Starts clause for TREAT_PFS sprintf(tmp, "hdd0:%s", PartyInfo[numParty].Name); partitionFd = fileXioOpen(tmp, O_RDONLY, 0); if (partitionFd >= 0) { @@ -180,7 +180,7 @@ void GetHddInfo(void) // pfs_str[3] = '0'+latestMount; fileXioUmount("pfs0:"); if (fileXioMount("pfs0:", tmp, FIO_MT_RDONLY) < 0) - PartyInfo[numParty].Treatment = TREAT_NOACCESS; //non-pfs partition + PartyInfo[numParty].Treatment = TREAT_NOACCESS; // non-pfs partition else { zoneFree = (u32)fileXioDevctl("pfs0:", PDIOC_ZONEFREE, NULL, 0, NULL, 0); zoneSize = (u32)fileXioDevctl("pfs0:", PDIOC_ZONESZ, NULL, 0, NULL, 0); @@ -188,19 +188,19 @@ void GetHddInfo(void) PartyInfo[numParty].FreeSize = (u64)zoneFree * zoneSize / MB; PartyInfo[numParty].UsedSize = PartyInfo[numParty].TotalSize - PartyInfo[numParty].FreeSize; } - } else { //Ends clause for partitionFd >= 0 + } else { // Ends clause for partitionFd >= 0 PartyInfo[numParty].Treatment = TREAT_NOACCESS; PartyInfo[numParty].FreeSize = 0; PartyInfo[numParty].UsedSize = 0; } - } //Ends clause for TREAT_PFS + } // Ends clause for TREAT_PFS numParty++; - } //Ends clause for finding brand new name for PartyInfo[numParty] - } //ends main while loop + } // Ends clause for finding brand new name for PartyInfo[numParty] + } // ends main while loop fileXioDclose(hddFd); - hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area - hddFree = (hddFreeSpace * 100) / hddSize; //free space percentage + hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; // free space rounded to useful area + hddFree = (hddFreeSpace * 100) / hddSize; // free space percentage end: drawMsg(tooManyPartitions ? LNG(HDD_Information_Read_Overflow) : LNG(HDD_Information_Read)); @@ -210,7 +210,7 @@ void GetHddInfo(void) ; // print operation result during 1.5 sec. } //------------------------------ -//endfunc GetHddInfo +// endfunc GetHddInfo //-------------------------------------------------------------- int sizeSelector(int size) { @@ -220,26 +220,26 @@ int sizeSelector(int size) char c[MAX_PATH]; int event, post_event = 0; - int mSprite_X1 = SCREEN_WIDTH / 2 - 12 * FONT_WIDTH; //Left edge of sprite - int mSprite_Y1 = SCREEN_HEIGHT / 2 - 3 * FONT_HEIGHT; //Top edge of sprite - int mSprite_X2 = SCREEN_WIDTH / 2 + 12 * FONT_WIDTH; //Right edge of sprite - int mSprite_Y2 = SCREEN_HEIGHT / 2 + 3 * FONT_HEIGHT; //Bottom edge of sprite + int mSprite_X1 = SCREEN_WIDTH / 2 - 12 * FONT_WIDTH; // Left edge of sprite + int mSprite_Y1 = SCREEN_HEIGHT / 2 - 3 * FONT_HEIGHT; // Top edge of sprite + int mSprite_X2 = SCREEN_WIDTH / 2 + 12 * FONT_WIDTH; // Right edge of sprite + int mSprite_Y2 = SCREEN_HEIGHT / 2 + 3 * FONT_HEIGHT; // Bottom edge of sprite - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_RIGHT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((size += 128) > MAX_PARTMB) size = MAX_PARTMB; } else if (new_pad & PAD_LEFT) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((size -= 128) < saveSize) size = saveSize; } else if (new_pad & PAD_R1) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (size < 1024) size = 1024; else { @@ -247,11 +247,11 @@ int sizeSelector(int size) size = MAX_PARTMB; } } else if (new_pad & PAD_L1) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((size -= 1024) < saveSize) size = saveSize; } else if (new_pad & PAD_R2) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if (size < 10240) size = 10240; else { @@ -259,20 +259,20 @@ int sizeSelector(int size) size = MAX_PARTMB; } } else if (new_pad & PAD_L2) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command if ((size -= 10240) < saveSize) size = saveSize; } else if ((new_pad & PAD_TRIANGLE) || (!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { return -1; } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2); @@ -284,7 +284,7 @@ int sizeSelector(int size) drawFrame(mSprite_X1 + 7 * FONT_WIDTH, mSprite_Y1 + FONT_HEIGHT / 2, mSprite_X2 - 7 * FONT_WIDTH, mSprite_Y1 + FONT_HEIGHT * 2 + FONT_HEIGHT / 2, setting->color[COLOR_FRAME]); - //RA NB: Next line assumes a scrollbar 19 characters wide (see below) + // RA NB: Next line assumes a scrollbar 19 characters wide (see below) sprintf(c, "128%s %3d%s", LNG(MB), MAX_PARTGB, LNG(GB)); printXY(c, mSprite_X1 + FONT_WIDTH, mSprite_Y1 + FONT_HEIGHT * 3, setting->color[COLOR_TEXT], TRUE, 0); @@ -293,7 +293,7 @@ int sizeSelector(int size) mSprite_X2 - 2 * FONT_WIDTH - FONT_WIDTH / 2, mSprite_Y1 + FONT_HEIGHT * 5); - //RA NB: Next line sets scroll position on a bar 19 chars wide (see above) + // RA NB: Next line sets scroll position on a bar 19 chars wide (see above) scrollBar = (size * (19 * FONT_WIDTH) / (MAX_PARTMB - 128)); drawOpSprite(setting->color[COLOR_FRAME], @@ -302,7 +302,7 @@ int sizeSelector(int size) mSprite_X1 + 2 * FONT_WIDTH + FONT_WIDTH / 2 + (int)scrollBar, mSprite_Y1 + FONT_HEIGHT * 5 + FONT_HEIGHT / 2); - //Tooltip section + // Tooltip section x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], @@ -325,15 +325,15 @@ int sizeSelector(int size) "::-/+128%s L1/R1:-/+1%s L2/R2:-/+10%s", LNG(OK), LNG(Cancel), LNG(Back), LNG(MB), LNG(GB), LNG(GB)); printXY(c, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while return size; } //------------------------------ -//endfunc sizeSelector +// endfunc sizeSelector //-------------------------------------------------------------- int MenuParty(PARTYINFO Info) { @@ -349,16 +349,16 @@ int MenuParty(PARTYINFO Info) menu_len = strlen(LNG(Expand)) > menu_len ? strlen(LNG(Expand)) : menu_len; menu_len = strlen(LNG(Format)) > menu_len ? strlen(LNG(Format)) : menu_len; - int menu_ch_w = menu_len + 1; //Total characters in longest menu string - int menu_ch_h = NUM_MENU; //Total number of menu lines - int mSprite_Y1 = 64; //Top edge of sprite - int mSprite_X2 = SCREEN_WIDTH - 35; //Right edge of sprite - int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; //Left edge of sprite - int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; //Bottom edge of sprite + int menu_ch_w = menu_len + 1; // Total characters in longest menu string + int menu_ch_h = NUM_MENU; // Total number of menu lines + int mSprite_Y1 = 64; // Top edge of sprite + int mSprite_X2 = SCREEN_WIDTH - 35; // Right edge of sprite + int mSprite_X1 = mSprite_X2 - (menu_ch_w + 3) * FONT_WIDTH; // Left edge of sprite + int mSprite_Y2 = mSprite_Y1 + (menu_ch_h + 1) * FONT_HEIGHT; // Bottom edge of sprite - unmountAll(); //unmount all uLE-used mountpoints - unmountParty(0); //unconditionally unmount primary mountpoint - unmountParty(1); //unconditionally unmount secondary mountpoint + unmountAll(); // unmount all uLE-used mountpoints + unmountParty(0); // unconditionally unmount primary mountpoint + unmountParty(1); // unconditionally unmount secondary mountpoint memset(enable, TRUE, NUM_MENU); @@ -371,33 +371,33 @@ int MenuParty(PARTYINFO Info) enable[EXPAND] = FALSE; } /*if (Info.Treatment == TREAT_HDL_RAW) { - enable[EXPAND] = FALSE; + enable[EXPAND] = FALSE; } if (Info.Treatment == TREAT_HDL_GAME) { - enable[EXPAND] = FALSE; + enable[EXPAND] = FALSE; } if (Info.Treatment == TREAT_NOACCESS) { - enable[EXPAND] = FALSE; + enable[EXPAND] = FALSE; }//*/ enable[EXPAND] = FALSE; for (sel = 0; sel < NUM_MENU; sel++) if (enable[sel] == TRUE) break; - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_UP && sel < NUM_MENU) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command do { sel--; if (sel < 0) sel = NUM_MENU - 1; } while (!enable[sel]); } else if (new_pad & PAD_DOWN && sel < NUM_MENU) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command do { sel++; if (sel == NUM_MENU) @@ -406,14 +406,14 @@ int MenuParty(PARTYINFO Info) } else if ((new_pad & PAD_TRIANGLE) || (!swapKeys && new_pad & PAD_CROSS) || (swapKeys && new_pad & PAD_CIRCLE)) { return -1; } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { - event |= 2; //event |= valid pad command + event |= 2; // event |= valid pad command break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section drawPopSprite(setting->color[COLOR_BACKGR], mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2); @@ -442,7 +442,7 @@ int MenuParty(PARTYINFO Info) if (sel < NUM_MENU) drawChar(LEFT_CUR, mSprite_X1 + FONT_WIDTH, mSprite_Y1 + (FONT_HEIGHT / 2 + sel * FONT_HEIGHT), setting->color[COLOR_TEXT]); - //Tooltip section + // Tooltip section x = SCREEN_MARGIN; y = Menu_tooltip_y; drawSprite(setting->color[COLOR_BACKGR], @@ -461,15 +461,15 @@ int MenuParty(PARTYINFO Info) "3:%s", LNG(OK), LNG(Cancel), LNG(Back)); printXY(tmp, x, y, setting->color[COLOR_SELECT], TRUE, 0); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while return sel; } //------------------------------ -//endfunc MenuParty +// endfunc MenuParty //-------------------------------------------------------------- int CreateParty(char *party, int size) { @@ -492,12 +492,12 @@ int CreateParty(char *party, int size) /* if(remSize <= 0)*/ ret = hddMakeFilesystem(size, party, O_RDWR | O_CREAT); /* else{ - ret = hddMakeFilesystem(2048, party, O_RDWR | O_CREAT); - hddGetFilesystemList(hddFs, MAX_PARTITIONS); - for(i=0; i 0) { @@ -514,7 +514,7 @@ int CreateParty(char *party, int size) return ret; } //------------------------------ -//endfunc CreateParty +// endfunc CreateParty //-------------------------------------------------------------- int RemoveParty(PARTYINFO Info) { @@ -530,8 +530,8 @@ int RemoveParty(PARTYINFO Info) if (ret == 0) { hddUsed -= Info.TotalSize; - hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area - hddFree = (hddFreeSpace * 100) / hddSize; //free space percentage + hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; // free space rounded to useful area + hddFree = (hddFreeSpace * 100) / hddSize; // free space percentage numParty--; if (Info.Count == numParty) { memset(&PartyInfo[numParty], 0, sizeof(PARTYINFO)); @@ -555,7 +555,7 @@ int RemoveParty(PARTYINFO Info) return ret; } //------------------------------ -//endfunc RemoveParty +// endfunc RemoveParty //-------------------------------------------------------------- int RenameParty(PARTYINFO Info, char *newName) { @@ -568,9 +568,9 @@ int RenameParty(PARTYINFO Info, char *newName) out[0] = 0; tmpName[0] = 0; sprintf(tmpName, "%s", newName); - if (!strcmp(Info.Name, tmpName)) //Exactly the same name entered. + if (!strcmp(Info.Name, tmpName)) // Exactly the same name entered. goto end; - //If other partitions exist with the same name, append a number to keep the name unique. + // If other partitions exist with the same name, append a number to keep the name unique. for (i = 0; i < numParty; i++) { if (!strcmp(PartyInfo[i].Name, tmpName)) { sprintf(tmpName, "%s%d", newName, num); @@ -580,7 +580,7 @@ int RenameParty(PARTYINFO Info, char *newName) strcpy(newName, tmpName); if (strlen(newName) >= MAX_PART_NAME) { ret = -ENAMETOOLONG; - goto end2; //For this case HDL renaming can't be done + goto end2; // For this case HDL renaming can't be done } sprintf(in, "hdd0:%s", Info.Name); @@ -604,12 +604,12 @@ int RenameParty(PARTYINFO Info, char *newName) return ret; } //------------------------------ -//endfunc RenameParty +// endfunc RenameParty //-------------------------------------------------------------- int RenameGame(PARTYINFO Info, char *newName) { DPRINTF("Rename Game: %d\n", Info.Count); - //int fd; + // int fd; int i, num = 1, ret = 0; char tmpName[MAX_ENTRY]; @@ -629,7 +629,7 @@ int RenameGame(PARTYINFO Info, char *newName) strcpy(newName, tmpName); if (strlen(newName) >= MAX_PART_NAME) { ret = -ENAMETOOLONG; - goto end2; //For this case HDL renaming can't be done + goto end2; // For this case HDL renaming can't be done } ret = HdlRenameGame(Info.Game.Name, newName); @@ -637,12 +637,12 @@ int RenameGame(PARTYINFO Info, char *newName) if (ret == 0) { strcpy(PartyInfo[Info.Count].Game.Name, newName); /* if(mountParty("hdd0:HDLoader Settings")>=0){ - if((fd=genOpen("pfs0:/gamelist.log", O_RDONLY)) >= 0){ - genClose(fd); - if(fileXioRemove("pfs0:/gamelist.log")!=0) - ret=0; - } - unmountParty(latestMount); + if((fd=genOpen("pfs0:/gamelist.log", O_RDONLY)) >= 0){ + genClose(fd); + if(fileXioRemove("pfs0:/gamelist.log")!=0) + ret=0; + } + unmountParty(latestMount); }*/ } else { sprintf(DbgMsg, "HdlRenameGame(\"%s\",\n \"%s\")\n=> %d", Info.Game.Name, newName, ret); @@ -666,7 +666,7 @@ int RenameGame(PARTYINFO Info, char *newName) return ret; } //------------------------------ -//endfunc RenameGame +// endfunc RenameGame //-------------------------------------------------------------- int ExpandParty(PARTYINFO Info, int size) { @@ -675,7 +675,7 @@ int ExpandParty(PARTYINFO Info, int size) t_hddFilesystem hddFs[MAX_PARTITIONS]; drawMsg(LNG(Expanding_Current_Partition)); - //printf("Expand Partition: %d\n", Info.Count); + // printf("Expand Partition: %d\n", Info.Count); sprintf(tmpName, "hdd0:%s", Info.Name); @@ -688,8 +688,8 @@ int ExpandParty(PARTYINFO Info, int size) if (ret > 0) { hddUsed += size; - hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area - hddFree = (hddFreeSpace * 100) / hddSize; //free space percentage + hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; // free space rounded to useful area + hddFree = (hddFreeSpace * 100) / hddSize; // free space percentage PartyInfo[Info.Count].TotalSize += size; PartyInfo[Info.Count].FreeSize += size; @@ -705,7 +705,7 @@ int ExpandParty(PARTYINFO Info, int size) return ret; } //------------------------------ -//endfunc ExpandParty +// endfunc ExpandParty //-------------------------------------------------------------- int FormatHdd(void) { @@ -730,7 +730,7 @@ int FormatHdd(void) return ret; } //------------------------------ -//endfunc FormatHdd +// endfunc FormatHdd //-------------------------------------------------------------- void hddManager(void) { @@ -755,15 +755,15 @@ void hddManager(void) loadHddModules(); GetHddInfo(); - event = 1; //event = initial entry + event = 1; // event = initial entry while (1) { - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad) { - //printf("Selected Partition: %d\n", browser_sel); - event |= 2; //event |= pad command + // printf("Selected Partition: %d\n", browser_sel); + event |= 2; // event |= pad command } if (new_pad & PAD_UP) browser_sel--; @@ -774,10 +774,10 @@ void hddManager(void) else if (new_pad & PAD_RIGHT) browser_sel += rows / 2; else if ((new_pad & PAD_SELECT) || (new_pad & PAD_TRIANGLE)) { - //Prepare for exit from HddManager - unmountAll(); //unmount all uLE-used mountpoints - unmountParty(0); //unconditionally unmount primary mountpoint - unmountParty(1); //unconditionally unmount secondary mountpoint + // Prepare for exit from HddManager + unmountAll(); // unmount all uLE-used mountpoints + unmountParty(0); // unconditionally unmount primary mountpoint + unmountParty(1); // unconditionally unmount secondary mountpoint return; } else if (new_pad & PAD_SQUARE) { if (PartyInfo[browser_sel].Treatment == TREAT_HDL_RAW) { @@ -790,8 +790,8 @@ void hddManager(void) DebugDisp(DbgMsg); } } else if (PartyInfo[browser_sel].Treatment == TREAT_HDL_GAME) - PartyInfo[browser_sel].Treatment = TREAT_HDL_RAW; //Press Square again to unload HDL info - } else if (new_pad & PAD_R1) { //Starts clause for R1 menu + PartyInfo[browser_sel].Treatment = TREAT_HDL_RAW; // Press Square again to unload HDL info + } else if (new_pad & PAD_R1) { // Starts clause for R1 menu ret = MenuParty(PartyInfo[browser_sel]); tmp[0] = 0; if (ret == CREATE) { @@ -804,33 +804,33 @@ void hddManager(void) if ((ret = sizeSelector(partySize)) > 0) { if (ynDialog(LNG(Create_New_Partition)) == 1) { CreateParty(tmp, ret); - nparties = 0; //Tell FileBrowser to refresh party list + nparties = 0; // Tell FileBrowser to refresh party list } } } } else if (ret == REMOVE) { if (ynDialog(LNG(Remove_Current_Partition)) == 1) { RemoveParty(PartyInfo[browser_sel]); - nparties = 0; //Tell FileBrowser to refresh party list + nparties = 0; // Tell FileBrowser to refresh party list } } else if (ret == RENAME) { drawMsg(LNG(Enter_New_Partition_Name)); drawMsg(LNG(Enter_New_Partition_Name)); - if (PartyInfo[browser_sel].Treatment == TREAT_HDL_GAME) { //Rename HDL Game + if (PartyInfo[browser_sel].Treatment == TREAT_HDL_GAME) { // Rename HDL Game strcpy(tmp, PartyInfo[browser_sel].Game.Name); if (keyboard(tmp, MAX_PART_NAME) > 0) { if (ynDialog(LNG(Rename_Current_Game)) == 1) RenameGame(PartyInfo[browser_sel], tmp); } - } else { //starts clause for normal partition RENAME + } else { // starts clause for normal partition RENAME strcpy(tmp, PartyInfo[browser_sel].Name); if (keyboard(tmp, MAX_PART_NAME) > 0) { if (ynDialog(LNG(Rename_Current_Partition)) == 1) { RenameParty(PartyInfo[browser_sel], tmp); - nparties = 0; //Tell FileBrowser to refresh party list + nparties = 0; // Tell FileBrowser to refresh party list } } - } //ends clause for normal partition RENAME + } // ends clause for normal partition RENAME } else if (ret == EXPAND) { drawMsg(LNG(Select_New_Partition_Size_In_MB)); drawMsg(LNG(Select_New_Partition_Size_In_MB)); @@ -839,25 +839,25 @@ void hddManager(void) if (ynDialog(LNG(Expand_Current_Partition)) == 1) { ret -= partySize; ExpandParty(PartyInfo[browser_sel], ret); - nparties = 0; //Tell FileBrowser to refresh party list + nparties = 0; // Tell FileBrowser to refresh party list } } } else if (ret == FORMAT) { if (ynDialog(LNG(Format_HDD)) == 1) { FormatHdd(); - nparties = 0; //Tell FileBrowser to refresh party list + nparties = 0; // Tell FileBrowser to refresh party list } } - } //Ends clause for R1 menu - } //ends pad response section + } // Ends clause for R1 menu + } // ends pad response section - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); browser_nfiles = numParty; - //printf("Number Of Partition: %d\n", numParty); + // printf("Number Of Partition: %d\n", numParty); if (top > browser_nfiles - rows) top = browser_nfiles - rows; @@ -990,9 +990,9 @@ void hddManager(void) printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, ((SCREEN_WIDTH / 2 - 20) - SCREEN_MARGIN - 2 * FONT_WIDTH)); y += FONT_HEIGHT; pfsFree = 0; - } else if (Treat == TREAT_HDL_RAW) { //starts clause for HDL without GameInfo + } else if (Treat == TREAT_HDL_RAW) { // starts clause for HDL without GameInfo //---------- Start of clause for HDL game partitions ---------- - //dlanor NB: Not properly implemented yet + // dlanor NB: Not properly implemented yet sprintf(c, "%s: %d %s", LNG(Raw_SIZE), (int)PartyInfo[browser_sel].RawSize, LNG(MB)); x = ((((SCREEN_WIDTH / 2 - 25) - Menu_start_x) / 2) + Menu_start_x) - (strlen(c) * FONT_WIDTH) / 2; printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, ((SCREEN_WIDTH / 2 - 20) - SCREEN_MARGIN - 2 * FONT_WIDTH)); @@ -1000,8 +1000,8 @@ void hddManager(void) strcpy(c, LNG(Info_not_loaded)); x = ((((SCREEN_WIDTH / 2 - 25) - Menu_start_x) / 2) + Menu_start_x) - (strlen(c) * FONT_WIDTH) / 2; printXY(c, x, y, setting->color[COLOR_TEXT], TRUE, ((SCREEN_WIDTH / 2 - 20) - SCREEN_MARGIN - 2 * FONT_WIDTH)); - pfsFree = -1; //Disable lower pie chart display - } else if (Treat == TREAT_HDL_GAME) { //starts clause for HDL with GameInfo + pfsFree = -1; // Disable lower pie chart display + } else if (Treat == TREAT_HDL_GAME) { // starts clause for HDL with GameInfo y += FONT_HEIGHT / 4; x = ((((SCREEN_WIDTH / 2 - 25) - Menu_start_x) / 2) + Menu_start_x) - @@ -1031,9 +1031,9 @@ void hddManager(void) else printXY(LNG(TYPE_CD_GAME), x, y, setting->color[COLOR_TEXT], TRUE, ((SCREEN_WIDTH / 2 - 20) - SCREEN_MARGIN - 2 * FONT_WIDTH)); - pfsFree = -1; //Disable lower pie chart display + pfsFree = -1; // Disable lower pie chart display //---------- End of clause for HDL game partitions ---------- - } else { //ends clause for HDL, starts clause for normal partitions + } else { // ends clause for HDL, starts clause for normal partitions //---------- Start of clause for PFS partitions ---------- sprintf(c, "%s: %d %s", LNG(PFS_SIZE), (int)PartyInfo[browser_sel].TotalSize, LNG(MB)); @@ -1049,9 +1049,9 @@ void hddManager(void) pfsFree = (PartyInfo[browser_sel].FreeSize * 100) / PartyInfo[browser_sel].TotalSize; //---------- End of clause for normal partitions (not HDL games) ---------- - } //ends clause for normal partitions + } // ends clause for normal partitions - if (pfsFree >= 0) { //Will be negative when skipping this graph + if (pfsFree >= 0) { // Will be negative when skipping this graph x = ((((SCREEN_WIDTH / 2 - 25) - Menu_start_x) / 2) + Menu_start_x); if (TV_mode != TV_mode_PAL) y += ray + 20; @@ -1092,15 +1092,15 @@ void hddManager(void) if (top + i >= browser_nfiles) break; if (top + i == browser_sel) - Color = setting->color[COLOR_SELECT]; //Highlight cursor line + Color = setting->color[COLOR_SELECT]; // Highlight cursor line else Color = setting->color[COLOR_TEXT]; strcpy(tmp, PartyInfo[top + i].Name); printXY(tmp, x + 4, y, Color, TRUE, ((SCREEN_WIDTH - SCREEN_MARGIN) - (SCREEN_WIDTH / 2 - FONT_WIDTH))); y += FONT_HEIGHT; - } //ends for, so all browser rows were fixed above - if (browser_nfiles > rows) { //if more files than available rows, use scrollbar + } // ends for, so all browser rows were fixed above + if (browser_nfiles > rows) { // if more files than available rows, use scrollbar drawFrame(SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 8, Frame_start_y, SCREEN_WIDTH - SCREEN_MARGIN, Frame_end_y, setting->color[COLOR_FRAME]); y0 = (Menu_end_y - Menu_start_y + 8) * ((double)top / browser_nfiles); @@ -1108,9 +1108,9 @@ void hddManager(void) drawOpSprite(setting->color[COLOR_FRAME], SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 6, (y0 + Menu_start_y - 4), SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 2, (y1 + Menu_start_y - 4)); - } //ends clause for scrollbar - } //ends hdd formated - //Tooltip section + } // ends clause for scrollbar + } // ends hdd formated + // Tooltip section sprintf(tooltip, "R1:%s \xFF" "3:%s", LNG(MENU), LNG(Exit)); @@ -1128,14 +1128,14 @@ void hddManager(void) } setScrTmp(LNG(PS2_HDD_MANAGER), tooltip); - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while return; } //------------------------------ -//endfunc hddManager +// endfunc hddManager //-------------------------------------------------------------- diff --git a/src/jpgviewer.c b/src/jpgviewer.c index 94341568..2bc204c9 100644 --- a/src/jpgviewer.c +++ b/src/jpgviewer.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: jpgviewer.c +// File name: jpgviewer.c //-------------------------------------------------------------- #include "launchelf.h" @@ -58,29 +58,29 @@ static void Command_List(void) strlen(LNG(Exit_To_Jpg_Browser)) + 3 : command_len; - int Command_ch_w = command_len + 1; //Total characters in longest Command Name. - int Command_ch_h = 9; //Total Command lines number. - int cSprite_Y1 = SCREEN_HEIGHT / 2 - ((Command_ch_h + 1) * FONT_HEIGHT) / 2; //Top edge - int cSprite_X2 = SCREEN_WIDTH / 2 + ((Command_ch_w + 3) * FONT_WIDTH) / 2; //Right edge - int cSprite_X1 = cSprite_X2 - (Command_ch_w + 3) * FONT_WIDTH - 4; //Left edge - int cSprite_Y2 = cSprite_Y1 + (Command_ch_h + 1) * FONT_HEIGHT; //Bottom edge + int Command_ch_w = command_len + 1; // Total characters in longest Command Name. + int Command_ch_h = 9; // Total Command lines number. + int cSprite_Y1 = SCREEN_HEIGHT / 2 - ((Command_ch_h + 1) * FONT_HEIGHT) / 2; // Top edge + int cSprite_X2 = SCREEN_WIDTH / 2 + ((Command_ch_w + 3) * FONT_WIDTH) / 2; // Right edge + int cSprite_X1 = cSprite_X2 - (Command_ch_w + 3) * FONT_WIDTH - 4; // Left edge + int cSprite_Y2 = cSprite_Y1 + (Command_ch_h + 1) * FONT_HEIGHT; // Bottom edge char tmp[MAX_PATH]; - event = 1; //event = initial entry. + event = 1; // event = initial entry. while (1) { - //Pad response section. + // Pad response section. waitPadReady(0, 0); if (readpad()) { if (new_pad) { - event |= 2; //event |= valid pad command. + event |= 2; // event |= valid pad command. break; } } - if (event || post_event) { //NB: We need to update two frame buffers per event. + if (event || post_event) { // NB: We need to update two frame buffers per event. - //Display section. + // Display section. drawOpSprite(setting->color[COLOR_BACKGR], cSprite_X1, cSprite_Y1, cSprite_X2, cSprite_Y2); drawFrame(cSprite_X1, cSprite_Y1, cSprite_X2, cSprite_Y2, setting->color[COLOR_FRAME]); @@ -111,12 +111,12 @@ static void Command_List(void) printXY(tmp, x, y, setting->color[COLOR_TEXT], TRUE, 0); y += FONT_HEIGHT; - } //ends if(event||post_event). + } // ends if(event||post_event). drawScr(); post_event = event; event = 0; - } //ends while. -} //ends Command_List. + } // ends while. +} // ends Command_List. //-------------------------------------------------------------- static void View_Render(void) { @@ -189,7 +189,7 @@ static void View_Render(void) setBrightness(50); if (!FullScreen) { - //Tooltip section + // Tooltip section strcpy(tmp, jpgpath); name = strrchr(tmp, '/'); strcpy(name, name + 1); @@ -241,7 +241,7 @@ static void View_Input(void) } } - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad & PAD_R3_V0) { // PanZoom In @@ -394,8 +394,8 @@ static void View_Input(void) ; // Wait To Ensure Switch View_Render(); } /* end else */ - } //ends pad response section - } //ends while + } // ends pad response section + } // ends while } /* end View_Input */ //-------------------------------------------------------------- @@ -538,7 +538,7 @@ void JpgViewer(char *file) loadIcon(); - event = 1; //event = initial entry + event = 1; // event = initial entry if (file != NULL) { strncpy(jpgpath, file, MAX_PATH - 1); @@ -546,23 +546,23 @@ void JpgViewer(char *file) strncpy(path, file, MAX_PATH - 1); path[MAX_PATH - 1] = '\0'; - //Separate the path and filename. path must have a trailing slash. + // Separate the path and filename. path must have a trailing slash. if ((p = strrchr(path, '/')) != NULL) { strcpy(cursorEntry, p + 1); *(p + 1) = '\0'; } else { - //Should not happen. + // Should not happen. strncpy(cursorEntry, path, MAX_PATH - 1); cursorEntry[MAX_PATH - 1] = '\0'; } StartShowSingle = TRUE; - jpg_browser_cd = TRUE; //Initial entry into the directory. - jpg_browser_repos = TRUE; //Track the displayed file. + jpg_browser_cd = TRUE; // Initial entry into the directory. + jpg_browser_repos = TRUE; // Track the displayed file. } while (1) { - //Thumb init + // Thumb init if (thumb_load) { jpg_browser_sel = 0; gsGlobal->CurrentPointer = 0x288000; @@ -570,7 +570,7 @@ void JpgViewer(char *file) thumb_test[i] = NOTLOADED; } - //browser path adjustment section + // browser path adjustment section if (jpg_browser_up) { if ((p = strrchr(path, '/')) != NULL) *p = 0; @@ -584,7 +584,7 @@ void JpgViewer(char *file) } jpg_browser_cd = TRUE; jpg_browser_repos = TRUE; - } //ends 'if(jpg_browser_up)' + } // ends 'if(jpg_browser_up)' //----- Process newly entered directory here (incl initial entry) if (jpg_browser_cd) { jpg_browser_nfiles = setFileList(path, ext, files, JPG_CNF); @@ -599,10 +599,10 @@ void JpgViewer(char *file) break; } } - } //ends if(jpg_browser_repos) + } // ends if(jpg_browser_repos) jpg_browser_cd = FALSE; jpg_browser_up = FALSE; - } //ends if(jpg_browser_cd) + } // ends if(jpg_browser_cd) if (!strncmp(path, "cdfs", 4)) { CDVD_Stop(); } @@ -622,11 +622,11 @@ void JpgViewer(char *file) t++; if (t & 0x0F) - event |= 4; //repetitive timer event + event |= 4; // repetitive timer event - if (event || post_event) { //NB: We need to update two frame buffers per event + if (event || post_event) { // NB: We need to update two frame buffers per event - //Display section + // Display section clrScr(setting->color[COLOR_BACKGR]); if (jpg_browser_mode == LIST) { @@ -692,12 +692,12 @@ void JpgViewer(char *file) list: for (i = 0; i < rows; i++) { - int name_limit = 0; //Assume that no name length problems exist + int name_limit = 0; // Assume that no name length problems exist if (top + i >= jpg_browser_nfiles) break; if (top + i == jpg_browser_sel) - color = setting->color[COLOR_SELECT]; //Highlight cursor line + color = setting->color[COLOR_SELECT]; // Highlight cursor line else color = setting->color[COLOR_TEXT]; @@ -708,16 +708,16 @@ void JpgViewer(char *file) name_limit = 71 * 8; } - if (jpg_browser_mode == LIST) { //List mode + if (jpg_browser_mode == LIST) { // List mode - if (name_limit) { //Do we need to check name length ? - int name_end = name_limit / 7; //Max string length for acceptable spacing + if (name_limit) { // Do we need to check name length ? + int name_end = name_limit / 7; // Max string length for acceptable spacing if (files[top + i].stats.AttrFile & sceMcFileAttrSubdir) - name_end -= 1; //For folders, reserve one character for final '/' - if (strlen(tmp) > name_end) { //Is name too long for clean display ? - tmp[name_end - 1] = '~'; //indicate filename abbreviation - tmp[name_end] = 0; //abbreviate name length to make room for details + name_end -= 1; // For folders, reserve one character for final '/' + if (strlen(tmp) > name_end) { // Is name too long for clean display ? + tmp[name_end - 1] = '~'; // indicate filename abbreviation + tmp[name_end] = 0; // abbreviate name length to make room for details } } if (files[top + i].stats.AttrFile & sceMcFileAttrSubdir) @@ -725,7 +725,7 @@ void JpgViewer(char *file) printXY(tmp, x + 4, y, color, TRUE, name_limit); y += FONT_HEIGHT; - } else { //Thumbnail mode + } else { // Thumbnail mode if (files[top + i].stats.AttrFile & sceMcFileAttrSubdir) { strcat(tmp, "/"); @@ -794,9 +794,9 @@ void JpgViewer(char *file) } /* end else THUMBNAIL */ - } //ends for, so all browser rows were fixed above + } // ends for, so all browser rows were fixed above thumb_load = FALSE; - if (jpg_browser_nfiles > rows) { //if more files than available rows, use scrollbar + if (jpg_browser_nfiles > rows) { // if more files than available rows, use scrollbar drawFrame(SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 8, Frame_start_y, SCREEN_WIDTH - SCREEN_MARGIN, Frame_end_y, setting->color[COLOR_FRAME]); y0 = (Menu_end_y - Menu_start_y + 8) * ((double)top / jpg_browser_nfiles); @@ -804,12 +804,12 @@ void JpgViewer(char *file) drawOpSprite(setting->color[COLOR_FRAME], SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 6, (y0 + Menu_start_y - 4), SCREEN_WIDTH - SCREEN_MARGIN - LINE_THICKNESS * 2, (y1 + Menu_start_y - 4)); - } //ends clause for scrollbar + } // ends clause for scrollbar msg0[0] = '\0'; if (jpg_browser_pushed) sprintf(msg0, "%s %s: %s", LNG(Jpg_Viewer), LNG(Path), path); - //Tooltip section + // Tooltip section msg1[0] = '\0'; if (swapKeys) sprintf(msg1, "1:%s", LNG(View)); @@ -834,20 +834,20 @@ void JpgViewer(char *file) sprintf(tmp, " R2:%s", LNG(PathPad)); strcat(msg1, tmp); setScrTmp(msg0, msg1); - } //ends if(event||post_event) + } // ends if(event||post_event) if (StartShowSingle) { StartShowSingle = FALSE; goto single; } - //Pad response section + // Pad response section waitPadReady(0, 0); if (readpad()) { if (new_pad) { jpg_browser_pushed = TRUE; print_name = 0; - event |= 2; //event |= pad command + event |= 2; // event |= pad command tmp[0] = 0; tmp1[0] = 0; t = 0; @@ -889,9 +889,9 @@ void JpgViewer(char *file) } else if (new_pad & PAD_L2) { if (--SlideShowTrans < 1) SlideShowTrans = 4; - } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { //Pushed OK + } else if ((swapKeys && new_pad & PAD_CROSS) || (!swapKeys && new_pad & PAD_CIRCLE)) { // Pushed OK if (files[jpg_browser_sel].stats.AttrFile & sceMcFileAttrSubdir) { - //pushed OK for a folder + // pushed OK for a folder thumb_load = TRUE; if (!strcmp(files[jpg_browser_sel].name, "..")) { jpg_browser_up = TRUE; @@ -901,7 +901,7 @@ void JpgViewer(char *file) jpg_browser_cd = TRUE; } } else { - //pushed OK for a file + // pushed OK for a file restart: sprintf(jpgpath, "%s%s", path, files[jpg_browser_sel].name); @@ -923,9 +923,9 @@ void JpgViewer(char *file) if (SlideShowSkip == 1) SlideShowSkip = 0; else if (SlideShowSkip == -1) { - i -= 2; //Loop index back to JPG before previous + i -= 2; // Loop index back to JPG before previous if (i <= 0) - i += jpg_browser_nfiles - 1; //Loop index back to JPG before final + i += jpg_browser_nfiles - 1; // Loop index back to JPG before final SlideShowSkip = 0; } if (SlideShowStop) @@ -945,7 +945,7 @@ void JpgViewer(char *file) } else if (SlideShowSkip == -1) { jpg_browser_sel -= 1; if (jpg_browser_sel <= 0) - jpg_browser_sel += jpg_browser_nfiles - 1; //Go back to final JPG + jpg_browser_sel += jpg_browser_nfiles - 1; // Go back to final JPG SlideShowSkip = 0; goto restart; } @@ -979,13 +979,13 @@ void JpgViewer(char *file) goto repeat; } } - } //ends pad response section + } // ends pad response section drawScr(); post_event = event; event = 0; - } //ends while + } // ends while } /* end JpgViewer */ //-------------------------------------------------------------- -//End of file: jpgviewer.c +// End of file: jpgviewer.c //-------------------------------------------------------------- diff --git a/src/lang.c b/src/lang.c index 34d6dd7e..cf574728 100644 --- a/src/lang.c +++ b/src/lang.c @@ -1,5 +1,5 @@ //--------------------------------------------------------------------------- -//File name: lang.c +// File name: lang.c //--------------------------------------------------------------------------- #include "launchelf.h" @@ -40,136 +40,136 @@ int get_LANG_string(u8 **LANG_p_p, u8 **id_p_p, u8 **value_p_p) start_line: while (*tp <= ' ' && *tp > '\0') - tp += 1; //Skip leading whitespace, if any + tp += 1; // Skip leading whitespace, if any if (*tp == '\0') - goto exit; //but exit at EOF - //Current pos is potential "lang(" entry, but we must verify this - if (tp[0] == '/' && tp[1] == '/') //It may be a comment line - { //We must skip a comment line + goto exit; // but exit at EOF + // Current pos is potential "lang(" entry, but we must verify this + if (tp[0] == '/' && tp[1] == '/') // It may be a comment line + { // We must skip a comment line while (*tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //Seek line end - goto start_line; //Go back to try next line + tp += 1; // Seek line end + goto start_line; // Go back to try next line } ret = -2; - //Here tp points to a non-zero string that is not a comment + // Here tp points to a non-zero string that is not a comment if (strncmp(tp, "lang", 4)) - goto exit; //Return error if not 'lang' macro - tp += 4; //but if it is, step past that name + goto exit; // Return error if not 'lang' macro + tp += 4; // but if it is, step past that name ret = -3; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -4; - //Here tp points to a non-zero string that should be an opening parenthesis + // Here tp points to a non-zero string that should be an opening parenthesis if (*tp != '(') - goto exit; //Return error if no opening parenthesis - tp += 1; //but if it is, step past this character + goto exit; // Return error if no opening parenthesis + tp += 1; // but if it is, step past this character ret = -5; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -6; - //Here tp points to a non-zero string that should be an index number + // Here tp points to a non-zero string that should be an index number if (*tp < '0' || *tp > '9') - goto exit; //Return error if it's not a number - ip = tp; //but if it is, save this pos as id start + goto exit; // Return error if it's not a number + ip = tp; // but if it is, save this pos as id start while (*tp >= '0' && *tp <= '9') - tp += 1; //skip past the index number + tp += 1; // skip past the index number ret = -7; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -8; - //Here tp points to a non-zero string that should be a comma + // Here tp points to a non-zero string that should be a comma if (*tp != ',') - goto exit; //Return error if no comma after index - tp += 1; //but if present, step past that comma + goto exit; // Return error if no comma after index + tp += 1; // but if present, step past that comma ret = -9; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -10; - //Here tp points to a non-zero string that should be a symbolic string name - //But we don't need to process this for language switch purposes, so we ignore it - //This may be changed later, to use the name for generating error messages + // Here tp points to a non-zero string that should be a symbolic string name + // But we don't need to process this for language switch purposes, so we ignore it + // This may be changed later, to use the name for generating error messages while (*tp != ',' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //seek inline comma + tp += 1; // seek inline comma if (*tp != ',') - goto exit; //Return error if no comma after string name - tp += 1; //but if present, step past that comma + goto exit; // Return error if no comma after string name + tp += 1; // but if present, step past that comma ret = -11; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -12; - //Here tp points to a non-zero string that should be the opening quote character + // Here tp points to a non-zero string that should be the opening quote character if (*tp != '\"') - goto exit; //Return error if no opening quote - tp += 1; //but if present, step past that quote + goto exit; // Return error if no opening quote + tp += 1; // but if present, step past that quote ret = -13; - vp = tp; //save this pos as value start + vp = tp; // save this pos as value start close_quote: while (*tp != '\"' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //seek inline quote + tp += 1; // seek inline quote if (*tp != '\"') - return -13; //Return error if no closing quote - cp = tp - 1; //save previous pos as check pointer - tp += 1; //step past the quote character + return -13; // Return error if no closing quote + cp = tp - 1; // save previous pos as check pointer + tp += 1; // step past the quote character if (*cp == '\\') - goto close_quote; //if this was an 'escaped' quote, try again - //Here tp points to the character after the closing quote. - length = (tp - 1) - vp; //prepare string length for return value + goto close_quote; // if this was an 'escaped' quote, try again + // Here tp points to the character after the closing quote. + length = (tp - 1) - vp; // prepare string length for return value ret = -14; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF ret = -15; - //Here tp points to a non-zero string that should be closing parenthesis + // Here tp points to a non-zero string that should be closing parenthesis if (*tp != ')') - goto exit; //Return error if no closing parenthesis - tp += 1; //but if present, step past the parenthesis + goto exit; // Return error if no closing parenthesis + tp += 1; // but if present, step past the parenthesis ret = -16; while (*tp <= ' ' && *tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //skip inline whitespace + tp += 1; // skip inline whitespace if (*tp == '\0') - goto exit; //but exit at EOF - //Here tp points to a non-zero string that should be line end or a comment + goto exit; // but exit at EOF + // Here tp points to a non-zero string that should be line end or a comment if (tp[0] != '/' || tp[1] != '/') - goto finish_line; //if no comment, go handle line end + goto finish_line; // if no comment, go handle line end ret = -17; while (*tp != '\r' && *tp != '\n' && *tp > '\0') - tp += 1; //Seek line end + tp += 1; // Seek line end if (*tp == '\0') - goto exit; //but exit at EOF + goto exit; // but exit at EOF finish_line: ret = -18; if (*tp != '\r' && *tp != '\n') - goto exit; //Return error if not valid line end + goto exit; // Return error if not valid line end if (tp[0] == '\r' && tp[1] == '\n') - tp += 1; //Step an extra pos for CR+LF - tp += 1; //Step past valid line end - //Here tp points beyond the line of the processed string, so we're done + tp += 1; // Step an extra pos for CR+LF + tp += 1; // Step past valid line end + // Here tp points beyond the line of the processed string, so we're done ret = length; exit: - *LANG_p_p = tp; //return new LANG file position - *id_p_p = ip; //return found index - *value_p_p = vp; //return found string value - return ret; //return control to caller + *LANG_p_p = tp; // return new LANG file position + *id_p_p = ip; // return found index + *value_p_p = vp; // return found string value + return ret; // return control to caller } -//Ends get_LANG_string +// Ends get_LANG_string //--------------------------------------------------------------------------- void Init_Default_Language(void) { memcpy(Lang_String, Lang_Default, sizeof(Lang_String)); } -//Ends Init_Default_Language +// Ends Init_Default_Language //--------------------------------------------------------------------------- void Load_External_Language(void) { @@ -182,24 +182,24 @@ void Load_External_Language(void) int lang_size = 0; int fd; - if (External_Lang_Buffer != NULL) { //if an external buffer was allocated before - free(External_Lang_Buffer); //release that buffer before the new attempt + if (External_Lang_Buffer != NULL) { // if an external buffer was allocated before + free(External_Lang_Buffer); // release that buffer before the new attempt External_Lang_Buffer = NULL; } Language *Lang = Lang_Default; memcpy(Lang_String, Lang, sizeof(Lang_String)); - if (strlen(setting->lang_file) != 0) { //if language file string set + if (strlen(setting->lang_file) != 0) { // if language file string set error_id = -2; genFixPath(setting->lang_file, filePath); fd = genOpen(filePath, O_RDONLY); - if (fd >= 0) { //if file opened OK + if (fd >= 0) { // if file opened OK int file_size = genLseek(fd, 0, SEEK_END); error_id = -3; - if (file_size > 0) { //if file size OK + if (file_size > 0) { // if file size OK error_id = -4; file_bp = (u8 *)malloc(file_size + 1); if (file_bp == NULL) @@ -209,43 +209,43 @@ void Load_External_Language(void) genLseek(fd, 0, SEEK_SET); if (genRead(fd, file_bp, file_size) != file_size) goto release_1; - file_bp[file_size] = '\0'; //enforce termination at buffer end + file_bp[file_size] = '\0'; // enforce termination at buffer end error_id = -6; file_tp = file_bp; while (1) { oldf_tp = file_tp; test = get_LANG_string(&file_tp, &id_p, &value_p); - if (test == -1) //if EOF reached without other error - break; //break from the loop normally - if (test < 0) //At any fatal error result - goto release_1; //go release file buffer - index = atoi(id_p); //get the string index - if (index >= LANG_COUNT) //At any fatal error result - goto release_1; //go release file buffer - lang_size += test + 1; //Include terminator space for total size + if (test == -1) // if EOF reached without other error + break; // break from the loop normally + if (test < 0) // At any fatal error result + goto release_1; // go release file buffer + index = atoi(id_p); // get the string index + if (index >= LANG_COUNT) // At any fatal error result + goto release_1; // go release file buffer + lang_size += test + 1; // Include terminator space for total size } - //Here lang_size is the space needed for real language buffer, + // Here lang_size is the space needed for real language buffer, error_id = -7; - lang_bp = (u8 *)malloc(lang_size + 1); //allocate real language buffer + lang_bp = (u8 *)malloc(lang_size + 1); // allocate real language buffer if (lang_bp == NULL) goto release_1; - //We're ready to read language strings, but must first init all pointers - //to use default strings, for any indexes left undefined by the file + // We're ready to read language strings, but must first init all pointers + // to use default strings, for any indexes left undefined by the file memcpy(Lang_Extern, Lang, sizeof(Lang_Extern)); file_tp = file_bp; lang_tp = lang_bp; while ((test = get_LANG_string(&file_tp, &id_p, &value_p)) >= 0) { - index = atoi(id_p); //get the string index - Lang_Extern[index].String = lang_tp; //save pointer to this string base - strncpy(lang_tp, value_p, test); //transfer the string - lang_tp[test] = '\0'; //transfer a terminator - lang_tp += test + 1; //move dest pointer past this string + index = atoi(id_p); // get the string index + Lang_Extern[index].String = lang_tp; // save pointer to this string base + strncpy(lang_tp, value_p, test); // transfer the string + lang_tp[test] = '\0'; // transfer a terminator + lang_tp += test + 1; // move dest pointer past this string } - External_Lang_Buffer = (Language *)lang_bp; //Save base pointer for releases + External_Lang_Buffer = (Language *)lang_bp; // Save base pointer for releases Lang = Lang_Extern; error_id = 0; release_1: @@ -265,13 +265,13 @@ void Load_External_Language(void) "%n", error_id, test, index, &stp); pos += stp; - if (error_id == -2) { //if file open failure + if (error_id == -2) { // if file open failure sprintf(tmp_s + pos, "This was a failure to open the file:\n" "\"%s\"\n", filePath); } - if (error_id == -6) { //if parsing error + if (error_id == -6) { // if parsing error strncpy(t1_s, oldf_tp, 100); t1_s[100] = '\0'; strncpy(t2_s, file_tp, 100); @@ -293,7 +293,7 @@ void Load_External_Language(void) char *tmp; if (strlen(setting->Misc) > 0) { - for (i = 0; i < 16; i++) { //Loop to rename the ELF paths with new language for launch keys + for (i = 0; i < 16; i++) { // Loop to rename the ELF paths with new language for launch keys if ((i < 12) || (setting->LK_Flag[i] != 0)) { if (!strncmp(setting->LK_Path[i], setting->Misc, strlen(setting->Misc))) { tmp = strrchr(setting->LK_Path[i], '/'); @@ -358,7 +358,7 @@ void Load_External_Language(void) sprintf(setting->Misc_Show_Build_Info, "%s/%s", LNG(MISC), LNG(Build_Info)); sprintf(setting->Misc_OSDSYS, "%s/%s", LNG(MISC), LNG(OSDSYS)); } -//Ends Load_External_Language +// Ends Load_External_Language //--------------------------------------------------------------------------- -//End of file: lang.c +// End of file: lang.c //--------------------------------------------------------------------------- diff --git a/src/main.c b/src/main.c index f7b9069e..29e28feb 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ //--------------------------------------------------------------------------- -//File name: main.c +// File name: main.c //--------------------------------------------------------------------------- #include "launchelf.h" #ifdef SMB @@ -8,10 +8,10 @@ #endif #define IMPORT_BIN2C(_n) \ - extern u8 _n[]; \ - extern int size_##_n + extern u8 _n[]; \ + extern int size_##_n -//IRX for togleable features +// IRX for togleable features #ifdef ETH IMPORT_BIN2C(ps2ip_irx); IMPORT_BIN2C(ps2smap_irx); @@ -123,11 +123,11 @@ char ip[16] = "192.168.0.10"; char netmask[16] = "255.255.255.0"; char gw[16] = "192.168.0.1"; -char netConfig[IPCONF_MAX_LEN + 64]; //Adjust size as needed +char netConfig[IPCONF_MAX_LEN + 64]; // Adjust size as needed -//State of module collections +// State of module collections static u8 have_HDD_modules = 0; -//State of Uncheckable Modules (invalid header) +// State of Uncheckable Modules (invalid header) static u8 have_cdvd = 0; static u8 have_usbd = 0; #ifdef DS34 @@ -144,7 +144,7 @@ static u8 have_ps2netfs = 0; static u8 have_ps2ftpd = 0; static u8 have_ps2kbd = 0; static u8 have_hdl_info = 0; -//State of Checkable Modules (valid header) +// State of Checkable Modules (valid header) static u8 have_poweroff = 0; static u8 have_ps2dev9 = 0; static u8 have_ps2atad = 0; @@ -155,7 +155,7 @@ static u8 have_vmc_fs = 0; #ifdef XFROM static u8 have_Flash_modules = 0; #endif -//State of whether DEV9 was successfully loaded or not. +// State of whether DEV9 was successfully loaded or not. static u8 ps2dev9_loaded = 0; u8 console_is_PSX = 0; @@ -164,11 +164,11 @@ static u8 have_DVRP_HDD_modules = 0; static u8 have_dvrdrv = 0; static u8 have_dvrfile = 0; #endif -//State of whether the UI has been initialized. -//Use this to determine whether code that loads a device's driver(s) can print onto the screen. +// State of whether the UI has been initialized. +// Use this to determine whether code that loads a device's driver(s) can print onto the screen. static u8 is_early_init = 1; -static int menu_LK[SETTING_LK_BTN_COUNT]; //holds RunElf index for each valid main menu entry +static int menu_LK[SETTING_LK_BTN_COUNT]; // holds RunElf index for each valid main menu entry static u8 done_setupPowerOff = 0; static u8 ps2kbd_opened = 0; @@ -177,24 +177,24 @@ static int boot_argc; static char *boot_argv[8]; static char boot_path[MAX_PATH]; -//Variables for SYSTEM.CNF processing +// Variables for SYSTEM.CNF processing int BootDiscType = 0; char SystemCnf_BOOT[MAX_PATH]; char SystemCnf_BOOT2[MAX_PATH]; -char SystemCnf_VER[10]; //Arbitrary. Real value should always be shorter -char SystemCnf_VMODE[10]; //Arbitrary, same deal. As yet unused +char SystemCnf_VER[10]; // Arbitrary. Real value should always be shorter +char SystemCnf_VMODE[10]; // Arbitrary, same deal. As yet unused char default_ESR_path[] = "mc:/BOOT/ESR.ELF"; char default_OSDSYS_path[30]; char default_OSDSYS_path2[30]; static unsigned short int ROMVersion; -char ROMVER_data[16]; //16 byte file read from rom0:ROMVER at init -char rough_region; //E==Europe, A==US, I==Japan, H==Asia, C==China +char ROMVER_data[16]; // 16 byte file read from rom0:ROMVER at init +char rough_region; // E==Europe, A==US, I==Japan, H==Asia, C==China -int cdmode; //Last detected disc type -int old_cdmode; //used for disc change detection -int uLE_cdmode; //used for smart disc detection +int cdmode; // Last detected disc type +int old_cdmode; // used for disc change detection +int uLE_cdmode; // used for smart disc detection #define SCECdESRDVD_0 0x15 // ESR-patched DVD, as seen without ESR driver active #define SCECdESRDVD_1 0x16 // ESR-patched DVD, as seen with ESR driver active @@ -222,10 +222,10 @@ DiscType DiscTypes[] = { {SCECdCDDA, "Audio CD"}, {SCECdDVDV, "Video DVD"}, {SCECdIllegalMedia, "Unsupported"}, - {0x00, ""} //end of list -}; //ends DiscTypes array + {0x00, ""} // end of list +}; // ends DiscTypes array -//Static function declarations +// Static function declarations static int PrintRow(int row_f, char *text_p); static int PrintPos(int row_f, int column, char *text_p, int COLORID); static void Show_About_uLE(void); @@ -270,9 +270,9 @@ static void Execute(char *pathin); static void Reset(void); static void InitializeBootExecPath(); //--------------------------------------------------------------------------- -//executable code +// executable code //--------------------------------------------------------------------------- -//Function to print a text row to the 'gs' screen +// Function to print a text row to the 'gs' screen //------------------------------ static int PrintRow(int row_f, char *text_p) { @@ -287,9 +287,9 @@ static int PrintRow(int row_f, char *text_p) return row; } //------------------------------ -//endfunc PrintRow +// endfunc PrintRow //--------------------------------------------------------------------------- -//Function to print a text row with text positioning +// Function to print a text row with text positioning //------------------------------ static int PrintPos(int row_f, int column, char *text_p, int COLORID) { @@ -304,9 +304,9 @@ static int PrintPos(int row_f, int column, char *text_p, int COLORID) return row; } //------------------------------ -//endfunc PrintPos +// endfunc PrintPos //--------------------------------------------------------------------------- -//Function to show a screen with program credits ("About uLE") +// Function to show a screen with program credits ("About uLE") //------------------------------ static void Show_About_uLE(void) { @@ -314,10 +314,10 @@ static void Show_About_uLE(void) int event, post_event = 0; int hpos = 16; - event = 1; //event = initial entry + event = 1; // event = initial entry //----- Start of event loop ----- while (1) { - //Pad response section + // Pad response section waitAnyPadReady(); if (readpad() && new_pad) { event |= 2; @@ -328,8 +328,8 @@ static void Show_About_uLE(void) break; } - //Display section - if (event || post_event) { //NB: We need to update two frame buffers per event + // Display section + if (event || post_event) { // NB: We need to update two frame buffers per event clrScr(setting->color[COLOR_BACKGR]); sprintf(TextRow, "About wLaunchELF %s %s", ULE_VERSION, ULE_VERDATE); PrintPos(03, hpos, TextRow, COLOR_SELECT); @@ -353,12 +353,12 @@ static void Show_About_uLE(void) PrintPos(-1, hpos, "Mod Release site:", COLOR_SELECT); PrintPos(-1, hpos, " github.com/israpps/wLaunchELF_ISR/releases", COLOR_TEXT); PrintPos(-1, hpos, "Ancestral project: LaunchELF v3.41 by Mirakichi", COLOR_TEXT); - //PrintPos(-1, hpos, "Created by: Mirakichi"); - } //ends if(event||post_event) - drawScr();// https://github.com/israpps/wLaunchELF_ISR/tree/41e43b3-mod + // PrintPos(-1, hpos, "Created by: Mirakichi"); + } // ends if(event||post_event) + drawScr(); // https://github.com/israpps/wLaunchELF_ISR/tree/41e43b3-mod post_event = event; event = 0; - } //ends while + } // ends while //----- End of event loop ----- } @@ -368,10 +368,10 @@ static void Show_build_info(void) int event, post_event = 0; int hpos = 16; - event = 1; //event = initial entry + event = 1; // event = initial entry //----- Start of event loop ----- while (1) { - //Pad response section + // Pad response section waitAnyPadReady(); if (readpad() && new_pad) { event |= 2; @@ -382,99 +382,105 @@ static void Show_build_info(void) break; } - //Display section - if (event || post_event) { //NB: We need to update two frame buffers per event + // Display section + if (event || post_event) { // NB: We need to update two frame buffers per event clrScr(setting->color[COLOR_BACKGR]); sprintf(TextRow, " wLaunchELF %s (%s)", ULE_VERSION, GIT_HASH); PrintPos(03, hpos, TextRow, COLOR_TEXT); PrintPos(-1, hpos, "Build features:", COLOR_SELECT); - - PrintPos(-1, hpos, + + PrintPos(-1, hpos, #ifdef SMB -" SMB:1" + " SMB:1" #else -" SMB:0" + " SMB:0" #endif #ifdef ETH -" ETH:1" + " ETH:1" #else -" ETH:0" -#endif -, COLOR_TEXT); - PrintPos(-1, hpos, + " ETH:0" +#endif + , + COLOR_TEXT); + PrintPos(-1, hpos, #ifdef XFROM -" XFROM=1" + " XFROM=1" #else -" XFROM=0" + " XFROM=0" #endif #ifdef DVRP -" DVRP_HDD=1" + " DVRP_HDD=1" #else -" DVRP_HDD=0" + " DVRP_HDD=0" #endif -, COLOR_TEXT); + , + COLOR_TEXT); - PrintPos(-1, hpos, + PrintPos(-1, hpos, #ifdef EXFAT -" EXFAT=1" + " EXFAT=1" #else -" EXFAT=0" + " EXFAT=0" #endif #ifdef DS34 -" DS34=1" + " DS34=1" #else -" DS34=0" + " DS34=0" #endif -, COLOR_TEXT); - PrintPos(-1, hpos, + , + COLOR_TEXT); + PrintPos(-1, hpos, #ifdef MX4SIO -" MX4SIO=1" + " MX4SIO=1" #else -" MX4SIO=0" + " MX4SIO=0" #endif -, COLOR_TEXT); + , + COLOR_TEXT); #if defined(UDPTTY) || defined(SIO_DEBUG) || defined(TTY2SIOR) || defined(NO_IOP_RESET) PrintPos(-1, hpos, "Debug Features:", COLOR_SELECT); - PrintPos(-1, hpos, + PrintPos(-1, hpos, #ifdef NO_IOP_RESET -" IOP_RESET=0" + " IOP_RESET=0" #else -" IOP_RESET=1" + " IOP_RESET=1" #endif #ifdef UDPTTY -" UDPTTY=1" + " UDPTTY=1" #else -" UDPTTY=0" + " UDPTTY=0" #endif -, COLOR_TEXT); - PrintPos(-1, hpos, + , + COLOR_TEXT); + PrintPos(-1, hpos, #ifdef SIO_DEBUG -" SIO_DEBUG=1" + " SIO_DEBUG=1" #else -" SIO_DEBUG=0" + " SIO_DEBUG=0" #endif #ifdef TTY2SIOR -" TTY2SIOR=1" + " TTY2SIOR=1" #else -" TTY2SIOR=0" + " TTY2SIOR=0" #endif -, COLOR_TEXT); + , + COLOR_TEXT); #endif PrintPos(-1, hpos, "Mod Release site:", COLOR_TEXT); PrintPos(-1, hpos, " github.com/israpps/wLaunchELF_ISR/releases", COLOR_TEXT); - } //ends if(event||post_event) - drawScr();// https://github.com/israpps/wLaunchELF_ISR/tree/41e43b3-mod + } // ends if(event||post_event) + drawScr(); // https://github.com/israpps/wLaunchELF_ISR/tree/41e43b3-mod post_event = event; event = 0; - } //ends while + } // ends while //----- End of event loop ----- } //------------------------------ -//endfunc Show_About_uLE +// endfunc Show_About_uLE //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // Parse network configuration from IPCONFIG.DAT @@ -496,13 +502,13 @@ static void getIpConfig(void) if (fd >= 0) { bzero(buf, IPCONF_MAX_LEN); - len = genRead(fd, buf, IPCONF_MAX_LEN - 1); //Save a byte for termination + len = genRead(fd, buf, IPCONF_MAX_LEN - 1); // Save a byte for termination genClose(fd); } if ((fd >= 0) && (len > 0)) { - buf[len] = '\0'; //Ensure string termination, regardless of file content - for (i = 0; ((c = buf[i]) != '\0'); i++) //Clear out spaces and any CR/LF + buf[len] = '\0'; // Ensure string termination, regardless of file content + for (i = 0; ((c = buf[i]) != '\0'); i++) // Clear out spaces and any CR/LF if ((c == ' ') || (c == '\r') || (c == '\n')) buf[i] = '\0'; strncpy(ip, buf, 15); @@ -523,7 +529,7 @@ static void getIpConfig(void) sprintf(netConfig, "%s: %-15s %-15s %-15s", LNG(Net_Config), ip, netmask, gw); } //------------------------------ -//endfunc getIpConfig +// endfunc getIpConfig //--------------------------------------------------------------------------- static void setLaunchKeys(void) { @@ -535,7 +541,7 @@ static void setLaunchKeys(void) strcpy(setting->LK_Path[SETTING_LK_RIGHT], setting->Misc_Load_CNFnext); } //------------------------------ -//endfunc setLaunchKeys() +// endfunc setLaunchKeys() //--------------------------------------------------------------------------- static int drawMainScreen(void) { @@ -567,7 +573,7 @@ static int drawMainScreen(void) } for (i = 0; i < SETTING_LK_BTN_COUNT; i++) { if ((setting->LK_Path[i][0]) && ((i <= SETTING_LK_SELECT) || (maxCNF > 1) || setting->LK_Flag[i])) { - menu_LK[nElfs] = i; //memorize RunElf index for this menu entry + menu_LK[nElfs] = i; // memorize RunElf index for this menu entry switch (i) { case SETTING_LK_AUTO: strcpy(c, "Default: "); @@ -618,23 +624,23 @@ static int drawMainScreen(void) case SETTING_LK_RIGHT: sprintf(c, "%s: ", LNG(RIGHT)); break; - } //ends switch - if (setting->Show_Titles) //Show Launch Titles ? + } // ends switch + if (setting->Show_Titles) // Show Launch Titles ? strcpy(f, setting->LK_Title[i]); else f[0] = '\0'; - if (!f[0]) { //No title present, or allowed ? - if (setting->Hide_Paths) { //Hide full path ? + if (!f[0]) { // No title present, or allowed ? + if (setting->Hide_Paths) { // Hide full path ? if ((p = strrchr(setting->LK_Path[i], '/'))) // found delimiter ? strcpy(f, p + 1); else // No delimiter ! strcpy(f, setting->LK_Path[i]); if ((p = strrchr(f, '.'))) *p = 0; - } else { //Show full path ! + } else { // Show full path ! strcpy(f, setting->LK_Path[i]); } - } //ends clause for No title + } // ends clause for No title if (nElfs++ == selected && mode == DPAD) color = setting->color[COLOR_SELECT]; else @@ -660,8 +666,8 @@ static int drawMainScreen(void) printXY(c, x + (len > 9 ? (len - 9) * FONT_WIDTH : 0), y, color, TRUE, 0); printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH), y, color, TRUE, 0); y += FONT_HEIGHT; - } //ends clause for defined LK_Path[i] valid for menu - } //ends for + } // ends clause for defined LK_Path[i] valid for menu + } // ends for if (mode == BUTTON) sprintf(c, "%s!", LNG(PUSH_ANY_BUTTON_or_DPAD)); @@ -683,7 +689,7 @@ static int drawMainScreen(void) return nElfs; } //------------------------------ -//endfunc drawMainScreen +// endfunc drawMainScreen //--------------------------------------------------------------------------- static int drawMainScreen2(int TV_mode) { @@ -735,23 +741,23 @@ static int drawMainScreen2(int TV_mode) for (i = 0; i < SETTING_LK_BTN_COUNT; i++) { if ((setting->LK_Path[i][0]) && ((i <= SETTING_LK_SELECT) || (maxCNF > 1) || setting->LK_Flag[i])) { - menu_LK[nElfs] = i; //memorize RunElf index for this menu entry - if (setting->Show_Titles) //Show Launch Titles ? + menu_LK[nElfs] = i; // memorize RunElf index for this menu entry + if (setting->Show_Titles) // Show Launch Titles ? strcpy(f, setting->LK_Title[i]); else f[0] = '\0'; - if (!f[0]) { //No title present, or allowed ? - if (setting->Hide_Paths) { //Hide full path ? + if (!f[0]) { // No title present, or allowed ? + if (setting->Hide_Paths) { // Hide full path ? if ((p = strrchr(setting->LK_Path[i], '/'))) // found delimiter ? strcpy(f, p + 1); else // No delimiter ! strcpy(f, setting->LK_Path[i]); if ((p = strrchr(f, '.'))) *p = 0; - } else { //Show full path ! + } else { // Show full path ! strcpy(f, setting->LK_Path[i]); } - } //ends clause for No title + } // ends clause for No title if (setting->LK_Path[i][0] && nElfs++ == selected && mode == DPAD) color = setting->color[COLOR_SELECT]; else @@ -769,21 +775,21 @@ static int drawMainScreen2(int TV_mode) printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + xo_config, y, color, TRUE, 0); else printXY(f, x + (len > 9 ? len * FONT_WIDTH : 9 * FONT_WIDTH) + 10, y, color, TRUE, 0); - } //ends clause for defined LK_Path[i] valid for menu + } // ends clause for defined LK_Path[i] valid for menu y += yo_step; if (i == SETTING_LK_AUTO) y += yo_first; else if (i == SETTING_LK_START) y += yo_config; - } //ends for + } // ends for - c[0] = '\0'; //dummy tooltip string (Tooltip unused for GUI menu) + c[0] = '\0'; // dummy tooltip string (Tooltip unused for GUI menu) setScrTmp(mainMsg, c); return nElfs; } //------------------------------ -//endfunc drawMainScreen2 +// endfunc drawMainScreen2 //--------------------------------------------------------------------------- static void delay(int count) { @@ -796,7 +802,7 @@ static void delay(int count) } } //------------------------------ -//endfunc delay +// endfunc delay //--------------------------------------------------------------------------- static void initsbv_patches(void) { @@ -805,7 +811,7 @@ static void initsbv_patches(void) sbv_patch_disable_prefix_check(); } //------------------------------ -//endfunc initsbv_patches +// endfunc initsbv_patches //--------------------------------------------------------------------------- static void load_ps2dev9(void) { @@ -814,12 +820,12 @@ static void load_ps2dev9(void) if (!have_ps2dev9) { ID = SifExecModuleBuffer(ps2dev9_irx, size_ps2dev9_irx, 0, NULL, &rcode); DPRINTF(" [DEV9.IRX]: ID=%d, ret=%d\n", ID, rcode); - ps2dev9_loaded = (ID >= 0 && rcode == 0); //DEV9.IRX must have successfully loaded and returned RESIDENT END. + ps2dev9_loaded = (ID >= 0 && rcode == 0); // DEV9.IRX must have successfully loaded and returned RESIDENT END. have_ps2dev9 = 1; } } //------------------------------ -//endfunc load_ps2dev9 +// endfunc load_ps2dev9 //--------------------------------------------------------------------------- #ifdef ETH static void load_ps2ip(void) @@ -834,14 +840,14 @@ static void load_ps2ip(void) } if (!have_ps2smap) { ID = SifExecModuleBuffer(ps2smap_irx, size_ps2smap_irx, - if_conf_len, &if_conf[0], &ret); + if_conf_len, &if_conf[0], &ret); DPRINTF(" [SMAP.IRX]: ID=%d, ret=%d\n", ID, ret); have_ps2smap = 1; } } #endif //------------------------------ -//endfunc load_ps2ip +// endfunc load_ps2ip //--------------------------------------------------------------------------- static void load_ps2atad(void) { @@ -883,19 +889,19 @@ static void load_ps2atad(void) } } //------------------------------ -//endfunc load_ps2atad +// endfunc load_ps2atad //--------------------------------------------------------------------------- #ifdef XFROM static void load_pflash(void) { int ID; ID = SifLoadModule("rom0:PFLASH", 0, NULL); - DPRINTF(" [rom0:PFLASH]: ID=%d\n", ID); + DPRINTF(" [rom0:PFLASH]: ID=%d\n", ID); ID = SifLoadModule("rom0:PXFROMMAN", 0, NULL); - DPRINTF(" [rom0:PXFROMMAN]: ID=%d\n", ID); + DPRINTF(" [rom0:PXFROMMAN]: ID=%d\n", ID); } //------------------------------ -//endfunc load_pflash +// endfunc load_pflash //--------------------------------------------------------------------------- #endif #ifdef ETH @@ -903,7 +909,7 @@ void load_ps2host(void) { int ret, ID; - setupPowerOff(); //resolves the stall out when opening host: from LaunchELF's FileBrowser + setupPowerOff(); // resolves the stall out when opening host: from LaunchELF's FileBrowser load_ps2ip(); if (!have_ps2host) { ID = SifExecModuleBuffer(ps2host_irx, size_ps2host_irx, 0, NULL, &ret); @@ -913,14 +919,14 @@ void load_ps2host(void) } #endif //------------------------------ -//endfunc load_ps2host +// endfunc load_ps2host //--------------------------------------------------------------------------- #ifdef SMB static void load_smbman(void) { int ret, ID; - setupPowerOff(); //resolves stall out when opening smb: FileBrowser + setupPowerOff(); // resolves stall out when opening smb: FileBrowser load_ps2ip(); if (!have_smbman) { ID = SifExecModuleBuffer(smbman_irx, size_smbman_irx, 0, NULL, &ret); @@ -929,7 +935,7 @@ static void load_smbman(void) } } //------------------------------ -//endfunc load_smbman +// endfunc load_smbman //--------------------------------------------------------------------------- #include "SMB_test.c" #endif @@ -939,14 +945,14 @@ static void load_ps2dvr(void) int ret, ID; load_ps2atad(); - if (!is_early_init) //Do not draw any text before the UI is initialized. + if (!is_early_init) // Do not draw any text before the UI is initialized. drawMsg("Loading dvrdrv"); if (!have_dvrdrv) { ID = SifExecModuleBuffer(dvrdrv_irx, size_dvrdrv_irx, 0, NULL, &ret); DPRINTF(" [DVRDRV.IRX]: ID=%d, ret=%d\n", ID, ret); have_dvrdrv = 1; } - if (!is_early_init) //Do not draw any text before the UI is initialized. + if (!is_early_init) // Do not draw any text before the UI is initialized. drawMsg("Loading dvrfile"); if (!have_dvrfile) { ID = SifExecModuleBuffer(dvrfile_irx, size_dvrfile_irx, 0, NULL, &ret); @@ -955,12 +961,12 @@ static void load_ps2dvr(void) } } //------------------------------ -//endfunc load_ps2dvr +// endfunc load_ps2dvr //--------------------------------------------------------------------------- #endif //--------------------------------------------------------------------------- -//Function to show a screen with debugging info +// Function to show a screen with debugging info //------------------------------ static void ShowDebugInfo(void) { @@ -973,10 +979,10 @@ static void ShowDebugInfo(void) loadSMBCNF("mc0:/SYS-CONF/SMB.CNF"); smbCurrentServer = 0; #endif - event = 1; //event = initial entry + event = 1; // event = initial entry //----- Start of event loop ----- while (1) { - //Pad response section + // Pad response section waitAnyPadReady(); if (readpad() && new_pad) { event |= 2; @@ -1006,8 +1012,8 @@ static void ShowDebugInfo(void) } } - //Display section - if (event || post_event) { //NB: We need to update two frame buffers per event + // Display section + if (event || post_event) { // NB: We need to update two frame buffers per event clrScr(setting->color[COLOR_BACKGR]); PrintRow(0, "Debug Info Screen:"); sprintf(TextRow, "rom0:ROMVER == \"%s\"", ROMVER_data); @@ -1018,11 +1024,10 @@ static void ShowDebugInfo(void) sprintf(TextRow, "argv[%d] == \"%s\"", i, boot_argv[i]); PrintRow(-1, TextRow); } - sprintf(TextRow, "Main System Update KELF == \"%s\"", (console_is_PSX) ? "BIEXEC-SYSTEM/xosdmain.elf" : (strchr(default_OSDSYS_path2,'/')+ 1)); + sprintf(TextRow, "Main System Update KELF == \"%s\"", (console_is_PSX) ? "BIEXEC-SYSTEM/xosdmain.elf" : (strchr(default_OSDSYS_path2, '/') + 1)); PrintRow(-1, TextRow); - if ((ROMVersion < 0x230) && (ROMVersion > 0x130)) - { - sprintf(TextRow, "Specific System Update KELF == \"B%cEXEC-SYSTEM/osd%03x.elf\"", rough_region, (ROMVersion+10)&~0x0F); + if ((ROMVersion < 0x230) && (ROMVersion > 0x130)) { + sprintf(TextRow, "Specific System Update KELF == \"B%cEXEC-SYSTEM/osd%03x.elf\"", rough_region, (ROMVersion + 10) & ~0x0F); PrintRow(-1, TextRow); } sprintf(TextRow, "boot_path == \"%s\"", boot_path); @@ -1058,15 +1063,15 @@ static void ShowDebugInfo(void) "3 Forget Logon"); PrintRow(-1, TextRow); #endif - } //ends if(event||post_event) + } // ends if(event||post_event) drawScr(); post_event = event; event = 0; - } //ends while + } // ends while //----- End of event loop ----- } //------------------------------ -//endfunc ShowDebugInfo +// endfunc ShowDebugInfo //--------------------------------------------------------------------------- void load_vmc_fs(void) { @@ -1079,7 +1084,7 @@ void load_vmc_fs(void) } } //------------------------------ -//endfunc load_vmc_fs +// endfunc load_vmc_fs //--------------------------------------------------------------------------- #ifdef ETH static void load_ps2ftpd(void) @@ -1100,7 +1105,7 @@ static void load_ps2ftpd(void) } #endif //------------------------------ -//endfunc load_ps2ftpd +// endfunc load_ps2ftpd //--------------------------------------------------------------------------- #ifdef ETH static void load_ps2netfs(void) @@ -1116,7 +1121,7 @@ static void load_ps2netfs(void) } #endif //------------------------------ -//endfunc load_ps2netfs +// endfunc load_ps2netfs //--------------------------------------------------------------------------- static void loadBasicModules(void) { @@ -1127,7 +1132,7 @@ static void loadBasicModules(void) id = SifExecModuleBuffer(filexio_irx, size_filexio_irx, 0, NULL, &ret); DPRINTF(" [FILEXIO.IRX]: id=%d ret=%d\n", id, ret); - id = SifExecModuleBuffer(allowdvdv_irx, size_allowdvdv_irx, 0, NULL, &ret); //unlocks cdvd for reading on psx dvr + id = SifExecModuleBuffer(allowdvdv_irx, size_allowdvdv_irx, 0, NULL, &ret); // unlocks cdvd for reading on psx dvr DPRINTF(" [ALLOWDVD.IRX]: id=%d ret=%d\n", id, ret); #ifdef HOMEBREW_SIO2MAN id = SifExecModuleBuffer(sio2man_irx, size_sio2man_irx, 0, NULL, &ret); @@ -1152,14 +1157,14 @@ static void loadBasicModules(void) DPRINTF("Hello from EE SIO!\n"); #endif - id = SifExecModuleBuffer(mcman_irx, size_mcman_irx, 0, NULL, &ret); //Home + id = SifExecModuleBuffer(mcman_irx, size_mcman_irx, 0, NULL, &ret); // Home DPRINTF(" [MCMAN.IRX]: id=%d ret=%d\n", id, ret); - //SifLoadModule("rom0:MCMAN", 0, NULL); //Sony - id = SifExecModuleBuffer(mcserv_irx, size_mcserv_irx, 0, NULL, &ret); //Home + // SifLoadModule("rom0:MCMAN", 0, NULL); //Sony + id = SifExecModuleBuffer(mcserv_irx, size_mcserv_irx, 0, NULL, &ret); // Home DPRINTF(" [MCSERV.IRX]: id=%d ret=%d\n", id, ret); - //SifLoadModule("rom0:MCSERV", 0, NULL); //Sony + // SifLoadModule("rom0:MCSERV", 0, NULL); //Sony #ifdef HOMEBREW_SIO2MAN - id = SifExecModuleBuffer(padman_irx, size_padman_irx, 0, NULL, &ret); //Home + id = SifExecModuleBuffer(padman_irx, size_padman_irx, 0, NULL, &ret); // Home DPRINTF(" [PADMAN.IRX]: id=%d ret=%d\n", id, ret); #else id = SifLoadModule("rom0:PADMAN", 0, NULL); @@ -1167,7 +1172,7 @@ static void loadBasicModules(void) #endif } //------------------------------ -//endfunc loadBasicModules +// endfunc loadBasicModules //--------------------------------------------------------------------------- static void loadCdModules(void) { @@ -1182,9 +1187,9 @@ static void loadCdModules(void) } } //------------------------------ -//endfunc loadCdModules +// endfunc loadCdModules //--------------------------------------------------------------------------- -int uLE_cdDiscValid(void) //returns 1 if disc valid, else returns 0 +int uLE_cdDiscValid(void) // returns 1 if disc valid, else returns 0 { cdmode = sceCdGetDiskType(); @@ -1211,7 +1216,7 @@ int uLE_cdDiscValid(void) //returns 1 if disc valid, else returns 0 } } //------------------------------ -//endfunc uLE_cdDiscValid +// endfunc uLE_cdDiscValid //--------------------------------------------------------------------------- int uLE_cdStop(void) { @@ -1220,12 +1225,12 @@ int uLE_cdStop(void) old_cdmode = cdmode; test = uLE_cdDiscValid(); uLE_cdmode = cdmode; - if (test) { //if stable detection of a real disc is achieved - if ((cdmode != old_cdmode) //if this was a new detection + if (test) { // if stable detection of a real disc is achieved + if ((cdmode != old_cdmode) // if this was a new detection && ((cdmode == SCECdDVDV) || (cdmode == SCECdPS2DVD))) { test = Check_ESR_Disc(); DPRINTF("Check_ESR_Disc => %d\n", test); - if (test > 0) { //ESR Disc ? + if (test > 0) { // ESR Disc ? uLE_cdmode = (cdmode == SCECdPS2DVD) ? SCECdESRDVD_1 : SCECdESRDVD_0; } } @@ -1235,7 +1240,7 @@ int uLE_cdStop(void) return uLE_cdmode; } //------------------------------ -//endfunc uLE_cdStop +// endfunc uLE_cdStop //--------------------------------------------------------------------------- static void getExternalFilePath(const char *argPath, char *filePath) { @@ -1244,14 +1249,14 @@ static void getExternalFilePath(const char *argPath, char *filePath) pathSep = strchr(argPath, '/'); if (!strncmp(argPath, "mass", 4)) { - //Loading some module from USB mass: - //This won't be for USB drivers, as mass: must first be accessible. + // Loading some module from USB mass: + // This won't be for USB drivers, as mass: must first be accessible. strcpy(filePath, argPath); if (pathSep && (pathSep - argPath < 7) && pathSep[-1] == ':') strcpy(filePath + (pathSep - argPath), pathSep + 1); } else if (!strncmp(argPath, "hdd0:/", 6)) { - //Loading some module from HDD + // Loading some module from HDD char party[MAX_PATH]; char *p; @@ -1263,7 +1268,7 @@ static void getExternalFilePath(const char *argPath, char *filePath) mountParty(party); #ifdef DVRP } else if (!strncmp(argPath, "dvr_hdd0:/", 10)) { - //Loading some module from HDD + // Loading some module from HDD char party[MAX_PATH]; char *p; @@ -1284,7 +1289,7 @@ static void getExternalFilePath(const char *argPath, char *filePath) } } //------------------------------ -//endfunc getExternalFilePath +// endfunc getExternalFilePath //--------------------------------------------------------------------------- // loadExternalFile below will use the given path, and read the // indicated file into a buffer it allocates for that purpose. @@ -1297,7 +1302,7 @@ static void getExternalFilePath(const char *argPath, char *filePath) // though, of course, none is allocated if the file is not found. //--------------------------------------------------------------------------- static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) -{ //The first three variables are local variants similar to the arguments +{ // The first three variables are local variants similar to the arguments char filePath[MAX_PATH]; void *fileBase; int fileSize; @@ -1308,8 +1313,8 @@ static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) getExternalFilePath(argPath, filePath); - //Here 'filePath' is a valid path for file I/O operations - //Which means we can now use generic file I/O + // Here 'filePath' is a valid path for file I/O operations + // Which means we can now use generic file I/O File = fopen(filePath, "r"); if (File != NULL) { fseek(File, 0, SEEK_END); @@ -1328,7 +1333,7 @@ static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) return fileSize; } //------------------------------ -//endfunc loadExternalFile +// endfunc loadExternalFile //--------------------------------------------------------------------------- // loadExternalModule below will use the given path and attempt // to load the indicated module. If the file is not @@ -1343,7 +1348,7 @@ static int loadExternalFile(char *argPath, void **fileBaseP, int *fileSizeP) static int loadExternalModule(char *modPath, void *defBase, int defSize) { char filePath[MAX_PATH]; - int ext_OK, def_OK; //Flags success for external and default module + int ext_OK, def_OK; // Flags success for external and default module int dummy; DPRINTF("%s: looking for [%s]\n", __FUNCTION__, modPath); ext_OK = 0; @@ -1365,7 +1370,7 @@ static int loadExternalModule(char *modPath, void *defBase, int defSize) return 0; } //------------------------------ -//endfunc loadExternalModule +// endfunc loadExternalModule //--------------------------------------------------------------------------- static void loadUsbDModule(void) { @@ -1374,46 +1379,46 @@ static void loadUsbDModule(void) have_usbd = 1; } //------------------------------ -//endfunc loadUsbDModule +// endfunc loadUsbDModule //--------------------------------------------------------------------------- #ifdef DS34 static void loadDs34Modules(void) { DPRINTF("Loading DS34\n"); - if (!have_ds34) { - if (loadExternalModule("DS34USB.IRX", &ds34usb_irx, size_ds34usb_irx)) - if (loadExternalModule("DS34BT.IRX", &ds34bt_irx, size_ds34bt_irx)) - have_ds34 = 1; - } + if (!have_ds34) { + if (loadExternalModule("DS34USB.IRX", &ds34usb_irx, size_ds34usb_irx)) + if (loadExternalModule("DS34BT.IRX", &ds34bt_irx, size_ds34bt_irx)) + have_ds34 = 1; + } } //------------------------------ -//endfunc loadDs34Modules +// endfunc loadDs34Modules //--------------------------------------------------------------------------- #endif static void loadUsbModules(void) #ifdef EXFAT { - int ret, ID; - - loadUsbDModule(); - if (have_usbd && !have_usb_mass && (USB_mass_loaded = loadExternalModule(setting->usbmass_file, NULL, 0))) { - delay(3); - have_usb_mass = 1; - } else if (have_usbd && !have_usb_mass) { - ID = SifExecModuleBuffer(bdm_irx, size_bdm_irx, 0, NULL, &ret); + int ret, ID; + + loadUsbDModule(); + if (have_usbd && !have_usb_mass && (USB_mass_loaded = loadExternalModule(setting->usbmass_file, NULL, 0))) { + delay(3); + have_usb_mass = 1; + } else if (have_usbd && !have_usb_mass) { + ID = SifExecModuleBuffer(bdm_irx, size_bdm_irx, 0, NULL, &ret); DPRINTF(" [BDM.IRX] ID=%d, ret=%d\n", ID, ret); - ID = SifExecModuleBuffer(bdmfs_fatfs_irx, size_bdmfs_fatfs_irx, 0, NULL, &ret); + ID = SifExecModuleBuffer(bdmfs_fatfs_irx, size_bdmfs_fatfs_irx, 0, NULL, &ret); DPRINTF(" [BDMFS_FATFS.IRX] ID=%d, ret=%d\n", ID, ret); - ID = SifExecModuleBuffer(usbmass_bd_irx, size_usbmass_bd_irx, 0, NULL, &ret); + ID = SifExecModuleBuffer(usbmass_bd_irx, size_usbmass_bd_irx, 0, NULL, &ret); DPRINTF(" [USBMASS_BD.IRX] ID=%d, ret=%d\n", ID, ret); - delay(3); - USB_mass_loaded = 1; - have_usb_mass = 1; - } - if (USB_mass_loaded == 1) // if using the internal mass driver - USB_mass_max_drives = USB_MASS_MAX_DRIVES; // allow multiple drives - else - USB_mass_max_drives = 1; // else allow only one mass drive + delay(3); + USB_mass_loaded = 1; + have_usb_mass = 1; + } + if (USB_mass_loaded == 1) // if using the internal mass driver + USB_mass_max_drives = USB_MASS_MAX_DRIVES; // allow multiple drives + else + USB_mass_max_drives = 1; // else allow only one mass drive #ifdef DS34 loadDs34Modules(); #endif @@ -1429,10 +1434,10 @@ static void loadUsbModules(void) delay(3); have_usb_mass = 1; } - if (USB_mass_loaded == 1) //if using the internal mass driver - USB_mass_max_drives = USB_MASS_MAX_DRIVES; //allow multiple drives + if (USB_mass_loaded == 1) // if using the internal mass driver + USB_mass_max_drives = USB_MASS_MAX_DRIVES; // allow multiple drives else - USB_mass_max_drives = 1; //else allow only one mass drive + USB_mass_max_drives = 1; // else allow only one mass drive #ifdef DS34 loadDs34Modules(); @@ -1440,7 +1445,7 @@ static void loadUsbModules(void) } #endif //------------------------------ -//endfunc loadUsbModules +// endfunc loadUsbModules //--------------------------------------------------------------------------- static void loadKbdModules(void) { @@ -1449,7 +1454,7 @@ static void loadKbdModules(void) have_ps2kbd = 1; } //------------------------------ -//endfunc loadKbdModules +// endfunc loadKbdModules //--------------------------------------------------------------------------- void loadHdlInfoModule(void) { @@ -1464,7 +1469,7 @@ void loadHdlInfoModule(void) } } //------------------------------ -//endfunc loadHdlInfoModule +// endfunc loadHdlInfoModule //--------------------------------------------------------------------------- static void closeAllAndPoweroff(void) { @@ -1486,15 +1491,16 @@ static void closeAllAndPoweroff(void) poweroffShutdown(); } //------------------------------ -//endfunc closeAllAndPoweroff +// endfunc closeAllAndPoweroff //--------------------------------------------------------------------------- static void poweroffHandler(int i) { - if (!is_early_init) drawMsg(LNG(Powering_Off_Console)); + if (!is_early_init) + drawMsg(LNG(Powering_Off_Console)); closeAllAndPoweroff(); } //------------------------------ -//endfunc poweroffHandler +// endfunc poweroffHandler //--------------------------------------------------------------------------- static void setupPowerOff(void) { @@ -1513,26 +1519,26 @@ static void setupPowerOff(void) } } //------------------------------ -//endfunc setupPowerOff +// endfunc setupPowerOff //--------------------------------------------------------------------------- void loadHddModules(void) { if (!have_HDD_modules) { - if (!is_early_init) //Do not draw any text before the UI is initialized. + if (!is_early_init) // Do not draw any text before the UI is initialized. drawMsg(LNG(Loading_HDD_Modules)); setupPowerOff(); - load_ps2atad(); //also loads ps2hdd & ps2fs + load_ps2atad(); // also loads ps2hdd & ps2fs have_HDD_modules = TRUE; } } //------------------------------ -//endfunc loadHddModules +// endfunc loadHddModules //--------------------------------------------------------------------------- #ifdef XFROM void loadFlashModules(void) { if (!have_Flash_modules) { - if (!is_early_init) //Do not draw any text before the UI is initialized. + if (!is_early_init) // Do not draw any text before the UI is initialized. drawMsg(LNG(Loading_Flash_Modules)); load_ps2dev9(); setupPowerOff(); @@ -1541,23 +1547,23 @@ void loadFlashModules(void) } } //------------------------------ -//endfunc loadFlashModules +// endfunc loadFlashModules //--------------------------------------------------------------------------- #endif #ifdef DVRP void loadDVRPHddModules(void) { if (!have_DVRP_HDD_modules) { - if (!is_early_init) //Do not draw any text before the UI is initialized. + if (!is_early_init) // Do not draw any text before the UI is initialized. drawMsg(LNG(Loading_HDD_Modules)); setupPowerOff(); load_ps2dvr(); - //sceCdNoticeGameStart(0, NULL); //shouldn't this be done by the bootloader? + // sceCdNoticeGameStart(0, NULL); //shouldn't this be done by the bootloader? have_DVRP_HDD_modules = TRUE; } } //------------------------------ -//endfunc loadDVRPHddModules +// endfunc loadDVRPHddModules //--------------------------------------------------------------------------- #endif @@ -1570,7 +1576,7 @@ static void loadNetModules(void) if (!have_NetModules) { drawMsg(LNG(Loading_NetFS_and_FTP_Server_Modules)); - getIpConfig(); //RA NB: I always get that info, early in init + getIpConfig(); // RA NB: I always get that info, early in init // //But sometimes it is useful to do it again (HDD) // Also, my module checking makes some other tests redundant load_ps2netfs(); // loads ps2netfs from internal buffer @@ -1585,7 +1591,7 @@ static void loadNetModules(void) } #endif //------------------------------ -//endfunc loadNetModules +// endfunc loadNetModules //--------------------------------------------------------------------------- static void startKbd(void) { @@ -1617,9 +1623,9 @@ static void startKbd(void) } } //------------------------------ -//endfunc startKbd +// endfunc startKbd //--------------------------------------------------------------------------- -//scanSystemCnf will check for a standard variable of a SYSTEM.CNF file +// scanSystemCnf will check for a standard variable of a SYSTEM.CNF file //------------------------------ static int scanSystemCnf(char *name, char *value) { @@ -1632,13 +1638,13 @@ static int scanSystemCnf(char *name, char *value) else if (!strcmp(name, "VMODE")) strncat(SystemCnf_VMODE, value, 9); else - return 0; //when no matching variable - return 1; //when matching variable found + return 0; // when no matching variable + return 1; // when matching variable found } //------------------------------ -//endfunc scanSystemCnf +// endfunc scanSystemCnf //--------------------------------------------------------------------------- -//readSystemCnf will read standard settings from a SYSTEM.CNF file +// readSystemCnf will read standard settings from a SYSTEM.CNF file //------------------------------ static int readSystemCnf(void) { @@ -1668,7 +1674,7 @@ static int readSystemCnf(void) if (!SystemCnf_VER[0]) strcpy(SystemCnf_VER, "???"); - if (RAM_p == NULL) { //if SYSTEM.CNF was not found test for PS1 special cases + if (RAM_p == NULL) { // if SYSTEM.CNF was not found test for PS1 special cases if (exists("cdrom0:\\PSXMYST\\MYST.CCS;1")) { strcpy(SystemCnf_BOOT, "SLPS_000.24"); BootDiscType = 1; @@ -1680,15 +1686,15 @@ static int readSystemCnf(void) } } - return BootDiscType; //0==none, 1==PS1, 2==PS2 + return BootDiscType; // 0==none, 1==PS1, 2==PS2 } //------------------------------ -//endfunc readSystemCnf +// endfunc readSystemCnf //--------------------------------------------------------------------------- static void ShowFont(void) { int test_type = 0; - int test_types = 2; //Patch test_types for number of test loops + int test_types = 2; // Patch test_types for number of test loops int i, j, event, post_event = 0; char Hex[18] = "0123456789ABCDEF"; int ch_x_stp = 1 + FONT_WIDTH + 1 + LINE_THICKNESS; @@ -1702,16 +1708,16 @@ static void ShowFont(void) int px, ly, cy; u64 col_0 = setting->color[COLOR_BACKGR], col_1 = setting->color[COLOR_FRAME], col_3 = setting->color[COLOR_TEXT]; - //The next line is a patch to save font, if/when needed (needs patch in draw.c too) + // The next line is a patch to save font, if/when needed (needs patch in draw.c too) // WriteFont_C("mc0:/SYS-CONF/font_uLE.c"); - event = 1; //event = initial entry + event = 1; // event = initial entry //----- Start of event loop ----- while (1) { - //Display section - if (event || post_event) { //NB: We need to update two frame buffers per event + // Display section + if (event || post_event) { // NB: We need to update two frame buffers per event drawOpSprite(col_0, mat_x, mat_y, mat_x + mat_w - 1, mat_y + mat_h - 1); - //Here the background rectangle has been prepared + // Here the background rectangle has been prepared /* //Start of commented out section //Move this line as needed for tests //Start of gsKit test section if(test_type > 1) goto done_test; @@ -1738,47 +1744,47 @@ static void ShowFont(void) goto end_display; done_test: //End of gsKit test section -*/ //End of commented out section //Move this line as needed for tests - //Start of font display section - //Now we start to draw all vertical frame lines +*/ // End of commented out section //Move this line as needed for tests + // Start of font display section + // Now we start to draw all vertical frame lines px = mat_x; drawOpSprite(col_1, px, mat_y, px + LINE_THICKNESS - 1, mat_y + mat_h - 1); - for (j = 0; j < 17; j++) { //for each font column, plus the row_index column + for (j = 0; j < 17; j++) { // for each font column, plus the row_index column px += ch_x_stp; drawOpSprite(col_1, px, mat_y, px + LINE_THICKNESS - 1, mat_y + mat_h - 1); - } //ends for each font column, plus the row_index column - //Here all the vertical frame lines have been drawn - //Next we draw the top horizontal line + } // ends for each font column, plus the row_index column + // Here all the vertical frame lines have been drawn + // Next we draw the top horizontal line drawOpSprite(col_1, mat_x, mat_y, mat_x + mat_w - 1, mat_y + LINE_THICKNESS - 1); cy = mat_y + LINE_THICKNESS + 2; ly = mat_y; - for (i = 0; i < 17; i++) { //for each font row + for (i = 0; i < 17; i++) { // for each font row px = ch_x; - if (!i) { //if top row (which holds the column indexes) - drawChar('\\', px, cy, col_3); //Display '\' at index crosspoint - } else { //else a real font row - drawChar(Hex[i - 1], px, cy, col_3); //Display row index + if (!i) { // if top row (which holds the column indexes) + drawChar('\\', px, cy, col_3); // Display '\' at index crosspoint + } else { // else a real font row + drawChar(Hex[i - 1], px, cy, col_3); // Display row index } - for (j = 0; j < 16; j++) { //for each font column + for (j = 0; j < 16; j++) { // for each font column px += ch_x_stp; - if (!i) { //if top row (which holds the column indexes) - drawChar(Hex[j], px, cy, col_3); //Display Column index + if (!i) { // if top row (which holds the column indexes) + drawChar(Hex[j], px, cy, col_3); // Display Column index } else { - drawChar((i - 1) * 16 + j, px, cy, col_3); //Display font character + drawChar((i - 1) * 16 + j, px, cy, col_3); // Display font character } - } //ends for each font column + } // ends for each font column ly += ch_y_stp; drawOpSprite(col_1, mat_x, ly, mat_x + mat_w - 1, ly + LINE_THICKNESS - 1); cy += ch_y_stp; - } //ends for each font row - //End of font display section - } //ends if(event||post_event) - //end_display: + } // ends for each font row + // End of font display section + } // ends if(event||post_event) + // end_display: drawScr(); post_event = event; event = 0; - //Pad response section + // Pad response section waitAnyPadReady(); if (readpad() && new_pad) { event |= 2; @@ -1792,11 +1798,11 @@ static void ShowFont(void) } break; } - } //ends while + } // ends while //----- End of event loop ----- } //------------------------------ -//endfunc ShowFont +// endfunc ShowFont //--------------------------------------------------------------------------- static void Validate_CNF_Path(void) { @@ -1808,7 +1814,7 @@ static void Validate_CNF_Path(void) } } //------------------------------ -//endfunc Validate_CNF_Path +// endfunc Validate_CNF_Path //--------------------------------------------------------------------------- static void Set_CNF_Path(void) { @@ -1826,9 +1832,9 @@ static void Set_CNF_Path(void) sprintf(mainMsg + 6, "%s = \"%s\"", LNG(CNF_Path), setting->CNF_Path); } //------------------------------ -//endfunc Set_CNF_Path +// endfunc Set_CNF_Path //--------------------------------------------------------------------------- -//Reload CNF, possibly after a path change +// Reload CNF, possibly after a path change static int reloadConfig(void) { char tmp[MAX_PATH]; @@ -1867,7 +1873,7 @@ static int reloadConfig(void) return CNF_error; } //------------------------------ -//endfunc reloadConfig +// endfunc reloadConfig //--------------------------------------------------------------------------- // Config Cycle Left (--) by EP static void decConfig(void) @@ -1880,7 +1886,7 @@ static void decConfig(void) reloadConfig(); } //------------------------------ -//endfunc decConfig +// endfunc decConfig //--------------------------------------------------------------------------- // Config Cycle Right (++) by EP static void incConfig(void) @@ -1893,9 +1899,9 @@ static void incConfig(void) reloadConfig(); } //------------------------------ -//endfunc incConfig +// endfunc incConfig //--------------------------------------------------------------------------- -//exists. Tests if a file exists or not +// exists. Tests if a file exists or not //------------------------------ static int exists(char *path) { @@ -1908,9 +1914,9 @@ static int exists(char *path) return 1; } //------------------------------ -//endfunc exists +// endfunc exists //--------------------------------------------------------------------------- -//uLE_related. Tests if an uLE_related file exists or not. +// uLE_related. Tests if an uLE_related file exists or not. // // Note: please use genFixPath() for config files instead because this will not // load other device modules, even if LaunchELF actually supports the device. @@ -1941,11 +1947,11 @@ int uLE_related(char *pathout, const char *pathin) pathout[2] = '1'; if (exists(pathout)) return 1; - pathout[2] ^= 1; //switch between mc0 and mc1 + pathout[2] ^= 1; // switch between mc0 and mc1 if (exists(pathout)) return 1; - //Default to LaunchELFDir + // Default to LaunchELFDir sprintf(pathout, "%s%s", LaunchElfDir, pathin + 5); return 0; } else @@ -1954,9 +1960,9 @@ int uLE_related(char *pathout, const char *pathin) return ret; } //------------------------------ -//endfunc uLE_related +// endfunc uLE_related //--------------------------------------------------------------------------- -//CleanUp releases uLE stuff preparatory to launching some other application +// CleanUp releases uLE stuff preparatory to launching some other application //------------------------------ static void CleanUp(void) { @@ -1974,32 +1980,32 @@ static void CleanUp(void) PS2KbdClose(); #ifdef DS34 WaitSema(semRunning); - isRunning=0; - SignalSema(semRunning); + isRunning = 0; + SignalSema(semRunning); WaitSema(semFinish); ds34usb_reset(); ds34bt_reset(); #endif } //------------------------------ -//endfunc CleanUp +// endfunc CleanUp //--------------------------------------------------------------------------- -//Indicates whether the file type is supported by LaunchELF (for any action) +// Indicates whether the file type is supported by LaunchELF (for any action) //------------------------------ int IsSupportedFileType(char *path) { if (strchr(path, ':') != NULL) { if (genCmpFileExt(path, "ELF")) { return (checkELFheader(path) >= 0); - } else if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF") ) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) { + } else if ((genCmpFileExt(path, "TXT") || genCmpFileExt(path, "CHT") || genCmpFileExt(path, "CFG") || genCmpFileExt(path, "INI") || genCmpFileExt(path, "CNF")) || (genCmpFileExt(path, "JPG") || genCmpFileExt(path, "JPEG"))) { return 1; } else return 0; - } else //No ':', hence no device name in path, which means it is a special action (e.g. MISC/*). + } else // No ':', hence no device name in path, which means it is a special action (e.g. MISC/*). return 1; } //------------------------------ -//endfunc IsSupportedFileType +// endfunc IsSupportedFileType //--------------------------------------------------------------------------- // Execute. Execute an action. May be called recursively. // For any path specified, its device must be accessible. @@ -2019,10 +2025,10 @@ static void Execute(char *pathin) if (pathin[0] == 0) return; - if (!uLE_related(path, pathin)) //1==uLE_rel 0==missing, -1==other dev + if (!uLE_related(path, pathin)) // 1==uLE_rel 0==missing, -1==other dev return; -Recurse_for_ESR: //Recurse here for PS2Disc command with ESR disc +Recurse_for_ESR: // Recurse here for PS2Disc command with ESR disc pathSep = strchr(path, '/'); @@ -2046,7 +2052,7 @@ static void Execute(char *pathin) loadHddModules(); if ((t = checkELFheader(path)) <= 0) goto ELFnotFound; - //coming here means the ELF is fine + // coming here means the ELF is fine sprintf(party, "hdd0:%s", path + 6); p = strchr(party, '/'); sprintf(fullpath, "pfs0:%s", p); @@ -2057,7 +2063,7 @@ static void Execute(char *pathin) loadDVRPHddModules(); if ((t = checkELFheader(path)) <= 0) goto ELFnotFound; - //coming here means the ELF is fine + // coming here means the ELF is fine sprintf(party, "dvr_hdd0:%s", path + 10); p = strchr(party, '/'); sprintf(fullpath, "dvr_pfs0:%s", p); @@ -2075,7 +2081,7 @@ static void Execute(char *pathin) } else if (!strncmp(path, "mass", 4)) { if ((t = checkELFheader(path)) <= 0) goto ELFnotFound; - //coming here means the ELF is fine + // coming here means the ELF is fine party[0] = 0; strcpy(fullpath, path); @@ -2137,11 +2143,11 @@ static void Execute(char *pathin) drawMsg(LNG(Reading_SYSTEMCNF)); party[0] = 0; readSystemCnf(); - if (BootDiscType == 2) { //Boot a PS2 disc + if (BootDiscType == 2) { // Boot a PS2 disc strcpy(fullpath, SystemCnf_BOOT2); goto CheckELF_fullpath; } - if (BootDiscType == 1) { //Boot a PS1 disc + if (BootDiscType == 1) { // Boot a PS1 disc char *args[2] = {SystemCnf_BOOT, SystemCnf_VER}; CleanUp(); LoadExecPS2("rom0:PS1DRV", 2, args); @@ -2152,7 +2158,7 @@ static void Execute(char *pathin) if (cdmode == SCECdDVDV) { x = Check_ESR_Disc(); DPRINTF("Check_ESR_Disc => %d\n", x); - if (x > 0) { //ESR Disc, so launch ESR + if (x > 0) { // ESR Disc, so launch ESR if (setting->LK_Flag[SETTING_LK_ESR] && setting->LK_Path[SETTING_LK_ESR][0]) strcpy(path, setting->LK_Path[SETTING_LK_ESR]); else @@ -2161,7 +2167,7 @@ static void Execute(char *pathin) goto Recurse_for_ESR; } - //DVD Video Disc, so launch DVD player + // DVD Video Disc, so launch DVD player char arg0[20], arg1[20], arg2[20], arg3[40]; char *args[4] = {arg0, arg1, arg2, arg3}; char kelf_loader[40]; @@ -2179,7 +2185,7 @@ static void Execute(char *pathin) strcpy(MG_region, "ACEJMORU"); pos = strlen(arg0) - 1; - for (i = 0; i < 9; i++) { //NB: MG_region[8] is a string terminator + for (i = 0; i < 9; i++) { // NB: MG_region[8] is a string terminator arg0[pos] = MG_region[i]; tst = SifLoadModuleEncrypted(arg0 + 3, 0, NULL); if (tst >= 0) @@ -2191,9 +2197,9 @@ static void Execute(char *pathin) strcpy(&arg2[pos - 3], "ELF"); else arg2[pos - 1] = MG_region[i]; - //At this point all args are ready to use internal DVD player + // At this point all args are ready to use internal DVD player - //We must check for an updated player on MC + // We must check for an updated player on MC dvdpl_path[6] = rough_region; dvdpl_update = 0; for (i = 0; i < 2; i++) { @@ -2205,7 +2211,7 @@ static void Execute(char *pathin) } if ((tst < 0) && (dvdpl_update == 0)) - goto Fail_PS2Disc; //We must abort if no working kelf found + goto Fail_PS2Disc; // We must abort if no working kelf found if (dvdpl_update) { // Launch DVD player from memory card strcpy(arg0, "-m rom0:SIO2MAN"); @@ -2224,7 +2230,7 @@ static void Execute(char *pathin) goto Done_PS2Disc; } if (cdmode == SCECdCDDA) { - //Fail_CDDA: + // Fail_CDDA: sprintf(mainMsg, "CDDA %s", LNG(Failed)); goto Done_PS2Disc; } @@ -2263,11 +2269,11 @@ static void Execute(char *pathin) return; } else if (!stricmp(path, setting->Misc_PS2Browser)) { Exit(0); - //There has been a major change in the code for calling PS2Browser - //The method above is borrowed from PS2MP3. It's independent of ELF loader - //The method below was used earlier, but causes reset with new ELF loader - //party[0]=0; - //strcpy(fullpath,"rom0:OSDSYS"); + // There has been a major change in the code for calling PS2Browser + // The method above is borrowed from PS2MP3. It's independent of ELF loader + // The method below was used earlier, but causes reset with new ELF loader + // party[0]=0; + // strcpy(fullpath,"rom0:OSDSYS"); #ifdef ETH } else if (!stricmp(path, setting->Misc_PS2Net)) { mainMsg[0] = 0; @@ -2322,7 +2328,7 @@ static void Execute(char *pathin) } else if (!stricmp(path, setting->Misc_Load_CNF)) { reloadConfig(); return; - //Next clause is for an optional font test routine + // Next clause is for an optional font test routine } else if (!stricmp(path, setting->Misc_ShowFont)) { ShowFont(); return; @@ -2362,7 +2368,7 @@ static void Execute(char *pathin) ELFchecked: CleanUp(); RunLoaderElf(fullpath, party); - } else { //Invalid path + } else { // Invalid path t = 0; ELFnotFound: if (t == 0) @@ -2373,7 +2379,7 @@ static void Execute(char *pathin) } } //------------------------------ -//endfunc Execute +// endfunc Execute //--------------------------------------------------------------------------- // reboot IOP (original source by Hermes in BOOT.c - cogswaploader) // dlanor: but changed now, as the original was badly bugged @@ -2405,16 +2411,16 @@ static void Reset() have_Flash_modules = 0; #endif #ifdef UDPTTY -int i, d; + int i, d; load_ps2ip(); i = SifExecModuleBuffer(&udptty_irx, size_udptty_irx, 0, NULL, &d); - DPRINTF(" [UDPTTY.IRX]: id=%d, ret=%d\n", i, d); + DPRINTF(" [UDPTTY.IRX]: id=%d, ret=%d\n", i, d); #endif loadBasicModules(); loadCdModules(); fileXioInit(); - //Increase the FILEIO R/W buffer size to reduce overhead. + // Increase the FILEIO R/W buffer size to reduce overhead. fileXioSetRWBufferSize(128 * 1024); DPRINTF("Initializing mc rpc\n"); #ifdef HOMEBREW_SIO2MAN @@ -2426,7 +2432,7 @@ int i, d; // setupPad(); } //------------------------------ -//endfunc Reset +// endfunc Reset //--------------------------------------------------------------------------- int uLE_InitializeRegion(void) { @@ -2438,7 +2444,7 @@ int uLE_InitializeRegion(void) if (ROMVER_fd < 0) { memset(ROMVER_data, 0, sizeof(ROMVER_data)); rough_region = 'X'; - TVMode = TV_mode_NTSC; //NTSC is default mode for unidentified console + TVMode = TV_mode_NTSC; // NTSC is default mode for unidentified console return TVMode; } genRead(ROMVER_fd, ROMVER_data, 16); @@ -2453,7 +2459,7 @@ int uLE_InitializeRegion(void) rough_region = 'E'; break; case 'A': - case 'H': //Asia shares the same letter as USA. + case 'H': // Asia shares the same letter as USA. rough_region = 'A'; break; case 'C': @@ -2464,15 +2470,15 @@ int uLE_InitializeRegion(void) } if (ROMVER_data[4] == 'E') - TVMode = TV_mode_PAL; //PAL mode is identified by 'E' for Europe + TVMode = TV_mode_PAL; // PAL mode is identified by 'E' for Europe else - TVMode = TV_mode_NTSC; //All other cases need NTSC + TVMode = TV_mode_NTSC; // All other cases need NTSC } return TVMode; } //------------------------------ -//endfunc uLE_InitializeRegion +// endfunc uLE_InitializeRegion //--------------------------------------------------------------------------- static void InitializeBootExecPath() { @@ -2480,10 +2486,10 @@ static void InitializeBootExecPath() uLE_InitializeRegion(); char RONVER[4 + 1]; - strncpy(RONVER,ROMVER_data,4); + strncpy(RONVER, ROMVER_data, 4); RONVER[4] = '\0'; ROMVersion = strtoul(RONVER, NULL, 16); - //Handle special cases, before osdmain.elf was supported. + // Handle special cases, before osdmain.elf was supported. switch (ROMVER_data[4]) { case 'E': if (!strncmp(ROMVER_data, "0120", 4)) @@ -2505,19 +2511,18 @@ static void InitializeBootExecPath() else strcpy(file, "osdmain.elf"); break; - default: //Asia and China + default: // Asia and China strcpy(file, "osdmain.elf"); } - sprintf( default_OSDSYS_path, "mc:/B%cEXEC-SYSTEM/%s", rough_region, file); - if ( ROMVersion >= 0x230 ) - sprintf(default_OSDSYS_path2, "/Incompatible Unit (0x%03x)", (ROMVersion)&~0x0F); + sprintf(default_OSDSYS_path, "mc:/B%cEXEC-SYSTEM/%s", rough_region, file); + if (ROMVersion >= 0x230) + sprintf(default_OSDSYS_path2, "/Incompatible Unit (0x%03x)", (ROMVersion) & ~0x0F); else sprintf(default_OSDSYS_path2, "mc:/B%cEXEC-SYSTEM/%s", rough_region, file); - } //------------------------------ -//endfunc InitializeBootExecPath +// endfunc InitializeBootExecPath //--------------------------------------------------------------------------- //#ifdef SMB @@ -2542,7 +2547,7 @@ int main(int argc, char *argv[]) char RunPath[MAX_PATH]; int RunELF_index, nElfs = 0; enum BOOT_DEVICE boot = BOOT_DEV_UNKNOWN; - int CNF_error = -1; //assume error until CNF correctly loaded + int CNF_error = -1; // assume error until CNF correctly loaded int i; boot_argc = argc; @@ -2558,37 +2563,37 @@ int main(int argc, char *argv[]) boot_path[0] = 0; if ((argc > 0) && argv[0]) { - strcpy(LaunchElfDir, argv[0]); //Default LaunchElfDir to the boot path. + strcpy(LaunchElfDir, argv[0]); // Default LaunchElfDir to the boot path. strcpy(boot_path, argv[0]); if (!strncmp(argv[0], "mass", 4)) { - if (!strncmp(argv[0], "mass0:\\", 7)) { //SwapMagic boot path for usb_mass - //Transform the boot path to homebrew standards + if (!strncmp(argv[0], "mass0:\\", 7)) { // SwapMagic boot path for usb_mass + // Transform the boot path to homebrew standards LaunchElfDir[4] = ':'; strcpy(&LaunchElfDir[5], &LaunchElfDir[7]); for (i = 0; LaunchElfDir[i] != 0; i++) { if (LaunchElfDir[i] == '\\') LaunchElfDir[i] = '/'; } - } //else we booted with normal homebrew mass: drivers + } // else we booted with normal homebrew mass: drivers boot = BOOT_DEVICE_MASS; } else if (!strncmp(argv[0], "mc", 2)) boot = BOOT_DEVICE_MC; else if (!strncmp(argv[0], "cd", 2)) { boot = BOOT_DEVICE_CDVD; - strcpy(LaunchElfDir, "mc0:/SYS-CONF/"); //Default to mc0 as a writable location. + strcpy(LaunchElfDir, "mc0:/SYS-CONF/"); // Default to mc0 as a writable location. } else if (!strncmp(argv[0], "hdd", 3)) { - //Booting from the HDD requires special handling for HDD-based paths. + // Booting from the HDD requires special handling for HDD-based paths. char temp[MAX_PATH]; char *t, *p; /* Change boot_path to contain a path to the block device. - Standard HDD path format: hdd0:partition:pfs:path/to/file - However, (older) homebrew may not use this format. */ - strcpy(temp, boot_path + 5); //Skip "hdd0:" when copying. - t = strchr(temp, ':'); //Check if the separator between the block device & the path exists. + Standard HDD path format: hdd0:partition:pfs:path/to/file + However, (older) homebrew may not use this format. */ + strcpy(temp, boot_path + 5); // Skip "hdd0:" when copying. + t = strchr(temp, ':'); // Check if the separator between the block device & the path exists. if (t != NULL) { - *(t) = 0; //If it does, get the block device name. - p = strchr(t + 1, ':'); //Get the path to the file + *(t) = 0; // If it does, get the block device name. + p = strchr(t + 1, ':'); // Get the path to the file if (p != NULL) { if (p[1] == '/') sprintf(LaunchElfDir, "hdd0:/%s", temp); @@ -2602,17 +2607,17 @@ int main(int argc, char *argv[]) boot = BOOT_DEVICE_HDD; #ifdef DVRP } else if (!strncmp(argv[0], "dvr_hdd", 7)) { - //Booting from the HDD requires special handling for HDD-based paths. + // Booting from the HDD requires special handling for HDD-based paths. char temp[MAX_PATH]; char *t, *p; /* Change boot_path to contain a path to the block device. - Standard HDD path format: dvr_hdd0:partition:pfs:path/to/file - However, (older) homebrew may not use this format. */ - strcpy(temp, boot_path + 9); //Skip "dvr_hdd0:" when copying. - t = strchr(temp, ':'); //Check if the separator between the block device & the path exists. + Standard HDD path format: dvr_hdd0:partition:pfs:path/to/file + However, (older) homebrew may not use this format. */ + strcpy(temp, boot_path + 9); // Skip "dvr_hdd0:" when copying. + t = strchr(temp, ':'); // Check if the separator between the block device & the path exists. if (t != NULL) { - *(t) = 0; //If it does, get the block device name. - p = strchr(t + 1, ':'); //Get the path to the file + *(t) = 0; // If it does, get the block device name. + p = strchr(t + 1, ':'); // Get the path to the file if (p != NULL) { if (p[1] == '/') sprintf(LaunchElfDir, "dvr_hdd0:/%s", temp); @@ -2637,11 +2642,11 @@ int main(int argc, char *argv[]) p = strrchr(LaunchElfDir, ':'); if (p != NULL) *(p + 1) = 0; - //The above cuts away the ELF filename from LaunchElfDir, leaving a pure path + // The above cuts away the ELF filename from LaunchElfDir, leaving a pure path LastDir[0] = 0; - TV_mode = uLE_InitializeRegion(); //Let console region decide default TV_mode + TV_mode = uLE_InitializeRegion(); // Let console region decide default TV_mode Frame_end_y = Menu_end_y + 4; Menu_tooltip_y = Frame_end_y + LINE_THICKNESS + 2; InitializeBootExecPath(); @@ -2649,20 +2654,20 @@ int main(int argc, char *argv[]) CNF_error = loadConfig(mainMsg, strcpy(CNF, "LAUNCHELF.CNF")); #ifdef ETH if (boot == BOOT_DEVICE_HOST) { - //If booted from the host: device, bring up the host device at this point. + // If booted from the host: device, bring up the host device at this point. getIpConfig(); initHOST(); } #endif - //Last chance to look at bootup screen, so allow braking here + // Last chance to look at bootup screen, so allow braking here /* if(readpad() && (new_pad && PAD_UP)) { scr_printf("________ Boot paused. Press 'Circle' to continue.\n"); - while(1) - { if(new_pad & PAD_CIRCLE) - break; - while(!readpad()); - } + while(1) + { if(new_pad & PAD_CIRCLE) + break; + while(!readpad()); + } } */ DPRINTF("setupGS()\n"); @@ -2675,7 +2680,7 @@ int main(int argc, char *argv[]) maxCNF = setting->numCNF; swapKeys = setting->swapKeys; - //It's time to load and init drivers + // It's time to load and init drivers DPRINTF("Getting IPCONFIG\n"); getIpConfig(); DPRINTF("Loading USB modules\n"); @@ -2683,7 +2688,7 @@ int main(int argc, char *argv[]) WaitTime = Timer(); DPRINTF("setup pad\n"); - setupPad(); //Comment out this line when using early setupPad above + setupPad(); // Comment out this line when using early setupPad above DPRINTF("Starting keyboard\n"); startKbd(); WaitTime = Timer(); @@ -2706,29 +2711,29 @@ int main(int argc, char *argv[]) else sprintf(mainMsg, "%s", LNG(Loaded_Config)); - //Here nearly everything is ready for the main menu event loop - //But before we start that, we need to validate CNF_Path + // Here nearly everything is ready for the main menu event loop + // But before we start that, we need to validate CNF_Path Validate_CNF_Path(); - RunPath[0] = 0; //Nothing to run yet - cdmode = -1; //flag unchecked cdmode state - event = 1; //event = initial entry + RunPath[0] = 0; // Nothing to run yet + cdmode = -1; // flag unchecked cdmode state + event = 1; // event = initial entry DPRINTF("starting main menu event loop\n"); //----- Start of main menu event loop ----- while (1) { int DiscType_ix; - //Background event section - uLE_cdStop(); //Test disc state and if needed stop disc (updates cdmode) - if (cdmode == old_cdmode) //if disc detection did not change state + // Background event section + uLE_cdStop(); // Test disc state and if needed stop disc (updates cdmode) + if (cdmode == old_cdmode) // if disc detection did not change state goto done_discControl; - event |= 4; //event |= disc change detection + event |= 4; // event |= disc change detection if (cdmode <= 0) sprintf(mainMsg, "%s ", LNG(No_Disc)); else if (cdmode >= 1 && cdmode <= 4) sprintf(mainMsg, "%s == ", LNG(Detecting_Disc)); - else //if(cdmode>=5) + else // if(cdmode>=5) sprintf(mainMsg, "%s == ", LNG(Stop_Disc)); DiscType_ix = 0; @@ -2737,11 +2742,11 @@ int main(int argc, char *argv[]) DiscType_ix = i; sprintf(mainMsg + strlen(mainMsg), DiscTypes[DiscType_ix].name); - //Comment out the debug output below when not needed + // Comment out the debug output below when not needed /* sprintf(mainMsg+strlen(mainMsg), - " cdmode==%d uLE_cdmode==%d type_ix==%d", - cdmode, uLE_cdmode, DiscType_ix); + " cdmode==%d uLE_cdmode==%d type_ix==%d", + cdmode, uLE_cdmode, DiscType_ix); //*/ done_discControl: if (init_delay) { @@ -2755,7 +2760,7 @@ int main(int argc, char *argv[]) init_delay_start = CurrTime; } if ((init_delay / 1000) != (prev_init_delay / 1000)) - event |= 8; //event |= visible delay change + event |= 8; // event |= visible delay change } else if (timeout && !user_acted) { prev_timeout = timeout; CurrTime = Timer(); @@ -2766,27 +2771,27 @@ int main(int argc, char *argv[]) timeout_start = CurrTime; } if ((timeout / 1000) != (prev_timeout / 1000)) - event |= 8; //event |= visible timeout change + event |= 8; // event |= visible timeout change } - //Display section - if (event || post_event) { //NB: We need to update two frame buffers per event + // Display section + if (event || post_event) { // NB: We need to update two frame buffers per event if (!(setting->GUI_skin[0])) - nElfs = drawMainScreen(); //Display pure text GUI on generic background - else if (!setting->Show_Menu) { //Display only GUI jpg + nElfs = drawMainScreen(); // Display pure text GUI on generic background + else if (!setting->Show_Menu) { // Display only GUI jpg setLaunchKeys(); clrScr(setting->color[COLOR_BACKGR]); - } else //Display launch filenames/titles on GUI jpg + } else // Display launch filenames/titles on GUI jpg nElfs = drawMainScreen2(TV_mode); } drawScr(); post_event = event; event = 0; - //Pad response section + // Pad response section if (!init_delay && (waitAnyPadReady(), readpad())) { if (new_pad) { - event |= 2; //event |= pad command + event |= 2; // event |= pad command } RunELF_index = -1; switch (mode) { @@ -2825,7 +2830,7 @@ int main(int argc, char *argv[]) else if (new_pad & PAD_UP || new_pad & PAD_DOWN) { user_acted = 1; if (!setting->Show_Menu && setting->GUI_skin[0]) { - } //GUI Menu: disabled when there's no text on menu screen + } // GUI Menu: disabled when there's no text on menu screen else { selected = 0; mode = DPAD; @@ -2851,11 +2856,11 @@ int main(int argc, char *argv[]) strcpy(RunPath, setting->LK_Path[menu_LK[selected]]); } break; - } //ends switch(mode) - } //ends Pad response section + } // ends switch(mode) + } // ends Pad response section if (!user_acted && ((timeout / 1000) == 0) && setting->LK_Path[SETTING_LK_AUTO][0] && mode == BUTTON) { - event |= 8; //event |= visible timeout change + event |= 8; // event |= visible timeout change strcpy(RunPath, setting->LK_Path[SETTING_LK_AUTO]); } @@ -2867,15 +2872,15 @@ int main(int argc, char *argv[]) if (setting->GUI_skin[0]) { GUI_active = 1; loadSkin(BACKGROUND_PIC, 0, 0); - //Load_External_Language(); - //loadFont(setting->font_file); + // Load_External_Language(); + // loadFont(setting->font_file); } } - } //ends while(1) + } // ends while(1) //----- End of main menu event loop ----- } //------------------------------ -//endfunc main +// endfunc main //--------------------------------------------------------------------------- -//End of file: main.c +// End of file: main.c //--------------------------------------------------------------------------- diff --git a/src/makeicon.c b/src/makeicon.c index af721996..46f81966 100644 --- a/src/makeicon.c +++ b/src/makeicon.c @@ -1,5 +1,5 @@ //-------------------------------------------------------------- -//File name: makeicon.c +// File name: makeicon.c //-------------------------------------------------------------- #include "launchelf.h" #include "libmc.h" @@ -14,7 +14,7 @@ static u16 *tex_buffer; #define FONT_WIDTH 8 #define FONT_HEIGHT 16 -//f16 = s16/4096 +// f16 = s16/4096 #define f16 s16 #define f32 float //-------------------------------------------------------------- @@ -30,7 +30,7 @@ struct icon_header struct icon_vertex { f16 xyz[3]; - u16 w; //no idea what this is //RA: but it is required, though it may be zeroed + u16 w; // no idea what this is //RA: but it is required, though it may be zeroed }; //-------------------------------------------------------------- struct icon_texturedata @@ -41,7 +41,7 @@ struct icon_texturedata //-------------------------------------------------------------- struct icon_animheader { - u32 id; //always 0x01 + u32 id; // always 0x01 u32 frame_length; f32 anim_speed; u32 play_offset; @@ -57,7 +57,7 @@ struct icon_framedata }; //-------------------------------------------------------------- // A few cheap defines for assigning vector and texture coordinates to vertices -//Set vector coordinate value of a vertex +// Set vector coordinate value of a vertex #define set_vv(coord, x, y, z) \ coord.xyz[0] = 4096 * x; \ coord.xyz[1] = 4096 * y; \ @@ -83,27 +83,27 @@ void tex_drawChar(unsigned int c, int x, int y, u16 colour) if (c >= 0x11A) c = '_'; - cm = &font_uLE[c * 16]; //cm points to the character definition in the font + cm = &font_uLE[c * 16]; // cm points to the character definition in the font pixMask = 0x80; - for (i = 0; i < 8; i++) { //for i == each pixel column + for (i = 0; i < 8; i++) { // for i == each pixel column pixBase = -1; - for (j = 0; j < 16; j++) { //for j == each pixel row - if ((pixBase < 0) && (cm[j] & pixMask)) { //if start of sequence + for (j = 0; j < 16; j++) { // for j == each pixel row + if ((pixBase < 0) && (cm[j] & pixMask)) { // if start of sequence pixBase = j; - } else if ((pixBase > -1) && !(cm[j] & pixMask)) { //if end of sequence + } else if ((pixBase > -1) && !(cm[j] & pixMask)) { // if end of sequence for (k = pixBase; k < j; k++) - temp_image[i * 2][k * 2] = 0xFFFF; //every other pixel is blank + temp_image[i * 2][k * 2] = 0xFFFF; // every other pixel is blank pixBase = -1; } - } //ends for j == each pixel row - if (pixBase > -1) //if end of sequence including final row + } // ends for j == each pixel row + if (pixBase > -1) // if end of sequence including final row { for (k = pixBase; k < j; k++) temp_image[i * 2][k * 2] = 0xFFFF; } pixMask >>= 1; - } //ends for i == each pixel column + } // ends for i == each pixel column // OR's with the previous bit in the row to fill in the blank space for (i = 1; i < 16; i += 2) @@ -115,7 +115,7 @@ void tex_drawChar(unsigned int c, int x, int y, u16 colour) for (i = 0; i < 16; i++) temp_image[i][j] = temp_image[i][j - 1] | temp_image[i][j]; - //store the temp image buffer into the real image buffer + // store the temp image buffer into the real image buffer for (i = 0; i < 16; i++) for (j = 0; j < 32; j++) tex_buffer[x + i + (y + j) * 128] = temp_image[i][j]; @@ -129,72 +129,72 @@ int tex_printXY(const unsigned char *s, int x, int y, u16 colour) { unsigned int c1, c2; int i; - int text_spacing = 16; //we magnified font + int text_spacing = 16; // we magnified font int x_orig = x; int x_max = x; i = 0; while ((c1 = s[i++]) != 0) { if (c1 == '\t') { //'Horizontal Tab' code ? - x += FONT_WIDTH; //use HT to step half a char space, for centering odd chars - continue; //loop back to try next character + x += FONT_WIDTH; // use HT to step half a char space, for centering odd chars + continue; // loop back to try next character } if (c1 == '\v') //'Vertical Tab' code ? - goto force_halfrow; //use VT to step half a row down, for centering odd rows + goto force_halfrow; // use VT to step half a row down, for centering odd rows if (c1 == '\r') { //'Carriage Return' code ? - force_newrow: //use CR to step a full row down, and restart a row + force_newrow: // use CR to step a full row down, and restart a row y += FONT_HEIGHT; - force_halfrow: //This label is used to allow centering of odd rows + force_halfrow: // This label is used to allow centering of odd rows y += FONT_HEIGHT; if (x > x_max) x_max = x; x = x_orig; - continue; //loop back to try next character + continue; // loop back to try next character } - if (y > ICON_HEIGHT - 2 * FONT_HEIGHT) //if insufficient room for current row - break; //then cut the string rendering here - if (x > ICON_WIDTH - ICON_MARGIN - 2 * FONT_WIDTH) { //if out of room on current row - i--; //back index to retry on next loop - goto force_newrow; //and cut this row here. + if (y > ICON_HEIGHT - 2 * FONT_HEIGHT) // if insufficient room for current row + break; // then cut the string rendering here + if (x > ICON_WIDTH - ICON_MARGIN - 2 * FONT_WIDTH) { // if out of room on current row + i--; // back index to retry on next loop + goto force_newrow; // and cut this row here. } - //Here we know there is room for at least one char on current row + // Here we know there is room for at least one char on current row if (c1 != 0xFF) { // Normal character norm_char: tex_drawChar(c1, x, y, colour); x += text_spacing; continue; - } //End if for normal character + } // End if for normal character // Here we got a sequence starting with 0xFF ('') - if ((c2 = s[i++]) == 0) { //if that was the final character - i--; //back index to retry on next loop - goto norm_char; //and go display '' as any other character + if ((c2 = s[i++]) == 0) { // if that was the final character + i--; // back index to retry on next loop + goto norm_char; // and go display '' as any other character } - //Here we deal with any sequence prefixed by '' - if ((c2 < '0') || (c2 > '=')) //if the sequence is illegal - continue; //then just ignore it - c1 = (c2 - '0') * 2 + 0x100; //generate adjusted char code > 0xFF - tex_drawChar(c1, x, y, colour); //render this base character to texture + // Here we deal with any sequence prefixed by '' + if ((c2 < '0') || (c2 > '=')) // if the sequence is illegal + continue; // then just ignore it + c1 = (c2 - '0') * 2 + 0x100; // generate adjusted char code > 0xFF + tex_drawChar(c1, x, y, colour); // render this base character to texture x += text_spacing; - if ((c2 > '4') && (c2 < ':')) //if this is a normal-width character - continue; //continue with the next loop - //compound sequence '0'=Circle '1'=Cross '2'=Square '3'=Triangle + if ((c2 > '4') && (c2 < ':')) // if this is a normal-width character + continue; // continue with the next loop + // compound sequence '0'=Circle '1'=Cross '2'=Square '3'=Triangle //'4'=FilledBox ':'=Pad_Rt ';'=Pad_Dn '<'=Pad_Lt '='=Pad_Up - if (x > ICON_WIDTH - ICON_MARGIN - 2 * FONT_WIDTH) //if out of room for compound character ? - goto force_newrow; //then cut this row here. - tex_drawChar(c1 + 1, x, y, colour); //render 2nd half of compound character + if (x > ICON_WIDTH - ICON_MARGIN - 2 * FONT_WIDTH) // if out of room for compound character ? + goto force_newrow; // then cut this row here. + tex_drawChar(c1 + 1, x, y, colour); // render 2nd half of compound character x += text_spacing; } // ends while(1) if (x > x_max) x_max = x; - return x_max; //Return max X position reached (not needed for anything though) + return x_max; // Return max X position reached (not needed for anything though) } //-------------------------------------------------------------- -//This is a quick and dirty RLE compression algorithm that assumes -//everything is part of a run, and treats everything as a run, -//regardless as to how long that run is. It could be slightly -//optimized, but the gains would be rather insignifigant. -//NB: With the text magnification used, the assumption of each -//sequence being a run longer than one pixel is always true. +// This is a quick and dirty RLE compression algorithm that assumes +// everything is part of a run, and treats everything as a run, +// regardless as to how long that run is. It could be slightly +// optimized, but the gains would be rather insignifigant. +// NB: With the text magnification used, the assumption of each +// sequence being a run longer than one pixel is always true. //-------------------------------------------------------------- u32 tex_compresRLE() { @@ -218,7 +218,7 @@ u32 tex_compresRLE() return size; } //-------------------------------------------------------------- -//These defines multiplied like '4096*+xs' yield a standard sized flat icon +// These defines multiplied like '4096*+xs' yield a standard sized flat icon #define xs 5 / 2 #define ys 5 / 2 #define zs 0 @@ -226,7 +226,7 @@ u32 tex_compresRLE() /* * Create an icon with the text 'icontext', and store in 'filename' * returns 0 on success, -1 on failure - * + * * The position of the text is hard coded in on line 260 */ //-------------------------------------------------------------- @@ -236,14 +236,14 @@ int make_icon(char *icontext, char *filename) struct icon_header icn_head; icn_head.icon_id = 0x010000; icn_head.anim_shapes = 0x01; - icn_head.texture_type = 0x0E; //uncompressed=0x07 + icn_head.texture_type = 0x0E; // uncompressed=0x07 icn_head.UNKNOWN = 0x3F800000; icn_head.num_vertices = 12; struct icon_vertex icn_vertices[12]; struct icon_texturedata texdata[12]; - struct icon_vertex normals[4]; //numvertices/3, as 3 vertices share one normal - //Back face //Triangle Vertices //Texture coordinates of vertices + struct icon_vertex normals[4]; // numvertices/3, as 3 vertices share one normal + // Back face //Triangle Vertices //Texture coordinates of vertices set_vv(normals[0], 0, 0, 1); set_vv(icn_vertices[0], -xs, -ys, zs); set_tv(texdata[0].uv, 1, 0); @@ -258,7 +258,7 @@ int make_icon(char *icontext, char *filename) set_tv(texdata[4].uv, 1, 1); set_vv(icn_vertices[5], -xs, -ys, zs); set_tv(texdata[5].uv, 1, 0); - //Front face + // Front face set_vv(normals[2], 0, 0, -1); set_vv(icn_vertices[6], xs, -ys, -zs); set_tv(texdata[6].uv, 1, 0); @@ -275,8 +275,8 @@ int make_icon(char *icontext, char *filename) set_tv(texdata[11].uv, 1, 0); for (i = 0; i < icn_head.num_vertices; i++) { - //the y values are generally too small, make them larger - icn_vertices[i].xyz[1] -= ys * 4096; //subtract increases? + // the y values are generally too small, make them larger + icn_vertices[i].xyz[1] -= ys * 4096; // subtract increases? texdata[i].rgba[0] = 0x80; texdata[i].rgba[1] = 0x80; texdata[i].rgba[2] = 0x80; @@ -302,7 +302,7 @@ int make_icon(char *icontext, char *filename) tex_printXY(icontext, 0, 0, 0xFFFF); // (string,xpos,ypos,color) u32 tex_size = tex_compresRLE(); // compress the texture, overwrites tex_buffer - FILE *f = fopen(filename, "wb"); //open/create the file + FILE *f = fopen(filename, "wb"); // open/create the file if (f == NULL) return -1; fwrite(&icn_head, sizeof(icn_head), 1, f); @@ -334,7 +334,7 @@ int make_iconsys(char *title, char *iconname, char *filename) memset(((void *)&icon_sys), 0, sizeof(icon_sys)); strcpy(icon_sys.head, "PS2D"); - icon_sys.nlOffset = 0; //0=automagically wordwrap, otherwise newline position(multiple of 2) + icon_sys.nlOffset = 0; // 0=automagically wordwrap, otherwise newline position(multiple of 2) strcpy_sjis((short *)&icon_sys.title, title); icon_sys.trans = 0x40; @@ -368,5 +368,5 @@ int make_iconsys(char *title, char *iconname, char *filename) return 0; } //-------------------------------------------------------------- -//End of file: makeicon.c +// End of file: makeicon.c //-------------------------------------------------------------- diff --git a/src/pad.c b/src/pad.c index a63f6455..78467353 100644 --- a/src/pad.c +++ b/src/pad.c @@ -22,7 +22,7 @@ int readpad_noKBnoRepeat(void) for (port = 0; port < 2; port++) { if ((state = padGetState(port, 0)) == PAD_STATE_STABLE || (state == PAD_STATE_FINDCTP1)) { - //Deal with cases where pad state is valid for padRead + // Deal with cases where pad state is valid for padRead ret[port] = padRead(port, 0, &buttons_t[port]); if (ret[port] != 0) { paddata_t[port] = 0xffff ^ buttons_t[port].btns; @@ -30,16 +30,16 @@ int readpad_noKBnoRepeat(void) old_pad_t[port] = paddata_t[port]; } } else { - //Deal with cases where pad state is not valid for padRead + // Deal with cases where pad state is not valid for padRead new_pad_t[port] = 0; - } //ends 'if' testing for state valid for padRead - } //ends for - new_pad = new_pad_t[0] | new_pad_t[1]; //This has only new button bits - paddata = paddata_t[0] | paddata_t[1]; //This has all pressed button bits + } // ends 'if' testing for state valid for padRead + } // ends for + new_pad = new_pad_t[0] | new_pad_t[1]; // This has only new button bits + paddata = paddata_t[0] | paddata_t[1]; // This has all pressed button bits return (ret[0] | ret[1]); } //------------------------------ -//endfunc readpad_noKBnoRepeat +// endfunc readpad_noKBnoRepeat //--------------------------------------------------------------------------- // read PAD, but ignore KB. This is needed in code with own KB handlers, // such as the virtual keyboard input routines for 'Rename' and 'New Dir' @@ -52,11 +52,11 @@ int readpad_no_KB(void) for (port = 0; port < 2; port++) { if ((state = padGetState(port, 0)) == PAD_STATE_STABLE || (state == PAD_STATE_FINDCTP1)) { - //Deal with cases where pad state is valid for padRead + // Deal with cases where pad state is valid for padRead ret[port] = padRead(port, 0, &buttons_t[port]); if (ret[port] != 0) { paddata_t[port] = 0xffff ^ buttons_t[port].btns; - if ((padtype_t[port] == 2) && (1 & (test_joy++))) { //DualShock && time for joy scan + if ((padtype_t[port] == 2) && (1 & (test_joy++))) { // DualShock && time for joy scan joy_value = 0; if (buttons_t[port].rjoy_h >= 0xbf) { paddata_t[port] = PAD_R3_H1; @@ -86,33 +86,33 @@ int readpad_no_KB(void) } new_pad_t[port] = paddata_t[port] & ~old_pad_t[port]; if (old_pad_t[port] == paddata_t[port]) { - //no change of pad data + // no change of pad data if (Timer() > rpt_time[port]) { - new_pad_t[port] = paddata_t[port]; //Accept repeated buttons as new - rpt_time[port] = Timer() + 40; //Min delay = 40ms => 25Hz repeat + new_pad_t[port] = paddata_t[port]; // Accept repeated buttons as new + rpt_time[port] = Timer() + 40; // Min delay = 40ms => 25Hz repeat if (rpt_count[port]++ < 20) - rpt_time[port] += 43; //Early delays = 83ms => 12Hz repeat + rpt_time[port] += 43; // Early delays = 83ms => 12Hz repeat } } else { - //pad data has changed ! + // pad data has changed ! rpt_count[port] = 0; - rpt_time[port] = Timer() + 400; //Init delay = 400ms + rpt_time[port] = Timer() + 400; // Init delay = 400ms old_pad_t[port] = paddata_t[port]; } } } else { - //Deal with cases where pad state is not valid for padRead - //NB: This should NOT clear KB repeat test variables + // Deal with cases where pad state is not valid for padRead + // NB: This should NOT clear KB repeat test variables new_pad_t[port] = 0; - //old_pad_t[port]=0; //Clearing this could cause hasty repeats - } //ends 'if' testing for state valid for padRead - } //ends for + // old_pad_t[port]=0; //Clearing this could cause hasty repeats + } // ends 'if' testing for state valid for padRead + } // ends for new_pad = new_pad_t[0] | new_pad_t[1]; - paddata = paddata_t[0] | paddata_t[1]; //This has all pressed button bits + paddata = paddata_t[0] | paddata_t[1]; // This has all pressed button bits return (ret[0] | ret[1]); } //------------------------------ -//endfunc readpad_no_KB +// endfunc readpad_no_KB //--------------------------------------------------------------------------- // simPadKB attempts reading data from a USB keyboard, and map this as a // virtual gamepad. (Very improvised and sloppy, but it should work fine.) @@ -130,18 +130,18 @@ int simPadKB(void) PS2KbdRead(&KeyPress); command = 0x100 + KeyPress; } - ret = 1; //Assume that the entered key is a valid command + ret = 1; // Assume that the entered key is a valid command switch (command) { - case 0x11B: //Escape == Triangle + case 0x11B: // Escape == Triangle new_pad = PAD_TRIANGLE; break; - case 0x00A: //Enter == OK + case 0x00A: // Enter == OK if (!swapKeys) new_pad = PAD_CIRCLE; else new_pad = PAD_CROSS; break; - case 0x020: //Space == Cancel/Mark + case 0x020: // Space == Cancel/Mark if (!swapKeys) new_pad = PAD_CROSS; else @@ -189,62 +189,62 @@ int simPadKB(void) case 0x06D: //'m' == Cross new_pad = PAD_CROSS; break; - case 0x101: //F1 == L1 + case 0x101: // F1 == L1 new_pad = PAD_L1; break; - case 0x102: //F2 == L2 + case 0x102: // F2 == L2 new_pad = PAD_L2; break; - case 0x103: //F3 == L3 + case 0x103: // F3 == L3 new_pad = PAD_L3; break; - case 0x12C: //Up == Up + case 0x12C: // Up == Up new_pad = PAD_UP; break; - case 0x12A: //Left == Left + case 0x12A: // Left == Left new_pad = PAD_LEFT; break; - case 0x129: //Right == Right + case 0x129: // Right == Right new_pad = PAD_RIGHT; break; - case 0x12B: //Down == Down + case 0x12B: // Down == Down new_pad = PAD_DOWN; break; - case 0x123: //Insert == Select + case 0x123: // Insert == Select new_pad = PAD_SELECT; break; - case 0x10C: //F12 == R1 + case 0x10C: // F12 == R1 new_pad = PAD_R1; break; - case 0x10B: //F11 == R2 + case 0x10B: // F11 == R2 new_pad = PAD_R2; break; - case 0x10A: //F10 == R3 + case 0x10A: // F10 == R3 new_pad = PAD_R3; break; - case 0x124: //Home == Triangle + case 0x124: // Home == Triangle new_pad = PAD_TRIANGLE; break; - case 0x127: //End == Square + case 0x127: // End == Square new_pad = PAD_SQUARE; break; - case 0x125: //PgUp == Circle + case 0x125: // PgUp == Circle new_pad = PAD_CIRCLE; break; - case 0x128: //PgDn == Cross + case 0x128: // PgDn == Cross new_pad = PAD_CROSS; break; - case 0x126: //Delete == Start + case 0x126: // Delete == Start new_pad = PAD_START; break; - default: //Unrecognized key => no pad button + default: // Unrecognized key => no pad button ret = 0; break; } return ret; } //------------------------------ -//endfunc simPadKB +// endfunc simPadKB //--------------------------------------------------------------------------- // readpad will call readpad_no_KB, and if no new pad buttons are found, it // will also attempt reading data from a USB keyboard, and map this as a @@ -260,7 +260,7 @@ int readpad(void) return simPadKB(); } //------------------------------ -//endfunc readpad +// endfunc readpad //--------------------------------------------------------------------------- // readpad_noRepeat calls readpad_noKBnoRepeat, and if no new pad buttons are // found, it also attempts reading data from a USB keyboard, and map this as @@ -276,7 +276,7 @@ int readpad_noRepeat(void) return simPadKB(); } //------------------------------ -//endfunc readpad_noRepeat +// endfunc readpad_noRepeat //--------------------------------------------------------------------------- // Wait for specific PAD, but also accept disconnected state void waitPadReady(int port, int slot) @@ -315,33 +315,33 @@ int setupPad(void) padInit(0); for (port = 0; port < 2; port++) { - padtype_t[port] = 0; //Assume that we don't have a proper PS2 controller + padtype_t[port] = 0; // Assume that we don't have a proper PS2 controller if ((ret = padPortOpen(port, 0, &padBuf_t[port][0])) == 0) return 0; waitPadReady(port, 0); state = padGetState(port, 0); - if (state != PAD_STATE_DISCONN) { //if anything connected to this port + if (state != PAD_STATE_DISCONN) { // if anything connected to this port modes = padInfoMode(port, 0, PAD_MODETABLE, -1); - if (modes != 0) { //modes != 0, so it may be a dualshock type + if (modes != 0) { // modes != 0, so it may be a dualshock type for (i = 0; i < modes; i++) { if (padInfoMode(port, 0, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK) { - padtype_t[port] = 2; //flag normal PS2 controller + padtype_t[port] = 2; // flag normal PS2 controller break; } - } //ends for (modes) - } else { //modes == 0, so this is a digital controller - padtype_t[port] = 1; //flag digital controller + } // ends for (modes) + } else { // modes == 0, so this is a digital controller + padtype_t[port] = 1; // flag digital controller } - if (padtype_t[port] == 2) //if DualShock - padSetMainMode(port, 0, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); //Set DualShock - else //else - padSetMainMode(port, 0, PAD_MMODE_DIGITAL, PAD_MMODE_UNLOCK); //Set Digital - waitPadReady(port, 0); //Await completion - } else { //Nothing is connected to this port - padSetMainMode(port, 0, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); //Fake DualShock - waitPadReady(port, 0); //Await completion + if (padtype_t[port] == 2) // if DualShock + padSetMainMode(port, 0, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); // Set DualShock + else // else + padSetMainMode(port, 0, PAD_MMODE_DIGITAL, PAD_MMODE_UNLOCK); // Set Digital + waitPadReady(port, 0); // Await completion + } else { // Nothing is connected to this port + padSetMainMode(port, 0, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK); // Fake DualShock + waitPadReady(port, 0); // Await completion } - } //ends for (port) + } // ends for (port) return 1; } //--------------------------------------------------------------------------- diff --git a/src/pad_ds34.c b/src/pad_ds34.c index 06e34e71..5d74d38a 100644 --- a/src/pad_ds34.c +++ b/src/pad_ds34.c @@ -21,7 +21,7 @@ u32 new_pad, new_pad_t[4]; u32 joy_value = 0; static int test_joy = 0; -int semPoll,semRunning,semFinish; +int semPoll, semRunning, semFinish; int isRunning; // Alarm handler @@ -39,22 +39,22 @@ void padPollingThread(void *args) { int state; ee_sema_t semData; - int semAlrm,iIsRunning; + int semAlrm, iIsRunning; semData.option = semData.attr = 0; semData.init_count = 0; semData.max_count = 1; while (1) { - + WaitSema(semRunning); - iIsRunning=isRunning; + iIsRunning = isRunning; SignalSema(semRunning); - - if(iIsRunning==0) - break; - - + + if (iIsRunning == 0) + break; + + state = padGetState(0, 0); if (state == PAD_STATE_STABLE || (state == PAD_STATE_FINDCTP1)) { @@ -97,7 +97,7 @@ void padPollingThread(void *args) WaitSema(semAlrm); DeleteSema(semAlrm); } - + SignalSema(semFinish); ExitDeleteThread(); } @@ -107,7 +107,7 @@ void padPollingInit(void) { ee_thread_t th_attr; - int pad_thr_id; + int pad_thr_id; ee_sema_t semData; static unsigned char stack[4096] __attribute__((aligned(16))); @@ -126,8 +126,8 @@ void padPollingInit(void) th_attr.gp_reg = &_gp; th_attr.initial_priority = 2; th_attr.attr = th_attr.option = 0; - - isRunning=1; + + isRunning = 1; pad_thr_id = CreateThread(&th_attr); StartThread(pad_thr_id, NULL); }