mirror of
https://gitlab.com/octospacc/MultiSpaccSDK
synced 2025-03-01 10:17:53 +01:00
Windows build support (MSYS2); Initial NDS support
This commit is contained in:
parent
1c660aa6ec
commit
046f05aef4
@ -1,44 +1,60 @@
|
||||
AppName = $(notdir ${CURDIR})
|
||||
Sources = $(wildcard *.c ../../LibMultiSpacc/*.c)
|
||||
CFlags = -O2
|
||||
CC = gcc $(Defines)
|
||||
CFlags = -O2 -Wpedantic -Werror
|
||||
|
||||
ifndef Target
|
||||
Target = PC
|
||||
ifeq ($(shell uname --operating-system), Msys)
|
||||
Target = WindowsPC
|
||||
else
|
||||
Target = LinuxPC
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef Target
|
||||
ifeq ($(Target), PC)
|
||||
ifeq ($(Target), LinuxPC)
|
||||
ExeSuffix = .run
|
||||
Defines = -DTarget_PC
|
||||
Defines += -DTarget_LinuxPC
|
||||
MultiSpacc_Target = SDL20
|
||||
else ifeq ($(Target), WindowsPC)
|
||||
ExeSuffix = .exe
|
||||
Defines += -DTarget_WindowsPC
|
||||
MultiSpacc_Target = SDL20
|
||||
else ifeq ($(Target), NDS)
|
||||
Defines += -DTarget_NDS
|
||||
MultiSpacc_Target = NDS
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MultiSpacc_Target), SDL12)
|
||||
Defines += -DMultiSpacc_Target_SDL12
|
||||
LdFlags += -lSDL -lSDL_image -lSDL_mixer -lSDL_ttf
|
||||
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)
|
||||
else ifeq ($(MultiSpacc_Target), SDL20)
|
||||
Defines += -DMultiSpacc_Target_SDL20
|
||||
LdFlags += -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf
|
||||
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)
|
||||
else ifeq ($(MultiSpacc_Target), NDS)
|
||||
#include $(DEVKITARM)/ds_rules
|
||||
Defines += -DMultiSpacc_Target_NDS
|
||||
CFlags += -I$(DEVKITPRO)/libnds/include -DARM9
|
||||
Sources += $(wildcard ../../LibMultiSpacc/NDS/*.c)
|
||||
ToolsPrefix = $(DEVKITARM)/bin/arm-none-eabi-
|
||||
endif
|
||||
|
||||
CC = $(ToolsPrefix)gcc $(CFlags) $(Defines)
|
||||
Objects = $(Sources:.c=.o)
|
||||
|
||||
All: $(AppName)
|
||||
All all: $(AppName)
|
||||
|
||||
$(AppName): $(Objects)
|
||||
$(CC) $^ $(CFlags) $(LdFlags) -o $(AppName)$(ExeSuffix)
|
||||
$(CC) $^ $(LdFlags) -o $(AppName)$(ExeSuffix)
|
||||
|
||||
Run: All
|
||||
Run run: All
|
||||
./$(AppName)$(ExeSuffix)
|
||||
|
||||
Clean:
|
||||
Clean clean:
|
||||
find -L . -name "*.o" -type f -delete
|
||||
find -L ../../LibMultiSpacc -name "*.o" -type f -delete
|
||||
rm -f $(AppName)$(ExeSuffix) $(AppName).*$(ExeSuffix)
|
||||
|
||||
all: All
|
||||
run: Run
|
||||
clean: Clean
|
||||
|
BIN
LibMultiSpacc/Examples/HelloWorld/HelloWorld
Normal file
BIN
LibMultiSpacc/Examples/HelloWorld/HelloWorld
Normal file
Binary file not shown.
@ -1,18 +1,16 @@
|
||||
#include "../../LibMultiSpacc/MultiSpacc.h"
|
||||
|
||||
#define AppName "Hello World"
|
||||
#define ScreenWidth 320
|
||||
#define ScreenHeight 240
|
||||
#define ScreenBits 16
|
||||
|
||||
int main( int argc, char *args[] )
|
||||
{
|
||||
MultiSpacc_Window *Window = MultiSpacc_SetWindow( ScreenWidth, ScreenHeight, ScreenBits, 0 );
|
||||
MultiSpacc_SurfaceConfig WindowConfig = { .Width = 320, .Height = 240, .Bits = 16 };
|
||||
MultiSpacc_Window *Window = MultiSpacc_SetWindow( WindowConfig );
|
||||
MultiSpacc_Surface *Screen = MultiSpacc_GetWindowSurface( Window );
|
||||
|
||||
if( Screen == NULL )
|
||||
{
|
||||
printf("[E] Error initializing Video System.\n");
|
||||
printf("[E] Error Initializing Video System.\n");
|
||||
return -1;
|
||||
};
|
||||
|
||||
@ -22,28 +20,14 @@ int main( int argc, char *args[] )
|
||||
// Copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT)
|
||||
MultiSpacc_Surface *TilesImg = MultiSpacc_LoadImage( "Tiles.png", Screen, NULL );
|
||||
|
||||
/*char Text[] = "Hello, World!";
|
||||
for(int i = 0; i < sizeof( Text ); i++){
|
||||
MultiSpacc_Rect Offset = {
|
||||
.x = (8 * i) + (ScreenWidth / sizeof( Text )),
|
||||
.y = ScreenHeight / 3,
|
||||
};
|
||||
MultiSpacc_Rect Clip = {
|
||||
.x = 8 * (Text[i] % 16),
|
||||
.y = 8 * (Text[i] / 16),
|
||||
.w = 8,
|
||||
.h = 8,
|
||||
};
|
||||
SDL_BlitSurface( TilesImg, &Clip, Screen, &Offset );
|
||||
};*/
|
||||
MultiSpacc_PrintString( "Hello, World!", Screen, ScreenWidth, ScreenHeight, 4, 4, TilesImg );
|
||||
MultiSpacc_PrintText( "Hello, World!", Screen, WindowConfig.Width, WindowConfig.Height, 4, 4, TilesImg );
|
||||
|
||||
if( MultiSpacc_UpdateWindowSurface( Window ) != 0 )
|
||||
{
|
||||
printf("[E] Error updating Screen.\n");
|
||||
printf("[E] Error Updating Screen.\n");
|
||||
return -1;
|
||||
};
|
||||
|
||||
MultiSpacc_Sleep( 3000 );
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef MultiSpacc_Target_SDL12
|
||||
#include "SDL12/SDL.h"
|
||||
@ -12,7 +14,18 @@
|
||||
#include "SDLCom/SDL.h"
|
||||
#endif
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( int Width, int Height, int Bits, Uint32 Flags );
|
||||
#ifdef MultiSpacc_Target_NDS
|
||||
#include "NDS/NDS.h"
|
||||
#endif
|
||||
|
||||
typedef struct MultiSpacc_SurfaceConfig {
|
||||
int Width;
|
||||
int Height;
|
||||
int Bits;
|
||||
Uint32 Flags;
|
||||
} MultiSpacc_SurfaceConfig;
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig );
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window );
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] );
|
||||
@ -23,4 +36,4 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key )
|
||||
|
||||
int MultiSpacc_PollEvent( MultiSpacc_Event *Event );
|
||||
|
||||
void MultiSpacc_PrintString( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ); // WIP
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ); // WIP
|
||||
|
25
LibMultiSpacc/LibMultiSpacc/NDS/NDS.c
Normal file
25
LibMultiSpacc/LibMultiSpacc/NDS/NDS.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include "../MultiSpacc.h"
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig )
|
||||
{
|
||||
MultiSpacc_Window *wip;
|
||||
return wip;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
MultiSpacc_Surface *wip;
|
||||
return wip;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ){}
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
|
||||
}
|
19
LibMultiSpacc/LibMultiSpacc/NDS/NDS.h
Normal file
19
LibMultiSpacc/LibMultiSpacc/NDS/NDS.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MultiSpacc_Target_NDS
|
||||
#define MultiSpacc_Target_NDS
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include <nds.h>
|
||||
|
||||
#define Uint32 int32
|
||||
#define MultiSpacc_Window PrintConsole
|
||||
#define MultiSpacc_Surface PrintConsole
|
||||
#define MultiSpacc_Sleep {}
|
||||
|
||||
typedef struct MultiSpacc_Event {
|
||||
int Keys;
|
||||
} MultiSpacc_Event;
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window );
|
@ -5,8 +5,8 @@
|
||||
#include "SDL/SDL_ttf.h"
|
||||
#include "../SDLCom/SDL.h"
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( int Width, int Height, int Bits, Uint32 Flags ) {
|
||||
return SDL_SetVideoMode( Width, Height, Bits, Flags );
|
||||
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;
|
||||
@ -24,4 +24,4 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key )
|
||||
return SDL_SetColorKey( Surface, SDL_SRCCOLORKEY, Key );
|
||||
else
|
||||
return SDL_SetColorKey( Surface, 0, Key );
|
||||
};
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_image.h"
|
||||
#include "SDL/SDL_mixer.h"
|
||||
#include "SDL/SDL_ttf.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;
|
||||
Uint32 Type;
|
||||
SDLKey Key;
|
||||
} MultiSpacc_Event;
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "SDL2/SDL_ttf.h"
|
||||
#include "../SDLCom/SDL.h"
|
||||
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( int Width, int Height, int Bits, Uint32 Flags ) {
|
||||
return SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Width, Height, Flags);
|
||||
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 );
|
||||
@ -24,4 +24,4 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key )
|
||||
return SDL_SetColorKey( Surface, SDL_TRUE, Key );
|
||||
else
|
||||
return SDL_SetColorKey( Surface, SDL_FALSE, Key );
|
||||
};
|
||||
}
|
||||
|
@ -5,10 +5,10 @@
|
||||
#endif
|
||||
|
||||
#include "../MultiSpacc.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#include "SDL2/SDL_image.h"
|
||||
#include "SDL2/SDL_mixer.h"
|
||||
#include "SDL2/SDL_ttf.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
|
||||
|
@ -9,7 +9,7 @@ int MultiSpacc_PollEvent( MultiSpacc_Event *Event )
|
||||
.Key = FromEvent.key.keysym.sym,
|
||||
};
|
||||
return Result;
|
||||
};
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey )
|
||||
{
|
||||
@ -30,12 +30,11 @@ MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *S
|
||||
};
|
||||
};
|
||||
return Final;
|
||||
};
|
||||
}
|
||||
|
||||
void MultiSpacc_PrintString( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, int ScreenWidth, int ScreenHeight, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ )
|
||||
{
|
||||
for(int i = 0; i < strlen( Text ); i++)
|
||||
//while(*(Text++))
|
||||
for( int i = 0; i < strlen( Text ); i++ )
|
||||
{
|
||||
MultiSpacc_Rect Offset = {
|
||||
.x = (x * 8) + (8 * i),
|
||||
@ -49,4 +48,4 @@ void MultiSpacc_PrintString( char Text[], MultiSpacc_Surface *Surface, int Scree
|
||||
};
|
||||
SDL_BlitSurface( Tiles, &Clip, Surface, &Offset );
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user