From c43a83bbdcdd3d5261d5793688795c0d0e58e0af Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 3 Feb 2024 14:31:45 +1100 Subject: Miscellaneous cleanups: konami/hexion.cpp: Fixed a potential heap smash, and don't mark tiles dirty unnecessarily. konami/spy.cpp: Fixed video enable never being set to false, added an object finder for ROM bank (reduce tag lookups). tvgames/xavix.cpp: It's stylised "Hi-kara" (no capital K), software list already uses this capitalisation. rm/rm380z*: Added object finder for character generator ROM, slightly cleaned up some code. homelab/homelab.cpp: Avoid some literal sizes. --- src/lib/util/flac.cpp | 6 +- src/lib/util/flac.h | 6 +- src/mame/homelab/homelab.cpp | 20 ++--- src/mame/konami/hexion.cpp | 111 ++++++++++++++-------------- src/mame/konami/spy.cpp | 170 +++++++++++++++++++++---------------------- src/mame/rm/rm380z.h | 110 ++++++++++++++-------------- src/mame/rm/rm380z_m.cpp | 100 ++++++++++++------------- src/mame/rm/rm380z_v.cpp | 120 +++++++++++++----------------- src/mame/tvgames/xavix.cpp | 2 +- 9 files changed, 316 insertions(+), 329 deletions(-) diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp index 4d6a3bca81b..66114e0e192 100644 --- a/src/lib/util/flac.cpp +++ b/src/lib/util/flac.cpp @@ -601,12 +601,12 @@ FLAC__StreamDecoderTellStatus flac_decoder::tell_callback_static(const FLAC__Str // stream //------------------------------------------------- -FLAC__StreamDecoderWriteStatus flac_decoder::write_callback_static(const FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) +FLAC__StreamDecoderWriteStatus flac_decoder::write_callback_static(const FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) { return reinterpret_cast(client_data)->write_callback(frame, buffer); } -FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) +FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[]) { assert(frame->header.channels == channels()); @@ -633,7 +633,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame } } -template FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) +template FLAC__StreamDecoderWriteStatus flac_decoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[]) { const int blocksize = frame->header.blocksize; const int shift = (Mode == SCALE_DOWN) ? frame->header.bits_per_sample - m_bits_per_sample : (Mode == SCALE_UP) ? m_bits_per_sample - frame->header.bits_per_sample : 0; diff --git a/src/lib/util/flac.h b/src/lib/util/flac.h index c3fee4b574b..7170ea96230 100644 --- a/src/lib/util/flac.h +++ b/src/lib/util/flac.h @@ -123,9 +123,9 @@ private: FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); static void metadata_callback_static(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); static FLAC__StreamDecoderTellStatus tell_callback_static(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); - static FLAC__StreamDecoderWriteStatus write_callback_static(const FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); - FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); - template FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); + static FLAC__StreamDecoderWriteStatus write_callback_static(const FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data); + FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[]); + template FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[]); static void error_callback_static(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); // output state diff --git a/src/mame/homelab/homelab.cpp b/src/mame/homelab/homelab.cpp index 8bd288b4801..bb2c49079c5 100644 --- a/src/mame/homelab/homelab.cpp +++ b/src/mame/homelab/homelab.cpp @@ -47,8 +47,8 @@ MB7051 - fuse programmed prom. #include "screen.h" #include "speaker.h" -namespace -{ +namespace { + class homelab_state : public driver_device { public: @@ -84,15 +84,15 @@ class homelab2_state : public homelab_state { public: homelab2_state(const machine_config &mconfig, device_type type, const char *tag) : - homelab_state(mconfig, type, tag), - m_nmi(0), - m_screenshadow_is_text_mode(true), - m_screenshadowY0(0), - m_screenshadowX0(0), - m_spr_bit(0) + homelab_state(mconfig, type, tag), + m_nmi(0), + m_screenshadow_is_text_mode(true), + m_screenshadowY0(0), + m_screenshadowX0(0), + m_spr_bit(0) { - std::fill_n(m_4000shadow, 0x4000, 0); - std::fill_n(m_screenshadow, 40 * 265, 0); + std::fill(std::begin(m_4000shadow), std::end(m_4000shadow), 0); + std::fill(std::begin(m_screenshadow), std::end(m_screenshadow), 0); } void homelab2(machine_config &config); diff --git a/src/mame/konami/hexion.cpp b/src/mame/konami/hexion.cpp index 36d830a48fa..9f83e2b6c57 100644 --- a/src/mame/konami/hexion.cpp +++ b/src/mame/konami/hexion.cpp @@ -14,77 +14,77 @@ Notes: This is the 052591 PMC code loaded at startup, it contains a RAM/VRAM filling program. See https://github.com/furrtek/SiliconRE/tree/master/Konami/052591 for details -00: 5f 80 01 e0 08 Entry point, set OUT0 high -01: df 80 00 e0 0c r0 = 0 -02: df 90 02 e0 0c r1 = 2 -03: df a0 03 e0 0c r2 = 3 -04: df b0 0f e0 0c r3 = f -05: df c0 ff bf 0c ExtAddr = 1fff, r4 = ffff -06: 5c 02 00 33 0c -07: 5f 80 04 80 0c Write 2 to RAM (1fff) m_bankctrl, select pmcram +00: 5f 80 01 e0 08 Entry point, set OUT0 high +01: df 80 00 e0 0c r0 = 0 +02: df 90 02 e0 0c r1 = 2 +03: df a0 03 e0 0c r2 = 3 +04: df b0 0f e0 0c r3 = f +05: df c0 ff bf 0c ExtAddr = 1fff, r4 = ffff +06: 5c 02 00 33 0c +07: 5f 80 04 80 0c Write 2 to RAM (1fff) m_bankctrl, select pmcram 08: 5c 0e 00 2b 0c -09: df 70 00 cb 08 r7 = RAM(4) -0a: 5f 80 00 80 0c ExtAddr = 0 +09: df 70 00 cb 08 r7 = RAM(4) +0a: 5f 80 00 80 0c ExtAddr = 0 0b: 5c 04 00 2b 0c -0c: df 60 00 cb 08 r6 = RAM(0) (commands 0, 1 and 30 are used) -0d: 5c 0c 1f e9 0c JP 1F if r6 == 0 -0e: 4c 0c 2d e9 08 JP 2D if r6 == 1 +0c: df 60 00 cb 08 r6 = RAM(0) (commands 0, 1 and 30 are used) +0d: 5c 0c 1f e9 0c JP 1F if r6 == 0 +0e: 4c 0c 2d e9 08 JP 2D if r6 == 1 Command anything other than 00 or 01: Set bank to r7, then clear 16 bytes starting from r5.w -0f: 5f 80 03 80 0c ExtAddr = 3 +0f: 5f 80 03 80 0c ExtAddr = 3 10: 5c 04 00 2b 0c -11: 5f 00 00 cb 00 Read MSB from RAM[3] -12: 5f 80 02 a0 0c ExtAddr = 2 -13: df d0 00 c0 04 r5.w = RAM[3], RAM[2] -14: 01 3a 00 f3 0a acc = r5 + r3 = r5 + f +11: 5f 00 00 cb 00 Read MSB from RAM[3] +12: 5f 80 02 a0 0c ExtAddr = 2 +13: df d0 00 c0 04 r5.w = RAM[3], RAM[2] +14: 01 3a 00 f3 0a acc = r5 + r3 = r5 + f 15: 5c 08 00 b3 0c -16: 5c 0e 00 13 0c Write 3 to RAM[1fff] m_bankctrl +16: 5c 0e 00 13 0c Write 3 to RAM[1fff] m_bankctrl 17: 5f 80 00 a0 0c -18: 5c 00 00 13 0c Write r7 to RAM[0] +18: 5c 00 00 13 0c Write r7 to RAM[0] 19: 5c 08 00 b3 0c -1a: 5c 00 00 13 0c Write 0 to RAM[1fff] m_bankctrl, select vram +1a: 5c 00 00 13 0c Write 0 to RAM[1fff] m_bankctrl, select vram 1b: 84 5a 00 b3 0c -1c: 48 0a 5b d1 0c Write 0 to RAM[r5++] until r5 > acc (16 times) -1d: 5f 80 00 e0 08 Set OUT0 low -1e: 5f 00 1e fd 0c JP 1E, infinite loop +1c: 48 0a 5b d1 0c Write 0 to RAM[r5++] until r5 > acc (16 times) +1d: 5f 80 00 e0 08 Set OUT0 low +1e: 5f 00 1e fd 0c JP 1E, infinite loop Command is 00: Set bank to 0 and fill from 0 to 0x1fff with r2.b 1f: 5f 80 01 a0 0c -20: df 20 00 cb 08 r2 = RAM[1] +20: df 20 00 cb 08 r2 = RAM[1] 21: 5c 08 00 b3 0c -22: 5f 80 03 00 0c Write 3 to RAM[1fff] m_bankctrl +22: 5f 80 03 00 0c Write 3 to RAM[1fff] m_bankctrl 23: 5c 08 00 b3 0c -24: 5f 80 00 80 0c Write 3 to RAM[1fff] m_bankctrl +24: 5f 80 00 80 0c Write 3 to RAM[1fff] m_bankctrl 25: 5c 00 00 33 0c -26: 5c 08 00 93 0c Write 0 to RAM[0] -27: 9f 91 ff cf 0e Write 0 to RAM[1fff] m_bankctrl, select vram, r1 = fff << 1 = 1ffe +26: 5c 08 00 93 0c Write 0 to RAM[0] +27: 9f 91 ff cf 0e Write 0 to RAM[1fff] m_bankctrl, select vram, r1 = fff << 1 = 1ffe 28: 5c 84 00 20 0c -29: 84 00 00 b3 0c ExtAddr = r0 -2a: 49 10 69 d1 0c Write r2 to RAM[r0++] while r0 < r1 -2b: 5f 80 00 e0 08 Set OUT0 low -2c: 5f 00 2c fd 0c JP 2C, infinite loop +29: 84 00 00 b3 0c ExtAddr = r0 +2a: 49 10 69 d1 0c Write r2 to RAM[r0++] while r0 < r1 +2b: 5f 80 00 e0 08 Set OUT0 low +2c: 5f 00 2c fd 0c JP 2C, infinite loop Command is 01: Set banks to 1 and fill from 0 to 0x1fff with r2.b 2d: 5f 80 01 a0 0c -2e: df 20 00 cb 08 r2 = RAM(1) +2e: df 20 00 cb 08 r2 = RAM(1) 2f: 5c 08 00 b3 0c -30: 5f 80 03 00 0c Write 3 to RAM[1fff] m_bankctrl +30: 5f 80 03 00 0c Write 3 to RAM[1fff] m_bankctrl 31: 5c 00 00 b3 0c -32: 5f 80 01 00 0c Write 3 to RAM[0] +32: 5f 80 01 00 0c Write 3 to RAM[0] 33: 5c 08 00 b3 0c -34: 5f 80 00 80 0c Write 1 to RAM[1fff] m_bankctrl +34: 5f 80 00 80 0c Write 1 to RAM[1fff] m_bankctrl 35: 5c 00 00 33 0c -36: 5c 08 00 93 0c Write 0 to RAM[0] -37: 9f 91 ff cf 0e Write 0 to RAM[1fff] m_bankctrl, select vram, r1 = fff << 1 = 1ffe +36: 5c 08 00 93 0c Write 0 to RAM[0] +37: 9f 91 ff cf 0e Write 0 to RAM[1fff] m_bankctrl, select vram, r1 = fff << 1 = 1ffe 38: 5c 84 00 20 0c 39: 84 00 00 b3 0c -3a: 49 10 79 d1 0c Write r2 to RAM[r0++] while r0 < r1 -3b: 5f 80 00 e0 08 Set OUT0 low -3c: 5f 00 3c fd 0c JP 3C, infinite loop +3a: 49 10 79 d1 0c Write r2 to RAM[r0++] while r0 < r1 +3b: 5f 80 00 e0 08 Set OUT0 low +3c: 5f 00 3c fd 0c JP 3C, infinite loop -3d: ff ff ff ff ff Garbage -3e: ff ff ff ff ff Garbage -3f: ff ff ff ff ff Garbage +3d: ff ff ff ff ff Garbage +3e: ff ff ff ff ff Garbage +3f: ff ff ff ff ff Garbage ***************************************************************************/ @@ -102,6 +102,7 @@ Command is 01: Set banks to 1 and fill from 0 to 0x1fff with r2.b #include "emupal.h" #include "speaker.h" #include "tilemap.h" + #include "multibyte.h" @@ -131,7 +132,7 @@ public: m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), m_vram(*this, "vram%u", 0U, 0x2000U, ENDIANNESS_LITTLE), - m_pmcram(*this, "pmcram", 0x800, ENDIANNESS_LITTLE), // Might be an unused area of VRAM + m_pmcram(*this, "pmcram", 0x800, ENDIANNESS_LITTLE), // Might be an unused area of VRAM m_rombank(*this, "rombank"), m_tilesrom(*this, "tiles") { } @@ -243,9 +244,9 @@ void hexion_state::bankswitch_w(uint8_t data) m_rombank->set_entry(data & 0x0f); // bit 6 triggers the 052591 - if (data & 0x40) + if (BIT(data, 6)) { - uint8_t command = m_pmcram[0]; + const uint8_t command = m_pmcram[0]; if (command <= 1) { memset(m_vram[command], m_pmcram[1], 0x2000); @@ -253,13 +254,17 @@ void hexion_state::bankswitch_w(uint8_t data) } else { - uint8_t bank = m_pmcram[4] & 1; - memset(m_vram[bank] + (get_u16le(&m_pmcram[2]) & 0x1fff), 0, 16); - m_bg_tilemap[bank]->mark_all_dirty(); + const uint8_t bank = m_pmcram[4] & 1; + const uint16_t offset = get_u16le(&m_pmcram[2]); + for (int i = 0; 16 > i; ++i) + m_vram[bank][(offset + i) & 0x1fff] = 0; + for (int i = 0; 4 > i; ++i) + m_bg_tilemap[bank]->mark_tile_dirty(((offset >> 2) + i) & 0x07ff); } } + // bit 7 = PMC-BK - m_pmcbank = (data & 0x80) >> 7; + m_pmcbank = BIT(data, 7); // other bits unknown if (data & 0x30) @@ -300,7 +305,7 @@ void hexion_state::bankedram_w(offs_t offset, uint8_t data) { LOGBANKEDRAM("%s: bankedram_w offset %04x, data %02x, bankctrl = %02x\n", m_maincpu->pc(), offset, data, m_bankctrl); m_vram[m_rambank][offset] = data; - m_bg_tilemap[m_rambank]->mark_tile_dirty(offset/4); + m_bg_tilemap[m_rambank]->mark_tile_dirty(offset >> 2); } else LOGBANKEDRAM("%04x pmc internal ram %04x = %02x\n", m_maincpu->pc(), offset, data); diff --git a/src/mame/konami/spy.cpp b/src/mame/konami/spy.cpp index adbff571245..884f31a2496 100644 --- a/src/mame/konami/spy.cpp +++ b/src/mame/konami/spy.cpp @@ -13,7 +13,7 @@ 31-01-2024 Furrtek - updated PMCU collision check code to match what the original program does - + 05-10-2002 Acho A. Tang - simulated PMCU protection(guess only) - changed priority scheme to fix graphics in 3D levels @@ -35,10 +35,13 @@ #include "machine/watchdog.h" #include "sound/k007232.h" #include "sound/ymopl.h" + #include "emupal.h" #include "speaker.h" + #include "multibyte.h" + namespace { class spy_state : public driver_device @@ -46,6 +49,7 @@ class spy_state : public driver_device public: spy_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_rombank(*this, "rombank"), m_ram(*this, "ram"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), @@ -60,6 +64,7 @@ public: private: /* memory pointers */ + required_memory_bank m_rombank; required_shared_ptr m_ram; uint8_t m_pmcram[0x800]{}; std::vector m_paletteram{}; @@ -68,7 +73,7 @@ private: int m_rambank = 0; int m_pmcbank = 0; uint8_t m_pmcpc = 0; - int m_video_enable = 0; + bool m_video_enable = false; int m_old_3f90 = 0; /* devices */ @@ -79,6 +84,7 @@ private: required_device m_k052109; required_device m_k051960; required_device m_palette; + uint8_t spy_bankedram1_r(offs_t offset); void spy_bankedram1_w(offs_t offset, uint8_t data); void bankswitch_w(uint8_t data); @@ -90,7 +96,7 @@ private: virtual void machine_start() override; virtual void machine_reset() override; uint32_t screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void pmc_run( ); + void pmc_run(); void volume_callback0(uint8_t data); void volume_callback1(uint8_t data); K052109_CB_MEMBER(tile_callback); @@ -177,7 +183,7 @@ uint8_t spy_state::spy_bankedram1_r(offs_t offset) } else { - return 0; // PMC internal RAM can't be read back + return 0; // PMC internal RAM can't be read back } } else @@ -212,106 +218,104 @@ This is the 052591 PMC code loaded at startup, it contains both projection and c See https://github.com/furrtek/SiliconRE/tree/master/Konami/052591 for details Coordinate projection routine: -00: e7 7e 38 fc 08 Clear r7 -01: df 36 38 dc 00 r3.w = RAM[0] -02: df 12 3a dc 00 r1.w = RAM[2] -03: df 00 38 dc 08 r0 = RAM[4] +00: e7 7e 38 fc 08 Clear r7 +01: df 36 38 dc 00 r3.w = RAM[0] +02: df 12 3a dc 00 r1.w = RAM[2] +03: df 00 38 dc 08 r0 = RAM[4] 04: 1f 7e 00 db 00 -05: 26 fe 00 ff 0c Acc.w = RAM[5],00 -06: 89 03 34 fc 0d 1+16 division steps, CALL 34... -07: 81 03 34 fc 09 add/sub, CALL 34 -08: 81 03 34 fc 09 add/sub, CALL 34 -09: 81 03 34 fc 09 add/sub, CALL 34 -0a: 81 03 2f fc 09 add/sub, CALL 34 +05: 26 fe 00 ff 0c Acc.w = RAM[5],00 +06: 89 03 34 fc 0d 1+16 division steps, CALL 34... +07: 81 03 34 fc 09 add/sub, CALL 34 +08: 81 03 34 fc 09 add/sub, CALL 34 +09: 81 03 34 fc 09 add/sub, CALL 34 +0a: 81 03 2f fc 09 add/sub, CALL 34 0b: cc 36 0e d9 08 r3--, JP 0e if 0 0c: 84 7e 00 ab 0c -0d: 5f 7e 03 cd 08 JP 03 +0d: 5f 7e 03 cd 08 JP 03 -0e: 7f 80 fe ef 08 Set OUT0 low -0f: 5f 7e 0f fd 08 JP 0f, infinite loop +0e: 7f 80 fe ef 08 Set OUT0 low +0f: 5f 7e 0f fd 08 JP 0f, infinite loop Collision check routine: -10: e7 7e 38 fc 08 r0.w = RAM[0] +10: e7 7e 38 fc 08 r0.w = RAM[0] 11: df 00 3a dc 00 -12: df 12 0e d9 08 r1 = RAM[2], JP 0e if 0 -13: df ec 10 e0 0c r6 = 10 -14: 1f fe 03 e0 0c Acc = 3 -15: df fe 03 e0 0c r7 = 3 -16: dc 5e 3e fc 08 r5 = 3 -17: df 12 2b d9 08 r1 = RAM[r6++], JP 2b if 0 -18: 67 25 38 fc 0c r2 = 8000 ? +12: df 12 0e d9 08 r1 = RAM[2], JP 0e if 0 +13: df ec 10 e0 0c r6 = 10 +14: 1f fe 03 e0 0c Acc = 3 +15: df fe 03 e0 0c r7 = 3 +16: dc 5e 3e fc 08 r5 = 3 +17: df 12 2b d9 08 r1 = RAM[r6++], JP 2b if 0 +18: 67 25 38 fc 0c r2 = 8000 ? 19: df 12 3c dc 00 1a: df 36 00 db 00 -1b: c1 14 00 fb 08 r1 += r2 -1c: c1 34 38 fc 08 r3 += r2 +1b: c1 14 00 fb 08 r1 += r2 +1c: c1 34 38 fc 08 r3 += r2 1d: c5 22 37 dc 00 1e: cd 12 3c dc 04 1f: c5 46 3b dc 00 20: cd 36 00 db 04 -21: 49 16 ed f9 0c JP 2d if r1 < r3 -22: c9 18 ea f9 0c JP 2a if r1 < r4 +21: 49 16 ed f9 0c JP 2d if r1 < r3 +22: c9 18 ea f9 0c JP 2a if r1 < r4 23: dc 12 2a f9 08 -24: cc 5a 26 f9 08 r5--, JP 26 if 0 -25: 5f 7e 18 fd 08 JP 18 -26: 5a 7e 32 f8 08 Clear RAM(r7++) if Acc is 0 -27: 84 6c 33 9c 0c RAM(r6++) = Acc -28: cc 00 0e d9 08 r0--, JP 0e if 0 +24: cc 5a 26 f9 08 r5--, JP 26 if 0 +25: 5f 7e 18 fd 08 JP 18 +26: 5a 7e 32 f8 08 Clear RAM(r7++) if Acc is 0 +27: 84 6c 33 9c 0c RAM(r6++) = Acc +28: cc 00 0e d9 08 r0--, JP 0e if 0 29: 5f 7e 14 fd 08 2a: 0a 7e 24 fd 08 -2b: c5 ec 0d e0 0c r6 += d, next object +2b: c5 ec 0d e0 0c r6 += d, next object 2c: 5f 7e 28 fd 08 -2d: dc 16 00 fb 08 r1 = r3 -2e: dc 44 22 fd 08 r4 = r2 -2f: cd fe 02 e0 0c r7 -= 3 +2d: dc 16 00 fb 08 r1 = r3 +2e: dc 44 22 fd 08 r4 = r2 +2f: cd fe 02 e0 0c r7 -= 3 30: 84 7e 00 bb 0c 31: 5a 7e 00 73 08 32: 84 7e 00 9b 0c 33: 5a 7e 00 36 08 -34: 81 03 00 fb 09 add/sub -35: 81 03 00 fb 09 add/sub -36: 81 03 00 fe 09 add/sub, ret +34: 81 03 00 fb 09 add/sub +35: 81 03 00 fb 09 add/sub +36: 81 03 00 fe 09 add/sub, ret -37: cd fe 01 e0 0c r7 -= 2 +37: cd fe 01 e0 0c r7 -= 2 38: 84 7e 00 ab 0c -39: 5f 7e 00 db 00 Set MSB as RAM(r7) +39: 5f 7e 00 db 00 Set MSB as RAM(r7) 3a: 84 7e 3f ad 0c -3b: cd ec 01 e0 0c r6 -= 2 +3b: cd ec 01 e0 0c r6 -= 2 3c: 84 6c 00 ab 0c -3d: 5f 7e 00 db 00 Set MSB as RAM(r6) +3d: 5f 7e 00 db 00 Set MSB as RAM(r6) 3e: 84 6c 00 ab 0c -3f: 5f 7e 00 ce 08 ret +3f: 5f 7e 00 ce 08 ret */ void spy_state::bankswitch_w(uint8_t data) { - int bank; - /* bit 0 = RAM bank */ if ((data & 1) == 0) popmessage("bankswitch RAM bank 0"); /* bit 1-4 = ROM bank */ + int bank; if (data & 0x10) bank = 8 + ((data & 0x06) >> 1); else - bank = ((data & 0x0e) >> 1); + bank = (data & 0x0e) >> 1; - membank("bank1")->set_entry(bank); + m_rombank->set_entry(bank); } -void spy_state::pmc_run( ) +void spy_state::pmc_run() { constexpr uint16_t MAX_SPRITES = 64; constexpr uint16_t DEF_NEAR_PLANE = 0x6400; - + if (m_pmcpc == 0x00) { // Projection program // Basically divides a list of 16-bit words by a constant, results are 8.8 fixed point uint16_t loopend, nearplane; - uint32_t op; - + loopend = get_u16be(&m_pmcram[0]); nearplane = get_u16be(&m_pmcram[2]); @@ -325,7 +329,7 @@ void spy_state::pmc_run( ) for (uint16_t i = 4; i < loopend; i += 2) { - op = get_u16be(&m_pmcram[i]); + uint32_t op = get_u16be(&m_pmcram[i]); op = (op << 8) / nearplane; put_u16be(&m_pmcram[i], op); } @@ -335,32 +339,32 @@ void spy_state::pmc_run( ) else { // Collision check program - + if (!m_pmcram[0x2]) return; - + const uint16_t count = get_u16be(&m_pmcram[0]); - + for (uint16_t i = 16; i < 16 + (14 * count); i += 14) { if (!m_pmcram[i]) continue; - + // Check all 3 dimensions uint8_t tests_failed = 3; for (uint16_t j = 0; j < 3 * 4; j += 4) { - const int16_t a_pos = get_s16be(&m_pmcram[j + 3]); // Object A center position - const int16_t a_size = get_s16be(&m_pmcram[j + 5]); // Object A half size - - const int16_t b_pos = get_s16be(&m_pmcram[i + j + 1]); // Object B center position - const int16_t b_size = get_s16be(&m_pmcram[i + j + 3]); // Object B half size - - const int16_t a_max = a_pos + a_size; // Object A right edge - const int16_t a_min = a_pos - a_size; // Object A left edge - const int16_t b_max = b_pos + b_size; // Object B right edge - const int16_t b_min = b_pos - b_size; // Object B left edge - + const int16_t a_pos = get_s16be(&m_pmcram[j + 3]); // Object A center position + const int16_t a_size = get_s16be(&m_pmcram[j + 5]); // Object A half size + + const int16_t b_pos = get_s16be(&m_pmcram[i + j + 1]); // Object B center position + const int16_t b_size = get_s16be(&m_pmcram[i + j + 3]); // Object B half size + + const int16_t a_max = a_pos + a_size; // Object A right edge + const int16_t a_min = a_pos - a_size; // Object A left edge + const int16_t b_max = b_pos + b_size; // Object B right edge + const int16_t b_min = b_pos - b_size; // Object B left edge + if (b_min > a_min) { // Object B left edge is > object A left edge @@ -376,9 +380,10 @@ void spy_state::pmc_run( ) tests_failed--; } } - + // Mark objects as collided or not - if (!tests_failed) m_pmcram[0xf] = 0; + if (!tests_failed) + m_pmcram[0xf] = 0; m_pmcram[i + 0xd] = tests_failed; } } @@ -433,7 +438,7 @@ void spy_state::spy_3f90_w(uint8_t data) m_k052109->set_rmrd_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE); /* bit 3 = disable video */ - m_video_enable = ~(data & 0x08); + m_video_enable = !(data & 0x08); /* bit 4 = read RAM at 0000 (if set) else read color palette RAM */ /* bit 5 = PMCBK */ @@ -459,15 +464,8 @@ void spy_state::spy_sh_irqtrigger_w(uint8_t data) void spy_state::sound_bank_w(uint8_t data) { - int bank_A, bank_B; - - bank_A = (data >> 0) & 0x03; - bank_B = (data >> 2) & 0x03; - m_k007232_1->set_bank(bank_A, bank_B); - - bank_A = (data >> 4) & 0x03; - bank_B = (data >> 6) & 0x03; - m_k007232_2->set_bank(bank_A, bank_B); + m_k007232_1->set_bank(BIT(data, 0, 2), BIT(data, 2, 2)); + m_k007232_2->set_bank(BIT(data, 4, 2), BIT(data, 6, 2)); } @@ -511,7 +509,7 @@ void spy_state::spy_map(address_map &map) map(0x3fd2, 0x3fd2).portr("P2"); map(0x3fd3, 0x3fd3).portr("DSW1"); map(0x3fe0, 0x3fe0).portr("DSW2"); - map(0x6000, 0x7fff).bankr("bank1"); + map(0x6000, 0x7fff).bankr(m_rombank); map(0x8000, 0xffff).rom(); } @@ -591,9 +589,9 @@ void spy_state::volume_callback1(uint8_t data) void spy_state::machine_start() { - uint8_t *ROM = memregion("maincpu")->base(); + uint8_t *const ROM = memregion("maincpu")->base(); - membank("bank1")->configure_entries(0, 12, &ROM[0x10000], 0x2000); + m_rombank->configure_entries(0, 12, &ROM[0x10000], 0x2000); m_paletteram.resize(0x800); m_palette->basemem().set(m_paletteram, ENDIANNESS_BIG, 2); @@ -614,7 +612,7 @@ void spy_state::machine_reset() m_rambank = 0; m_pmcbank = 0; m_pmcpc = 0; - m_video_enable = 0; + m_video_enable = false; m_old_3f90 = -1; } diff --git a/src/mame/rm/rm380z.h b/src/mame/rm/rm380z.h index 7de86cd7667..ae5c4bd5991 100644 --- a/src/mame/rm/rm380z.h +++ b/src/mame/rm/rm380z.h @@ -14,32 +14,16 @@ Research Machines RM 380Z #include "cpu/z80/z80.h" #include "imagedev/cassette.h" -#include "machine/ram.h" #include "imagedev/floppy.h" -#include "machine/wd_fdc.h" #include "machine/keyboard.h" +#include "machine/ram.h" +#include "machine/wd_fdc.h" // // // #define RM380Z_MAINCPU_TAG "maincpu" -#define RM380Z_PORTS_ENABLED_HIGH ( m_port0 & 0x80 ) -#define RM380Z_PORTS_ENABLED_LOW ( ( m_port0 & 0x80 ) == 0x00 ) - -#define RM380Z_VIDEOMODE_40COL 0x01 -#define RM380Z_VIDEOMODE_80COL 0x02 - -#define RM380Z_CHDIMX 5 -#define RM380Z_CHDIMY 9 -#define RM380Z_NCX 8 -#define RM380Z_NCY 16 -#define RM380Z_SCREENCOLS 80 -#define RM380Z_SCREENROWS 24 - -#define RM380Z_VIDEORAM_SIZE 0x600 -#define RM380Z_SCREENSIZE 0x1200 - // // @@ -51,6 +35,7 @@ class rm380z_state : public driver_device public: rm380z_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_chargen(*this, "chargen"), m_maincpu(*this, RM380Z_MAINCPU_TAG), m_cassette(*this, "cassette"), m_messram(*this, RAM_TAG), @@ -73,47 +58,31 @@ protected: virtual void machine_start() override; private: - bool get_rowcol_from_offset(int& row, int& col, offs_t offset) const; - void put_point(int charnum,int x,int y,int col); - void init_graphic_chars(); - - void putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bitmap,unsigned char* chsb,int vmode); - void decode_videoram_char(int row, int col, uint8_t& chr, uint8_t& attrib); - void scroll_videoram(); - void config_videomode(); - void check_scroll_register(); - - int writenum = 0; - - uint8_t m_port0 = 0; - uint8_t m_port0_mask = 0; - uint8_t m_port0_kbd = 0; - uint8_t m_port1 = 0; - uint8_t m_fbfd = 0; - uint8_t m_fbfe = 0; - - uint8_t m_graphic_chars[0x80][(RM380Z_CHDIMX+1)*(RM380Z_CHDIMY+1)]; - - uint8_t m_vramchars[RM380Z_SCREENROWS][RM380Z_SCREENCOLS]; - uint8_t m_vramattribs[RM380Z_SCREENROWS][RM380Z_SCREENCOLS]; + static inline constexpr int RM380Z_VIDEOMODE_40COL = 0x01; + static inline constexpr int RM380Z_VIDEOMODE_80COL = 0x02; - int m_rasterlineCtr = 0; - emu_timer* m_vblankTimer = nullptr; + static inline constexpr int RM380Z_CHDIMX = 5; + static inline constexpr int RM380Z_CHDIMY = 9; + static inline constexpr int RM380Z_NCX = 8; + static inline constexpr int RM380Z_NCY = 16; + static inline constexpr int RM380Z_SCREENCOLS = 80; + static inline constexpr int RM380Z_SCREENROWS = 24; - int m_old_fbfd = 0; - int m_old_old_fbfd = 0; + static inline constexpr int RM380Z_VIDEORAM_SIZE = 0x600; + static inline constexpr int RM380Z_SCREENSIZE = 0x1200; - int m_videomode = 0; - int m_old_videomode = 0; + bool ports_enabled_high() const { return ( m_port0 & 0x80 ); } + bool ports_enabled_low() const { return !( m_port0 & 0x80 ); } - emu_timer *m_static_vblank_timer = nullptr; + bool get_rowcol_from_offset(int &row, int &col, offs_t offset) const; + void put_point(int charnum, int x, int y, int col); + void init_graphic_chars(); - required_device m_maincpu; - optional_device m_cassette; - optional_device m_messram; - optional_device m_fdc; - optional_device m_floppy0; - optional_device m_floppy1; + void putChar(int charnum, int attribs, int x, int y, bitmap_ind16 &bitmap, int vmode); + void decode_videoram_char(int row, int col, uint8_t &chr, uint8_t &attrib); + void scroll_videoram(); + void config_videomode(); + void check_scroll_register(); void port_write(offs_t offset, uint8_t data); uint8_t port_read(offs_t offset); @@ -144,6 +113,39 @@ private: void rm380z_mem(address_map &map); void rm480z_io(address_map &map); void rm480z_mem(address_map &map); + + int writenum = 0; + + uint8_t m_port0 = 0; + uint8_t m_port0_mask = 0; + uint8_t m_port0_kbd = 0; + uint8_t m_port1 = 0; + uint8_t m_fbfd = 0; + uint8_t m_fbfe = 0; + + uint8_t m_graphic_chars[0x80][(RM380Z_CHDIMX+1)*(RM380Z_CHDIMY+1)]; + + uint8_t m_vramchars[RM380Z_SCREENROWS][RM380Z_SCREENCOLS]; + uint8_t m_vramattribs[RM380Z_SCREENROWS][RM380Z_SCREENCOLS]; + + int m_rasterlineCtr = 0; + emu_timer* m_vblankTimer = nullptr; + + uint8_t m_old_fbfd = 0; + uint8_t m_old_old_fbfd = 0; + + int m_videomode = 0; + int m_old_videomode = 0; + + emu_timer *m_static_vblank_timer = nullptr; + + required_region_ptr m_chargen; + required_device m_maincpu; + optional_device m_cassette; + optional_device m_messram; + optional_device m_fdc; + optional_device m_floppy0; + optional_device m_floppy1; }; #endif // MAME_RM_RM380Z_H diff --git a/src/mame/rm/rm380z_m.cpp b/src/mame/rm/rm380z_m.cpp index 7d98d717969..a079a417fda 100644 --- a/src/mame/rm/rm380z_m.cpp +++ b/src/mame/rm/rm380z_m.cpp @@ -31,29 +31,29 @@ void rm380z_state::port_write(offs_t offset, uint8_t data) { switch ( offset ) { - case 0xFC: // PORT0 + case 0xfc: // PORT0 //printf("%s FBFCw[%2.2x] FBFD [%2.2x] FBFE [%2.2x] writenum [%4.4x]\n",machine().describe_context().c_str(),data,m_fbfd,m_fbfe,writenum); m_port0 = data; m_cassette->output((m_port0 & 0xEF) ? +1.0 : -1.0); // set 2400hz, bit 4 - if (data&0x01) + if (data & 0x01) { //printf("WARNING: bit0 of port0 reset\n"); - m_port0_kbd=0; + m_port0_kbd = 0; } - m_port1&=~0x01; //? + m_port1 &= ~0x01; //? config_videomode(); config_memory_map(); break; - case 0xFD: // screen line counter (?) + case 0xfd: // screen line counter (?) //printf("%s FBFC [%2.2x] FBFDw[%2.2x] FBFE [%2.2x] writenum [%4.4x]\n",machine().describe_context().c_str(),m_port0,data,m_fbfe,writenum); - m_old_old_fbfd=m_old_fbfd; - m_old_fbfd=m_fbfd; - m_fbfd=data; + m_old_old_fbfd = m_old_fbfd; + m_old_fbfd = m_fbfd; + m_fbfd = data; writenum++; @@ -62,57 +62,57 @@ void rm380z_state::port_write(offs_t offset, uint8_t data) break; // port 1 - case 0xFE: // line on screen to write to divided by 2 + case 0xfe: // line on screen to write to divided by 2 //printf("%s FBFC [%2.2x] FBFD [%2.2x] FBFEw[%2.2x] writenum [%4.4x]\n",machine().describe_context().c_str(),m_port0,m_fbfd,data,writenum); - m_fbfe=data; + m_fbfe = data; break; - case 0xFF: // user I/O port + case 0xff: // user I/O port //printf("write of [%x] to FBFF\n",data); //logerror("%s: Write %02X to user I/O port\n", machine().describe_context(), data ); break; default: - printf("unknown port [%2.2x] write of [%2.2x]\n",offset,data); + printf("unknown port [%2.2x] write of [%2.2x]\n", offset, data); } } uint8_t rm380z_state::port_read(offs_t offset) { - uint8_t data = 0xFF; + uint8_t data = 0xff; switch ( offset ) { - case 0xFC: // PORT0 + case 0xfc: // PORT0 //m_port0_kbd=getKeyboard(); data = m_port0_kbd; - //if (m_port0_kbd!=0) m_port0_kbd=0; + //if (m_port0_kbd!=0) m_port0_kbd = 0; //m_port0_kbd=0; //printf("%s read of port0 (kbd)\n",machine().describe_context().c_str()); break; - case 0xFD: // "counter" (?) + case 0xfd: // "counter" (?) //printf("%s: Read from counter FBFD\n", machine().describe_context().c_str()); data = 0x00; break; - case 0xFE: // PORT1 - if ((m_cassette)->input() < +0.0) + case 0xfe: // PORT1 + if (m_cassette->input() < +0.0) m_port1 &= 0xDF; // bit 5 off else m_port1 |= 0x20; // bit 5 on data = m_port1; - //printf("%s read of port1\n",machine().describe_context().c_str()); + //printf("%s read of port1\n", machine().describe_context().c_str()); break; - case 0xFF: // user port + case 0xff: // user port //printf("%s: Read from user port\n", machine().describe_context().c_str()); break; default: - printf("read from unknown port [%2.2x]\n",offset); + printf("read from unknown port [%2.2x]\n", offset); } return data; @@ -120,12 +120,12 @@ uint8_t rm380z_state::port_read(offs_t offset) void rm380z_state::port_write_1b00(offs_t offset, uint8_t data) { - port_write(offset+0xfc,data); + port_write(offset + 0xfc, data); } uint8_t rm380z_state::port_read_1b00(offs_t offset) { - return port_read(offset+0xfc); + return port_read(offset + 0xfc); } uint8_t rm380z_state::rm380z_portlow_r() @@ -165,26 +165,26 @@ TIMER_CALLBACK_MEMBER(rm380z_state::static_vblank_timer) m_rasterlineCtr++; - m_rasterlineCtr%=(HORZ_LINES*LINE_SUBDIVISION); + m_rasterlineCtr %= HORZ_LINES * LINE_SUBDIVISION; // frame blanking - if (m_rasterlineCtr>=((HORZ_LINES-22)*LINE_SUBDIVISION)) + if (m_rasterlineCtr >= ((HORZ_LINES - 22) * LINE_SUBDIVISION)) { - m_port1|=0x40; + m_port1 |= 0x40; } else { - m_port1&=~0x40; + m_port1 &= ~0x40; } // line blanking - if ((m_rasterlineCtr%LINE_SUBDIVISION)>80) + if ((m_rasterlineCtr % LINE_SUBDIVISION) > 80) { - m_port1|=0x80; + m_port1 |= 0x80; } else { - m_port1&=~0x80; + m_port1 &= ~0x80; } } @@ -232,40 +232,40 @@ void rm380z_state::machine_start() void rm380z_state::init_rm380z() { - m_videomode=RM380Z_VIDEOMODE_80COL; - m_old_videomode=m_videomode; - m_port0_mask=0xff; + m_videomode = RM380Z_VIDEOMODE_80COL; + m_old_videomode = m_videomode; + m_port0_mask = 0xff; } void rm380z_state::init_rm380z34d() { - m_videomode=RM380Z_VIDEOMODE_40COL; - m_old_videomode=m_videomode; - m_port0_mask=0xdf; // disable 80 column mode + m_videomode = RM380Z_VIDEOMODE_40COL; + m_old_videomode = m_videomode; + m_port0_mask = 0xdf; // disable 80 column mode } void rm380z_state::init_rm380z34e() { - m_videomode=RM380Z_VIDEOMODE_40COL; - m_old_videomode=m_videomode; - m_port0_mask=0xdf; // disable 80 column mode + m_videomode = RM380Z_VIDEOMODE_40COL; + m_old_videomode = m_videomode; + m_port0_mask = 0xdf; // disable 80 column mode } void rm380z_state::machine_reset() { - m_port0=0x00; - m_port0_kbd=0x00; - m_port1=0x00; - m_fbfd=0x00; - m_fbfe=0x00; - m_old_fbfd=0x00; - m_old_old_fbfd=0x00; - writenum=0; + m_port0 = 0x00; + m_port0_kbd = 0x00; + m_port1 = 0x00; + m_fbfd = 0x00; + m_fbfe = 0x00; + m_old_fbfd = 0x00; + m_old_old_fbfd = 0x00; + writenum = 0; // m_videomode=RM380Z_VIDEOMODE_80COL; -// m_old_videomode=m_videomode; - m_rasterlineCtr=0; +// m_old_videomode = m_videomode; + m_rasterlineCtr = 0; // note: from COS 4.0 videos, screen seems to show garbage at the beginning memset(m_vramattribs, 0, sizeof(m_vramattribs)); @@ -283,7 +283,7 @@ void rm380z_state::config_memory_map() uint8_t *rom = memregion(RM380Z_MAINCPU_TAG)->base(); uint8_t* m_ram_p = m_messram->pointer(); - if ( RM380Z_PORTS_ENABLED_HIGH ) + if ( ports_enabled_high() ) { program.install_ram( 0x0000, 0xDFFF, m_ram_p ); } diff --git a/src/mame/rm/rm380z_v.cpp b/src/mame/rm/rm380z_v.cpp index 297274a0e2d..2eae61448dd 100644 --- a/src/mame/rm/rm380z_v.cpp +++ b/src/mame/rm/rm380z_v.cpp @@ -27,16 +27,15 @@ bool rm380z_state::get_rowcol_from_offset(int& row, int& col, offs_t offset) con return ((row < RM380Z_SCREENROWS) && (col < RM380Z_SCREENCOLS)); } -void rm380z_state::put_point(int charnum,int x,int y,int col) +void rm380z_state::put_point(int charnum, int x, int y, int col) { - int mx=3; - if (y==6) mx=4; + const int mx = (y == 6) ? 4 : 3; - for (unsigned int r=y;r<(y+mx);r++) + for (unsigned int r = y; r< (y + mx); r++) { - for (unsigned int c=x;c<(x+3);c++) + for (unsigned int c = x; c < (x + 3); c++) { - m_graphic_chars[charnum][c+(r*(RM380Z_CHDIMX+1))]=col; + m_graphic_chars[charnum][c + (r * (RM380Z_CHDIMX + 1))] = col; } } } @@ -67,20 +66,20 @@ void rm380z_state::init_graphic_chars() void rm380z_state::config_videomode() { - if (m_port0&0x20&m_port0_mask) + if (m_port0 & 0x20 & m_port0_mask) { // 80 cols - m_videomode=RM380Z_VIDEOMODE_80COL; + m_videomode = RM380Z_VIDEOMODE_80COL; } else { // 40 cols - m_videomode=RM380Z_VIDEOMODE_40COL; + m_videomode = RM380Z_VIDEOMODE_40COL; } - if (m_old_videomode!=m_videomode) + if (m_old_videomode != m_videomode) { - m_old_videomode=m_videomode; + m_old_videomode = m_videomode; } } @@ -92,53 +91,53 @@ void rm380z_state::config_videomode() // 3=reverse -void rm380z_state::decode_videoram_char(int row, int col, uint8_t& chr, uint8_t& attrib) +void rm380z_state::decode_videoram_char(int row, int col, uint8_t& chr, uint8_t &attrib) { - uint8_t ch1=m_vramchars[row][col]; - uint8_t ch2=m_vramattribs[row][col]; + uint8_t ch1 = m_vramchars[row][col]; + uint8_t ch2 = m_vramattribs[row][col]; // "special" (unknown) cases first - if ((ch1==0x80)&&(ch2==0x04)) + if ((ch1 == 0x80) && (ch2 == 0x04)) { // blank out - chr=0x20; - attrib=0; + chr = 0x20; + attrib = 0; return; } - else if ((ch1==0)&&(ch2==8)) + else if ((ch1 == 0) && (ch2 == 8)) { // cursor - chr=0x20; - attrib=8; + chr = 0x20; + attrib = 8; return; } - else if ((ch1==0)&&(ch2==0)) + else if ((ch1 == 0) && (ch2 == 0)) { // delete char (?) - chr=0x20; - attrib=0; + chr = 0x20; + attrib = 0; return; } - else if ((ch1==4)&&(ch2==4)) + else if ((ch1 == 4) && (ch2 == 4)) { // reversed cursor? - chr=0x20; - attrib=0; + chr = 0x20; + attrib = 0; return; } - else if ((ch1==4)&&(ch2==8)) + else if ((ch1 == 4) && (ch2 == 8)) { // normal cursor - chr=0x20; - attrib=8; + chr = 0x20; + attrib = 8; return; } else { - chr=ch1; - attrib=ch2; + chr = ch1; + attrib = ch2; - //printf("unhandled character combination [%x][%x]\n",ch1,ch2); + //printf("unhandled character combination [%x][%x]\n", ch1, ch2); } } @@ -155,26 +154,21 @@ void rm380z_state::scroll_videoram() void rm380z_state::check_scroll_register() { - uint8_t r[3]; + const uint8_t r[3] = { m_old_old_fbfd, m_old_fbfd, m_fbfd }; - r[0]=m_old_old_fbfd; - r[1]=m_old_fbfd; - r[2]=m_fbfd; - - if ( ((r[1]&0x20)==0) && ((r[2]&0x20)==0) ) + if (!(r[1] & 0x20) && !(r[2] & 0x20)) { // it's a scroll command - if (r[2]>r[1]) + if (r[2] > r[1]) { scroll_videoram(); } - else if ((r[2]==0x00)&&(r[1]==0x17)) + else if (!r[2] && (r[1] == 0x17)) { // wrap-scroll scroll_videoram(); } - } } @@ -223,17 +217,13 @@ uint8_t rm380z_state::videoram_read(offs_t offset) return 0; // return 0 if out of bounds (see VTIN description in firmware guide) } -void rm380z_state::putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bitmap,unsigned char* chsb,int vmode) +void rm380z_state::putChar(int charnum, int attribs, int x, int y, bitmap_ind16 &bitmap, int vmode) { - //bool attrDim=false; - bool attrRev=false; - bool attrUnder=false; + const bool attrUnder = attribs & 0x02; + //const bool attrDim = attribs & 0x04; + const bool attrRev = attribs & 0x08; - if (attribs&0x02) attrUnder=true; - //if (attribs&0x04) attrDim=true; - if (attribs&0x08) attrRev=true; - - if ((charnum>0)&&(charnum<=0x7f)) + if ((charnum > 0) && (charnum <= 0x7f)) { // normal chars (base set) @@ -246,7 +236,7 @@ void rm380z_state::putChar(int charnum,int attribs,int x,int y,bitmap_ind16 &bit { for (int c=0;cbase(); - - int ncols=80; - - if (m_videomode==RM380Z_VIDEOMODE_40COL) - { - ncols=40; - } + const int ncols = (m_videomode == RM380Z_VIDEOMODE_40COL) ? 40 : 80; // blank screen bitmap.fill(0); - for (int row=0;rowbase(); - uint16_t sy=0,ma=0; + uint16_t sy = 0, ma = 0; for (uint8_t y = 0; y < RM380Z_SCREENROWS; y++) { @@ -401,8 +383,8 @@ uint32_t rm380z_state::screen_update_rm480z(screen_device &screen, bitmap_ind16 uint8_t gfx = 0; if (ra < 10) { - uint8_t chr = m_vramchars[y][x]; - gfx = chargen[(chr<<4) | ra ]; + const uint8_t chr = m_vramchars[y][x]; + gfx = m_chargen[(chr << 4) | ra ]; } /* Display a scanline of a character */ *p++ = BIT(gfx, 7); @@ -415,7 +397,7 @@ uint32_t rm380z_state::screen_update_rm480z(screen_device &screen, bitmap_ind16 *p++ = BIT(gfx, 0); } } - ma+=64; + ma += 64; } return 0; } diff --git a/src/mame/tvgames/xavix.cpp b/src/mame/tvgames/xavix.cpp index ee48aa9fb9e..beb26e6b945 100644 --- a/src/mame/tvgames/xavix.cpp +++ b/src/mame/tvgames/xavix.cpp @@ -2129,4 +2129,4 @@ CONS( 2002, gcslottv, 0, 0, xavix_cart_gcslottv, gcslottv, xavix // Let’s!TVプレイ 超にんきスポット!ころがしほーだい たまごっちりぞーと (Let's! TV Play Chou Ninki Spot! Korogashi-Houdai Tamagotchi Resort) (only on the Japanese list? http://test.shinsedai.co.jp/english/products/Applied/list.html ) This also allows you to use an IR reciever to import a Tamagotchi from compatible games CONS( 2006, ltv_tam, 0, 0, xavix_i2c_24lc04_tam, ltv_tam,xavix_i2c_ltv_tam_state, init_xavix, "Bandai / SSD Company LTD", "Let's! TV Play Chou Ninki Spot! Korogashi-Houdai Tamagotchi Resort (Japan)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND ) -CONS( 2008, hikara, 0, 0, xavix_cart_hikara, hikara, xavix_hikara_state, init_xavix, "Takara Tomy / SSD Company LTD", "Hi-Kara (Japan)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND /*| MACHINE_IS_BIOS_ROOT*/ ) +CONS( 2008, hikara, 0, 0, xavix_cart_hikara, hikara, xavix_hikara_state, init_xavix, "Takara Tomy / SSD Company LTD", "Hi-kara (Japan)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND /*| MACHINE_IS_BIOS_ROOT*/ ) -- cgit v1.2.3