diff --git a/.gitignore b/.gitignore index ea197fd..d0ea227 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ lib/ *g1a +/tools/mapconv/mapconv diff --git a/microfx_src/Makefile b/microfx_src/Makefile index e33de99..328275f 100644 --- a/microfx_src/Makefile +++ b/microfx_src/Makefile @@ -13,7 +13,8 @@ SRC = src/start.c \ src/gui.c \ src/memory.c \ src/rtc.c \ - src/ext/img.c + src/ext/img.c \ + src/ext/gametools/map.c OBJ = $(SRC:src/%=build/%.o) CFLAGS = -Os -Wall -Wextra -Wpedantic -Werror -std=c89 diff --git a/microfx_src/include/microfx/ext/gametools.h b/microfx_src/include/microfx/ext/gametools.h new file mode 100644 index 0000000..512f1b4 --- /dev/null +++ b/microfx_src/include/microfx/ext/gametools.h @@ -0,0 +1,29 @@ +#ifndef GAMETOOLS_H +#define GAMETOOLS_H + +/******* MAP *******/ + +/* Struct */ + +typedef struct { + unsigned char *map; /* Map data (size w*h) + the tile 0 contains nothing, and the other tiles are decremented and grabbed + in tileset, so 1 is the first tile in tileset. */ + unsigned char **tileset; /* Tileset (Sprite Coder sprite table) */ + int w, h; /* Map width and height */ + int tw, th; /* Tile width and height */ + int px, py; /* Contains the position of the player on the screen, after + drawing the map */ +} MMap; + +/* Prototypes */ + +/* void dmap(int sx, int sy, MMap *map); + +Draws a map contained in a MMap struct. +dmap draw the map from sx, sy. +*/ + +void vmap(int sx, int sy, MMap *map); + +#endif diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index 817a3af..4699ce9 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -273,7 +273,7 @@ input. void gstrask(char *buffer, char *message, int maxlen); -/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); +/* void gfkeyset(int pos, unsigned char *img); Draws an fkey from a Sprite Coder string that is in img, at fkey position pos. */ diff --git a/microfx_src/src/display.c b/microfx_src/src/display.c index ee69e63..3574586 100644 --- a/microfx_src/src/display.c +++ b/microfx_src/src/display.c @@ -19,52 +19,52 @@ char* _GetVRAMAddress(void); /* Microfx */ void sclear() { - _Bdisp_AllClr_VRAM(); + _Bdisp_AllClr_VRAM(); } void supdate() { - _Bdisp_PutDisp_DD(); + _Bdisp_PutDisp_DD(); } void spixel(int x, int y, int color) { - if(x>=0 && x=0 && y=0 && x=0 && ytw, ty = sy/map->th; + /* mx contient le nombre de pixels qui seront cachés sur x, pareil pour + y. */ + int mx = sx-tx*map->tw, my = sy-ty*map->th; + /* tile contient la tuile à dessiner */ + unsigned char tile; + /* J'ajuste sx. */ + if(sx-SWIDTH/2<0){ + /* Si je ne peux pas centrer le joueur car je suis trop proche du bord + gauche de la map. */ + map->px = sx; + sx = 0; + }else if(sx+SWIDTH/2>map->w*map->tw){ + /* Si je ne peux pas centrer le joueur car je suis trop proche du bord + droit de la map. */ + map->px = sx-(map->w*map->tw-SWIDTH/2); + sx = map->w*map->tw-SWIDTH/2; + }else{ + /* Sinon je peux centrer le joueur. */ + sx = sx-SWIDTH/2; + map->px = SWIDTH/2; + } + /* J'ajuste sy. */ + if(sy-SHEIGHT/2<0){ + /* Si je ne peux pas centrer le joueur car je suis trop proche du haut + de la map. */ + map->py = sy; + sy = 0; + }else if(sy+SHEIGHT/2>map->h*map->th){ + /* Si je ne peux pas centrer le joueur car je suis trop proche du bas de + la map. */ + map->py = sy-(map->h*map->th-SHEIGHT/2); + sy = map->h*map->th-SHEIGHT/2; + }else{ + /* Sinon je peux centrer le joueur. */ + sy = sy-SHEIGHT/2; + map->py = SHEIGHT/2; + } + tx = sx/map->tw; + ty = sy/map->th; + for(y=0;yh;y++){ + for(x=0;xw;x++){ + /* Je récupère la tuile dans map et je la dessine si tx+x est plus + petit que la largeur de la map. */ + if(tx+x < map->w){ + tile = map->map[(ty+y)*map->w+tx+x]; + if(tile > 0){ + simage(x*map->tw-mx, y*map->th-my, map->tw, map->th, + map->tileset[(int)tile-1], SNORMAL); + } + } + } + } +} diff --git a/microfx_src/src/ext/img.c b/microfx_src/src/ext/img.c index ac49335..50bea4a 100644 --- a/microfx_src/src/ext/img.c +++ b/microfx_src/src/ext/img.c @@ -2,28 +2,28 @@ #include void simage(int sx, int sy, int w, int h, unsigned char *img, int mode) { - /* Draws an image from a sprite coder string */ - int x, y, rpos, gpos, bpos, color; - for(y=0;y rom - .rodata : { - *(.rodata) - *(.rodata.str1.4) - _romdata_start = . ; - } > rom - .bss : { - _start_bss = . ; - _bssdatasize = . ; - LONG(0); - *(.bss) - *(COMMON) - _end_bss = . ; - } > ram - .data : AT(_romdata_start) { - _start_data = . ; - *(.data) - _end_data = . ; - } > ram + .text : { + *(.pretext) + *(.text) + } > rom + .rodata : { + *(.rodata) + *(.rodata.str1.4) + _romdata_start = . ; + } > rom + .bss : { + _start_bss = . ; + _bssdatasize = . ; + LONG(0); + *(.bss) + *(COMMON) + _end_bss = . ; + } > ram + .data : AT(_romdata_start) { + _start_data = . ; + *(.data) + _end_data = . ; + } > ram } diff --git a/microfx_src/src/gui.c b/microfx_src/src/gui.c index f4c2fcf..3d06557 100644 --- a/microfx_src/src/gui.c +++ b/microfx_src/src/gui.c @@ -13,21 +13,21 @@ void _PopupWin(int nlines); /* Microfx */ int gnumask(char *message, int maxlen, int type) { - return _InputNumber((unsigned char *)message, maxlen, type); + return _InputNumber((unsigned char *)message, maxlen, type); } void gstrask(char *buffer, char *message, int maxlen) { - _InputString((unsigned char *)buffer, (unsigned char *)message, maxlen); + _InputString((unsigned char *)buffer, (unsigned char *)message, maxlen); } void gfkeyset(int pos, unsigned char *img) { - _DisplayFKeyIcon(pos, img); + _DisplayFKeyIcon(pos, img); } void gmessagebox(int height, char *message) { - _DisplayMessageBox(height, (unsigned char*)message); + _DisplayMessageBox(height, (unsigned char*)message); } void gpopup(int hlines) { - _PopupWin(hlines); + _PopupWin(hlines); } diff --git a/microfx_src/src/keyboard.c b/microfx_src/src/keyboard.c index 6e07174..41113b8 100644 --- a/microfx_src/src/keyboard.c +++ b/microfx_src/src/keyboard.c @@ -10,33 +10,33 @@ int _Keyboard_PRGM_GetKey(unsigned char* buffer); /* Microfx */ int kisdown(void) { - return _Keyboard_KeyDown(); + return _Keyboard_KeyDown(); } int kcheck(int key) { - /* TODO : Compatibility with older calcs. */ - /* Get the column and the row of the key. */ - int row = key%10; - int column = key/10 - 1; - /* The bit that I will read in the KIUDATA - register. */ - int column_pos = column + 8 * (row & 1); - /* row_data will contain the data of the - KIUDATA register that we need. - keyboard_register contains the address of - KIUDATA0. */ - unsigned short *keyboard_register = (unsigned short*)0xA44B0000; - unsigned short row_data; - /* Get KIUDATAx where x is row / 2 because two rows - are stored in each KIUDATA register. */ - row_data = keyboard_register[row/2]; - /* Get the bit located at column. */ - return (row_data >> column_pos) & 1; + /* TODO : Compatibility with older calcs. */ + /* Get the column and the row of the key. */ + int row = key%10; + int column = key/10 - 1; + /* The bit that I will read in the KIUDATA + register. */ + int column_pos = column + 8 * (row & 1); + /* row_data will contain the data of the + KIUDATA register that we need. + keyboard_register contains the address of + KIUDATA0. */ + unsigned short *keyboard_register = (unsigned short*)0xA44B0000; + unsigned short row_data; + /* Get KIUDATAx where x is row / 2 because two rows + are stored in each KIUDATA register. */ + row_data = keyboard_register[row/2]; + /* Get the bit located at column. */ + return (row_data >> column_pos) & 1; } int kgetkey(void){ - /* Made a prgm like getkey in the same way as simlo described it. */ - unsigned char buffer[12]; - _Keyboard_PRGM_GetKey(buffer); - return (buffer[1] & 0x0F) * 10 + ((buffer[2] & 0xF0 ) >> 4); + /* Made a prgm like getkey in the same way as simlo described it. */ + unsigned char buffer[12]; + _Keyboard_PRGM_GetKey(buffer); + return (buffer[1] & 0x0F) * 10 + ((buffer[2] & 0xF0 ) >> 4); } diff --git a/microfx_src/src/memory.c b/microfx_src/src/memory.c index 44625d9..8976b8d 100644 --- a/microfx_src/src/memory.c +++ b/microfx_src/src/memory.c @@ -19,57 +19,57 @@ int _Bfile_Size(int fd); extern int fugue; int mfugue(void) { - return fugue; + return fugue; } unsigned short int fname[PATHSIZELIMIT]; void _fixname(const char *filename) { - int len, i; - len = 0; - /* Getting the lenght of the filename */ - while(filename[len] != '\0' && len < PATHSIZELIMIT){ - len++; - } - /* Clearing fname, the file name for Bfile. */ - for(i=0;i 0){ file.fd = file.out; file.error = 0; file.fpos = 0; - file.fwpos = 0; + file.fwpos = 0; }else{ file.error = 1; } @@ -77,23 +77,23 @@ MFile mopen(const char *filename, int mode) { } void mwrite(MFile *file, const void *data, int size) { - /* Some checks to make the operation more secure. */ - if(!fugue && size%2){ + /* Some checks to make the operation more secure. */ + if(!fugue && size%2){ file->error = MODDSIZEWRITE; file->out = 1; - return; - } - msize(file); - if(file->fwpos + size > file->out && !file->error){ - file->out = MTOOBIGSIZE; - file->error = 1; - return; - } - /* Calling the Bfile syscall and updating the MFile struct. */ - file->out = _Bfile_Write(file->fd, data, size); - file->fpos += size; - file->fwpos += size; - if(file->out < 0){ + return; + } + msize(file); + if(file->fwpos + size > file->out && !file->error){ + file->out = MTOOBIGSIZE; + file->error = 1; + return; + } + /* Calling the Bfile syscall and updating the MFile struct. */ + file->out = _Bfile_Write(file->fd, data, size); + file->fpos += size; + file->fwpos += size; + if(file->out < 0){ file->error = 1; }else{ file->error = 0; @@ -101,17 +101,17 @@ void mwrite(MFile *file, const void *data, int size) { } void mread(MFile *file, void *data, int size, int whence) { - /* Making an absolute position out of whence. */ + /* Making an absolute position out of whence. */ if(whence == MRCONTINUE) whence = file->fpos; - /* A check to make the operation more secure. */ - msize(file); - if(whence + size > file->out && !file->error){ - file->out = MTOOBIGSIZE; - file->error = 1; - return; - } - /* Calling the Bfile syscall and updating the MFile struct. */ - file->out = _Bfile_Read(file->fd, data, size, whence); + /* A check to make the operation more secure. */ + msize(file); + if(whence + size > file->out && !file->error){ + file->out = MTOOBIGSIZE; + file->error = 1; + return; + } + /* Calling the Bfile syscall and updating the MFile struct. */ + file->out = _Bfile_Read(file->fd, data, size, whence); file->fpos += size; if(file->out < 0){ file->error = 1; @@ -121,8 +121,8 @@ void mread(MFile *file, void *data, int size, int whence) { } void mclose(MFile *file) { - /* Calling the Bfile syscall and updating the MFile struct. */ - file->out = _Bfile_Close(file->fd); + /* Calling the Bfile syscall and updating the MFile struct. */ + file->out = _Bfile_Close(file->fd); if(file->out < 0){ file->error = 1; }else{ @@ -131,17 +131,17 @@ void mclose(MFile *file) { } void mseek(MFile *file, int pos) { - /* Setting the new position whitout making checks because more informations - are required to make checks, so they are made directly when doing operations - on the file. - error and out are set to 0 because no error can occur when doing this. */ + /* Setting the new position whitout making checks because more informations + are required to make checks, so they are made directly when doing operations + on the file. + error and out are set to 0 because no error can occur when doing this. */ file->fpos = pos; file->error = 0; file->out = 0; } void msize(MFile *file) { - /* Calling the Bfile syscall and updating the MFile struct. */ + /* Calling the Bfile syscall and updating the MFile struct. */ file->out = _Bfile_Size(file->fd); if(file->out < 0){ file->error = 1; diff --git a/microfx_src/src/misc.c b/microfx_src/src/misc.c index 5d20bae..8095b6d 100644 --- a/microfx_src/src/misc.c +++ b/microfx_src/src/misc.c @@ -9,7 +9,7 @@ int _LongToAscHex(int value, char *dest, int digits); /* Microfx */ void itohex(char *buffer, int value, int len) { - _LongToAscHex(value, buffer, len); + _LongToAscHex(value, buffer, len); } /******* CPU *******/ @@ -17,5 +17,5 @@ void itohex(char *buffer, int value, int len) { /* Microfx */ void csleep(void) { - __asm__("sleep"); + __asm__("sleep"); } diff --git a/microfx_src/src/start.c b/microfx_src/src/start.c index cc0147e..859923c 100644 --- a/microfx_src/src/start.c +++ b/microfx_src/src/start.c @@ -17,28 +17,28 @@ int fugue; __attribute__((section(".pretext"))) int start(void) { - int i; - char *bss_startptr, *data_startptr, *romdataptr; - char *os_version = (void *)0x80010020; - /* Clearing the bss. */ - bss_startptr = &start_bss; - for(i=0;i<&end_bss - &start_bss;i++){ - bss_startptr[i] = 0; - } - /* Load the ROM data into the RAM. */ - data_startptr = &start_data; - romdataptr = &romdata_start; - for(i=0;i<&end_data - &start_data;i++){ - data_startptr[i] = romdataptr[i]; - } - /* Checking if the calculator has a fugue filesystem, because it is - important to know that when using Bfile. */ - if(os_version[1] == '3'){ - fugue = 1; - }else{ - fugue = 0; - } - /* Calling main. The return value of main is directly returned because no - modifications need to be made. */ - return main(); + int i; + char *bss_startptr, *data_startptr, *romdataptr; + char *os_version = (void *)0x80010020; + /* Clearing the bss. */ + bss_startptr = &start_bss; + for(i=0;i<&end_bss - &start_bss;i++){ + bss_startptr[i] = 0; + } + /* Load the ROM data into the RAM. */ + data_startptr = &start_data; + romdataptr = &romdata_start; + for(i=0;i<&end_data - &start_data;i++){ + data_startptr[i] = romdataptr[i]; + } + /* Checking if the calculator has a fugue filesystem, because it is + important to know that when using Bfile. */ + if(os_version[1] == '3'){ + fugue = 1; + }else{ + fugue = 0; + } + /* Calling main. The return value of main is directly returned because no + modifications need to be made. */ + return main(); } diff --git a/microfx_src/src/syscall.S b/microfx_src/src/syscall.S index c46bef9..f7aa95d 100644 --- a/microfx_src/src/syscall.S +++ b/microfx_src/src/syscall.S @@ -64,130 +64,130 @@ .global __PopupWin #define syscall(syscall_number) \ - mov.l 1f, r0 ;\ - mov.l do_syscall, r2 ;\ - jmp @r2 ;\ - nop ;\ + mov.l 1f, r0 ;\ + mov.l do_syscall, r2 ;\ + jmp @r2 ;\ + nop ;\ .align 4 ;\ -1: .long syscall_number +1: .long syscall_number /* Display */ __Bdisp_PutDisp_DD: - syscall(0x028) + syscall(0x028) __Bdisp_DrawRectangle: - syscall(0x0763) + syscall(0x0763) __Bdisp_AllClr_VRAM: - syscall(0x143) + syscall(0x143) __Bdisp_SetPoint_VRAM: - syscall(0x146) + syscall(0x146) __Bdisp_GetPoint_VRAM: - syscall(0x149) + syscall(0x149) __PrintXY: - syscall(0x150) + syscall(0x150) __locate: - syscall(0x807) + syscall(0x807) __Print: - syscall(0x808) + syscall(0x808) __Bdisp_DrawLineVRAM: - syscall(0x030) + syscall(0x030) __Bdisp_ClearLineVRAM: - syscall(0x031) + syscall(0x031) __PrintMiniSd: - syscall(0xC4F) + syscall(0xC4F) __DisplayMessageBox: - syscall(0x0901) + syscall(0x0901) __GetVRAMAddress: - syscall(0x135) + syscall(0x135) /* Keyboard */ __Keyboard_KeyDown: - syscall(0x24D) + syscall(0x24D) __Keyboard_PRGM_GetKey: - syscall(0x6C4) + syscall(0x6C4) /* Time */ __Sleep: - syscall(0x0420) + syscall(0x0420) __RTC_GetTicks: - syscall(0x03B) + syscall(0x03B) __RTC_Elapsed_ms: - syscall(0x03C) + syscall(0x03C) __RTC_Reset: - syscall(0x039) + syscall(0x039) __Timer_Install: - syscall(0x0118) + syscall(0x0118) __Timer_Deinstall: - syscall(0x0119) + syscall(0x0119) __Timer_Start: - syscall(0x011A) + syscall(0x011A) __Timer_Stop: - syscall(0x011B) + syscall(0x011B) /* RTC */ __RTC_GetTime: - syscall(0x03A) + syscall(0x03A) /* Files */ __Bfile_DeleteEntry: - mov #0, r5 - syscall(0x0439) + mov #0, r5 + syscall(0x0439) __Bfile_Create: - syscall(0x434) + syscall(0x434) __Bfile_Write: - syscall(0x435) + syscall(0x435) __Bfile_Open: - mov #0, r6 - syscall(0x42C) + mov #0, r6 + syscall(0x42C) __Bfile_Read: - syscall(0x432) + syscall(0x432) __Bfile_Close: - syscall(0x042D) + syscall(0x042D) __Bfile_Size: - syscall(0x042F) + syscall(0x042F) /* Tools */ _itoa: - syscall(0x541) + syscall(0x541) _malloc: - syscall(0xACD) + syscall(0xACD) _calloc: - syscall(0xE6B) + syscall(0xE6B) _realloc: - syscall(0xE6D) + syscall(0xE6D) _free: - syscall(0xACC) + syscall(0xACC) __LongToAscHex: - syscall(0x467) + syscall(0x467) _memcmp: - syscall(0xACE) + syscall(0xACE) _memcpy: - syscall(0xACF) + syscall(0xACF) _memset: - syscall(0xAD0) + syscall(0xAD0) _strcat: - syscall(0xAD4) + syscall(0xAD4) _strcmp: - syscall(0xAD5) + syscall(0xAD5) _strlen: - syscall(0xAD6) + syscall(0xAD6) _strncat: - syscall(0xAD7) + syscall(0xAD7) _strncmp: - syscall(0xAD8) + syscall(0xAD8) _strncpy: - syscall(0xAD9) + syscall(0xAD9) _strrchr: - syscall(0xADA) + syscall(0xADA) _strchr: - syscall(0xE6E) + syscall(0xE6E) _strstr: - syscall(0xE6F) + syscall(0xE6F) _memmove: - syscall(0xE6C) + syscall(0xE6C) /* GUI */ __InputNumber: - syscall(0x0CC4) + syscall(0x0CC4) __InputString: - syscall(0x0CC5) + syscall(0x0CC5) __DisplayFKeyIcon: - syscall(0x04D1) + syscall(0x04D1) __PopupWin: - syscall(0x08FE) + syscall(0x08FE) /* Menu */ /* Nothing here ... */ diff --git a/microfx_src/src/time.c b/microfx_src/src/time.c index 8a4adca..41d5d4a 100644 --- a/microfx_src/src/time.c +++ b/microfx_src/src/time.c @@ -17,33 +17,33 @@ int _Timer_Stop(int InternalTimerID); /* Microfx */ void tsleep_ms(int ms) { - _Sleep(ms); + _Sleep(ms); } int tgetticks(void) { - return _RTC_GetTicks(); + return _RTC_GetTicks(); } int tiselapsed(int start, int ms) { - return _RTC_Elapsed_ms(start, ms); + return _RTC_Elapsed_ms(start, ms); } void treset(void) { - _RTC_Reset(1); + _RTC_Reset(1); } int tinittimer(int ms, void (*callback)(void)) { - return _Timer_Install(0, callback, ms); + return _Timer_Install(0, callback, ms); } void tfreetimer(int id) { - _Timer_Deinstall(id); + _Timer_Deinstall(id); } void tstarttimer(int id) { - _Timer_Start(id); + _Timer_Start(id); } void tstoptimer(int id) { - _Timer_Stop(id); + _Timer_Stop(id); } diff --git a/template/lib/fx98xx.ld b/template/lib/fx98xx.ld index 8a5279b..7aeeae1 100644 --- a/template/lib/fx98xx.ld +++ b/template/lib/fx98xx.ld @@ -2,32 +2,32 @@ ENTRY(_start) MEMORY { - rom (rx) : ORIGIN = 0x00300200, LENGTH = 512K - ram (rw) : ORIGIN = 0x08100200, LENGTH = 20K + rom (rx) : ORIGIN = 0x00300200, LENGTH = 512K + ram (rw) : ORIGIN = 0x08100200, LENGTH = 20K } SECTIONS { - .text : { - *(.pretext) - *(.text) - } > rom - .rodata : { - *(.rodata) - *(.rodata.str1.4) - _romdata_start = . ; - } > rom - .bss : { - _start_bss = . ; - _bssdatasize = . ; - LONG(0); - *(.bss) - *(COMMON) - _end_bss = . ; - } > ram - .data : AT(_romdata_start) { - _start_data = . ; - *(.data) - _end_data = . ; - } > ram + .text : { + *(.pretext) + *(.text) + } > rom + .rodata : { + *(.rodata) + *(.rodata.str1.4) + _romdata_start = . ; + } > rom + .bss : { + _start_bss = . ; + _bssdatasize = . ; + LONG(0); + *(.bss) + *(COMMON) + _end_bss = . ; + } > ram + .data : AT(_romdata_start) { + _start_data = . ; + *(.data) + _end_data = . ; + } > ram } diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index 817a3af..4699ce9 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -273,7 +273,7 @@ input. void gstrask(char *buffer, char *message, int maxlen); -/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); +/* void gfkeyset(int pos, unsigned char *img); Draws an fkey from a Sprite Coder string that is in img, at fkey position pos. */ diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 8388373..8542b38 100644 Binary files a/template/lib/libMicrofx.a and b/template/lib/libMicrofx.a differ diff --git a/template/src/main.c b/template/src/main.c index c1e77bb..dc01899 100644 --- a/template/src/main.c +++ b/template/src/main.c @@ -1,16 +1,16 @@ #include int main(void) { - while(kisdown()); - /* Clear the screen */ - sclear(); - stext(1, 1, "A Microfx Add-in !", SBLACK); - /* Update the screen */ - supdate(); - /* Waits that the user presses EXIT. */ - int key = 0; - while(key != KCEXIT){ - key = kgetkey(); - } - return 1; + while(kisdown()); + /* Clear the screen */ + sclear(); + stext(1, 1, "A Microfx Add-in !", SBLACK); + /* Update the screen */ + supdate(); + /* Waits that the user presses EXIT. */ + int key = 0; + while(key != KCEXIT){ + key = kgetkey(); + } + return 1; } diff --git a/tools/mapconv/Makefile b/tools/mapconv/Makefile new file mode 100644 index 0000000..47d4f99 --- /dev/null +++ b/tools/mapconv/Makefile @@ -0,0 +1,21 @@ +NAME = mapconv + +SRC = src/main.c +OBJ = $(SRC:src/%=build/%.o) + +BUILD = build + +all: $(OBJ) + $(CC) $(OBJ) -o $(NAME) + +$(OBJ): $(SRC) | $(BUILD)/ + $(CC) -c $< -o $@ -Os -Iinc -std=c89 + +.PRECIOUS: %/ + +%/: + @ mkdir -p $@ + +clean: $(BUILD) + rm $(BUILD) --recursive + rm $(NAME) diff --git a/tools/mapconv/inc/help.h b/tools/mapconv/inc/help.h new file mode 100644 index 0000000..7a135c9 --- /dev/null +++ b/tools/mapconv/inc/help.h @@ -0,0 +1,22 @@ +#ifndef HELP_H +#define HELP_H + +const char help[] = "mapconv - Microfx map creator\n\n" +"This little tool makes it easier to create maps for the Microfx gametools ext." +"\n" +"Use :\n" +" mapconv map.txt conf.txt map.h\n" +"map.txt should contain a map made out of ASCII characters. Each line in the\n" +"map.txt file should represent one line in the map.\n" +"conf.txt should contain the map width, on the next line the height and then,\n" +"after, the number of the tile followed by a space and her ASCII character like" +"\n" +"this :\n" +" 1 #\n" +"The last argument is the header file that will be generated. You'll just need" +"\n" +"to modify it to add some informations into the MMap struct before using it in" +"\n" +"your game."; + +#endif diff --git a/tools/mapconv/src/main.c b/tools/mapconv/src/main.c new file mode 100644 index 0000000..d2fecf6 --- /dev/null +++ b/tools/mapconv/src/main.c @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +void grabint(char *data, int size, int *start, char stop, int *out) { + int i; + *out=0; + for(i=0;*start\n\n" + "const unsigned char _map[] = {", fp_map); + for(i=0;i