diff --git a/include/winami.h b/include/winami.h index 686d37f91..913b130c3 100644 --- a/include/winami.h +++ b/include/winami.h @@ -117,8 +117,8 @@ typedef struct WEVENT { /* port specific variable declarations */ extern winid WIN_BASE; extern winid WIN_OVER; -#define NHW_BASE 6 -#define NHW_OVER 7 /* overview window */ +#define NHW_BASE (NHW_LAST_TYPE + 1) +#define NHW_OVER (NHW_LAST_TYPE + 2) /* overview window */ extern struct amii_WinDesc *amii_wins[MAXWIN + 1]; diff --git a/sys/amiga/amidos.c b/sys/amiga/amidos.c index c06fc1b1c..9de6a0810 100644 --- a/sys/amiga/amidos.c +++ b/sys/amiga/amidos.c @@ -47,30 +47,19 @@ amiga_self_assign(void) UnLock(dup); } -/* Generate an RFC 4122 v4 UUID for this game. Entropy comes from - DateStamp + the running task's address mixed through a small LCG. */ +/* Generate an RFC 4122 v4 UUID for this game. Draw bytes from the + core's ISAAC64 RNG, which init_random() seeded before we get here. */ void get_nhuuid(void) { uchar bytes[16]; - struct DateStamp ds; - unsigned long x; int i; if (svn.nhuuid[0]) return; - DateStamp(&ds); - x = (unsigned long) ds.ds_Days - ^ ((unsigned long) ds.ds_Minute << 16) - ^ ((unsigned long) ds.ds_Tick << 8) - ^ (unsigned long) FindTask(NULL); - /* Classic glibc/POSIX rand() LCG (Knuth, C99 7.22.2.1). Full period - 2^32; we read bits 16-23 to skip the LCG's bad low bits. */ - for (i = 0; i < 16; i++) { - x = x * 1103515245u + 12345u; - bytes[i] = (uchar) (x >> 16); - } + for (i = 0; i < 16; i++) + bytes[i] = (uchar) rn2(256); /* RFC 4122: version=4 (random), variant=10. */ bytes[6] = (bytes[6] & 0x0F) | 0x40; bytes[8] = (bytes[8] & 0x3F) | 0x80; @@ -481,7 +470,7 @@ fopenp(const char *name, const char *mode) while (pp && *pp) { bp = buf; while (*pp && *pp != PATHSEP) { - if (bp > buf + BUFSIZ - 1) + if (bp >= buf + BUFSIZ - 1) return (NULL); lastch = *bp++ = *pp++; } diff --git a/sys/amiga/winamenu.c b/sys/amiga/winamenu.c index 9cc2a0fb3..6d2310bc4 100644 --- a/sys/amiga/winamenu.c +++ b/sys/amiga/winamenu.c @@ -215,7 +215,7 @@ make_menu_items(struct amii_WinDesc *cw, menu_item **rmip) } if (idx) { - mmip = *rmip = (menu_item *) alloc(idx * sizeof(*mip)); + mmip = *rmip = (menu_item *) alloc(idx * sizeof(menu_item)); for (mip = cw->menu.items; mip; mip = mip->next) { if (mip->selected) { mmip->item = mip->identifier; @@ -982,8 +982,8 @@ DoMenuScroll(int win, int blocking, int how, menu_item **retmip) amip->str[SOFF + 2] = '-'; } } - if (counting && amip->selected && amip->canselect - && amip->selector) { + if (amip && counting && amip->selected + && amip->canselect && amip->selector) { amip->count = count; reset_counting = TRUE; amip->str[SOFF + 2] = '#'; diff --git a/sys/amiga/winami.c b/sys/amiga/winami.c index 7770a3547..e1276e986 100644 --- a/sys/amiga/winami.c +++ b/sys/amiga/winami.c @@ -340,6 +340,11 @@ struct win_setup new_wins[] = { 22, 78 }, + /* NHW_PERMINVENT — placeholder; port does not implement persistent + inventory yet, but the slot must exist because new_wins[] is + indexed by NHW_* type. */ + { { 0 } }, + /* NHW_BASE */ { { 0, 0, WIDTH, WINDOWHEIGHT, 0xff, 0xff, RAWKEY | MENUPICK | MOUSEBUTTONS, diff --git a/sys/amiga/winami.p b/sys/amiga/winami.p index dfb588177..57b9af93c 100644 --- a/sys/amiga/winami.p +++ b/sys/amiga/winami.p @@ -6,8 +6,8 @@ void amii_raw_print(const char *); void amii_raw_print_bold(const char *); void amii_start_menu(winid , unsigned long ); void amii_add_menu(winid, const glyph_info *, const anything *, char, char, int, int, const char *, unsigned int); -void amii_end_menu(winid , char , const char * , const char *); -char amii_select_menu(winid ); +void amii_end_menu(winid, const char *); +int amii_select_menu(winid, int, menu_item **); void amii_update_inventory(int); void amii_mark_synch (void); void amii_wait_synch (void); @@ -46,7 +46,7 @@ void cursor_on(winid ); void amii_getret (void); void amii_getlin(const char * , char *); void getlind(const char * , char * , const char *); -void amii_suspend_nhwindows(char * ); +void amii_suspend_nhwindows(const char *); void amii_resume_nhwindows(void); void amii_bell(void); void EditColor(void); diff --git a/sys/amiga/winchar.c b/sys/amiga/winchar.c index 1b62c390f..7e17ea574 100644 --- a/sys/amiga/winchar.c +++ b/sys/amiga/winchar.c @@ -805,7 +805,7 @@ GlyphToIcon(int glyph) glyph_info gi; map_glyphinfo(0, 0, glyph, 0, &gi); - if (glyph > 10000) + if (glyph >= 10000) return glyph; return (gi.gm.tileidx); }