clbr / neslib

Neslib
zlib License
105 stars 25 forks source link

"Range error" with ZP-variable `oam_off` #1

Closed R-Gerard closed 7 years ago

R-Gerard commented 7 years ago

I'm trying to compile Shiru's examples using this fork of neslib as a git-submodule in my project.

I've made the following changes to Shiru's example code:

When I run the following command:

cl65 -o target/example1.nes -C nes.cfg -t nes -I neslib/   src/example1.c neslib/*.o

...I get this error:

ld65: Warning: Address size mismatch for _oam_off': Exported from example1.o, src/example1.s(17) asabsolute', import in crt0.o, display.sinc(1) as zeropage' ld65: Error: Range error in moduledisplay.sinc', line 40

I'm using the latest BrewFormula to install cc65 V2.13.3 rather than compile cc65 from the master branch.

Any idea what I'm doing wrong?

clbr commented 7 years ago

The oam_off variable must be placed in ZP, you placed it as a normal variable. This is the same as in the original neslib, it hasn't changed. I haven't looked at the examples, perhaps Shiru included the variable in his prebuilt library, but this is not how it relates to standalone projects - standalone ones have always needed to put the oam_off variable to ZP themselves.

An example on how to do that can be found under my nes repo, cnrom/, but that won't work on your old compiler, since the pragma syntax is different.

I'd advice against using a compiler that old. That's from 2012, five years old, and there have been quite some changes since.

R-Gerard commented 7 years ago

D'oh! Thanks. Just a simple case of RTFM.

R-Gerard commented 7 years ago

Actually, I'm having a similar issue with your example cnrom project using the latest cc65 from master (head commit of cc65/master is 0bbe4f56).

make clean all
rm -f cnrom.nes *.o
cl65 -c -C nes.cfg -t nes -Oisr main.c -o main.o
cl65 -c -C nes.cfg -t nes -Oisr crt0.s -o crt0.o
cl65 -o cnrom.nes -C nes.cfg -t nes -Oisr main.o crt0.o
ld65: Warning: Address size mismatch for `_oam_off': Exported from main.o, main.s(36) as `absolute', import in crt0.o, display.sinc(1) as `zeropage'
ld65: Error: Range error in module `display.sinc', line 40
make: *** [cnrom.nes] Error 1

Do you mind telling me what particular commit you compiled cc65 from?

clbr commented 7 years ago

24c2da9, but master should work just fine, unless there's some recent bug.

R-Gerard commented 7 years ago

Hrm... I get a different error with the cnrom project using that build of cc65:

cc65 --version
cc65 V2.15 - Git 24c2da98

make clean all
rm -f cnrom.nes *.o
cl65 -c -C nes.cfg -t nes -Oisr main.c -o main.o
main.c(77): Error: Undefined symbol: `KEY_START'
make: *** [main.o] Error 1
clbr commented 7 years ago

I confirm cc65 master is buggy. Also, although that git sha was what my cc65 --version says, the build system is also buggy - it doesn't update the version string when the git revision changes. My cc65 timestamp is Jan 21 2016, so one of that day's commits is known to work.

clbr commented 7 years ago

I bisected and reported the bug.

R-Gerard commented 7 years ago

Okay, I confirmed this fork works with Shiru's old examples using https://github.com/cc65/cc65/commit/f7cdfbf (last commit on Jan 21, 2016).