http://metopal.com/2012/03/24/porting-the-kill-screen/ (NES version)
What I would like to do is to be able to fix the NES Donkey Kong's kill screen, but what I wish to do is to base my fix on how Don Hodges did so for the arcade version which went like so, so that in the event of an overflow, such a result will not be written back to memory:
Code: Select all
000F7A 3A2962 LD A,(#6229) ; load A with the level number
000F7D FE04 CP #04 ; is the level number >= 4?
000F7F 3802 JR C,#0F83 ; if not, jump ahead and compute bonus normally
000F81 3E04 LD A,#04 ; if it is, then set A = 4
000F83 47 LD B,A ; copy A into B
000F84 A7 AND A ; clear the carry flag
000F85 17 RLA ; rotate left the bits in A
000F86 A7 AND A ; clear the carry flag
000F87 17 RLA ; rotate left the bits in A
000F88 A7 AND A ; clear the carry flag
000F89 17 RLA ; rotate left the bits in A
000F8A 80 ADD A,B ; A = A + B
000F8B 80 ADD A,B ; A = A + B
000F8C C628 ADD A,#28 ; A = A + #28 (40 decimal)
000F8E 21B062 LD HL,#62B0 ; load HL address to store the result
For your information, here is the relevant code for the NES version:
Code: Select all
; Set Y = level number, append single-tile BKG write of the level number
00CB7E A4 54 LDY $54
00CB80 C8 INY
00CB81 20 D1 F4 JSR $F4D1
; Set sign of BCD bonus as positive (#00 - positive)
00CB84 A9 00 LDA #$00
00CB86 85 2C STA $2C
; Set initial bonus value
; If the level number (Y) is lower than 4, load the bonus value from memory (C207[Y])
; Else, cap it at 8000 (#80 is the BCD value of the hundreds and thousands digits)
00CB88 A9 80 LDA #$80
00CB8A 88 DEY
00CB8B C0 04 CPY #$04
00CB8D 10 03 BPL $CB92
00CB8F B9 07 C2 LDA $C207,Y
00CB92 85 2E STA $2E
Code: Select all
; Set Y = level number
00CB7E A4 54 LDY $54 ; load Y with the level number
; Set initial bonus value derived from level number
; If the level number (Y) is lower than 4 ($03), load the bonus value from memory
00CB80 C9 03 CMP #03 ; are we on level 4 ($03) yet?
00CB82 B0 04 BCS $CB88 ; if not, continue with calculation
00CB84 A0 03 LDY #03 ; otherwise, load Y with 3 (for level 4)
00CB86 84 54 STY $54 ; store in $0054 to make permanent
; append single-tile BKG write of the level number
00CB88 C8 INY ; increment level number
00CB89 20 D1 F4 JSR $F4D1
; set sign of BCD bonus as positive (#00 - positive)
00CB8C A9 00 LDA #$00
00CB8E 85 2C STA $2C
; set initial bonus value
00CB90 A9 80 LDA #$80
00CB92 88 DEY
00CB93 B9 07 C2 LDA $C207,Y
00CB96 85 2E STA $2E
My question is this: which of the existing checks in the NES version's code should I get rid of to make this new fix work properly, please?
~Ben