Menu

arrays vs tables

2022-03-08
2022-03-09
  • stan cartwright

    stan cartwright - 2022-03-08

    I tried reading tables against reading an array and doesn't seem much difference.. except for ram.
    I tried this where it reads the table which turned out to be word vals and it takes 512B for 16x16 sprite.
    I don't see a speed difference so will use tables.
    This set up once.

        dim spritedata(256) as word ;trying sprite data in array instead of a table
        for ptr=1 to 256
             readtable sprite1,ptr,spritedata(ptr) ;copy table to array
        next
    

    you can test table or array with comment on/off

        sub sprite ( in sprite_x, in sprite_y ) ;fills box with sprite data
          SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 )
          ptr=1
          repeat 256
    ;        pixel=spritedata(ptr) ;reads array
            ReadTable sprite1,ptr,pixel ;reads table
            SendWord_ILI9341 pixel
            ptr++
          end repeat
    

    using gcstudio.

     
  • Anobium

    Anobium - 2022-03-09

    Interesting results. How accurate was your timing?

     
    • stan cartwright

      stan cartwright - 2022-03-09

      It was just a visual comparison. The difference in animation speed wasn't noticeable so I won't pursue the idea.
      You'd think you'd notice the difference... 512 bytes read 8 times every loop but I didn't notice a visible animation speed increase.
      Maybe it's using a mega328p. Maybe certain pics reading ram would be much faster than reading program memory. I dunno.
      Interesting experiment though.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.