/[projet1]/public/oric/games/Space 1999/Sources/game source/WHITE/white.h
Defence Force logotype

Contents of /public/oric/games/Space 1999/Sources/game source/WHITE/white.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations)
Tue May 26 07:45:25 2009 UTC (10 years, 6 months ago) by Chema
File MIME type: text/plain
File size: 5816 byte(s)


1 /* This is WHITE (World Handling & Interaction with The Environment)
2 Version 0.1
3 José María Enguita
4 2005
5 */
6
7 #ifndef _WHITE_H_
8 #define _WHITE_H_
9
10
11 #include "white_defs.h"
12 #include "noise.h"
13
14 // Callbacks for collisions
15 #ifdef COLLISION_CALLBACKS
16 char white_collided_with_bkg(char who, char against, char i, char j, char k); // Collided with a given background object
17 char white_collided_with_char(char who, char against); // Collided with a given character
18 #endif
19
20 void white_init(); // Inits the WHITE layer
21 void white_clear_room_map(); // Clears the room data (sets all tiles to 0)
22 void white_clear_screen(); // Clears the current screen (only the room) and sets paper and ink to 0
23 void white_show_screen(char attrmap1, char attrmap2); // Restore attribs so screen is visible. Sets the attribute value to attrmap1 and 2 alternatively
24 void white_load_room(char roomID); // Loads the room number roomID
25 void white_change_block(char i, char j, char k, char newID); // Changes a background block for the newID and repaints it.
26 void white_add_new_char(char ID); // Adds a character to the room... moving_chars[ID] should have been filled first.
27 void white_remove_char(char ID); // Removes a character from the room.
28 char white_step(char ID); // Makes a given char to move 1 step. Returns 0 if not able, 1 if able.
29 char white_movev(char ID, char dir); // Moves a character vertically. Returns 0 if not able, 1 if able.
30 char white_checkfloor(char ID); // Checks the floor a character is standing at. Returns 0 if nothing below, 1 else.
31 void white_standstill(char ID); // Makes the character to stand still (first frame)
32 void white_turn(char ID, char dir); // Turns character: CLOCKWISE (0) turns clockwise, ANTICLOCKWISE (1) turns anti-clockwise
33 void white_loop(); // main loop of white, for automatic actions.
34 void white_setPC(char ID); // sets the current player-controlled character and loads the room it is in.
35 char white_interact(char ID); // Makes the character ID (normally the player) explore what's nearby to interact with. Returns 0 if nothing found, 1 else.
36
37 #ifdef WAREHOUSE_MANAGE
38 char white_to_warehouse(char i, char j, char k); // Moves the object at position (i,j,k) to the warehouse.
39 //Returns ID if success, 0 if nothing there.
40 char white_from_warehouse(char i, char j, char k, char ID); // Moves object ID from the warehouse to current room at position (i,j,k).
41 //Returns 0 if success and an ID if there was an object already at that position.
42 #endif
43 char white_add_hook(void(*f)(void),char hook_point); // Adds a hook at a given hook_point
44 char white_remove_hook(char hook_point); // Removes a given hook_point
45
46 // Objects that move in the game
47 typedef struct t_moving_char{
48 unsigned char room;
49 unsigned char frame;
50 unsigned char direction;
51 unsigned char automov;
52 } moving_char_t;
53
54 // frame and direction fields have the 7th bit with a special meaning. If set, animation while stepping or changing direction
55 // respectively, is disabled.
56 // BEWARE: If animation in direction changes is disabled and later on enabled again, the actual direction should be consistent
57 // with the pointers to the graphics, or they will get corrupt. Basically it should be the same that when it was disabled. Just assign
58 // the old value when setting the 7th bit to 0 again and it should work well!
59
60
61 /* Structure of the automov field, controls how the char is auto-moved:
62 7 6 5 4 3 2 1 0
63 +---------------+
64 |a|t t t|f f|g|s|
65 +---------------+
66
67 a = automatic movement yes/no
68 s = speed
69 t = type of movement
70 g = char is affected by gravity
71 f = free */
72
73 // Macros to set flags
74 #define SET_AUTOMOV(x) x=(x | 0x80) // Sets the auto-movement flag (bit 7)
75 #define UNSET_AUTOMOV(x) x=(x & ~0x80) // Clears the auto-movement flag (bit 7)
76 #define SET_GRAV(x) x=(x | 0x2) // Sets the gravity flag (bit 1)
77 #define UNSET_GRAV(x) x=(x & ~0x2) // Clears the gravity flag (bit 1)
78 #define AM_TYPE0 0 // On collision turn CLOCKWISE
79 #define AM_TYPE1 1 // On collision turn ANTICLOCKWISE
80 #define AM_TYPE2 2 // On collision turn twice
81 #define AM_TYPE3 3 // On collision randomly act as any of the above
82 #define AM_TYPE4 4 // Do 0-4 randomly when stepping
83 #define SET_AMTYPE(x,y) x=(x | (y << 4)) // Sets auto-movement type
84 #define SET_SPEEDNORMAL(x) x=(x | 1) // Sets one step per loop (normal speed)
85 #define SET_SPEEDHALF(x) x=(x & 0xfe) // Sets one step every two loops (half speed)
86
87 // A more general macro, for direction and frame
88 #define SET_BIT7(x) x=(x | 0x80) // Sets bit 7
89 #define UNSET_BIT7(x) x=(x & ~0x80) // Clears bit 7
90
91 // Array of moving chars then...
92 extern moving_char_t moving_chars[MAX_CHARS];
93 extern char num_characters; // Number of entries in the above array
94
95
96
97 // Objects in the world
98 typedef struct t_object{
99 unsigned char room;
100 unsigned char id;
101 unsigned char i;
102 unsigned char j;
103 unsigned char k;
104 } object_t;
105
106 extern object_t objects[MAX_OBJS];
107 extern char num_objects; // Total of objects
108
109 extern char current_room; // Current room we are at
110 extern char player_char; // ID of the character we are controlling
111 extern char ink_colour; // Room ink
112 extern char ink_colour2; // Room ink 2 (for alternating scans)
113 extern char room_size; // Room size
114 extern char camera_angle; // Camera angle
115 extern char counter1; // Internal WHITE counter
116 extern char room_loaded; // Has any room been loaded?
117 extern char ignore_collisions; // Sets or clears ignoring collisions with background objects
118 extern char phantom_mode; // Sets or clears not stopping when colliding with background objects
119 extern char ignore_collision_test // Tells WHITE to ignore collision check when stepping
120
121
122 #endif //_WHITE_H_
123

  ViewVC Help
Powered by ViewVC 1.1.26