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
24 ExplosionShakeMurphy = 0; // Force explosion flag off
26 TerminalMaxCycles = 0x7F;
27 YellowDisksExploded = 0;
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; si++)
49 if (PlayField16[si] == fiMurphy)
57 void InitMurphyPosB(int si)
59 MurphyScreenXPos = MurphyXPos = GetStretchX(si); // Murphy's screen x-position
60 MurphyScreenYPos = MurphyYPos = GetStretchY(si); // Murphy's screen y-position
62 // To Do: draw Murphy in location ax
63 DDSpriteBuffer_BltImg(MurphyScreenXPos, MurphyScreenYPos, aniMurphy, 0);
65 subCalculateScreenScrollPos(); // calculate screen start addrs
70 SoftScrollTo(ScreenScrollXPos, ScreenScrollYPos, 1000, 25);
72 ScrollTo(ScreenScrollXPos, ScreenScrollYPos);
77 // ==========================================================================
79 // Convert to easy symbols and reset Infotron count If not ThenVer62
80 // ==========================================================================
82 int subConvertToEasySymbols()
84 int ax, bx, cx, dx, i;
95 if (al == 0xF1) // converted explosion?
97 MovLowByte(&PlayField16[i], 0x1F); // restore explosions
101 if (LowByte(GameBusyFlag) != 1) // free screen write?
103 if (ax == fiInfotron) // Infotron? -> yes--count!
106 if (ax == fiSnikSnak) // Snik Snak? -> yes--rearrange
109 if (ax == fiElectron) // Electron? -> yes--rearrange
113 // test for fancy RAM Chips:
114 if (ax == fiRAMLeft || ax == fiRAMRight)
117 if (ax == fiRAMTop || ax == fiRAMBottom)
120 if (ax < fiHWFirst) // All but deco hardware?
123 if (ax < fiRAMTop) // Decorative hardware?
127 if (ax < fiSpPortRight) // Gravity change ports only?
130 if (ax < fiSnikSnak) // Gravity change port! 'loc_g_2702:
135 loc_g_2704: // INFOTRON
136 dx = dx + 1; // Count Infotrons
139 loc_g_2707: // DECO RAM CHIPS
140 PlayField16[i] = fiRAM; // Convert to standard RAM chip
143 loc_g_270D: // DECO HARDWARE
144 PlayField16[i] = fiHardWare; // Convert to standard hardware
147 loc_g_2713: // SNIK-SNAK
148 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
151 MovHighByte(&PlayField16[i], 1); // turn left, step = NorthWest
155 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
158 PlayField16[i - FieldWidth] = 0x1011; // SnikSnak accessing from below, step = 0
159 PlayField16[i] = 0xFFFF;
163 if (PlayField16[i + 1] != 0) // 1 field right empty? -> point up
166 PlayField16[i + 1] = 0x2811; // SnikSnak accessing from left, step = 0
167 PlayField16[i] = 0xFFFF;
170 loc_g_2741: // ELECTRON
171 if (PlayField16[i - 1] != 0) // 1 field left empty? -> no--try up
174 MovHighByte(&PlayField16[i], 1);
178 if (PlayField16[i - FieldWidth] != 0) // 1 field up empty? -> no--try right
181 PlayField16[i - FieldWidth] = 0x1018; // 1 field up
182 PlayField16[i] = 0xFFFF;
186 if (PlayField16[i + 1] != 0) // 1 field right empty? -> no--point down
189 PlayField16[i + 1] = 0x2818;
190 PlayField16[i] = 0xFFFF;
193 loc_g_276F: // GRAVITY CHANGING PORTS
194 PlayField16[i] = (ax - 4) | 0x100; // Convert to standard ports
198 i = i + 1; // Next field
201 if (0 < cx) // Until all done 'loc_g_2782:
204 return dx; // return InfotronCount
208 // ==========================================================================
210 // Reset Infotron count. Call immediately after subConvertToEasySymbols
211 // ==========================================================================
213 void ResetInfotronsNeeded(int dx)
215 if (LInfo.InfotronsNeeded != 0) // Jump If equal (autodetect)
216 dx = LInfo.InfotronsNeeded;
218 InfotronsNeeded = LowByte(dx); // Remaining Infotrons needed
219 TotalInfotronsNeeded = InfotronsNeeded; // Number of Infotrons needed
223 // ==========================================================================
225 // Fetch and initialize a level
226 // ==========================================================================
228 void subFetchAndInitLevelB()
230 subFetchAndInitLevelA();
233 void subFetchAndInitLevelA()
235 GameBusyFlag = 0; // restore scissors too
236 subFetchAndInitLevel(); // fetch and initialize a level
237 GameBusyFlag = 1; // no free screen write
239 DemoKeyCode = 0; // delete last demo key!
242 void subFetchAndInitLevel()
244 int InfoCountInLevel;
246 PrepareLevel(); // initialize level data
248 GameBusyFlag = -GameBusyFlag; // make != 1
249 InfoCountInLevel = subConvertToEasySymbols(); // convert to easy symbols
250 GameBusyFlag = -GameBusyFlag; // restore
252 subDisplayLevel(); // paint (init) game field
254 ResetInfotronsNeeded(InfoCountInLevel); // and reset Infotron count
256 subInitGameConditions(); // init game conditions (vars)
258 InitMurphyPos(); // locate Murphy + screen pos