xiahanlu

free

Apr 23rd, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.02 KB | None | 0 0
  1. # include "globals.h"
  2. # include "might_fight.h"
  3. # include "font.h"
  4. # include "alpha.h"
  5. # include "snd_effect.h"
  6.  
  7. /* stage-0 task
  8.  
  9.  task 1- show ninteodo/capcom/moecmks'text infos.
  10.  task 2- show capcom's logo.
  11.  task 3- show talk context. check joypad.
  12.  task 4- show migthy final fight logo .check joypad
  13. */
  14.  
  15. // TODO: wait for simplification, 2333333333....
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. struct  stage_0ctx  {
  23.  
  24.   nbool task_init;
  25.   nbool fast_pass;
  26.   nbool fast_enable;
  27.   nbool talk_phase1_compelte;
  28.   nbool switch_one;
  29.   nbool switch_two;
  30.   nbool pass_final;
  31.   nbool first_s;
  32.   nbool first_s2;
  33.   nbool second_s;
  34.   nbool second_s2;
  35.   nbool third_s;
  36.   nbool third_s2;
  37.   nbool font_enable;
  38.   struct alpha_pulse ap_pulse;
  39.   struct alpha_pulse ap_pulse2;
  40.   struct snd_pulse sd_pulse;
  41.   struct outfb3_desc otb3;
  42.   int task_id;
  43.   int line;
  44. #  define DEALY_TICKS  2
  45.   uint64_t delay_init;
  46.  
  47. };
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. STAGE_STATUS stage_0_init (struct MFF_base *mfb, void **stage_ctx) {
  55.   struct stage_0ctx *t0 = malloc (sizeof (struct  stage_0ctx));
  56.   t0->task_init = nfalse;
  57.   t0->task_id = 0;
  58.   t0->talk_phase1_compelte = nfalse;
  59.   t0->switch_one = nfalse;
  60.   t0->switch_two = nfalse;
  61.   t0->pass_final = nfalse;
  62.   t0->first_s = nfalse;
  63.   t0->first_s2 = nfalse;
  64.   t0->second_s = nfalse;
  65.   t0->second_s2 = nfalse;
  66.   t0->third_s = nfalse;
  67.   t0->third_s2 = nfalse;
  68.   t0->line = 0;
  69.   t0->font_enable = ntrue;
  70.   * stage_ctx = t0;
  71.  
  72.  
  73. }
  74.  
  75.  
  76. static  
  77. int stage_0_task_doncm (struct MFF_base *mfb)  {
  78.   int ret = -1;
  79.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  80.   nbool csr = nfalse;
  81.   nbool max_enable;
  82.  
  83.   if (s0->task_init == nfalse)  {
  84.     s0->task_init = ntrue;
  85.     s0->fast_pass = nfalse;
  86.     s0->fast_enable = nfalse;
  87.     /* init current sub task's contexnt
  88.        play sound, show infos/.
  89.     */
  90.     ns_setctl_mask (PPU_BG_VISABLE | PPU_UNION_ALPHA);
  91.     ns_setun_ldpercent (0);
  92.     ns_setscrpage (0);
  93.     ns_setscrx (0);
  94.     ns_setscry (0);
  95.     ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  96.  
  97.     outfb (0, 4, 12, "/* COPYRIGHT:CAPCOM \n"
  98.                      "* -----------------------\n"
  99.                      "*PROGRAMMER:MOECMKS        \n"
  100.                      "*-----------------------\n"
  101.                      "*SOUND:CAPCOM\n"
  102.                      "*-----------------------\n"
  103.                      "*TEXTURE:CAPCOM\n"
  104.                      "*/");
  105.     alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 240, 240, 50, nfalse);
  106.     snd_pulse_init (& s0->sd_pulse, & mfb->gvens->bgm_author,
  107.       0.0, 0.10, 0.0, 180, 120, 1, 1, 50, 1, 160, ntrue, ntrue, nfalse);
  108.   } else  {
  109.     int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
  110.     int a = snd_pulse_do (& s0->sd_pulse);
  111.     if (max_enable != nfalse)
  112.       s0->fast_enable = ntrue;
  113.     if ( !s && !a)  {
  114.       ret   = 0;
  115.       s0->task_init = nfalse;
  116.       s0->fast_pass = nfalse;
  117.       s0->fast_enable = nfalse;
  118.       csr = ntrue;
  119.     }
  120.   }
  121.   /* check fast pass */
  122.   if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable)  {
  123.       /* adjust speed  */
  124.     if  (s0->fast_pass == nfalse)   {
  125.       struct  nes_joypad jp;
  126.       ns_getjoypad (& jp);
  127.       if  (jp.start & JOYPAD_MASK_PRESS)    {
  128.         s0->fast_pass = ntrue;
  129.         alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
  130.         snd_pulse_reset_speed (& s0->sd_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
  131.       }
  132.     }
  133.   }
  134.   return ret;
  135. }
  136. static
  137. int stage_0_task_doncm2 (struct MFF_base *mfb) {
  138.   int ret = -1;
  139.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  140.   nbool csr = nfalse;
  141.   nbool max_enable;
  142.  
  143.   if (s0->task_init == nfalse)  {
  144.     s0->task_init = ntrue;
  145.     s0->fast_pass = nfalse;
  146.     s0->fast_enable = nfalse;
  147.     ns_setun_ldpercent (0);
  148.     ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  149.  
  150.     outfb (0, 2, 12,
  151.   "/* THANKS FCEUX\n"
  152.   " * THANKS NSF PLAYER\n"
  153.   " * THANKS PHOTOSHOP CS2\n"
  154.   " * THANKS AUDITION CS6\n"
  155.   " * THANKS GIMP\n"
  156.   " * THANKS THEM.!>  - MOECMKS\n"
  157.   " */");
  158.     alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 120, 120, 50, nfalse);
  159.   } else  {
  160.     int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
  161.     if (max_enable != nfalse)
  162.       s0->fast_enable = ntrue;
  163.     if ( !s )  {
  164.       ret   = 0;
  165.       s0->task_init = nfalse;
  166.       s0->fast_pass = nfalse;
  167.       s0->fast_enable = nfalse;
  168.       csr = ntrue;
  169.     }
  170.   }
  171.   /* check fast pass */
  172.   if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable)  {
  173.       /* adjust speed  */
  174.     if  (s0->fast_pass == nfalse)   {
  175.       struct  nes_joypad jp;
  176.       ns_getjoypad (& jp);
  177.       if  (jp.start & JOYPAD_MASK_PRESS)    {
  178.         s0->fast_pass = ntrue;
  179.         alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
  180.       }
  181.     }
  182.   }
  183.   return ret;
  184. }
  185. static
  186. int stage_0_task_docapcom (struct MFF_base *mfb) {
  187.   int ret = -1;
  188.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  189.   nbool csr = nfalse;
  190.   nbool max_enable;
  191.  
  192.   if (s0->task_init == nfalse)  {
  193.     s0->task_init = ntrue;
  194.     s0->fast_pass = nfalse;
  195.     s0->fast_enable = nfalse;
  196.     ns_setun_ldpercent (0);
  197.     ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  198.     ns_fillmap_bypage (0, 8, 7, NTW_LOGO1_PAGE);
  199.     alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 120, 120, 50, nfalse);
  200.   } else  {
  201.     int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
  202.     if (max_enable != nfalse)
  203.       s0->fast_enable = ntrue;
  204.     if ( !s )  {
  205.       ret   = 0;
  206.       s0->task_init = nfalse;
  207.       s0->fast_pass = nfalse;
  208.       s0->fast_enable = nfalse;
  209.       csr = ntrue;
  210.     }
  211.   }
  212.   /* check fast pass */
  213.   if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable)  {
  214.       /* adjust speed  */
  215.     if  (s0->fast_pass == nfalse)   {
  216.       struct  nes_joypad jp;
  217.       ns_getjoypad (& jp);
  218.       if  (jp.start & JOYPAD_MASK_PRESS)    {
  219.         s0->fast_pass = ntrue;
  220.         alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 120, nfalse);
  221.       }
  222.     }
  223.   }
  224.   return ret;
  225. }
  226. static
  227. int stage_0_task_dotalk (struct MFF_base *mfb) {
  228.  
  229.   static char *dialogue_s1 [] = {
  230.     "THIS IS METRO CITY.\n\n"
  231.     "WITHIN THE WALLS OF\n\n"
  232.     "THE CITY LIVES  ",    // 0
  233.     "THE DAUGTHER OF\n\n"
  234.     "THE MAYOR, JESSICA.\n\n"
  235.     "HER BEAUTY RADI-   ", // 1
  236.     "ATES THROUGHOUT\n\n"
  237.     "THE CITY AND GIVES\n\n" // 2
  238.     "THE CITIZENS THE   " ,
  239.     "POWER TO SURVIVE.\n\n"
  240.     "BUT NOW A VILLAIN\n\n"
  241.     "ATTEMPTS TO HAVE   ", // 3
  242.     "THIS BEACON OF\n\n"
  243.     "LIGHT ALL TO\n\n"
  244.     "HIMSELF.   "          // 4
  245.   };
  246.   static char *dialogue_s2 [] = {
  247.     "I CAN'T BELIEVE\n\n"    
  248.     "THAT I'VE ACTUALLY\n\n"
  249.     "FALLEN IN LOVE ",    // 0
  250.     "WITH THE GIRL\n\n"
  251.     "SHE WILL BE MINE..\n\n"
  252.     "... ",                // 1  switch to black..
  253.     "A COUPLE DAYS\n\n"
  254.     "LATER... ",           // 2  switch logo n..
  255.     "WHAT?! JESSICA...\n\n"
  256.     "KIDNAPPED...!?!  ",   // 3
  257.     "WHAT HAVE YOU DONE\n\n"
  258.     "TO HER, CODY? ",     // 4
  259.     "ME?!! THIS IS THE\n\n"
  260.     "WORK OF THE MAD\n\n"
  261.     "GEAR GANG. ",        // 5
  262.     "WHAT DO YOU THINK,\n\n"
  263.     "GUY? ",              // 6  switch black..
  264.     "YES. THERE'S NOT A\n\n"
  265.     "MOMENT TO SPARE.\n\n"
  266.     "LET'S GO!"          // 7 switch gamelogol
  267.   };
  268.   int ret = -1;
  269.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  270.  
  271.   /* do phase  1*/
  272.   if  (s0->task_init == nfalse)  {
  273.     s0->task_init = ntrue;
  274.     s0->fast_pass = nfalse;
  275.     s0->fast_enable = nfalse;
  276.     ns_setun_ldpercent (255);
  277.     ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  278.     outfb3_init (& s0->otb3, mfb, 8, 21,
  279.         dialogue_s1, sizeof (dialogue_s1)/ sizeof (dialogue_s1[0]),
  280.             ntrue, 2, 148);
  281.   } else {
  282.     int line = -1;
  283.     if (s0->first_s == nfalse)  {
  284.       int s = outfb3 (& s0->otb3, & line);
  285.       if  (s == 0 && (s0->first_s2 == nfalse))  {
  286.       /* switch to bgpage 1*/
  287.         alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
  288.         ns_sound_start (mfb->gvens->bgm_preface.sound);
  289.         ns_sound_post  (mfb->gvens->bgm_preface.sound, 0, -1, 0);
  290.         s0->first_s2 = ntrue;
  291.       } else if (s0->first_s2 != nfalse)  {
  292.         nbool sc;
  293.         int c = alpha_pulse_do (& s0->ap_pulse, & sc, null);
  294.         if (sc != nfalse) {
  295.           ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  296.           ns_fillmap_bypage (0, 8, 7, NTW_BG_PAGE1);
  297.         }
  298.         if (c == 0) {
  299.           s0->first_s = ntrue ;
  300.               s0->first_s2 = nfalse;
  301.                     outfb3_init (& s0->otb3, mfb, 8, 21,
  302.             dialogue_s2, sizeof (dialogue_s2)/ sizeof (dialogue_s2[0]),
  303.                 nfalse, 2, 158);
  304.         }
  305.       }
  306.     }  else  if (s0->second_s == nfalse) {
  307.       int s = -1;
  308.       if (s0->font_enable != nfalse)  
  309.          s = outfb3 (& s0->otb3, & line);
  310.       if (line != -1)
  311.          s0->line = line;
  312.       if ( (line == 2 || line == 3 || line == 7 || line == 8) && (s0->otb3.timing_stamp == -1) ) {
  313.         alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
  314.         s0->font_enable = nfalse;
  315.       }  else if (s0->line >= 2) {
  316.         nbool max;
  317.         int c;
  318.         /* alpha intoi */
  319.         if (s0->second_s2 == nfalse)  {
  320.           c = alpha_pulse_do (& s0->ap_pulse, & max, null);
  321.           if (max != nfalse)
  322.             ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  323.           if ( c == 0)  {
  324.             s0->font_enable = ntrue;
  325.             s0->second_s2 = ntrue;
  326.             s0->otb3.timing_stamp = -1;
  327.           }
  328.         } else if (s0->third_s == nfalse && (s0->line >= 3))  {
  329.           c = alpha_pulse_do (& s0->ap_pulse, & max, null);
  330.           if (max != nfalse)
  331.              ns_fillmap_bypage (0, 8, 7, NTW_BG_PAGE2);
  332.           if ( c == 0)  {
  333.             s0->font_enable = ntrue;
  334.             s0->third_s = ntrue;
  335.             s0->otb3.timing_stamp = -1;
  336.             // alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
  337.           }
  338.         } else if (s0->third_s2 == nfalse && (s0->line >= 7))  {
  339.           c = alpha_pulse_do (& s0->ap_pulse, & max, null);
  340.           if (max != nfalse)
  341.              ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  342.           if ( c == 0)  {
  343.             s0->font_enable = ntrue;
  344.             s0->third_s2 = ntrue;
  345.             s0->otb3.timing_stamp = -1;
  346.             // ret = 0;
  347.           }
  348.  
  349.         }
  350.  
  351.       }
  352.       if (s == 0) {
  353.         ret   =0;
  354.         s0->task_init = nfalse;
  355.       }
  356.     }
  357.   }
  358.        /* check fast pass */
  359.   if (s0->task_init == ntrue)  {
  360.       /* adjust speed  */
  361.     if  (s0->fast_pass == nfalse)   {
  362.       struct  nes_joypad jp;
  363.       ns_getjoypad (& jp);
  364.       if  (jp.start & JOYPAD_MASK_PRESS)
  365.       { s0->fast_pass = ntrue;
  366.         s0->delay_init = ns_getticks ();
  367.         alpha_pulse_init (& s0->ap_pulse2, 255, 0, 255, 3, 3, 3, 3, 0, 0, 0, ntrue);
  368.         s0->task_init = nfalse;
  369.         ret  = 0;
  370.       }
  371.     }
  372.   }
  373.   return ret;
  374. }
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388. int stage_0_task_dogamelogo (struct MFF_base *mfb) {
  389.   int ret  = -1;
  390.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  391.  
  392.   if (s0->task_init == nfalse)   {
  393.     s0->task_init = ntrue;
  394.     alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 3, 3, 2, 2, 0, 0, 0, ntrue);
  395.     s0->first_s = nfalse;
  396.     s0->second_s = nfalse;
  397.     s0->third_s = nfalse;
  398.     s0->third_s2 = nfalse;
  399.   } else  {
  400.     nbool max;
  401.     int c = alpha_pulse_do (& s0->ap_pulse, & max, null);
  402.     if (max != nfalse)   {
  403.       ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
  404.       ns_fillmap_bypage (0, 0, 3, NTW_BG_PAGE3);
  405.       ns_fillmap_bypage (0, 16, 3, NTW_BG_PAGE3 + 1);
  406.       ns_sound_start (mfb->gvens->bgm_logo.sound);
  407.       ns_sound_post  (mfb->gvens->bgm_logo.sound, 0, -1, 0);
  408.       ns_sound_stop (mfb->gvens->bgm_preface.sound);
  409. #  define  BG_PAGE3_MASK 0x4040ff
  410.       ns_adjustcolor_page (0, 0, 3, 32, 16, 0, BG_PAGE3_MASK, ntrue);  
  411.     }
  412.     if (c == 0 && (s0->first_s == nfalse))  {
  413.       s0->first_s = ntrue;
  414.       ns_adjustcolor_page (0, 0, 3, 32, 16, BG_PAGE3_MASK, BG_PAGE3_MASK, ntrue);
  415.       ns_sound_start (mfb->gvens->eef_pulse.sound);
  416.       ns_sound_post  (mfb->gvens->eef_pulse.sound, 0, -1, 0);
  417.       outfb (-1, 12, 20, "PLEASE PRESS ENTER");
  418.       outfb (-1, 3, 24, "COPYRIGHT:NINTENDO/CAPCOM \n"
  419.         "PROGRAMMER:MOECMKS        \n");
  420.     } else if (s0->first_s == ntrue && (s0->second_s == nfalse) )  {
  421.         /* check joypad  */
  422.       struct nes_joypad jp;
  423.       ns_getjoypad (& jp);
  424.       if (jp.start & JOYPAD_MASK_PRESS)  
  425.         if (! (jp.start & JOYPAD_MASK_CONTINUOUSLY))
  426.            s0->third_s = ntrue;
  427.         else  ;
  428.       else ;
  429.       if (s0->third_s == ntrue)  {
  430.         /* check init alpha  final */
  431.         if (s0->third_s2 == nfalse) {
  432.           s0->third_s2 = ntrue;
  433.           alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
  434.           ns_sound_start (mfb->gvens->eef_pulse2.sound);
  435.           ns_sound_post  (mfb->gvens->eef_pulse2.sound, 0, -1, 0);
  436.           ret  =0;
  437.         }
  438.       }
  439.  
  440.     }
  441.   }
  442.  
  443.   return  ret;
  444. }
  445.  
  446. #  define STAGE_TASK_NUMS 5
  447. int (*sub_stage_set[STAGE_TASK_NUMS]) (struct MFF_base *) = {
  448.   stage_0_task_doncm,
  449.   stage_0_task_doncm2,
  450.   stage_0_task_docapcom,
  451.   stage_0_task_dotalk,
  452.   stage_0_task_dogamelogo  
  453. };
  454.  
  455. STAGE_STATUS stage_0 (struct MFF_base *mfb) {
  456.   int e;
  457.   STAGE_STATUS s = STAGE_RUNING;
  458.   struct  stage_0ctx  *s0 = mfb->gvens->cur_stage_context;
  459.   if  (mfb->gvens->stage_init == nfalse)  {
  460.     /* init stage - 0 env */
  461.     mfb->gvens->stage_init = ntrue;
  462.     /* open bg / alpha enable */
  463.  
  464.   }
  465.      /*play sound alpha font .*/
  466.     e = sub_stage_set[s0->task_id] (mfb);
  467.     if (e == 0)   {
  468.         /* pass current task, to next  */
  469.       s0->task_id ++;
  470.       if  (s0->task_id == STAGE_TASK_NUMS)  {
  471.         /* current stage comeplete */
  472.         s = STAGE_PASS;
  473.  
  474.       }
  475.  
  476.  
  477.  
  478.  
  479.  
  480.     }
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.   /* poll sub status  */
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.   return  s;
  501. }
Add Comment
Please, Sign In to add comment