Commit Graph
348 Commits
Author SHA1 Message Date
Ray Chason e0ecf0e5f2 Fix highlighting in 16 color text map
vga_redrawmap did not have the inverse flag available. Provide it.
2026-08-04 16:05:27 -04:00
Ray Chason 3e800b90d3 Support pet and tile decals in 16 color mode 2026-08-04 15:55:36 -04:00
Ray Chason 9d5184562e More decal support for VESA
* Support decals in overview mode
* Draw decals when redrawing the map
2026-08-04 09:38:38 -04:00
Ray Chason 85bb8c1fbc Simplify the 24-bit case 2026-08-03 22:20:18 -04:00
Ray Chason bd68058327 Extend decal support to all VESA modes 2026-08-03 22:12:14 -04:00
nhmall ff87463e47 initial hilite_pet and hilite_pile msdos tiles
This is an initial attempt at adding support for hilite_pet and
hilite_pile to the msdos tile implementation, using the new
decal.txt tiles.

This initial attempt only supports a 16-bit vesa mode.

Other vesa modes and vga have not been done as of yet.
Hopefully, someone more familiar with vesa might contribute
improvements and support of the other modes at some point.
2026-07-29 20:48:44 -04:00
Ray Chason e00b32263e Support the Curses-only configuration 2026-07-10 09:08:55 -04:00
Ray Chason 7889eedfa5 MS-DOS: Support no-tiles and no-graphics builds
In previous versions of NetHack, setting -DUSE_TILES enabled the tile
support, while setting -DSUPPRESS_GRAPHICS produced a NetHack that
would write its TTY output to standard output, and rely on ANSI.SYS or
similar to do screen control. (USE_TILES is now TILES_IN_GLYPHMAP.)

This change ensures that the current NetHack can be built the same
ways.

One twist is that previous NetHacks would drop all support for graphical
modes when tiles were not supported. Thus sys/msdos/vid{vga,vesa}.c have
very disordered use of TILES_IN_GLYPHMAP. There was no need to check
this. But now, the graphical modes also support Unicode. A non-tiled
build should have the graphical modes, with only the text functions
present, provided that ENHANCED_SYMBOLS is defined.

Some unused and locally used symbols were cleaned up along the way.
2026-07-09 23:48:14 -04:00
Ray Chason f3f39311e5 MS-DOS: Define a separate palette for VGA text
In 16 color mode, text colors are mapped onto the colors available in
the tileset. The mapping is a compromise, and is not one-to-one: cyan
and bright cyan are the same, and magenta and bright magenta are the
same.

This change defines a separate palette for use by the text map, and
switches palettes on any transition between text and tiled maps.
2026-07-07 16:24:35 -04:00
Ray Chason af79ad629c MS-DOS: some optimizations for tile handling
* In both the 16 color and the VESA mode, the tileset image is loaded
      and split into individual tiles; the tiles are then processed into a
      form that is compatible with the video mode in use. For 16 color mode,
      a tile is processed each time it is displayed, leading to slow
      redrawing. For VESA mode, each tile is processed at startup, leading
      to long startup times. Both modes are changed so that the tile is
      processed once, when it is first displayed, and the result is cached.

    * Use memcpy when splitting the image into tiles.

    * Only load the tileset once. In 16 color mode, for reasons I do not
      understand, the gr_init function is called twice, leading to delay
      in startup. This does not happen in VESA mode.
2026-07-04 13:43:23 -04:00
nhmall 454ab83a36 Merge branch 'msdos-font-null-ptr' of https://github.com/chasonr/NetHack into NetHack-5.0 2026-07-03 08:35:32 -04:00
Ray Chason b3fd7330ef Fix operator precedence 2026-07-03 00:24:17 -04:00
Ray Chason ae8982fe3e MS-DOS: Check font pointer for null
The 16 color mode loads the font specified in font_map, and accepts it
only if its size is 8 by 16 pixels. This change avoids a null
dereference if the font is not found.
2026-07-02 21:34:35 -04:00
Ray Chason 3384619431 MS-DOS: Add Extended2 symbols to the bundled fonts
This change adds U+2299, U+2601 and U+2980 to the bundled fonts, so
that all symbols specified in the Extended2 symbol set are available.

Also, a few more directives are added to the files, so that FontForge
can load them and display their contents.
2026-07-02 21:22:30 -04:00
nhmall 8e9d23b578 msdos warning bit
../sys/msdos/font.c: In function 'load_font':
../sys/msdos/font.c:89:22: warning: unused variable 'j' [-Wunused-variable]
   89 |             unsigned j;
      |                      ^
2026-06-12 11:00:28 -04:00
Ray Chason 0248dbf550 MSDOS: Accept only single character font mappings
* makefont.lua generates incorrect PSF fonts. There can be multiple
  characters mapped to a single glyph, but the mappings should be
  separated by FE bytes.

* font.c should accept only single character mappings -- not combining
  sequences. The bundled fonts have no combining sequences, but I am
  exploring other options that provide more Unicode coverate.
2026-06-10 23:14:09 -04:00
Ray Chason 1ac6ec5d1e MS-DOS: several fixes for the tiled map
VESA mode: Set the viewport size correctly so the position bar does
not overlay the map.

VESA mode: Correctly set the size to which tiles are stretched when
overview mode (F4) is selected.

Both VESA and 16 color modes: Pass correct parameters to vga_userpan
and vesa_userpan, so the pan keys (CTRL+arrow) work correctly.
Some emulations don't report CTRL with up or down arrows, so accept
CTRL-home, CTRL-page up, CTRL page down and CTRL-end.

16 color mode: Set the panning direction so CTRL-left and CTRL-right
pan in the same direction as 3.4.3.
2026-06-09 16:25:46 -04:00
Ray Chason a160322aef MS-DOS: Fix custom colors in VESA BIOS mode
The basic colors are being displayed as black. Colors specified as RGB
are not being converted to the pixel format for the current mode.  This
manifests as walls in dungeon branches being drawn in black when the
symbol set is IBMgraphics, and in the wrong color when Enhanced1 is in
use and the display mode uses 15 or 16 bits per pixel. A particular
mode that shows this bug is 1024 by 768 under DOSBox.
2026-06-07 17:09:27 -04:00
nhmall ce31feb231 add some foundational work for uplifts
Be able to carry out uplifts during minor release
lifetimes.

Document a way to be able to uplift struct content
without incrementing EDITLEVEL and breaking existing savefiles.
Use the mechanics outlined to uplift the contents instead, where
it is feasible to do so. The uplift is currently one-way only. An
uplifted savefile cannot be used with an earlier build of NetHack
, one built with a lower SAVEFILE_REVISION_LEVEL, than the one which
wrote the savefile.

The final byte (byte 79) of the 80 critical bytes in the savefile,
of which 10 are reserved for future expansion and not currently
used, will now be used for holding the savefile revision level
(SAVEFILE_REVISION_LEVEL in include/patchlevel.h) at the time
the savefile was written.

That leaves 9 of the bytes available for future use.
2026-05-27 16:14:20 -04:00
nhmall 3cb7bfc0b3 more sys 2026-04-26 11:08:10 -04:00
nhmall 8d1e6b054c Install.dos bit 2026-04-26 10:57:31 -04:00
nhmall d7a6b3085e sys files 2026-04-26 10:47:48 -04:00
nhmall 2a6e7c47ec leave outdated files as 3.6; more to 5.0 2026-04-26 09:29:50 -04:00
nhmall 97b6fad509 "NetHack 3.7" to "NetHack 5.0" in doc include src sys win 2026-04-26 09:25:42 -04:00
nhmall 1745d0bcce follow-up: cross compile for msdos 2026-04-05 13:36:06 -04:00
nhmall 686618f34d move early arg and enum dump processing to own file 2026-04-01 08:32:13 -04:00
Pasi Kallinen d78af5cec7 Add monster spell header file mcastu.h
Move the monster spell definitions there, and use hackery
(similar to objects.h) to generate enum and data from
the header file.

I have not tested Windows, VMS, or Amiga builds.
2026-03-24 17:26:24 +02:00
nhmall 044a229467 whitespace cleanup: tabs to spaces in sys 2026-03-19 20:33:03 -04:00
Pasi Kallinen d0b9846367 Move item actions into separate src file
Haven't tested compilation on Windows and VMS ...
2026-01-11 14:46:25 +02:00
nhmall 642cf9a93e bump Lua references from 5.4.6 to 5.4.8 2026-01-04 11:12:50 -05:00
nhmall 2c747b079e revert some CI test changes 2025-11-10 09:19:47 -05:00
nhmall efbc0d8f8f more troubleshooting Terminus font use in CI environment 2025-11-10 08:52:06 -05:00
nhmall 157fcad161 troubleshoot Terminus font download in CI environment 2025-11-10 08:24:39 -05:00
nhmall 6c3e70ad77 remove stray tabs from *.c files and config.h 2025-08-19 08:35:39 -04:00
nhmall 78a4fd2fb8 split config file processing into its own src file 2025-05-21 23:58:01 -04:00
nhmall 1f99638bbf ren nhconst.h -> weight.h
The speed related values were not used, except for NORMAL_SPEED,
which has been moved back to permonst.h
2025-03-19 17:14:07 -04:00
nhmall a943c4c10b replace some weight-related magic numbers
adds a header file include/nhconst.h  (I'm open to a better name)
2025-03-19 13:29:58 -04:00
nhmall be5143bb74 window-port updates
Remove start_screen() and end_screen() from the
Window-port interface.

They were only ever used by tty, and there was a comment
carried to several window-ports about how they "really
should go away. They are tty-specific"

term_start_screen() and term_end_screen() are part of
terminal/NO_TERMS supporting routines now.
2025-01-04 23:38:34 -05:00
nhmall 37758c7e48 some tty updates
Add a note about NO_TERMS to include/wintty.h for clarity.

Rename tty_startup and tty_shutdown to term_startup() and
term_shutdown(). They are found in termcap.c for !NO_TERMS
like most of the other term_ routines, as well as having
versions for several of the NO_TERMS platforms. They aren't
part of the tty_interface called from the core. The tty
implementation does call and rely on them.

Remove some conditional #ifdef's around term_shutdown()
(formerly tty_shutdown()) and just ensure that all the
tty platforms have an implementation that they can link
with, even if it is just a stub presently.

Put the protype for nethack_exit in extern.h to reduce
maintenance to a single spot, and remove it from other
locations. A warning in the msdos cross-compile led to
this change.
2025-01-04 19:01:34 -05:00
nhmall 50aff17f94 follow-up bit for sys/msdos/fetch-cross-compiler.sh 2024-12-29 13:54:06 -05:00
nhmall 7b4445f040 make msdos lib/djgpp/target folder more hierarchical
Instead of flat, have bin, lib and include folders for
the native DOS pieces.

If you have been cross-compiling for MSDOS, you will
need to carry out the following to bring things up-to-date:

    sys/msdos/fetch-cross-compiler.sh
    make CROSS_TO_MSDOS=1 WANT_DEBUG=1 package
2024-12-29 12:11:03 -05:00
nhmall 45b2a6c49a more C standard progress
There was a transcription error in the comments in cstd.h for
the standard list of header files, where only the description
remained for <stdlib.h>, not the name of the file itself.

Remove several extraneous inclusions of the standard C99 headers.

Tested on the following afterwards:
Linux (using hints/linux.370) including tty, curses, qt6, and X11
macOS (using hints/macOS.370) including tty, curses, qt5, and X11
Windows MSYS2 using sys/windows/GNUmakefile
Windows Visual Studio using sys/windows/Makefile.nmake
msdos cross-compile on Ubuntu using djgpp cross-compiler
2024-12-20 10:32:38 -05:00
nhmall 5a3795184f use bash for sys/msdos/fetch-cross-compiler.sh
bash allows arrays thus preventing duplication during fetching
2024-12-16 13:35:05 -05:00
nhmall 0a5948fffc follow-up on msdos cross-compile
Obtain gdb.exe during the execution of sys/msdosfetch-cross-compiler.sh
ahead of the build, so that the Makefile just has to move it into place.
2024-12-15 20:08:10 -05:00
nhmall 2965ce4bc5 msdos build correction
ENHANCED_SYMBOLS is defined by default in config.h.
The msdos build tried to #undef ENHANCED_SYMBOLS
in tilemap.c, but doing it in there created a mismatch
between the data struct definition for glyph_map in wintype.h
and the initializers generated in tilemap.c

Move the msdos build catch for ENHANCED_SYMBOLS to
one single place in config1.h so that the code and data agree.
2024-12-15 09:53:50 -05:00
nhmall bdeddbe63b update sys/msdos/Install.dos 2024-12-04 15:12:27 -05:00
nhmall 0792e5fe9e expand implicit fallthrough detection to non-gcc compilers
gcc has recognized various "magic comments" for white-listing
occurrences of implicit fallthrough in switch statements for
a long time:

    The range and shape of "falls through" comments accepted are
    contingent upon the level of the warning. (The default level is =3.)

    -Wimplicit-fallthrough=0 disables the warning altogether.
    -Wimplicit-fallthrough=1 treats any kind of comment as a "falls through" comment.
    -Wimplicit-fallthrough=2 essentially accepts any comment that contains something
     that matches (case insensitively) "falls?[ \t-]*thr(ough|u)" regular expression.
    -Wimplicit-fallthrough=3 case sensitively matches a wide range of regular
     expressions, listed in the GCC manual. E.g., all of these are accepted:
        /* Falls through. */
        /* fall-thru */
        /* Else falls through. */
        /* FALLTHRU */
        /* ... falls through ... */
       etc.
    -Wimplicit-fallthrough=4 also, case sensitively matches a range of regular
     expressions but is much more strict than level =3.
    -Wimplicit-fallthrough=5 doesn't recognize any comments.

Plenty of other compilers did not recognize the gcc comment convention,
and up until now the compiler warning for detecting unintended
fallthrough had to be suppressed on other compilers. That's because the code
in NetHack has been relying on the gcc approach, and only the gcc approach.

The C23 standard introduces an attribute [[fallthrough]] for the
functionality, when implicit fallthrough warnings have been enabled.

Several popular compilers already support that, or a very similar attribute
style approach, today, even ahead of their C23 support:

       C compiler                       whitelist approach
       ---------------------------   -------------------------------------
       C23 conforming compilers         [[fallthrough]]

       clang versions supporting
       standards prior to
       C23                              __attribute__((__fallthrough__))

       Microsoft Visual Studio
       since VS 2022 17.4.
       The warning C5262 controls
       whether the implict
       fallthrough is detected and
       warned about with
       /std:clatest.                    [[fallthrough]]

This adds support to NetHack for the attribute approach by inserting a
macro FALLTHROUGH to the existing cases that require white-listing, so
other compilers can analyze things too.

The definition of the FALLTHROUGH macro is controlled in include/tradstdc.h.

The gcc comment approach has also been left in place at this time.
2024-11-30 14:16:27 -05:00
nhmall fb70aadbb5 improve copy_bytes() maintenance
Remove the copy_bytes() function from files.c and util/recover.c
and place a single copy into hacklib.
2024-10-05 15:55:20 -04:00
nhmall 0eb7f109e0 follow-up, program_state 2024-07-13 16:31:35 -04:00
nhmall 6c0ae092c6 distinguish global variables that get written to savefile
The g? structs had a mix of variables that were written to
the savefile, and those that were not.

For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.

This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.

Details:

    gb.bases            -> svb.bases
    gb.bbubbles         -> svb.bbubbles
    gb.branches         -> svb.branches
    gc.context          -> svc.context
    gd.disco            -> svd.disco
    gd.dndest           -> svd.dndest
    gd.doors            -> svd.doors
    gd.doors_alloc      -> svd.doors_alloc
    gd.dungeon_topology -> svd.dungeon_topology
    gd.dungeons         -> svd.dungeons
    ge.exclusion_zones  -> sve.exclusion_zones
    gh.hackpid          -> svh.hackpid
    gi.inv_pos          -> svi.inv_pos
    gk.killer           -> svk.killer
    gl.lastseentyp      -> svl.lastseentyp
    gl.level            -> svl.level
    gl.level_info       -> svl.level_info
    gm.mapseenchn       -> svm.mapseenchn
    gm.moves            -> svm.moves
    gm.mvitals          -> svm.mvitals
    gn.n_dgns           -> svn.n_dgns
    gn.n_regions        -> svn.n_regions
    gn.nroom            -> svn.nroom
    go.oracle_cnt       -> svo.oracle_cnt
    gp.pl_character     -> svp.pl_character
    gp.pl_fruit         -> svp.pl_fruit
    gp.plname           -> svp.plname
    gp.program_state    -> svp.program_state
    gq.quest_status     -> svq.quest_status
    gr.rooms            -> svr.rooms
    gs.sp_levchn        -> svs.sp_levchn
    gs.spl_book         -> svs.spl_book
    gt.timer_id         -> svt.timer_id
    gt.tune             -> svt.tune
    gu.updest           -> svu.updest
    gx.xmax             -> svx.xmax
    gx.xmin             -> svx.xmin
    gy.ymax             -> svy.ymax
    gy.ymin             -> svy.ymin

Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
          gf.ftrap, gl.light_base, gt.timer_base
2024-07-13 14:57:50 -04:00