ScummVM API documentation
file_nes.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCUMM_FILE_NES_H
23 #define SCUMM_FILE_NES_H
24 
25 #include "scumm/file.h"
26 #include "common/array.h"
27 
28 namespace Scumm {
29 
30 class ScummNESFile : public BaseScummFile {
31 public:
32  enum ROMset {
33  kROMsetUSA,
34  kROMsetEurope,
35  kROMsetSweden,
36  kROMsetFrance,
37  kROMsetGermany,
38  kROMsetSpain,
39  kROMsetItaly,
40  kROMsetNum
41  };
42 
43  struct Resource;
44  struct ResourceGroup;
45  struct LFLEntry;
46  struct LFL;
47 
48  enum ResType {
49  NES_UNKNOWN,
50  NES_GLOBDATA,
51  NES_ROOM,
52  NES_SCRIPT,
53  NES_SOUND,
54  NES_COSTUME,
55  NES_ROOMGFX,
56  NES_COSTUMEGFX,
57  NES_SPRPALS,
58  NES_SPRDESC,
59  NES_SPRLENS,
60  NES_SPROFFS,
61  NES_SPRDATA,
62  NES_CHARSET,
63  NES_PREPLIST,
64  NES_TITLES,
65  NES_TITLE2_SPARKLECHR,
66  NES_TITLE2_SPARKLEPAL,
67  };
68 
69 
70  struct NESTitleScreen {
71  uint16 unk1;
72  uint16 unk2;
73  byte numberOfTiles;
75  uint16 unk3;
76  byte unk4;
77  byte width;
78  byte height;
79  Common::Array<byte> nametable;
80  uint16 unk5;
81  byte unk6;
82  byte attrWidth;
83  byte attrHeight;
84  Common::Array<byte> attributes;
85  byte stepNum;
86  Common::Array<byte> palette;
87  byte endOfData;
88  };
89 
90  bool decodeTitleScreen(uint titleIndex, NESTitleScreen &outTitle);
91  bool readTitle2SparkleChr(Common::Array<byte> &outChr);
92  bool readTitle2SparklePalette(Common::Array<byte> &outPalette);
93 
94 
95 private:
97  ROMset _ROMset;
98  byte *_buf;
99 
100  bool generateIndex();
101  bool generateResource(int res);
102  uint16 extractResource(Common::WriteStream *out, const Resource *res, ResType type);
103 
104  byte fileReadByte();
105  void decodeTitleRLE(Common::Array<byte> &dst, uint32 expectedSize);
106  uint16 fileReadUint16LE();
107 
108 public:
109  ScummNESFile();
110 
111  bool open(const Common::Path &filename) override;
112  bool openSubFile(const Common::Path &filename) override;
113 
114  void close() override;
115  bool eos() const override { return _stream->eos(); }
116  int64 pos() const override { return _stream->pos(); }
117  int64 size() const override { return _stream->size(); }
118  bool seek(int64 offs, int whence = SEEK_SET) override { return _stream->seek(offs, whence); }
119  uint32 read(void *dataPtr, uint32 dataSize) override;
120 };
121 
122 } // End of namespace Scumm
123 
124 #endif
virtual int64 size() const =0
Definition: file_nes.h:30
virtual int64 pos() const =0
Definition: stream.h:77
virtual bool seek(int64 offset, int whence=SEEK_SET)=0
virtual bool eos() const =0
Definition: path.h:52
bool eos() const override
Definition: file_nes.h:115
Definition: stream.h:745
int64 pos() const override
Definition: file_nes.h:116
uint32 read(void *dataPtr, uint32 dataSize) override
bool seek(int64 offs, int whence=SEEK_SET) override
Definition: file_nes.h:118
int64 size() const override
Definition: file_nes.h:117
Definition: actor.h:30
Definition: file_nes.h:70
Definition: file.h:36