Revision 178
minor fixes
proj/include/graph.h | ||
---|---|---|
1 | 1 |
#ifndef GRAPH_H_INCLUDED |
2 | 2 |
#define GRAPH_H_INCLUDED |
3 | 3 |
|
4 |
#include <lcom/lcf.h> |
|
5 |
#include <stdint.h> |
|
6 |
|
|
7 | 4 |
/// MACROS |
8 | 5 |
//#define GET_ALP(n) (0xFF & ((n) >> 24)) |
9 | 6 |
#define GET_RED(n) (0xFF & ((n) >> 16)) |
proj/include/i8254.h | ||
---|---|---|
1 | 1 |
#ifndef _LCOM_I8254_H_ |
2 | 2 |
#define _LCOM_I8254_H_ |
3 | 3 |
|
4 |
#include <lcom/lcf.h> |
|
5 |
|
|
6 | 4 |
/** @defgroup i8254 i8254 |
7 | 5 |
* |
8 | 6 |
* Constants for programming the i8254 Timer. Needs to be completed. |
proj/include/interrupts_func.h | ||
---|---|---|
1 | 1 |
#ifndef INTERRUPTS_FUNC_H_INCLUDED |
2 | 2 |
#define INTERRUPTS_FUNC_H_INCLUDED |
3 | 3 |
|
4 |
#include <stdint.h> |
|
5 |
|
|
6 | 4 |
/** |
7 | 5 |
* @brief Subscribes all drivers used (timer->keyboard->mouse) |
8 | 6 |
* @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK |
proj/include/mouse.h | ||
---|---|---|
1 | 1 |
#ifndef MOUSE_H_INCLUDED |
2 | 2 |
#define MOUSE_H_INCLUDED |
3 | 3 |
|
4 |
#include <stdint.h> |
|
5 |
|
|
6 | 4 |
/** |
7 | 5 |
* @brief Subscribes Mouse Interrupts and disables Minix Default IH |
8 | 6 |
* @param interrupt_bit Bit of Interrupt Vector that will be set when Mouse Interrupt is pending |
proj/include/rectangle.h | ||
---|---|---|
1 |
#ifndef RECTANGLE_H_INCLUDED |
|
2 |
#define RECTANGLE_H_INCLUDED |
|
3 |
|
|
4 |
struct rectangle; |
|
5 |
typedef struct rectangle rectangle_t; |
|
6 |
|
|
7 |
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h); |
|
8 |
void (rectangle_dtor)(rectangle_t *p); |
|
9 |
|
|
10 |
#endif //RECTANGLE_H_INCLUDED |
|
0 | 11 |
proj/include/sprite.h | ||
---|---|---|
13 | 13 |
void (sprite_set_angle) (sprite_t *p, double angle); |
14 | 14 |
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0); |
15 | 15 |
|
16 |
int sprite_get_x(const sprite_t *p);
|
|
17 |
int sprite_get_y(const sprite_t *p);
|
|
18 |
int sprite_get_w(const sprite_t *p);
|
|
19 |
int sprite_get_h(const sprite_t *p);
|
|
16 |
int16_t (sprite_get_x)(const sprite_t *p);
|
|
17 |
int16_t (sprite_get_y)(const sprite_t *p);
|
|
18 |
uint16_t (sprite_get_w)(const sprite_t *p);
|
|
19 |
uint16_t (sprite_get_h)(const sprite_t *p);
|
|
20 | 20 |
|
21 | 21 |
void (sprite_draw)(const sprite_t *p); |
22 | 22 |
|
proj/include/timer.h | ||
---|---|---|
5 | 5 |
#ifndef TIMER_H_INCLUDED |
6 | 6 |
#define TIMER_H_INCLUDED |
7 | 7 |
|
8 |
#include <stdint.h> |
|
9 |
|
|
10 | 8 |
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
11 | 9 |
|
12 | 10 |
uint32_t no_interrupts; |
proj/src/fast_math.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
1 | 3 |
#include "fast_math.h" |
2 | 4 |
|
3 | 5 |
#include <math.h> |
proj/src/graph.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
1 | 3 |
#include "graph.h" |
2 | 4 |
#include "graph_macros.h" |
3 | 5 |
#include "errors.h" |
4 | 6 |
|
5 |
#include <lcom/lcf.h> |
|
6 |
|
|
7 | 7 |
#include <stdio.h> |
8 | 8 |
|
9 | 9 |
/// MACROS |
... | ... | |
55 | 55 |
//} |
56 | 56 |
|
57 | 57 |
/// MEMORY |
58 |
static void *video_mem = NULL; /** @brief Frame-buffer VM address. */
|
|
58 |
static uint8_t *video_mem = NULL; /** @brief Frame-buffer VM address. */
|
|
59 | 59 |
static uint8_t *video_buf = NULL; /** @brief Primary buffer for drawing before copying to video_mem. */ |
60 | 60 |
static mmap_t mem_map; |
61 | 61 |
static int (graph_free_memory)(void) { |
... | ... | |
276 | 276 |
} |
277 | 277 |
|
278 | 278 |
int (graph_draw)(void){ |
279 |
memcpy((uint8_t*)video_mem, video_buf, graph_get_vram_size());
|
|
279 |
memcpy(video_mem, video_buf, graph_get_vram_size()); |
|
280 | 280 |
return 0; |
281 | 281 |
} |
282 | 282 |
|
proj/src/interrupts_func.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
1 | 3 |
#include "interrupts_func.h" |
2 | 4 |
#include "timer.h" |
3 | 5 |
#include "i8254.h" |
... | ... | |
7 | 9 |
#include "utils.h" |
8 | 10 |
#include "errors.h" |
9 | 11 |
|
10 |
#include <lcom/lcf.h> |
|
11 |
|
|
12 | 12 |
static int timer_subscribed = 0, timer_id; |
13 | 13 |
|
14 | 14 |
static int keyboard_subscribed = 0, kbc_id; |
proj/src/rectangle.c | ||
---|---|---|
1 |
#include <lcom/lcf.h> |
|
2 |
|
|
3 |
#include "rectangle.h" |
|
4 |
|
|
5 |
struct rectangle{ |
|
6 |
int16_t x, y; |
|
7 |
uint16_t w, h; |
|
8 |
uint32_t fill_color; |
|
9 |
uint32_t outline_color; |
|
10 |
uint16_t outline_width; |
|
11 |
}; |
|
12 |
|
|
13 |
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){ |
|
14 |
rectangle_t *ret = (rectangle_t*)malloc(sizeof(rectangle_t)); |
|
15 |
|
|
16 |
return ret; |
|
17 |
} |
|
18 |
void (rectangle_dtor)(rectangle_t *p){ |
|
19 |
if(p == NULL) return; |
|
20 |
free(p); |
|
21 |
} |
|
0 | 22 |
proj/src/sprite.c | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
void (sprite_dtor)(sprite_t *p){ |
38 | 38 |
if(p == NULL) return; |
39 |
if(p->map) free(p->map);
|
|
39 |
free(p->map); |
|
40 | 40 |
free(p); |
41 | 41 |
} |
42 | 42 |
|
... | ... | |
46 | 46 |
void (sprite_set_angle) (sprite_t *p, double angle){ p->theta = angle; } |
47 | 47 |
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0){ p->u0 = u0; p->v0 = v0; } |
48 | 48 |
|
49 |
int sprite_get_x(const sprite_t *p){ return p->x; }
|
|
50 |
int sprite_get_y(const sprite_t *p){ return p->y; }
|
|
51 |
int sprite_get_w(const sprite_t *p){ return p->w; }
|
|
52 |
int sprite_get_h(const sprite_t *p){ return p->h; }
|
|
49 |
int16_t (sprite_get_x)(const sprite_t *p){ return p->x; }
|
|
50 |
int16_t (sprite_get_y)(const sprite_t *p){ return p->y; }
|
|
51 |
uint16_t (sprite_get_w)(const sprite_t *p){ return p->w; }
|
|
52 |
uint16_t (sprite_get_h)(const sprite_t *p){ return p->h; }
|
|
53 | 53 |
|
54 | 54 |
void (sprite_src2pic)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){ |
55 | 55 |
int16_t dx = x - p->x; |
proj/DR.mk | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c
|
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D DIOGO -D __LCOM_OPTIMIZED_ |
8 | 8 |
|
proj/Makefile | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c
|
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D __LCOM_OPTIMIZED_ |
8 | 8 |
|
proj/TB.mk | ||
---|---|---|
2 | 2 |
|
3 | 3 |
.PATH: ${.CURDIR}/src |
4 | 4 |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c |
|
5 |
SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c
|
|
6 | 6 |
|
7 | 7 |
CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D TELMO #-D __LCOM_OPTIMIZED_ |
8 | 8 |
|
Also available in: Unified diff