Shop OBEX P1 Docs P2 Docs Learn Events
Update: Released new version! - Jump table in graphics.spin - Page 5 — Parallax Forums

Update: Released new version! - Jump table in graphics.spin

1235»

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-24 02:58
    Now that the spin interperter is almost cracked I can get back to this. smile.gif I found the problem. I thought that I would be smart so I tried to use one call to do both drawing glyphs at an x,y position and at an angle,radius. That works fine... except that I wasn't putting where the glyph was stored back in the right place when I called the x,y routine... I should have an update shortly.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-24 03:01
    As it's sleepy time here now (or already past sleepy time...) I will not look for it during the next hours. Good night!
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-24 03:44
    As promised above.

    Now you can draw glyph on the screen at an x,y or an angle, radius position. Use
    drawGlyph(x, y, xr, yr, angle, pixrot, pixdef_ptr, glyph) for angle radius position and
    drawGlyph(x, y, pixrot, 0, 0, 0, pixdef_ptr, glyph) for x,y position

    when drawing at an angle, raduis the yr argument cannot be 0 as it is used to determine whether we are drawing by x,y or angle,radius.

    Also you can draw strings at an x,y using
    str(x,y,stringPtr) although this does the main loop in spin at the moment.

    I also changed to using deSilva's demo code (changed slightly to use drawGlyph where possible) and (probably much to his delight) added some version info in the file name smile.gif

    I am currently using every long in the cog. There is still hope to add more functions by using overlays though. I am going to try to do this with the text functions so that we can draw strings with all types of font at a reasonable speed.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-27 08:51
    I have nearly got the text(x,y,stringPtr) working for the ROM font. At the moment it is only drawing the first character so I have some debugging to do... see attached
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-27 09:51
    I now have them all printing on top of each other, shouldn't be long now smile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-02-27 10:26
    The text method can now be used with both the Vector and ROM fonts. Simply use
    setFont(0) to set the vector font and
    setFont(1) to set the ROM font

    You will also need to set the text width to 16 using the textMode method when using the ROM font otherwise the characters will overlap.

    The scaling is ignored when using the ROM font. There is up to 60 longs available for doing new fonts using the overlay method so if someone can fit Clemens font in that than I will add that as well.

    Anything else people want added?

    I will remove the str function as it is no longer needed. Unless people want them I will also remove the glyph functions as you can now use the text method instead. This will free up around 20 longs in the cog if someone wants something else added.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-10 09:44
    Would someone be able to check that the spin in the comments is actually properly translated to asm? Its for the Clemens driver. It shows boxes (the right size) instead of the character.
        'cbase := $8000+ glyph/2*128
        'cbase:=glyph>>1<<7+$8000   'romBase=cbase    
    clemensStart            [b]ror[/b]     romBase,#1      [b]wc[/b]     'glyph>>1
                            [b]shl[/b]     romBase,#7             'glyph<<7
                            [b]add[/b]     romBase,h8000          'glyph+$8000
    
        'REPEAT  i from 0 to 11
                            [b]mov[/b]     loopC1,#11    'setup for loop around lines
    
          'The Clemens-Trick
          ' line:= LOOKUPZ(i: 1,4,6,9,11,14,17,20,22,25,27,28,31)   'data is down in clemensTable
    :loop1                  [b]mov[/b]     romAddr,#clemensTable   'start of table
                            [b]add[/b]     romAddr,loopC1          'add current row
                            [b]mov[/b]     romAddr,romAddr         'get the value in clemensTable (this gives the same as above times 4 since we are getting a long)        
           'pattern := long[noparse][[/noparse]cbase][noparse][[/noparse]line] 'get from rom
                            [b]add[/b]     romAddr,romBase         'add in the romBase  
                            [b]rdlong[/b]  pattern,romAddr         'get the data
           'pattern2~   'clear                   
                            [b]mov[/b]     pattern2,#0
           'IF glyph&1    'fix up for overlaid character
             'pattern >>= 1                 
            [b]if_c[/b]            [b]shr[/b]     pattern,#1              'the c flag gets set at the start and doesn't get changed anywhere else
           'REPEAT 8                                     
                            [b]mov[/b]     loopC2,#8               'setup for loop
             'pattern2 <<= 2                            
    :loop2                  [b]shl[/b]     pattern2,#2
             'if pattern&1                               
                            [b]test[/b]    pattern,#1      [b]wz[/b]
                'pattern2+=3                             
                  [b]if_z[/b]      [b]add[/b]     pattern2,#3
             'pattern >>= 4                             
                            [b]shr[/b]     pattern,#4
                            [b]djnz[/b]    loopC2,#:loop2          'do small loop again
                            
           'pixDef2[noparse][[/noparse]i+2]:= pattern2                    
                            [b]mov[/b]     pixAddr,#2              'get 2
                            [b]add[/b]     pixAddr,loopC1          'add in which row we are on
                            [b]shl[/b]     pixAddr,#1              'multiply by 2 for word size
                            [b]add[/b]     pixAddr,pixBase         'add in the address of the pix sprite that we are using
                            [b]wrword[/b]  pattern2,pixAddr        'write the data back to the hub
    
                            [b]djnz[/b]    loopC1,#:loop1          'do big loop again
    
                            [b]MOV[/b]     tmpArg2,arg2            'need to save this, set it to 0 and then restore it
                            [b]MOV[/b]     arg2,#0                 'to make not fliped or rotated
                            [b]CALL[/b]    #setd                   'some setup for the pix routine
                            [b]MOV[/b]     arg3,pixBase            '
                            [b]MOVS[/b]    pixret_,#clemensEnd     '
                            [b]JMP[/b]     #pix_
    
    clemensEnd              [b]MOV[/b]     arg2,tmpArg2            'restore arg2
                            [b]ADD[/b]     arg0,textsp             'increment x position for next character
                            [b]JMP[/b]     #chr                    'go back for the next character
        'return @pixDef2
    
    pixBase       [b]long[/b] 0                                    'need to set this during setup
    clemensTable  [b]long[/b] 4,16,24,36,44,14*4,17*4,20*4,22*4,25*4,27*4,28*4,31*4 
    tmpArg2       [b]long[/b]  0
    
    clemensBuffer           [b]word[/b]
                            [b]byte[/b]    1,12,0,0
                            [b]word[/b]    0[noparse][[/noparse]16]
    
    
    
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-20 01:29
    Well, after writing this in asm, doing a flowchart, writing it again in asm, converting the asm to spin and fixing a couple of typos in the spin my algorithm is working in spin! I haven't decided if this is a good or bad thing yet as it means that there is a problem somewhere else...

    Anyway, this is basically to let people know that I am still working on this and making (slowlysmile.gif) making progress.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-12 09:35
    I finally found the bug and Clemens font is working! hop.gif In the circle demo it looks like is faster than both the normal ROM font and the vector font.

    I'll clean everything up and post it tonight or tomorrow here before putting it in the OBEX.
  • ClemensClemens Posts: 236
    edited 2008-04-12 10:15
    Congratulations. Looking forward to see it. smile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-12 13:15
    Okay, here is an update. Its not final because I need to finish the method to get colors from the bitmap and still need to test a couple of methods but the demo is working well. All the text in the demo is done using either the ROM font or Clemens font.

    It is actually a variation on Clemens font because it only picks the rows and not columns that Clemens found.

    Edit: The vector font doesn't work very well in XOR mode. It could be fixed by making a short line wherever lines intersect so if anyone wants to volunteer....
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-13 06:03
    Clemens,
    For this I can choose any rows or columns but they have to be the same for all characters. Did you find a combination of columns that worked for all the characters or did it have to be different for some?
  • ClemensClemens Posts: 236
    edited 2008-04-13 15:01
    they had to be different for some chars or else thes chars have only one pixel width in their vertical lines. (you can even see this in the demo, look at the "l" when the glyphts rotate.
    this is how·I did it in spin, the column sequence is the same for all chars, just the starting column changes for "14IilYZ7VT"

        if lookdown(glyph:"14IilYZ7VT")
           startcol:=2
        else
           startcol:=0
    


    I didn't find a column setup, that works for all glypths, sorry.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-14 07:12
    Might be able to fit something in if there are only 10 characters that need to be different. I'll have a look tonight.
  • ClemensClemens Posts: 236
    edited 2008-04-17 20:50
    Yeah, it's looking really great. smile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-20 12:14
    Well, this is finally finished. I'll leave it for a couple of days before putting it in the object exchange in case anyone finds a bug in it.

    The only known issue is that some things like the vector font don't work well in XOR mode. The font can be fixed if someone wants to take the time but the other things can't really be fixed unless the entire driver is rewritten. See the file for a list of new methods.

    If you really want to same some space and don't want to use the vector font than you can comment out the vector font and save a hundred or so longs. If only wanted to use Clemens font or the ROM font than you could also comment the appropriate one of them out and save even more space.

    Let me know what you think.

    The demo uses only a single buffer and is 320x240.

    Maybe now I can get back to working on other projects smile.gif

    Have I listed names correctly in the license?

    Post Edited (stevenmess2004) : 4/20/2008 12:19:34 PM GMT
  • Ym2413aYm2413a Posts: 630
    edited 2008-04-20 14:43
    Cool! I can't wait to test this out later tonight. [noparse]:)[/noparse]
    I'm glad that there is support for the bitmap fonts now.

    Thanks Steve!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Share the knowledge: propeller.wikispaces.com
    Lets make some music: www.andrewarsenault.com/hss

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-22 11:28
    Well, this is finally in the object exchange after nearly 3 months. Thanks to everyone who helped. In particular deSilva and Clemens. I've learned a lot from this and its been a lot of fun.
Sign In or Register to comment.