Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:42 28 Nov 2024 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 : test version of GFXterm with resizable screen

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 07:08am 29 Apr 2023
Copy link to clipboard 
Print this post

attached are test versions of GFXterm compiled for 64-bit linux and win32. these have a couple of changes requested by Frank N. Furter:

1. anything being pasted that is only one line long now does NOT have a carriage return appended, and,

2. there is now a new menu option, "screen size" that enables you to manually set the screen size to anything between 40x16 and 160x60. this should accommodate the needs of the pico versions of MMbasic.

there have also been a few bug fixes, but since no one noticed them i'll not go into details  

i have NOT extensively tested the changes, so these versions should be strictly treated as experimental. please do report any odd behavior you notice. allowing for user settable screen size was a tad challenging, and may have unexpected side effects. what testing i did was with an MX170 micromite and mostly involved odd numbers of columns.


GFXterm64 (2023-04-30) test.zip

GFXtermW32 (2023-04-29) test.zip


cheers,
rob   :-)

addendum: replaced the linux version due to a compiler 'bug' that prevented running on some older systems. hence the later date of 2023-04-30.
Edited 2023-04-29 23:14 by robert.rozee
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4251
Posted: 07:54pm 01 May 2023
Copy link to clipboard 
Print this post

Hi Robert,

EDIT: it works fine. Running on picomite V50707RC6.
Using the Linux version on Ubuntu 22.04

For completeness, the source...

' A short test program to play the Game of Life, invented
' by John CONWAY. Unfortunately, Covid19 took John's life
' on April 11, 2020. His legacy lives on in the coutless
' people inspired by his invention of the cellular automaton
' called the Game of Life and his other works.
'
' Written by vegipete, April 22, 2020 for use with GFXTerm.

Option DEFAULT INTEGER
Dim INTEGER i,j,count
Dim INTEGER xs,ys
Dim INTEGER sw,sh

Dim string GFX$
Dim float w(41,41)

GFX$ = Chr$(16)

Print GFX$ "?"  ' request size of GFXTerm Window
Input sw,sh ' grab dimensions - width and height

Print Chr$(27)+"[2J";   ' esc sequence to erase the text screen
Print "Thank you John CONWAY. Rest in Peace."

xs = 100: ys = 20

' clear the world to start
For i = 0 To 41
For j = 0 To 41
w(i,j) = 0
'w(i,j) = 1+Rnd()*3
Next j
Next i

' seed the world
w(19,31) = 3 : w(20,31) = 3 : w(21,31) = 3
w(19,32) = 3 : w(21,32) = 3
w(19,33) = 3 : w(21,33) = 3
w(20,34) = 3
w(17,35) = 3 : w(19,35) = 3 : w(20,35) = 3: w(21,35) = 3
w(18,36) = 3 : w(20,36) = 3 : w(22,36) = 3
w(20,37) = 3 : w(23,37) = 3
w(19,38) = 3 : w(21,38) = 3
w(19,39) = 3 : w(21,39) = 3

showWorld
'Pause 2000

For i = 0 To 1000
CONWAYLife
showWorld
Print i
If i>49 Then
 Input a$
EndIf
Next i

End

' Calculate a new generation of life, using the classic rules
Sub CONWAYLife
Local integer i,j,count

' move most recent generation to previous and clear new geneartion
For i = 1 To 40
For j = 1 To 40
  w(i,j) = w(i,j) << 1
  'w(i,j) = (w(i,j) << 1) and 254
  'w(i,j) = w(i,j) * 2
Next j
Next i

' wrap the corners
w(0,0) = w(40,40) : w(41,41) = w(1,1)
w(0,41) = w(40,1) : w(41,0) = w(1,40)

' wrap the edges
For i = 1 To 40
w(0,i) = w(40,i) ' left
w(41,i) = w(1,i) ' right
w(i,0) = w(i,40) ' top
w(i,41) = w(i,1) ' bottom
Next i

' calculate new generation
For i = 1 To 40
For j = 1 To 40
  count = Neighbours(i,j)

  If (w(i,j) And 2) Then  ' was cell alive last generation?
    ' yes so test if it stays alive
    If (count = 2) Or (count = 3) Then
      w(i,j) = w(i,j) + 1 ' cell remains alive for new generation
    EndIf
  Else
    ' no so test if it gets born
    If count = 3 Then
      w(i,j) = w(i,j) + 1 ' cell becomes alive for new generation
    EndIf
  EndIf

Next j
Next i

End Sub

' return number of neighbours around given point
Function Neighbours(x,y)
Local count

count = 0

If (w(x-1,y-1) And 2) Then count = count + 1
If (w(x+0,y-1) And 2) Then count = count + 1
If (w(x+1,y-1) And 2) Then count = count + 1
If (w(x-1,y+0) And 2) Then count = count + 1
If (w(x+1,y+0) And 2) Then count = count + 1
If (w(x-1,y+1) And 2) Then count = count + 1
If (w(x+0,y+1) And 2) Then count = count + 1
If (w(x+1,y+1) And 2) Then count = count + 1

Neighbours = count

End Function

' display the current world
Sub showWorld
Local integer i,j

xstart = 50
Print gfx$ "C" 0,0,sw,sh
Print gfx$ "I" 255,255,0,4
For i = 1 To 40
For j = 1 To 40
  If w(i,j) And 1 Then
    Print gfx$ "A" xs+10*i,ys+10*j,xs+6+10*i,ys+6+10*j,0,0
  EndIf
Next j
Next i

End Sub

End

Edited 2023-05-02 06:02 by Volhout
PicomiteVGA PETSCII ROBOTS
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 12:26pm 02 May 2023
Copy link to clipboard 
Print this post

excellent... i've spotted a couple of small cosmetic errors (line the column counter only being 2-digits), but will leave them for the moment. GFXterm should also work with the CMM2 now, once the screen size is set to match.

it looks like TBS's Document Register (https://www.thebackshed.com/DocRegister/) is no longer there, so i'll need to find a new online home for GFXterm. quite understandable, as hardly anyone made use of the register (apart from me). will look at doing something with GitHub or GitLab.


cheers,
rob   :-)


Edited 2023-05-02 22:27 by robert.rozee
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 76
Posted: 09:56pm 02 May 2023
Copy link to clipboard 
Print this post

Firstly, thanks for GFXTerm,

simple to use, low dependancy,

suspect us people with grey beards will be playing with it and RS232, when we all have flying cars and anthropoid robots doing the housework.

Have you ever thought about grafting the graphics layer onto MMB4DOS ?
I know it wouldn't be MMB4windows, but possibly have a small niche.

just a thought.. regs Dave.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 12:35pm 04 May 2023
Copy link to clipboard 
Print this post

GitHub repository is now up:

https://github.com/robert-rozee/GFXterm

binaries are here:
https://github.com/robert-rozee/GFXterm/tree/main/binaries

documentation is here:
https://github.com/robert-rozee/GFXterm/tree/main/docs


cheers,
rob   :-)
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 05:20pm 05 May 2023
Copy link to clipboard 
Print this post

Great. Thanks.

I had trouble loading the examples until I found the note:
"HINT: if pasting into the Micromite's inbuilt editor, always ensure there is a space character to the right of the cursor before you start in order to suppress automatic line indenting."

Is there a version for Delphi?

Michal
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 12:46pm 06 May 2023
Copy link to clipboard 
Print this post

  Michal said  Is there a version for Delphi?


GFXterm was originally written using Delphi 5 Professional. the source code still exists, and anyone who wants is welcome to it (attached below). but, do bear in mind:
- development using Delphi stopped late 2019,
- that version only compiles under Windows,
- Delphi 5 Pro is over 20 years old now, so the GFXterm sources may not play so nicely when loaded up in a modern versions of Delphi. to give you some idea, Delphi 5 Pro was released before Windows XP became widely available!

on the plus side, back then GFXterm did support remote access to a Mite over the web using some handy 'visual components' that were a part of Delphi but without any equivalent functionality in Lazarus. while a couple of people were keen on having remote access to Mites over the web, i felt the functionality was rarely used by anyone in practice.

when i switched to using Linux (because modern Windows became just too frustrating to live with) i ported the Delphi 5 source code over to Lazarus, but at that time only supported Linux builds. This was during "the first lockdown" (2020). about the time of "the second lockdown" (2021) i added in win32 functionality, as well as moving to a threaded model of handling comms. i believe this later code is far more robust.


cheers,
rob   :-)


GFXterm (11-sept-2019) Delphi 5 Pro.zip
Edited 2023-05-06 22:53 by robert.rozee
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 07:03pm 06 May 2023
Copy link to clipboard 
Print this post

Thanks,

I compiled your code in Delphi 2007 with no problems.
It starts and connects(I suppose) but it doesn't display the response(characters).
The cursor is stationary. What do you think could be the cause.
Here is a link to the zipped exe:
https://drive.google.com/file/d/1sGecmmz_zjcaZ5isyO7CtATHvkLZpxwJ/view?usp=sharing

Your exe also behaves like this (on Windows 10-32 19045.2846).
After connecting, the red cursor blinks and stands still. Does not respond to the keyboard.
For picomite, do the sources need tweaking?

Michal
Edited 2023-05-07 07:11 by Michal
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 06:28am 07 May 2023
Copy link to clipboard 
Print this post

aha, i remember that issue:
"note 1: when connecting to a pico, you still need to press alt-1 to assert DTR."
from https://www.thebackshed.com/forum/ViewTopic.php?TID=14178&P=2#175952

for a more permanent fix, search the source for the word "DTR", grab that line, and paste a copy into the menu handler for 'connect' just after the connection is made.


cheers,
rob   :-)
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 06:47am 07 May 2023
Copy link to clipboard 
Print this post

Thanks,

Now mine and your build works.

Michal
 
Michal
Senior Member

Joined: 02/02/2022
Location: Poland
Posts: 123
Posted: 11:33am 07 May 2023
Copy link to clipboard 
Print this post

It is interesting that for "GFX Demo 3" the version compiled in Delphi2007 (older)
load the CPU in 3-4%, and compiled in Lazarus 2.2.6-Win32 (current) in 16-20%.

Michal
Edited 2023-05-08 04:20 by Michal
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 09:21am 08 May 2023
Copy link to clipboard 
Print this post

because Lazarus/FPC supports multiple targets, binaries have a fair bit more plumbing under the hood than with Delphi; more 'layers of abstraction' so to speak. also the very latest (Lazarus) version of GFXterm now supports a resizable display (rows and columns), which expands out the maths complexity to work out where each character bitmap is placed on the window. all simple integer equations, but repeated many many times, and without doubt it would benefit from some optimization after the latest change.


cheers,
rob   :-)
 
NPHighview

Senior Member

Joined: 02/09/2020
Location: United States
Posts: 200
Posted: 02:01am 09 May 2023
Copy link to clipboard 
Print this post

I'm still using Tera Term (sorry!), but couldn't help checking out the new MATH functions in the latest release of Pico firmware. Here's a modified version of Vegipete's Life program, with an inversion of the cell life logic. All in all, the core "ConwayLife" subroutine takes about 22% less time with the recent mods - nice!

' A short test program to play the Game of Life, invented
' by John CONWAY. Unfortunately, Covid19 took John's life
' on April 11, 2020. His legacy lives on in the coutless
' people inspired by his invention of the cellular automaton
' called the Game of Life and his other works.
'
' Written by vegipete, April 22, 2020 for use with GFXTerm.

' Modified by NPHighview (Steve Johnson), May 6, 2023 to use
' the latest Pico firmware MATH functions, plus an inversion
' of the cell life evaluation logic to reduce IF tests.

Option DEFAULT INTEGER
Dim INTEGER i,j,count
Dim INTEGER w(41,41)

Print @(0,0) "Thank you John CONWAY. Rest in Peace."

Math SET 0, w() ' clear the world to start

' seed the world
w( 9,11) = 3 : w(10,11) = 3 : w(11,11) = 3
w( 9,12) = 3 : w(11,12) = 3
w( 9,13) = 3 : w(11,13) = 3
w(10,14) = 3
w( 7,15) = 3 : w( 9,15) = 3 : w(10,15) = 3: w(11,15) = 3
w( 8,16) = 3 : w(10,16) = 3 : w(12,16) = 3
w(10,17) = 3 : w(13,17) = 3
w( 9,18) = 3 : w(11,18) = 3
w( 9,19) = 3 : w(11,19) = 3


w(19,32) = 3 : w(11,32) = 3
w(19,33) = 3 : w(11,33) = 3
w(20,34) = 3
w(17,35) = 3 : w( 9,35) = 3 : w(10,35) = 3: w(11,35) = 3
w(18,36) = 3 : w(10,36) = 3 : w(12,36) = 3
w(20,37) = 3 : w(13,37) = 3
w(19,38) = 3 : w(11,38) = 3
w(19,39) = 3 : w(11,39) = 3

showLife

For i = 0 To 1000
Old_Timer = Timer
CONWAYLife
New_Timer = Timer
showLife
Print "Generation" i Int(New_Timer-Old_Timer) " mSec"
Next i

End

' Calculate a new gen of life, using inverted rules
Sub CONWAYLife
 Local integer i, j, count

 Math SCALE w(), 2, w() ' shift left & clear new generation

 w(0, 0) = w(40,40) : w(41,41) = w(1, 1)  ' wrap corners
 w(0,41) = w(40, 1) : w(41, 0) = w(1,40)

 For i = 1 To 40  ' wrap the edges
   w( 0, i) = w(40, i) ' left
   w(41, i) = w( 1, i) ' right
   w( i, 0) = w( i,40) ' top
   w( i,41) = w( i, 1) ' bottom
 Next i

' calculate new generation
 For i = 1 To 40
   For j = 1 To 40
     count = Neighbors(i,j)
     If count=3 Then Inc w(i,j)
     If count=2 Then
       If (w(i,j) And 2) Then Inc w(i,j)
     EndIf
   Next j
 Next i
End Sub

Function Neighbors(x,y) ' return number of neighbours around given point
 Local count = 0
 If (w(x-1,y-1) And 2) Then Inc count
 If (w(x+0,y-1) And 2) Then Inc count
 If (w(x+1,y-1) And 2) Then Inc count
 If (w(x-1,y+0) And 2) Then Inc count
 If (w(x+1,y+0) And 2) Then Inc count
 If (w(x-1,y+1) And 2) Then Inc count
 If (w(x+0,y+1) And 2) Then Inc count
 If (w(x+1,y+1) And 2) Then Inc count

 Neighbors = count

End Function

Sub showLife  ' display the current world
 Local integer i,j

 Print @(1,1)
 For i = 1 To 40
   For j = 1 To 40
     If w(i,j) And 1 Then Print " @"; Else Print " .";
   Next j
 Print
 Next i

End Sub

End

Live in the Future. It's Just Starting Now!
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4251
Posted: 11:15am 09 May 2023
Copy link to clipboard 
Print this post

Hi NPHighView,

In your search for performance, you may want to look at

For i = 1 To 40  ' wrap the edges
  w( 0, i) = w(40, i) ' left
  w(41, i) = w( 1, i) ' right
  w( i, 0) = w( i,40) ' top
  w( i,41) = w( i, 1) ' bottom
Next i


To avoid counter i, and use:


MATH SLICE
MATH INSERT


Volhout

P.S. you may even be able to use MATH SLICE to subtract a 3x3 part out of the field, and do a MATH SUM to sum up all the neighbours. Not sure if that is faster, but it may be.
PicomiteVGA PETSCII ROBOTS
 
Print this page


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

© JAQ Software 2024