Skip to content

Commit 189521a

Browse files
committed
Updated definitions for multiple card and gx functions/enums/structs
1 parent 9d8ed71 commit 189521a

File tree

10 files changed

+96
-92
lines changed

10 files changed

+96
-92
lines changed

ttyd-tools/rel/include/gc/card.h

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,37 @@ namespace gc::card {
66

77
extern "C" {
88

9-
#define CARD_SLOTA 0 // Memory card slot A
10-
#define CARD_SLOTB 1 // Memory card slot B
9+
#define CARD_SLOTA 0 // Memory card slot A
10+
#define CARD_SLOTB 1 // Memory card slot B
1111

12-
#define CARD_FILENAMELEN 32 // Maximum filename length
13-
#define CARD_MAXICONS 8
12+
#define CARD_FILENAMELEN 32 // Maximum filename length
13+
#define CARD_MAXICONS 8
1414

15-
#define CARD_ERROR_UNLOCKED 1 // Card is being unlocked or is already unlocked
16-
#define CARD_ERROR_READY 0 // Card is ready
17-
#define CARD_ERROR_BUSY -1 // Card is busy
18-
#define CARD_ERROR_WRONGDEVICE -2 // Wrong device connected in slot
19-
#define CARD_ERROR_NOCARD -3 // No memory card in slot
20-
#define CARD_ERROR_NOFILE -4 // Specified file not found
21-
#define CARD_ERROR_IOERROR -5 // Internal EXI I/O error
22-
#define CARD_ERROR_BROKEN -6 // Directory structure or file entry broken
23-
#define CARD_ERROR_EXIST -7 // File already exists with the specified parameters
24-
#define CARD_ERROR_NOENT -8 // Found no empty block to create the file
25-
#define CARD_ERROR_INSSPACE -9 // Not enough space to write the file to the memory card
26-
#define CARD_ERROR_NOPERM -10 // Not enough permissions to operate on the file
27-
#define CARD_ERROR_LIMIT -11 // Card size limit reached
28-
#define CARD_ERROR_NAMETOOLONG -12 // Filename too long
29-
#define CARD_ERROR_ENCODING -13 // Font encoding PAL/SJIS mismatch
30-
#define CARD_ERROR_CANCELED -14 // Card operation canceled
31-
#define CARD_ERROR_FATAL_ERROR -128 // Fatal error, non-recoverable
15+
#define CARD_RESULT_UNLOCKED 1 // Card is being unlocked or is already unlocked
16+
#define CARD_RESULT_READY 0 // Card is ready
17+
#define CARD_RESULT_BUSY -1 // Card is busy
18+
#define CARD_RESULT_WRONGDEVICE -2 // Wrong device connected in slot
19+
#define CARD_RESULT_NOCARD -3 // No memory card in slot
20+
#define CARD_RESULT_NOFILE -4 // Specified file not found
21+
#define CARD_RESULT_IOERROR -5 // Internal EXI I/O error
22+
#define CARD_RESULT_BROKEN -6 // Directory structure or file entry broken
23+
#define CARD_RESULT_EXIST -7 // File already exists with the specified parameters
24+
#define CARD_RESULT_NOENT -8 // Found no empty block to create the file
25+
#define CARD_RESULT_INSSPACE -9 // Not enough space to write the file to the memory card
26+
#define CARD_RESULT_NOPERM -10 // Not enough permissions to operate on the file
27+
#define CARD_RESULT_LIMIT -11 // Card size limit reached
28+
#define CARD_RESULT_NAMETOOLONG -12 // Filename too long
29+
#define CARD_RESULT_ENCODING -13 // Font encoding PAL/SJIS mismatch
30+
#define CARD_RESULT_CANCELED -14 // Card operation canceled
31+
#define CARD_RESULT_FATAL_ERROR -128 // Fatal error, non-recoverable
3232

3333
typedef struct CARDFileInfo {
3434
int32_t channel;
3535
int32_t fileNum;
3636
int32_t offset;
3737
int32_t length;
3838
uint16_t iBlock;
39+
uint16_t padding;
3940
} CARDFileInfo;
4041

4142
typedef struct CARDStat {
@@ -53,7 +54,7 @@ typedef struct CARDStat {
5354
uint32_t offsetBannerTlut;
5455
uint32_t offsetIcon[CARD_MAXICONS];
5556
uint32_t offsetIconTlut;
56-
uint32_t offsetDada;
57+
uint32_t offsetData;
5758
} CARDStat;
5859

5960
typedef void (*CARDCallback)(int32_t channel, int32_t result);
@@ -62,12 +63,12 @@ int32_t CARDGetResultCode(int32_t channel);
6263
int32_t CARDProbeEx(int32_t channel, int32_t *memSize, int32_t *sectorSize);
6364
int32_t CARDMountAsync(int32_t channel, void *workArea, CARDCallback detachCallback, CARDCallback attachCallback);
6465
int32_t CARDUnmount(int32_t channel);
65-
int32_t CARDOpen(int32_t channel, char *fileName, CARDFileInfo *fileInfo);
66+
int32_t CARDOpen(int32_t channel, const char *fileName, CARDFileInfo *fileInfo);
6667
int32_t CARDClose(CARDFileInfo *fileInfo);
67-
int32_t CARDCreateAsync(int32_t channel, char *fileName, uint32_t size, CARDFileInfo *fileInfo, CARDCallback callback);
68+
int32_t CARDCreateAsync(int32_t channel, const char *fileName, uint32_t size, CARDFileInfo *fileInfo, CARDCallback callback);
6869
int32_t CARDReadAsync(CARDFileInfo *fileInfo, void *buffer, int32_t length, int32_t offset, CARDCallback callback);
6970
int32_t CARDWriteAsync(CARDFileInfo *fileInfo, void *buffer, int32_t length, int32_t offset, CARDCallback callback);
70-
int32_t CARDDelete(int32_t channel, char *fileName);
71+
int32_t CARDDelete(int32_t channel, const char *fileName);
7172
int32_t CARDGetStatus(int32_t channel, int32_t fileNum, CARDStat *stat);
7273
int32_t CARDSetStatusAsync(int32_t channel, int32_t fileNum, CARDStat *stat, CARDCallback callback);
7374

ttyd-tools/rel/include/gc/gx.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ namespace gc::gx {
66

77
extern "C" {
88

9-
enum GXPrimitive
9+
enum class GXPrimitive
1010
{
11-
GX_POINTS = 0,
12-
GX_LINES,
13-
GX_LINESTRIP,
14-
GX_TRIANGLES,
15-
GX_TRIANGLESTRIP,
16-
GX_TRIANGLEFAN,
17-
GX_QUADS,
11+
GX_QUADS = 128,
12+
GX_TRIANGLES = 144,
13+
GX_TRIANGLESTRIP = 152,
14+
GX_TRIANGLEFAN = 160,
15+
GX_LINES = 168,
16+
GX_LINESTRIP = 176,
17+
GX_POINTS = 184,
1818
};
1919

20-
enum GXVtxFmt
20+
enum class GXVtxFmt
2121
{
2222
GX_VTXFMT0 = 0,
2323
GX_VTXFMT1,
@@ -30,7 +30,7 @@ enum GXVtxFmt
3030
GX_MAX_VTXFMT,
3131
};
3232

33-
enum GXChannelID
33+
enum class GXChannelID
3434
{
3535
GX_COLOR0 = 0,
3636
GX_COLOR1,
@@ -41,7 +41,7 @@ enum GXChannelID
4141
GX_COLOR_ZERO,
4242
GX_ALPHA_BUMP,
4343
GX_ALPHA_BUMPN,
44-
GX_COLOR_NULL,
44+
GX_COLOR_NULL = 255,
4545
};
4646

4747
void GXBegin(GXPrimitive type, GXVtxFmt vtxFmt, uint16_t nVerts);

ttyd-tools/rel/include/global.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ struct DisplayActionCommandTiming
572572
struct MemoryCardStruct
573573
{
574574
uint8_t ReturnCode;
575-
char *SettingsFileName;
576-
char *SettingsDescription;
577-
char *RelFileName;
575+
const char *SettingsFileName;
576+
const char *SettingsDescription;
577+
const char *RelFileName;
578578
};
579579

580580
struct MemoryWatchStruct

ttyd-tools/rel/include/memcard.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ int32_t mountCard(int32_t channel);
1414

1515
int32_t unmountCard(int32_t channel);
1616

17-
int32_t openFileFromCard(int32_t channel, char *fileName, gc::card::CARDFileInfo *fileInfo);
17+
int32_t openFileFromCard(int32_t channel,
18+
const char *fileName, gc::card::CARDFileInfo *fileInfo);
1819

1920
int32_t closeFileFromCard(gc::card::CARDFileInfo *fileInfo);
2021

2122
void closeFileAndUnmountCard(gc::card::CARDFileInfo *fileInfo, int32_t channel);
2223

23-
int32_t createFileOnCard(int32_t channel, char *fileName,
24+
int32_t createFileOnCard(int32_t channel, const char *fileName,
2425
uint32_t size, gc::card::CARDFileInfo *fileInfo);
2526

2627
int32_t readFromFileOnCard(gc::card::CARDFileInfo *fileInfo,
@@ -29,18 +30,19 @@ int32_t readFromFileOnCard(gc::card::CARDFileInfo *fileInfo,
2930
int32_t writeToFileOnCard(gc::card::CARDFileInfo *fileInfo,
3031
void *buffer, int32_t length, int32_t offset);
3132

32-
int32_t deleteFileOnCard(int32_t channel, char *fileName);
33+
int32_t deleteFileOnCard(int32_t channel, const char *fileName);
3334

3435
int32_t getFileStatus(int32_t channel, int32_t fileNum, gc::card::CARDStat *stat);
3536

3637
int32_t setFileStatus(int32_t channel,
3738
int32_t fileNum, gc::card::CARDStat *stat);
3839

39-
int32_t loadSettings(char *settingsFileName);
40+
int32_t loadSettings(const char *settingsFileName);
4041

41-
int32_t writeSettings(char *settingsDescription, char *settingsFileName, char *relFileName);
42+
int32_t writeSettings(const char *settingsDescription,
43+
const char *settingsFileName, const char *relFileName);
4244

43-
int32_t createSettingsFile(char *settingsFileName,
44-
char *relFileName, gc::card::CARDFileInfo *settingsFileInfo);
45+
int32_t createSettingsFile(const char *settingsFileName,
46+
const char *relFileName, gc::card::CARDFileInfo *settingsFileInfo);
4547

4648
}

ttyd-tools/rel/source/draw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void drawArtAttackHitboxes()
8787
uint32_t HitboxLineColor = ttyd::fontmgr::HSV2RGB(HSVA);
8888

8989
// Set the color of the lines of the current hitbox
90-
gc::gx::GXSetChanMatColor(gc::gx::GX_COLOR0A0, reinterpret_cast<uint8_t *>(&HitboxLineColor));
90+
gc::gx::GXSetChanMatColor(gc::gx::GXChannelID::GX_COLOR0A0, reinterpret_cast<uint8_t *>(&HitboxLineColor));
9191

9292
// Adjust the hue for the lines of the next hitbox
9393
HSVA[0] += 45;
@@ -191,7 +191,7 @@ void drawArtAttackHitboxes()
191191
}
192192

193193
// Draw the line from corner 1 to corner 2
194-
gc::gx::GXBegin(static_cast<gc::gx::GXPrimitive>(168), gc::gx::GX_VTXFMT0, 2);
194+
gc::gx::GXBegin(gc::gx::GXPrimitive::GX_LINES, gc::gx::GXVtxFmt::GX_VTXFMT0, 2);
195195

196196
*WriteGatherPipe = ScreenPointOutLineStart[0];
197197
*WriteGatherPipe = ScreenPointOutLineStart[1];

ttyd-tools/rel/source/global.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,18 +1513,17 @@ void initMenuVars()
15131513
Menu[WARPS_INDEX].PreviousMenu = WARPS;
15141514
Menu[WARPS_INDEX].Line = WarpIndexLines;
15151515

1516-
// The CARD functions do not modify the strings, so const_cast<char *> can be used
1517-
MenuSettings.SettingsFileName = const_cast<char *>("rel_settings");
1516+
MenuSettings.SettingsFileName = "rel_settings";
15181517

15191518
#ifdef TTYD_US
1520-
MenuSettings.SettingsDescription = const_cast<char *>("Practice Codes Settings (US)");
1519+
MenuSettings.SettingsDescription = "Practice Codes Settings (US)";
15211520
#elif defined TTYD_JP
1522-
MenuSettings.SettingsDescription = const_cast<char *>("Practice Codes Settings (JP)");
1521+
MenuSettings.SettingsDescription = "Practice Codes Settings (JP)";
15231522
#elif defined TTYD_EU
1524-
MenuSettings.SettingsDescription = const_cast<char *>("Practice Codes Settings (EU)");
1523+
MenuSettings.SettingsDescription = "Practice Codes Settings (EU)";
15251524
#endif
15261525

1527-
MenuSettings.RelFileName = const_cast<char *>("rel");
1526+
MenuSettings.RelFileName = "rel";
15281527

15291528
// Set the initial settings
15301529
setSettings();

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
namespace mod {
3030

3131
// Assembly overwrite functions
32-
extern "C"
33-
{
32+
extern "C" {
3433

3534
void StartPreventPreBattleSoftlock();
3635
void StartDisableBattles();

0 commit comments

Comments
 (0)