+karri Posted March 4, 2017 Share Posted March 4, 2017 (edited) Getting started to develop on cc65 is a bit easier with a template. Common.mk Makefile cart: directory.s lnxhdr.s lynx.cfg Makefile game: game.c Makefile tree.pcx intro: bg.pcx intro.c Makefile resident: fadein.s fadeout.s lynx-snd.s Makefile resident.c tunes: Makefile soundbs.mac track2.s A small explanation: Common.mk contains all the common stuff for Makefiles. This means how to call compilers for getting the job done The resident directory contains the runtime that is always in memory. Intro directory contains the startup screen Game contains the game itself Tunes contain the sound effects. You can compile everything by writing make To clean everything before the make make clean To run the game mednafen cart/game.lnx I have tried to add all kind of interesting things in game.c for you to explore. Enjoy template.zip Edited March 5, 2017 by karri 4 Quote Link to comment Share on other sites More sharing options...
Turbo Laser Lynx Posted March 4, 2017 Share Posted March 4, 2017 (edited) Wohoo! Thank you so much for sharing! Having a good template like this is like having a golden key that opens up the gates to Lynx coding for anyone who can do a little programming Edited March 4, 2017 by Turbo Laser Lynx 1 Quote Link to comment Share on other sites More sharing options...
LX.NET Posted March 4, 2017 Share Posted March 4, 2017 Works like a charm. Thanks Karri! 1 Quote Link to comment Share on other sites More sharing options...
D-lag Posted March 8, 2017 Share Posted March 8, 2017 Thank you Karri for the template, it is a great idea! I have just tried it, and cannot compile, this is what I get: $ make "make" -C game; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/game' cc65 -t lynx --code-name GAME_CODE --rodata-name GAME_RODATA --data-name GAME_DATA --bss-name GAME_BSS -o game.s game.c game.c(7): Error: Conflicting types for `lynx_snd_init' game.c(: Error: Conflicting types for `lynx_snd_pause' game.c(9): Error: Conflicting types for `lynx_snd_continue' game.c(11): Error: Conflicting types for `lynx_snd_stop' make[1]: *** [../Common.mk:25: game.o] Error 1 make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/game' make: *** [Makefile:2: all] Error 2 Any idea why? Thanks! Quote Link to comment Share on other sites More sharing options...
+karri Posted March 8, 2017 Author Share Posted March 8, 2017 You probably have a version of the cc65 compiler that already has defined the chipper sound routines in the lynx.h include file. Then you can just remove the lined where you declare the lynx-snd methods. I did include them in the newest cc65 trunk. But when I moved back in time there is no sound support in the compiler and I have to include it by myself. Quote Link to comment Share on other sites More sharing options...
D-lag Posted March 8, 2017 Share Posted March 8, 2017 Thanks Karri, it was that, I had to comment the lynx-snd methods both in game.c and resident.c. Now I got further, and got another error in the cart part, here is the full log: $ make "make" -C game; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/game' cc65 -t lynx --code-name GAME_CODE --rodata-name GAME_RODATA --data-name GAME_DATA --bss-name GAME_BSS -o game.s game.c ca65 -t lynx -o game.o game.s rm -f game.s sp65 -r tree.pcx -c lynx-sprite,mode=packed,ax=94,ay=168 -w tree.c,ident=tree,bytesperline=8 cc65 -t lynx --code-name GAME_CODE --rodata-name GAME_RODATA --data-name GAME_DATA --bss-name GAME_BSS -o tree.s tree.c ca65 -t lynx -o tree.o tree.s rm -f tree.s rm -f objlist for obj in game.o tree.o; do echo ../game/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/game' "make" -C intro; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/intro' cc65 -t lynx --code-name INTRO_CODE --rodata-name INTRO_RODATA --data-name INTRO_DATA --bss-name INTRO_BSS -o intro.s intro.c ca65 -t lynx -o intro.o intro.s rm -f intro.s sp65 -r bg.pcx -c lynx-sprite,mode=packed -w bg.c,ident=bg,bytesperline=8 cc65 -t lynx --code-name INTRO_CODE --rodata-name INTRO_RODATA --data-name INTRO_DATA --bss-name INTRO_BSS -o bg.s bg.c ca65 -t lynx -o bg.o bg.s rm -f bg.s rm -f objlist for obj in intro.o bg.o; do echo ../intro/$obj >> objlist; done rm bg.c make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/intro' "make" -C resident; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/resident' cc65 -I . -t lynx --add-source -O -Or -Cl -Os -o resident.s resident.c ca65 -o resident.o resident.s rm resident.s ca65 -t lynx -I "/usr/lib/cc65/include/../asminc" -o fadein.o fadein.s ca65 -t lynx -I "/usr/lib/cc65/include/../asminc" -o fadeout.o fadeout.s ca65 -t lynx -I "/usr/lib/cc65/include/../asminc" -o lynx-snd.o lynx-snd.s touch objlist rm objlist for obj in resident.o fadein.o fadeout.o lynx-snd.o; do echo ../resident/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/resident' "make" -C tunes; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/tunes' ca65 -t lynx -I "/usr/lib/cc65/include/../asminc" -o track2.o track2.s touch objlist rm objlist for obj in track2.o; do echo ../tunes/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/tunes' "make" -C cart; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/cart' ca65 -t lynx -I -o lnxhdr.o lnxhdr.s ca65: Don't know what to do with `lnxhdr.s' make[1]: *** [Makefile:71: lnxhdr.o] Error 1 make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/cart' make: *** [Makefile:6: all] Error 2 I think I'm close enough, but I can't solve it by myself Quote Link to comment Share on other sites More sharing options...
+karri Posted March 8, 2017 Author Share Posted March 8, 2017 For some reason your environment variables are wrong. I changed the rules a bit. Could you try this template instead? template.zip Quote Link to comment Share on other sites More sharing options...
D-lag Posted March 8, 2017 Share Posted March 8, 2017 Yes, you're right, I had to change my environment variables in Common.mk as CC65 was installed in /usr/share/cc65 on my system. I changed it to /usr/local/lib/cc65 to have the same settings as you. Thanks for the new template.zip, I get one step further, and a new error: "make" -C game; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/game' cc65 -t lynx --code-name GAME_CODE --rodata-name GAME_RODATA --data-name GAME_DATA --bss-name GAME_BSS -o game.s game.c ca65 -t lynx -o game.o game.s rm -f game.s sp65 -r tree.pcx -c lynx-sprite,mode=packed,ax=94,ay=168 -w tree.c,ident=tree,bytesperline=8 cc65 -t lynx --code-name GAME_CODE --rodata-name GAME_RODATA --data-name GAME_DATA --bss-name GAME_BSS -o tree.s tree.c ca65 -t lynx -o tree.o tree.s rm -f tree.s rm -f objlist for obj in game.o tree.o; do echo ../game/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/game' "make" -C intro; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/intro' cc65 -t lynx --code-name INTRO_CODE --rodata-name INTRO_RODATA --data-name INTRO_DATA --bss-name INTRO_BSS -o intro.s intro.c ca65 -t lynx -o intro.o intro.s rm -f intro.s sp65 -r bg.pcx -c lynx-sprite,mode=packed -w bg.c,ident=bg,bytesperline=8 cc65 -t lynx --code-name INTRO_CODE --rodata-name INTRO_RODATA --data-name INTRO_DATA --bss-name INTRO_BSS -o bg.s bg.c ca65 -t lynx -o bg.o bg.s rm -f bg.s rm -f objlist for obj in intro.o bg.o; do echo ../intro/$obj >> objlist; done rm bg.c make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/intro' "make" -C resident; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/resident' ca65 -t lynx -I /usr/local/lib/cc65/asminc -o fadein.o fadein.s ca65 -t lynx -I /usr/local/lib/cc65/asminc -o fadeout.o fadeout.s ca65 -t lynx -I /usr/local/lib/cc65/asminc -o lynx-snd.o lynx-snd.s cc65 -t lynx --code-name CODE --rodata-name RODATA --data-name DATA --bss-name BSS -o resident.s resident.c ca65 -t lynx -o resident.o resident.s rm -f resident.s rm -f objlist for obj in fadein.o fadeout.o lynx-snd.o resident.o; do echo ../resident/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/resident' "make" -C tunes; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/tunes' ca65 -t lynx -I /usr/local/lib/cc65/asminc -o track2.o track2.s rm -f objlist for obj in track2.o; do echo ../tunes/$obj >> objlist; done make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/tunes' "make" -C cart; make[1]: Entering directory '/home/damdam/projects/atari_lynx/template/cart' ca65 -t lynx -I /usr/local/lib/cc65/asminc -o lnxhdr.o lnxhdr.s ca65 -t lynx -I /usr/local/lib/cc65/asminc -o directory.o directory.s cl65 -t lynx -o game.lnx -m lynx.map -C lynx.cfg lnxhdr.o directory.o @../resident/objlist @../intro/objlist @../game/objlist @../tunes/objlist lynx.lib Unresolved external `__BANK0BLOCKSIZE__' referenced in: lynx/bootldr.s(170) Unresolved external `__INIT_SIZE__' referenced in: directory.s(49) Unresolved external `__MAIN_SIZE__' referenced in: lynx/crt0.s(82) lynx/crt0.s(83) Unresolved external `__MAIN_START__' referenced in: lynx/crt0.s(82) lynx/crt0.s(83) ld65: Error: 4 unresolved external(s) found - cannot create output file make[1]: *** [Makefile:24: game.lnx] Error 1 make[1]: Leaving directory '/home/damdam/projects/atari_lynx/template/cart' make: *** [Makefile:6: all] Error 2 Quote Link to comment Share on other sites More sharing options...
+karri Posted March 9, 2017 Author Share Posted March 9, 2017 You are not running with the compiler version from bitbucket/atarilynx My guess is that you need to rename all segments in the lynx.cfg from RAM to MAIN. The same is true for everything called RAM in directory.s You also need to define __BANK0BLOCKSIZE__ in lynx.cfg to be the same as __BLOCKSIZE__. And remove __INIT_SIZE__ from directory.s as it is not used in your cc65 compiler version. You may encounter other differences as your compiler is much newer than mine. Like crashes when writing bigger games. 1 Quote Link to comment Share on other sites More sharing options...
D-lag Posted March 9, 2017 Share Posted March 9, 2017 Thanks a lot Karri, I was using the cc65-git package for Archlinux, I didn't know that your repository was a different version. Ok, so I got cc65 from bitbucket and am pleased to report that I can now compile successfully Quote Link to comment Share on other sites More sharing options...
pwwit1 Posted March 12, 2017 Share Posted March 12, 2017 This is really great! Thankyou I'm a little new to this, but is there any way to create breakpoints, view registers and step through the executing code? Quote Link to comment Share on other sites More sharing options...
LordKraken Posted March 12, 2017 Share Posted March 12, 2017 You can do most of that from Handydev. Pretty useful even though it's not Visual Studio debugger ^^. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.