summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/bus/coco/cococart.cpp2
-rw-r--r--src/devices/bus/iq151/minigraf.cpp8
-rw-r--r--src/devices/bus/iq151/ms151a.cpp8
-rw-r--r--src/devices/bus/isa/cga.cpp4
-rw-r--r--src/devices/bus/lpci/mpc105.cpp2
-rw-r--r--src/devices/bus/lpci/pci.cpp8
-rw-r--r--src/devices/bus/msx_cart/nomapper.cpp2
-rw-r--r--src/devices/bus/msx_slot/cartridge.cpp2
-rw-r--r--src/devices/bus/nubus/nubus_image.cpp4
-rw-r--r--src/devices/bus/sms_ctrl/lphaser.cpp8
-rw-r--r--src/devices/bus/snes/rom21.cpp6
-rw-r--r--src/devices/cpu/drcbec.cpp8
-rw-r--r--src/devices/cpu/drcfe.cpp4
-rw-r--r--src/devices/cpu/e132xs/e132xs.cpp40
-rw-r--r--src/devices/cpu/powerpc/ppccom.cpp2
-rw-r--r--src/devices/cpu/psx/psx.cpp8
-rw-r--r--src/devices/cpu/rsp/rsp.cpp6
-rw-r--r--src/devices/cpu/rsp/rspdrc.cpp2
-rw-r--r--src/devices/cpu/scudsp/scudsp.cpp4
-rw-r--r--src/devices/cpu/sharc/compute.hxx12
-rw-r--r--src/devices/cpu/superfx/superfx.cpp8
-rw-r--r--src/devices/cpu/tlcs900/tlcs900.cpp4
-rw-r--r--src/devices/cpu/tms34010/34010ops.hxx12
-rw-r--r--src/devices/cpu/tms34010/tms34010.cpp2
-rw-r--r--src/devices/cpu/uml.cpp4
-rw-r--r--src/devices/cpu/unsp/unsp.cpp2
-rw-r--r--src/devices/cpu/z8000/z8000ops.hxx4
-rw-r--r--src/devices/imagedev/cassette.cpp4
-rw-r--r--src/devices/machine/gt64xxx.cpp6
-rw-r--r--src/devices/machine/laserdsc.cpp18
-rw-r--r--src/devices/machine/laserdsc.h2
-rw-r--r--src/devices/machine/lpci.cpp8
-rw-r--r--src/devices/machine/mc68681.cpp6
-rw-r--r--src/devices/sound/astrocde.cpp4
-rw-r--r--src/devices/sound/disc_flt.hxx6
-rw-r--r--src/devices/sound/disc_wav.hxx4
-rw-r--r--src/devices/sound/discrete.cpp2
-rw-r--r--src/devices/sound/votrax.cpp2
-rw-r--r--src/devices/video/315_5124.cpp4
-rw-r--r--src/devices/video/bufsprite.h2
-rw-r--r--src/devices/video/gb_lcd.cpp6
-rw-r--r--src/devices/video/hd63484.cpp2
-rw-r--r--src/devices/video/huc6202.cpp2
-rw-r--r--src/devices/video/huc6270.cpp2
-rw-r--r--src/devices/video/mc6847.cpp6
-rw-r--r--src/devices/video/pc_vga.cpp2
-rw-r--r--src/devices/video/poly.h26
-rw-r--r--src/devices/video/polylgcy.cpp30
-rw-r--r--src/devices/video/sprite.h4
-rw-r--r--src/devices/video/stvvdp1.cpp4
-rw-r--r--src/devices/video/vector.cpp8
-rw-r--r--src/devices/video/voodoo.cpp22
-rw-r--r--src/devices/video/zeus2.cpp4
-rw-r--r--src/emu/debug/dvmemory.cpp14
-rw-r--r--src/emu/debug/express.h2
-rw-r--r--src/emu/drivenum.cpp2
-rw-r--r--src/emu/emupal.cpp2
-rw-r--r--src/emu/input.cpp8
-rw-r--r--src/emu/ioport.cpp4
-rw-r--r--src/emu/machine.cpp2
-rw-r--r--src/emu/render.cpp24
-rw-r--r--src/emu/rendfont.cpp4
-rw-r--r--src/emu/rendfont.h2
-rw-r--r--src/emu/romload.cpp4
-rw-r--r--src/emu/save.cpp6
-rw-r--r--src/emu/schedule.cpp4
-rw-r--r--src/emu/screen.cpp8
-rw-r--r--src/emu/softlist.cpp2
-rw-r--r--src/emu/sound.cpp4
-rw-r--r--src/emu/tilemap.cpp26
-rw-r--r--src/emu/tilemap.h2
-rw-r--r--src/emu/video.cpp6
-rw-r--r--src/emu/video/resnet.cpp6
-rw-r--r--src/frontend/mame/cheat.cpp8
-rw-r--r--src/frontend/mame/info.cpp8
-rw-r--r--src/frontend/mame/luaengine.cpp20
-rw-r--r--src/frontend/mame/ui/custmenu.cpp4
-rw-r--r--src/frontend/mame/ui/custui.cpp16
-rw-r--r--src/frontend/mame/ui/datmenu.cpp4
-rw-r--r--src/frontend/mame/ui/dirmenu.cpp12
-rw-r--r--src/frontend/mame/ui/menu.cpp4
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp4
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp2
-rw-r--r--src/frontend/mame/ui/selector.cpp4
-rw-r--r--src/frontend/mame/ui/selgame.cpp2
-rw-r--r--src/frontend/mame/ui/selmenu.cpp8
-rw-r--r--src/frontend/mame/ui/selsoft.cpp8
-rw-r--r--src/frontend/mame/ui/simpleselgame.cpp4
-rw-r--r--src/frontend/mame/ui/sndmenu.cpp2
-rw-r--r--src/frontend/mame/ui/submenu.cpp4
-rw-r--r--src/frontend/mame/ui/ui.cpp4
-rw-r--r--src/frontend/mame/ui/utils.cpp2
-rw-r--r--src/frontend/mame/ui/viewgfx.cpp12
-rw-r--r--src/frontend/mame/ui/widgets.cpp4
-rw-r--r--src/lib/formats/apridisk.cpp6
-rw-r--r--src/lib/formats/cassimg.cpp19
-rw-r--r--src/lib/formats/flopimg.cpp2
-rw-r--r--src/lib/formats/ioprocs.cpp4
-rw-r--r--src/lib/util/cdrom.cpp16
-rw-r--r--src/lib/util/chd.cpp14
-rw-r--r--src/lib/util/chdcodec.cpp2
-rw-r--r--src/lib/util/flac.cpp10
-rw-r--r--src/lib/util/huffman.cpp8
-rw-r--r--src/lib/util/options.h2
-rw-r--r--src/lib/util/palette.cpp13
-rw-r--r--src/lib/util/unicode.cpp8
-rw-r--r--src/lib/util/vbiparse.cpp6
-rw-r--r--src/mame/audio/hng64.cpp10
-rw-r--r--src/mame/drivers/atari400.cpp6
-rw-r--r--src/mame/drivers/icecold.cpp8
-rw-r--r--src/mame/drivers/jaguar.cpp2
-rw-r--r--src/mame/drivers/laser3k.cpp4
-rw-r--r--src/mame/drivers/magictg.cpp14
-rw-r--r--src/mame/drivers/maygayv1.cpp2
-rw-r--r--src/mame/drivers/midzeus.cpp4
-rw-r--r--src/mame/drivers/model3.cpp42
-rw-r--r--src/mame/drivers/namcona1.cpp6
-rw-r--r--src/mame/drivers/prestige.cpp4
-rw-r--r--src/mame/drivers/viper.cpp12
-rw-r--r--src/mame/machine/coco_vhd.cpp6
-rw-r--r--src/mame/machine/cybiko.cpp4
-rw-r--r--src/mame/machine/mac.cpp2
-rw-r--r--src/mame/machine/msx.cpp2
-rw-r--r--src/mame/machine/naomim2.cpp2
-rw-r--r--src/mame/machine/pce_cd.cpp2
-rw-r--r--src/mame/machine/segaic16.cpp2
-rw-r--r--src/mame/machine/sms.cpp8
-rw-r--r--src/mame/machine/vectrex.cpp2
-rw-r--r--src/mame/video/abc800.cpp4
-rw-r--r--src/mame/video/abc806.cpp2
-rw-r--r--src/mame/video/antic.cpp2
-rw-r--r--src/mame/video/apple2.cpp28
-rw-r--r--src/mame/video/astrocde.cpp12
-rw-r--r--src/mame/video/atarig1.cpp8
-rw-r--r--src/mame/video/chihiro.cpp98
-rw-r--r--src/mame/video/galaxian.cpp12
-rw-r--r--src/mame/video/jaguar.cpp4
-rw-r--r--src/mame/video/m62.cpp2
-rw-r--r--src/mame/video/micro3d.cpp2
-rw-r--r--src/mame/video/midzeus.cpp4
-rw-r--r--src/mame/video/midzeus2.cpp4
-rw-r--r--src/mame/video/model1.cpp12
-rw-r--r--src/mame/video/stic.cpp8
-rw-r--r--src/mame/video/tia.cpp22
-rw-r--r--src/osd/modules/debugger/debugwin.cpp2
-rw-r--r--src/osd/modules/debugger/osx/debugconsole.mm8
-rw-r--r--src/osd/modules/debugger/osx/debugview.mm18
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.mm10
-rw-r--r--src/osd/modules/debugger/osx/deviceinfoviewer.mm10
-rw-r--r--src/osd/modules/debugger/osx/disassemblyview.mm4
-rw-r--r--src/osd/modules/debugger/osx/disassemblyviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/errorlogviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/memoryview.mm4
-rw-r--r--src/osd/modules/debugger/osx/memoryviewer.mm2
-rw-r--r--src/osd/modules/debugger/osx/pointsviewer.mm4
-rw-r--r--src/osd/modules/debugger/qt/debuggerview.cpp4
-rw-r--r--src/osd/modules/debugger/qt/memorywindow.cpp2
-rw-r--r--src/osd/modules/debugger/win/consolewininfo.cpp6
-rw-r--r--src/osd/modules/debugger/win/debugviewinfo.cpp4
-rw-r--r--src/osd/modules/debugger/win/debugwin.h2
-rw-r--r--src/osd/modules/diagnostics/diagnostics_win32.cpp5
-rw-r--r--src/osd/modules/input/input_common.h7
-rw-r--r--src/osd/modules/input/input_dinput.cpp13
-rw-r--r--src/osd/modules/input/input_rawinput.cpp2
-rw-r--r--src/osd/modules/input/input_win32.cpp2
-rw-r--r--src/osd/modules/input/input_winhybrid.cpp2
-rw-r--r--src/osd/modules/input/input_xinput.cpp2
-rw-r--r--src/osd/modules/osdwindow.h2
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp3
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp10
-rw-r--r--src/osd/modules/render/draw13.cpp2
-rw-r--r--src/osd/modules/render/drawd3d.cpp6
-rw-r--r--src/osd/modules/sound/coreaudio_sound.cpp10
-rw-r--r--src/osd/modules/sound/direct_sound.cpp9
-rw-r--r--src/osd/modules/sound/sdl_sound.cpp4
-rw-r--r--src/osd/modules/sound/xaudio2_sound.cpp13
-rw-r--r--src/osd/osdcomm.h70
-rw-r--r--src/osd/osdsync.cpp12
-rw-r--r--src/osd/sdl/window.cpp20
-rw-r--r--src/osd/strconv.cpp7
-rw-r--r--src/osd/windows/window.cpp18
-rw-r--r--src/tools/chdman.cpp16
-rw-r--r--src/tools/imgtool/formats/coco_dsk.cpp3
-rw-r--r--src/tools/imgtool/modules/bml3.cpp2
-rw-r--r--src/tools/imgtool/modules/cybiko.cpp2
-rw-r--r--src/tools/imgtool/modules/fat.cpp28
-rw-r--r--src/tools/imgtool/modules/mac.cpp2
-rw-r--r--src/tools/imgtool/modules/macutil.cpp2
-rw-r--r--src/tools/imgtool/modules/os9.cpp10
-rw-r--r--src/tools/imgtool/modules/pc_hard.cpp2
-rw-r--r--src/tools/imgtool/modules/prodos.cpp4
-rw-r--r--src/tools/imgtool/modules/rsdos.cpp2
-rw-r--r--src/tools/imgtool/stream.cpp10
-rw-r--r--src/tools/ldresample.cpp2
-rw-r--r--src/tools/ldverify.cpp4
-rw-r--r--src/tools/pngcmp.cpp6
-rw-r--r--src/tools/regrep.cpp10
197 files changed, 780 insertions, 736 deletions
diff --git a/src/devices/bus/coco/cococart.cpp b/src/devices/bus/coco/cococart.cpp
index 904233550a5..76e6e9d8769 100644
--- a/src/devices/bus/coco/cococart.cpp
+++ b/src/devices/bus/coco/cococart.cpp
@@ -337,7 +337,7 @@ bool cococart_slot_device::call_load()
}
while(read_length < 0x8000)
{
- offs_t len = MIN(read_length, 0x8000 - read_length);
+ offs_t len = std::min(read_length, 0x8000 - read_length);
memcpy(m_cart->get_cart_base() + read_length, m_cart->get_cart_base(), len);
read_length += len;
}
diff --git a/src/devices/bus/iq151/minigraf.cpp b/src/devices/bus/iq151/minigraf.cpp
index 0eeae3af73b..446ce2c95a0 100644
--- a/src/devices/bus/iq151/minigraf.cpp
+++ b/src/devices/bus/iq151/minigraf.cpp
@@ -154,10 +154,10 @@ void iq151_minigraf_device::plotter_update(UINT8 control)
m_pen = BIT(control, 7);
// clamp within range
- m_posx = MAX(m_posx, 0);
- m_posx = MIN(m_posx, PAPER_MAX_X);
- m_posy = MAX(m_posy, 0);
- m_posy = MIN(m_posy, PAPER_MAX_Y);
+ m_posx = std::max(m_posx, INT16(0));
+ m_posx = std::min(m_posx, INT16(PAPER_MAX_X));
+ m_posy = std::max(m_posy, INT16(0));
+ m_posy = std::min(m_posy, INT16(PAPER_MAX_Y));
// if pen is down draws a point
if (m_pen)
diff --git a/src/devices/bus/iq151/ms151a.cpp b/src/devices/bus/iq151/ms151a.cpp
index f1bde64cf4c..2d0d732f1ad 100644
--- a/src/devices/bus/iq151/ms151a.cpp
+++ b/src/devices/bus/iq151/ms151a.cpp
@@ -156,10 +156,10 @@ void iq151_ms151a_device::plotter_update(UINT8 offset, UINT8 data)
}
// clamp within range
- m_posx = MAX(m_posx, 0);
- m_posx = MIN(m_posx, PAPER_MAX_X);
- m_posy = MAX(m_posy, 0);
- m_posy = MIN(m_posy, PAPER_MAX_Y);
+ m_posx = std::max(m_posx, 0);
+ m_posx = std::min(m_posx, PAPER_MAX_X);
+ m_posy = std::max(m_posy, 0);
+ m_posy = std::min(m_posy, PAPER_MAX_Y);
// if pen is down draws a point
if (m_pen)
diff --git a/src/devices/bus/isa/cga.cpp b/src/devices/bus/isa/cga.cpp
index 71e924dab84..622c316969c 100644
--- a/src/devices/bus/isa/cga.cpp
+++ b/src/devices/bus/isa/cga.cpp
@@ -349,7 +349,7 @@ void isa8_cga_device::device_start()
set_isa_device();
m_vram.resize(m_vram_size);
m_isa->install_device(0x3d0, 0x3df, read8_delegate( FUNC(isa8_cga_device::io_read), this ), write8_delegate( FUNC(isa8_cga_device::io_write), this ) );
- m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, "bank_cga", &m_vram[0]);
+ m_isa->install_bank(0xb8000, 0xb8000 + std::min(size_t(0x8000),m_vram_size) - 1, "bank_cga", &m_vram[0]);
if(m_vram_size == 0x4000)
m_isa->install_bank(0xbc000, 0xbffff, "bank_cga", &m_vram[0]);
@@ -1821,7 +1821,7 @@ WRITE8_MEMBER( isa8_ec1841_0002_device::io_write )
read8_delegate( FUNC(isa8_ec1841_0002_device::char_ram_read), this),
write8_delegate(FUNC(isa8_ec1841_0002_device::char_ram_write), this) );
} else {
- m_isa->install_bank(0xb8000, 0xb8000 + MIN(0x8000,m_vram_size) - 1, "bank_cga", &m_vram[0]);
+ m_isa->install_bank(0xb8000, 0xb8000 + std::min(size_t(0x8000),m_vram_size) - 1, "bank_cga", &m_vram[0]);
if(m_vram_size == 0x4000)
m_isa->install_bank(0xbc000, 0xbffff, "bank_cga", &m_vram[0]);
}
diff --git a/src/devices/bus/lpci/mpc105.cpp b/src/devices/bus/lpci/mpc105.cpp
index 74780b7159f..2fcde258b93 100644
--- a/src/devices/bus/lpci/mpc105.cpp
+++ b/src/devices/bus/lpci/mpc105.cpp
@@ -93,7 +93,7 @@ void mpc105_device::update_memory()
| (((m_bank_registers[(bank / 4) + 6] >> (bank % 4) * 8)) & 0x03) << 28
| 0x000FFFFF;
- end = MIN(end, begin + machine().device<ram_device>(RAM_TAG)->size() - 1);
+ end = std::min(end, begin + machine().device<ram_device>(RAM_TAG)->size() - 1);
if ((begin + 0x100000) <= end)
{
diff --git a/src/devices/bus/lpci/pci.cpp b/src/devices/bus/lpci/pci.cpp
index aa095a8cd4e..84f94a5569d 100644
--- a/src/devices/bus/lpci/pci.cpp
+++ b/src/devices/bus/lpci/pci.cpp
@@ -208,18 +208,18 @@ WRITE32_MEMBER( pci_bus_device::write )
READ64_MEMBER(pci_bus_device::read_64be)
{
UINT64 result = 0;
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ mem_mask = flipendian_int64(mem_mask);
if (ACCESSING_BITS_0_31)
result |= (UINT64)read(space, offset * 2 + 0, mem_mask >> 0) << 0;
if (ACCESSING_BITS_32_63)
result |= (UINT64)read(space, offset * 2 + 1, mem_mask >> 32) << 32;
- return FLIPENDIAN_INT64(result);
+ return flipendian_int64(result);
}
WRITE64_MEMBER(pci_bus_device::write_64be)
{
- data = FLIPENDIAN_INT64(data);
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ data = flipendian_int64(data);
+ mem_mask = flipendian_int64(mem_mask);
if (ACCESSING_BITS_0_31)
write(space, offset * 2 + 0, data >> 0, mem_mask >> 0);
if (ACCESSING_BITS_32_63)
diff --git a/src/devices/bus/msx_cart/nomapper.cpp b/src/devices/bus/msx_cart/nomapper.cpp
index 922649d5c1f..2f31fe937c7 100644
--- a/src/devices/bus/msx_cart/nomapper.cpp
+++ b/src/devices/bus/msx_cart/nomapper.cpp
@@ -81,7 +81,7 @@ void msx_cart_nomapper::initialize_cartridge()
break;
}
- m_end_address = MIN(m_start_address + size, 0x10000);
+ m_end_address = std::min(m_start_address + size, UINT32(0x10000));
}
READ8_MEMBER(msx_cart_nomapper::read_cart)
diff --git a/src/devices/bus/msx_slot/cartridge.cpp b/src/devices/bus/msx_slot/cartridge.cpp
index 17301489f3c..b926a5679d5 100644
--- a/src/devices/bus/msx_slot/cartridge.cpp
+++ b/src/devices/bus/msx_slot/cartridge.cpp
@@ -260,7 +260,7 @@ int msx_slot_cartridge_device::get_cart_type(UINT8 *rom, UINT32 length)
}
}
- if (MAX (kon4, kon5) > MAX (asc8, asc16) )
+ if (std::max(kon4, kon5) > std::max(asc8, asc16))
{
return (kon5 > kon4) ? KONAMI_SCC : KONAMI;
}
diff --git a/src/devices/bus/nubus/nubus_image.cpp b/src/devices/bus/nubus/nubus_image.cpp
index 86ffdee6de1..ec1f5f2e7fe 100644
--- a/src/devices/bus/nubus/nubus_image.cpp
+++ b/src/devices/bus/nubus/nubus_image.cpp
@@ -22,8 +22,8 @@
static UINT32 ni_htonl(UINT32 x) { return x; }
static UINT32 ni_ntohl(UINT32 x) { return x; }
#else
-static UINT32 ni_htonl(UINT32 x) { return FLIPENDIAN_INT32(x); }
-static UINT32 ni_ntohl(UINT32 x) { return FLIPENDIAN_INT32(x); }
+static UINT32 ni_htonl(UINT32 x) { return flipendian_int32(x); }
+static UINT32 ni_ntohl(UINT32 x) { return flipendian_int32(x); }
#endif
diff --git a/src/devices/bus/sms_ctrl/lphaser.cpp b/src/devices/bus/sms_ctrl/lphaser.cpp
index 9263b941cd3..474b8100d76 100644
--- a/src/devices/bus/sms_ctrl/lphaser.cpp
+++ b/src/devices/bus/sms_ctrl/lphaser.cpp
@@ -157,8 +157,8 @@ int sms_light_phaser_device::bright_aim_area( emu_timer *timer, int lgun_x, int
double dx_radius;
bool new_check_point = false;
- aim_area.min_y = MAX(lgun_y - LGUN_RADIUS, visarea.min_y);
- aim_area.max_y = MIN(lgun_y + LGUN_RADIUS, visarea.max_y);
+ aim_area.min_y = std::max(lgun_y - LGUN_RADIUS, visarea.min_y);
+ aim_area.max_y = std::min(lgun_y + LGUN_RADIUS, visarea.max_y);
while (!new_check_point)
{
@@ -187,8 +187,8 @@ int sms_light_phaser_device::bright_aim_area( emu_timer *timer, int lgun_x, int
dx_radius = ceil((float) sqrt((float) (r_x_r - (dy * dy))));
}
- aim_area.min_x = MAX(lgun_x - dx_radius, visarea.min_x);
- aim_area.max_x = MIN(lgun_x + dx_radius, visarea.max_x);
+ aim_area.min_x = std::max(INT32(lgun_x - dx_radius), visarea.min_x);
+ aim_area.max_x = std::min(INT32(lgun_x + dx_radius), visarea.max_x);
while (!new_check_point)
{
diff --git a/src/devices/bus/snes/rom21.cpp b/src/devices/bus/snes/rom21.cpp
index 477b75bdc1e..175e64991de 100644
--- a/src/devices/bus/snes/rom21.cpp
+++ b/src/devices/bus/snes/rom21.cpp
@@ -129,9 +129,9 @@ UINT8 sns_rom21_srtc_device::srtc_weekday( UINT32 year, UINT32 month, UINT32 day
UINT32 y = 1900, m = 1; // Epoch is 1900-01-01
UINT32 sum = 0; // Number of days passed since epoch
- year = MAX(1900, year);
- month = MAX(1, MIN(12, month));
- day = MAX(1, MIN(31, day));
+ year = std::max(1900U, year);
+ month = std::max(1U, std::min(12U, month));
+ day = std::max(1U, std::min(31U, day));
while (y < year)
{
diff --git a/src/devices/cpu/drcbec.cpp b/src/devices/cpu/drcbec.cpp
index 193512feb88..f3f9cf7be9f 100644
--- a/src/devices/cpu/drcbec.cpp
+++ b/src/devices/cpu/drcbec.cpp
@@ -1082,13 +1082,13 @@ int drcbe_c::execute(code_handle &entry)
case MAKE_OPCODE_SHORT(OP_BSWAP, 4, 0): // BSWAP dst,src
temp32 = PARAM1;
- PARAM0 = FLIPENDIAN_INT32(temp32);
+ PARAM0 = flipendian_int32(temp32);
break;
case MAKE_OPCODE_SHORT(OP_BSWAP, 4, 1):
temp32 = PARAM1;
flags = FLAGS32_NZ(temp32);
- PARAM0 = FLIPENDIAN_INT32(temp32);
+ PARAM0 = flipendian_int32(temp32);
break;
case MAKE_OPCODE_SHORT(OP_SHL, 4, 0): // SHL dst,src,count[,f]
@@ -1701,13 +1701,13 @@ int drcbe_c::execute(code_handle &entry)
case MAKE_OPCODE_SHORT(OP_BSWAP, 8, 0): // DBSWAP dst,src
temp64 = DPARAM1;
- DPARAM0 = FLIPENDIAN_INT64(temp64);
+ DPARAM0 = flipendian_int64(temp64);
break;
case MAKE_OPCODE_SHORT(OP_BSWAP, 8, 1):
temp64 = DPARAM1;
flags = FLAGS64_NZ(temp64);
- DPARAM0 = FLIPENDIAN_INT64(temp64);
+ DPARAM0 = flipendian_int64(temp64);
break;
case MAKE_OPCODE_SHORT(OP_SHL, 8, 0): // DSHL dst,src,count[,f]
diff --git a/src/devices/cpu/drcfe.cpp b/src/devices/cpu/drcfe.cpp
index 91ca544be02..92753e983d7 100644
--- a/src/devices/cpu/drcfe.cpp
+++ b/src/devices/cpu/drcfe.cpp
@@ -90,8 +90,8 @@ const opcode_desc *drc_frontend::describe_code(offs_t startpc)
pcstackptr++;
// loop while we still have a stack
- offs_t minpc = startpc - MIN(m_window_start, startpc);
- offs_t maxpc = startpc + MIN(m_window_end, 0xffffffff - startpc);
+ offs_t minpc = startpc - std::min(m_window_start, startpc);
+ offs_t maxpc = startpc + std::min(m_window_end, 0xffffffff - startpc);
while (pcstackptr != &pcstack[0])
{
// if we've already hit this PC, just mark it a branch target and continue
diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp
index be3ea79d7eb..e0889a24474 100644
--- a/src/devices/cpu/e132xs/e132xs.cpp
+++ b/src/devices/cpu/e132xs/e132xs.cpp
@@ -2008,7 +2008,7 @@ void hyperstone_device::hyperstone_movd(struct hyperstone_device::regs_decode *d
SET_DREG(SREG);
SET_DREGF(SREGF);
- tmp = CONCAT_64(SREG, SREGF);
+ tmp = concat_64(SREG, SREGF);
SET_Z( tmp == 0 ? 1 : 0 );
SET_N( SIGN_BIT(SREG) );
@@ -2032,7 +2032,7 @@ void hyperstone_device::hyperstone_divu(struct hyperstone_device::regs_decode *d
{
UINT64 dividend;
- dividend = CONCAT_64(DREG, DREGF);
+ dividend = concat_64(DREG, DREGF);
if( SREG == 0 )
{
@@ -2081,7 +2081,7 @@ void hyperstone_device::hyperstone_divs(struct hyperstone_device::regs_decode *d
{
INT64 dividend;
- dividend = (INT64) CONCAT_64(DREG, DREGF);
+ dividend = (INT64) concat_64(DREG, DREGF);
if( SREG == 0 || (DREG & 0x80000000) )
{
@@ -2750,7 +2750,7 @@ void hyperstone_device::hyperstone_shrdi(struct hyperstone_device::regs_decode *
high_order = DREG;
low_order = DREGF;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
if( N_VALUE )
SET_C((val >> (N_VALUE - 1)) & 1);
@@ -2759,8 +2759,8 @@ void hyperstone_device::hyperstone_shrdi(struct hyperstone_device::regs_decode *
val >>= N_VALUE;
- high_order = EXTRACT_64HI(val);
- low_order = EXTRACT_64LO(val);
+ high_order = extract_64hi(val);
+ low_order = extract_64lo(val);
SET_DREG(high_order);
SET_DREGF(low_order);
@@ -2786,7 +2786,7 @@ void hyperstone_device::hyperstone_shrd(struct hyperstone_device::regs_decode *d
high_order = DREG;
low_order = DREGF;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
if( n )
SET_C((val >> (n - 1)) & 1);
@@ -2795,8 +2795,8 @@ void hyperstone_device::hyperstone_shrd(struct hyperstone_device::regs_decode *d
val >>= n;
- high_order = EXTRACT_64HI(val);
- low_order = EXTRACT_64LO(val);
+ high_order = extract_64hi(val);
+ low_order = extract_64lo(val);
SET_DREG(high_order);
SET_DREGF(low_order);
@@ -2839,7 +2839,7 @@ void hyperstone_device::hyperstone_sardi(struct hyperstone_device::regs_decode *
high_order = DREG;
low_order = DREGF;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
if( N_VALUE )
SET_C((val >> (N_VALUE - 1)) & 1);
@@ -2888,7 +2888,7 @@ void hyperstone_device::hyperstone_sard(struct hyperstone_device::regs_decode *d
high_order = DREG;
low_order = DREGF;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
if( n )
SET_C((val >> (n - 1)) & 1);
@@ -2960,7 +2960,7 @@ void hyperstone_device::hyperstone_shldi(struct hyperstone_device::regs_decode *
high_order = DREG;
low_order = DREGF;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
SET_C( (N_VALUE)?(((val<<(N_VALUE-1))&U64(0x8000000000000000))?1:0):0);
mask = ((((UINT64)1) << (32 - N_VALUE)) - 1) ^ 0xffffffff;
tmp = high_order << N_VALUE;
@@ -2973,8 +2973,8 @@ void hyperstone_device::hyperstone_shldi(struct hyperstone_device::regs_decode *
val <<= N_VALUE;
- high_order = EXTRACT_64HI(val);
- low_order = EXTRACT_64LO(val);
+ high_order = extract_64hi(val);
+ low_order = extract_64lo(val);
SET_DREG(high_order);
SET_DREGF(low_order);
@@ -3004,7 +3004,7 @@ void hyperstone_device::hyperstone_shld(struct hyperstone_device::regs_decode *d
mask = ((((UINT64)1) << (32 - n)) - 1) ^ 0xffffffff;
- val = CONCAT_64(high_order, low_order);
+ val = concat_64(high_order, low_order);
SET_C( (n)?(((val<<(n-1))&U64(0x8000000000000000))?1:0):0);
tmp = high_order << n;
@@ -3016,8 +3016,8 @@ void hyperstone_device::hyperstone_shld(struct hyperstone_device::regs_decode *d
val <<= n;
- high_order = EXTRACT_64HI(val);
- low_order = EXTRACT_64LO(val);
+ high_order = extract_64hi(val);
+ low_order = extract_64lo(val);
SET_DREG(high_order);
SET_DREGF(low_order);
@@ -4270,7 +4270,7 @@ void hyperstone_device::hyperstone_extend(struct hyperstone_device::regs_decode
{
INT64 result;
- result = (INT64)CONCAT_64(GET_G_REG(14), GET_G_REG(15)) + (INT64)((INT64)(INT32)(vals) * (INT64)(INT32)(vald));
+ result = (INT64)concat_64(GET_G_REG(14), GET_G_REG(15)) + (INT64)((INT64)(INT32)(vals) * (INT64)(INT32)(vald));
vals = result >> 32;
vald = result & 0xffffffff;
@@ -4294,7 +4294,7 @@ void hyperstone_device::hyperstone_extend(struct hyperstone_device::regs_decode
{
INT64 result;
- result = (INT64)CONCAT_64(GET_G_REG(14), GET_G_REG(15)) - (INT64)((INT64)(INT32)(vals) * (INT64)(INT32)(vald));
+ result = (INT64)concat_64(GET_G_REG(14), GET_G_REG(15)) - (INT64)((INT64)(INT32)(vals) * (INT64)(INT32)(vald));
vals = result >> 32;
vald = result & 0xffffffff;
@@ -4318,7 +4318,7 @@ void hyperstone_device::hyperstone_extend(struct hyperstone_device::regs_decode
{
INT64 result;
- result = (INT64)CONCAT_64(GET_G_REG(14), GET_G_REG(15)) + (INT64)((INT64)(INT32)((vald & 0xffff0000) >> 16) * (INT64)(INT32)((vals & 0xffff0000) >> 16)) + ((INT64)(INT32)(vald & 0xffff) * (INT64)(INT32)(vals & 0xffff));
+ result = (INT64)concat_64(GET_G_REG(14), GET_G_REG(15)) + (INT64)((INT64)(INT32)((vald & 0xffff0000) >> 16) * (INT64)(INT32)((vals & 0xffff0000) >> 16)) + ((INT64)(INT32)(vald & 0xffff) * (INT64)(INT32)(vals & 0xffff));
vals = result >> 32;
vald = result & 0xffffffff;
diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp
index ce7249a6414..7611d6d0e25 100644
--- a/src/devices/cpu/powerpc/ppccom.cpp
+++ b/src/devices/cpu/powerpc/ppccom.cpp
@@ -409,7 +409,7 @@ inline void ppc_device::set_timebase(UINT64 newtb)
inline UINT32 ppc_device::get_decrementer()
{
INT64 cycles_until_zero = m_dec_zero_cycles - total_cycles();
- cycles_until_zero = MAX(cycles_until_zero, 0);
+ cycles_until_zero = std::max(cycles_until_zero, INT64(0));
if (!m_tb_divisor)
{
diff --git a/src/devices/cpu/psx/psx.cpp b/src/devices/cpu/psx/psx.cpp
index 35667a90374..e0a1394fd07 100644
--- a/src/devices/cpu/psx/psx.cpp
+++ b/src/devices/cpu/psx/psx.cpp
@@ -1173,16 +1173,16 @@ void psxcpu_device::multiplier_update()
case MULTIPLIER_OPERATION_MULT:
{
INT64 result = mul_32x32( (INT32)m_multiplier_operand1, (INT32)m_multiplier_operand2 );
- m_lo = EXTRACT_64LO( result );
- m_hi = EXTRACT_64HI( result );
+ m_lo = extract_64lo( result );
+ m_hi = extract_64hi( result );
}
break;
case MULTIPLIER_OPERATION_MULTU:
{
UINT64 result = mulu_32x32( m_multiplier_operand1, m_multiplier_operand2 );
- m_lo = EXTRACT_64LO( result );
- m_hi = EXTRACT_64HI( result );
+ m_lo = extract_64lo( result );
+ m_hi = extract_64hi( result );
}
break;
diff --git a/src/devices/cpu/rsp/rsp.cpp b/src/devices/cpu/rsp/rsp.cpp
index 9fd2525e193..d7e85e7525e 100644
--- a/src/devices/cpu/rsp/rsp.cpp
+++ b/src/devices/cpu/rsp/rsp.cpp
@@ -615,7 +615,7 @@ void rsp_device::execute_run()
if( m_sr & ( RSP_STATUS_HALT | RSP_STATUS_BROKE ) )
{
- m_rsp_state->icount = MIN(m_rsp_state->icount, 0);
+ m_rsp_state->icount = std::min(m_rsp_state->icount, 0);
}
while (m_rsp_state->icount > 0)
@@ -651,7 +651,7 @@ void rsp_device::execute_run()
case 0x0d: /* BREAK */
{
m_sp_set_status_func(0, 0x3, 0xffffffff);
- m_rsp_state->icount = MIN(m_rsp_state->icount, 1);
+ m_rsp_state->icount = std::min(m_rsp_state->icount, 1);
break;
}
case 0x20: /* ADD */ if (RDREG) RDVAL = (INT32)(RSVAL + RTVAL); break;
@@ -783,7 +783,7 @@ void rsp_device::execute_run()
if( m_sr & ( RSP_STATUS_HALT | RSP_STATUS_BROKE ) )
{
- m_rsp_state->icount = MIN(m_rsp_state->icount, 0);
+ m_rsp_state->icount = std::min(m_rsp_state->icount, 0);
}
/*m_cop2->dump(op);
if (((op >> 26) & 0x3f) == 0x3a)
diff --git a/src/devices/cpu/rsp/rspdrc.cpp b/src/devices/cpu/rsp/rspdrc.cpp
index ce334b91cc8..f6d15435b7f 100644
--- a/src/devices/cpu/rsp/rspdrc.cpp
+++ b/src/devices/cpu/rsp/rspdrc.cpp
@@ -273,7 +273,7 @@ void rsp_device::execute_run_drc()
{
if( m_sr & ( RSP_STATUS_HALT | RSP_STATUS_BROKE ) )
{
- m_rsp_state->icount = MIN(m_rsp_state->icount, 0);
+ m_rsp_state->icount = std::min(m_rsp_state->icount, 0);
break;
}
diff --git a/src/devices/cpu/scudsp/scudsp.cpp b/src/devices/cpu/scudsp/scudsp.cpp
index d752b082189..d4b28d87408 100644
--- a/src/devices/cpu/scudsp/scudsp.cpp
+++ b/src/devices/cpu/scudsp/scudsp.cpp
@@ -451,8 +451,8 @@ void scudsp_cpu_device::scudsp_operation(UINT32 opcode)
SET_V(((m_pl.si) ^ (m_acl.si)) & ((m_pl.si) ^ (i3)) & 0x80000000);
break;
case 0x6: /* AD2 */
- i1 = CONCAT_64((INT32)m_ph.si,m_pl.si);
- i2 = CONCAT_64((INT32)m_ach.si,m_acl.si);
+ i1 = concat_64((INT32)m_ph.si,m_pl.si);
+ i2 = concat_64((INT32)m_ach.si,m_acl.si);
m_alu = i1 + i2;
SET_Z((m_alu & S64(0xffffffffffff)) == 0);
SET_S((m_alu & S64(0x800000000000)) > 0);
diff --git a/src/devices/cpu/sharc/compute.hxx b/src/devices/cpu/sharc/compute.hxx
index 4124fadf6a9..852c739ed46 100644
--- a/src/devices/cpu/sharc/compute.hxx
+++ b/src/devices/cpu/sharc/compute.hxx
@@ -295,7 +295,7 @@ void adsp21062_device::compute_dec(int rn, int rx)
/* Rn = MIN(Rx, Ry) */
void adsp21062_device::compute_min(int rn, int rx, int ry)
{
- UINT32 r = MIN((INT32)REG(rx), (INT32)REG(ry));
+ UINT32 r = std::min((INT32)REG(rx), (INT32)REG(ry));
CLEAR_ALU_FLAGS();
SET_FLAG_AN(r);
@@ -309,7 +309,7 @@ void adsp21062_device::compute_min(int rn, int rx, int ry)
/* Rn = MAX(Rx, Ry) */
void adsp21062_device::compute_max(int rn, int rx, int ry)
{
- UINT32 r = MAX((INT32)REG(rx), (INT32)REG(ry));
+ UINT32 r = std::max((INT32)REG(rx), (INT32)REG(ry));
CLEAR_ALU_FLAGS();
SET_FLAG_AN(r);
@@ -699,7 +699,7 @@ void adsp21062_device::compute_fmax(int rn, int rx, int ry)
{
SHARC_REG r_alu;
- r_alu.f = MAX(FREG(rx), FREG(ry));
+ r_alu.f = std::max(FREG(rx), FREG(ry));
CLEAR_ALU_FLAGS();
m_core->astat |= (r_alu.f < 0.0f) ? AN : 0;
@@ -720,7 +720,7 @@ void adsp21062_device::compute_fmin(int rn, int rx, int ry)
{
SHARC_REG r_alu;
- r_alu.f = MIN(FREG(rx), FREG(ry));
+ r_alu.f = std::min(FREG(rx), FREG(ry));
CLEAR_ALU_FLAGS();
m_core->astat |= (r_alu.f < 0.0f) ? AN : 0;
@@ -1309,7 +1309,7 @@ void adsp21062_device::compute_fmul_fmax(int fm, int fxm, int fym, int fa, int f
SHARC_REG r_mul, r_alu;
r_mul.f = FREG(fxm) * FREG(fym);
- r_alu.f = MAX(FREG(fxa), FREG(fya));
+ r_alu.f = std::max(FREG(fxa), FREG(fya));
CLEAR_MULTIPLIER_FLAGS();
SET_FLAG_MN(r_mul.r);
@@ -1339,7 +1339,7 @@ void adsp21062_device::compute_fmul_fmin(int fm, int fxm, int fym, int fa, int f
SHARC_REG r_mul, r_alu;
r_mul.f = FREG(fxm) * FREG(fym);
- r_alu.f = MIN(FREG(fxa), FREG(fya));
+ r_alu.f = std::min(FREG(fxa), FREG(fya));
CLEAR_MULTIPLIER_FLAGS();
SET_FLAG_MN(r_mul.r);
diff --git a/src/devices/cpu/superfx/superfx.cpp b/src/devices/cpu/superfx/superfx.cpp
index 7601fa9bdc3..f0b7f79101c 100644
--- a/src/devices/cpu/superfx/superfx.cpp
+++ b/src/devices/cpu/superfx/superfx.cpp
@@ -533,7 +533,7 @@ void superfx_device::superfx_add_clocks_internal(UINT32 clocks)
{
if(m_romcl)
{
- m_romcl -= MIN(clocks, m_romcl);
+ m_romcl -= std::min(clocks, m_romcl);
if(m_romcl == 0)
{
m_sfr &= ~SUPERFX_SFR_R;
@@ -543,7 +543,7 @@ void superfx_device::superfx_add_clocks_internal(UINT32 clocks)
if(m_ramcl)
{
- m_ramcl -= MIN(clocks, m_ramcl);
+ m_ramcl -= std::min(clocks, m_ramcl);
if(m_ramcl == 0)
{
superfx_bus_write(0x700000 + (m_rambr << 16) + m_ramar, m_ramdr);
@@ -765,7 +765,7 @@ void superfx_device::execute_run()
if(!(m_sfr & SUPERFX_SFR_G))
{
superfx_add_clocks_internal(6);
- m_icount = MIN(m_icount, 0);
+ m_icount = std::min(m_icount, 0);
}
while (m_icount > 0 && (m_sfr & SUPERFX_SFR_G))
@@ -773,7 +773,7 @@ void superfx_device::execute_run()
if(!(m_sfr & SUPERFX_SFR_G))
{
superfx_add_clocks_internal(6);
- m_icount = MIN(m_icount, 0);
+ m_icount = std::min(m_icount, 0);
break;
}
diff --git a/src/devices/cpu/tlcs900/tlcs900.cpp b/src/devices/cpu/tlcs900/tlcs900.cpp
index cc610e7906d..fa36695b095 100644
--- a/src/devices/cpu/tlcs900/tlcs900.cpp
+++ b/src/devices/cpu/tlcs900/tlcs900.cpp
@@ -750,7 +750,7 @@ void tmp95c061_device::tlcs900_check_irqs()
}
/* Check highest allowed priority irq */
- for ( i = MAX( 1, ( ( m_sr.b.h & 0x70 ) >> 4 ) ); i < 7; i++ )
+ for ( i = std::max( 1, ( ( m_sr.b.h & 0x70 ) >> 4 ) ); i < 7; i++ )
{
if ( irq_vectors[i] >= 0 )
{
@@ -1704,7 +1704,7 @@ void tmp95c063_device::tlcs900_check_irqs()
}
/* Check highest allowed priority irq */
- for ( i = MAX( 1, ( ( m_sr.b.h & 0x70 ) >> 4 ) ); i < 7; i++ )
+ for ( i = std::max( 1, ( ( m_sr.b.h & 0x70 ) >> 4 ) ); i < 7; i++ )
{
if ( irq_vectors[i] >= 0 )
{
diff --git a/src/devices/cpu/tms34010/34010ops.hxx b/src/devices/cpu/tms34010/34010ops.hxx
index 486e4b2cb14..9b4300b6600 100644
--- a/src/devices/cpu/tms34010/34010ops.hxx
+++ b/src/devices/cpu/tms34010/34010ops.hxx
@@ -522,7 +522,7 @@ void tms340x0_device::dint(UINT16 op)
INT64 quotient = dividend / *rs; \
INT32 remainder = dividend % *rs; \
UINT32 signbits = (INT32)quotient >> 31; \
- if (EXTRACT_64HI(quotient) != signbits) \
+ if (extract_64hi(quotient) != signbits) \
{ \
SET_V_LOG(1); \
} \
@@ -569,7 +569,7 @@ void tms340x0_device::divs_b(UINT16 op) { DIVS(B); }
UINT64 dividend = ((UINT64)*rd1 << 32) | (UINT32)*rd2; \
UINT64 quotient = dividend / (UINT32)*rs; \
UINT32 remainder = dividend % (UINT32)*rs; \
- if (EXTRACT_64HI(quotient) != 0) \
+ if (extract_64hi(quotient) != 0) \
{ \
SET_V_LOG(1); \
} \
@@ -736,8 +736,8 @@ void tms340x0_device::modu_b(UINT16 op) { MODU(B); }
SET_Z_LOG(product == 0); \
SET_N_BIT(product >> 32, 31); \
\
- *rd1 = EXTRACT_64HI(product); \
- R##REG(DSTREG(op)|1) = EXTRACT_64LO(product); \
+ *rd1 = extract_64hi(product); \
+ R##REG(DSTREG(op)|1) = extract_64lo(product); \
\
COUNT_CYCLES(20); \
}
@@ -755,8 +755,8 @@ void tms340x0_device::mpys_b(UINT16 op) { MPYS(B); }
product = mulu_32x32(m1, *rd1); \
SET_Z_LOG(product == 0); \
\
- *rd1 = EXTRACT_64HI(product); \
- R##REG(DSTREG(op)|1) = EXTRACT_64LO(product); \
+ *rd1 = extract_64hi(product); \
+ R##REG(DSTREG(op)|1) = extract_64lo(product); \
\
COUNT_CYCLES(21); \
}
diff --git a/src/devices/cpu/tms34010/tms34010.cpp b/src/devices/cpu/tms34010/tms34010.cpp
index 3a5eb434554..e7098319d08 100644
--- a/src/devices/cpu/tms34010/tms34010.cpp
+++ b/src/devices/cpu/tms34010/tms34010.cpp
@@ -849,7 +849,7 @@ TIMER_CALLBACK_MEMBER( tms340x0_device::scanline_callback )
vtotal = SMART_IOREG(VTOTAL);
if (!master)
{
- vtotal = MIN(m_screen->height() - 1, vtotal);
+ vtotal = std::min(m_screen->height() - 1, vtotal);
vcount = m_screen->vpos();
}
diff --git a/src/devices/cpu/uml.cpp b/src/devices/cpu/uml.cpp
index 5810391dcb9..2ca54703497 100644
--- a/src/devices/cpu/uml.cpp
+++ b/src/devices/cpu/uml.cpp
@@ -661,9 +661,9 @@ void uml::instruction::simplify()
if (m_param[1].is_immediate())
{
if (m_size == 4)
- convert_to_mov_immediate(FLIPENDIAN_INT32(m_param[1].immediate()));
+ convert_to_mov_immediate(flipendian_int32(m_param[1].immediate()));
else if (m_size == 8)
- convert_to_mov_immediate(FLIPENDIAN_INT64(m_param[1].immediate()));
+ convert_to_mov_immediate(flipendian_int64(m_param[1].immediate()));
}
break;
diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp
index 15d557335c1..a6215b98fcf 100644
--- a/src/devices/cpu/unsp/unsp.cpp
+++ b/src/devices/cpu/unsp/unsp.cpp
@@ -797,7 +797,7 @@ void unsp_device::execute_run()
}
m_icount -= 5;
- m_icount = MAX(m_icount, 0);
+ m_icount = std::max(m_icount, 0);
}
}
diff --git a/src/devices/cpu/z8000/z8000ops.hxx b/src/devices/cpu/z8000/z8000ops.hxx
index c9d0b365783..4bb0d781f1d 100644
--- a/src/devices/cpu/z8000/z8000ops.hxx
+++ b/src/devices/cpu/z8000/z8000ops.hxx
@@ -5597,8 +5597,8 @@ void z8002_device::ZB1_dddd_0000()
void z8002_device::ZB1_dddd_0111()
{
GET_DST(OP0,NIB2);
- RQ(dst) = CONCAT_64((RQ(dst) & S32) ?
- 0xfffffffful : 0, EXTRACT_64LO(RQ(dst)));
+ RQ(dst) = concat_64((RQ(dst) & S32) ?
+ 0xfffffffful : 0, extract_64lo(RQ(dst)));
}
/******************************************
diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp
index 622a6994fec..57c4f52d15a 100644
--- a/src/devices/imagedev/cassette.cpp
+++ b/src/devices/imagedev/cassette.cpp
@@ -157,8 +157,8 @@ void cassette_image_device::output(double value)
{
update();
- value = MIN(value, 1.0);
- value = MAX(value, -1.0);
+ value = std::min(value, 1.0);
+ value = std::max(value, -1.0);
m_value = (INT32) (value * 0x7FFFFFFF);
}
diff --git a/src/devices/machine/gt64xxx.cpp b/src/devices/machine/gt64xxx.cpp
index d1b0f15e61a..15fb9443234 100644
--- a/src/devices/machine/gt64xxx.cpp
+++ b/src/devices/machine/gt64xxx.cpp
@@ -526,7 +526,7 @@ READ32_MEMBER (gt64xxx_device::cpu_if_r)
break;
}
- if (m_be) result = FLIPENDIAN_INT32(result);
+ if (m_be) result = flipendian_int32(result);
return result;
}
@@ -534,8 +534,8 @@ READ32_MEMBER (gt64xxx_device::cpu_if_r)
WRITE32_MEMBER(gt64xxx_device::cpu_if_w)
{
if (m_be) {
- data = FLIPENDIAN_INT32(data);
- mem_mask = FLIPENDIAN_INT32(mem_mask);
+ data = flipendian_int32(data);
+ mem_mask = flipendian_int32(mem_mask);
}
UINT32 oldata = m_reg[offset];
diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp
index 50e6dc09836..3867e9b5ca6 100644
--- a/src/devices/machine/laserdsc.cpp
+++ b/src/devices/machine/laserdsc.cpp
@@ -162,7 +162,7 @@ UINT32 laserdisc_device::screen_update(screen_device &screen, bitmap_rgb32 &bitm
rectangle clip(m_overclip);
clip.min_y = cliprect.min_y * overbitmap.height() / bitmap.height();
if (cliprect.min_y == screen.visible_area().min_y)
- clip.min_y = MIN(clip.min_y, m_overclip.min_y);
+ clip.min_y = std::min(clip.min_y, m_overclip.min_y);
clip.max_y = (cliprect.max_y + 1) * overbitmap.height() / bitmap.height() - 1;
// call the update callback
@@ -700,8 +700,8 @@ INT32 laserdisc_device::generic_update(const vbi_metadata &vbi, int fieldnum, co
if (delta < 0)
delta--;
advanceby = delta;
- advanceby = MIN(advanceby, GENERIC_SEARCH_SPEED);
- advanceby = MAX(advanceby, -GENERIC_SEARCH_SPEED);
+ advanceby = std::min(advanceby, GENERIC_SEARCH_SPEED);
+ advanceby = std::max(advanceby, -GENERIC_SEARCH_SPEED);
}
}
@@ -780,7 +780,7 @@ void laserdisc_device::init_disc()
if (err != CHDERR_NONE || m_vbidata.size() != totalhunks * VBI_PACKED_BYTES)
throw emu_fatalerror("Precomputed VBI metadata missing or incorrect size");
}
- m_maxtrack = MAX(m_maxtrack, VIRTUAL_LEAD_IN_TRACKS + VIRTUAL_LEAD_OUT_TRACKS + m_chdtracks);
+ m_maxtrack = std::max(m_maxtrack, VIRTUAL_LEAD_IN_TRACKS + VIRTUAL_LEAD_OUT_TRACKS + m_chdtracks);
}
@@ -986,9 +986,9 @@ laserdisc_device::frame_data &laserdisc_device::current_frame()
void laserdisc_device::read_track_data()
{
// compute the chdhunk number we are going to read
- INT32 chdtrack = m_curtrack - 1 - VIRTUAL_LEAD_IN_TRACKS;
- chdtrack = MAX(chdtrack, 0);
- chdtrack = MIN(chdtrack, m_chdtracks - 1);
+ UINT32 chdtrack = m_curtrack - 1 - VIRTUAL_LEAD_IN_TRACKS;
+ chdtrack = std::max(chdtrack, UINT32(0));
+ chdtrack = std::min(chdtrack, m_chdtracks - 1);
UINT32 readhunk = chdtrack * 2 + m_fieldnum;
// cheat and look up the metadata we are about to retrieve
@@ -1118,8 +1118,8 @@ void laserdisc_device::process_track_data()
if (m_avhuff_config.audio[chnum] == &m_audiobuffer[chnum][0])
{
// move data to the end
- int samplesleft = m_audiobufsize - m_audiobufin;
- samplesleft = MIN(samplesleft, m_audiocursamples);
+ UINT32 samplesleft = m_audiobufsize - m_audiobufin;
+ samplesleft = std::min(samplesleft, m_audiocursamples);
memmove(&m_audiobuffer[chnum][m_audiobufin], &m_audiobuffer[chnum][0], samplesleft * 2);
// shift data at the beginning
diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h
index fa67a167ddc..1bb19bea0a0 100644
--- a/src/devices/machine/laserdsc.h
+++ b/src/devices/machine/laserdsc.h
@@ -278,7 +278,7 @@ private:
void init_disc();
void init_video();
void init_audio();
- void add_and_clamp_track(INT32 delta) { m_curtrack += delta; m_curtrack = MAX(m_curtrack, 1); m_curtrack = MIN(m_curtrack, m_maxtrack - 1); }
+ void add_and_clamp_track(INT32 delta) { m_curtrack += delta; m_curtrack = std::max(m_curtrack, 1); m_curtrack = std::min(m_curtrack, INT32(m_maxtrack) - 1); }
void fillbitmap_yuy16(bitmap_yuy16 &bitmap, UINT8 yval, UINT8 cr, UINT8 cb);
void update_slider_pos();
void vblank_state_changed(screen_device &screen, bool vblank_state);
diff --git a/src/devices/machine/lpci.cpp b/src/devices/machine/lpci.cpp
index d03667d5be8..004b50dfcaf 100644
--- a/src/devices/machine/lpci.cpp
+++ b/src/devices/machine/lpci.cpp
@@ -212,18 +212,18 @@ WRITE32_MEMBER( pci_bus_legacy_device::write )
READ64_MEMBER(pci_bus_legacy_device::read_64be)
{
UINT64 result = 0;
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ mem_mask = flipendian_int64(mem_mask);
if (ACCESSING_BITS_0_31)
result |= (UINT64)read(space, offset * 2 + 0, mem_mask >> 0) << 0;
if (ACCESSING_BITS_32_63)
result |= (UINT64)read(space, offset * 2 + 1, mem_mask >> 32) << 32;
- return FLIPENDIAN_INT64(result);
+ return flipendian_int64(result);
}
WRITE64_MEMBER(pci_bus_legacy_device::write_64be)
{
- data = FLIPENDIAN_INT64(data);
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ data = flipendian_int64(data);
+ mem_mask = flipendian_int64(mem_mask);
if (ACCESSING_BITS_0_31)
write(space, offset * 2 + 0, data >> 0, mem_mask >> 0);
if (ACCESSING_BITS_32_63)
diff --git a/src/devices/machine/mc68681.cpp b/src/devices/machine/mc68681.cpp
index ec5e459d700..de8ede60fda 100644
--- a/src/devices/machine/mc68681.cpp
+++ b/src/devices/machine/mc68681.cpp
@@ -307,7 +307,7 @@ TIMER_CALLBACK_MEMBER( mc68681_device::duart_timer_callback )
update_interrupts();
}
- int count = MAX(CTR.w.l, 1);
+ int count = std::max(CTR.w.l, UINT16(1));
duart68681_start_ct(count);
}
else
@@ -400,7 +400,7 @@ READ8_MEMBER( mc68681_device::read )
half_period = 0;
}
- int count = MAX(CTR.w.l, 1);
+ int count = std::max(CTR.w.l, UINT16(1));
duart68681_start_ct(count);
break;
}
@@ -449,7 +449,7 @@ WRITE8_MEMBER( mc68681_device::write )
if (data & 0x40)
{
// Entering timer mode
- UINT16 count = MAX(CTR.w.l, 1);
+ UINT16 count = std::max(CTR.w.l, UINT16(1));
half_period = 0;
duart68681_start_ct(count);
diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp
index c26af3aca19..11bb951dc06 100644
--- a/src/devices/sound/astrocde.cpp
+++ b/src/devices/sound/astrocde.cpp
@@ -123,8 +123,8 @@ void astrocade_device::sound_stream_update(sound_stream &stream, stream_sample_t
/* compute the number of cycles until the next master oscillator reset */
/* or until the next noise boundary */
- samples_this_time = MIN(samples, 256 - master_count);
- samples_this_time = MIN(samples_this_time, 64 - noise_clock);
+ samples_this_time = std::min(samples, 256 - master_count);
+ samples_this_time = std::min(samples_this_time, 64 - noise_clock);
samples -= samples_this_time;
/* sum the output of the tone generators */
diff --git a/src/devices/sound/disc_flt.hxx b/src/devices/sound/disc_flt.hxx
index 18cb8f41c1c..346f18c04af 100644
--- a/src/devices/sound/disc_flt.hxx
+++ b/src/devices/sound/disc_flt.hxx
@@ -1187,14 +1187,14 @@ DISCRETE_STEP( dst_rcintegrate)
else
iQc = EM_IC(u - vE);
- m_vCE = MIN(vP - 0.1, vP - RG * iQc);
+ m_vCE = std::min(vP - 0.1, vP - RG * iQc);
/* Avoid oscillations
* The method tends to largely overshoot - no wonder without
* iterative solution approximation
*/
- m_vCE = MAX(m_vCE, 0.1 );
+ m_vCE = std::max(m_vCE, 0.1 );
m_vCE = 0.1 * m_vCE + 0.9 * (vP - vE - iQ * DST_RCINTEGRATE__R3);
switch (m_type)
@@ -1206,7 +1206,7 @@ DISCRETE_STEP( dst_rcintegrate)
set_output(0, vE);
break;
case DISC_RC_INTEGRATE_TYPE3:
- set_output(0, MAX(0, vP - iQ * DST_RCINTEGRATE__R3));
+ set_output(0, std::max(0.0, vP - iQ * DST_RCINTEGRATE__R3));
break;
}
}
diff --git a/src/devices/sound/disc_wav.hxx b/src/devices/sound/disc_wav.hxx
index 8087ea86627..a694f407d90 100644
--- a/src/devices/sound/disc_wav.hxx
+++ b/src/devices/sound/disc_wav.hxx
@@ -1579,13 +1579,13 @@ DISCRETE_STEP(dss_inverter_osc)
vG2 = this->tf(vG3);
break;
case IS_TYPE4:
- vI = MIN(I_ENABLE(), vI + 0.7);
+ vI = std::min(I_ENABLE(), vI + 0.7);
vG1 = 0;
vG3 = this->tf(vI);
vG2 = this->tf(vG3);
break;
case IS_TYPE5:
- vI = MAX(I_ENABLE(), vI - 0.7);
+ vI = std::max(I_ENABLE(), vI - 0.7);
vG1 = 0;
vG3 = this->tf(vI);
vG2 = this->tf(vG3);
diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp
index 80498db791f..9bf5d4d470f 100644
--- a/src/devices/sound/discrete.cpp
+++ b/src/devices/sound/discrete.cpp
@@ -235,7 +235,7 @@ void *discrete_task::task_callback(void *param, int threadid)
bool discrete_task::process(void)
{
- int samples = MIN(m_samples, MAX_SAMPLES_PER_TASK_SLICE);
+ int samples = std::min(int(m_samples), MAX_SAMPLES_PER_TASK_SLICE);
/* check dependencies */
for_each(input_buffer *, sn, &source_list)
diff --git a/src/devices/sound/votrax.cpp b/src/devices/sound/votrax.cpp
index d77b3669aa0..cfd512782c7 100644
--- a/src/devices/sound/votrax.cpp
+++ b/src/devices/sound/votrax.cpp
@@ -1372,6 +1372,6 @@ osd_printf_debug("%s: REQUEST\n", timer.machine().time().as_string(3));
}
// plus 1/2
- clocks_until_request = MAX(clocks_until_request, (1 << P_CLOCK_BIT) / 2);
+ clocks_until_request = std::max(clocks_until_request, UINT32(1 << P_CLOCK_BIT) / 2);
timer.adjust(attotime::from_ticks(clocks_until_request, m_master_clock_freq));
}
diff --git a/src/devices/video/315_5124.cpp b/src/devices/video/315_5124.cpp
index 09e5e6cf1d6..50a8c5bf3a1 100644
--- a/src/devices/video/315_5124.cpp
+++ b/src/devices/video/315_5124.cpp
@@ -1138,7 +1138,7 @@ void sega315_5124_device::draw_sprites_mode4( int *line_buffer, int *priority_se
else
{
sprite_col_occurred = true;
- sprite_col_x = MIN(sprite_col_x, pixel_plot_x);
+ sprite_col_x = std::min(sprite_col_x, pixel_plot_x);
}
}
}
@@ -1218,7 +1218,7 @@ void sega315_5124_device::draw_sprites_tms9918_mode( int *line_buffer, int line
else
{
sprite_col_occurred = true;
- sprite_col_x = MIN(sprite_col_x, pixel_plot_x);
+ sprite_col_x = std::min(sprite_col_x, pixel_plot_x);
}
}
}
diff --git a/src/devices/video/bufsprite.h b/src/devices/video/bufsprite.h
index 7e8606f454b..2e1f7c98bc5 100644
--- a/src/devices/video/bufsprite.h
+++ b/src/devices/video/bufsprite.h
@@ -67,7 +67,7 @@ public:
{
assert(m_spriteram != nullptr);
if (m_spriteram != nullptr)
- memcpy(&m_buffered[0], m_spriteram + srcoffset, MIN(srclength, m_spriteram.bytes() / sizeof(_Type) - srcoffset) * sizeof(_Type));
+ memcpy(&m_buffered[0], m_spriteram + srcoffset, std::min(srclength, UINT32(m_spriteram.bytes() / sizeof(_Type) - srcoffset)) * sizeof(_Type));
return &m_buffered[0];
}
diff --git a/src/devices/video/gb_lcd.cpp b/src/devices/video/gb_lcd.cpp
index c7560b485bf..60a6684ae5f 100644
--- a/src/devices/video/gb_lcd.cpp
+++ b/src/devices/video/gb_lcd.cpp
@@ -658,7 +658,7 @@ void gb_lcd_device::update_scanline()
if (cycles_to_go < 160)
{
- m_end_x = MIN(160 - cycles_to_go, 160);
+ m_end_x = std::min(int(160 - cycles_to_go), 160);
/* Draw empty pixels when the background is disabled */
if (!(LCDCONT & 0x01))
{
@@ -1000,7 +1000,7 @@ void sgb_lcd_device::update_scanline()
}
if (cycles_to_go < 160)
{
- m_end_x = MIN(160 - cycles_to_go,160);
+ m_end_x = std::min(int(160 - cycles_to_go),160);
/* if background or screen disabled clear line */
if (!(LCDCONT & 0x01))
@@ -1267,7 +1267,7 @@ void cgb_lcd_device::update_scanline()
if (cycles_to_go < 160)
{
- m_end_x = MIN(160 - cycles_to_go, 160);
+ m_end_x = std::min(int(160 - cycles_to_go), 160);
/* Draw empty line when the background is disabled */
if (!(LCDCONT & 0x01))
{
diff --git a/src/devices/video/hd63484.cpp b/src/devices/video/hd63484.cpp
index b4d46f125dd..74f06cc734d 100644
--- a/src/devices/video/hd63484.cpp
+++ b/src/devices/video/hd63484.cpp
@@ -812,7 +812,7 @@ void hd63484_device::draw_line(INT16 sx, INT16 sy, INT16 ex, INT16 ey)
void hd63484_device::draw_ellipse(INT16 cx, INT16 cy, double dx, double dy, double s_angol, double e_angol, bool c)
{
- double inc = 1.0 / (MAX(dx, dy) * 100);
+ double inc = 1.0 / (std::max(dx, dy) * 100);
for (double angol = s_angol; fabs(angol - e_angol) >= inc*2; angol += inc * (c ? -1 : +1))
{
if (angol > DEGREE_TO_RADIAN(360)) angol -= DEGREE_TO_RADIAN(360);
diff --git a/src/devices/video/huc6202.cpp b/src/devices/video/huc6202.cpp
index 2e2c4e60b6a..24a409da420 100644
--- a/src/devices/video/huc6202.cpp
+++ b/src/devices/video/huc6202.cpp
@@ -155,7 +155,7 @@ READ16_MEMBER( huc6202_device::time_until_next_event )
UINT16 next_event_clocks_0 = m_time_til_next_event_0_cb( 0, 0xffff );
UINT16 next_event_clocks_1 = m_time_til_next_event_1_cb( 0, 0xffff );
- return MIN( next_event_clocks_0, next_event_clocks_1 );
+ return std::min( next_event_clocks_0, next_event_clocks_1 );
}
diff --git a/src/devices/video/huc6270.cpp b/src/devices/video/huc6270.cpp
index 42527fbcf16..027d75bb05f 100644
--- a/src/devices/video/huc6270.cpp
+++ b/src/devices/video/huc6270.cpp
@@ -393,7 +393,7 @@ inline void huc6270_device::next_horz_state()
case HUC6270_HSW:
m_horz_state = HUC6270_HDS;
- m_horz_to_go = MAX( ( ( m_hsr >> 8 ) & 0x7F ), 2 ) + 1;
+ m_horz_to_go = std::max( ( ( m_hsr >> 8 ) & 0x7F ), 2 ) + 1;
/* If section has ended, advance to next vertical state */
while ( m_vert_to_go == 0 )
diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp
index ec072c6e206..89c6306dc89 100644
--- a/src/devices/video/mc6847.cpp
+++ b/src/devices/video/mc6847.cpp
@@ -743,8 +743,8 @@ void mc6847_base_device::record_body_scanline(UINT16 physical_scanline, UINT16 s
void mc6847_base_device::record_partial_body_scanline(UINT16 physical_scanline, UINT16 scanline, INT32 start_clock, INT32 end_clock)
{
- INT32 start_pos = MAX(scanline_position_from_clock(start_clock), 0);
- INT32 end_pos = MIN(scanline_position_from_clock(end_clock), 42);
+ INT32 start_pos = std::max(scanline_position_from_clock(start_clock), 0);
+ INT32 end_pos = std::min(scanline_position_from_clock(end_clock), 42);
if (start_pos < end_pos)
record_body_scanline(physical_scanline, scanline, start_pos, end_pos);
@@ -834,7 +834,7 @@ UINT32 mc6847_base_device::screen_update(screen_device &screen, bitmap_rgb32 &bi
}
}
- for (y = MAX(0, min_y - base_y); y < MIN(192, max_y - base_y); y++)
+ for (y = std::max(0, min_y - base_y); y < std::min(192, max_y - base_y); y++)
{
/* left border */
for (x = min_x; x < base_x; x++)
diff --git a/src/devices/video/pc_vga.cpp b/src/devices/video/pc_vga.cpp
index c40d801eb11..5bdd16b4869 100644
--- a/src/devices/video/pc_vga.cpp
+++ b/src/devices/video/pc_vga.cpp
@@ -366,7 +366,7 @@ void vga_device::vga_vh_text(bitmap_rgb32 &bitmap, const rectangle &cliprect)
back_col = (attr & 0x70) >> 4;
back_col |= (vga.attribute.data[0x10]&8) ? 0 : ((attr & 0x80) >> 4);
- for (h = MAX(-line, 0); (h < height) && (line+h < MIN(TEXT_LINES, bitmap.height())); h++)
+ for (h = std::max(-line, 0); (h < height) && (line+h < std::min(TEXT_LINES, bitmap.height())); h++)
{
bitmapline = &bitmap.pix32(line+h);
bits = vga.memory[font_base+(h>>(vga.crtc.scan_doubling))];
diff --git a/src/devices/video/poly.h b/src/devices/video/poly.h
index 5427e0d0ef9..11e078b8186 100644
--- a/src/devices/video/poly.h
+++ b/src/devices/video/poly.h
@@ -224,7 +224,7 @@ private:
// internal array types
typedef poly_array<polygon_info, _MaxPolys> polygon_array;
typedef poly_array<_ObjectData, _MaxPolys + 1> objectdata_array;
- typedef poly_array<work_unit, MIN(_MaxPolys * UNITS_PER_POLY, 65535)> unit_array;
+ typedef poly_array<work_unit, std::min(_MaxPolys * UNITS_PER_POLY, 65535)> unit_array;
// round in a cross-platform consistent manner
inline INT32 round_coordinate(_BaseType value)
@@ -525,8 +525,8 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_tile(
// clip coordinates
INT32 v1yclip = v1y;
INT32 v2yclip = v2y + ((m_flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- v1yclip = MAX(v1yclip, cliprect.min_y);
- v2yclip = MIN(v2yclip, cliprect.max_y + 1);
+ v1yclip = std::max(v1yclip, cliprect.min_y);
+ v2yclip = std::min(v2yclip, cliprect.max_y + 1);
if (v2yclip - v1yclip <= 0)
return 0;
@@ -592,7 +592,7 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_tile(
// fill in the work unit basics
unit.polygon = &polygon;
- unit.count_next = MIN(v2yclip - curscan, scaninc);
+ unit.count_next = std::min(v2yclip - curscan, scaninc);
unit.scanline = curscan;
unit.previtem = m_unit_bucket[bucketnum];
m_unit_bucket[bucketnum] = unit_index;
@@ -670,8 +670,8 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_trian
// clip coordinates
INT32 v1yclip = v1y;
INT32 v3yclip = v3y + ((m_flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- v1yclip = MAX(v1yclip, cliprect.min_y);
- v3yclip = MIN(v3yclip, cliprect.max_y + 1);
+ v1yclip = std::max(v1yclip, cliprect.min_y);
+ v3yclip = std::min(v3yclip, cliprect.max_y + 1);
if (v3yclip - v1yclip <= 0)
return 0;
@@ -750,7 +750,7 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_trian
// fill in the work unit basics
unit.polygon = &polygon;
- unit.count_next = MIN(v3yclip - curscan, scaninc);
+ unit.count_next = std::min(v3yclip - curscan, scaninc);
unit.scanline = curscan;
unit.previtem = m_unit_bucket[bucketnum];
m_unit_bucket[bucketnum] = unit_index;
@@ -860,8 +860,8 @@ template<typename _BaseType, class _ObjectData, int _MaxParams, int _MaxPolys>
UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_triangle_custom(const rectangle &cliprect, render_delegate callback, int startscanline, int numscanlines, const extent_t *extents)
{
// clip coordinates
- INT32 v1yclip = MAX(startscanline, cliprect.min_y);
- INT32 v3yclip = MIN(startscanline + numscanlines, cliprect.max_y + 1);
+ INT32 v1yclip = std::max(startscanline, cliprect.min_y);
+ INT32 v3yclip = std::min(startscanline + numscanlines, cliprect.max_y + 1);
if (v3yclip - v1yclip <= 0)
return 0;
@@ -883,7 +883,7 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_trian
// fill in the work unit basics
unit.polygon = &polygon;
- unit.count_next = MIN(v3yclip - curscan, scaninc);
+ unit.count_next = std::min(v3yclip - curscan, scaninc);
unit.scanline = curscan;
unit.previtem = m_unit_bucket[bucketnum];
m_unit_bucket[bucketnum] = unit_index;
@@ -968,8 +968,8 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_polyg
// clip coordinates
INT32 minyclip = miny;
INT32 maxyclip = maxy + ((m_flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- minyclip = MAX(minyclip, cliprect.min_y);
- maxyclip = MIN(maxyclip, cliprect.max_y + 1);
+ minyclip = std::max(minyclip, cliprect.min_y);
+ maxyclip = std::min(maxyclip, cliprect.max_y + 1);
if (maxyclip - minyclip <= 0)
return 0;
@@ -1058,7 +1058,7 @@ UINT32 poly_manager<_BaseType, _ObjectData, _MaxParams, _MaxPolys>::render_polyg
// fill in the work unit basics
unit.polygon = &polygon;
- unit.count_next = MIN(maxyclip - curscan, scaninc);
+ unit.count_next = std::min(maxyclip - curscan, scaninc);
unit.scanline = curscan;
unit.previtem = m_unit_bucket[bucketnum];
m_unit_bucket[bucketnum] = unit_index;
diff --git a/src/devices/video/polylgcy.cpp b/src/devices/video/polylgcy.cpp
index 25dd61aa733..2971b528781 100644
--- a/src/devices/video/polylgcy.cpp
+++ b/src/devices/video/polylgcy.cpp
@@ -320,7 +320,7 @@ legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t
/* allocate polygons */
poly->polygon_size = sizeof(polygon_info);
- poly->polygon_count = MAX(max_polys, 1);
+ poly->polygon_count = std::max(max_polys, 1);
poly->polygon_next = 0;
poly->polygon = (polygon_info **)allocate_array(machine, &poly->polygon_size, poly->polygon_count);
@@ -332,7 +332,7 @@ legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t
/* allocate triangle work units */
poly->unit_size = (flags & POLYFLAG_ALLOW_QUADS) ? sizeof(quad_work_unit) : sizeof(tri_work_unit);
- poly->unit_count = MIN(poly->polygon_count * UNITS_PER_POLY, 65535);
+ poly->unit_count = std::min(poly->polygon_count * UNITS_PER_POLY, UINT32(65535));
poly->unit_next = 0;
poly->unit = (work_unit **)allocate_array(machine, &poly->unit_size, poly->unit_count);
@@ -501,8 +501,8 @@ UINT32 poly_render_triangle(legacy_poly_manager *poly, void *dest, const rectang
/* clip coordinates */
v1yclip = v1y;
v3yclip = v3y + ((poly->flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- v1yclip = MAX(v1yclip, cliprect.min_y);
- v3yclip = MIN(v3yclip, cliprect.max_y + 1);
+ v1yclip = std::max(v1yclip, cliprect.min_y);
+ v3yclip = std::min(v3yclip, cliprect.max_y + 1);
if (v3yclip - v1yclip <= 0)
return 0;
@@ -540,7 +540,7 @@ UINT32 poly_render_triangle(legacy_poly_manager *poly, void *dest, const rectang
/* fill in the work unit basics */
unit->shared.polygon = polygon;
- unit->shared.count_next = MIN(v3yclip - curscan, scaninc);
+ unit->shared.count_next = std::min(v3yclip - curscan, scaninc);
unit->shared.scanline = curscan;
unit->shared.previtem = poly->unit_bucket[bucketnum];
poly->unit_bucket[bucketnum] = unit_index;
@@ -671,8 +671,8 @@ UINT32 poly_render_triangle_custom(legacy_poly_manager *poly, void *dest, const
UINT32 startunit;
/* clip coordinates */
- v1yclip = MAX(startscanline, cliprect.min_y);
- v3yclip = MIN(startscanline + numscanlines, cliprect.max_y + 1);
+ v1yclip = std::max(startscanline, cliprect.min_y);
+ v3yclip = std::min(startscanline + numscanlines, cliprect.max_y + 1);
if (v3yclip - v1yclip <= 0)
return 0;
@@ -701,7 +701,7 @@ UINT32 poly_render_triangle_custom(legacy_poly_manager *poly, void *dest, const
/* fill in the work unit basics */
unit->shared.polygon = polygon;
- unit->shared.count_next = MIN(v3yclip - curscan, scaninc);
+ unit->shared.count_next = std::min(v3yclip - curscan, scaninc);
unit->shared.scanline = curscan;
unit->shared.previtem = poly->unit_bucket[bucketnum];
poly->unit_bucket[bucketnum] = unit_index;
@@ -801,8 +801,8 @@ UINT32 poly_render_quad(legacy_poly_manager *poly, void *dest, const rectangle &
/* clip coordinates */
minyclip = miny;
maxyclip = maxy + ((poly->flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- minyclip = MAX(minyclip, cliprect.min_y);
- maxyclip = MIN(maxyclip, cliprect.max_y + 1);
+ minyclip = std::max(minyclip, cliprect.min_y);
+ maxyclip = std::min(maxyclip, cliprect.max_y + 1);
if (maxyclip - minyclip <= 0)
return 0;
@@ -892,7 +892,7 @@ UINT32 poly_render_quad(legacy_poly_manager *poly, void *dest, const rectangle &
/* fill in the work unit basics */
unit->shared.polygon = polygon;
- unit->shared.count_next = MIN(maxyclip - curscan, scaninc);
+ unit->shared.count_next = std::min(maxyclip - curscan, scaninc);
unit->shared.scanline = curscan;
unit->shared.previtem = poly->unit_bucket[bucketnum];
poly->unit_bucket[bucketnum] = unit_index;
@@ -985,7 +985,7 @@ UINT32 poly_render_quad_fan(legacy_poly_manager *poly, void *dest, const rectang
/* iterate over vertices */
for (vertnum = 2; vertnum < numverts; vertnum += 2)
- pixels += poly_render_quad(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum], &v[MIN(vertnum + 1, numverts - 1)]);
+ pixels += poly_render_quad(poly, dest, cliprect, callback, paramcount, &v[0], &v[vertnum - 1], &v[vertnum], &v[std::min(vertnum + 1, numverts - 1)]);
return pixels;
}
@@ -1033,8 +1033,8 @@ UINT32 poly_render_polygon(legacy_poly_manager *poly, void *dest, const rectangl
/* clip coordinates */
minyclip = miny;
maxyclip = maxy + ((poly->flags & POLYFLAG_INCLUDE_BOTTOM_EDGE) ? 1 : 0);
- minyclip = MAX(minyclip, cliprect.min_y);
- maxyclip = MIN(maxyclip, cliprect.max_y + 1);
+ minyclip = std::max(minyclip, cliprect.min_y);
+ maxyclip = std::min(maxyclip, cliprect.max_y + 1);
if (maxyclip - minyclip <= 0)
return 0;
@@ -1124,7 +1124,7 @@ UINT32 poly_render_polygon(legacy_poly_manager *poly, void *dest, const rectangl
/* fill in the work unit basics */
unit->shared.polygon = polygon;
- unit->shared.count_next = MIN(maxyclip - curscan, scaninc);
+ unit->shared.count_next = std::min(maxyclip - curscan, scaninc);
unit->shared.scanline = curscan;
unit->shared.previtem = poly->unit_bucket[bucketnum];
poly->unit_bucket[bucketnum] = unit_index;
diff --git a/src/devices/video/sprite.h b/src/devices/video/sprite.h
index bfc70ecf93e..c48a8ae0665 100644
--- a/src/devices/video/sprite.h
+++ b/src/devices/video/sprite.h
@@ -140,8 +140,8 @@ public:
// if the cliprect exceeds our current bitmap dimensions, expand
if (cliprect.right() >= m_bitmap.width() || cliprect.bottom() >= m_bitmap.height())
{
- int new_width = MAX(cliprect.right() + 1, m_bitmap.width());
- int new_height = MAX(cliprect.bottom() + 1, m_bitmap.height());
+ int new_width = std::max(cliprect.right() + 1, m_bitmap.width());
+ int new_height = std::max(cliprect.bottom() + 1, m_bitmap.height());
m_bitmap.resize(new_width, new_height, BITMAP_SLOP, BITMAP_SLOP);
m_dirty.resize(new_width, new_height);
}
diff --git a/src/devices/video/stvvdp1.cpp b/src/devices/video/stvvdp1.cpp
index 22d3074ae8e..5968759c8dc 100644
--- a/src/devices/video/stvvdp1.cpp
+++ b/src/devices/video/stvvdp1.cpp
@@ -1732,8 +1732,8 @@ void saturn_state::stv_vdp1_draw_normal_sprite(const rectangle &cliprect, int sp
xsize -= (cliprect.min_x - x);
x = cliprect.min_x;
}
- maxdrawypos = MIN(y+ysize-1,cliprect.max_y);
- maxdrawxpos = MIN(x+xsize-1,cliprect.max_x);
+ maxdrawypos = std::min(y+ysize-1,cliprect.max_y);
+ maxdrawxpos = std::min(x+xsize-1,cliprect.max_x);
for (drawypos = y; drawypos <= maxdrawypos; drawypos++ )
{
//destline = m_vdp1.framebuffer_draw_lines[drawypos];
diff --git a/src/devices/video/vector.cpp b/src/devices/video/vector.cpp
index 53286f3c623..41140496c58 100644
--- a/src/devices/video/vector.cpp
+++ b/src/devices/video/vector.cpp
@@ -104,10 +104,10 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity)
{
point *newpoint;
- intensity = MAX(0, MIN(255, intensity));
+ intensity = std::max(0, std::min(255, intensity));
- m_min_intensity = intensity > 0 ? MIN(m_min_intensity, intensity) : m_min_intensity;
- m_max_intensity = intensity > 0 ? MAX(m_max_intensity, intensity) : m_max_intensity;
+ m_min_intensity = intensity > 0 ? std::min(m_min_intensity, intensity) : m_min_intensity;
+ m_max_intensity = intensity > 0 ? std::max(m_max_intensity, intensity) : m_max_intensity;
if (vector_options::s_flicker && (intensity > 0))
{
@@ -115,7 +115,7 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity)
intensity -= (int)(intensity * random * vector_options::s_flicker);
- intensity = MAX(0, MIN(255, intensity));
+ intensity = std::max(0, std::min(255, intensity));
}
newpoint = &m_vector_list[m_vector_index];
diff --git a/src/devices/video/voodoo.cpp b/src/devices/video/voodoo.cpp
index 1c7f84b6765..0242e3cf4bf 100644
--- a/src/devices/video/voodoo.cpp
+++ b/src/devices/video/voodoo.cpp
@@ -2549,8 +2549,8 @@ INT32 voodoo_device::register_w(voodoo_device *vd, offs_t offset, UINT32 data)
visarea.set(hbp, hbp + hvis - 1, vbp, vbp + vvis - 1);
/* keep within bounds */
- visarea.max_x = MIN(visarea.max_x, htotal - 1);
- visarea.max_y = MIN(visarea.max_y, vtotal - 1);
+ visarea.max_x = std::min(visarea.max_x, htotal - 1);
+ visarea.max_y = std::min(visarea.max_y, vtotal - 1);
/* compute the new period for standard res, medium res, and VGA res */
stdperiod = HZ_TO_ATTOSECONDS(15750) * vtotal;
@@ -2889,8 +2889,8 @@ INT32 voodoo_device::lfb_direct_w(voodoo_device *vd, offs_t offset, UINT32 data,
/* byte swizzling */
if (LFBMODE_BYTE_SWIZZLE_WRITES(vd->reg[lfbMode].u))
{
- data = FLIPENDIAN_INT32(data);
- mem_mask = FLIPENDIAN_INT32(mem_mask);
+ data = flipendian_int32(data);
+ mem_mask = flipendian_int32(mem_mask);
}
/* word swapping */
@@ -2935,8 +2935,8 @@ INT32 voodoo_device::lfb_w(voodoo_device* vd, offs_t offset, UINT32 data, UINT32
/* byte swizzling */
if (LFBMODE_BYTE_SWIZZLE_WRITES(vd->reg[lfbMode].u))
{
- data = FLIPENDIAN_INT32(data);
- mem_mask = FLIPENDIAN_INT32(mem_mask);
+ data = flipendian_int32(data);
+ mem_mask = flipendian_int32(mem_mask);
}
/* word swapping */
@@ -3377,7 +3377,7 @@ INT32 voodoo_device::texture_w(voodoo_device *vd, offs_t offset, UINT32 data)
/* swizzle the data */
if (TEXLOD_TDATA_SWIZZLE(t->reg[tLOD].u))
- data = FLIPENDIAN_INT32(data);
+ data = flipendian_int32(data);
if (TEXLOD_TDATA_SWAP(t->reg[tLOD].u))
data = (data >> 16) | (data << 16);
@@ -3635,7 +3635,7 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
{
/* check for byte swizzling (bit 18) */
if (offset & 0x40000/4)
- data = FLIPENDIAN_INT32(data);
+ data = flipendian_int32(data);
cmdfifo_w(this, &fbi.cmdfifo[0], offset & 0xffff, data);
g_profiler.stop();
return;
@@ -3657,7 +3657,7 @@ WRITE32_MEMBER( voodoo_device::voodoo_w )
/* if not, we might be byte swizzled (bit 20) */
else if (offset & 0x100000/4)
- data = FLIPENDIAN_INT32(data);
+ data = flipendian_int32(data);
}
/* check the access behavior; note that the table works even if the */
@@ -4037,7 +4037,7 @@ static UINT32 lfb_r(voodoo_device *vd, offs_t offset, bool lfb_3d)
/* byte swizzling */
if (LFBMODE_BYTE_SWIZZLE_READS(vd->reg[lfbMode].u))
- data = FLIPENDIAN_INT32(data);
+ data = flipendian_int32(data);
if (LOG_LFB) vd->device->logerror("VOODOO.%d.LFB:read (%d,%d) = %08X\n", vd->index, x, y, data);
return data;
@@ -5180,7 +5180,7 @@ INT32 voodoo_device::fastfill(voodoo_device *vd)
for (y = sy; y < ey; y += ARRAY_LENGTH(extents))
{
poly_extra_data *extra = (poly_extra_data *)poly_get_extra_data(vd->poly);
- int count = MIN(ey - y, ARRAY_LENGTH(extents));
+ int count = std::min(ey - y, int(ARRAY_LENGTH(extents)));
extra->device= vd;
memcpy(extra->dither, dithermatrix, sizeof(extra->dither));
diff --git a/src/devices/video/zeus2.cpp b/src/devices/video/zeus2.cpp
index 0f885af9b3e..d85e2f25df2 100644
--- a/src/devices/video/zeus2.cpp
+++ b/src/devices/video/zeus2.cpp
@@ -1311,8 +1311,8 @@ void zeus2_renderer::zeus2_draw_quad(const UINT32 *databuffer, UINT32 texdata, i
clipvert[i].p[0] *= 65536.0f * 16.0f;
- maxx = MAX(maxx, clipvert[i].x);
- maxy = MAX(maxy, clipvert[i].y);
+ maxx = std::max(maxx, clipvert[i].x);
+ maxy = std::max(maxy, clipvert[i].y);
if (logextra & logit)
m_state->logerror("\t\t\tTranslated=(%f,%f)\n", (double)clipvert[i].x, (double)clipvert[i].y);
}
diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp
index 47a046081a4..3a463a6e56d 100644
--- a/src/emu/debug/dvmemory.cpp
+++ b/src/emu/debug/dvmemory.cpp
@@ -67,7 +67,7 @@ debug_view_memory_source::debug_view_memory_source(const char *name, memory_regi
m_length(region.bytes()),
m_offsetxor(ENDIAN_VALUE_NE_NNE(region.endianness(), 0, region.bytewidth() - 1)),
m_endianness(region.endianness()),
- m_prefsize(MIN(region.bytewidth(), 8))
+ m_prefsize(std::min(region.bytewidth(), UINT8(8)))
{
}
@@ -79,7 +79,7 @@ debug_view_memory_source::debug_view_memory_source(const char *name, void *base,
m_length(element_size * num_elements),
m_offsetxor(0),
m_endianness(ENDIANNESS_NATIVE),
- m_prefsize(MIN(element_size, 8))
+ m_prefsize(std::min(element_size, 8))
{
}
@@ -556,7 +556,7 @@ void debug_view_memory::recompute()
m_bytes_per_chunk *= 2;
m_chunks_per_row /= 2;
}
- m_chunks_per_row = MAX(1, m_chunks_per_row);
+ m_chunks_per_row = std::max(UINT32(1), m_chunks_per_row);
}
// recompute the byte offset based on the most recent expression result
@@ -612,8 +612,8 @@ bool debug_view_memory::needs_recompute()
{
recompute = true;
m_topleft.y = (m_expression.value() - m_byte_offset) / m_bytes_per_row;
- m_topleft.y = MAX(m_topleft.y, 0);
- m_topleft.y = MIN(m_topleft.y, m_total.y - 1);
+ m_topleft.y = std::max(m_topleft.y, 0);
+ m_topleft.y = std::min(m_topleft.y, m_total.y - 1);
const debug_view_memory_source &source = downcast<const debug_view_memory_source &>(*m_source);
offs_t resultbyte;
@@ -720,8 +720,8 @@ void debug_view_memory::set_cursor_pos(cursor_pos pos)
}
// clamp to the window bounds
- m_cursor.x = MIN(m_cursor.x, m_total.x);
- m_cursor.y = MIN(m_cursor.y, m_total.y);
+ m_cursor.x = std::min(m_cursor.x, m_total.x);
+ m_cursor.y = std::min(m_cursor.y, m_total.y);
// scroll if out of range
adjust_visible_x_for_cursor();
diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h
index 4f57bea70a2..bae298ada7e 100644
--- a/src/emu/debug/express.h
+++ b/src/emu/debug/express.h
@@ -296,7 +296,7 @@ private:
// setters
parse_token &set_offset(int offset) { m_offset = offset; return *this; }
parse_token &set_offset(const parse_token &src) { m_offset = src.m_offset; return *this; }
- parse_token &set_offset(const parse_token &src1, const parse_token &src2) { m_offset = MIN(src1.m_offset, src2.m_offset); return *this; }
+ parse_token &set_offset(const parse_token &src1, const parse_token &src2) { m_offset = std::min(src1.m_offset, src2.m_offset); return *this; }
parse_token &configure_number(UINT64 value) { m_type = NUMBER; m_value = value; return *this; }
parse_token &configure_string(const char *string) { m_type = STRING; m_string = string; return *this; }
parse_token &configure_memory(UINT32 address, parse_token &memoryat) { m_type = MEMORY; m_value = address; m_flags = memoryat.m_flags; m_string = memoryat.m_string; return *this; }
diff --git a/src/emu/drivenum.cpp b/src/emu/drivenum.cpp
index 99b0f1898c0..1d2f6d79f06 100644
--- a/src/emu/drivenum.cpp
+++ b/src/emu/drivenum.cpp
@@ -365,7 +365,7 @@ void driver_enumerator::find_approximate_matches(const char *string, int count,
// pick the best match between driver name and description
int curpenalty = penalty_compare(string, s_drivers_sorted[index]->description);
int tmp = penalty_compare(string, s_drivers_sorted[index]->name);
- curpenalty = MIN(curpenalty, tmp);
+ curpenalty = std::min(curpenalty, tmp);
// insert into the sorted table of matches
for (int matchnum = count - 1; matchnum >= 0; matchnum--)
diff --git a/src/emu/emupal.cpp b/src/emu/emupal.cpp
index ce6b17d721a..86f3b916b6d 100644
--- a/src/emu/emupal.cpp
+++ b/src/emu/emupal.cpp
@@ -159,7 +159,7 @@ UINT32 palette_device::transpen_mask(gfx_element &gfx, int color, int transcolor
assert(gfx.depth() <= 32);
// either gfx->color_depth entries or as many as we can get up until the end
- int count = MIN(gfx.depth(), m_indirect_pens.size() - entry);
+ int count = std::min(size_t(gfx.depth()), m_indirect_pens.size() - entry);
// set a bit anywhere the transcolor matches
UINT32 mask = 0;
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index 360810a3b6c..d1a85452757 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -863,7 +863,7 @@ input_item_id input_device::add_item(const char *name, input_item_id itemid, ite
}
// assign the new slot and update the maximum
- m_maxitem = MAX(m_maxitem, itemid);
+ m_maxitem = std::max(m_maxitem, itemid);
return itemid;
}
@@ -986,7 +986,7 @@ input_device *input_class::add_device(int devindex, const char *name, void *inte
m_device[devindex] = std::make_unique<input_device>(*this, devindex, name, internal);
// update the maximum index found
- m_maxindex = MAX(m_maxindex, devindex);
+ m_maxindex = std::max(m_maxindex, devindex);
osd_printf_verbose("Input: Adding %s #%d: %s\n", (*devclass_string_table)[m_devclass], devindex, name);
return m_device[devindex].get();
@@ -2363,8 +2363,8 @@ INT32 input_device_absolute_item::read_as_absolute(input_item_modifier modifier)
// positive/negative: scale to full axis
if (modifier == ITEM_MODIFIER_POS)
- result = MAX(result, 0) * 2 + INPUT_ABSOLUTE_MIN;
+ result = std::max(result, 0) * 2 + INPUT_ABSOLUTE_MIN;
if (modifier == ITEM_MODIFIER_NEG)
- result = MAX(-result, 0) * 2 + INPUT_ABSOLUTE_MIN;
+ result = std::max(-result, 0) * 2 + INPUT_ABSOLUTE_MIN;
return result;
}
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index 0590f22c71a..c215cfd1ba4 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -2148,7 +2148,7 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog)
unicode_char ch = field.keyboard_code(which);
if (ch == 0)
break;
- name.append(string_format("%-*s ", MAX(SPACE_COUNT - 1, 0), field.manager().natkeyboard().key_name(ch)));
+ name.append(string_format("%-*s ", std::max(SPACE_COUNT - 1, 0), field.manager().natkeyboard().key_name(ch)));
}
// trim extra spaces
@@ -4330,7 +4330,7 @@ void analog_field::frame_update(running_machine &machine)
rawvalue = apply_scale(rawvalue - INPUT_ABSOLUTE_MIN, m_positionalscale) * INPUT_RELATIVE_PER_PIXEL + m_minimum;
// clamp the high value so it does not roll over
- rawvalue = MIN(rawvalue, m_maximum);
+ rawvalue = std::min(rawvalue, m_maximum);
m_accum = apply_inverse_sensitivity(rawvalue);
}
else
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index 0b3719fb1b8..5e8c5f478d1 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -496,7 +496,7 @@ std::string running_machine::get_statename(const char *option) const
int end;
if ((end1 != -1) && (end2 != -1))
- end = MIN(end1, end2);
+ end = std::min(end1, end2);
else if (end1 != -1)
end = end1;
else if (end2 != -1)
diff --git a/src/emu/render.cpp b/src/emu/render.cpp
index a335489ce11..3f84421f69c 100644
--- a/src/emu/render.cpp
+++ b/src/emu/render.cpp
@@ -1225,14 +1225,14 @@ void render_target::compute_visible_area(INT32 target_width, INT32 target_height
// first compute scale factors to fit the screen
float xscale = (float)target_width / src_width;
float yscale = (float)target_height / src_height;
- float maxxscale = MAX(1, m_int_overscan? render_round_nearest(xscale) : floor(xscale));
- float maxyscale = MAX(1, m_int_overscan? render_round_nearest(yscale) : floor(yscale));
+ float maxxscale = std::max(1.0f, m_int_overscan? render_round_nearest(xscale) : floor(xscale));
+ float maxyscale = std::max(1.0f, m_int_overscan? render_round_nearest(yscale) : floor(yscale));
// now apply desired scale mode and aspect correction
if (m_keepaspect && target_aspect > src_aspect) xscale *= src_aspect / target_aspect * (maxyscale / yscale);
if (m_keepaspect && target_aspect < src_aspect) yscale *= target_aspect / src_aspect * (maxxscale / xscale);
- if (x_is_integer) xscale = MIN(maxxscale, MAX(1, render_round_nearest(xscale)));
- if (y_is_integer) yscale = MIN(maxyscale, MAX(1, render_round_nearest(yscale)));
+ if (x_is_integer) xscale = std::min(maxxscale, std::max(1.0f, render_round_nearest(xscale)));
+ if (y_is_integer) yscale = std::min(maxyscale, std::max(1.0f, render_round_nearest(yscale)));
// check if we have user defined scale factors, if so use them instead
xscale = m_int_scale_x? m_int_scale_x : xscale;
@@ -1301,8 +1301,8 @@ void render_target::compute_minimum_size(INT32 &minwidth, INT32 &minheight)
}
// pick the greater
- maxxscale = MAX(xscale, maxxscale);
- maxyscale = MAX(yscale, maxyscale);
+ maxxscale = std::max(xscale, maxxscale);
+ maxyscale = std::max(yscale, maxyscale);
screens_considered++;
}
@@ -1864,7 +1864,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const
prim->flags |= PRIMFLAG_TYPE_LINE;
// scale the width by the minimum of X/Y scale factors
- prim->width = curitem.width() * MIN(container_xform.xscale, container_xform.yscale);
+ prim->width = curitem.width() * std::min(container_xform.xscale, container_xform.yscale);
prim->flags |= curitem.flags();
// clip the primitive
@@ -1895,8 +1895,8 @@ void render_target::add_container_primitives(render_primitive_list &list, const
// based on the swap values, get the scaled final texture
int width = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.y1 - prim->bounds.y0) : (prim->bounds.x1 - prim->bounds.x0);
int height = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.x1 - prim->bounds.x0) : (prim->bounds.y1 - prim->bounds.y0);
- width = MIN(width, m_maxtexwidth);
- height = MIN(height, m_maxtexheight);
+ width = std::min(width, m_maxtexwidth);
+ height = std::min(height, m_maxtexheight);
curitem.texture()->get_scaled(width, height, prim->texture, list, curitem.flags());
@@ -2052,8 +2052,8 @@ void render_target::add_element_primitives(render_primitive_list &list, const ob
set_render_bounds_wh(&prim->bounds, render_round_nearest(xform.xoffs), render_round_nearest(xform.yoffs), (float) width, (float) height);
if (xform.orientation & ORIENTATION_SWAP_XY)
ISWAP(width, height);
- width = MIN(width, m_maxtexwidth);
- height = MIN(height, m_maxtexheight);
+ width = std::min(width, m_maxtexwidth);
+ height = std::min(height, m_maxtexheight);
// get the scaled texture and append it
@@ -2655,7 +2655,7 @@ float render_manager::max_update_rate() const
if (minimum == 0)
minimum = target.max_update_rate();
else
- minimum = MIN(target.max_update_rate(), minimum);
+ minimum = std::min(target.max_update_rate(), minimum);
}
return minimum;
diff --git a/src/emu/rendfont.cpp b/src/emu/rendfont.cpp
index 9687206f85b..b5ecffe3674 100644
--- a/src/emu/rendfont.cpp
+++ b/src/emu/rendfont.cpp
@@ -482,8 +482,8 @@ bool render_font::load_cached_bdf(const char *filename)
m_rawdata.resize(m_rawsize + 1);
// read the first chunk
- UINT32 bytes = file.read(&m_rawdata[0], MIN(CACHED_BDF_HASH_SIZE, m_rawsize));
- if (bytes != MIN(CACHED_BDF_HASH_SIZE, m_rawsize))
+ UINT32 bytes = file.read(&m_rawdata[0], std::min(CACHED_BDF_HASH_SIZE, m_rawsize));
+ if (bytes != std::min(CACHED_BDF_HASH_SIZE, m_rawsize))
return false;
// has the chunk
diff --git a/src/emu/rendfont.h b/src/emu/rendfont.h
index b2ec2f12568..88445510a45 100644
--- a/src/emu/rendfont.h
+++ b/src/emu/rendfont.h
@@ -109,7 +109,7 @@ private:
// constants
static const int CACHED_CHAR_SIZE = 12;
static const int CACHED_HEADER_SIZE = 16;
- static const int CACHED_BDF_HASH_SIZE = 1024;
+ static const UINT64 CACHED_BDF_HASH_SIZE = 1024;
};
void convert_command_glyph(std::string &s);
diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp
index 3ab732770f4..ad4b222dce5 100644
--- a/src/emu/romload.cpp
+++ b/src/emu/romload.cpp
@@ -199,7 +199,7 @@ UINT32 rom_file_size(const rom_entry *romp)
curlength += ROM_GETLENGTH(romp++);
/* track the maximum length */
- maxlength = MAX(maxlength, curlength);
+ maxlength = std::max(maxlength, curlength);
}
while (ROMENTRY_ISRELOAD(romp));
@@ -715,7 +715,7 @@ int rom_load_manager::read_rom_data(const rom_entry *parent_region, const rom_en
return rom_fread(base, numbytes, parent_region);
/* use a temporary buffer for complex loads */
- tempbufsize = MIN(TEMPBUFFER_MAX_SIZE, numbytes);
+ tempbufsize = std::min(TEMPBUFFER_MAX_SIZE, numbytes);
dynamic_buffer tempbuf(tempbufsize);
/* chunky reads for complex loads */
diff --git a/src/emu/save.cpp b/src/emu/save.cpp
index d747475fa34..273a3cc91cc 100644
--- a/src/emu/save.cpp
+++ b/src/emu/save.cpp
@@ -449,19 +449,19 @@ void state_entry::flip_data()
case 2:
data16 = (UINT16 *)m_data;
for (count = 0; count < m_typecount; count++)
- data16[count] = FLIPENDIAN_INT16(data16[count]);
+ data16[count] = flipendian_int16(data16[count]);
break;
case 4:
data32 = (UINT32 *)m_data;
for (count = 0; count < m_typecount; count++)
- data32[count] = FLIPENDIAN_INT32(data32[count]);
+ data32[count] = flipendian_int32(data32[count]);
break;
case 8:
data64 = (UINT64 *)m_data;
for (count = 0; count < m_typecount; count++)
- data64[count] = FLIPENDIAN_INT64(data64[count]);
+ data64[count] = flipendian_int64(data64[count]);
break;
}
}
diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp
index ca32bd6d56e..b3eee925a3c 100644
--- a/src/emu/schedule.cpp
+++ b/src/emu/schedule.cpp
@@ -732,7 +732,7 @@ void device_scheduler::compute_perfect_interleave()
// adjust all the actuals; this doesn't affect the current
m_quantum_minimum = perfect;
for (quantum_slot &quant : m_quantum_list)
- quant.m_actual = MAX(quant.m_requested, m_quantum_minimum);
+ quant.m_actual = std::max(quant.m_requested, m_quantum_minimum);
}
}
}
@@ -967,7 +967,7 @@ void device_scheduler::add_scheduling_quantum(const attotime &quantum, const att
{
quantum_slot &quant = *m_quantum_allocator.alloc();
quant.m_requested = quantum_attos;
- quant.m_actual = MAX(quantum_attos, m_quantum_minimum);
+ quant.m_actual = std::max(quantum_attos, m_quantum_minimum);
quant.m_expire = expire;
m_quantum_list.insert_after(quant, insert_after);
}
diff --git a/src/emu/screen.cpp b/src/emu/screen.cpp
index 8afb7a37e9a..b96e3b85738 100644
--- a/src/emu/screen.cpp
+++ b/src/emu/screen.cpp
@@ -1093,8 +1093,8 @@ void screen_device::realloc_screen_bitmaps()
return;
// determine effective size to allocate
- INT32 effwidth = MAX(m_width, m_visarea.max_x + 1);
- INT32 effheight = MAX(m_height, m_visarea.max_y + 1);
+ INT32 effwidth = std::max(m_width, m_visarea.max_x + 1);
+ INT32 effheight = std::max(m_height, m_visarea.max_y + 1);
// reize all registered screen bitmaps
for (auto &item : m_auto_bitmap_list)
@@ -1666,8 +1666,8 @@ void screen_device::finalize_burnin()
UINT64 *src = &m_burnin.pix64(y);
for (int x = 0; x < srcwidth; x++)
{
- minval = MIN(minval, src[x]);
- maxval = MAX(maxval, src[x]);
+ minval = std::min(minval, src[x]);
+ maxval = std::max(maxval, src[x]);
}
}
diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp
index 35639f57d2e..7c617b5db5d 100644
--- a/src/emu/softlist.cpp
+++ b/src/emu/softlist.cpp
@@ -447,7 +447,7 @@ void software_list_device::find_approx_matches(const char *name, int matches, co
// pick the best match between driver name and description
int longpenalty = driver_list::penalty_compare(name, swinfo.longname().c_str());
int shortpenalty = driver_list::penalty_compare(name, swinfo.shortname().c_str());
- int curpenalty = MIN(longpenalty, shortpenalty);
+ int curpenalty = std::min(longpenalty, shortpenalty);
// insert into the sorted table of matches
for (int matchnum = matches - 1; matchnum >= 0; matchnum--)
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp
index 1d26b77f992..cafd6fbfde9 100644
--- a/src/emu/sound.cpp
+++ b/src/emu/sound.cpp
@@ -491,7 +491,7 @@ void sound_stream::recompute_sample_rate_data()
// okay, we have a new sample rate; recompute the latency to be the maximum
// sample period between us and our input
attoseconds_t new_attosecs_per_sample = ATTOSECONDS_PER_SECOND / input.m_source->m_stream->m_sample_rate;
- attoseconds_t latency = MAX(new_attosecs_per_sample, m_attoseconds_per_sample);
+ attoseconds_t latency = std::max(new_attosecs_per_sample, m_attoseconds_per_sample);
// if the input stream's sample rate is lower, we will use linear interpolation
// this requires an extra sample from the source
@@ -504,7 +504,7 @@ void sound_stream::recompute_sample_rate_data()
// we generally don't want to tweak the latency, so we just keep the greatest
// one we've computed thus far
- input.m_latency_attoseconds = MAX(input.m_latency_attoseconds, latency);
+ input.m_latency_attoseconds = std::max(input.m_latency_attoseconds, latency);
assert(input.m_latency_attoseconds < update_attoseconds);
}
}
diff --git a/src/emu/tilemap.cpp b/src/emu/tilemap.cpp
index 48e288fa0c0..bc193b9d8e0 100644
--- a/src/emu/tilemap.cpp
+++ b/src/emu/tilemap.cpp
@@ -475,7 +475,7 @@ void tilemap_t::map_pens_to_layer(int group, pen_t pen, pen_t mask, UINT8 layerm
pen_t stop = start | ~mask;
// clamp to the number of entries actually there
- stop = MIN(stop, MAX_PEN_TO_FLAGS - 1);
+ stop = std::min(stop, MAX_PEN_TO_FLAGS - 1);
// iterate and set
UINT8 *array = m_pen_to_flags + group * MAX_PEN_TO_FLAGS;
@@ -635,12 +635,12 @@ void tilemap_t::mappings_create()
int max_logical_index = m_rows * m_cols;
// compute the maximum memory index
- int max_memory_index = 0;
+ tilemap_memory_index max_memory_index = 0;
for (UINT32 row = 0; row < m_rows; row++)
for (UINT32 col = 0; col < m_cols; col++)
{
tilemap_memory_index memindex = memory_index(col, row);
- max_memory_index = MAX(max_memory_index, memindex);
+ max_memory_index = std::max(max_memory_index, memindex);
}
max_memory_index++;
@@ -974,8 +974,8 @@ g_profiler.start(PROFILER_TILEMAP_DRAW);
int scrolly = effective_colscroll(0, height);
for (int ypos = scrolly - m_height; ypos <= original_cliprect.max_y; ypos += m_height)
{
- int const firstrow = MAX((original_cliprect.min_y - ypos) / rowheight, 0);
- int const lastrow = MIN((original_cliprect.max_y - ypos) / rowheight, m_scrollrows - 1);
+ int const firstrow = std::max((original_cliprect.min_y - ypos) / rowheight, 0);
+ int const lastrow = std::min((original_cliprect.max_y - ypos) / rowheight, INT32(m_scrollrows) - 1);
// iterate over rows in the tilemap
int nextrow;
@@ -1112,10 +1112,10 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
{
// clip destination coordinates to the tilemap
// note that x2/y2 are exclusive, not inclusive
- int x1 = MAX(xpos, blit.cliprect.min_x);
- int x2 = MIN(xpos + (int)m_width, blit.cliprect.max_x + 1);
- int y1 = MAX(ypos, blit.cliprect.min_y);
- int y2 = MIN(ypos + (int)m_height, blit.cliprect.max_y + 1);
+ int x1 = std::max(xpos, blit.cliprect.min_x);
+ int x2 = std::min(xpos + (int)m_width, blit.cliprect.max_x + 1);
+ int y1 = std::max(ypos, blit.cliprect.min_y);
+ int y2 = std::min(ypos + (int)m_height, blit.cliprect.max_y + 1);
// if totally clipped, stop here
if (x1 >= x2 || y1 >= y2)
@@ -1149,7 +1149,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
// set up row counter
int y = y1;
int nexty = m_tileheight * (y1 / m_tileheight) + m_tileheight;
- nexty = MIN(nexty, y2);
+ nexty = std::min(nexty, y2);
// loop over tilemap rows
for (;;)
@@ -1192,8 +1192,8 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
// compute the end of this run, in pixels
x_end = column * m_tilewidth;
- x_end = MAX(x_end, x1);
- x_end = MIN(x_end, x2);
+ x_end = std::max(x_end, x1);
+ x_end = std::min(x_end, x2);
// if we're rendering something, compute the pointers
const rgb_t *clut = m_palette->palette()->entry_list_adjusted();
@@ -1264,7 +1264,7 @@ void tilemap_t::draw_instance(screen_device &screen, _BitmapClass &dest, const b
// increment the Y counter
y = nexty;
nexty += m_tileheight;
- nexty = MIN(nexty, y2);
+ nexty = std::min(nexty, y2);
}
}
diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h
index 48a2bcbd543..5692589457e 100644
--- a/src/emu/tilemap.h
+++ b/src/emu/tilemap.h
@@ -484,7 +484,7 @@ class tilemap_t
static const logical_index INVALID_LOGICAL_INDEX = (logical_index)~0;
// maximum index in each array
- static const int MAX_PEN_TO_FLAGS = 256;
+ static const pen_t MAX_PEN_TO_FLAGS = 256;
protected:
// tilemap_manager controlls our allocations
diff --git a/src/emu/video.cpp b/src/emu/video.cpp
index 32d295fe425..abd1bd24066 100644
--- a/src/emu/video.cpp
+++ b/src/emu/video.cpp
@@ -1011,7 +1011,7 @@ void video_manager::update_refresh_speed()
{
attoseconds_t period = screen.frame_period().attoseconds();
if (period != 0)
- min_frame_period = MIN(min_frame_period, period);
+ min_frame_period = std::min(min_frame_period, period);
}
// compute a target speed as an integral percentage
@@ -1019,7 +1019,7 @@ void video_manager::update_refresh_speed()
// the fact that most refresh rates are not accurate to 10 digits...
UINT32 target_speed = floor((minrefresh - 0.25) * 1000.0 / ATTOSECONDS_TO_HZ(min_frame_period));
UINT32 original_speed = original_speed_setting();
- target_speed = MIN(target_speed, original_speed);
+ target_speed = std::min(target_speed, original_speed);
// if we changed, log that verbosely
if (target_speed != m_speed)
@@ -1180,7 +1180,7 @@ osd_file::error video_manager::open_next(emu_file &file, const char *extension)
int end;
if ((end1 != -1) && (end2 != -1))
- end = MIN(end1, end2);
+ end = std::min(end1, end2);
else if (end1 != -1)
end = end1;
else if (end2 != -1)
diff --git a/src/emu/video/resnet.cpp b/src/emu/video/resnet.cpp
index a4df1c0bdc4..0ae03e2ed14 100644
--- a/src/emu/video/resnet.cpp
+++ b/src/emu/video/resnet.cpp
@@ -670,7 +670,7 @@ int compute_res_net(int inputs, int channel, const res_net_info &di)
rTotal = 1.0 / rTotal;
v *= rTotal;
- v = MAX(minout, v - cut);
+ v = std::max(minout, v - cut);
switch (di.options & RES_NET_MONITOR_MASK)
{
@@ -679,8 +679,8 @@ int compute_res_net(int inputs, int channel, const res_net_info &di)
break;
case RES_NET_MONITOR_SANYO_EZV20:
v = vcc - v;
- v = MAX(0, v-0.7);
- v = MIN(v, vcc - 2 * 0.7);
+ v = std::max(double(0), v-0.7);
+ v = std::min(v, vcc - 2 * 0.7);
v = v / (vcc-1.4);
v = v * vcc;
break;
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index e6594b3b0e1..4d6df3fb866 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -159,7 +159,7 @@ cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols,
auto curitem = std::make_unique<item>(itemnode->value, value, format);
// ensure the maximum expands to suit
- m_maxval = MAX(m_maxval, curitem->value());
+ m_maxval = std::max(m_maxval, curitem->value());
m_itemlist.push_back(std::move(curitem));
}
@@ -1262,8 +1262,8 @@ std::string &cheat_manager::get_output_string(int row, ui::text_layout::text_jus
row = (row < 0) ? m_numlines + row : row - 1;
// clamp within range
- row = MAX(row, 0);
- row = MIN(row, m_numlines - 1);
+ row = std::max(row, 0);
+ row = std::min(row, m_numlines - 1);
// return the appropriate string
m_justify[row] = justify;
@@ -1359,7 +1359,7 @@ void cheat_manager::frame_update()
// set up for accumulating output
m_lastline = 0;
m_numlines = floor(1.0f / mame_machine_manager::instance()->ui().get_line_height());
- m_numlines = MIN(m_numlines, m_output.size());
+ m_numlines = std::min(size_t(m_numlines), m_output.size());
for (auto & elem : m_output)
elem.clear();
diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp
index ef7b4bcf61f..811f927262b 100644
--- a/src/frontend/mame/info.cpp
+++ b/src/frontend/mame/info.cpp
@@ -273,7 +273,7 @@ void info_xml_creator::output_one()
}
else
{
- nplayers = MAX(nplayers, field.player() + 1);
+ nplayers = std::max(nplayers, field.player() + 1);
field.set_player(field.player() + player_offset);
}
}
@@ -1091,7 +1091,7 @@ void info_xml_creator::output_input(const ioport_list &portlist)
control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1;
control_info[field.player() * CTRL_COUNT + ctrl_type].analog = FALSE;
}
- control_info[field.player() * CTRL_COUNT + ctrl_type].maxbuttons = MAX(control_info[field.player() * CTRL_COUNT + ctrl_type].maxbuttons, field.type() - IPT_BUTTON1 + 1);
+ control_info[field.player() * CTRL_COUNT + ctrl_type].maxbuttons = std::max(control_info[field.player() * CTRL_COUNT + ctrl_type].maxbuttons, field.type() - IPT_BUTTON1 + 1);
control_info[field.player() * CTRL_COUNT + ctrl_type].nbuttons++;
if (!field.optional())
control_info[field.player() * CTRL_COUNT + ctrl_type].reqbuttons++;
@@ -1110,7 +1110,7 @@ void info_xml_creator::output_input(const ioport_list &portlist)
case IPT_COIN10:
case IPT_COIN11:
case IPT_COIN12:
- ncoin = MAX(ncoin, field.type() - IPT_COIN1 + 1);
+ ncoin = std::max(ncoin, field.type() - IPT_COIN1 + 1);
break;
// track presence of keypads and keyboards
@@ -1202,7 +1202,7 @@ void info_xml_creator::output_input(const ioport_list &portlist)
{
control_info[i * CTRL_COUNT + j].nbuttons += control_info[i * CTRL_COUNT].nbuttons;
control_info[i * CTRL_COUNT + j].reqbuttons += control_info[i * CTRL_COUNT].reqbuttons;
- control_info[i * CTRL_COUNT + j].maxbuttons = MAX(control_info[i * CTRL_COUNT + j].maxbuttons, control_info[i * CTRL_COUNT].maxbuttons);
+ control_info[i * CTRL_COUNT + j].maxbuttons = std::max(control_info[i * CTRL_COUNT + j].maxbuttons, control_info[i * CTRL_COUNT].maxbuttons);
memset(&control_info[i * CTRL_COUNT], 0, sizeof(control_info[0]));
fix_done = TRUE;
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 4bad1bb39c8..c6359aa2871 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -1621,10 +1621,10 @@ int lua_engine::lua_screen::l_draw_box(lua_State *L)
int sc_width = sc->visible_area().width();
int sc_height = sc->visible_area().height();
float x1, y1, x2, y2;
- x1 = MIN(MAX(0, (float) lua_tonumber(L, 2)), sc_width-1) / static_cast<float>(sc_width);
- y1 = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast<float>(sc_height);
- x2 = MIN(MAX(0, (float) lua_tonumber(L, 4)), sc_width-1) / static_cast<float>(sc_width);
- y2 = MIN(MAX(0, (float) lua_tonumber(L, 5)), sc_height-1) / static_cast<float>(sc_height);
+ x1 = std::min(std::max(0.0f, (float) lua_tonumber(L, 2)), float(sc_width-1)) / float(sc_width);
+ y1 = std::min(std::max(0.0f, (float) lua_tonumber(L, 3)), float(sc_height-1)) / float(sc_height);
+ x2 = std::min(std::max(0.0f, (float) lua_tonumber(L, 4)), float(sc_width-1)) / float(sc_width);
+ y2 = std::min(std::max(0.0f, (float) lua_tonumber(L, 5)), float(sc_height-1)) / float(sc_height);
UINT32 bgcolor = lua_tounsigned(L, 6);
UINT32 fgcolor = lua_tounsigned(L, 7);
@@ -1658,10 +1658,10 @@ int lua_engine::lua_screen::l_draw_line(lua_State *L)
int sc_width = sc->visible_area().width();
int sc_height = sc->visible_area().height();
float x1, y1, x2, y2;
- x1 = MIN(MAX(0, (float) lua_tonumber(L, 2)), sc_width-1) / static_cast<float>(sc_width);
- y1 = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast<float>(sc_height);
- x2 = MIN(MAX(0, (float) lua_tonumber(L, 4)), sc_width-1) / static_cast<float>(sc_width);
- y2 = MIN(MAX(0, (float) lua_tonumber(L, 5)), sc_height-1) / static_cast<float>(sc_height);
+ x1 = std::min(std::max(0.0f, (float) lua_tonumber(L, 2)), float(sc_width-1)) / float(sc_width);
+ y1 = std::min(std::max(0.0f, (float) lua_tonumber(L, 3)), float(sc_height-1)) / float(sc_height);
+ x2 = std::min(std::max(0.0f, (float) lua_tonumber(L, 4)), float(sc_width-1)) / float(sc_width);
+ y2 = std::min(std::max(0.0f, (float) lua_tonumber(L, 5)), float(sc_height-1)) / float(sc_height);
UINT32 color = lua_tounsigned(L, 6);
// draw the line
@@ -1695,8 +1695,8 @@ int lua_engine::lua_screen::l_draw_text(lua_State *L)
float y, x = 0;
if(lua_isnumber(L, 2))
{
- x = MIN(MAX(0, (float) lua_tonumber(L, 2)), sc_width-1) / static_cast<float>(sc_width);
- y = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast<float>(sc_height);
+ x = std::min(std::max(0.0f, (float) lua_tonumber(L, 2)), float(sc_width-1)) / float(sc_width);
+ y = std::min(std::max(0.0f, (float) lua_tonumber(L, 3)), float(sc_height-1)) / float(sc_height);
}
else
{
diff --git a/src/frontend/mame/ui/custmenu.cpp b/src/frontend/mame/ui/custmenu.cpp
index 774cce13fe9..761dc2b1291 100644
--- a/src/frontend/mame/ui/custmenu.cpp
+++ b/src/frontend/mame/ui/custmenu.cpp
@@ -212,7 +212,7 @@ void menu_custom_filter::custom_render(void *selectedref, float top, float botto
ui().draw_text_full(container(), _("Select custom filters:"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -527,7 +527,7 @@ void menu_swcustom_filter::custom_render(void *selectedref, float top, float bot
ui().draw_text_full(container(), _("Select custom filters:"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index 060f50a2239..39db8f8ec29 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -167,7 +167,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), _("Custom UI Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -383,7 +383,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
ui().draw_text_full(container(), topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -410,7 +410,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
ui().draw_text_full(container(), topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr, m_info_size);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(origx2 - origx1, width);
+ maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
@@ -541,7 +541,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -569,7 +569,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
@@ -609,7 +609,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
}
// compute our bounds for header
@@ -882,7 +882,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
ui().draw_text_full(container(), topbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -907,7 +907,7 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
ui().draw_text_full(container(), sampletxt.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
x1 -= UI_BOX_LR_BORDER;
diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp
index 427f3187661..99ae6b69bb7 100644
--- a/src/frontend/mame/ui/datmenu.cpp
+++ b/src/frontend/mame/ui/datmenu.cpp
@@ -276,7 +276,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), driver.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -340,7 +340,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision);
ui().draw_text_full(container(), revision.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(origx2 - origx1, width);
+ maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp
index 040ecf9a826..80b036c5277 100644
--- a/src/frontend/mame/ui/dirmenu.cpp
+++ b/src/frontend/mame/ui/dirmenu.cpp
@@ -120,7 +120,7 @@ void menu_directory::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), _("Folders Setup"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -218,13 +218,13 @@ void menu_display_actual::custom_render(void *selectedref, float top, float bott
{
ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::LEFT, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
}
// get the size of the text
ui().draw_text_full(container(), m_tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- maxwidth = MAX(width, maxwidth);
+ maxwidth = std::max(width, maxwidth);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -508,7 +508,7 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- maxwidth = MAX(width, maxwidth);
+ maxwidth = std::max(width, maxwidth);
}
// compute our bounds
@@ -539,7 +539,7 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
ui().draw_text_full(container(), tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
@@ -644,7 +644,7 @@ void menu_remove_folder::custom_render(void *selectedref, float top, float botto
// get the size of the text
ui().draw_text_full(container(), tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index 78e0dd17285..154fda55e31 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -809,7 +809,7 @@ void menu::draw_text_box()
// maximum against "return to prior menu" text
prior_width = ui().get_string_width(backtext) + 2.0f * gutter_width;
- target_width = MAX(target_width, prior_width);
+ target_width = std::max(target_width, prior_width);
// determine the target location
target_x = 0.5f - 0.5f * target_width;
@@ -1240,7 +1240,7 @@ void menu::extra_text_position(float origx1, float origx2, float origy, float ys
int direction, float &x1, float &y1, float &x2, float &y2)
{
float width = layout.actual_width() + (2 * UI_BOX_LR_BORDER);
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 14a068e88cc..d90a5502250 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -807,7 +807,7 @@ void menu_machine_configure::custom_render(void *selectedref, float top, float b
ui().draw_text_full(container(), elem.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
}
// compute our bounds
@@ -951,7 +951,7 @@ void menu_plugins_configure::custom_render(void *selectedref, float top, float b
ui().draw_text_full(container(), _("Plugins"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index 3073388887f..9912935a755 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -299,7 +299,7 @@ void menu_game_options::custom_render(void *selectedref, float top, float bottom
ui().draw_text_full(container(), _("Settings"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index 0aa6798d849..e614bb587e7 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -170,7 +170,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
ui().draw_text_full(container(), tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += (2.0f * UI_BOX_LR_BORDER) + 0.01f;
- float maxwidth = MAX(width, origx2 - origx1);
+ float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -198,7 +198,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
ui().draw_text_full(container(), tempbuf.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index 4af579d0c62..3019bff9d0f 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -1214,7 +1214,7 @@ void menu_select_game::populate_search()
// pick the best match between driver name and description
int curpenalty = fuzzy_substring(m_search, m_displaylist[index]->description);
int tmp = fuzzy_substring(m_search, m_displaylist[index]->name);
- curpenalty = MIN(curpenalty, tmp);
+ curpenalty = std::min(curpenalty, tmp);
// insert into the sorted table of matches
for (int matchnum = VISIBLE_GAMES_IN_SEARCH - 1; matchnum >= 0; --matchnum)
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 9a942e88e22..6894603b990 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -671,7 +671,7 @@ float menu_select_launch::draw_icon(int linenum, void *selectedref, float x0, fl
if (ratioW < 1 || ratioH < 1)
{
// smaller ratio will ensure that the image fits in the view
- float ratio = MIN(ratioW, ratioH);
+ float ratio = std::min(ratioW, ratioH);
dest_xPixel = tmp->width() * ratio;
dest_yPixel = tmp->height() * ratio;
}
@@ -1488,7 +1488,7 @@ float menu_select_launch::draw_right_box_title(float x1, float y1, float x2, flo
{
auto textlen = ui().get_string_width(elem.c_str()) + 0.01f;
float tmp_size = (textlen > midl) ? (midl / textlen) : 1.0f;
- text_size = MIN(text_size, tmp_size);
+ text_size = std::min(text_size, tmp_size);
}
for (int cells = RP_FIRST; cells <= RP_LAST; ++cells)
@@ -1798,7 +1798,7 @@ void menu_select_launch::arts_render_images(bitmap_argb32 *tmp_bitmap, float ori
// smaller ratio will ensure that the image fits in the view
dest_yPixel = tmp_bitmap->width() * 0.75f;
ratioH = (float)panel_height_pixel / dest_yPixel;
- float ratio = MIN(ratioW, ratioH);
+ float ratio = std::min(ratioW, ratioH);
dest_xPixel = tmp_bitmap->width() * ratio;
dest_yPixel *= ratio;
}
@@ -1806,7 +1806,7 @@ void menu_select_launch::arts_render_images(bitmap_argb32 *tmp_bitmap, float ori
else if (ratioW < 1 || ratioH < 1 || (ui().options().enlarge_snaps() && !no_available))
{
// smaller ratio will ensure that the image fits in the view
- float ratio = MIN(ratioW, ratioH);
+ float ratio = std::min(ratioW, ratioH);
dest_xPixel = tmp_bitmap->width() * ratio;
dest_yPixel = tmp_bitmap->height() * ratio;
}
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index dfb97546fe7..1a6b6842df5 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -1033,7 +1033,7 @@ void menu_select_software::find_matches(const char *str, int count)
// pick the best match between driver name and description
int curpenalty = fuzzy_substring(str, m_displaylist[index]->longname);
int tmp = fuzzy_substring(str, m_displaylist[index]->shortname);
- curpenalty = MIN(curpenalty, tmp);
+ curpenalty = std::min(curpenalty, tmp);
// insert into the sorted table of matches
for (int matchnum = count - 1; matchnum >= 0; --matchnum)
@@ -1315,7 +1315,7 @@ void menu_select_software::infos_render(float origx1, float origy1, float origx2
ui().draw_text_full(container(), elem.c_str(), origx1, origy1, origx2 - origx1, ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, &txt_lenght, nullptr);
txt_lenght += 0.01f;
- title_size = MAX(txt_lenght, title_size);
+ title_size = std::max(txt_lenght, title_size);
}
rgb_t fgcolor = UI_TEXT_COLOR;
@@ -1476,7 +1476,7 @@ void software_parts::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), _("Software part selection:"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -1617,7 +1617,7 @@ void bios_selection::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), _("Bios selection:"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp
index b161713fead..f37892758c0 100644
--- a/src/frontend/mame/ui/simpleselgame.cpp
+++ b/src/frontend/mame/ui/simpleselgame.cpp
@@ -300,7 +300,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
ui().draw_text_full(container(), tempbuf[0].c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(width, origx2 - origx1);
+ maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
@@ -390,7 +390,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
ui().draw_text_full(container(), tempbuf[line].c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(maxwidth, width);
+ maxwidth = std::max(maxwidth, width);
}
// compute our bounds
diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp
index 869ec533050..6277e751773 100644
--- a/src/frontend/mame/ui/sndmenu.cpp
+++ b/src/frontend/mame/ui/sndmenu.cpp
@@ -148,7 +148,7 @@ void menu_sound_options::custom_render(void *selectedref, float top, float botto
ui().draw_text_full(container(), _("Sound Options"), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index 9f13c6cafec..ebef1f9a33c 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -423,7 +423,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
ui().draw_text_full(container(), _(m_options[0].description), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- float maxwidth = MAX(origx2 - origx1, width);
+ float maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
@@ -452,7 +452,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
width += 2 * UI_BOX_LR_BORDER;
- maxwidth = MAX(origx2 - origx1, width);
+ maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index 7c729224ef5..56c180571cf 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -2280,7 +2280,7 @@ INT32 mame_ui_manager::slider_flicker(running_machine &machine, void *arg, int i
INT32 mame_ui_manager::slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
- vector_options::s_beam_width_min = MIN((float)newval * 0.01f, vector_options::s_beam_width_max);
+ vector_options::s_beam_width_min = std::min((float)newval * 0.01f, vector_options::s_beam_width_max);
if (str != nullptr)
*str = string_format(_("%1$1.2f"), vector_options::s_beam_width_min);
return floor(vector_options::s_beam_width_min * 100.0f + 0.5f);
@@ -2295,7 +2295,7 @@ INT32 mame_ui_manager::slider_beam_width_min(running_machine &machine, void *arg
INT32 mame_ui_manager::slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval)
{
if (newval != SLIDER_NOCHANGE)
- vector_options::s_beam_width_max = MAX((float)newval * 0.01f, vector_options::s_beam_width_min);
+ vector_options::s_beam_width_max = std::max((float)newval * 0.01f, vector_options::s_beam_width_min);
if (str != nullptr)
*str = string_format(_("%1$1.2f"), vector_options::s_beam_width_max);
return floor(vector_options::s_beam_width_max * 100.0f + 0.5f);
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index b706e14682a..a2b9fd95e32 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -137,7 +137,7 @@ int fuzzy_substring(std::string s_needle, std::string s_haystack)
for (int j = 0; j < s_haystack.size(); ++j)
{
int cost = (s_needle[i] == s_haystack[j]) ? 0 : 1;
- row2[j + 1] = MIN(row1[j + 1] + 1, MIN(row2[j] + 1, row1[j] + cost));
+ row2[j + 1] = std::min(row1[j + 1] + 1, std::min(row2[j] + 1, row1[j] + cost));
}
int *tmp = row1;
diff --git a/src/frontend/mame/ui/viewgfx.cpp b/src/frontend/mame/ui/viewgfx.cpp
index 2a4e0ebad38..b19df247cfc 100644
--- a/src/frontend/mame/ui/viewgfx.cpp
+++ b/src/frontend/mame/ui/viewgfx.cpp
@@ -613,14 +613,14 @@ static void gfxset_handler(mame_ui_manager &mui, render_container &container, ui
info.columns[set] = xcells;
// worst case, we need a pixel scale of 1
- pixelscale = MAX(1, pixelscale);
+ pixelscale = std::max(1, pixelscale);
// in the Y direction, we just display as many as we can
ycells = cellboxheight / (pixelscale * cellypix);
// now determine the actual cellbox size
- cellboxwidth = MIN(cellboxwidth, xcells * pixelscale * cellxpix);
- cellboxheight = MIN(cellboxheight, ycells * pixelscale * cellypix);
+ cellboxwidth = std::min(cellboxwidth, xcells * pixelscale * cellxpix);
+ cellboxheight = std::min(cellboxheight, ycells * pixelscale * cellypix);
// compute the size of a single cell at this pixel scale factor, as well as the aspect ratio
cellwidth = (cellboxwidth / (float)xcells) / (float)targwidth;
@@ -998,12 +998,12 @@ static void tilemap_handler(mame_ui_manager &mui, render_container &container, u
{
for (maxxscale = 1; mapwidth * (maxxscale + 1) < mapboxwidth; maxxscale++) { }
for (maxyscale = 1; mapheight * (maxyscale + 1) < mapboxheight; maxyscale++) { }
- pixelscale = MIN(maxxscale, maxyscale);
+ pixelscale = std::min(maxxscale, maxyscale);
}
// recompute the final box size
- mapboxwidth = MIN(mapboxwidth, mapwidth * pixelscale);
- mapboxheight = MIN(mapboxheight, mapheight * pixelscale);
+ mapboxwidth = std::min(mapboxwidth, int(mapwidth * pixelscale));
+ mapboxheight = std::min(mapboxheight, int(mapheight * pixelscale));
// recompute the bounds, centered within the existing bounds
mapboxbounds.x0 += 0.5f * ((mapboxbounds.x1 - mapboxbounds.x0) - (float)mapboxwidth / (float)targwidth);
diff --git a/src/frontend/mame/ui/widgets.cpp b/src/frontend/mame/ui/widgets.cpp
index 956e251dba6..da0b6c12538 100644
--- a/src/frontend/mame/ui/widgets.cpp
+++ b/src/frontend/mame/ui/widgets.cpp
@@ -95,14 +95,14 @@ void widgets_manager::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source
// first column we only consume one pixel
if (x == 0)
{
- dalpha = MIN(0xff, linewidth);
+ dalpha = std::min(0xff, linewidth);
target[x] = rgb_t(dalpha, 0xff, 0xff, 0xff);
}
// remaining columns consume two pixels, one on each side
else
{
- dalpha = MIN(0x1fe, linewidth);
+ dalpha = std::min(0x1fe, linewidth);
target[x] = target[-x] = rgb_t(dalpha / 2, 0xff, 0xff, 0xff);
}
diff --git a/src/lib/formats/apridisk.cpp b/src/lib/formats/apridisk.cpp
index b19e2c26bd7..08fd6777bd9 100644
--- a/src/lib/formats/apridisk.cpp
+++ b/src/lib/formats/apridisk.cpp
@@ -74,9 +74,9 @@ bool apridisk_format::load(io_generic *io, UINT32 form_factor, floppy_image *ima
UINT8 sector = pick_integer_le(&sector_header, 13, 1);
UINT8 track = (UINT8) pick_integer_le(&sector_header, 14, 2);
- track_count = MAX(track_count, track);
- head_count = MAX(head_count, head);
- sector_count = MAX(sector_count, sector);
+ track_count = std::max(track_count, int(track));
+ head_count = std::max(head_count, int(head));
+ sector_count = std::max(sector_count, int(sector));
// build sector info
sectors[track][head][sector - 1].head = head;
diff --git a/src/lib/formats/cassimg.cpp b/src/lib/formats/cassimg.cpp
index 4d7aeb0a9a3..edb1b9c138a 100644
--- a/src/lib/formats/cassimg.cpp
+++ b/src/lib/formats/cassimg.cpp
@@ -13,6 +13,7 @@
#include "imageutl.h"
#include "cassimg.h"
+#include <algorithm>
/* debugging parameters */
@@ -460,13 +461,13 @@ casserr_t cassette_get_samples(cassette_image *cassette, int channel,
case 2:
word = interpolate16(sum);
if (waveform_flags & CASSETTE_WAVEFORM_ENDIAN_FLIP)
- word = FLIPENDIAN_INT16(word);
+ word = flipendian_int16(word);
*((INT16 *) dest_ptr) = word;
break;
case 4:
dword = sum;
if (waveform_flags & CASSETTE_WAVEFORM_ENDIAN_FLIP)
- dword = FLIPENDIAN_INT32(dword);
+ dword = flipendian_int32(dword);
*((INT32 *) dest_ptr) = dword;
break;
}
@@ -529,13 +530,13 @@ casserr_t cassette_put_samples(cassette_image *cassette, int channel,
case 2:
word = *((INT16 *) source_ptr);
if (waveform_flags & CASSETTE_WAVEFORM_ENDIAN_FLIP)
- word = FLIPENDIAN_INT16(word);
+ word = flipendian_int16(word);
dest_value = extrapolate16(word);
break;
case 4:
dword = *((INT32 *) source_ptr);
if (waveform_flags & CASSETTE_WAVEFORM_ENDIAN_FLIP)
- dword = FLIPENDIAN_INT32(dword);
+ dword = flipendian_int32(dword);
dest_value = dword;
break;
default:
@@ -596,7 +597,7 @@ casserr_t cassette_read_samples(cassette_image *cassette, int channels, double t
while(samples_loaded < sample_count)
{
- chunk_sample_count = MIN(sizeof(buffer) / sample_bytes, (sample_count - samples_loaded));
+ chunk_sample_count = std::min(sizeof(buffer) / sample_bytes, (sample_count - samples_loaded));
chunk_sample_period = map_double(sample_period, 0, sample_count, chunk_sample_count);
chunk_time_index = time_index + map_double(sample_period, 0, sample_count, samples_loaded);
@@ -636,7 +637,7 @@ casserr_t cassette_write_samples(cassette_image *cassette, int channels, double
while(samples_saved < sample_count)
{
- chunk_sample_count = MIN(sizeof(buffer) / sample_bytes, (sample_count - samples_saved));
+ chunk_sample_count = std::min(sizeof(buffer) / sample_bytes, (sample_count - samples_saved));
chunk_sample_period = map_double(sample_period, 0, sample_count, chunk_sample_count);
chunk_time_index = time_index + map_double(sample_period, 0, sample_count, samples_saved);
@@ -688,7 +689,7 @@ casserr_t cassette_modulation_identify(cassette_image *cassette, const struct Ca
choose_wave(modulation, &wave_bytes_length);
opts->bits_per_sample = 8;
opts->channels = 1;
- opts->sample_frequency = (UINT32) (MAX(modulation->zero_frequency_high, modulation->one_frequency_high) * wave_bytes_length * 2);
+ opts->sample_frequency = (UINT32) (std::max(modulation->zero_frequency_high, modulation->one_frequency_high) * wave_bytes_length * 2);
return CASSETTE_ERROR_SUCCESS;
}
@@ -778,7 +779,7 @@ casserr_t cassette_read_modulated_data(cassette_image *cassette, int channel, do
}
else
{
- buffer_length = MIN(length, 100000);
+ buffer_length = std::min(length, U64(100000));
alloc_buffer = (UINT8*)malloc(buffer_length);
if (!alloc_buffer)
{
@@ -790,7 +791,7 @@ casserr_t cassette_read_modulated_data(cassette_image *cassette, int channel, do
while(length > 0)
{
- this_length = (size_t) MIN(length, buffer_length);
+ this_length = std::min(size_t(length), buffer_length);
cassette_image_read(cassette, buffer, offset, this_length);
err = cassette_put_modulated_data(cassette, channel, time_index, buffer, this_length, modulation, &delta);
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index e51ff900116..ab28b539bed 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -492,7 +492,7 @@ static floperr_t floppy_readwrite_sector(floppy_image_legacy *floppy, int head,
if (err)
goto done;
- this_buffer_len = MIN(buffer_len, sector_length - offset);
+ this_buffer_len = std::min(buffer_len, size_t(sector_length - offset));
if (writing)
{
diff --git a/src/lib/formats/ioprocs.cpp b/src/lib/formats/ioprocs.cpp
index 3efb1055e56..0be7cab97f4 100644
--- a/src/lib/formats/ioprocs.cpp
+++ b/src/lib/formats/ioprocs.cpp
@@ -196,11 +196,11 @@ void io_generic_write_filler(struct io_generic *genio, UINT8 filler, UINT64 offs
UINT8 buffer[512];
size_t this_length;
- memset(buffer, filler, MIN(length, sizeof(buffer)));
+ memset(buffer, filler, std::min(length, sizeof(buffer)));
while(length > 0)
{
- this_length = MIN(length, sizeof(buffer));
+ this_length = std::min(length, sizeof(buffer));
io_generic_write(genio, buffer, offset, this_length);
offset += this_length;
length -= this_length;
diff --git a/src/lib/util/cdrom.cpp b/src/lib/util/cdrom.cpp
index 74cc984a257..59a5b6cc18c 100644
--- a/src/lib/util/cdrom.cpp
+++ b/src/lib/util/cdrom.cpp
@@ -1253,16 +1253,16 @@ chd_error cdrom_parse_metadata(chd_file *chd, cdrom_toc *toc)
/* TODO: I don't know why sometimes the data is one endian and sometimes another */
if (toc->numtrks > CD_MAX_TRACKS)
{
- toc->numtrks = FLIPENDIAN_INT32(toc->numtrks);
+ toc->numtrks = flipendian_int32(toc->numtrks);
for (i = 0; i < CD_MAX_TRACKS; i++)
{
- toc->tracks[i].trktype = FLIPENDIAN_INT32(toc->tracks[i].trktype);
- toc->tracks[i].subtype = FLIPENDIAN_INT32(toc->tracks[i].subtype);
- toc->tracks[i].datasize = FLIPENDIAN_INT32(toc->tracks[i].datasize);
- toc->tracks[i].subsize = FLIPENDIAN_INT32(toc->tracks[i].subsize);
- toc->tracks[i].frames = FLIPENDIAN_INT32(toc->tracks[i].frames);
- toc->tracks[i].padframes = FLIPENDIAN_INT32(toc->tracks[i].padframes);
- toc->tracks[i].extraframes = FLIPENDIAN_INT32(toc->tracks[i].extraframes);
+ toc->tracks[i].trktype = flipendian_int32(toc->tracks[i].trktype);
+ toc->tracks[i].subtype = flipendian_int32(toc->tracks[i].subtype);
+ toc->tracks[i].datasize = flipendian_int32(toc->tracks[i].datasize);
+ toc->tracks[i].subsize = flipendian_int32(toc->tracks[i].subsize);
+ toc->tracks[i].frames = flipendian_int32(toc->tracks[i].frames);
+ toc->tracks[i].padframes = flipendian_int32(toc->tracks[i].padframes);
+ toc->tracks[i].extraframes = flipendian_int32(toc->tracks[i].extraframes);
}
}
diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp
index fd6f1c5ad1a..6d50ce1b571 100644
--- a/src/lib/util/chd.cpp
+++ b/src/lib/util/chd.cpp
@@ -242,7 +242,7 @@ inline UINT64 chd_file::file_append(const void *source, UINT32 length, UINT32 al
delta = alignment - delta;
while (delta != 0)
{
- UINT32 bytes_to_write = MIN(sizeof(buffer), delta);
+ UINT32 bytes_to_write = std::min(UINT32(sizeof(buffer)), delta);
UINT32 count = m_file->write(buffer, bytes_to_write);
if (count != bytes_to_write)
throw CHDERR_WRITE_ERROR;
@@ -1337,7 +1337,7 @@ chd_error chd_file::read_metadata(chd_metadata_tag searchtag, UINT32 searchindex
// read the metadata
resultlen = metaentry.length;
- file_read(metaentry.offset + METADATA_HEADER_SIZE, output, MIN(outputlen, resultlen));
+ file_read(metaentry.offset + METADATA_HEADER_SIZE, output, std::min(outputlen, resultlen));
return CHDERR_NONE;
}
@@ -1959,7 +1959,7 @@ chd_error chd_file::compress_v5_map()
else if (refhunk == last_self + 1)
curcomp = COMPRESSION_SELF_1;
else
- max_self = MAX(max_self, refhunk);
+ max_self = std::max(max_self, refhunk);
last_self = refhunk;
}
@@ -1974,13 +1974,13 @@ chd_error chd_file::compress_v5_map()
else if (refunit == last_parent + m_hunkbytes / m_unitbytes)
curcomp = COMPRESSION_PARENT_1;
else
- max_parent = MAX(max_parent, refunit);
+ max_parent = std::max(max_parent, UINT64(refunit));
last_parent = refunit;
}
// track maximum compressed length
else //if (curcomp >= COMPRESSION_TYPE_0 && curcomp <= COMPRESSION_TYPE_3)
- max_complen = MAX(max_complen, be_read(&m_rawmap[hunknum * 12 + 1], 3));
+ max_complen = std::max(max_complen, UINT32(be_read(&m_rawmap[hunknum * 12 + 1], 3))); // TODO: check types
// track repeats
if (curcomp == lastcomp)
@@ -2001,7 +2001,7 @@ chd_error chd_file::compress_v5_map()
}
else
{
- int this_count = MIN(count, 3+16+255);
+ int this_count = std::min(count, 3+16+255);
encoder.histo_one(*dest++ = COMPRESSION_RLE_LARGE);
encoder.histo_one(*dest++ = (this_count - 3 - 16) >> 4);
encoder.histo_one(*dest++ = (this_count - 3 - 16) & 15);
@@ -2333,7 +2333,7 @@ chd_error chd_file::create_common()
UINT64 offset = m_mapoffset;
while (mapsize != 0)
{
- UINT32 bytes_to_write = MIN(mapsize, sizeof(buffer));
+ UINT32 bytes_to_write = std::min(mapsize, UINT32(sizeof(buffer)));
file_write(offset, buffer, bytes_to_write);
offset += bytes_to_write;
mapsize -= bytes_to_write;
diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp
index 736fd7fb094..041061c38e9 100644
--- a/src/lib/util/chdcodec.cpp
+++ b/src/lib/util/chdcodec.cpp
@@ -1292,7 +1292,7 @@ UINT32 chd_flac_compressor::compress(const UINT8 *src, UINT32 srclen, UINT8 *des
UINT32 complen_le = m_encoder.finish();
// pick the best one and add a byte
- UINT32 complen = MIN(complen_le, complen_be);
+ UINT32 complen = std::min(complen_le, complen_be);
if (complen + 1 >= hunkbytes())
throw CHDERR_COMPRESSION_ERROR;
diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp
index ced56cd3115..a642bc86ba8 100644
--- a/src/lib/util/flac.cpp
+++ b/src/lib/util/flac.cpp
@@ -127,7 +127,7 @@ bool flac_encoder::encode_interleaved(const INT16 *samples, UINT32 samples_per_c
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- UINT32 cur_samples = MIN(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ UINT32 cur_samples = std::min(UINT32(ARRAY_LENGTH(converted_buffer) / num_channels), samples_per_channel);
// convert a buffers' worth
for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++)
@@ -160,7 +160,7 @@ bool flac_encoder::encode(INT16 *const *samples, UINT32 samples_per_channel, boo
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- UINT32 cur_samples = MIN(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ UINT32 cur_samples = std::min(UINT32(ARRAY_LENGTH(converted_buffer) / num_channels), samples_per_channel);
// convert a buffers' worth
for (UINT32 sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
@@ -233,7 +233,7 @@ FLAC__StreamEncoderWriteStatus flac_encoder::write_callback(const FLAC__byte buf
// if we're ignoring, continue to do so
if (m_ignore_bytes != 0)
{
- int ignore = MIN(bytes - offset, m_ignore_bytes);
+ size_t ignore = std::min(bytes - offset, size_t(m_ignore_bytes));
offset += ignore;
m_ignore_bytes -= ignore;
}
@@ -526,7 +526,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
UINT32 outputpos = 0;
if (outputpos < *bytes && m_compressed_offset < m_compressed_length)
{
- UINT32 bytes_to_copy = MIN(*bytes - outputpos, m_compressed_length - m_compressed_offset);
+ UINT32 bytes_to_copy = std::min(UINT32(*bytes - outputpos), m_compressed_length - m_compressed_offset);
memcpy(&buffer[outputpos], m_compressed_start + m_compressed_offset, bytes_to_copy);
outputpos += bytes_to_copy;
m_compressed_offset += bytes_to_copy;
@@ -535,7 +535,7 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s
// once we're out of that, copy from the secondary buffer
if (outputpos < *bytes && m_compressed_offset < m_compressed_length + m_compressed2_length)
{
- UINT32 bytes_to_copy = MIN(*bytes - outputpos, m_compressed2_length - (m_compressed_offset - m_compressed_length));
+ UINT32 bytes_to_copy = std::min(UINT32(*bytes - outputpos), m_compressed2_length - (m_compressed_offset - m_compressed_length));
memcpy(&buffer[outputpos], m_compressed2_start + m_compressed_offset - m_compressed_length, bytes_to_copy);
outputpos += bytes_to_copy;
m_compressed_offset += bytes_to_copy;
diff --git a/src/lib/util/huffman.cpp b/src/lib/util/huffman.cpp
index 8aa32bd3b4d..62756b89a17 100644
--- a/src/lib/util/huffman.cpp
+++ b/src/lib/util/huffman.cpp
@@ -101,7 +101,7 @@
#include "coretmpl.h"
#include "huffman.h"
-
+#include <algorithm>
//**************************************************************************
@@ -375,7 +375,7 @@ huffman_error huffman_context_base::export_tree_huffman(bitstream_out &bitbuf)
}
// clamp first non-zero to be 8 at a maximum
- first_non_zero = MIN(first_non_zero, 8);
+ first_non_zero = std::min(first_non_zero, 8);
// output the lengths of the each small tree node, starting with the RLE
// token (0), followed by the first_non_zero value, followed by the data
@@ -488,7 +488,7 @@ void huffman_context_base::write_rle_tree_bits(bitstream_out &bitbuf, int value,
// otherwise, write a triple using 1 as the escape code
else
{
- int cur_reps = MIN(repcount - 3, (1 << numbits) - 1);
+ int cur_reps = std::min(repcount - 3, (1 << numbits) - 1);
bitbuf.write(1, numbits);
bitbuf.write(value, numbits);
bitbuf.write(cur_reps, numbits);
@@ -597,7 +597,7 @@ int huffman_context_base::build_tree(UINT32 totaldata, UINT32 totalweight)
node.m_numbits = 1;
// keep track of the max
- maxbits = MAX(maxbits, node.m_numbits);
+ maxbits = std::max(maxbits, int(node.m_numbits));
}
}
return maxbits;
diff --git a/src/lib/util/options.h b/src/lib/util/options.h
index a0c3817651a..b669000e59f 100644
--- a/src/lib/util/options.h
+++ b/src/lib/util/options.h
@@ -176,7 +176,7 @@ public:
void mark_changed(const char *name);
// misc
- static const char *unadorned(int x = 0) { return s_option_unadorned[MIN(x, MAX_UNADORNED_OPTIONS)]; }
+ static const char *unadorned(int x = 0) { return s_option_unadorned[std::min(x, MAX_UNADORNED_OPTIONS)]; }
int options_count() const { return m_entrylist.count(); }
private:
diff --git a/src/lib/util/palette.cpp b/src/lib/util/palette.cpp
index 5fe68973c4b..bbee6b321cd 100644
--- a/src/lib/util/palette.cpp
+++ b/src/lib/util/palette.cpp
@@ -13,6 +13,7 @@
#include "palette.h"
#include <stdlib.h>
#include <math.h>
+#include <algorithm>
//**************************************************************************
@@ -107,8 +108,8 @@ void palette_client::dirty_state::resize(UINT32 colors)
void palette_client::dirty_state::mark_dirty(UINT32 index)
{
m_dirty[index / 32] |= 1 << (index % 32);
- m_mindirty = MIN(m_mindirty, index);
- m_maxdirty = MAX(m_maxdirty, index);
+ m_mindirty = std::min(m_mindirty, index);
+ m_maxdirty = std::max(m_maxdirty, index);
}
@@ -504,8 +505,8 @@ void palette_t::group_set_contrast(UINT32 group, float contrast)
void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_max)
{
// clamp within range
- start = MAX(start, 0);
- end = MIN(end, m_numcolors - 1);
+ start = std::max(start, 0U);
+ end = std::min(end, m_numcolors - 1);
// find the minimum and maximum brightness of all the colors in the range
INT32 ymin = 1000 * 255, ymax = 0;
@@ -513,8 +514,8 @@ void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_m
{
rgb_t rgb = m_entry_color[index];
UINT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- ymin = MIN(ymin, y);
- ymax = MAX(ymax, y);
+ ymin = std::min(ymin, INT32(y));
+ ymax = std::max(ymax, INT32(y));
}
// determine target minimum/maximum
diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp
index 0ddee038eee..83e906e112b 100644
--- a/src/lib/util/unicode.cpp
+++ b/src/lib/util/unicode.cpp
@@ -161,9 +161,9 @@ int uchar_from_utf16f(unicode_char *uchar, const utf16_char *utf16char, size_t c
{
utf16_char buf[2] = {0};
if (count > 0)
- buf[0] = FLIPENDIAN_INT16(utf16char[0]);
+ buf[0] = flipendian_int16(utf16char[0]);
if (count > 1)
- buf[1] = FLIPENDIAN_INT16(utf16char[1]);
+ buf[1] = flipendian_int16(utf16char[1]);
return uchar_from_utf16(uchar, buf, count);
}
@@ -309,9 +309,9 @@ int utf16f_from_uchar(utf16_char *utf16string, size_t count, unicode_char uchar)
rc = utf16_from_uchar(buf, count, uchar);
if (rc >= 1)
- utf16string[0] = FLIPENDIAN_INT16(buf[0]);
+ utf16string[0] = flipendian_int16(buf[0]);
if (rc >= 2)
- utf16string[1] = FLIPENDIAN_INT16(buf[1]);
+ utf16string[1] = flipendian_int16(buf[1]);
return rc;
}
diff --git a/src/lib/util/vbiparse.cpp b/src/lib/util/vbiparse.cpp
index ff523ee4265..854b5fbd384 100644
--- a/src/lib/util/vbiparse.cpp
+++ b/src/lib/util/vbiparse.cpp
@@ -11,7 +11,7 @@
#include "osdcore.h"
#include "vbiparse.h"
#include <math.h>
-
+#include <algorithm>
/***************************************************************************
@@ -58,8 +58,8 @@ int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sources
for (x = 0; x < sourcewidth; x++)
{
UINT8 rawsrc = source[x] >> sourceshift;
- min = MIN(min, rawsrc);
- max = MAX(max, rawsrc);
+ min = std::min(min, rawsrc);
+ max = std::max(max, rawsrc);
}
/* bail if the line is all black or all white */
diff --git a/src/mame/audio/hng64.cpp b/src/mame/audio/hng64.cpp
index 982aa46ca70..be6857113cb 100644
--- a/src/mame/audio/hng64.cpp
+++ b/src/mame/audio/hng64.cpp
@@ -70,15 +70,15 @@ WRITE32_MEMBER(hng64_state::hng64_soundram_w)
/* swap data around.. keep the v53 happy */
data = data32 >> 16;
- data = FLIPENDIAN_INT16(data);
+ data = flipendian_int16(data);
mem_mask = mem_mask32 >> 16;
- mem_mask = FLIPENDIAN_INT16(mem_mask);
+ mem_mask = flipendian_int16(mem_mask);
COMBINE_DATA(&m_soundram[offset * 2 + 0]);
data = data32 & 0xffff;
- data = FLIPENDIAN_INT16(data);
+ data = flipendian_int16(data);
mem_mask = mem_mask32 & 0xffff;
- mem_mask = FLIPENDIAN_INT16(mem_mask);
+ mem_mask = flipendian_int16(mem_mask);
COMBINE_DATA(&m_soundram[offset * 2 + 1]);
if (DUMP_SOUNDPRG)
@@ -105,7 +105,7 @@ READ32_MEMBER(hng64_state::hng64_soundram_r)
UINT16 datalo = m_soundram[offset * 2 + 0];
UINT16 datahi = m_soundram[offset * 2 + 1];
- return FLIPENDIAN_INT16(datahi) | (FLIPENDIAN_INT16(datalo) << 16);
+ return flipendian_int16(datahi) | (flipendian_int16(datalo) << 16);
}
WRITE32_MEMBER( hng64_state::hng64_soundcpu_enable_w )
diff --git a/src/mame/drivers/atari400.cpp b/src/mame/drivers/atari400.cpp
index 68df140f85c..e5e43fc15e6 100644
--- a/src/mame/drivers/atari400.cpp
+++ b/src/mame/drivers/atari400.cpp
@@ -1707,14 +1707,14 @@ void a400_state::setup_ram(int bank, UINT32 size)
switch (bank)
{
case 0: // 0x0000-0x7fff
- ram_top = MIN(size, 0x8000) - 1;
+ ram_top = std::min(size, UINT32(0x8000)) - 1;
m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x0000, ram_top, "0000");
if (m_0000 == nullptr)
m_0000.findit();
m_0000->set_base(m_ram->pointer());
break;
case 1: // 0x8000-0x9fff
- ram_top = MIN(size, 0xa000) - 1;
+ ram_top = std::min(size, UINT32(0xa000)) - 1;
if (ram_top > 0x8000)
{
m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0x8000, ram_top, "8000");
@@ -1724,7 +1724,7 @@ void a400_state::setup_ram(int bank, UINT32 size)
}
break;
case 2: // 0xa000-0xbfff
- ram_top = MIN(size, 0xc000) - 1;
+ ram_top = std::min(size, UINT32(0xc000)) - 1;
if (ram_top > 0xa000)
{
m_maincpu->space(AS_PROGRAM).install_readwrite_bank(0xa000, ram_top, "a000");
diff --git a/src/mame/drivers/icecold.cpp b/src/mame/drivers/icecold.cpp
index c67a15f76e9..b3776f4948c 100644
--- a/src/mame/drivers/icecold.cpp
+++ b/src/mame/drivers/icecold.cpp
@@ -310,10 +310,10 @@ TIMER_DEVICE_CALLBACK_MEMBER(icecold_state::icecold_motors_timer)
m_ball_gate_sw = 0;
// motors are keep in range 0-100
- m_lmotor = MIN(m_lmotor, 100);
- m_lmotor = MAX(m_lmotor, 0);
- m_rmotor = MIN(m_rmotor, 100);
- m_rmotor = MAX(m_rmotor, 0);
+ m_lmotor = std::min(m_lmotor, 100);
+ m_lmotor = std::max(m_lmotor, 0);
+ m_rmotor = std::min(m_rmotor, 100);
+ m_rmotor = std::max(m_rmotor, 0);
if (lmotor_dir != 0 || rmotor_dir != 0)
{
diff --git a/src/mame/drivers/jaguar.cpp b/src/mame/drivers/jaguar.cpp
index 7eef1272cf8..d19bba4b9ea 100644
--- a/src/mame/drivers/jaguar.cpp
+++ b/src/mame/drivers/jaguar.cpp
@@ -1984,7 +1984,7 @@ int jaguar_state::quickload(device_image_interface &image, const char *file_type
offs_t quickload_begin = 0x4000, start = quickload_begin, skip = 0;
memset(m_shared_ram, 0, 0x200000);
- quickload_size = MIN(quickload_size, 0x200000 - quickload_begin);
+ quickload_size = std::min(quickload_size, int(0x200000 - quickload_begin));
image.fread( &memregion("maincpu")->base()[quickload_begin], quickload_size);
diff --git a/src/mame/drivers/laser3k.cpp b/src/mame/drivers/laser3k.cpp
index c8732ac239d..b4e5482c93a 100644
--- a/src/mame/drivers/laser3k.cpp
+++ b/src/mame/drivers/laser3k.cpp
@@ -531,8 +531,8 @@ void laser3k_state::text_update(screen_device &screen, bitmap_ind16 &bitmap, con
m_flash = ((machine().time() * 4).seconds() & 1) ? 1 : 0;
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
for (row = beginrow; row <= endrow; row += 8)
{
diff --git a/src/mame/drivers/magictg.cpp b/src/mame/drivers/magictg.cpp
index 7a7a20bb33b..4388cc4fb5a 100644
--- a/src/mame/drivers/magictg.cpp
+++ b/src/mame/drivers/magictg.cpp
@@ -560,8 +560,8 @@ WRITE32_MEMBER( magictg_state::f0_w )
offset *= 4;
- data = FLIPENDIAN_INT32(data);
- mem_mask = FLIPENDIAN_INT32(mem_mask);
+ data = flipendian_int32(data);
+ mem_mask = flipendian_int32(mem_mask);
ch = ((offset >> 2) & 3) - 1;
@@ -606,7 +606,7 @@ WRITE32_MEMBER( magictg_state::f0_w )
while (m_dma_ch[ch].count > 3)
{
- UINT32 src_dword = FLIPENDIAN_INT32(space.read_dword(src_addr));
+ UINT32 src_dword = flipendian_int32(space.read_dword(src_addr));
space.write_dword(dst_addr, src_dword);
src_addr += 4;
dst_addr += 4;
@@ -616,7 +616,7 @@ WRITE32_MEMBER( magictg_state::f0_w )
// FIXME!
if (m_dma_ch[ch].count & 3)
{
- UINT32 src_dword = FLIPENDIAN_INT32(space.read_dword(src_addr));
+ UINT32 src_dword = flipendian_int32(space.read_dword(src_addr));
UINT32 dst_dword = space.read_dword(dst_addr);
UINT32 mask = 0xffffffff >> ((m_dma_ch[ch].count & 3) << 3);
@@ -667,19 +667,19 @@ READ32_MEMBER( magictg_state::f0_r )
case 0xcf8:
{
- val = m_pci->read(space, 0, FLIPENDIAN_INT32(mem_mask));
+ val = m_pci->read(space, 0, flipendian_int32(mem_mask));
break;
}
case 0xcfc:
{
- val = m_pci->read(space, 1, FLIPENDIAN_INT32(mem_mask));
+ val = m_pci->read(space, 1, flipendian_int32(mem_mask));
break;
}
// default:
// osd_printf_debug("R: %.8x\n", 0x0f000000 + offset);
}
- return FLIPENDIAN_INT32(val);
+ return flipendian_int32(val);
}
diff --git a/src/mame/drivers/maygayv1.cpp b/src/mame/drivers/maygayv1.cpp
index f6f5071c90a..23a0f61d757 100644
--- a/src/mame/drivers/maygayv1.cpp
+++ b/src/mame/drivers/maygayv1.cpp
@@ -399,7 +399,7 @@ UINT32 maygayv1_state::screen_update_maygayv1(screen_device &screen, bitmap_ind1
bmpptr = (UINT8*)objptr;
// 4bpp
- for (x = xpos; x < MIN(xbound, xpos + width * 8); ++x)
+ for (x = xpos; x < std::min(xbound, int(xpos + width * 8)); ++x)
{
if (x >= 0)
{
diff --git a/src/mame/drivers/midzeus.cpp b/src/mame/drivers/midzeus.cpp
index 4a9fb4eaa7a..0af3eef7fcd 100644
--- a/src/mame/drivers/midzeus.cpp
+++ b/src/mame/drivers/midzeus.cpp
@@ -506,7 +506,7 @@ TIMER_CALLBACK_MEMBER(midzeus_state::invasn_gun_callback)
/* generate another interrupt on the next scanline while we are within the BEAM_DY */
beamy++;
if (beamy <= m_screen->visible_area().max_y && beamy <= gun_y[player] + BEAM_DY)
- gun_timer[player]->adjust(m_screen->time_until_pos(beamy, MAX(0, gun_x[player] - BEAM_DX)), player);
+ gun_timer[player]->adjust(m_screen->time_until_pos(beamy, std::max(0, gun_x[player] - BEAM_DX)), player);
}
@@ -535,7 +535,7 @@ WRITE32_MEMBER(midzeus_state::invasn_gun_w)
};
gun_x[player] = ioport(names[player][0])->read() * visarea.width() / 255 + visarea.min_x + BEAM_XOFFS;
gun_y[player] = ioport(names[player][1])->read() * visarea.height() / 255 + visarea.min_y;
- gun_timer[player]->adjust(m_screen->time_until_pos(MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player);
+ gun_timer[player]->adjust(m_screen->time_until_pos(std::max(0, gun_y[player] - BEAM_DY), std::max(0, gun_x[player] - BEAM_DX)), player);
}
}
}
diff --git a/src/mame/drivers/model3.cpp b/src/mame/drivers/model3.cpp
index ad81aa4ef73..f85f4dd9ffc 100644
--- a/src/mame/drivers/model3.cpp
+++ b/src/mame/drivers/model3.cpp
@@ -908,7 +908,7 @@ WRITE64_MEMBER(model3_state::mpc105_addr_w)
{
if (ACCESSING_BITS_32_63)
{
- UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32));
+ UINT32 d = flipendian_int32((UINT32)(data >> 32));
m_mpc105_addr = data >> 32;
m_pci_bus = (d >> 16) & 0xff;
@@ -921,22 +921,22 @@ WRITE64_MEMBER(model3_state::mpc105_addr_w)
READ64_MEMBER(model3_state::mpc105_data_r)
{
if(m_pci_device == 0) {
- return ((UINT64)(FLIPENDIAN_INT32(m_mpc105_regs[(m_pci_reg/2)+1])) << 32) |
- ((UINT64)(FLIPENDIAN_INT32(m_mpc105_regs[(m_pci_reg/2)+0])));
+ return ((UINT64)(flipendian_int32(m_mpc105_regs[(m_pci_reg/2)+1])) << 32) |
+ ((UINT64)(flipendian_int32(m_mpc105_regs[(m_pci_reg/2)+0])));
}
- return FLIPENDIAN_INT32(pci_device_get_reg());
+ return flipendian_int32(pci_device_get_reg());
}
WRITE64_MEMBER(model3_state::mpc105_data_w)
{
if(m_pci_device == 0) {
- m_mpc105_regs[(m_pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32));
- m_mpc105_regs[(m_pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data));
+ m_mpc105_regs[(m_pci_reg/2)+1] = flipendian_int32((UINT32)(data >> 32));
+ m_mpc105_regs[(m_pci_reg/2)+0] = flipendian_int32((UINT32)(data));
return;
}
if (ACCESSING_BITS_0_31)
{
- pci_device_set_reg(FLIPENDIAN_INT32((UINT32)data));
+ pci_device_set_reg(flipendian_int32((UINT32)data));
}
}
@@ -985,7 +985,7 @@ WRITE64_MEMBER(model3_state::mpc106_addr_w)
{
if (ACCESSING_BITS_32_63)
{
- UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32));
+ UINT32 d = flipendian_int32((UINT32)(data >> 32));
if (((d >> 8) & 0xffffff) == 0x800000)
{
@@ -1006,29 +1006,29 @@ WRITE64_MEMBER(model3_state::mpc106_addr_w)
READ64_MEMBER(model3_state::mpc106_data_r)
{
if(m_pci_device == 0) {
- return ((UINT64)(FLIPENDIAN_INT32(m_mpc106_regs[(m_pci_reg/2)+1])) << 32) |
- ((UINT64)(FLIPENDIAN_INT32(m_mpc106_regs[(m_pci_reg/2)+0])));
+ return ((UINT64)(flipendian_int32(m_mpc106_regs[(m_pci_reg/2)+1])) << 32) |
+ ((UINT64)(flipendian_int32(m_mpc106_regs[(m_pci_reg/2)+0])));
}
if (ACCESSING_BITS_32_63)
{
- return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg())) << 32;
+ return (UINT64)(flipendian_int32(pci_device_get_reg())) << 32;
}
else
{
- return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg()));
+ return (UINT64)(flipendian_int32(pci_device_get_reg()));
}
}
WRITE64_MEMBER(model3_state::mpc106_data_w)
{
if(m_pci_device == 0) {
- m_mpc106_regs[(m_pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32));
- m_mpc106_regs[(m_pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data));
+ m_mpc106_regs[(m_pci_reg/2)+1] = flipendian_int32((UINT32)(data >> 32));
+ m_mpc106_regs[(m_pci_reg/2)+0] = flipendian_int32((UINT32)(data));
return;
}
if (ACCESSING_BITS_0_31)
{
- pci_device_set_reg(FLIPENDIAN_INT32((UINT32)data));
+ pci_device_set_reg(flipendian_int32((UINT32)data));
}
}
@@ -1132,7 +1132,7 @@ LSI53C810_FETCH_CB(model3_state::scsi_fetch)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
UINT32 result = space.read_dword(dsp);
- return FLIPENDIAN_INT32(result);
+ return flipendian_int32(result);
}
LSI53C810_IRQ_CB(model3_state::scsi_irq_callback)
@@ -1167,18 +1167,18 @@ WRITE64_MEMBER(model3_state::real3d_dma_w)
{
case 0:
if(ACCESSING_BITS_32_63) { /* DMA source address */
- m_dma_source = FLIPENDIAN_INT32((UINT32)(data >> 32));
+ m_dma_source = flipendian_int32((UINT32)(data >> 32));
return;
}
if(ACCESSING_BITS_0_31) { /* DMA destination address */
- m_dma_dest = FLIPENDIAN_INT32((UINT32)(data));
+ m_dma_dest = flipendian_int32((UINT32)(data));
return;
}
break;
case 1:
if(ACCESSING_BITS_32_63) /* DMA length */
{
- int length = FLIPENDIAN_INT32((UINT32)(data >> 32)) * 4;
+ int length = flipendian_int32((UINT32)(data >> 32)) * 4;
if (m_dma_endian & 0x80)
{
real3d_dma_callback(m_dma_source, m_dma_dest, length, 0);
@@ -1207,9 +1207,9 @@ WRITE64_MEMBER(model3_state::real3d_dma_w)
break;
case 2:
if(ACCESSING_BITS_32_63) { /* DMA command */
- UINT32 cmd = FLIPENDIAN_INT32((UINT32)(data >> 32));
+ UINT32 cmd = flipendian_int32((UINT32)(data >> 32));
if(cmd & 0x20000000) {
- m_dma_data = FLIPENDIAN_INT32(m_real3d_device_id); /* (PCI Vendor & Device ID) */
+ m_dma_data = flipendian_int32(m_real3d_device_id); /* (PCI Vendor & Device ID) */
}
else if(cmd & 0x80000000) {
m_dma_status ^= 0xffffffff;
diff --git a/src/mame/drivers/namcona1.cpp b/src/mame/drivers/namcona1.cpp
index 690e9926c4c..84dbf3cd748 100644
--- a/src/mame/drivers/namcona1.cpp
+++ b/src/mame/drivers/namcona1.cpp
@@ -570,7 +570,7 @@ ADDRESS_MAP_END
READ16_MEMBER(namcona1_state::na1mcu_shared_r)
{
- UINT16 data = FLIPENDIAN_INT16(m_workram[offset]);
+ UINT16 data = flipendian_int16(m_workram[offset]);
#if 0
if (offset >= 0x70000/2)
@@ -583,8 +583,8 @@ READ16_MEMBER(namcona1_state::na1mcu_shared_r)
WRITE16_MEMBER(namcona1_state::na1mcu_shared_w)
{
- mem_mask = FLIPENDIAN_INT16(mem_mask);
- data = FLIPENDIAN_INT16(data);
+ mem_mask = flipendian_int16(mem_mask);
+ data = flipendian_int16(data);
COMBINE_DATA(&m_workram[offset]);
}
diff --git a/src/mame/drivers/prestige.cpp b/src/mame/drivers/prestige.cpp
index 2c8c728800e..9c6206c39f7 100644
--- a/src/mame/drivers/prestige.cpp
+++ b/src/mame/drivers/prestige.cpp
@@ -253,8 +253,8 @@ READ8_MEMBER( prestige_state::mouse_r )
break;
}
- data = MIN(data, +127);
- data = MAX(data, -127);
+ data = std::min(data, INT16(+127));
+ data = std::min(data, INT16(-127));
return 0x80 + data;
}
diff --git a/src/mame/drivers/viper.cpp b/src/mame/drivers/viper.cpp
index e9d40256c23..66af4e6d086 100644
--- a/src/mame/drivers/viper.cpp
+++ b/src/mame/drivers/viper.cpp
@@ -476,20 +476,20 @@ static inline void write64le_with_32le_device_handler(write32_delegate handler,
static inline UINT64 read64be_with_32le_device_handler(read32_delegate handler, address_space &space, offs_t offset, UINT64 mem_mask)
{
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ mem_mask = flipendian_int64(mem_mask);
UINT64 result = 0;
if (ACCESSING_BITS_0_31)
result = (UINT64)(handler)(space, offset * 2, mem_mask & 0xffffffff);
if (ACCESSING_BITS_32_63)
result |= (UINT64)(handler)(space, offset * 2 + 1, mem_mask >> 32) << 32;
- return FLIPENDIAN_INT64(result);
+ return flipendian_int64(result);
}
static inline void write64be_with_32le_device_handler(write32_delegate handler, address_space &space, offs_t offset, UINT64 data, UINT64 mem_mask)
{
- data = FLIPENDIAN_INT64(data);
- mem_mask = FLIPENDIAN_INT64(mem_mask);
+ data = flipendian_int64(data);
+ mem_mask = flipendian_int64(mem_mask);
if (ACCESSING_BITS_0_31)
handler(space, offset * 2, data & 0xffffffff, mem_mask & 0xffffffff);
if (ACCESSING_BITS_32_63)
@@ -1009,7 +1009,7 @@ READ32_MEMBER(viper_state::epic_r)
}
}
- return FLIPENDIAN_INT32(ret);
+ return flipendian_int32(ret);
}
WRITE32_MEMBER(viper_state::epic_w)
@@ -1017,7 +1017,7 @@ WRITE32_MEMBER(viper_state::epic_w)
int reg;
reg = offset * 4;
- data = FLIPENDIAN_INT32(data);
+ data = flipendian_int32(data);
#if VIPER_DEBUG_EPIC_REGS
if (reg != 0x600b0) // interrupt clearing is spammy
diff --git a/src/mame/machine/coco_vhd.cpp b/src/mame/machine/coco_vhd.cpp
index 0510ce469ff..9965b3c0fe3 100644
--- a/src/mame/machine/coco_vhd.cpp
+++ b/src/mame/machine/coco_vhd.cpp
@@ -149,7 +149,7 @@ void coco_vhd_image_device::coco_vhd_readwrite(UINT8 data)
/* perform the seek */
seek_position = ((UINT64) 256) * m_logical_record_number;
total_size = length();
- result = fseek(MIN(seek_position, total_size), SEEK_SET);
+ result = fseek(std::min(seek_position, total_size), SEEK_SET);
if (result < 0)
{
m_status = VHDSTATUS_ACCESS_DENIED;
@@ -163,7 +163,7 @@ void coco_vhd_image_device::coco_vhd_readwrite(UINT8 data)
{
memset(buffer, 0, sizeof(buffer));
- bytes_to_write = (UINT32) MIN(seek_position - total_size, (UINT64) sizeof(buffer));
+ bytes_to_write = (UINT32)std::min(seek_position - total_size, (UINT64) sizeof(buffer));
result = fwrite(buffer, bytes_to_write);
if (result != bytes_to_write)
{
@@ -181,7 +181,7 @@ void coco_vhd_image_device::coco_vhd_readwrite(UINT8 data)
memset(buffer, 0, 256);
if (total_size > seek_position)
{
- bytes_to_read = (UINT32) MIN((UINT64) 256, total_size - seek_position);
+ bytes_to_read = (UINT32)std::min((UINT64) 256, total_size - seek_position);
result = fread(buffer, bytes_to_read);
if (result != bytes_to_read)
{
diff --git a/src/mame/machine/cybiko.cpp b/src/mame/machine/cybiko.cpp
index d27661cefe3..010d0dc3e71 100644
--- a/src/mame/machine/cybiko.cpp
+++ b/src/mame/machine/cybiko.cpp
@@ -38,7 +38,7 @@ DRIVER_INIT_MEMBER(cybiko_state,cybikoxt)
QUICKLOAD_LOAD_MEMBER( cybiko_state, cybiko )
{
- image.fread(m_flash1->get_ptr(), MIN(image.length(), 0x84000));
+ image.fread(m_flash1->get_ptr(), std::min(image.length(), UINT64(0x84000)));
return IMAGE_INIT_PASS;
}
@@ -46,7 +46,7 @@ QUICKLOAD_LOAD_MEMBER( cybiko_state, cybiko )
QUICKLOAD_LOAD_MEMBER( cybiko_state, cybikoxt )
{
address_space &dest = m_maincpu->space(AS_PROGRAM);
- UINT32 size = MIN(image.length(), RAMDISK_SIZE);
+ UINT32 size = std::min(image.length(), UINT64(RAMDISK_SIZE));
dynamic_buffer buffer(size);
image.fread(&buffer[0], size);
diff --git a/src/mame/machine/mac.cpp b/src/mame/machine/mac.cpp
index 51260a749b4..eb245a52b67 100644
--- a/src/mame/machine/mac.cpp
+++ b/src/mame/machine/mac.cpp
@@ -150,7 +150,7 @@ void mac_state::mac_install_memory(offs_t memory_begin, offs_t memory_end,
address_space& space = m_maincpu->space(AS_PROGRAM);
offs_t memory_mirror;
- memory_size = MIN(memory_size, (memory_end + 1 - memory_begin));
+ memory_size = std::min(memory_size, (memory_end + 1 - memory_begin));
memory_mirror = (memory_end - memory_begin) & ~(memory_size - 1);
if (!is_rom)
diff --git a/src/mame/machine/msx.cpp b/src/mame/machine/msx.cpp
index 285d8c359db..f94d8541665 100644
--- a/src/mame/machine/msx.cpp
+++ b/src/mame/machine/msx.cpp
@@ -386,7 +386,7 @@ void msx_state::install_slot_pages(device_t &owner, UINT8 prim, UINT8 sec, UINT8
msx_state &msx = downcast<msx_state &>(owner);
msx_internal_slot_interface *internal_slot = dynamic_cast<msx_internal_slot_interface *>(device);
- for ( int i = page; i < MIN(page + numpages, 4); i++ )
+ for ( int i = page; i < std::min(page + numpages, 4); i++ )
{
msx.m_all_slots[prim][sec][i] = internal_slot;
}
diff --git a/src/mame/machine/naomim2.cpp b/src/mame/machine/naomim2.cpp
index e74da6573fd..6e288d62d1d 100644
--- a/src/mame/machine/naomim2.cpp
+++ b/src/mame/machine/naomim2.cpp
@@ -159,7 +159,7 @@ void naomi_m2_board::board_get_buffer(UINT8 *&base, UINT32 &limit)
} else {
UINT32 offset4mb = (rom_cur_address & 0x103FFFFF) | ((rom_cur_address & 0x07C00000) << 1);
base = m_region->base() + offset4mb;
- limit = MIN(m_region->bytes() - offset4mb, 0x00400000 - (offset4mb & 0x003FFFFF));
+ limit = std::min(m_region->bytes() - offset4mb, 0x00400000 - (offset4mb & 0x003FFFFF));
}
}
}
diff --git a/src/mame/machine/pce_cd.cpp b/src/mame/machine/pce_cd.cpp
index f6105c30367..20e4b60cf23 100644
--- a/src/mame/machine/pce_cd.cpp
+++ b/src/mame/machine/pce_cd.cpp
@@ -660,7 +660,7 @@ void pce_cd_device::nec_get_dir_info()
m_data_buffer[3] = 0x04; /* correct? */
} else
{
- track = MAX(bcd_2_dec(m_command_buffer[2]), 1);
+ track = std::max(bcd_2_dec(m_command_buffer[2]), 1U);
frame = toc->tracks[track-1].logframeofs;
// PCE wants the start sector for data tracks to *not* include the pregap
if (toc->tracks[track-1].trktype != CD_TRACK_AUDIO)
diff --git a/src/mame/machine/segaic16.cpp b/src/mame/machine/segaic16.cpp
index bef1aed63e9..42c4a100ae6 100644
--- a/src/mame/machine/segaic16.cpp
+++ b/src/mame/machine/segaic16.cpp
@@ -586,7 +586,7 @@ void sega_315_5195_mapper_device::compute_region(region_info &info, UINT8 index,
info.base = (m_regs[0x11 + 2 * index] << 16) & ~info.size_mask;
info.mirror = mirror & info.size_mask;
info.start = info.base + (offset & info.size_mask);
- info.end = info.start + MIN(length - 1, info.size_mask);
+ info.end = info.start + std::min(length - 1, info.size_mask);
}
diff --git a/src/mame/machine/sms.cpp b/src/mame/machine/sms.cpp
index 8296ac44fef..9b25b4017f4 100644
--- a/src/mame/machine/sms.cpp
+++ b/src/mame/machine/sms.cpp
@@ -1493,7 +1493,7 @@ void sms_state::screen_gg_sms_mode_scaling(screen_device &screen, bitmap_rgb32 &
/* Plot positions relative to visarea minimum values */
const int plot_min_x = cliprect.min_x - visarea.min_x;
- const int plot_max_x = MIN(cliprect.max_x - visarea.min_x, 159); // avoid m_line_buffer overflow.
+ const int plot_max_x = std::min(cliprect.max_x - visarea.min_x, 159); // avoid m_line_buffer overflow.
const int plot_min_y = cliprect.min_y - visarea.min_y;
const int plot_max_y = cliprect.max_y - visarea.min_y;
@@ -1521,7 +1521,7 @@ void sms_state::screen_gg_sms_mode_scaling(screen_device &screen, bitmap_rgb32 &
for (int plot_y_group = plot_y_first_group; plot_y_group <= plot_max_y; plot_y_group += 2)
{
- const int y_max_i = MIN(1, plot_max_y - plot_y_group);
+ const int y_max_i = std::min(1, plot_max_y - plot_y_group);
for (int y_i = y_min_i; y_i <= y_max_i; y_i++)
{
@@ -1530,7 +1530,7 @@ void sms_state::screen_gg_sms_mode_scaling(screen_device &screen, bitmap_rgb32 &
const int sms_max_y2 = sms_y + y_i + 2;
/* Process lines, but skip those already processed before */
- for (sms_y2 = MAX(sms_min_y2, sms_y2); sms_y2 <= sms_max_y2; sms_y2++)
+ for (sms_y2 = std::max(sms_min_y2, sms_y2); sms_y2 <= sms_max_y2; sms_y2++)
{
int *combineline_buffer = m_line_buffer.get() + (sms_y2 & 0x03) * 160;
@@ -1544,7 +1544,7 @@ void sms_state::screen_gg_sms_mode_scaling(screen_device &screen, bitmap_rgb32 &
/* Do horizontal scaling */
for (int plot_x_group = plot_x_first_group; plot_x_group <= plot_max_x; plot_x_group += 2)
{
- const int x_max_i = MIN(1, plot_max_x - plot_x_group);
+ const int x_max_i = std::min(1, plot_max_x - plot_x_group);
for (int x_i = x_min_i; x_i <= x_max_i; x_i++)
{
diff --git a/src/mame/machine/vectrex.cpp b/src/mame/machine/vectrex.cpp
index 4959c3de5f1..c2f909fd4a3 100644
--- a/src/mame/machine/vectrex.cpp
+++ b/src/mame/machine/vectrex.cpp
@@ -289,7 +289,7 @@ WRITE8_MEMBER(vectrex_state::vectrex_psg_port_w)
if (m_imager_freq > 1)
{
m_imager_timer->adjust(
- attotime::from_double(MIN(1.0 / m_imager_freq, m_imager_timer->remaining().as_double())),
+ attotime::from_double(std::min(1.0 / m_imager_freq, m_imager_timer->remaining().as_double())),
2,
attotime::from_double(1.0 / m_imager_freq));
}
diff --git a/src/mame/video/abc800.cpp b/src/mame/video/abc800.cpp
index 4bd01b4160f..6be1813928b 100644
--- a/src/mame/video/abc800.cpp
+++ b/src/mame/video/abc800.cpp
@@ -74,7 +74,7 @@ void abc800c_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect)
UINT16 addr = 0;
- for (int y = m_hrs; y < MIN(cliprect.max_y + 1, m_hrs + 480); y += 2)
+ for (int y = m_hrs; y < std::min(cliprect.max_y + 1, m_hrs + 480); y += 2)
{
int x = 0;
@@ -204,7 +204,7 @@ void abc800m_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect)
const pen_t *pen = m_palette->pens();
- for (int y = m_hrs + VERTICAL_PORCH_HACK; y < MIN(cliprect.max_y + 1, m_hrs + VERTICAL_PORCH_HACK + 240); y++)
+ for (int y = m_hrs + VERTICAL_PORCH_HACK; y < std::min(cliprect.max_y + 1, m_hrs + VERTICAL_PORCH_HACK + 240); y++)
{
int x = HORIZONTAL_PORCH_HACK;
diff --git a/src/mame/video/abc806.cpp b/src/mame/video/abc806.cpp
index 3d4a31ec39c..7eceef51096 100644
--- a/src/mame/video/abc806.cpp
+++ b/src/mame/video/abc806.cpp
@@ -387,7 +387,7 @@ void abc806_state::hr_update(bitmap_rgb32 &bitmap, const rectangle &cliprect)
UINT32 addr = (m_hrs & 0x0f) << 15;
- for (int y = m_sync + VERTICAL_PORCH_HACK; y < MIN(cliprect.max_y + 1, m_sync + VERTICAL_PORCH_HACK + 240); y++)
+ for (int y = m_sync + VERTICAL_PORCH_HACK; y < std::min(cliprect.max_y + 1, m_sync + VERTICAL_PORCH_HACK + 240); y++)
{
for (int sx = 0; sx < 128; sx++)
{
diff --git a/src/mame/video/antic.cpp b/src/mame/video/antic.cpp
index e393107bf53..45743a2113a 100644
--- a/src/mame/video/antic.cpp
+++ b/src/mame/video/antic.cpp
@@ -1655,7 +1655,7 @@ void antic_device::linerefresh()
dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16;
dst[3] = color_lookup[PBK] | color_lookup[PBK] << 16;
- draw_scanline8(*m_bitmap, 12, y, MIN(m_bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, nullptr);
+ draw_scanline8(*m_bitmap, 12, y, std::min(size_t(m_bitmap->width() - 12), sizeof(scanline)), (const UINT8 *) scanline, nullptr);
}
diff --git a/src/mame/video/apple2.cpp b/src/mame/video/apple2.cpp
index 787f9ff8f35..b56ac22ea38 100644
--- a/src/mame/video/apple2.cpp
+++ b/src/mame/video/apple2.cpp
@@ -73,8 +73,8 @@ void apple2_state::adjust_begin_and_end_row(const rectangle &cliprect, int *begi
assert((*beginrow % 8) == 0);
assert((*endrow % 8) == 7);
- *beginrow = MAX(*beginrow, cliprect.min_y - (cliprect.min_y % 8));
- *endrow = MIN(*endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ *beginrow = std::max(*beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ *endrow = std::min(*endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
/* sanity check again */
assert((*beginrow % 8) == 0);
@@ -948,8 +948,8 @@ void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap,
}
/* perform adjustments */
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
if (!(m_sysconfig & 0x03))
{
@@ -1030,8 +1030,8 @@ void a2_video_device::dlores_update(screen_device &screen, bitmap_ind16 &bitmap,
}
/* perform adjustments */
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
if (!(m_sysconfig & 0x03))
{
@@ -1176,8 +1176,8 @@ void a2_video_device::text_update(screen_device &screen, bitmap_ind16 &bitmap, c
start_address = m_page2 ? 0x800 : 0x400;
}
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
switch (m_sysconfig & 0x03)
{
@@ -1223,8 +1223,8 @@ void a2_video_device::text_update_orig(screen_device &screen, bitmap_ind16 &bitm
int fg = 0;
int bg = 0;
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
switch (m_sysconfig & 0x03)
{
@@ -1254,8 +1254,8 @@ void a2_video_device::text_update_jplus(screen_device &screen, bitmap_ind16 &bit
int fg = 0;
int bg = 0;
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
switch (m_sysconfig & 0x03)
{
@@ -1285,8 +1285,8 @@ void a2_video_device::text_update_ultr(screen_device &screen, bitmap_ind16 &bitm
int fg = 0;
int bg = 0;
- beginrow = MAX(beginrow, cliprect.min_y - (cliprect.min_y % 8));
- endrow = MIN(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
+ beginrow = std::max(beginrow, cliprect.min_y - (cliprect.min_y % 8));
+ endrow = std::min(endrow, cliprect.max_y - (cliprect.max_y % 8) + 7);
switch (m_sysconfig & 0x03)
{
diff --git a/src/mame/video/astrocde.cpp b/src/mame/video/astrocde.cpp
index 54ea340b7b4..302f9444d56 100644
--- a/src/mame/video/astrocde.cpp
+++ b/src/mame/video/astrocde.cpp
@@ -99,12 +99,12 @@ PALETTE_INIT_MEMBER(astrocde_state, astrocde)
b = (by + y) * 255;
/* clamp and store */
- r = MAX(r, 0);
- r = MIN(r, 255);
- g = MAX(g, 0);
- g = MIN(g, 255);
- b = MAX(b, 0);
- b = MIN(b, 255);
+ r = std::max(r, 0);
+ r = std::min(r, 255);
+ g = std::max(g, 0);
+ g = std::min(g, 255);
+ b = std::max(b, 0);
+ b = std::min(b, 255);
palette.set_pen_color(color * 16 + luma, rgb_t(r, g, b));
}
}
diff --git a/src/mame/video/atarig1.cpp b/src/mame/video/atarig1.cpp
index b5809441f0f..638abd27013 100644
--- a/src/mame/video/atarig1.cpp
+++ b/src/mame/video/atarig1.cpp
@@ -77,7 +77,7 @@ void atarig1_state::scanline_update(screen_device &screen, int scanline)
int offset = (scanline / 8) * 64 + 48;
if (offset >= 0x800)
return;
- screen.update_partial(MAX(scanline - 1, 0));
+ screen.update_partial(std::max(scanline - 1, 0));
/* update the playfield scrolls */
for (i = 0; i < 8; i++)
@@ -91,7 +91,7 @@ void atarig1_state::scanline_update(screen_device &screen, int scanline)
int newscroll = ((word >> 6) + m_pfscroll_xoffset) & 0x1ff;
if (newscroll != m_playfield_xscroll)
{
- screen.update_partial(MAX(scanline + i - 1, 0));
+ screen.update_partial(std::max(scanline + i - 1, 0));
m_playfield_tilemap->set_scrollx(0, newscroll);
m_playfield_xscroll = newscroll;
}
@@ -105,13 +105,13 @@ void atarig1_state::scanline_update(screen_device &screen, int scanline)
int newbank = word & 7;
if (newscroll != m_playfield_yscroll)
{
- screen.update_partial(MAX(scanline + i - 1, 0));
+ screen.update_partial(std::max(scanline + i - 1, 0));
m_playfield_tilemap->set_scrolly(0, newscroll);
m_playfield_yscroll = newscroll;
}
if (newbank != m_playfield_tile_bank)
{
- screen.update_partial(MAX(scanline + i - 1, 0));
+ screen.update_partial(std::max(scanline + i - 1, 0));
m_playfield_tilemap->mark_all_dirty();
m_playfield_tile_bank = newbank;
}
diff --git a/src/mame/video/chihiro.cpp b/src/mame/video/chihiro.cpp
index 48cca5d119c..b3ef942a1cb 100644
--- a/src/mame/video/chihiro.cpp
+++ b/src/mame/video/chihiro.cpp
@@ -3851,18 +3851,18 @@ float nv2a_renderer::combiner_map_input_function(int code, float value)
switch (code) {
case 0:
- return MAX(0.0f, value);
+ return std::max(0.0f, value);
case 1:
- t = MAX(value, 0.0f);
- return 1.0f - MIN(t, 1.0f);
+ t = std::max(value, 0.0f);
+ return 1.0f - std::min(t, 1.0f);
case 2:
- return 2.0f * MAX(0.0f, value) - 1.0f;
+ return 2.0f * std::max(0.0f, value) - 1.0f;
case 3:
- return -2.0f * MAX(0.0f, value) + 1.0f;
+ return -2.0f * std::max(0.0f, value) + 1.0f;
case 4:
- return MAX(0.0f, value) - 0.5f;
+ return std::max(0.0f, value) - 0.5f;
case 5:
- return -MAX(0.0f, value) + 0.5f;
+ return -std::max(0.0f, value) + 0.5f;
case 6:
return value;
case 7:
@@ -3880,37 +3880,37 @@ void nv2a_renderer::combiner_map_input_function3(int code, float *data)
switch (code) {
case 0:
- data[0] = MAX(0.0f, data[0]);
- data[1] = MAX(0.0f, data[1]);
- data[2] = MAX(0.0f, data[2]);
+ data[0] = std::max(0.0f, data[0]);
+ data[1] = std::max(0.0f, data[1]);
+ data[2] = std::max(0.0f, data[2]);
break;
case 1:
- t = MAX(data[0], 0.0f);
- data[0] = 1.0f - MIN(t, 1.0f);
- t = MAX(data[1], 0.0f);
- data[1] = 1.0f - MIN(t, 1.0f);
- t = MAX(data[2], 0.0f);
- data[2] = 1.0f - MIN(t, 1.0f);
+ t = std::max(data[0], 0.0f);
+ data[0] = 1.0f - std::min(t, 1.0f);
+ t = std::max(data[1], 0.0f);
+ data[1] = 1.0f - std::min(t, 1.0f);
+ t = std::max(data[2], 0.0f);
+ data[2] = 1.0f - std::min(t, 1.0f);
break;
case 2:
- data[0] = 2.0f * MAX(0.0f, data[0]) - 1.0f;
- data[1] = 2.0f * MAX(0.0f, data[1]) - 1.0f;
- data[2] = 2.0f * MAX(0.0f, data[2]) - 1.0f;
+ data[0] = 2.0f * std::max(0.0f, data[0]) - 1.0f;
+ data[1] = 2.0f * std::max(0.0f, data[1]) - 1.0f;
+ data[2] = 2.0f * std::max(0.0f, data[2]) - 1.0f;
break;
case 3:
- data[0] = -2.0f * MAX(0.0f, data[0]) + 1.0f;
- data[1] = -2.0f * MAX(0.0f, data[1]) + 1.0f;
- data[2] = -2.0f * MAX(0.0f, data[2]) + 1.0f;
+ data[0] = -2.0f * std::max(0.0f, data[0]) + 1.0f;
+ data[1] = -2.0f * std::max(0.0f, data[1]) + 1.0f;
+ data[2] = -2.0f * std::max(0.0f, data[2]) + 1.0f;
break;
case 4:
- data[0] = MAX(0.0f, data[0]) - 0.5f;
- data[1] = MAX(0.0f, data[1]) - 0.5f;
- data[2] = MAX(0.0f, data[2]) - 0.5f;
+ data[0] = std::max(0.0f, data[0]) - 0.5f;
+ data[1] = std::max(0.0f, data[1]) - 0.5f;
+ data[2] = std::max(0.0f, data[2]) - 0.5f;
break;
case 5:
- data[0] = -MAX(0.0f, data[0]) + 0.5f;
- data[1] = -MAX(0.0f, data[1]) + 0.5f;
- data[2] = -MAX(0.0f, data[2]) + 0.5f;
+ data[0] = -std::max(0.0f, data[0]) + 0.5f;
+ data[1] = -std::max(0.0f, data[1]) + 0.5f;
+ data[2] = -std::max(0.0f, data[2]) + 0.5f;
break;
case 6:
return;
@@ -4088,13 +4088,13 @@ void nv2a_renderer::combiner_map_final_input()
combiner.variable_EF[1] = combiner.variable_E[1] * combiner.variable_F[1];
combiner.variable_EF[2] = combiner.variable_E[2] * combiner.variable_F[2];
// sumclamp
- combiner.variable_sumclamp[0] = MAX(0, combiner.register_spare0[0]) + MAX(0, combiner.register_secondarycolor[0]);
- combiner.variable_sumclamp[1] = MAX(0, combiner.register_spare0[1]) + MAX(0, combiner.register_secondarycolor[1]);
- combiner.variable_sumclamp[2] = MAX(0, combiner.register_spare0[2]) + MAX(0, combiner.register_secondarycolor[2]);
+ combiner.variable_sumclamp[0] = std::max(0.0f, combiner.register_spare0[0]) + std::max(0.0f, combiner.register_secondarycolor[0]);
+ combiner.variable_sumclamp[1] = std::max(0.0f, combiner.register_spare0[1]) + std::max(0.0f, combiner.register_secondarycolor[1]);
+ combiner.variable_sumclamp[2] = std::max(0.0f, combiner.register_spare0[2]) + std::max(0.0f, combiner.register_secondarycolor[2]);
if (combiner.final.color_sum_clamp != 0) {
- combiner.variable_sumclamp[0] = MIN(combiner.variable_sumclamp[0], 1.0f);
- combiner.variable_sumclamp[1] = MIN(combiner.variable_sumclamp[1], 1.0f);
- combiner.variable_sumclamp[2] = MIN(combiner.variable_sumclamp[2], 1.0f);
+ combiner.variable_sumclamp[0] = std::min(combiner.variable_sumclamp[0], 1.0f);
+ combiner.variable_sumclamp[1] = std::min(combiner.variable_sumclamp[1], 1.0f);
+ combiner.variable_sumclamp[2] = std::min(combiner.variable_sumclamp[2], 1.0f);
}
// A
pv = combiner_map_input_select3(combiner.final.mapin_rgbA_input);
@@ -4142,9 +4142,9 @@ void nv2a_renderer::combiner_final_output()
combiner.output[0] = combiner.variable_A[0] * combiner.variable_B[0] + (1.0f - combiner.variable_A[0])*combiner.variable_C[0] + combiner.variable_D[0];
combiner.output[1] = combiner.variable_A[1] * combiner.variable_B[1] + (1.0f - combiner.variable_A[1])*combiner.variable_C[1] + combiner.variable_D[1];
combiner.output[2] = combiner.variable_A[2] * combiner.variable_B[2] + (1.0f - combiner.variable_A[2])*combiner.variable_C[2] + combiner.variable_D[2];
- combiner.output[0] = MIN(combiner.output[0], 1.0f);
- combiner.output[1] = MIN(combiner.output[1], 1.0f);
- combiner.output[2] = MIN(combiner.output[2], 1.0f);
+ combiner.output[0] = std::min(combiner.output[0], 1.0f);
+ combiner.output[1] = std::min(combiner.output[1], 1.0f);
+ combiner.output[2] = std::min(combiner.output[2], 1.0f);
// a
combiner.output[3] = combiner_map_input_function(combiner.final.mapin_aG_mapping, combiner.variable_G);
}
@@ -4225,26 +4225,26 @@ void nv2a_renderer::combiner_compute_rgb_outputs(int stage_number)
m = 0;
combiner_function_AB(combiner.function_RGBop1);
}
- combiner.function_RGBop1[0] = MAX(MIN((combiner.function_RGBop1[0] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop1[1] = MAX(MIN((combiner.function_RGBop1[1] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop1[2] = MAX(MIN((combiner.function_RGBop1[2] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop1[0] = std::max(std::min((combiner.function_RGBop1[0] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop1[1] = std::max(std::min((combiner.function_RGBop1[1] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop1[2] = std::max(std::min((combiner.function_RGBop1[2] + biasrgb) * scalergb, 1.0f), -1.0f);
if (combiner.stage[n].mapout_rgbCD_dotproduct) {
m = m | 1;
combiner_function_CdotD(combiner.function_RGBop2);
}
else
combiner_function_CD(combiner.function_RGBop2);
- combiner.function_RGBop2[0] = MAX(MIN((combiner.function_RGBop2[0] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop2[1] = MAX(MIN((combiner.function_RGBop2[1] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop2[2] = MAX(MIN((combiner.function_RGBop2[2] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop2[0] = std::max(std::min((combiner.function_RGBop2[0] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop2[1] = std::max(std::min((combiner.function_RGBop2[1] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop2[2] = std::max(std::min((combiner.function_RGBop2[2] + biasrgb) * scalergb, 1.0f), -1.0f);
if (m == 0) {
if (combiner.stage[n].mapout_rgb_muxsum)
combiner_function_ABmuxCD(combiner.function_RGBop3);
else
combiner_function_ABsumCD(combiner.function_RGBop3);
- combiner.function_RGBop3[0] = MAX(MIN((combiner.function_RGBop3[0] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop3[1] = MAX(MIN((combiner.function_RGBop3[1] + biasrgb) * scalergb, 1.0f), -1.0f);
- combiner.function_RGBop3[2] = MAX(MIN((combiner.function_RGBop3[2] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop3[0] = std::max(std::min((combiner.function_RGBop3[0] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop3[1] = std::max(std::min((combiner.function_RGBop3[1] + biasrgb) * scalergb, 1.0f), -1.0f);
+ combiner.function_RGBop3[2] = std::max(std::min((combiner.function_RGBop3[2] + biasrgb) * scalergb, 1.0f), -1.0f);
}
}
@@ -4273,9 +4273,9 @@ void nv2a_renderer::combiner_compute_a_outputs(int stage_number)
break;
}
combiner.function_Aop1 = combiner.variable_A[3] * combiner.variable_B[3];
- combiner.function_Aop1 = MAX(MIN((combiner.function_Aop1 + biasa) * scalea, 1.0f), -1.0f);
+ combiner.function_Aop1 = std::max(std::min((combiner.function_Aop1 + biasa) * scalea, 1.0f), -1.0f);
combiner.function_Aop2 = combiner.variable_C[3] * combiner.variable_D[3];
- combiner.function_Aop2 = MAX(MIN((combiner.function_Aop2 + biasa) * scalea, 1.0f), -1.0f);
+ combiner.function_Aop2 = std::max(std::min((combiner.function_Aop2 + biasa) * scalea, 1.0f), -1.0f);
if (combiner.stage[n].mapout_a_muxsum) {
if (combiner.register_spare0[3] >= 0.5f)
combiner.function_Aop3 = combiner.variable_A[3] * combiner.variable_B[3];
@@ -4284,7 +4284,7 @@ void nv2a_renderer::combiner_compute_a_outputs(int stage_number)
}
else
combiner.function_Aop3 = combiner.variable_A[3] * combiner.variable_B[3] + combiner.variable_C[3] * combiner.variable_D[3];
- combiner.function_Aop3 = MAX(MIN((combiner.function_Aop3 + biasa) * scalea, 1.0f), -1.0f);
+ combiner.function_Aop3 = std::max(std::min((combiner.function_Aop3 + biasa) * scalea, 1.0f), -1.0f);
}
void nv2a_renderer::vblank_callback(screen_device &screen, bool state)
diff --git a/src/mame/video/galaxian.cpp b/src/mame/video/galaxian.cpp
index 9af1055eea0..df4c744f4f2 100644
--- a/src/mame/video/galaxian.cpp
+++ b/src/mame/video/galaxian.cpp
@@ -540,8 +540,8 @@ void galaxian_state::sprites_draw(bitmap_rgb32 &bitmap, const rectangle &cliprec
/* 16 of the 256 pixels of the sprites are hard-clipped at the line buffer */
/* according to the schematics, it should be the first 16 pixels */
- clip.min_x = MAX(clip.min_x, (!m_flipscreen_x) * (16 + hoffset) * GALAXIAN_XSCALE);
- clip.max_x = MIN(clip.max_x, (256 - m_flipscreen_x * (16 + hoffset)) * GALAXIAN_XSCALE - 1);
+ clip.min_x = std::max(clip.min_x, (!m_flipscreen_x) * (16 + hoffset) * GALAXIAN_XSCALE);
+ clip.max_x = std::min(clip.max_x, (256 - m_flipscreen_x * (16 + hoffset)) * GALAXIAN_XSCALE - 1);
/* The line buffer is only written if it contains a '0' currently; */
/* it is cleared during the visible area, and populated during HBLANK */
@@ -946,24 +946,24 @@ void galaxian_state::background_draw_colorsplit(bitmap_rgb32 &bitmap, const rect
if (m_flipscreen_x)
{
rectangle draw = cliprect;
- draw.max_x = MIN(draw.max_x, split_flipped * GALAXIAN_XSCALE - 1);
+ draw.max_x = std::min(draw.max_x, split_flipped * GALAXIAN_XSCALE - 1);
if (draw.min_x <= draw.max_x)
bitmap.fill(rgb_t::black, draw);
draw = cliprect;
- draw.min_x = MAX(draw.min_x, split_flipped * GALAXIAN_XSCALE);
+ draw.min_x = std::max(draw.min_x, split_flipped * GALAXIAN_XSCALE);
if (draw.min_x <= draw.max_x)
bitmap.fill(color, draw);
}
else
{
rectangle draw = cliprect;
- draw.max_x = MIN(draw.max_x, split * GALAXIAN_XSCALE - 1);
+ draw.max_x = std::min(draw.max_x, split * GALAXIAN_XSCALE - 1);
if (draw.min_x <= draw.max_x)
bitmap.fill(color, draw);
draw = cliprect;
- draw.min_x = MAX(draw.min_x, split * GALAXIAN_XSCALE);
+ draw.min_x = std::max(draw.min_x, split * GALAXIAN_XSCALE);
if (draw.min_x <= draw.max_x)
bitmap.fill(rgb_t::black, draw);
}
diff --git a/src/mame/video/jaguar.cpp b/src/mame/video/jaguar.cpp
index 3e0803cfb90..15a016389bb 100644
--- a/src/mame/video/jaguar.cpp
+++ b/src/mame/video/jaguar.cpp
@@ -647,10 +647,10 @@ WRITE16_MEMBER( jaguar_state::tom_regs_w )
if (reg_store != m_gpu_regs[offset])
{
int hperiod = 2 * ((m_gpu_regs[HP] & 0x3ff) + 1);
- int hbend = effective_hvalue(ENABLE_BORDERS ? m_gpu_regs[HBE] : MIN(m_gpu_regs[HDB1], m_gpu_regs[HDB2]));
+ int hbend = effective_hvalue(ENABLE_BORDERS ? m_gpu_regs[HBE] : std::min(m_gpu_regs[HDB1], m_gpu_regs[HDB2]));
int hbstart = effective_hvalue(m_gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
int vperiod = (m_gpu_regs[VP] & 0x7ff) + 1;
- int vbend = MAX(m_gpu_regs[VBE],m_gpu_regs[VDB]) & 0x7ff;
+ int vbend = std::max(m_gpu_regs[VBE],m_gpu_regs[VDB]) & 0x7ff;
int vbstart = m_gpu_regs[VBB] & 0x7ff;
/* adjust for the half-lines */
diff --git a/src/mame/video/m62.cpp b/src/mame/video/m62.cpp
index 35c97ef807b..60ae3964a8e 100644
--- a/src/mame/video/m62.cpp
+++ b/src/mame/video/m62.cpp
@@ -193,7 +193,7 @@ void m62_state::m62_amplify_contrast(palette_t *palette, UINT32 numcolors)
{
rgb_t rgb = palette->entry_color(i);
UINT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- ymax = MAX(ymax, y);
+ ymax = std::max(ymax, y);
}
palette->set_contrast(255000.0/ymax);
diff --git a/src/mame/video/micro3d.cpp b/src/mame/video/micro3d.cpp
index 2c51c32f928..8b40a56571d 100644
--- a/src/mame/video/micro3d.cpp
+++ b/src/mame/video/micro3d.cpp
@@ -72,7 +72,7 @@ TMS340X0_SCANLINE_IND16_CB_MEMBER(micro3d_state::scanline_update)
UINT16 *frame_src;
- scanline = MAX((scanline - params->veblnk), 0);
+ scanline = std::max((scanline - params->veblnk), 0);
frame_src = m_frame_buffers[m_display_buffer].get() + (scanline << 10);
/* TODO: XFER3DK - X/Y offsets for 3D */
diff --git a/src/mame/video/midzeus.cpp b/src/mame/video/midzeus.cpp
index 7cf60e4f6a5..a521da29013 100644
--- a/src/mame/video/midzeus.cpp
+++ b/src/mame/video/midzeus.cpp
@@ -1216,8 +1216,8 @@ void midzeus_renderer::zeus_draw_quad(int long_fmt, const UINT32 *databuffer, UI
clipvert[i].x += 200.5f;
clipvert[i].y += 128.5f;
- maxx = MAX(maxx, clipvert[i].x);
- maxy = MAX(maxy, clipvert[i].y);
+ maxx = std::max(maxx, clipvert[i].x);
+ maxy = std::max(maxy, clipvert[i].y);
if (logit)
m_state.logerror("\t\t\tTranslated=(%f,%f,%f)\n", (double) clipvert[i].x, (double) clipvert[i].y, (double) clipvert[i].p[0]);
diff --git a/src/mame/video/midzeus2.cpp b/src/mame/video/midzeus2.cpp
index 7f196f35780..94b7b680773 100644
--- a/src/mame/video/midzeus2.cpp
+++ b/src/mame/video/midzeus2.cpp
@@ -1213,8 +1213,8 @@ In memory:
clipvert[i].y += 200.5f;
clipvert[i].p[0] *= 65536.0f * 16.0f;
- maxx = MAX(maxx, clipvert[i].x);
- maxy = MAX(maxy, clipvert[i].y);
+ maxx = std::max(maxx, clipvert[i].x);
+ maxy = std::max(maxy, clipvert[i].y);
if (logit)
m_state.logerror("\t\t\tTranslated=(%f,%f)\n", (double) clipvert[i].x, (double) clipvert[i].y);
}
diff --git a/src/mame/video/model1.cpp b/src/mame/video/model1.cpp
index b22d6f67410..2b7d2701f83 100644
--- a/src/mame/video/model1.cpp
+++ b/src/mame/video/model1.cpp
@@ -479,10 +479,10 @@ void model1_state::draw_quads(bitmap_rgb32 &bitmap, const rectangle &cliprect)
int save_x2 = view->x2;
int save_y1 = view->y1;
int save_y2 = view->y2;
- view->x1 = MAX(view->x1, cliprect.min_x);
- view->x2 = MIN(view->x2, cliprect.max_x);
- view->y1 = MAX(view->y1, cliprect.min_y);
- view->y2 = MIN(view->y2, cliprect.max_y);
+ view->x1 = std::max(view->x1, cliprect.min_x);
+ view->x2 = std::min(view->x2, cliprect.max_x);
+ view->y1 = std::max(view->y1, cliprect.min_y);
+ view->y2 = std::min(view->y2, cliprect.max_y);
for (int i = 0; i < count; i++)
{
@@ -943,8 +943,8 @@ void model1_state::push_object(UINT32 tex_adr, UINT32 poly_adr, UINT32 size) {
float dif = glm::dot(vn, m_view->light);
float spec = compute_specular(vn, m_view->light, dif, lightmode);
- float ln = m_view->lightparams[lightmode].a + m_view->lightparams[lightmode].d * MAX(0.0f, dif) + spec;
- int lumval = 255.0f * MIN(1.0f, ln);
+ float ln = m_view->lightparams[lightmode].a + m_view->lightparams[lightmode].d * std::max(0.0f, dif) + spec;
+ int lumval = 255.0f * std::min(1.0f, ln);
int color = m_paletteram16[0x1000 | (m_tgp_ram[tex_adr - 0x40000] & 0x3ff)];
int r = (color >> 0x0) & 0x1f;
int g = (color >> 0x5) & 0x1f;
diff --git a/src/mame/video/stic.cpp b/src/mame/video/stic.cpp
index 350544e8f90..b73881e4d3e 100644
--- a/src/mame/video/stic.cpp
+++ b/src/mame/video/stic.cpp
@@ -191,10 +191,10 @@ int stic_device::sprites_collide(int spriteNum1, int spriteNum2)
return FALSE;
// iterate over the intersecting bits to see if any touch
- x0 = MAX(x1, x2);
- y0 = MAX(y1, y2);
- w0 = MIN(x1 + w1, x2 + w2) - x0;
- h0 = MIN(y1 + h1, y2 + h2) - y0;
+ x0 = std::max(x1, x2);
+ y0 = std::max(y1, y2);
+ w0 = std::min(x1 + w1, x2 + w2) - x0;
+ h0 = std::min(y1 + h1, y2 + h2) - y0;
x1 = x0 - x1;
y1 = y0 - y1;
x2 = x0 - x2;
diff --git a/src/mame/video/tia.cpp b/src/mame/video/tia.cpp
index c616ce695b0..618b59fb2ef 100644
--- a/src/mame/video/tia.cpp
+++ b/src/mame/video/tia.cpp
@@ -1085,11 +1085,11 @@ WRITE8_MEMBER( tia_video_device::HMP0_w )
return;
/* Check if HMOVE cycles are still being applied */
- if ( HMOVE_started != HMOVE_INACTIVE && curr_x < MIN( HMOVE_started + 6 + motclkP0 * 4, 7 ) ) {
+ if ( HMOVE_started != HMOVE_INACTIVE && curr_x < std::min( HMOVE_started + 6 + motclkP0 * 4, 7 ) ) {
int new_motclkP0 = ( data ^ 0x80 ) >> 4;
/* Check if new horizontal move can still be applied normally */
- if ( new_motclkP0 > motclkP0 || curr_x <= MIN( HMOVE_started + 6 + new_motclkP0 * 4, 7 ) ) {
+ if ( new_motclkP0 > motclkP0 || curr_x <= std::min( HMOVE_started + 6 + new_motclkP0 * 4, 7 ) ) {
horzP0 -= ( new_motclkP0 - motclkP0 );
motclkP0 = new_motclkP0;
} else {
@@ -1117,11 +1117,11 @@ WRITE8_MEMBER( tia_video_device::HMP1_w )
return;
/* Check if HMOVE cycles are still being applied */
- if ( HMOVE_started != HMOVE_INACTIVE && curr_x < MIN( HMOVE_started + 6 + motclkP1 * 4, 7 ) ) {
+ if ( HMOVE_started != HMOVE_INACTIVE && curr_x < std::min( HMOVE_started + 6 + motclkP1 * 4, 7 ) ) {
int new_motclkP1 = ( data ^ 0x80 ) >> 4;
/* Check if new horizontal move can still be applied normally */
- if ( new_motclkP1 > motclkP1 || curr_x <= MIN( HMOVE_started + 6 + new_motclkP1 * 4, 7 ) ) {
+ if ( new_motclkP1 > motclkP1 || curr_x <= std::min( HMOVE_started + 6 + new_motclkP1 * 4, 7 ) ) {
horzP1 -= ( new_motclkP1 - motclkP1 );
motclkP1 = new_motclkP1;
} else {
@@ -1149,11 +1149,11 @@ WRITE8_MEMBER( tia_video_device::HMM0_w )
return;
/* Check if HMOVE cycles are still being applied */
- if ( HMOVE_started != HMOVE_INACTIVE && curr_x < MIN( HMOVE_started + 6 + motclkM0 * 4, 7 ) ) {
+ if ( HMOVE_started != HMOVE_INACTIVE && curr_x < std::min( HMOVE_started + 6 + motclkM0 * 4, 7 ) ) {
int new_motclkM0 = ( data ^ 0x80 ) >> 4;
/* Check if new horizontal move can still be applied normally */
- if ( new_motclkM0 > motclkM0 || curr_x <= MIN( HMOVE_started + 6 + new_motclkM0 * 4, 7 ) ) {
+ if ( new_motclkM0 > motclkM0 || curr_x <= std::min( HMOVE_started + 6 + new_motclkM0 * 4, 7 ) ) {
horzM0 -= ( new_motclkM0 - motclkM0 );
motclkM0 = new_motclkM0;
} else {
@@ -1180,11 +1180,11 @@ WRITE8_MEMBER( tia_video_device::HMM1_w )
return;
/* Check if HMOVE cycles are still being applied */
- if ( HMOVE_started != HMOVE_INACTIVE && curr_x < MIN( HMOVE_started + 6 + motclkM1 * 4, 7 ) ) {
+ if ( HMOVE_started != HMOVE_INACTIVE && curr_x < std::min( HMOVE_started + 6 + motclkM1 * 4, 7 ) ) {
int new_motclkM1 = ( data ^ 0x80 ) >> 4;
/* Check if new horizontal move can still be applied normally */
- if ( new_motclkM1 > motclkM1 || curr_x <= MIN( HMOVE_started + 6 + new_motclkM1 * 4, 7 ) ) {
+ if ( new_motclkM1 > motclkM1 || curr_x <= std::min( HMOVE_started + 6 + new_motclkM1 * 4, 7 ) ) {
horzM1 -= ( new_motclkM1 - motclkM1 );
motclkM1 = new_motclkM1;
} else {
@@ -1211,11 +1211,11 @@ WRITE8_MEMBER( tia_video_device::HMBL_w )
return;
/* Check if HMOVE cycles are still being applied */
- if ( HMOVE_started != HMOVE_INACTIVE && curr_x < MIN( HMOVE_started + 6 + motclkBL * 4, 7 ) ) {
+ if ( HMOVE_started != HMOVE_INACTIVE && curr_x < std::min( HMOVE_started + 6 + motclkBL * 4, 7 ) ) {
int new_motclkBL = ( data ^ 0x80 ) >> 4;
/* Check if new horizontal move can still be applied normally */
- if ( new_motclkBL > motclkBL || curr_x <= MIN( HMOVE_started + 6 + new_motclkBL * 4, 7 ) ) {
+ if ( new_motclkBL > motclkBL || curr_x <= std::min( HMOVE_started + 6 + new_motclkBL * 4, 7 ) ) {
horzBL -= ( new_motclkBL - motclkBL );
motclkBL = new_motclkBL;
} else {
@@ -1543,7 +1543,7 @@ WRITE8_MEMBER( tia_video_device::CXCLR_w )
#define RESXX_APPLY_ACTIVE_HMOVE(HORZ,MOTION,MOTCLK) \
- if ( curr_x < MIN( HMOVE_started + 6 + 16 * 4, 7 ) ) { \
+ if ( curr_x < std::min( HMOVE_started + 6 + 16 * 4, 7 ) ) { \
int decrements_passed = ( curr_x - ( HMOVE_started + 4 ) ) / 4; \
HORZ += 8; \
if ( ( MOTCLK - decrements_passed ) > 0 ) { \
diff --git a/src/osd/modules/debugger/debugwin.cpp b/src/osd/modules/debugger/debugwin.cpp
index 973aec1f570..c66a54e6d30 100644
--- a/src/osd/modules/debugger/debugwin.cpp
+++ b/src/osd/modules/debugger/debugwin.cpp
@@ -20,6 +20,8 @@
#include "win/memorywininfo.h"
#include "win/pointswininfo.h"
#include "win/uimetrics.h"
+#undef min
+#undef max
#include "emu.h"
#include "debugger.h"
diff --git a/src/osd/modules/debugger/osx/debugconsole.mm b/src/osd/modules/debugger/osx/debugconsole.mm
index 35eb2d57c68..1d4155b6678 100644
--- a/src/osd/modules/debugger/osx/debugconsole.mm
+++ b/src/osd/modules/debugger/osx/debugconsole.mm
@@ -156,19 +156,19 @@
consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height;
adjustment.width = regSize.width - regCurrent.width;
adjustment.height = regSize.height - regCurrent.height;
- adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width);
+ adjustment.width += std::max(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width);
windowFrame.size.width += adjustment.width;
windowFrame.size.height += adjustment.height; // not used - better to go for fixed height
- windowFrame.size.height = MIN(512.0, available.size.height);
- windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
+ windowFrame.size.height = std::min(512.0, available.size.height);
+ windowFrame.size.width = std::min(windowFrame.size.width, available.size.width);
windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
windowFrame.origin.y = available.origin.y;
[window setFrame:windowFrame display:YES];
NSRect lhsFrame = [regScroll frame];
NSRect rhsFrame = [dasmSplit frame];
- adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2);
+ adjustment.width = std::min(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2);
rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width;
rhsFrame.size.width += lhsFrame.size.width - adjustment.width;
lhsFrame.size.width = adjustment.width;
diff --git a/src/osd/modules/debugger/osx/debugview.mm b/src/osd/modules/debugger/osx/debugview.mm
index 8f0c404cf93..409bbeadceb 100644
--- a/src/osd/modules/debugger/osx/debugview.mm
+++ b/src/osd/modules/debugger/osx/debugview.mm
@@ -172,7 +172,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
// this gets all the lines that are at least partially visible
debug_view_xy origin(0, 0), size(totalWidth, totalHeight);
[self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y];
- size.y = MIN(size.y, totalHeight - origin.y);
+ size.y = std::min(size.y, totalHeight - origin.y);
// tell the underlying view how much real estate is available
view->set_visible_size(size);
@@ -205,8 +205,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
fontHeight * totalHeight);
if (wholeLineScroll)
content.height += (fontHeight * 2) - 1;
- [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)),
- ceil(MAX(clip.height, content.height)))];
+ [self setFrameSize:NSMakeSize(ceil(std::max(clip.width, content.width)),
+ ceil(std::max(clip.height, content.height)))];
[self recomputeVisible];
}
@@ -282,8 +282,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
fontHeight * newSize.y);
if (wholeLineScroll)
content.height += (fontHeight * 2) - 1;
- [self setFrameSize:NSMakeSize(ceil(MAX(clip.width, content.width)),
- ceil(MAX(clip.height, content.height)))];
+ [self setFrameSize:NSMakeSize(ceil(std::max(clip.width, content.width)),
+ ceil(std::max(clip.height, content.height)))];
}
totalWidth = newSize.x;
totalHeight = newSize.y;
@@ -583,7 +583,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
if (wholeLineScroll)
{
CGFloat const clamp = [self bounds].size.height - fontHeight - proposedVisibleRect.size.height;
- proposedVisibleRect.origin.y = MIN(proposedVisibleRect.origin.y, MAX(clamp, 0));
+ proposedVisibleRect.origin.y = std::min(proposedVisibleRect.origin.y, std::max(clamp, 0));
proposedVisibleRect.origin.y -= fmod(proposedVisibleRect.origin.y, fontHeight);
}
return proposedVisibleRect;
@@ -600,8 +600,8 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
INT32 row, clip;
[self convertBounds:dirtyRect toFirstAffectedLine:&row count:&clip];
clip += row;
- row = MAX(row, origin.y);
- clip = MIN(clip, origin.y + size.y);
+ row = std::max(row, origin.y);
+ clip = std::min(clip, origin.y + size.y);
// this gets the text for the whole visible area
debug_view_char const *data = view->viewdata();
@@ -668,7 +668,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate)
inTextContainer:textContainer];
if (start == 0)
box.origin.x = 0;
- box.size.width = MAX([self bounds].size.width - box.origin.x, 0);
+ box.size.width = std::max([self bounds].size.width - box.origin.x, 0);
[[self backgroundForAttribute:attr] set];
[NSBezierPath fillRect:NSMakeRect(box.origin.x,
row * fontHeight,
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm
index ceb41e1de79..a4cd46df631 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.mm
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm
@@ -341,16 +341,16 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
// limit the size to the minimum size
NSSize const minimum = [window minSize];
- windowFrame.size.width = MAX(windowFrame.size.width, minimum.width);
- windowFrame.size.height = MAX(windowFrame.size.height, minimum.height);
+ windowFrame.size.width = std::max(windowFrame.size.width, minimum.width);
+ windowFrame.size.height = std::max(windowFrame.size.height, minimum.height);
// limit the size to the main screen size
NSRect const available = [[NSScreen mainScreen] visibleFrame];
- windowFrame.size.width = MIN(windowFrame.size.width, available.size.width);
- windowFrame.size.height = MIN(windowFrame.size.height, available.size.height);
+ windowFrame.size.width = std::min(windowFrame.size.width, available.size.width);
+ windowFrame.size.height = std::min(windowFrame.size.height, available.size.height);
// arbitrary additional height limit
- windowFrame.size.height = MIN(windowFrame.size.height, 320);
+ windowFrame.size.height = std::min(windowFrame.size.height, 320);
// place it in the bottom right corner and apply
windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width;
diff --git a/src/osd/modules/debugger/osx/deviceinfoviewer.mm b/src/osd/modules/debugger/osx/deviceinfoviewer.mm
index bbc2ac7d0f5..29b4186ccf9 100644
--- a/src/osd/modules/debugger/osx/deviceinfoviewer.mm
+++ b/src/osd/modules/debugger/osx/deviceinfoviewer.mm
@@ -40,7 +40,7 @@
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize {
NSSize const newBoundsSize = [[self superview] bounds].size;
- [self setFrameSize:NSMakeSize(MAX(newBoundsSize.width, minWidth), [self frame].size.height)];
+ [self setFrameSize:NSMakeSize(std::max(newBoundsSize.width, minWidth), [self frame].size.height)];
}
@end
@@ -97,9 +97,9 @@
- (void)addLabel:(NSString *)l withWidth:(CGFloat)w andField:(NSString *)f toView:(NSView *)v {
NSTextField *const label = [self makeLabel:l];
NSTextField *const field = [self makeField:f];
- CGFloat const height = MAX([label frame].size.height, [field frame].size.height);
+ CGFloat const height = std::max([label frame].size.height, [field frame].size.height);
NSSize space = [v bounds].size;
- space.width = MAX(space.width, [field frame].size.width + w + 52);
+ space.width = std::max(space.width, [field frame].size.width + w + 52);
space.height += height + 8;
[label setFrame:NSMakeRect(25, space.height - height - 20, w, height)];
[field setFrame:NSMakeRect(w + 27, space.height - height - 20, space.width - w - 52, height)];
@@ -115,7 +115,7 @@
NSTextField *const field = [self makeField:f];
[field setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
NSSize space = [b frame].size;
- space.width = MAX(space.width, [field frame].size.width + 32);
+ space.width = std::max(space.width, [field frame].size.width + 32);
space.height += [field frame].size.height + 8;
[field setFrame:NSMakeRect(15, 14, space.width - 32, [field frame].size.height)];
[b setFrameSize:space];
@@ -126,7 +126,7 @@
- (void)addBox:(NSBox *)b toView:(NSView *)v {
NSSize space = [v frame].size;
- space.width = MAX(space.width, [b frame].size.width + 34);
+ space.width = std::max(space.width, [b frame].size.width + 34);
space.height += [b frame].size.height + 4;
[b setFrameOrigin:NSMakePoint(17, space.height - [b frame].size.height - 16)];
[v setFrameSize:space];
diff --git a/src/osd/modules/debugger/osx/disassemblyview.mm b/src/osd/modules/debugger/osx/disassemblyview.mm
index 212f8194cd6..4e99e38ddce 100644
--- a/src/osd/modules/debugger/osx/disassemblyview.mm
+++ b/src/osd/modules/debugger/osx/disassemblyview.mm
@@ -47,8 +47,8 @@
{
view->set_source(*source);
debug_view_xy const current = view->total_size();
- max.x = MAX(max.x, current.x);
- max.y = MAX(max.y, current.y);
+ max.x = std::max(max.x, current.x);
+ max.y = std::max(max.y, current.y);
}
view->set_source(*source);
return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])),
diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.mm b/src/osd/modules/debugger/osx/disassemblyviewer.mm
index f57d62cfaf4..50fe4eae2ef 100644
--- a/src/osd/modules/debugger/osx/disassemblyviewer.mm
+++ b/src/osd/modules/debugger/osx/disassemblyviewer.mm
@@ -55,7 +55,7 @@
// adjust sizes to make it fit nicely
expressionFrame = [expressionField frame];
- expressionFrame.size.height = MAX(expressionFrame.size.height, [subviewButton frame].size.height);
+ expressionFrame.size.height = std::max(expressionFrame.size.height, [subviewButton frame].size.height);
expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2;
[expressionField setFrame:expressionFrame];
expressionFrame.origin.x = expressionFrame.size.width;
diff --git a/src/osd/modules/debugger/osx/errorlogviewer.mm b/src/osd/modules/debugger/osx/errorlogviewer.mm
index 0548ff9351f..087694ca81b 100644
--- a/src/osd/modules/debugger/osx/errorlogviewer.mm
+++ b/src/osd/modules/debugger/osx/errorlogviewer.mm
@@ -44,7 +44,7 @@
borderType:[logScroll borderType]];
// this thing starts with no content, so its prefered height may be very small
- desired.height = MAX(desired.height, 240);
+ desired.height = std::max(desired.height, 240);
[self cascadeWindowWithDesiredSize:desired forView:logScroll];
}
diff --git a/src/osd/modules/debugger/osx/memoryview.mm b/src/osd/modules/debugger/osx/memoryview.mm
index aac06f3e63a..5a843c6e38f 100644
--- a/src/osd/modules/debugger/osx/memoryview.mm
+++ b/src/osd/modules/debugger/osx/memoryview.mm
@@ -69,8 +69,8 @@
{
view->set_source(*source);
debug_view_xy const current = view->total_size();
- max.x = MAX(max.x, current.x);
- max.y = MAX(max.y, current.y);
+ max.x = std::max(max.x, current.x);
+ max.y = std::max(max.y, current.y);
}
view->set_source(*source);
return NSMakeSize(ceil((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding])),
diff --git a/src/osd/modules/debugger/osx/memoryviewer.mm b/src/osd/modules/debugger/osx/memoryviewer.mm
index 9b027e11368..bd7d1941067 100644
--- a/src/osd/modules/debugger/osx/memoryviewer.mm
+++ b/src/osd/modules/debugger/osx/memoryviewer.mm
@@ -53,7 +53,7 @@
// adjust sizes to make it fit nicely
expressionFrame = [expressionField frame];
- expressionFrame.size.height = MAX(expressionFrame.size.height, [subviewButton frame].size.height);
+ expressionFrame.size.height = std::max(expressionFrame.size.height, [subviewButton frame].size.height);
expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2;
[expressionField setFrame:expressionFrame];
expressionFrame.origin.x = expressionFrame.size.width;
diff --git a/src/osd/modules/debugger/osx/pointsviewer.mm b/src/osd/modules/debugger/osx/pointsviewer.mm
index c9301eb2894..d99f072a95c 100644
--- a/src/osd/modules/debugger/osx/pointsviewer.mm
+++ b/src/osd/modules/debugger/osx/pointsviewer.mm
@@ -119,8 +119,8 @@
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[watchScroll borderType]];
- NSSize const desired = NSMakeSize(MAX(breakDesired.width, watchDesired.width),
- MAX(breakDesired.height, watchDesired.height));
+ NSSize const desired = NSMakeSize(std::max(breakDesired.width, watchDesired.width),
+ std::max(breakDesired.height, watchDesired.height));
[self cascadeWindowWithDesiredSize:desired forView:tabs];
// don't forget the result
diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp
index f1d66abee42..3b5c9d88cb3 100644
--- a/src/osd/modules/debugger/qt/debuggerview.cpp
+++ b/src/osd/modules/debugger/qt/debuggerview.cpp
@@ -49,7 +49,7 @@ void DebuggerView::paintEvent(QPaintEvent* event)
// Tell the MAME debug view how much real estate is available
QFontMetrics actualFont = fontMetrics();
const double fontWidth = actualFont.width(QString(100, '_')) / 100.;
- const int fontHeight = MAX(1, actualFont.lineSpacing());
+ const int fontHeight = std::max(1, actualFont.lineSpacing());
m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight));
@@ -240,7 +240,7 @@ void DebuggerView::mousePressEvent(QMouseEvent* event)
{
QFontMetrics actualFont = fontMetrics();
const double fontWidth = actualFont.width(QString(100, '_')) / 100.;
- const int fontHeight = MAX(1, actualFont.height());
+ const int fontHeight = std::max(1, actualFont.height());
debug_view_xy topLeft = m_view->visible_position();
debug_view_xy clickViewPosition;
diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp
index 8709c8d5aa2..7b55db34a20 100644
--- a/src/osd/modules/debugger/qt/memorywindow.cpp
+++ b/src/osd/modules/debugger/qt/memorywindow.cpp
@@ -328,7 +328,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event)
{
QFontMetrics actualFont = fontMetrics();
const double fontWidth = actualFont.width(QString(100, '_')) / 100.;
- const int fontHeight = MAX(1, actualFont.height());
+ const int fontHeight = std::max(1, actualFont.height());
debug_view_xy topLeft = view()->visible_position();
debug_view_xy clickViewPosition;
diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp
index 735f59a2fbb..6c4e5b0a2e1 100644
--- a/src/osd/modules/debugger/win/consolewininfo.cpp
+++ b/src/osd/modules/debugger/win/consolewininfo.cpp
@@ -60,13 +60,13 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
set_minwidth(bounds.right - bounds.left);
bounds.top = bounds.left = 0;
- bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + MAX(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH;
+ bounds.right = bounds.bottom = EDGE_WIDTH + m_views[1]->maxwidth() + (2 * EDGE_WIDTH) + std::max(m_views[0]->maxwidth(), m_views[2]->maxwidth()) + EDGE_WIDTH;
AdjustWindowRectEx(&bounds, DEBUG_WINDOW_STYLE, FALSE, DEBUG_WINDOW_STYLE_EX);
set_maxwidth(bounds.right - bounds.left);
// position the window at the bottom-right
- int const bestwidth = MIN(maxwidth(), work_bounds.right - work_bounds.left);
- int const bestheight = MIN(500, work_bounds.bottom - work_bounds.top);
+ int const bestwidth = std::min(int(maxwidth()), int(work_bounds.right - work_bounds.left));
+ int const bestheight = std::min(500, int(work_bounds.bottom - work_bounds.top));
SetWindowPos(window(), HWND_TOP,
work_bounds.right - bestwidth, work_bounds.bottom - bestheight,
bestwidth, bestheight,
diff --git a/src/osd/modules/debugger/win/debugviewinfo.cpp b/src/osd/modules/debugger/win/debugviewinfo.cpp
index 2104e09246e..d23a666adf8 100644
--- a/src/osd/modules/debugger/win/debugviewinfo.cpp
+++ b/src/osd/modules/debugger/win/debugviewinfo.cpp
@@ -475,9 +475,9 @@ void debugview_info::update()
// if we hid the scrollbars, make sure we reset the top/left corners
if (topleft.y + visiblesize.y > totalsize.y)
- topleft.y = MAX(totalsize.y - visiblesize.y, 0);
+ topleft.y = std::max(totalsize.y - visiblesize.y, 0);
if (topleft.x + visiblesize.x > totalsize.x)
- topleft.x = MAX(totalsize.x - visiblesize.x, 0);
+ topleft.x = std::max(totalsize.x - visiblesize.x, 0);
// fill out the scroll info struct for the vertical scrollbar
scrollinfo.cbSize = sizeof(scrollinfo);
diff --git a/src/osd/modules/debugger/win/debugwin.h b/src/osd/modules/debugger/win/debugwin.h
index bedf2b36d43..0e3bcd25131 100644
--- a/src/osd/modules/debugger/win/debugwin.h
+++ b/src/osd/modules/debugger/win/debugwin.h
@@ -18,6 +18,8 @@
#ifdef _MSC_VER
#include <zmouse.h>
#endif
+#undef min
+#undef max
#include "emu.h"
diff --git a/src/osd/modules/diagnostics/diagnostics_win32.cpp b/src/osd/modules/diagnostics/diagnostics_win32.cpp
index b3e9d8320e0..8179e333187 100644
--- a/src/osd/modules/diagnostics/diagnostics_win32.cpp
+++ b/src/osd/modules/diagnostics/diagnostics_win32.cpp
@@ -22,6 +22,9 @@
#include <memory>
#include <vector>
+#undef min
+#undef max
+#include <algorithm>
#include "modules/lib/osdlib.h"
@@ -709,7 +712,7 @@ int CLIB_DECL sampling_profiler::compare_address(const void *item1, const void *
{
const FPTR *entry1 = reinterpret_cast<const FPTR *>(item1);
const FPTR *entry2 = reinterpret_cast<const FPTR *>(item2);
- int mincount = MIN(entry1[0], entry2[0]);
+ int mincount = std::min(entry1[0], entry2[0]);
// sort in order of: bucket, caller, caller's caller, etc.
for (int index = 1; index <= mincount; index++)
diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h
index eedfd1450c3..741376ecb81 100644
--- a/src/osd/modules/input/input_common.h
+++ b/src/osd/modules/input/input_common.h
@@ -18,6 +18,9 @@
#include <mutex>
#include <queue>
#include <string>
+#undef min
+#undef max
+#include <algorithm>
//============================================================
@@ -614,14 +617,14 @@ inline static INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawma
if (raw >= center)
{
INT32 result = (INT64)(raw - center) * (INT64)INPUT_ABSOLUTE_MAX / (INT64)(rawmax - center);
- return MIN(result, INPUT_ABSOLUTE_MAX);
+ return std::min(result, INPUT_ABSOLUTE_MAX);
}
// below center
else
{
INT32 result = -((INT64)(center - raw) * (INT64)-INPUT_ABSOLUTE_MIN / (INT64)(center - rawmin));
- return MAX(result, INPUT_ABSOLUTE_MIN);
+ return std::max(result, INPUT_ABSOLUTE_MIN);
}
}
diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp
index 0db6695565d..0ef0fc2d095 100644
--- a/src/osd/modules/input/input_dinput.cpp
+++ b/src/osd/modules/input/input_dinput.cpp
@@ -22,7 +22,10 @@
#undef WINNT
#include <dinput.h>
#undef interface
+#undef min
+#undef max
+#include <algorithm>
#include <mutex>
#include <thread>
@@ -387,8 +390,8 @@ public:
}
// cap the number of axes and buttons based on the format
- devinfo->dinput.caps.dwAxes = MIN(devinfo->dinput.caps.dwAxes, 3);
- devinfo->dinput.caps.dwButtons = MIN(devinfo->dinput.caps.dwButtons, (devinfo->dinput.format == &c_dfDIMouse) ? 4 : 8);
+ devinfo->dinput.caps.dwAxes = std::min(devinfo->dinput.caps.dwAxes, DWORD(3));
+ devinfo->dinput.caps.dwButtons = std::min(devinfo->dinput.caps.dwButtons, DWORD((devinfo->dinput.format == &c_dfDIMouse) ? 4 : 8));
// populate the axes
for (axisnum = 0; axisnum < devinfo->dinput.caps.dwAxes; axisnum++)
@@ -479,9 +482,9 @@ int dinput_joystick_device::configure()
osd_printf_warning("DirectInput: Unable to reset saturation for joystick %d (%s)\n", devindex, name());
// cap the number of axes, POVs, and buttons based on the format
- dinput.caps.dwAxes = MIN(dinput.caps.dwAxes, 8);
- dinput.caps.dwPOVs = MIN(dinput.caps.dwPOVs, 4);
- dinput.caps.dwButtons = MIN(dinput.caps.dwButtons, 128);
+ dinput.caps.dwAxes = std::min(dinput.caps.dwAxes, DWORD(8));
+ dinput.caps.dwPOVs = std::min(dinput.caps.dwPOVs, DWORD(4));
+ dinput.caps.dwButtons = std::min(dinput.caps.dwButtons, DWORD(128));
// populate the axes
for (axisnum = axiscount = 0; axiscount < dinput.caps.dwAxes && axisnum < 8; axisnum++)
diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp
index 3c617ef191a..739ae4496f3 100644
--- a/src/osd/modules/input/input_rawinput.cpp
+++ b/src/osd/modules/input/input_rawinput.cpp
@@ -16,6 +16,8 @@
#include <windows.h>
#include <tchar.h>
#undef interface
+#undef min
+#undef max
#include <mutex>
#include <functional>
diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp
index 24234969eef..dc9b95b3f28 100644
--- a/src/osd/modules/input/input_win32.cpp
+++ b/src/osd/modules/input/input_win32.cpp
@@ -15,6 +15,8 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef interface
+#undef min
+#undef max
// MAME headers
#include "emu.h"
diff --git a/src/osd/modules/input/input_winhybrid.cpp b/src/osd/modules/input/input_winhybrid.cpp
index a7453d59cf8..80a1280c511 100644
--- a/src/osd/modules/input/input_winhybrid.cpp
+++ b/src/osd/modules/input/input_winhybrid.cpp
@@ -25,6 +25,8 @@
#include <dinput.h>
#undef interface
+#undef min
+#undef max
// MAME headers
#include "emu.h"
diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp
index 0b2427b7f1c..e64b166c287 100644
--- a/src/osd/modules/input/input_xinput.cpp
+++ b/src/osd/modules/input/input_xinput.cpp
@@ -19,6 +19,8 @@
#include <xinput.h>
#undef interface
+#undef min
+#undef max
// MAME headers
#include "emu.h"
diff --git a/src/osd/modules/osdwindow.h b/src/osd/modules/osdwindow.h
index 7abc76469ed..3fa62babfbf 100644
--- a/src/osd/modules/osdwindow.h
+++ b/src/osd/modules/osdwindow.h
@@ -21,6 +21,8 @@
#include <windowsx.h>
#include <mmsystem.h>
#endif
+#undef min
+#undef max
#ifdef OSD_SDL
// forward declaration
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index 2116322f19a..444d3c05348 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -20,7 +20,8 @@
#include <bx/readerwriter.h>
#include <bx/crtimpl.h>
-
+#undef min
+#undef max
#include "bgfxutil.h"
#include "chainmanager.h"
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index 241f4b2a7f6..560bffa1379 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -25,7 +25,9 @@
#include "strconv.h"
#include "d3dhlsl.h"
#include "../frontend/mame/ui/slider.h"
-
+#undef min
+#undef max
+#include <algorithm>
//============================================================
// PROTOTYPES
@@ -1047,9 +1049,9 @@ rgb_t shaders::apply_color_convolution(rgb_t color)
b = chroma[2] * saturation + luma;
return rgb_t(
- MAX(0, MIN(255, static_cast<int>(r * 255.0f))),
- MAX(0, MIN(255, static_cast<int>(g * 255.0f))),
- MAX(0, MIN(255, static_cast<int>(b * 255.0f))));
+ std::max(0, std::min(255, static_cast<int>(r * 255.0f))),
+ std::max(0, std::min(255, static_cast<int>(g * 255.0f))),
+ std::max(0, std::min(255, static_cast<int>(b * 255.0f))));
}
int shaders::color_convolution_pass(d3d_render_target *rt, int source_index, poly_info *poly, int vertnum)
diff --git a/src/osd/modules/render/draw13.cpp b/src/osd/modules/render/draw13.cpp
index 24bf22c3b27..50faacb1ca7 100644
--- a/src/osd/modules/render/draw13.cpp
+++ b/src/osd/modules/render/draw13.cpp
@@ -282,7 +282,7 @@ void renderer_sdl2::render_quad(texture_info *texture, const render_primitive &p
texture->render_quad(prim, x, y);
copyinfo->time += osd_ticks();
- copyinfo->pixel_count += MAX(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height()));
+ copyinfo->pixel_count += std::max(STAT_PIXEL_THRESHOLD , (texture->raw_width() * texture->raw_height()));
if (m_last_blit_pixels)
{
copyinfo->time += (m_last_blit_time * (INT64) (texture->raw_width() * texture->raw_height())) / (INT64) m_last_blit_pixels;
diff --git a/src/osd/modules/render/drawd3d.cpp b/src/osd/modules/render/drawd3d.cpp
index 102abf35413..7668cb6660f 100644
--- a/src/osd/modules/render/drawd3d.cpp
+++ b/src/osd/modules/render/drawd3d.cpp
@@ -19,7 +19,9 @@
#include "window.h"
#include "drawd3d.h"
#include "modules/render/d3d/d3dhlsl.h"
-
+#undef min
+#undef max
+#include <algorithm>
//============================================================
// TYPE DEFINITIONS
@@ -1993,7 +1995,7 @@ texture_info::texture_info(d3d_texture_manager *manager, const render_texinfo* t
D3DFORMAT format;
DWORD usage = m_texture_manager->is_dynamic_supported() ? D3DUSAGE_DYNAMIC : 0;
D3DPOOL pool = m_texture_manager->is_dynamic_supported() ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
- int maxdim = MAX(m_renderer->get_presentation()->BackBufferWidth, m_renderer->get_presentation()->BackBufferHeight);
+ int maxdim = std::max(m_renderer->get_presentation()->BackBufferWidth, m_renderer->get_presentation()->BackBufferHeight);
// pick the format
if (PRIMFLAG_GET_TEXFORMAT(flags) == TEXFORMAT_YUY16)
diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp
index 88ce712a396..1f03939de45 100644
--- a/src/osd/modules/sound/coreaudio_sound.cpp
+++ b/src/osd/modules/sound/coreaudio_sound.cpp
@@ -81,7 +81,7 @@ private:
EFFECT_COUNT_MAX = 10
};
- UINT32 clamped_latency() const { return MAX(MIN(m_audio_latency, LATENCY_MAX), LATENCY_MIN); }
+ UINT32 clamped_latency() const { return std::max(std::min(m_audio_latency, LATENCY_MAX), LATENCY_MIN); }
UINT32 buffer_avail() const { return ((m_writepos >= m_playpos) ? m_buffer_size : 0) + m_playpos - m_writepos; }
UINT32 buffer_used() const { return ((m_playpos > m_writepos) ? m_buffer_size : 0) + m_writepos - m_playpos; }
@@ -228,7 +228,7 @@ int sound_coreaudio::init(const osd_options &options)
// Allocate buffer
m_headroom = m_sample_bytes * (clamped_latency() * sample_rate() / 40);
- m_buffer_size = m_sample_bytes * MAX(sample_rate() * (clamped_latency() + 3) / 40, 256);
+ m_buffer_size = m_sample_bytes * std::max(sample_rate() * (clamped_latency() + 3) / 40, 256);
m_buffer = global_alloc_array_clear<INT8>(m_buffer_size);
if (!m_buffer)
{
@@ -306,7 +306,7 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, INT16 const *buffer
return;
}
- UINT32 const chunk = MIN(m_buffer_size - m_writepos, bytes_this_frame);
+ UINT32 const chunk = std::min(m_buffer_size - m_writepos, bytes_this_frame);
memcpy(m_buffer + m_writepos, (INT8 *)buffer, chunk);
m_writepos += chunk;
if (m_writepos >= m_buffer_size)
@@ -324,7 +324,7 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, INT16 const *buffer
void sound_coreaudio::set_mastervolume(int attenuation)
{
- int const clamped_attenuation = MAX(MIN(attenuation, 0), -32);
+ int const clamped_attenuation = std::max(std::min(attenuation, 0), -32);
m_scale = (-32 == clamped_attenuation) ? 0 : (INT32)(pow(10.0, clamped_attenuation / 20.0) * 128);
}
@@ -996,7 +996,7 @@ OSStatus sound_coreaudio::render(
return noErr;
}
- UINT32 const chunk = MIN(m_buffer_size - m_playpos, number_bytes);
+ UINT32 const chunk = std::min(m_buffer_size - m_playpos, number_bytes);
copy_scaled((INT8 *)data->mBuffers[0].mData, m_buffer + m_playpos, chunk);
m_playpos += chunk;
if (m_playpos >= m_buffer_size)
diff --git a/src/osd/modules/sound/direct_sound.cpp b/src/osd/modules/sound/direct_sound.cpp
index 04d29866876..b677889de6b 100644
--- a/src/osd/modules/sound/direct_sound.cpp
+++ b/src/osd/modules/sound/direct_sound.cpp
@@ -20,6 +20,8 @@
#undef WINNT
#include <dsound.h>
#undef interface
+#undef min
+#undef max
// MAME headers
#include "emu.h"
@@ -34,6 +36,7 @@
#include "winmain.h"
#include "window.h"
#endif
+#include <algorithm>
//============================================================
// DEBUGGING
@@ -163,7 +166,7 @@ private:
assert(m_bytes1);
assert((m_locked1 + m_locked2) >= bytes);
- memcpy(m_bytes1, data, MIN(m_locked1, bytes));
+ memcpy(m_bytes1, data, std::min(m_locked1, bytes));
if (m_locked1 < bytes)
{
assert(m_bytes2);
@@ -359,7 +362,7 @@ void sound_direct_sound::update_audio_stream(
void sound_direct_sound::set_mastervolume(int attenuation)
{
// clamp the attenuation to 0-32 range
- attenuation = MAX(MIN(attenuation, 0), -32);
+ attenuation = std::max(std::min(attenuation, 0), -32);
// set the master volume
if (m_stream_buffer)
@@ -429,7 +432,7 @@ HRESULT sound_direct_sound::dsound_init()
// compute the buffer size based on the output sample rate
DWORD stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * m_audio_latency / 10;
- stream_buffer_size = MAX(1024, (stream_buffer_size / 1024) * 1024);
+ stream_buffer_size = std::max(DWORD(1024), (stream_buffer_size / 1024) * 1024);
LOG(("stream_buffer_size = %u\n", (unsigned)stream_buffer_size));
diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp
index efab053ef6e..6bd73917c66 100644
--- a/src/osd/modules/sound/sdl_sound.cpp
+++ b/src/osd/modules/sound/sdl_sound.cpp
@@ -331,7 +331,7 @@ void sound_sdl::update_audio_stream(bool is_throttled, const INT16 *buffer, int
void sound_sdl::set_mastervolume(int _attenuation)
{
// clamp the attenuation to 0-32 range
- attenuation = MAX(MIN(_attenuation, 0), -32);
+ attenuation = std::max(std::min(_attenuation, 0), -32);
if (stream_in_initialized)
{
@@ -445,7 +445,7 @@ int sound_sdl::init(const osd_options &options)
sdl_xfer_samples = obtained.samples;
// pin audio latency
- audio_latency = MAX(MIN(m_audio_latency, MAX_AUDIO_LATENCY), 1);
+ audio_latency = std::max(std::min(m_audio_latency, MAX_AUDIO_LATENCY), 1);
// compute the buffer sizes
stream_buffer_size = (sample_rate() * 2 * sizeof(INT16) * (2 + audio_latency)) / 30;
diff --git a/src/osd/modules/sound/xaudio2_sound.cpp b/src/osd/modules/sound/xaudio2_sound.cpp
index bb45626a6c6..c4923a9571c 100644
--- a/src/osd/modules/sound/xaudio2_sound.cpp
+++ b/src/osd/modules/sound/xaudio2_sound.cpp
@@ -20,13 +20,16 @@
// XAudio2 include
#include <xaudio2.h>
+#undef interface
+#undef min
+#undef max
+
// stdlib includes
#include <mutex>
#include <thread>
#include <queue>
#include <chrono>
-
-#undef interface
+#include <algorithm>
// MAME headers
#include "emu.h"
@@ -397,7 +400,7 @@ void sound_xaudio2::update_audio_stream(
while (bytes_left > 0)
{
- UINT32 chunk = MIN(m_buffer_size, bytes_left);
+ UINT32 chunk = std::min(UINT32(m_buffer_size), bytes_left);
// Roll the buffer if needed
if (m_writepos + chunk >= m_buffer_size)
@@ -429,7 +432,7 @@ void sound_xaudio2::set_mastervolume(int attenuation)
HRESULT result;
// clamp the attenuation to 0-32 range
- attenuation = MAX(MIN(attenuation, 0), -32);
+ attenuation = std::max(std::min(attenuation, 0), -32);
// Ranges from 1.0 to XAUDIO2_MAX_VOLUME_LEVEL indicate additional gain
// Ranges from 0 to 1.0 indicate a reduced volume level
@@ -498,7 +501,7 @@ void sound_xaudio2::create_buffers(const WAVEFORMATEX &format)
m_buffer_count = (audio_latency_in_seconds * 1000.0f) / SUBMIT_FREQUENCY_TARGET_MS;
// Now record the size of the individual buffers
- m_buffer_size = MAX(1024, total_buffer_size / m_buffer_count);
+ m_buffer_size = std::max(DWORD(1024), total_buffer_size / m_buffer_count);
// Make the buffer a multiple of the format size bytes (rounding up)
UINT32 remainder = m_buffer_size % format.nBlockAlign;
diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h
index c6c15d0df2a..b102ba3deaa 100644
--- a/src/osd/osdcomm.h
+++ b/src/osd/osdcomm.h
@@ -111,15 +111,6 @@ using unicode_char = std::uint32_t;
FUNDAMENTAL MACROS
***************************************************************************/
-/* Standard MIN/MAX macros */
-#ifndef MIN
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-#endif
-#ifndef MAX
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#endif
-
-
/* U64 and S64 are used to wrap long integer constants. */
#if defined(__GNUC__) || defined(_MSC_VER)
#define U64(val) val##ULL
@@ -131,9 +122,20 @@ using unicode_char = std::uint32_t;
/* Concatenate/extract 32-bit halves of 64-bit values */
-#define CONCAT_64(hi,lo) (((UINT64)(hi) << 32) | (UINT32)(lo))
-#define EXTRACT_64HI(val) ((UINT32)((val) >> 32))
-#define EXTRACT_64LO(val) ((UINT32)(val))
+inline UINT64 concat_64(UINT32 hi, UINT32 lo)
+{
+ return (UINT64(hi) << 32) | UINT32(lo);
+}
+
+inline UINT32 extract_64hi(UINT64 val)
+{
+ return UINT32(val >> 32);
+}
+
+inline UINT32 extract_64lo(UINT64 val)
+{
+ return UINT32(val);
+}
// Highly useful template for compile-time knowledge of an array size
template <typename T, size_t N> constexpr inline size_t ARRAY_LENGTH(T (&)[N]) { return N;}
@@ -147,27 +149,29 @@ template <typename T, typename U, std::size_t N> struct equivalent_array<T, U[N]
template <typename T, typename U> using equivalent_array_t = typename equivalent_array<T, U>::type;
#define EQUIVALENT_ARRAY(a, T) equivalent_array_t<T, std::remove_reference_t<decltype(a)> >
-
/* Macros for normalizing data into big or little endian formats */
-#define FLIPENDIAN_INT16(x) (((((UINT16) (x)) >> 8) | ((x) << 8)) & 0xffff)
-#define FLIPENDIAN_INT32(x) ((((UINT32) (x)) << 24) | (((UINT32) (x)) >> 24) | \
- (( ((UINT32) (x)) & 0x0000ff00) << 8) | (( ((UINT32) (x)) & 0x00ff0000) >> 8))
-#define FLIPENDIAN_INT64(x) \
- ( \
- (((((UINT64) (x)) >> 56) & ((UINT64) 0xFF)) << 0) | \
- (((((UINT64) (x)) >> 48) & ((UINT64) 0xFF)) << 8) | \
- (((((UINT64) (x)) >> 40) & ((UINT64) 0xFF)) << 16) | \
- (((((UINT64) (x)) >> 32) & ((UINT64) 0xFF)) << 24) | \
- (((((UINT64) (x)) >> 24) & ((UINT64) 0xFF)) << 32) | \
- (((((UINT64) (x)) >> 16) & ((UINT64) 0xFF)) << 40) | \
- (((((UINT64) (x)) >> 8) & ((UINT64) 0xFF)) << 48) | \
- (((((UINT64) (x)) >> 0) & ((UINT64) 0xFF)) << 56) \
- )
+inline UINT16 flipendian_int16( UINT16 val )
+{
+ return (val << 8) | (val >> 8 );
+}
+
+inline UINT32 flipendian_int32( UINT32 val )
+{
+ val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF );
+ return (val << 16) | (val >> 16);
+}
+
+inline UINT64 flipendian_int64( UINT64 val )
+{
+ val = ((val << 8) & U64(0xFF00FF00FF00FF00) ) | ((val >> 8) & U64(0x00FF00FF00FF00FF) );
+ val = ((val << 16) & U64(0xFFFF0000FFFF0000) ) | ((val >> 16) & U64(0x0000FFFF0000FFFF) );
+ return (val << 32) | (val >> 32);
+}
#ifdef LSB_FIRST
-#define BIG_ENDIANIZE_INT16(x) (FLIPENDIAN_INT16(x))
-#define BIG_ENDIANIZE_INT32(x) (FLIPENDIAN_INT32(x))
-#define BIG_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x))
+#define BIG_ENDIANIZE_INT16(x) (flipendian_int16(x))
+#define BIG_ENDIANIZE_INT32(x) (flipendian_int32(x))
+#define BIG_ENDIANIZE_INT64(x) (flipendian_int64(x))
#define LITTLE_ENDIANIZE_INT16(x) (x)
#define LITTLE_ENDIANIZE_INT32(x) (x)
#define LITTLE_ENDIANIZE_INT64(x) (x)
@@ -175,9 +179,9 @@ template <typename T, typename U> using equivalent_array_t = typename equivalent
#define BIG_ENDIANIZE_INT16(x) (x)
#define BIG_ENDIANIZE_INT32(x) (x)
#define BIG_ENDIANIZE_INT64(x) (x)
-#define LITTLE_ENDIANIZE_INT16(x) (FLIPENDIAN_INT16(x))
-#define LITTLE_ENDIANIZE_INT32(x) (FLIPENDIAN_INT32(x))
-#define LITTLE_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x))
+#define LITTLE_ENDIANIZE_INT16(x) (flipendian_int16(x))
+#define LITTLE_ENDIANIZE_INT32(x) (flipendian_int32(x))
+#define LITTLE_ENDIANIZE_INT64(x) (flipendian_int64(x))
#endif /* LSB_FIRST */
#ifdef _MSC_VER
diff --git a/src/osd/osdsync.cpp b/src/osd/osdsync.cpp
index d32de87459c..a782d287e1d 100644
--- a/src/osd/osdsync.cpp
+++ b/src/osd/osdsync.cpp
@@ -21,7 +21,9 @@
#include <atomic>
#include <thread>
#include <vector>
-
+#undef min
+#undef max
+#include <algorithm>
// MAME headers
#include "osdcore.h"
#include "osdsync.h"
@@ -89,7 +91,7 @@ static void spin_while_not(const volatile _AtomType * volatile atom, const _Main
int osd_get_num_processors(void)
{
// max out at 4 for now since scaling above that seems to do poorly
- return MIN(std::thread::hardware_concurrency(), 4);
+ return std::min(std::thread::hardware_concurrency(), 4U);
}
//============================================================
@@ -272,7 +274,7 @@ osd_work_queue *osd_work_queue_alloc(int flags)
threadnum = osdthreadnum;
// clamp to the maximum
- queue->threads = MIN(threadnum, WORK_MAX_THREADS);
+ queue->threads = std::min(threadnum, WORK_MAX_THREADS);
// allocate memory for thread array (+1 to count the calling thread if WORK_QUEUE_FLAG_MULTI)
if (flags & WORK_QUEUE_FLAG_MULTI)
@@ -639,7 +641,7 @@ static int effective_num_processors(void)
// osd_num_processors == 0 for 'auto'
if (osd_num_processors > 0)
{
- return MIN(4 * physprocs, osd_num_processors);
+ return std::min(4 * physprocs, osd_num_processors);
}
else
{
@@ -649,7 +651,7 @@ static int effective_num_processors(void)
// note that we permit more than the real number of processors for testing
const char *procsoverride = osd_getenv(ENV_PROCESSORS);
if (procsoverride != nullptr && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0)
- return MIN(4 * physprocs, numprocs);
+ return std::min(4 * physprocs, numprocs);
// otherwise, return the info from the system
return physprocs;
diff --git a/src/osd/sdl/window.cpp b/src/osd/sdl/window.cpp
index 0c54d4d9e5a..d655298fa8b 100644
--- a/src/osd/sdl/window.cpp
+++ b/src/osd/sdl/window.cpp
@@ -490,8 +490,8 @@ osd_dim sdl_window_info::pick_best_mode()
m_target->compute_minimum_size(minimum_width, minimum_height);
// use those as the target for now
- target_width = minimum_width * MAX(1, prescale());
- target_height = minimum_height * MAX(1, prescale());
+ target_width = minimum_width * std::max(1, prescale());
+ target_height = minimum_height * std::max(1, prescale());
// if we're not stretching, allow some slop on the minimum since we can handle it
{
@@ -926,12 +926,12 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
m_target->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
- propwidth = MAX(propwidth, MIN_WINDOW_DIM);
- propheight = MAX(propheight, MIN_WINDOW_DIM);
+ propwidth = std::max(propwidth, MIN_WINDOW_DIM);
+ propheight = std::max(propheight, MIN_WINDOW_DIM);
// clamp against the minimum width and height
- propwidth = MAX(propwidth, minwidth);
- propheight = MAX(propheight, minheight);
+ propwidth = std::max(propwidth, minwidth);
+ propheight = std::max(propheight, minheight);
// clamp against the maximum (fit on one screen for full screen mode)
if (m_fullscreen)
@@ -946,14 +946,14 @@ osd_rect sdl_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// further clamp to the maximum width/height in the window
if (m_win_config.width != 0)
- maxwidth = MIN(maxwidth, m_win_config.width + extrawidth);
+ maxwidth = std::min(maxwidth, m_win_config.width + extrawidth);
if (m_win_config.height != 0)
- maxheight = MIN(maxheight, m_win_config.height + extraheight);
+ maxheight = std::min(maxheight, m_win_config.height + extraheight);
}
// clamp to the maximum
- propwidth = MIN(propwidth, maxwidth);
- propheight = MIN(propheight, maxheight);
+ propwidth = std::min(propwidth, maxwidth);
+ propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
diff --git a/src/osd/strconv.cpp b/src/osd/strconv.cpp
index 49a70f52684..7ab8f2f401b 100644
--- a/src/osd/strconv.cpp
+++ b/src/osd/strconv.cpp
@@ -5,12 +5,13 @@
// strconv.cpp - Win32 string conversion
//
//============================================================
-
#if defined(SDLMAME_WIN32) || defined(OSD_WINDOWS)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
-
+#undef min
+#undef max
+#include <algorithm>
// MAMEOS headers
#include "strconv.h"
@@ -140,7 +141,7 @@ int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count)
goto error;
// The multibyte char can't be bigger than the max character size
- count = MIN(count, cp.MaxCharSize);
+ count = std::min(count, size_t(cp.MaxCharSize));
if (MultiByteToWideChar(CP_ACP, 0, osdchar, static_cast<DWORD>(count), &wch, 1) == 0)
goto error;
diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp
index b1cc369c0af..12e578d4682 100644
--- a/src/osd/windows/window.cpp
+++ b/src/osd/windows/window.cpp
@@ -51,8 +51,8 @@ using namespace Windows::UI::Core;
#define MAKE_DI_SCAN(scan, isextended) (scan & 0x7f) | (isextended ? 0x80 : 0x00)
#define WINOSD(machine) downcast<windows_osd_interface*>(&machine.osd())
-// min(x, y) macro interferes with chrono time_point::min()
#undef min
+#undef max
//============================================================
// PARAMETERS
@@ -1464,12 +1464,12 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
m_target->compute_minimum_size(minwidth, minheight);
// clamp against the absolute minimum
- propwidth = MAX(propwidth, MIN_WINDOW_DIM);
- propheight = MAX(propheight, MIN_WINDOW_DIM);
+ propwidth = std::max(propwidth, MIN_WINDOW_DIM);
+ propheight = std::max(propheight, MIN_WINDOW_DIM);
// clamp against the minimum width and height
- propwidth = MAX(propwidth, minwidth);
- propheight = MAX(propheight, minheight);
+ propwidth = std::max(propwidth, minwidth);
+ propheight = std::max(propheight, minheight);
// clamp against the maximum (fit on one screen for full screen mode)
if (fullscreen())
@@ -1484,14 +1484,14 @@ osd_rect win_window_info::constrain_to_aspect_ratio(const osd_rect &rect, int ad
// further clamp to the maximum width/height in the window
if (m_win_config.width != 0)
- maxwidth = MIN(maxwidth, m_win_config.width + extrawidth);
+ maxwidth = std::min(maxwidth, m_win_config.width + extrawidth);
if (m_win_config.height != 0)
- maxheight = MIN(maxheight, m_win_config.height + extraheight);
+ maxheight = std::min(maxheight, m_win_config.height + extraheight);
}
// clamp to the maximum
- propwidth = MIN(propwidth, maxwidth);
- propheight = MIN(propheight, maxheight);
+ propwidth = std::min(propwidth, maxwidth);
+ propheight = std::min(propheight, maxheight);
// compute the visible area based on the proposed rectangle
m_target->compute_visible_area(propwidth, propheight, pixel_aspect, m_target->orientation(), viswidth, visheight);
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index 0c557b03e4a..338f982253d 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -268,7 +268,7 @@ public:
: m_toc(nullptr),
m_file(file),
m_offset(offset),
- m_maxoffset(MIN(maxoffset, file.logical_bytes())) { }
+ m_maxoffset(std::min(maxoffset, file.logical_bytes())) { }
// read interface
virtual UINT32 read_data(void *dest, UINT64 offset, UINT32 length)
@@ -469,7 +469,7 @@ public:
UINT32 samples = (UINT64(m_info.rate) * UINT64(effframe + 1) * UINT64(1000000) + m_info.fps_times_1million - 1) / UINT64(m_info.fps_times_1million) - first_sample;
// loop over channels and read the samples
- int channels = MIN(m_info.channels, ARRAY_LENGTH(m_audio));
+ int channels = std::min(m_info.channels, UINT32(ARRAY_LENGTH(m_audio)));
EQUIVALENT_ARRAY(m_audio, INT16 *) samplesptr;
for (int chnum = 0; chnum < channels; chnum++)
{
@@ -509,7 +509,7 @@ public:
// copy to the destination
UINT64 start_offset = UINT64(framenum) * UINT64(m_info.bytes_per_frame);
UINT64 end_offset = start_offset + m_info.bytes_per_frame;
- UINT32 bytes_to_copy = MIN(length_remaining, end_offset - offset);
+ UINT32 bytes_to_copy = std::min(length_remaining, UINT32(end_offset - offset));
memcpy(dest, &m_rawdata[offset - start_offset], bytes_to_copy);
// advance
@@ -1449,7 +1449,7 @@ static void do_info(parameters_t &params)
UINT32 count = buffer.size();
// limit output to 60 characters of metadata if not verbose
if (!verbose)
- count = MIN(60, count);
+ count = std::min(60U, count);
for (int chnum = 0; chnum < count; chnum++)
printf("%c", isprint(UINT8(buffer[chnum])) ? buffer[chnum] : '.');
printf("\n");
@@ -1544,7 +1544,7 @@ static void do_verify(parameters_t &params)
progress(false, "Verifying, %.1f%% complete... \r", 100.0 * double(offset) / double(input_chd.logical_bytes()));
// determine how much to read
- UINT32 bytes_to_read = MIN((UINT32)buffer.size(), input_chd.logical_bytes() - offset);
+ UINT32 bytes_to_read = std::min(UINT32(buffer.size()), UINT32(input_chd.logical_bytes() - offset));
chd_error err = input_chd.read_bytes(offset, &buffer[0], bytes_to_read);
if (err != CHDERR_NONE)
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->second->c_str(), chd_file::error_string(err));
@@ -1721,7 +1721,7 @@ static void do_create_hd(parameters_t &params)
}
// process hunk size (needs to know sector_size)
- UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : MAX((4096 / sector_size) * sector_size, sector_size);
+ UINT32 hunk_size = output_parent.opened() ? output_parent.hunk_bytes() : std::max((4096 / sector_size) * sector_size, sector_size);
parse_hunk_size(params, sector_size, hunk_size);
// process input start/end (needs to know hunk_size)
@@ -2284,7 +2284,7 @@ static void do_extract_raw(parameters_t &params)
progress(false, "Extracting, %.1f%% complete... \r", 100.0 * double(offset - input_start) / double(input_end - input_start));
// determine how much to read
- UINT32 bytes_to_read = MIN((UINT32)buffer.size(), input_end - offset);
+ UINT32 bytes_to_read = std::min(UINT32(buffer.size()), UINT32(input_end - offset));
chd_error err = input_chd.read_bytes(offset, &buffer[0], bytes_to_read);
if (err != CHDERR_NONE)
report_error(1, "Error reading CHD file (%s): %s", params.find(OPTION_INPUT)->second->c_str(), chd_file::error_string(err));
@@ -2609,7 +2609,7 @@ static void do_extract_ld(parameters_t &params)
avconfig.actsamples = &actsamples;
for (int chnum = 0; chnum < ARRAY_LENGTH(audio_data); chnum++)
{
- audio_data[chnum].resize(MAX(1,max_samples_per_frame));
+ audio_data[chnum].resize(std::max(1U,max_samples_per_frame));
avconfig.audio[chnum] = &audio_data[chnum][0];
}
diff --git a/src/tools/imgtool/formats/coco_dsk.cpp b/src/tools/imgtool/formats/coco_dsk.cpp
index 7d7d2544046..525df13b5b8 100644
--- a/src/tools/imgtool/formats/coco_dsk.cpp
+++ b/src/tools/imgtool/formats/coco_dsk.cpp
@@ -16,6 +16,7 @@
#include "formats/basicdsk.h"
#include "formats/imageutl.h"
#include "coretmpl.h"
+#include <algorithm>
/* -----------------------------------------------------------------------
* JVC (Jeff Vavasour CoCo) format
@@ -1024,7 +1025,7 @@ static floperr_t internal_coco_dmk_read_sector(floppy_image_legacy *floppy, int
if (calculated_crc != crc_on_disk)
return FLOPPY_ERROR_INVALIDIMAGE;
- memcpy(buffer, sector_data, MIN(sector_length, buflen));
+ memcpy(buffer, sector_data, std::min(size_t(sector_length), buflen));
return FLOPPY_ERROR_SUCCESS;
}
diff --git a/src/tools/imgtool/modules/bml3.cpp b/src/tools/imgtool/modules/bml3.cpp
index ba825dab389..c658b42ebf0 100644
--- a/src/tools/imgtool/modules/bml3.cpp
+++ b/src/tools/imgtool/modules/bml3.cpp
@@ -760,7 +760,7 @@ static imgtoolerr_t bml3_diskimage_writefile(imgtool_partition *partition, const
gptr = &granule_map[g];
- i = MIN(read_sz, granule_bytes);
+ i = std::min(read_sz, UINT64(granule_bytes));
if (i > 0) {
err = transfer_to_granule(img, g, i, sourcef);
if (err)
diff --git a/src/tools/imgtool/modules/cybiko.cpp b/src/tools/imgtool/modules/cybiko.cpp
index 735bb733be5..649b3e9cab9 100644
--- a/src/tools/imgtool/modules/cybiko.cpp
+++ b/src/tools/imgtool/modules/cybiko.cpp
@@ -107,7 +107,7 @@ static UINT16 page_buffer_calc_checksum_2( UINT8 *buffer)
val ^= buffer_read_16_be( buffer + 0);
val ^= buffer_read_16_be( buffer + 2);
val ^= buffer_read_16_be( buffer + 4);
- return FLIPENDIAN_INT16(val);
+ return flipendian_int16(val);
}
static int page_buffer_verify( UINT8 *buffer, UINT32 size, int block_type)
diff --git a/src/tools/imgtool/modules/fat.cpp b/src/tools/imgtool/modules/fat.cpp
index c9305a7fab2..c2943625d91 100644
--- a/src/tools/imgtool/modules/fat.cpp
+++ b/src/tools/imgtool/modules/fat.cpp
@@ -305,7 +305,7 @@ static imgtoolerr_t fat_read_sector(imgtool_partition *partition, UINT32 sector_
if (err)
return err;
- len = MIN(buffer_len, sizeof(data) - offset);
+ len = std::min(buffer_len, sizeof(data) - offset);
memcpy(buffer, data + offset, len);
buffer = ((UINT8 *) buffer) + len;
@@ -337,7 +337,7 @@ static imgtoolerr_t fat_write_sector(imgtool_partition *partition, UINT32 sector
while(buffer_len > 0)
{
- len = MIN(buffer_len, sizeof(data) - offset);
+ len = std::min(buffer_len, sizeof(data) - offset);
if ((offset != 0) || (buffer_len < sizeof(data)))
{
@@ -620,7 +620,7 @@ static imgtoolerr_t fat_load_fat(imgtool_partition *partition, UINT8 **fat_table
while(pos < table_size)
{
- len = MIN(table_size - pos, FAT_SECLEN);
+ len = std::min(table_size - pos, UINT32(FAT_SECLEN));
err = fat_read_sector(partition, sector_index++, 0, &table[pos], len);
if (err)
@@ -658,7 +658,7 @@ static imgtoolerr_t fat_save_fat(imgtool_partition *partition, const UINT8 *fat_
while(pos < table_size)
{
- len = MIN(table_size - pos, FAT_SECLEN);
+ len = std::min(table_size - pos, UINT32(FAT_SECLEN));
err = fat_write_sector(partition, sector_index++, 0, &fat_table[pos], len);
if (err)
@@ -887,7 +887,7 @@ static imgtoolerr_t fat_readwrite_file(imgtool_partition *partition, fat_file *f
if (bytes_read)
*bytes_read = 0;
if (!file->directory)
- buffer_len = MIN(buffer_len, file->filesize - file->index);
+ buffer_len = std::min(buffer_len, size_t(file->filesize - file->index));
while(!file->eof && (buffer_len > 0))
{
@@ -896,7 +896,7 @@ static imgtoolerr_t fat_readwrite_file(imgtool_partition *partition, fat_file *f
return fat_corrupt_file_error(file);
offset = file->index % FAT_SECLEN;
- len = MIN(buffer_len, FAT_SECLEN - offset);
+ len = std::min(buffer_len, size_t(FAT_SECLEN - offset));
/* read or write the data from the disk */
if (read_or_write)
@@ -993,7 +993,7 @@ static imgtoolerr_t fat_set_file_size(imgtool_partition *partition, fat_file *fi
}
/* what is the new position? */
- new_pos = MIN(file->index, new_size);
+ new_pos = std::min(file->index, new_size);
if (file->root)
{
@@ -1110,7 +1110,7 @@ static imgtoolerr_t fat_set_file_size(imgtool_partition *partition, fat_file *fi
if (file->directory && !delete_file)
{
if (file->root)
- clear_size = MIN(file->filesize - new_size, FAT_DIRENT_SIZE);
+ clear_size = std::min(file->filesize - new_size, UINT32(FAT_DIRENT_SIZE));
else
clear_size = (disk_info->cluster_size - (new_size % disk_info->cluster_size)) % disk_info->cluster_size;
@@ -1159,7 +1159,7 @@ static void prepend_lfn_bytes(utf16_char *lfn_buf, size_t lfn_buflen, size_t *lf
int i;
size_t move_len;
- move_len = MIN(*lfn_len + 1, lfn_buflen - chars - 1);
+ move_len = std::min(*lfn_len + 1, lfn_buflen - chars - 1);
memmove(&lfn_buf[chars], &lfn_buf[0], move_len * sizeof(*lfn_buf));
for (i = 0; i < chars; i++)
@@ -1466,7 +1466,7 @@ static imgtoolerr_t fat_construct_dirent(const char *filename, creation_policy_t
if (!short_char || (short_char != cannonical_short_char))
{
if (toupper(short_char) == toupper(cannonical_short_char))
- sfn_disposition = MAX(sfn_disposition, SFN_DERIVATIVE);
+ sfn_disposition = std::max(sfn_disposition, SFN_DERIVATIVE);
else
sfn_disposition = SFN_MANGLED;
}
@@ -1478,7 +1478,7 @@ static imgtoolerr_t fat_construct_dirent(const char *filename, creation_policy_t
if (sfn_in_extension)
sfn_disposition = SFN_MANGLED;
else if (last_short_char == ' ')
- sfn_disposition = MAX(sfn_disposition, SFN_DERIVATIVE);
+ sfn_disposition = std::max(sfn_disposition, SFN_DERIVATIVE);
sfn_in_extension = 1;
sfn_pos = 8;
@@ -1554,7 +1554,7 @@ static imgtoolerr_t fat_construct_dirent(const char *filename, creation_policy_t
/* trailing spaces? */
if (short_char == ' ')
- sfn_disposition = MAX(sfn_disposition, SFN_DERIVATIVE);
+ sfn_disposition = std::max(sfn_disposition, SFN_DERIVATIVE);
if (sfn_disposition == SFN_SUFFICIENT)
{
@@ -1758,7 +1758,7 @@ static imgtoolerr_t fat_lookup_path(imgtool_partition *partition, const char *pa
LOG(("fat_lookup_path(): creating entry; pos=%u length=%u\n", freeent.position, freeent.required_size));
- err = fat_set_file_size(partition, file, MAX(file->filesize, freeent.position + created_entry_len));
+ err = fat_set_file_size(partition, file, std::max(file->filesize, UINT32(freeent.position + created_entry_len)));
if (err)
goto done;
@@ -1957,7 +1957,7 @@ static imgtoolerr_t fat_partition_writefile(imgtool_partition *partition, const
while(bytes_left > 0)
{
- len = MIN(bytes_left, sizeof(buffer));
+ len = std::min(bytes_left, UINT32(sizeof(buffer)));
stream_read(sourcef, buffer, len);
err = fat_write_file(partition, &file, buffer, len, NULL);
diff --git a/src/tools/imgtool/modules/mac.cpp b/src/tools/imgtool/modules/mac.cpp
index bfa111c6205..32f2475267d 100644
--- a/src/tools/imgtool/modules/mac.cpp
+++ b/src/tools/imgtool/modules/mac.cpp
@@ -5644,7 +5644,7 @@ static imgtoolerr_t mac_image_readfile(imgtool_partition *partition, const char
i = 0;
while(i < data_len)
{
- run_len = MIN(data_len - i, sizeof(buf));
+ run_len = std::min(size_t(data_len - i), sizeof(buf));
err = mac_file_read(&fileref, run_len, buf);
if (err)
diff --git a/src/tools/imgtool/modules/macutil.cpp b/src/tools/imgtool/modules/macutil.cpp
index fe2e1ade51a..d569684c34c 100644
--- a/src/tools/imgtool/modules/macutil.cpp
+++ b/src/tools/imgtool/modules/macutil.cpp
@@ -80,7 +80,7 @@ void pascal_from_c_string(unsigned char *pstring, size_t pstring_len, const char
size_t cstring_len, i;
cstring_len = strlen(cstring);
- pstring[0] = MIN(cstring_len, pstring_len - 1);
+ pstring[0] = std::min(cstring_len, pstring_len - 1);
for (i = 0; i < pstring[0]; i++)
pstring[1 + i] = cstring[i];
diff --git a/src/tools/imgtool/modules/os9.cpp b/src/tools/imgtool/modules/os9.cpp
index 32138dccc9c..15e737a1658 100644
--- a/src/tools/imgtool/modules/os9.cpp
+++ b/src/tools/imgtool/modules/os9.cpp
@@ -275,7 +275,7 @@ static imgtoolerr_t os9_decode_file_header(imgtool_image *image,
/* read all sector map entries */
max_entries = (disk_info->sector_size - 16) / 5;
- max_entries = MIN(max_entries, ARRAY_LENGTH(info->sector_map) - 1);
+ max_entries = std::min(max_entries, int(ARRAY_LENGTH(info->sector_map) - 1));
for (i = 0; i < max_entries; i++)
{
lsn = pick_integer_be(header, 16 + (i * 5) + 0, 3);
@@ -461,7 +461,7 @@ static imgtoolerr_t os9_set_file_size(imgtool_image *image,
/* do we have to write the sector map? */
if (sector_map_length >= 0)
{
- for (i = 0; i < MIN(sector_map_length + 1, ARRAY_LENGTH(file_info->sector_map)); i++)
+ for (i = 0; i < std::min(sector_map_length + 1, int(ARRAY_LENGTH(file_info->sector_map))); i++)
{
place_integer_be(header, 16 + (i * 5) + 0, 3, file_info->sector_map[i].lsn);
place_integer_be(header, 16 + (i * 5) + 3, 2, file_info->sector_map[i].count);
@@ -691,7 +691,7 @@ static imgtoolerr_t os9_diskimage_open(imgtool_image *image, imgtool_stream *str
for (i = 0; i < allocation_bitmap_lsns; i++)
{
err = os9_read_lsn(image, 1 + i, 0, &info->allocation_bitmap[i * info->sector_size],
- MIN(info->allocation_bitmap_bytes - (i * info->sector_size), info->sector_size));
+ std::min(info->allocation_bitmap_bytes - (i * info->sector_size), info->sector_size));
if (err)
return err;
}
@@ -1012,7 +1012,7 @@ static imgtoolerr_t os9_diskimage_readfile(imgtool_partition *partition, const c
{
for (j = 0; j < file_info.sector_map[i].count; j++)
{
- used_size = MIN(file_size, disk_info->sector_size);
+ used_size = std::min(file_size, disk_info->sector_size);
err = os9_read_lsn(img, file_info.sector_map[i].lsn + j, 0,
buffer, used_size);
if (err)
@@ -1055,7 +1055,7 @@ static imgtoolerr_t os9_diskimage_writefile(imgtool_partition *partition, const
while(sz > 0)
{
- write_size = (size_t) MIN(sz, (UINT64) disk_info->sector_size);
+ write_size = std::min(size_t(sz), size_t(disk_info->sector_size));
stream_read(sourcef, &buf[0], write_size);
diff --git a/src/tools/imgtool/modules/pc_hard.cpp b/src/tools/imgtool/modules/pc_hard.cpp
index eefc78b85ec..97ddd3b6894 100644
--- a/src/tools/imgtool/modules/pc_hard.cpp
+++ b/src/tools/imgtool/modules/pc_hard.cpp
@@ -397,7 +397,7 @@ static imgtoolerr_t pc_chd_list_partitions(imgtool_image *image, imgtool_partiti
info = pc_chd_get_image_info(image);
- for (i = 0; i < MIN(4, len); i++)
+ for (i = 0; i < std::min(size_t(4), len); i++)
{
partitions[i].base_block = info->partitions[i].sector_index;
partitions[i].block_count = info->partitions[i].total_sectors;
diff --git a/src/tools/imgtool/modules/prodos.cpp b/src/tools/imgtool/modules/prodos.cpp
index 576f496da8a..ffd2b377819 100644
--- a/src/tools/imgtool/modules/prodos.cpp
+++ b/src/tools/imgtool/modules/prodos.cpp
@@ -1611,7 +1611,7 @@ static imgtoolerr_t prodos_read_file_tree(imgtool_image *image, UINT32 *filesize
else
{
/* this is a leaf block */
- bytes_to_write = MIN(*filesize, sizeof(buffer));
+ bytes_to_write = std::min(size_t(*filesize), sizeof(buffer));
stream_write(destf, buffer, bytes_to_write);
*filesize -= bytes_to_write;
}
@@ -1662,7 +1662,7 @@ static imgtoolerr_t prodos_write_file_tree(imgtool_image *image, UINT32 *filesiz
else
{
/* this is a leaf block */
- bytes_to_read = MIN(*filesize, sizeof(buffer));
+ bytes_to_read = std::min(size_t(*filesize), sizeof(buffer));
stream_read(sourcef, buffer, bytes_to_read);
*filesize -= bytes_to_read;
diff --git a/src/tools/imgtool/modules/rsdos.cpp b/src/tools/imgtool/modules/rsdos.cpp
index d6d28c7610e..e067ae8de5f 100644
--- a/src/tools/imgtool/modules/rsdos.cpp
+++ b/src/tools/imgtool/modules/rsdos.cpp
@@ -465,7 +465,7 @@ static imgtoolerr_t rsdos_diskimage_writefile(imgtool_partition *partition, cons
gptr = &granule_map[g];
- i = MIN(sz, (9*256));
+ i = std::min(sz, UINT64(9*256));
err = transfer_to_granule(img, g, i, sourcef);
if (err)
return err;
diff --git a/src/tools/imgtool/stream.cpp b/src/tools/imgtool/stream.cpp
index b11e7a5e4be..417a33ed8b1 100644
--- a/src/tools/imgtool/stream.cpp
+++ b/src/tools/imgtool/stream.cpp
@@ -350,7 +350,7 @@ int stream_seek(imgtool_stream *s, INT64 pos, int where)
if (pos < 0)
s->position = 0;
else
- s->position = MIN(size, pos);
+ s->position = std::min(size, UINT64(pos));
if (s->position < pos)
stream_fill(s, '\0', pos - s->position);
@@ -373,7 +373,7 @@ UINT64 stream_transfer(imgtool_stream *dest, imgtool_stream *source, UINT64 sz)
UINT64 readsz;
char buf[1024];
- while(sz && (readsz = stream_read(source, buf, MIN(sz, sizeof(buf)))))
+ while(sz && (readsz = stream_read(source, buf, std::min(sz, sizeof(buf)))))
{
stream_write(dest, buf, readsz);
sz -= readsz;
@@ -444,12 +444,12 @@ UINT64 stream_fill(imgtool_stream *f, unsigned char b, UINT64 sz)
char buf[1024];
outsz = 0;
- memset(buf, b, MIN(sz, sizeof(buf)));
+ memset(buf, b, std::min(sz, sizeof(buf)));
while(sz)
{
- outsz += stream_write(f, buf, MIN(sz, sizeof(buf)));
- sz -= MIN(sz, sizeof(buf));
+ outsz += stream_write(f, buf, std::min(sz, sizeof(buf)));
+ sz -= std::min(sz, sizeof(buf));
}
return outsz;
}
diff --git a/src/tools/ldresample.cpp b/src/tools/ldresample.cpp
index 1f04edac3f0..9cc4f264a44 100644
--- a/src/tools/ldresample.cpp
+++ b/src/tools/ldresample.cpp
@@ -475,7 +475,7 @@ printf("%5d: start=%10d (%5d.%03d) end=%10d (%5d.%03d)\n",
dynamic_buffer buffer;
INT16 *sampledata[2] = { &m_info.lsound[0], &m_info.rsound[0] };
avhuff_encoder::assemble_data(buffer, m_info.bitmap, m_info.channels, m_info.samples, sampledata);
- memcpy(dest, &buffer[0], MIN(buffer.size(), datasize));
+ memcpy(dest, &buffer[0], std::min(buffer.size(), size_t(datasize)));
if (buffer.size() < datasize)
memset(&dest[buffer.size()], 0, datasize - buffer.size());
}
diff --git a/src/tools/ldverify.cpp b/src/tools/ldverify.cpp
index 45c20d9d70c..737dee83c2a 100644
--- a/src/tools/ldverify.cpp
+++ b/src/tools/ldverify.cpp
@@ -536,8 +536,8 @@ static void verify_video(video_info &video, int frame, bitmap_yuy16 &bitmap)
}
// update the overall min/max
- video.min_overall = MIN(yminval, video.min_overall);
- video.max_overall = MAX(ymaxval, video.max_overall);
+ video.min_overall = std::min(yminval, video.min_overall);
+ video.max_overall = std::max(ymaxval, video.max_overall);
// track low fields
if (yminval <= 0)
diff --git a/src/tools/pngcmp.cpp b/src/tools/pngcmp.cpp
index e34bcf401e4..5ee6d703cda 100644
--- a/src/tools/pngcmp.cpp
+++ b/src/tools/pngcmp.cpp
@@ -135,18 +135,18 @@ static int generate_png_diff(const std::string& imgfile1, const std::string& img
height = width = 0;
{
/* determine the maximal width */
- maxwidth = MAX(bitmap1.width(), bitmap2.width());
+ maxwidth = std::max(bitmap1.width(), bitmap2.width());
width = bitmap1.width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE + maxwidth;
/* add to the height */
- height += MAX(bitmap1.height(), bitmap2.height());
+ height += std::max(bitmap1.height(), bitmap2.height());
}
/* allocate the final bitmap */
finalbitmap.allocate(width, height);
/* now copy and compare each set of bitmaps */
- int curheight = MAX(bitmap1.height(), bitmap2.height());
+ int curheight = std::max(bitmap1.height(), bitmap2.height());
/* iterate over rows in these bitmaps */
for (y = 0; y < curheight; y++)
{
diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp
index 0c6d11093c6..bfe05ea52db 100644
--- a/src/tools/regrep.cpp
+++ b/src/tools/regrep.cpp
@@ -876,12 +876,12 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir,
int curwidth;
/* determine the maximal width */
- maxwidth = MAX(maxwidth, bitmaps[bmnum].width());
+ maxwidth = std::max(maxwidth, bitmaps[bmnum].width());
curwidth = bitmaps[0].width() + BITMAP_SPACE + maxwidth + BITMAP_SPACE + maxwidth;
- width = MAX(width, curwidth);
+ width = std::max(width, curwidth);
/* add to the height */
- height += MAX(bitmaps[0].height(), bitmaps[bmnum].height());
+ height += std::max(bitmaps[0].height(), bitmaps[bmnum].height());
if (bmnum != 1)
height += BITMAP_SPACE;
}
@@ -895,7 +895,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir,
{
bitmap_argb32 &bitmap1 = bitmaps[0];
bitmap_argb32 &bitmap2 = bitmaps[bmnum];
- int curheight = MAX(bitmap1.height(), bitmap2.height());
+ int curheight = std::max(bitmap1.height(), bitmap2.height());
int x, y;
/* iterate over rows in these bitmaps */
@@ -921,7 +921,7 @@ static int generate_png_diff(const summary_file *curfile, std::string &destdir,
}
/* update the starting Y position */
- starty += BITMAP_SPACE + MAX(bitmap1.height(), bitmap2.height());
+ starty += BITMAP_SPACE + std::max(bitmap1.height(), bitmap2.height());
}
/* write the final PNG */