Subversion Repositories NedoOS

Rev

Rev 957 | Rev 960 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. #define CHEAT
  2.  
  3. #include <evo.h>
  4. #include "functions.h"
  5. #include "resources.h"
  6.  
  7. #define PAL256_FONT PAL_FONT_16
  8. #define PAL256_BG1 PAL_BG1_16
  9. #define PAL256_BG2 PAL_BG2_16
  10. #define PAL256_BG3 PAL_BG3_16
  11. #define PAL256_BG4 PAL_BG4_16
  12. #define PAL256_BG5 PAL_BG5_16
  13. #define PAL256_BG6 PAL_BG6_16
  14. #define PAL256_BG7 PAL_BG7_16
  15. #define PAL256_BG8 PAL_BG8_16
  16. #define PAL16_SPRITES PAL_SPRITES_16
  17. #define PAL256_FINAL PAL_FINAL_16
  18. #define PAL256_TITLE PAL_TITLE_16
  19.  
  20. #define IMG256_FONT IMG_FONT_16
  21. #define IMG256_BG1 IMG_BG1_16
  22. #define IMG256_BG2 IMG_BG2_16
  23. #define IMG256_BG3 IMG_BG3_16
  24. #define IMG256_BG4 IMG_BG4_16
  25. #define IMG256_BG5 IMG_BG5_16
  26. #define IMG256_BG6 IMG_BG6_16
  27. #define IMG256_BG7 IMG_BG7_16
  28. #define IMG256_BG8 IMG_BG8_16
  29. #define IMG256_FINAL IMG_FINAL_16
  30. #define IMG256_TITLE IMG_TITLE_16
  31.  
  32. #define MIN_X_RES 8/*0*/
  33. #define MAX_X_RES 296/*300*/
  34. #define MIN_Y_RES 16/*0*/
  35. #define MAX_Y_RES 216/*240*/
  36. #define STARTY 321
  37.  
  38. #define draw_tile_g256 draw_tile
  39. #define unpack_pal256(a,b) pal_select(a)
  40. #define unpack_pal16(a,n,b) pal_select(a)
  41. #define draw_image_g256(x,y,n) draw_image(x,y,n)
  42. #define set_screen_sync(a) ;
  43. #define set_res(a) ;
  44.  
  45. struct game_sprite
  46. {
  47.     u8 id;
  48.     u8 pal;
  49.     i16 x;
  50.     i16 y;
  51.     u16 tile;
  52. };
  53.  
  54. u8 id = 0;
  55.  
  56. struct game_sprite sprlist[85];
  57.  
  58. void preparescroll(char *fn) __naked
  59. {
  60. __asm
  61.         ld hl,#2
  62.         add hl,sp
  63.         ld e,(hl)
  64.         inc hl
  65.         ld d,(hl)
  66.        push ix
  67.         call _PREPARESCROLL
  68.        pop ix
  69.         ret
  70. __endasm;
  71. }
  72.  
  73. void incscroll(i16 scroll) __naked
  74. {
  75. __asm
  76.         ld hl,#2
  77.         add hl,sp
  78.         ld c,(hl)
  79.         inc hl
  80.         ld b,(hl)
  81.        push ix
  82.         call _INCSCROLL
  83.        pop ix
  84.         ret
  85. __endasm;
  86. }
  87.  
  88. void drawscroll(void) __naked
  89. {
  90. __asm
  91.         ld hl,#2
  92.         add hl,sp
  93.        push ix
  94.         call _DRAWSCROLL
  95.        pop ix
  96.         ret
  97. __endasm;
  98. }
  99.  
  100. void swap_screen_scroll(void) __naked
  101. {
  102. __asm
  103.         jp _SWAP_SCREEN_SCROLL
  104. __endasm;
  105. }
  106.  
  107. u8 create_sprite(u8 a, u8 wid8, u8 hgt8)
  108. {// TODO
  109.         //u8 id = 0;
  110.         return id++;
  111. }
  112.  
  113. void begin_set_sprites()
  114. {
  115.         //id = 0;
  116. }
  117.  
  118. void end_set_sprites()
  119. {
  120.     u8 i;
  121.     u8 id = 0;
  122.     for (i = 0; i < 85; i++) {
  123.         if (sprlist[i].x<0) continue;
  124.         if (sprlist[i].x>320-16) continue;
  125.         if (sprlist[i].y<0) continue;
  126.         if (sprlist[i].y>200-16) continue;
  127.         if (id<64) set_sprite(id++,sprlist[i].x>>1,sprlist[i].y,sprlist[i].tile);
  128.         if ((sprlist[i].tile & 0xffc0) != 0x140) {
  129.            if ((id<64)&&((sprlist[i].x>>1)<=160-16)) set_sprite(id++,(sprlist[i].x>>1)+8,sprlist[i].y   ,sprlist[i].tile+1);
  130.            if (sprlist[i].y>200-32) continue;
  131.            if (id<64) set_sprite(id++,(sprlist[i].x>>1)  ,sprlist[i].y+16,sprlist[i].tile+32);
  132.            if ((id<64)&&((sprlist[i].x>>1)<=160-16)) set_sprite(id++,(sprlist[i].x>>1)+8,sprlist[i].y+16,sprlist[i].tile+33);
  133.         }
  134.     }
  135.     if (id<64) set_sprite(id,0,0,-1);
  136.     //drawscroll();
  137. }
  138.  
  139. void set_sprite256(u8 id, u16 tile, u8 pal, i16 x, i16 y)
  140. {
  141.         //x = x-16;
  142.         //if (x<0) return; //x = 0;
  143.         //x = x>>1;
  144.         //if (x>160-8) return; //x = 160-8;
  145.         //if (y<0) return;
  146.         //if (y>200-16) return;
  147.         //if (id>=64) return;
  148.         //set_sprite(id,x,y,1/*(tile>>4)&0xff*/);
  149.         sprlist[id].x = x-8;
  150.         sprlist[id].y = y-16;
  151.         sprlist[id].tile = ((tile&0xff)>>1) + ((tile&0x0f00)>>2);
  152. }
  153.  
  154. void setscroll(u16 scroll) __naked
  155. {
  156. __asm
  157.         ld hl,#2
  158.         add hl,sp
  159.         ld a,(hl)
  160.         inc hl
  161.         ld h,(hl)
  162.         ld l,a
  163.        push ix
  164.         call _SETSCROLL
  165.        pop ix
  166.         ret
  167. __endasm;
  168. }
  169.  
  170. void scroll(i16 x, i16 y)
  171. {// TODO x
  172. __asm
  173.         ld hl,#2
  174.         add hl,sp
  175.        inc hl
  176.        inc hl
  177.         ld a,(hl)
  178.         inc hl
  179.         ld h,(hl)
  180.         ld l,a
  181.        push ix
  182.         call _SETSCROLL
  183.        pop ix
  184.         ret
  185. __endasm;
  186. }
  187.  
  188.  
  189. static u16 score;
  190. static u8 lifes;
  191.  
  192. #include "sprite_pool.c"
  193.  
  194. #include "engine.c"
  195. #include "font.c"
  196.  
  197. #include "gameloop.c"
  198. #include "gameover.c"
  199. #include "menu.c"
  200. #include "dialogs.c"
  201. #include "win_stage.c"
  202.  
  203. void intro()
  204. {
  205.         unpack_pal256(PAL256_TITLE, 0);
  206.         draw_image_g256(0, 0, IMG256_TITLE);
  207.         text_x = 11;
  208.         text_y = 22;//25;
  209.         //put_slow_str("This is party version!");
  210.         text_y += 2;
  211.         text_x = 12;
  212.         put_slow_str("Press SPACE to start");
  213.         swap_screen();
  214.         while (!keys[FIRE])
  215.         {
  216.                 keyboard(keys);
  217.                 vsync();//swap_screen();
  218.         }
  219.         for (cnt = BRIGHT_MID; cnt > BRIGHT_MIN; cnt--)
  220.         {
  221.                 pal_bright(cnt);
  222.                 vsync();//swap_screen();
  223.         }
  224. }
  225.  
  226. void state_manager()
  227. {
  228.         while (TRUE)
  229.         {
  230.                 music_stop();
  231.                 //sprites_stop();
  232.                 switch (state)
  233.                 {
  234.                 case STATE_PLAY:
  235.                         start_game_loop();
  236.                         break;
  237.                 case STATE_MENU:
  238.                         init_menu_loop();
  239.                         break;
  240.                 case STATE_GAMEOVER:
  241.                         gameover();
  242.                         break;
  243.                 case STATE_WIN:
  244.                         win_stage();
  245.                         break;
  246.                 default:
  247.                         break;
  248.                 }
  249.         }
  250. }
  251.  
  252. void main(void)
  253. {
  254. u16 curscroll;
  255.         // Порт 0x20AF - порт управления скоростью CPU. Значение 6 - это 14МГц и включенный кэш(0110)
  256.         //__asm
  257.         //ld bc, #0x20af
  258.         //ld a, #6
  259.         //out(c), a
  260.         //__endasm;
  261.         set_screen_sync(1);
  262.         set_res(MODE320X240);
  263.         pal_bright(BRIGHT_MID);
  264. sprites_start();
  265.         intro();
  266. /*
  267. preparescroll("bg2-16.bmp");
  268. curscroll=0;
  269. while(1) {
  270. scroll(0, curscroll++);
  271. drawscroll();
  272. swap_screen_scroll();
  273. }
  274. */
  275.         scroll(0, 0);
  276.         init_pool();
  277.         state = STATE_MENU;
  278.         state_manager();
  279. }