Shop OBEX P1 Docs P2 Docs Learn Events
2BitBitmapDemo — Parallax Forums

2BitBitmapDemo

BTXBTX Posts: 674
edited 2009-09-24 21:15 in Propeller 1
I was playing arround the Rayman 2BitBitmapDemo.
My intention is to load the bitmap data from a software variable, instead using a "DAT" declaration and follow the "filename.dat" who contains the data.
I've no luck with this, does anybody get it work ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.

Alberto.

Comments

  • AleAle Posts: 2,363
    edited 2009-09-24 06:51
    You mean from an array right ? Then it should be the same just pass the address using the '@' operator. But if the variable contains the address, just use that value. You may need to clarify what "does not work" means... I normally use the address $8000 (where the fonts are) for testing. If the usual patterns are displayed... then the driver works. For 2 bits (using grayscale) should look like this:

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit some of my articles at Propeller Wiki:
    MATH on the propeller propeller.wikispaces.com/MATH
    pPropQL: propeller.wikispaces.com/pPropQL
    pPropQL020: propeller.wikispaces.com/pPropQL020
    OMU for the pPropQL/020 propeller.wikispaces.com/OMU
    398 x 296 - 36K
  • BTXBTX Posts: 674
    edited 2009-09-24 12:39
    Ok Ale, thank you so much for the answer. I will remake the question.

    In the Rayman 2BitBitmapDemo he catch the bitmap data like this:
    DAT
    PropUpper long
    'Prop_Upper is 16x5
    file "Prop_Upper.dat"
    



    I want to do this: (from a variable)
    VAR
     long   PropUpper[noparse][[/noparse]1280]
    



    Then I will fill the variable with the bitmap data, getting it from another eeprom or SD card.
    To show the bitmap, he uses something like the TV driver explain, this is:

    BmpAddress:=@PropUpper
         screen[noparse][[/noparse]row * cols + col] := (color) << 10 + BmpAddress>>6 + c       ' ' c:=0..15
    
    



    It should work for me, but he add some type of correction in the data address that I can't finish to understand, I tried something like this above, but wont work correctly.

    All examples I found are done in this way, How to do what I'm looking for

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • Agent420Agent420 Posts: 439
    edited 2009-09-24 12:52
    >It should work for me, but he add some type of correction in the data address that I can't finish to understand, I tried something like this above, but wont work correctly

    If I understand correctly, this has to do with the fact that the video drivers require the bitmap or tile data to be long aligned.· As you cannot specify or otherwise guarentee the address your source data compiles to will be 64 byte long aligned, he includes a buffer variable (PADDING) imediately before the bitmap data that accounts for the worst case addressing scenario.· Then early in the code he moves the data from where it compiled to the nearest 64 byte aligned address (AND'ing with $FFC0) using a longmove:

     '64 byte align the user characters:
      'The video generators require char data to be long block aligned.
      'This moves the char data in DAT from it's original compiled position to the previous
      'long aligned address location - the PADDING data allocates free space to accommodate
      'the worst case scenario of any long alignment offset.
      user_charbase := @uchar & $FFC0                                               'new destination
      longmove(user_charbase,@uchar,16*nuchars)  
    


    Having moved the bitmap data, you then need to use the new location (user_charbase) as the array pointer.
    So you need to do something similar.· It is important that the number of longs to move are exactly how large your bitmap data is.

    edit -

    Here is something to try...

      user_charbase := @PropUpper & $FFC0
      longmove(user_charbase,@PropUpper,1280) 
     
    ...
     
      screen[noparse][[/noparse]row * cols + col] := (color) << 10 + user_charbase>>6 + c       ' ' c:=0..15
     
    ...
     
      DAT
      padding LONG  7[noparse][[/noparse]16] 'alignment padding for the following user defined char
      PropUpper long 
      'Prop_Upper is 16x5
      file "Prop_Upper.dat"
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Agent420) : 9/24/2009 7:27:44 PM GMT
  • RaymanRayman Posts: 14,851
    edited 2009-09-24 16:05
    I think Agent420 has it exactly right... You can do it, but you need to look at that longmove line to figure out what the offset is you need to use for moving the data...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Agent420Agent420 Posts: 439
    edited 2009-09-24 19:35
    Oops, I forgot you mentioned using the an array variable declared in VAR...··

    I'm thinking that declaring the array as the first variable in VAR should result in it being long aligned, but you may have to use the PADDING variable as described above.

    Alternatively, I guess that there's not much difference between reserving your data memory space in VAR as opposed to having it in DAT, other than you would have to use placeholder data such as

    DAT

    PropUpper· LONG 0[noparse][[/noparse]1280] ' reserves 1280 longs filled with 0

    Either way, you just insert the data from the SD card to the appropriate pointer address, which would be the new calculated long aliogned address, not the original location.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BTXBTX Posts: 674
    edited 2009-09-24 20:24
    Hi guys, you are a big help for me !!! Thank you !!
    @Agent420
    Yes !, it is the same as declare how you suggest, I found that about a few minutes ago, just I did it and works fine.
    The point that is not still clear for me, is that I've to adjust the padding value, in the Ray's code he uses padding 7(16), and for some reason I should use padding 7(11) to get the code working fine.

    Using data in this way, I could have many differents screens of about 16x12 tiles each, reading them from a SD card, and showing them one by one. While having enough memory space for more code. As in your below example, "PropUpper" will be my image buffer for SD read data.

    Here I've attached my simple example with small variables.

    PS I've declared the array variable at the top of all, but wont work correctly, seems to be non aligned in that way. also using a padding.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
  • RaymanRayman Posts: 14,851
    edited 2009-09-24 20:40
    The bitmap has to be long aligned to 16-longs... So, 16 (or maybe it's really 15) is the maximum shift required, so I reserve that much space for padding... The actual amount of shift required depends on exactly where it winds up, so it's calculated at run time...

    So, you can either borrow from that shift calculation, or guess at the required shift and don't change the code after you guess right...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • BTXBTX Posts: 674
    edited 2009-09-24 21:15
    Ray said...
    So, you can either borrow from that shift calculation, or guess at the required shift and don't change the code after you guess right...

    Ah ok Ray, I did it before, but i thought that was my bad programming technics. (I had to adjust the padding each after insert more code)
    Thank you !!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Regards.

    Alberto.
Sign In or Register to comment.