Here's my 1st attempt sprite for ili9341 code. uses sprite height-width grid but only plots lit pixels.
I abreviated colour names or the table looked messy. https://youtu.be/qwXrzUCCAXY
Checking only lit pixels in sprite seems smoother than ploting background pixels.
;sprite#chip mega328p, 16#option explicit#include<glcd.h>;#define GLCD_TYPE GLCD_TYPE_ILI9341#define GLCD_DC portb.2#define GLCD_CS portd.7#define GLCD_RESET portd.4 ; Reset line Tie high..not needed#define GLCD_DO portb.3 ; MOSI SDI#define GLCD_SCK portb.5 ; SCK#define ILI9341_HardwareSPI ' remove/comment out if you want to use software SPI.#define GLCD_EXTENDEDFONTSET1#define bk ILI9341_BLACK#define re ILI9341_RED#define gr ILI9341_GREEN#define bl ILI9341_BLUE#define wh ILI9341_WHITE#define pu ILI9341_PURPLE#define ye ILI9341_YELLOW#define cy ILI9341_CYAN#define dg ILI9341_D_GRAY#define lg ILI9341_L_GRAY#define si ILI9341_SILVER#define ma ILI9341_MAROON#define ol ILI9341_OLIVE#define li ILI9341_LIME#define aq ILI9341_AQUA#define te ILI9341_TEAL#define na ILI9341_NAVY#define fu ILI9341_FUCHSIA;GLCDBackground=ILI9341_BLACKGLCDfntDefaultsize=2GLCDRotate(landscape)GLCDCLSILI9341_BLACKGLCDPrint(0,0,"TEST");dimsprite_height,sprite_width,sprite1data,sprite_yasbytedimsprite_row,sprite_column,pset_sprite,py,ptrasbytedimsprite_x,pixelasWordsprite_x=100:sprite_y=100:sprite_height=12:sprite_width=12pset_sprite=1doforsprite_x=0to300pset_sprite=1spritewait1mspset_sprite=0spriteNextforsprite_x=300to0pset_sprite=1spritewait1mspset_sprite=0spritenextloop;subspriteptr=0:py=sprite_yforsprite_row=1tosprite_heightforsprite_column=0tosprite_width-1ReadTablespritedata,ptr,pixelifpset_sprite=0then;Itriedifpset_sprite=0andpixel<>0thenpsetsprite_x+sprite_column,py,GLCDBackgroundelseifpixel<>0thenpsetsprite_x+sprite_column,py,pixelendifendifptr=ptr+1nextsprite_columnpy=py+1nextsprite_rowendsub;tablespritedata0,0,0,0,0,ye,ye,0,0,0,0,00,0,0,ye,ye,wh,wh,ye,ye,0,0,00,0,y,bl,bl,wh,wh,bl,bl,0,00,ye,bl,bl,bl,wh,wh,bl,bl,bl,ye,00,ye,bl,bl,bl,wh,wh,bl,bl,bl,ye,0ye,wh,wh,wh,wh,wh,wh,wh,wh,wh,wh,yeye,re,re,re,re,re,re,re,re,re,re,ye0,ye,re,wh,wh,wh,wh,wh,wh,re,ye,00,ye,re,wh,wh,wh,wh,wh,wh,re,ye,00,0,ye,re,re,wh,wh,re,re,ye,0,00,0,0,ye,re,re,re,re,ye,0,0,00,0,0,0,0,ye,ye,0,0,0,0,0endtable
Last edit: stan cartwright 2017-08-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Slight improvement to the sprite draw routine. 4.7-5.4ms = ~5ms with the sprite being updated in 1.2-1.9ms. Why the difference... edges of the screen take more time as there is more to update.
At 5ms delay the ball has persistence of vision but any game playing would be very hard!
I managed to get a ssd1306 sprite using pset, it takes 3.8 ms for the shape in the listing not moving. Less lit pixels, the faster it plots the sprite.
sub sprite (sprite_x,sprite_y,sprite_height,sprite_pset)
for sprite_column=1 to sprite_height
readtable sprite_data,sprite_column,sprite_pixel
for sprite_bit=0 to 7
if sprite_pixel and 1 =1 then
pset sprite_x+sprite_column-1,sprite_y+sprite_bit,sprite_pixel and sprite_pset
end if
rotate sprite_pixel right
next sprite_bit
next sprite_column
end sub
table sprite_data ;sprite shape data
b'00010000'
b'01100011'
b'01000011'
b'10000000'
b'10000000'
b'01000011'
b'01100011'
b'00010000'
end Table
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The revised sprite method in release v0.98.00 or greater updates the sprite in 1.255ms and 615us if not moving. Mega 328p@16mhz handling a 64 bit pixels where 48 pixels are not background color.
Last edit: Anobium 2017-08-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had a think for a faster method...thought 2 seperate routines,1 for plot, other for erase. Would be faster, a bit. I'm only experimenting. It's quite interesting.
The video games from the early 80's 8 bit era where a screen byte represented more than 1 pixel never used plot to draw graphics, they were usually rotated bytes. Amstrad and BBC used 1 byte per pixel in hi res colour mode, simpler.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes indeed, looking forward to .98
Not quaint version does't work..just 3 rows. Is var1.var2 allowed? ie bit var2 of var 1
I changed my sprite so no rotate but don't work as previous which was so simple...but not 45 us. https://youtu.be/ymBa2OjQjaQ
If I have x named tables, how do I say sprite_table=table_x ? I get errors with =
;should work but doesn't
sub sprite (sprite_x,sprite_y,sprite_height,sprite_pset)
for sprite_column=1 to sprite_height
readtable sprite_data,sprite_column,sprite_byte
for sprite_bit=0 to 7
if sprite_byte.sprite_bit =1 then ; and 1 =1 then
pset sprite_x+sprite_column-1,sprite_y+sprite_bit,(sprite_byte.sprite_bit and sprite_pset)
end if
next sprite_bit
next sprite_column
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's my 1st attempt sprite for ili9341 code. uses sprite height-width grid but only plots lit pixels.
I abreviated colour names or the table looked messy. https://youtu.be/qwXrzUCCAXY
Checking only lit pixels in sprite seems smoother than ploting background pixels.
Last edit: stan cartwright 2017-08-21
Slight improvement to the sprite draw routine. 4.7-5.4ms = ~5ms with the sprite being updated in 1.2-1.9ms. Why the difference... edges of the screen take more time as there is more to update.
At 5ms delay the ball has persistence of vision but any game playing would be very hard!
A video
Last edit: Anobium 2017-08-21
I managed to get a ssd1306 sprite using pset, it takes 3.8 ms for the shape in the listing not moving. Less lit pixels, the faster it plots the sprite.
How quaint.
The revised sprite method in release v0.98.00 or greater updates the sprite in 1.255ms and 615us if not moving. Mega 328p@16mhz handling a 64 bit pixels where 48 pixels are not background color.
Last edit: Anobium 2017-08-24
I had a think for a faster method...thought 2 seperate routines,1 for plot, other for erase. Would be faster, a bit. I'm only experimenting. It's quite interesting.
The video games from the early 80's 8 bit era where a screen byte represented more than 1 pixel never used plot to draw graphics, they were usually rotated bytes. Amstrad and BBC used 1 byte per pixel in hi res colour mode, simpler.
We are very close to releasing v0.98.00. There are many new GLCD performance features that may be of interest.
Yes indeed, looking forward to .98
Not quaint version does't work..just 3 rows. Is var1.var2 allowed? ie bit var2 of var 1
I changed my sprite so no rotate but don't work as previous which was so simple...but not 45 us.
https://youtu.be/ymBa2OjQjaQ
If I have x named tables, how do I say sprite_table=table_x ? I get errors with =