From 96d1885b23ccdc338c65f204978565dfad11071a Mon Sep 17 00:00:00 2001 From: jonnosan Date: Tue, 18 Aug 2009 02:41:34 +0000 Subject: [PATCH] git-svn-id: http://svn.code.sf.net/p/netboot65/code@180 93682198-c243-4bdb-bd91-e943c89aac3b --- client/inc/version.i | 1 + client/ip65/url.s | 52 +++++++++------ client/nb65/Makefile | 2 +- client/nb65/nb65_c64.s | 2 +- client/nb65/nb65_version.i | 1 - client/test/test_get_url.s | 132 +++++++++++++++++++++++++++++++++++++ dist/make_dist.rb | 4 +- dist/version_number.txt | 2 +- 8 files changed, 171 insertions(+), 25 deletions(-) create mode 100644 client/inc/version.i delete mode 100644 client/nb65/nb65_version.i create mode 100644 client/test/test_get_url.s diff --git a/client/inc/version.i b/client/inc/version.i new file mode 100644 index 0000000..a99521c --- /dev/null +++ b/client/inc/version.i @@ -0,0 +1 @@ +.byte "0.9.21" diff --git a/client/ip65/url.s b/client/ip65/url.s index ce3f617..d960108 100644 --- a/client/ip65/url.s +++ b/client/ip65/url.s @@ -8,11 +8,13 @@ .include "../inc/nb65_constants.i" .endif +TIMEOUT_SECONDS=15 + .import output_buffer .importzp copy_src .importzp copy_dest .import copymem - +.import timer_read .import ip65_error .import ip65_process .import parser_init @@ -57,7 +59,7 @@ selector_buffer=output_buffer src_ptr: .res 1 dest_ptr: .res 1 - + timeout_counter: .res 1 url_download_buffer: .res 2 ; points to a buffer that url will be downloaded into url_download_buffer_length: .res 2 ;length of buffer that url will be downloaded into @@ -211,7 +213,7 @@ lda #url_type_gopher ;now the HTTP version number & Host: field ldx #0 : - lda http_version_and_host,x + lda http_preamble,x beq :+ ldy dest_ptr inc dest_ptr @@ -256,9 +258,10 @@ lda #url_type_gopher lda #$0a sta (copy_dest),y iny + sty dest_ptr dex bne @final_crlf - + @done: lda #$00 sta (copy_dest),y @@ -295,7 +298,8 @@ url_download: stax temp_buffer ldax url_download_buffer_length stax temp_buffer_length - + jsr put_zero_at_end_of_dl_buffer + ldx #3 ; save IP address just retrieved : lda url_ip,x sta tcp_connect_ip,x @@ -314,11 +318,19 @@ url_download: ldax url_selector jsr tcp_send_string + jsr timer_read + txa + adc #TIMEOUT_SECONDS*4 ;what value shoul trigger the timeout? + sta timeout_counter ;now loop until we're done @download_loop: jsr ip65_process + jsr timer_read + cpx timeout_counter + beq @timeout lda download_flag beq @download_loop +@timeout: jsr tcp_close clc @error: @@ -335,20 +347,21 @@ url_download: lda tcp_inbound_data_length+1 cmp #$ff - bne @not_end_of_file + bne not_end_of_file @end_of_file: lda #1 sta download_flag - - ;put a zero byte at the end of the file (in case it was a text file) + +put_zero_at_end_of_dl_buffer: + ;put a zero byte at the end of the file ldax temp_buffer stax copy_dest lda #0 tay sta (copy_dest),y rts -@not_end_of_file: - + +not_end_of_file: ;copy this chunk to our input buffer ldax temp_buffer stax copy_dest @@ -374,10 +387,8 @@ url_download: lda temp_buffer+1 adc tcp_inbound_data_length+1 sta temp_buffer+1 -; lda #'*' -; jsr print_a - - rts + jmp put_zero_at_end_of_dl_buffer + @would_overflow_buffer: pla ;clean up the stack ldax temp_buffer_length @@ -391,15 +402,18 @@ url_download: lda #0 sta temp_buffer_length sta temp_buffer_length+1 - rts + jmp put_zero_at_end_of_dl_buffer .rodata get: .byte "GET " get_length=4 - http_version_and_host: .byte " HTTP/1.1",$0d,$0a, "Host: ",0 -; http_trailer: .byte " HTTP/1.1",$0a,$0a -; http_trailer_end: -; http_trailer_length=http_trailer_end-http_trailer + http_preamble: + .byte " HTTP/1.1",$0d,$0a + .byte "User-Agent: IP65/" + .include "../inc/version.i" + .byte $0d,$0a + .byte "Connection: close",$0d,$0a + .byte "Host: ",0 colon_slash_slash: .byte ":/" slash: .byte "/",0 diff --git a/client/nb65/Makefile b/client/nb65/Makefile index 0d6e2cc..33662ec 100644 --- a/client/nb65/Makefile +++ b/client/nb65/Makefile @@ -9,7 +9,7 @@ INCFILES=\ ../inc/net.i\ ../inc/menu.i\ ../inc/nb65_constants.i\ - nb65_version.i\ + ../inc/version.i\ IP65LIB=../ip65/ip65.lib diff --git a/client/nb65/nb65_c64.s b/client/nb65/nb65_c64.s index d866f1a..ebfbb09 100644 --- a/client/nb65/nb65_c64.s +++ b/client/nb65/nb65_c64.s @@ -674,7 +674,7 @@ exit_gopher: netboot65_msg: .byte 13,"NB65 - V" -.include "nb65_version.i" +.include "../inc/version.i" .byte 13,0 main_menu_msg: .byte 13," MAIN MENU",13,13 diff --git a/client/nb65/nb65_version.i b/client/nb65/nb65_version.i deleted file mode 100644 index 6742d88..0000000 --- a/client/nb65/nb65_version.i +++ /dev/null @@ -1 +0,0 @@ -.byte "0.9.20" diff --git a/client/test/test_get_url.s b/client/test/test_get_url.s new file mode 100644 index 0000000..aedeaf6 --- /dev/null +++ b/client/test/test_get_url.s @@ -0,0 +1,132 @@ +.include "../inc/common.i" +.include "../inc/commonprint.i" +.include "../inc/net.i" +;.include "../ip65/url_download.s" + +.import print_a +.import get_key +.import cfg_get_configuration_ptr +.import ascii_to_native +.import parser_init +.import parser_skip_next +.importzp copy_src +.importzp copy_dest +.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 +temp_buff=copy_dest + +.bss + +string_offset: .res 1 +selector_ptr: .res 2 +temp_url_ptr: .res 2 +.segment "STARTUP" ;this is what gets put at the start of the file on the C64 + +.word basicstub ; load address + +basicstub: + .word @nextline + .word 2003 + .byte $9e + .byte <(((init / 1000) .mod 10) + $30) + .byte <(((init / 100 ) .mod 10) + $30) + .byte <(((init / 10 ) .mod 10) + $30) + .byte <(((init ) .mod 10) + $30) + .byte 0 +@nextline: + .word 0 + +init: + + ;switch to lower case charset + lda #23 + sta $d018 + + init_ip_via_dhcp + jsr print_ip_config + + ldax #url_1 + jsr test_url_download + + ldax #url_2 + jsr test_url_download + + rts + +test_url_download: + stax temp_url_ptr + ldax #downloading + jsr print + ldax temp_url_ptr + jsr print + jsr print_cr + ldax #dl_buffer + stax url_download_buffer + ldax #dl_buffer_length + stax url_download_buffer_length + + ldax temp_url_ptr + jsr url_download + bcc :+ + jmp print_errorcode + : + ldax #dl_buffer + jsr parser_init +@next_title: + ldax #title + jsr parser_skip_next + bcs @done + + jsr print_tag_contents + jsr print_cr + + jmp @next_title +@done: + + rts + +wait_key: + ldax #press_a_key + jsr print + jmp get_key + + +print_tag_contents: + stax temp_buff + lda #0 + sta string_offset +@next_byte: + ldy string_offset + lda (temp_buff),y + beq @done + cmp #'<' + beq @done + jsr ascii_to_native + jsr print_a + inc string_offset + beq @done + jmp @next_byte +@done: + rts + +.data +title: +.byte "",0 + +url_1: +.byte "http://static.cricinfo.com/rss/livescores.xml",0 +url_2: +.byte "http://search.twitter.com/search.atom?q=kipper",0 + +downloading: .asciiz "DOWNLOADING " +press_a_key: .byte "PRESS ANY KEY TO CONTINUE",13,0 + +.bss +dl_buffer_length=8092 +dl_buffer: .res dl_buffer_length diff --git a/dist/make_dist.rb b/dist/make_dist.rb index a6d5ae8..6477987 100644 --- a/dist/make_dist.rb +++ b/dist/make_dist.rb @@ -9,7 +9,7 @@ require 'ftools' WORKING_DIR=File.expand_path(File.dirname(__FILE__)+"/netboot65") SRC_DIR=File.expand_path(File.dirname(__FILE__)+"/../") VERSION_FILE=File.expand_path(File.dirname(__FILE__)+"/version_number.txt") -VERSION_INC_FILE=File.expand_path(File.dirname(__FILE__)+"/../client/nb65/nb65_version.i") +VERSION_INC_FILE=File.expand_path(File.dirname(__FILE__)+"/../client/inc/version.i") version_string=File.open(VERSION_FILE).read ["","c64","lib","bin","boot","doc","inc","examples"].each do |dir_suffix| @@ -23,7 +23,7 @@ end #["client/nb65/nb65_rrnet.bin","c64/"], ["client/nb65/nb65_c64_ram.prg","c64/"], ["client/nb65/nb65_std_cart.bin","c64/"], -\["client/nb65/nb65_tcp_cart.bin","c64/"], +["client/nb65/nb65_tcp_cart.bin","c64/"], ["client/nb65/d64_upload.prg","boot/"], ["server/lib/tftp_server.rb","lib"], ["server/lib/file_list.rb","lib"], diff --git a/dist/version_number.txt b/dist/version_number.txt index 6b7a3e3..fc6d9f6 100644 --- a/dist/version_number.txt +++ b/dist/version_number.txt @@ -1 +1 @@ -0.9.20 \ No newline at end of file +0.9.21 \ No newline at end of file