resonance 1.0.1
Loading...
Searching...
No Matches
savefilemct.h
Go to the documentation of this file.
1#pragma once
2
3#include <libmc.h>
4
5#ifdef VIDEO_STANDARD_PAL
6#include <vector>
7#endif
8
10#include "os/hxstr.h"
11
12#ifdef VIDEO_STANDARD_PAL
13// The header of SaveSpaceCheckerMCT includes this one for SaveFileMCT and SaveFileEntry.
15
24enum SaveFileStep {
25 kSaveFileStepCheckSpace = 0,
27 kSaveFileStepOpenFile = 2,
28 kSaveFileStepWriteFile = 3,
31};
32
39struct SaveFileEntry {
41 HxStr mName;
42
44 const void *mData;
45
47 int mLength;
48};
49#else
73
79#endif
80
82constexpr int kIconTitleBufferSize = 64;
83
114class SaveFileMCT : public MemcardTask {
115public:
128 SaveFileMCT(MemcardUser *pUser, Memcard *pCard, int nPortSlot, int nCookie);
129
134 virtual ~SaveFileMCT();
135
152 void Save(const HxStr &dirName,
153 const HxStr &fileName,
154 const HxStr &iconTitle,
155 const void *pData,
156 int nLength,
157 int bSkipIconFiles);
158
165 void RunStep();
166
178 void BuildIconSys(const char *pszTitle);
179
180#ifdef VIDEO_STANDARD_PAL
191 virtual void OnCheckInfo(CheckInfoOp *pOp);
192
204 void OnSpaceChecked(int nKilobytes);
205
214 void StartSpaceCheck();
215#endif
216
221 virtual void OnCreateDir(CreateDirOp *pOp);
222
227 virtual void OnWrite(WriteOp *pOp);
228
233 virtual void OnOpenWrite(OpenWriteOp *pOp);
234
239 virtual void OnClose(CloseOp *pOp);
240
245 virtual void Finish();
246
257 virtual void Execute();
258
259protected:
260#ifdef VIDEO_STANDARD_PAL
261 // The kilobytes the files need, or once a check fails the kilobytes the card lacks. +0x1c
262 int mKilobytes;
263
264 // The descriptor the current step writes through. +0x20
265 int mFile;
266
267 // The browser icon header, built in place and written as one 964-byte block. +0x24
268 sceMcIconSys mIconSys;
269
270 // The files to write, in order. +0x3e8
271 std::vector<SaveFileEntry> mFiles;
272
273 // The save directory. Without its leading `/` it is also the marker file name. +0x3f4
275
276 // The text the browser shows. +0x3fc
278
279 // One of SaveFileStep, storing the step to run next. +0x404
280 int mStep;
281
282 // The space check, deleted by kSaveFileStepCreateDir. +0x408
283 SaveSpaceCheckerMCT *mSpaceChecker;
284
285 // Non-zero to write the payload alone. Stored by Save() and never acted on. +0x40c
286 int mSkipIconFiles;
287
288 // Set to 1 by Execute() and never read. +0x410
289 int mExecuted;
290
291 // The index in mFiles of the file being written. +0x414
292 int mFileIndex;
293
294 // The free clusters the card enquiry reported. +0x418
295 int mFreeClusters;
296#else
297 // The descriptor the current step writes through. +0x1c
298 int mFile;
299
300 // The browser icon header, built in place and written as one 964-byte block. +0x20
301 sceMcIconSys mIconSys;
302
303 // The save directory, and the name of the marker file written inside it. +0x3e4
305
306 // The payload file, appended to mDirName. +0x3ec
308
309 // The text the browser shows. +0x3f4
311
312 // One of SaveFileStep, storing the step to run next. +0x3fc
313 int mStep;
314
315 // The payload. +0x400
316 const void *mData;
317
318 // The payload length. +0x404
320
321 // Non-zero to write the payload alone. +0x408
323#endif
324};
Enquiry about the card in one slot.
Definition checkinfoop.h:13
Close of an open memory-card file.
Definition closeop.h:14
Creation of one directory on a card.
Definition createdirop.h:12
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
virtual void OnCheckInfo(CheckInfoOp *pOp)
Report a finished card enquiry.
MemcardTask(MemcardUser *pUser, Memcard *pCard, int nPortSlot, int nCookie)
Construct an idle task against one card slot.
Receiver notified once a memory-card task has finished.
Definition memcarduser.h:24
Queue of memory-card operations, with one entry point per libmc call.
Definition memcard.h:29
Open of one memory-card file for writing, creating it when it is absent.
Definition openwriteop.h:15
HxStr mFileName
Definition savefilemct.h:307
virtual void Finish()
virtual void OnCreateDir(CreateDirOp *pOp)
virtual void OnWrite(WriteOp *pOp)
void Save(const HxStr &dirName, const HxStr &fileName, const HxStr &iconTitle, const void *pData, int nLength, int bSkipIconFiles)
Record what to write and start the sequence.
virtual void OnOpenWrite(OpenWriteOp *pOp)
virtual ~SaveFileMCT()
SaveFileMCT(MemcardUser *pUser, Memcard *pCard, int nPortSlot, int nCookie)
Construct an idle save task.
void RunStep()
Run the step mStep selects and advance to the step after it.
sceMcIconSys mIconSys
Definition savefilemct.h:301
int mFile
Definition savefilemct.h:298
virtual void Execute()
Start the sequence.
int mDataLength
Definition savefilemct.h:319
int mSkipIconFiles
Definition savefilemct.h:322
int mStep
Definition savefilemct.h:313
virtual void OnClose(CloseOp *pOp)
HxStr mDirName
Definition savefilemct.h:304
HxStr mIconTitle
Definition savefilemct.h:310
const void * mData
Definition savefilemct.h:316
void BuildIconSys(const char *pszTitle)
Fill mIconSys with the browser icon header.
Measure the kilobytes a SaveFileMCT's files need beyond the space they occupy on the card now.
Definition savespacecheckermct.h:27
Write to an open memory-card file.
Definition writeop.h:14
constexpr int kSaveFileMinimumFreeClusters
Free clusters SavePersonasMCT, SaveGlobalSettingsMCT, and SaveJukeboxPlayListMCT require before they ...
Definition savefilemct.h:78
SaveFileStep
Steps SaveFileMCT::mStep selects between.
Definition savefilemct.h:60
@ kSaveFileStepCreateDir
Definition savefilemct.h:61
@ kSaveFileStepWriteData
Definition savefilemct.h:69
@ kSaveFileStepOpenIconSys
Definition savefilemct.h:62
@ kSaveFileStepWriteIconImage
Definition savefilemct.h:65
@ kSaveFileStepWriteIconSys
Definition savefilemct.h:63
@ kSaveFileStepOpenIconImage
Definition savefilemct.h:64
@ kSaveFileStepReport
Definition savefilemct.h:70
@ kSaveFileStepWriteMarker
Definition savefilemct.h:67
@ kSaveFileStepOpenMarker
Definition savefilemct.h:66
@ kSaveFileStepDone
Definition savefilemct.h:71
@ kSaveFileStepOpenData
Definition savefilemct.h:68
constexpr int kIconTitleBufferSize
Bytes the Shift-JIS title buffer reserves on the stack for BuildIconSys() to fill.
Definition savefilemct.h:82