2020-03-17 20:04:24 +00:00
|
|
|
extern "C" {
|
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
void ptn_snap_8(screen_x_t left, vram_y_t top, int ptn_id)
|
2020-03-17 20:04:24 +00:00
|
|
|
{
|
|
|
|
unsigned int vram_offset = vram_offset_muldiv(left, top);
|
|
|
|
ptn_t *ptn = ptn_with_id(ptn_id);
|
2020-08-21 18:13:08 +00:00
|
|
|
for(pixel_t y = 0; y < PTN_H; y++) {
|
2020-03-17 20:04:24 +00:00
|
|
|
#define snap(ptn, vram_offset, w) \
|
|
|
|
ptn->planes.B[y] = VRAM_CHUNK(B, vram_offset, w); \
|
|
|
|
ptn->planes.R[y] = VRAM_CHUNK(R, vram_offset, w); \
|
|
|
|
ptn->planes.G[y] = VRAM_CHUNK(G, vram_offset, w); \
|
|
|
|
ptn->planes.E[y] = VRAM_CHUNK(E, vram_offset, w);
|
|
|
|
snap(ptn, vram_offset, PTN_W);
|
|
|
|
#undef snap
|
|
|
|
vram_offset += ROW_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-21 18:13:08 +00:00
|
|
|
static inline ptn_dots_t dot_mask(pixel_t x, pixel_t w)
|
2020-03-17 20:04:24 +00:00
|
|
|
{
|
|
|
|
return static_cast<ptn_dots_t>((1u << w) - 1u) << (w - x);
|
|
|
|
}
|
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
void ptn_snap_quarter_8(
|
|
|
|
screen_x_t left, vram_y_t top, int ptn_id, int quarter
|
|
|
|
)
|
2020-03-17 20:04:24 +00:00
|
|
|
{
|
2020-08-21 18:13:08 +00:00
|
|
|
pixel_t y;
|
2020-03-17 20:04:24 +00:00
|
|
|
unsigned int vram_offset = vram_offset_muldiv(left, top);
|
2020-08-21 18:13:08 +00:00
|
|
|
pixel_t q_y;
|
2020-03-17 20:04:24 +00:00
|
|
|
ptn_dots_t q_mask;
|
|
|
|
long q_x;
|
|
|
|
ptn_t *ptn = ptn_with_id(ptn_id);
|
|
|
|
|
|
|
|
q_y = ptn_quarter_y(quarter);
|
|
|
|
q_mask = (quarter & 1)
|
|
|
|
? dot_mask(PTN_QUARTER_W, PTN_QUARTER_W)
|
|
|
|
: dot_mask( 0, PTN_QUARTER_W);
|
|
|
|
q_x = ptn_quarter_x(quarter);
|
|
|
|
|
|
|
|
for(y = q_y; y < (q_y + PTN_QUARTER_H); y++) {
|
|
|
|
#define snap_quarter_plane(P, offset, w) \
|
|
|
|
ptn->planes.P[y] &= q_mask; \
|
|
|
|
ptn->planes.P[y] |= (VRAM_CHUNK(P, offset, w) << q_x) & ~q_mask;
|
|
|
|
|
|
|
|
#define snap_quarter(offset, w) \
|
|
|
|
snap_quarter_plane(B, offset, w); \
|
|
|
|
snap_quarter_plane(R, offset, w); \
|
|
|
|
snap_quarter_plane(G, offset, w); \
|
|
|
|
snap_quarter_plane(E, offset, w);
|
|
|
|
|
|
|
|
snap_quarter(vram_offset, PTN_W);
|
|
|
|
|
|
|
|
#undef snap_quarter
|
|
|
|
#undef snap_quarter_plane
|
|
|
|
vram_offset += ROW_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|