Commit 3d7829b5 authored by Steven Fuller's avatar Steven Fuller

misc.c: Added Dan's put_dos2ansi (for exit screen)

parent dbc8142a
...@@ -20,7 +20,7 @@ typedef struct ...@@ -20,7 +20,7 @@ typedef struct
============================================================================= =============================================================================
*/ */
static byte *tinf; static mapfiletype *tinf;
int mapon; int mapon;
word *mapsegs[MAPPLANES]; word *mapsegs[MAPPLANES];
...@@ -467,9 +467,9 @@ static void CAL_SetupMapFile() ...@@ -467,9 +467,9 @@ static void CAL_SetupMapFile()
CA_CannotOpen(fname); CA_CannotOpen(fname);
length = filelength(handle); length = filelength(handle);
MM_GetPtr ((memptr)&tinf,length); MM_GetPtr((memptr)&tinf, length);
CA_FarRead(handle, tinf, length); CA_FarRead(handle, (byte *)tinf, length);
close(handle); close(handle);
...@@ -487,7 +487,7 @@ static void CAL_SetupMapFile() ...@@ -487,7 +487,7 @@ static void CAL_SetupMapFile()
// //
for (i=0;i<NUMMAPS;i++) for (i=0;i<NUMMAPS;i++)
{ {
pos = ((mapfiletype *)tinf)->headeroffsets[i]; pos = tinf->headeroffsets[i];
if (pos < 0) /* $FFFFFFFF start is a sparse map */ if (pos < 0) /* $FFFFFFFF start is a sparse map */
continue; continue;
...@@ -907,7 +907,7 @@ void CA_CacheMap(int mapnum) ...@@ -907,7 +907,7 @@ void CA_CacheMap(int mapnum)
source++; source++;
MM_GetPtr(&buffer2seg, expanded); MM_GetPtr(&buffer2seg, expanded);
CAL_CarmackExpand(source, (word *)buffer2seg,expanded); CAL_CarmackExpand(source, (word *)buffer2seg,expanded);
CA_RLEWexpand(((word *)buffer2seg)+1,*dest,size,((mapfiletype *)tinf)->RLEWtag); CA_RLEWexpand(((word *)buffer2seg)+1,*dest,size, tinf->RLEWtag);
MM_FreePtr(&buffer2seg); MM_FreePtr(&buffer2seg);
MM_FreePtr(&bigbufferseg); MM_FreePtr(&bigbufferseg);
......
...@@ -100,3 +100,99 @@ char *ultoa(unsigned long value, char *string, int radix) ...@@ -100,3 +100,99 @@ char *ultoa(unsigned long value, char *string, int radix)
} }
#endif /* DOSISM */ #endif /* DOSISM */
/* from Dan Olson */
static void put_dos2ansi(byte attrib)
{
byte fore,back,blink=0,intens=0;
fore = attrib&15; // bits 0-3
back = attrib&112; // bits 4-6
blink = attrib&128; // bit 7
// Fix background, blink is either on or off.
back = back>>4;
// Fix foreground
if (fore > 7) {
intens = 1;
fore-=8;
}
// Convert fore/back
switch (fore) {
case 0: // BLACK
fore=30;
break;
case 1: // BLUE
fore=34;
break;
case 2: // GREEN
fore=32;
break;
case 3: // CYAN
fore=36;
break;
case 4: // RED
fore=31;
break;
case 5: // Magenta
fore=35;
break;
case 6: // BROWN(yellow)
fore=33;
break;
case 7: //GRAy
fore=37;
break;
}
switch (back) {
case 0: // BLACK
back=40;
break;
case 1: // BLUE
back=44;
break;
case 2: // GREEN
back=42;
break;
case 3: // CYAN
back=46;
break;
case 4: // RED
back=41;
break;
case 5: // Magenta
back=45;
break;
case 6: // BROWN(yellow)
back=43;
break;
case 7: //GRAy
back=47;
break;
}
if (blink)
printf ("%c[%d;5;%dm%c[%dm", 27, intens, fore, 27, back);
else
printf ("%c[%d;25;%dm%c[%dm", 27, intens, fore, 27, back);
}
void DisplayTextSplash(byte *text)
{
int i;
//printf("%02X %02X %02X %02X\n", text[0], text[1], text[2], text[3]);
text += 4;
for (i = 0; i < 7*160; i += 2) {
put_dos2ansi(text[i+0]);
if (text[i+1])
printf("%c", text[i+1]);
else
printf(" ");
}
/* TODO: reset color */
printf("\n");
}
...@@ -15,9 +15,10 @@ byte *gfxbuf = NULL; ...@@ -15,9 +15,10 @@ byte *gfxbuf = NULL;
========================== ==========================
*/ */
void DisplayTextSplash(byte *text);
void Quit(char *error) void Quit(char *error)
{ {
/* TODO: blah blah blah */
memptr screen = NULL; memptr screen = NULL;
if (!error || !*error) { if (!error || !*error) {
...@@ -33,6 +34,8 @@ void Quit(char *error) ...@@ -33,6 +34,8 @@ void Quit(char *error)
if (screen) { if (screen) {
printf("TODO: spiffy ansi screen goes here..\n"); printf("TODO: spiffy ansi screen goes here..\n");
/* doesn't look too good on console at the moment ...*/
//DisplayTextSplash(screen);
} }
if (error && *error) { if (error && *error) {
......
...@@ -55,9 +55,10 @@ int main(int argc, char *argv[]) ...@@ -55,9 +55,10 @@ int main(int argc, char *argv[])
========================== ==========================
*/ */
void DisplayTextSplash(byte *text);
void Quit(char *error) void Quit(char *error)
{ {
/* TODO: blah blah blah */
memptr screen = NULL; memptr screen = NULL;
if (!error || !*error) { if (!error || !*error) {
...@@ -72,7 +73,8 @@ void Quit(char *error) ...@@ -72,7 +73,8 @@ void Quit(char *error)
ShutdownId(); ShutdownId();
if (screen) { if (screen) {
printf("TODO: spiffy ansi screen goes here..\n"); //printf("TODO: spiffy ansi screen goes here..\n");
DisplayTextSplash(screen);
} }
if (error && *error) { if (error && *error) {
......
...@@ -943,8 +943,9 @@ static void AsmRefresh() ...@@ -943,8 +943,9 @@ static void AsmRefresh()
if (tilehit & 0x40) { if (tilehit & 0x40) {
/* vertpushwall */ /* vertpushwall */
long ytemp = yintercept + (pwallpos * ystep) / 64; long ytemp = yintercept + (pwallpos * ystep) / 64;
ytemp &= ~0x4000000; /* TODO: why? */
//fprintf(stderr, "VertPushWall@%d: 0x%X vs 0x%X\n", angle, yintercept, ytemp); fprintf(stderr, "VertPushWall@%d: %d = %d + (%d * %d) / 64\n", angle, ytemp, yintercept, pwallpos, ystep);
ytemp &= ~0x4000000; /* TODO: why? */
if (TILE(ytemp) != TILE(yintercept)) if (TILE(ytemp) != TILE(yintercept))
goto passvert; goto passvert;
yintercept = ytemp; yintercept = ytemp;
...@@ -985,6 +986,8 @@ static void AsmRefresh() ...@@ -985,6 +986,8 @@ static void AsmRefresh()
/* horizdoor */ /* horizdoor */
if (tilehit & 0x40) { if (tilehit & 0x40) {
long xtemp = xintercept + (pwallpos * xstep) / 64; long xtemp = xintercept + (pwallpos * xstep) / 64;
fprintf(stderr, "HorizPushWall@%d: %d = %d + (%d * %d) / 64\n", angle, xtemp, xintercept, pwallpos, xstep);
xtemp &= ~0x4000000; xtemp &= ~0x4000000;
/* horizpushwall */ /* horizpushwall */
if (TILE(xtemp) != TILE(xintercept)) if (TILE(xtemp) != TILE(xintercept))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment