Const chars to avoid warnings, small fixes

This commit is contained in:
simon.kagstrom 2009-01-04 12:19:26 +00:00
parent 4572895460
commit 8f21e2901f
5 changed files with 30 additions and 23 deletions

View File

@ -12,11 +12,14 @@
#if defined(GEKKO)
#include <wiiuse/wpad.h>
#define FONT_PATH "/apps/frodo/FreeMono.ttf"
#else
#define FONT_PATH "FreeMono.ttf"
#endif
static struct timeval tv_start;
static int MENU_SIZE_X, MENU_SIZE_Y;
static char *main_menu_messages[] = {
static const char *main_menu_messages[] = {
"Insert disc or tape", /* 0 */
"Load disc or tape", /* 1 */
"Reset C64", /* 2 */
@ -30,14 +33,14 @@ static char *main_menu_messages[] = {
NULL,
};
static char *display_option_messages[] = {
static const char *display_option_messages[] = {
"1-1 resolution", /* 0 */
"double resolution, centered", /* 1 */
"full-screen stretched", /* 2 */
NULL,
};
static char *bind_key_messages[] = {
static const char *bind_key_messages[] = {
"Bind to A", /* 0 */
"Bind to B", /* 1 */
"Bind to Plus", /* 2 */
@ -46,7 +49,7 @@ static char *bind_key_messages[] = {
NULL,
};
static char *save_load_state_messages[] = {
static const char *save_load_state_messages[] = {
"Load saved state", /* 0 */
"Save current state", /* 0 */
"Delete state", /* 0 */
@ -82,7 +85,7 @@ void C64::c64_ctor1(void)
SDL_RWops *rw;
Uint8 *data = (Uint8*)malloc(1 * 1024*1024);
FILE *fp = fopen("/apps/frodo/FreeMono.ttf", "r");
FILE *fp = fopen(FONT_PATH, "r");
if (!fp) {
fprintf(stderr, "Could not open font\n");
exit(1);
@ -122,7 +125,7 @@ void C64::c64_dtor(void)
void C64::select_disc(Prefs *np)
{
DIR *d = opendir(this->base_dir);
char **file_list;
const char **file_list;
int cur = 0;
struct dirent *de;
int cnt = 16;
@ -131,7 +134,7 @@ void C64::select_disc(Prefs *np)
if (!d)
return;
file_list = (char**)malloc(cnt * sizeof(char*));
file_list = (const char**)malloc(cnt * sizeof(char*));
file_list[cur++] = strdup("None");
file_list[cur] = NULL;
@ -151,7 +154,7 @@ void C64::select_disc(Prefs *np)
if (cur > cnt - 2)
{
cnt = cnt + 32;
file_list = (char**)realloc(file_list, cnt * sizeof(char*));
file_list = (const char**)realloc(file_list, cnt * sizeof(char*));
if (!file_list)
return;
}
@ -164,7 +167,7 @@ void C64::select_disc(Prefs *np)
int opt = menu_select(real_screen, &select_disc_menu, ~0, NULL);
if (opt >= 0)
{
char *name = file_list[opt];
const char *name = file_list[opt];
if (strcmp(file_list[opt], "None") == 0)
{
@ -186,7 +189,7 @@ void C64::select_disc(Prefs *np)
/* Cleanup everything */
for ( int i = 0; i < cur; i++ )
free(file_list[i]);
free((void*)file_list[i]);
free(file_list);
}
@ -196,7 +199,7 @@ void C64::bind_key(Prefs *np)
{
menu_t bind_key_menu;
menu_t key_menu;
static char *keys[] = { "space", "Run/Stop", "return", "F1", "F3", "F5", "F7",
static const char *keys[] = { "space", "Run/Stop", "return", "F1", "F3", "F5", "F7",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
"B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z",
@ -512,8 +515,7 @@ uint8 C64::poll_joystick(int port)
return j;
#endif
#ifdef HAVE_LINUX_JOYSTICK_H
#elif defined(HAVE_LINUX_JOYSTICK_H)
JS_DATA_TYPE js;
uint8 j = 0xff;

View File

@ -86,11 +86,6 @@ int init_graphics(void)
real_screen = SDL_SetVideoMode(640, 480, 8,
SDL_DOUBLEBUF | SDL_FULLSCREEN);
#if 0
screen = SDL_SetVideoMode(DISPLAY_X, DISPLAY_Y + 17, 8,
SDL_DOUBLEBUF | SDL_FULLSCREEN);
#endif
return 1;
}

View File

@ -30,6 +30,16 @@ int main(int argc, char **argv)
if (!init_graphics())
return 0;
fflush(stdout);
// Init SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
return 0;
}
if (TTF_Init() < 0)
{
fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() );
return 0;
}
the_app = new Frodo();
the_app->ArgvReceived(argc, argv);

View File

@ -43,7 +43,7 @@ static submenu_t *find_submenu(menu_t *p_menu, int index)
}
static void print_font(SDL_Surface *screen, TTF_Font *font, int r, int g, int b,
int x, int y, char *msg)
int x, int y, const char *msg)
{
SDL_Surface *font_surf;
SDL_Rect dst = {x, y, 0, 0};
@ -93,7 +93,7 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu)
for (i = p_menu->start_entry_visible; i < p_menu->n_entries; i++)
{
char *msg = p_menu->pp_msgs[i];
const char *msg = p_menu->pp_msgs[i];
int y = (i - p_menu->start_entry_visible) * line_height;
if ((p_menu->available_options & (1<<i)) == 0) /* Gray (not available) */
@ -179,7 +179,7 @@ static int is_submenu_title(menu_t *p_menu, int n)
}
void menu_init(menu_t *p_menu, TTF_Font *p_font, char **pp_msgs,
void menu_init(menu_t *p_menu, TTF_Font *p_font, const char **pp_msgs,
int16_t x1, int16_t y1, int16_t x2, int16_t y2)
{
int i;

View File

@ -30,7 +30,7 @@ typedef struct
typedef struct
{
char **pp_msgs;
const char **pp_msgs;
TTF_Font *p_font;
int x1,y1;
int x2,y2;
@ -46,7 +46,7 @@ typedef struct
int n_entries;
} menu_t;
void menu_init(menu_t *p_menu, TTF_Font *p_font, char **pp_msgs,
void menu_init(menu_t *p_menu, TTF_Font *p_font, const char **pp_msgs,
int16_t x1, int16_t y1, int16_t x2, int16_t y2);
void menu_fini(menu_t *p_menu);