@@ -2470,7 +2470,8 @@ int gettile(int tilenum)
24702470 topleft = ((tilenum /(xtiles <<gettilezoom ))* (xtiles <<gettilezoom ))- (xtiles <<gettilezoom );
24712471 if (topleft < 0 ) topleft = 0 ;
24722472 if (topleft > MAXTILES - (tottiles <<(gettilezoom <<1 ))) topleft = MAXTILES - (tottiles <<(gettilezoom <<1 ));
2473- while ((keystatus [0x1c ]|keystatus [1 ]) == 0 )
2473+ bflushkeys ();
2474+ while (1 )
24742475 {
24752476 drawtilescreen (topleft ,tilenum );
24762477 OSD_Draw ();
@@ -2479,47 +2480,49 @@ int gettile(int tilenum)
24792480 if (handleevents ()) {
24802481 if (quitevent ) quitevent = 0 ;
24812482 }
2483+ ch = bgetkey ();
2484+ if (ch == 0x1c || ch == 0x1 ) break ;
24822485
24832486 synctics = totalclock - lockclock ;
24842487 lockclock += synctics ;
24852488
2486- if ((keystatus [ 0x37 ] > 0 ) && (gettilezoom < 2 ))
2489+ if ((ch == 0x37 ) && (gettilezoom < 2 ))
24872490 {
24882491 gettilezoom ++ ;
24892492 topleft = ((tilenum /(xtiles <<gettilezoom ))* (xtiles <<gettilezoom ))- (xtiles <<gettilezoom );
24902493 if (topleft < 0 ) topleft = 0 ;
24912494 if (topleft > MAXTILES - (tottiles <<(gettilezoom <<1 ))) topleft = MAXTILES - (tottiles <<(gettilezoom <<1 ));
24922495 keystatus [0x37 ] = 0 ;
24932496 }
2494- if ((keystatus [ 0xb5 ] > 0 ) && (gettilezoom > 0 ))
2497+ if ((ch == 0xb5 ) && (gettilezoom > 0 ))
24952498 {
24962499 gettilezoom -- ;
24972500 topleft = ((tilenum /(xtiles <<gettilezoom ))* (xtiles <<gettilezoom ))- (xtiles <<gettilezoom );
24982501 if (topleft < 0 ) topleft = 0 ;
24992502 if (topleft > MAXTILES - (tottiles <<(gettilezoom <<1 ))) topleft = MAXTILES - (tottiles <<(gettilezoom <<1 ));
25002503 keystatus [0xb5 ] = 0 ;
25012504 }
2502- if ((keystatus [ 0xcb ] > 0 ) && (tilenum > 0 ))
2505+ if ((ch == 0xcb ) && (tilenum > 0 ))
25032506 tilenum -- , keystatus [0xcb ] = 0 ;
2504- if ((keystatus [ 0xcd ] > 0 ) && (tilenum < MAXTILES - 1 ))
2507+ if ((ch == 0xcd ) && (tilenum < MAXTILES - 1 ))
25052508 tilenum ++ , keystatus [0xcd ] = 0 ;
2506- if ((keystatus [ 0xc8 ] > 0 ) && (tilenum >= (xtiles <<gettilezoom )))
2509+ if ((ch == 0xc8 ) && (tilenum >= (xtiles <<gettilezoom )))
25072510 tilenum -= (xtiles <<gettilezoom ), keystatus [0xc8 ] = 0 ;
2508- if ((keystatus [ 0xd0 ] > 0 ) && (tilenum < MAXTILES - (xtiles <<gettilezoom )))
2511+ if ((ch == 0xd0 ) && (tilenum < MAXTILES - (xtiles <<gettilezoom )))
25092512 tilenum += (xtiles <<gettilezoom ), keystatus [0xd0 ] = 0 ;
2510- if ((keystatus [ 0xc9 ] > 0 ) && (tilenum >= (xtiles <<gettilezoom )))
2513+ if ((ch == 0xc9 ) && (tilenum >= (xtiles <<gettilezoom )))
25112514 {
25122515 tilenum -= (tottiles <<(gettilezoom <<1 ));
25132516 if (tilenum < 0 ) tilenum = 0 ;
25142517 keystatus [0xc9 ] = 0 ;
25152518 }
2516- if ((keystatus [ 0xd1 ] > 0 ) && (tilenum < MAXTILES - (xtiles <<gettilezoom )))
2519+ if ((ch == 0xd1 ) && (tilenum < MAXTILES - (xtiles <<gettilezoom )))
25172520 {
25182521 tilenum += (tottiles <<(gettilezoom <<1 ));
25192522 if (tilenum >= MAXTILES ) tilenum = MAXTILES - 1 ;
25202523 keystatus [0xd1 ] = 0 ;
25212524 }
2522- if (keystatus [ 0x2f ] > 0 ) //V
2525+ if (ch == 0x2f ) //V
25232526 {
25242527 keystatus [0x2f ] = 0 ;
25252528 if (tilenum < localartlookupnum )
@@ -2530,7 +2533,7 @@ int gettile(int tilenum)
25302533 for (i = 0 ;i < MAXTILES ;i ++ )
25312534 localartlookup [i ] = i ;
25322535 }
2533- if (keystatus [ 0x22 ] > 0 ) //G (goto)
2536+ if (ch == 0x22 ) //G (goto)
25342537 {
25352538 if (tilenum < localartlookupnum ) //Automatically press 'V'
25362539 tilenum = localartlookup [tilenum ];
@@ -2567,15 +2570,17 @@ int gettile(int tilenum)
25672570 break ;
25682571 }
25692572 }
2573+ ch = 0 ;
25702574 clearkeys ();
2575+ bflushkeys ();
25712576 }
25722577 while (tilenum < topleft ) topleft -= (xtiles <<gettilezoom );
25732578 while (tilenum >= topleft + (tottiles <<(gettilezoom <<1 ))) topleft += (xtiles <<gettilezoom );
25742579 if (topleft < 0 ) topleft = 0 ;
25752580 if (topleft > MAXTILES - (tottiles <<(gettilezoom <<1 ))) topleft = MAXTILES - (tottiles <<(gettilezoom <<1 ));
25762581 }
25772582
2578- if (keystatus [ 0x1c ] == 0 )
2583+ if (ch == 0x1 )
25792584 {
25802585 tilenum = otilenum ;
25812586 }
@@ -6184,8 +6189,8 @@ char *findfilename(char *path)
61846189int menuselect (int newpathmode )
61856190{
61866191 int listsize ;
6187- int i ;
6188- char ch , buffer [90 ];
6192+ int i , ch ;
6193+ char buffer [90 ];
61896194 CACHE1D_FIND_REC * dir ;
61906195
61916196 int bakpathsearchmode = pathsearchmode ;
@@ -6255,14 +6260,8 @@ int menuselect(int newpathmode)
62556260 }
62566261 showframe ();
62576262
6258- keystatus [0xcb ] = 0 ;
6259- keystatus [0xcd ] = 0 ;
6260- keystatus [0xc8 ] = 0 ;
6261- keystatus [0xd0 ] = 0 ;
6262- keystatus [0x1c ] = 0 ; //enter
6263- keystatus [0xf ] = 0 ; //tab
6264- keystatus [1 ] = 0 ; //esc
6265- ch = 0 ; //Interesting fakery of ch = getch()
6263+ bflushkeys ();
6264+ ch = 0 ;
62666265 while (ch == 0 )
62676266 {
62686267 if (handleevents ()) {
@@ -6271,43 +6270,38 @@ int menuselect(int newpathmode)
62716270 quitevent = 0 ;
62726271 }
62736272 }
6274- ch = bgetchar ();
6275- if (keystatus [0xcb ] > 0 ) ch = 9 ; // left arr
6276- if (keystatus [0xcd ] > 0 ) ch = 9 ; // right arr
6277- if (keystatus [0xc8 ] > 0 ) ch = 72 ; // up arr
6278- if (keystatus [0xd0 ] > 0 ) ch = 80 ; // down arr
6279-
6273+ ch = bgetkey ();
62806274 }
62816275
6282- if (ch == 'f' || ch == 'F' ) {
6276+ if (ch == 0x21 ) { //f
62836277 currentlist = 0 ;
62846278 pathsearchmode = 1 - pathsearchmode ;
62856279 if (pathsearchmode == PATHSEARCH_SYSTEM ) {
62866280 strcpy (selectedboardfilename , "" );
62876281 Bcanonicalisefilename (selectedboardfilename , 1 );
62886282 } else strcpy (selectedboardfilename , "/" );
62896283 getfilenames (selectedboardfilename , "*.map" );
6290- } else if (ch == 'g' || ch == 'G' ) {
6284+ } else if (ch == 0x22 ) { //g
62916285 if (pathsearchmode == PATHSEARCH_GAME ) {
62926286 grponlymode = 1 - grponlymode ;
62936287 getfilenames (selectedboardfilename , "*.map" );
62946288 }
6295- } else if (ch == 9 ) {
6289+ } else if (ch == 0xf ) { //tab
62966290 if ((currentlist == 0 && findfiles ) || (currentlist == 1 && finddirs ))
62976291 currentlist = 1 - currentlist ;
6298- } else if ((ch == 75 ) || (ch == 72 )) {
6292+ } else if ((ch == 0xcb ) || ( ch == 0xc8 ) || ( ch == 75 ) || (ch == 72 )) { //left,up arrow
62996293 if (currentlist == 0 ) {
63006294 if (finddirshigh && finddirshigh -> prev ) finddirshigh = finddirshigh -> prev ;
63016295 } else {
63026296 if (findfileshigh && findfileshigh -> prev ) findfileshigh = findfileshigh -> prev ;
63036297 }
6304- } else if ((ch == 77 ) || (ch == 80 )) {
6298+ } else if ((ch == 0xcd ) || ( ch == 0xd0 ) || ( ch == 77 ) || (ch == 80 )) { //right,down arrow
63056299 if (currentlist == 0 ) {
63066300 if (finddirshigh && finddirshigh -> next ) finddirshigh = finddirshigh -> next ;
63076301 } else {
63086302 if (findfileshigh && findfileshigh -> next ) findfileshigh = findfileshigh -> next ;
63096303 }
6310- } else if ((ch == 13 ) && (currentlist == 0 ) && finddirshigh ) {
6304+ } else if ((ch == 0x1c ) && (currentlist == 0 ) && finddirshigh ) { //enter
63116305 if (finddirshigh -> type == CACHE1D_FIND_DRIVE ) {
63126306 strcpy (selectedboardfilename , finddirshigh -> name );
63136307 } else {
@@ -6327,10 +6321,10 @@ int menuselect(int newpathmode)
63276321 clearbuf ((unsigned char * )frameplace , (bytesperline * ydim16 ) >> 2 , 0l );
63286322 showframe ();
63296323 }
6330- if (ch == 13 && !findfileshigh ) ch = 0 ;
6324+ if (ch == 0x1c && !findfileshigh ) ch = 0 ;
63316325 }
6332- while ((ch != 13 ) && (ch != 27 ));
6333- if (ch == 13 )
6326+ while ((ch != 0x1c ) && (ch != 0x1 ));
6327+ if (ch == 0x1c )
63346328 {
63356329 Bstrcat (selectedboardfilename , findfileshigh -> name );
63366330 //printf("Selected file: %s\n", selectedboardfilename);
0 commit comments