mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:43:15 -06:00
Compare commits
2 Commits
v3.1.1-pre
...
v3.1.1-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f3fb51884 | ||
|
|
36fe842bec |
@@ -607,9 +607,20 @@ PDLY:
|
||||
JNZ PDLY
|
||||
;
|
||||
.Z80
|
||||
; RECORD THE ACTIVE BANK
|
||||
LD A,(0FFE0H) ; GET CURRENT HBIOS BANK ID
|
||||
LD (BANK),A ; AND SAVE IT
|
||||
; record the active bank
|
||||
ld a,(0ffe0h) ; get current hbios bank id
|
||||
ld (BANK),a ; and save it
|
||||
; Check for Z180 CPU
|
||||
xor a ; assume Z80
|
||||
ld (IS180),a ; save it
|
||||
ld de,0506H ; 5 x 6
|
||||
db 0EDH,05CH ; MLT DE: de = 30 if z180
|
||||
ld a,e ; result to A
|
||||
cp 30 ; check if multiply happened
|
||||
jr nz,z80 ; if invalid, then Z80
|
||||
or 0ffH ; flag value for Z180
|
||||
ld (IS180),a ; save it
|
||||
z80:
|
||||
.8080
|
||||
;
|
||||
LXI H,0 ; Init active port counter
|
||||
@@ -623,28 +634,76 @@ PORTLP:
|
||||
JZ ISPORT ; Print mask port
|
||||
ENDIF
|
||||
;
|
||||
mov c,a ; port number to reg c
|
||||
mvi b,0 ; for 16 bit port addressing
|
||||
.Z80
|
||||
in a,(c)
|
||||
.8080
|
||||
di ; interrupts off
|
||||
ld a,(IS180) ; Z180?
|
||||
or a
|
||||
jr nz,rd180
|
||||
;
|
||||
.Z80
|
||||
; MAKE SURE CORRECT BANK IS STILL SELECTED!
|
||||
; Z80 port read
|
||||
; Read port using IN A,(C), push result
|
||||
ld a,d
|
||||
ld c,a
|
||||
ld (pnum0a),a ; dynamic update
|
||||
ld (pnum0b),a ; dynamic update
|
||||
ld b,0
|
||||
in a,(c)
|
||||
push af
|
||||
; Read port using IN A,(port), push result
|
||||
in a,(0ffh) ; IN0
|
||||
pnum0a equ $-1
|
||||
push af
|
||||
; Read port using IN A,(port), push result
|
||||
in a,(0ffh) ; IN0
|
||||
pnum0b equ $-1
|
||||
push af
|
||||
jr rdz
|
||||
;
|
||||
rd180:
|
||||
; Z180 port read
|
||||
; Read port using IN A,(C), push result
|
||||
ld a,d
|
||||
ld c,a
|
||||
ld (pnum1a),a ; dynamic update
|
||||
ld (pnum1b),a ; dynamic update
|
||||
ld b,0
|
||||
in a,(c)
|
||||
push af
|
||||
; Read port using IN0 A,(port), push result
|
||||
db 0EDH,038H,0FFH ; IN0
|
||||
pnum1a equ $-1
|
||||
push af
|
||||
; Read port using IN0 A,(port), push result
|
||||
db 0EDH,038H,0FFH ; IN0
|
||||
pnum1b equ $-1
|
||||
push af
|
||||
;
|
||||
rdz:
|
||||
; Make sure correct bank is still selected!
|
||||
push af
|
||||
ld a,(BANK)
|
||||
call 0FFF3H
|
||||
pop af
|
||||
;
|
||||
ei ; interrupts back on now
|
||||
;
|
||||
; port is considered inactive if values read from different port
|
||||
; read mechanisms differ or if the value $FF is read consistently,
|
||||
; or if the value read is equal to the port number itself
|
||||
;
|
||||
pop bc ; second IN0 (port) value
|
||||
pop af ; first IN0 (port) valule
|
||||
cp b ; same?
|
||||
pop bc ; IN (C) value
|
||||
jr nz,ISPORT ; if no, active running ctr port
|
||||
cp b ; same?
|
||||
jr nz,NEXTPT ; if not, inactive port
|
||||
cp 0FFh ; pullup value???
|
||||
jr z,NEXTPT ; if so, consider not active
|
||||
cp d ; value same as port num???
|
||||
jr z,NEXTPT ; if so, consider not active
|
||||
;
|
||||
.8080
|
||||
;
|
||||
; inactive port could return 0xFF or 0x78 or the port address
|
||||
;
|
||||
cmp c
|
||||
jz nextpt
|
||||
cpi 0FFh
|
||||
jz nextpt
|
||||
cpi 078h
|
||||
jz nextpt
|
||||
ISPORT:
|
||||
mov a,d ; got a live one, probably
|
||||
ani 0f0h ; is port in same group as last ?
|
||||
@@ -760,6 +819,7 @@ EMPF: DS 1 ; Empty so far flag
|
||||
BLKSHF: DS 1 ; block shift factor
|
||||
MAXALL: DS 2 ; maximum block number
|
||||
BANK: DS 1 ; saved HBIOS bank id
|
||||
IS180: DS 1 ; non-zero for Z180 CPU
|
||||
FINIS EQU $ ; End of program
|
||||
;
|
||||
.DEPHASE
|
||||
|
||||
@@ -23,6 +23,7 @@ pushd ps2info && call Build || exit /b & popd
|
||||
pushd 2piotst && call Build || exit /b & popd
|
||||
pushd piomon && call Build || exit /b & popd
|
||||
pushd banktest && call Build || exit /b & popd
|
||||
pushd portswp && call Build || exit /b & popd
|
||||
|
||||
goto :eof
|
||||
|
||||
|
||||
@@ -20,3 +20,4 @@ pushd ps2info && call Clean || exit /b 1 & popd
|
||||
pushd 2piotst && call Clean || exit /b 1 & popd
|
||||
pushd piomon && call Clean || exit /b 1 & popd
|
||||
pushd banktest && call Clean || exit /b 1 & popd
|
||||
pushd portswp && call Clean || exit /b 1 & popd
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
OBJECTS =
|
||||
SUBDIRS = DMAmon I2C inttest ppidetst ramtest tstdskng rzsz vdctest kbdtest ps2info 2piotst piomon banktest
|
||||
SUBDIRS = DMAmon I2C inttest ppidetst ramtest tstdskng rzsz vdctest kbdtest ps2info 2piotst piomon banktest portswp
|
||||
DEST = ../../../Binary/Apps/Test
|
||||
TOOLS =../../../Tools
|
||||
|
||||
|
||||
11
Source/Apps/Test/portswp/Build.cmd
Normal file
11
Source/Apps/Test/portswp/Build.cmd
Normal file
@@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set TOOLS=../../../../Tools
|
||||
set PATH=%TOOLS%\tasm32;%PATH%
|
||||
set TASMTABS=%TOOLS%\tasm32
|
||||
|
||||
tasm -t180 -g3 -fFF portswp.asm portswp.com portswp.lst || exit /b
|
||||
|
||||
copy /Y portswp.com ..\..\..\..\Binary\Apps\Test\ || exit /b
|
||||
|
||||
6
Source/Apps/Test/portswp/Clean.cmd
Normal file
6
Source/Apps/Test/portswp/Clean.cmd
Normal file
@@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
if exist *.com del *.com
|
||||
if exist *.lst del *.lst
|
||||
if exist *.bin del *.bin
|
||||
9
Source/Apps/Test/portswp/Makefile
Normal file
9
Source/Apps/Test/portswp/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
OBJECTS = portswp.com
|
||||
DEST = ../../../../Binary/Apps/Test
|
||||
TOOLS =../../../../Tools
|
||||
|
||||
USETASM=1
|
||||
|
||||
include $(TOOLS)/Makefile.inc
|
||||
|
||||
TASM=$(BINDIR)/uz80as -t hd64180
|
||||
609
Source/Apps/Test/portswp/portswp.asm
Normal file
609
Source/Apps/Test/portswp/portswp.asm
Normal file
@@ -0,0 +1,609 @@
|
||||
;===============================================================================
|
||||
; PORTSWP - Sweep Ports
|
||||
;
|
||||
;===============================================================================
|
||||
;
|
||||
; Author: Wayne Warthen (wwarthen@gmail.com)
|
||||
;_______________________________________________________________________________
|
||||
;
|
||||
; Usage:
|
||||
; PORTSWP
|
||||
;
|
||||
; Operation:
|
||||
; Reads all ports (multiple ways) and displays values read
|
||||
;_______________________________________________________________________________
|
||||
;
|
||||
; Change Log:
|
||||
; 2023-02-14 [WBW] Initial release
|
||||
;_______________________________________________________________________________
|
||||
;
|
||||
; ToDo:
|
||||
;_______________________________________________________________________________
|
||||
;
|
||||
;===============================================================================
|
||||
; Definitions
|
||||
;===============================================================================
|
||||
;
|
||||
runloc .equ $C000 ; Running location (upper memory required)
|
||||
stksiz .equ $40 ; Working stack size
|
||||
;
|
||||
rmj .equ 3 ; intended HBIOS version - major
|
||||
rmn .equ 1 ; intended HBIOS version - minor
|
||||
;
|
||||
restart .equ $0000 ; CP/M restart vector
|
||||
;
|
||||
#include "../../../HBIOS/hbios.inc"
|
||||
;
|
||||
;===============================================================================
|
||||
; Code Section
|
||||
;===============================================================================
|
||||
;
|
||||
.org $100
|
||||
;
|
||||
; relocate worker code to upper memory
|
||||
ld hl,begin ; start of working code image
|
||||
ld de,runloc ; running location
|
||||
ld bc,size ; size of working code image
|
||||
ldir ; copy to upper RAM
|
||||
jp runloc ; and go
|
||||
;
|
||||
; Start of working code
|
||||
;
|
||||
begin .equ $ ; image loaded here
|
||||
;
|
||||
.org runloc ; now generate running location adresses
|
||||
;
|
||||
; setup stack (save old value)
|
||||
ld (stksav),sp ; save stack
|
||||
ld sp,stack ; set new stack
|
||||
;
|
||||
; initialization
|
||||
call init ; initialize
|
||||
jr nz,exit ; abort if init fails
|
||||
;
|
||||
; process
|
||||
call process ; do main processing
|
||||
jr nz,exit ; abort on error
|
||||
;
|
||||
exit: ; clean up and return to command processor
|
||||
call crlf ; formatting
|
||||
ld sp,(stksav) ; restore stack
|
||||
;jp restart ; return to CP/M via restart
|
||||
ret ; return to CP/M w/o restart
|
||||
;
|
||||
; Initialization
|
||||
;
|
||||
init:
|
||||
call crlf2 ; formatting
|
||||
ld de,msgban ; point to version message part 1
|
||||
call prtstr ; print it
|
||||
;
|
||||
call idbio ; identify active BIOS
|
||||
cp 1 ; check for HBIOS
|
||||
jp nz,errbio ; handle BIOS error
|
||||
;
|
||||
ld a,rmj << 4 | rmn ; expected HBIOS ver
|
||||
cp d ; compare with result above
|
||||
jp nz,errbio ; handle BIOS error
|
||||
;
|
||||
initx
|
||||
; initialization complete
|
||||
xor a ; signal success
|
||||
ret ; return
|
||||
;
|
||||
; Process
|
||||
;
|
||||
process:
|
||||
call crlf
|
||||
ld a,($FFE0) ; get current hbios bank id
|
||||
ld (orgbnk),a ; and save it
|
||||
ld a,0 ; start with port 0
|
||||
ld (curport),a ; save it for use below
|
||||
; Test for z180 using mlt
|
||||
ld de,$0506 ; 5 x 6
|
||||
mlt de ; de = 30 if z180
|
||||
ld a,e ; result to A
|
||||
cp 30 ; check if multiply happened
|
||||
jr nz,prtcpu ; if invalid, then Z80
|
||||
or $FF ; flag value for Z180
|
||||
ld (is180),a ; save it
|
||||
;
|
||||
prtcpu:
|
||||
ld de,msgcpu
|
||||
call prtstr
|
||||
ld a,(is180)
|
||||
or a
|
||||
ld de,msgz80
|
||||
jr z,prtcpu1
|
||||
ld de,msgz180
|
||||
prtcpu1:
|
||||
call prtstr
|
||||
call crlf
|
||||
;
|
||||
loop:
|
||||
call crlf
|
||||
ld a,(curport)
|
||||
call prthex
|
||||
ld a,':'
|
||||
call prtchr
|
||||
;
|
||||
di ; interrupts off
|
||||
;
|
||||
ld hl,vallist ; init value list pointer
|
||||
call portread ; read the port
|
||||
call portread ; do it again
|
||||
;
|
||||
; restore possibly corrupted bank registers
|
||||
ld a,(orgbnk) ; get proper bank id
|
||||
call $FFF3 ; restore it
|
||||
;
|
||||
ei ; interrupts safe now
|
||||
;
|
||||
ld hl,vallist ; re-init value list pointer
|
||||
ld b,4 ; print 4 values
|
||||
prtloop:
|
||||
ld a,' '
|
||||
call prtchr
|
||||
ld a,(hl)
|
||||
call prthex
|
||||
inc hl
|
||||
djnz prtloop
|
||||
;
|
||||
; update port and loop as needed
|
||||
ld a,(curport) ; get current port
|
||||
inc a ; move to next
|
||||
ld (curport),a ; save it
|
||||
jr z,done ; done on wraparound
|
||||
jr loop ; loop until done
|
||||
;
|
||||
done:
|
||||
;
|
||||
call crlf2
|
||||
ld de,msgdone ; message to print
|
||||
call prtstr ; do it
|
||||
ret ; all done
|
||||
;
|
||||
;
|
||||
;
|
||||
portread:
|
||||
ld a,(is180)
|
||||
or a
|
||||
jr nz,portread_z180
|
||||
;
|
||||
portread_z80: ; use traditional "IN"
|
||||
; read port using IN <portnum>
|
||||
ld a,(curport) ; get current port
|
||||
ld (port),a ; modify IN instruction
|
||||
nop ; defeat Z280 pipeline
|
||||
nop
|
||||
in a,($FF) ; read the port
|
||||
port .equ $-1
|
||||
ld (hl),a ; save it
|
||||
inc hl ; bump value list pointer
|
||||
;
|
||||
; read port using IN (C)
|
||||
ld a,(curport) ; get current port
|
||||
ld b,0 ; in case 16 bits decoded
|
||||
ld c,a ; move to reg C
|
||||
in a,(c) ; read the port
|
||||
ld (hl),a ; save it
|
||||
inc hl ; bump value list pointer
|
||||
ret
|
||||
;
|
||||
portread_z180: ; use "IN0"
|
||||
; read port using IN <portnum>
|
||||
ld a,(curport) ; get current port
|
||||
ld (port1),a ; modify IN instruction
|
||||
in0 a,($FF) ; read the port
|
||||
port1 .equ $-1
|
||||
ld (hl),a ; save it
|
||||
inc hl ; bump value list pointer
|
||||
;
|
||||
; read port using IN (C)
|
||||
ld a,(curport) ; get current port
|
||||
ld b,0 ; in case 16 bits decoded
|
||||
ld c,a ; move to reg C
|
||||
in a,(c) ; read the port
|
||||
ld (hl),a ; save it
|
||||
inc hl ; bump value list pointer
|
||||
ret
|
||||
;
|
||||
; Identify active BIOS. RomWBW HBIOS=1, UNA UBIOS=2, else 0
|
||||
;
|
||||
idbio:
|
||||
;
|
||||
; Check for UNA (UBIOS)
|
||||
ld a,($FFFD) ; fixed location of UNA API vector
|
||||
cp $C3 ; jp instruction?
|
||||
jr nz,idbio1 ; if not, not UNA
|
||||
ld hl,($FFFE) ; get jp address
|
||||
ld a,(hl) ; get byte at target address
|
||||
cp $FD ; first byte of UNA push ix instruction
|
||||
jr nz,idbio1 ; if not, not UNA
|
||||
inc hl ; point to next byte
|
||||
ld a,(hl) ; get next byte
|
||||
cp $E5 ; second byte of UNA push ix instruction
|
||||
jr nz,idbio1 ; if not, not UNA, check others
|
||||
;
|
||||
ld bc,$04FA ; UNA: get BIOS date and version
|
||||
rst 08 ; DE := ver, HL := date
|
||||
;
|
||||
ld a,2 ; UNA BIOS id = 2
|
||||
ret ; and done
|
||||
;
|
||||
idbio1:
|
||||
; Check for RomWBW (HBIOS)
|
||||
ld hl,(HB_IDENT) ; HL := HBIOS ident location
|
||||
ld a,'W' ; First byte of ident
|
||||
cp (hl) ; Compare
|
||||
jr nz,idbio2 ; Not HBIOS
|
||||
inc hl ; Next byte of ident
|
||||
ld a,~'W' ; Second byte of ident
|
||||
cp (hl) ; Compare
|
||||
jr nz,idbio2 ; Not HBIOS
|
||||
;
|
||||
ld b,BF_SYSVER ; HBIOS: VER function
|
||||
ld c,0 ; required reserved value
|
||||
rst 08 ; DE := version, L := platform id
|
||||
;
|
||||
ld a,1 ; HBIOS BIOS id = 1
|
||||
ret ; and done
|
||||
;
|
||||
idbio2:
|
||||
; No idea what this is
|
||||
xor a ; Setup return value of 0
|
||||
ret ; and done
|
||||
;
|
||||
; Print character in A without destroying any registers
|
||||
;
|
||||
prtchr:
|
||||
push bc ; save registers
|
||||
push de
|
||||
push hl
|
||||
ld e,a ; character to print in E
|
||||
ld b,BF_CIOOUT ; HBIOS function to output a character
|
||||
ld c,CIO_CONSOLE ; write to current console unit
|
||||
call HB_INVOKE ; invoke HBIOS via call
|
||||
pop hl ; restore registers
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
;
|
||||
prtdot:
|
||||
;
|
||||
; shortcut to print a dot preserving all regs
|
||||
push af ; save af
|
||||
ld a,'.' ; load dot char
|
||||
call prtchr ; print it
|
||||
pop af ; restore af
|
||||
ret ; done
|
||||
;
|
||||
prtspace:
|
||||
;
|
||||
; shortcut to print a space preserving all regs
|
||||
push af ; save af
|
||||
ld a,' ' ; load dot char
|
||||
call prtchr ; print it
|
||||
pop af ; restore af
|
||||
ret ; done
|
||||
;
|
||||
prtcr:
|
||||
;
|
||||
; shortcut to print a dot preserving all regs
|
||||
push af ; save af
|
||||
ld a,13 ; load CR value
|
||||
call prtchr ; print it
|
||||
pop af ; restore af
|
||||
ret ; done
|
||||
;
|
||||
; Print a zero terminated string at (DE) without destroying any registers
|
||||
;
|
||||
prtstr:
|
||||
push de
|
||||
;
|
||||
prtstr1:
|
||||
ld a,(de) ; get next char
|
||||
or a
|
||||
jr z,prtstr2
|
||||
call prtchr
|
||||
inc de
|
||||
jr prtstr1
|
||||
;
|
||||
prtstr2:
|
||||
pop de ; restore registers
|
||||
ret
|
||||
;
|
||||
; Print a block of memory nicely formatted
|
||||
; de=buffer address
|
||||
;
|
||||
dump_buffer:
|
||||
call crlf
|
||||
|
||||
push de
|
||||
pop hl
|
||||
inc d
|
||||
inc d
|
||||
|
||||
db_blkrd:
|
||||
push bc
|
||||
push hl
|
||||
pop bc
|
||||
call prthexword ; print start location
|
||||
pop bc
|
||||
call prtspace ;
|
||||
ld c,16 ; set for 16 locs
|
||||
push hl ; save starting hl
|
||||
db_nxtone:
|
||||
ld a,(hl) ; get byte
|
||||
call prthex ; print it
|
||||
call prtspace ;
|
||||
db_updh:
|
||||
inc hl ; point next
|
||||
dec c ; dec. loc count
|
||||
jr nz,db_nxtone ; if line not done
|
||||
; now print 'decoded' data to right of dump
|
||||
db_pcrlf:
|
||||
call prtspace ; space it
|
||||
ld c,16 ; set for 16 chars
|
||||
pop hl ; get back start
|
||||
db_pcrlf0:
|
||||
ld a,(hl) ; get byte
|
||||
and 060h ; see if a 'dot'
|
||||
ld a,(hl) ; o.k. to get
|
||||
jr nz,db_pdot ;
|
||||
db_dot:
|
||||
ld a,2eh ; load a dot
|
||||
db_pdot:
|
||||
call prtchr ; print it
|
||||
inc hl ;
|
||||
ld a,d ;
|
||||
cp h ;
|
||||
jr nz,db_updh1 ;
|
||||
ld a,e ;
|
||||
cp l ;
|
||||
jp z,db_end ;
|
||||
db_updh1:
|
||||
; if block not dumped, do next character or line
|
||||
dec c ; dec. char count
|
||||
jr nz,db_pcrlf0 ; do next
|
||||
db_contd:
|
||||
call crlf ;
|
||||
jp db_blkrd ;
|
||||
|
||||
db_end:
|
||||
ret
|
||||
;
|
||||
; Print the value in A in hex without destroying any registers
|
||||
;
|
||||
prthex:
|
||||
push af ; save AF
|
||||
push de ; save DE
|
||||
call hexascii ; convert value in A to hex chars in DE
|
||||
ld a,d ; get the high order hex char
|
||||
call prtchr ; print it
|
||||
ld a,e ; get the low order hex char
|
||||
call prtchr ; print it
|
||||
pop de ; restore DE
|
||||
pop af ; restore AF
|
||||
ret ; done
|
||||
;
|
||||
; print the hex word value in bc
|
||||
;
|
||||
prthexword:
|
||||
push af
|
||||
ld a,b
|
||||
call prthex
|
||||
ld a,c
|
||||
call prthex
|
||||
pop af
|
||||
ret
|
||||
;
|
||||
; print the hex dword value in de:hl
|
||||
;
|
||||
prthex32:
|
||||
push bc
|
||||
push de
|
||||
pop bc
|
||||
call prthexword
|
||||
push hl
|
||||
pop bc
|
||||
call prthexword
|
||||
pop bc
|
||||
ret
|
||||
;
|
||||
; Convert binary value in A to ascii hex characters in DE
|
||||
;
|
||||
hexascii:
|
||||
ld d,a ; save A in D
|
||||
call hexconv ; convert low nibble of A to hex
|
||||
ld e,a ; save it in E
|
||||
ld a,d ; get original value back
|
||||
rlca ; rotate high order nibble to low bits
|
||||
rlca
|
||||
rlca
|
||||
rlca
|
||||
call hexconv ; convert nibble
|
||||
ld d,a ; save it in D
|
||||
ret ; done
|
||||
;
|
||||
; Convert low nibble of A to ascii hex
|
||||
;
|
||||
hexconv:
|
||||
and $0F ; low nibble only
|
||||
add a,$90
|
||||
daa
|
||||
adc a,$40
|
||||
daa
|
||||
ret
|
||||
;
|
||||
; Print value of A or HL in decimal with leading zero suppression
|
||||
; Use prtdecb for A or prtdecw for HL
|
||||
;
|
||||
prtdecb:
|
||||
push hl
|
||||
ld h,0
|
||||
ld l,a
|
||||
call prtdecw ; print it
|
||||
pop hl
|
||||
ret
|
||||
;
|
||||
prtdecw:
|
||||
push af
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
call prtdec0
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
pop af
|
||||
ret
|
||||
;
|
||||
prtdec0:
|
||||
ld e,'0'
|
||||
ld bc,-10000
|
||||
call prtdec1
|
||||
ld bc,-1000
|
||||
call prtdec1
|
||||
ld bc,-100
|
||||
call prtdec1
|
||||
ld c,-10
|
||||
call prtdec1
|
||||
ld e,0
|
||||
ld c,-1
|
||||
prtdec1:
|
||||
ld a,'0' - 1
|
||||
prtdec2:
|
||||
inc a
|
||||
add hl,bc
|
||||
jr c,prtdec2
|
||||
sbc hl,bc
|
||||
cp e
|
||||
ret z
|
||||
ld e,0
|
||||
call prtchr
|
||||
ret
|
||||
;
|
||||
; Start a new line
|
||||
;
|
||||
crlf2:
|
||||
call crlf ; two of them
|
||||
crlf:
|
||||
push af ; preserve AF
|
||||
ld a,13 ; <CR>
|
||||
call prtchr ; print it
|
||||
ld a,10 ; <LF>
|
||||
call prtchr ; print it
|
||||
pop af ; restore AF
|
||||
ret
|
||||
;
|
||||
; Get the next non-blank character from (HL).
|
||||
;
|
||||
nonblank:
|
||||
ld a,(hl) ; load next character
|
||||
or a ; string ends with a null
|
||||
ret z ; if null, return pointing to null
|
||||
cp ' ' ; check for blank
|
||||
ret nz ; return if not blank
|
||||
inc hl ; if blank, increment character pointer
|
||||
jr nonblank ; and loop
|
||||
;
|
||||
; Convert character in A to uppercase
|
||||
;
|
||||
ucase:
|
||||
cp 'a' ; if below 'a'
|
||||
ret c ; ... do nothing and return
|
||||
cp 'z' + 1 ; if above 'z'
|
||||
ret nc ; ... do nothing and return
|
||||
res 5,a ; clear bit 5 to make lower case -> upper case
|
||||
ret ; and return
|
||||
;
|
||||
; Add the value in A to HL (HL := HL + A)
|
||||
;
|
||||
addhl:
|
||||
add a,l ; A := A + L
|
||||
ld l,a ; Put result back in L
|
||||
ret nc ; if no carry, we are done
|
||||
inc h ; if carry, increment H
|
||||
ret ; and return
|
||||
;
|
||||
; Jump indirect to address in HL
|
||||
;
|
||||
jphl:
|
||||
jp (hl)
|
||||
;
|
||||
; Short delay functions. No clock speed compensation, so they
|
||||
; will run longer on slower systems. The number indicates the
|
||||
; number of call/ret invocations. a single call/ret is
|
||||
; 27 t-states on a z80, 25 t-states on a z180
|
||||
;
|
||||
; ; Z80 Z180
|
||||
; ; ---- ----
|
||||
dly64: call dly32 ; 1728 1600
|
||||
dly32: call dly16 ; 864 800
|
||||
dly16: call dly8 ; 432 400
|
||||
dly8: call dly4 ; 216 200
|
||||
dly4: call dly2 ; 108 100
|
||||
dly2: call dly1 ; 54 50
|
||||
dly1: ret ; 27 25
|
||||
|
||||
;
|
||||
; Errors
|
||||
;
|
||||
erruse: ; command usage error (syntax)
|
||||
ld de,msguse
|
||||
jr err
|
||||
;
|
||||
errprm: ; command parameter error (syntax)
|
||||
ld de,msgprm
|
||||
jr err
|
||||
;
|
||||
errbio: ; invalid BIOS or version
|
||||
ld de,msgbio
|
||||
jr err
|
||||
;
|
||||
err: ; print error string and return error signal
|
||||
call crlf2 ; print newline
|
||||
;
|
||||
err1: ; without the leading crlf
|
||||
call prtstr ; print error string
|
||||
;
|
||||
err2: ; without the string
|
||||
; call crlf ; print newline
|
||||
or $FF ; signal error
|
||||
ret ; done
|
||||
;
|
||||
;===============================================================================
|
||||
; Storage Section
|
||||
;===============================================================================
|
||||
;
|
||||
is180 .db 0 ; non-zero for z180
|
||||
orgbnk .db 0 ; original bank id
|
||||
curport .db 0 ; current port being processed
|
||||
vallist .fill 8,0 ; port values read
|
||||
;
|
||||
stksav .dw 0 ; stack pointer saved at start
|
||||
.fill stksiz,0 ; stack
|
||||
stack .equ $ ; stack top
|
||||
;
|
||||
; Messages
|
||||
;
|
||||
msgban .db "PORTSWP v1.0, 14-Feb-2023",13,10
|
||||
.db "Copyright (C) 2023, Wayne Warthen, GNU GPL v3",0
|
||||
msguse .db "Usage: PORTSWP",13,10
|
||||
msgprm .db "Parameter error (PORTSWP /? for usage)",0
|
||||
msgbio .db "Incompatible BIOS or version, "
|
||||
.db "HBIOS v", '0' + rmj, ".", '0' + rmn, " required",0
|
||||
str_sep .db ": ",0
|
||||
;
|
||||
msgcpu .db "CPU is ",0
|
||||
msgz80 .db "Z80",0
|
||||
msgz180 .db "Z180",0
|
||||
msgdone .db "End of Port Sweep",0
|
||||
|
||||
;
|
||||
;
|
||||
;
|
||||
size .equ $ - runloc
|
||||
;
|
||||
.end
|
||||
@@ -40,8 +40,6 @@ ENA_XM .EQU TRUE ; INCLUDE XMODEM IF SPACE AVAILABLE
|
||||
;
|
||||
ENA_MBC6502 .EQU FALSE ; ENABLE OR DISABLE MBC6502 OPTION
|
||||
;
|
||||
#INCLUDE "util.asm"
|
||||
;
|
||||
;__UART_ENTRY_________________________________________________________________
|
||||
;
|
||||
; SERIAL MONITOR STARTUP
|
||||
@@ -1846,6 +1844,233 @@ DSKY_ENTRY:
|
||||
;
|
||||
#ENDIF
|
||||
;
|
||||
;==================================================================================================
|
||||
; UTILITY FUNCTIONS
|
||||
;==================================================================================================
|
||||
;
|
||||
;
|
||||
CHR_BEL .EQU 07H
|
||||
CHR_CR .EQU 0DH
|
||||
CHR_LF .EQU 0AH
|
||||
CHR_BS .EQU 08H
|
||||
CHR_ESC .EQU 1BH
|
||||
;
|
||||
;__________________________________________________________________________________________________
|
||||
;
|
||||
; UTILITY PROCS TO PRINT SINGLE CHARACTERS WITHOUT TRASHING ANY REGISTERS
|
||||
;
|
||||
PC_SPACE:
|
||||
PUSH AF
|
||||
LD A,' '
|
||||
JR PC_PRTCHR
|
||||
PC_COLON:
|
||||
PUSH AF
|
||||
LD A,':'
|
||||
JR PC_PRTCHR
|
||||
PC_CR:
|
||||
PUSH AF
|
||||
LD A,CHR_CR
|
||||
JR PC_PRTCHR
|
||||
|
||||
PC_LF:
|
||||
PUSH AF
|
||||
LD A,CHR_LF
|
||||
JR PC_PRTCHR
|
||||
|
||||
PC_PRTCHR:
|
||||
CALL COUT
|
||||
POP AF
|
||||
RET
|
||||
|
||||
NEWLINE2:
|
||||
CALL NEWLINE
|
||||
NEWLINE:
|
||||
CALL PC_CR
|
||||
CALL PC_LF
|
||||
RET
|
||||
PRTSTR:
|
||||
LD A,(HL)
|
||||
INC HL
|
||||
CP '$'
|
||||
RET Z
|
||||
CALL COUT
|
||||
JR PRTSTR
|
||||
;
|
||||
; PRINT THE HEX BYTE VALUE IN A
|
||||
;
|
||||
PRTHEXBYTE:
|
||||
PUSH AF
|
||||
PUSH DE
|
||||
CALL HEXASCII
|
||||
LD A,D
|
||||
CALL COUT
|
||||
LD A,E
|
||||
CALL COUT
|
||||
POP DE
|
||||
POP AF
|
||||
RET
|
||||
;
|
||||
; CONVERT BINARY VALUE IN A TO ASCII HEX CHARACTERS IN DE
|
||||
;
|
||||
HEXASCII:
|
||||
LD D,A
|
||||
CALL HEXCONV
|
||||
LD E,A
|
||||
LD A,D
|
||||
RLCA
|
||||
RLCA
|
||||
RLCA
|
||||
RLCA
|
||||
CALL HEXCONV
|
||||
LD D,A
|
||||
RET
|
||||
;
|
||||
; CONVERT LOW NIBBLE OF A TO ASCII HEX
|
||||
;
|
||||
HEXCONV:
|
||||
AND 0FH ;LOW NIBBLE ONLY
|
||||
ADD A,90H
|
||||
DAA
|
||||
ADC A,40H
|
||||
DAA
|
||||
RET
|
||||
;
|
||||
; ADD HL,A
|
||||
;
|
||||
; A REGISTER IS DESTROYED!
|
||||
;
|
||||
ADDHLA:
|
||||
ADD A,L
|
||||
LD L,A
|
||||
RET NC
|
||||
INC H
|
||||
RET
|
||||
;
|
||||
; DELAY 16US (CPU SPEED COMPENSATED) INCUDING CALL/RET INVOCATION
|
||||
; REGISTER A AND FLAGS DESTROYED
|
||||
; NO COMPENSATION FOR Z180 MEMORY WAIT STATES
|
||||
; THERE IS AN OVERHEAD OF 3TS PER INVOCATION
|
||||
; IMPACT OF OVERHEAD DIMINISHES AS CPU SPEED INCREASES
|
||||
;
|
||||
; CPU SCALER (CPUSCL) = (CPUHMZ - 2) FOR 16US + 3TS DELAY
|
||||
; NOTE: CPUSCL MUST BE >= 1!
|
||||
;
|
||||
; EXAMPLE: 8MHZ CPU (DELAY GOAL IS 16US)
|
||||
; LOOP = ((6 * 16) - 5) = 91TS
|
||||
; TOTAL COST = (91 + 40) = 131TS
|
||||
; ACTUAL DELAY = (131 / 8) = 16.375US
|
||||
;
|
||||
; --- TOTAL COST = (LOOP COST + 40) TS -----------------+
|
||||
DELAY: ; 17TS (FROM INVOKING CALL) |
|
||||
LD A,(CPUSCL) ; 13TS |
|
||||
; |
|
||||
DELAY1: ; |
|
||||
; --- LOOP = ((CPUSCL * 16) - 5) TS ------------+ |
|
||||
DEC A ; 4TS | |
|
||||
#IF (BIOS == BIOS_WBW) ; | |
|
||||
#IF (CPUFAM == CPU_Z180) ; | |
|
||||
OR A ; +4TS FOR Z180 | |
|
||||
#ENDIF ; | |
|
||||
#ENDIF ; | |
|
||||
JR NZ,DELAY1 ; 12TS (NZ) / 7TS (Z) | |
|
||||
; ----------------------------------------------+ |
|
||||
; |
|
||||
RET ; 10TS (RETURN) |
|
||||
;-------------------------------------------------------+
|
||||
;
|
||||
; DELAY 16US * DE (CPU SPEED COMPENSATED)
|
||||
; REGISTER DE, A, AND FLAGS DESTROYED
|
||||
; NO COMPENSATION FOR Z180 MEMORY WAIT STATES
|
||||
; THERE IS A 27TS OVERHEAD FOR CALL/RET PER INVOCATION
|
||||
; IMPACT OF OVERHEAD DIMINISHES AS DE AND/OR CPU SPEED INCREASES
|
||||
;
|
||||
; CPU SCALER (CPUSCL) = (CPUHMZ - 2) FOR 16US OUTER LOOP COST
|
||||
; NOTE: CPUSCL MUST BE > 0!
|
||||
;
|
||||
; EXAMPLE: 8MHZ CPU, DE=6250 (DELAY GOAL IS .1 SEC OR 100,000US)
|
||||
; INNER LOOP = ((16 * 6) - 5) = 91TS
|
||||
; OUTER LOOP = ((91 + 37) * 6250) = 800,000TS
|
||||
; ACTUAL DELAY = ((800,000 + 27) / 8) = 100,003US
|
||||
;
|
||||
; --- TOTAL COST = (OUTER LOOP + 27) TS ------------------------+
|
||||
VDELAY: ; 17TS (FROM INVOKING CALL) |
|
||||
; |
|
||||
; --- OUTER LOOP = ((INNER LOOP + 37) * DE) TS ---------+ |
|
||||
LD A,(CPUSCL) ; 13TS | |
|
||||
; | |
|
||||
VDELAY1: ; | |
|
||||
; --- INNER LOOP = ((CPUSCL * 16) - 5) TS ------+ | |
|
||||
#IF (BIOS == BIOS_WBW) ; | | |
|
||||
#IF (CPUFAM == CPU_Z180) ; | | |
|
||||
OR A ; +4TS FOR Z180 | | |
|
||||
#ENDIF ; | | |
|
||||
#ENDIF ; | | |
|
||||
DEC A ; 4TS | | |
|
||||
JR NZ,VDELAY1 ; 12TS (NZ) / 7TS (Z) | | |
|
||||
; ----------------------------------------------+ | |
|
||||
; | |
|
||||
DEC DE ; 6TS | |
|
||||
#IF (BIOS == BIOS_WBW) ; | | |
|
||||
#IF (CPUFAM == CPU_Z180) ; | |
|
||||
OR A ; +4TS FOR Z180 | |
|
||||
#ENDIF ; | |
|
||||
#ENDIF ; | |
|
||||
LD A,D ; 4TS | |
|
||||
OR E ; 4TS | |
|
||||
JP NZ,VDELAY ; 10TS | |
|
||||
;-------------------------------------------------------+ |
|
||||
; |
|
||||
RET ; 10TS (FINAL RETURN) |
|
||||
;---------------------------------------------------------------+
|
||||
;
|
||||
; DELAY ABOUT 0.5 SECONDS
|
||||
; 500000US / 16US = 31250
|
||||
;
|
||||
LDELAY:
|
||||
PUSH AF
|
||||
PUSH DE
|
||||
LD DE,31250
|
||||
CALL VDELAY
|
||||
POP DE
|
||||
POP AF
|
||||
RET
|
||||
;
|
||||
; INITIALIZE DELAY SCALER BASED ON OPERATING CPU SPEED
|
||||
; ENTER WITH A = CPU SPEED IN MHZ
|
||||
;
|
||||
DELAY_INIT:
|
||||
CP 3 ; TEST FOR <= 2 (SPECIAL HANDLING)
|
||||
JR C,DELAY_INIT1 ; IF <= 2, SPECIAL PROCESSING
|
||||
SUB 2 ; ADJUST AS REQUIRED BY DELAY FUNCTIONS
|
||||
JR DELAY_INIT2 ; AND CONTINUE
|
||||
DELAY_INIT1:
|
||||
LD A,1 ; USE THE MIN VALUE OF 1
|
||||
DELAY_INIT2:
|
||||
LD (CPUSCL),A ; UPDATE CPU SCALER VALUE
|
||||
RET
|
||||
|
||||
#IF (CPUMHZ < 3)
|
||||
CPUSCL .DB 1 ; CPU SCALER MUST BE > 0
|
||||
#ELSE
|
||||
CPUSCL .DB CPUMHZ - 2 ; OTHERWISE 2 LESS THAN PHI MHZ
|
||||
#ENDIF
|
||||
;
|
||||
; SHORT DELAY FUNCTIONS. NO CLOCK SPEED COMPENSATION, SO THEY
|
||||
; WILL RUN LONGER ON SLOWER SYSTEMS. THE NUMBER INDICATES THE
|
||||
; NUMBER OF CALL/RET INVOCATIONS. A SINGLE CALL/RET IS
|
||||
; 27 T-STATES ON A Z80, 25 T-STATES ON A Z180
|
||||
;
|
||||
; ; Z80 Z180
|
||||
; ; ---- ----
|
||||
DLY64: CALL DLY32 ; 1728 1600
|
||||
DLY32: CALL DLY16 ; 864 800
|
||||
DLY16: CALL DLY8 ; 432 400
|
||||
DLY8: CALL DLY4 ; 216 200
|
||||
DLY4: CALL DLY2 ; 108 100
|
||||
DLY2: CALL DLY1 ; 54 50
|
||||
DLY1: RET ; 27 25
|
||||
;
|
||||
;
|
||||
;
|
||||
.FILL 16,0 ; SET MINIMUM STACK DEPTH
|
||||
SLACK .EQU (MON_END - $)
|
||||
|
||||
@@ -1020,6 +1020,9 @@ HB_ENTRYTBL .EQU $
|
||||
;
|
||||
JP HB_START ; HBIOS INITIALIZATION
|
||||
JP HB_DISPATCH ; VECTOR TO DISPATCHER
|
||||
JP PRTSUM
|
||||
; !!! DO NOT ADD ADDTIONAL VECTORS HERE WITHOUT
|
||||
; CHECKING W/ WAYNE !!!
|
||||
;
|
||||
HB_STKSIZ .EQU $100 - ($ & $FF)
|
||||
;
|
||||
|
||||
@@ -464,8 +464,6 @@ applst2:
|
||||
; Device list
|
||||
;
|
||||
devlst:
|
||||
ld hl,str_devlst ; device list header string
|
||||
call pstr ; display it
|
||||
jp prtall ; do it
|
||||
;
|
||||
; Set console interface unit
|
||||
@@ -1826,99 +1824,26 @@ CST .equ cst
|
||||
; Device inventory display
|
||||
;=======================================================================
|
||||
;
|
||||
; Print list of all drives (WBW)
|
||||
;
|
||||
#if (BIOS == BIOS_WBW)
|
||||
;
|
||||
; Print list of all drives (WBW)
|
||||
;
|
||||
; Just invoke the existing HBIOS routine...
|
||||
;
|
||||
prtall:
|
||||
call nl ; formatting
|
||||
ld b,BF_SYSGET
|
||||
ld c,BF_SYSGET_DIOCNT
|
||||
rst 08 ; E := disk unit count
|
||||
ld b,e ; count to B
|
||||
ld a,b ; count to A
|
||||
or a ; set flags
|
||||
ret z ; bail out if zero
|
||||
ld c,0 ; init device index
|
||||
;
|
||||
prtall1:
|
||||
ld hl,str_disk ; prefix string
|
||||
call pstr ; display it
|
||||
ld a,c ; index
|
||||
call prtdecb ; print it
|
||||
ld hl,str_on ; separator string
|
||||
call pstr
|
||||
push bc ; save loop control
|
||||
ld b,BF_DIODEVICE ; HBIOS func: report device info
|
||||
rst 08 ; call HBIOS
|
||||
call prtdrv ; print it
|
||||
pop bc ; restore loop control
|
||||
inc c ; bump index
|
||||
djnz prtall1 ; loop as needed
|
||||
ret ; done
|
||||
;
|
||||
; Print the device info
|
||||
; On input D has device type, E has device number
|
||||
; Destroy no registers other than A
|
||||
;
|
||||
prtdrv:
|
||||
push de ; preserve de
|
||||
push hl ; preserve HL
|
||||
ld a,d ; load device/unit
|
||||
rrca ; rotate device
|
||||
rrca ; ... bits
|
||||
rrca ; ... into
|
||||
rrca ; ... lowest 4 bits
|
||||
and $0F ; isolate device bits
|
||||
add a,a ; multiple by two for word table
|
||||
ld hl,devtbl ; point to start of table
|
||||
call addhla ; add A to HL for table entry
|
||||
ld a,(hl) ; deref HL for string adr
|
||||
inc hl ; ...
|
||||
ld h,(hl) ; ...
|
||||
ld l,a ; ...
|
||||
call pstr ; print the device nmemonic
|
||||
pop hl ; recover HL
|
||||
pop de ; recover DE
|
||||
ld a,e ; device number
|
||||
call prtdecb ; print it
|
||||
ld a,':' ; suffix
|
||||
call cout ; print it
|
||||
ret
|
||||
;
|
||||
devtbl: ; device table
|
||||
.dw dev00, dev01, dev02, dev03
|
||||
.dw dev04, dev05, dev06, dev07
|
||||
.dw dev08, dev09, dev10, dev11
|
||||
.dw dev12, dev13, dev14, dev15
|
||||
;
|
||||
devunk .db "???",0
|
||||
dev00 .db "MD",0
|
||||
dev01 .db "FD",0
|
||||
dev02 .db "RAMF",0
|
||||
dev03 .db "IDE",0
|
||||
dev04 .db "ATAPI",0
|
||||
dev05 .db "PPIDE",0
|
||||
dev06 .db "SD",0
|
||||
dev07 .db "PRPSD",0
|
||||
dev08 .db "PPPSD",0
|
||||
dev09 .db "HDSK",0
|
||||
dev10 .equ devunk
|
||||
dev11 .equ devunk
|
||||
dev12 .equ devunk
|
||||
dev13 .equ devunk
|
||||
dev14 .equ devunk
|
||||
dev15 .equ devunk
|
||||
ld a,BID_BIOS ; BIOS Bank please
|
||||
ld ix,$0406 ; HBIOS PRTSUM vector
|
||||
jp HB_BNKCALL ; do it
|
||||
;
|
||||
#endif
|
||||
;
|
||||
;
|
||||
;
|
||||
#if (BIOS == BIOS_UNA)
|
||||
;
|
||||
; Print list of all drives (UNA)
|
||||
;
|
||||
prtall:
|
||||
ld hl,str_devlst ; device list header string
|
||||
call pstr ; display it
|
||||
call nl ; formatting
|
||||
ld b,0 ; start with unit 0
|
||||
;
|
||||
@@ -1997,6 +1922,8 @@ devsd .db "SD",0
|
||||
devdsd .db "DSD",0
|
||||
devunk .db "UNK",0
|
||||
;
|
||||
str_devlst .db "\r\n\r\nDisk Devices:",0
|
||||
;
|
||||
#endif
|
||||
;
|
||||
;=======================================================================
|
||||
@@ -2090,7 +2017,6 @@ str_reboot .db "\r\n\r\nRestarting System...",0
|
||||
str_newcon .db "\r\n\r\n Console on Unit #",0
|
||||
str_chspeed .db "\r\n\r\n Change speed now. Press a key to resume.",0
|
||||
str_applst .db "\r\n\r\nROM Applications:",0
|
||||
str_devlst .db "\r\n\r\nDisk Devices:",0
|
||||
str_invcmd .db "\r\n\r\n*** Invalid Command ***",bel,0
|
||||
str_load .db "\r\n\r\nLoading ",0
|
||||
str_disk .db "\r\n Disk Unit ",0
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
#DEFINE RMN 1
|
||||
#DEFINE RUP 1
|
||||
#DEFINE RTP 0
|
||||
#DEFINE BIOSVER "3.1.1-pre.197"
|
||||
#DEFINE BIOSVER "3.1.1-pre.198"
|
||||
|
||||
@@ -3,5 +3,5 @@ rmn equ 1
|
||||
rup equ 1
|
||||
rtp equ 0
|
||||
biosver macro
|
||||
db "3.1.1-pre.197"
|
||||
db "3.1.1-pre.198"
|
||||
endm
|
||||
|
||||
Reference in New Issue
Block a user