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-16 00:52:20 +01:00
# ifdef __cplusplus
extern " C " {
# endif
2023-11-14 00:29:48 +01:00
// Amount of times per second to call the FixedUpdate function, independent from video rate and hardcoded in some places due to consoles, don't change
2023-11-11 12:30:35 +01:00
# 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-14 00:29:48 +01:00
# include <stdlib.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
2023-11-16 00:52:20 +01:00
# ifdef MultiSpacc_Target_SDLCommon
2023-10-30 12:27:41 +01:00
# 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-11-16 00:52:20 +01:00
# ifdef MultiSpacc_Target_Switch
# include <switch.h>
# include <unistd.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-19 01:34:57 +01:00
typedef struct MultiSpacc_SpriteFlags {
bool flipHorizontal ;
bool flipVertical ;
} MultiSpacc_SpriteFlags ;
2023-11-16 00:52:20 +01:00
typedef struct {
2023-11-09 19:26:53 +01:00
int * chr ;
int * x ;
int * y ;
2023-11-19 01:34:57 +01:00
MultiSpacc_SpriteFlags * flags ;
2023-11-16 00:52:20 +01:00
} MultiSpacc_SpritesMap , MultiSpacc_TilesMap ;
2023-11-09 19:26:53 +01:00
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 elapsedRealTime ;
Uint32 elapsedFixedTime ;
} MultiSpacc_MainLoopHandlerArgs ;
2023-11-22 00:19:32 +01:00
# if defined(MultiSpacc_Target_NES)
# define MultiSpacc_StaticScreenWidth 256
# define MultiSpacc_StaticScreenHeight 240
# define MultiSpacc_StaticScreenSizeNull false
# else
# define MultiSpacc_StaticScreenWidth 0
# define MultiSpacc_StaticScreenHeight 0
# define MultiSpacc_StaticScreenSizeNull true
# endif
2023-11-26 01:06:18 +01:00
# if defined(MultiSpacc_Target_NES)
# define MultiSpacc_SystemClockAvailable false
# else
# define MultiSpacc_SystemClockAvailable true
# endif
bool MultiSpacc_InitSystem ( void ) ;
2023-11-11 12:30:35 +01:00
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-14 00:29:48 +01:00
bool MultiSpacc_SetMainLoop ( bool functionFixedUpdate ( void * args ) , bool functionRealUpdate ( void * args , double deltaTime ) , void * args ) ;
2023-11-26 01:06:18 +01:00
bool MultiSpacc_MainLoopHandler ( MultiSpacc_MainLoopHandlerArgs * handlerArgs ) ;
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-14 18:51:12 +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-19 01:34:57 +01:00
void MultiSpacc_SetSprite ( int id , int x , int y , int sprite , MultiSpacc_SpriteFlags * flags , MultiSpacc_Surface * tiles , MultiSpacc_Surface * screen ) ;
2023-11-09 19:26:53 +01:00
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
2023-11-14 18:51:12 +01:00
void MultiSpacc_SetTile ( int x , int y , int tile , MultiSpacc_Surface * tiles , MultiSpacc_Surface * screen ) ;
2023-11-19 01:34:57 +01:00
void MultiSpacc_SetMetaTile ( int x , int y , MultiSpacc_TilesMap * map , int mapSize , MultiSpacc_Surface * tiles , MultiSpacc_Surface * screen ) ;
2023-11-14 18:51:12 +01:00
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-14 00:29:48 +01:00
bool MultiSpacc_UpdateDisplay ( MultiSpacc_Window * window ) ;
2023-11-06 23:23:22 +01:00
# include "./Keys.h"
2023-11-16 00:52:20 +01:00
# ifdef __cplusplus
}
# endif
2023-11-06 23:23:22 +01:00
# endif // _MultiSpacc_MultiSpacc_h_