Files
nethack/sys/amiga/winkey.c
Ingo Paschke 2d597cb9fa Revive Amiga port for NetHack 3.7
Update the Amiga Intuition window port (AMII/AMIV) for the 3.7
window_procs API. Key changes:

- Update all window function signatures for 3.7
- Add assembly trampolines for AmigaOS register-based callbacks
- Convert all K&R function definitions to C99
- Add cross-compilation build system (cross-pre1/pre2/post.370)
  using bebbo's m68k-amigaos-gcc with -noixemul -std=gnu17 -m68000
- Clipping fixes: viewport centering, simplified ScrollRaster,
  duplicate Ctrl-R suppression, glyph buffer invalidation
- Add menucolor support in menu rendering
- Move native txt2iff.c and xpm2iff.c to outdated/
- Add nethack.cnf and README.amiga
2026-03-23 20:48:06 +01:00

104 lines
2.4 KiB
C

/* NetHack 3.6 winkey.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef CROSS_TO_AMIGA
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
int
amii_nh_poskey(coordxy *x, coordxy *y, int *mod)
{
struct amii_WinDesc *cw;
WETYPE type;
struct RastPort *rp;
struct Window *w;
/* No entry log for nh_poskey -- too noisy (called constantly) */
if (cw = amii_wins[WIN_MESSAGE]) {
cw->wflags &= ~FLMAP_SKIP;
if (scrollmsg)
cw->wflags |= FLMSG_FIRST;
cw->disprows = 0;
}
if (WIN_MAP != WIN_ERR && (cw = amii_wins[WIN_MAP]) && (w = cw->win)) {
cursor_on(WIN_MAP);
} else
panic("no MAP window opened for nh_poskey\n");
rp = w->RPort;
while (1) {
type = WindowGetevent();
if (type == WEMOUSE) {
*mod = CLICK_1;
if (lastevent.un.mouse.qual)
*mod = 0;
/* X coordinates are 1 based, Y are 1 based. */
*x = ((lastevent.un.mouse.x - w->BorderLeft) / mxsize) + 1;
*y = ((lastevent.un.mouse.y - w->BorderTop - MAPFTBASELN)
/ mysize) + 1;
#ifdef CLIPPING
if (clipping) {
*x += clipx;
*y += clipy;
}
#endif
return (0);
} else if (type == WEKEY) {
lastevent.type = WEUNK;
return (lastevent.un.key);
}
}
}
int
amii_nhgetch(void)
{
int ch;
struct amii_WinDesc *cw = amii_wins[WIN_MESSAGE];
/* No entry log for nhgetch -- too noisy (called constantly) */
if (WIN_MAP != WIN_ERR && amii_wins[WIN_MAP]) {
cursor_on(WIN_MAP);
}
if (cw)
cw->wflags &= ~FLMAP_SKIP;
ch = WindowGetchar();
return (ch);
}
void
amii_get_nh_event(void)
{
/* nothing now - later I have no idea. Is this just a Mac hook? */
}
void
amii_getret(void)
{
int c;
raw_print("");
raw_print("Press Return...");
c = 0;
while (c != '\n' && c != '\r') {
if (HackPort)
c = WindowGetchar();
else
c = getchar();
}
return;
}