Plotting a 16x16 multi coloured char is 256 bytes (if they're bytes.. maybe words)
I just coded different scans of the table to get normal, inverted, rotate +90, -90 and reversed.
It saves memory but for displays filled boxes and triangles maybe.
loop;end main loop;------------------suberase_sprite(sprite_x,sprite_y);write a box of 0'sSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)repeat256SendWord_ILI9341bgendrepeatendsub;subsprite_normal(insprite_x, insprite_y, inspritedata_ptr);fills box with sprite dataSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)ptr=spritedata_ptrrepeat256ReadTablespritedata,ptr,pixelSendWord_ILI9341pixelptr++endrepeatendsub;subsprite_reversed(insprite_x, insprite_y, inspritedata_ptr);fills box with sprite data reversedSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)ptr=spritedata_ptr+15repeat16repeat16ReadTablespritedata,ptr,pixelSendWord_ILI9341pixelptr---endrepeatptr=ptr+32endrepeatendsub;subsprite_90anti(insprite_x, insprite_y, inspritedata_ptr);fills box with sprite data 90 degrees anti-clockwiseSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)ptr=spritedata_ptr+15repeat16repeat16ReadTablespritedata,ptr,pixelSendWord_ILI9341pixelptr=ptr+16endrepeatptr=ptr-257endrepeatendsub;subsprite_90clok(insprite_x, insprite_y, inspritedata_ptr);fills box with sprite data 90 degrees clockwiseSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)ptr=spritedata_ptr+240repeat16repeat16ReadTablespritedata,ptr,pixelSendWord_ILI9341pixelptr=ptr-16endrepeatptr=ptr+257endrepeatendsub;subsprite_inverted(insprite_x, insprite_y, inspritedata_ptr);fills box with sprite data invertedSetAddressWindow_ILI9341(sprite_x,sprite_y,sprite_x+15,sprite_y+15)ptr=spritedata_ptr+240repeat16repeat16ReadTablespritedata,ptr,pixelSendWord_ILI9341pixelptr++endrepeatptr=ptr-32endrepeatendsub;tablespritedata;sprite 1wh,bl,bl,bl,bl,bg,bg,bg,bg,bg,bg,bl,bl,bl,bl,whbg,bl,re,re,re,bl,bl,bg,bg,bl,bl,re,re,re,bl,bgbg,bg,bl,re,re,re,bl,bg,bg,bl,re,re,re,bl,bg,bgbg,bg,bg,bl,re,wh,bl,bg,bg,bl,wh,re,bl,bg,bg,bgbg,bg,bg,bg,bl,wh,bl,bg,bg,bl,wh,bl,bg,bg,bg,bgbg,bg,bg,bg,bg,bl,bl,bg,bg,bl,bl,bg,bg,bg,bg,bgbg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bgbg,bg,bg,bg,ye,ye,ye,bg,bg,ye,ye,ye,bg,bg,bg,bgbg,bg,bg,ye,bg,bg,bg,bg,bg,bg,bg,bg,ye,bg,bg,bgbg,ye,ye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,ye,ye,bgbg,ye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,ye,bgye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bl,yeye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,yeye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,yebg,ye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,ye,bgbg,bg,ye,bg,bg,bg,bg,bg,bg,bg,bg,bg,bg,ye,bg,bg;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I didn't think it was interesting... just messin' about with reading tables.
'''A demonstration program for GCB'''---------------------------------------------------------------------------------''' This demonstration shows sprites on the GLCD using an SPI device can use hardware or software SPI.''''''--------------------------------------------------------------------------------------;Pic settings;#chip 18f25k22,64;#config MCLRE=on;#option Explicit;#include <glcd.h>;Pin mappings for ILI9341;#define GLCD_DC portc.2;#define GLCD_CS portc.0;#define GLCD_RESET portc.1;As we are using Harware SPI this cannot be change on this chip. This is a non-PPS chip.;#define GLCD_DI portc.4;#define GLCD_DO portc.5;#define GLCD_SCK portc.3;#define ILI9341_hardwarespi;------------------------------------------------------------------------------------------------;lgt/uno settings ; #chip LGT8F328P ; #option explicit ; #include <glcd.h> ; #include <LGT8F328P.h>;---------------------------------------------------- #chip mega328P,16 #option explicit #include <glcd.h> #include <uno_mega328P.h> #define GLCD_TYPE GLCD_TYPE_ILI9341 #define ILI9341_HardwareSPI #define HWSPIMode MASTERULTRAFAST 'Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI #define GLCD_DC DIGITAL_8 ' Data command line #define GLCD_RESET DIGITAL_9 ' Reset line #define GLCD_CS DIGITAL_10 ' Chip select line #define GLCD_DO DIGITAL_11 ' Data out | MOSI #define GLCD_SCK DIGITAL_13 ' Clock Line;------------------------------------------------------------------------------------- ;define the frame_refresh #define frame_refresh 5 '1 to 5 is advised ; ;now rename colours to make it easier to set up sprite data #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 ;backgroung color #define bg bk GLCDRotate Portrait GLCDCLS bg ;init vars dim sprite_height,sprite_width,temp,frame,frame_count as byte dim sprite_x,sprite_y,ptr,spritedata_ptr,pixel,dx(8),dy(8),spy(8),oldspy(8),spx(8),oldspx(8) as Word ;set up start sprite positions and directions dx(1)=2:dx(2)=3:dx(3)=65536-4:dx(4)=6 dx(5)=65536-8:dx(6)=65536-8:dx(7)=65536-8:dx(8)=65536-8 dy(1)=65536-5:dy(2)=65536-3:dy(3)=65536-8:dy(4)=3 dy(5)=2:dy(6)=7:dy(7)=2:dy(8)=8 ; spx(1)=30:spx(2)=100:spx(3)=150:spx(4)=50 spx(5)=160:spx(6)=100:spx(7)=80:spx(8)=30 spy(1)=20:spy(2)=20:spy(3)=16:spy(4)=50:spy(5)=60:spy(6)=40 spy(5)=20:spy(6)=30:spy(7)=24:spy(8)=36 sprite_height=16:sprite_width=16 spritedata_ptr=1 frame=0:frame_count=0 ; do ;main loop-------------------- temp=1 repeat 8 if spx(temp)> (229-sprite_width) then ;check right edge dx(temp)= 65536-dx(temp) end if if spx(temp)<8 then ;check left edge dx(temp)= 65536-dx(temp) end if if spy(temp)> (319-sprite_height) then ;check bottom edge dy(temp)= 65536-dy(temp) end if if spy(temp)<8 then ;check top edge dy(temp)= 65536-dy(temp) end if ; oldspx(temp)=spx(temp):oldspy(temp)=spy(temp) ;get last position for erase spx(temp)=spx(temp)+dx(temp):spy(temp)=spy(temp)+dy(temp) ;get new position for draw ;******* change sprite_90clok to sprite_90anti or sprite_normal or sprite_inverted or sprite_reversed ********************************* if frame=0 then;which sprite to draw erase_sprite (oldspx(temp),oldspy(temp)) ;erase sprite at last position ' 1 ;pointer to sprite 1 in table sprite_90clok (spx(temp),spy(temp), 1 ) ;draw sprite1 at new position else erase_sprite (oldspx(temp),oldspy(temp)) ;erase sprite at last position ' 257 ;pointer to sprite 2 in table sprite_90clok (spx(temp),spy(temp), 256) ;draw sprite2 at new position end if ; temp++ end repeat;************************************************************************* frame_count++ ;when to change spritedata_ptr if frame_count=frame_refresh then frame=!frame frame_count=0 end if loop ;end main loop ;------------------ sub erase_sprite (sprite_x,sprite_y) ;write a box of 0's SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) repeat 256 SendWord_ILI9341 bg end repeat end sub;sub sprite_normal ( in sprite_x, in sprite_y, in spritedata_ptr ) ;fills box with sprite data SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) ptr=spritedata_ptr repeat 256 ReadTable spritedata,ptr,pixel SendWord_ILI9341 pixel ptr++ end repeat end sub;sub sprite_reversed ( in sprite_x, in sprite_y, in spritedata_ptr ) ;fills box with sprite data reversed SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) ptr=spritedata_ptr+15 repeat 16 repeat 16 ReadTable spritedata,ptr,pixel SendWord_ILI9341 pixel ptr--- end repeat ptr=ptr+32 end repeatend sub;sub sprite_90anti( in sprite_x, in sprite_y, in spritedata_ptr ) ;fills box with sprite data 90 degrees anti-clockwise SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) ptr=spritedata_ptr+15 repeat 16 repeat 16 ReadTable spritedata,ptr,pixel SendWord_ILI9341 pixel ptr=ptr+16 end repeat ptr=ptr-257 end repeatend sub;sub sprite_90clok ( in sprite_x, in sprite_y, in spritedata_ptr ) ;fills box with sprite data 90 degrees clockwise SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) ptr=spritedata_ptr+240 repeat 16 repeat 16 ReadTable spritedata,ptr,pixel SendWord_ILI9341 pixel ptr=ptr-16 end repeat ptr=ptr+257 end repeatend sub;sub sprite_inverted ( in sprite_x, in sprite_y, in spritedata_ptr ) ;fills box with sprite data inverted SetAddressWindow_ILI9341 ( sprite_x,sprite_y,sprite_x +15,sprite_y +15 ) ptr=spritedata_ptr+240 repeat 16 repeat 16 ReadTable spritedata,ptr,pixel SendWord_ILI9341 pixel ptr++ end repeat ptr=ptr-32 end repeatend sub;; table spritedata ;sprite 1 wh,bl,bl,bl,bl,bg,bg,bg,bg,bg,bg,bl,bl,bl,bl,wh bg,bl,re,re,re,bl,bl,bg,bg,bl,bl,re,re,re,bl,bg bg,bg,bl,re,re,re,bl,bg,bg,bl,re,re,re,bl,bg,bg bg,bg,bg,bl,re,wh,bl,bg,bg,bl,wh,re,bl,bg,bg,bg bg,bg,bg,bg,bl,wh,bl,bg,bg,bl,wh,bl,bg,bg,bg,bg bg,bg,bg,bg,bg,bl,bl,bg,bg,bl,bl,bg,bg,b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bg,bg,bg,ye,bg,bg bg,bg,bg,ye,ye,bg,bg,bg,bg,bg,bg,ye,ye,bg,bg,bg bg,bg,bg,bg,ye,ye,bg,bg,bg,bg,ye,ye,bg,bg,bg,bg bg,bg,bg,bg,bg,ye,bg,bg,bg,bg,ye,bg,bg,bg,bg,bg bg,bg,bg,bg,bg,bg,ye,bg,bg,ye,bg,bg,bg,bg,bg,bg end table ;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Plotting a 16x16 multi coloured char is 256 bytes (if they're bytes.. maybe words)
I just coded different scans of the table to get normal, inverted, rotate +90, -90 and reversed.
It saves memory but for displays filled boxes and triangles maybe.
Come on.. :-)
Post the complete demo!!
I didn't think it was interesting... just messin' about with reading tables.
I luv gcb glcd
Make a video