-
Notifications
You must be signed in to change notification settings - Fork 3
/
hard-drop-taus.s
99 lines (80 loc) · 2.52 KB
/
hard-drop-taus.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
;
; Hard drop
; Originally by Stephen Sherratt (stevebob, gridbugs)
; Reimplemented from https://github.com/gridbugs/mos6502/tree/main/tetris-hard-drop-patcher
;
.include "build/tetris.inc"
.include "ips.inc"
HINT_PATTERN_INDEX = $FA
EMPTY_TILE = $EF
BOARD_HEIGHT = 20
CONTROLLER_BIT_UP = $08
.ifndef HIDE_GHOST_PIECE
.segment "IPSCHR"
ips_tile_segment "IPSCHR",CHR01+CHR_RIGHT,HINT_PATTERN_INDEX
; hint pattern
.incbin "hard-drop-taus.chr"
.endif
.segment "stageSpriteForCurrentPiecePlayer1"
ips_segment "stageSpriteForCurrentPiecePlayer1",gameModeState_updatePlayer1+6
; replaces "jsr stageSpriteForCurrentPiece"
jsr oam_dma_page_update
.segment "stageSpriteForCurrentPiecePlayer2"
ips_segment "stageSpriteForCurrentPiecePlayer2",gameModeState_updatePlayer2+12
; replaces "jsr stageSpriteForCurrentPiece"
jsr oam_dma_page_update
.segment "playState_playerControlsActiveTetrimino"
ips_segment "playState_playerControlsActiveTetrimino",playState_playerControlsActiveTetrimino
; replaces "jsr shift_tetrimino"
jsr controls
.segment "playState_player2ControlsActiveTetrimino"
ips_segment "playState_player2ControlsActiveTetrimino",playState_player2ControlsActiveTetrimino
; replaces "jsr shift_tetrimino"
jsr controls
.segment "CODE"
; Hold follows in unreferenced_data1.
ips_segment "CODE",unreferenced_data1,$4C
drop_piece:
ldx tetriminoY
stx originalY
@tryLowerPosition:
inc tetriminoY
jsr isPositionValid
beq @tryLowerPosition
dec tetriminoY
lda tetriminoY
sec
sbc originalY
rts
oam_dma_page_update:
jsr stageSpriteForCurrentPiece
.ifndef HIDE_GHOST_PIECE
jsr drop_piece
beq @after_render_hint
lda originalY
pha
jsr stageSpriteForCurrentPiece
pla
sta tetriminoY
lda #HINT_PATTERN_INDEX
ldx oamStagingLength
sta oamStaging-3 ,x
sta oamStaging-3- 4,x
sta oamStaging-3- 8,x
sta oamStaging-3-12,x
.endif
@after_render_hint:
rts
controls:
jsr shift_tetrimino
lda heldButtons
and #CONTROLLER_BIT_UP
beq @controller_end
jsr drop_piece
sta holdDownPoints
lda #$00
sta autorepeatY
lda dropSpeed
sta fallTimer
@controller_end:
rts