forked from libretro/vemulator-libretro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash.h
107 lines (79 loc) · 2.76 KB
/
flash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
VeMUlator - A Dreamcast Visual Memory Unit emulator for libretro
Copyright (C) 2018 Mahmoud Jaoune
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _FLASH_H_
#define _FLASH_H_
#include <string.h>
#include <streams/file_stream.h>
#include "common.h"
#include "flashfile.h"
#include "ram.h"
class VE_VMS_FLASH
{
public:
VE_VMS_FLASH(VE_VMS_RAM *_ram);
~VE_VMS_FLASH();
///Loads raw VMS data to be easily accessed.
//romType 0: Memory Dump (.bin)
//romType 1: VMS file
//romType 2: DCI file
void loadROM(byte *d, size_t buffSize, int romType, const char *fileName, bool enableSave);
///Returns raw VMS data and its size
size_t getROM(byte *out);
///Returns data
size_t getData(byte *out);
//Operations
///Returns byte at address. (No banking)
byte getByte(size_t address);
///Returns byte at address (With banking)
byte readByte(size_t address);
//Returns int16 at address (Little-endian)
int getWord(size_t address);
///Writes int to address
void writeByte(size_t address, byte d);
//Writes int to raw address
void writeByte_RAW(size_t address, byte d);
///Writes int16 to address (Little-endian)
void writeWord(size_t address, byte d);
///Get block data (512)
void readBlock(int blockNumber, byte *out);
///Write data to block (512)
void writeBlock(int blockNumber, byte *in);
///Checks if card is corrupt
bool IsCorrupt();
///Counts files in directory
int countFiles();
//File operations
///Get file info from directory depending on its index
VE_VMS_FLASH_FILE getFileAt(int index);
///Get file info from directory depending on its name
VE_VMS_FLASH_FILE getFile(const char *name);
///Counts number of mini-games found in ROM
int countGames();
//FAT operations
///Get data of file from FAT FS
size_t getFileData(VE_VMS_FLASH_FILE fileinfo, byte *out);
private:
//File structure
byte *userData;
byte *directory;
byte *FAT;
byte *rootBlock;
byte *data;
RFILE *flashWriter;
bool IsRealFlash;
bool IsSaveEnabled;
VE_VMS_RAM *ram;
};
#endif // _FLASH_H_