cctech Digest, Vol 30, Issue 15

Ethan Dicks ethan.dicks at gmail.com
Fri Jan 6 11:05:30 CST 2017


On Thu, Jan 5, 2017 at 8:15 PM, Tim Mann <tim at tim-mann.org> wrote:
> ... xtrs (http://tim-mann.org/xtrs.html) emulates LD A,R
> by putting an 8-bit random number in A. Of course that's cheesy and wrong
> -- especially bit 7 being random instead of retaining a 0 from reset or the
> last value written to it -- but at least it works OK with Ethan's
> subroutine. The subroutine may loop a few times due to the value randomly
> being negative or zero until it escapes the first time the value is
> randomly positive.

Hi, Tim,

Yep.  That should work, though it would be interesting to see how that
biases the numbers as used as percentages in the game code (really,
the granularity is that many events have a medium chance of occurring
and a few events have a low chance of occurring.  Some stuff is just
"color" - as in randomly printing dialog fragments to simulate
intelligent NPC behavior.  As long as the numbers coming out aren't
biased to the lower quintile, gameplay should be fine.

> The pointer that someone posted to
> http://www.worldofspectrum.org/faq/reference/z80reference.htm#RRegister may
> inspire me to fix the emulation, though it looks like a bit of work to get
> it exactly right...

I worked with Peter Shorn, the author of altairz80 on Simh, to do a
fairly good implementation.  I did a simple "increment and wrap on
7-bits" bump in the dispatch loop, which is first-order-approximate,
but the true solution has to do with all the extended commands and
shifts that add extra M1 cycles.

The new code for altairz80 is at http://schorn.ch/altair_beta.php

My latest adventure is figuring out why there's a different problem
with CP/M 3.0 Plus on the Commodore 128.  VICE appears to do the
"random number in R" trick (I haven't inspected the code, but I have a
short Z-80 app that reads and prints the R register several times) and
the game program does not have a problem in reading R, _but_ it seems
to matter in a different place, where there's a BDOS 10 Call to read
buffered console input, one version of CP/M (from Jan 1985) does all
the right things, but two newer versions (Dec 1985 and May 1987) don't
respond after prompting the user for input.

I haven't tried xtrs yet, in part because there already is a TRS-DOS
version of this game (which wouldn't need CP/M, and I haven't ever
fiddled with running CP/M on real Tandy hardware).

Thanks for the response!

-ethan


More information about the cctalk mailing list