;------------------------------------------------------------------------
;
;		Copyright 2012 Intergraded Logic Systems
;                  Source Code is Copyright Stephen J. Carden
;
;
;			Please do not share this source!
;------------------------------------------------------------------------
;                              PortTest.s
;
;Wrote this to test the Joy Stick Ports.
;First Design 10,19,2012
;
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;------------------------------------------------------------------------
; Notes: o This source code MAY NOT be placed for download on any BBS's!
;        o "mea" is a macro that loads the address of the first field
;          into the pointer specified by the second field.
;------------------------------------------------------------------------
; Assembler:  MADMAC (tm) ST Cross Assembler (Atari Corp)
;             XASM   st and IBM VERSIONS
;------------------------------------------------------------------------
;=====================================================================

com_file_name:		.macro
;			dc.b   13,"filename.ext",$9b
			dc.b   12,"PortTest.com",$9b
			.endm

;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; File revision history. Version Number in hex
;
file_ver:		equ  	$10
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the Month in dec for the first time this revision 
;was compiled
;
c_month:		equ   10
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the day in dec for the first time this revision 
;was compiled
c_day:			equ   20
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the year in dec for the first time this revision 
;was compiled
c_year:			equ   2012
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Type of compiler used in program
;
; 0 = unknown Compiler
; 1 = xasm
; 2 = mac_65
; 3 = basic
; 4 = compiled basic xl
; 5 = C65
; 6 = Action
;
; We can add more as time goes on!
;
;
;
xasm:			equ	1
mac_65:			equ	2 
basic:			equ	3
basicxl:		equ	4
c65:			equ	5
action:			equ	6

file_compiler:		equ	xasm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; is this relocatable code ?
; anyother value other than 1 or 2 would be unknown
r..yes:			equ	1
r..no:			equ	2
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define if it can be relocated
l_relocatable:		equ	r..no
;
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define if it can be relocated
r..crl:			equ	$7d
r..crlf:		equ	$9b
r..space:		equ	$20

l_frstscreenbyte:	equ	r..crl
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; The language the output file is in. 
;
;
; 0	=	Undifined
; 1	=	English
; 2	=	German
;
r..language:		equ	1
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


			.include	equates
			.include	globals
			.include	macros

			.org 	$4000

win_start:
header_info:
			.include	header	; this reads info out of the header and displays to screen
;						; based on info stored at the front of the file
begin_port:		lda	#$60
			sta	begin_port
			jsr	pin_reset
			jsr	pin_off
			lda	#$01
			Sta	$2f0


top:
			ldx	#0
			ldy	#6
			jsr	gotoxy
			jsr	printsi
;	                                  1111111111222222222233333333334
;	                         1234567890123456789012345678901234567890
			dc.b	" The purpose of this program is to test",$9b
			dc.b	" the Joy Stick Port and Trigger in R/W",$9b
			dc.b	$9b,$9b
			dc.b	<+128>,"[R]"
			dc.b	" Displays Joystick results!",$9b	
			dc.b	$9b
			dc.b	<+128>,"[W]"
			dc.b	" Joystick Ports in Write Mode.",$9b
			dc.b	$9b
			dc.b	<+128>,"[H]"
			dc.b	"ow to Build Display Box!",$9b,$9b
			dc.b	<+128>,"[Q]"
			dc.b	"uit to Dos",$9b,$9b,$9b
			dc.b	<+128>,"Your Selection?"
			dc.b	"  "
			dc.b	-1
.again:			jsr	getkey
			jsr	upcase
			cmp	#'R'
			beq	.r
			cmp	#'W'
			beq	.w
			cmp	#'H'
			beq	.h
			cmp	#'Q'
			beq	.q
			cmp	#$1b
			beq	.bye
			bne	.again

.r:
			jmp	Joy_test
.w:
			jmp	Joy_write
.H:
			jmp	help_menu
.bye:			jmp	$e474
.Q:
			lda	#$00		; Zero is what is needed to turn corsor on!
			sta	$2f0		; turn the cursor back on

			jsr	printsi
			dc.b	$9b
			dc.b	$9b
			dc.b	-1
			rts






Joy_write:
			jsr	pin_reset
			jsr	pin_on
			lda	#$7d
			jsr	echo
			jsr	begin_port-3

			ldx	#0
			ldy	#7
			jsr	gotoxy
			jsr	printsi
;	                                  1111111111222222222233333333334
;	                         1234567890123456789012345678901234567890
			dc.b	" The purpose of this Menu is to write",$9b
			dc.b	"  to the Joy Stick Port and Trigger",$9b
			dc.b	$9b,$9b,-1
			jsr	pin_on
			jsr	pin_reset
			jsr	pin_on

.loop:			ldx	#5
			ldy	#14
			jsr	gotoxy
			jsr	printsi
			dc.b	" Low Trigger is ==>",-1
			jsr	low_trigger

			ldx	#5
			ldy	#15
			jsr	gotoxy
			jsr	printsi
			dc.b	"High Trigger is ==>",-1
			jsr	high_trigger

			jsr	Show_portA
			jsr	pin_1
			jsr	Show_portA
			jsr	delay
			jsr	pin_2
			jsr	Show_portA
			jsr	delay
			jsr	pin_3
			jsr	Show_portA
			jsr	delay
			jsr	pin_4
			jsr	Show_portA
			jsr	delay
			jsr	pin_5
			jsr	Show_portA
			jsr	delay
			jsr	pin_6
			jsr	Show_portA
			jsr	delay
			jsr	pin_7
			jsr	Show_portA
			jsr	delay
			jsr	pin_8
			jsr	Show_portA
			jsr	delay

			jsr	pin_1
			jsr	Show_portA
			jsr	delay
			jsr	pin_2
			jsr	Show_portA
			jsr	delay
			jsr	pin_3
			jsr	Show_portA
			jsr	delay
			jsr	pin_4
			jsr	Show_portA
			jsr	delay
			jsr	pin_5
			jsr	Show_portA
			jsr	delay
			jsr	pin_6
			jsr	Show_portA
			jsr	delay
			jsr	pin_7
			jsr	Show_portA
			jsr	delay
			jsr	pin_8
			jsr	Show_portA
			jsr	delay



         		lda 	764
         		cmp 	#$ff
         		bne 	.quit
			jmp	.loop
.quit:
			lda	#$ff
			sta	764

			lda	#$7d
			jsr	echo
			jsr	begin_port-3
			jmp	top

			rts

Show_portA:
			ldx	#0
			ldy	#20
			jsr	gotoxy
			jsr	printsi
			dc.b	"Lighting up The LED's ",-1

			jsr	check_bit
			mea	show_bits,pr_ptr
			jsr	echos
			rts


Joy_test:
			jsr	pin_reset
			jsr	pin_off

			lda	#$00
			sta	$52
			lda	#$7d
			jsr	echo
			jsr	begin_port-3

			ldx	#0
			ldy	#7
			jsr	gotoxy
			jsr	printsi
;	                                  1111111111222222222233333333334
;	                         1234567890123456789012345678901234567890
			dc.b	" The purpose of this program is to test",$9b
			dc.b	"     the Joy Stick Port and Trigger",$9b
			dc.b	$9b,$9b,-1

.loop:			ldx	#5
			ldy	#10
			jsr	gotoxy
			jsr	printsi
			dc.b	" Low Trigger is ==>",-1
			jsr	low_trigger

			ldx	#5
			ldy	#11
			jsr	gotoxy
			jsr	printsi
			dc.b	"High Trigger is ==>",-1
			jsr	high_trigger

			ldx	#5
			ldy	#20
			jsr	gotoxy
			jsr	printsi
			dc.b	" Joy Stick Port test ==>",-1

			jsr	check_bit
			mea	show_bits,pr_ptr
			jsr	echos

         		lda 	764
         		cmp 	#$ff
         		bne 	.quit
			jmp	.loop
.quit:
			lda	#$ff
			sta	764

			lda	#$7d
			jsr	echo
			jsr	begin_port-3
			jmp	top

			rts









high_trigger:
			lda	$D011
			cmp	#$01
			beq	.a
			jsr	printsi
			dc.b	<+128>,"ON"
			dc.b	" ",$9b,-1
			rts
.a:
			jsr	printsi
			dc.b	<+128>,"OFF"
			dc.b	$9b,-1

			rts
low_trigger:
			lda	$D010
			cmp	#$01
			beq	.a
			jsr	printsi
			dc.b	<+128>,"ON"
			dc.b	" ",$9b,-1
			rts
.a:
			jsr	printsi
			dc.b	<+128>,"OFF"
			dc.b	$9b,-1

			rts

delay:
			lda	#$00
			sta	$14
one_second:
			lda	764
			cmp	#$ff
			bne	d.out
seconds:		lda	#20			;60
			cmp	$14
			bne	one_second
d.out:
			rts
;===========================================================
;
;Draw out a big plus to look like what a joystick 
;would do
;-----------------------------------------------------------
Left_arror:
;			lda	


			rts


;-----------------------------
; Print Hex Numbers to screen byte or card
;-----------------------------
;
;
; print a hex word value
; low byte in a reg x is high byte
;
pr_hex_card:		sta	.h_cardd
			txa
			jsr	pr_hex_byte
			lda	.h_cardd
			jsr	pr_hex_byte
			rts
;
.h_cardd:		dc.b	$00
;
pr_hex_byte:		pha
			lsr
			lsr
			lsr
			lsr
			jsr	.a
			pla
			and	#$0f
.a:			cmp	#$0a
			bcs	.b
			ora	#$30
			bne	.c
.b:			adc	#$36
.c:			jsr	echo
			rts

		
;-----------------------


gotoxy:			stx	85
			sty	84
			rts


;
;--------------------
; turn pin 1 on/off
;--------------------
pin_1:
			lda	$d300
			eor	#$10
			sta	$d300
			rts
;
;
;--------------------
; TURN PIN 2 ON/off
;--------------------
pin_2:
			lda	$d300
			eor	#$20
			sta	$d300
			rts
;
;-------------------
;TURN PIN 3 ON/off
;-------------------
pin_3:
			lda	$d300
			eor	#$40
			sta	$d300
			rts
;
;-------------------
;TURN PIN 4 ON/off
;-------------------
pin_4:
			lda	$d300
			eor	#$80
			sta	$d300
			rts
;
;----------
;PORT off
;----------
pin_off:
			lda	#$00
			sta	$d300
			lda	#$3c
			sta	$d302
			rts
;
;---------
;PORT ON
;---------
pin_on:
			lda	$d302
			sec
			sbc	#$04
			sta	$d302
			lda	#$0a
			sta	$d302
			lda	#$f0
			sta	$d300
			lda	#$00
			sta	$d300
			rts
;------------------------
;FOR WHEN YOU NEED LESS
;THAN A JIFFIY			
;------------------------
spause:			lda	#$00
.splop:			adc	#$01
			cmp	#$60
			nop
			nop
			bcc	.splop
			rts
;
;------------------------
;  PIN RESET
;------------------------
pin_reset:
			lda	#$00
			sta	$d300
			rts
;------------------------
;   PIN 5 ON/OFF 
;------------------------
pin_5:
			lda	$d300
			eor	#$01
			sta	$d300
			rts
;------------------------
;   PIN 6 ON/OFF
;------------------------
pin_6:
			lda	$d300
			eor	#$02
			sta	$d300
			rts
;------------------------
;   PIN 7 ON/OFF
;------------------------
pin_7:
			lda	$d300
			eor	#$04
			sta	$d300
			rts
;------------------------
;   PIN 8 ON/OFF 
;------------------------
pin_8:
			lda	$d300
			eor	#$08
			sta	$d300
			rts
;
;------------------------
;   LOAD PIN 
;------------------------
load_pin:
			sta	$d300
			rts
;------------------------
; BIT LOGIC LOAD ACC 
; LOAD Y REG WITH BIT	#
;------------------------
check_bit:
			lda	$d300			;porta
			ldy	#7
			sta	check_hold
			sty	check_hold+1
			ldy	#$00
			lda	#$94			;'1'
check1:			sta	check_line,y
			iny
			cpy	#$08
			bcc	check1
			lda	check_hold
			clc
			asl
			bcc	c_bit_1
			ldy	#$14			;'0'
			sty	check_line+7
			clc
c_bit_1:
			asl
			bcc	c_bit_2
			ldy	#$14			;'0'
			sty	check_line+6
			clc
c_bit_2:
			asl
			bcc	c_bit_3
			ldy	#$14			;'0'
			sty	check_line+5
			clc
c_bit_3:
			asl
			bcc	c_bit_4
			ldy	#$14			;'0'
			sty	check_line+4
			clc
c_bit_4:
			asl
			bcc	c_bit_5
			ldy	#$14			;'0'
			sty	check_line+3
			clc
c_bit_5:
			asl
			bcc	c_bit_6
			ldy	#$14			;'0'
			sty	check_line+2
			clc
c_bit_6:
			asl
			bcc	c_bit_7
			ldy	#$14			;'0'
			sty	check_line+1
			clc
c_bit_7:
			cmp	#$00
			beq	c_bit_8
			ldy	#$14			;'0'
			sty	check_line
			clc
c_bit_8:
			clc
			ldy	check_hold+1
			lda	check_line,y
			cmp	#$01
			bne	c_bit_9
			sec
			rts

c_bit_9:		clc
			rts


check_hold:		dc.b	$00,$00
show_bits:		dc.b	8
check_line:		dc.b	0,0,0,0
			dc.b	0,0,0,0

driverror:
			pha
			jsr	printsi
			dc.b	$9b," Siov Error # ",$FF
			pla
			jsr	pr_byte
			jsr	printsi
			dc.b	$9b,-1
			rts



;
;
;
pr_byte:
			ldx	#$00
pr_card:
			sta	$d4
			stx	$d4+1
			lda	#$00
			sta	$f2
			jsr	$d9aa
			jsr	$d8e6
			ldy	#$00
.a:
			lda	($f3),y
			php
			and	#$7f
			iny
			jsr	echo
			plp
			bpl	.a
			rts
; 

;  this unifys the length string
;  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echos.unify:
			ldy	#0
			lda	(pr_ptr),y		;get length to print
			beq	.xpri     		;exit, null string
			sta	.maxlth
			iny
			sty	.tempy

			ldy	.tempy
			lda	(pr_ptr),y
			jsr	upcase
			sta	(pr_ptr),y
			jmp	.prnext

.pril:			ldy	.tempy
			cpy	#$02
			bcc	.prnext
			lda	(pr_ptr),y		; changing the bytes to lower case.
			jsr	locase
			sta	(pr_ptr),y

			cmp	#' '			; look for the space
			bne	.prnext
			inc	.tempy
			dec	.maxlth
			ldy	.tempy			
			lda	(pr_ptr),y		; make the char right after the space upper case
			jsr	upcase
			sta	(pr_ptr),y


.prnext:		inc	.tempy
			dec	.maxlth
			bne	.pril
.xpri:			rts

.tempy:			dc.b	1
.maxlth:		dc.b    1


;
;
upcase:			cmp	#'a'
			bcc	.xupcase
			cmp	#'z'+1
			beq	.xupcase
			bcs	.xupcase
			sec
			sbc	#32
.xupcase:		rts


locase:			cmp     #'A'
			bcc     .xlocase
			cmp     #'Z'+1
			beq     .xlocase
			bcs     .xlocase
			clc
			adc     #32
.xlocase:		rts




;
;  prints: prints string with address in PR_PTR, length byte in 0th byte
;  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

echos:
			ldy	#0
			lda	(pr_ptr),y		;get length to print
			beq	.xpri     		;exit, null string
			sta	.maxlth
			iny
			sty	.tempy

.pril:			ldy	.tempy
			lda	(pr_ptr),y
			cmp	#$00
			beq	.xpri
			jsr	echo
.prnext:		inc	.tempy
			dec	.maxlth
			bne	.pril
.xpri:			rts

.tempy:			dc.b	1
.maxlth:		dc.b    1

pr_mode:		dc.b	0


; 
;
;---------------------------
;this one make's a nice tone
;---------------------------
bell
			sta	.data
			sty	.data+1
			stx	.data+2
			ldy	#$af
			lda	#$14
			sta	$d200
.a:			sty	$d201
			lda	#$00
			sta	$14
.b:			lda	$14
			cmp	#$02
			bcc	.b
			dey
			cpy	#$a0
			bcs	.a
			lda	.data
			ldy	.data+1
			ldx	.data+2
			rts
.data:			dc.b	$00,$00,$00
;
;
;---------------------------------
;this make's inveres charter flash
;         FLASH MACRO             
;---------------------------------
;
;
flash:			pha
			pha
flash_1:	
;   lda	#$00
;   sta	$41
flash_loop4:		inc	flash_data
			lda	#$0a
			cmp	flash_data
			beq	flash_loop
;
			lda	#$00
			sta	$14
flash_loop3
			nop
			lda	#$01
			sta	$02f3
			lda	$14
			cmp	flash_data
			beq	flash_lppp
			bne	flash_loop3
flash_lppp:		lda	#$00
			sta	$14
flash_loop5:		nop
			lda	#$02
			sta	$02f3
			lda	$14
			cmp	flash_data+1
			beq	flash_loop4
			bne	flash_loop5
flash_loop
;  lda	#$00
;   sta	$41
			lda	#$00
			sta	$02f0
			pla
			pla
			lda	#$05
			sta	flash_data
			lda	#$0a
			sta	flash_data+1
			rts
flash_data:			dc.b	$05,$0a
; 
;--------------------------------------------
;printsi Routeen macro             
;this is a slow print to the screen
;usage jsr	printsi
;    .byte $9b," string to be printed",$ff
;--------------------------------------------
;
printsi:		pla
			sta	pstr+1
			pla
			sta	pstr+2
prsl:			inc	pstr+1
			bne	pstr
			inc	pstr+2
pstr:			lda	$ffff
			cmp	#$ff
			beq	estri
			jsr	fast_output
			jmp	prsl
estri:			lda	pstr+2
			pha
			lda	pstr+1
			pha
			rts
;
;	

;
;-------------------------
;actual screen handler    
;screen offset definitions
;-------------------------
scr_offset:		dc.w	0
			dc.w	40
			dc.w	80
			dc.w	120
			dc.w	160
			dc.w	200
			dc.w	240
			dc.w	280
			dc.w	320
			dc.w	360
			dc.w	400
			dc.w	440
			dc.w	480
			dc.w	520
			dc.w	560
			dc.w	600
			dc.w	640
			dc.w	680
			dc.w	720
			dc.w	760
			dc.w	800
			dc.w	840
			dc.w	880
			dc.w	920
;
echo:
fast_output:
			sta	$5a
			lda	sc.redirect
			cmp	#print_p
			beq	.go_cio
.leo:
			lda 	$02ff   	; CONTROL 1 FLAG
			cmp 	#$00
			bne 	.leo

			lda	$5a
			cmp	#32
			bcc	.do_look
			cmp	#125
			bcc	.do_here
.do_look:		ldy	#0
.lookup:		lda	.char_table,y
			beq	.do_here
			cmp	$5a
			beq	.go_cio
			iny
			bne	.lookup


.go_cio:		lda	$5a
			jmp	putlocal


.do_here:		ldy	#0
			lda	$5d
			sta	($5e),y
			lda	$5a
			cmp	#$9b
			beq	.docr
.notcr:			jsr	.get_adr
			lda	$5a
			and	#$7f
			cmp	#32
			bcc	.add64
			cmp	#96
			bcc	.sub32
			jmp	.asis
.add64:			clc
			adc	#64
			jmp	.asis
.sub32:			sec
			sbc	#32
.asis:			bit	$5a
			bpl	.xxlate
			ora	#$80
.xxlate:		ldy	#0
			sta	($5e),y
			inc	$55
			inc	$63
			lda	$55
			cmp	#40
			bcs	.next_row
			iny
			lda	($5e),y
			sta	$5d
			ora	#$80
			ldx	752
			bne	.nocurs1
			sta	($5e),y
.nocurs1:		inc	$5e
			bne	.nooav
			inc	$5e+1
.nooav:			rts
.docr:			lda	#0
			sta	$63
.next_row:		lda	$52
			sta	$55
			inc	$54
			ldy	$54
			cpy	#24
			bcs	.scroll
			jsr	.get_adr
			ldy	#0
			lda	($5e),y
			sta	$5d
			ldx	752
			bne	.nocurs2
			ora	#$80
			sta	($5e),y
.nocurs2:		rts

.scroll:		dec	$54
			lda	$58
			sta	$68
			clc
			adc	#40
			sta	$5e
			lda	$58+1
			sta	$68+1
			adc	#0
			sta	$5e+1
			ldy	#0
			ldx	#3
.scloop:		lda	($5e),y
			sta	($68),y
			iny
			bne	.scloop
			inc	$5e+1
			inc	$68+1
			dex
			bne	.scloop
.scloop2:		lda	($5e),y
			sta	($68),y
			iny
			cpy	#152
			bcc	.scloop2
			lda	$58
			clc
			adc	#920&$ff
			sta	$5e
			lda	$58+1
			adc	#920/256
			sta	$5e+1
			ldy	#0
			tya
.clear:			sta	($5e),y
			iny
			cpy	#40
			bcc	.clear
			ldx	752
			bne	.nocurs3
			lda	#$80
			ldy	$55
			sta	($5e),y
.nocurs3:		lda	#0
			sta	$5d
			lda	$5e
			clc
			adc	$55
			sta	$5e
			lda	$5e+1
			adc	#0
			sta	$5e+1
			rts
.get_adr:		lda	$54
			asl
			tay
			lda	$58
			clc
			adc	scr_offset,y
			sta	$5e
			lda	$58+1
			adc	scr_offset+1,y
			sta	$5e+1
			lda	$5e
			clc
			adc	$55
			sta	$5e
			lda	$5e+1
			adc	#0
			sta	$5e+1
			rts
.char_table:
			dc.b	27,28,29,30,31,125,126,127
			dc.b	156,157,158,159,253,254,255,0


putlocal:		ldx	#11
			stx	$0342
			ldx	#0
			stx	$0348
			stx	$0349
			jmp	$e456
;
;------------------------------
;   GET KEY  ROUTEEN           
;this routeen get's one key and
;return it to the accumlator   
;------------------------------
;
getkey:			stx	$b6
			sty	$b7
			jsr	.a
			ldx	$b6
			ldy	$b7
			rts
.a:			lda	$e420+5
			pha
			lda	$e420+4
			pha
			rts
;

;--------------
;  help menu section
;--------------
help_menu



			lda	#$7d
			jsr	echo
			jsr	begin_port-3

			jsr	printsi
;	                                  1111111111222222222233333333334
;	                         1234567890123456789012345678901234567890
			dc.b	"Display Joystick Port results With this",$9b	
			dc.b	"hardware box. Parts required for box",$9b,$9b
			dc.b	" 1  220 ohm Resister!",$9b
			dc.b	" 1  Project Box large enough for parts",$9b
			dc.b	" 8  LED's Color of you choice!",$9b
			dc.b    " 10 Momentary Pushbuttons Switchs.",$9b
			dc.b	" 1  9 pin Joystick Extension cable.",$9b
			dc.b	$9b,$9b,-1
			jsr	pause

			jsr	printsi
			dc.b	$7d
			dc.b	$9b
;	                                  1111111111222222222233333333334
;	                         1234567890123456789012345678901234567890

			dc.b	"Pin 7 = +5---/\/\/\/\----------------+",$9b
;			dc.b	"                                     |",$9b
			dc.b	"+3  N/C --+-+-+-+--+-+--+--+---------+",$9b
                        dc.b	"          | | | |  | |  |  |       ",$9b
			dc.b	"L Pin 8 --)-)-)-)--)-)--)--)------+",$9b
			dc.b	"          | | | |  | |  |  |  _+_ |",$9b
                        dc.b	"L Pin 1 --)-)-)-)--)-)--)--O--: :-+",$9b
			dc.b	"          | | | |  | |  |     _+_ |",$9b  
			dc.b	"L Pin 2 --)-)-)-)--)-)--O-----: :-+",$9b
			dc.b	"          | | | |  | |        _+_ |",$9b
                        dc.b	"L Pin 3 --)-)-)-)--)-O--------: :-+",$9b
			dc.b	"          | | | |  |          _+_ |",$9b  
			dc.b	"L Pin 4 --)-)-)-)--O----------: :-+",$9b
			dc.b	"          | | | |             _+_ |",$9b  
			dc.b	"L Pin 6 --)-)-)-)-------------: :-+",$9b
			dc.b	"          | | | |             _+_ |",$9b
                        dc.b	"R Pin 1 --)-)-)-O-------------: :-+",$9b
			dc.b	"          | | |               _+_ |",$9b  
			dc.b	"R Pin 2 --)-)-O---------------: :-+",$9b
			dc.b	"          | |                 _+_ |",$9b
                        dc.b	"R Pin 3 --)-O-----------------: :-+",$9b
			dc.b	"          |                   _+_ |",$9b  
			dc.b	"R Pin 4 --O-------------------: :-+",$9b
			dc.b	"                              _+_ |",$9b  
			dc.b	"R Pin 6 ----------------------: :-+",-1

			jsr	pause1
			jsr	printsi
			dc.b	$7d
			dc.b	$9b

                        dc.b	"Atari Joystick Port Pins and Functions",$9b
                        dc.b	"    Left Port:         Right Port:",$9b
                        dc.b	"======================================",$9b
                        dc.b	"__________________ ___________________",$9b
                        dc.b	"\  1  2  3  4  5 / \   1  2  3  4  5 /",$9b
                        dc.b	" \              /   \               / ",$9b
                        dc.b	"  \ 6  7  8  9 /     \  6  7  8  9 /  ",$9b
                        dc.b	"   \          /       \           /   ",$9b
                        dc.b	"    ----------         -----------    ",$9b
                        dc.b	"======================================",$9b
                        dc.b	"Pin #1 = (joystick) forward input",$9b
                        dc.b	"2 = (joystick) back input",$9b
                        dc.b	"3 = (joystick) left input",$9b
                        dc.b	"4 = (joystick) right input",$9b
                        dc.b	"5 = "
			dc.b	$22
			dc.b	"B"
			dc.b	$22
			dc.b	" potentiometer input",$9b
                        dc.b	"6 = trigger input",$9b
                        dc.b	"7 = +5 volts",$9b
                        dc.b	"8 = ground",$9b
                        dc.b	"9 = "
			dc.b	$22
			dc.b	"A"
			dc.b	$22
			dc.b	" potentiometer input",$9b
			dc.b	$9b
			dc.b	-1


			jsr	pause
			jsr	printsi

			dc.b	" Schematics Ledge",$9b
			dc.b	"                              _+_ |   ",$9b  
			dc.b	"Momentary Pushbutton Switch---: :-+   ",$9b
			dc.b	"                                   |  ",$9b  
			dc.b	"Led      -->|--                ----O  ",$9b
			dc.b	"                                      ",$9b  
			dc.b	"Resister ---/\/\/\/\---- 220 ohm      ",$9b
			dc.b	$9b,$9b,-1

			jsr	pause
			jsr	printsi

			dc.b	$9b," Should a company wish to use this",$9b
			dc.b	" I will provide a site license for a",$9b 
			dc.b	" cost $100.00 US Dollars.",$9b 
			dc.b	" Atari user or usergroups",$9b
			dc.b	" may use it FREE of charge for there",$9b 
			dc.b	" BBS Systems",$9b,-1
			jsr	pause
			jsr	printsi
			dc.b	$9b,$9b
			dc.b	" if you wish to have the source",$9B
			dc.b	" code then contact:",$9B,$9B
			dc.b	"       Stephen J. Carden",$9B
			dc.b	"       3321 Jonathan Cir.",$9B
			dc.b	"       Augusta, Ga. 30906",$9B
			dc.b	"       sjcarden@bellsouth.net",$9B,$9b
;
			dc.b	" or send a donation of $20.00US to",$9b 
			dc.b	"the above address.",$9B,$FF
			jsr	printsi
			dc.b	$9b,$9b
			dc.b	" Press "
			dc.b	<+128>,"[Return]"
			dc.b	" for Dos, any other key ",$9B
			dc.b	" to continue with this file",$9B,$FF
			jsr	getkey
			cmp	#$9b
			bne	help2
			rts

help2:
			lda	#$7d
			jsr	echo
			jsr	begin_port-3
			jmp	top
;
pause:   			;           a more command
			jsr	printsi
			dc.b	<+128>,"[ -More- ]" 
			dc.b	  -1
			jsr	getkey
			jsr	printsi
			dc.b	"~~~~~~~~~~~~~",$FF
			rts
pause1:   			;           a more command
			jsr	printsi
			dc.b	<+128>,"[M]" 
			dc.b	  -1
			jsr	getkey
			jsr	printsi
			dc.b	"~~~",$FF
			rts



win_end:		ds.b	0
;
;
;





