-
Notifications
You must be signed in to change notification settings - Fork 13
/
entername.asm
140 lines (114 loc) · 2.11 KB
/
entername.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// ------------------------------------------------
StartEnterNameMode:
ldy #SCREEN_LEVELSELECT
jsr PRINT_SCREEN
// see if we have a high score
// copy player score to the hiscore new_score variable
lda score
sta new_score
lda score+1
sta new_score+1
lda score+2
sta new_score+2
jsr PROCESS_NEW_SCORE
ldx #14
ldy #14
jsr PRINT_HISCORE_TABLE
// this is not zero when a score has been added
lda new_hiscore // new_score_entry
beq noNewHiScore
// print the hiscore message
jsr PrintHappyMessage
// reset input len counter
ldx #0
stx input_len
// put cursor in right position
lda #13
clc
adc new_hiscore // new_score_entry
tax
ldy #21 // x pos
clc
jsr PLOT
jsr PRINT_CURSOR
// clear input buffer
lda #0
sta $c6
rts
noNewHiScore:
jsr PrintSadMessage
rts
// ------------------------------------------------
UpdateEnterNameMode:
lda new_hiscore // new_score_entry
bne waitForInput
// wait for a button or key
lda inputResult
cmp #DOWN
beq !exit+
cmp #TURNCLOCK
beq !exit+
rts
!exit:
jmp EndEnterNameMode
// player is entering name
waitForInput:
// accumulator is 0 when input is not yet done
jsr CONTROLLED_INPUT
beq !exit+
// done
// copy name from buffer to score entry
ldy entry_offset
ldx #0
!loop:
lda input_buffer,x
sta hiscore_table_start+3,y
iny
inx
cpx #TABLE_NAMELENGTH
bne !loop-
// save to disk
jsr SAVE_FILE
jmp EndEnterNameMode
!exit:
rts
// ------------------------------------------------
EndEnterNameMode:
lda #MODE_ATTRACT
sta gameMode
jsr StartAttractMode
rts
// ------------------------------------------------
PrintHappyMessage:
ldy #0
ldx #17
!loop:
lda hiscoremessage1,y
sta $0400+52,y
lda hiscoremessage2,y
sta $0400+52+40,y
iny
dex
bne !loop-
rts
PrintSadMessage:
ldy #0
ldx #17
!loop:
lda noHiscoremessage1,y
sta $0400+52,y
lda noHiscoremessage2,y
sta $0400+52+40,y
iny
dex
bne !loop-
rts
// ------------------------------------------------
hiscoremessage1:
.text " a new hiscore!! "
hiscoremessage2:
.text " enter your name "
noHiscoremessage1:
.text " too bad :( "
noHiscoremessage2:
.text " game over "