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 EnterRepeatCounter = 0; // restart Enter repeat counter
31 SnikSnaksElectronsFrozen = 0; // Snik-Snaks and Electrons move!
33 SplitMoveFlag = 0; // Reset Split-through-ports
34 RedDiskReleasePhase = 0; // (re-)enable red disk release
35 RedDiskReleaseMurphyPos = 0; // Red disk was released here
39 // ==========================================================================
41 // Locate Murphy and init location.
42 // ==========================================================================
48 for (si = 0; si <= LevelMax - 1; si++)
49 if (PlayField16[si] == fiMurphy)
57 void InitMurphyPosB(int si)
59 MurphyYPos = GetStretchY(si) / Stretch;
60 MurphyXPos = GetStretchX(si) / Stretch;
62 MurphyScreenXPos = GetStretchX(si); // Murphy's screen x-position
63 MurphyScreenYPos = GetStretchY(si); // Murphy's screen y-position
65 // To Do: draw Murphy in location ax
66 DDSpriteBuffer_BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0);
68 MurphyScreenXPos = MurphyScreenXPos / Stretch;
69 MurphyScreenYPos = MurphyScreenYPos / Stretch;
71 subCalculateScreenScrollPos(); // calculate screen start addrs
76 SoftScrollTo(ScreenScrollXPos, ScreenScrollYPos, 1000, 25);
78 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
83 // ==========================================================================
85 // Convert to easy symbols and reset Infotron count If not ThenVer62
86 // ==========================================================================
88 int subConvertToEasySymbols()
90 int ax, bx, cx, dx, i;
101 if (al == 0xF1) // converted explosion?
103 MovLowByte(&PlayField16[i], 0x1F); // restore explosions
107 if (LowByte(GameBusyFlag) != 1) // free screen write?
109 if (ax == fiInfotron) // Infotron? -> yes--count!
112 if (ax == fiSnikSnak) // Snik Snak? -> yes--rearrange
115 if (ax == fiElectron) // Electron? -> yes--rearrange
119 // test for fancy RAM Chips:
120 if (ax == fiRAMLeft || ax == fiRAMRight)
123 if (ax == fiRAMTop || ax == fiRAMBottom)
126 if (ax < fiHWFirst) // All but deco hardware?
129 if (ax < fiRAMTop) // Decorative hardware?
133 if (ax < fiSpPortRight) // Gravity change ports only?
136 if (ax < fiSnikSnak) // Gravity change port! 'loc_g_2702:
141 loc_g_2704: // INFOTRON
142 dx = dx + 1; // Count Infotrons
145 loc_g_2707: // DECO RAM CHIPS
146 PlayField16[i] = fiRAM; // Convert to standard RAM chip
149 loc_g_270D: // DECO HARDWARE
150 PlayField16[i] = fiHardWare; // Convert to standard hardware
153 loc_g_2713: // SNIK-SNAK
154 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
157 MovHighByte(&PlayField16[i], 1); // turn left, step = NorthWest
161 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
164 PlayField16[i - FieldWidth] = 0x1011; // SnikSnak accessing from below, step = 0
165 PlayField16[i] = 0xFFFF;
169 if (PlayField16[i + 1] != 0) // 1 field right empty? -> point up
172 PlayField16[i + 1] = 0x2811; // SnikSnak accessing from left, step = 0
173 PlayField16[i] = 0xFFFF;
176 loc_g_2741: // ELECTRON
177 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
180 MovHighByte(&PlayField16[i], 1);
184 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
187 PlayField16[i - FieldWidth] = 0x1018; // 1 field up
188 PlayField16[i] = 0xFFFF;
192 if (PlayField16[i + 1] != 0) // 1 field right empty? -> no--point down
195 PlayField16[i + 1] = 0x2818;
196 PlayField16[i] = 0xFFFF;
199 loc_g_276F: // GRAVITY CHANGING PORTS
200 PlayField16[i] = (ax - 4) | 0x100; // Convert to standard ports
204 i = i + 1; // Next field
207 if (0 < cx) // Until all done 'loc_g_2782:
210 return dx; // return InfotronCount
214 // ==========================================================================
216 // Reset Infotron count. Call immediately after subConvertToEasySymbols
217 // ==========================================================================
219 void ResetInfotronsNeeded(int dx)
221 if (LInfo.InfotronsNeeded != 0) // Jump If equal (autodetect)
222 dx = LInfo.InfotronsNeeded;
224 InfotronsNeeded = LowByte(dx); // Remaining Infotrons needed
225 TotalInfotronsNeeded = InfotronsNeeded; // Number of Infotrons needed
229 // ==========================================================================
231 // Fetch and initialize a level
232 // ==========================================================================
234 void subFetchAndInitLevelB()
236 subFetchAndInitLevelA();
239 void subFetchAndInitLevelA()
241 GameBusyFlag = 0; // restore scissors too
243 subFetchAndInitLevel(); // Fetch and initialize a level
245 GameBusyFlag = 1; // no free screen write
247 DemoKeyCode = 0; // delete last demo key!
250 void subFetchAndInitLevel()
252 int InfoCountInLevel;
254 ReadLevel(); // Read LEVELS.DAT
256 GameBusyFlag = -GameBusyFlag; // make <>1
258 InfoCountInLevel = subConvertToEasySymbols(); // Convert to easy symbols
260 GameBusyFlag = -GameBusyFlag; // restore
262 subDisplayLevel(); // Paint (Init) game field
264 ResetInfotronsNeeded(InfoCountInLevel); // and reset Infotron count
266 subInitGameConditions(); // Init game conditions (vars)
268 InitMurphyPos(); // Locate Murphy + screen pos