Added rng.c implementing an awesome RNG.
[cantaveria.git] / backend.h
blobed03b046bca800bea107976e43353134362ff433
1 /*
2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 enum {
24 ESCAPE_KEY,
25 PAUSE_KEY,
27 LEFT_KEY,
28 RIGHT_KEY,
29 UP_KEY,
30 DOWN_KEY,
32 FIRE_KEY,
33 JUMP_KEY,
34 INVENTORY_KEY,
35 SPECIAL_KEY,
37 L_KEY,
38 R_KEY,
39 START_KEY,
40 SELECT_KEY
43 enum{
44 FIRE_BUTTON,
45 JUMP_BUTTON,
46 INVENTORY_BUTTON,
47 SPECIAL_BUTTON,
49 L_BUTTON,
50 R_BUTTON,
51 START_BUTTON,
52 SELECT_BUTTON
55 enum{
56 KEYUP,
57 KEYDOWN,
58 JOYMOVEX,
59 JOYMOVEY,
60 JOYPRESS,
61 JOYRELEASE
64 struct handler {
65 void (*keydown)(int key);
66 void (*keyup)(int key);
67 void (*joymovex)(int joy, int x);
68 void (*joymovey)(int joy, int y);
69 void (*joypress)(int joy, int button);
70 void (*joyrelease)(int joy, int button);
71 //void (*keyentry)(utf32 u);
74 #define VERSION_MAJOR 0
75 #define VERSION_MINOR 0
77 #define JOY_MAX 32767
78 #define JOY_MIN -32768
80 #define MAX_PLAYERS 6
82 #define dt 10
83 #define DELAY_AMOUNT 1
85 #define PI 3.14159265359
86 #define PI2 2*PI
88 #define SCREEN_W 320
89 #define SCREEN_H 240
91 #define MAX_GFX 256
94 #define COLOR_KEY 0x000000
96 #define SAMPLE_RATE 44100
97 #define BUFFER_SIZE 1024
99 #define RANDOM_SEED 57
102 void backend_init(int argc, char* argv[]);
103 void backend_quit();
105 void input(); /* pump event system */
106 void draw(); /* draw all active graphics */
108 int since(); /* ms since last time since() was called */
109 void delay(int ms); /* wait ms ms */
110 void end_program();
111 int ended();
113 void update_video();
114 void clear_video();
116 /* input */
117 int keynum(int name); /* get key number for key name */
118 int butnum(int joy, int name); /* get button number for button name */
119 void control(int type, int par1, int par2); /* automatic control */
120 void enable_alphanum(int yn);
121 void set_handler(struct handler h);
123 /* gfx control */
124 int load_gfx(char* filename);
125 void draw_gfx(int gfxid, int x, int y, int X, int Y, int W, int H);
126 void draw_gfx_raw(int gfxid, int x, int y, int X, int Y, int W, int H);
127 int gfx_width(int gfxid);
128 int gfx_height(int gfxid);
130 /* sound control */
131 int load_sound(char* filename);
132 void play_sound(int id);
133 int load_music(char* filename);
134 int play_music(int id);
136 void fps_update();
137 void fps_draw();
138 int get_fps();