aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2014-05-09 22:40:08 -0700
committerH. Peter Anvin <hpa@zytor.com>2014-05-09 22:40:08 -0700
commit7f138920360f9444625a7b110fb033f725929c3c (patch)
treee6707ad97a1f46a56aedbc1c229fed837504b4f8
parentc224dce6bb9f07a65aafc4568b902d78394db8d8 (diff)
downloadabc80-7f138920360f9444625a7b110fb033f725929c3c.tar.gz
abc80-7f138920360f9444625a7b110fb033f725929c3c.tar.xz
abc80-7f138920360f9444625a7b110fb033f725929c3c.zip
CP/M: fix the BIOS enough that we can actually get to a prompt
Make the keyboard work, fix the loader and the output routine; with this we actually get an A> prompt that we can type at. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--data/cbios.asm101
-rw-r--r--data/cpm.asm3
2 files changed, 65 insertions, 39 deletions
diff --git a/data/cbios.asm b/data/cbios.asm
index f64ccdf..e001596 100644
--- a/data/cbios.asm
+++ b/data/cbios.asm
@@ -142,9 +142,9 @@ rowtbl:
pio_init:
; Port A initialization sequence
- defb 0CFh, 0FFh, kbdvec & 255, 0B7h, 080h
+ defb 0CFh, 0FFh, kbdvec & 255, 0B7h, 07Fh
; Port B initialization sequence
- defb 0CFh, 087h, v24vec & 255, 0B7h, 000h
+ defb 0CFh, 087h, v24vec & 255, 0B7h, 0FFh
; bios functions follow
boot: ; Cold boot
@@ -153,8 +153,13 @@ boot: ; Cold boot
out (7),a ; Map 3, NMI disabled
ld sp,0x100 ; Put our stack in the default DMA buffer
- xor a
- ld (iobyte), a
+ ; Zero all memory (just in case)
+ ld hl,0
+ ld de,1
+ ld bc,bios-1
+ ld (hl),l
+ ldir
+
; say hello
ld hl,bootmsg
do_boot_msg:
@@ -174,7 +179,7 @@ wboot: ; warm boot -- reload CCP and then run it again,
; we also reload BDOS for good measure
; CCP+BDOS is located in track 0 at sector offset 0
; CCP+BDOS is 0x1600 bytes long, ie 44 sectors.
- ; so we read 44 sectors from sector 20 onwards
+ ; so we read 44 sectors from sector 0 onwards
; into memory starting at address ccp
; put our stack in the default DMA buffer
@@ -215,24 +220,16 @@ wboot: ; warm boot -- reload CCP and then run it again,
ld c, 0
call setsec
- ; count of sectors to load
- ld de, 44
- push de ; store remaining sector count
-
wbootloop:
; read sector
call read
- pop de ; recover remaining sector count
- dec de
- ld a, d
- or e
- jr z, gocpm ; boot CP/M after loading the final sector
- push de ; stash sector count
; advance to next sector
ld a, (cursector)
inc a
ld (cursector), a
+ cp 44
+ jr z, gocpm
; advance to next DMA address
ld hl, (curdmaaddr)
@@ -253,21 +250,32 @@ gocpm:
ld (6), hl ; write vector for BDOS at 0x0006, 0x0007.
ld bc, 0x0080 ; default DMA address
call setdma ; configure DMA
- ld a, (cdisk) ; get current disk
- ld c, a ; send to ccp
+ ld bc,(cdisk) ; get current disk (only C matters)
jp ccp ; and we're off!
irq_kbd:
+ push af
+ ld a,0FFh
+ ld (conflag),a
+ pop af
irq_v24:
reti
const: ; read console status
-connotready:
- xor a
+ ld a,(conflag)
ret
conin: ; read character from console into A; wait if no character ready
+ call con_swapcursor
+conin_wait:
+ ld a,(conflag)
+ and a
+ jr z,conin_wait
+ call con_swapcursor
xor a
+ ld (conflag),a
+ in a,(56)
+ and 07Fh
ret
conout: ; write chracter from C to console
@@ -285,17 +293,7 @@ conout: ; write chracter from C to console
jr z,con_cr
; Fall through
con_print:
- ld a,(currow)
- add a
- add rowtbl & 0xff
- ld l,a
- ld h,rowtbl/256
- ld a,(curcol)
- ld b,a
- add (hl)
- ld e,a
- inc l
- ld d,(hl)
+ call con_getaddr
di
ld a,4 ; Map 0, NMI off
out (7),a
@@ -398,6 +396,34 @@ con_ffloop:
jr nz,con_ffloop
jr con_pop_done
+con_getaddr:
+ ld a,(currow)
+ add a
+ add rowtbl & 0xff
+ ld l,a
+ ld h,rowtbl/256
+ ld a,(curcol)
+ ld b,a
+ add (hl)
+ ld e,a
+ inc l
+ ld d,(hl)
+ ret
+
+con_swapcursor:
+ call con_getaddr
+ di
+ ld a,4 ; Map 0, NMI off
+ out (7),a
+ ld a,c
+ ld a,(de)
+ xor 80h
+ ld (de),a
+ ld a,7 ; Map 3, NMI off
+ out (7),a
+ ei
+ ret
+
list: ; write character to listing device (we don't have one!)
ret
@@ -423,13 +449,9 @@ seldsk: ; select disk indicated by register C
add a,a ; *4
add a,a ; *8
add a,a ; *16
- add a,l
+ add a,dpbase & 0xff
ld l,a
- if (dpbase & 0xff) > (256-ndisks*16)
- ld a,h
- adc a,0
- ld h,a
- endif
+ ld h,dpbase/256
; HL = dpbase + disk number * 16
ret
@@ -459,7 +481,7 @@ read: ; read a sector from disk
ld c,03h ; READ + SECTOR TO HOST
call sendcmd
ld hl,(curdmaaddr)
- ld bc,128
+ ld bc,128*256+0
inir
xor a ; Success!
ret
@@ -469,7 +491,7 @@ write: ; write sector to disk
ld c,0Ch ; SECTOR FROM HOST + WRITE
call sendcmd
ld hl,(curdmaaddr)
- ld bc,128
+ ld bc,128*256+0
otir
xor a ; Success!
ret
@@ -485,7 +507,7 @@ sendcmd:
or 24h ; +4 for volume, CP/M mode
ld e,a
ld a,(cursector)
- rrca
+ srl a
jr nc,bc1
set 4,e ; odd CP/M sector
bc1:
@@ -538,6 +560,7 @@ curdisk: db 0
cursector: db 0
curtrack: dw 0
curdmaaddr: dw 0
+conflag: db 0
; scratch RAM used by BDOS
dirbf: ds 128 ; directory scratch area
diff --git a/data/cpm.asm b/data/cpm.asm
index cbbb876..1299aec 100644
--- a/data/cpm.asm
+++ b/data/cpm.asm
@@ -27,6 +27,9 @@ _start:
out (7),a
in a,(7)
+
+ ld hl,(ABCCURSOR)
+ ld (CPMCURSOR),hl
ld hl,bios
ld de,CPMBIOS