SHOW:
|
|
- or go back to the newest paste.
1 | ; ALTTP One-Mind hack: causes the current player in control of Link to switch every so often. | |
2 | ; In places where this does not occur (e.g. title screen), both controllers are registered. | |
3 | ; Save this text file as an ASM file and patch it to your rom with Asar. | |
4 | ; A few extra options for adjusting timing are below. | |
5 | ||
6 | ;;;; Timing | |
7 | ||
8 | !count_silent = $08 ; Number of silent ticks before audible ones | |
9 | !count_audible = $04 ; Number of audible ticks before the controller switches | |
10 | !tickTiming = $1F ; Number of frames between ticks (valid: 01, 03, 07, 0F, 1F, 3F, 7F, FF) | |
11 | ||
12 | ; Hard mode: set silent to 1, audible to 1. | |
13 | ||
14 | ;;;; SFX | |
15 | ||
16 | !SFX_Tick = $06 ; SFX values for the tick noise. | |
17 | !SFXIO_Tick = $012E | |
18 | !SFX_Switch = $25 ; SFX values for when the players switch. | |
19 | !SFXIO_Switch = $012F | |
20 | ||
21 | ||
22 | ;;;; Technical | |
23 | ||
24 | !freeram = $7F9000 ; 2 bytes of free ram to use. | |
25 | ||
26 | ||
27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
28 | ;; Code begins; don't touch it unless you know what you're doing. | |
29 | ||
30 | !active = !freeram ; 1 byte - currently active player | |
31 | !ticks = !freeram+1 ; 1 byte - counter for the number of ticks so far | |
32 | ||
33 | ||
34 | org $0083D1 | |
35 | autoclean JSL OneMind | |
36 | BRA $05 | |
37 | ||
38 | freecode | |
39 | OneMind: | |
40 | PHB : PHK : PLB | |
41 | JSR Main | |
42 | PLB | |
43 | RTL | |
44 | ||
45 | Main: | |
46 | ; Check whether in a mode we allow switching in. | |
47 | ; If not, register both controllers. | |
48 | LDA $10 | |
49 | CMP #$07 ; normal play - interior | |
50 | BEQ .acceptable | |
51 | CMP #$09 ; normal play - exterior | |
52 | BEQ .acceptable | |
53 | CMP #$0E ; normal play - text box, pause screen, map screen | |
54 | BEQ .acceptable | |
55 | BRA SetBothControllers | |
56 | .acceptable | |
57 | ||
58 | ; Good to go. | |
59 | LDA $1A | |
60 | AND #!tickTiming | |
61 | BNE SetControllers | |
62 | LDA !ticks | |
63 | INC | |
64 | CMP #!count_silent | |
65 | BCC .silentTick | |
66 | CMP #!count_silent+!count_audible | |
67 | BCC .tick | |
68 | JSR SwitchPlayers | |
69 | BRA SetControllers | |
70 | .tick | |
71 | LDY #!SFX_Tick | |
72 | STY !SFXIO_Tick | |
73 | .silentTick | |
74 | STA !ticks | |
75 | ||
76 | SetControllers: | |
77 | LDA !active | |
78 | AND #$01 | |
79 | BNE .c2 | |
80 | .c1 | |
81 | LDA $4218 | |
82 | STA $00 | |
83 | LDA $4219 | |
84 | RTS | |
85 | .c2 | |
86 | LDA $421A | |
87 | STA $00 | |
88 | LDA $421B | |
89 | RTS | |
90 | ||
91 | SetBothControllers: | |
92 | LDA $4218 | |
93 | ORA $421A | |
94 | STA $00 | |
95 | LDA $4219 | |
96 | ORA $421B | |
97 | RTS | |
98 | ||
99 | ||
100 | ||
101 | SwitchPlayers: | |
102 | LDA #$00 | |
103 | STA !ticks | |
104 | LDA !active | |
105 | INC | |
106 | STA !active | |
107 | LDA #!SFX_Switch | |
108 | STA !SFXIO_Switch | |
109 | ||
110 | REP #$30 | |
111 | LDA $7EF35B | |
112 | AND #$00FF | |
113 | TAX | |
114 | LDA !active | |
115 | AND #$0001 | |
116 | BNE .p2pal | |
117 | LDA $1BEC06,x | |
118 | AND #$00FF | |
119 | ASL | |
120 | ADC #$D308 | |
121 | STA $00 | |
122 | LDA #$001B | |
123 | STA $02 | |
124 | BRA .paletteUpload | |
125 | .p2pal | |
126 | TXA | |
127 | ASL | |
128 | TAX | |
129 | LDA P2Palettes,x | |
130 | STA $00 | |
131 | LDA.w #P2PalA>>16 | |
132 | STA $02 | |
133 | ||
134 | .paletteUpload | |
135 | LDY #$000E | |
136 | LDX #$01E2 | |
137 | ||
138 | - LDA [$00] | |
139 | STA $7EC300,X | |
140 | STA $7EC500,X | |
141 | INC $00 | |
142 | INC $00 | |
143 | INX | |
144 | INX | |
145 | DEY | |
146 | BPL - | |
147 | SEP #$30 | |
148 | INC $15 | |
149 | RTS | |
150 | ||
151 | ||
152 | P2Palettes: | |
153 | dw P2PalA,P2PalB,P2PalC | |
154 | ||
155 | ; Player 2 palette data. Feel free to mess with it if you know how. | |
156 | P2PalA: ; green mail | |
157 | dw $7FFF,$237E,$11B7,$369E,$14A5 | |
158 | dw $01FF,$1078,$599D,$1CF3,$2CFC | |
159 | dw $0415,$101C,$2A5C,$1571,$7A18 | |
160 | P2PalB: ; blue mail | |
161 | dw $7FFF,$237E,$11B7,$369E,$14A5 | |
162 | dw $01FF,$1078,$599D,$0A1D,$2B3D | |
163 | dw $6132,$7E17,$2A5C,$1199,$7A18 | |
164 | P2PalC: ; red mail | |
165 | dw $7FFF,$237E,$11B7,$369E,$14A5 | |
166 | dw $01FF,$1078,$599D,$62C2,$73EB | |
167 | dw $2B28,$3FCB,$2A5C,$2227,$7A18 |