* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: HP FOR loops slowing things down?  (Read 4596 times)

0 Members and 1 Guest are viewing this topic.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
HP FOR loops slowing things down?
« on: December 25, 2014, 06:46:04 am »
Ok, so after some tests, it seems like on the HP Prime, if you decide to make a game utilizing tilemaps, then if you want a fast speed but need to update the entire screen every frame for whatever reason (eg a parallax background), you will need to pre-render the entire level map into a massive GROB, then only draw the 320x240 chunk you need on top of the background. That's unless, of course, you don't need to redraw the entire map every frame (in which case it should be much faster).

Otherwise, from this code, which fills the screen with one tile every frame:

Code: [Select]
WHILE 1 DO


BLIT_P(G9,0,0,320,240,G3,0,0,320,240);
FOR mapTileX FROM 0 TO 320 STEP 16 DO
FOR mapTileY FROM 0 TO 240 STEP 16 DO
BLIT_P(G9,mapTileX-A, mapTileY, mapTileX+16-A, mapTileY+16, G1,112,0,128,16,#666666);
END;
END;
A := A+1;
IF A>16 THEN
A := 0;
END;

BLIT_P(G0,0,0,320,240,G9,0,0,160,120);
END;

This is how fast things will get:




The massive GROB pre-rendering method might cause some issues if you run into that one nasty HP Prime bug that causes some large GROB to not work properly, though, so I'll have to experiment. That said, it would be a more ideal situation since I wouldn't need to render the level every frame.


Another thing that could be done is checking if without a FOR loop it's faster (eg by using one BLIT command for each tile (336 of them). If it is, then it means this calc has the same problem as the 83+ had with TI-BASIC, where inverting the entire screen using 5985 Pxl-Change() commands instead of For(A,0,95:For(B,0,63:Pxl-Change(A,B:End:End was over twice faster.

For simple games this might not be a serious issue, though, but for more complex games that requires complex and pixel-accurate physics that could cause issues.

You could always use frame-skipping, though.

Anyway I am slowly implementing map rendering into the game now.
« Last Edit: December 25, 2014, 06:56:37 am by DJ Omnimaga »


  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #1 on: December 25, 2014, 09:24:47 am »
(I didn't understood the pxl change problem for 83+)

You could try having smaller submaps globs to redraw when you need tjem and refresh when their geometry change. That and Quadtree could get quite along.
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #2 on: December 25, 2014, 01:37:04 pm »
Pxl-change inverts the pixel color on the 83+.

Also what do you mean by quadtree?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #3 on: December 25, 2014, 01:57:17 pm »
Qudtree is aethod to improve collision collision performances. When you have to check for each pair of objects to check if they collide, you can split the world in smaller area and track thearea they are inside. Thus you don't have to check all the objects, just the locally near.
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #4 on: December 25, 2014, 02:09:48 pm »
Oh ok, yeah I was planning to do something similar actually. Also if collision speed became an issue I could just render and check enemies that are in the screen and only render 3 max at once in the screen like in some SNES games.


EDIT: Also, while pixel-based map data is nice for map storage and editing, it seems like it could make collision and map display much more cumbersome. When pre-rendering the map data I might also copy it in a list so that it's easier to work with (and edit).
« Last Edit: December 25, 2014, 02:11:30 pm by DJ Omnimaga »
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2883
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #5 on: December 29, 2014, 08:53:07 pm »
maybe it's this slow because you are reading pics ? That sounds very likely.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #6 on: December 29, 2014, 11:05:53 pm »
I am unsure. It could be very possible, though, plus the fact that graphical buffers can be any size in width.

On the 83+ tho I once made a shoot-em-up in pure BASIC where I used 1 output command per ship (16 total IIRC). It was very large, but if I had used two For loops it would have been about three times slower. That's how bad TI-BASIC could be.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2883
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #7 on: December 30, 2014, 12:27:34 pm »
Lol yeah TI basic is slow as hell. Doesn't mean the prime has to be that slow tho.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #8 on: December 30, 2014, 12:54:05 pm »
Eyup, FOR are mostly slow because sometimes the parser needs to go backwards in the code. I don't know why it would be slow but there's my idea.
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #9 on: December 30, 2014, 06:53:54 pm »
Lol yeah TI basic is slow as hell. Doesn't mean the prime has to be that slow tho.
Well, it can at least be proportionally slower than not using For. As in, if for example it's 4 times slower in BASIC, maybe it will also be 4 times slower in HP PPL. It's just that HP PPL is so fast in the first place that even with such slowdown you can still make almost any type of 2D game.

You can also do frame skipping anyway. I tried with my program above to only draw every 4 frame and it was blazing fast.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2883
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #10 on: December 30, 2014, 07:40:03 pm »
Good to know. You still should try to store the map in a different way though. :)
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #11 on: December 31, 2014, 05:13:48 am »
I'M planning to store it all into one massive picture, along with a second copy in list format. Lists will make it much easier to display it and collision. However, displaying or storing the massive pic might be a problem due to an HP PPL glitch with large images (which happens after running many programs that use such stuff).

If the program runs fine that way before running anything else, then I had an idea in mind though: Have the game pixel-test one part of the screen to check if map is drawn properly, and if it isn't, then it would show a warning text telling you to press ON+SYMB to fix game. Kinda like that TI-84+ BASIC trick that checks if the extra Text() row glitch was triggered (I think it was Pxl-On(6,0:Text(1,1," ":If not(Pxl-Test(6,0:DispTable )
« Last Edit: December 31, 2014, 05:17:07 am by DJ Omnimaga »
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #12 on: December 31, 2014, 07:23:29 am »
Ok so I tried again using a pre-rendered level image and background. The background is 640x240 and the foreground 960x240. This is how fast it gets (although it's smoother on-calc, scrolling by 1 pixel at a time):



Fun fact: those images are about 30 KB total in size, using the ICON (PNG) format. In HP's proprietary format, they're over 1 MB :crazy:


EDIT: I had the FOR loop set to increment scrolling offset by 0.5 instead of 1. Re-uploaded new screenshot now, which is twice faster.
« Last Edit: December 31, 2014, 07:41:35 am by DJ Omnimaga »
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Streetwalrus

  • Professional slacker
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2883
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #13 on: January 03, 2015, 11:04:28 pm »
Cool !
Also, since each nibble takes two bytes it's kinda normal that the data is 4x bigger lol.
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18428
  • Post Rating Ratio: +93/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: HP FOR loops slowing things down?
« Reply #14 on: January 04, 2015, 05:28:31 am »
There is also the issue about HP PPL using unicode for the source, so one character is like 2 or 4 bytes. Basically, a 16x16 sprite in HP PPL format can take about 512 or 1024 bytes of space. In PNG it really depends of how complex the image is.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games