diff --git a/datos/sprites.dat b/datos/sprites.dat index 1934d32..0159030 100755 Binary files a/datos/sprites.dat and b/datos/sprites.dat differ diff --git a/grafix.h b/grafix.h index 6f70f09..3ceb128 100644 --- a/grafix.h +++ b/grafix.h @@ -1 +1,32 @@ #pragma once + +#include + +namespace draw +{ + void init(); + + uint8_t *newSurface(const int width, const int height); + uint8_t *loadSurface(const char *filename); + void deleteSurface(const uint8_t *surface); + + void draw(uint8_t *src, uint8_t *dst, uint16_t src_offset, uint16_t w, uint16_t h, uint16_t dst_x, uint16_t dst_y); + void draw(uint8_t *src, uint8_t *dst); + + void cls(const uint8_t color, uint8_t *dst); + + void setPalette(uint8_t *paleta); + uint8_t *getPalette(); + void setColor(const uint8_t index, const uint8_t r, const uint8_t g, const uint8_t b); + void getColor(const uint8_t index, uint8_t *r, uint8_t *g, uint8_t *b); + void blackout(); + + void fadeDown(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t espera); // espera son el nombre de waitVsync a executar en cada iteració del bucle + void fadeUp(const uint8_t *paleta, const uint8_t espera); + + void putPixel(const int x, const int y, const uint8_t color, uint8_t *dst); + void line(const int x1, const int y1, const int x2, const int y2, const uint8_t color, uint8_t *dst); + + void waitVsync(); + void blit(); +} diff --git a/jinput.h b/jinput.h index 1880566..4620ace 100644 --- a/jinput.h +++ b/jinput.h @@ -1,3 +1,10 @@ #pragma once -bool TeclaPuls(uint8_t tecla); \ No newline at end of file +namespace input +{ + void init(); + + bool anyKey(); + bool keyPressed(uint8_t tecla); + uint8_t getKey(); +} \ No newline at end of file diff --git a/midiplay.h b/midiplay.h index 6f70f09..c95a72f 100644 --- a/midiplay.h +++ b/midiplay.h @@ -1 +1,9 @@ #pragma once + +namespace audio +{ + void playMusic(); + bool musicPlaying(); + void stopMusic(); + void unloadMusic(); +} diff --git a/pepe2000_utf8.cpp b/pepe2000_utf8.cpp index 5d19154..fe2d647 100644 --- a/pepe2000_utf8.cpp +++ b/pepe2000_utf8.cpp @@ -146,10 +146,18 @@ #define FINALN03 45 #define FINALN04 46 +#define rosita_enabled 99 +#define job_enabled 199 + +#define pepe_facil 5 +#define pepe_normal 15 +#define pepe_dificil 25 + +#define rosita_facil 6 #define rosita_normal 16 #define rosita_dificil 26 -#define Dream_tour 7 +#define dream_tour 7 #define pepe_malo 0 + 56 #define d_malo1 132 + 56 @@ -287,7 +295,7 @@ uint8_t vides; // : byte; uint8_t num_fase; // : byte; uint8_t mode_rosita, mode_amic, mode_easy, mode_normal, mode_hard; // : byte; - uint8_t mode_easy_r, mode_normal_r, mode_hard_r, mode_Dream_tour; // : byte; + uint8_t mode_easy_r, mode_normal_r, mode_hard_r, mode_dream_tour; // : byte; uint8_t color_pintura, color_marcador_pintura; // : byte; uint8_t R, G, B; // : byte; uint8_t volumen; // : byte; @@ -321,7 +329,7 @@ uint8_t path[20]; // : ARRAY[1..20] of byte; char nom[20][255]; char nom2[20][255]; // : ARRAY[1..20] of string; - uint8_t *paleta; // : tpaleta; + //uint8_t *paleta; // : tpaleta; char frase[255]; // : string; uint16_t numero_G[91]; // : ARRAY [0..90] of word; int32_t puntuacio[5]; // : ARRAY [1..5] of longint; @@ -359,37 +367,37 @@ malo_t malo[max_malos]; /*──────────────────────────────────────────────────────────────────────────*/ -void power_off(uint16_t where) +void power_off(uint8_t *where) { uint16_t i; uint8_t j; - fadedown(0, 0, 0, 0); + draw::fadeDown(0, 0, 0, 0); - cls32(0, where); - volcar32(where, VGA); - set_color(1, 63, 63, 63); + draw::cls(0, where); + draw::draw(where, VGA); + draw::setColor(1, 63, 63, 63); for (int i = 0; i < 320; ++i) - putpixel(i, 100, 1, where); + draw::putPixel(i, 100, 1, where); for (int i = 0; i <= 160; ++i) { - putpixel(i, 100, 0, where); - putpixel(320 - i, 100, 0, where); + draw::putPixel(i, 100, 0, where); + draw::putPixel(320 - i, 100, 0, where); if (i % 2 == 0) - volcar32(where, VGA); + draw::draw(where, VGA); } for (int i = 0; i <= 20; ++i) - espera_VGA(); + draw::waitVsync(); } /*──────────────────────────────────────────────────────────────────────────*/ void load_mif(int num, uint8_t *where) { - espera_VGA(); - cls32(0, VGA); + draw::waitVsync(); + draw::cls(0, VGA); FILE *fich = fopen("datos/graf.mif", "rb"); // Reset(fich); uint8_t num_dibuixos = fgetc(fich); @@ -399,7 +407,7 @@ void load_mif(int num, uint8_t *where) fread(where, 64000, 1, fich); uint8_t paleta[768]; fread(paleta, 768, 1, fich); - setpaleta(paleta); + draw::setPalette(paleta); fclose(fich); } @@ -477,7 +485,7 @@ void load_cfg() } /*──────────────────────────────────────────────────────────────────────────*/ -void ini_midi(char *midi_titol) +void ini_midi(const char *midi_titol) { // [RZC 24/01/2024] [TODO] Reescritura sencera // Si està sonant una música, parar-la @@ -491,7 +499,7 @@ var aux : boolean; intents : word; begin - if midi then begin StopMIDI; unloadmidi; midi:=false; end; + if midi then begin audio::stopMusic; audio::unloadMusic; midi:=false; end; if GM then begin @@ -549,7 +557,7 @@ var aux : boolean; intents : word; mode_easy_r = fgetc(fich); mode_normal_r = fgetc(fich); mode_hard_r = fgetc(fich); - mode_Dream_tour = fgetc(fich); + mode_dream_tour = fgetc(fich); fclose(fich); } @@ -584,7 +592,7 @@ var aux : boolean; intents : word; fputc(mode_easy_r, fich); fputc(mode_normal_r, fich); fputc(mode_hard_r, fich); - fputc(mode_Dream_tour, fich); + fputc(mode_dream_tour, fich); fclose(fich); } @@ -661,9 +669,9 @@ void pinta_number_zoom(uint8_t zoom, uint16_t offset, uint8_t color, uint16_t x, void retard(int centesimes) { uint32_t t = SDL_GetTicks() + centesimes * 10; - while ((SDL_GetTicks() < t) && (!TeclaPuls(SDL_SCANCODE_SPACE))) {}; + while ((SDL_GetTicks() < t) && (!input::keyPressed(SDL_SCANCODE_SPACE))) {}; // [RZC 24/01/0224] [NOTA] Açò del midi estaba dins del bucle este anterior. Crec que és perque necessita anar omplint el buffer - // if (not(playing)) and (midi) then PlayMIDI; + // if (not(audio::musicPlaying())) and (midi) then audio::playMusic; } /*──────────────────────────────────────────────────────────────────────────*/ @@ -671,8 +679,8 @@ void escriu_frase(char *nom, uint8_t color_determinat, uint16_t x,uint16_t y, ui { for (int i=0; i 80 ) { - if (!playing && midi) + if (!audio::musicPlaying() && midi) { ini_midi(musica_final_joc); - if (midi) Playmidi(); + if (midi) audio::playMusic(); } - Put_Sprite_ICE_baix(vaddr2, vaddr, offset, ample, alt, x, i_int); - espera_VGA(); - volcar32(vaddr, VGA); + draw::draw(vaddr2, vaddr, offset, ample, alt, x, i_int); + draw::waitVsync(); + draw::draw(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } @@ -1412,28 +1415,28 @@ void credits() if (num < 5) while (i_int > -alt) { - if (!playing && midi) + if (!audio::musicPlaying() && midi) { ini_midi(musica_final_joc); - if (midi) Playmidi(); + if (midi) audio::playMusic(); } - Put_Sprite_ICE_dalt(vaddr2, vaddr, offset, ample, alt, x, i_int); - espera_VGA(); - volcar32(vaddr, VGA); + draw::draw(vaddr2, vaddr, offset, ample, alt, x, i_int); + draw::waitVsync(); + draw::draw(vaddr, VGA); velocitat++; if (velocitat % 5 == 0) i_int--; } } uint32_t t = SDL_GetTicks()+10000; - do {} while (!QteclaPuls() && SDL_GetTicks()0) { @@ -1922,19 +1913,20 @@ void pinta_marcadors() /*──────────────────────────────────────────────────────────────────────────*/ void ini_pantalla() +/* var i,j : word; i_int:integer; offset : word; VirscrFase : Ptr_pantalla; vaddrFase : Word; - +*/ { - uint8_t *vaddrFase = (uint8_t*)malloc(64000); // 6400??? + uint8_t *vaddrFase = (uint8_t*)malloc(6400); // 6400??? load_mif(FASES,vaddr); - Cls32(0, vaddrFase); - offset = ((num_fase / 6)*160)+((((num_fase-1) % 5)*40)*320); - PutSprite(vaddr, vaddrFase, offset, 160, 40, 0, 0); + draw::cls(0, vaddrFase); + const uint16_t offset = ((num_fase / 6)*160)+((((num_fase-1) % 5)*40)*320); + draw::draw(vaddr, vaddrFase, offset, 160, 40, 0, 0); if (!mode_nocturne) { @@ -1954,63 +1946,63 @@ var i,j : word; // pinta les pareds for (int i=0; i<38; ++i) for (int j=0; j<29; ++j) - if (pantalla[i,j]==es_una_paret) pinta(dib_pared, 255, (i*6)+4, (j+1)*6, vaddr2); + if (pantalla[i][j]==es_una_paret) pinta(dib_pared, 255, (i*6)+4, (j+1)*6, vaddr2); // pinta a Rosita i a la presó if (num_fase==ultima_fase) { pinta(rosita, 255, 16, 96, vaddr2); pinta(preso, 255, 22, 96, vaddr2); - for (int i=97; i<=102; ++i) putpixel(16, i, 237, vaddr2); - putpixel(17, 97, 237, vaddr2); - putpixel(22, 97, 237, vaddr2); - putpixel(17, 102, 237, vaddr2); - putpixel(22, 102, 237, vaddr2); + for (int i=97; i<=102; ++i) draw::putPixel(16, i, 237, vaddr2); + draw::putPixel(17, 97, 237, vaddr2); + draw::putPixel(22, 97, 237, vaddr2); + draw::putPixel(17, 102, 237, vaddr2); + draw::putPixel(22, 102, 237, vaddr2); } // pinta el marcador de pintura for (int i=pos_esq_m_p; i<=pos_dreta_m_p; ++i) for (int j=(pos_base_m_p-(pintura / tamany_m_p)); j<=pos_base_m_p; ++j) { - putpixel(i, j, color_marcador_pintura, vaddr2); - putpixel(pos_esq_m_p-1, j, color_borde_m_p, vaddr2); - putpixel(pos_dreta_m_p+1, j, color_borde_m_p, vaddr2); - putpixel(i, (pos_base_m_p-(max_pintura / tamany_m_p)-1), color_borde_m_p, vaddr2); - putpixel(i, (pos_base_m_p+1), color_borde_m_p, vaddr2); + draw::putPixel(i, j, color_marcador_pintura, vaddr2); + draw::putPixel(pos_esq_m_p-1, j, color_borde_m_p, vaddr2); + draw::putPixel(pos_dreta_m_p+1, j, color_borde_m_p, vaddr2); + draw::putPixel(i, (pos_base_m_p-(max_pintura / tamany_m_p)-1), color_borde_m_p, vaddr2); + draw::putPixel(i, (pos_base_m_p+1), color_borde_m_p, vaddr2); } // coloca la fase - getpaleta(paleta); - blackout(); - cls32(0, vaddr); - PutBloc(vaddr2, 0, vaddr, 249, 200, 0, 0); - volcar32(vaddr, VGA); - fadeup(paleta, 0); + uint8_t *paleta = draw::getPalette(); + draw::blackout(); + draw::cls(0, vaddr); + draw::draw(vaddr2, vaddr, 0, 249, 200, 0, 0); + draw::draw(vaddr, VGA); + draw::fadeUp(paleta, 0); // posa el marcador for (int j=0; j<=49; ++j) { const int i = j << 1; - PutBloc(vaddr2, 248+((99-i)*320), vaddr, 72, i+1, 248, 0); - PutBloc(vaddr2, 32248, vaddr, 72, i+1, 248, 199-i); - PutBloc(vaddr2, 0, vaddr, 249, 200, 0, 0); - espera_VGA(); - volcar32(vaddr, VGA); + draw::draw(vaddr2, vaddr, 248+((99-i)*320), 72, i+1, 248, 0); + draw::draw(vaddr2, vaddr, 32248, 72, i+1, 248, 199-i); + draw::draw(vaddr2, vaddr, 0, 249, 200, 0, 0); + draw::waitVsync(); + draw::draw(vaddr, VGA); } // posa el lletrero de fase X if (story_mode_mode) for (int i=-40; i<=80; ++i) { - volcar32(vaddr2, vaddr); + draw::draw(vaddr2, vaddr); if (i<20) - Put_Sprite_ICE_esquerra(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); + draw::draw(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); else - Put_Sprite_ICE_dreta(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); + draw::draw(vaddrFase, vaddr, 0, 160, 40, i << 2, 80); - if (i==14) delay(2000); - espera_VGA(); - Volcar32(vaddr, VGA); + if (i==14) SDL_Delay(2000); + draw::waitVsync(); + draw::draw(vaddr, VGA); } free(vaddrFase); } @@ -2020,17 +2012,17 @@ void level_complete() { if (midi) { - StopMIDI(); - unloadmidi(); + audio::stopMusic(); + audio::unloadMusic(); midi = false; } if (!mode_nocturne) { load_mif(DONE01, vaddr); - espera_vga(); - volcar32(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr, VGA); ini_midi(musica_canvi_fase); - if (midi) Playmidi(); + if (midi) audio::playMusic(); const uint32_t t = SDL_GetTicks() + 4000; do {} while( SDL_GetTicks() < t ); @@ -2039,19 +2031,19 @@ void level_complete() else { load_mif(DONE05, vaddr); - espera_vga(); - volcar32(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr, VGA); ini_midi(musica_canvi_fase_n); - if (midi) Playmidi(); + if (midi) audio::playMusic(); if (midi) - do {} while(playing); + do {} while(audio::musicPlaying()); else - for (int i=0; i<=300; ++i) espera_VGA(); + for (int i=0; i<=300; ++i) draw::waitVsync(); borrat_de_pantalla(vaddr); if (midi) { - StopMIDI(); - unloadmidi(); + audio::stopMusic(); + audio::unloadMusic(); midi = false; } } @@ -2060,7 +2052,9 @@ void level_complete() /*──────────────────────────────────────────────────────────────────────────*/ void volcat_de_pantalla() { - volcar32(vaddr, vaddr2); + uint32_t segons = SDL_GetTicks()/1000; + + draw::draw(vaddr, vaddr2); // inicialització i comprobació de la fletxa de GO! fletxa_final_fase = true; @@ -2071,18 +2065,18 @@ void volcat_de_pantalla() // pinta el rellontge if (rellontge.viu) - switch ((c % 48)/12) + switch ((SDL_GetTicks() % 500)/125) { case 0: case 2: pinta(rellontge_dib, 255, rellontge.i, rellontge.j, vaddr2); break; - case 1: pinta(rellontge_dib_X, 255, rellontge.i, rellontge.j, vaddr2); break; - case 3: pinta(rellontge_dib_Y, 255, rellontge.i, rellontge.j, vaddr2); break; + case 1: pinta(rellontge_dib_x, 255, rellontge.i, rellontge.j, vaddr2); break; + case 3: pinta(rellontge_dib_y, 255, rellontge.i, rellontge.j, vaddr2); break; } if ( (x==pos_ini_x_pepe) && (y==pos_ini_y_pepe) ) en_casa = true; // pinta a PEPE, ROSITA o JOB - if (mode_nocturne && !rosita_selected &&d !amic_selected) pinta(gorro, 255, x, y-6, vaddr2); + if (mode_nocturne && !rosita_selected && !amic_selected) pinta(gorro, 255, x, y-6, vaddr2); if (pintura > 0) if (rosita_selected) pinta(rosita_p, 255, x, y, vaddr2); @@ -2123,18 +2117,18 @@ void volcat_de_pantalla() // pinta a rosita en la pressó if (num_fase == ultima_fase) { - if ((s%4)==0) + if ((segons%4)==0) pinta(rosita, 255, 16, 96, vaddr2); else - if ((s%4)==1) + if ((segons%4)==1) pinta(rosita2, 255, 16, 96, vaddr2); else - if ((s%4)==2) + if ((segons%4)==2) pinta(rosita, 255, 16, 96, vaddr2); else pinta(rosita3, 255, 16, 96, vaddr2); - if ( ((s%10)==0) || ((s%10)==1) ) + if ( ((segons%10)==0) || ((segons%10)==1) ) { pinta(rosita_chillido, 255, 16, 96, vaddr2); pinta_number(help_1, 255, 12, 87, vaddr2); @@ -2143,7 +2137,10 @@ void volcat_de_pantalla() } // pinta el mapa - if (map) put_map(pantalla, 255, 270, 1, 38, 29, vaddr2); + if (map) + for (int i=0; i<28; ++i) + for (int j=0; i<29; ++j) + draw::putPixel(270+i, 1+j, pantalla[i][j], vaddr2); // pinta l'altaveu if (amb_so) @@ -2153,7 +2150,7 @@ void volcat_de_pantalla() // pinta la fletxa de GO! if (fletxa_final_fase) - if (c%99 < 50) + if (SDL_GetTicks()%999 < 50) { pinta_number(fletxa_final01, 255, 250, 90, vaddr2); pinta_number(fletxa_final02, 255, 259, 90, vaddr2); @@ -2168,8 +2165,8 @@ void volcat_de_pantalla() pinta_number(fletxa_final04, 255, 257, 99, vaddr2); } - espera_vga(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); } /*──────────────────────────────────────────────────────────────────────────*/ @@ -2193,7 +2190,7 @@ void omplir_pot() else pinta(pepe, 255, x, y, vaddr); - Play_WAV(sample[so_pot]); + //Play_WAV(sample[so_pot]); while (pintura < max_pintura) { @@ -2202,10 +2199,10 @@ void omplir_pot() if (pintura < max_pintura) pintura++; pinta_marcadors(); if (time_attack_mode) posa_el_temps(vaddr); - if ((pintura==Max_pintura) || (pintura%50==0)) Play_WAV(sample[so_pot]); + //if ((pintura==max_pintura) || (pintura%50==0)) Play_WAV(sample[so_pot]); volcat_de_pantalla(); } - nosound(); + //nosound(); } en_casa = true; } @@ -2234,7 +2231,7 @@ void pinta_un_bloc(uint8_t color, uint8_t queda_pintura) else punts = punts + (((25-(5*dificultat))+valor_del_bloc)*2); - if ( (punts%20000) > (25-(5*dificultat)+valor_del_bloc) donar_vida = true; + if ( (punts%20000) > (25-(5*dificultat)+valor_del_bloc) ) donar_vida = true; if ( (vides<9) && story_mode_mode && donar_vida) if (punts>100) if ( (punts%20000) < (25-(5*dificultat)+valor_del_bloc) ) @@ -2243,9 +2240,9 @@ void pinta_un_bloc(uint8_t color, uint8_t queda_pintura) donar_vida = false; vides++; pinta_number_zoom(5, numero_G[vides], 255, 260, 150, VGA); - if (amb_so) - PlayWav(sample[so_ring]);/*so_de(vida_extra)*/ - else + //if (amb_so) + // PlayWav(sample[so_ring]);/*so_de(vida_extra)*/ + //else retard(40); } } @@ -2269,7 +2266,7 @@ void pinta_un_bloc(uint8_t color, uint8_t queda_pintura) /*──────────────────────────────────────────────────────────────────────────*/ void animacio_mort() { - Play_WAV(sample[so_mort]); + //Play_WAV(sample[so_mort]); for (int i=1; i<=5; ++i) { retard(10); @@ -2292,7 +2289,7 @@ void animacio_mort() pinta(pepe_m2, 255, x, y, VGA); //if amb_so then sound(1000); } - nosound(); + //nosound(); } /*──────────────────────────────────────────────────────────────────────────*/ @@ -2309,7 +2306,7 @@ void animacio_alegria() pinta(gorro, 255, x, y-6, VGA); } - for int i=1; i<=1; ++i) + for (int i=1; i<=10; ++i) { retard(10); if (rosita_selected) @@ -2356,7 +2353,7 @@ void mort() if (el_que_hi_havia == es_un_bloc_pintat) pinta(pepe, color_pintura, x, y, vaddr); volcat_de_pantalla(); //so_de(mos_a_pepe); - Play_WAV(sample[so_mort]); + //Play_WAV(sample[so_mort]); animacio_mort(); pantalla[x/6][(y/6)-1] = el_que_hi_havia; //es_un_bloc_pintat x = pos_ini_x_pepe; @@ -2380,9 +2377,9 @@ void mira_el_que_hi_ha(uint8_t cap_on_vaig) switch (cap_on_vaig) { case amunt: que_hi_ha = pantalla[x/6][((y-max_m_y)/6)-1]; break; - case dreta: que_hi_ha = pantalla[(x+max_m_x)/6)][(y/6)-1]; break; + case dreta: que_hi_ha = pantalla[(x+max_m_x)/6][(y/6)-1]; break; case avall: que_hi_ha = pantalla[x/6][((y+max_m_y)/6)-1]; break; - case esquerra: que_hi_ha = pantalla[(x-max_m_x) div 6][(y/6)-1]; break; + case esquerra: que_hi_ha = pantalla[(x-max_m_x)/6][(y/6)-1]; break; } } @@ -2403,9 +2400,9 @@ void munta_velocitat_joc() pinta_number_zoom(6, numero_G[velocitat_pepe], 255, 110, 80, VGA); if (amb_so) { - sound(velocitat_pepe*150); + //sound(velocitat_pepe*150); retard(1); - nosound(); + //nosound(); } } @@ -2416,9 +2413,9 @@ void baixa_velocitat_joc() pinta_number_zoom(6, numero_G[velocitat_pepe], 255, 110, 80, VGA); if (amb_so) { - sound(velocitat_pepe*150); + //sound(velocitat_pepe*150); retard(1); - nosound(); + //nosound(); } } @@ -2427,14 +2424,14 @@ void moure(uint8_t direccio) //var desp_pixel:byte; { cap_on_va_Pepe = direccio; - SWITCH (direccio) + switch (direccio) { case amunt: if ( ((y-max_m_y)>=l0) && (!en_casa) && (!(pantalla[x/6][((y-max_m_y) / 6)-1] == es_una_paret)) ) { mira_el_que_hi_ha(direccio); if (que_hi_ha == es_un_bicho) - mort() + mort(); else { pinta_un_bloc(color_pintura, pintura); @@ -2489,7 +2486,7 @@ void moure(uint8_t direccio) { mira_el_que_hi_ha(direccio); if (en_casa && (que_hi_ha == es_un_bicho)) ja_no_pots_eixir(); - if (que_hi_ha == es_un_bicho) then + if (que_hi_ha == es_un_bicho) mort(); else { @@ -2519,16 +2516,15 @@ void ini_rellontge() rellontge.i = (a*6)+4; rellontge.j = (b+1)*6; rellontge.viu = true; - Play_WAV(sample[so_ring]); + //Play_WAV(sample[so_ring]); sense_rellontge = false; } /*──────────────────────────────────────────────────────────────────────────*/ void naix_malo(uint8_t numero) -//var a,b : byte; cont : word; { malo[numero].viu = true; - cont = 0; + uint16_t cont = 0; uint8_t a, b; do { @@ -2546,12 +2542,12 @@ void naix_malo(uint8_t numero) malo[numero].i = a; malo[numero].j = b; //so_de(naiximent_del_malo); - Play_WAV(sample[so_malo]); + //Play_WAV(sample[so_malo]); pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); } /*──────────────────────────────────────────────────────────────────────────*/ -void mou_malo(uint8_t numero, uint8_t direccio); +void mou_malo(uint8_t numero, uint8_t direccio) { switch (direccio) { @@ -2559,7 +2555,7 @@ void mou_malo(uint8_t numero, uint8_t direccio); if ( (pantalla[malo[numero].i][malo[numero].j-1] == es_un_bloc_pintat) && (!(pantalla[malo[numero].i][malo[numero].j-1] == es_un_bicho)) ) { pinta(malo[numero].dibuix, color_pintura, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); - pantalla[malo[numero].i, malo[numero].j] = es_un_bloc_pintat; + pantalla[malo[numero].i][malo[numero].j] = es_un_bloc_pintat; malo[numero].j--; pinta(malo[numero].dibuix, 255, (malo[numero].i*6)+4, (malo[numero].j+1)*6, vaddr); pantalla[malo[numero].i][malo[numero].j] = es_un_bicho; @@ -2708,8 +2704,8 @@ void load_setup_i_versio() const int color = 80; bool tot_ok = true; - espera_VGA(); - cls32(226, VGA); + draw::waitVsync(); + draw::cls(226, VGA); escriu_frase("PEPE EL PINTOR", color, 20, 20, vaddr, 0, 0, 1); escriu_frase("VERSIO 1.70 BUILD 3", color, 20, 30, vaddr, 0, 0, 1); @@ -2718,12 +2714,12 @@ void load_setup_i_versio() if (!fich) { tot_ok = false; - escriu_frase('GENERANT RECORDS',198,20,110,vaddr,0,0,1); - nom[1] = "SERGI"; puntuacio[1] = 200000; - nom[2] = "PEPE"; puntuacio[2] = 150000; - nom[3] = "ICEKAS"; puntuacio[3] = 125000; - nom[4] = "ROSITA"; puntuacio[4] = 100000; - nom[5] = "JOB"; puntuacio[5] = 50000; + escriu_frase("GENERANT RECORDS", 198, 20, 110, vaddr, 0, 0, 1); + strcpy(nom[1], "SERGI"); puntuacio[1] = 200000; + strcpy(nom[2], "PEPE"); puntuacio[2] = 150000; + strcpy(nom[3], "ICEKAS"); puntuacio[3] = 125000; + strcpy(nom[4], "ROSITA"); puntuacio[4] = 100000; + strcpy(nom[5], "JOB"); puntuacio[5] = 50000; fich = fopen("datos/story.dat", "w"); for (int i = 0; i < 6; ++i) @@ -2738,12 +2734,12 @@ void load_setup_i_versio() if (!fich) { tot_ok = false; - escriu_frase('GENERANT RECORDS',198,20,110,vaddr,0,0,1); - nom2[1] = "SERGI"; minuts[1] = 1; segons_tabla[1] = 45; - nom2[2] = "PEPE"; minuts[2] = 2; segons_tabla[2] = 00; - nom2[3] = "ICEKAS"; minuts[3] = 2; segons_tabla[3] = 10; - nom2[4] = "ROSITA"; minuts[4] = 2; segons_tabla[4] = 20; - nom2[5] = "JOB"; minuts[5] = 2; segons_tabla[5] = 30; + escriu_frase("GENERANT RECORDS", 198, 20, 110, vaddr, 0, 0, 1); + strcpy(nom2[1], "SERGI"); minuts[1] = 1; segons_tabla[1] = 45; + strcpy(nom2[2], "PEPE"); minuts[2] = 2; segons_tabla[2] = 00; + strcpy(nom2[3], "ICEKAS"); minuts[3] = 2; segons_tabla[3] = 10; + strcpy(nom2[4], "ROSITA"); minuts[4] = 2; segons_tabla[4] = 20; + strcpy(nom2[5], "JOB"); minuts[5] = 2; segons_tabla[5] = 30; fich = fopen("datos/time.dat", "w"); for (int i = 0; i < 6; ++i) @@ -2761,7 +2757,7 @@ void load_setup_i_versio() escriu_frase("PULSA UNA TECLA PER A CONTINUAR...", color, 20, 180, vaddr, 0, 0, 1); - do {} while (!QteclaPuls); + do {} while (!input::anyKey()); } /*──────────────────────────────────────────────────────────────────────────*/ @@ -2769,7 +2765,7 @@ void story_mode() { historia(); num_fase = 1; - + bool eixir = false; do { contador = 0; @@ -2779,89 +2775,84 @@ void story_mode() if (num_fase = 1) punts = 0; // if not(mode_nocturne) then pantalla_presentacio(num_fase); ini_pantalla(); - volcar32(vaddr2, vaddr); + eixir = false; + draw::draw(vaddr2, vaddr); pinta_marcadors(); - bool eixir = false; - if (midi) then - { - StopMIDI(); - unloadmidi(); - midi = false; - } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; } if (mode_nocturne) ini_midi(musica_fase_nit); else ini_midi(musica_fase); - if (midi) Playmidi(); + if (midi) audio::playMusic(); /*------------------------------*/ do { - if (!playing && midi) PlayMIDI(); + if (!audio::musicPlaying() && midi) audio::playMusic(); menejant = false; contador++; if (retard_pepe>0) retard_pepe--; - if (teclapuls(SDL_SCANCODE_KP_PLUS)) then + if (input::keyPressed(SDL_SCANCODE_KP_PLUS)) { munta_velocitat_joc(); - do {} while (TeclaPuls(SDL_SCANCODE_KP_PLUS)); // [RZC 25/01/2004] [TODO] Açò no va a funcionar en SDL. Fer un keyDown i un keyPress. Revisar el tot el codi. + do {} while (input::keyPressed(SDL_SCANCODE_KP_PLUS)); // [RZC 25/01/2004] [TODO] Açò no va a funcionar en SDL. Fer un keyDown i un keyPress. Revisar el tot el codi. } - if (teclapuls(SDL_SCANCODE_KP_MINUS)) then + if (input::keyPressed(SDL_SCANCODE_KP_MINUS)) { baixa_velocitat_joc(); - do {} while (TeclaPuls(SDL_SCANCODE_KP_MINUS)); + do {} while (input::keyPressed(SDL_SCANCODE_KP_MINUS)); } if (retard_pepe == 0) - if (teclapuls(tecla_amunt)) - moure(amunt) + if (input::keyPressed(tecla_amunt)) + moure(amunt); else - if (teclapuls(tecla_avall)) - moure(avall) + if (input::keyPressed(tecla_avall)) + moure(avall); else - if (teclapuls(tecla_dreta)) - moure(dreta) + if (input::keyPressed(tecla_dreta)) + moure(dreta); else - if (teclapuls(tecla_esquerra)) + if (input::keyPressed(tecla_esquerra)) moure(esquerra); - if (TeclaPuls(SDL_SCANCODE_M)) + if (input::keyPressed(SDL_SCANCODE_M)) { map = !map; - do {} while (TeclaPuls(SDL_SCANCODE_M)); + do {} while (input::keyPressed(SDL_SCANCODE_M)); } /*---------*/ - /* if TeclaPuls(KeyN) then + /* if input::keyPressed(KeyN) then begin final_fase:=true; num_fase:=9; end; - if TeclaPuls(KeyB) then final_fase:=true;*/ + if input::keyPressed(KeyB) then final_fase:=true;*/ /*---------*/ - if (teclapuls(SDL_SCANCODE_1)) + if (input::keyPressed(SDL_SCANCODE_1)) { amb_so = false; //!amb_so - repeat until not(TeclaPuls(SDL_SCANCODE_1)); + do {} while (input::keyPressed(SDL_SCANCODE_1)); } - if (teclapuls(SDL_SCANCODE_ESCAPE)) + if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { rellontge.temps = rellontge.temps - SDL_GetTicks(); escriu_frase("JOC DETINGUT", 147, 69, 89, vaddr2, 0, 0, 0); escriu_frase("(*ESC* PER A EIXIR)", 147, 38, 101, vaddr2, 0, 0, 0); - espera_VGA(); - volcar32(vaddr2, VGA); - do {} while (TeclaPuls(SDL_SCANCODE_ESCAPE)); - do {} while (!QteclaPuls()); - if (TeclaPuls(SDL_SCANCODE_ESCAPE)) eixir = true; + draw::waitVsync(); + draw::draw(vaddr2, VGA); + do {} while (input::keyPressed(SDL_SCANCODE_ESCAPE)); + do {} while (!input::anyKey()); + if (input::keyPressed(SDL_SCANCODE_ESCAPE)) eixir = true; rellontge.temps = rellontge.temps + SDL_GetTicks(); } @@ -2871,9 +2862,9 @@ void story_mode() malos_quets = true; rellontge.temps = SDL_GetTicks()+10; rellontge.viu = false; - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_campanes); - if (midi) Playmidi(); + if (midi) audio::playMusic(); } fer_apareixer_els_malos(); @@ -2887,12 +2878,12 @@ void story_mode() if (SDL_GetTicks() >= rellontge.temps) { malos_quets = false; - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } if (mode_nocturne) ini_midi(musica_fase_nit); else ini_midi(musica_fase); - if (midi) Playmidi(); + if (midi) audio::playMusic(); } } @@ -2909,8 +2900,8 @@ void story_mode() x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); - fadedown(0,0,0,2); - if (midi) { StopMIDI(); unloadmidi(); midi = false; } + draw::fadeDown(0,0,0,2); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi = false; } level_complete(); num_fase++; } @@ -2922,10 +2913,10 @@ void story_mode() x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); - fadedown(0,0,0,3); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,3); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } historia_final(); - mode_Dream_Tour = Dream_Tour; + mode_dream_tour = dream_tour; save_records(); } else @@ -2935,8 +2926,8 @@ void story_mode() x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); - fadedown(0,0,0,3); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,3); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } if (dificultat == dificil) { historia_final(); @@ -2995,14 +2986,14 @@ void story_mode() if (no_queden_vides) { - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } missatge_game_over(); } if (eixir) { - fadedown(0,0,0,0); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,0); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } } @@ -3013,31 +3004,31 @@ void time_attack() num_fase = 0; ini_vars(num_fase); ini_pantalla(); - volcar32(vaddr2, vaddr); + draw::draw(vaddr2, vaddr); pinta_marcadors(); dificultat = normal; rosita_selected = false; amic_selected = false; color_pintura = 162; color_marcador_pintura = 162; - espera_VGA(); - volcar32(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr, VGA); pinta_marcadors(); volcat_de_pantalla(); bool eixir = false; - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_time_attack); - if (midi) Playmidi(); + if (midi) audio::playMusic(); contador = 0; - do {} while (!TeclaPuls(tecla_esquerra)); + do {} while (!input::keyPressed(tecla_esquerra)); pilla_temps(); //------------------------------------------------------------------------------------------ do { - if (!playing && midi) PlayMIDI(); + if (!audio::musicPlaying() && midi) audio::playMusic(); contador++; if (retard_pepe > 0) retard_pepe--; @@ -3046,31 +3037,31 @@ void time_attack() if ( retard_pepe == 0 ) { - if ( teclapuls(tecla_amunt) ) + if ( input::keyPressed(tecla_amunt) ) moure(amunt); else - if ( teclapuls(tecla_avall) ) + if ( input::keyPressed(tecla_avall) ) moure(avall); else - if ( teclapuls(tecla_dreta) ) + if ( input::keyPressed(tecla_dreta) ) moure(dreta); else - if ( teclapuls(tecla_esquerra) ) + if ( input::keyPressed(tecla_esquerra) ) moure(esquerra); } - if ( teclapuls(SDL_SCANCODE_1) ) + if ( input::keyPressed(SDL_SCANCODE_1) ) { amb_so = false; //not(amb_so); - do {} while(TeclaPuls(SDL_SCANCODE_1)); + do {} while(input::keyPressed(SDL_SCANCODE_1)); } - if ( teclapuls(SDL_SCANCODE_ESCAPE) ) + if ( input::keyPressed(SDL_SCANCODE_ESCAPE) ) { eixir = true; } - /*if TeclaPuls(KeyN) then final_fase:=true;*/ + /*if input::keyPressed(KeyN) then final_fase:=true;*/ fer_apareixer_els_malos(); @@ -3083,36 +3074,39 @@ void time_attack() } while ( !(eixir || final_fase || no_queden_vides) ); //------------------------------------------------------------------------------------------ - if (midi) { StopMIDI(); unloadmidi(); midi=false; } - if (final_fase + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } + if (final_fase) { pinta(pepe, color_pintura, x, y, VGA); x = pos_ini_x_pepe; y = pos_ini_y_pepe; animacio_alegria(); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } resultat_time_attack(); } else if (eixir) { - fadedown(0,0,0,0); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,0); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } if (no_queden_vides) { missatge_game_over(); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } } } /*──────────────────────────────────────────────────────────────────────────*/ +uint8_t pos, pos_dif, pos_m, cord_y; +uint8_t percentatge; + void ini_estreles() { - cls32(0, vaddr); + draw::cls(0, vaddr); for (int i=0; i<10; ++i) { estreles[i].x = rand()%290; @@ -3133,89 +3127,92 @@ void time_attack() } else estreles[i].y = estreles[i].y + (estreles[i].velocitat); - Putsprite(from, where, 26747, 9, 8, estreles[i].x, estreles[i].y); + draw::draw(from, where, 26747, 9, 8, estreles[i].x, estreles[i].y); } } void actualitza_options(uint8_t *from, uint8_t *where) { - cls32(0, vaddr2); + draw::cls(0, vaddr2); for (int i=0; i<=3; ++i) for (int j=0; j<=5; ++j) - Putsprite(vaddr, where, 48000, 50, 50, j*50, i*50); + draw::draw(vaddr, where, 48000, 50, 50, j*50, i*50); fondo_estreles(vaddr, vaddr2); - Putsprite(from, where, 30400, 165, 28, 70, 5); + draw::draw(from, where, 30400, 165, 28, 70, 5); + + draw::draw(from, where, 39733, 116, 18, 22, 43); - Putsprite(from, where, 39733, 116, 18, 22, 43); if ( amb_so ) - Putsprite(from, where, 40492, 25, 17, 149, 45) + draw::draw(from, where, 40492, 25, 17, 149, 45); else - Putsprite(from, where, 39557, 28, 20, 150, 42); + draw::draw(from, where, 39557, 28, 20, 150, 42); + + draw::draw(from, where, 57332, 113, 19, 20, 81); - Putsprite(from, where, 57332, 113, 19, 20, 81); if (GM) - Putsprite(from, where, 51573, 107, 17, 141, 81) + draw::draw(from, where, 51573, 107, 17, 141, 81); else - Putsprite(from, where, 51684, 130, 20, 141, 81); + draw::draw(from, where, 51684, 130, 20, 141, 81); + + draw::draw(from, where, 45172, 39, 20, 22, 61); - Putsprite(from, where, 45172, 39, 20, 22, 61); switch (volumen) { - case 0 : Putsprite(from, where, 45551, 32, 18, 70, 62); break; - case 1 : Putsprite(from, where, 45580, 16, 18, 70, 62); break; - case 2 : Putsprite(from, where, 45596, 16, 18, 70, 62); break; - case 3 : Putsprite(from, where, 45611, 16, 18, 70, 62); break; - case 4 : Putsprite(from, where, 45626, 16, 18, 70, 62); break; - case 5 : Putsprite(from, where, 45642, 16, 18, 70, 62); break; - case 6 : Putsprite(from, where, 45658, 16, 18, 70, 62); break; - case 7 : Putsprite(from, where, 45673, 16, 18, 70, 62); break; - case 8 : Putsprite(from, where, 45689, 16, 18, 70, 62); break; - case 9 : Putsprite(from, where, 45705, 14, 18, 71, 62); break; - case 10 : Putsprite(from, where, 45720, 40, 18, 70, 62); break; + case 0 : draw::draw(from, where, 45551, 32, 18, 70, 62); break; + case 1 : draw::draw(from, where, 45580, 16, 18, 70, 62); break; + case 2 : draw::draw(from, where, 45596, 16, 18, 70, 62); break; + case 3 : draw::draw(from, where, 45611, 16, 18, 70, 62); break; + case 4 : draw::draw(from, where, 45626, 16, 18, 70, 62); break; + case 5 : draw::draw(from, where, 45642, 16, 18, 70, 62); break; + case 6 : draw::draw(from, where, 45658, 16, 18, 70, 62); break; + case 7 : draw::draw(from, where, 45673, 16, 18, 70, 62); break; + case 8 : draw::draw(from, where, 45689, 16, 18, 70, 62); break; + case 9 : draw::draw(from, where, 45705, 14, 18, 71, 62); break; + case 10 : draw::draw(from, where, 45720, 40, 18, 70, 62); break; } - Putsprite(from, where, 21673, 84, 73, 22, 117); + draw::draw(from, where, 21673, 84, 73, 22, 117); - Putsprite(vaddr, vaddr2, tecla_amunt_dib, 21, 21, 135, 110); - Putsprite(vaddr, vaddr2, tecla_avall_dib, 21, 21, 135, 131); - Putsprite(vaddr, vaddr2, tecla_esquerra_dib, 21, 21, 135, 152); - Putsprite(vaddr, vaddr2, tecla_dreta_dib, 21, 21, 135, 173); + draw::draw(vaddr, vaddr2, tecla_amunt_dib, 21, 21, 135, 110); + draw::draw(vaddr, vaddr2, tecla_avall_dib, 21, 21, 135, 131); + draw::draw(vaddr, vaddr2, tecla_esquerra_dib, 21, 21, 135, 152); + draw::draw(vaddr, vaddr2, tecla_dreta_dib, 21, 21, 135, 173); // fletxes i ESC - Putsprite(vaddr, vaddr2, 31527, 47, 24, 238, 172); + draw::draw(vaddr, vaddr2, 31527, 47, 24, 238, 172); // Complet + percentatge - Putsprite(vaddr, vaddr2, 58405, 70, 17, 200, 120); - Putsprite(vaddr, vaddr2, percentatge*29, 29, 14, 220, 142); + draw::draw(vaddr, vaddr2, 58405, 70, 17, 200, 120); + draw::draw(vaddr, vaddr2, percentatge*29, 29, 14, 220, 142); - Pinta_number(fletxa3, 255, 13, cord_y, vaddr2); + pinta_number(fletxa3, 255, 13, cord_y, vaddr2); } void pinta_marcs(uint16_t posicio) { - volcar32(vaddr, vaddr2); + draw::draw(vaddr, vaddr2); for (int i=posicio; i<=posicio+75; ++i) { - putpixel(i, 11, 15, vaddr2); - putpixel(i, 12, 15, vaddr2); - putpixel(i, 90, 15, vaddr2); - putpixel(i, 91, 15, vaddr2); + draw::putPixel(i, 11, 15, vaddr2); + draw::putPixel(i, 12, 15, vaddr2); + draw::putPixel(i, 90, 15, vaddr2); + draw::putPixel(i, 91, 15, vaddr2); } for (int i=11; i<=91; ++i) { - putpixel(posicio, i, 15, vaddr2); - putpixel(posicio+1, i, 15, vaddr2); - putpixel(posicio+74, i, 15, vaddr2); - putpixel(posicio+75, i, 15, vaddr2); + draw::putPixel(posicio, i, 15, vaddr2); + draw::putPixel(posicio+1, i, 15, vaddr2); + draw::putPixel(posicio+74, i, 15, vaddr2); + draw::putPixel(posicio+75, i, 15, vaddr2); } if (mode_nocturne) { - if (mode_Dream_Tour == Dream_tour) pinta_number_zoom(2, tick, 255, 216, 143, vaddr2); + if (mode_dream_tour == dream_tour) pinta_number_zoom(2, tick, 255, 216, 143, vaddr2); } else if ( (pos==1) || (pos==3) ) @@ -3235,8 +3232,8 @@ void time_attack() if (pos_dif == 2) pinta_number(fletxa, 255, 98, 143, vaddr2); if (pos_dif == 3) pinta_number(fletxa, 255, 98, 168, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); } void desp_marc(uint8_t direccio) @@ -3317,93 +3314,93 @@ void menu_joc() if (mode_easy_r == rosita_facil) percentatge++; if (mode_normal_r == rosita_normal) percentatge++; if (mode_hard_r == rosita_dificil) percentatge++; - if (mode_Dream_tour == Dream_tour) percentatge++; + if (mode_dream_tour == dream_tour) percentatge++; if (mode_nocturne) - load_mif(menu_nit, vaddr) + load_mif(MENU_NIT, vaddr); else - load_mif(menu, vaddr); + load_mif(MENU, vaddr); - load_mif(menu_s, vaddr2); - espera_vga(); - volcar32(vaddr, VGA); + load_mif(MENU_S, vaddr2); + draw::waitVsync(); + draw::draw(vaddr, VGA); if (!mode_nocturne) { - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_title); - if (midi) Playmidi(); + if (midi) audio::playMusic(); } else { - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_nit); - if (midi) Playmidi(); + if (midi) audio::playMusic(); if (!midi) ini_midi(musica_nit); - if (!Playing && midi) PlayMidi(); + if (!audio::musicPlaying() && midi) audio::playMusic(); } int i = 320; if (!mode_nocturne) while (i > 20) { - espera_VGA(); - volcar32(vaddr, VGA); - Put_Sprite_ICE_dreta(vaddr2, VGA, 16983, 142, 26, i, 53); - dec(i, 10); - if (i == 20) Put_Sprite_ICE_dreta(vaddr2, vaddr, 16983, 142, 26, i, 53); + draw::waitVsync(); + draw::draw(vaddr, VGA); + draw::draw(vaddr2, VGA, 16983, 142, 26, i, 53); + i-=10; + if (i == 20) draw::draw(vaddr2, vaddr, 16983, 142, 26, i, 53); } i = 320; while (i > 20) { - espera_VGA(); - volcar32(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr, VGA); if (!mode_nocturne) - Put_Sprite_ICE_dreta(vaddr2, VGA, 28822, 132, 25, i, 90) + draw::draw(vaddr2, VGA, 28822, 132, 25, i, 90); else - Put_Sprite_ICE_dreta(vaddr2, VGA, 28958, 132, 25, i, 90); + draw::draw(vaddr2, VGA, 28958, 132, 25, i, 90); i-=10; if (i == 20) - if (!mode_nocturne) then - Put_Sprite_ICE_dreta(vaddr2, vaddr, 28822, 132, 25, i, 90) + if (!mode_nocturne) + draw::draw(vaddr2, vaddr, 28822, 132, 25, i, 90); else - Put_Sprite_ICE_dreta(vaddr2, vaddr, 28958, 132, 25, i, 90); + draw::draw(vaddr2, vaddr, 28958, 132, 25, i, 90); } i = 320; while (i > 20) { - espera_VGA(); - volcar32(vaddr, VGA); - Put_Sprite_ICE_dreta(vaddr2, VGA, 40982, 152, 24, i, 128); + draw::waitVsync(); + draw::draw(vaddr, VGA); + draw::draw(vaddr2, VGA, 40982, 152, 24, i, 128); i-=10; - if (i == 20) Put_Sprite_ICE_dreta(vaddr2, vaddr, 40982, 152, 24, i, 128); + if (i == 20) draw::draw(vaddr2, vaddr, 40982, 152, 24, i, 128); } i = 320; while (i > 20) { - espera_VGA(); - volcar32(vaddr, VGA); - Put_Sprite_ICE_dreta(vaddr2, VGA, 52182, 103, 30, i, 163); + draw::waitVsync(); + draw::draw(vaddr, VGA); + draw::draw(vaddr2, VGA, 52182, 103, 30, i, 163); i-=10; - if (i == 20) Put_Sprite_ICE_dreta(vaddr2, vaddr, 52182, 103, 30, i, 163); + if (i == 20) draw::draw(vaddr2, vaddr, 52182, 103, 30, i, 163); } i = -35; while (i < 15) { - espera_VGA(); - volcar32(vaddr, VGA); - espera_VGA(); - Put_Sprite_ICE_dalt(vaddr2, VGA, 5463, 133, 33, 23, i); + draw::waitVsync(); + draw::draw(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA, 5463, 133, 33, 23, i); i+=10; - if (i == 15) Put_Sprite_ICE_dalt(vaddr2, vaddr, 5463, 133, 33, 23, i); + if (i == 15) draw::draw(vaddr2, vaddr, 5463, 133, 33, 23, i); } - espera_VGA(); - volcar32(vaddr, VGA); + draw::waitVsync(); + draw::draw(vaddr, VGA); uint32_t temps = SDL_GetTicks()/1000; uint32_t temps2; @@ -3416,21 +3413,21 @@ void menu_joc() do { - if (!playing) + if (!audio::musicPlaying()) if (mode_nocturne) { ini_midi(musica_nit); - if (midi) PlayMIDI(); + if (midi) audio::playMusic(); } else { ini_midi(musica_title); - if (midi) PlayMIDI(); + if (midi) audio::playMusic(); } temps2 = SDL_GetTicks()/1000; - if ( TeclaPuls(SDL_SCANCODE_DOWN) && (pos_m<4) ) + if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_m<4) ) { pos_m++; switch (pos_m) @@ -3440,18 +3437,18 @@ void menu_joc() case 3: cord_y = 138; break; case 4: cord_y = 174; break; } - volcar32(vaddr, vaddr2); + draw::draw(vaddr, vaddr2); pinta_number(fletxa2, 255, 13, cord_y, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); temps = SDL_GetTicks()/1000; temps2 = temps + 1; - Play_WAV(sample[so_fletxa]); - do {} while (TeclaPuls(SDL_SCANCODE_DOWN)); + //Play_WAV(sample[so_fletxa]); + do {} while (input::keyPressed(SDL_SCANCODE_DOWN)); } - if ( TeclaPuls(SDL_SCANCODE_UP) && (pos_m>1) ) + if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_m>1) ) { pos_m--; if (mode_nocturne && (pos_m==1)) pos_m = 2; @@ -3462,33 +3459,33 @@ void menu_joc() case 3: cord_y = 138; break; case 4: cord_y = 174; break; } - volcar32(vaddr, vaddr2); + draw::draw(vaddr, vaddr2); pinta_number(fletxa2, 255, 13, cord_y, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); temps = SDL_GetTicks()/1000; temps2 = temps + 1; - Play_WAV(sample[so_fletxa]); - do {} while (TeclaPuls(SDL_SCANCODE_UP)); + //Play_WAV(sample[so_fletxa]); + do {} while (input::keyPressed(SDL_SCANCODE_UP)); } - volcar32(vaddr, vaddr2); + draw::draw(vaddr, vaddr2); if ( (temps2%2)==0 ) - pinta_number(fletxa2, 255, 13, cord_y, vaddr2) + pinta_number(fletxa2, 255, 13, cord_y, vaddr2); else pinta_number(fletxa2, 255, 15, cord_y, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); - } while ( !(TeclaPuls(SDL_SCANCODE_RETURN)) && !(TeclaPuls(SDL_SCANCODE_ESCAPE)) && !((temps2-temps)>=10) ); + } while ( !(input::keyPressed(SDL_SCANCODE_RETURN)) && !(input::keyPressed(SDL_SCANCODE_ESCAPE)) && !((temps2-temps)>=10) ); - if (TeclaPuls(SDL_SCANCODE_RETURN)) Play_WAV(sample[so_enter]); + //if (input::keyPressed(SDL_SCANCODE_RETURN)) Play_WAV(sample[so_enter]); - if (teclapuls(SDL_SCANCODE_ESCAPE)) + if (input::keyPressed(SDL_SCANCODE_ESCAPE)) { pos_m = 5; - StopMIDI(); + audio::stopMusic(); power_off(vaddr); eixir_del_joc = true; } @@ -3496,7 +3493,7 @@ void menu_joc() if ( (temps2-temps) >= 10 ) { pos_m = 5; - fadedown(0,0,0,0); + draw::fadeDown(0,0,0,0); escriu_records(10); titol_del_joc(); } @@ -3505,16 +3502,16 @@ void menu_joc() if ( (pos_m == 1) && !mode_nocturne ) { time_attack_mode = true; - fadedown(0,0,0,1); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,1); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } time_attack(); } // PEPE VELL if ( pos_m == 3 ) { - fadedown(0,0,0,1); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + draw::fadeDown(0,0,0,1); + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } pepe_text(); } @@ -3522,72 +3519,72 @@ void menu_joc() if ( pos_m == 2 ) { borrat_de_pantalla(vaddr); - do {} while (TeclaPuls(SDL_SCANCODE_RETURN)); + do {} while (input::keyPressed(SDL_SCANCODE_RETURN)); story_mode_mode = true; rosita_selected = false; amic_selected = false; if (mode_nocturne) - load_mif(select_n, vaddr) + load_mif(SELECT_N, vaddr); else - load_mif(select, vaddr); + load_mif(SELECT, vaddr); if ( mode_rosita != rosita_enabled ) { for (int i=137; i<=212; ++i) - for (int j=11; j<=91; j++) putpixel(i, j, 0, vaddr); - putpixel(145, 19, 14, vaddr); - putpixel(197, 44, 14, vaddr); - putpixel(149, 78, 14, vaddr); - putpixel(194, 77, 14, vaddr); - putpixel(172, 54, 14, vaddr); - putpixel(198, 65, 14, vaddr); - putpixel(177, 38, 9, vaddr); - putpixel(169, 82, 9, vaddr); - putpixel(183, 12, 9, vaddr); - putpixel(139, 37, 9, vaddr); - putpixel(211, 81, 9, vaddr); + for (int j=11; j<=91; j++) draw::putPixel(i, j, 0, vaddr); + draw::putPixel(145, 19, 14, vaddr); + draw::putPixel(197, 44, 14, vaddr); + draw::putPixel(149, 78, 14, vaddr); + draw::putPixel(194, 77, 14, vaddr); + draw::putPixel(172, 54, 14, vaddr); + draw::putPixel(198, 65, 14, vaddr); + draw::putPixel(177, 38, 9, vaddr); + draw::putPixel(169, 82, 9, vaddr); + draw::putPixel(183, 12, 9, vaddr); + draw::putPixel(139, 37, 9, vaddr); + draw::putPixel(211, 81, 9, vaddr); } if ( mode_amic != job_enabled ) { for (int i=219; i<=294; ++i) - for (int j=11; j<=91; ++j) putpixel(i, j, 0, vaddr); - putpixel(228, 65, 14, vaddr); - putpixel(290, 26, 14, vaddr); - putpixel(264, 63, 14, vaddr); - putpixel(284, 85, 14, vaddr); - putpixel(262, 13, 14, vaddr); - putpixel(239, 46, 14, vaddr); - putpixel(266, 74, 9, vaddr); - putpixel(264, 21, 9, vaddr); - putpixel(248, 84, 9, vaddr); - putpixel(279, 87, 9, vaddr); - putpixel(254, 39, 9, vaddr); + for (int j=11; j<=91; ++j) draw::putPixel(i, j, 0, vaddr); + draw::putPixel(228, 65, 14, vaddr); + draw::putPixel(290, 26, 14, vaddr); + draw::putPixel(264, 63, 14, vaddr); + draw::putPixel(284, 85, 14, vaddr); + draw::putPixel(262, 13, 14, vaddr); + draw::putPixel(239, 46, 14, vaddr); + draw::putPixel(266, 74, 9, vaddr); + draw::putPixel(264, 21, 9, vaddr); + draw::putPixel(248, 84, 9, vaddr); + draw::putPixel(279, 87, 9, vaddr); + draw::putPixel(254, 39, 9, vaddr); } - espera_vga(); - volcar32(vaddr, vga); + draw::waitVsync(); + draw::draw(vaddr, VGA); pinta_marcs(55); pos = 1; pos_dif = mode_nocturne ? 0 : 1; - a_on_pinte_el_marc = 55; - get_color(15, R, G, B); + uint16_t a_on_pinte_el_marc = 55; + draw::getColor(15, &R, &G, &B); i=0; G=0; B=0; do { i = (i+1)%127; B = SDL_abs(63-i); G = B; - set_color(15,R,G,B); - if ( !playing && midi ) PlayMIDI(); + draw::setColor(15,R,G,B); + if ( !audio::musicPlaying() && midi ) audio::playMusic(); - if ( TeclaPuls(SDL_SCANCODE_LEFT) && (pos>1) ) + if ( input::keyPressed(SDL_SCANCODE_LEFT) && (pos>1) ) if (!mode_nocturne) { desp_marc(Left); pos--; } - if ( TeclaPuls(SDL_SCANCODE_RIGHT) && (pos<3) ) + if ( input::keyPressed(SDL_SCANCODE_RIGHT) && (pos<3) ) if (!mode_nocturne) { if ( (pos==1) && (mode_rosita==99) ) @@ -3603,20 +3600,20 @@ void menu_joc() } } - if ( TeclaPuls(SDL_SCANCODE_DOWN) && (pos_dif<3) && !mode_nocturne ) + if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_dif<3) && !mode_nocturne ) { pos_dif++; pinta_marcs(a_on_pinte_el_marc); - Play_WAV(sample[so_fletxa]); - do {} while (TeclaPuls(SDL_SCANCODE_DOWN)); + //Play_WAV(sample[so_fletxa]); + do {} while (input::keyPressed(SDL_SCANCODE_DOWN)); } - if ( TeclaPuls(SDL_SCANCODE_UP) && (pos_dif>1) && !mode_nocturne ) + if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_dif>1) && !mode_nocturne ) { pos_dif--; pinta_marcs(a_on_pinte_el_marc); - Play_WAV(sample[so_fletxa]); - do {} while (TeclaPuls(SDL_SCANCODE_UP)); + //Play_WAV(sample[so_fletxa]); + do {} while (input::keyPressed(SDL_SCANCODE_UP)); } if (pos==2) @@ -3639,11 +3636,11 @@ void menu_joc() a_on_pinte_el_marc = 55; } - } while ( !TeclaPuls(SDL_SCANCODE_RETURN) && !TeclaPuls(SDL_SCANCODE_ESCAPE) ); + } while ( !input::keyPressed(SDL_SCANCODE_RETURN) && !input::keyPressed(SDL_SCANCODE_ESCAPE) ); - if ( TeclaPuls(SDL_SCANCODE_RETURN) ) Play_WAV(sample[so_enter]); + //if ( input::keyPressed(SDL_SCANCODE_RETURN) ) Play_WAV(sample[so_enter]); - if ( TeclaPuls(SDL_SCANCODE_ESCAPE) ) pos = 4; + if ( input::keyPressed(SDL_SCANCODE_ESCAPE) ) pos = 4; if ( pos_dif == 1 ) dificultat = facil; if ( pos_dif == 2 ) dificultat = normal; @@ -3676,14 +3673,14 @@ void menu_joc() } if ( pos == 4 ) - borrat_de_pantalla(vaddr) + borrat_de_pantalla(vaddr); else - fadedown(0,0,0,0); + draw::fadeDown(0,0,0,0); if ( pos != 4 ) { - if (midi && !mode_nocturne) { StopMIDI(); unloadmidi(); midi=false; } - Story_mode(); + if (midi && !mode_nocturne) { audio::stopMusic(); audio::unloadMusic(); midi=false; } + story_mode(); } } @@ -3694,71 +3691,71 @@ void menu_joc() pos_m = 1; - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } ini_midi(musica_options); - if (midi) Playmidi(); + if (midi) audio::playMusic(); cord_y = 47; - load_mif(options, vaddr); + load_mif(OPTIONS, vaddr); actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); do { - if (!playing && midi) PlayMIDI(); + if (!audio::musicPlaying() && midi) audio::playMusic(); - if ( TeclaPuls(SDL_SCANCODE_DOWN) && (pos_m<7) ) + if ( input::keyPressed(SDL_SCANCODE_DOWN) && (pos_m<7) ) { pos_m++; switch (pos_m) { - case 1: cord_y:=47; break; - case 2: cord_y:=65; break; - case 3: cord_y:=83; break; - case 4: cord_y:=122; break; - case 5: cord_y:=140; break; - case 6: cord_y:=158; break; - case 7: cord_y:=176; break; + case 1: cord_y = 47; break; + case 2: cord_y = 65; break; + case 3: cord_y = 83; break; + case 4: cord_y = 122; break; + case 5: cord_y = 140; break; + case 6: cord_y = 158; break; + case 7: cord_y = 176; break; } - Play_WAV(sample[so_fletxa]); + //Play_WAV(sample[so_fletxa]); actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (TeclaPuls(SDL_SCANCODE_DOWN)); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (input::keyPressed(SDL_SCANCODE_DOWN)); } - if ( TeclaPuls(SDL_SCANCODE_UP) && (pos_m>1) ) + if ( input::keyPressed(SDL_SCANCODE_UP) && (pos_m>1) ) { pos_m--; switch (pos_m) { - case 1: cord_y:=47; break; - case 2: cord_y:=65; break; - case 3: cord_y:=83; break; - case 4: cord_y:=122; break; - case 5: cord_y:=140; break; - case 6: cord_y:=158; break; - case 7: cord_y:=176; break; + case 1: cord_y = 47; break; + case 2: cord_y = 65; break; + case 3: cord_y = 83; break; + case 4: cord_y = 122; break; + case 5: cord_y = 140; break; + case 6: cord_y = 158; break; + case 7: cord_y = 176; break; } - Play_WAV(sample[so_fletxa]); + //Play_WAV(sample[so_fletxa]); actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (TeclaPuls(SDL_SCANCODE_UP)); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (input::keyPressed(SDL_SCANCODE_UP)); } - if (TeclaPuls(SDL_SCANCODE_RIGHT)) + if (input::keyPressed(SDL_SCANCODE_RIGHT)) { if (pos_m == 1) { @@ -3773,20 +3770,20 @@ void menu_joc() if ( volumen < 10 ) volumen++; } else - if (pos_m ==3) then GM = !GM; + if (pos_m == 3) GM = !GM; actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (QTeclaPuls()); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (input::anyKey()); } - if (TeclaPuls(SDL_SCANCODE_LEFT)) + if (input::keyPressed(SDL_SCANCODE_LEFT)) { if (pos_m == 1) { @@ -3803,27 +3800,27 @@ void menu_joc() else if ( pos_m == 3) GM = !GM; actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (QTeclaPuls()); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (input::anyKey()); } - if ( TeclaPuls(SDL_SCANCODE_RETURN) && (pos_m>3) ) + if ( input::keyPressed(SDL_SCANCODE_RETURN) && (pos_m>3) ) { do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - Play_WAV(sample[so_enter]); - } while (TeclaPuls(SDL_SCANCODE_RETURN)); - aux = 0; - dib_aux = 23781; + draw::waitVsync(); + draw::draw(vaddr2, VGA); + //Play_WAV(sample[so_enter]); + } while (input::keyPressed(SDL_SCANCODE_RETURN)); + uint8_t aux = 0; + uint16_t dib_aux = 23781; actualitza_options(vaddr, vaddr2); switch (pos_m) @@ -3846,28 +3843,29 @@ void menu_joc() break; } - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + bool tecla_incorrecta; do { tecla_incorrecta = true; do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (!Qteclapuls()); - aux = AgarrarTecla(); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (!input::anyKey()); + aux = input::getKey(); do { actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); - } while (QTeclaPuls()); + draw::waitVsync(); + draw::draw(vaddr2, VGA); + } while (input::anyKey()); bool tecla_incorrecta = true; - if (aux >= SDL_SCANCODE_A && aux <) SDL_SCANCODE_Z) tecla_incorrecta = false; - if (aux >= SDL_SCANCODE_RIGHT && aux <) SDL_SCANCODE_UP) tecla_incorrecta = false; + if (aux >= SDL_SCANCODE_A && aux <= SDL_SCANCODE_Z) tecla_incorrecta = false; + if (aux >= SDL_SCANCODE_RIGHT && aux <= SDL_SCANCODE_UP) tecla_incorrecta = false; } while (tecla_incorrecta); @@ -3925,19 +3923,19 @@ void menu_joc() break; } actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); } actualitza_options(vaddr, vaddr2); - espera_VGA(); - volcar32(vaddr2, VGA); + draw::waitVsync(); + draw::draw(vaddr2, VGA); - } while (!TeclaPuls(SDL_SCANCODE_ESCAPE)); + } while (!input::keyPressed(SDL_SCANCODE_ESCAPE)); borrat_de_pantalla(vaddr2); - if (midi) { StopMIDI(); unloadmidi(); midi=false; } + if (midi) { audio::stopMusic(); audio::unloadMusic(); midi=false; } save_cfg(); } @@ -3949,17 +3947,17 @@ int main(int argc, char *argv[]) { comprobar_comp_i_sprites(); - randomize(); + srand(SDL_GetTicks()); - instalarkb(); + input::init(); - setmode(0x13); + //setmode(0x13); + draw::init(); - setupvirtual(virscr, vaddr); - setupvirtual(virscr2, vaddr2); - getmem(virscrSP, 7680); - vaddrSP = seg(virscrSP ^); - loadPCX('datos/sprites.dat', vaddrSP); + vaddr = draw::newSurface(320, 240); + vaddr2 = draw::newSurface(320, 240); + vaddrSP = draw::loadSurface("datos/sprites.dat"); //(320, 24);// (uint8_t *)malloc(7680); + //loadPCX('datos/sprites.dat', vaddrSP); load_setup_i_versio(); @@ -3980,24 +3978,24 @@ int main(int argc, char *argv[]) } while (!eixir_del_joc); - Tancarvirtual(virscr); - Tancarvirtual(virscr2); - Freemem(virscrSP, 7680); + draw::deleteSurface(vaddr); + draw::deleteSurface(vaddr2); + draw::deleteSurface(vaddrSP); /* if amb_so then arxius_wav(FALSE); if amb_so then EndWAV;*/ - DesinstalarKB(); + //DesinstalarKB(); - setmode(0x3); + //setmode(0x3); } /* ini_midi('.\music\logo.mid'); - if midi then Playmidi; + if midi then audio::playMusic; - if (not(playing)) and (midi) then PlayMIDI; + if (not(audio::musicPlaying())) and (midi) then audio::playMusic; - if midi then begin StopMIDI; unloadmidi; midi:=false; end; + if midi then begin audio::stopMusic; audio::unloadMusic; midi:=false; end; */ \ No newline at end of file