From d0081fd21efce3c060c2dd0e876bb5075161d3c4 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 21 Sep 2020 22:35:46 +0200 Subject: [PATCH] config system cleanup - hex values --- src/,,config_custom.s | 6 +++--- src/,,config_cx16.s | 2 +- src/,,config_generic.s | 6 +++--- src/,,config_mega65.s | 2 +- src/,,config_testing.s | 6 +++--- src/,,config_ultimate64.s | 6 +++--- src/aliases/,aliases_config.s | 10 ++++++++-- tools/build_segment.cc | 24 +++++++++++++++++++++--- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/,,config_custom.s b/src/,,config_custom.s index 2e5ba848..f1a1895b 100644 --- a/src/,,config_custom.s +++ b/src/,,config_custom.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $00 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $00 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! @@ -65,8 +65,8 @@ ; Sound support -; !set CONFIG_SID_2ND_ADDRESS = $D420 -; !set CONFIG_SID_3RD_ADDRESS = $D440 +;; #CONFIG# SID_2ND_ADDRESS NO +;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO diff --git a/src/,,config_cx16.s b/src/,,config_cx16.s index d18a5bc2..4b1ffdcb 100644 --- a/src/,,config_cx16.s +++ b/src/,,config_cx16.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $04 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $04 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! diff --git a/src/,,config_generic.s b/src/,,config_generic.s index 5712d169..40a3b5e5 100644 --- a/src/,,config_generic.s +++ b/src/,,config_generic.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $01 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $01 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! @@ -55,8 +55,8 @@ ; Sound support -; !set CONFIG_SID_2ND_ADDRESS = $D420 -; !set CONFIG_SID_3RD_ADDRESS = $D440 +;; #CONFIG# SID_2ND_ADDRESS NO +;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO diff --git a/src/,,config_mega65.s b/src/,,config_mega65.s index d556a521..5d99001f 100644 --- a/src/,,config_mega65.s +++ b/src/,,config_mega65.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $02 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $02 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! diff --git a/src/,,config_testing.s b/src/,,config_testing.s index da77a667..f08df178 100644 --- a/src/,,config_testing.s +++ b/src/,,config_testing.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $F0 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $F0 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! @@ -55,8 +55,8 @@ ; Sound support -; !set CONFIG_SID_2ND_ADDRESS = $D420 -; !set CONFIG_SID_3RD_ADDRESS = $D440 +;; #CONFIG# SID_2ND_ADDRESS NO +;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO diff --git a/src/,,config_ultimate64.s b/src/,,config_ultimate64.s index 91ad1ba9..9a57d781 100644 --- a/src/,,config_ultimate64.s +++ b/src/,,config_ultimate64.s @@ -1,5 +1,5 @@ -!set CONFIG_ID = $03 ; should be 1 byte, different for each config file! +;; #CONFIG# ID $03 ; should be 1 byte, different for each config file! ; ; Please read CONFIG.md before modifying this file! @@ -45,8 +45,8 @@ ; Sound support -; !set CONFIG_SID_2ND_ADDRESS = $D420 -; !set CONFIG_SID_3RD_ADDRESS = $D440 +;; #CONFIG# SID_2ND_ADDRESS NO +;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX YES ;; #CONFIG# SID_D5XX YES diff --git a/src/aliases/,aliases_config.s b/src/aliases/,aliases_config.s index 25bb5e3f..94462198 100644 --- a/src/aliases/,aliases_config.s +++ b/src/aliases/,aliases_config.s @@ -189,10 +189,16 @@ !if (counter != 0) { !error "Do not use CONFIG_SID_* options for MEGA65 motherboard" } } !ifdef CONFIG_SID_2ND_ADDRESS { - !if (CONFIG_SID_2ND_ADDRESS = $D400) { !error "CONFIG_SID_2ND_ADDRESS points to the 1st SID" } + !if (CONFIG_SID_2ND_ADDRESS = $D400) { !error "CONFIG_SID_2ND_ADDRESS points to the 1st SID" } + !if (CONFIG_SID_2ND_ADDRESS < $D420) { !error "CONFIG_SID_2ND_ADDRESS needs hex value from $D420-$D7E0 range" } + !if (CONFIG_SID_2ND_ADDRESS > $D7E0) { !error "CONFIG_SID_2ND_ADDRESS needs hex value from $D420-$D7E0 range" } + !if ((CONFIG_SID_2ND_ADDRESS % $20) != 0) { !error "CONFIG_SID_2ND_ADDRESS has to be aligned to $20" } } !ifdef CONFIG_SID_3RD_ADDRESS { - !if (CONFIG_SID_3RD_ADDRESS = $D400) { !error "CONFIG_SID_3RD_ADDRESS points to the 1st SID" } + !if (CONFIG_SID_3RD_ADDRESS = $D400) { !error "CONFIG_SID_3RD_ADDRESS points to the 1st SID" } + !if (CONFIG_SID_3RD_ADDRESS < $D420) { !error "CONFIG_SID_3RD_ADDRESS needs hex value from $D420-$D7E0 range" } + !if (CONFIG_SID_3RD_ADDRESS > $D7E0) { !error "CONFIG_SID_3RD_ADDRESS needs hex value from $D420-$D7E0 range" } + !if ((CONFIG_SID_3RD_ADDRESS % $20) != 0) { !error "CONFIG_SID_3RD_ADDRESS has to be aligned to $20" } } !ifdef CONFIG_SID_2ND_ADDRESS { !ifdef CONFIG_SID_3RD_ADDRESS { !if (CONFIG_SID_2ND_ADDRESS = CONFIG_SID_3RD_ADDRESS) { !error "Configured SIDs have the same addresses" } diff --git a/tools/build_segment.cc b/tools/build_segment.cc index ad4ca41d..38f59099 100644 --- a/tools/build_segment.cc +++ b/tools/build_segment.cc @@ -117,6 +117,8 @@ private: typedef struct ConfigEntry { std::string key; std::string valStr; // XXX add support for string values + uint32_t valInt; + bool valIntValid; } ConfigEntry; std::map configEntries; @@ -725,8 +727,17 @@ void SourceFile::preprocess() { // XXX add spacing // XXX add support for string values - outStream << "!set CONFIG_" << configEntries[lineNum].key << " = 1" << - " " << line; + outStream << "!set CONFIG_" << configEntries[lineNum].key << " = "; + if (configEntries[lineNum].valIntValid) + { + outStream << "$" << std::hex << configEntries[lineNum].valInt; + } + else + { + outStream << "1"; + } + + outStream << " " << line; const std::string outString = outStream.str(); content.insert(content.end(), outString.begin(), outString.end()); @@ -818,7 +829,14 @@ void SourceFile::preprocessLine_Config(const std::list &tokens, std if (valStr.compare("NO") == 0) return; else if (valStr.compare("YES") == 0) { - configEntries[lineNum].key = key; + configEntries[lineNum].key = key; + configEntries[lineNum].valIntValid = false; + } + else if (valStr.length() > 1 && valStr[0] == '$') + { + configEntries[lineNum].key = key; + configEntries[lineNum].valInt = std::stoul(valStr.substr(1, std::string::npos), nullptr, 16); + configEntries[lineNum].valIntValid = true; } else {