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 : Z-MIM the Z-machine Interpreter for Colour Maximite 2
Page 2 of 3 | |||||
Author | Message | ||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1593 |
Tom, Have you considered porting your Zmachine to MMBasic for DOS/Windows? I suspect the CMM1 version should be very close if not actually able to run? I could reach a bigger audience. Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Hi Bill, Technically it is certainly possible, I suspect only the memory routines "mem_xxx.inc" would need changing; on the downside there is no POKE/PEEK in MMBasic for DOS, but on the upside it might have enough memory that you don't need a virtual memory implementation. Practically though I'm not sure there is any point for me to do it as there is nothing for me to learn in doing the port and if people want to play Z-machine games on Windows there is a much better implementation to use: Windows Frotz. If however somebody else wants to do that port then I'm happy to support their effort and would be delighted if they would allow me to include it (with due credit) in the distribution. To be honest I'm a little disappointed that nobody seems to have used it "in anger", but I'm not that surprised. I doubt there are more than a couple of dozen CMM2s in the wild at the moment, most of the people with them are developers, tinkerers or hardware folks, and playing old text adventures is a niche activity at the best of times. In any case it doesn't really matter since I had fun and learnt a lot writing it and whilst it isn't as flashy as Mauro's stuff it does give the CMM2 a good workout and has helped me shake out some of the bugs in the firmware. It may also be the only Z-Machine implementation in existence written in BASIC. I'm still actively working on the CMM1 port, or to be more accurate I'm writing (in MMBasic) a pre-processor / BASIC language manipulator that will automatically perform the necessary transformations on the code and might form the basis of a useful tool for other members of the community who want to do their development on the CMM2 itself instead of using MMEdit. Beyond that I'm thinking I might enhance the tool so it can transform from MMBasic to BBC BASIC-V and then I can get Z-MIM running on RISC OS where I'll probably look at replacing some of the routines with ARM A32 assembler. Perhaps ultimately bringing it full circle back to the CMM2 if we get "CFunction" support. Add to that enhancing the CMM2 implementation to support .z4 and .z5 format storys and various other related software projects I have ideas for (does anyone want a Z-Machine written in Forth?) not to mention trying to teach myself some hardware I think I've got enough to keep myself busy for a few years EDIT: I know you didn't ask for "my life story", but it feels useful to spell out some of my plans if only for myself. Best wishes, Tom Edited 2020-07-02 09:17 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3661 |
It looks as if it's fast enough on the CMM2 but the CMM1 not so. Profiling would help, probably, but the CMM1 is not going to help with that I suspect. Does it spend lots of time on the CMM1 in one of the VM routines / loading pages? I suppose a faster way to retrieve bytes, such as an external RAM chip, is needed there, big enough to do away with the SD card paged VM. John |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
The memory reading is the "hottest" part of the code. Running my benchmark example there are 32,000 Z-machine instructions processed (probably x5 as many "memory reads") but only 130 page-faults. I do not believe loading pages is a significant burden - I do need to switch to an LRU algorithm to determine which page to replace, but with only 130 page-faults that is only going to give a very modest performance boost. But even without a page fault the CMM1 implementation has to do a lot more for each memory read: 'CMM1 Function rb(a) Local pp,vp If a<BASE_STATIC Then rb=Peek(Var m(0),a):Exit Function vp=a\PAGE_SIZE pp=vp_to_pp(vp) ' vp_to_pp is an array not a function If pp=0 Then pp=mem_load(vp):pf=pf+1 rb=Peek(Var m(0),pp*PAGE_SIZE+(a Mod PAGE_SIZE)) End Function 1. PAGE_SIZE is a constant so I will be inlining that in the next version. 2. I also wonder what proportion of reads actually occur below BASE_STATIC (memory that is not paged), perhaps that is not the optimisation it would be in other languages. 3. And maybe pp and vp should be globals? vs. ' CMM2 Function rb(a) rb = Peek(Byte MAD + a) End Function Talk about using a hammer to crack a nut I don't think I'll be doing that for such a frivilous entertainment as playing text adventures. Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
So I hacked in those changes and the CMM1 went from 28.7 ZMIPS -> 28.9 ZMIPS This it alas typical of my attempts to optimise the code. I believe it's not because any particular part of it is unnecessarily slow, it's just that a significant proportion needs to be run very often and very quickly in the tight read/decode/execute loop. I think it possible that even if I had CFunctions I would have to replace the entire instruction loop to achieve anything significant. For the moment my best hope is to inline all the constants, reduce all the identifiers to 3 characters or less and eliminate the rest of the redundant whitespace. Watch this space, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3661 |
That's not many page faults. Maybe just the CFunction feature would be enough. John |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Hi Tom, I just received my CMM2 hardware a few days ago. I have played with your Z-MIM a bit now. It seems responsive and works well as far as I have tested. I had a question about the story file menu at the beginning. On my setup options 1-4 start with ._ and the samples and tutorial are listed each with a ._ prefix. These don't seem to work. Option 5 is missing from the menu, but will play miniZork if selected. Options 6-8 are the two samples and tutorial and these also seem to work. I am running MMBasic 5.05.04b1r Z-Mim version 3b1 I downloaded your zip file to the root of A: and unzipped it there. Also any hints on where to download more story files? -Carl -Carl |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Hi Carl, Thanks for taking an interest. Strange, that's not what I see and it's not like we should need to worry about having different hardware. Running a fresh "install" of Z-MIM I see only 4 options: Could you please post a photo of what you see? Also please run and post the output of: ls "A:\zmim\stories" > Also any hints on where to download more story files? The "zmim.pdf" included in the distribution lists stories that are legitimately downloadable from the internet. A little imagination may help you find others. Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
I swear, I'm not making this up! This is what I was seeing: Well, the mystery is solved at least partially. Apparently my MAC created the files with the ._ prefix when it unzipped the file structure. Not sure why the miniZork does not show up as option 5, but if you enter 5 at the prompt it does indeed play miniZork. Also, not sure why the ._ prefixed files were created in the first place. These files do not show up in the CMM2 file manager, but they apparently show up when ZMIM asks for the contents of the directory. I am using an old SD card that was formatted with FAT16 so it may have something to do with long filename support on FAT16 or something like that. Edit: The files apparently contain "metadata" used by MAC OSX and are "hidden" files. It's interesting that the CMM2 file manager seems to know not to show them but they are reported to ZMIM. I'm going to try formatting for FAT32 to see if the files are still created when I unzip the archive. Edited 2020-07-03 05:17 by Sasquatch -Carl |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Dear Carl, Thanks for the first Z-MIM bug report. - The issue with the missing "minizork.z3" is a bug in my table rendering code that I've now fixed and will be in the next beta. - For good measure I've also changed the code to ignore any files beginning "." since no legitimate .z3 will have such a prefix. Since this isn't a critical failure I'll probably wait until the weekend to package a new version. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Release 3 now available for download Excerpt from ChangeLog: Release 3: - Optimised the CMM2 implementation at '/zmim/zmim.bas'; this is approximately 15% faster than Release 2. - The unoptimised version, with readable source-code can still be found at '/zmim/src/main.bas' this is now slower than Release 2 because it uses an error checking memory implementation. - Added CMM1 implementation at '/zmim/zmim_cm1.bas' - currently, and probably forever, this is too slow to be playable but is included for completeness as the CMM1 was the original target for this project. - Fixed missing variable declaration in interactive debugger. - Minor updates to the README. As the release notes suggest, after 3 weeks working on it I don't think a Colour Maximite 1 version of Z-MIM is actually viable without CSub support. However I've included it in the download if anyone wants to give it a go; it is functional if excruciatingly slow. In addition if anyone wants a preview of (the limited capabilities of) my MMBasic Transcompiler then they should start by looking at "src/zmim_cm1.mbt" and "src/zmim_cm2.mbt" and then search the rest of the code for "directives" beginning '! (single-quote, exclamation mark). I hope to have a beta version available for download next weekend. Best wishes, Tom Edited 2020-07-12 07:01 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261 |
Yeah that’s a Mac thing and it won’t matter what file system you use. I know it’s annoyingly that they do that... |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
The file chooser in Z-MIM release 3 ignores files prefixed with a full-stop. Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
cosmic frog Senior Member Joined: 09/02/2012 Location: United KingdomPosts: 278 |
Hi Tom. Just trying out your Z-MIM on my CMM1 and getting this error- [1143] Chdir d$ Error: Cannot find or create directory Any ideas? I have all the files and folders on my sd card. Thanks. Dave. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Hi Dave, Interesting since 1143 doesn't appear to be a CHDIR statement. - Is zmim_cm1.bas installed in B:/zmim/ ? - Which release are you using? - Are you getting the Z-MIM ASCII art/title displayed or is it failing before that? Regards, Tom Edited 2020-07-14 22:01 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
What is the output from: PRINT MM.DRIVE$ If it is "A:" then try: DRIVE "B:" And see if Z-MIM runs then. If you do make this change then you may want to restore to: DRIVE "A:" afterwards. Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
cosmic frog Senior Member Joined: 09/02/2012 Location: United KingdomPosts: 278 |
I had it in a folder called "games" so I've now put it in the root and I'm getting a bit further. It now lets me select a story but gives this error- [1246] Open s$ for output As #2 ERROR: Invalid file or directory name The release is 3b1 MMBASIC 4.5C |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
It now lets me select a story but gives this error- [1246] Open s$ for output As #2 ERROR: Invalid file or directory name The release is 3b1 MMBASIC 4.5C OK that is a beta, there is a proper release 3 now, follow the link in my signature or download directly from https://github.com/thwill1000/zmim/releases/download/r3/zmim-r3.zip If you want to change the installation directory then edit "zmim_cm1.bas", line 1223 should be: ss$(0)="\zmim" You can change this to, for example: ss$(0)="\games\zmim" And it should work, though I have not tested that on the CMM1. Regards, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
cosmic frog Senior Member Joined: 09/02/2012 Location: United KingdomPosts: 278 |
It now lets me select a story but gives this error- [1246] Open s$ for output As #2 ERROR: Invalid file or directory name The release is 3b1 MMBASIC 4.5C OK that is a beta, there is a proper release 3 now, follow the link in my signature or download directly from https://github.com/thwill1000/zmim/releases/download/r3/zmim-r3.zip If you want to change the installation directory then edit "zmim_cm1.bas", line 1223 should be: ss$(0)="\zmim" You can change this to, for example: ss$(0)="\games\zmim" And it should work, though I have not tested that on the CMM1. Regards, Tom Thanks for the mega-fast response. I will download and try. Thanks. Dave. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
You're welcome, just and indication of how mega-dull the day job is at the moment and how loosely I am supervised Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Page 2 of 3 |
Print this page |