title hsysgen harddisk fuer prof-80 ; -- cp/m 3.0 -- ; _______________________________________ ; autor wilfried schmitten, heidebloeck 16, 2000 hamburg 74 ; letzte aenderung 25. Juni 1989 ; fuer direkten HD Boot ab PROF 1.7 ; kopiert zusaetzlich das File HBOOT.HD nach ; track 0 sector 0 der Festplatte ; 17.11.87 ; Filenamen hboot.hxc und cpmldr.hxc eingefuehrt ; 11.2.89 Wilfried ; assemblieren mit slr assembler z80asm hsysgen/a ; Das Gerippe dieses Programms wurde von Conitecs ; csysgen uebernommen und nach z80 uebertragen. ; kopiert das HBOOT.HXC nach track 0 sector 0 ; des angegebenen Laufwerks sowie CPMLDR.HXC nach track ; 0 sector 2 der Festplatte maclib cdef.lib maclib syspage.lib ; bdos equ 00005h openfile equ 15 readseq equ 20 setdma equ 26 multisec equ 44 wboot equ 00000h tpa equ 100h epromcode equ 2000h ;hierher werden die eprom routinen geladen systemsave equ epromcode+900h stack equ epromcode+400h ; ; ; monsetcmdt equ 15h monread equ 27h monwrite equ 2ah montest equ 41h ; ; ; ld hl,kennung ;pruefe ob prof-80 computer ld de,prof80 ; ld b,7 ; checkloop: ; ld a,(de) cp (hl) jr nz,computer$falsch ; djnz checkloop ; ld a,(current$bank) ;pruefe ob bank 0 oder bank 1 and 0feh ; jr z,checkok ;sprung wenn computer = prof-80 und bank0/1 computer$falsch: ld hl,falschtxt ;gebe fehlermeldung aus call sout ; jp wboot ; ; falschtxt: db 0dh,0ah,'Error HSYSGEN runs only in bank 0 or bank 1' db 0dh,0ah,'of a PROF-80 computer',0dh,0ah,'$' prof80 db 'PROF-80' ; checkok: ; ld sp,stack ;setze stack neu ld hl,switchcode ;copiere eprom ld de,epromcode ;routinen ld bc,epromcodel ; ldir ; ld hl,anftxt ;gebe version aus call sout ; start: ld hl,lf3 call sout ld hl,hbname ;hboot call sout ld hl,stext ;lese source drive ein call sout ; call conin ;lese laufwerkbuchstaben ein call echo ; jr c,mainlp2 ; call valid1 ;laufwerks angabe korrekt? jr nc,mainlp1 ;sprung wenn ok ld hl,etext1 ; call sout ; jr start ;neue eingabe mainlp1 ld (drivecr),a ;speichere buchstaben ab ld hl,setext ;gebe lw. nochmal aus call sout ; ld a,(drivecr) ; ld c,a ; call conout ; ld hl,eetext ; call sout ; call conin ; call echo ; jr nc,start ; ld a,'B' ld (type),a call getsys ;lese system ein ld hl,hbname call sout ld hl,hbgel ;hboot call sout ld hl,qtext ; call sout ; mainlp2: ld hl,dtext ; call sout ; call conin ;lese zeichen call echo ;zurueck zur konsole jp c,start2 ;war return, weiter zum hboot.hxc call valid ;pruefe ob zeichen ok jr nc,mainlp3 ; ld hl,etext ; call sout ; jr mainlp2 ;neue eingabe mainlp3 ld (drivecr),a ;lege laufwerkbuchstabe ab ld hl,detext ; call sout ; ld a,(drivecr) ; call echo ; ld hl,eetext ; call sout ; call conin ; call echo ; jr nc,mainlp2 ; ld a,(type) ;richtiges File cp 'B' jp nz,start ;im Speicher? call putsys ; ld hl,hbname call sout ld hl,hbges call sout ld hl,qtext ; call sout ; ;---------------------------------------------------- start2: ld hl,hb1name ;hboot.hd call sout ld hl,stext ;lese source drive ein call sout ; call conin ;lese laufwerkbuchstaben ein call echo ; jr c,mainlp21 ; call valid1 ;laufwerks angabe korrekt? jr nc,mainlp11 ;sprung wenn ok ld hl,etext1 ; call sout ; jr start2 ;neue eingabe mainlp11: ld (drivecr),a ;speichere buchstaben ab ld hl,setext ;gebe lw. nochmal aus call sout ; ld a,(drivecr) ; ld c,a ; call conout ; ld hl,eetext ; call sout ; call conin ; call echo ; jr nc,start2 ; ld a,'H' ld (type),a call getsys1 ;lese system ein ld hl,hb1name call sout ld hl,hbgel ;hboot.hd call sout ld hl,qtext ; call sout ; mainlp21: ld hl,?text ; call sout ; ld hl,?text1 call sout call conin ;lese zeichen call echo ;zurueck zur konsole jp c,start1 ;war return, weiter cp 'Y' jr z,mainlp31 cp 'y' jr z,mainlp31 jp start2 ;wiederholen mainlp31 ld a,(type) ;richtiges File cp 'H' ;im Speicher? jp nz,start2 ld b,0 ;Sektor Nr ld c,1 ;Sektor Anz. call hdwrite ld hl,hb1name call sout ld hl,hbges call sout ld hl,qtext ; call sout ; jp start1 ; ;---------------------------------------------------- start1 ld hl,hlname ;cpmldr call sout ld hl,stext ;lese source drive ein call sout ; call conin ;lese laufwerkbuchstaben ein call echo ; jr c,mainlp20 ; call valid1 ;laufwerks angabe korrekt? jr nc,mainlp10 ;sprung wenn ok ld hl,etext1 ; call sout ; jr start1 ;neue eingabe mainlp10 ld (drivecr),a ;speichere buchstaben ab ld hl,setext ;gebe lw. nochmal aus call sout ; ld a,(drivecr) ; ld c,a ; call conout ; ld hl,eetext ; call sout ; call conin ; call echo ; jr nc,start1 ; ld a,'L' ld (type),a call getldr ;lese Lader ein ld hl,hlname ; call sout ld hl,hbgel call sout ld hl,qtext ; call sout ; mainlp20: ld hl,?text ; call sout ; ld hl,??text call sout call conin ;lese zeichen call echo ;zurueck zur konsole jp c,wboot ;war return, zurueck zum cp/m cp 'Y' jr z,hldr1 cp 'y' jr z,hldr1 jp start ;neue eingabe hldr1 ld a,(type) ;richtiges File cp 'L' ;im Speicher? jp nz,start1 ld b,2 ;Sektor Nr ld c,12 ;Sektor Anz 12x512 = 6K call hdwrite ld hl,hlname call sout ld hl,hbges call sout ld hl,qtext ; call sout ; jp start ; ; ; ; getsys: ld a,0 ; ld (writeflag),a ; ld (bootfcb+12),a ld (bootfcb+32),a ld a,(drivecr) sub a,'@' ld (bootfcb),a ld de,systemsave ld c,setdma call bdos ld c,openfile ld de,bootfcb call bdos inc a jp z,bdoserr ld e,4 ;512 byte lesen ld c,multisec call bdos ld de,bootfcb ld c,readseq call bdos or a ret z dec a ;reading unwritten Data jp nz,bdoserr ;ist zulaessig ret ; getsys1: ld a,0 ; ld (writeflag),a ; ld (hbootfcb+12),a ld (hbootfcb+32),a ld a,(drivecr) sub a,'@' ld (hbootfcb),a ld de,systemsave ld c,setdma call bdos ld c,openfile ld de,hbootfcb call bdos inc a jp z,bdoserr ld e,4 ;512 byte lesen ld c,multisec call bdos ld de,hbootfcb ld c,readseq call bdos or a ret z dec a ;reading unwritten Data jp nz,bdoserr ;ist zulaessig ret getldr: ld a,0 ; ld (writeflag),a ; ld (ldrfcb+12),a ld (ldrfcb+32),a ld a,(drivecr) sub a,'@' ld (ldrfcb),a ld de,systemsave ld c,setdma call bdos ld c,openfile ld de,ldrfcb call bdos inc a jp z,bdoserr ld e,48 ;6 Kbyte lesen ld c,multisec call bdos ld de,ldrfcb ld c,readseq call bdos or a ret z dec a ;reading unwritten data jp nz,bdoserr ;ist zulaessig ret ; ; putsys: ld a,0ffh ; ld (writeflag),a jp getputsys ; ; ; ; bdoserr ld hl,notfound call sout ld a,(type) ld hl,hbname cp 'B' jr z,bd1 ld hl,hb1name cp 'H' jr z,bd1 ld hl,hlname bd1 call sout jp start getputerr: pop hl ;fehlermeldung fuer schlechte systemspuren ld hl,btrktxt call sout ld hl,sotxt ld a,(writeflag) or a jr z,badtrk1 ld hl,detxt badtrk1 call sout jp start btrktxt db 0dh,0ah,'bad system track on $' sotxt db 'source$' detxt db 'destination$' ; ; ; lf3: db 0dh,0ah,0ah,0ah,24h anftxt db 0ah,0dh db 'HSYSGEN WS V 1.2',0ah,0dh,24h ; ; ; stext db 0ah,0dh db 'source drive name (or return to skip) ' db 24h ; qtext: db ', function complete' db 24h ; etext db 0ah,0dh db 'invalid drive name (use A,B,C or D)' db 24h etext1 db 0ah,0dh db 'invalid drive name (use A - P)' db 24h ; dtext db 0ah,0dh db 'destination drive name (or return to skip )' db 24h ; detext db 0ah,0dh db 'destination on ' db 24h ; setext db 0ah,0dh db 'source on ' db 24h ; eetext db ', then type return' db 24h ; hbname db 0ah,0dh db 'HBOOT.HXC' db 24h hb1name: db 0ah,0dh db 'HBOOT.HD' db 24h hbgel db ' read' db 24h hbges db ' written' db 24h hlname db 0ah,0dh db 'CPMLDR.HXC' db 24h ?text1: db 0ah,0dh db '(or return to skip) ' db 24h ?text db 0ah,0dh db 'write to systemtrack harddisk ? (y/n) ' db 24h ??text db 0ah,0dh db 'or type return to reboot ' db 24h notfound db 0ah,0dh db 'File not found' db 24h valid: ;setzt carry flag, wenn zeichen in a ;kein gueltiger laufwerksbuchstabe ist cp 'A' ret c cp 'E' jr c,nret sret scf ret nret scf ccf ret valid1: ;setzt carry flag, wenn zeichen in a ;kein gueltiger laufwerksbuchstabe ist cp 'A' ret c cp 'Q' jr c,n1ret scf ret n1ret ccf ret ; ; ; echo: ;schreibt zeichen in a auf konsole ;bei cr wird cr lf ausgegeben und carry gesetzt ; ld c,a ; call conout ; cp 0dh ; jr nz,nret ;ohne carry zurueck ld c,0ah ; call conout ; jp sret ;mit carry zurueck ; ; ; conout push af ; push bc ; push de ; push hl ; ld e,c ; ld c,6 ; call bdos ; pop hl ; pop de ; pop bc ; pop af ; ret ; ; ; ; conin push bc ; push de ; push hl ; conin1 ld e,0ffh ;input ld c,6 ; call bdos ; cp 00h ; jr z,conin1 ; cp 'a' ;wandle in grossbuchstaben jr c,conin2 ; sub a,'a'-'A' ; conin2 pop hl ; pop de ; pop bc ; ret ; ; ; ; sout: ;gibt asciistring aus (anfang in hl,ende durch $) ; ld a,(hl) cp 24h ;ende des strings ? ret z ; ld c,a ; call conout ; inc hl ; jp sout ; ; ; ; ;------------------------------------------------------------ ; ; getputsys: ;wenn writeflag=0 dann lese die systemspuren ;wenn writeflag <> 0 dann schreibe die systemspuren ; xor a ;setze cmdtab fuer spur eins ld (test$track),a ; ld a,(drivecr) ;setze unit dec a ; and 00000011b ; ld (unit),a ; call test ;teste drive call setcmdt ;setze cmdtabelle xor a ; ld (track),a ; ld (head),a ; ; ld a,1 ;lade/schreibe bootsektor ld (sector),a ; ld a,4 ld (sectcnt),a ; ld hl,systemsave ; ld (dmaadr),hl ; ld a,(writeflag) ; or a ; jr z,bootsek1 ; call write ; jr bootsek2 ; bootsek1: ; call read ; bootsek2: ; jp nz,getputerr ; ret ; ; bootfcb db ' HBOOT HXC' db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 hbootfcb db ' HBOOT HD ' db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ldrfcb db ' CPMLDR HXC' db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 drivecr ds 1 ;zwischenspeicher fuer laufwerk chr writeflag ds 1 ; type: ds 1 ;------------------------------------------------------------------- error call waitrdy in a,(hd$data) and 2 ret z reqsense: ld a,3 ;request sense command ld hl,cdb$com ld (hl),a xor a ld b,5 ;weitere 5 byte 0 reqloop inc hl ld (hl),a djnz reqloop call command ld hl,sense$data ;ergebnispuffer ld c,hd$data ld b,4 ;4 byte lesen req1 call waitrdy ini jr nz,req1 ret waitrdy: in a,(hd$status) ;warten auf and 1 ret nz ;request transfer jr waitrdy command: out (hd$select),a ;controller mit dummy ansprechen ld hl,cdb$com ;com descriptor block ld b,6 ; 6 byte ld c,hd$data comloop call waitrdy outi jr nz,comloop ret hdwrite ld a,10 ;write command Šhdrwcom ld (cdb$com),a ;command ablegen xor a ld (cdb$head),a ;head 0 ld (cdb$cylinder),a ;track 0 ld a,b ld (cdb$sector),a ;sector ld a,c ld (cdb$count),a ld a,1 ld (cdb$control),a call command call waitrdy hdrwc in a,(hd$status) Š and 4 jr nz,hderr1 ld hl,systemsave ;dma adress ld c,hd$data rwpatch outi rwloop in a,(hd$status) rra jr nc,rwloop ;kein data request and 2 jr z,rwpatch ;naechstes byte data hderr1 jp error ;------------------------------------------------------------------- ; switchcode: ;dieser bereich wird nach epromcode ;kopiert, damit monitor up's benutzt werden ;koennen ; ; ; readoff equ $-switchcode call epromon call monread call epromoff ret ; writeoff equ $-switchcode call epromon call monwrite call epromoff ret ; testoff equ $-switchcode call epromon call montest call epromoff ret ; setcmdtoff equ $-switchcode call epromon call monsetcmdt call epromoff ret ; epromonoff equ $-switchcode push af ; ld a,(epromz) ; or a ; jr nz,epromon1 ; inc a ; ld (epromz),a ; push bc ; ld b,0 ;kachel 0 ld c,p$ram$table ;port der ram tabelle ld a,0 ;eprom bank out (c),a ; ld b,10h ;kachel 1 out (c),a ; pop bc ; pop af ; ret ; epromon1 inc a ; ld (epromz),a ; pop af ; ret ; epromoffoff equ $-switchcode push af ; ld a,(epromz) ; dec a ; jr nz,epromoff1 ; ld (epromz),a ; push bc ; ld b,0 ;kachel 0 ld c,p$ram$table ;port ld a,(current$bank) ;alte tpa bank add 2 ;phys adr. out (c),a ; ld b,10h ; out (c),a ; pop bc ; pop af ; ret ; epromoff1 ld (epromz),a ; pop af ; ret ; ; read equ readoff+epromcode write equ writeoff+epromcode test equ testoff+epromcode setcmdt equ setcmdtoff+epromcode epromon equ epromonoff+epromcode epromoff equ epromoffoff+epromcode ; epromcodel equ $-switchcode end