;====================================================================== ; Initialization section (12_Nov_84) ;=================================== ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro, Ca. ; Written by David Block and Jim Kearney (September 1983) ; ;---------------------------------------------------------------------- ; Index (12_Nov_84) ;------------------ ; ; SLFTST Self Test Routine ; KTEST Keyboard Test ; MTEST Memory Test ; ; INIUART Initialize the Uart Main Line ; SETBAUD Determine the Baud Rate ; SETUART Set the Uart's Baud Rate ; INIT8 Set the Uart's Reciever/Transmitter Format ; ; GETSW Get the value of the Dip Switches ; INITBUF Initialize the Input Buffers ; SETXLT Set up pointers for doing tranlation of foreign character sets PAGE ;---------------------------------------------------------------------- ; Self-Test Routine ;------------------ ; Check Ram and See if a keyboard is connected. ; SLFTST: JSR KTEST ;test memory JSR MTEST ;test kbrd RTS ;---------------------------------------------------------------------- ; Test the Keyboard ;------------------ ; KTEST: LDX BAUD ; see if kbrd trying to send BPL CHKKBRD ; if ( kbrd trying to send) then JSR GETKEY ; get key from keyboard JMP KTEST ; wait for settle CHKKBRD:LDA #$1 ; assert attention to KBRD ORA BDREG STA BAUD LDX #200 ; sample for 4 ms ( 200 * 20 Micro secs ) KWAIT: TXA PHA LDX 2 ; wait 20 micro seconds JSR KDLY LDX BAUD ; see if ACK RCV'D from keyboard BMI KBRDOK ; if bit set, then keyboard is ok PLA ; else, decrement time out count TAX DEX BNE KWAIT ; if time not up, then keep looking LDA KMESG ; point to memory fail message STA MESG LDA KMESG+1 STA MESG+1 JSR PRNTMSG ; print message PLA PLA ; preserve stack JMP SLFTST ; wait for the keyboard to be connected KBRDOK: PLA ; fix stack LDA #BEEP ; now, we have to give this ack a character SEI ; and set up the needed parameters PHA LDY #8 JMP ACK1 ; go send it a key, and return to Selftest PAGE ;---------------------------------------------------------------------- ; Test Memory ;------------ ; MTEST: LDY #0 ST1: TYA STA CRAM,Y STA CRAM+1021,Y STA ARAM,Y STA ARAM+509,Y INY BNE ST1 ST2: TYA CMP CRAM,Y BNE SERROR CMP CRAM+1021,Y BNE SERROR CMP ARAM+509,Y BNE SERROR CMP ARAM,Y BNE SERROR INY BNE ST2 RTS SERROR: LDA #BEEP ; beep the bell JSR KBRDOUT LDA MMESG ; point to memory fail message STA MESG LDA MMESG+1 STA MESG+1 JSR PRNTMSG ; print message SELF: JMP SELF ; and loop forever PAGE ;---------------------------------------------------------------------- ; Uart Initialization ;-------------------- ; INIUART:JSR SETBAUD ;determine baud rate selection bits JSR SETUART ;setup UART for proper BAUD rate, etc JSR INIT8 ;set status of bit 8 parity, or mark, or space RTS ;---------------------------------------------------------------------- ; Determine the Baud Rate Settings ;--------------------------------- ; SETBAUD:LDA BDREG ;get current contents of baud register AND #$F9 ;Clear BD0 and BD1 STA BDREG LDA DIP1 ;get dipsw value AND #$03 ;get baud rate selection bits ASL A ;align with BDREG ORA BDREG ;set/clr baud bits STA BDREG ;Save it STA BAUD ;and set baud bits RTS PAGE ;---------------------------------------------------------------------- ; Set the Uart Baud Rate ;----------------------- ; SETUART:LDX #$80 ;after setting baud rate, wait to settle SULP1: DEX BNE SULP1 LDA #$80 ;reset USART STA S1STAT TAX TAX ;WAIT STA S1STAT LDA #$40 STA S1STAT ;Put USART in command mode LDA DIP1 ;get dip switch settings AND #%00001100 ;get the parity select bits ASL A ASL A ;align them for USART Mode byte STA TEMP ;put it aside LDA DIP1 ;get dip switch AND #%00000010 ;determine if it needs /16 or /64 LSR A ;move the determining bit over ORA TEMP ;get parity select bits back ORA #%01001110 ;OR in USART MODE boiler plate (8-data, 1-stop) STA S1STAT ;set USART Mode LDA #%00110111 ;get enable byte for USART STA S1STAT ;Enable USART STA UARTCMD ;save it in command instr. register LDA S1DATA ;Flush one character RTS ;---------------------------------------------------------------------- ; Set Transmission/Reception Format ;---------------------------------- ; INIT8: LDA DIP1 ;get dip setings LSR A ;get parity on/off status LSR A TAX AND #%00000001 STA PARSTAT ;save it in parity status TXA LSR A AND #%00000001 ;get whether mark or space/ odd/even STA BIT8 RTS PAGE ;---------------------------------------------------------------------- ; Read the Dip Switches ;---------------------- ; GETSW: LDA DIPSW11 ; READ DIP SWITCH ASL A STA DIP1 LDA DIPSW12 ; GET 8TH SWITCH AND #01 ; MASK OFF BAD BITS ORA DIP1 ; ASSEMBLE THE 8 DATA BITS STA DIP1 ; save the dipsw settings RTS ;---------------------------------------------------------------------- ; Initialize the Input Buffers (9_Nov_84) ;---------------------------------------- ; INITBUF:LDA #$FF ;A:= 0FFh (End of Buffer Character LDX #0 ;Index/Counter:= 0 ITBLP1: STA INBUF,X ;Repeat Input_Buffer:= 0FFh DEX ; Decrement the Index/Counter BNE ITBLP1 ;Until (Counter eq 0) ITBLP2: STA INBUF2,X ;Repeat (Input_Buffer_2:= 0FFh) DEX ; Decrement the Index/Counter BNE ITBLP2 ;Until (Counter eq 0) ITBLP3: STA SNDBUF,X ;Repeat (Send_Buffer:= 0FFh) INX ; Decrement the Index/Counter BPL ITBLP3 ;Until (Counter eq 0) RTS ;Return PAGE ;---------------------------------------------------------------------- ; Set up pointers for doing tranlation of foreign character sets ;--------------------------------------------------------------- ; SETXLT: LDA DIP1 ; get dip switch settings LSR A LSR A LSR A LSR A AND #%00000111 ; get the foreign mode select bits STA FOREIGN ; save their value ASL A ; each char mode has two bytes of numxlt TAY LDA XLTCNT,Y ; get # of chars that need XLATION STA NUMXLTI ; ......for data from host INY LDA XLTCNT,Y STA NUMXLTO ; for data from KBRD DEY ; set back to former value TYA ASL A ; Now, get a pointer to XLT table vectors ASL A TAY LDX #0 ; set to count for 8 vectors MOVPTR: LDA XLTVCT,Y ; move a vector STA XLT1,X INY INX CPX #8 ; see if 8 vectors moved yet BNE MOVPTR ; if not, move another RTS PAGE END