[net.micro] SOURCE : sanyo 555vb to run ibmpc GEM DESKTOP

indra@utai.UUCP (Indra Laksono) (08/10/85)

    Well, here it is.  All you sanyo users out there who have the
video board can now run GEM DESKTOP.  It won't do much good unless
you have more RAM though.  The calculator and clock is missing at
<384K.  You also can't run GEM DRAW.

    SO!  If any of you know of a memory expansion scheme that woiks
with the VIDEO BOARD, PLEASE TELL ME!!!   I'm dying to know!  Mail
me.

    To use this, cut on the dotted line and type : sh <dee file>



..{allegra cornell decvax ihnp4 linus utzoo}!utcsri!utai!indra


------CUT---HERE---------NOT--WITH--SCISSORS---THOUGH-----------------
echo xtracting : patch.doc
cat > "patch.doc" << '\\EOF patch.doc\\'
What is GEM
 
    GEM is a Graphics Environment that is meant to complement msdos on the
ibm pc and clones.  The entire package is an icon and pointer approach to
computers, not unlike that of the Apple Macintosh.
 
    When you run GEM, what the user sees is a 'desktop', with various icons
on screen.  Items are selected by moving a pointer and clicking a button.
The msdos files are seen as sheets of paper and the directory is known as a
folder.  Folders can contain files or other folders.  The default display is
icons, but can be changed to text.  To run a program, you can either open it
or obtain a directory listing first by double-clicking on the drive icon,
move to the appropriate file icon and double click.  The executable files
are the EXE, COM, BAT and APP.  The last one refers to GEM APPlication files
like GEM DRAW, OUTPUT, WRITE.
 
    This will be a great aid for novices, but there is a price to pay.
The Sanyo comes with a max of 256K memory, (with exception of 3rd party
boards).  If you have 256K, you won't like the fact that it gobbles up
close to 128K of your memory.  With 40K or so used by dos, you have about
than 90K work space.  You will still be able to run Lotus 1-2-3, but not
the tutorial from the GEM DESKTOP.  Even GEM DRAW, which is so fascinating
on an ibm pc does not have enough memory.
 
Technical stuff
 
    When GEM.EXE is executed, it installs an INT EF via dos INT 21h AH=25.
This unfortunately, is used in the sanyo to deal with the 8251A chip.
Using debug, you can search for the location where this is done.  I found
this by tracing the program via debug and setting the break-points where
appropriate.  The system hangs immediately after this because it meets
this new routine instead of some vital low level handler.
 
    There are two simple solutions to the problem.  The first is to patch
the GEM.EXE where this occurs.  However, all the GEM APPlication files and
even DESK1.ACC uses INT EF, so these files have to be patched too.  Further,
the APP files check if GEMAES has been installed by directly looking at the
vector table locn 0:03bc - 03bf.  You have to change this to locn 0:n*4
- n*4+3.  It's obvious that this approach has a big drawback - you have
to patch every GEM program you buy in the future.
 
    Unfortunately, I used the 1st approach before I realised how dumb it
really is.  The second approach is more elegant.  The system itself can be
patched.  Simply redirect INT EF to another, (I chose F0).  This is done by
copying (0:03bc-03bf to n*4..n*4+3) and replacing the INT EF call by INT F0.
This will occur once between 40:2000 and 40:3000.
 
    The second problem is more tricky.  Dragging icons is done by pressing
[shift][home].  The file IBMCHMP2.SYS checks for a [shift] by doing INT 16H
with AH=2.  This occurs twice.  The first solution is to patch this file to
call another interrupt, but my final solution was to mask INT 16h by a trap
routine that checks AH=2 or a certain key.  The key will act as a toggle to
enter and exit the 'drag mode'.  When AH=2, it returns the appropriate value
in AL to indicate this, otherwise, it does the original INT 16H which has
been redirected elsewhere (I chose 41).
 
    ([home] is the [7] on the cursor control pad).

    The final program I wrote does the second approach.  The disadvantage is
will have to be run everytime you boot the system if you want to run GEM. It
also grabs 416 bytes of main momory.  The advantage is that now, the ibm pc
GEM will run if you have enough memory.  (DRAW requires > 256K).
 
    This routine will slow down keyboard somewhat, but it's not visible to
the naked eye.  However, the communications program MINITEL does lose a char
or so while in VT102 emulation.  However, if your modem program has buffer
handling, you should not have any problem
 
    If you find the slowdown of the keys irritating, use patch1 which uses
removes the screen-dump interrupt.  Patch1 should be faster, but patch2 is
a lot more flexible.
 
Curtains
 
    In the future, I'd like to hear from anyone who writes a driver for some
pointing device.  GEM supports a mouse that can be connected to the RS-232C
port, it should be easy to use some mouse on the sanyo, but I don't have one.
 
\\EOF patch.doc\\
echo xtracting : patch1.asm
cat > "patch1.asm" << '\\EOF patch1.asm\\'
        page 60,132
title GEMPATCH1 - Patching msdos 2.11 VB to run GEM desktop.
;---------------------------------------------------------------
; 85 07 27.  Indra Laksono, Sanyo Users In Toronto (SUIT)
;            PO BOX 575,
;            Station P,
;            Toronto, Ontario
;            Canada M6G 3Y6
;            Phone : (416)-534-4026.
;--------------------------------------------------------------
; Simple patch for GEM Desktop to run unmodified on
; the Sanyo.  This patch is for keyboard control only.
; Drag is done by : [shift][ctrl][del][home][shift][ctrl][del].
;
; Technical :
;       GEM doesn't run because it installs an INT EF.
;       INT EF is used in Sanyo VB.  So, the solution is :
;       [1] copy the vector INT EF to some other INTerrupt (F0)
;       [2] change the occurence of INT EF (CD EF) to INT F0 (CD F0)
; Possible problems :
;       [1]     Memory : Can't run DRAW with 256K : (like always)
;       [2]     If 1 is solved, need better pointing device. Keyboard stinks
;       [3]     This was designed to work with any VB dos.  But never tested.
 
int05addr equ 14H
intEFaddr equ 03bch
intF0addr equ 03c0h
;---------------------------------------------------------------
codesg  segment para 'CODE'
        assume cs:codesg
        org 100h
begin   proc far
        push ds
        xor ax,ax
        push ax
        jmp overdata
;--- This is:
thecode:
        pushf
        cli
        push ax
        mov ax,cs
        push ds
        mov ds,ax
        db 0f6h,16h   ; not byte ptr [????]
byteadr1 dw 1e76h
        pop ds
        pop ax
        popf
        iret
        db 0
callroutine:
        pushf
        cli
        mov ax,cs
        mov ds,ax
        db 0a0h        ; mov al,byte ptr [????]
byteadr2 dw 1e76h
        or al,al
        jz finish
        mov al,03
finish: popf
        db 0c3h
;--thecode ends here.
errorstr db 'Cannot find INT EF instruction',10,'$'
overdata:
        mov ds,ax        ; Make ds, es = 0
        mov es,ax        ;
        mov si,intEFaddr
        mov di,intF0addr
        lodsw
        stosw
        lodsw
        stosw
        mov es,ax        ; segment of most INT service routines
        mov ds,ax
        mov al,0cdh      ; this is an INT instruction
        mov di,2000h     ; search from es:2000h to es:3000h
        mov cx,1000h     ;
startscan:
        repne scasb              ; is this INT opcode ?
        mov bh,byte ptr[di]      ; ds should be segment of most INTs
        cmp bh,0EFH
        jz foundintEF
        jcxz notfound
        jmp startscan
notfound:
        mov ax,cs
        mov ds,ax
        mov ah,09
        mov dx,offset errorstr
        int 21h
        ret
foundintEF:
        mov al,0f0h
        stosb
        mov ah,35h   ; Get int vector for INT 05
        mov al,05
        int 21h
        mov ax,bx
        add ax,10h
        mov dx,ax
        inc dx
        mov byteadr1,ax     ; fix the offset addr of
        mov byteadr2,ax     ; the flag byte in thecode
        mov ax,cs
        mov ds,ax
        mov si,offset thecode
        mov di,bx
        mov cx,22h          ; thecode is 22h bytes long.
        rep movsb           ; copy thecode to memory
        mov ah,35h          ; Get Vector for INT 16h
        mov al,16h
        int 21h
        add bx,49h          ; Should have mov al,0   pop bx pop ds iret
        mov di,bx
        add bx,03           ; length of a call intsruction
        sub dx,bx
        mov al,0e8h
        stosb
        mov ax,dx
        stosb
        mov ax,dx
        mov al,ah
        stosb
        mov al,0ebh
        stosb
        mov al,0e7h
        stosb
        mov ax,cs
        mov ds,ax
        mov dx, offset Messg
        mov ah,09
        int 21h
        ret
begin   endp
Messg   db 'Gem Patch in dos - Indra Laksono',10,13
        db '[shift][ctrl][del][home][shift][ctrl][del] to drag$'
codesg  ends
        end begin
\\EOF patch1.asm\\
echo xtracting : patch1.asm
cat > "patch1.bas" << '\\EOF patch1.bas\\'
10 REM Indra Laksono GEM PATCH
20 PRINT "MAKING PATCH1.COM"
30 OPEN "R",#1, "PATCH1.COM",1
40 FIELD#1,1 as T$
50 READ D$ : REC%=1 : LINENUM = 100
60 WHILE D$ <> "END"
62   CHK%=0 : READ CHKSUM%
65   FOR P% = 0 to 31
70     M%=VAL("&H"+MID$(D$,2*P%+1,2)) : LSET T$=CHR$(M%)
72     PUT#1,REC% : REC%=REC%+1 : CHK%=(CHK%+M%) MOD 512
75   NEXT
77   IF CHK% <> CHKSUM% THEN PRINT "Chksum Error at ",LINENUM
80   READ D$ : LINENUM = LINENUM+10
90 WEND
95 CLOSE : PRINT "FINISHED. RUN PATCH1.COM from DOS before running GEM"
100 DATA 1E33C050EB43909CFA508CC81E8ED8F616761E1F589DCF009CFA8CC88ED8A076, 198
110 DATA 1E0AC07402B0039DC343616E6E6F742066696E6420494E5420454620696E7374, 297
120 DATA 72756374696F6E0A248ED88EC0BEBC03BFC003ADABADAB8EC08ED8B0CDBF0020, 165
130 DATA B90010F2AE8A3D80FFEF7410E302EBF38CC88ED8B409BA2901CD21CBB0F0AAB4, 503
140 DATA 35B005CD218BC30510008BD0422EA311012EA31F018CC88ED8BE07018BFBB922, 141
150 DATA 00F3A4B435B016CD2183C3498BFB83C3032BD3B0E8AA8BC2AA8BC28AC4AAB0EB, 169
160 DATA AAB0E7AA8CC88ED8BAD001B409CD21CB47656D20506174636820696E20646F73, 300
170 DATA 202D20496E647261204C616B736F6E6F0A0D5B73686966745D5B6374726C5D5B, 263
180 DATA 64656C5D5B686F6D655D5B73686966745D5B6374726C5D5B64656C5D20746F20, 70
190 DATA 6472616724000000000000000000000000000000000000000000000000000000, 450
200 DATA 0000000000000000000000000000000000000000000000000000000000000000, 0
210 DATA 0000000000000000000000000000000000000000000000000000000000000000, 0
220 DATA END
\\EOF patch1.bas\\
echo xtracting : patch2.asm
cat > "patch2.asm" << '\\EOF patch2.asm\\'
page 60,132
title GEMPATCH2 - Patching msdos 2.11 VB to run GEM desktop.
;---------------------------------------------------------------
; 85 08 01.  Indra Laksono, Sanyo Users In Toronto (SUIT)
;            PO BOX 575,
;            Station P,
;            Toronto, Ontario
;            Canada M6G 3Y6
;            Phone : (416)-534-4026.
;---------------------------------------------------------------
; Simple patch for IBM PC GEM Desktop to run unmodified on
; the Sanyo.  This patch is for keyboard control only.
; Drag is done by : [graph][/][home][/]
;
; Technical :
;    a. GEM doesn't run because it installs an INT EF.
;       INT EF is used in Sanyo VB.  So, the solution is :
;       [1] copy the vector INT EF to some other INTerrupt (F0)
;       [2] change the occurence of INT EF (CD EF) to INT F0 (CD F0)
;    b. You can't drag icons with keyboard.  IBMCHMP2.SYS checks for
;       [shift] status via INT 16H AH=2, which always returns AL=0 in
;       Sanyo.
;       Solution :
;       [1] Rewrite INT 16H to check for a 'dragKey', this will toggle
;           a flag from 0 to ff.  Then do the original INT 16H which has
;           been rewritten to INT 41H
;
; Possible problems :
;       [1]     Memory : Can't run DRAW with 256K : (like always)
;       [2]     Also, with 256K, the calculator and alarm clock is not there.
;       [3]     If 1 is solved, need better pointing device. Keyboard stinks
;       [4]     This was designed to work with any VB dos.  But never tested.
;
; Parting shot :
;       Actually this can be extended to allow emulation of all 8 status
;       check keys on the ibm.  Just trap for 8 different keys.
;       I ask for nothing except to be informed about future updates
;       or extensions by others.  Future plans include (chronological) :
;       [1]     Use of Joystick
;       [2]     Use of Mouse
;---------------------------------------------------------------
dragKey   equ 0d2h       ; this is the [/] in GRAPH mode. Change to suit taste
intEFaddr equ 03bch
intF0addr equ 03c0h
;---------------------------------------------------------------
codesg  segment para 'CODE'
        assume cs:codesg,ds:codesg
        org 100h
start:
        jmp overdata
;--- This is:
int16rtn proc far
        push ax
        mov ah,01
        int 41h          ; do the original INT 16H
        jz nokey         ; has a char been hit ?
        cmp al,dragKey
        jne nokey        ; no char hit, do std int 16h
        not byte ptr cs:flag  ; negate flag
        xor ah,ah             ; clear buffer
        int 41h
nokey:
        pop ax           ; recover the calling fcn
        cmp ah,02        ; Is this the keyboard status check ?
        jnz not_stat
        mov al,cs:flag
        or al,al
        jz endit
        mov al,03        ; this indicates both shift keys hit.
endit:
        iret
not_stat:
        int 41h
        db 0cah, 02, 00   ; retf 2
int16rtn endp
flag    db 0h
;--thecode ends here.
overdata:
        xor ax,ax
        mov ds,ax        ; Make ds, es = 0
        mov es,ax        ;
        mov si,intEFaddr
        mov di,intF0addr
        lodsw
        stosw
        lodsw
        stosw
        mov es,ax        ; segment of most INT service routines
        mov ds,ax
        mov al,0cdh      ; this is an INT instruction
        mov di,2000h     ; search from es:2000h to es:3000h
        mov cx,1000h     ;
startscan:
        repne scasb              ; is this INT opcode ?
        mov bh,byte ptr[di]      ; es should be segment of most INTs
        cmp bh,0EFH
        jz foundintEF
        jcxz notfound
        jmp startscan
notfound:
        mov ax,cs
        mov ds,ax
        mov ah,09
        mov dx,offset errorstr
        int 21h
        xor ah,ah               ; terminate program
        int 21h
errorstr db 'Cannot find INT EF instruction',10,'$'
foundintEF:
        mov al,0f0h
        stosb
install:
        ; copy Vector for INT 16h into vector for INT 41H
        mov ah,35h   ; Get int vector for INT 16h
        mov al,16h
        int 21h
        mov ax,es    ; copy into vector for INT 41h
        mov ds,ax
        mov dx,bx
        mov ah,25h
        mov al,41h
        int 21h
        ; modify INT 16h to our routine to trap AH=2
        mov ax,cs
        mov ds,ax
        mov dx,offset int16rtn
        mov ah,25h
        mov al,16h
        int 21h
        ; print message
        mov ah,09
        mov dx, offset messg
        int 21h
        ; prepare for exit
        mov dx, offset overdata+1
        int 27h                         ; terminate - resident
messg   db 'Gem Patch in dos - Indra Laksono',10,13
        db 'Press [graph][/][home][/] to drag$'
codesg  ends
        end start

\\EOF patch2.asm\\
echo xtracting : patch2.bas
cat > "patch2.bas" << '\\EOF patch2.bas\\'
10 REM I make binary files
20 PRINT "MAKING PATCH2.COM"
30 OPEN "R",#1, "PATCH2.COM",1
40 FIELD#1,1 as T$
50 READ D$ : REC%=1 : LINENUM = 100
60 WHILE D$ <> "END"
62   CHK%=0 : READ CHKSUM%
65   FOR P% = 0 to 31
70     M%=VAL("&H"+MID$(D$,2*P%+1,2)) : LSET T$=CHR$(M%)
72     PUT#1,REC% : REC%=REC%+1 : CHK%=(CHK%+M%) MOD 512
75   NEXT
77   IF CHK% <> CHKSUM% THEN PRINT "Chksum Error at ",LINENUM
80   READ D$ : LINENUM = LINENUM+10
90 WEND
95 CLOSE : PRINT "FINISHED. RUN PATCH2.COM from DOS before running GEM"
100 DATA EB2C9050B401CD41740D3CD275092EF6162D0132E4CD415880FC02750B2EA02D, 164
110 DATA 010AC07402B003CFCD41CA02000033C08ED88EC0BEBC03BFC003ADABADAB8EC0, 321
120 DATA 8ED8B0CDBF0020B90010F2AE8A3D80FFEF7433E302EBF38CC88ED8B409BA6601, 354
130 DATA CD2132E4CD2143616E6E6F742066696E6420494E5420454620696E7374727563, 500
140 DATA 74696F6E0A24B0F0AAB435B016CD218CC08ED88BD3B425B041CD218CC88ED8BA, 267
150 DATA 0301B425B016CD21B409BAB401CD21BA2F01CD2747656D20506174636820696E, 425
160 DATA 20646F73202D20496E647261204C616B736F6E6F0A0D5072657373205B677261, 145
170 DATA 70685D5B2F5D5B686F6D655D5B2F5D20746F2064726167240000000000000000, 73
180 DATA END

\\EOF patch2.bas\\
echo xtracting : READ.ME
cat > "READ.ME" << '\\EOF READ.ME\\'
This actually contains two different patches to run GEM desktop on the
Sanyo MBC 555 VB.  The patches come on asm and bas formats.  If you
do not have an assembler, run the BASIC program to get the respective
COM files.
 
WARNING : IF YOU ASSEMBLE, USE EXE2BIN TO CONVERT TO COM FILE.
 
You have to run one of the COM files everytime you boot your system.
Either one should work, but the differences are :
 
patch1 : does not use memory, does not slow down keyboard, may not work,
         removes the screen dump interrupt.
 
patch2 : uses memory, slows down keyboard(negligible), should work,
         preserves screen dump, can be modified to other key.
 
I would recommend using patch2 unless you want to run minitel, in which
case, you have to use patch1.
 
DO NOT USE GEM DESKTOP WHICH HAS BEEN SETUP UNDER IBM PC UNLESS YOU ARE
WILLING TO COPY OVER THE DOS ONTO IT.  GEM MAY LOAD COMMAND.COM AT TIMES,
AND WILL CRASH WHEN THE PCDOS COMMAND.COM IS LOADED.  IT IS ADVISABLE TO
SETUP GEM ON YOUR SANYO BY RUNNING THE PROGRAM GEMPREP.EXE ON DISK 1 OF
GEM DESKTOP.
 
GEM DRAW WILL NOT RUN UNLESS YOU HAVE >= 384K OF MEMORY.
 
If you have any problems, please contact :
        Indra Laksono
        PO BOX, 575,
        Station P,
        Toronto, Ontario,
        Canada   M6G 3Y6.
        (416)-534-4026.


\\EOF READ.ME\\
echo done.  Please read READ.ME now.
#! rnews 822
Relay-Version: version B 2.10.2 9/18/84; site utai.UUCP
Posting-Version: version B 2.10.2 9/18/84; site utai.UUCP
Path: utai!indra
From: indra@utai.UUCP (Indra Laksono)
Newsgroups: net.micro
Subject: Re: Amiga vs ST520
Message-ID: <652@utai.UUCP>
Date: 10 Aug 85