home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-07 | 34.3 KB | 1,572 lines |
- .z80
- title custom BIOS for Turbo-ROM with MicroSphere RAM disk
- subttl Documentation
-
- if false
-
- Universal High-BIOS for Turbo ROM
-
- copyright 1985 (c), Plu*Perfect Systems
- p.o. box 1494
- Idyllwild, California 92349
-
- This code is provided for the use of owners of the Advent Products
- Turbo ROM (Kaypro versions). It relies heavily on the presence of
- the Turbo ROM and will not work without it. Additional code has
- been added to support the MicroSphere RAM disk. Print buffer
- functions and ramdisk access are provided.
-
- Syntax adjusted for assembly with Z80ASM
-
- ;=================================================================
- ***** modification log *****
-
-
- 13 Oct. 89 v2.0A
-
- Conversion to assembly by Z80ASM. Removed Z3 code since
- with ZCPR34 all Z matters are handled more efficiently by the
- NZ-COM loader. Added code for MicroSphere RAM disk. Added
- code to return hibit keys with console status. Added extra
- jumps to handle print buffer control and return iflag address.
- Removed configuration code to external file for easy assembly.
- -- Lindsay Haisley
- 07 june 87 v1.3a
- Conversion for assembly by zasm. Added equates to control
- location of the bios stack, to log into a15: on boot, to
- include or not include environment. Made initial command
- a macro for easier modification. Signon banner will
- customize itself according to ccp location. Removed one
- defb 0 that was overwriting the ccp's first byte (C3h).
- -- Michal Carson
- 24 may 86 v1.2
- Conversion for zcpr3 and zrdos 1.6 (correctly with
- checking for stomping on Turbo's ram area of the BIOS.)
- Improved package space initialization. Inclusion of
- sys.env and expath in BIOS. Added iop initialization.
- -- Jim Sinning
- 14 mar 86 v1.1
- Conversion for zcpr3 and zrdos. Basic version with no
- bells and whistles. No iop's yet.
-
- 04 jan 86 v1.0
- Initial conversion to standard zilog mnemonics for slr's
- z80asm. Addition of zcpr2 initialization code and zcpr2
- equates. Elimination of buggy code constructs such as
- "mvi a,jmp". -- Jim Sinning
-
- ;=================================================================
-
-
-
- endif
- eject
- subttl User Equates
-
- false equ 0
- true equ not false
-
- include TBMSBIOS.HDR ; Removed to external file
-
- ;
- subttl Miscelaneous macro definitions
- eject
-
- ;=================================================================
- .printx
- ; ***** macro definitions *****
-
- ; macro to generate ROM entry points
-
- xentry macro mname
- xcount defl xcount+3
- mname equ xcount
- endm
-
- ; define ROM entry points
-
- xcount defl 0
- xstart equ xcount
-
- .lall
- xentry xdskrst ; (de-activate host buffer)
- xentry xcrtnit ; initialise video driver
- xentry xdevnit ; (initialise unit record hardware)
- xentry xhome ; (de-activate host buffer only if not written)
- xentry xseldsk ; select disk for next access
- xentry xsettrk ; set track for next disk access
- xentry xsetsec ; set sector for next disk access
- xentry xsetdma ; set dma address for next disk access
- xentry xread ; read sector
- xentry xwrite ; write sector
- xentry xsctrn ; sector translation (dummy)
- xentry xdskon ; trun on floppy motors
- xentry xdskoff ; turn off/deselect drives and flush deblocking
- xentry xcrtsta ; standard keyboard input status
- xentry xcrtin ; standard keyboard input
- xentry xkbdout ; keyboard serial output (use with caution)
- xentry xttysta ; tty input status
- xentry xttyin ; get char from tty
- xentry xttyout ; send (c) to tty
- xentry xlptsta ; centronics output status
- xentry xlptout ; send (c) to centronics
- xentry xttosta ; tty output status
- xentry xcrtout ; send (c) to video screen
- xentry xtmsec ; delay (a) ten millseconds
- xentry xul1sta ; user list input status
- xentry xul1in ; user list input
- xentry xul1out ; user list output
- xentry xul1ost ; user list output status
- xentry xldsys ; reload system
- xentry xgetscr ; return next screen char
- xentry xdefcur ; set cursor to (a)
- xentry xmsec ; delay (a) msec
- .xall
-
- ; ========================================================================
- ; Macros for stat display at assembly time
- ; (credit Jim Lill)
-
- prtval2 macro m1,m2,m3,m4,m5 ; \
- .printx &m1&m2&m3&m4&m5 ; +- this is the print value macro
- endm ; /
-
- prtval macro r,msg1,val,msg2 ; \
- .radix r ; passing the radix value
- prtval2 <msg1>,%val,<msg2> ; requires the uses of 2 macros
- .radix 10
- endm ; /
-
- prtdec macro msg1,val1,val2
- prtval2 <msg1>,%val1,.,%val2,K
- endm
-
- asmerr defl 0 ; Used for assembly error listing
-
- subttl Constants and port definitions
- eject
- ;=================================================================
- ; *** port definitions ***
-
- sioacmd equ 06h ; tty command port
- siobcmd equ 07h ; keyboard command port
- siobst equ 07h ; keyboard status port
- siobdat equ 05h ; keyboard data
- sioccmd equ 0eh ; ul1 command port
- ddata equ 2Ah ; RAM disk data port
- dcntl equ 2Bh ; RAM disk command port
- bitport equ 14h ; system port (bank switching, PIO strobe, etc.)
- bauda equ 0 ; tty baud rate
- baudb equ 8 ; serial printer (84 only)
-
- ;=================================================================
- ; *** miscellaneous definitions ***
-
- topmem equ 0
- romid equ topmem - 8 ; start of ROM identifing sequence
- vecptr equ topmem - 16 ; pointer to base of interrupt vectors
- hrdptr equ topmem - 20 ; pointer to winchester parameters
- sysimag equ 900h ; address of system image in SYS file
-
- beldly equ 40 ; delay before sending bell to keyboard
- lf equ 0ah
- cr equ 0dh
- bs equ 08h
- ccp equ biosloc-1600h
- ramimag equ ccp-200h
-
- ; Misc. definitions for RAM disk
- ;
- on equ 1
- off equ 0
-
- dsync equ 0aah
- psync equ 055h
- haltsnc equ 05ah
- pausnc equ 0a5h
- rdcmd equ 0ffh
- wrcmd equ 0
- pstrob equ 3
- pbusy equ 6
-
- subttl Ramdisk dph tables
- eject
- ;=================================================================
- ; Ramdisk dpb's
-
- if Rd256 ;a 256k ramdisk
- spt equ 40
- bsh equ 3
- blm equ 7
- exm equ 0
- if pb64
- dsm equ 191
- endif
- if pb32
- dsm equ 207
- endif
- if pb4
- dsm equ 235 ; 235 for 4K buffer 194 for 191K drive
- endif ; and 207 for 32K buffer
- drm equ 63
- al0 equ 0f0h
- al1 equ 0
- cks equ 0
- offtrk equ 0
- endif
-
- if Rd512 ;a 512k ramdisk
- spt equ 40
- bsh equ 4
- blm equ 15
- exm equ 1
- if pb64 ;make dsm 215 for 64K ,230 for 32K print buffer
- dsm equ 215 ;and dsm equals 247 for 4K buffer
- endif
- if pb32
- dsm equ 230
- endif
- if pb4
- dsm equ 247
- endif
- drm equ 63
- al0 equ 0c0h
- al1 equ 0
- cks equ 0
- offtrk equ 0
- endif
-
- if Rd768 ;a 3/4 mbyte ramdisk
- spt equ 40
- bsh equ 4
- blm equ 15
- exm equ 0
- if pb64 ;337 for 64K buffer, 352 for 32K buffer
- dsm equ 337 ;dsm equ 367 for 4K buffer
- endif
- if pb32
- dsm equ 362
- endif
- if pb4
- dsm equ 367
- endif
- drm equ 255
- al0 equ 0f0h
- al1 equ 0
- cks equ 0
- offtrk equ 0
- endif
-
- if Rd1024 ;a 1 mbyte ramdisk
- spt equ 40
- bsh equ 4
- blm equ 15
- exm equ 0
- if pb64 ;465 for 64K buffer, 480 for 32K buffer
- dsm equ 465 ;dsm equ 495 for 4K buffer
- endif
- if pb32
- dsm equ 480
- endif
- if pb4
- dsm equ 495
- endif
- drm equ 255
- al0 equ 0f0h
- al1 equ 0
- cks equ 0
- offtrk equ 0
- endif
-
-
- subttl load parameter sector (config. tables)
- eject
- ;=================================================================
-
- ; load parameter sector (standard Kaypro)
- ; This sector is loaded by the Turbo ROM into the
- ; CP/M directory buffer where it remains through
- ; the cold boot.
- ; It also contains the configuration information.
-
- org sysimag
- .phase ramimag ;running location of
- ;cold boot code
-
- ldparm: ;the following matches standard kaypro
- jr ldparm ;id and safety
- defw bootcd ;start loading
- defw bootcd ;cold boot entry
- defw syssct ;number of sectors to load
-
- ;=================================================================
- ;sign-on message, placed here so relocator can patch in
- ;displayable system size. labels define tpa as BDOS-100h.
-
- tpasize equ (ccp+800h)/400h
- quarter equ ((ccp+800h) mod 400h) / 100h * 25
-
- banner macro mlabel
- db (mlabel/10)+'0'
- db (mlabel mod 10)+'0'
- endm
-
- sign:
- defb 1ah ;clear screen
- defb 1ah ;change to 07h if you like noise
-
- banner tpasize
- defb '.'
- banner quarter
- defb 'K ZCPR1/TurboBIOS/MSRD '
- banner bvers
- defb beta
- defb '$ '
-
- ; you must maintain the length of the signonÇ message
- ; as a constant (25h bytes).
- signlen equ $ - sign
- if signlen gt 25h
- .printx Signon message is too long
- endif
- if signlen lt 25h
- .printx Signon message is too short
- endif
-
- ;=================================================================
- ; offsets from start of code to other configurable
- ; parameters that are set by Turbo config program
-
- defw schar - bootcd ;screen dump trigger
- defw iflag - bootcd ;interrupt flag (& func keys)
- defw motcns - bootcd ;motor off time constant
- defw rbtdrv - bootcd ;warm boot drive
- defw wptr0 - bootcd ;pointer to warm boot message
- defw wptr1 - bootcd ;pointer " " " "
-
- ;=================================================================
- ; configuration data structure
- ; miscellaneous options
-
- iiobyt:
- defb 10000001b ;initial i/o byte
-
- curs83:
- ; defb 7fh + 00h ;83 cursor (steady block)
- defb 7fh + 60h ;83 cursor (flashing underscore)
- curs84:
- ; defb 00000000b ;84 cursor (steady full block)
- defb 01101110b ;84 cursor (slow flashing 2-high underscore)
- ; defb 01101111b ;84 cursor (slow flashing 2-high underscore)
-
- clk84:
- defb 0 ;84 machine clock entry in ROM
- ;(0 is no clock)
- typena:
- defb 0 ;00h = type ahead enabled
- ;0ffh = type ahead disabled
- clkmsk:
- defb 0 ;08h = disable keyclicks
- ;00h = enable keyclicks
-
- ;=================================================================
- ;floppy disk time constants
- fflag:
- defb 0 ;flag whether replacement
- ;constants valid
- ftime: ;(step rate,head load,head settle)
-
- ; the following lines are for a three-drive
- ; kaypro ii with Advent's decoder board and two 96-tpi
- ; panasonic 5.25-inch drives as a: and b:, the original
- ; 48-tpi tandon as drive c:
-
- defb 3,50,16 ;floppy 0 96-tpi panasonic
- defb 3,50,16 ;floppy 1 96-tpi panasonic
- ; defb 6,50,16 ; 48-tpi epson
- defb 6,50,25 ;floppy 2 48-tpi tandon
- defb 6,50,25 ;floppy 3 Advent defaults
-
-
-
- ;=================================================================
- ; serial ports
-
- ; device initialization tables
- ; note order of registers taken from osborne.
-
- ;siob - keyboard device
-
- devtab:
- defb siobcmd,00000010b ;select wr2
- defb siobcmd
-
- ivect:
- defb 0 ;patched in by init code
-
- ; ** bauda **
-
- defb bauda,7 ;default to 1200
-
- ; ** sioa - tty: device **
-
- defb sioacmd,00010100b ;select wr4 & reset ext stat
- defb sioacmd,01000100b ;x16, async 1 stop,no parity
-
- defb sioacmd,00010011b ;select wr3 & reset ext stat
- defb sioacmd,11100001b ;rx 8 bits,yes hshak,enab rx
-
- defb sioacmd,00000101b ;select wr5
- defb sioacmd,11101000b ;tx 8 bits,dtr assert,enab tx
-
- defb sioacmd,00000001b ;select wr1
- defb sioacmd,00000000b ;disable interrupts
-
- ilen83 equ ($ - devtab)/2
-
- ; ** baudb **
-
- defb baudb,5 ;default to 300
-
- ; ** sioc -- ul1: serial printer device **
-
- defb sioccmd,00010100b ;select wr4 & reset ext stat
- defb sioccmd,01000100b ;x16, async 1 stop,no parity
-
- defb sioccmd,00010011b ;select wr3 & reset ext stat
- defb sioccmd,11100001b ;rx 8 bits,yes hshak,enab rx
-
- defb sioccmd,00000101b ;select wr5
- defb sioccmd,11101000b ;tx 8 bits,dtr assert,enab tx
-
- defb sioccmd,00000001b ;select wr1
- defb sioccmd,00000000b ;disable interrupts
-
- ilen84 equ ($ - devtab)/2
-
-
- ;warm boot message printed by bdos string printer
-
- ; ==>> someone running datestamper should try this and
- ; see that it works ok. we patch the warm boot message to
- ; a simple cr and this sets wmsglen = 2. can datestamper
- ; handle this?
-
- ; note that you will get an error message if you make the
- ; warm boot message too long. you can put anything here you
- ; want, but don't make the length 0 (you will try to pad
- ; 65536 bytes if you do.)
-
- wmsg0:
- defb cr
- defb lf,'-*-'
- defb '$' ;terminator
- wmsglen equ $ - wmsg0
-
- if $-ldparm lt 80h
- psfree equ 80h-($-ldparm)
-
- if psfree ge 10
- prtval 10,<Param. sec. free space ...... >,psfree,< bytes>
- else
- prtval 10,<Param. sec. free space ...... >,psfree,< bytes>
- endif
-
- defs ldparm+80h-$
- defb 0
-
- else
- psovfl equ $-ldparm-80h
- asmerr defl asmerr or 01h
- prtval 10,<Param. sec. excess .......... >,psovfl,< bytes +++>
- endif
-
-
- subttl cold boot initialization code
- eject
- ;=================================================================
-
- ; start of actual cold boot code
- ; (note that ROM is switched in)
-
- .dephase
- org sysimag+80h
- .phase ramimag+80h
-
-
-
- ; must initially set up stack to use during boot,
- ; put just below start of code
-
- bootcd:
- ld sp,bootcd
-
- ; verify presence of Turbo ROM
-
- ld hl,romid ;start of id sequence
- push hl ;save start of romid
- xor a
- ld b,8
- chks:
- add a,(hl) ;checksum
- inc hl
- djnz chks
- pop hl ;recover start of romid
- jr nz,xrom ;jump if wrong ROM
- ld de,sig
- ld b,3
- csig:
- ld a,(de) ;now check signature
- cp (hl)
- jr nz,xrom
- inc hl
- inc de
- djnz csig
- jr romok
-
- sig:
- defb 'PPS' ;signature in ROM
-
- ; message for wrong ROM detected
-
- emsg:
- defb 1ah,07h,'requires Turbo ROM!'
- elen equ $ - emsg
-
-
- ;=================================================================
- ; use direct ROM calls to video output routine
-
- xrom:
- ld hl,emsg
- ld b,elen
- loop:
- ld c,(hl)
- inc hl
- push hl
- push bc
- call xcrtout
- pop bc
- pop hl
- djnz loop
- hang:
- di
- halt
-
-
- ;=================================================================
- ; find dirbuf to get initialization tables
-
- romok:
- ld c,0 ;select drive 0 to get dph ptr
- ld e,1 ;don't bother redetermining
- call xseldsk ;direct ROM call
- ld de,8
- add hl,de ;now have pointer to pointer
- ld e,(hl)
- inc hl
- ld d,(hl)
- ld (rdirbuf),de ; Tell RAM disk where it is
- push de
- pop ix ;index register points to buffer
-
-
- ; initialize timer interrupts in case they
- ; are later enabled
-
- ld hl,(vecptr) ;get pointer to interrupt vector base
- ;poke low order to write register 2
- ld a,h ;set up cpu interrupt vector
- ld i,a
- im 2 ;make sure in mode 2
- ld (ix+ivect-ldparm),l
- ld de,timer ;note that tx interrupt is base
- ld (hl),e
- inc hl
- ld (hl),d ;put vector in place
-
- ; initialize any unit record devices
- ; find which machine
-
- ld a,(0fffbh) ;get version byte
- rlca ;move machine bit to cy
- push af ;save machine
- push ix
- pop hl
- ld de,devtab - ldparm
- add hl,de
- ex de,hl ;table in de
- pop af
- push af ;get cy
- ld a,ilen83
- jr nc,do83
- ld a,ilen84
- do83:
- ld l,xdevnit ;ROM device initialize
- call calrom ;use ROM function (switch in ram)
-
- ;=================================================================
- ; now do other config options like cursor, bell,
- ; keyboard type-ahead,interrupt motor turn off,
- ; motor deselect time constant, screen dump character
-
- ; cursor definition
-
- pop af ;get back machine
- ld a,(ix+curs83-ldparm)
- jr nc,cu83
-
- ; for 84 must set up display clock address
-
- ld a,(ix+clk84-ldparm)
- ld (0ffe6h),a ;entry point in high memory
- ld a,(ix+curs84-ldparm)
- cu83:
- ld l,xdefcur
- call calrom ;define the cursor
-
-
- ; keyboard type ahead and key clicks
-
- ld hl,(hrdptr) ;get pointer to hard disk area
- ;point to type ahead flag
- dec hl
- ld a,(ix+typena-ldparm)
- ld (hl),a
- dec hl ;point to ROM bell character
- ld a,(ix+clkmsk-ldparm)
- ld (txchar),a ;set bell used by interrupt time out
- ld (click0),a
- or (hl)
- ld (hl),a ;set ROM character
-
- ; move floppy timing
-
- ld a,(ix+fflag-ldparm)
- or a ;test if floppy timing data valid
- jr z,nflp
- ld hl,(hrdptr)
- ld de,16 ;offset to high memory area
- add hl,de ;point to destination
- ex de,hl
- push de
- push ix
- pop hl
- ld de,ftime - ldparm
- add hl,de
- pop de
- ld bc,12
- ldir ;move 12 time constants
-
- ; move warm boot message into position
-
- nflp:
- push ix
- pop hl
- ld de,wmsg0 - ldparm
- add hl,de
- wptr1 equ $ + 1 ;for patching by datestamper install
- ld de,wmsg
- ld bc,wmsglen
- ldir
-
-
- ; note ROM calls above switched ram back on.
- ; exit so we can set up page zero.
-
- ;=================================================================
- ; set up initial iobyte and logged on drive
-
- ld hl,0003h ;point to iobyte
- ld a,(ix+iiobyt-ldparm) ;get initial iobyte
- ld (hl),a ;stuff it
- inc hl ;point logged du byte
- ld (hl),0 ;start with a0:
-
- ;now set rest of page zero
-
- ld a,0c3h ;z-80 jump instruction
- ld (0000h),a
- ld (bdos),a ;set up BIOS/bdos jumps
- ld hl,cboot+3
- ld (0001h),hl ;BIOS warm boot pointer
- ld hl,ccp+0806h
- ld (bdos+1),hl ;bdos pointer
-
-
- ; now print sign on message (can use bdos as
- ; everything else is set up)
-
- push ix
- pop hl
- ld de,sign - ldparm
- add hl,de
- ex de,hl ;point to message
- ld c,9
- call bdos ;use bdos string printer
-
- ; set up drive to pass to ccp, if extra init code added
- ; then this function must be preserved
-
- xor a ;we put 0 in graf byte and use
- ;it for default du as well
-
- duroot equ droot or (uroot<<4)
- ld a,duroot ; Log into specified du
-
-
-
- ld c,a ;always set up du=a0: on cold boot
- jr ccp ;go for it
- eject
- ; pad rest of sector with nop
- ; additional init code could be patched in here
- endcode:
-
- if $-ldparm gt 512
- initofl equ $-ldparm-512
- asmerr defl asmerr or 02
- prtval 10,<Init code excess ............ >,initofl,< bytes +++>
- else
- initfre equ 512-($ - ldparm)
- if initfre ge 10
- prtval 10,<Init code free space ........ >,initfre,< bytes>
- else
- prtval 10,<Init code free space ........ >,initfre,< bytes>
- endif
- defs ldparm+512-$,0
- endif
-
-
- ccpsct equ 4 ;4*512 bytes/kaypro physical sector
- .dephase
- ;=================================================================
- ; Cold boot command to be loaded into ZCPR
- if usecold
- org sysimag+207h
- coldcmd
- endif
- ;
- ;
-
- subttl BIOS proper
- eject
- ;=================================================================
-
- org sysimag + 1800h
- .phase ramimag + 1800h
-
- cboot:
- jp boot
- jp wboot
- jp consta
- jp conin
- jp conout
- jp list
- jp punch
- jp reader
- jp home
- jp seldsk
- jp settrk
- jp setsec
- jp setdma
- jp read
- jp write
- jp listst
- jp sectrn
- ;
- jp spcfnc ; See note below
- jp calrom ; Call ROM service routine
-
- ; Special Functions call
- ; C = 0 Pause print buffer
- ; C = 1 Halt print buffer
- ; C = 2 Return logical ramdisk assignment (0ffh if not initialized)
- ; C = 3 Return address of iflag in HL
-
-
-
- iflag:
- defb 0 ;motor interrupt flag
- bsflag:
- defb 0 ;flags used by BIOS
- ;bit 7 (raw/decoded function keys)
- ;bit 6 (foreign language kaypros only)
- ;bit 5 (foreign language kaypros only)
- ;bit 4 (foreign language kaypros only)
- ;bit 3 unused
- ;bit 2 unused
- ;bit 1 unused
- ;bit 0 write safe flag (old ROMs only)
-
-
- ; standard kaypro layout of function keys
- ; (pre - universal ROM)
-
- akeys:
- defb 0bh,0ah,08h,0ch ;standard adm 3a cursor keys
- ;(for wordstar)
- keypad:
- ; defb '0123456789-,' ;standard keypad definition
- ; defb cr,'.'
- defb '0123456789-+' ;modified keypad definition
- defb cr,'.'
-
-
- ; motor delay used in count down offset preserved
- ; (any program can zero this if it wants control
- ; of the drive motors)
-
- mcnter:
- defw 0 ;interrupt version only uses
- ;first byte
- schar:
- defb 0 ; Screen dump character - not used
-
- ;=================================================================
- ; true cold boot entry which causes system restart
- ; note -- this is different from kaypro use
-
- boot:
- ld l,xstart
- xcalrm:
- jp calrom
-
-
- ;=================================================================
- ; ** page-zero addresses **
- ;
- iobyte equ 0003h
- cdrive equ 0004h
- bdos equ 0005h
-
- wboot:
- ld sp,0100h ;make sure we have good stack
- rbtdrv equ $ + 1 ;location to patch for different boot
- ld a,0 ;default is to reboot from a
- ld de,ccp ;location to load at
- ;number of sectors and starting sector
- ralph: equ (1600h/80h)*100h
- ld bc,ralph + ccpsct
- ld l,57h ;ROM warm boot entry
- call calrom
- ld a,0c3h ;z-80 'jp' instruction
- ld (0),a
- ld (bdos),a ;set up BIOS/bdos jumps
- ld hl,cboot+3
- ld (1),hl ;BIOS warm boot pointer
- ld hl,ccp + 0806h
- ld (bdos+1),hl ;bdos ptr
-
- wptr0 equ $ + 1 ;for patching by datestamper install
- ld de,wmsg ;pointer to warm boot message
- ld c,9
- call bdos ;use bdos string printer
-
- ld hl,bsflag ;point at BIOS flag
- res 7,(hl) ;make sure function keys not 'raw'
-
- ld a,(cdrive)
- ld c,a ;get logged in drive/user
- jp ccp + 3
-
- ;=================================================================
- ; console status
-
- consta:
- ld a,(iflag)
- or a ;test if using interrupts
- jr nz,ncnt ;skip if we are
-
- ;constat polling motor count down
-
- ld hl,mcnter + 1
- or (hl) ;test for count down (high byte only)
- jr z,ncnt
- dec hl
- dec (hl) ;decrement low byte
- jr nz,ncnt
- inc hl
- dec (hl)
- call z,motoff
-
- ncnt:
- ld a,(iobyte)
- rrca ;test for crt/tty
- ld l,xttysta
- jr nc,xcalrm ;no buffering from tty
-
- bufclr equ $ + 1
- ld a,0 ;buffer clear flag
- or a
- ld l,0 ; Return null in l to indicate real character
- ret nz ; Return if buffer not clear
-
- ld l,xcrtsta ;go see if anything new
- call calrom
- ld l,a
- ret z ;return if no character
-
- ; else fetch it
-
- ld l,xcrtin
- call calrom
-
-
- ; check for function keys pressed
-
- cp maxkey
- jr c,isnorm ; < maxkey = normal character
- ; All others are function keys
- isfunc:
- ld l,a ; Save char for return to IOP
- xor a ; A function key has been pressed
- ret
- isnorm:
- ld (bufchr),a ; A printable key has been pressed
- xor a
- ld l,a ; Return null in L
- dec a
- ld (bufclr),a
- ret
-
- ;=================================================================
- ; ** console input **
-
- conin:
- call consta
- jr z,conin ;loop out of ROM
- ld a,(iobyte)
- rrca
- jp nc,reader ;no screen dump or
- ;function keys with tty
-
- bufchr equ $ + 1 ;one character look-ahead where
- ld a,0 ;constat places character
- ld hl,bufclr
- ld (hl),0 ;clear buffer flag
-
- ; now must map any function keys
-
- mapfnc:
- or a
- ret p ;if no high bit then return
- ld hl,bsflag ;see if we are to map
- bit 7,(hl)
- ret nz ;return raw function if set
- ld hl,akeys ;point to mapping table
- and 1fh ;crunch hi bits
- add a,l
- ld l,a ;get offset, (always in first page)
- ld a,(hl)
- ret
-
-
-
- ;=================================================================
- ; ** console output **
-
- conout:
- ld a,(iobyte)
- rrca
- jr nc,punch ;send to tty
-
- ; must trap bell character if interrupt timer being used
-
- crtout:
-
- ; the following code handles the kaypro graphics and
- ; allows zcpr3 to toggle the graphics on/off.
-
- if grafbt ne 0
- ld a,(grafbt) ;get the graf byte
- or a ;non-0 to pass graphics chars
- jr nz,nograf
- ld a,c ;char is in c
- and 7fh
- ld c,a ;now put back masked byte
- nograf:
- endif
-
- ld l,xcrtout
- ld a,(iflag) ;are we using interrupts
- or a
- jr z,calrom
- ld a,(mcnter) ;is motor still running
- or a
- jr z,calrom
- ld a,c
- cp 7 ;test for bell
- jr nz,calrom
- ld hl,txchar
- set 2,(hl) ;set bell bit
- ret
-
-
- ;=================================================================
- ; ** list output **
-
- list:
- call listst ;loop till ready in hi memory
- jr z,list
- ld a,(iobyte)
- and 0c0h ;isolate list device
- jr z,punch
- rlca
- rlca
- dec a ;test for crt
- jr z,crtout
- dec a
- ld l,xul1out
- jr nz,calrom
- ld a,psync ;access print buffer
- call strobe
- ld a,c
- call strobe
- ret
-
-
-
- ;=================================================================
- ; ** sector translate **
-
- sectrn:
- ld a,(dstat)
- or a
- ld l,xsctrn
- jr z,calrom
- push bc
- pop hl
- ret
-
-
- ;=================================================================
- ; ** turn off floppy motor / deselect hard disk **
-
- motoff:
- ld l,xdskoff
- jr calrom ;jump to ROM
-
-
- ;=================================================================
- ; ** punch device (always tty) **
-
- punch:
- ld l,xttyout ;and fall through
-
-
- ;=================================================================
- ; ***** main entry to ROM *****
-
- calrom:
- push af ;save a
-
- ; disable sio status interrupts
-
- ld a,(iflag)
- or a
- jr z,skip
- di ;make sure we are not hit
- ld a,1 ;select write reg 1
- out (siobcmd),a
- xor a ;disable all interrupts
- out (siobcmd),a
- ei
- skip:
- pop af
- call 0fffch ;fixed ROM entry point
- push hl
- push af
-
- ; check if motor counter needs reset
-
- ld a,(iflag)
- or a
- jr z,notint
- ld hl,mcnter ;point to current motor counter
- ;(lo byte only used by interrupt
- ;counter)
- and (hl) ;test for zero
- jr z,notint
-
- ; now reinitialize sio status interrupts
-
- di
- in a,(siobst) ;check if buffer empty
- bit 2,a
- jr z,nempty
- dec (hl) ;decrement count
- jr nz,not00
- inc (hl) ;make sure we are non zero
- ;only time-out in
- ;actual interrupt routine
- click0 equ $ + 1
- not00:
- ld a,0
- out (siobdat),a ;restart timer
-
- nempty:
- ld a,1
- out (siobcmd),a ;select register 1
- ld a,00000110b ;enable vectored tx empty interrupts
- out (siobcmd),a
- ei
- notint:
- pop af
- pop hl
- ret
-
-
- ;=================================================================
- ; ** reader device (always tty) **
-
- reader:
- ld l,xttyin
- jr calrom
-
-
- ;=================================================================
- ; ** home selected disk drive **
-
- home:
- ld a,(dstat)
- or a
- ld l,xhome
- jr z,calrom
- xor a
- ld (dtrack),a
- ld (dsector),a
- ret
-
- ;=================================================================
- ; ** select disk **
-
- seldsk:
- ld a,c
- cp rdnum
- ld a,1
- jr z,isram
- ld a,0
- isram: ld (dstat),a
- ld hl,rdiskdph
- ret z
- ld l,xseldsk
- xclrm: jr calrom
-
-
- ;=================================================================
- ; ** set track **
-
- settrk:
- ld a,(dstat)
- or a
- ld l,xsettrk
- jr z,calrom
- ld a,c
- ld (dtrack),a
- ret
-
- ;=================================================================
- ; ** set sector **
-
- setsec:
- ld a,(dstat)
- or a
- ld l,xsetsec
- jr z,calrom
- ld a,c
- ld (dsector),a
- ret
-
- ;=================================================================
- ; ** set dma address **
-
- setdma:
- ld (dmaptr),bc
- ld l,xsetdma
- jr xclrm
-
- ;=================================================================
- ; ** read specified sector **
-
- read:
- ld a,(dstat)
- or a
- jr z,notram
- ld c,rdcmd
- call ramrun
- rd0:
- ld a,d
- out (bitport),a
- ini
- ld a,e
- out (bitport),a
- jr nz,rd0
- call setpin
- retnul:
- xor a
- ei
- ret
- notram:
- ld b,xread
-
- ; common read/write entry
-
- motcns equ $ + 1
- stime:
- ld hl,2fffh ;reset motor off timer
- ld (mcnter),hl
- ld l,b ;get function set up
- jr xclrm
-
- ;=================================================================
- ; ** write specified sector **
-
- write:
- ld a,(dstat)
- or a
- ld b,xwrite
- jr z,stime
- ld c,wrcmd
- call ramrun
- call setpout
- wr0:
- outi
- ld a,d
- out (bitport),a
- ld a,e
- out (bitport),a
- jr nz,wr0
- call setpin
- xor a
- ei
- ret
-
- ;=================================================================
- ; ** list status **
-
- listst:
- ld a,(iobyte)
- and 0c0h ;mask out list bits
- ld l,xttosta
- jr z,xclrm ;tty used
- rlca
- rlca ;move into low bits
- dec a ;test for crt, always ready
- jr z,ready
- dec a
- jr z,ready
- ld l,xul1ost
- jr xclrm
- ready:
- dec a
- ret ;always ready
-
- ;=================================================================
- ;interrupt driven motor/deselect timer
-
- ; this interrupt driven timer uses the keyboard tx buffer
- ; empty which interrupts at 30 hz rate. if iflag enabled
- ; then type-ahead keyboard must also be enabled, so that
- ; occassional framing errors generated by keyboard firmware
- ; bug can be corrected. note that some very early smk
- ; keyboards with 8749 (cf 8049 in later) have a serious
- ; bug that makes operation with interrupts impossible,
- ; symptoms of this problem are ^@'s appearing on console
- ; when a key is pressed.
-
- ; maximum timing delay is 8.3 seconds.
-
-
- timer:
- ld (timstk),sp ;save current stack
- ld sp,timstk ;set up new local stack
- push af
- push hl
- ld hl,mcnter ;point to counter
- dec (hl) ;decrement
- call z,motoff ;deselect and flush if needed
- txchar equ $ + 1 ;clicks and bell
- ld a,0 ;character to send to keyboard
- bit 2,a ;is bell bit set
- jr z,nbel ;skip if no bell
- ld h,beldly ;need to delay
- lp:
- dec l
- jr nz,lp
- dec h
- jr nz,lp ;delay before bell
-
- nbel:
- out (siobdat),a ;send character
- res 2,a ;clear bell bit
- ld (txchar),a
- pop hl ;note motoff saves additional reg. used
- pop af
- ld sp,(timstk) ;get back old stack pointer
- ei
- reti
-
- ; Special function for misc BIOS services related to IOP and NZCOM
- ;
- spcfnc:
- ld a,c
- or a
- jr z,ppause ; c=0 Printer pause
- dec a
- jr z,phalt ; c=1 Printer halt
- dec a
- jr z,rdstat ; c=2 Return ramdisk status
- dec a
- ld hl,iflag ; c=3 Return address of iflag
- ret z
- ;
- ; Additional subfucntions may be added here
- ;
- xor a ; Return a=0ffh, not valid subfunction
- dec a
- ret
-
- rdstat: ld a,rdnum ; Return ramdisk logical disk assignment
- ret
-
- phalt:
- ld a,haltsnc
- call strobe
- ret
-
- ppause: ld a,pausnc
- call strobe
- ret
-
- strobe:
- push af
- in a,(bitport)
- res pstrob,a
- out (bitport),a
- st0:
- in a,(bitport)
- bit pbusy,a
- jr nz,st0
- call setpout
- pop af
- out (ddata),a
- in a,(bitport)
- set pstrob,a
- out (bitport),a
- st1:
- in a,(bitport)
- bit pbusy,a
- jr z,st1
- call setpin
- xor a ; Zero it for consta
- ret
-
- setpin:
- ld a,0cfh
- out (dcntl),a
- ld a,0ffh
- out (dcntl),a
- ret
-
- setpout:
- ld a,0cfh
- out (dcntl),a
- ld a,0
- out (dcntl),a
- ret
-
- ramrun:
- di
- ld a,dsync
- call strobe
- ld a,(dtrack)
- call strobe
- ld a,(dsector)
- call strobe
- ld a,c
- call strobe
- ld hl,(dmaptr)
- ld b,128
- ld c,ddata
- in a,(bitport)
- res pstrob,a
- ld d,a
- set pstrob,a
- ld e,a
- ret
-
- subttl Data tables
- eject
-
- ; ==========================================================
- ;
- ; DATA TABLES
- ;
-
- ; RAM disk DPH
- ;
- rdiskdph:
- defw 0,0,0,0
- rdirbuf:
- defw 0 ; Must be filled in by init routine
- defw rdiskdp
- defw 0000,alvd ; Let's use DRI std. Pointer to csvd = 0
- csvd: ; if non-removable medium.
- ds cks
- alvd:
- ds (dsm/8)+1
-
- rdiskdp:
- defw spt ; RAM disk DPB
- defb bsh
- defb blm
- defb exm
- defw dsm
- defw drm
- defb al0
- defb al1
- defw cks
- defw offtrk
-
- dtrack:
- defb 0 ; RAM disk sector
- dsector:
- defb 0 ; RAM disk sector
- dstat:
- defb 0 ; RAM disk select
- dmaptr:
- defw 0 ; RAM disk DMA pointer
-
- subttl stack and assembly time stat display
- ;=================================================================
- endbios equ $
-
- ; The original amount of space here is determined by datestamper
- ; requirements. We will make it smaller, since we don't bother with
- ; datestamper.
-
- wmsg: defs wmsglen
- if false
-
- Timstk defines a stack--for use by the ROM itself--which is
- compatible with Plu*Perfect Systems DateStamper.
-
- The syssct label instructs the ROM how many sectors to load from
- disk. When the environment is to be included in the cold boot load,
- it must be taken into account when syssct is computed.
- endif
-
- if bstack ne 0
- alldone equ $ ;stack is external, don't count it
- else
- .dephase
- org sysimag + (wmsg + 64 - ramimag)
- .phase wmsg + 64
- timstk: defw 0 ;word to save stack during init.
- alldone equ $ ;stack is internal, count it
- endif
-
- bslen equ alldone-ccp-0800h-0E00h
-
- sysbyt defl ($ - bootcd)
- syssct defl ($ - bootcd)/128
- if sysbyt mod 128 gt 0
- syssct defl syssct + 1
- endif
-
- .printx
- prtval 10,<System sectors allocated .... >,syssct,< sectors>
- .printx Maximum System size ........ 55 sectors
- if syssct le 37h
- prtval 10,<System bytes allocated ..... >,sysbyt,< bytes>
- .printx
-
- secbyt equ 128 - (sysbyt mod 128)
- scrtbyt equ scratch-alldone
-
- if secbyt ge 100
- prtval 10,<Bytes left in this sector .. >,secbyt,< bytes>
- else
- if secbyt ge 10
- prtval 10,<Bytes left in this sector .. >,secbyt,< bytes>
- else
- prtval 10,<Bytes left in this sector .. >,secbyt,< bytes>
- endif
- endif
-
- if scrtbyt ge 100
- prtval 10,<Bytes free to scratch ...... >,scrtbyt,< bytes>
- else
- if scrtbyt ge 10
- prtval 10,<Bytes free to scratch ...... >,scrtbyt,< bytes>
- else
- prtval 10,<Bytes free to scratch ...... >,scrtbyt,< bytes>
- endif
- endif
-
- else
- sysofl equ syssct-55
- bytofl equ sysbyt-7040
- asmerr defl asmerr or 04h
-
- prtval 10,<System sector excess ......... >,sysofl,< sectors>
- prtval 10,< " " " ........ >,bytofl,< bytes +++>
- endif
- .dephase
- if bstack ne 0
- org sysimag + (bstack - ramimag)
- .phase bstack
- timstk: defw 0
- .dephase
- endif
-
- .printx
- cphase equ bootcd + 180h
-
- prtval 16,<Start of CCP ................ >,cphase,< hex>
- prtval 16,<Last address in BIOS ........ >,alldone,< hex>
- if alldone ge scratch
- asmerr defl asmerr or 08h
- endif
- prtval 16,<Size of BIOS ................ >,alldone-cboot,< hex>
-
- sysk equ (ccp+1c00h)/400h
- sysq equ ((ccp+1c00h) mod 400h)/100h * 25
-
- if asmerr
- .printx
- endif
- if asmerr and 01h
- .printx *** ERROR *** Parameter sector overflow
- endif
- if asmerr and 02h
- .printx *** ERROR *** Initialization code overflow
- endif
- if asmerr and 04h
- .printx *** ERROR *** System size overflow
- endif
- if asmerr and 08h
- .printx *** ERROR *** Code overflows into reserved memory
- endif
- sbios equ (scratch - (alldone-cboot)) & 0ff00h ; Suggested biosloc
- sccp equ sbios-1600h
- ssysk equ (sccp+1c00h)/400h
- ssysq equ ((sccp+1c00h) mod 400h)/100h * 25 ; Suggested sys size
- .printx
- .printx SYSTEM WITH BIOS AS ASSEMBLED:
- prtval 16,<BIOS location ................... >,biosloc
- prtdec <Required TurboROM system size ... >,sysk,sysq
- .printx
- if asmerr & 7
- .printx CORRECT ERROR(S) MARKED "+++" AND REASSEMBLE *****
- else
- .printx SUGGESTED OPTIMUM SYSTEM:
- prtval 16,<BIOS location ................... >,sbios
- prtdec <Required TurboROM system size ... >,ssysk,ssysq
- endif
- .printx
- .printx
- end
-