Resource centre for ZX Spectrum games
using Manic Miner and Jet Set Willy game engines
Archive of the
Manic Miner & Jet Set Willy Yahoo! Group
messages
|
|
||
|
|
Message: 7132
Author: ian.rushforth
Date: 08/08/2017
Subject: Room Setup vs Main Loop Patch Vectors
I've just been reading Andrew Broad's Technical Notes for his game 'JSW64 MM: James Bond'. Here is an excerpt, relating to room 10 'Moonraker':
> 11. Patch-vector to clear individual pixel-rows on the screen (1:#E900-E929)
-------------------------------------------------------------
> Thanks to John Elliott fixing a bug in the JSW64:Z engine, this patch-vector is no longer needed, but this > section may be a useful reference for drawing ad-hoc pixels on the screen via the primary pixel-buffer
> (#7000-7FFF).
> "Moonraker" [10] uses global cell-class 13 for Earth which is meant to be blank, but due to an bug in the
> JSW64:Z engine (which has now been fixed), it had the pixel-pattern of cell-class 1 (Water). This was a
> problem because guardians that are meant to pass harmlessly through these Earth-cells would collide with
> them.
> My solution was a main-loop patch-vector that blanked out individual pixel-rows that would cause a collision.
> At the time that the JSW64 engine calls the main-loop patch-vector, the pixels to be written to the top two
> thirds of the screen (#4000-4FFF) are in the primary pixel-buffer (#7000-7FFF), so that's where the patch-
> vector needed to alter them.
In fact, I believe the clearing of pixels from the primary pixel-buffer only needs to be done once, and is therefore best achieved via a Room Setup Patch Vector, rather than the Main Loop Patch Vector (which will needlessly clear already-blank bytes in all subsequent game 'ticks' after the first one upon entry to the room).
Not only would using a Room Setup Patch slightly speed up the running of the game in that room, it would also prevent a theoretical collision between a guardian and the pixels in question, in the first time-frame upon entry to that room. (In the first time-frame, before the Main Loop Patch is enacted, there would be one iteration of the errant pixels being copied from the primary to the secondary pixel-buffer, and then one enactment of the 'Draw the guardians' routine. Evidently this wasn't a problem in 'Moonraker' [even before John Elliott fixed the game engine bug referred to above] - presumably the initial position of the guardians in question didn't coincide with the room cells that contained the errant pixels?)
