X-Git-Url: http://cloudbase.mooo.com/gitweb/avrcpm.git/blobdiff_plain/db568140f48e404231f1b9d5b99680073c94bf49..8791c3a48be156966a602adabc11614147ff85c8:/avrcpm/cpm/bios.asm
diff --git a/avrcpm/cpm/bios.asm b/avrcpm/cpm/bios.asm
index a242c55..0ae7932 100644
--- a/avrcpm/cpm/bios.asm
+++ b/avrcpm/cpm/bios.asm
@@ -13,20 +13,23 @@
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see .
+;
+; $Id$
+;
msize: equ 62 ;size of available RAM in k
bias: equ (msize-20) * 1024
-ccp: equ $3400+bias ;base of cpm ccp
-bdos: equ ccp+$806 ;base of bdos
-bios: equ ccp+$1600 ;base of bios
-cdisk: equ $0004 ;current disk number (0 ... 15)
-iobyte: equ $0003 ;intel iobyte
-buff: equ $0080 ;default buffer address
+ccp: equ 3400h+bias ;base of cpm ccp
+bdos: equ ccp+806h ;base of bdos
+bios: equ ccp+1600h ;base of bios
+cdisk: equ 0004h ;current disk number (0 ... 15)
+iobyte: equ 0003h ;intel iobyte
+buff: equ 0080h ;default buffer address
retry: equ 3 ;max retries on disk i/o before error
-cr: equ 13
-lf: equ 10
+cr:equ 13
+lf:equ 10
READ_FUNC: equ 7
WRITE_FUNC: equ 6
@@ -60,12 +63,197 @@ signon:
db msize/10+'0'
db msize - (msize/10)*10 + '0' ;modulo doesn't work?
db "k cp/m vers 2.2"
- db cr,lf,0
+msgnl: db cr,lf,0
+
+const:
+ in a,(0)
+ ret
+
+conin:
+ in a,(0)
+ cp 0ffh
+ jp nz,conin
+
+ in a,(1)
+ ret
+
+conout:
+ ld a,c
+ out (2),a
+ ret
+
+list:
+ ret
+
+listst:
+ ld a,0
+ ret
+
+punch:
+ ret
+
+reader:
+ ld a,01Fh
+ ret
+
+prmsg:
+ ld a,(hl)
+ or a
+ ret z
+ push hl
+ ld c,a
+ call conout
+ pop hl
+ inc hl
+ jp prmsg
+
+prhex:
+ ld a,c
+ push af
+ rra
+ rra
+ rra
+ rra
+ call prhexdigit
+ pop af
+ ; fall thru
+
+prhexdigit:
+ and 00fh
+ cp 10
+ jp c,prd1
+ add a,7
+prd1:
+ add a,'0'
+ ld c,a
+ jp conout
+
boot:
ld sp,buff
ld hl,signon
call prmsg
+
+ xor a
+ ld (bootdsk),a
+ ld a,(dpb)
+ ld (bootspt),a
+
+ ld c,'I'-'A'
+ call seldsk
+ ld a,h
+ or l
+ jp z,boot1
+
+ ld de,10
+ add hl,de
+ ld e,(hl)
+ inc hl
+ ld d,(hl) ;de = dpb of first ram disk
+
+ ld hl,7
+ add hl,de
+ ld a,(hl) ;get drm
+ add 3 ;ToDo: this works only up to 252 dir entries
+ and 0fch
+ rrca ;4 dir entries per sector
+ rrca ;Number of sectors to init
+ push af
+
+ ld bc,6
+ add hl,bc
+ ld c,(hl) ;Start track (= # of reserved tracks)
+ push bc ;Save track
+
+; Check, if we have reserved tracks.
+ ld a,c
+ or a
+ jp z,boot0 ;Skip if not.
+
+; Save CPM to ram disk.
+
+ ld a,(de) ;sectors per track
+ ld (bootspt),a
+ ld a,'I'-'A'
+ ld (bootdsk),a
+ call home
+ ld b,nsects
+ ld c,0 ;track
+ ld d,1 ;sektor (0 based)
+ ld hl,ccp
+store1:
+ push bc
+ push de
+ push hl
+ ld c,d
+ ld b,0
+ call setsec
+ pop bc
+ push bc
+ call setdma
+ ld c,0
+ call write
+
+ pop hl
+ ld de,128
+ add hl,de
+ pop de
+ pop bc
+ dec b
+ jp z,boot0
+
+ inc d
+ ld a,(bootspt)
+ dec a
+ cp d ;if sector >= spt then change tracks
+ jp nc,store1
+
+ ld d,0
+ inc c
+ push bc
+ push de
+ push hl
+ ld b,0
+ call settrk
+ pop hl
+ pop de
+ pop bc
+ jp store1
+
+; Clear directory area of ram disk.
+
+boot0:
+ pop bc
+ call settrk
+ pop af
+ ld d,a ;d = # of sectors
+ ld e,0 ;e = sector
+ push de
+ ld hl,dirbuf ;Clear dirbuf
+ ld c,128
+ ld a,0E5h
+boot_cl:
+ ld (hl),a
+ inc hl
+ dec c
+ jp nz,boot_cl
+
+ ld bc,dirbuf
+ call setdma
+ pop de
+boot_cl2:
+ push de
+ ld c,e
+ ld b,0
+ call setsec
+ ld c,0
+ call write
+ pop de
+ inc e
+ dec d
+ jp nz,boot_cl2
+
+boot1:
xor a
ld (iobyte),a
ld (cdisk),a
@@ -73,9 +261,10 @@ boot:
wboot: ;re-load CP/M
ld sp,buff
- ld a,1<= 26 then change tracks
- jp c,load1
+ ld a,(bootspt)
+ dec a
+ cp d ;if sector >= spt then change tracks
+ jp nc,load1
ld d,0
inc c
@@ -135,46 +325,25 @@ gocpm:
ld a,(cdisk)
ld c,a
jp ccp
-
-const:
- in a,(0)
- ret
-
-conin:
- in a,(0)
- cp $ff
- jp nz,conin
-
- in a,(1)
- ret
-
-conout:
- ld a,c
- out (2),a
- ret
-
-list:
- ret
-
-listst:
- ld a,0
- ret
-
-punch:
- ret
-
-reader:
- ld a,$1F
- ret
-
+
seldsk:
- ld hl,0 ;error return code
- ld a,c
- out (15),a
- cp 0 ;only one disk supportet
- jp nz,seldsk_na
- ld hl,dph ;return disk parameter header address
-seldsk_na:
+ ld hl,dphtab
+ ld b,0
+ add hl,bc
+ add hl,bc
+ ld a,(hl) ;get table entry for selected disk
+ inc hl
+ ld h,(hl)
+ ld l,a
+ or h ;no entry, no disk
+ ret z ;
+
+ ld a,c
+ out (15),a
+ in a,(15) ;querry, if disk exists
+ or a ;0 = disk is ok
+ ret z
+ ld hl,0 ;error return code
ret
home:
@@ -204,14 +373,17 @@ setdma:
read:
ld a,1<