Menu

sprite not right

Help
2017-08-02
2017-08-02
  • stan cartwright

    stan cartwright - 2017-08-02

    Hi, I'm developing a simple sprite program for ssd1306. I want to use/access the buffer_alias in my own program but I am stuck connecting the two. Hard to explain for me. This code don't asm past the line I've highlighted so I can't test for other errors.
    Any advice would be handy.I was thinking of writing a game and plotting chars seems slow.

    #chip mega328p, 16
    #option explicit
    #include <glcd.h>
    ;
    #define HI2C_BAUD_RATE 400
    #define HI2C_DATA
    HI2CMode Master
    #define GLCD_TYPE GLCD_TYPE_SSD1306
    #define GLCD_I2C_Address 0x78
    ;
    #define SSD1306_COLUMNADDR =0x21
    #define SSD1306_PAGEADDR =0x22 ;Page 0-7 represents 8 pixel line,1 byte, 0 - 7
    ;
    dim tmp1,row,ptr,py,px,shiftsright,sprite1,sprite_hibyte,sprite_lowbyte,spritebyte as Byte
    ;!!!!!!!!!!!!!!!!!!!!!!! help here please !!!!!!!!!!!!!
    dim ssd1306buffer as alias SSD1306_BufferAlias
    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    GLCDCLS
    ;
    px=50:py=20
    draw_sprite
    ;end
    do forever
    ;
    sub draw_sprite
      for tmp1=1 to 8 ;8 vertical bytes in a horizontal row
        ReadTable sprite1, tmp1, sprite_hibyte ;this vertical sprite byte
        shiftsright=py And 7 ;number of right shifts
        do until shiftsright=0
          set c off
          rotate sprite_hibyte Right
          rotate sprite_lowbyte Right ;carry from hi to low byte
          shiftsright=shiftsright-1
        loop ;rotate byte to py screen co-ord
        ;sprite byte now is between hi and low byte
        ;now get buffer byte position from px,py
        ptr=py And 0xF8:ptr=(FnLSl (ptr,4) or px)+1 ;buffer position to start writing to
        ;xor sprite byte to buffer byte
        ssd1306buffer(ptr)=ssd1306buffer(ptr) xor sprite_hibyte ;hibyte in buffer
        ptr=ptr+128 ;next row in buffer
        ssd1306buffer(ptr)=ssd1306buffer(ptr) xor sprite_lowbyte ;lowbyte in buffer
        ;now write the bytes from buffer to display
        row= FnLSR (py,3) ;row 0 to 7
    ;
        spritebyte=sprite_hibyte
        write_sprite_byte ;write high byte to display from buffer
    ;
        row=row+1 ;next row of bytes
    ;
        spritebyte=sprite_lowbyte
        write_sprite_byte ;write low byte to display from buffer
    ;
      next tmp1
    end sub
    ;
    sub write_sprite_byte ;writes byte to display at row and px co-ord
      hi2csend (0)
      hi2csend (SSD1306_PAGEADDR) ;row 0 to 7
      hi2csend (0)
      hi2csend (row)
      hi2csend (0)
      hi2csend (7)
      hi2csend (0)
      hi2csend (SSD1306_COLUMNADDR) ;px position
      hi2csend (0)
      hi2csend (px)
      hi2csend (0)
      hi2csend (127)
      hi2csend (64) ;write data to follow
      hi2csend (spritebyte) ;oled screen byte
    end sub
    ;
    table sprite1 ;sprite shape data
      b'11111111'
      b'11000011'
      b'10011001'
      b'10100101'
      b'10100101'
      b'10011001'
      b'11000011'
      b'11111111'
    end Table
    
     
  • Anobium

    Anobium - 2017-08-03

    You are on a release candidate version of Great Cow BASIC. You version of the library is not the same as the formally released version.

    Post code that.compiles, or is intended to compile, plus any libraries you have adapted as a zip file.

     
  • stan cartwright

    stan cartwright - 2017-08-03

    I'm using GCB V0.97.00 2017-04-09 and the original ssd1306 include that came with it. It was intended as an addon everyone could use.
    It doesn't compile with errors ssd1306buffer not defined..my unique variable name.
    I had this problem when I tried to write a test pixel on or off program but it was flawed because at the time I thought arrays started at zero. Anyway you wrote the program for next release and I never figured why I couldn't access the SSD1306_BufferAlias array from my code but I'll keep trying.
    I've been inpired by youtube videos of gamebuino handheld game devices and the thought that gcb can do what arduino can. Arduino has sprites.
    The glcd includes are excellent. I was surprised that GLCDDrawChar does actually plot/draw chars.
    I hope for faster result but that's not a criticism. On colour displays we could have multicoloured chars but needs memory.
    In the community spirit, I want to help. I'm using a free program and the forum for help and want to give anything I can do back as thanks.
    How much memory would a complicated polygon fill routine take?.. I'll check.

     

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.