forked from wiebow/tetris.c64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelselect.asm
139 lines (113 loc) · 2.44 KB
/
levelselect.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
.const FLASH_DELAY = 18
// ----------------------------------
StartLevelSelectMode:
lda #$00
sta currentLevel
sta previousLevel
sta levelDisplayFlag
lda #1
sta levelFlashDelay // and delay counter
ldy #SCREEN_LEVELSELECT
jsr PRINT_SCREEN
// print the hi scores!
ldx #14
ldy #14
jsr PRINT_HISCORE_TABLE
rts
// --------------------------------------------------
UpdateLevelSelectMode:
// jsr GetInput // check for input
ldx inputResult
cpx #NOINPUT
beq doLevelFlash
// there is input
cpx #TURNCLOCK // hit fire?
bne !skip+
jmp EndLevelSelectMode
!skip:
cpx #DOWN // hit return?
bne !skip+
jmp EndLevelSelectMode
!skip:
cpx #LEFT
bne !skip+
lda currentLevel
beq doLevelFlash // we cant go lower, goto flashing
sta previousLevel // store level
dec currentLevel // and change level
jmp inputDone
!skip:
cpx #RIGHT
bne doLevelFlash // no further relevant input, goto flashing
lda currentLevel
cmp #9
beq doLevelFlash // we cannot go higher, goto flashing
sta previousLevel
inc currentLevel
inputDone:
// level select has changed
// make sure previous level is showing
ldx previousLevel
lda levelY,x
pha
lda levelX,x
tay
pla
tax
clc
jsr PLOT
lda previousLevel
adc #$30 // add #$30 to it to get a screencode
jsr PRINT
// make sure to show change asap
lda #$01
sta levelDisplayFlag
sta levelFlashDelay
doLevelFlash:
dec levelFlashDelay
beq !skip+ // do flashing
rts // nothing to do anymore
!skip:
// we are going to flash the level indicator
lda #FLASH_DELAY
sta levelFlashDelay // reset the delay counter
// set cursor to correct location
ldx currentLevel
lda levelY,x
pha
lda levelX,x
tay
pla
tax
clc
jsr PLOT
// flip the display flag
lda levelDisplayFlag
eor #%00000001
sta levelDisplayFlag
beq space // flag clear? then print space
lda currentLevel // get the level value
adc #$30 // add #$30 to it to get a screencode
jmp PRINT // print and exit
space:
lda #$20
jmp PRINT // and exit
// ----------------------------------
EndLevelSelectMode:
lda #MODE_PLAY
sta gameMode
jsr StartPlayMode
rts
// ----------------------------------
// x/y positions of level numbers on screen
// 0 1 2 3 4 5 6 7 8 9
levelX:
.byte 16,18,20,22,24,16,18,20,22,24
levelY:
.byte 07,07,07,07,07,09,09,09,09,09
levelFlashDelay:
.byte 0 // counter
levelDisplayFlag:
.byte 0 // render number or space
previousLevel:
.byte 0