Jump to content
IGNORED

cc65 for Windows


karri

Recommended Posts

Try to create a timer and do your animation based on it. The speed will be the same, no matter what the frequency is.

 

I can help you with some code if you want.

 

If frame rate drops often, I'd stay with the lower frame rate. IHMO a drop is more visible then a constant slow down.

Of course you could use triple buffering ;-) But then you need 4*8000 bytes of RAM if you use a collision buffer.

 

Link to comment
Share on other sites

I still have to implement timers. I did gain enough headroom for an extra bullet simply by replacing INTs with CHARs wherever possible, especially as loop control variables. I'm going to be out for a few days, but I'll clean up and post my code when I get back. Thank you all for the tips!

Link to comment
Share on other sites

OK, here's my project. I still haven't implemented any timers.

 

I set it up according to the very nice Atari Lynx Programming tutorial here:

 

https://atarilynxdeveloper.wordpress.com/series/atarilynxprogrammingtutorial/

 

I did not go with Visual Studio though, just a makefile and GNU make. So it uses make (for GNU Make,) external resources for sprite data, SP65 and/or SPRPCK, and the Unix utilities set he recommends for the makefiles.

 

All of the code is in C, with external resources being the sprite data as .o files converted from BMP or PCX-drawn sprites (robot, bullets, playfield.)

 

I tried to format it properly and comment it sufficiently. Understand I'm not only not a C programmer, I'm not even a programmer. This is my first attempt at something since LOGO in junior high school. So if you have any ridicule for me, please let me have it so I may learn :)

 

Edit: Shot speed to the right is slowed down to make it easier to test number of bullets on screen. One of the buttons changes the robot walk speedfactor. Default 50, but will go up to 100. No slow down button anymore - that is now the fire button. The score shows number of frames, and the second number shows the robot speedfactor.

robogame.zip

Edited by rmzalbar
Link to comment
Share on other sites

I'm reading about how to use the timers on the Lynx, and how to use timers for controlling the flow of real-time games in general. First though, I will learn to use pointers to update my SCBs instead of querying the arrays every update, to see how much that improves performance.

 

Oh yeah, and learn use the timers to measure execution of different functions so I can tell when I'm doing better.

Link to comment
Share on other sites

So I had a quick look at your code, and without digging much into it, I can say that I'm not surprised your game is slowing down when a couple of bullets are active.

I think the mother of all evil is the playershotmove() function.

 

There you iterate through 16 "shots". If they are inactive you do nothing, but when they are you have way too many if with way too many conditions. On top of that, you're not testing against simple variables but against 2 dimension arrays.

 

I would recommend the following:

1) Create a shot/bullet structure with the data you need (probably some position). It's going to be clearer than an array of 4 char. And you will be able to get a pointer on the struct later on.

2) Get a pointer on the shot/bullet structure instead of adressing everything through "shots[3]"

for (i = 0; i < MAXSHOTS; ++i) {
    struct SBullet* bullet;
    bullet = &shots[i];
    if (bullet->state == 200) {
       continue;
    } else if (bullet->state > 9) {
        // something
    } else {
        // something else
    }
}

3) Try to simplify playershotmove()

4) Try to update your score only when needed. It's probably not doing any good to calls itoa 2 times on every frame (in upkeep())

 

Last but not least, keep up the good work, it's pretty amayzing what you achieve if you're not a developer!!!

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

I can double the tip about arrays. Multi-index arrays create bad code. Esp. if the sizes are not "nice" (means multiple of 2) numbers.

So if you have

char test[8][10];

You have a multiply by 10 for every test[x][y] access.

 

Rather you switch case instead of multiple if.

 

Some hint on coding style: Use #defineS for "magic" numbers (like MAXSHOTS). Makes it easier to understand the code in half year ;-)
For example for the boundery checks.

 

I suggest to check if "unsigned char" is really producing better code.

In addition to LordKraken: Load array/struct elements into a variable:

for (i = 0; i < MAXSHOTS; ++i) {
struct SBullet* bullet;
char state;
bullet = &shots[i];
state = bullet->state;
if (state == 200) {
  continue;
} else if (state > 9) {
// something
} else {
// something else
}
}

And maybe binary code your movement:
bit 0 => up

bit 1 => down

bit 2 => left

bit 3 => right

hpos = playersprite.hpos;
vpos = playersprite.hpos;

if ( (walk & 3) && (walk & 0xc) ){
  /* diagonal walk */
} else {
  /* cardinal walk */
}
if ( walk & 1 ){
 ++hpos; /* quicker than hpos++ and hpos += 1 */
} else if ( walk & 2 ){
  --hpos;
}
if ( walk & 4 ){
  ++vpos;
} else if ( walk & 8 ){
  --vpos; 
}
if ( vpos > LEFT_BOUND && vpos < RIGHT_BOUND ){
  playersprite.vpos = vpos; /* set new pos */
}
if ( hpos > UPPER_BOUND && hpos < LOWER_BOUND ){
  playersprite.hpos = hpos;
}

Just my 2 cents

  • Like 1
Link to comment
Share on other sites

I'm reading about how to use the timers on the Lynx, and how to use timers for controlling the flow of real-time games in general. First though, I will learn to use pointers to update my SCBs instead of querying the arrays every update, to see how much that improves performance.

 

Oh yeah, and learn use the timers to measure execution of different functions so I can tell when I'm doing better.

 

I think you should have different robot sprites to show in which direction it will shoot.

Link to comment
Share on other sites

Thank you for all the feedback! I am about 40 pages into the C programming language book, and last night I was staring at ASM examples and the timers/interrupts in LX.NETs Lynx tutorial. Then I followed that over to the 6502 interrupts tutorial and fell down the rabbit hole. I'll start making changes in another day or so.

Link to comment
Share on other sites

  • 3 months later...

I have newcc65 working fine on windows, but I was running into all kinds of issues with cc65 "remake" when trying to run that in windows cmd. Anyhow it's been fun to learn a little bit about Linux on the Rasberry Pi, I've been enjoying it, so my thought was simply to continue lynxdev on linux side, but perhaps try it out on that windows linux subsystem if I feel like updating to win10.

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

If you fail with wsl, the easiest is to setup a VM with Linux. I do this everyday because all kinds of stuff needs to be done on Linux (e.g. Yocto).

 

Oracle Virtual Box is nice and you can exchange files with windows over a shared folder.

 

So running cc65 in the VM and the uploader/handy on Windows works w/o pain.

Link to comment
Share on other sites

  • 6 months later...
  • 8 months later...

Hi All, I can now share Spacecube, my 3d drawing program (early release) written in cc65 .

If you want to see/ experiment with the code goto http:// https://ANDREW-PROGS@bitbucket.org/ANDREW-PROGS/allcubes.git

As with previous release i could only get the code to work using game.O in mednafen.

I use 42bs Drawtriangle and Sintab81 code from bll

The planet background sprite was drawn using Gimp and was packed using Nop90's extended Sprpck app.

??

 

spacecube.png

game.O

Edited by Positron5
To clarify and remove typos
  • Like 1
Link to comment
Share on other sites

  • 10 months later...

Hi All, I have made some updates to the spacecube project and I want to share them with you.

This demo I've called CubeContact and displays a rotating cube with a simple hidden surface removal technnique.

Also the cube coordinate system is much improved giving the possibility of other 3d object design handling.

The code is available here:

https://ANDREW-PROGS@bitbucket.org/ANDREW-PROGS/contacts.git

image.thumb.png.280d12b36f6578ccc9dfa0d2a8776031.png

 

game.O

(will run in handy)

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...