Fixed sequencer timing.
[cantaveria.git] / backend.h
bloba2843bb5aec3cdc2f1168b732d95825202969c98
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 SCREEN_W 320
86 #define SCREEN_H 240
88 #define MAX_GFX 256
91 #define COLOR_KEY 0x000000
93 #define SAMPLE_RATE 44100
94 #define BUFFER_SIZE 1024
96 #define RANDOM_SEED 57
99 void backend_init(int argc, char* argv[]);
100 void backend_quit();
102 void input(); /* pump event system */
103 void draw(); /* draw all active graphics */
105 int since(); /* ms since last time since() was called */
106 void delay(int ms); /* wait ms ms */
107 void end_program();
108 int ended();
110 void update_video();
111 void clear_video();
113 /* input */
114 int keynum(int name); /* get key number for key name */
115 int butnum(int joy, int name); /* get button number for button name */
116 void control(int type, int par1, int par2); /* automatic control */
117 void enable_alphanum(int yn);
118 void set_handler(struct handler h);
120 /* gfx control */
121 int load_gfx(char* filename);
122 void draw_gfx(int gfxid, int x, int y, int X, int Y, int W, int H);
123 void draw_gfx_raw(int gfxid, int x, int y, int X, int Y, int W, int H);
124 int gfx_width(int gfxid);
125 int gfx_height(int gfxid);
127 /* sound control */
128 int load_sound(char* filename);
129 void play_sound(int id);
130 int load_music(char* filename);
131 int play_music(int id);
133 void fps_update();
134 void fps_draw();
135 int get_fps();