New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setcolor.com has no effect [when output=ttf] #4503
Comments
@Arthur3032 Just tried to |
Please try SETCOLOR 2, SETCOLOR 3 |
I've just tried Perhaps only a particular build/SDL combo is affected? |
Update: |
Note while debugging: setVGADAC in output_ttf.cpp seems getting the right altBGR1 matrix to IO_WriteB, but such change has no effect on display. |
I haven't understood the code completely, but the following patch seems to work. diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp
index 6e2d7da55..3389a12fa 100644
--- a/src/dos/dos_programs.cpp
+++ b/src/dos/dos_programs.cpp
@@ -8145,7 +8145,9 @@ static void COLOR_ProgramStart(Program * * make) {
*make=new COLOR;
}
-bool setVGAColor(const char *colorArray, int i) {
+alt_rgb altBGR[16], *rgbcolors = (alt_rgb*)render.pal.rgb;
+
+bool setVGAColor(const char *colorArray, int j) {
if (!IS_VGA_ARCH||!CurMode) return false;
const char * nextRGB = colorArray;
int rgbVal[4] = {-1,-1,-1,-1};
@@ -8164,16 +8166,18 @@ bool setVGAColor(const char *colorArray, int i) {
} else
return false;
IO_ReadB(mem_readw(BIOS_VIDEO_PORT)+6);
- IO_WriteB(VGAREG_ACTL_ADDRESS, i+32);
+ IO_WriteB(VGAREG_ACTL_ADDRESS, j+32);
uint8_t imap=IO_ReadB(VGAREG_ACTL_READ_DATA);
IO_WriteB(VGAREG_DAC_WRITE_ADDRESS, imap);
- IO_WriteB(VGAREG_DAC_DATA, (rgbVal[0]+3)*63/255);
- IO_WriteB(VGAREG_DAC_DATA, (rgbVal[1]+3)*63/255);
- IO_WriteB(VGAREG_DAC_DATA, (rgbVal[2]+3)*63/255);
+ IO_WriteB(VGAREG_DAC_DATA, rgbVal[0] >> 2);
+ IO_WriteB(VGAREG_DAC_DATA, rgbVal[1] >> 2);
+ IO_WriteB(VGAREG_DAC_DATA, rgbVal[2] >> 2);
+ rgbcolors[j].red = rgbVal[0];
+ rgbcolors[j].green = rgbVal[1];
+ rgbcolors[j].blue = rgbVal[2];
return true;
}
-alt_rgb altBGR[16], *rgbcolors = (alt_rgb*)render.pal.rgb;
#if defined(USE_TTF)
extern alt_rgb altBGR1[16];
extern bool colorChanged;
@@ -8275,9 +8279,12 @@ void SETCOLOR::Run()
#if defined(USE_TTF)
} else if (setColors(value,i)) {
bool colornul = staycolors || (IS_VGA_ARCH && (altBGR1[i].red > 4 || altBGR1[i].green > 4 || altBGR1[i].blue > 4) && rgbcolors[i].red < 5 && rgbcolors[i].green < 5 && rgbcolors[i].blue < 5);
- altBGR[i].red = colornul||(colorChanged&&!IS_VGA_ARCH)?altBGR1[i].red:rgbcolors[i].red;
- altBGR[i].green = colornul||(colorChanged&&!IS_VGA_ARCH)?altBGR1[i].green:rgbcolors[i].green;
- altBGR[i].blue = colornul||(colorChanged&&!IS_VGA_ARCH)?altBGR1[i].blue:rgbcolors[i].blue;
+ LOG_MSG("%d,%d,%d %d,%d,%d",altBGR[i].red, altBGR[i].green, altBGR[i].blue, rgbcolors[i].red,rgbcolors[i].green,rgbcolors[i].blue);
+ LOG_MSG("colornul=%d, colorChanged=%d, IS_VGA_ARCH=%d",colornul, colorChanged, IS_VGA_ARCH);
+ altBGR[i].red = (colornul||(colorChanged&&!IS_VGA_ARCH))?altBGR1[i].red:rgbcolors[i].red;
+ altBGR[i].green = (colornul||(colorChanged&&!IS_VGA_ARCH))?altBGR1[i].green:rgbcolors[i].green;
+ altBGR[i].blue = (colornul||(colorChanged&&!IS_VGA_ARCH))?altBGR1[i].blue:rgbcolors[i].blue;
+ LOG_MSG("%d,%d,%d %d,%d,%d",altBGR[i].red, altBGR[i].green, altBGR[i].blue, rgbcolors[i].red,rgbcolors[i].green,rgbcolors[i].blue);
WriteOut("Color %d => (%d,%d,%d) or #%02x%02x%02x\n",i,altBGR[i].red,altBGR[i].green,altBGR[i].blue,altBGR[i].red,altBGR[i].green,altBGR[i].blue);
resetFontSize();
} else
diff --git a/src/output/output_ttf.cpp b/src/output/output_ttf.cpp
index 2195df046..3e818d54d 100644
--- a/src/output/output_ttf.cpp
+++ b/src/output/output_ttf.cpp
@@ -242,9 +242,9 @@ void setVGADAC() {
IO_WriteB(VGAREG_ACTL_ADDRESS, i+32);
imap[i]=IO_ReadB(VGAREG_ACTL_READ_DATA);
IO_WriteB(VGAREG_DAC_WRITE_ADDRESS, imap[i]);
- IO_WriteB(VGAREG_DAC_DATA, (altBGR1[i].red+3)*63/255);
- IO_WriteB(VGAREG_DAC_DATA, (altBGR1[i].green+3)*63/255);
- IO_WriteB(VGAREG_DAC_DATA, (altBGR1[i].blue+3)*63/255);
+ IO_WriteB(VGAREG_DAC_DATA, altBGR1[i].red>>2);
+ IO_WriteB(VGAREG_DAC_DATA, altBGR1[i].green>>2);
+ IO_WriteB(VGAREG_DAC_DATA, altBGR1[i].blue>>2);
}
}
}
@@ -261,7 +261,7 @@ bool setColors(const char *colorArray, int n) {
staycolors = strlen(colorArray) && *colorArray == '+';
const char* nextRGB = colorArray + (staycolors?1:0);
uint8_t * altPtr = (uint8_t *)altBGR1;
- int rgbVal[3] = {-1,-1,-1};
+ int rgbVal[4] = {-1,-1,-1,-1};
for (int colNo = 0; colNo < (n>-1?1:16); colNo++) {
if (n>-1) altPtr+=4*n;
if (sscanf(nextRGB, " ( %d , %d , %d)", &rgbVal[0], &rgbVal[1], &rgbVal[2]) == 3) { // Decimal: (red,green,blue)
@@ -273,22 +273,24 @@ bool setColors(const char *colorArray, int n) {
while (*nextRGB != ')')
nextRGB++;
nextRGB++;
- } else if (sscanf(nextRGB, " #%6x", ((unsigned int*)(&rgbVal[0]))) == 1) {
// Hexadecimal
- if (rgbVal[0] < 0)
+ } else if (sscanf(nextRGB, " #%6x", ((uint32_t*)(&rgbVal[3]))) == 1) {
// Hexadecimal
+ if (rgbVal[3] < 0)
return false;
for (int i = 0; i < 3; i++) {
- altPtr[2-i] = rgbVal[0]&255;
- rgbVal[0] >>= 8;
+ rgbVal[2-i] = rgbVal[3]&255;
+ rgbVal[3] >>= 8;
}
nextRGB = strchr(nextRGB, '#') + 7;
} else
return false;
altPtr += 4;
- }
- for (int i = n>-1?n:0; i < (n>-1?n+1:16); i++) {
- altBGR0[i].blue = (altBGR1[i].blue*2 + 128)/4;
- altBGR0[i].green = (altBGR1[i].green*2 + 128)/4;
- altBGR0[i].red = (altBGR1[i].red*2 + 128)/4;
+ altBGR1[n].blue = rgbVal[2];
+ altBGR1[n].green = rgbVal[1];
+ altBGR1[n].red = rgbVal[0];
+ rgbColors[n].blue = rgbVal[2];
+ rgbColors[n].green = rgbVal[1];
+ rgbColors[n].red = rgbVal[0];
+
}
setVGADAC();
colorChanged=justChanged=true; |
Thank you, Let me try it. |
Patch works as expected! |
@maxpat78 Thank you for testing. I'll prepare a PR. |
It's OK, Thank you. |
Describe the bug
Z:\BIN\SETCOLOR 2 #005500 --> #00aa00 not #005500
Steps to reproduce the behaviour
Z:\BIN\SETCONT
Z:\BIN\SETCOLOR 2 #005500
Expected behavior
No response
What operating system(s) this bug have occurred on?
Windows 11 22H2
What version(s) of DOSBox-X have this bug?
dosbox-x 2023-09-01
Used configuration
No response
Output log
No response
Additional information
No response
Have you checked that no similar bug report(s) exist?
Code of Conduct & Contributing Guidelines
The text was updated successfully, but these errors were encountered: