ZXSimulator

Anything QL Software or Programming Related.
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: ZXSimulator

Post by bwinkel67 »

My last update had a major flaw with character codes (i.e. the CODE function was broken). That was due to me optimizing things a bit too much. Hopefully it works now:

zx.zip
(38.49 KiB) Downloaded 121 times

I was working on a YouTube video for my channel for December (#DOScember) and was looking at the original specs of the first IBM PC and how they mapped to the ZX81. On Sunday I decided to write a little MS-DOS simulator for the ZX81. Completely self-contained command interpreter that simulates DIR, CD, CLS, TYPE, MORE, plus typing in EXE, COM, and BAT files will run the programs. It's fake but fun to explore.

Code: Select all

10 REM %M%A%I%N
15 GOSUB 1050
20 LET D$=""
25 LET I$=""
30 LET K$=""
35 PRINT AT 21,0;"A";D$;">";I$;"\.. ";
40 LET K$=INKEY$
45 IF K$="" THEN GOTO 40
50 LET C=CODE K$
55 IF C=118 OR C=67 THEN GOSUB 1100
60 IF C=225 OR C=252 THEN LET K$=" "
62 REM PRINT AT 20,0;CODE K$;"   "
65 IF C=119 OR C=194 THEN GOTO 80
70 LET I$=I$+K$
75 GOTO 35
80 IF I$<>"" THEN LET I$=I$( TO LEN I$-1)
85 GOTO 35
1000 REM %C%L%E%A%R
1005 FAST
1010 CLS
1015 SLOW
1020 RETURN
1050 REM %B%O%O%T
1055 PRINT AT 0,0;"16 KB OK"
1060 PRINT AT 2,0;"MS-DOS VERSION 0.1"
1065 PRINT AT 3,0;"Micro Sinclair Operating System"
1070 PRINT AT 5,0;"SHIFT-S FOR SPACE KEY ON ZX81"
1075 RETURN
1100 REM %C%O%M%M%A%N%D
1105 PRINT AT 21,LEN I$+2+LEN D$;" ";
1110 IF I$="" THEN GOTO 1140
1115 FOR I=1 TO LEN I$
1120 IF I$(I)=" " THEN NEXT I
1125 FOR J=LEN I$ TO 1 STEP -1
1130 IF I$(J)=" " THEN NEXT J
1135 LET I$=I$(I TO J)
1140 LET L=LEN I$
1145 SCROLL
1150 LET D=0
1155 LET A$=""
1160 LET T$=""
1165 LET N$="?"
1170 GOSUB 1200
1175 LET I$=""
1180 LET K$=""
1185 IF N$<>"?" THEN LET D$=N$
1190 RETURN
1200 REM %P%A%R%S%E
1205 IF I$="" THEN RETURN
1210 FOR I=1 TO L
1215 IF I$(I)<>" " THEN NEXT I
1220 LET C$=I$( TO I-1)
1225 IF I>L THEN GOTO 1245
1230 FOR J=I TO L
1235 IF I$(J)=" " THEN NEXT J
1240 LET A$=I$(J TO )
1245 IF C$<>"DIR" THEN GOTO 1270
1250 IF (A$="DOS" AND D$="") OR (A$="" AND D$=":DOS") THEN GOTO 1400
1255 IF (A$="MISC" AND D$="") OR (A$="" AND D$=":MISC")  THEN GOTO 1500
1260 IF A$="" AND D$="" THEN GOTO 1600
1265 GOTO 1380
1270 IF C$<>"CD" THEN GOTO 1300
1275 IF A$="DOS" AND D$="" THEN LET N$=":DOS"
1280 IF A$="MISC" AND D$="" THEN LET N$=":MISC"
1285 IF A$=".." THEN LET N$=""
1290 IF A$="" OR N$<>"?" THEN RETURN
1295 GOTO 1380
1300 IF C$<>"MORE" AND C$<>"TYPE" THEN GOTO 1350
1305 IF A$="CARD.TXT" AND D$=":MISC" THEN LET T$="HAPPY HOLIDAYS TO ALL"
1310 IF A$="CONTACTS.LST" AND D$=":MISC" THEN LET T$="SANTA CLAUS\. KRIS KRINGLE"
1315 IF A$="LETTER.TXT" AND D$=":MISC" THEN LET T$="DEAR SIRS,\. \. I HOPE ALL IS WELL WITH YOU.\. KINDLY RESPOND TO MY INQUIRY.\. \. SINCERELY,\. \. CLIVE"
1320 IF A$="AUTOEXEC.BAT" AND D$=":DOS" THEN LET T$="ECHO ON"
1325 FOR I=1 TO LEN T$
1330 IF T$(I)<>"\. " THEN PRINT T$(I);
1335 IF T$(I)="\. " THEN SCROLL
1340 NEXT I
1345 IF T$<>"" THEN GOTO 1385
1350 IF A$<>"" THEN GOTO 1380
1355 IF C$="CLS" THEN GOTO 1000
1360 IF (C$="COMMAND" OR C$="COMMAND.COM") AND D$=":DOS" THEN RETURN
1365 IF (C$="AUTOEXEC" OR C$="AUTOEXEC.BAT") AND D$=":DOS" THEN GOTO 1700
1370 IF (C$="XMAS" OR C$="XMAS.EXE") AND D$=":MISC" THEN GOTO 1800
1375 IF (C$="SHOOTER" OR C$="SHOOTER.EXE") AND D$=":MISC" THEN GOTO 1900
1380 PRINT AT 21,0;"BAD COMMAND: "+C$
1385 SCROLL
1390 SCROLL
1395 RETURN
1400 REM %D%I%R% %D%O%S
1405 SCROLL
1410 PRINT " DIRECTORY OF A:DOS"
1415 SCROLL
1420 SCROLL
1425 PRINT "COMMAND  COM      240 01-10-1982"
1430 SCROLL
1435 PRINT "AUTOEXEC BAT        9 01-10-1982"
1440 SCROLL
1445 PRINT "   2 FILE(S)    6267 BYTES FREE"
1450 SCROLL
1455 SCROLL
1460 RETURN
1500 REM %D%I%R% %M%I%S%C
1505 SCROLL
1510 PRINT " DIRECTORY OF A:MISC"
1515 SCROLL
1520 SCROLL
1525 PRINT "CARD     TXT       23 01-10-1982"
1530 SCROLL
1535 PRINT "XMAS     EXE      704 01-10-1982"
1540 SCROLL
1545 PRINT "CONTACTS LST       27 01-10-1982"
1550 SCROLL
1555 PRINT "LETTER   TXT       98 01-10-1982"
1560 SCROLL
1565 PRINT "SHOOTER  EXE      824 01-10-1982"
1570 SCROLL
1575 PRINT "   5 FILE(S)    6267 BYTES FREE"
1580 SCROLL
1585 SCROLL
1590 RETURN
1600 REM %D%I%R
1605 SCROLL
1610 PRINT " DIRECTORY OF A:"
1615 SCROLL
1620 SCROLL
1625 PRINT "DOS         <DIR>     01-10-1982"
1630 SCROLL
1635 PRINT "MISC        <DIR>     01-10-1982"
1640 SCROLL
1645 PRINT "   2 FILE(S)    6267 BYTES FREE"
1650 SCROLL
1655 SCROLL
1660 RETURN
1700 REM %A%U%T%O%E%X%E%C
1705 PRINT "ECHO ON"
1710 SCROLL
1715 RETURN
1800 REM %X%M%A%S
1805 GOSUB 1000
1810 PRINT AT 21,0;"PRESS Q TO QUIT."
1815 LET X=1
1820 LET A$="\:'\:'\: \:'\' \:'\: \:'\: \: \:  \:'\' \: \: \:'\: \: \:'\' \':\' \:'\:'\: \:'\: \:'\'    "
1825 LET B$="\: \: \: \:. \:.\: \:.\: \':\'  \:  \:.\: \:.\: \: \:.\. \ : \: \: \: \:.\: \:.\.   "
1830 LET C$="\:  \: \:.\. \:'\. \:'\. \ :  \:.\. \: \: \:'\. \: \..\: \ : \:  \: \: \: \..\:    "
1835 PRINT AT 8,0;A$(X TO 32);A$(1 TO X-1);B$(X TO 32);B$(1 TO X-1);C$(X TO 32);C$(1 TO X-1)
1840 PRINT AT 9,0;B$(X TO 32);B$(1 TO X-1)
1845 PRINT AT 10,0;C$(X TO 32);C$(1 TO X-1)
1850 LET X=X+1
1855 IF X>31 THEN LET X=1
1860 FOR I=1 TO 10
1865 NEXT I
1870 IF INKEY$="Q" THEN GOTO 1000
1875 GOTO 1835
1900 REM %S%H%O%O%T%E%R
1902 GOSUB 1000
1904 FOR Z=0 TO 25
1906 PLOT Z,0
1908 PLOT Z,25
1910 PLOT 25,Z
1912 PLOT 0,Z
1914 NEXT Z
1916 LET P=1
1918 LET S=0
1920 PRINT AT 4,0;"Q TO QUIT"
1922 PRINT AT 5,0;"<-5 ->8 F=0"
1924 PRINT AT 7,0;"SCORE:";AT 8,0;"AIM FOR:"
1926 FOR N=157 TO 165
1928 LET Q=INT (RND*11)*2+1
1930 LET R=INT (RND*20)+3
1932 PRINT AT 21-INT (R/2),1+INT (Q/2);CHR$ N
1934 PRINT AT 8,9;CHR$ N
1936 FOR Z=0 TO 25
1938 UNPLOT P,1 
1940 LET P=P+(INKEY$ ="8")-(INKEY$ ="5")
1942 PLOT P,1
1944 IF INKEY$ ="Q" THEN GOTO 1000
1946 IF INKEY$ <>"0" THEN GOTO 1960
1948 IF P=Q+1 OR P=Q+2 THEN LET S=S+1
1950 FOR Z=2 TO 24
1952 PLOT P,Z
1954 NEXT Z
1956 FOR Z=2 TO 24
1958 UNPLOT P,Z
1960 NEXT Z
1962 PRINT AT 7,7;S
1964 NEXT N
1966 PRINT AT 7,10;"END"
1968 PAUSE 600
1970 GOTO 1000
...and will run on an original ZX81 with 16K RAM (it's only about 5K in size). I might compile it to make it run a bit quicker. Though the shooter game only works well on original ZX81 speed. Here's a .P file that I created from the above BASIC -- MS for Micro Sinclair:

msdos_p.zip
(2.33 KiB) Downloaded 116 times


User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: ZXSimulator

Post by bwinkel67 »

Someone pointed out the original MS-DOS used TYPE not MORE...so I added both to the above BASIC and p file. The change was simply adding an AND condition to an IF (I know it says if it's not MORE and not TYPE, but since ZX81 BASIC doesn't have code blocks, that's a way to do it):

Code: Select all

1300 IF C$<>"MORE" AND C$<>"TYPE" THEN GOTO 1350
Yes, yes, I get that MORE works a little different as it pauses after a full page but all the simulated files are short so it never gets to that.

Btw, anyone every play with ZX81 RAM Disk Operating System (ROS) -- I saw RWAP comment on it on a different forum about 15 years ago. I've played with it on an emulator and it's cool but a bit strange. Don' t know what its use would have been as it seems a very self-contained environment (i.e. I'm not sure what an executable program would look like in ROS). Just curious since I've always wondered if the ZX81 ROM could have been replaced by a completely different OS like the QL does with Minerva vs JS, etc...


didier
ROM Dongle
Posts: 11
Joined: Thu Aug 31, 2017 4:51 pm

Re: ZXSimulator

Post by didier »

hello everyone

excuse me for my english .. i am french

i am looking for the zxsimulator program NOT zipped (with all the files not zipped (not compressed) ...

where can i find this?

thank you very much

didier


User avatar
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: ZXSimulator

Post by tofro »

bwinkel67 wrote: Thu Oct 17, 2024 7:30 pm Don' t know what its use would have been as it seems a very self-contained environment (i.e. I'm not sure what an executable program would look like in ROS). Just curious since I've always wondered if the ZX81 ROM could have been replaced by a completely different OS like the QL does with Minerva vs JS, etc...
Well, there was at least the AZMIC ROM that turned the ZX81 into a pretty slick development platform for Z80 assembly (but didn't have a GUI).

Also, at least two implementations of Forth in ROM, one of them h4th, the other, I think free4th. And a number of more or less original ZX81 ROMs that weeded out some errors (just like Minerva does for the QL) and implemented speed-ups, like the "Shoulders of Giants"-ROM


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: ZXSimulator

Post by bwinkel67 »

didier wrote: Thu Dec 19, 2024 2:07 pm hello everyone

excuse me for my english .. i am french

i am looking for the zxsimulator program NOT zipped (with all the files not zipped (not compressed) ...

where can i find this?

thank you very much

didier
Hi, maybe this is a bad English translation, but if not Zipped, how would you expect to get it? On MDV? I can probably create an MDV version of it.


didier
ROM Dongle
Posts: 11
Joined: Thu Aug 31, 2017 4:51 pm

Re: ZXSimulator

Post by didier »

good evening

i have big problems with my unzipper ...

that's why i wanted the original and unzipped files of zxsimulator to be able to install it on my ql (via an sd card and my vdrive)

thanks

didier

'excuse for my english'


Derek_Stewart
Font of All Knowledge
Posts: 4653
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: ZXSimulator

Post by Derek_Stewart »

didier wrote: Thu Dec 19, 2024 8:15 pm good evening

i have big problems with my unzipper ...

that's why i wanted the original and unzipped files of zxsimulator to be able to install it on my ql (via an sd card and my vdrive)

thanks

didier

'excuse for my english'
what unzipper are you using?


Regards,

Derek
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: ZXSimulator

Post by bwinkel67 »

didier wrote: Thu Dec 19, 2024 8:15 pm i have big problems with my unzipper ...

It's a bit complicated for new users. You have to get the unzip executable to first work, which takes some thought. You can use your favorite emulator -- I recommend more memory and speed -- and use the JOB2BAS zip version to turn it into an executable.

https://dilwyn.theqlforum.com/arch/unzip541_bas

Once you have that you can start unzipping executables and move them to MDV images. When I get some time I'll create an MDV of ZXSimulator. Come to think of it, I may also create an MDV of zip and unzip which may make that a little simpler for any new users. Unfortunately I have a deadline before Monday so I can't get to it quickly.

[Edit: I see that Dilwyn also has a BASIC program that will restore the file header of the version 5.32 of the zip executable so there, you just unzip everything in a directory under Windows, add this BASIC program, and in Q-emulator (or QLAY or QPC), just run it to create your working unzip exec]

Code: Select all

100 REMark restore Unzip v5.32 executable file header
110 :
120 fl = 108460 : REMark length in bytes of this version
130 ds = 51270 : REMark dataspace in bytes of this version
140 :
150 REMark reserve some space to "fix" the file in memory
160 REMark use ALCHP in place of RESPR in next line if you have ALCHP
170 base = RESPR(108460) : REMark file length of Unzip
180 :
190 REMark change 'flp1_' to drive name required for loading UNZIP
200 LBYTES flp1_unzip,base
210 :
220 REMark change 'ram1_' to drive name required for saving UNZIP
230 SEXEC ram1_unzip,base,fl,ds
240 :
250 REMark if you used ALCHP in line 150 above,remove REMark in next line
260 REMark RECHP base
270 PRINT #0,'Program finished.'


Derek_Stewart
Font of All Knowledge
Posts: 4653
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: ZXSimulator

Post by Derek_Stewart »

Hi,

why not use a MDV image that can loaded from a Vdrive?


Regards,

Derek
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: ZXSimulator

Post by bwinkel67 »

Derek_Stewart wrote: Fri Dec 20, 2024 12:31 pm Hi,

why not use a MDV image that can loaded from a Vdrive?
There currently is no MDV image for ZXSimulator. Is there one for zip/unzip?


Post Reply