This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Technology & Calculator Open Topic subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

Calculator Tech Support => Technology & Calculator Open Topic
 » Goto page Previous  1, 2, 3, 4  Next
Author Message
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 23 Jan 2004 05:13:19 pm    Post subject: I think I was misunderstood; I was talking about typing in 64 bits when programming in Asm. In Basic that's kind of a waste of memory since each will take a byte.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 24 Jan 2004 05:32:18 am    Post subject: Jedd wrote:The fastest way to do sprites in pure BASIC is in a seperate program. Wrong, it's faster if you do it in the main program itself. You're right about hard-coded sprites being faster though. Quote:What would the prgm look like to make a made up 8*8 sprite move accross the screen?Do note this is very slow and you should use hard-coded sprites or assembly subroutines. You should also have a look at the topics about sprites in the TiBasic forum. ClrDraw AxesOff FnOff PlotsOff GridOff "0000000000000000000000000000000000000000000000000000000000000000->Str0 47->A 31->B Repeat K=45 getKey->K A+(Ans=26)-(Ans=24->A B+(K=25)-(K=34->B For(C,1,8 For(D,1,8 If "1"=sub(str0,8(D-1)+C,1 Pxl-On(B+D,A+C End End EndLast edited by Guest on 24 Jan 2004 05:32:55 am; edited 1 time in total
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 24 Jan 2004 12:19:38 pm    Post subject: I don't think the 64-zero-string was a good idea. A list, though taking up more memory, would be faster to work with. The best way is to code both the sprite and its movement on an individual approach basis, using Line(, Pt-On(, etc.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 24 Jan 2004 12:34:41 pm    Post subject: I think you could make it quite effective if you use instring() instead of 2 for loops to get through the sprite data, but then again maybe not.
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 24 Jan 2004 12:46:23 pm    Post subject: Code: ```For(I,0,7 For(J,0,7 If L1(1+I+8J Pt-Chg(A+I,B+J End End``` is much faster and smaller than anything with strings
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 24 Jan 2004 12:50:57 pm    Post subject: If it would skip over the empty parts of the sprite, yes. But it doesn't, however, you can use instring to do just that. On the other hand, you don't have that much empty parts in an 8*8 sprite.Last edited by Guest on 24 Jan 2004 12:51:51 pm; edited 1 time in total
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 24 Jan 2004 01:00:18 pm    Post subject: You might also want to do different things, such as: If the number is 1, switch the pixel on. If it is 0, leave it alone. If it is -1, switch the pixel state. If it is 2, switch the pixel off. I doubt the gain in time by using instring( would compensate for the loss in getting the character out of the string and comparing it to 1. Also, I'd use Pt-On instead on Pxl-On, so an error doesn't happen when a sprite goes off the screen. On the other hand, Code: ```For(I,0,7 For(J,0,7 If L1(1+I+8J Pxl-Chg(A+I,B+J If B+J>94 7->J End If A+I>62 7 -> I End``` might be fast enough.Last edited by Guest on 24 Jan 2004 01:00:30 pm; edited 1 time in total
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 24 Jan 2004 01:05:54 pm    Post subject: Well, you're going to have to compare those values regardless of wether you're using a list or a string. Also, you shouldn't be drawing stuff outside the screen, that's just wasting cpu cycles.Last edited by Guest on 24 Jan 2004 01:08:00 pm; edited 1 time in total
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 25 Jan 2004 05:47:22 pm    Post subject: Arcane Wizard wrote:Also, you shouldn't be drawing stuff outside the screen, that's just wasting cpu cycles. If the sprite doesn't go off the screen often, you might waste more cycles checking for it all the time. The comparison in the Pt-On code, slow as it might be, is undoubtedly faster than an "If" comparison.
Jedd
1980 Pong World Champion

Elite

Joined: 18 Nov 2003
Posts: 823

 Posted: 25 Jan 2004 10:39:44 pm    Post subject: Quote:Wrong, it's faster if you do it in the main program itself. You're right about hard-coded sprites being faster though. That's what I though for a while too. But because the seperate program uses Return after each sprite, it doesn't run through the rest of the program and try a bunch of If statements that are going to fail anyway. There's no way to make it skip the rest of the sprites if the sprites are in the main program.
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 25 Jan 2004 11:13:20 pm    Post subject: I think he means put the Pxl-Ons in the program where you need to draw the sprite instead of going to another part and using Ifs.
Jedd
1980 Pong World Champion

Elite

Joined: 18 Nov 2003
Posts: 823

 Posted: 26 Jan 2004 02:34:26 am    Post subject: Oh gotcha. Yes, for the main character that is always moving, that would be a lot faster. That's how my games have worked, too. What I was talking about is best used for screen loading.
Arcane Wizard
`semi-hippie`

Super Elite (Last Title)

Joined: 02 Jun 2003
Posts: 8993

 Posted: 26 Jan 2004 07:03:51 am    Post subject: Sir Robin wrote: Arcane Wizard wrote: Also, you shouldn't be drawing stuff outside the screen, that's just wasting cpu cycles. If the sprite doesn't go off the screen often, you might waste more cycles checking for it all the time. The comparison in the Pt-On code, slow as it might be, is undoubtedly faster than an "If" comparison. You don't need if to keep from drawing outside the screen. It's always faster if you just do it in one program, the only difference with using several programs is that it also calls another program and then returns to the main program which takes additional cpu cycles and thus more time.
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 26 Jan 2004 02:23:00 pm    Post subject: Arcane Wizard wrote: Sir Robin wrote: Arcane Wizard wrote: Also, you shouldn't be drawing stuff outside the screen, that's just wasting cpu cycles. If the sprite doesn't go off the screen often, you might waste more cycles checking for it all the time. The comparison in the Pt-On code, slow as it might be, is undoubtedly faster than an "If" comparison. You don't need if to keep from drawing outside the screen. If it is a mouse like in DragonOS, you would need to clip a sprite to display it near the edge of the screen (just as an example, I know DragonOS is Asm). Quote:It's always faster if you just do it in one program, the only difference with using several programs is that it also calls another program and then returns to the main program which takes additional cpu cycles and thus more time. If you needed to recall the sprite in several different parts of the main program, you would need to write the sprite code each time, using up more space. Or you could use a goto in the main program which would take as many cpu cycles, possibly more.
Fixen

Member

Joined: 27 Jan 2004
Posts: 134

 Posted: 27 Jan 2004 09:21:24 am    Post subject: Fixen, new here. I've made this program for people with headaches in sprite-making. First, set window as following: XMax: 47 XMin: -47 YMax: 31 YMin: -31 Draw your sprite in the middle (Try having CoordOn, it will make it much easier.) Code: ```PROGRAM:SPRITER :1->U :For(Y,16,46 :For(Z,32,62 :If pxl-Text(Y,Z)=1 :Then :Y-31->V :Z-47->W :V->[List*](U) :W->[List*](U+1) :U+2->U :End :End :End``` *In the code, change [List] into the list you want to store your sprite into. Here's the drawing routine (Put V as the x coordinate for the sprite, and W as y coordinate): Code: ```PROGRAM:ZDRAW :For(U,1,dim(LTEMP),2 :Pxl-On(V+LTEMP(U), W+LTEMP(U+1) :End``` *In the code, before running this subroutine, store the sprite list into LTEMP How's that?
DarkerLine
ceci n'est pas une |

Super Elite (Last Title)

Joined: 04 Nov 2003
Posts: 8328

 Posted: 27 Jan 2004 01:38:57 pm    Post subject: Fixen wrote:Code: ```PROGRAM:SPRITER :1->U :For(Y,16,46 :For(Z,32,62 :If pxl-Text(Y,Z)=1 :Then :Y-31->V :Z-47->W :V->[List*](U) :W->[List*](U+1) :U+2->U :End :End :End``` *In the code, change [List] into the list you want to store your sprite into. Here's the drawing routine (Put V as the x coordinate for the sprite, and W as y coordinate): Code: ```PROGRAM:ZDRAW :For(U,1,dim(LTEMP),2 :Pxl-On(V+LTEMP(U), W+LTEMP(U+1) :End``` *In the code, before running this subroutine, store the sprite list into LTEMP How's that? Speed: very good. Will only loop through points in the sprite. Size: not so good. A 8x8 sprite might take up up to 1152 bytes. The six monster sprites I posted will take up approximately 5400 bytes altogether. That compared to the 192 bytes they'd take up in Asm.
Darth Android
DragonOS Dev Team

Bandwidth Hog

Joined: 31 May 2003
Posts: 2104

 Posted: 27 Jan 2004 02:02:59 pm    Post subject: some things i want to point out: lists: easire to use, though slower to access, take up more room than srings strings: opposite of above (faster, harder,smaller) pt-on: slower than pxl-on, have to set window pxl-on: faster than pt-on, dont have to set window this is factual info, based on the asm code that has to be done for each. i dont have the exact cc (clock cycles), but in general, use strings and pxl-on whenever possible
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 27 Jan 2004 06:16:26 pm    Post subject: I think the best way to do basic sprites would be to use a string and have each 2 numbers be coordinates of a dot. Like this: 10000001 00000000 00000000 00000000 00000000 00000000 00000000 10000001 Would be this: 00 07 70 77 (without spaces) But if there's more than 8 dots, it would be smaller to do the whole thing in hex codes.

Calc Guru

Joined: 06 Jan 2004
Posts: 1002

 Posted: 27 Jan 2004 06:18:47 pm    Post subject: Huh? I don't get it.
X1011
10100111001

Active Member

Joined: 14 Nov 2003
Posts: 657

 Posted: 27 Jan 2004 08:51:24 pm    Post subject: Instead of having a 1 for on and a 0 for off for each pixel, you have 2 numbers for each pixel you want to turn on. The first is the row, the second is the column.
 Display posts from previous: All Posts Oldest FirstNewest First
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
 » Goto page Previous  1, 2, 3, 4  Next Page 2 of 4 » All times are UTC - 5 Hours