Revision 324
corrected some more things
proj/include/proj_structures.h | ||
---|---|---|
52 | 52 |
|
53 | 53 |
void host_info_dtor(host_info_t *p); |
54 | 54 |
|
55 |
remote_info_t* remote_info_ctor(); |
|
55 |
remote_info_t* remote_info_ctor(void);
|
|
56 | 56 |
|
57 | 57 |
void remote_info_dtor(remote_info_t *p); |
58 | 58 |
|
59 |
bullet_info_t* bullet_info_ctor(); |
|
59 |
bullet_info_t* bullet_info_ctor(void);
|
|
60 | 60 |
|
61 | 61 |
void bullet_info_dtor(bullet_info_t *p); |
62 | 62 |
|
proj/libs/graph/src/graph.c | ||
---|---|---|
8 | 8 |
#define VC_BIOS_SERV 0x10 /** @brief Interrupt service of video card */ |
9 | 9 |
#define VBE_CALL 0x4F /** @brief VBE call function specifier */ |
10 | 10 |
|
11 |
//#define MBYTE_BASE 0x0 /** @brief Base address (zero address) */
|
|
12 |
//#define MBYTE_SIZE 0xFFFFF /** @brief Size of a mebibyte */
|
|
11 |
#define MBYTE_BASE 0x0 /** @brief Base address (zero address) */ |
|
12 |
#define MBYTE_SIZE 0xFFFFF /** @brief Size of a mebibyte */ |
|
13 | 13 |
|
14 | 14 |
// Graphics Functions |
15 |
//#define VBE_CTRL_INFO 0x00 /** @brief Get VBE Controller Information */
|
|
15 |
#define VBE_CTRL_INFO 0x00 /** @brief Get VBE Controller Information */ |
|
16 | 16 |
#define VBE_MD_INFO 0x01 /** @brief Get VBE Mode Information */ |
17 | 17 |
#define SET_VBE_MD 0x02 /** @brief Set VBE Mode */ |
18 | 18 |
|
19 | 19 |
// Error codes (AH) |
20 | 20 |
#define AH_SUCCESS 0x00 /** @brief Success code on BIOS call */ |
21 |
//#define AH_FUNC_CALL_FAIL 0x01 /** @brief Function call failed */
|
|
22 |
//#define AH_FUNC_NOT_SUPP 0x02 /** @brief Function call is not supported in current HW configuration */
|
|
23 |
//#define AH_FUNC_INVALID 0x03 /** @brief Invalid function in current video mode */
|
|
21 |
#define AH_FUNC_CALL_FAIL 0x01 /** @brief Function call failed */ |
|
22 |
#define AH_FUNC_NOT_SUPP 0x02 /** @brief Function call is not supported in current HW configuration */ |
|
23 |
#define AH_FUNC_INVALID 0x03 /** @brief Invalid function in current video mode */ |
|
24 | 24 |
|
25 | 25 |
/// MACROS |
26 |
//#define FAR2PHYS(n) ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
|
|
26 |
#define FAR2PHYS(n) ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF)) |
|
27 | 27 |
|
28 | 28 |
/// STRUCT |
29 | 29 |
typedef struct __attribute__((packed)) { |
proj/libs/graph/src/menu.c | ||
---|---|---|
8 | 8 |
#include "proj_macros.h" |
9 | 9 |
#include "errors.h" |
10 | 10 |
|
11 |
const int W = 400; |
|
12 |
const int H = 60; |
|
13 |
const int W1 = 40; |
|
14 |
const int H1 = 40; |
|
15 |
const int H2 = 20; |
|
11 |
static const int W = 400;
|
|
12 |
static const int H = 60;
|
|
13 |
static const int W1 = 40;
|
|
14 |
static const int H1 = 40;
|
|
15 |
static const int H2 = 20;
|
|
16 | 16 |
|
17 | 17 |
struct menu { |
18 | 18 |
const font_t *fnt; |
... | ... | |
23 | 23 |
}; |
24 | 24 |
|
25 | 25 |
static int menu_recalculate(menu_t *menu){ |
26 |
const int Wtotal = 2*W1+W;
|
|
27 |
const int Htotal = 2*H1+menu->sz*H+(menu->sz-1)*H2;
|
|
28 |
int x = graph_get_XRes()/2-Wtotal/2; |
|
29 |
int y = graph_get_YRes()/2-Htotal/2; |
|
26 |
const uint16_t Wtotal = 2*W1+W;
|
|
27 |
const uint16_t Htotal = (uint16_t)(2*H1+menu->sz*H+(menu->sz-1)*H2);
|
|
28 |
int16_t x = graph_get_XRes()/2-Wtotal/2;
|
|
29 |
int16_t y = graph_get_YRes()/2-Htotal/2;
|
|
30 | 30 |
rectangle_set_pos (menu->frame, x, y); |
31 | 31 |
rectangle_set_size(menu->frame, Wtotal, Htotal); |
32 | 32 |
x += W1; y += H1; |
... | ... | |
86 | 86 |
if(!click) return -1; |
87 | 87 |
for(size_t i = 0; i < menu->sz; ++i) |
88 | 88 |
if(rectangle_collide_point(menu->r[i], *get_mouse_X(), *get_mouse_Y())) |
89 |
return i; |
|
89 |
return (int)i;
|
|
90 | 90 |
return -1; |
91 | 91 |
} |
92 | 92 |
|
proj/libs/kbc/src/mouse.c | ||
---|---|---|
19 | 19 |
// Byte 2 - Y delta |
20 | 20 |
|
21 | 21 |
/* Mouse Commands */ |
22 |
//#define RESET 0xFF /* @brief Reset mouse */
|
|
23 |
//#define RESEND 0xFE /* @brief Resend command */
|
|
24 |
//#define DEFAULT 0xF6 /* @brief Set default values */
|
|
22 |
#define RESET 0xFF /* @brief Reset mouse */ |
|
23 |
#define RESEND 0xFE /* @brief Resend command */ |
|
24 |
#define DEFAULT 0xF6 /* @brief Set default values */ |
|
25 | 25 |
#define DIS_DATA_REP 0xF5 /* @brief Disable Data Reporting */ |
26 | 26 |
#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */ |
27 |
//#define SET_SAMPLE_RT 0xF3 /* @brief Sets state sampling rate */
|
|
28 |
//#define SET_REMOTE_MD 0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
|
|
27 |
#define SET_SAMPLE_RT 0xF3 /* @brief Sets state sampling rate */ |
|
28 |
#define SET_REMOTE_MD 0xF0 /* @brief Sets Mouse on Remote Mode, data on request */ |
|
29 | 29 |
#define READ_DATA 0xEB /* @brief Sends data packet request */ |
30 |
//#define SET_STREAM_MD 0xEA /* @brief Sets mouse on Stream Mode, data on events */
|
|
31 |
//#define STATUS_REQUEST 0xE9 /* @brief Get mouse configuration */
|
|
32 |
//#define SET_RESOLUTION 0xE8 /* @brief Sets resolution for mouse movement */
|
|
33 |
//#define SCALING_ACC_MD 0xE7 /* @brief Sets scaling on acceleration mode */
|
|
34 |
//#define SCALING_LIN_MD 0xE6 /* @brief Sets scaling on linear mode */
|
|
30 |
#define SET_STREAM_MD 0xEA /* @brief Sets mouse on Stream Mode, data on events */ |
|
31 |
#define STATUS_REQUEST 0xE9 /* @brief Get mouse configuration */ |
|
32 |
#define SET_RESOLUTION 0xE8 /* @brief Sets resolution for mouse movement */ |
|
33 |
#define SCALING_ACC_MD 0xE7 /* @brief Sets scaling on acceleration mode */ |
|
34 |
#define SCALING_LIN_MD 0xE6 /* @brief Sets scaling on linear mode */ |
|
35 | 35 |
|
36 | 36 |
/* Mouse Controller Responses */ |
37 | 37 |
#define ACK_OK 0xFA /* @brief Operation sucessful */ |
38 |
//#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
|
|
38 |
#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */ |
|
39 | 39 |
#define ACK_ERROR 0xFC /* @brief Invalid Byte on resend */ |
40 | 40 |
|
41 | 41 |
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) { |
proj/libs/timer/src/timer.c | ||
---|---|---|
2 | 2 |
|
3 | 3 |
#include "timer.h" |
4 | 4 |
|
5 |
//#define TIMER_FREQ 1193182 /**< @brief clock frequency for timer in PC and AT */
|
|
6 |
//#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0) /**< @brief mininum frequency for timer */
|
|
5 |
#define TIMER_FREQ 1193182 /**< @brief clock frequency for timer in PC and AT */ |
|
6 |
#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0) /**< @brief mininum frequency for timer */ |
|
7 | 7 |
|
8 | 8 |
/* I/O port addresses */ |
9 | 9 |
|
10 |
//#define TIMER_0 0x40 /**< @brief Timer 0 count register */
|
|
11 |
//#define TIMER_1 0x41 /**< @brief Timer 1 count register */
|
|
12 |
//#define TIMER_2 0x42 /**< @brief Timer 2 count register */
|
|
13 |
//#define TIMER_CTRL 0x43 /**< @brief Control register */
|
|
10 |
#define TIMER_0 0x40 /**< @brief Timer 0 count register */ |
|
11 |
#define TIMER_1 0x41 /**< @brief Timer 1 count register */ |
|
12 |
#define TIMER_2 0x42 /**< @brief Timer 2 count register */ |
|
13 |
#define TIMER_CTRL 0x43 /**< @brief Control register */ |
|
14 | 14 |
|
15 |
//#define SPEAKER_CTRL 0x61 /**< @brief Register for speaker control */
|
|
15 |
#define SPEAKER_CTRL 0x61 /**< @brief Register for speaker control */ |
|
16 | 16 |
|
17 | 17 |
/* Timer control */ |
18 | 18 |
|
19 | 19 |
/* Timer selection: bits 7 and 6 */ |
20 | 20 |
|
21 |
//#define TIMER_SEL0 0x00 /**< @brief Control Word for Timer 0 */
|
|
22 |
//#define TIMER_SEL1 BIT(6) /**< @brief Control Word for Timer 1 */
|
|
23 |
//#define TIMER_SEL2 BIT(7) /**< @brief Control Word for Timer 2 */
|
|
24 |
//#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
|
|
21 |
#define TIMER_SEL0 0x00 /**< @brief Control Word for Timer 0 */ |
|
22 |
#define TIMER_SEL1 BIT(6) /**< @brief Control Word for Timer 1 */ |
|
23 |
#define TIMER_SEL2 BIT(7) /**< @brief Control Word for Timer 2 */ |
|
24 |
#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */ |
|
25 | 25 |
|
26 | 26 |
/* Register selection: bits 5 and 4 */ |
27 | 27 |
|
28 |
//#define TIMER_LSB BIT(4) /**< @brief Initialize Counter LSB only */
|
|
29 |
//#define TIMER_MSB BIT(5) /**< @brief Initialize Counter MSB only */
|
|
30 |
//#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB) /**< @brief Initialize LSB first and MSB afterwards */
|
|
31 |
//#define TIMER_INMODE_MASK 0x30 /**< @brief Mask for Timer Counter Mode */
|
|
32 |
//#define TIMER_INMODE_POS 4 /**< @brief Bit position of Timer Counter Mode */
|
|
28 |
#define TIMER_LSB BIT(4) /**< @brief Initialize Counter LSB only */ |
|
29 |
#define TIMER_MSB BIT(5) /**< @brief Initialize Counter MSB only */ |
|
30 |
#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB) /**< @brief Initialize LSB first and MSB afterwards */ |
|
31 |
#define TIMER_INMODE_MASK 0x30 /**< @brief Mask for Timer Counter Mode */ |
|
32 |
#define TIMER_INMODE_POS 4 /**< @brief Bit position of Timer Counter Mode */ |
|
33 | 33 |
|
34 | 34 |
/* Operating mode: bits 3, 2 and 1 */ |
35 | 35 |
|
36 |
//#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
|
|
37 |
//#define TIMER_RATE_GEN BIT(2) /**< @brief Mode 2: rate generator */
|
|
38 |
//#define TIMER_MODE_MASK 0x0E /**< @brief Mask for mode */
|
|
39 |
//#define TIMER_MODE_POS 1 /**< @brief Position of smallest bit from mode */
|
|
40 |
//#define TIMER_MODE_2ALT 0x6 /**< @brief Alternative notation for mode 2 */
|
|
41 |
//#define TIMER_MODE_3ALT 0x7 /**< @brief Alternative notation for mode 3 */
|
|
42 |
//#define TIMER_MODE_RED2 0x03 /**< @brief Reduce 3-bit mode to 2-bit mode */
|
|
36 |
#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */ |
|
37 |
#define TIMER_RATE_GEN BIT(2) /**< @brief Mode 2: rate generator */ |
|
38 |
#define TIMER_MODE_MASK 0x0E /**< @brief Mask for mode */ |
|
39 |
#define TIMER_MODE_POS 1 /**< @brief Position of smallest bit from mode */ |
|
40 |
#define TIMER_MODE_2ALT 0x6 /**< @brief Alternative notation for mode 2 */ |
|
41 |
#define TIMER_MODE_3ALT 0x7 /**< @brief Alternative notation for mode 3 */ |
|
42 |
#define TIMER_MODE_RED2 0x03 /**< @brief Reduce 3-bit mode to 2-bit mode */ |
|
43 | 43 |
|
44 | 44 |
/* Counting mode: bit 0 */ |
45 | 45 |
|
46 |
//#define TIMER_BCD 0x01 /**< @brief Count in BCD */
|
|
47 |
//#define TIMER_BIN 0x00 /**< @brief Count in binary */
|
|
46 |
#define TIMER_BCD 0x01 /**< @brief Count in BCD */ |
|
47 |
#define TIMER_BIN 0x00 /**< @brief Count in binary */ |
|
48 | 48 |
|
49 | 49 |
/* READ-BACK COMMAND FORMAT */ |
50 | 50 |
|
51 |
//#define TIMER_RB_COUNT_ BIT(5) /**< @brief Read counter value on read-back (0 to activate) */
|
|
52 |
//#define TIMER_RB_STATUS_ BIT(4) /**< @brief Read status value on read-back (0 to activate) */
|
|
53 |
//#define TIMER_RB_SEL(n) BIT((n) + 1) /**< @brief Select timer to read information from */
|
|
51 |
#define TIMER_RB_COUNT_ BIT(5) /**< @brief Read counter value on read-back (0 to activate) */ |
|
52 |
#define TIMER_RB_STATUS_ BIT(4) /**< @brief Read status value on read-back (0 to activate) */ |
|
53 |
#define TIMER_RB_SEL(n) BIT((n) + 1) /**< @brief Select timer to read information from */ |
|
54 | 54 |
|
55 | 55 |
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id) { |
56 | 56 |
if (interrupt_id == NULL) return 1; |
proj/libs/uart/src/hltp.c | ||
---|---|---|
6 | 6 |
|
7 | 7 |
static void* hltp_interpret_string(const uint8_t *p, const size_t sz){ |
8 | 8 |
void *ret = malloc((sz+1)*sizeof(char)); |
9 |
for(size_t i = 0; i < sz; ++i) ((char*)ret)[i] = p[i]; |
|
9 |
for(size_t i = 0; i < sz; ++i) ((char*)ret)[i] = (char)p[i];
|
|
10 | 10 |
((char*)ret)[sz] = '\0'; |
11 | 11 |
return ret; |
12 | 12 |
} |
13 | 13 |
int hltp_send_string(const char *p){ |
14 | 14 |
uint8_t type = hltp_type_string; |
15 |
uint8_t* ptr[2]; ptr[0] = &type; ptr[1] = (uint8_t*)p;
|
|
16 |
size_t sz[2]; sz [0] = 1; sz [1] = strlen(p); |
|
15 |
const uint8_t* ptr[2]; ptr[0] = &type; ptr[1] = (const uint8_t*)p;
|
|
16 |
size_t sz[2]; sz [0] = 1; sz [1] = strlen(p);
|
|
17 | 17 |
return nctp_send(2, ptr, sz); |
18 | 18 |
} |
19 | 19 |
|
proj/libs/uart/src/uart.c | ||
---|---|---|
113 | 113 |
config->receiver_line_stat_int = UART_GET_INT_EN_RECEIVER_LINE_STAT(config->ier); |
114 | 114 |
config->modem_stat_int = UART_GET_INT_EN_MODEM_STAT (config->ier); |
115 | 115 |
/// DIV LATCH |
116 |
config->divisor_latch = UART_GET_DIV_LATCH(config->dlm, config->dll); |
|
116 |
config->divisor_latch = (uint16_t)UART_GET_DIV_LATCH(config->dlm, config->dll);
|
|
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
static int uart_get_lcr(int base_addr, uint8_t *p){ |
... | ... | |
176 | 176 |
printf("\tLCR = 0x%X: %d bits per char\t %d stop bits\t", config.lcr, config.bits_per_char, config.stop_bits); |
177 | 177 |
if((config.parity&BIT(0)) == 0) printf("NO parity\n"); |
178 | 178 |
else switch(config.parity){ |
179 |
case uart_parity_none: printf("NO parity\n" ); break; |
|
179 | 180 |
case uart_parity_odd : printf("ODD parity\n" ); break; |
180 | 181 |
case uart_parity_even: printf("EVEN parity\n" ); break; |
181 | 182 |
case uart_parity_par1: printf("parity bit is 1\n"); break; |
182 | 183 |
case uart_parity_par0: printf("parity bit is 0\n"); break; |
183 |
default : printf("invalid\n" ); break; |
|
184 |
//default : printf("invalid\n" ); break;
|
|
184 | 185 |
} |
185 | 186 |
printf("\tDLM = 0x%02X DLL=0x%02X: bitrate = %d bps\n", config.dlm, config.dll, UART_BITRATE/config.divisor_latch); |
186 | 187 |
printf("\tIER = 0x%02X: Rx interrupts: %s\tTx interrupts: %s\n", config.ier, |
... | ... | |
200 | 201 |
if(stop != 1 && stop != 2) return INVALID_ARG; |
201 | 202 |
int ret = SUCCESS; |
202 | 203 |
stop -= 1; |
203 |
stop = (stop&1)<<2;
|
|
204 |
stop = (uint8_t)((stop&1)<<2);
|
|
204 | 205 |
uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret; |
205 | 206 |
conf = (conf & (~UART_STOP_BITS)) | stop; |
206 | 207 |
return uart_set_lcr(base_addr, conf); |
207 | 208 |
} |
208 | 209 |
int uart_set_parity(int base_addr, uart_parity par){ |
209 | 210 |
int ret = SUCCESS; |
210 |
uint8_t parity = par << 3;
|
|
211 |
uint8_t parity = (uint8_t)(par << 3);
|
|
211 | 212 |
uint8_t conf; if((ret = uart_get_lcr(base_addr, &conf))) return ret; |
212 | 213 |
conf = (conf & (~UART_PARITY)) | parity; |
213 | 214 |
return uart_set_lcr(base_addr, conf); |
214 | 215 |
} |
215 | 216 |
int uart_set_bit_rate(int base_addr, double bit_rate){ |
216 | 217 |
int ret = SUCCESS; |
217 |
uint16_t latch = UART_BITRATE/bit_rate;
|
|
218 |
uint16_t latch = (uint16_t)(UART_BITRATE/bit_rate);
|
|
218 | 219 |
uint8_t dll = UART_GET_DLL(latch); |
219 | 220 |
uint8_t dlm = UART_GET_DLM(latch); |
220 | 221 |
if((ret = uart_enable_divisor_latch(base_addr))) return ret; |
... | ... | |
282 | 283 |
#define NCTP_OK 0xFF |
283 | 284 |
#define NCTP_NOK 0x00 |
284 | 285 |
|
285 |
queue_t *out = NULL; |
|
286 |
queue_t *in = NULL; |
|
287 |
void (*process)(const uint8_t*, const size_t) = NULL; |
|
286 |
static queue_t *out = NULL;
|
|
287 |
static queue_t *in = NULL;
|
|
288 |
static void (*process)(const uint8_t*, const size_t) = NULL;
|
|
288 | 289 |
|
289 | 290 |
int nctp_init(void){ |
290 | 291 |
out = queue_ctor(); if(out == NULL) return NULL_PTR; |
... | ... | |
374 | 375 |
switch(UART_GET_INT_PEND(iir)){ |
375 | 376 |
case uart_int_rx: nctp_receive (); break; |
376 | 377 |
case uart_int_tx: nctp_transmit(); break; |
377 |
default: break; |
|
378 |
case uart_int_receiver_line_stat: break; |
|
379 |
case uart_int_modem_stat: break; |
|
380 |
case uart_int_char_timeout_fifo: break; |
|
381 |
//default: break; |
|
378 | 382 |
} |
379 | 383 |
} |
380 | 384 |
} |
proj/src/ent.c | ||
---|---|---|
301 | 301 |
return map_collides_gunner_pos(p, gunner_get_x(shooter), gunner_get_y(shooter), radius); |
302 | 302 |
} |
303 | 303 |
int (map_make_dijkstra)(map_t *p, double x_, double y_){ |
304 |
int16_t x = x_, y = y_;
|
|
304 |
int16_t x = (int16_t)x_, y = (int16_t)y_;
|
|
305 | 305 |
|
306 | 306 |
const uint16_t W = basic_sprite_get_w(p->bsp_background), |
307 | 307 |
H = basic_sprite_get_h(p->bsp_background); |
... | ... | |
322 | 322 |
|
323 | 323 |
while(!queue_empty(q)){ |
324 | 324 |
c = *(int*)queue_top(q); free(queue_top(q)); queue_pop(q); |
325 |
x = c%W, y = c/W;
|
|
325 |
x = (int16_t)(c%W), y = (int16_t)(c/W);
|
|
326 | 326 |
if(p->visited[c]) continue; |
327 | 327 |
p->visited[c] = true; |
328 | 328 |
if(p->collide_gunner[c]) continue; |
... | ... | |
338 | 338 |
} |
339 | 339 |
int (map_where_to_follow)(const map_t *p, double x, double y, double *theta){ |
340 | 340 |
const uint16_t W = basic_sprite_get_w(p->bsp_background); |
341 |
int x_ = x, y_ = y; |
|
342 |
int pos = y_*W+x_; |
|
343 |
//printf("Is in %d,%d\n", x_, y_); |
|
344 |
int newx = p->prev[pos]%W, newy = p->prev[pos]/W; |
|
345 |
//printf("from %d,%d to %d,%d\n", x_, y_, newx, newy); |
|
341 |
int16_t x_ = (int16_t)x, y_ = (int16_t)y; |
|
342 |
int32_t pos = y_*W+x_; |
|
343 |
int16_t newx = (int16_t)(p->prev[pos]%W), newy = (int16_t)(p->prev[pos]/W); |
|
346 | 344 |
*theta = atan2(-(newy-y_), newx-x_); |
347 | 345 |
return SUCCESS; |
348 | 346 |
} |
proj/src/makecode_map.c | ||
---|---|---|
1 | 1 |
#include "makecode_map.h" |
2 | 2 |
|
3 |
const char makecode_map[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\'', ERROR_CODE /*«*/, ERROR_CODE /*escape*/, |
|
4 |
ERROR_CODE /*tab*/, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '+', ERROR_CODE /* ´ */, ERROR_CODE /*enter*/, |
|
5 |
ERROR_CODE /*ctrl*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ERROR_CODE /* Ç */, ERROR_CODE /* º */, '\\', ERROR_CODE /*lshift*/, '~', |
|
6 |
'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '-', ERROR_CODE /*rshift*/, ERROR_CODE /*unkown*/, ERROR_CODE /*alt*/, ' ' /*space*/}; |
|
3 |
static const char makecode_map[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\'', ERROR_CODE /*«*/, ERROR_CODE /*escape*/,
|
|
4 |
ERROR_CODE /*tab*/, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '+', ERROR_CODE /* ´ */, ERROR_CODE /*enter*/,
|
|
5 |
ERROR_CODE /*ctrl*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ERROR_CODE /* Ç */, ERROR_CODE /* º */, '\\', ERROR_CODE /*lshift*/, '~',
|
|
6 |
'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '-', ERROR_CODE /*rshift*/, ERROR_CODE /*unkown*/, ERROR_CODE /*alt*/, ' ' /*space*/};
|
|
7 | 7 |
|
8 |
const int size = sizeof(makecode_map); |
|
8 |
static const int size = sizeof(makecode_map);
|
|
9 | 9 |
|
10 |
|
|
11 | 10 |
char (map_makecode)(uint8_t code) { |
12 | 11 |
int key = code - BASE_CODE; |
13 | 12 |
if (key < 0 || key >= size) return ERROR_CODE; |
proj/src/proj_func.c | ||
---|---|---|
65 | 65 |
free(p); |
66 | 66 |
} |
67 | 67 |
|
68 |
remote_info_t* remote_info_ctor() { |
|
68 |
remote_info_t* remote_info_ctor(void) {
|
|
69 | 69 |
remote_info_t *ret = (remote_info_t*)malloc(sizeof(remote_info_t)); |
70 | 70 |
if (ret == NULL) return ret; |
71 | 71 |
|
... | ... | |
81 | 81 |
free(p); |
82 | 82 |
} |
83 | 83 |
|
84 |
bullet_info_t* bullet_info_ctor() { |
|
84 |
bullet_info_t* bullet_info_ctor(void) {
|
|
85 | 85 |
bullet_info_t *ret = (bullet_info_t*)malloc(sizeof(bullet_info_t)); |
86 | 86 |
if (ret == NULL) return ret; |
87 | 87 |
|
... | ... | |
117 | 117 |
} |
118 | 118 |
|
119 | 119 |
void update_movement(map_t *map, gunner_t *p, keys_t *keys, list_t *shooter_list) { |
120 |
int ver_mov = keys->s_pressed - keys->w_pressed; |
|
121 |
int hor_mov = keys->d_pressed - keys->a_pressed; |
|
122 |
double x = gunner_get_x(p); |
|
123 |
double y = gunner_get_y(p); |
|
120 |
/** Player movement */{ |
|
121 |
int ver_mov = keys->s_pressed - keys->w_pressed; |
|
122 |
int hor_mov = keys->d_pressed - keys->a_pressed; |
|
123 |
double x = gunner_get_x(p); |
|
124 |
double y = gunner_get_y(p); |
|
124 | 125 |
|
125 |
gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y); |
|
126 |
if (map_collides_gunner(map, p)) gunner_set_pos(p, x, y); |
|
127 |
else { |
|
128 |
list_node_t *it = list_begin(shooter_list); |
|
129 |
while (it != list_end(shooter_list)) { |
|
130 |
gunner_t *p2 = *(gunner_t**)list_node_val(it); |
|
131 |
if (p != p2 && gunner_collides_gunner(p, p2)) { |
|
132 |
gunner_set_pos(p, x, y); |
|
133 |
break; |
|
126 |
gunner_set_pos(p, x + SHOOTER_SPEED * hor_mov, y); |
|
127 |
if (map_collides_gunner(map, p)) gunner_set_pos(p, x, y); |
|
128 |
else { |
|
129 |
list_node_t *it = list_begin(shooter_list); |
|
130 |
while (it != list_end(shooter_list)) { |
|
131 |
gunner_t *p2 = *(gunner_t**)list_node_val(it); |
|
132 |
if (p != p2 && gunner_collides_gunner(p, p2)) { |
|
133 |
gunner_set_pos(p, x, y); |
|
134 |
break; |
|
135 |
} |
|
136 |
it = list_node_next(it); |
|
134 | 137 |
} |
135 |
it = list_node_next(it); |
|
136 | 138 |
} |
137 |
} |
|
138 |
x = gunner_get_x(p); |
|
139 |
gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov); |
|
140 |
if (map_collides_gunner(map, p)) gunner_set_pos(p, x, y); |
|
141 |
else { |
|
142 |
list_node_t *it = list_begin(shooter_list); |
|
143 |
while (it != list_end(shooter_list)) { |
|
144 |
gunner_t *p2 = *(gunner_t**)list_node_val(it); |
|
145 |
if (p != p2 && gunner_collides_gunner(p, p2)) { |
|
146 |
gunner_set_pos(p, x, y); |
|
147 |
break; |
|
139 |
x = gunner_get_x(p); |
|
140 |
gunner_set_pos(p, x, y + SHOOTER_SPEED * ver_mov); |
|
141 |
if (map_collides_gunner(map, p)) gunner_set_pos(p, x, y); |
|
142 |
else { |
|
143 |
list_node_t *it = list_begin(shooter_list); |
|
144 |
while (it != list_end(shooter_list)) { |
|
145 |
gunner_t *p2 = *(gunner_t**)list_node_val(it); |
|
146 |
if (p != p2 && gunner_collides_gunner(p, p2)) { |
|
147 |
gunner_set_pos(p, x, y); |
|
148 |
break; |
|
149 |
} |
|
150 |
it = list_node_next(it); |
|
148 | 151 |
} |
149 |
it = list_node_next(it); |
|
150 | 152 |
} |
151 | 153 |
} |
152 |
|
|
153 |
// Update zombie positions |
|
154 |
list_node_t *it = list_begin(shooter_list); |
|
155 |
while(it != list_end(shooter_list)){ |
|
156 |
gunner_t *g = *(gunner_t**)list_node_val(it); |
|
157 |
if(gunner_get_type(g) & GUNNER_FOLLOW){ |
|
158 |
double theta = 0.0; |
|
159 |
map_where_to_follow(map, gunner_get_x(g), gunner_get_y(g), &theta); |
|
160 |
double c = fm_cos(theta), s = fm_sin(theta); |
|
161 |
double dx = ZOMBIE_SPEED*c, dy = -ZOMBIE_SPEED*s; |
|
162 |
double x = gunner_get_x(g); |
|
163 |
double y = gunner_get_y(g); |
|
164 |
gunner_set_pos(g, x+dx, y+dy); |
|
165 |
if (map_collides_gunner(map, g)){ |
|
166 |
//printf("Zombie colliding with map\n"); |
|
167 |
gunner_set_pos(g, x, y); |
|
168 |
} else { |
|
169 |
list_node_t *it = list_begin(shooter_list); |
|
170 |
while (it != list_end(shooter_list)) { |
|
171 |
gunner_t *p2 = *(gunner_t**)list_node_val(it); |
|
172 |
if (g != p2 && gunner_collides_gunner(g, p2)) { |
|
173 |
//printf("Zombie colliding with zombie\n"); |
|
174 |
gunner_set_pos(g, x, y); |
|
175 |
break; |
|
154 |
/** Followers movement */ { |
|
155 |
list_node_t *it = list_begin(shooter_list); |
|
156 |
while(it != list_end(shooter_list)){ |
|
157 |
gunner_t *g = *(gunner_t**)list_node_val(it); |
|
158 |
if(gunner_get_type(g) & GUNNER_FOLLOW){ |
|
159 |
double theta = 0.0; |
|
160 |
map_where_to_follow(map, gunner_get_x(g), gunner_get_y(g), &theta); |
|
161 |
double c = fm_cos(theta), s = fm_sin(theta); |
|
162 |
double dx = ZOMBIE_SPEED*c, dy = -ZOMBIE_SPEED*s; |
|
163 |
double x = gunner_get_x(g); |
|
164 |
double y = gunner_get_y(g); |
|
165 |
gunner_set_pos(g, x+dx, y+dy); |
|
166 |
if (map_collides_gunner(map, g)){ |
|
167 |
gunner_set_pos(g, x, y); |
|
168 |
} else { |
|
169 |
list_node_t *it2 = list_begin(shooter_list); |
|
170 |
while (it2 != list_end(shooter_list)) { |
|
171 |
gunner_t *p2 = *(gunner_t**)list_node_val(it2); |
|
172 |
if (g != p2 && gunner_collides_gunner(g, p2)) { |
|
173 |
gunner_set_pos(g, x, y); |
|
174 |
break; |
|
175 |
} |
|
176 |
it2 = list_node_next(it2); |
|
176 | 177 |
} |
177 |
it = list_node_next(it); |
|
178 | 178 |
} |
179 |
gunner_set_angle(g, theta-M_PI_2); |
|
179 | 180 |
} |
180 |
gunner_set_angle(g, theta-M_PI_2); /*printf("angle: %d.%d\n", (int)theta, abs((int)(theta*1000)%1000));*/
|
|
181 |
it = list_node_next(it);
|
|
181 | 182 |
} |
182 |
it = list_node_next(it); |
|
183 | 183 |
} |
184 | 184 |
} |
185 | 185 |
|
... | ... | |
298 | 298 |
|
299 | 299 |
void (update_mouse)(struct packet *p) { |
300 | 300 |
mouse_x = max16(0, mouse_x + p->delta_x); |
301 |
mouse_x = min16(mouse_x, graph_get_XRes() - 1); |
|
301 |
mouse_x = min16(mouse_x, (int16_t)graph_get_XRes() - 1);
|
|
302 | 302 |
|
303 | 303 |
mouse_y = max16(0, mouse_y - p->delta_y); |
304 |
mouse_y = min16(mouse_y, graph_get_YRes() - 1); |
|
304 |
mouse_y = min16(mouse_y, (int16_t)graph_get_YRes() - 1);
|
|
305 | 305 |
|
306 | 306 |
key_presses.lb_pressed = p->lb; |
307 | 307 |
} |
proj/Makefile | ||
---|---|---|
9 | 9 |
.PATH: ${.CURDIR}/libs/classes/src |
10 | 10 |
.PATH: ${.CURDIR}/libs/utils/src |
11 | 11 |
|
12 |
SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c menu.c proj.c proj_func.c rectangle.c font.c
|
|
12 |
SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c rtc.c uart.c makecode_map.c menu.c proj_func.c rectangle.c font.c ent.c proj.c hltp.c
|
|
13 | 13 |
IPATHS=-I./include -I./libs/graph/include -I./libs/kbc/include -I./libs/rtc/include -I./libs/timer/include -I./libs/uart/include -I./libs/classes/include -I./libs/utils/include -I./maps -I./media/xpm |
14 | 14 |
|
15 |
CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__ #-Weverything
|
|
15 |
CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__ -Weverything -Wno-padded -Wno-unused-macros
|
|
16 | 16 |
|
17 | 17 |
|
18 | 18 |
DPADD += ${LIBLCF} |
Also available in: Unified diff