Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:26 10 May 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 : MMBasic for Windows - alphas

     Page 8 of 12    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 04:40pm 22 Feb 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  I bet you write self-modifying code just to upset people. :)


I write self-modifying people just to upset code.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 04:44pm 22 Feb 2022
Copy link to clipboard 
Print this post

  Quote  That sounds ideal, so the workflow would be something like

Exactly that. If you put it in MMB4L as well and drop the abuse of the CSUB then we have a standard
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 05:12pm 22 Feb 2022
Copy link to clipboard 
Print this post

MMBasic.zip

Implemented

dim a(20)
data 0,1,2,3,4,5,6,7,8,9
data 10,11,12,13,14,15,16,17,18,19

for i=0 to 13
read a(i)
next i
readmydata
for i=14 to 19
read a(i)
next i
for i = 0 to 19
if a(i)<>i then print i,"WTF",a(i)
next i
end
sub readmydata
local s$(7)
local i
read save
restore testlabel
for i=0 to 6
read s$(i)
next i
read restore
for i = 0 to 6
print s$(i);
next i
print ""
end sub

testlabel:
data b,c,d,e,f,g,h


C code is trivial in the extreme

void cmd_read(void) {
int i, j, k, len, card;
unsigned char *p, datatoken, *lineptr = NULL, *ptr;
int vcnt, vidx, num_to_read = 0;
static unsigned char* SaveNextDataLine = ProgMemory;
static int SaveNextData = 0;
if (checkstring(cmdline, (unsigned char*)"SAVE")) {
SaveNextDataLine = NextDataLine;
SaveNextData = NextData;
return;
}
if (checkstring(cmdline, (unsigned char*)"RESTORE")) {
NextDataLine = SaveNextDataLine;
NextData = SaveNextData;
return;
}
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 05:15pm 22 Feb 2022
Copy link to clipboard 
Print this post

  matherp said  ... Implemented ...


LOL, thanks for doing this Peter.

Will incorporate in the next alpha for MMB4L, though that is some time away.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 05:21pm 22 Feb 2022
Copy link to clipboard 
Print this post

  Quote  Will incorporate in the next alpha for MMB4L, though that is some time away.


You may need to tweak signed/unsigned and the static initialisation depending on whether ProgMemory is a constant or a variable. For the CMM2 it is:

static char* SaveNextDataLine = NULL;
static int SaveNextData = 0;
if (checkstring(cmdline, (char*)"SAVE")) {
SaveNextDataLine = NextDataLine;
SaveNextData = NextData;
return;
}
if (checkstring(cmdline, (char*)"RESTORE")) {
NextDataLine = SaveNextDataLine;
NextData = SaveNextData;
return;
}

   getargs(&cmdline, (MAX_ARG_COUNT * 2) - 1, ",");                // getargs macro must be the first executable stmt in a block
   if(SaveNextDataLine == NULL)SaveNextDataLine = ProgMemory;
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4251
Posted: 05:51pm 22 Feb 2022
Copy link to clipboard 
Print this post

Thanks Peter, I'm sure I will figure it out.

I've noticed that in general you've been having fun and games with char signedness. With GCC you can tell the compiler whether unqualified chars should be treated as unsigned or signed, I've done the former in MMB4L and been removing qualifiers where I encounter then, seems to be working for me.

YMMV but I'm not sure about using static function variables for this piece of state, it makes it difficult to "zero" out between RUNs.

Best wishes,

Tom
Edited 2022-02-23 03:59 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 05:59pm 22 Feb 2022
Copy link to clipboard 
Print this post

  Quote  With GCC you can tell the compiler whether unqualified chars should be treated as unsigned or signed,


It has been a complete nightmare under C++ on VS2022

With your default every strlen, strcpy etc. would give a hard error because they only accept (char*)
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 572
Posted: 08:37pm 22 Feb 2022
Copy link to clipboard 
Print this post

hi matherp,

can we have a mask color for the blit command?

such like :
option mask color = &hxyz
can we have &B101 for the blit command which will not copy the mask color .
gtx
Plasma
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 08:47pm 22 Feb 2022
Copy link to clipboard 
Print this post

matherp, could you implement the OPTION DEGREE? This will help me a lot to keep the same source for the Into the Darkness to the MMBasic for Windows and CMM2 simultaneously.
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 374
Posted: 08:51pm 22 Feb 2022
Copy link to clipboard 
Print this post

Tested a7 for MM.INFO.
-MM.INFO(FILESIZE) gives syntax error
-MM.INFO(WRITEPAGE) gives syntax error
-MM.INFO(ERRMSG) crashes the program. Initially it was Ok, but now several restarts and crashes. In fact crashes every time now.

Simple testprogram. I had to comment out the lines that gave errors in order to complete the tests.
?"SOUND: ";
?MM.INFO(SOUND)
?"MAX PAGES: ";
?MM.INFO(MAX PAGES)
?"PAGE ADDRESS: ";
'?MM.INFO(PAGE ADDRESS)
?"FRAMEBUFFER: ";
?MM.INFO(FRAMEBUFFER)
?"DIRECTORY: ";
?MM.INFO(DIRECTORY)
?"EXISTS FILE: ";
'?MM.INFO(EXISTS FILE)
?"EXISTS DIR: ";
'?MM.INFO(EXISTS DIR)
?"OPTION AUTORUN: ";
?MM.INFO(OPTION AUTORUN)
?"OPTION EXPLICIT: ";
?MM.INFO(OPTION EXPLICIT)
?"OPTION BASE: ";
?MM.INFO(OPTION BASE)
?"PROGRAM: ";
?MM.INFO(PROGRAM)
?"AUTORUN: ";
?MM.INFO(AUTORUN)
?"DEVICE): ";
?MM.INFO(DEVICE) ' (same as MM.DEVICE$)
?"DEFAULT PATH: ";
?MM.INFO(DEFAULT PATH)
?"VERSION: ";
?MM.INFO(VERSION) ' (same as MM.VER)
?"VARCNT: ";
?MM.INFO(VARCNT)
?"CURRENT: ";
?MM.INFO(CURRENT)
?"FONTWIDTH: ";
?MM.INFO(FONTWIDTH)
?"FONTHEIGHT: ";
?MM.INFO(FONTHEIGHT)
?"FILESIZE: ";
'?MM.INFO(FILESIZE)
?"SYNTAX ERROR"
?"FONTCOUNT: ";
?MM.INFO(FONTCOUNT) ' (how many chars are available in current font)
?"WIDTH: ";
?MM.INFO(WIDTH)
?"HEIGHT: ";
?MM.INFO(HEIGHT)
?"HPOS: ";
?MM.INFO(HPOS)
?"VPOS: ";
?MM.INFO(VPOS)
?"FCOLOUR: ";
?MM.INFO(FCOLOUR)
?"BCLOUR: ";
?MM.INFO(BCOLOUR)
?"FRAMEH: ";
?MM.INFO(FRAMEH)
?"FRAMEV: ";
?MM.INFO(FRAMEV)
?"WRITEPAGE: ";
'?MM.INFO(WRITEPAGE)
?"syntax error"
?"FONT: ";
?MM.INFO(FONT)
?"ERRNO: ";
?MM.INFO(ERRNO)
?"ERRMSG: ";
'?MM.INFO(ERRMSG)
?"CRASHES THE PROGRAM"
?"OPTION BREAK: ";
?MM.INFO(OPTION BREAK)

end


Regards Fred
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 374
Posted: 08:57pm 22 Feb 2022
Copy link to clipboard 
Print this post

Sorry forgot the outputs:
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3998
Posted: 09:36pm 22 Feb 2022
Copy link to clipboard 
Print this post

  matherp said  
  Quote  With GCC you can tell the compiler whether unqualified chars should be treated as unsigned or signed,


It has been a complete nightmare under C++ on VS2022

With your default every strlen, strcpy etc. would give a hard error because they only accept (char*)

I use typedef to get

uchar  (an unsigned char) - usually just an 8-bit item, often not a character

schar  (a signed char) - hardly ever used

char  (don't care) - commonly actually is a character

Seems to survive porting well.

OTOH I don't tend to be porting existing code written by someone else.

I wonder if you could use C++ overloading to make strlen(unsigned char *) the same as strlen(char *).

John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10066
Posted: 10:32pm 22 Feb 2022
Copy link to clipboard 
Print this post

MM.INFO(FILESIZE) gives syntax error
-MM.INFO(WRITEPAGE) gives syntax error


Perhaps try specifying a filename or directory name in the function?

  Quote  MM.INFO(ERRMSG)


Shouldn't crash of course but calling it before there is an error makes no sense

  Quote  can we have a mask color for the blit command?

There is one - BLACK  I'm not implementing changes to the code that aren't on the CMM2 except where absolutely required by the architecture
Edited 2022-02-23 08:36 by matherp
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 572
Posted: 11:10pm 22 Feb 2022
Copy link to clipboard 
Print this post

Ah , whats will do the trick , need only a bit precalculation. The for the hint
Plasma
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 715
Posted: 01:45am 23 Feb 2022
Copy link to clipboard 
Print this post

*********** W O R K S  O N  R A S P B E R R Y  P I **************

Box86 / Wine  ( FOR without NEXT problem though )


my site
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3309
Posted: 01:50am 23 Feb 2022
Copy link to clipboard 
Print this post

  hitsware2 said  FOR without NEXT problem though


for x = 1 to 3: ?x: next
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 715
Posted: 02:06am 23 Feb 2022
Copy link to clipboard 
Print this post

  lizby said  
  hitsware2 said  FOR without NEXT problem though


for x = 1 to 3: ?x: next


A new paradigm  ?
my site
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3309
Posted: 02:30am 23 Feb 2022
Copy link to clipboard 
Print this post

  hitsware2 said  A new paradigm  ?

Not sure what you're saying. The error you get with FOR on the command line and no NEXT is the same for MMBasic on any device.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 715
Posted: 02:52am 23 Feb 2022
Copy link to clipboard 
Print this post

Duh ..... How do I get to the editor ?

my site
 
KD5ZXG
Regular Member

Joined: 21/01/2022
Location: United States
Posts: 53
Posted: 03:27am 23 Feb 2022
Copy link to clipboard 
Print this post

Edit now requires a file name.

Because numbered and un-numbered lines are both allowed, reliably positioning any new line requires either the editor or perfectly sequential entry of the whole shebang while some option to autosave is turned on, I forget exactly how.

Your line 10 was immediately executed and not saved. Which is why you never got the chance to follow up with a line 20 and maybe NEXT x.
Edited 2022-02-23 13:29 by KD5ZXG
 
     Page 8 of 12    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025