mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:13:13 -06:00
* added hack to handle tunes * quiet clean * added chmod for execution * suppress warnings * Multi-boot fixes * the windows build somehow thinks that these filesystems are cpm3. * credit and primitive instructions * Update sd.asm Cosmetic fix. * make compile shut up about conditionals * Add bin2asm for linus and update build to process font files under linix * fixed quoted double quote bug, added tests * added tests * added bin2asm for font file source creation * Revert linux bin2asm font stuff * added rule for font source generation * build fonts * added directory mapping cache. if the same directory is being hit as last run, we don't need to rebuild the map. will likely break if you are running more than one at a time, in that the cache will be ineffective. also, if the directory contents change, this will also break. * removed strip. breaks osx * added directory tag so . isn't matched all over the place * added real cache validation * fixed build * this file is copied from optdsk.lib or optcmd.lib * install to ../HBIOS * prerequisite verbosity * diff soft failure and casefn speedup * added lzsa * added lzsa * removed strip. breaks on osx * added clobber * added code to handle multiple platform rom builds with rom size override * added align and 0x55 hex syntax * default to hd64180 * added N8 capability * added SBC_std.rom to default build * added support for binary diff * diff fixes * clean, identical build. font source generator emitted .align. this does not match the windows build * Upgrade NZCOM to latest * Misc. Cleanup * fixed expression parser bug : ~(1|2) returned 0xfe * added diff build option * Update Makefile Makefile enhancement to better handle ncurses library from Bob Dunlop. * Update sd.asm Back out hack for uz80as now that Curt fixed it. * Misc. Cleanup * UNA Catchup UNA support was lacking some of the more recent behavior changes. This corrects most of it. * Add github action for building RomWBW * Bump Pre-release Version * Update build.yml Added "make clean" which will remove temporary files without removing final binary outputs. * Update Makefile Build all ROM variants by default in Linux/Mac build. * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update for GitHub Build Case issue in TASM includes showing up in GitHub build. This should correct that. * Added an gitignore files to exclude generated files * Removed Tunes/clean.cmd and Tunes/ReadMe.txt - as make clean removes them * Build.sh: marked as executable chmod +x Build.sh * Fix to HBIOS/build.sh When adding files to rom disk, if files were missing, it would error out. It appears the intent is to skip non-existing files. Updated to log out correctly for missing files - and continue operation. * Update Microsoft NASCOM BASIC.docx Nascom manual, text version by Jan S (full name unknown) * Fix issue with Apps/Tune not making If dest directory does not exist, fails to make Apps * Create ReadMe.txt * Update Makefile * Update Build.sh * Make .gitignores for Tools/unix more specific * cpmtools Update Updated cpmtools applications (Windows only). Removed hack in diskdefs that is no longer required. * HBIOS Proxy Temp Stack Enhancement Reuse the bounce buffer area as the temporary stack space required briefly in HBX_INVOKE when transitioning banks. Increases size of temporary stack space to 64 bytes. * Update ReadMe.txt * HBIOS - clean up TMPSTK * Update hbios.asm Minor cosmetic changes. * Build Process Updates Minor udpates to build process to improve consistency between Windows and Mac/Linux builds. * Update hbios.asm Add improved interrupt protection to HBIOS PEEK, POKE, and BNKCPY functions. * hbios - wrap hbx_bnkcpy * hbios - adjust hbx_peek hbx_poke guards * Update hbios.asm Adjusted used of DI/EI for PEEK and POKE to regain a bit of INTSTK space. Added code so that HB_INVBNK can be used as a flag indicating if HBIOS is active, $FF is inactive, anything else means active. * Add HBIOS MuTex * Initial Nascom basic ecb-vdu graphics set and reset for 80x25b screen with 256 character mod * Finalize Pre-release 34 Final support for FreeRTOS * Update nascom.asm Optimization, cleanup, tabs and white spaces * IDE & PPIDE Cleanup * Clean up Make version include files common. * Update Makefile * Update Makefile * Build Test * Build Test * Build Fixes * Update nascom.asm Cleanup * Update nascom.asm Optimization * hbios - temp stack tweak * Update hbios.asm Comments on HBX_BUF usage. * Update nascom.asm Optimization * Update nascom.asm Setup ECB-VDU build option, remove debug code * Update nascom.asm Set default build. update initialization * Update nascom.asm Make CLS clear vdu screen * Update nascom.asm Fixup top screen line not showing * Add SC131 Support Also cleaned up some ReadMe files. * HBIOS SCZ180 - remove mutex special files * HBIOS SCZ180 - adjust mutex comment * Misc. Cleanup Includes some minor improvements to contents in some disk images. * Delete FAT.COM Changing case of FAT.COM extension to lowercase. * Create FAT.com Completing change of case in extension of FAT.com. * Update Makefile Remove ROM variants that just have the HBIOS MUTEX enabled. Users can easily enable this in a custom build. * Cleanup Removed hack from Images Makefile. Fixed use of DEFSERCFG in various places. * GitHub CI Updates Adds automation of build and release assets upon release. * Prerelease 36 General cleanup * Build Script Cleanups * Config File Cleanups * Update RomWBW Architecture General refresh for v2.9.2 * Update vdu.asm Removed a hack in VDU driver that has existed for 8 years. :-) * Fix CONSOLE Constant Rename CIODEV_CONSOLE constant to CIO_CONSOLE because it is a unit code, not a device type code. Retabify TastyBasic. * Minor Bug Fixes - Disk assignment edge case - CP/M 3 accidental fall thru - Cosmetic updates * Update util.z80 * Documentation Cleanup * Documentation Update * Documentation Update * Documentation Updates * Documentation Updates * Create Common.inc * Documentation Updates * Documentation Updates * doc - a few random fixes * Documentation Cleanup * Fix IM 0 Build Error in ACIA * Documentation Updates * Documentation Cleanup * Remove OSLDR The OSLDR application was badly broken and almost impossible to fix with new expanded OS support. * Bug Fixes - Init RAM disk at boot under CP/M 3 - Fix ACR activation in TUNE * FD Motor Timeout - Made FDC motor timeout smaller and more consistent across different speed CPUs - Added "boot" messaging to RTC * Cleanup * Cleanup - Fix SuperZAP to work under NZCOM and ZPM3 - Finalize standard config files * Minor Changes - Slight change to ZAP configuration - Added ZSDOS.ZRL to NZCOM image * ZDE Upgrade - Upgraded ZDE 1.6 -> 1.6a * Config File Tuning * Pre-release for Testing * cfg - mutex consistent config language * Bump to Version 3.0 * Update SD Card How-To Thanks David! * update ReadMe.md Remove some odd `\`. * Update ReadMe.txt * Update ReadMe.md * Update Generated Doc Files * Improve XModem Startup - Extended startup timeout for XM.COM so that it doesn't timeout so quickly while host is selecing a file to send. - Updated SD Card How-To from David Reese. * XModem Timing Refinements * TMS Driver Z180 Improvements - TMS driver udpated to insert Z180 I/O waitstates internally so other code can run at full speed. - Updated How-To documents from David. - Fixed TUNE app to properly restore Z180 I/O waitstates after manipulating them. * CLRDIR and ZDE updates - CLRDIR has been updated by Max Scane for CP/M 3 compatibility. - A minor issue in the preconfigured ZDE VT100 terminal escape sequences was corrected. * Fix Auto CRT Console Switch on CP/M 3 * Handle lack of RTC better DSRTC driver now correctly returns an error if there is no RTC present. * Minor RTC Updates * Finalize v3.0.1 Cleanup release for v3.0 * New ROMLDR and INTRTC driver - Refactored romldr.asm - Added new periodic timer based RTC driver * CP/M 3 Date Hack - Hack to allow INTRTC to increment time without destroying the date * Update romldr.asm Work around minor Linux build inconsistency * Update Apps for New Version * Revert "Update Apps for New Version" This reverts commitad80432252. * Revert "Update romldr.asm" This reverts commit4a9825cd57. * Revert "CP/M 3 Date Hack" This reverts commit153b494e61. * Revert "New ROMLDR and INTRTC driver" This reverts commitd9bed4563e. * Start v3.1 Development * Update FDISK80.COM Updated FDISK80 to allow reserving up to 256 slices. * Update sd.asm For Z180 CSIO, ensure that xmit is finished, before asserting CS for next transaction. * Add RC2014 UART, Improve SD protocol fix - RC2014 and related platforms will autodetect a UART at 0xA0 and 0xA8 - Ensure that CS fully brackets all SD I/O * ROMLDR Improvements .com files can now be started from CP/M and size of .com files has been reduced so they always fit. * Update commit.yml Run commit build in all branches * Update commit.yml Run commit build for master and dev branches * Improved clock driver auto-detect/fallback * SIO driver now CTC aware The SIO driver can now use a CTC (if available) to provide much more flexible baud rate programming. * CTC driver fine tuning * Update xmdm125.asm Fixed a small issue in core XM125 code that caused a file write error message to not be displayed when it should be. * CF Card compatibility improvement Older CF Cards did not reset IDE registers to defaults values when reset. Implemented a work around. * Update ACIA detection ACIA should no longer be detected if there is also a UART module in the system. * Handle CTC anomaly Small update to accommodate CTC behavior that occurs when the CTC trigger is more than half the CTC clock. * Update acia.asm Updated ACIA detection to use primary ACIA port instead of phantom port. * Update acia.asm Fix bug in ACIA detection. Thanks Alan! * MacOS Build Improvement Build script updated to improve compatibility with MacOS. Credit to Fredrik Axtelius for this. * HBIOS Makefile - use env vars for target Allow build ROM targets to be restricted to just one platform thru use of ENV vars: ROM_PLATFORM - if defined to a known platform, only this platform is build - defaults to std config ROM_CONFIG - sets the desired platform config - defaults to std if the above ENVs are not defined, builds all ROMs * Added some more gitignores * Whitespace changes (crlf) * HBIOS: Force the assembly to fail for vdu drivers if function table count is not correct * Whitespace: trailing whitespaces * makefile: updated some make scripts to use when calling subdir makefiles * linux build: update to Build.sh fix for some platforms The initialization of the Rom dat file used the pipe (|) operator to build an initial empty file. But the pipe operator | may sometimes return a non-zero exit code for some linux platforms, if the the streams are closed before dd has fully processed the stream. This issue occured on a travis linux ubuntu image. Solution was to change to redirection. * Bump version * Enhance CTC periodic timer Add ability to use TIMER mode in CTC driver to generate priodic interrupts. * HBIOS: Added support for sound drivers New sound driver support with initial support for the SN76489 chip New build configuration entry: * SN76489ENABLE Ports are currently locked in with: * SN76489_PORT_LEFT .EQU $FC ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT) * SN76489_PORT_RIGHT .EQU $F8 ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT) * Miscellaneous Cleanup No functional changes. Co-authored-by: curt mayer <curt@zen-room.org> Co-authored-by: Wayne Warthen <wwarthen@gmail.com> Co-authored-by: ed <linux@maidavale.org> Co-authored-by: Dean Netherton <dnetherton@dius.com.au> Co-authored-by: ed <ed@maidavale.org> Co-authored-by: Phillip Stevens <phillip.stevens@gmail.com> Co-authored-by: Dean Netherton <dean.netherton@gmail.com>
606 lines
13 KiB
Plaintext
606 lines
13 KiB
Plaintext
;
|
||
; PROGRAM: LDR
|
||
; AUTHOR: RICHARD CONN
|
||
; VERSION: 1.0
|
||
; DATE: 27 FEB 84
|
||
; PREVIOUS VERSIONS: 0.1 (3 Feb 84), 0.2 (22 Feb 84), 1.1 (28 Sep 84)
|
||
;
|
||
;VERSION EQU 10
|
||
|
||
;VERSION EQU 11 ; Version 1.1 by Joe Wright 28 Sept 84
|
||
|
||
; This version modified to allow loading the .ENV
|
||
; file the first time, when there is no environment
|
||
; descriptor in memory. The program now takes
|
||
; the environment address from the .ENV file so
|
||
; that subsequent files are also loaded correctly.
|
||
; ie. LDR SYS.ENV,SYS.RCP,etc. Note that .ENV must
|
||
; be the first declared file until LDR is installed
|
||
; to your environment. jww
|
||
|
||
VERSION EQU 12 ; Version 1.2 by Dave Lucky 31 Dec 84
|
||
|
||
; This version modified to correct exit regs from
|
||
; SDLOAD subroutine. The Source and Destination
|
||
; registers on entry were HL and DE, respectively.
|
||
; On exit, they were DE and HL. The calling routine
|
||
; (SETDATA) went amuck when calculating number of NDR
|
||
; records using bogus DE. Also, corrected the SETDATA
|
||
; routine from using the incorrect address of the NDR
|
||
; entry size field as well as its contents acquired
|
||
; from the GETNDR routine.
|
||
|
||
EXTENV EQU 1 ; 1 for External Environ, 0 for Internal Environ
|
||
|
||
;
|
||
; LDR is a general-purpose package loader for ZCPR3. It is
|
||
; invoked by the following form:
|
||
;
|
||
; LDR <list of packages>
|
||
;
|
||
; For example:
|
||
; LDR DEFAULT.RCP,SYSIO.IOP
|
||
;
|
||
; No default file types are assumed on the list of packages, and
|
||
; each package specified must be unambigous and have a type of RCP or IOP
|
||
; (for Resident Command Package or Input/Output Package). LDR
|
||
; checks to make sure that the files are valid packages and then loads
|
||
; them into memory at the correct locations, checking for package boundary
|
||
; overflow.
|
||
;
|
||
;
|
||
|
||
;
|
||
; ZCPR3 Header
|
||
;
|
||
MACLIB Z3BASE.LIB
|
||
|
||
;
|
||
; System Equates
|
||
;
|
||
bdos equ 5
|
||
fcb equ 5ch
|
||
tbuff equ 80h
|
||
rcpflg equ 1 ; package type is RCP
|
||
iopflg equ 2 ; package type is IOP
|
||
fcpflg equ 3 ; package type is FCP
|
||
ndrflg equ 4 ; package type is NDR
|
||
envflg equ 5 ; package type is ENV
|
||
tcapflg equ 6 ; package type is Z3T
|
||
cr equ 0dh
|
||
lf equ 0ah
|
||
|
||
ext z3init,envptr
|
||
ext retud,getud,putud,logud
|
||
ext getrcp,getfcp,getiop,getndr
|
||
ext f$open,f$close,f$read
|
||
ext print,pfn2
|
||
ext hmovb,moveb,fillb
|
||
ext cline,sksp,zfname
|
||
|
||
;
|
||
; Environments
|
||
;
|
||
origin:
|
||
;
|
||
if extenv ; if external environment ...
|
||
;
|
||
; External Environment Definition
|
||
;
|
||
jmp z3ldr
|
||
db 'Z3ENV' ; this is an environment
|
||
db 1 ; class 1 environment (external)
|
||
envloc:
|
||
dw z3env ; ptr to environment
|
||
z3ldr:
|
||
lhld envloc ; HL pts to environment
|
||
|
||
else ; if internal environment ...
|
||
;
|
||
; Internal Environment Definition
|
||
;
|
||
MACLIB SYSENV.LIB
|
||
envloc:
|
||
jmp z3ldr
|
||
SYSENV ; define environment
|
||
z3ldr:
|
||
lxi h,envloc ; HL pts to environment
|
||
|
||
endif
|
||
|
||
;
|
||
; Beginning of LDR
|
||
;
|
||
call z3init ; initialize environment pointer
|
||
call banner ; print banner
|
||
lxi h,tbuff ; pt to command line
|
||
call cline ; save command line as string
|
||
call sksp ; skip over spaces
|
||
mov a,m ; get offending char
|
||
cpi '/' ; help?
|
||
jz help
|
||
ora a ; help?
|
||
jz help
|
||
;
|
||
; Main Loop - HL pts to next file name in list
|
||
;
|
||
z3ldr1:
|
||
lxi d,fcb ; pt to fcb
|
||
call zfname ; extract file name and data
|
||
inx d ; pt to file name
|
||
call print
|
||
db cr,lf,' Loading ',0
|
||
call pfn2 ; print file name
|
||
push h ; save ptr
|
||
call pkload ; load file
|
||
pop h ; get ptr
|
||
mov a,m ; get char
|
||
inx h ; pt to next char
|
||
cpi ',' ; another file in list?
|
||
jz z3ldr1
|
||
ret
|
||
;
|
||
; Print Help Message
|
||
;
|
||
help:
|
||
call print
|
||
db cr,lf,' LDR Syntax:'
|
||
db cr,lf,' LDR <list of packages/data files>'
|
||
db cr,lf,' where entries in the list may be any of these types:'
|
||
db cr,lf
|
||
db cr,lf,' FCP - Flow Cmnd Package ENV - Z3 Environ'
|
||
db cr,lf,' IOP - Input/Output Package NDR - Z3 Named Dir'
|
||
db cr,lf,' RCP - Resident Cmnd Package Z3T - Z3TCAP Entry'
|
||
db cr,lf,lf,' The ENV file must be first if LDR is not installed.'
|
||
db cr,lf,0
|
||
ret
|
||
;
|
||
; Load package named in FCB
|
||
;
|
||
pkload:
|
||
call setdata ; load data buffers from environment in case of change
|
||
call cktype ; check for valid file type
|
||
jz typerr ; abort if error
|
||
call open ; open file, read in first block, check for valid
|
||
jz getud ; abort if error
|
||
|
||
; Check if ENV. If so, get Z3ENV and call z3init
|
||
|
||
push h ; save package pointer from cktype
|
||
lxi d,fcb+9 ; fcb type
|
||
lxi h,envtyp ; ENV?
|
||
call comptyp ; compare types
|
||
pop h ; get package pointer
|
||
jnz pkld ; not ENV, proceed normally
|
||
;
|
||
; File type is ENV. Get Z3ENV address from file and re-initialize
|
||
;
|
||
lxi h,tbuff ; first sector in tbuff
|
||
lxi d,1bh ; offset to Z3ENV
|
||
dad d ; point hl to it
|
||
mov e,m ; get Z3ENV
|
||
inx h
|
||
mov d,m ; got it
|
||
xchg ; in hl
|
||
call z3init ; set new environment
|
||
|
||
pkld: call load ; load package into memory at correct location
|
||
call close ; close up process
|
||
call getud ; return home
|
||
;
|
||
; Check for IOP and return if not
|
||
;
|
||
lda pktype ; init package if IOP
|
||
cpi iopflg
|
||
rnz
|
||
;
|
||
; Init IOP
|
||
;
|
||
lhld packadr ; get address
|
||
lxi d,9 ; 4th JMP into it
|
||
dad d
|
||
push h ; address on stack
|
||
ret ; "CALL" routine and return to OS
|
||
;
|
||
; Load Data Buffers from Environment
|
||
;
|
||
setdata:
|
||
lhld envptr ; get environment descriptor address
|
||
shld envadr
|
||
lxi d,80H ; pt to Z3TCAP
|
||
dad d
|
||
shld tcapadr
|
||
call getrcp ; get RCP data
|
||
lxi d,rcpdata ; load
|
||
call sdload
|
||
call getiop ; get IOP data
|
||
lxi d,iopdata ; load
|
||
call sdload
|
||
call getfcp ; get FCP data
|
||
lxi d,fcpdata ; load
|
||
call sdload
|
||
lxi h,ndridat ; init NDR data in case no entry
|
||
lxi d,ndrdata
|
||
mvi b,9 ; 9 bytes (1-jmp, 5-ID, 2-adr, 1-size)
|
||
call moveb
|
||
call getndr ; get NDR data
|
||
mov b,a ; save entry count ;1284DL
|
||
mov a,h ; no NDR data?
|
||
ora l
|
||
rz
|
||
mov a,b ; restore entry count ;1284DL
|
||
call sdload ; with DE -> ndrdata ;1284DL
|
||
push d ; save ptr to entry count ;1284DL
|
||
mvi h,0 ; HL = value
|
||
mov l,a ; A = entry count
|
||
dad h ; *2
|
||
mov d,h ; DE = value * 2
|
||
mov e,l
|
||
dad h ; *4
|
||
dad h ; *8
|
||
dad h ; *16
|
||
dad d ; *18
|
||
mov a,h ; /128
|
||
rlc
|
||
ani 0feh
|
||
mov h,a
|
||
mov a,l
|
||
rlc
|
||
ani 1
|
||
ora h ; A = value * 18 / 128
|
||
inr a ; +1
|
||
pop d ; get ptr
|
||
stax d ; save value
|
||
ret
|
||
;
|
||
; Load 3 bytes pted to by HL into memory pted to by DE+6
|
||
;
|
||
; Input Regs: ;1284DL
|
||
; HL = Source ;1284DL
|
||
; DE = Destination ;1284DL
|
||
; ;1284DL
|
||
; Output Regs: ;1284DL
|
||
; HL = Source ;1284DL
|
||
; DE = Destination+8 ;1284DL
|
||
; ;1284DL
|
||
sdload:
|
||
push h ; save ptr to data
|
||
lxi h,6 ; add 6 to DE to pt to proper buffer
|
||
dad d ; HL pts to buffer
|
||
pop d ; DE contains address
|
||
mov m,e ; store address
|
||
inx h
|
||
mov m,d
|
||
inx h
|
||
mov m,a ; store size data
|
||
xchg ; swap Source / Destination regs ;1284DL
|
||
ret
|
||
;
|
||
; Print Banner
|
||
;
|
||
banner:
|
||
call print
|
||
db cr,lf,'ZCPR3 LDR, Version '
|
||
db (VERSION/10)+'0','.',(VERSION MOD 10)+'0',0
|
||
ret
|
||
;
|
||
; Check for Valid Package File Type
|
||
; Return with Zero Flag Set if error
|
||
; If validated, PKTYPE contains package type and HL pts to data
|
||
;
|
||
cktype:
|
||
lxi d,fcb+9 ; pt to file type
|
||
lxi h,rcptyp ; see if RCP
|
||
mvi b,rcpflg ; RCP code
|
||
call comptyp ; compare
|
||
jz cktok ; OK if match
|
||
lxi h,ioptyp ; see if IOP
|
||
mvi b,iopflg ; IOP code
|
||
call comptyp ; compare
|
||
jz cktok ; OK if match
|
||
lxi h,fcptyp ; see if FCP
|
||
mvi b,fcpflg ; FCP code
|
||
call comptyp ; compare
|
||
jz cktok ; OK if match
|
||
lxi h,ndrtyp ; see if NDR
|
||
mvi b,ndrflg ; NDR code
|
||
call comptyp ; compare
|
||
jz cktok ; OK if match
|
||
lxi h,envtyp ; see if ENV
|
||
mvi b,envflg ; ENV code
|
||
call comptyp ; compare
|
||
jz cktok ; OK if match
|
||
lxi h,tcaptyp ; see if Z3TCAP
|
||
mvi b,tcapflg ; Z3T code
|
||
call comptyp ; compare
|
||
jz cktok
|
||
mvi b,0 ; invalid type
|
||
cktok:
|
||
mov a,b ; set package type
|
||
sta pktype
|
||
ora a ; set NZ if no error
|
||
ret
|
||
comptyp:
|
||
push d ; save regs
|
||
push b
|
||
mvi b,3 ; 3 bytes
|
||
compt1:
|
||
ldax d ; get FCB char
|
||
ani 7fh ; mask
|
||
cmp m ; compare
|
||
jnz compt2
|
||
inx h ; pt to next
|
||
inx d
|
||
dcr b ; count down
|
||
jnz compt1
|
||
compt2:
|
||
pop b ; restore regs
|
||
pop d
|
||
ret
|
||
typerr:
|
||
call prf ; print file name and string
|
||
db ' is not a Valid Type',0
|
||
ret
|
||
;
|
||
; Open File and Load First Block into TBUFF
|
||
; Validate Package Structure and Return with Zero Flag Set if Error
|
||
; On input, HL pts to data buffer
|
||
; If no error, HL points to load address and B is number of 128-byte
|
||
; pages allowed in buffer
|
||
;
|
||
open:
|
||
call putud ; save location
|
||
call retud ; get UD in BC
|
||
lda fcb ; get disk
|
||
ora a ; default?
|
||
jz open0
|
||
mov b,a ; disk in B (A=1)
|
||
dcr b ; adjust to A=0
|
||
open0:
|
||
lda fcb+13 ; get user
|
||
mov c,a ; user in C
|
||
call logud ; log into UD
|
||
xra a ; clear disk
|
||
sta fcb
|
||
|
||
;
|
||
; Disallow Ambiguous File Name
|
||
;
|
||
call ambchk ; check for ambiguous file name
|
||
jz amberr ; abort if any ambiguity
|
||
;
|
||
; Open File
|
||
;
|
||
lxi d,fcb ; pt to FCB
|
||
call f$open ; open file
|
||
jnz fnferr ; abort if file not found
|
||
;
|
||
; Read First 128-byte Block
|
||
;
|
||
call f$read ; read in first block
|
||
jnz fempty ; abort if file empty
|
||
;
|
||
; Validate Package
|
||
; Package Data Area is structured as follows:
|
||
; DB numjmps ; number of jumps at beginning of package
|
||
; DB 'Z3xxx' ; package ID (always 5 chars)
|
||
; DW address ; address of memory buffer
|
||
; DB size ; number of 128-byte blocks in memory buffer
|
||
;
|
||
xchg ; DE pts to package data
|
||
ldax d ; get number of jumps
|
||
inx d ; pt to package ID
|
||
mov b,a ; jump count in B
|
||
;
|
||
; Validate Package - MUST have proper number of JMPs
|
||
;
|
||
lxi h,tbuff ; check jumps
|
||
open1:
|
||
mov a,b ; at limit of jumps?
|
||
ora a
|
||
jz open2
|
||
dcr b ; count down
|
||
mov a,m ; check for JMP
|
||
cpi 0C3H ; JMP?
|
||
jnz strerr ; structure error
|
||
inx h ; pt to next
|
||
inx h
|
||
inx h
|
||
jmp open1
|
||
;
|
||
; Check Package ID - must match
|
||
;
|
||
open2:
|
||
mvi b,5 ; check package ID
|
||
open3:
|
||
ldax d ; get byte
|
||
cpi ' ' ; no ID if space
|
||
jz open4
|
||
cmp m ; check
|
||
jnz strerr ; structure error
|
||
open4:
|
||
inx d ; pt to next
|
||
inx h
|
||
dcr b ; count down
|
||
jnz open3
|
||
;
|
||
; Extract Package Address
|
||
;
|
||
ldax d ; get low-order address
|
||
mov l,a ; put in HL
|
||
inx d
|
||
ldax d ; get high-order address
|
||
mov h,a
|
||
inx d
|
||
;
|
||
; Check for Valid Package Address
|
||
;
|
||
mov a,h ; must not be zero
|
||
ora l
|
||
jz adrerr
|
||
;
|
||
; Extract 128-byte Block Count
|
||
;
|
||
ldax d ; get block count
|
||
mov b,a ; put in B
|
||
xra a ; set flags
|
||
dcr a ; NZ
|
||
ret
|
||
;
|
||
; Ambiguous File Name Check
|
||
; Returns with Z Set if Ambiguous
|
||
;
|
||
ambchk:
|
||
lxi d,fcb+1 ; check for ambiguous file name
|
||
mvi b,11 ; 11 chars
|
||
ambchk1:
|
||
ldax d ; get char
|
||
ani 7fh ; mask
|
||
cpi '?'
|
||
rz
|
||
inx d ; pt to next
|
||
dcr b ; count down
|
||
jnz ambchk1
|
||
dcr b ; set NZ flag
|
||
ret
|
||
|
||
;
|
||
; Error Messages
|
||
;
|
||
amberr:
|
||
call prf ; print file name and message
|
||
db ' is Ambiguous',0
|
||
erret:
|
||
xra a ; set error code
|
||
ret
|
||
adrerr:
|
||
call prf ; print file name and message
|
||
db ' Not Known to Environ',0
|
||
jmp erret
|
||
fnferr:
|
||
call prf ; print file name and message
|
||
db ' Not Found',0
|
||
jmp erret
|
||
fempty:
|
||
call prf ; print file name and message
|
||
db ' Empty',0
|
||
jmp erret
|
||
strerr:
|
||
call prf ; print file name and message
|
||
db ' Contains a Format Flaw',0
|
||
jmp erret
|
||
prf:
|
||
call print
|
||
db cr,lf,' File ',0
|
||
lxi d,fcb+1
|
||
call pfn2
|
||
jmp print
|
||
|
||
;
|
||
; Close File
|
||
;
|
||
close:
|
||
lxi d,fcb ; pt to FCB
|
||
jmp f$close ; close file
|
||
|
||
;
|
||
; Load File Into Buffer
|
||
;
|
||
load:
|
||
shld packadr ; save package address in case of error
|
||
xchg ; DE pts to buffer, B = Max Blocks
|
||
load1:
|
||
push b ; save count
|
||
lxi h,tbuff ; pt to buffer
|
||
mvi b,128
|
||
call hmovb ; copy TBUFF into Buffer
|
||
push d ; save ptr to next block in buffer
|
||
lxi d,fcb ; pt to fcb
|
||
call f$read ; read next block
|
||
pop d ; get ptr
|
||
pop b ; get count
|
||
rnz ; done if NZ
|
||
dcr b ; count down
|
||
jnz load1
|
||
;
|
||
; Buffer Full
|
||
;
|
||
call prf
|
||
db ' is too Large',0
|
||
lhld packadr ; clear package
|
||
mvi b,128 ; NOPs
|
||
xra a
|
||
call fillb
|
||
lxi b,128 ; pt to after last NOP
|
||
dad b
|
||
mvi b,3 ; copy 3 bytes
|
||
xchg ; DE pts to empty space
|
||
lxi h,ercode ; store error code
|
||
jmp moveb
|
||
;
|
||
; Error Code to be Stored if Package Load Fails
|
||
;
|
||
ercode:
|
||
xra a ; 3 bytes
|
||
dcr a ; A=0FFH and NZ Flag Set
|
||
ret
|
||
|
||
;
|
||
; Buffers
|
||
;
|
||
ndridat:
|
||
db 0 ; no JMPs
|
||
db ' ' ; no ID stored
|
||
dw 0 ; address
|
||
db 0 ; (z3ndirs*18)/128+1 size
|
||
rcptyp:
|
||
db 'RCP' ; file type of RCP file
|
||
rcpdata:
|
||
db 0 ; 0 JMPs
|
||
db 'Z3RCP' ; ID
|
||
dw 0 ; address
|
||
db 0 ; size
|
||
ioptyp:
|
||
db 'IOP' ; file type of IOP file
|
||
iopdata:
|
||
db 16 ; 16 JMPs
|
||
db 'Z3IOP' ; ID
|
||
dw 0 ; address
|
||
db 0 ; size
|
||
fcptyp:
|
||
db 'FCP' ; file type of FCP file
|
||
fcpdata:
|
||
db 0 ; 0 JMPs
|
||
db 'Z3FCP' ; ID
|
||
dw 0 ; address
|
||
db 0 ; size
|
||
ndrtyp:
|
||
db 'NDR' ; file type of NDR file
|
||
ndrdata:
|
||
db 0 ; no JMPs
|
||
db ' ' ; no ID stored
|
||
dw 0 ; address
|
||
db 0 ; (z3ndirs*18)/128+1 size
|
||
envtyp:
|
||
db 'ENV' ; file type of ENV file
|
||
envdata:
|
||
db 1 ; 1 JMP
|
||
db 'Z3ENV' ; ID
|
||
envadr:
|
||
dw 0 ; address
|
||
db 2 ; 2 128-byte blocks max
|
||
tcaptyp:
|
||
db 'Z3T' ; file type of Z3TCAP file
|
||
tcapdata:
|
||
db 0 ; no JMPs
|
||
db ' ' ; no ID stored
|
||
tcapadr:
|
||
dw 0 ; address
|
||
db 1 ; 1 128-byte block max
|
||
pktype:
|
||
ds 1 ; package type (0=error)
|
||
packadr:
|
||
ds 2 ; package address
|
||
|
||
end
|
||
|