Commit 0627c8c4 authored by Christian Michael Baum's avatar Christian Michael Baum 🏀
Browse files

Allegro 4 compiles city night again

parent abfda71d
......@@ -71,7 +71,7 @@ static DumbProperties CN__load_dumb_properties_file()
}
#endif
CN_bool CN_Init(CN_Options *options)
CN_bool CN_Backend_Init(CN_Options *options)
{
int errors = allegro_init(), mode;
if(options == NULL) {
......@@ -179,7 +179,7 @@ void CN_Backend_FinalizeFrame()
if((CN_bool)keyboard_needs_poll()) poll_keyboard();
}
CN_bool CN_Deinit(void)
CN_bool CN_Backend_Deinit(void)
{
CN_Assert(allegro4_backend != NULL);
/*
......@@ -199,6 +199,11 @@ CN_bool CN_Deinit(void)
return CN_true;
}
CN_bool CN_Backend_CanReinit(void)
{
return CN_false;
}
CN_bool CN_ExitCondition()
{
return CN_exit;
......@@ -210,7 +215,9 @@ CN_Image *CN_Image_Load(const char *path)
{
int length = strlen(path);
CN_Image *image = NULL;
if(path[length-3] == 'g' ) /* Assume GIF*/
if(path[length-3] == 'g' &&
path[length-2] == 'i' &&
path[length-1] == 'f')
{
#ifdef CN_ALGIF
image = load_gif(path, NULL);
......@@ -236,7 +243,7 @@ CN_Image *CN_Image_Create(int width, int height)
}
/* These are where the original draw functions were */
#include "shared/draw.c"
#include "../img/draw.c"
size_t CN_Image_EstimateSizeOf(const CN_Image *image)
{
......@@ -538,9 +545,9 @@ int main(int argc, char **argv)
CN_Init(argc, argv);
while(!CN_ExitCondition())
{
CN_Frame(argc, argv);
CN_Frame(CN_GetDeltaTime());
}
CN_Deinit(argc, argv);
CN_Deinit();
}
#endif
......
......@@ -47,8 +47,8 @@ typedef struct Allegro4_Backend {
AL_DUH_PLAYER *duh_player;
DumbProperties dumb_properties;
#endif /* CN_DUMB */
volatile int CN_msecs;
volatile int CN_ticks;
volatile unsigned int CN_msecs;
volatile unsigned int CN_ticks;
unsigned char keyup [KEY_MAX];
unsigned char keydown [KEY_MAX];
} Allegro4_Backend;
......@@ -70,6 +70,9 @@ typedef MIDI CN_MIDI_Impl;
typedef void CN_Music_Impl;
typedef int CN_Key_Impl;
/* TODO: This is a placeholder. */
typedef char CN_MouseButton_Impl;
/*Input defines*/
#define CN_KEY__A KEY_A
#define CN_KEY__B KEY_B
......
......@@ -15,7 +15,7 @@ static CN_inline char CN_CharKeyDown()
return (x && 0xff);
}
static CN_inline int CN_GetDeltaTime(void)
static CN_inline unsigned int CN_GetDeltaTime(void)
{
int temp = allegro4_backend->CN_msecs;
if(allegro4_backend->CN_msecs > 0)
......@@ -54,6 +54,11 @@ static CN_inline void CN_IncrementTicker()
allegro4_backend->CN_ticks++;
} END_OF_FUNCTION(CN_IncrementTicker)
static CN_inline unsigned int CN_GetMilliseconds(void)
{
return allegro4_backend->CN_msecs;
}
static CN_inline CN_RGB CN_Image_GetRGB(
const CN_RGB* pal, CN_Image *image, int x, int y)
{
......
sdl2_dep = dependency(
'sdl2',
required : get_option('cnbackend') == 'sdl2',
method : 'auto'
)
sdl2_image_dep = dependency(
'SDL2_image',
required : get_option('cnbackend') == 'sdl2',
method : 'auto'
)
if get_option('cnbackend') == 'sdl2'
sdl2_dep = dependency(
'sdl2',
required : true,
method : 'auto'
)
sdl2_image_dep = dependency(
'SDL2_image',
required : false,
method : 'auto'
)
sdl2_mixer_dep = dependency(
'SDL2_mixer',
required : false,
method : 'auto'
)
sdl2_mixer_dep = dependency(
'SDL2_mixer',
required : get_option('cnbackend') == 'sdl2',
method : 'auto'
)
if sdl2_dep.found()
add_project_arguments('-DCN_SDL2', language : 'c')
cngine_deps = [sdl2_dep, sdl2_image_dep, sdl2_mixer_dep]
add_project_arguments('-DCN_SDL2', language : 'c')
if not sdl2_image_dep.found()
add_project_arguments('-DCN_NO_IMAGE', language : 'c')
endif
......@@ -26,12 +29,35 @@ if sdl2_dep.found()
endif
endif
if get_option('cnbackend') == 'allegro4'
allegro4_dep = dependency(
'allegro',
required : true,
method : 'auto'
)
dumb_dep = dependency(
'dumb',
required : false,
method : 'auto'
)
cngine_deps = [allegro4_dep, dumb_dep]
add_project_arguments('-DCN_ALLEGRO4', language : 'c')
if dumb_dep.found()
add_project_arguments('-DCN_DUMB', language : 'c')
endif
endif
lua_dep = dependency(
'lua',
version : '5.1',
required : false,
method : 'auto')
cngine_deps += lua_dep
if not lua_dep.found()
add_project_arguments('-DCN_NO_LUA', language : 'c')
endif
......@@ -62,4 +88,4 @@ cngine_sources = files(
'img/pcx.c',
'img/pixmap.c')
cngine_deps = [sdl2_dep, sdl2_image_dep, sdl2_mixer_dep, lua_dep]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment