Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/MZ/UFO.txt
1481 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: UFO Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// Reserved Object Slot Aliases
13
// (The UFO object occupies the slot the Title Card is initially in)
14
private alias 11 : SLOT_TITLECARD
15
16
17
// ========================
18
// Function Declarations
19
// ========================
20
21
reserve function UFO_DebugDraw
22
reserve function UFO_DebugSpawn
23
24
25
// ========================
26
// Function Definitions
27
// ========================
28
29
private function UFO_DebugDraw
30
DrawSprite(0)
31
end function
32
33
34
private function UFO_DebugSpawn
35
// Place one... and then clear it?
36
// The actual UFO placing is done below, a fake one is placed because Debug Mode does an operation with tempObjectPos after running the DebugSpawn function
37
CreateTempObject(TypeName[UFO], 0, object.xpos, object.ypos)
38
object[tempObjectPos].type = TypeName[Blank Object]
39
40
// There can only be 1 UFO object at a time since they occupy the Title Card object slot, so let's see if they exist and either add them or remove them
41
if object[SLOT_TITLECARD].type == TypeName[UFO]
42
// If the UFOs already exist, clear them
43
ResetObjectEntity(SLOT_TITLECARD, TypeName[Blank Object], 0, 0, 0)
44
else
45
// If they don't exist, then spawn them
46
ResetObjectEntity(SLOT_TITLECARD, TypeName[UFO], 0, 0, 0)
47
object[SLOT_TITLECARD].priority = PRIORITY_ACTIVE
48
object[SLOT_TITLECARD].drawOrder = 1 // Place it among the lowest draw order, it's supposed to be drawn as part of the BG
49
object[SLOT_TITLECARD].inkEffect = INK_ALPHA
50
end if
51
end function
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
// Animate the UFOs
60
object.frame = object.animationTimer
61
object.frame >>= 3
62
63
object.animationTimer++
64
object.animationTimer &= 63
65
end event
66
67
68
event ObjectDraw
69
if screen.yoffset < 640
70
temp0 = screen.xoffset
71
temp0 >>= 3
72
temp0 &= 0x7F
73
FlipSign(temp0)
74
75
// temp1 is the base pos for the UFOs to draw at
76
temp1 = tileLayer[1].scrollPos
77
temp1 /= -0x10000
78
temp1 += 32
79
80
// First draw the "closer" set of UFOs
81
temp2 = screen.xsize
82
temp2 += 32
83
temp5 = oscillation
84
temp5 <<= 1
85
while temp0 < temp2
86
temp3 = temp0
87
temp3 += temp5
88
89
Sin(temp4, temp3)
90
temp4 >>= 5
91
temp4 += temp1
92
93
Cos(object.alpha, temp3)
94
object.alpha >>= 2
95
object.alpha += 128
96
97
DrawSpriteScreenFX(object.frame, FX_INK, temp0, temp4)
98
99
temp0 += 64
100
loop
101
102
// And then draw the "further" set of UFOs
103
temp0 = screen.xoffset
104
temp0 >>= 4
105
temp0 &= 0x7F
106
temp0 += 32
107
FlipSign(temp0)
108
while temp0 < temp2
109
temp3 = temp0
110
temp3 += temp5
111
112
Sin(temp4, temp3)
113
temp4 >>= 5
114
FlipSign(temp4)
115
temp4 += temp1
116
117
Cos(object.alpha, temp3)
118
object.alpha >>= 2
119
FlipSign(object.alpha)
120
object.alpha += 128
121
122
DrawSpriteScreenFX(object.frame, FX_INK, temp0, temp4)
123
124
temp0 += 64
125
loop
126
end if
127
end event
128
129
130
event ObjectStartup
131
LoadSpriteSheet("MZ/Objects.gif")
132
133
// UFO frames
134
SpriteFrame(-16, -8, 32, 16, 123, 303)
135
SpriteFrame(-16, -8, 32, 16, 156, 230)
136
SpriteFrame(-16, -12, 32, 24, 123, 247)
137
SpriteFrame(-16, -15, 32, 30, 123, 272)
138
SpriteFrame(-16, -16, 32, 32, 130, 355)
139
SpriteFrame(-16, -15, 32, 30, 156, 273)
140
SpriteFrame(-16, -12, 32, 25, 156, 247)
141
SpriteFrame(-16, -8, 32, 16, 123, 230)
142
143
// Add UFOs to the stage's debug object list
144
SetTableValue(TypeName[UFO], DebugMode_ObjCount, DebugMode_TypesTable)
145
SetTableValue(UFO_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
146
SetTableValue(UFO_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
147
DebugMode_ObjCount++
148
end event
149
150
151
// ========================
152
// Editor Events
153
// ========================
154
155
event RSDKDraw
156
DrawSprite(0)
157
end event
158
159
160
event RSDKLoad
161
LoadSpriteSheet("MZ/Objects.gif")
162
SpriteFrame(-16, -8, 32, 16, 123, 303)
163
164
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
165
end event
166
167