-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpack.h
62 lines (51 loc) · 1.79 KB
/
pack.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
/****************************************************************
* PackScan: An SFC memory pack dump analysis tool.
*
* Written by Andrew Henderson ([email protected]).
*
* This code is open source and licensed under the GPLv3. Please
* review the LICENSE file for the details if you would like to
* use this source code in your own projects.
***************************************************************/
#ifndef __PACK_H__
#define __PACK_H__
#include <string>
#include <vector>
#include <cstdint>
class Pack {
public:
Pack(const char *filename);
~Pack();
bool isLoaded(void) { return mIsLoaded; }
void analyze(void);
std::string generateReport(const bool color);
private:
std::vector<uint8_t> mPackData;
std::string mFilename;
bool mIsLoaded;
enum PackSize_t {
INVALID = 0,
SIZE_8M = (1024 * 1024),
SIZE_32M = (4 * 1024 * 1024)
} mPackSize;
typedef struct {
uint32_t address; /* Address of header in pack */
uint8_t licensee[2]; /* xFB0-xFB1 */
uint8_t programType[4]; /* xFB2-xFB5 */
uint8_t title[17]; /* xFC0-xFCF (plus NUL) */
uint8_t blockAlloc[4]; /* xFD0-xFD3 */
uint8_t starts[2]; /* xFD4-xFD5 */
uint8_t dateMonth; /* xFD6 */
uint8_t dateDay; /* xFD7 */
uint8_t speedMap; /* xFD8 */
uint8_t fileType; /* xFD9 */
uint8_t maker; /* xFDA */
uint8_t version; /* xFDB */
uint16_t invChksum; /* xFDC-xFDD */
uint16_t chksum; /* xFDE-xFDF */
} Header_t;
std::vector<Header_t> mBlockHeader;
bool validHeader(const uint32_t block, const bool LoROM, Pack::Header_t *header);
uint16_t calcCRC(const Header_t *header);
};
#endif /* __PACK_H__ */