Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include "globals.h"
- # include "might_fight.h"
- # include "font.h"
- # include "alpha.h"
- # include "snd_effect.h"
- /* stage-0 task
- task 1- show ninteodo/capcom/moecmks'text infos.
- task 2- show capcom's logo.
- task 3- show talk context. check joypad.
- task 4- show migthy final fight logo .check joypad
- */
- // TODO: wait for simplification, 2333333333....
- struct stage_0ctx {
- nbool task_init;
- nbool fast_pass;
- nbool fast_enable;
- nbool talk_phase1_compelte;
- nbool switch_one;
- nbool switch_two;
- nbool pass_final;
- nbool first_s;
- nbool first_s2;
- nbool second_s;
- nbool second_s2;
- nbool third_s;
- nbool third_s2;
- nbool font_enable;
- struct alpha_pulse ap_pulse;
- struct alpha_pulse ap_pulse2;
- struct snd_pulse sd_pulse;
- struct outfb3_desc otb3;
- int task_id;
- int line;
- # define DEALY_TICKS 2
- uint64_t delay_init;
- };
- STAGE_STATUS stage_0_init (struct MFF_base *mfb, void **stage_ctx) {
- struct stage_0ctx *t0 = malloc (sizeof (struct stage_0ctx));
- t0->task_init = nfalse;
- t0->task_id = 0;
- t0->talk_phase1_compelte = nfalse;
- t0->switch_one = nfalse;
- t0->switch_two = nfalse;
- t0->pass_final = nfalse;
- t0->first_s = nfalse;
- t0->first_s2 = nfalse;
- t0->second_s = nfalse;
- t0->second_s2 = nfalse;
- t0->third_s = nfalse;
- t0->third_s2 = nfalse;
- t0->line = 0;
- t0->font_enable = ntrue;
- * stage_ctx = t0;
- }
- static
- int stage_0_task_doncm (struct MFF_base *mfb) {
- int ret = -1;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- nbool csr = nfalse;
- nbool max_enable;
- if (s0->task_init == nfalse) {
- s0->task_init = ntrue;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- /* init current sub task's contexnt
- play sound, show infos/.
- */
- ns_setctl_mask (PPU_BG_VISABLE | PPU_UNION_ALPHA);
- ns_setun_ldpercent (0);
- ns_setscrpage (0);
- ns_setscrx (0);
- ns_setscry (0);
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- outfb (0, 4, 12, "/* COPYRIGHT:CAPCOM \n"
- "* -----------------------\n"
- "*PROGRAMMER:MOECMKS \n"
- "*-----------------------\n"
- "*SOUND:CAPCOM\n"
- "*-----------------------\n"
- "*TEXTURE:CAPCOM\n"
- "*/");
- alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 240, 240, 50, nfalse);
- snd_pulse_init (& s0->sd_pulse, & mfb->gvens->bgm_author,
- 0.0, 0.10, 0.0, 180, 120, 1, 1, 50, 1, 160, ntrue, ntrue, nfalse);
- } else {
- int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
- int a = snd_pulse_do (& s0->sd_pulse);
- if (max_enable != nfalse)
- s0->fast_enable = ntrue;
- if ( !s && !a) {
- ret = 0;
- s0->task_init = nfalse;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- csr = ntrue;
- }
- }
- /* check fast pass */
- if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable) {
- /* adjust speed */
- if (s0->fast_pass == nfalse) {
- struct nes_joypad jp;
- ns_getjoypad (& jp);
- if (jp.start & JOYPAD_MASK_PRESS) {
- s0->fast_pass = ntrue;
- alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
- snd_pulse_reset_speed (& s0->sd_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
- }
- }
- }
- return ret;
- }
- static
- int stage_0_task_doncm2 (struct MFF_base *mfb) {
- int ret = -1;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- nbool csr = nfalse;
- nbool max_enable;
- if (s0->task_init == nfalse) {
- s0->task_init = ntrue;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- ns_setun_ldpercent (0);
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- outfb (0, 2, 12,
- "/* THANKS FCEUX\n"
- " * THANKS NSF PLAYER\n"
- " * THANKS PHOTOSHOP CS2\n"
- " * THANKS AUDITION CS6\n"
- " * THANKS GIMP\n"
- " * THANKS THEM.!> - MOECMKS\n"
- " */");
- alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 120, 120, 50, nfalse);
- } else {
- int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
- if (max_enable != nfalse)
- s0->fast_enable = ntrue;
- if ( !s ) {
- ret = 0;
- s0->task_init = nfalse;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- csr = ntrue;
- }
- }
- /* check fast pass */
- if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable) {
- /* adjust speed */
- if (s0->fast_pass == nfalse) {
- struct nes_joypad jp;
- ns_getjoypad (& jp);
- if (jp.start & JOYPAD_MASK_PRESS) {
- s0->fast_pass = ntrue;
- alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 0, nfalse);
- }
- }
- }
- return ret;
- }
- static
- int stage_0_task_docapcom (struct MFF_base *mfb) {
- int ret = -1;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- nbool csr = nfalse;
- nbool max_enable;
- if (s0->task_init == nfalse) {
- s0->task_init = ntrue;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- ns_setun_ldpercent (0);
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- ns_fillmap_bypage (0, 8, 7, NTW_LOGO1_PAGE);
- alpha_pulse_init (& s0->ap_pulse, 0, 255, 0, 6, 6, 3, 3, 120, 120, 50, nfalse);
- } else {
- int s = alpha_pulse_do (& s0->ap_pulse, & max_enable, null);
- if (max_enable != nfalse)
- s0->fast_enable = ntrue;
- if ( !s ) {
- ret = 0;
- s0->task_init = nfalse;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- csr = ntrue;
- }
- }
- /* check fast pass */
- if (s0->task_init == ntrue && (csr == nfalse) && s0->fast_enable) {
- /* adjust speed */
- if (s0->fast_pass == nfalse) {
- struct nes_joypad jp;
- ns_getjoypad (& jp);
- if (jp.start & JOYPAD_MASK_PRESS) {
- s0->fast_pass = ntrue;
- alpha_pulse_reset_speed (& s0->ap_pulse, 4, 4, 3, 3, 15, 0, 120, nfalse);
- }
- }
- }
- return ret;
- }
- static
- int stage_0_task_dotalk (struct MFF_base *mfb) {
- static char *dialogue_s1 [] = {
- "THIS IS METRO CITY.\n\n"
- "WITHIN THE WALLS OF\n\n"
- "THE CITY LIVES ", // 0
- "THE DAUGTHER OF\n\n"
- "THE MAYOR, JESSICA.\n\n"
- "HER BEAUTY RADI- ", // 1
- "ATES THROUGHOUT\n\n"
- "THE CITY AND GIVES\n\n" // 2
- "THE CITIZENS THE " ,
- "POWER TO SURVIVE.\n\n"
- "BUT NOW A VILLAIN\n\n"
- "ATTEMPTS TO HAVE ", // 3
- "THIS BEACON OF\n\n"
- "LIGHT ALL TO\n\n"
- "HIMSELF. " // 4
- };
- static char *dialogue_s2 [] = {
- "I CAN'T BELIEVE\n\n"
- "THAT I'VE ACTUALLY\n\n"
- "FALLEN IN LOVE ", // 0
- "WITH THE GIRL\n\n"
- "SHE WILL BE MINE..\n\n"
- "... ", // 1 switch to black..
- "A COUPLE DAYS\n\n"
- "LATER... ", // 2 switch logo n..
- "WHAT?! JESSICA...\n\n"
- "KIDNAPPED...!?! ", // 3
- "WHAT HAVE YOU DONE\n\n"
- "TO HER, CODY? ", // 4
- "ME?!! THIS IS THE\n\n"
- "WORK OF THE MAD\n\n"
- "GEAR GANG. ", // 5
- "WHAT DO YOU THINK,\n\n"
- "GUY? ", // 6 switch black..
- "YES. THERE'S NOT A\n\n"
- "MOMENT TO SPARE.\n\n"
- "LET'S GO!" // 7 switch gamelogol
- };
- int ret = -1;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- /* do phase 1*/
- if (s0->task_init == nfalse) {
- s0->task_init = ntrue;
- s0->fast_pass = nfalse;
- s0->fast_enable = nfalse;
- ns_setun_ldpercent (255);
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- outfb3_init (& s0->otb3, mfb, 8, 21,
- dialogue_s1, sizeof (dialogue_s1)/ sizeof (dialogue_s1[0]),
- ntrue, 2, 148);
- } else {
- int line = -1;
- if (s0->first_s == nfalse) {
- int s = outfb3 (& s0->otb3, & line);
- if (s == 0 && (s0->first_s2 == nfalse)) {
- /* switch to bgpage 1*/
- alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
- ns_sound_start (mfb->gvens->bgm_preface.sound);
- ns_sound_post (mfb->gvens->bgm_preface.sound, 0, -1, 0);
- s0->first_s2 = ntrue;
- } else if (s0->first_s2 != nfalse) {
- nbool sc;
- int c = alpha_pulse_do (& s0->ap_pulse, & sc, null);
- if (sc != nfalse) {
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- ns_fillmap_bypage (0, 8, 7, NTW_BG_PAGE1);
- }
- if (c == 0) {
- s0->first_s = ntrue ;
- s0->first_s2 = nfalse;
- outfb3_init (& s0->otb3, mfb, 8, 21,
- dialogue_s2, sizeof (dialogue_s2)/ sizeof (dialogue_s2[0]),
- nfalse, 2, 158);
- }
- }
- } else if (s0->second_s == nfalse) {
- int s = -1;
- if (s0->font_enable != nfalse)
- s = outfb3 (& s0->otb3, & line);
- if (line != -1)
- s0->line = line;
- if ( (line == 2 || line == 3 || line == 7 || line == 8) && (s0->otb3.timing_stamp == -1) ) {
- alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
- s0->font_enable = nfalse;
- } else if (s0->line >= 2) {
- nbool max;
- int c;
- /* alpha intoi */
- if (s0->second_s2 == nfalse) {
- c = alpha_pulse_do (& s0->ap_pulse, & max, null);
- if (max != nfalse)
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- if ( c == 0) {
- s0->font_enable = ntrue;
- s0->second_s2 = ntrue;
- s0->otb3.timing_stamp = -1;
- }
- } else if (s0->third_s == nfalse && (s0->line >= 3)) {
- c = alpha_pulse_do (& s0->ap_pulse, & max, null);
- if (max != nfalse)
- ns_fillmap_bypage (0, 8, 7, NTW_BG_PAGE2);
- if ( c == 0) {
- s0->font_enable = ntrue;
- s0->third_s = ntrue;
- s0->otb3.timing_stamp = -1;
- // alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
- }
- } else if (s0->third_s2 == nfalse && (s0->line >= 7)) {
- c = alpha_pulse_do (& s0->ap_pulse, & max, null);
- if (max != nfalse)
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- if ( c == 0) {
- s0->font_enable = ntrue;
- s0->third_s2 = ntrue;
- s0->otb3.timing_stamp = -1;
- // ret = 0;
- }
- }
- }
- if (s == 0) {
- ret =0;
- s0->task_init = nfalse;
- }
- }
- }
- /* check fast pass */
- if (s0->task_init == ntrue) {
- /* adjust speed */
- if (s0->fast_pass == nfalse) {
- struct nes_joypad jp;
- ns_getjoypad (& jp);
- if (jp.start & JOYPAD_MASK_PRESS)
- { s0->fast_pass = ntrue;
- s0->delay_init = ns_getticks ();
- alpha_pulse_init (& s0->ap_pulse2, 255, 0, 255, 3, 3, 3, 3, 0, 0, 0, ntrue);
- s0->task_init = nfalse;
- ret = 0;
- }
- }
- }
- return ret;
- }
- int stage_0_task_dogamelogo (struct MFF_base *mfb) {
- int ret = -1;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- if (s0->task_init == nfalse) {
- s0->task_init = ntrue;
- alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 3, 3, 2, 2, 0, 0, 0, ntrue);
- s0->first_s = nfalse;
- s0->second_s = nfalse;
- s0->third_s = nfalse;
- s0->third_s2 = nfalse;
- } else {
- nbool max;
- int c = alpha_pulse_do (& s0->ap_pulse, & max, null);
- if (max != nfalse) {
- ns_fillmap_bypage2 (0, NTW_FONT_PAGE, NTW_FONT_TRANS_LAND);
- ns_fillmap_bypage (0, 0, 3, NTW_BG_PAGE3);
- ns_fillmap_bypage (0, 16, 3, NTW_BG_PAGE3 + 1);
- ns_sound_start (mfb->gvens->bgm_logo.sound);
- ns_sound_post (mfb->gvens->bgm_logo.sound, 0, -1, 0);
- ns_sound_stop (mfb->gvens->bgm_preface.sound);
- # define BG_PAGE3_MASK 0x4040ff
- ns_adjustcolor_page (0, 0, 3, 32, 16, 0, BG_PAGE3_MASK, ntrue);
- }
- if (c == 0 && (s0->first_s == nfalse)) {
- s0->first_s = ntrue;
- ns_adjustcolor_page (0, 0, 3, 32, 16, BG_PAGE3_MASK, BG_PAGE3_MASK, ntrue);
- ns_sound_start (mfb->gvens->eef_pulse.sound);
- ns_sound_post (mfb->gvens->eef_pulse.sound, 0, -1, 0);
- outfb (-1, 12, 20, "PLEASE PRESS ENTER");
- outfb (-1, 3, 24, "COPYRIGHT:NINTENDO/CAPCOM \n"
- "PROGRAMMER:MOECMKS \n");
- } else if (s0->first_s == ntrue && (s0->second_s == nfalse) ) {
- /* check joypad */
- struct nes_joypad jp;
- ns_getjoypad (& jp);
- if (jp.start & JOYPAD_MASK_PRESS)
- if (! (jp.start & JOYPAD_MASK_CONTINUOUSLY))
- s0->third_s = ntrue;
- else ;
- else ;
- if (s0->third_s == ntrue) {
- /* check init alpha final */
- if (s0->third_s2 == nfalse) {
- s0->third_s2 = ntrue;
- alpha_pulse_init (& s0->ap_pulse, 255, 0, 255, 4, 4, 3, 3, 0, 0, 0, ntrue);
- ns_sound_start (mfb->gvens->eef_pulse2.sound);
- ns_sound_post (mfb->gvens->eef_pulse2.sound, 0, -1, 0);
- ret =0;
- }
- }
- }
- }
- return ret;
- }
- # define STAGE_TASK_NUMS 5
- int (*sub_stage_set[STAGE_TASK_NUMS]) (struct MFF_base *) = {
- stage_0_task_doncm,
- stage_0_task_doncm2,
- stage_0_task_docapcom,
- stage_0_task_dotalk,
- stage_0_task_dogamelogo
- };
- STAGE_STATUS stage_0 (struct MFF_base *mfb) {
- int e;
- STAGE_STATUS s = STAGE_RUNING;
- struct stage_0ctx *s0 = mfb->gvens->cur_stage_context;
- if (mfb->gvens->stage_init == nfalse) {
- /* init stage - 0 env */
- mfb->gvens->stage_init = ntrue;
- /* open bg / alpha enable */
- }
- /*play sound alpha font .*/
- e = sub_stage_set[s0->task_id] (mfb);
- if (e == 0) {
- /* pass current task, to next */
- s0->task_id ++;
- if (s0->task_id == STAGE_TASK_NUMS) {
- /* current stage comeplete */
- s = STAGE_PASS;
- }
- }
- /* poll sub status */
- return s;
- }
Add Comment
Please, Sign In to add comment