1 // ----------------------------------------------------------------------------
2 // InitGameConditions.c
3 // ----------------------------------------------------------------------------
5 #include "InitGameConditions.h"
8 // ==========================================================================
10 // Init game conditions (variables)
11 // ==========================================================================
13 void subInitGameConditions()
15 MurphyVarFaceLeft = 0;
16 KillMurphyFlag = 0; // no "kill Murphy"
18 LeadOutCounter = 0; // quit flag: lead-out counter
19 RedDiskCount = 0; // Red disk counter
21 YawnSleepCounter = 0; // Wake up sleeping Murphy
23 ExplosionShake = 0; // Force explosion flag off
25 TerminalMaxCycles = 0x7F;
26 YellowDisksExploded = 0;
30 SnikSnaksElectronsFrozen = 0; // Snik-Snaks and Electrons move!
32 SplitMoveFlag = 0; // Reset Split-through-ports
33 RedDiskReleasePhase = 0; // (re-)enable red disk release
34 RedDiskReleaseMurphyPos = 0; // Red disk was released here
38 // ==========================================================================
40 // Locate Murphy and init location.
41 // ==========================================================================
47 for (si = 0; si < LevelMax; si++)
48 if (PlayField16[si] == fiMurphy)
56 void InitMurphyPosB(int si)
58 MurphyScreenXPos = MurphyXPos = GetStretchX(si); // Murphy's screen x-position
59 MurphyScreenYPos = MurphyYPos = GetStretchY(si); // Murphy's screen y-position
61 // To Do: draw Murphy in location ax
62 DDSpriteBuffer_BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0);
64 subCalculateScreenScrollPos(); // calculate screen start addrs
69 SoftScrollTo(ScreenScrollXPos, ScreenScrollYPos, 1000, 25);
71 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
76 // ==========================================================================
78 // Convert to easy symbols and reset Infotron count If not ThenVer62
79 // ==========================================================================
81 int subConvertToEasySymbols()
83 int ax, bx, cx, dx, i;
94 if (al == 0xF1) // converted explosion?
96 MovLowByte(&PlayField16[i], 0x1F); // restore explosions
100 if (LowByte(GameBusyFlag) != 1) // free screen write?
102 if (ax == fiInfotron) // Infotron? -> yes--count!
105 if (ax == fiSnikSnak) // Snik Snak? -> yes--rearrange
108 if (ax == fiElectron) // Electron? -> yes--rearrange
112 // test for fancy RAM Chips:
113 if (ax == fiRAMLeft || ax == fiRAMRight)
116 if (ax == fiRAMTop || ax == fiRAMBottom)
119 if (ax < fiHWFirst) // All but deco hardware?
122 if (ax < fiRAMTop) // Decorative hardware?
126 if (ax < fiSpPortRight) // Gravity change ports only?
129 if (ax < fiSnikSnak) // Gravity change port! 'loc_g_2702:
134 loc_g_2704: // INFOTRON
135 dx = dx + 1; // Count Infotrons
138 loc_g_2707: // DECO RAM CHIPS
139 PlayField16[i] = fiRAM; // Convert to standard RAM chip
142 loc_g_270D: // DECO HARDWARE
143 PlayField16[i] = fiHardWare; // Convert to standard hardware
146 loc_g_2713: // SNIK-SNAK
147 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
150 MovHighByte(&PlayField16[i], 1); // turn left, step = NorthWest
154 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
157 PlayField16[i - FieldWidth] = 0x1011; // SnikSnak accessing from below, step = 0
158 PlayField16[i] = 0xFFFF;
162 if (PlayField16[i + 1] != 0) // 1 field right empty? -> point up
165 PlayField16[i + 1] = 0x2811; // SnikSnak accessing from left, step = 0
166 PlayField16[i] = 0xFFFF;
169 loc_g_2741: // ELECTRON
170 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
173 MovHighByte(&PlayField16[i], 1);
177 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
180 PlayField16[i - FieldWidth] = 0x1018; // 1 field up
181 PlayField16[i] = 0xFFFF;
185 if (PlayField16[i + 1] != 0) // 1 field right empty? -> no--point down
188 PlayField16[i + 1] = 0x2818;
189 PlayField16[i] = 0xFFFF;
192 loc_g_276F: // GRAVITY CHANGING PORTS
193 PlayField16[i] = (ax - 4) | 0x100; // Convert to standard ports
197 i = i + 1; // Next field
200 if (0 < cx) // Until all done 'loc_g_2782:
203 return dx; // return InfotronCount
207 // ==========================================================================
209 // Reset Infotron count. Call immediately after subConvertToEasySymbols
210 // ==========================================================================
212 void ResetInfotronsNeeded(int dx)
214 if (LInfo.InfotronsNeeded != 0) // Jump If equal (autodetect)
215 dx = LInfo.InfotronsNeeded;
217 InfotronsNeeded = LowByte(dx); // Remaining Infotrons needed
218 TotalInfotronsNeeded = InfotronsNeeded; // Number of Infotrons needed
222 // ==========================================================================
224 // Fetch and initialize a level
225 // ==========================================================================
227 void subFetchAndInitLevelB()
229 subFetchAndInitLevelA();
232 void subFetchAndInitLevelA()
234 GameBusyFlag = 0; // restore scissors too
235 subFetchAndInitLevel(); // fetch and initialize a level
236 GameBusyFlag = 1; // no free screen write
238 DemoKeyCode = 0; // delete last demo key!
241 void subFetchAndInitLevel()
243 int InfoCountInLevel;
245 PrepareLevel(); // initialize level data
247 GameBusyFlag = -GameBusyFlag; // make != 1
248 InfoCountInLevel = subConvertToEasySymbols(); // convert to easy symbols
249 GameBusyFlag = -GameBusyFlag; // restore
251 subDisplayLevel(); // paint (init) game field
253 ResetInfotronsNeeded(InfoCountInLevel); // and reset Infotron count
255 subInitGameConditions(); // init game conditions (vars)
257 InitMurphyPos(); // locate Murphy + screen pos