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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
- 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.
- 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.
- 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.
- 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.
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.
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.
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.
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.
- 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.
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.
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.
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.