adam_smasher wrote:

What assembler are you using? Have you checked to see that this is getting assembled correctly?

Asar. Yeah, I've stepped through the disassembly and everything checks out, as far as I can tell. Here's the disassembly:

$B8/C99E 08 PHP A:0002 X:0000 Y:0C70 P:envMxdizc

$B8/C99F C2 30 REP #$30 A:0002 X:0000 Y:0C70 P:envMxdizc

$B8/C9A1 48 PHA A:0002 X:0000 Y:0C70 P:envmxdizc

$B8/C9A2 DA PHX A:0002 X:0000 Y:0C70 P:envmxdizc

$B8/C9A3 5A PHY A:0002 X:0000 Y:0C70 P:envmxdizc

$B8/C9A4 E2 20 SEP #$20 A:0002 X:0000 Y:0C70 P:envmxdizc

$B8/C9A6 C2 10 REP #$10 A:0002 X:0000 Y:0C70 P:envMxdizc

$B8/C9A8 A2 00 80 LDX #$8000 A:0002 X:0000 Y:0C70 P:envMxdizc

$B8/C9AB 8E 72 43 STX $4372 [$05:4372] A:0002 X:8000 Y:0C70 P:eNvMxdizc

$B8/C9AE A9 B0 LDA #$B0 A:0002 X:8000 Y:0C70 P:eNvMxdizc

$B8/C9B0 8D 74 43 STA $4374 [$05:4374] A:00B0 X:8000 Y:0C70 P:eNvMxdizc

$B8/C9B3 A0 20 00 LDY #$0020 A:00B0 X:8000 Y:0C70 P:eNvMxdizc

$B8/C9B6 8C 75 43 STY $4375 [$05:4375] A:00B0 X:8000 Y:0020 P:envMxdizc

$B8/C9B9 A9 E0 LDA #$E0 A:00B0 X:8000 Y:0020 P:envMxdizc

$B8/C9BB 8D 21 21 STA $2121 [$05:2121] A:00E0 X:8000 Y:0020 P:eNvMxdizc

$B8/C9BE A2 02 22 LDX #$2202 A:00E0 X:8000 Y:0020 P:eNvMxdizc

$B8/C9C1 8E 70 43 STX $4370 [$05:4370] A:00E0 X:2202 Y:0020 P:envMxdizc

$B8/C9C4 A9 80 LDA #$80 A:00E0 X:2202 Y:0020 P:envMxdizc

$B8/C9C6 8D 0B 42 STA $420B [$05:420B] A:0080 X:2202 Y:0020 P:eNvMxdizc

$B8/C9C9 C2 30 REP #$30 A:0080 X:2202 Y:0020 P:eNvMxdizc

$B8/C9CB 7A PLY A:0080 X:2202 Y:0020 P:eNvmxdizc

$B8/C9CC FA PLX A:0080 X:2202 Y:0C70 P:envmxdizc

$B8/C9CD 68 PLA A:0080 X:0000 Y:0C70 P:envmxdiZc

$B8/C9CE 28 PLP A:0002 X:0000 Y:0C70 P:envmxdizc