* * This is the original DigRes SYSGEN broken and * annotated - modified for the Morrow DJ system. * W6BSK 1 May 83 DISZILOG dissassembler. * wboot equ 00000h ;warm boot entry cbios equ 00001h ;offset constant bdos equ 00005h ;bdos entry point fcblk equ 0005ch ;file control block address flname equ 0005dh ;first character of fname currcd equ 0007ch ;current record flag stores equ 00900h ;storage area in ram maxsec equ 0001ah ;maximum sector count org 0100h begin: jp start ;skip over nonsense defb 'copyright (c) 1978, digital research ' ntraks: defb 02 ;number of system tracks nsctrs: defb 1ah ;number of sectors per track sktabl: defb 01,02,03,04,05,06,07,08,09,0ah,0bh,0ch,0dh,0eh,0fh defb 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1ah,1bh,1ch,1dh,1eh,1fh defb 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2ah,2bh,2ch,2dh,2eh,2fh defb 30h defs 10h setcnt: ld c,010h ;set count to move mover: ld a,(hl) ;get entry inc hl ;move to next ld (de),a ;save entry into buffer inc de ;and update dec c jp nz,mover ;loop until done ret block: ld l,a ;get current store address ld h,000h ;clear upper byte add hl,hl ;x2 add hl,hl ;x4 add hl,hl ;x8 add hl,hl ;x16 add hl,hl ;x32 add hl,hl ;x64 add hl,hl ;x128 ret ;return with address upped 1 block chinpt: ld c,001h ;set bdos vector for input call bdos ;and input from keyboard cp 061h ;lower case? ret c ;carry set if not cp 07bh ret nc ;not legal input. and 05fh ;convert if necessary ret ;and return. cbdos: ld e,a ;set bdos vector for ld c,002h ;output to display jp bdos ;and do it. crlnfd: ld a,00dh ;this loads and executes call cbdos ;a carriage return/line feed ld a,00ah ;pair jp cbdos gcrlfd: push hl ;stack hl and do a cr/lf call crlnfd pop hl dsplay: ld a,(hl) ;get the character or a ;and test for binary 00 ret z push hl call cbdos ;do it pop hl inc hl ;and get the next one jp dsplay ;and repeat until done. scount: ld hl,(dpaddr) ;get dp address ex de,hl ;swap call setcnt ;and move line setdrv: ld a,(drive) ;get binary drive value ld c,a ld de,00018h ;set setdrv offset jp jmptbl settrk: ld de,0001bh ;set trakset offset jp jmptbl setsec: ld de,0001eh ;set setsec offset jp jmptbl setdma: ld de,00021h ;set setdma offset jp jmptbl setred: ld de,00024h ;set read offset jp jmptbl setwrt: ld de,00027h ;set write offset jmptbl: ld hl,cbios ;get cbios jump table add hl,de ;add in offset jp (hl) ;and jump into table. redseq: ld c,014h ;set vector to jp bdos ;sequential read opnfil: ld c,00fh ;set vector to jp bdos ;open the file params: ld a,maxsec ;get max sector number ld (nsctrs),a ;and save it call setdrv ;set the proper drive ld a,h and l ;test for good set jp z,badrt ;badbad ld de,0000ah ;load offset into dpb add hl,de ld e,(hl) inc hl ;read from table ld d,(hl) ex de,hl ;and put in pointer ld (dpaddr),hl ;save it ld de,dpbdat call setcnt ;move line into buffer ld de,moddpb call scount ld hl,stores ;point to store area ld (pointr),hl ;and save start address ld a,0ffh ;initialize counter ld (curtrk),a ;save current track-1 chktrk: ld hl,curtrk ;get current track inc (hl) ;and update it ld a,(ntraks) ;number system tracks cp (hl) ;stop at track 2 jp z,return ;this is just a return: ld c,(hl) call settrk ;set the current track ld a,0ffh ;initialize sector-1 ld (csectr),a ;and start sector load redsec: ld a,(nsctrs) ;get max sector number ld hl,csectr ;point to current inc (hl) ;update it cp (hl) ;test for done- jp z,ndtrk0 ;last sector ld hl,csectr ld e,(hl) ld d,000h ;get current sector ld hl,sktabl ;and skew table start ld b,(hl) ;b = 01 add hl,de ;go into table ld c,(hl) ;and get physical sector push bc call setsec ;set up for it pop bc ld a,c sub b call block ex de,hl ;calculate dma address ld hl,(pointr) ;start at 0900h, natch add hl,de ld b,h ld c,l call setdma ;and set it. xor a ld (rdwrit),a ;initialize r/w flag tstflg: ld a,(rdwrit) cp 00ah jp c,testrw ld hl,error ;"Permanent error" call dsplay call chinpt cp 00dh ;c/r ignores it jp nz,exit call crlnfd jp redsec testrw: inc a ;update flag ld (rdwrit),a ld a,(trpflg) ;read or write? or a jp z,getred ;read call setwrt ;write jp getwrt getred: call setred ;go to read jump getwrt: or a ;test for good setup jp z,redsec ;good, read it jp tstflg ;now test for more ndtrk0: ld hl,01600h ;done with track 0 ld (pointr),hl ;set new pointer ld a,030h ;to start track 1 ld (nsctrs),a ; new sectr count ld de,dpbdat ;start new read call scount jp chktrk return: ret start: ld sp,stack ;set the stack pointer ld hl,signon ;and get sign-on msg call dsplay ld a,(flname) ;get fname cp 020h ;test for one present jp z,nofile ; none, branch & get drive ld de,fcblk ;otherwise use filename call opnfil ;open the file inc a jp nz,sorcok ;test for file present ld hl,nsrce ;if not, write error message call gcrlfd jp exit ;and go back to cp/m sorcok: xor a ;good open, use it ld (currcd),a ;clear cr byte ld c,010h ;set for one block lodbfr: push bc ld de,fcblk call redseq ;get sector from disc pop bc or a jp nz,eofile ;end of file read dec c jp nz,lodbfr ;get the next byte ld hl,stores ;loaded, store it fillbf: push hl ld b,h ld c,l call setdma ;store it ld de,fcblk call redseq ;get byte pop hl or a ;test read jp nz,dstdrv ;branch if good read ld de,00080h ;not good- add hl,de jp fillbf ;oh, really? eofile: ld hl,incmp ;get incomplete message call gcrlfd jp exit ;and return to cp/m nofile: ld hl,sdname ;no file requested call gcrlfd ;dsplay source request call chinpt ;and get the source choice cp 00dh ;c/r means already in memory. jp z,dstdrv ;so use it. sub 041h ;test for legal drive request cp 004h jp c,source ;ok, use it call baddrv ;not good - say so jp nofile ;and try again source: add a,041h ;convert back to ascii ld (sdriv),a ;and save it. sub 041h ;make binary gain ld (drive),a ;and save that, too. call crlnfd ld hl,srcon ;display source message call dsplay call chinpt ;ask for destination drive cp 00dh jp nz,exit ;must be c/r call crlnfd xor a ;clear trip flag ld (trpflg),a call params ;go to it, baby. ld hl,fcmpt call dsplay dstdrv: ld hl,dname call gcrlfd call chinpt cp 00dh jp z,exit ;c/r always bombs out sub 041h ;convert to binary cp 004h ;and test for legal jp c,wrtdst ;ok, go call baddrv ;no, dsplay error message jp dstdrv ;and try again wrtdst: add a,041h ;convert to ascii ld (ddriv),a ;and save as dest drive sub 041h ;return to binary ld (drive),a ;and stuff it away. ld hl,dmesg ;show destination message call gcrlfd call chinpt cp 00dh jp nz,exit ;quit on anything else call crlnfd ld hl,trpflg ld (hl),001h call params ld hl,fcmpt call dsplay jp dstdrv badrt: call baddrv exit: xor a ld (drive),a call setdrv call crlnfd jp wboot baddrv: ld hl,inval ;point to invalid drive message jp gcrlfd ;and dsplay it signon: defb 'sysgen ver 2.2' defb 000h sdname: defb 'source drive name (or return to skip) defb 000h srcon: defb 'source on ' sdriv: defb 0cdh defb ' then type return' defb 000h dname: defb 'destination drive name (or return to reboot)' defb 000h dmesg: defb 'destination on ' ddriv: defb 00dh defb ', then type return' defb 000h error: defb 'permanent error, type return to ignore ' defb 000h fcmpt: defb 'function complete' defb 000h inval: defb 'invalid drive name (use a, b, c, or d)' defb 0000h nsrce: defb 'no source file on disk' defb 000h incmp: defb 'source file incomplete' defb 000h drive: defb 49h curtrk: defb 50h csectr: defb 29h trpflg: defb 000h pointr: defs 002h rdwrit: defb 000h dpaddr: defs 002h dpbdat: defs 0010h moddpb: defb 1ah,00h,03h,07h,00h,0f2h,00h,3fh,00h defb 0c0h,00,10h,00h,02h,00h,01h defs 20h stack: defb 000h end