Patches for PocketGo compilation

This commit is contained in:
octospacc 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
ExeName = $(AppName).exe
ExeSuffix = .exe
Sources = $(wildcard Source/*.c)
Objects = $(Sources:.c=.o)
Defines = -DTarget_PC
CFlags = -O2
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)
$(AppName): $(Objects)
$(CC) $^ $(CFlags) $(LdFlags) -o $(ExeName)
$(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix)
clean:
rm Source/*.o $(ExeName)
rm -f Source/*.o $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix)

View File

@ -1,18 +1,28 @@
#pragma once
#define KeyEsc SDLK_ESCAPE
#define KeyDebug SDLK_F3
#define KeyGenFlatMap SDLK_F6
#define KeyGenNoiseMap SDLK_F7
#define KeyUp SDLK_UP
#define KeyDown SDLK_DOWN
#define KeyLeft SDLK_LEFT
#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 KeyBelow SDLK_LCTRL
#define KeyPlace SDLK_z
#define KeyBreak SDLK_x
#endif

View File

@ -4,15 +4,13 @@
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include "TargetsConfigs.h"
#include "Blocks.h"
#include "Keys.h"
#include "Util.h"
#define AppName "BloccSpacc"
#define ScreenBits 16
int ScreenWidth = 512;
int ScreenHeight = 512;
#define GameTick 30
SDL_Surface * Screen = NULL;
@ -28,7 +26,7 @@ SDL_Surface * DebugMsg = NULL;
TTF_Font * DebugFont = NULL;
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>
static Uint32 NextTime;
@ -103,19 +101,19 @@ void MoveCursor (int Direction) {
if ( Direction == 0 && CursorPos.z > 0 ) { // Up
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;
}
if ( Direction == 4 && CursorPos.z < BlockSize * (ChunksNum.z - 1) ) { // Down
else if ( Direction == 4 && CursorPos.z < BlockSize * (ChunksNum.z - 1) ) { // Down
CursorPos.z += BlockSize;
}
if ( Direction == 6 && CursorPos.x > 0 ) { // Left
else if ( Direction == 6 && CursorPos.x > 0 ) { // Left
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;
}
if ( Direction == 9 && CursorPos.y > 0 ) { // Below
else if ( Direction == 9 && CursorPos.y > 0 ) { // Below
CursorPos.y -= BlockSize;
}
@ -177,7 +175,7 @@ void SetCamera() {
int z = ( CursorPos.z + BlockSize/2 );
struct xyz xyz = OrthoToIso ( x, y, z, 1 );
Camera.x = xyz.x - ScreenWidth/2;
Camera.z = xyz.z - ScreenHeight/2;
Camera.z = xyz.z - ScreenHeight*0.80;
}
void DrawCursor() {
@ -269,12 +267,12 @@ int main( int argc, char* args[] ) {
CursorPos.y = 0;
CursorPos.z = BlockSize * (ChunksNum.z - 1);
Redraw = true;
Recalc = true;
while ( !Quit ) {
NextTime = SDL_GetTicks() + GameTick;
while ( SDL_PollEvent( & Event ) ) {
Redraw = true;
Recalc = true;
if ( Event.type == SDL_QUIT ) {
Quit = true;
}
@ -321,8 +319,8 @@ int main( int argc, char* args[] ) {
}
}
}
if ( Recalc ) {
EventHandle();
if ( Redraw ) {
SDL_FillRect( Screen, &Screen->clip_rect, SDL_MapRGB( Screen->format, 0xFF, 0xFF, 0xFF ) );
SetCamera();
DrawMap( ChunksNum );
@ -333,7 +331,7 @@ int main( int argc, char* args[] ) {
if ( !FlipScreen( Screen ) ) {
return 1;
}
Redraw = false;
Recalc = false;
}
SDL_Delay( TimeLeft() );
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 ) {
Screen = SDL_SetVideoMode ( Width, Height, Bits,
#ifdef Target_PocketGo
SDL_HWSURFACE
#else
//SDL_SWSURFACE //|
SDL_HWSURFACE |
SDL_DOUBLEBUF |
SDL_RESIZABLE //|
//SDL_FULLSCREEN //|
#endif
);
return Screen;
}