[stella] compact send-only serial subroutine

Subject: [stella] compact send-only serial subroutine
From: Glenn Saunders <mos6507@xxxxxxxxx>
Date: Fri, 12 Aug 2005 17:42:36 -0400
I'd like to do some kind of proof of concept to get
the 2600 to send 1 byte through a joystick port to the
PC reliably.

Anyone have a webpage that shows how to create a cable
for this?

I think I found a good code snippet to use from here:

http://xi6.com/files/7800dump.asm

I chopped out the register save/restore and
flag-clearing and the use of a temp byte of RAM.  Let
me know if you see any problems with it or if it can
be compressed further.




;	Configure joystick port for OUT232 once

RELCODE	LDA	#$40		; configure bit 6 for output
	STA	SWACNT

;-----------------------------------------------------------------------;
;	Output a character as RS-232 through the joystick
port
;
; note: 6.5 lines = approx one 2400 baud bit
;        13 lines = approx one 1200 baud bit
;-----------------------------------------------------------------------;

;	These constants add up to two bit times

;BIT1	EQU	13		; 1200 baud
;BIT2	EQU	13

BIT1	EQU	7		; 2400 baud
BIT2	EQU	6



OUT232	LDX	#0		; output low for start bit
	STX	SWCHA
	LDX	#4		; init count for 4 bit pairs
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY		; send the start bit

OUT232b	ROR			; rotate out next bit
	ROR
	ROR
	STA	SWCHA
	LDY	#BIT2		; wait 1 bit
	JSR	WSYNCY	; send the next bit
	ROR			; rotate out next bit
	ROR
	ROR
	STA	SWCHA
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY	; output next bit
	DEX			; decrement counter
	BNE	OUT232b	; loop until 8 bits sent
;	STA	WSYNC		; adjust timing a little bit
	LDA	#$FF		; output high for stop bit
	STA	SWCHA
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY	; send the stop bit

	RTS

;-----------------------------------------------------------------------;
; wait for number of scan lines specified in Y
register
;-----------------------------------------------------------------------;

WSYNCY	STY	WSYNC		; wait a line
	DEY			; decrement line counter
	BNE	WSYNCY		; loop until done
	RTS



		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://stella.biglist.com

Current Thread