Nav apraksta

useful-bped.h 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. #ifndef _USEFUL_BPED
  2. #define _USEFUL_BPED
  3. #define objBaseAddr ((u8 *) 0x02020630) //OK
  4. #define OAMBuffer ((OAMThingy*)objBaseAddr)
  5. #define dummyAnimData (u32 *) 0x083023E8 //Transliterate... OK
  6. #define dummyAnimRoutine (u32 *) 0x08007429 //OK
  7. //Memory Locations Passen alle
  8. #define OAM_Mem ((u16 *)0x030022F8)
  9. #define OBJ_PaletteMem ((u16 *)0x02037914) // Sprite Palette(256/16 colors) (adjusted for FR callback)
  10. #define BG_PaletteMem ((u16 *)0x02037714) // Background Palette(256/16 colors) (adjusted for FR callback)
  11. #define BG_PaletteMem2 ((u16 *)0x02037B14) // Background Palette(256/16
  12. #define OBJ_PaletteMem2 ((u16 *)0x02037D14) // Sprite Palette(256/16 colors)
  13. //Key Stuffs
  14. #define KEYS (*(u8 *)0x030022EE) //Wird schon passen
  15. #define KEYSHOLD (*(u8 *)0x030022EC) //.
  16. #define KEYSSCROLL (*(u8 *)0x030022F0) //.
  17. #define KEYSLR (*(u8 *)0x030022EF) //.
  18. #define KEYSHOLDLR (*(u8 *)0x030022ED) //.
  19. #define KEYSSCROLLLR (*(u8 *)0x030022F1) //.
  20. //Variables and Such
  21. #define LASTRESULT (*(u16 *) 0x20375F0) //OK
  22. #define var8004 (*(u16 *) 0x20375E0) //OK
  23. #define fadeScreenDone (*(u8 *) (0x02037FD4 + 7)) //OK
  24. #define globalVars (*((u32 *)0x0203BCD0)) //OK
  25. #define boxInitStuff ((s32 *)0x0859CB38) // Transliterate... OK
  26. #define nullCallback ((s32 *)0x080861CD) // OK
  27. //RoA Sounds //Gehe mal davon aus das ist OK, weil Sound Table
  28. #define EMPTYMOVESOUND 0x05
  29. #define TILEMOVESOUND 0x23
  30. #define ERRORSOUND 0x20
  31. #define TAKETILESOUND 0x24
  32. #define DROPTILESOUND 0x2C
  33. #define WINSONG 0x186
  34. typedef struct
  35. {
  36. void *dummyPtr;
  37. } Sprite;
  38. void updateEverything()
  39. {
  40. int(*func)(void) = (int(*)(void))0x080A9129; //Transliterate... OK
  41. func();
  42. int(*func2)(void) = (int(*)(void))0x080069C1; //OK
  43. func2();
  44. int(*func3)(void) = (int(*)(void))0x08006A0D; //OK
  45. func3();
  46. int(*func4)(void) = (int(*)(void))0x080A1A39; // Transliterate... OK
  47. func4();
  48. }
  49. //TODO Find actual names
  50. void updateEverything2()
  51. {
  52. int(*func)(void) = (int(*)(void))0x08007189; //OK
  53. func();
  54. int(*func2)(void) = (int(*)(void))0x0800742D; //OK
  55. func2();
  56. int(*func3)(void) = (int(*)(void))0x080A19DD; //Transliterate... OK
  57. func3();
  58. }
  59. int malloc(int size)
  60. {
  61. int(*func)(int) = (int(*)(int))0x08000B39; //OK
  62. return func(size);
  63. }
  64. void free(void *addr)
  65. {
  66. int(*func)(int *) = (int(*)(int *))0x08000B61; //OK
  67. func(addr);
  68. }
  69. void fadeScreen2(unsigned int bitmask, int r1, int r2, int r3, unsigned int color)
  70. {
  71. int(*func)(u32, u32, u32, u32, u32) = (int(*)(u32, u32, u32, u32, u32))0x080A1AF1;
  72. func(bitmask, r1, r2, r3, color);
  73. }
  74. void unfadeScreen()
  75. {
  76. fadeScreen2(0xFFFFFFFF, 0x0, 0x10, 0, 0x0000);
  77. }
  78. void fadeScreen()
  79. {
  80. fadeScreen2(0xFFFFFFFF, 0x0, 0, 0x10, 0x0000);
  81. }
  82. void copyPal(void *source, void *dest)
  83. {
  84. asm("mov r2, #0x8");
  85. SystemCall(0xC);
  86. //int (*func)(void) = (int (*)(void))0x080087BD;
  87. //func();
  88. }
  89. void copyMem(void *source, void *dest, int size)
  90. {
  91. SystemCall(0xC);
  92. }
  93. void playFanfare(u16 fanfareNum)
  94. {
  95. int(*func)(u16) = (int(*)(u16))0x080A3101; //Transliterate... OK
  96. func(fanfareNum);
  97. }
  98. int waitForFanfare() {
  99. int(*func)(void) = (int(*)(void))0x080A313D; //Transliterate... OK
  100. return func();
  101. }
  102. void playSound(u16 soundNum)
  103. {
  104. int(*func)(u16) = (int(*)(u16))0x080A37C1; //Transliterate... OK
  105. func(soundNum);
  106. }
  107. int waitForSound()
  108. {
  109. int(*func)(void) = (int(*)(void))0x080A38BD; //Transliterate... OK
  110. return func();
  111. }
  112. void changeIO(int offset, u16 value)
  113. {
  114. int(*func)(int, u16) = (int(*)(int, u16))0x080010B5; //OK
  115. func(offset, value);
  116. }
  117. void enableBG(u8 BG)
  118. {
  119. int(*func)(u8) = (int(*)(u8))0x08001B31; //OK
  120. func(BG);
  121. }
  122. void clearOAM()
  123. {
  124. int(*func)(void) = (int(*)(void))0x08006975; //OK
  125. func();
  126. }
  127. void initStuff()
  128. {
  129. clearOAM();
  130. int(*func2)(void) = (int(*)(void))0x0800870D; //OK
  131. func2();
  132. int(*func3)(u8) = (int(*)(u8))0x080017BD; //OK
  133. func3((u8)0x0);
  134. }
  135. void storeCallback(void *addr)
  136. {
  137. int(*func)(void *) = (int(*)(void *))0x08000541; //OK
  138. func(addr);
  139. }
  140. void storeCallback2(int *addr)
  141. {
  142. int(*func)(int *) = (int(*)(int *))0x080006F1; //OK
  143. func(addr);
  144. }
  145. Sprite *createSprite(int *addr, int *addr2, u16 XPos, u16 YPos, u8 i)
  146. {
  147. int(*func)(int *) = (int(*)(int *))0x080084F9; //OK
  148. func(addr);
  149. int(*func2)(int *, u16, u16, u8) = (int(*)(int *, u16, u16, u8))0x08006DF5; //OK
  150. int result = func2(addr2, XPos, YPos, (u8)0);
  151. result = (result * 0x44) + (int)objBaseAddr;
  152. return (int *)result;
  153. }
  154. void loadPalette(int *addr, u8 offset, u8 length)
  155. {
  156. int(*func)(int *, u8, u8) = (int(*)(int *, u8, u8))0x080A1955; //Transliterate... OK
  157. func(addr, offset, length);
  158. }
  159. void boxPrint(u8 foo, u8 font, u8 x, u8 y, u32 bar, u32 baz, u32 txtpointer)
  160. {
  161. int(*func3)(u8, u8, u8, u8, u32, u32, u32) = (int(*)(u8, u8, u8, u8, u32, u32, u32))0x08199971; //Transliterate... OK
  162. func3(foo, font, x, y, bar, baz, txtpointer);
  163. }
  164. void writeBoxesToTilemap(u8 a, u8 b)
  165. {
  166. int(*func5)(u8, u8) = (int(*)(u8, u8))0x08003659; //OK
  167. func5(a, b);
  168. }
  169. void initMapData(u8 r0, u32 r1, u8 r2)
  170. {
  171. int(*func)(u8, u32, u8) = (int(*)(u8, u32, u8))0x080017E9; //OK
  172. func(r0, r1, r2);
  173. }
  174. void someExitFunc()
  175. {
  176. int(*func)(void) = (int(*)(void))0x08003605; //OK
  177. func();
  178. }
  179. void forceNewBoxAndInitBG(u32 addr)
  180. {
  181. int(*func)(u32) = (int(*)(u32))0x080031C1; //OK
  182. func(addr);
  183. }
  184. void loadSpritePal(u32 addr)
  185. {
  186. int(*func)(u32) = (int(*)(u32))0x08008745; //OK
  187. func(addr);
  188. }
  189. void songNumStartOrChange(u16 n)
  190. {
  191. int(*func)(u16) = (int(*)(u16))0x082F5E9D;
  192. func(n);
  193. }
  194. #endif