2009-07-17 22:10:19 +00:00
|
|
|
;telnet routines
|
|
|
|
; to use:
|
|
|
|
; 1) include this file
|
|
|
|
; 2) include these other files:
|
|
|
|
; .include "../inc/common.i"
|
|
|
|
; .include "../inc/commonprint.i"
|
|
|
|
; .include "../inc/net.i"
|
|
|
|
; 3) define a routine called 'exit_telnet'
|
2009-07-30 10:43:37 +00:00
|
|
|
|
|
|
|
.import telnet_connect
|
|
|
|
.import telnet_local_echo
|
|
|
|
.import telnet_line_mode
|
|
|
|
.import telnet_use_native_charset
|
|
|
|
.import telnet_port
|
|
|
|
.import telnet_ip
|
|
|
|
|
|
|
|
|
2009-07-17 22:10:19 +00:00
|
|
|
.code
|
|
|
|
telnet_main_entry:
|
|
|
|
;prompt for a hostname, then resolve to an IP address
|
|
|
|
|
|
|
|
ldax #remote_host
|
|
|
|
jsr print
|
2009-09-22 09:49:37 +00:00
|
|
|
kippercall #KPR_INPUT_HOSTNAME
|
2009-07-17 22:10:19 +00:00
|
|
|
bcc @host_entered
|
|
|
|
;if no host entered, then bail.
|
|
|
|
jmp exit_telnet
|
|
|
|
@host_entered:
|
2009-09-22 09:49:37 +00:00
|
|
|
stax kipper_param_buffer
|
2009-07-17 22:10:19 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #resolving
|
|
|
|
jsr print
|
2009-09-22 09:49:37 +00:00
|
|
|
ldax kipper_param_buffer
|
|
|
|
kippercall #KPR_PRINT_ASCIIZ
|
2009-07-17 22:10:19 +00:00
|
|
|
jsr print_cr
|
2009-09-22 09:49:37 +00:00
|
|
|
ldax #kipper_param_buffer
|
|
|
|
kippercall #KPR_DNS_RESOLVE
|
2009-07-17 22:10:19 +00:00
|
|
|
bcc @resolved_ok
|
|
|
|
print_failed
|
|
|
|
jsr print_cr
|
|
|
|
jsr print_errorcode
|
|
|
|
jmp telnet_main_entry
|
|
|
|
@resolved_ok:
|
|
|
|
ldx #3
|
|
|
|
@copy_telnet_ip_loop:
|
2009-09-22 09:49:37 +00:00
|
|
|
lda kipper_param_buffer,x
|
2009-07-17 22:10:19 +00:00
|
|
|
sta telnet_ip,x
|
|
|
|
dex
|
|
|
|
bpl @copy_telnet_ip_loop
|
|
|
|
@get_port:
|
|
|
|
ldax #remote_port
|
|
|
|
jsr print
|
2009-09-22 09:49:37 +00:00
|
|
|
kippercall #KPR_INPUT_PORT_NUMBER
|
2009-07-17 22:10:19 +00:00
|
|
|
bcc @port_entered
|
|
|
|
;if no port entered, then assume port 23
|
|
|
|
ldax #23
|
|
|
|
@port_entered:
|
|
|
|
stax telnet_port
|
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
ldax #char_mode_prompt
|
|
|
|
jsr print
|
|
|
|
@char_mode_input:
|
|
|
|
jsr get_key
|
|
|
|
cmp #'A'
|
|
|
|
beq @ascii_mode
|
|
|
|
cmp #'a'
|
|
|
|
beq @ascii_mode
|
|
|
|
|
|
|
|
cmp #'P'
|
|
|
|
beq @petscii_mode
|
|
|
|
cmp #'p'
|
|
|
|
beq @petscii_mode
|
2009-07-24 07:01:59 +00:00
|
|
|
|
|
|
|
cmp #'l'
|
|
|
|
beq @line_mode
|
|
|
|
cmp #'L'
|
|
|
|
beq @line_mode
|
|
|
|
|
2009-07-17 22:10:19 +00:00
|
|
|
jmp @char_mode_input
|
|
|
|
@ascii_mode:
|
|
|
|
lda #0
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_use_native_charset
|
|
|
|
sta telnet_line_mode
|
2009-07-24 00:17:41 +00:00
|
|
|
lda #1
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_local_echo
|
2009-07-24 00:17:41 +00:00
|
|
|
jmp @after_mode_set
|
2009-07-17 22:10:19 +00:00
|
|
|
@petscii_mode:
|
|
|
|
lda #1
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_use_native_charset
|
2009-07-24 00:17:41 +00:00
|
|
|
lda #0
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_local_echo
|
|
|
|
sta telnet_line_mode
|
2009-07-24 07:01:59 +00:00
|
|
|
jmp @after_mode_set
|
|
|
|
@line_mode:
|
|
|
|
lda #0
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_use_native_charset
|
2009-07-24 07:01:59 +00:00
|
|
|
lda #1
|
2009-07-30 10:43:37 +00:00
|
|
|
sta telnet_local_echo
|
|
|
|
sta telnet_line_mode
|
2009-07-24 00:17:41 +00:00
|
|
|
|
|
|
|
@after_mode_set:
|
|
|
|
|
2009-07-17 22:10:19 +00:00
|
|
|
lda #147 ; 'CLR/HOME'
|
|
|
|
jsr print_a
|
|
|
|
|
|
|
|
ldax #connecting_in
|
|
|
|
jsr print
|
2009-07-30 10:43:37 +00:00
|
|
|
lda telnet_use_native_charset
|
2009-07-17 22:10:19 +00:00
|
|
|
beq @a_mode
|
|
|
|
ldax #petscii
|
|
|
|
jmp @c_mode
|
|
|
|
@a_mode:
|
2009-07-30 10:43:37 +00:00
|
|
|
lda telnet_line_mode
|
2009-07-24 07:01:59 +00:00
|
|
|
bne @l_mode
|
|
|
|
ldax #ascii
|
|
|
|
jmp @c_mode
|
|
|
|
@l_mode:
|
|
|
|
ldax #line
|
2009-07-17 22:10:19 +00:00
|
|
|
@c_mode:
|
2009-07-24 07:01:59 +00:00
|
|
|
jsr print
|
2009-07-17 22:10:19 +00:00
|
|
|
ldax #mode
|
|
|
|
jsr print
|
2009-07-30 10:43:37 +00:00
|
|
|
jsr telnet_connect
|
|
|
|
jmp telnet_main_entry
|
2009-07-17 22:10:19 +00:00
|
|
|
|
|
|
|
;constants
|
|
|
|
connecting_in: .byte "CONNECTING IN ",0
|
|
|
|
ascii: .byte "ASCII",0
|
|
|
|
petscii: .byte "PETSCII",0
|
2009-07-24 07:01:59 +00:00
|
|
|
line: .byte "LINE",0
|
2009-07-17 22:10:19 +00:00
|
|
|
mode: .byte " MODE",13,0
|
|
|
|
remote_host: .byte "HOSTNAME (LEAVE BLANK TO QUIT)",13,": ",0
|
|
|
|
remote_port: .byte "PORT # (LEAVE BLANK FOR DEFAULT)",13,": ",0
|
2009-07-24 07:01:59 +00:00
|
|
|
char_mode_prompt: .byte "MODE - A=ASCII, P=PETSCII, L=LINE",13,0
|
2009-07-17 22:10:19 +00:00
|
|
|
|