Jump to content
IGNORED

cc65 - Having trouble with player 0 and garbage being drawn, also _graphics


bkumanchik

Recommended Posts

I watched a YouTube video on Atari BASIC Player Missile graphics and have tried to duplicate the same thing with cc65 by converting it to C , I can get my sprite (invader) to show up as it should, but even after clearing out the sprites data first, I am still getting garbage on the screen.

 

I don't think it's related to the sprite as it's not the sprites color. Also if I try to set the graphics mode with  _graphics(0)  then I don't see my sprite at all. Please see attached file:

 

Any help would be appreciated, thanks

 

Brian

 

 

invader.c

  • Like 1
Link to comment
Share on other sites

I don't believe that the _graphics(0) call will do anything but crash, unless the linker configuration file is adjusted to have at least 1 byte of reserved memory (refer to: https://cc65.github.io/doc/atari.html#ss6.1)

Also, using the RAMTOP to reserve an area of memory is not the best idea with cc65, because it is likely to create a conflict with the cc65 runtime stack.

 

Using the standard linker configuration:

The C runtime stack lowest address is at $B420, page $B4.

When entering main(), RAMTOP is $C0

To reserve two kilobytes of RAM for PMG, the desired RAMTOP should be $B4-$08 = $AC, so the RAMTOP should be lowered by at least 20, otherwise the PMG area will be "shared" with the cc65 runtime stack, which is undesirable.

 

 

 

  • Like 3
Link to comment
Share on other sites

I have a lot of it working but I'm starting to run into issues as I add more code my graphics start doing weird things, I tried setting my sprites up as shown above that Baktra recommended but i was even worse, am I moving my sprites in the Y the wrong way and having memory overwrite things or what, when I started completely rewriting my code to work with the example above I ran into trouble even sooner. issues like my invader sprite would animate for about 4 or 5 frames then just stop animating but still moving or my shots would start halfway down the screen, etc.

 

You can move the turret left and right and fire and hit the invader for 10 points , also the invader fires (no collision with him yet) I'm just trying to learn how to program the atari 8-bit computers with C and cc65.

 

Any help would be appreciated, thanks,

 

Brian

invader.zip

Link to comment
Share on other sites

@bkumanchik I've compiled your code and from what I've seen, it's working fine, apart from the invader runs

off the bottom of the screen :) and the invader "shot" doesn't kill the turret.

 

However, not sure what environment your compiling under. But when I first tried I was getting loads of warnings about

"Constants being long" and this may have introduced errors into the end result.

 

The fix was simple it was complaining wherever you used this type of code:-POKE(53277, 3);                             // enable player missile graphics

 

If you #include <atarisyseq.h> and use the system defines instead of the numeric addresses all the warning go away,

also it makes your code more readable. i.e.     POKE(GRACTL, 3);                             // enable player missile graphics

 

Hope this helps

 

Edited by TGB1718
Link to comment
Share on other sites

30 minutes ago, TGB1718 said:

@bkumanchik I've compiled your code and from what I've seen, it's working fine, apart from the invader runs

off the bottom of the screen :) and the invader "shot" doesn't kill the turret.

 

However, not sure what environment your compiling under. But when I first tried I was getting loads of warnings about

"Constants being long" and this may have introduced errors into the end result.

 

The fix was simple it was complaining wherever you used this type of code:-POKE(53277, 3);                             // enable player missile graphics

 

If you #include <atarisyseq.h> and use the system defines instead of the numeric addresses all the warning go away,

also it makes your code more readable. i.e.     POKE(GRACTL, 3);                             // enable player missile graphics

 

Hope this helps

 

What environment are you compiling under? can you show me?

Link to comment
Share on other sites

Are you using "Mapping the Atari" ?

It describes all the memory locations and their names.

 

In the Atarisyseq.h file player colours are:-

#define  PCOLR0     0X2C0
#define  PCOLR1     0X2C1
#define  PCOLR2     0X2C2
#define  PCOLR3     0X2C3

 

Page 64, it also tells you the missile colours associated with each player.

 

Also I don't think Atarisyseq.h is a definitive list, but does give most of the popular locations.

Personally I created my own header file which include many more.

 

Page 44 describes how to change the player resolution (location 559 (0x22F) SDMCTL) bit 4 controls the resolution.

 

One thing I've noticed in your code, all variables are "int" where as a lot of them could be "char", this will speed up your

code by using them.

 

 

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

3 hours ago, TGB1718 said:

Are you using "Mapping the Atari" ?

It describes all the memory locations and their names.

 

In the Atarisyseq.h file player colours are:-

#define  PCOLR0     0X2C0
#define  PCOLR1     0X2C1
#define  PCOLR2     0X2C2
#define  PCOLR3     0X2C3

 

Page 64, it also tells you the missile colours associated with each player.

 

Also I don't think Atarisyseq.h is a definitive list, but does give most of the popular locations.

Personally I created my own header file which include many more.

 

Page 44 describes how to change the player resolution (location 559 (0x22F) SDMCTL) bit 4 controls the resolution.

 

One thing I've noticed in your code, all variables are "int" where as a lot of them could be "char", this will speed up your

code by using them.

 

 

Thanks for the help!

 

Link to comment
Share on other sites

OK, fully working now (with a few bugs and minus sound), but my missiles are canceling each other out when they cross each other mid-air. F2 will restart game.

 

I AM using the "Mapping the Atari" book (sorry for not answering that earlier)  but I can't seem to do some things other than with a PEEK or POKE, please let me know if any of my code that uses them could be done with system defines, and if so, how? as I just can't seem to figure it out. Or is it OK to use some PEEKS and POKES with cc65?

 

Where is the  Atarisyseq.h  located? I can't find it in my folders

 

Thanks,

 

Brian

 

 

 

 

 

 

 invader.zip

  • Like 1
Link to comment
Share on other sites

42 minutes ago, bkumanchik said:

Where is the  Atarisyseq.h  located? I can't find it in my folders

Wherever you installed cc65 there's an include folder, that's where it is.

 

There is another way to access system variables, atari.h has a structure defined "OS"

within that are the memory locations that you can access for example from some code in one of my programs.

 

        OS.color2 = 57;
        OS.color1 = 2;
        OS.color4 = 200;
        OS.shflok = 64;

 

and a simple delay function using the clock variables.


void delay(int dly)
{
    OS.rtclok[2] = 0;
    while(OS.rtclok[2] < dly);
}

 

Uses the same names as in atarisyseq.h but lowercase and preceded by OS.

Hope this helps.

 

Link to comment
Share on other sites

I've downloaded it from here:  https://cc65.github.io/  by clicking the  Windows Snapshot  link at the bottom, and I can't find the  Atarisyseq.h  anywhere in there, where did you get your copy of cc65? (sanity check)

 

Anyhow, I do have the  atari.h  I see if I can figure out how to make use of it, Thanks so much for all you're help. Any idea why my Missile's sort of cancel each other out? I know that I couldn't draw them next to each other even static on the screen.

 

Brian

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