GAMELIB16 その5

メガドライブのSGDKも共通APIでラップしました。

http://www.geocities.jp/parallel_computer_inc/gamelib16.zip

f:id:tanam:20180117054549j:image:w360

void wwc_set_color_mode(int mode);
void wwc_font_set_colordata(u16 tilestart, u16 noftiles, u16 *data);
void wwc_palette_set_color(u8 palettenumber, u8 colornumber, u16 color);
void screen_set_char(u8 layer, u8 xts, u8 yts, u8 xte, u8 yte, u16 *map);
void screen_set_scroll(u8 layer, u8 x, u8 y);
void display_control(u8 mode);
void sprite_set_range(u8 sprstart, u8 sprend);
void sprite_set_location(u8 sprite_no, u8 x, u8 y);
void sprite_set_char(u8 sprite_no, u16 char_data);
u8 key_press_check(void);
void sys_wait(u16 nofvbl);
void wwc_set_color_mode(int x)
{
	VDP_init();
	VDP_setScreenWidth256();
	VDP_setScreenHeight224();
	VDP_setPalette(0, color.palette->data);
	return;
}
void wwc_font_set_colordata(u16 tilestart, u16 noftiles, u16 *data)
{
	VDP_loadTileSet(&fonts, TILE_USERINDEX, TRUE);
	return;
}
void screen_set_char(u8 layer, u8 xts, u8 yts, u8 xte, u8 yte, u16 *map)
{
	int x, y;
	u8 xy;
	for (y = yts; y < SCREEN_HEIGHT; y++) {
		for (x = xts; x < SCREEN_WIDTH; x++) {
			xy = map[y*SCREEN_WIDTH+x];
			VDP_setTileMapXY(PLAN_A, TILE_USERINDEX + xy, x, y);
		}
	}
	return;
}
void screen_set_scroll(u8 layer, u8 x, u8 y) {
	VDP_setHorizontalScroll(PLAN_A, x);
	VDP_setVerticalScroll(PLAN_A, y);
	return;
}
void sprite_set_location(u8 sprite_no, u8 x, u8 y) {
	if (sprite_no == 31) VDP_setSpriteFull(sprite_no, x, y, SPRITE_SIZE(1,1), TILE_ATTR_FULL(PAL0,1,0,0,TILE_USERINDEX+128 + sprite_no * 8), 0);
	else VDP_setSpriteFull(sprite_no, x, y, SPRITE_SIZE(1,1), TILE_ATTR_FULL(PAL0,1,0,0,TILE_USERINDEX+128 + sprite_no * 8), sprite_no+1);
	return;
}
#define KEY_UP1     BUTTON_UP
#define KEY_DOWN1   BUTTON_DOWN
#define KEY_LEFT1   BUTTON_LEFT
#define KEY_RIGHT1  BUTTON_RIGHT
#define KEY_A       BUTTON_A
#define KEY_B       BUTTON_B

u8 key_press_check(void)
{
	return JOY_readJoypad(JOY_1);
}
void sys_wait(u16 nofvbl)
{
	int i;
	for (i=0; i < nofvbl; i++) VDP_waitVSync();
	VDP_updateSprites(32,0);
	return;
}

以下の共通APIはMEGADRIVEでは何もしません。

void wwc_palette_set_color(u8 palettenumber, u8 colornumber, u16 color) {return;}
void display_control(u8 mode) {return;}
void sprite_set_range(u8 sprstart, u8 sprend) {return;}
void sprite_set_char(u8 sprite_no, u16 char_data) {return;}