From 25eee632f605f5e80ba5b076566b39e46078b4a9 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 3 Jan 2008 05:33:59 +0000 Subject: [PATCH] (inspired by Firewave) Removed ui_popup(). Drivers should always be using popmessage() instead (has been this way for a while). Augmented popmessage() so that you can pass NULL to immediately dismiss any messages. --- src/emu/cpu/mips/psx.c | 2 +- src/emu/mame.c | 34 +++++++++++++++++++++------------- src/emu/mame.h | 4 ++-- src/emu/sound/k054539.c | 2 +- src/emu/ui.c | 22 ---------------------- src/mame/drivers/dkong.c | 2 +- src/mame/drivers/legionna.c | 16 ++++++++-------- src/mame/video/legionna.c | 10 +++++----- 8 files changed, 39 insertions(+), 53 deletions(-) diff --git a/src/emu/cpu/mips/psx.c b/src/emu/cpu/mips/psx.c index 06a5eedd49d..1860b606f49 100644 --- a/src/emu/cpu/mips/psx.c +++ b/src/emu/cpu/mips/psx.c @@ -3126,7 +3126,7 @@ static void docop2( int gteop ) } break; } - ui_popup_time( 1, "unknown GTE op %08x", gteop ); + popmessage( "unknown GTE op %08x", gteop ); logerror( "%08x: unknown GTE op %08x\n", mipscpu.pc, gteop ); mips_stop(); } diff --git a/src/emu/mame.c b/src/emu/mame.c index 0934fa3ff4f..f83789e7a1d 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -1153,18 +1153,26 @@ void CLIB_DECL fatalerror_exitcode(int exitcode, const char *text, ...) popmessage - pop up a user-visible message -------------------------------------------------*/ -void CLIB_DECL popmessage(const char *text, ...) +void CLIB_DECL popmessage(const char *format, ...) { - extern void CLIB_DECL ui_popup(const char *text, ...) ATTR_PRINTF(1,2); - va_list arg; + /* if the format is NULL, it is a signal to clear the popmessage */ + if (format == NULL) + ui_popup_time(0, " "); + + /* otherwise, generate the buffer and call the UI to display the message */ + else + { + extern void CLIB_DECL ui_popup(const char *format, ...) ATTR_PRINTF(1,2); + va_list arg; + + /* dump to the buffer */ + va_start(arg, format); + vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, format, arg); + va_end(arg); - /* dump to the buffer */ - va_start(arg, text); - vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, text, arg); - va_end(arg); - - /* pop it in the UI */ - ui_popup("%s", giant_string_buffer); + /* pop it in the UI */ + ui_popup_time((int)strlen(giant_string_buffer) / 40 + 2, "%s", giant_string_buffer); + } } @@ -1173,7 +1181,7 @@ void CLIB_DECL popmessage(const char *text, ...) OSD-defined output streams -------------------------------------------------*/ -void CLIB_DECL logerror(const char *text, ...) +void CLIB_DECL logerror(const char *format, ...) { running_machine *machine = Machine; @@ -1191,8 +1199,8 @@ void CLIB_DECL logerror(const char *text, ...) profiler_mark(PROFILER_LOGERROR); /* dump to the buffer */ - va_start(arg, text); - vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, text, arg); + va_start(arg, format); + vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, format, arg); va_end(arg); /* log to all callbacks */ diff --git a/src/emu/mame.h b/src/emu/mame.h index 5264d7794a5..ed6485c1e0d 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -369,10 +369,10 @@ void mame_printf_debug(const char *format, ...) ATTR_PRINTF(1,2); /* ----- miscellaneous bits & pieces ----- */ /* pop-up a user visible message */ -void CLIB_DECL popmessage(const char *text,...) ATTR_PRINTF(1,2); +void CLIB_DECL popmessage(const char *format,...) ATTR_PRINTF(1,2); /* log to the standard error.log file */ -void CLIB_DECL logerror(const char *text,...) ATTR_PRINTF(1,2); +void CLIB_DECL logerror(const char *format,...) ATTR_PRINTF(1,2); /* adds a callback to be called on logerror() */ void add_logerror_callback(running_machine *machine, void (*callback)(running_machine *, const char *)); diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index 9900c06912c..fe50e0d1f3f 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -377,7 +377,7 @@ else if (input_code_pressed_once(KEYCODE_DEL_PAD)) { gc_active ^= 1; - if (!gc_active) ui_popup_time(0, " "); + if (!gc_active) popmessage(NULL); } if (gc_active) diff --git a/src/emu/ui.c b/src/emu/ui.c index 2f6a630b09f..4cf4eef848d 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -806,28 +806,6 @@ void ui_draw_text_box(const char *text, int justify, float xpos, float ypos, rgb } -/*------------------------------------------------- - ui_popup - popup a message for a standard - amount of time --------------------------------------------------*/ - -void CLIB_DECL ui_popup(const char *text, ...) -{ - int seconds; - va_list arg; - - /* extract the text */ - va_start(arg,text); - vsprintf(messagebox_text, text, arg); - messagebox_backcolor = UI_FILLCOLOR; - va_end(arg); - - /* set a timer */ - seconds = (int)strlen(messagebox_text) / 40 + 2; - popup_text_end = osd_ticks() + osd_ticks_per_second() * seconds; -} - - /*------------------------------------------------- ui_popup_time - popup a message for a specific amount of time diff --git a/src/mame/drivers/dkong.c b/src/mame/drivers/dkong.c index ac991889f24..45c26d236ca 100644 --- a/src/mame/drivers/dkong.c +++ b/src/mame/drivers/dkong.c @@ -511,7 +511,7 @@ static READ8_HANDLER( dkong_in2_r ) if (!lst && (readinputportbytag("TST") & 0x01)) { ui_snd = (ui_snd + 1) % 10; - ui_popup("Sound %d", ui_snd); + popmessage("Sound %d", ui_snd); } lst = readinputportbytag("TST") & 0x01; if (ui_snd<8) diff --git a/src/mame/drivers/legionna.c b/src/mame/drivers/legionna.c index d17100293f1..4f9f52ab315 100644 --- a/src/mame/drivers/legionna.c +++ b/src/mame/drivers/legionna.c @@ -1009,7 +1009,7 @@ static UINT16 cop2_hit_prot(void) // xp = (param1 & 0x00f0) >> 4; // yp = (param1 & 0x0f00) >> 8; -// ui_popup("%04x %04x",param1,param2); +// popmessage("%04x %04x",param1,param2); xp = 0; yp = 0; @@ -1172,7 +1172,7 @@ static WRITE16_HANDLER( cop2_mcu_w ) case (0x420/2): { //coin counter write - //ui_popup("%04x",mcu_ram[offset]); + //popmessage("%04x",mcu_ram[offset]); prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]); //prot_bcd = mcu_ram[offset] - 0x22; break; @@ -1205,7 +1205,7 @@ static WRITE16_HANDLER( cop2_mcu_w ) break; case 0x4100: break; case 0x41c0: break; - //default: ui_popup("%04x",mcu_ram[offset]); + //default: popmessage("%04x",mcu_ram[offset]); } break; } @@ -1471,7 +1471,7 @@ static READ16_HANDLER( sdgndmrb_cop_mcu_r ) if(offset > (0x500/2) && offset < (0x600/2)) { logerror("CPU0 PC %06x MCU read offset: %04x\n",activecpu_get_previouspc(),offset*2); - //ui_popup("PC %06x MCU read: %04x",activecpu_get_previouspc(),offset*2); + //popmessage("PC %06x MCU read: %04x",activecpu_get_previouspc(),offset*2); } return mcu_ram[offset]; @@ -1501,7 +1501,7 @@ static WRITE16_HANDLER( sdgndmrb_cop_mcu_w ) break; case 0x4100: break; case 0x41c0: break; - //default: ui_popup("%04x",mcu_ram[offset]); + //default: popmessage("%04x",mcu_ram[offset]); } break; } @@ -1614,7 +1614,7 @@ static WRITE16_HANDLER( sdgndmrb_cop_mcu_w ) case (0x420/2): { //coin counter write - //ui_popup("%04x",mcu_ram[offset]); + //popmessage("%04x",mcu_ram[offset]); prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]); //prot_bcd = mcu_ram[offset] - 0x22; break; @@ -1656,7 +1656,7 @@ static WRITE16_HANDLER( sdgndmrb_cop_mcu_w ) { case 0xa180:/*do the job [1]*/ { - //ui_popup("%08x %08x %04x",dma_src,dma_dst,dma_size); + //popmessage("%08x %08x %04x",dma_src,dma_dst,dma_size); /*fix the offset for easier reading*/ dma_src+=4; //dma_dst+=4; @@ -1842,7 +1842,7 @@ static WRITE16_HANDLER( sdgndmrb_cop_mcu_w ) // default: // logerror("CPU0 PC %06x MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset*2,data); -// ui_popup("CPU0 PC %06x MCU write offset: %04x data: %04x",activecpu_get_previouspc(),offset*2,data); +// popmessage("CPU0 PC %06x MCU write offset: %04x data: %04x",activecpu_get_previouspc(),offset*2,data); } } diff --git a/src/mame/video/legionna.c b/src/mame/video/legionna.c index 83ebd6a7979..8cad0e79ae0 100644 --- a/src/mame/video/legionna.c +++ b/src/mame/video/legionna.c @@ -319,31 +319,31 @@ VIDEO_UPDATE( legionna ) if (input_code_pressed_once (KEYCODE_Z)) { dislayer[0] ^= 1; - ui_popup("bg0: %01x",dislayer[0]); + popmessage("bg0: %01x",dislayer[0]); } if (input_code_pressed_once (KEYCODE_X)) { dislayer[1] ^= 1; - ui_popup("bg1: %01x",dislayer[1]); + popmessage("bg1: %01x",dislayer[1]); } if (input_code_pressed_once (KEYCODE_C)) { dislayer[2] ^= 1; - ui_popup("bg2: %01x",dislayer[2]); + popmessage("bg2: %01x",dislayer[2]); } if (input_code_pressed_once (KEYCODE_V)) { dislayer[3] ^= 1; - ui_popup("sprites: %01x",dislayer[3]); + popmessage("sprites: %01x",dislayer[3]); } if (input_code_pressed_once (KEYCODE_B)) { dislayer[4] ^= 1; - ui_popup("text: %01x",dislayer[4]); + popmessage("text: %01x",dislayer[4]); } #endif