mirror of
https://gitlab.com/octospacc/MultiSpaccSDK
synced 2025-06-05 22:09:21 +02:00
Upd. Makefile and CI, add keypad reading to example, improve lib internals
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
AppName = $(notdir ${CURDIR})
|
||||
AppName = $(notdir $(CURDIR))
|
||||
AppAssets = CHARS.png
|
||||
AppSources = $(wildcard *.c)
|
||||
AppHeaders = $(wildcard *.h)
|
||||
SpaccSources = $(wildcard ../../LibMultiSpacc/*.c)
|
||||
@ -21,8 +22,6 @@ ifndef Target
|
||||
endif
|
||||
endif
|
||||
|
||||
# TODO: handle building for Windows targets from Linux hosts
|
||||
|
||||
ifeq ($(Target), LinuxPC)
|
||||
ExeSuffix = .run
|
||||
Defines += -DTarget_LinuxPC
|
||||
@ -45,6 +44,7 @@ else ifeq ($(Target), Windows9x)
|
||||
else
|
||||
ToolsSyspath = /opt/Sdk/mingw32/bin
|
||||
ToolsWrapper = wine
|
||||
LdFlags += -LZ:/opt/Sdk/mingw32/lib
|
||||
endif
|
||||
ToolsPrefix = $(ToolsSyspath)/
|
||||
else ifeq ($(Target), Web)
|
||||
@ -70,6 +70,7 @@ else ifeq ($(MultiSpacc_Target), SDL20)
|
||||
BuildProcess = __Normal__
|
||||
else ifeq ($(MultiSpacc_Target), Web)
|
||||
Defines += -DMultiSpacc_Target_Web -DMultiSpacc_Target_SDL20 -DMultiSpacc_Target_SDLCom
|
||||
LdFlags += -sWASM=1 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='["png"]' -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2
|
||||
BuildProcess = __Web__
|
||||
else ifeq ($(MultiSpacc_Target), NDS)
|
||||
Defines += -DMultiSpacc_Target_NDS
|
||||
@ -93,8 +94,9 @@ __Normal__: $(BuildObjects)
|
||||
$(CC) $^ $(LdFlags) -o $(AppName)$(ExeSuffix)
|
||||
|
||||
__Web__:
|
||||
emcc $(BuildSources) -sWASM=1 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='["png"]' -sUSE_SDL_TTF=2 -sUSE_SDL_MIXER=2 --preload-file Emscripten -o Emscripten.js
|
||||
cp ../Emscripten.html ./$(AppName.html)
|
||||
mkdir -p ./Build/Web
|
||||
emcc $(BuildSources) $(CFlags) $(Defines) $(LdFlags) --preload-file $(AppAssets) -o ./Build/Web/Emscripten.js
|
||||
cp ../Emscripten.html ./Build/Web/$(AppName).html
|
||||
# TODO: bundle JS, WASM, and assets package in HTML file
|
||||
|
||||
# TODO: Fix include substitutions properly in non-standard build processes
|
||||
|
@ -10,11 +10,13 @@ typedef struct MainArgs {
|
||||
MultiSpacc_SurfaceConfig *WindowConfig;
|
||||
MultiSpacc_Window *Window;
|
||||
MultiSpacc_Surface *Screen;
|
||||
MultiSpacc_Surface *Background;
|
||||
MultiSpacc_Surface *Foreground;
|
||||
MultiSpacc_Surface *TilesImg;
|
||||
} MainArgs;
|
||||
|
||||
/*{pal:"nes",layout:"nes"}*/
|
||||
const char PALETTE[32] = {
|
||||
const char palette[32] = {
|
||||
0x03, // screen
|
||||
0x11,0x30,0x27,0x00, // background 0
|
||||
0x1c,0x20,0x2c,0x00, // background 1
|
||||
@ -33,6 +35,7 @@ bool MainLoop( void *args )
|
||||
MainArgs *margs = (MainArgs*)args;
|
||||
|
||||
MultiSpacc_Sprite( 0, margs->spriteX, margs->spriteY, 1, margs->TilesImg, margs->Screen );
|
||||
// ... this must go on Foreground
|
||||
//scroll(spriteX,0);
|
||||
|
||||
margs->spriteX += margs->accelX;
|
||||
@ -42,21 +45,25 @@ bool MainLoop( void *args )
|
||||
{
|
||||
margs->spriteX = 0;
|
||||
}
|
||||
|
||||
if( margs->spriteY == 0 || margs->spriteY == ( margs->WindowConfig->Height - 8 ) )
|
||||
{
|
||||
margs->accelY *= -1;
|
||||
}
|
||||
|
||||
// check keys
|
||||
// if ESC pressed exit
|
||||
// ...
|
||||
/* TODO: listen for OS terminate signal */
|
||||
if( MultiSpacc_CheckKey( MultiSpacc_Key_Pause, 0 ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !MultiSpacc_WaitUpdateDisplay( margs->Window, &nextTick ) )
|
||||
{
|
||||
MultiSpacc_PrintDebug("[E] Error Updating Screen.\n");
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// apply Background and then Foreground on Screen
|
||||
// ...
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -73,12 +80,11 @@ int main( int argc, char *argv[] )
|
||||
WindowConfig.Width = 320;
|
||||
WindowConfig.Height = 240;
|
||||
WindowConfig.Bits = 16;
|
||||
memcpy( WindowConfig.Palette, PALETTE, 32 );
|
||||
memcpy( WindowConfig.Palette, palette, 32 );
|
||||
//WindowConfig.Frequency = 50;
|
||||
|
||||
margs.Window = MultiSpacc_SetWindow( &WindowConfig );
|
||||
margs.Screen = MultiSpacc_GetWindowSurface( margs.Window );
|
||||
|
||||
if( margs.Screen == NULL )
|
||||
{
|
||||
MultiSpacc_PrintDebug("[E] Error Initializing Video System.\n");
|
||||
@ -91,7 +97,13 @@ int main( int argc, char *argv[] )
|
||||
// Bitmap font borrowed from: <https://github.com/nesdoug/01_Hello/blob/master/Alpha.chr>
|
||||
// Copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT)
|
||||
margs.TilesImg = MultiSpacc_LoadImage( "CHARS.png", margs.Screen, NULL );
|
||||
if( margs.TilesImg == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
MultiSpacc_PrintText( "Hello, World!", margs.Screen, &WindowConfig, 2, 2, margs.TilesImg );
|
||||
// ... this must print on Background
|
||||
|
||||
return MultiSpacc_SetMainLoop( MainLoop, &margs );
|
||||
}
|
||||
|
Reference in New Issue
Block a user