this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

#1586: added `export mapimg ...` command

nesbox 4e7f1f17 c904c5e3

+40
+40
src/studio/screens/console.c
··· 105 105 macro(tiles) \ 106 106 macro(sprites) \ 107 107 macro(map) \ 108 + macro(mapimg) \ 108 109 macro(sfx) \ 109 110 macro(music) \ 110 111 macro(screen) \ ··· 2032 2033 memcpy(buffer, map->data, Size); 2033 2034 2034 2035 onFileExported(console, filename, tic_fs_save(console->fs, filename, buffer, Size, true)); 2036 + } 2037 + } 2038 + 2039 + static void onExport_mapimg(Console* console, const char* param, const char* path, ExportParams params) 2040 + { 2041 + const char* filename = getFilename(path, ".png"); 2042 + 2043 + enum{Width = TIC_MAP_WIDTH * TIC_SPRITESIZE, Height = TIC_MAP_HEIGHT * TIC_SPRITESIZE}; 2044 + 2045 + png_img img = {Width, Height, malloc(Width * Height * sizeof(png_rgba))}; 2046 + 2047 + SCOPE(free(img.data)) 2048 + { 2049 + { 2050 + tic_mem* tic = console->tic; 2051 + 2052 + tic_api_sync(tic, -1, params.bank, false); 2053 + 2054 + for(s32 r = 0; r < TIC_MAP_ROWS; r++) 2055 + for(s32 c = 0; c < TIC_MAP_COLS; c++) 2056 + { 2057 + tic_api_map(tic, c * TIC_MAP_SCREEN_WIDTH, r * TIC_MAP_SCREEN_HEIGHT, 2058 + TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, NULL, 0, 1, NULL, NULL); 2059 + 2060 + tic_core_blit(tic, tic->screen_format); 2061 + 2062 + for(s32 j = 0; j < TIC80_HEIGHT; j++) 2063 + for(s32 i = 0; i < TIC80_WIDTH; i++) 2064 + img.values[(i + c * TIC80_WIDTH) + (j + r * TIC80_HEIGHT) * Width] = 2065 + tic->screen[(i + TIC80_MARGIN_LEFT) + (j + TIC80_MARGIN_TOP) * TIC80_FULLWIDTH]; 2066 + } 2067 + } 2068 + 2069 + png_buffer png = png_write(img); 2070 + 2071 + SCOPE(free(png.data)) 2072 + { 2073 + onFileExported(console, filename, tic_fs_save(console->fs, filename, png.data, png.size, true)); 2074 + } 2035 2075 } 2036 2076 } 2037 2077