Reformat all C files.
I'll push a formatting guide at some point. There may still be outstanding changes, but please feel free to resolve those as you arrive a them. To the best of my knowledge, there is no changes to the actual code content, but the formatter does have the occasional bug. If you run into an issue, please fix it!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 msdos.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 msdos.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
|
||||
/* NetHack 3.6 msdos.c $Date: 2012/01/22 06:27:07 $ $Revision: 1.7 $ */
|
||||
/* Copyright (c) NetHack PC Development Team 1990 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -21,18 +21,18 @@
|
||||
/*
|
||||
* MS-DOS functions
|
||||
*/
|
||||
#define DIRECT_INPUT 0x07 /* Unfiltered Character Input Without Echo */
|
||||
#define FATINFO 0x1B /* Get Default Drive Data */
|
||||
#define DIRECT_INPUT 0x07 /* Unfiltered Character Input Without Echo */
|
||||
#define FATINFO 0x1B /* Get Default Drive Data */
|
||||
/* MS-DOS 2.0+: */
|
||||
#define GETDTA 0x2F /* Get DTA Address */
|
||||
#define FREESPACE 0x36 /* Get Drive Allocation Info */
|
||||
#define GETSWITCHAR 0x3700 /* Get Switch Character */
|
||||
#define FINDFIRST 0x4E /* Find First File */
|
||||
#define FINDNEXT 0x4F /* Find Next File */
|
||||
#define SETFILETIME 0x5701 /* Set File Date & Time */
|
||||
/*
|
||||
* BIOS interrupts
|
||||
*/
|
||||
#define GETDTA 0x2F /* Get DTA Address */
|
||||
#define FREESPACE 0x36 /* Get Drive Allocation Info */
|
||||
#define GETSWITCHAR 0x3700 /* Get Switch Character */
|
||||
#define FINDFIRST 0x4E /* Find First File */
|
||||
#define FINDNEXT 0x4F /* Find Next File */
|
||||
#define SETFILETIME 0x5701 /* Set File Date & Time */
|
||||
/*
|
||||
* BIOS interrupts
|
||||
*/
|
||||
#ifdef PC9800
|
||||
#define KEYBRD_BIOS 0x18
|
||||
#else
|
||||
@@ -42,58 +42,58 @@
|
||||
/*
|
||||
* Keyboard BIOS functions
|
||||
*/
|
||||
#define READCHAR 0x00 /* Read Character from Keyboard */
|
||||
#define READCHAR 0x00 /* Read Character from Keyboard */
|
||||
#define GETKEYFLAGS 0x02 /* Get Keyboard Flags */
|
||||
/*#define KEY_DEBUG */ /* print values of unexpected key codes - devel*/
|
||||
/*#define KEY_DEBUG */ /* print values of unexpected key codes - devel*/
|
||||
|
||||
void FDECL(get_cursor,(int *, int *));
|
||||
void FDECL(get_cursor, (int *, int *));
|
||||
|
||||
/* direct bios calls are used only when iflags.BIOS is set */
|
||||
|
||||
STATIC_DCL char NDECL(DOSgetch);
|
||||
STATIC_DCL char NDECL(BIOSgetch);
|
||||
#ifndef __GO32__
|
||||
STATIC_DCL char * NDECL(getdta);
|
||||
STATIC_DCL char *NDECL(getdta);
|
||||
#endif
|
||||
STATIC_DCL unsigned int FDECL(dos_ioctl, (int,int,unsigned));
|
||||
STATIC_DCL unsigned int FDECL(dos_ioctl, (int, int, unsigned));
|
||||
#ifdef USE_TILES
|
||||
extern boolean FDECL(pckeys,(unsigned char, unsigned char)); /* pckeys.c */
|
||||
extern boolean FDECL(pckeys, (unsigned char, unsigned char)); /* pckeys.c */
|
||||
#endif
|
||||
|
||||
int
|
||||
tgetch()
|
||||
{
|
||||
char ch;
|
||||
char ch;
|
||||
|
||||
/* BIOSgetch can use the numeric key pad on IBM compatibles. */
|
||||
# ifdef SIMULATE_CURSOR
|
||||
if (iflags.grmode && cursor_flag) DrawCursor();
|
||||
# endif
|
||||
if (iflags.BIOS)
|
||||
ch = BIOSgetch();
|
||||
else
|
||||
ch = DOSgetch();
|
||||
# ifdef SIMULATE_CURSOR
|
||||
if (iflags.grmode && cursor_flag) HideCursor();
|
||||
# endif
|
||||
return ((ch == '\r') ? '\n' : ch);
|
||||
/* BIOSgetch can use the numeric key pad on IBM compatibles. */
|
||||
#ifdef SIMULATE_CURSOR
|
||||
if (iflags.grmode && cursor_flag)
|
||||
DrawCursor();
|
||||
#endif
|
||||
if (iflags.BIOS)
|
||||
ch = BIOSgetch();
|
||||
else
|
||||
ch = DOSgetch();
|
||||
#ifdef SIMULATE_CURSOR
|
||||
if (iflags.grmode && cursor_flag)
|
||||
HideCursor();
|
||||
#endif
|
||||
return ((ch == '\r') ? '\n' : ch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Keyboard translation tables.
|
||||
*/
|
||||
#ifdef PC9800
|
||||
#define KEYPADLO 0x38
|
||||
#define KEYPADHI 0x50
|
||||
#define KEYPADLO 0x38
|
||||
#define KEYPADHI 0x50
|
||||
#else
|
||||
#define KEYPADLO 0x47
|
||||
#define KEYPADHI 0x53
|
||||
#define KEYPADLO 0x47
|
||||
#define KEYPADHI 0x53
|
||||
#endif
|
||||
|
||||
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
||||
#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI)
|
||||
#define PADKEYS (KEYPADHI - KEYPADLO + 1)
|
||||
#define iskeypad(x) (KEYPADLO <= (x) && (x) <= KEYPADHI)
|
||||
|
||||
/*
|
||||
* Keypad keys are translated to the normal values below.
|
||||
@@ -101,92 +101,94 @@ tgetch()
|
||||
* shift values below.
|
||||
*/
|
||||
static const struct pad {
|
||||
char normal, shift, cntrl;
|
||||
} keypad[PADKEYS] = {
|
||||
char normal, shift, cntrl;
|
||||
} keypad[PADKEYS] =
|
||||
{
|
||||
#ifdef PC9800
|
||||
{'>', '>', '>'}, /* Ins */
|
||||
{'<', '<', '<'}, /* Del */
|
||||
{'k', 'K', C('k')}, /* Up */
|
||||
{'h', 'H', C('h')}, /* Left */
|
||||
{'l', 'L', C('l')}, /* Right */
|
||||
{'j', 'J', C('j')}, /* Down */
|
||||
{ 0 , 0 , 0 }, /* HomeClr */
|
||||
{'?', '?', '?' }, /* Help */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'/', '/', '/'}, /* / */
|
||||
{'y', 'Y', C('y')}, /* 7 */
|
||||
{'k', 'K', C('k')}, /* 8 */
|
||||
{'u', 'U', C('u')}, /* 9 */
|
||||
{'*', '*', '*'}, /* * */
|
||||
{'h', 'H', C('h')}, /* 4 */
|
||||
{'g', 'g', 'g'}, /* 5 */
|
||||
{'l', 'L', C('l')}, /* 6 */
|
||||
{'p', 'P', C('p')}, /* + */
|
||||
{'b', 'B', C('b')}, /* 1 */
|
||||
{'j', 'J', C('j')}, /* 2 */
|
||||
{'n', 'N', C('n')}, /* 3 */
|
||||
{'=', '=', '='}, /* = */
|
||||
{'i', 'I', C('i')}, /* 0 */
|
||||
{',', ':', ':'}, /* , */
|
||||
{'.', '.', '.'} /* . */
|
||||
{ '>', '>', '>' }, /* Ins */
|
||||
{ '<', '<', '<' }, /* Del */
|
||||
{ 'k', 'K', C('k') }, /* Up */
|
||||
{ 'h', 'H', C('h') }, /* Left */
|
||||
{ 'l', 'L', C('l') }, /* Right */
|
||||
{ 'j', 'J', C('j') }, /* Down */
|
||||
{ 0, 0, 0 }, /* HomeClr */
|
||||
{ '?', '?', '?' }, /* Help */
|
||||
{ 'm', C('p'), C('p') }, /* - */
|
||||
{ '/', '/', '/' }, /* / */
|
||||
{ 'y', 'Y', C('y') }, /* 7 */
|
||||
{ 'k', 'K', C('k') }, /* 8 */
|
||||
{ 'u', 'U', C('u') }, /* 9 */
|
||||
{ '*', '*', '*' }, /* * */
|
||||
{ 'h', 'H', C('h') }, /* 4 */
|
||||
{ 'g', 'g', 'g' }, /* 5 */
|
||||
{ 'l', 'L', C('l') }, /* 6 */
|
||||
{ 'p', 'P', C('p') }, /* + */
|
||||
{ 'b', 'B', C('b') }, /* 1 */
|
||||
{ 'j', 'J', C('j') }, /* 2 */
|
||||
{ 'n', 'N', C('n') }, /* 3 */
|
||||
{ '=', '=', '=' }, /* = */
|
||||
{ 'i', 'I', C('i') }, /* 0 */
|
||||
{ ',', ':', ':' }, /* , */
|
||||
{ '.', '.', '.' } /* . */
|
||||
#else
|
||||
{'y', 'Y', C('y')}, /* 7 */
|
||||
{'k', 'K', C('k')}, /* 8 */
|
||||
{'u', 'U', C('u')}, /* 9 */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'h', 'H', C('h')}, /* 4 */
|
||||
{'g', 'g', 'g'}, /* 5 */
|
||||
{'l', 'L', C('l')}, /* 6 */
|
||||
{'p', 'P', C('p')}, /* + */
|
||||
{'b', 'B', C('b')}, /* 1 */
|
||||
{'j', 'J', C('j')}, /* 2 */
|
||||
{'n', 'N', C('n')}, /* 3 */
|
||||
{'i', 'I', C('i')}, /* Ins */
|
||||
{'.', ':', ':'} /* Del */
|
||||
{ 'y', 'Y', C('y') }, /* 7 */
|
||||
{ 'k', 'K', C('k') }, /* 8 */
|
||||
{ 'u', 'U', C('u') }, /* 9 */
|
||||
{ 'm', C('p'), C('p') }, /* - */
|
||||
{ 'h', 'H', C('h') }, /* 4 */
|
||||
{ 'g', 'g', 'g' }, /* 5 */
|
||||
{ 'l', 'L', C('l') }, /* 6 */
|
||||
{ 'p', 'P', C('p') }, /* + */
|
||||
{ 'b', 'B', C('b') }, /* 1 */
|
||||
{ 'j', 'J', C('j') }, /* 2 */
|
||||
{ 'n', 'N', C('n') }, /* 3 */
|
||||
{ 'i', 'I', C('i') }, /* Ins */
|
||||
{ '.', ':', ':' } /* Del */
|
||||
#endif
|
||||
}, numpad[PADKEYS] = {
|
||||
},
|
||||
numpad[PADKEYS] = {
|
||||
#ifdef PC9800
|
||||
{'>', '>', '>'}, /* Ins */
|
||||
{'<', '<', '<'}, /* Del */
|
||||
{'8', M('8'), '8'}, /* Up */
|
||||
{'4', M('4'), '4'}, /* Left */
|
||||
{'6', M('6'), '6'}, /* Right */
|
||||
{'2', M('2'), '2'}, /* Down */
|
||||
{ 0 , 0 , 0 }, /* HomeClr */
|
||||
{'?', '?', '?'}, /* Help */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'/', '/', '/'}, /* / */
|
||||
{'7', M('7'), '7'}, /* 7 */
|
||||
{'8', M('8'), '8'}, /* 8 */
|
||||
{'9', M('9'), '9'}, /* 9 */
|
||||
{'*', '*', '*'}, /* * */
|
||||
{'4', M('4'), '4'}, /* 4 */
|
||||
{'g', 'G', 'g'}, /* 5 */
|
||||
{'6', M('6'), '6'}, /* 6 */
|
||||
{'p', 'P', C('p')}, /* + */
|
||||
{'1', M('1'), '1'}, /* 1 */
|
||||
{'2', M('2'), '2'}, /* 2 */
|
||||
{'3', M('3'), '3'}, /* 3 */
|
||||
{'=', '=', '='}, /* = */
|
||||
{'i', 'I', C('i')}, /* 0 */
|
||||
{',', ':', ':'}, /* , */
|
||||
{'.', '.', '.'} /* . */
|
||||
{ '>', '>', '>' }, /* Ins */
|
||||
{ '<', '<', '<' }, /* Del */
|
||||
{ '8', M('8'), '8' }, /* Up */
|
||||
{ '4', M('4'), '4' }, /* Left */
|
||||
{ '6', M('6'), '6' }, /* Right */
|
||||
{ '2', M('2'), '2' }, /* Down */
|
||||
{ 0, 0, 0 }, /* HomeClr */
|
||||
{ '?', '?', '?' }, /* Help */
|
||||
{ 'm', C('p'), C('p') }, /* - */
|
||||
{ '/', '/', '/' }, /* / */
|
||||
{ '7', M('7'), '7' }, /* 7 */
|
||||
{ '8', M('8'), '8' }, /* 8 */
|
||||
{ '9', M('9'), '9' }, /* 9 */
|
||||
{ '*', '*', '*' }, /* * */
|
||||
{ '4', M('4'), '4' }, /* 4 */
|
||||
{ 'g', 'G', 'g' }, /* 5 */
|
||||
{ '6', M('6'), '6' }, /* 6 */
|
||||
{ 'p', 'P', C('p') }, /* + */
|
||||
{ '1', M('1'), '1' }, /* 1 */
|
||||
{ '2', M('2'), '2' }, /* 2 */
|
||||
{ '3', M('3'), '3' }, /* 3 */
|
||||
{ '=', '=', '=' }, /* = */
|
||||
{ 'i', 'I', C('i') }, /* 0 */
|
||||
{ ',', ':', ':' }, /* , */
|
||||
{ '.', '.', '.' } /* . */
|
||||
#else
|
||||
{'7', M('7'), '7'}, /* 7 */
|
||||
{'8', M('8'), '8'}, /* 8 */
|
||||
{'9', M('9'), '9'}, /* 9 */
|
||||
{'m', C('p'), C('p')}, /* - */
|
||||
{'4', M('4'), '4'}, /* 4 */
|
||||
{'5', M('5'), '5'}, /* 5 */
|
||||
{'6', M('6'), '6'}, /* 6 */
|
||||
{'p', 'P', C('p')}, /* + */
|
||||
{'1', M('1'), '1'}, /* 1 */
|
||||
{'2', M('2'), '2'}, /* 2 */
|
||||
{'3', M('3'), '3'}, /* 3 */
|
||||
{'0', M('0'), '0'}, /* Ins */
|
||||
{'.', ':', ':'} /* Del */
|
||||
{ '7', M('7'), '7' }, /* 7 */
|
||||
{ '8', M('8'), '8' }, /* 8 */
|
||||
{ '9', M('9'), '9' }, /* 9 */
|
||||
{ 'm', C('p'), C('p') }, /* - */
|
||||
{ '4', M('4'), '4' }, /* 4 */
|
||||
{ '5', M('5'), '5' }, /* 5 */
|
||||
{ '6', M('6'), '6' }, /* 6 */
|
||||
{ 'p', 'P', C('p') }, /* + */
|
||||
{ '1', M('1'), '1' }, /* 1 */
|
||||
{ '2', M('2'), '2' }, /* 2 */
|
||||
{ '3', M('3'), '3' }, /* 3 */
|
||||
{ '0', M('0'), '0' }, /* Ins */
|
||||
{ '.', ':', ':' } /* Del */
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Unlike Ctrl-letter, the Alt-letter keystrokes have no specific ASCII
|
||||
@@ -197,172 +199,176 @@ static const struct pad {
|
||||
* "meta" bit for it. -3.
|
||||
*/
|
||||
#ifdef PC9800
|
||||
#define SCANLO 0x5
|
||||
#define SCANLO 0x5
|
||||
#else
|
||||
#define SCANLO 0x10
|
||||
#define SCANLO 0x10
|
||||
#endif /* PC9800 */
|
||||
|
||||
static const char scanmap[] = { /* ... */
|
||||
static const char scanmap[] = {
|
||||
/* ... */
|
||||
#ifdef PC9800
|
||||
0, 0, 0, 0, 0, 0, '-','^','\\','\b',
|
||||
'\t','q','w','e','r','t','y','u','i','o','p','@','[', '\n',
|
||||
'a','s','d','f','g','h','j','k','l',';',':', ']',
|
||||
'z','x','c','v','b','N','m',',','.','/' /* ... */
|
||||
0, 0, 0, 0, 0, 0, '-', '^', '\\', '\b', '\t', 'q', 'w', 'e', 'r', 't',
|
||||
'y', 'u', 'i', 'o', 'p', '@', '[', '\n', 'a', 's', 'd', 'f', 'g', 'h',
|
||||
'j', 'k', 'l', ';', ':', ']', 'z', 'x', 'c', 'v', 'b', 'N', 'm', ',', '.',
|
||||
'/' /* ... */
|
||||
#else
|
||||
'q','w','e','r','t','y','u','i','o','p','[',']', '\n',
|
||||
0, 'a','s','d','f','g','h','j','k','l',';','\'', '`',
|
||||
0, '\\', 'z','x','c','v','b','n','m',',','.','?' /* ... */
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a',
|
||||
's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x',
|
||||
'c', 'v', 'b', 'n', 'm', ',', '.', '?' /* ... */
|
||||
#endif /* PC9800 */
|
||||
};
|
||||
|
||||
#define inmap(x) (SCANLO <= (x) && (x) < SCANLO + SIZE(scanmap))
|
||||
#define inmap(x) (SCANLO <= (x) && (x) < SCANLO + SIZE(scanmap))
|
||||
|
||||
#ifdef NEW_ALT
|
||||
#define NUMERIC_SCANLO 0x78
|
||||
static const char numeric_scanmap[] = { /* ... */
|
||||
'1','2','3','4','5','6','7','8','9','0','-','='
|
||||
#define NUMERIC_SCANLO 0x78
|
||||
static const char numeric_scanmap[] = { /* ... */
|
||||
'1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', '0', '-', '='
|
||||
};
|
||||
# define in_numericmap(x) (NUMERIC_SCANLO <= (x) && \
|
||||
(x) < NUMERIC_SCANLO + SIZE(numeric_scanmap))
|
||||
# endif
|
||||
#define in_numericmap(x) \
|
||||
(NUMERIC_SCANLO <= (x) && (x) < NUMERIC_SCANLO + SIZE(numeric_scanmap))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* BIOSgetch gets keys directly with a BIOS call.
|
||||
*/
|
||||
#ifdef PC9800
|
||||
#define SHIFT 0x1
|
||||
#define KANA 0x4
|
||||
#define GRPH 0x8
|
||||
#define CTRL 0x10
|
||||
#define SHIFT 0x1
|
||||
#define KANA 0x4
|
||||
#define GRPH 0x8
|
||||
#define CTRL 0x10
|
||||
#else
|
||||
#define SHIFT (0x1 | 0x2)
|
||||
#define CTRL 0x4
|
||||
#define ALT 0x8
|
||||
#define SHIFT (0x1 | 0x2)
|
||||
#define CTRL 0x4
|
||||
#define ALT 0x8
|
||||
#endif /* PC9800 */
|
||||
|
||||
STATIC_OVL char
|
||||
BIOSgetch()
|
||||
{
|
||||
unsigned char scan, shift, ch=0;
|
||||
const struct pad *kpad;
|
||||
union REGS regs;
|
||||
unsigned char scan, shift, ch = 0;
|
||||
const struct pad *kpad;
|
||||
union REGS regs;
|
||||
|
||||
do {
|
||||
/* Get scan code.
|
||||
*/
|
||||
regs.h.ah = READCHAR;
|
||||
int86(KEYBRD_BIOS, ®s, ®s);
|
||||
ch = regs.h.al;
|
||||
scan = regs.h.ah;
|
||||
/* Get shift status.
|
||||
*/
|
||||
regs.h.ah = GETKEYFLAGS;
|
||||
int86(KEYBRD_BIOS, ®s, ®s);
|
||||
shift = regs.h.al;
|
||||
do {
|
||||
/* Get scan code.
|
||||
*/
|
||||
regs.h.ah = READCHAR;
|
||||
int86(KEYBRD_BIOS, ®s, ®s);
|
||||
ch = regs.h.al;
|
||||
scan = regs.h.ah;
|
||||
/* Get shift status.
|
||||
*/
|
||||
regs.h.ah = GETKEYFLAGS;
|
||||
int86(KEYBRD_BIOS, ®s, ®s);
|
||||
shift = regs.h.al;
|
||||
|
||||
/* Translate keypad keys */
|
||||
if (iskeypad(scan)) {
|
||||
kpad = iflags.num_pad ? numpad : keypad;
|
||||
if (shift & SHIFT)
|
||||
ch = kpad[scan - KEYPADLO].shift;
|
||||
else if (shift & CTRL)
|
||||
ch = kpad[scan - KEYPADLO].cntrl;
|
||||
else
|
||||
ch = kpad[scan - KEYPADLO].normal;
|
||||
}
|
||||
/* Translate keypad keys */
|
||||
if (iskeypad(scan)) {
|
||||
kpad = iflags.num_pad ? numpad : keypad;
|
||||
if (shift & SHIFT)
|
||||
ch = kpad[scan - KEYPADLO].shift;
|
||||
else if (shift & CTRL)
|
||||
ch = kpad[scan - KEYPADLO].cntrl;
|
||||
else
|
||||
ch = kpad[scan - KEYPADLO].normal;
|
||||
}
|
||||
#ifdef USE_TILES
|
||||
/* Check for special interface manipulation keys */
|
||||
if (pckeys(scan, shift)) {
|
||||
ch = 0xFF;
|
||||
continue;
|
||||
}
|
||||
/* Check for special interface manipulation keys */
|
||||
if (pckeys(scan, shift)) {
|
||||
ch = 0xFF;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* Translate unassigned Alt-letters */
|
||||
/* Translate unassigned Alt-letters */
|
||||
#ifdef PC9800
|
||||
if (shift & KANA)
|
||||
return 0;
|
||||
if ((shift & GRPH) && (ch >= 0x80)) {
|
||||
if (shift & KANA)
|
||||
return 0;
|
||||
if ((shift & GRPH) && (ch >= 0x80)) {
|
||||
#else
|
||||
if ((shift & ALT) && !ch) {
|
||||
if ((shift & ALT) && !ch) {
|
||||
#endif
|
||||
#if 0
|
||||
pline("Scan code: %d 0x%03X", scan, scan);
|
||||
#endif
|
||||
if (inmap(scan))
|
||||
ch = scanmap[scan - SCANLO];
|
||||
if (inmap(scan))
|
||||
ch = scanmap[scan - SCANLO];
|
||||
#ifdef NEW_ALT
|
||||
else if (in_numericmap(scan))
|
||||
ch = numeric_scanmap[scan - NUMERIC_SCANLO];
|
||||
else if (in_numericmap(scan))
|
||||
ch = numeric_scanmap[scan - NUMERIC_SCANLO];
|
||||
#endif
|
||||
return (isprint(ch) ? M(ch) : ch);
|
||||
}
|
||||
} while (ch == 0xFF);
|
||||
return ch;
|
||||
return (isprint(ch) ? M(ch) : ch);
|
||||
}
|
||||
} while (ch == 0xFF);
|
||||
return ch;
|
||||
}
|
||||
|
||||
STATIC_OVL char
|
||||
DOSgetch()
|
||||
{
|
||||
union REGS regs;
|
||||
char ch;
|
||||
struct pad (*kpad)[PADKEYS];
|
||||
union REGS regs;
|
||||
char ch;
|
||||
struct pad(*kpad)[PADKEYS];
|
||||
|
||||
regs.h.ah = DIRECT_INPUT;
|
||||
intdos(®s, ®s);
|
||||
ch = regs.h.al;
|
||||
regs.h.ah = DIRECT_INPUT;
|
||||
intdos(®s, ®s);
|
||||
ch = regs.h.al;
|
||||
|
||||
#ifdef PC9800
|
||||
if (ch < 0) /* KANA letters and GRPH-shifted letters(?) */
|
||||
ch = 0; /* munch it */
|
||||
if (ch < 0) /* KANA letters and GRPH-shifted letters(?) */
|
||||
ch = 0; /* munch it */
|
||||
#else
|
||||
/*
|
||||
* The extended codes for Alt-shifted letters, and unshifted keypad
|
||||
* and function keys, correspond to the scan codes. So we can still
|
||||
* translate the unshifted cursor keys and Alt-letters. -3.
|
||||
*/
|
||||
if (ch == 0) { /* an extended key */
|
||||
regs.h.ah = DIRECT_INPUT;
|
||||
intdos(®s, ®s); /* get the extended key code */
|
||||
ch = regs.h.al;
|
||||
/*
|
||||
* The extended codes for Alt-shifted letters, and unshifted keypad
|
||||
* and function keys, correspond to the scan codes. So we can still
|
||||
* translate the unshifted cursor keys and Alt-letters. -3.
|
||||
*/
|
||||
if (ch == 0) { /* an extended key */
|
||||
regs.h.ah = DIRECT_INPUT;
|
||||
intdos(®s, ®s); /* get the extended key code */
|
||||
ch = regs.h.al;
|
||||
|
||||
if (iskeypad(ch)) { /* unshifted keypad keys */
|
||||
kpad = (void *)(iflags.num_pad ? numpad : keypad);
|
||||
ch = (*kpad)[ch - KEYPADLO].normal;
|
||||
} else if (inmap(ch)) { /* Alt-letters */
|
||||
ch = scanmap[ch - SCANLO];
|
||||
if (isprint(ch)) ch = M(ch);
|
||||
} else ch = 0; /* munch it */
|
||||
}
|
||||
if (iskeypad(ch)) { /* unshifted keypad keys */
|
||||
kpad = (void *) (iflags.num_pad ? numpad : keypad);
|
||||
ch = (*kpad)[ch - KEYPADLO].normal;
|
||||
} else if (inmap(ch)) { /* Alt-letters */
|
||||
ch = scanmap[ch - SCANLO];
|
||||
if (isprint(ch))
|
||||
ch = M(ch);
|
||||
} else
|
||||
ch = 0; /* munch it */
|
||||
}
|
||||
#endif
|
||||
return (ch);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
char
|
||||
switchar()
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
regs.x.ax = GETSWITCHAR;
|
||||
intdos(®s, ®s);
|
||||
return regs.h.dl;
|
||||
regs.x.ax = GETSWITCHAR;
|
||||
intdos(®s, ®s);
|
||||
return regs.h.dl;
|
||||
}
|
||||
|
||||
long
|
||||
freediskspace(path)
|
||||
char *path;
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = FREESPACE;
|
||||
if (path[0] && path[1] == ':')
|
||||
regs.h.dl = (toupper(path[0]) - 'A') + 1;
|
||||
else
|
||||
regs.h.dl = 0;
|
||||
intdos(®s, ®s);
|
||||
if (regs.x.ax == 0xFFFF)
|
||||
return -1L; /* bad drive number */
|
||||
else
|
||||
return ((long) regs.x.bx * regs.x.cx * regs.x.ax);
|
||||
regs.h.ah = FREESPACE;
|
||||
if (path[0] && path[1] == ':')
|
||||
regs.h.dl = (toupper(path[0]) - 'A') + 1;
|
||||
else
|
||||
regs.h.dl = 0;
|
||||
intdos(®s, ®s);
|
||||
if (regs.x.ax == 0xFFFF)
|
||||
return -1L; /* bad drive number */
|
||||
else
|
||||
return ((long) regs.x.bx * regs.x.cx * regs.x.ax);
|
||||
}
|
||||
|
||||
#ifndef __GO32__
|
||||
@@ -373,63 +379,63 @@ int
|
||||
findfirst_file(path)
|
||||
char *path;
|
||||
{
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
|
||||
regs.h.ah = FINDFIRST;
|
||||
regs.x.cx = 0; /* attribute: normal files */
|
||||
regs.x.dx = FP_OFF(path);
|
||||
sregs.ds = FP_SEG(path);
|
||||
intdosx(®s, ®s, &sregs);
|
||||
return !regs.x.cflag;
|
||||
regs.h.ah = FINDFIRST;
|
||||
regs.x.cx = 0; /* attribute: normal files */
|
||||
regs.x.dx = FP_OFF(path);
|
||||
sregs.ds = FP_SEG(path);
|
||||
intdosx(®s, ®s, &sregs);
|
||||
return !regs.x.cflag;
|
||||
}
|
||||
|
||||
int
|
||||
findnext_file() {
|
||||
union REGS regs;
|
||||
findnext_file()
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = FINDNEXT;
|
||||
intdos(®s, ®s);
|
||||
return !regs.x.cflag;
|
||||
regs.h.ah = FINDNEXT;
|
||||
intdos(®s, ®s);
|
||||
return !regs.x.cflag;
|
||||
}
|
||||
|
||||
char *
|
||||
foundfile_buffer()
|
||||
{
|
||||
return (getdta() + 30);
|
||||
return (getdta() + 30);
|
||||
}
|
||||
|
||||
|
||||
/* Get disk transfer area */
|
||||
STATIC_OVL char *
|
||||
getdta()
|
||||
{
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
char *ret;
|
||||
union REGS regs;
|
||||
struct SREGS sregs;
|
||||
char *ret;
|
||||
|
||||
regs.h.ah = GETDTA;
|
||||
intdosx(®s, ®s, &sregs);
|
||||
# ifdef MK_FP
|
||||
ret = (char *)MK_FP(sregs.es, regs.x.bx);
|
||||
# else
|
||||
FP_OFF(ret) = regs.x.bx;
|
||||
FP_SEG(ret) = sregs.es;
|
||||
# endif
|
||||
return ret;
|
||||
regs.h.ah = GETDTA;
|
||||
intdosx(®s, ®s, &sregs);
|
||||
#ifdef MK_FP
|
||||
ret = (char *) MK_FP(sregs.es, regs.x.bx);
|
||||
#else
|
||||
FP_OFF(ret) = regs.x.bx;
|
||||
FP_SEG(ret) = sregs.es;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
long
|
||||
filesize_nh(file)
|
||||
char *file;
|
||||
{
|
||||
char *dta;
|
||||
char *dta;
|
||||
|
||||
if (findfirst_file(file)) {
|
||||
dta = getdta();
|
||||
return (* (long *) (dta + 26));
|
||||
} else
|
||||
return -1L;
|
||||
if (findfirst_file(file)) {
|
||||
dta = getdta();
|
||||
return (*(long *) (dta + 26));
|
||||
} else
|
||||
return -1L;
|
||||
}
|
||||
|
||||
#endif /* __GO32__ */
|
||||
@@ -441,61 +447,61 @@ void
|
||||
chdrive(str)
|
||||
char *str;
|
||||
{
|
||||
# define SELECTDISK 0x0E
|
||||
char *ptr;
|
||||
union REGS inregs;
|
||||
char drive;
|
||||
#define SELECTDISK 0x0E
|
||||
char *ptr;
|
||||
union REGS inregs;
|
||||
char drive;
|
||||
|
||||
if ((ptr = index(str, ':')) != (char *)0) {
|
||||
drive = toupper(*(ptr - 1));
|
||||
inregs.h.ah = SELECTDISK;
|
||||
inregs.h.dl = drive - 'A';
|
||||
intdos(&inregs, &inregs);
|
||||
}
|
||||
return;
|
||||
if ((ptr = index(str, ':')) != (char *) 0) {
|
||||
drive = toupper(*(ptr - 1));
|
||||
inregs.h.ah = SELECTDISK;
|
||||
inregs.h.dl = drive - 'A';
|
||||
intdos(&inregs, &inregs);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Use the IOCTL DOS function call to change stdin and stdout to raw
|
||||
* mode. For stdin, this prevents MSDOS from trapping ^P, thus
|
||||
* freeing us of ^P toggling 'echo to printer'.
|
||||
* Thanks to Mark Zbikowski (markz@microsoft.UUCP).
|
||||
*/
|
||||
|
||||
#define DEVICE 0x80
|
||||
#define RAW 0x20
|
||||
#define IOCTL 0x44
|
||||
#define STDIN fileno(stdin)
|
||||
#define STDOUT fileno(stdout)
|
||||
#define GETBITS 0
|
||||
#define SETBITS 1
|
||||
#define DEVICE 0x80
|
||||
#define RAW 0x20
|
||||
#define IOCTL 0x44
|
||||
#define STDIN fileno(stdin)
|
||||
#define STDOUT fileno(stdout)
|
||||
#define GETBITS 0
|
||||
#define SETBITS 1
|
||||
|
||||
static unsigned int old_stdin, old_stdout;
|
||||
static unsigned int old_stdin, old_stdout;
|
||||
|
||||
void
|
||||
disable_ctrlP()
|
||||
{
|
||||
|
||||
if (!iflags.rawio) return;
|
||||
if (!iflags.rawio)
|
||||
return;
|
||||
|
||||
old_stdin = dos_ioctl(STDIN, GETBITS, 0);
|
||||
old_stdout = dos_ioctl(STDOUT, GETBITS, 0);
|
||||
if (old_stdin & DEVICE)
|
||||
if (old_stdin & DEVICE)
|
||||
dos_ioctl(STDIN, SETBITS, old_stdin | RAW);
|
||||
if (old_stdout & DEVICE)
|
||||
if (old_stdout & DEVICE)
|
||||
dos_ioctl(STDOUT, SETBITS, old_stdout | RAW);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
enable_ctrlP()
|
||||
{
|
||||
if (!iflags.rawio) return;
|
||||
if (old_stdin)
|
||||
if (!iflags.rawio)
|
||||
return;
|
||||
if (old_stdin)
|
||||
(void) dos_ioctl(STDIN, SETBITS, old_stdin);
|
||||
if (old_stdout)
|
||||
if (old_stdout)
|
||||
(void) dos_ioctl(STDOUT, SETBITS, old_stdout);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC_OVL unsigned int
|
||||
@@ -503,15 +509,15 @@ dos_ioctl(handle, mode, setvalue)
|
||||
int handle, mode;
|
||||
unsigned setvalue;
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = IOCTL;
|
||||
regs.h.al = mode;
|
||||
regs.x.bx = handle;
|
||||
regs.h.dl = setvalue;
|
||||
regs.h.dh = 0; /* Zero out dh */
|
||||
intdos(®s, ®s);
|
||||
return (regs.x.dx);
|
||||
regs.h.ah = IOCTL;
|
||||
regs.h.al = mode;
|
||||
regs.x.bx = handle;
|
||||
regs.h.dl = setvalue;
|
||||
regs.h.dh = 0; /* Zero out dh */
|
||||
intdos(®s, ®s);
|
||||
return (regs.x.dx);
|
||||
}
|
||||
|
||||
#endif /* MSDOS */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 ovlinit.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 ovlinit.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 ovlinit.c $Date: 2009/05/06 10:49:38 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)ovlinit.c 3.5 1994/03/20 */
|
||||
/* Copyright (c) NetHack PC Development Team 1995 */
|
||||
@@ -8,57 +8,57 @@
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define RESERVED_PARAGRAPHS 5120 /* leave 80K for malloc and inits */
|
||||
/* subject to change before release */
|
||||
#define RESERVED_PARAGRAPHS 5120 /* leave 80K for malloc and inits */
|
||||
/* subject to change before release */
|
||||
|
||||
/*
|
||||
* memavail() Returns the amount of RAM available (in paragraphs which are 16
|
||||
* bytes) - the amount to be reserved for heap allocations.
|
||||
*
|
||||
*/
|
||||
unsigned memavail(minovl)
|
||||
unsigned minovl; /* minimum size of overlay heap */
|
||||
unsigned
|
||||
memavail(minovl)
|
||||
unsigned minovl; /* minimum size of overlay heap */
|
||||
{
|
||||
unsigned available;
|
||||
unsigned available;
|
||||
|
||||
unsigned farparaavail;
|
||||
unsigned tmp;
|
||||
unsigned farparaavail;
|
||||
unsigned tmp;
|
||||
|
||||
/*
|
||||
* _dos_allocmem will return the maximum block size available.
|
||||
* It uses DOS (int 21h) service 0x48.
|
||||
*/
|
||||
/*
|
||||
* _dos_allocmem will return the maximum block size available.
|
||||
* It uses DOS (int 21h) service 0x48.
|
||||
*/
|
||||
|
||||
_dos_allocmem(0xFFFF, &farparaavail);
|
||||
available = farparaavail - RESERVED_PARAGRAPHS;
|
||||
tmp = RESERVED_PARAGRAPHS + minovl;
|
||||
if (farparaavail < tmp) {
|
||||
panic("Not enough free RAM to begin a game of NetHack (%ld bytes)",
|
||||
(long)((long)tmp * 16L));
|
||||
}
|
||||
return available;
|
||||
_dos_allocmem(0xFFFF, &farparaavail);
|
||||
available = farparaavail - RESERVED_PARAGRAPHS;
|
||||
tmp = RESERVED_PARAGRAPHS + minovl;
|
||||
if (farparaavail < tmp) {
|
||||
panic("Not enough free RAM to begin a game of NetHack (%ld bytes)",
|
||||
(long) ((long) tmp * 16L));
|
||||
}
|
||||
return available;
|
||||
}
|
||||
#endif /*_MSC_VER*/
|
||||
#endif /*_MSC_VER*/
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
|
||||
#define RSRVD_MALLOC 65 * 1024L /* malloc() calls use about 65K */
|
||||
#define RSRVD_CRTL 50 * 1024L /* C runtime library uses 50K */
|
||||
#define RSRVD_TOTAL 115 * 1024L /* reserved for use in malloc() */
|
||||
/* as well as by C runtime library */
|
||||
/* routines which allocate memory */
|
||||
/* after this routine runs. */
|
||||
#define MIN_OVRBUF 30 * 1024L /* Overlay buffer gets minimum of */
|
||||
#define MAX_OVRBUF 200 * 1024L /* 30K and maximum of 200K. */
|
||||
#define RSRVD_MALLOC 65 * 1024L /* malloc() calls use about 65K */
|
||||
#define RSRVD_CRTL 50 * 1024L /* C runtime library uses 50K */
|
||||
#define RSRVD_TOTAL 115 * 1024L /* reserved for use in malloc() */
|
||||
/* as well as by C runtime library */
|
||||
/* routines which allocate memory */
|
||||
/* after this routine runs. */
|
||||
#define MIN_OVRBUF 30 * 1024L /* Overlay buffer gets minimum of */
|
||||
#define MAX_OVRBUF 200 * 1024L /* 30K and maximum of 200K. */
|
||||
|
||||
#define RESIZE_OVL
|
||||
#ifdef RESIZE_OVL
|
||||
|
||||
extern unsigned _ovrbuffer = 0; /* Use default size initially */
|
||||
unsigned appFail = 0; /* Fail flag if not enough RAM */
|
||||
extern unsigned _ovrbuffer = 0; /* Use default size initially */
|
||||
unsigned appFail = 0; /* Fail flag if not enough RAM */
|
||||
unsigned memAlloc = 0;
|
||||
unsigned long ProgramSize;
|
||||
unsigned long runAlloc;
|
||||
@@ -70,87 +70,89 @@ int xmsstatus;
|
||||
|
||||
void NDECL(_resizeOvrBuffer);
|
||||
|
||||
void _resizeOvrBuffer()
|
||||
void
|
||||
_resizeOvrBuffer()
|
||||
{
|
||||
mem_top = (unsigned far *) MK_FP( _psp, 0x02 );
|
||||
total = *mem_top - _psp;
|
||||
mem_top = (unsigned far *) MK_FP(_psp, 0x02);
|
||||
total = *mem_top - _psp;
|
||||
|
||||
ProgramSize = * (unsigned far *) MK_FP( _psp - 1, 0x03 );
|
||||
tmpbuffer = total - ProgramSize - RSRVD_TOTAL / 16;
|
||||
memAlloc = min (MAX_OVRBUF / 16, tmpbuffer);
|
||||
if (tmpbuffer >= MIN_OVRBUF / 16)
|
||||
_ovrbuffer = memAlloc;
|
||||
else {
|
||||
_ovrbuffer = 1;
|
||||
appFail = 1;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Remember, when inside this code, nothing has been setup on
|
||||
* the system, so do NOT call any RTL functions for I/O or
|
||||
* anything else that might rely on a startup function. This
|
||||
* includes accessing any global objects as their constructors
|
||||
* have not been called yet.
|
||||
*/
|
||||
ProgramSize = *(unsigned far *) MK_FP(_psp - 1, 0x03);
|
||||
tmpbuffer = total - ProgramSize - RSRVD_TOTAL / 16;
|
||||
memAlloc = min(MAX_OVRBUF / 16, tmpbuffer);
|
||||
if (tmpbuffer >= MIN_OVRBUF / 16)
|
||||
_ovrbuffer = memAlloc;
|
||||
else {
|
||||
_ovrbuffer = 1;
|
||||
appFail = 1;
|
||||
};
|
||||
|
||||
/*
|
||||
* Remember, when inside this code, nothing has been setup on
|
||||
* the system, so do NOT call any RTL functions for I/O or
|
||||
* anything else that might rely on a startup function. This
|
||||
* includes accessing any global objects as their constructors
|
||||
* have not been called yet.
|
||||
*/
|
||||
}
|
||||
|
||||
#pragma startup _resizeOvrBuffer 0 /* Put function in table */
|
||||
#pragma startup _resizeOvrBuffer 0 /* Put function in table */
|
||||
|
||||
void
|
||||
startup ()
|
||||
startup()
|
||||
{
|
||||
if (appFail) {
|
||||
printf ("NetHack fits in memory, but it cannot allocate memory");
|
||||
printf (" for the overlay buffer\nand the runtime functions. ");
|
||||
printf ("Please free up just %ld more bytes.",
|
||||
(long)(MIN_OVRBUF - tmpbuffer * 16L));
|
||||
exit (-1);
|
||||
} else {
|
||||
if (appFail) {
|
||||
printf("NetHack fits in memory, but it cannot allocate memory");
|
||||
printf(" for the overlay buffer\nand the runtime functions. ");
|
||||
printf("Please free up just %ld more bytes.",
|
||||
(long) (MIN_OVRBUF - tmpbuffer * 16L));
|
||||
exit(-1);
|
||||
} else {
|
||||
/* Now try to use expanded memory for the overlay manager */
|
||||
/* If that doesn't work, we revert to extended memory */
|
||||
|
||||
/* Now try to use expanded memory for the overlay manager */
|
||||
/* If that doesn't work, we revert to extended memory */
|
||||
|
||||
emsstatus = _OvrInitEms (0, 0, 0);
|
||||
emsstatus = _OvrInitEms(0, 0, 0);
|
||||
#ifdef RECOGNIZE_XMS
|
||||
xmsstatus = (emsstatus) ? _OvrInitExt (0, 0) : -1;
|
||||
xmsstatus = (emsstatus) ? _OvrInitExt(0, 0) : -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
show_borlandc_stats(win)
|
||||
winid win;
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ];
|
||||
|
||||
putstr(win, 0, "");
|
||||
putstr(win, 0, "");
|
||||
putstr(win, 0, "Memory usage stats"); putstr(win, 0, "");
|
||||
putstr(win, 0, "");
|
||||
Sprintf (buf, "Overlay buffer memory allocation: %ld bytes.",
|
||||
memAlloc * 16L); putstr(win, 0, buf);
|
||||
Sprintf (buf, "_ovrbuffer = %u.", _ovrbuffer); putstr(win, 0, buf);
|
||||
Sprintf (buf, "Startup memory usage: 0x%X", ProgramSize);
|
||||
putstr(win, 0, buf);
|
||||
runAlloc = * (unsigned far *) MK_FP( _psp - 1, 0x03);
|
||||
Sprintf (buf, "Current memory usage: 0x%X", runAlloc);
|
||||
putstr(win, 0, buf);
|
||||
if (emsstatus) Sprintf (buf, "EMS search failed (%d).", emsstatus);
|
||||
else Sprintf (buf, "EMS search successful.");
|
||||
putstr(win, 0, buf);
|
||||
putstr(win, 0, "");
|
||||
putstr(win, 0, "");
|
||||
putstr(win, 0, "Memory usage stats");
|
||||
putstr(win, 0, "");
|
||||
putstr(win, 0, "");
|
||||
Sprintf(buf, "Overlay buffer memory allocation: %ld bytes.",
|
||||
memAlloc * 16L);
|
||||
putstr(win, 0, buf);
|
||||
Sprintf(buf, "_ovrbuffer = %u.", _ovrbuffer);
|
||||
putstr(win, 0, buf);
|
||||
Sprintf(buf, "Startup memory usage: 0x%X", ProgramSize);
|
||||
putstr(win, 0, buf);
|
||||
runAlloc = *(unsigned far *) MK_FP(_psp - 1, 0x03);
|
||||
Sprintf(buf, "Current memory usage: 0x%X", runAlloc);
|
||||
putstr(win, 0, buf);
|
||||
if (emsstatus)
|
||||
Sprintf(buf, "EMS search failed (%d).", emsstatus);
|
||||
else
|
||||
Sprintf(buf, "EMS search successful.");
|
||||
putstr(win, 0, buf);
|
||||
#ifdef RECOGNIZE_XMS
|
||||
if (xmsstatus) Sprintf (buf, "XMS search failed (%d).", xmsstatus);
|
||||
else Sprintf (buf, "XMS search successful.");
|
||||
putstr(win, 0, buf);
|
||||
if (xmsstatus)
|
||||
Sprintf(buf, "XMS search failed (%d).", xmsstatus);
|
||||
else
|
||||
Sprintf(buf, "XMS search successful.");
|
||||
putstr(win, 0, buf);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* #ifdef RESIZE_OVL */
|
||||
#endif /* #ifdef RESIZE_OVL */
|
||||
#endif /* #ifdef __BORLANDC__ */
|
||||
|
||||
/*ovlinit.c*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 pckeys.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 pckeys.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
|
||||
/* NetHack 3.6 pckeys.c $Date: 2009/05/06 10:49:39 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)pckeys.c 3.5 1996/05/11 */
|
||||
/* Copyright (c) NetHack PC Development Team 1996 */
|
||||
@@ -11,18 +11,18 @@
|
||||
#include "hack.h"
|
||||
|
||||
#ifdef MSDOS
|
||||
# ifdef USE_TILES
|
||||
#include "wintty.h"
|
||||
#ifdef USE_TILES
|
||||
#include "wintty.h"
|
||||
#include "pcvideo.h"
|
||||
|
||||
boolean FDECL(pckeys, (unsigned char, unsigned char));
|
||||
|
||||
extern struct WinDesc *wins[MAXWIN]; /* from wintty.c */
|
||||
extern boolean inmap; /* from video.c */
|
||||
extern struct WinDesc *wins[MAXWIN]; /* from wintty.c */
|
||||
extern boolean inmap; /* from video.c */
|
||||
|
||||
#define SHIFT (0x1 | 0x2)
|
||||
#define CTRL 0x4
|
||||
#define ALT 0x8
|
||||
#define SHIFT (0x1 | 0x2)
|
||||
#define CTRL 0x4
|
||||
#define ALT 0x8
|
||||
|
||||
/*
|
||||
* Check for special interface manipulation keys.
|
||||
@@ -34,49 +34,48 @@ pckeys(scancode, shift)
|
||||
unsigned char scancode;
|
||||
unsigned char shift;
|
||||
{
|
||||
boolean opening_dialog;
|
||||
boolean opening_dialog;
|
||||
|
||||
opening_dialog = pl_character[0] ? FALSE : TRUE;
|
||||
# ifdef SIMULATE_CURSOR
|
||||
switch(scancode) {
|
||||
case 0x3d: /* F3 = toggle cursor type */
|
||||
HideCursor();
|
||||
cursor_type += 1;
|
||||
if (cursor_type >= NUM_CURSOR_TYPES) cursor_type = 0;
|
||||
DrawCursor();
|
||||
break;
|
||||
# endif
|
||||
case 0x74: /* Control-right_arrow = scroll horizontal to right */
|
||||
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
|
||||
vga_userpan(1);
|
||||
break;
|
||||
opening_dialog = pl_character[0] ? FALSE : TRUE;
|
||||
#ifdef SIMULATE_CURSOR
|
||||
switch (scancode) {
|
||||
case 0x3d: /* F3 = toggle cursor type */
|
||||
HideCursor();
|
||||
cursor_type += 1;
|
||||
if (cursor_type >= NUM_CURSOR_TYPES)
|
||||
cursor_type = 0;
|
||||
DrawCursor();
|
||||
break;
|
||||
#endif
|
||||
case 0x74: /* Control-right_arrow = scroll horizontal to right */
|
||||
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
|
||||
vga_userpan(1);
|
||||
break;
|
||||
|
||||
case 0x73: /* Control-left_arrow = scroll horizontal to left */
|
||||
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
|
||||
vga_userpan(0);
|
||||
break;
|
||||
case 0x3E: /* F4 = toggle overview mode */
|
||||
if (iflags.tile_view && !opening_dialog
|
||||
&& !Is_rogue_level(&u.uz)) {
|
||||
iflags.traditional_view = FALSE;
|
||||
vga_overview(iflags.over_view ? FALSE : TRUE);
|
||||
vga_refresh();
|
||||
}
|
||||
break;
|
||||
case 0x3F: /* F5 = toggle traditional mode */
|
||||
if (iflags.tile_view && !opening_dialog
|
||||
&& !Is_rogue_level(&u.uz)) {
|
||||
iflags.over_view = FALSE;
|
||||
vga_traditional(iflags.traditional_view ? FALSE : TRUE);
|
||||
vga_refresh();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
case 0x73: /* Control-left_arrow = scroll horizontal to left */
|
||||
if ((shift & CTRL) && iflags.tile_view && !opening_dialog)
|
||||
vga_userpan(0);
|
||||
break;
|
||||
case 0x3E: /* F4 = toggle overview mode */
|
||||
if (iflags.tile_view && !opening_dialog && !Is_rogue_level(&u.uz)) {
|
||||
iflags.traditional_view = FALSE;
|
||||
vga_overview(iflags.over_view ? FALSE : TRUE);
|
||||
vga_refresh();
|
||||
}
|
||||
break;
|
||||
case 0x3F: /* F5 = toggle traditional mode */
|
||||
if (iflags.tile_view && !opening_dialog && !Is_rogue_level(&u.uz)) {
|
||||
iflags.over_view = FALSE;
|
||||
vga_traditional(iflags.traditional_view ? FALSE : TRUE);
|
||||
vga_refresh();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
# endif /* USE_TILES */
|
||||
#endif /* USE_TILES */
|
||||
#endif /* MSDOS */
|
||||
|
||||
/*pckeys.c*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 pctiles.c $NHDT-Date: 1425319883 2015/03/02 18:11:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
|
||||
/* NetHack 3.6 pctiles.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
|
||||
/* NetHack 3.6 pctiles.c $Date: 2009/05/06 10:49:39 $ $Revision: 1.5 $ */
|
||||
/* SCCS Id: @(#)pctiles.c 3.5 1995/07/31 */
|
||||
/* Copyright (c) NetHack PC Development Team 1993, 1994 */
|
||||
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/*
|
||||
* pctiles.c - PC Graphical Tile Support Routines
|
||||
*
|
||||
*
|
||||
*Edit History:
|
||||
* Initial Creation M. Allison 93/10/30
|
||||
*
|
||||
@@ -18,18 +18,18 @@
|
||||
|
||||
#if defined(__GO32__) || defined(__DJGPP__)
|
||||
#include <unistd.h>
|
||||
#define TILES_IN_RAM /* allow tiles to be read into ram */
|
||||
#define TILES_IN_RAM /* allow tiles to be read into ram */
|
||||
#endif
|
||||
|
||||
# if defined(_MSC_VER)
|
||||
# if _MSC_VER >= 700
|
||||
#pragma warning(disable:4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#pragma warning(disable:4131) /* old style declarator */
|
||||
#pragma warning(disable:4309) /* initializing */
|
||||
# endif
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER >= 700
|
||||
#pragma warning(disable : 4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable : 4127) /* conditional expression is constant */
|
||||
#pragma warning(disable : 4131) /* old style declarator */
|
||||
#pragma warning(disable : 4309) /* initializing */
|
||||
#endif
|
||||
#include <conio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "pcvideo.h"
|
||||
#include "tile.h"
|
||||
@@ -37,14 +37,14 @@
|
||||
|
||||
STATIC_VAR FILE *tilefile;
|
||||
STATIC_VAR FILE *tilefile_O;
|
||||
extern short glyph2tile[]; /* in tile.c (made from tilemap.c) */
|
||||
extern short glyph2tile[]; /* in tile.c (made from tilemap.c) */
|
||||
|
||||
#ifdef TILES_IN_RAM
|
||||
struct planar_cell_struct *ramtiles;
|
||||
struct overview_planar_cell_struct *oramtiles;
|
||||
boolean tiles_in_ram = FALSE;
|
||||
boolean otiles_in_ram = FALSE;
|
||||
extern int total_tiles_used; /* tile.c */
|
||||
extern int total_tiles_used; /* tile.c */
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -55,19 +55,20 @@ extern int total_tiles_used; /* tile.c */
|
||||
* at the start of the file, including a palette.
|
||||
*
|
||||
*/
|
||||
int ReadTileFileHeader(tibhdr, filestyle)
|
||||
int
|
||||
ReadTileFileHeader(tibhdr, filestyle)
|
||||
struct tibhdr_struct *tibhdr;
|
||||
boolean filestyle;
|
||||
{
|
||||
FILE *x;
|
||||
x = filestyle ? tilefile_O : tilefile;
|
||||
if (fseek(x,0L,SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(tibhdr, sizeof(struct tibhdr_struct), 1, x);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
FILE *x;
|
||||
x = filestyle ? tilefile_O : tilefile;
|
||||
if (fseek(x, 0L, SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(tibhdr, sizeof(struct tibhdr_struct), 1, x);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the requested tile file.
|
||||
@@ -91,74 +92,80 @@ char *tilefilename;
|
||||
boolean filestyle;
|
||||
{
|
||||
#ifdef TILES_IN_RAM
|
||||
int k;
|
||||
int k;
|
||||
#endif
|
||||
if (filestyle) {
|
||||
tilefile_O = fopen(tilefilename,"rb");
|
||||
if (tilefile_O == (FILE *)0) return 1;
|
||||
} else {
|
||||
tilefile = fopen(tilefilename,"rb");
|
||||
if (tilefile == (FILE *)0) return 1;
|
||||
}
|
||||
if (filestyle) {
|
||||
tilefile_O = fopen(tilefilename, "rb");
|
||||
if (tilefile_O == (FILE *) 0)
|
||||
return 1;
|
||||
} else {
|
||||
tilefile = fopen(tilefilename, "rb");
|
||||
if (tilefile == (FILE *) 0)
|
||||
return 1;
|
||||
}
|
||||
#ifdef TILES_IN_RAM
|
||||
if (iflags.preload_tiles) {
|
||||
if (filestyle) {
|
||||
struct overview_planar_cell_struct *gp;
|
||||
long ram_needed = sizeof(struct overview_planar_cell_struct) *
|
||||
total_tiles_used;
|
||||
if (fseek(tilefile_O,(long)TIBHEADER_SIZE, SEEK_SET)) { /*failure*/
|
||||
}
|
||||
oramtiles = (struct overview_planar_cell_struct *)alloc(ram_needed);
|
||||
/* Todo: fall back to file method here if alloc failed */
|
||||
gp = oramtiles;
|
||||
for(k=0; k < total_tiles_used; ++k) {
|
||||
fread(gp, sizeof(struct overview_planar_cell_struct),
|
||||
1, tilefile_O);
|
||||
++gp;
|
||||
}
|
||||
if (filestyle) {
|
||||
struct overview_planar_cell_struct *gp;
|
||||
long ram_needed =
|
||||
sizeof(struct overview_planar_cell_struct) * total_tiles_used;
|
||||
if (fseek(tilefile_O, (long) TIBHEADER_SIZE,
|
||||
SEEK_SET)) { /*failure*/
|
||||
}
|
||||
oramtiles =
|
||||
(struct overview_planar_cell_struct *) alloc(ram_needed);
|
||||
/* Todo: fall back to file method here if alloc failed */
|
||||
gp = oramtiles;
|
||||
for (k = 0; k < total_tiles_used; ++k) {
|
||||
fread(gp, sizeof(struct overview_planar_cell_struct), 1,
|
||||
tilefile_O);
|
||||
++gp;
|
||||
}
|
||||
#ifdef DEBUG_RAMTILES
|
||||
pline("%d overview tiles read into ram.", k);
|
||||
mark_synch();
|
||||
pline("%d overview tiles read into ram.", k);
|
||||
mark_synch();
|
||||
#endif
|
||||
otiles_in_ram = TRUE;
|
||||
} else {
|
||||
struct planar_cell_struct *gp;
|
||||
long ram_needed = sizeof(struct planar_cell_struct) *
|
||||
total_tiles_used;
|
||||
if (fseek(tilefile,(long)TIBHEADER_SIZE, SEEK_SET)) { /*failure*/
|
||||
}
|
||||
ramtiles = (struct planar_cell_struct *)alloc(ram_needed);
|
||||
/* Todo: fall back to file method here if alloc failed */
|
||||
gp = ramtiles;
|
||||
for(k=0; k < total_tiles_used; ++k) {
|
||||
fread(gp, sizeof(struct planar_cell_struct),
|
||||
1, tilefile);
|
||||
++gp;
|
||||
}
|
||||
otiles_in_ram = TRUE;
|
||||
} else {
|
||||
struct planar_cell_struct *gp;
|
||||
long ram_needed =
|
||||
sizeof(struct planar_cell_struct) * total_tiles_used;
|
||||
if (fseek(tilefile, (long) TIBHEADER_SIZE,
|
||||
SEEK_SET)) { /*failure*/
|
||||
}
|
||||
ramtiles = (struct planar_cell_struct *) alloc(ram_needed);
|
||||
/* Todo: fall back to file method here if alloc failed */
|
||||
gp = ramtiles;
|
||||
for (k = 0; k < total_tiles_used; ++k) {
|
||||
fread(gp, sizeof(struct planar_cell_struct), 1, tilefile);
|
||||
++gp;
|
||||
}
|
||||
#ifdef DEBUG_RAMTILES
|
||||
pline("%d tiles read into ram.", k);
|
||||
mark_synch();
|
||||
pline("%d tiles read into ram.", k);
|
||||
mark_synch();
|
||||
#endif
|
||||
tiles_in_ram = TRUE;
|
||||
}
|
||||
tiles_in_ram = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CloseTileFile(filestyle)
|
||||
boolean filestyle;
|
||||
{
|
||||
fclose(filestyle ? tilefile_O : tilefile);
|
||||
fclose(filestyle ? tilefile_O : tilefile);
|
||||
#ifdef TILES_IN_RAM
|
||||
if (!filestyle && tiles_in_ram) {
|
||||
if (ramtiles) free((genericptr_t) ramtiles);
|
||||
tiles_in_ram = FALSE;
|
||||
} else if (filestyle && otiles_in_ram) {
|
||||
if (oramtiles) free((genericptr_t) oramtiles);
|
||||
otiles_in_ram = FALSE;
|
||||
}
|
||||
if (!filestyle && tiles_in_ram) {
|
||||
if (ramtiles)
|
||||
free((genericptr_t) ramtiles);
|
||||
tiles_in_ram = FALSE;
|
||||
} else if (filestyle && otiles_in_ram) {
|
||||
if (oramtiles)
|
||||
free((genericptr_t) oramtiles);
|
||||
otiles_in_ram = FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -184,72 +191,75 @@ struct overview_planar_cell_struct oplancell;
|
||||
* increasing the memory requirement - can't have everything).
|
||||
*
|
||||
*/
|
||||
# ifdef PLANAR_FILE
|
||||
int ReadPlanarTileFile(tilenum,gp)
|
||||
#ifdef PLANAR_FILE
|
||||
int
|
||||
ReadPlanarTileFile(tilenum, gp)
|
||||
int tilenum;
|
||||
struct planar_cell_struct **gp;
|
||||
{
|
||||
long fpos;
|
||||
long fpos;
|
||||
|
||||
#ifdef TILES_IN_RAM
|
||||
if (tiles_in_ram) {
|
||||
*gp = ramtiles + tilenum;
|
||||
return 0;
|
||||
}
|
||||
if (tiles_in_ram) {
|
||||
*gp = ramtiles + tilenum;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
fpos = ((long)(tilenum) * (long)sizeof(struct planar_cell_struct)) +
|
||||
(long)TIBHEADER_SIZE;
|
||||
if (fseek(tilefile,fpos,SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(&plancell, sizeof(struct planar_cell_struct), 1, tilefile);
|
||||
}
|
||||
*gp = &plancell;
|
||||
return 0;
|
||||
fpos = ((long) (tilenum) * (long) sizeof(struct planar_cell_struct))
|
||||
+ (long) TIBHEADER_SIZE;
|
||||
if (fseek(tilefile, fpos, SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(&plancell, sizeof(struct planar_cell_struct), 1, tilefile);
|
||||
}
|
||||
*gp = &plancell;
|
||||
return 0;
|
||||
}
|
||||
int ReadPlanarTileFile_O(tilenum,gp)
|
||||
int
|
||||
ReadPlanarTileFile_O(tilenum, gp)
|
||||
int tilenum;
|
||||
struct overview_planar_cell_struct **gp;
|
||||
{
|
||||
long fpos;
|
||||
long fpos;
|
||||
|
||||
#ifdef TILES_IN_RAM
|
||||
if (otiles_in_ram) {
|
||||
*gp = oramtiles + tilenum;
|
||||
return 0;
|
||||
}
|
||||
if (otiles_in_ram) {
|
||||
*gp = oramtiles + tilenum;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
fpos = ((long)(tilenum) *
|
||||
(long)sizeof(struct overview_planar_cell_struct)) +
|
||||
(long)TIBHEADER_SIZE;
|
||||
if (fseek(tilefile_O,fpos,SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(&oplancell, sizeof(struct overview_planar_cell_struct),
|
||||
1, tilefile_O);
|
||||
}
|
||||
*gp = &oplancell;
|
||||
return 0;
|
||||
fpos =
|
||||
((long) (tilenum) * (long) sizeof(struct overview_planar_cell_struct))
|
||||
+ (long) TIBHEADER_SIZE;
|
||||
if (fseek(tilefile_O, fpos, SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(&oplancell, sizeof(struct overview_planar_cell_struct), 1,
|
||||
tilefile_O);
|
||||
}
|
||||
*gp = &oplancell;
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# ifdef PACKED_FILE
|
||||
int ReadPackedTileFile(tilenum,pta)
|
||||
#ifdef PACKED_FILE
|
||||
int
|
||||
ReadPackedTileFile(tilenum, pta)
|
||||
int tilenum;
|
||||
char (*pta)[TILE_X];
|
||||
{
|
||||
long fpos;
|
||||
|
||||
fpos = ((long)(tilenum) * (long)(TILE_Y * TILE_X) +
|
||||
(long)TIBHEADER_SIZE);
|
||||
if (fseek(tilefile,fpos,SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(pta, (TILE_Y * TILE_X), 1, tilefile);
|
||||
}
|
||||
return 0;
|
||||
long fpos;
|
||||
|
||||
fpos =
|
||||
((long) (tilenum) * (long) (TILE_Y * TILE_X) + (long) TIBHEADER_SIZE);
|
||||
if (fseek(tilefile, fpos, SEEK_SET)) {
|
||||
return 1;
|
||||
} else {
|
||||
fread(pta, (TILE_Y * TILE_X), 1, tilefile);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif /* USE_TILES */
|
||||
|
||||
/* pctiles.c */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 sound.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 sound.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 sound.c $Date: 2009/05/06 10:49:43 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)sound.c 3.5 1996/02/19 */
|
||||
/* Copyright (c) NetHack PC Development Team 1993,1995 */
|
||||
@@ -23,40 +23,40 @@
|
||||
|
||||
#ifndef TESTING
|
||||
|
||||
#define printf pline
|
||||
#define printf pline
|
||||
|
||||
int
|
||||
assign_soundcard(sopt)
|
||||
char *sopt;
|
||||
{
|
||||
iflags.hassound = 0;
|
||||
#ifdef PCMUSIC
|
||||
iflags.usepcspeaker = 0;
|
||||
#endif
|
||||
|
||||
iflags.hassound = 0;
|
||||
# ifdef PCMUSIC
|
||||
iflags.usepcspeaker = 0;
|
||||
# endif
|
||||
|
||||
if (strncmpi(sopt,"def",3) == 0) { /* default */
|
||||
/* do nothing - default */
|
||||
}
|
||||
# ifdef PCMUSIC
|
||||
else if (strncmpi(sopt,"speaker",7) == 0) { /* pc speaker */
|
||||
iflags.usepcspeaker = 1;
|
||||
}
|
||||
# endif
|
||||
else if (strncmpi(sopt,"auto",4) == 0) { /* autodetect */
|
||||
/*
|
||||
* Auto-detect Priorities (arbitrary for now):
|
||||
* Just pcspeaker
|
||||
*/
|
||||
if (0) ;
|
||||
# ifdef PCMUSIC
|
||||
else iflags.usepcspeaker = 1;
|
||||
# endif
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
if (strncmpi(sopt, "def", 3) == 0) { /* default */
|
||||
/* do nothing - default */
|
||||
}
|
||||
#ifdef PCMUSIC
|
||||
else if (strncmpi(sopt, "speaker", 7) == 0) { /* pc speaker */
|
||||
iflags.usepcspeaker = 1;
|
||||
}
|
||||
#endif
|
||||
else if (strncmpi(sopt, "auto", 4) == 0) { /* autodetect */
|
||||
/*
|
||||
* Auto-detect Priorities (arbitrary for now):
|
||||
* Just pcspeaker
|
||||
*/
|
||||
if (0)
|
||||
;
|
||||
#ifdef PCMUSIC
|
||||
else
|
||||
iflags.usepcspeaker = 1;
|
||||
#endif
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -64,78 +64,80 @@ char *sopt;
|
||||
|
||||
/* 8254/3 Control Word Defines */
|
||||
|
||||
#define CTR0SEL (0<<6)
|
||||
#define CTR1SEL (1<<6)
|
||||
#define CTR2SEL (2<<6)
|
||||
#define RDBACK (3<<6)
|
||||
#define CTR0SEL (0 << 6)
|
||||
#define CTR1SEL (1 << 6)
|
||||
#define CTR2SEL (2 << 6)
|
||||
#define RDBACK (3 << 6)
|
||||
|
||||
#define LATCH (0<<4)
|
||||
#define RW_LSB (1<<4)
|
||||
#define RW_MSB (2<<4) /* If both LSB and MSB are read, LSB is done first */
|
||||
#define LATCH (0 << 4)
|
||||
#define RW_LSB (1 << 4)
|
||||
#define RW_MSB (2 << 4) /* If both LSB and MSB are read, LSB is done first \
|
||||
*/
|
||||
|
||||
#define MODE0 (0<<1) /* Interrupt on terminal count */
|
||||
#define MODE1 (1<<1) /* Hardware One-Shot */
|
||||
#define MODE2 (2<<1) /* Pulse Generator */
|
||||
#define MODE3 (3<<1) /* Square Wave Generator */
|
||||
#define MODE4 (4<<1) /* Software Triggered Strobe */
|
||||
#define MODE5 (5<<1) /* Hardware Triggered Strobe */
|
||||
#define MODE0 (0 << 1) /* Interrupt on terminal count */
|
||||
#define MODE1 (1 << 1) /* Hardware One-Shot */
|
||||
#define MODE2 (2 << 1) /* Pulse Generator */
|
||||
#define MODE3 (3 << 1) /* Square Wave Generator */
|
||||
#define MODE4 (4 << 1) /* Software Triggered Strobe */
|
||||
#define MODE5 (5 << 1) /* Hardware Triggered Strobe */
|
||||
|
||||
#define BINARY (0<<0) /* Binary counter (16 bits) */
|
||||
#define BCD (1<<0) /* Binary Coded Decimal (BCD) Counter (4 Decades) */
|
||||
#define BINARY (0 << 0) /* Binary counter (16 bits) */
|
||||
#define BCD (1 << 0) /* Binary Coded Decimal (BCD) Counter (4 Decades) */
|
||||
|
||||
/* Misc 8254/3 Defines */
|
||||
|
||||
#define TIMRFRQ (1193180UL) /* Input frequency to the clock (Hz) */
|
||||
#define TIMRFRQ (1193180UL) /* Input frequency to the clock (Hz) */
|
||||
|
||||
/* Speaker Defines */
|
||||
|
||||
#define TIMER (1<<0) /* Timer 2 Output connected to Speaker */
|
||||
#define SPKR_ON (1<<1) /* Turn on/off Speaker */
|
||||
#define TIMER (1 << 0) /* Timer 2 Output connected to Speaker */
|
||||
#define SPKR_ON (1 << 1) /* Turn on/off Speaker */
|
||||
|
||||
/* Port Definitions */
|
||||
|
||||
/* 8254/3 Ports */
|
||||
|
||||
#define CTR0 0x40
|
||||
#define CTR1 0x41
|
||||
#define CTR2 0x42
|
||||
#define CTRL 0x43
|
||||
#define CTR0 0x40
|
||||
#define CTR1 0x41
|
||||
#define CTR2 0x42
|
||||
#define CTRL 0x43
|
||||
|
||||
/* Speaker Port */
|
||||
|
||||
#define SPEAKER 0x61
|
||||
#define SPEAKER 0x61
|
||||
|
||||
void
|
||||
startsound (unsigned freq)
|
||||
startsound(unsigned freq)
|
||||
{
|
||||
/* To start a sound on the PC:
|
||||
*
|
||||
* First, set the second counter to have the correct frequency:
|
||||
*/
|
||||
/* To start a sound on the PC:
|
||||
*
|
||||
* First, set the second counter to have the correct frequency:
|
||||
*/
|
||||
|
||||
unsigned count;
|
||||
unsigned count;
|
||||
|
||||
if (freq == 0) freq = 523;
|
||||
if (freq == 0)
|
||||
freq = 523;
|
||||
|
||||
count = TIMRFRQ / freq; /* Divide frequencies to get count. */
|
||||
count = TIMRFRQ / freq; /* Divide frequencies to get count. */
|
||||
|
||||
#ifdef TESTING
|
||||
printf ("freq = %u, count = %u\n", freq, count);
|
||||
printf("freq = %u, count = %u\n", freq, count);
|
||||
#endif
|
||||
|
||||
outportb (CTRL, CTR2SEL|RW_LSB|RW_MSB|MODE3|BINARY);
|
||||
outportb (CTR2, count & 0x0FF);
|
||||
outportb (CTR2, count / 0x100);
|
||||
outportb(CTRL, CTR2SEL | RW_LSB | RW_MSB | MODE3 | BINARY);
|
||||
outportb(CTR2, count & 0x0FF);
|
||||
outportb(CTR2, count / 0x100);
|
||||
|
||||
/* Next, turn on the speaker */
|
||||
/* Next, turn on the speaker */
|
||||
|
||||
outportb (SPEAKER, inportb(SPEAKER)|TIMER|SPKR_ON);
|
||||
outportb(SPEAKER, inportb(SPEAKER) | TIMER | SPKR_ON);
|
||||
}
|
||||
|
||||
void
|
||||
stopsound (void)
|
||||
stopsound(void)
|
||||
{
|
||||
outportb (SPEAKER, inportb(SPEAKER) & ~(TIMER|SPKR_ON));
|
||||
outportb(SPEAKER, inportb(SPEAKER) & ~(TIMER | SPKR_ON));
|
||||
}
|
||||
|
||||
static unsigned tempo, length, octave, mtype;
|
||||
@@ -154,97 +156,117 @@ static unsigned tempo, length, octave, mtype;
|
||||
* number.
|
||||
*/
|
||||
|
||||
unsigned long notefactors[12] = { 483852, 456695, 431063, 406869, 384033,
|
||||
362479, 342135, 322932, 304808, 287700, 271553, 256312 };
|
||||
unsigned long notefactors[12] = { 483852, 456695, 431063, 406869,
|
||||
384033, 362479, 342135, 322932,
|
||||
304808, 287700, 271553, 256312 };
|
||||
|
||||
void
|
||||
note (long notenum)
|
||||
note(long notenum)
|
||||
{
|
||||
startsound ((unsigned) (4050816000UL / notefactors[notenum % 12]
|
||||
>> (7 - notenum / 12)));
|
||||
startsound((unsigned) (4050816000UL / notefactors[notenum % 12]
|
||||
>> (7 - notenum / 12)));
|
||||
}
|
||||
|
||||
int notes[7] = { 9, 11, 0, 2, 4, 5, 7 };
|
||||
|
||||
char *
|
||||
startnote (char *c)
|
||||
startnote(char *c)
|
||||
{
|
||||
long n;
|
||||
long n;
|
||||
|
||||
n = notes[toupper(*c++) - 'A'] + octave * 12;
|
||||
if (*c == '#' || *c == '+') { n++; c++; }
|
||||
else if (*c == '-') { if (n) n--; c++; }
|
||||
n = notes[toupper(*c++) - 'A'] + octave * 12;
|
||||
if (*c == '#' || *c == '+') {
|
||||
n++;
|
||||
c++;
|
||||
} else if (*c == '-') {
|
||||
if (n)
|
||||
n--;
|
||||
c++;
|
||||
}
|
||||
|
||||
note (n);
|
||||
note(n);
|
||||
|
||||
return --c;
|
||||
return --c;
|
||||
}
|
||||
|
||||
void
|
||||
delaytime (unsigned time)
|
||||
delaytime(unsigned time)
|
||||
{
|
||||
/* time and twait are in units of milliseconds */
|
||||
/* time and twait are in units of milliseconds */
|
||||
|
||||
unsigned twait;
|
||||
unsigned twait;
|
||||
|
||||
switch (toupper (mtype)) {
|
||||
case 'S': twait = time / 4; break;
|
||||
case 'L': twait = 0; break;
|
||||
default: twait = time / 8; break;
|
||||
}
|
||||
switch (toupper(mtype)) {
|
||||
case 'S':
|
||||
twait = time / 4;
|
||||
break;
|
||||
case 'L':
|
||||
twait = 0;
|
||||
break;
|
||||
default:
|
||||
twait = time / 8;
|
||||
break;
|
||||
}
|
||||
|
||||
msleep (time - twait);
|
||||
stopsound ();
|
||||
msleep (twait);
|
||||
msleep(time - twait);
|
||||
stopsound();
|
||||
msleep(twait);
|
||||
}
|
||||
|
||||
char *
|
||||
delaynote (char *c)
|
||||
delaynote(char *c)
|
||||
{
|
||||
unsigned time = 0;
|
||||
unsigned time = 0;
|
||||
|
||||
while (isdigit(*c)) time = time * 10 + (*c++ - '0');
|
||||
while (isdigit(*c))
|
||||
time = time * 10 + (*c++ - '0');
|
||||
|
||||
if (!time) time = length;
|
||||
if (!time)
|
||||
time = length;
|
||||
|
||||
time = (unsigned)(240000 / time / tempo);
|
||||
time = (unsigned) (240000 / time / tempo);
|
||||
|
||||
while (*c == '.') { time = time * 3 / 2; c++; }
|
||||
while (*c == '.') {
|
||||
time = time * 3 / 2;
|
||||
c++;
|
||||
}
|
||||
|
||||
delaytime (time);
|
||||
delaytime(time);
|
||||
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
initspeaker (void)
|
||||
initspeaker(void)
|
||||
{
|
||||
tempo = 120, length = 4, octave = 3, mtype = 'N';
|
||||
tempo = 120, length = 4, octave = 3, mtype = 'N';
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
play (char *tune)
|
||||
play(char *tune)
|
||||
{
|
||||
char *c, *n;
|
||||
unsigned num;
|
||||
char *c, *n;
|
||||
unsigned num;
|
||||
|
||||
for (c = tune; *c; ) {
|
||||
sscanf (c + 1, "%u", &num);
|
||||
for (n = c + 1; isdigit(*n); n++) /* do nothing */;
|
||||
if (isspace(*c)) c++;
|
||||
else switch (toupper(*c)) {
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
c = startnote (c);
|
||||
case 'P':
|
||||
c = delaynote (++c);
|
||||
break;
|
||||
for (c = tune; *c;) {
|
||||
sscanf(c + 1, "%u", &num);
|
||||
for (n = c + 1; isdigit(*n); n++) /* do nothing */
|
||||
;
|
||||
if (isspace(*c))
|
||||
c++;
|
||||
else
|
||||
switch (toupper(*c)) {
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
c = startnote(c);
|
||||
case 'P':
|
||||
c = delaynote(++c);
|
||||
break;
|
||||
#if 0
|
||||
case 'M': c++; mtype = *c; c++; break;
|
||||
case 'T':
|
||||
@@ -270,62 +292,72 @@ play (char *tune)
|
||||
case '>': if (octave < 7) octave++; c++; break;
|
||||
case '<': if (octave) octave--; c++; break;
|
||||
#endif
|
||||
case ' ': c++; break;
|
||||
default:
|
||||
printf ("Unrecognized play value (%s)!\n", c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case ' ':
|
||||
c++;
|
||||
break;
|
||||
default:
|
||||
printf("Unrecognized play value (%s)!\n", c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TESTING
|
||||
void
|
||||
pc_speaker (struct obj *instr, char *tune)
|
||||
pc_speaker(struct obj *instr, char *tune)
|
||||
{
|
||||
if (!iflags.usepcspeaker) return;
|
||||
initspeaker ();
|
||||
switch (instr->otyp)
|
||||
{
|
||||
case WOODEN_FLUTE:
|
||||
case MAGIC_FLUTE:
|
||||
octave = 5; /* up one octave */
|
||||
break;
|
||||
case TOOLED_HORN:
|
||||
case FROST_HORN:
|
||||
case FIRE_HORN:
|
||||
octave = 2; /* drop two octaves */
|
||||
break;
|
||||
case BUGLE:
|
||||
break;
|
||||
case WOODEN_HARP:
|
||||
case MAGIC_HARP:
|
||||
length = 8;
|
||||
mtype = 'L'; /* fast, legato */
|
||||
break;
|
||||
if (!iflags.usepcspeaker)
|
||||
return;
|
||||
initspeaker();
|
||||
switch (instr->otyp) {
|
||||
case WOODEN_FLUTE:
|
||||
case MAGIC_FLUTE:
|
||||
octave = 5; /* up one octave */
|
||||
break;
|
||||
case TOOLED_HORN:
|
||||
case FROST_HORN:
|
||||
case FIRE_HORN:
|
||||
octave = 2; /* drop two octaves */
|
||||
break;
|
||||
case BUGLE:
|
||||
break;
|
||||
case WOODEN_HARP:
|
||||
case MAGIC_HARP:
|
||||
length = 8;
|
||||
mtype = 'L'; /* fast, legato */
|
||||
break;
|
||||
}
|
||||
play (tune);
|
||||
play(tune);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
main ()
|
||||
main()
|
||||
{
|
||||
char s[80];
|
||||
int tool;
|
||||
char s[80];
|
||||
int tool;
|
||||
|
||||
initspeaker();
|
||||
printf ("1) flute\n2) horn\n3) harp\n4) other\n");
|
||||
fgets (s, 80, stdin);
|
||||
sscanf (s, "%d", &tool);
|
||||
switch (tool) {
|
||||
case 1: octave = 5; break;
|
||||
case 2: octave = 2; break;
|
||||
case 3: length = 8; mtype = 'L'; break;
|
||||
default: break;
|
||||
}
|
||||
printf ("Enter tune:");
|
||||
fgets(s, 80, stdin);
|
||||
play (s);
|
||||
initspeaker();
|
||||
printf("1) flute\n2) horn\n3) harp\n4) other\n");
|
||||
fgets(s, 80, stdin);
|
||||
sscanf(s, "%d", &tool);
|
||||
switch (tool) {
|
||||
case 1:
|
||||
octave = 5;
|
||||
break;
|
||||
case 2:
|
||||
octave = 2;
|
||||
break;
|
||||
case 3:
|
||||
length = 8;
|
||||
mtype = 'L';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf("Enter tune:");
|
||||
fgets(s, 80, stdin);
|
||||
play(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 tile2bin.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 tile2bin.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
|
||||
/* NetHack 3.6 tile2bin.c $Date: 2009/05/06 10:49:47 $ $Revision: 1.4 $ */
|
||||
/* SCCS Id: @(#)tile2bin.c 3.5 1995/01/26 */
|
||||
/* Copyright (c) NetHack PC Development Team 1993, 1994, 1995 */
|
||||
@@ -14,7 +14,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hack.h"
|
||||
#include "pcvideo.h"
|
||||
#include "tile.h"
|
||||
@@ -31,10 +30,10 @@
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 700
|
||||
#pragma warning(disable:4309) /* initializing */
|
||||
#pragma warning(disable:4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable:4131) /* old style declarator */
|
||||
#pragma warning(disable:4127) /* conditional express. is constant */
|
||||
#pragma warning(disable : 4309) /* initializing */
|
||||
#pragma warning(disable : 4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable : 4131) /* old style declarator */
|
||||
#pragma warning(disable : 4127) /* conditional express. is constant */
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@@ -44,7 +43,7 @@ extern unsigned _stklen = STKSIZ;
|
||||
extern char *FDECL(tilename, (int, int));
|
||||
|
||||
#ifdef PLANAR_FILE
|
||||
char masktable[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
|
||||
char masktable[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
|
||||
char charcolors[MAXCOLORMAPSIZE];
|
||||
#ifdef OVERVIEW_FILE
|
||||
struct overview_planar_cell_struct planetile;
|
||||
@@ -65,16 +64,14 @@ struct tibhdr_struct tibheader;
|
||||
|
||||
static void FDECL(write_tibtile, (int));
|
||||
static void FDECL(write_tibheader, (FILE *, struct tibhdr_struct *));
|
||||
static void FDECL(build_tibtile, (pixel (*)[TILE_X]));
|
||||
static void FDECL(build_tibtile, (pixel(*) [TILE_X]));
|
||||
|
||||
#ifndef OVERVIEW_FILE
|
||||
char *tilefiles[] = { "../win/share/monsters.txt",
|
||||
"../win/share/objects.txt",
|
||||
"../win/share/other.txt"};
|
||||
char *tilefiles[] = { "../win/share/monsters.txt", "../win/share/objects.txt",
|
||||
"../win/share/other.txt" };
|
||||
#else
|
||||
char *tilefiles[] = { "../win/share/monthin.txt",
|
||||
"../win/share/objthin.txt",
|
||||
"../win/share/oththin.txt"};
|
||||
char *tilefiles[] = { "../win/share/monthin.txt", "../win/share/objthin.txt",
|
||||
"../win/share/oththin.txt" };
|
||||
#endif
|
||||
|
||||
int tilecount;
|
||||
@@ -86,229 +83,221 @@ main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int i;
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
char *paletteptr;
|
||||
int i;
|
||||
struct tm *newtime;
|
||||
time_t aclock;
|
||||
char *paletteptr;
|
||||
|
||||
if (argc != 1) {
|
||||
Fprintf(stderr, "usage: tile2bin (from the util directory)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (argc != 1) {
|
||||
Fprintf(stderr, "usage: tile2bin (from the util directory)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef PLANAR_FILE
|
||||
# ifndef OVERVIEW_FILE
|
||||
tibfile1 = fopen(NETHACK_PLANAR_TILEFILE, WRBMODE);
|
||||
# else
|
||||
tibfile1 = fopen(NETHACK_OVERVIEW_TILEFILE, WRBMODE);
|
||||
# endif
|
||||
if (tibfile1 == (FILE *)0) {
|
||||
Fprintf(stderr, "Unable to open output file %s\n",
|
||||
# ifndef OVERVIEW_FILE
|
||||
NETHACK_PLANAR_TILEFILE);
|
||||
#ifndef OVERVIEW_FILE
|
||||
tibfile1 = fopen(NETHACK_PLANAR_TILEFILE, WRBMODE);
|
||||
#else
|
||||
NETHACK_OVERVIEW_TILEFILE);
|
||||
tibfile1 = fopen(NETHACK_OVERVIEW_TILEFILE, WRBMODE);
|
||||
#endif
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (tibfile1 == (FILE *) 0) {
|
||||
Fprintf(stderr, "Unable to open output file %s\n",
|
||||
#ifndef OVERVIEW_FILE
|
||||
NETHACK_PLANAR_TILEFILE);
|
||||
#else
|
||||
NETHACK_OVERVIEW_TILEFILE);
|
||||
#endif
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PACKED_FILE
|
||||
tibfile2 = fopen(NETHACK_PACKED_TILEFILE, WRBMODE);
|
||||
if (tibfile2 == (FILE *)0) {
|
||||
Fprintf(stderr, "Unable to open output file %s\n",
|
||||
NETHACK_PACKED_TILEFILE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
tibfile2 = fopen(NETHACK_PACKED_TILEFILE, WRBMODE);
|
||||
if (tibfile2 == (FILE *) 0) {
|
||||
Fprintf(stderr, "Unable to open output file %s\n",
|
||||
NETHACK_PACKED_TILEFILE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
time(&aclock);
|
||||
newtime = localtime(&aclock);
|
||||
time(&aclock);
|
||||
newtime = localtime(&aclock);
|
||||
|
||||
tilecount = 0;
|
||||
paletteflag = 0;
|
||||
filenum = 0;
|
||||
while (filenum < 3) {
|
||||
if (!fopen_text_file(tilefiles[filenum], RDTMODE)) {
|
||||
Fprintf(stderr,
|
||||
"usage: tile2bin (from the util or src directory)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
num_colors = colorsinmap;
|
||||
if (num_colors > 62) {
|
||||
Fprintf(stderr, "too many colors (%d)\n", num_colors);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
tilecount = 0;
|
||||
paletteflag = 0;
|
||||
filenum = 0;
|
||||
while (filenum < 3) {
|
||||
if (!fopen_text_file(tilefiles[filenum], RDTMODE)) {
|
||||
Fprintf(stderr,
|
||||
"usage: tile2bin (from the util or src directory)\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
num_colors = colorsinmap;
|
||||
if (num_colors > 62) {
|
||||
Fprintf(stderr, "too many colors (%d)\n", num_colors);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!paletteflag) {
|
||||
paletteptr = tibheader.palette;
|
||||
for (i = 0; i < num_colors; i++) {
|
||||
*paletteptr++ = ColorMap[CM_RED][i],
|
||||
*paletteptr++ = ColorMap[CM_GREEN][i],
|
||||
*paletteptr++ = ColorMap[CM_BLUE][i];
|
||||
}
|
||||
paletteflag++;
|
||||
}
|
||||
if (!paletteflag) {
|
||||
paletteptr = tibheader.palette;
|
||||
for (i = 0; i < num_colors; i++) {
|
||||
*paletteptr++ = ColorMap[CM_RED][i],
|
||||
*paletteptr++ = ColorMap[CM_GREEN][i],
|
||||
*paletteptr++ = ColorMap[CM_BLUE][i];
|
||||
}
|
||||
paletteflag++;
|
||||
}
|
||||
|
||||
|
||||
while (read_text_tile(pixels)) {
|
||||
build_tibtile(pixels);
|
||||
write_tibtile(tilecount);
|
||||
tilecount++;
|
||||
}
|
||||
while (read_text_tile(pixels)) {
|
||||
build_tibtile(pixels);
|
||||
write_tibtile(tilecount);
|
||||
tilecount++;
|
||||
}
|
||||
|
||||
(void) fclose_text_file();
|
||||
++filenum;
|
||||
}
|
||||
(void) fclose_text_file();
|
||||
++filenum;
|
||||
}
|
||||
|
||||
# if defined(_MSC_VER)
|
||||
tibheader.compiler = MSC_COMP;
|
||||
# elif defined(__BORLANDC__)
|
||||
tibheader.compiler = BC_COMP;
|
||||
# elif defined(__GO32__)
|
||||
tibheader.compiler = DJGPP_COMP;
|
||||
# else
|
||||
tibheader.compiler = OTHER_COMP;
|
||||
# endif
|
||||
|
||||
strncpy(tibheader.ident,
|
||||
"NetHack 3.6 MSDOS Port binary tile file", 80);
|
||||
strncpy(tibheader.timestamp, asctime(newtime), 24);
|
||||
tibheader.timestamp[25] = '\0';
|
||||
tibheader.tilecount = tilecount;
|
||||
tibheader.numcolors = num_colors;
|
||||
# ifdef PLANAR_FILE
|
||||
tibheader.tilestyle = PLANAR_STYLE;
|
||||
write_tibheader(tibfile1, &tibheader);
|
||||
(void) fclose(tibfile1);
|
||||
# ifndef OVERVIEW_FILE
|
||||
Fprintf(stderr, "Total of %d planar tiles written to %s.\n",
|
||||
tilecount, NETHACK_PLANAR_TILEFILE);
|
||||
# else
|
||||
Fprintf(stderr, "Total of %d planar tiles written to %s.\n",
|
||||
tilecount, NETHACK_OVERVIEW_TILEFILE);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(_MSC_VER)
|
||||
tibheader.compiler = MSC_COMP;
|
||||
#elif defined(__BORLANDC__)
|
||||
tibheader.compiler = BC_COMP;
|
||||
#elif defined(__GO32__)
|
||||
tibheader.compiler = DJGPP_COMP;
|
||||
#else
|
||||
tibheader.compiler = OTHER_COMP;
|
||||
#endif
|
||||
|
||||
# ifdef PACKED_FILE
|
||||
tibheader.tilestyle = PACKED_STYLE;
|
||||
write_tibheader(tibfile2, &tibheader);
|
||||
Fprintf(stderr, "Total of %d packed tiles written to %s.\n",
|
||||
tilecount, NETHACK_PACKED_TILEFILE);
|
||||
(void) fclose(tibfile2);
|
||||
# endif
|
||||
strncpy(tibheader.ident, "NetHack 3.6 MSDOS Port binary tile file", 80);
|
||||
strncpy(tibheader.timestamp, asctime(newtime), 24);
|
||||
tibheader.timestamp[25] = '\0';
|
||||
tibheader.tilecount = tilecount;
|
||||
tibheader.numcolors = num_colors;
|
||||
#ifdef PLANAR_FILE
|
||||
tibheader.tilestyle = PLANAR_STYLE;
|
||||
write_tibheader(tibfile1, &tibheader);
|
||||
(void) fclose(tibfile1);
|
||||
#ifndef OVERVIEW_FILE
|
||||
Fprintf(stderr, "Total of %d planar tiles written to %s.\n", tilecount,
|
||||
NETHACK_PLANAR_TILEFILE);
|
||||
#else
|
||||
Fprintf(stderr, "Total of %d planar tiles written to %s.\n", tilecount,
|
||||
NETHACK_OVERVIEW_TILEFILE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
#ifdef PACKED_FILE
|
||||
tibheader.tilestyle = PACKED_STYLE;
|
||||
write_tibheader(tibfile2, &tibheader);
|
||||
Fprintf(stderr, "Total of %d packed tiles written to %s.\n", tilecount,
|
||||
NETHACK_PACKED_TILEFILE);
|
||||
(void) fclose(tibfile2);
|
||||
#endif
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
write_tibheader(fileptr,tibhdr)
|
||||
write_tibheader(fileptr, tibhdr)
|
||||
FILE *fileptr;
|
||||
struct tibhdr_struct *tibhdr;
|
||||
{
|
||||
|
||||
if (fseek(fileptr,0L,SEEK_SET)) {
|
||||
Fprintf(stderr, "Error writing header to tile file\n");
|
||||
}
|
||||
fwrite(tibhdr, sizeof(struct tibhdr_struct), 1, fileptr);
|
||||
if (fseek(fileptr, 0L, SEEK_SET)) {
|
||||
Fprintf(stderr, "Error writing header to tile file\n");
|
||||
}
|
||||
fwrite(tibhdr, sizeof(struct tibhdr_struct), 1, fileptr);
|
||||
}
|
||||
|
||||
static void
|
||||
build_tibtile(pixels)
|
||||
pixel (*pixels)[TILE_X];
|
||||
{
|
||||
int i, j, k, co_off;
|
||||
unsigned char co_mask,tmp;
|
||||
int i, j, k, co_off;
|
||||
unsigned char co_mask, tmp;
|
||||
|
||||
#ifndef OVERVIEW_FILE
|
||||
memset((void *)&planetile,0,sizeof(struct planar_cell_struct));
|
||||
memset((void *) &planetile, 0, sizeof(struct planar_cell_struct));
|
||||
#else
|
||||
memset((void *)&planetile,0,
|
||||
sizeof(struct overview_planar_cell_struct));
|
||||
memset((void *) &planetile, 0,
|
||||
sizeof(struct overview_planar_cell_struct));
|
||||
#endif
|
||||
for (j = 0; j < TILE_Y; j++) {
|
||||
for (i = 0; i < TILE_X; i++) {
|
||||
for (k = 0; k < num_colors; k++) {
|
||||
if (ColorMap[CM_RED][k] == pixels[j][i].r &&
|
||||
ColorMap[CM_GREEN][k] == pixels[j][i].g &&
|
||||
ColorMap[CM_BLUE][k] == pixels[j][i].b)
|
||||
break;
|
||||
}
|
||||
if (k >= num_colors)
|
||||
Fprintf(stderr, "color not in colormap!\n");
|
||||
for (j = 0; j < TILE_Y; j++) {
|
||||
for (i = 0; i < TILE_X; i++) {
|
||||
for (k = 0; k < num_colors; k++) {
|
||||
if (ColorMap[CM_RED][k] == pixels[j][i].r
|
||||
&& ColorMap[CM_GREEN][k] == pixels[j][i].g
|
||||
&& ColorMap[CM_BLUE][k] == pixels[j][i].b)
|
||||
break;
|
||||
}
|
||||
if (k >= num_colors)
|
||||
Fprintf(stderr, "color not in colormap!\n");
|
||||
#ifdef PACKED_FILE
|
||||
packtile[j][i] = k;
|
||||
packtile[j][i] = k;
|
||||
#endif
|
||||
|
||||
#ifdef PLANAR_FILE
|
||||
if (i > 7) {
|
||||
co_off = 1;
|
||||
co_mask = masktable[i - 8];
|
||||
} else {
|
||||
co_off = 0;
|
||||
co_mask = masktable[i];
|
||||
}
|
||||
if (i > 7) {
|
||||
co_off = 1;
|
||||
co_mask = masktable[i - 8];
|
||||
} else {
|
||||
co_off = 0;
|
||||
co_mask = masktable[i];
|
||||
}
|
||||
|
||||
tmp = planetile.plane[0].image[j][co_off];
|
||||
planetile.plane[0].image[j][co_off] = (k & 0x0008) ?
|
||||
(tmp | co_mask) :
|
||||
(tmp & ~co_mask);
|
||||
tmp = planetile.plane[0].image[j][co_off];
|
||||
planetile.plane[0].image[j][co_off] =
|
||||
(k & 0x0008) ? (tmp | co_mask) : (tmp & ~co_mask);
|
||||
|
||||
tmp = planetile.plane[1].image[j][co_off];
|
||||
planetile.plane[1].image[j][co_off] = (k & 0x0004) ?
|
||||
(tmp | co_mask) :
|
||||
(tmp & ~co_mask);
|
||||
tmp = planetile.plane[1].image[j][co_off];
|
||||
planetile.plane[1].image[j][co_off] =
|
||||
(k & 0x0004) ? (tmp | co_mask) : (tmp & ~co_mask);
|
||||
|
||||
tmp = planetile.plane[2].image[j][co_off];
|
||||
planetile.plane[2].image[j][co_off] = (k & 0x0002) ?
|
||||
(tmp | co_mask) :
|
||||
(tmp & ~co_mask);
|
||||
tmp = planetile.plane[2].image[j][co_off];
|
||||
planetile.plane[2].image[j][co_off] =
|
||||
(k & 0x0002) ? (tmp | co_mask) : (tmp & ~co_mask);
|
||||
|
||||
tmp = planetile.plane[3].image[j][co_off];
|
||||
planetile.plane[3].image[j][co_off] = (k & 0x0001) ?
|
||||
(tmp | co_mask) :
|
||||
(tmp & ~co_mask);
|
||||
tmp = planetile.plane[3].image[j][co_off];
|
||||
planetile.plane[3].image[j][co_off] =
|
||||
(k & 0x0001) ? (tmp | co_mask) : (tmp & ~co_mask);
|
||||
#endif /* PLANAR_FILE */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
write_tibtile(recnum)
|
||||
int recnum;
|
||||
{
|
||||
long fpos;
|
||||
long fpos;
|
||||
|
||||
#ifdef PLANAR_FILE
|
||||
# ifndef OVERVIEW_FILE
|
||||
fpos = ((long)(recnum) * (long)sizeof(struct planar_cell_struct)) +
|
||||
(long)TIBHEADER_SIZE;
|
||||
# else
|
||||
fpos = ((long)(recnum) *
|
||||
(long)sizeof(struct overview_planar_cell_struct)) +
|
||||
(long)TIBHEADER_SIZE;
|
||||
# endif
|
||||
if (fseek(tibfile1,fpos,SEEK_SET)) {
|
||||
Fprintf(stderr, "Error seeking before planar tile write %d\n",
|
||||
recnum);
|
||||
}
|
||||
# ifndef OVERVIEW_FILE
|
||||
fwrite(&planetile, sizeof(struct planar_cell_struct), 1, tibfile1);
|
||||
# else
|
||||
fwrite(&planetile,
|
||||
sizeof(struct overview_planar_cell_struct), 1, tibfile1);
|
||||
# endif
|
||||
#ifndef OVERVIEW_FILE
|
||||
fpos = ((long) (recnum) * (long) sizeof(struct planar_cell_struct))
|
||||
+ (long) TIBHEADER_SIZE;
|
||||
#else
|
||||
fpos =
|
||||
((long) (recnum) * (long) sizeof(struct overview_planar_cell_struct))
|
||||
+ (long) TIBHEADER_SIZE;
|
||||
#endif
|
||||
if (fseek(tibfile1, fpos, SEEK_SET)) {
|
||||
Fprintf(stderr, "Error seeking before planar tile write %d\n",
|
||||
recnum);
|
||||
}
|
||||
#ifndef OVERVIEW_FILE
|
||||
fwrite(&planetile, sizeof(struct planar_cell_struct), 1, tibfile1);
|
||||
#else
|
||||
fwrite(&planetile, sizeof(struct overview_planar_cell_struct), 1,
|
||||
tibfile1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PACKED_FILE
|
||||
fpos = ((long)(recnum) * (long)sizeof(packtile)) +
|
||||
(long)TIBHEADER_SIZE;
|
||||
if (fseek(tibfile2,fpos,SEEK_SET)) {
|
||||
Fprintf(stderr, "Error seeking before packed tile write %d\n",
|
||||
recnum);
|
||||
}
|
||||
fwrite(&packtile, sizeof(packtile), 1, tibfile2);
|
||||
fpos =
|
||||
((long) (recnum) * (long) sizeof(packtile)) + (long) TIBHEADER_SIZE;
|
||||
if (fseek(tibfile2, fpos, SEEK_SET)) {
|
||||
Fprintf(stderr, "Error seeking before packed tile write %d\n",
|
||||
recnum);
|
||||
}
|
||||
fwrite(&packtile, sizeof(packtile), 1, tibfile2);
|
||||
#endif
|
||||
}
|
||||
|
||||
1053
sys/msdos/video.c
1053
sys/msdos/video.c
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 vidtxt.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.6 vidtxt.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
|
||||
/* NetHack 3.6 vidtxt.c $Date: 2009/05/06 10:49:49 $ $Revision: 1.6 $ */
|
||||
/* SCCS Id: @(#)vidtxt.c 3.5 1994/04/04 */
|
||||
/* Copyright (c) NetHack PC Development Team 1993 */
|
||||
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/*
|
||||
* vidtxt.c - Textmode video hardware support (BIOS and DJGPPFAST)
|
||||
*
|
||||
*
|
||||
*Edit History:
|
||||
* Initial Creation M. Allison 93/04/04
|
||||
* Add djgpp support K. Smolkowski 93/04/26
|
||||
@@ -23,66 +23,67 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# if _MSC_VER >= 700
|
||||
#pragma warning(disable:4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable:4127) /* conditional expression is constant */
|
||||
#pragma warning(disable:4131) /* old style declarator */
|
||||
#pragma warning(disable:4305) /* prevents complaints with MK_FP */
|
||||
#pragma warning(disable:4309) /* initializing */
|
||||
#pragma warning(disable:4759) /* prevents complaints with MK_FP */
|
||||
# endif
|
||||
#if _MSC_VER >= 700
|
||||
#pragma warning(disable : 4018) /* signed/unsigned mismatch */
|
||||
#pragma warning(disable : 4127) /* conditional expression is constant */
|
||||
#pragma warning(disable : 4131) /* old style declarator */
|
||||
#pragma warning(disable : 4305) /* prevents complaints with MK_FP */
|
||||
#pragma warning(disable : 4309) /* initializing */
|
||||
#pragma warning(disable : 4759) /* prevents complaints with MK_FP */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* void FDECL(txt_xputc,(char, int)); */ /* write out character (and attribute) */
|
||||
/* void FDECL(txt_xputc,(char, int)); */ /* write out character (and
|
||||
attribute) */
|
||||
|
||||
extern int attrib_text_normal; /* text mode normal attribute */
|
||||
extern int attrib_gr_normal; /* graphics mode normal attribute */
|
||||
extern int attrib_text_intense; /* text mode intense attribute */
|
||||
extern int attrib_gr_intense; /* graphics mode intense attribute */
|
||||
extern int attrib_text_normal; /* text mode normal attribute */
|
||||
extern int attrib_gr_normal; /* graphics mode normal attribute */
|
||||
extern int attrib_text_intense; /* text mode intense attribute */
|
||||
extern int attrib_gr_intense; /* graphics mode intense attribute */
|
||||
|
||||
void
|
||||
txt_get_scr_size()
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
if (!iflags.BIOS) {
|
||||
CO = 80;
|
||||
LI = 24;
|
||||
return;
|
||||
}
|
||||
if (!iflags.BIOS) {
|
||||
CO = 80;
|
||||
LI = 24;
|
||||
return;
|
||||
}
|
||||
|
||||
# ifdef PC9800
|
||||
regs.h.ah = SENSEMODE;
|
||||
(void) int86(CRT_BIOS, ®s, ®s);
|
||||
#ifdef PC9800
|
||||
regs.h.ah = SENSEMODE;
|
||||
(void) int86(CRT_BIOS, ®s, ®s);
|
||||
|
||||
CO = (regs.h.al & 0x02) ? 40 : 80;
|
||||
LI = (regs.h.al & 0x01) ? 20 : 25;
|
||||
# else
|
||||
regs.x.ax = FONTINFO;
|
||||
regs.x.bx = 0; /* current ROM BIOS font */
|
||||
regs.h.dl = 24; /* default row count */
|
||||
/* in case no EGA/MCGA/VGA */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Font Information */
|
||||
CO = (regs.h.al & 0x02) ? 40 : 80;
|
||||
LI = (regs.h.al & 0x01) ? 20 : 25;
|
||||
#else
|
||||
regs.x.ax = FONTINFO;
|
||||
regs.x.bx = 0; /* current ROM BIOS font */
|
||||
regs.h.dl = 24; /* default row count */
|
||||
/* in case no EGA/MCGA/VGA */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Font Information */
|
||||
|
||||
/* MDA/CGA/PCjr ignore INT 10h, Function 11h, but since we
|
||||
* cleverly loaded up DL with the default, everything's fine.
|
||||
*
|
||||
* Otherwise, DL now contains rows - 1. Also, CX contains the
|
||||
* points (bytes per character) and ES:BP points to the font
|
||||
* table. -3.
|
||||
*/
|
||||
/* MDA/CGA/PCjr ignore INT 10h, Function 11h, but since we
|
||||
* cleverly loaded up DL with the default, everything's fine.
|
||||
*
|
||||
* Otherwise, DL now contains rows - 1. Also, CX contains the
|
||||
* points (bytes per character) and ES:BP points to the font
|
||||
* table. -3.
|
||||
*/
|
||||
|
||||
regs.h.ah = GETMODE;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Video Mode */
|
||||
regs.h.ah = GETMODE;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Video Mode */
|
||||
|
||||
/* This goes back all the way to the original PC. Completely
|
||||
* safe. AH contains # of columns, AL contains display mode,
|
||||
* and BH contains the active display page.
|
||||
*/
|
||||
/* This goes back all the way to the original PC. Completely
|
||||
* safe. AH contains # of columns, AL contains display mode,
|
||||
* and BH contains the active display page.
|
||||
*/
|
||||
|
||||
LI = regs.h.dl + 1;
|
||||
CO = regs.h.ah;
|
||||
# endif /* PC9800 */
|
||||
LI = regs.h.dl + 1;
|
||||
CO = regs.h.ah;
|
||||
#endif /* PC9800 */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -94,54 +95,56 @@ txt_get_scr_size()
|
||||
#ifdef NO_TERMS
|
||||
/* #include "wintty.h" */
|
||||
|
||||
# ifdef SCREEN_DJGPPFAST
|
||||
#ifdef SCREEN_DJGPPFAST
|
||||
#include <pc.h>
|
||||
#include <unistd.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void FDECL(txt_gotoxy, (int,int));
|
||||
void FDECL(txt_gotoxy, (int, int));
|
||||
|
||||
# if defined(SCREEN_BIOS) && !defined(PC9800)
|
||||
#if defined(SCREEN_BIOS) && !defined(PC9800)
|
||||
void FDECL(txt_get_cursor, (int *, int *));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# ifdef SCREEN_DJGPPFAST
|
||||
#define txt_get_cursor(x,y) ScreenGetCursor(y,x)
|
||||
# endif
|
||||
#ifdef SCREEN_DJGPPFAST
|
||||
#define txt_get_cursor(x, y) ScreenGetCursor(y, x)
|
||||
#endif
|
||||
|
||||
extern int g_attribute; /* Current attribute to use */
|
||||
extern int monoflag; /* 0 = not monochrome, else monochrome */
|
||||
extern int g_attribute; /* Current attribute to use */
|
||||
extern int monoflag; /* 0 = not monochrome, else monochrome */
|
||||
|
||||
void
|
||||
txt_backsp()
|
||||
{
|
||||
# ifdef PC9800
|
||||
union REGS regs;
|
||||
#ifdef PC9800
|
||||
union REGS regs;
|
||||
|
||||
regs.h.dl = 0x01; /* one column */
|
||||
regs.h.ah = CURSOR_LEFT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
regs.h.dl = 0x01; /* one column */
|
||||
regs.h.ah = CURSOR_LEFT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
|
||||
# else
|
||||
int col,row;
|
||||
#else
|
||||
int col, row;
|
||||
|
||||
txt_get_cursor(&col, &row);
|
||||
if (col > 0) col = col-1;
|
||||
txt_gotoxy(col,row);
|
||||
# endif
|
||||
txt_get_cursor(&col, &row);
|
||||
if (col > 0)
|
||||
col = col - 1;
|
||||
txt_gotoxy(col, row);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
txt_nhbell()
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
if (flags.silent) return;
|
||||
regs.h.dl = 0x07; /* bell */
|
||||
regs.h.ah = 0x02; /* Character Output function */
|
||||
(void) int86(DOSCALL, ®s, ®s);
|
||||
if (flags.silent)
|
||||
return;
|
||||
regs.h.dl = 0x07; /* bell */
|
||||
regs.h.ah = 0x02; /* Character Output function */
|
||||
(void) int86(DOSCALL, ®s, ®s);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -150,118 +153,116 @@ txt_clear_screen()
|
||||
* so for now we just use the BIOS Routines
|
||||
*/
|
||||
{
|
||||
union REGS regs;
|
||||
# ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
union REGS regs;
|
||||
#ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
|
||||
regs.h.dl = 0x02; /* clear whole screen */
|
||||
regs.h.ah = SCREEN_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
regs.h.dl = 0x02; /* clear whole screen */
|
||||
regs.h.ah = SCREEN_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
# else
|
||||
regs.h.dl = (char)(CO - 1); /* columns */
|
||||
regs.h.dh = (char)(LI - 1); /* rows */
|
||||
regs.x.cx = 0; /* CL,CH = x,y of upper left */
|
||||
regs.x.ax = 0;
|
||||
regs.x.bx = 0;
|
||||
regs.h.bh = (char)attrib_text_normal;
|
||||
regs.h.ah = (char)SCROLL;
|
||||
/* DL,DH = x,y of lower rt */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Scroll or init window */
|
||||
txt_gotoxy(0,0);
|
||||
# endif
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
#else
|
||||
regs.h.dl = (char) (CO - 1); /* columns */
|
||||
regs.h.dh = (char) (LI - 1); /* rows */
|
||||
regs.x.cx = 0; /* CL,CH = x,y of upper left */
|
||||
regs.x.ax = 0;
|
||||
regs.x.bx = 0;
|
||||
regs.h.bh = (char) attrib_text_normal;
|
||||
regs.h.ah = (char) SCROLL;
|
||||
/* DL,DH = x,y of lower rt */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Scroll or init window */
|
||||
txt_gotoxy(0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
txt_cl_end(col,row) /* clear to end of line */
|
||||
int col,row;
|
||||
void txt_cl_end(col, row) /* clear to end of line */
|
||||
int col, row;
|
||||
{
|
||||
union REGS regs;
|
||||
# ifndef PC9800
|
||||
int count;
|
||||
# endif
|
||||
union REGS regs;
|
||||
#ifndef PC9800
|
||||
int count;
|
||||
#endif
|
||||
|
||||
# ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
#ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
|
||||
regs.h.dl = 0x00; /* clear to end of line */
|
||||
regs.h.ah = LINE_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
regs.h.dl = 0x00; /* clear to end of line */
|
||||
regs.h.ah = LINE_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
# else
|
||||
count = CO - col;
|
||||
txt_gotoxy(col,row);
|
||||
regs.h.ah = PUTCHARATT; /* write attribute & character */
|
||||
regs.h.al = ' '; /* character */
|
||||
regs.h.bh = 0; /* display page */
|
||||
/* BL = attribute */
|
||||
regs.h.bl = (char)attrib_text_normal;
|
||||
regs.x.cx = count;
|
||||
if (count != 0)
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* write attribute
|
||||
& character */
|
||||
# endif
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
#else
|
||||
count = CO - col;
|
||||
txt_gotoxy(col, row);
|
||||
regs.h.ah = PUTCHARATT; /* write attribute & character */
|
||||
regs.h.al = ' '; /* character */
|
||||
regs.h.bh = 0; /* display page */
|
||||
/* BL = attribute */
|
||||
regs.h.bl = (char) attrib_text_normal;
|
||||
regs.x.cx = count;
|
||||
if (count != 0)
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* write attribute
|
||||
& character */
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
txt_cl_eos() /* clear to end of screen */
|
||||
void txt_cl_eos() /* clear to end of screen */
|
||||
{
|
||||
union REGS regs;
|
||||
# ifndef PC9800
|
||||
int col,row;
|
||||
# endif
|
||||
union REGS regs;
|
||||
#ifndef PC9800
|
||||
int col, row;
|
||||
#endif
|
||||
|
||||
# ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
#ifdef PC9800
|
||||
regs.h.dl = attr98[attrib_text_normal];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
|
||||
regs.h.dl = 0x00; /* clear to end of screen */
|
||||
regs.h.ah = SCREEN_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
regs.h.dl = 0x00; /* clear to end of screen */
|
||||
regs.h.ah = SCREEN_CLEAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
# else
|
||||
txt_get_cursor(&col, &row);
|
||||
txt_cl_end(col,row); /* clear to end of line */
|
||||
txt_gotoxy(0,(row < (LI-1) ? row+1 : (LI-1)));
|
||||
regs.h.dl = (char) (CO-1); /* X of lower right */
|
||||
regs.h.dh = (char) (LI-1); /* Y of lower right */
|
||||
regs.h.cl = 0; /* X of upper left */
|
||||
/* Y (row) of upper left */
|
||||
regs.h.ch = (char) (row < (LI-1) ? row+1 :(LI-1));
|
||||
regs.x.cx = 0;
|
||||
regs.x.ax = 0;
|
||||
regs.x.bx = 0;
|
||||
regs.h.bh = (char)attrib_text_normal;
|
||||
regs.h.ah = SCROLL;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Scroll or initialize window */
|
||||
# endif
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
#else
|
||||
txt_get_cursor(&col, &row);
|
||||
txt_cl_end(col, row); /* clear to end of line */
|
||||
txt_gotoxy(0, (row < (LI - 1) ? row + 1 : (LI - 1)));
|
||||
regs.h.dl = (char) (CO - 1); /* X of lower right */
|
||||
regs.h.dh = (char) (LI - 1); /* Y of lower right */
|
||||
regs.h.cl = 0; /* X of upper left */
|
||||
/* Y (row) of upper left */
|
||||
regs.h.ch = (char) (row < (LI - 1) ? row + 1 : (LI - 1));
|
||||
regs.x.cx = 0;
|
||||
regs.x.ax = 0;
|
||||
regs.x.bx = 0;
|
||||
regs.h.bh = (char) attrib_text_normal;
|
||||
regs.h.ah = SCROLL;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Scroll or initialize window */
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
txt_startup(wid, hgt)
|
||||
int *wid, *hgt;
|
||||
int *wid, *hgt;
|
||||
{
|
||||
txt_get_scr_size();
|
||||
*wid = CO;
|
||||
*hgt = LI;
|
||||
txt_get_scr_size();
|
||||
*wid = CO;
|
||||
*hgt = LI;
|
||||
|
||||
attrib_gr_normal = attrib_text_normal;
|
||||
attrib_gr_intense = attrib_text_intense;
|
||||
g_attribute = attrib_text_normal; /* Give it a starting value */
|
||||
attrib_gr_normal = attrib_text_normal;
|
||||
attrib_gr_intense = attrib_text_intense;
|
||||
g_attribute = attrib_text_normal; /* Give it a starting value */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -289,80 +290,81 @@ txt_startup(wid, hgt)
|
||||
*/
|
||||
|
||||
void
|
||||
txt_xputs(s,col,row)
|
||||
txt_xputs(s, col, row)
|
||||
const char *s;
|
||||
int col,row;
|
||||
int col, row;
|
||||
{
|
||||
char c;
|
||||
char c;
|
||||
|
||||
if (s != (char *)0) {
|
||||
while (*s != '\0') {
|
||||
txt_gotoxy(col,row);
|
||||
c = *s++;
|
||||
txt_xputc(c,g_attribute);
|
||||
if (col < (CO-1)) col++;
|
||||
txt_gotoxy(col,row);
|
||||
}
|
||||
}
|
||||
if (s != (char *) 0) {
|
||||
while (*s != '\0') {
|
||||
txt_gotoxy(col, row);
|
||||
c = *s++;
|
||||
txt_xputc(c, g_attribute);
|
||||
if (col < (CO - 1))
|
||||
col++;
|
||||
txt_gotoxy(col, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
txt_xputc(ch,attr) /* write out character (and attribute) */
|
||||
void txt_xputc(ch, attr) /* write out character (and attribute) */
|
||||
char ch;
|
||||
int attr;
|
||||
{
|
||||
# ifdef PC9800
|
||||
union REGS regs;
|
||||
#ifdef PC9800
|
||||
union REGS regs;
|
||||
|
||||
regs.h.dl = attr98[attr];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
regs.h.dl = attr98[attr];
|
||||
regs.h.ah = SETATT;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
|
||||
if (ch == '\n') {
|
||||
regs.h.dl = '\r';
|
||||
regs.h.ah = PUTCHAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
if (ch == '\n') {
|
||||
regs.h.dl = '\r';
|
||||
regs.h.ah = PUTCHAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
}
|
||||
regs.h.dl = ch;
|
||||
regs.h.ah = PUTCHAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
}
|
||||
regs.h.dl = ch;
|
||||
regs.h.ah = PUTCHAR;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
# else
|
||||
# ifdef SCREEN_BIOS
|
||||
union REGS regs;
|
||||
# endif
|
||||
int col,row;
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s);
|
||||
#else
|
||||
#ifdef SCREEN_BIOS
|
||||
union REGS regs;
|
||||
#endif
|
||||
int col, row;
|
||||
|
||||
txt_get_cursor(&col,&row);
|
||||
switch(ch) {
|
||||
case '\n':
|
||||
txt_get_cursor(&col, &row);
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
#if 0
|
||||
col = 0;
|
||||
++row;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
# ifdef SCREEN_DJGPPFAST
|
||||
ScreenPutChar((int)ch,attr,col,row);
|
||||
# endif
|
||||
# ifdef SCREEN_BIOS
|
||||
regs.h.ah = PUTCHARATT; /* write att & character */
|
||||
regs.h.al = ch; /* character */
|
||||
regs.h.bh = 0; /* display page */
|
||||
regs.h.bl = (char)attr; /* BL = attribute */
|
||||
regs.x.cx = 1; /* one character */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
# endif
|
||||
if (col < (CO -1 )) ++col;
|
||||
break;
|
||||
} /* end switch */
|
||||
txt_gotoxy(col,row);
|
||||
# endif /* PC9800 */
|
||||
break;
|
||||
default:
|
||||
#ifdef SCREEN_DJGPPFAST
|
||||
ScreenPutChar((int) ch, attr, col, row);
|
||||
#endif
|
||||
#ifdef SCREEN_BIOS
|
||||
regs.h.ah = PUTCHARATT; /* write att & character */
|
||||
regs.h.al = ch; /* character */
|
||||
regs.h.bh = 0; /* display page */
|
||||
regs.h.bl = (char) attr; /* BL = attribute */
|
||||
regs.x.cx = 1; /* one character */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
#endif
|
||||
if (col < (CO - 1))
|
||||
++col;
|
||||
break;
|
||||
} /* end switch */
|
||||
txt_gotoxy(col, row);
|
||||
#endif /* PC9800 */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -386,74 +388,74 @@ int attr;
|
||||
* screen writes will occur next, it does not change
|
||||
* the location of the player on the NetHack level.
|
||||
*/
|
||||
|
||||
# if defined(SCREEN_BIOS) && !defined(PC9800)
|
||||
|
||||
#if defined(SCREEN_BIOS) && !defined(PC9800)
|
||||
/*
|
||||
* This is implemented as a macro under DJGPPFAST.
|
||||
*/
|
||||
void
|
||||
txt_get_cursor(x,y) /* get cursor position */
|
||||
void txt_get_cursor(x, y) /* get cursor position */
|
||||
int *x, *y;
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
regs.x.dx = 0;
|
||||
regs.h.ah = GETCURPOS; /* get cursor position */
|
||||
regs.x.cx = 0;
|
||||
regs.x.bx = 0;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Cursor Position */
|
||||
*x = regs.h.dl;
|
||||
*y = regs.h.dh;
|
||||
regs.x.dx = 0;
|
||||
regs.h.ah = GETCURPOS; /* get cursor position */
|
||||
regs.x.cx = 0;
|
||||
regs.x.bx = 0;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Cursor Position */
|
||||
*x = regs.h.dl;
|
||||
*y = regs.h.dh;
|
||||
}
|
||||
# endif /* SCREEN_BIOS && !PC9800 */
|
||||
#endif /* SCREEN_BIOS && !PC9800 */
|
||||
|
||||
void
|
||||
txt_gotoxy(x,y)
|
||||
int x,y;
|
||||
txt_gotoxy(x, y)
|
||||
int x, y;
|
||||
{
|
||||
# ifdef SCREEN_BIOS
|
||||
union REGS regs;
|
||||
#ifdef SCREEN_BIOS
|
||||
union REGS regs;
|
||||
|
||||
# ifdef PC9800
|
||||
regs.h.dh = (char)y; /* row */
|
||||
regs.h.dl = (char)x; /* column */
|
||||
regs.h.ah = SETCURPOS;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s); /* Set Cursor Position */
|
||||
# else
|
||||
regs.h.ah = SETCURPOS;
|
||||
regs.h.bh = 0; /* display page */
|
||||
regs.h.dh = (char)y; /* row */
|
||||
regs.h.dl = (char)x; /* column */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Set Cursor Position */
|
||||
# endif
|
||||
# endif
|
||||
# if defined(SCREEN_DJGPPFAST)
|
||||
ScreenSetCursor(y,x);
|
||||
# endif
|
||||
/* The above, too, goes back all the way to the original PC. If
|
||||
* we ever get so fancy as to swap display pages (i doubt it),
|
||||
* then we'll need to set BH appropriately. This function
|
||||
* returns nothing. -3.
|
||||
*/
|
||||
#ifdef PC9800
|
||||
regs.h.dh = (char) y; /* row */
|
||||
regs.h.dl = (char) x; /* column */
|
||||
regs.h.ah = SETCURPOS;
|
||||
regs.h.cl = DIRECT_CON_IO;
|
||||
(void) int86(DOS_EXT_FUNC, ®s, ®s); /* Set Cursor Position */
|
||||
#else
|
||||
regs.h.ah = SETCURPOS;
|
||||
regs.h.bh = 0; /* display page */
|
||||
regs.h.dh = (char) y; /* row */
|
||||
regs.h.dl = (char) x; /* column */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Set Cursor Position */
|
||||
#endif
|
||||
#endif
|
||||
#if defined(SCREEN_DJGPPFAST)
|
||||
ScreenSetCursor(y, x);
|
||||
#endif
|
||||
/* The above, too, goes back all the way to the original PC. If
|
||||
* we ever get so fancy as to swap display pages (i doubt it),
|
||||
* then we'll need to set BH appropriately. This function
|
||||
* returns nothing. -3.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* This marks the end of the cursor manipulation/information routines.
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
*/
|
||||
|
||||
# ifdef MONO_CHECK
|
||||
int txt_monoadapt_check()
|
||||
#ifdef MONO_CHECK
|
||||
int
|
||||
txt_monoadapt_check()
|
||||
{
|
||||
union REGS regs;
|
||||
union REGS regs;
|
||||
|
||||
regs.h.al = 0;
|
||||
regs.h.ah = GETMODE; /* get video mode */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
return (regs.h.al == 7) ? 1 : 0; /* 7 means monochrome mode */
|
||||
regs.h.al = 0;
|
||||
regs.h.ah = GETMODE; /* get video mode */
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
return (regs.h.al == 7) ? 1 : 0; /* 7 means monochrome mode */
|
||||
}
|
||||
# endif /* MONO_CHECK */
|
||||
#endif /* MONO_CHECK */
|
||||
#endif /* NO_TERMS */
|
||||
|
||||
/* vidtxt.c */
|
||||
|
||||
1921
sys/msdos/vidvga.c
1921
sys/msdos/vidvga.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user