Jump to content
IGNORED

Rebound by JD Casten joystick handling


telengard

Recommended Posts

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 by telengard
  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

Screenshot_1.png

Edited by telengard
Link to comment
Share on other sites

  • 2 years later...
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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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 :)

 

STICK_READ_TEST_11182023.thumb.png.857fad23003c0f2aae56f6fd6ba234c5.png

Edited by 777ismyname
Link to comment
Share on other sites

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 :)

 

STICK_READ_TEST_11182023.thumb.png.857fad23003c0f2aae56f6fd6ba234c5.png

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