Skip to content

Commit

Permalink
Cleanup input
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov committed Nov 17, 2022
1 parent 6d8b57a commit eb7f06b
Show file tree
Hide file tree
Showing 56 changed files with 675 additions and 657 deletions.
6 changes: 3 additions & 3 deletions src/game/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,14 +1511,14 @@ Object* pick_object(int objectType, bool a2)
foundObject = NULL;

do {
_get_input();
get_input();
} while ((mouse_get_buttons() & MOUSE_EVENT_LEFT_BUTTON_REPEAT) != 0);

gmouse_set_cursor(MOUSE_CURSOR_PLUS);
gmouse_3d_off();

do {
if (_get_input() == -2) {
if (get_input() == -2) {
mouseEvent = mouse_get_buttons();
if ((mouseEvent & MOUSE_EVENT_LEFT_BUTTON_UP) != 0) {
keyCode = 0;
Expand Down Expand Up @@ -1556,7 +1556,7 @@ int pick_hex()
elevation = map_elevation;

while (1) {
inputEvent = _get_input();
inputEvent = get_input();
if (inputEvent == -2) {
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/game/anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,8 +2841,8 @@ void object_animate()

Object* object = sad_entry->obj;

unsigned int time = _get_time();
if (getTicksBetween(time, sad_entry->animationTimestamp) < sad_entry->ticksPerFrame) {
unsigned int time = get_time();
if (elapsed_tocks(time, sad_entry->animationTimestamp) < sad_entry->ticksPerFrame) {
continue;
}

Expand Down Expand Up @@ -3140,8 +3140,8 @@ void dude_fidget()
return;
}

unsigned int v0 = _get_bk_time();
if (getTicksBetween(v0, last_time) <= next_time) {
unsigned int v0 = get_bk_time();
if (elapsed_tocks(v0, last_time) <= next_time) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/game/automap.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void automap(bool isInGame, bool isUsingScanner)

// FIXME: There is minor bug in the interface - pressing H/L to toggle
// high/low details does not update switch state.
int keyCode = _get_input();
int keyCode = get_input();
switch (keyCode) {
case KEY_TAB:
case KEY_ESCAPE:
Expand Down Expand Up @@ -444,7 +444,7 @@ void automap(bool isInGame, bool isUsingScanner)
game_quit_with_confirm();
break;
case KEY_F12:
takeScreenshot();
dump_screen();
break;
}

Expand Down
26 changes: 13 additions & 13 deletions src/game/bmpdlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ int dialog_out(const char* title, const char** body, int bodyLength, int x, int

int rc = -1;
while (rc == -1) {
int keyCode = _get_input();
int keyCode = get_input();

if (keyCode == 500) {
rc = 1;
Expand Down Expand Up @@ -670,8 +670,8 @@ int file_dialog(char* title, char** fileList, char* dest, int fileListLength, in

int rc = -1;
while (rc == -1) {
unsigned int tick = _get_time();
int keyCode = _get_input();
unsigned int tick = get_time();
int keyCode = get_input();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE;
int scrollCounter = 0;
bool isScrolling = false;
Expand Down Expand Up @@ -778,7 +778,7 @@ int file_dialog(char* title, char** fileList, char* dest, int fileListLength, in
unsigned int scrollDelay = 4;
doubleClickSelectedFileIndex = -2;
while (1) {
unsigned int scrollTick = _get_time();
unsigned int scrollTick = get_time();
scrollCounter += 1;
if ((!isScrolling && scrollCounter == 1) || (isScrolling && scrollCounter > 14.4)) {
isScrolling = true;
Expand Down Expand Up @@ -822,15 +822,15 @@ int file_dialog(char* title, char** fileList, char* dest, int fileListLength, in
}

unsigned int delay = (scrollCounter > 14.4) ? 1000 / scrollDelay : 1000 / 24;
while (getTicksSince(scrollTick) < delay) {
while (elapsed_time(scrollTick) < delay) {
}

if (game_user_wants_to_quit != 0) {
rc = 1;
break;
}

int keyCode = _get_input();
int keyCode = get_input();
if (keyCode == 505 || keyCode == 503) {
break;
}
Expand All @@ -844,7 +844,7 @@ int file_dialog(char* title, char** fileList, char* dest, int fileListLength, in
doubleClickSelectedFileIndex = -2;
}

while (getTicksSince(tick) < (1000 / 24)) {
while (elapsed_time(tick) < (1000 / 24)) {
}
}

Expand Down Expand Up @@ -1075,8 +1075,8 @@ int save_file_dialog(char* title, char** fileList, char* dest, int fileListLengt

int rc = -1;
while (rc == -1) {
unsigned int tick = _get_time();
int keyCode = _get_input();
unsigned int tick = get_time();
int keyCode = get_input();
int scrollDirection = FILE_DIALOG_SCROLL_DIRECTION_NONE;
int scrollCounter = 0;
bool isScrolling = false;
Expand Down Expand Up @@ -1220,7 +1220,7 @@ int save_file_dialog(char* title, char** fileList, char* dest, int fileListLengt
unsigned int scrollDelay = 4;
doubleClickSelectedFileIndex = -2;
while (1) {
unsigned int scrollTick = _get_time();
unsigned int scrollTick = get_time();
scrollCounter += 1;
if ((!isScrolling && scrollCounter == 1) || (isScrolling && scrollCounter > 14.4)) {
isScrolling = true;
Expand Down Expand Up @@ -1281,15 +1281,15 @@ int save_file_dialog(char* title, char** fileList, char* dest, int fileListLengt
// FIXME: Missing windowRefresh makes blinking useless.

unsigned int delay = (scrollCounter > 14.4) ? 1000 / scrollDelay : 1000 / 24;
while (getTicksSince(scrollTick) < delay) {
while (elapsed_time(scrollTick) < delay) {
}

if (game_user_wants_to_quit != 0) {
rc = 1;
break;
}

int key = _get_input();
int key = get_input();
if (key == 505 || key == 503) {
break;
}
Expand All @@ -1313,7 +1313,7 @@ int save_file_dialog(char* title, char** fileList, char* dest, int fileListLengt
doubleClickSelectedFileIndex = -2;
}

while (getTicksSince(tick) < (1000 / 24)) {
while (elapsed_time(tick) < (1000 / 24)) {
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/game/combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,7 +2483,7 @@ static void combat_begin(Object* a1)
{
combat_turn_running = 0;
anim_stop();
tickersRemove(dude_fidget);
remove_bk_process(dude_fidget);
combat_elev = map_elevation;

if (!isInCombat()) {
Expand Down Expand Up @@ -2548,7 +2548,7 @@ static void combat_begin(Object* a1)
register_end();

while (anim_busy(v1)) {
_process_bk();
process_bk();
}
}
}
Expand Down Expand Up @@ -2683,7 +2683,7 @@ static void combat_over()
}
}

tickersAdd(dude_fidget);
add_bk_process(dude_fidget);

for (int index = 0; index < list_noncom + list_com; index++) {
Object* critter = combat_list[index];
Expand Down Expand Up @@ -2713,7 +2713,7 @@ static void combat_over()
register_end();

while (anim_busy(critter)) {
_process_bk();
process_bk();
}
}
}
Expand Down Expand Up @@ -3045,7 +3045,7 @@ void combat_end()
void combat_turn_run()
{
while (combat_turn_running > 0) {
_process_bk();
process_bk();
}
}

Expand All @@ -3069,10 +3069,10 @@ static int combat_input()
break;
}

int keyCode = _get_input();
int keyCode = get_input();
if (action_explode_running()) {
while (combat_turn_running > 0) {
_process_bk();
process_bk();
}
}

Expand Down Expand Up @@ -3221,7 +3221,7 @@ static int combat_turn(Object* a1, bool a2)
}

while (combat_turn_running > 0) {
_process_bk();
process_bk();
}

if (a1 == obj_dude) {
Expand Down Expand Up @@ -5467,7 +5467,7 @@ static int get_called_shot_location(Object* critter, int* hitLocation, int hitMo

int eventCode;
while (true) {
eventCode = _get_input();
eventCode = get_input();

if (eventCode == KEY_ESCAPE) {
break;
Expand Down
4 changes: 2 additions & 2 deletions src/game/combatai.c
Original file line number Diff line number Diff line change
Expand Up @@ -2954,7 +2954,7 @@ void combat_ai(Object* a1, Object* a2)
// 0x42B3FC
bool combatai_want_to_join(Object* a1)
{
_process_bk();
process_bk();

if ((a1->flags & OBJECT_HIDDEN) != 0) {
return false;
Expand Down Expand Up @@ -3000,7 +3000,7 @@ bool combatai_want_to_join(Object* a1)
// 0x42B4A8
bool combatai_want_to_stop(Object* a1)
{
_process_bk();
process_bk();

if ((a1->data.critter.combat.maneuver & CRITTER_MANEUVER_STOP_ATTACKING) != 0) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/game/counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void counter_on(CounterOutputFunc* outputFunc)
{
if (!counter_is_on) {
debug_printf("Turning on counter...\n");
tickersAdd(counter);
add_bk_process(counter);
counter_output_func = outputFunc;
counter_is_on = 1;
last_time = clock();
Expand All @@ -35,7 +35,7 @@ void counter_on(CounterOutputFunc* outputFunc)
void counter_off()
{
if (counter_is_on) {
tickersRemove(counter);
remove_bk_process(counter);
counter_is_on = 0;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/game/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void credits(const char* filePath, int backgroundFid, bool useReversedStyle)
unsigned char* dest = intermediateBuffer + CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT - CREDITS_WINDOW_WIDTH + (CREDITS_WINDOW_WIDTH - v19) / 2;
unsigned char* src = stringBuffer;
for (int index = 0; index < lineHeight; index++) {
if (_get_input() != -1) {
if (get_input() != -1) {
stop = true;
break;
}
Expand All @@ -170,10 +170,10 @@ void credits(const char* filePath, int backgroundFid, bool useReversedStyle)
windowBuffer,
CREDITS_WINDOW_WIDTH);

while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
while (elapsed_time(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}

tick = _get_time();
tick = get_time();

win_draw(window);

Expand All @@ -187,7 +187,7 @@ void credits(const char* filePath, int backgroundFid, bool useReversedStyle)

if (!stop) {
for (int index = 0; index < CREDITS_WINDOW_HEIGHT; index++) {
if (_get_input() != -1) {
if (get_input() != -1) {
break;
}

Expand All @@ -208,10 +208,10 @@ void credits(const char* filePath, int backgroundFid, bool useReversedStyle)
windowBuffer,
CREDITS_WINDOW_WIDTH);

while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
while (elapsed_time(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}

tick = _get_time();
tick = get_time();

win_draw(window);
}
Expand Down
16 changes: 8 additions & 8 deletions src/game/cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void cycle_init()
monitors[index] >>= 2;
}

tickersAdd(cycle_colors);
add_bk_process(cycle_colors);

cycle_initialized = true;
cycle_enabled = true;
Expand All @@ -150,7 +150,7 @@ void cycle_reset()
last_cycle_medium = 0;
last_cycle_fast = 0;
last_cycle_very_fast = 0;
tickersAdd(cycle_colors);
add_bk_process(cycle_colors);
cycle_enabled = true;
}
}
Expand All @@ -159,7 +159,7 @@ void cycle_reset()
void cycle_exit()
{
if (cycle_initialized) {
tickersRemove(cycle_colors);
remove_bk_process(cycle_colors);
cycle_initialized = false;
cycle_enabled = false;
}
Expand Down Expand Up @@ -214,9 +214,9 @@ static void cycle_colors()
bool changed = false;

unsigned char* palette = getSystemPalette();
unsigned int time = _get_time();
unsigned int time = get_time();

if (getTicksBetween(time, last_cycle_slow) >= COLOR_CYCLE_PERIOD_SLOW * cycle_speed_factor) {
if (elapsed_tocks(time, last_cycle_slow) >= COLOR_CYCLE_PERIOD_SLOW * cycle_speed_factor) {
changed = true;
last_cycle_slow = time;

Expand Down Expand Up @@ -266,7 +266,7 @@ static void cycle_colors()
}
}

if (getTicksBetween(time, last_cycle_medium) >= COLOR_CYCLE_PERIOD_MEDIUM * cycle_speed_factor) {
if (elapsed_tocks(time, last_cycle_medium) >= COLOR_CYCLE_PERIOD_MEDIUM * cycle_speed_factor) {
changed = true;
last_cycle_medium = time;

Expand All @@ -286,7 +286,7 @@ static void cycle_colors()
}
}

if (getTicksBetween(time, last_cycle_fast) >= COLOR_CYCLE_PERIOD_FAST * cycle_speed_factor) {
if (elapsed_tocks(time, last_cycle_fast) >= COLOR_CYCLE_PERIOD_FAST * cycle_speed_factor) {
changed = true;
last_cycle_fast = time;

Expand All @@ -307,7 +307,7 @@ static void cycle_colors()
}
}

if (getTicksBetween(time, last_cycle_very_fast) >= COLOR_CYCLE_PERIOD_VERY_FAST * cycle_speed_factor) {
if (elapsed_tocks(time, last_cycle_very_fast) >= COLOR_CYCLE_PERIOD_VERY_FAST * cycle_speed_factor) {
changed = true;
last_cycle_very_fast = time;

Expand Down
Loading

0 comments on commit eb7f06b

Please sign in to comment.