wok diff oldrunner/stuff/remap.u @ rev 25454
oldrunner: add apple2 keys mapping
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Sep 22 07:58:57 2022 +0000 (2022-09-22) |
parents | |
children | 002a704d9c02 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/oldrunner/stuff/remap.u Thu Sep 22 07:58:57 2022 +0000 1.3 @@ -0,0 +1,82 @@ 1.4 +--- oldrunner.c 2010-07-17 17:30:32.000000000 +0000 1.5 ++++ oldrunner.c 2022-09-22 07:31:51.585297479 +0000 1.6 +@@ -36,6 +36,8 @@ 1.7 + 1.8 + #include "oldrunner.h" 1.9 + 1.10 ++int remap_apple = 0; 1.11 ++ 1.12 + /* 1.13 + * Oldrunner is a remake of the Loadrunner game from Broderbund, and one of the 1.14 + * first computer games my father offered me. I wrote this in memory of him. 1.15 +@@ -50,7 +52,7 @@ 1.16 + int ch, startlvl; 1.17 + 1.18 + startlvl = 0; 1.19 +- while ((ch = getopt (argc, argv, "l:v")) != -1) 1.20 ++ while ((ch = getopt (argc, argv, "l:av")) != -1) 1.21 + { 1.22 + switch (ch) 1.23 + { 1.24 +@@ -62,6 +64,9 @@ 1.25 + return 1; 1.26 + } 1.27 + break; 1.28 ++ case 'a': 1.29 ++ remap_apple++; 1.30 ++ break; 1.31 + case 'v': 1.32 + fputs ("oldrunner-" VERSION "\n", stdout); 1.33 + return 0; 1.34 +@@ -74,7 +79,7 @@ 1.35 + if (argc >= 1) 1.36 + { 1.37 + err: 1.38 +- fputs ("usage: oldrunner [-v] [-l<num>]\n", stderr); 1.39 ++ fputs ("usage: oldrunner [-v] [-a] [-l<num>]\n", stderr); 1.40 + return 0; 1.41 + } 1.42 + 1.43 +--- usr.c 2010-07-17 17:30:32.000000000 +0000 1.44 ++++ usr.c 2022-09-22 07:28:52.590988791 +0000 1.45 +@@ -43,6 +43,31 @@ 1.46 + rec_input.key = ORKEY_NONE; 1.47 + } 1.48 + 1.49 ++static int 1.50 ++remap (int key) 1.51 ++{ 1.52 ++ extern int remap_apple; 1.53 ++ if (remap_apple) 1.54 ++ { 1.55 ++ switch (key | 0x20) 1.56 ++ { 1.57 ++ case 'u': 1.58 ++ return ORKEY_DIG_LEFT; 1.59 ++ case 'i': 1.60 ++ return ORKEY_MOVE_UP; 1.61 ++ case 'o': 1.62 ++ return ORKEY_DIG_RIGHT; 1.63 ++ case 'j': 1.64 ++ return ORKEY_MOVE_LEFT; 1.65 ++ case 'k': 1.66 ++ return ORKEY_MOVE_DOWN; 1.67 ++ case 'l': 1.68 ++ return ORKEY_MOVE_RIGHT; 1.69 ++ } 1.70 ++ } 1.71 ++ return key; 1.72 ++} 1.73 ++ 1.74 + void 1.75 + usr_input (void) 1.76 + { 1.77 +@@ -63,7 +88,7 @@ 1.78 + continue; 1.79 + } 1.80 + 1.81 +- switch (rec_input.key) 1.82 ++ switch (remap(rec_input.key)) 1.83 + { 1.84 + case ORKEY_EXIT: 1.85 + return;