10 struct EngineSnapshotInfo_SP engine_snapshot_sp;
12 static void init_struct_functions()
14 Stage.Blt = &DDScrollBuffer_Blt;
15 Stage.ScrollTo = &DDScrollBuffer_ScrollTo;
16 Stage.ScrollTowards = &DDScrollBuffer_ScrollTowards;
17 Stage.SoftScrollTo = &DDScrollBuffer_SoftScrollTo;
19 StretchedSprites.BltEx = &DDSpriteBuffer_BltEx;
20 StretchedSprites.BltImg = &DDSpriteBuffer_BltImg;
23 static void init_global_values()
25 menBorder.Checked = False;
26 menPanel.Checked = True;
27 menAutoScroll.Checked = True;
29 MainForm.picPane.Width = picPane.Width = SCR_FIELDX * TILEX;
30 MainForm.picPane.Height = picPane.Height = SCR_FIELDY * TILEY;
35 init_struct_functions();
40 SetBitmaps_SP(&sp_objects);
43 /* too small for oversized levels, but too big for graphics performance */
44 /* (the whole playfield is drawn/updated, not only visible/scrolled area) */
45 /* !!! FIX THIS !!! */
46 screenBitmap = CreateBitmap(60 * TILEX, 24 * TILEY,
49 screenBitmap = CreateBitmap(MAX_BUF_XSIZE * TILEX, MAX_BUF_YSIZE * TILEY,
53 DDSpriteBuffer_CreateFromFile("[NONE]", 16, 16);
60 unsigned int InitEngineRandom_SP(long seed)
62 if (seed == NEW_RANDOMIZE)
65 printf("::: init.c: InitEngineRandom_SP(): subRandomize()\n");
70 seed = (long)RandomSeed;
73 RandomSeed = (short)seed;
76 printf("::: init.c: InitEngineRandom_SP(): RandomSeed == %d\n", RandomSeed);
79 return (unsigned int) seed;
83 /* ------------------------------------------------------------------------- */
84 /* Supaplex game engine snapshot handling functions */
85 /* ------------------------------------------------------------------------- */
87 static ListNode *engine_snapshot_list_sp = NULL;
89 void SaveEngineSnapshotValues_SP()
93 engine_snapshot_sp.game_sp = game_sp;
95 /* these arrays have playfield-size dependent variable size */
97 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
98 engine_snapshot_sp.PlayField16[i] = PlayField16[i];
99 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
100 engine_snapshot_sp.PlayField8[i] = PlayField8[i];
101 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
102 engine_snapshot_sp.DisPlayField[i] = DisPlayField[i];
104 for (i = 0; i < FieldWidth * (FieldHeight - 2); i++)
105 engine_snapshot_sp.AnimationPosTable[i] = AnimationPosTable[i];
106 for (i = 0; i < FieldWidth * (FieldHeight - 2); i++)
107 engine_snapshot_sp.AnimationSubTable[i] = AnimationSubTable[i];
108 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
109 engine_snapshot_sp.TerminalState[i] = TerminalState[i];
111 /* store special data into engine snapshot buffers */
113 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FieldWidth));
114 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FieldHeight));
115 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FieldMax));
116 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(LevelMax));
117 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(FileMax));
119 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(TimerVar));
120 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RandomSeed));
122 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(TerminalMaxCycles));
124 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(mScrollX));
125 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(mScrollY));
126 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(mScrollX_last));
127 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(mScrollY_last));
129 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScreenScrollXPos));
130 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScreenScrollYPos));
131 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMinX));
132 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMinY));
133 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMaxX));
134 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayMaxY));
135 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayWidth));
136 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(DisplayHeight));
138 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(InfotronsNeeded));
139 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(KillMurphyFlag));
140 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyMoveCounter));
141 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyExplodePos));
142 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(SplitMoveFlag));
143 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RedDiskReleaseMurphyPos));
144 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyPosIndex));
145 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyXPos));
146 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyYPos));
147 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyScreenXPos));
148 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyScreenYPos));
149 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MurphyVarFaceLeft));
150 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RedDiskCount));
151 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RedDiskReleaseFlag));
152 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(MovingPictureSequencePhase));
153 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(RedDiskReleasePhase));
154 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScratchGravity));
155 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GravityFlag));
156 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(SnikSnaksElectronsFrozen));
157 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(UpdateTimeFlag));
158 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(UpdatedFlag));
159 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(YellowDisksExploded));
160 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(YawnSleepCounter));
162 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(LeadOutCounter));
164 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GfxElementLast));
165 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GfxGraphicLast));
166 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GfxGraphic));
167 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(GfxFrame));
169 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollMinX));
170 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollMinY));
171 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollMaxX));
172 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollMaxY));
173 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollX));
174 SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(ScrollY));
176 SaveEngineSnapshotBuffer(&PlayField16[-game_sp.preceding_buffer_size],
177 game_sp.preceding_buffer_size * sizeof(int));
180 void LoadEngineSnapshotValues_SP()
184 /* stored engine snapshot buffers already restored at this point */
186 game_sp = engine_snapshot_sp.game_sp;
188 /* these arrays have playfield-size dependent variable size */
190 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
191 PlayField16[i] = engine_snapshot_sp.PlayField16[i];
192 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
193 PlayField8[i] = engine_snapshot_sp.PlayField8[i];
194 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
195 DisPlayField[i] = engine_snapshot_sp.DisPlayField[i];
197 for (i = 0; i < FieldWidth * (FieldHeight - 2); i++)
198 AnimationPosTable[i] = engine_snapshot_sp.AnimationPosTable[i];
199 for (i = 0; i < FieldWidth * (FieldHeight - 2); i++)
200 AnimationSubTable[i] = engine_snapshot_sp.AnimationSubTable[i];
201 for (i = 0; i < FieldWidth * FieldHeight + HeaderSize; i++)
202 TerminalState[i] = engine_snapshot_sp.TerminalState[i];
204 RedrawPlayfield_SP(TRUE);