diff --git a/Sim.cfg b/Sim.cfg index 7d4d24f1..fc695e6e 100644 --- a/Sim.cfg +++ b/Sim.cfg @@ -1,11 +1,11 @@ set cpu z80 ;set throttle 4K set cpu noaltairrom -set n8vem enabled debug=verbose +;set n8vem enabled debug=verbose set debug debug.log ; Console -set console telnet=23 +; set console telnet=23 ; Configure Serial Port (Basic polled 16550 UART) set sio tty @@ -21,7 +21,7 @@ echo ROM Image: '%1' attach n8vem0 %1 ; hard disks -set hdsk debug=read;write;verbose +;set hdsk debug=read;write;verbose attach hdsk0 Output\hd0.img attach hdsk1 Output\hd1.img set hdsk0 format=HDSK diff --git a/Sim.cmd b/Sim.cmd new file mode 100644 index 00000000..00a706d3 --- /dev/null +++ b/Sim.cmd @@ -0,0 +1,12 @@ +@echo off +set ROM=Output\SBC_simh.rom +if not "%1"=="" set ROM=Output\%1.rom +if not exist %ROM% goto romerr +rem start C:\Users\WWarthen\Bin\putty.exe -load "SIMH Telnet" +start /w tools\altairz80.exe sim.cfg %ROM% +goto :eof + +:romerr +echo ROM Image %ROM% Not Found! +pause +goto :eof diff --git a/Source/BPBIOS/@WBW Z3ENV.txt b/Source/BPBIOS/@WBW Z3ENV.txt index ede61d20..0b8bb617 100644 --- a/Source/BPBIOS/@WBW Z3ENV.txt +++ b/Source/BPBIOS/@WBW Z3ENV.txt @@ -1,123 +1,229 @@ -============================================================================= -ORIGINAL DISTRIBUTION ENVIRONMENT ------------------------------------------------------------------------------ - A - Environment - FE00H F - Named Dirs - FC00H - Size (# recs)- 2 # of Entries - 14 - B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H - Size (# recs)- 4 # of Entries - 5 - C - I/O Package - EC00H H - Shell Stack - FD00H - Size (# recs)- 12 # of Entries - 4 - D - Res Cmd Proc - F200H Entry Size - 32 - Size (# recs)- 16 I - Msg Buffer - FD80H - E - Command Line - FF00H J - Ext. FCB - FDD0H - Size (bytes) - 203 K - Ext. Stack - FFD0H -============================================================================= +BPBIOS for RomWBW / HBIOS +------------------------- + +The build process included in this directory constructs multiple BPBIOS OS images that +can be loaded dynamically on a running RomWBW CP/M-like system. Normally, you would +boot CP/M and then load the desired variant. On a running system, you would enter +something like "LDSYS BP34T". This document describes the specifics of the build +process and the image variations which are identified by naming convention. + +Each image is composed of three basic components: Command Processor (CCP), Disk +Operating System (DOS), and Basic I/O System (BIOS). The CCP and DOS components +are pre-built, relocatable binaries. The BIOS (BPBIOS) is assembled into a relocatable +binary by the build, then the build links together all three components to form the +final loadable image (.IMG) file. The linking process is performed by the custom BPBIOS +linker (BPBUILD.COM). In addition to linking the 3 components, BPBUILD also sets +adjusts the ZCPR environment configuration. + +BPBUILD is designed to be run interactively. However, it can be started with an +existing OS image to edit an existing image file. In order to achieve an automated +build process with no interaction, this directory contains several template image (.DAT) +files that have environment configurations defined below. The build process passes the desired +tempate file to BPBUILD on the command line and uses input redirection to automate the +running of BPBUILD. + +The CCP can be ZCPR 3.3 (ZCPR33?.REL), ZCPR 3.4 (Z34.REL), or ZCPR 4.1 (Z41.ZRL). ZCPR 3.3 +uses static references to the ZCPR segments, so a custom version of it must be assembled. +The ZCPR33 subdirectory provides a build process for doing this. It produces a specific +version for each of the memory segment configurations (ZCPR33T.REL & ZCPR33N.REL). + +The DOS can be ZSDOS 1.1 (ZSDOS.ZRL) or ZSDOS 2.03 (ZS203.ZRL). These are both pre-built +relocatable binaries. Note that only certain version combinations of ZSDOS and ZCPR are +possible as indicated below. Additionally, ZSDOS 2.X requires a banked BIOS. + +ZCPR 3.X == ZSDOS 1.X +ZCPR 4.X == ZSDOS 2.X + +BPBIOS must be assembled for the target configuration. BPBIOS includes a DEF-WW-???????.LIB +file during assembly which sets various equates to contol the features and behavior of +BPBIOS. The most critical ones are: + + BANKED: If YES, BPBIOS implements memory banking features + ZSDOS2: If YES, BPBIOS is built to utilize ZSDOS 2.X specifics features + INTPXY: If YES, BPBIOS implements HBIOS proxy code internally w/ stub at FFE0H-FFFFH + +The table below illustrates the target build configurations along with the +.DAT and .LIB files which are utilized for the specific configuration. The "?" +is replaced with a letter that represents one of the ZCPR memory segment configurations +described later in this document. + +BP33?.DAT DEF-WW-Z33?.LIB Non-Banked BPBIOS w/ ZCPR 3.3 & ZSDOS 1.1 +BP33?BNK.DAT DEF-WW-Z33?BNK.LIB Banked BPBIOS w/ ZCPR 3.3 & ZSDOS 1.1 +BP34?.DAT DEF-WW-Z34?.LIB Non-Banked BPBIOS w/ ZCPR 3.4 & ZSDOS 1.1 +BP34?BNK.DAT DEF-WW-Z34?BNK.LIB Banked BPBIOS w/ ZCPR 3.4 & ZSDOS 1.1 +BP41?BNK.DAT DEF-WW-Z41?BNK.LIB Banked BPBIOS w/ ZCPR 4.1 & ZSDOS 2.03 + +The table below illustrates the BPBIOS equates used and the specific CCP/DOS/BIOS +components that are used to generate each configuration. As above, the "?" is +replaced with a letter that represents one of the ZCPR memory segment configurations +described later in this document. + + BP33? BP33?BNK BP34? BP34?BNK BP41?BNK +-------------- -------------- -------------- -------------- -------------- -------------- +BANKED NO YES NO YES YES +ZSDOS2 NO NO NO NO YES +-------------- -------------- -------------- -------------- -------------- -------------- +CCP ZCPR33?.REL ZCPR33?.REL Z34.REL Z34.REL Z41.ZRL +DOS ZSDOS.ZRL ZSDOS.ZRL ZSDOS.ZRL ZSDOS.ZRL ZS203.ZRL +BIOS BP33.REL BP33BNK.REL BP34.REL BP34BNK.REL BP41.REL +-------------- -------------- -------------- -------------- -------------- -------------- -============================================================================= -STANDARD ENVIRONMENT (HBIOS IMBEDDED IN BPBIOS) ------------------------------------------------------------------------------ - A - Environment - FE00H F - Named Dirs - FC00H - Size (# recs)- 2 # of Entries - 14 - B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H - Size (# recs)- 4 # of Entries - 5 - C - I/O Package - EC00H H - Shell Stack - FD00H - Size (# recs)- 12 # of Entries - 4 - D - Res Cmd Proc - F200H Entry Size - 32 - Size (# recs)- 16 I - Msg Buffer - FD80H - E - Command Line - FF00H J - Ext. FCB - FDD0H - Size (bytes) - 203 K - Ext. Stack - FFD0H -============================================================================= +In addition to the configuration options above, ZCPR also utilizes a +defined set of memory segments in upper memory. The location and size of these +segments have many ramifications and general ZCPR / BPBIOS documents +should be consulted to understand these. The build process used here +produces several different configurations which can be loaded at runtime. +The original distributed memory segment configuration occupies the top +of memory which, unfortunately, conflicts with the RomWBW HBIOS need to +occupt this space. + +Although RomWBW HBIOS is implemented in it's own dedicated memory bank, it +requires a small proxy at the top of memory which acts as a mechansim to +route calls to HBIOS. There are two ways to implement this upper memory +proxy. The full proxy occupies FE00H-FFFFH and implements all of the +HBIOS routing code. Alternatively, a mini proxy can be utilized to +minimize the dedicated proxy space in upper memory. The mini proxy +requires just 20H bytes at the top of memory (FFE0H-FFFFH), but requires +that the bulk of the proxy code be implemented internally in BPBIOS. + +Taking the above into account, the build process implements a couple of +memory segment configurations that are compatible with RomWBW HBIOS. +Essentially, these configurations rearrange the ZCPR memory segments +to free up the area required by the HBIOS full or mini proxy. Note +that this is a bit complicated because there are some constraints on +the locations of certain segments. + +First, the RCP, FCP, and IOP segments contain executable code which is +pre-built and intended to run at specific locations. Specifically, the +SYS.RCP, SYS.FCP, and SYS.IOP files provided with the BPBIOS distribution +must be loaded at their original intended location. In theory, new +versions of these files could be created to load at different locations, +but that is not the approach taken here. Instead, the memory segment +configurations are designed to keep these 3 components at the same +location as the original distribution. + +BPBIOS is assembled as relocatable code. Subsequently, the BPBUILD tool +is used to link BPBIOS with the CCP and DOS relocatable code to produce +the absolute image (.IMG file). Note that BPBUILD does more than just +linking. As part of it's work, BPBUILD adjusts the built-in environment +segment to customize the final image for the desired location and size +of Z-System segments. + +The following table summarizes the original memory segment configuration and the +two new configurations utilized by this build process. As indicated above, the +original configuration is incompatible with RomWBW HBIOS because it occupies the +very top of memory. This configuration is shown below purely to document the +original distribued configuration. + +SEGMENT Original T Config N Config +-------------- -------------- -------------- -------------- +Environment FE00 EA00* FE00 + # Recs 2 2 2 +Flow Ctl Pkg FA00 FA00 FA00 + # Recs 4 4 4 +I/O Pkg EC00 EC00 EC00 + # Recs 12 12 12 +Res Cmd Pkg F200 F200 F200 + # Recs 16 16 16 +Cmd Line FF00 EB00* FF00 + # Bytes 203 203 171* +Named Dirs FC00 FC00 FC00 + # Ents 14 14 14 +Ext Path FDF4 FDF4 FDF4 + # Ents 5 5 5 +Shell Stack FD00 FD00 FD00 + # Ents 4 4 4 + Ent Size 32 32 32 +Msg Buffer FD80 FD80 FD80 +Ext FCB FDD0 FDD0 FDD0 +Ext Stack FFD0 EBD0* FFB0* + +User Space E900 E700* E900 + Size 300 300 300 + +Wheel Byte FDFF FDFF FDFF + +The sections below provide a more detailed description of the memory +segment configurations. ============================================================================= -X ENVIRONMENT (HBIOS @ FC00): ALL SEGMENTS SHIFTED DOWN BY $400 +ORIGINAL DISTRIBUTION CONFIGURATION (NO HBIOS): + This is the original distribution configuration of BPBIOS which + occupies all upper RAM (to FFFFH). So, there is no room for the + HBIOS proxy and, therefore, is not compatibile with RomWBW. This + configuration is documented only for reference. It is not built + by the build process and is not compatible with RomWBW HBIOS. ----------------------------------------------------------------------------- - A - Environment - FA00H F - Named Dirs - F800H - Size (# recs)- 2 # of Entries - 14 - B - Flow Ctrl Pkg - F600H G - External Path - F9F4H - Size (# recs)- 4 # of Entries - 5 - C - I/O Package - E800H H - Shell Stack - F900H - Size (# recs)- 12 # of Entries - 4 - D - Res Cmd Proc - EE00H Entry Size - 32 - Size (# recs)- 16 I - Msg Buffer - F980H - E - Command Line - FB00H J - Ext. FCB - F9D0H - Size (bytes) - 171 K - Ext. Stack - FBB0H + A - Environment - FE00H F - Named Dirs - FC00H + Size (# recs)- 2 # of Entries - 14 + B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H + Size (# recs)- 4 # of Entries - 5 + C - I/O Package - EC00H H - Shell Stack - FD00H + Size (# recs)- 12 # of Entries - 4 + D - Res Cmd Proc - F200H Entry Size - 32 + Size (# recs)- 16 I - Msg Buffer - FD80H + E - Command Line - FF00H J - Ext. FCB - FDD0H + Size (bytes) - 203 K - Ext. Stack - FFD0H ============================================================================= ============================================================================= -T ENVIRONMENT (HBIOS @ FC00): ALL SEGMENTS REARRANGED +T CONFIGURATION (HBIOS FULL PROXY @ FC00-FFFF): + This configuration uses a modified layout of the ZSystem segments so + that critical segments can be located at the same address as the + "stock" configuration. Some segments are built with an assumed + memory location and will generally fail if they are not loaded in + that location. The Flow Control Package (FCP) and Resident + Command Processor (RCP) are very sensitive to this. This configuration + places them at their original locations, so they work well. ----------------------------------------------------------------------------- - A - Environment - EA00H F - Named Dirs - E800H - Size (# recs)- 2 # of Entries - 14 - B - Flow Ctrl Pkg - FA00H G - External Path - E9F4H - Size (# recs)- 4 # of Entries - 5 - C - I/O Package - EC00H H - Shell Stack - E900H - Size (# recs)- 12 # of Entries - 4 - D - Res Cmd Proc - F200H Entry Size - 32 - Size (# recs)- 16 I - Msg Buffer - E980H - E - Command Line - EB00H J - Ext. FCB - E9D0H - Size (bytes) - 171 K - Ext. Stack - EBB0H + A - Environment - EA00H F - Named Dirs - FC00H + Size (# recs)- 2 # of Entries - 14 + B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H + Size (# recs)- 4 # of Entries - 5 + C - I/O Package - EC00H H - Shell Stack - FD00H + Size (# recs)- 12 # of Entries - 4 + D - Res Cmd Proc - F200H Entry Size - 32 + Size (# recs)- 16 I - Msg Buffer - FD80H + E - Command Line - EB00H J - Ext. FCB - FDD0H + Size (bytes) - 203 K - Ext. Stack - EBD0H ============================================================================= ============================================================================= -N ENVIRONMENT (HBIOS IMBEDDED IN BPBIOS): SMALL HBIOS STUB AT FFE0-FFFF +N CONFIGURATION (HBIOS MINI PROXY @ FFE0-FFFF): + This configuration frees up the top 20H bytes of memory to make space for the + HBIOS mini-proxy. It does this by shrinking Cmd Line and shifting the Ext Stack + down by 32 bytes. This configuration will only work if INTPXY=YES in HBIOS. ----------------------------------------------------------------------------- - A - Environment - FE00H F - Named Dirs - FC00H - Size (# recs)- 2 # of Entries - 14 - B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H - Size (# recs)- 4 # of Entries - 5 - C - I/O Package - EC00H H - Shell Stack - FD00H - Size (# recs)- 12 # of Entries - 4 - D - Res Cmd Proc - F200H Entry Size - 32 - Size (# recs)- 16 I - Msg Buffer - FD80H - E - Command Line - FF00H J - Ext. FCB - FDD0H - Size (bytes) - 171 K - Ext. Stack - FFB0H + A - Environment - FE00H F - Named Dirs - FC00H + Size (# recs)- 2 # of Entries - 14 + B - Flow Ctrl Pkg - FA00H G - External Path - FDF4H + Size (# recs)- 4 # of Entries - 5 + C - I/O Package - EC00H H - Shell Stack - FD00H + Size (# recs)- 12 # of Entries - 4 + D - Res Cmd Proc - F200H Entry Size - 32 + Size (# recs)- 16 I - Msg Buffer - FD80H + E - Command Line - FF00H J - Ext. FCB - FDD0H + Size (bytes) - 171 K - Ext. Stack - FFB0H ============================================================================= - - -COMPONENT BP33 BP33BNK BP34 BP34BNK BP41 --------------- -------------- -------------- -------------- -------------- -------------- -CCP ZCPR33.REL ZCPR33.REL Z34.REL Z34.REL Z41.ZRL -DOS ZSDOS.ZRL ZSDOS.ZRL ZSDOS.ZRL ZSDOS.ZRL ZS203.ZRL -BIOS BP33.REL BP33BNK.REL BP34.REL BP34BNK.REL BP41.REL - -NOTE: Implementing the environment changes in ZCPR33 requires building a new ZCPR33 from source!!! - - -SEGMENT Original Std Type X Type T Type N --------------- -------------- -------------- -------------- -------------- -------------- - -Environment FE00 FE00 FA00 EA00 FE00 - # Recs 2 2 2 2 2 -Flow Ctl Pkg FA00 FA00 F600 FA00 FA00 - # Recs 4 4 4 4 4 -I/O Pkg EC00 EC00 E800 EC00 EC00 - # Recs 12 12 12 12 12 -Res Cmd Pkg F200 F200 EE00 F200 F200 - # Recs 16 16 16 16 16 -Cmd Line FF00 FF00 FB00 EB00 FF00 - # Bytes 203 203 171 171 171 -Named Dirs FC00 FC00 F800 E800 FC00 - # Ents 14 14 14 14 14 -Ext Path FDF4 FDF4 F9F4 E9F4 FDF4 - # Ents 5 5 5 5 5 -Shell Stack FD00 FD00 F900 E900 FD00 - # Ents 4 4 4 4 4 - Ent Size 32 32 32 32 32 -Msg Buffer FD80 FD80 F980 E980 FD80 -Ext FCB FDD0 FDD0 F9D0 E9D0 FDD0 -Ext Stack FFD0 FFD0 FBB0 EBB0 FFB0 - - -Type X: All segments shifted down by size of HBIOS Proxy (1024 bytes) -Type T: Segments rearranged to allow space for HBIOS Proxy - FC00-FFFF --> EA00-EBFF - Environment, Cmd Line, Named Dirs, Ext Path, Shell Stack, Msg Buffer, Ext FCB, Ext Stack -Type N: Frees up HBIOS interface area at FFE0-FFFF by shrinking Cmd Line and shifting - Ext Stack down by 32 bytes - - -If built with INTPXY=NO, then LDSYS BP34T, BP34TBNK, or BP41T -If built with INTPXY=YES, then LDSYS BP33N, BP33NBNK, BP34N, BP34NBNK, or BP41N - - +BPBIOS is designed to invoke a command at startup (autostart command). There +are 3 ZEX command files customized for this build. They are Z33.ZEX, Z34.ZEX, +and Z41.ZEX. BPBIOS is customized to launch the ZEX command file corresponding +to the version of ZCPR being linked with it. + +The table below summarizes the loadable image files created by the build +process: + +ZCPR ZSDOS BPBIOS STARTUP T (INTPXY=NO) N (INTPXY=YES) +------ ------ -------------- -------------- -------------- -------------- +v3.3 v1.1 NON-BANKED Z33.ZEX BP33T.IMG BP33N.IMG +v3.3 v1.1 BANKED Z33.ZEX BP33TBNK.IMG BP33NBNK.IMG +v3.4 v1.1 NON-BANKED Z34.ZEX BP34T.IMG BP34N.IMG +v3.4 v1.1 BANKED Z34.ZEX BP34TBNK.IMG BP34NBNK.IMG +v4.1 v2.03 BANKED Z41.ZEX BP41TBNK.IMG BP41NBNK.IMG + +WARNING: Once an N configuration image has been loaded, it is no longer +possible to load a T configuration without rebooting. This constraint +exists because the N configurations wipe out all but the top 20H bytes +of memory. The T configurations rely on the full 200H byte HBIOS +proxy. diff --git a/Source/BPBIOS/Build.cmd b/Source/BPBIOS/Build.cmd index 746c33e9..6437d2c5 100644 --- a/Source/BPBIOS/Build.cmd +++ b/Source/BPBIOS/Build.cmd @@ -8,266 +8,68 @@ set ZXBINDIR=../../tools/cpm/bin/ set ZXLIBDIR=../../tools/cpm/lib/ set ZXINCDIR=../../tools/cpm/include/ -rem -rem Z33 + ZSDOS11 w/ Non-banked BPBIOS -rem - -copy def-ww-z33.lib def-ww.lib -zx ZMAC -BPBIO-WW -/P -if exist bp33.prn del bp33.prn -ren bpbio-ww.prn bp33.prn +pushd ZCPR33 && call Build.cmd && popd pause -if exist bp33.rel del bp33.rel -ren bpbio-ww.rel bp33.rel - -if exist bpsys.img del bpsys.img -zx bpbuild -bp33.dat beginning of command line buffer + ld (nxtchr),hl ; Save as pointer to next character to process + ld (hl),0 ; Zero out command line (in case of warm boot) + push hl ; Save pointer to command line + call readbuf ; Input command line (ZEX, submit, shell, + ; ..or user) + pop hl ; Get back pointer to command line + ld a,(hl) ; Check for comment line + cp comment ; Begins with comment character? + jr z,restart ; If so, go back for another line + ; Otherwise, fall through + +;----------------------------------------------------------------------------- + +; COMMAND CONTINUATION PROCESSING ENTRY POINT + +; This is the entry point for continuing the processing of an existing command +; line. The current drive and user values as known to the CPR are combined +; and made into the user/drive byte that CP/M keeps at location 0004. If the +; HIGHUSER option is enabled, the user number for this byte is forced to be +; in the range 0..15. Next the command status flag is processed. The error +; and ECP bits in the actual flag are reset, and the original flag is checked +; for an ECP error return (both ECP bit and error bit set). In that case, +; control is transferred to the error handler. + +nextcmd: + ld hl,(curusr) ; Get currently logged drive and user + ld a,l ; Work on user number + if highuser + and 0fh ; Keep value modulo 16 + endif ;highuser + swap ; Get user into high nibble + or h ; ..and drive into low nibble + ld (udflag),a ; Set user/disk flag in page 0 + + ld a,2 ; Turn ZEX input redirection off + ld (zexinpfl),a + if subon + ld (xsubflag),a ; Turn off XSUB input redirection + endif ;subon + + ld hl,cmdstatfl ; Point to the command status flag (CSF) + ld a,(hl) ; Get a copy into register A + res 1,(hl) ; Reset the actual error bit + res 2,(hl) ; Reset the actual ECP bit + and 110b ; Select ECP and error bits in original flag + cp 110b ; Test for an ECP error + jp z,error ; Process ECP error with error handler + +nextcmd1: + ld sp,stack ; Reset stack + call logcurrent ; Return to default directory + ld hl,(nxtchr) ; Point to first character of next command + push hl ; Save pointer to next character to process + +; We have to capitalize the command line each time because an alias or other +; command line generator may have stuck some new text in. The code is shorter +; if we simply capitalize the entire command rather than trying to capitalize +; only the one command we are about to execute. + +capbuf: ; Capitalize the command line + ld a,(hl) ; Get character + call ucase ; Convert to upper case + ld (hl),a ; Put it back + inc hl ; Point to next one + or a ; See if end of line (marked with null) + jr nz,capbuf ; If not, loop back + + pop hl ; Restore pointer to next character to process + +nextcmd3: + +; ZCPR33 provides a convenience feature to make it easier to enter a leading +; colon to force the current directory to be scanned and to make the CPR skip +; resident commands. If ALTCOLON is active, an alternate character can be +; entered as the first character of a command. The default (and recommended) +; alternative character is the period (it could not have any other meaning +; here). If FASTECP (see below) is not enabled or if ALTONLY is enabled, +; leading spaces on the command line are skipped before looking for the +; alternate character for the colon + + if [ not fastecp ] or [ fastecp and altonly ] + call sksp + endif ;[ not fastecp ] or [ fastecp and altonly ] + + if altcolon ; If allowing alias character for leading colon + ; Set B = ':' and C = alias character ('.') + ld bc,':' shl 8 + altchar + ld a,(hl) ; Get first character in new command line + cp c ; If first character is ALTCHAR, treat as ':' + jr nz,nextcmd3a ; Branch if not '.' + ld (hl),b ; Else replace with colon +nextcmd3a: + endif ;altcolon + + +; ZCPR33 supports three new options that can speed up command processing. +; FASTECP allows commands with a leading space to bypass the search for +; resident commands or transient commands (COM files) along the path and go +; directly to the extended command processor. With SKIPPATH enabled, when +; a command is prefixed by an explicit directory specification (but not a +; lone colon), searching of the path and invocation of the ECP are disabled. +; If the command is not found in the specified directory, the error handler +; is invoked immediately. Finally, if BADDUECP is enabled, when an attempt +; is made to log into an invalid directory, the command is sent directly to +; the ECP, which can provide special handling. To implement these three +; features, the first actual character of the command line is saved as a +; flag in FIRSTCHAR. My apologies for the complexity of these nested +; conditionals. + + if fastecp or skippath or badduecp + + ; With FASTECP we store the first actual + ; ..character and then skip over spaces (unless ALTONLY is + ; ..enabled, in which case we skipped spaces above) + + if fastecp + + if altspace ; If allowing alias character for leading space + ; Set B = ' ' and C = alias character ('/') + ld bc,' ' shl 8 + ecpchar + ld a,(hl) ; Get first character in new command line + cp c ; If first character is ECPCHAR treat as ' ' + jr nz,nextcmd3b ; Branch if not '/' (alternate character) + ld (hl),b ; Else replace with space +nextcmd3b: + endif ;altspace + + ld a,(hl) ; Get first character in command line + ld (firstchar),a ; Save it in flag + call sksp ; Then skip leading spaces + endif ;fastecp + + ; With SKIPPATH but not FASTECP we store the first + ; ..character of the command (spaces were skipped above) + + if [ not fastecp ] and skippath + ld (firstchar),a ; Store first nonspace character + endif ;[ not fastecp ] and skippath + + ; With only BADDUECP (and neither SKIPPATH nor FASTECP) + ; ..we store a null in the FIRSTCHAR flag + + if [ not fastecp ] and [ not skippath ] + xor a + ld (firstchar),a + endif ;[ not fastecp ] and [ not skippath ] + + endif ;fastecp or skippath or badduecp + +; Resume processing of the command line + + or a ; Now at end of line? + jr z,restart ; If so, get a new command line + cp ctrlc ; Flush ^C to prevent error-handler + jr z,restart ; ..invocation on warm boots + + cp cmdsep ; Is it a command separator? + jr nz,nextcmd4 ; If not, skip ahead to process the command + inc hl ; If it is, skip over it + jr nextcmd3 ; ..and process next command + +nextcmd4: + +; Unless we are now running the external error handler, the following code +; saves the address of the current command in Z3MSG+4 for use by programs +; to determine the command line with which they were invoked. + + ld a,(cmdstatfl) ; Get command status flag + bit 1,a ; Test for error handler invocation + jr nz,nextcmd5 ; If so, skip over next instruction + ld (cmdptr),hl + +nextcmd5: + call parser ; Parse entire command line, then look for + ; ..the command + + +;============================================================================= + +; C O M M A N D S E A R C H C O D E + +;============================================================================= + +; CODE FOR FINDING AND RUNNING THE COMMAND + +; Here is the code for running a command. Commands are searched for and +; processed in the following order: +; +; 1) flow control package (FCP) commands and IF state testing +; 2) resident command package (RCP) +; 3) command processor (CPR) +; 4) transient (COM file or extended command processor) +; 5) external error handler +; 6) internal error message and processing +; +; Special notes: +; +; a) If the current command is a shell command, special handling of flow +; control is required. If SHELLIF is enabled so that flow commands are +; allowed in shell alias scripts, then we reset the flow state to its +; initial condition (none) with each shell invocation (and after each +; command is run, we reset the shell bit in the code after CALLPROG). +; In this case shells will run regardless of flow state, and residual +; conditionals from the last running of the shell are flushed. Each +; shell input sequence begins afresh. On the other hand, if SHELLIF is +; off, flow control commands inside a shell script must be flushed so +; that they do not interfere with user entered commands. +; b) Directory prefixes are ignored for flow commands, since all flow control +; processing must pass through the FCP (the command must run even when +; the current flow state is false). +; c) If the command is not found in the FCP, then the current flow state is +; tested. If it is false, the command is flushed and the code branches +; back to get the next command. +; d) If the command had a directory prefix (a colon alone is sufficient), +; then steps #2 and #3 are skipped over,and the command is processed +; immediately as a transient program. +; e) In ZCPR33, unlike ZCPR30, RCP commands are scanned before CPR commands. +; This has been done so that more powerful RCP commands can supercede +; CPR commands. +; f) If the SKIPPATH option is enabled, when an explicit directory is +; specified with a command (but not just a colon), searching of the path +; is bypassed. If the FASTECP option is enabled, commands with leading +; spaces are sent directly to the ECP for processing. +; g) If no external command can be found, ZCPR33 performs extensive error +; handling. If the command error occurred while looking for a shell +; program, then the shell stack is popped. Otherwise, ZCPR33 tries to +; invoke an external, user-specified error handling command line. If +; none was specified or if the error handler invoked by that command +; line cannot be found, the internal error message (step #6) is displayed. + + +;----------------------------------------------------------------------------- + +runcmd: + if shellif ; If shells reininitialize flow control... + ld a,(cmdstatfl) ; Get command status flag + bit 0,a ; Shell bit set? + jr z,fcpcmd ; If not a shell, process command + xor a ; Otherwise, shell is running, so + ld (ifptrfl),a ; ..reinitialize the IF system and continue + endif ;shellif + + +; ---------- Module <<1>>: Flow Control Processing + +; An option is supported here to allow the address of the FCP to be obtained +; from the environment descriptor. This is logically consistent with the +; pholosopy of the Z-System and is useful when one wants to have a single block +; of FCP/RCP memory that can be allocated dynamically between FCP and RCP +; functions. + +fcpcmd: + + if fcp ne 0 ; Omit code if FCP not implemented + + if fcpenv ; If getting FCP address from Z3ENV + + ld e,12h ; Offset in Z3ENV to FCP address + call pkgoff ; Set HL to FCP+5 + jr z,runcmd1 ; Skip if no FCP present + + else ; using fixed FCP address + + ld hl,fcp+5 ; Get address from Z3BASE.LIB + + endif ;fcpenv + + +; If flow control processing is not allowed in shell aliases (scripts running +; as shell commands), then we have to make sure that we flush any flow control +; commmands, otherwise the CPR will attempt to execute them as transients, +; with dire consequences. In the code below we check the shell bit. If it +; is not set, we proceed normally. If it is set, we scan for flow commands +; and then jump past the flow testing to RUNFCP2, where the code will flush +; the command if it was a flow command and execute it unconditionally if not. + + if not shellif + ld a,(cmdstatfl) ; Get command status flag + bit 0,a ; If shell bit not set, + jr z,runfcp1 ; ..we do normal processing + call cmdscan ; Otherwise, check for flow command + jr runfcp2 ; ..and flush if so using code below + endif ;not shellif + +runfcp1: + call cmdscan ; Scan command table in the module + jr z,callprog ; Run if found (with no leading CRLF) + +; This is where we test the current IF state. If it is false, we skip this +; command. + + call iftest ; Check current IF status + +runfcp2: ; If false, skip this command and go on to next + if drvprefix ; If DRVPREFIX we can use code below + jr z,jpnextcmd ; ..to save a byte + else ; Otherwise, we have to do an + jp z,nextcmd ; ..absolute jump + endif ;drvprefix + + endif ;fcp ne 0 + + +runcmd1: + if fastecp or badduecp + ld a,(firstchar) ; If FIRSTCHAR flag set for ECP invocation, + cp ' ' ; ..then go straight to transient processing + jr z,com + endif ;fastecp or badduecp + +colon equ $+1 ; Flag for in-the-code modification + ld a,0 ; If command had a directory prefix (even just + or a ; ..a colon) then skip over resident commands + jr nz,comdir + + +; ---------- Module <<2>>: RCP Processing + +; An option is supported here to allow the address of the RCP to be obtained +; from the environment descriptor. This is logically consistent with the +; pholosopy of the Z-System and is useful when one wants to have a single block +; of FCP/RCP memory that can be allocated dynamically between FCP and RCP +; functions. + + if rcp ne 0 ; Omit code if RCP not implemented + +rcpcmd: + + if rcpenv ; If getting address of rcp from Z3ENV + + ld e,0ch ; Offset in Z3ENV to RCP address + call pkgoff ; Set HL to address of RCP+5 + jr z,cprcmd ; Skip if no RCP + + else ; using fixed RCP address + + ld hl,rcp+5 ; Get address from Z3BASE.LIB + + endif ; rcpenv + + call cmdscan ; Check for command in RCP + jr z,callproglf ; If so, run it (with leading CRLF) + + endif ;rcp ne 0 + + +; ---------- Module <<3>>: CPR-Resident Command Processing + +cprcmd: + + ld hl,cmdtbl ; Point to CPR-resident command table + call cmdscan ; ..and scan for the command + jr z,callprog ; If found, run it (with no leading CRLF) + + + +; ---------- Module <<4>>: Transient Command Processing + +comdir: ; Test for DU: or DIR: only (directory change) + + if drvprefix + + ld a,(cmdfcb+1) ; Any command name? + cp ' ' + jr nz,com ; If so, must be transient or error + + ; Entry point for change of directory only + + if wdu ; If controlled by wheel.. + + ld a,(z3whl) ; Get wheel byte + or a ; If wheel on, go on ahead + jr nz,comdir1 + + if badduecp + ld (colon),a ; Pretend there is no colon + ld a,' ' ; Force invocation of ECP + ld (firstchar),a + jr com + else ;not badduecp + ld a,ecduchg + jr z,error + endif ;badduecp + + endif ; wdu + +comdir1: + ld hl,(tempusr) ; Get temporary drive and user bytes + + if not highuser ; If only users 0..15 can be logged + ld a,l ; Get user number and + cp 16 ; ..make sure not above 15 + jr nc,baddirerr ; If out of range, invoke error handling + endif ;not highuser + + dec h ; Shift drive to range 0..15 + ld (curusr),hl ; Make the temporary DU into the current DU + call logcurrent ; Log into the new current directory +jpnextcmd: + jp nextcmd ; Resume command line processing + + else ;not drvprefix + + if badduecp + xor a ; Pretend there is no colon + ld (colon),a + ld a,' ' ; Force invocation of ECP + ld (firstchar),a + else ;not badduecp + ld a,ecduchg + jr z,error + endif ;badduecp + + endif ;drvprefix + + +com: ; Process transient command + + ld a,(cmdstatfl) ; Check command status flag to see if + and 2 ; ..error handler is running + ld (zexinpfl),a ; Store result in ZEX control flag (2 will turn + ; ..ZEX input redirection off (0 = on) + if subon + ld (xsubflag),a ; Turn off XSUB input redirection also + endif ;subon + + ld hl,tpa ; Set default execution/load address + ld a,3 ; Dynamically load type-3 and above ENVs + call mload ; Load memory with file specified in cmd line + ld a,(cmdstatfl) ; Check command status flag to see if + and 100b ; ..ECP running (and suppress leading CRLF) + +; CALLPROG is the entry point for the execution of the loaded program. At +; alternate entry point CALLPROGLF if the zero flag is set, a CRLF is sent to +; the console before running the program. + +callproglf: + call z,crlf ; Leading new line + +callprog: + ; Copy command tail into TBUFF + +tailsv equ $+1 ; Pointer for in-the-code modification + ld hl,0 ; Address of first character of command tail + ld de,tbuff ; Point to TBUFF + push de ; Save pointer + ld bc,7e00h ; C=0 (byte counter) and B=7E (max bytes) + inc de ; Point to first char +tail: + ld a,(hl) ; Get character from tail + call tsteol ; Check for EOL + jr z,tail1 ; Jump if we are done + ld (de),a ; Put character into TBUFF + inc hl ; Advance pointers + inc de + inc c ; Increment character count + djnz tail ; If room for more characters, continue + call print ; Display overflow message + db bell ; ..ring bell + db 'Ovf','l'+80h ; ..then continue anyway +tail1: + xor a ; Store ending zero + ld (de),a + pop hl ; Get back pointer to character count byte + ld (hl),c ; Store the count + +; Run loaded transient program + + call defltdma ; Set DMA to 0080h standard value + +; Perform automatic installation of Z3 programs (unless type-2 environment) + + ld hl,(execadr) ; Get current execution address + call z3chk ; See if file is a Z3 program + jr nz,noinstall ; Branch if not + + cp 2 ; If type-2 (internal) environment + jr z,noinstall ; ..do not perform installation + + inc hl ; Advance to place for ENV address + ld (hl),low z3env ; Put in low byte of environment address + inc hl + ld (hl),high z3env ; Put in high byte + +noinstall: + +; Execution of the program occurs here by calling it as a subroutine + + ld hl,z3env ; Pass environment address to program in HL +execadr equ $+1 ; Pointer for in-line code modification + call 0 ; Call transient + +; Return from execution + + if shellif ; If flow processing allowed in shells... + ld hl,cmdstatfl ; Reset the shell bit in the command status + res 0,(hl) ; ..flag so multiple-command shells will work + endif ;shellif + + ; Continue command processing + if drvprefix ; If DRVPREFIX we can save a byte by + jr jpnextcmd ; ..doing a two-step relative jump + else ; Otherwise, we just have to do + jp nextcmd ; ..the absolute jump + endif ;drvprefix + + +; ---------- Module <<5>>: External Error Handler Processing + +baddirerr: + ld a,ecbaddir ; Error code for bad directory specification + +error: + +; If we are returning from an external command to process an error, we want +; to leave the error return code as it was set by the transient program. + + ld hl,cmdstatfl ; Point to command status flag + bit 3,(hl) ; Check transient error flag bit + jr nz,error1 ; If set, leave error code as set externally + ld (ecflag),a ; Otherwise, save error code from A register + +error1: + res 2,(hl) ; Reset the ECP bit to prevent recursion of + ; ..error handler by programs that don't + ; ..clear the bit + bit 0,(hl) ; Was error in attempting to run a shell? + jr nz,errsh ; If so, pop shell stack + +; The following code is included to avoid a catastrophic infinite loop when +; the external error handler cannot be found. After one unsuccessful try, +; the internal code is invoked. + + bit 1,(hl) ; Was an error handler already called? + jr nz,errintrnl ; If so, use internal error handler + +; If the current IF state is false, we would like to ignore the error and just +; go on with the next command. Unfortunately, for some errors (e.g., a bad +; command format such as a command with a wildcard character) the error handler +; is invoked before the pointer in the multiple command line buffer is set up +; to the next command. In that case, we fall into an infinite loop. We also +; must not allow the external error handler to run, since it will not run and +; we will again fall into an infinite loop. The present code is not so bad, of +; course, since even a command in a false part of a command sequence should not +; have a true error in it. We have already put in code to bypass password +; checking during a false IF state, since a command with a password is not an +; invalid command. + + if fcp ne 0 + call iftest ; If we are in a false IF state, external + jr z,errintrnl ; ..handler will not run, so use built-in + endif ;fcp ne 0 + + set 1,(hl) ; Set command status flag for error invocation + ld hl,errcmd ; Point to error handler command line + ld a,(hl) ; Check first byte for presence of an + or a ; ..error command line + jr z,errintrnl ; If no error handler, use built-in one + ld (nxtchr),hl ; Else, use error command line as next command + jp nextcmd1 ; Run command without resetting status flag + + +; ---------- Module <<6>>: Resident Error Handler Code + +; If the error is with the invocation of a shell command, we pop the bad shell +; command off the stack to prevent recursion of the error. We then use the +; the internal error handler to echo the bad shell command. + +errsh: + + ld de,shstk ; Point to current entry in shell stack + ld hl,shstk+shsize ; Point to next entry in stack + ld bc,[shstks-1]*shsize ; Bytes to move + ldir ; Pop the stack + xor a ; Clear the last entry position + ld (de),a + +errintrnl: + if subon + call subkil ; Terminate active submit file if any + endif ;subon + + call crlf ; New line + ld hl,(cmdptr) ; Point to beginning of bad command + call printhl ; Echo it to console + call print ; Print '?' + defb '?'+80h + jp restart ; Restart CPR + +; End ZCPR33-2.Z80 + + page + +; ZCPR33-3.Z80 + +;============================================================================= +; +; C O M M A N D L I N E P A R S I N G C O D E +; +;============================================================================= + +; This code parses the command line pointed to by HL. The command verb is +; parsed, placing the requested program name into the command file control +; block. The drive and user bytes are set. If an explicit DU or DIR was +; given, the COLON flag is set so that the processor knows about this later +; when the command search path is built. + +parser: + + ld de,cmdfcb ; Point to the command FCB + push de + call initfcb ; Initialize the FCB + pop de + ld (duerrflag),a ; Store zero (INITFCB ends with A=0) into flag + call scanner ; Parse first token on command line into FCB + jr nz,badcmd ; Invoke error handler if '?' in command + +duerrflag equ $+1 ; Pointer for in-the-code modification + ld a,0 ; See if bad DU/DIR specified with command verb + or a + + if badduecp + jr z,parser1 ; If DU/DIR is OK, skip ahead + ld a,(cmdstatfl) ; If ECP already running + bit 2,a ; ..skip ahead + jr nz,parser1 + ld a,(cmdfcb+1) ; If not a directory change command + sub ' ' ; ..invoke error handler + jr nz,baddirerr + ; If bad directory change attempt, + ld (tmpcolon),a ; ..pretend there is no colon (A=0) + ld a,' ' ; ..and force immediate ECP invocation + ld (firstchar),a ; ..when command is processed + else ; If errors not processed by ECP then + jr nz,baddirerr ; ..invoke error handler + endif ; badduecp + +parser1: + ld de,cmdfcb+9 ; Make sure no explicit file type was given + ld a,(de) ; Get first character of file type + cp ' ' ; Must be blank +badcmd: + ld a,ecbadcmd ; Error code for illegal command form + jr nz,error ; If not, invoke error handler + + push hl ; Save pointer to next byte of command + ld hl,commsg ; Place default file type (COM) into FCB + ld bc,3 + ldir + pop hl ; Get command line pointer back + +; The following block of code is arranged so that the COLON flag is set only +; when an explicit directory specification is detected in the command verb. +; Other parses also change the TMPCOLON flag, but only when passing here does +; the flag get transferred to COLON. + +tmpcolon equ $+1 ; Pointer for in-the-code modification + ld a,0 ; ..by SCANNER routine + ld (colon),a ; If explicit DU/DIR, set COLON flag + +; Find the end of this command and set up the pointer to the next command. + + push hl ; Save command line pointer + dec hl ; Adjust for preincrementing below +parser2: ; Find end of this command + inc hl ; Point to next character + ld a,(hl) ; ..and get it + call tsteol ; Test for end of command + jr nz,parser2 ; Keep looping if not + + ld (nxtchr),hl ; Set pointer to next command + pop hl ; Get back pointer to current command tail + +; This block of code parses two tokens in the command line into the two +; default FCBs at 5Ch and 6Ch. It also sets a pointer to the command tail +; for later copying into the command tail buffer at 80h. This code is used +; first when attempting to parse a normal command line and possibly again +; later when the entire user's command is treated as a tail to the extended +; command processor. The resident JUMP and SAVE commands use it also, and +; the entry point is available at location CCP+9 for use by other programs. + +parsetail: + ld (tailsv),hl ; Save pointer to command tail + + ; Process first token + + ld de,tfcb ; Point to first default FCB + push de ; Save pointer while initializing + call initfcb ; Initialize both default FCBs + pop de + call sksp ; Skip over spaces in command line + call nz,scanner ; If not end of line, parse the token + ; ..into first FCB + ld (parseptr),hl ; Save pointer to second token for reparsing + + ; Process second token + + call sksp ; Skip over spaces + ret z ; Done if end of line or end of command + ld de,tfcb2 ; Point to second default FCB + ; ..and fall through to SCANNER routine + +;----------------------------------------------------------------------------- + +; This routine processes a command line token pointed to by HL. It attempts +; to interpret the token according to the form [DU:|DIR:]NAME.TYP and places +; the corresponding values into the FCB pointed to by DE. On exit, HL points +; to the delimiter encountered at the end of the token. The Z flag is set if +; a wild card was detected in the token. + +scanner: + xor a ; Initialize various flags + ld (tmpcolon),a ; Set no colon + ld bc,(curusr) ; Get current drive and user into BC + inc b ; Shift drive range from 0..15 to 1..16 + ld (tempusr),bc ; Initialize temporary DU + + call scanfld8 ; Extract possible file name + cp ':' ; Was terminating character a colon? + jr nz,scantype ; If not, go on to extract file type + ld (tmpcolon),a ; Otherwise, set colon and process DU/DIR + inc hl ; Point to character after colon + +; Code for resolving directory specifications (macro RESOLVE is defined in +; Z33MAC.LIB). RESOLVE returns with a nonzero value and a NZ flag setting +; if the DU/DIR specification cannot be resolved. There are quite a few +; possibilities here. + + ; Case where both forms are accepted + + if accptdir and accptdu + if dufirst + resolve du,dir ; Check DU: form before DIR: form + else + resolve dir,du ; Check DIR: form before DU: form + endif ;dufirst + endif ;accptdir and accptdu + + ; Cases of only one form accepted + + if accptdu and not accptdir + resolve du, ; Check only DU: form + endif ;accptdu and not accptdir + + if accptdir and not accptdu + resolve dir, ; Check only DIR: form + endif ;accptdir and not accptdu + + ; Case of neither form accepted + + if not accptdir and not accptdu + push hl ; Save pointer to command string + inc de ; Point to first character of name + ld a,(de) ; Get it + dec de ; Restore the pointer + sub ' ' ; If no name is there, A=0 and Z flag set + endif ;not accptdir and not accptdu + + push de ; Save pointer to FCB again + push af ; Save bad directory flag + ld a,(tempdr) ; Set designated drive + ld (de),a ; ..into FCB + inc de ; Point to file name field + call ifcb ; Perform partial init (set user code) + pop af ; Get bad directory flag back + ld (duerrflag),a ; Save flag in parser code + jr z,scanner1 ; Branch if valid directory specified + dec de ; Back up to record count byte + dec de + ld (de),a ; Store error flag there (NZ if error) +scanner1: + pop de ; Get FCB pointer back + pop hl ; Restore pointer to command string + call scanfld8 ; Scan for file name + +; This code processes the file type specification in the token + +scantype: + ld a,(hl) ; Get ending character of file name field + ex de,hl ; Switch FCB pointer into HL + ld bc,8 ; Offset to file type field + add hl,bc + ex de,hl ; Switch pointers back + + ld b,3 ; Maximum characters in file type + cp '.' ; See if file type specified + jr nz,scantype2 ; If not, skip over file type parsing + + inc hl ; Point to character after '.' + push de ; Save pointer to FCB file type + call scanfield ; Parse file type into FCB + pop de + +scantype2: + ex de,hl ; Swap pointers again + ld bc,5 ; Offset from file type to S1 field in FCB + add hl,bc + ex de,hl ; Swap pointers back + ld a,(tempusr) ; Get specified user number + ld (de),a ; ..and store in S1 byte of FCB + +scan3: ; Skip to space character, character after an + ; ..equal sign, or to end of command + ld a,(hl) ; Get next character + cp ' '+1 ; Done if less than space + jr c,scan4 + call tsteol ; Done if end of line or end of command + jr z,scan4 + inc hl ; Skip on to next character + cp '=' ; If not equal sign + jr nz,scan3 ; ..keep scanning + +scan4: ; Set zero flag if '?' in filename.typ + +qmcnt equ $+1 ; Pointer for in-the-code modification + ld a,0 ; Number of question marks + or a ; Set zero flag + ret + +; This routine invokes SCANFIELD for a file name field. It initializes the +; question mark count and preserves the FCB pointer. + +scanfld8: + xor a ; Initialize question mark count + ld (qmcnt),a + push de ; Save pointer to FCB + ld b,8 ; Scan up to 8 characters + call scanfield + pop de ; Restore pointer to FCB + ret + +; This routine scans a command-line token pointed to by HL for a field whose +; maximum length is given by the contents of the B register. The result is +; placed into the FCB buffer pointed to by DE. The FCB must have had its name +; and type fields initialized before this routine is called. Wild cards of +; '?' and '*' are expanded. On exit, HL points to the terminating delimiter. + +scanfield: + call sdelm ; Done if delimiter encountered + ret z + inc de ; Point to next byte in FCB + cp '*' ; Is character a wild card? + jr nz,scanfld1 ; Continue if not + + ld a,'?' ; Process '*' by filling with '?'s + ld (de),a + call qcountinc ; Increment count of question marks + jr scanfld2 ; Skip so HL pointer left on '*' + +scanfld1: ; Not wildcard character '*' + ld (de),a ; Store character in FCB + inc hl ; Point to next character in command line + cp '?' ; Check for question mark (wild) + call z,qcountinc ; Increment question mark count +scanfld2: + djnz scanfield ; Decrement char count until limit reached +scanfld3: + call sdelm ; Skip until delimiter + ret z ; Zero flag set if delimiter found + inc hl ; Pt to next char in command line + jr scanfld3 + + +; Subroutine to increment the count of question mark characters in the +; parsed file name. + +qcountinc: + push hl + ld hl,qmcnt ; Point to count + inc (hl) ; Increment it + pop hl + ret + +;----------------------------------------------------------------------------- + +; Validate the password pointed to by HL. Prompt user for password entry +; and return zero if it is correct. + + if pwcheck + +passck: + push hl ; Save pointer to password + call print ; Prompt user + defb cr,lf,'PW?',' '+80h + ld hl,pwlin ; Set up buffer for user input + ld bc,90ah ; Set 0ah (BDOS readln function) in C + ld (hl),b ; ..and 9 (max character count) in B + ex de,hl ; Switch buffer pointer to DE + + if pwnoecho + ld a,0c9h ; Disable BIOS conout routine to + ld (bios+0ch),a ; ..suppress password echoing + call bdossave ; Get user input + ld a,0c3h ; Reenable BIOS conout routine + ld (bios+0ch),a + else ;not pwnoecho + call bdossave ; Get user input + endif ;pwnoecho + + ex de,hl ; Restore pointer to HL + inc hl ; Point to count of characters entered + ld a,(hl) ; Get character count + inc hl ; Point to first character + push hl ; Save pointer while marking end of input + call addah ; Advance HL to just past last character + ld (hl),' ' ; Place space there + pop de ; Restore pointer to beginning of user input + pop hl ; Restore pointer to password from NDR + ld b,8 ; Maximum characters to compare +pwck: + ld a,(de) ; Get next user character + call ucase ; Capitalize it + cp (hl) ; Compare to NDR + ret nz ; No match + cp ' ' ; If last user character matched space in + ret z ; ..NDR, then we have a complete match + inc hl ; If not done, point to next characters + inc de + djnz pwck ; (flags not affected by DJNZ) + xor a ; Set zero flag and + ret ; ..return Z to show success + + endif ; pwcheck + +;----------------------------------------------------------------------------- + +; This code attempts to interpret the token in the FCB pointed to by register +; pair DE as a DIR (named directory) prefix. If it is successful, the drive +; and user values are stored in TEMPDR and TEMPUSR, the zero flag is set, and +; a value of zero is returned in register A. +; +; If the named directory is found to be password restricted, then the user is +; asked for the password (unless the directory is the one currently logged or +; the current IF state is false). If an incorrect password is entered, the +; error handler is generally invoked directly. The exception to this is when +; the transient program bit is set in the command status flag (this bit would +; be set by a non-CPR program that calls REPARSE). In this case the default +; directory is returned, the zero flag is reset, and a nonzero value in +; returned in register A to show a bad directory. In addition, the code in +; SCANNER will set record-count byte in the FCB to a nonzero value so that +; the calling program can detect the error. [Note: if DU processing is also +; allowed and it follows DIR processing, DUSCAN will also be called. Unless +; there is a passworded directory with a DU form, this will cause no trouble.] + + if accptdir + +dirscan: + +; If the DU form is not allowed, we have to detect a colon-only condition here. +; Otherwise DUSCAN will take care of it. + + inc de ; Point to first byte of directory form + + if not accptdu + ld a,(de) ; Get first character of directory + sub ' ' ; If it is a blank space + ret z ; ..we have a successful directory resolution + endif ;not accptdu + + ex de,hl ; Switch pointer to FCB to HL + + if ndrenv ; If getting NDR address for Z3ENV + ld e,15h ; Offset to NDR address + push hl ; Preserve pointer to FCB + call pkgoff ; Get NDR address from ENV into DE + pop hl + jr z,direrr ; Branch if no NDR implemented + else ; using fixed address of NDR buffer + ld de,z3ndir ; Point to first entry in NDR + endif ; ndrenv + +dirscan1: + ld a,(de) ; Get next character + or a ; Zero if end of NDR + jr z,direrr + inc de ; Point to name of directory + inc de + push hl ; Save pointer to name we are looking for + push de ; Save pointer to NDR entry + ld b,8 ; Number of characters to compare + +dirscan2: + ld a,(de) + cp (hl) + jr nz,dirscan3 ; If no match, quit and go on to next DIR + inc hl ; Point to next characters to compare + inc de + djnz dirscan2 ; Count down + +dirscan3: + pop de ; Restore pointers + pop hl + jr z,dirscan4 ; Branch if we have good match + + ex de,hl ; Advance to next entry in NDR + ld bc,16 ; 8 bytes for name + 8 bytes for password + add hl,bc + ex de,hl + jr dirscan1 ; Continue comparing + +; If ACCPTDU is enabled, we can share similar code in DUSCAN and do not need +; the code here. + + if not accptdu +direrr: ; No match found + dec a + ret + endif ;not accptdu + +dirscan4: ; Match found + ex de,hl ; Switch pointer to NDR entry into HL + push hl ; ..and save it for later + dec hl ; Point to user corresponding to the DIR + ld c,(hl) ; Get user value into C + dec hl ; Point to drive + ld b,(hl) ; Get it into B + + if pwcheck + + ld hl,(curusr) ; Get current drive/user into HL + inc h ; Shift drive to range 1..16 + xor a ; Clear carry flag + sbc hl,bc ; Compare + pop hl ; Restore pointer to NDR entry + jr z,setdu ; If same, accept values without PW checking + +; If WPASS is set, then password checking is bypassed when the wheel byte is +; set. + + if wpass + ld a,(z3whl) ; Get wheel byte + or a ; If wheel byte set + jr nz,setdu ; ..skip checking passwords + endif ;wpass + +; This code is a bit tricky. We do not want to be asked for passwords for +; named directory references in commands when the current IF state is false. +; So, first we check to see if there is a password on the directory. If not, +; we proceed to set the temporary DU to the specified directory. If there is +; a password, we check the current IF state. If it is false, we do not check +; passwords and pretend there was no password. However, we leave the current +; directory in effect. This will work properly in all but one rare +; circumstance. When the command is an 'OR' command with a reference to a +; passworded named directory (e.g., "OR EXIST SECRET:FN.FT"), the password +; will not be requested and the current directory will be used instead of the +; specified one. + + push bc ; Save requested drive/user + ld bc,8 ; Point to password in NDR + add hl,bc + ld a,(hl) ; Get first character of password + cp ' ' ; Is there a password? + + if fcp eq 0 ; If FCP not implemented ... + + call nz,passck ; Perform password checking if pw present + + else ;fcp ne 0 ; FCP implemented ... + + jr z,dirscan5 ; If no pw, skip ahead + call iftest ; Otherwise, test current IF state + pop bc ; Restore BC in case we return now + ret z ; If false IF in effect, fake success without + ; ..checking password (but TEMPDR/TEMPUSR not + ; ..set) + push bc ; Otherwise, save BC again + call passck ; Perform password checking + + endif ;fcp eq 0 + +dirscan5: + pop bc ; Restore requested drive/user + jr z,setdu ; If not bad password, set it up + ld a,(cmdstatfl) ; See if external invocation (disable + bit 3,a ; ..error handling if so) + ret nz ; Return NZ to show bad directory + ld a,ecbadpass ; Error code for bad password + jp error + + else ;not pwcheck + + pop hl ; Clean up stack + if accptdu ; If we cannot fall through, branch + jr setdu + endif ;accptdu + + endif ;pwcheck + + if not accptdu ; If NOT ACCPTDU, we have to supply code here +setdu: + ld (tempusr),bc + xor a ; Set Z to flag success + ret + endif ;not accptdu + + endif ;accptdir + +;----------------------------------------------------------------------------- + +; This code attempts to interpret the token in the FCB pointed to by register +; pair DE as a DU (drive/user) prefix. If it is successful, the drive and +; user values are stored in TEMPDR and TEMPUSR, the zero flag is set, and a +; value of zero is returned in register A. Otherwise the zero flag is reset +; and a nonzero value is returned in register A. +; +; The ADUENV option allows acceptance of the DU form to be controlled by the +; DUOK flag in the environment descriptor. An additional feature of this code +; when the ADUENV option is enabled is that a DU value is always accepted, +; even if DUOK is off and even if it is outside the normally allowed range, +; if it corresponds to a named directory with no password. The currently +; logged directory is unconditionally acceptable (if you got there once, you +; can stay as long as you like without further hassles). + + if accptdu ; Allow DU: form + +direrr: ; This code may do double duty for DIRSCAN + ; ..above +duerr: + xor a ; Return NZ to show failure + dec a + ret + +duscan: + ex de,hl ; Switch FCB pointer to HL + inc hl ; Point to first byte of file name in FCB + + ld bc,(curusr) ; Preset C to current user, B to current drive + ld a,(hl) ; Get possible drive specification + sub 'A' ; Otherwise convert to number 0..15 + jr c,duscan1 ; If < 0, leave B as is + cp 16 + jr nc,duscan1 ; If > 15, leave B as is + ld b,a ; Otherwise use value given + inc hl ; ..and point to next character + +duscan1: + inc b ; Shift drive to range 1..16 + ld a,(hl) ; Get possible user specification + cp ' ' + jr z,duscan2 ; If none present, leave C as is + push bc ; Save DU values in BC + call decimal1 ; Get specified decimal user number into BC + pop hl ; Restore values to HL + jr c,duerr ; Return NZ if invalid decimal conversion + ld a,b ; Get high byte of result + or a ; Make sure it is zero + ret nz ; If not, return NZ to show bad user number + ld b,h ; DU value is now in BC + +; If the specified directory is the currently logged directory, accept it +; even if it is out of range and/or password protected. + +duscan2: + ld hl,(curusr) ; Get current drive/user into HL + inc h ; Shift drive to range 1..16 + xor a ; Clear carry flag + sbc hl,bc ; Compare values + jr z,setdu + +; If the specified DU corresponds to a named directory with no password, or +; if WPASS is enabled so that password checking is not performed when the +; wheel byte is set, then accept it. + + if z3ndir ne 0 + + call du2dir ; See if there is a matching named directory + jr z,duscan3 ; If not, skip on + + if pwcheck ; If passwords are being checked... + + if wpass + ld a,(z3whl) ; Get wheel byte + or a ; If wheel byte set, skip checking passwords + jr nz,setdu ; ..and accept the DU values + endif ;wpass + + ld de,9 ; Advance to password + add hl,de + ld a,(hl) ; Get first character of password + cp ' ' + jr z,setdu ; If none, we have a valid DU + + else ;not pwcheck + + jr setdu ; Set the DU + + endif ;pwcheck + + endif ;z3ndir ne 0 + +duscan3: + if aduenv ; Check DUOK flag in ENV + ld a,(duokfl) ; Get flag + or a ; If DU not accepted + jr z,duerr ; ..skip over the DU scan + endif ;aduenv + + if duenv ; If getting max drive and user from ENV + ld hl,(maxdrenv) ; Get max drive into L and max user into H + ld a,l ; Test drive value + cp b + jr c,duerr + ld a,h ; Test user value + cp c + jr c,duerr + else ; Using fixed values of max DU + ld a,maxdisk + cp b + jr c,duerr + ld a,maxusr + cp c + jr c,duerr + endif ;duenv + +setdu: + ld (tempusr),bc + xor a ; Set Z to flag success + ret + + endif ; accptdu + +; End ZCPR33-3.Z80 + + page + +; ZCPR33-4.Z80 + +;============================================================================= +; +; G E N E R A L S U B R O U T I N E S S E C T I O N +; +;============================================================================= + + +;----------------------------------------------------------------------------- +; +; CHARACTER I/O BDOS ROUTINES +; +;----------------------------------------------------------------------------- + +; Get uppercase character from console (with ^S processing). Registers B, +; D, H, and L are preserved. The character is returned in A. + +conin: + ld c,1 ; BDOS conin function + call bdossave + ; Fall through to UCASE + +;-------------------- + +; Convert character in A to upper case. All registers except A are preserved. + +ucase: + and 7fh ; Mask out msb + cp 61h ; Less than lower-case 'a'? + ret c ; If so, return + cp 7bh ; Greater than lower-case 'z'? + ret nc ; If so, return + and 5fh ; Otherwise capitalize + ret + +;---------------------------------------- + +; Output CRLF + +crlf: + call print + db cr + db lf or 80h + ret + +;---------------------------------------- + +; Output character in A to the console. All registers are preserved. + +conout: + push de + push bc + ld c,2 ; BDOS conout function +output: ; Entry point for LCOUT below + ld e,a + call bdossave + pop bc + pop de + ret + +;---------------------------------------- + +; Print the character string immediately following the call to this routine. +; The string terminates with a character whose high bit is set or with a null. +; At entry point PRINTC the string is automatically preceded by a +; carriage-return-linefeed sequence. All registers are preserved except A. + +printc: + call crlf ; New line + +print: + ex (sp),hl ; Get pointer to string + call printhl ; Print string + ex (sp),hl ; Restore HL and set return address + ret + +;---------------------------------------- + +; Print the character string pointed to by HL. Terminate on character with +; the high bit set or on a null character. On return HL points to the byte +; after the last character displayed. All other registers except A are +; preserved. + +printhl: + ld a,(hl) ; Get a character + inc hl ; Point to next byte + or a ; End of string null? + ret z + push af ; Save flags + and 7fh ; Mask out msb + call conout ; Print character + pop af ; Get flags + ret m ; String terminated by msb set + jr printhl + + +;----------------------------------------------------------------------------- +; +; FILE I/O BDOS ROUTINES +; +;----------------------------------------------------------------------------- + +; Read a record from a file to be listed or typed + + if lton ; Only needed for LIST and TYPE functions + +readf: + ld de,tfcb + jr read + + endif ; lton + +;---------------------------------------- + +; Read a record from the command file named in CMDFCB + +readcmd: + ld de,cmdfcb + +; Read a record from file whose FCB is pointed to by DE + +read: + ld c,14h ; Read-sequential function + ; Fall through to BDOSSAVE + +;-------------------- + +; Call BDOS for read and write operations. The flags are set appropriately. +; The BC, DE, and HL registers are preserved. + +bdossave: + putreg + call bdos + getreg + or a ; Set flags +note: ; This return is used for NOTE command, too + ret + + +;----------------------------------------------------------------------------- +; +; MISCELLANEOUS BDOS ROUTINES +; +;----------------------------------------------------------------------------- + +; Set DMA address. At the entry point DEFLTDMA the address is set to the +; default value of 80H. At the entry point DMASET it is set to the value +; passed in the DE registers. + +defltdma: + ld de,tbuff +dmaset: + ld c,1ah + jr bdossave + +;---------------------------------------- + +; Log in the drive value passed in the A register (A=0). + +setdrive: + ld e,a + ld c,0eh + jr bdossave + +;---------------------------------------- + +; Open a file. At entry point OPENCMD the file is the one specified in +; CMDFCB, and the current record is set to zero. At entry point OPEN +; the file whose FCB is pointed to by DE is used. + +opencmd: + xor a ; Set current record to 0 + ld (cmdfcb+32),a + ld de,cmdfcb ; Command file control block + ; Fall through to open + +open: + ld c,0fh ; BDOS open function + ; Fall through to BDOSTEST + +;-------------------- + +; Invoke BDOS for disk functions. This routine increments the return code in +; register A so that the zero flag is set if there was an error. Registers +; BC, DE, and HL are preserved. + +bdostest: + call bdossave + inc a ; Set zero flag for error return + ret + +;---------------------------------------- + +; Close file whose FCB is pointed to by DE. + + if saveon or subon +close: + ld c,10h + jr bdostest + endif ;saveon or subon + +;---------------------------------------- + +; Search for first matching file. At entry point SRCHFST1 the first default FCB +; is used. At entry point SRCHFST the FCB pointed to by DE is used. + + if diron or eraon or renon or saveon +srchfst1: + ld de,tfcb ; Use first default FCB + endif ;diron or eraon or renon or saveon + +srchfst: + ld c,11h + jr bdostest + +;----------------------------------------------------------------------------- + +; Search for next matching file whose FCB is pointed to by DE. + + if diron or eraon ; Only needed by DIR and ERA functions +srchnxt: + ld c,12h + jr bdostest + endif ; diron or eraon + +;----------------------------------------------------------------------------- + +; Kill any submit file that is executing. + + if subon + +subkil: + ld hl,subflag ; Check for submit file in execution + ld a,(hl) + or a ; 0=no + ret z ; If none executing, return now + ; Kill submit file + xor a + ld (hl),a ; Zero submit flag + call setuser ; Log in user 0 + ld de,subfcb ; Delete submit file + ; ..by falling through to delete routine + + endif ; subon + +;-------------------- + +; Delete file whose FCB is pointed to by DE. + + if eraon or renon or saveon or subon +delete: + ld c,13h + jr bdossave + endif ;eraon or renon or saveon or subon + +;----------------------------------------------------------------------------- + +; Get and set user number. Registers B, D, H, and L are preserved. Register +; E is also preserved at entry point SETUSER1. + +getuser: + ld a,0ffh ; Get current user number +setuser: + ld e,a ; User number in E +setuser1: + ld c,20h ; Get/Set BDOS function + jr bdossave + + +;----------------------------------------------------------------------------- +; +; GENERAL UTILITY ROUTINES +; +;----------------------------------------------------------------------------- + + +; This subroutine checks to see if a program loaded at an address given by HL +; has a Z3ENV header. If the header is not present, the zero flag is reset. +; If it is present, the zero flag is set, and on return HL points to the +; environment-type byte and A contains that byte. + +z3chk: + ld de,z3env+3 ; Point to 'Z3ENV' string in ENV + inc hl ; Advance three bytes to possible program + inc hl ; ..header + inc hl + ld b,5 ; Characters to compare +z3chk1: ; Check for Z3 ID header + ld a,(de) ; Get character from ENV descriptor + cp (hl) ; Compare it to loaded file + ret nz ; Quit now if mismatch + inc hl ; If same, advance to next characters + inc de ; ..and continue comparing + djnz z3chk1 ; (flags not affected by DJNZ) + ld a,(hl) ; Return the environment type in A + ret ; Return Z if all 5 characters match + +;---------------------------------------- + +; Subroutine to skip over spaces in the buffer pointed to by HL. On return, +; the zero flag is set if we encountered the end of the line or a command +; separator character. + +sksp: + ld a,(hl) ; Get next character + inc hl ; Point to the following character + cp ' ' ; Space? + jr z,sksp ; If so, keep skipping + dec hl ; Back up to non-space + ; ..and fall through + +;-------------------- + +; Subroutine to check if character is the command separator or marks the end +; of the line. + +tsteol: + or a ; End of command line? + ret z ; Return with zero flag set + cp cmdsep ; Command separator? + ret ; Return with flag set appropriately + +;---------------------------------------- + +; Initialize complete FCB pointed to by DE + +initfcb: + xor a + ld (de),a ; Set default disk (dn byte is 0) + inc de ; Point to file name field + call ifcb ; Fill 1st part of FCB + ; Fall through to IFCB to run again + +;-------------------- + +; Initialize part of FCB whose file name field is pointed to by DE on entry. +; The file name and type are set to space characters; the EX, S2, RC, and the +; following CR (current record ) or DN (disk number) fields are set to zero. +; The S1 byte is set to the current user number. On exit, DE points to the +; byte at offset 17 in the FCB (two bytes past the record count byte). + +ifcb: + ld b,11 ; Store 11 spaces for file name and type + ld a,' ' + call fill + xor a + ld (de),a ; Set extent byte to zero + inc de + ld a,(curusr) + ld (de),a ; Set S1 byte to current user + inc de + ld b,3 ; Store 3 zeroes + xor a ; Fall thru to fill + +;-------------------- + +; Fill memory pointed to by DE with character in A for B bytes + +fill: + ld (de),a ; Fill with byte in A + inc de ; Point to next + djnz fill + ret + +;---------------------------------------- + +; Subroutine to display the 'no file' error message for the built-in +; commands DIR, ERA, LIST, TYPE, and/or REN. + + if diron or eraon + +prnnf: + call printc ; No file message + defb 'No Fil','e'+80h + ret + endif ; diron or eraon + +;---------------------------------------- + +; Calculate address of command table in package from Z3ENV. On entry, E +; contains the offset to the address of the package in the environment. On +; exit, DE points to the beginning of the package and HL points to the fifth +; byte (where the command table starts in the RCP and FCP modules). The zero +; flag is set on return if the package is not supported. + + if fcpenv or rcpenv or ndrenv +pkgoff: + ld hl,z3env ; Point to beginning of ENV descriptor + ld d,0 ; Make DE have offset + add hl,de ; ..and add it + ld a,(hl) ; Get low byte of package address + inc hl ; Point to high byte + ld h,(hl) ; ..and get it + ld l,a ; Move full address into HL + or h ; Set zero flag if no package + ld de,5 ; Offset to start of table + ex de,hl ; Preserve start address of package in DE + add hl,de ; Pointer to 5th byte of package in HL + ret ; Return with zero flag set appropriately + + endif ;fcpenv or rcpenv or ndrenv + +;---------------------------------------- + +; This subroutine checks to see if we are in a false IF state. If that is +; the case, the routine returns with the zero flag set. If there is not active +; IF state or if it is true, then the zero flag is reset. + + if fcp ne 0 ; Omit code if FCP not implemented + +iftest: + ld bc,(ifptrfl) ; Current IF pointer into C, IF status into B + ld a,c ; See if any IF in effect + or a + jr z,iftest1 ; Branch if no IF state is active + and b ; Mask the current IF status + ret +iftest1: + dec a ; Reset the zero flag + ret + + endif ;fcp ne 0 + +;---------------------------------------- + +; Print the command prompt with DU and/or DIR (but without any trailing +; character). This is also the code in which the current drive and user +; will be stored. The conditional assemblies are somewhat involved because +; of the possibilities of either or both of the DU or DIR forms being omitted +; from the prompt. + +prompt: + call crlf + + if incldu ; If drive/user in prompt + + ld hl,(curusr) ; Get current drive/user into HL + +; If INCLENV is enabled, the drive and user (DU) will be included in the +; prompt based on the state of the DUOK flag in the environment. If INCLENV +; is disabled, the DU form will always be included if INCLDU is on. + + if inclenv + ld a,(duokfl) ; If ENV disallows DU, + or a ; ..then don't show it in + jr z,prompt2 ; ..the prompt, either + endif ;inclenv + + ld a,h ; Get current drive + add a,'A' ; Convert to ascii A-P + call conout + ld a,l ; Get current user + + if supres ; If suppressing user # report for user 0 + or a + jr z,prompt2 + endif + + cp 10 ; User < 10? + jr c,prompt1 + + if highuser ; If allowing users 16..31 + + ld c,'0'-1 +prompt0: + inc c + sub 10 + jr nc,prompt0 + add a,10 + ld b,a + ld a,c + call conout + ld a,b + + else ;using only standard user numbers 0..15 + + sub 10 ; Subtract 10 from user number + push af ; Save low digit + call print ; Display a '1' for tens digit + defb '1' or 80h + pop af + + endif ;highuser + +prompt1: + add a,'0' ; Output 1's digit (convert to ascii) + call conout +prompt2: + endif ; incldu + + ; Display named directory + + if incldir + + if incldu + ld b,h ; Copy drive/user from HL to BC + ld c,l ; ..(saves a byte) + else + ld bc,(curusr) ; Get current drive and user into BC + endif ;incldu + + inc b ; Switch drive to range 1..16 + call du2dir ; See if there is a corresponding DIR form + ret z ; If not, return now + + if incldu ; Separate DU and DIR with colon + + if inclenv + ld a,(duokfl) ; If not displaying DU, then + or a ; ..don't send separator, either + ld a,':' ; Make the separator + call nz,conout ; ..and send if permitted + else + call print ; Put in colon separator + defb ':' or 80h + endif ;inclenv + + endif ; incldu + + ld b,8 ; Max of 8 chars in DIR name +prompt3: + inc hl ; Point to next character in DIR name + ld a,(hl) ; ..and get it + cp ' ' ; Done if space + ret z + call conout ; Print character + djnz prompt3 ; Count down + + endif ; incldir + + ret + +;----------------------------------------------------------------------------- + +; Subroutine to convert DU value in BC into pointer to a matching entry in +; the NDR. If there is no match, the routine returns with the zero flag set. +; If a match is found, the zero flag is reset, and the code returns with HL +; pointing to the byte before the directory name. + + if z3ndir ne 0 + +du2dir: + + if ndrenv ; If getting NDR address from environment + ld e,15h ; Offset to NDR in Z3ENV + call pkgoff ; Get address of NDR into DE + ex de,hl ; ..and switch into HL + ret z ; If no NDR, return with zero flag set + jr du2dir2 + else + ld hl,z3ndir-17 ; Scan directory for match + endif ;ndrenv + +du2dir1: ; Advance to next entry in NDR + ld de,16+1 ; Skip user (1 byte) and name/pw (16 bytes) + add hl,de + +du2dir2: + ld a,(hl) ; End of NDR? + or a + ret z ; If so, return with zero flag set + + inc hl ; Point to user number in NDR entry + cp b ; Compare drive values + jr nz,du2dir1 ; If mismatch, back for another try + ld a,(hl) ; Get user number + sub c ; ..and compare + jr nz,du2dir1 ; If mismatch, back for another try + dec a ; Force NZ to show successful match + ret + + endif ;z3ndir ne 0 + +;----------------------------------------------------------------------------- + +; This routine gets the next line of input for the command buffer. The +; following order of priority is followed: +; If ZEX is active, the next line is obtained from ZEX +; If a submit file is running, its last record provides the input +; If there is a command line on the shell stack, use it +; Finally, if none of the above, the input is obtained from the user + +readbuf: + + ld a,(zexrunfl) ; Get ZEX-running flag + or a + jr nz,userinput ; If ZEX running, go directly to user input + + if subon ; If submit facility is enabled, check for it + + ld a,(subflag) ; Test for submit file running + or a + jr z,shellinput ; If not, go on to possible shell input + + xor a ; Log into user 0 + call setuser + call defltdma ; Initialize DMA pointer + ld de,subfcb ; Point to submit file FCB + call open ; Try to open file + jr z,readbuf1 ; Branch if open failed + + ld hl,subfrc ; Point to record count in submit FCB + ld a,(hl) ; Get the number of records in file + dec a ; Reduce to number of last record + ld (subfcr),a ; ..and put into current record field + call read ; Attempt to read submit file + jr nz,readbuf1 ; Branch if read failed + + dec (hl) ; Reduce file record cound + dec hl ; Point to S2 byte of FCB (yes, this is req'd!) + ld (hl),a ; Stuff a zero in there (A=0 from call to READ) + call close ; Close the submit file one record smaller + jr z,readbuf1 ; Branch if close failed + +; Now we copy the line read from the file into the multiple command line +; buffer + + ld de,chrcnt ; Point to command length byte in command buffer + ld hl,tbuff ; Point to sector read in from submit file + + if buflen gt 7fh ; If command line buffer is longer than record, + ld bc,80h ; ..then copy entire record from $$$.SUB file + else ;buflen le 7fh ; Otherwise copy only enough to fill + ld bc,buflen+1 ; ..the command line buffer + endif ;buflen gt 7fh + + ldir ; Transfer line from submit file to buffer + +; We now deal with various options that control the display of commands fed +; to the command processor from a submit file. + + if subnoise gt 0 ; If subnoise = 0 we omit all this display code + + if subnoise eq 1 ; If subnoise = 1 we follow the quiet flag + ld a,(quietfl) + or a + jr nz,readbuf0 ; If quiet, skip echoing the command + endif ;subnoise eq 1 + + call prompt ; Print prompt + call print ; Print submit prompt trailer + defb sprmpt or 80h + ld hl,cmdlin ; Print command line + call printhl + + endif ;subnoise gt 0 + +readbuf0: + call break ; Check for abort (any char) + ret nz ; If no ^C, return to caller and run + +readbuf1: + call subkil ; Kill submit file and abort + jp restart ; Restart CPR + + endif ; subon + +shellinput: + ld hl,shstk ; Point to shell stack + ld a,(hl) ; Check first byte + cp ' '+1 ; See if any entry + jr c,userinput ; Get user input if none + + ld de,cmdlin ; Point to first character of command line + ld bc,shsize ; Copy shell line into command line buffer + ldir ; Do copy + ex de,hl ; HL points to end of line + ld a,1 ; Set command status flag to show + ld (cmdstatfl),a ; ..that a shell has been invoked + jr readbuf3 ; Store ending zero and exit + +userinput: + call prompt ; Print prompt + call print ; Print prompt trailer + defb cprmpt or 80h + ld c,0ah ; Read command line from user + ld de,bufsiz ; Point to buffer size byte of command line + call bdos + + ; Store null at end of line + + ld hl,chrcnt ; Point to character count + ld a,(hl) ; ..and get its value + inc hl ; Point to first character of command line + call addah ; Make pointer to byte past end of command line +readbuf3: + ld (hl),0 ; Store ending zero + ret + +;----------------------------------------------------------------------------- + +; Check for any character from the user console. Return with the character +; in A. If the character is a control-C, then the zero flag will be set. + + if subon or diron or eraon or lton + +break: + ld c,0bh ; BDOS console status function + call bdossave ; Call BDOS and set flags + call nz,conin ; Get input character if there is one + cp 'C'-'@' ; Check for abort + ret + + endif ; subon or diron or eraon or lton + +;----------------------------------------------------------------------------- + +; Add A to HL (HL=HL+A) + +addah: + add a,l + ld l,a + ret nc + inc h + ret + +;----------------------------------------------------------------------------- + +; The routine NUMBER evaluates a string in the first FCB as either a decimal +; or, if terminated with the NUMBASE hexadecimal marker, a HEX number. If the +; conversion is successful, the value is returned as a 16-bit quantity in BC. +; If an invalid character is encountered in the string, the routine returns +; with the carry flag set and HL pointing to the offending character. + + if saveon + +number: + ld hl,tfcb+8 ; Set pointer to end of number string + ld bc,8 ; Number of characters to scan + ld a,numbase ; Scan for HEX identifier + cpdr ; Do the search + jr nz,decimal ; Branch if HEX identifier not found + + inc hl ; Point to HEX marker + ld (hl),' ' ; Replace HEX marker with valid terminator + ; ..and fall through to HEXNUM + + endif ;saveon + +;---------------------------------------- + +; At this entry point the character string in the first default FCB is +; converted as a hexadecimal number (there must NOT be a HEX marker). + +hexnum: + ld hl,tfcb+1 ; Point to string in first FCB + +; At this entry point the character string pointed to by HL is converted +; as a hexadecimal number (there must be NO HEX marker at the end). + +hexnum1: + ld de,16 ; HEX radix base + jr radbin ; Invoke the generalized conversion routine + +;---------------------------------------- + +; This entry point performs decimal conversion of the string in the first +; default FCB. + +decimal: + ld hl,tfcb+1 ; Set pointer to number string + +; This entry point performs decimal conversion of the string pointed to +; by HL. + +decimal1: + ld de,10 ; Decimal radix base + ; Fall through to generalized + ; ..radix conversion routine + +; This routine converts the string pointed to by HL using the radix passed in +; DE. If the conversion is successful, the value is returned in BC. HL points +; to the character that terminated the number, and A contains that character. +; If an invalid character is encountered, the routine returns with the carry +; flag set, and HL points to the offending character. + +radbin: + ld bc,0 ; Initialize result +radbin1: + or a ; Make sure carry is reset + call sdelm ; Test for delimiter (returns Z if delimiter) + ret z ; Return if delimiter encountered + + sub '0' ; See if less than '0' + ret c ; Return with carry set if so + cp 10 ; See if in range '0'..'9' + jr c,radbin2 ; Branch if it is valid + cp 'A'-'0' ; Bad character if < 'A' + ret c ; ..so we return with carry set + sub 7 ; Convert to range 10..15 +radbin2: + cp e ; Compare to radix in E + ccf ; Carry should be set; this will clear it + ret c ; If carry now set, we have an error + + inc hl ; Point to next character + push bc ; Push the result we are forming onto the stack + ex (sp),hl ; Now HL=result, (sp)=source pointer + call mpy16 ; HLBC = previous$result * radix + ld h,0 ; Discard high 16 bits and + ld l,a ; ..move current digit into HL + add hl,bc ; Form new result + ld c,l ; Move it into BC + ld b,h + pop hl ; Get string pointer back + jr radbin1 ; Loop until delimiter + +;----------------------------------------------------------------------------- + +; This routine multiplies the 16-bit values in DE and HL and returns the +; 32-bit result in HLBC (HL has high 16 bits; BC has low 16 bits). Register +; pair AF is preserved. + +mpy16: + ex af,af' ; Save AF + ld a,h ; Transfer factor in HL to A and C + ld c,l + ld hl,0 ; Initialize product + ld b,16 ; Set bit counter + rra ; Shift AC right so first multiplier bit + rr c ; ..is in carry flag +mp161: + jr nc,mp162 ; If carry not set, skip the addition + add hl,de ; Add multiplicand +mp162: + rr h ; Rotate HL right, low bit into carry + rr l + rra ; Continue rotating through AC, with + rr c ; ..next multiplier bit moving into carry + djnz mp161 ; Loop through 16 bits + + ld b,a ; Move A to B so result is in HLBC + ex af,af' ; Restore original AF registers + ret + +;----------------------------------------------------------------------------- + +; This routine checks for a delimiter character pointed to by HL. It returns +; with the character in A and the zero flag set if it is a delimiter. All +; registers are preserved except A. + +sdelm: + ld a,(hl) ; Get the character + exx ; Use alternate register set (shorter code) + ld hl,deldat ; Point to delimiter list + ld bc,delend-deldat; Length of delimiter list + cpir ; Scan for match + exx ; Restore registers + ret ; Returns Z if delimiter + +deldat: ; List of delimiter characters + db ' ' + db '=' + db '_' + db '.' + db ':' + db ';' + db '<' + db '>' + db ',' + db 0 + if cmdsep ne ';' + db cmdsep + endif ;cmdsep ne ';' +delend: + +;----------------------------------------------------------------------------- + +; Log into DU contained in FCB pointed to by DE. Registers DE are preserved; +; all others are changed. Explicit values for the temporary drive and user +; are extracted from the FCB. If the record-count byte has an FF in it, that +; is a signal that the directory specification was invalid. We then invoke +; the error handler. + + if diron or eraon or lton or renon or saveon + +fcblog: + push de ; Save pointer to FCB + ex de,hl + ld a,(hl) ; Get drive + ld bc,13 ; Offset to S1 field + add hl,bc + ld c,(hl) ; Get user into C + or a ; See if drive value was 0 + jr nz,fcblog1 ; If not, branch ahead + ld a,(curdr) ; Otherwise substitute current drive + inc a ; ..shifted to range 1..16 +fcblog1: + ld b,a ; Get drive into B + ld (tempusr),bc ; Set up temporary DU values + call logtemp ; ..and log into it + pop de ; Restore pointer to FCB + +; Now check to make sure that the directory specification was valid. + + inc hl ; Advance pointer to record-count byte + inc hl + ld a,(hl) ; See if it is nonzero + or a + jp nz,baddirerr ; If so, invoke error handler + + ret ; Otherwise return + + endif ;diron or eraon or lton or renon or saveon + +;----------------------------------------------------------------------------- + +; Log into the temporary directory. Registers B, H, and L are preserved. + +logtemp: + ld de,(tempusr) ; Set D = tempdr, E = tempusr + call setuser1 ; Register D is preserved during this call + ld a,d ; Move drive into A + dec a ; Adjust for drive range 0..15 + jp setdrive ; Log in new drive and return + +;----------------------------------------------------------------------------- + +; This routine scans the command table pointed to by HL for the command name +; stored in the command FCB. If the command is not found, the routine returns +; with the zero flag reset. If the command is found, the address vector is +; stored in EXECADR and the zero flag is set. + +cmdscan: + ld b,(hl) ; Get length of each command + inc hl ; Point to first command name + +scannext: + ld a,(hl) ; Check for end of table + or a + jr z,scanend ; Branch if end + + ld de,cmdfcb+1 ; Point to name of requested command + push bc ; Save size of commands in table + + if wheel + ; Ignore commands with high bit set in first + ; ..char of command name if wheel is false + ld a,(z3whl) ; Get the wheel byte + or a + ld c,0ffh ; Make a mask that passes all characters + jr z,scancmp ; Use this mask if wheel not set + + endif ; wheel + + ld c,7fh ; Use mask to block high bit if wheel set + ; ..or not in use + +scancmp: + ld a,(de) ; Compare against table entry + + xor (hl) + and c ; Mask high bit of comparison + jr nz,scanskip ; No match, so skip rest of command name + + inc de ; Advance to next characters to compare + inc hl + res 7,c ; Mask out high bit on characters after first + djnz scancmp ; Count down + + ld a,(de) ; See if next character in input command + cp ' ' ; ..is a space + jr nz,scanbad ; If not, user command is longer than commands + ; ..in the command table + + ; Matching command found + + pop bc ; Clear stack + ld a,(hl) ; Get address from table into HL + inc hl + ld h,(hl) + ld l,a + ld (execadr),hl ; Set execution address + xor a ; Set zero flag to show that command found + ret + +scanskip: + inc hl ; Skip to next command table entry + djnz scanskip + +scanbad: + pop bc ; Get back size of each command + inc hl ; Skip over address vector + inc hl + jr scannext ; Try scanning next entry in table + +scanend: + xor a ; Reset zero flag to show + dec a ; ..that command was not found + ret + +; End ZCPR33-4.Z80 + + page + +; ZCPR33-5.Z80 + +;============================================================================= +; +; R E S I D E N T C O M M A N D C O D E +; +;============================================================================= + +; Command: DIR +; Function: To display a directory of the files on disk +; Forms: +; DIR Displays the DIR-attribute files +; DIR Same as DIR *.* +; DIR S Displays the SYS-attribute files +; DIR /S Same as DIR *.* S +; DIR A Display both DIR and SYS files +; DIR /A Same as DIR *.* A + + if diron + +dir: + ld de,tfcb ; Point to target FCB + push de ; ..and save the pointer for later + inc de ; Point to file name + ld a,(de) ; Get first character + + if slashfl ; If allowing "DIR /S" and "DIR /A" formats + cp '/' ; If name does not start with '/' + jr nz,dir1 ; ..branch and process normally + inc de ; Point to second character + ld a,(de) ; Get option character after slash + ld (tfcb2+1),a ; ..and put it into second FCB + dec de ; Back to first character + ld a,' ' ; Simulate empty FCB + endif ;slashfl + +dir1: + cp ' ' ; If space, make all wild + jr nz,dir2 + ld b,11 + ld a,'?' + call fill + +dir2: + pop de ; Restore pointer to FCB + call fcblog ; Log in the specified directory + + if whldir + ld a,(z3whl) ; Check wheel status + or a ; If not set, then ignore options + jr z,dir2a + endif ;whldir + + ld a,(tfcb2+1) ; Check for any option letter + ld b,1 ; Flag for both DIR and SYS files + cp allchar ; See if all (SYS and DIR) option letter + jr z,dirpr ; Branch if so + dec b ; B = 0 for SYS files only + cp syschar ; See if SYS-only option letter + jr z,dirpr ; Branch if so +dir2a: + ld b,80h ; Flag for DIR-only selection + ; Drop into DIRPR to print directory + + endif ; diron + +;-------------------- + +; Directory display routine + +; On entry, if attribute checking is required, the B register is +; set as follows: +; 00H for SYS files only +; 80H for DIR files only +; 01H for both + + if diron or eraon + +dirpr: + if diron ; Attribute checking needed only for DIR + ld a,b ; Get flag + ld (systst),a ; Set system test flag + endif + + ld e,0 ; Set column counter to zero + push de ; Save column counter (E) + call srchfst1 ; Search for specified file (first occurrence) + jr nz,dir3 + call prnnf ; Print no-file message + pop de ; Restore DE + xor a ; Set Z to show no files found + ret + +; Entry selection loop. On entering this code, A contains the offset in the +; directory block as returned by the search-first or search-next call. + +dir3: + if diron ; Attribute checking needed only for DIR cmd + + call getsbit ; Get and test for type of files + jr z,dir6 + + else ;not diron + + dec a ; Adjust returned value from 1..4 to 0..3 + rrca ; Multiply by 32 to convert number to + rrca ; ..offset into TBUFF + rrca + ld c,a ; C = offset to entry in TBUFF + + endif ;diron + + pop de ; Restore count of + ld a,e ; ..entries displayed + inc e ; Increment entry counter + push de ; Save it + and 03h ; Output CRLF if 4 entries printed in line + jr nz,dir4 + call crlf ; New line + jr dir5 +dir4: + call print + + if wide + + defb ' ' ; 2 spaces + defb fence ; Then fence char + defb ' ',' '+80h ; Then 2 more spaces + + else ;not wide + + defb ' ' ; Space + defb fence ; Then fence char + defb ' '+80h ; Then space + + endif ; wide + +dir5: + ld a,1 + call dirptr ; HL now points to 1st byte of file name + call prfn ; Print file name +dir6: + call break ; Check for abort + jr z,dir7 + call srchnxt ; Search for next file + jr nz,dir3 ; Continue if file found + +dir7: + pop de ; Restore stack + dec a ; Set NZ flag + ret + + endif ; diron or eraon + +;----------------------------------------------------------------------------- + + if diron or attchk or eraon + +; This routine returns a pointer in HL to the directory entry in TBUFF that +; corresponds to the offset specified in registers C (file offset) and C +; (byte offset within entry). + +dirptr: + ld hl,tbuff + add a,c ; Add the two offset contributions + call addah ; Set pointer to desired byte + ld a,(hl) ; Get the desired byte + ret + + endif ; diron or attchk or eraon + +;----------------------------------------------------------------------------- + +; Test File in FCB for existence, ask user to delete if so, and abort if he +; choses not to + + if saveon or renon + +extest: + ld de,tfcb ; Point to FCB + push de ; ..and save it for later + call fcblog ; Log into specified directory + call srchfst1 ; Look for specified file + pop de ; Restore pointer + ret z ; OK if not found, so return + call printc + if bellfl + defb bell + endif ;bellfl + defb 'Erase',' '+80h + ld hl,tfcb+1 ; Point to file name field + call prfn ; Print it + call print ; Add question mark + defb '?' or 80h + call conin ; Get user response + cp 'Y' ; Test for permission to erase file + jp nz,restart ; If not, flush the entire command line + jp delete ; Delete the file + + endif ; saveon or renon + +;----------------------------------------------------------------------------- + +; Print file name pointed to by HL + + if diron or renon or saveon + +prfn: + ld b,8 ; Display 8 characters in name + call prfn1 + call print ; Put in dot + defb '.' or 80h + ld b,3 ; Display 3 characters in type +prfn1: + ld a,(hl) ; Get character + inc hl ; Point to next + call conout ; Print character + djnz prfn1 ; Loop through them all + ret + + endif ;diron or renon or saveon + +;----------------------------------------------------------------------------- + +; This routine returns NZ if the file has the required attributes and Z if +; it does not. It works by performing the 'exclusive or' of the mask passed +; in register A and the filename attribute obtained by masking out all but +; the highest bit of the character. For the 'both' case, setting any bit +; in the mask other than bit 7 will guarantee a nonzero result. +; +; File name: : X 0 0 0 0 0 0 0 (After 80H mask, X=1 if SYS, 0 if DIR) +; +; SYS-ONLY : 0 0 0 0 0 0 0 0 (XOR gives 00H if X=0 and 80H if X=1) +; DIR-ONLY : 1 0 0 0 0 0 0 0 (XOR gives 80H if X=0 and 00H if X=1) +; BOTH : 0 0 0 0 0 0 0 1 (XOR gives 01H if X=0 and 81H if X=1) + + if diron or attchk + +getsbit: + dec a ; Adjust to returned value from 1..4 to 0..3 + rrca ; Multiply by 32 to convert number to + rrca ; ..offset into TBUFF + rrca + ld c,a ; Save offset in TBUFF in C + ld a,10 ; Add 10 to point to SYS attribute bit + call dirptr ; A = SYS byte + and 80h ; Look only at attribute bit +systst equ $+1 ; In-the-code variable + xor 0 ; If SYSTST=0, SYS only; if SYSTST=80H, DIR + ; ..only; if SYSTST=1, both SYS and DIR + ret ; NZ if OK, Z if not OK + + endif ;diron or attchk + +;----------------------------------------------------------------------------- + +; Command: REN +; Function: To change the name of an existing file +; Forms: REN = +; Notes: If either file spec is ambiguous, or if the source file does +; not exist, the error handler will be entered. If a file with +; the new name already exists, the user is prompted for deletion +; and ZEX is turned off during the prompt. + + if renon + +ren: + ld hl,tfcb ; Check for ambiguity in first file name + call ambchk + call fcblog ; Login to fcb + ld hl,tfcb2 ; Check for ambiguity in second file name + call ambchk + xor a ; Use current drive for 2nd file + ld (de),a + call srchfst ; Check for old file's existence + jr nz,ren0a ; Branch if file exists +jpnofile: + ld a,ecnofile ; Set error code for file not found + jp error ; ..and invoke error handler +ren0a: + call extest ; Test for file existence and return if not + ld b,12 ; Exchange new and old file names + push de ; Save pointer to FCB + ld hl,tfcb2 ; Point to FCB for old file name +ren0: + ld a,(de) ; Get character of old name + ld c,a ; ..into C register + ld a,(hl) ; Get character of new name + ld (de),a ; ..into place in old name + ld (hl),c ; Put character of old name into new name + inc hl ; Advance pointers + inc de + djnz ren0 + +; Perform rename function + + pop de ; Restore pointer to FCB + ld c,17h ; BDOS rename function + jp bdostest + + endif ;renon + +;----------------------------------------------------------------------------- + +; Command: ERA +; Function: Erase files +; Forms: +; ERA Erase specified files and dislay their names +; ERA I Display names of files to be erased and prompt for +; inspection before erase is performed. (Character 'I' +; is defined by INSPCH in Z33HDR.LIB; if it is ' ', then +; any character triggers inspection.) + + if eraon + +era: + if inspfl and eraok; 'I' flag and verification enabled? + ld a,(tfcb2+1) ; Get flag, if any, entered by user + ld (eraflg),a ; Save it in code below + endif ;erav and eraok + + ld de,tfcb ; Point to target FCB + call fcblog ; ..and log into the specified directory + + if diron or attchk ; Attribute checking only in these cases + ld b,1 ; Display all matching files + endif ;diron or attchk + + call dirpr ; Print directory of erased files + ret z ; Abort if no files + + if eraok ; Print prompt + + if inspfl ; Test verify flag + +eraflg equ $+1 ; Address of flag (in-the-code modification) + ld a,0 + cp inspch ; Is it an inspect option? + + if inspch ne ' ' ; If an explicit inspect character is specified + jr nz,era2 ; ..skip prompt if it is not that character + else ; If INSPCH is the space character + jr z,era2 ; ..then skip prompt only if FCB has a space + endif ;inspch ne ' ' + + endif ;inspfl + + call printc + defb 'OK to Erase','?'+80h + call conin ; Get reply + cp 'Y' ; Yes? + ret nz ; Abort if not + + endif ; eraok + +era2: + ld de,tfcb + jp delete ; Delete files and return + + endif ; Eraon + +;----------------------------------------------------------------------------- + +; Command: LIST +; Function: Print out specified file on the LST: device +; Forms: LIST Print file (No Paging) +; Notes: The flags which apply to TYPE do not take effect with LIST + + if lton + +list: + ld a,0ffh ; Turn on printer flag + jr type0 + +;----------------------------------------------------------------------------- + +; Command: TYPE +; Function: Print out specified file on the CON: Device +; Forms: TYPE Print file with default paging option +; TYPE P Print file with paging option reversed + +type: + xor a ; Turn off printer flag + +; Common entry point for LIST and TYPE functions + +type0: + ld (prflg),a ; Set printer/console flag + ld a,(tfcb2+1) ; Check for user page toggle ('P') option + ld (pgflg),a ; Save it as a flag in code below + ld hl,tfcb ; Point to target file FCB + call ambchk ; Check for ambiguous file spec (vectors to + ; ..error handler if so) + call fcblog ; Log into specified directory + call open ; Open the file + + if renon ; If REN on, share code + jr z,jpnofile + else ;not renon ; Otherwise repeat code here + ld a,ecnofile + jp z,error + endif ;renon + + call crlf ; New line + ld a,(crttxt0) ; Set line count using value from the + ; ..environment for CRT0 + inc a ; One extra the first time through + ld (pagcnt),a + ld bc,080h ; Set character position and tab count + ; (B = 0 = tab, C = 080h = char position) + +; Main loop for loading next block + +type2: + ld a,c ; Get character count + cp 80h ; If not end of disk record + jr c,type3 ; ..then skip + + call readf ; Read next record of file + ret nz ; Quit if end of file + + ld c,0 ; Reset character count + ld hl,tbuff ; Point to first character + +; Main loop for printing characters in TBUFF + +type3: + ld a,(hl) ; Get next character + and 7fh ; Mask out MSB + cp 1ah ; Check for end of file (^z) + ret z ; Quit if so + +; Output character to CON: or LST: device with tabulation + + cp cr ; If carriage return, + jr z,type4 ; ..branch to reset tab count + cp lf ; If line feed, then output + jr z,type4a ; ..with no change in tab count + cp tab ; If tab + jr z,type5 ; ..expand to spaces + +; Output character and increment character count + + call lcout ; Output character + inc b ; Increment tab count + jr type6 + +; Output CR and reset tab count + +type4: + ld b,0 ; Reset tab counter + +; Output LF and leave tab count as is + +type4a: + call lcout ; Output or + jr type6 + +; Process tab character + +type5: + ld a,' ' ; Space + call lcout + inc b ; Increment tab count + ld a,b + and 7 + jr nz,type5 ; Loop until column = n * 8 + 7 + +; Continue processing + +type6: + inc c ; Increment character count + inc hl ; Point to next character + push bc + call break ; Check for user abort + pop bc + ret z ; Quit if so + jr type2 ; Else back for more + +;-------------------- + +; Output character in A to console or list device depending on a flag. +; Registers are preserved. This code is used only by the LIST and TYPE +; commands. + +lcout: + push af ; Save character +prflg equ $+1 ; Pointer for in-the-code modification + ld a,0 ; ..to determine destination (CON or LST) + or a ; Z=type, NZ=list + jr z,lc1 + + ; Output to list device + + pop af ; Get character back + push de + push bc + ld c,5 ; LISTOUT function + jp output + + ; Output to console with paging + +lc1: + pop af ; Get character back + push af ; Save it again for page check + call conout ; Output to console + pop af ; Get character back again + cp lf ; Check for new line (paging) + ret nz ; If not new line, we are done + + ; Paging routines + +pager: + push hl + ld hl,pagcnt ; Decrement lines remaining on screen + dec (hl) + jr nz,pager1 ; Jump if not end of page + + ; New page + ld a,(crttxt0) ; Get full page count from environment + ld (hl),a ; Reset count to a full page +pgflg equ $+1 ; Pointer to in-the-code buffer pgflg + ld a,0 + cp pagech ; Page default override option wanted? + + if pagech ne ' ' ; If using explicit character for page toggle + + if pagefl ; If paging is default + jr z,pager1 ; ..PAGECH means no paging + else ; If paging not default + jr nz,pager1 ; ..PAGECH means please paginate + endif ;pagefl + + else ; Any character toggles paging + + if pagefl ; If paging is default + jr nz,pager1 ; ..any character means no paging + else ; If paging not default + jr z,pager1 ; ..any character means please paginate + endif ;pagefl + + endif ;pagech ne ' ' + + ; End of page + push bc + call bios+9 ; Wait for user input (BIOS console input) + pop bc + cp 'C'-'@' ; Did user enter control-c? + jp z,nextcmd ; If so, terminate this command + +pager1: + pop hl ; Restore HL + ret + + endif ; lton + +;----------------------------------------------------------------------------- + +; Command: SAVE +; Function: To save the contents of the TPA onto disk as a file +; Forms: +; SAVE +; Save specified number of pages (starting at 100H) from TPA +; into specified file +; +; SAVE +; Like SAVE above, but numeric argument specifies +; number of sectors rather than pages + + if saveon + +; Entry point for SAVE command + +save: + call number ; Extract number from command line + jr c,badnumber ; Invoke error handler if bad number + push bc ; Save the number + call reparse ; Reparse tail after number of sectors/pages + pop hl ; Get sector/page count back into HL + ld a,(tfcb2+1) ; Check sector flag in second FCB + cp sectch + + if sectch ne ' ' ; If using a specific character, then jump + jr z,save0 ; ..if it is that character + else ; If allowing any character (SECTCH=' ') + jr nz,save0 ; ..jump if it is anything other than space + endif ;sectch ne ' ' + + add hl,hl ; Double page count to get sector count +save0: + ld a,1 ; Maximum allowed value in H + cp h ; Make sure sector count < 512 (64K) + jr c,badnumber ; If >511, invoke error handler + + push hl ; Save sector count + ld hl,tfcb + call ambchk ; Check for ambiguous file spec (vectors to + ; ..error handler if so) + + call extest ; Test for existence of file and abort if so + ld c,16h ; BDOS make file function + call bdostest + jr z,save3 ; Branch if error in creating file + + pop bc ; Get sector count into BC + ld hl,tpa-80h ; Set pointer to one record before TPA + +save1: + ld a,b ; Check for BC = 0 + or c + dec bc ; Count down on sectors (flags unchanged, + ; ..B=0FFH if all records written successfully) + jr z,save2 ; If BC=0, save is done so branch + + push bc ; Save sector count + ld de,80h ; Advance address by one record + add hl,de + push hl ; Save address on stack + ex de,hl ; Put address into DE for BDOS call + call dmaset ; Set DMA address for write + ld de,tfcb ; Write sector + ld c,15h ; BDOS write sector function + call bdossave + pop hl ; Get address back into HL + pop bc ; Get sector count back into BC + jr z,save1 ; If write successful, go back for more + + ld b,0 ; B=0 if write failed + +save2: + call close ; Close file even if last write failed + and b ; Combine close return code with + ; ..write success flag + ret nz ; Return if all ok + +save3: ; Disk must be full + ld a,ecdiskfull ; Disk full error code + jr jperror + + endif ; saveon + +;----------------------------------------------------------------------------- + + if lton or saveon or renon or geton + +; Check file control block pointed to by HL for any wildcard characters ('?'). +; Return to calling program if none found. Otherwise branch to error handler. +; The routine also treats an empty file name as ambiguous. + +ambchk: + push hl ; Save pointer to FCB + inc hl ; Point to first character in file name + ld a,(hl) ; See if first character is a space + cp ' ' + jr z,ambchk1 ; If so, branch to error return + + ld a,'?' ; Set up for scan for question mark + ld bc,11 ; Scan 11 characters + cpir + pop de ; Restore pointer to FCB in DE + ret nz ; Return if no '?' found +ambchk1: + ld a,ecambig ; Error code for ambiguous file name + jr jperror + + endif ;lton or renon or saveon or geton + + if lton or renon or saveon or geton or jumpon + +badnumber: + ld a,ecbadnum ; Error code for bad number value +jperror: ; Local entry point for relative jump + jp error ; ..to go to error handler + + endif ;lton or renon or saveon or geton or jumpon + +;----------------------------------------------------------------------------- + +; Command: JUMP +; Function: To execute a program already loaded into some specified memory +; address +; Forms: JUMP +; The address is in hex; the tail will be parsed as usual + + if jumpon + +jump: + call hexnum ; Get load address into BC + jr c,badnumber ; If bad number, invoke error handling + push bc ; ..and save it + call reparse ; Reparse tail after address value + pop hl ; Restore execution address to HL + jr getproglf ; Perform call via code below + + endif ;jumpon + +;----------------------------------------------------------------------------- + +; Command: GO +; Function: To Call the program in the TPA without loading +; loading from disk. Same as JUMP 100H, but much +; more convenient, especially when used with +; parameters for programs like STAT. Also can be +; allowed on remote-access systems with no problems. +; +;Form: GO + + if goon + +go: + ld hl,tpa ; Set up TPA as the execution address + + endif ; goon + + if jumpon or goon ; Common code + +getproglf: + ld (execadr),hl + xor a ; Set zero flag to enable leading CRLF + jp callproglf ; Perform call (with leading CRLF) + + endif ;jumpon or goon + +;----------------------------------------------------------------------------- + +; Command: GET +; Function: To load the specified file from disk to the specified address +; Forms: GET +; Loads the specified file to the specified hexadecimal address +; Note that the normal file search path is used to find the file. +; If SCANCUR is off, the file may not be found in the current +; directory unless a colon is included in the file spec. + + if geton + +get: + +; TMPCOLON was set when the file name was parsed. We use that as the colon +; flag so that the file will be loaded from a directory just as if it had +; been entered as the command name. + + if drvprefix and [not scancur] + ld a,(tmpcolon) ; Allow GET to load from specified + ld (colon),a ; directory + endif ;drvprefix and [not scancur] + + ld hl,tfcb2 ; Copy TFCB2 to CMDFCB for load + push hl + ld de,cmdfcb + ld bc,14 + ldir + pop hl + call ambchk ; Make sure file is not ambiguous (vectors + ; ..to error handler if so) + +; If GET fails to find the specified file along the search path, we do not +; want the ECP to be engaged. To prevent that, we fool the command processor +; by telling it that the ECP is already engaged. + + ld hl,cmdstatfl ; Point to command status flag + set 2,(hl) ; Turn on ECP flag to prevent use of ECP + call hexnum ; Get load address into BC + jr c,badnumber ; If invalid number, invoke error handler + + if not fullget + ld a,b ; If trying to load into base page + or a ; ..treat as error + jr z,badnumber + endif ;not fullget + + ld h,b ; Move address into HL + ld l,c + ld a,0ffh ; Disable dynamic loading + ; Fall through to mload + + endif ; geton + +; End ZCPR33-5.Z80 + + page + +; ZCPR33-6.Z80 + +;============================================================================= +; +; P A T H S E A R C H A N D F I L E L O A D I N G C O D E +; +;============================================================================= + +; This block of code loads a file into memory. The normal address at which +; loading is to begin is passed to the routine in the HL register. The name +; of the file to load is passed in the command file control block. +; +; This code supports an advanced option that loads files to a dynamic address +; specified in the header to the file using a new type-3 environment. In a +; type-3 environment, the execution/load address is stored in the word +; following the environment descriptor address. A value is passed to MLOAD in +; the A register that controls this dynamic loading mechanism. The value +; specifies the lowest environment type value for which dynamic loading will +; be performed. This value will be 3 when MLOAD is called for normal COM file +; execution and will be 0FFH when chained to from the GET command. In the +; latter case, the user-specified load address must be used. +; +; MLOAD guards against loading a file over the operating system. It computes +; the lower of the following two addresses: 1) the CPR entry point; 2) the +; bottom of protected memory as indicated by the DOS entry address stored at +; address 0006H. If the load would exceed this limit, error handling is +; engaged (except for the GET command when FULLGET is enabled). + +mload: + ld (envtype),a ; Set up in-the-code modification below + ld (execadr),hl ; Set up execution/load address + call defltdma ; Set DMA address to 80H for file searches + + +; This code sets the attributes of COM files which are acceptable. If both +; SYS and DIR type files are acceptable, there is no need to include this code, +; and ATTCHK can be set to false. + + if attchk ; Only if attribute checking enabled + ld a,comatt ; Attributes specified in Z33HDR.LIB + ld (systst),a ; Set flag + endif ;attchk + +;----------------------------------------------------------------------------- + +; PATH BUILDING CODE + +; In ZCPR33 the minpath feature, optional in ZCPR30, is always used. To +; minimize the size of the CPR code, however, there is an option to place the +; minpath in an external buffer (outside the CPR). If the path is short +; enough, the minpath can be placed at the bottom of the system stack. + + ld de,path ; Point to first element in user's symbolic path + ld hl,mpath ; Point to minpath buffer + xor a + ld (hl),a ; Initialize to empty minpath + + +; If DRVPREFIX is enabled, the CPR will recognize an explicit directory +; reference in a command. The first element of the path will then be this +; explicit directory. If no explicit directory was given in the command, +; then no entry is made into the search path. If the WPREFIX option is +; on, explicit directory prefixes will be recognized only when the wheel +; byte is on. + + if drvprefix ; Pay attention to du:com prefix? + + ld a,(colon) ; See if colon was present in command + or a + jr z,makepath2 ; If not, skip ahead + + if wprefix + ld a,(z3whl) ; See if wheel byte is on + or a + jr z,makepath2 ; If not, skip ahead + endif ;wprefix + + ld a,(cmdfcb) ; Get drive from command FCB + ld (hl),a ; Put drive into minpath + inc hl ; Advance pointer + ld a,(cmdfcb+13) ; Get user number from command FCB + ld (hl),a ; Put it into minpath + inc hl ; Advance pointer to next path element + xor a ; A=0 + ld (hl),a ; Store ending 0 in mpath +makepath2: + endif ; drvprefix + + +; If SCANCUR is enabled in Z33HDR.LIB, then we always include the current +; directory automatically, even without a '$$' element in the user's path. +; If WPREFIX is enabled, however, we do not want to allow the current +; directory to be included, but we must make sure that it is included in +; the building of the root path, in case the user's symbolic path is empty. + + if scancur ; Scan current directory at all times? + + ld bc,(curusr) ; C = current user, B = current drive + inc b ; Set drive to range 1..16 + + if wprefix + + ld a,(z3whl) ; See if wheel byte is on + or a + jr nz,addpath ; If it is, add element to path; if not, + ; ..fall through to MAKEPATH3 + else ;not wprefix + + jr addpath ; Begin loop of placing entries into mpath + + endif ;wprefix + + else ;not scancur + +; If SCANCUR is off and ROOTONLY is in effect, we have to make sure that some +; directory values are put into the root path in the case where the user's +; path is completely empty. To do so, we preset BC for directory A0. + + if rootonly + ld bc,0100h ; Setup for drive A (B=1), user 0 (C=0) + endif ;rootonly + + endif ;scancur + + +; Convert symbolic entries in user's path into absolute DU values in minpath. +; Entries are read one-by-one from the symbolic path. If the 'current' drive +; or user indicator is present (default symbol is '$'), then the current +; drive or user value is fetched. Otherwise the explicit binary value from the +; path is used. After each absolute DU value is formed, the minpath as it +; exists so far is scanned to see if this DU value is already there. If it is +; not, then the DU value is appended to the path. Otherwise it is ignored. + +makepath3: + ld a,(de) ; Get next symbolic path entry + or a ; If 0, we are at end of path + jr z,makepath6 + + ld bc,(curusr) ; C = current user, B = current drive + inc b ; Set drive to range 1..16 + cp curind ; Check for current drive symbol (default '$') + jr z,makepath4 ; If so, leave current drive in B + ld b,a ; Else move specified drive into B +makepath4: + inc de ; Point to user value in symbolic path + ld a,(de) ; Get user + inc de ; Point to next element in symbolic path + cp curind ; Check for current user symbol (default '$') + jr z,makepath5 ; If so, leave current drive in C + ld c,a ; Else move specified user into C +makepath5: + +; At this point in the code we have a potential path element in BC. We first +; have to scan the minpath we have so far to see if that element is already +; there. In that case we ignore it; otherwise we add it to the end of the path. + +addpath: + ; Skip path if directory given explicitly + + if skippath + + if wprefix + ld a,(z3whl) ; See if wheel byte is on + or a + call nz,skipchk ; If not, fall through + else ;not wprefix + call skipchk ; See if path should be skipped + endif ;wprefix + + jr nz,makepath3 ; If so, branch out of ADDPATH + + endif ;skippath + + ld hl,mpath ; Point to beginning of minpath + +addpath1: ; Point of reentry + ld a,(hl) ; Get drive value + or a ; Check for end of minpath + jr z,addpath2 ; If end, jump and add BC to minpath + + inc hl ; Increment pointer to user + cp b ; Check for drive match + ld a,(hl) ; Get user from minpath + inc hl ; Point to next minpath entry + jr nz,addpath1 ; If drive was different, loop back again + cp c ; Check for user match + jr nz,addpath1 ; If user is different, loop back again + jr makepath3 ; Branch if we have a duplicate + +; We have a new DU; add it to minpath + +addpath2: + ld (hl),b ; Store drive + inc hl + ld (hl),c ; Store user + inc hl + ld (hl),0 ; Store ending 0 + jr makepath3 ; Continue scanning user's path + +; If the ECP facility is set up to use the root directory, then create a +; root path. BC presently contains the proper DU. + +makepath6: + + if rootonly + ld hl,rootpth ; Point to special path to contain root + ld (hl),b ; Store disk + inc hl + ld (hl),c ; Store user + endif ;rootonly + +;----------------------------------------------------------------------------- + +; This is the code for loading the specified file by searching the minpath. + + xor a ; Always use current disk specification in the + ld (cmdfcb),a ; ..command FCB + +mload1: + + ld hl,mpath ; Point to beginning of minpath + +mload2: + +; Either the FASTECP or BADDUECP option may have set FIRSTCHAR to a space +; character as a signal to go directly to extended command processing. If +; neither option is enabled but SKIPPATH is, then the FIRSTCHAR data is +; stored in the routine below where path skipping is implemented. + + if fastecp or badduecp + + ld a,(cmdstatfl) ; If ECP is running + bit 2,a ; ..we branch to look for ECP along path + jr nz,mload2a +firstchar equ $+1 ; Pointer for in-the-code modification + ld a,0 + cp ' ' ; Was command invoked with leading space? + jr z,ecprun ; If so, go directly to ECP code + + endif ;fastecp or badduecp + +mload2a: + ld a,(hl) ; Get drive from path + or a ; If end of path, command not found + jr nz,mload3 ; If not end of path, skip over ECP code + +;----------------------------------------------------------------------------- + +; EXTENDED COMMAND PROCESSING + +; At this point we have exhausted the search path. We now engage the +; extended command processor. + +ecprun: + if skippath + call skipchk ; See if path should be skipped + jr nz,jnzerror ; If so, invoke error handler + endif ;skippath + + ld hl,cmdstatfl ; Point to command status flag + ld a,(hl) ; ..and get value + and 110b ; Isolate ECP and error handler bits +jnzerror: ; If either is set, + ld a,ecnocmd ; Error code for command not found + jp nz,error ; ..process as an error + + set 2,(hl) ; Set ECP bit + + ld hl,ecpfcb ; Copy name of ECP to command FCB + ld de,cmdfcb + ld bc,12 ; Only 12 bytes required + ldir + + ld hl,(cmdptr) ; Get pointer to current command line + call parsetail ; Parse entire command as the command tail + + if rootonly ; Look for ECP in root directory only + ld hl,rootpth ; Point to path containing root directory only + jr mload2 ; Search for command + else ; not rootonly + jr mload1 ; Search the entire minpath for the ECP + endif ; rootonly + +;----------------------------------------------------------------------------- + +mload3: + ld b,a ; Drive into B + inc hl ; Point to user number + ld c,(hl) ; User into C + ld (tempusr),bc ; Save the values + inc hl ; Point to next entry in path + call logtemp ; Log in path-specified user/drive + + if attchk ; If allowing execution only of COM files with + ; ..specific attributes + + ld de,cmdfcb ; Point to command FCB + call srchfst ; Look for directory entry for file + jr z,mload2a ; Continue path search if file not found + push hl ; Save path pointer + call getsbit ; Check system attribute bit + pop hl ; Restore path pointer + jr z,mload2a ; Continue if attributes do not match + call opencmd ; Open file for input + jr z,mload2a ; If open failed, back to next path element + + else ;not attchk + + call opencmd ; Open file for input + jr z,mload2a ; If open failed, back to next path element + + endif ; attchk + + call readcmd ; Read first record into default DMA address + jr nz,mload5 ; Branch if zero-length file + xor a ; Set file current record back to zero + ld (cmdfcb+20h),a + ld hl,80h ; Pointer to start of code + call z3chk + jr nz,mload3a ; If not Z3 file, branch + +; The following test is modified by earlier code. For normal COM file loading, +; a 3 is inserted for the minimum environment type for dynamic load address +; determination. For the GET command, where the user-specified address should +; be used, a value of 0FFH is put in here so the carry flag will always be set. + +envtype equ $+1 ; Pointer for in-the-code modification + cp 3 ; See if no higher than a type-3 environment + jr c,mload3a ; If higher than type 3, branch + + inc hl ; Advance to load address word + inc hl + inc hl + ld a,(hl) ; Get load address into HL + inc hl + ld h,(hl) + ld l,a + ld (execadr),hl ; Set new execution/load address + +mload3a: + ld hl,(execadr) ; Get initial loading address + +; Load the file, making sure neither CPR nor protected memory is overwritten + +mload4: + if fullget + ld a,(envtype) ; If ENVTYPE is FF (from GET command) + inc a ; ..then skip memory limit checking + jr z,mload4b + endif ;fullget + + if rel + ld bc,entry ; We have to use a relocatable form to get + dec b ; ..highest page below the CPR + else ;not rel + ld b,high entry - 1 ; We can use shorter code for absolute form + endif ;rel + + ld a,(0007h) ; Get highest page below + dec a ; ..protected memory + cp b ; If A is lower value, + jr c,mload4a ; ..branch + ld a,b ; Otherwise use lower value in B +mload4a: + cp h ; Are we going to overwrite protected memory? + ld a,ectpafull ; Get ready with TPA overflow error code + jp c,error ; Error if about to overwrite protected memory +mload4b: + push hl ; Save this load address + ex de,hl ; Set DMA address + call dmaset + call readcmd + pop hl ; Get last load address back + jr nz,mload5 ; Read error or eof? + ld de,128 ; Increment load address by 128 + add hl,de + jr mload4 ; Continue loading + +; In case a program would like to find out in what directory the command +; processor found the program, temporary DU is stored in bytes 13 (user) and +; 14 (drive) in the command FCB. + +mload5: + +tempusr equ $+1 ; Pointers for in-the-code modification +tempdr equ $+2 + ld hl,0 + ld (cmdfcb+13),hl + +logcurrent: ; Return to original logged directory + ld hl,(curusr) ; Set L = current user, H = current drive + ld a,h + call setdrive ; Login current drive + ld a,l + jp setuser ; Log in new user and return from MLOAD + +;---------------------------------------- + +; This routine checks to see if building the path or running the ECP should +; be skipped. If there is a colon in the command (an explicit directory +; given) but it was not a lone colon (indicating desire to skip resident +; commands), then the routine returns with the zero flag reset. + + if skippath + +skipchk: + ld a,(colon) ; Was there a colon in the command? + or a + ret z ; Return with zero flag set if not + + if fastecp or badduecp + ld a,(firstchar) ; See if the first character was the colon + else +firstchar equ $+1 ; Put data here if other two options are + ld a,0 ; ..false (in-the-code modification) + endif ;fastecp or badduecp + + cp ':' + ret ; Return: Z if lone colon, NZ otherwise + + endif ;skippath + + +; End ZCPR33-6.Z80 + + page + +;----------------------------------------------------------------------------- +; +; D A T A A R E A D E F I N I T I O N S +; +;----------------------------------------------------------------------------- + +; ---------- Page line count buffer + + if lton ; Needed only if TYPE command included + +pagcnt: + defs 1 ; Lines left on page (filled in by code) + + endif ;lton + + +; ---------- Minpath/Rootpth buffers + + if extmpath + +mpath equ extmpathadr ; Assign external minpath address + + else + +mpath: + if drvprefix + defs 2 ; Two bytes for specified DU + endif + + if scancur + defs 2 ; Two bytes for current DU + endif + + defs 2 * expaths ; Space for path from path buffer + + defs 1 ; One byte for ending null + + endif ; not extmpath + + + if rootonly +rootpth: + defs 2 ; Special path for root dir only + defb 0 ; End of path + endif ; rootonly + +;----------------------------------------------------------------------------- + +; The following will cause an error message to appear if +; the size of ZCPR33 is over 2K bytes. + + if [ $ - entry ] gt 800h + *** ZCPR33 IS LARGER THAN 2K BYTES *** + endif + + endif ;errflag + + end ; ZCPR33 + \ No newline at end of file diff --git a/Source/BPBIOS/bp33.dat b/Source/BPBIOS/bp33.dat deleted file mode 100644 index 2463481e..00000000 Binary files a/Source/BPBIOS/bp33.dat and /dev/null differ diff --git a/Source/BPBIOS/bp33bnk.dat b/Source/BPBIOS/bp33bnk.dat deleted file mode 100644 index 10912647..00000000 Binary files a/Source/BPBIOS/bp33bnk.dat and /dev/null differ diff --git a/Source/BPBIOS/bp33bnkx.dat b/Source/BPBIOS/bp33bnkx.dat deleted file mode 100644 index 8de61c30..00000000 Binary files a/Source/BPBIOS/bp33bnkx.dat and /dev/null differ diff --git a/Source/BPBIOS/bp33n.dat b/Source/BPBIOS/bp33n.dat index 69695a7b..8ec9a9c2 100644 Binary files a/Source/BPBIOS/bp33n.dat and b/Source/BPBIOS/bp33n.dat differ diff --git a/Source/BPBIOS/bp33nbnk.dat b/Source/BPBIOS/bp33nbnk.dat index c2ab01c6..8ec9a9c2 100644 Binary files a/Source/BPBIOS/bp33nbnk.dat and b/Source/BPBIOS/bp33nbnk.dat differ diff --git a/Source/BPBIOS/bp33t.dat b/Source/BPBIOS/bp33t.dat index 6e5d6781..09506ea4 100644 Binary files a/Source/BPBIOS/bp33t.dat and b/Source/BPBIOS/bp33t.dat differ diff --git a/Source/BPBIOS/bp33tbnk.dat b/Source/BPBIOS/bp33tbnk.dat index 768dd714..09506ea4 100644 Binary files a/Source/BPBIOS/bp33tbnk.dat and b/Source/BPBIOS/bp33tbnk.dat differ diff --git a/Source/BPBIOS/bp33x.dat b/Source/BPBIOS/bp33x.dat deleted file mode 100644 index 4e325d46..00000000 Binary files a/Source/BPBIOS/bp33x.dat and /dev/null differ diff --git a/Source/BPBIOS/bp33xbnk.dat b/Source/BPBIOS/bp33xbnk.dat deleted file mode 100644 index 8de61c30..00000000 Binary files a/Source/BPBIOS/bp33xbnk.dat and /dev/null differ diff --git a/Source/BPBIOS/bp34.dat b/Source/BPBIOS/bp34.dat deleted file mode 100644 index 57932427..00000000 Binary files a/Source/BPBIOS/bp34.dat and /dev/null differ diff --git a/Source/BPBIOS/bp34bnk.dat b/Source/BPBIOS/bp34bnk.dat deleted file mode 100644 index 404aef99..00000000 Binary files a/Source/BPBIOS/bp34bnk.dat and /dev/null differ diff --git a/Source/BPBIOS/bp34n.dat b/Source/BPBIOS/bp34n.dat index 65ed0e34..bb4c48f3 100644 Binary files a/Source/BPBIOS/bp34n.dat and b/Source/BPBIOS/bp34n.dat differ diff --git a/Source/BPBIOS/bp34nbnk.dat b/Source/BPBIOS/bp34nbnk.dat index 0252f3c4..bb4c48f3 100644 Binary files a/Source/BPBIOS/bp34nbnk.dat and b/Source/BPBIOS/bp34nbnk.dat differ diff --git a/Source/BPBIOS/bp34t.dat b/Source/BPBIOS/bp34t.dat index 1abf11c5..ffb28311 100644 Binary files a/Source/BPBIOS/bp34t.dat and b/Source/BPBIOS/bp34t.dat differ diff --git a/Source/BPBIOS/bp34tbnk.dat b/Source/BPBIOS/bp34tbnk.dat index 733f5436..ffb28311 100644 Binary files a/Source/BPBIOS/bp34tbnk.dat and b/Source/BPBIOS/bp34tbnk.dat differ diff --git a/Source/BPBIOS/bp34x.dat b/Source/BPBIOS/bp34x.dat deleted file mode 100644 index b19d0134..00000000 Binary files a/Source/BPBIOS/bp34x.dat and /dev/null differ diff --git a/Source/BPBIOS/bp34xbnk.dat b/Source/BPBIOS/bp34xbnk.dat deleted file mode 100644 index 7caa2b41..00000000 Binary files a/Source/BPBIOS/bp34xbnk.dat and /dev/null differ diff --git a/Source/BPBIOS/bp41.dat b/Source/BPBIOS/bp41.dat deleted file mode 100644 index fc3cb8c1..00000000 Binary files a/Source/BPBIOS/bp41.dat and /dev/null differ diff --git a/Source/BPBIOS/bp41n.dat b/Source/BPBIOS/bp41n.dat deleted file mode 100644 index 0c01177b..00000000 Binary files a/Source/BPBIOS/bp41n.dat and /dev/null differ diff --git a/Source/BPBIOS/bp41nbnk.dat b/Source/BPBIOS/bp41nbnk.dat new file mode 100644 index 00000000..7f6786be Binary files /dev/null and b/Source/BPBIOS/bp41nbnk.dat differ diff --git a/Source/BPBIOS/bp41t.dat b/Source/BPBIOS/bp41t.dat deleted file mode 100644 index 06c9dfdb..00000000 Binary files a/Source/BPBIOS/bp41t.dat and /dev/null differ diff --git a/Source/BPBIOS/bp41tbnk.dat b/Source/BPBIOS/bp41tbnk.dat new file mode 100644 index 00000000..736fbe67 Binary files /dev/null and b/Source/BPBIOS/bp41tbnk.dat differ diff --git a/Source/BPBIOS/bp41x.dat b/Source/BPBIOS/bp41x.dat deleted file mode 100644 index d9397418..00000000 Binary files a/Source/BPBIOS/bp41x.dat and /dev/null differ diff --git a/Source/BPBIOS/bpbio-ww.z80 b/Source/BPBIOS/bpbio-ww.z80 index 92487418..1394f585 100644 --- a/Source/BPBIOS/bpbio-ww.z80 +++ b/Source/BPBIOS/bpbio-ww.z80 @@ -98,7 +98,13 @@ WRUAL EQU 2 ; DOS code for unallocated write LOCKF EQU LOW [NOT AUTOSL] ;Lock flag for format default ALONE EQU FALSE ; Boot code equate IF Z3 - MACLIB Z3BASE.LIB ; Include ENV definitions +; MACLIB Z3BASE.LIB ; Include ENV definitions + IF CONF_T + MACLIB Z3BASET.LIB + ENDIF + IF CONF_N + MACLIB Z3BASEN.LIB + ENDIF ENDIF PAGE ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/Source/BPBIOS/cboot-ww.z80 b/Source/BPBIOS/cboot-ww.z80 index 91eb5171..c89069e6 100644 --- a/Source/BPBIOS/cboot-ww.z80 +++ b/Source/BPBIOS/cboot-ww.z80 @@ -371,11 +371,11 @@ BLKMV: POP BC ; And number of bytes to move ; Get and save the internal HBIOS physical disk ; buffer address which is assumed to be in the ; HBIOS bank. - LD B,19H ; Set buffer function call + LD B,18H ; Get buffer function call (assumes already allocated!!!) LD HL,0 ; ... with address 0 to get HBIOS buf adr CALL HBX_INVOKE ; ... to return internal HBIOS buffer adr LD (HB_DSKBUF),HL ; Record the buffer address - + IF HAVIOP LD HL,IOPRET LD (BIOSJT+1),HL diff --git a/Source/BPBIOS/def-ww-z33n.lib b/Source/BPBIOS/def-ww-z33n.lib new file mode 100644 index 00000000..a81c1ad6 --- /dev/null +++ b/Source/BPBIOS/def-ww-z33n.lib @@ -0,0 +1,373 @@ +;:::::::::::::::::::::::::::::::::::::::::::::::********************** +; B/P BIOS Configuration and Equate File. ** System Dependant ** +; - D-X Designs Pty Ltd P112 CPU Board - ********************** +; Tailor your system here. +; +; 30 Aug 01 - Cleaned up for GPL release. HFB +; 11 May 97 - Added GIDE and adjusted HD equates. HFB +; 5 Jan 97 - Reformatted to Standard. HFB +; 10 Jun 96 - Initial Test Release. HFB +;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +; BIOS Configuration Equates and Macros + +DATE MACRO + DEFB '17 Jan 14' ; Date of this version + ENDM + +AUTOCL MACRO + DEFB 8,'ZEX Z33 ',0 ; Autostart command line + ENDM + +;--- Basic System and Z-System Section --- + +MOVCPM EQU no ; Integrate into MOVCPM "type" loader? + IF MOVCPM +VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) + ELSE +VERS EQU 21H ; Version number w/Device Swapping permitted + ENDIF +BANKED EQU NO ; Is this a banked BIOS? +ZSDOS2 EQU NO ; Yes = Banked Dos, No = CP/M 2.2 Compatible +INROM EQU NO ; Alternate bank in ROM? +MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) +FASTWB EQU YES ; Yes if restoring CPR from banked RAM + ; ..No if restoring from Drive A +Z3 EQU YES ; Include ZCPR init code? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N + +;--- Memory configuration Section --- (Expansion Memory configured here) + +IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) + ; No = Include Common RAM transfer buffer + +;--- Character Device Section --- + +MORDEV EQU NO ; YES = Include any extra Char Device Drivers + ; NO = Only use the 4 defined Char Devices +ESCC_B EQU NO ; Include ESCC Channel B Driver? + ; The following two devices result in non-standard data rates + ; with the standard 16.00 MHz crystal in the P112. If a more + ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) + ; is used, the ports become usable. + ; Driver code for ASCI0 and ASCI1 includes an option for + ; assembling Polled or Interrupt-driven buffered input. + ; Select the desired option for ASCI0 with the BUFFA0 flag, + ; and BUFFA1 for ASCI1. +ASCI_0 EQU false ; Include ASCI0 Driver? +BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? +ASCI_1 EQU false ; Include ASCI1 Driver? +BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? + +QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) + ; ..must be 2^n with n<8 +RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? +XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? + +;--- Clock and Time Section --- + +CLOCK EQU YES ; Include ZSDOS Clock Driver Code? +DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? +CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) +TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) + +;--- Floppy Diskette Section --- + +BIOERM EQU yes ; Print BIOS error messages? +CALCSK EQU YES ; Calculate skew table? +AUTOSL EQU YES ; Auto select floppy formats? + ; If AUTOSL=True, the next two are active... +FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? +FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? +FLOPY8 EQU no ; Include 8" Floppy Formats? +MORDPB EQU NO ; Include additional Floppy DPB Formats? + +;--- RAM Disk Section --- + +RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made + +;--- Hard Disk Section --- + +HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only + ; (Pick 1 of 3 options below) +SCSI EQU NO ; YES = Use SCSI Driver +IDE EQU NO ; YES = Use IDE Driver +HDSK EQU YES ; YES = Use SIMH HDSK Driver +HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? + ; (DMA not implemented for GIDE) +UNIT_0 EQU YES ; Hard Disk Physical Unit 1 +UNIT_1 EQU YES ; Hard Disk Physical Unit 2 +UNIT_2 EQU YES ; Hard Disk Physical Unit 3 + +;--- Logical Drive Section --- + +DRV_A EQU no ; Set each of these equates for the drive and +DRV_B EQU no ; partition complement of your system. Assume +DRV_C EQU no ; that A-D are Floppies. +DRV_D EQU no +DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk +DRV_F EQU yes ; Partitions +DRV_G EQU yes +DRV_H EQU yes +DRV_I EQU yes +DRV_J EQU yes +DRV_K EQU yes +DRV_L EQU yes +DRV_M EQU RAMDSK ; This is Yes for RAM drive +DRV_N EQU yes +DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled +DRV_P EQU no + +;========== Configuration Unique Equates (P112) =========== +;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< +;>>> Do NOT Alter these unless you KNOW what you're doing <<< +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +REFRSH EQU NO ; Set to NO for only Static RAM, needed for + ; systems with dynamic RAMs. +NOWAIT EQU NO ; Set to NO to use configured Wait States in + ; Hard Disk Driver. Yes to eliminate Waits. + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; For Z-180/HD64180 systems, The Bank numbers should reflect Physical +; memory in 32k increments. In P112, the ROM occupies the first 32k +; increment and is ambiguously addressed occupying 0-1FFFFH. The upper +; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. + +BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H +BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H +BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H +BNKU EQU 00H ; User Area Bank 58000H + ; (set to 0 to disable) +BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H +BNKM EQU BID_RAMM ; Maximum Bank # F8000H + ; With both on-board RAMs only (MEM1 or MEM2), + ; the maximum Bank number is 11 (0BH). + +;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== + +CNTLA0 EQU 00H ; Control Port ASCI 0 +CNTLA1 EQU 01H ; Control Port ASCI 1 +STAT0 EQU 04H ; Serial port 0 Status +STAT1 EQU 05H ; Serial port 1 Status +TDR0 EQU 06H ; Serial port 0 Output Data +TDR1 EQU 07H ; Serial port 1 Output Data +RDR0 EQU 08H ; Serial port 0 Input Data +RDR1 EQU 09H ; Serial Port 1 Input Data +CNTR EQU 0AH ; HD64180 Counter port +TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) +TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) +RLDR0L EQU 0EH ; CTC0 Reload Count, Low +RLDR0H EQU 0FH ; CTC0 Reload Count, High +TCR EQU 10H ; Interrupt Control Register +TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) +TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) +RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) +RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) +FRC EQU 18H ; Free-Running Counter +CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) +SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) +MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) +DSTAT EQU 30H ; DMA Status/Control port +DMODE EQU 31H ; DMA Mode Control port +DCNTL EQU 32H ; DMA/WAIT Control Register +IL EQU 33H ; Interrupt Segment Register +ITC EQU 34H ; Interrupt/Trap Control Register +RCR EQU 36H ; HD64180 Refresh Control register +CBR EQU 38H ; MMU Common Base Register +BBR EQU 39H ; MMU Bank Base Register +CBAR EQU 3AH ; MMU Common/Bank Area Register +OMCR EQU 3EH ; Operation Mode Control Reg +ICR EQU 3FH ; I/O Control Register + +; Some bit definitions used with the Z-180 on-chip peripherals: + +TDRE EQU 02H ; ACSI Transmitter Buffer Empty +RDRF EQU 80H ; ACSI Received Character available + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Extended Features of Z80182 for P112 + +WSGCS EQU 0D8H ; Wait-State Generator CS +ENH182 EQU 0D9H ; Z80182 Enhancements Register +PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register +RAMUBR EQU 0E6H ; RAM End Boundary +RAMLBR EQU 0E7H ; RAM Start Boundary +ROMBR EQU 0E8H ; ROM Boundary +FIFOCTL EQU 0E9H ; FIFO Control Register +RTOTC EQU 0EAH ; RX Time-Out Time Constant +TTOTC EQU 0EBH ; TX Time-Out Time Constant +FCR EQU 0ECH ; FIFO Register +SCR EQU 0EFH ; System Pin Control +RBR EQU 0F0H ; MIMIC RX Buffer Register (R) +THR EQU 0F0H ; MIMIN TX Holding Register (W) +IER EQU 0F1H ; Interrupt Enable Register +LCR EQU 0F3H ; Line Control Register +MCR EQU 0F4H ; Modem Control Register +LSR EQU 0F5H ; Line Status Register +MDMSR EQU 0F6H ; Modem Status Register +MSCR EQU 0F7H ; MIMIC Scratch Register +DLATL EQU 0F8H ; Divisor Latch (Low) +DLATM EQU 0F9H ; Divisor Latch (High) +TTCR EQU 0FAH ; TX Time Constant +RTCR EQU 0FBH ; RX Time Constant +IVEC EQU 0FCH ; MIMIC Interrupt Vector +MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register +IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register +MMCR EQU 0FFH ; MIMIC Master Control Register + +; Z80182 PIO Registers + +DDRA EQU 0EDH ; Data Direction Register A +DRA EQU 0EEH ; Port A Data +DDRB EQU 0E4H ; Data Direction Register B +DRB EQU 0E5H ; Data B Data +DDRC EQU 0DDH ; Data Direction Register C +DRC EQU 0DEH ; Data C Data + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; ESCC Registers on Z80182 + +SCCACNT EQU 0E0H ; ESCC Control Channel A +SCCAD EQU 0E1H ; ESCC Data Channel A +SCCBCNT EQU 0E2H ; ESCC Control Channel B +SCCBD EQU 0E3H ; ESCC Data Channel B + +; [E]SCC Internal Register Definitions + +RR0 EQU 00H +RR1 EQU 01H +RR2 EQU 02H +RR3 EQU 03H +RR6 EQU 06H +RR7 EQU 07H +RR10 EQU 0AH +RR12 EQU 0CH +RR13 EQU 0DH +RR15 EQU 0FH + +WR0 EQU 00H +WR1 EQU 01H +WR2 EQU 02H +WR3 EQU 03H +WR4 EQU 04H +WR5 EQU 05H +WR6 EQU 06H +WR7 EQU 07H +WR9 EQU 09H +WR10 EQU 0AH +WR11 EQU 0BH +WR12 EQU 0CH +WR13 EQU 0DH +WR14 EQU 0EH +WR15 EQU 0FH + +; FDC37C665/6 Parallel Port in Standard AT Mode + +DPORT EQU 8CH ; Data Port +SPORT EQU 8DH ; Status Port +CPORT EQU 8EH ; Control Port + +; FDC37C665/6 Configuration Control (access internal registers) + +CFCNTL EQU 90H ; Configuration control port +CFDATA EQU 91H ; Configuration data port + +; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) + +DCR EQU 92H ; Drive Control Register (Digital Output) +MSR EQU 94H ; Main Status Register +DR EQU 95H ; Data/Command Register +DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 + +_DMA EQU 0A0H ; Diskette DMA Address + +; FDC37C665/6 Serial Port (National 16550 compatible) + +_RBR EQU 68H ;R Receiver Buffer +_THR EQU 68H ;W Transmit Holding Reg +_IER EQU 69H ;RW Interrupt-Enable Reg +_IIR EQU 6AH ;R Interrupt Ident. Reg +_FCR EQU 6AH ;W FIFO Control Reg +_LCR EQU 6BH ;RW Line Control Reg +_MCR EQU 6CH ;RW Modem Control Reg +_LSR EQU 6DH ;RW Line Status Reg +_MMSR EQU 6EH ;RW Modem Status Reg +_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) +_DDL EQU 68H ;RW Divisor LSB | wih DLAB +_DLM EQU 69H ;RW Divisor MSB | set High + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates for the National DP8490/NCR 5380 Prototype SCSI controller + + IF HARDDSK +NCR EQU 40H ; Base of NCR 5380 + +; 5380 Chip Registers + +NCRDAT EQU NCR ; Current SCSI Data (Read) + ; Output Data Register (Write) +NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) +NCRMOD EQU NCR+2 ; Mode Register (Read/Write) +NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) +NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) +NCRST EQU NCR+5 ; Bus & Status Register (Read) + ; Start DMA Send (Write) +NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) + ; Start DMA Initiator Receive (Write) +DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) + +; Bit Assignments for NCR 5380 Ports as indicated + +B_ARST EQU 10000000B ; Assert *RST (NCRCMD) +B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) +B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) +B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) + +B_BSY EQU 01000000B ; *Busy (NCRBUS) +B_REQ EQU 00100000B ; *Request (NCRBUS) +B_MSG EQU 00010000B ; *Message (NCRBUS) +B_CD EQU 00001000B ; *Command/Data (NCRBUS) +B_IO EQU 00000100B ; *I/O (NCRBUS) +B_SEL EQU 00000010B ; *Select (NCRBUS) + +B_PHAS EQU 00001000B ; Phase Match (NCRST) +B_BBSY EQU 00000100B ; Bus Busy (NCRST) + +B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) +B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) + ENDIF ;harddsk + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) +; Set the base GIDE equate to the jumper setting on the GIDE board. + + IF IDE +GIDE EQU 50H ; Set base of 16 byte address range + +IDEDOR EQU GIDE+6 ; Digital Output Register +IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) +IDEErr EQU GIDE+9 ; IDE Error Register +IDESCnt EQU GIDE+0AH ; IDE Sector Count Register +IDESNum EQU GIDE+0BH ; IDE Sector Number Register +IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) +IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) +IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register +IDECmd EQU GIDE+0FH ; IDE Command/Status Register + +CMDHOM EQU 10H ; Home Drive Heads +CMDRD EQU 20H ; Read Sector Command (w/retry) +CMDWR EQU 30H ; Write Sector Command (w/retry) +CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) +CMDFMT EQU 50H ; Format Track Command +CMDDIAG EQU 90H ; Execute Diagnostics Command +CMDINIT EQU 91H ; Initialize Drive Params Command +CMDPW0 EQU 0E0H ; Low Range of Power Control Commands +CMDPW3 EQU 0E3H ; High Range of Power Control Commands +CMDPWQ EQU 0E5H ; Power Status Query Command +CMDID EQU 0ECH ; Read Drive Ident Data Command + ENDIF ;ide +;=================== End Unique Equates ======================= + \ No newline at end of file diff --git a/Source/BPBIOS/def-ww-z33nbnk.lib b/Source/BPBIOS/def-ww-z33nbnk.lib new file mode 100644 index 00000000..0f37d33b --- /dev/null +++ b/Source/BPBIOS/def-ww-z33nbnk.lib @@ -0,0 +1,373 @@ +;:::::::::::::::::::::::::::::::::::::::::::::::********************** +; B/P BIOS Configuration and Equate File. ** System Dependant ** +; - D-X Designs Pty Ltd P112 CPU Board - ********************** +; Tailor your system here. +; +; 30 Aug 01 - Cleaned up for GPL release. HFB +; 11 May 97 - Added GIDE and adjusted HD equates. HFB +; 5 Jan 97 - Reformatted to Standard. HFB +; 10 Jun 96 - Initial Test Release. HFB +;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +; BIOS Configuration Equates and Macros + +DATE MACRO + DEFB '17 Jan 14' ; Date of this version + ENDM + +AUTOCL MACRO + DEFB 8,'ZEX Z33 ',0 ; Autostart command line + ENDM + +;--- Basic System and Z-System Section --- + +MOVCPM EQU no ; Integrate into MOVCPM "type" loader? + IF MOVCPM +VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) + ELSE +VERS EQU 21H ; Version number w/Device Swapping permitted + ENDIF +BANKED EQU YES ; Is this a banked BIOS? +ZSDOS2 EQU NO ; Yes = Banked Dos, No = CP/M 2.2 Compatible +INROM EQU NO ; Alternate bank in ROM? +MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) +FASTWB EQU YES ; Yes if restoring CPR from banked RAM + ; ..No if restoring from Drive A +Z3 EQU YES ; Include ZCPR init code? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N + +;--- Memory configuration Section --- (Expansion Memory configured here) + +IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) + ; No = Include Common RAM transfer buffer + +;--- Character Device Section --- + +MORDEV EQU NO ; YES = Include any extra Char Device Drivers + ; NO = Only use the 4 defined Char Devices +ESCC_B EQU no ; Include ESCC Channel B Driver? + ; The following two devices result in non-standard data rates + ; with the standard 16.00 MHz crystal in the P112. If a more + ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) + ; is used, the ports become usable. + ; Driver code for ASCI0 and ASCI1 includes an option for + ; assembling Polled or Interrupt-driven buffered input. + ; Select the desired option for ASCI0 with the BUFFA0 flag, + ; and BUFFA1 for ASCI1. +ASCI_0 EQU false ; Include ASCI0 Driver? +BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? +ASCI_1 EQU false ; Include ASCI1 Driver? +BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? + +QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) + ; ..must be 2^n with n<8 +RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? +XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? + +;--- Clock and Time Section --- + +CLOCK EQU YES ; Include ZSDOS Clock Driver Code? +DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? +CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) +TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) + +;--- Floppy Diskette Section --- + +BIOERM EQU yes ; Print BIOS error messages? +CALCSK EQU YES ; Calculate skew table? +AUTOSL EQU YES ; Auto select floppy formats? + ; If AUTOSL=True, the next two are active... +FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? +FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? +FLOPY8 EQU no ; Include 8" Floppy Formats? +MORDPB EQU NO ; Include additional Floppy DPB Formats? + +;--- RAM Disk Section --- + +RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made + +;--- Hard Disk Section --- + +HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only + ; (Pick 1 of 3 options below) +SCSI EQU NO ; YES = Use SCSI Driver +IDE EQU NO ; YES = Use IDE Driver +HDSK EQU YES ; YES = Use SIMH HDSK Driver +HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? + ; (DMA not implemented for GIDE) +UNIT_0 EQU YES ; Hard Disk Physical Unit 1 +UNIT_1 EQU YES ; Hard Disk Physical Unit 2 +UNIT_2 EQU YES ; Hard Disk Physical Unit 3 + +;--- Logical Drive Section --- + +DRV_A EQU no ; Set each of these equates for the drive and +DRV_B EQU no ; partition complement of your system. Assume +DRV_C EQU no ; that A-D are Floppies. +DRV_D EQU no +DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk +DRV_F EQU yes ; Partitions +DRV_G EQU yes +DRV_H EQU yes +DRV_I EQU yes +DRV_J EQU yes +DRV_K EQU yes +DRV_L EQU yes +DRV_M EQU RAMDSK ; This is Yes for RAM drive +DRV_N EQU yes +DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled +DRV_P EQU no + +;========== Configuration Unique Equates (P112) =========== +;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< +;>>> Do NOT Alter these unless you KNOW what you're doing <<< +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +REFRSH EQU NO ; Set to NO for only Static RAM, needed for + ; systems with dynamic RAMs. +NOWAIT EQU NO ; Set to NO to use configured Wait States in + ; Hard Disk Driver. Yes to eliminate Waits. + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; For Z-180/HD64180 systems, The Bank numbers should reflect Physical +; memory in 32k increments. In P112, the ROM occupies the first 32k +; increment and is ambiguously addressed occupying 0-1FFFFH. The upper +; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. + +BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H +BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H +BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H +BNKU EQU 00H ; User Area Bank 58000H + ; (set to 0 to disable) +BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H +BNKM EQU BID_RAMM ; Maximum Bank # F8000H + ; With both on-board RAMs only (MEM1 or MEM2), + ; the maximum Bank number is 11 (0BH). + +;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== + +CNTLA0 EQU 00H ; Control Port ASCI 0 +CNTLA1 EQU 01H ; Control Port ASCI 1 +STAT0 EQU 04H ; Serial port 0 Status +STAT1 EQU 05H ; Serial port 1 Status +TDR0 EQU 06H ; Serial port 0 Output Data +TDR1 EQU 07H ; Serial port 1 Output Data +RDR0 EQU 08H ; Serial port 0 Input Data +RDR1 EQU 09H ; Serial Port 1 Input Data +CNTR EQU 0AH ; HD64180 Counter port +TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) +TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) +RLDR0L EQU 0EH ; CTC0 Reload Count, Low +RLDR0H EQU 0FH ; CTC0 Reload Count, High +TCR EQU 10H ; Interrupt Control Register +TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) +TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) +RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) +RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) +FRC EQU 18H ; Free-Running Counter +CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) +SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) +MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) +DSTAT EQU 30H ; DMA Status/Control port +DMODE EQU 31H ; DMA Mode Control port +DCNTL EQU 32H ; DMA/WAIT Control Register +IL EQU 33H ; Interrupt Segment Register +ITC EQU 34H ; Interrupt/Trap Control Register +RCR EQU 36H ; HD64180 Refresh Control register +CBR EQU 38H ; MMU Common Base Register +BBR EQU 39H ; MMU Bank Base Register +CBAR EQU 3AH ; MMU Common/Bank Area Register +OMCR EQU 3EH ; Operation Mode Control Reg +ICR EQU 3FH ; I/O Control Register + +; Some bit definitions used with the Z-180 on-chip peripherals: + +TDRE EQU 02H ; ACSI Transmitter Buffer Empty +RDRF EQU 80H ; ACSI Received Character available + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Extended Features of Z80182 for P112 + +WSGCS EQU 0D8H ; Wait-State Generator CS +ENH182 EQU 0D9H ; Z80182 Enhancements Register +PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register +RAMUBR EQU 0E6H ; RAM End Boundary +RAMLBR EQU 0E7H ; RAM Start Boundary +ROMBR EQU 0E8H ; ROM Boundary +FIFOCTL EQU 0E9H ; FIFO Control Register +RTOTC EQU 0EAH ; RX Time-Out Time Constant +TTOTC EQU 0EBH ; TX Time-Out Time Constant +FCR EQU 0ECH ; FIFO Register +SCR EQU 0EFH ; System Pin Control +RBR EQU 0F0H ; MIMIC RX Buffer Register (R) +THR EQU 0F0H ; MIMIN TX Holding Register (W) +IER EQU 0F1H ; Interrupt Enable Register +LCR EQU 0F3H ; Line Control Register +MCR EQU 0F4H ; Modem Control Register +LSR EQU 0F5H ; Line Status Register +MDMSR EQU 0F6H ; Modem Status Register +MSCR EQU 0F7H ; MIMIC Scratch Register +DLATL EQU 0F8H ; Divisor Latch (Low) +DLATM EQU 0F9H ; Divisor Latch (High) +TTCR EQU 0FAH ; TX Time Constant +RTCR EQU 0FBH ; RX Time Constant +IVEC EQU 0FCH ; MIMIC Interrupt Vector +MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register +IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register +MMCR EQU 0FFH ; MIMIC Master Control Register + +; Z80182 PIO Registers + +DDRA EQU 0EDH ; Data Direction Register A +DRA EQU 0EEH ; Port A Data +DDRB EQU 0E4H ; Data Direction Register B +DRB EQU 0E5H ; Data B Data +DDRC EQU 0DDH ; Data Direction Register C +DRC EQU 0DEH ; Data C Data + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; ESCC Registers on Z80182 + +SCCACNT EQU 0E0H ; ESCC Control Channel A +SCCAD EQU 0E1H ; ESCC Data Channel A +SCCBCNT EQU 0E2H ; ESCC Control Channel B +SCCBD EQU 0E3H ; ESCC Data Channel B + +; [E]SCC Internal Register Definitions + +RR0 EQU 00H +RR1 EQU 01H +RR2 EQU 02H +RR3 EQU 03H +RR6 EQU 06H +RR7 EQU 07H +RR10 EQU 0AH +RR12 EQU 0CH +RR13 EQU 0DH +RR15 EQU 0FH + +WR0 EQU 00H +WR1 EQU 01H +WR2 EQU 02H +WR3 EQU 03H +WR4 EQU 04H +WR5 EQU 05H +WR6 EQU 06H +WR7 EQU 07H +WR9 EQU 09H +WR10 EQU 0AH +WR11 EQU 0BH +WR12 EQU 0CH +WR13 EQU 0DH +WR14 EQU 0EH +WR15 EQU 0FH + +; FDC37C665/6 Parallel Port in Standard AT Mode + +DPORT EQU 8CH ; Data Port +SPORT EQU 8DH ; Status Port +CPORT EQU 8EH ; Control Port + +; FDC37C665/6 Configuration Control (access internal registers) + +CFCNTL EQU 90H ; Configuration control port +CFDATA EQU 91H ; Configuration data port + +; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) + +DCR EQU 92H ; Drive Control Register (Digital Output) +MSR EQU 94H ; Main Status Register +DR EQU 95H ; Data/Command Register +DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 + +_DMA EQU 0A0H ; Diskette DMA Address + +; FDC37C665/6 Serial Port (National 16550 compatible) + +_RBR EQU 68H ;R Receiver Buffer +_THR EQU 68H ;W Transmit Holding Reg +_IER EQU 69H ;RW Interrupt-Enable Reg +_IIR EQU 6AH ;R Interrupt Ident. Reg +_FCR EQU 6AH ;W FIFO Control Reg +_LCR EQU 6BH ;RW Line Control Reg +_MCR EQU 6CH ;RW Modem Control Reg +_LSR EQU 6DH ;RW Line Status Reg +_MMSR EQU 6EH ;RW Modem Status Reg +_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) +_DDL EQU 68H ;RW Divisor LSB | wih DLAB +_DLM EQU 69H ;RW Divisor MSB | set High + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates for the National DP8490/NCR 5380 Prototype SCSI controller + + IF HARDDSK +NCR EQU 40H ; Base of NCR 5380 + +; 5380 Chip Registers + +NCRDAT EQU NCR ; Current SCSI Data (Read) + ; Output Data Register (Write) +NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) +NCRMOD EQU NCR+2 ; Mode Register (Read/Write) +NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) +NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) +NCRST EQU NCR+5 ; Bus & Status Register (Read) + ; Start DMA Send (Write) +NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) + ; Start DMA Initiator Receive (Write) +DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) + +; Bit Assignments for NCR 5380 Ports as indicated + +B_ARST EQU 10000000B ; Assert *RST (NCRCMD) +B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) +B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) +B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) + +B_BSY EQU 01000000B ; *Busy (NCRBUS) +B_REQ EQU 00100000B ; *Request (NCRBUS) +B_MSG EQU 00010000B ; *Message (NCRBUS) +B_CD EQU 00001000B ; *Command/Data (NCRBUS) +B_IO EQU 00000100B ; *I/O (NCRBUS) +B_SEL EQU 00000010B ; *Select (NCRBUS) + +B_PHAS EQU 00001000B ; Phase Match (NCRST) +B_BBSY EQU 00000100B ; Bus Busy (NCRST) + +B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) +B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) + ENDIF ;harddsk + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) +; Set the base GIDE equate to the jumper setting on the GIDE board. + + IF IDE +GIDE EQU 50H ; Set base of 16 byte address range + +IDEDOR EQU GIDE+6 ; Digital Output Register +IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) +IDEErr EQU GIDE+9 ; IDE Error Register +IDESCnt EQU GIDE+0AH ; IDE Sector Count Register +IDESNum EQU GIDE+0BH ; IDE Sector Number Register +IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) +IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) +IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register +IDECmd EQU GIDE+0FH ; IDE Command/Status Register + +CMDHOM EQU 10H ; Home Drive Heads +CMDRD EQU 20H ; Read Sector Command (w/retry) +CMDWR EQU 30H ; Write Sector Command (w/retry) +CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) +CMDFMT EQU 50H ; Format Track Command +CMDDIAG EQU 90H ; Execute Diagnostics Command +CMDINIT EQU 91H ; Initialize Drive Params Command +CMDPW0 EQU 0E0H ; Low Range of Power Control Commands +CMDPW3 EQU 0E3H ; High Range of Power Control Commands +CMDPWQ EQU 0E5H ; Power Status Query Command +CMDID EQU 0ECH ; Read Drive Ident Data Command + ENDIF ;ide +;=================== End Unique Equates ======================= + \ No newline at end of file diff --git a/Source/BPBIOS/def-ww-z33.lib b/Source/BPBIOS/def-ww-z33t.lib similarity index 96% rename from Source/BPBIOS/def-ww-z33.lib rename to Source/BPBIOS/def-ww-z33t.lib index 307c7ccc..4a09616a 100644 --- a/Source/BPBIOS/def-ww-z33.lib +++ b/Source/BPBIOS/def-ww-z33t.lib @@ -34,6 +34,9 @@ FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU NO ; Internal HBIOS Mini Proxy +CONF_T EQU YES ; Set for Segment Configuration T +CONF_N EQU NO ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/def-ww-z33bnk.lib b/Source/BPBIOS/def-ww-z33tbnk.lib similarity index 95% rename from Source/BPBIOS/def-ww-z33bnk.lib rename to Source/BPBIOS/def-ww-z33tbnk.lib index dc03758b..fffbe7ac 100644 --- a/Source/BPBIOS/def-ww-z33bnk.lib +++ b/Source/BPBIOS/def-ww-z33tbnk.lib @@ -33,7 +33,10 @@ MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? -HAVIOP EQU no ; Include IOP code into Jump table? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU NO ; Internal HBIOS Mini Proxy +CONF_T EQU YES ; Set for Segment Configuration T +CONF_N EQU NO ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/def-ww-z34n.lib b/Source/BPBIOS/def-ww-z34n.lib new file mode 100644 index 00000000..865301ea --- /dev/null +++ b/Source/BPBIOS/def-ww-z34n.lib @@ -0,0 +1,373 @@ +;:::::::::::::::::::::::::::::::::::::::::::::::********************** +; B/P BIOS Configuration and Equate File. ** System Dependant ** +; - D-X Designs Pty Ltd P112 CPU Board - ********************** +; Tailor your system here. +; +; 30 Aug 01 - Cleaned up for GPL release. HFB +; 11 May 97 - Added GIDE and adjusted HD equates. HFB +; 5 Jan 97 - Reformatted to Standard. HFB +; 10 Jun 96 - Initial Test Release. HFB +;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +; BIOS Configuration Equates and Macros + +DATE MACRO + DEFB '17 Jan 14' ; Date of this version + ENDM + +AUTOCL MACRO + DEFB 8,'ZEX Z34 ',0 ; Autostart command line + ENDM + +;--- Basic System and Z-System Section --- + +MOVCPM EQU no ; Integrate into MOVCPM "type" loader? + IF MOVCPM +VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) + ELSE +VERS EQU 21H ; Version number w/Device Swapping permitted + ENDIF +BANKED EQU NO ; Is this a banked BIOS? +ZSDOS2 EQU NO ; Yes = Banked Dos, No = CP/M 2.2 Compatible +INROM EQU NO ; Alternate bank in ROM? +MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) +FASTWB EQU YES ; Yes if restoring CPR from banked RAM + ; ..No if restoring from Drive A +Z3 EQU YES ; Include ZCPR init code? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N + +;--- Memory configuration Section --- (Expansion Memory configured here) + +IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) + ; No = Include Common RAM transfer buffer + +;--- Character Device Section --- + +MORDEV EQU NO ; YES = Include any extra Char Device Drivers + ; NO = Only use the 4 defined Char Devices +ESCC_B EQU no ; Include ESCC Channel B Driver? + ; The following two devices result in non-standard data rates + ; with the standard 16.00 MHz crystal in the P112. If a more + ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) + ; is used, the ports become usable. + ; Driver code for ASCI0 and ASCI1 includes an option for + ; assembling Polled or Interrupt-driven buffered input. + ; Select the desired option for ASCI0 with the BUFFA0 flag, + ; and BUFFA1 for ASCI1. +ASCI_0 EQU false ; Include ASCI0 Driver? +BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? +ASCI_1 EQU false ; Include ASCI1 Driver? +BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? + +QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) + ; ..must be 2^n with n<8 +RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? +XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? + +;--- Clock and Time Section --- + +CLOCK EQU YES ; Include ZSDOS Clock Driver Code? +DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? +CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) +TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) + +;--- Floppy Diskette Section --- + +BIOERM EQU yes ; Print BIOS error messages? +CALCSK EQU YES ; Calculate skew table? +AUTOSL EQU YES ; Auto select floppy formats? + ; If AUTOSL=True, the next two are active... +FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? +FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? +FLOPY8 EQU no ; Include 8" Floppy Formats? +MORDPB EQU NO ; Include additional Floppy DPB Formats? + +;--- RAM Disk Section --- + +RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made + +;--- Hard Disk Section --- + +HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only + ; (Pick 1 of 3 options below) +SCSI EQU NO ; YES = Use SCSI Driver +IDE EQU NO ; YES = Use IDE Driver +HDSK EQU YES ; YES = Use SIMH HDSK Driver +HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? + ; (DMA not implemented for GIDE) +UNIT_0 EQU YES ; Hard Disk Physical Unit 1 +UNIT_1 EQU YES ; Hard Disk Physical Unit 2 +UNIT_2 EQU YES ; Hard Disk Physical Unit 3 + +;--- Logical Drive Section --- + +DRV_A EQU no ; Set each of these equates for the drive and +DRV_B EQU no ; partition complement of your system. Assume +DRV_C EQU no ; that A-D are Floppies. +DRV_D EQU no +DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk +DRV_F EQU yes ; Partitions +DRV_G EQU yes +DRV_H EQU yes +DRV_I EQU yes +DRV_J EQU yes +DRV_K EQU yes +DRV_L EQU yes +DRV_M EQU RAMDSK ; This is Yes for RAM drive +DRV_N EQU yes +DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled +DRV_P EQU no + +;========== Configuration Unique Equates (P112) =========== +;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< +;>>> Do NOT Alter these unless you KNOW what you're doing <<< +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +REFRSH EQU NO ; Set to NO for only Static RAM, needed for + ; systems with dynamic RAMs. +NOWAIT EQU NO ; Set to NO to use configured Wait States in + ; Hard Disk Driver. Yes to eliminate Waits. + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; For Z-180/HD64180 systems, The Bank numbers should reflect Physical +; memory in 32k increments. In P112, the ROM occupies the first 32k +; increment and is ambiguously addressed occupying 0-1FFFFH. The upper +; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. + +BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H +BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H +BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H +BNKU EQU 00H ; User Area Bank 58000H + ; (set to 0 to disable) +BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H +BNKM EQU BID_RAMM ; Maximum Bank # F8000H + ; With both on-board RAMs only (MEM1 or MEM2), + ; the maximum Bank number is 11 (0BH). + +;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== + +CNTLA0 EQU 00H ; Control Port ASCI 0 +CNTLA1 EQU 01H ; Control Port ASCI 1 +STAT0 EQU 04H ; Serial port 0 Status +STAT1 EQU 05H ; Serial port 1 Status +TDR0 EQU 06H ; Serial port 0 Output Data +TDR1 EQU 07H ; Serial port 1 Output Data +RDR0 EQU 08H ; Serial port 0 Input Data +RDR1 EQU 09H ; Serial Port 1 Input Data +CNTR EQU 0AH ; HD64180 Counter port +TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) +TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) +RLDR0L EQU 0EH ; CTC0 Reload Count, Low +RLDR0H EQU 0FH ; CTC0 Reload Count, High +TCR EQU 10H ; Interrupt Control Register +TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) +TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) +RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) +RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) +FRC EQU 18H ; Free-Running Counter +CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) +SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) +MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) +DSTAT EQU 30H ; DMA Status/Control port +DMODE EQU 31H ; DMA Mode Control port +DCNTL EQU 32H ; DMA/WAIT Control Register +IL EQU 33H ; Interrupt Segment Register +ITC EQU 34H ; Interrupt/Trap Control Register +RCR EQU 36H ; HD64180 Refresh Control register +CBR EQU 38H ; MMU Common Base Register +BBR EQU 39H ; MMU Bank Base Register +CBAR EQU 3AH ; MMU Common/Bank Area Register +OMCR EQU 3EH ; Operation Mode Control Reg +ICR EQU 3FH ; I/O Control Register + +; Some bit definitions used with the Z-180 on-chip peripherals: + +TDRE EQU 02H ; ACSI Transmitter Buffer Empty +RDRF EQU 80H ; ACSI Received Character available + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Extended Features of Z80182 for P112 + +WSGCS EQU 0D8H ; Wait-State Generator CS +ENH182 EQU 0D9H ; Z80182 Enhancements Register +PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register +RAMUBR EQU 0E6H ; RAM End Boundary +RAMLBR EQU 0E7H ; RAM Start Boundary +ROMBR EQU 0E8H ; ROM Boundary +FIFOCTL EQU 0E9H ; FIFO Control Register +RTOTC EQU 0EAH ; RX Time-Out Time Constant +TTOTC EQU 0EBH ; TX Time-Out Time Constant +FCR EQU 0ECH ; FIFO Register +SCR EQU 0EFH ; System Pin Control +RBR EQU 0F0H ; MIMIC RX Buffer Register (R) +THR EQU 0F0H ; MIMIN TX Holding Register (W) +IER EQU 0F1H ; Interrupt Enable Register +LCR EQU 0F3H ; Line Control Register +MCR EQU 0F4H ; Modem Control Register +LSR EQU 0F5H ; Line Status Register +MDMSR EQU 0F6H ; Modem Status Register +MSCR EQU 0F7H ; MIMIC Scratch Register +DLATL EQU 0F8H ; Divisor Latch (Low) +DLATM EQU 0F9H ; Divisor Latch (High) +TTCR EQU 0FAH ; TX Time Constant +RTCR EQU 0FBH ; RX Time Constant +IVEC EQU 0FCH ; MIMIC Interrupt Vector +MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register +IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register +MMCR EQU 0FFH ; MIMIC Master Control Register + +; Z80182 PIO Registers + +DDRA EQU 0EDH ; Data Direction Register A +DRA EQU 0EEH ; Port A Data +DDRB EQU 0E4H ; Data Direction Register B +DRB EQU 0E5H ; Data B Data +DDRC EQU 0DDH ; Data Direction Register C +DRC EQU 0DEH ; Data C Data + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; ESCC Registers on Z80182 + +SCCACNT EQU 0E0H ; ESCC Control Channel A +SCCAD EQU 0E1H ; ESCC Data Channel A +SCCBCNT EQU 0E2H ; ESCC Control Channel B +SCCBD EQU 0E3H ; ESCC Data Channel B + +; [E]SCC Internal Register Definitions + +RR0 EQU 00H +RR1 EQU 01H +RR2 EQU 02H +RR3 EQU 03H +RR6 EQU 06H +RR7 EQU 07H +RR10 EQU 0AH +RR12 EQU 0CH +RR13 EQU 0DH +RR15 EQU 0FH + +WR0 EQU 00H +WR1 EQU 01H +WR2 EQU 02H +WR3 EQU 03H +WR4 EQU 04H +WR5 EQU 05H +WR6 EQU 06H +WR7 EQU 07H +WR9 EQU 09H +WR10 EQU 0AH +WR11 EQU 0BH +WR12 EQU 0CH +WR13 EQU 0DH +WR14 EQU 0EH +WR15 EQU 0FH + +; FDC37C665/6 Parallel Port in Standard AT Mode + +DPORT EQU 8CH ; Data Port +SPORT EQU 8DH ; Status Port +CPORT EQU 8EH ; Control Port + +; FDC37C665/6 Configuration Control (access internal registers) + +CFCNTL EQU 90H ; Configuration control port +CFDATA EQU 91H ; Configuration data port + +; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) + +DCR EQU 92H ; Drive Control Register (Digital Output) +MSR EQU 94H ; Main Status Register +DR EQU 95H ; Data/Command Register +DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 + +_DMA EQU 0A0H ; Diskette DMA Address + +; FDC37C665/6 Serial Port (National 16550 compatible) + +_RBR EQU 68H ;R Receiver Buffer +_THR EQU 68H ;W Transmit Holding Reg +_IER EQU 69H ;RW Interrupt-Enable Reg +_IIR EQU 6AH ;R Interrupt Ident. Reg +_FCR EQU 6AH ;W FIFO Control Reg +_LCR EQU 6BH ;RW Line Control Reg +_MCR EQU 6CH ;RW Modem Control Reg +_LSR EQU 6DH ;RW Line Status Reg +_MMSR EQU 6EH ;RW Modem Status Reg +_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) +_DDL EQU 68H ;RW Divisor LSB | wih DLAB +_DLM EQU 69H ;RW Divisor MSB | set High + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates for the National DP8490/NCR 5380 Prototype SCSI controller + + IF HARDDSK +NCR EQU 40H ; Base of NCR 5380 + +; 5380 Chip Registers + +NCRDAT EQU NCR ; Current SCSI Data (Read) + ; Output Data Register (Write) +NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) +NCRMOD EQU NCR+2 ; Mode Register (Read/Write) +NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) +NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) +NCRST EQU NCR+5 ; Bus & Status Register (Read) + ; Start DMA Send (Write) +NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) + ; Start DMA Initiator Receive (Write) +DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) + +; Bit Assignments for NCR 5380 Ports as indicated + +B_ARST EQU 10000000B ; Assert *RST (NCRCMD) +B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) +B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) +B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) + +B_BSY EQU 01000000B ; *Busy (NCRBUS) +B_REQ EQU 00100000B ; *Request (NCRBUS) +B_MSG EQU 00010000B ; *Message (NCRBUS) +B_CD EQU 00001000B ; *Command/Data (NCRBUS) +B_IO EQU 00000100B ; *I/O (NCRBUS) +B_SEL EQU 00000010B ; *Select (NCRBUS) + +B_PHAS EQU 00001000B ; Phase Match (NCRST) +B_BBSY EQU 00000100B ; Bus Busy (NCRST) + +B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) +B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) + ENDIF ;harddsk + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) +; Set the base GIDE equate to the jumper setting on the GIDE board. + + IF IDE +GIDE EQU 50H ; Set base of 16 byte address range + +IDEDOR EQU GIDE+6 ; Digital Output Register +IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) +IDEErr EQU GIDE+9 ; IDE Error Register +IDESCnt EQU GIDE+0AH ; IDE Sector Count Register +IDESNum EQU GIDE+0BH ; IDE Sector Number Register +IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) +IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) +IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register +IDECmd EQU GIDE+0FH ; IDE Command/Status Register + +CMDHOM EQU 10H ; Home Drive Heads +CMDRD EQU 20H ; Read Sector Command (w/retry) +CMDWR EQU 30H ; Write Sector Command (w/retry) +CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) +CMDFMT EQU 50H ; Format Track Command +CMDDIAG EQU 90H ; Execute Diagnostics Command +CMDINIT EQU 91H ; Initialize Drive Params Command +CMDPW0 EQU 0E0H ; Low Range of Power Control Commands +CMDPW3 EQU 0E3H ; High Range of Power Control Commands +CMDPWQ EQU 0E5H ; Power Status Query Command +CMDID EQU 0ECH ; Read Drive Ident Data Command + ENDIF ;ide +;=================== End Unique Equates ======================= + \ No newline at end of file diff --git a/Source/BPBIOS/def-ww-z34nbnk.lib b/Source/BPBIOS/def-ww-z34nbnk.lib new file mode 100644 index 00000000..f64eb30e --- /dev/null +++ b/Source/BPBIOS/def-ww-z34nbnk.lib @@ -0,0 +1,373 @@ +;:::::::::::::::::::::::::::::::::::::::::::::::********************** +; B/P BIOS Configuration and Equate File. ** System Dependant ** +; - D-X Designs Pty Ltd P112 CPU Board - ********************** +; Tailor your system here. +; +; 30 Aug 01 - Cleaned up for GPL release. HFB +; 11 May 97 - Added GIDE and adjusted HD equates. HFB +; 5 Jan 97 - Reformatted to Standard. HFB +; 10 Jun 96 - Initial Test Release. HFB +;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +; BIOS Configuration Equates and Macros + +DATE MACRO + DEFB '17 Jan 14' ; Date of this version + ENDM + +AUTOCL MACRO + DEFB 8,'ZEX Z34 ',0 ; Autostart command line + ENDM + +;--- Basic System and Z-System Section --- + +MOVCPM EQU no ; Integrate into MOVCPM "type" loader? + IF MOVCPM +VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) + ELSE +VERS EQU 21H ; Version number w/Device Swapping permitted + ENDIF +BANKED EQU YES ; Is this a banked BIOS? +ZSDOS2 EQU NO ; Yes = Banked Dos, No = CP/M 2.2 Compatible +INROM EQU NO ; Alternate bank in ROM? +MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) +FASTWB EQU YES ; Yes if restoring CPR from banked RAM + ; ..No if restoring from Drive A +Z3 EQU YES ; Include ZCPR init code? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N + +;--- Memory configuration Section --- (Expansion Memory configured here) + +IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) + ; No = Include Common RAM transfer buffer + +;--- Character Device Section --- + +MORDEV EQU NO ; YES = Include any extra Char Device Drivers + ; NO = Only use the 4 defined Char Devices +ESCC_B EQU no ; Include ESCC Channel B Driver? + ; The following two devices result in non-standard data rates + ; with the standard 16.00 MHz crystal in the P112. If a more + ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) + ; is used, the ports become usable. + ; Driver code for ASCI0 and ASCI1 includes an option for + ; assembling Polled or Interrupt-driven buffered input. + ; Select the desired option for ASCI0 with the BUFFA0 flag, + ; and BUFFA1 for ASCI1. +ASCI_0 EQU false ; Include ASCI0 Driver? +BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? +ASCI_1 EQU false ; Include ASCI1 Driver? +BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? + +QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) + ; ..must be 2^n with n<8 +RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? +XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? + +;--- Clock and Time Section --- + +CLOCK EQU YES ; Include ZSDOS Clock Driver Code? +DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? +CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) +TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) + +;--- Floppy Diskette Section --- + +BIOERM EQU yes ; Print BIOS error messages? +CALCSK EQU YES ; Calculate skew table? +AUTOSL EQU YES ; Auto select floppy formats? + ; If AUTOSL=True, the next two are active... +FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? +FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? +FLOPY8 EQU no ; Include 8" Floppy Formats? +MORDPB EQU NO ; Include additional Floppy DPB Formats? + +;--- RAM Disk Section --- + +RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made + +;--- Hard Disk Section --- + +HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only + ; (Pick 1 of 3 options below) +SCSI EQU NO ; YES = Use SCSI Driver +IDE EQU NO ; YES = Use IDE Driver +HDSK EQU YES ; YES = Use SIMH HDSK Driver +HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? + ; (DMA not implemented for GIDE) +UNIT_0 EQU YES ; Hard Disk Physical Unit 1 +UNIT_1 EQU YES ; Hard Disk Physical Unit 2 +UNIT_2 EQU YES ; Hard Disk Physical Unit 3 + +;--- Logical Drive Section --- + +DRV_A EQU no ; Set each of these equates for the drive and +DRV_B EQU no ; partition complement of your system. Assume +DRV_C EQU no ; that A-D are Floppies. +DRV_D EQU no +DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk +DRV_F EQU yes ; Partitions +DRV_G EQU yes +DRV_H EQU yes +DRV_I EQU yes +DRV_J EQU yes +DRV_K EQU yes +DRV_L EQU yes +DRV_M EQU RAMDSK ; This is Yes for RAM drive +DRV_N EQU yes +DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled +DRV_P EQU no + +;========== Configuration Unique Equates (P112) =========== +;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< +;>>> Do NOT Alter these unless you KNOW what you're doing <<< +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +REFRSH EQU NO ; Set to NO for only Static RAM, needed for + ; systems with dynamic RAMs. +NOWAIT EQU NO ; Set to NO to use configured Wait States in + ; Hard Disk Driver. Yes to eliminate Waits. + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; For Z-180/HD64180 systems, The Bank numbers should reflect Physical +; memory in 32k increments. In P112, the ROM occupies the first 32k +; increment and is ambiguously addressed occupying 0-1FFFFH. The upper +; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. + +BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H +BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H +BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H +BNKU EQU 00H ; User Area Bank 58000H + ; (set to 0 to disable) +BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H +BNKM EQU BID_RAMM ; Maximum Bank # F8000H + ; With both on-board RAMs only (MEM1 or MEM2), + ; the maximum Bank number is 11 (0BH). + +;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== + +CNTLA0 EQU 00H ; Control Port ASCI 0 +CNTLA1 EQU 01H ; Control Port ASCI 1 +STAT0 EQU 04H ; Serial port 0 Status +STAT1 EQU 05H ; Serial port 1 Status +TDR0 EQU 06H ; Serial port 0 Output Data +TDR1 EQU 07H ; Serial port 1 Output Data +RDR0 EQU 08H ; Serial port 0 Input Data +RDR1 EQU 09H ; Serial Port 1 Input Data +CNTR EQU 0AH ; HD64180 Counter port +TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) +TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) +RLDR0L EQU 0EH ; CTC0 Reload Count, Low +RLDR0H EQU 0FH ; CTC0 Reload Count, High +TCR EQU 10H ; Interrupt Control Register +TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) +TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) +RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) +RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) +FRC EQU 18H ; Free-Running Counter +CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) +SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) +MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) +DSTAT EQU 30H ; DMA Status/Control port +DMODE EQU 31H ; DMA Mode Control port +DCNTL EQU 32H ; DMA/WAIT Control Register +IL EQU 33H ; Interrupt Segment Register +ITC EQU 34H ; Interrupt/Trap Control Register +RCR EQU 36H ; HD64180 Refresh Control register +CBR EQU 38H ; MMU Common Base Register +BBR EQU 39H ; MMU Bank Base Register +CBAR EQU 3AH ; MMU Common/Bank Area Register +OMCR EQU 3EH ; Operation Mode Control Reg +ICR EQU 3FH ; I/O Control Register + +; Some bit definitions used with the Z-180 on-chip peripherals: + +TDRE EQU 02H ; ACSI Transmitter Buffer Empty +RDRF EQU 80H ; ACSI Received Character available + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Extended Features of Z80182 for P112 + +WSGCS EQU 0D8H ; Wait-State Generator CS +ENH182 EQU 0D9H ; Z80182 Enhancements Register +PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register +RAMUBR EQU 0E6H ; RAM End Boundary +RAMLBR EQU 0E7H ; RAM Start Boundary +ROMBR EQU 0E8H ; ROM Boundary +FIFOCTL EQU 0E9H ; FIFO Control Register +RTOTC EQU 0EAH ; RX Time-Out Time Constant +TTOTC EQU 0EBH ; TX Time-Out Time Constant +FCR EQU 0ECH ; FIFO Register +SCR EQU 0EFH ; System Pin Control +RBR EQU 0F0H ; MIMIC RX Buffer Register (R) +THR EQU 0F0H ; MIMIN TX Holding Register (W) +IER EQU 0F1H ; Interrupt Enable Register +LCR EQU 0F3H ; Line Control Register +MCR EQU 0F4H ; Modem Control Register +LSR EQU 0F5H ; Line Status Register +MDMSR EQU 0F6H ; Modem Status Register +MSCR EQU 0F7H ; MIMIC Scratch Register +DLATL EQU 0F8H ; Divisor Latch (Low) +DLATM EQU 0F9H ; Divisor Latch (High) +TTCR EQU 0FAH ; TX Time Constant +RTCR EQU 0FBH ; RX Time Constant +IVEC EQU 0FCH ; MIMIC Interrupt Vector +MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register +IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register +MMCR EQU 0FFH ; MIMIC Master Control Register + +; Z80182 PIO Registers + +DDRA EQU 0EDH ; Data Direction Register A +DRA EQU 0EEH ; Port A Data +DDRB EQU 0E4H ; Data Direction Register B +DRB EQU 0E5H ; Data B Data +DDRC EQU 0DDH ; Data Direction Register C +DRC EQU 0DEH ; Data C Data + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; ESCC Registers on Z80182 + +SCCACNT EQU 0E0H ; ESCC Control Channel A +SCCAD EQU 0E1H ; ESCC Data Channel A +SCCBCNT EQU 0E2H ; ESCC Control Channel B +SCCBD EQU 0E3H ; ESCC Data Channel B + +; [E]SCC Internal Register Definitions + +RR0 EQU 00H +RR1 EQU 01H +RR2 EQU 02H +RR3 EQU 03H +RR6 EQU 06H +RR7 EQU 07H +RR10 EQU 0AH +RR12 EQU 0CH +RR13 EQU 0DH +RR15 EQU 0FH + +WR0 EQU 00H +WR1 EQU 01H +WR2 EQU 02H +WR3 EQU 03H +WR4 EQU 04H +WR5 EQU 05H +WR6 EQU 06H +WR7 EQU 07H +WR9 EQU 09H +WR10 EQU 0AH +WR11 EQU 0BH +WR12 EQU 0CH +WR13 EQU 0DH +WR14 EQU 0EH +WR15 EQU 0FH + +; FDC37C665/6 Parallel Port in Standard AT Mode + +DPORT EQU 8CH ; Data Port +SPORT EQU 8DH ; Status Port +CPORT EQU 8EH ; Control Port + +; FDC37C665/6 Configuration Control (access internal registers) + +CFCNTL EQU 90H ; Configuration control port +CFDATA EQU 91H ; Configuration data port + +; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) + +DCR EQU 92H ; Drive Control Register (Digital Output) +MSR EQU 94H ; Main Status Register +DR EQU 95H ; Data/Command Register +DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 + +_DMA EQU 0A0H ; Diskette DMA Address + +; FDC37C665/6 Serial Port (National 16550 compatible) + +_RBR EQU 68H ;R Receiver Buffer +_THR EQU 68H ;W Transmit Holding Reg +_IER EQU 69H ;RW Interrupt-Enable Reg +_IIR EQU 6AH ;R Interrupt Ident. Reg +_FCR EQU 6AH ;W FIFO Control Reg +_LCR EQU 6BH ;RW Line Control Reg +_MCR EQU 6CH ;RW Modem Control Reg +_LSR EQU 6DH ;RW Line Status Reg +_MMSR EQU 6EH ;RW Modem Status Reg +_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) +_DDL EQU 68H ;RW Divisor LSB | wih DLAB +_DLM EQU 69H ;RW Divisor MSB | set High + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates for the National DP8490/NCR 5380 Prototype SCSI controller + + IF HARDDSK +NCR EQU 40H ; Base of NCR 5380 + +; 5380 Chip Registers + +NCRDAT EQU NCR ; Current SCSI Data (Read) + ; Output Data Register (Write) +NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) +NCRMOD EQU NCR+2 ; Mode Register (Read/Write) +NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) +NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) +NCRST EQU NCR+5 ; Bus & Status Register (Read) + ; Start DMA Send (Write) +NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) + ; Start DMA Initiator Receive (Write) +DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) + +; Bit Assignments for NCR 5380 Ports as indicated + +B_ARST EQU 10000000B ; Assert *RST (NCRCMD) +B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) +B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) +B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) + +B_BSY EQU 01000000B ; *Busy (NCRBUS) +B_REQ EQU 00100000B ; *Request (NCRBUS) +B_MSG EQU 00010000B ; *Message (NCRBUS) +B_CD EQU 00001000B ; *Command/Data (NCRBUS) +B_IO EQU 00000100B ; *I/O (NCRBUS) +B_SEL EQU 00000010B ; *Select (NCRBUS) + +B_PHAS EQU 00001000B ; Phase Match (NCRST) +B_BBSY EQU 00000100B ; Bus Busy (NCRST) + +B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) +B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) + ENDIF ;harddsk + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) +; Set the base GIDE equate to the jumper setting on the GIDE board. + + IF IDE +GIDE EQU 50H ; Set base of 16 byte address range + +IDEDOR EQU GIDE+6 ; Digital Output Register +IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) +IDEErr EQU GIDE+9 ; IDE Error Register +IDESCnt EQU GIDE+0AH ; IDE Sector Count Register +IDESNum EQU GIDE+0BH ; IDE Sector Number Register +IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) +IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) +IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register +IDECmd EQU GIDE+0FH ; IDE Command/Status Register + +CMDHOM EQU 10H ; Home Drive Heads +CMDRD EQU 20H ; Read Sector Command (w/retry) +CMDWR EQU 30H ; Write Sector Command (w/retry) +CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) +CMDFMT EQU 50H ; Format Track Command +CMDDIAG EQU 90H ; Execute Diagnostics Command +CMDINIT EQU 91H ; Initialize Drive Params Command +CMDPW0 EQU 0E0H ; Low Range of Power Control Commands +CMDPW3 EQU 0E3H ; High Range of Power Control Commands +CMDPWQ EQU 0E5H ; Power Status Query Command +CMDID EQU 0ECH ; Read Drive Ident Data Command + ENDIF ;ide +;=================== End Unique Equates ======================= + \ No newline at end of file diff --git a/Source/BPBIOS/def-ww-z34.lib b/Source/BPBIOS/def-ww-z34t.lib similarity index 95% rename from Source/BPBIOS/def-ww-z34.lib rename to Source/BPBIOS/def-ww-z34t.lib index df947672..cfb06fad 100644 --- a/Source/BPBIOS/def-ww-z34.lib +++ b/Source/BPBIOS/def-ww-z34t.lib @@ -33,7 +33,10 @@ MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? -HAVIOP EQU no ; Include IOP code into Jump table? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU NO ; Internal HBIOS Mini Proxy +CONF_T EQU YES ; Set for Segment Configuration T +CONF_N EQU NO ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/def-ww-z34bnk.lib b/Source/BPBIOS/def-ww-z34tbnk.lib similarity index 95% rename from Source/BPBIOS/def-ww-z34bnk.lib rename to Source/BPBIOS/def-ww-z34tbnk.lib index e80eb05a..dbb99554 100644 --- a/Source/BPBIOS/def-ww-z34bnk.lib +++ b/Source/BPBIOS/def-ww-z34tbnk.lib @@ -33,7 +33,10 @@ MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? -HAVIOP EQU no ; Include IOP code into Jump table? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU NO ; Internal HBIOS Mini Proxy +CONF_T EQU YES ; Set for Segment Configuration T +CONF_N EQU NO ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/def-ww-z41nbnk.lib b/Source/BPBIOS/def-ww-z41nbnk.lib new file mode 100644 index 00000000..1e2b4570 --- /dev/null +++ b/Source/BPBIOS/def-ww-z41nbnk.lib @@ -0,0 +1,372 @@ +;:::::::::::::::::::::::::::::::::::::::::::::::********************** +; B/P BIOS Configuration and Equate File. ** System Dependant ** +; - D-X Designs Pty Ltd P112 CPU Board - ********************** +; Tailor your system here. +; +; 30 Aug 01 - Cleaned up for GPL release. HFB +; 11 May 97 - Added GIDE and adjusted HD equates. HFB +; 5 Jan 97 - Reformatted to Standard. HFB +; 10 Jun 96 - Initial Test Release. HFB +;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +; BIOS Configuration Equates and Macros + +DATE MACRO + DEFB '17 Jan 14' ; Date of this version + ENDM + +AUTOCL MACRO + DEFB 8,'ZEX Z41 ',0 ; Autostart command line + ENDM + +;--- Basic System and Z-System Section --- + +MOVCPM EQU no ; Integrate into MOVCPM "type" loader? + IF MOVCPM +VERS EQU 13H ; Version number in BCD (Hex) (Major/Minor) + ELSE +VERS EQU 21H ; Version number w/Device Swapping permitted + ENDIF +BANKED EQU YES ; Is this a banked BIOS? +ZSDOS2 EQU YES ; Yes = Banked Dos, No = CP/M 2.2 Compatible +INROM EQU NO ; Alternate bank in ROM? +MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) +FASTWB EQU YES ; Yes if restoring CPR from banked RAM + ; ..No if restoring from Drive A +Z3 EQU YES ; Include ZCPR init code? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N + +;--- Memory configuration Section --- (Expansion Memory configured here) + +IBMOVS EQU NO ; Yes = Inter-bank Moves allowed (Z180/64180) + ; No = Include Common RAM transfer buffer +;--- Character Device Section --- + +MORDEV EQU NO ; YES = Include any extra Char Device Drivers + ; NO = Only use the 4 defined Char Devices +ESCC_B EQU no ; Include ESCC Channel B Driver? + ; The following two devices result in non-standard data rates + ; with the standard 16.00 MHz crystal in the P112. If a more + ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) + ; is used, the ports become usable. + ; Driver code for ASCI0 and ASCI1 includes an option for + ; assembling Polled or Interrupt-driven buffered input. + ; Select the desired option for ASCI0 with the BUFFA0 flag, + ; and BUFFA1 for ASCI1. +ASCI_0 EQU false ; Include ASCI0 Driver? +BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? +ASCI_1 EQU false ; Include ASCI1 Driver? +BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? + +QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) + ; ..must be 2^n with n<8 +RTSCTS EQU no ; Include RTS/CTS code on Serial Outputs? +XONOFF EQU no ; Include Xon/Xoff handshaking in Serial lines? + +;--- Clock and Time Section --- + +CLOCK EQU YES ; Include ZSDOS Clock Driver Code? +DS1202 EQU YES ; Use Dallas DS-1202 instead of Interrupt RTC? +CLKSET EQU YES ; Allow DS-1202 Clock Sets? (Error if No) +TICTOC EQU NO ;== NOT USED IN P112 ("heartbeat" count) + +;--- Floppy Diskette Section --- + +BIOERM EQU yes ; Print BIOS error messages? +CALCSK EQU YES ; Calculate skew table? +AUTOSL EQU YES ; Auto select floppy formats? + ; If AUTOSL=True, the next two are active... +FDDMA EQU no ; Use DMA Control for Floppy Drive Transfers? +FLOPYH EQU no ; Include "Hi-Density" Floppy Formats? +FLOPY8 EQU no ; Include 8" Floppy Formats? +MORDPB EQU NO ; Include additional Floppy DPB Formats? + +;--- RAM Disk Section --- + +RAMDSK EQU YES ; YES = Make RAM-Disk Code, NO = No code made + +;--- Hard Disk Section --- + +HARDDSK EQU YES ; YES = Add Hard-disk Code, NO = Floppy Only + ; (Pick 1 of 3 options below) +SCSI EQU NO ; YES = Use SCSI Driver +IDE EQU NO ; YES = Use IDE Driver +HDSK EQU YES ; YES = Use SIMH HDSK Driver +HDDMA EQU NO ; Use DMA-Controlled Hard Disk Data Transfers? + ; (DMA not implemented for GIDE) +UNIT_0 EQU YES ; Hard Disk Physical Unit 1 +UNIT_1 EQU YES ; Hard Disk Physical Unit 2 +UNIT_2 EQU YES ; Hard Disk Physical Unit 3 + +;--- Logical Drive Section --- + +DRV_A EQU no ; Set each of these equates for the drive and +DRV_B EQU no ; partition complement of your system. Assume +DRV_C EQU no ; that A-D are Floppies. +DRV_D EQU no +DRV_E EQU yes ; Assume that E-L and N-P are Hard Disk +DRV_F EQU yes ; Partitions +DRV_G EQU yes +DRV_H EQU yes +DRV_I EQU yes +DRV_J EQU yes +DRV_K EQU yes +DRV_L EQU yes +DRV_M EQU RAMDSK ; This is Yes for RAM drive +DRV_N EQU yes +DRV_O EQU ~RAMDSK ; Use HBIOS RAM disk if BPBIOS RAM disk is not enabled +DRV_P EQU no + +;========== Configuration Unique Equates (P112) =========== +;>>>>>>>>>>>>>>>>>>>>>>>>>>> W A R N I N G <<<<<<<<<<<<<<<<<<<<<<<<<<<<< +;>>> Do NOT Alter these unless you KNOW what you're doing <<< +;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +REFRSH EQU NO ; Set to NO for only Static RAM, needed for + ; systems with dynamic RAMs. +NOWAIT EQU NO ; Set to NO to use configured Wait States in + ; Hard Disk Driver. Yes to eliminate Waits. + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; For Z-180/HD64180 systems, The Bank numbers should reflect Physical +; memory in 32k increments. In P112, the ROM occupies the first 32k +; increment and is ambiguously addressed occupying 0-1FFFFH. The upper +; memory bounds (BNKU, BNK3 and BNKM) should be set for your configuration. + +BNK0 EQU BID_USR ; First TPA Bank (switched in/out) 40000H +BNK1 EQU BID_HB ; Second TPA Bank (Common Bank) 48000H +BNK2 EQU BID_SYS ; System Bank (BIOS, DOS, CPR) 50000H +BNKU EQU 00H ; User Area Bank 58000H + ; (set to 0 to disable) +BNK3 EQU BID_RAMD ; First Bank for RAM disk 60000H +BNKM EQU BID_RAMM ; Maximum Bank # F8000H + ; With both on-board RAMs only (MEM1 or MEM2), + ; the maximum Bank number is 11 (0BH). + +;=========== CPU-dependent Equates, Zilog Z-180/Hitachi HD64180 ========== + +CNTLA0 EQU 00H ; Control Port ASCI 0 +CNTLA1 EQU 01H ; Control Port ASCI 1 +STAT0 EQU 04H ; Serial port 0 Status +STAT1 EQU 05H ; Serial port 1 Status +TDR0 EQU 06H ; Serial port 0 Output Data +TDR1 EQU 07H ; Serial port 1 Output Data +RDR0 EQU 08H ; Serial port 0 Input Data +RDR1 EQU 09H ; Serial Port 1 Input Data +CNTR EQU 0AH ; HD64180 Counter port +TMDR0L EQU 0CH ; HD64180 DMA channel reg (low) +TMDR0H EQU 0DH ; HD64180 DMA channel reg (hi) +RLDR0L EQU 0EH ; CTC0 Reload Count, Low +RLDR0H EQU 0FH ; CTC0 Reload Count, High +TCR EQU 10H ; Interrupt Control Register +TMDR1L EQU 14H ; Timer Data Reg Ch1 (Low) +TMDR1H EQU 15H ; Timer Data Reg Ch1 (High) +RLDR1L EQU 16H ; Timer Reload Reg Ch1 (Low) +RLDR1H EQU 17H ; Timer Reload Reg Ch1 (High) +FRC EQU 18H ; Free-Running Counter +CCR EQU 1FH ; CPU Control Register (ZS8180/Z80182) +SAR0L EQU 20H ; DMA Channel 0 Register start (8 ports) +MAR1L EQU 28H ; DMA Channel 1 Register start (8 ports) +DSTAT EQU 30H ; DMA Status/Control port +DMODE EQU 31H ; DMA Mode Control port +DCNTL EQU 32H ; DMA/WAIT Control Register +IL EQU 33H ; Interrupt Segment Register +ITC EQU 34H ; Interrupt/Trap Control Register +RCR EQU 36H ; HD64180 Refresh Control register +CBR EQU 38H ; MMU Common Base Register +BBR EQU 39H ; MMU Bank Base Register +CBAR EQU 3AH ; MMU Common/Bank Area Register +OMCR EQU 3EH ; Operation Mode Control Reg +ICR EQU 3FH ; I/O Control Register + +; Some bit definitions used with the Z-180 on-chip peripherals: + +TDRE EQU 02H ; ACSI Transmitter Buffer Empty +RDRF EQU 80H ; ACSI Received Character available + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Extended Features of Z80182 for P112 + +WSGCS EQU 0D8H ; Wait-State Generator CS +ENH182 EQU 0D9H ; Z80182 Enhancements Register +PINMUX EQU 0DFH ; Interrupt Edge/Pin Mux Register +RAMUBR EQU 0E6H ; RAM End Boundary +RAMLBR EQU 0E7H ; RAM Start Boundary +ROMBR EQU 0E8H ; ROM Boundary +FIFOCTL EQU 0E9H ; FIFO Control Register +RTOTC EQU 0EAH ; RX Time-Out Time Constant +TTOTC EQU 0EBH ; TX Time-Out Time Constant +FCR EQU 0ECH ; FIFO Register +SCR EQU 0EFH ; System Pin Control +RBR EQU 0F0H ; MIMIC RX Buffer Register (R) +THR EQU 0F0H ; MIMIN TX Holding Register (W) +IER EQU 0F1H ; Interrupt Enable Register +LCR EQU 0F3H ; Line Control Register +MCR EQU 0F4H ; Modem Control Register +LSR EQU 0F5H ; Line Status Register +MDMSR EQU 0F6H ; Modem Status Register +MSCR EQU 0F7H ; MIMIC Scratch Register +DLATL EQU 0F8H ; Divisor Latch (Low) +DLATM EQU 0F9H ; Divisor Latch (High) +TTCR EQU 0FAH ; TX Time Constant +RTCR EQU 0FBH ; RX Time Constant +IVEC EQU 0FCH ; MIMIC Interrupt Vector +MIMIE EQU 0FDH ; MIMIC Interrupt Enable Register +IUSIP EQU 0FEH ; MIMIC Interrupt Under-Service Register +MMCR EQU 0FFH ; MIMIC Master Control Register + +; Z80182 PIO Registers + +DDRA EQU 0EDH ; Data Direction Register A +DRA EQU 0EEH ; Port A Data +DDRB EQU 0E4H ; Data Direction Register B +DRB EQU 0E5H ; Data B Data +DDRC EQU 0DDH ; Data Direction Register C +DRC EQU 0DEH ; Data C Data + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; ESCC Registers on Z80182 + +SCCACNT EQU 0E0H ; ESCC Control Channel A +SCCAD EQU 0E1H ; ESCC Data Channel A +SCCBCNT EQU 0E2H ; ESCC Control Channel B +SCCBD EQU 0E3H ; ESCC Data Channel B + +; [E]SCC Internal Register Definitions + +RR0 EQU 00H +RR1 EQU 01H +RR2 EQU 02H +RR3 EQU 03H +RR6 EQU 06H +RR7 EQU 07H +RR10 EQU 0AH +RR12 EQU 0CH +RR13 EQU 0DH +RR15 EQU 0FH + +WR0 EQU 00H +WR1 EQU 01H +WR2 EQU 02H +WR3 EQU 03H +WR4 EQU 04H +WR5 EQU 05H +WR6 EQU 06H +WR7 EQU 07H +WR9 EQU 09H +WR10 EQU 0AH +WR11 EQU 0BH +WR12 EQU 0CH +WR13 EQU 0DH +WR14 EQU 0EH +WR15 EQU 0FH + +; FDC37C665/6 Parallel Port in Standard AT Mode + +DPORT EQU 8CH ; Data Port +SPORT EQU 8DH ; Status Port +CPORT EQU 8EH ; Control Port + +; FDC37C665/6 Configuration Control (access internal registers) + +CFCNTL EQU 90H ; Configuration control port +CFDATA EQU 91H ; Configuration data port + +; FDC37C665/6 Floppy Controller on P112 (Intel 80277 compatible) + +DCR EQU 92H ; Drive Control Register (Digital Output) +MSR EQU 94H ; Main Status Register +DR EQU 95H ; Data/Command Register +DRR EQU 97H ; Data Rate Register/Disk Changed Bit in B7 + +_DMA EQU 0A0H ; Diskette DMA Address + +; FDC37C665/6 Serial Port (National 16550 compatible) + +_RBR EQU 68H ;R Receiver Buffer +_THR EQU 68H ;W Transmit Holding Reg +_IER EQU 69H ;RW Interrupt-Enable Reg +_IIR EQU 6AH ;R Interrupt Ident. Reg +_FCR EQU 6AH ;W FIFO Control Reg +_LCR EQU 6BH ;RW Line Control Reg +_MCR EQU 6CH ;RW Modem Control Reg +_LSR EQU 6DH ;RW Line Status Reg +_MMSR EQU 6EH ;RW Modem Status Reg +_SCR EQU 6FH ;N/A Scratch Reg. (not avail in XT) +_DDL EQU 68H ;RW Divisor LSB | wih DLAB +_DLM EQU 69H ;RW Divisor MSB | set High + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates for the National DP8490/NCR 5380 Prototype SCSI controller + + IF HARDDSK +NCR EQU 40H ; Base of NCR 5380 + +; 5380 Chip Registers + +NCRDAT EQU NCR ; Current SCSI Data (Read) + ; Output Data Register (Write) +NCRCMD EQU NCR+1 ; Initiator Command Register (Read/Write) +NCRMOD EQU NCR+2 ; Mode Register (Read/Write) +NCRTGT EQU NCR+3 ; Target Command Register (Read/Write) +NCRBUS EQU NCR+4 ; Current SCSI Bus Status (Read) +NCRST EQU NCR+5 ; Bus & Status Register (Read) + ; Start DMA Send (Write) +NCRINT EQU NCR+7 ; Reset Parity/Interrupt (Read) + ; Start DMA Initiator Receive (Write) +DMAACK EQU NCR+8 ; SCSI Dack IO Port (Read/Write) + +; Bit Assignments for NCR 5380 Ports as indicated + +B_ARST EQU 10000000B ; Assert *RST (NCRCMD) +B_AACK EQU 00010000B ; Assert *ACK (NCRCMD) +B_ASEL EQU 00000100B ; Assert *SEL (NCRCMD) +B_ABUS EQU 00000001B ; Assert *Data Bus (NCRCMD) + +B_BSY EQU 01000000B ; *Busy (NCRBUS) +B_REQ EQU 00100000B ; *Request (NCRBUS) +B_MSG EQU 00010000B ; *Message (NCRBUS) +B_CD EQU 00001000B ; *Command/Data (NCRBUS) +B_IO EQU 00000100B ; *I/O (NCRBUS) +B_SEL EQU 00000010B ; *Select (NCRBUS) + +B_PHAS EQU 00001000B ; Phase Match (NCRST) +B_BBSY EQU 00000100B ; Bus Busy (NCRST) + +B_MBSY EQU 00000100B ; Monitor Busy Flag (NCRMOD) +B_DMA EQU 00000010B ; DMA Mode of transfer (NCRMOD) + ENDIF ;harddsk + +;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +; Equates reflecting GIDE Base address from Address Jumpers (if GIDE added) +; Set the base GIDE equate to the jumper setting on the GIDE board. + + IF IDE +GIDE EQU 50H ; Set base of 16 byte address range + +IDEDOR EQU GIDE+6 ; Digital Output Register +IDEDat EQU GIDE+8 ; IDE Data Register (16-bit wide) +IDEErr EQU GIDE+9 ; IDE Error Register +IDESCnt EQU GIDE+0AH ; IDE Sector Count Register +IDESNum EQU GIDE+0BH ; IDE Sector Number Register +IDECLo EQU GIDE+0CH ; IDE Cylinder Number (Low) +IDECHi EQU GIDE+0DH ; IDE Cylinter Number (High) +IDESDH EQU GIDE+0EH ; IDE S-Drive-Head Register +IDECmd EQU GIDE+0FH ; IDE Command/Status Register + +CMDHOM EQU 10H ; Home Drive Heads +CMDRD EQU 20H ; Read Sector Command (w/retry) +CMDWR EQU 30H ; Write Sector Command (w/retry) +CMDVER EQU 40H ; Verify Sector(s) Command (w/retry) +CMDFMT EQU 50H ; Format Track Command +CMDDIAG EQU 90H ; Execute Diagnostics Command +CMDINIT EQU 91H ; Initialize Drive Params Command +CMDPW0 EQU 0E0H ; Low Range of Power Control Commands +CMDPW3 EQU 0E3H ; High Range of Power Control Commands +CMDPWQ EQU 0E5H ; Power Status Query Command +CMDID EQU 0ECH ; Read Drive Ident Data Command + ENDIF ;ide +;=================== End Unique Equates ======================= + \ No newline at end of file diff --git a/Source/BPBIOS/def-ww-z41.lib b/Source/BPBIOS/def-ww-z41tbnk.lib similarity index 95% rename from Source/BPBIOS/def-ww-z41.lib rename to Source/BPBIOS/def-ww-z41tbnk.lib index f95a8ded..bb97b618 100644 --- a/Source/BPBIOS/def-ww-z41.lib +++ b/Source/BPBIOS/def-ww-z41tbnk.lib @@ -33,7 +33,10 @@ MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? -HAVIOP EQU no ; Include IOP code into Jump table? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU NO ; Internal HBIOS Mini Proxy +CONF_T EQU YES ; Set for Segment Configuration T +CONF_N EQU NO ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/def-ww.lib b/Source/BPBIOS/def-ww.lib index f95a8ded..1e2b4570 100644 --- a/Source/BPBIOS/def-ww.lib +++ b/Source/BPBIOS/def-ww.lib @@ -33,7 +33,10 @@ MHZ EQU 18 ; Set to Speed in MHZ (6/9/12/16/18/24) FASTWB EQU YES ; Yes if restoring CPR from banked RAM ; ..No if restoring from Drive A Z3 EQU YES ; Include ZCPR init code? -HAVIOP EQU no ; Include IOP code into Jump table? +HAVIOP EQU NO ; Include IOP code into Jump table? +INTPXY EQU YES ; Internal HBIOS Mini Proxy +CONF_T EQU NO ; Set for Segment Configuration T +CONF_N EQU YES ; Set for Segment Configuration N ;--- Memory configuration Section --- (Expansion Memory configured here) diff --git a/Source/BPBIOS/hardhb.z80 b/Source/BPBIOS/hardhb.z80 index 56c257d8..bfac16cd 100644 --- a/Source/BPBIOS/hardhb.z80 +++ b/Source/BPBIOS/hardhb.z80 @@ -194,19 +194,32 @@ HDSK_RW: LD C,(HL) ; LOAD IT IN C FOR HBIOS CALL LATER PUSH BC ; SAVE FUNCTION AND DEVICE FOR LATER - LD DE,(HSTTRK) - LD HL,0 - LD B,4 ; PREPARE TO LEFT SHIT BY 4 BITS +; LD DE,(HSTTRK) +; LD HL,0 +; LD B,4 ; PREPARE TO LEFT SHIT BY 4 BITS +;HDSK_RW1: +; SLA E ; SHIFT DE LEFT BY 4 BITS +; RL D +; RL L +; RL H +; DJNZ HDSK_RW1 ; LOOP TILL ALL BITS DONE +; LD A,(HSTSEC) ; GET THE SECTOR INTO A +; AND 0FH ; GET RID OF TOP NIBBLE FOR SAFETY +; OR E ; COMBINE WITH E +; LD E,A ; BACK IN E + + LD HL,(HSTTRK) ; GET TRACK VALUE + LD A,L ; LSB OF TRACK TO A + AND 0FH ; ISOLATE HEAD IN LOW 4 BITS + LD D,A ; STUFF IT IN D + LD A,(HSTSEC) ; GET SECTOR + LD E,A ; STUFF IT IN E + LD B,4 ; PREPARE TO SHIFT OUT 4 BIT HEAD VALUE HDSK_RW1: - SLA E ; SHIFT DE LEFT BY 4 BITS - RL D - RL L - RL H - DJNZ HDSK_RW1 ; LOOP TILL ALL BITS DONE - LD A,(HSTSEC) ; GET THE SECTOR INTO A - AND 0FH ; GET RID OF TOP NIBBLE FOR SAFETY - OR E ; COMBINE WITH E - LD E,A ; BACK IN E + SRL H ; SHIFT ONE BIT OUT + RR L ; ... OF HL + DJNZ HDSK_RW1 ; DO ALL 4 BITS + EX DE,HL ; HL <-> DE FOR HBIOS CALL POP BC ; RECOVER FUNCTION AND DEVICE CALL HBX_INVOKE diff --git a/Source/BPBIOS/romwbw.lib b/Source/BPBIOS/romwbw.lib index 03fc7bb0..25fcaa28 100644 --- a/Source/BPBIOS/romwbw.lib +++ b/Source/BPBIOS/romwbw.lib @@ -9,7 +9,7 @@ ; HBIOS configuration. ; HBIOS EQU YES ; Use HBIOS functions -INTPXY EQU YES ; Internal HBIOS Proxy +;INTPXY EQU YES ; Internal HBIOS Proxy HBLOC EQU 0FE00H ; Location of HBIOS proxy (used if not INTPXY) ; ; Set exactly one of the following to YES to specify platform diff --git a/Source/BPBIOS/z3base.lib b/Source/BPBIOS/z3base.lib index 397ecd97..520777ce 100644 --- a/Source/BPBIOS/z3base.lib +++ b/Source/BPBIOS/z3base.lib @@ -14,9 +14,8 @@ ; alternative, just leave this file alone and configure everything with ; the utilities provided. -; FFE0 - FFFF 32 Bytes HBIOS Reserved -; FFB0 - FFDF 48 Bytes ZCPR3 External Stack -; FF00 - FFAF 176 Bytes Multiple Command Line Buffer +; FFD0 - FFFF 48 Bytes ZCPR3 External Stack +; FF00 - FFCF 208 Bytes Multiple Command Line Buffer ; FE00 - FEFF 256 Bytes Environment Descriptor ; Bytes 00H-7FH: Z3 Parameters ; Bytes 80H-FFH: Z3 TCAP @@ -50,16 +49,14 @@ NO EQU FALSE ; The External Stack is placed in the very top position in memory. It is ; mandatory for B/P Bios and ZCPR 3.3. -;EXTSTK EQU 0FFD0H ; ZCPR3 External Stack -EXTSTK EQU 0FFB0H ; ZCPR3 External Stack +EXTSTK EQU 0FFD0H ; ZCPR3 External Stack EXTSTKS EQU YES ; The Multiple Command Line Buffer is placed in the Top Page of Memory to ; place it above the Environment. It is mandatory for ZCPR 3.3. Z3CL EQU 0FF00H ; ZCPR3 Command Line Buffer -;Z3CLS EQU 208-5 ; Size of Command Line Buffer-5 -Z3CLS EQU 176-5 ; Size of Command Line Buffer-5 +Z3CLS EQU 208-5 ; Size of Command Line Buffer-5 ; The ZCPR3 External Environment Descriptor is mandatory B/P Bios & ZCPR 3.3. ; The Environment Descriptor MUST begin on an even Page Boundary (xx00H). diff --git a/Source/BPBIOS/z3basen.lib b/Source/BPBIOS/z3basen.lib new file mode 100644 index 00000000..397ecd97 --- /dev/null +++ b/Source/BPBIOS/z3basen.lib @@ -0,0 +1,128 @@ +; B/P Bios System Z3 Definition File. + +; This file is adapted from the basic Z3BASE.LIB configuration file used for +; most ZCPR33 systems. It has added the new definitions for the Resident +; User Space defined in B/P Bios descriptions. +;========================================================================= +;== NOTE: The Starting Address of the User Space marks the lower == +;== base of memory and MUST be entered. B/P Bios Utilities use == +;== this address to locate many portions of the operating system. == +;========================================================================= +; To change your systems definition, first sketch out the memory map in the +; comment table, then set the equates to reflect the memory map, doing any +; required calculations for element sizes and required spaces. As an +; alternative, just leave this file alone and configure everything with +; the utilities provided. + +; FFE0 - FFFF 32 Bytes HBIOS Reserved +; FFB0 - FFDF 48 Bytes ZCPR3 External Stack +; FF00 - FFAF 176 Bytes Multiple Command Line Buffer +; FE00 - FEFF 256 Bytes Environment Descriptor +; Bytes 00H-7FH: Z3 Parameters +; Bytes 80H-FFH: Z3 TCAP +; FDFF 1 Byte Wheel byte +; FDF4 - FDFE 11 Bytes Path (5 elements) +; FDD0 - FDF3 36 Bytes ZCPR3 External FCB +; FD80 - FDCF 80 Bytes ZCPR3 Message Buffers +; FD00 - FD7F 128 Bytes ZCPR3 Shell Stack +; FC00 - FCFF 256 Bytes Named Directory Buffer +; FA00 - FBFF 512 Bytes Flow Command Package +; F200 - F9FF 2.0 KBytes Resident Command Package +; EC00 - F1FF 1.5 KBytes IO Package +; E900 - EBFF .75 KBytes Resident User Space + +; The remainder is for the Operating System. Exact sizes vary depending +; primarily on the Number and sizes of Hard Drive Partitions, but may be: + +; D100 - EBFF 5.0 KBytes B/P BIOS (unbanked version) +; C300 - D0FF 3.5 KBytes ZSDOS 1.0 BDOS +; BB00 - C2FF 2 KBytes ZCPR 3.3 Command Processor +; 0100 - BAFF ~46 KBytes Transient Program Area +; 0000 - 00FF 256 Bytes Standard CP/M Buffers +;======================================================================== + +FALSE EQU 0 +TRUE EQU NOT FALSE + +YES EQU TRUE +NO EQU FALSE + +; The External Stack is placed in the very top position in memory. It is +; mandatory for B/P Bios and ZCPR 3.3. + +;EXTSTK EQU 0FFD0H ; ZCPR3 External Stack +EXTSTK EQU 0FFB0H ; ZCPR3 External Stack +EXTSTKS EQU YES + +; The Multiple Command Line Buffer is placed in the Top Page of Memory to +; place it above the Environment. It is mandatory for ZCPR 3.3. + +Z3CL EQU 0FF00H ; ZCPR3 Command Line Buffer +;Z3CLS EQU 208-5 ; Size of Command Line Buffer-5 +Z3CLS EQU 176-5 ; Size of Command Line Buffer-5 + +; The ZCPR3 External Environment Descriptor is mandatory B/P Bios & ZCPR 3.3. +; The Environment Descriptor MUST begin on an even Page Boundary (xx00H). + +Z3ENV EQU 0FE00H ; Environment Descriptors +Z3ENVS EQU 2 ; Size of Env Descriptor in 128-Byte Blks + +; The ZCPR3 Wheel Byte is mandatory for ZCPR 3.3. + +Z3WHL EQU 0FDFFH ; Wheel Byte Address +Z3WHLS EQU YES + +; The Path is mandatory for ZCPR 3.3. + +EXPATH EQU 0FDF4H ; External Path starting Address +EXPATHS EQU 5 ; (Path Size = EXPATHS*2 + 1 = 11 bytes) + ; This defines 5 2-byte Path Elements + +; The ZCPR3 External FCB is mandatory for ZCPR 3.3. + +EXTFCB EQU 0FDD0H ; 36-Byte ZCPR3 External FCB +EXTFCBS EQU YES + +; The ZCPR3 Message Buffers are mandatory for ZCPR 3.3. + +Z3MSG EQU 0FD80H ; 80-Byte ZCPR3 Message Buffer +Z3MSGS EQU YES + +; Shell Stack definition. Set SHSTKS to 0 to eliminate Shell Stack + +SHSTK EQU 0FD00H ; Shell Stack Starting Address +SHSTKS EQU 4 ; Number of SHSIZE-Byte Shell Stack entries +SHSIZE EQU 32 ; (Stack Size = SHSTKS * SHSIZE = 128 Bytes) + +; ZCPR3 Named Directory Buffer definition. Set Z3NDIRS to 0 to eliminate +; the named directory buffer. + +Z3NDIR EQU 0FC00H ; Start of Named Directory Buffer +Z3NDIRS EQU 14 ; Number of Named Directory Elements + ; (NDIR Size = Z3NDIRS * 18 + 1 = 253 Bytes) + +; Flow Command Package definition. Set FCPS to 0 to eliminate FCP + +FCP EQU 0FA00H ; Start of Flow Command Package +FCPS EQU 4 ; (FCP Size = 128 * FCPS = 512 Bytes) + +; Resident Command Processor Definition. Set RCPS to 0 to eliminate RCP + +RCP EQU 0F200H ; Start of Resident Command Processor +RCPS EQU 16 ; (RCP Size = 128 * RCPS = 2 kBytes) + +; IO Package definition. Set IOPS to 0 to eliminate IOP + +IOP EQU 0EC00H ; Start of IO Package +IOPS DEFL 12 ; (IOP Size = 128 * IOPS = 1.5 kBytes) + +;========================================================================= +; Resident User Space Definition. Set USPCS to 0 to eliminate USPC. +; The USPC Value marks the Lower Limit of Reserved Common High Memory and +; MUST BE PRESENT! + +USPC EQU 0E900H ; Start of Resident User Space (MANDATORY) +USPCS EQU 6 ; (USPC Size = 128 * USPCS = 0.75 kBytes) + +;--- End of Z3BASE.LIB --- + \ No newline at end of file diff --git a/Source/BPBIOS/z3baset.lib b/Source/BPBIOS/z3baset.lib new file mode 100644 index 00000000..9327887a --- /dev/null +++ b/Source/BPBIOS/z3baset.lib @@ -0,0 +1,126 @@ +; B/P Bios System Z3 Definition File. + +; This file is adapted from the basic Z3BASE.LIB configuration file used for +; most ZCPR33 systems. It has added the new definitions for the Resident +; User Space defined in B/P Bios descriptions. +;========================================================================= +;== NOTE: The Starting Address of the User Space marks the lower == +;== base of memory and MUST be entered. B/P Bios Utilities use == +;== this address to locate many portions of the operating system. == +;========================================================================= +; To change your systems definition, first sketch out the memory map in the +; comment table, then set the equates to reflect the memory map, doing any +; required calculations for element sizes and required spaces. As an +; alternative, just leave this file alone and configure everything with +; the utilities provided. + +; FE00 - FFFF 512 Bytes HBIOS Reserved +; FDFF 1 Byte Wheel byte +; FDF4 - FDFE 11 Bytes Path (5 elements) +; FDD0 - FDF3 36 Bytes ZCPR3 External FCB +; FD80 - FDCF 80 Bytes ZCPR3 Message Buffers +; FD00 - FD7F 128 Bytes ZCPR3 Shell Stack +; FC00 - FCFF 256 Bytes Named Directory Buffer +; FA00 - FBFF 512 Bytes Flow Command Package +; F200 - F9FF 2.0 KBytes Resident Command Package +; EC00 - F1FF 1.5 KBytes IO Package +; EBD0 - EBFF 48 Bytes ZCPR3 External Stack +; EB00 - EBAF 176 Bytes Multiple Command Line Buffer +; EA00 - EAFF 256 Bytes Environment Descriptor +; Bytes 00H-7FH: Z3 Parameters +; Bytes 80H-FFH: Z3 TCAP +; E700 - E9FF .75 KBytes Resident User Space + +; The remainder is for the Operating System. Exact sizes vary depending +; primarily on the Number and sizes of Hard Drive Partitions, but may be: + +; D300 - E6FF 5.0 KBytes B/P BIOS (unbanked version) +; C500 - D2FF 3.5 KBytes ZSDOS 1.0 BDOS +; BD00 - C4FF 2 KBytes ZCPR 3.3 Command Processor +; 0100 - BCFF ~47 KBytes Transient Program Area +; 0000 - 00FF 256 Bytes Standard CP/M Buffers +;======================================================================== + +FALSE EQU 0 +TRUE EQU NOT FALSE + +YES EQU TRUE +NO EQU FALSE + +; The External Stack is placed in the very top position in memory. It is +; mandatory for B/P Bios and ZCPR 3.3. + +EXTSTK EQU 0EBD0H ; ZCPR3 External Stack +EXTSTKS EQU YES + +; The Multiple Command Line Buffer is placed in the Top Page of Memory to +; place it above the Environment. It is mandatory for ZCPR 3.3. + +Z3CL EQU 0EB00H ; ZCPR3 Command Line Buffer +Z3CLS EQU 208-5 ; Size of Command Line Buffer-5 + +; The ZCPR3 External Environment Descriptor is mandatory B/P Bios & ZCPR 3.3. +; The Environment Descriptor MUST begin on an even Page Boundary (xx00H). + +Z3ENV EQU 0EA00H ; Environment Descriptors +Z3ENVS EQU 2 ; Size of Env Descriptor in 128-Byte Blks + +; The ZCPR3 Wheel Byte is mandatory for ZCPR 3.3. + +Z3WHL EQU 0FDFFH ; Wheel Byte Address +Z3WHLS EQU YES + +; The Path is mandatory for ZCPR 3.3. + +EXPATH EQU 0FDF4H ; External Path starting Address +EXPATHS EQU 5 ; (Path Size = EXPATHS*2 + 1 = 11 bytes) + ; This defines 5 2-byte Path Elements + +; The ZCPR3 External FCB is mandatory for ZCPR 3.3. + +EXTFCB EQU 0FDD0H ; 36-Byte ZCPR3 External FCB +EXTFCBS EQU YES + +; The ZCPR3 Message Buffers are mandatory for ZCPR 3.3. + +Z3MSG EQU 0FD80H ; 80-Byte ZCPR3 Message Buffer +Z3MSGS EQU YES + +; Shell Stack definition. Set SHSTKS to 0 to eliminate Shell Stack + +SHSTK EQU 0FD00H ; Shell Stack Starting Address +SHSTKS EQU 4 ; Number of SHSIZE-Byte Shell Stack entries +SHSIZE EQU 32 ; (Stack Size = SHSTKS * SHSIZE = 128 Bytes) + +; ZCPR3 Named Directory Buffer definition. Set Z3NDIRS to 0 to eliminate +; the named directory buffer. + +Z3NDIR EQU 0FC00H ; Start of Named Directory Buffer +Z3NDIRS EQU 14 ; Number of Named Directory Elements + ; (NDIR Size = Z3NDIRS * 18 + 1 = 253 Bytes) + +; Flow Command Package definition. Set FCPS to 0 to eliminate FCP + +FCP EQU 0FA00H ; Start of Flow Command Package +FCPS EQU 4 ; (FCP Size = 128 * FCPS = 512 Bytes) + +; Resident Command Processor Definition. Set RCPS to 0 to eliminate RCP + +RCP EQU 0F200H ; Start of Resident Command Processor +RCPS EQU 16 ; (RCP Size = 128 * RCPS = 2 kBytes) + +; IO Package definition. Set IOPS to 0 to eliminate IOP + +IOP EQU 0EC00H ; Start of IO Package +IOPS DEFL 12 ; (IOP Size = 128 * IOPS = 1.5 kBytes) + +;========================================================================= +; Resident User Space Definition. Set USPCS to 0 to eliminate USPC. +; The USPC Value marks the Lower Limit of Reserved Common High Memory and +; MUST BE PRESENT! + +USPC EQU 0E700H ; Start of Resident User Space (MANDATORY) +USPCS EQU 6 ; (USPC Size = 128 * USPCS = 0.75 kBytes) + +;--- End of Z3BASE.LIB --- + \ No newline at end of file diff --git a/Source/BPBIOS/zcpr33.rel b/Source/BPBIOS/zcpr33.rel index f9f24ee8..7c0a2567 100644 Binary files a/Source/BPBIOS/zcpr33.rel and b/Source/BPBIOS/zcpr33.rel differ diff --git a/Source/BPBIOS/zcpr33.rel.sav b/Source/BPBIOS/zcpr33.rel.sav deleted file mode 100644 index 7c0a2567..00000000 Binary files a/Source/BPBIOS/zcpr33.rel.sav and /dev/null differ diff --git a/Source/BPBIOS/zcpr33n.rel b/Source/BPBIOS/zcpr33n.rel new file mode 100644 index 00000000..f9f24ee8 Binary files /dev/null and b/Source/BPBIOS/zcpr33n.rel differ diff --git a/Source/BPBIOS/zcpr33t.rel b/Source/BPBIOS/zcpr33t.rel new file mode 100644 index 00000000..3a2fd054 Binary files /dev/null and b/Source/BPBIOS/zcpr33t.rel differ diff --git a/Source/HBIOS/ide.asm b/Source/HBIOS/ide.asm index b0a756c5..27094258 100644 --- a/Source/HBIOS/ide.asm +++ b/Source/HBIOS/ide.asm @@ -6,7 +6,7 @@ ; TODO: ; - IMPLEMENT IDE_INITDEVICE ; - HANDLE SECONDARY INTERFACE ON DIDE -; - BREAK OUT IDE_SELECT FROM UNITSEL +; - IMPLEMENT INTELLIGENT RESET, CHECK IF DEVICE IS ACTUALLY BROKEN BEFORE RESET ; ; +-----------------------------------------------------------------------+ ; | CONTROL BLOCK REGISTERS | @@ -154,11 +154,11 @@ IDE_IO_DRVADR .EQU $IDE_IO_BASE + $0F ; DRIVE ADDRESS REGISTER (R) ; ; COMMAND BYTES ; -IDE_CIDE_RECAL .EQU $10 -IDE_CIDE_READ .EQU $20 -IDE_CIDE_WRITE .EQU $30 -IDE_CIDE_IDDEV .EQU $EC -IDE_CIDE_SETFEAT .EQU $EF +IDE_CMD_RECAL .EQU $10 +IDE_CMD_READ .EQU $20 +IDE_CMD_WRITE .EQU $30 +IDE_CMD_IDDEV .EQU $EC +IDE_CMD_SETFEAT .EQU $EF ; ; FEATURE BYTES ; @@ -195,6 +195,18 @@ IDE_STAT .EQU 0 ; LAST STATUS (1 BYTE) IDE_TYPE .EQU 1 ; DEVICE TYPE (1 BYTE) IDE_CAPACITY .EQU 2 ; DEVICE CAPACITY (1 DWORD/4 BYTES) ; +; THE IDE_WAITXXX FUNCTIONS ARE BUILT TO TIMEOUT AS NEEDED SO DRIVER WILL +; NOT HANG IF DEVICE IS UNRESPONSIVE. DIFFERENT TIMEOUTS ARE USED DEPENDING +; ON THE SITUATION. GENERALLY, THE FAST TIMEOUT IS USED TO PROBE FOR DEVICES +; USING FUNCTIONS THAT PERFORM NO I/O. OTHERWISE THE NORMAL TIMEOUT IS USED. +; IDE SPEC ALLOWS FOR UP TO 30 SECS MAX TO RESPOND. IN PRACTICE, THIS IS WAY +; TOO LONG, BUT IF YOU ARE USING A VERY OLD DEVICE, THESE TIMEOUTS MAY NEED TO +; BE ADJUSTED. NOTE THAT THESE ARE BYTE VALUES, SO YOU CANNOT EXCEED 255. +; THE TIMEOUTS ARE IN UNITS OF .05 SECONDS. +; +IDE_TONORM .EQU 200 ; NORMAL TIMEOUT IS 10 SECS +IDE_TOFAST .EQU 10 ; FAST TIMEOUT IS 0.5 SECS +; ; MACRO TO RETURN POINTER TO FIELD WITHIN UNIT DATA ; #DEFINE IDE_DPTR(FIELD) CALL IDE_DPTRIMP \ .DB FIELD @@ -205,6 +217,14 @@ IDE_CAPACITY .EQU 2 ; DEVICE CAPACITY (1 DWORD/4 BYTES) ; IDE_INIT: PRTS("IDE:$") ; LABEL FOR IO ADDRESS +; + ; COMPUTE CPU SPEED COMPENSATED TIMEOUT SCALER + ; AT 1MHZ, THE SCALER IS 961 (50000US / 52TS = 961) + ; SCALER IS THEREFORE 961 * CPU SPEED IN MHZ + LD DE,961 ; LOAD SCALER FOR 1MHZ + LD A,(HCB + HCB_CPUMHZ) ; LOAD CPU SPEED IN MHZ + CALL MULT8X16 ; HL := DE * A + LD (IDE_TOSCALER),HL ; SAVE IT ; #IF (IDEMODE == IDEMODE_DIO) PRTS(" MODE=DIO$") @@ -242,10 +262,6 @@ IDE_INIT1: RET ; DONE ; IDE_INIT2: -; ; DISPLAY DEVICE INFO -; CALL IDE_SELUNIT ; SELECT UNIT -; RET NZ ; ABORT ON ERROR -; LD (IDE_UNIT),A ; SET CURRENT UNIT ; ; CHECK FOR BAD STATUS @@ -298,7 +314,6 @@ IDE_DISPATCH: CP IDE_UNITCNT CALL NC,PANIC ; PANIC IF TOO HIGH LD (IDE_UNIT),A ; SAVE IT - ;CALL IDE_SELUNIT ; SELECT DESIRED UNIT ; ; DISPATCH ACCORDING TO DISK SUB-FUNCTION LD A,B ; GET REQUESTED FUNCTION @@ -371,12 +386,7 @@ IDE_SENSE: ; THE ENTIRE INTERFACE. SO, TO HANDLE POSSIBLE HOT ; SWAP WE DO THAT, THEN RESELECT THE DESIRED UNIT AND ; CONTINUE. - LD A,(IDE_UNIT) ; GET UNIT SELECTION - PUSH AF ; SAVE UNIT SELECTION CALL IDE_RESET ; RESET ALL DEVICES ON BUS - POP AF ; RECOVER UNIT SELECTION - LD (IDE_UNIT),A ; RESTORE UNIT SELECTION - ;CALL IDE_SELUNIT ; RESELECT DESIRED UNIT ; IDE_DPTR(IDE_STAT) ; POINT TO UNIT STATUS LD A,(HL) ; GET STATUS @@ -440,7 +450,7 @@ IDE_SETFEAT: OUT (IDE_IO_FEAT),A ; SET THE FEATURE VALUE DCALL PC_SPACE DCALL PRTHEXBYTE - LD A,IDE_CIDE_SETFEAT ; CMD = SETFEAT + LD A,IDE_CMD_SETFEAT ; CMD = SETFEAT LD (IDE_CMD),A ; SAVE IT JP IDE_RUNCMD ; RUN COMMAND AND EXIT ; @@ -455,7 +465,7 @@ IDE_IDENTIFY: OUT (IDE_IO_DRVHD),A DCALL PC_SPACE DCALL PRTHEXBYTE - LD A,IDE_CIDE_IDDEV + LD A,IDE_CMD_IDDEV LD (IDE_CMD),A CALL IDE_RUNCMD RET NZ @@ -477,7 +487,7 @@ IDE_RDSEC: DCALL PC_SPACE DCALL PRTHEXBYTE CALL IDE_SETADDR ; SETUP CYL, TRK, HEAD - LD A,IDE_CIDE_READ + LD A,IDE_CMD_READ LD (IDE_CMD),A CALL IDE_RUNCMD RET NZ @@ -499,7 +509,7 @@ IDE_WRSEC: DCALL PC_SPACE DCALL PRTHEXBYTE CALL IDE_SETADDR ; SETUP CYL, TRK, HEAD - LD A,IDE_CIDE_WRITE + LD A,IDE_CMD_WRITE LD (IDE_CMD),A CALL IDE_RUNCMD RET NZ @@ -510,7 +520,7 @@ IDE_WRSEC: ; IDE_SETADDR: ; SEND 3 LOWEST BYTES OF LBA IN REVERSE ORDER - ; IDE_IO_LBA3 HAS ALREADY BEEN SET BY IDE_SELECT + ; IDE_IO_LBA3 HAS ALREADY BEEN SET ; HSTLBA2-0 --> IDE_IO_LBA2-0 LD C,IDE_IO_LBA0 + 3 ; STARTING IO PORT (NOT PRE-DEC BELOW) LD HL,HSTLBA + 2 ; STARTING LBA BYTE ADR @@ -662,25 +672,34 @@ IDE_GETRES: IDE_RESET: ; #IF (PLATFORM == PLT_MK4) + ; USE HARDWARE RESET LINE LD A,$80 ; HIGH BIT OF XAR IS IDE RESET OUT (MK4_XAR),A - LD DE,16 ; DELAY ~250US + LD DE,2 ; DELAY 32US (SPEC IS >= 25US) CALL VDELAY XOR A ; CLEAR RESET BIT OUT (MK4_XAR),A #ELSE + ; INITIATE SOFT RESET LD A,%00001110 ; NO INTERRUPTS, ASSERT RESET BOTH DRIVES OUT (IDE_IO_CTRL),A #ENDIF ; - LD DE,16 ; DELAY ~250US + LD DE,2 ; DELAY 32US (SPEC IS >= 25US) CALL VDELAY ; + ; CONFIGURE OPERATION AND END SOFT RESET LD A,%00001010 ; NO INTERRUPTS, DEASSERT RESET - OUT (IDE_IO_CTRL),A + OUT (IDE_IO_CTRL),A ; PUSH TO REGISTER +; +; SPEC ALLOWS UP TO 450MS FOR DEVICES TO ASSERT THEIR PRESENCE +; VIA -DASP. I ENCOUNTER PROBLEMS LATER ON IF I DON'T WAIT HERE +; FOR THAT TO OCCUR. THUS FAR, IT APPEARS THAT 150MS IS SUFFICIENT +; FOR ANY DEVICE ENCOUNTERED. MAY NEED TO EXTEND BACK TO 500MS +; IF A SLOWER DEVICE IS ENCOUNTERED. ; - ;CALL LDELAY - LD DE,$2000 ; DELAY N * 16US (~128MS) + ;LD DE,500000/16 ; ~500MS + LD DE,150000/16 ; ~???MS CALL VDELAY ; ; CLEAR OUT ALL DATA (FOR ALL UNITS) @@ -704,7 +723,7 @@ IDE_RESET1: DJNZ IDE_RESET1 ; LOOP AS NEEDED ; POP AF ; RECOVER ORIGINAL UNIT NUMBER - CALL IDE_SELUNIT ; ... AND SELECT IT + LD (IDE_UNIT),A ; AND SAVE IT ; XOR A ; SIGNAL SUCCESS RET ; AND DONE @@ -713,54 +732,48 @@ IDE_RESET1: ; IDE_INITUNIT: LD (IDE_UNIT),A ; SET ACTIVE UNIT - + CALL IDE_SELUNIT ; SELECT UNIT RET NZ ; ABORT IF ERROR + + LD HL,IDE_TIMEOUT ; POINT TO TIMEOUT + LD (HL),IDE_TOFAST ; USE FAST TIMEOUT DURING INIT CALL IDE_PROBE ; DO PROBE RET NZ ; ABORT IF ERROR - OR $FF - OUT (IDE_IO_COUNT),A ; ZERO KEY REGISTERS IN TESTED DEVICE - OUT (IDE_IO_SECT),A ; ZERO KEY REGISTERS IN TESTED DEVICE - - ;RET - - JP IDE_INITDEV ; INIT DEVICE AND RETURN + CALL IDE_INITDEV ; ATTEMPT TO INIT DEVICE + + LD HL,IDE_TIMEOUT ; POINT TO TIMEOUT + LD (HL),IDE_TONORM ; BACK TO NORMAL TIMEOUT + + RET ; ; TAKE ANY ACTIONS REQUIRED TO SELECT DESIRED PHYSICAL UNIT -; UNIT IS SPECIFIED IN A +; UNIT IS SPECIFIED IN IDE_UNIT +; REGISTER A IS DESTROYED ; IDE_SELUNIT: -; LD HL,IDE_UNIT ; POINT TO PREVIOUSLY SELECTED UNIT -; CP (HL) ; SAME? -; RET Z ; IF SO, NOTHING MORE TO DO - + LD A,(IDE_UNIT) ; GET UNIT CP IDE_UNITCNT ; CHECK VALIDITY (EXCEED UNIT COUNT?) JP NC,IDE_INVUNIT ; HANDLE INVALID UNIT ; -; ; NEW UNIT SELECTED, IMPLEMENT IT -; LD (IDE_UNIT),A ; RECORD NEW UNIT NUMBER -; -; #IF (IDEMODE == IDEMODE_DIDE) ; SELECT PRIMARY/SECONDARY INTERFACE FOR DIDE HARDWARE #ENDIF ; + ; DETERMINE AND SAVE DRIVE/HEAD VALUE FOR SELECTED UNIT PUSH HL ; SAVE HL + LD A,(IDE_UNIT) ; GET CURRENT UNIT AND $01 ; LS BIT DETERMINES MASTER/SLAVE LD HL,IDE_DRVSEL CALL ADDHLA LD A,(HL) ; LOAD DRIVE/HEAD VALUE POP HL ; RECOVER HL + LD (IDE_DRVHD),A ; SAVE IT ; - OUT (IDE_IO_DRVHD),A ; SELECT DRIVE - LD (IDE_DRVHD),A ; UPDATE SHADOW REGISTER -; - ; SPEC REQUIRES 400NS DELAY BEFORE CHECKING STATUS REGISTER -; - XOR A - RET + XOR A ; SIGNAL SUCCESS + RET ; AND DONE ; ; ; @@ -769,6 +782,23 @@ IDE_PROBE: CALL IDE_PRTPREFIX PRTS(" PROBE$") ; LABEL FOR IO ADDRESS #ENDIF +; + LD A,(IDE_DRVHD) + OUT (IDE_IO_DRVHD),A + DCALL PC_SPACE + DCALL PRTHEXBYTE + + CALL DELAY ; DELAY ~16US +; + DCALL IDE_REGDUMP +; + ;JR IDE_PROBE1 ; *DEBUG* +; +IDE_PROBE0: + CALL IDE_WAITBSY ; WAIT FOR BUSY TO CLEAR + RET NZ ; ABORT ON TIMEOUT +; + DCALL IDE_REGDUMP ; ; CHECK STATUS IN A,(IDE_IO_STAT) ; GET STATUS @@ -777,19 +807,6 @@ IDE_PROBE: OR A ; SET FLAGS TO TEST FOR ZERO JP Z,IDE_NOMEDIA ; -IDE_PROBE0: - ;CALL IDE_WAITBSY ; WAIT FOR BUSY TO CLEAR - ;RET NZ ; ABORT ON TIMEOUT -; - ;; CHECK STATUS - ;IN A,(IDE_IO_STAT) ; GET STATUS - ;DCALL PRTHEXBYTE ; IF DEBUG, PRINT STATUS - ;OR A ; SET FLAGS TO TEST FOR ZERO - ;JR NZ,IDE_PROBE1 ; CONTINUE IF NON-ZERO - ;DEC A ; ZERO MEANS NO MEDIA, SIGNAL ERROR - ;RET ; AND DONE -; -IDE_PROBE1: ; CHECK SIGNATURE DCALL PC_SPACE IN A,(IDE_IO_COUNT) @@ -812,6 +829,7 @@ IDE_PROBE1: CP $00 JP NZ,IDE_NOMEDIA ; +IDE_PROBE1: ; SIGNATURE MATCHES ATA DEVICE, RECORD TYPE AND RETURN SUCCESS IDE_DPTR(IDE_TYPE) ; POINT HL TO UNIT TYPE FIELD, A IS TRASHED LD (HL),IDE_TYPEATA ; SET THE DEVICE TYPE @@ -845,6 +863,7 @@ IDE_INITDEV: #ELSE LD A,IDE_FEAT_DISABLE8BIT ; FEATURE VALUE = DISABLE 8-BIT PIO #ENDIF + CALL IDE_SETFEAT ; SET FEATURE RET NZ ; BAIL OUT ON ERROR ; @@ -886,16 +905,16 @@ IDE_CHKDEVICE: ; ; IDE_WAITRDY: - LD B,15 ; ~15 SECOND TIMEOUT? + LD A,(IDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR IDE_WAITRDY1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(IDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR IDE_WAITRDY2: IN A,(IDE_IO_STAT) ; READ STATUS LD C,A ; SAVE IT AND %11000000 ; ISOLATE BUSY AND RDY BITS XOR %01000000 ; WE WANT BUSY(7) TO BE 0 AND RDY(6) TO BE 1 RET Z ; ALL SET, RETURN WITH Z SET - CALL DELAY ; DELAY 16US DEC DE LD A,D OR E @@ -906,17 +925,17 @@ IDE_WAITRDY2: ; ; IDE_WAITDRQ: - LD B,3 ; ~3 SECOND TIMEOUT??? + LD A,(IDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR IDE_WAITDRQ1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(IDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR IDE_WAITDRQ2: IN A,(IDE_IO_STAT) ; WAIT FOR DRIVE'S 512 BYTE READ BUFFER LD C,A ; SAVE IT AND %10001000 ; TO FILL (OR READY TO FILL) XOR %00001000 RET Z - CALL DELAY ; DELAY 16US - DEC DE + DEC DE LD A,D OR E JR NZ,IDE_WAITDRQ2 @@ -926,21 +945,21 @@ IDE_WAITDRQ2: ; ; IDE_WAITBSY: - LD B,3 ; ~3 SECOND TIMEOUT??? + LD A,(IDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR IDE_WAITBSY1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(IDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR IDE_WAITBSY2: - IN A,(IDE_IO_STAT) ; WAIT FOR DRIVE'S 512 BYTE READ BUFFER - LD C,A ; SAVE IT - AND %10000000 ; TO FILL (OR READY TO FILL) - RET Z - CALL DELAY ; DELAY 16US - DEC DE - LD A,D - OR E - JR NZ,IDE_WAITBSY2 - DJNZ IDE_WAITBSY1 - JP IDE_BSYTO ; EXIT WITH BSYTO ERR + IN A,(IDE_IO_STAT) ; WAIT FOR DRIVE'S 512 BYTE READ BUFFER ; 11TS + LD C,A ; SAVE IT ; 4TS + AND %10000000 ; TO FILL (OR READY TO FILL) ; 7TS + RET Z ; 5TS + DEC DE ; 6TS + LD A,D ; 4TS + OR E ; 4TS + JR NZ,IDE_WAITBSY2 ; 12TS + DJNZ IDE_WAITBSY1 ; ----- + JP IDE_BSYTO ; EXIT WITH BSYTO ERR ; 52TS ; ;============================================================================= ; ERROR HANDLING AND DIAGNOSTICS @@ -1042,7 +1061,8 @@ IDE_PRTSTAT3: POP AF RET ; -; +; PRINT ALL REGISTERS DIRECTLY FROM DEVICE +; DEVICE MUST BE SELECTED PRIOR TO CALL ; IDE_REGDUMP: PUSH AF @@ -1116,6 +1136,9 @@ IDE_STR_NO .TEXT "NO$" ; DATA STORAGE ;============================================================================= ; +IDE_TIMEOUT .DB IDE_TONORM ; WAIT FUNCS TIMEOUT IN TENTHS OF SEC +IDE_TOSCALER .DW CPUMHZ * 961 ; WAIT FUNCS SCALER FOR CPU SPEED +; IDE_CMD .DB 0 ; PENDING COMMAND TO PROCESS IDE_DRVHD .DB 0 ; CURRENT DRIVE/HEAD MASK ; diff --git a/Source/HBIOS/ppide.asm b/Source/HBIOS/ppide.asm index fbe774e5..7b9bc73a 100644 --- a/Source/HBIOS/ppide.asm +++ b/Source/HBIOS/ppide.asm @@ -5,7 +5,8 @@ ; ; TODO: ; - IMPLEMENT PPIDE_INITDEVICE -; - BREAK OUT PPIDE_SELECT FROM UNITSEL +; - IMPLEMENT INTELLIGENT RESET, CHECK IF DEVICE IS ACTUALLY BROKEN BEFORE RESET +; - FIX SCALER CONSTANT ; ; PPIDE_IO_DATALO .EQU PPIDEIOB + 0 ; IDE DATA BUS LSB (8255 PORT A) @@ -156,11 +157,11 @@ PPIDE_UNITCNT .EQU 2 ; ASSUME ONLY PRIMARY INTERFACE ; ; COMMAND BYTES ; -PPIDE_CPPIDE_RECAL .EQU $10 -PPIDE_CPPIDE_READ .EQU $20 -PPIDE_CPPIDE_WRITE .EQU $30 -PPIDE_CPPIDE_IDDEV .EQU $EC -PPIDE_CPPIDE_SETFEAT .EQU $EF +PPIDE_CMD_RECAL .EQU $10 +PPIDE_CMD_READ .EQU $20 +PPIDE_CMD_WRITE .EQU $30 +PPIDE_CMD_IDDEV .EQU $EC +PPIDE_CMD_SETFEAT .EQU $EF ; ; FEATURE BYTES ; @@ -197,6 +198,18 @@ PPIDE_STAT .EQU 0 ; LAST STATUS (1 BYTE) PPIDE_TYPE .EQU 1 ; DEVICE TYPE (1 BYTE) PPIDE_CAPACITY .EQU 2 ; DEVICE CAPACITY (1 DWORD/4 BYTES) ; +; THE IDE_WAITXXX FUNCTIONS ARE BUILT TO TIMEOUT AS NEEDED SO DRIVER WILL +; NOT HANG IF DEVICE IS UNRESPONSIVE. DIFFERENT TIMEOUTS ARE USED DEPENDING +; ON THE SITUATION. GENERALLY, THE FAST TIMEOUT IS USED TO PROBE FOR DEVICES +; USING FUNCTIONS THAT PERFORM NO I/O. OTHERWISE THE NORMAL TIMEOUT IS USED. +; IDE SPEC ALLOWS FOR UP TO 30 SECS MAX TO RESPOND. IN PRACTICE, THIS IS WAY +; TOO LONG, BUT IF YOU ARE USING A VERY OLD DEVICE, THESE TIMEOUTS MAY NEED TO +; BE ADJUSTED. NOTE THAT THESE ARE BYTE VALUES, SO YOU CANNOT EXCEED 255. +; THE TIMEOUTS ARE IN UNITS OF .05 SECONDS. +; +PPIDE_TONORM .EQU 200 ; NORMAL TIMEOUT IS 10 SECS +PPIDE_TOFAST .EQU 10 ; FAST TIMEOUT IS 0.5 SECS +; ; MACRO TO RETURN POINTER TO FIELD WITHIN UNIT DATA ; #DEFINE PPIDE_DPTR(FIELD) CALL PPIDE_DPTRIMP \ .DB FIELD @@ -207,6 +220,15 @@ PPIDE_CAPACITY .EQU 2 ; DEVICE CAPACITY (1 DWORD/4 BYTES) ; PPIDE_INIT: PRTS("PPIDE: IO=0x$") ; LABEL FOR IO ADDRESS +; + ; COMPUTE CPU SPEED COMPENSATED TIMEOUT SCALER + ; AT 1MHZ, THE SCALER IS 961 (50000US / 52TS = 961) + ; SCALER IS THEREFORE 961 * CPU SPEED IN MHZ + LD DE,961 ; LOAD SCALER FOR 1MHZ + LD A,(HCB + HCB_CPUMHZ) ; LOAD CPU SPEED IN MHZ + CALL MULT8X16 ; HL := DE * A + LD (PPIDE_TOSCALER),HL ; SAVE IT +; LD A,PPIDEIOB CALL PRTHEXBYTE #IF (PPIDE8BIT) @@ -233,10 +255,6 @@ PPIDE_INIT1: RET ; DONE ; PPIDE_INIT2: -; ; DISPLAY DEVICE INFO -; CALL PPIDE_SELUNIT ; SELECT UNIT -; RET NZ ; ABORT ON ERROR -; LD (PPIDE_UNIT),A ; SET CURRENT UNIT ; ; CHECK FOR BAD STATUS @@ -289,7 +307,6 @@ PPIDE_DISPATCH: CP PPIDE_UNITCNT CALL NC,PANIC ; PANIC IF TOO HIGH LD (PPIDE_UNIT),A ; SAVE IT - ;CALL PPIDE_SELUNIT ; SELECT DESIRED UNIT ; ; DISPATCH ACCORDING TO DISK SUB-FUNCTION LD A,B ; GET REQUESTED FUNCTION @@ -332,6 +349,7 @@ PPIDE_READ: LD HL,PPIDE_PRTERR ; SET UP PPIDE_PRTERR PUSH HL ; ... TO FILTER ALL EXITS #ENDIF + CALL PPIDE_SELUNIT ; HARDWARE SELECTION OF TARGET UNIT JP PPIDE_RDSEC ; ; @@ -342,6 +360,7 @@ PPIDE_WRITE: LD HL,PPIDE_PRTERR ; SET UP PPIDE_PRTERR PUSH HL ; ... TO FILTER ALL EXITS #ENDIF + CALL PPIDE_SELUNIT ; HARDWARE SELECTION OF TARGET UNIT JP PPIDE_WRSEC ; ; @@ -360,12 +379,7 @@ PPIDE_SENSE: ; THE ENTIRE INTERFACE. SO, TO HANDLE POSSIBLE HOT ; SWAP WE DO THAT, THEN RESELECT THE DESIRED UNIT AND ; CONTINUE. - LD A,(PPIDE_UNIT) ; GET UNIT SELECTION - PUSH AF ; SAVE UNIT SELECTION CALL PPIDE_RESET ; RESET ALL DEVICES ON BUS - POP AF ; RECOVER UNIT SELECTION - LD (PPIDE_UNIT),A ; RESTORE UNIT SELECTION - ;CALL PPIDE_SELUNIT ; RESELECT DESIRED UNIT ; PPIDE_DPTR(PPIDE_STAT) ; POINT TO UNIT STATUS LD A,(HL) ; GET STATUS @@ -435,7 +449,7 @@ PPIDE_SETFEAT: .DB PPIDE_REG_FEAT DCALL PC_SPACE DCALL PRTHEXBYTE - LD A,PPIDE_CPPIDE_SETFEAT ; CMD = SETFEAT + LD A,PPIDE_CMD_SETFEAT ; CMD = SETFEAT LD (PPIDE_CMD),A ; SAVE IT JP PPIDE_RUNCMD ; RUN COMMAND AND EXIT ; @@ -452,7 +466,7 @@ PPIDE_IDENTIFY: .DB PPIDE_REG_DRVHD DCALL PC_SPACE DCALL PRTHEXBYTE - LD A,PPIDE_CPPIDE_IDDEV + LD A,PPIDE_CMD_IDDEV LD (PPIDE_CMD),A CALL PPIDE_RUNCMD RET NZ @@ -476,7 +490,7 @@ PPIDE_RDSEC: DCALL PC_SPACE DCALL PRTHEXBYTE CALL PPIDE_SETADDR ; SETUP CYL, TRK, HEAD - LD A,PPIDE_CPPIDE_READ + LD A,PPIDE_CMD_READ LD (PPIDE_CMD),A CALL PPIDE_RUNCMD RET NZ @@ -498,7 +512,7 @@ PPIDE_WRSEC: DCALL PC_SPACE DCALL PRTHEXBYTE CALL PPIDE_SETADDR ; SETUP CYL, TRK, HEAD - LD A,PPIDE_CPPIDE_WRITE + LD A,PPIDE_CMD_WRITE LD (PPIDE_CMD),A CALL PPIDE_RUNCMD RET NZ @@ -508,6 +522,10 @@ PPIDE_WRSEC: ; ; PPIDE_SETADDR: + ; XXX + ; SEND 3 LOWEST BYTES OF LBA IN REVERSE ORDER + ; IDE_IO_LBA3 HAS ALREADY BEEN SET + ; HSTLBA2-0 --> IDE_IO_LBA2-0 LD A,(HSTLBA + 2) DCALL PC_SPACE DCALL PRTHEXBYTE @@ -714,13 +732,11 @@ PPIDE_RESET: ; LD A,PPIDE_CTL_RESET OUT (PPIDE_IO_CTL),A - LD DE,16 - ;LD DE,1024 + LD DE,2 CALL VDELAY XOR A OUT (PPIDE_IO_CTL),A - LD DE,16 - ;LD DE,1024 + LD DE,2 CALL VDELAY ; LD A,%00001010 ; SET ~IEN, NO INTERRUPTS @@ -728,8 +744,14 @@ PPIDE_RESET: CALL PPIDE_OUT .DB PPIDE_REG_CTRL ; - ;CALL LDELAY - LD DE,$2000 ; DELAY N * 16US (~128MS) +; SPEC ALLOWS UP TO 450MS FOR DEVICES TO ASSERT THEIR PRESENCE +; VIA -DASP. I ENCOUNTER PROBLEMS LATER ON IF I DON'T WAIT HERE +; FOR THAT TO OCCUR. THUS FAR, IT APPEARS THAT 150MS IS SUFFICIENT +; FOR ANY DEVICE ENCOUNTERED. MAY NEED TO EXTEND BACK TO 500MS +; IF A SLOWER DEVICE IS ENCOUNTERED. +; + ;LD DE,500000/16 ; ~500MS + LD DE,150000/16 ; ~???MS CALL VDELAY ; ; CLEAR OUT ALL DATA (FOR ALL UNITS) @@ -753,7 +775,7 @@ PPIDE_RESET1: DJNZ PPIDE_RESET1 ; LOOP AS NEEDED ; POP AF ; RECOVER ORIGINAL UNIT NUMBER - CALL PPIDE_SELUNIT ; ... AND RESELECT IT + LD (PPIDE_UNIT),A ; AND SAVE IT ; XOR A ; SIGNAL SUCCESS RET ; AND DONE @@ -766,48 +788,36 @@ PPIDE_INITUNIT: CALL PPIDE_SELUNIT ; SELECT UNIT RET NZ ; ABORT IF ERROR + LD HL,PPIDE_TIMEOUT ; POINT TO TIMEOUT + LD (HL),PPIDE_TOFAST ; USE FAST TIMEOUT DURING INIT + CALL PPIDE_PROBE ; DO PROBE RET NZ ; ABORT IF ERROR - OR $FF - CALL PPIDE_OUT - .DB PPIDE_REG_COUNT - CALL PPIDE_OUT - .DB PPIDE_REG_SECT - - ;RET - - JP PPIDE_INITDEV ; INIT DEVICE AND RETURN + CALL PPIDE_INITDEV ; INIT DEVICE AND RETURN +; + LD HL,PPIDE_TIMEOUT ; POINT TO TIMEOUT + LD (HL),PPIDE_TONORM ; BACK TO NORMAL TIMEOUT +; + RET ; ; TAKE ANY ACTIONS REQUIRED TO SELECT DESIRED PHYSICAL UNIT ; UNIT IS SPECIFIED IN A ; PPIDE_SELUNIT: - ;LD HL,PPIDE_UNIT ; POINT TO PREVIOUSLY SELECTED UNIT - ;CP (HL) ; SAME? - ;RET Z ; IF SO, NOTHING MORE TO DO - + LD A,(PPIDE_UNIT) ; GET UNIT CP PPIDE_UNITCNT ; CHECK VALIDITY (EXCEED UNIT COUNT?) JP NC,PPIDE_INVUNIT ; HANDLE INVALID UNIT -; - ; NEW UNIT SELECTED, IMPLEMENT IT - ;LD (PPIDE_UNIT),A ; RECORD NEW UNIT NUMBER ; PUSH HL ; SAVE HL, IT IS DESTROYED BELOW -; + LD A,(PPIDE_UNIT) ; GET CURRENT UNIT AND $01 ; LS BIT DETERMINES MASTER/SLAVE LD HL,PPIDE_DRVSEL CALL ADDHLA LD A,(HL) ; LOAD DRIVE/HEAD VALUE -; - ;OUT (PPIDE_REG_DRVHD),A ; SELECT DRIVE - CALL PPIDE_OUT - .DB PPIDE_REG_DRVHD - LD (PPIDE_DRVHD),A ; UPDATE SHADOW REGISTER -; - ; SPEC REQUIRES 400NS DELAY BEFORE CHECKING STATUS REGISTER -; POP HL ; RECOVER HL + LD (PPIDE_DRVHD),A ; SAVE IT +; XOR A RET ; @@ -818,6 +828,25 @@ PPIDE_PROBE: CALL PPIDE_PRTPREFIX PRTS(" PROBE$") ; LABEL FOR IO ADDRESS #ENDIF +; + LD A,(PPIDE_DRVHD) + ;OUT (IDE_IO_DRVHD),A + CALL PPIDE_OUT + .DB PPIDE_REG_DRVHD + DCALL PC_SPACE + DCALL PRTHEXBYTE + + CALL DELAY ; DELAY ~16US +; + DCALL PPIDE_REGDUMP +; + ;JR PPIDE_PROBE1 ; *DEBUG* +; +PPIDE_PROBE0: + CALL PPIDE_WAITBSY ; WAIT FOR BUSY TO CLEAR + RET NZ ; ABORT ON TIMEOUT +; + DCALL PPIDE_REGDUMP ; ; CHECK STATUS ; IN A,(PPIDE_REG_STAT) ; GET STATUS @@ -828,19 +857,6 @@ PPIDE_PROBE: OR A ; SET FLAGS TO TEST FOR ZERO JP Z,PPIDE_NOMEDIA ; CONTINUE IF NON-ZERO ; -PPIDE_PROBE0: - ;CALL PPIDE_WAITBSY ; WAIT FOR BUSY TO CLEAR - ;RET NZ ; ABORT ON TIMEOUT -; - ;; CHECK STATUS - ;IN A,(PPIDE_REG_STAT) ; GET STATUS - ;DCALL PRTHEXBYTE ; IF DEBUG, PRINT STATUS - ;OR A ; SET FLAGS TO TEST FOR ZERO - ;JR NZ,PPIDE_PROBE1 ; CONTINUE IF NON-ZERO - ;DEC A ; ZERO MEANS NO MEDIA, SIGNAL ERROR - ;RET ; AND DONE -; -PPIDE_PROBE1: ; CHECK SIGNATURE DCALL PC_SPACE ;IN A,(PPIDE_REG_COUNT) @@ -871,6 +887,7 @@ PPIDE_PROBE1: CP $00 JP NZ,PPIDE_NOMEDIA ; +PPIDE_PROBE1: ; SIGNATURE MATCHES ATA DEVICE, RECORD TYPE AND RETURN SUCCESS PPIDE_DPTR(PPIDE_TYPE) ; POINT HL TO UNIT TYPE FIELD, A IS TRASHED LD (HL),PPIDE_TYPEATA ; SET THE DEVICE TYPE @@ -945,9 +962,10 @@ PPIDE_CHKDEVICE: ; ; PPIDE_WAITRDY: - LD B,15 ; ~15 SECOND TIMEOUT? + LD A,(PPIDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR PPIDE_WAITRDY1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(PPIDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR PPIDE_WAITRDY2: ;IN A,(PPIDE_REG_STAT) ; READ STATUS CALL PPIDE_IN @@ -956,7 +974,6 @@ PPIDE_WAITRDY2: AND %11000000 ; ISOLATE BUSY AND RDY BITS XOR %01000000 ; WE WANT BUSY(7) TO BE 0 AND RDY(6) TO BE 1 RET Z ; ALL SET, RETURN WITH Z SET - CALL DELAY ; DELAY 16US DEC DE LD A,D OR E @@ -967,9 +984,10 @@ PPIDE_WAITRDY2: ; ; PPIDE_WAITDRQ: - LD B,3 ; ~3 SECOND TIMEOUT??? + LD A,(PPIDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR PPIDE_WAITDRQ1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(PPIDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR PPIDE_WAITDRQ2: ;IN A,(PPIDE_REG_STAT) ; READ STATUS CALL PPIDE_IN @@ -978,7 +996,6 @@ PPIDE_WAITDRQ2: AND %10001000 ; TO FILL (OR READY TO FILL) XOR %00001000 RET Z - CALL DELAY ; DELAY 16US DEC DE LD A,D OR E @@ -989,9 +1006,10 @@ PPIDE_WAITDRQ2: ; ; PPIDE_WAITBSY: - LD B,3 ; ~3 SECOND TIMEOUT??? + LD A,(PPIDE_TIMEOUT) ; GET TIMEOUT IN 0.05 SECS + LD B,A ; PUT IN OUTER LOOP VAR PPIDE_WAITBSY1: - LD DE,-1 ; ~1 SECOND INNER LOOP + LD DE,(PPIDE_TOSCALER) ; CPU SPPED SCALER TO INNER LOOP VAR PPIDE_WAITBSY2: ;IN A,(PPIDE_REG_STAT) ; READ STATUS CALL PPIDE_IN @@ -999,7 +1017,6 @@ PPIDE_WAITBSY2: LD C,A ; SAVE IT AND %10000000 ; TO FILL (OR READY TO FILL) RET Z - CALL DELAY ; DELAY 16US DEC DE LD A,D OR E @@ -1072,7 +1089,6 @@ PPIDE_IOERR: JR PPIDE_ERR ; PPIDE_RDYTO: - CALL PC_COLON LD A,PPIDE_STRDYTO JR PPIDE_ERR ; @@ -1150,7 +1166,8 @@ PPIDE_PRTSTAT3: POP AF RET ; -; +; PRINT ALL REGISTERS DIRECTLY FROM DEVICE +; DEVICE MUST BE SELECTED PRIOR TO CALL ; PPIDE_REGDUMP: PUSH AF @@ -1232,6 +1249,9 @@ PPIDE_STR_NO .TEXT "NO$" ; DATA STORAGE ;============================================================================= ; +PPIDE_TIMEOUT .DB PPIDE_TONORM ; WAIT FUNCS TIMEOUT IN TENTHS OF SEC +PPIDE_TOSCALER .DW CPUMHZ * 961 ; WAIT FUNCS SCALER FOR CPU SPEED +; PPIDE_CMD .DB 0 ; PENDING COMMAND TO PROCESS PPIDE_DRVHD .DB 0 ; CURRENT DRIVE/HEAD MASK ; diff --git a/Source/HBIOS/sd.asm b/Source/HBIOS/sd.asm index 10e8d4a0..de6041f8 100644 --- a/Source/HBIOS/sd.asm +++ b/Source/HBIOS/sd.asm @@ -1358,11 +1358,11 @@ SD_GET1: OUT (SD_OPRREG),A ; DO IT DJNZ SD_GET1 ; REPEAT FOR ALL 8 BITS LD A,C ; GET BYTE RECEIVED INTO A -#IF (SDMODE == SDMODE_UART) + #IF (SDMODE == SDMODE_UART) XOR $FF ; DO IS INVERTED ON UART + #ENDIF #ENDIF RET -#ENDIF ; ;============================================================================= ; ERROR HANDLING AND DIAGNOSTICS diff --git a/Source/HBIOS/util.asm b/Source/HBIOS/util.asm index 14c53cea..522d1c54 100644 --- a/Source/HBIOS/util.asm +++ b/Source/HBIOS/util.asm @@ -213,10 +213,10 @@ HEXASCII: HEXCONV: AND 0FH ;LOW NIBBLE ONLY ADD A,90H - DAA + DAA ADC A,40H - DAA - RET + DAA + RET ; ; PRINT A BYTE BUFFER IN HEX POINTED TO BY DE ; REGISTER A HAS SIZE OF BUFFER @@ -244,7 +244,7 @@ DUMP_BUFFER: POP HL INC D INC D - + DB_BLKRD: PUSH BC PUSH HL @@ -258,7 +258,7 @@ DB_NXTONE: LD A,(HL) ; GET BYTE CALL PRTHEXBYTE ; PRINT IT CALL PC_SPACE ; -DB_UPDH: +DB_UPDH: INC HL ; POINT NEXT DEC C ; DEC. LOC COUNT JR NZ,DB_NXTONE ; IF LINE NOT DONE @@ -273,10 +273,10 @@ DB_PCRLF0: LD A,(HL) ; O.K. TO GET JR NZ,DB_PDOT ; DB_DOT: - LD A,2EH ; LOAD A DOT + LD A,2EH ; LOAD A DOT DB_PDOT: CALL COUT ; PRINT IT - INC HL ; + INC HL ; LD A,D ; CP H ; JR NZ,DB_UPDH1 ; @@ -292,7 +292,7 @@ DB_CONTD: CALL NEWLINE ; JP DB_BLKRD ; -DB_END: +DB_END: RET ; ; ; OUTPUT A '$' TERMINATED STRING @@ -346,11 +346,11 @@ PANIC: LD B,H LD C,L CALL PRTHEXWORD - + RST 38 - + HALT - + JP 0 ; ;================================================================================================== @@ -534,7 +534,7 @@ ADDHLA: RET ; ;**************************** -; A(BCD) => A(BIN) +; A(BCD) => A(BIN) ; [00H..99H] -> [0..99] ;**************************** ; @@ -555,7 +555,7 @@ BCD2BYTE: RET ; ;***************************** -; A(BIN) => A(BCD) +; A(BIN) => A(BCD) ; [0..99] => [00H..99H] ;***************************** ; @@ -720,6 +720,22 @@ MULT8_LOOP: MULT8_NOADD: DJNZ MULT8_LOOP RET +; +; MULTIPLY A 16 BIT BY 8 BIT INTO 16 BIT +; IN: MULTIPLY DE BY A +; OUT: HL = RESULT, B=0, A, C, DE UNCHANGED +; +MULT8X16: + LD B,8 + LD HL,0 +MULT8X16_1: + ADD HL,HL + RLCA + JR NC,MULT8X16_2 + ADD HL,DE +MULT8X16_2: + DJNZ MULT8X16_1 + RET ;; ;; COMPUTE HL / DE ;; RESULT IN BC, REMAINDER IN HL, AND SET ZF DEPENDING ON REMAINDER @@ -1023,13 +1039,13 @@ KY_STATLOOP: ; DECODE THE RAW VALUE KY_DECODE: LD D,00H - LD HL,KY_KEYMAP ; POINT TO BEGINNING OF TABLE + LD HL,KY_KEYMAP ; POINT TO BEGINNING OF TABLE KY_GET_LOOP: CP (HL) ; MATCH? JR Z,KY_GET_DONE ; FOUND, DONE INC HL INC D ; D + 1 - JR NZ,KY_GET_LOOP ; NOT FOUND, LOOP UNTIL EOT + JR NZ,KY_GET_LOOP ; NOT FOUND, LOOP UNTIL EOT KY_GET_DONE: ; CLEAR OUT KEY_BUF XOR A @@ -1037,7 +1053,7 @@ KY_GET_DONE: ; RETURN THE INDEX POSITION WHERE THE RAW VALUE WAS FOUND LD A,D RET -; +; ;__KY_SCAN____________________________________________________________________________________________ ; ; SCAN KEYBOARD MATRIX FOR AN INPUT @@ -1051,7 +1067,7 @@ KY_SCAN: IN A,(PPIB) ; GET ROWS AND 7FH ;ignore PB7 for PPISD CP 00H ; ANYTHING PRESSED? - JR NZ,KY_SCAN_FOUND ; YES, EXIT + JR NZ,KY_SCAN_FOUND ; YES, EXIT LD C,0040H LD A,42H | 30H ; SCAN COL TWO @@ -1060,7 +1076,7 @@ KY_SCAN: IN A,(PPIB) ; GET ROWS AND 7FH ;ignore PB7 for PPISD CP 00H ; ANYTHING PRESSED? - JR NZ,KY_SCAN_FOUND ; YES, EXIT + JR NZ,KY_SCAN_FOUND ; YES, EXIT LD C,0080H LD A,44H | 30H ; SCAN COL THREE @@ -1069,7 +1085,7 @@ KY_SCAN: IN A,(PPIB) ; GET ROWS AND 7FH ;ignore PB7 for PPISD CP 00H ; ANYTHING PRESSED? - JR NZ,KY_SCAN_FOUND ; YES, EXIT + JR NZ,KY_SCAN_FOUND ; YES, EXIT LD C,00C0H ; LD A,48H | 30H ; SCAN COL FOUR @@ -1078,7 +1094,7 @@ KY_SCAN: IN A,(PPIB) ; GET ROWS AND 7FH ;ignore PB7 for PPISD CP 00H ; ANYTHING PRESSED? - JR NZ,KY_SCAN_FOUND ; YES, EXIT + JR NZ,KY_SCAN_FOUND ; YES, EXIT LD A,040H | 30H ; TURN OFF ALL COLUMNS OUT (PPIC),A ; SEND TO COLUMN LINES @@ -1087,7 +1103,7 @@ KY_SCAN: KY_SCAN_FOUND: AND 3FH ; CLEAR TOP TWO BITS - OR C ; ADD IN ROW BITS + OR C ; ADD IN ROW BITS LD C,A ; STORE VALUE ; WAIT FOR KEY TO BE RELEASED @@ -1107,7 +1123,7 @@ KY_CLEAR_LOOP: ; WAIT FOR KEY TO CLEAR RET ; ;_KEYMAP_TABLE_____________________________________________________________________________________________________________ -; +; KY_KEYMAP: ; 0 1 2 3 4 5 6 7 .DB 041H,002H,042H,082H,004H,044H,084H,008H @@ -1156,7 +1172,7 @@ DSKY_HEXOUT2: JP Z,DSKY_STROBE ; DO FINAL STROBE AND RETURN CALL DSKY_STROBE JR DSKY_HEXOUT2 - + DSKY_STROBEC: LD A,80H | 30H JP DSKY_STROBE0