Jump to content
IGNORED

My Atari Lynx Programming Journal


OldAtAtari

Recommended Posts

4 hours ago, karri said:

The clue is in the Makefile.

 

objects= \
        abcmusic.o \
        main.o \

target = test.lnx
 

It links 2 object. One is abcmusic.o and the other is main.o

 

The abcmusic.o is actually compiled from abcmusic.s which is the abcmusic library for cc65.

 

You don't need Chipper at all. Just delete the tunes directory and also the lynxsnd.s driver if you go with ABCmusic. Again, look at the Makefile.

 

Actually... You should not use the template at all. Just edit your main.c file to contain your game.

Ok. Do-over. I'm going to set up the tools and template brand new and start over, more or less, without using template. I saved my edited game.c file so that can copy in my modifications.

 

So Karri, you're saying I shouldn't use the template at all. Why is that? Aside from being designed with Chipper, are there other reasons I shouldn't use it?

And instead, I should base my code on main.c, which is the file found in the /contrib/abcmusic/ directory, right? It's more appropriate for what I'm doing?

 

Thanks.

 

Link to comment
Share on other sites

40 minutes ago, OldAtAtari said:

Ok. Do-over. I'm going to set up the tools and template brand new and start over, more or less, without using template. I saved my edited game.c file so that can copy in my modifications.

 

So Karri, you're saying I shouldn't use the template at all. Why is that? Aside from being designed with Chipper, are there other reasons I shouldn't use it?

And instead, I should base my code on main.c, which is the file found in the /contrib/abcmusic/ directory, right? It's more appropriate for what I'm doing?

 

Thanks.

 

The template is definitely good always because all the special things are there like directory, handling of special keys like flip, reset. But for just trying out some simple stuff it may be easier to just use a single c-file and leave the rest to the compiler.

 

Later, when you have an idea for a real game then the template makes sense. It can handle loading of different levels in the game, sound effects, music, eeprom support and so on.

  • Like 1
Link to comment
Share on other sites

3 minutes ago, karri said:

The template is definitely good always because all the special things are there like directory, handling of special keys like flip, reset. But for just trying out some simple stuff it may be easier to just use a single c-file and leave the rest to the compiler.

 

Later, when you have an idea for a real game then the template makes sense. It can handle loading of different levels in the game, sound effects, music, eeprom support and so on.

Ok, that makes sense. So for now, I just want to get my basic game working with sounds, and it seems like that will be most easily done with main.c in the ABCmusic directory. So that's what I'll do. I hope to get some sound effects soon, and then I'll have a silly game to present to you all. Thanks.

Edited by OldAtAtari
Link to comment
Share on other sites

About Chipper and the template: There's a slightly painful learning curve the first time you learn how trackers work, but when you know one, all the other ones are usually very similar. Trackers are pretty much standard for creating music on old systems, so you open up a whole new world of possibilities. One reason I think why trackers have become so popular for old systems is that you can easily change instrument on every note, and this is very useful and powerful for systems with only two, three or four sound channels where you need to "channel jump" a lot to make all instruments fit. The Lynx has four channels which is quite a luxury, so you can "easily" leave one channel empty for sound effects if you want.

In the template up, down and left starts different channels for sfx, but you can pull them out of there and call them all at once and start some music like this: (call them only once).

lynx_snd_play(0, musicptr.music1);
lynx_snd_play(1, musicptr.music2);
lynx_snd_play(2, musicptr.music3);
lynx_snd_play(3, musicptr.music4);

Chipper exports to Karri's cc65, newcc65 and bll, so you can just export your song and replace track2.s in the tunes folder with your own song.

Chipper looks horribly complicated, but you can simplify it down for yourself to the essentials like this:

- Tracker window: 1. put in notes 2. put in instrument for each note.

- Playlist window (Within the tracker window): 1. put in patterns i.e. tracks to build up the whole song.
- Simple instrument window:

1. use preset instruments (there's a bunch included in the chipper package), go through them in the drop down menu and check which ones you like.

2. Optional: Create your own sounds. Read the attached pdf here:

 

It's really as simple as that!

One more thing that might feel a bit odd with trackers at first is that there's no length to the notes, the length is how long the sound of the instrument is. So if you use a longer sound and put notes close after each other, the sound would get cut off and start over every note.

 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, Turbo Laser Lynx said:

About Chipper and the template: There's a slightly painful learning curve the first time you learn how trackers work, but when you know one, all the other ones are usually very similar. Trackers are pretty much standard for creating music on old systems, so you open up a whole new world of possibilities. One reason I think why trackers have become so popular for old systems is that you can easily change instrument on every note, and this is very useful and powerful for systems with only two, three or four sound channels where you need to "channel jump" a lot to make all instruments fit. The Lynx has four channels which is quite a luxury, so you can "easily" leave one channel empty for sound effects if you want.

In the template up, down and left starts different channels for sfx, but you can pull them out of there and call them all at once and start some music like this: (call them only once).


lynx_snd_play(0, musicptr.music1);
lynx_snd_play(1, musicptr.music2);
lynx_snd_play(2, musicptr.music3);
lynx_snd_play(3, musicptr.music4);

Chipper exports to Karri's cc65, newcc65 and bll, so you can just export your song and replace track2.s in the tunes folder with your own song.

Chipper looks horribly complicated, but you can simplify it down for yourself to the essentials like this:

- Tracker window: 1. put in notes 2. put in instrument for each note.

- Playlist window (Within the tracker window): 1. put in patterns i.e. tracks to build up the whole song.
- Simple instrument window:

1. use preset instruments (there's a bunch included in the chipper package), go through them in the drop down menu and check which ones you like.

2. Optional: Create your own sounds. Read the attached pdf here:

 

It's really as simple as that!

One more thing that might feel a bit odd with trackers at first is that there's no length to the notes, the length is how long the sound of the instrument is. So if you use a longer sound and put notes close after each other, the sound would get cut off and start over every note.

 

Thank you, Turbo Laser Lynx. I definitely looked at your getting started guide several times, and I looked at the official documentation, which was developed for version 0.1 Beta and doesn't seem to cover much of the current program. And the Getting Started guide seems a bit too complex for me (or maybe too simple, I'm not sure). Like it just didn't give me enough information to get off the ground, ya know? Like an instruction like "Put in notes" leaves a lot of mystery. So I click squares and hit keys, and some notes pop into the boxes. And for putting in the number of the instrument, it seems like I can't just type in "26". Somehow various letters are associated with numbers in that field. Maybe it's hex. I'm not sure. And then it crashes, and I walk away sad. But maybe it would help to learn about trackers in general, like you say. Maybe one day... For today, I'm just hoping to get something going with abc. It's supposed to be easier.

Link to comment
Share on other sites

I had problems with everything at first too. About putting in notes, it's there, but I will clarify it more in the next re-write of the tutorial:

Quote

Note: you put in the notes with the keys of your keyboard (I was clicking aroung with the mouse for much longer than I care to admit) :P

They're lined up like on a piano, so the row that starts with Z on your keyboard is white keys, the next row starting with A is black keys. Q row is again white keys and numeric row is black keys. Then there was some way to get even higher or lower notes, but I can't remember the keyboard shortcut right now.

The instrument numbers are indeed hex in the tracker window (although the instruments are represented with decimals in the drop down menu in the simple instrument window).

Oh, and I forgot to say that I did use abc-music for all my mini-games/demos in the mid-2000s, I found that really easy to understand somehow, but Chipper is much faster and more convenient once you get the hang of it.

Also Karri's Lynx-DJ set up seem super fabulous too, I think especially if you were to perform live with chip music. But it should also be perfectly suitable for games. This one uses the HandyMusic driver which has its own strengths too.

 

Edited by Turbo Laser Lynx
  • Like 1
Link to comment
Share on other sites

23 minutes ago, Turbo Laser Lynx said:

They're lined up like on a piano, so the row that starts with Z on your keyboard is white keys, the next row starting with A is black keys. Q row is again white keys and numeric row is black keys.

Oh, my gosh. I didn't get that at all! Is that just an understood thing about trackers? Or did I just miss it in the documentation?

 

But it is really, really neat, though. Great idea.

Edited by OldAtAtari
  • Like 1
Link to comment
Share on other sites

Ok, I tried to shoehorn my program into the non-template main.c example that exists in the abcmusic directory. It was very difficult. And then I realized that my program really is the template example, only that I've added some sprite direction control and collisions (using coordinate overlaps), and I'm swapping out the music files for abcmusic. So I went back to trying to compile it in the template directory. I've adjusted the Makefiles to include abcmusic and my new additional sprite.

 

I'm suffering in the memory department, though. My Makefile results look like this:

 

steven@Steves2016HP:~/Atari/template$ make
"make" -C game;
make[1]: Entering directory '/home/steven/Atari/template/game'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/steven/Atari/template/game'
"make" -C intro;
make[1]: Entering directory '/home/steven/Atari/template/intro'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/steven/Atari/template/intro'
"make" -C resident;
make[1]: Entering directory '/home/steven/Atari/template/resident'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/steven/Atari/template/resident'
"make" -C tunes;
make[1]: Entering directory '/home/steven/Atari/template/tunes'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/steven/Atari/template/tunes'
"make" -C cart;
make[1]: Entering directory '/home/steven/Atari/template/cart'
cl65 -t lynx -o treeJumper.lnx -m lynx.map abcmusic.o directory.o @../resident/objlist @../intro/objlist @../game/objlist  lynx.lib
ld65: Warning: [builtin config](13): Memory area overflow in `DIR', segment `DIRECTORY' (32 bytes)
ld65: Error: Cannot generate output due to memory area overflow
make[1]: *** [Makefile:24: treeJumper.lnx] Error 1
make[1]: Leaving directory '/home/steven/Atari/template/cart'
make: *** [Makefile:6: all] Error 2

It worked fine until I added the abcmusic.

 

I tried tweaking the lynx.cfg line

  __DIRECTORYSIZE__: value = 5*8, type = export;

by changing the 5*8 to various things, all the way up to 64*8. But the error persists. 

 

It surprises me that abcmusic would require a .cfg change, as the abcmusic main.c example doesn't seem to require a custom .cfg at all. 

Is there something simple I'm missing?

By the way, here are my make files:

/template/Makefile:

all:
        "$(MAKE)" -C game;
        "$(MAKE)" -C intro;
        "$(MAKE)" -C resident;
        "$(MAKE)" -C tunes;
        "$(MAKE)" -C cart;

clean:
        "$(MAKE)" -C cart clean;
        "$(MAKE)" -C game clean;
        "$(MAKE)" -C intro clean;
        "$(MAKE)" -C resident clean;
        "$(MAKE)" -C tunes clean;

template/game/Makefile:

include ../Common.mk

thisdir=game

objects= \
        treeJumper.o \
        tree.o \
        dude.o

temporaryobjects= \
        tree.c \
        dude.c

SEGMENTS= \
        --code-name GAME_CODE \
        --rodata-name GAME_RODATA \
        --data-name GAME_DATA \
        --bss-name GAME_BSS

all: objlist

objlist: $(objects)
        $(RM) objlist
        for obj in $(objects); do $(ECHO) ../$(thisdir)/$$obj >> objlist; done

tree.c : tree.pcx
        $(SP) -r $< -c lynx-sprite,mode=packed,ax=94,ay=168 -w $*.c,ident=$*,bytesperline
=8

dude : dude.pcx
        $(SP) -r $< -c lynx-sprite,mode=packed,ax=94,ay=168 -w $*.c,ident=$*,bytesperline
=8

clean:
        $(RM) objlist $(temporaryobjects) $(objects)

/template/cart/Makefile

include ../Common.mk

objects= \
        abcmusic.o \
        directory.o

objlists = \
        ../resident/objlist \
        ../intro/objlist \
        ../game/objlist \


others = \
        @../resident/objlist \
        @../intro/objlist \
        @../game/objlist \


target = treeJumper.lnx

all: $(target)

$(target) : $(objects) $(objlists)
        $(CL) -t lynx -o $@ -m lynx.map $(objects) $(others) lynx.lib

clean:
        $(RM) $(objects) $(target) lynx.map

Of course I'm in well over my head at this point, going from hacking up a simple example to having to deal with memory assignments. But's it's probably an error in my hacking that's requiring the extra memory in the first place.

Does anyone have any ideas? Thanks. You guys are the best, as always.

 

 

 

 

 


 

 

 

 

Edited by OldAtAtari
Link to comment
Share on other sites

@Turbo Laser Lynx

Taking a break from my programming frustrations, I thought I'd play around with Chipper. The thing about the keyboard keys is helpful. So I've put in a handful of notes, as in the image, but when I hit Play Track or Play, it only plays the first note. Any idea what I'm missing? And feel free to tell me to RTFM. ?
image.thumb.png.250fbd829aaaa39df834f417569d08a6.png

 

Link to comment
Share on other sites

22 minutes ago, Turbo Laser Lynx said:

Try changing instrument on each note, perhaps having them that close together makes it sound like only one note.

Good idea, but no dice. Changing the instruments doesn't help. When I hit Play, I hear the first note and see it flash. As the other notes flash and turn red, one by one, there is silence.

image.thumb.png.aec62eb9d21f17511eb785d1f434bebc.png

Edited by OldAtAtari
Link to comment
Share on other sites

14 minutes ago, OldAtAtari said:

Good idea, but no dice. Changing the instruments doesn't help. When I hit Play, I hear the first note and see it flash. As the other notes flash and turn red, one by one, there is silence.

image.thumb.png.aec62eb9d21f17511eb785d1f434bebc.png

Your instruments are 1,2,3,4,5,6,7,8 in this tune. Have you loaded some instruments to these slots?

 

You need to open the panel that looks like this:  http://whitelynx.fi/chipper/

Look at the highlighted element at top right. There is several places for instruments but you need to load them.

  • Like 1
Link to comment
Share on other sites

10 minutes ago, karri said:

Your instruments are 1,2,3,4,5,6,7,8 in this tune. Have you loaded some instruments to these slots?

 

You need to open the panel that looks like this:  http://whitelynx.fi/chipper/

Look at the highlighted element at top right. There is several places for instruments but you need to load them.

Yes! You are right, Karri! I thought that the basic instruments were pre-defined and pre-loaded. So I had to go into that screen, define them and load them. Thank you! I seem to be able to make music now. Or sounds, anyway.

Link to comment
Share on other sites

Ok, big news. I have completed my first silly practice game! It has an intro screen, two moving sprites, scaling, collisions, score keeping, and some of the worst sound effects you've ever heard. By the way, the three Chipper secrets for me were:

 

1) from Turbo Laser Lynx - The bottom two rows on the keyboard act like piano keys.

2) from Karri - When you see "1. SimpleInstr", that's not an instrument. It's a placeholder that you have to load an instrument into.

3) from BitJag in an old post https://atariage.com/forums/topic/249163-example-code-for-cc65-tgi-sound-functions/ - After I export the sound file from Chipper, I need to go in there and edit the head to match my code. (I just copied the head that was in existing /template/tunes/ file)

 

So that's it. I'll clean up the code and post it here soon, so that you all can critique it, and maybe some newbie like me can download it someday and use it as a learning example or maybe the start of a new game.

 

 

Thanks everybody for your support and for your patience!

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, OldAtAtari said:

So that's it. I'll clean up the code and post it here soon,

May I suggest that you put your code on github/gitlab instead of posting it here.

For one, you have a history and it is easier to download.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@42bs@karri@Turbo Laser Lynx, and any others who care to look:

Here is my pretty much complete first game "Tree Jumper". It's simple and not much fun, but it was really just a means of learning the process and the tools. And I hope that other newbies in the future might be able to use it for something. Thanks to all of you for your assistance.

 

https://github.com/OldAtAtari/TreeJumper (my first Github, so if I messed it up, just let me know)

 

The measurements aren't dead-on, when it comes to collision and such, but that's ok. I didn't want to spend too much time fine-tuning this practice program once I got it basically working.

 

The only broken thing I care about fixing is the reset. I'm not sure what I'm doing wrong there. It works during the game, but I can't reset from the "Game Over" screen. It seems like the program just dies when it hits that point. I'm sure there's a perfectly obvious c-programming mistake I'm making.

Feel free to pick it apart and give your constructive criticisms.

 

Thank you!

 

image.png.210f13331f534030462924c728aceb9c.png

 

  • Like 1
Link to comment
Share on other sites

Large arrays on the stack might produce bad code (not sure, check Assembly).

You might want to use #defineS for the constants to be more flexible when you change for example the player Sprite.

And IMHO the indenting is horrible ;-) Does your editor not support auto-identing?

Just my 2cents (Euro, not Dollar ? )

 

Some more: For the logic and understanding I'd initialize the jump variable on jump start not when the jump has finished. Saves also the need to set the variables at the beginning of the function.

Edited by 42bs
  • Like 1
Link to comment
Share on other sites

11 hours ago, 42bs said:

Large arrays on the stack might produce bad code (not sure, check Assembly).

You might want to use #defineS for the constants to be more flexible when you change for example the player Sprite.

And IMHO the indenting is horrible ;-) Does your editor not support auto-identing?

Just my 2cents (Euro, not Dollar ? )

 

Some more: For the logic and understanding I'd initialize the jump variable on jump start not when the jump has finished. Saves also the need to set the variables at the beginning of the function.

Thanks, 42bs. I'm such a programming hack. I really appreciate your advice. It will take me a while to dig into all of this. As for the indenting, wow! You are correct! I know it didn't look that bad on my PC, using Notepad++, but on GitHub, it's horrific. I'll investigate and fix that. Thanks again.

Link to comment
Share on other sites

13 hours ago, 42bs said:

draw_screen() misses a return at the end of the function.

 

Hmmm, the "return 1" was there, and now I've moved it around and tried it in different ways. I'm betting that the problem is more of what you said in your other post, which is a stack corruption. That will take some extra work to debug. I'll work on that later.

Link to comment
Share on other sites

13 hours ago, 42bs said:

And IMHO the indenting is horrible ;-) Does your editor not support auto-identing?

I resolved the indenting problem. The problem was that my code had a combination of spaces and tabs. GitHub likes spaces. So 4 spaces is just great when you upload code to GitHub. But I read that GitHub will take a single tab in your code and convert it to 8 spaces. So my lines with tabs essentially got double-indented when I uploaded to GitHub.

In Notebook++, there's an option in Settings/Preferences/Languages that will convert tabs to spaces. I've turned that on now. It seems to work well. The new code in GitHub looks better.

 

image.thumb.png.76f57d97e2394c7ade0ad76b4a8a0069.png

 

Link to comment
Share on other sites

On 8/22/2020 at 9:36 AM, OldAtAtari said:

The bottom two rows on the keyboard act like piano keys.

Also the qwerty row and the numeric row (top two rows if you don't count the function keys). :thumbsup:
 

On 8/22/2020 at 10:39 AM, Nop90 said:

To make the tune loop add in the esported asm a DO 0  before the beginning of the loop, and LOOP after the end of the loop, for every channel you use in the tune.

Important hint from Nop! ^^

Like this (unless it's an sfx channel):

CHANNEL_0:
	PATTERN ENVIROS
	DO 0
	PATTERN PATTERN_01
	PATTERN PATTERN_05
	PATTERN PATTERN_81
	PATTERN PATTERN_09
	PATTERN PATTERN_13
	PATTERN PATTERN_13
	PATTERN PATTERN_17
	PATTERN PATTERN_17
	PATTERN PATTERN_85
	PATTERN PATTERN_81
	PATTERN PATTERN_25
	LOOP
CHAN_STOP

 

On 8/22/2020 at 9:36 AM, OldAtAtari said:

After I export the sound file from Chipper, I need to go in there and edit the head to match my code. (I just copied the head that was in existing /template/tunes/ file)

Sorry, I had completely forgotten about this.
 

18 hours ago, OldAtAtari said:

Here is my pretty much complete first game "Tree Jumper".

Great haha! :thumbsup: Getting pushed over the edge + sound effect really made me giggle every time. The color palette of the player immediately reminded me of Giana sisters. "Tree Jumper" Giana sister's lesser known big brother. :grin: I really like the sound effects too, they sound great.
 

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

2 hours ago, Turbo Laser Lynx said:

I really like the sound effects too, they sound great.

Well you are very kind! Thank you! The sound effects seem very "Atari 2600" to me, but it was enough to prove to myself that I'm capable of getting sounds out of Chipper. I'd put more time into it for a "real" game. But thanks again!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...