- Move secondary preprocessor defines down further in config.h
so that they can be overridden via [platform]conf.h which is
included from global.h, specifically:
LIVELOGFILE when LIVELOG is defined
DUMPLOG_FILE when DUMPLOG is defined
- Minimize platform-specific, or compiler-specific code in hack.h and decl.h.
- reorganize src/decl.c to align with include/decl.h.
- a new header file cstd.h added, containing calls to C99
standard header files.
- hack.h, decl.h, and decl.c have been cleaned up and had code
moved so that things line up as follows:
hack.h defines values that are available to all
NetHack source files, contains enums for use in all
NetHack source files, and contains a number of
struct definitions for use in all NetHack source files.
It does not contain variable declarations or variable
definitions.
decl.h contains the extern declarations for variables that
are defined in decl.c. These variables are global and
available to all NetHack source files. The location of
the variables within decl.h was random, so give it some
order for now.
decl.c contains the definition of the variables declared in
decl.h, and initializes them where appropriate. The
variable definitions are laid out in much the
same order as their declarations in decl.h.
- wintty.h: There were some varying terminal-related prototypes in
system.h, and that was the only thing left that demanded that
system.h be included. Those have been replaced by an #include
<term.h> in include/wintty.h to get the more current (and hopefully
more correct) prototypes, rather than hardcoding them in NetHack
sources.
For edge-case platform compatiblity, there is no #include <term.h>
if the build defines NO_TERMCAP_HEADERS. In that case one set of
hardcoded prototypes is still used in include/wintty.h.
The added #include "term.h" is also bypassed for NO_TERMS builds (builds
that don't link to terminfo/termcap at all, but still present a tty
interface using platform or window-port specific functions to fulfill
the same role as that of terminfo/termcap).
- some scattered, unnecessary #include "integer.h" were removed from
various files, since that's always included in current NetHack-3.7
sources, either directly from config.h or indirectly from #include
"hack.h".
- system.h references removed.
- new cstd.h added; the #include "system.h" references in Makefiles
and project files (Xcode, visual studio), were replaced
with #include "cstd.h" references. A "make depends" is probably
warranted.
Also:
- Use of <term.h>, which defines clear_screen() as a macro, conflicts
with an actual function with that name in win/tty/termcap.c. The most
straight-forward course of action was to rename the NetHack function,
and change the references to it, from clear_screen() to
term_clear_screen(), so that was done.
52 lines
1.9 KiB
C
Executable File
52 lines
1.9 KiB
C
Executable File
/* Maintain a data structure describing a monospaced bitmap font */
|
|
|
|
#ifndef FONT_H
|
|
#define FONT_H
|
|
|
|
/*
|
|
* The file format is Linux PSF, version 2. Version 1 is not supported.
|
|
* Actual Linux fonts are restricted to 256 or 512 glyphs; for NetHack, the
|
|
* font can have any number of glyphs. The Unicode map is expected to be
|
|
* present, but combining sequences are not supported.
|
|
* The fonts supplied for use with this data structure have the first 256
|
|
* glyphs arranged according to IBM code page 437, for simpler support of
|
|
* the IBM handling mode for the map.
|
|
*/
|
|
|
|
/* For Unicode lookup, a three level tree provides constant-time access to
|
|
the glyphs without using an excessive amount of memory.
|
|
The root has seventeen entries, one for each plane of Unicode. Most fonts
|
|
will populate only plane 0, and Unicode defines only planes 0, 1, 2, 3, 15
|
|
and 16.
|
|
The second level has 256 entries, each pointing to a third level node with
|
|
256 entries. Each third level entry has type unsigned, and gives the index
|
|
of the glyph.
|
|
Given the Unicode code point, we can use bits 20 through 16 to index the
|
|
root, bits 15 through 8 for the second level and bits 7 through 0 for the
|
|
third level. */
|
|
|
|
struct BitmapFont {
|
|
/* Dimensions of a single glyph */
|
|
unsigned width;
|
|
unsigned height;
|
|
|
|
/* The glyphs, in the order that they appear in the font */
|
|
/* IBM handling will index the glyphs this way */
|
|
/* glyph points to an allocated array, each element of which points to
|
|
another allocated array */
|
|
unsigned num_glyphs;
|
|
unsigned char **glyphs;
|
|
|
|
/* The root node of the Unicode tree */
|
|
unsigned **unicode[17];
|
|
};
|
|
|
|
extern struct BitmapFont *load_font(const char *filename);
|
|
extern void free_font(struct BitmapFont *font);
|
|
extern const unsigned char *get_font_glyph(
|
|
struct BitmapFont *font,
|
|
uint32 ch,
|
|
boolean unicode);
|
|
|
|
#endif
|