diff --git a/language/Spanish/strings.po b/language/Spanish/strings.po index 448e9164749..fd398a8c2e2 100644 --- a/language/Spanish/strings.po +++ b/language/Spanish/strings.po @@ -928,7 +928,7 @@ msgstr "" #: src/frontend/mame/ui/miscmenu.cpp:780 msgid "This machine has no bios." -msgstr "" +msgstr "Esta máquina no tiene BIOS" #: src/frontend/mame/ui/miscmenu.cpp:794 msgid "Save machine configuration" @@ -1459,11 +1459,11 @@ msgstr "Confirmar salida de máquina" #: src/frontend/mame/ui/submenu.cpp:28 msgid "Skip information screen at startup" -msgstr "" +msgstr "Evitar la pantalla de información al inicio" #: src/frontend/mame/ui/submenu.cpp:29 msgid "Force 4:3 aspect for snapshot display" -msgstr "" +msgstr "Forzar aspecto 4:3 al capturar la pantalla" #: src/frontend/mame/ui/submenu.cpp:30 msgid "Use image as background" @@ -1479,47 +1479,47 @@ msgstr "Saltar el menú de selección de software" #: src/frontend/mame/ui/submenu.cpp:33 msgid "Info auto audit" -msgstr "" +msgstr "Información de la auditoría automática" #: src/frontend/mame/ui/submenu.cpp:34 msgid "Hide romless machine from available list" -msgstr "" +msgstr "Ocultar las máquinas sin ROMs de la lista" #: src/frontend/mame/ui/submenu.cpp:38 msgid "Advanced Options" -msgstr "" +msgstr "Opciones avanzadas" #: src/frontend/mame/ui/submenu.cpp:39 msgid "Performance Options" -msgstr "" +msgstr "Opciones de rendimiento" #: src/frontend/mame/ui/submenu.cpp:40 msgid "Auto frame skip" -msgstr "" +msgstr "Salto de frames automático" #: src/frontend/mame/ui/submenu.cpp:41 msgid "Frame skip" -msgstr "" +msgstr "Salto de frame" #: src/frontend/mame/ui/submenu.cpp:42 msgid "Throttle" -msgstr "" +msgstr "Acelerar" #: src/frontend/mame/ui/submenu.cpp:43 msgid "Sleep" -msgstr "" +msgstr "Suspender" #: src/frontend/mame/ui/submenu.cpp:44 msgid "Speed" -msgstr "" +msgstr "Velocidad" #: src/frontend/mame/ui/submenu.cpp:45 msgid "Refresh speed" -msgstr "" +msgstr "Velocidad de refresco" #: src/frontend/mame/ui/submenu.cpp:47 msgid "Rotation Options" -msgstr "" +msgstr "Opciones de rotación" #: src/frontend/mame/ui/submenu.cpp:48 src/frontend/mame/ui/videoopt.cpp:204 msgid "Rotate" @@ -1527,67 +1527,67 @@ msgstr "Girar" #: src/frontend/mame/ui/submenu.cpp:49 msgid "Rotate right" -msgstr "" +msgstr "Rotar a la derecha" #: src/frontend/mame/ui/submenu.cpp:50 msgid "Rotate left" -msgstr "" +msgstr "Rotar a la izquierda" #: src/frontend/mame/ui/submenu.cpp:51 msgid "Auto rotate right" -msgstr "" +msgstr "Rotar automáticamente a la derecha" #: src/frontend/mame/ui/submenu.cpp:52 msgid "Auto rotate left" -msgstr "" +msgstr "Rotar automáticamente a la izquierda" #: src/frontend/mame/ui/submenu.cpp:53 msgid "Flip X" -msgstr "" +msgstr "Voltear horizontalmente" #: src/frontend/mame/ui/submenu.cpp:54 msgid "Flip Y" -msgstr "" +msgstr "Voltear verticalmente" #: src/frontend/mame/ui/submenu.cpp:56 msgid "Artwork Options" -msgstr "" +msgstr "Opciones de arte" #: src/frontend/mame/ui/submenu.cpp:57 msgid "Artwork Crop" -msgstr "" +msgstr "Recortes del arte" #: src/frontend/mame/ui/submenu.cpp:58 msgid "Use Backdrops" -msgstr "" +msgstr "Utilizar fondos" #: src/frontend/mame/ui/submenu.cpp:59 msgid "Use Overlays" -msgstr "" +msgstr "Utilizar sobreimpresiones" #: src/frontend/mame/ui/submenu.cpp:60 msgid "Use Bezels" -msgstr "" +msgstr "Utilizar marcos" #: src/frontend/mame/ui/submenu.cpp:61 msgid "Use Control Panels" -msgstr "" +msgstr "Utilizar paneles de control" #: src/frontend/mame/ui/submenu.cpp:62 msgid "Use Marquees" -msgstr "" +msgstr "Utilizar marquesinas" #: src/frontend/mame/ui/submenu.cpp:64 msgid "State/Playback Options" -msgstr "" +msgstr "Opciones de estado/reproducción" #: src/frontend/mame/ui/submenu.cpp:65 msgid "Automatic save/restore" -msgstr "" +msgstr "Guardado/recuperación automático/a" #: src/frontend/mame/ui/submenu.cpp:66 msgid "Bilinear snapshot" -msgstr "" +msgstr "Captura bilineal" #: src/frontend/mame/ui/submenu.cpp:67 msgid "Burn-in" @@ -1595,31 +1595,31 @@ msgstr "" #: src/frontend/mame/ui/submenu.cpp:69 msgid "Input Options" -msgstr "" +msgstr "Opciones de entrada" #: src/frontend/mame/ui/submenu.cpp:70 msgid "Coin lockout" -msgstr "" +msgstr "Bloqueo de monedas" #: src/frontend/mame/ui/submenu.cpp:71 msgid "Mouse" -msgstr "" +msgstr "Ratón" #: src/frontend/mame/ui/submenu.cpp:72 msgid "Joystick" -msgstr "" +msgstr "Joystick" #: src/frontend/mame/ui/submenu.cpp:73 msgid "Lightgun" -msgstr "" +msgstr "Pistola de luz" #: src/frontend/mame/ui/submenu.cpp:74 msgid "Multi-keyboard" -msgstr "" +msgstr "Multi-teclado" #: src/frontend/mame/ui/submenu.cpp:75 msgid "Multi-mouse" -msgstr "" +msgstr "Multi-ratón" #: src/frontend/mame/ui/submenu.cpp:76 msgid "Steadykey" @@ -1627,31 +1627,31 @@ msgstr "" #: src/frontend/mame/ui/submenu.cpp:77 msgid "UI active" -msgstr "" +msgstr "Interfaz de usuario activa" #: src/frontend/mame/ui/submenu.cpp:78 msgid "Offscreen reload" -msgstr "" +msgstr "Recarga no visible" #: src/frontend/mame/ui/submenu.cpp:79 msgid "Joystick deadzone" -msgstr "" +msgstr "Zona muerta de los Joysticks" #: src/frontend/mame/ui/submenu.cpp:80 msgid "Joystick saturation" -msgstr "" +msgstr "Saturación de los Joysticks" #: src/frontend/mame/ui/submenu.cpp:81 msgid "Natural keyboard" -msgstr "" +msgstr "Teclado natural" #: src/frontend/mame/ui/submenu.cpp:82 msgid "Simultaneous contradictory" -msgstr "" +msgstr "Entradas contradictorias simultáneas" #: src/frontend/mame/ui/submenu.cpp:83 msgid "Coin impulse" -msgstr "" +msgstr "Impulso de monedas" #: src/frontend/mame/ui/submenu.cpp:87 msgid "Device Mapping" @@ -1695,7 +1695,7 @@ msgstr "Modo de vídeo" #: src/frontend/mame/ui/submenu.cpp:101 msgid "Number Of Screens" -msgstr "" +msgstr "Número de pantallas" #: src/frontend/mame/ui/submenu.cpp:103 msgid "Triple Buffering" @@ -2243,7 +2243,7 @@ msgstr "Fondos" #: src/frontend/mame/ui/videoopt.cpp:212 msgid "Overlays" -msgstr "Superposiciones" +msgstr "Sobreimpresiones" #: src/frontend/mame/ui/videoopt.cpp:216 msgid "Bezels" diff --git a/src/devices/bus/a7800/a78_slot.cpp b/src/devices/bus/a7800/a78_slot.cpp index 9e028502170..b28b71564bb 100644 --- a/src/devices/bus/a7800/a78_slot.cpp +++ b/src/devices/bus/a7800/a78_slot.cpp @@ -378,7 +378,7 @@ bool a78_cart_slot_device::call_load() char head[128]; fread(head, 128); - if (verify_header((char *)head) == IMAGE_VERIFY_FAIL) + if (!verify_header((char *)head)) return IMAGE_INIT_FAIL; len = (head[49] << 24) | (head[50] << 16) | (head[51] << 8) | head[52]; @@ -499,18 +499,18 @@ void a78_cart_slot_device::call_unload() has an admissible header -------------------------------------------------*/ -int a78_cart_slot_device::verify_header(char *header) +bool a78_cart_slot_device::verify_header(char *header) { const char *magic = "ATARI7800"; if (strncmp(magic, header + 1, 9)) { logerror("Not a valid A7800 image\n"); - return IMAGE_VERIFY_FAIL; + return false; } logerror("returning ID_OK\n"); - return IMAGE_VERIFY_PASS; + return true; } diff --git a/src/devices/bus/a7800/a78_slot.h b/src/devices/bus/a7800/a78_slot.h index 88a758b8ce2..933ef663958 100644 --- a/src/devices/bus/a7800/a78_slot.h +++ b/src/devices/bus/a7800/a78_slot.h @@ -128,7 +128,7 @@ private: device_a78_cart_interface* m_cart; int m_type; - int verify_header(char *header); + bool verify_header(char *header); int validate_header(int head, bool log); void internal_header_logging(UINT8 *header, UINT32 len); }; diff --git a/src/devices/bus/apricot/keyboard/hle.cpp b/src/devices/bus/apricot/keyboard/hle.cpp index c940b269233..4fb94c1f1a4 100644 --- a/src/devices/bus/apricot/keyboard/hle.cpp +++ b/src/devices/bus/apricot/keyboard/hle.cpp @@ -45,15 +45,7 @@ ***************************************************************************/ #include "hle.h" - - -//************************************************************************** -// CONSTANTS / MACROS -//************************************************************************** - -#define APRICOT_KEY(_key, _index) \ - PORT_BIT(1 << _key, IP_ACTIVE_HIGH, IPT_KEYBOARD) \ - PORT_CHANGED_MEMBER(DEVICE_SELF, apricot_keyboard_hle_device, key_callback, (void *) _index) +#include "machine/keyboard.ipp" //************************************************************************** @@ -68,110 +60,128 @@ const device_type APRICOT_KEYBOARD_HLE = &device_creator') - APRICOT_KEY(16, 2) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') - APRICOT_KEY(17, 2) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) - APRICOT_KEY(18, 2) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) - APRICOT_KEY(19, 2) PORT_CODE(KEYCODE_SCRLOCK) PORT_CHAR(UCHAR_MAMEKEY(SCRLOCK)) - APRICOT_KEY(20, 2) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) - APRICOT_KEY(21, 2) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) - APRICOT_KEY(22, 2) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) - APRICOT_KEY(23, 2) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) - APRICOT_KEY(24, 2) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) - APRICOT_KEY(25, 2) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') - APRICOT_KEY(26, 2) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) PORT_NAME("Stop") - APRICOT_KEY(27, 2) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) - APRICOT_KEY(28, 2) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) - APRICOT_KEY(29, 2) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) - APRICOT_KEY(30, 2) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) - APRICOT_KEY(31, 2) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) + PORT_START("row_2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR(0xa3) // pound + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('$') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') - PORT_START("keyboard_3") - APRICOT_KEY( 0, 3) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) + PORT_START("row_3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) // actually a dedicated % key + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH_PAD) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) + + PORT_START("row_4") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') + + PORT_START("row_5") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) + + PORT_START("row_6") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) PORT_NAME("Clear") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') + + PORT_START("row_7") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') + + PORT_START("row_8") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') + + PORT_START("row_9") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') + + PORT_START("row_a") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SCRLOCK) PORT_CHAR(UCHAR_MAMEKEY(SCRLOCK)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) + + PORT_START("row_b") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) PORT_NAME("Stop") + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) + + PORT_START("row_c") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) INPUT_PORTS_END ioport_constructor apricot_keyboard_hle_device::device_input_ports() const @@ -191,10 +201,8 @@ ioport_constructor apricot_keyboard_hle_device::device_input_ports() const apricot_keyboard_hle_device::apricot_keyboard_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, APRICOT_KEYBOARD_HLE, "Apricot Keyboard (HLE)", tag, owner, clock, "apricotkb_hle", __FILE__), device_apricot_keyboard_interface(mconfig, *this), - device_serial_interface(mconfig, *this), - m_rxd(1), - m_data_in(0), - m_data_out(0) + device_buffered_serial_interface(mconfig, *this), + device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7", "row_8", "row_9", "row_a", "row_b", "row_c") { } @@ -204,6 +212,7 @@ apricot_keyboard_hle_device::apricot_keyboard_hle_device(const machine_config &m void apricot_keyboard_hle_device::device_start() { + device_buffered_serial_interface::register_save_state(machine().save(), this); } //------------------------------------------------- @@ -212,21 +221,17 @@ void apricot_keyboard_hle_device::device_start() void apricot_keyboard_hle_device::device_reset() { + clear_fifo(); + receive_register_reset(); transmit_register_reset(); set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1); set_rcv_rate(7800); set_tra_rate(7800); -} -//------------------------------------------------- -// device_timer - device-specific timer -//------------------------------------------------- - -void apricot_keyboard_hle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - device_serial_interface::device_timer(timer, id, param, ptr); + reset_key_state(); + start_processing(attotime::from_hz(7800)); } void apricot_keyboard_hle_device::tra_callback() @@ -236,49 +241,54 @@ void apricot_keyboard_hle_device::tra_callback() void apricot_keyboard_hle_device::tra_complete() { - if (m_data_out != 0) - { - transmit_register_setup(m_data_out); - m_data_out = 0; - } + device_buffered_serial_interface::tra_complete(); } -void apricot_keyboard_hle_device::rcv_callback() +void apricot_keyboard_hle_device::received_byte(UINT8 byte) { - receive_register_update_bit(m_rxd); + logerror("received command: %02x\n", byte); } -void apricot_keyboard_hle_device::rcv_complete() -{ - receive_register_extract(); - m_data_in = get_received_char(); +//------------------------------------------------- +// key_make - handle a key being pressed +//------------------------------------------------- - // reset command? send keyboard ready (likely needs a delay, just disable for now) -// if (m_data_in == 0xe8) -// transmit_register_setup(0xfb); +void apricot_keyboard_hle_device::key_make(UINT8 row, UINT8 column) +{ + // send the make code + transmit_byte((row << 3) | column); +} + +//------------------------------------------------- +// key_break - handle a key being released +//------------------------------------------------- + +void apricot_keyboard_hle_device::key_break(UINT8 row, UINT8 column) +{ + // send the break code + transmit_byte(0x80 | (row << 3) | column); } void apricot_keyboard_hle_device::out_w(int state) { - m_rxd = state; - device_serial_interface::rx_w(m_rxd); + device_buffered_serial_interface::rx_w(state); } -INPUT_CHANGED_MEMBER( apricot_keyboard_hle_device::key_callback ) +//------------------------------------------------- +// transmit_byte - send a byte or queue it +//------------------------------------------------- + +void apricot_keyboard_hle_device::transmit_byte(UINT8 byte) { - UINT32 oldvalue = oldval * field.mask(), newvalue = newval * field.mask(); - UINT32 delta = oldvalue ^ newvalue; - - for (int i = 0; i < 32; i++) - { - if (delta & (1 << i)) - { - UINT8 down = (newvalue & (1 << i)) ? 0x00 : 0x80; - UINT8 scancode = (FPTR) param * 32 + i; - scancode |= down; - transmit_register_setup(scancode); - break; - } - } - + device_buffered_serial_interface::transmit_byte(byte); +} + +//------------------------------------------------- +// device_timer - device-specific timer +//------------------------------------------------- + +void apricot_keyboard_hle_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + device_matrix_keyboard_interface::device_timer(timer, id, param, ptr); + device_buffered_serial_interface::device_timer(timer, id, param, ptr); } diff --git a/src/devices/bus/apricot/keyboard/hle.h b/src/devices/bus/apricot/keyboard/hle.h index e6ce8ee9df5..a0d8b1b306f 100644 --- a/src/devices/bus/apricot/keyboard/hle.h +++ b/src/devices/bus/apricot/keyboard/hle.h @@ -13,6 +13,7 @@ #include "emu.h" #include "keyboard.h" +#include "machine/keyboard.h" //************************************************************************** @@ -21,14 +22,15 @@ // ======================> apricot_keyboard_hle_device -class apricot_keyboard_hle_device : public device_t, public device_apricot_keyboard_interface, public device_serial_interface +class apricot_keyboard_hle_device : public device_t, + public device_apricot_keyboard_interface, + public device_buffered_serial_interface<8>, + protected device_matrix_keyboard_interface<13> { public: // construction/destruction apricot_keyboard_hle_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - DECLARE_INPUT_CHANGED_MEMBER(key_callback); - // from host virtual void out_w(int state) override; @@ -38,19 +40,19 @@ protected: virtual void device_start() override; virtual void device_reset() override; - // device_serial_interface overrides + // device_buffered_serial_interface overrides virtual void tra_callback() override; virtual void tra_complete() override; - virtual void rcv_callback() override; - virtual void rcv_complete() override; + virtual void received_byte(UINT8 byte) override; + + // device_matrix_keyboard_interface overrides + virtual void key_make(UINT8 row, UINT8 column) override; + virtual void key_break(UINT8 row, UINT8 column) override; + void transmit_byte(UINT8 byte); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: - int m_rxd; - - UINT8 m_data_in; - UINT8 m_data_out; }; 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..d95c5a564ce 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, 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/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..b894060b182 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)(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)(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_TAG)->size() - 1); + end = std::min(end, begin + machine().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..175681e0227 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, 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/nes/disksys.cpp b/src/devices/bus/nes/disksys.cpp index 38b24438408..bdc4862da56 100644 --- a/src/devices/bus/nes/disksys.cpp +++ b/src/devices/bus/nes/disksys.cpp @@ -81,7 +81,7 @@ const rom_entry *nes_disksys_device::device_rom_region() const } -void nes_disksys_device::load_proc(device_image_interface &image) +void nes_disksys_device::load_proc(device_image_interface &image, bool is_created) { nes_disksys_device *disk_sys = static_cast(image.device().owner()); disk_sys->load_disk(image); diff --git a/src/devices/bus/nes/disksys.h b/src/devices/bus/nes/disksys.h index 7dbefa37ee4..8fabb0a80db 100644 --- a/src/devices/bus/nes/disksys.h +++ b/src/devices/bus/nes/disksys.h @@ -33,7 +33,7 @@ public: virtual void hblank_irq(int scanline, int vblank, int blanked) override; virtual void pcb_reset() override; - static void load_proc(device_image_interface &image); + static void load_proc(device_image_interface &image, bool is_created); static void unload_proc(device_image_interface &image); private: 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/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp index 2d5905e240c..937d08d4e2c 100644 --- a/src/devices/bus/sega8/sega8_slot.cpp +++ b/src/devices/bus/sega8/sega8_slot.cpp @@ -213,15 +213,15 @@ static const char *sega8_get_slot(int type) call load -------------------------------------------------*/ -int sega8_cart_slot_device::verify_cart( UINT8 *magic, int size ) +bool sega8_cart_slot_device::verify_cart( UINT8 *magic, int size ) { - int retval = IMAGE_VERIFY_FAIL; + int retval = false; // Verify the file is a valid image - check $7ff0 for "TMR SEGA" if (size >= 0x8000) { if (!strncmp((char*)&magic[0x7ff0], "TMR SEGA", 8)) - retval = IMAGE_VERIFY_PASS; + retval = true; } return retval; @@ -368,7 +368,7 @@ bool sega8_cart_slot_device::call_load() memcpy(ROM, get_software_region("rom"), get_software_region_length("rom")); /* check the image */ - if (verify_cart(ROM, len) == IMAGE_VERIFY_FAIL) + if (!verify_cart(ROM, len)) logerror("Warning loading image: verify_cart failed\n"); if (software_entry() != nullptr) diff --git a/src/devices/bus/sega8/sega8_slot.h b/src/devices/bus/sega8/sega8_slot.h index b136f68ea99..c9236b41eed 100644 --- a/src/devices/bus/sega8/sega8_slot.h +++ b/src/devices/bus/sega8/sega8_slot.h @@ -117,7 +117,7 @@ public: void setup_ram(); void internal_header_logging(UINT8 *ROM, UINT32 len, UINT32 nvram_len); - int verify_cart(UINT8 *magic, int size); + bool verify_cart(UINT8 *magic, int size); void set_lphaser_xoffset(UINT8 *rom, int size); void save_ram() { if (m_cart && m_cart->get_ram_size()) m_cart->save_ram(); } 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/bus/ti99_peb/ti_rs232.cpp b/src/devices/bus/ti99_peb/ti_rs232.cpp index ce83d3425bd..2996c2dbf70 100644 --- a/src/devices/bus/ti99_peb/ti_rs232.cpp +++ b/src/devices/bus/ti99_peb/ti_rs232.cpp @@ -231,7 +231,7 @@ bool ti_pio_attached_device::call_load() ti_rs232_pio_device* card = static_cast(owner()); // tell whether the image is readable - card->m_pio_readable = !has_been_created(); + card->m_pio_readable = true; // tell whether the image is writable card->m_pio_writable = !is_readonly(); diff --git a/src/devices/cpu/arc/arcdasm.cpp b/src/devices/cpu/arc/arcdasm.cpp index 7a525d6cb61..1b7897069de 100644 --- a/src/devices/cpu/arc/arcdasm.cpp +++ b/src/devices/cpu/arc/arcdasm.cpp @@ -194,7 +194,7 @@ static const char *regnames[0x40] = CPU_DISASSEMBLE(arc) { UINT32 op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); output = buffer; diff --git a/src/devices/cpu/cubeqcpu/cubedasm.cpp b/src/devices/cpu/cubeqcpu/cubedasm.cpp index 81d7d95c088..bbd1c750361 100644 --- a/src/devices/cpu/cubeqcpu/cubedasm.cpp +++ b/src/devices/cpu/cubeqcpu/cubedasm.cpp @@ -81,7 +81,7 @@ CPU_DISASSEMBLE( cquestsnd ) " ", }; - UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom); + UINT64 inst = big_endianize_int64(*(UINT64 *)oprom); UINT32 inslow = inst & 0xffffffff; UINT32 inshig = inst >> 32; @@ -185,7 +185,7 @@ CPU_DISASSEMBLE( cquestrot ) "??? " }; - UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom); + UINT64 inst = big_endianize_int64(*(UINT64 *)oprom); UINT32 inslow = inst & 0xffffffff; UINT32 inshig = inst >> 32; @@ -271,7 +271,7 @@ CPU_DISASSEMBLE( cquestlin ) "BRES ", }; - UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom); + UINT64 inst = big_endianize_int64(*(UINT64 *)oprom); UINT32 inslow = inst & 0xffffffff; UINT32 inshig = inst >> 32; 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/esrip/esripdsm.cpp b/src/devices/cpu/esrip/esripdsm.cpp index 8e5a01ae792..41f3434d2cd 100644 --- a/src/devices/cpu/esrip/esripdsm.cpp +++ b/src/devices/cpu/esrip/esripdsm.cpp @@ -45,7 +45,7 @@ CPU_DISASSEMBLE( esrip ) }; #endif - UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom); + UINT64 inst = big_endianize_int64(*(UINT64 *)oprom); UINT32 inst_hi = inst >> 32; UINT32 inst_lo = inst & 0xffffffff; diff --git a/src/devices/cpu/mb86233/mb86233d.cpp b/src/devices/cpu/mb86233/mb86233d.cpp index 6e27c3b4d06..f75053c07ff 100644 --- a/src/devices/cpu/mb86233/mb86233d.cpp +++ b/src/devices/cpu/mb86233/mb86233d.cpp @@ -779,6 +779,6 @@ static unsigned dasm_mb86233(char *buffer, UINT32 opcode ) CPU_DISASSEMBLE( mb86233 ) { UINT32 op = *(UINT32 *)oprom; - op = LITTLE_ENDIANIZE_INT32(op); + op = little_endianize_int32(op); return dasm_mb86233(buffer, op); } diff --git a/src/devices/cpu/mb86235/mb86235d.cpp b/src/devices/cpu/mb86235/mb86235d.cpp index 58dcfc047b6..640fef9bccf 100644 --- a/src/devices/cpu/mb86235/mb86235d.cpp +++ b/src/devices/cpu/mb86235/mb86235d.cpp @@ -833,7 +833,7 @@ static unsigned dasm_mb86235(char *buffer, UINT32 pc, UINT64 opcode) CPU_DISASSEMBLE( mb86235 ) { UINT64 op = *(UINT64*)oprom; - op = LITTLE_ENDIANIZE_INT64(op); + op = little_endianize_int64(op); return dasm_mb86235(buffer, pc, op); } diff --git a/src/devices/cpu/mips/mips3.cpp b/src/devices/cpu/mips/mips3.cpp index 73b5974bab7..306760f33d3 100644 --- a/src/devices/cpu/mips/mips3.cpp +++ b/src/devices/cpu/mips/mips3.cpp @@ -968,9 +968,9 @@ offs_t mips3_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *op extern unsigned dasmmips3(char *, unsigned, UINT32); UINT32 op = *(UINT32 *)oprom; if (m_bigendian) - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); else - op = LITTLE_ENDIANIZE_INT32(op); + op = little_endianize_int32(op); return dasmmips3(buffer, pc, op); } diff --git a/src/devices/cpu/mips/mips3dsm.cpp b/src/devices/cpu/mips/mips3dsm.cpp index 71e81ca7b5c..0eca3d73c54 100644 --- a/src/devices/cpu/mips/mips3dsm.cpp +++ b/src/devices/cpu/mips/mips3dsm.cpp @@ -539,7 +539,7 @@ unsigned dasmmips3(char *buffer, unsigned pc, UINT32 op) CPU_DISASSEMBLE( mips3be ) { UINT32 op = *(UINT32 *)oprom; - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); return dasmmips3(buffer, pc, op); } @@ -547,6 +547,6 @@ CPU_DISASSEMBLE( mips3be ) CPU_DISASSEMBLE( mips3le ) { UINT32 op = *(UINT32 *)oprom; - op = LITTLE_ENDIANIZE_INT32(op); + op = little_endianize_int32(op); return dasmmips3(buffer, pc, op); } diff --git a/src/devices/cpu/mips/r3kdasm.cpp b/src/devices/cpu/mips/r3kdasm.cpp index 3e65c0f0e9c..01cf1ad7599 100644 --- a/src/devices/cpu/mips/r3kdasm.cpp +++ b/src/devices/cpu/mips/r3kdasm.cpp @@ -381,7 +381,7 @@ static unsigned dasmr3k(char *buffer, unsigned pc, UINT32 op) CPU_DISASSEMBLE( r3000be ) { UINT32 op = *(UINT32 *)oprom; - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); return dasmr3k(buffer, pc, op); } @@ -389,6 +389,6 @@ CPU_DISASSEMBLE( r3000be ) CPU_DISASSEMBLE( r3000le ) { UINT32 op = *(UINT32 *)oprom; - op = LITTLE_ENDIANIZE_INT32(op); + op = little_endianize_int32(op); return dasmr3k(buffer, pc, op); } diff --git a/src/devices/cpu/powerpc/ppc_dasm.cpp b/src/devices/cpu/powerpc/ppc_dasm.cpp index d80f800c89b..25a79140193 100644 --- a/src/devices/cpu/powerpc/ppc_dasm.cpp +++ b/src/devices/cpu/powerpc/ppc_dasm.cpp @@ -1172,6 +1172,6 @@ offs_t ppc_dasm_one(char *buffer, UINT32 pc, UINT32 op) CPU_DISASSEMBLE( powerpc ) { UINT32 op = *(UINT32 *)oprom; - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); return ppc_dasm_one(buffer, pc, op); } diff --git a/src/devices/cpu/powerpc/ppccom.cpp b/src/devices/cpu/powerpc/ppccom.cpp index ce7249a6414..081aa5d0838 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, 0); if (!m_tb_divisor) { @@ -1235,7 +1235,7 @@ offs_t ppc_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *opro { extern offs_t ppc_dasm_one(char *buffer, UINT32 pc, UINT32 op); UINT32 op = *(UINT32 *)oprom; - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); return ppc_dasm_one(buffer, pc, op); } 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/rsp_dasm.cpp b/src/devices/cpu/rsp/rsp_dasm.cpp index d4ade625904..b430a43a75d 100644 --- a/src/devices/cpu/rsp/rsp_dasm.cpp +++ b/src/devices/cpu/rsp/rsp_dasm.cpp @@ -359,6 +359,6 @@ offs_t rsp_dasm_one(char *buffer, offs_t pc, UINT32 op) CPU_DISASSEMBLE( rsp ) { UINT32 op = *(UINT32 *)opram; - op = BIG_ENDIANIZE_INT32(op); + op = big_endianize_int32(op); return rsp_dasm_one(buffer, pc, op); } 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/sparc/mb86901.cpp b/src/devices/cpu/sparc/mb86901.cpp index 1e9eafebcb1..be7edbe6284 100644 --- a/src/devices/cpu/sparc/mb86901.cpp +++ b/src/devices/cpu/sparc/mb86901.cpp @@ -550,7 +550,7 @@ UINT32 mb86901_device::disasm_max_opcode_bytes() const offs_t mb86901_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) { UINT32 op = *reinterpret_cast(oprom); - return m_dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(op)); + return m_dasm.dasm(buffer, pc, big_endianize_int32(op)); } 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/unsp/unspdasm.cpp b/src/devices/cpu/unsp/unspdasm.cpp index f755a3fcf5a..34f153fc916 100644 --- a/src/devices/cpu/unsp/unspdasm.cpp +++ b/src/devices/cpu/unsp/unspdasm.cpp @@ -61,8 +61,8 @@ CPU_DISASSEMBLE( unsp ) { UINT16 op = *(UINT16 *)oprom; UINT16 imm16 = *(UINT16 *)(oprom + 2); - op = BIG_ENDIANIZE_INT16(op); - imm16 = BIG_ENDIANIZE_INT16(imm16); + op = big_endianize_int16(op); + imm16 = big_endianize_int16(imm16); output = buffer; 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 62f2d9306c3..e5c909477e4 100644 --- a/src/devices/imagedev/cassette.cpp +++ b/src/devices/imagedev/cassette.cpp @@ -73,10 +73,10 @@ void cassette_image_device::device_config_complete() bool cassette_image_device::is_motor_on() { if ((m_state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED) - return FALSE; + return false; if ((m_state & CASSETTE_MASK_MOTOR) != CASSETTE_MOTOR_ENABLED) - return FALSE; - return TRUE; + return false; + return true; } @@ -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); } @@ -252,10 +252,15 @@ void cassette_image_device::device_start() bool cassette_image_device::call_create(int format_type, util::option_resolution *format_options) { - return call_load(); + return internal_load(true); } bool cassette_image_device::call_load() +{ + return internal_load(false); +} + +bool cassette_image_device::internal_load(bool is_create) { casserr_t err; int cassette_flags; @@ -264,7 +269,7 @@ bool cassette_image_device::call_load() device_image_interface *image = nullptr; interface(image); - if ((has_been_created()) || (length() == 0)) + if (is_create || (length() == 0)) { /* creating an image */ err = cassette_create((void *)image, &image_ioprocs, &wavfile_format, m_create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &m_cassette); diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index bf0440f9b6a..84d1b9ac507 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -95,6 +95,7 @@ protected: // device-level overrides virtual void device_config_complete() override; virtual void device_start() override; + private: cassette_image *m_cassette; cassette_state m_state; @@ -109,6 +110,8 @@ private: const struct CassetteOptions *m_create_opts; cassette_state m_default_state; const char * m_interface; + + bool internal_load(bool is_create); }; // device type definition diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp index f090d7f0032..cac16961a31 100644 --- a/src/devices/imagedev/chd_cd.cpp +++ b/src/devices/imagedev/chd_cd.cpp @@ -61,7 +61,7 @@ void cdrom_image_device::device_config_complete() { m_extension_list = "chd,cue,toc,nrg,gdi,iso,cdr"; - m_formatlist.push_back(std::make_unique("chdcd", "CD-ROM drive", m_extension_list, cd_option_spec)); + add_format("chdcd", "CD-ROM drive", m_extension_list, cd_option_spec); // set brief and instance name update_names(); diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp index 64e313865bf..a47451a1c47 100644 --- a/src/devices/imagedev/diablo.cpp +++ b/src/devices/imagedev/diablo.cpp @@ -56,7 +56,7 @@ diablo_image_device::~diablo_image_device() void diablo_image_device::device_config_complete() { - m_formatlist.push_back(std::make_unique("chd", "CHD Hard drive", "chd,dsk", dsk_option_spec)); + add_format("chd", "CHD Hard drive", "chd,dsk", dsk_option_spec); // set brief and instance name update_names(); diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp index 75da2d10f5d..290d6671cd3 100644 --- a/src/devices/imagedev/flopdrv.cpp +++ b/src/devices/imagedev/flopdrv.cpp @@ -375,7 +375,7 @@ void legacy_floppy_image_device::floppy_drive_write_sector_data(int side, int in } } -void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image)) +void legacy_floppy_image_device::floppy_install_load_proc(void (*proc)(device_image_interface &image, bool is_created)) { m_load_proc = proc; } @@ -417,7 +417,7 @@ void legacy_floppy_image_device::floppy_drive_set_controller(device_t *controlle m_controller = controller; } -int legacy_floppy_image_device::internal_floppy_device_load(int create_format, util::option_resolution *create_args) +int legacy_floppy_image_device::internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args) { floperr_t err; const struct FloppyFormat *floppy_options; @@ -428,7 +428,7 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, u interface(image); /* figure out the floppy options */ floppy_options = m_config->formats; - if (has_been_created()) + if (is_create) { /* creating an image */ assert(create_format >= 0); @@ -452,6 +452,10 @@ int legacy_floppy_image_device::internal_floppy_device_load(int create_format, u /* disk changed */ m_dskchg = CLEAR_LINE; + // If we have one of our hacky load procs, call it + if (m_load_proc) + m_load_proc(*this, is_create); + return IMAGE_INIT_PASS; error: @@ -821,7 +825,7 @@ void legacy_floppy_image_device::device_config_complete() // only add if creatable if (floppy_options[i].param_guidelines) { // allocate a new format and append it to the list - m_formatlist.push_back(std::make_unique(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines)); + add_format(floppy_options[i].name, floppy_options[i].description, floppy_options[i].extensions, floppy_options[i].param_guidelines); } image_specify_extension( m_extension_list, 256, floppy_options[i].extensions ); } @@ -832,17 +836,12 @@ void legacy_floppy_image_device::device_config_complete() bool legacy_floppy_image_device::call_create(int format_type, util::option_resolution *format_options) { - return internal_floppy_device_load(format_type, format_options); + return internal_floppy_device_load(true, format_type, format_options); } bool legacy_floppy_image_device::call_load() { - int retVal = internal_floppy_device_load(-1, nullptr); - if (retVal==IMAGE_INIT_PASS) { - /* if we have one of our hacky unload procs, call it */ - if (m_load_proc) - m_load_proc(*this); - } + int retVal = internal_floppy_device_load(false, -1, nullptr); /* push disk halfway into drive */ m_wpt = CLEAR_LINE; diff --git a/src/devices/imagedev/flopdrv.h b/src/devices/imagedev/flopdrv.h index 080093e1b17..800a0b878c2 100644 --- a/src/devices/imagedev/flopdrv.h +++ b/src/devices/imagedev/flopdrv.h @@ -127,7 +127,7 @@ public: void floppy_drive_format_sector(int side, int sector_index,int c,int h, int r, int n, int filler); void floppy_drive_read_sector_data(int side, int index1, void *ptr, int length); void floppy_drive_write_sector_data(int side, int index1, const void *ptr,int length, int ddam); - void floppy_install_load_proc(void (*proc)(device_image_interface &image)); + void floppy_install_load_proc(void (*proc)(device_image_interface &image, bool is_created)); void floppy_install_unload_proc(void (*proc)(device_image_interface &image)); void floppy_drive_set_index_pulse_callback(void (*callback)(device_t *controller,device_t *image, int state)); int floppy_drive_get_current_track(); @@ -162,7 +162,7 @@ private: TIMER_CALLBACK_MEMBER(floppy_drive_index_callback); void floppy_drive_init(); void floppy_drive_index_func(); - int internal_floppy_device_load(int create_format, util::option_resolution *create_args); + int internal_floppy_device_load(bool is_create, int create_format, util::option_resolution *create_args); TIMER_CALLBACK_MEMBER( set_wpt ); protected: @@ -215,7 +215,7 @@ protected: floppy_image_legacy *m_floppy; int m_track; - void (*m_load_proc)(device_image_interface &image); + void (*m_load_proc)(device_image_interface &image, bool is_created); void (*m_unload_proc)(device_image_interface &image); int m_floppy_drive_type; diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 44b80e6629a..30d535c28fa 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -242,7 +242,7 @@ void floppy_image_device::set_formats(const floppy_format_type *formats) else fif_list->append(fif); - m_formatlist.push_back(std::make_unique(fif->name(), fif->description(), fif->extensions(), "")); + add_format(fif->name(), fif->description(), fif->extensions(), ""); image_specify_extension( extension_list, 256, fif->extensions() ); } diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp index 42eeac477be..588ef862c4d 100644 --- a/src/devices/imagedev/harddriv.cpp +++ b/src/devices/imagedev/harddriv.cpp @@ -79,7 +79,7 @@ harddisk_image_device::~harddisk_image_device() void harddisk_image_device::device_config_complete() { - m_formatlist.push_back(std::make_unique("chd", "CHD Hard drive", "chd,hd", hd_option_spec)); + add_format("chd", "CHD Hard drive", "chd,hd", hd_option_spec); // set brief and instance name update_names(); diff --git a/src/devices/imagedev/midiin.h b/src/devices/imagedev/midiin.h index 3309d366f7c..c0279f9822d 100644 --- a/src/devices/imagedev/midiin.h +++ b/src/devices/imagedev/midiin.h @@ -42,7 +42,7 @@ public: virtual bool must_be_loaded() const override { return 0; } virtual bool is_reset_on_load() const override { return 0; } virtual const char *file_extensions() const override { return "mid"; } - virtual bool core_opens_image_file() const override { return FALSE; } + virtual bool core_opens_image_file() const override { return false; } protected: // device-level overrides diff --git a/src/devices/imagedev/midiout.h b/src/devices/imagedev/midiout.h index 0954987a824..096bece8fef 100644 --- a/src/devices/imagedev/midiout.h +++ b/src/devices/imagedev/midiout.h @@ -45,7 +45,7 @@ public: virtual bool must_be_loaded() const override { return 0; } virtual bool is_reset_on_load() const override { return 0; } virtual const char *file_extensions() const override { return "mid"; } - virtual bool core_opens_image_file() const override { return FALSE; } + virtual bool core_opens_image_file() const override { return false; } virtual void tx(UINT8 state) { rx_w(state); } 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/hp_taco.cpp b/src/devices/machine/hp_taco.cpp index adb369c59f2..87adeb15488 100644 --- a/src/devices/machine/hp_taco.cpp +++ b/src/devices/machine/hp_taco.cpp @@ -1678,13 +1678,11 @@ void hp_taco_device::start_cmd_exec(UINT16 new_cmd_reg) } } -bool hp_taco_device::call_load() +bool hp_taco_device::internal_load(bool is_create) { - LOG(("call_load %d\n" , has_been_created())); - device_reset(); - if (has_been_created()) { + if (is_create) { clear_tape(); save_tape(); } else if (!load_tape()) { @@ -1699,10 +1697,16 @@ bool hp_taco_device::call_load() return IMAGE_INIT_PASS; } +bool hp_taco_device::call_load() +{ + LOG(("call_load\n")); + return internal_load(false); +} + bool hp_taco_device::call_create(int format_type, util::option_resolution *format_options) { - LOG(("call_create %d\n" , has_been_created())); - return call_load(); + LOG(("call_create\n")); + return internal_load(true); } void hp_taco_device::call_unload() diff --git a/src/devices/machine/hp_taco.h b/src/devices/machine/hp_taco.h index 4a34ec420ed..ffd8c928ed7 100644 --- a/src/devices/machine/hp_taco.h +++ b/src/devices/machine/hp_taco.h @@ -182,6 +182,7 @@ private: void set_data_timeout(bool long_timeout); void cmd_fsm(void); void start_cmd_exec(UINT16 new_cmd_reg); + bool internal_load(bool is_create); }; // device type definition diff --git a/src/devices/machine/keyboard.ipp b/src/devices/machine/keyboard.ipp index 91c6992962e..b96954dd8bc 100644 --- a/src/devices/machine/keyboard.ipp +++ b/src/devices/machine/keyboard.ipp @@ -5,6 +5,11 @@ #pragma once +// Work around for MSVC warning that identifies some of these as unused +#ifdef _MSC_VER +#pragma warning ( disable : 4505 ) +#endif + #include "keyboard.h" #include diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index 50e6dc09836..57d5a6f0edb 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); } @@ -987,8 +987,8 @@ 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); + chdtrack = (std::max)(chdtrack, 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/machine/strata.cpp b/src/devices/machine/strata.cpp index 4f7006f4d99..0bf396d83ef 100644 --- a/src/devices/machine/strata.cpp +++ b/src/devices/machine/strata.cpp @@ -94,7 +94,7 @@ void strataflash_device::nvram_read(emu_file &file) for (i = 0; i < FEEPROM_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } // protection registers @@ -103,7 +103,7 @@ void strataflash_device::nvram_read(emu_file &file) for (i = 0; i < PROT_REGS_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } // block lock flags @@ -142,28 +142,28 @@ void strataflash_device::nvram_write(emu_file &file) for (i = 0; i < FEEPROM_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } if (file->write(m_flashmemory, FEEPROM_SIZE) != FEEPROM_SIZE) return 1; for (i = 0; i < FEEPROM_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_flashmemory[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } // protection registers for (i = 0; i < PROT_REGS_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } if (file->write(m_prot_regs, PROT_REGS_SIZE) != PROT_REGS_SIZE) return 1; for (i = 0; i < PROT_REGS_SIZE; i += 2) { UINT16 *ptr = (UINT16 *) (&m_prot_regs[i]); - *ptr = LITTLE_ENDIANIZE_INT16(*ptr); + *ptr = little_endianize_int16(*ptr); } // block lock flags 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/cdda.cpp b/src/devices/sound/cdda.cpp index 3223142a062..45ef2a1dc42 100644 --- a/src/devices/sound/cdda.cpp +++ b/src/devices/sound/cdda.cpp @@ -189,8 +189,8 @@ void cdda_device::get_audio_data(stream_sample_t *bufL, stream_sample_t *bufR, U for (i = 0; i < samples; i++) { /* CD-DA data on the disc is big-endian */ - *bufL++ = (INT16) BIG_ENDIANIZE_INT16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; - *bufR++ = (INT16) BIG_ENDIANIZE_INT16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; + *bufL++ = (INT16) big_endianize_int16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; + *bufR++ = (INT16) big_endianize_int16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; } samples_wanted -= samples; 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/samples.cpp b/src/devices/sound/samples.cpp index 0b92b51202d..44627261377 100644 --- a/src/devices/sound/samples.cpp +++ b/src/devices/sound/samples.cpp @@ -429,7 +429,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) osd_printf_warning("Unexpected size offset %u (%s)\n", offset, file.filename()); return false; } - filesize = LITTLE_ENDIANIZE_INT32(filesize); + filesize = little_endianize_int32(filesize); // read the RIFF file type and make sure it's a WAVE file char buf[32]; @@ -451,7 +451,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) { offset += file.read(buf, 4); offset += file.read(&length, 4); - length = LITTLE_ENDIANIZE_INT32(length); + length = little_endianize_int32(length); if (memcmp(&buf[0], "fmt ", 4) == 0) break; @@ -468,7 +468,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) // read the format -- make sure it is PCM UINT16 temp16; offset += file.read(&temp16, 2); - temp16 = LITTLE_ENDIANIZE_INT16(temp16); + temp16 = little_endianize_int16(temp16); if (temp16 != 1) { osd_printf_warning("unsupported format %u - only PCM is supported (%s)\n", temp16, file.filename()); @@ -477,7 +477,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) // number of channels -- only mono is supported offset += file.read(&temp16, 2); - temp16 = LITTLE_ENDIANIZE_INT16(temp16); + temp16 = little_endianize_int16(temp16); if (temp16 != 1) { osd_printf_warning("unsupported number of channels %u - only mono is supported (%s)\n", temp16, file.filename()); @@ -487,7 +487,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) // sample rate UINT32 rate; offset += file.read(&rate, 4); - rate = LITTLE_ENDIANIZE_INT32(rate); + rate = little_endianize_int32(rate); // bytes/second and block alignment are ignored offset += file.read(buf, 6); @@ -495,7 +495,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) // bits/sample UINT16 bits; offset += file.read(&bits, 2); - bits = LITTLE_ENDIANIZE_INT16(bits); + bits = little_endianize_int16(bits); if (bits != 8 && bits != 16) { osd_printf_warning("unsupported bits/sample %u - only 8 and 16 are supported (%s)\n", bits, file.filename()); @@ -511,7 +511,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) { offset += file.read(buf, 4); offset += file.read(&length, 4); - length = LITTLE_ENDIANIZE_INT32(length); + length = little_endianize_int32(length); if (memcmp(&buf[0], "data", 4) == 0) break; @@ -555,7 +555,7 @@ bool samples_device::read_wav_sample(emu_file &file, sample_t &sample) // swap high/low on big-endian systems if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) for (UINT32 sindex = 0; sindex < length / 2; sindex++) - sample.data[sindex] = LITTLE_ENDIANIZE_INT16(sample.data[sindex]); + sample.data[sindex] = little_endianize_int16(sample.data[sindex]); } return true; } 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..70975527c32 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, 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..024ba3d777a 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)) @@ -1142,7 +1142,7 @@ void cgb_lcd_device::update_sprites() data = *((UINT16 *) &m_vram[((oam[3] & 0x8)<<10) + (oam[2] & tilemask) * 16 + (line - oam[0]) * 2]); } - data = LITTLE_ENDIANIZE_INT16(data); + data = little_endianize_int16(data); switch (oam[3] & 0xA0) { @@ -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_array; typedef poly_array<_ObjectData, _MaxPolys + 1> objectdata_array; - typedef poly_array unit_array; + typedef poly_array 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 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..0d6a872ed6d 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, 65535U); 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/debugcon.cpp b/src/emu/debug/debugcon.cpp index 9ce385554ee..b90c9e0d556 100644 --- a/src/emu/debug/debugcon.cpp +++ b/src/emu/debug/debugcon.cpp @@ -332,7 +332,7 @@ CMDERR debugger_console::execute_command(const char *command, bool echo) printf(">%s\n", command); /* parse and execute */ - result = internal_parse_command(command, TRUE); + result = internal_parse_command(command, true); /* display errors */ if (result != CMDERR_NONE) diff --git a/src/emu/debug/dvmemory.cpp b/src/emu/debug/dvmemory.cpp index 47a046081a4..51899cdf54f 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(), 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(1U, 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(*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/diimage.cpp b/src/emu/diimage.cpp index 79db5ab471c..f587ff80cc2 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -228,6 +228,27 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo } +//------------------------------------------------- +// add_format +//------------------------------------------------- + +void device_image_interface::add_format(std::unique_ptr &&format) +{ + m_formatlist.push_back(std::move(format)); +} + + +//------------------------------------------------- +// add_format +//------------------------------------------------- + +void device_image_interface::add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec) +{ + auto format = std::make_unique(std::move(name), std::move(description), std::move(extensions), std::move(optspec)); + add_format(std::move(format)); +} + + /**************************************************************************** ERROR HANDLING ****************************************************************************/ @@ -946,7 +967,7 @@ bool device_image_interface::load_internal(const std::string &path, bool is_crea m_create_args = create_args; if (m_init_phase==false) { - m_err = (image_error_t)finish_load(); + m_err = (finish_load()==IMAGE_INIT_PASS) ? IMAGE_ERROR_SUCCESS : IMAGE_ERROR_INTERNAL; if (m_err) goto done; } @@ -1109,10 +1130,10 @@ bool device_image_interface::finish_load() { image_checkhash(); - if (has_been_created()) + if (m_created) { err = call_create(m_create_format, m_create_args); - if (err) + if (err == IMAGE_INIT_FAIL) { if (!m_err) m_err = IMAGE_ERROR_UNSPECIFIED; @@ -1122,7 +1143,7 @@ bool device_image_interface::finish_load() { // using device load err = call_load(); - if (err) + if (err == IMAGE_INIT_FAIL) { if (!m_err) m_err = IMAGE_ERROR_UNSPECIFIED; diff --git a/src/emu/diimage.h b/src/emu/diimage.h index cb6069cae78..cf0c6c87338 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -101,7 +101,7 @@ class software_part; class software_info; // device image interface function types -typedef delegate device_image_load_delegate; +typedef delegate device_image_load_delegate; typedef delegate device_image_func_delegate; // legacy typedef void (*device_image_partialhash_func)(util::hash_collection &, const unsigned char *, unsigned long, const char *); @@ -110,15 +110,13 @@ typedef void (*device_image_partialhash_func)(util::hash_collection &, const uns // MACROS //************************************************************************** -#define IMAGE_INIT_PASS FALSE -#define IMAGE_INIT_FAIL TRUE -#define IMAGE_VERIFY_PASS FALSE -#define IMAGE_VERIFY_FAIL TRUE +#define IMAGE_INIT_PASS false +#define IMAGE_INIT_FAIL true #define DEVICE_IMAGE_LOAD_MEMBER_NAME(_name) device_image_load_##_name #define DEVICE_IMAGE_LOAD_NAME(_class,_name) _class::DEVICE_IMAGE_LOAD_MEMBER_NAME(_name) -#define DECLARE_DEVICE_IMAGE_LOAD_MEMBER(_name) int DEVICE_IMAGE_LOAD_MEMBER_NAME(_name)(device_image_interface &image) -#define DEVICE_IMAGE_LOAD_MEMBER(_class,_name) int DEVICE_IMAGE_LOAD_NAME(_class,_name)(device_image_interface &image) +#define DECLARE_DEVICE_IMAGE_LOAD_MEMBER(_name) bool DEVICE_IMAGE_LOAD_MEMBER_NAME(_name)(device_image_interface &image) +#define DEVICE_IMAGE_LOAD_MEMBER(_class,_name) bool DEVICE_IMAGE_LOAD_NAME(_class,_name)(device_image_interface &image) #define DEVICE_IMAGE_LOAD_DELEGATE(_class,_name) device_image_load_delegate(&DEVICE_IMAGE_LOAD_NAME(_class,_name),#_class "::device_image_load_" #_name, downcast<_class *>(device->owner())) #define DEVICE_IMAGE_UNLOAD_MEMBER_NAME(_name) device_image_unload_##_name @@ -149,12 +147,12 @@ public: virtual void device_compute_hash(util::hash_collection &hashes, const void *data, size_t length, const char *types) const; - virtual bool call_load() { return FALSE; } - virtual bool call_create(int format_type, util::option_resolution *format_options) { return FALSE; } + virtual bool call_load() { return IMAGE_INIT_PASS; } + virtual bool call_create(int format_type, util::option_resolution *format_options) { return IMAGE_INIT_PASS; } virtual void call_unload() { } virtual std::string call_display() { return std::string(); } virtual device_image_partialhash_func get_partial_hash() const { return nullptr; } - virtual bool core_opens_image_file() const { return TRUE; } + virtual bool core_opens_image_file() const { return true; } virtual iodevice_t image_type() const = 0; virtual bool is_readable() const = 0; virtual bool is_writeable() const = 0; @@ -182,7 +180,6 @@ public: util::core_file &image_core_file() const { return *m_file; } UINT64 length() { check_for_file(); return m_file->size(); } bool is_readonly() const { return m_readonly; } - bool has_been_created() const { return m_created; } void make_readonly() { m_readonly = true; } UINT32 fread(void *buffer, UINT32 length) { check_for_file(); return m_file->read(buffer, length); } UINT32 fread(optional_shared_ptr &ptr, UINT32 length) { ptr.allocate(length); return fread(ptr.target(), length); } @@ -195,7 +192,7 @@ public: int image_feof() { check_for_file(); return m_file->eof(); } void *ptr() {check_for_file(); return const_cast(m_file->buffer()); } // configuration access - void set_init_phase() { m_init_phase = TRUE; } + void set_init_phase() { m_init_phase = true; } const char* longname() const { return m_longname.c_str(); } const char* manufacturer() const { return m_manufacturer.c_str(); } @@ -279,6 +276,9 @@ protected: bool load_software_part(const char *path, const software_part *&swpart); std::string software_get_default_slot(const char *default_card_slot) const; + void add_format(std::unique_ptr &&format); + void add_format(std::string &&name, std::string &&description, std::string &&extensions, std::string &&optspec); + // derived class overrides // configuration @@ -326,9 +326,6 @@ protected: std::string m_brief_instance_name; std::string m_instance_name; - // creation info - formatlist_type m_formatlist; - // in the case of arcade cabinet with fixed carts inserted, // we want to disable command line cart loading... bool m_user_loadable; @@ -338,6 +335,9 @@ protected: private: static image_error_t image_error_from_file_error(osd_file::error filerr); bool schedule_postload_hard_reset_if_needed(); + + // creation info + formatlist_type m_formatlist; }; // iterator 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..6e87f0826b3 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -718,7 +718,7 @@ bool input_seq::is_valid() const // non-switch items can't have a NOT input_item_class itemclass = code.item_class(); if (itemclass != ITEM_CLASS_SWITCH && lastcode == not_code) - return FALSE; + return false; // absolute/relative items must all be the same class if ((lastclass == ITEM_CLASS_ABSOLUTE && itemclass != ITEM_CLASS_ABSOLUTE) || @@ -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(*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..43649e3f886 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 @@ -3302,11 +3302,11 @@ _Type ioport_manager::playback_read(_Type &result) // return the appropriate value else if (sizeof(result) == 8) - result = LITTLE_ENDIANIZE_INT64(result); + result = little_endianize_int64(result); else if (sizeof(result) == 4) - result = LITTLE_ENDIANIZE_INT32(result); + result = little_endianize_int32(result); else if (sizeof(result) == 2) - result = LITTLE_ENDIANIZE_INT16(result); + result = little_endianize_int16(result); return result; } @@ -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..5b15bc4498e 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, float(m_int_overscan ? render_round_nearest(xscale) : floor(xscale))); + float maxyscale = std::max(1.0f, float(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..2f27fd0e506 100644 --- a/src/emu/rendfont.cpp +++ b/src/emu/rendfont.cpp @@ -18,6 +18,8 @@ #include "ui/cmdrender.h" +const UINT64 render_font::CACHED_BDF_HASH_SIZE; + //************************************************************************** // INLINE FUNCTIONS //************************************************************************** @@ -482,8 +484,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..eabf943eb1e 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)); @@ -576,13 +576,13 @@ int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp // is actually a concatenation of: listname + setname + parentname // separated by '%' (parentname being present only for clones) std::string tag1(regiontag), tag2, tag3, tag4, tag5; - bool is_list = FALSE; - bool has_parent = FALSE; + bool is_list = false; + bool has_parent = false; int separator1 = tag1.find_first_of('%'); if (separator1 != -1) { - is_list = TRUE; + is_list = true; // we are loading through softlists, split the listname from the regiontag tag4.assign(tag1.substr(separator1 + 1, tag1.length() - separator1 + 1)); @@ -593,7 +593,7 @@ int rom_load_manager::open_rom_file(const char *regiontag, const rom_entry *romp int separator2 = tag4.find_first_of('%'); if (separator2 != -1) { - has_parent = TRUE; + has_parent = true; // we are loading a clone through softlists, split the setname from the parentname tag5.assign(tag4.substr(separator2 + 1, tag4.length() - separator2 + 1)); @@ -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 */ @@ -983,13 +983,13 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ // is actually a concatenation of: listname + setname + parentname // separated by '%' (parentname being present only for clones) std::string tag1(locationtag), tag2, tag3, tag4, tag5; - bool is_list = FALSE; - bool has_parent = FALSE; + bool is_list = false; + bool has_parent = false; int separator1 = tag1.find_first_of('%'); if (separator1 != -1) { - is_list = TRUE; + is_list = true; // we are loading through softlists, split the listname from the regiontag tag4.assign(tag1.substr(separator1 + 1, tag1.length() - separator1 + 1)); @@ -1000,7 +1000,7 @@ int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_ int separator2 = tag4.find_first_of('%'); if (separator2 != -1) { - has_parent = TRUE; + has_parent = true; // we are loading a clone through softlists, split the setname from the parentname tag5.assign(tag4.substr(separator2 + 1, tag4.length() - separator2 + 1)); @@ -1357,7 +1357,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list /* now process the entries in the region */ if (ROMREGION_ISROMDATA(region)) - process_rom_entries(locationtag.c_str(), region, region + 1, &device, TRUE); + process_rom_entries(locationtag.c_str(), region, region + 1, &device, true); else if (ROMREGION_ISDISKDATA(region)) process_disk_entries(regiontag.c_str(), region, region + 1, locationtag.c_str()); } @@ -1370,7 +1370,7 @@ void rom_load_manager::load_software_part_region(device_t &device, software_list } /* display the results and exit */ - display_rom_load_results(TRUE); + display_rom_load_results(true); } @@ -1422,7 +1422,7 @@ void rom_load_manager::process_region_list() #endif /* now process the entries in the region */ - process_rom_entries(device.shortname(), region, region + 1, &device, FALSE); + process_rom_entries(device.shortname(), region, region + 1, &device, false); } else if (ROMREGION_ISDISKDATA(region)) process_disk_entries(regiontag.c_str(), region, region + 1, nullptr); @@ -1483,5 +1483,5 @@ rom_load_manager::rom_load_manager(running_machine &machine) process_region_list(); /* display the results and exit */ - display_rom_load_results(FALSE); + display_rom_load_results(false); } diff --git a/src/emu/save.cpp b/src/emu/save.cpp index d747475fa34..0dd66cd2e82 100644 --- a/src/emu/save.cpp +++ b/src/emu/save.cpp @@ -298,7 +298,7 @@ save_error save_manager::write_file(emu_file &file) header[9] = NATIVE_ENDIAN_VALUE_LE_BE(0, SS_MSB_FIRST); strncpy((char *)&header[0x0a], machine().system().name, 0x1c - 0x0a); UINT32 sig = signature(); - *(UINT32 *)&header[0x1c] = LITTLE_ENDIANIZE_INT32(sig); + *(UINT32 *)&header[0x1c] = little_endianize_int32(sig); // write the header and turn on compression for the rest of the file file.compress(FCOMPRESS_NONE); @@ -337,8 +337,8 @@ UINT32 save_manager::signature() const // add the type and size to the CRC UINT32 temp[2]; - temp[0] = LITTLE_ENDIANIZE_INT32(entry->m_typecount); - temp[1] = LITTLE_ENDIANIZE_INT32(entry->m_typesize); + temp[0] = little_endianize_int32(entry->m_typecount); + temp[1] = little_endianize_int32(entry->m_typesize); crc = core_crc32(crc, (UINT8 *)&temp[0], sizeof(temp)); } return crc; @@ -393,10 +393,10 @@ save_error save_manager::validate_header(const UINT8 *header, const char *gamena if (signature != 0) { UINT32 rawsig = *(UINT32 *)&header[0x1c]; - if (signature != LITTLE_ENDIANIZE_INT32(rawsig)) + if (signature != little_endianize_int32(rawsig)) { if (errormsg != nullptr) - (*errormsg)("%sIncompatible save file (signature %08x, expected %08x)", error_prefix, LITTLE_ENDIANIZE_INT32(rawsig), signature); + (*errormsg)("%sIncompatible save file (signature %08x, expected %08x)", error_prefix, little_endianize_int32(rawsig), signature); return STATERR_INVALID_HEADER; } } @@ -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..9e1c4e3ebae 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) @@ -1143,14 +1143,14 @@ bool screen_device::update_partial(int scanline) if (machine().video().skip_this_frame()) { LOG_PARTIAL_UPDATES(("skipped due to frameskipping\n")); - return FALSE; + return false; } // skip if this screen is not visible anywhere if (!machine().render().is_live(*this)) { LOG_PARTIAL_UPDATES(("skipped because screen not live\n")); - return FALSE; + return false; } } @@ -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..13c90f7a283 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(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(m_numlines, m_output.size()); for (auto & elem : m_output) elem.clear(); diff --git a/src/frontend/mame/clifront.cpp b/src/frontend/mame/clifront.cpp index 0dfaa4c97dd..2ce5a6a5581 100644 --- a/src/frontend/mame/clifront.cpp +++ b/src/frontend/mame/clifront.cpp @@ -1620,7 +1620,7 @@ void cli_frontend::getsoftlist(const char *gamename) { FILE *out = stdout; std::unordered_set list_map; - bool isfirst = TRUE; + bool isfirst = true; driver_enumerator drivlist(m_options); while (drivlist.next()) @@ -1629,7 +1629,7 @@ void cli_frontend::getsoftlist(const char *gamename) if (core_strwildcmp(gamename, swlistdev.list_name()) == 0 && list_map.insert(swlistdev.list_name()).second) if (!swlistdev.get_info().empty()) { - if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = FALSE; } + if (isfirst) { fprintf( out, SOFTLIST_XML_BEGIN); isfirst = false; } output_single_softlist(out, swlistdev); } } diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp index ef7b4bcf61f..918cd07f673 100644 --- a/src/frontend/mame/info.cpp +++ b/src/frontend/mame/info.cpp @@ -268,12 +268,12 @@ void info_xml_creator::output_one() { if (field.type() == IPT_KEYBOARD) { - if (!new_kbd) new_kbd = TRUE; + if (!new_kbd) new_kbd = true; field.set_player(field.player() + kbd_offset); } else { - nplayers = MAX(nplayers, field.player() + 1); + nplayers = std::max(nplayers, field.player() + 1); field.set_player(field.player() + player_offset); } } @@ -355,11 +355,11 @@ void info_xml_creator::output_one() void info_xml_creator::output_one_device(device_t &device, const char *devtag) { - bool has_speaker = FALSE, has_input = FALSE; + bool has_speaker = false, has_input = false; // check if the device adds speakers to the system sound_interface_iterator snditer(device); if (snditer.first() != nullptr) - has_speaker = TRUE; + has_speaker = true; // generate input list ioport_list portlist; std::string errors; @@ -370,7 +370,7 @@ void info_xml_creator::output_one_device(device_t &device, const char *devtag) for (ioport_field &field : port.second->fields()) if (field.type() >= IPT_START1 && field.type() < IPT_UI_FIRST) { - has_input = TRUE; + has_input = true; break; } @@ -894,7 +894,7 @@ void info_xml_creator::output_input(const ioport_list &portlist) for (auto &port : portlist) { int ctrl_type = CTRL_DIGITAL_BUTTONS; - bool ctrl_analog = FALSE; + bool ctrl_analog = false; for (ioport_field &field : port.second->fields()) { // track the highest player number @@ -996,75 +996,75 @@ void info_xml_creator::output_input(const ioport_list &portlist) case IPT_AD_STICK_X: case IPT_AD_STICK_Y: case IPT_AD_STICK_Z: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_JOYSTICK; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "stick"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_PADDLE: case IPT_PADDLE_V: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_PADDLE; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "paddle"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_PEDAL: case IPT_PEDAL2: case IPT_PEDAL3: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_PEDAL; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "pedal"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_LIGHTGUN_X: case IPT_LIGHTGUN_Y: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_LIGHTGUN; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "lightgun"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_POSITIONAL: case IPT_POSITIONAL_V: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_POSITIONAL; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "positional"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_DIAL: case IPT_DIAL_V: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_DIAL; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "dial"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_TRACKBALL_X: case IPT_TRACKBALL_Y: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_TRACKBALL; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "trackball"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; case IPT_MOUSE_X: case IPT_MOUSE_Y: - ctrl_analog = TRUE; + ctrl_analog = true; ctrl_type = CTRL_ANALOG_MOUSE; control_info[field.player() * CTRL_COUNT + ctrl_type].type = "mouse"; control_info[field.player() * CTRL_COUNT + ctrl_type].player = field.player() + 1; - control_info[field.player() * CTRL_COUNT + ctrl_type].analog = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].analog = true; break; // map buttons @@ -1084,14 +1084,14 @@ void info_xml_creator::output_input(const ioport_list &portlist) case IPT_BUTTON14: case IPT_BUTTON15: case IPT_BUTTON16: - ctrl_analog = FALSE; + ctrl_analog = false; if (control_info[field.player() * CTRL_COUNT + ctrl_type].type == nullptr) { control_info[field.player() * CTRL_COUNT + ctrl_type].type = "only_buttons"; 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].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 @@ -1184,7 +1184,7 @@ void info_xml_creator::output_input(const ioport_list &portlist) if (field.delta() != 0) control_info[field.player() * CTRL_COUNT + ctrl_type].keydelta = field.delta(); if (field.analog_reverse() != 0) - control_info[field.player() * CTRL_COUNT + ctrl_type].reverse = TRUE; + control_info[field.player() * CTRL_COUNT + ctrl_type].reverse = true; } } } @@ -1196,16 +1196,16 @@ void info_xml_creator::output_input(const ioport_list &portlist) // for lightguns) and therefore we really need this separate loop. for (int i = 0; i < CTRL_PCOUNT; i++) { - bool fix_done = FALSE; + bool fix_done = false; for (int j = 1; j < CTRL_COUNT; j++) if (control_info[i * CTRL_COUNT].type != nullptr && control_info[i * CTRL_COUNT + j].type != nullptr && !fix_done) { 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; + fix_done = true; } } diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 52af1b85bef..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(sc_width); - y1 = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast(sc_height); - x2 = MIN(MAX(0, (float) lua_tonumber(L, 4)), sc_width-1) / static_cast(sc_width); - y2 = MIN(MAX(0, (float) lua_tonumber(L, 5)), sc_height-1) / static_cast(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(sc_width); - y1 = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast(sc_height); - x2 = MIN(MAX(0, (float) lua_tonumber(L, 4)), sc_width-1) / static_cast(sc_width); - y2 = MIN(MAX(0, (float) lua_tonumber(L, 5)), sc_height-1) / static_cast(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(sc_width); - y = MIN(MAX(0, (float) lua_tonumber(L, 3)), sc_height-1) / static_cast(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 { @@ -2006,7 +2006,8 @@ void lua_engine::menu_populate(std::string &menu, std::vector &menu_l { if(lua_istable(m_lua_state, -1)) { - menu_item item; + menu_list.emplace_back(); + menu_item &item = menu_list.back(); lua_rawgeti(m_lua_state, -1, 1); item.text = lua_tostring(m_lua_state, -1); lua_pop(m_lua_state, 1); @@ -2016,7 +2017,6 @@ void lua_engine::menu_populate(std::string &menu, std::vector &menu_l lua_rawgeti(m_lua_state, -1, 3); item.flags = lua_tostring(m_lua_state, -1); lua_pop(m_lua_state, 1); - menu_list.push_back(item); } lua_pop(m_lua_state, 1); } 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/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp index 87fa7ff0a60..485e2f41130 100644 --- a/src/frontend/mame/ui/filemngr.cpp +++ b/src/frontend/mame/ui/filemngr.cpp @@ -40,7 +40,7 @@ menu_file_manager::menu_file_manager(mame_ui_manager &mui, render_container &con else m_warnings.clear(); - m_curr_selected = FALSE; + m_curr_selected = false; } @@ -180,7 +180,7 @@ void menu_file_manager::handle() selected_device = (device_image_interface *) event->itemref; if (selected_device != nullptr) { - m_curr_selected = TRUE; + m_curr_selected = true; floppy_image_device *floppy_device = dynamic_cast(selected_device); if (floppy_device != nullptr) { 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..7394f03be2f 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -281,7 +281,7 @@ void mame_ui_manager::display_startup_screens(bool first_time) // disable everything if we are using -str for 300 or fewer seconds, or if we're the empty driver, // or if we are debugging if (!first_time || (str > 0 && str < 60*5) || &machine().system() == &GAME_NAME(___empty) || (machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) - show_gameinfo = show_warnings = show_mandatory_fileman = FALSE; + show_gameinfo = show_warnings = show_mandatory_fileman = false; #if defined(EMSCRIPTEN) // also disable for the JavaScript port since the startup screens do not run asynchronously @@ -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/ap_dsk35.cpp b/src/lib/formats/ap_dsk35.cpp index 5af4c2b5bcd..baa60254b4b 100644 --- a/src/lib/formats/ap_dsk35.cpp +++ b/src/lib/formats/ap_dsk35.cpp @@ -933,11 +933,11 @@ static floperr_t apple35_diskcopy_headerdecode(floppy_image_legacy *floppy, UINT floppy_image_read(floppy, &header, 0, sizeof(header)); - header.data_size = BIG_ENDIANIZE_INT32(header.data_size); - header.tag_size = BIG_ENDIANIZE_INT32(header.tag_size); - header.data_checksum = BIG_ENDIANIZE_INT32(header.data_checksum); - header.tag_checksum = BIG_ENDIANIZE_INT32(header.tag_checksum); - header.magic = BIG_ENDIANIZE_INT16(header.magic); + header.data_size = big_endianize_int32(header.data_size); + header.tag_size = big_endianize_int32(header.tag_size); + header.data_checksum = big_endianize_int32(header.data_checksum); + header.tag_checksum = big_endianize_int32(header.tag_checksum); + header.magic = big_endianize_int16(header.magic); if (header.disk_name[0] >= sizeof(header.disk_name)) return FLOPPY_ERROR_INVALIDIMAGE; @@ -1001,10 +1001,10 @@ static FLOPPY_CONSTRUCT(apple35_diskcopy_construct) tag_size = 80*sides*10*12; memset(&header, 0, sizeof(header)); - header.data_size = BIG_ENDIANIZE_INT32(data_size); - header.tag_size = BIG_ENDIANIZE_INT32(tag_size); + header.data_size = big_endianize_int32(data_size); + header.tag_size = big_endianize_int32(tag_size); header.disk_format = (sides > 1) ? 1 : 0; - header.magic = BIG_ENDIANIZE_INT16(0x100); + header.magic = big_endianize_int16(0x100); floppy_image_write(floppy, &header, 0, sizeof(header)); floppy_image_write_filler(floppy, 0, sizeof(header), data_size + tag_size); @@ -1077,17 +1077,17 @@ static floperr_t apple35_2img_decode(floppy_image_legacy *floppy, UINT32 *image_ return FLOPPY_ERROR_INVALIDIMAGE; } - header.header_length = LITTLE_ENDIANIZE_INT16(header.header_length); - header.version = LITTLE_ENDIANIZE_INT16(header.version); - header.image_format = LITTLE_ENDIANIZE_INT32(header.image_format); - header.flags = LITTLE_ENDIANIZE_INT32(header.flags); - header.block_count = LITTLE_ENDIANIZE_INT32(header.block_count); - header.data_offset = LITTLE_ENDIANIZE_INT32(header.data_offset); - header.data_length = LITTLE_ENDIANIZE_INT32(header.data_length); - header.comment_offset = LITTLE_ENDIANIZE_INT32(header.comment_offset); - header.comment_length = LITTLE_ENDIANIZE_INT32(header.comment_length); - header.creator_offset = LITTLE_ENDIANIZE_INT32(header.creator_offset); - header.creator_length = LITTLE_ENDIANIZE_INT32(header.creator_length); + header.header_length = little_endianize_int16(header.header_length); + header.version = little_endianize_int16(header.version); + header.image_format = little_endianize_int32(header.image_format); + header.flags = little_endianize_int32(header.flags); + header.block_count = little_endianize_int32(header.block_count); + header.data_offset = little_endianize_int32(header.data_offset); + header.data_length = little_endianize_int32(header.data_length); + header.comment_offset = little_endianize_int32(header.comment_offset); + header.comment_length = little_endianize_int32(header.comment_length); + header.creator_offset = little_endianize_int32(header.creator_offset); + header.creator_length = little_endianize_int32(header.creator_length); // at least some images "in the wild" (e.g. TOSEC Minor Set 1) have big-endian data sizes // even though that's against the .2mg spec @@ -1145,10 +1145,10 @@ static FLOPPY_CONSTRUCT(apple35_2img_construct) data_size = 80*sides*10*512; memset(&header, 0, sizeof(header)); - header.header_length = LITTLE_ENDIANIZE_INT16(sizeof(header)); - header.block_count = LITTLE_ENDIANIZE_INT32(80*sides*10); - header.data_offset = LITTLE_ENDIANIZE_INT32(data_offset); - header.data_length = LITTLE_ENDIANIZE_INT32(data_size); + header.header_length = little_endianize_int16(sizeof(header)); + header.block_count = little_endianize_int32(80*sides*10); + header.data_offset = little_endianize_int32(data_offset); + header.data_length = little_endianize_int32(data_size); floppy_image_write(floppy, &header, 0, sizeof(header)); floppy_image_write_filler(floppy, 0, sizeof(header), data_size); diff --git a/src/lib/formats/apridisk.cpp b/src/lib/formats/apridisk.cpp index b19e2c26bd7..a004d54ccd0 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(§or_header, 13, 1); UINT8 track = (UINT8) pick_integer_le(§or_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(unsigned(track))); + head_count = std::max(head_count, int(unsigned(head))); + sector_count = std::max(sector_count, int(unsigned(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..38403e598d2 100644 --- a/src/lib/formats/cassimg.cpp +++ b/src/lib/formats/cassimg.cpp @@ -13,6 +13,7 @@ #include "imageutl.h" #include "cassimg.h" +#include /* 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, 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)(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/csw_cas.cpp b/src/lib/formats/csw_cas.cpp index 336a9dde7cd..f2523ef839d 100644 --- a/src/lib/formats/csw_cas.cpp +++ b/src/lib/formats/csw_cas.cpp @@ -38,7 +38,7 @@ static UINT32 get_leuint32(const void *ptr) { UINT32 value; memcpy(&value, ptr, sizeof(value)); - return LITTLE_ENDIANIZE_INT32(value); + return little_endianize_int32(value); } static int mycaslen; diff --git a/src/lib/formats/d88_dsk.cpp b/src/lib/formats/d88_dsk.cpp index b676db7fd21..21c73fec5c0 100644 --- a/src/lib/formats/d88_dsk.cpp +++ b/src/lib/formats/d88_dsk.cpp @@ -420,7 +420,7 @@ int d88_format::identify(io_generic *io, UINT32 form_factor) UINT8 h[32]; io_generic_read(io, h, 0, 32); - if((LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x1c)) == size) && + if((little_endianize_int32(*(UINT32 *)(h+0x1c)) == size) && (h[0x1b] == 0x00 || h[0x1b] == 0x10 || h[0x1b] == 0x20 || h[0x1b] == 0x30 || h[0x1b] == 0x40)) return 100; @@ -481,7 +481,7 @@ bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) for(int track=0; track < track_count; track++) for(int head=0; head < head_count; head++) { - int pos = LITTLE_ENDIANIZE_INT32(track_pos[track * head_count + head]); + int pos = little_endianize_int32(track_pos[track * head_count + head]); if(!pos) continue; @@ -494,9 +494,9 @@ bool d88_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) io_generic_read(io, hs, pos, 16); pos += 16; - UINT16 size = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+14)); + UINT16 size = little_endianize_int16(*(UINT16 *)(hs+14)); if(i == 0) { - sector_count = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hs+4)); + sector_count = little_endianize_int16(*(UINT16 *)(hs+4)); // Support broken vfman converter if(sector_count == 0x1000) sector_count = 0x10; diff --git a/src/lib/formats/dsk_dsk.cpp b/src/lib/formats/dsk_dsk.cpp index 4987a5bb52b..528f30c24be 100644 --- a/src/lib/formats/dsk_dsk.cpp +++ b/src/lib/formats/dsk_dsk.cpp @@ -343,13 +343,13 @@ struct sector_header bool dsk_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) { UINT8 header[0x100]; - bool extendformat = FALSE; + bool extendformat = false; UINT64 image_size = io_generic_size(io); io_generic_read(io, &header, 0, sizeof(header)); if ( memcmp( header, EXT_FORMAT_HEADER, 16 ) ==0) { - extendformat = TRUE; + extendformat = true; } int heads = header[0x31]; diff --git a/src/lib/formats/fdd_dsk.cpp b/src/lib/formats/fdd_dsk.cpp index 2c564e3e306..46aa8976605 100644 --- a/src/lib/formats/fdd_dsk.cpp +++ b/src/lib/formats/fdd_dsk.cpp @@ -97,7 +97,7 @@ bool fdd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) secs[(track * 26) + sect] = hsec[2]; sec_sizes[(track * 26) + sect] = hsec[3]; fill_vals[(track * 26) + sect] = hsec[4]; - sec_offs[(track * 26) + sect] = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(hsec + 0x08)); + sec_offs[(track * 26) + sect] = little_endianize_int32(*(UINT32 *)(hsec + 0x08)); curr_track_size += (128 << hsec[3]); curr_num_sec++; 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/imageutl.h b/src/lib/formats/imageutl.h index a2369e8284a..7da4a184112 100644 --- a/src/lib/formats/imageutl.h +++ b/src/lib/formats/imageutl.h @@ -34,12 +34,12 @@ static inline void place_integer_be(void *ptr, size_t offset, size_t size, UINT6 switch(size) { case 2: - val16 = BIG_ENDIANIZE_INT16((UINT16) value); + val16 = big_endianize_int16((UINT16) value); memcpy(byte_ptr, &val16, sizeof(val16)); break; case 4: - val32 = BIG_ENDIANIZE_INT32((UINT32) value); + val32 = big_endianize_int32((UINT32) value); memcpy(byte_ptr, &val32, sizeof(val32)); break; @@ -71,12 +71,12 @@ static inline UINT64 pick_integer_be(const void *ptr, size_t offset, size_t size case 2: memcpy(&val16, byte_ptr, sizeof(val16)); - result = BIG_ENDIANIZE_INT16(val16); + result = big_endianize_int16(val16); break; case 4: memcpy(&val32, byte_ptr, sizeof(val32)); - result = BIG_ENDIANIZE_INT32(val32); + result = big_endianize_int32(val32); break; default: @@ -102,12 +102,12 @@ static inline void place_integer_le(void *ptr, size_t offset, size_t size, UINT6 switch(size) { case 2: - val16 = LITTLE_ENDIANIZE_INT16((UINT16) value); + val16 = little_endianize_int16((UINT16) value); memcpy(byte_ptr, &val16, sizeof(val16)); break; case 4: - val32 = LITTLE_ENDIANIZE_INT32((UINT32) value); + val32 = little_endianize_int32((UINT32) value); memcpy(byte_ptr, &val32, sizeof(val32)); break; @@ -139,12 +139,12 @@ static inline UINT64 pick_integer_le(const void *ptr, size_t offset, size_t size case 2: memcpy(&val16, byte_ptr, sizeof(val16)); - result = LITTLE_ENDIANIZE_INT16(val16); + result = little_endianize_int16(val16); break; case 4: memcpy(&val32, byte_ptr, sizeof(val32)); - result = LITTLE_ENDIANIZE_INT32(val32); + result = little_endianize_int32(val32); break; default: 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/formats/nfd_dsk.cpp b/src/lib/formats/nfd_dsk.cpp index 816498190a7..0691543cce6 100644 --- a/src/lib/formats/nfd_dsk.cpp +++ b/src/lib/formats/nfd_dsk.cpp @@ -129,7 +129,7 @@ bool nfd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) UINT8 mfm[164 * 26]; UINT8 sec_sizes[164 * 26]; - UINT32 hsize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x110)); + UINT32 hsize = little_endianize_int32(*(UINT32 *)(h+0x110)); int pos = 0x120; @@ -142,7 +142,7 @@ bool nfd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) // read sector map absolute location io_generic_read(io, hsec, pos, 4); pos += 4; - UINT32 secmap_addr = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(hsec)); + UINT32 secmap_addr = little_endianize_int32(*(UINT32 *)(hsec)); if (secmap_addr) { @@ -151,8 +151,8 @@ bool nfd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) // first WORD is # of sectors, second WORD is # of special data sectors io_generic_read(io, hsec, secmap_addr, 0x10); secmap_addr += 0x10; - num_secs[track] = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hsec)); - num_specials[track] = LITTLE_ENDIANIZE_INT16(*(UINT16 *)(hsec + 0x2)); + num_secs[track] = little_endianize_int16(*(UINT16 *)(hsec)); + num_specials[track] = little_endianize_int16(*(UINT16 *)(hsec + 0x2)); for (int sect = 0; sect < num_secs[track]; sect++) { @@ -177,7 +177,7 @@ bool nfd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) { io_generic_read(io, hsec, secmap_addr, 0x10); secmap_addr += 0x10; - curr_track_size += (hsec[9] + 1) * LITTLE_ENDIANIZE_INT32(*(UINT32 *)(hsec + 0x0a)); + curr_track_size += (hsec[9] + 1) * little_endianize_int32(*(UINT32 *)(hsec + 0x0a)); } } } diff --git a/src/lib/formats/pc98fdi_dsk.cpp b/src/lib/formats/pc98fdi_dsk.cpp index 1e6f1809536..c4c21d937f6 100644 --- a/src/lib/formats/pc98fdi_dsk.cpp +++ b/src/lib/formats/pc98fdi_dsk.cpp @@ -36,12 +36,12 @@ int pc98fdi_format::identify(io_generic *io, UINT32 form_factor) UINT8 h[32]; io_generic_read(io, h, 0, 32); - UINT32 hsize = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0x8)); - UINT32 psize = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0xc)); - UINT32 ssize = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0x10)); - UINT32 scnt = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0x14)); - UINT32 sides = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0x18)); - UINT32 ntrk = LITTLE_ENDIANIZE_INT32(*(UINT32 *) (h + 0x1c)); + UINT32 hsize = little_endianize_int32(*(UINT32 *) (h + 0x8)); + UINT32 psize = little_endianize_int32(*(UINT32 *) (h + 0xc)); + UINT32 ssize = little_endianize_int32(*(UINT32 *) (h + 0x10)); + UINT32 scnt = little_endianize_int32(*(UINT32 *) (h + 0x14)); + UINT32 sides = little_endianize_int32(*(UINT32 *) (h + 0x18)); + UINT32 ntrk = little_endianize_int32(*(UINT32 *) (h + 0x1c)); if(size == hsize + psize && psize == ssize*scnt*sides*ntrk) return 100; @@ -54,11 +54,11 @@ bool pc98fdi_format::load(io_generic *io, UINT32 form_factor, floppy_image *imag io_generic_read(io, h, 0, 32); - UINT32 hsize = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x8)); - UINT32 sector_size = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x10)); - UINT32 sector_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x14)); - UINT32 head_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x18)); - UINT32 track_count = LITTLE_ENDIANIZE_INT32(*(UINT32 *)(h+0x1c)); + UINT32 hsize = little_endianize_int32(*(UINT32 *)(h+0x8)); + UINT32 sector_size = little_endianize_int32(*(UINT32 *)(h+0x10)); + UINT32 sector_count = little_endianize_int32(*(UINT32 *)(h+0x14)); + UINT32 head_count = little_endianize_int32(*(UINT32 *)(h+0x18)); + UINT32 track_count = little_endianize_int32(*(UINT32 *)(h+0x1c)); int cell_count = form_factor == floppy_image::FF_35 ? 200000 : 166666; diff --git a/src/lib/formats/wavfile.cpp b/src/lib/formats/wavfile.cpp index 1cb4746f39c..f827102a57b 100644 --- a/src/lib/formats/wavfile.cpp +++ b/src/lib/formats/wavfile.cpp @@ -27,7 +27,7 @@ static UINT32 get_leuint32(const void *ptr) { UINT32 value; memcpy(&value, ptr, sizeof(value)); - return LITTLE_ENDIANIZE_INT32(value); + return little_endianize_int32(value); } @@ -36,14 +36,14 @@ static UINT16 get_leuint16(const void *ptr) { UINT16 value; memcpy(&value, ptr, sizeof(value)); - return LITTLE_ENDIANIZE_INT16(value); + return little_endianize_int16(value); } static void put_leuint32(void *ptr, UINT32 value) { - value = LITTLE_ENDIANIZE_INT32(value); + value = little_endianize_int32(value); memcpy(ptr, &value, sizeof(value)); } @@ -51,7 +51,7 @@ static void put_leuint32(void *ptr, UINT32 value) static void put_leuint16(void *ptr, UINT16 value) { - value = LITTLE_ENDIANIZE_INT16(value); + value = little_endianize_int16(value); memcpy(ptr, &value, sizeof(value)); } diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp index 08fa138a177..6efae25a654 100644 --- a/src/lib/util/aviio.cpp +++ b/src/lib/util/aviio.cpp @@ -1760,7 +1760,7 @@ avi_file::error avi_file_impl::read_sound_samples(int channel, std::uint32_t fir base += stream->channels() * (firstsample - chunkbase) + offset; for (sampnum = 0; sampnum < samples_this_chunk; sampnum++) { - *output++ = LITTLE_ENDIANIZE_INT16(*base); + *output++ = little_endianize_int16(*base); base += stream->channels(); } } @@ -1939,13 +1939,13 @@ avi_file::error avi_file_impl::append_sound_samples(int channel, const std::int1 { std::int16_t data = *samples++; samples += sampleskip; - data = LITTLE_ENDIANIZE_INT16(data); + data = little_endianize_int16(data); m_soundbuf[sampoffset++ * m_info.audio_channels + channel] = data; } m_soundbuf_chansamples[channel] = sampoffset; /* flush any full sound chunks to disk */ - return soundbuf_flush(TRUE); + return soundbuf_flush(true); } 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..07da646dca3 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)(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))); // 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, sizeof(buffer)); file_write(offset, buffer, bytes_to_write); offset += bytes_to_write; mapsize -= bytes_to_write; diff --git a/src/lib/util/chdcd.cpp b/src/lib/util/chdcd.cpp index 4e3fb152eb3..76da08b6b9e 100644 --- a/src/lib/util/chdcd.cpp +++ b/src/lib/util/chdcd.cpp @@ -245,7 +245,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) printf("ERROR: unexpected size offset %lu (%s)\n", offset, filename); return 0; } - filesize = LITTLE_ENDIANIZE_INT32(filesize); + filesize = little_endianize_int32(filesize); /* read the RIFF file type and make sure it's a WAVE file */ file->read(buf, offset, 4, actual); @@ -268,7 +268,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) offset += actual; file->read(&length, offset, 4, actual); offset += actual; - length = LITTLE_ENDIANIZE_INT32(length); + length = little_endianize_int32(length); if (memcmp(&buf[0], "fmt ", 4) == 0) break; @@ -284,7 +284,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) /* read the format -- make sure it is PCM */ file->read(&temp16, offset, 2, actual); offset += actual; - temp16 = LITTLE_ENDIANIZE_INT16(temp16); + temp16 = little_endianize_int16(temp16); if (temp16 != 1) { printf("ERROR: unsupported format %u - only PCM is supported (%s)\n", temp16, filename); @@ -294,7 +294,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) /* number of channels -- only stereo is supported */ file->read(&temp16, offset, 2, actual); offset += actual; - temp16 = LITTLE_ENDIANIZE_INT16(temp16); + temp16 = little_endianize_int16(temp16); if (temp16 != 2) { printf("ERROR: unsupported number of channels %u - only stereo is supported (%s)\n", temp16, filename); @@ -304,7 +304,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) /* sample rate */ file->read(&rate, offset, 4, actual); offset += actual; - rate = LITTLE_ENDIANIZE_INT32(rate); + rate = little_endianize_int32(rate); if (rate != 44100) { printf("ERROR: unsupported samplerate %u - only 44100 is supported (%s)\n", rate, filename); @@ -318,7 +318,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) /* bits/sample */ file->read(&bits, offset, 2, actual); offset += actual; - bits = LITTLE_ENDIANIZE_INT16(bits); + bits = little_endianize_int16(bits); if (bits != 16) { printf("ERROR: unsupported bits/sample %u - only 16 is supported (%s)\n", bits, filename); @@ -335,7 +335,7 @@ static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs) offset += actual; file->read(&length, offset, 4, actual); offset += actual; - length = LITTLE_ENDIANIZE_INT32(length); + length = little_endianize_int32(length); if (memcmp(&buf[0], "data", 4) == 0) break; 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/corefile.cpp b/src/lib/util/corefile.cpp index 8e52b942d2f..5fcd9e00239 100644 --- a/src/lib/util/corefile.cpp +++ b/src/lib/util/corefile.cpp @@ -463,12 +463,12 @@ int core_text_file::getc() case text_file_type::UTF32BE: if (read(&uchar, sizeof(uchar)) == sizeof(uchar)) - uchar = BIG_ENDIANIZE_INT32(uchar); + uchar = big_endianize_int32(uchar); break; case text_file_type::UTF32LE: if (read(&uchar, sizeof(uchar)) == sizeof(uchar)) - uchar = LITTLE_ENDIANIZE_INT32(uchar); + uchar = little_endianize_int32(uchar); break; } diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp index ced56cd3115..085eaacffef 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)(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)(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)(*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)(*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 //************************************************************************** @@ -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.cpp b/src/lib/util/options.cpp index 096499fe88c..f799ad06c97 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -17,6 +17,7 @@ #include +const int core_options::MAX_UNADORNED_OPTIONS; //************************************************************************** // GLOBAL VARIABLES 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..196031d3694 100644 --- a/src/lib/util/palette.cpp +++ b/src/lib/util/palette.cpp @@ -13,6 +13,7 @@ #include "palette.h" #include #include +#include //************************************************************************** @@ -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, y); + ymax = (std::max)(ymax, y); } // determine target minimum/maximum diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp index 73c43e9cf90..11c0bb4db7b 100644 --- a/src/lib/util/png.cpp +++ b/src/lib/util/png.cpp @@ -62,13 +62,13 @@ static inline UINT8 fetch_8bit(UINT8 *v) #ifdef UNUSED_FUNCTION static inline UINT16 fetch_16bit(UINT8 *v) { - return BIG_ENDIANIZE_INT16(*(UINT16 *)v); + return big_endianize_int16(*(UINT16 *)v); } #endif static inline UINT32 fetch_32bit(UINT8 *v) { - return BIG_ENDIANIZE_INT32(*(UINT32 *)v); + return big_endianize_int32(*(UINT32 *)v); } @@ -81,13 +81,13 @@ static inline void put_8bit(UINT8 *v, UINT8 data) #ifdef UNUSED_FUNCTION static inline void put_16bit(UINT8 *v, UINT16 data) { - *(UINT16 *)v = BIG_ENDIANIZE_INT16(data); + *(UINT16 *)v = big_endianize_int16(data); } #endif static inline void put_32bit(UINT8 *v, UINT32 data) { - *(UINT32 *)v = BIG_ENDIANIZE_INT32(data); + *(UINT32 *)v = big_endianize_int32(data); } 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 - +#include /*************************************************************************** @@ -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/lib/util/wavwrite.cpp b/src/lib/util/wavwrite.cpp index 7172873a14d..d052287216d 100644 --- a/src/lib/util/wavwrite.cpp +++ b/src/lib/util/wavwrite.cpp @@ -47,33 +47,33 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels) fwrite("fmt ", 1, 4, wav->file); /* write the format length */ - temp32 = LITTLE_ENDIANIZE_INT32(16); + temp32 = little_endianize_int32(16); fwrite(&temp32, 1, 4, wav->file); /* write the format (PCM) */ - temp16 = LITTLE_ENDIANIZE_INT16(1); + temp16 = little_endianize_int16(1); fwrite(&temp16, 1, 2, wav->file); /* write the channels */ - temp16 = LITTLE_ENDIANIZE_INT16(channels); + temp16 = little_endianize_int16(channels); fwrite(&temp16, 1, 2, wav->file); /* write the sample rate */ - temp32 = LITTLE_ENDIANIZE_INT32(sample_rate); + temp32 = little_endianize_int32(sample_rate); fwrite(&temp32, 1, 4, wav->file); /* write the bytes/second */ bps = sample_rate * 2 * channels; - temp32 = LITTLE_ENDIANIZE_INT32(bps); + temp32 = little_endianize_int32(bps); fwrite(&temp32, 1, 4, wav->file); /* write the block align */ align = 2 * channels; - temp16 = LITTLE_ENDIANIZE_INT16(align); + temp16 = little_endianize_int16(align); fwrite(&temp16, 1, 2, wav->file); /* write the bits/sample */ - temp16 = LITTLE_ENDIANIZE_INT16(16); + temp16 = little_endianize_int16(16); fwrite(&temp16, 1, 2, wav->file); /* write the 'data' tag */ @@ -100,13 +100,13 @@ void wav_close(wav_file *wav) /* update the total file size */ fseek(wav->file, wav->total_offs, SEEK_SET); temp32 = total - (wav->total_offs + 4); - temp32 = LITTLE_ENDIANIZE_INT32(temp32); + temp32 = little_endianize_int32(temp32); fwrite(&temp32, 1, 4, wav->file); /* update the data size */ fseek(wav->file, wav->data_offs, SEEK_SET); temp32 = total - (wav->data_offs + 4); - temp32 = LITTLE_ENDIANIZE_INT32(temp32); + temp32 = little_endianize_int32(temp32); fwrite(&temp32, 1, 4, wav->file); fclose(wav->file); 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/audio/snes_snd.cpp b/src/mame/audio/snes_snd.cpp index a9295fd560c..127fec049ce 100644 --- a/src/mame/audio/snes_snd.cpp +++ b/src/mame/audio/snes_snd.cpp @@ -149,8 +149,8 @@ static const int ENVCNT[0x20] #define SR( v ) (m_dsp_regs[((v) << 4) + 6] & 0x1f) /* Returns SUSTAIN rate */ /* Handle endianness */ -#define LEtoME16( x ) LITTLE_ENDIANIZE_INT16(x) -#define MEtoLE16( x ) LITTLE_ENDIANIZE_INT16(x) +#define LEtoME16( x ) little_endianize_int16(x) +#define MEtoLE16( x ) little_endianize_int16(x) const device_type SNES = &device_creator; diff --git a/src/mame/drivers/apexc.cpp b/src/mame/drivers/apexc.cpp index acbdb0b39c0..2dac4620982 100644 --- a/src/mame/drivers/apexc.cpp +++ b/src/mame/drivers/apexc.cpp @@ -118,7 +118,7 @@ bool apexc_cylinder_image_device::call_load() UINT32 *RAM = (UINT32 *)(machine().root_device().memregion("maincpu")->base()); for (int i=0; i < 0x0400; i++) - RAM[i] = BIG_ENDIANIZE_INT32(RAM[i]); + RAM[i] = big_endianize_int32(RAM[i]); } #endif @@ -139,7 +139,7 @@ void apexc_cylinder_image_device::call_unload() UINT32 *RAM = (UINT32 *)(machine().root_device().memregion("maincpu")->base()); for (int i=0; i < /*0x2000*/0x0400; i++) - RAM[i] = BIG_ENDIANIZE_INT32(RAM[i]); + RAM[i] = big_endianize_int32(RAM[i]); } #endif /* write */ 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/aussiebyte.cpp b/src/mame/drivers/aussiebyte.cpp index 1fdf1cd1fcb..efbca5f0931 100644 --- a/src/mame/drivers/aussiebyte.cpp +++ b/src/mame/drivers/aussiebyte.cpp @@ -341,14 +341,11 @@ static const z80_daisy_config daisy_chain_intf[] = ************************************************************/ // baud rate generator. All inputs are 1.2288MHz. -TIMER_DEVICE_CALLBACK_MEMBER( aussiebyte_state::ctc_tick ) +WRITE_LINE_MEMBER( aussiebyte_state::clock_w ) { - m_ctc->trg0(1); - m_ctc->trg0(0); - m_ctc->trg1(1); - m_ctc->trg1(0); - m_ctc->trg2(1); - m_ctc->trg2(0); + m_ctc->trg0(state); + m_ctc->trg1(state); + m_ctc->trg2(state); } WRITE_LINE_MEMBER( aussiebyte_state::ctc_z0_w ) @@ -475,6 +472,9 @@ static MACHINE_CONFIG_START( aussiebyte, aussiebyte_state ) MCFG_DEVICE_ADD("cent_data_in", INPUT_BUFFER, 0) MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics") + MCFG_DEVICE_ADD("ctc_clock", CLOCK, XTAL_4_9152MHz / 4) + MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(aussiebyte_state, clock_w)) + MCFG_DEVICE_ADD("ctc", Z80CTC, XTAL_16MHz / 4) MCFG_Z80CTC_INTR_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) MCFG_Z80CTC_ZC0_CB(WRITELINE(aussiebyte_state, ctc_z0_w)) // SIO1 Ch A @@ -532,7 +532,6 @@ static MACHINE_CONFIG_START( aussiebyte, aussiebyte_state ) MCFG_MC6845_ADDR_CHANGED_CB(aussiebyte_state, crtc_update_addr) MCFG_MSM5832_ADD("rtc", XTAL_32_768kHz) - MCFG_TIMER_DRIVER_ADD_PERIODIC("ctc_tick", aussiebyte_state, ctc_tick, attotime::from_hz(XTAL_4_9152MHz / 4)) MACHINE_CONFIG_END diff --git a/src/mame/drivers/bigbord2.cpp b/src/mame/drivers/bigbord2.cpp index 88af1c08601..8c938c3500d 100644 --- a/src/mame/drivers/bigbord2.cpp +++ b/src/mame/drivers/bigbord2.cpp @@ -2,16 +2,16 @@ // copyright-holders:Robbbert /*************************************************************************** - Big Board 2 +Ferguson / Digital Research Computers Big Board II - 12/05/2009 Skeleton driver. +2009-05-12 Skeleton driver. - This is very much under construction. +This is very much under construction. - Despite the name, this is not like the xerox or bigboard at all. +Despite the name, this is not like the xerox or bigboard at all. - It is compatible only if the software uses the same published - calls to the bios. Everything else is different. +It is compatible only if the software uses the same published +calls to the bios. Everything else is different. 80 = sio ce 84 = ctca ce @@ -29,14 +29,6 @@ dc = 6845 ce Difficulties encountered: -CTCA controls a pair of vectored interrupts. -One is triggered by a keypress, the other by a vsync pulse.. -Once a key is pressed, CTCA continually issues a keyboard interrupt, -causing a complete freeze. Therefore CTCA has been isolated, and the -2 interrupts are triggered by a hack. It isn't a very good hack, -because the system crashes after a while. However it will allow -testing and development to continue. - The FDC has a INTRQ pin, the diagram says it goes to page 6, but it just vanishes instead. @@ -54,12 +46,10 @@ The switching from port C8 is emulated. ToDo: - Finish floppy disk support (i have no boot disk) -- Finish the DMA switch in portcc_w. -- Fix the above problems with the CTC. -- Finish connecting up the SIO, when it becomes usable. -- Connect up the SASI, Centronics and other interfaces on ports D8-DB. -- Connect up the programming port C0-C3. -- Connect up the numerous board jumpers. +- (optional) Connect SIO to RS232. +- (optional) Connect up the SASI, Centronics and other interfaces on ports D8-DB. +- (optional) Connect up the programming port C0-C3. +- (optional) Connect up the numerous board jumpers. - Need software Monitor commands: @@ -84,63 +74,67 @@ X - change banks #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" #include "machine/z80ctc.h" -#include "machine/z80dart.h" +#include "machine/z80sio.h" #include "machine/z80dma.h" #include "video/mc6845.h" #include "machine/keyboard.h" #include "sound/beep.h" #include "machine/wd_fdc.h" +#include "machine/clock.h" -#define SCREEN_TAG "screen" -#define KEYBOARD_TAG "keyboard" -#define Z80_TAG "u39" -#define Z80SIO_TAG "u16" -#define Z80CTCA_TAG "u37" -#define Z80CTCB_TAG "u21" -#define Z80DMA_TAG "u62" class bigbord2_state : public driver_device { public: bigbord2_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, Z80_TAG), - m_6845(*this, "crtc"), - m_ctca(*this, Z80CTCA_TAG), - m_ctcb(*this, Z80CTCB_TAG), - m_dma(*this, Z80DMA_TAG), - m_fdc(*this, "fdc"), - m_floppy0(*this, "fdc:0"), - m_floppy1(*this, "fdc:1"), - m_beeper(*this, "beeper"), - m_dsw(*this, "DSW"), - m_bankr(*this, "bankr"), - m_bankv(*this, "bankv"), - m_banka(*this, "banka"), - m_palette(*this, "palette") + : driver_device(mconfig, type, tag) + , m_palette(*this, "palette") + , m_maincpu(*this, "maincpu") + , m_ctc1(*this, "ctc1") + , m_ctc2(*this, "ctc2") + , m_sio(*this, "sio") + , m_dma(*this, "dma") + , m_fdc(*this, "fdc") + , m_floppy0(*this, "fdc:0") + , m_floppy1(*this, "fdc:1") + , m_beeper(*this, "beeper") + , m_dsw(*this, "DSW") + , m_bankr(*this, "bankr") + , m_bankv(*this, "bankv") + , m_banka(*this, "banka") { } + DECLARE_WRITE8_MEMBER(portc0_w ); DECLARE_WRITE8_MEMBER(portc8_w ); DECLARE_WRITE8_MEMBER(portcc_w ); DECLARE_READ8_MEMBER(portc4_r); DECLARE_READ8_MEMBER(portd0_r); - DECLARE_WRITE8_MEMBER(bigbord2_kbd_put); - DECLARE_WRITE_LINE_MEMBER(frame); + DECLARE_WRITE8_MEMBER(kbd_put); + DECLARE_WRITE_LINE_MEMBER(clock_w); + DECLARE_WRITE_LINE_MEMBER(busreq_w); + DECLARE_WRITE_LINE_MEMBER(ctc_z1_w); + DECLARE_WRITE_LINE_MEMBER(sio_wrdya_w); + DECLARE_WRITE_LINE_MEMBER(sio_wrdyb_w); + DECLARE_WRITE_LINE_MEMBER(fdc_drq_w); DECLARE_DRIVER_INIT(bigbord2); - TIMER_DEVICE_CALLBACK_MEMBER(ctc_tick); DECLARE_READ8_MEMBER(memory_read_byte); DECLARE_WRITE8_MEMBER(memory_write_byte); DECLARE_READ8_MEMBER(io_read_byte); DECLARE_WRITE8_MEMBER(io_write_byte); MC6845_UPDATE_ROW(crtc_update_row); + required_device m_palette; + +private: + UINT8 crt8002(UINT8 ac_ra, UINT8 ac_chr, UINT8 ac_attr, UINT16 ac_cnt, bool ac_curs); UINT8 *m_p_chargen; /* character ROM */ UINT8 *m_p_videoram; /* Video RAM */ UINT8 *m_p_attribram; /* Attribute RAM */ -private: UINT8 m_term_data; UINT8 m_term_status; - int m_c8[8]; + UINT16 m_cnt; + bool m_c8[8]; + bool m_cc[8]; floppy_image_device *m_floppy; virtual void machine_start() override; virtual void machine_reset() override; @@ -148,9 +142,9 @@ private: address_space *m_mem; address_space *m_io; required_device m_maincpu; - required_device m_6845; - required_device m_ctca; - required_device m_ctcb; + required_device m_ctc1; + required_device m_ctc2; + required_device m_sio; required_device m_dma; required_device m_fdc; required_device m_floppy0; @@ -160,10 +154,13 @@ private: required_memory_bank m_bankr; required_memory_bank m_bankv; required_memory_bank m_banka; -public: - required_device m_palette; }; +// Eprom programming port +WRITE8_MEMBER( bigbord2_state::portc0_w ) +{ +} + /* Status port 0 = RXDA 1 = RXDB @@ -190,49 +187,59 @@ READ8_MEMBER( bigbord2_state::portd0_r ) return ret; } -WRITE8_MEMBER( bigbord2_state::bigbord2_kbd_put ) +WRITE8_MEMBER( bigbord2_state::kbd_put ) { if (data) { m_term_data = data; m_term_status = 8; - m_ctca->trg0(0); - m_ctca->trg0(1); - if (m_mem->read_byte(0xf13d) == 0x4d) - { - // simulate interrupt by saving current pc on - // the stack and jumping to interrupt handler. - UINT16 spreg = m_maincpu->state_int(Z80_SP); - UINT16 pcreg = m_maincpu->state_int(Z80_PC); - spreg--; - m_mem->write_byte(spreg, pcreg >> 8); - spreg--; - m_mem->write_byte(spreg, pcreg); - m_maincpu->set_state_int(Z80_SP, spreg); - m_maincpu->set_state_int(Z80_PC, 0xF120); - } + m_ctc1->trg0(0); + m_ctc1->trg0(1); } } +WRITE_LINE_MEMBER( bigbord2_state::sio_wrdya_w ) +{ + m_cc[0] = state; +} + +WRITE_LINE_MEMBER( bigbord2_state::sio_wrdyb_w ) +{ + m_cc[1] = state; +} + +WRITE_LINE_MEMBER( bigbord2_state::fdc_drq_w ) +{ + m_cc[2] = state; +} + + /* Z80 DMA */ -READ8_MEMBER(bigbord2_state::memory_read_byte) +WRITE_LINE_MEMBER( bigbord2_state::busreq_w ) +{ +// since our Z80 has no support for BUSACK, we assume it is granted immediately + m_maincpu->set_input_line(Z80_INPUT_LINE_BUSRQ, state); + m_dma->bai_w(state); // tell dma that bus has been granted +} + +READ8_MEMBER( bigbord2_state::memory_read_byte ) { return m_mem->read_byte(offset); } -WRITE8_MEMBER(bigbord2_state::memory_write_byte) +WRITE8_MEMBER( bigbord2_state::memory_write_byte ) { m_mem->write_byte(offset, data); } -READ8_MEMBER(bigbord2_state::io_read_byte) +READ8_MEMBER( bigbord2_state::io_read_byte ) { return m_io->read_byte(offset); } -WRITE8_MEMBER(bigbord2_state::io_write_byte) +WRITE8_MEMBER( bigbord2_state::io_write_byte ) { m_io->write_byte(offset, data); } @@ -296,7 +303,7 @@ WRITE8_MEMBER( bigbord2_state::portc8_w ) // motor on if (m_floppy) { - m_floppy->mon_w(~m_c8[6]); + m_floppy->mon_w(m_c8[6]? 0 : 1); } break; case 7: @@ -338,11 +345,7 @@ WRITE8_MEMBER( bigbord2_state::portcc_w ) m_fdc->set_floppy(m_floppy); - bool dma_rdy = 0; - if ((data & 7) == 2) - dma_rdy = m_fdc->drq_r(); - - m_dma->rdy_w(dma_rdy); + m_dma->rdy_w(m_cc[data & 7]); } @@ -360,18 +363,19 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( bigbord2_io, AS_IO, 8, bigbord2_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) - AM_RANGE(0x80, 0x83) AM_DEVREADWRITE(Z80SIO_TAG, z80sio0_device, ba_cd_r, ba_cd_w) - //AM_RANGE(0x84, 0x87) AM_DEVREADWRITE(Z80CTCA_TAG, z80ctc_device, read, write) //has issues - AM_RANGE(0x88, 0x8b) AM_DEVREADWRITE(Z80CTCB_TAG, z80ctc_device, read, write) - AM_RANGE(0x8C, 0x8F) AM_DEVREADWRITE(Z80DMA_TAG, z80dma_device, read, write) - //AM_RANGE(0xC0, 0xC3) eprom programming port - AM_RANGE(0xC4, 0xC7) AM_READ(portc4_r) + ADDRESS_MAP_UNMAP_HIGH + AM_RANGE(0x80, 0x83) AM_DEVREADWRITE("sio", z80sio_device, ba_cd_r, ba_cd_w) // u16 + AM_RANGE(0x84, 0x87) AM_DEVREADWRITE("ctc1", z80ctc_device, read, write) // u37 has issues + AM_RANGE(0x88, 0x8b) AM_DEVREADWRITE("ctc2", z80ctc_device, read, write) // u21 + AM_RANGE(0x8C, 0x8F) AM_DEVREADWRITE("dma", z80dma_device, read, write) // u62 + AM_RANGE(0xC0, 0xC3) AM_WRITE(portc0_w) // eprom programming port + AM_RANGE(0xC4, 0xC7) AM_READ (portc4_r) AM_RANGE(0xC8, 0xCB) AM_WRITE(portc8_w) AM_RANGE(0xCC, 0xCF) AM_WRITE(portcc_w) - AM_RANGE(0xD0, 0xD3) AM_READ(portd0_r) - AM_RANGE(0xD4, 0xD7) AM_DEVREADWRITE("fdc", mb8877_t, read, write) + AM_RANGE(0xD0, 0xD3) AM_READ (portd0_r) + AM_RANGE(0xD4, 0xD7) AM_DEVREADWRITE("fdc", mb8877_t, read, write) // u10 //AM_RANGE(0xD8, 0xDB) AM_READWRITE(portd8_r, portd8_w) // various external data ports; DB = centronics printer - AM_RANGE(0xDC, 0xDC) AM_MIRROR(2) AM_DEVREADWRITE("crtc", mc6845_device, status_r, address_w) + AM_RANGE(0xDC, 0xDC) AM_MIRROR(2) AM_DEVREADWRITE("crtc", mc6845_device, status_r, address_w) // u30 AM_RANGE(0xDD, 0xDD) AM_MIRROR(2) AM_DEVREADWRITE("crtc", mc6845_device, register_r, register_w) ADDRESS_MAP_END @@ -398,51 +402,37 @@ INPUT_PORTS_END /* Z80 CTC */ -TIMER_DEVICE_CALLBACK_MEMBER(bigbord2_state::ctc_tick) +WRITE_LINE_MEMBER( bigbord2_state::clock_w ) { - m_ctcb->trg0(1); - m_ctcb->trg1(1); - m_ctcb->trg0(0); - m_ctcb->trg1(0); + m_ctc2->trg0(state); + m_ctc2->trg1(state); + if (m_floppy) + m_ctc1->trg1(m_floppy->idx_r()); } -WRITE_LINE_MEMBER( bigbord2_state::frame ) +// there's a multitude of optional jumpers in this area, but this will do +WRITE_LINE_MEMBER( bigbord2_state::ctc_z1_w ) { - static UINT8 framecnt; - framecnt++; - - if ((m_mem->read_byte(0xf13d) == 0x4d) & (framecnt > 3)) - { - framecnt = 0; - // simulate interrupt by saving current pc on - // the stack and jumping to interrupt handler. - UINT16 spreg = m_maincpu->state_int(Z80_SP); - UINT16 pcreg = m_maincpu->state_int(Z80_PC); - spreg--; - m_mem->write_byte(spreg, pcreg >> 8); - spreg--; - m_mem->write_byte(spreg, pcreg); - m_maincpu->set_state_int(Z80_SP, spreg); - m_maincpu->set_state_int(Z80_PC, 0xF18E); - } + m_sio->rxca_w(state); + m_sio->txca_w(state); } - /* Z80 Daisy Chain */ -static const z80_daisy_config bigbord2_daisy_chain[] = +static const z80_daisy_config daisy_chain[] = { - { Z80DMA_TAG }, - { Z80CTCA_TAG }, - { Z80CTCB_TAG }, - { Z80SIO_TAG }, + { "dma" }, + { "ctc1" }, + { "ctc2" }, + { "sio" }, { nullptr } }; /* WD1793 Interface */ static SLOT_INTERFACE_START( bigbord2_floppies ) - SLOT_INTERFACE( "525dd", FLOPPY_525_DD ) + SLOT_INTERFACE( "drive0", FLOPPY_8_DSDD ) + SLOT_INTERFACE( "drive1", FLOPPY_8_DSDD ) SLOT_INTERFACE_END @@ -452,8 +442,8 @@ void bigbord2_state::video_start() { /* find memory regions */ m_p_chargen = memregion("chargen")->base(); - m_p_videoram = memregion(Z80_TAG)->base()+0x6000; - m_p_attribram = memregion(Z80_TAG)->base()+0x7000; + m_p_videoram = memregion("maincpu")->base()+0x6000; + m_p_attribram = memregion("maincpu")->base()+0x7000; } @@ -463,13 +453,18 @@ void bigbord2_state::machine_start() { /* register for state saving */ save_item(NAME(m_term_data)); + m_floppy = nullptr; } void bigbord2_state::machine_reset() { UINT8 i; for (i = 0; i < 8; i++) + { m_c8[i] = 0; + m_cc[i] = 1; + } + m_cc[2] = 0; m_beeper->set_state(0); m_bankr->set_entry(0); m_bankv->set_entry(0); @@ -480,7 +475,7 @@ DRIVER_INIT_MEMBER(bigbord2_state,bigbord2) { m_mem = &m_maincpu->space(AS_PROGRAM); m_io = &m_maincpu->space(AS_IO); - UINT8 *RAM = memregion(Z80_TAG)->base(); + UINT8 *RAM = memregion("maincpu")->base(); m_bankr->configure_entries(0, 2, &RAM[0x0000], 0x10000); m_bankv->configure_entries(0, 2, &RAM[0x6000], 0x10000); m_banka->configure_entries(0, 2, &RAM[0x7000], 0x10000); @@ -490,39 +485,93 @@ DRIVER_INIT_MEMBER(bigbord2_state,bigbord2) /* Screen */ /* F4 Character Displayer */ -static const gfx_layout bigbord2_charlayout = +static const gfx_layout crt8002_charlayout = { - 8, 16, /* 8 x 8 characters */ - 256, /* 256 characters */ + 8, 12, /* 7 x 11 characters */ + 128, /* 128 characters */ 1, /* 1 bits per pixel */ { 0 }, /* no bitplanes */ /* x offsets */ { 0, 1, 2, 3, 4, 5, 6, 7 }, /* y offsets */ - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, - 8*16 /* every char takes 8 bytes */ + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8 }, + 8*16 /* every char takes 16 bytes */ }; -static GFXDECODE_START( bigbord2 ) - GFXDECODE_ENTRY( "chargen", 0x0000, bigbord2_charlayout, 0, 1 ) +static GFXDECODE_START( crt8002 ) + GFXDECODE_ENTRY( "chargen", 0x0000, crt8002_charlayout, 0, 1 ) GFXDECODE_END +UINT8 bigbord2_state::crt8002(UINT8 ac_ra, UINT8 ac_chr, UINT8 ac_attr, UINT16 ac_cnt, bool ac_curs) +{ + UINT8 gfx = 0; + switch (ac_attr & 3) + { + case 0: // lores gfx + switch (ac_ra) + { + case 0: + case 1: + case 2: + gfx = (BIT(ac_chr, 7) ? 0xf8 : 0) | (BIT(ac_chr, 3) ? 7 : 0); + break; + case 3: + case 4: + case 5: + gfx = (BIT(ac_chr, 6) ? 0xf8 : 0) | (BIT(ac_chr, 2) ? 7 : 0); + break; + case 6: + case 7: + case 8: + gfx = (BIT(ac_chr, 5) ? 0xf8 : 0) | (BIT(ac_chr, 1) ? 7 : 0); + break; + default: + gfx = (BIT(ac_chr, 4) ? 0xf8 : 0) | (BIT(ac_chr, 0) ? 7 : 0); + break; + } + break; + case 1: // external mode + gfx = BITSWAP8(ac_chr, 0,1,2,3,4,5,6,7); + break; + case 2: // thin gfx + break; + case 3: // alpha + gfx = m_p_chargen[((ac_chr & 0x7f)<<4) | ac_ra]; + break; + } + + if (BIT(ac_attr, 3) & (ac_ra == 11)) // underline + gfx = 0xff; + if (BIT(ac_attr, 2) & ((ac_ra == 5) | (ac_ra == 6))) // strike-through + gfx = 0xff; + if (BIT(ac_attr, 6) & BIT(ac_cnt, 13)) // flash + gfx = 0; + if BIT(ac_attr, 5) // blank + gfx = 0; + if (ac_curs && BIT(ac_cnt, 14)) // cursor + gfx ^= 0xff; + if BIT(ac_attr, 4) // reverse video + gfx ^= 0xff; + return gfx; +} + MC6845_UPDATE_ROW( bigbord2_state::crtc_update_row ) { const rgb_t *palette = m_palette->palette()->entry_list_raw(); - UINT8 chr,gfx,inv; + UINT8 chr,gfx,attr; UINT16 mem,x; UINT32 *p = &bitmap.pix32(y); + ra &= 15; + m_cnt++; for (x = 0; x < x_count; x++) { - inv=0; mem = (ma + x) & 0x7ff; - if (BIT(m_p_attribram[mem], 7)) inv^=0xff; + attr = m_p_attribram[mem]; chr = m_p_videoram[mem]; - /* get pattern of pixels for that character scanline */ - gfx = m_p_chargen[(chr<<4) | ra ] ^ inv; + /* process attributes */ + gfx = crt8002(ra, chr, attr, m_cnt, (x==cursor_x)); /* Display a scanline of a character */ *p++ = palette[BIT( gfx, 7 )]; @@ -542,60 +591,66 @@ MC6845_UPDATE_ROW( bigbord2_state::crtc_update_row ) static MACHINE_CONFIG_START( bigbord2, bigbord2_state ) /* basic machine hardware */ - MCFG_CPU_ADD(Z80_TAG, Z80, MAIN_CLOCK) + MCFG_CPU_ADD("maincpu", Z80, MAIN_CLOCK) MCFG_CPU_PROGRAM_MAP(bigbord2_mem) MCFG_CPU_IO_MAP(bigbord2_io) - MCFG_Z80_DAISY_CHAIN(bigbord2_daisy_chain) + MCFG_Z80_DAISY_CHAIN(daisy_chain) /* video hardware */ - MCFG_SCREEN_ADD(SCREEN_TAG, RASTER) + MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_RAW_PARAMS(XTAL_10_69425MHz, 700, 0, 560, 260, 0, 240) MCFG_SCREEN_UPDATE_DEVICE("crtc", mc6845_device, screen_update) - MCFG_GFXDECODE_ADD("gfxdecode", "palette", bigbord2) + MCFG_GFXDECODE_ADD("gfxdecode", "palette", crt8002) MCFG_PALETTE_ADD_MONOCHROME("palette") - /* keyboard */ - MCFG_TIMER_DRIVER_ADD_PERIODIC("ctc", bigbord2_state, ctc_tick, attotime::from_hz(MAIN_CLOCK)) + MCFG_DEVICE_ADD("ctc_clock", CLOCK, MAIN_CLOCK) + MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(bigbord2_state, clock_w)) /* devices */ - MCFG_DEVICE_ADD(Z80DMA_TAG, Z80DMA, MAIN_CLOCK) - MCFG_Z80DMA_OUT_BUSREQ_CB(INPUTLINE(Z80_TAG, INPUT_LINE_HALT)) - MCFG_Z80DMA_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) + MCFG_DEVICE_ADD("dma", Z80DMA, MAIN_CLOCK) + MCFG_Z80DMA_OUT_BUSREQ_CB(WRITELINE(bigbord2_state, busreq_w)) + MCFG_Z80DMA_OUT_INT_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) MCFG_Z80DMA_IN_MREQ_CB(READ8(bigbord2_state, memory_read_byte)) MCFG_Z80DMA_OUT_MREQ_CB(WRITE8(bigbord2_state, memory_write_byte)) MCFG_Z80DMA_IN_IORQ_CB(READ8(bigbord2_state, io_read_byte)) MCFG_Z80DMA_OUT_IORQ_CB(WRITE8(bigbord2_state, io_write_byte)) - MCFG_Z80SIO0_ADD(Z80SIO_TAG, MAIN_CLOCK, 0, 0, 0, 0) - MCFG_Z80DART_OUT_INT_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) + MCFG_Z80SIO_ADD("sio", MAIN_CLOCK, 0, 0, 0, 0) + MCFG_Z80SIO_OUT_INT_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) + MCFG_Z80SIO_OUT_SYNCA_CB(DEVWRITELINE("ctc1", z80ctc_device, trg2)) + MCFG_Z80SIO_OUT_WRDYA_CB(WRITELINE(bigbord2_state, sio_wrdya_w)) + MCFG_Z80SIO_OUT_WRDYB_CB(WRITELINE(bigbord2_state, sio_wrdyb_w)) - MCFG_DEVICE_ADD(Z80CTCA_TAG, Z80CTC, MAIN_CLOCK) - MCFG_Z80CTC_INTR_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) - // other inputs of ctca: - // trg0 = KBDSTB; trg1 = index pulse from fdc; trg2 = synca output from sio + MCFG_DEVICE_ADD("ctc1", Z80CTC, MAIN_CLOCK) + MCFG_Z80CTC_INTR_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) - MCFG_DEVICE_ADD(Z80CTCB_TAG, Z80CTC, MAIN_CLOCK / 6) - MCFG_Z80CTC_INTR_CB(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0)) - // ZC0 = SIO channel B clock, ZC1 = SIO channel A clock - MCFG_Z80CTC_ZC2_CB(DEVWRITELINE(Z80CTCB_TAG, z80ctc_device, trg3)) + MCFG_DEVICE_ADD("ctc2", Z80CTC, MAIN_CLOCK) + MCFG_Z80CTC_INTR_CB(INPUTLINE("maincpu", INPUT_LINE_IRQ0)) + MCFG_Z80CTC_ZC0_CB(DEVWRITELINE("sio", z80sio_device, rxtxcb_w)) // to SIO Ch B + MCFG_Z80CTC_ZC1_CB(WRITELINE(bigbord2_state, ctc_z1_w)) // to SIO Ch A + MCFG_Z80CTC_ZC2_CB(DEVWRITELINE("ctc2", z80ctc_device, trg3)) - MCFG_MB8877_ADD("fdc", XTAL_16MHz / 16) - MCFG_FLOPPY_DRIVE_ADD("fdc:0", bigbord2_floppies, "525dd", floppy_image_device::default_floppy_formats) - MCFG_FLOPPY_DRIVE_ADD("fdc:1", bigbord2_floppies, "525dd", floppy_image_device::default_floppy_formats) + MCFG_MB8877_ADD("fdc", XTAL_16MHz / 8) // 2MHz for 8 inch, or 1MHz otherwise (jumper-selectable) + //MCFG_WD_FDC_INTRQ_CALLBACK(INPUTLINE("maincpu", ??)) // info missing from schematic + MCFG_FLOPPY_DRIVE_ADD("fdc:0", bigbord2_floppies, "drive0", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_SOUND(true) + MCFG_FLOPPY_DRIVE_ADD("fdc:1", bigbord2_floppies, "drive1", floppy_image_device::default_floppy_formats) + MCFG_FLOPPY_DRIVE_SOUND(true) - MCFG_MC6845_ADD("crtc", MC6845, SCREEN_TAG, XTAL_16MHz / 8) + MCFG_MC6845_ADD("crtc", MC6845, "screen", XTAL_16MHz / 8) MCFG_MC6845_SHOW_BORDER_AREA(false) MCFG_MC6845_CHAR_WIDTH(8) MCFG_MC6845_UPDATE_ROW_CB(bigbord2_state, crtc_update_row) - MCFG_MC6845_OUT_VSYNC_CB(WRITELINE(bigbord2_state, frame)) + MCFG_MC6845_OUT_VSYNC_CB(DEVWRITELINE("ctc1", z80ctc_device, trg3)) - MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0) - MCFG_GENERIC_KEYBOARD_CB(WRITE8(bigbord2_state, bigbord2_kbd_put)) + /* keyboard */ + MCFG_DEVICE_ADD("keyboard", GENERIC_KEYBOARD, 0) + MCFG_GENERIC_KEYBOARD_CB(WRITE8(bigbord2_state, kbd_put)) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("beeper", BEEP, 950) // actual frequency is unknown - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -603,12 +658,11 @@ MACHINE_CONFIG_END ROM_START( bigbord2 ) - ROM_REGION( 0x18000, Z80_TAG, 0 ) + ROM_REGION( 0x18000, "maincpu", 0 ) ROM_LOAD( "bigbrdii.bin", 0x0000, 0x1000, CRC(c588189e) SHA1(4133903171ee8b9fcf12cc72de843af782b4a645) ) - // internal to 8002 chip (undumped) we will use one from 'vta2000' for now - ROM_REGION( 0x2000, "chargen", ROMREGION_INVERT ) - ROM_LOAD( "bdp-15_14.rom", 0x0000, 0x2000, BAD_DUMP CRC(a1dc4f8e) SHA1(873fd211f44713b713d73163de2d8b5db83d2143) ) + ROM_REGION( 0x800, "chargen", 0 ) + ROM_LOAD( "8002.bin", 0x0000, 0x0800, CRC(fdd6eb13) SHA1(a094d416e66bdab916e72238112a6265a75ca690) ) ROM_END /* System Drivers */ diff --git a/src/mame/drivers/coleco.cpp b/src/mame/drivers/coleco.cpp index 9c3038c9b71..b7c12e5e6d1 100644 --- a/src/mame/drivers/coleco.cpp +++ b/src/mame/drivers/coleco.cpp @@ -352,15 +352,15 @@ void coleco_state::machine_reset() m_last_nmi_state = 0; } -//static int coleco_cart_verify(const UINT8 *cartdata, size_t size) +//static bool coleco_cart_verify(const UINT8 *cartdata, size_t size) //{ -// int retval = IMAGE_VERIFY_FAIL; +// int retval = false; // // /* Verify the file is in Colecovision format */ // if ((cartdata[0] == 0xAA) && (cartdata[1] == 0x55)) /* Production Cartridge */ -// retval = IMAGE_VERIFY_PASS; +// retval = true; // if ((cartdata[0] == 0x55) && (cartdata[1] == 0xAA)) /* "Test" Cartridge. Some games use this method to skip ColecoVision title screen and delay */ -// retval = IMAGE_VERIFY_PASS; +// retval = true; // // return retval; //} diff --git a/src/mame/drivers/cps3.cpp b/src/mame/drivers/cps3.cpp index f82276b13c9..4d703937971 100644 --- a/src/mame/drivers/cps3.cpp +++ b/src/mame/drivers/cps3.cpp @@ -1331,7 +1331,7 @@ UINT32 cps3_state::screen_update_cps3(screen_device &screen, bitmap_rgb32 &bitma READ32_MEMBER(cps3_state::cps3_ssram_r) { if (offset>0x8000/4) - return LITTLE_ENDIANIZE_INT32(m_ss_ram[offset]); + return little_endianize_int32(m_ss_ram[offset]); else return m_ss_ram[offset]; } @@ -1341,8 +1341,8 @@ WRITE32_MEMBER(cps3_state::cps3_ssram_w) if (offset>0x8000/4) { // we only want to endian-flip the character data, the tilemap info is fine - data = LITTLE_ENDIANIZE_INT32(data); - mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask); + data = little_endianize_int32(data); + mem_mask = little_endianize_int32(mem_mask); m_gfxdecode->gfx(0)->mark_dirty(offset/16); } @@ -1389,14 +1389,14 @@ READ32_MEMBER(cps3_state::cram_data_r) { UINT32 fulloffset = (((m_cram_bank&0x7)*0x100000)/4) + offset; - return LITTLE_ENDIANIZE_INT32(m_char_ram[fulloffset]); + return little_endianize_int32(m_char_ram[fulloffset]); } WRITE32_MEMBER(cps3_state::cram_data_w) { UINT32 fulloffset = (((m_cram_bank&0x7)*0x100000)/4) + offset; - mem_mask = LITTLE_ENDIANIZE_INT32(mem_mask); - data = LITTLE_ENDIANIZE_INT32(data); + mem_mask = little_endianize_int32(mem_mask); + data = little_endianize_int32(data); COMBINE_DATA(&m_char_ram[fulloffset]); m_gfxdecode->gfx(1)->mark_dirty(fulloffset/0x40); } @@ -2016,9 +2016,9 @@ void cps3_state::cps3_process_character_dma(UINT32 address) for (i = 0; i < 0x1000; i += 3) { - UINT32 dat1 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 0 + (address)]); - UINT32 dat2 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 1 + (address)]); - UINT32 dat3 = LITTLE_ENDIANIZE_INT32(m_char_ram[i + 2 + (address)]); + UINT32 dat1 = little_endianize_int32(m_char_ram[i + 0 + (address)]); + UINT32 dat2 = little_endianize_int32(m_char_ram[i + 1 + (address)]); + UINT32 dat3 = little_endianize_int32(m_char_ram[i + 2 + (address)]); UINT32 real_source = (dat3 << 1) - 0x400000; UINT32 real_destination = dat2 << 3; UINT32 real_length = (((dat1 & 0x001fffff) + 1) << 3); diff --git a/src/mame/drivers/dvk_ksm.cpp b/src/mame/drivers/dvk_ksm.cpp index d7cd941eb8b..60cfee34578 100644 --- a/src/mame/drivers/dvk_ksm.cpp +++ b/src/mame/drivers/dvk_ksm.cpp @@ -360,8 +360,6 @@ static MACHINE_CONFIG_START( ksm, ksm_state ) // serial connection to host MCFG_DEVICE_ADD( "i8251line", I8251, 0) MCFG_I8251_TXD_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd)) - MCFG_I8251_DTR_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_dtr)) - MCFG_I8251_RTS_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_rts)) MCFG_I8251_RXRDY_HANDLER(DEVWRITELINE("pic8259", pic8259_device, ir3_w)) MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "null_modem") @@ -369,6 +367,7 @@ static MACHINE_CONFIG_START( ksm, ksm_state ) MCFG_RS232_CTS_HANDLER(DEVWRITELINE("i8251line", i8251_device, write_cts)) MCFG_RS232_DSR_HANDLER(DEVWRITELINE("i8251line", i8251_device, write_dsr)) + // XXX /RTS, /DTR, PC5 and PC6 are wired to baud rate generator. MCFG_DEVICE_ADD("line_clock", CLOCK, 9600*16) // 8251 is set to /16 on the clock input MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(ksm_state, write_line_clock)) diff --git a/src/mame/drivers/homelab.cpp b/src/mame/drivers/homelab.cpp index 7c1ab0eb2cc..66bb22675db 100644 --- a/src/mame/drivers/homelab.cpp +++ b/src/mame/drivers/homelab.cpp @@ -698,8 +698,8 @@ QUICKLOAD_LOAD_MEMBER( homelab_state,homelab) return IMAGE_INIT_FAIL; } - quick_addr = LITTLE_ENDIANIZE_INT16(args[0]); - quick_length = LITTLE_ENDIANIZE_INT16(args[1]); + quick_addr = little_endianize_int16(args[0]); + quick_length = little_endianize_int16(args[1]); quick_end = quick_addr+quick_length-1; if (quick_end > 0x7fff) 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/itech32.cpp b/src/mame/drivers/itech32.cpp index 1b0ef8b6137..3ff9ab1af93 100644 --- a/src/mame/drivers/itech32.cpp +++ b/src/mame/drivers/itech32.cpp @@ -2160,7 +2160,7 @@ ROM_START( pairs ) /* Version 1.2 (3-tier board set: P/N 1059 Rev 3, P/N 1061 R ROM_LOAD16_BYTE( "ensoniq.2m", 0x000000, 0x200000, CRC(9fdc4825) SHA1(71e5255c66d9010be7e6f27916b605441fc53839) ) /* Ensoniq 2m 1350901601 */ ROM_REGION16_BE( 0x400000, "ensoniq.2", ROMREGION_ERASE00 ) - ROM_LOAD16_BYTE( "srom0_pairs_v1.srom0", 0x000000, 0x80000, CRC(1d96c581) SHA1(3b7c84b7db3b098ec28c7058c16f97e9cf0e4733) ) + ROM_LOAD16_BYTE( "srom0.bin", 0x000000, 0x80000, CRC(19a857f9) SHA1(2515b4c127191d52d3b5a72477384847d8cabad3) ) /* Unknown label and / or revision */ ROM_END 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/lynx.cpp b/src/mame/drivers/lynx.cpp index c4d0c8db5ba..1c866a91cfc 100644 --- a/src/mame/drivers/lynx.cpp +++ b/src/mame/drivers/lynx.cpp @@ -162,7 +162,7 @@ QUICKLOAD_LOAD_MEMBER( lynx_state, lynx ) return IMAGE_INIT_FAIL; /* Check the image */ - if (lynx_verify_cart((char*)header, LYNX_QUICKLOAD) == IMAGE_VERIFY_FAIL) + if (!lynx_verify_cart((char*)header, LYNX_QUICKLOAD)) return IMAGE_INIT_FAIL; start = header[3] | (header[2]<<8); //! big endian format in file format for little endian cpu 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/mekd2.cpp b/src/mame/drivers/mekd2.cpp index a2b7d1f9d71..3e35ea23fff 100644 --- a/src/mame/drivers/mekd2.cpp +++ b/src/mame/drivers/mekd2.cpp @@ -315,9 +315,9 @@ QUICKLOAD_LOAD_MEMBER( mekd2_state, mekd2_quik ) return IMAGE_INIT_FAIL; } image.fread(&addr, 2); - addr = LITTLE_ENDIANIZE_INT16(addr); + addr = little_endianize_int16(addr); image.fread(&size, 2); - size = LITTLE_ENDIANIZE_INT16(size); + size = little_endianize_int16(size); image.fread(&ident, 1); logerror("mekd2 rom load: $%04X $%04X $%02X\n", addr, size, ident); while (size-- > 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..2f96452e14c 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::max)(data, INT16(-127)); return 0x80 + data; } diff --git a/src/mame/drivers/splash.cpp b/src/mame/drivers/splash.cpp index 5e62122aa72..dac2738f613 100644 --- a/src/mame/drivers/splash.cpp +++ b/src/mame/drivers/splash.cpp @@ -222,7 +222,7 @@ WRITE16_MEMBER(splash_state::funystrp_sh_irqtrigger_w) } static ADDRESS_MAP_START( funystrp_map, AS_PROGRAM, 16, splash_state ) - AM_RANGE(0x000000, 0x01ffff) AM_ROM /* ROM */ + AM_RANGE(0x000000, 0x07ffff) AM_ROM /* ROM */ AM_RANGE(0x100000, 0x1fffff) AM_RAM /* protection? RAM */ AM_RANGE(0x800000, 0x83ffff) AM_RAM AM_SHARE("pixelram") /* Pixel Layer */ AM_RANGE(0x84000a, 0x84000b) AM_WRITE(coin_w) /* Coin Counters + Coin Lockout */ @@ -999,6 +999,34 @@ ROM_START( puckpepl ) ROM_LOAD( "pp34.u51", 0x060000, 0x020000, CRC(93f2d483) SHA1(eb6981b0228acb1ec92325924d0aa295f9e2cfe1) ) ROM_END +/* + +Ring & Ball (?) + +Came from a dead board, silkscreen ring&ball/a by microhard + +u87 & u111 program +u51 +u53 empty socket might be missing +u130 sound (z80) + +no idea on this one... + +*/ + +ROM_START( ringball ) + ROM_REGION( 0x080000, "maincpu", 0 ) /* 68000 code + gfx */ + // TODO: encrypted, there's a device with scratched part between 68k and roms. u87 looks to have standard 68k vectors with scrambled bits. + ROM_LOAD( "u87.bin", 0x000000, 0x040000, CRC(f8f21cfd) SHA1(c258689fc79195945db21663d2df0a33a4412618) ) + ROM_LOAD( "u111.bin", 0x040000, 0x040000, CRC(11e246b0) SHA1(b056bcaa52ab2898f470a29b0a5c2f3594e2522b) ) // actually "u101"? + + ROM_REGION( 0x080000, "audiocpu", 0 ) /* Z80 code + sound data */ + ROM_LOAD( "u130.bin", 0x000000, 0x080000, CRC(892202ea) SHA1(10b5933b136a6595f739510d380d12c4cefd9f09) ) + + ROM_REGION( 0x100000, "gfx1", 0 ) + ROM_LOAD( "u51.bin", 0x000000, 0x080000, CRC(32c01844) SHA1(ad461c47cd270414c442325751eca0d6c1ea9e2d) ) + ROM_LOAD( "u53.bin", 0x080000, 0x080000, NO_DUMP ) // empty on this PCB, GFXs doesn't seem enough for a complete game? +ROM_END /* DRIVER INITs */ @@ -1386,3 +1414,4 @@ GAME( 1993, roldfroga,roldfrog, roldfrog, splash, splash_state, roldfrog, ROT0 GAME( 1995, rebus, 0, roldfrog, splash, splash_state, rebus, ROT0, "Microhard", "Rebus", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_NO_SOUND | MACHINE_SUPPORTS_SAVE ) GAME( 199?, funystrp, 0, funystrp, funystrp, splash_state, funystrp, ROT0, "Microhard / MagicGames", "Funny Strip", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_SUPPORTS_SAVE ) GAME( 199?, puckpepl, funystrp, funystrp, funystrp, splash_state, funystrp, ROT0, "Microhard", "Puck People", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_SUPPORTS_SAVE ) +GAME( 199?, ringball, funystrp, funystrp, funystrp, splash_state, funystrp, ROT0, "Microhard", "Ring & Ball (unknown title)", MACHINE_NOT_WORKING | MACHINE_UNEMULATED_PROTECTION | MACHINE_SUPPORTS_SAVE ) // Wouldn't surprise me if in-game is actually called King & Bell ... diff --git a/src/mame/drivers/tmnt.cpp b/src/mame/drivers/tmnt.cpp index 6f5aef5d5bb..9e10bef4773 100644 --- a/src/mame/drivers/tmnt.cpp +++ b/src/mame/drivers/tmnt.cpp @@ -4095,9 +4095,9 @@ static void chunky_to_planar(memory_region *rgn) for (int i = 0; i < len; i++) { - UINT32 data = LITTLE_ENDIANIZE_INT32(ROM[i]); + UINT32 data = little_endianize_int32(ROM[i]); data = BITSWAP32(data,31,27,23,19,15,11,7,3,30,26,22,18,14,10,6,2,29,25,21,17,13,9,5,1,28,24,20,16,12,8,4,0); - ROM[i] = LITTLE_ENDIANIZE_INT32(data); + ROM[i] = little_endianize_int32(data); } } diff --git a/src/mame/drivers/tv950.cpp b/src/mame/drivers/tv950.cpp index 7fe87623194..a84031817ba 100644 --- a/src/mame/drivers/tv950.cpp +++ b/src/mame/drivers/tv950.cpp @@ -1,20 +1,55 @@ // license:BSD-3-Clause -// copyright-holders:Robbbert +// copyright-holders:R. Belmont, Robbbert /*************************************************************************** 2013-09-10 Skeleton driver for Televideo TV950 + 2016-07-30 Preliminary not-so-skeleton driver TODO: - - Everything - this is just a skeleton - - Seems there should be a few more roms. - - + - Keyboard + - CRTC reset and drawing + + Hardware: + 6502 CPU + 6545 CRTC + 6522 VIA, wired to count HSYNCs and to enable the 6502 to pull RESET on the CRTC + 3x 6551 ACIA 1 for the keyboard, 1 for the modem port, 1 for the printer port + + VIA hookup (see schematics): + PA3 = beep? + PA5 = inverse video + PA6 = IRQ in + PA7 = force blank + PB6 = Hblank in + CA1 = reset CRTC in + CA2 = reset CRTC out + CB2 = blink timer + + IRQ = ACIAs (all 3 ORed together) + NMI = 6522 VIA's IRQ line + + http://www.bitsavers.org/pdf/televideo/950/Model_950_Terminal_Theory_of_Operation_26Jan1981.pdf + http://www.bitsavers.org/pdf/televideo/950/2002100_Model_950_Maintenance_Manual_Nov1983.pdf + http://www.bitsavers.org/pdf/televideo/950/B300002-001_Model_950_Operators_Manual_Feb81.pdf + ****************************************************************************/ #include "emu.h" #include "cpu/m6502/m6502.h" +#include "video/mc6845.h" +#include "machine/6522via.h" +#include "machine/mos6551.h" +#include "bus/rs232/rs232.h" +#define ACIA1_TAG "acia1" +#define ACIA2_TAG "acia2" +#define ACIA3_TAG "acia3" +#define CRTC_TAG "crtc" +#define VIA_TAG "via" +#define RS232A_TAG "rs232a" +#define RS232B_TAG "rs232b" + +#define MASTER_CLOCK (23814000) class tv950_state : public driver_device { @@ -22,20 +57,39 @@ public: tv950_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") + , m_via(*this, VIA_TAG) + , m_crtc(*this, CRTC_TAG) + , m_vram(*this, "vram") { } + MC6845_UPDATE_ROW(crtc_update_row); + MC6845_ON_UPDATE_ADDR_CHANGED(crtc_update_addr); + + DECLARE_WRITE8_MEMBER(row_addr_w); + DECLARE_WRITE_LINE_MEMBER(via_crtc_reset_w); + private: virtual void machine_reset() override; - required_device m_maincpu; + required_device m_maincpu; + required_device m_via; + required_device m_crtc; + required_shared_ptr m_vram; + + int m_row_addr; }; static ADDRESS_MAP_START(tv950_mem, AS_PROGRAM, 8, tv950_state) ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0xefff) AM_RAM - AM_RANGE(0xf000, 0xffff) AM_ROM -ADDRESS_MAP_END - -static ADDRESS_MAP_START(tv950_io, AS_IO, 8, tv950_state) + AM_RANGE(0x0000, 0x07ff) AM_RAM + AM_RANGE(0x2000, 0x3fff) AM_RAM AM_SHARE("vram") // VRAM + AM_RANGE(0x8000, 0x8100) AM_DEVREADWRITE(CRTC_TAG, r6545_1_device, status_r, address_w) + AM_RANGE(0x8001, 0x8101) AM_DEVREADWRITE(CRTC_TAG, r6545_1_device, register_r, register_w) + AM_RANGE(0x9000, 0x9000) AM_WRITE(row_addr_w) + AM_RANGE(0x9300, 0x9303) AM_DEVREADWRITE(ACIA1_TAG, mos6551_device, read, write) + AM_RANGE(0x9500, 0x9503) AM_DEVREADWRITE(ACIA2_TAG, mos6551_device, read, write) + AM_RANGE(0x9900, 0x9903) AM_DEVREADWRITE(ACIA3_TAG, mos6551_device, read, write) + AM_RANGE(0xb100, 0xb10f) AM_DEVREADWRITE(VIA_TAG, via6522_device, read, write) + AM_RANGE(0xe000, 0xffff) AM_ROM AM_REGION("maincpu", 0) ADDRESS_MAP_END @@ -48,23 +102,75 @@ void tv950_state::machine_reset() { } +WRITE_LINE_MEMBER(tv950_state::via_crtc_reset_w) +{ + //printf("via_crtc_reset_w: %d\n", state); + m_via->write_ca1(state); + + if (!state) + { + //m_crtc->device_reset(); + } +} + +WRITE8_MEMBER(tv950_state::row_addr_w) +{ + m_row_addr = data; +} + +MC6845_ON_UPDATE_ADDR_CHANGED( tv950_state::crtc_update_addr ) +{ +} + +MC6845_UPDATE_ROW( tv950_state::crtc_update_row ) +{ +} + static MACHINE_CONFIG_START( tv950, tv950_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", M6502, XTAL_2MHz) + MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK/14) MCFG_CPU_PROGRAM_MAP(tv950_mem) - MCFG_CPU_IO_MAP(tv950_io) + + MCFG_SCREEN_ADD("screen", RASTER) + MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK, 882, 0, 720, 370, 0, 350 ) // not real values + MCFG_SCREEN_UPDATE_DEVICE( CRTC_TAG, r6545_1_device, screen_update ) + + // there are many 6845 CRTC submodels, the Theory of Operation manual references the Rockwell R6545-1 specificially. + MCFG_MC6845_ADD(CRTC_TAG, R6545_1, "screen", MASTER_CLOCK/14) + MCFG_MC6845_SHOW_BORDER_AREA(false) + MCFG_MC6845_CHAR_WIDTH(8) + MCFG_MC6845_UPDATE_ROW_CB(tv950_state, crtc_update_row) + MCFG_MC6845_ADDR_CHANGED_CB(tv950_state, crtc_update_addr) + MCFG_MC6845_OUT_HSYNC_CB(DEVWRITELINE(VIA_TAG, via6522_device, write_pb6)) + + MCFG_DEVICE_ADD(VIA_TAG, VIA6522, MASTER_CLOCK/14) + MCFG_VIA6522_IRQ_HANDLER(INPUTLINE("maincpu", M6502_NMI_LINE)) + MCFG_VIA6522_CA2_HANDLER(WRITELINE(tv950_state, via_crtc_reset_w)) + + MCFG_DEVICE_ADD(ACIA1_TAG, MOS6551, 0) + MCFG_MOS6551_XTAL(MASTER_CLOCK/13) + + MCFG_DEVICE_ADD(ACIA2_TAG, MOS6551, 0) + MCFG_MOS6551_XTAL(MASTER_CLOCK/13) + + MCFG_DEVICE_ADD(ACIA3_TAG, MOS6551, 0) + MCFG_MOS6551_XTAL(MASTER_CLOCK/13) MACHINE_CONFIG_END /* ROM definition */ ROM_START( tv950 ) - ROM_REGION(0x10000, "maincpu", 0) - ROM_SYSTEM_BIOS( 0, "8000043", "8000043") - ROMX_LOAD( "tv-043h.rom", 0xf000, 0x1000, CRC(89b826be) SHA1(fd5575be04317682d0c9062702b5932b46f89926), ROM_BIOS(1) ) - ROM_SYSTEM_BIOS( 1, "8000044", "8000044") - ROMX_LOAD( "tv-044h.rom", 0xf000, 0x1000, CRC(24b0383d) SHA1(71cabb7f3da8652a36afdf3d505ab8a41651e801), ROM_BIOS(2) ) + ROM_REGION(0x2000, "maincpu", 0) + ROM_LOAD( "180000-001a_a41_eb17.bin", 0x001000, 0x001000, CRC(b7187cc5) SHA1(41cc8fd51661314e03ee7e00cc1e206e9a694d92) ) + ROM_LOAD( "180000-007a_a42_67d3.bin", 0x000000, 0x001000, CRC(3ef2e6fb) SHA1(21ccfd2b50c37b715eed67671b82faa4d75fc6bb) ) + + ROM_REGION(0x2000, "graphics", 0) + ROM_LOAD16_BYTE( "180000-002a_a33_9294.bin", 0x000001, 0x001000, CRC(eaf4f346) SHA1(b4c531626846f3f055ddc086ac24fdb1b34f3f8e) ) + ROM_LOAD16_BYTE( "180000-003a_a32_7ebf.bin", 0x000000, 0x001000, CRC(783ca0b6) SHA1(1cec9a9a56ef5795809f7ca7cd2e3f61b27e698d) ) + + ROM_REGION(0x1000, "kbd", 0) + ROM_LOAD( "950kbd_8748_pn52080723-02.bin", 0x000000, 0x000400, CRC(11c8f22c) SHA1(99e73e9c74b10055733e89b92adbc5bf7f4ff338) ) ROM_END /* Driver */ - /* YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS */ -COMP( 198?, tv950, 0, 0, tv950, tv950, driver_device, 0, "Televideo", "TV950", MACHINE_IS_SKELETON ) +COMP( 1981, tv950, 0, 0, tv950, tv950, driver_device, 0, "TeleVideo", "TV950", MACHINE_NOT_WORKING | MACHINE_NO_SOUND ) 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/includes/aussiebyte.h b/src/mame/includes/aussiebyte.h index 0f798e1a99f..d410d4502c7 100644 --- a/src/mame/includes/aussiebyte.h +++ b/src/mame/includes/aussiebyte.h @@ -20,6 +20,7 @@ #include "bus/rs232/rs232.h" #include "machine/wd_fdc.h" #include "machine/msm5832.h" +#include "machine/clock.h" /*********************************************************** @@ -78,9 +79,9 @@ public: DECLARE_WRITE_LINE_MEMBER(sio1_rdyb_w); DECLARE_WRITE_LINE_MEMBER(sio2_rdya_w); DECLARE_WRITE_LINE_MEMBER(sio2_rdyb_w); + DECLARE_WRITE_LINE_MEMBER(clock_w); DECLARE_MACHINE_RESET(aussiebyte); DECLARE_DRIVER_INIT(aussiebyte); - TIMER_DEVICE_CALLBACK_MEMBER(ctc_tick); DECLARE_WRITE_LINE_MEMBER(ctc_z0_w); DECLARE_WRITE_LINE_MEMBER(ctc_z1_w); DECLARE_WRITE_LINE_MEMBER(ctc_z2_w); diff --git a/src/mame/includes/chihiro.h b/src/mame/includes/chihiro.h index 49801466e9f..3f47f8833a2 100644 --- a/src/mame/includes/chihiro.h +++ b/src/mame/includes/chihiro.h @@ -707,7 +707,7 @@ public: float modelview[4][4]; float modelview_inverse[4][4]; float projection[4][4]; - float translate[4]; + float traslate[4]; float scale[4]; } matrix; struct { diff --git a/src/mame/includes/lviv.h b/src/mame/includes/lviv.h index f0634fc237d..3a50e491732 100644 --- a/src/mame/includes/lviv.h +++ b/src/mame/includes/lviv.h @@ -57,7 +57,7 @@ public: void lviv_update_memory (); void lviv_setup_snapshot (UINT8 * data); void dump_registers(); - int lviv_verify_snapshot (UINT8 * data, UINT32 size); + bool lviv_verify_snapshot (UINT8 * data, UINT32 size); DECLARE_SNAPSHOT_LOAD_MEMBER( lviv ); DECLARE_INPUT_CHANGED_MEMBER(lviv_reset); }; diff --git a/src/mame/includes/lynx.h b/src/mame/includes/lynx.h index f11b34bd69f..6f3fcf779fa 100644 --- a/src/mame/includes/lynx.h +++ b/src/mame/includes/lynx.h @@ -181,7 +181,7 @@ public: void lynx_timer_count_down(int which); UINT32 lynx_time_factor(int val); void lynx_uart_reset(); - int lynx_verify_cart (char *header, int kind); + bool lynx_verify_cart (char *header, int kind); DECLARE_QUICKLOAD_LOAD_MEMBER( lynx ); protected: diff --git a/src/mame/includes/microtan.h b/src/mame/includes/microtan.h index c9e990ea472..1ab63792b4a 100644 --- a/src/mame/includes/microtan.h +++ b/src/mame/includes/microtan.h @@ -88,7 +88,7 @@ public: UINT8 read_dsw(); void microtan_set_irq_line(); void store_key(int key); - int microtan_verify_snapshot(UINT8 *data, int size); + bool microtan_verify_snapshot(UINT8 *data, int size); int parse_intel_hex(UINT8 *snapshot_buff, char *src); int parse_zillion_hex(UINT8 *snapshot_buff, char *src); void microtan_set_cpu_regs(const UINT8 *snapshot_buff, int base); diff --git a/src/mame/machine/atarifdc.cpp b/src/mame/machine/atarifdc.cpp index 29554a77f99..6c390d9839e 100644 --- a/src/mame/machine/atarifdc.cpp +++ b/src/mame/machine/atarifdc.cpp @@ -102,13 +102,13 @@ static const xfd_format xfd_formats[] = *****************************************************************************/ #define MAXSIZE 5760 * 256 + 80 -static void _atari_load_proc(device_image_interface &image) +static void _atari_load_proc(device_image_interface &image, bool is_created) { atari_fdc_device *atarifdc = static_cast(image.device().owner()); - atarifdc->atari_load_proc(image); + atarifdc->atari_load_proc(image, is_created); } -void atari_fdc_device::atari_load_proc(device_image_interface &image) +void atari_fdc_device::atari_load_proc(device_image_interface &image, bool is_created) { int id = floppy_get_drive(image); int size, i; @@ -121,7 +121,7 @@ void atari_fdc_device::atari_load_proc(device_image_interface &image) /* tell whether the image is writable */ m_drv[id].mode = !image.is_readonly(); /* set up image if it has been created */ - if (image.has_been_created()) + if (is_created) { int sector; char buff[256]; diff --git a/src/mame/machine/atarifdc.h b/src/mame/machine/atarifdc.h index 4c41c7b745a..355dea59aad 100644 --- a/src/mame/machine/atarifdc.h +++ b/src/mame/machine/atarifdc.h @@ -18,7 +18,7 @@ public: DECLARE_READ8_MEMBER( serin_r ); DECLARE_WRITE8_MEMBER( serout_w ); DECLARE_WRITE_LINE_MEMBER( pia_cb2_w ); - void atari_load_proc(device_image_interface &image); + void atari_load_proc(device_image_interface &image, bool is_created); protected: // device-level overrides diff --git a/src/mame/machine/cbm_snqk.cpp b/src/mame/machine/cbm_snqk.cpp index e066aa8e262..348f252432f 100644 --- a/src/mame/machine/cbm_snqk.cpp +++ b/src/mame/machine/cbm_snqk.cpp @@ -66,7 +66,7 @@ int general_cbm_loadsnap( device_image_interface &image, const char *file_type, } image.fread( &address, 2); - address = LITTLE_ENDIANIZE_INT16(address); + address = little_endianize_int16(address); if (!core_stricmp(file_type, "t64")) address = 2049; snapshot_size -= 2; 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/decocrpt.cpp b/src/mame/machine/decocrpt.cpp index 3ada025a017..680481a3e52 100644 --- a/src/mame/machine/decocrpt.cpp +++ b/src/mame/machine/decocrpt.cpp @@ -610,7 +610,7 @@ static void deco_decrypt(running_machine &machine,const char *rgntag,const UINT8 /* we work on 16-bit words but data is loaded as 8-bit, so swap bytes on LSB machines */ if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE) for (i = 0;i < len;i++) - rom[i] = BIG_ENDIANIZE_INT16(rom[i]); + rom[i] = big_endianize_int16(rom[i]); memcpy(&buffer[0],rom,len*2); @@ -644,7 +644,7 @@ static void deco_decrypt(running_machine &machine,const char *rgntag,const UINT8 /* we work on 16-bit words but data is loaded as 8-bit, so swap bytes on LSB machines */ if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE) for (i = 0;i < len;i++) - rom[i] = BIG_ENDIANIZE_INT16(rom[i]); + rom[i] = big_endianize_int16(rom[i]); } void deco56_decrypt_gfx(running_machine &machine, const char *tag) diff --git a/src/mame/machine/fddebug.cpp b/src/mame/machine/fddebug.cpp index a384512642d..22276a29f66 100644 --- a/src/mame/machine/fddebug.cpp +++ b/src/mame/machine/fddebug.cpp @@ -600,7 +600,7 @@ static void load_overlay_file(running_machine &machine) /* convert from big-endian */ for (pcaddr = 0; pcaddr < keystatus_words; pcaddr++) - keystatus[pcaddr] = BIG_ENDIANIZE_INT16(keystatus[pcaddr]) & ~SEARCH_MASK; + keystatus[pcaddr] = big_endianize_int16(keystatus[pcaddr]) & ~SEARCH_MASK; } /* mark the key dirty */ @@ -624,14 +624,14 @@ static void save_overlay_file(running_machine &machine) { /* convert to big-endian */ for (pcaddr = 0; pcaddr < keystatus_words; pcaddr++) - keystatus[pcaddr] = BIG_ENDIANIZE_INT16(keystatus[pcaddr]); + keystatus[pcaddr] = big_endianize_int16(keystatus[pcaddr]); /* write the data */ file.write(keystatus, keystatus_words * 2); /* convert from big-endian */ for (pcaddr = 0; pcaddr < keystatus_words; pcaddr++) - keystatus[pcaddr] = BIG_ENDIANIZE_INT16(keystatus[pcaddr]); + keystatus[pcaddr] = big_endianize_int16(keystatus[pcaddr]); } } diff --git a/src/mame/machine/lviv.cpp b/src/mame/machine/lviv.cpp index e2fd86c293f..44f307b7164 100644 --- a/src/mame/machine/lviv.cpp +++ b/src/mame/machine/lviv.cpp @@ -281,24 +281,24 @@ void lviv_state::dump_registers() logerror("HL = %04x\n", (unsigned) m_maincpu->state_int(I8085_HL)); } -int lviv_state::lviv_verify_snapshot (UINT8 * data, UINT32 size) +bool lviv_state::lviv_verify_snapshot (UINT8 * data, UINT32 size) { const char* tag = "LVOV/DUMP/2.0/"; if( strncmp( tag, (char*)data, strlen(tag) ) ) { logerror("Not a Lviv snapshot\n"); - return IMAGE_VERIFY_FAIL; + return false; } if (size != LVIV_SNAPSHOT_SIZE) { logerror ("Incomplete snapshot file\n"); - return IMAGE_VERIFY_FAIL; + return false; } logerror("returning ID_OK\n"); - return IMAGE_VERIFY_PASS; + return true; } SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) @@ -307,7 +307,7 @@ SNAPSHOT_LOAD_MEMBER( lviv_state, lviv ) image.fread( &lviv_snapshot_data[0], LVIV_SNAPSHOT_SIZE); - if(lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size) == IMAGE_VERIFY_FAIL) + if(!lviv_verify_snapshot(&lviv_snapshot_data[0], snapshot_size)) { return IMAGE_INIT_FAIL; } diff --git a/src/mame/machine/lynx.cpp b/src/mame/machine/lynx.cpp index 179ac99a40f..daf5167e93f 100644 --- a/src/mame/machine/lynx.cpp +++ b/src/mame/machine/lynx.cpp @@ -2030,14 +2030,14 @@ void lynx_state::machine_start() ****************************************/ -int lynx_state::lynx_verify_cart (char *header, int kind) +bool lynx_state::lynx_verify_cart (char *header, int kind) { if (kind) { if (strncmp("BS93", &header[6], 4)) { logerror("This is not a valid Lynx image\n"); - return IMAGE_VERIFY_FAIL; + return false; } } else @@ -2051,11 +2051,11 @@ int lynx_state::lynx_verify_cart (char *header, int kind) } else logerror("This is not a valid Lynx image\n"); - return IMAGE_VERIFY_FAIL; + return false; } } - return IMAGE_VERIFY_PASS; + return true; } DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart ) @@ -2082,7 +2082,7 @@ DEVICE_IMAGE_LOAD_MEMBER( lynx_state, lynx_cart ) image.fread(header, 0x40); // Check the image - if (lynx_verify_cart((char*)header, LYNX_CART) == IMAGE_VERIFY_FAIL) + if (!lynx_verify_cart((char*)header, LYNX_CART)) return IMAGE_INIT_FAIL; /* 2008-10 FP: According to Handy source these should be page_size_bank0. Are we using 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/microtan.cpp b/src/mame/machine/microtan.cpp index eb9c555cd04..422e79e16aa 100644 --- a/src/mame/machine/microtan.cpp +++ b/src/mame/machine/microtan.cpp @@ -522,23 +522,23 @@ void microtan_state::machine_reset() output().set_led_value(1, (m_keyrows[3] & 0x80) ? 0 : 1); } -int microtan_state::microtan_verify_snapshot(UINT8 *data, int size) +bool microtan_state::microtan_verify_snapshot(UINT8 *data, int size) { if (size == 8263) { logerror("microtan_snapshot_id: magic size %d found\n", size); - return IMAGE_VERIFY_PASS; + return true; } else { if (4 + data[2] + 256 * data[3] + 1 + 16 + 16 + 16 + 1 + 1 + 16 + 16 + 64 + 7 == size) { logerror("microtan_snapshot_id: header RAM size + structures matches filesize %d\n", size); - return IMAGE_VERIFY_PASS; + return true; } } - return IMAGE_VERIFY_FAIL; + return false; } int microtan_state::parse_intel_hex(UINT8 *snapshot_buff, char *src) @@ -827,7 +827,7 @@ SNAPSHOT_LOAD_MEMBER( microtan_state, microtan ) if (!snapshot_buff) return IMAGE_INIT_FAIL; - if (microtan_verify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL) + if (!microtan_verify_snapshot(snapshot_buff, snapshot_size)) return IMAGE_INIT_FAIL; microtan_snapshot_copy(snapshot_buff, snapshot_size); diff --git a/src/mame/machine/ms7004.cpp b/src/mame/machine/ms7004.cpp index 766b67173f4..5de44785bc3 100644 --- a/src/mame/machine/ms7004.cpp +++ b/src/mame/machine/ms7004.cpp @@ -176,164 +176,164 @@ F12 sends ^H */ INPUT_PORTS_START( ms7004 ) PORT_START("KBD12") // vertical row 1 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Print Screen (F2)") PORT_CODE(KEYCODE_F2) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Hold Screen (F1)") PORT_CODE(KEYCODE_F1) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Hold Screen (F1)") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // '{' / '|' - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) // '+' - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock") PORT_CODE(KEYCODE_CAPSLOCK) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LShift") PORT_CODE(KEYCODE_LSHIFT) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("; +") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') // '+' + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LShift") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_START("KBD13") // vertical row 2 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Setup (F3)") PORT_CODE(KEYCODE_F3) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Data / Talk (F4)") PORT_CODE(KEYCODE_F4) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("1") PORT_CODE(KEYCODE_1) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("J") PORT_CODE(KEYCODE_J) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("C") PORT_CODE(KEYCODE_C) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F") PORT_CODE(KEYCODE_F) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Rus/Lat") PORT_CODE(KEYCODE_ESC) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Compose") PORT_CODE(KEYCODE_LALT) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Setup (F3)") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Data / Talk (F4)") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("1 !") PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Rus/Lat") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Compose") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) PORT_START("KBD14") // vertical row 3 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Break (F5)") PORT_CODE(KEYCODE_F5) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Break (F5)") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("2") PORT_CODE(KEYCODE_2) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("U") PORT_CODE(KEYCODE_U) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tilde") PORT_CODE(KEYCODE_TILDE) // ^ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("2 \"") PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("` ~") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') // ^ + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("KBD15") // vertical row 4 PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3") PORT_CODE(KEYCODE_3) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("4") PORT_CODE(KEYCODE_4) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("K") PORT_CODE(KEYCODE_K) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("W") PORT_CODE(KEYCODE_W) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("S") PORT_CODE(KEYCODE_S) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3 #") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("4 $") PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("KBD11") // vertical row 5 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Interrupt (F6)") PORT_CODE(KEYCODE_F6) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("5") PORT_CODE(KEYCODE_5) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("E") PORT_CODE(KEYCODE_E) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("P") PORT_CODE(KEYCODE_P) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("A") PORT_CODE(KEYCODE_A) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("M") PORT_CODE(KEYCODE_M) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Interrupt (F6)") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("5 %") PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("KBD10") // vertical row 6 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Resume (F7)") PORT_CODE(KEYCODE_F7) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("6") PORT_CODE(KEYCODE_6) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("N") PORT_CODE(KEYCODE_N) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("G") PORT_CODE(KEYCODE_G) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("R") PORT_CODE(KEYCODE_R) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("T") PORT_CODE(KEYCODE_T) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("I") PORT_CODE(KEYCODE_I) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Resume (F7)") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("6 &") PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') PORT_START("KBD9") // vertical row 7 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Cancel (F8)") PORT_CODE(KEYCODE_F8) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Main Screen (F9)") PORT_CODE(KEYCODE_F9) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7") PORT_CODE(KEYCODE_7) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("O") PORT_CODE(KEYCODE_O) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("X") PORT_CODE(KEYCODE_X) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("B") PORT_CODE(KEYCODE_B) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Cancel (F8)") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Main Screen (F9)") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("7 '") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') PORT_START("KBD8") // vertical row 8 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Exit (F10)") PORT_CODE(KEYCODE_F10) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("9") PORT_CODE(KEYCODE_9) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("8") PORT_CODE(KEYCODE_8) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("D") PORT_CODE(KEYCODE_D) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("L") PORT_CODE(KEYCODE_L) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) // '@' - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Exit (F10)") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("9 )") PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("8 (") PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("@") // '@' + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(", <") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') PORT_START("KBD7") // vertical row 9 PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC (F11)") PORT_CODE(KEYCODE_F11) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0") PORT_CODE(KEYCODE_0) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("H") PORT_CODE(KEYCODE_H) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("V") PORT_CODE(KEYCODE_V) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\") PORT_CODE(KEYCODE_BACKSLASH) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC (F11)") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("- =") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') PORT_START("KBD6") // vertical row 10 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("BS (F12)") PORT_CODE(KEYCODE_F12) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LF (F13)") PORT_CODE(KEYCODE_PRTSCR) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("BS (F12)") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("LF (F13)") PORT_CODE(KEYCODE_PRTSCR) PORT_CHAR(UCHAR_MAMEKEY(PRTSCR)) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // '}' PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("'") PORT_CODE(KEYCODE_QUOTE) // ':' + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(": *") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) // '??' - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("_") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('_') PORT_START("KBD5") // vertical row 11 - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Additional Options (F14)") PORT_CODE(KEYCODE_PAUSE) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Additional Options (F14)") PORT_CODE(KEYCODE_PAUSE) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Delete (owner); msx_internal_slot_interface *internal_slot = dynamic_cast(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/psion_pack.cpp b/src/mame/machine/psion_pack.cpp index a773f7114e5..070e477d0c8 100644 --- a/src/mame/machine/psion_pack.cpp +++ b/src/mame/machine/psion_pack.cpp @@ -94,7 +94,7 @@ void datapack_device::device_start() void datapack_device::device_config_complete() { - m_formatlist.push_back(std::make_unique("opk", "Psion Datapack image", "opk", datapack_option_spec)); + add_format("opk", "Psion Datapack image", "opk", datapack_option_spec); // set brief and instance name update_names(); 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/machine/z80bin.cpp b/src/mame/machine/z80bin.cpp index ac18c8e7e11..7a5bb3d24c3 100644 --- a/src/mame/machine/z80bin.cpp +++ b/src/mame/machine/z80bin.cpp @@ -8,7 +8,7 @@ memory -------------------------------------------------*/ -int z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ) +bool z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ) { int ch; UINT16 args[3]; @@ -51,9 +51,9 @@ int z80bin_load_file(device_image_interface *image, address_space &space, const return IMAGE_INIT_FAIL; } - exec_addr[0] = LITTLE_ENDIANIZE_INT16(args[0]); - start_addr[0] = LITTLE_ENDIANIZE_INT16(args[1]); - end_addr[0] = LITTLE_ENDIANIZE_INT16(args[2]); + exec_addr[0] = little_endianize_int16(args[0]); + start_addr[0] = little_endianize_int16(args[1]); + end_addr[0] = little_endianize_int16(args[2]); size = (end_addr[0] - start_addr[0] + 1) & 0xffff; diff --git a/src/mame/machine/z80bin.h b/src/mame/machine/z80bin.h index 1690ebffcda..7a839466506 100644 --- a/src/mame/machine/z80bin.h +++ b/src/mame/machine/z80bin.h @@ -13,6 +13,6 @@ #ifndef __Z80_BIN__ #define __Z80_BIN__ -int z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ); +bool z80bin_load_file(device_image_interface *image, address_space &space, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr ); #endif diff --git a/src/mame/mame.lst b/src/mame/mame.lst index c459953f179..3cd222328b4 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -33617,6 +33617,7 @@ roldfrog // not a gaelco game but based on splash code roldfroga // not a gaelco game but based on splash code splash // (c) 1992 - Ref 922804 splash10 // (c) 1992 - Ref 922804 +ringball // not a gaelco game but based on splash code @source:splus.cpp spss4240 // 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..21fe7d30ba1 100644 --- a/src/mame/video/chihiro.cpp +++ b/src/mame/video/chihiro.cpp @@ -2366,7 +2366,6 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti // should use either the vertex program or transformation matrices if (vertex_pipeline == 4) { // transformation matrices - // it is not implemented, so we pretend its always using screen coordinates for (m = 0; m < count; m++) { for (int i = 0; i < 4; i++) { t[i] = 0; @@ -2378,11 +2377,12 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti for (int j = 0; j < 4; j++) v[i] += matrix.projection[i][j] * t[j]; }; - /*for (int i = 0; i < 3; i++) { + /* it seems these are not needed ? + for (int i = 0; i < 3; i++) { v[i] *= matrix.scale[i]; } for (int i = 0; i < 3; i++) { - v[i] += matrix.translate[i]; + v[i] += matrix.traslate[i]; }*/ destination[m].w = v[3]; destination[m].x = (v[0] / v[3])*supersample_factor_x; // source[m].attribute[0].fv[0]; @@ -2400,6 +2400,7 @@ void nv2a_renderer::convert_vertices_poly(vertex_nv *source, nv2avertex_t *desti // vertex program // run vertex program vertexprogram.exec.process(vertexprogram.start_instruction, source, vert, count); + // the output of the vertex program has the perspective divide, viewport scale and offset already applied // copy data for poly.c for (m = 0; m < count; m++) { destination[m].w = vert[m].attribute[0].fv[3]; @@ -2680,6 +2681,15 @@ UINT32 nv2a_renderer::render_triangle_clipping(const rectangle &cliprect, render vi[2] = &_v3; for (int n=0;n < 3;n++) { + // remove traslate + vi[n]->x = vi[n]->x - translatex; + vi[n]->y = vi[n]->y - translatey; + vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] - translatez; + // remove scale + vi[n]->x = vi[n]->x / scalex; + vi[n]->y = vi[n]->y / scaley; + vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] / scalez; + // remove perspective divide vi[n]->x = vi[n]->x * vi[n]->w; vi[n]->y = vi[n]->y * vi[n]->w; vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] = vi[n]->p[(int)VERTEX_PARAMETER::PARAM_Z] * vi[n]->w; @@ -2715,16 +2725,26 @@ UINT32 nv2a_renderer::render_triangle_clipping(const rectangle &cliprect, render } for (int n = 0; n < idx; n++) { + // apply perspective divide vo[n].x = vo[n].x / vo[n].w; vo[n].y = vo[n].y / vo[n].w; vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] / vo[n].w; + // apply scale + vo[n].x = vo[n].x * scalex; + vo[n].y = vo[n].y * scaley; + vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] * scalez; + // apply traslate + vo[n].x = vo[n].x + translatex; + vo[n].y = vo[n].y + translatey; + vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] = vo[n].p[(int)VERTEX_PARAMETER::PARAM_Z] + translatez; + } + for (int n = 0; n < (idx-2); n++) + { + if ((n & 1) == 0) + render_triangle_culling(cliprect, callback, paramcount, vo[n], vo[n + 1], vo[n + 2]); + else + render_triangle_culling(cliprect, callback, paramcount, vo[n], vo[n + 2], vo[n + 1]); } - if (idx > 2) - render_triangle_culling(cliprect, callback, paramcount, vo[0], vo[1], vo[2]); - if (idx > 3) - render_triangle_culling(cliprect, callback, paramcount, vo[0], vo[2], vo[3]); - if (idx > 4) - exit(0); #endif return 0; } @@ -2869,7 +2889,7 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN data = space.read_dword(address); channel[chanel][subchannel].object.method[method] = data; #ifdef LOG_NV2A - printf("A:%08X MTHD:%08X D:%08X\n\r",address,maddress,data); + //printf("A:%08X MTHD:%08X D:%08X\n\r",address,maddress,data); #endif if (maddress == 0x17fc) { #if 0 // useful while debugging to see what coordinates have been used @@ -3483,12 +3503,16 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN *(UINT32 *)(&matrix.projection[maddress >> 2][maddress & 3]) = data; countlen--; } - // viewport translate + // viewport traslate if ((maddress >= 0x0a20) && (maddress < 0x0a30)) { maddress = (maddress - 0x0a20) / 4; - *(UINT32 *)(&matrix.translate[maddress]) = data; + *(UINT32 *)(&matrix.traslate[maddress]) = data; // set corresponding vertex shader constant too vertexprogram.exec.c_constant[59].iv[maddress] = data; // constant -37 +#ifdef LOG_NV2A + if (maddress == 3) + machine().logerror("viewport traslate = {%f %f %f %f}\n", matrix.traslate[0], matrix.traslate[1], matrix.traslate[2], matrix.traslate[3]); +#endif countlen--; } // viewport scale @@ -3497,6 +3521,10 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN *(UINT32 *)(&matrix.scale[maddress]) = data; // set corresponding vertex shader constant too vertexprogram.exec.c_constant[58].iv[maddress] = data; // constant -38 +#ifdef LOG_NV2A + if (maddress == 3) + machine().logerror("viewport scale = {%f %f %f %f}\n", matrix.scale[0], matrix.scale[1], matrix.scale[2], matrix.scale[3]); +#endif countlen--; } // Vertex program (shader) @@ -3557,6 +3585,15 @@ int nv2a_renderer::geforce_exec_method(address_space & space, UINT32 chanel, UIN machine().logerror("Need to increase size of vertexprogram.parameter to %d\n\r", vertexprogram.upload_parameter_index); vertexprogram.upload_parameter_component++; if (vertexprogram.upload_parameter_component >= 4) { +#ifdef LOG_NV2A + if ((vertexprogram.upload_parameter_index == 58) || (vertexprogram.upload_parameter_index == 59)) + machine().logerror("vp constant %d (%s) = {%f %f %f %f}\n", vertexprogram.upload_parameter_index, + vertexprogram.upload_parameter_index == 58 ? "viewport scale" : "viewport traslate", + vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[0], + vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[1], + vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[2], + vertexprogram.exec.c_constant[vertexprogram.upload_parameter_index].fv[3]); +#endif vertexprogram.upload_parameter_component = 0; vertexprogram.upload_parameter_index++; } @@ -3851,18 +3888,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 +3917,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 +4125,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 +4179,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 +4262,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 +4310,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 +4321,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) @@ -4616,6 +4653,8 @@ WRITE32_MEMBER(nv2a_renderer::geforce_w) dmaget = &channel[chanel][0].regs[0x44 / 4]; //printf("dmaget %08X dmaput %08X\n\r",*dmaget,*dmaput); if (((*dmaput == 0x048cf000) && (*dmaget == 0x07f4d000)) || // only for outr2 + ((*dmaput == 0x045cd000) && (*dmaget == 0x07f4d000)) || // only for scg06nt + ((*dmaput == 0x0494c000) && (*dmaget == 0x07f4d000)) || // only for wangmid ((*dmaput == 0x07dca000) && (*dmaget == 0x07f4d000))) // only for crtaxihr { *dmaget = *dmaput; 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..f9bf650a7ac 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, CGFloat(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, CGFloat(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..853fe8fd4b6 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, CGFloat(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..56108223cb7 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, CGFloat(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..de1c65f90cb 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)(maxwidth(), work_bounds.right - work_bounds.left); + int const bestheight = (std::min)(500, 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 #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..cdacba72ceb 100644 --- a/src/osd/modules/diagnostics/diagnostics_win32.cpp +++ b/src/osd/modules/diagnostics/diagnostics_win32.cpp @@ -22,6 +22,9 @@ #include #include +#undef min +#undef max +#include #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(item1); const FPTR *entry2 = reinterpret_cast(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..45752639d0a 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -18,6 +18,9 @@ #include #include #include +#undef min +#undef max +#include //============================================================ @@ -461,10 +464,10 @@ class input_module_base : public input_module public: input_module_base(const char *type, const char* name) : input_module(type, name), - m_input_enabled(FALSE), - m_mouse_enabled(FALSE), - m_lightgun_enabled(FALSE), - m_input_paused(FALSE), + m_input_enabled(false), + m_mouse_enabled(false), + m_lightgun_enabled(false), + m_input_paused(false), m_options(nullptr) { } @@ -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..f12e30a26c2 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -22,7 +22,10 @@ #undef WINNT #include #undef interface +#undef min +#undef max +#include #include #include @@ -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..1bd0cd9fe28 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -16,6 +16,8 @@ #include #include #undef interface +#undef min +#undef max #include #include @@ -521,7 +523,7 @@ protected: { // Only handle raw input data if (!input_enabled() || eventid != INPUT_EVENT_RAWINPUT) - return FALSE; + return false; HRAWINPUT rawinputdevice = *static_cast(eventdata); @@ -533,11 +535,11 @@ protected: // ignore if not enabled if (!input_enabled()) - return FALSE; + return false; // determine the size of databuffer we need if ((*get_rawinput_data)(rawinputdevice, RID_INPUT, nullptr, &size, sizeof(RAWINPUTHEADER)) != 0) - return FALSE; + return false; // if necessary, allocate a temporary buffer and fetch the data if (size > sizeof(small_buffer)) @@ -545,7 +547,7 @@ protected: larger_buffer = std::make_unique(size); data = larger_buffer.get(); if (data == nullptr) - return FALSE; + return false; } // fetch the data and process the appropriate message types @@ -565,7 +567,7 @@ protected: if (input->header.hDevice == devinfo->device_handle()) { devinfo->queue_events(input, 1); - result = TRUE; + result = true; } } } diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 24234969eef..ce1cf4e883f 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 #undef interface +#undef min +#undef max // MAME headers #include "emu.h" @@ -93,7 +95,7 @@ public: bool handle_input_event(input_event eventid, void *eventdata) override { if (!input_enabled()) - return FALSE; + return false; KeyPressEventArgs *args; @@ -105,10 +107,10 @@ public: for (int i = 0; i < devicelist()->size(); i++) downcast(devicelist()->at(i))->queue_events(args, 1); - return TRUE; + return true; default: - return FALSE; + return false; } } }; @@ -229,13 +231,13 @@ public: bool handle_input_event(input_event eventid, void *eventdata) override { if (!input_enabled() || !mouse_enabled() || eventid != INPUT_EVENT_MOUSE_BUTTON) - return FALSE; + return false; auto args = static_cast(eventdata); for (int i = 0; i < devicelist()->size(); i++) downcast(devicelist()->at(i))->queue_events(args, 1); - return TRUE; + return true; } }; 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 #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 #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 #include #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 #include - +#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..105313cb308 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 //============================================================ // PROTOTYPES @@ -538,19 +540,19 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r options->scanline_bright_offset = winoptions.screen_scanline_bright_offset(); options->scanline_jitter = winoptions.screen_scanline_jitter(); options->hum_bar_alpha = winoptions.screen_hum_bar_alpha(); - get_vector(winoptions.screen_defocus(), 2, options->defocus, TRUE); - get_vector(winoptions.screen_converge_x(), 3, options->converge_x, TRUE); - get_vector(winoptions.screen_converge_y(), 3, options->converge_y, TRUE); - get_vector(winoptions.screen_radial_converge_x(), 3, options->radial_converge_x, TRUE); - get_vector(winoptions.screen_radial_converge_y(), 3, options->radial_converge_y, TRUE); - get_vector(winoptions.screen_red_ratio(), 3, options->red_ratio, TRUE); - get_vector(winoptions.screen_grn_ratio(), 3, options->grn_ratio, TRUE); - get_vector(winoptions.screen_blu_ratio(), 3, options->blu_ratio, TRUE); - get_vector(winoptions.screen_offset(), 3, options->offset, TRUE); - get_vector(winoptions.screen_scale(), 3, options->scale, TRUE); - get_vector(winoptions.screen_power(), 3, options->power, TRUE); - get_vector(winoptions.screen_floor(), 3, options->floor, TRUE); - get_vector(winoptions.screen_phosphor(), 3, options->phosphor, TRUE); + get_vector(winoptions.screen_defocus(), 2, options->defocus, true); + get_vector(winoptions.screen_converge_x(), 3, options->converge_x, true); + get_vector(winoptions.screen_converge_y(), 3, options->converge_y, true); + get_vector(winoptions.screen_radial_converge_x(), 3, options->radial_converge_x, true); + get_vector(winoptions.screen_radial_converge_y(), 3, options->radial_converge_y, true); + get_vector(winoptions.screen_red_ratio(), 3, options->red_ratio, true); + get_vector(winoptions.screen_grn_ratio(), 3, options->grn_ratio, true); + get_vector(winoptions.screen_blu_ratio(), 3, options->blu_ratio, true); + get_vector(winoptions.screen_offset(), 3, options->offset, true); + get_vector(winoptions.screen_scale(), 3, options->scale, true); + get_vector(winoptions.screen_power(), 3, options->power, true); + get_vector(winoptions.screen_floor(), 3, options->floor, true); + get_vector(winoptions.screen_phosphor(), 3, options->phosphor, true); options->saturation = winoptions.screen_saturation(); options->yiq_enable = winoptions.screen_yiq_enable(); options->yiq_jitter = winoptions.screen_yiq_jitter(); @@ -570,7 +572,7 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r options->vector_length_ratio = winoptions.screen_vector_length_ratio(); options->bloom_blend_mode = winoptions.screen_bloom_blend_mode(); options->bloom_scale = winoptions.screen_bloom_scale(); - get_vector(winoptions.screen_bloom_overdrive(), 3, options->bloom_overdrive, TRUE); + get_vector(winoptions.screen_bloom_overdrive(), 3, options->bloom_overdrive, true); options->bloom_level0_weight = winoptions.screen_bloom_lvl0_weight(); options->bloom_level1_weight = winoptions.screen_bloom_lvl1_weight(); options->bloom_level2_weight = winoptions.screen_bloom_lvl2_weight(); @@ -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(r * 255.0f))), - MAX(0, MIN(255, static_cast(g * 255.0f))), - MAX(0, MIN(255, static_cast(b * 255.0f)))); + std::max(0, std::min(255, static_cast(r * 255.0f))), + std::max(0, std::min(255, static_cast(g * 255.0f))), + std::max(0, std::min(255, static_cast(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..17d77dd4446 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 //============================================================ // TYPE DEFINITIONS @@ -852,7 +854,7 @@ try_again: D3DRTYPE_TEXTURE, m_screen_format); if (FAILED(result) && m_texture_manager->is_dynamic_supported()) { - m_texture_manager->set_dynamic_supported(FALSE); + m_texture_manager->set_dynamic_supported(false); goto try_again; } if (FAILED(result)) @@ -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..483af364aa4 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 unsigned(std::max(std::min(m_audio_latency, int(LATENCY_MAX)), int(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, 256U); m_buffer = global_alloc_array_clear(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..745a20932f0 100644 --- a/src/osd/modules/sound/direct_sound.cpp +++ b/src/osd/modules/sound/direct_sound.cpp @@ -20,6 +20,8 @@ #undef WINNT #include #undef interface +#undef min +#undef max // MAME headers #include "emu.h" @@ -34,6 +36,7 @@ #include "winmain.h" #include "window.h" #endif +#include //============================================================ // 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..dc14acff64d 100644 --- a/src/osd/modules/sound/xaudio2_sound.cpp +++ b/src/osd/modules/sound/xaudio2_sound.cpp @@ -20,13 +20,16 @@ // XAudio2 include #include +#undef interface +#undef min +#undef max + // stdlib includes #include #include #include #include - -#undef interface +#include // 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..a97920cff7f 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,12 +122,12 @@ 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)) +constexpr UINT64 concat_64(UINT32 hi, UINT32 lo) { return (UINT64(hi) << 32) | UINT32(lo); } +constexpr UINT32 extract_64hi(UINT64 val) { return UINT32(val >> 32); } +constexpr UINT32 extract_64lo(UINT64 val) { return UINT32(val); } // Highly useful template for compile-time knowledge of an array size -template constexpr inline size_t ARRAY_LENGTH(T (&)[N]) { return N;} +template constexpr size_t ARRAY_LENGTH(T (&)[N]) { return N;} // For declaring an array of the same dimensions as another array (including multi-dimensional arrays) template struct equivalent_array_or_type { typedef T type; }; @@ -147,42 +138,35 @@ template struct equivalent_array using equivalent_array_t = typename equivalent_array::type; #define EQUIVALENT_ARRAY(a, T) equivalent_array_t > - /* 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) \ - ) +constexpr UINT16 flipendian_int16(UINT16 val) { return (val << 8) | (val >> 8); } + +constexpr UINT32 flipendian_int32_partial16(UINT32 val) { return ((val << 8) & 0xFF00FF00U) | ((val >> 8) & 0x00FF00FFU); } +constexpr UINT32 flipendian_int32(UINT32 val) { return (flipendian_int32_partial16(val) << 16) | (flipendian_int32_partial16(val) >> 16); } + +constexpr UINT64 flipendian_int64_partial16(UINT64 val) { return ((val << 8) & U64(0xFF00FF00FF00FF00)) | ((val >> 8) & U64(0x00FF00FF00FF00FF)); } +constexpr UINT64 flipendian_int64_partial32(UINT64 val) { return ((flipendian_int64_partial16(val) << 16) & U64(0xFFFF0000FFFF0000)) | ((flipendian_int64_partial16(val) >> 16) & U64(0x0000FFFF0000FFFF)); } +constexpr UINT64 flipendian_int64(UINT64 val) { return (flipendian_int64_partial32(val) << 32) | (flipendian_int64_partial32(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 LITTLE_ENDIANIZE_INT16(x) (x) -#define LITTLE_ENDIANIZE_INT32(x) (x) -#define LITTLE_ENDIANIZE_INT64(x) (x) +constexpr UINT16 big_endianize_int16(UINT16 x) { return flipendian_int16(x); } +constexpr UINT32 big_endianize_int32(UINT32 x) { return flipendian_int32(x); } +constexpr UINT64 big_endianize_int64(UINT64 x) { return flipendian_int64(x); } +constexpr UINT16 little_endianize_int16(UINT16 x) { return x; } +constexpr UINT32 little_endianize_int32(UINT32 x) { return x; } +constexpr UINT64 little_endianize_int64(UINT64 x) { return x; } #else -#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)) +constexpr UINT16 big_endianize_int16(UINT16 x) { return x; } +constexpr UINT32 big_endianize_int32(UINT32 x) { return x; } +constexpr UINT64 big_endianize_int64(UINT64 x) { return x; } +constexpr UINT16 little_endianize_int16(UINT16 x) { return flipendian_int16(x); } +constexpr UINT32 little_endianize_int32(UINT32 x) { return flipendian_int32(x); } +constexpr UINT64 little_endianize_int64(UINT64 x) { return flipendian_int64(x); } #endif /* LSB_FIRST */ #ifdef _MSC_VER #include -typedef ptrdiff_t ssize_t; +using ssize_t = std::make_signed_t; #if _MSC_VER == 1900 // VS2015 #define __LINE__Var 0 #endif // VS2015 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 #include #include - +#undef min +#undef max +#include // 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/osdsync.h b/src/osd/osdsync.h index 07b1d9fd82d..92bfd11fedc 100644 --- a/src/osd/osdsync.h +++ b/src/osd/osdsync.h @@ -91,7 +91,7 @@ public: { if (!m_signalled) { - return FALSE; + return false; } else break; 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 #endif - +#undef min +#undef max +#include // 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(count), &wch, 1) == 0) goto error; diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index b1cc369c0af..12832f8580d 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(&machine.osd()) -// min(x, y) macro interferes with chrono time_point::min() #undef min +#undef max //============================================================ // PARAMETERS @@ -406,7 +406,7 @@ void winwindow_process_events_periodic(running_machine &machine) // update once every 1/8th of a second if (currticks - last_event_check < std::chrono::milliseconds(1000 / 8)) return; - winwindow_process_events(machine, TRUE, FALSE); + winwindow_process_events(machine, TRUE, false); } @@ -415,13 +415,13 @@ void winwindow_process_events_periodic(running_machine &machine) // is_mame_window //============================================================ -static BOOL is_mame_window(HWND hwnd) +static bool is_mame_window(HWND hwnd) { for (auto window : osd_common_t::s_window_list) if (window->platform_window() == hwnd) - return TRUE; + return true; - return FALSE; + return false; } inline static BOOL handle_mouse_button(windows_osd_interface *osd, int button, int down, int x, int y) @@ -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..f7fe16310bd 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 = unsigned((std::min)(m_info.channels, 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, end_offset - offset); memcpy(dest, &m_rawdata[offset - start_offset], bytes_to_copy); // advance @@ -1449,7 +1449,7 @@ static void do_info(parameters_t ¶ms) 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 ¶ms) 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)(buffer.size(), 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 ¶ms) } // 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 ¶ms) 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)(buffer.size(), 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 ¶ms) 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 /* ----------------------------------------------------------------------- * 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/amiga.cpp b/src/tools/imgtool/modules/amiga.cpp index 35e8b896c1f..fa53e24dfad 100644 --- a/src/tools/imgtool/modules/amiga.cpp +++ b/src/tools/imgtool/modules/amiga.cpp @@ -367,7 +367,7 @@ static void copy_integer_array_be(UINT32 *dest, const UINT32 *source, int size) for (i = 0; i < size; i++) { - dest[i] = BIG_ENDIANIZE_INT32(source[i]); + dest[i] = big_endianize_int32(source[i]); } } @@ -375,9 +375,9 @@ static void copy_integer_array_be(UINT32 *dest, const UINT32 *source, int size) /* This function converts an array of UINT32s to an amiga_date */ static void copy_date_be(amiga_date *dest, const UINT32 *source) { - dest->days = BIG_ENDIANIZE_INT32(source[0]); - dest->mins = BIG_ENDIANIZE_INT32(source[1]); - dest->ticks = BIG_ENDIANIZE_INT32(source[2]); + dest->days = big_endianize_int32(source[0]); + dest->mins = big_endianize_int32(source[1]); + dest->ticks = big_endianize_int32(source[2]); } 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..ad75a206193 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))) { @@ -578,7 +578,7 @@ static imgtoolerr_t fat_partition_create(imgtool_image *image, UINT64 first_bloc first_fat_entries = ((UINT64) media_descriptor) | 0xFFFFFF00; first_fat_entries &= (((UINT64) 1) << fat_bits) - 1; first_fat_entries |= ((((UINT64) 1) << fat_bits) - 1) << fat_bits; - first_fat_entries = LITTLE_ENDIANIZE_INT64(first_fat_entries); + first_fat_entries = little_endianize_int64(first_fat_entries); for (i = 0; i < fat_count; i++) { @@ -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) @@ -698,7 +698,7 @@ static UINT32 fat_get_fat_entry(imgtool_partition *partition, const UINT8 *fat_t * disk_info->sectors_per_fat) + (bit_index / 8), sizeof(entry)); /* we've extracted the bytes; we now need to normalize it */ - entry = LITTLE_ENDIANIZE_INT64(entry); + entry = little_endianize_int64(entry); entry >>= bit_index % 8; entry &= bit_mask; @@ -735,10 +735,10 @@ static void fat_set_fat_entry(imgtool_partition *partition, UINT8 *fat_table, UI memcpy(&entry, fat_table + (i * FAT_SECLEN * disk_info->sectors_per_fat) + (bit_index / 8), sizeof(entry)); - entry = LITTLE_ENDIANIZE_INT64(entry); + entry = little_endianize_int64(entry); entry &= (~((UINT64) 0xFFFFFFFF >> (32 - disk_info->fat_bits)) << (bit_index % 8)) | ((1 << (bit_index % 8)) - 1); entry |= ((UINT64) value) << (bit_index % 8); - entry = LITTLE_ENDIANIZE_INT64(entry); + entry = little_endianize_int64(entry); memcpy(fat_table + (i * FAT_SECLEN * disk_info->sectors_per_fat) + (bit_index / 8), &entry, sizeof(entry)); @@ -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,14 +1159,14 @@ 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++) { /* read the character */ memcpy(&w, &entry[offset + i * 2], 2); - w = LITTLE_ENDIANIZE_INT16(w); + w = little_endianize_int16(w); /* append to buffer */ lfn_buf[i] = (w != 0xFFFF) ? w : 0; @@ -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, 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..0e165f6d881 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, 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, 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)(sz, 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..8aea81031e5 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, UINT64(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) + 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 */ diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 1c9c74bb7e1..ddcaf7ec389 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -212,14 +212,14 @@ CPU_DISASSEMBLE( z8 ); CPU_DISASSEMBLE( z80 ); CPU_DISASSEMBLE( z8000 ); -CPU_DISASSEMBLE( sparcv7 ) { static sparc_disassembler dasm(nullptr, 7); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv8 ) { static sparc_disassembler dasm(nullptr, 8); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9 ) { static sparc_disassembler dasm(nullptr, 9); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9vis1 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_1); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9vis2 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_2); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9vis2p ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_2p); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9vis3 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_3); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } -CPU_DISASSEMBLE( sparcv9vis3b ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_3b); return dasm.dasm(buffer, pc, BIG_ENDIANIZE_INT32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv7 ) { static sparc_disassembler dasm(nullptr, 7); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv8 ) { static sparc_disassembler dasm(nullptr, 8); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9 ) { static sparc_disassembler dasm(nullptr, 9); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9vis1 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_1); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9vis2 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_2); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9vis2p ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_2p); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9vis3 ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_3); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } +CPU_DISASSEMBLE( sparcv9vis3b ) { static sparc_disassembler dasm(nullptr, 9, sparc_disassembler::vis_3b); return dasm.dasm(buffer, pc, big_endianize_int32(*reinterpret_cast(oprom))); } static const dasm_table_entry dasm_table[] =