telengard Posted December 2, 2020 Share Posted December 2, 2020 (edited) Always been a fan of this game, remember typing it in as a kid so it is a pretty nostalgic thing for me to play. It's very unique and I also like that there is a construction set for it. https://web.archive.org/web/20191029090111/https://casten.io/rebound.html My one frustration with the game is the joystick handling. Both in emulators and on the real thing, it doesn't handle great as far as playability. The timing seems a bit off for some reason, or almost too precise input is necessary. Not sure if that is just due to it being a BASIC program, or something with the logic, or my stinky playing lol. What seems to happen, when I have Flip lined up to go left or right and move the joystick in that direction, a good percentage of the time it doesn't detect the joystick move and Flip continues to go up and down in the same column. I noticed in the BASIC listing that it does a PEEK(632) in a loop, would changing this to using STICK add any benefits? I've attached the BASIC listing for the game. Any other fans have thoughts on how well it controls? I'd like to try and improve this somehow, but I have limited BASIC skills. The most I've done with BASIC is speeding up a text output routine in Stocks and Bonds, this might be more complicated or require more intrusive changes. rebound_listing.txt Edited December 2, 2020 by telengard 1 Quote Link to comment Share on other sites More sharing options...
baktra Posted December 3, 2020 Share Posted December 3, 2020 10 hours ago, telengard said: Always been a fan of this game, remember typing it in as a kid so it is a pretty nostalgic thing for me to play. It's very unique and I also like that there is a construction set for it. https://web.archive.org/web/20191029090111/https://casten.io/rebound.html My one frustration with the game is the joystick handling. Both in emulators and on the real thing, it doesn't handle great as far as playability. The timing seems a bit off for some reason, or almost too precise input is necessary. Not sure if that is just due to it being a BASIC program, or something with the logic, or my stinky playing lol. What seems to happen, when I have Flip lined up to go left or right and move the joystick in that direction, a good percentage of the time it doesn't detect the joystick move and Flip continues to go up and down in the same column. I noticed in the BASIC listing that it does a PEEK(632) in a loop, would changing this to using STICK add any benefits? I've attached the BASIC listing for the game. Any other fans have thoughts on how well it controls? I'd like to try and improve this somehow, but I have limited BASIC skills. The most I've done with BASIC is speeding up a text output routine in Stocks and Bonds, this might be more complicated or require more intrusive changes. rebound_listing.txt 14.12 kB · 10 downloads Changing to STICK would make it slightly slower. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted December 3, 2020 Share Posted December 3, 2020 The poor joystick is as you suspect because its in BASIC, if you could Speed the loop(s) up, it may help. I noticed a strange way to loop @ line "100 FOR Z=0 TO 1 STEP 0" this is an endless loop BASIC has to evaluate the variables and STEP for each pass. It's slightly quicker if you remove the FOR Z=0 TO 1 STEP 0 at line 100, leave the rest of the line and change 199 NEXT J:NEXT Z with NEXT J : GOTO 100 There maybe other things to help speed it up, will try have a look later Quote Link to comment Share on other sites More sharing options...
777ismyname Posted December 3, 2020 Share Posted December 3, 2020 Probably the easiest way of speeding it up on your real machine , without touching the code, would be to use Turbo BASIC XL to load it. Doing that certainly makes another one of his games (my favorite by him), Risky Rescue, much quicker and much more challenging. Quote Link to comment Share on other sites More sharing options...
Rybags Posted December 3, 2020 Share Posted December 3, 2020 If a game only uses left/right, then you can often save a bunch of time using the PTRIG( function. That gives the 0/1 values and you can invert them by using e.g. A=NOT PTRIG(0) 1 Quote Link to comment Share on other sites More sharing options...
zzip Posted December 3, 2020 Share Posted December 3, 2020 JD Casten made some cool games, but they were all kind of held back due to being written in BASIC. As someone else mentioned, running them under Turbo Basic XL should give them improved performance. There's also a Turbo Basic compiler for even more speed, but there's a risk of making it too fast and unplayable. Quote Link to comment Share on other sites More sharing options...
telengard Posted December 3, 2020 Author Share Posted December 3, 2020 Thanks everyone for your thoughts. And I will have to check out Risky Rescue. It sounds like the recommended changes would also speed up gameplay in addition to improving the joystick performance? The speed of the game is perfect, it's just the polling rate of the joystick that needs to be sped up and still work w/ the current game loop. How do games normally do this (whether BASIC or asm)? I wonder if caching the joystick value every N loops would help? So, if there was input in those N loops it would be utilized. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted December 3, 2020 Share Posted December 3, 2020 In assembler you can get accurate reads by detecting the Joystick in the Vertical Blank routine so it's read every 1/50th or 1/60th of a second. If you want the read to be NOT be so often, you can set a timer to read the joystick at the desired interval. In BASIC it's not so precise, so more down to the way it's coded. Quote Link to comment Share on other sites More sharing options...
telengard Posted December 3, 2020 Author Share Posted December 3, 2020 32 minutes ago, TGB1718 said: In assembler you can get accurate reads by detecting the Joystick in the Vertical Blank routine so it's read every 1/50th or 1/60th of a second. If you want the read to be NOT be so often, you can set a timer to read the joystick at the desired interval. In BASIC it's not so precise, so more down to the way it's coded. I'm a C/C++ programmer and do inline assembly on occasion. Can you do this in BASIC? i.e. write some 6502 that does what you described and sets a variable that can be referenced in the BASIC? I wonder what could be changed in that loop to get it to respond better without changing game speed. Multiple checks *in* the loop for the state of the joystick OR'ed together? 1 Quote Link to comment Share on other sites More sharing options...
zzip Posted December 3, 2020 Share Posted December 3, 2020 25 minutes ago, telengard said: I'm a C/C++ programmer and do inline assembly on occasion. Can you do this in BASIC? i.e. write some 6502 that does what you described and sets a variable that can be referenced in the BASIC? I wonder what could be changed in that loop to get it to respond better without changing game speed. Multiple checks *in* the loop for the state of the joystick OR'ed together? yes you can call machine code from BASIC (not in-line assembly, it has to be already assembled), but the game is probably going to poll the new variable you set up as often as it does the joystick, so not sure it will help much. It's also possible to set up VBIs or DLIs from BASIC as well, and that could be used to poll 50/60 times per second and maybe move the sprite accordingly, but you may end up having to recode much of the game logic in ASM. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted December 3, 2020 Share Posted December 3, 2020 1 hour ago, telengard said: I wonder what could be changed in that loop to get it to respond better without changing game speed. Multiple checks *in* the loop for the state of the joystick OR'ed together? You could maybe code it to run faster, then set a flag in a VBI routine and have the BASIC code wait at a certain point until it see's the value it wants from the flag, that's about the only way you could probably synchronize a BASIC program, however as BASIC is so slow it's still unlikely to improve things much, saying that if you've ever compiled a BASIC program, you can see things become very different and although not running at the same speed as pure assembler you tend to find you have to slow some things down. Quote Link to comment Share on other sites More sharing options...
telengard Posted December 4, 2020 Author Share Posted December 4, 2020 (edited) I spent some time last night on this and figured out how the joystick code works. The peek'ed value is used as an index into a read in array that has -1, 0, and 1 values at the appropriate indices. I changed the PEEK(632) to utilizing PTRIG and it handles MUCH better except for when Flip is bouncing up and down in height of 2 or 3, this is where the diagonals are helpful as those also move Flip (upper/lower left -1 upper/lower right +1). Attached is a screengrab of a spot where I've been unable to to go the left with the PTRIG code. So, it felt more responsive, but made some parts of the board very hard to maneuver. Edited December 4, 2020 by telengard Quote Link to comment Share on other sites More sharing options...
777ismyname Posted November 15, 2023 Share Posted November 15, 2023 @telengard, did you work on speeding up aspects of Risky Rescue, by chance? I’ve given a good bit of thought about it for a while, almost exclusively because of the latency involved with joystick stuff and stock Atari BASIC. Quote Link to comment Share on other sites More sharing options...
telengard Posted November 15, 2023 Author Share Posted November 15, 2023 13 hours ago, 777ismyname said: @telengard, did you work on speeding up aspects of Risky Rescue, by chance? I’ve given a good bit of thought about it for a while, almost exclusively because of the latency involved with joystick stuff and stock Atari BASIC. Hey @777ismyname, I'm not familiar with that title. It may have the same joystick code if by JD. I started porting Rebound to FastBASIC, and am about 3/4 done, just been a little busy. Quote Link to comment Share on other sites More sharing options...
777ismyname Posted November 18, 2023 Share Posted November 18, 2023 Oops, I’m sorry @telengard, I got my threads mixed up. I had been talking to someone via DM that was thinking of messing about with Risky Rescue. I reckon I will work on it some next week Fwiw, Risky Rescue is a type in program from Antic magazine, from 1984. It was written in Atari BASIC, with a ML routine or two. I always liked the game, but the latency from joystick movement/trigger press makes it a bit tricky. Using TBXL or similar speeds the game up dramatically, making it even more difficult. My apologies Quote Link to comment Share on other sites More sharing options...
Houdini Posted November 18, 2023 Share Posted November 18, 2023 (edited) I typed this one in back in the day too. One of my favorites. Edit: Posted compiled version 1st time. That won't help very much. Lol. Fixed. Risky Rescue(req Basic).atr Edited November 18, 2023 by Houdini 1 Quote Link to comment Share on other sites More sharing options...
telengard Posted November 18, 2023 Author Share Posted November 18, 2023 hey, no problem at all, sounds like a cool game I'm going to try it out. And yeah, Rebound is very similar; mostly BASIC with a few ML routines. I tried Turbo XL and it didn't seem to help out with the joystick (but I also had to put in a delay to keep the speed of the game down). I'm hoping I'll have more control porting to FastBASIC. 1 Quote Link to comment Share on other sites More sharing options...
777ismyname Posted November 19, 2023 Share Posted November 19, 2023 (edited) I was aware of being able to use PTRIG, but was not aware of how much faster it is! I just ran a quick test in Turbo BASIC XL (not compiled), scanning STICK(0), PEEK(632), PTRIG(0) each for ten seconds and counting how many iterations were made in a WHILE/WEND loop. PTRIG won by a mile. I'm definitely using it, where possible! EDIT: For kicks and giggles, I ran it through the TBXL compiler. STICK(0)=6744, PEEK(632)=6852, PTRIG(8132)=8132. Now I've got to try this in Fast Basic Edited November 19, 2023 by 777ismyname Quote Link to comment Share on other sites More sharing options...
telengard Posted November 19, 2023 Author Share Posted November 19, 2023 (edited) 16 hours ago, 777ismyname said: I was aware of being able to use PTRIG, but was not aware of how much faster it is! I just ran a quick test in Turbo BASIC XL (not compiled), scanning STICK(0), PEEK(632), PTRIG(0) each for ten seconds and counting how many iterations were made in a WHILE/WEND loop. PTRIG won by a mile. I'm definitely using it, where possible! EDIT: For kicks and giggles, I ran it through the TBXL compiler. STICK(0)=6744, PEEK(632)=6852, PTRIG(8132)=8132. Now I've got to try this in Fast Basic I had tried using that, but since it is only left and right, diagonals didn't work so I'd get stuck on a board trying to get out of a corner. I had done the STICK() too instead of the peek and it didn't seem to make much difference. Edited November 19, 2023 by telengard 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.