Jump to content



0

How can I speed up an XB program?


33 replies to this topic

#26 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Wed Nov 16, 2011 5:25 PM

View Postjacquesg, on Wed Nov 16, 2011 2:30 PM, said:

The time measurements must be in fractions of seconds. Does anyone know what they are? Also, I am having trouble understanding 'per RPT #' used in three spots. Can someone clarify what is intended?

Looks like milliseconds. This image is from the original page:
Attached File  MG-SmartProgrammer8409_Excerpt.jpg   249.44K   29 downloads

...lee

#27 Willsy ONLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Wed Nov 16, 2011 6:28 PM

Wow! Look how fast it is to call a user defined SUB. SEE! I've *always* said people should be using SUBs all the time in XB.

Hrmph... Nobody ever listens to me! <sulk> ;)

#28 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Wed Nov 16, 2011 6:35 PM

Wilsy you are correct, we need to give Barry Traver credit for Tiger Cub being entirely written in CALL [program] format.

In the GPL code it uses all temporary variables and forces a garbage collection (XML COMPCT) and XML SPEED
(makes XML faster by cutting down on support routines use in ROM)

Very well played Wilsy. Maybe I should look at RXB and borrow some of the tricks to speed up other things in XB.

#29 sometimes99er OFFLINE  

sometimes99er

    Stargunner

  • 1,922 posts
  • Location:Denmark

Posted Thu Nov 17, 2011 12:24 AM

CALL sub - 7
GOSUB    - 1

Yes, I've seen the light.

Edited by sometimes99er, Thu Nov 17, 2011 12:25 AM.


#30 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Nov 17, 2011 2:11 AM

GOSUB and RETURN are faster but use normal memory to access Variables and as such do not use XML COMPCT or XML SPEED that often.

But GOSUB and RETURN are in the NUD table so you are correct that they are faster as they use Assembly ROM for access.

So you are right and I was mistaken.

#31 sometimes99er OFFLINE  

sometimes99er

    Stargunner

  • 1,922 posts
  • Location:Denmark

Posted Thu Nov 17, 2011 3:04 AM

I would have expected CALL "SUB" to be slower than GOSUB, and the timing table indicated just that.

There's the option to use local and/or global variables, but I'd still expect GOSUB to be faster. For this topic (speed) it's GOSUB over CALL SUB. Though the timing table list CALL SUB as one of the faster statements.

For speed one might also consider the power of ON GOSUB.

#32 Willsy ONLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Nov 17, 2011 5:01 AM

Yep. For speed in XB its GOTO and GOSUB. That is definately true.

I can say though (having written programs using spaghetti GOTOs GOSUBs and SUBs that writing with SUBs is so much nicer. Passing locals into the SUBs is a nice high-level system.

But yeah, for speed I can see that you'd want to use GOTO & GOSUB (or, not use XB at all and use something else, like assembler ;)

#33 sometimes99er OFFLINE  

sometimes99er

    Stargunner

  • 1,922 posts
  • Location:Denmark

Posted Thu Nov 17, 2011 8:17 AM

View PostWillsy, on Thu Nov 17, 2011 5:01 AM, said:

or, not use XB at all and use something else, like assembler

Besides compiling an XB program (which I haven't tried), then I don't think it's been directly suggested here, or maybe considered outside topic, but you can of course "speed up an XB program" using an Assembly routine(s). And there's already quite a few routines out there, for example Matthew's music player or some of my own one shot and hook up effect routines. Like this one (sorry, animation is not as smooth as on the real iron) ...

Posted Image

Also not forgetting your own The Gamewriter's Toolkit.

One could write a hook up that monitors the hardware collision detection, and when sprung, freezes action (sets number of sprites for auto movement to zero) and stores information in a byte for XB to read at any time. XB might be a bit late to pickup and react upon the collision, but the collision isn't missed.

Lots of possibilities.

#34 RXB OFFLINE  

RXB

    Dragonstomper

  • 539 posts
  • Location:Vancouver, Washington, USA

Posted Thu Nov 17, 2011 2:42 PM

XB has a added bonus of being able to create outlines for more complicated languages like Assembly.

Most programs you see had the first concept in XB for a good reason.
Also XB is much more easy to transfer over into another language then say C into XB or C into Logo or Forth.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users