Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:40 28 Nov 2025 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 : PicoMite V6.01.00 release candidates

     Page 12 of 18    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 01:15pm 10 Nov 2025
Copy link to clipboard 
Print this post

are you using rgb(red) or just red? If the latter USE OPTION EXPLICIT!!!
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 694
Posted: 01:54pm 10 Nov 2025
Copy link to clipboard 
Print this post

Ok thanks.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5485
Posted: 07:59am 12 Nov 2025
Copy link to clipboard 
Print this post

Hi Peter,

I know it has been closing day for new features for 6.01.00 for a while, but since you have not closed it yet, I want to propose a change (in all platforms that have flash slots and VGA/HDMI).

What about the option to format a flash slot as a video plane (i.e. RGB121 320x240, or RGB222 320x240). And allow the BLIT command to copy data from it as it if where video data (tiles/sprites). This would be read only planes, that can only be written to with FLASH LOAD IMAGE "xxx.bmp".

You can achieve similar as in Petscii where we store non-compressed, or compressed video data in a flash slot. But that method is quite elaborate. It was needed for Petscii since there where so many sprites and tiles.

LeoNicolas is now looking at porting KnighMare to PicoVGA. The graphic elements in that game are (unless I misunderstood) in a single plane, loaded from a PNG file. CMM2 and MMB4W have so much RAM it is simple have another plane.
For Pico, converting the PNG file to a BMP in RGB121 and re-formatting to fit in one or more 320x240 BMP's, seems easy on a PC Put on SD card, then it is simple to load it in a flash slot, and start copying data with BLIT (in case BLIT supports this).

A 100kbyte flash slot could hold 2 planes 320x240 in RGB121, or one in RGB222. But maybe it is better to define the geometry to fill the 100kbyte (320x600 ? 256x720 ?)

When you put
REM Video bitmap data RGB121 320x600
END


At the start of that flash slot, a FLASH LIST will also show what it is used for, and accidental FLASH RUN x will not crash the system.

Just an idea. It feels much simpler than the Petscii way (which takes hours manual work, prone to making mistakes).

Volhout
Edited 2025-11-12 18:10 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 721
Posted: 02:17pm 12 Nov 2025
Copy link to clipboard 
Print this post

Hi Peter,

I have possibly found a bug.

IR doesn't work anymore.

Observation: If I press on my (working two) remote controlls, the code is recognized, but only one single time, other key presses aren't. If I do a power off on the picoMiteHDMI, then the whole process repeats: only one single time the remote code is recognized, I have to reboot again. There isn't an error or so, but as said it only works for exactly one single time. On previous versions (but I don't know in which this "bug" (?) is introduced) everything worked.

P.S.: I just tested a (previously working) second picoMiteHDMI, but with the USB firmware, exactly the same behavior! Ir receive just works for one single time.




Greetings
Daniel
Edited 2025-11-13 00:26 by Amnesie
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 07:13pm 12 Nov 2025
Copy link to clipboard 
Print this post

V6.01.00RC12

PicoMiteRP2350VGAV6.01.00RC12.zip

I know this is supposed to be a release candidate thread but....
My daughter says my grandson want to have a go at coding so I thought turtle graphics would be a good start. The CMM2 has an implementation but it is fairly primitive so Claude and I rolled our sleeves up.

This release contains a very comprehensive turtle graphics implementation for all versions except the WebMite RP2040 and WebMite RP2350.
The supported commands are:
Movement Commands
FORWARD distance        (FD)  - Move forward by distance pixels
BACK distance          (BK)  - Move backward by distance pixels
LEFT [angle]             (LT)  - Turn left by angle degrees, 90 degrees if not specified
RIGHT [angle]            (RT)  - Turn right by angle degrees, 90 degrees if not

Position Commands
SET XY x, y                    - Move to absolute position (x,y)
SET X x                       - Set X coordinate, keep Y
SET Y y                       - Set Y coordinate, keep X
SET HEADING angle       (SETH) - Set absolute heading (0=right, 90=up)
HOME                         - Return to center (160,120) heading 0

Pen Control Commands
PEN UP                  (PU)  - Lift pen (stop drawing)
PEN DOWN                (PD)  - Lower pen (start drawing)
PEN COLOUR color         (PC)  - Set pen color
PEN WIDTH width         (PW)  - Set pen line width

Arc and Curve Commands
ARC radius angle             - Draw arc with given radius and angle
ARCLEFT radius,angle  (ARCL) - Draw arc turning left
ARCRIGHT radius,angle (ARCR) - Draw arc turning right
BEZIER cp1 , cp1angle, cp2, cp2angle, end, endangle          - Draw Bezier curve with control points

Basic Shape Commands
CIRCLE radius               - Draw circle at current position
DOT size                   - Draw filled dot (default size=5)
FCIRCLE radius             - Draw filled circle
FRECTANGLE width,height (FRECT) - Draw filled rectangle
WEDGE radius start end     - Draw filled wedge/pie slice

Fill Commands
FILL COLOUR color        (FC)  - Set fill color and enable filling
FILL PATTERN pattern    (FP)  - Set fill pattern (0-7)
NO FILL                      - Disable filling
FILL                        - Flood fill at current position
BEGIN FILL             (BF)  - Start recording polygon for fill
END FILL               (EF)  - End recording and fill polygon

Cursor Commands
SHOW TURTLE            (ST)  - Show turtle cursor
HIDE TURTLE            (HT)  - Hide turtle cursor
CURSOR SIZE size       (CS)  - Set cursor size
CURSOR COLOUR color     (CC)  - Set cursor color
STAMP                        - Draw a turtle at the current x,y position

State Management Commands
RESET [show]                 - clear screen and reset everything, show the turtle if show = 1
PUSH                        - Save current position and heading to stack
POP                         - Restore position and heading from stack

The code includes the ability to fill circles,rectangles and polygons with a textured fill. Run it in mode 2 on a RP2040 VGA system or mode 3 on a RP2350 VGA or HDMI.

Fill Patterns
0: Solid fill
1: Checkerboard
2: Vertical lines
3: Horizontal lines
4: Diagonal cross
5: Diagonal stripes
6: Crosshatch
7: Fine diagonal
8: Dense checkerboard
9: Diagonal right medium
10: Diagonal left medium
11: Vertical lines medium
12: Horizontal lines medium
13: Large checkerboard
14: Dotted vertical
15: Horizontal stripes tight
16: Grid
17: Weave pattern
18: Diamond
19: Gradient diagonal
20: Gradient diagonal reverse
21: Border/frame
22: Vertical split
23: Woven
24: Sparse dots
25: Diagonal very fine
26: Arrow up
27: Dense dots
28: Chevron
29: Diamond hollow
30: Circle
31: Circle filled

The best way to see what the code can do is to run my test harness below.

RC12 also includes a new driver for the PICOMITE RP2350.
VGA222 and VGA222_320.
These are enabled with:
OPTION LCDPANEL VGA222/VGA222_320, hsyncpin, bluelpin

This checks for availability of
hysyncpin and hysyncpin+1 (vsync)
bluelpin - bluelpin+5 (blue_l, blue_h, green_l, green_h, red_l, red_h
assuming these are all free it sets up to run VGA222 output on the pins specified in either 640x480 (VGA222) or 320x240 (VGA222_320)
To connect the data pins to the VGA connector use 390 and 820 ohm resistors from the outputs as per the green channel in the manual ( page 29)

RGB222 gives a much nicer colour rendition than the RGB121 available on the VGA version. Note, there are no modes. The 640x480 and 320x240 are different drivers and use different amounts of memory (much more in the case of 640x480). To generate the VGA output I use PIO0 and PIO1 leaving PIO2 available (unless you also use the I2S audio driver.

I've tested running Petscii robots on the 320x240 driver and it runs superbly

To support the new driver, the mode parameter in LOAD DITHERED and LOAD JPG is changed:
DITHER_FS_RGB121 0      
DITHER_FS_RGB222 1      
DITHER_FS_RGB332 2      
DITHER_ATKINSON_RGB121 4
DITHER_ATKINSON_RGB222 5
DITHER_ATKINSON_RGB332 6

i.e. bit 2 specifies the dithering type and bits 0 and 1 specify the resolution

' ============================================================================
' TURTLE GRAPHICS TEST SUITE FOR MMBASIC
' ============================================================================

Option EXPLICIT
Option DEFAULT INTEGER

Dim test_number As INTEGER = 0
Dim passed As INTEGER = 0
Dim failed As INTEGER = 0

' ============================================================================
' MAIN TEST MENU
' ============================================================================
Sub TestMenu()
 Local choice$

 Do
   CLS
   Print "TURTLE GRAPHICS TEST SUITE"
   Print "=========================="
   Print
   Print "1.  Basic Movement Tests"
   Print "2.  Pen Control Tests"
   Print "3.  Position Tests"
   Print "4.  Shape Tests (Circles)"
   Print "5.  Shape Tests (Rectangles)"
   Print "6.  Arc Tests"
   Print "7.  Fill Pattern Tests"
   Print "8.  Polygon Fill Tests"
   Print "9.  Stack (PUSH/POP) Tests"
   Print "10. Cursor Tests"
   Print "11. Complex Drawing Tests"
   Print "12. Stress Tests"
   Print "13. Run All Tests"
   Print "0.  Exit"
   Print
   Input "Select test: ", choice$

   Select Case Val(choice$)
     Case 1: Test_BasicMovement()
     Case 2: Test_PenControl()
     Case 3: Test_Position()
     Case 4: Test_Circles()
     Case 5: Test_Rectangles()
     Case 6: Test_Arcs()
     Case 7: Test_FillPatterns()
     Case 8: Test_PolygonFill()
     Case 9: Test_Stack()
     Case 10: Test_Cursor()
     Case 11: Test_ComplexDrawing()
     Case 12: Test_Stress()
     Case 13: RunAllTests()
     Case 0: Exit Sub
   End Select

   Print
   Print "Press any key to continue..."
   Do While Inkey$ = "": Loop
 Loop
End Sub

' ============================================================================
' TEST 1: BASIC MOVEMENT
' ============================================================================
Sub Test_BasicMovement()
 Local i As INTEGER

 StartTest("Basic Movement Tests")

 ' Test 1.1: Square using FORWARD and RIGHT
 TestCase("Square with FD and RT")
 Turtle RESET
 Turtle HIDETURTLE
 For i = 1 To 4
   Turtle FORWARD 100
   Turtle RIGHT 90
 Next i
 WaitForKey()

 ' Test 1.2: Square using short commands
 TestCase("Square with short commands (FD, RT)")
 Turtle RESET
 Turtle HT
 For i = 1 To 4
   Turtle FD 100
   Turtle RT 90
 Next i
 WaitForKey()

 ' Test 1.3: Triangle using LEFT
 TestCase("Triangle with FD and LT")
 Turtle RESET
 Turtle HT
 For i = 1 To 3
   Turtle FD 100
   Turtle LT 120
 Next i
 WaitForKey()

 ' Test 1.4: Star using large angles
 TestCase("Star pattern")
 Turtle RESET
 Turtle HT
 For i = 1 To 5
   Turtle FD 100
   Turtle RT 144
 Next i
 WaitForKey()

 ' Test 1.5: BACK command
 TestCase("Forward and Back")
 Turtle RESET
 Turtle HT
 Turtle FD 100
 Pause 500
 Turtle BACK 100
 WaitForKey()

 ' Test 1.6: Spiral
 TestCase("Spiral using increasing distances")
 Turtle RESET
 Turtle HT
 For i = 1 To 50
   Turtle FD i * 2
   Turtle RT 15
 Next i
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 2: PEN CONTROL
' ============================================================================
Sub Test_PenControl()
 Local i As INTEGER
 Local w As INTEGER
 Local colors(6) As INTEGER

 StartTest("Pen Control Tests")

 ' Test 2.1: PENUP and PENDOWN
 TestCase("Dashed line with PENUP/PENDOWN")
 Turtle RESET
 Turtle HT
 For i = 1 To 5
   Turtle PD
   Turtle FD 20
   Turtle PU
   Turtle FD 20
 Next i
 WaitForKey()

 ' Test 2.2: PENCOLOR
 TestCase("Rainbow colors")
 Turtle RESET
 Turtle HT
 colors(0) = RGB(RED)
 colors(1) = RGB(255,127,0)
 colors(2) = RGB(YELLOW)
 colors(3) = RGB(GREEN)
 colors(4) = RGB(BLUE)
 colors(5) = RGB(75,0,130)
 colors(6) = RGB(148,0,211)
 For i = 0 To 6
   Turtle PENCOLOR colors(i)
   Turtle FD 40
   Turtle RT 51
 Next i
 WaitForKey()

 ' Test 2.3: PENWIDTH
 TestCase("Varying line widths")
 Turtle RESET
 Turtle HT
 For w = 1 To 5
   Turtle PENWIDTH w
   Turtle FD 50
   Turtle RT 90
 Next w
 WaitForKey()

 ' Test 2.4: Pen color and width combination
 TestCase("Colored thick spiral")
 Turtle RESET
 Turtle HT
 Turtle PENWIDTH 3
 For i = 1 To 36
   Turtle PENCOLOR RGB(255, (i*7) Mod 256, 255-((i*7) Mod 256))
   Turtle FD i * 2
   Turtle RT 10
 Next i
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 3: POSITION CONTROL
' ============================================================================
Sub Test_Position()
 Local x As INTEGER
 Local angle As INTEGER
 Local i As INTEGER

 StartTest("Position Control Tests")

 ' Test 3.1: SETXY
 TestCase("Connect four corners with SETXY")
 Turtle RESET
 Turtle HT
 Turtle PU
 Turtle SETXY 50, 50
 Turtle PD
 Turtle SETXY 270, 50
 Turtle SETXY 270, 190
 Turtle SETXY 50, 190
 Turtle SETXY 50, 50
 WaitForKey()

 ' Test 3.2: SETX and SETY
 TestCase("Grid pattern with SETX/SETY")
 Turtle RESET
 Turtle HT
 Turtle PU
 Turtle setxy 40,40
 Turtle pd
 For x = 40 To 280 Step 40
   Turtle SETX x
   Turtle SETY 40
   Turtle PD
   Turtle SETY 200
   Turtle PU
 Next x
 WaitForKey()

 ' Test 3.3: SETHEADING
 TestCase("Radial lines with SETHEADING")
 Turtle RESET
 Turtle HT
 For angle = 0 To 360 Step 30
   Turtle HOME
   Turtle SETHEADING angle
   Turtle FD 80
 Next angle
 WaitForKey()

 ' Test 3.4: HOME command
 TestCase("Random walk then HOME")
 Turtle RESET
 Turtle HT
 For i = 1 To 50
   Turtle FD 8
   Turtle RT(Rnd() * 90 - 45)
 Next i
 Pause 1000
 Turtle PU
 Turtle HOME
 Turtle PD
 Turtle PENCOLOR RGB(RED)
 Turtle CIRCLE 5
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 4: CIRCLE TESTS
' ============================================================================
Sub Test_Circles()
 Local r As INTEGER
 Local x As INTEGER
 Local y As INTEGER
 Local i As INTEGER

 StartTest("Circle Tests")

 ' Test 4.1: Basic circles
 TestCase("Concentric circles")
 Turtle RESET
 Turtle HT
 For r = 10 To 100 Step 10
   Turtle HOME
   Turtle CIRCLE r
 Next r
 WaitForKey()

 ' Test 4.2: Circle at different positions
 TestCase("Circle grid")
 Turtle RESET
 Turtle HT
 For x = 60 To 260 Step 50
   For y = 60 To 180 Step 40
     Turtle PU
     Turtle SETXY x, y
     Turtle PD
     Turtle CIRCLE 20
   Next y
 Next x
 WaitForKey()

 ' Test 4.3: DOT command
 TestCase("Dots of varying sizes")
 Turtle RESET
 Turtle HT
 For i = 1 To 10
   Turtle PU
   Turtle SETXY 30 + i * 25, 120
   Turtle PD
   Turtle DOT i * 3
 Next i
 WaitForKey()

 ' Test 4.4: FCIRCLE (filled circles)
 TestCase("Filled circles - solid")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(255, 100, 100)
 Turtle PU
 Turtle SETXY 100, 120
 Turtle FCIRCLE 40
 Turtle SETXY 220, 120
 Turtle FILLCOLOR RGB(100, 100, 255)
 Turtle FCIRCLE 40
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 5: RECTANGLE TESTS
' ============================================================================
Sub Test_Rectangles()
 Local angle As INTEGER

 StartTest("Rectangle Tests")

 ' Test 5.1: FRECT (axis-aligned filled rectangles)
 TestCase("Axis-aligned filled rectangles")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(RED)
 Turtle PU
 Turtle SETXY 80, 120
 Turtle FRECT 60, 40
 Turtle SETXY 160, 120
 Turtle FILLCOLOR RGB(GREEN)
 Turtle FRECT 60, 40
 Turtle SETXY 240, 120
 Turtle FILLCOLOR RGB(BLUE)
 Turtle FRECT 60, 40
 WaitForKey()

 ' Test 5.2: ARECT (heading-aligned rectangles)
 TestCase("Rotated rectangles with ARECT")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(255, 200, 0)
 For angle = 0 To 360 Step 45
   Turtle HOME
   Turtle SETHEADING angle
   Turtle ARECT 80, 40
 Next angle
 WaitForKey()

 ' Test 5.3: ARECT vs FRECT comparison
 TestCase("ARECT vs FRECT at 45 degrees")
 Turtle RESET
 Turtle HT
 Turtle PU
 Turtle SETXY 100, 120
 Turtle SETHEADING 45
 Turtle FILLCOLOR RGB(255, 0, 0)
 Turtle ARECT 80, 50
 Turtle SETXY 220, 120
 Turtle FILLCOLOR RGB(0, 0, 255)
 Turtle FRECT 80, 50
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 6: ARC TESTS
' ============================================================================
Sub Test_Arcs()
 Local i As INTEGER
 Local x As INTEGER
 Local angles(3) As INTEGER
 Local colors(3) As INTEGER
 Local start_angle As INTEGER

 StartTest("Arc Tests")

 ' Test 6.1: Basic arc
 TestCase("Simple arc - semicircle")
 Turtle RESET
 Turtle HT
 Turtle ARC 50, 180
 WaitForKey()

 ' Test 6.2: Flower pattern with arcs
 TestCase("Flower with arc petals")
 Turtle RESET
 Turtle HT
 For i = 1 To 30
   Turtle ARC 40, 60
   Turtle RT 120
   Turtle ARC 40, 60
   Turtle RT 195
 Next i
 WaitForKey()

 ' Test 6.3: ARCL and ARCR
 TestCase("ARCL vs ARCR")
 Turtle RESET
 Turtle HT
 Turtle PU
 Turtle SETXY 100, 120
 Turtle PD
 Turtle PENCOLOR RGB(RED)
 Turtle ARCL 50, 180
 Turtle PU
 Turtle SETXY 220, 120
 Turtle PD
 Turtle PENCOLOR RGB(BLUE)
 Turtle ARCR 50, 180
 WaitForKey()

 ' Test 6.4: Spiral with arcs
 TestCase("Arc spiral")
 Turtle RESET
 Turtle HT
 For i = 1 To 20
   Turtle ARC(i * 3), 30
 Next i
 WaitForKey()

 ' Test 6.5: WEDGE (pie slice)
 TestCase("Pac-Man with WEDGE")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(255, 255, 0)
 Turtle WEDGE 60, 30, 330
 ' Add eye
 Turtle PU
 Turtle SETXY 175, 100
 Turtle FILLCOLOR RGB(0, 0, 0)
 Turtle FCIRCLE 5
 WaitForKey()

 ' Test 6.6: Pie chart
 TestCase("Simple pie chart")
 Turtle RESET
 Turtle HT
 angles(0) = 90
 angles(1) = 120
 angles(2) = 150
 angles(3) = 0
 colors(0) = RGB(255,0,0)
 colors(1) = RGB(0,255,0)
 colors(2) = RGB(0,0,255)
 colors(3) = RGB(255,255,0)
 start_angle = 0
 For i = 0 To 3
   Turtle HOME
   Turtle FILLCOLOR colors(i)
   Turtle WEDGE 70, start_angle,(start_angle + angles(i))
   start_angle = start_angle + angles(i)
 Next i
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 7: FILL PATTERN TESTS
' ============================================================================
Sub Test_FillPatterns()
 Local x As INTEGER
 Local y As INTEGER
 Local p As INTEGER
 Local i As INTEGER
 Local gradient_patterns(7) As INTEGER

 StartTest("Fill Pattern Tests")

 ' Test 7.1: All patterns showcase
 TestCase("Pattern showcase (0-15)")
 Turtle RESET
 Turtle HT
 For p = 0 To 15
   x = (p Mod 4) * 70 + 50
   y = (p \ 4) * 50 + 40
   Turtle PU
   Turtle SETXY x, y
   Turtle FILLPATTERN p
   Turtle FILLCOLOR RGB(200, 100, 50)
   Turtle FCIRCLE 25
 Next p
 WaitForKey()

 ' Test 7.2: More patterns
 TestCase("Pattern showcase (16-31)")
 Turtle RESET
 Turtle HT
 For p = 16 To 31
   x = ((p-16) Mod 4) * 70 + 50
   y = ((p-16) \ 4) * 50 + 40
   Turtle PU
   Turtle SETXY x, y
   Turtle FILLPATTERN p
   Turtle FILLCOLOR RGB(50, 100, 200)
   Turtle FCIRCLE 25
 Next p
 WaitForKey()

 ' Test 7.3: Patterns on rectangles
 TestCase("Patterns on rectangles")
 Turtle RESET
 Turtle HT
 For p = 0 To 7
   Turtle PU
   Turtle SETXY 40 + p * 35, 120
   Turtle FILLPATTERN p
   Turtle FILLCOLOR RGB(100, 200, 100)
   Turtle FRECT 30, 80
 Next p
 WaitForKey()

 ' Test 7.4: Gradient effect
 TestCase("Density gradient (sparse to dense)")
 Turtle RESET
 Turtle HT
 gradient_patterns(0) = 24
 gradient_patterns(1) = 14
 gradient_patterns(2) = 7
 gradient_patterns(3) = 1
 gradient_patterns(4) = 8
 gradient_patterns(5) = 11
 gradient_patterns(6) = 27
 gradient_patterns(7) = 0
 For i = 0 To 7
   Turtle PU
   Turtle SETXY 40 + i * 35, 120
   Turtle FILLPATTERN gradient_patterns(i)
   Turtle FILLCOLOR RGB(150, 150, 150)
   Turtle FCIRCLE 25
 Next i
 WaitForKey()

 ' Test 7.5: Pattern on rotated rectangle
 TestCase("Patterns on rotated rectangles")
 Local angle As INTEGER
 Turtle RESET
 Turtle HT
 Turtle FILLPATTERN 6
 Turtle FILLCOLOR RGB(255, 150, 0)
 For angle = 0 To 360 Step 45
   CLS
   Turtle HOME
   Turtle SETHEADING angle
   Turtle ARECT 70, 30
   Pause 1000
 Next angle
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 8: POLYGON FILL TESTS
' ============================================================================
Sub Test_PolygonFill()
 Local i As INTEGER

 StartTest("Polygon Fill Tests")

 ' Test 8.1: Filled triangle
 TestCase("Filled triangle with BEGIN_FILL/END_FILL")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(255, 100, 100)
 Turtle BEGIN_FILL
 For i = 1 To 3
   Turtle FD 100
   Turtle RT 120
 Next i
 Turtle END_FILL
 WaitForKey()

 ' Test 8.2: Filled star
 TestCase("Filled star")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(255, 255, 0)
 Turtle BEGIN_FILL
 For i = 1 To 5
   Turtle FD 100
   Turtle RT 144
 Next i
 Turtle END_FILL
 WaitForKey()

 ' Test 8.3: Pattern-filled hexagon
 TestCase("Pattern-filled hexagon")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(100, 200, 255)
 Turtle FILLPATTERN 6
 Turtle BEGIN_FILL
 For i = 1 To 6
   Turtle FD 60
   Turtle RT 60
 Next i
 Turtle END_FILL
 WaitForKey()

 ' Test 8.4: Complex polygon with curves
 TestCase("Polygon with arcs")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(200, 100, 200)
 Turtle FILLPATTERN 1
 Turtle BEGIN_FILL
 For i = 1 To 4
   Turtle ARC 40, 90
 Next i
 Turtle END_FILL
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 9: STACK TESTS
' ============================================================================
Sub Test_Stack()
 Local i As INTEGER

 StartTest("Stack (PUSH/POP) Tests")

 ' Test 9.1: Simple PUSH/POP
 TestCase("Basic PUSH/POP - draw and return")
 Turtle RESET
 Turtle HT
 Turtle PUSH
 Turtle FD 100
 Turtle RT 90
 Turtle FD 50
 Turtle POP
 Turtle PENCOLOR RGB(RED)
 Turtle CIRCLE 5
 WaitForKey()

 ' Test 9.2: Recursive tree
 TestCase("Recursive tree with PUSH/POP")
 Turtle RESET
 Turtle HT
 Turtle PU
 Turtle SETXY 160, 200
 Turtle SETHEADING 90
 Turtle PD
 DrawBranch(60)
 WaitForKey()

 ' Test 9.3: Multiple PUSH/POP
 TestCase("Nested PUSH/POP")
 Turtle RESET
 Turtle HT
 Turtle PUSH
 Turtle FD 80
 Turtle PUSH
 Turtle RT 45
 Turtle FD 60
 Turtle POP
 Turtle RT 90
 Turtle FD 60
 Turtle POP
 Turtle PENCOLOR RGB(RED)
 Turtle CIRCLE 5
 WaitForKey()

 ' Test 9.4: Snowflake with PUSH/POP
 TestCase("Snowflake pattern")
 Turtle RESET
 Turtle HT
 For i = 1 To 6
   Turtle PUSH
   DrawSnowflakeBranch(70)
   Turtle POP
   Turtle RT 60
 Next i
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 10: CURSOR TESTS
' ============================================================================
Sub Test_Cursor()
 Local i As INTEGER
 Local size As INTEGER
 Local cursor_colors(4) As INTEGER

 StartTest("Cursor Tests")

 ' Test 10.1: SHOWTURTLE and HIDETURTLE
 TestCase("Toggle cursor visibility")
 Turtle RESET
 Turtle ST
 Print "Cursor should be visible"
 WaitForKey()
 Turtle HT
 Print "Cursor should be hidden"
 WaitForKey()

 ' Test 10.2: Cursor follows movement
 TestCase("Cursor following movement")
 Turtle RESET
 Turtle ST
 For i = 1 To 4
   Turtle FD 80
   Pause 500
   Turtle RT 90
 Next i
 WaitForKey()

 ' Test 10.3: CURSORSIZE
 TestCase("Different cursor sizes")
 Turtle RESET
 For size = 5 To 20 Step 5
   Turtle ST
   Turtle CS size
   Pause 800
 Next size
 WaitForKey()

 ' Test 10.4: CURSORCOLOR
 TestCase("Different cursor colors")
 Turtle RESET
 Turtle ST
 cursor_colors(0) = RGB(RED)
 cursor_colors(1) = RGB(GREEN)
 cursor_colors(2) = RGB(BLUE)
 cursor_colors(3) = RGB(YELLOW)
 cursor_colors(4) = RGB(MAGENTA)
 For i = 0 To 4
   Turtle CURSORCOLOR cursor_colors(i)
   Turtle FD 40
   Turtle RT 72
   Pause 500
 Next i
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 11: COMPLEX DRAWING TESTS
' ============================================================================
Sub Test_ComplexDrawing()
 Local x As INTEGER
 Local layer As INTEGER
 Local i As INTEGER

 StartTest("Complex Drawing Tests")

 ' Test 11.1: House
 TestCase("Draw a house")
 Turtle RESET
 Turtle HT
 ' Base
 Turtle FILLCOLOR RGB(200, 150, 100)
 Turtle PU
 Turtle SETXY 160, 150
 Turtle FRECT 100, 80
 ' Roof
 Turtle PU
 Turtle SETXY 160, 110
 Turtle PD
 Turtle FILLCOLOR RGB(150, 50, 50)
 Turtle BEGIN_FILL
 Turtle setxy 110,110
 Turtle setxy 130,80
 Turtle setxy 190,80
 Turtle setxy 210,110
 Turtle setxy 110,110
 Turtle END_FILL
 ' Door
 Turtle PU
 Turtle SETXY 160, 170
 Turtle FILLCOLOR RGB(100, 50, 0)
 Turtle FRECT 25, 40
 ' Window
 Turtle SETXY 130, 135
 Turtle FILLCOLOR RGB(200, 220, 255)
 Turtle FRECT 20, 20
 WaitForKey()

' Test 11.2: Flower garden
 TestCase("Flower garden")
 Turtle RESET
 Turtle HT
 ' Ground - make it span the full width
 Turtle PU
 Turtle SETXY 160, 180
 Turtle FILLCOLOR RGB(brown)
 Turtle FILLPATTERN 1
 Turtle FRECT 320, 80

' Flowers - evenly spaced across the ground
 For x = 70 To 250 Step 60
   DrawFlower(x, 150 + Int(Rnd() * 10))
 Next x
 WaitForKey()

 ' Test 11.3: Spiral galaxy
 TestCase("Spiral galaxy")
 Turtle RESET
 Turtle HT
 Turtle PENWIDTH 2
 For i = 1 To 100
   Turtle PENCOLOR RGB((100 + i), (100 + i), 255)
   Turtle FD(i * 0.8)
   Turtle RT 20
 Next i
 WaitForKey()

 ' Test 11.4: Mandala
 TestCase("Mandala pattern")
 Turtle RESET
 Turtle HT
 For layer = 1 To 3
   For i = 1 To 12
     Turtle HOME
     Turtle SETHEADING(i * 30)
     Turtle FD(layer * 25)
     Turtle FILLCOLOR RGB((255 - layer * 60), (100 + layer * 40), 200)
     Turtle FILLPATTERN(layer * 5)
     Turtle FCIRCLE(20 - layer * 5)
   Next i
 Next layer
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' TEST 12: STRESS TESTS
' ============================================================================
Sub Test_Stress()
 Local i As INTEGER
 Local start_time As INTEGER
 Local p As INTEGER

 StartTest("Stress Tests")

 ' Test 12.1: Many small lines
 TestCase("1000 random lines")
 Turtle RESET
 Turtle HT
 start_time = Timer
 For i = 1 To 1000
   Turtle PU
   Turtle SETXY Rnd() * 300 + 10, (Rnd() * 220 + 10)
   Turtle PD
   Turtle SETHEADING Rnd() * 360
   Turtle FD 10
 Next i
 Print "Time: " + Str$(Timer - start_time) + " ms"
 WaitForKey()

 ' Test 12.2: Many circles
 TestCase("100 random circles")
 Turtle RESET
 Turtle HT
 start_time = Timer
 For i = 1 To 100
   Turtle PU
   Turtle SETXY Rnd() * 280 + 20, (Rnd() * 200 + 20)
   Turtle FILLCOLOR RGB((Rnd()*255), (Rnd()*255), (Rnd()*255))
   Turtle FILLPATTERN Rnd() * 8
   Turtle FCIRCLE Rnd() * 15 + 5
 Next i
 Print "Time: " + Str$(Timer - start_time) + " ms"
 WaitForKey()

 ' Test 12.3: Deep stack
 TestCase("Deep PUSH/POP stack (10 levels)")
 Turtle RESET
 Turtle HT
 For i = 1 To 10
   Turtle PUSH
   Turtle FD(i * 10)
   Turtle RT 36
 Next i
 For i = 1 To 10
   Turtle POP
   Pause 200
 Next i
 WaitForKey()

 ' Test 12.4: Large polygon
 TestCase("100-sided polygon fill")
 Turtle RESET
 Turtle HT
 Turtle FILLCOLOR RGB(200, 100, 255)
 Turtle FILLPATTERN 1
 start_time = Timer
 Turtle BEGIN_FILL
 For i = 1 To 100
   Turtle FD 3
   Turtle RT 3.6
 Next i
 Turtle END_FILL
 Print "Time: " + Str$(Timer - start_time) + " ms"
 WaitForKey()

 EndTest()
End Sub

' ============================================================================
' HELPER FUNCTIONS FOR COMPLEX DRAWINGS
' ============================================================================

Sub DrawBranch(length As INTEGER)
 If length < 10 Then Exit Sub

 Turtle FD length

 Turtle PUSH
 Turtle LT 30
 DrawBranch(length * 0.7)
 Turtle POP

 Turtle PUSH
 Turtle RT 30
 DrawBranch(length * 0.7)
 Turtle POP
End Sub

Sub DrawSnowflakeBranch(length As INTEGER)
 Turtle FD length
 Turtle PUSH
 Turtle RT 45
 Turtle FD(length * 0.4)
 Turtle POP
 Turtle PUSH
 Turtle LT 45
 Turtle FD(length * 0.4)
 Turtle POP
End Sub

Sub DrawFlower(x As INTEGER, y As INTEGER)
 Local i As INTEGER

 Turtle PU
 Turtle SETXY x, y
 Turtle PD

 ' Stem
 Turtle PENCOLOR RGB(50, 150, 50)
 Turtle PENWIDTH 2
 Turtle SETHEADING 0
 Turtle FD 30

 ' Petals
 Turtle FILLCOLOR RGB(255, 100, 150)
 For i = 1 To 6
   Turtle PUSH
   Turtle FCIRCLE 8
   Turtle POP
   Turtle RT 60
 Next i

 ' Center
 Turtle FILLCOLOR RGB(255, 255, 0)
 Turtle FCIRCLE 5

 Turtle PENWIDTH 1
End Sub

' ============================================================================
' TEST FRAMEWORK HELPERS
' ============================================================================

Sub StartTest(test_name$)
 CLS
 Print "=========================================="
 Print test_name$
 Print "=========================================="
 Print
 test_number = 0
End Sub

Sub EndTest()
 Print
 Print "Test section complete."
End Sub

Sub TestCase(description$)
 test_number = test_number + 1
 Print "Test " + Str$(test_number) + ": " + description$
End Sub

Sub WaitForKey()
 Print "  (Press any key for next test)"
 Do While Inkey$ = "": Loop
End Sub

Sub RunAllTests()
 Print "Running all tests..."
 Test_BasicMovement()
 Test_PenControl()
 Test_Position()
 Test_Circles()
 Test_Rectangles()
 Test_Arcs()
 Test_FillPatterns()
 Test_PolygonFill()
 Test_Stack()
 Test_Cursor()
 Test_ComplexDrawing()
 Test_Stress()
 Print
 Print "ALL TESTS COMPLETE!"
End Sub

' ============================================================================
' RUN THE TEST MENU
' ============================================================================
TestMenu()

Edited 2025-11-13 05:19 by matherp
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 498
Posted: 09:08pm 12 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  V6.01.00RC12

This release contains a very comprehensive turtle graphics implementation for all versions except the WebMite RP2040 and WebMite RP2350.


Awwww. No Webmite?  
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8320
Posted: 08:01am 13 Nov 2025
Copy link to clipboard 
Print this post

Now this is getting a bit silly, Peter. You've more or less included a full dedicated Turtle computer into the firmware. :) Very nice, thanks!

@toml
The Webmite doesn't support a VGA or HDMI graphics display. It's designed to send any graphics to a browser. That doesn't support pixel by pixel operations.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 08:22am 13 Nov 2025
Copy link to clipboard 
Print this post

Couple of typos in the command list

  Quote  SET HEADING angle       (SETH) - Set absolute heading (0=right, 90=up)
HOME                         - Return to center (160,120) heading 0


should be
  Quote  SET HEADING angle       (SETH) - Set absolute heading (0=up, 90=right)
HOME                         - Return to center (MM.HRES\2,MM.VRES\2) heading 0


Here is one of the CMM2 turtle demo programs. Run on a VGA or HDMI at 640x480 resolution. Tested on a RP2040 VGA mode 1
' Sierpinski Triangle Recursive Fractal
' Author: "Sasquatch"
MODE 1
CLS
Text 0, 0, "Sierpinski Triangle", "", 2
Text 2, 25, "Press ctrl-C to Quit", "", 1
Turtle reset
Turtle Pen Up
Turtle Move 55,470
Turtle Turn Right 90
Turtle Pen Down
Sierpinski(520,7)
Do :Loop
Sub Sierpinski(Length,Level)
 If Level = 0 Then
   For i = 1 To 3
     Turtle Forward Length
     Turtle Turn Left 120
   Next i
   Exit Sub
 EndIf
 Sierpinski(Length / 2.0, Level - 1)
 Turtle Pen Up
 Turtle Forward Length / 2.0
 Turtle Pen Down
 Sierpinski(Length / 2.0, Level - 1)
 Turtle Pen Up
 Turtle Turn Left 120
 Turtle Forward Length / 2.0
 Turtle Turn Right 120
 Turtle Pen Down
 Sierpinski(Length / 2.0, Level - 1)
 Turtle Pen Up
 Turtle Turn Left 60
 Turtle Backward Length / 2.0
 Turtle Turn Right 60
 Turtle Pen Down
End Sub

Edited 2025-11-13 18:35 by matherp
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4158
Posted: 09:13am 13 Nov 2025
Copy link to clipboard 
Print this post

I wonder if Tom and Gerry are keeping up...

(Jerry would have been a handy spelling!)

John
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5485
Posted: 09:13am 13 Nov 2025
Copy link to clipboard 
Print this post

@Peter,

Should I worry about memory (flash) management ? The uf2 file has grown since the start of V6.01.00 by 60kbyte at least (b9->rc12).
But the A:/ drive is still 774144 bytes in size.
And we still have 3 flash slots size 100kbyte.
And there is still 16k persistent variable memory.

No overlap yet with grown firmware ?

This is RP2040 VGA PS2.

My worry is not with VGA, but with the non-vga RP2040 used for Game*Mite. The Game*Mite essentially operates using flash slots, and (except 40kbyte) the whole A: drive. When A: shrinks there is definitely impact.

Regards,

Volhout

P.S. I started testing rc12 VGA2040 on my key programs, but have not finished yet. There is one program that does not run (AS02.5) but I have to check what causes it. If it is reserved keyword use as variable. Don't know yet. I also noticed that the speed increase you realized between b20 and rc? has been reversed in rc12 (it is slower again). But marginally slower (derived from framerates in LA and games).
Edited 2025-11-13 19:20 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5485
Posted: 01:01pm 13 Nov 2025
Copy link to clipboard 
Print this post

@Peter,

LINE PLOT does not adhere to the selected framebuffer in 2040 VGA. It always plots to N.

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 01:34pm 13 Nov 2025
Copy link to clipboard 
Print this post

It can't, unless line also does the same. It calls the same underlying routine with no differences
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3487
Posted: 01:42pm 13 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  ... a very comprehensive turtle graphics implementation ...


Congratulations to you and Claude. I may have to introduce myself to this Claude fellow (though I'm not sure I have any projects worthy of his attention).

Any hope for an RP2340A version for ILI9488 480x320? That's my go-to ready-at-hand picomite, because I typically sit in my La-Z-Boy with a laptop and have no monitor for VGA or HDMI.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 02:06pm 13 Nov 2025
Copy link to clipboard 
Print this post

  Quote  Any hope for an RP2340A version for ILI9488 480x320?

Already there, it is only the WebMites where I haven't enabled it
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5485
Posted: 02:31pm 13 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  It can't, unless line also does the same. It calls the same underlying routine with no differences


LINE PLOT is so blazing fast. Had to adapt the program loop for it. Now it is fine.

Volhout
PicomiteVGA PETSCII ROBOTS
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3487
Posted: 03:06pm 13 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  Already there


Thanks. All turtle tests ran successfully, other than that for 2 of the spirals, the LCD borders were exceeded and the last lines were drawn on the bordering pixels.

Great job.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 498
Posted: 03:19pm 13 Nov 2025
Copy link to clipboard 
Print this post

  matherp said  V6.01.00RC12
V6.01.00RC12


Your handheld design won't have turtle graphics, will it?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 03:27pm 13 Nov 2025
Copy link to clipboard 
Print this post

Yes, of course
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 721
Posted: 03:56pm 13 Nov 2025
Copy link to clipboard 
Print this post

Peter,

there is still the IR "bug"? in your new RC12 - did you read my post?

Post above

Greetings
Daniel
Edited 2025-11-14 01:57 by Amnesie
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10653
Posted: 05:56pm 13 Nov 2025
Copy link to clipboard 
Print this post

Minor update to RC12 to fix IR issue and add extra memory protection to the turtle code.
Note for IR on the RP2350 a 4K7 pullup on the data line is HIGHLY recommended  (E9 issues)

PicoMiteV6.01.00RC12.zip
 
     Page 12 of 18    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025