Super Mario 64s source code (from a leak on 4chan so be careful)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

429 lines
6.6 KiB

6 years ago
  1. .include "model_ids.inc"
  2. .include "seq_ids.inc"
  3. .set OP_AND, 0
  4. .set OP_NAND, 1
  5. .set OP_EQ, 2
  6. .set OP_NEQ, 3
  7. .set OP_LT, 4
  8. .set OP_LEQ, 5
  9. .set OP_GT, 6
  10. .set OP_GEQ, 7
  11. .set OP_SET, 0
  12. .set OP_GET, 1
  13. .set VAR_CURR_SAVE_FILE_NUM, 0
  14. .set VAR_CURR_COURSE_NUM, 1
  15. .set VAR_CURR_ACT_NUM, 2
  16. .set VAR_CURR_LEVEL_NUM, 3
  17. .set VAR_CURR_AREA_INDEX, 4
  18. .macro execute seg, script, scriptEnd, entry
  19. .byte 0x00, 0x10
  20. .hword \seg
  21. .word \script
  22. .word \scriptEnd
  23. .word \entry
  24. .endm
  25. .macro exit_and_execute seg, script, scriptEnd, entry
  26. .byte 0x01, 0x10
  27. .hword \seg
  28. .word \script
  29. .word \scriptEnd
  30. .word \entry
  31. .endm
  32. .macro exit
  33. .byte 0x02, 0x04
  34. .hword 0
  35. .endm
  36. .macro sleep frames
  37. .byte 0x03, 0x04
  38. .hword \frames
  39. .endm
  40. .macro sleep_before_exit frames
  41. .byte 0x04, 0x04
  42. .hword \frames
  43. .endm
  44. .macro jump target
  45. .byte 0x05, 0x08
  46. .hword 0
  47. .word \target
  48. .endm
  49. .macro jump_link target
  50. .byte 0x06, 0x08
  51. .hword 0
  52. .word \target
  53. .endm
  54. .macro return
  55. .byte 0x07, 0x04
  56. .hword 0
  57. .endm
  58. .macro jump_link_push_arg arg
  59. .byte 0x08, 0x04
  60. .hword \arg
  61. .endm
  62. .macro jump_n_times
  63. .byte 0x09, 0x04
  64. .hword 0
  65. .endm
  66. .macro loop_begin
  67. .byte 0x0A, 0x04
  68. .hword 0
  69. .endm
  70. .macro loop_until op, arg
  71. .byte 0x0B, 0x08
  72. .byte \op
  73. .byte 0
  74. .word \arg
  75. .endm
  76. .macro jump_if op, arg, target
  77. .byte 0x0C, 0x0C
  78. .byte \op
  79. .byte 0
  80. .word \arg
  81. .word \target
  82. .endm
  83. .macro jump_link_if op, arg, target
  84. .byte 0x0D, 0x0C
  85. .byte \op
  86. .byte 0
  87. .word \arg
  88. .word \target
  89. .endm
  90. .macro skip_if op, arg
  91. .byte 0x0E, 0x08
  92. .byte \op
  93. .byte 0
  94. .word \arg
  95. .endm
  96. .macro skip
  97. .byte 0x0F, 0x04
  98. .hword 0
  99. .endm
  100. .macro skip_nop
  101. .byte 0x10, 0x04
  102. .hword 0
  103. .endm
  104. .macro call arg, func
  105. .byte 0x11, 0x08
  106. .hword \arg
  107. .word \func
  108. .endm
  109. .macro call_loop arg, func
  110. .byte 0x12, 0x08
  111. .hword \arg
  112. .word \func
  113. .endm
  114. .macro set_reg value
  115. .byte 0x13, 0x04
  116. .hword \value
  117. .endm
  118. .macro push_pool
  119. .byte 0x14, 0x04
  120. .hword 0
  121. .endm
  122. .macro pop_pool
  123. .byte 0x15, 0x04
  124. .hword 0
  125. .endm
  126. .macro fixed_load loadAddr, romStart, romEnd
  127. .byte 0x16, 0x10
  128. .hword 0
  129. .word \loadAddr
  130. .word \romStart
  131. .word \romEnd
  132. .endm
  133. .macro load_raw seg, romStart, romEnd
  134. .byte 0x17, 0x0C
  135. .hword \seg
  136. .word \romStart
  137. .word \romEnd
  138. .endm
  139. .macro load_mio0 seg, romStart, romEnd
  140. .byte 0x18, 0x0C
  141. .hword \seg
  142. .word \romStart
  143. .word \romEnd
  144. .endm
  145. .macro load_mario_head sethead
  146. .byte 0x19, 0x04
  147. .hword \sethead
  148. .endm
  149. .macro load_mio0_texture seg, romStart, romEnd
  150. .byte 0x1A, 0x0C
  151. .hword \seg
  152. .word \romStart
  153. .word \romEnd
  154. .endm
  155. .macro init_level
  156. .byte 0x1B, 0x04
  157. .hword 0
  158. .endm
  159. .macro clear_level
  160. .byte 0x1C, 0x04
  161. .hword 0
  162. .endm
  163. .macro alloc_level_pool
  164. .byte 0x1D, 0x04
  165. .hword 0
  166. .endm
  167. .macro free_level_pool
  168. .byte 0x1E, 0x04
  169. .hword 0
  170. .endm
  171. .macro area index, geo
  172. .byte 0x1F, 0x08
  173. .byte \index
  174. .byte 0
  175. .word \geo
  176. .endm
  177. .macro end_area
  178. .byte 0x20, 0x04
  179. .hword 0
  180. .endm
  181. .macro load_model_from_dl model, dl, layer
  182. .byte 0x21, 0x08
  183. .hword (\layer << 8) | \model
  184. .word \dl
  185. .endm
  186. .macro load_model_from_geo model, geo
  187. .byte 0x22, 0x08
  188. .hword \model
  189. .word \geo
  190. .endm
  191. .macro cmd23 model, unk4, unk8
  192. .byte 0x23, 0x0C
  193. .hword \model
  194. .word \unk4
  195. .word \unk8
  196. .endm
  197. .macro object model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, acts=0x1F
  198. .byte 0x24, 0x18
  199. .byte \acts
  200. .byte \model
  201. .hword \posX
  202. .hword \posY
  203. .hword \posZ
  204. .hword \angleX
  205. .hword \angleY
  206. .hword \angleZ
  207. .word \behParam
  208. .word \beh
  209. .endm
  210. .macro mario unk3, behArg, beh
  211. .byte 0x25, 0x0C
  212. .byte 0
  213. .byte \unk3
  214. .word \behArg
  215. .word \beh
  216. .endm
  217. .macro warp_node id, destLevel, destArea, destNode, unk6
  218. .byte 0x26, 0x08
  219. .byte \id, \destLevel, \destArea, \destNode
  220. .hword \unk6
  221. .endm
  222. .macro painting_warp_node id, destLevel, destArea, destNode, unk6
  223. .byte 0x27, 0x08
  224. .byte \id, \destLevel, \destArea, \destNode
  225. .hword \unk6
  226. .endm
  227. .macro instant_warp index, destArea, displaceX, displaceY, displaceZ
  228. .byte 0x28, 0x0C
  229. .byte \index
  230. .byte \destArea
  231. .hword \displaceX
  232. .hword \displaceY
  233. .hword \displaceZ
  234. .hword 0
  235. .endm
  236. .macro load_area area
  237. .byte 0x29, 0x04
  238. .byte \area
  239. .byte 0
  240. .endm
  241. .macro cmd2A unk2
  242. .byte 0x2A, 0x04
  243. .byte \unk2
  244. .byte 0
  245. .endm
  246. .macro mario_pos area, yaw, posX, posY, posZ
  247. .byte 0x2B, 0x0C
  248. .byte \area
  249. .byte 0
  250. .hword \yaw
  251. .hword \posX
  252. .hword \posY
  253. .hword \posZ
  254. .endm
  255. .macro cmd2C
  256. .byte 0x2C, 0x04
  257. .hword 0
  258. .endm
  259. .macro cmd2D
  260. .byte 0x2D, 0x04
  261. .hword 0
  262. .endm
  263. .macro terrain terrainData
  264. .byte 0x2E, 0x08
  265. .hword 0
  266. .word \terrainData
  267. .endm
  268. .macro rooms surfaceRooms
  269. .byte 0x2F, 0x08
  270. .hword 0
  271. .word \surfaceRooms
  272. .endm
  273. .macro show_dialog unk2, unk3
  274. .byte 0x30, 0x04
  275. .byte \unk2
  276. .byte \unk3
  277. .endm
  278. .macro terrain_type terrainType
  279. .byte 0x31, 0x04
  280. .hword \terrainType
  281. .endm
  282. .macro nop
  283. .byte 0x32, 0x04
  284. .hword 0
  285. .endm
  286. .macro transition unk2, unk3, colorR, colorG, colorB
  287. .byte 0x33, 0x08
  288. .byte \unk2
  289. .byte \unk3
  290. .byte \colorR
  291. .byte \colorG
  292. .byte \colorB
  293. .byte 0
  294. .endm
  295. .macro blackout active
  296. .byte 0x34, 0x04
  297. .byte \active
  298. .byte 0
  299. .endm
  300. .macro gamma enabled
  301. .byte 0x35, 0x04
  302. .byte \enabled
  303. .byte 0
  304. .endm
  305. .macro set_music unk2, seq
  306. .byte 0x36, 0x08
  307. .hword \unk2
  308. .hword \seq
  309. .hword 0
  310. .endm
  311. .macro set_menu_music seq
  312. .byte 0x37, 0x04
  313. .hword \seq
  314. .endm
  315. .macro cmd38 unk2
  316. .byte 0x38, 0x04
  317. .hword \unk2
  318. .endm
  319. .macro macro_objects objList
  320. .byte 0x39, 0x08
  321. .hword 0
  322. .word \objList
  323. .endm
  324. .macro cmd3A unk2, unk4, unk6, unk8, unk10
  325. .byte 0x3A, 0x0C
  326. .hword \unk2
  327. .hword \unk4
  328. .hword \unk6
  329. .hword \unk8
  330. .hword \unk10
  331. .endm
  332. .macro whirlpool unk2, unk3, posX, posY, posZ, strength
  333. .byte 0x3B, 0x0C
  334. .byte \unk2
  335. .byte \unk3
  336. .hword \posX
  337. .hword \posY
  338. .hword \posZ
  339. .hword \strength
  340. .endm
  341. .macro get_or_set op, var
  342. .byte 0x3C, 0x04
  343. .byte \op
  344. .byte \var
  345. .endm
  346. /* Layer Defines */
  347. # drawing layers
  348. .set LAYER_NULL, 0x00
  349. .set LAYER_OPAQUE, 0x10
  350. .set LAYER_OPAQUE_DECAL, 0x20
  351. .set LAYER_UNUSED_03, 0x30
  352. .set LAYER_ALPHA, 0x40
  353. .set LAYER_TRANSPARENT, 0x50
  354. .set LAYER_TRANSPARENT_DECAL, 0x60
  355. /* Head Defines */
  356. .set REGULAR_FACE, 0x0002
  357. .set DIZZY_FACE, 0x0003