/* Keep these headers */ #include #include #include #include /* Standard headers - it's recommended to leave them included */ #include #include #include #include #include "map.h" #include "mem.h" #include "rle.h" uint8_t* map = {0}; /* Your code here */ // map data is RLE-compressed // bits 0-4 : tile ID (5-bits) // bits 5-7 : number (3-bits) // 0 value for end of data uint8_t* initMap1(uint8_t* map) { uint8_t map_C[] = {225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,129,198,97,64,41,32,65,36,64,68,32,36,32,45,32,100,65,68,96,36,32,45,96,68,65,224,192,65,160,45,224,192,68,128,100,65,224,128,68,65,134,161,102,33,134,33,166,225,36,128,68,33,32,193,224,32,33,37,32,74,65,224,224,224,224,65,39,128,74,160,40,65,39,224,128,43,224,224,224,224,224,224,224,224,128,65,224,33,64,41,64,65,42,64,43,128,33,37,161,39,224,224,128,42,32,42,192,65,128,140,160,65,192,42,96,37,129,37,224,96,42,224,160,42,224,224,224,224,160,65,224,64,43,32,43,42,65,44,32,33,34,32,33,37,44,33,37,96,65,224,43,224,37,32,35,33,108,33,96,33,134,37,192,79,96,65,96,37,108,37,70,37,225,225,225,225,225,79,33,79,97,79,33,79,33,47,97,47,224,32,65,192,37,225,33,160,45,37,32,33,230,134,204,46,76,33,37,160,44,128,44,37,96,37,128,37,32,65,224,32,37,96,37,64,37,224,224,96,65,134,44,45,192,36,225,225,225,33,224,40,65,39,160,37,192,65,192,37,224,32,37,192,37,32,43,96,65,76,37,102,44,128,33,37,65,32,37,96,69,102,37,224,37,96,37,64,37,160,43,192,42,96,43,65,96,43,128,37,128,65,224,192,65,224,192,65,192,37,102,161,39,160,37,224,32,37,140,37,32,37,65,96,65,64,37,32,44,37,64,37,76,33,37,65,37,128,37,128,37,76,225,225,129,44,34,37,32,35,140,34,37,97,37,44,46,33,128,37,44,37,32,40,65,39,192,43,64,42,64,65,39,224,160,65,224,64,37,96,65,192,37,224,32,37,128,37,32,37,224,64,37,32,33,37,32,43,37,96,37,65,37,134,37,224,224,224,43,65,96,37,224,37,32,65,37,64,33,96,43,37,32,37,224,37,33,140,33,44,33,32,65,224,192,65,32,33,32,49,58,59,49,58,59,37,32,33,32,65,224,224,192,37,32,37,224,64,37,32,33,108,33,37,64,37,65,37,224,64,108,65,44,37,224,32,37,44,46,65,32,33,39,37,224,37,96,37,64,33,37,44,46,44,34,32,76,37,65,37,64,37,65,172,33,32,65,160,49,58,59,49,58,59,129,32,65,240,65,32,65,96,43,224,160,42,96,37,32,37,224,64,37,32,33,96,33,37,64,37,65,224,192,65,42,37,192,43,32,37,42,32,65,32,37,42,37,224,37,96,37,96,37,224,37,65,37,64,37,33,192,33,32,65,128,33,208,129,42,33,240,80,33,32,97,37,225,33,96,225,225,225,65,37,225,97,79,33,79,65,47,225,225,97,32,97,37,225,225,225,225,161,192,161,96,33,208,193,240,80,161,37,225,33,96,225,225,225,65,37,225,225,225,225,225,32,97,37,225,225,225,225,161,192,161,96,33,208,193,240,80,129,32,37,38,37,32,45,96,33,96,65,64,196,224,224,192,65,224,192,65,192,45,64,43,32,33,32,65,32,37,68,96,68,32,100,65,224,192,65,32,45,32,68,224,32,65,128,33,208,129,39,97,240,129,96,37,128,40,33,96,65,39,224,224,224,32,44,230,230,33,96,43,65,64,42,192,35,44,33,32,65,32,37,224,128,65,108,39,224,32,40,65,224,160,40,65,128,35,33,208,97,74,32,161,144,97,96,37,38,37,96,33,96,65,224,224,224,192,40,65,39,224,64,75,42,65,37,44,34,224,32,33,32,65,39,37,160,33,224,32,65,224,224,32,33,224,64,65,160,35,33,176,161,37,96,37,65,112,97,160,37,96,33,96,65,160,35,65,172,65,44,37,224,128,65,160,75,64,37,35,129,37,224,64,40,33,32,65,32,37,160,33,39,224,53,224,192,42,32,37,33,224,32,40,65,39,160,35,33,240,48,161,80,33,112,97,32,43,42,64,37,38,37,32,33,47,64,65,192,68,160,65,32,37,64,129,37,33,64,40,65,128,35,65,34,32,37,96,65,37,64,37,108,34,96,33,32,65,32,37,160,33,96,35,44,65,108,37,33,140,33,37,76,65,76,37,33,224,64,65,192,40,65,240,144,65,176,97,37,76,34,96,37,32,65,64,65,39,224,160,65,39,37,32,33,34,68,32,37,35,33,64,65,39,224,32,37,64,40,65,37,43,32,37,224,33,32,65,32,37,160,33,42,128,65,96,37,33,128,33,37,64,65,64,37,224,96,65,224,32,35,225,33,144,97,112,97,37,192,37,32,37,33,32,97,224,192,65,32,37,65,32,51,56,32,37,32,65,32,65,224,64,37,96,65,76,34,37,192,42,33,32,65,39,37,160,33,76,46,129,39,64,37,33,128,33,37,32,40,65,192,35,76,34,37,224,192,100,32,161,240,80,97,37,230,38,37,33,64,65,96,43,32,50,160,42,32,65,39,32,65,32,52,57,32,37,32,65,32,65,224,64,37,96,65,96,37,128,35,76,33,32,65,32,37,224,128,65,96,37,33,128,33,37,64,97,230,70,37,224,224,64,97,64,35,65,176,161,224,64,37,33,64,65,64,193,64,47,129,64,193,37,97,32,65,64,107,128,37,64,43,65,39,64,37,224,33,32,65,32,37,224,128,65,96,37,33,128,33,37,64,65,224,96,37,35,44,129,37,192,35,97,192,35,161,34,64,65,192,43,64,37,33,64,65,64,193,64,161,64,37,225,33,37,32,65,235,42,32,37,74,43,65,96,37,128,37,64,33,32,65,32,37,160,43,96,75,65,96,37,33,64,74,33,37,64,65,32,43,224,32,37,32,42,65,43,32,37,128,42,64,53,32,43,128,42,224,32,42,32,161,37,225,64,65,64,193,64,225,37,225,33,37,225,225,225,161,37,97,32,97,37,225,225,65,37,33,44,129,37,225,225,225,97,37,225,225,225,193,37,225,64,65,64,193,64,225,37,225,33,37,225,225,225,161,37,97,32,97,37,225,225,65,37,33,32,129,37,225,225,225,97,37,225,225,225,97,68,32,37,192,33,64,65,96,132,96,68,32,65,64,37,128,42,96,37,32,65,224,45,160,65,42,128,45,64,37,64,33,32,65,32,37,224,96,42,65,96,37,33,64,33,39,32,37,64,65,64,65,68,32,36,96,68,65,160,37,224,65,64,36,32,45,32,68,128,36,65,224,64,40,33,64,65,224,160,40,65,64,37,64,35,76,34,64,37,32,97,32,129,37,64,33,102,65,76,37,166,37,32,40,33,32,65,32,37,224,32,43,32,44,65,39,96,33,64,33,32,42,37,32,40,65,32,60,224,128,65,39,128,37,192,40,65,39,224,160,65,128,37,44,46,33,64,33,64,65,224,192,65,64,37,224,32,37,32,65,160,65,192,65,64,37,160,37,64,33,32,65,32,37,224,35,34,64,65,42,96,33,64,33,76,37,64,65,37,97,37,224,224,32,37,96,75,224,224,96,65,128,37,64,45,32,42,33,64,65,224,160,40,65,64,37,224,32,37,32,65,39,96,42,224,32,65,39,32,37,160,37,32,40,33,32,65,32,37,224,64,43,42,65,76,160,33,64,37,64,65,37,32,45,32,37,224,96,37,76,37,108,33,108,33,37,224,192,42,32,65,64,43,32,37,32,37,32,37,44,33,64,65,224,192,65,64,37,44,47,44,64,44,47,44,37,32,65,32,37,108,34,64,37,76,47,32,65,64,37,224,32,33,32,65,32,37,160,35,34,64,76,65,224,33,43,32,37,64,65,128,33,76,34,64,35,76,65,37,64,37,96,45,96,225,33,32,129,46,161,37,108,34,32,37,32,37,32,33,64,65,192,42,160,37,65,64,37,32,33,128,33,32,37,32,65,32,37,192,37,32,65,32,65,64,37,192,35,65,32,65,32,37,128,43,96,40,33,32,65,39,192,33,108,37,44,65,128,33,224,32,65,76,46,44,37,96,43,128,65,224,42,128,36,65,37,128,43,37,32,37,32,33,64,65,160,35,140,34,32,37,65,75,37,32,33,39,64,40,33,32,37,43,65,32,37,192,37,32,42,32,42,97,108,33,224,32,65,32,37,96,35,34,160,40,65,64,43,96,47,33,96,37,32,65,128,33,224,32,65,128,37,172,37,64,65,37,198,33,160,65,37,128,35,108,37,33,64,65,224,160,37,97,44,97,128,33,46,33,44,65,32,37,42,128,35,76,33,46,97,236,44,65,34,64,65,32,37,224,128,65,32,37,76,37,76,33,39,64,37,32,65,32,37,224,128,65,37,32,42,32,37,160,37,128,37,224,160,65,37,224,32,37,33,64,65,224,160,37,224,224,32,65,32,140,37,224,65,128,44,33,76,32,33,96,65,32,37,65,224,64,65,32,37,64,37,64,45,96,37,32,65,32,37,224,128,65,37,44,46,44,37,128,37,76,37,64,37,224,160,65,37,42,224,37,33,64,65,64,43,224,64,37,224,192,43,32,65,43,128,37,192,43,65,32,74,96,42,64,33,96,65,32,37,224,128,65,32,37,64,37,160,42,37,32,65,32,37,64,42,224,32,65,37,96,37,128,37,32,42,37,97,43,64,47,37,224,161,37,225,64,65,64,65,239,225,65,37,65,37,225,129,37,0}; uint8_t* ptr_out=0; decompRLE(map, map_C, 5, 0, &ptr_out, 0x80, 0, 0); return ptr_out; } void initMap2(uint8_t* map) { uint8_t map_C[] = {225,65,140,193,79,129,37,65,239,225,225,161,47,37,33,47,65,239,225,225,225,33,37,225,161,37,225,64,65,64,225,225,129,37,65,37,225,129,37,225,65,128,225,161,37,225,225,225,225,33,37,225,225,225,225,161,37,225,65,96,37,64,45,96,33,64,65,64,36,128,37,32,100,32,65,32,45,96,37,64,37,128,65,160,37,224,65,224,192,65,32,37,160,45,160,65,224,192,65,32,37,96,45,224,65,64,100,32,132,32,68,65,96,33,32,37,224,65,96,37,160,43,33,64,65,64,43,32,54,32,33,37,128,40,65,192,97,108,37,65,160,37,70,37,128,65,39,224,160,65,32,37,224,43,42,64,65,128,43,96,42,128,65,32,37,224,96,40,65,39,224,160,65,96,33,32,37,192,40,65,39,32,35,44,34,37,64,76,33,64,65,64,35,46,97,37,160,65,192,97,96,37,65,39,128,37,64,37,96,40,65,224,161,32,65,32,37,108,46,204,37,65,96,37,33,102,33,102,44,65,32,37,224,128,65,224,64,43,128,33,96,33,32,37,224,65,160,37,128,33,64,65,224,192,65,76,34,96,65,128,37,65,128,69,64,69,96,65,224,33,32,97,32,65,32,37,224,96,37,65,96,37,224,160,37,224,44,64,40,65,39,192,37,225,65,37,33,32,37,38,37,160,65,160,37,134,33,64,65,96,49,58,59,49,58,59,49,58,59,32,65,192,65,39,96,37,65,128,37,128,37,96,65,39,192,33,64,41,33,32,65,32,37,224,96,37,65,39,64,37,224,160,37,64,33,44,64,76,96,65,224,37,160,65,64,37,128,37,160,65,39,128,37,128,33,64,65,64,33,240,80,97,192,65,128,37,65,39,64,69,128,69,32,40,65,224,53,96,33,32,65,32,37,32,42,224,32,37,65,96,37,224,76,65,76,33,32,76,46,32,42,32,33,64,65,39,192,37,128,40,65,64,37,32,79,32,37,96,129,96,42,32,37,128,33,64,65,64,33,240,80,97,37,32,42,96,65,76,37,76,65,96,37,192,37,64,65,64,37,236,76,47,65,32,37,172,46,37,140,65,96,37,224,64,65,64,33,134,76,70,33,38,65,224,37,160,65,64,37,32,65,224,65,32,37,35,140,34,37,32,33,64,65,64,33,240,80,97,37,172,65,64,37,32,97,64,69,192,69,32,65,44,32,37,33,96,204,65,32,37,192,37,128,161,76,33,140,79,97,128,44,32,33,192,65,39,224,128,40,97,38,37,134,65,96,40,65,32,37,192,37,32,33,64,65,64,65,240,80,65,37,160,65,64,37,32,33,128,37,224,32,37,160,37,33,224,64,65,32,37,192,37,96,40,65,140,65,108,33,108,65,96,65,64,76,65,44,97,224,192,97,32,37,224,96,65,43,37,96,42,64,37,32,33,64,65,64,65,240,80,65,37,64,42,64,65,43,32,37,32,53,128,37,42,224,37,160,37,33,42,96,55,128,65,32,37,96,42,64,37,64,43,32,65,224,192,65,75,160,44,64,42,64,65,224,192,97,224,160,97,37,193,37,65,64,65,64,193,80,65,48,225,37,129,37,225,33,37,143,225,225,97,79,97,37,225,225,33,79,65,79,32,111,225,225,225,97,96,225,143,33,47,65,47,193,37,193,37,65,64,65,64,193,80,65,48,225,37,129,37,225,33,37,225,225,225,161,37,225,225,225,32,225,225,225,193,96,225,225,225,32,37,43,64,45,64,37,32,33,64,65,128,161,144,97,128,37,32,65,32,37,64,65,96,45,32,36,96,68,64,65,224,32,45,128,65,32,37,32,68,64,36,160,65,32,68,32,100,64,68,64,65,36,160,36,64,68,32,36,65,32,97,68,96,36,45,64,65,68,224,128,65,32,76,128,76,32,33,64,65,192,35,161,112,97,128,65,32,37,64,65,224,160,40,65,39,224,224,32,37,224,96,40,65,39,224,128,40,65,32,129,224,192,33,224,32,40,65,224,64,76,64,65,224,42,64,33,64,65,192,40,193,144,65,96,65,32,37,32,40,65,224,224,224,224,96,37,224,32,42,64,65,224,192,225,33,224,128,65,32,37,97,37,96,65,224,32,43,128,65,192,65,64,33,64,65,224,64,129,176,33,96,65,32,37,64,65,224,224,224,32,37,44,65,76,225,225,97,224,192,97,132,65,32,37,44,46,76,65,46,37,33,64,37,96,37,96,65,39,192,76,96,40,65,39,128,43,96,40,33,64,65,224,96,161,112,33,96,65,32,37,64,225,34,96,35,65,37,65,140,37,70,37,160,65,68,224,128,65,224,192,65,39,128,40,33,32,37,128,65,32,37,33,64,37,96,140,65,192,43,32,36,128,65,128,76,128,33,64,65,224,64,40,161,112,65,42,128,37,64,65,128,47,96,43,64,42,37,65,128,37,64,37,224,224,160,40,65,224,192,65,96,61,64,33,38,37,102,37,65,32,37,33,108,34,224,192,76,192,65,224,96,33,42,32,65,224,128,161,112,65,32,75,32,37,32,42,65,42,96,225,33,37,65,32,42,64,37,64,37,224,224,32,74,32,43,32,65,224,64,74,64,97,37,108,37,33,32,37,96,37,65,32,37,33,64,36,224,224,68,96,47,32,47,65,224,96,65,32,65,224,192,97,144,225,129,37,49,58,59,49,58,59,49,58,59,225,129,37,32,37,108,97,108,33,76,65,140,97,108,33,76,225,33,45,37,96,37,33,32,37,33,32,33,37,65,32,37,33,43,192,37,129,44,64,76,160,33,32,97,32,76,166,37,65,64,65,224,192,97,240,240,208,33,240,48,33,176,65,32,37,96,65,224,224,224,224,65,32,37,96,37,33,32,37,33,32,33,32,65,32,37,33,76,37,128,37,64,65,96,36,224,64,65,42,64,43,32,43,64,37,32,33,64,65,64,43,128,43,64,106,97,240,240,208,33,240,112,97,48,65,32,37,64,42,65,32,42,224,224,32,43,224,32,74,65,32,37,96,37,53,32,37,33,32,33,32,65,32,37,33,43,32,37,128,37,64,65,224,96,47,32,47,97,79,97,47,33,37,65,64,65,108,33,76,225,225,225,225,225,225,33,112,225,225,225,225,37,33,37,225,225,97,32,161,37,225,225,111,65,79,97,32,225,129,37,65,64,65,192,225,225,225,225,225,225,33,112,225,225,225,225,37,33,37,225,225,97,32,161,37,225,225,225,97,32,97,160,43,42,32,37,32,33,64,65,224,192,65,64,132,32,45,32,100,32,65,224,64,45,96,65,64,65,144,33,45,32,43,42,65,192,45,192,65,128,36,37,33,37,32,100,160,37,192,33,32,33,32,65,32,37,96,45,224,65,224,45,64,33,64,65,128,37,44,33,46,44,32,33,64,65,96,111,224,224,224,224,224,64,65,32,42,33,144,65,32,37,129,224,192,65,39,128,37,33,37,160,65,76,37,70,37,102,33,32,33,32,65,32,37,224,128,65,32,44,224,32,33,64,65,39,32,37,76,32,45,96,33,224,35,33,34,128,42,128,43,224,128,42,160,74,43,192,40,65,37,65,144,33,64,37,64,65,224,33,134,97,224,192,65,160,37,43,64,33,32,33,32,65,32,37,172,37,128,40,65,32,172,37,96,36,64,65,64,37,160,35,44,33,224,37,96,43,37,108,37,172,37,192,37,236,108,224,65,37,33,144,65,39,32,37,64,65,224,192,65,224,47,160,65,39,64,43,32,37,65,160,65,32,37,160,37,160,65,64,100,32,37,192,65,64,37,224,33,224,37,35,34,32,76,32,45,32,37,160,37,128,42,32,37,224,32,76,224,65,37,33,144,65,64,37,64,65,64,33,96,74,96,37,32,65,39,192,33,160,65,64,97,37,32,41,160,65,32,37,64,43,32,43,37,128,40,65,39,160,37,192,65,39,32,37,230,33,32,42,65,96,37,32,42,192,37,160,37,32,35,140,37,224,32,76,39,192,65,37,65,144,65,32,37,192,33,46,161,64,37,32,65,128,49,58,59,49,58,59,49,58,59,65,128,33,37,64,43,128,65,32,37,108,46,76,34,128,65,128,37,108,37,128,65,64,37,224,33,76,65,34,37,236,37,64,37,160,37,96,68,32,37,224,32,68,224,64,37,32,35,33,144,33,32,37,128,43,96,161,39,32,37,32,65,75,42,33,240,80,65,39,96,161,32,33,32,40,65,32,37,128,68,160,65,96,43,37,96,37,32,35,129,64,37,192,65,160,37,224,37,204,37,32,37,224,224,224,160,37,64,33,144,225,97,49,58,59,33,49,58,59,49,58,59,193,240,80,65,224,192,65,32,37,224,224,32,76,37,96,37,128,65,64,37,192,41,192,37,224,37,192,37,32,37,224,224,224,160,37,64,35,33,240,240,80,33,240,240,240,65,224,192,65,32,37,224,224,96,37,96,37,108,37,65,32,43,37,224,192,37,42,32,43,128,37,43,32,42,96,37,32,37,224,160,43,32,43,224,128,37,96,33,240,240,80,33,240,240,240,65,224,192,65,32,37,224,224,96,37,224,37,65,47,225,225,225,225,97,47,225,225,225,225,225,225,225,225,225,225,97,143,129,47,33,47,225,225,225,225,129,0}; decompRLE(map, map_C, 5, 0, 0, 0x80, 0, 0); } uint8_t* initMap() { int i; uint8_t* ptr; map = (uint8_t*)myMalloc(MAP_SIZE); ptr=map; memset(map, 1, MAP_SIZE); initMap2(initMap1(map)); return map; } void initEndRoom(int rx, int ry) { uint8_t map_C[] = { 225,225,33,0, 225,225,33,0, 161,34,64,68,35,129,0, 97,34,36,192,36,97,0, 65,34,224,64,35,65,0, 65,224,128,65,0, 65,39,224,64,40,65,0, 65,224,128,65,0, 65,224,128,65,0, 65,70,225,129,0, 65,64,129,191,65,0, 97,47,225,129,0, }; uint8_t* ptr_in = map_C, i=0; uint8_t* ptr_out = getMapPtr(rx*ROOM_WIDTH,ry*ROOM_HEIGHT); for(i=0; i