Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. #include <genesis.h>
  2.  
  3. // resources.h is generated from resources.res
  4.  
  5. // Bitmap
  6. #include "moon.h"
  7.  
  8.  
  9. // Songs
  10. #include "vgm_drv.h"
  11. #include "songs.h"
  12.  
  13.  
  14.  
  15. // Global Variables
  16. #define TILE1 1
  17. #define NUM_TRACKS 5
  18.  
  19.  
  20. const u32 tile[8]=
  21. {
  22. 0x00000000,
  23. 0x00000000,
  24. 0x00000000,
  25. 0x00000000,
  26. 0x00000000,
  27. 0x00000000,
  28. 0x00000000,
  29. 0x00000000
  30. };
  31.  
  32. // Main
  33.  
  34. int main( )
  35. {
  36. int counter = 0;
  37. int counter2 = 0;
  38. int delay = 0;
  39.  
  40. // get the image width (in pixel) ==> should be 8pix aligned
  41. u16 w = moon.w;
  42. // get the image height (in pixel) ==> should be 8px aligned
  43. u16 h = moon.h;
  44.  
  45. // Get the tile
  46. VDP_loadTileData( (const u32 *)tile, TILE1, 1, 0);
  47.  
  48. // get the palette data of moon
  49. VDP_setPalette(PAL1, moon.palette->data);
  50.  
  51. // load bitmap data of moon in VRAM
  52. // w/8 = width in tiles we want to load
  53. // h/8 = height in tile we want to load
  54. // w/8 = width in tiles of the bitamp
  55. // the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
  56. VDP_loadBMPTileData(moon.image, 1, w / 8, h / 8, w / 8);
  57.  
  58. // draw the moon at (12,12)
  59. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 12, 12, w / 8, h / 8);
  60.  
  61.  
  62. // Sound stuff.
  63.  
  64. waitMs(100);
  65.  
  66. Z80_requestBus(1);
  67. // enable DAC
  68. YM2612_enableDAC();
  69. Z80_releaseBus();
  70.  
  71. SND_startPlay_VGM(track1_vgm);
  72.  
  73.  
  74. while(1)
  75. {
  76. VDP_waitVSync();
  77.  
  78. // # Scene #1
  79. if(counter < 100) {
  80. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), counter, 12, w / 8, h / 8);
  81. waitMs(delay);
  82. }
  83.  
  84. else if(counter == 100) {
  85. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  86. VDP_drawText("Frame #: 100", 10, 13);
  87. }
  88.  
  89. // Scene #2
  90. else if(counter < 200) {
  91. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 200-counter, 12, w / 8, h / 8);
  92. waitMs(delay);
  93. }
  94.  
  95. else if(counter == 200) {
  96. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  97. VDP_drawText("Frame #: 200", 10, 13);
  98. }
  99.  
  100. // Scene #3
  101. else if(counter < 300) {
  102. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 12, counter-200, w / 8, h / 8);
  103. waitMs(delay);
  104. }
  105.  
  106. else if(counter == 300) {
  107. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  108. VDP_drawText("Frame #: 300", 10, 13);
  109. }
  110.  
  111. // Scene #4
  112. else if(counter < 400) {
  113. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 12, 400-counter, w / 8, h / 8);
  114. waitMs(delay);
  115. }
  116.  
  117. else if(counter == 400) {
  118. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  119. VDP_drawText("Frame #: 400", 10, 13);
  120. }
  121.  
  122. // Scene #5
  123. else if(counter < 500) {
  124. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), counter-400, counter-400, w / 8, h / 8);
  125. waitMs(delay);
  126. }
  127.  
  128. else if(counter == 500) {
  129. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  130. VDP_drawText("Frame #: 500", 10, 13);
  131. }
  132.  
  133. // Scene #6
  134. else if(counter < 600) {
  135. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 600-counter, 600-counter, w / 8, h / 8);
  136. waitMs(delay);
  137. }
  138.  
  139. else if(counter == 600) {
  140. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  141. VDP_drawText("Frame #: 600", 10, 13);
  142. }
  143.  
  144. // Scene #7
  145. else if(counter < 700) {
  146. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 12, 12, w / 8, h / 8);
  147. waitMs(delay);
  148. }
  149.  
  150. else if(counter == 700) {
  151. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  152. VDP_drawText("Frame #: 700", 10, 13);
  153. }
  154.  
  155. // Scene #8
  156. else if(counter < 800) {
  157. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 500 * (counter%2), 12 , w / 8, h / 8);
  158. waitMs(delay);
  159. }
  160.  
  161. else if(counter == 800) {
  162. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL3, 0, 0, 0, TILE1), 0, 0, 240, 240);
  163. VDP_drawText("Frame #: 800", 10, counter2/100);
  164. }
  165.  
  166. // Scene #9
  167. else if(counter < 900) {
  168. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 12, 500 * (counter%2), w / 8, h / 8);
  169. waitMs(delay);
  170. }
  171.  
  172. else if(counter == 900) {
  173. // VDP_fillTileMapRect(PLAN_A, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 0, 0, 240, 240);
  174. VDP_drawText("Frame #: 900", 10, 13);
  175. }
  176.  
  177. // Scene #10
  178. else if(counter < 1000) {
  179. VDP_fillTileMapRectInc(PLAN_B, TILE_ATTR_FULL(PAL1, 0, 0, 0, TILE1), 500 * (counter%2), 500 * (counter%2), w / 8, h / 8);
  180. waitMs(delay);
  181. }
  182.  
  183. counter += 1;
  184. counter2 += 1;
  185. // sprintf("%d", counter);
  186. }
  187. return 0;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement