Menu

pointer to table

Help
2017-09-13
2017-09-13
  • stan cartwright

    stan cartwright - 2017-09-13

    Is it possible to have several tables and change the pointer to any one?
    I tried data=data1 but get- can't find data error. There doesn't seem to be a way without if then or select case which would be too slow.
    It's been asked before. I'll try using strings instead. Is mid(stringvar) as fast as reading a table item?

    sub plot
    readtable data,ptr,pixel
    etc.
    end sub
    table data1
    1,2,3
    end table
    table data2
    4,5,6
    end table
    
     
  • stan cartwright

    stan cartwright - 2017-09-13

    It got complicated with strings. I want tables/arrays of glcd colours, 0's don't plot and re,bl,gn defined as ili9341 colours which are 16 bit numbers I think.
    I'm using a 18f25k22
    • Up to 64 Kbytes Linear Program Memory
    I'm new to pics and haven't done basic since the 80's when you could use a rem statement to store data or code because you knew the address. Don't think that's useful now.
    If I dim four arrays ,dim a1(100),a2(100)..could I find the address of 1st element and use that with peek?

     
  • Anobium

    Anobium - 2017-09-13

    If you use arrays then just address the specific element or elements should be no need for peek or poke.

    If you explain what outcome you are trying to achieve , and, some high level pseudo code - folks may be able to assist.

    Anobium

    P.S. if you using v0.98.00 RC4 please stop using. There is a very serious bug and results of pretty simple calcs with braces anda array elements with no yield the correct ASM or Hex file.

     
  • stan cartwright

    stan cartwright - 2017-09-14

    It's a simple sprite sub to plot/erase...or not plot/erase pixels on ili9341.
    I need to be able to change sprite_data to point to sprite_data1 , 2 etc.
    a 12x12 sprite is 144 bytes and a table is only 255 bytes so a big table is out.
    I could read the tables into an array and use a pointer to each data set..hmm,I'll try that.
    I'll look at the asm of some code and see how arrays and tables are done if I can follow it.
    I changed my code to use select case and a var to use different tables but as the code stood it tested for each pixel in the table so was visually flickery.

    sub sprite (sprite_x,sprite_y,sprite_height,sprite_width,sprite_data,pset_sprite)
      ptr=0:py=sprite_y
      if pset_sprite=0 then ;erase sprite
        for sprite_row=1 to sprite_height
          for sprite_column=0 to sprite_width-1
            ReadTable sprite_data,ptr,pixel
            if pixel>0 then ;erase pixel
              pset sprite_x+sprite_column,py,GLCDBackground
            end if
            ptr=ptr+1
          next sprite_column
          py=py+1
        next sprite_row
      else ;plot sprite
        for sprite_row=1 to sprite_height
          for sprite_column=0 to sprite_width-1
            ReadTable sprite_data,ptr,pixel
            if pixel>0 then ;plot pixel
              pset sprite_x+sprite_column,py,pixel
            end if
            ptr=ptr+1
          next sprite_column
          py=py+1
        next sprite_row
      end if
    end sub
    ;
    table sprite_data
    0,0,0,0,0,ye,ye,0,0,0,0,0
    0,0,0,ye,ye,wh,wh,ye,ye,0,0,0
    0,0,ye,bl,bl,wh,wh,bl,bl,ye,0,0
    0,ye,bl,bl,bl,wh,wh,bl,bl,bl,ye,0
    0,ye,bl,bl,bl,wh,wh,bl,bl,bl,ye,0
    ye,wh,wh,wh,wh,wh,wh,wh,wh,wh,wh,ye
    ye,re,re,re,re,re,re,re,re,re,re,ye
    0,ye,re,wh,wh,wh,wh,wh,wh,re,ye,0
    0,ye,re,wh,wh,wh,wh,wh,wh,re,ye,0
    0,0,ye,re,re,wh,wh,re,re,ye,0,0
    0,0,0,ye,re,re,re,re,ye,0,0,0
    0,0,0,0,0,ye,ye,0,0,0,0,0
    end table
    
     

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.