Index: proj/DR.mk
===================================================================
--- proj/DR.mk	(nonexistent)
+++ proj/DR.mk	(revision 152)
@@ -0,0 +1,10 @@
+PROG=proj
+
+SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c
+
+CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_ -D DIOGO
+
+DPADD += ${LIBLCF}
+LDADD += -llcf
+
+.include <minix.lcom.mk>

Property changes on: proj/DR.mk
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/TB.mk
===================================================================
--- proj/TB.mk	(nonexistent)
+++ proj/TB.mk	(revision 152)
@@ -0,0 +1,10 @@
+PROG=proj
+
+SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c
+
+CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_ -D TELMO
+
+DPADD += ${LIBLCF}
+LDADD += -llcf
+
+.include <minix.lcom.mk>

Property changes on: proj/TB.mk
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/proj.c
===================================================================
--- proj/proj.c	(revision 151)
+++ proj/proj.c	(revision 152)
@@ -36,6 +36,25 @@
 
 int(proj_main_loop)(int argc, char *argv[]) {
 
+    if (vbe_get_mode_information(INDEXED_1024_768)) {
+        printf("%s: failed to get information for mode %x.\n", __func__, INDEXED_1024_768);
+        if (vg_exit())
+            printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+        return 1;
+    }
+
+    map_vram(); // if function fails it aborts program
+
+    if (set_graphics_mode(INDEXED_1024_768)) {
+        printf("%s: failed to set graphic mode %x.\n", __func__, INDEXED_1024_768);
+        if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+        if (free_memory_map()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        return 1;
+    };
+
+
     /// loop stuff
     int ipc_status, r;
     message msg;
@@ -117,5 +136,25 @@
     if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
     if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts
 
+    
+    if (vg_exit()) {
+        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+        if (free_memory_map()) printf("%s: lm_free failed\n", __func__);
+        return 1;
+    }
+
+    if (free_memory_map()) {
+        printf("%s: lm_free failed\n", __func__);
+        return 1;
+    }
+
+    
+    #ifdef DIOGO
+        hello
+    #endif
+
+
     return 0;
+
+    return 0;
 }
Index: proj/sprite.c
===================================================================
--- proj/sprite.c	(nonexistent)
+++ proj/sprite.c	(revision 152)
@@ -0,0 +1,52 @@
+#include <lcom/lcf.h>
+
+#include "sprite.h"
+
+#include "graphics.h"
+
+struct sprite{
+    int x, y;
+    int w, h;
+    uint8_t *map;
+};
+
+sprite_t* sprite_ctor(const xpm_map_t xpm){
+    sprite_t *ret = (sprite_t*)malloc(sizeof(sprite_t));
+    if(ret == NULL) return NULL;
+    enum xpm_image_type type = XPM_INDEXED;
+    xpm_image_t img;
+    ret->map = xpm_load(xpm, type, &img);
+    if(ret->map == NULL){
+        free(ret);
+        return NULL;
+    }
+    ret->w = img.width;
+    ret->h = img.height;
+    return ret;
+}
+
+void sprite_dtor(sprite_t *p){
+    if(p == NULL) return;
+    if(p->map) free(p->map);
+    free(p);
+}
+
+void sprite_set_x(sprite_t *p, int x){ p->x = x; }
+void sprite_set_y(sprite_t *p, int y){ p->y = y; }
+void sprite_set_pos(sprite_t *p, int x, int y){
+    sprite_set_x(p, x);
+    sprite_set_y(p, y);
+}
+
+int sprite_get_w(const sprite_t *p){ return p->w; }
+int sprite_get_h(const sprite_t *p){ return p->h; }
+
+void sprite_draw(const sprite_t *p){
+    for (int i = 0; i < p->w; i++) {
+        for (int j = 0; j < p->h; j++) {
+            if (p->x + i < get_XRes() && p->y + j < get_YRes()) {
+                set_pixel(p->x + i, p->y + j, p->map[i + j * p->w]);
+            }
+        }
+    }
+}

Property changes on: proj/sprite.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/sprite.h
===================================================================
--- proj/sprite.h	(nonexistent)
+++ proj/sprite.h	(revision 152)
@@ -0,0 +1,19 @@
+#ifndef SPRITE_H_INCLUDED
+#define SPRITE_H_INCLUDED
+
+struct sprite;
+typedef struct sprite sprite_t;
+
+sprite_t* sprite_ctor(const xpm_map_t xpm);
+void      sprite_dtor(sprite_t *p);
+
+void sprite_set_x(sprite_t *p, int x);
+void sprite_set_y(sprite_t *p, int y);
+void sprite_set_pos(sprite_t *p, int x, int y);
+
+int sprite_get_h(const sprite_t *p);
+int sprite_get_w(const sprite_t *p);
+
+void sprite_draw(const sprite_t *p);
+
+#endif //SPRITE_H_INCLUDED

Property changes on: proj/sprite.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
