nfsu / NFS

Is a tool created for rom hacking, it stands for Nintendo File System (Utils) and can quickly read and interpret nds files such as NARC, NCLR, NCGR, etc.
MIT License
25 stars 1 forks source link

[NFS_Reloaded] Use bitflags #8

Closed Nielsbishere closed 4 years ago

Nielsbishere commented 5 years ago

Apparently bitflags are a thing in C; which also work in C++17. This means that instead of doing template magic, the compiler can handle it for us. The ux and u1 types can be removed.

u32 bits2 : 2;
u32 bits1 : 1;
u32 bits3 : 3;
u32 bits : 26;

This means the problem with structs that have different sizes can easily be fixed. It also means that the CPSR for ARM emulation could be perfectly emulated without a hassle:

u32 negative : 1;
u32 zero : 1;
u32 carry : 1;
u32 overflow : 1;
u32 saturation : 1;
u32 thumbIT0 : 2;
u32 jazelle : 1;
u32 pad0 : 4;
u32 condition: 4;
u32 thumbIT1 : 6;
u32 useBigEndian : 1;
u32 asyncAbort : 1;
u32 disableIRQ : 1;
u32 disableFIRQ : 1;
u32 thumbMode : 1;
u32 one : 1;
u32 systemMode : 4; //USR, FIQ, IRQ, SVC, MON, ABT, HYP, UND, SYS
Nielsbishere commented 4 years ago

Compiler dependent.