2009-07-17 02:53:46 +00:00
|
|
|
; C64 gopher browser
|
|
|
|
; july 2009 - jonno @ jamtronix.com
|
|
|
|
; this contains the key gopher rendering routines
|
|
|
|
; to use:
|
|
|
|
; 1) include this file
|
|
|
|
; 2) include these other files:
|
|
|
|
; .include "../inc/common.i"
|
|
|
|
; .include "../inc/commonprint.i"
|
|
|
|
; .include "../inc/net.i"
|
|
|
|
; .include "../inc/char_conv.i"
|
|
|
|
; .include "../inc/c64keycodes.i"
|
|
|
|
; 3) define a routine called 'exit_gopher'
|
|
|
|
|
2009-10-27 10:51:28 +00:00
|
|
|
|
2009-07-10 09:24:42 +00:00
|
|
|
.import get_key_if_available
|
2009-07-05 05:55:00 +00:00
|
|
|
.import mul_8_16
|
|
|
|
.importzp acc16
|
2009-07-05 10:17:38 +00:00
|
|
|
.importzp copy_src
|
|
|
|
.importzp copy_dest
|
|
|
|
.import copymem
|
2009-07-30 10:43:37 +00:00
|
|
|
.import ascii_to_native
|
2009-07-10 06:32:49 +00:00
|
|
|
.import dns_ip
|
|
|
|
.import dns_resolve
|
|
|
|
.import dns_set_hostname
|
|
|
|
.import ip65_error
|
2009-07-05 10:17:38 +00:00
|
|
|
.import cls
|
2009-07-10 06:32:49 +00:00
|
|
|
.import get_filtered_input
|
|
|
|
.import filter_dns
|
2009-07-18 13:24:52 +00:00
|
|
|
.import filter_text
|
2009-07-31 14:50:02 +00:00
|
|
|
.importzp screen_current_row
|
|
|
|
.importzp screen_current_col
|
|
|
|
.import print_a_inverse
|
2009-08-02 08:49:38 +00:00
|
|
|
|
|
|
|
.import telnet_port
|
|
|
|
.import telnet_ip
|
|
|
|
.import telnet_connect
|
|
|
|
.import telnet_use_native_charset
|
2009-08-25 03:17:55 +00:00
|
|
|
|
|
|
|
.import url_ip
|
|
|
|
.import url_port
|
|
|
|
.import url_selector
|
|
|
|
.import url_resource_type
|
|
|
|
.import url_parse
|
|
|
|
.import url_download
|
|
|
|
.import url_download_buffer
|
|
|
|
.import url_download_buffer_length
|
|
|
|
.import resource_download
|
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
.segment "IP65ZP" : zeropage
|
|
|
|
|
|
|
|
; pointer for moving through buffers
|
|
|
|
buffer_ptr: .res 2 ; source pointer
|
2009-07-17 02:53:46 +00:00
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
.data
|
|
|
|
get_next_byte:
|
|
|
|
lda $ffff
|
|
|
|
inc get_next_byte+1
|
|
|
|
bne :+
|
|
|
|
inc get_next_byte+2
|
|
|
|
:
|
|
|
|
rts
|
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
|
|
|
|
current_resource_history_entry: .byte 0
|
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
.segment "APP_SCRATCH"
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
DISPLAY_LINES=22
|
2009-07-04 13:52:04 +00:00
|
|
|
page_counter: .res 1
|
2009-07-05 05:55:00 +00:00
|
|
|
MAX_PAGES = 50
|
2009-07-04 13:52:04 +00:00
|
|
|
page_pointer_lo: .res MAX_PAGES
|
|
|
|
page_pointer_hi: .res MAX_PAGES
|
|
|
|
|
|
|
|
resource_counter: .res 1
|
2009-07-05 10:17:38 +00:00
|
|
|
MAX_RESOURCES = DISPLAY_LINES
|
2009-07-04 13:52:04 +00:00
|
|
|
|
|
|
|
resource_pointer_lo: .res MAX_RESOURCES
|
|
|
|
resource_pointer_hi: .res MAX_RESOURCES
|
|
|
|
resource_type: .res MAX_RESOURCES
|
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
download_flag: .res 1
|
|
|
|
dl_loop_counter: .res 2
|
2009-07-04 13:52:04 +00:00
|
|
|
this_is_last_page: .res 1
|
|
|
|
|
2009-08-25 03:17:55 +00:00
|
|
|
|
2009-12-06 06:24:18 +00:00
|
|
|
;temp_ax: .res 2
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
RESOURCE_HOSTNAME_MAX_LENGTH=64
|
2009-07-05 10:17:38 +00:00
|
|
|
current_resource:
|
2009-07-10 06:32:49 +00:00
|
|
|
resource_hostname: .res RESOURCE_HOSTNAME_MAX_LENGTH
|
2009-07-05 10:17:38 +00:00
|
|
|
resource_port: .res 2
|
2009-07-18 13:24:52 +00:00
|
|
|
resource_selector: .res 128
|
2009-07-10 06:32:49 +00:00
|
|
|
resource_selector_length: .res 1
|
2009-07-17 02:53:46 +00:00
|
|
|
displayed_resource_type: .res 1
|
2009-08-25 03:17:55 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
RESOURCE_HISTORY_ENTRIES=8
|
|
|
|
resource_history:
|
|
|
|
.res $100*RESOURCE_HISTORY_ENTRIES
|
|
|
|
|
2010-07-30 05:21:58 +00:00
|
|
|
scratch_buffer_length=GOPHER_BUFFER_SIZE
|
2009-07-17 13:10:44 +00:00
|
|
|
scratch_buffer:
|
2009-08-25 03:17:55 +00:00
|
|
|
.res scratch_buffer_length
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
.code
|
2009-07-10 06:32:49 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
;display whatever is in the buffer either as plain text or gopher text
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
display_resource_in_buffer:
|
2009-07-17 13:10:44 +00:00
|
|
|
ldax #scratch_buffer
|
2009-07-04 13:52:04 +00:00
|
|
|
stax get_next_byte+1
|
|
|
|
|
|
|
|
lda #0
|
2009-07-05 05:55:00 +00:00
|
|
|
sta page_counter
|
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
@do_one_page:
|
2009-07-05 10:17:38 +00:00
|
|
|
jsr cls
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-09 23:43:47 +00:00
|
|
|
; ldax #page_header
|
|
|
|
; jsr print
|
|
|
|
; lda page_counter
|
|
|
|
; jsr print_hex
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
; jsr print_resource_description
|
2009-07-04 13:52:04 +00:00
|
|
|
ldx page_counter
|
|
|
|
lda get_next_byte+1
|
2009-07-05 05:55:00 +00:00
|
|
|
sta page_pointer_lo,x
|
2009-07-04 13:52:04 +00:00
|
|
|
lda get_next_byte+2
|
2009-07-05 05:55:00 +00:00
|
|
|
sta page_pointer_hi,x
|
2009-07-04 13:52:04 +00:00
|
|
|
inc page_counter
|
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
|
|
|
|
lda displayed_resource_type
|
|
|
|
cmp #'0'
|
|
|
|
bne @displayed_resource_is_directory
|
|
|
|
|
|
|
|
;if this is a text file, just convert ascii->petscii and print to screen
|
|
|
|
@show_one_char:
|
|
|
|
jsr get_next_byte
|
2009-07-30 10:43:37 +00:00
|
|
|
tax ;this sets Z flag
|
2009-07-17 02:53:46 +00:00
|
|
|
bne :+
|
|
|
|
lda #1
|
|
|
|
sta this_is_last_page
|
|
|
|
jmp @get_keypress
|
|
|
|
:
|
|
|
|
|
2009-07-30 10:43:37 +00:00
|
|
|
jsr ascii_to_native
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr print_a
|
2009-07-31 14:50:02 +00:00
|
|
|
lda screen_current_row
|
2009-07-17 02:53:46 +00:00
|
|
|
cmp #DISPLAY_LINES
|
|
|
|
bmi @show_one_char
|
|
|
|
jmp @end_of_current_page
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
@displayed_resource_is_directory:
|
2010-07-30 05:21:58 +00:00
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
lda #0
|
|
|
|
sta resource_counter
|
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
@next_line:
|
|
|
|
jsr get_next_byte
|
2009-07-18 13:24:52 +00:00
|
|
|
cmp #0
|
|
|
|
beq @last_line
|
2009-07-04 13:52:04 +00:00
|
|
|
cmp #'.'
|
|
|
|
bne @not_last_line
|
2009-07-18 13:24:52 +00:00
|
|
|
@last_line:
|
2009-07-04 13:52:04 +00:00
|
|
|
lda #1
|
|
|
|
sta this_is_last_page
|
|
|
|
jmp @done
|
|
|
|
@not_last_line:
|
|
|
|
cmp #'i'
|
|
|
|
beq @info_line
|
|
|
|
cmp #'0'
|
|
|
|
beq @standard_resource
|
|
|
|
cmp #'1'
|
|
|
|
beq @standard_resource
|
2009-07-18 13:24:52 +00:00
|
|
|
cmp #'7'
|
|
|
|
beq @standard_resource
|
2009-08-02 08:49:38 +00:00
|
|
|
cmp #'8'
|
|
|
|
beq @standard_resource
|
2009-07-04 13:52:04 +00:00
|
|
|
|
|
|
|
;if we got here, we know not what it is
|
|
|
|
jmp @skip_to_end_of_line
|
|
|
|
@standard_resource:
|
2009-07-17 02:53:46 +00:00
|
|
|
pha
|
2009-07-04 13:52:04 +00:00
|
|
|
ldx resource_counter
|
|
|
|
sta resource_type,x
|
2009-07-05 05:55:00 +00:00
|
|
|
sec
|
2009-07-04 13:52:04 +00:00
|
|
|
lda get_next_byte+1
|
2009-07-05 05:55:00 +00:00
|
|
|
sbc #1 ;since "get_next_byte" did the inc, we need to backtrack 1 byte
|
2009-07-04 13:52:04 +00:00
|
|
|
sta resource_pointer_lo,x
|
|
|
|
lda get_next_byte+2
|
2009-07-05 05:55:00 +00:00
|
|
|
sbc #0 ;in case there was an overflow on the low byte
|
2009-07-04 13:52:04 +00:00
|
|
|
sta resource_pointer_hi,x
|
|
|
|
inc resource_counter
|
2009-07-17 02:53:46 +00:00
|
|
|
|
2009-07-31 14:50:02 +00:00
|
|
|
lda screen_current_col ;are we at the start of the current line?
|
|
|
|
beq :+
|
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
jsr print_cr
|
|
|
|
:
|
2009-07-17 02:53:46 +00:00
|
|
|
pla ;get back the resource type
|
2009-07-31 14:50:02 +00:00
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
lda resource_counter
|
|
|
|
clc
|
|
|
|
adc #'a'-1
|
2009-07-31 14:50:02 +00:00
|
|
|
jsr print_a_inverse
|
2009-07-04 13:52:04 +00:00
|
|
|
lda #' '
|
|
|
|
jsr print_a
|
|
|
|
|
|
|
|
@info_line:
|
|
|
|
@print_until_tab:
|
|
|
|
@next_byte:
|
|
|
|
jsr get_next_byte
|
2010-07-30 05:21:58 +00:00
|
|
|
cmp #0
|
|
|
|
beq @last_line
|
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
cmp #$09
|
|
|
|
beq @skip_to_end_of_line
|
2009-07-30 10:43:37 +00:00
|
|
|
jsr ascii_to_native
|
2009-07-04 13:52:04 +00:00
|
|
|
jsr print_a
|
|
|
|
jmp @next_byte
|
|
|
|
|
|
|
|
@skip_to_end_of_line:
|
|
|
|
jsr get_next_byte
|
2009-08-02 08:49:38 +00:00
|
|
|
cmp #0
|
|
|
|
beq @last_line
|
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
cmp #$0A
|
|
|
|
bne @skip_to_end_of_line
|
2009-07-31 14:50:02 +00:00
|
|
|
|
|
|
|
lda screen_current_col
|
2009-07-04 13:52:04 +00:00
|
|
|
cmp #0
|
2009-08-25 03:17:55 +00:00
|
|
|
beq :+
|
2009-07-04 13:52:04 +00:00
|
|
|
jsr print_cr
|
|
|
|
:
|
2009-07-31 14:50:02 +00:00
|
|
|
lda screen_current_row
|
2009-07-05 05:55:00 +00:00
|
|
|
cmp #DISPLAY_LINES
|
2009-07-17 02:53:46 +00:00
|
|
|
bpl @end_of_current_page
|
|
|
|
jmp @next_line
|
|
|
|
|
|
|
|
@end_of_current_page:
|
2009-07-04 13:52:04 +00:00
|
|
|
lda #0
|
|
|
|
sta this_is_last_page
|
|
|
|
@done:
|
2009-07-05 05:55:00 +00:00
|
|
|
@get_keypress:
|
2009-07-10 09:24:42 +00:00
|
|
|
jsr ip65_process ;keep polling the network, so we respond to arps/pings/late packets etc etc
|
|
|
|
jsr get_key_if_available
|
2009-07-05 05:55:00 +00:00
|
|
|
cmp #' '
|
|
|
|
beq @go_next_page
|
2009-07-31 14:50:02 +00:00
|
|
|
cmp #KEY_NEXT_PAGE
|
2009-07-05 05:55:00 +00:00
|
|
|
beq @go_next_page
|
|
|
|
cmp #KEYCODE_DOWN
|
|
|
|
beq @go_next_page
|
2009-07-31 14:50:02 +00:00
|
|
|
cmp #KEY_PREV_PAGE
|
2009-07-05 05:55:00 +00:00
|
|
|
beq @go_prev_page
|
|
|
|
cmp #KEYCODE_UP
|
|
|
|
beq @go_prev_page
|
2009-07-31 14:50:02 +00:00
|
|
|
cmp #KEY_SHOW_HISTORY
|
2009-07-05 10:17:38 +00:00
|
|
|
beq @show_history
|
2009-07-05 10:42:48 +00:00
|
|
|
cmp #KEYCODE_LEFT
|
|
|
|
beq @back_in_history
|
2009-07-31 14:50:02 +00:00
|
|
|
cmp #KEY_BACK_IN_HISTORY
|
2009-07-05 10:42:48 +00:00
|
|
|
beq @back_in_history
|
2009-07-31 14:50:02 +00:00
|
|
|
cmp #KEY_NEW_SERVER
|
2009-07-17 02:53:46 +00:00
|
|
|
beq @prompt_for_new_server
|
|
|
|
|
|
|
|
cmp #KEYCODE_ABORT
|
2009-07-05 05:55:00 +00:00
|
|
|
beq @quit
|
|
|
|
;if fallen through we don't know what the keypress means, go get another one
|
|
|
|
and #$7f ;turn off the high bit
|
|
|
|
sec
|
|
|
|
sbc #$40
|
|
|
|
bmi @not_a_resource
|
|
|
|
cmp resource_counter
|
|
|
|
beq @valid_resource
|
|
|
|
bcs @not_a_resource
|
|
|
|
@valid_resource:
|
|
|
|
tax
|
|
|
|
dex
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr select_resource_from_current_directory
|
2009-07-05 05:55:00 +00:00
|
|
|
@not_a_resource:
|
|
|
|
jmp @get_keypress
|
2009-07-05 10:42:48 +00:00
|
|
|
@back_in_history:
|
|
|
|
ldx current_resource_history_entry
|
|
|
|
dex
|
|
|
|
beq @get_keypress ;if we were already at start of history, can't go back any further
|
|
|
|
stx current_resource_history_entry
|
|
|
|
txa
|
|
|
|
jsr load_resource_from_history
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr load_resource_into_buffer
|
|
|
|
jmp display_resource_in_buffer
|
2009-07-05 10:17:38 +00:00
|
|
|
@show_history:
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr show_history
|
|
|
|
jmp display_resource_in_buffer
|
2009-07-05 05:55:00 +00:00
|
|
|
@go_next_page:
|
2009-07-04 13:52:04 +00:00
|
|
|
lda this_is_last_page
|
2009-07-05 05:55:00 +00:00
|
|
|
bne @get_keypress
|
|
|
|
jmp @do_one_page
|
2009-07-17 02:53:46 +00:00
|
|
|
@prompt_for_new_server:
|
|
|
|
jsr prompt_for_gopher_resource ;that routine only returns if no server was entered.
|
|
|
|
jmp display_resource_in_buffer
|
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
@quit:
|
2009-07-17 02:53:46 +00:00
|
|
|
jmp exit_gopher
|
2009-07-05 05:55:00 +00:00
|
|
|
@go_prev_page:
|
|
|
|
ldx page_counter
|
|
|
|
dex
|
|
|
|
bne @not_first_page
|
|
|
|
jmp @get_keypress
|
|
|
|
@not_first_page:
|
|
|
|
dex
|
|
|
|
dec page_counter
|
|
|
|
dec page_counter
|
|
|
|
|
|
|
|
lda page_pointer_lo,x
|
|
|
|
sta get_next_byte+1
|
|
|
|
lda page_pointer_hi,x
|
|
|
|
sta get_next_byte+2
|
2009-07-04 13:52:04 +00:00
|
|
|
jmp @do_one_page
|
2009-07-05 05:55:00 +00:00
|
|
|
|
|
|
|
;get a gopher resource
|
|
|
|
;X should be the selected resource number
|
|
|
|
;the resources selected should be loaded into resource_pointer_*
|
2009-07-17 02:53:46 +00:00
|
|
|
select_resource_from_current_directory:
|
2009-07-05 05:55:00 +00:00
|
|
|
lda resource_pointer_lo,x
|
|
|
|
sta buffer_ptr
|
|
|
|
lda resource_pointer_hi,x
|
|
|
|
sta buffer_ptr+1
|
|
|
|
ldy #0
|
|
|
|
ldx #0
|
2009-07-17 02:53:46 +00:00
|
|
|
|
|
|
|
lda (buffer_ptr),y
|
|
|
|
sta displayed_resource_type
|
2009-07-18 13:24:52 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
@skip_to_next_tab:
|
|
|
|
iny
|
|
|
|
beq @done_skipping_over_tab
|
|
|
|
lda (buffer_ptr),y
|
|
|
|
cmp #$09
|
|
|
|
bne @skip_to_next_tab
|
|
|
|
@done_skipping_over_tab:
|
2009-07-17 02:53:46 +00:00
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
;should now be pointing at the tab just before the selector
|
|
|
|
@copy_selector:
|
|
|
|
iny
|
|
|
|
lda (buffer_ptr),y
|
|
|
|
cmp #09
|
|
|
|
beq @end_of_selector
|
|
|
|
sta resource_selector,x
|
|
|
|
inx
|
|
|
|
jmp @copy_selector
|
|
|
|
@end_of_selector:
|
2009-07-10 06:32:49 +00:00
|
|
|
stx resource_selector_length
|
2009-08-25 03:17:55 +00:00
|
|
|
;terminate with a CR,LF,$00
|
|
|
|
lda #$0D
|
|
|
|
sta resource_selector,x
|
|
|
|
lda #$0A
|
|
|
|
sta resource_selector+1,x
|
|
|
|
lda #$00
|
|
|
|
sta resource_selector+2,x
|
|
|
|
|
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
tax
|
|
|
|
;should now be pointing at the tab just before the hostname
|
|
|
|
@copy_hostname:
|
|
|
|
iny
|
|
|
|
lda (buffer_ptr),y
|
|
|
|
cmp #09
|
|
|
|
beq @end_of_hostname
|
|
|
|
sta resource_hostname,x
|
|
|
|
inx
|
|
|
|
jmp @copy_hostname
|
|
|
|
|
|
|
|
@end_of_hostname:
|
|
|
|
lda #$00
|
|
|
|
sta resource_hostname,x
|
|
|
|
|
|
|
|
;should now be pointing at the tab just before the port number
|
|
|
|
lda #0
|
|
|
|
sta resource_port
|
|
|
|
sta resource_port+1
|
|
|
|
@parse_port:
|
|
|
|
iny
|
|
|
|
beq @end_of_port
|
|
|
|
lda (buffer_ptr),y
|
2009-07-05 11:07:36 +00:00
|
|
|
cmp #$1F
|
|
|
|
bcc @end_of_port ;any control char should be treated as end of port field
|
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
ldax resource_port
|
|
|
|
stax acc16
|
|
|
|
lda #10
|
|
|
|
jsr mul_8_16
|
|
|
|
ldax acc16
|
|
|
|
stax resource_port
|
|
|
|
lda (buffer_ptr),y
|
|
|
|
sec
|
|
|
|
sbc #'0'
|
|
|
|
clc
|
|
|
|
adc resource_port
|
|
|
|
sta resource_port
|
|
|
|
bcc :+
|
|
|
|
inc resource_port+1
|
|
|
|
:
|
|
|
|
jmp @parse_port
|
|
|
|
@end_of_port:
|
2009-07-18 13:24:52 +00:00
|
|
|
|
|
|
|
lda displayed_resource_type
|
|
|
|
|
|
|
|
cmp #'7' ;is it a 'search' resource?
|
|
|
|
bne @done
|
|
|
|
|
|
|
|
ldax #query
|
|
|
|
jsr print
|
|
|
|
@get_query_string:
|
|
|
|
ldy #32 ;max chars
|
|
|
|
ldax #filter_text
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @get_query_string
|
|
|
|
stax buffer_ptr
|
|
|
|
jsr print_cr
|
|
|
|
ldy #0
|
2009-08-25 03:17:55 +00:00
|
|
|
ldx resource_selector_length
|
2009-07-18 13:24:52 +00:00
|
|
|
lda #09
|
|
|
|
@copy_one_char:
|
2009-08-25 03:17:55 +00:00
|
|
|
sta resource_selector,x
|
|
|
|
inx
|
2009-07-18 13:24:52 +00:00
|
|
|
lda (buffer_ptr),y
|
|
|
|
beq @done_query_string
|
|
|
|
iny
|
2009-08-25 03:17:55 +00:00
|
|
|
bne @copy_one_char
|
2009-07-18 13:24:52 +00:00
|
|
|
@done_query_string:
|
2009-08-25 03:17:55 +00:00
|
|
|
;terminate with a CR,LF,$00
|
|
|
|
lda #$0D
|
|
|
|
sta resource_selector,x
|
|
|
|
lda #$0A
|
|
|
|
sta resource_selector+1,x
|
|
|
|
lda #$00
|
|
|
|
sta resource_selector+2,x
|
2009-09-22 02:05:49 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
@done:
|
|
|
|
|
|
|
|
add_resource_to_history_and_display:
|
2009-07-05 10:17:38 +00:00
|
|
|
;add this to the resource history
|
2009-07-05 10:42:48 +00:00
|
|
|
lda current_resource_history_entry
|
|
|
|
cmp #RESOURCE_HISTORY_ENTRIES
|
|
|
|
bne @dont_shuffle_down
|
|
|
|
ldax #resource_history
|
|
|
|
stax copy_dest
|
|
|
|
inx ;one page higher up
|
|
|
|
stax copy_src
|
|
|
|
ldx #(RESOURCE_HISTORY_ENTRIES-1)
|
|
|
|
lda #$00
|
|
|
|
jsr copymem
|
|
|
|
dec current_resource_history_entry
|
|
|
|
|
|
|
|
@dont_shuffle_down:
|
2009-07-05 10:17:38 +00:00
|
|
|
ldax #current_resource
|
|
|
|
stax copy_src
|
|
|
|
lda #<resource_history
|
|
|
|
sta copy_dest
|
|
|
|
clc
|
|
|
|
lda #>resource_history
|
|
|
|
adc current_resource_history_entry
|
|
|
|
sta copy_dest+1
|
|
|
|
ldax #$100
|
|
|
|
jsr copymem
|
|
|
|
|
|
|
|
inc current_resource_history_entry
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
jsr load_resource_into_buffer
|
|
|
|
bcs @error_in_loading
|
|
|
|
jmp display_resource_in_buffer
|
|
|
|
@error_in_loading:
|
2009-08-25 03:17:55 +00:00
|
|
|
jmp print_errorcode
|
2009-07-10 06:32:49 +00:00
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
;show the entries in the history buffer
|
|
|
|
show_history:
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
jsr cls
|
|
|
|
ldax #history
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
lda current_resource_history_entry
|
|
|
|
@show_one_entry:
|
|
|
|
pha
|
|
|
|
jsr load_resource_from_history
|
|
|
|
jsr print_resource_description
|
|
|
|
pla
|
|
|
|
sec
|
|
|
|
sbc #1
|
|
|
|
bne @show_one_entry
|
2009-08-02 08:49:38 +00:00
|
|
|
get_keypress_then_rts:
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr print_cr
|
2009-08-25 03:17:55 +00:00
|
|
|
ldax #press_a_key_to_continue
|
2009-07-17 02:53:46 +00:00
|
|
|
jsr print
|
2009-10-27 10:51:28 +00:00
|
|
|
jsr get_key_ip65
|
2009-07-17 02:53:46 +00:00
|
|
|
rts
|
2009-07-05 10:17:38 +00:00
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
|
|
|
|
;load the 'current_resource' into the buffer
|
|
|
|
load_resource_into_buffer:
|
|
|
|
ldax #resolving
|
|
|
|
jsr print
|
|
|
|
ldax #resource_hostname
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
ldax #resource_hostname
|
|
|
|
jsr dns_set_hostname
|
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
bcs :+
|
2009-07-10 06:32:49 +00:00
|
|
|
jsr dns_resolve
|
2009-07-17 02:53:46 +00:00
|
|
|
:
|
2009-07-18 13:24:52 +00:00
|
|
|
bcc @no_error
|
2009-08-25 03:17:55 +00:00
|
|
|
rts
|
2009-07-18 13:24:52 +00:00
|
|
|
@no_error:
|
2009-07-10 06:32:49 +00:00
|
|
|
ldx #3 ; save IP address just retrieved
|
|
|
|
: lda dns_ip,x
|
2009-08-25 03:17:55 +00:00
|
|
|
sta url_ip,x
|
2009-08-02 08:49:38 +00:00
|
|
|
sta telnet_ip,x
|
2009-07-10 06:32:49 +00:00
|
|
|
dex
|
|
|
|
bpl :-
|
2009-08-25 03:17:55 +00:00
|
|
|
|
|
|
|
|
2009-08-02 08:49:38 +00:00
|
|
|
lda displayed_resource_type
|
|
|
|
cmp #'8' ;is it a 'telnet' resource?
|
|
|
|
bne @not_telnet_resource
|
2009-08-25 03:17:55 +00:00
|
|
|
ldax #connecting
|
|
|
|
jsr print
|
2009-07-10 06:32:49 +00:00
|
|
|
ldax resource_port
|
2009-08-02 08:49:38 +00:00
|
|
|
stax telnet_port
|
|
|
|
lda #0
|
|
|
|
sta telnet_use_native_charset
|
|
|
|
|
2009-08-09 06:25:36 +00:00
|
|
|
;if the username = '/n', then connect in native mode
|
2009-08-02 08:49:38 +00:00
|
|
|
lda resource_selector_length
|
|
|
|
|
2009-08-09 06:25:36 +00:00
|
|
|
cmp #2
|
|
|
|
bne @not_native
|
|
|
|
lda resource_selector
|
|
|
|
cmp #'/'
|
2009-08-02 08:49:38 +00:00
|
|
|
bne @not_native
|
|
|
|
lda resource_selector+1
|
|
|
|
cmp #'n'
|
|
|
|
bne @not_native
|
|
|
|
inc telnet_use_native_charset
|
|
|
|
@not_native:
|
|
|
|
jsr telnet_connect
|
|
|
|
jmp get_keypress_then_rts
|
|
|
|
|
|
|
|
@not_telnet_resource:
|
|
|
|
ldax resource_port
|
2009-08-25 03:17:55 +00:00
|
|
|
stax url_port
|
2009-07-10 06:32:49 +00:00
|
|
|
ldax #resource_selector
|
2009-08-25 03:17:55 +00:00
|
|
|
stax url_selector
|
|
|
|
ldax #scratch_buffer
|
|
|
|
stax url_download_buffer
|
|
|
|
ldax #scratch_buffer_length
|
|
|
|
stax url_download_buffer_length
|
2009-07-10 06:32:49 +00:00
|
|
|
|
2009-08-25 03:17:55 +00:00
|
|
|
jmp resource_download
|
2009-07-10 06:32:49 +00:00
|
|
|
|
2009-07-04 13:52:04 +00:00
|
|
|
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
;retrieve entry specified by A from resource history
|
|
|
|
;NB 'A' = 1 means the first entry
|
|
|
|
load_resource_from_history:
|
|
|
|
clc
|
|
|
|
adc #(>resource_history)-1
|
|
|
|
sta copy_src+1
|
|
|
|
lda #<resource_history
|
|
|
|
sta copy_src
|
|
|
|
|
|
|
|
ldax #current_resource
|
|
|
|
stax copy_dest
|
|
|
|
ldax #$100
|
|
|
|
jsr copymem
|
2009-07-05 05:55:00 +00:00
|
|
|
|
2009-07-05 10:17:38 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
print_resource_description:
|
2009-07-09 23:43:47 +00:00
|
|
|
; ldax #port_no
|
|
|
|
; jsr print
|
|
|
|
; lda resource_port+1
|
|
|
|
; jsr print_hex
|
|
|
|
; lda resource_port
|
|
|
|
; jsr print_hex
|
|
|
|
; jsr print_cr
|
|
|
|
|
2009-07-17 02:53:46 +00:00
|
|
|
ldax #server
|
2009-07-05 10:17:38 +00:00
|
|
|
jsr print
|
|
|
|
ldax #resource_hostname
|
2009-07-17 02:53:46 +00:00
|
|
|
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
ldax #selector
|
2009-07-05 10:17:38 +00:00
|
|
|
jsr print
|
|
|
|
ldax #resource_selector
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
rts
|
2009-07-10 06:32:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
prompt_for_gopher_resource:
|
|
|
|
ldax #gopher_server
|
|
|
|
jsr print
|
2009-07-17 13:10:44 +00:00
|
|
|
ldy #40
|
2009-07-10 06:32:49 +00:00
|
|
|
ldax #filter_dns
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_server_entered
|
|
|
|
stax copy_src
|
|
|
|
ldax #resource_hostname
|
|
|
|
stax copy_dest
|
|
|
|
ldax #RESOURCE_HOSTNAME_MAX_LENGTH
|
|
|
|
jsr copymem
|
|
|
|
ldax #70
|
|
|
|
stax resource_port
|
|
|
|
lda #'/'
|
|
|
|
sta resource_selector
|
2009-11-07 22:42:15 +00:00
|
|
|
lda #$0d
|
2009-07-10 06:32:49 +00:00
|
|
|
sta resource_selector+1
|
2009-11-07 22:42:15 +00:00
|
|
|
|
|
|
|
lda #$0a
|
|
|
|
sta resource_selector+2
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta resource_selector+3
|
2009-07-10 06:32:49 +00:00
|
|
|
sta resource_selector_length+1
|
2009-11-07 22:42:15 +00:00
|
|
|
lda #3
|
2009-07-10 06:32:49 +00:00
|
|
|
sta resource_selector_length
|
2009-07-17 02:53:46 +00:00
|
|
|
lda #'1'
|
|
|
|
sta displayed_resource_type
|
2009-07-10 06:32:49 +00:00
|
|
|
jsr print_cr
|
|
|
|
jmp add_resource_to_history_and_display
|
|
|
|
@no_server_entered:
|
|
|
|
sec
|
|
|
|
rts
|
2009-07-04 13:52:04 +00:00
|
|
|
.rodata
|
2009-07-05 05:55:00 +00:00
|
|
|
page_header:
|
|
|
|
.byte "PAGE NO $",0
|
|
|
|
port_no:
|
|
|
|
.byte "PORT NO ",0
|
2009-07-05 10:17:38 +00:00
|
|
|
history:
|
2009-07-17 02:53:46 +00:00
|
|
|
.byte "GOPHER HISTORY ",13,0
|
2009-07-10 06:32:49 +00:00
|
|
|
cr_lf: .byte $0D,$0A
|
|
|
|
connecting:
|
2009-07-17 02:53:46 +00:00
|
|
|
.byte "CONNECTING ",0
|
2009-07-10 06:32:49 +00:00
|
|
|
retrieving:
|
2009-07-17 02:53:46 +00:00
|
|
|
.byte "RETRIEVING ",0
|
2009-07-10 06:32:49 +00:00
|
|
|
gopher_server:
|
2009-07-17 02:53:46 +00:00
|
|
|
.byte "GOPHER "
|
|
|
|
server:
|
|
|
|
.byte "SERVER :",0
|
|
|
|
selector:
|
|
|
|
.byte "SELECTOR :",0
|
2009-07-18 13:24:52 +00:00
|
|
|
query:
|
|
|
|
.byte "QUERY :",0
|
|
|
|
|
2009-07-10 06:32:49 +00:00
|
|
|
|
2009-10-22 10:49:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;-- LICENSE FOR gopher.i --
|
|
|
|
; The contents of this file are subject to the Mozilla Public License
|
|
|
|
; Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
; compliance with the License. You may obtain a copy of the License at
|
|
|
|
; http://www.mozilla.org/MPL/
|
|
|
|
;
|
|
|
|
; Software distributed under the License is distributed on an "AS IS"
|
|
|
|
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
; License for the specific language governing rights and limitations
|
|
|
|
; under the License.
|
|
|
|
;
|
|
|
|
; The Original Code is ip65.
|
|
|
|
;
|
|
|
|
; The Initial Developer of the Original Code is Jonno Downes,
|
|
|
|
; jonno@jamtronix.com.
|
|
|
|
; Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
; Jonno Downes. All Rights Reserved.
|
|
|
|
; -- LICENSE END --
|