ScummVM API documentation
ws_cruncher.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef M4_WSCRIPT_WS_CRUNCHER_H
24 #define M4_WSCRIPT_WS_CRUNCHER_H
25 
26 #include "m4/m4_types.h"
27 #include "m4/wscript/ws_machine.h"
28 
29 namespace M4 {
30 
31 #define OP_INSTR 0xfe000000
32 #define OP_FORMAT1 0x01c00000
33 #define OP_FORMAT2 0x00380000
34 #define OP_FORMAT3 0x00070000
35 #define OP_HIGH_DATA 0xffff0000
36 #define OP_LOW_DATA 0x0000ffff
37 #define OP_DATA_SIGN 0x8000
38 #define OP_DATA_VALUE 0x7fff
39 
40 #define FMT_NOTHING 0
41 #define FMT_LOCAL_SRC 1
42 #define FMT_GLOBAL_SRC 2
43 #define FMT_INT15 3
44 #define FMT_4_11 4
45 #define FMT_7_8 5
46 #define FMT_11_4 6
47 #define FMT_15_0 7
48 #define REG_SET_IDX 0x0fff
49 #define REG_SET_IDX_REG 0x8000
50 #define LOCAL_FMT 0x7000
51 #define LOCAL_FMT_PARENT 0x0000
52 #define LOCAL_FMT_REG 0x1000
53 #define LOCAL_FMT_DATA 0x2000
54 
55 #define BRANCH_BR 0
56 #define BRANCH_BLT 1
57 #define BRANCH_BLE 2
58 #define BRANCH_BE 3
59 #define BRANCH_BNE 4
60 #define BRANCH_BGE 5
61 #define BRANCH_BGT 6
62 
63 struct EOSreq {
64  EOSreq *next = nullptr;
65  EOSreq *prev = nullptr;
66  Anim8 *myAnim8 = nullptr;
67 };
68 
69 struct cruncher {
70  Anim8 *backLayerAnim8;
71  Anim8 *frontLayerAnim8;
72  Anim8 *firstAnim8ToCrunch;
73  Anim8 *lastAnim8ToCrunch;
74 };
75 
77  cruncher *_myCruncher = nullptr;
78  bool _cruncherInitialized = false;
79  EOSreq *_EOSreqList = nullptr;
80  int32 _memtypeEOS = -1;
81 
82  int32 _stackSize = 0;
83  uint32 *_stackBase = nullptr;
84  uint32 *_stackTop = nullptr;
85  uint32 *_stackLimit = nullptr;
86  Anim8 *_crunchNext = nullptr;
87 
88  // OPCODE PROCESSING GLOBALS
89  int16 *_myDepthTable = nullptr;
90 
91  frac16 _dataArg1 = 0;
92  frac16 _dataArg2 = 0;
93  frac16 _dataArg3 = 0;
94  frac16 *_myArg1 = nullptr;
95  frac16 *_myArg2 = nullptr;
96  frac16 *_myArg3 = nullptr;
97 
98  bool _keepProcessing = false, _terminated = false, _mapTheCel = false;
99  int32 _compareCCR = 0;
100  int32 _indexReg = 0;
101  int32 _pcOffsetOld = 0;
102 };
103 
104 int32 *ws_GetDataFormats();
105 bool ws_InitCruncher();
106 void ws_KillCruncher();
107 
108 Anim8 *ws_AddAnim8ToCruncher(machine *m, int32 sequHash);
109 
113 bool ws_ChangeAnim8Program(machine *m, int32 newSequHash);
114 
118 void ws_RemoveAnim8FromCruncher(Anim8 *myAnim8);
119 
120 bool ws_PauseAnim8(Anim8 *myAnim8);
121 bool ws_ResumeAnim8(Anim8 *myAnim8);
122 
131 int32 ws_PreProcessPcode(uint32 **PC, Anim8 *myAnim8);
132 
133 void ws_CrunchAnim8s(int16 *depth_table);
134 void ws_CrunchEOSreqs();
135 bool ws_OnEndSeqRequest(Anim8 *myAnim8, int32 pcOffset, int32 pcCount);
136 void ws_CancelOnEndSeq(Anim8 *myAnim8);
137 
138 } // End of namespace M4
139 
140 #endif
Definition: ws_machine.h:130
Definition: ws_cruncher.h:69
int32 ws_PreProcessPcode(uint32 **PC, Anim8 *myAnim8)
Definition: ws_machine.h:92
intptr frac16
Definition: m4_types.h:46
Definition: database.h:28
void ws_RemoveAnim8FromCruncher(Anim8 *myAnim8)
Definition: ws_cruncher.h:63
Definition: ws_cruncher.h:76
bool ws_ChangeAnim8Program(machine *m, int32 newSequHash)