Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/CNZ/SlotDisplay.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Slot Display Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value1 : object.prizePivot.y
13
14
// Frame IDs
15
private alias 0 : SLOTPRIZE_SONIC
16
private alias 1 : SLOTPRIZE_TAILS
17
private alias 2 : SLOTPRIZE_RING // (Amy just replaces the Rings icon, she doesn't get her own slot or anything)
18
private alias 3 : SLOTPRIZE_BAR
19
private alias 4 : SLOTPRIZE_JACKPOT
20
private alias 5 : SLOTPRIZE_EGGMAN
21
private alias 6 : SLOTPRIZE_KNUX // Only Sonic OR Knux can appear at any one time
22
private alias 7 : SLOTPRIZE_SUPER // (Unused)
23
24
25
// ========================
26
// Static Values
27
// ========================
28
29
private value SlotDisplay_needsSetup = 1
30
31
32
// ========================
33
// Tables
34
// ========================
35
36
private table SlotDisplay_sheetY_L
37
3 // SLOTPRIZE_BAR
38
5 // SLOTPRIZE_EGGMAN
39
2 // SLOTPRIZE_RING
40
1 // SLOTPRIZE_TAILS
41
0 // SLOTPRIZE_SONIC
42
4 // SLOTPRIZE_JACKPOT
43
1 // SLOTPRIZE_TAILS
44
2 // SLOTPRIZE_RING
45
end table
46
47
private table SlotDisplay_sheetY_M
48
3 // SLOTPRIZE_BAR
49
5 // SLOTPRIZE_EGGMAN
50
2 // SLOTPRIZE_RING
51
1 // SLOTPRIZE_TAILS
52
0 // SLOTPRIZE_SONIC
53
4 // SLOTPRIZE_JACKPOT
54
5 // SLOTPRIZE_EGGMAN
55
0 // SLOTPRIZE_SONIC
56
end table
57
58
private table SlotDisplay_sheetY_R
59
3 // SLOTPRIZE_BAR
60
5 // SLOTPRIZE_EGGMAN
61
2 // SLOTPRIZE_RING
62
1 // SLOTPRIZE_TAILS
63
0 // SLOTPRIZE_SONIC
64
4 // SLOTPRIZE_JACKPOT
65
1 // SLOTPRIZE_TAILS
66
2 // SLOTPRIZE_RING
67
end table
68
69
// These tables have their values initialized in ObjectStartup
70
71
private table SlotDisplay_sheetX_L
72
1, 1, 1, 1, 1, 1, 1, 1
73
end table
74
75
private table SlotDisplay_sheetX_M
76
1, 1, 1, 1, 1, 1, 1, 1
77
end table
78
79
private table SlotDisplay_sheetX_R
80
1, 1, 1, 1, 1, 1, 1, 1
81
end table
82
83
84
// ========================
85
// Events
86
// ========================
87
88
event ObjectDraw
89
// Slot L - Upper
90
temp0 = SlotMachine_slotPrizeL
91
temp0 >>= 5
92
GetTableValue(temp1, temp0, SlotDisplay_sheetY_L)
93
#platform: USE_ORIGINS
94
GetTableValue(temp3, temp0, SlotDisplay_sheetX_L)
95
#endplatform
96
temp0 = SlotMachine_slotPrizeL
97
temp0 &= 31
98
temp2 = 32
99
temp2 -= temp0
100
object.prizePivot.y = temp0
101
object.prizePivot.y -= 16
102
#platform: USE_STANDALONE
103
EditFrame(0, -48, object.prizePivot.y, 32, temp2, 1, temp1)
104
#endplatform
105
#platform: USE_ORIGINS
106
EditFrame(0, -48, object.prizePivot.y, 32, temp2, temp3, temp1)
107
#endplatform
108
109
// Slot L - Lower
110
temp0 = SlotMachine_slotPrizeL
111
temp0 >>= 5
112
temp0++
113
temp0 &= 7
114
GetTableValue(temp1, temp0, SlotDisplay_sheetY_L)
115
#platform: USE_ORIGINS
116
GetTableValue(temp3, temp0, SlotDisplay_sheetX_L)
117
#endplatform
118
temp0 = SlotMachine_slotPrizeL
119
temp0 &= 31
120
temp2 = 32
121
temp2 -= temp0
122
temp1 += temp2
123
#platform: USE_STANDALONE
124
EditFrame(1, -48, -16, 32, temp0, 1, temp1)
125
#endplatform
126
#platform: USE_ORIGINS
127
EditFrame(1, -48, -16, 32, temp0, temp3, temp1)
128
#endplatform
129
130
// Slot M - Upper
131
temp0 = SlotMachine_slotPrizeM
132
temp0 >>= 5
133
GetTableValue(temp1, temp0, SlotDisplay_sheetY_M)
134
#platform: USE_ORIGINS
135
GetTableValue(temp3, temp0, SlotDisplay_sheetX_M)
136
#endplatform
137
temp0 = SlotMachine_slotPrizeM
138
temp0 &= 31
139
temp2 = 32
140
temp2 -= temp0
141
object.prizePivot.y = temp0
142
object.prizePivot.y -= 16
143
#platform: USE_STANDALONE
144
EditFrame(2, -16, object.prizePivot.y, 32, temp2, 1, temp1)
145
#endplatform
146
#platform: USE_ORIGINS
147
EditFrame(2, -16, object.prizePivot.y, 32, temp2, temp3, temp1)
148
#endplatform
149
150
// Slot M - Lower
151
temp0 = SlotMachine_slotPrizeM
152
temp0 >>= 5
153
temp0++
154
temp0 &= 7
155
GetTableValue(temp1, temp0, SlotDisplay_sheetY_M)
156
#platform: USE_ORIGINS
157
GetTableValue(temp3, temp0, SlotDisplay_sheetX_M)
158
#endplatform
159
temp0 = SlotMachine_slotPrizeM
160
temp0 &= 31
161
temp2 = 32
162
temp2 -= temp0
163
temp1 += temp2
164
#platform: USE_STANDALONE
165
EditFrame(3, -16, -16, 32, temp0, 1, temp1)
166
#endplatform
167
#platform: USE_ORIGINS
168
EditFrame(3, -16, -16, 32, temp0, temp3, temp1)
169
#endplatform
170
171
// Slot R - Upper
172
temp0 = SlotMachine_slotPrizeR
173
temp0 >>= 5
174
GetTableValue(temp1, temp0, SlotDisplay_sheetY_R)
175
#platform: USE_ORIGINS
176
GetTableValue(temp3, temp0, SlotDisplay_sheetX_R)
177
#endplatform
178
temp0 = SlotMachine_slotPrizeR
179
temp0 &= 31
180
temp2 = 32
181
temp2 -= temp0
182
object.prizePivot.y = temp0
183
object.prizePivot.y -= 16
184
#platform: USE_STANDALONE
185
EditFrame(4, 16, object.prizePivot.y, 32, temp2, 1, temp1)
186
#endplatform
187
#platform: USE_ORIGINS
188
EditFrame(4, 16, object.prizePivot.y, 32, temp2, temp3, temp1)
189
#endplatform
190
191
// Slot R - Lower
192
temp0 = SlotMachine_slotPrizeR
193
temp0 >>= 5
194
temp0++
195
temp0 &= 7
196
GetTableValue(temp1, temp0, SlotDisplay_sheetY_R)
197
#platform: USE_ORIGINS
198
GetTableValue(temp3, temp0, SlotDisplay_sheetX_R)
199
#endplatform
200
temp0 = SlotMachine_slotPrizeR
201
temp0 &= 31
202
temp2 = 32
203
temp2 -= temp0
204
temp1 += temp2
205
#platform: USE_STANDALONE
206
EditFrame(5, 16, -16, 32, temp0, 1, temp1)
207
#endplatform
208
#platform: USE_ORIGINS
209
EditFrame(5, 16, -16, 32, temp0, temp3, temp1)
210
#endplatform
211
212
DrawSprite(0)
213
DrawSprite(1)
214
DrawSprite(2)
215
DrawSprite(3)
216
DrawSprite(4)
217
DrawSprite(5)
218
end event
219
220
221
event ObjectStartup
222
LoadSpriteSheet("CNZ/Objects.gif")
223
SpriteFrame(-48, -16, 32, 32, 1, 256) // Slot L (Upper) - #0
224
SpriteFrame(-16, -16, 32, 32, 1, 256) // Slot L (Lower) - #1
225
SpriteFrame( 16, -16, 32, 32, 1, 256) // Slot M (Upper) - #2
226
SpriteFrame(-48, -16, 32, 32, 1, 256) // Slot M (Lower) - #3
227
SpriteFrame(-16, -16, 32, 32, 1, 256) // Slot R (Upper) - #4
228
SpriteFrame( 16, -16, 32, 32, 1, 256) // Slot R (Lower) - #5
229
230
if SlotDisplay_needsSetup == true
231
SlotDisplay_needsSetup = false
232
233
temp0 = 0
234
while temp0 < 8
235
GetTableValue(temp1, temp0, SlotDisplay_sheetY_L)
236
GetTableValue(temp2, temp0, SlotDisplay_sheetY_M)
237
GetTableValue(temp3, temp0, SlotDisplay_sheetY_R)
238
239
#platform: USE_STANDALONE
240
if stage.playerListPos == PLAYER_KNUCKLES_A
241
// Replace all Sonics with Knuckles instead
242
243
if temp1 == SLOTPRIZE_SONIC
244
temp1 = SLOTPRIZE_KNUX
245
end if
246
247
if temp2 == SLOTPRIZE_SONIC
248
temp2 = SLOTPRIZE_KNUX
249
end if
250
251
if temp3 == SLOTPRIZE_SONIC
252
temp3 = SLOTPRIZE_KNUX
253
end if
254
end if
255
#endplatform
256
257
#platform: USE_ORIGINS
258
switch stage.playerListPos
259
case PLAYER_KNUCKLES_A
260
// Replace all Sonics with Knuckles instead
261
262
if temp1 == SLOTPRIZE_SONIC
263
temp1 = SLOTPRIZE_KNUX
264
end if
265
266
if temp2 == SLOTPRIZE_SONIC
267
temp2 = SLOTPRIZE_KNUX
268
end if
269
270
if temp3 == SLOTPRIZE_SONIC
271
temp3 = SLOTPRIZE_KNUX
272
end if
273
break
274
275
case PLAYER_AMY_A
276
// Replace all Sonics with... Rings, and apply Amy's sprite to them
277
// 34 is the x position of Amy's icon in the spritesheet
278
279
if temp1 == SLOTPRIZE_SONIC
280
SetTableValue(34, temp0, SlotDisplay_sheetX_L)
281
temp1 = SLOTPRIZE_RING
282
end if
283
284
if temp2 == SLOTPRIZE_SONIC
285
SetTableValue(34, temp0, SlotDisplay_sheetX_M)
286
temp2 = SLOTPRIZE_RING
287
end if
288
289
if temp3 == SLOTPRIZE_SONIC
290
SetTableValue(34, temp0, SlotDisplay_sheetX_R)
291
temp3 = SLOTPRIZE_RING
292
end if
293
break
294
end switch
295
#endplatform
296
297
temp1 <<= 5
298
temp1 += 0x100
299
300
temp2 <<= 5
301
temp2 += 0x100
302
303
temp3 <<= 5
304
temp3 += 0x100
305
306
SetTableValue(temp1, temp0, SlotDisplay_sheetY_L)
307
SetTableValue(temp2, temp0, SlotDisplay_sheetY_M)
308
SetTableValue(temp3, temp0, SlotDisplay_sheetY_R)
309
310
temp0++
311
loop
312
end if
313
end event
314
315
316
// ========================
317
// Editor Events
318
// ========================
319
320
event RSDKDraw
321
DrawSprite(0)
322
DrawSprite(1)
323
DrawSprite(2)
324
end event
325
326
327
event RSDKLoad
328
LoadSpriteSheet("CNZ/Objects.gif")
329
SpriteFrame(-48, -16, 32, 32, 1, 256) // Slot L - Sonic
330
SpriteFrame(-16, -16, 32, 32, 1, 416) // Slot M - Eggman
331
SpriteFrame( 16, -16, 32, 32, 1, 384) // Slot R - Jackpot!
332
333
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
334
end event
335
336