Commit Graph
195 Commits
Author SHA1 Message Date
Ingo Paschke 6736f878aa Amiga: graphical tombstone RTG-screen fallback
amii_outrip relies on LoadRGB4/transpalette fade and raw BltBitMap
to a SMART_REFRESH window -- chipset-era idioms that do not reach
the visible display on Picasso96 or CyberGraphX screens.  On RTG
the screen stayed black and the user saw nothing between the
death messages and the high-score list.  Detect RTG by screen
size > 800x600 and fall through to genl_outrip so RTG users get
the ASCII tombstone instead.

Switch the still-graphical path to BltBitMapRastPort so the blit
goes through the layer system, and move CloseWindow(ripwin)
outside the Forbid()/Permit() pair (same fix as amii_cleanup).

Rename cmap_white/cmap_black to cmap_outline/cmap_fill -- those
variables actually hold the indices of the darkest and lightest
palette entries, used for the four offset outline strokes and
the centered fill stroke respectively; the old names were
backwards.
2026-05-12 15:33:29 +02:00
Ingo Paschke 89971a5fc9 Amiga: fix extended-command menu mouse-pick
The amii_get_ext_cmd menu used the first character of each command
as the item identity (id.a_char) and then linearly searched
extcmdlist for the first command starting with that character.
Many commands share a first letter, so picking #airlevel returned
#adjust, #wipe returned #wear, etc.  Store the actual index in
id.a_int and read it back directly.

While in that function, size obufp at BUFSZ (was 100) and replace
the unbounded strcpy from extcmdlist[i].ef_txt with strncpy +
explicit NUL.
2026-05-12 15:31:44 +02:00
Ingo Paschke 146fbf20d8 Amiga: clamp amii_numcolors and guard tile CMAP loop
Reject tile/tomb IFF files whose nPlanes field exceeds DEPTH:
the CMAP loop writes 1<<np entries into amii_initmap[] /
amiv_init_map[], both sized AMII_MAXCOLORS = 1<<DEPTH = 64, so
a malformed file with nPlanes >= 7 would corrupt adjacent BSS.

After OpenScreen succeeds, clamp amii_numcolors to the actually
populated portion of the init-map arrays (AMII_PALETTE_SIZE for
text mode, AMIV_PALETTE_SIZE for tile mode).  On a 64-color
screen this stops LoadRGB4 from loading the zero-initialized
tail entries as black.  Replace the matching magic 32 in the
tilefile selection with AMIV_PALETTE_SIZE.

While there, add the (char) cast on amii_glyph_buffer's
truncating assignment to make the contract explicit.
2026-05-12 15:30:48 +02:00
Ingo Paschke 459113a48e Amiga: fix --more-- infinite loop on overlong words
When a single word exceeds the visible message-window width the
wrap loop found no whitespace, called outmore(cw), and continued
without advancing str -- and on the next iteration curx==0 took
it straight back to the same spot.  Force-break the word at the
column boundary when we are already at the start of a line.

Also reset the wrapping static flag to 0 after the NHW_BASE wrap
cleanup runs, so the cleanup fires once after a wrap instead of
on every subsequent putstr.
2026-05-12 15:29:37 +02:00
Ingo Paschke 4e63ba90ca Amiga: bound BufferQueueChar; move CloseWindow out of Forbid()
Make the BufferQueueChar macro bounds-check KbdBuffered against
KBDBUFFER internally so the RAWKEY and NEWSIZE 'R'-64 paths can
no longer push past the 10-byte queue; widen KbdBuffered to int
so the counter cannot wrap silently in the queue-scan loops.

In amii_cleanup move kill_nhwindows()/DeleteMsgPort() outside
the Forbid()/Permit() pair: CloseWindow can wait on layers.library
semaphores on OS 3.x and that is unsafe under Forbid.  Keep only
the IDCMP-flush loop inside.
2026-05-12 15:28:43 +02:00
Ingo Paschke 252ca5bef7 Amiga: defensive NULL/bounds guards in menus and window creation
Guard the gd lookup in DoMenuScroll's GADGETUP/MOUSEMOVE branches
so a window with no GadgetID==1 does not deref NULL; match the
existing guards in the keyboard-scroll branches.  In the keyboard
selector and MENU_UNSELECT_ALL paths, only mutate items with
canselect set so a non-selectable header cannot have its str
stomped.  Clamp MENU_LAST_PAGE topidx to >= 0.  Make find_menu_item
return NULL on negative idx instead of the head item.  Guard the
PROMPTFIRST data[] shuffle behind cury > 0.

In amii_destroy_nhwindow's NHW_OVER branch use cw->win with a NULL
guard instead of dereferencing amii_wins[WIN_OVER]->win blindly.
Range-check the type argument to amii_create_nhwindow.  Fix the
*argv_in[1] precedence bug so the -L/-l flag does not deref NULL
when it is the last argument.  Wrap AllocAslRequest result in a
NULL check before AslRequestTags/FreeAslRequest.

Defensively bounds-check the idx argument to DispCol.  Replace
the -25937 signed-int literal in clipwin's PropInfo with the
equivalent UWORD value 39599.  Simplify amii_start_menu's free
loop; switch DoMenuScroll's inventory title and Count display to
Snprintf, and stop passing countString to pline as a format.
2026-05-12 15:27:13 +02:00
Ingo Paschke 15e3973ac2 Amiga: tighten input/dialog buffer bounds
Right-size the Intuition string-gadget buffer to BUFSZ so a caller
with a BUFSZ-sized buffer cannot be overflowed.  Enlarge the
amii_yn_function prompt buffer to fit the worst-case query + resp
+ def + trailing space and switch the appends to Snprintf with
remaining-space tracking.  Replace sprintf in amii_display_file's
"Can't display X: Y" path with Snprintf.  In EditColor's Save path
drop the strcpy/strcat chain that could trail off the end of
oname/nname when dirname returned a near-full path; use Snprintf
instead.  Rewrite dirname() to copy first and truncate the copy,
so it no longer briefly NULs the caller's string.
2026-05-12 15:24:15 +02:00
Ingo Paschke d99eeb17c2 Amiga: header hygiene and palette-size constants
Add AMII_PALETTE_SIZE / AMIV_PALETTE_SIZE in amiconf.h to make the
actual populated portion of the init-map arrays explicit.  Drop the
redundant extern void exit() declaration.  Annotate Abort with
NORETURN in both amiconf.h and winproto.h; drop the duplicate Abort
declaration further down winproto.h.

Convert the bare-token "CLIPPING must be defined" assertion in
windefs.h into a real #error directive.

Comment in winext.h to disambiguate the three similarly named
amii*_init*map palette arrays.
2026-05-12 15:21:23 +02:00
Ingo Paschke ebcf31a4da Amiga: drop UNTESTED AROS path; tighten fopenp separator write
The UNTESTED #ifdef in freediskspace was never gated by any hints
file, so the unsigned-long-long path could only be enabled by a
stray manual #define -- in which case the return type is still
long and silently truncates.  Remove the branches.

In fopenp the separator '/' write was unchecked: when the path
segment exactly filled the buffer to BUFSIZ-2 it would land at
buf[BUFSIZ-1] and the follow-on NUL would write past the end.
Guard the write.
2026-05-12 15:19:28 +02:00
Ingo Paschke 157c005f02 Amiga: harden host-side bmp/xpm to iff converters
Replace #pragma-pack BMP header reads with little-endian byte
readers so the tool works on any host endianness.  Add dimension
and color-count range checks, zero-init pixel remap table, check
calloc, free bmpdata on early returns, send malloc errors to
stderr.  Add bp>xbuf guards to xpmgetline's strip loop.
2026-05-12 15:18:44 +02:00
Ingo Paschke cb46d9effd Amiga: tighten two minor issues from review
- amii_set_text_font called CloseLibrary(DiskfontBase) outside the
  OpenLibrary guard; on Kickstart V36+ that is a no-op for a NULL
  handle, but on V33/V34 it is undefined.  Move the close inside
  the if-block where DiskfontBase is known non-NULL.
- amii_get_ext_cmd's bounds check used BUFSZ for an obufp[100]
  buffer; the tighter COLNO check actually bounded it but the
  expression was misleading.  Use sizeof obufp.
2026-05-12 15:12:07 +02:00
Ingo Paschke 74c87caac3 Amiga: fix bitmap/IFF resource handling in winchar.c
- MyAllocBitMap left bm->bm.Planes[] uninitialized; InitBitMap only
  fills BytesPerRow/Rows/Flags/Depth, not Planes[].  If AllocRaster
  fails mid-loop, MyFreeBitMap was iterating up to Depth and would
  pass uninitialized stack-garbage pointers to FreeRaster.  Zero
  Planes[] before the alloc loop.
- ReadImageFile leaked iffparse.library, the IFFHandle, the DOS file
  handle, and any open-IFF state on every panic path.  On AmigaOS
  those handles are not auto-reclaimed when the process dies, so
  each failure stranded resources until reboot.  Restructure to a
  single cleanup label and free in reverse-acquisition order before
  panicking.
- OpenIFF returns an error code that was being thrown away, so a
  failed open would feed corrupt state to ParseIFF.  Check and
  bail.
2026-05-12 15:12:07 +02:00
Ingo Paschke f583787825 Amiga: fix overview-window crashes
- MyAllocBitMap left bm->mflags uninitialized, so MyFreeBitMap took the
  wrong path between FreeRaster and FreeMem and intermittently corrupted
  exec's free list (Software Failure 0x81000005, DEADEND in FreeMem).
- The NHW_OVER window is BORDERLESS, so attaching WINDOWSIZING |
  WINDOWDRAG | WINDOWCLOSE created phantom gadgets that hit-test against
  unrelated input.  Pressing ESC while the overview was selected fired
  CLOSEWINDOW and destroyed the window underneath the running code,
  leading to wild-PC crashes.  Drop the gadget flags; SHIFT-HELP already
  toggles the overview cleanly via delayed_key_action.
- amii_destroy_nhwindow only reset WIN_MAP / WIN_STATUS / WIN_MESSAGE /
  WIN_INVEN; WIN_OVER and WIN_BASE kept pointing at freed slots, so any
  later 'WIN_X != WIN_ERR && amii_wins[WIN_X]->win' check dereferenced
  NULL.  Reset them too.
2026-05-12 15:12:07 +02:00
Ingo Paschke 657f6eaad9 Amiga: fix latent issues found in code review
- fname[18]/sprintf risks overflow for >=10 in any version field;
  switch to snprintf into a wider static buffer.
- (1L << i) for i==31 (or shifting into the depth-loop terminator)
  is undefined for signed long; use 1UL.
- Drop unused cnt= from amii_display_nhwindow's DoMenuScroll call;
  the menu return value is consumed elsewhere, not here.
2026-05-12 15:12:07 +02:00
Ingo Paschke 1cfff0f002 Amiga: correct command-line flag doc in amii.hlp
Wizard mode is gated on player name == WIZARD_NAME, not on -D or
-debug.  Document -uwizard as the working entry point.
2026-05-11 20:51:06 +02:00
Ingo Paschke 2e61bf768f Amiga: fix port_help double-prefix path
display_file -> dlb_fopen -> fopen_datafile already prepends DATAPREFIX;
wrapping PORT_HELP in fqname() too produced "NetHack:NetHack:amii.hlp".
2026-05-11 20:51:06 +02:00
Ingo Paschke 344063afb6 Amiga: route non-menu messages from DoMenuScroll to ProcessMessage
DoMenuScroll dropped IDCMP messages for non-owner windows -- so a
resize of WIN_INVEN or close-gadget on WIN_OVER during a menu never
reached the game state.  Forward those to ProcessMessage;
VANILLAKEY/RAWKEY stay with the menu.
2026-05-11 20:51:06 +02:00
Ingo Paschke 8dbbbc2fef Amiga: deduplicate amii_procs and amiv_procs
Factor common body into AMI_WIN_PROCS_BODY.  The POSITIONBAR / CLIPPING /
CHANGE_COLOR guards in the original were dead.
2026-05-11 20:51:06 +02:00
Ingo Paschke c85a8cf607 Amiga: drop redundant 'either windowtype' guards
Six if(WINVERS_AMIV || WINVERS_AMII) sites are always true with
amitty.c gone.
2026-05-11 20:51:06 +02:00
Ingo Paschke 5d86dfccb5 Amiga: replace WINVERS_AMI* strcmp with WINDOWPORT() id compare
The macros were strcmp("amiv", windowprocs.name)==0 at every reference
-- 72 sites including inner loops.  Use the 5.0 core's WINDOWPORT(wn)
which compares wp_id.
2026-05-11 20:51:06 +02:00
Ingo Paschke 688f9344cd Amiga: route port paths through fqname()
Tile loading hard-coded "NetHack:tiles/tiles{16,32}.iff" and PORT_HELP
hard-coded "nethack:amii.hlp".  Route through fqname(DATAPREFIX) so
DATADIR= overrides apply.  Refresh amii.hlp to 5.0 content, ship it via
amigapkg, and document HACKDIR / SAVEDIR / BONESDIR examples in
nethack.cnf.
2026-05-11 20:51:06 +02:00
Ingo Paschke c5d8ab1985 Amiga: collapse #ifndef CROSS_TO_AMIGA include forks
Every #include block had a paired NH: assign path for native builds.
Only the cross-compile path is built now.
2026-05-11 20:43:08 +02:00
Ingo Paschke 94a74b84d8 Amiga: drop OPT_DISPMAP / display_map / fast_map machinery
display_map() was never integrated; no .c defines it.  All OPT_DISPMAP /
DISPMAP / sysflags.fast_map conditionals were unreachable.
2026-05-11 20:43:08 +02:00
Ingo Paschke 7b559f4d02 Amiga: delete dead files and dead-macro code
Delete amigst.c (empty) and amitty.c (TTY/BBS stub).  Drop WINVERS_AMIT,
SUPERBITMAP_MAP, EXTMENU, SHELL/dosh(), and the bbs_id reference in
src/files.c.
2026-05-11 20:30:45 +02:00
Ingo Paschke beaed3aa08 Amiga: delete the .p prototype headers
amidos.p, amiwind.p, winami.p duplicated and partly contradicted
winproto.h.  Switch amidos.c and amigst.c to winproto.h.
2026-05-11 20:30:45 +02:00
Ingo Paschke e90a297021 Amiga: drop #if 0 dead-code blocks
Includes a dead amii_player_selection / RandomWindow pair (~280 lines),
eraseall / CopyFile in amidos.c, and smaller fragments.
2026-05-11 20:30:45 +02:00
Ingo Paschke 00433c7998 Amiga: drop TESTING dev toggle in winchar.c 2026-05-11 20:30:45 +02:00
Ingo Paschke a8e54185eb Amiga: drop SHAREDLIB dead build flavor 2026-05-11 20:29:47 +02:00
Ingo Paschke 7b67da20b7 Amiga: make INTUI_NEW_LOOK unconditional
OS 2.0+ Intuition is required; the pre-2.0 fallback paths are unreachable.
2026-05-11 20:29:47 +02:00
Ingo Paschke f0b6ddc6f8 Amiga: drop legacy non-gcc compiler guards
Remove AZTEC_C, _DCC, SASC, LATTICE, MANX arms. The port targets bebbo gcc.
2026-05-11 20:29:47 +02:00
Ingo Paschke 22ddba7c1e Amiga: more review fixes
- NHW_BASE / NHW_OVER collided with NHW_PERMINVENT=6; renumber off NHW_LAST_TYPE.
- GlyphToIcon used > 10000 instead of >=.
- make_menu_items sized array by sizeof(amii_menu_item) instead of menu_item.
- DoMenuScroll could deref NULL amip on SELECTUP.
- get_nhuuid uses ISAAC64 rn2() instead of hand-rolled LCG.
- fopenp's bound check fired one byte too late.
- winami.p had stale signatures for amii_end_menu, amii_select_menu, amii_suspend_nhwindows.
2026-05-11 20:29:47 +02:00
Ingo Paschke f8ea34489f Amiga: fix three latent bugs found in code review
amiv_lprint_glyph used uninitialized 'base'; amii_clear_nhwindow
compared cw->type to a winid; amii_sethipens fell through.
2026-05-11 20:29:47 +02:00
nhmall a583201f15 check malloc() return in bmp2iff_host.c 2026-05-11 06:34:20 -04:00
nhmall aa63616118 spelling correction 2026-05-10 11:36:43 -04:00
nhmall edafe39f5d add awareness of possible updated binary with numeric suffix
Close #1514
2026-05-10 09:07:10 -04:00
Ingo Paschke c1ae9d5d8c Amiga: restore glyph icons in menus
Core changes routed transient inventory away from WIN_INVEN, so the
port's win == WIN_INVEN gate stopped matching and glyphs vanished.
Track has_glyphs on the menu and key rendering and sizing off that.
2026-05-09 17:11:33 +02:00
Ingo Paschke ed4d100459 Amiga: provide a real v4 UUID via get_nhuuid 2026-05-04 19:13:48 +02:00
Ingo Paschke 5852e8c2a0 Amiga: ship as a NetHack drawer with drawer icon and README 2026-05-04 15:43:12 +02:00
Ingo Paschke d94fb08f8b Amiga: ship Workbench icons for the binary and text files 2026-05-04 15:33:20 +02:00
Ingo Paschke 9a909be7c5 Amiga: auto-assign NetHack: to the program directory 2026-05-04 15:33:14 +02:00
Ingo Paschke 82efba55f2 Amiga: fix misleading fallback warning and stale comment 2026-05-04 12:42:36 +02:00
Ingo Paschke b72f5cb9a2 Amiga: stop rendering CLR_BLACK and CLR_WHITE as inverse video 2026-05-04 12:42:10 +02:00
Ingo Paschke 548f356cbd Amiga: default number_pad:1 in shipped nethack.cnf 2026-05-04 12:38:21 +02:00
Ingo Paschke b6747f89ca Amiga: fall back to text mode when tile mode is not viable
Detect Workbench depth, display-database MaxDepth, and free chip RAM;
if any signals AMIV can't run (e.g. A1000 with 4-colour WB), swap
windowprocs to amii_procs before opening any screens.
2026-05-03 18:01:07 +02:00
Ingo Paschke d9da319622 Amiga: honor __stack under libnix
Reference __stkinit so the linker pulls swapstack.o from libnix.a;
without it the program runs on the inherited shell stack and crashes
inside Lua / level-gen.
2026-05-03 17:48:15 +02:00
nhmall 3cb7bfc0b3 more sys 2026-04-26 11:08:10 -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 b58d2d4096 try to reduce some Amiga cross-compile warnings 2026-03-25 08:48:14 -04:00
nhmall 7f8f7c54dc Files identification update 2026-03-24 07:13:04 -04:00