Skip to content

Commit

Permalink
Use device code to determine console type on Wii
Browse files Browse the repository at this point in the history
Fix unintended fallthrough switch statement
  • Loading branch information
Extrems committed Feb 15, 2025
1 parent d494f02 commit a15a612
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions gc/ogc/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ distribution.
#define SYS_CONSOLE_RETAIL_ES2_1 0x00000021
#define SYS_CONSOLE_RETAIL_ES3_0 0x00000030
#define SYS_CONSOLE_RETAIL_ES3_1 0x00000031
#define SYS_CONSOLE_ARCADE 0x00000100
#define SYS_CONSOLE_NDEV_ES1_0 0x10000010
#define SYS_CONSOLE_NDEV_ES1_1 0x10000011
#define SYS_CONSOLE_NDEV_ES1_2 0x10000012
Expand Down
2 changes: 2 additions & 0 deletions libogc/stm.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ s32 STM_ShutdownToIdle(void)
case 1:
case 2:
__stm_immbufin[0] = 0xFCA08280;
break;
default:
__stm_immbufin[0] = 0xFCE082C0;
break;
}
res= IOS_Ioctl(__stm_imm_fd,IOCTL_STM_IDLE,__stm_immbufin,0x20,__stm_immbufout,0x20);
if(res<0) {
Expand Down
27 changes: 25 additions & 2 deletions libogc/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -2036,8 +2036,31 @@ u32 SYS_GetConsoleType(void)
u32 SYS_GetConsoleType(void)
{
u32 type;
type = SYS_CONSOLE_RETAIL_ES1_0;
type += *((u32*)0x80003138);
u16 dev_code;

type = 0;
dev_code = *((u16*)0x800030e6);
if(dev_code&0x8000) {
switch(dev_code&~0x8000) {
case 0x0002:
case 0x0003:
case 0x0203:
type = SYS_CONSOLE_RETAIL_ES1_0;
type += *((u32*)0x80003138);
break;
case 0x0201:
case 0x0202:
type = SYS_CONSOLE_NDEV_ES1_0;
type += *((u32*)0x80003138);
break;
case 0x0300:
type = SYS_CONSOLE_ARCADE;
break;
}
} else {
type = SYS_CONSOLE_RETAIL_ES1_0;
type += *((u32*)0x80003138);
}
return type;
}

Expand Down

0 comments on commit a15a612

Please sign in to comment.