From ddccf4f0d13e807215ce3aa609e6ce8a41fb7741 Mon Sep 17 00:00:00 2001 From: jonnosan Date: Fri, 31 Jul 2009 14:50:02 +0000 Subject: [PATCH] git-svn-id: http://svn.code.sf.net/p/netboot65/code@168 93682198-c243-4bdb-bd91-e943c89aac3b --- client/drivers/a2input.s | 8 +- client/drivers/a2print.s | 13 ++- client/drivers/c64print.s | 20 +++- client/inc/gopher.i | 47 ++++------ client/nb65/nb65_c64.s | 10 +- client/test/Makefile | 3 +- client/test/a2_gopher.s | 38 ++++++-- client/test/a2_telnet.s | 189 ++++++++++++++++++++++++++++++++++---- 8 files changed, 267 insertions(+), 61 deletions(-) diff --git a/client/drivers/a2input.s b/client/drivers/a2input.s index bd0694c..e6ef5a3 100644 --- a/client/drivers/a2input.s +++ b/client/drivers/a2input.s @@ -22,8 +22,11 @@ allowed_ptr=copy_src ;reuse zero page ;inputs: none ;outputs: A contains ASCII code of key pressed get_key: - lda #$a0 - jmp $fd1b + ;lda #$a0 + ;lda #$20 + ;ldy #$24 ;KEYIN assumes Y is loaded with column + ;jmp $fd1b + jmp $fd0c ;inputs: none ;outputs: A contains ASCII value of key just pressed (0 if no key pressed) @@ -43,6 +46,7 @@ check_for_abort_key: lda $c000 ;current key pressed cmp #$9B bne :+ +bit $c010 ;clear the keyboard strobe sec rts : diff --git a/client/drivers/a2print.s b/client/drivers/a2print.s index d0769cb..dfc435d 100644 --- a/client/drivers/a2print.s +++ b/client/drivers/a2print.s @@ -1,10 +1,17 @@ .export print_a +.export print_a_inverse .export print_cr .export cls .export beep +.exportzp screen_current_row +.exportzp screen_current_col + .code +screen_current_col=$24 ; CH - Horizontal cursor-position (0-39) +screen_current_row=$25 ; CV - Vertical cursor-position (0-23) + ; ;use Apple 2 monitor ROM function to display 1 char ;inputs: A should be set to ASCII char to display @@ -32,4 +39,8 @@ cls: ;inputs: none ;outputs: none beep: - jmp $fbdd \ No newline at end of file + jmp $fbdd + +print_a_inverse: + and #$7F ;turn off bit 8 + jmp $fded \ No newline at end of file diff --git a/client/drivers/c64print.s b/client/drivers/c64print.s index 1db0f2b..c482376 100644 --- a/client/drivers/c64print.s +++ b/client/drivers/c64print.s @@ -3,6 +3,14 @@ .export print_cr .export cls .export beep +.export print_a_inverse + +.exportzp screen_current_row +.exportzp screen_current_col + + +screen_current_row=$d6 +screen_current_col=$d3 .data ;use C64 Kernel ROM function to print a character to the screen @@ -30,4 +38,14 @@ cls: ;inputs: none ;outputs: none beep: - rts \ No newline at end of file + rts + +;print a single char in inverse text: +print_a_inverse: + pha + lda #18 ;inverse mode on + jsr print_a + pla + jsr print_a + lda #146 ;inverse mode off + jmp print_a diff --git a/client/inc/gopher.i b/client/inc/gopher.i index e20079f..0aff85c 100644 --- a/client/inc/gopher.i +++ b/client/inc/gopher.i @@ -34,7 +34,9 @@ .import get_filtered_input .import filter_dns .import filter_text - + .importzp screen_current_row + .importzp screen_current_col + .import print_a_inverse .segment "IP65ZP" : zeropage ; pointer for moving through buffers @@ -135,7 +137,7 @@ display_resource_in_buffer: jsr ascii_to_native jsr print_a - lda $d6 + lda screen_current_row cmp #DISPLAY_LINES bmi @show_one_char jmp @end_of_current_page @@ -180,27 +182,17 @@ display_resource_in_buffer: sta resource_pointer_hi,x inc resource_counter - lda $d3 ;are we at the start of the current line? - beq :+ + lda screen_current_col ;are we at the start of the current line? + beq :+ + jsr print_cr : pla ;get back the resource type -; cmp #'1' -; beq @resource_is_a_dir -; lda #'-' -; jmp @print_resource_indicator -;@resource_is_a_dir: -; lda #'+' -;@print_resource_indicator: -; jsr print_a - lda #18 ;inverse mode on - jsr print_a + lda resource_counter clc adc #'a'-1 - jsr print_a - lda #146 ;inverse mode off - jsr print_a + jsr print_a_inverse lda #' ' jsr print_a @@ -218,14 +210,13 @@ display_resource_in_buffer: jsr get_next_byte cmp #$0A bne @skip_to_end_of_line - - - lda $d3 + + lda screen_current_col cmp #0 - beq :+ +; beq :+ jsr print_cr : - lda $d6 + lda screen_current_row cmp #DISPLAY_LINES bpl @end_of_current_page jmp @next_line @@ -239,21 +230,21 @@ display_resource_in_buffer: jsr get_key_if_available cmp #' ' beq @go_next_page - cmp #KEYCODE_F7 + cmp #KEY_NEXT_PAGE beq @go_next_page cmp #KEYCODE_DOWN beq @go_next_page - cmp #KEYCODE_F1 + cmp #KEY_PREV_PAGE beq @go_prev_page cmp #KEYCODE_UP beq @go_prev_page - cmp #KEYCODE_F2 + cmp #KEY_SHOW_HISTORY beq @show_history cmp #KEYCODE_LEFT beq @back_in_history - cmp #KEYCODE_F3 + cmp #KEY_BACK_IN_HISTORY beq @back_in_history - cmp #KEYCODE_F5 + cmp #KEY_NEW_SERVER beq @prompt_for_new_server cmp #KEYCODE_ABORT @@ -453,7 +444,7 @@ add_resource_to_history_and_display: lda ip65_error jsr print_hex jsr print_cr - jsr get_key + ;jsr get_key rts diff --git a/client/nb65/nb65_c64.s b/client/nb65/nb65_c64.s index 137e1ba..820bfa1 100644 --- a/client/nb65/nb65_c64.s +++ b/client/nb65/nb65_c64.s @@ -45,6 +45,14 @@ .include "../inc/menu.i" .if (BANKSWITCH_SUPPORT=$03) + + KEY_NEXT_PAGE=KEYCODE_F7 + KEY_PREV_PAGE=KEYCODE_F1 + KEY_SHOW_HISTORY=KEYCODE_F2 + KEY_BACK_IN_HISTORY=KEYCODE_F3 + KEY_NEW_SERVER=KEYCODE_F5 + + .include "../inc/gopher.i" .include "../inc/telnet.i" .endif @@ -640,7 +648,7 @@ exit_gopher: .rodata netboot65_msg: -.byte 13," NETBOOT65 - C64 CLIENT VERSION " +.byte 13," NETBOOT65 FOR C64 - VERSION " .include "nb65_version.i" .byte 13,0 main_menu_msg: diff --git a/client/test/Makefile b/client/test/Makefile index 56456f2..3faae27 100644 --- a/client/test/Makefile +++ b/client/test/Makefile @@ -50,6 +50,7 @@ test_tcp.prg: test_tcp.o $(IP65TCPLIB) $(C64PROGLIB) $(INCFILES) ../cfg/c64prg.c # $(LD) -m gopher_browser.map -vm -C ../cfg/c64prg.cfg -o gopher_browser.prg $(AFLAGS) $< $(IP65TCPLIB) $(C64PROGLIB) a2_gopher.pg2: a2_gopher.o $(IP65TCPLIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2bin.cfg ../inc/gopher.i + $(AS) $(AFLAGS) a2_gopher.s $(LD) -C ../cfg/a2bin.cfg -o a2_gopher.pg2 $(AFLAGS) $< $(IP65TCPLIB) $(APPLE2PROGLIB) a2_telnet.pg2: a2_telnet.o $(IP65TCPLIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2bin.cfg @@ -60,7 +61,7 @@ a2_telnet.pg2: a2_telnet.o $(IP65TCPLIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2b a2_netapps.dsk: a2_gopher.pg2 a2_telnet.pg2 ripxplore.rb --init BeautifulBoot a2_netapps.dsk -a a2_gopher.pg2 -t AppleBinary - ripxplore.rb a2_netapps.dsk -a a2_telnet.pg2 -t AppleBinary +# ripxplore.rb a2_netapps.dsk -a a2_telnet.pg2 -t AppleBinary ip65test.dsk: testdns.pg2 testdottedquad.pg2 testtftp.pg2 ripxplore.rb --init BeautifulBoot ip65test.dsk -a testdns.pg2 -t AppleBinary diff --git a/client/test/a2_gopher.s b/client/test/a2_gopher.s index 88641e0..48f6047 100644 --- a/client/test/a2_gopher.s +++ b/client/test/a2_gopher.s @@ -1,11 +1,21 @@ -;C64 gopher browser +;Apple 2 gopher browser ;july 2009 - jonno @ jamtronix.com .include "../inc/common.i" .include "../inc/commonprint.i" .include "../inc/net.i" - .include "../inc/c64keycodes.i" - .include "../inc/gopher.i" + .include "../inc/a2keycodes.i" +; .include "../inc/c64keycodes.i" + + + + KEY_NEXT_PAGE=$8E ; ^N + KEY_PREV_PAGE=$90; ^P + KEY_SHOW_HISTORY=$93; ^S + KEY_BACK_IN_HISTORY=$82 ; ^B + KEY_NEW_SERVER=$89 ;TAB key + +.include "../inc/gopher.i" .import __CODE_LOAD__ .import __CODE_SIZE__ @@ -25,19 +35,25 @@ init: jsr cls + jsr $c300 ; go to 80 column mode + + ldax #title jsr print jsr print_cr init_ip_via_dhcp jsr print_ip_config - -@loop_forever: - jsr prompt_for_gopher_resource ;only returns if no server was entered. - jsr print_cr - jmp @loop_forever + + + ldax #initial_location + sta resource_pointer_lo + stx resource_pointer_hi + ldx #0 + jsr select_resource_from_current_directory exit_gopher: - rts + jmp $e000 +; rts .rodata title: @@ -45,3 +61,7 @@ title: resolving: .byte "RESOLVING ",0 + +initial_location: +.byte "1gopher.floodgap.com",$09,"/",$09,"gopher.floodgap.com",$09,"70",$0D,$0A,0 + diff --git a/client/test/a2_telnet.s b/client/test/a2_telnet.s index efed7dd..93c43fb 100644 --- a/client/test/a2_telnet.s +++ b/client/test/a2_telnet.s @@ -6,6 +6,7 @@ .include "../inc/net.i" .include "../inc/a2keycodes.i" + .import __CODE_LOAD__ .import __CODE_SIZE__ .import __RODATA_SIZE__ @@ -22,11 +23,21 @@ .import telnet_ip .import cfg_init +.import dns_ip +.import dns_resolve +.import dns_set_hostname +.import get_filtered_input +.import filter_dns +.import filter_number + .segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 .addr __CODE_LOAD__-3 ; Start address .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size jmp init + .segment "IP65ZP" : zeropage + +buffer_ptr: .res 2 .code @@ -37,42 +48,184 @@ init: ldax #title jsr print jsr print_cr - jsr cfg_init -; jsr print_ip_config -; jsr get_key init_ip_via_dhcp jsr print_ip_config -@loop_forever: + jmp telnet_main_entry + +exit_telnet: + jmp $e000 + + +telnet_main_entry: +;prompt for a hostname, then resolve to an IP address + + ldax #remote_host + jsr print + ldax #filter_dns + jsr get_filtered_input + bcc @host_entered + ;if no host entered, then bail. + jmp exit_telnet +@host_entered: + stax hostname_ptr + jsr print_cr + ldax #resolving + jsr print + ldax hostname_ptr + jsr print + jsr print_cr + ldax hostname_ptr + jsr dns_set_hostname + bcs :+ + jsr dns_resolve +: + bcc @resolved_ok + print_failed + jsr print_cr + jsr print_errorcode + jmp telnet_main_entry +@resolved_ok: ldx #3 @copy_telnet_ip_loop: - lda remote_host,x + lda dns_ip,x sta telnet_ip,x dex bpl @copy_telnet_ip_loop - +@get_port: + ldax #remote_port + jsr print + jsr get_port_number + 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 #'N' + beq @native_mode + cmp #'n' + beq @native_mode + + cmp #'l' + beq @line_mode + cmp #'L' + beq @line_mode + + jmp @char_mode_input +@ascii_mode: lda #0 sta telnet_use_native_charset sta telnet_line_mode lda #1 sta telnet_local_echo - - jsr telnet_connect - jmp @loop_forever - - -exit_telnet: - rts + jmp @after_mode_set +@native_mode: + lda #1 + sta telnet_use_native_charset + lda #0 + sta telnet_local_echo + sta telnet_line_mode + jmp @after_mode_set +@line_mode: + lda #0 + sta telnet_use_native_charset + lda #1 + sta telnet_local_echo + sta telnet_line_mode +@after_mode_set: + + jsr cls + + ldax #connecting_in + jsr print + lda telnet_use_native_charset + beq @a_mode + ldax #native + jmp @c_mode +@a_mode: + lda telnet_line_mode + bne @l_mode + ldax #ascii + jmp @c_mode +@l_mode: + ldax #line +@c_mode: + jsr print + ldax #mode + jsr print + jsr telnet_connect + jmp telnet_main_entry + + +get_port_number: + .import mul_8_16 + .importzp acc16 + + ldy #5 ;max chars + ldax #filter_number + jsr get_filtered_input + bcs @no_port_entered + + ;AX now points a string containing port number + + stax buffer_ptr + lda #0 + sta port_number + sta port_number+1 + tay +@parse_port: + lda (buffer_ptr),y + cmp #$1F + bcc @end_of_port ;any control char should be treated as end of port field + ldax port_number + stax acc16 + lda #10 + jsr mul_8_16 + ldax acc16 + stax port_number + lda (buffer_ptr),y + sec + sbc #'0' + clc + adc port_number + sta port_number + bcc @no_rollover + inc port_number+1 +@no_rollover: + iny + bne @parse_port +@end_of_port: + ldax port_number + clc +@no_port_entered: + rts + + +.bss +hostname_ptr: .res 2 +port_number: .res 2 .rodata title: .byte " TELNET ][",13," jonno@jamtronix.com",13,0 +resolving: .byte "RESOLVING ",0 +connecting_in: .byte "CONNECTING IN ",0 +ascii: .byte "ASCII",0 +native: .byte "NATIVE",0 +line: .byte "LINE",0 +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 +char_mode_prompt: .byte "MODE - A=ASCII, N=NATIVE, L=LINE",13,0 -resolving: -.byte "RESOLVING ",0 -remote_host: -.byte 10,5,2,1 -padding: .byte 0,0,0,0,0 \ No newline at end of file