One of the things that's puzzled me is why the hi-score screen for bzone is diagonal and shifted down onto the words BONUS TANK.

It's odd because the hi-score screen for bzonea is perfectly aligned.

bzone
[Linked Image from i.imgur.com]

bzonea
[Linked Image from i.imgur.com]

Apparently, the only difference between bzone and bzonea is the rendering of the hi-score screen text and how many tank icons are displayed.

For bzone, the text is rendered each line as an offset of the line above it.

For bzonea, each line of text has a CNTR command followed by a move.

Any high score above 100K will draw a tank icon in bzone.

Bzonea will draw up to 10 tanks per 100K of hi score, going off the screen to do so. (6 1/2 are visible)
If you have too many hi scores and tanks onscreen it will clip the rendering of the BONUS TANK line as it overloads the AVG.

http://www.vectorlist.org/Vectorlist/2003/07/0046.html Re: bzone and bzone2 roms - whats the diff
http://www.vectorlist.org/Vectorlist/2003/07/0046.html Re: Bug: Battlezone high score rendering


I took a hexdump and diff'ed it and got this:

Code
diff bzone_orighex.txt bzonea_orighex.txt 
55c55
< 00005340  67 45 44 52 a2 00 86 d2  8e 3c 03 bc 00 03 c4 b8  |gEDR.....<......|
---
> 00005340  70 45 44 52 a2 00 86 d2  8e 3c 03 bc 00 03 c4 b8  |pEDR.....<......|
77,86c77,86
< 000054a0  20 98 6c 20 6a 7a a0 00  a9 e0 a2 1a 20 8e 7a a2  | .l jz...... .z.|
< 000054b0  00 8e 40 03 ae 40 03 bd  00 03 85 0a 1d 01 03 f0  |..@..@..........|
< 000054c0  7c bd 01 03 85 0b a9 0a  20 9e 7b a2 1c 20 98 6c  ||....... .{.. .l|
< 000054d0  ae 40 03 bd 1e 03 20 6a  55 ae 40 03 bd 1f 03 20  |.@.... jU.@.... |
< 000054e0  6a 55 ae 40 03 bd 20 03  20 6a 55 a0 00 ae 40 03  |jU.@.. . jU...@.|
< 000054f0  bd 01 03 f0 1a ad f0 33  91 02 c8 ad f1 33 91 02  |.......3.....3..|
< 00005500  c8 ad 90 35 91 02 c8 ad  91 35 91 02 20 76 7a ae  |...5.....5.. vz.|
< 00005510  40 03 e0 1b b0 27 e8 e8  e8 8e 40 03 a9 d8 85 06  |@....'....@.....|
< 00005520  a9 ff 85 07 a9 fe 85 05  98 f0 04 a9 a3 d0 02 a9  |................|
< 00005530  f4 85 04 a9 00 85 01 20  ab 7a 4c b4 54 ad 00 0a  |....... .zL.T...|
---
> 000054a0  20 98 6c 20 6a 7a a0 00  8c 40 03 a9 e0 a2 1e 8e  | .l jz...@......|
> 000054b0  71 03 20 8e 7a ae 40 03  bd 00 03 85 0a 1d 01 03  |q. .z.@.........|
> 000054c0  f0 7b bd 01 03 85 0b a9  0a 20 9e 7b a2 1c 20 98  |.{....... .{.. .|
> 000054d0  6c ae 40 03 bd 1e 03 20  6a 55 ae 40 03 bd 1f 03  |l.@.... jU.@....|
> 000054e0  20 6a 55 ae 40 03 bd 20  03 20 6a 55 a0 00 ae 40  | jU.@.. . jU...@|
> 000054f0  03 bd 01 03 f0 24 aa ad  f0 33 91 02 c8 ad f1 33  |.....$...3.....3|
> 00005500  91 02 e0 0a 90 02 a2 0a  c8 ad 90 35 91 02 c8 ad  |...........5....|
> 00005510  91 35 91 02 ca d0 f1 20  76 7a ae 40 03 e0 1b b0  |.5..... vz.@....|
> 00005520  1c e8 e8 e8 8e 40 03 20  6a 7a ad 71 03 38 e9 0a  |.....@. jz.q.8..|
> 00005530  8d 71 03 aa a9 e0 a0 00  4c b2 54 45 52 ad 00 0a  |.q......L.TER...|


Code
cat bzone_dasm_diff.txt 
54A0: 20 98 6C jsr $6c98					54A0: 20 98 6C jsr $6c98
54A3: 20 6A 7A jsr $7a6a					54A3: 20 6A 7A jsr $7a6a
54A6: A0 00    ldy #$00						54A6: A0 00    ldy #$00
54A8: A9 E0    lda #$e0					      |	54A8: 8C 40 03 sty $0340
54AA: A2 1A    ldx #$1a					      |	54AB: A9 E0    lda #$e0
54AC: 20 8E 7A jsr $7a8e				      |	54AD: A2 1E    ldx #$1e
54AF: A2 00    ldx #$00					      |	54AF: 8E 71 03 stx $0371
54B1: 8E 40 03 stx $0340				      |	54B2: 20 8E 7A jsr $7a8e
54B4: AE 40 03 ldx $0340				      |	54B5: AE 40 03 ldx $0340
54B7: BD 00 03 lda $0300, x				      |	54B8: BD 00 03 lda $0300, x
54BA: 85 0A    sta $0a					      |	54BB: 85 0A    sta $0a
54BC: 1D 01 03 ora $0301, x				      |	54BD: 1D 01 03 ora $0301, x
54BF: F0 7C    beq $553d				      |	54C0: F0 7B    beq $553d
54C1: BD 01 03 lda $0301, x				      |	54C2: BD 01 03 lda $0301, x
54C4: 85 0B    sta $0b					      |	54C5: 85 0B    sta $0b
54C6: A9 0A    lda #$0a					      |	54C7: A9 0A    lda #$0a
54C8: 20 9E 7B jsr $7b9e				      |	54C9: 20 9E 7B jsr $7b9e
54CB: A2 1C    ldx #$1c					      |	54CC: A2 1C    ldx #$1c
54CD: 20 98 6C jsr $6c98				      |	54CE: 20 98 6C jsr $6c98
54D0: AE 40 03 ldx $0340				      |	54D1: AE 40 03 ldx $0340
54D3: BD 1E 03 lda $031e, x				      |	54D4: BD 1E 03 lda $031e, x
54D6: 20 6A 55 jsr $556a				      |	54D7: 20 6A 55 jsr $556a
54D9: AE 40 03 ldx $0340				      |	54DA: AE 40 03 ldx $0340
54DC: BD 1F 03 lda $031f, x				      |	54DD: BD 1F 03 lda $031f, x
54DF: 20 6A 55 jsr $556a				      |	54E0: 20 6A 55 jsr $556a
54E2: AE 40 03 ldx $0340				      |	54E3: AE 40 03 ldx $0340
54E5: BD 20 03 lda $0320, x				      |	54E6: BD 20 03 lda $0320, x
54E8: 20 6A 55 jsr $556a				      |	54E9: 20 6A 55 jsr $556a
54EB: A0 00    ldy #$00					      |	54EC: A0 00    ldy #$00
54ED: AE 40 03 ldx $0340				      |	54EE: AE 40 03 ldx $0340
54F0: BD 01 03 lda $0301, x				      |	54F1: BD 01 03 lda $0301, x
54F3: F0 1A    beq $550f				      |	54F4: F0 24    beq $551a
54F5: AD F0 33 lda $33f0				      |	54F6: AA       tax
54F8: 91 02    sta ($02), y				      |	54F7: AD F0 33 lda $33f0
54FA: C8       iny					      |	54FA: 91 02    sta ($02), y
54FB: AD F1 33 lda $33f1				      |	54FC: C8       iny
54FE: 91 02    sta ($02), y				      |	54FD: AD F1 33 lda $33f1
5500: C8       iny					      |	5500: 91 02    sta ($02), y
5501: AD 90 35 lda $3590				      |	5502: E0 0A    cpx #$0a
5504: 91 02    sta ($02), y				      |	5504: 90 02    bcc $5508
5506: C8       iny					      |	5506: A2 0A    ldx #$0a
5507: AD 91 35 lda $3591				      |	5508: C8       iny
550A: 91 02    sta ($02), y				      |	5509: AD 90 35 lda $3590
550C: 20 76 7A jsr $7a76				      |	550C: 91 02    sta ($02), y
550F: AE 40 03 ldx $0340				      |	550E: C8       iny
5512: E0 1B    cpx #$1b					      |	550F: AD 91 35 lda $3591
5514: B0 27    bcs $553d				      |	5512: 91 02    sta ($02), y
5516: E8       inx					      |	5514: CA       dex
5517: E8       inx					      |	5515: D0 F1    bne $5508
5518: E8       inx					      |	5517: 20 76 7A jsr $7a76
5519: 8E 40 03 stx $0340				      |	551A: AE 40 03 ldx $0340
551C: A9 D8    lda #$d8					      |	551D: E0 1B    cpx #$1b
551E: 85 06    sta $06					      |	551F: B0 1C    bcs $553d
5520: A9 FF    lda #$ff					      |	5521: E8       inx
5522: 85 07    sta $07					      |	5522: E8       inx
5524: A9 FE    lda #$fe					      |	5523: E8       inx
5526: 85 05    sta $05					      |	5524: 8E 40 03 stx $0340
5528: 98       tya					      |	5527: 20 6A 7A jsr $7a6a
5529: F0 04    beq $552f				      |	552A: AD 71 03 lda $0371
552B: A9 A3    lda #$a3					      |	552D: 38       sec
552D: D0 02    bne $5531				      |	552E: E9 0A    sbc #$0a
552F: A9 F4    lda #$f4					      |	5530: 8D 71 03 sta $0371
5531: 85 04    sta $04					      |	5533: AA       tax
5533: A9 00    lda #$00					      |	5534: A9 E0    lda #$e0
5535: 85 01    sta $01					      |	5536: A0 00    ldy #$00
5537: 20 AB 7A jsr $7aab				      |	5538: 4C B2 54 jmp $54b2
553A: 4C B4 54 jmp $54b4				      |	553B: 45 52    eor $52
553D: AD 00 0A lda $0a00					553D: AD 00 0A lda $0a00
5540: 4A       lsr a						5540: 4A       lsr a
5541: 4A       lsr a						5541: 4A       lsr a
5542: 4A       lsr a						5542: 4A       lsr a
5543: 4A       lsr a						5543: 4A       lsr a
5544: 29 03    and #$03						5544: 29 03    and #$03
5546: F0 1C    beq $5564					5546: F0 1C    beq $5564
5548: AA       tax						5548: AA       tax
5549: BD 86 38 lda $3886, x					5549: BD 86 38 lda $3886, x
554C: 18       clc						554C: 18       clc
554D: F8       sed						554D: F8       sed
554E: 69 01    adc #$01						554E: 69 01    adc #$01




So if we change a few memory locations we can get the hiscore of bzone to perfectly match the output of bzonea but there will still be only one tank rendered.


Here's a little lua routine to mimic the self-test routine of bzone:

Code
function hex(a,digits) digits = digits or 2 return string.format("%0"..digits.."x",a) end

mem2=manager:machine():memory().regions[":maincpu"]
mem=mem2

function bzself()
-- self test initializes to 0xff and then xors every byte in each 0x800 block, after each block the value should be zero, skipping blocks 0x4000-0x47ff and 0x4800-0x4fff
for j=0x0,0x9 do o=0xff for i=0x3000+j*0x800,0x3000+j*0x800+0x7ff do o=o~mem:read_u8(i) end print(j,hex(0x3000+j*0x800),o) end -- self test at $7d01
bzmemlocs={0x5530,0x54a9,0x54ab,0x552c,0x5340}
bzmemlocsdesc={
"hiscore horiz move for next line",
"hiscore first line x pos",
"hiscore first line y pos",
"hiscore horiz move next line w/tank icon",
"self test eor checksum fixer"}
print("-------------")
for i=1,#bzmemlocs do print(hex(i),hex(bzmemlocs[i]),hex(mem2:read_u8(bzmemlocs[i])),bzmemlocsdesc[i]) end
end


On initial start we get:
Code
bzself()
0	3000	0
1	3800	0
2	4000	255
3	4800	255
4	5000	0
5	5800	0
6	6000	0
7	6800	0
8	7000	0
9	7800	0
-------------
01	5530	f4	hiscore horiz move for next line
02	54a9	e0	hiscore first line x pos
03	54ab	1a	hiscore first line y pos
04	552c	a3	hiscore horiz move next line w/tank icon
05	5340	67	self test eor checksum fixer



mem2:write_u8(0x5530,0xf8)   -- f4 to f8  0100 to 1000
mem2:write_u8(0x54ab,0x1e)   -- 1a to 1e  1010 to 1110
mem2:write_u8(0x552c,0xa7)   -- a3 to a7  0011 to 0111
mem2:write_u8(0x5340,0x6b)   -- fix the self test checksum


bzself()
0	3000	0
1	3800	0
2	4000	255
3	4800	255
4	5000	0
5	5800	0
6	6000	0
7	6800	0
8	7000	0
9	7800	0
-------------
01	5530	f8	hiscore horiz move for next line
02	54a9	e0	hiscore first line x pos
03	54ab	1e	hiscore first line y pos
04	552c	a7	hiscore horiz move next line w/tank icon
05	5340	6b	self test eor checksum fixer



If you didn't care about it matching bzonea exactly, you could probably find some values that don't change the eor checksum and look reasonable on screen.


Then we get a high score screen that matches:

Loaded the fixed bzone and the bzonea and overlaid it with gimp and modified the opacity to see how it lines up.

[Linked Image from i.imgur.com]