Commit fa4185d7 by beoran

Solve some problems with versions of ALLEGRO, and add mapping macros.

parent 04e989e5
......@@ -9,4 +9,12 @@ library then does is to use A4 to provide certain conversions and services that
allow you to keep on using the Allegro 4 API in part, but redirect the output
and receive the input through Allegro 5.
Look at the example for now to see how this works.
Look at the example for now to see how this works. a4a5 is currently work in
progress.
Build it like this:
mkdir build
cd build
cmake ..
make
......@@ -6,6 +6,7 @@
#define WIDTH 640
#define HEIGHT 460
void abort_example(char * message) {
puts(message);
exit(1);
......@@ -15,8 +16,9 @@ void abort_example(char * message) {
int main(void) {
ALLEGRO_THREAD * thread;
ALLEGRO_DISPLAY * display;
int k = 0;
if (!al_init()) {
if (!(al_install_system(ALLEGRO_VERSION_INT, atexit))) {
abort_example("Could not init Allegro.\n");
}
......@@ -39,6 +41,19 @@ int main(void) {
puts("Waiting for Q");
while (!key[KEY_Q]) {
}
puts("Clear key buffer.");
clear_keybuf();
puts("Waiting for key");
while (!keypressed()) {
}
while (keypressed()) {
k = readkey();
printf("Got key: %d \n", k);
}
al_set_thread_should_stop(thread);
......
#ifndef A4A5_H_INCLUDED
#define A4A5_H_INCLUDED
/* No Allegro 4 include, to prevent pollution. Use void *
* and limited includes in stead. */
/* #include <allegro.h> */
#include <allegro/keyboard.h>
/* Allegro 5 include. */
#include <allegro5/allegro.h>
/* Allegro 4 include. */
#include <allegro.h>
/** Result of a function that could fail. */
typedef enum A4A5_RESULT_ENUM {
......@@ -14,10 +18,28 @@ typedef enum A4A5_RESULT_ENUM {
} A4A5_RESULT ;
ALLEGRO_BITMAP * a4a5_convert_bitmap(BITMAP * bitmap);
ALLEGRO_BITMAP * a4a5_convert_bitmap(void * bitmap);
ALLEGRO_THREAD * a4a5_start_keyboard_thread(void);
ALLEGRO_THREAD * a4a5_start_mouse_thread(void);
ALLEGRO_THREAD * a4a5_start_joystick_thread(void);
/* A4 for use by the client */
extern volatile char key[];
void a4a5_clear_keybuf();
int a4a5_keypressed();
void a4a5_simulate_keypress(int key);
int a4a5_readkey();
#ifndef A4A5_DONT_MAP_A4
#define clear_keybuf a4a5_clear_keybuf
#define keypressed a4a5_keypressed
#define readkey a4a5_readkey
#define simulate_keypress a4a5_simulate_keypress
#endif
#endif
......@@ -4,7 +4,8 @@
#include <allegro.h>
/** Converts an Allegro4 bitmap to an Allegro 5 one. */
ALLEGRO_BITMAP * a4a5_convert_bitmap(BITMAP * bitmap) {
ALLEGRO_BITMAP * a4a5_convert_bitmap(void * vbitmap) {
BITMAP * bitmap = vbitmap;
return NULL;
}
......
Markdown is supported
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