mirror of
https://github.com/Oibaf66/fbzx-wii.git
synced 2024-11-24 17:16:57 +01:00
Joypad as joystick as default, FBZX Wii for Window can be installed everywhere
This commit is contained in:
parent
24c37cf1ac
commit
f931efe19e
@ -29,6 +29,7 @@
|
|||||||
#include "computer.h"
|
#include "computer.h"
|
||||||
#include "VirtualKeyboard.h"
|
#include "VirtualKeyboard.h"
|
||||||
#include "menu_sdl.h"
|
#include "menu_sdl.h"
|
||||||
|
#include "emulator.h"
|
||||||
#include<SDL/SDL_image.h>
|
#include<SDL/SDL_image.h>
|
||||||
|
|
||||||
#ifdef GEKKO
|
#ifdef GEKKO
|
||||||
@ -73,35 +74,46 @@ void VirtualKeyboard_init(SDL_Surface *screen)
|
|||||||
VirtualKeyboard.sel_x = 64;
|
VirtualKeyboard.sel_x = 64;
|
||||||
VirtualKeyboard.sel_y = 100;
|
VirtualKeyboard.sel_y = 100;
|
||||||
vkb_is_init = -1;
|
vkb_is_init = -1;
|
||||||
|
char *image_path;
|
||||||
|
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard.png");
|
image_path=myfile("fbzx/Spectrum_keyboard.png");
|
||||||
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load keyboard image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load keyboard image\n"); return;}
|
||||||
image_kbd=SDL_DisplayFormat(tmp_surface);
|
image_kbd=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
|
||||||
|
image_path=myfile("fbzx/symbol_shift.png");
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/symbol_shift.png");
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load symbol shift image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load symbol shift image\n"); return;}
|
||||||
image_sym=SDL_DisplayFormat(tmp_surface);
|
image_sym=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
|
||||||
|
image_path=myfile("fbzx/caps_shift.png");
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/caps_shift.png");
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load caps shift image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load caps shift image\n"); return;}
|
||||||
image_caps=SDL_DisplayFormat(tmp_surface);
|
image_caps=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/Spectrum_keyboard_small.png");
|
image_path=myfile("fbzx/Spectrum_keyboard_small.png");
|
||||||
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load keyboard small image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load keyboard small image\n"); return;}
|
||||||
image_kbd_small=SDL_DisplayFormat(tmp_surface);
|
image_kbd_small=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/symbol_shift_small.png");
|
image_path=myfile("fbzx/symbol_shift_small.png");
|
||||||
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load symbol shift small image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load symbol shift small image\n"); return;}
|
||||||
image_sym_small=SDL_DisplayFormat(tmp_surface);
|
image_sym_small=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
|
||||||
tmp_surface=IMG_Load("/fbzx-wii/fbzx/caps_shift_small.png");
|
image_path=myfile("fbzx/caps_shift_small.png");
|
||||||
|
tmp_surface=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
if (tmp_surface == NULL) {printf("Impossible to load caps shift small image\n"); return;}
|
if (tmp_surface == NULL) {printf("Impossible to load caps shift small image\n"); return;}
|
||||||
image_caps_small=SDL_DisplayFormat(tmp_surface);
|
image_caps_small=SDL_DisplayFormat(tmp_surface);
|
||||||
SDL_FreeSurface (tmp_surface);
|
SDL_FreeSurface (tmp_surface);
|
||||||
|
@ -99,6 +99,8 @@ void computer_init () { //Called only on start-up
|
|||||||
ordenador.videosystem = 0; //PAL
|
ordenador.videosystem = 0; //PAL
|
||||||
ordenador.joystick[0] = 1; //Kemposton
|
ordenador.joystick[0] = 1; //Kemposton
|
||||||
ordenador.joystick[1] = 0; // Cursor
|
ordenador.joystick[1] = 0; // Cursor
|
||||||
|
ordenador.joypad_as_joystick[0]= 1;
|
||||||
|
ordenador.joypad_as_joystick[1]= 1;
|
||||||
ordenador.vk_auto = 0; //Vk called by +
|
ordenador.vk_auto = 0; //Vk called by +
|
||||||
ordenador.vk_rumble = 1; //enabled
|
ordenador.vk_rumble = 1; //enabled
|
||||||
ordenador.rumble[0] = 0;
|
ordenador.rumble[0] = 0;
|
||||||
|
@ -242,7 +242,12 @@ unsigned char InitNetwork()
|
|||||||
int load_zxspectrum_picture()
|
int load_zxspectrum_picture()
|
||||||
{
|
{
|
||||||
|
|
||||||
image=IMG_Load("/fbzx-wii/fbzx/ZXSpectrum48k.png");
|
char *image_path;
|
||||||
|
|
||||||
|
image_path=myfile("fbzx/ZXSpectrum48k.png");
|
||||||
|
|
||||||
|
image=IMG_Load(image_path);
|
||||||
|
free(image_path);
|
||||||
|
|
||||||
if (image == NULL) {printf("Impossible to load image\n"); return 0;}
|
if (image == NULL) {printf("Impossible to load image\n"); return 0;}
|
||||||
|
|
||||||
@ -307,25 +312,17 @@ void SDL_Fullscreen_Switch()
|
|||||||
|
|
||||||
FILE *myfopen(char *filename,char *mode) {
|
FILE *myfopen(char *filename,char *mode) {
|
||||||
|
|
||||||
char tmp[4096];
|
char path[MAX_PATH_LENGTH];
|
||||||
FILE *fichero;
|
FILE *fichero;
|
||||||
|
int length;
|
||||||
|
|
||||||
fichero=fopen(filename,mode);
|
strcpy(path,getenv("HOME"));
|
||||||
if (fichero!=NULL) {
|
length=strlen(path);
|
||||||
return (fichero);
|
if ((length>0)&&(path[length-1]!='/'))
|
||||||
}
|
strcat(path,"/");
|
||||||
sprintf(tmp,"/usr/share/%s",filename);
|
strcat(path,filename);
|
||||||
fichero=fopen(tmp,mode);
|
printf("opening %s\n",path);
|
||||||
if (fichero!=NULL) {
|
fichero=fopen(path,mode);
|
||||||
return (fichero);
|
|
||||||
}
|
|
||||||
sprintf(tmp,"/usr/local/share/%s",filename);
|
|
||||||
fichero=fopen(tmp,mode);
|
|
||||||
if (fichero!=NULL) {
|
|
||||||
return (fichero);
|
|
||||||
}
|
|
||||||
sprintf(tmp,"/fbzx-wii/%s",filename);
|
|
||||||
fichero=fopen(tmp,mode);
|
|
||||||
if (fichero!=NULL) {
|
if (fichero!=NULL) {
|
||||||
return (fichero);
|
return (fichero);
|
||||||
}
|
}
|
||||||
@ -333,6 +330,22 @@ FILE *myfopen(char *filename,char *mode) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *myfile(char *filename) {
|
||||||
|
|
||||||
|
char *path;
|
||||||
|
int length;
|
||||||
|
|
||||||
|
path=(char *)malloc(MAX_PATH_LENGTH);
|
||||||
|
|
||||||
|
strcpy(path,getenv("HOME"));
|
||||||
|
length=strlen(path);
|
||||||
|
if ((length>0)&&(path[length-1]!='/'))
|
||||||
|
strcat(path,"/");
|
||||||
|
strcat(path,filename);
|
||||||
|
|
||||||
|
return (path);
|
||||||
|
}
|
||||||
|
|
||||||
char *load_a_rom(char **filenames) {
|
char *load_a_rom(char **filenames) {
|
||||||
|
|
||||||
char **pointer;
|
char **pointer;
|
||||||
@ -786,7 +799,7 @@ void load_config_network(struct computer *object) {
|
|||||||
unsigned char smb_enable=0, ftp_enable=0, FTPPassive=0;
|
unsigned char smb_enable=0, ftp_enable=0, FTPPassive=0;
|
||||||
unsigned int FTPPort=21;
|
unsigned int FTPPort=21;
|
||||||
|
|
||||||
fconfig = fopen("/fbzx-wii/fbzx.net","rb");
|
fconfig = myfopen("fbzx.net","rb");
|
||||||
if (fconfig==NULL) {
|
if (fconfig==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1190,7 +1203,16 @@ int main(int argc,char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MINGW
|
#ifdef MINGW
|
||||||
if(!getenv("HOME")) putenv("HOME=/fbzx-wii");
|
char path_home[MAX_PATH_LENGTH];
|
||||||
|
int i;
|
||||||
|
strcpy(path_home,"HOME=");
|
||||||
|
getcwd(path_home+5, MAX_PATH_LENGTH-5);
|
||||||
|
|
||||||
|
for (i=4; path_home[i]!=0;i++)
|
||||||
|
if (path_home[i]=='\\') path_home[i]='/';
|
||||||
|
|
||||||
|
printf("%s\n",path_home);
|
||||||
|
putenv(path_home);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef GEKKO
|
#ifdef GEKKO
|
||||||
|
@ -56,6 +56,7 @@ int load_config(struct computer *object, char *filename);
|
|||||||
int save_config(struct computer *object, char *filename);
|
int save_config(struct computer *object, char *filename);
|
||||||
int save_config_game(struct computer *object, char *filename, int overwrite);
|
int save_config_game(struct computer *object, char *filename, int overwrite);
|
||||||
FILE *myfopen(char *filename,char *mode);
|
FILE *myfopen(char *filename,char *mode);
|
||||||
|
char *myfile(char *filename);
|
||||||
void init_sdl();
|
void init_sdl();
|
||||||
void init_sound();
|
void init_sound();
|
||||||
void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface);
|
void init_screen(int resx,int resy,int depth,int fullscreen,int dblbuffer,int hwsurface);
|
||||||
|
@ -86,7 +86,6 @@ static SDL_Surface *real_screen;
|
|||||||
#define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )
|
#define IS_SUBMENU(p_msg) ( (p_msg)[0] == '^' )
|
||||||
#define IS_TEXT(p_msg) ( (p_msg)[0] == '#' || (p_msg)[0] == ' ' )
|
#define IS_TEXT(p_msg) ( (p_msg)[0] == '#' || (p_msg)[0] == ' ' )
|
||||||
#define IS_MARKER(p_msg) ( (p_msg)[0] == '@' )
|
#define IS_MARKER(p_msg) ( (p_msg)[0] == '@' )
|
||||||
#define FONT_PATH "/fbzx-wii/fbzx/FreeMono.ttf"
|
|
||||||
|
|
||||||
static int is_inited = 0;
|
static int is_inited = 0;
|
||||||
static TTF_Font *menu_font16, *menu_font20, *menu_font8, *menu_font10;
|
static TTF_Font *menu_font16, *menu_font20, *menu_font8, *menu_font10;
|
||||||
@ -1492,12 +1491,18 @@ static TTF_Font *read_font(const char *path, int font_size)
|
|||||||
|
|
||||||
void font_init()
|
void font_init()
|
||||||
{
|
{
|
||||||
|
char *font_path;
|
||||||
|
|
||||||
TTF_Init();
|
TTF_Init();
|
||||||
|
|
||||||
menu_font16 = read_font(FONT_PATH, 16);
|
font_path=myfile("fbzx/FreeMono.ttf");
|
||||||
menu_font20 = read_font(FONT_PATH, 20);
|
|
||||||
menu_font8 = read_font(FONT_PATH, 8);
|
menu_font16 = read_font(font_path, 16);
|
||||||
menu_font10 = read_font(FONT_PATH, 10);
|
menu_font20 = read_font(font_path, 20);
|
||||||
|
menu_font8 = read_font(font_path, 8);
|
||||||
|
menu_font10 = read_font(font_path, 10);
|
||||||
|
|
||||||
|
free(font_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_init(SDL_Surface *screen)
|
void menu_init(SDL_Surface *screen)
|
||||||
|
Loading…
Reference in New Issue
Block a user