-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgamelib.h
95 lines (73 loc) · 2.47 KB
/
gamelib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef _GAMELIB_H
#define _GAMELIB_H
#include "stddef.h"
#include "revolution.h"
#include "gamedefs.h"
#define MEM_START 0x88040000
#define MEM_IGNORE 0x0
#define MEM_EMPTY 0x1
#define DIRECTION_MIDDLE 0x0
#define DIRECTION_NORTH 0x1
#define DIRECTION_EAST 0x2
#define DIRECTION_SOUTH 0x3
#define DIRECTION_WEST 0x4
#define AI_MOVE_WANDER 0x0000
#define AI_MOVE_PURSUE 0x1000
#define AI_MOVE_FLEE 0x2000
#define AI_MOVE 0xF000
#define AI_ARG0 0x0F00
#define AI_ARG1 0x00F0
#define AI_ARG2 0x000F
/* STRUCTS */
typedef struct player player_t;
typedef struct mapcache mapcache_t;
struct player {
entity_t character;
/*
These values describe the position of the chunk compared to the others
Can store at most 0xFF and 0xFF == a map with 256 by 256 chunks
*/
unsigned char map_x;
unsigned char map_y;
};
struct mapcache {
mapchunk_t cache[5];
unsigned char sizes; //0xF0 | 0x0F
entity_t entities[8]; //8 entities (loaded)
};
/* EXTERNALS */
extern unsigned char *g_vram; //where the VRAM is on the 9860gii
extern sprite_t *g_sprite_tile_list; //all tile sprites; used to draw chunks
extern sprite_t *g_sprite_entity_list; //all sprites; used to draw chunks
extern sprite_t *g_sprite_projectile_list; //all sprites; used to draw chunks
extern mapcache_t *g_mapcache; //all currently loaded maps
extern player_t *g_player; //the player
void sprite_register(sprite_t *sp, unsigned char i);
/* INITS */
void globals_initialize(); //initializes extern values
void game_initialize(); //initializes game values & globals
void mapcache_init();
/* LOAD */
void load_game();
void load_mapchunk(game_header_t *header, size_t coffset, unsigned char x, unsigned char y, mapchunk_t *store);
/* GAME */
void *game_cmalloc(size_t size, unsigned char calloc);
void game_run();
void game_stop();
void game_process_entities();
void game_process_projectiles();
void game_process_input(int *kc1, int* kc2, short *unused);
/* ENTITIES */
char entity_add(entity_t* e);
void entity_remove(unsigned char index);
void entity_ai(entity_t* e);
void entity_move(entity_t* e, unsigned char direction);
void entity_xmove(entity_t* e, unsigned char direction, int x);
unsigned char entity_collide_map(entity_t *e, unsigned char direction);
unsigned char player_onborder();
/* DRAW */
void Draw_Sprite(sprite_t *sprite, unsigned char x, unsigned char y);
void Draw_Entity(entity_t *entity);
void Draw_EntityState(entity_t *entity, unsigned char state);
void Draw_Mapchunk(mapchunk_t *mc);
#endif