Skip to content

Commit 9a86cc2

Browse files
author
Hugh Robinson
committed
On menu screens, read Unicode key value instead of keynumber (Peter de Wachter).
1 parent 993c521 commit 9a86cc2

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

asylum.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ int main(int argc, char** argv)
480480

481481
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
482482
SDL_WM_SetCaption("Asylum", "Asylum");
483+
SDL_EnableUNICODE(1);
483484
#ifndef _NO_SOUND
484485
init_audio();
485486
#endif

asylum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ void swi_stasis_control(int a, int b);
495495
void swi_stasis_volslide(int a, int b, int c);
496496
void swi_removecursors();
497497
int osbyte_79(int c);
498+
int osbyte_79_unicode(int c);
498499
int osbyte_7a();
499500
void osbyte_7c();
500501
int osbyte_81(int c);

keyboard.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
extern asylum_options options;
2121

22-
char keyboard[512];
23-
int keybuf;
24-
int mouse;
22+
static char keyboard[512];
23+
static int keybuf;
24+
static int unibuf;
25+
static int mouse;
2526

2627
#define ESC_VALUE 27
2728

@@ -54,6 +55,14 @@ int osbyte_79(int c)
5455
return -1;
5556
}
5657

58+
int osbyte_79_unicode(int c)
59+
{
60+
update_keyboard();
61+
int uni = unibuf;
62+
unibuf = -1;
63+
return uni;
64+
}
65+
5766
int osbyte_7a()
5867
{
5968
update_keyboard(); for (int i = 0; i < 512; i++) if (keyboard[i]) return i;return -1;
@@ -96,6 +105,10 @@ void update_keyboard()
96105
ke = (SDL_KeyboardEvent*)&e;
97106
keyboard[ke->keysym.sym] = 0xff;
98107
keybuf = ke->keysym.sym;
108+
if (ke->keysym.unicode)
109+
unibuf = ke->keysym.unicode;
110+
else
111+
unibuf = -1;
99112
break;
100113
case SDL_KEYUP:
101114
ke = (SDL_KeyboardEvent*)&e;
@@ -128,7 +141,7 @@ void update_keyboard()
128141

129142
void zonecheatread(int* zone)
130143
{
131-
char r1 = osbyte_7a(); // was _81(0)
144+
char r1 = osbyte_79_unicode(0); // was _81(0)
132145

133146
if ((r1 < 48) || (r1 > 56)) return;
134147
*zone = r1-48;

menus.c

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,17 @@ int escapehandler()
5454
swi_fastspr_clearwindow();
5555
texthandler();
5656
}
57-
esctextstop:
58-
if (osbyte_81(-113))
57+
switch (osbyte_79_unicode(1))
5958
{
60-
loselife(); return 0;
61-
}
62-
if (osbyte_81(-111))
63-
{
64-
adjustopt(); return 0;
65-
}
66-
if (osbyte_81(-114))
67-
{
68-
rejoin(); return 0;
59+
case 'q': case 'Q':
60+
loselife();
61+
return 0;
62+
case 'o': case 'O':
63+
adjustopt();
64+
return 0;
65+
case 'r': case 'R':
66+
rejoin();
67+
return 0;
6968
}
7069
}
7170
osbyte_7c();
@@ -478,7 +477,7 @@ int readopt(int maxopt)
478477
{
479478
int r1;
480479

481-
do
480+
for (;;)
482481
{
483482
keyloop:
484483
if (options.joyno != 0)
@@ -488,27 +487,18 @@ int readopt(int maxopt)
488487
//if (r0&(1<<16)) {/*optfire:*/ return 0;}
489488
}
490489
nooptstick:
491-
r1 = osbyte_81(1); // read key in time limit
492-
// if (r1!=0xff) printf("%i\n",r1);
490+
r1 = osbyte_79_unicode(1); // read key in time limit
493491
if (swi_readescapestate())
494492
{
495493
optescape:
496494
osbyte_7c(); // clear escape
497495
return -1;
498496
}
499-
if (r1 == 0) continue;
497+
if (r1 >= '0' && r1 <= '0' + maxopt)
498+
return r1 - '0';
500499
if (osbyte_81(options.firekey) == 0xff)
501500
return 0;
502-
if (r1 >= SDLK_0 && r1 <= SDLK_9)
503-
r1 -= SDLK_0;
504-
else if (r1 >= SDLK_KP0 && r1 <= SDLK_KP9)
505-
r1 -= SDLK_KP0;
506-
else
507-
continue;
508501
}
509-
while (!((r1 >= 0) && (r1 <= maxopt)));
510-
optexit:
511-
return r1;
512502
}
513503

514504
const int _x = 250;
@@ -559,8 +549,8 @@ int prelude()
559549
if (readmousestate()&2)
560550
{
561551
gocheat:
562-
if (osbyte_81(-307) != 0xff) return cheatpermit;
563-
if (osbyte_81(-308) != 0xff) return cheatpermit;
552+
if (osbyte_81(-SDLK_LALT) != 0xff) return cheatpermit;
553+
if (osbyte_81(-SDLK_RALT) != 0xff && osbyte_81(-SDLK_MODE) != 0xff) return cheatpermit;
564554
cheatpermit = 1;
565555
scroll = 1024;
566556
}

0 commit comments

Comments
 (0)