Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:28 23 Apr 2024 Privacy Policy
Jump to

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 1 of 3    
Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 08:59pm 11 Jun 2020
Copy link to clipboard 
Print this post

Rather suprisingly I think this is ready for a public beta and I'd be interested to hear what you think ...

... other than "I hated text adventure games in the '80s and I still hate them now"

You can read about it in zmim.pdf

You can download it from the link in my signature - it's a google drive link.

Please let me know about all the horrendous show-stopping bugs that I have let through.

I'm especially interested to hear from anyone trying it on a VGA monitor. When I briefly tried it appeared that the last 2 characters of every line were being printed "off the screen" which I don't understand at all as I'm not doing anything more complex than calling PRINT. I don't think it is a monitor configuration issue because the built-in EDIT command doesn't show the same clipping.

Regards,

Tom
Edited 2020-06-12 07:13 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1350
Posted: 04:06am 12 Jun 2020
Copy link to clipboard 
Print this post

Hi Tom, I had a quick look in between other tasks, gee that brings back memories, really great work there.

You mentioned a screen wrapping issue and it is a problem, as you said, it uses Print so it should be fine as print wraps correctly, it's almost like the standard font is changes in the game. Hope you find the issue as it slows my reading speed down greatly.

Mike.
It's all too hard.
Mike.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 10:56am 12 Jun 2020
Copy link to clipboard 
Print this post

  Quote  When I briefly tried it appeared that the last 2 characters of every line were being printed "off the screen"


Are you using text, print, or print @ to output the text. Are you doing your own linewrap or letting MMBasic do it for you?
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 11:00am 12 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  When I briefly tried it appeared that the last 2 characters of every line were being printed "off the screen"


Are you using text, print, or print @ to output the text. Are you doing your own linewrap or letting MMBasic do it for you?


For this release I'm just calling PRINT and letting MMBasic handling everything as if it was the dumbest terminal in the world. There are "smarter" things that I want to do in the future, but dumb is (mostly) sufficient for now.

It's perplexing, but I can't say I've really had a dig into it yet, my guess is that PRINT is broken ... but that seems so unlikely so I suspect I'm just being thick.

Regards,

Tom
Edited 2020-06-12 21:01 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3650
Posted: 11:07am 12 Jun 2020
Copy link to clipboard 
Print this post

Just in case, remember PRINT adds a CR LF unless your final item is a semi-colon (;)

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 11:11am 12 Jun 2020
Copy link to clipboard 
Print this post

  JohnS said  Just in case, remember PRINT adds a CR LF unless your final item is a semi-colon (;)

John


Thanks, but I can't see how that could explain the loss of two characters off the right hand of the screen.

Peter, what MODE does EDIT run in?
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 11:17am 12 Jun 2020
Copy link to clipboard 
Print this post

Mode 1 but handles the screen totally differently

If you execute your program then Ctrl-C then type BOX 0,0,mm.hres,mm.vres you will see your text goes right to the right hand edge of the screen so the extra chars are definitely off the edge.

PS. Ctrl-C leaves the cursor on the status line. I fixed that and will include in next beta
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 11:20am 12 Jun 2020
Copy link to clipboard 
Print this post

Thanks Peter.

I'm not going to get a chance to poke at this until this evening at the earliest, but I think you (and Mike) are telling me that I'm not hallucinating or failing to setup my monitor correctly, and that there is a software (or firmware) issue to investigate.

Regards,

Tom
Edited 2020-06-12 22:10 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 07:20pm 12 Jun 2020
Copy link to clipboard 
Print this post

I loaded up Z-MIM and had a play. I successfully captured the butterfly too.

But some things don't seem to work for me.
(CMM2 vers 5.0503, zmim directory at root level)

If I use the file manager and select "zmim.bas" to run it, I get a "[3] Error: Could not find file"

If I type "ls", I see the contents of "A:/zmim" which consists of 4 directories and 4 files, including "zmim.bas"

If I "RUN "zmim"", I get the same error.

To run it, I need to "chdir "src"" and then "run "main""

Regarding the missing characters:
They are not off screen. I adjusted the horizontal size and position on my monitor but nothing extra appeared.

Also, the number of missing characters seems to be variable. Some lines appear to be missing 3 characters, some 2, some 1. There are also instances of a character missing at the start of a line, where the line above is blank.

(View the following with the window wide enough to prevent wrapping. I added "xx]" to the start of each line.)
01]Another useful command is "INVENTORY". It lets you know what objects you are carrying. Try it now.)
02]
03]>> i
04]You are empty-handed.
05]
06](Oh, well. You weren't anything to start with, but you might have been, so it's good to hav
07]checked. For convenience "I" is a short form of "INVENTORY" and "L" is a short form of "LOOK AROUND"
08].
09]
10]o move around, you use compass directions. For example, to walk to the east, you can type "WALK EAST
11]. The games often mention passages, tunnels, roads, and the like in descriptions, but these are ment
12]ed for descriptive purposes only. Let's try going east.)

Line  7: Nothing missing from end.
Line 10: One letter ("T") missing from the start, 1 from the end.
Line 11: 3 letters ("ion") missing from the end.

Very puzzling.
Visit Vegipete's *Mite Library for cool programs.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 07:29pm 12 Jun 2020
Copy link to clipboard 
Print this post

Hi vegipete,

Thanks for taking a look.

  vegipete said  But some things don't seem to work for me.
(CMM2 vers 5.0503, zmim directory at root level) ...


OK, is that the beta firmware? I'm still running 5.05.02. If you look at "zmim.bas", it contains one line, and I can't see why that wouldn't work. But I will certainly check.

  Quote  Regarding the missing characters:
They are not off screen. I adjusted the horizontal size and position on my monitor but nothing extra appeared ...


Good to have that confirmed.

If you check out the CMM2 bugs thread you'll see that Peter thinks it's memory corruption so I'm now trying to eliminate the problem being in my code rather than the firmware.

Regards,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 07:41pm 12 Jun 2020
Copy link to clipboard 
Print this post

I just tried a simple program:

a$ = "a long string, wider than the editor window, with a space character as the last one. "
b$ = "Another, different, long string, also ending with a space. "

for i = 1 to 20
 ? a$;
 ? b$;
next i

This more than filled the screen with a wall of text. But there were no missing characters. Characters wrapped to the next line exactly as you would expect them to. Is there any chance that the missing characters are lost when the text is read in from where ever it comes from? I can't imagine how that would affect loosing characters at the end of long lines but...?
Visit Vegipete's *Mite Library for cool programs.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 10:30pm 13 Jun 2020
Copy link to clipboard 
Print this post

Thanks "vegipete".

Turns out it was a firmware issue which Peter has kindly fixed in V5.05.03b1g.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 11:41pm 20 Jun 2020
Copy link to clipboard 
Print this post

Hello folks,

For anyone who is interested I have uploaded Z-MIM Release 2 to the link given in my signature. For best results please upgrade your firmware to 5.05.03b1r or later.

The addition of word-wrapping makes it easier on the eye and support for paging means it is possible to play very "wordy" stories on the VGA display.

The complete ChangeLog for this release is:

Release 2:
- Added word-wrapping
  - assumes 100 character wide console.
- Added paging, i.e. displays [MORE] prompt when more than one page of text is output between input prompts
  - assumes 50 character high console.
- Made execution approximately 15% faster.
- Changed startup so that console is now cleared before the story file starts executing.
- Changed console so that it only ever scrolls upwards and the input prompt is always at the bottom
  - this is the conventional behaviour for the console of a Z-machine implementation.
  - EXCEPTION: the initial selection of a story file and choosing whether to write a script.
- Changed console so that it recognises when a story is trying to clear the console and repond appropriately
  - the Z-machine provides no specific clear console instruction instruction so old z3 stories often just print 20-40 blank lines on the assumption that will be sufficient; as it probably was for a 1980s microcomputer.
- Fixed issue with Z-MIM changing the current working directory
  - it still does change it during operation but should now have restored it before it exits whether cleanly or due to an error or Ctrl-C.
- Fixed "Error: EXEC is not declared" when quitting after a 'restart'.
- Minor improvements to the interactive debugger.
- Cosmetic improvements to code and README.


Best wishes,

Tom
Edited 2020-06-21 10:11 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 10:45am 21 Jun 2020
Copy link to clipboard 
Print this post

Seems much faster and the word wrap makes a big difference - congrats on a great bit of code
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 01:50pm 21 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  Seems much faster and the word wrap makes a big difference - congrats on a great bit of code


Thanks Peter, that means a lot coming from you, and wouldn't have been possible without you crushing the firmware issues so quickly.

With luck there will be more speed to come if/when I cast off the baggage of supporting the CMM1 (for the moment that port is still happening). I have high hopes that your suggestion of using EVAL for function dispatch will work and be at least as fast, if nothing else it will be more readable. I can also take advantage of the CMM2's excessive memory to simplify instruction decoding by just looking up byte values in arrays/tables instead of having to use masks and shifts to decode them.

Regards,

Tom
Edited 2020-06-22 08:53 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 10:44am 22 Jun 2020
Copy link to clipboard 
Print this post

Just a line to say that my Z-MIM repository is now public on GitHub: https://github.com/thwill1000/zmim
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 10:43am 27 Jun 2020
Copy link to clipboard 
Print this post

Well I've got the CMM1 port to the state where it runs ...

... but it's far too slow.

Using my benchmark example:

CMM1:                    28.7   Z-machine instructions per second
CMM2 (using CMM1 code): 532.8
CMM2 (using CMM2 code): 747.2


The principal difference in the two codes is that the CMM1 code has to use a virtual memory implementation whereas the CMM2 can fit the Z-machines 128K entirely in physical memory.

For this particular application the CMM2 is ~18x faster than the CMM1 running the same code.

Because I'm developing some interesting tooling for the purpose I'm going to persevere for a bit longer and inline all the constants and crunch the variable and function/subroutine names but I doubt that will make it playable, apologies if anyone seriously wanted this - by all means you can have the code to optimise yourself if you want.

Regards,

Tom
Edited 2020-06-27 21:02 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3650
Posted: 11:40am 27 Jun 2020
Copy link to clipboard 
Print this post

How many Z-MIPS (Z-machine instructions per seconds) are needed to make something reasonably playable?

Maybe post the code before you optimise it to death - code tends to get really unreadable in that situation.

Peter posted some ideas to speed it up - are your figures after trying those?

John
Edited 2020-06-27 21:42 by JohnS
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 12:11pm 27 Jun 2020
Copy link to clipboard 
Print this post

Hi John,

  JohnS said  How many Z-MIPS (Z-machine instructions per seconds) are needed to make something reasonably playable?


I imagine 100 provided there was also a visual indication that the vCPU is crunching such as a spinning prompt character. I doubt this is actually possible and I'm only really persevering because of the preprocessor I'm developing to automate the conversion. However any optimisations might also help get the CMM2 version up to the magic 1000 ZMIPS.

  Quote  Maybe post the code before you optimise it to death - code tends to get really unreadable in that situation.


Agreed, I'll post it this evening. Note that at the moment I'm restricting myself to optimisations I can automate for exactly the argument you give.

  Quote  Peter posted some ideas to speed it up - are your figures after trying those?


Of those suggestions only the restructuring of the massive IF blocks is applicable to the CMM1. I tried that on the CMM2 some weeks ago and it was surprisingly ineffective. I will try it on the CMM1 once I've automated the constant inlining and variable/function/subroutine name crunching mentioned in my previous post.  

Regards,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3838
Posted: 11:24pm 27 Jun 2020
Copy link to clipboard 
Print this post

Hi folks,

A zip file containing the CMM1 version of Z-MIM discussed above can be downloaded from here: https://github.com/thwill1000/zmim/releases/download/r3b1/zmim-r3b1.zip (Release 3, beta 1)

The file to run is "zmim/zmim_cm1.bas"

This zip contains all the code of the CMM2 version from which the CMM1 version was automatically generated in the zmim/src folder. See zmim/src/main.bas to see a sample of the directives for my "pre-processor".

My standard benchmark can be generated by:

1. Select "minizork.z3"
2. Type "n" so as not to create a script
3. Type "*replay"
4. Select "bench.scr"
5. Sit back and wait ... takes many, many minutes on the CMM1

Best regards,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 1 of 3    
Print this page
© JAQ Software 2024