-= FISHING FOR ATARI (source) =-

a game for 2 players on 1 Lynx
by Dr. Ludos - 30/11/2019


-= ABOUT =-

I could never have been able to make a Lynx game without the wonderful tools and templates
created and shared by LynxDev community hanging on AtariAge forums. 
In particular, I used CC65 "Lynx Edition" and the game template by Karri Kaksonen, 
the updated template with fadein, EEPROM save by Nop90 
and Chipper audio driver and sound creation by Sage.

So here's my little to contribution to the wonderful LYNX community, in the form of the fully commented source of this game.
It's quite simple, but it may be useful to someone who is starting LynxDev like I was myself not so long ago!


-= HOW TO BUILD =-

The game is written in C. To compile it for the Atari Lynx, you'll have to use the CC65 cross-compiler, in a specially tweaked edition 
made by Karri Kaksonen to add extra features for the Lynx (e.g. segments loading).
You can find the latest version of the required CC65 "Karri Edition" here:
https://bitbucket.org/atarilynx/lynx/src/master/tools/cc65/

When you have the toolchain all set up, simply call the Makefile with the following parameters:
make -f Makefile all

It'll generate you a "game.lnx" file. It's a fully functional Atari Lynx program that you can load into an emulator.
I personnaly recommend Handy as a Lynx emulator, although Mednafen and RetroArch are very good too (and all based on Handy anyway!)

To use the .lnx file on real hardware, you'll have to convert it / pad it to the required format depending on the flashcart you use.
You can use the Lynx ROM image convert tool for that:
http://www.vectrex.hackermesh.org/index.php/en/42-gadgetuk-lynx-rom-image-converter


-= GRAPHICS =-

Graphics are automatically converted to a Lynx format by a CC65 tool named sp65.
Documentation: https://cc65.github.io/doc/sp65.html

This tool expects graphic images in .PCX format as entry. 
However, it is quite sensitive in how the PCX file is made: it seems that it wants a PCX with a 256 color palette, but with only the first 16 colors defined.
I've tested various tools that were unable to generate PCX files working with SP65, until Karri Kaksonen suggested to use GIMP.
And indeed, besides being a great image manipulation tool, GIMP generates PCX file that works flawlessly with sp65.
So use GIMP to modify or create new graphical data! :)

In case you need it, you can find my source images inside the "game/" folder:
"gfx_bg.pcx" is the background
"gfx_sprites.pcx" contains all the sprites and letters for text messages.

Remember that the Lynx can only display 16 different colors at a time (with coding tricks like palette swap), so don't forget to stay in indexed colors mode with a 16 colors palette.

-= AUDIO =-

Audio is made using the wonderful Chipper tool. It's a music and sound effects creation and playback tool for the Lynx.
Download from here: http://bjoern.spruck.net/lynx/
Documentation / tutorial: https://atariage.com/forums/topic/256753-atari-lynx-programming-tools-and-tutorials-wip/?tab=comments#comment-4137925

The Chipper audio driver (written in ASM) was already included in the template I used (thanks Karri and Nop90).
So now you simply need to create new sound effects and music with Chipper.
Then you'll export them in the "BLL driver > CC65 remake" format.
It'll generate an ASM file (.s) with the audio date, that you'll included in your program. 
You'll then be able to play the "tracks" form this file using lynx_snd_XXX functions (see "game/game.c", line 325)

I've included the Chipper source file of the few sound effects I've made for this game (nothing fancy as you can hear!),
Open the "tunes/sfxmusic.lcp" with Chipper to get them.
The "tunes/sfxmusic.s" is the resulting exported file, that has been slightly modified / edited to give clear names to the sound effects
so I could call them more easily afterwards. Also, to make a looping sound, you'll need to do it manually in this file (see line 57)


-= FINAL WORDS =-

If you actually happen to read or want to use this source code and have any question about it, 
feel free to get in touch: drludos@ludoscience.com

I hope you'll enjoy the game!