From 2416fec4a2d4e081531c4d81821961cde47d7c79 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 16 Oct 2021 19:50:32 -0300 Subject: [PATCH] Add 3 GB RAM support to SPD and win_settings --- src/mem/spd.c | 26 +++++++++++++++++++++----- src/win/win_settings.c | 7 ++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/mem/spd.c b/src/mem/spd.c index 32b49a101..b5400de4b 100644 --- a/src/mem/spd.c +++ b/src/mem/spd.c @@ -167,6 +167,22 @@ spd_populate(uint16_t *rows, uint8_t slot_count, uint16_t total_size, uint16_t m } +static int +spd_write_part_no(char *part_no, char *type, uint16_t size) +{ + char size_unit; + + if (size >= 1024) { + size_unit = 'G'; + size >>= 10; + } else { + size_unit = 'M'; + } + + return sprintf(part_no, EMU_NAME "-%s-%03d%c", type, size, size_unit); +} + + void spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) { @@ -204,7 +220,7 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) /* Register SPD devices and populate their data according to the rows. */ row = 0; - for (slot = 0; slot < SPD_MAX_SLOTS && rows[row]; slot++) { + for (slot = 0; (slot < SPD_MAX_SLOTS) && rows[row]; slot++) { if (!(slot_mask & (1 << slot))) continue; /* slot disabled */ @@ -249,8 +265,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) edo_data->dram_width = 8; edo_data->spd_rev = 0x12; - sprintf(edo_data->part_no, EMU_NAME "-%s-%03dM", (ram_type == SPD_TYPE_FPM) ? "FPM" : "EDO", rows[row]); - for (i = strlen(edo_data->part_no); i < sizeof(edo_data->part_no); i++) + for (i = spd_write_part_no(edo_data->part_no, (ram_type == SPD_TYPE_FPM) ? "FPM" : "EDO", rows[row]); + i < sizeof(edo_data->part_no); i++) edo_data->part_no[i] = ' '; /* part number should be space-padded */ edo_data->rev_code[0] = BCD8(EMU_VERSION_MAJ); edo_data->rev_code[1] = BCD8(EMU_VERSION_MIN); @@ -303,8 +319,8 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size) sdram_data->ca_hold = sdram_data->data_hold = 0x08; sdram_data->spd_rev = 0x12; - sprintf(sdram_data->part_no, EMU_NAME "-SDR-%03dM", rows[row]); - for (i = strlen(sdram_data->part_no); i < sizeof(sdram_data->part_no); i++) + for (i = spd_write_part_no(sdram_data->part_no, "SDR", rows[row]); + i < sizeof(sdram_data->part_no); i++) sdram_data->part_no[i] = ' '; /* part number should be space-padded */ sdram_data->rev_code[0] = BCD8(EMU_VERSION_MAJ); sdram_data->rev_code[1] = BCD8(EMU_VERSION_MIN); diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 7e90ef1ba..4b538f31b 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -807,7 +807,12 @@ win_settings_machine_recalc_machine(HWND hdlg) } else { /* MB granularity */ h = GetDlgItem(hdlg, IDC_MEMSPIN); - SendMessage(h, UDM_SETRANGE, 0, (machines[temp_machine].min_ram << 6) | machines[temp_machine].max_ram >> 10); +#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) + i = MIN(machines[temp_machine].max_ram, 2097152); +#else + i = MIN(machines[temp_machine].max_ram, 3145728); +#endif + SendMessage(h, UDM_SETRANGE, 0, (machines[temp_machine].min_ram << 6) | (i >> 10)); accel.nSec = 0; accel.nInc = machines[temp_machine].ram_granularity >> 10;