[net.micro.6809] Fixing versions 1.00 and 1.01 for COCO3

draco@chinet.UUCP (Kent D. Meyers) (11/09/86)

 NAM cc3fix
 TTL Fix version 1.00 and 1.01 OS9 to run on CoCo3.


* Utility to convert Version 1.00.00 and 1.01.00 to a form
* that is compatible with the new COCO3.
*
* If it assembles correctly the ident is:
*
*    Header for:  cc3fix 
*    Module size: $0135    #309
*    Module CRC:  $BFFE45 (Good) 
*    Hdr parity:  $1C 
*    Exec. off:   $00A1    #161
*    Data Size:   $00C8    #200
*    Edition:     $01      #1
*    Ty/La At/Rv: $11 $81 
*    Prog mod, 6809 obj, re-en 

* Boot the system normally, run cc3fix, and then do a cobbler
* to a freshly formatted blank disk. This new system disk will
* boot directly on the COCO3 without the memory conflicts that
* would previously cause 1.00.00 and 1.01.00 to crash.
* The new disk will still work correctly on a COCO1 or COCO2,
* but you will lose one 256 byte page of memory.
* Kent D. Meyers. November 4, 1986.

 IFP1
 USE DEFSFILE
 ENDC

 MOD SIZE,NAME,PRGRM+OBJCT,REENT+1,ENTRY,MSIZ

 ORG 0
 RMB 200 stack
MSIZ EQU .

NAME FCS "cc3fix"
 FCB 1 edition

OS9NAM FCS 'OS9'
SYSGONAM FCS 'SYSGO'

BADVERSN FCC " Wrong Version of OS9."
 FCB $0A
 FCC " NO patches made!!"
 FCB $0D

PATCHMSG FCC " Already Patched."
 FCB $0A
 FCC " NO patches made!!"
 FCB $0D

GOODMSG FCC " Now Compatible with COCO3!!"
 FCB $0A
 FCC " OK to run cobbler now!!"
 FCB $0D

* Fix memory limit in OS9 module.

ENTRY LEAX OS9NAM,PCR
 LDA #$C1
 OS9 F$LINK
 LDX M$SIZE,U
 CMPX #$07E7
 BNE WRONGVSN
 LEAX $BC,U
 LDD #$F0*$100+$EF
 CMPA ,X
 BNE PATCHED
 STB ,X
 BSR MVERIFY

* Fix the loader that moves the kernel up into high memory.

 LDX #$F049
 LDA #$EF
 STA ,X
 STA $F054-$F049,X

* Fix warm boot setup in the Sysgo module.

* This code may appear a bit strange at first, but I felt that I
* had to take into account the fact that many people have made
* customized sysgo modules. So the code scans through the module
* until it finds the jmp instruction that must be modified.

 LEAX SYSGONAM,PCR
 LDA #$C1
 OS9 F$LINK
 PSHS U

SETJMP LDD #$F00C
 PSHS A,B
 LDA #$7E

FINDJMP CMPA ,U+
 BNE FINDJMP
 PULS A,B
 CMPD ,U
 BNE SETJMP
 LDA #$EF
 STA ,U
 PULS U
 BSR MVERIFY

* Kill warm reset. It won't work anymore.

 LDD #$00FF
 STD >$0071

 LEAX GOODMSG,PCR

WRITEOUT LDA #2
 LDY #80
 OS9 I$WRITLN
 CLRB
 OS9 F$EXIT

WRONGVSN LEAX BADVERSN,PCR
 BRA WRITEOUT

PATCHED LEAX PATCHMSG,PCR
 BRA WRITEOUT

* MVERIFY   by Kevin K. Darling
************************************************
* module verify in memory with CRC update.
*

MVERIFY TFR U,X x is mod address

 LDY M$SIZE,X y is mod size
 LEAY -3,Y beginning of chksum
 TFR Y,D y is byte count
 LEAU D,U set u to chksum
 LDA #$FF init chksum
 STA ,U
 STA 1,U
 STA 2,U
 PSHS U
 OS9 F$CRC calc new crc
 PULS U
 COM ,U+
 COM ,U+
 COM ,U
 RTS

 EMOD
SIZE EQU *
 END