HAUNTED HOUSE Conversion Notes  (Version 2 - 10-Nov-1999)
=========================================================

Well, I couldn't leave well enough alone.  I fixed up all of the 
incompatibilities with various Model 1 and 3 DOS's, so now my fused
Haunted House works on Model 1/3/4's (in Model III mode of course), under
all versions of the various DOS's.

The original version was supplied as two tapes.  Part 1 and Part 2.  About
midway through the game, you were prompted to load up the second tape,
and it would load the final portion of the adventure.  It was designed to
run in 4K of RAM, and so you can imagine things were a bit tight.  I
patched the game to hop right into the second part - you won't even notice
the transition.  [It's not terribly hard to figure out where it does it
though - there's no "going back" to the first section once you've made
it to the second].

I have included the .CAS file for those who wish to load it via cassette.
Most emulators have the capability to dump .CAS files out to real tape, so
you may load it on an original TRS-80 16k system.  [this fused version will
not work on a 4K RAM system].  The .CAS file is 500 baud [Model 1
Level 2 or Model 3 "Low" speed].

To load it via cassette, from ROM-BASIC simply:

Cass? L                [Model III/IV only]
Memory Size? [enter]
Radio Shack Basic [blahblahblah]

>SYSTEM

*?HAUNT

(two *'s will appear in the upper right corner, one will flash)
(when it's done...)

*?/

(Note: the *? and > are prompts in the above - do not type them).

The screen should clear, and the program will run.  There may be some
"schmutz" on the screen - just hit RETURN and you will be get the first
room's description.

Below, I enclose my "technical" notes about how to make such ancient
tape software work when loaded via DOS.

Enjoy!

=Lord Apollyon=

PS: For HARDCORE purists, both parts are available on Ira's site.  You
will need to make two cassettes from the /CMD files - though it's
possible the person who converted them opted to have them be 
separately loaded - rather than chained like the original was.

------------------------------------------------------------------------

In the process of taming that old Haunted House adventure by Tandy/Radio
Shack, I ran into 2 main problems....

1) It lived REALLY low in memory.... like 42xx area.  It was designed for
a 4K Level 1 Basic machine, and so the programmer was forced to origin his
code as low as possible.

This isn't typically such a problem... you just relocate the sucker to
6000h or so (for ease of editing in DEBUG or equivalent) to load above DOS
[can't be overwriting DOS during the program's loading, now can we?!)...
and tack on the usual LDIR relocator and hop to the program's original
entry point.  2 minutes, including the time to boot DOS, load the program
relocated to 6000h, going to debug, banging out the 13 byte add-on
routine, and then trying to remember the exact syntax of DUMP to write out
the new /CMD file.

2) Most DOS's, in fact, nearly ALL of them, install their own interrupt
handlers and/or *KI and/or *DO drivers.  ROM character output code
typically pipes through these vectors, and if you've clobbered them with
your program, CRASH-O-RAMA baby.

Oddly enough, TRSDOS 1.3 is perhaps the only DOS that leaves all of those
vectors alone.

For the others, you'll need to replace the vectors (from 4000h to about
4036) with the ROM's copy.  But alas, there was never a standard place for
either a routine, or the master initialising copy of the vector table.  It
varies between Model 1 and Model 3.

I disassembled the 3 versions of Model 1 ROMs and the Model III ROM [where
there other versions of Model III ROMs?].  I think the Model 4 uses the
Model 3's ROM as-is when it's in Model III mode, no?

Anyhow.  I offer the following code fragment which correctly handles and
cleans up DOS-messed-up vectors so that ancient tape-based software
99.99999% of the world couldn't CARE LESS about anymore can run.  Maybe I
was bored this 3am, maybe my pedantic ass was annoyed that such a small
thing could remain unsolved.  I didn't spend more than a couple hours on
it, but it was *FUN* to hack like this again.  The Z80 opcodes came back
to me like a hippy flashing back to Haight Ashbury in the 1960s.  Heheh.

Well, screw it.  It's solved, and I've tried it with every emulator I
have, with every DOS I have, and it does the trick.  (Naturally, it won't
work in Model 4 mode, but the software you'd be trying to run wouldn't run
in this ROM-less mode either).

Here's the code... some of you folks with "FYI" or
information-to-old-hackers areas on their websites may feel free to copy
and archive this so others don't need to gnash their teeth on it.

=R=

;
; ancient tape software relocator/ROM-vector fixer-upper
;
; contributed by Lord Apollyon
;
; the following symbols are just an example....
;
            relocated_code  equ     6000h   

; this is a nice relo area - well past DOS

            original_code   equ     42e9h
            code_size       equ     0dffh
            entry_point     equ     42e9h

0000  F3                di              ; disable the interrupts - just in case
0001  CD1A00            call    getvectors
0004  110040            ld      de,4000h
0007  EDB0              ldir

; we've installed ROM's RST and keyboard/screen vectors

0009  210060            ld      hl,relocated_code
000C  11E942            ld      de,original_code
000F  01FF0D            ld      bc,code_size
0012  EDB0              ldir
0014  CDC901            call    01c9h           ; clear the screen
;
; important !!! don't use 01c9 to clear the screen if the vectors are dangling
; in nowhere land.  CLS is implemented as a pair of control calls to the *DO
; driver.  You get big boom-boom if *DO is whacked.
;
0017  C3E942            jp      entry_point

001A            getvectors:
001A  21AA36            ld      hl,36aah
001D  014C00            ld      bc,004ch

; Model 1 (0004h=06) while Model 3 (0004h=30h)
                                        
0020  3A0400            ld      a,(0004h)   
0023  FE30              cp      30h
0025  C8                ret     z
;
; this is the Model I vector area and size (all 3 Model 1 ROM versions checked)
;
0026  21D206            ld      hl,06d2h
0029  013600            ld      bc,0036h
002C  C9                ret
