CHEWY: mouse - remove some unused extern, reduce some variable scopes, turn some uint8 to boolean

This commit is contained in:
Strangerke 2022-01-29 00:04:00 +01:00 committed by Paul Gilbert
parent b70f984db4
commit c545c36c43
8 changed files with 37 additions and 92 deletions

View File

@ -28,7 +28,6 @@
namespace Chewy {
extern char *err_str;
int16 mouse_push;
int print_delay_count1;

View File

@ -19,7 +19,6 @@
*
*/
#include "common/textconsole.h"
#include "chewy/cursor.h"
#include "chewy/events.h"
@ -48,9 +47,9 @@ cursor::~cursor() {
void cursor::plot_cur() {
if (maus_da && sichtbar) {
if (cur_move == 1) {
mouse_active = 1;
cur_move = 0;
if (cur_move) {
mouse_active = true;
cur_move = false;
if (!curblk->no_back) {
out->blockcopy(curblk->cur_back, cur_x_old, cur_y_old, scr_width);
@ -74,14 +73,14 @@ void cursor::plot_cur() {
out->sprite_set(curblk->sprite[ani_count], cur_x_old, cur_y_old,
scr_width);
mouse_active = 0;
mouse_active = false;
}
}
void cursor::show_cur() {
if ((maus_da) && (!sichtbar)) {
sichtbar = true;
mouse_active = 1;
mouse_active = true;
minfo->x = g_events->_mousePos.x;
minfo->y = g_events->_mousePos.y;
@ -94,7 +93,7 @@ void cursor::show_cur() {
cur_x_old = (minfo->x + curblk->page_off_x);
cur_y_old = (minfo->y + curblk->page_off_y);
cur_move = 1;
cur_move = true;
plot_cur();
}
}
@ -116,18 +115,18 @@ void cursor::set_cur_ani(cur_ani *ani1) {
void cursor::move(int16 x, int16 y) {
if (maus_da) {
mouse_active = 1;
mouse_active = true;
minfo->x = x;
minfo->y = y;
cur_x_old = (minfo->x + curblk->page_off_x);
cur_y_old = (minfo->y + curblk->page_off_y);
in->move_mouse(x, y);
if (sichtbar == true)
cur_move = 1;
if (sichtbar)
cur_move = true;
else
cur_move = 0;
mouse_active = 0;
cur_move = false;
mouse_active = false;
}
}

View File

@ -110,8 +110,8 @@ void EventsManager::handleMouseEvent(const Common::Event &event) {
}
// Set mouse position
if (cur_move != 1) {
cur_move = 1;
if (!cur_move) {
cur_move = true;
minfo.x = event.mouse.x;
minfo.y = event.mouse.y;
}

View File

@ -77,9 +77,7 @@ void standard_init() {
curani.ani_anf = 0;
curani.ani_end = 0;
curani.delay = 0;
mouse_hot_x = 0;
mouse_hot_y = 0;
cur = new cursor(out, in, &curblk);
cur->set_cur_ani(&curani);

View File

@ -173,8 +173,8 @@ int16 io_game::io_menu(iog_init *iostruc) {
if (y < (max_scroll)) {
if (y + scroll_flag != i) {
mouse_links_los = 0;
cur_move = 1;
mouse_links_los = false;
cur_move = true;
cur->hide_cur();
if (io_flag != 0)
@ -186,15 +186,13 @@ int16 io_game::io_menu(iog_init *iostruc) {
if (io_flag != 0)
mark_eintrag(cur_y, i);
cur->show_cur();
} else {
if (mouse_links_los == 1) {
mouse_links_los = 0;
dklick_end = g_system->getMillis(); //clock();
if ((dklick_end - dklick_start) / 1000 < d_klick)
kbinfo->key_code = 28;
else
dklick_start = g_system->getMillis(); //clock();
}
} else if (mouse_links_los) {
mouse_links_los = false;
dklick_end = g_system->getMillis(); //clock();
if ((dklick_end - dklick_start) / 1000 < d_klick)
kbinfo->key_code = 28;
else
dklick_start = g_system->getMillis(); //clock();
}
}
} else {

View File

@ -142,13 +142,9 @@ void free_buffers() {
}
void cursor_wahl(int16 nr) {
int16 ok;
int16 *xy;
ok = true;
int16 ok = true;
if (nr != CUR_USER) {
curblk.sprite = curtaf->image;
mouse_hot_x = 0;
mouse_hot_y = 0;
curani.delay = (1 + _G(spieler).DelaySpeed) * 5;
}
switch (nr) {
@ -263,9 +259,9 @@ void cursor_wahl(int16 nr) {
}
if (ok) {
cur_move = 1;
cur_move = true;
cur->set_cur_ani(&curani);
xy = (int16 *)curblk.sprite[curani.ani_anf];
int16 *xy = (int16 *)curblk.sprite[curani.ani_anf];
_G(spieler).CurBreite = xy[0];
_G(spieler).CurHoehe = xy[1];
in->rectangle(0, 0, 320 - xy[0], 210 - xy[1]);

View File

@ -26,21 +26,11 @@
namespace Chewy {
// FIXME. Externals
uint8 mouse_links_los;
uint8 mouse_active;
uint8 jflag;
int16 xdiff;
int16 ydiff;
int16 eck1x;
int16 eck1y;
int16 eck2x;
int16 eck2y;
bool mouse_links_los;
bool mouse_active;
// end of externals
uint8 cur_move;
uint8 mouse_hot_x;
uint8 mouse_hot_y;
bool cur_move;
void set_new_kb_handler(kb_info *key) {
@ -51,10 +41,6 @@ void set_old_kb_handler() {
g_events->setKbdInfo(nullptr);
}
void del_kb_puffer() {
g_events->clearEvents();
}
void set_mouse_handler(maus_info *mpos) {
// No implementation in ScummVM
}
@ -84,13 +70,10 @@ void maus::rectangle(int16 xmin, int16 ymin, int16 xmax, int16 ymax) {
// Mouse clip rectangle isn't supported in ScummVM
}
int16 maus::maus_vector(int16 x, int16 y, const int16 *tbl,
int16 anz) {
int16 i, j;
i = -1;
for (j = 0; (j < anz * 4) && (i == -1); j += 4) {
if ((x >= tbl[j]) && (x <= tbl[j + 2]) &&
(y >= tbl[j + 1]) && (y <= tbl[j + 3]))
int16 maus::maus_vector(int16 x, int16 y, const int16 *tbl, int16 anz) {
int16 i = -1;
for (int16 j = 0; (j < anz * 4) && (i == -1); j += 4) {
if ((x >= tbl[j]) && (x <= tbl[j + 2]) && (y >= tbl[j + 1]) && (y <= tbl[j + 3]))
i = j / 4;
}
@ -113,10 +96,6 @@ void maus::alter_kb_handler() {
#endif
}
void maus::flush_kb_puffer() {
del_kb_puffer();
}
void maus::neuer_maushandler(maus_info *mpos) {
set_mouse_handler(mpos);
maus_info_blk = mpos;
@ -130,8 +109,7 @@ in_zeiger *maus::get_in_zeiger() {
}
int16 maus::get_switch_code() {
int16 switch_code;
switch_code = 0;
int16 switch_code = 0;
if (maus_info_blk) {
if (maus_info_blk->button == 2) {

View File

@ -28,34 +28,12 @@ namespace Chewy {
void set_new_kb_handler(kb_info *key);
void set_old_kb_handler();
void del_kb_puffer();
void set_mouse_handler(maus_info *mpos);
extern uint8 new_kb;
extern uint8 mouse_on;
extern int16 mouse_button;
extern uint8 mouse_links;
extern uint8 mouse_links_los;
extern uint8 mouse_active;
extern uint8 cur_move;
extern uint8 mouse_hor;
extern uint8 mouse_ver;
extern uint8 mouse_hot_x;
extern uint8 mouse_hot_y;
extern uint8 jflag;
extern uint8 joy_code;
extern uint8 button;
extern int16 xdiff;
extern int16 ydiff;
extern int16 joyx;
extern int16 joyy;
extern int16 eck1x;
extern int16 eck1y;
extern int16 eck2x;
extern int16 eck2y;
extern bool mouse_links_los;
extern bool mouse_active;
extern bool cur_move;
extern int16 modul;
extern int16 fcode;
@ -71,7 +49,6 @@ public:
void neuer_kb_handler(kb_info *key);
void alter_kb_handler();
void flush_kb_puffer();
void neuer_maushandler(maus_info *mpos);
maus_info *maus_info_adr();