Jump to content
IGNORED

Tricky XB Commands .. need a timer.


Retrospect

Recommended Posts

Does any of you Brainiacs out there know of a decent way to get an accurate timer for a compiled XB game?  I'm wanting a count-down, doesn't have to be in seconds precisely but it would be nice if it was consistent to some degree.   I've tried a CALL LOAD that accesses a timer on the VDP but this has proven to be undesirable and that is the politest word I can think of.

I could use my old trick of invisible sprite in automotion and detect it's position but that's only for if I can't get another way.  

 

Anyone?    :)    

  • Like 1
Link to comment
Share on other sites

At -31879 is the VDP interrupt timer. The value increments 60 times a second (50 times a second in Europe). If you are not using INPUT or ACCEPT AT, I think this would work for you. (Those instructions use this as a cursor timer and each flash of the cursor resets it to zero)

10 CALL PEEK(-31879,X):: PRINT X;:: GOTO 10

You could CALL LOAD(-31879,0) to start the timer, then you would have to CALL PEEK(-31879,X) to see what is happening at the timer.

With this, you should be able to come up with something to keep track of the time.

 

This runs just a little slow in XB, but would probably be pretty close when compiled: (Of course, that slowness could be my computer, which struggles to keep up when running Classic99)

 

10 CALL PEEK(-31879,X):: IF X>60 THEN X=X-60 :: CALL LOAD(-31879,X):: SECONDS=SECONDS+1 :: PRINT SECONDS
20 GOTO 10

 

In BASIC you could change it to something like X=X-56 to keep better time.

 

Edited by senior_falcon
  • Like 2
Link to comment
Share on other sites

Thanks @senior_falcon.   @Vorticon, I've no idea what Bit the value is.  I'm delving into the unknown to try and get a timer .  I have an idea for my upcoming game which will have you in a field full of cows , blasting aliens that are trying to eat the cows , and they just keep coming and coming relentlessly ... I wanted a timer to count down from like 30 seconds ... if you survive the 30 seconds you get to round 2, or level 2 , whatever.  And then it could increment to 35 or 40 seconds to blast them.  

@TheBF That's true, it'll be quiet, but it'll also stop execution.  I should have explained better in the1st post, it's for a count-down literally displayed on the screen whilst your "schooner" is blasting oncoming aliens.  ;) 

  • Like 3
Link to comment
Share on other sites

6 hours ago, Retrospect said:

I could use my old trick of invisible sprite in automotion and detect it's position but that's only for if I can't get another way.

Brilliant idea ! 🏆
Put it outside the screen.
From the manual: Dot-row can be from 1 to 192 and dot-column can be from 1 to 256. Actually dot-row can go up to 256, but the positions from 193 through 256 are off the bottom of the screen.
 

Edited by sometimes99er
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

1 minute ago, sometimes99er said:

Brilliant idea ! 🏆
Put it outside the screen.
From the manual: Dot-row can be from 1 to 192 and dot-column can be from 1 to 256. Actually dot-row can go up to 256, but the positions from 193 through 256 are off the bottom of the screen.
 

Thanks.  Yes, if call loading the vdp proves not satisfactory i'll just put a sprite at the bottom of the screen with Color 1 , going across in automotion say value 10.  The time doesn't strictly have to be a literal second, just a unit of time is all.  ;)

  • Like 1
Link to comment
Share on other sites

You could actually make a bar at the bottom with the sprite as a pointer to indicate time taken ! 🥇

2 hours ago, Retrospect said:

Thanks.  Yes, if call loading the vdp proves not satisfactory i'll just put a sprite at the bottom of the screen with Color 1 , going across in automotion say value 10.  The time doesn't strictly have to be a literal second, just a unit of time is all.  ;)

Better make the automation 1, 2, 4, 8 or 16 etc. (geometric sequence). Then I think you get a perfect timer. The internal automotion (addition) works "smoothly" with these numbers.
 

Edited by sometimes99er
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

10 hours ago, Retrospect said:

I could use my old trick of invisible sprite in automotion and detect it's position but that's only for if I can't get another way.  

It is the trick I also use for my game in progress, I find it very very efficient.

The sprite is moving at 240th line, hidden 🙂

 

 

  • Like 2
Link to comment
Share on other sites

12 hours ago, Retrospect said:

Does any of you Brainiacs out there know of a decent way to get an accurate timer for a compiled XB game?  I'm wanting a count-down, doesn't have to be in seconds precisely but it would be nice if it was consistent to some degree.   I've tried a CALL LOAD that accesses a timer on the VDP but this has proven to be undesirable and that is the politest word I can think of.

 

0I could use my old trick of invisible sprite in automotion and detect it's position but that's only for if I can't get another way.  

 

Anyone?    :)    

 

You could set up your own counter that would get serviced by the console ISR exactly in step with the VDP timer, with the exception that it will do whatever you want it to do without any resetting that you do not initiate. As an example of what can be done, the following short routine loads in low RAM and sets up a word (2 bytes) in low RAM that gets ticked at every interrupt (1/60 second) and will go for 18 minutes 12+ seconds before rolling over. For @senior_falcon’s XB compiler, you may need to move its location:

 

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
*++ Program:  MYTIMR                                      ++* 
*++                                                       ++* 
*++ Called by Console ISR through the ISR hook at >83C4.  ++*
*++                                                       ++* 
*++ Increments timer word each 1/60 second and returns    ++*
*++ to caller of console ISR. Range is 0..18+ minutes.    ++*
*++                                                       ++* 
*++ AORG to whatever location works best. Change all      ++*
*++ entries below that reference this location.           ++*
*++                                                       ++* 
*++ Operations---                                         ++*
*++   - Initialize the timer to any integer any time with ++*
*++       CALL LOAD(8448,0,0)   ! clears MYTIME at >2100  ++*
*++                                                       ++* 
*++   - Enable ISR handling of MYTIMR (>2102) with        ++*
*++       CALL LOAD(-31804,33,2)  ! >2102 to >83C4        ++*
*++                                                       ++* 
*++   - Put current value of timer in variable TICKS with ++*
*++       CALL PEEK(8448,TICKS,LSB)  ! MSB,LSB from >2100 ++*
*++       TICKS = TICKS*256 + LSB    ! compose word value ++*
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*

       AORG >2100       ; change this location as needed

MYTIME DATA 0           ; initialize timer to 0
MYTIMR INC  @MYTIME     ; increment timer
*
* The following 2 instructions are copies of the remainder of the console ROM's
* ISR (except that 'CLR R8' was removed because it is only needed by TI Basic)
* because we're not going back there!
*
       LWPI >83C0       ; change to console's ISR workspace
       RTWP             ; return to caller of console ISR
       END

 

...lee

  • Like 4
Link to comment
Share on other sites

6 minutes ago, Retrospect said:

@OLD CS1 how do ya find this stuff so quickly lol

I have a ridiculous library of movies and TV shows on-hand (over 5,000 hours of each,) and an almost encyclopedic knowledge of everything I own.  A long life including wasted adolescence and lonely adulthood.

 

Did you ever see the TV show "Dream On"?  Kind-of how my mind works.

  • Like 1
Link to comment
Share on other sites

16 minutes ago, Retrospect said:

I haven't, but my curiosity means I might take a look , ha

It is an old HBO (Home Box Office) show, back when HBO was still cable- and satellite-only and started into producing serials (some damn good shows, too.)  The protagonist spent his childhood in front of the tube watching all kinds of shows in good ol' black-and-white, and he relates events happening throughout his day with cutaways to clips of shows ostensibly from his youth.

  • Like 1
Link to comment
Share on other sites

Larger warp sprites ... aliens do arrive now, around the edges of the screen so that they're not gonna be all clumped together when they move ... they're not moving YET though as I've still that code to do ... but here's a vid to show the improvements and me having rootin-tootin good ol' time shootin' dem cows.   

 

 

 

  • Like 4
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...