Proper cursor operation in tank names.

This commit is contained in:
Pecusx
2022-08-27 16:12:03 +02:00
parent d0ceb2ec0d
commit 851e8dd5af
2 changed files with 45 additions and 31 deletions
BIN
View File
Binary file not shown.
+45 -31
View File
@@ -1079,12 +1079,12 @@ NoArrowDown
jsr displaybyte jsr displaybyte
jsr HighlightLevel ; setting choosen level of the opponent (Moron, etc) jsr HighlightLevel ; setting choosen level of the opponent (Moron, etc)
; clear tank name editor field ; clear tank name editor field - not necessary
ldx #8 ; ldx #8
lda #0 ; lda #0
@ sta NameAdr,x ;@ sta NameAdr,x
dex ; dex
bpl @- ; bpl @-
; copy existing name and place cursor at end ; copy existing name and place cursor at end
lda TankNr lda TankNr
@@ -1102,25 +1102,22 @@ NoArrowDown
endOfTankName endOfTankName
@ lda NameAdr,y @ lda NameAdr,y
and #$7f
bne LastNameChar bne LastNameChar
dey dey
bpl @- bpl @-
LastNameChar LastNameChar
cpy #7
beq @+
iny iny
lda #$80 ; place cursor on the end
sta NameAdr,y
cpy #8
bne @+
dey
@ sty PositionInName @ sty PositionInName
; dey ; lda NameAdr,y
; bpl @+ ; ora #$80 ; place cursor on the end
; iny ; if old name is empty or first time entering ; sta NameAdr,y
;@ sty PositionInName
CheckKeys CheckKeys
jsr CursorDisplay
jsr getkey jsr getkey
bit escFlag bit escFlag
spl:rts spl:rts
@@ -1143,13 +1140,12 @@ YesLetter
NotFirstLetter NotFirstLetter
sta NameAdr,x sta NameAdr,x
inx inx
lda #$80 ; cursor behind the char ; lda #$80 ; cursor behind the char
sta NameAdr,x ; sta NameAdr,x
cpx #$08 ; is there 8 characters? cpx #$08 ; is there 8 characters?
beq CheckKeys ; if so, nothing increased bne @+
stx PositionInName ; if not, we store dex
; position incremented by 1 @ stx PositionInName ; if not, we store
jmp CheckKeys jmp CheckKeys
CheckFurtherX01 ; here we check Tab, Return and Del CheckFurtherX01 ; here we check Tab, Return and Del
cmp #$0c ; Return cmp #$0c ; Return
@@ -1169,15 +1165,19 @@ CheckFurtherX01 ; here we check Tab, Return and Del
bne CheckKeys bne CheckKeys
; handling backing one char ; handling backing one char
ldx PositionInName ldx PositionInName
beq FirstChar beq FirstChar ; ferst char - no go back
cpx #7
bne NotLastChar
lda NameAdr,x
and #$7f
bne LastIsNotSpace ; last char not empty - first clear last char (no go back)
NotLastChar
dex dex
LastIsNotSpace
FirstChar FirstChar
lda #$80
sta NameAdr,x
lda #$00
sta NameAdr+1,x
sta NameAdr+2,x
stx PositionInName stx PositionInName
lda #0
sta NameAdr,x
jmp CheckKeys jmp CheckKeys
ChangeOfLevelUp ; change difficulty level of computer opponent ChangeOfLevelUp ; change difficulty level of computer opponent
inc:lda DifficultyLevel inc:lda DifficultyLevel
@@ -1275,13 +1275,27 @@ nextchar05
bne nextchar05 bne nextchar05
rts rts
.endp .endp
.proc CursorDisplay
ldy #7
CursorLoop
lda NameAdr,y
and #$7f
cpy PositionInName
bne @+
ora #$80 ; place cursor
@ sta NameAdr,y
dey
bpl CursorLoop
rts
.endp
.proc EnterNameByJoy .proc EnterNameByJoy
checkjoy checkjoy
lda STICK0 lda STICK0
and #$0f ; commented but necessary (memory problems) !!!
cmp #$0f ; and #$0f
bne JoyNotCentered ; cmp #$0f
; bne JoyNotCentered
notpressedJoy notpressedJoy
;fire ;fire