mirror of
https://gitlab.com/octospacc/MultiSpaccSDK
synced 2025-04-08 16:11:05 +02:00
Restructure code in preparation for function-based hierarchy
This commit is contained in:
parent
8f73970599
commit
12c2dfee6d
@ -2,6 +2,7 @@ AppName = $(notdir ${CURDIR})
|
||||
Sources = $(wildcard *.c ../../LibMultiSpacc/*.c)
|
||||
CFlags = -O2 -Wpedantic -Werror
|
||||
|
||||
# Default build is always for the host system
|
||||
ifndef Target
|
||||
ifeq ($(shell uname --operating-system), Msys)
|
||||
Target = WindowsPC
|
||||
@ -26,16 +27,16 @@ ifdef Target
|
||||
endif
|
||||
|
||||
ifeq ($(MultiSpacc_Target), SDL12)
|
||||
Defines += -DMultiSpacc_Target_SDL12
|
||||
Defines += -DMultiSpacc_Target_SDL12 -DMultiSpacc_Target_SDLCom
|
||||
CFlags += $(shell sdl-config --cflags)
|
||||
LdFlags += $(shell sdl-config --libs) -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf
|
||||
Sources += $(wildcard ../../LibMultiSpacc/SDLCom/*.c ../../LibMultiSpacc/SDL12/*.c)
|
||||
#Sources += $(wildcard ../../LibMultiSpacc/SDLCom/*.c ../../LibMultiSpacc/SDL12/*.c)
|
||||
BuildProcess = Normal
|
||||
else ifeq ($(MultiSpacc_Target), SDL20)
|
||||
Defines += -DMultiSpacc_Target_SDL20
|
||||
Defines += -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom
|
||||
CFlags += $(shell sdl2-config --cflags)
|
||||
LdFlags += $(shell sdl2-config --libs) -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf
|
||||
Sources += $(wildcard ../../LibMultiSpacc/SDLCom/*.c ../../LibMultiSpacc/SDL20/*.c)
|
||||
#Sources += $(wildcard ../../LibMultiSpacc/SDLCom/*.c ../../LibMultiSpacc/SDL20/*.c)
|
||||
BuildProcess = Normal
|
||||
else ifeq ($(MultiSpacc_Target), NDS)
|
||||
Defines += -DMultiSpacc_Target_NDS
|
||||
@ -56,12 +57,14 @@ NDS:
|
||||
cp ../NDS.mk $(VirtualBuildDir)/Makefile
|
||||
cp $(Sources) $(VirtualBuildDir)/source/
|
||||
cp $(wildcard ../../LibMultiSpacc/*.*) $(VirtualBuildDir)/source/.tmp/
|
||||
cd $(VirtualBuildDir)/source/.tmp; for i in *; do mv $$i ../LibMultiSpacc_$$i; done
|
||||
cp $(wildcard ../../LibMultiSpacc/NDS/*.*) $(VirtualBuildDir)/source/.tmp/
|
||||
cd $(VirtualBuildDir)/source/.tmp; for i in *; do mv $$i ../LibMultiSpacc_NDS_$$i; done
|
||||
# rm of the last file is temporary fix for a strange file duplication bug
|
||||
cd $(VirtualBuildDir)/source/.tmp; for i in *; do mv $$i ../LibMultiSpacc_$$i; done; rm ../MultiSpacc.c #
|
||||
#cp $(wildcard ../../LibMultiSpacc/NDS/*.*) $(VirtualBuildDir)/source/.tmp/
|
||||
#cd $(VirtualBuildDir)/source/.tmp; for i in *; do mv $$i ../LibMultiSpacc_NDS_$$i; done
|
||||
for i in $(VirtualBuildDir)/source/*; do sed -i 's|#include[ \t]"../../LibMultiSpacc/|#include "LibMultiSpacc_|g' $$i; done
|
||||
for i in $(VirtualBuildDir)/source/*; do sed -i 's|#include[ \t]"../MultiSpacc|#include "LibMultiSpacc_MultiSpacc|g' $$i; done
|
||||
for i in $(VirtualBuildDir)/source/*; do sed -i 's|#include[ \t]"NDS/|#include "LibMultiSpacc_NDS_|g' $$i; done
|
||||
for i in $(VirtualBuildDir)/source/*; do sed -i 's|#include[ \t]"./|#include "./LibMultiSpacc_|g' $$i; done
|
||||
cd $(VirtualBuildDir); make
|
||||
|
||||
Run run: All
|
||||
|
@ -1,3 +1,6 @@
|
||||
# This Makefile is borrowed from devkitPro's nds-examples
|
||||
# <https://github.com/devkitPro/nds-examples>
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -39,23 +42,22 @@ LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lnds9
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBNDS)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
@ -63,7 +65,7 @@ CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin)))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -80,46 +82,44 @@ endif
|
||||
|
||||
export OFILES := $(BINFILES:.bin=.o) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).ds.gba
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
||||
|
154
LibMultiSpacc/LibMultiSpacc/MultiSpacc.c
Normal file
154
LibMultiSpacc/LibMultiSpacc/MultiSpacc.c
Normal file
@ -0,0 +1,154 @@
|
||||
#include "./MultiSpacc.h"
|
||||
|
||||
#ifdef MultiSpacc_Target_SDL12
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig ) {
|
||||
return SDL_SetVideoMode( WindowConfig.Width, WindowConfig.Height, WindowConfig.Bits, WindowConfig.Flags );
|
||||
}
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) {
|
||||
return Window;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char *Title ) {
|
||||
SDL_WM_SetCaption( Title, NULL );
|
||||
}
|
||||
void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon ) {
|
||||
SDL_WM_SetIcon( Icon, NULL );
|
||||
}
|
||||
|
||||
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) {
|
||||
if( Flag )
|
||||
return SDL_SetColorKey( Surface, SDL_SRCCOLORKEY, Key );
|
||||
else
|
||||
return SDL_SetColorKey( Surface, 0, Key );
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_SDL20
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig ) {
|
||||
return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WindowConfig.Width, WindowConfig.Height, WindowConfig.Flags );
|
||||
}
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) {
|
||||
return SDL_GetWindowSurface( Window );
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ) {
|
||||
SDL_SetWindowTitle( Window, Title );
|
||||
}
|
||||
void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon ) {
|
||||
SDL_SetWindowIcon( Window, Icon );
|
||||
}
|
||||
|
||||
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) {
|
||||
if ( Flag ) {
|
||||
return SDL_SetColorKey( Surface, SDL_TRUE, Key );
|
||||
} else {
|
||||
return SDL_SetColorKey( Surface, SDL_FALSE, Key );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_SDLCom
|
||||
int MultiSpacc_PollEvent( MultiSpacc_Event *Event )
|
||||
{
|
||||
SDL_Event FromEvent;
|
||||
int Result = SDL_PollEvent( &FromEvent );
|
||||
*Event = (MultiSpacc_Event) {
|
||||
.Type = FromEvent.type,
|
||||
.Key = FromEvent.key.keysym.sym,
|
||||
};
|
||||
return Result;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey )
|
||||
{
|
||||
MultiSpacc_Surface *Final = NULL;
|
||||
MultiSpacc_Surface *Raw = IMG_Load( FilePath );
|
||||
if( Raw == NULL ) {
|
||||
printf("[E] Error reading image %s.\n", FilePath);
|
||||
} else {
|
||||
Final = SDL_ConvertSurface( Raw, Screen->format, 0 );
|
||||
SDL_FreeSurface( Raw );
|
||||
if( Final == NULL ) {
|
||||
printf("[E] Error adapting image %s.\n", FilePath);
|
||||
} else {
|
||||
Uint32 FinalColorKey = SDL_MapRGB( Final->format, 0xFF, 0x00, 0xFF ); // Magenta
|
||||
if( ColorKey != NULL )
|
||||
FinalColorKey = *ColorKey;
|
||||
MultiSpacc_SetColorKey( Final, true, FinalColorKey );
|
||||
};
|
||||
};
|
||||
return Final;
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
for( int i = 0; i < strlen( Text ); i++ )
|
||||
{
|
||||
MultiSpacc_Rect Offset = {
|
||||
.x = (x * 8) + (8 * i),
|
||||
.y = (y * 8),
|
||||
};
|
||||
MultiSpacc_Rect Clip = {
|
||||
.x = 8 * (Text[i] % 16),
|
||||
.y = 8 * (Text[i] / 16),
|
||||
.w = 8,
|
||||
.h = 8,
|
||||
};
|
||||
SDL_BlitSurface( Tiles, &Clip, Surface, &Offset );
|
||||
};
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintDebug( const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
fprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_NDS
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig )
|
||||
{
|
||||
PrintConsole *bottomScreen = NULL;
|
||||
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
bottomScreen = consoleInit(bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
consoleSelect(bottomScreen);
|
||||
return bottomScreen;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
return Window;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ){}
|
||||
void MultiSpacc_PrintDebug( const char *format, ... ){}
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
iprintf(Text);
|
||||
}
|
||||
|
||||
void MultiSpacc_Sleep( int milliseconds )
|
||||
{
|
||||
int frames = (60 * milliseconds / 1000);
|
||||
for (int i=0; i<frames; i++)
|
||||
{
|
||||
swiWaitForVBlank();
|
||||
};
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey )
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
#endif
|
@ -6,17 +6,49 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef MultiSpacc_Target_SDL12
|
||||
#include "SDL12/SDL.h"
|
||||
#include "SDLCom/SDL.h"
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <SDL/SDL_mixer.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
#define MultiSpacc_Window SDL_Surface
|
||||
#define MultiSpacc_UpdateWindowSurface SDL_Flip
|
||||
typedef struct MultiSpacc_Event {
|
||||
Uint32 Type;
|
||||
SDLKey Key;
|
||||
} MultiSpacc_Event;
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_SDL20
|
||||
#include "SDL20/SDL.h"
|
||||
#include "SDLCom/SDL.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#define MultiSpacc_Window SDL_Window
|
||||
#define MultiSpacc_UpdateWindowSurface SDL_UpdateWindowSurface
|
||||
typedef struct MultiSpacc_Event {
|
||||
Uint32 Type;
|
||||
SDL_Keycode Key;
|
||||
} MultiSpacc_Event;
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_SDLCom
|
||||
#define MultiSpacc_Init SDL_Init
|
||||
#define MultiSpacc_Surface SDL_Surface
|
||||
#define MultiSpacc_GetTicks SDL_GetTicks
|
||||
#define MultiSpacc_Sleep SDL_Delay
|
||||
#define MultiSpacc_Rect SDL_Rect
|
||||
#endif
|
||||
|
||||
#ifdef MultiSpacc_Target_NDS
|
||||
#include "NDS/NDS.h"
|
||||
#include <nds.h>
|
||||
#define Uint32 int32
|
||||
#define MultiSpacc_Surface PrintConsole
|
||||
#define MultiSpacc_Window PrintConsole
|
||||
typedef struct MultiSpacc_Event {
|
||||
int Keys;
|
||||
} MultiSpacc_Event;
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window );
|
||||
void MultiSpacc_Sleep( int milliseconds );
|
||||
#endif
|
||||
|
||||
typedef struct MultiSpacc_SurfaceConfig {
|
||||
|
@ -1,40 +0,0 @@
|
||||
#include "../MultiSpacc.h"
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig )
|
||||
{
|
||||
PrintConsole *bottomScreen = NULL;
|
||||
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
bottomScreen = consoleInit(bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
consoleSelect(bottomScreen);
|
||||
return bottomScreen;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
return Window;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ){}
|
||||
void MultiSpacc_PrintDebug( const char *format, ... ){}
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
iprintf(Text);
|
||||
}
|
||||
|
||||
void MultiSpacc_Sleep( int milliseconds )
|
||||
{
|
||||
int frames = (60 * milliseconds / 1000);
|
||||
for (int i=0; i<frames; i++)
|
||||
{
|
||||
swiWaitForVBlank();
|
||||
};
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MultiSpacc_Target_NDS
|
||||
#define MultiSpacc_Target_NDS
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include <nds.h>
|
||||
|
||||
#define Uint32 int32
|
||||
#define MultiSpacc_Surface PrintConsole
|
||||
#define MultiSpacc_Window PrintConsole
|
||||
|
||||
typedef struct MultiSpacc_Event {
|
||||
int Keys;
|
||||
} MultiSpacc_Event;
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window );
|
||||
|
||||
void MultiSpacc_Sleep( int milliseconds );
|
@ -1,27 +0,0 @@
|
||||
#include "../MultiSpacc.h"
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_image.h"
|
||||
#include "SDL/SDL_mixer.h"
|
||||
#include "SDL/SDL_ttf.h"
|
||||
#include "../SDLCom/SDL.h"
|
||||
|
||||
MultiSpacc_Window MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig ) {
|
||||
return *SDL_SetVideoMode( WindowConfig.Width, WindowConfig.Height, WindowConfig.Bits, WindowConfig.Flags );
|
||||
}
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) {
|
||||
return Window;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char *Title ) {
|
||||
SDL_WM_SetCaption( Title, NULL );
|
||||
}
|
||||
void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon ) {
|
||||
SDL_WM_SetIcon( Icon, NULL );
|
||||
}
|
||||
|
||||
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) {
|
||||
if( Flag )
|
||||
return SDL_SetColorKey( Surface, SDL_SRCCOLORKEY, Key );
|
||||
else
|
||||
return SDL_SetColorKey( Surface, 0, Key );
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MultiSpacc_Target_SDL12
|
||||
#define MultiSpacc_Target_SDL12
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <SDL/SDL_mixer.h>
|
||||
#include <SDL/SDL_ttf.h>
|
||||
|
||||
#define MultiSpacc_Window SDL_Surface
|
||||
#define MultiSpacc_UpdateWindowSurface SDL_Flip
|
||||
|
||||
typedef struct MultiSpacc_Event {
|
||||
Uint32 Type;
|
||||
SDLKey Key;
|
||||
} MultiSpacc_Event;
|
@ -1,27 +0,0 @@
|
||||
#include "../MultiSpacc.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#include "SDL2/SDL_image.h"
|
||||
#include "SDL2/SDL_mixer.h"
|
||||
#include "SDL2/SDL_ttf.h"
|
||||
#include "../SDLCom/SDL.h"
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig ) {
|
||||
return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WindowConfig.Width, WindowConfig.Height, WindowConfig.Flags );
|
||||
}
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) {
|
||||
return SDL_GetWindowSurface( Window );
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ) {
|
||||
SDL_SetWindowTitle( Window, Title );
|
||||
}
|
||||
void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon ) {
|
||||
SDL_SetWindowIcon( Window, Icon );
|
||||
}
|
||||
|
||||
int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) {
|
||||
if ( Flag )
|
||||
return SDL_SetColorKey( Surface, SDL_TRUE, Key );
|
||||
else
|
||||
return SDL_SetColorKey( Surface, SDL_FALSE, Key );
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MultiSpacc_Target_SDL20
|
||||
#define MultiSpacc_Target_SDL20
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
#define MultiSpacc_Window SDL_Window
|
||||
#define MultiSpacc_UpdateWindowSurface SDL_UpdateWindowSurface
|
||||
|
||||
typedef struct MultiSpacc_Event {
|
||||
Uint32 Type;
|
||||
SDL_Keycode Key;
|
||||
} MultiSpacc_Event;
|
@ -1,59 +0,0 @@
|
||||
#include "../MultiSpacc.h"
|
||||
|
||||
int MultiSpacc_PollEvent( MultiSpacc_Event *Event )
|
||||
{
|
||||
SDL_Event FromEvent;
|
||||
int Result = SDL_PollEvent( &FromEvent );
|
||||
*Event = (MultiSpacc_Event) {
|
||||
.Type = FromEvent.type,
|
||||
.Key = FromEvent.key.keysym.sym,
|
||||
};
|
||||
return Result;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey )
|
||||
{
|
||||
MultiSpacc_Surface *Final = NULL;
|
||||
MultiSpacc_Surface *Raw = IMG_Load( FilePath );
|
||||
if( Raw == NULL ) {
|
||||
printf("[E] Error reading image %s.\n", FilePath);
|
||||
} else {
|
||||
Final = SDL_ConvertSurface( Raw, Screen->format, 0 );
|
||||
SDL_FreeSurface( Raw );
|
||||
if( Final == NULL ) {
|
||||
printf("[E] Error adapting image %s.\n", FilePath);
|
||||
} else {
|
||||
Uint32 FinalColorKey = SDL_MapRGB( Final->format, 0xFF, 0x00, 0xFF ); // Magenta
|
||||
if( ColorKey != NULL )
|
||||
FinalColorKey = *ColorKey;
|
||||
MultiSpacc_SetColorKey( Final, true, FinalColorKey );
|
||||
};
|
||||
};
|
||||
return Final;
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
for( int i = 0; i < strlen( Text ); i++ )
|
||||
{
|
||||
MultiSpacc_Rect Offset = {
|
||||
.x = (x * 8) + (8 * i),
|
||||
.y = (y * 8),
|
||||
};
|
||||
MultiSpacc_Rect Clip = {
|
||||
.x = 8 * (Text[i] % 16),
|
||||
.y = 8 * (Text[i] / 16),
|
||||
.w = 8,
|
||||
.h = 8,
|
||||
};
|
||||
SDL_BlitSurface( Tiles, &Clip, Surface, &Offset );
|
||||
};
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintDebug( const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
fprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
|
||||
#define MultiSpacc_Init SDL_Init
|
||||
#define MultiSpacc_Surface SDL_Surface
|
||||
#define MultiSpacc_GetTicks SDL_GetTicks
|
||||
#define MultiSpacc_Sleep SDL_Delay
|
||||
#define MultiSpacc_Rect SDL_Rect
|
Loading…
x
Reference in New Issue
Block a user