Skip to content

Commit

Permalink
- Fixed: F1 help used a hard coded pointer to EGA memory for some scr…
Browse files Browse the repository at this point in the history
…eens. Instead use an alternate set of drawing functions to work with *GACHAR files. This also fixes the vanilla bug where those screens didn't show up properly in CGA mode.
  • Loading branch information
Blzut3 committed Jun 19, 2014
1 parent 0dabe46 commit 10ee958
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 68 deletions.
43 changes: 14 additions & 29 deletions catacomb.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ boolean wantmore (void)
/* */
/* charpic */
/* */
void charpic(int x,int y, classtype c, dirtype dir, int stage)
static void charpic(int x,int y, classtype c, dirtype dir, int stage)
{
int xx,yy,size,tilenum;

Expand All @@ -291,15 +291,12 @@ void charpic(int x,int y, classtype c, dirtype dir, int stage)

for (yy=y;yy<=y+size-1;yy++)
for (xx=x;xx<=x+size-1;xx++)
drawchar (xx,yy,tilenum++);
drawchartile (xx,yy,tilenum++);
};

void help (void)
{
int x,y;
char *oldcharptr;
#define OLDSET oldcharptr = charptr;charptr = (char*)0xa400;
#define NEWSET charptr = oldcharptr;

centerwindow (20,20);
print (" C A T A C O M B \n");
Expand Down Expand Up @@ -343,20 +340,16 @@ void help (void)
print ("launched. \n");
print ("\n");

OLDSET;

for (y=11; y<=18; y++)
for (x=3; x<=20; x++)
drawchar (x,y,128);
drawchartile (x,y,128);

charpic (4,14,player,east,2);
charpic (19,15,shot,east,1);
charpic (17,14,shot,east,0);
charpic (15,15,shot,east,1);
charpic (8,14,bigshot,east,0);

NEWSET;

if (!wantmore())
return;

Expand All @@ -369,23 +362,19 @@ void help (void)
print ("searching walls and \n");
print ("fighting retreats. \n");

OLDSET;

for (y=11; y<=18; y++)
for (x=3; x<=20; x++)
if (y==15)
drawchar (x,y,129);
drawchartile (x,y,129);
else if (y==16)
drawchar (x,y,131);
drawchartile (x,y,131);
else
drawchar (x,y,128);
drawchartile (x,y,128);
charpic (6,13,player,south,2);
sx=6;
sy=15;
print ("\35\35\36\36\37\37");

NEWSET;

if (!wantmore())
return;

Expand Down Expand Up @@ -420,18 +409,14 @@ void help (void)
print ("when you are being \n");
print ("mobbed by monsters! \n\n");

OLDSET;

print (" \200\200\200\n");
print ("POTIONS: \200\242\200\n");
print (" \200\200\200\n");
print ("SCROLLS: \200\243\200\n");
print (" (BOLTS/NUKES) \200\200\200\n");
print ("TREASURE: \200\247\200\n");
print (" (POINTS) \200\200\200\n");
print (" \200\200\200\n");

NEWSET;
printchartile (" \200\200\200\n");
printchartile ("POTIONS: \200\242\200\n");
printchartile (" \200\200\200\n");
printchartile ("SCROLLS: \200\243\200\n");
printchartile (" (BOLTS/NUKES) \200\200\200\n");
printchartile ("TREASURE: \200\247\200\n");
printchartile (" (POINTS) \200\200\200\n");
printchartile (" \200\200\200\n");

wantmore();

Expand Down
99 changes: 61 additions & 38 deletions catasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ void doall()

//=======================================================================

static void drawcgachartile(byte *dest, int tile)
{
byte *src = pics + (tile<<4);
unsigned r;
for(r = 0;r < 8;++r, src += 2)
{
*dest++ = (src[0]>>6)&3;
*dest++ = (src[0]>>4)&3;
*dest++ = (src[0]>>2)&3;
*dest++ = (src[0]>>0)&3;
*dest++ = (src[1]>>6)&3;
*dest++ = (src[1]>>4)&3;
*dest++ = (src[1]>>2)&3;
*dest = (src[1]>>0)&3;

dest += screenpitch-7;
}
}

//=========
//
// CGAREFRESH redraws the tiles that have changed in the tiled screen area
Expand All @@ -169,21 +188,7 @@ void cgarefresh()
if(tile != oldtiles[i])
{
oldtiles[i] = tile;
byte *src = pics + (tile<<4);
byte *dest = vbuf;
for(r = 0;r < 8;++r, src += 2)
{
*dest++ = (src[0]>>6)&3;
*dest++ = (src[0]>>4)&3;
*dest++ = (src[0]>>2)&3;
*dest++ = (src[0]>>0)&3;
*dest++ = (src[1]>>6)&3;
*dest++ = (src[1]>>4)&3;
*dest++ = (src[1]>>2)&3;
*dest = (src[1]>>0)&3;

dest += screenpitch-7;
}
drawcgachartile(vbuf, tile);
}
++i;
++ofs;
Expand All @@ -205,6 +210,32 @@ void cgarefresh()

//=======================================================================

static void drawegachartile(byte *dest, int tile)
{
byte *src = pics + (tile<<5);
unsigned r;
for(r = 0;r < 8;++r, ++src)
{
const byte chan[4] = {
src[0],
src[8],
src[16],
src[24]
};

*dest++ = EGA(chan,7);
*dest++ = EGA(chan,6);
*dest++ = EGA(chan,5);
*dest++ = EGA(chan,4);
*dest++ = EGA(chan,3);
*dest++ = EGA(chan,2);
*dest++ = EGA(chan,1);
*dest = EGA(chan,0);

dest += screenpitch-7;
}
}

//=========
//
// EGAREFRESH redraws the tiles that have changed in the tiled screen area
Expand All @@ -216,7 +247,7 @@ void egarefresh()
unsigned ofs = originy*86 + originx;

int tile;
unsigned i = 0, r;
unsigned i = 0;
unsigned endofrow = ofs + 24;
byte *vbuf = screenseg;
do
Expand All @@ -225,28 +256,7 @@ void egarefresh()
if(tile != oldtiles[i])
{
oldtiles[i] = tile;
byte *src = pics + (tile<<5);
byte *dest = vbuf;
for(r = 0;r < 8;++r, ++src)
{
const byte chan[4] = {
src[0],
src[8],
src[16],
src[24]
};

*dest++ = EGA(chan,7);
*dest++ = EGA(chan,6);
*dest++ = EGA(chan,5);
*dest++ = EGA(chan,4);
*dest++ = EGA(chan,3);
*dest++ = EGA(chan,2);
*dest++ = EGA(chan,1);
*dest = EGA(chan,0);

dest += screenpitch-7;
}
drawegachartile(vbuf, tile);
}
++i;
++ofs;
Expand All @@ -265,3 +275,16 @@ void egarefresh()

UpdateScreen();
}

void drawchartile(int x, int y, int tile)
{
switch(grmode)
{
case EGAgr:
drawegachartile(screenseg + (y<<3)*screenpitch + (x<<3), tile);
break;
case CGAgr:
drawcgachartile(screenseg + (y<<3)*screenpitch + (x<<3), tile);
break;
}
}
2 changes: 2 additions & 0 deletions pcrlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void installgrfile (char *filename,int unpack,void *inmem);

void drawchar (int x, int y, int charnum);
void drawpic (int x, int y, int picnum);
void drawchartile (int x, int y, int tile);

/*=========================================================================*/

Expand All @@ -226,6 +227,7 @@ int get (void);
int _input(char *string,int max);
unsigned _inputint(void);
void print (const char *str);
void printchartile (const char *str);
void _printc(char *string);
void _printhexb(unsigned char value);
void _printhex(unsigned value);
Expand Down
19 changes: 18 additions & 1 deletion pcrlib_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,24 @@ void print (const char *str)
else if (ch == '\r')
sx=leftedge;
else
drawchar (sx++,sy,ch);
drawchar (sx++,sy,(byte)ch);
}

// For help screen
void printchartile (const char *str)
{
char ch;

while ((ch=*str++) != 0)
if (ch == '\n')
{
sy++;
sx=leftedge;
}
else if (ch == '\r')
sx=leftedge;
else
drawchartile (sx++,sy,(byte)ch);
}


Expand Down

0 comments on commit 10ee958

Please sign in to comment.