Title System Loader for CPM3+ (23_Mar_84) Copyright 1984, Morrow Designs, Inc. ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; Bill Smith ; .z80 cseg ; To Assemble and Link This File use the following command lines ; A>m80 =ldrbios ; A>link bootldr[l4000]=cpmldr,ldrbios,scb ; ;---------------------------------------------------------------------- ; Include Files ;-------------- ; .sall ;Suppress all Macro Expansions .xlist ;Supress Listing of Include Files Include HD22DEF.MAC ;General Definitions/Equates Include DRIVES.MAC ;Drive Definitions Include DEFINE.MAC ;Drive Selection .list ;Resume Listing page 64 ;---------------------------------------------------------------------- ; External Declarations (22_Mar_84) ;---------------------------------- ; External @civec ;Console Input Redirection Vector External @covec ; " Output " " External @aivec ;Aux Input " " External @aovec ; " Output " " External @lovec ;List " " " External @bnkbf ;128 byte buffer for banked bios External @crdma ;Current DMA Address External @crdsk ;Current Disk External @vinfo ;Bdos Variable Information External @resel ;FCB Flag External @fx ;Bdos Function for Error Messages External @usrcd ;Current User Code External @mltio ;Current sector count External @ermde ;Error Mode External @erdsk ;Error Disk External @media ;Door Open Flag External @bflgs ;Message Size Flag External @date ;Date (since 1_Jan_84) External @hour ;Hours (BCD) External @min ;Minutes (BCD) External @sec ;Seconds (BCD) External ?erjmp ;Error Message Jump External @mxtpa ;Top of the TPA ;---------------------------------------------------------------------- ; Equates ;-------- ; ;Rom Jump Table Definitions rom equ 0 rdhsrm equ rom+9 ;rom read disk routine wrhsrm equ rom+0Ch ;rom write disk routine page ;---------------------------------------------------------------------- ; Jump Table (from cp/m plus version 3.0) ;---------------------------------------- ; jp boot ;arrive here from cold start load warmpt: jp wboot ;arrive here for warm start jp const ;return console input status jp conin ;read console character jp conout ;write conlole character jp list ;write list character jp auxout ;write aux character jp auxin ;read aux character jp home ;move to track zero on selected drive jp seldsk ;select disk drive jp settrk ;set track number jp setsec ;set sector number jp setdma ;set DMA address jp read ;read selected sector jp write ;write selected sector jp listst ;return list device status jp sectrn ;translate logical to physical sector number jp conost ;return console output status jp auxist ;return aux device input status jp auxost ;return aux device output status jp devtbl ;return address of character i/o table jp devini ;init character i/o devices jp drvtbl ;return address of disk drive table jp multio ;set number of consec. sec. to read/write jp flush ;flush user [de]blocking buffers jp move ;copy memory to memory jp time ;clock support jp selmem ;select memory bank jp setbnk ;set bank for next DMA jp xmove ;set banks for next move jp userf ;reserved for me. jp wboot ;reserved for DRI jp wboot ;reserved for DRI page ;---------------------------------------------------------------------- ; Definitions of Null Routines (13_Sept_84) ;------------------------------------------ ; conost: listst: auxist: auxost: list: auxout: auxin: flush: time: write: setbnk: userf: selmem: xmove: multio: home: wboot: devtbl: devini: drvtbl: ret page ;---------------------------------------------------------------------- ; Cold Boot Routine ;------------------ ; ;save interrupt vectors boot: ld hl,0fff0h ;source ld de,irq_vec_buf ;dest ld bc,16 ;leng ldir ;copy ret ;---------------------------------------------------------------------- ; Console Input Status Routine (13_Sept_84) ;------------------------------------------ ; ConSt: in a,(S1Stat) ;Get the Console Input Status and $RcvRdy ;If (No Character ready) ret z ; Return (A:= 0) ld a,0FFh ;Else ret ; Return (A:= 0FFh) ;---------------------------------------------------------------------- ; Console Input Routine (13_Sept_84) ;----------------------------------- ; ConIn: in a,(S1Stat) ;Repeat Get the Console Input Status and $RcvRdy ; Mask off all but input status jr z,ConSt ;Until (Input Character eq Recieved) in a,(S1Data) ;A:= Input Character ret ;---------------------------------------------------------------------- ; Console Output Routine (13_Sept_84) ;------------------------------------ ; ConOut: in a,(S1Stat) ;Repeat Get the Console Output Status and $TxRdy ; Mask off all but output status jr z,ConOut ;Until (Buffer eq ready) ld a,c ;A:= Character to Output out (S1Data),a ;Output the character ret ;Return page ;---------------------------------------------------------------------- ; Set the Track ;-------------- ; settrk: ld (hsttrk+ramdaty),bc ;set track in ramdaty ret ;---------------------------------------------------------------------- ; Set the Sector ;--------------- ; setsec: ld (hstsec+ramdaty),bc ;set sector in ramdaty ret ;---------------------------------------------------------------------- ; Set the Current DMA Address ;---------------------------- ; setdma: ld (dmaadr+ramdaty),bc ;set dma address in ramdaty ret ;---------------------------------------------------------------------- ; Sector Translation ;------------------- ; sectrn: ld l,c ;hl=bc ld h,b inc hl ;start sectors at 1 ld a,d ;see if xlat table or e ret z ;return if no xlat ex de,hl ;hl=xlt add hl,bc ;add to table ld l,(hl) ;get xlated sector ld h,0 ret page ;---------------------------------------------------------------------- ; Select the Disk ;---------------- ; seldsk:: ;select drive 0, 1k sectors, others set-up if floppy ld a,5 else ld a,9 endif ld (physpt+ramdaty),a ;set sectors for BAD ld hl,dpha ret ;---------------------------------------------------------------------- ; Read a Sector ;-------------- ; read:: ld iy,ramdaty ;set-up iy -> ramdaty call rdhsrm ;read from disk ld de,(dmaadr+ramdaty) ;destination address ld hl,dskbuf ;source address ld bc,400h ;number of bytes to transfer ldir or a ;If (No Error) ret z ; Return (accm=0) ld a,1 ;Else ret ; Return (accm=1) ;---------------------------------------------------------------------- ; Move a Block of Memory ;----------------------- ; first call here is to move highest 128 bytes (ff80-ffff) ; on first call, replace vectors ; move: ex de,hl ldir ex de,hl ld a,h or l ret nz ;if [hl] = 0, just clobbered vectors push hl push de ld hl,irq_vec_buf ;source ld de,0fff0h ;top 16 bytes of memory ld bc,16 ldir pop de pop hl ;restore ret page ;---------------------------------------------------------------------- ; Data Areas ;----------- ; ramdatY: db 0 ;(SEKDSK) BDOS disk number dw 0 ;(SEKTRK) BDOS track number ; dw 0 ;(SEKSEC) BDOS sector number ; dw 0 ;(SEKHST) Actual sector number on the disk ; db 0 ;(UNACNT) Unallocated record count db 0 ;(UNADSK) Unallocated disk number dw 0 ;(UNATRK) Unallocated track number ; dw 0 ;(UNASEC) Unallocated sector number ; db 0 ;(UNAMAX) Sectors per Unallocated block dw 0 ;(SECTRK) Logical Sectors per track ; db 0 ;(PHYSPT) Physical sectors per track db 0 ;(WRTYPE) Write type db 0 ;(CFLAG) Flag Byte db 0 ;(DFLAG) Flag Byte db 0 ;(TRSEC) Offset to logical sector within physical sector dw 0 ;(VMSGP) Pointer to virtual drive message ; dw 0 ;(VDRVP) Pointer to virtual drive in message ; db 0FFh ;(CDSK) Current drive db 0 ;(VDSK) Current virtual drive dw 0 ;(DMAADR) BDOS DMA address ; dw conout ;(CONOUT) Pointer to Current console output routine ; dw conin ;(CONIN) Pointer to Current console input routine ; dw const ;(CONSTS) Pointer to Current console status routine db 0 ;(CPYBNK) Copy of bank strobe (printer restore = false) page ;---------------------------------------------------------------------- ; Default Application Interface area (13_Oct_83) ;----------------------------------------------- ; APIF: db 0 ;(HSTDRV) BDOS Drive Number (1st floppy) dw 0000 ;(HSTTRK) Desired Cylinder (lo) ; Desired Cylinder (hi) dw 1 ;(HSTSEC) Desired Sector (lo) ; Desired Sector (hi) db 1 ;(SECCNT) Number of sectors to transfer db 20 ;(RETRY) Retry Count dw dskbuf ;(HSTBUF) Buffer Address (lo) ; Buffer Address (hi) db 0 ;(ERFLAG) Error Code db 0 ;(OPFLAG) Options Flag dw 0 ;(PHYTRK) Physical track number (lo) ; Physical track number (hi) db 0 ;(PHYSEC) Physical sector number db 0 ;(PHYHD) Desired Head db 2 ;(PHYDRV) Physical Drive Number dw 0 ;(IOADD) Execution Address (lo) ; Execution Address (hi) page ;---------------------------------------------------------------------- ; Ram MTABs (3_Oct_83) ;--------------------- ; mtab: mtma ;make mtab ;---------------------------------------------------------------------- dpbase: dpha: if floppy dw xlt1k ;xlt else dw 0 endif ds 10,0 ;scratch dw dpba ;dpb dw 0 ;csv dw 0 dw dirbcb dw dtabcb dw -1 ;hash db 0 ;hbank dphlen equ $-dpha dirbcb: db -1 ds 9,0 dw dirbuf ds 3,0 dtabcb: db -1 ds 9,0 dw dtabuf ds 3,0 dpbma ;make dpb xlt1k: db 1,4,2,5,3 irq_vec_buf equ $ dirbuf equ irq_vec_buf+16 dtabuf equ dirbuf+1024 end