diff --git a/src/include/86box/86box.h b/src/include/86box/86box.h index 11c250201..885f81011 100644 --- a/src/include/86box/86box.h +++ b/src/include/86box/86box.h @@ -45,8 +45,11 @@ # define ENABLE_LOG_COMMANDS 1 #endif -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define ABS(x) ((x) > 0 ? (x) : -(x)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define ABS(x) ((x) > 0 ? (x) : -(x)) +#define BCD8(x) ((((x) / 10) << 4) | ((x) % 10)) +#define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x)) +#define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x)) #ifdef __cplusplus extern "C" { diff --git a/src/mem/spd.c b/src/mem/spd.c index f65417f9f..0268c1d5a 100644 --- a/src/mem/spd.c +++ b/src/mem/spd.c @@ -29,7 +29,6 @@ #include <86box/machine.h> -#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define SPD_ROLLUP(x) ((x) >= 16 ? ((x) - 15) : (x)) @@ -328,8 +327,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) sprintf(edo_data->part_no, EMU_NAME "-%s-%03dM", (ram_type == SPD_TYPE_FPM) ? "FPM" : "EDO", vslots[vslot]); for (i = strlen(edo_data->part_no); i < sizeof(edo_data->part_no); i++) edo_data->part_no[i] = ' '; /* part number should be space-padded */ - edo_data->rev_code[0] = EMU_VERSION_MAJ; - edo_data->rev_code[1] = (((EMU_VERSION_MIN / 10) << 4) | (EMU_VERSION_MIN % 10)); + edo_data->rev_code[0] = BCD8(EMU_VERSION_MAJ); + edo_data->rev_code[1] = BCD8(EMU_VERSION_MIN); edo_data->mfg_year = 20; edo_data->mfg_week = 17; @@ -383,8 +382,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) sprintf(sdram_data->part_no, EMU_NAME "-SDR-%03dM", vslots[vslot]); for (i = strlen(sdram_data->part_no); i < sizeof(sdram_data->part_no); i++) sdram_data->part_no[i] = ' '; /* part number should be space-padded */ - sdram_data->rev_code[0] = EMU_VERSION_MAJ; - sdram_data->rev_code[1] = (((EMU_VERSION_MIN / 10) << 4) | (EMU_VERSION_MIN % 10)); + sdram_data->rev_code[0] = BCD8(EMU_VERSION_MAJ); + sdram_data->rev_code[1] = BCD8(EMU_VERSION_MIN); sdram_data->mfg_year = 20; sdram_data->mfg_week = 13;