On the Road again


Author Message
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1471
Posted: 07:01am 12 Oct 2022      

  Quote  Not 30fps using ili9341 but lots of speed increase if blit load blit write used.


sadly, I dont have a ili9341 here to test it, but to use Blit, we would need a source to Blit from and I have no Idea, if it is possibl.
to paint in the Blit source  
Nevertheless, I tryed a Version without using a framebuffer, which hopefully would also run with the ili9341...


Dim Col%(15),Xofs%(160)
Restore colors:For f%=1 To 15:Read Col%(f%):Next f%
'SH% and SW% Displayresolution
SH%=240:SW%=320
dist%=0:Speed%=4
Option Break 4: On Key 3, on_break
MODE 2
'Precalculate the Curve
For f%=0 To 159:Xofs%(159-f%)=((160*Exp(f%/50))/20)-8:Next
'
CLS COL%(1)
HW%=SW%/2:HH%=SH%/2
'-------endless loop -----------------------
'b1x% left x position of the left Border
'b2x% right x position of the left Border and left x position of the street
'b3x% right x position of the street and left x position of the right Border
'b4x% right x position of the right Border
'BB% Border broad
'bc% Border Color (red or white) calculated over Sinus Function
'HH% Half Screen y-Res  HW% Half Screen x-Res
'xofs%() Pre calculated Curve over Exponetial function
'ofsx% how much has the Curve to be bended
Do
t%=Timer
 'bend right
 For n%=1 To 1000 Step Speed%
   For F%=0 To HH%
     bc%=col%(7-3*((Sin((((120-f%)/40)^3)+dist%))>0))
     ofs%=xofs%(f%)*n%/1000
     y%=hh%+f%
     BB%=Int(f%/4)
     b1X%=HW%-F%-bb%+ofs%:b2x%=HW%-F%+ofs%
     b3x%=HW%-F%+ofs%+2*f%:b4x%=b1x%+(2*bb%+2*f%)
     Line 0,y%,b1x%,y%,,COL%(2):Line b1x%,y%,b2x%,y%,,bc%
     Line  b2x%,y%,b3x%,y%,,0
     Line b3x%,y%,b4x%,y%,,bc%:Line b4x%,y%,SW%,y%,,COL%(2)
   Next
   Inc dist%
  Next
'bend back
 For n%=1000 To 1 Step -Speed%
   For F%=0 To HH%
     bc%=col%(7-3*((Sin((((120-f%)/40)^3)+dist%))>0))
     ofs%=xofs%(f%)*n%/1000
     y%=hh%+f%
     BB%=Int(f%/4)
     b1X%=HW%-F%-bb%+ofs%:b2x%=HW%-F%+ofs%
     b3x%=HW%-F%+ofs%+2*f%:b4x%=b1x%+(2*bb%+2*f%)
     Line 0,y%,b1x%,y%,,COL%(2):Line b1x%,y%,b2x%,y%,,bc%
     Line  b2x%,y%,b3x%,y%,,0
     Line b3x%,y%,b4x%,y%,,bc%:Line b4x%,y%,SW%,y%,,COL%(2)
   Next
   Inc dist%
 Next
'bend left
 For n%=1 To 1000 Step Speed%
  For F%=0 To HH%
     bc%=col%(7-3*((Sin((((120-f%)/40)^3)+dist%))>0))
     ofs%=xofs%(f%)*n%/1000
     y%=hh%+f%:BB%=Int(f%/4)
     b1X%=HW%-F%-bb%-ofs%:b2x%=HW%-F%-ofs%
     b3x%=HW%-F%-ofs%+2*f%:b4x%=b1x%+(2*bb%+2*f%)
     Line 0,y%,b1x%,y%,,COL%(2):Line b1x%,y%,b2x%,y%,,bc%
     Line b2x%,y%,b3x%,y%,,0
     Line b3x%,y%,b4x%,y%,,bc%:Line b4x%,y%,SW%,y%,,COL%(2)
   Next
  Inc dist%
 Next
'bend back
 For n%=1000 To 1 Step -Speed%
   For F%=0 To HH%
     bc%=col%(7-3*((Sin((((120-f%)/40)^3)+dist%))>0))
     ofs%=xofs%(f%)*n%/1000
     y%=hh%+f%:BB%=Int(f%/4)
     b1X%=HW%-F%-bb%-ofs%:b2x%=HW%-F%-ofs%
     b3x%=HW%-F%-ofs%+2*f%:b4x%=b1x%+(2*bb%+2*f%)
     Line 0,y%,b1x%,y%,,COL%(2):Line b1x%,y%,b2x%,y%,,bc%
     Line b2x%,y%,b3x%,y%,,0
     Line b3x%,y%,b4x%,y%,,bc%:Line b4x%,y%,SW%,y%,,COL%(2)
   Next
   Inc dist%
 Next
 dist%=dist% And 255
 t%=(Timer-t%)
 t%=t%/1000
 Print @(0,0)1000/t%
Loop
'------------------------------
Sub on_break
 MODE 1: Option Break 3
 End
End Sub
colors:
'--Colorscheme accordung to matherp
Data RGB(BLUE),RGB(GREEN),RGB(CYAN),RGB(RED),RGB(MAGENTA),RGB(YELLOW),RGB(WHITE)
Data RGB(MYRTLE),RGB(COBALT),RGB(MIDGREEN),RGB(CERULEAN),RGB(RUST),RGB(FUCHSIA)
Data RGB(BROWN),RGB(LILAC)                                                                    

with CPUSPEED 378000 i get a result of 22-23 fps. To speed things up, one can half the Resolution of the street (as originally using the Box Command with the height of 2 and just draw every 2nd Line)
please try it and give me a Feedback
Cheers
Mart!n
Edited 2022-10-12 17:10 by Martin H.