ScummVM API documentation
amiga_decode.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 MACS2_AMIGA_DECODE_H
23 #define MACS2_AMIGA_DECODE_H
24 
25 #include "common/array.h"
26 #include "common/scummsys.h"
27 #include "graphics/palette.h"
28 
29 namespace Macs2 {
30 
31 struct AmigaMxooInfo {
32  uint32 scriptOffset = 0;
33  uint32 stringOffset = 0;
34  uint32 slotOffsets[21];
35  uint32 extraOffset = 0;
36  uint32 bodyOffset = 12; // start of body within MXOO
37  uint32 bodySize = 0;
38 
39  AmigaMxooInfo() {
40  for (uint i = 0; i < 21; i++)
41  slotOffsets[i] = 0xFFFFFFFF;
42  }
43 };
44 
46  uint16 frameCount = 0;
47  uint16 width = 0;
48  uint16 height = 0;
49  uint16 seqPos = 0;
50  uint16 repeatCounter = 0;
51  uint16 loopStart = 0;
52  uint16 headerHint = 0;
53  uint32 pixelOffset = 0; // absolute offset in MXOO of first planar byte
54  uint32 headerSize = 0; // bytes from slot start to pixel data
55  bool valid = false;
56 };
57 
58 bool parseAmigaMxoo(const byte *mxoo, uint32 mxooSize, AmigaMxooInfo &out);
59 bool inspectAmigaAnimSlot(const byte *mxoo, uint32 mxooSize, uint32 bodyRelativeOffset, AmigaAnimSlotInfo &out);
60 void amiga12ToVga6(uint16 rgb, byte &r6, byte &g6, byte &b6);
61 byte remapAmigaCopperIndexToStableUi(byte color);
62 bool decodeAmigaPlanarFrame(const byte *planar, uint16 width, uint16 height, uint16 frameIndex,
63  uint16 frameCount, Common::Array<byte> &outPixels);
64 bool convertAmigaAnimSlotToDosBlob(const byte *mxoo, uint32 mxooSize, uint32 bodyRelativeOffset,
65  Common::Array<byte> &outBlob);
66 bool extractAmigaScript(const byte *mxoo, uint32 mxooSize, Common::Array<byte> &outScript);
67 bool extractAmigaStringBlock(const byte *mxoo, uint32 mxooSize, Common::Array<byte> &outStrings);
68 bool convertAmigaSimpleSpriteToDosBlob(const byte *mxoo, uint32 mxooSize, Common::Array<byte> &outBlob);
69 bool convertAmigaPortraitAtlasToDosBlob(const byte *mxoo, uint32 mxooSize, uint32 bodyRelativeExtraOffset,
70  Common::Array<byte> &outBlob);
71 
72 enum : uint32 {
73  kAmigaSceneWidth = 320,
74  kAmigaSceneHeight = 200,
75  kAmigaScenePlanes = 6,
76  kAmigaSceneScreenSize = 54432,
77  kAmigaSceneCopperOffset = 0xBB80,
78  kAmigaSceneCopperSize = 0x1920, // 16 base colors + 200x16 line colors
79  kAmigaSceneCopperColorCount = 16,
80  kAmigaSceneCopperLineBytes = kAmigaSceneCopperColorCount * 2, // 16 x u16BE
81  kAmigaSceneCopperBaseBytes = kAmigaSceneCopperLineBytes, // static COLOR0..15 before per-line colors
82  kAmigaScenePlaneBytes = 8000, // 40x200
83  kAmigaColorRegisterCount = 32,
84  kAmigaEhbPaletteCount = 64,
85 
87  kAmigaMxmmHeaderSize = 10,
88  kAmigaMxmmMinSize = kAmigaMxmmHeaderSize + 4,
89 
90  kAmigaMxmmWordSize = 2, // u16BE count / preamble
91  kAmigaMxmmTrailerPreambleSize = kAmigaMxmmWordSize,
92  kAmigaMxmmPathfindingNodeCount = 16,
93  kAmigaMxmmPathfindingNodeSize = 10,
94  kAmigaMxmmPathfindingMaxAdj = 4,
95  kAmigaMxmmPathfindingNodeXOffset = 0,
96  kAmigaMxmmPathfindingNodeYOffset = 2,
97  kAmigaMxmmPathfindingNodeAdjOffset = 4,
98  kAmigaMxmmPathfindingNodeConnOffset = 8,
99  kAmigaMxmmPathfindingTableSize = kAmigaMxmmWordSize +
100  kAmigaMxmmPathfindingNodeCount * kAmigaMxmmPathfindingNodeSize, // 0xA2
101  kAmigaMxmmHotspotColorBytes = 0x20,
102  kAmigaMxmmHotspotTableSize = kAmigaMxmmWordSize + kAmigaMxmmHotspotColorBytes, // 0x22
103  kAmigaMxmmWalkPaletteSize = 10, // 5 x u16BE
104  kAmigaMxmmWalkDepthThresholdYOffset = 0,
105  kAmigaMxmmWalkDepthScaleFactorOffset = 2,
106  kAmigaMxmmWalkBaseSpeedPctOffset = 4,
107  kAmigaMxmmWalkScenePaletteModeOffset = 6,
108  kAmigaMxmmWalkPaletteDarkenPercentOffset = 8,
109  kAmigaMxmmPathfindingToHotspotOffset = kAmigaMxmmPathfindingTableSize + kAmigaMxmmTrailerPreambleSize,
110  kAmigaMxmmPathfindingToWalkOffset = kAmigaMxmmPathfindingToHotspotOffset + kAmigaMxmmHotspotTableSize,
111  kAmigaMxmmTrailerTablesSize = kAmigaMxmmTrailerPreambleSize + kAmigaMxmmPathfindingTableSize +
112  kAmigaMxmmTrailerPreambleSize + kAmigaMxmmHotspotTableSize +
113  kAmigaMxmmWalkPaletteSize,
114 
115  kAmigaMxccVersionOffset = 4,
116  kAmigaMxccMarkerOffset = 5,
117  kAmigaMxccRowTableOffset = 0x0A,
118  kAmigaMxccRowDataOffset = kAmigaMxccRowTableOffset + kAmigaSceneHeight * 2 // 0x19A
119 };
120 
121 bool decodeAmigaMxmmSceneBackground(const byte *mxmm, uint32 mxmmSize,
122  Common::Array<byte> &outPixels,
123  Graphics::Palette &outPalette,
124  uint &outColorCount,
125  Common::Array<byte> &outLineCopperPal);
126 
127 bool extractAmigaMxmmSceneScript(const byte *mxmm, uint32 mxmmSize,
128  Common::Array<byte> &outScript,
129  Common::Array<byte> &outStrings);
130 
131 bool extractAmigaMxmmSceneWalkParams(const byte *mxmm, uint32 mxmmSize,
132  uint16 &outWalkDepthThresholdY,
133  uint16 &outWalkDepthScaleFactor,
134  uint16 &outWalkBaseSpeedPct,
135  uint16 &outScenePaletteMode,
136  uint16 &outPaletteDarkenPercent);
137 
139  uint16 x = 0;
140  uint16 y = 0;
141  byte adjacent[kAmigaMxmmPathfindingMaxAdj] = {};
142  uint16 numConnections = 0;
143 };
144 
145 bool extractAmigaMxmmScenePathfinding(const byte *mxmm, uint32 mxmmSize,
146  uint16 &outNumPoints,
148 
149 bool extractAmigaMxmmSceneMaps(const byte *mxmm, uint32 mxmmSize,
150  Common::Array<byte> &outPathfinding,
151  Common::Array<byte> &outDepth,
152  Common::Array<byte> &outShadow);
153 
154 bool extractAmigaMxmmSceneHotspotColors(const byte *mxmm, uint32 mxmmSize,
155  uint16 &outNumHotspots,
156  Common::Array<uint16> &outColorTable);
157 
158 bool extractAmigaMxmmMxccHotspotMap(const byte *mxmm, uint32 mxmmSize,
159  Common::Array<byte> &outHotspotMap);
160 
161 bool amigaMxmmHasMxaaOverlay(const byte *mxmm, uint32 mxmmSize);
162 
164  byte ascii = 0;
165  uint16 width = 0;
166  uint16 height = 0;
167  Common::Array<byte> pixels; // width * height
168 };
169 
170 bool decodeAmigaMxffFont(const byte *mxff, uint32 mxffSize, Common::Array<AmigaMxffGlyph> &outGlyphs);
171 
172 bool extractAmigaMxosPcm(const byte *mxos, uint32 mxosSize, Common::Array<byte> &outPcm, uint16 &outRateHz);
173 
174 } // End of namespace Macs2
175 
176 #endif // MACS2_AMIGA_DECODE_H
Definition: amiga_decode.h:163
Definition: amiga_decode.h:138
Definition: amiga_decode.h:31
Definition: amiga_decode.h:45
Simple class for handling a palette data.
Definition: palette.h:61
Definition: actionbar.h:31