bkumanchik Posted November 13, 2023 Share Posted November 13, 2023 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 1 Quote Link to comment Share on other sites More sharing options...
Peri Noid Posted November 13, 2023 Share Posted November 13, 2023 I think you should clear memory of all the sprites or move all but yours away from the screen. 1 Quote Link to comment Share on other sites More sharing options...
Irgendwer Posted November 13, 2023 Share Posted November 13, 2023 (edited) Not having the time to analyze your code (yet), but maybe this working example helps: Edited November 13, 2023 by Irgendwer 2 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 14, 2023 Author Share Posted November 14, 2023 Thanks for the help, I'll give this a try ASAP Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 14, 2023 Share Posted November 14, 2023 (edited) @bkumanchik all it needs is the following change, you can add the _graphics(0); too if you want, still works. newtop = PEEK(106) - 12; // or newtop = PEEK(106) - 16; // Edited November 14, 2023 by TGB1718 2 Quote Link to comment Share on other sites More sharing options...
baktra Posted November 14, 2023 Share Posted November 14, 2023 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. 3 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 14, 2023 Author Share Posted November 14, 2023 16 hours ago, Peri Noid said: I think you should clear memory of all the sprites or move all but yours away from the screen. Thanks! Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 14, 2023 Author Share Posted November 14, 2023 It's working now, now I just have to make the adjustments that baktra mentioned. 1 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 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 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 18, 2023 Share Posted November 18, 2023 (edited) @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 November 18, 2023 by TGB1718 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 Thanks for the feedback, I'll upload my version where I started converting it over to use the system defines and I was having other problems instead. FYI I haven't setup the collision for the invader yet, I mentioned that in my post. Brian Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 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? Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 18, 2023 Share Posted November 18, 2023 I'm using Sublime Text 3 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 11 minutes ago, TGB1718 said: I'm using Sublime Text 3 11 minutes ago, TGB1718 said: I'm using Sublime Text 3 I'm just using Notepad++ and a windows command line: [cl65 -t atari invader.c -o invader] 1 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 here's the new version where I started using sinvader.zipystem defines, it does weird stuff, you can only fire once, the invader just disappears after a few lines of movement. 1 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 19 minutes ago, bkumanchik said: here's the new version where I started using sinvader.zipystem defines, it does weird stuff, you can only fire once, the invader just disappears after a few lines of movement. I figured out the disappearing invader thing, fixed it. 1 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 18, 2023 Author Share Posted November 18, 2023 Looking at the header files, I cant figure out how to set player or missile colors or single line resolution using the system defines Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 19, 2023 Share Posted November 19, 2023 (edited) 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 November 19, 2023 by TGB1718 1 Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 19, 2023 Author Share Posted November 19, 2023 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! Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 19, 2023 Author Share Posted November 19, 2023 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 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 19, 2023 Share Posted November 19, 2023 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. Quote Link to comment Share on other sites More sharing options...
bkumanchik Posted November 20, 2023 Author Share Posted November 20, 2023 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 Quote Link to comment Share on other sites More sharing options...
sanny Posted November 20, 2023 Share Posted November 20, 2023 There is no atarisyseq.h in the cc65 distribution. The file to use is atari.h. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 20, 2023 Share Posted November 20, 2023 1 hour ago, sanny said: There is no atarisyseq.h in the cc65 distribution. My bad, I think I may have created this header file from my old MAC/65 installation. Here it is if it's any use to you. atarisyseq.h 1 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted November 20, 2023 Share Posted November 20, 2023 There is a similar file as part of the cc65 distro. It should be just atari.h. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.