Re: [stella] compact send-only serial subroutine

Subject: Re: [stella] compact send-only serial subroutine
From: "Fred Quimby" <c9r@xxxxxxxxxxx>
Date: Sat, 13 Aug 2005 02:17:45 -0400
Here's the source, which should make it obvious... When I ran it, my laptop 
screen filled with line after line of the string below.

Note that this is designed for a direct connection from the 2600's right 
joystick to a PC serial port like I suggested.

If you prefer use a TTL level converter like the ones you posted, the 
program needs to be modified.  See comments below for how to modify the 
program if you use one of these.

processor 6502
include "vcs.h"
include "macro.h"

BIT1	EQU	13		; 1200 baud
BIT2	EQU	13

ORG $F000
start

sei
cld
ldx #0
txa
clearmem
inx
txs
pha
bne clearmem
lda #1
sta SWACNT
lda #$ff
sta SWCHA
rerestart
ldx #200
delay
STA WSYNC
dex
bne delay

restart
ldx #0
stx $a0
keepgoing
lda data,x
beq rerestart
jsr OUT232
inc $a0
ldx $a0
jmp keepgoing

data .byte 13
dc.b "This is a test to see if this character string gets sent properly."
.byte 13,10,13,10,0


OUT232
	LDX	#$FF		; output low for start bit
;	LDX	#$00		; Uncomment this line if using a TTL level converter
	STX	SWCHA
	LDX	#4		; init count for 4 bit pairs
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY		; send the start bit

	EOR	#$FF
; remove the above line if using a TTL level converter

OUT232b
	STA	SWCHA
	LDY	#BIT2		; wait 1 bit
	JSR	WSYNCY	; send the next bit
	ROR			; rotate out next bit
	STA	SWCHA
	ROR			; rotate out next bit
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY	; output next bit
	DEX			; decrement counter
	BNE	OUT232b	; loop until 8 bits sent


	LDA	#$00		; output high for stop bit
;	LDA	#$FF		; Uncomment this line if using a TTL level converter
	STA	SWCHA
	LDY	#BIT1		; wait 1 bit
	JSR	WSYNCY	; send the stop bit

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

ORG $FFFC
.word start
.word start


>Looks like I have something fun to play around with
>over the weekend.
>
>Just so I know what to look for, what is your BIN
>supposed to send to the PC?
>
>--- Fred Quimby <c9r@xxxxxxxxxxx> wrote:
>
> > Hmmm.... TTL works for me, on every computer I have.
> >
> > I've proved it too.  Make a cable the way I
> > described, just two wires, no
> > funky electronics.  Run a PC serial comms program
> > (such as hyperterminal) at
> > 1200bps N81, no flow control.  Then turn on 2600
> > running attached .bin.
> >
> > Yes, strictly speaking, 0v TTL is out of spec, but
> > 2600 programmers say BAH!
> > to specs.  This actually does work on most serial
> > ports without need for
> > charge pumps and the like.
>
>
>
>____________________________________________________
>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
>


Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://stella.biglist.com

Current Thread