42bs Posted July 10, 2018 Share Posted July 10, 2018 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. Quote Link to comment Share on other sites More sharing options...
+karri Posted July 10, 2018 Author Share Posted July 10, 2018 I would also recommend to increase the frame rate to 75. Then you have to wait less for a chance to start drawing the frame. Quote Link to comment Share on other sites More sharing options...
rmzalbar Posted July 11, 2018 Share Posted July 11, 2018 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! Quote Link to comment Share on other sites More sharing options...
42bs Posted July 11, 2018 Share Posted July 11, 2018 replacing INTs with CHARs wherever possible In the end, it's an 8bit machine Quote Link to comment Share on other sites More sharing options...
sage Posted July 12, 2018 Share Posted July 12, 2018 (edited) at least the old cc did not really optimized that INT->CHAR ... just using two bytes everywhere But for some things you gain a lot by inline assmbler Edited July 12, 2018 by sage Quote Link to comment Share on other sites More sharing options...
rmzalbar Posted July 17, 2018 Share Posted July 17, 2018 (edited) 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 July 17, 2018 by rmzalbar Quote Link to comment Share on other sites More sharing options...
enthusi Posted July 18, 2018 Share Posted July 18, 2018 The zip doenst contain a Lynx binary which complicates matters Quote Link to comment Share on other sites More sharing options...
rmzalbar Posted July 18, 2018 Share Posted July 18, 2018 Here it is, now with the game.lnx binary included. cc65.zip Quote Link to comment Share on other sites More sharing options...
rmzalbar Posted July 18, 2018 Share Posted July 18, 2018 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. Quote Link to comment Share on other sites More sharing options...
LordKraken Posted July 19, 2018 Share Posted July 19, 2018 (edited) 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 July 19, 2018 by LordKraken 1 Quote Link to comment Share on other sites More sharing options...
42bs Posted July 19, 2018 Share Posted July 19, 2018 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 1 Quote Link to comment Share on other sites More sharing options...
42bs Posted July 19, 2018 Share Posted July 19, 2018 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. Quote Link to comment Share on other sites More sharing options...
LordKraken Posted July 19, 2018 Share Posted July 19, 2018 good 2 cents Quote Link to comment Share on other sites More sharing options...
rmzalbar Posted July 19, 2018 Share Posted July 19, 2018 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. Quote Link to comment Share on other sites More sharing options...
Turbo Laser Lynx Posted November 1, 2018 Share Posted November 1, 2018 I wonder if both versions of cc65 would work easily out of the box on this?https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux I got a little bit intrerrested in updating to win10, not that I don't like having a use for my Raspberry Pi. Quote Link to comment Share on other sites More sharing options...
42bs Posted November 1, 2018 Share Posted November 1, 2018 Why not simply compile it for Windows? Quote Link to comment Share on other sites More sharing options...
Turbo Laser Lynx Posted November 1, 2018 Share Posted November 1, 2018 (edited) 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 November 1, 2018 by Turbo Laser Lynx Quote Link to comment Share on other sites More sharing options...
42bs Posted November 1, 2018 Share Posted November 1, 2018 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. Quote Link to comment Share on other sites More sharing options...
Turbo Laser Lynx Posted November 1, 2018 Share Posted November 1, 2018 Ah, thanks for the hint, that sounds like a nice setup as well! Quote Link to comment Share on other sites More sharing options...
+karri Posted May 30, 2019 Author Share Posted May 30, 2019 The first post in this thread tells about how to install cc65. There is a similar thred for Android. Quote Link to comment Share on other sites More sharing options...
Cyprian Posted May 30, 2019 Share Posted May 30, 2019 Karri, I have compiled the latest source CC65 myself. Is it ok for Lynx or no? thx Quote Link to comment Share on other sites More sharing options...
+karri Posted May 30, 2019 Author Share Posted May 30, 2019 Of course it is ok to compile cc65 by yourself. I just wanted to surrect an old thread for people working on Windows. Quote Link to comment Share on other sites More sharing options...
Cyprian Posted May 30, 2019 Share Posted May 30, 2019 ok Quote Link to comment Share on other sites More sharing options...
Positron5 Posted February 26, 2020 Share Posted February 26, 2020 (edited) 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. ?? game.O Edited March 1, 2020 by Positron5 To clarify and remove typos 1 Quote Link to comment Share on other sites More sharing options...
Positron5 Posted January 7, 2021 Share Posted January 7, 2021 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 game.O (will run in handy) 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.