├── screen.png ├── examples └── test.bin ├── include ├── def.h ├── draw.h ├── file.h └── str.h ├── .gitignore ├── Makefile ├── LICENSE ├── src ├── str.c ├── file.c ├── draw.c └── main.c └── README.md /screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paul-arutyunov/vtGBte/HEAD/screen.png -------------------------------------------------------------------------------- /examples/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paul-arutyunov/vtGBte/HEAD/examples/test.bin -------------------------------------------------------------------------------- /include/def.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEF_H_ 2 | #define _DEF_H_ 3 | 4 | #define MAXH 32 5 | #define MAXW 32 6 | #define FAILURE 1 7 | #define SUCCESS 0 8 | #define STRING_LENGTH 64 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /include/draw.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int h,w; 4 | extern int display_guide; 5 | 6 | void print_help(); 7 | 8 | void textbox(int, int, int, int); 9 | 10 | void draw_boxes(); 11 | 12 | void displayCanvas(); 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # list of files to ignore 2 | # usually just the binaries and objs 3 | # they are annoying when popping up in git status 4 | # I hate red 5 | # (maybe) 6 | 7 | # Object files 8 | *.o 9 | *.a 10 | 11 | gbt # The binary file 12 | -------------------------------------------------------------------------------- /include/file.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_H_ 2 | #define _FILE_H_ 3 | 4 | #include "include/def.h" 5 | #include 6 | #include 7 | 8 | int initFile(char *filename); 9 | void saveAsset(); 10 | void loadAsset(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/str.h: -------------------------------------------------------------------------------- 1 | #ifndef _STR_H_ 2 | #define _STR_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern int h,w; 11 | 12 | void clear_line(); 13 | 14 | void get_input_line(char *string, int len); 15 | 16 | char *get_token(char *str, int* prev); 17 | 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Put your compiler name here 2 | CC = gcc 3 | CFLAGS = -I$(CURDIR) 4 | 5 | PREFIX = "/usr/local" 6 | # By default 7 | 8 | .PHONY: all clean install uninstall 9 | 10 | all: gbt 11 | 12 | draw.o: src/draw.c 13 | $(CC) $(CFLAGS) -c -o draw.o src/draw.c -lncurses 14 | 15 | file.o: src/file.c 16 | $(CC) $(CFLAGS) -c -o file.o src/file.c -lncurses 17 | 18 | main.o: src/main.c 19 | $(CC) $(CFLAGS) -c -o main.o src/main.c -lncurses 20 | 21 | str.o: src/str.c 22 | $(CC) $(CFLAGS) -c -o str.o src/str.c -lncurses 23 | 24 | gbt: main.o str.o draw.o file.o 25 | $(CC) $(CFLAGS) -o gbt main.o draw.o str.o file.o -lncurses 26 | 27 | clean: 28 | rm -rf gbt *.o 29 | 30 | install: 31 | install ./gbt $(PREFIX)/bin 32 | 33 | uninstall: 34 | rm -rf $(PREFIX)/bin/gbt 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Paul Aruytunov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/str.c: -------------------------------------------------------------------------------- 1 | #include "include/str.h" 2 | 3 | void clear_line() 4 | { 5 | extern int maxcol; 6 | int i; 7 | attron(COLOR_PAIR(4)); 8 | move(h+7, 9); 9 | for (i=0; i<(maxcol-1); i++) addch(' '); 10 | } 11 | 12 | void get_input_line(char *string, int len) 13 | { 14 | int c; 15 | int i = 0; 16 | int j = 0; 17 | int width = 0; 18 | int height = 0; 19 | 20 | getmaxyx(stdscr, height, width); 21 | curs_set(1); 22 | clear_line(); 23 | move(h+7,11); 24 | 25 | if (strlen(string)>0) { 26 | for (i=0; i0) { 32 | i--; 33 | mvaddch(h+7,11+i,' '); 34 | move(h+7,11+i); 35 | string[i]='\0'; 36 | } 37 | else if( !iscntrl(c) && strlen(string) < len) { 38 | string[i] = c; 39 | mvaddch(h+7,11+i,c); 40 | string[++i] = '\0'; 41 | } 42 | } 43 | curs_set(0); 44 | } 45 | 46 | 47 | char *get_token(char *str, int *prev) 48 | { 49 | static char token[32]; 50 | memset(token, '\0', 31); 51 | 52 | int i = 0; 53 | 54 | while (str[i] != ' ' && str[i] != '\0') { 55 | token[i] = str[*prev+i]; 56 | i++; 57 | } 58 | 59 | *prev = i+1; 60 | return token; 61 | } 62 | -------------------------------------------------------------------------------- /src/file.c: -------------------------------------------------------------------------------- 1 | #include "include/file.h" 2 | #include "include/str.h" 3 | 4 | FILE *fp; 5 | 6 | int initFile(char *filename) 7 | { 8 | extern FILE *fp; 9 | extern int h,w; 10 | int c; 11 | fp = fopen(filename,"rb+"); 12 | move(h+7,9); 13 | if (fp!=NULL) { 14 | printw("Opened file '%s'",filename); 15 | return SUCCESS; 16 | } else { 17 | printw("There's no file '%s'. Create?",filename); 18 | c=getch(); 19 | 20 | if (c=='y') 21 | { 22 | fp = fopen(filename,"wb+"); 23 | 24 | if (fp==NULL) { 25 | clear_line(); 26 | printw("\r Can't create file '%s'",filename); 27 | return FAILURE; 28 | } else { 29 | clear_line(); 30 | printw("\r Created file '%s'",filename); 31 | return SUCCESS; 32 | } 33 | } 34 | if (c=='n') 35 | { 36 | clear_line(); 37 | printw("\r Oki."); 38 | return FAILURE; 39 | } 40 | } 41 | } 42 | 43 | void saveAsset() 44 | { 45 | extern unsigned char asset[256][16]; 46 | extern FILE *fp; 47 | int i,j; 48 | 49 | for (i=0; i<256; i++) 50 | { 51 | fwrite(asset[i],sizeof(unsigned char),16,fp); 52 | } 53 | fclose(fp); 54 | } 55 | 56 | void loadAsset() 57 | { 58 | extern unsigned char asset[256][16]; 59 | extern FILE *fp; 60 | int i,j; 61 | 62 | for (i=0; i<256; i++) 63 | { 64 | fread(asset[i],sizeof(unsigned char),16,fp); 65 | } 66 | fclose(fp); 67 | } 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vtGBte (Very Tiny GameBoy Tile Editor) 2 | 3 | ![](./screen.png) 4 | 5 | A simple *keyboard-controlled* Game Boy tile editor for Unix systems written in C using ncurses library. 6 | (Everything besides plotting pixels is achieved by pressing keys) 7 | 8 | 9 | Hope you'll find it useful. 10 | 11 | ## Building 12 | 13 | First you'll need to clone the repo: 14 | `$ git clone https://github.com/paul-arutyunov/vtGBte.git` 15 | `$ cd vtGBte` 16 | 17 | To build the project, run 18 | `$ make` 19 | in your terminal. 20 | 21 | This will create binary file in the repo dir. 22 | 23 | To install the program, simply run 24 | `# make install` 25 | 26 | This will install the binary to the directory specified in the makefile (`/usr/local/bin` by default). 27 | 28 | Expectably, to uninstall run 29 | `# make uninstall` 30 | 31 | Before re-building always run 32 | `$ make clean` 33 | This will remove all object files in the repo dir. 34 | Also it'd be nice to have a script named, say, "rebuild.sh" located in the repo dir and consisting of two lines. 35 | 36 | 37 | *Note that you'll need `ncurses` library located somwhere on your computer.* 38 | *And `make`.* 39 | *And `install`.* 40 | *And `rm`.* 41 | *And, if thruth to be told, a C compiler is required too.* 42 | *Why am I writing this.* 43 | 44 | ## Usage 45 | 46 | Asset is always 256 tiles in size. 47 | vtGBte saves assets in raw binary format. This means that you only have to 48 | save your work to a file, named, say, 'sprites.bin', you will only need to 49 | include it in your assembly file, for example, that's how you do it in RGBDS: 50 | 51 | `incbin "sprites.bin"` 52 | 53 | You would likely do not use up the whole asset, so you can include only a part of file: 54 | 55 | `incbin "sprites.bin",0,32` 56 | 57 | In RGBDS, this will include only 32 bytes (2 tiles) starting at byte 0. 58 | 59 | 60 | Minimalistic! 61 | 62 | ## Commands 63 | 64 | Drawing: 65 | Arrow keys to move the cursor, number keys (1..4) to select color, SPACE to plot a pixel, 66 | F to fill the whole tile with selected color. 67 | 68 | `r` to redraw screen (similar to ^R in Nethack) - useful if your screen is ruined for any reason. 69 | 70 | `S` to resize canvas (up to 32x32 size supported) 71 | 72 | `g` - show guide 73 | 74 | `,` and `.` keys to shift tile 75 | 76 | `<` and `>` keys to toggle the color of the selected color number 77 | 78 | `c` to copy, `p` to paste 79 | 80 | `s` to save asset to file 81 | 82 | `l` to load asset from file 83 | 84 | `h` to open the help screen 85 | 86 | `q` to quit 87 | 88 | ## So... 89 | 90 | Be sure to make suggestions or contribute. 91 | You're welcome! 92 | -------------------------------------------------------------------------------- /src/draw.c: -------------------------------------------------------------------------------- 1 | /* Some draw functions included have I. */ 2 | 3 | #include "include/draw.h" 4 | #include "include/def.h" 5 | 6 | int display_guide; 7 | 8 | void print_help() 9 | { 10 | int c=0; 11 | attron(COLOR_PAIR(4)); 12 | printw("\n\n\n"); 13 | printw(" +--1/2--- Help Message -----+\n"); 14 | printw(" | Here's the list of cmds: |\n"); 15 | printw(" | |\n"); 16 | printw(" | 1...4 = pick color |\n"); 17 | printw(" | ARROWS = move cursor |\n"); 18 | printw(" | SPACE = draw |\n"); 19 | printw(" | r = redraw screen |\n"); 20 | printw(" | f = fill with color|\n"); 21 | printw(" | h = get some help |\n"); 22 | printw(" | q = quit |\n"); 23 | printw(" +--press space to continue--+\n"); 24 | 25 | while (getch()!=' '); 26 | clear(); 27 | 28 | printw("\n\n\n"); 29 | printw(" +--2/2--- Help Message -----+\n"); 30 | printw(" | Here's the list of cmds: |\n"); 31 | printw(" | |\n"); 32 | printw(" | u = update display |\n"); 33 | printw(" | , . = choose tile |\n"); 34 | printw(" | l = load from file |\n"); 35 | printw(" | s = save to file |\n"); 36 | printw(" | S = resize tiles |\n"); 37 | printw(" | c p = copy, paste |\n"); 38 | printw(" | |\n"); 39 | printw(" +--press space to continue--+\n"); 40 | 41 | while(getch()!=' '); 42 | clear(); 43 | draw_boxes(); 44 | } 45 | 46 | 47 | 48 | void textbox(int startx, int starty, int w, int h) 49 | { 50 | int i; 51 | 52 | move(starty,startx); 53 | addch(/*ACS_ULCORNER*/'+'); 54 | move(starty+h+1, startx); 55 | addch(/*ACS_LLCORNER*/'+'); 56 | for (i = 1; i < w+1; i++) 57 | { 58 | move(starty,startx+i); 59 | addch(ACS_HLINE); 60 | move(starty+h+1,startx+i); 61 | addch(ACS_HLINE); 62 | 63 | } 64 | mvaddch(starty,startx+w+1, /*ACS_URCORNER*/'+'); 65 | mvaddch(starty+h+1,startx+w+1, /*ACS_LRCORNER*/'+'); 66 | 67 | for (i = 1; i < h+1; i++) 68 | { 69 | move(starty+i, startx); 70 | addch(ACS_VLINE); 71 | move(starty+i, startx+w+1); 72 | addch(ACS_VLINE); 73 | } 74 | } 75 | 76 | void draw_boxes() 77 | { 78 | attron(COLOR_PAIR(4)); 79 | clear(); 80 | 81 | printw("\n Very Tiny GameBoy Tile Editor\n\n"); 82 | printw(" [ ] [ ] [ ] [ ] "); 83 | move(3,13+w*2); 84 | printw("Hex Data:"); 85 | textbox(9,4,w*2,h); 86 | textbox(13+(w*2),4,w,h); 87 | } 88 | 89 | void displayCanvas() 90 | { 91 | int i,j; 92 | extern int h,w; 93 | extern int assign[]; 94 | extern unsigned char drawing_space[MAXH][MAXW]; 95 | for (i = 0; i < h; i++) 96 | { 97 | for (j = 0; j < w; j++) /* Display canvas */ 98 | { 99 | attron(COLOR_PAIR(assign[drawing_space[i][j]]+1)); 100 | move(5+i,10+j*2); 101 | 102 | if (display_guide) { 103 | printw(". "); 104 | } else printw(" "); 105 | } 106 | } 107 | 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2018 Paul Arutyunov 3 | */ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "include/def.h" 11 | #include "include/draw.h" 12 | #include "include/file.h" 13 | #include "include/str.h" 14 | 15 | unsigned char drawing_space[MAXH][MAXW]; 16 | unsigned char clipboard[MAXH][MAXW]; 17 | unsigned char asset[256][16]; 18 | int assign[] = {0, 1, 2, 3}; /* Assign pallette */ 19 | 20 | int h,w; 21 | int maxcol, maxrow; 22 | 23 | void initColors(); 24 | void updateCanvas(int tile); 25 | 26 | void signalHandler(int signum) { 27 | endwin(); 28 | printf("\033[?1003l\n"); 29 | exit(signum); 30 | } 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | extern unsigned char drawing_space[MAXH][MAXW]; 35 | extern unsigned char clipboard[MAXH][MAXW]; 36 | extern char command[]; 37 | int k; 38 | int color; 39 | extern int display_guide; 40 | int i; 41 | int j; 42 | int l; 43 | extern int maxcol, maxrow; 44 | int gstartx, gstarty; 45 | extern int h, w; 46 | unsigned char b1,b2; 47 | MEVENT event; 48 | uint8_t current_tile=0; 49 | unsigned char a = 0; 50 | unsigned int x = 0; 51 | unsigned int y = 0; 52 | extern int assign[]; 53 | int plotting=0; 54 | char filename[STRING_LENGTH+1]={0}; 55 | /*changed from pointer to a fixed string because 56 | the pointer didn't point to any allocated memory 57 | which should cause segfault 58 | */ 59 | h = 8; 60 | w = 8; 61 | 62 | if (argc>2){ 63 | printf("Too many arguments, dude! \n"); 64 | printf("Press any key to quit..."); 65 | getchar(); 66 | return 2; 67 | } 68 | 69 | initscr(); 70 | if (has_colors() == FALSE) { 71 | endwin(); 72 | printf("\nYour terminal does not support color. Life is dull without color, how can you live without it?"); 73 | printf("\nTerminating :(\n"); 74 | return 1; 75 | } 76 | if (can_change_color() == FALSE) { 77 | printw("Hey!\nYour terminal seems to do not \nsupport color re-definitions.\n"); 78 | printw("As this program uses neat custom palette,\n you might experience eye bleeding.\n"); 79 | printw("Press any key to continue."); 80 | getch(); 81 | } 82 | 83 | noecho(); 84 | start_color(); 85 | keypad(stdscr, 1); 86 | curs_set(0); 87 | cbreak(); 88 | initColors(); 89 | display_guide=0; /* don't */ 90 | mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL); 91 | printf("\033[?1003h\n"); 92 | mouseinterval(0); 93 | 94 | signal(SIGINT, signalHandler); 95 | 96 | color = 3; 97 | 98 | draw_boxes(); 99 | 100 | if (argc==2) { 101 | strncpy(filename,argv[1],STRING_LENGTH); 102 | if (initFile(filename)==SUCCESS) loadAsset(); 103 | updateCanvas(current_tile); 104 | } 105 | 106 | while(1) 107 | { 108 | getmaxyx(stdscr, maxrow, maxcol); 109 | displayCanvas(); 110 | 111 | for (i = 0; i < 4; i++) /* Display color panel */ 112 | { 113 | attron(COLOR_PAIR(assign[i]+1)); 114 | move(3,10+i*4); 115 | printw("%d",i); 116 | if (i == color) { 117 | attron(COLOR_PAIR(4)); 118 | mvaddch(2,10+i*4,'v'); 119 | } else { 120 | attron(COLOR_PAIR(4)); 121 | mvaddch(2,10+i*4,' '); 122 | } 123 | } 124 | 125 | 126 | move(h+6,9); 127 | printw("#%d ",current_tile); 128 | 129 | /* Display hex data */ 130 | for (i = 0; i < h; i++) 131 | { 132 | for (l = 0; l < w/8; l++) 133 | { 134 | b1 = 0; 135 | b2 = 0; 136 | for (j = 0; j < 8; j++) 137 | { 138 | a = drawing_space[i][j+l*8]; 139 | /*b1 = b1 | ( (a>>1) << (7-j) ); 140 | b2 = b2 | ( (a&1) << (7-j) );*/ 141 | b1 = b1 | (a&1) << (7-j); 142 | b2 = b2 | (a>>1) << (7-j); 143 | } 144 | move(5+i,14+w*2+l*8); 145 | printw("%.2X, %.2X",b1,b2); 146 | asset[current_tile+(h/8*l)][i*2+1] = b2; 147 | asset[current_tile+(h/8*l)][i*2] = b1; 148 | } 149 | } 150 | 151 | x = x%w; 152 | y = y%h; 153 | move(5+y,10+x*2); 154 | 155 | /*Change color to prevent the cursor 156 | * from hiding the pixel underneath */ 157 | attron(COLOR_PAIR(assign[drawing_space[y][x]]+1)); 158 | printw("[]"); 159 | k = getch(); 160 | 161 | switch (k) /* Input */ 162 | { 163 | case 'u': 164 | updateCanvas(current_tile); 165 | break; 166 | 167 | case KEY_MOUSE: 168 | if (getmouse(&event)==OK) 169 | { 170 | x = (event.x-10) >> 1; 171 | y = (event.y-5); 172 | 173 | y=y%h; 174 | x=x%w; 175 | 176 | if (event.bstate & BUTTON1_PRESSED) 177 | plotting=1; 178 | 179 | if (event.bstate & BUTTON1_RELEASED) 180 | plotting=0; 181 | 182 | if (plotting) drawing_space[y][x] = color; 183 | 184 | /*move(h+7,9); 185 | printw("x: %d, y: %d ", x,y);*/ 186 | } 187 | 188 | break; 189 | 190 | case KEY_UP: 191 | y--; 192 | break; 193 | 194 | case KEY_DOWN: 195 | y++; 196 | break; 197 | 198 | case KEY_LEFT: 199 | x--; 200 | break; 201 | 202 | case KEY_RIGHT: 203 | x++; 204 | break; 205 | 206 | case ' ': /* Plot */ 207 | drawing_space[y][x] = color; 208 | break; 209 | 210 | case 'r': /* Redraw */ 211 | clear(); 212 | draw_boxes(); 213 | break; 214 | 215 | case 'h': /* Help */ 216 | clear(); 217 | print_help(); 218 | break; 219 | 220 | case ',': 221 | current_tile-=(h/8)*(w/8); 222 | updateCanvas(current_tile); 223 | break; 224 | 225 | case '.': 226 | current_tile+=(h/8)*(w/8); 227 | updateCanvas(current_tile); 228 | break; 229 | 230 | case '<': 231 | if (assign[color]==0) assign[color]=3; 232 | else assign[color] -= 1; 233 | break; 234 | 235 | case '>': 236 | assign[color] = (assign[color]+1) % 4; 237 | break; 238 | 239 | case 'f': /* Fill the whole tile with one 240 | color (NOT flood fill)*/ 241 | for (i = 0; i "); 302 | get_input_line(filename,STRING_LENGTH); 303 | if (initFile(filename)==SUCCESS) saveAsset(); 304 | break; 305 | 306 | case 'l': 307 | 308 | move(h+7,9); 309 | attron(COLOR_PAIR(4)); 310 | printw("> "); 311 | get_input_line(filename,STRING_LENGTH); 312 | if (initFile(filename)==SUCCESS) loadAsset(); 313 | updateCanvas(current_tile); 314 | break; 315 | 316 | case 'S': 317 | move(h+7,9); 318 | attron(COLOR_PAIR(1)); 319 | move(h+8,9); 320 | printw("Press Shift-S again to end"); 321 | curs_set(1); 322 | 323 | while ((k=getch())!='S') { 324 | if (k==KEY_DOWN) h+=8; 325 | if (k==KEY_UP && h>8) h-=8; 326 | if (k==KEY_RIGHT) w+=8; 327 | if (k==KEY_LEFT && w>8) w-=8; 328 | clear(); 329 | draw_boxes(); 330 | updateCanvas(current_tile); 331 | displayCanvas(); 332 | move(h+7,9); 333 | attron(COLOR_PAIR(1)); 334 | printw("%d, %d - use arrows to change",h,w); 335 | attron(COLOR_PAIR(4)); 336 | move(h+8,9); 337 | attron(COLOR_PAIR(2)); 338 | printw("Press Shift+S again when finished"); 339 | refresh(); 340 | } 341 | 342 | curs_set(0); 343 | clear(); 344 | draw_boxes(); 345 | break; 346 | 347 | default: 348 | if (k >= '1' && k <= '4') 349 | color = k-'1'; 350 | break; 351 | } 352 | refresh(); 353 | } 354 | 355 | endwin(); 356 | printf("\033[?1003l\n"); 357 | return 0; 358 | } 359 | 360 | void initColors() 361 | { 362 | if (init_pair(1, COLOR_BLACK, COLOR_WHITE)==ERR) { 363 | printw("Woops..."); 364 | getch(); 365 | } 366 | init_pair(2, COLOR_BLACK, COLOR_YELLOW); 367 | init_pair(3, COLOR_WHITE, COLOR_GREEN); 368 | init_pair(4, COLOR_WHITE, COLOR_BLACK); 369 | 370 | init_color(COLOR_YELLOW, 150,650,400); 371 | init_color(COLOR_GREEN, 200,400,250); 372 | init_color(COLOR_BLACK, 100,200,150); 373 | } 374 | 375 | void updateCanvas(int tile) 376 | { 377 | extern unsigned char drawing_space[MAXH][MAXW]; 378 | extern unsigned char asset[256][16]; 379 | extern int h,w; 380 | 381 | int c; 382 | int i,j,l; 383 | int b1,b2; 384 | 385 | tile = tile % 256; 386 | 387 | for (i=0; i> 7); 399 | c = c | (((b2<> 6); 400 | 401 | drawing_space[i][j+l*8] = c; 402 | } 403 | } 404 | } 405 | } 406 | --------------------------------------------------------------------------------