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.

444 lines
11 KiB

6 years ago
  1. #ifndef _ABI_H_
  2. #define _ABI_H_
  3. /**************************************************************************
  4. * *
  5. * Copyright (C) 1994, Silicon Graphics, Inc. *
  6. * *
  7. * These coded instructions, statements, and computer programs contain *
  8. * unpublished proprietary information of Silicon Graphics, Inc., and *
  9. * are protected by Federal copyright law. They may not be disclosed *
  10. * to third parties or copied or duplicated in any form, in whole or *
  11. * in part, without the prior written consent of Silicon Graphics, Inc. *
  12. * *
  13. **************************************************************************/
  14. /**************************************************************************
  15. *
  16. * $Revision: 1.32 $
  17. * $Date: 1997/02/11 08:16:37 $
  18. * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/abi.h,v $
  19. *
  20. **************************************************************************/
  21. /*
  22. * Header file for the Audio Binary Interface.
  23. * This is included in the Media Binary Interface file
  24. * mbi.h.
  25. *
  26. * This file follows the framework used for graphics.
  27. *
  28. */
  29. /* Audio commands: */
  30. #define A_SPNOOP 0
  31. #define A_ADPCM 1
  32. #define A_CLEARBUFF 2
  33. #define A_ENVMIXER 3
  34. #define A_LOADBUFF 4
  35. #define A_RESAMPLE 5
  36. #define A_SAVEBUFF 6
  37. #define A_SEGMENT 7
  38. #define A_SETBUFF 8
  39. #define A_SETVOL 9
  40. #define A_DMEMMOVE 10
  41. #define A_LOADADPCM 11
  42. #define A_MIXER 12
  43. #define A_INTERLEAVE 13
  44. #define A_POLEF 14
  45. #define A_SETLOOP 15
  46. #define ACMD_SIZE 32
  47. /*
  48. * Audio flags
  49. */
  50. #define A_INIT 0x01
  51. #define A_CONTINUE 0x00
  52. #define A_LOOP 0x02
  53. #define A_OUT 0x02
  54. #define A_LEFT 0x02
  55. #define A_RIGHT 0x00
  56. #define A_VOL 0x04
  57. #define A_RATE 0x00
  58. #define A_AUX 0x08
  59. #define A_NOAUX 0x00
  60. #define A_MAIN 0x00
  61. #define A_MIX 0x10
  62. /*
  63. * BEGIN C-specific section: (typedef's)
  64. */
  65. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  66. /*
  67. * Data Structures.
  68. */
  69. typedef struct {
  70. unsigned int cmd:8;
  71. unsigned int flags:8;
  72. unsigned int gain:16;
  73. unsigned int addr;
  74. } Aadpcm;
  75. typedef struct {
  76. unsigned int cmd:8;
  77. unsigned int flags:8;
  78. unsigned int gain:16;
  79. unsigned int addr;
  80. } Apolef;
  81. typedef struct {
  82. unsigned int cmd:8;
  83. unsigned int flags:8;
  84. unsigned int pad1:16;
  85. unsigned int addr;
  86. } Aenvelope;
  87. typedef struct {
  88. unsigned int cmd:8;
  89. unsigned int pad1:8;
  90. unsigned int dmem:16;
  91. unsigned int pad2:16;
  92. unsigned int count:16;
  93. } Aclearbuff;
  94. typedef struct {
  95. unsigned int cmd:8;
  96. unsigned int pad1:8;
  97. unsigned int pad2:16;
  98. unsigned int inL:16;
  99. unsigned int inR:16;
  100. } Ainterleave;
  101. typedef struct {
  102. unsigned int cmd:8;
  103. unsigned int pad1:24;
  104. unsigned int addr;
  105. } Aloadbuff;
  106. typedef struct {
  107. unsigned int cmd:8;
  108. unsigned int flags:8;
  109. unsigned int pad1:16;
  110. unsigned int addr;
  111. } Aenvmixer;
  112. typedef struct {
  113. unsigned int cmd:8;
  114. unsigned int flags:8;
  115. unsigned int gain:16;
  116. unsigned int dmemi:16;
  117. unsigned int dmemo:16;
  118. } Amixer;
  119. typedef struct {
  120. unsigned int cmd:8;
  121. unsigned int flags:8;
  122. unsigned int dmem2:16;
  123. unsigned int addr;
  124. } Apan;
  125. typedef struct {
  126. unsigned int cmd:8;
  127. unsigned int flags:8;
  128. unsigned int pitch:16;
  129. unsigned int addr;
  130. } Aresample;
  131. typedef struct {
  132. unsigned int cmd:8;
  133. unsigned int flags:8;
  134. unsigned int pad1:16;
  135. unsigned int addr;
  136. } Areverb;
  137. typedef struct {
  138. unsigned int cmd:8;
  139. unsigned int pad1:24;
  140. unsigned int addr;
  141. } Asavebuff;
  142. typedef struct {
  143. unsigned int cmd:8;
  144. unsigned int pad1:24;
  145. unsigned int pad2:2;
  146. unsigned int number:4;
  147. unsigned int base:24;
  148. } Asegment;
  149. typedef struct {
  150. unsigned int cmd:8;
  151. unsigned int flags:8;
  152. unsigned int dmemin:16;
  153. unsigned int dmemout:16;
  154. unsigned int count:16;
  155. } Asetbuff;
  156. typedef struct {
  157. unsigned int cmd:8;
  158. unsigned int flags:8;
  159. unsigned int vol:16;
  160. unsigned int voltgt:16;
  161. unsigned int volrate:16;
  162. } Asetvol;
  163. typedef struct {
  164. unsigned int cmd:8;
  165. unsigned int pad1:8;
  166. unsigned int dmemin:16;
  167. unsigned int dmemout:16;
  168. unsigned int count:16;
  169. } Admemmove;
  170. typedef struct {
  171. unsigned int cmd:8;
  172. unsigned int pad1:8;
  173. unsigned int count:16;
  174. unsigned int addr;
  175. } Aloadadpcm;
  176. typedef struct {
  177. unsigned int cmd:8;
  178. unsigned int pad1:8;
  179. unsigned int pad2:16;
  180. unsigned int addr;
  181. } Asetloop;
  182. /*
  183. * Generic Acmd Packet
  184. */
  185. typedef struct {
  186. unsigned int w0;
  187. unsigned int w1;
  188. } Awords;
  189. typedef union {
  190. Awords words;
  191. Aadpcm adpcm;
  192. Apolef polef;
  193. Aclearbuff clearbuff;
  194. Aenvelope envelope;
  195. Ainterleave interleave;
  196. Aloadbuff loadbuff;
  197. Aenvmixer envmixer;
  198. Aresample resample;
  199. Areverb reverb;
  200. Asavebuff savebuff;
  201. Asegment segment;
  202. Asetbuff setbuff;
  203. Asetvol setvol;
  204. Admemmove dmemmove;
  205. Aloadadpcm loadadpcm;
  206. Amixer mixer;
  207. Asetloop setloop;
  208. long long int force_union_align; /* dummy, force alignment */
  209. } Acmd;
  210. /*
  211. * ADPCM State
  212. */
  213. #define ADPCMVSIZE 8
  214. #define ADPCMFSIZE 16
  215. typedef short ADPCM_STATE[ADPCMFSIZE];
  216. /*
  217. * Pole filter state
  218. */
  219. typedef short POLEF_STATE[4];
  220. /*
  221. * Resampler state
  222. */
  223. typedef short RESAMPLE_STATE[16];
  224. /*
  225. * Resampler constants
  226. */
  227. #define UNITY_PITCH 0x8000
  228. #define MAX_RATIO 1.99996 /* within .03 cents of +1 octave */
  229. /*
  230. * Enveloper/Mixer state
  231. */
  232. typedef short ENVMIX_STATE[40];
  233. /*
  234. * Macros to assemble the audio command list
  235. */
  236. #define aADPCMdec(pkt, f, s) \
  237. { \
  238. Acmd *_a = (Acmd *)pkt; \
  239. \
  240. _a->words.w0 = _SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(f, 16, 8); \
  241. _a->words.w1 = (unsigned int)(s); \
  242. }
  243. #define aPoleFilter(pkt, f, g, s) \
  244. { \
  245. Acmd *_a = (Acmd *)pkt; \
  246. \
  247. _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \
  248. _SHIFTL(g, 0, 16)); \
  249. _a->words.w1 = (unsigned int)(s); \
  250. }
  251. #define aClearBuffer(pkt, d, c) \
  252. { \
  253. Acmd *_a = (Acmd *)pkt; \
  254. \
  255. _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \
  256. _a->words.w1 = (unsigned int)(c); \
  257. }
  258. #define aEnvMixer(pkt, f, s) \
  259. { \
  260. Acmd *_a = (Acmd *)pkt; \
  261. \
  262. _a->words.w0 = _SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8); \
  263. _a->words.w1 = (unsigned int)(s); \
  264. }
  265. #define aInterleave(pkt, l, r) \
  266. { \
  267. Acmd *_a = (Acmd *)pkt; \
  268. \
  269. _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \
  270. _a->words.w1 = _SHIFTL(l, 16, 16) | _SHIFTL(r, 0, 16); \
  271. }
  272. #define aLoadBuffer(pkt, s) \
  273. { \
  274. Acmd *_a = (Acmd *)pkt; \
  275. \
  276. _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8); \
  277. _a->words.w1 = (unsigned int)(s); \
  278. }
  279. #define aMix(pkt, f, g, i, o) \
  280. { \
  281. Acmd *_a = (Acmd *)pkt; \
  282. \
  283. _a->words.w0 = (_SHIFTL(A_MIXER, 24, 8) | _SHIFTL(f, 16, 8) | \
  284. _SHIFTL(g, 0, 16)); \
  285. _a->words.w1 = _SHIFTL(i,16, 16) | _SHIFTL(o, 0, 16); \
  286. }
  287. #define aPan(pkt, f, d, s) \
  288. { \
  289. Acmd *_a = (Acmd *)pkt; \
  290. \
  291. _a->words.w0 = (_SHIFTL(A_PAN, 24, 8) | _SHIFTL(f, 16, 8) | \
  292. _SHIFTL(d, 0, 16)); \
  293. _a->words.w1 = (unsigned int)(s); \
  294. }
  295. #define aResample(pkt, f, p, s) \
  296. { \
  297. Acmd *_a = (Acmd *)pkt; \
  298. \
  299. _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(f, 16, 8) |\
  300. _SHIFTL(p, 0, 16)); \
  301. _a->words.w1 = (unsigned int)(s); \
  302. }
  303. #define aSaveBuffer(pkt, s) \
  304. { \
  305. Acmd *_a = (Acmd *)pkt; \
  306. \
  307. _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8); \
  308. _a->words.w1 = (unsigned int)(s); \
  309. }
  310. #define aSegment(pkt, s, b) \
  311. { \
  312. Acmd *_a = (Acmd *)pkt; \
  313. \
  314. _a->words.w0 = _SHIFTL(A_SEGMENT, 24, 8); \
  315. _a->words.w1 = _SHIFTL(s, 24, 8) | _SHIFTL(b, 0, 24); \
  316. }
  317. #define aSetBuffer(pkt, f, i, o, c) \
  318. { \
  319. Acmd *_a = (Acmd *)pkt; \
  320. \
  321. _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \
  322. _SHIFTL(i, 0, 16)); \
  323. _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \
  324. }
  325. #define aSetVolume(pkt, f, v, t, r) \
  326. { \
  327. Acmd *_a = (Acmd *)pkt; \
  328. \
  329. _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \
  330. _SHIFTL(v, 0, 16)); \
  331. _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \
  332. }
  333. #define aSetLoop(pkt, a) \
  334. { \
  335. Acmd *_a = (Acmd *)pkt; \
  336. _a->words.w0 = _SHIFTL(A_SETLOOP, 24, 8); \
  337. _a->words.w1 = (unsigned int)(a); \
  338. }
  339. #define aDMEMMove(pkt, i, o, c) \
  340. { \
  341. Acmd *_a = (Acmd *)pkt; \
  342. \
  343. _a->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(i, 0, 24); \
  344. _a->words.w1 = _SHIFTL(o, 16, 16) | _SHIFTL(c, 0, 16); \
  345. }
  346. #define aLoadADPCM(pkt, c, d) \
  347. { \
  348. Acmd *_a = (Acmd *)pkt; \
  349. \
  350. _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \
  351. _a->words.w1 = (unsigned int) d; \
  352. }
  353. /*
  354. * --------------------------------------------------------------------
  355. * The below commands are seemingly declared manually and used for the
  356. * sound driver.
  357. * --------------------------------------------------------------------
  358. */
  359. // This is a version of aSetAudio which takes a single 32-bit parameter
  360. // instead of two 16-bit ones. According to AziAudio, it is used to set
  361. // ramping values when neither bit 4 nor bit 8 is set in the flags parameter.
  362. #define aSetVolume32(pkt, f, v, tr) \
  363. { \
  364. Acmd *_a = (Acmd *)pkt; \
  365. \
  366. _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \
  367. _SHIFTL(v, 0, 16)); \
  368. _a->words.w1 = (unsigned int)(tr); \
  369. }
  370. // Like aSetBuffer, expect that the order of operands to the w1 bitor is
  371. // swapped. This is needed for the code to match... (In fact, it's almost
  372. // fine to redefine aSetBuffer itself this way, but there's a single function
  373. // whose bitor then get its order of operands messed up.)
  374. #define aSetBuffer2(pkt, f, i, o, c) \
  375. { \
  376. Acmd *_a = (Acmd *)pkt; \
  377. \
  378. _a->words.w0 = (_SHIFTL(A_SETBUFF, 24, 8) | _SHIFTL(f, 16, 8) | \
  379. _SHIFTL(i, 0, 16)); \
  380. _a->words.w1 = _SHIFTL(c, 0, 16) | _SHIFTL(o, 16, 16); \
  381. }
  382. #endif /* _LANGUAGE_C */
  383. #endif /* !_ABI_H_ */