News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_khaz

Is there a Z-Machine interpreter for the CPC?

Started by khaz, 16:09, 09 January 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PulkoMandy

Even Zeugma from Linus Akesson (Zeugma, runs on C64) gave up on Z7 and later because they are too slow. It says they should be playable with a SuperCPU (at 20MHz), but the CPC doesn't have anything like that yet. But maybe the desire of CPC people to prove the C64 guys wrong can beat this? :D

TFM

Well, we got the CPC Booster (nice math co-cpu if encoded for it) and Albeiro for mass storage and Lenovo-Power-CPU support (see other thread). And since you (I guess) know what you're talking about. Let me ask this: What in your opinion is the most time consuming? (Sorry, I don't quite get it).  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

pelrun

The problem is actually that the Inform library that basically all the Inform-compiled games use does a LOT of computation . It doesn't matter if you optimise the hell out of your interpreter, there's still a maximum number of (virtual) instructions per second it can execute. If your interpreter does 500000 instructions per second, and the game needs to execute 20 million instructions for every game command, it's going to take 40 seconds no matter what.

PulkoMandy

The Z-Machine is a virtual machine just like Java for modern computers. There is even a C compiler for it (vbccz). So, what you get from the game files is a memory image you feed to the interpreter. You can always do some tricks to optimize your interpreter loop to death, but in the end there is still some overhead and you can't really optimize the game opcodes.
You would have to write a JIT that rewrite the game code on the fly to z80. Or, maybe easier for some games, get the Inform sources and write a compiler that targets the z80 directly, bypassing the Z-Machine completely.

robcfg


TFM

Quote from: pelrun on 07:59, 16 January 16
The problem is actually that the Inform library that basically all the Inform-compiled games use does a LOT of computation . It doesn't matter if you optimise the hell out of your interpreter, there's still a maximum number of (virtual) instructions per second it can execute. If your interpreter does 500000 instructions per second, and the game needs to execute 20 million instructions for every game command, it's going to take 40 seconds no matter what.


Glad that you don't exaggerate... ;-) Seriously how much virtual instructions can a game step need? It's 'just' and adventure. So per game step you will have about 20 or maybe 100. Real instructions will be way more of course.

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

GeoffB17

Well, I'd guess that the data is just badly organised.


In the earlier systems, there were not so many separate tables, and the tables were not so big.   Crude search techniques were OK.   v5 maybe has more tables and/or bigger, v8 certainly has MUCH more (the old version 3 files in the Infocom games were just over 100k, the two v8 games I was trying had 200k+ and 500k+).  If each 'action' required looking up in one table, with consequent searches in two or more other tables, all searches needed sequential search, that all adds time.   I'd guess no indexes, and main files not sorted/fixed length records, so better search methods NOT possible anyway.   So no ability to use binary chop search.   Keep the data as is, and rather than copy it to memory, create sorted indexes so you CAN do binary chop, would be a massive help.


Just for info, if you need to search a file of 500 'records', you'd need to do an average of 250 reads.   With binary chop you'd have a MAXIMUM of 9, but the data MUST be sorted.   And readable directly by 'record'.   If the data is NOT so tidy, then an index could be created that had regular records, sorted, each recprd having a pointer to the actual data in the main files, so you could access linked data in numerous files/tables in less time the original system could read 1 table.


If this is the case, then a better interpreter could still use the Inform created v8 'story' files??


Geoff

pelrun

Quote from: TFM on 01:00, 18 January 16
Seriously how much virtual instructions can a game step need? It's 'just' and adventure. So per game step you will have about 20 or maybe 100.


Writing massively inefficient code is easy. When you're three layers up, in a natural-language development environment (which Inform 7 is), it's very hard to tell that you're constantly invoking a bunch of very expensive operations. The tools are focused towards creative people writing adventures without necessarily being software developers, and not towards producing efficient binaries.

PulkoMandy

Quote from: GeoffB17 on 02:55, 18 January 16

If this is the case, then a better interpreter could still use the Inform created v8 'story' files??



This would require a very smart interpreter. What gets fed to the interpreter is not high level instructions like "search for word in table", but low level stuff like "get data at address", "increment address", etc. So you would need a lot of work to analyze this code, understand what it's trying to do, and replace it with a more efficient version.


If you have the Inform source files (not the generated Z-Machine bytecode), then yes, maybe you can write a new compiler that performs such optimizations. But if you have only the generated bytecode, I doubt there is much to be done from it. Or maybe manually, like some people do for z80 games.

khaz

I don't know if that would help, but I found a bunch of non-Infocom games playable on CPC CP/M

Index: if-archive/games/cpm Here I was able to play Colossal Cave Adventure B03 by copying the files on a disc in Winape and launching adv.com in CP/M. No slowdowns apart from the constant disc accesses, once I figure how to copy files into the RAM-drive it should entirely disappear.

Index: if-archive/games/amstrad Here are games specifically for AMSDOS. They are in the form of listings, probably not much could be used to make an interpreter. I haven't tried them as I don't know of an easy way to convert a listing.txt into a .BAS file (And I sure won't type the whole thing.)

The Z-Machine Standards Document All the Infocom v3 stories were ported to the CPC, through a CP/M executable. None of the v4 were, for some reason.

MiguelSky

Quote from: khaz on 04:31, 19 January 16I haven't tried them as I don't know of an easy way to convert a listing.txt into a .BAS file (And I sure won't type the whole thing.)
You can load in emulator with the Auto-type feature at WinAPE ana JavaCPC. A faster way is loading as a tape in CPCE, but the file needs be edited to change carriage returns.

khaz

Quote from: MiguelSky on 12:23, 19 January 16
You can load in emulator with the Auto-type feature at WinAPE ana JavaCPC. A faster way is loading as a tape in CPCE, but the file needs be edited to change carriage returns.

I tried that, and Winape goes crazy if the system isn't qwerty. the typing is also quite slow.
Another way to do it is to put the txt on a disc (with or without header), load"listing.txt , save"listing.bas . I don't know if it's an added convenience from the emulator or if it works on a real machine, but that's quite neat. And much faster than auto-type. You have to convert your line feed character to CR+LF if you're not using Windows though.

But it doesn't really matter, as the listings are not for the CPC, but for the Amstrad NC notebooks line  :laugh:

TFM

Quote from: pelrun on 06:28, 18 January 16
Writing massively inefficient code is easy. When you're three layers up,


You got a point there of course.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

MiguelSky

Quote from: khaz on 14:16, 19 January 16You have to convert your line feed character to CR+LF if you're not using Windows though.
Yes, by doing this, you can load the file as a tape directly (and activating Tape Bypass option).


Yes, I noticed, the files are not for CPC.

khaz

A bit of a bump, but on this page you can find PASCAL sources for a Z-machine. I'm not sure it's finished or even working on CP/M, the webpage (author?) isn't clear about it. It's a different program than the one previously discussed, so maybe it could be of some help?

Adventures
http://www.z80.eu/downloads/INF.ZIP

PulkoMandy

Quote from: khaz on 14:16, 19 January 16
load"listing.txt , save"listing.bas . I don't know if it's an added convenience from the emulator or if it works on a real machine, but that's quite neat.


It works on the real machine as well.
And the reverse conversion as well:


load"listing.bas"
save"listing.txt",a

SRS

#41
I took a look at the Pascal from no$cash. Well, my Pascal is lost somehwo :(

So is my C - could C specialist compile FROTZ for CPC (128k?) -> GitHub - DavidGriffith/frotz: Infocom-style interactive fiction player for Unix maybe ?

SRS

*bump*

ZXZVM: Porting

"From time to time, I've seen people discuss the lack of a version 5 Z-code interpreter for CP/M. And inevitable, someone points out that ZXZVM exists on the PCW, and reasons "surely it can't be that hard to port it to the CPC / Kaypro / Osborne / whatever platform we're discussing?""

SO, ASM-specialists that know how to do porting from spectrum to CPC and how to use banked memory - this is your chance :D

khaz

QuoteThe PCW front end makes no attempt at portability; it loads the entire story file into the PCW's RAMdisc, using direct hardware access to do so. (It also uses direct hardware access to redefine the font, but that's a less fundamental requirement).

hm

If all else fail, maybe the X-MEM could be used for this purpose. Limited compatibility, but still better than nothing.

SRS

BUMP
No one interested and able to port this to CPC ?
I just can't :(

Nich

Quote from: SRS on 20:46, 29 May 19
No one interested and able to port this to CPC ?
I just can't :(

It looks like @arnoldemu has managed to convert it:

http://www.cpc-power.com/index.php?page=detail&num=16439

I don't recall seeing any announcement about it on this forum - or anywhere else, for that matter - and I haven't tested it with any Inform files myself.

arnoldemu

Yes. I saw @SRS plea and I decided to have a go.
More info about the version and newer version is here:
http://www.cpcwiki.eu/index.php/Z-Machine
Bruno will update cpc-power soon.

I am thinking about making an X-MEM version running under AMSDOS. I did experiment with using extra memory under CPM+ but I couldn't find a free area to put some code in the base 64KB ram :(


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

khaz


||C|-|E||

It is actually super cool to have something like that, super cool  :D

arnoldemu

Just before Christmas I released a vew version. There is both a cpm and amsdos version. See the cpcwiki page or my games page cpcrulez or cpc power for the download.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod