-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscreens.s
140 lines (121 loc) · 3.52 KB
/
screens.s
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
;
; Display the various screens of Tetris
;
.include "build/tetris.inc"
.include "ips.inc"
.segment "HUNK1"
ips_segment "HUNK1",$800E
; at nmi, replaces "jsr render"
nop
nop
nop
.segment "JMP_MAIN_LOOP_ITER"
ips_segment "JMP_MAIN_LOOP_ITER",$8138
; at mainLoop, replaces "jsr branchOnGameMode"
jsr mainLoopIterMod
.segment "CODE"
ips_segment "CODE",unreferenced_data1,$0637
screenToDisplay := levelNumber
backgroundRendered := levelNumber+1
mainLoopIterMod:
lda newlyPressedButtons_player1
beq @checkForRender
lda #$00
sta backgroundRendered
inc screenToDisplay
lda screenToDisplay
cmp #screens
bne @checkForRender
lda #$00
sta screenToDisplay
@checkForRender:
lda backgroundRendered
bne @return
inc backgroundRendered
jsr load_background
@return:
lda #$00 ; wait for vsync
sta $A7
rts
load_background:
jsr updateAudioWaitForNmiAndDisablePpuRendering
jsr disableNmi
lda #$10
jsr setMMC1Control
ldx screenToDisplay
lda bank0s,x
jsr changeCHRBank0
ldx screenToDisplay
lda bank1s,x
jsr changeCHRBank1
lda screenToDisplay
jsr my_bulkCopyToPpu
lda screenToDisplay
clc
adc #screens
jsr my_bulkCopyToPpu
; screen-specific hacks
lda screenToDisplay
cmp #$07
bpl @continue
jsr switchOnA
.addr @continue
.addr @continue
.addr @continue
.addr @levelMenuTypeA
.addr @levelMenuTypeB
.addr @continue
.addr @highScoreEntry
@levelMenuTypeA:
jsr bulkCopyToPpu
.addr height_menu_nametablepalette_patch
; fall-through
@levelMenuTypeB:
@highScoreEntry:
; This is necessary on type a, since the height menu patch overwrites
; the high score table (unnecessarily). On type b it appears to have
; no impact. On high score entry it messes up the background (a bug).
jsr bulkCopyToPpu
.addr high_scores_nametable
; fall-through
@continue:
jsr waitForVBlankAndEnableNmi
jsr updateAudioWaitForNmiAndEnablePpuRendering
rts
; index passed as 'a'
my_bulkCopyToPpu:
asl a
tax
lda palettes,x ; will read into nametables as well
sta tmp1
lda palettes+1,x
sta tmp2
jsr bulkCopyToPpu+3
rts
screens = 10
bank0s:
.byte 0, 0, 0, 0, 0, 3, 0, 2, 2, 1
bank1s:
.byte 0, 0, 0, 0, 0, 3, 0, 2, 2, 1
palettes:
.addr legal_screen_palette
.addr menu_palette
.addr menu_palette
.addr menu_palette
.addr menu_palette
.addr game_palette
.addr menu_palette
.addr ending_palette
.addr ending_palette
.addr ending_palette
nametables:
.addr legal_screen_nametable
.addr title_screen_nametable
.addr game_type_menu_nametable
.addr level_menu_nametable
.addr level_menu_nametable
.addr game_nametable
.addr enter_high_score_nametable
.addr type_a_ending_nametable
.addr type_b_ending_nametable
.addr type_b_lvl9_ending_nametable