git-svn-id: http://svn.code.sf.net/p/netboot65/code@34 93682198-c243-4bdb-bd91-e943c89aac3b

This commit is contained in:
jonnosan 2009-01-31 13:56:41 +00:00
parent 9acf3ff877
commit 9ce0ea276f

View File

@ -1,15 +1,15 @@
OPTIONS_PER_PAGE = 18 OPTIONS_PER_PAGE = $10
.bss .bss
number_of_options: .res 1 number_of_options: .res 2
current_option: .res 1 current_option: .res 2
temp_option_counter: .res 2
first_option_this_page: .res 1 first_option_this_page: .res 2
options_shown_this_page: .res 1 options_shown_this_page: .res 1
options_table_pointer: .res 2
option_description_pointers: .res 256 ;table of addresses of up to 128 options jump_to_prefix: .res 1
.code .code
@ -17,74 +17,120 @@ option_description_pointers: .res 256 ;table of addresses of up to 128 options
;on exit, AX points to the selected string ;on exit, AX points to the selected string
select_option_from_menu: select_option_from_menu:
stax @lda_from_options_source+1 stax options_table_pointer
ldy #0 stax @get_current_byte+1
sty number_of_options lda #0
sta current_option
sta current_option+1
@copy_one_pointer: sta number_of_options
jsr @lda_from_options_source sta number_of_options+1
beq @found_last_option_string
lda @lda_from_options_source+1 ;count the number of options. this is done by scanning till we find a double zero, incrementing the count on each single zero
sta option_description_pointers,y @count_strings:
lda @lda_from_options_source+2 jsr @skip_past_next_null_byte
sta option_description_pointers+1,y
iny
iny
beq @found_last_option_string ;if we overflow y, then stop scanning options
inc number_of_options inc number_of_options
bne :+
@scan_for_null_byte: inc number_of_options+1
:
jsr @get_current_byte
bne @count_strings
jmp @display_first_page_of_options
@skip_past_next_null_byte:
jsr @move_to_next_byte jsr @move_to_next_byte
jsr @lda_from_options_source jsr @get_current_byte
bne @scan_for_null_byte bne @skip_past_next_null_byte
jsr @move_to_next_byte jsr @move_to_next_byte
jmp @copy_one_pointer rts
@lda_from_options_source: @get_current_byte:
lda $FFFF ;filled in from above lda $FFFF ;filled in from above
rts rts
@move_to_next_byte: @move_to_next_byte:
inc @lda_from_options_source+1 inc @get_current_byte+1
bne :+ bne :+
inc @lda_from_options_source+2 inc @get_current_byte+2
: :
rts rts
@found_last_option_string:
;move the ptr along till it's pointing at the whatever is the value of current_option
@move_to_current_option:
ldax options_table_pointer
stax @get_current_byte+1
lda #0
sta temp_option_counter
sta temp_option_counter+1
@skip_over_strings:
lda temp_option_counter
cmp current_option
bne @not_at_current_option
lda temp_option_counter+1
cmp current_option+1
bne @not_at_current_option
rts
@not_at_current_option:
jsr @skip_past_next_null_byte
inc temp_option_counter
bne :+
inc temp_option_counter+1
:
jmp @skip_over_strings
@display_first_page_of_options: @display_first_page_of_options:
lda #0 lda #0
sta first_option_this_page sta first_option_this_page
sta first_option_this_page+1
; lda #$D1
; sta first_option_this_page
@print_current_page: @print_current_page:
lda first_option_this_page
sta current_option
lda first_option_this_page+1
sta current_option+1
jsr @move_to_current_option
jsr cls jsr cls
ldax #select_from_following_options ldax #select_from_following_options
jsr print jsr print
lda number_of_options+1
bne @print_arrow_keys_msg
lda number_of_options lda number_of_options
cmp #OPTIONS_PER_PAGE cmp #OPTIONS_PER_PAGE
bcc :+ bcc :+
@print_arrow_keys_msg:
ldax #arrow_keys_to_move ldax #arrow_keys_to_move
jsr print jsr print
: :
lda #'(' lda #'('
jsr print_a jsr print_a
lda #'$' lda #'$'
jsr print_a jsr print_a
lda first_option_this_page+1
jsr print_hex
lda first_option_this_page lda first_option_this_page
sta current_option
clc
adc #1
jsr print_hex jsr print_hex
lda #'/' lda #'/'
jsr print_a jsr print_a
lda #'$' lda #'$'
jsr print_a jsr print_a
lda number_of_options+1
jsr print_hex
lda number_of_options lda number_of_options
jsr print_hex jsr print_hex
lda #')' lda #')'
@ -107,30 +153,73 @@ select_option_from_menu:
lda #' ' lda #' '
jsr print_a jsr print_a
lda current_option ; lda @get_current_byte+2
asl ; jsr print_hex
tax ; lda @get_current_byte+1
lda option_description_pointers,x ; jsr print_hex
tay
lda option_description_pointers+1,x lda @get_current_byte+1
tax ldx @get_current_byte+2
tya
jsr print jsr print
jsr print_cr jsr print_cr
jsr @skip_past_next_null_byte
inc current_option inc current_option
bne :+
inc current_option+1
:
lda current_option lda current_option
cmp number_of_options cmp number_of_options
beq @get_keypress bne :+
lda current_option+1
cmp number_of_options+1
bne :+
jmp @get_keypress
:
inc options_shown_this_page inc options_shown_this_page
lda options_shown_this_page lda options_shown_this_page
cmp #OPTIONS_PER_PAGE cmp #OPTIONS_PER_PAGE
beq @get_keypress beq @get_keypress
jmp @print_loop jmp @print_loop
@jump_to:
jsr print_cr
ldax #jump_to_prompt
jsr print
lda #'?'
jsr get_key
ora #$e0 ;make it a lower case letter with high bit set
sta jump_to_prefix
ldax options_table_pointer
stax @get_current_byte+1
lda #0
sta first_option_this_page
sta first_option_this_page+1
@check_if_at_jump_to_prefix:
jsr @get_current_byte
ora #$e0 ;make it a lower case letter with high bit set
cmp jump_to_prefix
; bmi @gone_past_prefix
beq @at_prefix
jsr @skip_past_next_null_byte
inc first_option_this_page
bne :+
inc first_option_this_page+1
:
jmp @check_if_at_jump_to_prefix
@gone_past_prefix:
@at_prefix:
jmp @print_current_page
@get_keypress: @get_keypress:
lda #'?' lda #'?'
jsr get_key jsr get_key
cmp #'/'+$80
beq @jump_to
cmp #$95 cmp #$95
beq @forward_one_page beq @forward_one_page
cmp #$8a cmp #$8a
@ -147,21 +236,19 @@ select_option_from_menu:
cmp #OPTIONS_PER_PAGE-1 cmp #OPTIONS_PER_PAGE-1
beq @got_valid_option beq @got_valid_option
bpl @get_keypress ;if we have underflowed, it wasn't a valid option bpl @get_keypress ;if we have underflowed, it wasn't a valid option
@got_valid_option:
@got_valid_option:
clc clc
adc first_option_this_page adc first_option_this_page
cmp number_of_options sta current_option
bcs @get_keypress ;this cmp/bcs is to check the case where we are on the last page of options (which can have less than then lda #0
;normal number of options) and have pressed a letter that is not a valid option for this page, but is for all other adc first_option_this_page+1
;pages.
;a now contains the index of the selected option sta current_option+1
asl ;double it jsr @move_to_current_option
tay ldax @get_current_byte+1
lda option_description_pointers+1,y
tax
lda option_description_pointers,y
rts rts
@ -170,30 +257,46 @@ select_option_from_menu:
lda first_option_this_page lda first_option_this_page
adc #OPTIONS_PER_PAGE adc #OPTIONS_PER_PAGE
sta first_option_this_page sta first_option_this_page
bcc :+
inc first_option_this_page+1
:
lda first_option_this_page+1
cmp number_of_options+1
bne @not_last_page_of_options
lda first_option_this_page
cmp number_of_options cmp number_of_options
bmi @not_last_page_of_options bne @not_last_page_of_options
@back_to_first_page: @back_to_first_page:
jmp @display_first_page_of_options jmp @display_first_page_of_options
@not_last_page_of_options: @not_last_page_of_options:
jmp @print_current_page jmp @print_current_page
@back_one_page: @back_one_page:
sec sec
lda first_option_this_page lda first_option_this_page
sbc #OPTIONS_PER_PAGE sbc #OPTIONS_PER_PAGE
bcc @show_last_page_of_options
sta first_option_this_page sta first_option_this_page
lda first_option_this_page+1
sbc #0
sta first_option_this_page+1
bmi @show_last_page_of_options
jmp @print_current_page jmp @print_current_page
@show_last_page_of_options: @show_last_page_of_options:
sec sec
lda number_of_options lda number_of_options
sbc #OPTIONS_PER_PAGE sbc #OPTIONS_PER_PAGE
bcc @back_to_first_page
sta first_option_this_page sta first_option_this_page
lda number_of_options+1
sbc #0
sta first_option_this_page+1
bmi @back_to_first_page
jmp @print_current_page jmp @print_current_page
; ldax #tftp_dir_buffer
; stax temp_filename_ptr
.rodata .rodata
select_from_following_options: .byte "SELECT ONE OF THE FOLLOWING OPTIONS:",13,0 select_from_following_options: .byte "SELECT ONE OF THE FOLLOWING OPTIONS:",13,0
arrow_keys_to_move: .byte "ARROW KEYS NAVIGATE BETWEEN MENU PAGES",13,0 arrow_keys_to_move: .byte "ARROW KEYS NAVIGATE BETWEEN MENU PAGES",13,0
jump_to_prompt: .byte "JUMP TO:",0