Programming NES games in C article
Moderator: Moderators
Re: Programming NES games in C article
I guess it was the same for me, I probably was just adding anything that the linker was complaining about.
Re: Programming NES games in C article
Hi, new here
I'm impatient so I'm posting my urgent question first, will figure out where to post my introduction in a minute...
Shiru, I'm trying to use your library with Nintendulator DX v34 which requires a newer version of the debug files, so I'm trying to compile a new runtime.lib with the version of CC65 included with NDX.
When I run make with the source files you posted earlier in the thread, I get this:
I know next to nothing about GNU. Can you help out a brother?
Shiru, I'm trying to use your library with Nintendulator DX v34 which requires a newer version of the debug files, so I'm trying to compile a new runtime.lib with the version of CC65 included with NDX.
When I run make with the source files you posted earlier in the thread, I get this:
Code: Select all
c:\mingw\bin\make
../bin/ar65 a runtime.lib *.o
ar65.exe: Warning: Library `runtime.lib' not found - will be created
ar65.exe: Error: Could not open `*.o': No such file or directory
Makefile:230: recipe for target 'neslib' failed
make: *** [neslib] Error 255sonder
Re: Programming NES games in C article
I don't know much about GNU either. What I did is this: first remove the 'neslib: $(AR) a runtime.lib *.o' lines from the makefile and compile. It'll produce many object files. Then put it back and compile again. It'll create the runtime.lib.
Re: Programming NES games in C article
Thanks so much man - would have never figured that out myself. I'm posting my new runtime.lib file, which I tested and it totally worked!
- Attachments
-
- runtime.zip
- for Shiru framework programs compiled in CC65 (the version that came with NDX v34) to be fully debug-able
- (39.4 KiB) Downloaded 226 times
sonder
Re: Programming NES games in C article
I'm familiar with makefiles. Can someone upload the entire makefile so I can look at it and/or give advice on the issue?
Re: Programming NES games in C article
The makefile is included into this archive.
Re: Programming NES games in C article
Thanks.
The Makefile looks like it's missing dependencies for the neslib target. I would suggest:
You can replace the second $(OBJS) with *.o if you want, but that may or may not be a wise idea. What this will do is make it so that any time someone does make neslib, it will build the relevant .o files (referenced by the OBJS variable) first (if they don't exist).
An example of a working dependency list would be like this:
In English:
bsdhwmon (the final executable) is dependent upon the .o files mentioned in OBJS. The OBJS themselves are dependent upon global.h (i.e. in case I update global.h all the .o files should be recompiled), and to recompile those .o files, cc $CFLAGS -c {objectname_minus_the_.o_part}.c will be run. The final executable build (linking) is done via cc $CFLAGS -o bsdhwmon {all the .o files}
In BSD make, $.ALLSRC is the same as $>, and $.TARGET is the same as $@. Not sure if GNU make has those alternate names as well, but I find them to be much easier to read.
Example run:
There are also some "magic" target names, like doing something like this:
Which would make all the relevant .o files dependent upon their .c file equivalents, a well as global.h. See "Makefile.3" for an explanation. Lots of people use this methodology.
Anyway, you may also want to add runtime.lib as a dependency for some other target (possibly "all" ?), and then make a runtime.lib target which does the right thing there. Then there's no more "make neslib" necessity -- instead "make" just does it all for you -- it all depends on what you want, of course.
Make sense? Sorry if it's a bit confusing. :-)
The Makefile looks like it's missing dependencies for the neslib target. I would suggest:
Code: Select all
neslib: $(OBJS)
$(AR) a runtime.lib $(OBJS)
An example of a working dependency list would be like this:
Code: Select all
OBJS= main.o boards.o output.o chip_w83792d.o chip_w83793g.o chip_x6dva.o
all: bsdhwmon
bsdhwmon: ${OBJS}
${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
${OBJS}: global.h
${CC} ${CFLAGS} -c ${.PREFIX}.c
bsdhwmon (the final executable) is dependent upon the .o files mentioned in OBJS. The OBJS themselves are dependent upon global.h (i.e. in case I update global.h all the .o files should be recompiled), and to recompile those .o files, cc $CFLAGS -c {objectname_minus_the_.o_part}.c will be run. The final executable build (linking) is done via cc $CFLAGS -o bsdhwmon {all the .o files}
In BSD make, $.ALLSRC is the same as $>, and $.TARGET is the same as $@. Not sure if GNU make has those alternate names as well, but I find them to be much easier to read.
Example run:
Code: Select all
$ make
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c main.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c boards.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c output.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_w83792d.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_w83793g.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -c chip_x6dva.c
cc -O2 -pipe -fno-omit-frame-pointer -march=core2 -Werror -Wall -Wformat-security -fno-inline -o bsdhwmon main.o boards.o output.o chip_w83792d.o chip_w83793g.o chip_x6dva.o
Code: Select all
%.o: %.c global.h
${CC} ${CFLAGS} -c ${.ALLSRC}
Anyway, you may also want to add runtime.lib as a dependency for some other target (possibly "all" ?), and then make a runtime.lib target which does the right thing there. Then there's no more "make neslib" necessity -- instead "make" just does it all for you -- it all depends on what you want, of course.
Make sense? Sorry if it's a bit confusing. :-)
-
lucasweatherby
- Posts: 1
- Joined: Sun Mar 31, 2013 12:47 pm
Re: Programming NES games in C article
Hey there guys. New member here. I have been registered for a while and browsed for a while but never posted.. I've decided that while i have had some assembly experience i wanted to give this method a try.
With that being said, I am more of a Java guy so I am having some troubles getting setup. I followed the instructions posted here:
http://oliverschmidt.github.io/cc65/get ... arted.html
to get cc65 up and running and added it to my class path but I get the following error:
Looks like it has something to do with the make file stuff you all were mentioning above so I wanted to get some clarification. Do I need to basically redo the steps in the cc65 installation link but before I run the make.exe for cc65 replace the makefile with the one you all provided?
With that being said, I am more of a Java guy so I am having some troubles getting setup. I followed the instructions posted here:
http://oliverschmidt.github.io/cc65/get ... arted.html
to get cc65 up and running and added it to my class path but I get the following error:
Code: Select all
C:\cc65\src>compile.bat
C:\cc65\src>path=path;..\bin\
C:\cc65\src>set CC65_HOME=..\
C:\cc65\src>cc65 -Oi game.c --add-source
game.c(225): Warning: #pragma bssseg is obsolete, please use #pragma bss-name in
stead
game.c(226): Warning: #pragma dataseg is obsolete, please use #pragma data-name
instead
C:\cc65\src>ca65 crt0.s
crt0.s(29): Error: Cannot open include file `zeropage.inc': No such file or dire
ctory
C:\cc65\src>ca65 game.s
game.s(12): Error: Cannot open include file `longbranch.mac': No such file or di
rectory
game.s(4837): Error: `:' expected
game.s(4837): Error: Unexpected trailing garbage characters
game.s(4869): Error: Symbol `jcs' is already defined
game.s(4869): Error: `:' expected
game.s(4869): Error: Symbol `.size' is already defined
game.s(4869): Error: Unexpected trailing garbage characters
game.s(4888): Error: `:' expected
game.s(4888): Error: Unexpected trailing garbage characters
game.s(5239): Error: Symbol `jcs' is already defined
game.s(5239): Error: `:' expected
game.s(5239): Error: Symbol `.size' is already defined
game.s(5239): Error: Unexpected trailing garbage characters
game.s(5399): Error: `:' expected
game.s(5399): Error: Unexpected trailing garbage characters
game.s(5466): Error: Symbol `jcs' is already defined
game.s(5466): Error: `:' expected
game.s(5466): Error: Symbol `.size' is already defined
game.s(5466): Error: Unexpected trailing garbage characters
game.s(5513): Error: Symbol `jne' is already defined
game.s(5513): Error: `:' expected
game.s(5513): Error: Symbol `.size' is already defined
game.s(5513): Error: Unexpected trailing garbage characters
game.s(5518): Error: Symbol `jeq' is already defined
game.s(5518): Error: `:' expected
game.s(5518): Error: Symbol `.size' is already defined
game.s(5518): Error: Unexpected trailing garbage characters
game.s(5548): Error: Symbol `jcs' is already defined
game.s(5548): Error: `:' expected
game.s(5548): Error: Symbol `.size' is already defined
game.s(5548): Error: Unexpected trailing garbage characters
game.s(5688): Error: Symbol `jeq' is already defined
game.s(5688): Error: `:' expected
game.s(5688): Error: Symbol `.size' is already defined
game.s(5688): Error: Unexpected trailing garbage characters
game.s(5699): Error: Symbol `jeq' is already defined
game.s(5699): Error: `:' expected
game.s(5699): Error: Symbol `.size' is already defined
game.s(5699): Error: Unexpected trailing garbage characters
game.s(5705): Error: Symbol `jne' is already defined
game.s(5705): Error: `:' expected
game.s(5705): Error: Symbol `.size' is already defined
game.s(5705): Error: Unexpected trailing garbage characters
game.s(5912): Error: `:' expected
game.s(5912): Error: Unexpected trailing garbage characters
game.s(5930): Error: Symbol `jcc' is already defined
game.s(5930): Error: `:' expected
game.s(5930): Error: Symbol `.size' is already defined
game.s(5930): Error: Unexpected trailing garbage characters
game.s(6044): Error: Symbol `jne' is already defined
game.s(6044): Error: `:' expected
game.s(6044): Error: Symbol `.size' is already defined
game.s(6044): Error: Unexpected trailing garbage characters
game.s(6097): Error: Symbol `jne' is already defined
game.s(6097): Error: `:' expected
game.s(6097): Error: Symbol `.size' is already defined
game.s(6097): Error: Unexpected trailing garbage characters
game.s(6286): Error: Symbol `jeq' is already defined
game.s(6286): Error: `:' expected
game.s(6286): Error: Symbol `.size' is already defined
game.s(6286): Error: Unexpected trailing garbage characters
game.s(6291): Error: Symbol `jne' is already defined
game.s(6291): Error: `:' expected
game.s(6291): Error: Symbol `.size' is already defined
game.s(6291): Error: Unexpected trailing garbage characters
game.s(6371): Error: Symbol `jeq' is already defined
game.s(6371): Error: `:' expected
game.s(6371): Error: Symbol `.size' is already defined
game.s(6371): Error: Unexpected trailing garbage characters
game.s(6603): Error: Symbol `jcc' is already defined
game.s(6603): Error: `:' expected
game.s(6603): Error: Symbol `.size' is already defined
game.s(6603): Error: Unexpected trailing garbage characters
game.s(6759): Error: Symbol `jeq' is already defined
game.s(6759): Error: `:' expected
game.s(6759): Error: Symbol `.size' is already defined
game.s(6759): Error: Unexpected trailing garbage characters
C:\cc65\src>ld65 -C nes.cfg -o Chase.nes crt0.o game.o runtime.lib
ld65: Error: nes.cfg(82): Attribute expected
C:\cc65\src>pause
Press any key to continue . . .-
DrDementia
- Posts: 32
- Joined: Thu Oct 31, 2013 4:55 pm
Re: Programming NES games in C article
would anyone still have that runtime.zip file? I'm having a little trouble getting runtime.lib built
- rainwarrior
- Posts: 8062
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Programming NES games in C article
The sources for runtime stuff are in the CC65 source package.
-
DrDementia
- Posts: 32
- Joined: Thu Oct 31, 2013 4:55 pm
Re: Programming NES games in C article
yeah I was just looking for shiru's makefile. I already compiled ca65 from src. and i built the libs. But runtime.lib doesn't get built. I tried "make lib" and "make all"
shiru's examples don't compile with newer versions of ca65 because it complains version differs. so I wanted to build runtime.lib myself. in another thread he said he renamed runtime.lib. I think he just used certain .o's. which is why I wanted to look at his makefile. can't use "ar65 l" on runtime.lib either.
renaming nes.lib to runtime.lib might work.
shiru's examples don't compile with newer versions of ca65 because it complains version differs. so I wanted to build runtime.lib myself. in another thread he said he renamed runtime.lib. I think he just used certain .o's. which is why I wanted to look at his makefile. can't use "ar65 l" on runtime.lib either.
renaming nes.lib to runtime.lib might work.
- rainwarrior
- Posts: 8062
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Programming NES games in C article
You might just try building everything in /common and /runtime and packing them into a lib. (I dunno, though, setting up a suitable runtime library collection is a bit of an advanced task. Hard to do right unless you're well versed in NES and 6502 assembly.)
Re: Programming NES games in C article
Why don't you use the runtime.lib that sonder posted in this thread?DrDementia wrote:shiru's examples don't compile with newer versions of ca65 because it complains version differs. so I wanted to build runtime.lib myself. in another thread he said he renamed runtime.lib. I think he just used certain .o's. which is why I wanted to look at his makefile. can't use "ar65 l" on runtime.lib either.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
-
DrDementia
- Posts: 32
- Joined: Thu Oct 31, 2013 4:55 pm
Re: Programming NES games in C article
thefox wrote:Why don't you use the runtime.lib that sonder posted in this thread?
sonder's runtime.lib does work for me with latest version of cc65, I tried nenaming nes.lib(from CC65) to runtime.lib, that seems to work too. I can use "ar65 l" on both those, and runtime.lib seems to contain mostly math stuff, all of which seem to be in nes.lib. the nes lib contains some nes specific stuff, not sure if that will cause any conflicts.