Index: proj/font/png
===================================================================
--- proj/font/png	(nonexistent)
+++ proj/font/png	(revision 182)

Property changes on: proj/font/png
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+*.png
Index: proj/font/xpm2
===================================================================
--- proj/font/xpm2	(nonexistent)
+++ proj/font/xpm2	(revision 182)

Property changes on: proj/font/xpm2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+*.xpm2
Index: proj/font/setup.sh
===================================================================
--- proj/font/setup.sh	(nonexistent)
+++ proj/font/setup.sh	(revision 182)
@@ -0,0 +1,2 @@
+python3 split_font.py
+python3 xpm_to_xpm2.py

Property changes on: proj/font/setup.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/font/setup_clean.sh
===================================================================
--- proj/font/setup_clean.sh	(nonexistent)
+++ proj/font/setup_clean.sh	(revision 182)
@@ -0,0 +1,3 @@
+rm -f png/*.png
+rm -f xpm/*.xpm
+rm -f xpm2/*.xpm2
\ No newline at end of file

Property changes on: proj/font/setup_clean.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/font/split_font.py
===================================================================
--- proj/font/split_font.py	(revision 181)
+++ proj/font/split_font.py	(revision 182)
@@ -11,18 +11,36 @@
 
 i = 32
 
+with open("font.h", 'w') as f:
+    includes = ""
+    lst = ""
 
+    for j in range(i):
+        if lst != "": lst += ","
+        lst += "NULL"
 
-for h in range(Nh):
-    t = int(H/Nh)*h
-    b = int(H/Nh)*(h+1)
-    for w in range(Nw):
-        #l = int((W*w)/Nw)
-        #r = int((W*(w+1))/Nw)
-        l = 59*w
-        r = 59*(w+1)
-        im1 = im.crop((l,t,r,b))
-        im1.save("%03d.png"%i)
-        os.system("convert %03d.png xpm/%03d.xpm"%(i,i))
-        os.system("rm %03d.png"%i)
-        i += 1
+
+    for h in range(Nh):
+        t = int(H/Nh)*h
+        b = int(H/Nh)*(h+1)
+        for w in range(Nw):
+            #l = int((W*w)/Nw)
+            #r = int((W*(w+1))/Nw)
+            l = 59*w
+            r = 59*(w+1)
+            im1 = im.crop((l,t,r,b))
+            im1.save("png/ascii%03d.png"%i)
+            os.system("convert png/ascii%03d.png xpm/ascii%03d.xpm"%(i,i))
+
+            
+            includes += '#include "%03d.xpm"\n'%i
+            if lst != "": lst += ","
+            lst += "%03d_xpm"%i
+
+            #DEV
+            os.system("rm png/ascii%03d.png"%i)
+
+            i += 1
+
+    f.write(includes)
+    f.write("xpm_map_t font[] = {"+lst+"}\n")
\ No newline at end of file
Index: proj/font/xpm_to_xpm2.py
===================================================================
--- proj/font/xpm_to_xpm2.py	(nonexistent)
+++ proj/font/xpm_to_xpm2.py	(revision 182)
@@ -0,0 +1,19 @@
+import glob
+import os
+
+files = [s[4:12] for s in glob.glob("xpm/*.xpm")]
+files.sort()
+
+with open("convert.c", 'w') as f:
+    f.write('#include "xpm_utils.h"\n')
+    f.write("".join(['#include "%s.xpm"\n'%s for s in files]))
+    f.write("int main(){\n")
+    f.write("".join(['    xpm_save_as_xpm2(%s,"xpm2/%s.xpm2");\n'%(s,s) for s in files]))
+    f.write('    char **r = xpm_load_xpm2("xpm2/ascii065.xpm2");\n')
+    f.write("    return 0;\n}\n")
+
+os.system("gcc -I./xpm -I../include convert.c ../src/xpm_utils.c -o convert.app")
+os.system("./convert.app")
+
+os.system("rm -f convert.c convert.app")
+os.system("rm -f xpm/*.xpm")

Property changes on: proj/font/xpm_to_xpm2.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/include/font.h
===================================================================
--- proj/include/font.h	(nonexistent)
+++ proj/include/font.h	(revision 182)
@@ -0,0 +1,12 @@
+#ifndef FONT_H_INCLUDED
+#define FONT_H_INCLUDED
+
+struct glyph;
+typedef struct glyph glyph_t;
+
+glyph_t* (glyph_ctor)(const char **xpm);
+void     (glyph_dtor)(glyph_t *p);
+
+//glyph_t** (get_font)(const char *s);
+
+#endif //FONT_H_INCLUDED

Property changes on: proj/include/font.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/include/xpm_utils.h
===================================================================
--- proj/include/xpm_utils.h	(nonexistent)
+++ proj/include/xpm_utils.h	(revision 182)
@@ -0,0 +1,8 @@
+#ifndef XMP_UTILS_H_INCLUDED
+#define XMP_UTILS_H_INCLUDED
+
+void xpm_save_as_xpm2(char **p, const char *s);
+
+char** xpm_load_xpm2(const char *s);
+
+#endif //XMP_UTILS_H_INCLUDED
\ No newline at end of file

Property changes on: proj/include/xpm_utils.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/font.c
===================================================================
--- proj/src/font.c	(nonexistent)
+++ proj/src/font.c	(revision 182)
@@ -0,0 +1,29 @@
+#include <lcom/lcf.h>
+
+#include "font.h"
+
+struct glyph{
+    uint16_t w, h;
+    uint8_t *map;
+};
+
+glyph_t* (glyph_ctor)(const char **xpm){
+    glyph_t *ret = malloc(sizeof(glyph_t));
+    if(ret == NULL) return NULL;
+    enum xpm_image_type type = XPM_8_8_8_8;
+    xpm_image_t img;
+    ret->map = xpm_load((xpm_map_t)xpm, type, &img);
+    if(ret->map == NULL){
+        free(ret);
+        return NULL;
+    }
+    ret->w = img.width;
+    ret->h = img.height;
+    return ret;
+}
+
+void (glyph_dtor)(glyph_t *p){
+    if(p == NULL) return;
+    free(p->map);
+    free(p);
+}

Property changes on: proj/src/font.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/proj.c
===================================================================
--- proj/src/proj.c	(revision 181)
+++ proj/src/proj.c	(revision 182)
@@ -14,10 +14,8 @@
 #include "graph.h"
 #include "sprite.h"
 #include "rectangle.h"
+#include "font.h"
 
-#ifdef DIOGO
-    #include "shooter.h"
-#endif
 #ifdef TELMO
     #include "crosshair.h"
 #endif
@@ -85,6 +83,9 @@
 
         graph_draw();
         */
+
+
+
     #endif
 
     #ifdef TELMO
Index: proj/src/sprite.c
===================================================================
--- proj/src/sprite.c	(revision 181)
+++ proj/src/sprite.c	(revision 182)
@@ -11,7 +11,7 @@
     int16_t x, y;
     uint16_t w, h;
     int16_t u0, v0;
-    float theta;
+    double theta;
     uint8_t *map;
 };
 
Index: proj/src/xpm_utils.c
===================================================================
--- proj/src/xpm_utils.c	(nonexistent)
+++ proj/src/xpm_utils.c	(revision 182)
@@ -0,0 +1,47 @@
+#ifdef LCOM_MACRO
+    #include <lcom/lcf.h>
+#endif
+
+#include "xpm_utils.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void xpm_save_as_xpm2(char **p, const char *s){
+    FILE *f = fopen(s, "w");
+    int w, h, num_colors, chars_per_pixel;
+    sscanf(p[0], "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
+    for(int i = 0; i < 1+num_colors+h; ++i){
+        fprintf(f, "%s\n", p[i]);
+    }
+    fclose(f); f = NULL;
+}
+
+char** xpm_load_xpm2(const char *fpath){
+    FILE *f = fopen(fpath, "r");
+    if(f == NULL) return NULL;
+    char *line_buf = malloc(1024*sizeof(char)); size_t len = 1024;
+    int sz;
+
+    char **ret = NULL;
+
+    int w, h, num_colors, chars_per_pixel;
+
+    sz = getline(&line_buf, &len, f);{
+        sscanf(line_buf, "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
+        ret = malloc((1+num_colors+h)*sizeof(char*));
+    }
+    ret[0] = malloc((sz+1)*sizeof(char));
+    strcpy(ret[0], line_buf);
+    
+    for(int i = 1; i < 1+num_colors+h; ++i){
+        sz = getline(&line_buf, &len, f);
+        ret[i] = malloc((sz+1)*sizeof(char));
+        strcpy(ret[i], line_buf);
+        ret[i][sz-1] = '\0';
+        printf("%s\n", ret[i]);
+    }
+    fclose(f); f = NULL;
+    return ret;
+}

Property changes on: proj/src/xpm_utils.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/DR.mk
===================================================================
--- proj/DR.mk	(revision 181)
+++ proj/DR.mk	(revision 182)
@@ -2,9 +2,9 @@
 
 .PATH: ${.CURDIR}/src
 
-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
+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 font.c
 
-CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D DIOGO -D __LCOM_OPTIMIZED_
+CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D DIOGO -D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/Makefile
===================================================================
--- proj/Makefile	(revision 181)
+++ proj/Makefile	(revision 182)
@@ -2,9 +2,9 @@
 
 .PATH: ${.CURDIR}/src
 
-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
+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 font.c
 
-CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D __LCOM_OPTIMIZED_
+CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/TB.mk
===================================================================
--- proj/TB.mk	(revision 181)
+++ proj/TB.mk	(revision 182)
@@ -2,9 +2,9 @@
 
 .PATH: ${.CURDIR}/src
 
-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
+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 font.c
 
-CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D TELMO #-D __LCOM_OPTIMIZED_
+CPPFLAGS += -pedantic -I./include -I./bmp -I./xpm -D LCOM_MACRO -D TELMO #-D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/setup.sh
===================================================================
--- proj/setup.sh	(nonexistent)
+++ proj/setup.sh	(revision 182)
@@ -0,0 +1,2 @@
+cd font
+./setup.sh
\ No newline at end of file

Property changes on: proj/setup.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/setup_clean.sh
===================================================================
--- proj/setup_clean.sh	(nonexistent)
+++ proj/setup_clean.sh	(revision 182)
@@ -0,0 +1,2 @@
+cd font
+./setup_clean.sh
\ No newline at end of file

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