Fix SDL and NDS printing compatibility; Update README
This commit is contained in:
parent
0364ead98b
commit
8f73970599
|
@ -2,47 +2,31 @@
|
|||
|
||||
#define AppName "Hello World"
|
||||
|
||||
//MultiSpacc_Window consoleInnit(MultiSpacc_Window console){
|
||||
// consoleSelect(&console);
|
||||
// PrintConsole *consolePtr = consoleInit(&console, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
// consoleSelect(&console);
|
||||
// consoleSelect(consolePtr);
|
||||
// return *consolePtr;
|
||||
//return *consoleInit(&Window, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
//}
|
||||
|
||||
int main( void )
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
MultiSpacc_SurfaceConfig WindowConfig = { .Width = 320, .Height = 240, .Bits = 16 };
|
||||
MultiSpacc_Window Window = MultiSpacc_SetWindow( WindowConfig );
|
||||
MultiSpacc_Surface *Screen = MultiSpacc_GetWindowSurface( &Window );
|
||||
MultiSpacc_Window *Window = MultiSpacc_SetWindow( WindowConfig );
|
||||
MultiSpacc_Surface *Screen = MultiSpacc_GetWindowSurface( Window );
|
||||
|
||||
/* if( Screen == NULL )
|
||||
if( Screen == NULL )
|
||||
{
|
||||
printf("[E] Error Initializing Video System.\n");
|
||||
MultiSpacc_PrintDebug("[E] Error Initializing Video System.\n");
|
||||
return -1;
|
||||
};*/
|
||||
};
|
||||
|
||||
//MultiSpacc_SetAppTitle( Window, AppName );
|
||||
|
||||
//PrintConsole bottomScreen;
|
||||
//consoleInit(&Window, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
//Window = consoleInnit(Window);
|
||||
//consoleSelect(&Window);
|
||||
MultiSpacc_SetAppTitle( Window, AppName );
|
||||
|
||||
// Bitmap font borrowed from: <https://github.com/nesdoug/01_Hello/blob/master/Alpha.chr>
|
||||
// Copyright (c) 2018 Doug Fraker www.nesdoug.com (MIT)
|
||||
//MultiSpacc_Surface *TilesImg = MultiSpacc_LoadImage( "Tiles.png", Screen, NULL );
|
||||
MultiSpacc_PrintText( "Hello, World!", NULL, WindowConfig, 4, 4, NULL );
|
||||
MultiSpacc_Surface *TilesImg = MultiSpacc_LoadImage( "Tiles.png", Screen, NULL );
|
||||
MultiSpacc_PrintText( "Hello, World!", Screen, WindowConfig, 0, 0, TilesImg );
|
||||
|
||||
while(1){ swiWaitForVBlank(); }
|
||||
|
||||
/*if( MultiSpacc_UpdateWindowSurface( Window ) != 0 )
|
||||
if( MultiSpacc_UpdateWindowSurface( Window ) != 0 )
|
||||
{
|
||||
printf("[E] Error Updating Screen.\n");
|
||||
MultiSpacc_PrintDebug("[E] Error Updating Screen.\n");
|
||||
return -1;
|
||||
};*/
|
||||
};
|
||||
|
||||
MultiSpacc_Sleep( 3000 );
|
||||
MultiSpacc_Sleep( 4000 );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -25,7 +26,7 @@ typedef struct MultiSpacc_SurfaceConfig {
|
|||
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[] );
|
||||
|
@ -36,4 +37,5 @@ 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
|
||||
|
|
|
@ -1,37 +1,24 @@
|
|||
#include "../MultiSpacc.h"
|
||||
|
||||
MultiSpacc_Window MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig )
|
||||
MultiSpacc_Window *MultiSpacc_SetWindow( MultiSpacc_SurfaceConfig WindowConfig )
|
||||
{
|
||||
//PrintConsole topScreen;
|
||||
PrintConsole bottomScreen;
|
||||
//PrintConsole *bottomScreenPtr;
|
||||
PrintConsole *bottomScreen = NULL;
|
||||
|
||||
//videoSetMode(MODE_0_2D);
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
|
||||
//vramSetBankA(VRAM_A_MAIN_BG);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
//consoleInit(&topScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
|
||||
//bottomScreenPtr = consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
|
||||
//consoleSelect(&bottomScreen);
|
||||
//return *bottomScreenPtr;
|
||||
|
||||
|
||||
PrintConsole *bottomScreenPtr = consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
bottomScreen = *bottomScreenPtr;
|
||||
consoleSelect(&bottomScreen);
|
||||
bottomScreen = consoleInit(bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
consoleSelect(bottomScreen);
|
||||
return bottomScreen;
|
||||
}
|
||||
|
||||
MultiSpacc_Surface *MultiSpacc_GetWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
consoleSelect(Window);
|
||||
return Window;
|
||||
}
|
||||
|
||||
void MultiSpacc_SetAppTitle( MultiSpacc_Window *Window, const char Title[] ){}
|
||||
void MultiSpacc_PrintDebug( const char *format, ... ){}
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window )
|
||||
{
|
||||
|
@ -41,4 +28,13 @@ int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window )
|
|||
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();
|
||||
};
|
||||
}
|
|
@ -10,10 +10,11 @@
|
|||
#define Uint32 int32
|
||||
#define MultiSpacc_Surface PrintConsole
|
||||
#define MultiSpacc_Window PrintConsole
|
||||
#define MultiSpacc_Sleep {}
|
||||
|
||||
typedef struct MultiSpacc_Event {
|
||||
int Keys;
|
||||
} MultiSpacc_Event;
|
||||
|
||||
int MultiSpacc_UpdateWindowSurface( MultiSpacc_Window *Window );
|
||||
|
||||
void MultiSpacc_Sleep( int milliseconds );
|
|
@ -5,8 +5,8 @@
|
|||
#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_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;
|
||||
|
|
|
@ -49,3 +49,11 @@ void MultiSpacc_PrintText( char Text[], MultiSpacc_Surface *Surface, MultiSpacc_
|
|||
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);
|
||||
}
|
|
@ -8,10 +8,11 @@ The list of supported (or planned) backend libraries follows:
|
|||
|
||||
- SDL 1.2 (WIP)
|
||||
- SDL 2.0/3.0 (WIP)[^1]
|
||||
- NDS (Planned)
|
||||
- NDS (WIP)
|
||||
- GBA (Planned)
|
||||
- NES (Planned)
|
||||
|
||||
Example programs (and makefiles) will come soon.
|
||||
SDL is used as the main cross-platform library (covering many old systems with v1.2, and all modern PC, embedded, and virtualized systems with v2.0).
|
||||
Specific platform that require special code are handled separately via other base abstraction layers.
|
||||
|
||||
[^1]: I just discovered that SDL 3.0 exists, I'm so tired, why would they make a new major, now I have to support 3 versions... or just drop 2.0 and only support 1.2 + 3.0.
|
||||
|
|
Loading…
Reference in New Issue