;Z3AP60.ASM ; ; ; This is a BIOS overlay to install ZCPR3 on an Apple II/II+/IIe ;with the Microsoft Z80 Softcard and CP/M 2.23. Patches unrelated to ZCPR ;are included to install the BIOS printer status routine for a parallel ;interface and prevent the screen from clearing on warm boot when using the ;Apple //e 80 column card. All features of ZCPR3 are supported except ;redirected I/O. This overlay should be assembled with the MAC assembler. ;Other files needed are ZCPR3.ASM, Z3HDR.LIB, Z3BASE.LIB, DDT.COM and ;CPM60.COM from the system master disk. The purpose of this overlay and it's ;routines is described in the ZCPR3 installation manual. ; ; ZCPR3 requires approximately 5K of external buffer allocation for a ;full installation. The approach taken here is to leave the BIOS and BDOS ;at their normal locations and locate the buffers between ZCPR3 and BDOS. ;The specific size and locations are determined from the Z3BASE.LIB file that ;needs to be edited for your choice of options before assembly of this ;overlay. The buffer area is protected from being overwritten by setting the ;BDOS vector to point 7 locations after ZCPR3 as if BDOS immediately followed ;ZCPR3. A vector is installed at this location that points to the true BDOS ;entry point. A workable memory allocation is as follows: ; ; 003B wheel byte ; 003D maxdrv (1) ; 003F maxusr (1) ; 0040-0048 command search path ; C000-C7FF ZCPR3 (2) ; C806-C808 jump to BDOS entry ; C809-D5FF resident command package (3) ; D600-D7FF flow command package ; D800-D8FF environment descriptor ; D900-D97F shell stack ; D980-D9CF message buffers ; D9D0-D9FF external file control block ; DA00-DAFF named directory buffer ; DB00-DBCF command line buffer ; DBD0-DBFF external stack ; DC00-F9FF BDOS ; FA00-FFFF BIOS ; ; (1) These locations are not ZCPR3 specific and are used if ; operating a RCPM system ; (2) ZCPR must start on an even 256 byte page boundary ; to satisfy the 6502 disk bootstrap loader routines ; (3) This is larger than required but allows for future expansion ; ; Several patches are made to the 6502 disk bootstrap loader routines ;to load ZCPR to the proper location. The location of these and other patches ;may need adjustment if your CP/M version is not 2.23. This can be verified ;by comparing your CPM60.COM installation file to the original values shown ;in the comments of the patches. DDT or EDFILE can be used to do this. ; ; After you have assembled ZCPR3.HEX and Z3AP60.HEX files, the ;following commands complete the installation: ; ; DDT CPM60.COM ; IZCPR3.HEX ; R5000 ; IZ3AP60.HEX ; R ; G0 ; SAVE 44 ZCPR3-60.COM ; ZCPR3-60 ; ; If ZCPR3 is assembled at a different location than C000, change the ;offset value in line 3. This and other procedures are explained in the ;ZCPR3 installation manual. ; ; Thor Hallen ; August 8, 1984 ; ;------------------------------------------------------------------------------ ; UPDATE LOG ;ORIGINAL RELEASE AUG 8,1984 THOR HALLEN ; ;------------------------------------------------------------------------------ ; ; ;Library file containing system addresses ; MACLIB Z3BASE ; ;General Equates ; CR EQU 0DH LF EQU 0AH ; ;The following equate identifies the location of the user patch area in ;CPM60.COM when loaded with DDT ; USRPAT EQU 0D00H ; ;The next equate accounts for the location difference of the user patch ;area in CPM60.COM and where it is actually loaded (0F200H) ; OFFSET EQU 0F200H - USRPAT ; ;The next 2 equates are used by RCPM programs to determine privilege status ; MAXDRV EQU 1 ;maximum drive (0=A, 1=B ect.) MAXUSR EQU 1 ;maximum user area (1=user0, 2=user1 ect.) ; ;The Apple disk boot loader routine requires the CCP or ZCPR to start ;on an even 256 byte page boundary. ;This test verifies that ZCPR is located on an even page boundary or ;invokes an error message otherwise. ; IF (CCP MOD 0100H) NE 0 ERROR EQU CCP-LOCATION ;CCP NOT ON EVEN PAGE BOUNDARY (0NN00H) ENDIF ; ;The following equates determine the memory page of ZCPR as ;addressed by the Z80 or 6502 ; CCPPAGE EQU CCP/0100H ; IF CCPPAGE LT 0B0H P6502 EQU CCPPAGE+10H ELSE P6502 EQU CCPPAGE+20H ENDIF ; ;Z80 macro definition for decrement B and jump on not zero ; DJNZ MACRO ?N DB 10H DB ?N-$-1 ENDM ; ;Update screen messages ; ORG 021BH ;update CPM60 sign on message ; DB 'Softcard ZCPR3',CR,LF,' 60K' ;original values: ;20 53 6F 66 74 63 61 ... ; ORG 02CB7H ;update ZCPR sign on message ; ;This message will be displayed when a disk is initially booted. ;Terminate with a zero and don't exceed 72 bytes. ; DB 'ZCPR ',Z3REV/10+'0','.',(Z3REV MOD 10)+'0',CR,LF DB MSIZE/10+'0',(MSIZE MOD 10)+'0','K TPA',CR,LF DB '(c) Richard Conn',CR,LF,LF DB 'CP/M Ver. 2.23',CR,LF DB '(c) Microsoft',CR,LF DB 0 ;original values: ;0D 0A 0A 0A 20 20 20 ;20 20 53 6F 66 74 ... ; ;Eliminate entries in keyboard translation table if not needed ; ORG 0EACH ;memory location 0F3ACH DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH ;original values: ;0B 5B 00 7F 02 5C 15 09 ; ;The first sector of the original CCP is unused except for documentation ; ORG 0F00H ;not loaded into memory ; DB 'ZCPR3 INSTALLED ' ;this format is consistent DB ' ' ;with most disk inspection DB 'THIS SECTOR IS ' ;utilities DB 'UNUSED ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' DB ' ' ;do not exceed 256 bytes ;original values: ;C3 0C D6 C3 08 D6 7F 00 ... ; ;Modify the 6502 cold boot loader routine to load only BDOS and BIOS ;ZCPR will be loaded when the BIOS cold boot routine is called ; ORG 06F8H ;bank switched memory location 0B1F8H DB P6502 ;6502 page of ZCPR for warm boot loader ;original value: F3 ; ORG 0C20H ;bank switched memory location 0B720H DB 089H ;cold boot starting 6502 memory page ;original value: 80 ; ORG 0C25H ;bank switched memory location 0B725H DB 08H ;warm boot number of sectors to load ;original value: 0A ; ORG 0701H ;bank switched memory location 0B201H DB 0C8H,08CH,0E0H,03H ;read from track 1 ;original values: 8C E0 03 C8 ; ORG 0711H ;bank switched memory location 0B211H DB 04H ;first disk sector of BDOS ;original value: 0B ; ORG 0716H ;bank switched memory location 0B216H DB 015H ;cold boot number of sectors to load ;original value: 1E ; ;Patch in fake location in warm boot routine that sets up 06H-07H ; ORG 027FAH ;memory location 0FAFAH DB CCPPAGE + 8 ;fake starting page of BDOS ;original value: DC ; ;Patch the warm boot jump to the CCP for the location of ZCPR3 ; ORG 0280FH ;memory location 0FB0FH DB CCPPAGE ;page location of ZCPR2 ;original value: D3 ; ;Prevent warm boot attempts to modify the original CCP area ; ORG 027E0H ;memory location 0FAB8H DB 0,0,0 ;prevent warm boot modification of ccp ;original values: 32 07 D3 ; ORG 02806H ;memory location 0FB06H DB 0,0,0 ;prevent warm boot modification of ccp ;original values: 32 4E D7 ; ;Install jump to Apple //e 80 column card patch ; ORG 02C72H ;memory location 0FF72H JMP IIE80C + OFFSET ;jump to apple 80 column patch ;original values: 3A 98 F3 ; ;Set BIOS LSTTST vector to LSTTST routine ; ORG 0272DH ;memory location 0FA2DH JMP LSTTST + OFFSET ;bios vector to LSTTST routine ;original values: AF C9 00 ; ;Set BIOS cold boot vector to point to ZCPR initialization sequence ; ORG 02700H ;memory location 0FA00H JMP ZPATCH + OFFSET ;point bios cold boot vector to zcpr patch ;original values: C3 EA FE ; ;Install BIOS patches in reserved user patch area ; ORG USRPAT ;start of user patch area at 0F200H ; ;Patch for Apple //e 80 column card ; IIE80C: MVI A,02H STA 0FA83H LDA 0F398H JMP 0FF75H ; ;Install the BIOS LSTTST function ; LSTTST: LDA 0E090H ;Grappler+ status register for slot 1 ANI 01H ;Grappler+ status bit RZ ;return with A=0 to indicate printer busy MVI A,0FFH RET ;return with A=FF to indicate printer ready ; ;Prepare 6502 load routine to read ZCPR from track 0 for warm boots ; ZPATCH: LDA 0E08BH ;set up first ram bank to read and write LDA 0E08BH ;with two successive reads to soft switch MVI A,0CH ;loader routine to start with first ZCPR sector STA 0B211H MVI B,4 ;set up loader to read from track 0 LXI D,TRACK0+OFFSET LXI H,0B201H CALL MOVLOP+OFFSET LDA 0E083H ;restore second ram bank LDA 0E083H ; ;Call 6502 loader routine to load ZCPR ; LXI H,0E00H ;set up 6502 address of loader routine vector SHLD 0F3D0H LHLD 0F3DEH ;load slot independent location of softcard MOV M,A ;call 6502 loader routine ; ;Place pointer to true BDOS location at fake location ; MVI B,3 LXI D,BDOSV+OFFSET LXI H,CCP+0806H CALL MOVLOP+OFFSET ; ;Initialize the external command path ; IF EXPATH NE 0 MVI B,EXPATHS*2 + 1 LXI D,PATH+OFFSET LXI H,EXPATH CALL MOVLOP+OFFSET ENDIF ; ;Initialize wheel, maxdrv and maxusr bytes ; IF Z3WHL NE 0 MVI A,0FFH STA Z3WHL MVI A,MAXDRV STA 03DH MVI A,MAXUSR STA 03FH ENDIF ; ;Initialize rcp buffer ; IF RCP NE 0 LXI H,RCP CALL ZERO128+OFFSET ENDIF ; ;Initialize flow command package buffer ; IF FCP NE 0 LXI H,FCP CALL ZERO128+OFFSET ENDIF ; ;Initialize the environment descriptor ; IF Z3ENV NE 0 LXI H,Z3ENV MVI B,128+16 CALL ZEROM+OFFSET ENDIF ; ;Initialize the shell stack ; IF SHSTK NE 0 XRA A STA SHSTK ENDIF ; ;Initialize message buffer ; IF Z3MSG NE 0 LXI H,Z3MSG MVI B,80 CALL ZEROM+OFFSET ENDIF ; ;Initialize named directory buffer ; IF Z3NDIR NE 0 LXI H,Z3NDIR CALL ZERO128+OFFSET ENDIF ; ;Initialize command line buffer ; IF Z3CL NE 0 LXI D,CMDSET+OFFSET LXI H,Z3CL MVI B,CMDEND-CMDSET+1 ELSE LXI D,CMDSET+OFFSET+4 LXI H,CCP+8 MVI B,CMDEND-CMDSET-3 ENDIF CALL MOVLOP+OFFSET ; JMP 0FEEAH ;jump to original cold boot ; MOVER: MVI B,128 MOVLOP: LDAX D MOV M,A INX D INX H DJNZ MOVLOP RET ZERO128: MVI B,128 ZEROM: MVI M,0 INX H DJNZ ZEROM RET ; ;Start of data storage area ; PATH: DB 1,0,0,0,0,0,0,0,0 ;default search path BDOSV: DB 0C3H,06H,0DCH ;BDOS vector TRACK0: DB 08CH,0E0H,03H,0C8H ; ;The following test verifies that the previous initialization routines ;fit in the available user patch space. ; IF $ GT USRPAT+0100H ERROR EQU PATCH-SIZE ;PATCHES EXCEED AVAILABLE MEMORY ENDIF ; ;Initial command line on even disk sector boundary for easy location ; ORG USRPAT+0100H CMDSET: DW Z3CL+4 DB Z3CLS,0 ;initial command line DB 'STARTUP' DB 0 CMDEND: ; ; END