2023-11-06 23:23:22 +01:00
# ifndef _MultiSpacc_MultiSpacc_h_
# define _MultiSpacc_MultiSpacc_h_
2023-11-01 13:58:22 +01:00
2023-11-11 12:30:35 +01:00
// Fixed amount of times per second to call the FixedUpdate function
# define MultiSpacc_GameTick 50
2023-10-10 18:11:20 +02:00
# include <stdarg.h>
2023-11-01 13:58:22 +01:00
# ifndef MultiSpacc_Target_NES
# include <stdbool.h>
# endif
2022-08-06 20:34:46 +02:00
# include <stddef.h>
2023-10-07 16:51:29 +02:00
# include <stdint.h>
# include <stdio.h>
2023-11-01 13:58:22 +01:00
# include <string.h>
2022-08-06 01:07:35 +02:00
# ifdef MultiSpacc_Target_SDL12
2023-10-30 12:27:41 +01:00
# 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 ;
2022-08-06 01:07:35 +02:00
# endif
# ifdef MultiSpacc_Target_SDL20
2023-10-30 12:27:41 +01:00
# 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
2022-08-06 01:07:35 +02:00
# endif
2022-08-07 00:38:18 +02:00
2023-11-04 16:49:35 +01:00
# ifdef MultiSpacc_Target_Web
# include <emscripten.h>
# endif
2023-10-07 16:51:29 +02:00
# ifdef MultiSpacc_Target_NDS
2023-10-30 12:27:41 +01:00
# include <nds.h>
# define Uint32 int32
# define MultiSpacc_Surface PrintConsole
# define MultiSpacc_Window PrintConsole
typedef struct MultiSpacc_Event {
int Keys ;
} MultiSpacc_Event ;
2023-10-07 16:51:29 +02:00
# endif
2023-10-31 18:06:39 +01:00
# ifdef MultiSpacc_Target_NES
# include <nes.h>
# include "neslib.h"
2023-11-11 12:30:35 +01:00
# define float int
# define double int
2023-11-01 13:58:22 +01:00
# define Uint32 int
2023-11-06 23:23:22 +01:00
# define MultiSpacc_Window char
# define MultiSpacc_Surface char
# define MultiSpacc_Event char
2023-11-09 19:26:53 +01:00
# define main( argc, argv ) main(void)
2023-11-06 23:23:22 +01:00
# endif
# ifdef MultiSpacc_Target_SDLCom
# define MultiSpacc_Sleep SDL_Delay
# else
2023-11-01 23:22:11 +01:00
void MultiSpacc_Sleep ( int milliseconds ) ;
2023-10-31 18:06:39 +01:00
# endif
2023-11-06 23:23:22 +01:00
# ifdef MultiSpacc_Target_SDLCom
# define MultiSpacc_Point SDL_Point
# define MultiSpacc_Rect SDL_Rect
# else
typedef struct MultiSpacc_Point {
int x , y ;
} MultiSpacc_Point ;
typedef struct MultiSpacc_Rect {
int x , y , w , h ;
} MultiSpacc_Rect ;
# endif
2023-10-07 16:51:29 +02:00
typedef struct MultiSpacc_SurfaceConfig {
2023-11-08 23:46:18 +01:00
int width ;
int height ;
int bits ;
char palette [ 32 ] ;
Uint32 flags ;
2023-10-07 16:51:29 +02:00
} MultiSpacc_SurfaceConfig ;
2023-11-09 19:26:53 +01:00
typedef struct MultiSpacc_SpritesMap {
int * chr ;
int * x ;
int * y ;
int * flags ;
} MultiSpacc_SpritesMap ;
2023-11-11 12:30:35 +01:00
typedef struct MultiSpacc_MainLoopHandlerArgs {
bool ( * functionFixedUpdate ) ( void * args ) ;
bool ( * functionRealUpdate ) ( void * args , double deltaTime ) ;
void * args ;
//Uint32 *nextTick;
//Uint32 ticksLast;
Uint32 elapsedRealTime ;
Uint32 elapsedFixedTime ;
} MultiSpacc_MainLoopHandlerArgs ;
bool MultiSpacc_MainLoopHandler ( MultiSpacc_MainLoopHandlerArgs * handlerArgs ) ;
2023-11-08 23:46:18 +01:00
MultiSpacc_Window * MultiSpacc_SetWindow ( MultiSpacc_SurfaceConfig * windowConfig ) ;
2022-08-07 00:38:18 +02:00
MultiSpacc_Surface * MultiSpacc_GetWindowSurface ( MultiSpacc_Window * Window ) ;
2023-07-20 00:51:16 +02:00
void MultiSpacc_SetAppTitle ( MultiSpacc_Window * Window , const char Title [ ] ) ;
2022-08-07 00:38:18 +02:00
void MultiSpacc_SetAppIcon ( MultiSpacc_Window * Window , MultiSpacc_Surface * Icon ) ;
2023-11-11 12:30:35 +01:00
bool MultiSpacc_SetMainLoop ( bool functionFixedUpdate ( void * args ) , bool functionRealUpdate ( void * args , double deltaTime ) , Uint32 * nextTick , void * args ) ;
2023-11-04 16:49:35 +01:00
2023-07-20 00:51:16 +02:00
MultiSpacc_Surface * MultiSpacc_LoadImage ( char FilePath [ ] , MultiSpacc_Surface * Screen , Uint32 * ColorKey ) ;
2022-08-07 00:38:18 +02:00
int MultiSpacc_SetColorKey ( MultiSpacc_Surface * Surface , bool Flag , Uint32 Key ) ;
2023-07-20 00:51:16 +02:00
int MultiSpacc_PollEvent ( MultiSpacc_Event * Event ) ;
2023-10-07 01:55:59 +02:00
2023-11-08 23:46:18 +01:00
void MultiSpacc_PrintText ( char Text [ ] , MultiSpacc_Surface * Surface , MultiSpacc_SurfaceConfig * surfaceConfig , int x , int y , MultiSpacc_Surface * Tiles /*, int FontSize, int Color */ ) ; // WIP
2023-11-09 19:26:53 +01:00
void MultiSpacc_PrintDebug ( const char * format , . . . ) ;
2023-10-31 18:06:39 +01:00
2023-11-09 19:26:53 +01:00
void MultiSpacc_SetSprite ( int id , int x , int y , int sprite , MultiSpacc_Surface * tiles , MultiSpacc_Surface * screen ) ;
void MultiSpacc_SetMetaSprite ( int id , int x , int y , MultiSpacc_SpritesMap * map , int mapSize , MultiSpacc_Surface * tiles , MultiSpacc_Surface * screen ) ;
2023-11-08 23:46:18 +01:00
MultiSpacc_Surface * MultiSpacc_CreateSurface ( MultiSpacc_SurfaceConfig * surfaceConfig ) ;
void MultiSpacc_BlitLayer ( MultiSpacc_Surface * source , MultiSpacc_Surface * destination ) ;
2023-11-01 13:58:22 +01:00
2023-11-06 23:23:22 +01:00
# include "./Keys.h"
2023-11-09 19:26:53 +01:00
# include "./VideoCycle.h"
2023-11-06 23:23:22 +01:00
# endif // _MultiSpacc_MultiSpacc_h_