 lib environment
 lib inttab
 lib fio
 lib iop/fio_codes
 data
 sttl Machine Dependent Rouintes
 pag
 name mach
 global clkinz,mchint,endinit

*
* clkinz
*
* Initialize system clock.
*

clkinz
 ldd #O_CLOCK start clock
 ldu #0 -- nil sequence/terminal
 jsr fio_send
 rts return

*
* mchint
*
* Initialize all hardware junk and try to find
* the existing acias.  The ones that aren't there
* need to have their mask bits cleared.
*

mchint
 ldb #$D0 Clear any interrupts on WD Floppy
 stb DMF3COM
 ldb W5CMD clear any WD winchester interrupts also
 lda #wd_sz_512+%11000 ** Turn off winchester select light **
 sta wd_sdh
*
*   configure the VIA, but dont actually enable interrupts yet
*
 lda #%01111111 disable all VIA interrupts
 sta AT_IER
 lda #-1
 sta AT_DTB initialize B side
 sta AT_DXA and A side Data Registers
 sta AT_DRA set all outputs on A side
 lda #%10000011
 sta AT_DRB set up B direction reg
*lda #%00001110
 lda #%00101110 CB2 falling indep/CA2 high out
 sta AT_PCR set peripheral control reg
 jsr ATinit initialize archive tape
*
*   Now allow interrupts from the board
*
 lda #-1 clear out any pending VIA irqs
 sta AT_IFR
*lda #%10010000 set up the VIA irq enable register
 lda #%10001000 enable CB2 interrupts only
 sta AT_IER

mchin2
 jsr map_iop
 lda NUM_TRM get number of terminals
 sta strm
 lda NUM_TSK get number of tasks
 suba #4
 sta NUM_TRAN save # transactions allowed
 jsr map_io
 rts

*
* endinit - End of machine initialization
*
endinit tst $F000 reset interrupts
 rts
