#include "include/flag_access.h" #include "include/aliases.h" #include const char *get_flag_string(flag_access flag); static bool flags[FLAG_COUNT] = {false}; bool get_flag(flag_access flag) { if (flag < FLAG_COUNT) { return flags[flag]; } return false; } void set_flags(u16 value) { if (value == 0) { flags[FLAG_ZERO] = true; flags[FLAG_SIGN] = false; } else if ((value & 0x8000) == 0x8000) { flags[FLAG_ZERO] = false; flags[FLAG_SIGN] = true; } else { flags[FLAG_ZERO] = false; flags[FLAG_SIGN] = false; } } void print_flags() { printf("\t"); for (u32 i = 0; i < FLAG_COUNT; ++i) { if (flags[i]) { printf("%s", get_flag_string((flag_access)i)); } } printf("\n"); } const char *get_flag_string(flag_access flag) { const char *output = ""; switch (flag) { case FLAG_ZERO: output = "Z"; break; case FLAG_SIGN: output = "S"; break; default: break; } return output; }