changeset 2286:d3c1d1258b42

Updated from Aaron's sources
author boisy
date Tue, 29 Dec 2009 02:34:05 +0000
parents 7948792bbab8
children e49532f2c754
files level1/cmds/chat.asm level1/cmds/dw.asm level1/cmds/ftp.asm level1/cmds/wget.asm
diffstat 4 files changed, 116 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/level1/cmds/chat.asm	Tue Dec 29 02:06:49 2009 +0000
+++ b/level1/cmds/chat.asm	Tue Dec 29 02:34:05 2009 +0000
@@ -29,9 +29,6 @@
 name        fcs     /chat/
            fcb     edition
 
-int			fcs		/int/
-	
-
 ******************************************			
 * writech - write character in A to screen
 * In:
@@ -86,43 +83,7 @@
 			lbcs	errex2
 			rts
 
-			* ask for next open port
-getport		leax	<int,pc
-			bsr		wrname
-			* send it twice for arg
-			leax	<int,pc
-			bsr		wrname
-			* read response
-			ldy		#0006
-			lda		portpath,u
-			leax	pbuffer,u
-			os9		I$Read
-			lbcs	errex2
-			lda		pbuffer,u
-			lbeq		errex2			; no ports left
-			* close /t0
-			lda		portpath,u
-			os9		I$Close
-			lbcs	errex2
-			
-			* write port name
-			lda	#4
-			sta	numbyt,u
-			bsr	writepb
-			* open given port
-			lda   	#UPDAT.      		get mode for modem path
-			leax	pbuffer,u    	point to modem path
-			os9   	I$Open      	open it
-			lbcs  	errex1        	If error, exit with it
-			sta		portpath,u		;set our working port
-			rts
-
-* use /t0 to get next available util port	
-defport  	fcc   '/t0'
-        	fcb   C$CR
-        	fcb   $00,$00
-
-chat		fcs		'chat'			
+	
         	
 			
            * save initial parameters
@@ -134,19 +95,45 @@
 			sta		outpath,u
 			
 			
-			* open /t0 first to get working port
+			* see if we can find a port to use
 			
-			lda   #UPDAT.      		get mode for modem path
-			leax	<defport,pc    	point to modem path
+			* first setup pbuffer
+			leax 	pbuffer,u
+			lda		#47
+			sta		,x+
+			lda		#85
+			sta		,x+
+			lda		#48
+			sta		,x+
+			lda		#13
+			sta		,x
+						
+tryport		lda   #UPDAT.      		get mode for modem path
+			leax	pbuffer,u    	point to modem path
 			os9   	I$Open      	open it
-			lbcs  	errex1        	If error, exit with it
-			sta		portpath,u
+			bcc		gotport		
 			
-			bsr		getport			;find open utility port
+			cmpb	#250		;in use?
+			lbne	errex1		;other error, bail out
+			leax	pbuffer,u
+			lda		2,x
+			inca
+			sta		2,x
+			bra		tryport
+		
+chat		fcs		'chat'				
 			
+gotport		sta		portpath,u
+				
+			*print out port we got
+			lda		#4
+			sta		numbyt,u
+			leax	pbuffer,u
+			lbsr		writepb
+						
 			* at this point we should have a port
 			leax		chat,pc
-			lbsr		wrname			;write our name to server
+			lbsr		wrname			;write our command to server
 		
 			* write parameters to port - X = start addr, y = # bytes, A = path#
 			
--- a/level1/cmds/dw.asm	Tue Dec 29 02:06:49 2009 +0000
+++ b/level1/cmds/dw.asm	Tue Dec 29 02:34:05 2009 +0000
@@ -68,14 +68,35 @@
 			pshs	d
 			pshs	x
 			
-			* open port
+			* see if we can find a port to use
 			
-			lda   #UPDAT.      get mode for modem path
-			leax	<defport,pc    point to modem path
-			os9   I$Open       open it
-			lbcs  errex1        If error, exit with it
-			sta   portpath,u    save path to modem
+			* first setup pbuffer
+			leax 	pbuffer,u
+			lda		#47
+			sta		,x+
+			lda		#85
+			sta		,x+
+			lda		#48
+			sta		,x+
+			lda		#13
+			sta		,x
+						
+tryport		lda   #UPDAT.      		get mode for modem path
+			leax	pbuffer,u    	point to modem path
+			os9   	I$Open      	open it
+			bcc		gotport		
 			
+			cmpb	#250		;in use?
+			lbne	errex1		;other error, bail out
+			leax	pbuffer,u
+			lda		2,x
+			inca
+			sta		2,x
+			bra		tryport
+
+gotport		sta		portpath,u
+				
+		
 			* write our name
 			ldy		#0001
 			leax	<name,pc
--- a/level1/cmds/ftp.asm	Tue Dec 29 02:06:49 2009 +0000
+++ b/level1/cmds/ftp.asm	Tue Dec 29 02:34:05 2009 +0000
@@ -60,10 +60,6 @@
 * dw main
 *
 
-* default to port /t0.. and use it no matter what, maybe set on cmdline in future?	
-defport  	fcc   '/t0'
-         	fcb   C$CR
-         	fcb   $00,$00               
 
          	
 wrname		ldy		#0001
@@ -101,14 +97,36 @@
 			sta		outpath,u
 			
 			
-			* open port
+			* see if we can find a port to use
 			
-			lda   #UPDAT.      get mode for modem path
-			leax	<defport,pc    point to modem path
-			os9   I$Open       open it
-			lbcs  errex1        If error, exit with it
-			sta   portpath,u    save path to modem
+			* first setup pbuffer
+			leax 	pbuffer,u
+			lda		#47
+			sta		,x+
+			lda		#85
+			sta		,x+
+			lda		#48
+			sta		,x+
+			lda		#13
+			sta		,x
+						
+tryport		lda   #UPDAT.      		get mode for modem path
+			leax	pbuffer,u    	point to modem path
+			os9   	I$Open      	open it
+			bcc		gotport		
 			
+			cmpb	#250		;in use?
+			lbne	errex1		;other error, bail out
+			leax	pbuffer,u
+			lda		2,x
+			inca
+			sta		2,x
+			bra		tryport
+		
+chat		fcs		'chat'				
+			
+gotport		sta		portpath,u
+							
 			bsr		wrname			;write our name to server
 		
 			* write parameters to port - X = start addr, y = # bytes, A = path#
--- a/level1/cmds/wget.asm	Tue Dec 29 02:06:49 2009 +0000
+++ b/level1/cmds/wget.asm	Tue Dec 29 02:34:05 2009 +0000
@@ -57,9 +57,6 @@
 *
 
 * default to port /t0.. and use it no matter what, maybe set on cmdline in future?	
-defport  	fcc   '/t0'
-         	fcb   C$CR
-         	fcb   $00,$00               
 
             * initialization/startup?
 start      nop
@@ -67,14 +64,34 @@
 			* save parameters for later
 			pshs	d
 			pshs	x
-			
-			* open port
+
+			* see if we can find a port to use
 			
-			lda   #UPDAT.      get mode for modem path
-			leax	<defport,pc    point to modem path
-			os9   I$Open       open it
-			lbcs  errex1        If error, exit with it
-			sta   portpath,u    save path to modem
+			* first setup pbuffer
+			leax 	pbuffer,u
+			lda		#47
+			sta		,x+
+			lda		#85
+			sta		,x+
+			lda		#48
+			sta		,x+
+			lda		#13
+			sta		,x
+						
+tryport		lda   #UPDAT.      		get mode for modem path
+			leax	pbuffer,u    	point to modem path
+			os9   	I$Open      	open it
+			bcc		gotport		
+			
+			cmpb	#250		;in use?
+			lbne	errex1		;other error, bail out
+			leax	pbuffer,u
+			lda		2,x
+			inca
+			sta		2,x
+			bra		tryport
+			
+gotport		sta		portpath,u
 			
 			* write our name
 			ldy		#0001