Author Topic: Is there a Z-Machine interpreter for the CPC?  (Read 5225 times)

0 Members and 1 Guest are viewing this topic.

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 337
  • Country: fr
  • Liked: 268
  • Likes Given: 1
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #25 on: 22:22, 15 January 16 »
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

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1977
  • Likes Given: 4650
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #26 on: 23:07, 15 January 16 »
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

Offline pelrun

  • VK4CPC
  • Supporter
  • 6128 Plus
  • *
  • Posts: 569
  • Country: au
    • index.php?action=treasury
  • Liked: 294
  • Likes Given: 156
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #27 on: 08: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.

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 337
  • Country: fr
  • Liked: 268
  • Likes Given: 1
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #28 on: 10:36, 16 January 16 »
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.

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.153
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 959
  • Likes Given: 2130
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #29 on: 12:10, 16 January 16 »
Isn't a 16Mhz CPC called PcW16? :D

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1977
  • Likes Given: 4650
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #30 on: 02:00, 18 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

Offline GeoffB17

  • 6128 Plus
  • ******
  • Posts: 532
  • Country: gb
  • PCW since '85
  • Liked: 114
  • Likes Given: 7
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #31 on: 03:55, 18 January 16 »
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

Offline pelrun

  • VK4CPC
  • Supporter
  • 6128 Plus
  • *
  • Posts: 569
  • Country: au
    • index.php?action=treasury
  • Liked: 294
  • Likes Given: 156
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #32 on: 07:28, 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.

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 337
  • Country: fr
  • Liked: 268
  • Likes Given: 1
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #33 on: 08:09, 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.

Offline khaz

  • 464 Plus
  • *****
  • Posts: 490
  • Country: fr
  • Liked: 248
  • Likes Given: 68
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #34 on: 05:31, 19 January 16 »
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.

Offline MiguelSky

  • 464 Plus
  • *****
  • Posts: 345
  • Country: es
    • CPCGamesCD
  • Liked: 155
  • Likes Given: 312
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #35 on: 13:23, 19 January 16 »
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.)
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.

Offline khaz

  • 464 Plus
  • *****
  • Posts: 490
  • Country: fr
  • Liked: 248
  • Likes Given: 68
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #36 on: 15:16, 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:

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1977
  • Likes Given: 4650
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #37 on: 19:13, 19 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

Offline MiguelSky

  • 464 Plus
  • *****
  • Posts: 345
  • Country: es
    • CPCGamesCD
  • Liked: 155
  • Likes Given: 312
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #38 on: 19:49, 19 January 16 »
You 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.

Offline khaz

  • 464 Plus
  • *****
  • Posts: 490
  • Country: fr
  • Liked: 248
  • Likes Given: 68
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #39 on: 03:50, 04 February 16 »
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

Offline PulkoMandy

  • 464 Plus
  • *****
  • Posts: 337
  • Country: fr
  • Liked: 268
  • Likes Given: 1
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #40 on: 08:13, 04 February 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

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 530
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 531
  • Likes Given: 268
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #41 on: 20:11, 04 February 16 »
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 ?
« Last Edit: 22:13, 11 February 16 by SRS »

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 530
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 531
  • Likes Given: 268
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #42 on: 19:28, 16 May 16 »
*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

Offline khaz

  • 464 Plus
  • *****
  • Posts: 490
  • Country: fr
  • Liked: 248
  • Likes Given: 68
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #43 on: 15:14, 17 May 16 »
Quote
The 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.

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 530
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 531
  • Likes Given: 268
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #44 on: 22:46, 29 May 19 »
BUMP
No one interested and able to port this to CPC ?
I just can't :(

Offline Nich

  • Supporter
  • 6128 Plus
  • *
  • Posts: 658
  • Country: gb
  • CPC Game Reviews webmaster
    • CPC Game Reviews
  • Liked: 500
  • Likes Given: 611
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #45 on: 22:32, 07 July 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.

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.332
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2251
  • Likes Given: 3477
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #46 on: 15:41, 08 July 19 »
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

Offline khaz

  • 464 Plus
  • *****
  • Posts: 490
  • Country: fr
  • Liked: 248
  • Likes Given: 68
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #47 on: 17:45, 10 July 19 »
Oooh, neat!

Offline ||C|-|E||

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 1.787
  • Country: gb
    • index.php?action=treasury
    • Mundo CPC
  • Liked: 1005
  • Likes Given: 1017
Re: Is there a Z-Machine interpreter for the CPC?
« Reply #48 on: 22:15, 15 July 19 »
It is actually super cool to have something like that, super cool  :D