***********
* Program PLAY_MESSAGE
*
* Prints message identified by switches S1 and S0 to terminal.
* Repeats continuously.
*
* Uses indirect table lookup.
* Switch mapped to memory adr containing adr of the first char
* of the message.
*
* P. H. Anderson, MSU, 22 Oct 91; 15 Jan 93
***********
PSCT	EQU $C000
DSCT	EQU $D000
IDSCT	EQU $D300

STACKTP 	EQU $0045
REG_BASE	EQU $1000

OUT_CHAR	EQU $E3B3
* out_char is Buffalo routine which outputs char in A to term

PORTB	EQU  $04
PORTC	EQU  $03
DDRC	EQU  $07

	ORG PSCT

	LDS #STACKTP
	LDY #REG_BASE
	CLR DDRC,Y	* port c configured as 8-bit input
TOP
	LDAA PORTC,Y	* get 2 least sig switches
	ANDA #$03
	ASLA		* mult by 2 and save
	STAA OFFSET
	LDX #LOOK_UP
	XGDX
	ADDB OFFSET
	ADCA #$00	* adr of loc containing adr now in D
	XGDX		* now X
	LDX 00,X	* address of message now in X
	BSR PLAY_MSG	* output the message to the terminal
	BRA TOP

PLAY_MSG
* outputs characters to terminal beginning at address in X
* stops when character $FF is encountered

	PSHX
	PSHA
NEXT
	LDAA 00,X	* get the character
	CMPA #$FF	* test if stop character
	BEQ DONE
	JSR OUT_CHAR	* otherwise output the character
	INX		* point to next character
	BRA NEXT
DONE
	PULA
	PULX
	RTS

	ORG DSCT

OFFSET	RMB 1

	ORG IDSCT

LOOK_UP
	FDB MESSAGE_0
	FDB MESSAGE_1
	FDB MESSAGE_2
	FDB MESSAGE_3

MESSAGE_0
	FCC 'Welcome to Morgan State University.'
	FCB $0A, $0D, $FF      * CR, LF and stop character
MESSAGE_1
	FCC 'Hello World.'
	FCB $0A, $0D, $FF      * CR, LF and stop character
MESSAGE_2
	FCB '>'
	FCB $0A, $0D, $FF  * output simply a >
MESSAGE_3
	FCC 'Now is the time for all good men to come'
	FCB $0A, $0D
	FCC 'to the aid of their party.'
	FCB $0A, $0D, $FF      * CR, LF and stop character


