Anders
No one knows I'm schepe

Posts: 427
Registered: 03-02 |
I looked into it again and after some browsing in the MSDN labyrinth I found out how to set the colors in the windows console, tested it by modifying the eternity 3.33.02 source, works like a charm. If anyone wants to use it in their port, just say so and I'll write a version using ANSI control codes for non-windows targets.
code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
// Written by Anders Ĺstrand 2006-02-11
// Displays the colorful ENDOOM lump on the windows console
// Give it a pointer to the ENDOOM lump, and the length of it.
void TXT_Endoom(char *src, int length) {
int i;
char c;
char *ptr;
HANDLE console_handle;
CONSOLE_SCREEN_BUFFER_INFO console_info;
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(console_handle, &console_info);
ptr = src;
i = 0;
while (ptr < src+length) {
c = *(ptr++);
SetConsoleTextAttribute(console_handle, *(ptr++));
putc(c, stdout);
// Make sure to add linebreaks every 80th char if the console is wider then that
if ((console_info.dwSize.X > 80) && ((++i)%80 == 0))
putc('\n', stdout);
}
}
EDIT: Oh, and if you feel this is a really time critical part of your port you could ofcourse modify it to only set the attribute when it actually changes.
EDIT2: And sorry for the thread hi-jacking fraggle, i didn't realise this was the chocolate doom thread when i posted. Perhaps someone can split it out as this isn't targeted towards chocolate doom in any way.
EDIT3: I just realised this isn't fraggle's thread. /me hides.
Last edited by Anders on 02-11-06 at 18:01
|