-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgameover.asm
159 lines (128 loc) · 2.16 KB
/
gameover.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
; asmsyntax=ca65
go_Ded:
.byte " Game Over", $00
go_Win:
.byte "OMG you won", $00
go_Start:
.byte " Press Start", $00
Init_GameWon:
ldx #0
stx TextEor
:
lda go_Win, x
sta TextBuffer, x
beq @done
inx
cpx #18
bne :-
@done:
jsr TextPrepare
jmp gameover_init
Init_GameOver:
jsr TextClearStringBuffer
; load into the buffer
ldx #0
stx TextEor
:
lda go_Ded, x
sta TextBuffer, x
beq @done
inx
cpx #18
bne :-
@done:
jsr TextPrepare
gameover_init:
.Disable_Drawing
.NMI_Disable
.repeat 8, i
lda Pal_Tv+i
sta PaletteBuffer+i
sta PaletteBufferSprites+i
.endrepeat
;lda #' '
;jsr FillNametable0
jsr ClearAttrTable0
jsr ClearSprites
lda #ChrData::Title
jsr LoadChrData
jsr WriteBlankTile
lda #$00
sta AddressPointer0+0
lda #$02
sta AddressPointer0+1
lda #12
ldx #0
jsr WriteTextBuffer
jsr TextClearStringBuffer
ldx #0
stx TextEor
:
lda go_Start, x
sta TextBuffer, x
beq @st_text_done
inx
cpx #18
bne :-
@st_text_done:
jsr TextPrepare
lda #$20
sta AddressPointer0+0
lda #$03
sta AddressPointer0+1
lda #12
ldx #$FF
jsr WriteTextBuffer
jsr WriteTvAttr
lda #ScreenIDs::Tv
ldx #$20
jsr LoadScreen
bit $2002
; Tiles for "Game Over"
lda #$21
sta $2006
lda #$4B
sta $2006
ldx #$20
ldy #12
:
stx $2007
inx
dey
bne :-
; Tiles for "Press Start"
lda #$21
sta $2006
lda #$CA
sta $2006
ldx #$32
ldy #12
:
stx $2007
inx
dey
bne :-
Frame_GameOver:
.NMI_Set NMI_GameOver
lda #PPU_CTRL_NMI | PPU_CTRL_BG_PATTERN
sta PpuControl
jsr ReadControllers
lda #BUTTON_START
jsr ButtonPressedP1
beq :+
jsr WaitForNMI
lda #InitIDs::Title
jmp JumpToInit
:
jsr WaitForNMI
jmp Frame_GameOver
NMI_GameOver:
jsr WriteSprites
jsr WritePalettes
.Update_PpuMask PPU_MASK_ON | PPU_MASK_LEFTSPRITES | PPU_MASK_LEFTBACKGROUND
lda #0
sta $2005
sta $2005
.Update_PpuControl PPU_CTRL_NMI
dec Sleeping
rti