diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a35e6d4..1d2fcab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ image: debian:latest before_script: | - sudo apt update - sudo apt install -y \ + apt update + apt install -y \ make gcc mingw-w64 wine wine32 cc65 emscripten curl p7zip-full python3 python3-pil \ libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev \ libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev \ @@ -10,9 +10,9 @@ before_script: | curl -o ./mingw32.7z https://hlb0.octt.eu.org/Drive/Misc/mingw32-9.2.0.7z.sfx.exe 7z x ./mingw32.7z cp ./mingw32/bin/*.dll ./mingw32/libexec/gcc/mingw32/9.2.0/ - sudo mv ./mingw32 /opt/Sdk/mingw32 - curl https://apt.devkitpro.org/install-devkitpro-pacman | sudo bash - sudo dkp-pacman -Sy nds-dev + mv ./mingw32 /opt/Sdk/mingw32 + curl https://apt.devkitpro.org/install-devkitpro-pacman | bash + dkp-pacman -Sy nds-dev Tests: stage: build diff --git a/LibMultiSpacc/Examples/CHARS.png b/LibMultiSpacc/Examples/CHARS.png new file mode 100644 index 0000000..f8eee0c Binary files /dev/null and b/LibMultiSpacc/Examples/CHARS.png differ diff --git a/LibMultiSpacc/Examples/Common.mk b/LibMultiSpacc/Examples/Common.mk index aaab7c7..76e3e86 100644 --- a/LibMultiSpacc/Examples/Common.mk +++ b/LibMultiSpacc/Examples/Common.mk @@ -1,5 +1,5 @@ AppName = $(notdir $(CURDIR)) -AppAssets = CHARS.png +AppAssets = ../CHARS.png AppSources = $(wildcard *.c) AppHeaders = $(wildcard *.h) SpaccSources = $(wildcard ../../LibMultiSpacc/*.c) @@ -125,7 +125,7 @@ __NES__: for i in $(VirtualBuildDir)/*.c $(VirtualBuildDir)/*.h; do sed -i 's|#include[ \t]"./|#include "LibMultiSpacc_|g' $$i; done cp ../../neslib/*.cfg ../../neslib/crt0.o ../../neslib/*.lib ../../neslib/*.h $(VirtualBuildDir)/ printf ".segment \"CHARS\"\n\t.incbin \"CHARS.chr\"" > $(VirtualBuildDir)/CHARS.s - echo "AppName='$(AppName)'; Defines='$(Defines)'; ProjectRoot=../..;" > $(VirtualBuildDir)/Make.sh + echo "ProjectRoot=../..; AppName='$(AppName)'; AppAssets='$(AppAssets)'; Defines='$(Defines)';" > $(VirtualBuildDir)/Make.sh cat ../NES.mk.sh >> $(VirtualBuildDir)/Make.sh cd $(VirtualBuildDir); sh ./Make.sh diff --git a/LibMultiSpacc/Examples/HelloWorld/CHARS.png b/LibMultiSpacc/Examples/HelloWorld/CHARS.png deleted file mode 100644 index d7b9c36..0000000 Binary files a/LibMultiSpacc/Examples/HelloWorld/CHARS.png and /dev/null differ diff --git a/LibMultiSpacc/Examples/HelloWorld/HelloWorld.c b/LibMultiSpacc/Examples/HelloWorld/HelloWorld.c index b0cd511..9a7429f 100644 --- a/LibMultiSpacc/Examples/HelloWorld/HelloWorld.c +++ b/LibMultiSpacc/Examples/HelloWorld/HelloWorld.c @@ -7,17 +7,17 @@ typedef struct MainArgs { int spriteY; int accelX; int accelY; - MultiSpacc_SurfaceConfig *WindowConfig; - MultiSpacc_Window *Window; - MultiSpacc_Surface *Screen; - MultiSpacc_Surface *Background; - MultiSpacc_Surface *Foreground; - MultiSpacc_Surface *TilesImg; + 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] = { - 0x03, // screen + 0x0F, // screen 0x11,0x30,0x27,0x00, // background 0 0x1c,0x20,0x2c,0x00, // background 1 0x00,0x10,0x20,0x00, // background 2 @@ -34,18 +34,20 @@ 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 + //SDL_FillRect(margs->Background, &rect, 0x000000); + MultiSpacc_BlitLayer( margs->background, margs->screen ); + //SDL_BlitSurface( margs->Foreground, &rect, margs->Screen, &rect ); + MultiSpacc_Sprite( 0, margs->spriteX, margs->spriteY, 1, margs->tilesImg, margs->screen ); //scroll(spriteX,0); margs->spriteX += margs->accelX; margs->spriteY += margs->accelY; - if( margs->spriteX >= margs->WindowConfig->Width ) + if( margs->spriteX >= margs->windowConfig->width ) { margs->spriteX = 0; } - if( margs->spriteY == 0 || margs->spriteY == ( margs->WindowConfig->Height - 8 ) ) + if( margs->spriteY == 0 || margs->spriteY == ( margs->windowConfig->height - 8 ) ) { margs->accelY *= -1; } @@ -56,54 +58,51 @@ bool MainLoop( void *args ) return false; } - if( !MultiSpacc_WaitUpdateDisplay( margs->Window, &nextTick ) ) + if( !MultiSpacc_WaitUpdateDisplay( margs->window, &nextTick ) ) { MultiSpacc_PrintDebug("[E] Error Updating Screen.\n"); return false; } - // apply Background and then Foreground on Screen - // ... - return true; } int main( int argc, char *argv[] ) { MainArgs margs = {0}; - MultiSpacc_SurfaceConfig WindowConfig = {0}; + MultiSpacc_SurfaceConfig windowConfig = {0}; - margs.WindowConfig = &WindowConfig; - margs.accelX = +1; + margs.windowConfig = &windowConfig; + margs.accelX = +2; margs.accelY = +2; - WindowConfig.Width = 320; - WindowConfig.Height = 240; - WindowConfig.Bits = 16; - memcpy( WindowConfig.Palette, palette, 32 ); - //WindowConfig.Frequency = 50; + windowConfig.width = 320; + windowConfig.height = 240; + windowConfig.bits = 16; + memcpy( windowConfig.palette, palette, 32 ); - margs.Window = MultiSpacc_SetWindow( &WindowConfig ); - margs.Screen = MultiSpacc_GetWindowSurface( margs.Window ); - if( margs.Screen == NULL ) + margs.window = MultiSpacc_SetWindow( &windowConfig ); + margs.screen = MultiSpacc_GetWindowSurface( margs.window ); + margs.background = MultiSpacc_CreateSurface( &windowConfig ); + //margs.Foreground = MultiSpacc_CreateSurface( &windowConfig ); + if( margs.screen == NULL || margs.background == NULL /*|| margs.Foreground == NULL*/ ) { MultiSpacc_PrintDebug("[E] Error Initializing Video System.\n"); return -1; }; - MultiSpacc_SetAppTitle( margs.Window, AppName ); + MultiSpacc_SetAppTitle( margs.window, AppName ); MultiSpacc_PrintDebug("[I] Ready!\n"); - // Bitmap font borrowed from: - // Copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT) - margs.TilesImg = MultiSpacc_LoadImage( "CHARS.png", margs.Screen, NULL ); - if( margs.TilesImg == NULL ) + // Bitmap font forked from: + // Original 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 + MultiSpacc_PrintText( "Hello, World!", margs.background, &windowConfig, 2, 2, margs.tilesImg ); return MultiSpacc_SetMainLoop( MainLoop, &margs ); } diff --git a/LibMultiSpacc/Examples/NES.mk.sh b/LibMultiSpacc/Examples/NES.mk.sh index fbe8112..7041ecf 100644 --- a/LibMultiSpacc/Examples/NES.mk.sh +++ b/LibMultiSpacc/Examples/NES.mk.sh @@ -2,7 +2,10 @@ set -e SdkRoot="${ProjectRoot}/../../.." -sh "${SdkRoot}/Tools/python3.sh" "${SdkRoot}/Tools/pilbmp2nes.py" -i "${ProjectRoot}/CHARS.png" -o ./CHARS.chr +# TODO: multiple files +for File in ${AppAssets} +do sh "${SdkRoot}/Tools/python3.sh" "${SdkRoot}/Tools/pilbmp2nes.py" -i "${ProjectRoot}/${File}" -o ./CHARS.chr +done for File in *.c do cc65 -Oirs --target nes ${File} ${Defines} diff --git a/LibMultiSpacc/Examples/Pong/Makefile b/LibMultiSpacc/Examples/Pong/Makefile new file mode 100644 index 0000000..636699b --- /dev/null +++ b/LibMultiSpacc/Examples/Pong/Makefile @@ -0,0 +1 @@ +include ../Common.mk \ No newline at end of file diff --git a/LibMultiSpacc/Examples/Pong/Pong.c b/LibMultiSpacc/Examples/Pong/Pong.c new file mode 100644 index 0000000..3febfa7 --- /dev/null +++ b/LibMultiSpacc/Examples/Pong/Pong.c @@ -0,0 +1,128 @@ +#include "../../LibMultiSpacc/MultiSpacc.h" + +#define AppName "Pong" + +bool paused = false; +Uint32 nextTick; + +int ballX; +int ballY; +int accelX = 2; +int accelY = 2; + +// the Y position of the paddles, measured from the top +int paddleSx; +int paddleDx; + +MultiSpacc_SurfaceConfig windowConfig = {0}; +MultiSpacc_Window *window; +MultiSpacc_Surface *screen; +MultiSpacc_Surface *background; +MultiSpacc_Surface *tilesImg; + +#define BallSize 8 + +#define TileBall 128 +#define TilePaddle 129 + +#define SpriteBall 0 +#define SpritePaddleSx 1 +#define SpritePaddleDx 1+4 + +/*{pal:"nes",layout:"nes"}*/ +const char palette[32] = { + 0x0F, // screen + 0x11,0x30,0x27,0x00, // background 0 + 0x1c,0x20,0x2c,0x00, // background 1 + 0x00,0x10,0x20,0x00, // background 2 + 0x06,0x16,0x26,0x00, // background 3 + 0x16,0x35,0x24,0x00, // sprite 0 + 0x00,0x37,0x25,0x00, // sprite 1 + 0x0d,0x2d,0x3a,0x00, // sprite 2 + 0x0d,0x27,0x2a, // sprite 3 +}; + +bool MainLoop( void *args ) +{ + if (!paused) + { + MultiSpacc_BlitLayer( background, screen ); + + MultiSpacc_Sprite( SpriteBall, ballX, ballY, TileBall, tilesImg, screen ); + + // TODO: metasprites + + MultiSpacc_Sprite( SpritePaddleSx , BallSize, paddleSx , TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleSx+1, BallSize, paddleSx + BallSize, TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleSx+2, BallSize, paddleSx + 2*BallSize, TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleSx+3, BallSize, paddleSx + 3*BallSize, TilePaddle, tilesImg, screen ); + + MultiSpacc_Sprite( SpritePaddleDx , windowConfig.width - 2*BallSize, paddleDx , TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleDx+1, windowConfig.width - 2*BallSize, paddleDx + BallSize, TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleDx+2, windowConfig.width - 2*BallSize, paddleDx + 2*BallSize, TilePaddle, tilesImg, screen ); + MultiSpacc_Sprite( SpritePaddleDx+3, windowConfig.width - 2*BallSize, paddleDx + 3*BallSize, TilePaddle, tilesImg, screen ); + + ballX += accelX; + ballY += accelY; + + if( ballX == 0 || ballX == ( windowConfig.width - 8 ) ) + { + accelX *= -1; + } + + if( ballY == 0 || ballY == ( windowConfig.height - 8 ) ) + { + accelY *= -1; + } + } + + /* TODO: listen for OS terminate signal */ + if( MultiSpacc_CheckKey( MultiSpacc_Key_Pause, 0 ) ) + { + if (!paused) paused = true; + else return false; + } + + if( !MultiSpacc_WaitUpdateDisplay( window, &nextTick ) ) + { + MultiSpacc_PrintDebug("[E] Error Updating Screen.\n"); + return false; + } + + return true; +} + +int main( int argc, char *argv[] ) +{ + windowConfig.width = 320; + windowConfig.height = 240; + windowConfig.bits = 16; + memcpy( windowConfig.palette, palette, 32 ); + + window = MultiSpacc_SetWindow( &windowConfig ); + screen = MultiSpacc_GetWindowSurface( window ); + background = MultiSpacc_CreateSurface( &windowConfig ); + if( window == NULL || screen == NULL || background == NULL ) + { + MultiSpacc_PrintDebug("[E] Error Initializing Video System.\n"); + return -1; + }; + + MultiSpacc_SetAppTitle( window, AppName ); + MultiSpacc_PrintDebug("[I] Ready!\n"); + + // Bitmap font forked from: + // Original copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT) + tilesImg = MultiSpacc_LoadImage( "../CHARS.png", screen, NULL ); + if( tilesImg == NULL ) + { + return -1; + } + + ballX = windowConfig.width/2; + ballY = windowConfig.height/2; + paddleSx = windowConfig.height/2 - 24; + paddleDx = windowConfig.height/2 - 24; + + return MultiSpacc_SetMainLoop( MainLoop, NULL ); +} diff --git a/LibMultiSpacc/LibMultiSpacc/MultiSpacc.c b/LibMultiSpacc/LibMultiSpacc/MultiSpacc.c index fd7acd8..273fd58 100644 --- a/LibMultiSpacc/LibMultiSpacc/MultiSpacc.c +++ b/LibMultiSpacc/LibMultiSpacc/MultiSpacc.c @@ -1,21 +1,33 @@ #include "./MultiSpacc.h" +MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) +{ + #if defined(MultiSpacc_Target_SDL12) + return Window; + #elif defined(MultiSpacc_Target_SDL20) + return SDL_GetWindowSurface(Window); + #elif defined(MultiSpacc_Target_NDS) + return Window; + #endif +} + MultiSpacc_Surface *MultiSpacc_LoadImage( char FilePath[], MultiSpacc_Surface *Screen, Uint32 *ColorKey ) { #ifdef MultiSpacc_Target_SDLCom MultiSpacc_Surface *Final = NULL; - MultiSpacc_Surface *Raw = IMG_Load( FilePath ); + MultiSpacc_Surface *Raw = IMG_Load(FilePath); if( Raw == NULL ) { - MultiSpacc_PrintDebug("[E] Error Reading Image %s.\n", FilePath); + MultiSpacc_PrintDebug( "[E] Error Reading Image %s.\n", FilePath ); } else { Final = SDL_ConvertSurface( Raw, Screen->format, 0 ); - SDL_FreeSurface( Raw ); + SDL_FreeSurface(Raw); if( Final == NULL ) { - MultiSpacc_PrintDebug("[E] Error Adapting Image %s.\n", FilePath); + MultiSpacc_PrintDebug( "[E] Error Adapting Image %s.\n", FilePath ); } else { Uint32 FinalColorKey = SDL_MapRGB( Final->format, 0xFF, 0x00, 0xFF ); // Magenta - if( ColorKey != NULL ) + if( ColorKey != NULL ){ FinalColorKey = *ColorKey; + } MultiSpacc_SetColorKey( Final, true, FinalColorKey ); }; }; @@ -80,9 +92,9 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) } #endif -void MultiSpacc_Sprite( int id, int x, int y, int sprite, MultiSpacc_Surface *Tiles, MultiSpacc_Surface *Surface ) +void MultiSpacc_Sprite( int id, int x, int y, int sprite, MultiSpacc_Surface *Tiles, MultiSpacc_Surface *surface ) { - #ifdef MultiSpacc_Target_SDLCom + #if defined(MultiSpacc_Target_SDLCom) MultiSpacc_Rect Offset = { .x = x, .y = y, }; MultiSpacc_Rect Clip = { .x = (8 * (sprite % 16)), @@ -90,10 +102,22 @@ void MultiSpacc_Sprite( int id, int x, int y, int sprite, MultiSpacc_Surface *Ti .w = 8, .h = 8, }; - SDL_BlitSurface( Tiles, &Clip, Surface, &Offset ); - #endif - - #ifdef MultiSpacc_Target_NES + SDL_BlitSurface( Tiles, &Clip, surface, &Offset ); + #elif defined(MultiSpacc_Target_NES) oam_spr(x, y, sprite, 0, id); #endif } + +void MultiSpacc_BlitLayer( MultiSpacc_Surface *source, MultiSpacc_Surface *destination ) +{ + #if defined(MultiSpacc_Target_SDLCom) + SDL_BlitSurface( source, NULL, destination, NULL ); + #endif +} + +MultiSpacc_Surface *MultiSpacc_CreateSurface( MultiSpacc_SurfaceConfig *surfaceConfig ) +{ + #if defined(MultiSpacc_Target_SDLCom) + return SDL_CreateRGBSurface( 0, surfaceConfig->width, surfaceConfig->height, surfaceConfig->bits, 0, 0, 0, 0 ); + #endif +} diff --git a/LibMultiSpacc/LibMultiSpacc/MultiSpacc.h b/LibMultiSpacc/LibMultiSpacc/MultiSpacc.h index 9e01cc2..e422ee1 100644 --- a/LibMultiSpacc/LibMultiSpacc/MultiSpacc.h +++ b/LibMultiSpacc/LibMultiSpacc/MultiSpacc.h @@ -84,14 +84,14 @@ #endif typedef struct MultiSpacc_SurfaceConfig { - int Width; - int Height; - int Bits; - char Palette[32]; - Uint32 Flags; + int width; + int height; + int bits; + char palette[32]; + Uint32 flags; } MultiSpacc_SurfaceConfig; -MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *WindowConfig ); +MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *windowConfig ); MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ); void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ); @@ -107,9 +107,12 @@ int MultiSpacc_SetColorKey( MultiSpacc_Surface *Surface, bool Flag, Uint32 Key ) int MultiSpacc_PollEvent( MultiSpacc_Event *Event ); void MultiSpacc_PrintDebug( const char *format, ... ); -void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig *WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ); // WIP +void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig *surfaceConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ); // WIP -void MultiSpacc_Sprite( int id, int x, int y, int sprite, MultiSpacc_Surface *Tiles, MultiSpacc_Surface *Surface ); +void MultiSpacc_Sprite( int id, int x, int y, int sprite, MultiSpacc_Surface *Tiles, MultiSpacc_Surface *surface ); + +MultiSpacc_Surface *MultiSpacc_CreateSurface( MultiSpacc_SurfaceConfig *surfaceConfig ); +void MultiSpacc_BlitLayer( MultiSpacc_Surface *source, MultiSpacc_Surface *destination ); #include "./Keys.h" diff --git a/LibMultiSpacc/LibMultiSpacc/Print.c b/LibMultiSpacc/LibMultiSpacc/Print.c index 58cea18..a238d0e 100644 --- a/LibMultiSpacc/LibMultiSpacc/Print.c +++ b/LibMultiSpacc/LibMultiSpacc/Print.c @@ -1,9 +1,9 @@ #include "./MultiSpacc.h" -void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig *WindowConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ) +void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_SurfaceConfig *surfaceConfig, int x, int y, MultiSpacc_Surface *Tiles /*, int FontSize, int Color */ ) { #ifdef MultiSpacc_Target_SDLCom - /* TODO: not just 8x8 tiles */ + /* TODO: not just 8x8 tiles, and account for surface dimensions */ for( int i = 0; i < strlen(Text); i++ ) { MultiSpacc_Rect Offset = { @@ -37,7 +37,7 @@ void MultiSpacc_PrintDebug( const char *format, ... ) #ifdef MultiSpacc_Target_SDLCom va_list args; va_start( args, format ); - fprintf( stderr, format, args ); - va_end( args ); + SDL_Log( format, args ); + va_end(args); #endif } diff --git a/LibMultiSpacc/LibMultiSpacc/Setup.c b/LibMultiSpacc/LibMultiSpacc/Setup.c index bf047fe..32e056b 100644 --- a/LibMultiSpacc/LibMultiSpacc/Setup.c +++ b/LibMultiSpacc/LibMultiSpacc/Setup.c @@ -1,48 +1,5 @@ #include "./MultiSpacc.h" -MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *WindowConfig ) -{ - #ifdef MultiSpacc_Target_SDL12 - return SDL_SetVideoMode( WindowConfig->Width, WindowConfig->Height, WindowConfig->Bits, WindowConfig->Flags ); - #endif - - #ifdef MultiSpacc_Target_SDL20 - return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WindowConfig->Width, WindowConfig->Height, WindowConfig->Flags ); - #endif - - #ifdef MultiSpacc_Target_NDS - 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; - #endif - - #ifdef MultiSpacc_Target_NES - WindowConfig->Width = 256; - WindowConfig->Height = 240; - oam_clear(); - pal_all(WindowConfig->Palette); - ppu_on_all(); - #endif -} - -MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window ) -{ - #ifdef MultiSpacc_Target_SDL12 - return Window; - #endif - #ifdef MultiSpacc_Target_SDL20 - return SDL_GetWindowSurface(Window); - #endif - #ifdef MultiSpacc_Target_NDS - return Window; - #endif -} - bool MultiSpacc_SetMainLoop( bool function( void *args ), void *args ) { #ifdef MultiSpacc_Target_Web @@ -59,20 +16,18 @@ bool MultiSpacc_SetMainLoop( bool function( void *args ), void *args ) void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char *Title ) { - #ifdef MultiSpacc_Target_SDL12 + #if defined(MultiSpacc_Target_SDL12) SDL_WM_SetCaption( Title, NULL ); - #endif - #ifdef MultiSpacc_Target_SDL20 + #elif defined(MultiSpacc_Target_SDL20) SDL_SetWindowTitle( Window, Title ); #endif } void MultiSpacc_SetAppIcon( MultiSpacc_Window *Window, MultiSpacc_Surface *Icon ) { - #ifdef MultiSpacc_Target_SDL12 + #if defined(MultiSpacc_Target_SDL12) SDL_WM_SetIcon( Icon, NULL ); - #endif - #ifdef MultiSpacc_Target_SDL20 + #elif defined(MultiSpacc_Target_SDL20) SDL_SetWindowIcon( Window, Icon ); #endif } diff --git a/LibMultiSpacc/LibMultiSpacc/VideoSetup.c b/LibMultiSpacc/LibMultiSpacc/VideoSetup.c new file mode 100644 index 0000000..f5a83fe --- /dev/null +++ b/LibMultiSpacc/LibMultiSpacc/VideoSetup.c @@ -0,0 +1,29 @@ +#include "./MultiSpacc.h" + +MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig *windowConfig ) +{ + #if defined(MultiSpacc_Target_SDL12) + return SDL_SetVideoMode( windowConfig->width, windowConfig->height, windowConfig->bits, windowConfig->flags ); + + #elif defined(MultiSpacc_Target_SDL20) + return SDL_CreateWindow( NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowConfig->width, windowConfig->height, windowConfig->flags ); + + #elif defined(MultiSpacc_Target_NDS) + 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; + + #elif defined(MultiSpacc_Target_NES) + windowConfig->width = 256; + windowConfig->height = 240; + oam_clear(); + pal_all(windowConfig->palette); + ppu_on_all(); + + #endif +} diff --git a/LibMultiSpacc/neslib/neslib.h b/LibMultiSpacc/neslib/neslib.h index 44cef8a..eece40e 100644 --- a/LibMultiSpacc/neslib/neslib.h +++ b/LibMultiSpacc/neslib/neslib.h @@ -67,7 +67,6 @@ void __fastcall__ pal_spr_bright(unsigned char bright); void __fastcall__ pal_bg_bright(unsigned char bright); - // wait actual TV frame, 50hz for PAL, 60hz for NTSC void __fastcall__ ppu_wait_nmi(void); @@ -185,7 +184,6 @@ void __fastcall__ bank_spr(unsigned char n); void __fastcall__ bank_bg(unsigned char n); - // get random number 0..255 or 0..65535 unsigned char __fastcall__ rand8(void); unsigned int __fastcall__ rand16(void); @@ -194,7 +192,6 @@ unsigned int __fastcall__ rand16(void); void __fastcall__ set_rand(unsigned int seed); - // when display is enabled, vram access could only be done with this vram update system // the function sets a pointer to the update buffer that contains data and addresses // in a special format. It allows to write non-sequental bytes, as well as horizontal or @@ -266,7 +263,6 @@ void __fastcall__ oam_meta_spr_clip(signed int x,unsigned char y,const unsigned void __fastcall__ nmi_set_callback(void (*callback)(void)); - #define PAD_A 0x01 #define PAD_B 0x02 #define PAD_SELECT 0x04