 ************************** TRS31/CMD : Version .95 *************************

This started out as one of those rainy day projects and sort of grew to use
more of my time than what I had anticipated. What started the whole brew was
the fact that I had some TRS-80 Model III programs (and Model 1) on the BBS
system (FastPlus which I wrote) and had some complaints about those programs
not working properly. One was MAC2TRS1/CMD and there were a number of others.
Since I only have a Model 4 I could not run the Model 1/3 programs to see if
they work unless I was in the Model 3 mode. Problem being that my hard drive
was (and still is) only configured for a Model 4. So booting from a Model 3
DOS I had to transfer the suspected files over and play around with them to
make sure they worked.

I got the rather brilliant idea that it would be nice to have a Model 3
emulator on line (I should know better after writing the VT100 emulation for
FastTerm; but I'm a slow learner). Hence I sat down and tried to figure out
the quickest and easiest way to do it. I had written a disassembler and
thought that it should be a "quick" job to patch the disassembler to be able
to load and scan through a Model 1 or 3 program and change addresses to what
I wanted. While that may be my ultimate goal if I ever get enough time to
really do all I want to get done for now it was going to use too much time.
So time limiting, I wrote the first version which used the standard Model 4
screen and keyboard.

Version .01

While it worked (sort of) I could see that the viewing anything on the video
was going to be a major pain in the backside. The 80 column screen on the 4
doesn't take kindly to working in 64 as the 1 and 3 require. So I started
modifying the video portion.

Version .14

This version had a complete video section written to use the center of the
video on the Model 4. It used a TASK vector and updated the screen every
16 ms. Which shouldn't cause too much screen flickering (although some is
slight). In effect what I did was write a driver to handle characters going
to the video display on the Model 1/3 (its at 3C00H) and then I used the
TASK to simply move that screen to the Model 4 video section. That works
fine in most cases except for some cursor commands. Nothing is ever prefect.

Version .29

I started with the ROM CALLS in the Model 1/3 and wrote a TABLE of them.
After loading the program, TRS31 will search for these specific calls and
change them to routines within TRS31.

Version .52

Next was the JPs to ROM. Seems that not all programmers in the days of the
Model 1/3 used a CALL to execute a routine in ROM. They could use a JP and
then use the RET found at the completion of the ROM routine.

Verison .79

Course I had missed something pretty basic, and that was the DOS calls. So
into a table they went. Like file handling and the like.

Version .86

Seems there were some problems with printer ports. Model 1 used 37E8 and the
Model 3 used PORT (F8). I had to add these to the program so that I could
get a hardcopy from the Model 1/3 application.

Version .90

Added address routines to "fool" the Model 1/3 program into getting the
right memory size and detecting if the computer was a Model 1 or 3.

Version .95

Added some text to it and more CALLS and JPS so that it would work better.
This is the current version and while it works some of the time on some of the
programs, again its not perfect.

======================== technical Info ========================

If you are interested in this program and want to know how it works better
this section is for you.

Effectively, I have written subroutines to handle all the Model 1 and 3
STANDARD (a keyword here) ROE or DOS routines. I have a table of PORTS,
addresses (for a memory map), DOS CALLS, ROM CALLS in TRS31 which is used
as a look up.

When you start the program, the short text information is displayed and you
are asked to enter a Model 1/3 /CMD filename (i.e. COPTER/CMD; which by the
way is a little graphic game which actually works on it). Once done, TRS31
will clear memory from about 5000H to a little less that top of memory. There
is no need to clear it all, since most Model 1/3 programs don't use it all
anyway.

It then loads the Model 1/3 program into RAM and then starts at the execution
point and scans through it changing any address calls/jps it finds to use
my routines in RAM (which are interfaced with the TRS Model 4 RSTs). Once
done it will deliver one of two messages.

If no addresses were found which it didn't change it will excute, otherwise
it will let you know that there may be some ROM calls which it didn't change
and the application program may not work as expected.

Once done, error trapping, keyboard, video and such are handled by TRS31 with
the application thinking its working on a real Model 1/3.

======================== Problems, problems problems..... ====================

TRS31 is not without problems which stem from a number of things. The main
body of TRS31 sits from 3000H to 3C00H (under the video display on a Model 1
or 3) so there is no conflict from the Model 1 or 3 program.

However, many programs which were once CASSETTE (shudder) based on the Model 1
/3 were transfered to DOS by using programs such as LMOFFSET or a number of
others. While they work on a REAL Model 1/3 then may fail on TRS31 because they
have a DI (disable INTERUPTS code). DI will effectively also DISABLE my video
TASK for emulating the Model 3 screen (ie it won't be displayed). I check
for this at the beginning since thats usually where it is, but not always. So
sometimes it will just got into "sudden death" and RESET is your only way
out.

The addresses I am checking for are STANDARD. Like CALL 0040H for the keyboard
input routine in ROM. If your program uses CALL 0041H, TRS31 will miss it. 
If you have a NORMAL well BEHAVED program it will probably stand a pretty
good chance at working under TRS31. If its not and uses some wild ROM calls
to do whatever, I'll almost wager its not going to work at all.

Don't bother trying to run a program which trys to steal the DCB (device
control blocks) like a TERMINAL program. A program which uses the VIDEO DCB or
KEYBOARD to intercept characters is not going to work. Besides, FastTerm is
better than any Model 1/3 program going anyways. Word processing is another
one to shy away from. They do some wild stuff and usually steal the video
and keyboard drivers (and some use the printer drivers too). Again there are
better programs on the Model 4 for these. Trying to run BASIC/CMD will result
in a "large" headache. Save your time.

Programs which PEEK (examine the keyboard directly) will work. I wrote a 
KEYBOARD PEEK routine to handle these (as most graphic games use this). Its
a little slower but it will work most of the time. NOTE that when a program
says use CLEAR on a Model 1/3, to us thats SHIFT CLEAR (Model 4).

So you see I have done some fair amount of work on this "rainy" day project
but its by no means finished. In case you are wonderin about the verison,
standards dictate that any version less than 1.0 is BETA and boy is this BETA
(not to be confused with VHS either).

_______________________________ Challenges ___________________________________

If you're a machine language hacker and have some addresses which I missed
PLEASE let me know. Its a simple matter to add CALLS or JP checks to this
application (even if I have to write a small subroutine to support it). If
you find addresses which I am changing which I shouldn't be, let me know again
so I can take the steps to correct it.

Below is a list of addresses and ports currently checked for :

;Port address table (Printer), 1st is LD A,(37E8H), 2nd LD (37E8H),A
tports  DB      8               ;number of items in list
ports   DB      3AH,0E8H,37H    ;LD     A,(37E8H) checks printer port
        DB      0,0DBH,0F8H     ;replace it with NOP, IN A,(F8H)
;
        DB      32H,0E8H,37H    ;LD     (37E8H),A send to port
        DB      00H,0D3H,0F8H   ;change to NOP, OUT  (F8),A to send
;
        DB      3AH,40H,38H     ;LD  A,(3840H) (arrows)
        DB      0CDH            ;CALL ROW7
        DW      row7            ;use my routine to check keyboard
;
        DB      3AH,04H,00H     ;see if Model 1/3 (30H=3)
        DB      3AH
        DW      mod3            ;fool it I hope
;
        DB      3AH,10H,38H     ;LD A,(3810H) (numbers)
        DB      0CDH
        DW      row5            ;use CALL to my routine
;
        DB      3AH,25H,01H     ;LD A,(0125H) 49H=Model 3
        DB      3AH
        DW      model1          ;show where new location is
;
        DB      32H,0ECH,37H    ;LD (37ECH),A (disk controller)
        DB      00H,0D3H,0F0H   ;NOP, OUT (F0),A cmd/status reg
;
        DB      32H,0EEH,37H    ;LD (37EEH),A (disk controller)
        DB      00H,0D3H,0F2H   ;NOP, OUT (F2),A (sector reg)
;
;Address table for lookup
tadd    DB      37
table   DW      0040H,keyin     ;line input routine
        DW      0049H,inkey     ;INKEY$ routine
        DW      002BH,kbd       ;scan keyboard
        DW      0033H,disply    ;show character
        DW      003BH,print     ;send character to printer
        DW      0060H,delay     ;pause routine
        DW      402DH,todos     ;else to DOS READY
        DW      0013H,get       ;read single byte from device
        DW      001BH,put       ;send single byte to device
        DW      01C9H,cls       ;clear the screen
        DW      3033H,date      ;get the date from DOS
        DW      01F8H,cass      ;cassette routine
        DW      0212H,cass
        DW      0287E,cass      ;"      "
        DW      033AH,disply    ;write byte to video
;Dos Calls Table
        DW      409H,dskerr    ;error routine
        DW      4420H,init      ;open or create a filespec
        DW      4424H,open      ;open the filespec only
        DW      4428H,close     ;close the filespec
        DW      442CH,kill      ;remove open filespec from directory
        DW      4430H,load      ;do a /CMD load
        DW      4433H,run       ;run a /CMD file
        DW      4436H,read      ;read a sector
        DW      4439H,write     ;write a sector
        DW      443CH,verf      ;verify after write
        DW      443FH,rew       ;move to beginning of file
        DW      4442H,posn      ;position to record #
        DW      4445H,bksp      ;back up 1 record
        DW      4448H,peof      ;position to end of file
        DW      4030H,abort     ;exit to DOS
        DW      4400H,todos     ;exit to DOS
        DW      4405H,cmndi     ;command line intpreter
        DW      4419H,cat       ;list filespec and ext to video
        DW      441CH,fspec     ;create a filespec
        DW      4467H,disp      ;display a line
        DW      446AH,lprint    ;print a line
        DW      4470H,date      ;get date from the system

******************************************************************************

Well thats about it. If you find programs which work on TRS31 please let me
know, if you find ones which don't work ah "keep it a secret". I suggest
when trying this sort of thing you WRITE PROTECT your disks. Otherwise the
flying fickle finger of fate may farkle your disks. 

It also helps to be in upper case most of the time. A lot of programs for the
Model 1/3 didn't understand commands or filenames if you type them in with
lower case enabled.

While this program is public domain, the source code for it isn't. If you
want to continue and want my source code, send $5.00 to :
     
     Mel Patrick : 13699 70A Ave. : Surrey, B.C. : Canada : V3W 2J8

I'll send you back a disk with the source code for whatever the current version
happens to be at that point in time.

If you have questions about TRS31, do me a GREAT big favour and don't leave
messages on Compu$erve or GEnie. Remember this isn't shareware so while you
may only leave one message but so do 50 others, then I have to spend a great
deal of money/time answering all them. I suggest you preformat your messages
to 60 characters per line (max 10 lines), call my BBS and upload them. I'll
try to answer any within 24 hours. My BBS can be reached at :

        (604) - 594-7398 : 300/1200 : 8 bit word, 1 Stop, NO PARITY.  

Hope you enjoy the program and find a use for it. Oh, and there is a BUG in
MAC2TRS1. Seems the programmer wants to open with a logical record length of
1 when it was create with a LRL of 256. His error routine was written wrong
and doesn't recover well (at all).

Mel Patrick
______________________________________________________________________________
Programs known to work :

COPTER/CMD - A short graphic shootem up game with a helicopter dropping bombs.
TRACK/CMD - A Video Store rental program (which I wrote)
PHANTOM/CMD - This is one of those typical adventure programs (says its #1).

If you find others, leave me a note and I'll add them to this list. I don't
have may Model 3 programs any more.
_____________________________________________________________________________
