Jump to content
IGNORED

Pong with segments


karri

Recommended Posts

I already found out that having many tunes in the same build causes some clashes in the namespace.

 

The format of Chipper is nice. It would be very nice to have a set of cool sound effects that could be used in real time. Perhaps we could maintain a Chipper sound library in Bitbucket with cool sound effects? You could save the sounds in BLL, newcc65 and "cc65 remake" formats.

 

To use it you may need to give the musicptr some sensible name like _boingsound in order to use it from C-code.

 

;;; source file for CC65 "remake" compiler
.include "soundbs.mac"
.global _boingsound
.rodata
_boingsound:
.word CHANNEL_0, CHANNEL_1, CHANNEL_2, CHANNEL_3

PATTERN_LENGTH   .set  2560

CHANNEL_0:
PATTERN ENVIROS
PATTERN PATTERN_01
PATTERN PATTERN_04
CHAN_STOP

CHANNEL_1:
PATTERN ENVIROS
PATTERN PATTERN_02
PATTERN PATTERN_02
CHAN_STOP

CHANNEL_2:
PATTERN ENVIROS
PATTERN PATTERN_03
PATTERN PATTERN_03
CHAN_STOP

CHANNEL_3:
PATTERN ENVIROS
PATTERN PATTERN_DELAY
PATTERN PATTERN_DELAY
CHAN_STOP
...

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I've been manually editing these .asm files btw, and wondered about the relevance of 'PATTERN_LENGTH .set 2560 '. Since i've been removing patterns etc, does anyone foresee a problem? I guess I would need to understand how that value is calculated in order to change it manually.

Link to comment
Share on other sites

  • 1 year later...

Hi! I've been tampering with installing cc65 remake and finally maybe got it (I think/hope) I'm now trying to compile the pong with segments example but I ran into problems. It seems sh.exe keeps crashing when running make and unfortunatley I'm not exactly knowing what I'm doing. I wonder if I would need some cygwin stuff to make everything run properly on windows or if the cc65 snapshots downloaded from LX.NET's tutorial thread are newer and incompatible with the pong example. Any help appreciated.

 

RIN# make
C:/CC65/usr/local/wbin/make.EXE -C cart
make.EXE[1]: Entering directory `C:/Lynx/pong2/cart'
C:/CC65/usr/local/wbin/make.EXE -C ../intro
make.EXE[2]: Entering directory `C:/Lynx/pong2/intro'
make.EXE[2]: Nothing to be done for `all'.
make.EXE[2]: Leaving directory `C:/Lynx/pong2/intro'
C:/CC65/usr/local/wbin/make.EXE -C ../music
make.EXE[2]: Entering directory `C:/Lynx/pong2/music'
rm -f objlist
for obj in track2.o; do echo ../music/$obj >> objlist; done
make.EXE[2]: Leaving directory `C:/Lynx/pong2/music'
C:/CC65/usr/local/wbin/make.EXE -C ../play
make.EXE[2]: Entering directory `C:/Lynx/pong2/play'
cc65 -t lynx --code-name PONG_CODE --rodata-name PONG_RODATA --data-name PONG_D
ATA --bss-name PONG_BSS -o pong.s pong.c
ca65 -t lynx -o pong.o pong.s
rm -f pong.s
rm -f objlist
for obj in pong.o; do echo ../play/$obj >> objlist; done
make.EXE[2]: Leaving directory `C:/Lynx/pong2/play'
C:/CC65/usr/local/wbin/make.EXE -C ../main
make.EXE[2]: Entering directory `C:/Lynx/pong2/main'
cc65 -t lynx -o main.s main.c
main.c(30): Error: Call to undefined function `lynx_snd_init'
main.c(36): Error: Call to undefined function `lynx_snd_pause'
main.c(38): Error: Call to undefined function `lynx_snd_play'
main.c(42): Error: Call to undefined function `lynx_snd_continue'
make.EXE[2]: *** [main.o] Error 255
make.EXE[2]: Leaving directory `C:/Lynx/pong2/main'
make.EXE[1]: *** [all] Error 2
make.EXE[1]: Leaving directory `C:/Lynx/pong2/cart'
C:\CC65\usr\local\wbin\make.EXE: *** [all] Error 2
RIN#

 

Also when I try to compile an old MegaPak template with Catacomb Raider on it it says:

 

"C:/CC65/usr/local/wbin/make.EXE" -C resident;

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make30002.sh: fork failed: no error [1]
"C:/CC65/usr/local/wbin/make.EXE" -C intro;
C:\CC65\usr\local\wbin\make.EXE[1]: Entering directory `C:/Lynx/MegaPak/intro'
cc65 -I . -t lynx --add-source -O -Or -Cl -Os --code-name INTRO_CODE --rodata-na
me INTRO_RODATA --bss-name INTRO_BSS --data-name INTRO_DATA -o intro.s intro.c
intro.c(11): Error: Macro redefinition is not identical
intro.c(12): Error: Macro redefinition is not identical
intro.c(13): Error: Macro redefinition is not identical
intro.c(653): Warning: Converting integer to pointer without a cast
intro.c(658): Warning: Converting integer to pointer without a cast
intro.c(664): Warning: Converting integer to pointer without a cast
intro.c(669): Warning: Converting integer to pointer without a cast
intro.c(689): Warning: Converting integer to pointer without a cast
intro.c(694): Warning: Converting integer to pointer without a cast
intro.c(700): Warning: Converting integer to pointer without a cast
intro.c(705): Warning: Converting integer to pointer without a cast
intro.c(1152): Warning: Converting integer to pointer without a cast
intro.c(1191): Warning: Converting integer to pointer without a cast
C:\CC65\usr\local\wbin\make.EXE[1]: *** [intro.o] Error 255
C:\CC65\usr\local\wbin\make.EXE[1]: Leaving directory `C:/Lynx/MegaPak/intro'
C:\CC65\usr\local\wbin\make.EXE: *** [all] Error 2

 

The lines it's complaining about are:

#include <lynx.h>
#include <tgi.h>
#include <joystick.h>
#include <stdlib.h>
#include <conio.h>
#include <6502.h>
#include <string.h>
#include "../resident/resident.h"
#include "../abcmusic/abcmusic.h"

#define tgi_sprite(spr) tgi_ioctl(0, (unsigned)(spr))
#define tgi_flip() tgi_ioctl(1, 0)
#define tgi_setbgcolor(col) tgi_ioctl(2, (unsigned)(col))
Link to comment
Share on other sites

You are still missing the latest cc65. The missing chipper support complains about not having lynx_snd.

 

The reason for tgi_sprite etc is that these definitions are now part of cc65 and you should delete these lines from your own code.

 

We put up a repository for the cc65 version that is stable. I could try to make a Windows version of all the latest stuff and put it in a download section.

 

https://bitbucket.org/atarilynx/lynx

 

PS. A quick check showed me that the binaries by LX.NET are the latest in the pinned Tutorial section. So I am not going to change anything here.

--

Karri

Edited by karri
Link to comment
Share on other sites

Sorry about the previous misleading post. The chipper is not part of the c65. Perhaps it should be.

 

I really have to check the status of this detail. In order for chipper to work you need to add a file to your project.

 

You also need to add a few defines to use it:

 

 

 

void lynx_snd_init ();
void lynx_snd_pause ();
void lynx_snd_continue ();
void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
void lynx_snd_stop ();

 

My original idea was to include this into cc65. But for some reason (which I don't remember) I have not done this.

 

Just rename this to lynx-snd.s and add it to your compiled sources.

 

ca65 -t lynx -I $(CC65_ASMINC) -o lynx-snd.o $(AFLAGS) lynx-snd.s

--

Karri

lynx-snd.txt

Edited by karri
Link to comment
Share on other sites

I could try to make a Windows version of all the latest stuff and put it in a download section.

 

 

That would be amazingly awesome obviously :grin: I'll play around more with this today and see if I can get anything to work. Chipper got me really excited too, it should be so much easier to create better lynx-music with it.

Link to comment
Share on other sites

 

That would be amazingly awesome obviously :grin: I'll play around more with this today and see if I can get anything to work. Chipper got me really excited too, it should be so much easier to create better lynx-music with it.

 

I already compiled it but the result is identical to the files at LX.NET. Your installed compiler is already ok.

Link to comment
Share on other sites

I got pong to compile both with and without music, wohoo! But I still have some weird problems. When running "make" or "ls" only 1 in 5 times seems to work, otherwise it throws "abnormal program termination", i also get that in the middle of the compiling but it seems to work anyway.

 

Also although there's rules for creating .o files from .s files in Common.mk I have to ca65 the .s files manually, maybe there's som path(s) wrong. I managed to add lynx-snd as an object to the cart make file so now it doesn't complain about the missing externals any more but it warns something about the segments instead. With the pong example at least I got forward by experimenting (and guessing) but I don't understand at all what goes wrong when trying to compile the old MegaPak (further down). Again any help mega-appreciated, sry for being such an old noob :/

 

make.EXE[2]: Entering directory `C:/Lynx/pong2/cart'
cl65 -t lynx -C lynx-coll.cfg -o pong.lnx -m pong.map exehdr.o directory.o @../i
ntro/objlist @../music/objlist @../play/objlist @../main/objlist lynx.lib
ld65.exe: Warning: lynx-coll.cfg(67): Segment `PONG_RODATA' does not exist
ld65.exe: Warning: lynx-coll.cfg(67): Segment `PONG_BSS' does not exist
ld65.exe: Warning: lynx-coll.cfg(67): Segment `INTRO_DATA' does not exist
ld65.exe: Warning: lynx-coll.cfg(67): Segment `INTRO_BSS' does not exist
make.EXE[2]: Leaving directory `C:/Lynx/pong2/cart'
make.EXE[1]: Leaving directory `C:/Lynx/pong2/cart'
RIN#

With the pong example at least I got forward by experimenting (and guessing) but I don't understand at all what goes wrong when trying to compile the old MegaPak:

 

RIN# cd MegaPak/
RIN# make
"C:/CC65/usr/local/wbin/make.EXE" -C resident;
C:\CC65\usr\local\wbin\make.EXE[1]: Entering directory `C:/Lynx/MegaPak/resident
'
ca65 -t lynx -I "C:\CC65\include/../asminc" -o fadeout.o fadeout.s

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make50482.sh: fork failed: no error [1]
ca65 -t lynx -I "C:\CC65\include/../asminc" -o fileexec.o fileexec.s
ca65 -t lynx -I "C:\CC65\include/../asminc" -o vbl.o vbl.s
touch objlist
rm objlist
for obj in aaresident.o lynxeeprom.o eeprom.o fadein.o fadeout.o filedir.o filee
xec.o filehelp.o fileload.o irq.o lynx-stdjoy.o lynx-160-102-16.o uploader.o vbl
.o kbhit.o cgetc.o; do echo ../resident/$obj >> objlist; done
C:\CC65\usr\local\wbin\make.EXE[1]: Leaving directory `C:/Lynx/MegaPak/resident'

"C:/CC65/usr/local/wbin/make.EXE" -C intro;
C:\CC65\usr\local\wbin\make.EXE[1]: Entering directory `C:/Lynx/MegaPak/intro'
touch objlist
rm objlist
for obj in intro.o bricks_megapak.o radioon.o radiooff.o checkon.o checkoff.o Me
gaPak.o game.o image.o music.o toolbox.o; do echo ../intro/$obj >> objlist; done

C:\CC65\usr\local\wbin\make.EXE[1]: Leaving directory `C:/Lynx/MegaPak/intro'
"C:/CC65/usr/local/wbin/make.EXE" -C abcmusic;

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make16804.sh: fork failed: no error [1]
"C:/CC65/usr/local/wbin/make.EXE" -C mygame;

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make16805.sh: fork failed: no error [1]
"C:/CC65/usr/local/wbin/make.EXE" -C music;

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make16806.sh: fork failed: no error [1]
"C:/CC65/usr/local/wbin/make.EXE" -C miniloader;
C:\CC65\usr\local\wbin\make.EXE[1]: Entering directory `C:/Lynx/MegaPak/miniload
er'
touch objlist
rm objlist
for obj in aaminiexec.o minidir.o minihelp.o miniload.o; do echo ../miniloader/$
obj >> objlist; done
C:\CC65\usr\local\wbin\make.EXE[1]: Leaving directory `C:/Lynx/MegaPak/miniloade
r'
"C:/CC65/usr/local/wbin/make.EXE" -C cart clean;
C:\CC65\usr\local\wbin\make.EXE[1]: Entering directory `C:/Lynx/MegaPak/cart'
touch lnxhdr.o encrypt1024.o directory.o title.o
rm lnxhdr.o encrypt1024.o directory.o title.o
touch cart.lnx
rm cart.lnx
touch lynxcart.map
rm lynxcart.map
C:\CC65\usr\local\wbin\make.EXE[1]: Leaving directory `C:/Lynx/MegaPak/cart'
"C:/CC65/usr/local/wbin/make.EXE" -C cart;

abnormal program termination
C:\Users\Sampo\AppData\Local\Temp\make16809.sh: fork failed: no error [1]
cp cart/cart.lnx .
cp: cart/cart.lnx: No such file or directory
C:\CC65\usr\local\wbin\make.EXE: *** [all] Error 1
RIN#

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

many things are simplified a lot since the MegaPak template.

 

You don't need to compile tgi or joy libs anymore. The fadeout/fadein does not work well currently. I have not looked into it.

 

A typical hello.c looks like this:

 

 

#include <lynx.h>
#include <tgi.h>
#include <6502.h>

void main(void) {
  tgi_install(&lynx_160_102_16);
  tgi_init();
  CLI();
  while (tgi_busy())
    ;
  tgi_clear();
  tgi_setcolor(COLOR_GREEN);
  tgi_outtextxy(0, 0, "Hello World");
  tgi_updatedisplay();
  while (1)
    ;
}
Link to comment
Share on other sites

You could look at "Shaken, not stirred" for an example.

 

https://bitbucket.org/karri/shaken

 

You should look at the sources and especially the

cart/lynx.cfg

cart/directory.s

 

to see what kind of new defines are required in lynx.cfg.

 

There is also no explicit bootloader anymore.

 

And in the bitmaps directory all bitmaps are compiled to sprites using sp65. Only *.pcx format is supported. You can easily convert your graphics to pcx in Gimp.

 

static void initlynx() {
tgi_install(&tgi_static_stddrv);
tgi_init();
joy_install(&joy_static_stddrv);
lynx_snd_init();
CLI();
lynx_snd_pause();
lynx_snd_play(0, musicptr.music0);
lynx_snd_play(1, musicptr.music1);
lynx_snd_play(2, musicptr.music2);
lynx_snd_play(3, musicptr.music3);
lynx_snd_continue();
};
Edited by karri
Link to comment
Share on other sites

Yay! I managed to compile shaken now, but there's a lot of stuff going on that I don't understand, if anyone has any ideas help would be super-appreciated.

 

- It complained that there's no rule for creating an objectlist, although I think I see stuff for that in the makefiles. Anyways, I created object lists manually into the cart and intro folders.

 

- it seems that it still can't create some .o files, but just a while ago created a bunch of .o files in the bitmaps directory, but in the cart directory i had to ca65 them manually.

 

I wonder if there's something wrong with my cc65 installation or could it be windows 8.1? (or probably just the user :? )

Link to comment
Share on other sites

Thanks LX.net, that would be very nice of you. Actually I'm thinking about setting everything up with visual studio in case that would help, but then again that wouldn't be helpful at all if the underlying cc65 installation is somehow screwed up.

There are two new articles on my blog that guide you through the steps of setting up your machine and do a clean compile of both the CC65 tools and the Shaken project. I will expand the examples in the latest post to also include the Pong with Segments game.

Here are the two articles:

  1. https://atarilynxdeveloper.wordpress.com/2015/03/29/compiling-cc65-suite-and-lynx-libraries/
  2. https://atarilynxdeveloper.wordpress.com/2015/03/30/compiling-lynx-homebrew-projects/

Please let me know if you find these useful and if you are missing something here or run into trouble otherwise.

Good luck. I will ping this thread if I expand the post with Pong or otherwise.

Link to comment
Share on other sites

@LX.net That's so great! I already read both and look forward to getting it to work. A big thanks also for the whole programming tutorial on your blog, it's really amazing and an important contribution to the Lynx community! I must have read it 3-4 times already the last years.

 

@Karri I've read about the segments in LX.net's tutorial many times and I feel I understand the theory fine, however understanding it on a practical level (the shaken code) is a bit tougher. When I look at lynx.cfg and directory.s it seems to me that all five parts begin at the same place in memory $0200 so those can replace each other in ram, but I can't see where the resident file is placed in the memory (the main one that can't be replaced/removed), is that the RAM part $BE38 minus $1c00?

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

Yes. All the default segments like Lynx libraries, CODE, DATA, RODATA are in the RAM segment. I just decided to chip away $1C00 bytes from the beginning of memory for the background sprites (Casino, Warehouse, Garage, Spa, Alley, Penny). This was a very basic segmentation. All code is in the RAM segment in Shaken.

ZP:     file = "", define = yes, start = $0000, size = $0100;not defined machine stack start at $0100, size $0100SPA:    file = %O, define = yes, start = $0200, size = $1c00;RAM:    file = %O, define = yes, start = $1e00, size = $BE38 - $1c00 - __STACKSIZE__;SCREEN buffers start at $BE38

Start of RAM = $1e00

 

I even noticed a typo. The RAM size should be "all the rest of memory" This means $BE38 - $1E00.

Then we also need to reserve space for the BSS and subroutine calls. These go into __STACKSIZE__.

This is defined as

 __STACKSIZE__: type = weak, value = $0800; # 2k stack

This means that the correct RAM size should have been

size = $BE38 - $1e00 - __STACKSIZE__;

or simply

 

size = $9838;

Edited by karri
Link to comment
Share on other sites

  • 4 years later...

Hey guyz!

I would like to ask for a little help on getting Chipper working with CC65.

I am using the attached files (which come from another thread), which I can compile and link.

Inside my code, I have implemented:

 

	extern unsigned char *music;
	void PlayMusic() { 
		lynx_snd_pause();
		lynx_snd_play(0, music);
		lynx_snd_continue();
	}
	void StopMusic() { 
		lynx_snd_stop();
	}

But the game freezes when I get to lynx_snd_play.  Maybe I am not declaring the music data correctly...?

I am using a recent version of cc65, and everything else (sprites, joystick, etc...) is working as it should.

 

Thanks in advance for any help!

Tony

music.asm soundbs.mac

Link to comment
Share on other sites

Hi Tony!

I compared the soundbs.mac file with the one in the newest version of Karri's template with Nop90's add ons, and they're identical:

 

So I think the issue probably is that you're using a newer version of CC65 then, because it was froze in time for this specific version of Lynx CC65. Here's a link to where you can find the correct version of everything:
https://atariage.com/forums/topic/287147-is-10-fps-a-too-low-framerate-for-a-lynx-tile-based-game/page/2/?tab=comments#comment-4202302

 

Edited by Turbo Laser Lynx
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...