Alright, I found the location that produces the error, but not the actual reason:
If I declare a variable in the zeropage, it's fine in both emulators. If I declare it in the regular RAM section, it works only with fceux.
I used CC65 and I didn't use any additional config file. I let the compiler use the built-in one.
My compile command is this:
Code:
cl65 -t nes -LC:\cc65\lib -o Test.nes Test.s
Below, you'll find my code. Search for the word IMPORTANT to find the relevant stuff.
Also, you'll find the config file that CC65 uses.
The "Graphics.chr" is attached. The ROM as well.
In fceux, you'll see a 1 within all the zeroes on the screen as declared in the code. In Nestopia, you'll see a blank space (since all tiles are empty, except for numbers and letters and he took some random tile).
Code:
.segment "HEADER"
.byte "NES", $1A, $02, $01, $01, $00
.segment "STARTUP"
.segment "ZEROPAGE"
Pointer: .res 2
; IMPORTANT: With ZEROPAGE, it works.
.segment "BSS"
Score: .res 1
.segment "CODE"
Reset:
SEI
CLD
LDX #$40
STX $4017
LDX #$FF
TXS
INX
STX $2000
STX $2001
STX $4010
BIT $2002
@waitForVBlank1:
BIT $2002
BPL @waitForVBlank1
LDA #$00
STA Pointer
STA Pointer + 1
TAX
TAY
@outerLoop:
@innerLoop:
STA (Pointer), Y
INY
BNE @innerLoop
INC Pointer + 1
INX
CPX #$08
BNE @outerLoop
LDA #$F4
LDX #$00
@loop:
STA $0200, X
INX
BNE @loop
@waitForVBlank2:
BIT $2002
BPL @waitForVBlank2
LoadPalettes:
LDA $2002
LDA #$3F
STA $2006
LDA #$00
STA $2006
LDX #$00
@loop:
LDA Palettes, X
STA $2007
INX
CPX #$20
BNE @loop
; IMPORTANT: Score is set to 1.
LDA #$01
STA Score
LDA #%10010000
STA $2000
LDA #%00011110
STA $2001
@forever:
JMP @forever
Nmi:
LDA #$00
STA $2003
LDA #$02
STA $4014
; IMPORTANT: Score (i.e. tile 1) is drawn to the PPU into a specific location.
LDA $2002
LDA #$20
STA $2006
LDA #$6D
STA $2006
LDA Score
STA $2007
LDA #$00
STA $2006
STA $2006
STA $2005
STA $2005
RTI
.segment "VECTORS"
.word $00, $00, $00
.word Nmi
.word Reset
.word 0
.segment "RODATA"
Palettes:
.byte $21, $00, $10, $30, $21, $10, $30, $12, $21, $05, $26, $16, $21, $23, $12, $31
.byte $21, $18, $16, $36, $21, $16, $24, $36, $21, $07, $F0, $36, $21, $38, $12, $36
.segment "CHARS"
.incbin "Graphics.chr"
Code:
MEMORY {
ZP: start = $02, size = $1A, type = rw, define = yes;
HEADER: start = $0, size = $10, file = %O ,fill = yes;
ROM0: start = $8000, size = $7ff4, file = %O ,fill = yes, define = yes;
ROMV: start = $fff6, size = $c, file = %O, fill = yes;
ROM2: start = $0000, size = $2000, file = %O, fill = yes;
SRAM: start = $0500, size = $0300, define = yes;
RAM: start = $6000, size = $2000, define = yes;
}
SEGMENTS {
HEADER: load = HEADER, type = ro;
STARTUP: load = ROM0, type = ro, define = yes;
LOWCODE: load = ROM0, type = ro, optional = yes;
INIT: load = ROM0, type = ro, define = yes, optional = yes;
CODE: load = ROM0, type = ro, define = yes;
RODATA: load = ROM0, type = ro, define = yes;
DATA: load = ROM0, run = RAM, type = rw, define = yes;
VECTORS: load = ROMV, type = rw;
CHARS: load = ROM2, type = rw;
BSS: load = RAM, type = bss, define = yes;
HEAP: load = RAM, type = bss, optional = yes;
ZEROPAGE: load = ZP, type = zp;
}
FEATURES {
CONDES: segment = INIT,
type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__;
CONDES: segment = RODATA,
type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__;
CONDES: type = interruptor,
segment = RODATA,
label = __INTERRUPTOR_TABLE__,
count = __INTERRUPTOR_COUNT__;
}
SYMBOLS {
__STACKSIZE__ = $0300;
}