Pasaeta de IWYU

This commit is contained in:
2025-03-14 21:22:55 +01:00
parent 3ee47ba906
commit 6c7cfaae59
27 changed files with 350 additions and 408 deletions

View File

@@ -9,9 +9,8 @@
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "stage.h" // Para power #include "stage.h" // Para addPower
#include "texture.h" // Para Texture #include "utils.h" // Para Zone, Color, flash_color
#include "utils.h" // Para Zone, BLOCK, Color, flash_color
// Constructor // Constructor
BalloonManager::BalloonManager() BalloonManager::BalloonManager()

View File

@@ -4,7 +4,6 @@
#include "options.h" // Para OptionsController, Options, options #include "options.h" // Para OptionsController, Options, options
#include "param.h" // Para Param, param, ParamGame, ParamTitle #include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "section.h" // Para Name, Options, name, options
#include "text.h" // Para Text #include "text.h" // Para Text
// Constructor // Constructor

View File

@@ -4,43 +4,45 @@
#include <SDL2/SDL_audio.h> // Para AUDIO_S16 #include <SDL2/SDL_audio.h> // Para AUDIO_S16
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_events.h> // Para SDL_DISABLE
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR... #include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN #include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // Para SDL_bool, Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32, SDL_bool
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO... #include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // Para printf, perror #include <stdio.h> // Para printf, perror
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU #include <sys/stat.h> // Para mkdir, stat, S_IRWXU
#include <unistd.h> // Para getuid #include <unistd.h> // Para getuid
#include <algorithm> // Para min #include <algorithm> // Para min
#include <chrono> // Para chrono #include <chrono> // Para chrono
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, rand #include <cstdlib> // Para exit, EXIT_FAILURE, size_t, rand
#include <iostream> // Para basic_ostream, operator<<, basi... #include <iostream> // Para basic_ostream, operator<<, basi...
#include <memory> // Para make_unique, unique_ptr #include <memory> // Para make_unique, unique_ptr
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include <string> // Para operator+, char_traits, allocator #include <string> // Para operator+, char_traits, allocator
#include <vector> // Para vector #include <vector> // Para vector
#include "asset.h" // Para Asset, AssetType #include "asset.h" // Para Asset, AssetType
#include "credits.h" // Para Credits #include "credits.h" // Para Credits
#include "dbgtxt.h" // Para dbg_init #include "dbgtxt.h" // Para dbg_init
#include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_... #include "game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_...
#include "hiscore_table.h" // Para HiScoreTable #include "hiscore_table.h" // Para HiScoreTable
#include "input.h" // Para Input, InputType #include "input.h" // Para Input, InputType
#include "instructions.h" // Para Instructions #include "instructions.h" // Para Instructions
#include "intro.h" // Para Intro #include "intro.h" // Para Intro
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV... #include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV...
#include "lang.h" // Para Code, loadFromFile #include "lang.h" // Para Code, loadFromFile
#include "logo.h" // Para Logo #include "logo.h" // Para Logo
#include "manage_hiscore_table.h" // Para ManageHiScoreTable #include "manage_hiscore_table.h" // Para ManageHiScoreTable
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "on_screen_help.h" // Para OnScreenHelp #include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // Para Options, options, OptionsContro... #include "options.h" // Para Options, options, OptionsContro...
#include "param.h" // Para Param, ParamGame, param, loadPa... #include "param.h" // Para Param, ParamGame, param, loadPa...
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, Options, name, options #include "section.h" // Para Name, Options, name, options
#include "title.h" // Para Title #include "title.h" // Para Title
#include "utils.h" // Para Overrides, overrides #include "utils.h" // Para Overrides, overrides
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> // Para getpwuid, passwd #include <pwd.h> // Para getpwuid, passwd
@@ -53,7 +55,7 @@ Director::Director(int argc, const char *argv[])
section::name = section::Name::GAME; section::name = section::Name::GAME;
section::options = section::Options::GAME_PLAY_1P; section::options = section::Options::GAME_PLAY_1P;
#elif DEBUG #elif DEBUG
section::name = section::Name::INTRO; section::name = section::Name::LOGO;
#else // NORMAL GAME #else // NORMAL GAME
section::name = section::Name::LOGO; section::name = section::Name::LOGO;
section::options = section::Options::NONE; section::options = section::Options::NONE;

View File

@@ -1,9 +1,6 @@
#include "enter_name.h" #include "enter_name.h"
#include "utils.h" #include <stddef.h> // Para size_t
#include <stddef.h> // Para size_t #include "utils.h" // Para trim
#include <algorithm> // Para max, min
#include <cassert> // Para assert
#include <iostream>
// Constructor // Constructor
EnterName::EnterName() EnterName::EnterName()

View File

@@ -1,6 +1,6 @@
#include "game.h" #include "game.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // Para SDL_Event, SDL_PollEvent, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4 #include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
@@ -14,15 +14,14 @@
#include "balloon.h" // Para Balloon, BALLOON_SPEED #include "balloon.h" // Para Balloon, BALLOON_SPEED
#include "balloon_manager.h" // Para BalloonManager #include "balloon_manager.h" // Para BalloonManager
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus #include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "enter_name.h" // Para NAME_LENGHT
#include "fade.h" // Para Fade, FadeType, FadeMode #include "fade.h" // Para Fade, FadeType, FadeMode
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update #include "global_inputs.h" // Para check, update
#include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL... #include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL...
#include "item.h" // Para Item, ItemType #include "item.h" // Para Item, ItemType
#include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState #include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry #include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry
#include "global_events.h" // Para handleEvent
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "path_sprite.h" // Para Path, PathSprite, createPath, Path... #include "path_sprite.h" // Para Path, PathSprite, createPath, Path...
@@ -30,10 +29,10 @@
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB... #include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, AttractMode, Options #include "section.h" // Para Name, name, AttractMode, attract_mode
#include "smart_sprite.h" // Para SmartSprite #include "smart_sprite.h" // Para SmartSprite
#include "stage.h" // Para number, get, Stage, total_power #include "stage.h" // Para number, get, Stage, total_power
#include "tabe.h" // Para Tabe #include "tabe.h" // Para Tabe, TabeState
#include "text.h" // Para Text #include "text.h" // Para Text
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
@@ -1379,7 +1378,7 @@ void Game::handleDemoMode()
for (const auto &player : players_) for (const auto &player : players_)
{ {
if (player->isPlaying()) if (player->isPlaying())
{ {
// Maneja el input específico del jugador en modo demo. // Maneja el input específico del jugador en modo demo.
handleDemoPlayerInput(player, index); handleDemoPlayerInput(player, index);
} }

View File

@@ -1,13 +1,13 @@
#include "gif.h" #include "gif.h"
#include <stdio.h> // for NULL, fprintf, stderr #include <stdio.h> // Para NULL, fprintf, stderr
#include <stdlib.h> // for malloc, realloc, exit, calloc, free #include <stdlib.h> // Para malloc, realloc, exit, calloc, free
void uncompress( int code_length, void uncompress(int code_length,
const unsigned char *input, const unsigned char *input,
int input_length, int input_length,
unsigned char *out ) unsigned char *out)
{ {
//int maxbits; // int maxbits;
int i, bit; int i, bit;
int code, prev = -1; int code, prev = -1;
dictionary_entry_t *dictionary; dictionary_entry_t *dictionary;
@@ -18,15 +18,15 @@ void uncompress( int code_length,
int stop_code; // one more than clear code int stop_code; // one more than clear code
int match_len; int match_len;
clear_code = 1 << ( code_length ); clear_code = 1 << (code_length);
stop_code = clear_code + 1; stop_code = clear_code + 1;
// To handle clear codes // To handle clear codes
reset_code_length = code_length; reset_code_length = code_length;
// Create a dictionary large enough to hold "code_length" entries. // Create a dictionary large enough to hold "code_length" entries.
// Once the dictionary overflows, code_length increases // Once the dictionary overflows, code_length increases
dictionary = ( dictionary_entry_t * ) dictionary = (dictionary_entry_t *)
malloc( sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) ); malloc(sizeof(dictionary_entry_t) * (1 << (code_length + 1)));
// Initialize the first 2^code_len entries of the dictionary with their // Initialize the first 2^code_len entries of the dictionary with their
// indices. The rest of the entries will be built up dynamically. // indices. The rest of the entries will be built up dynamically.
@@ -35,14 +35,14 @@ void uncompress( int code_length,
// dictionary. The spec says that the encoder "should output a // dictionary. The spec says that the encoder "should output a
// clear code as the first code in the image data stream". It doesn't // clear code as the first code in the image data stream". It doesn't
// say must, though... // say must, though...
for ( dictionary_ind = 0; for (dictionary_ind = 0;
dictionary_ind < ( 1 << code_length ); dictionary_ind < (1 << code_length);
dictionary_ind++ ) dictionary_ind++)
{ {
dictionary[ dictionary_ind ].byte = dictionary_ind; dictionary[dictionary_ind].byte = dictionary_ind;
// XXX this only works because prev is a 32-bit int (> 12 bits) // XXX this only works because prev is a 32-bit int (> 12 bits)
dictionary[ dictionary_ind ].prev = -1; dictionary[dictionary_ind].prev = -1;
dictionary[ dictionary_ind ].len = 1; dictionary[dictionary_ind].len = 1;
} }
// 2^code_len + 1 is the special "end" code; don't give it an entry here // 2^code_len + 1 is the special "end" code; don't give it an entry here
@@ -50,48 +50,48 @@ void uncompress( int code_length,
dictionary_ind++; dictionary_ind++;
// TODO verify that the very last byte is clear_code + 1 // TODO verify that the very last byte is clear_code + 1
while ( input_length ) while (input_length)
{ {
code = 0x0; code = 0x0;
// Always read one more bit than the code length // Always read one more bit than the code length
for ( i = 0; i < ( code_length + 1 ); i++ ) for (i = 0; i < (code_length + 1); i++)
{ {
// This is different than in the file read example; that // This is different than in the file read example; that
// was a call to "next_bit" // was a call to "next_bit"
bit = ( *input & mask ) ? 1 : 0; bit = (*input & mask) ? 1 : 0;
mask <<= 1; mask <<= 1;
if ( mask == 0x100 ) if (mask == 0x100)
{ {
mask = 0x01; mask = 0x01;
input++; input++;
input_length--; input_length--;
} }
code = code | ( bit << i ); code = code | (bit << i);
} }
if ( code == clear_code ) if (code == clear_code)
{ {
code_length = reset_code_length; code_length = reset_code_length;
dictionary = ( dictionary_entry_t * ) realloc( dictionary, dictionary = (dictionary_entry_t *)realloc(dictionary,
sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) ); sizeof(dictionary_entry_t) * (1 << (code_length + 1)));
for ( dictionary_ind = 0; for (dictionary_ind = 0;
dictionary_ind < ( 1 << code_length ); dictionary_ind < (1 << code_length);
dictionary_ind++ ) dictionary_ind++)
{ {
dictionary[ dictionary_ind ].byte = dictionary_ind; dictionary[dictionary_ind].byte = dictionary_ind;
// XXX this only works because prev is a 32-bit int (> 12 bits) // XXX this only works because prev is a 32-bit int (> 12 bits)
dictionary[ dictionary_ind ].prev = -1; dictionary[dictionary_ind].prev = -1;
dictionary[ dictionary_ind ].len = 1; dictionary[dictionary_ind].len = 1;
} }
dictionary_ind++; dictionary_ind++;
dictionary_ind++; dictionary_ind++;
prev = -1; prev = -1;
continue; continue;
} }
else if ( code == stop_code ) else if (code == stop_code)
{ {
/*if ( input_length > 1 ) /*if ( input_length > 1 )
{ {
@@ -103,73 +103,73 @@ void uncompress( int code_length,
// Update the dictionary with this character plus the _entry_ // Update the dictionary with this character plus the _entry_
// (character or string) that came before it // (character or string) that came before it
if ( ( prev > -1 ) && ( code_length < 12 ) ) if ((prev > -1) && (code_length < 12))
{ {
if ( code > dictionary_ind ) if (code > dictionary_ind)
{ {
fprintf( stderr, "code = %.02x, but dictionary_ind = %.02x\n", fprintf(stderr, "code = %.02x, but dictionary_ind = %.02x\n",
code, dictionary_ind ); code, dictionary_ind);
exit( 0 ); exit(0);
} }
// Special handling for KwKwK // Special handling for KwKwK
if ( code == dictionary_ind ) if (code == dictionary_ind)
{ {
int ptr = prev; int ptr = prev;
while ( dictionary[ ptr ].prev != -1 ) while (dictionary[ptr].prev != -1)
{ {
ptr = dictionary[ ptr ].prev; ptr = dictionary[ptr].prev;
} }
dictionary[ dictionary_ind ].byte = dictionary[ ptr ].byte; dictionary[dictionary_ind].byte = dictionary[ptr].byte;
} }
else else
{ {
int ptr = code; int ptr = code;
while ( dictionary[ ptr ].prev != -1 ) while (dictionary[ptr].prev != -1)
{ {
ptr = dictionary[ ptr ].prev; ptr = dictionary[ptr].prev;
} }
dictionary[ dictionary_ind ].byte = dictionary[ ptr ].byte; dictionary[dictionary_ind].byte = dictionary[ptr].byte;
} }
dictionary[ dictionary_ind ].prev = prev; dictionary[dictionary_ind].prev = prev;
dictionary[ dictionary_ind ].len = dictionary[ prev ].len + 1; dictionary[dictionary_ind].len = dictionary[prev].len + 1;
dictionary_ind++; dictionary_ind++;
// GIF89a mandates that this stops at 12 bits // GIF89a mandates that this stops at 12 bits
if ( ( dictionary_ind == ( 1 << ( code_length + 1 ) ) ) && if ((dictionary_ind == (1 << (code_length + 1))) &&
( code_length < 11 ) ) (code_length < 11))
{ {
code_length++; code_length++;
dictionary = ( dictionary_entry_t * ) realloc( dictionary, dictionary = (dictionary_entry_t *)realloc(dictionary,
sizeof( dictionary_entry_t ) * ( 1 << ( code_length + 1 ) ) ); sizeof(dictionary_entry_t) * (1 << (code_length + 1)));
} }
} }
prev = code; prev = code;
// Now copy the dictionary entry backwards into "out" // Now copy the dictionary entry backwards into "out"
match_len = dictionary[ code ].len; match_len = dictionary[code].len;
while ( code != -1 ) while (code != -1)
{ {
out[ dictionary[ code ].len - 1 ] = dictionary[ code ].byte; out[dictionary[code].len - 1] = dictionary[code].byte;
if ( dictionary[ code ].prev == code ) if (dictionary[code].prev == code)
{ {
fprintf( stderr, "Internal error; self-reference." ); fprintf(stderr, "Internal error; self-reference.");
exit( 0 ); exit(0);
} }
code = dictionary[ code ].prev; code = dictionary[code].prev;
} }
out += match_len; out += match_len;
} }
} }
static int read_sub_blocks( unsigned char* buffer, unsigned char **data ) static int read_sub_blocks(unsigned char *buffer, unsigned char **data)
{ {
int data_length; int data_length;
int index; int index;
@@ -181,20 +181,20 @@ static int read_sub_blocks( unsigned char* buffer, unsigned char **data )
*data = NULL; *data = NULL;
index = 0; index = 0;
while ( 1 ) while (1)
{ {
READ(&block_size, 1); READ(&block_size, 1);
if ( block_size == 0 ) // end of sub-blocks if (block_size == 0) // end of sub-blocks
{ {
break; break;
} }
data_length += block_size; data_length += block_size;
*data = (unsigned char*)realloc( *data, data_length ); *data = (unsigned char *)realloc(*data, data_length);
// TODO this could be split across block size boundaries // TODO this could be split across block size boundaries
READ(*data + index, block_size); READ(*data + index, block_size);
index += block_size; index += block_size;
} }
@@ -202,10 +202,10 @@ static int read_sub_blocks( unsigned char* buffer, unsigned char **data )
return data_length; return data_length;
} }
unsigned char* process_image_descriptor( unsigned char* buffer, unsigned char *process_image_descriptor(unsigned char *buffer,
rgb *gct, rgb *gct,
int gct_size, int gct_size,
int resolution_bits ) int resolution_bits)
{ {
image_descriptor_t image_descriptor; image_descriptor_t image_descriptor;
int compressed_data_length; int compressed_data_length;
@@ -215,27 +215,28 @@ unsigned char* process_image_descriptor( unsigned char* buffer,
unsigned char *uncompressed_data = NULL; unsigned char *uncompressed_data = NULL;
// TODO there could actually be lots of these // TODO there could actually be lots of these
READ(&image_descriptor, 9); READ(&image_descriptor, 9);
// TODO if LCT = true, read the LCT // TODO if LCT = true, read the LCT
READ(&lzw_code_size, 1); READ(&lzw_code_size, 1);
compressed_data_length = read_sub_blocks( buffer, &compressed_data ); compressed_data_length = read_sub_blocks(buffer, &compressed_data);
// width = image_descriptor.image_width; // width = image_descriptor.image_width;
// height = image_descriptor.image_height; // height = image_descriptor.image_height;
uncompressed_data_length = image_descriptor.image_width * uncompressed_data_length = image_descriptor.image_width *
image_descriptor.image_height; image_descriptor.image_height;
uncompressed_data = (unsigned char*)malloc( uncompressed_data_length ); uncompressed_data = (unsigned char *)malloc(uncompressed_data_length);
uncompress( lzw_code_size, compressed_data, compressed_data_length, uncompress(lzw_code_size, compressed_data, compressed_data_length,
uncompressed_data ); uncompressed_data);
if ( compressed_data ) free( compressed_data ); if (compressed_data)
free(compressed_data);
//if ( uncompressed_data ) // if ( uncompressed_data )
// free( uncompressed_data ); // free( uncompressed_data );
return uncompressed_data; return uncompressed_data;
} }
@@ -247,47 +248,50 @@ unsigned char* process_image_descriptor( unsigned char* buffer,
*/ */
#define rb (*(buffer++)) #define rb (*(buffer++))
uint32_t* LoadPalette(unsigned char *buffer) { uint32_t *LoadPalette(unsigned char *buffer)
unsigned char header[7]; {
screen_descriptor_t screen_descriptor; unsigned char header[7];
//int color_resolution_bits; screen_descriptor_t screen_descriptor;
// int color_resolution_bits;
int global_color_table_size = 0; // number of entries in global_color_table int global_color_table_size = 0; // number of entries in global_color_table
uint32_t *global_color_table = NULL; uint32_t *global_color_table = NULL;
READ(header, 6); READ(header, 6);
READ(&screen_descriptor, 7); READ(&screen_descriptor, 7);
//color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1; // color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
global_color_table = (uint32_t *)calloc(1, 1024); global_color_table = (uint32_t *)calloc(1, 1024);
if (screen_descriptor.fields & 0x80) { if (screen_descriptor.fields & 0x80)
global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1)); {
global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
//global_color_table = (rgb *)malloc(3 * global_color_table_size); // global_color_table = (rgb *)malloc(3 * global_color_table_size);
//READ(global_color_table, 3 * global_color_table_size); // READ(global_color_table, 3 * global_color_table_size);
for (int i=0; i<global_color_table_size;++i) { for (int i = 0; i < global_color_table_size; ++i)
global_color_table[i] = (buffer[0]<<16) + (buffer[1]<<8) + buffer[2]; {
buffer+=3; global_color_table[i] = (buffer[0] << 16) + (buffer[1] << 8) + buffer[2];
buffer += 3;
} }
} }
return global_color_table; return global_color_table;
} }
static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short* w, unsigned short* h) static unsigned char *process_gif_stream(unsigned char *buffer, unsigned short *w, unsigned short *h)
{ {
unsigned char header[ 7 ]; unsigned char header[7];
screen_descriptor_t screen_descriptor; screen_descriptor_t screen_descriptor;
int color_resolution_bits; int color_resolution_bits;
int global_color_table_size =0; // number of entries in global_color_table int global_color_table_size = 0; // number of entries in global_color_table
rgb *global_color_table = NULL; rgb *global_color_table = NULL;
unsigned char block_type = 0x0; unsigned char block_type = 0x0;
// A GIF file starts with a Header (section 17) // A GIF file starts with a Header (section 17)
READ(header, 6); READ(header, 6);
header[ 6 ] = 0x0; header[6] = 0x0;
// XXX there's another format, GIF87a, that you may still find // XXX there's another format, GIF87a, that you may still find
// floating around. // floating around.
@@ -305,87 +309,87 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
// Can't use sizeof here since GCC does byte alignment; // Can't use sizeof here since GCC does byte alignment;
// sizeof( screen_descriptor_t ) = 8! // sizeof( screen_descriptor_t ) = 8!
READ(&screen_descriptor, 7); READ(&screen_descriptor, 7);
*w = screen_descriptor.width; *w = screen_descriptor.width;
*h = screen_descriptor.height; *h = screen_descriptor.height;
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1; color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
if ( screen_descriptor.fields & 0x80 ) if (screen_descriptor.fields & 0x80)
{ {
//int i; // int i;
// If bit 7 is set, the next block is a global color table; read it // If bit 7 is set, the next block is a global color table; read it
global_color_table_size = 1 << global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
( ( ( screen_descriptor.fields & 0x07 ) + 1 ) );
global_color_table = (rgb *)malloc(3 * global_color_table_size);
global_color_table = ( rgb * ) malloc( 3 * global_color_table_size );
// XXX this could conceivably return a short count... // XXX this could conceivably return a short count...
READ(global_color_table, 3 * global_color_table_size); READ(global_color_table, 3 * global_color_table_size);
} }
while ( block_type != TRAILER ) while (block_type != TRAILER)
{ {
READ(&block_type, 1); READ(&block_type, 1);
unsigned char size; unsigned char size;
switch ( block_type ) switch (block_type)
{ {
case IMAGE_DESCRIPTOR: case IMAGE_DESCRIPTOR:
return process_image_descriptor(buffer, return process_image_descriptor(buffer,
global_color_table, global_color_table,
global_color_table_size, global_color_table_size,
color_resolution_bits); color_resolution_bits);
break; break;
case EXTENSION_INTRODUCER: case EXTENSION_INTRODUCER:
buffer++; buffer++;
size = *(buffer++);
buffer += size;
do
{
size = *(buffer++); size = *(buffer++);
buffer += size; buffer += size;
do { } while (size != 0);
size = *(buffer++);
buffer += size;
} while (size != 0);
/*if ( !process_extension( buffer ) ) /*if ( !process_extension( buffer ) )
{ {
return NULL;
}*/
break;
case TRAILER:
break;
default:
fprintf( stderr, "Bailing on unrecognized block type %.02x\n",
block_type );
return NULL; return NULL;
}*/
break;
case TRAILER:
break;
default:
fprintf(stderr, "Bailing on unrecognized block type %.02x\n",
block_type);
return NULL;
} }
} }
return NULL; return NULL;
} }
unsigned char *LoadGif(unsigned char *buffer, unsigned short *w, unsigned short *h)
unsigned char* LoadGif(unsigned char *buffer, unsigned short* w, unsigned short* h) { {
return process_gif_stream(buffer, w, h); return process_gif_stream(buffer, w, h);
} }
/*int main( int argc, char *argv[] ) /*int main( int argc, char *argv[] )
{ {
FILE* gif_file; FILE* gif_file;
if ( argc < 2 ) if ( argc < 2 )
{ {
fprintf( stderr, "Usage: %s <path-to-gif-file>\n", argv[ 0 ] ); fprintf( stderr, "Usage: %s <path-to-gif-file>\n", argv[ 0 ] );
exit( 0 ); exit( 0 );
} }
gif_file = fopen( argv[ 1 ], "rb" ); gif_file = fopen( argv[ 1 ], "rb" );
if ( gif_file == NULL ) if ( gif_file == NULL )
{ {
fprintf( stderr, "Unable to open file '%s'", argv[ 1 ] ); fprintf( stderr, "Unable to open file '%s'", argv[ 1 ] );
perror( ": " ); perror( ": " );
} }
process_gif_stream( gif_file ); process_gif_stream( gif_file );
fclose( gif_file ); fclose( gif_file );
}*/ }*/

View File

@@ -1,19 +1,22 @@
#pragma once #pragma once
#include <stdint.h> // for uint32_t #include <stdint.h> // Para uint32_t
#include <string.h> // for memcpy #include <string.h> // Para memcpy
#define EXTENSION_INTRODUCER 0x21 #define EXTENSION_INTRODUCER 0x21
#define IMAGE_DESCRIPTOR 0x2C #define IMAGE_DESCRIPTOR 0x2C
#define TRAILER 0x3B #define TRAILER 0x3B
#define GRAPHIC_CONTROL 0xF9 #define GRAPHIC_CONTROL 0xF9
#define APPLICATION_EXTENSION 0xFF #define APPLICATION_EXTENSION 0xFF
#define COMMENT_EXTENSION 0xFE #define COMMENT_EXTENSION 0xFE
#define PLAINTEXT_EXTENSION 0x01 #define PLAINTEXT_EXTENSION 0x01
#define READ(dst, size) memcpy(dst, buffer, size); buffer += size #define READ(dst, size) \
memcpy(dst, buffer, size); \
buffer += size
typedef struct { typedef struct
{
unsigned short width; unsigned short width;
unsigned short height; unsigned short height;
unsigned char fields; unsigned char fields;
@@ -21,11 +24,13 @@ typedef struct {
unsigned char pixel_aspect_ratio; unsigned char pixel_aspect_ratio;
} screen_descriptor_t; } screen_descriptor_t;
typedef struct { typedef struct
{
unsigned char r, g, b; unsigned char r, g, b;
} rgb; } rgb;
typedef struct { typedef struct
{
unsigned short image_left_position; unsigned short image_left_position;
unsigned short image_top_position; unsigned short image_top_position;
unsigned short image_width; unsigned short image_width;
@@ -33,34 +38,39 @@ typedef struct {
unsigned char fields; unsigned char fields;
} image_descriptor_t; } image_descriptor_t;
typedef struct { typedef struct
{
unsigned char byte; unsigned char byte;
int prev; int prev;
int len; int len;
} dictionary_entry_t; } dictionary_entry_t;
typedef struct { typedef struct
{
unsigned char extension_code; unsigned char extension_code;
unsigned char block_size; unsigned char block_size;
} extension_t; } extension_t;
typedef struct { typedef struct
{
unsigned char fields; unsigned char fields;
unsigned short delay_time; unsigned short delay_time;
unsigned char transparent_color_index; unsigned char transparent_color_index;
} graphic_control_extension_t; } graphic_control_extension_t;
typedef struct { typedef struct
{
unsigned char application_id[8]; unsigned char application_id[8];
unsigned char version[3]; unsigned char version[3];
} application_extension_t; } application_extension_t;
typedef struct { typedef struct
{
unsigned short left, top, width, height; unsigned short left, top, width, height;
unsigned char cell_width, cell_height; unsigned char cell_width, cell_height;
unsigned char foreground_color, background_color; unsigned char foreground_color, background_color;
} plaintext_extension_t; } plaintext_extension_t;
void uncompress(int code_length, const unsigned char *input, int input_length, unsigned char *out); void uncompress(int code_length, const unsigned char *input, int input_length, unsigned char *out);
uint32_t* LoadPalette(unsigned char *buffer); uint32_t *LoadPalette(unsigned char *buffer);
unsigned char* LoadGif(unsigned char *buffer, unsigned short* w, unsigned short* h); unsigned char *LoadGif(unsigned char *buffer, unsigned short *w, unsigned short *h);

View File

@@ -1,8 +1,8 @@
#include "global_events.h" #include "global_events.h"
#include "section.h" #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include "mouse.h" #include <iostream> // Para char_traits, basic_ostream, operator<<
#include "resource.h" #include "mouse.h" // Para handleEvent
#include <iostream> #include "section.h" // Para Name, Options, name, options
namespace globalEvents namespace globalEvents
{ {
@@ -17,13 +17,11 @@ namespace globalEvents
return; return;
case SDL_RENDER_DEVICE_RESET: case SDL_RENDER_DEVICE_RESET:
case SDL_RENDER_TARGETS_RESET: case SDL_RENDER_TARGETS_RESET:
// Resource::get()->reloadTextures();
std::cout << "SDL_RENDER_TARGETS_RESET" << std::endl; std::cout << "SDL_RENDER_TARGETS_RESET" << std::endl;
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{ {
// Resource::get()->reloadTextures();
std::cout << "SDL_WINDOWEVENT_SIZE_CHANGED" << std::endl; std::cout << "SDL_WINDOWEVENT_SIZE_CHANGED" << std::endl;
} }
break; break;

View File

@@ -1,16 +1,18 @@
#include "global_inputs.h" #include "global_inputs.h"
#include <string> // Para operator+, string, to_string, basic_string #include <SDL2/SDL_render.h> // Para SDL_RenderSetIntegerScale
#include <vector> // Para vector #include <SDL2/SDL_stdinc.h> // Para SDL_FALSE, SDL_TRUE
#include "asset.h" // Para Asset #include <string> // Para operator+, string, to_string, basic_string
#include "input.h" // Para Input, InputDeviceToUse, InputType, INPU... #include <vector> // Para vector
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume #include "asset.h" // Para Asset
#include "lang.h" // Para Code, getText, change, loadFromFile #include "input.h" // Para Input, InputDeviceToUse, InputType, INP...
#include "notifier.h" // Para Notifier #include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume
#include "on_screen_help.h" // Para OnScreenHelp #include "lang.h" // Para getText, Code, getNextLangCode, loadFro...
#include "options.h" // Para Options, options, OptionsGame, OptionsAudio #include "notifier.h" // Para Notifier
#include "screen.h" // Para Screen, ScreenVideoMode #include "on_screen_help.h" // Para OnScreenHelp
#include "section.h" // Para Name, Options, name, options #include "options.h" // Para Options, options, OptionsGame, OptionsV...
#include "utils.h" // Para boolToOnOff, stringInVector #include "screen.h" // Para Screen, ScreenVideoMode
#include "section.h" // Para Name, name, Options, options, AttractMode
#include "utils.h" // Para boolToOnOff
namespace globalInputs namespace globalInputs
{ {
@@ -33,7 +35,7 @@ namespace globalInputs
// Si la notificación de salir no está activa, muestra la notificación // Si la notificación de salir no está activa, muestra la notificación
#ifdef ARCADE #ifdef ARCADE
const int INDEX = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94; const int INDEX = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
Notifier::get()->showText({lang::getText(INDEX), std::string()}, -1, CODE); Notifier::get()->show({lang::getText(INDEX), std::string()}, -1, CODE);
#else #else
Notifier::get()->show({lang::getText(94), std::string()}, -1, CODE); Notifier::get()->show({lang::getText(94), std::string()}, -1, CODE);
#endif #endif

View File

@@ -1,31 +1,29 @@
#include "hiscore_table.h" #include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED #include <stdlib.h> // Para rand, size_t
#include <stdlib.h> // Para rand
#include <algorithm> // Para max #include <algorithm> // Para max
#include <functional> // Para function #include <functional> // Para function
#include <vector> // Para vector #include <vector> // Para vector
#include "background.h" // Para Background #include "background.h" // Para Background
#include "fade.h" // Para Fade, FadeMode, FadeType #include "fade.h" // Para Fade, FadeMode, FadeType
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update #include "global_inputs.h" // Para check, update
#include "input.h" // Para Input
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para HiScoreEntry #include "manage_hiscore_table.h" // Para HiScoreEntry
#include "global_events.h" // Para handleEvent
#include "options.h" // Para Options, OptionsGame, options #include "options.h" // Para Options, OptionsGame, options
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "path_sprite.h" // Para PathSprite, Path, PathType #include "path_sprite.h" // Para PathSprite, Path, PathType
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options, Attr... #include "section.h" // Para Name, name
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text, TEXT_COLOR, TEXT_SHADOW #include "text.h" // Para Text, TEXT_SHADOW, TEXT_COLOR
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "utils.h" // Para Color, easeOutQuint, fade_color #include "utils.h" // Para Color, easeOutQuint, fade_color, Zone
// Constructor // Constructor
HiScoreTable::HiScoreTable() HiScoreTable::HiScoreTable()

View File

@@ -1,14 +1,14 @@
#include "instructions.h" #include "instructions.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // Para max #include <algorithm> // Para max
#include <utility> // Para move #include <utility> // Para move
#include <vector> // Para vector
#include "fade.h" // Para Fade, FadeMode, FadeType #include "fade.h" // Para Fade, FadeMode, FadeType
#include "global_inputs.h" // Para check #include "global_events.h" // Para check
#include "input.h" // Para Input #include "global_inputs.h" // Para check, update
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
@@ -17,14 +17,8 @@
#include "section.h" // Para Name, name, Options, options #include "section.h" // Para Name, name, Options, options
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_... #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "texture.h" // Para Texture
#include "tiled_bg.h" // Para TiledBG, TiledBGMode #include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, shdw_txt_color, Zone, no_color #include "utils.h" // Para Color, shdw_txt_color, Zone, no_color
#include "global_events.h"
#include <SDL2/SDL.h>
#include <vector>
#include <cmath>
// Constructor // Constructor
Instructions::Instructions() Instructions::Instructions()

View File

@@ -1,24 +1,27 @@
#include "intro.h" #include "intro.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <utility> // Para move #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include "global_inputs.h" // Para check #include <SDL2/SDL_render.h> // Para SDL_SetTextureBlendMode, SDL_GetRend...
#include "input.h" // Para Input #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include "jail_audio.h" // Para JA_StopMusic, JA_PlayMusic #include <array> // Para array
#include "lang.h" // Para getText #include <functional> // Para function
#include "param.h" // Para Param, ParamGame, param #include <string> // Para basic_string, string
#include "resource.h" // Para Resource #include <utility> // Para move
#include "screen.h" // Para Screen #include "global_events.h" // Para check
#include "section.h" // Para Name, name, Options, options #include "global_inputs.h" // Para check, update
#include "path_sprite.h" // Para PathSprite #include "jail_audio.h" // Para JA_PlayMusic, JA_StopMusic
#include "text.h" // Para Text #include "lang.h" // Para getText
#include "texture.h" // Para Texture #include "param.h" // Para Param, ParamGame, param
#include "utils.h" // Para Zone, BLOCK, Color, bg_color #include "path_sprite.h" // Para PathSprite, PathType
#include "writer.h" // Para Writer #include "resource.h" // Para Resource
#include "global_events.h" #include "screen.h" // Para Screen
#include "tiled_bg.h" #include "section.h" // Para Name, name, Options, options
#include <array> #include "texture.h" // Para Texture
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, Zone, easeOutQuint, BLOCK
#include "writer.h" // Para Writer
// Constructor // Constructor
Intro::Intro() Intro::Intro()
@@ -358,7 +361,7 @@ void Intro::initSprites()
SDL_RenderCopy(Screen::get()->getRenderer(), texture, nullptr, &rect); SDL_RenderCopy(Screen::get()->getRenderer(), texture, nullptr, &rect);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);
//shadow_texture->setAlpha(160); // shadow_texture->setAlpha(160);
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp); SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
shadow_textures.push_back(shadow_texture); shadow_textures.push_back(shadow_texture);
@@ -491,7 +494,7 @@ void Intro::updatePostState()
if (ELAPSED_TIME >= 1000) if (ELAPSED_TIME >= 1000)
{ {
tiled_bg_->stopGracefully(); tiled_bg_->stopGracefully();
// Modifica el color del fondo hasta llegar a blanco // Modifica el color del fondo hasta llegar a blanco
if (bg_color_ < 255) if (bg_color_ < 255)
{ {

View File

@@ -1,14 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL2/SDL.h> // Para SDL_Texture #include <memory> // Para unique_ptr
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
#include "path_sprite.h" // Para PathSprite #include "path_sprite.h" // Para PathSprite
#include "tiled_bg.h" // Para TiledBG
#include "writer.h" // Para Writer #include "writer.h" // Para Writer
#include "tiled_bg.h"
class Text; // lines 8-8
class Texture; // lines 9-9
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia

View File

@@ -1,20 +1,17 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // Para move #include <utility> // Para move
#include <iostream> #include "global_events.h" // Para check
#include "global_inputs.h" // Para check #include "global_inputs.h" // Para check, update
#include "input.h" // Para Input #include "jail_audio.h" // Para JA_FadeOutMusic, JA_PlaySound, JA_StopC...
#include "jail_audio.h" // Para JA_StopMusic #include "param.h" // Para Param, ParamGame, param
#include "param.h" // Para Param, ParamGame, param #include "resource.h" // Para Resource
#include "resource.h" // Para Resource #include "screen.h" // Para Screen
#include "screen.h" // Para Screen #include "section.h" // Para Name, name
#include "section.h" // Para Name, name, Options, options #include "sprite.h" // Para Sprite
#include "sprite.h" // Para Sprite #include "texture.h" // Para Texture
#include "texture.h" // Para Texture #include "utils.h" // Para Color, Zone
#include "utils.h" // Para Color, Zone
#include "global_events.h"
// Constructor // Constructor
Logo::Logo() Logo::Logo()
@@ -115,17 +112,10 @@ void Logo::updateJAILGAMES()
// Comprueba si ha terminado el logo // Comprueba si ha terminado el logo
if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION) if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION)
{ {
state_ = LogoState::RETROWEEKEND; section::name = section::Name::INTRO;
ticks_start_ = SDL_GetTicks();
} }
} }
// Gestiona el logo de RETROWEEKEND
void Logo::updateRETROWEEKEND()
{
section::name = section::Name::INTRO;
}
// Gestiona el color de las texturas // Gestiona el color de las texturas
void Logo::updateTextureColors() void Logo::updateTextureColors()
{ {
@@ -165,20 +155,8 @@ void Logo::update()
// Comprueba las entradas // Comprueba las entradas
checkInput(); checkInput();
switch (state_) updateJAILGAMES();
{ updateTextureColors();
case LogoState::JAILGAMES:
updateJAILGAMES();
updateTextureColors();
break;
case LogoState::RETROWEEKEND:
updateRETROWEEKEND();
break;
default:
break;
}
// Gestiona el contador // Gestiona el contador
counter_++; counter_++;
@@ -194,18 +172,7 @@ void Logo::render()
Screen::get()->start(); Screen::get()->start();
Screen::get()->clean(); Screen::get()->clean();
switch (state_) renderJAILGAMES();
{
case LogoState::JAILGAMES:
renderJAILGAMES();
break;
case LogoState::RETROWEEKEND:
break;
default:
break;
}
Screen::get()->render(); Screen::get()->render();
} }

View File

@@ -2,12 +2,11 @@
#include <SDL2/SDL_rect.h> // Para SDL_Point #include <SDL2/SDL_rect.h> // Para SDL_Point
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL.h> #include <memory> // Para shared_ptr, unique_ptr
#include <memory> // Para shared_ptr, unique_ptr #include <vector> // Para vector
#include <vector> // Para vector class Sprite; // lines 8-8
class Sprite; class Texture; // lines 9-9
class Texture; // lines 9-9 struct Color; // lines 10-10
struct Color;
/* /*
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
@@ -17,31 +16,10 @@ struct Color;
ZX Spectrum ZX Spectrum
*/ */
struct Pixel
{
int x, y; // Coordenadas del píxel
Uint8 r, g, b, a; // Color del píxel
// Método para ascender y desvanecerse
void evaporate()
{
y -= 1; // Asciende hacia arriba
a = (a > 5) ? a - 5 : 0; // Desvanece el alfa (transparencia)
// Añadir movimiento zig-zag aleatorio
x += (rand() % 3 - 1); // Movimiento horizontal aleatorio (-1, 0, 1)
}
};
// Clase Logo // Clase Logo
class Logo class Logo
{ {
private: private:
enum class LogoState
{
JAILGAMES,
RETROWEEKEND,
};
// Constantes // Constantes
static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998" static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998"
static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro
@@ -56,12 +34,10 @@ private:
std::vector<std::unique_ptr<Sprite>> jail_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES std::vector<std::unique_ptr<Sprite>> jail_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
// Variables // Variables
std::vector<Color> color_; // Vector con los colores para el fade std::vector<Color> color_; // Vector con los colores para el fade
int counter_ = 0; // Contador int counter_ = 0; // Contador
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
SDL_Point dest_; // Posición X donde dibujar el logo SDL_Point dest_; // Posición X donde dibujar el logo
LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando
Uint32 ticks_start_ = 0; // Almacena el valor actual de los ticks de SDL
// Actualiza las variables // Actualiza las variables
void update(); void update();
@@ -78,15 +54,9 @@ private:
// Gestiona el logo de JAILGAMES // Gestiona el logo de JAILGAMES
void updateJAILGAMES(); void updateJAILGAMES();
// Gestiona el logo de RETROWEEKEND
void updateRETROWEEKEND();
// Renderiza el logo de JAILGAMES // Renderiza el logo de JAILGAMES
void renderJAILGAMES(); void renderJAILGAMES();
// Renderiza el logo de RETROWEEKEND
void renderRETROWEEKEND();
// Gestiona el color de las texturas // Gestiona el color de las texturas
void updateTextureColors(); void updateTextureColors();

View File

@@ -1,9 +1,10 @@
#include "manage_hiscore_table.h" #include "manage_hiscore_table.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile #include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <algorithm> // Para sort #include <algorithm> // Para find_if, sort
#include <iostream> // Para basic_ostream, operator<<, cout, endl #include <iostream> // Para basic_ostream, operator<<, cout, endl
#include "utils.h" // Para HiScoreEntry, getFileName #include <iterator> // Para distance
#include "utils.h" // Para getFileName
// Resetea la tabla a los valores por defecto // Resetea la tabla a los valores por defecto
void ManageHiScoreTable::clear() void ManageHiScoreTable::clear()

View File

@@ -1,5 +1,4 @@
#include "moving_sprite.h" #include "moving_sprite.h"
#include <algorithm> // Para max
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
// Constructor // Constructor
@@ -28,7 +27,7 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> texture)
rotate_(Rotate()), rotate_(Rotate()),
zoom_w_(1.0f), zoom_w_(1.0f),
zoom_h_(1.0f), zoom_h_(1.0f),
flip_(SDL_FLIP_NONE) {Sprite::clear(); } flip_(SDL_FLIP_NONE) { Sprite::clear(); }
// Reinicia todas las variables // Reinicia todas las variables
void MovingSprite::clear() void MovingSprite::clear()

View File

@@ -1,16 +1,17 @@
#pragma once #pragma once
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
#include "input.h" // Para InputType, InputDeviceToUse #include "input.h" // Para InputType, InputDeviceToUse
#include "manage_hiscore_table.h" // Para HiScoreEntry #include "manage_hiscore_table.h" // Para HiScoreEntry
enum class ScreenFilter : int; // lines 10-10 enum class ScreenFilter : int; // lines 8-8
enum class ScreenVideoMode : Uint32; // lines 11-11 enum class ScreenVideoMode : Uint32; // lines 9-9
namespace lang namespace lang
{ {
enum class Code : int; enum class Code : int;
} // lines 14-14 } // lines 12-12
// Dificultad del juego // Dificultad del juego
enum class GameDifficulty enum class GameDifficulty

View File

@@ -1,9 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <string> // Para string #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <vector> // Para vector #include <string> // Para string
#include "utils.h" // Para Color, Zone #include <vector> // Para vector
#include "utils.h" // Para Color, Zone
// param.game // param.game
struct ParamGame struct ParamGame

View File

@@ -2,14 +2,13 @@
#include <algorithm> // Para find_if #include <algorithm> // Para find_if
#include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr #include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include <utility> // Para pair
#include "asset.h" // Para Asset, AssetType #include "asset.h" // Para Asset, AssetType
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound #include "jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "text.h" // Para Text, loadTextFile #include "text.h" // Para Text, loadTextFile
struct JA_Music_t; // lines 10-10 struct JA_Music_t; // lines 11-11
struct JA_Sound_t; // lines 11-11 struct JA_Sound_t; // lines 12-12
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Resource *Resource::resource_ = nullptr; Resource *Resource::resource_ = nullptr;

View File

@@ -5,13 +5,12 @@
#include <math.h> // Para roundf #include <math.h> // Para roundf
#include <iomanip> // Para operator<<, setfill, setw #include <iomanip> // Para operator<<, setfill, setw
#include <sstream> // Para basic_ostream, basic_ostringstream #include <sstream> // Para basic_ostream, basic_ostringstream
#include "enter_name.h" // Para MAX_NAME_LENGHT
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR
#include "enter_name.h" // Para NAME_LENGHT
#include <iostream>
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard *Scoreboard::scoreboard_ = nullptr; Scoreboard *Scoreboard::scoreboard_ = nullptr;
@@ -297,6 +296,7 @@ void Scoreboard::fillPanelTextures()
// NAME // NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106)); text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5)); text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
// text_scoreboard_->writeColored(enter_name_pos_.x, enter_name_pos_.y, record_name_[i], getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
break; break;
} }
case ScoreboardMode::GAME_COMPLETED: case ScoreboardMode::GAME_COMPLETED:
@@ -439,9 +439,12 @@ void Scoreboard::renderSeparator()
// Inicializa el vector de colores para el nombre // Inicializa el vector de colores para el nombre
void Scoreboard::iniNameColors() void Scoreboard::iniNameColors()
{ {
// Color color = orange_soft_color;
Color color = green_color;
name_colors_.clear(); name_colors_.clear();
name_colors_.emplace_back(green_color.lighten(50)); name_colors_.emplace_back(color.lighten(50));
name_colors_.emplace_back(green_color.lighten(25)); name_colors_.emplace_back(color.lighten(25));
name_colors_.emplace_back(green_color); name_colors_.emplace_back(color);
name_colors_.emplace_back(green_color.darken(25)); name_colors_.emplace_back(color.darken(25));
} }

View File

@@ -1,9 +1,7 @@
#include "screen.h" #include "screen.h"
#include <SDL2/SDL_events.h> // Para SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para clamp, max, min #include <algorithm> // Para max, min
#include <fstream> // Para basic_ifstream, ifstream #include <fstream> // Para basic_ifstream, ifstream
#include <iterator> // Para istreambuf_iterator, operator== #include <iterator> // Para istreambuf_iterator, operator==
#include <string> // Para allocator, operator+, char_traits, to_s... #include <string> // Para allocator, operator+, char_traits, to_s...
@@ -11,11 +9,11 @@
#include "asset.h" // Para Asset #include "asset.h" // Para Asset
#include "dbgtxt.h" // Para dbg_print #include "dbgtxt.h" // Para dbg_print
#include "global_inputs.h" // Para service_pressed_counter #include "global_inputs.h" // Para service_pressed_counter
#include "jail_shader.h" // Para init, render
#include "mouse.h" // Para updateCursorVisibility
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "on_screen_help.h" // Para OnScreenHelp #include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // Para Options, OptionsVideo, options, Options... #include "options.h" // Para Options, OptionsVideo, options, Options...
#include "mouse.h"
#include "jail_shader.h" // para init, render
// [SINGLETON] // [SINGLETON]
Screen *Screen::screen_ = nullptr; Screen *Screen::screen_ = nullptr;

View File

@@ -1,6 +1,5 @@
#include "smart_sprite.h" #include "smart_sprite.h"
#include "moving_sprite.h" // Para MovingSprite #include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 2-2
// Actualiza la posición y comprueba si ha llegado a su destino // Actualiza la posición y comprueba si ha llegado a su destino
void SmartSprite::update() void SmartSprite::update()

View File

@@ -1,13 +1,12 @@
// IWYU pragma: no_include <bits/std_abs.h> // IWYU pragma: no_include <bits/std_abs.h>
#include "tabe.h" #include "tabe.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE #include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <SDL2/SDL.h> #include <stdlib.h> // Para rand, abs
#include <stdlib.h> // Para rand, abs #include <algorithm> // Para max
#include <algorithm> // Para max #include "jail_audio.h" // Para JA_PlaySound
#include "jail_audio.h" // Para JA_PlaySound #include "param.h" // Para Param, ParamGame, param
#include "param.h" // Para Param, ParamGame, param #include "resource.h" // Para Resource
#include "resource.h" // Para Resource #include "utils.h" // Para Zone
#include "utils.h" // Para Zone
// Constructor // Constructor
Tabe::Tabe() Tabe::Tabe()

View File

@@ -1,7 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL.h> #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand
#include <memory> // Para unique_ptr #include <memory> // Para unique_ptr
#include "animated_sprite.h" // Para AnimatedSprite #include "animated_sprite.h" // Para AnimatedSprite

View File

@@ -1,8 +1,9 @@
#include "utils.h" #include "utils.h"
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread #include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <stddef.h> // Para size_t
#include <algorithm> // Para min, clamp, find_if_not, find, transform #include <algorithm> // Para min, clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace #include <cctype> // Para tolower, isspace
#include <cmath> // Para cos, pow, M_PI #include <cmath> // Para pow, sin, M_PI, cos
#include <compare> // Para operator< #include <compare> // Para operator<
#include <filesystem> // Para path #include <filesystem> // Para path
#include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios #include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios
@@ -254,7 +255,6 @@ double easeInElastic(double t)
return t == 0 ? 0 : (t == 1 ? 1 : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * (2 * M_PI) / 3)); return t == 0 ? 0 : (t == 1 ? 1 : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * (2 * M_PI) / 3));
} }
// Función de suavizado // Función de suavizado
double easeOutBounce(double t) double easeOutBounce(double t)
{ {

View File

@@ -4,6 +4,7 @@
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint8 #include <SDL2/SDL_stdinc.h> // Para Uint8
#include <stdint.h> // Para int32_t #include <stdint.h> // Para int32_t
#include <algorithm> // Para max, min
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector