Add display string for the transfer speed

This commit is contained in:
simon.kagstrom 2009-01-25 07:22:44 +00:00
parent 8b6f14dcaa
commit c2a49cde0f
3 changed files with 12 additions and 2 deletions

View File

@ -617,8 +617,8 @@ void C64::VBlank(bool draw_frame)
} }
if (now - last_time_update > 1000) if (now - last_time_update > 1000)
{ {
printf("%.2f kbytes / second\n", TheDisplay->NetworkTrafficMeter(((bytes_sent * 1000.0) /
((bytes_sent * 1000.0) / ((float)now - last_time_update)) / 1024.0); ((float)now - last_time_update)) / 1024.0);
for (int i = 0; i < this->network_server->n_clients; i++) for (int i = 0; i < this->network_server->n_clients; i++)
this->network_server->clients[i]->ResetBytesSent(); this->network_server->clients[i]->ResetBytesSent();
bytes_sent = 0; bytes_sent = 0;

View File

@ -71,6 +71,7 @@ public:
void Update(void); void Update(void);
void UpdateLEDs(int l0, int l1, int l2, int l3); void UpdateLEDs(int l0, int l1, int l2, int l3);
void Speedometer(int speed); void Speedometer(int speed);
void NetworkTrafficMeter(float kb_per_s);
uint8 *BitmapBase(void); uint8 *BitmapBase(void);
int BitmapXMod(void); int BitmapXMod(void);
#ifdef __riscos__ #ifdef __riscos__
@ -141,6 +142,7 @@ private:
#ifdef HAVE_SDL #ifdef HAVE_SDL
char speedometer_string[16]; // Speedometer text char speedometer_string[16]; // Speedometer text
char networktraffic_string[16]; // Speedometer text
void draw_string(SDL_Surface *s, int x, int y, const char *str, uint8 front_color, uint8 back_color); void draw_string(SDL_Surface *s, int x, int y, const char *str, uint8 front_color, uint8 back_color);
#endif #endif

View File

@ -129,6 +129,7 @@ C64Display::C64Display(C64 *the_c64) : TheC64(the_c64)
{ {
quit_requested = false; quit_requested = false;
speedometer_string[0] = 0; speedometer_string[0] = 0;
networktraffic_string[0] = 0;
printf("ssof2 %d:%d\n", sizeof(C64Display), sizeof(C64)); printf("ssof2 %d:%d\n", sizeof(C64Display), sizeof(C64));
// Open window // Open window
@ -224,6 +225,8 @@ void C64Display::Update(uint8 *src_pixels)
/* Stretch */ /* Stretch */
SDL_SoftStretch(sdl_screen, &srcrect, real_screen, &dstrect); SDL_SoftStretch(sdl_screen, &srcrect, real_screen, &dstrect);
} }
draw_string(real_screen, 0, 0, networktraffic_string, black, fill_gray);
SDL_Flip(real_screen); SDL_Flip(real_screen);
} }
@ -295,6 +298,11 @@ void C64Display::Speedometer(int speed)
delay++; delay++;
} }
void C64Display::NetworkTrafficMeter(float kb_per_s)
{
sprintf(this->networktraffic_string, "%6.2f KB/S",
kb_per_s);
}
/* /*
* Return pointer to bitmap data * Return pointer to bitmap data