Skip to content

Commit

Permalink
Handle auto-rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudreadmon committed Apr 11, 2019
1 parent a29273a commit f327c19
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
7 changes: 7 additions & 0 deletions core/hw/naomi/naomi_cart.cpp
Expand Up @@ -49,6 +49,7 @@ extern char g_roms_dir[PATH_MAX];

InputDescriptors *naomi_game_inputs;
u8 *naomi_default_eeprom;
static RotationType game_rotation = ROT0;

static bool naomi_LoadBios(const char *filename, Archive *child_archive, Archive *parent_archive, int region)
{
Expand Down Expand Up @@ -335,6 +336,7 @@ static bool naomi_cart_LoadZip(char *filename)
}
if (naomi_default_eeprom == NULL && game->eeprom_dump != NULL)
naomi_default_eeprom = game->eeprom_dump;
game_rotation = game->rotation_flag;
if (archive != NULL)
delete archive;
if (parent_archive != NULL)
Expand Down Expand Up @@ -393,6 +395,11 @@ int naomi_cart_GetSystemType(const char* file)
return DC_PLATFORM_NAOMI;
}

int naomi_cart_GetRotation()
{
return game_rotation;
}

bool naomi_cart_LoadRom(char* file, char *s, size_t len)
{
printf("nullDC-Naomi rom loader v1.2\n");
Expand Down
1 change: 1 addition & 0 deletions core/hw/naomi/naomi_cart.h
Expand Up @@ -80,6 +80,7 @@ class M2Cartridge : public NaomiCartridge

bool naomi_cart_SelectFile(char *s, size_t len);
int naomi_cart_GetSystemType(const char* file);
int naomi_cart_GetRotation();

extern char naomi_game_id[];
extern u8 *naomi_default_eeprom;
Expand Down
28 changes: 12 additions & 16 deletions core/libretro/libretro.cpp
Expand Up @@ -1735,8 +1735,6 @@ bool retro_load_game(const struct retro_game_info *game)
mkdir_norecurse(data_dir);
}
}
int rotation = rotate_screen ? 1 : 0;
environ_cb(RETRO_ENVIRONMENT_SET_ROTATION, &rotation);

params.context_type = RETRO_HW_CONTEXT_NONE;

Expand Down Expand Up @@ -1818,6 +1816,10 @@ bool retro_load_game(const struct retro_game_info *game)
log_cb(RETRO_LOG_ERROR, "Reicast emulator initialization failed\n");
return false;
}
int rotation = rotate_screen ? 3 : 0;
if (naomi_cart_GetRotation() == 3)
rotation = rotate_screen ? 0 : 1;
environ_cb(RETRO_ENVIRONMENT_SET_ROTATION, &rotation);
init_disk_control_interface(game->path);
refresh_devices(true);

Expand Down Expand Up @@ -2040,21 +2042,15 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
u32 pixel_clock= spg_clks[(SPG_CONTROL.full >> 6) & 3];

info->geometry.aspect_ratio = settings.rend.WideScreen ? (16.0 / 9.0) : (4.0 / 3.0);
if(naomi_cart_GetRotation() == 3)
info->geometry.aspect_ratio = 1 / info->geometry.aspect_ratio;
int maximum = screen_width > screen_height ? screen_width : screen_height;
info->geometry.base_width = screen_height;
info->geometry.base_height = screen_width;
info->geometry.max_width = maximum;
info->geometry.max_height = maximum;
if (rotate_screen)
{
info->geometry.base_width = screen_height;
info->geometry.base_height = screen_width;
info->geometry.max_width = screen_height;
info->geometry.max_height = screen_width;
info->geometry.aspect_ratio = 1 / info->geometry.aspect_ratio;
}
else
{
info->geometry.base_width = screen_width;
info->geometry.base_height = screen_height;
info->geometry.max_width = screen_width;
info->geometry.max_height = screen_height;
}
info->geometry.aspect_ratio = 1 / info->geometry.aspect_ratio;

switch (pixel_clock)
{
Expand Down

0 comments on commit f327c19

Please sign in to comment.