Advertisement
GoGoJJTech

Bag.c

Apr 24th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. #include "include/gba.h"
  2. #include "useful.h"
  3. #include "img_bins/sprites.h"
  4. #include "img_bins/workaround.c"
  5. #include "img_bins/ui.c"
  6. #include "img_bins/empty.c"
  7.  
  8. #define DMA3Source (*(u32 *) 0x040000D4)
  9. #define DMA3Dest (*(u32 *) 0x040000D8)
  10. #define DMA3Options (*(u32 *) 0x040000DC)
  11.  
  12. #define Tiles ((u16 *) 0x6008000)
  13. #define Tiles2 ((u16 *) 0x6000000)
  14. #define MapData ((u16 *) 0x600E800)
  15. #define BG0Data ((u16 *) 0x600E800)
  16. #define BG2Data ((u16 *) 0x600E000)
  17. #define BG3Data ((u16 *) 0x600F000)
  18. #define OBJData ((u16 *) 0x6010000)
  19. #define MenuBG ((u16 *) 0x600F800)
  20.  
  21. #define waitasec (65535*2)
  22.  
  23. void GetInput();
  24.  
  25. #define currentLoop (*(u8 *) (globalVars + 0x0))//helps in main since ya know
  26. #define lastKeyPress (*(u8 *) (globalVars + 0x1))//helps so we know that they're done pressing
  27. #define currentpocket (*(u8 *) (globalVars + 0x2))
  28. #define dirtomove (*(u8 *) (globalVars + 0x3))//lets me know where I'm moving next. 0,1,2 for none, left, right.
  29. #define stuffthree (*(u8 *) (globalVars + 0x4))
  30. #define unused_one (*(u8 *) (globalVars + 0x5))
  31. #define unused_two (*(u8 *) (globalVars + 0x6))
  32. #define unused_three (*(u8 *) (globalVars + 0x7))
  33. #define unused_four (*(u8 *) (globalVars + 0x8))
  34. #define unused_five (*(u8 *) (globalVars + 0x9))
  35. #define unused_six (*(u8 *) (globalVars + 0xA))
  36. #define unused_seven (*(u8 *) (globalVars + 0xB))
  37. #define unused_eight (*(u8 *) (globalVars + 0xC))
  38. #define unused_nine (*(u16 *) (globalVars + 0xD))
  39. #define unused_ten (*(u16 *) (globalVars + 0xF))
  40. #define unused_eleven (*(u16 *) (globalVars + 0x11))
  41.  
  42. //original bag routine at 0x0806F481
  43.  
  44. void init2();
  45. void init3();
  46. void main();
  47.  
  48. void init() {
  49.  
  50. storeCallback((void *) init2 + 1);
  51. }
  52.  
  53. #include "include/gba_compress.h"
  54.  
  55. #include "useful-bpre.h"
  56.  
  57. void init2() {
  58. storeCallback2(0);
  59. globalVars = malloc(0x80);
  60.  
  61. int blank = 0;
  62. DMA3Source = ␣
  63. DMA3Dest = globalVars;
  64. DMA3Options = 0x81000040;
  65.  
  66. currentLoop = 0;
  67. currentpocket = 0;
  68.  
  69. storeCallback((void *) init3 + 1);
  70. }
  71.  
  72. void init3() {
  73. for(int i=0x10;i<0x20;i+=2) changeIO(i,0);
  74.  
  75. initStuff();
  76.  
  77. const u32 mapDataUnk[2] = {
  78. 0x000001E0, 0x000011D9
  79. };
  80.  
  81. initMapData(0x1,mapDataUnk,0x2);
  82.  
  83. storeCallback((void *) main + 1);
  84. LASTRESULT = 0xFF;
  85. }
  86.  
  87. void main()
  88. {
  89. if (currentLoop == 0)
  90. {
  91. dirtomove = 0;
  92. initVideo();
  93. initBG();
  94. clearOAM();
  95.  
  96. unfadeScreen();
  97. currentLoop++;
  98. storeCallback2((void *) updateEverything2 + 1);
  99. }
  100. else if (currentLoop == 1)
  101. {
  102. if (fadeScreenDone == 0)
  103. currentLoop++;
  104. }
  105. else if (currentLoop == 2)
  106. {
  107. GetInput();
  108. }
  109. else if (currentLoop == 3)//exiting function
  110. {
  111. if (fadeScreenDone == 0)
  112. someExitFunc();
  113. }
  114. updateEverything();
  115. }
  116.  
  117. void GetInput()
  118. {
  119. if(keyPressed(KEY_LEFT) && currentpocket != 0)
  120. {
  121. dirtomove = 1;
  122. }
  123. else if(keyPressed(KEY_RIGHT) && currentpocket != 2)
  124. {
  125. dirtomove = 2;
  126. }
  127. else if(keyPressed(KEY_A))
  128. {
  129. yesNoBox();
  130. }
  131. else if(keyPressed(KEY_B))
  132. {
  133. fadeScreen();
  134. storeCallback(nullCallback);
  135. if (globalVars != 0)
  136. {
  137. free(globalVars);
  138. globalVars = 0;
  139. }
  140. currentLoop = 3;
  141. }
  142. }
  143.  
  144. void initVideo() {
  145.  
  146. changeIO(0,OBJ_ENABLE | OBJ_MAP_1D);
  147.  
  148. u32 x = 0x80 << 5;
  149. u32 endAddr = 0xC0 << 0x13;
  150. int blank = 0;
  151.  
  152. for(u32 i = 0xC0 << 9; i > x ; i -= x, endAddr += x) {
  153. DMA3Source = &blank;
  154. DMA3Dest = endAddr;
  155. DMA3Options = 0x81000800;
  156. }
  157.  
  158. textboxBGInit(boxInitStuff);
  159.  
  160. enableBG(0);
  161. enableBG(1);
  162. enableBG(3);
  163.  
  164. changeIO(0x4, 0x1E08);
  165. changeIO(0x6, 0x1C46);
  166. changeIO(0x8,(0x1E << SCREEN_SHIFT));
  167. changeIO(0xA,(0x1D << SCREEN_SHIFT) | (2 << CHAR_SHIFT) | 3);
  168. changeIO(0,0x3740);
  169.  
  170. }
  171.  
  172. void loaditem(){
  173. u32* loc = (u32*)0x0203988C;
  174. u8* itemdataPointer = (u8*)loc[0];
  175. u16 item = itemdataPointer[0];
  176. u8 itemamount = itemdataPointer[2];
  177. }
  178.  
  179. void initBG(){
  180. LZ77UnCompVram(uiTiles,Tiles-0x4000);
  181. LZ77UnCompVram(uiMap, BG2Data);
  182. copyPal(uiPal,0);
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement