Clean up unused options for soundscape.

Clean up console interface to be less likely to fail to define the width and height.
Update notes in the PDF.
Add the PDF for newer Yamaha even if I don't have one (and the protocol has significant differences).
This commit is contained in:
2026-02-27 12:57:20 -06:00
parent b9da0b5987
commit 6d16d119cd
5 changed files with 83 additions and 71 deletions

View File

@@ -59,39 +59,68 @@ void Console_Init(short Left, short Top, short Width, short Height, short bottom
exit(1);
}
wOldColorAttrs = csbi.wAttributes;
consoleWidth = Width;
consoleHeight = Height;
scrollBot = Height - 1;
scrollTop = Height - bottomScrollHeight - 1;
scrollBot = consoleHeight - 1;
scrollTop = consoleHeight - bottomScrollHeight - 1;
#if 1
COORD max = GetLargestConsoleWindowSize(hStdout);
SHORT w = (Width > max.X) ? max.X : Width;
SHORT h = (Height > max.Y) ? max.Y : Height;
SMALL_RECT win = { 0, 0, (SHORT)(w - 1), (SHORT)(h - 1) };
// Enlarge buffer first (for growth), then set window.
SetConsoleScreenBufferSize(hStdout, { w, h });
SetConsoleWindowInfo(hStdout, TRUE, &win);
#else
// Desired size (width x height)
COORD newSize = { 0, 0 };
newSize.X = consoleWidth; // columns
newSize.Y = consoleHeight; // rows
COORD bufferSize = { 0, 0 };
bufferSize.X = (csbi.dwSize.X < Width) ? Width : csbi.dwSize.X; // columns
bufferSize.Y = (csbi.dwSize.Y < Height) ? Height : csbi.dwSize.Y; // rows
// Step 2: Set new buffer size
if (!SetConsoleScreenBufferSize(hStdout, newSize)) {
if (!SetConsoleScreenBufferSize(hStdout, bufferSize)) {
fprintf(stderr, "Error: Unable to set console buffer size. Code: %lu\n", GetLastError());
// figure out why ...
CONSOLE_SCREEN_BUFFER_INFOEX info;
info.cbSize = sizeof(info);
if (!GetConsoleScreenBufferInfoEx(hStdout, &info)) {
// handle error
}
fprintf(stderr, "Width[%u] > info.dwMaximumWindowSize.X[%u] || Height[%u] > info.dwMaximumWindowSize.Y[%u]\n",
Width, info.dwMaximumWindowSize.X, Height, info.dwMaximumWindowSize.Y);
fprintf(stderr, "Width[%u] < GetSystemMetrics(SM_CXMIN)[%u] || Height[%u] < GetSystemMetrics(SM_CYMIN)[%u]\n",
Width, GetSystemMetrics(SM_CXMIN), Height, GetSystemMetrics(SM_CYMIN));
exit(1);
}
// Step 3: Set final window size to match buffer
// The final window size we want to set
SMALL_RECT newWindow = { 0 };
newWindow.Left = 0;
newWindow.Top = 0;
newWindow.Right = newSize.X - 1;
newWindow.Bottom = newSize.Y - 1;
newWindow.Right = bufferSize.X - 1;
newWindow.Bottom = bufferSize.Y - 1;
if (!SetConsoleWindowInfo(hStdout, TRUE, &newWindow)) {
fprintf(stderr, "Error: Unable to set console window size. Code: %lu\n", GetLastError());
CONSOLE_SCREEN_BUFFER_INFOEX info;
info.cbSize = sizeof(info);
if (!GetConsoleScreenBufferInfoEx(hStdout, &info)) {
// handle error
}
fprintf(stderr, "Width[%u] > info.dwMaximumWindowSize.X[%u] || Height[%u] > info.dwMaximumWindowSize.Y[%u]\n",
Width, info.dwMaximumWindowSize.X, Height, info.dwMaximumWindowSize.Y);
fprintf(stderr, "Width[%u] < GetSystemMetrics(SM_CXMIN)[%u] || Height[%u] < GetSystemMetrics(SM_CYMIN)[%u]\n",
Width, GetSystemMetrics(SM_CXMIN), Height, GetSystemMetrics(SM_CYMIN));
exit(1);
}
// end
Console_SetWindowPosition(Left, Top);
#endif
}
void Console_Close() {