Here is a patch for the bug that is seen in Jet Set Willy in non-Black rooms, if a Guardian is present that has a different Brightness setting to the Air cells in that room. e.g. The Flying Pig in Emergency Generator.
The following 'new' code should be added - I suggest you locate it between #96f4 and #970b:
7e e6 38 c2 f2 91 dd 7e 01 e6 0f c6 38 e6 47 4f 7e e6 38 a9 4f c3 fd 91
Then the existing code at #91ee to #91fc should be edited as follows (this is based on the suggested starting address for the new code listed above):
c3 f4 96 00 dd 7e 01 e6 07 4f 7e e6 78 a9 4f
[Bold and strikethrough text in the above represents Danny's previous suggested improvement]
Looking again at the above, there are two bytes which are common to both chunks of code, and located at the substantive end of each ('A9 4F'). So perhaps the new code could be two bytes shorter, jumping back to resume working through the main 'Draw the guardians' routine at the 'A9' command, instead of at the '71' LD (HL), C instruction (at #91FD)?
The more efficient code would go as follows:
'New' code at #96F4 to #9709 [or wherever]:
7e e6 38 c2 f2 91 dd 7e 01 e6 0f c6 38 e6 47 4f 7e e6 38 c3 fb 91
Existing code at #91ee to #91fa edited as follows (the address in italics can be changed accordingly to point at the above 'new' code; the spare NOPped out byte is in bold):
c3 f4 96 00 dd 7e 01 e6 07 4f 7e e6 78
That is then followed by the re-entry point from the 'new' code, at #91fb:
a9 4f ... etc
[Of course, if the additional code could be consolidated to sit inside the main loop, or somewhere within 128 bytes of the source routine, then two of the absolute jumps could be replaced with relative jumps, and one of the absolute jumps could perhaps be done away with altogether, providing a further saving of up to five bytes. But the routine is in quite a 'tight' part of the code.]
Edited by IRF, 13 May 2016 - 06:10 PM.