Bloody Paws Snow Bug Fix ======================== Author: Flavio M. Matsumoto reikainosuke-tk@yahoo.com.br, http://cantinhotk90x.blogspot.com.br Date: 08/20/2012 Bloody Paws has a bug that cause the 'snow' effect in the screen. When IM 2 is activated with I register in the range 64-127, ULA is confused and shows noises in the screen. This bug does not affect machine code execution and game can be played normally, but this effect is visually very annoying. The program disassembly reveals forbidden value (93 or #5D) being attributed for I register: 24000 LD SP,24000 24003 DI 24004 LD A,#5D 24006 LD I,A 24008 IM 2 24010 XOR A The value of assembly instruction operand at 24004 must be replaced by any value greater than #7F. The chosen value was #FB because the RAM in the #FB00-#FC00 range was empty. The instruction at 24004 has been altered to: 24004 LD A,#FB In IM 2, the most significant byte (MSB) of the interrupt vector is the value of I register and the least significant byte (LSB) is read from data bus. Owing to the push-up resistors present in the data bus, the LSB is usually 255 (#FF), but it can return any other values because noise can be left by some device (mainly ULA). Programmer of Bloody Paws erroneously assumed that LSB will always be 255, but this is wrong! The proper way to handle interrupts would be making an interrupt vector table in the RAM, containing all possible values of LSB. Moreover, the interrupt routine address must be symmetrical because LSB can assume even or odd value. To prepare interrupt vector table, the RAM located at #FB00-#FC00 range was chosen because it was empty. Address #FAFA was also empty and was chosen to hold the interrupt routine that consists only by 'JP #FEF6' instruction (#FEF6 is the beginning of program's real interrupt routine).