From 76250afac9850a988704e833a386770ef81dc08c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 21 Sep 2020 23:01:05 +0200 Subject: [PATCH] better SIDs and integers handling in config files --- CONFIG.md | 6 +++--- src/,,config_custom.s | 2 ++ src/,,config_generic.s | 2 ++ src/,,config_mega65.s | 6 +++--- src/,,config_testing.s | 2 ++ src/,,config_ultimate64.s | 2 ++ src/aliases/,aliases_config.s | 33 ++++++++++++++++++++++----------- src/kernal/init/fda3.ioinit.s | 10 ++++++++-- tools/build_segment.cc | 30 ++++++++++++++++++++++++++++++ 9 files changed, 74 insertions(+), 19 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 3b096f4a..0cbd02e3 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -177,13 +177,13 @@ The SID support in the ROM is very limited - it only disables the sound during s ### `CONFIG_SID_2ND_ADDRESS` and `CONFIG_SID_3RD_ADDRESS` -Each of them add support for one additional SID - addresses should be given as parameter, respectively. Do not use when `CONFIG_MB_M65` is selected - the motherboard support code already knows the SID locations. +Each of them adds support for one additional SID - addresses should be given as parameters. Do not use when `CONFIG_MB_M65` is selected - the motherboard support code already knows the SID locations. Each of these options needs 3 bytes in KERNAL segment. -### `CONFIG_SID_D4XX` and `CONFIG_SID_D5XX` +### `CONFIG_SID_D4XX`, `CONFIG_SID_D5XX`, `CONFIG_SID_D6XX` and `CONFIG_SID_D7XX` -Cause the system to support SIDs in `$D4xx` and `$D5xx` ranges, respectively. +Enables support for SIDs in `$D4xx` / `$D5xx` / `$D6xx` / `$D7xx` ranges, respectively. Each of them needs a couple of bytes in KERNAL segment - but they can share some code, and `$D4xx` range support replaces the standard `$D400` address handling, so exact amount depends on the exact configuration. Do not use when `CONFIG_MB_M65` is selected - the motherboard support code already knows the SID locations. diff --git a/src/,,config_custom.s b/src/,,config_custom.s index f1a1895b..5bf77d40 100644 --- a/src/,,config_custom.s +++ b/src/,,config_custom.s @@ -69,6 +69,8 @@ ;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO +;; #CONFIG# SID_D6XX NO +;; #CONFIG# SID_D7XX NO ; Keyboard settings diff --git a/src/,,config_generic.s b/src/,,config_generic.s index 40a3b5e5..8f210287 100644 --- a/src/,,config_generic.s +++ b/src/,,config_generic.s @@ -59,6 +59,8 @@ ;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO +;; #CONFIG# SID_D6XX NO +;; #CONFIG# SID_D7XX NO ; Keyboard settings diff --git a/src/,,config_mega65.s b/src/,,config_mega65.s index 5d99001f..8fc14e60 100644 --- a/src/,,config_mega65.s +++ b/src/,,config_mega65.s @@ -112,9 +112,9 @@ ; Built-in DOS configuration -!set CONFIG_UNIT_SDCARD = 0 ; do not change, DOS is not implemented yet -!set CONFIG_UNIT_FLOPPY = 0 ; do not change, DOS is not implemented yet -!set CONFIG_UNIT_RAMDISK = 0 ; do not change, DOS is not implemented yet +;; #CONFIG# UNIT_SDCARD 0 ; do not change, DOS is not implemented yet +;; #CONFIG# UNIT_FLOPPY 0 ; do not change, DOS is not implemented yet +;; #CONFIG# UNIT_RAMDISK 0 ; do not change, DOS is not implemented yet ; Debug options diff --git a/src/,,config_testing.s b/src/,,config_testing.s index f08df178..9b0ce350 100644 --- a/src/,,config_testing.s +++ b/src/,,config_testing.s @@ -59,6 +59,8 @@ ;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX NO ;; #CONFIG# SID_D5XX NO +;; #CONFIG# SID_D6XX NO +;; #CONFIG# SID_D7XX NO ; Keyboard settings diff --git a/src/,,config_ultimate64.s b/src/,,config_ultimate64.s index 9a57d781..e12ab6fc 100644 --- a/src/,,config_ultimate64.s +++ b/src/,,config_ultimate64.s @@ -49,6 +49,8 @@ ;; #CONFIG# SID_3RD_ADDRESS NO ;; #CONFIG# SID_D4XX YES ;; #CONFIG# SID_D5XX YES +;; #CONFIG# SID_D6XX NO +;; #CONFIG# SID_D7XX NO ; Keyboard settings diff --git a/src/aliases/,aliases_config.s b/src/aliases/,aliases_config.s index 94462198..052ed994 100644 --- a/src/aliases/,aliases_config.s +++ b/src/aliases/,aliases_config.s @@ -181,6 +181,8 @@ !ifdef CONFIG_SID_3RD_ADDRESS { !set counter = counter + 1 } !ifdef CONFIG_SID_D4XX { !set counter = counter + 1 } !ifdef CONFIG_SID_D5XX { !set counter = counter + 1 } +!ifdef CONFIG_SID_D6XX { !set counter = counter + 1 } +!ifdef CONFIG_SID_D7XX { !set counter = counter + 1 } !ifdef CONFIG_PLATFORM_COMMANDER_X16 { !if (counter != 0) { !error "Do not use CONFIG_SID_* options for Commander X16 platform" } @@ -189,16 +191,24 @@ !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 < $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" } + !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" } + !if ((CONFIG_SID_2ND_ADDRESS DIV $100) = $D4) { !ifdef CONFIG_SID_D4XX { !error "CONFIG_SID_2ND_ADDRESS redundant due to CONFIG_SID_D4XX" } } + !if ((CONFIG_SID_2ND_ADDRESS DIV $100) = $D5) { !ifdef CONFIG_SID_D5XX { !error "CONFIG_SID_2ND_ADDRESS redundant due to CONFIG_SID_D5XX" } } + !if ((CONFIG_SID_2ND_ADDRESS DIV $100) = $D6) { !ifdef CONFIG_SID_D6XX { !error "CONFIG_SID_2ND_ADDRESS redundant due to CONFIG_SID_D6XX" } } + !if ((CONFIG_SID_2ND_ADDRESS DIV $100) = $D7) { !ifdef CONFIG_SID_D7XX { !error "CONFIG_SID_2ND_ADDRESS redundant due to CONFIG_SID_D7XX" } } } !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 < $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" } + !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" } + !if ((CONFIG_SID_3RD_ADDRESS DIV $100) = $D4) { !ifdef CONFIG_SID_D4XX { !error "CONFIG_SID_3RD_ADDRESS redundant due to CONFIG_SID_D4XX" } } + !if ((CONFIG_SID_3RD_ADDRESS DIV $100) = $D5) { !ifdef CONFIG_SID_D5XX { !error "CONFIG_SID_3RD_ADDRESS redundant due to CONFIG_SID_D5XX" } } + !if ((CONFIG_SID_3RD_ADDRESS DIV $100) = $D6) { !ifdef CONFIG_SID_D6XX { !error "CONFIG_SID_3RD_ADDRESS redundant due to CONFIG_SID_D6XX" } } + !if ((CONFIG_SID_3RD_ADDRESS DIV $100) = $D7) { !ifdef CONFIG_SID_D7XX { !error "CONFIG_SID_3RD_ADDRESS redundant due to CONFIG_SID_D7XX" } } } !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" } @@ -349,9 +359,10 @@ ; Handle sound configuration -!ifdef CONFIG_SID_D4XX { !set CONFIG_SID_D4XX_OR_D5XX = 1 } -!ifdef CONFIG_SID_D5XX { !set CONFIG_SID_D4XX_OR_D5XX = 1 } - +!ifdef CONFIG_SID_D4XX { !set CONFIG_SID_DX_RANGE = 1 } +!ifdef CONFIG_SID_D5XX { !set CONFIG_SID_DX_RANGE = 1 } +!ifdef CONFIG_SID_D6XX { !set CONFIG_SID_DX_RANGE = 1 } +!ifdef CONFIG_SID_D7XX { !set CONFIG_SID_DX_RANGE = 1 } ; Handle keyboard configuration diff --git a/src/kernal/init/fda3.ioinit.s b/src/kernal/init/fda3.ioinit.s index 3acc96a4..e2243c7f 100644 --- a/src/kernal/init/fda3.ioinit.s +++ b/src/kernal/init/fda3.ioinit.s @@ -84,9 +84,9 @@ IOINIT_skip_DOS: !ifdef CONFIG_SID_3RD_ADDRESS { sta SID_SIGVOL - __SID_BASE + CONFIG_SID_3RD_ADDRESS } - ; Silence whole D4XX and D5XX ranges (if configured) + ; Silence whole D4XX, D5XX, D6XX, D7XX ranges (if configured) -!ifdef CONFIG_SID_D4XX_OR_D5XX { +!ifdef CONFIG_SID_DX_RANGE { ldy #$00 @1: @@ -97,6 +97,12 @@ IOINIT_skip_DOS: !ifdef CONFIG_SID_D5XX { sta SID_SIGVOL + $100, Y } +!ifdef CONFIG_SID_D6XX { + sta SID_SIGVOL + $200, Y +} +!ifdef CONFIG_SID_D7XX { + sta SID_SIGVOL + $300, Y +} tya clc diff --git a/tools/build_segment.cc b/tools/build_segment.cc index 38f59099..8ffe5170 100644 --- a/tools/build_segment.cc +++ b/tools/build_segment.cc @@ -829,15 +829,45 @@ void SourceFile::preprocessLine_Config(const std::list &tokens, std if (valStr.compare("NO") == 0) return; else if (valStr.compare("YES") == 0) { + // This is a YES/NO value (bool) + configEntries[lineNum].key = key; configEntries[lineNum].valIntValid = false; } else if (valStr.length() > 1 && valStr[0] == '$') { + // This is a hexadecimal value + + for (size_t idx = 1; idx < valStr.length(); idx++) + { + if (valStr[idx] < '0' && valStr[idx] > '9' && + valStr[idx] < 'A' && valStr[idx] > 'F' && + valStr[idx] < 'a' && valStr[idx] > 'f') + { + ERROR("syntax error, wrong hex value in '#CONFIG#'"); + } + } + configEntries[lineNum].key = key; configEntries[lineNum].valInt = std::stoul(valStr.substr(1, std::string::npos), nullptr, 16); configEntries[lineNum].valIntValid = true; } + else if (valStr.length() > 0 && valStr[0] >= '0' && valStr[0] <= '9') + { + // This is a decimal value + + for (size_t idx = 0; idx < valStr.length(); idx++) + { + if (valStr[idx] < '0' && valStr[idx] > '9') + { + ERROR("syntax error, wrong dec value in '#CONFIG#'"); + } + } + + configEntries[lineNum].key = key; + configEntries[lineNum].valInt = std::stoul(valStr.substr(0, std::string::npos), nullptr, 10); + configEntries[lineNum].valIntValid = true; + } else { // XXX add support for string values