Patches for PocketGo compilation

This commit is contained in:
2022-08-04 00:39:06 +02:00
parent 5d630b66f0
commit c8b08f9cf7
5 changed files with 63 additions and 25 deletions

View File

@ -1,15 +1,28 @@
AppName = BloccSpacc AppName = BloccSpacc
ExeName = $(AppName).exe ExeSuffix = .exe
Sources = $(wildcard Source/*.c) Sources = $(wildcard Source/*.c)
Objects = $(Sources:.c=.o) Objects = $(Sources:.c=.o)
Defines = -DTarget_PC
CFlags = -O2 CFlags = -O2
LdFlags = -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_ttf LdFlags = -lSDL -lSDL_gfx -lSDL_image -lSDL_mixer -lSDL_ttf
CC = gcc $(Defines)
ifdef Target
ifeq ($(Target), PocketGo)
ExeSuffix = .PocketGo.exe
PathPrefix = /opt/miyoo/bin/arm-miyoo-linux-uclibcgnueabi
Defines = -DTarget_PocketGo
CC = $(PathPrefix)-gcc $(Defines)
endif
endif
all: $(AppName) all: $(AppName)
$(AppName): $(Objects) $(AppName): $(Objects)
$(CC) $^ $(CFlags) $(LdFlags) -o $(ExeName) $(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix)
clean: clean:
rm Source/*.o $(ExeName) rm -f Source/*.o $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix)

View File

@ -1,18 +1,28 @@
#pragma once #pragma once
#define KeyEsc SDLK_ESCAPE
#define KeyDebug SDLK_F3
#define KeyGenFlatMap SDLK_F6
#define KeyGenNoiseMap SDLK_F7
#define KeyUp SDLK_UP #define KeyUp SDLK_UP
#define KeyDown SDLK_DOWN #define KeyDown SDLK_DOWN
#define KeyLeft SDLK_LEFT #define KeyLeft SDLK_LEFT
#define KeyRight SDLK_RIGHT #define KeyRight SDLK_RIGHT
#define KeyEsc SDLK_ESCAPE
#define KeyDebug SDLK_F3
#ifdef Target_PocketGo
#define KeyGenFlatMap SDLK_LSHIFT // X
#define KeyGenNoiseMap SDLK_SPACE // Y
#define KeyAbove SDLK_LALT // A
#define KeyBelow SDLK_LCTRL // B
#define KeyPlace SDLK_TAB // L
#define KeyBreak SDLK_BACKSPACE // R
#else
#define KeyGenFlatMap SDLK_F6
#define KeyGenNoiseMap SDLK_F7
#define KeyAbove SDLK_LSHIFT #define KeyAbove SDLK_LSHIFT
#define KeyBelow SDLK_LCTRL #define KeyBelow SDLK_LCTRL
#define KeyPlace SDLK_z #define KeyPlace SDLK_z
#define KeyBreak SDLK_x #define KeyBreak SDLK_x
#endif

View File

@ -4,15 +4,13 @@
#include "SDL/SDL.h" #include "SDL/SDL.h"
#include "SDL/SDL_image.h" #include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h" #include "SDL/SDL_ttf.h"
#include "TargetsConfigs.h"
#include "Blocks.h" #include "Blocks.h"
#include "Keys.h" #include "Keys.h"
#include "Util.h" #include "Util.h"
#define AppName "BloccSpacc" #define AppName "BloccSpacc"
#define ScreenBits 16
int ScreenWidth = 512;
int ScreenHeight = 512;
#define GameTick 30 #define GameTick 30
SDL_Surface * Screen = NULL; SDL_Surface * Screen = NULL;
@ -28,7 +26,7 @@ SDL_Surface * DebugMsg = NULL;
TTF_Font * DebugFont = NULL; TTF_Font * DebugFont = NULL;
SDL_Color DebugTextColor = { 80, 80, 80 }; SDL_Color DebugTextColor = { 80, 80, 80 };
bool Quit, Redraw, DebugMode; bool Quit, Recalc, DebugMode;
// <https://www.libsdl.org/release/SDL-1.2.15/docs/html/guidetimeexamples.html> // <https://www.libsdl.org/release/SDL-1.2.15/docs/html/guidetimeexamples.html>
static Uint32 NextTime; static Uint32 NextTime;
@ -103,19 +101,19 @@ void MoveCursor (int Direction) {
if ( Direction == 0 && CursorPos.z > 0 ) { // Up if ( Direction == 0 && CursorPos.z > 0 ) { // Up
CursorPos.z -= BlockSize; CursorPos.z -= BlockSize;
} }
if ( Direction == 2 && CursorPos.x < BlockSize * (ChunksNum.x - 1) ) { // Right else if ( Direction == 2 && CursorPos.x < BlockSize * (ChunksNum.x - 1) ) { // Right
CursorPos.x += BlockSize; CursorPos.x += BlockSize;
} }
if ( Direction == 4 && CursorPos.z < BlockSize * (ChunksNum.z - 1) ) { // Down else if ( Direction == 4 && CursorPos.z < BlockSize * (ChunksNum.z - 1) ) { // Down
CursorPos.z += BlockSize; CursorPos.z += BlockSize;
} }
if ( Direction == 6 && CursorPos.x > 0 ) { // Left else if ( Direction == 6 && CursorPos.x > 0 ) { // Left
CursorPos.x -= BlockSize; CursorPos.x -= BlockSize;
} }
if ( Direction == 8 && CursorPos.y < BlockSize * (ChunksNum.y - 1) ) { // Above else if ( Direction == 8 && CursorPos.y < BlockSize * (ChunksNum.y - 1) ) { // Above
CursorPos.y += BlockSize; CursorPos.y += BlockSize;
} }
if ( Direction == 9 && CursorPos.y > 0 ) { // Below else if ( Direction == 9 && CursorPos.y > 0 ) { // Below
CursorPos.y -= BlockSize; CursorPos.y -= BlockSize;
} }
@ -177,7 +175,7 @@ void SetCamera() {
int z = ( CursorPos.z + BlockSize/2 ); int z = ( CursorPos.z + BlockSize/2 );
struct xyz xyz = OrthoToIso ( x, y, z, 1 ); struct xyz xyz = OrthoToIso ( x, y, z, 1 );
Camera.x = xyz.x - ScreenWidth/2; Camera.x = xyz.x - ScreenWidth/2;
Camera.z = xyz.z - ScreenHeight/2; Camera.z = xyz.z - ScreenHeight*0.80;
} }
void DrawCursor() { void DrawCursor() {
@ -269,12 +267,12 @@ int main( int argc, char* args[] ) {
CursorPos.y = 0; CursorPos.y = 0;
CursorPos.z = BlockSize * (ChunksNum.z - 1); CursorPos.z = BlockSize * (ChunksNum.z - 1);
Redraw = true; Recalc = true;
while ( !Quit ) { while ( !Quit ) {
NextTime = SDL_GetTicks() + GameTick; NextTime = SDL_GetTicks() + GameTick;
while ( SDL_PollEvent( & Event ) ) { while ( SDL_PollEvent( & Event ) ) {
Redraw = true; Recalc = true;
if ( Event.type == SDL_QUIT ) { if ( Event.type == SDL_QUIT ) {
Quit = true; Quit = true;
} }
@ -321,8 +319,8 @@ int main( int argc, char* args[] ) {
} }
} }
} }
EventHandle(); if ( Recalc ) {
if ( Redraw ) { EventHandle();
SDL_FillRect( Screen, &Screen->clip_rect, SDL_MapRGB( Screen->format, 0xFF, 0xFF, 0xFF ) ); SDL_FillRect( Screen, &Screen->clip_rect, SDL_MapRGB( Screen->format, 0xFF, 0xFF, 0xFF ) );
SetCamera(); SetCamera();
DrawMap( ChunksNum ); DrawMap( ChunksNum );
@ -333,7 +331,7 @@ int main( int argc, char* args[] ) {
if ( !FlipScreen( Screen ) ) { if ( !FlipScreen( Screen ) ) {
return 1; return 1;
} }
Redraw = false; Recalc = false;
} }
SDL_Delay( TimeLeft() ); SDL_Delay( TimeLeft() );
NextTime += GameTick; NextTime += GameTick;

13
Source/TargetsConfigs.h Normal file
View File

@ -0,0 +1,13 @@
#ifdef Target_PocketGo
#define ScreenBits 16
int ScreenWidth = 320;
int ScreenHeight = 240;
#else
#define ScreenBits 32
int ScreenWidth = 512;
int ScreenHeight = 512;
#endif

View File

@ -30,11 +30,15 @@ void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface *
SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen ) { SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen ) {
Screen = SDL_SetVideoMode ( Width, Height, Bits, Screen = SDL_SetVideoMode ( Width, Height, Bits,
#ifdef Target_PocketGo
SDL_HWSURFACE
#else
//SDL_SWSURFACE //| //SDL_SWSURFACE //|
SDL_HWSURFACE | SDL_HWSURFACE |
SDL_DOUBLEBUF | SDL_DOUBLEBUF |
SDL_RESIZABLE //| SDL_RESIZABLE //|
//SDL_FULLSCREEN //| //SDL_FULLSCREEN //|
#endif
); );
return Screen; return Screen;
} }