Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
card.h
Go to the documentation of this file.
1#ifndef CARD_H
2#define CARD_H
3
4#include "dolphin/types.h"
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10#define CARD_ENCODE_ANSI 0u
11#define CARD_ENCODE_SJIS 1u
12
13/* Sizes */
14#define CARD_WORKAREA_SIZE (5 * 8 * 1024)
15#define CARD_READ_SIZE 512
16#define CARD_MAX_FILE 127
17#define CARD_COMMENT_SIZE 64
18#define CARD_FILENAME_MAX 32
19#define CARD_ICON_MAX 8
20#define CARD_ICON_WIDTH 32
21#define CARD_ICON_HEIGHT 32
22#define CARD_BANNER_WIDTH 96
23#define CARD_BANNER_HEIGHT 32
24
25/* Icon animation */
26#define CARD_MODE_NORMAL 0
27#define CARD_MODE_FAST 1
28
29#define CARDGetBannerFormat(stat) (((stat)->bannerFormat) & CARD_STAT_BANNER_MASK)
30#define CARDGetIconAnim(stat) (((stat)->bannerFormat) & CARD_STAT_ANIM_MASK)
31#define CARDGetIconFormat(stat, n) (((stat)->iconFormat >> (2 * (n))) & CARD_STAT_ICON_MASK)
32#define CARDGetIconSpeed(stat, n) (((stat)->iconSpeed >> (2 * (n))) & CARD_STAT_SPEED_MASK)
33#define CARDSetBannerFormat(stat, f) \
34 ((stat)->bannerFormat = (u8)(((stat)->bannerFormat & ~CARD_STAT_BANNER_MASK) | (f)))
35#define CARDSetIconAnim(stat, f) \
36 ((stat)->bannerFormat = (u8)(((stat)->bannerFormat & ~CARD_STAT_ANIM_MASK) | (f)))
37#define CARDSetIconFormat(stat, n, f) \
38 ((stat)->iconFormat = \
39 (u16)(((stat)->iconFormat & ~(CARD_STAT_ICON_MASK << (2 * (n)))) | ((f) << (2 * (n)))))
40#define CARDSetIconSpeed(stat, n, f) \
41 ((stat)->iconSpeed = \
42 (u16)(((stat)->iconSpeed & ~(CARD_STAT_SPEED_MASK << (2 * (n)))) | ((f) << (2 * (n)))))
43#define CARDSetIconAddress(stat, addr) ((stat)->iconAddr = (u32)(addr))
44#define CARDSetCommentAddress(stat, addr) ((stat)->commentAddr = (u32)(addr))
45#define CARDGetFileNo(fileInfo) ((fileInfo)->fileNo)
46
47#define CARD_RESULT_UNLOCKED 1
48#define CARD_RESULT_READY 0
49#define CARD_RESULT_BUSY -1
50#define CARD_RESULT_WRONGDEVICE -2
51#define CARD_RESULT_NOCARD -3
52#define CARD_RESULT_NOFILE -4
53#define CARD_RESULT_IOERROR -5
54#define CARD_RESULT_BROKEN -6
55#define CARD_RESULT_EXIST -7
56#define CARD_RESULT_NOENT -8
57#define CARD_RESULT_INSSPACE -9
58#define CARD_RESULT_NOPERM -10
59#define CARD_RESULT_LIMIT -11
60#define CARD_RESULT_NAMETOOLONG -12
61#define CARD_RESULT_ENCODING -13
62#define CARD_RESULT_CANCELED -14
63#define CARD_RESULT_FATAL_ERROR -128
64
65#define CARD_STAT_ICON_NONE 0
66#define CARD_STAT_ICON_C8 1
67#define CARD_STAT_ICON_RGB5A3 2
68#define CARD_STAT_ICON_MASK 3
69
70#define CARD_STAT_BANNER_NONE 0
71#define CARD_STAT_BANNER_C8 1
72#define CARD_STAT_BANNER_RGB5A3 2
73#define CARD_STAT_BANNER_MASK 3
74
75#define CARD_STAT_ANIM_LOOP 0x00
76#define CARD_STAT_ANIM_BOUNCE 0x04
77#define CARD_STAT_ANIM_MASK 0x04
78
79#define CARD_STAT_SPEED_END 0
80#define CARD_STAT_SPEED_FAST 1
81#define CARD_STAT_SPEED_MIDDLE 2
82#define CARD_STAT_SPEED_SLOW 3
83#define CARD_STAT_SPEED_MASK 3
84
85#define CARD_ATTR_PUBLIC 0x04u
86#define CARD_ATTR_NO_COPY 0x08u
87#define CARD_ATTR_NO_MOVE 0x10u
88#define CARD_ATTR_GLOBAL 0x20u
89#define CARD_ATTR_COMPANY 0x40u
90
100
101typedef struct CARDStat {
104 u32 time; // seconds since 01/01/2000 midnight
107
110 u32 iconAddr; // offset to the banner, bannerTlut, icon, iconTlut data set.
113 u32 commentAddr; // offset to the pair of 32 byte character strings.
114
121
122typedef void (*CARDCallback)(s32 chan, s32 result);
123
124/* CARDBios */
125void CARDInit(void);
128
129/* CARDCheck */
130s32 CARDCheck(s32 chan);
131static s32 CARDCheckExAsync(s32 chan, s32* xferBytes, CARDCallback callback);
132
133/* CARDCreate */
134static s32 CARDCreateAsync(s32 chan, const char* fileName, u32 size, CARDFileInfo* fileInfo,
135 CARDCallback callback);
136s32 CARDCreate(s32 chan, const char* fileName, u32 size, CARDFileInfo* fileInfo);
137
138/* CARDFormat */
139s32 CARDFormat(s32 chan);
140
141/* CARDMount */
142s32 CARDProbe(s32 chan);
143s32 CARDProbeEx(s32 chan, s32* memSize, s32* sectorSize);
144s32 CARDMount(s32 chan, void* workArea, CARDCallback attachCb);
145s32 CARDUnmount(s32 chan);
146static s32 CARDMountAsync(s32 chan, void* workArea, CARDCallback detachCb, CARDCallback attachCb);
147
148/* CARDNet */
150
151/* CARDOpen */
152s32 CARDOpen(s32 chan, const char* fileName, CARDFileInfo* fileInfo);
153s32 CARDClose(CARDFileInfo* fileInfo);
154
155/* CARDRead */
156static s32 CARDReadAsync(CARDFileInfo* fileInfo, void* buf, s32 length, s32 offset,
157 CARDCallback callback);
158s32 CARDRead(CARDFileInfo* fileInfo, void* buf, s32 length, s32 offset);
159
160/* CARDStat */
161s32 CARDSetStatus(s32 chan, s32 fileNo, CARDStat* stat);
162s32 CARDGetStatus(s32 chan, s32 fileNo, CARDStat* stat);
163static s32 CARDSetStatusAsync(s32 chan, s32 fileNo, CARDStat* stat, CARDCallback callback);
164
165/* CARDWrite */
166static s32 CARDWriteAsync(CARDFileInfo* fileInfo, const void* buf, s32 length, s32 offset,
167 CARDCallback callback);
168s32 CARDWrite(CARDFileInfo* fileInfo, const void* buf, s32 length, s32 offset);
169
170#ifdef __cplusplus
171}
172#endif
173
174#endif /* CARD_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
s32 CARDCreate(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo)
Definition CARDCreate.c:122
void CARDInit(void)
Definition CARDBios.c:505
s32 CARDProbeEx(s32 chan, s32 *memSize, s32 *sectorSize)
Definition CARDMount.c:69
BOOL CARDGetFastMode(void)
Definition CARDBios.c:655
s32 CARDGetStatus(s32 chan, s32 fileNo, CARDStat *stat)
Definition CARDStat.c:67
static s32 CARDCheckExAsync(s32 chan, s32 *xferBytes, CARDCallback callback)
Definition CARDCheck.c:194
s32 CARDSetStatus(s32 chan, s32 fileNo, CARDStat *stat)
Definition CARDStat.c:149
s32 CARDMount(s32 chan, void *workArea, CARDCallback attachCb)
Definition CARDMount.c:360
s32 CARDWrite(CARDFileInfo *fileInfo, const void *buf, s32 length, s32 offset)
Definition CARDWrite.c:122
s32 CARDOpen(s32 chan, const char *fileName, CARDFileInfo *fileInfo)
Definition CARDOpen.c:132
s32 CARDClose(CARDFileInfo *fileInfo)
Definition CARDOpen.c:161
s32 CARDCheck(s32 chan)
Definition CARDCheck.c:326
static s32 CARDCreateAsync(s32 chan, const char *fileName, u32 size, CARDFileInfo *fileInfo, CARDCallback callback)
Definition CARDCreate.c:56
static s32 CARDReadAsync(CARDFileInfo *fileInfo, void *buf, s32 length, s32 offset, CARDCallback callback)
Definition CARDRead.c:108
static s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *buf, s32 length, s32 offset, CARDCallback callback)
Definition CARDWrite.c:87
void(* CARDCallback)(s32 chan, s32 result)
Definition card.h:122
s32 CARDProbe(s32 chan)
Definition CARDMount.c:56
static s32 CARDMountAsync(s32 chan, void *workArea, CARDCallback detachCb, CARDCallback attachCb)
Definition CARDMount.c:302
s32 CARDFreeBlocks(s32 chan, s32 *byteNotUsed, s32 *filesNotUsed)
Definition CARDBios.c:583
s32 CARDGetSerialNo(s32 chan, u64 *serialNo)
Definition CARDNet.c:12
s32 CARDUnmount(s32 chan)
Definition CARDMount.c:388
s32 CARDFormat(s32 chan)
Definition CARDFormat.c:127
static s32 CARDSetStatusAsync(s32 chan, s32 fileNo, CARDStat *stat, CARDCallback callback)
Definition CARDStat.c:104
s32 CARDRead(CARDFileInfo *fileInfo, void *buf, s32 length, s32 offset)
Definition CARDRead.c:145
Definition card.h:91
s32 length
Definition card.h:96
s32 offset
Definition card.h:95
s32 fileNo
Definition card.h:93
s32 chan
Definition card.h:92
u16 __padding
Definition card.h:98
u16 iBlock
Definition card.h:97
Definition card.h:101
u8 bannerFormat
Definition card.h:108
u32 offsetBannerTlut
Definition card.h:116
u32 length
Definition card.h:103
u32 offsetIconTlut
Definition card.h:118
u32 time
Definition card.h:104
u8 gameName[4]
Definition card.h:105
u32 offsetIcon[CARD_ICON_MAX]
Definition card.h:117
char fileName[CARD_FILENAME_MAX]
Definition card.h:102
u32 offsetData
Definition card.h:119
u16 iconSpeed
Definition card.h:112
u16 iconFormat
Definition card.h:111
u32 iconAddr
Definition card.h:110
u32 offsetBanner
Definition card.h:115
u32 commentAddr
Definition card.h:113
u8 company[2]
Definition card.h:106
u8 __padding
Definition card.h:109
int BOOL
Definition types.h:27
unsigned long u32
Definition types.h:10
unsigned short u16
Definition types.h:9
unsigned long long u64
Definition types.h:11
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8