1
General Jo Engine Help / 50Hz / 60Hz detection?
« Last post by FranMatsusaka on March 22, 2022, 10:35:34 am »It is possible to dectect if the consol is running at 60Hz (NTSC) or 50Hz (PAL)?
Thanks in advance
Thanks in advance
void jo_img_to_vdp2_cells(const jo_img_8bits * const img, const bool vertical_flip, unsigned char *cell)
{
register int x;
register int y;
register int cell_x;
register int cell_y;
register int line_y;
register int i;
#ifdef JO_DEBUG
if (img == JO_NULL)
{
jo_core_error("img is null");
return ;
}
if (JO_MOD_POW2(img->width, 8) != 0)
{
jo_core_error("Image width must be multiple of 8");
return ;
}
if (JO_MOD_POW2(img->height, 8) != 0)
{
jo_core_error("Image height must be multiple of 8");
return ;
}
#endif
for (JO_ZERO(y), JO_ZERO(line_y); y < img->height; y += CELL_HEIGHT, line_y += JO_MULT_BY_8(img->width))
{
for (JO_ZERO(x); x < img->width; x += CELL_WIDTH)
{
cell_x = x;
cell_y = line_y;
for (JO_ZERO(i); i < CELL_SIZE; ++i, ++cell, ++cell_x)
{
if (i != 0 && JO_MOD_POW2(i, CELL_WIDTH) == 0)
{
cell_x -= CELL_WIDTH;
cell_y += img->width;
}
/**/
if (vertical_flip)
*cell = img->data[(img->width - cell_x - 1) + cell_y];
else
/**/
*cell = img->data[cell_x + cell_y];
}
}
}
}
static void __jo_create_map(const jo_img_8bits * const img, unsigned short *map, const unsigned short palette_id, const int map_offset)
{
register int x;
register int y;
register int x2;
register int y2;
register int i;
unsigned short paloff;
paloff = JO_MULT_BY_4096(palette_id);
y = JO_DIV_BY_8(img->height);
x = JO_DIV_BY_8(img->width);
JO_ZERO(y2);
JO_ZERO(x2);
for (JO_ZERO(i); i < MAP_LENGTH; ++i)
{
/*
if (i != 0 && JO_MOD_POW2(i, CELL_COUNT_PER_ROW) == 0)
++y2;
if (y2 >= y)
JO_ZERO(y2);
*map = (JO_MULT_BY_2(x2 + y2 * y) | paloff) + map_offset;
++map;
++x2;
if (x2 >= x)
JO_ZERO(y2);
/**/
if (i != 0 && JO_MOD_POW2(i, CELL_COUNT_PER_ROW) == 0) {
JO_ZERO(x2);
++y2;
/*
if (y2 >= y) {
JO_ZERO(y2);
}*/
}
*map = (JO_MULT_BY_2(x2 + y2 * x) | paloff) + map_offset;
++map;
++x2;
/**/
}
}
Check the "demo - vdp2 plane".
While not exactly what you want, it does demonstrate the process of loading an indexed color targa file to a VDP2 background layer.
You could copy this structure entirely, and simply not rotate the background layer.
//jo_img bg;
//bg.data = NULL;
//jo_tga_loader(&bg, "BGO", image_to_load, JO_COLOR_Transparent);
//if (bg.data != NULL) {
//jo_set_background_sprite(&bg, 0, 0);
//jo_free_img(&bg);
//}
jo_img_8bits bg;
bg.data = NULL;
jo_tga_8bits_loader(&bg, "BG8", image_to_load, JO_COLOR_Transparent);
if (bg.data != NULL) {
jo_set_background_8bits_sprite(&bg, 0, false);
jo_free_img(&bg);
}