![]() |
Forum Index : Microcontroller and PC projects : PicoMiteVGA DEMO
![]() ![]() |
|||||
Author | Message | ||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 510 |
OK! No restrictions, just fun! I didn’t invent this code myself, I just adapted the ready-made one to the syntax of MMBASIC and slightly modified it for dynamics. |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 510 |
Galaxian ![]() ![]() MODE 2 Text 160,0,"000000","CT",7,1 For R=0 To 2: Proc(16*R,238,6,1):Next Proc(140,230,12,7):Proc(150,192,2,7):Proc(154,50,17,6) For R=1 To 8 Proc(32*R,150,9,8):Proc(32*R,120,10,9):Proc(32*R,90,8,14) Next End Sub Proc(X0,Y0,Q,C) Color Map(C) A=1:W=X0:U=W+2*Q For X=1 To (Q+2)/2 Y=Y0:I=1 Do If I And A Then Box W,Y,2,2: Box U,Y,2,2 Inc Y,-2:Inc I,I Loop Until I>A A=A*(Q+1-X)/X Inc W,2:Inc U,-2 Next End Sub |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5166 |
Few more lines and you have a game... Great !! Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1264 |
I've found a little listing in Facebook and converted it to run in MMBasic Here the PicomiteVGA Version mode 2 ' 320x240 Const SCREEN_HEIGHT = 480 Const Q = 3 Dim XP(Q), YP(Q), ZP(Q) As Integer Dim MX(26,26), MY(26,26) As Integer cls ' Define charge points XP(1) = 11 : YP(1) = 6 : ZP(1) = 175 XP(2) = 17 : YP(2) = 18 : ZP(2) = -150 XP(3) = 7 : YP(3) = 19 : ZP(3) = 40 ' Projection constants Dim XS , YS As Integer XS = 25: YS = 200 ' Fill matrix with transformed coordinates For X = 0 To 25 For Y = 0 To 25 UPJE = 0 For W = 1 To Q D = Sqr((X - XP(W))^2 + (Y - YP(W))^2) inc UPJE, ZP(W) * Exp(-D / 2) Next ' Fix grid orientation (X then Y) MX(X,Y) = XS + 11*X + 11*Y ' Flip Y-axis (to match PC-BASIC lower-left origin) MY(X,Y) = SCREEN_HEIGHT - (UPJE + YS - X*4 + Y*4) ' Optional: show control points Pixel MX(X,Y)/2, MY(X,Y)/2, rgb(0,255,255) Next Next ' Draw the surface E = 0 For Y = 25 To 1 Step -1 For X = 0 To 24 X1 = MX(X,Y)/2: Y1 = MY(X,Y)/2 X2 = MX(X+1,Y)/2: Y2 = MY(X+1,Y)/2 X3 = MX(X+1,Y-1)/2: Y3 = MY(X+1,Y-1)/2 X4 = MX(X,Y-1)/2: Y4 = MY(X,Y-1)/2 ' Fill with alternating pattern If (E Mod 2 = 0) Then K = RGB(0,0,255) else K = RGB(0,128,255) endif TRIANGLE X1, Y1, X2, Y2,X3, Y3 ,k,k TRIANGLE X1, Y1, X4, Y4,X3, Y3 ,k,k Line X1,Y1 ,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K XPc = (X1 + X3) \ 2 YPc = (Y1 + Y3) \ 2 ' Highlight border K = RGB(255,255,255) Line X1,Y1,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K inc E Next Next ![]() Since the program was designed for 640x360, I divided all screen coordinates by 2. Not elegant but it works ![]() Cheers Martin Edited 2025-08-03 15:31 by Martin H. 'no comment |
||||
Amnesie Guru ![]() Joined: 30/06/2020 Location: GermanyPosts: 690 |
Martin, this is funny, I saw the same exact post in this Facebook-Group, too and also wondered if it can be translated to MMBASIC ![]() ![]() Greetings Daniel |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1264 |
Good Morning Daniel, Sometimes you do strange things with your first coffee on a Sunday morning ![]() I have now (after coffee) also noticed that the 4 “Line” commands after the “Triangle” commands can be omitted Edited 2025-08-03 17:09 by Martin H. 'no comment |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10371 |
Looks even better in 1280x720 mode 3 (640x360) ![]() MODE 3 ' 640x360 Const SCREEN_HEIGHT = 360 Const Q = 3 Dim XP(Q), YP(Q), ZP(Q) As Integer Dim MX(26,26), MY(26,26) As Integer CLS ' Define charge points XP(1) = 11 : YP(1) = 6 : ZP(1) = 175 XP(2) = 17 : YP(2) = 18 : ZP(2) = -150 XP(3) = 7 : YP(3) = 19 : ZP(3) = 40 ' Projection constants Dim XS , YS As Integer XS = 25: YS = 200 ' Fill matrix with transformed coordinates For X = 0 To 25 For Y = 0 To 25 UPJE = 0 For W = 1 To Q D = Sqr((X - XP(W))^2 + (Y - YP(W))^2) Inc UPJE, ZP(W) * Exp(-D / 2) Next ' Fix grid orientation (X then Y) MX(X,Y) = XS + 11*X + 11*Y ' Flip Y-axis (to match PC-BASIC lower-left origin) MY(X,Y) = SCREEN_HEIGHT - (UPJE + YS - X*4 + Y*4) ' Optional: show control points Pixel MX(X,Y), MY(X,Y), RGB(0,255,255) Next Next ' Draw the surface E = 0 For Y = 25 To 1 Step -1 For X = 0 To 24 X1 = MX(X,Y): Y1 = MY(X,Y) X2 = MX(X+1,Y): Y2 = MY(X+1,Y) X3 = MX(X+1,Y-1): Y3 = MY(X+1,Y-1) X4 = MX(X,Y-1): Y4 = MY(X,Y-1) ' Fill with alternating pattern If (E Mod 2 = 0) Then K = RGB(0,0,255) Else K = RGB(0,128,255) EndIf Triangle X1, Y1, X2, Y2,X3, Y3 ,k,k Triangle X1, Y1, X4, Y4,X3, Y3 ,k,k XPc = (X1 + X3) YPc = (Y1 + Y3) ' Highlight border K = RGB(255,255,255) Line X1,Y1,X2,Y2,, K Line X2,Y2 ,X3,Y3,, K Line X3,Y3,X4,Y4,, K Line X4,Y4,X1,Y1,, K Inc E Next Next Save image "layer" |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1264 |
Thank you Peter, This certainly looks better ![]() Have a good Sunday Cheers Martin 'no comment |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 510 |
Mandelbrot MODE 2 / MODE 3 ![]() MODE 2 Dim CM(3)=(RGB(Blue),RGB(Cyan),RGB(Yellow),RGB(Magenta)) Dim R(15)=(0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5) L=Log(2) S=0:For U=-1.725 To -1.225 Step .5/MM.HRES D=0:For V=-0.2 To .0000002 Step .4/MM.VRES Color CM(Int((fM(U,V)+R(S Mod 4+4*(D Mod 4)))/16)Mod 4) Pixel S,D:Pixel S,MM.VRES-D Inc D: Next V Inc S: Next U Do :Loop While Inkey$="" Function fM(U,V) Local X,Y,A,B,C Do Y=2*X*Y+V X=A-B+U A=X*X B=Y*Y Inc C Loop Until C>=50 Or A+B>16 If C=50 Then fM=0 Else fM=5*(C+1-Log((Log(A+B)/2)/L)/L) End Function |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2614 |
nice. can the colours be mapped and rotated? |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 510 |
Cylinder on a plane by bazzargh 10.07.2025 # Weekend MMBasic Entertainment # Procedural graphics ![]() Q=.755/8 Z=.636363/8 C=.527225 For X=0 To 1280 Step 2 For Y=0 To 1000 Step 2 V=(X+4*Y)\500 W=(X-Y+450)\200 F=1 If (X>70 And X<430 And Y>300 And Y<900)Or((X-250)*(X-250)/8+(Y-300)*(Y-300)<4000) Then F=1-X/250:F=F*(F>0) EndIf If (X-250)*(X-250)/8+(Y-900)*(Y-900)<4000 Then F=0 If F=1 And V>1 And V<7 And W>0 And W<6 Then F=.5+.25*((W+V)Mod 2)-.25*(X>250 And X-3*Y>-900 And X-8*Y<-1600) EndIf I=Q*X+Z*Y+C I=I-Int(I) If Int(F)-(F-Int(F)>I) And 1 Then Pixel X\2,500-Y\2 Next :Next |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1264 |
Hi javavi I have no idea how the program does it, but it's brilliant ![]() 'no comment |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1140 |
Here's a slight change to the cylinder on checker-board so it fits on a 320 pixel wide screen, and possibly runs slightly faster: Q=.755/8 Z=.636363/8 C=.527225 For X=0 To 1280 Step 4 For Y=0 To 1000 Step 4 V=(X+4*Y)\500 W=(X-Y+450)\200 F=1 X2=X-250 X3=X2*X2/8 If (X>70 And X<430 And Y>300 And Y<900)Or(X3+(Y-300)*(Y-300)<4000) Then F=1-X/250:F=F*(F>0) EndIf If X3+(Y-900)*(Y-900)<4000 Then F=0 If F=1 And V>1 And V<7 And W>0 And W<6 Then F=.5+.25*((W+V)Mod 2)-.25*(X>250 And X-3*Y>-900 And X-8*Y<-1600) EndIf I=Q*X+Z*Y+C I=I-Int(I) If Int(F)-(F-Int(F)>I) And 1 Then Pixel X\4,250-Y\4 Next Next Visit Vegipete's *Mite Library for cool programs. |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2614 |
looks fine ili9341 |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1264 |
Found on Facebook sh=MM.VRes : sw=MM.HRes xc = sw / 2 : yc = sh / 2 rad = sh / 40 For j = 1 To 9999 CLS a = Rnd(1) If a > 0.86 Then a = a * 0.86 If a < 0.1 Then a = a + 0.1 If a = 0.5 Then a = 0.4999 b = 0.9998 Print @(5,5) a p = 15000 c = 2 - 2 * a x = 0 y = 12.17 w = a * x + c * x * x / (1 + x * x) For h = 0 To p If h > 150 Then ct = 1.1 * Sqr(x * x + y * y) / rad cr = 83 * ct : If cr >255 Then cr = cr/5 cg = 177 * ct : If cg >255 Then cg = cg/5 cb = 186 * ct : If Cb >255 Then cb = cb/5 Pixel x * rad + xc, y * rad + yc, RGB(cr, cg, cb) z = x x = b * y + w u = x * x w = a * x + c * u / (1 + u) y = w - z End If Next h Pause 300 Next j Edited 2025-08-13 17:44 by Martin H. 'no comment |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2669 |
After a while this happened:- [23] Pixel x * rad + xc, y * rad + yc, RGB(cr, cg, cb) Error : 256 is invalid (valid is 0 to 255) So added rollovers to the colours. sh=MM.VRES : sw=MM.HRES xc = sw / 2 : yc = sh / 2 rad = sh / 40 For j = 1 To 9999 CLS a = Rnd(1) If a > 0.86 Then a = a * 0.86 If a < 0.1 Then a = a + 0.1 If a = 0.5 Then a = 0.4999 b = 0.9998 Print @(5,5) a p = 15000 c = 2 - 2 * a x = 0 y = 12.17 w = a * x + c * x * x / (1 + x * x) For h = 0 To p If h > 150 Then ct = 1.1 * Sqr(x * x + y * y) / rad cr = 83 * ct : If cr >255 Then cr = cr/5 cg = 177 * ct : If cg >255 Then cg = cg/5 cb = 186 * ct : If Cb >255 Then cb = cb/5 cr = cr And 255 cg = cg And 255 cb = cb And 255 Pixel x * rad + xc, y * rad + yc, RGB(cr, cg, cb) z = x x = b * y + w u = x * x w = a * x + c * u / (1 + u) y = w - z End If Next h Pause 300 Next j Edited 2025-08-13 18:24 by phil99 |
||||
javavi![]() Guru ![]() Joined: 01/10/2023 Location: UkrainePosts: 510 |
Waves 640х480 ![]() MODE 1 Dim float t,d,h Dim integer x,y,x1,y1,z FRAMEBUFFER CREATE FRAMEBUFFER WRITE F Do CLS For y1=0 To 24 For x1=0 To 24 x=12*(24-x1)+12*y1+30 y=-6*(24-x1)+6*y1+240 h=60*Sin((x1-y1)/4+t) 'h=60*Sin((x1+y1)/4+t) 'h=60*Sin(x1/2+t)+60*Cos(y1/2+t) Circle x,y-h,7,,,0,1 Next Next FRAMEBUFFER COPY F,N,B Inc t,.2 Loop |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2614 |
nice demo! works as is hdmi. bit harder to work on ili9341 display, still working on it |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |