cross compilation of Win32 version (using win32 API)
This commit is contained in:
parent
184a4ba414
commit
4b28894bb8
18
src/Makefile
18
src/Makefile
@ -388,9 +388,13 @@ endif
|
|||||||
CC = $(CROSS_CC)
|
CC = $(CROSS_CC)
|
||||||
CROSS_STRIP ?= $(shell which i686-w64-mingw32-strip || which mingw32-strip)
|
CROSS_STRIP ?= $(shell which i686-w64-mingw32-strip || which mingw32-strip)
|
||||||
STRIP = $(CROSS_STRIP)
|
STRIP = $(CROSS_STRIP)
|
||||||
BIN = ../bin/grafx2.exe
|
BIN = ../bin/grafx2-$(API).exe
|
||||||
COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb -Dmain=SDL_main $(shell $(CROSS_SDLCONFIG) --cflags) $(TTFCOPT)
|
COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb $(TTFCOPT)
|
||||||
LOPT = -mwindows -lmingw32 -lSDLmain -lSDL -lshlwapi $(shell $(CROSS_SDLCONFIG) --libs) -lSDL_image $(TTFLOPT)
|
LOPT = -mwindows -lmingw32 -lshlwapi $(TTFLOPT)
|
||||||
|
ifeq ($(API),sdl)
|
||||||
|
COPT += -Dmain=SDL_main $(shell $(CROSS_SDLCONFIG) --cflags)
|
||||||
|
LOPT += -lSDLmain -lSDL $(shell $(CROSS_SDLCONFIG) --libs) -lSDL_image
|
||||||
|
endif
|
||||||
ifeq (,$(CROSS_PKGCONFIG))
|
ifeq (,$(CROSS_PKGCONFIG))
|
||||||
COPT += -D__no_pnglib__
|
COPT += -D__no_pnglib__
|
||||||
else
|
else
|
||||||
@ -404,7 +408,10 @@ endif
|
|||||||
WINDRES ?= $(shell which i686-w64-mingw32-windres || which mingw32-windres)
|
WINDRES ?= $(shell which i686-w64-mingw32-windres || which mingw32-windres)
|
||||||
PLATFORM = win32
|
PLATFORM = win32
|
||||||
PLATFORMOBJ = winres.o
|
PLATFORMOBJ = winres.o
|
||||||
PLATFORMFILES = bin/SDL.dll bin/SDL_image.dll $(wildcard ../bin/libpng*.dll) $(wildcard ../bin/libjpeg*.dll) bin/zlib1.dll $(TTFLIBS)
|
PLATFORMFILES = $(wildcard ../bin/libpng*.dll) $(wildcard ../bin/libjpeg*.dll) bin/zlib1.dll $(TTFLIBS)
|
||||||
|
ifeq ($(API),sdl)
|
||||||
|
PLATFORMFILES += bin/SDL.dll bin/SDL_image.dll
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
ifdef GP2XCROSS
|
ifdef GP2XCROSS
|
||||||
#cross compile an exec for the gp2x
|
#cross compile an exec for the gp2x
|
||||||
@ -571,6 +578,9 @@ ifeq ($(API),sdl2)
|
|||||||
APIOBJ = sdlscreen.o
|
APIOBJ = sdlscreen.o
|
||||||
COPT += -DUSE_SDL2
|
COPT += -DUSE_SDL2
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(API),win32)
|
||||||
|
APIOBJ = win32screen.o
|
||||||
|
endif
|
||||||
|
|
||||||
#To enable Joystick emulation of cursor, make USE_JOYSTICK=1 (for input.o)
|
#To enable Joystick emulation of cursor, make USE_JOYSTICK=1 (for input.o)
|
||||||
#This can be necessary to test cursor code on a PC, but by default for all
|
#This can be necessary to test cursor code on a PC, but by default for all
|
||||||
|
|||||||
@ -56,7 +56,7 @@ $(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h loadsave.h \
|
|||||||
$(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \
|
$(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \
|
||||||
loadsave.h gfx2surface.h engine.h pages.h screen.h errors.h readini.h \
|
loadsave.h gfx2surface.h engine.h pages.h screen.h errors.h readini.h \
|
||||||
saveini.h io.h text.h setup.h windows.h brush.h palette.h realpath.h \
|
saveini.h io.h text.h setup.h windows.h brush.h palette.h realpath.h \
|
||||||
input.h keycodes.h help.h filesel.h
|
input.h keycodes.h help.h filesel.h win32screen.h
|
||||||
$(OBJDIR)/misc.o: misc.c struct.h const.h global.h errors.h buttons.h loadsave.h \
|
$(OBJDIR)/misc.o: misc.c struct.h const.h global.h errors.h buttons.h loadsave.h \
|
||||||
gfx2surface.h engine.h misc.h keyboard.h screen.h windows.h palette.h \
|
gfx2surface.h engine.h misc.h keyboard.h screen.h windows.h palette.h \
|
||||||
input.h keycodes.h graph.h pages.h
|
input.h keycodes.h graph.h pages.h
|
||||||
@ -119,7 +119,8 @@ $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.
|
|||||||
loadsave.h gfx2surface.h pages.h tiles.h
|
loadsave.h gfx2surface.h pages.h tiles.h
|
||||||
$(OBJDIR)/unicode.o: unicode.c unicode.h struct.h const.h
|
$(OBJDIR)/unicode.o: unicode.c unicode.h struct.h const.h
|
||||||
$(OBJDIR)/version.o: version.c
|
$(OBJDIR)/version.o: version.c
|
||||||
$(OBJDIR)/win32screen.o: win32screen.c screen.h struct.h const.h global.h
|
$(OBJDIR)/win32screen.o: win32screen.c screen.h struct.h const.h global.h errors.h \
|
||||||
|
windows.h input.h keycodes.h keyboard.h
|
||||||
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \
|
$(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \
|
||||||
global.h graph.h input.h keycodes.h misc.h op_c.h colorred.h readline.h \
|
global.h graph.h input.h keycodes.h misc.h op_c.h colorred.h readline.h \
|
||||||
screen.h palette.h unicode.h keyboard.h
|
screen.h palette.h unicode.h keyboard.h
|
||||||
|
|||||||
42
src/main.c
42
src/main.c
@ -72,8 +72,11 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
|
#if defined(WIN32) && !(defined(USE_SDL) || defined(USE_SDL2))
|
||||||
|
#include "win32screen.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN32__)
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#elif defined (__MINT__)
|
#elif defined (__MINT__)
|
||||||
@ -86,7 +89,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined (__WIN32__)
|
#if defined (WIN32) && (defined(USE_SDL) || defined(USE_SDL2))
|
||||||
// On Windows, SDL_putenv is not present in any compilable header.
|
// On Windows, SDL_putenv is not present in any compilable header.
|
||||||
// It can be linked anyway, this declaration only avoids
|
// It can be linked anyway, this declaration only avoids
|
||||||
// a compilation warning.
|
// a compilation warning.
|
||||||
@ -830,17 +833,19 @@ int Init_program(int argc,char * argv[])
|
|||||||
Pixel_ratio);
|
Pixel_ratio);
|
||||||
|
|
||||||
// Windows only: move back the window to its original position.
|
// Windows only: move back the window to its original position.
|
||||||
#if defined(__WIN32__)
|
#if defined(WIN32)
|
||||||
if (!Video_mode[starting_videomode].Fullscreen)
|
if (!Video_mode[starting_videomode].Fullscreen)
|
||||||
{
|
{
|
||||||
if (Config.Window_pos_x != 9999 && Config.Window_pos_y != 9999)
|
if (Config.Window_pos_x != 9999 && Config.Window_pos_y != 9999)
|
||||||
{
|
{
|
||||||
//RECT r;
|
//RECT r;
|
||||||
|
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||||
static SDL_SysWMinfo pInfo;
|
static SDL_SysWMinfo pInfo;
|
||||||
SDL_VERSION(&pInfo.version);
|
SDL_VERSION(&pInfo.version);
|
||||||
SDL_GetWMInfo(&pInfo);
|
SDL_GetWMInfo(&pInfo);
|
||||||
//GetWindowRect(pInfo.window, &r);
|
//GetWindowRect(pInfo.window, &r);
|
||||||
SetWindowPos(pInfo.window, 0, Config.Window_pos_x, Config.Window_pos_y, 0, 0, SWP_NOSIZE);
|
SetWindowPos(pInfo.window, 0, Config.Window_pos_x, Config.Window_pos_y, 0, 0, SWP_NOSIZE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1043,7 +1048,7 @@ void Program_shutdown(void)
|
|||||||
int return_code;
|
int return_code;
|
||||||
|
|
||||||
// Windows only: Recover the window position.
|
// Windows only: Recover the window position.
|
||||||
#if defined(__WIN32__)
|
#if defined(WIN32) && (defined(USE_SDL) || defined(USE_SDL2))
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
static SDL_SysWMinfo pInfo;
|
static SDL_SysWMinfo pInfo;
|
||||||
@ -1171,7 +1176,7 @@ int main(int argc,char * argv[])
|
|||||||
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
|
GetModuleFileName(NULL, ModuleFileName, MAX_PATH);
|
||||||
GetShortPathName(ModuleFileName, ModuleShortFileName, MAX_PATH);
|
GetShortPathName(ModuleFileName, ModuleShortFileName, MAX_PATH);
|
||||||
argv[argc++] = arg_buffer;
|
argv[argc++] = arg_buffer;
|
||||||
for (i = 0; i < sizeof(arg_buffer); i++) {
|
for (i = 0; i < (int)sizeof(arg_buffer); i++) {
|
||||||
arg_buffer[i] = (char)ModuleShortFileName[i];
|
arg_buffer[i] = (char)ModuleShortFileName[i];
|
||||||
if (arg_buffer[i] == 0) break;
|
if (arg_buffer[i] == 0) break;
|
||||||
}
|
}
|
||||||
@ -1188,3 +1193,30 @@ int main(int argc,char * argv[])
|
|||||||
Program_shutdown();
|
Program_shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2) && !defined(_MSC_VER)
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR _lpCmdLine, int nCmdShow)
|
||||||
|
{
|
||||||
|
WCHAR *lpCmdLine = GetCommandLineW();
|
||||||
|
if (__argc == 1)
|
||||||
|
{ // avoids GetCommandLineW bug that does not always quote the program name if no arguments
|
||||||
|
do { ++lpCmdLine; } while (*lpCmdLine);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOL quoted = lpCmdLine[0] == L'"';
|
||||||
|
++lpCmdLine; // skips the " or the first letter (all paths are at least 1 letter)
|
||||||
|
while (*lpCmdLine)
|
||||||
|
{
|
||||||
|
if (quoted && lpCmdLine[0] == L'"') quoted = FALSE; // found end quote
|
||||||
|
else if (!quoted && lpCmdLine[0] == L' ')
|
||||||
|
{ // found an unquoted space, now skip all spaces
|
||||||
|
do { ++lpCmdLine; } while (lpCmdLine[0] == L' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++lpCmdLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -32,10 +32,6 @@
|
|||||||
#include "struct.h"
|
#include "struct.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2)
|
|
||||||
int Init_Win32(HINSTANCE hInstance, HINSTANCE hPrevInstance);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void GFX2_Set_mode(int *width, int *height, int fullscreen);
|
void GFX2_Set_mode(int *width, int *height, int fullscreen);
|
||||||
|
|
||||||
byte Get_Screen_pixel(int x, int y);
|
byte Get_Screen_pixel(int x, int y);
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
#include <Windows.h>
|
#include <windows.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
@ -30,6 +30,7 @@
|
|||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "keyboard.h"
|
||||||
|
|
||||||
extern int user_feedback_required;
|
extern int user_feedback_required;
|
||||||
extern word Input_new_mouse_X;
|
extern word Input_new_mouse_X;
|
||||||
|
|||||||
34
src/win32screen.h
Normal file
34
src/win32screen.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* vim:expandtab:ts=2 sw=2:
|
||||||
|
*/
|
||||||
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
|
Copyright 2018 Thomas Bernard
|
||||||
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; version 2
|
||||||
|
of the License.
|
||||||
|
|
||||||
|
Grafx2 is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
///@file win32screen.h
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef WIN32SCREEN_H_INCLUDED
|
||||||
|
#define WIN32SCREEN_H_INCLUDED
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(USE_SDL) && !defined(USE_SDL2)
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int Init_Win32(HINSTANCE hInstance, HINSTANCE hPrevInstance);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user