this repo has no description
0
fork

Configure Feed

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

whoa whoa whoa blit fixed?

alice b42976cb 7424aef9

+106 -5
+77 -4
src/studio/studio.c
··· 2232 2232 s32 sprite = CLAMP(tic->ram->vram.vars.cursor.sprite, 0, TIC_BANK_SPRITES - 1); 2233 2233 const tic_bank* bank = &tic->cart.bank0; 2234 2234 2235 - tic_point hot = {0}; 2235 + tic_point hot = {0}; // Default hot point 2236 2236 2237 2237 if(tic->ram->vram.vars.cursor.system) 2238 2238 { ··· 2253 2253 u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; 2254 2254 2255 2255 for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) 2256 + { 2256 2257 for(s32 x = s.x, endx = x + TIC_SPRITESIZE; x != endx; ++x, ++i, ++dst) 2257 - if(x < TIC80_FULLWIDTH) 2258 + { 2259 + if(x < TIC80_FULLWIDTH && x >= 0 && y >= 0) 2258 2260 { 2259 2261 u8 c = tic_tool_peek4(tile->data, i); 2260 - if(c) 2261 - *dst = tic_rgba(&pal->colors[c]); 2262 + if(c < TIC_PALETTE_SIZE) 2263 + { 2264 + const tic_rgb* color = &pal->colors[c]; 2265 + if(color->r >= 0 && color->r <= 255 && 2266 + color->g >= 0 && color->g <= 255 && 2267 + color->b >= 0 && color->b <= 255) 2268 + { 2269 + *dst = tic_rgba(color); 2270 + } 2271 + else 2272 + { 2273 + // Log an error message with debug information 2274 + fprintf(stderr, "Invalid color values detected at position (%d, %d):\n", x, y); 2275 + fprintf(stderr, " Color index: %d\n", (int)c); 2276 + fprintf(stderr, " RGB values: (%d, %d, %d)\n", (int)color->r, (int)color->g, (int)color->b); 2277 + 2278 + // Set a default color or skip drawing 2279 + tic_rgb DefaultColor = {255, 0, 255}; // Example default color (magenta) 2280 + *dst = tic_rgba(&DefaultColor); 2281 + } 2282 + } 2262 2283 } 2284 + } 2285 + } 2263 2286 } 2264 2287 } 2288 + // static void blitCursor(Studio* studio) 2289 + // { 2290 + // tic_mem* tic = studio->tic; 2291 + // tic80_mouse* m = &tic->ram->input.mouse; 2292 + 2293 + // if(tic->input.mouse && !m->relative && m->x < TIC80_FULLWIDTH && m->y < TIC80_FULLHEIGHT) 2294 + // { 2295 + // s32 sprite = CLAMP(tic->ram->vram.vars.cursor.sprite, 0, TIC_BANK_SPRITES - 1); 2296 + // const tic_bank* bank = &tic->cart.bank0; 2297 + 2298 + // tic_point hot = {0}; // Default hot point 2299 + 2300 + // if(tic->ram->vram.vars.cursor.system) 2301 + // { 2302 + // bank = &getConfig(studio)->cart->bank0; 2303 + // hot = (tic_point[]) 2304 + // { 2305 + // {0, 0}, 2306 + // {3, 0}, 2307 + // {2, 3}, 2308 + // }[CLAMP(sprite, 0, 2)]; 2309 + // } 2310 + // else if(sprite == 0) return; 2311 + 2312 + // const tic_palette* pal = &bank->palette.vbank0; 2313 + // const tic_tile* tile = &bank->sprites.data[sprite]; 2314 + 2315 + // tic_point s = {m->x - hot.x, m->y - hot.y}; 2316 + // u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; 2317 + 2318 + // for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) 2319 + // for(s32 x = s.x, endx = x + TIC_SPRITESIZE; x != endx; ++x, ++i, ++dst) 2320 + // if(x < TIC80_FULLWIDTH) 2321 + // { 2322 + // u8 c = tic_tool_peek4(tile->data, i); 2323 + // if(c < TIC_PALETTE_SIZE) // Ensure the color index is within the palette size 2324 + // { 2325 + // const tic_rgb* color = &pal->colors[c]; 2326 + // if(color) // Check if the pointer to the color is not null 2327 + // *dst = tic_rgba(color); 2328 + // else 2329 + // printf("Null pointer for color index %d\n", c); 2330 + // } 2331 + // else 2332 + // { 2333 + // printf("Invalid color index %d\n", c); 2334 + // } 2335 + // } 2336 + // } 2337 + // } 2265 2338 2266 2339 tic_mem* getMemory(Studio* studio) 2267 2340 {
+29 -1
src/tools.h
··· 25 25 #include "api.h" 26 26 #include "tic.h" 27 27 #include <stddef.h> 28 + #include <stdio.h> 28 29 29 30 inline s32 tic_tool_sfx_pos(s32 speed, s32 ticks) 30 31 { ··· 74 75 #undef PEEK_N 75 76 #undef POKE_N 76 77 78 + // inline u32 tic_rgba(const tic_rgb* c) 79 + // { 80 + // if (c == NULL) { 81 + // printf("tic_rgba: c is NULL\n"); 82 + // return 0; // Return a default value indicating error or invalid input. 83 + // } 84 + 85 + // // Ensure the color components are within the 0-255 range using bitwise AND with 0xFF 86 + // u32 r = (c->r & 0xff); 87 + // u32 g = (c->g & 0xff); 88 + // u32 b = (c->b & 0xff); 89 + 90 + // // Construct the RGBA value 91 + // return (0xff << 24) | (b << 16) | (g << 8) | r; 92 + // } 93 + // #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) 77 94 inline u32 tic_rgba(const tic_rgb* c) 78 95 { 79 - return (0xff << 24) | (c->b << 16) | (c->g << 8) | (c->r << 0); 96 + if (c == NULL) { 97 + printf("tic_rgba: c is NULL\n"); 98 + return 0; // Return a default value indicating error or invalid input. 99 + } 100 + u8 r = (u8)CLAMP(c->r, 0, 255); 101 + u8 g = (u8)CLAMP(c->g, 0, 255); 102 + u8 b = (u8)CLAMP(c->b, 0, 255); 103 + return (u32)((0xffu << 24) | ((u32)b << 16) | ((u32)g << 8) | (u32)r); 80 104 } 105 + // inline u32 tic_rgba(const tic_rgb* c) 106 + // { 107 + // return (0xff << 24) | (c->b << 16) | (c->g << 8) | (c->r << 0); 108 + // } 81 109 82 110 inline s32 tic_modulo(s32 x, s32 m) 83 111 {