2017-08-17 03:18:59 +00:00
|
|
|
enter_name:
|
|
|
|
|
|
|
|
jsr TEXT
|
|
|
|
|
|
|
|
; zero out name
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2020-12-30 06:00:25 +00:00
|
|
|
ldx #0
|
2017-08-17 03:18:59 +00:00
|
|
|
lda #0
|
2020-12-30 06:00:25 +00:00
|
|
|
zero_name_loop:
|
2021-01-20 21:36:26 +00:00
|
|
|
sta HERO_NAME,X
|
2020-12-30 06:00:25 +00:00
|
|
|
inx
|
|
|
|
cpx #8
|
|
|
|
bne zero_name_loop
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
; set up initial conditions
|
2021-01-20 21:36:26 +00:00
|
|
|
|
|
|
|
lda #0
|
2021-02-07 06:03:23 +00:00
|
|
|
sta NAMEX ; name ptr
|
|
|
|
sta XX ; x-coord of grid
|
|
|
|
sta YY ; y-coord of grid
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
name_loop:
|
2021-01-20 21:36:26 +00:00
|
|
|
; clear screen
|
|
|
|
lda #$A0
|
|
|
|
jsr clear_top_a
|
|
|
|
jsr clear_bottom
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
; print entry string at top
|
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
jsr normal_text
|
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
lda #>(enter_name_string)
|
|
|
|
sta OUTH
|
|
|
|
lda #<(enter_name_string)
|
|
|
|
sta OUTL
|
|
|
|
jsr move_and_print
|
2017-08-17 03:18:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
;=============================
|
|
|
|
; print current name + cursor
|
|
|
|
; on screen at 11,2?
|
|
|
|
|
|
|
|
; get pointer to line 2
|
|
|
|
lda gr_offsets+(2*2)
|
2021-01-22 05:50:11 +00:00
|
|
|
clc
|
|
|
|
adc #11
|
2021-01-20 21:36:26 +00:00
|
|
|
sta OUTL
|
|
|
|
lda gr_offsets+(2*2)+1
|
|
|
|
clc
|
|
|
|
adc DRAW_PAGE
|
|
|
|
sta OUTH
|
|
|
|
|
|
|
|
ldx #0
|
2021-01-22 05:50:11 +00:00
|
|
|
ldy #0
|
2021-01-20 21:36:26 +00:00
|
|
|
print_name_loop:
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
cpx NAMEX
|
2021-01-20 21:36:26 +00:00
|
|
|
bne print_name_name
|
|
|
|
print_name_cursor:
|
2017-08-17 03:18:59 +00:00
|
|
|
lda #'+'
|
2021-01-20 21:36:26 +00:00
|
|
|
bne print_name_put_char ; bra
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
print_name_name:
|
|
|
|
lda HERO_NAME,X
|
|
|
|
bne print_name_char
|
|
|
|
print_name_zero:
|
|
|
|
lda #'_'+$80
|
|
|
|
bne print_name_put_char ; bra
|
|
|
|
|
|
|
|
print_name_char:
|
2017-08-17 03:18:59 +00:00
|
|
|
ora #$80
|
2021-01-20 21:36:26 +00:00
|
|
|
|
|
|
|
print_name_put_char:
|
|
|
|
sta (OUTL),Y
|
|
|
|
|
|
|
|
done_print_name_loop:
|
|
|
|
|
|
|
|
inx
|
2021-01-22 05:50:11 +00:00
|
|
|
|
2017-08-17 03:18:59 +00:00
|
|
|
iny
|
2021-01-20 21:36:26 +00:00
|
|
|
iny
|
2021-01-22 05:50:11 +00:00
|
|
|
|
|
|
|
cpy #16
|
2021-01-20 21:36:26 +00:00
|
|
|
bne print_name_loop
|
|
|
|
|
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
;=====================
|
|
|
|
; print char selector
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
print_char_selector_loop:
|
|
|
|
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
clc
|
|
|
|
adc #10
|
|
|
|
tay
|
|
|
|
|
|
|
|
; set up y pointer
|
|
|
|
|
|
|
|
lda gr_offsets,Y
|
|
|
|
clc
|
|
|
|
adc #11
|
|
|
|
sta GBASL
|
|
|
|
lda gr_offsets+1,Y
|
|
|
|
clc
|
|
|
|
adc DRAW_PAGE
|
|
|
|
sta GBASH
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
inner_matrix_loop:
|
|
|
|
|
|
|
|
txa ; want Ycoord*8
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
sta TEMPY
|
|
|
|
|
|
|
|
tya
|
|
|
|
adc TEMPY
|
|
|
|
|
2021-01-26 01:38:05 +00:00
|
|
|
sta TEMPY ; save char for later
|
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
; adjust to numbers if ycoord>4
|
|
|
|
|
|
|
|
cpx #4
|
|
|
|
bcs textentry_numbers
|
|
|
|
|
|
|
|
textentry_alpha:
|
|
|
|
clc
|
|
|
|
adc #$40
|
|
|
|
textentry_numbers:
|
|
|
|
|
|
|
|
; check if Y equal
|
|
|
|
cpx YY
|
|
|
|
bne textentry_normal
|
|
|
|
cpy XX
|
|
|
|
beq textentry_inverse
|
|
|
|
|
|
|
|
textentry_normal:
|
|
|
|
ora #$80 ; convert to NORMAL uppercase
|
|
|
|
sta (GBASL),Y
|
|
|
|
lda #' '|$80
|
|
|
|
jmp textentry_putc
|
|
|
|
|
|
|
|
textentry_inverse:
|
2021-02-07 06:03:23 +00:00
|
|
|
sta putletter_smc+1
|
2021-01-22 05:50:11 +00:00
|
|
|
and #$3f ; convert to INVERSE
|
|
|
|
sta (GBASL),Y
|
|
|
|
lda #' '
|
|
|
|
|
|
|
|
textentry_putc:
|
|
|
|
inc GBASL
|
|
|
|
sta (GBASL),Y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
cpy #8
|
|
|
|
bne inner_matrix_loop
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
|
|
|
cpx #8
|
|
|
|
bne print_char_selector_loop
|
|
|
|
|
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
; special case bottom buttons
|
|
|
|
lda YY
|
|
|
|
cmp #8
|
|
|
|
bne done_button_normal
|
|
|
|
lda XX
|
|
|
|
cmp #4
|
|
|
|
bcs done_button_normal
|
|
|
|
done_button_inverse:
|
|
|
|
jsr inverse_text
|
|
|
|
jmp done_button_print
|
|
|
|
|
|
|
|
done_button_normal:
|
|
|
|
jsr normal_text
|
|
|
|
|
|
|
|
done_button_print:
|
|
|
|
lda #>(done_button_string)
|
|
|
|
sta OUTH
|
|
|
|
lda #<(done_button_string)
|
|
|
|
sta OUTL
|
|
|
|
jsr move_and_print
|
|
|
|
|
|
|
|
|
|
|
|
lda YY
|
|
|
|
cmp #8
|
|
|
|
bne back_button_normal
|
|
|
|
lda XX
|
|
|
|
cmp #4
|
|
|
|
bcc back_button_normal
|
|
|
|
back_button_inverse:
|
|
|
|
jsr inverse_text
|
|
|
|
jmp back_button_print
|
|
|
|
|
|
|
|
back_button_normal:
|
|
|
|
jsr normal_text
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
back_button_print:
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
lda #>(back_button_string)
|
|
|
|
sta OUTH
|
|
|
|
lda #<(back_button_string)
|
|
|
|
sta OUTL
|
|
|
|
jsr move_and_print
|
|
|
|
|
|
|
|
|
|
|
|
done_bottom_buttons:
|
|
|
|
|
|
|
|
|
|
|
|
;=================
|
2021-01-22 05:50:11 +00:00
|
|
|
;=================
|
|
|
|
; handle keypress
|
2021-02-07 06:03:23 +00:00
|
|
|
;=================
|
|
|
|
;=================
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
jsr get_keypress
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_textentry_up:
|
|
|
|
cmp #'W'
|
|
|
|
bne check_textentry_down
|
|
|
|
textentry_up:
|
|
|
|
dec YY
|
|
|
|
jmp done_textentry
|
|
|
|
|
|
|
|
check_textentry_down:
|
|
|
|
cmp #'S'
|
|
|
|
bne check_textentry_left
|
|
|
|
textentry_down:
|
|
|
|
inc YY
|
|
|
|
jmp done_textentry
|
|
|
|
|
|
|
|
|
|
|
|
check_textentry_left:
|
|
|
|
cmp #'A'
|
|
|
|
bne check_textentry_right
|
|
|
|
textentry_left:
|
|
|
|
dec XX
|
|
|
|
lda YY
|
|
|
|
cmp #8
|
|
|
|
bne textentry_left_not_bottom
|
|
|
|
dec XX
|
|
|
|
dec XX
|
|
|
|
dec XX
|
|
|
|
textentry_left_not_bottom:
|
|
|
|
jmp done_textentry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_textentry_right:
|
|
|
|
cmp #'D'
|
|
|
|
bne check_textentry_escape
|
|
|
|
textentry_right:
|
|
|
|
inc XX
|
|
|
|
lda YY
|
|
|
|
cmp #8
|
|
|
|
bne textentry_right_not_bottom
|
|
|
|
inc XX
|
|
|
|
inc XX
|
|
|
|
inc XX
|
|
|
|
textentry_right_not_bottom:
|
|
|
|
jmp done_textentry
|
|
|
|
|
|
|
|
check_textentry_escape:
|
|
|
|
cmp #27
|
2021-01-26 01:38:05 +00:00
|
|
|
bne check_textentry_return
|
2021-01-22 05:50:11 +00:00
|
|
|
textentry_escape:
|
|
|
|
jmp done_enter_name
|
|
|
|
|
2021-01-26 01:38:05 +00:00
|
|
|
check_textentry_return:
|
|
|
|
cmp #13
|
|
|
|
bne done_textentry_keypress
|
|
|
|
textentry_return:
|
2021-01-22 05:50:11 +00:00
|
|
|
|
2021-01-26 01:38:05 +00:00
|
|
|
lda YY
|
|
|
|
cmp #8
|
|
|
|
bne textentry_insert_char
|
|
|
|
|
|
|
|
textentry_handle_button:
|
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
lda XX
|
|
|
|
cmp #4
|
|
|
|
bcc button_was_done
|
|
|
|
|
|
|
|
button_was_back:
|
|
|
|
lda #0
|
|
|
|
ldx NAMEX
|
|
|
|
sta HERO_NAME,X
|
|
|
|
dec NAMEX
|
|
|
|
bpl back_not_zero
|
|
|
|
sta NAMEX
|
|
|
|
back_not_zero:
|
|
|
|
jmp done_textentry_keypress
|
|
|
|
|
|
|
|
button_was_done:
|
|
|
|
; done with this, exit routine
|
|
|
|
jmp done_enter_name
|
|
|
|
|
|
|
|
|
2021-01-26 01:38:05 +00:00
|
|
|
textentry_insert_char:
|
2021-02-07 06:03:23 +00:00
|
|
|
|
|
|
|
putletter_smc:
|
|
|
|
lda #$d1
|
2021-01-26 01:38:05 +00:00
|
|
|
ldx NAMEX
|
|
|
|
sta HERO_NAME,X
|
|
|
|
inc NAMEX
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-26 01:38:05 +00:00
|
|
|
done_textentry_keypress:
|
|
|
|
|
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
;=======================
|
|
|
|
; keep things in bounds
|
|
|
|
|
|
|
|
; if (name_x>7) name_x=7;
|
|
|
|
lda NAMEX
|
|
|
|
cmp #7
|
|
|
|
bcc namex_good
|
|
|
|
lda #7
|
|
|
|
sta NAMEX
|
|
|
|
namex_good:
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_xx_bounds:
|
|
|
|
|
|
|
|
; if (cursor_x<0) { cursor_x=7; cursor_y--; }
|
|
|
|
; if (cursor_x>7) { cursor_x=0; cursor_y++; }
|
|
|
|
|
|
|
|
check_xx_too_small:
|
|
|
|
lda XX
|
|
|
|
bpl check_xx_too_big
|
|
|
|
lda #7
|
|
|
|
sta XX
|
|
|
|
dec YY
|
|
|
|
jmp check_yy_bounds
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_xx_too_big:
|
|
|
|
cmp #8
|
|
|
|
bcc check_yy_bounds ; blt
|
|
|
|
lda #0
|
|
|
|
sta XX
|
|
|
|
inc YY
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_yy_bounds:
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
; if (cursor_y<0) cursor_y=8;
|
|
|
|
; if (cursor_y>8) cursor_y=0;
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_yy_too_small:
|
|
|
|
lda YY
|
|
|
|
bpl check_yy_too_big
|
|
|
|
lda #8
|
|
|
|
sta YY
|
|
|
|
bne done_check_bounds ; bra
|
2021-01-20 21:36:26 +00:00
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
check_yy_too_big:
|
|
|
|
cmp #8
|
|
|
|
beq check_yy_buttons
|
|
|
|
bcc done_check_bounds
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta YY
|
|
|
|
beq done_check_bounds ; bra
|
|
|
|
|
|
|
|
; if ((cursor_y==8) && (cursor_x<4)) cursor_x=0;
|
|
|
|
; else if ((cursor_y==8) && (cursor_x>=4)) cursor_x=4;
|
|
|
|
check_yy_buttons:
|
|
|
|
lda XX
|
|
|
|
cmp #4
|
|
|
|
bcc button_make_0
|
|
|
|
lda #4
|
|
|
|
sta XX
|
|
|
|
bne done_check_bounds ; bra
|
|
|
|
|
|
|
|
button_make_0:
|
|
|
|
lda #0
|
|
|
|
sta XX
|
|
|
|
|
|
|
|
|
|
|
|
done_check_bounds:
|
2021-01-20 21:36:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
|
|
|
|
done_textentry:
|
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
|
|
|
|
jsr page_flip
|
|
|
|
|
|
|
|
jmp name_loop
|
|
|
|
|
|
|
|
done_enter_name:
|
2017-08-17 03:18:59 +00:00
|
|
|
|
2021-02-07 20:13:07 +00:00
|
|
|
; copy in default if empty
|
2021-01-22 05:50:11 +00:00
|
|
|
|
2021-02-07 20:13:07 +00:00
|
|
|
; FIXME: use heroine name if applicable
|
|
|
|
|
|
|
|
lda HERO_NAME
|
|
|
|
bne really_done_enter_name
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
copy_name_loop:
|
|
|
|
lda default_hero,X
|
|
|
|
sta HERO_NAME,X
|
|
|
|
beq really_done_enter_name
|
|
|
|
inx
|
|
|
|
cpx #8
|
|
|
|
bne copy_name_loop
|
|
|
|
|
|
|
|
really_done_enter_name:
|
2017-08-17 03:18:59 +00:00
|
|
|
rts
|
|
|
|
|
2021-01-20 21:36:26 +00:00
|
|
|
|
|
|
|
enter_name_string:
|
|
|
|
.byte 0,0,"PLEASE ENTER A NAME:",0
|
|
|
|
|
2021-02-07 06:03:23 +00:00
|
|
|
done_button_string:
|
|
|
|
.byte 11,21," DONE ",0
|
|
|
|
|
|
|
|
back_button_string:
|
|
|
|
.byte 20,21," BACK ",0
|
|
|
|
|
2021-01-22 05:50:11 +00:00
|
|
|
default_hero:
|
|
|
|
.byte "DEATER",0
|
|
|
|
|
|
|
|
default_heroine:
|
|
|
|
.byte "FROGGY",0
|
2021-02-07 06:03:23 +00:00
|
|
|
|