Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:42 19 May 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 : MMBasic for Windows - pre-alphas

     Page 4 of 17    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 09:56am 27 Jan 2022
Copy link to clipboard 
Print this post

  Quote  With MMBasic version 5.07.03pa1 I get

  Quote  I get

load the version where I announced the GUI. I said I wasn't going to be rigorous with version numbers.
OPTION MOUSE is a CMM2 command. This is windows. The mouse is always there
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 328
Posted: 10:18am 27 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  With MMBasic version 5.07.03pa1 I get

  Quote  I get

load the version where I announced the GUI. I said I wasn't going to be rigorous with version numbers.
OPTION MOUSE is a CMM2 command. This is windows. The mouse is always there


Oops! More than one in my PATH. The GUI does work on my system now. Thanks.
Edited 2022-01-27 20:24 by toml_12953
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 10:57am 27 Jan 2022
Copy link to clipboard 
Print this post

MMBasic under "wine" on a debian "buster": 3.7 mio loops in a second!

-andreas

 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 504
Posted: 12:52pm 27 Jan 2022
Copy link to clipboard 
Print this post

@Andreas

226 Fps ? What your specs and is this the gui release version?
Plasma
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 01:12pm 27 Jan 2022
Copy link to clipboard 
Print this post

  Plasmamac said  @Andreas

226 Fps ? What your specs and is this the gui release version?


  Quote  $ inxi -F
System:    Host: server Kernel: 4.19.0-18-amd64 x86_64 bits: 64 Desktop: MATE 1.20.4 Distro: Debian GNU/Linux 10 (buster)
Machine:   Type: Desktop System: FUJITSU product: CELSIUS W580power v: N/A serial: <root required>
          Mobo: FUJITSU model: D3617-A1 v: S26361-D3617-A1 serial: <root required> UEFI: FUJITSU // American Megatrends
          v: 5.0.0.13 R1.25.0 for D3617-A1x date: 06/30/2020
CPU:       Topology: 6-Core model: Intel Core i5-8600 bits: 64 type: MCP L2 cache: 9216 KiB
          Speed: 800 MHz min/max: 800/4300 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 800 5: 800 6: 800
Graphics:  Device-1: Intel UHD Graphics 630 driver: i915 v: kernel
          Display: x11 server: X.Org 1.20.4 driver: modesetting unloaded: fbdev,vesa
          resolution: 1920x1080~60Hz, 1920x1080~60Hz
          OpenGL: renderer: Mesa DRI Intel UHD Graphics 630 (Coffeelake 3x8 GT2) v: 4.5 Mesa 18.3.6
Audio:     Device-1: Intel Cannon Lake PCH cAVS driver: snd_hda_intel
          Sound Server: ALSA v: k4.19.0-18-amd64


I have problems to use my german keyboard layout under wine. Is there any OPTION or wine config?

  Quote  $ setxkbmap -v
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwertz)
types:      complete
compat:     complete
symbols:    pc+de+inet(evdev)+altwin(prtsc_rwin)
geometry:   pc(pc102)


-andreas
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 01:14pm 27 Jan 2022
Copy link to clipboard 
Print this post

no it was the non-gui version.
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 01:19pm 27 Jan 2022
Copy link to clipboard 
Print this post

this are the results with the gui version: FPS 105 but loop with 3.6 mio/s



-andreas
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 01:56pm 27 Jan 2022
Copy link to clipboard 
Print this post

  andreas said  this are the results with the gui version: FPS 105 but loop with 3.6 mio/s



-andreas


Well more than that, actually because you are doing the Timer - tstart for every loop.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1141
Posted: 02:17pm 27 Jan 2022
Copy link to clipboard 
Print this post

  Tinine said  Well more than that, actually because you are doing the Timer - tstart for every loop.

Yes!

Dim integer counter = 0
Timer = 0

Do While Timer < 1000
Inc counter
Loop

Print "counter="counter


BTW: FPS: 17 (4*3 GHz)

even faster:
Dim integer c = 0
Timer = 0

Do While Timer < 1000
Inc c
Loop

Print "counter="c

Edited 2022-01-28 00:34 by twofingers
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 04:49pm 27 Jan 2022
Copy link to clipboard 
Print this post

  twofingers said  
  Tinine said  Well more than that, actually because you are doing the Timer - tstart for every loop.

Yes!

Dim integer counter = 0
Timer = 0

Do While Timer < 1000
Inc counter
Loop

Print "counter="counter


BTW: FPS: 17 (4*3 GHz)

even faster:
Dim integer c = 0
Timer = 0

Do While Timer < 1000
Inc c
Loop

Print "counter="c



I might be thinking of another processor but I found a lot of the time was attributed to the Do/Loop and therefore I pasted hundreds of lines within the loop to get a better idea of in-line code execution time.

Craig
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 05:14pm 27 Jan 2022
Copy link to clipboard 
Print this post

  Tinine said  
  twofingers said  
  Tinine said  Well more than that, actually because you are doing the Timer - tstart for every loop.

Yes!

Dim integer counter = 0
Timer = 0

Do While Timer < 1000
Inc counter
Loop

Print "counter="counter


BTW: FPS: 17 (4*3 GHz)

even faster:
Dim integer c = 0
Timer = 0

Do While Timer < 1000
Inc c
Loop

Print "counter="c



I might be thinking of another processor but I found a lot of the time was attributed to the Do/Loop and therefore I pasted hundreds of lines within the loop to get a better idea of in-line code execution time.

Craig





-andreas
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 06:11pm 27 Jan 2022
Copy link to clipboard 
Print this post

even faster:)


Dim integer c=0
SetTick 1000,result,1

Do
Inc c
Loop

Sub result
Print c
End Sub


-andreas
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 07:44pm 27 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  Need to find a better timer - any ideas?


On Windows I use QueryPerformanceFrequency to get the timing resolution
and QueryPerformanceCounter to get the ticks.


You only need to use QueryPerformanceFrequency once at the start of the program.

I have never tried on Linux but I think you get the same with clock_gettime & clock_getres.

They should be easy enough to use for the TIMER function but I am not sure how it fits into SETTICK etc.

https://docs.microsoft.com/en-us/windows/win32/api/profileapi/

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 03:32pm 28 Jan 2022
Copy link to clipboard 
Print this post

MMBasic.zip


Timer function now accurate to 0.1uS and reported as a floating point number of milliseconds. Settick and pause remain as-is and have an accuracy of around +/- 16mSec. I could fix this but only by having a thread running continuously reading the high resolution timer. If you need accurate timing you can have the tight loop in basic with the TIMER function

timer=0:do:b=timer:?b-a:a=b:loop


Some other reported things fixed

Currently working on the PAGE command and second display layer
Edited 2022-01-29 01:33 by matherp
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 328
Posted: 04:03pm 28 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  MMBasic.zip


Timer function now accurate to 0.1uS and reported as a floating point number of milliseconds. Settick and pause remain as-is and have an accuracy of around +/- 16mSec. I could fix this but only by having a thread running continuously reading the high resolution timer. If you need accurate timing you can have the tight loop in basic with the TIMER function

timer=0:do:b=timer:?b-a:a=b:loop


Some other reported things fixed

Currently working on the PAGE command and second display layer


Should this be able to run gui-test.bas? I get

[36] Font 3 : GUI Frame frm_pump, "Power", 20, 290, 170, 163,RGB(200,20,255)
Error : -60216 is invalid (valid is -16777216 to -65794)
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 04:20pm 28 Jan 2022
Copy link to clipboard 
Print this post

  Quote  Should this be able to run gui-test.bas? I get

Sorry I'm working on getting the A in ARGB working and missed that. Wait til next version
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 04:38pm 28 Jan 2022
Copy link to clipboard 
Print this post

  matherp said  MMBasic.zip


Timer function now accurate to 0.1uS and reported as a floating point number of milliseconds. Settick and pause remain as-is and have an accuracy of around +/- 16mSec. I could fix this but only by having a thread running continuously reading the high resolution timer. If you need accurate timing you can have the tight loop in basic with the TIMER function

timer=0:do:b=timer:?b-a:a=b:loop


Some other reported things fixed

Currently working on the PAGE command and second display layer


Hello, I'm very happy with this MMBasic Version and waiting every day on new releases.
I'm using it under debian linux and wine. The advatage is, I can edit the source code using linux editors and after saving the code to the ~/documents folder a simple switch to the basic gui allows a load " myprog.bas to get the code loaded. I do this by pressing the up-arrow which has the last load in the history.

Here is my nikolaus program running under 5.07.03pa1 - have fun!


' nikolaus.bas - Zeige alle Loesungen fuer das Haus des Nikolaus
' This versions was tested under MMBasic Version 5.07.03pa1
' running under wine/debian linux
' (c) 2021/22 Andreas Mueller, Gerolsbach (AMI)
'
' Die Eckpunke des Hauses erhalten die Nummern 1..5
'
'            3
'           / \
'          2   4
'          | X |
'          1 - 5
'
' Eine Verbindung V zwischen zwei Eckpunkten wird durch das Paar (a=Anfangspunkt,e=Endpunkt) beschrieben
' Beispiel: V = (1,2) ist die Verbindung zwischen den Eckpunkten 1 und 2
'
' Ein "Pfad" wird durch eine Folge von Verbindungen Vi beschrieben: (1,2),(2,3),(3,4),(4,2),(2,5),(5,4),(4,1),(1,5)
'
' Ein gueltiger "Nikolauspfad" ist ein Pfad, der aus genau 8 Verbindungen besteht fuer welche gilt:
'
'   a) Es gibt keine Verbindung der Form (a,a) fuer alle Eckpunkte a
'
'   b) Wenn (ai,ei) und (aj,ej) zwei benachbarte (j=i+1) Verbindungen im Pfad sind, dann gilt ei = aj.
'
'   c) Wenn die Verbindung (a,e) im Pfad ist, dann gibt es kein weitere Verbindung (a,e) oder (e,a) im Pfad.
'
'   d) Die Verbindungen (1,3),(3,1),(5,3) und (3,5) sind nicht erlaubt.
'
'   zu a) Ein Pfad hat keine Schleifen
'   zu b) Stellt sicher, dass der Pfad zusammenhaengend "in einem Zug" gezeichnet werden kann.
'   zu c) Sichert, dass keine Verbindung unabhaengig von der Laufrichtung zweimal durchlaufen wird.
'   zu d) Sorgt fuer die typische Struktur/Form des Nikolaushauses.
'
'   Die kleinen Zeichenfehler sind Absicht ;-)

dim gx,gy,pen,farbe,heading,caos as integer
dim flag as integer = 1 ' 1 = graphische Ausgabe, 0 = Textausgabe
dim delay as integer = 100 ' Dauer der Verzoegerung beim Zeichnen in ms
     
cls  
Mode 9 ' running under MMBasic V5.07.03pa1 for Windows or wine/linux
dim nikolaus(16) as integer ' Speicher fuer einen vollstaendigen Pfad (8 Startpunkte und 8 Endpunkte)
caos = 0

do
 houses = 0
 for i = 1 to 16
   nikolaus(i) = 0
 next i
 cls
 turtle_reset  
 for a1 = 1 to 5
   for e1 = 1 to 5
     if gueltig(a1,e1) then
       nikolaus(1) = a1
       nikolaus(2) = e1
       a2 = e1     ' Regel b)
       for e2 = 1 to 5
         if gueltig(a2,e2) then
           nikolaus(3) = a2
           nikolaus(4) = e2
           a3 = e2
           for e3 = 1 to 5
             if gueltig(a3,e3) then
               nikolaus(5) = a3
               nikolaus(6) = e3
               a4 = e3
               for e4 = 1 to 5
                 if gueltig(a4,e4) then
                   nikolaus(7) = a4
                   nikolaus(8) = e4
                   a5 = e4
                   for e5 = 1 to 5
                     if gueltig(a5,e5) then
                       nikolaus(9) = a5
                       nikolaus(10) = e5
                       a6 = e5
                       for e6 = 1 to 5
                         if gueltig(a6,e6) then
                           nikolaus(11) = a6
                           nikolaus(12) = e6
                           a7 = e6
                           for e7 = 1 to 5
                             if gueltig(a7,e7) then
                               nikolaus(13) = a7
                               nikolaus(14) = e7
                               a8 = e7
                               for e8 = 1 to 5
                                 if gueltig(a8,e8) then      
                                   nikolaus(15) = a8
                                   nikolaus(16) = e8
                                   printhaus ' success!
                                 endif
                               next e8
                               nikolaus(15)=0
                               nikolaus(16)=0
                             endif
                           next e7
                           nikolaus(14)=0
                           nikolaus(13)=0
                         endif
                       next e6
                       nikolaus(11)=0
                       nikolaus(12)=0
                     endif
                   next e5
                   nikolaus(9)=0
                   nikolaus(10)=0
                 endif
               next e4
               nikolaus(7)=0
               nikolaus(8)=0
             endif
           next e3
           nikolaus(5)=0
           nikolaus(6)=0
         endif
       next e2
       nikolaus(3)=0
       nikolaus(4)=0
     endif
   next e1
   nikolaus(1)=0
   nikolaus(2)=0
 next a1
 pause delay
 inc caos                  
loop
end
     
function gueltig(a,b) as integer ' pruefe neue Verbindung auf "Nikolauseigenschaft"
   
 if a = b then gueltig = 0 : exit function           'nicht erlaubt nach Regel a)
 if a = 1 and b = 3 then gueltig = 0 : exit function 'nicht erlaubt nach Regel d)  
 if a = 5 and b = 3 then gueltig = 0 : exit function 'nicht erlaubt nach Regel d)
 if a = 3 and b = 1 then gueltig = 0 : exit function 'nicht erlaubt nach Regel d)
 if a = 3 and b = 5 then gueltig = 0 : exit function 'nicht erlaubt nach Regel d)
     
 for i = 1 to 15 step 2                              
   if (nikolaus(i) = a) and (nikolaus(i+1) = b) then
     gueltig = 0 : exit function                     'nicht erlaubt nach Regel c)
   endif  
   if (nikolaus(i) = b) and (nikolaus(i+1) = a) then
     gueltig = 0 : exit function                     'nicht erlaubt nach Regel c)
   endif
 next i
     
 gueltig = 1 ' (a,b) ist eine gueltige neue Verbindung
 
end function
     
     
sub printhaus
 local x,y,i,f as integer
 const size = 29
 inc houses
 if flag = 1 then ' graphische Ausgabe
   if nikolaus(1) = 1 then
     x = 60+60*(houses mod 10)+(60-size)/2
     y = size+60+60*(houses \ 10)
   else
     x = 60+60*(houses mod 10)+size+(60-size)/2
     y = size+60+60*(houses \ 10)
   endif
   turtle_pen_up
   turtle_move x,y
   turtle_pen_down
   for i = 1 to 15 step 2
     zeichneverbindung (nikolaus(i),nikolaus(i+1),size,rgb(255-i*17,10*i,i*17))
   next i
   else ' Textausgabe
     print houses;": ";
     open "A:/nikolaus.txt" for append as #1
     print #1,houses;": ";
     print nikolaus(1);" ->";
     print #1,nikolaus(1);" -> ";
     for i = 2 to 14 step 2
       print nikolaus(i);" ->";
       print #1,nikolaus(i);" -> ";
     next i
     print nikolaus(16)
     print #1,nikolaus(16)
     close #1
   endif  
 end sub
     
sub zeichneverbindung (a,b,l,c)
 turtle_pen_colour c
 f = caos - int(rnd*2*caos) ' bringt zufaellige fehler ein
 'f=0
 turtle_pen_down
 if a=1 and b=2 then
   turtle_heading f
   turtle_forward l
 endif
 if a=2 and  b=1 then
   turtle_heading 180+f
   turtle_forward l
 endif
 if a=5 and b=4 then
   turtle_heading f
   turtle_forward l
 endif
 if a=4 and b=5 then
   turtle_heading 180-f
   turtle_forward l
 endif
 if a=1 and b=5 then
   turtle_heading 90+f
   turtle_forward l
 endif
 if a=5 and b=1 then
   turtle_heading 270-f
   turtle_forward l
 endif
 if a=2 and b=4 then
   turtle_heading 90-f
   turtle_forward l
 endif
 if a=4 and b=2 then
   turtle_heading 270+f
   turtle_forward l
 endif
 if a=2 and b=3 then
   turtle_heading 30+f
   turtle_forward 0.90 * sqr(l^2+(l/2)^2)
 endif
 if a=3 and b=2 then
   turtle_heading 210-f
   turtle_forward 0.90 * sqr(l^2+(l/2)^2)
 endif
 if a=4 and b=3 then
   turtle_heading 330+f
   turtle_forward 0.90 * sqr(l^2+(l/2)^2)
 endif
 if a=3 and b=4 then
   turtle_heading 150-f
   turtle_forward 0.90 * sqr(l^2+(l/2)^2)
 endif
 if a=1 and b=4 then
   turtle_heading 45+f
   turtle_forward sqr(l^2*2)
 endif
 if a=4 and b=1 then
   turtle_heading 225-f
   turtle_forward sqr(l^2*2)
 endif
 if a=5 and b=2 then
   turtle_heading 315+f
   turtle_forward sqr(l^2*2)
 endif
 if a=2 and b=5 then
   turtle_heading 135-f
   turtle_forward sqr(l^2*2)
 endif
 turtle_pen_up
 'pause 300    
end sub    
 
sub turtle_reset
 gx=0
 gy=0
 pen=0
 heading=0
 farbe=rgb(white)
end sub
 
sub turtle_pen_up
 pen=0
end sub
 
sub turtle_pen_down
 pen=1
end sub
 
sub turtle_move (x,y)
 if pen=1 then
   line gx,gy,x,y,1,farbe
 end if
 gx = x
 gy = y
end sub
 
sub turtle_pen_colour (c)
 farbe = c
end sub
 
sub turtle_heading (h)
 heading = h
end sub
 
sub turtle_forward (f)
 phi = pi*(heading-90)/180
 if pen=1 then
   line gx,gy,gx+f*cos(phi),gy+f*sin(phi),1,farbe
 end if
 gx=gx+f*cos(phi)
 gy=gy+f*sin(phi)
end sub
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 504
Posted: 05:48pm 28 Jan 2022
Copy link to clipboard 
Print this post

Hi ,
trying the turtle code from andreas gives me an error in line 296
then type edit
press enter

the line show double  but clipboard is empty




hope it help
Edited 2022-01-29 03:49 by Plasmamac
Plasma
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 05:52pm 28 Jan 2022
Copy link to clipboard 
Print this post

  Plasmamac said  Hi ,
trying the turtle code from andreas gives me an error in line 296
then type edit
press enter

the line show double  but clipboard is empty




hope it help


The original code should be:
sub turtle_forward (f)
 phi = pi*(heading-90)/180
 if pen=1 then
   line gx,gy,gx+f*cos(phi),gy+f*sin(phi),1,farbe
 end if
 gx=gx+f*cos(phi)
 gy=gy+f*sin(phi)
end sub


possibly an transfer error...

-andreas
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 187
Posted: 07:02pm 28 Jan 2022
Copy link to clipboard 
Print this post

I get the same error as Plasmamac when using pa2 version. Nikolaus runs using pa1.

-andreas
 
     Page 4 of 17    
Print this page
© JAQ Software 2024