Skip to content

Commit

Permalink
User can enter multiple names for members of party
Browse files Browse the repository at this point in the history
  • Loading branch information
samcan committed Jul 16, 2020
1 parent 8fb5960 commit 30948b1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 33 deletions.
111 changes: 82 additions & 29 deletions src/engine_logic_functions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,48 @@ MACRO UpdateStoreDisplayRegular sprOffset,item,peritempr,itempr,firstX,firstY,se
DisplayNumberThousands temp, bcdResult+3, bcdResult+2, bcdResult+1, bcdResult, secondX, secondY, secondAttr
ENDM
;;;;;;;;;;;;;;;;;;;
MACRO DrawName name,startX,startY
; set X = sprite offset
; set name to 16-bit address of name var
; clobbers A, X, Y, temp, pointer
; returns X = next sprite offset

LDA #<name
STA pointer
LDA #>name
STA pointer+1

LDA startX
STA letterX

LDY #$00
- LDA startY
STA $0200, X

INX
STX temp
;LDX identity_table, Y
LDA (pointer), Y
LDX temp
STA $0200, X

INX
LDA #%00000000
STA $0200, X

INX
LDA letterX
STA $0200, X
CLC
ADC #$10
STA letterX

INY
INX
CPY #MAX_LETTER_NAME
BNE -
ENDM
;;;;;;;;;;;;;;;;;;;
GameEngineLogic:
LDA gamestate
ASL A
Expand Down Expand Up @@ -129,6 +171,12 @@ EngineLogicAlphabet:
BEQ @NameZero
CMP #$01
BEQ @NameOne
CMP #$02
BEQ @NameTwo
CMP #$03
BEQ @NameThree
CMP #MAX_NAMES
BEQ @NameFour

@NameZero:
LDA #<name0
Expand All @@ -144,6 +192,27 @@ EngineLogicAlphabet:
STA curname+1
JMP @cont

@NameTwo:
LDA #<name2
STA curname
LDA #>name2
STA curname+1
JMP @cont

@NameThree:
LDA #<name3
STA curname
LDA #>name3
STA curname+1
JMP @cont

@NameFour:
LDA #<name4
STA curname
LDA #>name4
STA curname+1
JMP @cont


@cont: ; move cursor around
CheckForButton #BTN_UPARROW, MoveCursorUp, +
Expand Down Expand Up @@ -184,7 +253,14 @@ EngineLogicAlphabetEraseLetter:
EngineLogicAlphabetDoneSelecting:
JMP UpdateCursorLetterSprites
EngineLogicAlphabetEndState:
LDA curnameidx
CMP #MAX_NAMES
BNE +
JMP EndAlphabetState
+ INC curnameidx
LDA #$00
STA numletters
JMP GameEngineLogicDone

MoveCursorUp:
LDA hilitedltr
Expand Down Expand Up @@ -290,37 +366,14 @@ UpdateCursorLetterSprites:
INX
LDA cursorX
STA $0200, x

; draw selected letters
LDA #NAME0_X
STA letterX

LDY #$00
- INX
LDA #NAME0_Y
STA $0200, X

INX
STX temp
LDX identity_table, Y
LDA name0, X
LDX temp
STA $0200, X

INX
LDA #%00000000
STA $0200, X

INX
LDA letterX
STA $0200, X
CLC
ADC #$10
STA letterX

INY
CPY #$0A
BNE -
; draw names
DrawName name0, #NAME0_X, #NAME0_Y
DrawName name1, #NAME1_X, #NAME1_Y
DrawName name2, #NAME2_X, #NAME2_Y
DrawName name3, #NAME3_X, #NAME3_Y
DrawName name4, #NAME4_X, #NAME4_Y

; now that we've implemented an OK button, we don't need to look
; for the START button to end this state
Expand Down
10 changes: 6 additions & 4 deletions src/westward.asm
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,22 @@ BTN_LEFTARROW = 1 << 1
BTN_RIGHTARROW = 1 << 0

; alphabet screen
MAX_NAMES = $04 ; including 0, so 5 names total
MAX_LETTER_NAME = $08
MIN_Y = $8F
MAX_Y = $BF
MIN_X = $48
MAX_X = $A8
NAME0_X = $30
NAME0_Y = $2F
NAME1_X = #NAME0_X
NAME1_Y = #NAME0_Y + $10
NAME1_Y = $3F
NAME2_X = #NAME0_X
NAME2_Y = #NAME1_Y + $10
NAME2_Y = $4F
NAME3_X = #NAME0_X
NAME3_Y = #NAME2_Y + $10
NAME3_Y = $5F
NAME4_X = #NAME0_X
NAME4_Y = #NAME3_Y + $10
NAME4_Y = $6F

; pace screen
PACE_CURSOR_SPR = $3F
Expand Down

0 comments on commit 30948b1

Please sign in to comment.