home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / tbmsbios.lbr / TBMSBIOS.ZZ0 / TBMSBIOS.Z80
Encoding:
Text File  |  1993-06-07  |  34.3 KB  |  1,572 lines

  1. .z80
  2.     title custom BIOS for Turbo-ROM with MicroSphere RAM disk 
  3.     subttl Documentation
  4.  
  5.     if false
  6.  
  7.     Universal High-BIOS for Turbo ROM
  8.  
  9.     copyright 1985 (c), Plu*Perfect Systems
  10.             p.o. box 1494
  11.           Idyllwild, California 92349
  12.  
  13. This code is provided for the use of owners of the Advent Products
  14. Turbo ROM (Kaypro versions).  It relies heavily on the presence of
  15. the Turbo ROM and will not work without it.  Additional code has 
  16. been added to support the MicroSphere RAM disk.  Print buffer
  17. functions and ramdisk access are provided.
  18.  
  19. Syntax adjusted for assembly with Z80ASM
  20.  
  21. ;=================================================================
  22.         *****    modification log   *****
  23.  
  24.  
  25.  13 Oct. 89    v2.0A
  26.  
  27.     Conversion to assembly by Z80ASM.  Removed Z3 code since
  28.     with ZCPR34 all Z matters are handled more efficiently by the
  29.     NZ-COM loader.  Added code for MicroSphere RAM disk.  Added 
  30.     code to return hibit keys with console status.  Added extra 
  31.     jumps to handle print buffer control and return iflag address.
  32.     Removed configuration code to external file for easy assembly. 
  33.                      -- Lindsay Haisley
  34.  07 june 87    v1.3a
  35.         Conversion for assembly by zasm.  Added equates to control
  36.         location of the bios stack, to log into a15: on boot, to
  37.         include or not include environment.  Made initial command
  38.         a macro for easier modification.  Signon banner will
  39.         customize itself according to ccp location.  Removed one
  40.         defb 0 that was overwriting the ccp's first byte (C3h).
  41.                     -- Michal Carson
  42.  24 may 86    v1.2
  43.         Conversion for zcpr3 and zrdos 1.6 (correctly with
  44.         checking for stomping on Turbo's ram area of the BIOS.)
  45.         Improved package space initialization.  Inclusion of
  46.         sys.env and expath in BIOS. Added iop initialization.
  47.                     -- Jim Sinning
  48.  14 mar 86    v1.1
  49.         Conversion for zcpr3 and zrdos.  Basic version with no
  50.         bells and whistles.  No iop's yet.
  51.  
  52.  04 jan 86    v1.0
  53.         Initial conversion to standard zilog mnemonics for slr's
  54.         z80asm.  Addition of zcpr2 initialization code and zcpr2
  55.         equates. Elimination of buggy code constructs such as
  56.         "mvi a,jmp".             -- Jim Sinning
  57.  
  58. ;=================================================================
  59.  
  60.  
  61.  
  62.     endif
  63.     eject
  64.     subttl User Equates
  65.  
  66. false    equ    0
  67. true    equ    not false
  68.     
  69.     include    TBMSBIOS.HDR        ; Removed to external file
  70.  
  71. ;
  72.     subttl Miscelaneous macro definitions
  73.     eject
  74.  
  75. ;=================================================================
  76.     .printx
  77. ;    *****    macro definitions   *****
  78.  
  79. ; macro to generate ROM entry points
  80.  
  81. xentry    macro mname
  82. xcount    defl xcount+3
  83. mname    equ xcount
  84.     endm
  85.  
  86. ; define ROM entry points
  87.  
  88. xcount    defl 0
  89. xstart    equ xcount
  90.  
  91.     .lall
  92.     xentry xdskrst    ; (de-activate host buffer)
  93.     xentry xcrtnit    ; initialise video driver
  94.     xentry xdevnit    ; (initialise unit record hardware)
  95.     xentry xhome    ; (de-activate host buffer only if not written)
  96.     xentry xseldsk    ; select disk for next access
  97.     xentry xsettrk    ; set track for next disk access
  98.     xentry xsetsec    ; set sector for next disk access
  99.     xentry xsetdma    ; set dma address for next disk access
  100.     xentry xread    ; read sector
  101.     xentry xwrite    ; write sector
  102.     xentry xsctrn    ; sector translation (dummy)
  103.     xentry xdskon    ; trun on floppy motors
  104.     xentry xdskoff    ; turn off/deselect drives and flush deblocking
  105.     xentry xcrtsta    ; standard keyboard input status
  106.     xentry xcrtin    ; standard keyboard input
  107.     xentry xkbdout    ; keyboard serial output (use with caution)
  108.     xentry xttysta    ; tty input status
  109.     xentry xttyin    ; get char from tty
  110.     xentry xttyout    ; send (c) to tty
  111.     xentry xlptsta    ; centronics output status
  112.     xentry xlptout    ; send (c) to centronics
  113.     xentry xttosta    ; tty output status
  114.     xentry xcrtout    ; send (c) to video screen
  115.     xentry xtmsec    ; delay (a) ten millseconds
  116.     xentry xul1sta    ; user list input status
  117.     xentry xul1in    ; user list input
  118.     xentry xul1out    ; user list output
  119.     xentry xul1ost    ; user list output status
  120.     xentry xldsys    ; reload system
  121.     xentry xgetscr    ; return next screen char
  122.     xentry xdefcur    ; set cursor to (a)
  123.     xentry xmsec    ; delay (a) msec
  124.     .xall
  125.  
  126. ; ========================================================================
  127. ; Macros for stat display at assembly time
  128. ; (credit Jim Lill)
  129.  
  130. prtval2    macro m1,m2,m3,m4,m5        ; \
  131.     .printx    &m1&m2&m3&m4&m5        ;  +- this is the print value macro
  132.     endm                ; /
  133.  
  134. prtval    macro r,msg1,val,msg2        ; \
  135.     .radix r            ;   passing the radix value
  136.     prtval2 <msg1>,%val,<msg2>    ;   requires the uses of 2 macros
  137.     .radix 10
  138.     endm                ; /
  139.  
  140. prtdec    macro msg1,val1,val2
  141.     prtval2 <msg1>,%val1,.,%val2,K
  142.     endm
  143.  
  144. asmerr    defl    0            ; Used for assembly error listing
  145.  
  146.     subttl    Constants and port definitions
  147.     eject
  148. ;=================================================================
  149. ;    ***  port definitions  ***
  150.  
  151. sioacmd    equ     06h    ; tty command port
  152. siobcmd    equ     07h    ; keyboard command port
  153. siobst    equ     07h    ; keyboard status port
  154. siobdat    equ     05h    ; keyboard data
  155. sioccmd    equ     0eh    ; ul1 command port
  156. ddata    equ    2Ah    ; RAM disk data port
  157. dcntl    equ    2Bh    ; RAM disk command port
  158. bitport    equ    14h    ; system port (bank switching, PIO strobe, etc.)
  159. bauda    equ     0    ; tty baud rate
  160. baudb    equ     8    ; serial printer (84 only)
  161.  
  162. ;=================================================================
  163. ;    ***  miscellaneous definitions    ***
  164.  
  165. topmem    equ 0
  166. romid    equ topmem - 8    ; start of ROM identifing sequence
  167. vecptr    equ topmem - 16    ; pointer to base of interrupt vectors
  168. hrdptr    equ topmem - 20    ; pointer to winchester parameters
  169. sysimag    equ 900h    ; address of system image in SYS file
  170.  
  171. beldly    equ 40        ; delay before sending bell to keyboard
  172. lf    equ 0ah
  173. cr    equ 0dh
  174. bs    equ 08h
  175. ccp    equ biosloc-1600h
  176. ramimag    equ ccp-200h
  177.  
  178. ; Misc. definitions for RAM disk
  179. ;
  180. on    equ    1
  181. off    equ    0
  182.  
  183. dsync    equ    0aah
  184. psync    equ    055h
  185. haltsnc    equ    05ah
  186. pausnc    equ    0a5h
  187. rdcmd    equ    0ffh
  188. wrcmd    equ    0
  189. pstrob    equ    3
  190. pbusy    equ    6
  191.  
  192.     subttl    Ramdisk dph tables
  193.     eject
  194. ;=================================================================
  195. ; Ramdisk dpb's
  196.  
  197.      if    Rd256        ;a 256k ramdisk
  198. spt    equ    40
  199. bsh    equ    3
  200. blm    equ    7
  201. exm    equ    0
  202.      if pb64
  203. dsm    equ    191
  204.      endif
  205.      if pb32
  206. dsm    equ    207
  207.      endif
  208.      if pb4
  209. dsm    equ    235    ; 235 for 4K buffer 194 for 191K drive
  210.      endif        ; and 207 for 32K buffer
  211. drm    equ    63
  212. al0    equ    0f0h
  213. al1    equ    0
  214. cks    equ    0
  215. offtrk    equ    0
  216.      endif
  217.  
  218.      if    Rd512        ;a 512k ramdisk
  219. spt    equ    40
  220. bsh    equ    4
  221. blm    equ    15
  222. exm    equ    1
  223.      if pb64    ;make dsm 215 for 64K ,230 for 32K print buffer
  224. dsm    equ    215    ;and dsm equals 247 for 4K buffer
  225.      endif
  226.      if pb32
  227. dsm    equ    230
  228.      endif
  229.      if pb4
  230. dsm    equ    247
  231.      endif        
  232. drm    equ    63
  233. al0    equ    0c0h
  234. al1    equ    0
  235. cks    equ    0
  236. offtrk    equ    0
  237.      endif
  238.  
  239.      if    Rd768        ;a 3/4 mbyte ramdisk
  240. spt    equ    40
  241. bsh    equ    4
  242. blm    equ    15
  243. exm    equ    0
  244.      if pb64    ;337 for 64K buffer, 352 for 32K buffer 
  245. dsm    equ    337    ;dsm equ 367 for 4K buffer
  246.      endif
  247.      if pb32
  248. dsm    equ    362
  249.      endif
  250.      if pb4
  251. dsm    equ    367
  252.      endif        
  253. drm    equ    255
  254. al0    equ    0f0h
  255. al1    equ    0
  256. cks    equ    0
  257. offtrk    equ    0
  258.      endif
  259.  
  260.      if    Rd1024        ;a 1 mbyte ramdisk
  261. spt    equ    40
  262. bsh    equ    4
  263. blm    equ    15
  264. exm    equ     0    
  265.      if pb64    ;465 for 64K buffer, 480 for 32K buffer 
  266. dsm    equ    465    ;dsm equ 495 for 4K buffer
  267.      endif
  268.      if pb32
  269. dsm    equ    480
  270.      endif
  271.      if pb4
  272. dsm    equ    495
  273.      endif        
  274. drm    equ    255
  275. al0    equ    0f0h
  276. al1    equ    0
  277. cks    equ    0
  278. offtrk    equ    0
  279.      endif
  280.  
  281.  
  282.     subttl load parameter sector (config. tables)
  283.     eject
  284. ;=================================================================
  285.  
  286. ; load parameter sector (standard Kaypro)
  287. ; This sector is loaded by the Turbo ROM into the
  288. ; CP/M directory buffer where it remains through
  289. ; the cold boot.
  290. ; It also contains the configuration information.
  291.  
  292.     org    sysimag
  293.     .phase    ramimag        ;running location of
  294.                 ;cold boot code
  295.  
  296. ldparm:            ;the following matches standard kaypro
  297.     jr   ldparm    ;id and safety
  298.     defw bootcd    ;start loading
  299.     defw bootcd    ;cold boot entry
  300.     defw syssct    ;number of sectors to load
  301.  
  302. ;=================================================================
  303. ;sign-on message, placed here so relocator can patch in
  304. ;displayable system size.  labels define tpa as BDOS-100h.
  305.  
  306. tpasize equ (ccp+800h)/400h
  307. quarter equ ((ccp+800h) mod 400h) / 100h * 25
  308.  
  309. banner    macro mlabel
  310.     db    (mlabel/10)+'0'
  311.     db    (mlabel mod 10)+'0'
  312.     endm
  313.  
  314. sign:
  315.     defb 1ah    ;clear screen
  316.     defb 1ah    ;change to 07h if you like noise
  317.  
  318.     banner tpasize
  319.     defb '.'
  320.     banner quarter
  321.     defb 'K ZCPR1/TurboBIOS/MSRD '
  322.     banner bvers
  323.     defb beta
  324.     defb '$   '
  325.  
  326. ; you must maintain the length of the signonÇ message
  327. ; as a constant (25h bytes).
  328. signlen    equ $ - sign
  329.     if signlen gt 25h
  330.     .printx Signon message is too long
  331.     endif
  332.     if signlen lt 25h
  333.     .printx Signon message is too short
  334.     endif
  335.  
  336. ;=================================================================
  337. ; offsets from start of code to other configurable
  338. ; parameters that are set by Turbo config program
  339.  
  340.     defw schar - bootcd     ;screen dump trigger
  341.     defw iflag - bootcd     ;interrupt flag (& func keys)
  342.     defw motcns - bootcd     ;motor off time constant
  343.     defw rbtdrv - bootcd     ;warm boot drive
  344.     defw wptr0 - bootcd     ;pointer to warm boot message
  345.     defw wptr1 - bootcd     ;pointer  "    "     "   "
  346.  
  347. ;=================================================================
  348. ; configuration data structure
  349. ; miscellaneous options
  350.  
  351. iiobyt:
  352.     defb 10000001b        ;initial i/o byte
  353.  
  354. curs83:
  355. ;    defb 7fh + 00h    ;83 cursor (steady block)
  356.     defb 7fh + 60h    ;83 cursor (flashing underscore)
  357. curs84:
  358. ;    defb 00000000b    ;84 cursor (steady full block)
  359.      defb 01101110b    ;84 cursor (slow flashing 2-high underscore)
  360. ;     defb 01101111b    ;84 cursor (slow flashing 2-high underscore)
  361.  
  362. clk84:
  363.     defb 0        ;84 machine clock entry in ROM
  364.             ;(0 is no clock)
  365. typena:
  366.     defb 0        ;00h = type ahead enabled
  367.             ;0ffh = type ahead disabled
  368. clkmsk:
  369.     defb 0        ;08h = disable keyclicks
  370.             ;00h = enable keyclicks
  371.  
  372. ;=================================================================
  373. ;floppy disk time constants
  374. fflag:
  375.     defb 0        ;flag whether replacement
  376.             ;constants valid
  377. ftime:            ;(step rate,head load,head settle)
  378.  
  379. ; the following lines are for a three-drive
  380. ; kaypro ii with Advent's decoder board and two 96-tpi
  381. ; panasonic 5.25-inch drives as a: and b:, the original
  382. ; 48-tpi tandon as drive c:
  383.  
  384.     defb 3,50,16    ;floppy 0 96-tpi panasonic
  385.     defb 3,50,16    ;floppy 1 96-tpi panasonic
  386. ;    defb 6,50,16    ;         48-tpi epson
  387.     defb 6,50,25    ;floppy 2 48-tpi tandon
  388.     defb 6,50,25    ;floppy 3 Advent defaults
  389.  
  390.  
  391.  
  392. ;=================================================================
  393. ;    serial ports
  394.  
  395. ; device initialization tables
  396. ; note order of registers taken from osborne.
  397.  
  398. ;siob - keyboard device
  399.  
  400. devtab:
  401.     defb siobcmd,00000010b ;select wr2
  402.     defb siobcmd
  403.  
  404. ivect:
  405.     defb 0        ;patched in by init code
  406.  
  407. ;    ** bauda **
  408.  
  409.     defb bauda,7    ;default to 1200
  410.  
  411. ;    ** sioa - tty: device **
  412.  
  413.     defb sioacmd,00010100b ;select wr4 & reset ext stat
  414.     defb sioacmd,01000100b ;x16, async 1 stop,no parity
  415.  
  416.     defb sioacmd,00010011b ;select wr3 & reset ext stat
  417.     defb sioacmd,11100001b ;rx 8 bits,yes hshak,enab rx
  418.  
  419.     defb sioacmd,00000101b ;select wr5
  420.     defb sioacmd,11101000b ;tx 8 bits,dtr assert,enab tx
  421.  
  422.     defb sioacmd,00000001b ;select wr1
  423.     defb sioacmd,00000000b ;disable interrupts
  424.  
  425. ilen83    equ ($ - devtab)/2
  426.  
  427. ;    ** baudb **
  428.  
  429.     defb baudb,5    ;default to 300
  430.  
  431. ;    ** sioc -- ul1: serial printer device **
  432.  
  433.     defb sioccmd,00010100b ;select wr4 & reset ext stat
  434.     defb sioccmd,01000100b ;x16, async 1 stop,no parity
  435.  
  436.     defb sioccmd,00010011b ;select wr3 & reset ext stat
  437.     defb sioccmd,11100001b ;rx 8 bits,yes hshak,enab rx
  438.  
  439.     defb sioccmd,00000101b ;select wr5
  440.     defb sioccmd,11101000b ;tx 8 bits,dtr assert,enab tx
  441.  
  442.     defb sioccmd,00000001b ;select wr1
  443.     defb sioccmd,00000000b ;disable interrupts
  444.  
  445. ilen84    equ ($ - devtab)/2
  446.  
  447.  
  448. ;warm boot message printed by bdos string printer
  449.  
  450. ; ==>> someone running datestamper should try this and
  451. ; see that it works ok. we patch the warm boot message to
  452. ; a simple cr and this sets wmsglen = 2.  can datestamper
  453. ; handle this?
  454.  
  455. ; note that you will get an error message if you make the
  456. ; warm boot message too long.  you can put anything here you
  457. ; want, but don't make the length 0 (you will try to pad
  458. ; 65536 bytes if you do.)
  459.  
  460. wmsg0:
  461.     defb cr
  462.     defb lf,'-*-'
  463.     defb '$'        ;terminator
  464. wmsglen    equ $ -    wmsg0
  465.  
  466.      if $-ldparm lt 80h
  467. psfree    equ 80h-($-ldparm)
  468.  
  469.      if    psfree ge 10
  470.     prtval    10,<Param. sec. free space ......  >,psfree,< bytes>
  471.      else
  472.     prtval    10,<Param. sec. free space ......   >,psfree,< bytes>
  473.      endif
  474.  
  475.     defs ldparm+80h-$
  476.     defb 0
  477.  
  478.      else
  479. psovfl    equ $-ldparm-80h
  480. asmerr    defl    asmerr or 01h
  481.     prtval    10,<Param. sec. excess ..........    >,psovfl,< bytes  +++>
  482.      endif
  483.  
  484.  
  485.     subttl    cold boot initialization code
  486.     eject
  487. ;=================================================================
  488.  
  489. ; start of actual cold boot code
  490. ; (note that ROM is switched in)
  491.  
  492.     .dephase
  493.     org    sysimag+80h
  494.     .phase    ramimag+80h
  495.  
  496.  
  497.  
  498. ; must initially set up stack to use during boot,
  499. ; put just below start of code
  500.  
  501. bootcd:
  502.     ld     sp,bootcd
  503.  
  504. ; verify presence of Turbo ROM
  505.  
  506.     ld     hl,romid    ;start of id sequence
  507.     push     hl        ;save start of romid
  508.     xor     a
  509.     ld     b,8
  510. chks:
  511.     add     a,(hl)        ;checksum
  512.     inc     hl
  513.     djnz     chks
  514.     pop     hl        ;recover start of romid
  515.     jr     nz,xrom        ;jump if wrong ROM
  516.     ld     de,sig
  517.     ld     b,3
  518. csig:
  519.     ld     a,(de)        ;now check signature
  520.     cp     (hl)
  521.     jr     nz,xrom
  522.     inc     hl
  523.     inc     de
  524.     djnz     csig
  525.     jr     romok
  526.  
  527. sig:
  528.     defb     'PPS'    ;signature in ROM
  529.  
  530. ; message for wrong ROM detected
  531.  
  532. emsg:
  533.     defb     1ah,07h,'requires Turbo ROM!'
  534. elen    equ     $ - emsg
  535.  
  536.  
  537. ;=================================================================
  538. ; use direct ROM calls to video output routine
  539.  
  540. xrom:
  541.     ld     hl,emsg
  542.     ld     b,elen
  543. loop:
  544.     ld     c,(hl)
  545.     inc     hl
  546.     push     hl
  547.     push     bc
  548.     call     xcrtout
  549.     pop     bc
  550.     pop     hl
  551.     djnz     loop
  552. hang:
  553.     di
  554.     halt
  555.  
  556.  
  557. ;=================================================================
  558. ; find dirbuf to get initialization tables
  559.  
  560. romok:
  561.     ld     c,0        ;select drive 0 to get dph ptr
  562.     ld     e,1        ;don't bother redetermining
  563.     call     xseldsk        ;direct ROM call
  564.     ld     de,8
  565.     add     hl,de        ;now have pointer to pointer
  566.     ld     e,(hl)
  567.     inc     hl
  568.     ld     d,(hl)
  569.     ld    (rdirbuf),de    ; Tell RAM disk where it is
  570.     push     de
  571.     pop     ix        ;index register points to buffer
  572.  
  573.  
  574. ; initialize timer interrupts in case they
  575. ; are later enabled
  576.  
  577.     ld     hl,(vecptr)    ;get pointer to interrupt vector base
  578.                 ;poke low order to write register 2
  579.     ld     a,h        ;set up cpu interrupt vector
  580.     ld     i,a
  581.     im     2        ;make sure in mode 2
  582.     ld     (ix+ivect-ldparm),l
  583.     ld     de,timer    ;note that tx interrupt is base
  584.     ld     (hl),e
  585.     inc     hl
  586.     ld     (hl),d        ;put vector in place
  587.  
  588. ; initialize any unit record devices
  589. ; find which machine
  590.  
  591.     ld     a,(0fffbh)    ;get version byte
  592.     rlca            ;move machine bit to cy
  593.     push     af        ;save machine
  594.     push     ix
  595.     pop     hl
  596.     ld     de,devtab - ldparm
  597.     add     hl,de
  598.     ex     de,hl        ;table in de
  599.     pop     af
  600.     push     af        ;get cy
  601.     ld     a,ilen83
  602.     jr     nc,do83
  603.     ld     a,ilen84
  604. do83:
  605.     ld     l,xdevnit    ;ROM device initialize
  606.     call     calrom        ;use ROM function (switch in ram)
  607.  
  608. ;=================================================================
  609. ; now do other config options like cursor, bell,
  610. ; keyboard type-ahead,interrupt motor turn off,
  611. ; motor deselect time constant, screen dump character
  612.  
  613. ; cursor definition
  614.  
  615.     pop     af        ;get back machine
  616.     ld     a,(ix+curs83-ldparm)
  617.     jr     nc,cu83
  618.  
  619. ; for 84 must set up display clock address
  620.  
  621.     ld     a,(ix+clk84-ldparm)
  622.     ld     (0ffe6h),a    ;entry point in high memory
  623.     ld     a,(ix+curs84-ldparm)
  624. cu83:
  625.     ld     l,xdefcur
  626.     call     calrom        ;define the cursor
  627.  
  628.  
  629. ; keyboard type ahead and key clicks
  630.  
  631.     ld     hl,(hrdptr)    ;get pointer to hard disk area
  632.                 ;point to type ahead flag
  633.     dec     hl
  634.     ld     a,(ix+typena-ldparm)
  635.     ld     (hl),a
  636.     dec     hl        ;point to ROM bell character
  637.     ld     a,(ix+clkmsk-ldparm)
  638.     ld     (txchar),a    ;set bell used by interrupt time out
  639.     ld     (click0),a
  640.     or     (hl)
  641.     ld     (hl),a        ;set ROM character
  642.  
  643. ; move floppy timing
  644.  
  645.     ld     a,(ix+fflag-ldparm)
  646.     or     a        ;test if floppy timing data valid
  647.     jr     z,nflp
  648.     ld     hl,(hrdptr)
  649.     ld     de,16        ;offset to high memory area
  650.     add     hl,de        ;point to destination
  651.     ex     de,hl
  652.     push     de
  653.     push     ix
  654.     pop     hl
  655.     ld     de,ftime - ldparm
  656.     add     hl,de
  657.     pop     de
  658.     ld     bc,12
  659.     ldir            ;move 12 time constants
  660.  
  661. ; move warm boot message into position
  662.  
  663. nflp:
  664.     push     ix
  665.     pop     hl
  666.     ld     de,wmsg0 - ldparm
  667.     add     hl,de
  668. wptr1    equ     $ + 1        ;for patching by datestamper install
  669.     ld     de,wmsg
  670.     ld     bc,wmsglen
  671.     ldir
  672.  
  673.  
  674. ; note ROM calls above switched ram back on.
  675. ; exit so we can set up page zero.
  676.  
  677. ;=================================================================
  678. ; set up initial iobyte and logged on drive
  679.  
  680.     ld     hl,0003h    ;point to iobyte
  681.     ld     a,(ix+iiobyt-ldparm)    ;get initial iobyte
  682.     ld     (hl),a        ;stuff it
  683.     inc     hl        ;point logged du byte
  684.     ld     (hl),0        ;start with a0:
  685.  
  686. ;now set rest of page zero
  687.  
  688.     ld     a,0c3h        ;z-80 jump instruction
  689.     ld     (0000h),a
  690.     ld     (bdos),a    ;set up BIOS/bdos jumps
  691.     ld     hl,cboot+3
  692.     ld     (0001h),hl    ;BIOS warm boot pointer
  693.     ld     hl,ccp+0806h
  694.     ld     (bdos+1),hl    ;bdos pointer
  695.  
  696.  
  697. ; now print sign on message (can use bdos as
  698. ; everything else is set up)
  699.  
  700.     push     ix
  701.     pop     hl
  702.     ld     de,sign - ldparm
  703.     add     hl,de
  704.     ex     de,hl        ;point to message
  705.     ld     c,9
  706.     call     bdos        ;use bdos string printer
  707.  
  708. ; set up drive to pass to ccp, if extra init code added
  709. ; then this function must be preserved
  710.  
  711.     xor     a        ;we put 0 in graf byte and use
  712.                 ;it for default du as well
  713.  
  714. duroot    equ    droot or (uroot<<4)
  715.     ld    a,duroot    ; Log into specified du
  716.      
  717.     
  718.  
  719.     ld     c,a        ;always set up du=a0: on cold boot
  720.     jr     ccp        ;go for it
  721.     eject
  722. ; pad rest of sector with nop
  723. ; additional init code could be patched in here
  724. endcode:
  725.  
  726.      if $-ldparm gt 512
  727. initofl    equ    $-ldparm-512
  728. asmerr    defl    asmerr or 02
  729.     prtval    10,<Init code excess ............  >,initofl,< bytes  +++>
  730.      else
  731. initfre    equ    512-($ - ldparm)
  732.      if initfre ge 10
  733.     prtval    10,<Init code free space ........ >,initfre,< bytes>
  734.      else
  735.     prtval    10,<Init code free space ........  >,initfre,< bytes>
  736.      endif
  737.     defs ldparm+512-$,0
  738.      endif
  739.  
  740.  
  741. ccpsct     equ 4        ;4*512 bytes/kaypro physical sector
  742.     .dephase
  743. ;=================================================================
  744. ; Cold boot command to be loaded into ZCPR
  745.      if     usecold
  746.     org    sysimag+207h
  747.     coldcmd
  748.      endif
  749. ;
  750. ;
  751.  
  752.     subttl BIOS proper
  753.     eject
  754. ;=================================================================
  755.  
  756.     org    sysimag + 1800h
  757.     .phase    ramimag + 1800h
  758.  
  759. cboot:
  760.     jp     boot
  761.     jp     wboot
  762.     jp     consta
  763.     jp     conin
  764.     jp     conout
  765.     jp     list
  766.     jp     punch
  767.     jp     reader
  768.     jp     home
  769.     jp     seldsk
  770.     jp     settrk
  771.     jp     setsec
  772.     jp     setdma
  773.     jp     read
  774.     jp     write
  775.     jp     listst
  776.     jp    sectrn
  777. ;
  778.     jp    spcfnc            ; See note below
  779.     jp    calrom            ; Call ROM service routine
  780.  
  781. ;  Special Functions call
  782. ;    C = 0    Pause print buffer
  783. ;    C = 1    Halt print buffer
  784. ;    C = 2    Return logical ramdisk assignment (0ffh if not initialized)
  785. ;    C = 3    Return address of iflag in HL
  786.  
  787.  
  788.  
  789. iflag:
  790.     defb 0        ;motor interrupt flag
  791. bsflag:
  792.     defb 0        ;flags used by BIOS
  793.             ;bit 7 (raw/decoded function keys)
  794.             ;bit 6 (foreign language kaypros only)
  795.             ;bit 5 (foreign language kaypros only)
  796.             ;bit 4 (foreign language kaypros only)
  797.             ;bit 3    unused
  798.             ;bit 2    unused
  799.             ;bit 1    unused
  800.             ;bit 0    write safe flag (old ROMs only)
  801.  
  802.  
  803. ; standard kaypro layout of function keys
  804. ; (pre - universal ROM)
  805.  
  806. akeys:
  807.     defb 0bh,0ah,08h,0ch     ;standard adm 3a cursor keys
  808.                 ;(for wordstar)
  809. keypad:
  810. ;    defb '0123456789-,'    ;standard keypad definition
  811. ;    defb cr,'.'
  812.     defb '0123456789-+'     ;modified keypad definition
  813.     defb cr,'.'
  814.  
  815.  
  816. ; motor delay used in count down offset preserved
  817. ; (any program can zero this if it wants control
  818. ; of the drive motors)
  819.  
  820. mcnter:
  821.     defw     0        ;interrupt version only uses
  822.                 ;first byte
  823. schar:
  824.     defb    0        ; Screen dump character - not used
  825.  
  826. ;=================================================================
  827. ; true cold boot entry which causes system restart
  828. ; note -- this is different from kaypro use
  829.  
  830. boot:
  831.     ld     l,xstart
  832. xcalrm:
  833.     jp     calrom
  834.  
  835.  
  836. ;=================================================================
  837. ;    ** page-zero addresses **
  838. ;
  839. iobyte    equ 0003h
  840. cdrive    equ 0004h
  841. bdos    equ 0005h
  842.  
  843. wboot:
  844.     ld     sp,0100h    ;make sure we have good stack
  845. rbtdrv    equ     $ + 1        ;location to patch for different boot
  846.     ld     a,0        ;default is to reboot from a
  847.     ld     de,ccp        ;location to load at
  848.                 ;number of sectors and starting sector
  849. ralph:    equ    (1600h/80h)*100h
  850.     ld    bc,ralph + ccpsct
  851.     ld     l,57h        ;ROM warm boot entry
  852.     call     calrom
  853.     ld     a,0c3h        ;z-80 'jp' instruction
  854.     ld     (0),a
  855.     ld     (bdos),a    ;set up BIOS/bdos jumps
  856.     ld     hl,cboot+3
  857.     ld     (1),hl        ;BIOS warm boot pointer
  858.     ld     hl,ccp + 0806h
  859.     ld     (bdos+1),hl    ;bdos ptr
  860.  
  861. wptr0    equ     $ + 1        ;for patching by datestamper install
  862.     ld     de,wmsg        ;pointer to warm boot message
  863.     ld     c,9
  864.     call     bdos        ;use bdos string printer
  865.  
  866.     ld     hl,bsflag    ;point at BIOS flag
  867.     res     7,(hl)        ;make sure function keys not 'raw'
  868.  
  869.     ld     a,(cdrive)
  870.     ld     c,a        ;get logged in drive/user
  871.     jp     ccp + 3
  872.  
  873. ;=================================================================
  874. ; console status
  875.  
  876. consta:
  877.     ld     a,(iflag)
  878.     or     a        ;test if using interrupts
  879.     jr     nz,ncnt        ;skip if we are
  880.  
  881. ;constat polling motor count down
  882.  
  883.     ld     hl,mcnter + 1
  884.     or     (hl)        ;test for count down (high byte only)
  885.     jr     z,ncnt
  886.     dec     hl
  887.     dec     (hl)        ;decrement low byte
  888.     jr     nz,ncnt
  889.     inc     hl
  890.     dec     (hl)
  891.     call     z,motoff
  892.  
  893. ncnt:
  894.     ld     a,(iobyte)
  895.     rrca            ;test for crt/tty
  896.     ld     l,xttysta
  897.     jr     nc,xcalrm    ;no buffering from tty
  898.  
  899. bufclr    equ     $ + 1
  900.     ld     a,0        ;buffer clear flag
  901.     or     a
  902.     ld    l,0        ; Return null in l to indicate real character
  903.     ret     nz        ; Return if buffer not clear
  904.  
  905.     ld     l,xcrtsta    ;go see if anything new
  906.     call     calrom
  907.     ld    l,a
  908.     ret     z        ;return if no character
  909.  
  910. ; else fetch it
  911.  
  912.     ld     l,xcrtin
  913.     call     calrom
  914.  
  915.  
  916. ; check for function keys pressed
  917.  
  918.     cp    maxkey
  919.     jr    c,isnorm    ; < maxkey = normal character
  920.                 ; All others are function keys
  921. isfunc:
  922.     ld    l,a        ; Save char for return to IOP
  923.     xor    a        ; A function key has been pressed
  924.     ret
  925. isnorm:
  926.     ld    (bufchr),a    ; A printable key has been pressed
  927.     xor    a
  928.     ld    l,a        ; Return null in L
  929.     dec    a
  930.     ld    (bufclr),a
  931.     ret
  932.  
  933. ;=================================================================
  934. ;    ** console input **
  935.  
  936. conin:
  937.     call     consta
  938.     jr     z,conin        ;loop out of ROM
  939.     ld     a,(iobyte)
  940.     rrca
  941.     jp     nc,reader    ;no screen dump or
  942.                 ;function keys with tty
  943.  
  944. bufchr    equ     $ + 1        ;one character look-ahead where
  945.     ld     a,0        ;constat places character
  946.     ld     hl,bufclr
  947.     ld     (hl),0        ;clear buffer flag
  948.  
  949. ; now must map any function keys
  950.  
  951. mapfnc:
  952.     or     a
  953.     ret     p        ;if no high bit then return
  954.     ld     hl,bsflag    ;see if we are to map
  955.     bit     7,(hl)
  956.     ret     nz        ;return raw function if set
  957.     ld     hl,akeys    ;point to mapping table
  958.     and     1fh        ;crunch hi bits
  959.     add     a,l
  960.     ld     l,a        ;get offset, (always in first page)
  961.     ld     a,(hl)
  962.     ret
  963.  
  964.  
  965.  
  966. ;=================================================================
  967. ;    **  console output  **
  968.  
  969. conout:
  970.     ld     a,(iobyte)
  971.     rrca
  972.     jr     nc,punch    ;send to tty
  973.  
  974. ; must trap bell character if interrupt timer being used
  975.  
  976. crtout:
  977.  
  978. ; the following code handles the kaypro graphics and
  979. ; allows zcpr3 to toggle the graphics on/off.
  980.  
  981.      if grafbt ne 0
  982.     ld     a,(grafbt)    ;get the graf byte
  983.     or     a        ;non-0 to pass graphics chars
  984.     jr     nz,nograf
  985.     ld     a,c        ;char is in c
  986.     and     7fh
  987.     ld     c,a        ;now put back masked byte
  988. nograf:
  989.      endif
  990.  
  991.     ld     l,xcrtout
  992.     ld     a,(iflag)    ;are we using interrupts
  993.     or     a
  994.     jr     z,calrom
  995.     ld     a,(mcnter)    ;is motor still running
  996.     or     a
  997.     jr     z,calrom
  998.     ld     a,c
  999.     cp     7        ;test for bell
  1000.     jr     nz,calrom
  1001.     ld     hl,txchar
  1002.     set     2,(hl)        ;set bell bit
  1003.     ret
  1004.  
  1005.  
  1006. ;=================================================================
  1007. ;        **  list output  **
  1008.  
  1009. list:
  1010.     call     listst        ;loop till ready in hi memory
  1011.     jr     z,list
  1012.     ld     a,(iobyte)
  1013.     and     0c0h        ;isolate list device
  1014.     jr     z,punch
  1015.     rlca
  1016.     rlca
  1017.     dec     a        ;test for crt
  1018.     jr     z,crtout
  1019.     dec     a
  1020.     ld     l,xul1out
  1021.     jr     nz,calrom
  1022.     ld    a,psync        ;access print buffer
  1023.     call    strobe
  1024.     ld    a,c
  1025.     call    strobe
  1026.     ret
  1027.  
  1028.  
  1029.  
  1030. ;=================================================================
  1031. ;        **  sector translate  **
  1032.  
  1033. sectrn:
  1034.     ld    a,(dstat)
  1035.     or    a
  1036.     ld     l,xsctrn
  1037.     jr     z,calrom
  1038.     push    bc
  1039.     pop    hl
  1040.     ret
  1041.  
  1042.  
  1043. ;=================================================================
  1044. ; ** turn off floppy motor / deselect hard disk **
  1045.  
  1046. motoff:
  1047.     ld     l,xdskoff
  1048.     jr    calrom        ;jump to ROM
  1049.  
  1050.  
  1051. ;=================================================================
  1052. ;    **  punch device (always tty)  **
  1053.  
  1054. punch:
  1055.     ld     l,xttyout    ;and fall through
  1056.  
  1057.  
  1058. ;=================================================================
  1059. ;    *****    main entry to ROM   *****
  1060.  
  1061. calrom:
  1062.     push     af        ;save a
  1063.  
  1064. ; disable sio status interrupts
  1065.  
  1066.     ld     a,(iflag)
  1067.     or     a
  1068.     jr     z,skip
  1069.     di            ;make sure we are not hit
  1070.     ld     a,1        ;select write reg 1
  1071.     out     (siobcmd),a
  1072.     xor     a        ;disable all interrupts
  1073.     out     (siobcmd),a
  1074.     ei
  1075. skip:
  1076.     pop     af
  1077.     call     0fffch        ;fixed ROM entry point
  1078.     push     hl
  1079.     push     af
  1080.  
  1081. ; check if motor counter needs reset
  1082.  
  1083.     ld     a,(iflag)
  1084.     or     a
  1085.     jr     z,notint
  1086.     ld     hl,mcnter    ;point to current motor counter
  1087.                 ;(lo byte only used by interrupt
  1088.                 ;counter)
  1089.     and     (hl)        ;test for zero
  1090.     jr     z,notint
  1091.  
  1092. ; now reinitialize sio status interrupts
  1093.  
  1094.     di
  1095.     in     a,(siobst)    ;check if buffer empty
  1096.     bit     2,a
  1097.     jr     z,nempty
  1098.     dec     (hl)        ;decrement count
  1099.     jr     nz,not00
  1100.     inc     (hl)        ;make sure we are non zero
  1101.                 ;only time-out in
  1102.                 ;actual interrupt routine
  1103. click0    equ     $ + 1
  1104. not00:
  1105.     ld     a,0
  1106.     out     (siobdat),a    ;restart timer
  1107.  
  1108. nempty:
  1109.     ld     a,1
  1110.     out     (siobcmd),a    ;select register 1
  1111.     ld     a,00000110b    ;enable vectored tx empty interrupts
  1112.     out     (siobcmd),a
  1113.     ei
  1114. notint:
  1115.     pop     af
  1116.     pop     hl
  1117.     ret
  1118.  
  1119.  
  1120. ;=================================================================
  1121. ;    **  reader device (always tty)    **
  1122.  
  1123. reader:
  1124.     ld     l,xttyin
  1125.     jr     calrom
  1126.  
  1127.  
  1128. ;=================================================================
  1129. ;    **  home selected disk drive  **
  1130.  
  1131. home:
  1132.     ld    a,(dstat)
  1133.     or    a
  1134.     ld     l,xhome
  1135.     jr     z,calrom
  1136.     xor    a
  1137.     ld    (dtrack),a
  1138.     ld    (dsector),a
  1139.     ret
  1140.  
  1141. ;=================================================================
  1142. ;        **  select disk  **
  1143.  
  1144. seldsk:
  1145.     ld    a,c
  1146.     cp    rdnum
  1147.     ld    a,1
  1148.     jr    z,isram
  1149.     ld    a,0
  1150. isram:    ld    (dstat),a
  1151.     ld    hl,rdiskdph
  1152.     ret    z
  1153.     ld     l,xseldsk
  1154. xclrm:    jr     calrom
  1155.  
  1156.  
  1157. ;=================================================================
  1158. ;        **  set track  **
  1159.  
  1160. settrk:
  1161.     ld    a,(dstat)
  1162.     or    a
  1163.     ld     l,xsettrk
  1164.     jr     z,calrom
  1165.     ld    a,c
  1166.     ld    (dtrack),a
  1167.     ret
  1168.  
  1169. ;=================================================================
  1170. ;        **  set sector    **
  1171.  
  1172. setsec:
  1173.     ld    a,(dstat)
  1174.     or    a
  1175.     ld     l,xsetsec
  1176.     jr     z,calrom
  1177.     ld    a,c
  1178.     ld    (dsector),a
  1179.     ret
  1180.  
  1181. ;=================================================================
  1182. ;        **  set dma address  **
  1183.  
  1184. setdma:
  1185.     ld    (dmaptr),bc
  1186.     ld     l,xsetdma
  1187.     jr     xclrm
  1188.  
  1189. ;=================================================================
  1190. ;    **  read specified sector  **
  1191.  
  1192. read:
  1193.     ld    a,(dstat)
  1194.     or    a
  1195.     jr    z,notram
  1196.     ld    c,rdcmd
  1197.     call    ramrun
  1198. rd0:
  1199.     ld    a,d
  1200.     out    (bitport),a
  1201.     ini
  1202.     ld    a,e
  1203.     out    (bitport),a
  1204.     jr    nz,rd0
  1205.     call    setpin
  1206. retnul:
  1207.     xor    a
  1208.     ei
  1209.     ret
  1210. notram:
  1211.     ld     b,xread
  1212.  
  1213. ; common read/write entry
  1214.  
  1215. motcns    equ     $ + 1
  1216. stime:
  1217.     ld     hl,2fffh    ;reset motor off timer
  1218.     ld     (mcnter),hl
  1219.     ld     l,b        ;get function set up
  1220.     jr     xclrm
  1221.  
  1222. ;=================================================================
  1223. ;    **  write specified sector  **
  1224.  
  1225. write:
  1226.     ld    a,(dstat)
  1227.     or    a
  1228.     ld    b,xwrite
  1229.     jr    z,stime
  1230.     ld    c,wrcmd
  1231.     call    ramrun
  1232.     call    setpout
  1233. wr0:
  1234.     outi
  1235.     ld    a,d
  1236.     out    (bitport),a
  1237.     ld    a,e
  1238.     out    (bitport),a
  1239.     jr    nz,wr0
  1240.     call    setpin
  1241.     xor    a
  1242.     ei
  1243.     ret
  1244.  
  1245. ;=================================================================
  1246. ;        **  list status  **
  1247.  
  1248. listst:
  1249.     ld     a,(iobyte)
  1250.     and     0c0h        ;mask out list bits
  1251.     ld     l,xttosta
  1252.     jr     z,xclrm        ;tty used
  1253.     rlca
  1254.     rlca            ;move into low bits
  1255.     dec     a        ;test for crt, always ready
  1256.     jr    z,ready
  1257.     dec    a
  1258.     jr    z,ready
  1259.     ld     l,xul1ost
  1260.     jr     xclrm
  1261. ready:
  1262.     dec     a
  1263.     ret            ;always ready
  1264.  
  1265. ;=================================================================
  1266. ;interrupt driven motor/deselect timer
  1267.  
  1268. ; this interrupt driven timer uses the keyboard tx buffer
  1269. ; empty which interrupts at 30 hz rate.  if iflag enabled
  1270. ; then type-ahead keyboard must also be enabled, so that
  1271. ; occassional framing errors generated by keyboard firmware
  1272. ; bug can be corrected.  note that some very early smk
  1273. ; keyboards with 8749 (cf 8049 in later) have a serious
  1274. ; bug that makes operation with interrupts impossible,
  1275. ; symptoms of this problem are ^@'s appearing on console
  1276. ; when a key is pressed.
  1277.  
  1278. ; maximum timing delay is 8.3 seconds.
  1279.  
  1280.  
  1281. timer:
  1282.     ld     (timstk),sp    ;save current stack
  1283.     ld     sp,timstk    ;set up new local stack
  1284.     push     af
  1285.     push     hl
  1286.     ld     hl,mcnter    ;point to counter
  1287.     dec     (hl)        ;decrement
  1288.     call     z,motoff    ;deselect and flush if needed
  1289. txchar    equ     $ + 1        ;clicks and bell
  1290.     ld     a,0        ;character to send to keyboard
  1291.     bit     2,a        ;is bell bit set
  1292.     jr     z,nbel        ;skip if no bell
  1293.     ld     h,beldly    ;need to delay
  1294. lp:
  1295.     dec     l
  1296.     jr     nz,lp
  1297.     dec     h
  1298.     jr     nz,lp        ;delay before bell
  1299.  
  1300. nbel:
  1301.     out     (siobdat),a    ;send character
  1302.     res     2,a        ;clear bell bit
  1303.     ld     (txchar),a
  1304.     pop     hl        ;note motoff saves additional reg. used
  1305.     pop     af
  1306.     ld     sp,(timstk)    ;get back old stack pointer
  1307.     ei
  1308.     reti
  1309.  
  1310. ; Special function for misc BIOS services related to IOP and NZCOM
  1311. ;
  1312. spcfnc:
  1313.     ld    a,c
  1314.     or    a
  1315.     jr    z,ppause    ; c=0    Printer pause
  1316.     dec    a
  1317.     jr    z,phalt        ; c=1    Printer halt
  1318.     dec    a
  1319.     jr    z,rdstat    ; c=2    Return ramdisk status
  1320.     dec    a
  1321.     ld    hl,iflag    ; c=3    Return address of iflag
  1322.     ret    z
  1323. ;    
  1324. ; Additional subfucntions may be added here
  1325. ;
  1326.     xor    a        ; Return a=0ffh, not valid subfunction
  1327.     dec    a
  1328.     ret
  1329.  
  1330. rdstat:    ld    a,rdnum        ; Return ramdisk logical disk assignment
  1331.     ret
  1332.     
  1333. phalt:
  1334.     ld    a,haltsnc
  1335.     call    strobe
  1336.     ret
  1337.  
  1338. ppause:    ld    a,pausnc
  1339.     call    strobe
  1340.     ret
  1341.  
  1342. strobe:
  1343.     push    af
  1344.     in    a,(bitport)
  1345.     res    pstrob,a
  1346.     out    (bitport),a
  1347. st0:
  1348.     in    a,(bitport)
  1349.     bit    pbusy,a
  1350.     jr    nz,st0
  1351.     call    setpout
  1352.     pop    af
  1353.     out    (ddata),a
  1354.     in    a,(bitport)
  1355.     set    pstrob,a
  1356.     out    (bitport),a
  1357. st1:
  1358.     in    a,(bitport)
  1359.     bit    pbusy,a
  1360.     jr    z,st1
  1361.     call    setpin
  1362.     xor    a        ; Zero it for consta
  1363.     ret
  1364.  
  1365. setpin:
  1366.     ld    a,0cfh
  1367.     out    (dcntl),a
  1368.     ld    a,0ffh
  1369.     out    (dcntl),a
  1370.     ret
  1371.  
  1372. setpout:
  1373.     ld    a,0cfh
  1374.     out    (dcntl),a
  1375.     ld    a,0
  1376.     out    (dcntl),a
  1377.     ret
  1378.  
  1379. ramrun:
  1380.     di
  1381.     ld    a,dsync
  1382.     call    strobe
  1383.     ld    a,(dtrack)
  1384.     call    strobe
  1385.     ld    a,(dsector)
  1386.     call    strobe
  1387.     ld    a,c
  1388.     call    strobe
  1389.     ld    hl,(dmaptr)
  1390.     ld    b,128
  1391.     ld    c,ddata
  1392.     in    a,(bitport)
  1393.     res    pstrob,a
  1394.     ld    d,a
  1395.     set    pstrob,a
  1396.     ld    e,a
  1397.     ret
  1398.  
  1399.     subttl    Data tables
  1400.     eject
  1401.  
  1402. ; ==========================================================
  1403. ;
  1404. ;   DATA TABLES
  1405. ;
  1406.  
  1407. ; RAM disk DPH
  1408. ;
  1409. rdiskdph:
  1410.     defw    0,0,0,0
  1411. rdirbuf:
  1412.     defw    0        ; Must be filled in by init routine
  1413.     defw    rdiskdp
  1414.     defw    0000,alvd    ; Let's use DRI std. Pointer to csvd = 0
  1415. csvd:                ; if non-removable medium.
  1416.     ds    cks
  1417. alvd:
  1418.     ds    (dsm/8)+1
  1419.  
  1420. rdiskdp:
  1421.     defw    spt        ; RAM disk DPB
  1422.     defb    bsh
  1423.     defb    blm
  1424.     defb    exm
  1425.     defw    dsm
  1426.     defw    drm
  1427.     defb    al0
  1428.     defb    al1
  1429.     defw    cks
  1430.     defw    offtrk
  1431.  
  1432. dtrack:
  1433.     defb    0        ; RAM disk sector
  1434. dsector:
  1435.     defb    0        ; RAM disk sector
  1436. dstat:
  1437.     defb    0        ; RAM disk select
  1438. dmaptr:
  1439.     defw    0        ; RAM disk DMA pointer
  1440.  
  1441.     subttl stack and assembly time stat display
  1442. ;=================================================================
  1443. endbios    equ $
  1444.  
  1445. ; The original amount of space here is determined by datestamper
  1446. ; requirements.  We will make it smaller, since we don't bother with
  1447. ; datestamper.
  1448.  
  1449. wmsg:    defs wmsglen
  1450.     if false
  1451.  
  1452. Timstk defines a stack--for use by the ROM itself--which is
  1453. compatible with Plu*Perfect Systems DateStamper.
  1454.  
  1455. The syssct label instructs the ROM how many sectors to load from
  1456. disk.  When the environment is to be included in the cold boot load,
  1457. it must be taken into account when syssct is computed.
  1458.     endif
  1459.  
  1460.      if    bstack ne 0
  1461. alldone    equ    $        ;stack is external, don't count it
  1462.      else
  1463.     .dephase
  1464.     org    sysimag + (wmsg + 64 - ramimag)
  1465.     .phase    wmsg + 64
  1466. timstk:    defw     0        ;word to save stack during init.
  1467. alldone equ    $        ;stack is internal, count it
  1468.      endif
  1469.  
  1470. bslen    equ    alldone-ccp-0800h-0E00h
  1471.  
  1472. sysbyt    defl    ($ - bootcd)
  1473. syssct    defl    ($ - bootcd)/128
  1474.      if     sysbyt mod 128 gt 0
  1475. syssct    defl     syssct + 1
  1476.      endif
  1477.  
  1478.     .printx
  1479.     prtval    10,<System sectors allocated ....  >,syssct,< sectors>
  1480.     .printx     Maximum System size  ........  55 sectors
  1481.      if syssct le 37h
  1482.     prtval    10,<System bytes allocated ..... >,sysbyt,< bytes>
  1483.     .printx
  1484.  
  1485. secbyt    equ    128 - (sysbyt mod 128)
  1486. scrtbyt    equ    scratch-alldone
  1487.  
  1488.      if secbyt ge 100
  1489.     prtval    10,<Bytes left in this sector ..  >,secbyt,< bytes>
  1490.      else
  1491.      if secbyt ge 10
  1492.     prtval    10,<Bytes left in this sector ..   >,secbyt,< bytes>
  1493.      else
  1494.     prtval    10,<Bytes left in this sector ..    >,secbyt,< bytes>
  1495.      endif
  1496.      endif
  1497.  
  1498.      if scrtbyt ge 100
  1499.     prtval    10,<Bytes free to scratch ......  >,scrtbyt,< bytes>
  1500.      else
  1501.      if scrtbyt ge 10
  1502.     prtval    10,<Bytes free to scratch ......   >,scrtbyt,< bytes>
  1503.      else
  1504.     prtval    10,<Bytes free to scratch ......    >,scrtbyt,< bytes>
  1505.      endif
  1506.      endif
  1507.  
  1508.      else
  1509. sysofl    equ    syssct-55
  1510. bytofl    equ    sysbyt-7040
  1511. asmerr    defl    asmerr or 04h
  1512.  
  1513.     prtval    10,<System sector excess .........  >,sysofl,< sectors>
  1514.     prtval    10,<  "      "      "    ........  >,bytofl,< bytes  +++>
  1515.      endif
  1516.     .dephase
  1517.      if bstack ne 0
  1518.     org    sysimag + (bstack - ramimag)
  1519.     .phase    bstack
  1520. timstk:    defw    0
  1521.     .dephase
  1522.      endif
  1523.  
  1524.     .printx
  1525. cphase    equ    bootcd + 180h
  1526.  
  1527.     prtval    16,<Start of CCP ................  >,cphase,< hex>
  1528.     prtval    16,<Last address in BIOS ........  >,alldone,< hex>
  1529.      if alldone ge scratch
  1530. asmerr    defl    asmerr or 08h
  1531.      endif
  1532.     prtval    16,<Size of BIOS ................    >,alldone-cboot,< hex>
  1533.  
  1534. sysk     equ (ccp+1c00h)/400h
  1535. sysq    equ ((ccp+1c00h) mod 400h)/100h * 25
  1536.  
  1537.      if asmerr
  1538.     .printx
  1539.      endif
  1540.      if asmerr and 01h
  1541.        .printx *** ERROR ***   Parameter sector overflow
  1542.      endif
  1543.      if asmerr and 02h
  1544.     .printx *** ERROR ***   Initialization code overflow
  1545.      endif
  1546.      if asmerr and 04h
  1547.     .printx *** ERROR ***   System size overflow
  1548.      endif
  1549.      if asmerr and 08h
  1550.     .printx *** ERROR ***   Code overflows into reserved memory
  1551.      endif
  1552. sbios    equ    (scratch - (alldone-cboot)) & 0ff00h    ; Suggested biosloc
  1553. sccp    equ    sbios-1600h
  1554. ssysk    equ    (sccp+1c00h)/400h
  1555. ssysq    equ    ((sccp+1c00h) mod 400h)/100h * 25    ; Suggested sys size
  1556.     .printx    
  1557.     .printx    SYSTEM WITH BIOS AS ASSEMBLED:
  1558.     prtval    16,<BIOS location ................... >,biosloc
  1559.     prtdec    <Required TurboROM system size ... >,sysk,sysq
  1560.     .printx
  1561.      if asmerr & 7
  1562.     .printx CORRECT ERROR(S) MARKED "+++" AND REASSEMBLE *****
  1563.      else
  1564.     .printx    SUGGESTED OPTIMUM SYSTEM:
  1565.     prtval    16,<BIOS location ................... >,sbios
  1566.     prtdec    <Required TurboROM system size ... >,ssysk,ssysq
  1567.      endif
  1568.     .printx
  1569.     .printx
  1570.     end
  1571.  
  1572.