Skip to content

Commit

Permalink
Big cleanup(Part 1).
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolf3s committed Jan 10, 2025
1 parent f1570a2 commit f3084af
Show file tree
Hide file tree
Showing 34 changed files with 1,153 additions and 1,073 deletions.
1 change: 1 addition & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
./modules/isofs/lz4.h
./modules/network/lwNBD
./thirdparty/clang-format-lint-action
./src/hdd.c
24 changes: 0 additions & 24 deletions include/appsupport.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
#ifndef __APP_SUPPORT_H
#define __APP_SUPPORT_H

#define APP_MODE_UPDATE_DELAY 240

#define APP_TITLE_MAX 128
#define APP_PATH_MAX 128
#define APP_BOOT_MAX 64
#define APP_ARGV1_MAX 128

#define APP_CONFIG_TITLE "title"
#define APP_CONFIG_BOOT "boot"
#define APP_CONFIG_ARGV1 "argv1"

#define APP_TITLE_CONFIG_FILE "title.cfg"

typedef struct
{
char title[APP_TITLE_MAX + 1];
char path[APP_PATH_MAX + 1];
char boot[APP_BOOT_MAX + 1];
char argv1[APP_ARGV1_MAX + 1];
u8 legacy;
} app_info_t;

void appInit();
item_list_t *appGetObject(int initOnly);
void appPostUpdateCallback(int mode);

#endif
3 changes: 2 additions & 1 deletion include/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

void audioInit(void);
void audioEnd(void);
void audioSetVolume(int sfx);
void audioSetVolume();
void audioSetSfxVolume(int sfx);

#endif
22 changes: 2 additions & 20 deletions include/bdmsupport.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
#ifndef __BDM_SUPPORT_H
#define __BDM_SUPPORT_H

#define BDM_MODE_UPDATE_DELAY MENU_UPD_DELAY_GENREFRESH

typedef struct
{
int active; /* Activation flag */
u64 start_sector; /* Start sector of vmc file */
int flags; /* Card flag */
vmc_spec_t specs; /* Card specifications */
} bdm_vmc_infos_t;

#define MAX_BDM_DEVICES 5

#define BDM_TYPE_UNKNOWN -1
#define BDM_TYPE_USB 0
#define BDM_TYPE_ILINK 1
#define BDM_TYPE_SDC 2
#define BDM_TYPE_ATA 3

typedef struct
{
int massDeviceIndex; // Underlying device index backing the mass fs partition, ex: usb0 = 0, usb1 = 1, etc.
Expand All @@ -38,10 +20,10 @@ typedef struct
unsigned char ForceRefresh;
} bdm_device_data_t;

void bdmInit();
extern bdm_device_data_t *gAutoLaunchDeviceData;

int bdmFindPartition(char *target, const char *name, int write);
void bdmLoadModules(void);
void bdmLaunchGame(item_list_t *itemList, int id, config_set_t *configSet);

void bdmInitSemaphore();
void bdmEnumerateDevices();
Expand Down
6 changes: 5 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ int configSetColor(config_set_t *configSet, const char *key, unsigned char *colo
int configGetColor(config_set_t *configSet, const char *key, unsigned char *color);
int configRemoveKey(config_set_t *configSet, const char *key);
void configMerge(config_set_t *dest, const config_set_t *source);

void configGetDiscIDBinary(config_set_t *configSet, void *dst);

int configRead(config_set_t *configSet);
Expand All @@ -183,4 +182,9 @@ void configRemoveVMC(config_set_t *configSet, int slot);
char *configGetDir(void);
void configPrepareNotifications(char *prefix);

int configCheckBDM(int types);
int configCheckHDD(int types);

int configCheckMC(int types);

#endif
8 changes: 3 additions & 5 deletions include/ethsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ typedef struct
vmc_spec_t specs; /* Card specifications */
} smb_vmc_infos_t;

void ethInit(item_list_t *itemList); // Full initialization (Start ETH + SMB and apply configuration). GUI must be already initialized, used by GUI to start SMB mode.
void ethDeinitModules(void); // Module-only deinitialization, without the GUI's knowledge (for specific reasons, otherwise unused).
int ethLoadInitModules(void); // Initializes Ethernet and applies configuration.
void ethDisplayErrorStatus(void); // Displays the current error status (if any). GUI must be already initialized.
void ethDeinitModules(void); // Module-only deinitialization, without the GUI's knowledge (for specific reasons, otherwise unused).
int ethLoadInitModules(void); // Initializes Ethernet and applies configuration.
void ethDisplayErrorStatus(void); // Displays the current error status (if any). GUI must be already initialized.
int ethGetNetConfig(u8 *ip_address, u8 *netmask, u8 *gateway);
int ethApplyConfig(void);
int ethGetDHCPStatus(void);
item_list_t *ethGetObject(int initOnly);

#endif
96 changes: 33 additions & 63 deletions include/hdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#include <hdd-ioctl.h>

#define HDL_GAME_NAME_MAX 64

// APA Partition
#define APA_IOCTL2_GETHEADER 0x6836

typedef struct
{
u32 start; // Sector address
Expand All @@ -11,49 +16,24 @@ typedef struct

typedef struct
{
u8 unused;
u8 sec;
u8 min;
u8 hour;
u8 day;
u8 month;
u16 year;
} ps2time_t;
char partition_name[APA_IDMAX + 1];
char name[HDL_GAME_NAME_MAX + 1];
char startup[8 + 1 + 3 + 1];
u8 hdl_compat_flags;
u8 ops2l_compat_flags;
u8 dma_type;
u8 dma_mode;
u8 disctype;
u32 layer_break;
u32 start_sector;
u32 total_size_in_kb;
} hdl_game_info_t;

typedef struct
{
u32 checksum;
u32 magic; // APA_MAGIC
u32 next;
u32 prev;
char id[APA_IDMAX];
char rpwd[APA_PASSMAX];
char fpwd[APA_PASSMAX];
u32 start;
u32 length;
u16 type;
u16 flags;
u32 nsub;
ps2time_t created;
u32 main;
u32 number;
u32 modver;
u32 pading1[7];
char pading2[128];
struct
{
char magic[32];
u32 version;
u32 nsector;
ps2time_t created;
u32 osdStart;
u32 osdSize;
char pading3[200];
} mbr;
apa_sub_t subs[APA_MAXSUB];
} apa_header_t;

#define PFS_INODE_MAX_BLOCKS 114
u32 count;
hdl_game_info_t *games;
} hdl_games_list_t;

typedef struct
{
Expand All @@ -62,29 +42,7 @@ typedef struct
u16 count;
} pfs_blockinfo_t;

typedef struct
{
u32 checksum;
u32 magic;
pfs_blockinfo_t inode_block;
pfs_blockinfo_t next_segment;
pfs_blockinfo_t last_segment;
pfs_blockinfo_t unused;
pfs_blockinfo_t data[PFS_INODE_MAX_BLOCKS];
u16 mode;
u16 attr;
u16 uid;
u16 gid;
ps2time_t atime;
ps2time_t ctime;
ps2time_t mtime;
u64 size;
u32 number_blocks;
u32 number_data;
u32 number_segdesg;
u32 subpart;
u32 reserved[4];
} pfs_inode_t;
extern hdl_game_info_t *gAutoLaunchGame;

int hddReadSectors(u32 lba, u32 nsectors, void *buf);

Expand All @@ -94,4 +52,16 @@ int hddGetPartitionInfo(const char *name, apa_sub_t *parts);
// Array should be max entries.
int hddGetFileBlockInfo(const char *name, const apa_sub_t *subs, pfs_blockinfo_t *blocks, int max);

int hddCheck(void);
u32 hddGetTotalSectors(void);
int hddIs48bit(void);
int hddSetTransferMode(int type, int mode);
void hddSetIdleTimeout(int timeout);
void hddSetIdleImmediate(void);
int hddGetHDLGamelist(hdl_games_list_t *game_list);
void hddFreeHDLGamelist(hdl_games_list_t *game_list);
int hddSetHDLGameInfo(hdl_game_info_t *ginfo);
int hddDeleteHDLGame(hdl_game_info_t *ginfo);


#endif
41 changes: 0 additions & 41 deletions include/hddsupport.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
#ifndef __HDD_SUPPORT_H
#define __HDD_SUPPORT_H

#include "include/hdd.h"

#define HDD_MODE_UPDATE_DELAY MENU_UPD_DELAY_NOUPDATE

#define HDL_GAME_NAME_MAX 64

// APA Partition
#define APA_IOCTL2_GETHEADER 0x6836

typedef struct
{
char partition_name[APA_IDMAX + 1];
char name[HDL_GAME_NAME_MAX + 1];
char startup[8 + 1 + 3 + 1];
u8 hdl_compat_flags;
u8 ops2l_compat_flags;
u8 dma_type;
u8 dma_mode;
u8 disctype;
u32 layer_break;
u32 start_sector;
u32 total_size_in_kb;
} hdl_game_info_t;

typedef struct
{
u32 count;
hdl_game_info_t *games;
} hdl_games_list_t;

typedef struct
{
u32 start;
Expand All @@ -46,17 +16,6 @@ typedef struct
vmc_spec_t specs; /* Card specifications */
} hdd_vmc_infos_t;

int hddCheck(void);
u32 hddGetTotalSectors(void);
int hddIs48bit(void);
int hddSetTransferMode(int type, int mode);
void hddSetIdleTimeout(int timeout);
void hddSetIdleImmediate(void);
int hddGetHDLGamelist(hdl_games_list_t *game_list);
void hddFreeHDLGamelist(hdl_games_list_t *game_list);
int hddSetHDLGameInfo(hdl_game_info_t *ginfo);
int hddDeleteHDLGame(hdl_game_info_t *ginfo);

void hddInit();
item_list_t *hddGetObject(int initOnly);
void hddLoadModules(void);
Expand Down
2 changes: 0 additions & 2 deletions include/iosupport.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __IOSUPPORT_H
#define __IOSUPPORT_H

#include "include/config.h"

#define IO_MODE_SELECTED_NONE -1
#define IO_MODE_SELECTED_ALL MODE_COUNT

Expand Down
28 changes: 3 additions & 25 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@

#include <kernel.h>
#include <sifrpc.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <gsKit.h>
#include <malloc.h>
#include <math.h>

#include "include/config.h"
#include "include/iosupport.h"
#include "include/submenu.h"
#include "include/menu.h"
#include "include/mcemu.h"
#include "include/hddsupport.h"
#include "include/supportbase.h"
#include "include/bdmsupport.h"
// Master password for disabling the parental lock.
#define OPL_PARENTAL_LOCK_MASTER_PASS "989765"

Expand All @@ -38,13 +36,6 @@

#define OPL_VMODE_CHANGE_CONFIRMATION_TIMEOUT_MS 10000

int oplPath2Mode(const char *path);
int oplGetAppImage(const char *device, char *folder, int isRelative, char *value, char *suffix, GSTEXTURE *resultTex, short psm);
int oplScanApps(int (*callback)(const char *path, config_set_t *appConfig, void *arg), void *arg);
int oplShouldAppsUpdate(void);
config_set_t *oplGetLegacyAppsConfig(void);
config_set_t *oplGetLegacyAppsInfo(char *name);

void setErrorMessage(int strId);
void setErrorMessageWithCode(int strId, int error);
int loadConfig(int types);
Expand Down Expand Up @@ -185,9 +176,6 @@ extern unsigned char gDefaultSelTextColor[3];
extern unsigned char gDefaultUITextColor[3];

// Launching games with args
extern hdl_game_info_t *gAutoLaunchGame;
extern base_game_info_t *gAutoLaunchBDMGame;
extern bdm_device_data_t *gAutoLaunchDeviceData;
extern char *gHDDPrefix;
extern char gOPLPart[128];

Expand All @@ -197,9 +185,6 @@ void setDefaultColors(void);

#define MENU_ITEM_HEIGHT 19

#include "include/submenu.h"
#include "include/menu.h"

typedef struct
{
item_list_t *support;
Expand All @@ -211,11 +196,4 @@ typedef struct
submenu_list_t *subMenu;
} opl_io_module_t;

/*
BLURT output char blurttext[128];
#define BLURT \
snprintf(blurttext, sizeof(blurttext), "%s\\%s(%d)", __FILE__, __func__, __LINE__); \
delay(10);
#define BLURT snprintf(blurttext, sizeof(blurttext), "%s(%d)", blurttext, __LINE__);
*/
#endif
Loading

0 comments on commit f3084af

Please sign in to comment.