From 44054051d1c510c11564ad79585beac2f6d1cf00 Mon Sep 17 00:00:00 2001 From: Martin Schaffner Date: Tue, 25 Jan 2005 19:44:27 +0000 Subject: [PATCH] use timer_get_fixed_seconds instead of TICKER macro --- ChangeLog | 2 ++ ui/file.c | 10 ++++------ ui/listbox.c | 19 +++++++++---------- ui/mouse.c | 11 +++++------ ui/scroll.c | 19 +++++++++---------- ui/window.c | 11 +++++------ 6 files changed, 34 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e1e27a3..1012b55c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ * main/editor/medwall.c: include cntrlcen.h * ui/barbox.c, ui/number.c: pass int*, not short* to gr_get_string_size * include/ui.h, ui/barbox.c: make ui_barbox_update return void + * patching file ui/file.c, ui/listbox.c, file ui/mouse.c, ui/scroll.c, + ui/window.c: use timer_get_fixed_seconds instead of TICKER macro 2005-01-24 Chris Taylor diff --git a/ui/file.c b/ui/file.c index 3963cc27..0c884f7d 100644 --- a/ui/file.c +++ b/ui/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $ */ +/* $Id: file.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: file.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; +static char rcsid[] = "$Id: file.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $"; #endif #include @@ -38,8 +38,6 @@ static char rcsid[] = "$Id: file.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; #include "u_mem.h" -#define TICKER (*(volatile int *)0x46C) - char filename_list[300][13]; char directory_list[100][13]; @@ -507,8 +505,8 @@ int ui_get_filename( char * filename, char * Filespec, char * message ) ui_wprintf_at( wnd, 20, 60, "%s", Spaces ); ui_wprintf_at( wnd, 20, 60, "%s", CurDir ); - i = TICKER; - while ( TICKER < i+2 ); + //i = TICKER; + //while ( TICKER < i+2 ); }else { sprintf(ErrorMessage, "Error changing to directory '%s'", fulldir ); diff --git a/ui/listbox.c b/ui/listbox.c index f30a37f6..28a7ef45 100644 --- a/ui/listbox.c +++ b/ui/listbox.c @@ -1,4 +1,4 @@ -/* $Id: listbox.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $ */ +/* $Id: listbox.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: listbox.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; +static char rcsid[] = "$Id: listbox.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -27,8 +27,7 @@ static char rcsid[] = "$Id: listbox.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $" #include "gr.h" #include "ui.h" #include "key.h" - -#define TICKER (*(volatile int *)0x46C) +#include "timer.h" void ui_draw_listbox( UI_GADGET_LISTBOX * listbox ) { @@ -290,18 +289,18 @@ void ui_listbox_do( UI_GADGET_LISTBOX * listbox, int keypress ) else mitem = (Mouse.y - listbox->y1)/listbox->textheight; - if ( (mitem < 0 ) && ( TICKER > listbox->last_scrolled+1) ) + if ((mitem < 0) && (timer_get_fixed_seconds() > listbox->last_scrolled + 1)) { listbox->current_item--; - listbox->last_scrolled = TICKER; + listbox->last_scrolled = timer_get_fixed_seconds(); listbox->moved = 1; } - if ( ( mitem >= listbox->num_items_displayed ) && - ( TICKER > listbox->last_scrolled+1) ) + if ((mitem >= listbox->num_items_displayed) && + (timer_get_fixed_seconds() > listbox->last_scrolled + 1)) { listbox->current_item++; - listbox->last_scrolled = TICKER; + listbox->last_scrolled = timer_get_fixed_seconds(); listbox->moved = 1; } @@ -372,7 +371,7 @@ void ui_listbox_change( UI_WINDOW * wnd, UI_GADGET_LISTBOX * listbox, short numi listbox->num_items = numitems; listbox->first_item = 0; listbox->current_item = -1; - listbox->last_scrolled = TICKER; + listbox->last_scrolled = timer_get_fixed_seconds(); listbox->dragging = 0; listbox->selected_item = -1; listbox->status = 1; diff --git a/ui/mouse.c b/ui/mouse.c index 4e148ca1..7bb0c117 100644 --- a/ui/mouse.c +++ b/ui/mouse.c @@ -1,4 +1,4 @@ -/* $Id: mouse.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $ */ +/* $Id: mouse.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: mouse.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; +static char rcsid[] = "$Id: mouse.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -27,6 +27,7 @@ static char rcsid[] = "$Id: mouse.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; #include "pstypes.h" #include "gr.h" #include "mouse.h" +#include "timer.h" #include "ui.h" @@ -80,8 +81,6 @@ static grs_bitmap * default_pointer; UI_MOUSE Mouse; -#define TICKER (*(volatile int *)0x46C) - /* int ui_mouse_find_gadget(short n) { @@ -199,11 +198,11 @@ void ui_mouse_process() if ((Mouse.b1_status & BUTTON_PRESSED) && (Mouse.b1_last_status & BUTTON_RELEASED) ) { - if ( (TICKER <= Mouse.time_lastpressed+5) ) //&& (Mouse.moved==0) + if ((timer_get_fixed_seconds() <= Mouse.time_lastpressed + F1_0/5)) //&& (Mouse.moved==0) Mouse.b1_status |= BUTTON_DOUBLE_CLICKED; Mouse.moved = 0; - Mouse.time_lastpressed = TICKER; + Mouse.time_lastpressed = timer_get_fixed_seconds(); Mouse.b1_status |= BUTTON_JUST_PRESSED; } diff --git a/ui/scroll.c b/ui/scroll.c index e70d5fae..3476aabf 100644 --- a/ui/scroll.c +++ b/ui/scroll.c @@ -1,4 +1,4 @@ -/* $Id: scroll.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $ */ +/* $Id: scroll.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: scroll.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; +static char rcsid[] = "$Id: scroll.c,v 1.5 2005-01-25 19:44:27 schaffner Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -27,8 +27,7 @@ static char rcsid[] = "$Id: scroll.c,v 1.4 2005-01-24 22:19:10 schaffner Exp $"; #include "gr.h" #include "ui.h" #include "key.h" - -#define TICKER (*(volatile int *)0x46C) +#include "timer.h" void ui_draw_scrollbar( UI_GADGET_SCROLLBAR * scrollbar ) { @@ -131,9 +130,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress ) if ( (scrollbar->up_button->position!=0) || (keyfocus && keyd_pressed[KEY_UP]) ) { - if (TICKER > scrollbar->last_scrolled+1) + if (timer_get_fixed_seconds() > scrollbar->last_scrolled + 1) { - scrollbar->last_scrolled = TICKER; + scrollbar->last_scrolled = timer_get_fixed_seconds(); scrollbar->position--; if (scrollbar->position < scrollbar->start ) scrollbar->position = scrollbar->start; @@ -145,9 +144,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress ) if ( (scrollbar->down_button->position!=0) || (keyfocus && keyd_pressed[KEY_DOWN]) ) { - if (TICKER > scrollbar->last_scrolled+1) + if (timer_get_fixed_seconds() > scrollbar->last_scrolled + 1) { - scrollbar->last_scrolled = TICKER; + scrollbar->last_scrolled = timer_get_fixed_seconds(); scrollbar->position++; if (scrollbar->position > scrollbar->stop ) scrollbar->position = scrollbar->stop; @@ -181,9 +180,9 @@ void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress ) scrollbar->drag_starting = scrollbar->fake_position; } - if ( B1_PRESSED && OnMe && !OnSlider && (TICKER > scrollbar->last_scrolled+4) ) + if (B1_PRESSED && OnMe && !OnSlider && (timer_get_fixed_seconds() > scrollbar->last_scrolled + 4)) { - scrollbar->last_scrolled = TICKER; + scrollbar->last_scrolled = timer_get_fixed_seconds(); if ( Mouse.y < scrollbar->fake_position+scrollbar->y1 ) { diff --git a/ui/window.c b/ui/window.c index 1b6966eb..09573b33 100644 --- a/ui/window.c +++ b/ui/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.5 2005-01-24 22:19:10 schaffner Exp $ */ +/* $Id: window.c,v 1.6 2005-01-25 19:44:27 schaffner Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +13,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ #ifdef RCS -static char rcsid[] = "$Id: window.c,v 1.5 2005-01-24 22:19:10 schaffner Exp $"; +static char rcsid[] = "$Id: window.c,v 1.6 2005-01-25 19:44:27 schaffner Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -31,6 +31,7 @@ static char rcsid[] = "$Id: window.c,v 1.5 2005-01-24 22:19:10 schaffner Exp $"; #include "gr.h" #include "ui.h" #include "key.h" +#include "timer.h" #include "mono.h" #include "mouse.h" @@ -73,8 +74,6 @@ static int PlaybackSpeed = 1; extern void ui_draw_frame( short x1, short y1, short x2, short y2 ); -#define TICKER (*(volatile int *)0x46C) - // 1=1x faster, 2=2x faster, etc void ui_set_playback_speed( int speed ) { @@ -336,12 +335,12 @@ int last_event = 0; void ui_reset_idle_seconds() { - last_event = TICKER; + last_event = timer_get_fixed_seconds(); } int ui_get_idle_seconds() { - return (((TICKER - last_event)*10)/182); + return (timer_get_fixed_seconds() - last_event)/F1_0; } void ui_mega_process() -- 2.39.2