diff --git a/docs/changelog.txt b/docs/changelog.txt index 6a05c662c..559aab5c4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -7,6 +7,10 @@ USERS + Added an experimental Dreamcast port (asie, Lachesis). + Added an experimental MS-DOS 32-bit port based on DJGPP (Mr_Alert, asie, Lachesis). ++ Added the new counter KEY_PRESSEDn to read internal keycode + statuses. This is like KEYn, but KEY_PRESSEDn accepts internal + keycodes instead of PC XT keycodes. KEY_PRESSEDn will return + 1 if the key is currently pressed, or 0 if it is not pressed. + Added the new counter DATE_WEEKDAY containing the number of the current day of the week, where 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday. diff --git a/docs/counter_list.txt b/docs/counter_list.txt index b5276338f..60938e1f9 100644 --- a/docs/counter_list.txt +++ b/docs/counter_list.txt @@ -69,6 +69,7 @@ name r/w g/n/f/b i "KEY" r b * "KEY_CODE" r b * "KEY_PRESSED" r b * +"KEY_PRESSEDn" r b * "KEY_RELEASE" r b * "KEYn" r b * "LASTXPOS" r w n * diff --git a/src/counter.c b/src/counter.c index cbce2ba74..04b886ad6 100644 --- a/src/counter.c +++ b/src/counter.c @@ -1217,6 +1217,13 @@ static int key_release_read(struct world *mzx_world, return get_last_key_released(keycode_pc_xt); } +static int key_pressedn_read(struct world *mzx_world, + const struct function_counter *counter, const char *name, int id) +{ + int key_num = strtol(name + 11, NULL, 10); + return get_key_status(keycode_internal, key_num) > 0; +} + static int joyn_read(struct world *mzx_world, const struct function_counter *counter, const char *name, int id) { @@ -2662,6 +2669,7 @@ static const struct function_counter builtin_counters[] = { "key!", V269, keyn_read, NULL }, { "key_code", V269, key_code_read, NULL }, { "key_pressed", V260, key_pressed_read, NULL }, + { "key_pressed!", V293, key_pressedn_read, NULL }, { "key_release", V269, key_release_read, NULL }, { "lava_walk", V260, lava_walk_read, lava_walk_write }, { "load_bc?", V270, load_bc_read, NULL },