pxl8/src/pxl8_blit.c

36 lines
1 KiB
C
Raw Normal View History

2025-08-13 15:04:49 -05:00
#include "pxl8_blit.h"
2025-11-28 14:41:35 -06:00
void pxl8_blit_hicolor(u16* fb, u32 fb_width, const u16* sprite, u32 atlas_width,
i32 x, i32 y, u32 w, u32 h) {
2025-11-28 14:41:35 -06:00
u16* dest_base = fb + y * fb_width + x;
const u16* src_base = sprite;
2025-08-13 15:04:49 -05:00
for (u32 row = 0; row < h; row++) {
2025-11-28 14:41:35 -06:00
u16* dest_row = dest_base + row * fb_width;
const u16* src_row = src_base + row * atlas_width;
for (u32 col = 0; col < w; col++) {
2025-11-28 14:41:35 -06:00
if (src_row[col] != 0) {
2025-08-13 15:04:49 -05:00
dest_row[col] = src_row[col];
}
}
}
}
void pxl8_blit_indexed(u8* fb, u32 fb_width, const u8* sprite, u32 atlas_width,
i32 x, i32 y, u32 w, u32 h) {
2025-09-28 13:10:29 -05:00
u8* dest_base = fb + y * fb_width + x;
const u8* src_base = sprite;
2025-08-13 15:04:49 -05:00
for (u32 row = 0; row < h; row++) {
2025-09-28 13:10:29 -05:00
u8* dest_row = dest_base + row * fb_width;
const u8* src_row = src_base + row * atlas_width;
for (u32 col = 0; col < w; col++) {
2025-09-28 13:10:29 -05:00
if (src_row[col] != 0) {
2025-08-13 15:04:49 -05:00
dest_row[col] = src_row[col];
}
}
}
}