Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:01 12 Nov 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMiteVGA DEMO

     Page 14 of 14    
Author Message
Bleep

Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 874
Posted: 07:03pm 10 Nov 2026
Copy link to clipboard 
Print this post

Here is a CSub version.
This gets it down to 35mS, to be honest you might as well stick with your original and replace the 'Sprite' For 'Blit' which gives 45mS all in standard Basic.
Option Default None
Option Explicit

MODE 2 'MODE 7 for MMB4W
Randomize (Timer)
CLS
Dim Integer tt,f,fire(160,20),fire2(160,20),ranr(2048)
Dim Integer rp,y,y1,yy,xx,ff(160),aa(160),bb(160)
For f=0 To 2047:ranr(f)=Int(Rnd*4):Next
'Prepare source
Dither 0,RGB(RED):Box 8,0,8,2,,RGB(RED)
Dither 8,RGB(255,64,0):Box 16,0,8,2,,RGB(255,64,0)
Dither 16,RGB(255,128,0):Box 24,0,8,2,,RGB(255,128,0)
Dither 24,RGB(yellow):Box 32,0,8,2,,RGB(yellow)
Dither 32,RGB(White):Box 40,0,2,2,,RGB(White)
For f=0 To 20:Blit read f+1,f*2,0,2,2:Next
'------
CLS 0
Box 0,238,320,2,,RGB(white)
For f=0 To 160:fire(f,20)=20:Next
Do
tt=Timer
rp=Int(Rnd*2048)
For y=0 To 19
 y1=y+1
 yy=198+(y<<1)
 xx=0
 animate
 For f=0 To 159
  If ff(f) Then Blit Write ff(f),aa(f),bb(f),0
 Next
Next
Print @(0,0);Timer-tt;"     "
'Pause 20' for MMB4W
Loop
'------
/*
' --- mmb2csub: animate replaced by a CSUB; original follows
Sub animate
Local Integer f,r,x,xr,fr
 For x=0 To 159
   r=ranr(rp)
   xr=(x+(r)) Mod 160
   fr=fire(xr,y1)-r:If fr <0 Then fr=0
   ff(x)=0:If fire2(x,y)<> fr Then  fire(x,y)=fr:fire2(x,y)=fr:ff(x)=fr+1:aa(x)=xx:bb(x)=yy
   Inc xx,2:Inc rp: If rp>2047 Then rp=0
 Next
End Sub
*/
'------
Sub dither x As Integer,col As Integer
 Pixel x+2,0,col:Pixel x+4,0,col:Pixel x+6,0,col
 Pixel x+7,0,col:Pixel x+5,1,col:Pixel x+7,1,col
End Sub

' --- mmb2csub: generated code for animate
' The wrapper keeps the original name, so call sites are unchanged.
Sub animate
 Local Integer __gt(10)
 __gt(0) = Peek(VARADDR aa%())
 __gt(1) = Peek(VARADDR bb%())
 __gt(2) = Peek(VARADDR ff%())
 __gt(3) = Peek(VARADDR fire%())
 __gt(4) = Peek(VARADDR fire2%())
 __gt(5) = Peek(VARADDR ranr%())
 __gt(6) = Peek(VARADDR rp%)
 __gt(7) = Peek(VARADDR xx%)
 __gt(8) = Peek(VARADDR y%)
 __gt(9) = Peek(VARADDR y1%)
 __gt(10) = Peek(VARADDR yy%)
 animateK __gt()
End Sub

CSUB animateK INTEGER
00000000
'animateK
4646B5F0 465746DE 4D7E2200 682BB5C0 69DBB08A 6FDB6801 601A605A 69DA682B
6FD46B03 60E1469A 61216881 61616901 61A16981 61E16A01 62636A81 62216B83
469B62A3 62E36C03 6C834698 63239307 6D036826 63639308 D1002E00 6863E0BB
23009309 92002200 46539301 46C24F65 E0499303 18EB9D04 9B059304 9B0400DD
C303195B 681B4653 009B4698 015B4443 00DB4443 197618F6 2501C603 46632600
41711940 465BC303 9B06CB03 191B68DB 9B08C303 6853CB03 C303191B 21002002
CB0C465B 414B1812 20014659 2100C10C CB0C9B03 414B1812 DC042B00 2180D105
428A0109 2200D301 99032300 C10C2400 9A019900 18C92301 683B4162 92019100
6FDC69DB D05929A0 330168A3 059B60A3 683BD103 6A9B69DB 683B4798 69DA9903
6FD36809 6A1B00C9 CB18185B 99019800 18C00026 24A44161 59140064 22A0001D
47A02300 9907683B 680969DB 008B6FDA 9206185B 6994015B 00DB185B 00C018E3
CB03181B 002B9404 1AC00034 320C41A1 DA012900 21002000 25009B00 689300DC
469C2600 466344A4 4653C360 9D00681B 009B4698 015B4443 69164443 950500DB
46A818F5 464544A0 4285682D E761D000 686D4645 D000428D E77FE75C 2B009B01
2000D1A2 9B092100 B00A6063 46BBBCE0 46A846B2 2780BDF0 6B13017F 47980038
6020682B 6FDB69DB 682B605E 6FDC69DB 93096863 D80042BB 6066E733 69DB682B
E72C6FDC E000ED08
End CSUB

Edited 2026-11-11 05:54 by Bleep
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1578
Posted: 12:22pm 11 Nov 2026
Copy link to clipboard 
Print this post

Thank you for your support Kevin...
Up until now, I've equated Sprite and Blit in my mind
Exchanging the "SPRITE" with "BLIT" speed up from ~80 mS to ~50mS
Using your CSUB Version speeds up  ~50mS to ~29mS = 34FpS
So you can really call it an animation
'no comment
 
     Page 14 of 14    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026