Make P files auto-run...

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Make P files auto-run...

Post by sirmorris »

... it's easy enough; put a SAVE line in the BASIC and the program will continue from the line after the save statement when it loads.

What I wanted was a way to avoid having to edit & re-save a program when I write C in z88. I hacked ZX81LIST by Jack Raats to make a program which alters the NEXTLINE system variable in a P file. You tell it which line number you want to execute on LOAD, it scans the BASIC, finds the address of the line, and pops it into the NEXTLINE system variable.

It's easy to put this in my build script and makes the load/run cycle quicker. So all-in-all it's not that useful but it may be that someone else may find it saves a little bit of effort.

Source and windows exe attached.
Attachments
PAR.zip
(34.15 KiB) Downloaded 269 times
User avatar
Paul
Posts: 1511
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Make P files auto-run...

Post by Paul »

A program similar to this could be used to stop a program from autostarting showing the Adress & line number that would continue and resetting the system variable, wouldn't it?
Could become a cracking tool. Although there are different ways of doing this, it would be easier to do this way.
If it were in one progam this would be the ultimate autostart/autostop tool ;)
In theory, there is no difference between theory and practice. But, in practice, there is.
David G
Posts: 387
Joined: Thu Jul 17, 2014 7:58 am
Location: 21 North, 156 West

Re: Make P files auto-run...

Post by David G »

P-file Auto Run

What an elegant program. It's small, fast, and does only what it needs to do


Coming from a Windows perspective, I am used to code being consumer-friendly, so there is a lot of code doing non-essential features such as checking to see if it's really a P file, is it well formed, etc. When I first tried PAR i mistakenly opened the wrong P file (actually not a P file) and it filled screen after screen with garbage characters. But so what? the screen is infinite. I simply BREAKed tried again and it worked perfectly. It's refreshing to see just the code needed


It can be compiled using Visual Studio 2022 free edition, by opening a Console App template, then paste the source code in
* One change to source code: change "char *" to "const char*". This is the newer C++ standard I'm guessing?
VS project configuration changes
* add _CRT_SECURE_NO_WARNINGS to C/++|Preprocessor|Preprocessor Definitions (this is to prevent the error about unsafe use of the old fread function)
* (OPTIONAL) change "General|Platform Toolset" to "Visual Studio 2017 - Windows XP (v141_xp)" (to allow it to work with Windows XP)
* change "General|Use of MFC" to "Use MFC in a Static Library"

Upon sucessfully compiling, I immediately thought, why is my version so huge? Like nearly a megabyte compared to the original 61 KB. I suspect it is because of the static linking, which allows the exe to run on any machine without installing the newer VC Runtime files

Jack's original ZX81LIST.EXE (or at least the one I find, at zx81.de) is only 7 KB and looks to be a pure MZ executable (MS-DOS only). Sir Morris's PAR.EXE (P Auto Run) is a NE excecutable (Win32 console app*) but it still only 61 KB. I compiled the source using VS2022 and the result was 846 KB! That's a lot of unneeded staticly-linked code, perhaps the entirety of the standard library even though PAR uses maybe four library functions

*A Win32 console app looks and acts like a DOS exe, but can have more features possible, with full access to the Windows API. Win32 can run on Windows 95, Windows XP, Windows 10, etc.

To run a MS-DOS exe on newer Windows requires DOSBOX or something, as 16-bit MS-DOS support is now historical. For example, Jack Raat's program won't run on my Windows 8.1 machine
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Make P files auto-run...

Post by XavSnap »

HI,

Whith TIM-GCC 4.9.2 w32-w64:
par.JPG
par2.JPG
PAR.zip
(112.32 KiB) Downloaded 89 times
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Make P files auto-run...

Post by dr beep »

Paul wrote: Tue Jan 31, 2012 7:41 am A program similar to this could be used to stop a program from autostarting showing the Adress & line number that would continue and resetting the system variable, wouldn't it?
Could become a cracking tool. Although there are different ways of doing this, it would be easier to do this way.
If it were in one progam this would be the ultimate autostart/autostop tool ;)
That won't work on my games since the BASIC is placed over the sysvar and you would lose the BASIC-line.

The compiler needs to add the sysvar, so why not add my sysvar settings and you have autostart.
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Make P files auto-run...

Post by XavSnap »

Hi,

It remembers me that: viewtopic.php?p=30172#p30172

An auto-load on the PRT_BUFF @ 16393.
I had to move the first BASIC line to 16393 and RUN the BASIC NXT_LINE in this aera.
All lines before 16509 are ignored by a standard LIST and erased by a LPRINT.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
David G
Posts: 387
Joined: Thu Jul 17, 2014 7:58 am
Location: 21 North, 156 West

Re: Make P files auto-run...

Post by David G »

XavSnap wrote: Sun Jul 17, 2022 3:08 amWhith TIM-GCC 4.9.2 w32-w64
Is that TDM-GCC? I see it on SourceForge. Or did you use Dev-C++ IDE?

The exes are much smaller
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Make P files auto-run...

Post by XavSnap »

Hi David,

I usually use "DEV C++" to compile the C++ codes.

This IDE is a front-end compiler, to compile the code with the TIM-GCC 4.9.2 (w32-w64) executable codes.
"DEV C++" compile the C++ code and add Windows header (infos and icon resource) to the file.

But DEV C++ don't compiler the code using its own library and compiler like .NET, Borland C++ (?).
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
JoeBloggs
Posts: 3
Joined: Thu Jul 28, 2022 1:49 pm

Re: Make P files auto-run...

Post by JoeBloggs »

Hi all,
I'm new here so please bear with me as I get to know you all and how you like things done. Let me know if I do something wrong, I'll learn from it.

I am using the EightyOne emulator. Some of my personal old .p programs that originally autorran on the ZX81 using a Save command in line 1, and the program itself starting from line 2 afterwards. When I Load the program, after loading it stops with a 0/0 report. I then have to do a manual Goto 2 after which it Runs normally.
I have tried to do a new save of the program by doing using Run from line 1, and also Goto Line 1, the program completes the Save, and continues on as it should from Line 2.

However, the newly Saved file still doesn't autorun! I have tried many different Saves all with no solution.

I searched for and found this discussion under the title I too am looking for an answer to. I saved the PAR.exe file on this message (by sirmorris Mon Jan 30, 2012 10:54 pm), but could not get it to do anything (I had to stop my anti-virus from stealing it away first).

So checked the messages that followed, and tried the second version by XavSnap Sun Jul 17, 2022 2:08 am. However, it too would not do anything after starting it (again after retrieving it from the Anti-Virus which seem not to like either version).
I had opened a new folder and copied all the files into it for each version. The second version zip contains a par_w32.exe, and a par_w64.exe so should run under Windows (10) 64bit.

What am I missing here?

Any help would be appreciated, even if its pointing to a different solution.

Thanks.
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Make P files auto-run...

Post by XavSnap »

Hi JoeBloggs,

A single SAVE"MYPRG" will save your program as is, and will give a 0/0 on loaging.

Try to insert these lines to add the SAVE command in the BASIC listing:

Code: Select all

9998 SAVE"MYPROGRAM"
9999 RUN
And type RUN 9998

It will save the program, and the progam will autorun after a LOAD""

Have Fun.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply