IRF Posted June 8, 2020 Report Share Posted June 8, 2020 I have taken the liberty of editing the title of this topic from 'The AND instruction' [as it was when started by jetsetdanny] to 'The AND, OR and XOR instructions', to reflect more inclusively the discussions of the use of those instructions in the thread as a whole. This is a good place to mention a cunning use of the OR command - namely something which Norman Sword came up with, to fix the bug in the original Manic Miner game engine whereby crumbling cells can sometimes leave ghosts. The original MM engine clears the bottom pixel-row of a crumbly cell when Willy stands on it, then shifts all the pixel-rows above down by one pixel-row, and then checks the bottom pixel-row - and if it is empty, the program considers that cell to be cleared and replaces the crumbly colour-attribute with the air cell attribute for the current cavern. The problem with that approach is if you have a crumbly cell pixel pattern with a clear (inkless) pixel-row halfway down the cell, with some infilled pixels in the pixel-rows above that blank row - then the program is fooled into turning the crumbly cell to air prematurely, leaving a 'ghost' of the uncleared pixels in the top part of the (now air) cell. Norman Sword rewrote the crumbling cell routine (as discussed elsewhere), so that all eight pixel-rows of a crumbly cell are OR'd together whenever Willy stands on the cell. After clearing the Accumulator (A register), a loop is set up to apply the OR command to all eight bytes representing the bitmaps for each pixel-row of the crumbly cell. (i.e. pixel-row 1 OR pixel-row 2 OR row 3 OR row 4 OR row 5 OR row 6 OR row 7 OR row 8). If a single pixel is infilled in any one of those pixel-rows, then the Zero flag will not be set at the end of the loop. Only if all eight crumbly rows are clear (all eight bytes which are OR'd together hold the value 00) will the Z flag be set - with the outcome that the crumbly cell gets changed to air [by changing the cell's attribute]. In Manic Mixup, I adapted Norman's code, based on the OR command, to be used both in underfoot crumbly cells, and also whenever Willy uses his hard hat to headbutt away an overhead earth block (which causes the pixel-rows to be cleared in the opposite direction i.e. the rows are shifted from the bottom upwards). Spider, jetsetdanny and andrewbroad 3 Quote Link to comment Share on other sites More sharing options...
jetsetdanny Posted June 14, 2020 Author Report Share Posted June 14, 2020 (edited) A cunning use of the OR command, indeed! :) Edited June 14, 2020 by jetsetdanny andrewbroad, Spider and IRF 3 Quote Link to comment Share on other sites More sharing options...
andrewbroad Posted June 15, 2020 Report Share Posted June 15, 2020 I've seen some cunning uses of the Boolean operators in JavaScript, where they have some quirky behaviour when their operands are non-Boolean. Spider and IRF 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.