process cred_texto (fuentes1,ctdesp, string cttexto)
begin
     graph=write_in_map(fuentes1,cttexto,4);
     x=160;
     y=father.y+ctdesp;
     while (y>-20)
           y=father.y+ctdesp;
           frame;
     end
     unload_map(file,graph);
end

process cred_img (graph1,graph2,cidesp)
begin
     graph=graph1;
     x=160;
     y=father.y+cidesp;
     while (y>-20)
           y=father.y+cidesp;
           if ((y%8)==0)
              if (graph==graph1) graph=graph2; else graph=graph1; end
           end
           frame;
     end
end

process creditos ()
private
       fuentes1;
       fuentes2;
       cont1;
       max_desp[2];
       ant_down;
       musica;
begin
     for (cont1=0;cont1<100;cont1++) frame; end
     while(key(_enter)) frame; end
     load_pal("century_cred2.fnt");
     fuentes1=load_fnt("century_cred1.fnt");
     fuentes2=load_fnt("century_cred2.fnt");
     graficos1=load_fpg("creditos.fpg");
     musica=load_song("jpc_cred.ogg");
     put_screen(graficos1,1);
     max_desp[0]=120;
     max_desp[1]=90;
     max_desp[2]=-950;
     fade(100,100,100,1);
     while(fading) frame; end
     
     play_song(musica,1);
     y=120;
     cont1=0;
     cred_texto(fuentes2,-20,"Ideado, diseñado y");
     cred_texto(fuentes2,0,"programado por:");
     cred_texto(fuentes1,20,"Carlos A. Lopez Ortin");
     cred_texto(fuentes1,100,"Saber mas");
     cred_texto(fuentes1,130,"¿en serio quieres saber mas?");
     loop
         //comprueba si el usuario quiere segir layendo
         if (key(_down) && !ant_down)
            cont1++;
            ant_down=true;
         end
         if (!key(_down) && ant_down) ant_down=false; end
         //comprueba si hemos llegado al tope de la zona de lectura
         //if (cont1<2)
            if (y>max_desp[cont1]) y--; end
         /*else
             y--;
         end*/
         //generador de lineas según el desplazamiento
         switch (y)
         case 40: cred_texto(fuentes2,-y+260,"Idea original:"); end
         case 20: cred_texto(fuentes1,-y+260,"Carlos A. Lopez Ortin."); end
         case -40: cred_texto(fuentes2,-y+260,"Programacion:"); end
         case -60: cred_texto(fuentes1,-y+260,"Carlos A. Lopez Ortin."); end
         case -100: cred_texto(fuentes2,-y+260,"Programacion adicional:"); end
         case -120: cred_texto(fuentes1,-y+260,"Fenix Team."); end
         case -140: cred_texto(fuentes1,-y+260,"Puck2099."); end
         case -200: cred_texto(fuentes2,-y+260,"Graficos:"); end
         case -220: cred_texto(fuentes1,-y+260,"Carlos A. Lopez Ortin."); end
         case -280: cred_texto(fuentes2,-y+260,"Fotografia:"); end
         case -300: cred_texto(fuentes1,-y+260,"Carlos A. Lopez Ortin."); end
         case -340: cred_texto(fuentes2,-y+260,"Iluminacion:"); end
         case -360: cred_texto(fuentes1,-y+260,"Dios."); end
         case -400: cred_texto(fuentes2,-y+260,"Modelo:"); end
         case -420: cred_img(2,3,-y+260); end
         case -480: cred_texto(fuentes2,-y+260,"Sonido:"); end
         case -500: cred_texto(fuentes1,-y+260,"Carl... ejem."); end
         case -520: cred_texto(fuentes1,-y+260,"Banco de sonidos MIDI para"); end
         case -540: cred_texto(fuentes1,-y+260,"W98 de tarjeta de sonido SB."); end
         case -600: cred_texto(fuentes2,-y+260,"Musica:"); end
         case -630: cred_texto(fuentes1,-y+260,"Marco A. Romero, "+chr(34)+"Capzo"+chr(34)); end
         case -650: cred_img(2,3,-y+260); end
         case -790: cred_texto(fuentes2,-y+260,"AND YOU."); end
         case -949: write(fuentes2,320,240,8,"Pulsa START"); end
         end
         
         if (key(_enter)) break; end
         frame;
     end

     if (is_playing_song()) fade_music_off(2000); end
     fade(0,0,0,1);
     while(fading) frame; end
     cont1=get_id(type cred_texto);
     while (cont1!=0)
           signal(cont1,s_kill);
           cont1=get_id(type cred_texto);
     end
     cont1=get_id(type cred_img);
     while (cont1!=0)
           signal(cont1,s_kill);
           cont1=get_id(type cred_img);
     end
     delete_text(all_text);
     clear_screen();
     unload_fnt(fuentes1);
     unload_fpg(graficos1);
     unload_song(musica);
     estado=3;
     frame;
end
