?login_element?

Subversion Repositories NedoOS

Rev

Rev 962 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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 _PREPSCROLLXY
  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 _DRAWSCROLLXY
  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. {
  172. __asm
  173.         ld hl,#2
  174.         add hl,sp
  175.        ld e,(hl)
  176.        inc hl
  177.        ld d,(hl)
  178.        inc hl
  179.         ld a,(hl)
  180.         inc hl
  181.         ld h,(hl)
  182.         ld l,a
  183. ;hl=y
  184. ;de=x
  185.        push ix
  186.         call _SETSCROLLXY
  187.        pop ix
  188.         ret
  189. __endasm;
  190. }
  191.  
  192.  
  193. static u16 score;
  194. static u8 lifes;
  195. static u8 cheat_on;
  196.  
  197. #include "sprite_pool.c"
  198.  
  199. #include "engine.c"
  200. #include "font.c"
  201.  
  202. #include "gameloop.c"
  203. #include "gameover.c"
  204. #include "menu.c"
  205. #include "dialogs.c"
  206. #include "win_stage.c"
  207.  
  208. void intro()
  209. {
  210. u16 curscroll = 1;
  211. i16 curdscroll = 1;
  212. preparescroll("title-16.bmp");
  213.         unpack_pal256(PAL256_TITLE, 0);
  214.         //draw_image_g256(0, 0, IMG256_TITLE);
  215.         /*text_x = 11;
  216.         text_y = 22;//25;
  217.         //put_slow_str("This is party version!");
  218.         text_y += 2;
  219.         text_x = 12;
  220.         put_slow_str("Press SPACE to start");*/
  221.         swap_screen();
  222.         while (!keys[FIRE])
  223.         {
  224.                 keyboard(keys);
  225. scroll(0, 512-240+curscroll);
  226. drawscroll();
  227. if ((curscroll==0)||(curscroll==40)) curdscroll = -curdscroll;
  228. curscroll+=curdscroll;
  229.                 swap_screen_scroll();
  230.         }
  231.         for (cnt = BRIGHT_MID; cnt > BRIGHT_MIN; cnt--)
  232.         {
  233.                 pal_bright(cnt);
  234.                 swap_screen();
  235.         }
  236. }
  237.  
  238. void state_manager()
  239. {
  240.         while (TRUE)
  241.         {
  242.                 music_stop();
  243.                 //sprites_stop();
  244.                 switch (state)
  245.                 {
  246.                 case STATE_PLAY:
  247.                         start_game_loop();
  248.                         break;
  249.                 case STATE_MENU:
  250.                         init_menu_loop();
  251.                         break;
  252.                 case STATE_GAMEOVER:
  253.                         gameover();
  254.                         break;
  255.                 case STATE_WIN:
  256.                         win_stage();
  257.                         break;
  258.                 default:
  259.                         break;
  260.                 }
  261.         }
  262. }
  263.  
  264. void main(void)
  265. {
  266.         // Порт 0x20AF - порт управления скоростью CPU. Значение 6 - это 14МГц и включенный кэш(0110)
  267.         //__asm
  268.         //ld bc, #0x20af
  269.         //ld a, #6
  270.         //out(c), a
  271.         //__endasm;
  272.         set_screen_sync(1);
  273.         set_res(MODE320X240);
  274.         pal_bright(BRIGHT_MID);
  275. sprites_start();
  276. /*
  277. preparescroll("bg1-16.bmp");
  278. curscroll=0;
  279. while(1) {
  280. scroll(0, curscroll);
  281. drawscroll();
  282. swap_screen_scroll();
  283. }
  284. */
  285.         intro();
  286. //win_stage();
  287.         scroll(0, 0);
  288.         init_pool();
  289.         state = STATE_MENU;
  290.         state_manager();
  291. }