diff options
| author | 2025-10-06 23:13:00 +0900 | |
|---|---|---|
| committer | 2025-10-07 01:13:00 +1100 | |
| commit | 1d1e5813b85e548d4cc8371291f9b4a4e2aa2744 (patch) | |
| tree | 324dc8c3410491366781d6fc81995c6c06ebc236 | |
| parent | 757e9c05762635ec819f3dd7e1497c02190b6379 (diff) | |
snk/hng64*.cpp: Cleaned up code. (#14275)
* Use template for tilemap info function.
* Use logmacro.h for configurable logging.
* Suppress side effects for debugger reads.
* Reduced literal tags.
* Use abbreviated integer types consistently.
| -rw-r--r-- | src/mame/snk/hng64.cpp | 351 | ||||
| -rw-r--r-- | src/mame/snk/hng64.h | 531 | ||||
| -rw-r--r-- | src/mame/snk/hng64_3d.ipp | 272 | ||||
| -rw-r--r-- | src/mame/snk/hng64_a.cpp | 181 | ||||
| -rw-r--r-- | src/mame/snk/hng64_sprite.ipp | 97 | ||||
| -rw-r--r-- | src/mame/snk/hng64_v.cpp | 478 |
6 files changed, 909 insertions, 1001 deletions
diff --git a/src/mame/snk/hng64.cpp b/src/mame/snk/hng64.cpp index 456607b18ff..87262935ab6 100644 --- a/src/mame/snk/hng64.cpp +++ b/src/mame/snk/hng64.cpp @@ -681,6 +681,7 @@ LVS-DG2 #define LOG_SNDCOM_UNKNWN (1U << 2) #define LOG_DMA (1U << 3) #define LOG_VREGS (1U << 4) +#define LOG_SYSREGS (1U << 5) #define VERBOSE (LOG_GENERAL) #include "logmacro.h" @@ -696,18 +697,18 @@ LVS-DG2 */ -void hng64_state::hng_comm_map(address_map &map) +void hng64_state::comm_map(address_map &map) { map(0x00000, 0x1ffff).rom().region("comm", 0); map(0x20000, 0x3ffff).bankr(m_com_bank); map(0x40000, 0x47fff).mirror(0xb8000).ram(); } -void hng64_state::hng_comm_io_map(address_map &map) +void hng64_state::comm_io_map(address_map &map) { map.global_mask(0xff); /* Reserved for the KL5C80 internal hardware */ -// map(0x00, 0x07).rw(FUNC(hng64_state::hng64_comm_mmu_r), FUNC(hng64_state::hng64_comm_mmu_w)); +// map(0x00, 0x07).rw(FUNC(hng64_state::comm_mmu_r), FUNC(hng64_state::comm_mmu_w)); // map(0x08, 0x1f).noprw(); /* Reserved */ // map(0x20, 0x25).rw(hng64_state::)); /* Timer/Counter B */ /* hng64 writes here */ // map(0x27, 0x27).noprw(); /* Reserved */ @@ -721,8 +722,8 @@ void hng64_state::hng_comm_io_map(address_map &map) /* General IO */ // map(0x40, 0x47).rw("ulanc", FUNC(com20020_device::read), FUNC(com20020_device::write)); - map(0x50, 0x57).rw(FUNC(hng64_state::hng64_com_share_r), FUNC(hng64_state::hng64_com_share_w)); - map(0x72, 0x72).w(FUNC(hng64_state::hng64_com_bank_w)); + map(0x50, 0x57).rw(FUNC(hng64_state::com_share_r), FUNC(hng64_state::com_share_w)); + map(0x72, 0x72).w(FUNC(hng64_state::com_bank_w)); // map(0x73, 0x73).w(hng64_state::)); /* dunno yet */ } @@ -736,59 +737,60 @@ void hng64_state::reset_net() void hng64_state::hng64_network(machine_config &config) { KL5C80A12(config, m_comm, HNG64_MASTER_CLOCK / 4); /* KL5C80A12CFP - binary compatible with Z80. */ - m_comm->set_addrmap(AS_PROGRAM, &hng64_state::hng_comm_map); - m_comm->set_addrmap(AS_IO, &hng64_state::hng_comm_io_map); + m_comm->set_addrmap(AS_PROGRAM, &hng64_state::comm_map); + m_comm->set_addrmap(AS_IO, &hng64_state::comm_io_map); } -uint32_t hng64_state::hng64_com_r(offs_t offset, uint32_t mem_mask) +u32 hng64_state::com_r(offs_t offset, u32 mem_mask) { - LOGMASKED(LOG_COMRW, "com read (PC=%08x): %08x %08x = %08x\n", m_maincpu->pc(), (offset*4)+0xc0000000, mem_mask, m_idt7133_dpram[offset]); + if (!machine().side_effects_disabled()) + LOGMASKED(LOG_COMRW, "com read (PC=%08x): %08x %08x = %08x\n", m_maincpu->pc(), (offset*4)+0xc0000000, mem_mask, m_idt7133_dpram[offset]); return m_idt7133_dpram[offset]; } -void hng64_state::hng64_com_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::com_w(offs_t offset, u32 data, u32 mem_mask) { LOGMASKED(LOG_COMRW, "com write (PC=%08x): %08x %08x = %08x\n", m_maincpu->pc(), (offset*4)+0xc0000000, mem_mask, data); COMBINE_DATA(&m_idt7133_dpram[offset]); } /* TODO: fully understand this */ -void hng64_state::hng64_com_share_mips_w(offs_t offset, uint8_t data) +void hng64_state::com_share_mips_w(offs_t offset, u8 data) { m_com_shared[offset ^ 3] = data; } -uint8_t hng64_state::hng64_com_share_mips_r(offs_t offset) +u8 hng64_state::com_share_mips_r(offs_t offset) { return m_com_shared[offset]; } -void hng64_state::hng64_com_share_w(offs_t offset, uint8_t data) +void hng64_state::com_share_w(offs_t offset, u8 data) { m_com_shared[offset] = data; } -uint8_t hng64_state::hng64_com_share_r(offs_t offset) +u8 hng64_state::com_share_r(offs_t offset) { - if(offset == 4) + if (offset == 4) return m_com_shared[offset] | 1; // some busy flag? return m_com_shared[offset]; } -void hng64_state::hng64_com_bank_w(uint8_t data) +void hng64_state::com_bank_w(u8 data) { m_com_bank->set_entry(data & 0x03); } -uint32_t hng64_state::hng64_rtc_r(offs_t offset, uint32_t mem_mask) +u32 hng64_state::rtc_r(offs_t offset, u32 mem_mask) { if (offset & 1) { // RTC is mapped to 1 byte (4-bits used) in every 8 bytes so we can't even install this with a umask - int rtc_addr = offset >> 1; + const int rtc_addr = offset >> 1; // bit 4 disables "system log reader" (the device is 4-bit? so this bit is not from the device?) if ((rtc_addr & 0xf) == 0xd) @@ -799,7 +801,8 @@ uint32_t hng64_state::hng64_rtc_r(offs_t offset, uint32_t mem_mask) else { // shouldn't happen unless something else is mapped here too - LOG("%s: unhandled hng64_rtc_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); + if (!machine().side_effects_disabled()) + LOG("%s: unhandled rtc_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); return 0xffffffff; } } @@ -812,28 +815,26 @@ void hng64_state::do_dma(address_space &space) LOGMASKED(LOG_DMA, "Performing DMA Start %08x Len %08x Dst %08x\n", m_dma_start, m_dma_len, m_dma_dst); while (m_dma_len >= 0) { - uint32_t dat; - - dat = space.read_dword(m_dma_start); - space.write_dword(m_dma_dst, dat); + space.write_dword(m_dma_dst, space.read_dword(m_dma_start)); m_dma_start += 4; m_dma_dst += 4; m_dma_len--; } } -uint32_t hng64_state::hng64_dmac_r(offs_t offset, uint32_t mem_mask) +u32 hng64_state::dmac_r(offs_t offset, u32 mem_mask) { // DMAC seems to be mapped as 4 bytes in every 8 if ((offset * 4) == 0x54) return 0x00000000; //dma status, 0x800 - LOG("%s: unhandled hng64_dmac_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); + if (!machine().side_effects_disabled()) + LOG("%s: unhandled dmac_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); return 0xffffffff; } -void hng64_state::hng64_dmac_w(address_space &space, offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::dmac_w(address_space &space, offs_t offset, u32 data, u32 mem_mask) { // DMAC seems to be mapped as 4 bytes in every 8 switch (offset * 4) @@ -852,12 +853,12 @@ void hng64_state::hng64_dmac_w(address_space &space, offs_t offset, uint32_t dat case 0x4c: // (0x0101 - trigger) (0x0000 - after DMA) case 0x5c: // (0x0008 - trigger?) after 0x4c default: - LOG("%s: unhandled hng64_dmac_w (%04x) %08x (%08x)\n", machine().describe_context(), offset*4, data, mem_mask); + LOG("%s: unhandled dmac_w (%04x) %08x (%08x)\n", machine().describe_context(), offset*4, data, mem_mask); break; } } -void hng64_state::hng64_rtc_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::rtc_w(offs_t offset, u32 data, u32 mem_mask) { if (offset & 1) { @@ -867,33 +868,35 @@ void hng64_state::hng64_rtc_w(offs_t offset, uint32_t data, uint32_t mem_mask) else { // shouldn't happen unless something else is mapped here too - LOG("%s: unhandled hng64_rtc_w (%04x) %08x (%08x)\n", machine().describe_context(), offset*4, data, mem_mask); + LOG("%s: unhandled rtc_w (%04x) %08x (%08x)\n", machine().describe_context(), offset*4, data, mem_mask); } } -void hng64_state::hng64_mips_to_iomcu_irq_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::mips_to_iomcu_irq_w(offs_t offset, u32 data, u32 mem_mask) { // guess, written after a write to 0x00 in dpram, which is where the command goes, and the IRQ onthe MCU reads the command LOG("%s: HNG64 writing to SYSTEM Registers %08x (%08x) (IO MCU IRQ TRIGGER?)\n", machine().describe_context(), data, mem_mask); if (mem_mask & 0xffff0000) m_tempio_irqon_timer->adjust(attotime::zero); } -uint32_t hng64_state::hng64_irqc_r(offs_t offset, uint32_t mem_mask) +u32 hng64_state::irqc_r(offs_t offset, u32 mem_mask) { if ((offset * 4) == 0x04) { - LOG("%s: irq level READ %04x\n", machine().describe_context(), m_irq_level); + if (!machine().side_effects_disabled()) + LOG("%s: irq level READ %04x\n", machine().describe_context(), m_irq_level); return m_irq_level; } else { - LOG("%s: unhandled hng64_irqc_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); + if (!machine().side_effects_disabled()) + LOG("%s: unhandled irqc_r (%04x) (%08x)\n", machine().describe_context(), offset*4, mem_mask); } return 0xffffffff; } -void hng64_state::hng64_irqc_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::irqc_w(offs_t offset, u32 data, u32 mem_mask) { switch (offset * 4) { @@ -905,7 +908,7 @@ void hng64_state::hng64_irqc_w(offs_t offset, uint32_t data, uint32_t mem_mask) break; default: - LOG("%s: unhandled hng64_irqc_w (%04x) %08x (%08x)\n", machine().describe_context(), offset * 4, data, mem_mask); + LOG("%s: unhandled irqc_w (%04x) %08x (%08x)\n", machine().describe_context(), offset * 4, data, mem_mask); break; } } @@ -940,41 +943,41 @@ void hng64_state::hng64_irqc_w(offs_t offset, uint32_t data, uint32_t mem_mask) ---- */ -uint32_t hng64_state::hng64_sysregs_r(offs_t offset, uint32_t mem_mask) +u32 hng64_state::sysregs_r(offs_t offset, u32 mem_mask) { - //LOG("%s: hng64_sysregs_r (%04x) (%08x)\n", machine().describe_context(), offset * 4, mem_mask); + //LOG("%s: sysregs_r (%04x) (%08x)\n", machine().describe_context(), offset * 4, mem_mask); - switch(offset*4) + switch (offset * 4) { case 0x001c: return 0x00000000; // 0x00000040 must not be set or games won't boot //case 0x106c: //case 0x107c: case 0x1084: - LOG("%s: HNG64 reading MCU status port (%08x)\n", machine().describe_context(), mem_mask); + if (!machine().side_effects_disabled()) + LOG("%s: HNG64 reading MCU status port (%08x)\n", machine().describe_context(), mem_mask); return 0x00000002; //MCU->MIPS latch port } return m_sysregs[offset]; } -void hng64_state::raster_irq_pos_w(uint32_t data) +void hng64_state::raster_irq_pos_w(u32 data) { m_raster_irq_pos[m_irq_pos_half] = data; m_irq_pos_half ^= 1; } -void hng64_state::hng64_sysregs_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::sysregs_w(offs_t offset, u32 data, u32 mem_mask) { - COMBINE_DATA (&m_sysregs[offset]); + COMBINE_DATA(&m_sysregs[offset]); + + if (((offset * 4) & 0xff00) == 0x1100) + LOGMASKED(LOG_SYSREGS, "%s: HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", machine().describe_context(), offset*4, m_sysregs[offset], m_maincpu->pc()); -#if 0 - if(((offset*4) & 0xff00) == 0x1100) - logerror("HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", offset*4, m_sysregs[offset], m_maincpu->pc()); -#endif - int scanline = m_screen->vpos(); + const int scanline = m_screen->vpos(); - switch(offset*4) + switch (offset * 4) { /* case 0x0014: @@ -1005,7 +1008,7 @@ void hng64_state::hng64_sysregs_w(offs_t offset, uint32_t data, uint32_t mem_mas break; */ default: - logerror("%s: HNG64 writing to SYSTEM Registers %08x %08x (%08x) on scanline %d\n", machine().describe_context(), offset * 4, data, mem_mask, scanline); + LOGMASKED(LOG_SYSREGS, "%s: HNG64 writing to SYSTEM Registers %08x %08x (%08x) on scanline %d\n", machine().describe_context(), offset * 4, data, mem_mask, scanline); } } @@ -1014,9 +1017,10 @@ void hng64_state::hng64_sysregs_w(offs_t offset, uint32_t data, uint32_t mem_mas * MIPS side Dual Port RAM hookup for MCU **************************************/ -uint8_t hng64_state::hng64_dualport_r(offs_t offset) +u8 hng64_state::dualport_r(offs_t offset) { - LOG("%s: dualport R %04x\n", machine().describe_context(), offset); + if (!machine().side_effects_disabled()) + LOG("%s: dualport R %04x\n", machine().describe_context(), offset); // hack, this should just be put in ram at 0x600 by the MCU. if (!(m_mcu_en == 0x0c)) @@ -1054,10 +1058,10 @@ Beast Busters 2 outputs (all at offset == 0x1c): need to work out what triggers the interrupt, as a write to 0 wouldn't as the Dual Port RAM interrupts are on addresses 0x7fe and 0x7ff (we're using an address near the system regs, based on code analysis - it seems correct, see hng64_mips_to_iomcu_irq_w ) + it seems correct, see mips_to_iomcu_irq_w ) */ -void hng64_state::hng64_dualport_w(offs_t offset, uint8_t data) +void hng64_state::dualport_w(offs_t offset, u8 data) { m_dt71321_dpram->right_w(offset, data); LOG("%s: dualport WRITE %04x %02x\n", machine().describe_context(), offset, data); @@ -1068,14 +1072,12 @@ void hng64_state::hng64_dualport_w(offs_t offset, uint8_t data) /* The following is guesswork, needs confirmation with a test on the real board. */ // every sprite is 0x20 bytes // -void hng64_state::hng64_sprite_clear_even_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::sprite_clear_even_w(offs_t offset, u32 data, u32 mem_mask) { auto &mspace = m_maincpu->space(AS_PROGRAM); - uint32_t spr_offs; - - spr_offs = (offset) * 0x40; + const u32 spr_offs = (offset) * 0x40; // for one sprite - if(ACCESSING_BITS_16_31) + if (ACCESSING_BITS_16_31) { mspace.write_dword(0x20000000+0x00+0x00+spr_offs, 0x00000000); mspace.write_dword(0x20000000+0x08+0x00+spr_offs, 0x00000000); @@ -1083,7 +1085,7 @@ void hng64_state::hng64_sprite_clear_even_w(offs_t offset, uint32_t data, uint32 mspace.write_dword(0x20000000+0x18+0x00+spr_offs, 0x00000000); } // for another sprite - if(ACCESSING_BITS_8_15) + if (ACCESSING_BITS_8_15) { mspace.write_dword(0x20000000+0x00+0x20+spr_offs, 0x00000000); mspace.write_dword(0x20000000+0x08+0x20+spr_offs, 0x00000000); @@ -1092,14 +1094,12 @@ void hng64_state::hng64_sprite_clear_even_w(offs_t offset, uint32_t data, uint32 } } -void hng64_state::hng64_sprite_clear_odd_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::sprite_clear_odd_w(offs_t offset, u32 data, u32 mem_mask) { auto &mspace = m_maincpu->space(AS_PROGRAM); - uint32_t spr_offs; - - spr_offs = (offset) * 0x40; + const u32 spr_offs = (offset) * 0x40; // for one sprite - if(ACCESSING_BITS_16_31) + if (ACCESSING_BITS_16_31) { mspace.write_dword(0x20000000+0x04+0x00+spr_offs, 0x00000000); // mspace.write_dword(0x20000000+0x0c+0x00+spr_offs, 0x00000000); // erases part of the slash palette in the sams64 2nd intro when we don't want it to! (2nd slash) @@ -1107,7 +1107,7 @@ void hng64_state::hng64_sprite_clear_odd_w(offs_t offset, uint32_t data, uint32_ mspace.write_dword(0x20000000+0x1c+0x00+spr_offs, 0x00000000); } // for another sprite - if(ACCESSING_BITS_0_15) + if (ACCESSING_BITS_0_15) { mspace.write_dword(0x20000000+0x04+0x20+spr_offs, 0x00000000); // mspace.write_dword(0x20000000+0x0c+0x20+spr_offs, 0x00000000); // erases part of the slash palette in the sams64 2nd intro when we don't want it to! (1st slash) @@ -1116,16 +1116,16 @@ void hng64_state::hng64_sprite_clear_odd_w(offs_t offset, uint32_t data, uint32_ } } -void hng64_state::hng64_vregs_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::vregs_w(offs_t offset, u32 data, u32 mem_mask) { - LOGMASKED(LOG_VREGS, "hng64_vregs_w %02x, %08x %08x\n", offset * 4, data, mem_mask); + LOGMASKED(LOG_VREGS, "vregs_w %02x, %08x %08x\n", offset * 4, data, mem_mask); - uint32_t newval = m_videoregs[offset]; + u32 newval = m_videoregs[offset]; COMBINE_DATA(&newval); if (newval != m_videoregs[offset]) { - int vpos = m_screen->vpos(); + const int vpos = m_screen->vpos(); if (vpos > 0) m_screen->update_partial(vpos - 1); @@ -1134,9 +1134,9 @@ void hng64_state::hng64_vregs_w(offs_t offset, uint32_t data, uint32_t mem_mask) } } -uint16_t hng64_state::main_sound_comms_r(offs_t offset) +u16 hng64_state::main_sound_comms_r(offs_t offset) { - switch(offset *2) + switch (offset * 2) { case 0x00: return main_latch[0]; @@ -1147,15 +1147,16 @@ uint16_t hng64_state::main_sound_comms_r(offs_t offset) case 0x06: return sound_latch[1]; default: - LOGMASKED(LOG_SNDCOM_UNKNWN, "%08x R\n",offset*2); + if (!machine().side_effects_disabled()) + LOGMASKED(LOG_SNDCOM_UNKNWN, "%08x R\n",offset*2); break; } return 0; } -void hng64_state::main_sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::main_sound_comms_w(offs_t offset, u16 data, u16 mem_mask) { - switch(offset * 2) + switch (offset * 2) { case 0x00: COMBINE_DATA(&main_latch[0]); @@ -1178,43 +1179,43 @@ void hng64_state::main_sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_ } -void hng64_state::hng_map(address_map &map) +void hng64_state::main_map(address_map &map) { // main RAM / ROM - map(0x00000000, 0x00ffffff).ram().share("mainram"); + map(0x00000000, 0x00ffffff).ram().share(m_mainram); map(0x04000000, 0x05ffffff).nopw().rom().region("gameprg", 0); // Misc Peripherals - map(0x1f700000, 0x1f7010ff).rw(FUNC(hng64_state::hng64_sysregs_r), FUNC(hng64_state::hng64_sysregs_w)).share("sysregs"); // various things + map(0x1f700000, 0x1f7010ff).rw(FUNC(hng64_state::sysregs_r), FUNC(hng64_state::sysregs_w)).share(m_sysregs); // various things - map(0x1f701100, 0x1f70111f).rw(FUNC(hng64_state::hng64_irqc_r), FUNC(hng64_state::hng64_irqc_w)); - map(0x1f701200, 0x1f70127f).rw(FUNC(hng64_state::hng64_dmac_r), FUNC(hng64_state::hng64_dmac_w)); + map(0x1f701100, 0x1f70111f).rw(FUNC(hng64_state::irqc_r), FUNC(hng64_state::irqc_w)); + map(0x1f701200, 0x1f70127f).rw(FUNC(hng64_state::dmac_r), FUNC(hng64_state::dmac_w)); // 1f702004 used (rarely writes 01 or a random looking value as part of init sequences) - map(0x1f702100, 0x1f70217f).rw(FUNC(hng64_state::hng64_rtc_r), FUNC(hng64_state::hng64_rtc_w)); - map(0x1f7021c4, 0x1f7021c7).w(FUNC(hng64_state::hng64_mips_to_iomcu_irq_w)); + map(0x1f702100, 0x1f70217f).rw(FUNC(hng64_state::rtc_r), FUNC(hng64_state::rtc_w)); + map(0x1f7021c4, 0x1f7021c7).w(FUNC(hng64_state::mips_to_iomcu_irq_w)); // SRAM. Coin data, Player Statistics, etc. map(0x1f800000, 0x1f803fff).ram().share("nvram"); // Dualport RAM (shared with IO MCU) - map(0x1f808000, 0x1f8087ff).rw(FUNC(hng64_state::hng64_dualport_r), FUNC(hng64_state::hng64_dualport_w)).umask32(0xffffffff); + map(0x1f808000, 0x1f8087ff).rw(FUNC(hng64_state::dualport_r), FUNC(hng64_state::dualport_w)).umask32(0xffffffff); // BIOS ROM - map(0x1fc00000, 0x1fc7ffff).nopw().rom().region("user1", 0); + map(0x1fc00000, 0x1fc7ffff).nopw().rom().region("bios", 0); // Sprites - map(0x20000000, 0x2000bfff).ram().share("spriteram"); - map(0x2000d800, 0x2000e3ff).w(FUNC(hng64_state::hng64_sprite_clear_even_w)); - map(0x2000e400, 0x2000efff).w(FUNC(hng64_state::hng64_sprite_clear_odd_w)); - map(0x20010000, 0x20010013).ram().share("spriteregs"); + map(0x20000000, 0x2000bfff).ram().share(m_spriteram); + map(0x2000d800, 0x2000e3ff).w(FUNC(hng64_state::sprite_clear_even_w)); + map(0x2000e400, 0x2000efff).w(FUNC(hng64_state::sprite_clear_odd_w)); + map(0x20010000, 0x20010013).ram().share(m_spriteregs); // Backgrounds - map(0x20100000, 0x2017ffff).ram().w(FUNC(hng64_state::hng64_videoram_w)).share("videoram"); // Tilemap - map(0x20190000, 0x20190037).ram().w(FUNC(hng64_state::hng64_vregs_w)).share("videoregs"); + map(0x20100000, 0x2017ffff).ram().w(FUNC(hng64_state::videoram_w)).share(m_videoram); // Tilemap + map(0x20190000, 0x20190037).ram().w(FUNC(hng64_state::vregs_w)).share(m_videoregs); // Mixing - map(0x20200000, 0x20203fff).ram().w(FUNC(hng64_state::pal_w)).share("paletteram"); - map(0x20208000, 0x2020805f).w(FUNC(hng64_state::tcram_w)).share("tcram"); // Transition Control + map(0x20200000, 0x20203fff).ram().w(FUNC(hng64_state::pal_w)).share(m_paletteram); + map(0x20208000, 0x2020805f).w(FUNC(hng64_state::tcram_w)).share(m_tcram); // Transition Control map(0x20208000, 0x2020805f).r(FUNC(hng64_state::tcram_r)); // 3D display list control @@ -1225,27 +1226,27 @@ void hng64_state::hng_map(address_map &map) map(0x20300218, 0x2030021b).r(FUNC(hng64_state::dl_vreg_r)); // 3D framebuffer - map(0x30000000, 0x30000003).rw(FUNC(hng64_state::hng64_fbcontrol_r), FUNC(hng64_state::hng64_fbcontrol_w)).umask32(0xffffffff); - map(0x30000004, 0x30000007).w(FUNC(hng64_state::hng64_fbscale_w)).share("fbscale"); - map(0x30000008, 0x3000000b).w(FUNC(hng64_state::hng64_fbscroll_w)).share("fbscroll"); - map(0x3000000c, 0x3000000f).w(FUNC(hng64_state::hng64_fbunkbyte_w)).share("fbunk"); + map(0x30000000, 0x30000003).rw(FUNC(hng64_state::fbcontrol_r), FUNC(hng64_state::fbcontrol_w)).umask32(0xffffffff); + map(0x30000004, 0x30000007).w(FUNC(hng64_state::fbscale_w)).share(m_fbscale); + map(0x30000008, 0x3000000b).w(FUNC(hng64_state::fbscroll_w)).share(m_fbscroll); + map(0x3000000c, 0x3000000f).w(FUNC(hng64_state::fbunkbyte_w)).share(m_fbunk); // as the below registers are used at render time, not mixing time, it's possible the above scroll/scale registers are too - map(0x30000010, 0x3000002f).rw(FUNC(hng64_state::hng64_texture_wrapsize_table_r), FUNC(hng64_state::hng64_texture_wrapsize_table_w)).umask32(0xffffffff); + map(0x30000010, 0x3000002f).rw(FUNC(hng64_state::texture_wrapsize_table_r), FUNC(hng64_state::texture_wrapsize_table_w)).umask32(0xffffffff); - map(0x30100000, 0x3015ffff).rw(FUNC(hng64_state::hng64_fbram1_r), FUNC(hng64_state::hng64_fbram1_w)).share("fbram1"); // 3D Display Buffer A - map(0x30200000, 0x3025ffff).rw(FUNC(hng64_state::hng64_fbram2_r), FUNC(hng64_state::hng64_fbram2_w)).share("fbram2"); // 3D Display Buffer B + map(0x30100000, 0x3015ffff).rw(FUNC(hng64_state::fbram1_r), FUNC(hng64_state::fbram1_w)).share(m_fbram1); // 3D Display Buffer A + map(0x30200000, 0x3025ffff).rw(FUNC(hng64_state::fbram2_r), FUNC(hng64_state::fbram2_w)).share(m_fbram2); // 3D Display Buffer B // Sound - map(0x60000000, 0x601fffff).rw(FUNC(hng64_state::hng64_soundram2_r), FUNC(hng64_state::hng64_soundram2_w)); // actually seems unmapped, see note in audio/hng64.c - map(0x60200000, 0x603fffff).rw(FUNC(hng64_state::hng64_soundram_r), FUNC(hng64_state::hng64_soundram_w)); // program + data for V53A gets uploaded here + map(0x60000000, 0x601fffff).rw(FUNC(hng64_state::soundram2_r), FUNC(hng64_state::soundram2_w)); // actually seems unmapped, see note in audio/hng64.c + map(0x60200000, 0x603fffff).rw(FUNC(hng64_state::soundram_r), FUNC(hng64_state::soundram_w)); // program + data for V53A gets uploaded here // These are sound ports of some sort map(0x68000000, 0x6800000f).rw(FUNC(hng64_state::main_sound_comms_r), FUNC(hng64_state::main_sound_comms_w)); - map(0x6f000000, 0x6f000003).w(FUNC(hng64_state::hng64_soundcpu_enable_w)); + map(0x6f000000, 0x6f000003).w(FUNC(hng64_state::soundcpu_enable_w)); // Dualport RAM (shared with Communications CPU) - map(0xc0000000, 0xc0000fff).rw(FUNC(hng64_state::hng64_com_r), FUNC(hng64_state::hng64_com_w)).share("com_ram"); - map(0xc0001000, 0xc0001007).ram().share("comhack");//.rw(FUNC(hng64_state::hng64_com_share_mips_r), FUNC(hng64_state::hng64_com_share_mips_w)); + map(0xc0000000, 0xc0000fff).rw(FUNC(hng64_state::com_r), FUNC(hng64_state::com_w)).share("com_ram"); + map(0xc0001000, 0xc0001007).ram().share(m_comhack);//.rw(FUNC(hng64_state::com_share_mips_r), FUNC(hng64_state::com_share_mips_w)); } @@ -1748,20 +1749,20 @@ static const gfx_layout hng64_16x16x8_spritelayout = 32*64 }; -static const uint32_t texlayout_xoffset[1024] = { STEP1024(0,8) }; -static const uint32_t texlayout_yoffset[1024] = { STEP1024(0,8192) }; +static const u32 texlayout_xoffset[1024] = { STEP1024(0,8) }; +static const u32 texlayout_yoffset[1024] = { STEP1024(0,8192) }; -template <uint32_t... Values> -static auto const &texlayout_xoffset_4(std::integer_sequence<uint32_t, Values...>) +template <u32... Values> +static auto const &texlayout_xoffset_4(std::integer_sequence<u32, Values...>) { - static constexpr uint32_t const s_values[sizeof...(Values)] = { ((Values * 4) ^ 4)... }; + static constexpr u32 const s_values[sizeof...(Values)] = { ((Values * 4) ^ 4)... }; return s_values; } -template <uint32_t... Values> -static auto const &texlayout_yoffset_4(std::integer_sequence<uint32_t, Values...>) +template <u32... Values> +static auto const &texlayout_yoffset_4(std::integer_sequence<u32, Values...>) { - static constexpr uint32_t const s_values[sizeof...(Values)] = { (Values * 4096)... }; + static constexpr u32 const s_values[sizeof...(Values)] = { (Values * 4096)... }; return s_values; } @@ -1788,8 +1789,8 @@ static const gfx_layout hng64_1024x1024x4_texlayout = EXTENDED_XOFFS, EXTENDED_YOFFS, 1024*2048*4, - texlayout_xoffset_4(std::make_integer_sequence<uint32_t, 1024>()), - texlayout_yoffset_4(std::make_integer_sequence<uint32_t, 2048>()) + texlayout_xoffset_4(std::make_integer_sequence<u32, 1024>()), + texlayout_yoffset_4(std::make_integer_sequence<u32, 2048>()) }; @@ -1810,13 +1811,13 @@ static GFXDECODE_START( gfx_hng64 ) GFXDECODE_END -static void hng64_reorder( uint8_t* gfxregion, size_t gfxregionsize) +static void hng64_reorder(u8* gfxregion, size_t gfxregionsize) { // by default 2 4bpp tiles are stored in each 8bpp tile, this makes decoding in MAME harder than it needs to be // reorder them - uint8_t tilesize = 4*8; // 4 bytes per line, 8 lines + const u8 tilesize = 4*8; // 4 bytes per line, 8 lines - std::vector<uint8_t> buffer(gfxregionsize); + std::vector<u8> buffer(gfxregionsize); for (int i = 0; i < gfxregionsize/2; i += tilesize) { @@ -1827,14 +1828,14 @@ static void hng64_reorder( uint8_t* gfxregion, size_t gfxregionsize) memcpy(gfxregion, &buffer[0], gfxregionsize); } -void hng64_state::init_hng64_reorder_gfx() +void hng64_state::init_reorder_gfx() { hng64_reorder(memregion("scrtile")->base(), memregion("scrtile")->bytes()); } void hng64_state::init_hng64() { - init_hng64_reorder_gfx(); + init_reorder_gfx(); } void hng64_state::init_hng64_fght() @@ -1846,7 +1847,7 @@ void hng64_state::init_hng64_fght() void hng64_state::init_ss64() { init_hng64_fght(); - m_samsho64_3d_hack = 1; + m_samsho64_3d_hack = true; } void hng64_state::init_hng64_drive() @@ -1858,7 +1859,7 @@ void hng64_state::init_hng64_drive() void hng64_state::init_roadedge() { init_hng64_drive(); - m_roadedge_3d_hack = 1; + m_roadedge_3d_hack = true; } void hng64_state::init_hng64_shoot() @@ -1867,7 +1868,7 @@ void hng64_state::init_hng64_shoot() init_hng64(); } -void hng64_state::set_irq(uint32_t irq_vector) +void hng64_state::set_irq(u32 irq_vector) { /* TODO: @@ -2107,11 +2108,11 @@ void hng64_state::set_irq(uint32_t irq_vector) m_irq_pending |= irq_vector; - if(m_irq_pending) + if (m_irq_pending) { - for(int i = 0; i < 31; i++) + for (int i = 0; i < 31; i++) { - if(m_irq_pending & 1 << i) + if (m_irq_pending & 1 << i) { m_irq_level = i; break; @@ -2126,7 +2127,7 @@ void hng64_state::set_irq(uint32_t irq_vector) TIMER_DEVICE_CALLBACK_MEMBER(hng64_state::hng64_irq) { - int scanline = param; + const int scanline = param; if (!(scanline & 1)) // in reality there are half as many scanlines, as we're running in interlace mode { @@ -2156,11 +2157,11 @@ TIMER_DEVICE_CALLBACK_MEMBER(hng64_state::hng64_irq) void hng64_state::machine_start() { /* 1 meg of virtual address space for the com cpu */ - m_com_virtual_mem = std::make_unique<uint8_t[]>(0x100000); - m_com_op_base = std::make_unique<uint8_t[]>(0x10000); + m_com_virtual_mem = std::make_unique<u8[]>(0x100000); + m_com_op_base = std::make_unique<u8[]>(0x10000); - m_soundram = std::make_unique<uint16_t[]>(0x200000 / 2); - m_soundram2 = std::make_unique<uint16_t[]>(0x200000 / 2); + m_soundram = std::make_unique<u16[]>(0x200000 / 2); + m_soundram2 = std::make_unique<u16[]>(0x200000 / 2); /* set the fastest DRC options */ m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS + MIPS3DRC_STRICT_VERIFY); @@ -2184,12 +2185,13 @@ void hng64_state::machine_start() m_irq_pending = 0; - m_3dfifo_timer = timer_alloc(FUNC(hng64_state::hng64_3dfifo_processed), this); + m_3dfifo_timer = timer_alloc(FUNC(hng64_state::_3dfifo_processed), this); m_comhack_timer = timer_alloc(FUNC(hng64_state::comhack_callback), this); m_com_bank->configure_entries(0, 4, memregion("comm")->base(), 0x20000); m_com_bank->set_entry(0); + init_sound(); init_io(); save_pointer(NAME(m_com_virtual_mem), 0x100000); @@ -2240,7 +2242,7 @@ TIMER_CALLBACK_MEMBER(hng64_state::comhack_callback) LOG("comhack_callback %04x\n\n", m_comhack[0]); // different network IDs give different default colours for the cars in roadedge - uint8_t network_id = 0x01; + u8 network_id = 0x01; // this fixes the stuck scroller text in the xrally intro (largest pink text) but prevents the inputs from working. // It's probably trying to sync the scroller with another unit? however the original machines can run as singles @@ -2285,7 +2287,7 @@ void hng64_state::machine_reset() ***********************************************/ -void hng64_state::ioport1_w(uint8_t data) +void hng64_state::ioport1_w(u8 data) { //LOG("%s: ioport1_w %02x\n", machine().describe_context(), data); @@ -2306,20 +2308,20 @@ void hng64_state::ioport1_w(uint8_t data) } // it does write 0xff here before each set of reading, but before setting a new output address? -void hng64_state::ioport3_w(uint8_t data) +void hng64_state::ioport3_w(u8 data) { if (m_port1 & 0x08) // 0x08 in port1 enables write? otherwise it writes 0xff to port 7 all the time, when port 7 is also lamps { - int addr = (m_port1 & 0xe0) >> 5; + const int addr = (m_port1 & 0xe0) >> 5; m_lamps->lamps_w(addr, data); } } -uint8_t hng64_state::ioport3_r() +u8 hng64_state::ioport3_r() { - int addr = (m_port1&0xe0)>>5; + const int addr = (m_port1 & 0xe0) >> 5; //LOG("%s: ioport3_r (from address %02x) (other bits of m_port1 %02x)\n", machine().describe_context(), addr, m_port1 & 0x1f); return m_in[addr]->read(); @@ -2327,7 +2329,7 @@ uint8_t hng64_state::ioport3_r() DEFINE_DEVICE_TYPE(HNG64_LAMPS, hng64_lamps_device, "hng64_lamps", "HNG64 Lamps") -hng64_lamps_device::hng64_lamps_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +hng64_lamps_device::hng64_lamps_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, HNG64_LAMPS, tag, owner, clock) , m_lamps_out_cb(*this) { @@ -2337,7 +2339,7 @@ void hng64_lamps_device::device_start() { } -void hng64_state::hng64_drive_lamps7_w(uint8_t data) +void hng64_state::drive_lamps7_w(u8 data) { /* 0x80 - BGM Select #2 (Active High) @@ -2351,7 +2353,7 @@ void hng64_state::hng64_drive_lamps7_w(uint8_t data) */ } -void hng64_state::hng64_drive_lamps6_w(uint8_t data) +void hng64_state::drive_lamps6_w(u8 data) { /* 0x80 - BGM Select #4 (Active High) @@ -2363,15 +2365,15 @@ void hng64_state::hng64_drive_lamps6_w(uint8_t data) 0x02 0x01 - Coin Counter #1 */ - machine().bookkeeping().coin_counter_w(0, data & 0x01); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); } -void hng64_state::hng64_drive_lamps5_w(uint8_t data) +void hng64_state::drive_lamps5_w(u8 data) { // force feedback steering position } -void hng64_state::hng64_shoot_lamps7_w(uint8_t data) +void hng64_state::shoot_lamps7_w(u8 data) { /* 0x80 @@ -2395,7 +2397,7 @@ void hng64_state::hng64_shoot_lamps7_w(uint8_t data) 0x00004000 gun #3 */ -void hng64_state::hng64_shoot_lamps6_w(uint8_t data) +void hng64_state::shoot_lamps6_w(u8 data) { // Start Lamp #1 / #2 don't get written to the output port, is this a TLCS870 bug or are they not connected to the 'lamp' outputs, they do get written to the DP ram, see above notes /* @@ -2410,7 +2412,7 @@ void hng64_state::hng64_shoot_lamps6_w(uint8_t data) */ } -void hng64_state::hng64_fight_lamps6_w(uint8_t data) +void hng64_state::fight_lamps6_w(u8 data) { /* 0x80 @@ -2422,8 +2424,8 @@ void hng64_state::hng64_fight_lamps6_w(uint8_t data) 0x02 - Coin Counter #2 0x01 - Coin Counter #1 */ - machine().bookkeeping().coin_counter_w(0, data & 0x01); - machine().bookkeeping().coin_counter_w(1, data & 0x02); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); } @@ -2433,7 +2435,7 @@ void hng64_state::hng64_fight_lamps6_w(uint8_t data) ***********************************************/ -void hng64_state::ioport7_w(uint8_t data) +void hng64_state::ioport7_w(u8 data) { /* Port bits @@ -2477,18 +2479,19 @@ void hng64_state::ioport7_w(uint8_t data) m_port7 = data; } -uint8_t hng64_state::ioport0_r() +u8 hng64_state::ioport0_r() { - uint16_t addr = (m_ex_ramaddr | (m_ex_ramaddr_upper<<9)) & 0x7ff; - uint8_t ret = m_dt71321_dpram->left_r(addr); + const u16 addr = (m_ex_ramaddr | (m_ex_ramaddr_upper << 9)) & 0x7ff; + const u8 ret = m_dt71321_dpram->left_r(addr); - LOG("%s: ioport0_r %02x (from address %04x)\n", machine().describe_context(), ret, addr); + if (!machine().side_effects_disabled()) + LOG("%s: ioport0_r %02x (from address %04x)\n", machine().describe_context(), ret, addr); return ret; } -void hng64_state::ioport0_w(uint8_t data) +void hng64_state::ioport0_w(u8 data) { - uint16_t addr = (m_ex_ramaddr | (m_ex_ramaddr_upper<<9)) & 0x7ff; + const u16 addr = (m_ex_ramaddr | (m_ex_ramaddr_upper << 9)) & 0x7ff; m_dt71321_dpram->left_w(addr, data); LOG("%s: ioport0_w %02x (to address %04x)\n", machine().describe_context(), data, addr); @@ -2504,7 +2507,7 @@ void hng64_state::ioport0_w(uint8_t data) /* This port is dual purpose, with the upper pins being used as a serial input / output / clock etc. and the output latch (written data) being configured appropriately however the lower 2 bits also seem to be used maybe these lower 2 bits were intended for serial comms LEDs, although none are documented in the PCB layouts. */ -void hng64_state::ioport4_w(uint8_t data) +void hng64_state::ioport4_w(u8 data) { LOG("%s: ioport4_w %02x\n", machine().describe_context(), data); } @@ -2533,14 +2536,14 @@ void hng64_state::sio0_w(int state) TIMER_CALLBACK_MEMBER(hng64_state::tempio_irqon_callback) { LOG("timer_hack_on\n"); - m_iomcu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE ); + m_iomcu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); m_tempio_irqoff_timer->adjust(m_maincpu->cycles_to_attotime(1000)); } TIMER_CALLBACK_MEMBER(hng64_state::tempio_irqoff_callback) { LOG("timer_hack_off\n"); - m_iomcu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE ); + m_iomcu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); } @@ -2561,7 +2564,7 @@ void hng64_state::hng64(machine_config &config) VR4300BE(config, m_maincpu, HNG64_MASTER_CLOCK); // actually R4300 m_maincpu->set_icache_size(16384); m_maincpu->set_dcache_size(16384); - m_maincpu->set_addrmap(AS_PROGRAM, &hng64_state::hng_map); + m_maincpu->set_addrmap(AS_PROGRAM, &hng64_state::main_map); TIMER(config, "scantimer", 0).configure_scanline(FUNC(hng64_state::hng64_irq), "screen", 0, 1); @@ -2573,8 +2576,8 @@ void hng64_state::hng64(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_raw(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART); - m_screen->set_screen_update(FUNC(hng64_state::screen_update_hng64)); - m_screen->screen_vblank().set(FUNC(hng64_state::screen_vblank_hng64)); + m_screen->set_screen_update(FUNC(hng64_state::screen_update)); + m_screen->screen_vblank().set(FUNC(hng64_state::screen_vblank)); PALETTE(config, m_palette).set_format(palette_device::xRGB_888, 0x1000); PALETTE(config, m_palette_fade0).set_format(palette_device::xRGB_888, 0x1000); @@ -2623,14 +2626,14 @@ void hng64_state::hng64_default(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps_out_cb<0>().set(FUNC(hng64_state::hng64_default_lamps_w<0>)); - lamps.lamps_out_cb<1>().set(FUNC(hng64_state::hng64_default_lamps_w<1>)); - lamps.lamps_out_cb<2>().set(FUNC(hng64_state::hng64_default_lamps_w<2>)); - lamps.lamps_out_cb<3>().set(FUNC(hng64_state::hng64_default_lamps_w<3>)); - lamps.lamps_out_cb<4>().set(FUNC(hng64_state::hng64_default_lamps_w<4>)); - lamps.lamps_out_cb<5>().set(FUNC(hng64_state::hng64_default_lamps_w<5>)); - lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_default_lamps_w<6>)); - lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_default_lamps_w<7>)); + lamps.lamps_out_cb<0>().set(FUNC(hng64_state::default_lamps_w<0>)); + lamps.lamps_out_cb<1>().set(FUNC(hng64_state::default_lamps_w<1>)); + lamps.lamps_out_cb<2>().set(FUNC(hng64_state::default_lamps_w<2>)); + lamps.lamps_out_cb<3>().set(FUNC(hng64_state::default_lamps_w<3>)); + lamps.lamps_out_cb<4>().set(FUNC(hng64_state::default_lamps_w<4>)); + lamps.lamps_out_cb<5>().set(FUNC(hng64_state::default_lamps_w<5>)); + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::default_lamps_w<6>)); + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::default_lamps_w<7>)); } void hng64_state::hng64_drive(machine_config &config) @@ -2638,9 +2641,9 @@ void hng64_state::hng64_drive(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps_out_cb<5>().set(FUNC(hng64_state::hng64_drive_lamps5_w)); // force feedback steering - lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_drive_lamps6_w)); // lamps + coin counter - lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_drive_lamps7_w)); // lamps + lamps.lamps_out_cb<5>().set(FUNC(hng64_state::drive_lamps5_w)); // force feedback steering + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::drive_lamps6_w)); // lamps + coin counter + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::drive_lamps7_w)); // lamps } void hng64_state::hng64_shoot(machine_config &config) @@ -2648,8 +2651,8 @@ void hng64_state::hng64_shoot(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_shoot_lamps6_w)); // start lamps (some missing?!) - lamps.lamps_out_cb<7>().set(FUNC(hng64_state::hng64_shoot_lamps7_w)); // gun lamps + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::shoot_lamps6_w)); // start lamps (some missing?!) + lamps.lamps_out_cb<7>().set(FUNC(hng64_state::shoot_lamps7_w)); // gun lamps } void hng64_state::hng64_fight(machine_config &config) @@ -2657,7 +2660,7 @@ void hng64_state::hng64_fight(machine_config &config) hng64(config); hng64_lamps_device &lamps(HNG64_LAMPS(config, m_lamps, 0)); - lamps.lamps_out_cb<6>().set(FUNC(hng64_state::hng64_fight_lamps6_w)); // coin counters + lamps.lamps_out_cb<6>().set(FUNC(hng64_state::fight_lamps6_w)); // coin counters } @@ -2675,7 +2678,7 @@ void hng64_state::hng64_fight(machine_config &config) #define HNG64_BIOS \ /* R4300 BIOS code (main CPU) */ \ - ROM_REGION32_BE( 0x0100000, "user1", 0 ) \ + ROM_REGION32_BE( 0x0100000, "bios", 0 ) \ ROM_SYSTEM_BIOS( 0, "japan", "Japan" ) \ ROM_LOAD_HNG64_BIOS( 0, "brom1.bin", 0x00000, 0x080000, CRC(a30dd3de) SHA1(3e2fd0a56214e6f5dcb93687e409af13d065ea30) ) \ ROM_SYSTEM_BIOS( 1, "us", "USA" ) \ diff --git a/src/mame/snk/hng64.h b/src/mame/snk/hng64.h index 0d7bec2d87a..33f3eb83ee4 100644 --- a/src/mame/snk/hng64.h +++ b/src/mame/snk/hng64.h @@ -33,7 +33,7 @@ struct polyVert float light; // The intensity of the illumination at this point - //uint16_t colorIndex = 0; // Flat shaded polygons, no texture, no lighting + //u16 colorIndex = 0; // Flat shaded polygons, no texture, no lighting }; struct polygon @@ -46,17 +46,17 @@ struct polygon bool flatShade = false; // Flat shaded polygon, no texture, no lighting bool blend = false; - uint8_t texIndex = 0; // Which texture to draw from (0x00-0x0f) - uint8_t tex4bpp = 0; // How to index into the texture - uint16_t texPageSmall = 0; // Does this polygon use 'small' texture pages? - uint32_t palOffset = 0; // The base offset where this object's palette starts. - uint16_t colorIndex = 0; + u8 texIndex = 0; // Which texture to draw from (0x00-0x0f) + u8 tex4bpp = 0; // How to index into the texture + u16 texPageSmall = 0; // Does this polygon use 'small' texture pages? + u32 palOffset = 0; // The base offset where this object's palette starts. + u16 colorIndex = 0; - uint16_t texscrollx = 0; - uint16_t texscrolly = 0; + u16 texscrollx = 0; + u16 texscrolly = 0; - uint16_t tex_mask_x = 1024; - uint16_t tex_mask_y = 1024; + u16 tex_mask_x = 1024; + u16 tex_mask_y = 1024; }; @@ -83,17 +83,17 @@ typedef frustum_clip_vertex<float, 5> hng64_clip_vertex; struct hng64_poly_data { - uint8_t tex4bpp = 0; - uint8_t texIndex = 0; - uint16_t texPageSmall = 0; - uint32_t palOffset = 0; - uint16_t colorIndex = 0; + u8 tex4bpp = 0; + u8 texIndex = 0; + u16 texPageSmall = 0; + u32 palOffset = 0; + u16 colorIndex = 0; bool blend = false; - uint16_t texscrollx = 0; - uint16_t texscrolly = 0; + u16 texscrollx = 0; + u16 texscrolly = 0; - uint16_t tex_mask_x = 1024; - uint16_t tex_mask_y = 1024; + u16 tex_mask_x = 1024; + u16 tex_mask_y = 1024; }; class hng64_state; @@ -101,22 +101,22 @@ class hng64_state; class hng64_poly_renderer : public poly_manager<float, hng64_poly_data, 7> { public: - hng64_poly_renderer(hng64_state& state); + hng64_poly_renderer(hng64_state &state); void drawShaded(polygon *p); - void render_texture_scanline(int32_t scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid); - void render_flat_scanline(int32_t scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid); + void render_texture_scanline(s32 scanline, const extent_t &extent, const hng64_poly_data &renderData, int threadid); + void render_flat_scanline(s32 scanline, const extent_t &extent, const hng64_poly_data &renderData, int threadid); - hng64_state& state() { return m_state; } - float* depthBuffer3d() { return m_depthBuffer3d.get(); } - uint16_t* colorBuffer3d() { return m_colorBuffer3d.get(); } + hng64_state &state() { return m_state; } + float *depthBuffer3d() { return m_depthBuffer3d.get(); } + u16 *colorBuffer3d() { return m_colorBuffer3d.get(); } private: - hng64_state& m_state; + hng64_state &m_state; // (Temporarily class members - someday they will live in the memory map) std::unique_ptr<float[]> m_depthBuffer3d; - std::unique_ptr<uint16_t[]> m_colorBuffer3d; + std::unique_ptr<u16[]> m_colorBuffer3d; }; @@ -124,11 +124,11 @@ private: class hng64_lamps_device : public device_t { public: - hng64_lamps_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + hng64_lamps_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); template <unsigned N> auto lamps_out_cb() { return m_lamps_out_cb[N].bind(); } - void lamps_w(offs_t offset, uint8_t data) { m_lamps_out_cb[offset](data); } + void lamps_w(offs_t offset, u8 data) { m_lamps_out_cb[offset](data); } protected: virtual void device_start() override ATTR_COLD; @@ -175,6 +175,7 @@ public: m_fbunk(*this, "fbunk"), m_idt7133_dpram(*this, "com_ram"), m_com_bank(*this, "com_bank"), + m_audio_bank(*this, "audio_bank_%u", 0U), m_gfxdecode(*this, "gfxdecode"), m_in(*this, "IN%u", 0U), m_samsho64_3d_hack(0), @@ -182,20 +183,20 @@ public: { } - void hng64(machine_config &config); - void hng64_default(machine_config &config); - void hng64_drive(machine_config &config); - void hng64_shoot(machine_config &config); - void hng64_fight(machine_config &config); + void hng64(machine_config &config) ATTR_COLD; + void hng64_default(machine_config &config) ATTR_COLD; + void hng64_drive(machine_config &config) ATTR_COLD; + void hng64_shoot(machine_config &config) ATTR_COLD; + void hng64_fight(machine_config &config) ATTR_COLD; - void init_roadedge(); - void init_hng64_drive(); - void init_hng64(); - void init_hng64_shoot(); - void init_ss64(); - void init_hng64_fght(); + void init_roadedge() ATTR_COLD; + void init_hng64_drive() ATTR_COLD; + void init_hng64() ATTR_COLD; + void init_hng64_shoot() ATTR_COLD; + void init_ss64() ATTR_COLD; + void init_hng64_fght() ATTR_COLD; - uint8_t *m_texturerom = nullptr; + u8 *m_texturerom = nullptr; required_device<screen_device> m_screen; required_device<palette_device> m_palette; required_device<palette_device> m_palette_fade0; @@ -204,19 +205,24 @@ public: required_shared_ptr<u32> m_paletteram; required_ioport m_vblank; +protected: + virtual void machine_start() override ATTR_COLD; + virtual void machine_reset() override ATTR_COLD; + virtual void video_start() override ATTR_COLD; + private: static constexpr int HNG64_MASTER_CLOCK = 50'000'000; /* TODO: NOT measured! */ - static constexpr int PIXEL_CLOCK = (HNG64_MASTER_CLOCK*2)/4; // x 2 is due to the interlaced screen ... + static constexpr int PIXEL_CLOCK = (HNG64_MASTER_CLOCK * 2) / 4; // x 2 is due to the interlaced screen ... - static constexpr int HTOTAL = 0x200+0x100; + static constexpr int HTOTAL = 0x200 + 0x100; static constexpr int HBEND = 0; static constexpr int HBSTART = 0x200; - static constexpr int VTOTAL = 264*2; + static constexpr int VTOTAL = 264 * 2; static constexpr int VBEND = 0; - static constexpr int VBSTART = 224*2; + static constexpr int VBSTART = 224 * 2; required_device<mips3_device> m_maincpu; required_device<v53a_device> m_audiocpu; @@ -227,79 +233,69 @@ private: required_device<cpu_device> m_comm; required_device<msm6242_device> m_rtc; - required_shared_ptr<uint32_t> m_mainram; - required_region_ptr<uint32_t> m_cart; - required_shared_ptr<uint32_t> m_sysregs; - required_region_ptr<uint32_t> m_rombase; - required_shared_ptr<uint32_t> m_spriteram; - required_shared_ptr<uint32_t> m_spriteregs; - required_shared_ptr<uint32_t> m_videoram; - required_shared_ptr<uint32_t> m_videoregs; - required_shared_ptr<uint32_t> m_tcram; - - std::unique_ptr<uint16_t[]> m_dl; - required_shared_ptr<uint32_t> m_comhack; - required_shared_ptr<uint32_t> m_fbram1; - required_shared_ptr<uint32_t> m_fbram2; - required_shared_ptr<uint32_t> m_fbscale; - required_shared_ptr<uint32_t> m_fbscroll; - required_shared_ptr<uint32_t> m_fbunk; - - required_shared_ptr<uint32_t> m_idt7133_dpram; - //required_shared_ptr<uint8_t> m_com_mmu_mem; + required_shared_ptr<u32> m_mainram; + required_region_ptr<u32> m_cart; + required_shared_ptr<u32> m_sysregs; + required_region_ptr<u32> m_rombase; + required_shared_ptr<u32> m_spriteram; + required_shared_ptr<u32> m_spriteregs; + required_shared_ptr<u32> m_videoram; + required_shared_ptr<u32> m_videoregs; + required_shared_ptr<u32> m_tcram; + + std::unique_ptr<u16[]> m_dl; + required_shared_ptr<u32> m_comhack; + required_shared_ptr<u32> m_fbram1; + required_shared_ptr<u32> m_fbram2; + required_shared_ptr<u32> m_fbscale; + required_shared_ptr<u32> m_fbscroll; + required_shared_ptr<u32> m_fbunk; + + required_shared_ptr<u32> m_idt7133_dpram; + //required_shared_ptr<u8> m_com_mmu_mem; required_memory_bank m_com_bank; + required_memory_bank_array<16> m_audio_bank; + required_device<gfxdecode_device> m_gfxdecode; required_ioport_array<8> m_in; - template <unsigned N> void hng64_default_lamps_w(uint8_t data) { logerror("lamps%u %02x\n", N, data); } - - void hng64_drive_lamps7_w(uint8_t data); - void hng64_drive_lamps6_w(uint8_t data); - void hng64_drive_lamps5_w(uint8_t data); - - void hng64_shoot_lamps7_w(uint8_t data); - void hng64_shoot_lamps6_w(uint8_t data); + bool m_samsho64_3d_hack = false; + bool m_roadedge_3d_hack = false; - void hng64_fight_lamps6_w(uint8_t data); + u8 m_fbcontrol[4]{}; + u8 m_texture_wrapsize_table[0x20]{}; - int m_samsho64_3d_hack; - int m_roadedge_3d_hack; - - uint8_t m_fbcontrol[4]{}; - uint8_t m_texture_wrapsize_table[0x20]; - - std::unique_ptr<uint16_t[]> m_soundram; - std::unique_ptr<uint16_t[]> m_soundram2; + std::unique_ptr<u16[]> m_soundram; + std::unique_ptr<u16[]> m_soundram2; /* Communications stuff */ - std::unique_ptr<uint8_t[]> m_com_op_base; - std::unique_ptr<uint8_t[]> m_com_virtual_mem; - uint8_t m_com_shared[8]{}; + std::unique_ptr<u8[]> m_com_op_base; + std::unique_ptr<u8[]> m_com_virtual_mem; + u8 m_com_shared[8]{}; - int32_t m_dma_start = 0; - int32_t m_dma_dst = 0; - int32_t m_dma_len = 0; + s32 m_dma_start = 0; + s32 m_dma_dst = 0; + s32 m_dma_len = 0; - uint16_t m_mcu_en = 0; + u16 m_mcu_en = 0; - uint32_t m_activeDisplayList = 0U; - uint32_t m_no_machine_error_code = 0U; + u32 m_activeDisplayList = 0U; + u32 m_no_machine_error_code = 0U; - uint32_t m_unk_vreg_toggle = 0U; - uint32_t m_p1_trig = 0U; - - //uint32_t *q2 = nullptr; + u32 m_unk_vreg_toggle = 0U; + u32 m_p1_trig = 0U; + //u32 *q2 = nullptr; bitmap_ind16 m_sprite_bitmap; bitmap_ind16 m_sprite_zbuffer; - uint8_t m_irq_pos_half; - uint32_t m_raster_irq_pos[2]; + u8 m_irq_pos_half; + u32 m_raster_irq_pos[2]; - uint8_t m_screen_dis = 0U; + u8 m_screen_dis = 0U; struct hng64_tilemap { tilemap_t *m_tilemap_8x8 = nullptr; @@ -309,17 +305,17 @@ private: hng64_tilemap m_tilemap[4]{}; - uint32_t m_old_animmask = 0U; - uint32_t m_old_animbits = 0U; - uint16_t m_old_tileflags[4]{}; + u32 m_old_animmask = 0U; + u32 m_old_animbits = 0U; + u16 m_old_tileflags[4]{}; // 3d State - uint16_t m_texturescrollx = 0; - uint16_t m_texturescrolly = 0; - uint16_t m_paletteState3d = 0; - uint16_t m_modelscalex = 0; - uint16_t m_modelscaley = 0; - uint16_t m_modelscalez = 0; + u16 m_texturescrollx = 0; + u16 m_texturescrolly = 0; + u16 m_paletteState3d = 0; + u16 m_modelscalex = 0; + u16 m_modelscaley = 0; + u16 m_modelscalez = 0; float m_projectionMatrix[16]{}; float m_modelViewMatrix[16]{}; @@ -328,212 +324,225 @@ private: float m_lightStrength = 0; float m_lightVector[3]{}; - uint32_t hng64_com_r(offs_t offset, uint32_t mem_mask = ~0); - void hng64_com_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void hng64_com_share_w(offs_t offset, uint8_t data); - uint8_t hng64_com_share_r(offs_t offset); - void hng64_com_bank_w(uint8_t data); - void hng64_com_share_mips_w(offs_t offset, uint8_t data); - uint8_t hng64_com_share_mips_r(offs_t offset); - uint32_t hng64_sysregs_r(offs_t offset, uint32_t mem_mask = ~0); - void hng64_sysregs_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t hng64_rtc_r(offs_t offset, uint32_t mem_mask = ~0); - void hng64_rtc_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t hng64_dmac_r(offs_t offset, uint32_t mem_mask = ~0); - void hng64_dmac_w(address_space &space, offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t hng64_irqc_r(offs_t offset, uint32_t mem_mask = ~0); - void hng64_irqc_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void hng64_mips_to_iomcu_irq_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void raster_irq_pos_w(uint32_t data); - - uint8_t hng64_dualport_r(offs_t offset); - void hng64_dualport_w(offs_t offset, uint8_t data); - - uint8_t hng64_fbcontrol_r(offs_t offset); - void hng64_fbcontrol_w(offs_t offset, uint8_t data); - - void hng64_fbscale_w(offs_t offset, uint32_t data, uint32_t mem_mask); - void hng64_fbscroll_w(offs_t offset, uint32_t data, uint32_t mem_mask); - - void hng64_fbunkbyte_w(offs_t offset, uint32_t data, uint32_t mem_mask); - - uint8_t hng64_texture_wrapsize_table_r(offs_t offset); - void hng64_texture_wrapsize_table_w(offs_t offset, uint8_t data); - - uint32_t hng64_fbram1_r(offs_t offset); - void hng64_fbram1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - - uint32_t hng64_fbram2_r(offs_t offset); - void hng64_fbram2_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - - void dl_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - //uint32_t dl_r(); - void dl_control_w(uint32_t data); - void dl_upload_w(uint32_t data); - void dl_unk_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t dl_vreg_r(); - - void set_palette_entry_with_faderegs(int entry, uint8_t r, uint8_t g, uint8_t b, uint32_t rgbfade, uint8_t r_mode, uint8_t g_mode, uint8_t b_mode, palette_device *palette); - void set_single_palette_entry(int entry, uint8_t r, uint8_t g, uint8_t b); + u8 m_port7 = 0; + u8 m_port1 = 0; + + u16 m_ex_ramaddr = 0; + u16 m_ex_ramaddr_upper = 0; + + emu_timer *m_tempio_irqon_timer = nullptr; + emu_timer *m_tempio_irqoff_timer = nullptr; + + u32 m_irq_pending = 0; + + emu_timer *m_comhack_timer = nullptr; + + u32 m_irq_level = 0; + std::unique_ptr<hng64_poly_renderer> m_poly_renderer; + + emu_timer *m_3dfifo_timer = nullptr; + + u16* m_vertsrom = nullptr; + u32 m_vertsrom_size = 0; + std::vector<polygon> m_polys; // HNG64_MAX_POLYGONS + + u16 main_latch[2]{}; + u16 sound_latch[2]{}; + + template <unsigned N> void default_lamps_w(u8 data) { logerror("lamps%u %02x\n", N, data); } + + void drive_lamps7_w(u8 data); + void drive_lamps6_w(u8 data); + void drive_lamps5_w(u8 data); + + void shoot_lamps7_w(u8 data); + void shoot_lamps6_w(u8 data); + + void fight_lamps6_w(u8 data); + + u32 com_r(offs_t offset, u32 mem_mask = ~0); + void com_w(offs_t offset, u32 data, u32 mem_mask = ~0); + void com_share_w(offs_t offset, u8 data); + u8 com_share_r(offs_t offset); + void com_bank_w(u8 data); + void com_share_mips_w(offs_t offset, u8 data); + u8 com_share_mips_r(offs_t offset); + u32 sysregs_r(offs_t offset, u32 mem_mask = ~0); + void sysregs_w(offs_t offset, u32 data, u32 mem_mask = ~0); + u32 rtc_r(offs_t offset, u32 mem_mask = ~0); + void rtc_w(offs_t offset, u32 data, u32 mem_mask = ~0); + u32 dmac_r(offs_t offset, u32 mem_mask = ~0); + void dmac_w(address_space &space, offs_t offset, u32 data, u32 mem_mask = ~0); + u32 irqc_r(offs_t offset, u32 mem_mask = ~0); + void irqc_w(offs_t offset, u32 data, u32 mem_mask = ~0); + void mips_to_iomcu_irq_w(offs_t offset, u32 data, u32 mem_mask = ~0); + void raster_irq_pos_w(u32 data); + + u8 dualport_r(offs_t offset); + void dualport_w(offs_t offset, u8 data); + + u8 fbcontrol_r(offs_t offset); + void fbcontrol_w(offs_t offset, u8 data); + + void fbscale_w(offs_t offset, u32 data, u32 mem_mask); + void fbscroll_w(offs_t offset, u32 data, u32 mem_mask); + + void fbunkbyte_w(offs_t offset, u32 data, u32 mem_mask); + + u8 texture_wrapsize_table_r(offs_t offset); + void texture_wrapsize_table_w(offs_t offset, u8 data); + + u32 fbram1_r(offs_t offset); + void fbram1_w(offs_t offset, u32 data, u32 mem_mask = ~0); + + u32 fbram2_r(offs_t offset); + void fbram2_w(offs_t offset, u32 data, u32 mem_mask = ~0); + + void dl_w(offs_t offset, u16 data, u16 mem_mask = ~0); + //u32 dl_r(); + void dl_control_w(u32 data); + void dl_upload_w(u32 data); + void dl_unk_w(offs_t offset, u32 data, u32 mem_mask = ~0); + u32 dl_vreg_r(); + + void set_palette_entry_with_faderegs(int entry, u8 r, u8 g, u8 b, u32 rgbfade, u8 r_mode, u8 g_mode, u8 b_mode, palette_device *palette); + void set_single_palette_entry(int entry, u8 r, u8 g, u8 b); void update_palette_entry(int entry); - void pal_w(offs_t offset, uint32_t data, uint32_t mem_mask); - void tcram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t tcram_r(offs_t offset); + void pal_w(offs_t offset, u32 data, u32 mem_mask); + void tcram_w(offs_t offset, u32 data, u32 mem_mask = ~0); + u32 tcram_r(offs_t offset); - void hng64_soundram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t hng64_soundram_r(offs_t offset); - void hng64_vregs_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void soundram_w(offs_t offset, u32 data, u32 mem_mask = ~0); + u32 soundram_r(offs_t offset); + void vregs_w(offs_t offset, u32 data, u32 mem_mask = ~0); // not actually used, but left in code so you can turn it and see the (possibly undesired?) behavior, see notes in memory map - void hng64_soundram2_w(uint32_t data); - uint32_t hng64_soundram2_r(); + void soundram2_w(u32 data); + u32 soundram2_r(); - void hng64_soundcpu_enable_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void soundcpu_enable_w(offs_t offset, u32 data, u32 mem_mask = ~0); - void hng64_sprite_clear_even_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void hng64_sprite_clear_odd_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void hng64_videoram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void sprite_clear_even_w(offs_t offset, u32 data, u32 mem_mask = ~0); + void sprite_clear_odd_w(offs_t offset, u32 data, u32 mem_mask = ~0); + void videoram_w(offs_t offset, u32 data, u32 mem_mask = ~0); // shared ram access - uint8_t ioport0_r(); - void ioport0_w(uint8_t data); - void ioport7_w(uint8_t data); + u8 ioport0_r(); + void ioport0_w(u8 data); + void ioport7_w(u8 data); // input port access - uint8_t ioport3_r(); - void ioport3_w(uint8_t data); - void ioport1_w(uint8_t data); + u8 ioport3_r(); + void ioport3_w(u8 data); + void ioport1_w(u8 data); // unknown access - void ioport4_w(uint8_t data); + void ioport4_w(u8 data); void sio0_w(int state); - uint8_t m_port7 = 0; - uint8_t m_port1 = 0; - - int m_ex_ramaddr = 0; - int m_ex_ramaddr_upper = 0; - TIMER_CALLBACK_MEMBER(tempio_irqon_callback); TIMER_CALLBACK_MEMBER(tempio_irqoff_callback); - emu_timer *m_tempio_irqon_timer = nullptr; - emu_timer *m_tempio_irqoff_timer = nullptr; void init_io(); - void init_hng64_reorder_gfx(); - - void set_irq(uint32_t irq_vector); - uint32_t m_irq_pending = 0; + void init_reorder_gfx(); + void set_irq(u32 irq_vector); TIMER_CALLBACK_MEMBER(comhack_callback); - emu_timer *m_comhack_timer = nullptr; - - - int m_irq_level = 0; - TILE_GET_INFO_MEMBER(get_hng64_tile0_8x8_info); - TILE_GET_INFO_MEMBER(get_hng64_tile0_16x16_info); - TILE_GET_INFO_MEMBER(get_hng64_tile1_8x8_info); - TILE_GET_INFO_MEMBER(get_hng64_tile1_16x16_info); - TILE_GET_INFO_MEMBER(get_hng64_tile2_8x8_info); - TILE_GET_INFO_MEMBER(get_hng64_tile2_16x16_info); - TILE_GET_INFO_MEMBER(get_hng64_tile3_8x8_info); - TILE_GET_INFO_MEMBER(get_hng64_tile3_16x16_info); - virtual void machine_start() override ATTR_COLD; - virtual void machine_reset() override ATTR_COLD; - virtual void video_start() override ATTR_COLD; - uint32_t screen_update_hng64(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - void screen_vblank_hng64(int state); + template <u8 Which, u8 Size> TILE_GET_INFO_MEMBER(get_tile_info); + u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void screen_vblank(int state); TIMER_DEVICE_CALLBACK_MEMBER(hng64_irq); void do_dma(address_space &space); - void hng64_mark_all_tiles_dirty(int tilemap); - void hng64_mark_tile_dirty(int tilemap, int tile_index); + void mark_all_tiles_dirty(int tilemap); + void mark_tile_dirty(int tilemap, int tile_index); - uint16_t get_tileregs(int tm); - uint16_t get_scrollbase(int tm); + u16 get_tileregs(int tm); + u16 get_scrollbase(int tm); int get_blend_mode(int tm); - void hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm, int flags, int line); - - void hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, - int wraparound, uint8_t drawformat, uint8_t alpha, uint8_t mosaic, uint8_t tm, int splitside); + void draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm, int flags, int line); - std::unique_ptr<hng64_poly_renderer> m_poly_renderer; - - TIMER_CALLBACK_MEMBER(hng64_3dfifo_processed); - emu_timer *m_3dfifo_timer = nullptr; - - uint16_t* m_vertsrom = nullptr; - int m_vertsrom_size = 0; - std::vector<polygon> m_polys; // HNG64_MAX_POLYGONS + void tilemap_draw_roz_core_line( + screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, + int wraparound, u8 drawformat, u8 alpha, u8 mosaic, u8 tm, int splitside); + TIMER_CALLBACK_MEMBER(_3dfifo_processed); void clear3d(); - bool hng64_command3d(const uint16_t* packet); + bool command3d(const u16* packet); - void mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, const rectangle& cliprect, uint16_t priority, int y); + void mixsprites_test(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, u16 priority, int y); - void get_tile_details(bool chain, uint16_t spritenum, uint8_t xtile, uint8_t ytile, uint8_t xsize, uint8_t ysize, bool xflip, bool yflip, uint32_t& tileno, uint16_t& pal, uint8_t &gfxregion); + void get_tile_details(bool chain, u16 spritenum, u8 xtile, u8 ytile, u8 xsize, u8 ysize, bool xflip, bool yflip, u32 &tileno, u16 &pal, u8 &gfxregion); void draw_sprites_buffer(screen_device &screen, const rectangle &cliprect); - void draw_sprite_line(screen_device& screen, const rectangle& cliprect, int32_t curyy, int16_t cury, int16_t xpos, int chainx, int32_t dx, int32_t dy, int ytileblock, int chaini, int currentsprite, int chainy, int xflip, int yflip, uint16_t zval, bool zsort, bool blend, uint16_t group, bool checkerboard, uint8_t mosaic); - - void drawline(bitmap_ind16& dest, bitmap_ind16& destz, const rectangle& cliprect, - gfx_element* gfx, uint32_t code, uint32_t color, int flipy, int32_t xpos, - int32_t dx, int32_t dy, uint32_t trans_pen, uint32_t zval, bool zrev, bool blend, bool checkerboard, uint8_t mosaic, uint8_t &mosaic_count_x, int32_t ypos, const u8* srcdata, int32_t srcx, uint32_t leftovers, int line, uint16_t &srcpix); - - void zoom_transpen(bitmap_ind16 &dest, bitmap_ind16 &destz, const rectangle &cliprect, - gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int32_t xpos, int32_t ypos, - int32_t dx, int32_t dy, uint32_t dstwidth, uint32_t trans_pen, uint32_t zval, bool zrev, bool blend, uint16_t group, bool checkerboard, uint8_t mosaic, uint8_t &mosaic_count_x, int line, uint16_t &srcpix); - - void setCameraTransformation(const uint16_t* packet); - void setLighting(const uint16_t* packet); - void set3dFlags(const uint16_t* packet); - void setCameraProjectionMatrix(const uint16_t* packet); - void recoverStandardVerts(polygon& currentPoly, int m, uint16_t* chunkOffset_verts, int& counter, const uint16_t *packet); - void recoverPolygonBlock(const uint16_t* packet, int& numPolys); - void printPacket(const uint16_t* packet, int hex); - float uToF(uint16_t input); + void draw_sprite_line( + screen_device &screen, const rectangle &cliprect, + s32 curyy, s16 cury, s16 xpos, int chainx, s32 dx, s32 dy, int ytileblock, int chaini, int currentsprite, int chainy, + int xflip, int yflip, u16 zval, bool zsort, bool blend, u16 group, bool checkerboard, u8 mosaic); + + void drawline( + bitmap_ind16 &dest, bitmap_ind16 &destz, const rectangle &cliprect, + gfx_element *gfx, u32 code, u32 color, + int flipy, s32 xpos, s32 dx, s32 dy, + u32 trans_pen, u32 zval, bool zrev, bool blend, bool checkerboard, u8 mosaic, u8 &mosaic_count_x, + s32 ypos, const u8 *srcdata, s32 srcx, u32 leftovers, int line, u16 &srcpix); + + void zoom_transpen( + bitmap_ind16 &dest, bitmap_ind16 &destz, const rectangle &cliprect, + gfx_element *gfx, u32 code, u32 color, + int flipx, int flipy, s32 xpos, s32 ypos, s32 dx, s32 dy, u32 dstwidth, + u32 trans_pen, u32 zval, bool zrev, bool blend, u16 group, bool checkerboard, u8 mosaic, u8 &mosaic_count_x, + int line, u16 &srcpix); + + void setCameraTransformation(const u16 *packet); + void setLighting(const u16 *packet); + void set3dFlags(const u16 *packet); + void setCameraProjectionMatrix(const u16 *packet); + void recoverStandardVerts(polygon ¤tPoly, int m, const u16 *chunkOffset_verts, int &counter, const u16 *packet); + void recoverPolygonBlock(const u16 *packet, int &numPolys); + void printPacket(const u16 *packet, int hex); + float uToF(u16 input); void matmul4(float *product, const float *a, const float *b); void vecmatmul4(float *product, const float *a, const float *b); float vecDotProduct(const float *a, const float *b); void setIdentity(float *matrix); void normalize(float* x); + void init_sound(); + void reset_sound(); void reset_net(); void dma_hreq_cb(int state); - uint8_t dma_memr_cb(offs_t offset); - void dma_iow3_cb(uint8_t data); + u8 dma_memr_cb(offs_t offset); + void dma_iow3_cb(u8 data); void tcu_tm0_cb(int state); void tcu_tm1_cb(int state); void tcu_tm2_cb(int state); + u16 sound_port_0008_r(offs_t offset, u16 mem_mask = ~0); + void sound_port_0008_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void sound_port_000a_w(offs_t offset, u16 data, u16 mem_mask = ~0); + void sound_port_000c_w(offs_t offset, u16 data, u16 mem_mask = ~0); - uint16_t hng64_sound_port_0008_r(offs_t offset, uint16_t mem_mask = ~0); - void hng64_sound_port_0008_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - - void hng64_sound_port_000a_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void hng64_sound_port_000c_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_port_0080_w(u16 data); - void hng64_sound_port_0080_w(uint16_t data); + void sound_bank_w(offs_t offset, u16 data); + u16 main_sound_comms_r(offs_t offset); + void main_sound_comms_w(offs_t offset, u16 data, u16 mem_mask = ~0); + u16 sound_comms_r(offs_t offset); + void sound_comms_w(offs_t offset, u16 data, u16 mem_mask = ~0); - void hng64_sound_bank_w(offs_t offset, uint16_t data); - uint16_t main_sound_comms_r(offs_t offset); - void main_sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t sound_comms_r(offs_t offset); - void sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t main_latch[2]{}; - uint16_t sound_latch[2]{}; - void hng64_audio(machine_config &config); - void hng64_network(machine_config &config); - void hng_comm_io_map(address_map &map) ATTR_COLD; - void hng_comm_map(address_map &map) ATTR_COLD; - void hng_map(address_map &map) ATTR_COLD; - void hng_sound_io(address_map &map) ATTR_COLD; - void hng_sound_map(address_map &map) ATTR_COLD; + void hng64_audio(machine_config &config) ATTR_COLD; + void hng64_network(machine_config &config) ATTR_COLD; + void comm_io_map(address_map &map) ATTR_COLD; + void comm_map(address_map &map) ATTR_COLD; + void main_map(address_map &map) ATTR_COLD; + void sound_io_map(address_map &map) ATTR_COLD; + void sound_map(address_map &map) ATTR_COLD; }; #endif // MAME_SNK_HNG64_H diff --git a/src/mame/snk/hng64_3d.ipp b/src/mame/snk/hng64_3d.ipp index 00a11105628..1ab4bf9467d 100644 --- a/src/mame/snk/hng64_3d.ipp +++ b/src/mame/snk/hng64_3d.ipp @@ -5,14 +5,28 @@ /// Hyper NeoGeo 64 - 3D bits /// ///////////////////////////////// +#define LOG_3D (1 << 1) +#define LOG_FRAMEBUFFER (1 << 2) +#define LOG_DISPLAY_LIST (1 << 3) +#define LOG_TEXTURE (1 << 4) + +#define VERBOSE (0) + +#include "logmacro.h" + +#define LOG3D(...) LOGMASKED(LOG_3D, __VA_ARGS__) +#define LOGFRAMEBUFFER(...) LOGMASKED(LOG_FRAMEBUFFER, __VA_ARGS__) +#define LOGDISPLAYLIST(...) LOGMASKED(LOG_DISPLAY_LIST, __VA_ARGS__) +#define LOGTEXTURE(...) LOGMASKED(LOG_TEXTURE, __VA_ARGS__) + // Polygon rasterizer interface hng64_poly_renderer::hng64_poly_renderer(hng64_state& state) : poly_manager<float, hng64_poly_data, 7>(state.machine()) , m_state(state) { - const int32_t bufferSize = 512 * 512; + const s32 bufferSize = 512 * 512; m_depthBuffer3d = std::make_unique<float[]>(bufferSize); - m_colorBuffer3d = std::make_unique<uint16_t[]>(bufferSize); + m_colorBuffer3d = std::make_unique<u16[]>(bufferSize); } @@ -31,38 +45,38 @@ hng64_poly_renderer::hng64_poly_renderer(hng64_state& state) 30140000-3015ffff is ZBuffer A (512x256 8-bit?) */ -uint32_t hng64_state::hng64_fbram1_r(offs_t offset) +u32 hng64_state::fbram1_r(offs_t offset) { return m_fbram1[offset]; } -void hng64_state::hng64_fbram1_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::fbram1_w(offs_t offset, u32 data, u32 mem_mask) { - COMBINE_DATA (&m_fbram1[offset]); + COMBINE_DATA(&m_fbram1[offset]); } -uint32_t hng64_state::hng64_fbram2_r(offs_t offset) +u32 hng64_state::fbram2_r(offs_t offset) { return m_fbram2[offset]; } -void hng64_state::hng64_fbram2_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::fbram2_w(offs_t offset, u32 data, u32 mem_mask) { - COMBINE_DATA (&m_fbram2[offset]); + COMBINE_DATA(&m_fbram2[offset]); } // The 3d 'display list' -void hng64_state::dl_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::dl_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_dl[offset]); } -void hng64_state::dl_unk_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::dl_unk_w(offs_t offset, u32 data, u32 mem_mask) { - logerror("%s: dl_unk_w %08x (%08x)\n", machine().describe_context(), data, mem_mask); + LOGDISPLAYLIST("%s: dl_unk_w %08x (%08x)\n", machine().describe_context(), data, mem_mask); } -void hng64_state::dl_upload_w(uint32_t data) +void hng64_state::dl_upload_w(u32 data) { //m_paletteState3d = 0; // no, breaks fatfurwa characters @@ -75,23 +89,23 @@ void hng64_state::dl_upload_w(uint32_t data) // We're assuming it to be a 'send to 3d hardware' trigger. // This can be called multiple times per frame (at least 2, as long as it gets the expected interrupt / status flags) auto profile = g_profiler.start(PROFILER_USER1); - for(int packetStart = 0; packetStart < 0x100; packetStart += 16) + for (int packetStart = 0; packetStart < 0x100; packetStart += 16) { // Send it off to the 3d subsystem. - if (!hng64_command3d(&m_dl[packetStart])) + if (!command3d(&m_dl[packetStart])) break; } // Schedule a small amount of time to let the 3d hardware rasterize the display buffer - m_3dfifo_timer->adjust(m_maincpu->cycles_to_attotime(0x200*8)); + m_3dfifo_timer->adjust(m_maincpu->cycles_to_attotime(0x200 * 8)); } -TIMER_CALLBACK_MEMBER(hng64_state::hng64_3dfifo_processed) +TIMER_CALLBACK_MEMBER(hng64_state::_3dfifo_processed) { set_irq(0x0008); } -void hng64_state::dl_control_w(uint32_t data) +void hng64_state::dl_control_w(u32 data) { /* m_activeDisplayList is not currently connected to anything, it seems unlikely there are different banks. games typically write up to 8 lots of 0x200 data, writing bit 0 between them @@ -109,16 +123,16 @@ void hng64_state::dl_control_w(uint32_t data) */ /* - logerror("dl_control_w %08x %08x\n", data, mem_mask); + LOGDISPLAYLIST("dl_control_w %08x %08x\n", data, mem_mask); - if(data & 2) // swap buffers + if (data & 2) // swap buffers { clear3d(); } */ } -uint32_t hng64_state::dl_vreg_r() +u32 hng64_state::dl_vreg_r() { /* tested with possible masked bits 0xf003 (often masking 0xf000 or 0x0003) @@ -135,11 +149,11 @@ uint32_t hng64_state::dl_vreg_r() // 3d 'Functions' // //////////////////// -void hng64_state::printPacket(const uint16_t* packet, int hex) +void hng64_state::printPacket(const u16* packet, int hex) { if (hex) { - logerror("Packet : %04x %04x 2:%04x %04x 4:%04x %04x 6:%04x %04x 8:%04x %04x 10:%04x %04x 12:%04x %04x 14:%04x %04x\n", + LOG3D("Packet : %04x %04x 2:%04x %04x 4:%04x %04x 6:%04x %04x 8:%04x %04x 10:%04x %04x 12:%04x %04x 14:%04x %04x\n", packet[0], packet[1], packet[2], packet[3], packet[4], packet[5], @@ -151,7 +165,7 @@ void hng64_state::printPacket(const uint16_t* packet, int hex) } else { - logerror("Packet : %04x %3.4f 2:%3.4f %3.4f 4:%3.4f %3.4f 6:%3.4f %3.4f 8:%3.4f %3.4f 10:%3.4f %3.4f 12:%3.4f %3.4f 14:%3.4f %3.4f\n", + LOG3D("Packet : %04x %3.4f 2:%3.4f %3.4f 4:%3.4f %3.4f 6:%3.4f %3.4f 8:%3.4f %3.4f 10:%3.4f %3.4f 12:%3.4f %3.4f 14:%3.4f %3.4f\n", packet[0], uToF(packet[1] )*128, uToF(packet[2] )*128, uToF(packet[3] )*128, uToF(packet[4] )*128, uToF(packet[5] )*128, @@ -165,7 +179,7 @@ void hng64_state::printPacket(const uint16_t* packet, int hex) // Operation 0001 // Camera transformation. -void hng64_state::setCameraTransformation(const uint16_t* packet) +void hng64_state::setCameraTransformation(const u16* packet) { /*////////////// // PACKET FORMAT @@ -211,7 +225,7 @@ void hng64_state::setCameraTransformation(const uint16_t* packet) // Operation 0010 // Lighting information -void hng64_state::setLighting(const uint16_t* packet) +void hng64_state::setLighting(const u16* packet) { /*////////////// // PACKET FORMAT @@ -233,8 +247,8 @@ void hng64_state::setLighting(const uint16_t* packet) // [14] - ???? ... ? Used in fatfurwa // [15] - ???? ... ? Used in fatfurwa ////////////*/ - if (packet[1] != 0x0000) logerror("packet[1] in setLighting function is non-zero!\n"); - if (packet[2] != 0x0000) logerror("packet[2] in setLighting function is non-zero!\n"); + if (packet[1] != 0x0000) LOG3D("packet[1] in setLighting function is non-zero!\n"); + if (packet[2] != 0x0000) LOG3D("packet[2] in setLighting function is non-zero!\n"); m_lightVector[0] = uToF(packet[3]); m_lightVector[1] = uToF(packet[4]); @@ -244,7 +258,7 @@ void hng64_state::setLighting(const uint16_t* packet) // Operation 0011 // Palette / Model flags? -void hng64_state::set3dFlags(const uint16_t* packet) +void hng64_state::set3dFlags(const u16* packet) { /*////////////// // PACKET FORMAT @@ -277,7 +291,7 @@ void hng64_state::set3dFlags(const uint16_t* packet) // Operation 0012 // Projection Matrix. -void hng64_state::setCameraProjectionMatrix(const uint16_t* packet) +void hng64_state::setCameraProjectionMatrix(const u16* packet) { /*////////////// // PACKET FORMAT @@ -352,7 +366,7 @@ void hng64_state::setCameraProjectionMatrix(const uint16_t* packet) #endif } -void hng64_state::recoverStandardVerts(polygon& currentPoly, int m, uint16_t* chunkOffset_verts, int& counter, const uint16_t* packet) +void hng64_state::recoverStandardVerts(polygon& currentPoly, int m, const u16* chunkOffset_verts, int& counter, const u16* packet) { currentPoly.vert[m].worldCoords[0] = uToF(chunkOffset_verts[counter++]); currentPoly.vert[m].worldCoords[1] = uToF(chunkOffset_verts[counter++]); @@ -361,7 +375,7 @@ void hng64_state::recoverStandardVerts(polygon& currentPoly, int m, uint16_t* ch currentPoly.n = 3; // this seems to be some kind of default lighting value / brightness, probably for unlit polys? used in various places, eg side of house in ice stage of ss64, some shadows - [[maybe_unused]] uint16_t maybe_blend = chunkOffset_verts[counter++]; + [[maybe_unused]] u16 maybe_blend = chunkOffset_verts[counter++]; currentPoly.vert[m].texCoords[0] = uToF(chunkOffset_verts[counter]); if (currentPoly.flatShade) @@ -369,7 +383,6 @@ void hng64_state::recoverStandardVerts(polygon& currentPoly, int m, uint16_t* ch counter++; currentPoly.vert[m].texCoords[1] = uToF(chunkOffset_verts[counter++]); - // set on the Hyper 64 logos for roadedge and xrally which are known to be scaled // also set on the car select screen in roadedge, and the car on the stage name screen // not set anywhere else? @@ -386,13 +399,13 @@ void hng64_state::recoverStandardVerts(polygon& currentPoly, int m, uint16_t* ch currentPoly.vert[m].worldCoords[2] = (currentPoly.vert[m].worldCoords[2] * m_modelscalex) / 0x100; // if ((m_modelscalex != 0x100) || (m_modelscaley != 0x100) || (m_modelscalez != 0x100)) - // logerror("maybe using model scale %04x %04x %04x\n", m_modelscalex, m_modelscaley, m_modelscalez); + // LOG3D("maybe using model scale %04x %04x %04x\n", m_modelscalex, m_modelscaley, m_modelscalez); } } // Operation 0100 // Polygon rasterization. -void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) +void hng64_state::recoverPolygonBlock(const u16* packet, int& numPolys) { //printPacket(packet, 1); @@ -454,9 +467,9 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) objectMatrix[14] = uToF(packet[6]); objectMatrix[15] = 1.0f; - uint32_t size[4]; - uint32_t address[4]; - uint32_t megaOffset; + u32 size[4]; + u32 address[4]; + u32 megaOffset; polygon lastPoly = { 0 }; @@ -489,9 +502,9 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) //////////////////////////////////////////////*/ // 3d ROM Offset - uint16_t* threeDRoms = m_vertsrom; - uint32_t threeDOffset = (((uint32_t)packet[2]) << 16) | ((uint32_t)packet[3]); - uint16_t* threeDPointer = &threeDRoms[threeDOffset * 3]; + const u16 *threeDRoms = m_vertsrom; + const u32 threeDOffset = (((u32)packet[2]) << 16) | ((u32)packet[3]); + const u16 *const threeDPointer = &threeDRoms[threeDOffset * 3]; if (threeDOffset >= m_vertsrom_size) { @@ -499,7 +512,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) if ((packet[2] == 0x2347) && (packet[3] == 0x5056)) return; - logerror("Strange geometry packet: (ignoring)\n"); + LOG3D("Strange geometry packet: (ignoring)\n"); printPacket(packet, 1); return; } @@ -522,29 +535,29 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) address[2] = threeDPointer[3]; address[3] = threeDPointer[4]; - if (threeDPointer[5] != 0x0000) logerror("3dPointer[5] is non-zero!\n"); + if (threeDPointer[5] != 0x0000) LOG3D("3dPointer[5] is non-zero!\n"); size[0] = threeDPointer[6]; size[1] = threeDPointer[7]; - if (threeDPointer[8] != 0x0000) logerror("3dPointer[8] is non-zero!\n"); + if (threeDPointer[8] != 0x0000) LOG3D("3dPointer[8] is non-zero!\n"); size[2] = threeDPointer[9]; size[3] = threeDPointer[10]; // the low 8-bits of each of these is used (or at least contains data, probably one byte for each hunk?) - //if (threeDPointer[11] != 0x0000) logerror("3dPointer[11] is %04x!\n", threeDPointer[11]); // ???? [11]; Used. - //if (threeDPointer[12] != 0x0000) logerror("3dPointer[12] is %04x!\n", threeDPointer[12]); // ???? [12]; Used. - //if (threeDPointer[13] != 0x0000) logerror("3dPointer[13] is %04x!\n", threeDPointer[13]); // ???? [13]; Used. - //if (threeDPointer[14] != 0x0000) logerror("3dPointer[14] is %04x!\n", threeDPointer[14]); // ???? [14]; Used. + //if (threeDPointer[11] != 0x0000) LOG3D("3dPointer[11] is %04x!\n", threeDPointer[11]); // ???? [11]; Used. + //if (threeDPointer[12] != 0x0000) LOG3D("3dPointer[12] is %04x!\n", threeDPointer[12]); // ???? [12]; Used. + //if (threeDPointer[13] != 0x0000) LOG3D("3dPointer[13] is %04x!\n", threeDPointer[13]); // ???? [13]; Used. + //if (threeDPointer[14] != 0x0000) LOG3D("3dPointer[14] is %04x!\n", threeDPointer[14]); // ???? [14]; Used. - if (threeDPointer[15] != 0x0000) logerror("3dPointer[15] is non-zero!\n"); - if (threeDPointer[16] != 0x0000) logerror("3dPointer[16] is non-zero!\n"); - if (threeDPointer[17] != 0x0000) logerror("3dPointer[17] is non-zero!\n"); + if (threeDPointer[15] != 0x0000) LOG3D("3dPointer[15] is non-zero!\n"); + if (threeDPointer[16] != 0x0000) LOG3D("3dPointer[16] is non-zero!\n"); + if (threeDPointer[17] != 0x0000) LOG3D("3dPointer[17] is non-zero!\n"); - if (threeDPointer[18] != 0x0000) logerror("3dPointer[18] is non-zero!\n"); - if (threeDPointer[19] != 0x0000) logerror("3dPointer[19] is non-zero!\n"); - if (threeDPointer[20] != 0x0000) logerror("3dPointer[20] is non-zero!\n"); + if (threeDPointer[18] != 0x0000) LOG3D("3dPointer[18] is non-zero!\n"); + if (threeDPointer[19] != 0x0000) LOG3D("3dPointer[19] is non-zero!\n"); + if (threeDPointer[20] != 0x0000) LOG3D("3dPointer[20] is non-zero!\n"); // Concatenate the megaOffset with the addresses address[0] |= (megaOffset << 16); @@ -555,7 +568,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) // For all 4 polygon chunks for (int k = 0; k < 4; k++) { - uint16_t* chunkOffset = &threeDRoms[address[k] * 3]; + const u16 *chunkOffset = &threeDRoms[address[k] * 3]; for (int l = 0; l < size[k]; l++) { //////////////////////////////////////////// @@ -578,12 +591,12 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) // 'Welcome to South Africa' roadside banner on xrally | 000e 8c0d d870 or 0096 8c0d d870 (8c0d, d870 seems key 1000 1100 0000 1101 // 1101 1000 0111 0000 ) - uint8_t chunkType = chunkOffset[0] & 0x00ff; + u8 chunkType = chunkOffset[0] & 0x00ff; // Debug - ajg if (chunkOffset[0] & 0xff00) { - logerror("Weird! The top byte of the chunkType has a value %04x!\n", chunkOffset[0]); + LOG3D("Weird! The top byte of the chunkType has a value %04x!\n", chunkOffset[0]); continue; } @@ -591,7 +604,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) polygon& currentPoly = m_polys[numPolys]; // Debug - ajg - //logerror("%d (%08x) : %04x %04x %04x\n", k, address[k]*3*2, chunkOffset[0], chunkOffset[1], chunkOffset[2]); + //LOG3D("%d (%08x) : %04x %04x %04x\n", k, address[k]*3*2, chunkOffset[0], chunkOffset[1], chunkOffset[2]); //break; if (chunkOffset[1] & 0x1000) currentPoly.tex4bpp = 0x1; @@ -615,8 +628,8 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) // PALETTE currentPoly.palOffset = 0; - //uint16_t explicitPaletteValue0 = ((chunkOffset[?] & 0x????) >> ?) * 0x800; - uint16_t explicitPaletteValue = ((chunkOffset[1] & 0x0ff0) >> 4); + //u16 explicitPaletteValue0 = ((chunkOffset[?] & 0x????) >> ?) * 0x800; + u16 explicitPaletteValue = ((chunkOffset[1] & 0x0ff0) >> 4); explicitPaletteValue = explicitPaletteValue << 3; // HACK: this is not the enable, the cars in roadedge rely on this to switch palettes @@ -665,9 +678,9 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) currentPoly.texscrolly = 0; } - uint8_t chunkLength = 0; + u8 chunkLength = 0; int counter = 3; - switch(chunkType) + switch (chunkType) { /*///////////////////////// // CHUNK TYPE BITS - These are very likely incorrect. @@ -784,7 +797,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) currentPoly.faceNormal[3] = lastPoly.faceNormal[3]; // TODO: I'm not reading 3 necessary words here (maybe face normal) - [[maybe_unused]] uint16_t unused; + [[maybe_unused]] u16 unused; unused = chunkOffset[counter++]; unused = chunkOffset[counter++]; unused = chunkOffset[counter++]; @@ -793,7 +806,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) break; } default: - logerror("UNKNOWN geometry CHUNK TYPE : %02x\n", chunkType); + LOG3D("UNKNOWN geometry CHUNK TYPE : %02x\n", chunkType); chunkLength = counter; break; } @@ -906,7 +919,7 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) if (currentPoly.visible) { // Clip against all edges of the view frustum - int num_vertices = frustum_clip_all<float, 5>(clipVerts, currentPoly.n, clipVerts); + const int num_vertices = frustum_clip_all<float, 5>(clipVerts, currentPoly.n, clipVerts); // Copy the results of currentPoly.n = num_vertices; @@ -958,11 +971,11 @@ void hng64_state::recoverPolygonBlock(const uint16_t* packet, int& numPolys) } -bool hng64_state::hng64_command3d(const uint16_t* packet) +bool hng64_state::command3d(const u16* packet) { int numPolys = 0; - //logerror("packet type : %04x %04x|%04x %04x|%04x %04x|%04x %04x | %04x %04x %04x %04x %04x %04x %04x %04x\n", packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7], packet[8], packet[9], packet[10], packet[11], packet[12], packet[13], packet[14], packet[15]); + //LOG3D("packet type : %04x %04x|%04x %04x|%04x %04x|%04x %04x | %04x %04x %04x %04x %04x %04x %04x %04x\n", packet[0],packet[1],packet[2],packet[3],packet[4],packet[5],packet[6],packet[7], packet[8], packet[9], packet[10], packet[11], packet[12], packet[13], packet[14], packet[15]); switch (packet[0]) { @@ -998,8 +1011,8 @@ bool hng64_state::hng64_command3d(const uint16_t* packet) case 0x0102: // Geometry with only translation // 'world' in roadedge/xrally (track, trackside objects etc.) // Split the packet and call recoverPolygonBlock on each half. - uint16_t miniPacket[16]; - memset(miniPacket, 0, sizeof(uint16_t)*16); + u16 miniPacket[16]; + memset(miniPacket, 0, sizeof(u16)*16); for (int i = 0; i < 7; i++) miniPacket[i] = packet[i]; miniPacket[7] = 0x7fff; miniPacket[11] = 0x7fff; @@ -1010,7 +1023,7 @@ bool hng64_state::hng64_command3d(const uint16_t* packet) { if (packet[8] == 0x0102) { - memset(miniPacket, 0, sizeof(uint16_t) * 16); + memset(miniPacket, 0, sizeof(u16) * 16); for (int i = 0; i < 7; i++) miniPacket[i] = packet[i + 8]; miniPacket[7] = 0x7fff; miniPacket[11] = 0x7fff; @@ -1030,7 +1043,7 @@ bool hng64_state::hng64_command3d(const uint16_t* packet) break; case 0x1000: // Unknown: Some sort of global flags? - //printPacket(packet, 1); logerror("\n"); + //printPacket(packet, 1); LOG3D("\n"); break; case 0x1001: // Unknown: Some sort of global flags? Almost always comes in a group of 4 with an index [0,3]. @@ -1038,7 +1051,7 @@ bool hng64_state::hng64_command3d(const uint16_t* packet) break; default: - logerror("HNG64: Unknown 3d command %04x.\n", packet[0]); + LOG3D("HNG64: Unknown 3d command %04x.\n", packet[0]); break; } @@ -1064,8 +1077,6 @@ void hng64_state::clear3d() m_poly_renderer->colorBuffer3d()[i] = 0; } - - m_paletteState3d = 0; // Set some matrices to the identity... @@ -1086,25 +1097,25 @@ void hng64_state::clear3d() * 3 | ---- ---- | */ -uint8_t hng64_state::hng64_fbcontrol_r(offs_t offset) +u8 hng64_state::fbcontrol_r(offs_t offset) { - logerror("%s: hng64_fbcontrol_r (%03x)\n", machine().describe_context(), offset); + LOGFRAMEBUFFER("%s: fbcontrol_r (%03x)\n", machine().describe_context(), offset); return m_fbcontrol[offset]; } -void hng64_state::hng64_fbcontrol_w(offs_t offset, uint8_t data) +void hng64_state::fbcontrol_w(offs_t offset, u8 data) { /* roadedge does the following to turn off the framebuffer clear (leave trails) and then turn it back on when selecting a car - ':maincpu' (8001EDE0): hng64_fbcontrol_w (002) 10 (disable frame buffer clear) - ':maincpu' (8001FE4C): hng64_fbcontrol_w (002) 38 (normal) + ':maincpu' (8001EDE0): fbcontrol_w (002) 10 (disable frame buffer clear) + ':maincpu' (8001FE4C): fbcontrol_w (002) 38 (normal) during the Hyper Neogeo 64 logo it has a value of - ':maincpu' (8005AA44): hng64_fbcontrol_w (002) 18 + ':maincpu' (8005AA44): fbcontrol_w (002) 18 sams64 does - ':maincpu' (800C13C4): hng64_fbcontrol_r (002) (ANDs with 0x07, ORs with 0x18) - ':maincpu' (800C13D0): hng64_fbcontrol_w (002) 18 + ':maincpu' (800C13C4): fbcontrol_r (002) (ANDs with 0x07, ORs with 0x18) + ':maincpu' (800C13D0): fbcontrol_w (002) 18 other games use either mix of 0x18 and 0x38. bit 0x08 must prevent the framebuffer clear tho according to above table bit 0x20 is color base, but implementation for it is a hack @@ -1115,44 +1126,44 @@ void hng64_state::hng64_fbcontrol_w(offs_t offset, uint8_t data) */ - logerror("%s: hng64_fbcontrol_w (%03x) %02x\n", machine().describe_context(), offset, data); + LOGFRAMEBUFFER("%s: fbcontrol_w (%03x) %02x\n", machine().describe_context(), offset, data); m_fbcontrol[offset] = data; } // the framebuffer scroll and scale registers are used in fatfurwa (intro scaling) and xrally (course select, car select) // they are NOT used for buriki 'how to play' scren, which uses unhandled values in the 3d packets to reposition the fighters instead -void hng64_state::hng64_fbscale_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::fbscale_w(offs_t offset, u32 data, u32 mem_mask) { COMBINE_DATA(&m_fbscale[offset]); if (mem_mask & 0xffff0000) { // NORMAL value is 3fe0 (0x400 / 2 = 0x200 = 512) - // ':maincpu' (8006E46C): hng64_fb_scale_x 3fe00000 ffff0000 + // ':maincpu' (8006E46C): fb_scale_x 3fe00000 ffff0000 // on xrally course select this is 39e0 (0x3a0 / 2 = 0x1d0 = 464) - // hng64_fb_scale_x 39e00000 ffff0000 + // fb_scale_x 39e00000 ffff0000 - //logerror("%s: hng64_fb_scale_x %08x %08x\n", machine().describe_context(), data, mem_mask); + //LOGFRAMEBUFFER("%s: fb_scale_x %08x %08x\n", machine().describe_context(), data, mem_mask); } if (mem_mask & 0x0000ffff) { // NORMAL value is 37e0 (0x380 / 2 = 0x1c0 = 448) - // hng64_fb_scale_y 000037e0 0000ffff + // fb_scale_y 000037e0 0000ffff // on xrally course select this is 32e0 (0x330 / 2 = 408) - // hng64_fb_scale_y 000032e0 0000ffff + // fb_scale_y 000032e0 0000ffff // during fatfurwa scaled intro it uses 2de0, although writes 37e0 in the same frame; presumably rendering takes place while it is 2de0 though // 0x2e0 / 2 = 0x170 = 368 (needs to be ~287 pixels though) - // ':maincpu' (800667A0): hng64_fb_scale_y 00002de0 0000ffff - //logerror("%s: hng64_fb_scale_y %08x %08x\n", machine().describe_context(), data, mem_mask); + // ':maincpu' (800667A0): fb_scale_y 00002de0 0000ffff + //LOGFRAMEBUFFER("%s: fb_scale_y %08x %08x\n", machine().describe_context(), data, mem_mask); } } -void hng64_state::hng64_fbscroll_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::fbscroll_w(offs_t offset, u32 data, u32 mem_mask) { COMBINE_DATA(&m_fbscroll[offset]); @@ -1160,32 +1171,32 @@ void hng64_state::hng64_fbscroll_w(offs_t offset, uint32_t data, uint32_t mem_ma if (mem_mask & 0xffff0000) { // NORMAL value is e000 (e0 = 224) - // hng64_fbscroll x e0000000 ffff0000 + // fbscroll x e0000000 ffff0000 // on xrally course select this is e600 (+0600 from normal) - // ':maincpu' (8002327C): hng64_fbscroll x e6000000 ffff0000 + // ':maincpu' (8002327C): fbscroll x e6000000 ffff0000 // on xrally car select this is e680 - // hng64_fbscroll x e6800000 ffff0000 - //logerror("%s: hng64_fbscroll x %08x (%d) %08x\n", machine().describe_context(), data, ((data&0x7fff0000) >> 21), mem_mask); + // fbscroll x e6800000 ffff0000 + //LOGFRAMEBUFFER("%s: fbscroll x %08x (%d) %08x\n", machine().describe_context(), data, ((data&0x7fff0000) >> 21), mem_mask); } if (mem_mask & 0x0000ffff) { // NORMAL value is 1c00 (1c0 = 448) /2 = 224 (midpoint y?) - // ':maincpu' (8006FA18): hng64_fbscroll y 00001c00 0000ffff + // ':maincpu' (8006FA18): fbscroll y 00001c00 0000ffff // on xrally course select this is 1700 (0x170 = 368) - // ':maincpu' (8002327C): hng64_fbscroll y 00001700 0000ffff (-0500 from normal) + // ':maincpu' (8002327C): fbscroll y 00001700 0000ffff (-0500 from normal) // on xrally car select this is 1260 (and needs to be higher up) - // ':maincpu' (80012820): hng64_fbscroll y 00001260 0000ffff + // ':maincpu' (80012820): fbscroll y 00001260 0000ffff // 00001a60 on screen after, not quite as high up, but higher than 1c00 - //logerror("%s: hng64_fbscroll y %08x (%d) %08x\n", machine().describe_context(), data, (data >> 5), mem_mask); + //LOGFRAMEBUFFER("%s: fbscroll y %08x (%d) %08x\n", machine().describe_context(), data, (data >> 5), mem_mask); } } -void hng64_state::hng64_fbunkbyte_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::fbunkbyte_w(offs_t offset, u32 data, u32 mem_mask) { COMBINE_DATA(&m_fbunk[offset]); @@ -1193,7 +1204,7 @@ void hng64_state::hng64_fbunkbyte_w(offs_t offset, uint32_t data, uint32_t mem_m // is 02 in most games, 03 in samsh4 games // could be related to how fbscrolly is applied? - logerror("%s: hng64_unkbyte_w %08x %08x\n", machine().describe_context(), data, mem_mask); + LOGFRAMEBUFFER("%s: fbunkbyte_w %08x %08x\n", machine().describe_context(), data, mem_mask); } /* @@ -1215,15 +1226,16 @@ sams64_2 00000000 00000000 00000000 00000000 00000000 07070000 00000000 0000000 these values are used in the rendering, to control the size at which a texture wraps on each of the texture pages. */ -uint8_t hng64_state::hng64_texture_wrapsize_table_r(offs_t offset) +u8 hng64_state::texture_wrapsize_table_r(offs_t offset) { - logerror("%s: hng64_texture_wrapsize_table_r (%03x)\n", machine().describe_context(), offset * 4); + if (!machine().side_effects_disabled()) + LOGTEXTURE("%s: texture_wrapsize_table_r (%03x)\n", machine().describe_context(), offset * 4); return m_texture_wrapsize_table[offset]; } -void hng64_state::hng64_texture_wrapsize_table_w(offs_t offset, uint8_t data) +void hng64_state::texture_wrapsize_table_w(offs_t offset, u8 data) { - logerror("%s: hng64_texture_wrapsize_table_w (%03x) %08x\n", machine().describe_context(), offset * 4, data); + LOGTEXTURE("%s: texture_wrapsize_table_w (%03x) %08x\n", machine().describe_context(), offset * 4, data); m_texture_wrapsize_table[offset] = data; #if 0 @@ -1275,7 +1287,7 @@ void hng64_state::vecmatmul4(float *product, const float *a, const float *b) float hng64_state::vecDotProduct(const float *a, const float *b) { - return ((a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2])); + return ((a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2])); } void hng64_state::setIdentity(float *matrix) @@ -1288,24 +1300,24 @@ void hng64_state::setIdentity(float *matrix) matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0f; } -float hng64_state::uToF(uint16_t input) +float hng64_state::uToF(u16 input) { float retVal; - retVal = float(int16_t(input)) / 32768.0f; + retVal = float(s16(input)) / 32768.0f; return retVal; #if 0 - if (int16_t(input) < 0) - retVal = float(int16_t(input)) / 32768.0f; + if (s16(input) < 0) + retVal = float(s16(input)) / 32768.0f; else - retVal = float(int16_t(input)) / 32767.0f; + retVal = float(s16(input)) / 32767.0f; #endif } void hng64_state::normalize(float* x) { - double l2 = (x[0]*x[0]) + (x[1]*x[1]) + (x[2]*x[2]); - double l = sqrt(l2); + const double l2 = (x[0] * x[0]) + (x[1] * x[1]) + (x[2] * x[2]); + const double l = sqrt(l2); x[0] = float(x[0] / l); x[1] = float(x[1] / l); @@ -1317,7 +1329,7 @@ void hng64_state::normalize(float* x) // POLYGON RASTERIZATION CODE // //////////////////////////////// -void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid) +void hng64_poly_renderer::render_texture_scanline(s32 scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid) { if ((scanline > 511) | (scanline < 0)) return; @@ -1336,13 +1348,13 @@ void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent const float dt = extent.param[6].dpdx; // Pointers to the pixel buffers - uint16_t* colorBuffer = &m_colorBuffer3d[(scanline * 512)]; - float* depthBuffer = &m_depthBuffer3d[(scanline * 512)]; + u16* colorBuffer = &m_colorBuffer3d[(scanline * 512)]; + float* depthBuffer = &m_depthBuffer3d[(scanline * 512)]; - const uint8_t *textureOffset = &m_state.m_texturerom[renderData.texIndex * 1024 * 1024]; + const u8 *textureOffset = &m_state.m_texturerom[renderData.texIndex * 1024 * 1024]; // Step over each pixel in the horizontal span - for(int x = extent.startx; x < extent.stopx; x++) + for (int x = extent.startx; x < extent.stopx; x++) { if (z < depthBuffer[x & 511]) { @@ -1363,10 +1375,9 @@ void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent textureS += (renderData.texscrolly & 0x3fff)>>5; textureT += (renderData.texscrollx & 0x3fff)>>5; - - int textPageSub = (renderData.texPageSmall & 0xc000) >> 14; - int texPageHorizOffset = (renderData.texPageSmall & 0x3f80) >> 7; - int texPageVertOffset = (renderData.texPageSmall & 0x007f) >> 0; + const int textPageSub = (renderData.texPageSmall & 0xc000) >> 14; + const int texPageHorizOffset = (renderData.texPageSmall & 0x3f80) >> 7; + const int texPageVertOffset = (renderData.texPageSmall & 0x007f) >> 0; // Small-Page textures // what is textPageSub & 1 used for? seems to be enabled on almost everything? it does not control wrap enable? @@ -1376,12 +1387,12 @@ void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent textureS = fmod(textureS, (float)renderData.tex_mask_y); textureS += (8.0f * texPageVertOffset); } - uint8_t paletteEntry; + u8 paletteEntry; int t = (int)textureT; int s = (int)textureS; t &= 1023; - s &= 1023; // 4bpp pages seem to be limited to 1024 pixels, with page numbering being the same, the bottom 1024 pixels of 4bpp pages are unsed? + s &= 1023; // 4bpp pages seem to be limited to 1024 pixels, with page numbering being the same, the bottom 1024 pixels of 4bpp pages are unused? if (renderData.tex4bpp) { @@ -1401,8 +1412,8 @@ void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent if (paletteEntry != 0) { float rIntensity = rCorrect / 16.0f; - uint8_t lightval = (uint8_t)rIntensity; - uint16_t color = ((renderData.palOffset + paletteEntry) & 0x7ff) | (lightval << 12); + u8 lightval = (u8)rIntensity; + u16 color = ((renderData.palOffset + paletteEntry) & 0x7ff) | (lightval << 12); if (renderData.blend) color |= 0x800; @@ -1420,7 +1431,7 @@ void hng64_poly_renderer::render_texture_scanline(int32_t scanline, const extent } } -void hng64_poly_renderer::render_flat_scanline(int32_t scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid) +void hng64_poly_renderer::render_flat_scanline(s32 scanline, const extent_t& extent, const hng64_poly_data& renderData, int threadid) { if ((scanline > 511) | (scanline < 0)) return; @@ -1430,11 +1441,11 @@ void hng64_poly_renderer::render_flat_scanline(int32_t scanline, const extent_t& const float dz = extent.param[0].dpdx; // Pointers to the pixel buffers - float* depthBuffer = &m_depthBuffer3d[(scanline * 512)]; - uint16_t* colorBuffer = &m_colorBuffer3d[(scanline * 512)]; + float* depthBuffer = &m_depthBuffer3d[(scanline * 512)]; + u16* colorBuffer = &m_colorBuffer3d[(scanline * 512)]; // Step over each pixel in the horizontal span - for(int x = extent.startx; x < extent.stopx; x++) + for (int x = extent.startx; x < extent.stopx; x++) { if (z < depthBuffer[x & 511]) { @@ -1468,7 +1479,6 @@ void hng64_poly_renderer::drawShaded(polygon *p) rectangle visibleArea; visibleArea.set(0, 512, 0, 512); - if (p->flatShade) { // Rasterize the triangles diff --git a/src/mame/snk/hng64_a.cpp b/src/mame/snk/hng64_a.cpp index 5952fa5cee8..a3fd6d98818 100644 --- a/src/mame/snk/hng64_a.cpp +++ b/src/mame/snk/hng64_a.cpp @@ -43,6 +43,13 @@ so levels 0,1,2,5 are unmasked, vectors get set during the sound CPU init code. #include "hng64.h" #include "speaker.h" +#define LOG_SOUND (1 << 1) + +#define VERBOSE (0) + +#include "logmacro.h" + +#define LOGSOUND(...) LOGMASKED(LOG_SOUND, __VA_ARGS__) // save the sound program? #define DUMP_SOUNDPRG 0 @@ -54,22 +61,22 @@ so levels 0,1,2,5 are unmasked, vectors get set during the sound CPU init code. // if you actually map RAM here on the MIPS side then xrally will upload the actual sound program here and blank out the area where // the program would usually be uploaded (and where all other games upload it) this seems to suggest that the area is unmapped on // real hardware. -void hng64_state::hng64_soundram2_w(uint32_t data) +void hng64_state::soundram2_w(u32 data) { } -uint32_t hng64_state::hng64_soundram2_r() +u32 hng64_state::soundram2_r() { return 0x0000; } -void hng64_state::hng64_soundram_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::soundram_w(offs_t offset, u32 data, u32 mem_mask) { - //logerror("hng64_soundram_w %08x: %08x %08x\n", offset, data, mem_mask); + LOGSOUND("%s: soundram_w %08x: %08x %08x\n", machine().describe_context(), offset, data, mem_mask); - uint32_t mem_mask32 = mem_mask; - uint32_t data32 = data; + const u32 mem_mask32 = mem_mask; + const u32 data32 = data; /* swap data around.. keep the v53 happy */ data = data32 >> 16; @@ -86,14 +93,14 @@ void hng64_state::hng64_soundram_w(offs_t offset, uint32_t data, uint32_t mem_ma if (DUMP_SOUNDPRG) { - if (offset==0x7ffff) + if (offset == 0x7ffff) { - logerror("dumping sound program in m_soundram\n"); + LOGSOUND("dumping sound program in m_soundram\n"); auto filename = "soundram_" + std::string(machine().system().name); auto fp = fopen(filename.c_str(), "w+b"); if (fp) { - fwrite((uint8_t*)m_soundram.get(), 0x80000*4, 1, fp); + fwrite((u8*)m_soundram.get(), 0x80000 * 4, 1, fp); fclose(fp); } } @@ -101,41 +108,41 @@ void hng64_state::hng64_soundram_w(offs_t offset, uint32_t data, uint32_t mem_ma } -uint32_t hng64_state::hng64_soundram_r(offs_t offset) +u32 hng64_state::soundram_r(offs_t offset) { - uint16_t datalo = m_soundram[offset * 2 + 0]; - uint16_t datahi = m_soundram[offset * 2 + 1]; + const u16 datalo = m_soundram[offset * 2 + 0]; + const u16 datahi = m_soundram[offset * 2 + 1]; return swapendian_int16(datahi) | (swapendian_int16(datalo) << 16); } -void hng64_state::hng64_soundcpu_enable_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::soundcpu_enable_w(offs_t offset, u32 data, u32 mem_mask) { if (ACCESSING_BITS_16_31) { - int cmd = data >> 16; + const int cmd = data >> 16; // I guess it's only one of the bits, the commands are inverse of each other - if (cmd==0x55AA) + if (cmd == 0x55AA) { - logerror("soundcpu ON\n"); + LOGSOUND("%s: soundcpu ON\n", machine().describe_context()); m_audiocpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); m_audiocpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE); } - else if (cmd==0xAA55) + else if (cmd == 0xAA55) { - logerror("soundcpu OFF\n"); + LOGSOUND("%s: soundcpu OFF\n", machine().describe_context()); m_audiocpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); } else { - logerror("unknown hng64_soundcpu_enable_w cmd %04x\n", cmd); + LOGSOUND("%s: unknown soundcpu_enable_w cmd %04x\n", machine().describe_context(), cmd); } } if (ACCESSING_BITS_0_15) { - logerror("unknown hng64_soundcpu_enable_w %08x %08x\n", data, mem_mask); + LOGSOUND("%s: unknown soundcpu_enable_w %08x %08x\n", machine().describe_context(), data, mem_mask); } } @@ -143,26 +150,21 @@ void hng64_state::hng64_soundcpu_enable_w(offs_t offset, uint32_t data, uint32_t // General // ---------------------------------------------- +void hng64_state::init_sound() +{ + u8 *RAM = (u8*)m_soundram.get(); + for (int i = 0; i < 16; i++) + { + m_audio_bank[i]->configure_entries(0, 0x20, RAM, 0x10000); + } +} void hng64_state::reset_sound() { - uint8_t *RAM = (uint8_t*)m_soundram.get(); - membank("bank0")->set_base(&RAM[0x1f0000]); - membank("bank1")->set_base(&RAM[0x1f0000]); - membank("bank2")->set_base(&RAM[0x1f0000]); - membank("bank3")->set_base(&RAM[0x1f0000]); - membank("bank4")->set_base(&RAM[0x1f0000]); - membank("bank5")->set_base(&RAM[0x1f0000]); - membank("bank6")->set_base(&RAM[0x1f0000]); - membank("bank7")->set_base(&RAM[0x1f0000]); - membank("bank8")->set_base(&RAM[0x1f0000]); - membank("bank9")->set_base(&RAM[0x1f0000]); - membank("banka")->set_base(&RAM[0x1f0000]); - membank("bankb")->set_base(&RAM[0x1f0000]); - membank("bankc")->set_base(&RAM[0x1f0000]); - membank("bankd")->set_base(&RAM[0x1f0000]); - membank("banke")->set_base(&RAM[0x1f0000]); - membank("bankf")->set_base(&RAM[0x1f0000]); + for (int i = 0; i < 16; i++) + { + m_audio_bank[i]->set_entry(0x1f); + } m_audiocpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); @@ -173,101 +175,69 @@ void hng64_state::reset_sound() // ---------------------------------------------- -void hng64_state::hng_sound_map(address_map &map) +void hng64_state::sound_map(address_map &map) { - map(0x00000, 0x0ffff).bankrw("bank0"); - map(0x10000, 0x1ffff).bankrw("bank1"); - map(0x20000, 0x2ffff).bankrw("bank2"); - map(0x30000, 0x3ffff).bankrw("bank3"); - map(0x40000, 0x4ffff).bankrw("bank4"); - map(0x50000, 0x5ffff).bankrw("bank5"); - map(0x60000, 0x6ffff).bankrw("bank6"); - map(0x70000, 0x7ffff).bankrw("bank7"); - map(0x80000, 0x8ffff).bankrw("bank8"); - map(0x90000, 0x9ffff).bankrw("bank9"); - map(0xa0000, 0xaffff).bankrw("banka"); - map(0xb0000, 0xbffff).bankrw("bankb"); - map(0xc0000, 0xcffff).bankrw("bankc"); - map(0xd0000, 0xdffff).bankrw("bankd"); - map(0xe0000, 0xeffff).bankrw("banke"); - map(0xf0000, 0xfffff).bankrw("bankf"); + for (int i = 0; i < 16; i++) + { + map(i << 16, (i << 16) | 0xffff).bankrw(m_audio_bank[i]); + } } -void hng64_state::hng64_sound_port_0008_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::sound_port_0008_w(offs_t offset, u16 data, u16 mem_mask) { -// logerror("hng64_sound_port_0008_w %04x %04x\n", data, mem_mask); + LOGSOUND("sound_port_0008_w %04x %04x\n", data, mem_mask); // seems to one or more of the DMARQ on the V53, writes here when it expects DMA channel 3 to transfer ~0x20 bytes just after startup /* TODO: huh? */ - m_audiocpu->dreq_w<3>(data&0x1); - m_dsp->l7a1045_sound_w(8/2,data,mem_mask); + m_audiocpu->dreq_w<3>(data & 0x1); + m_dsp->l7a1045_sound_w(8 / 2,data,mem_mask); // m_audiocpu->hack_w(1); - } -uint16_t hng64_state::hng64_sound_port_0008_r(offs_t offset, uint16_t mem_mask) +u16 hng64_state::sound_port_0008_r(offs_t offset, u16 mem_mask) { // read in irq5 - //logerror("%s: hng64_sound_port_0008_r mask (%04x)\n", machine().describe_context(), mem_mask); + if (!machine().side_effects_disabled()) + LOGSOUND("%s: sound_port_0008_r mask (%04x)\n", machine().describe_context(), mem_mask); return 0; } // but why not just use the V33/V53 XA mode?? -void hng64_state::hng64_sound_bank_w(offs_t offset, uint16_t data) +void hng64_state::sound_bank_w(offs_t offset, u16 data) { - logerror("%s hng64_sound_bank_w? %02x %04x\n", machine().describe_context(), offset, data); + LOGSOUND("%s sound_bank_w? %02x %04x\n", machine().describe_context(), offset, data); // buriki writes 0x3f to 0x200 before jumping to the low addresses.. // where it expects to find data from 0x1f0000 // the 2 early games don't do this.. maybe all banks actuallly default to that region tho? // the sound code on those games seems buggier anyway. - uint8_t *RAM = (uint8_t*)m_soundram.get(); - - int bank = data & 0x1f; - - if (offset == 0x0) membank("bank0")->set_base(&RAM[bank*0x10000]); - if (offset == 0x1) membank("bank1")->set_base(&RAM[bank*0x10000]); - if (offset == 0x2) membank("bank2")->set_base(&RAM[bank*0x10000]); - if (offset == 0x3) membank("bank3")->set_base(&RAM[bank*0x10000]); - if (offset == 0x4) membank("bank4")->set_base(&RAM[bank*0x10000]); - if (offset == 0x5) membank("bank5")->set_base(&RAM[bank*0x10000]); - if (offset == 0x6) membank("bank6")->set_base(&RAM[bank*0x10000]); - if (offset == 0x7) membank("bank7")->set_base(&RAM[bank*0x10000]); - if (offset == 0x8) membank("bank8")->set_base(&RAM[bank*0x10000]); - if (offset == 0x9) membank("bank9")->set_base(&RAM[bank*0x10000]); - if (offset == 0xa) membank("banka")->set_base(&RAM[bank*0x10000]); - if (offset == 0xb) membank("bankb")->set_base(&RAM[bank*0x10000]); - if (offset == 0xc) membank("bankc")->set_base(&RAM[bank*0x10000]); - if (offset == 0xd) membank("bankd")->set_base(&RAM[bank*0x10000]); - if (offset == 0xe) membank("banke")->set_base(&RAM[bank*0x10000]); - if (offset == 0xf) membank("bankf")->set_base(&RAM[bank*0x10000]); - + m_audio_bank[offset & 0xf]->set_entry(data & 0x1f); } -void hng64_state::hng64_sound_port_000a_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::sound_port_000a_w(offs_t offset, u16 data, u16 mem_mask) { - logerror("%s: hng64_port hng64_sound_port_000a_w %04x mask (%04x)\n", machine().describe_context(), data, mem_mask); + LOGSOUND("%s: hng64_port sound_port_000a_w %04x mask (%04x)\n", machine().describe_context(), data, mem_mask); } -void hng64_state::hng64_sound_port_000c_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::sound_port_000c_w(offs_t offset, u16 data, u16 mem_mask) { - logerror("%s: hng64_port hng64_sound_port_000c_w %04x mask (%04x)\n", machine().describe_context(), data, mem_mask); + LOGSOUND("%s: hng64_port sound_port_000c_w %04x mask (%04x)\n", machine().describe_context(), data, mem_mask); } -void hng64_state::hng64_sound_port_0080_w(uint16_t data) +void hng64_state::sound_port_0080_w(u16 data) { - logerror("%s: hng64_port 0x0080 %04x\n", machine().describe_context(), data); + LOGSOUND("%s: hng64_port 0x0080 %04x\n", machine().describe_context(), data); } -void hng64_state::sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_mask) +void hng64_state::sound_comms_w(offs_t offset, u16 data, u16 mem_mask) { - switch(offset << 1) + switch (offset << 1) { // Data to main CPU case 0x0: @@ -283,9 +253,9 @@ void hng64_state::sound_comms_w(offs_t offset, uint16_t data, uint16_t mem_mask) } } -uint16_t hng64_state::sound_comms_r(offs_t offset) +u16 hng64_state::sound_comms_r(offs_t offset) { - switch(offset << 1) + switch (offset << 1) { case 0x00: return sound_latch[0]; @@ -300,19 +270,19 @@ uint16_t hng64_state::sound_comms_r(offs_t offset) return 0; } -void hng64_state::hng_sound_io(address_map &map) +void hng64_state::sound_io_map(address_map &map) { map(0x0000, 0x0007).rw(m_dsp, FUNC(l7a1045_sound_device::l7a1045_sound_r), FUNC(l7a1045_sound_device::l7a1045_sound_w)); - map(0x0008, 0x0009).rw(FUNC(hng64_state::hng64_sound_port_0008_r), FUNC(hng64_state::hng64_sound_port_0008_w)); - map(0x000a, 0x000b).w(FUNC(hng64_state::hng64_sound_port_000a_w)); - map(0x000c, 0x000d).w(FUNC(hng64_state::hng64_sound_port_000c_w)); + map(0x0008, 0x0009).rw(FUNC(hng64_state::sound_port_0008_r), FUNC(hng64_state::sound_port_0008_w)); + map(0x000a, 0x000b).w(FUNC(hng64_state::sound_port_000a_w)); + map(0x000c, 0x000d).w(FUNC(hng64_state::sound_port_000c_w)); - map(0x0080, 0x0081).w(FUNC(hng64_state::hng64_sound_port_0080_w)); + map(0x0080, 0x0081).w(FUNC(hng64_state::sound_port_0080_w)); map(0x0100, 0x010f).rw(FUNC(hng64_state::sound_comms_r), FUNC(hng64_state::sound_comms_w)); - map(0x0200, 0x021f).w(FUNC(hng64_state::hng64_sound_bank_w)); // ?? + map(0x0200, 0x021f).w(FUNC(hng64_state::sound_bank_w)); // ?? } @@ -321,18 +291,19 @@ void hng64_state::dma_hreq_cb(int state) m_audiocpu->hack_w(1); } -uint8_t hng64_state::dma_memr_cb(offs_t offset) +u8 hng64_state::dma_memr_cb(offs_t offset) { return m_audiocpu->space(AS_PROGRAM).read_byte(offset); } -void hng64_state::dma_iow3_cb(uint8_t data) +void hng64_state::dma_iow3_cb(u8 data) { // currently it reads a block of 0x20 '0x00' values from a very specific block of RAM where there is a 0x20 space in the data and transfers them repeatedly, I assume // this is some kind of buffer for the audio or DSP and eventually will be populated with other values... // if this comes to life maybe something interesting is happening! - if (data!=0x00) logerror("dma_iow3_cb %02x\n", data); + if (data != 0x00) + LOGSOUND("dma_iow3_cb %02x\n", data); } void hng64_state::tcu_tm0_cb(int state) @@ -354,8 +325,8 @@ void hng64_state::tcu_tm2_cb(int state) void hng64_state::hng64_audio(machine_config &config) { V53A(config, m_audiocpu, 32_MHz_XTAL); // reference footage indicates the timer must be the full 32 MHz - m_audiocpu->set_addrmap(AS_PROGRAM, &hng64_state::hng_sound_map); - m_audiocpu->set_addrmap(AS_IO, &hng64_state::hng_sound_io); + m_audiocpu->set_addrmap(AS_PROGRAM, &hng64_state::sound_map); + m_audiocpu->set_addrmap(AS_IO, &hng64_state::sound_io_map); m_audiocpu->out_hreq_cb().set(FUNC(hng64_state::dma_hreq_cb)); m_audiocpu->in_memr_cb().set(FUNC(hng64_state::dma_memr_cb)); m_audiocpu->out_iow_cb<3>().set(FUNC(hng64_state::dma_iow3_cb)); diff --git a/src/mame/snk/hng64_sprite.ipp b/src/mame/snk/hng64_sprite.ipp index 4555450d432..bcb13e3c1ca 100644 --- a/src/mame/snk/hng64_sprite.ipp +++ b/src/mame/snk/hng64_sprite.ipp @@ -44,7 +44,7 @@ #define PIXEL_OP_REBASE_TRANSPEN(DEST, DESTZ, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + const u32 srcdata = (SOURCE); \ if (xdrawpos <= cliprect.right() && xdrawpos >= cliprect.left()) \ { \ if (zval < (DESTZ)) \ @@ -63,7 +63,7 @@ while (0) #define PIXEL_OP_REBASE_TRANSPEN_REV(DEST, DESTZ, SOURCE) \ do \ { \ - uint32_t srcdata = (SOURCE); \ + const u32 srcdata = (SOURCE); \ if (xdrawpos <= cliprect.right() && xdrawpos >= cliprect.left()) \ { \ if (zval >= (DESTZ)) \ @@ -112,20 +112,20 @@ do \ } \ while (0) -inline void hng64_state::drawline(bitmap_ind16 & dest, bitmap_ind16 & destz, const rectangle & cliprect, - gfx_element * gfx, uint32_t code, uint32_t color, int flipy, int32_t xpos, - int32_t dx, int32_t dy, uint32_t trans_pen, uint32_t zval, bool zrev, bool blend, bool checkerboard, uint8_t mosaic, uint8_t &mosaic_count_x, int32_t ypos, const u8 *srcdata, int32_t srcx, uint32_t leftovers, int curyy, uint16_t &srcpix) +inline void hng64_state::drawline(bitmap_ind16 &dest, bitmap_ind16 &destz, const rectangle &cliprect, + gfx_element * gfx, u32 code, u32 color, int flipy, s32 xpos, + s32 dx, s32 dy, u32 trans_pen, u32 zval, bool zrev, bool blend, bool checkerboard, u8 mosaic, u8 &mosaic_count_x, s32 ypos, const u8 *srcdata, s32 srcx, u32 leftovers, int curyy, u16 &srcpix) { auto* destptr = &dest.pix(ypos, 0); auto* destzptr = &destz.pix(ypos, 0); const u8* srcptr = srcdata + (flipy ? ((15-curyy) & 0xf) : (curyy & 0xf)) * gfx->rowbytes(); - int32_t cursrcx = srcx; + s32 cursrcx = srcx; if (zrev) { // iterate over leftover pixels - for (int32_t curx = 0; curx < leftovers; curx++) + for (s32 curx = 0; curx < leftovers; curx++) { int xdrawpos = xpos + curx; PIX_CHECKERBOARD; @@ -136,7 +136,7 @@ inline void hng64_state::drawline(bitmap_ind16 & dest, bitmap_ind16 & destz, con else { // iterate over leftover pixels - for (int32_t curx = 0; curx < leftovers; curx++) + for (s32 curx = 0; curx < leftovers; curx++) { int xdrawpos = xpos + curx; PIX_CHECKERBOARD; @@ -147,15 +147,15 @@ inline void hng64_state::drawline(bitmap_ind16 & dest, bitmap_ind16 & destz, con } inline void hng64_state::zoom_transpen(bitmap_ind16 &dest, bitmap_ind16 &destz, const rectangle &cliprect, - gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int32_t xpos, int32_t ypos, - int32_t dx, int32_t dy, uint32_t dstwidth, uint32_t trans_pen, uint32_t zval, bool zrev, bool blend, uint16_t group, bool checkerboard, uint8_t mosaic, uint8_t &mosaic_count_x, int curyy, uint16_t &srcpix) + gfx_element *gfx, u32 code, u32 color, int flipx, int flipy, s32 xpos, s32 ypos, + s32 dx, s32 dy, u32 dstwidth, u32 trans_pen, u32 zval, bool zrev, bool blend, u16 group, bool checkerboard, u8 mosaic, u8 &mosaic_count_x, int curyy, u16 &srcpix) { // use pen usage to optimize code %= gfx->elements(); if (gfx->has_pen_usage()) { // fully transparent; do nothing - uint32_t usage = gfx->pen_usage(code); + const u32 usage = gfx->pen_usage(code); if ((usage & ~(1 << trans_pen)) == 0) return; } @@ -178,7 +178,7 @@ inline void hng64_state::zoom_transpen(bitmap_ind16 &dest, bitmap_ind16 &destz, if (dstwidth < 1) return; - int32_t srcx = 0; + s32 srcx = 0; // apply X flipping if (flipx) { @@ -189,8 +189,8 @@ inline void hng64_state::zoom_transpen(bitmap_ind16 &dest, bitmap_ind16 &destz, // fetch the source data const u8 *srcdata = gfx->get_data(code); - int32_t destendx = xpos + dstwidth - 1; - uint32_t leftovers = (destendx + 1 - xpos); + s32 destendx = xpos + dstwidth - 1; + u32 leftovers = (destendx + 1 - xpos); drawline(dest, destz, cliprect, gfx, code, color, flipy, xpos, @@ -198,7 +198,7 @@ inline void hng64_state::zoom_transpen(bitmap_ind16 &dest, bitmap_ind16 &destz, } -inline void hng64_state::get_tile_details(bool chain, uint16_t spritenum, uint8_t xtile, uint8_t ytile, uint8_t xsize, uint8_t ysize, bool xflip, bool yflip, uint32_t& tileno, uint16_t& pal, uint8_t &gfxregion) +inline void hng64_state::get_tile_details(bool chain, u16 spritenum, u8 xtile, u8 ytile, u8 xsize, u8 ysize, bool xflip, bool yflip, u32& tileno, u16& pal, u8 &gfxregion) { int offset; if (!xflip) @@ -256,14 +256,14 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl m_sprite_bitmap.fill(0x0000, cliprect); // global offsets in sprite regs - int spriteoffsx = (m_spriteregs[1] >> 0) & 0xffff; - int spriteoffsy = (m_spriteregs[1] >> 16) & 0xffff; + const int spriteoffsx = (m_spriteregs[1] >> 0) & 0xffff; + const int spriteoffsy = (m_spriteregs[1] >> 16) & 0xffff; // This flips between ingame and other screens for roadedge, where the sprites which are filtered definitely needs to change and the game explicitly swaps the values in the sprite list at the same time. // m_spriteregs[2] could also play a part as it also flips between 0x00000000 and 0x000fffff at the same time // Samsho games also set the upper 3 bits which could be related, samsho games still have some unwanted sprites (but also use the other 'sprite clear' mechanism) // Could also be draw order related, check if it inverts the z value? - bool zsort = !(m_spriteregs[0] & 0x01000000); + const bool zsort = !(m_spriteregs[0] & 0x01000000); if (zsort) m_sprite_zbuffer.fill(0x0000, cliprect); @@ -275,11 +275,10 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl while (currentsprite < ((0xc000 / 4) / 8)) { - uint16_t zval = (m_spriteram[(currentsprite * 8) + 2] & 0x07ff0000) >> 16; + const u16 zval = (m_spriteram[(currentsprite * 8) + 2] & 0x07ff0000) >> 16; - - int16_t ypos = (m_spriteram[(currentsprite * 8) + 0] & 0xffff0000) >> 16; - int16_t xpos = (m_spriteram[(currentsprite * 8) + 0] & 0x0000ffff) >> 0; + s16 ypos = (m_spriteram[(currentsprite * 8) + 0] & 0xffff0000) >> 16; + s16 xpos = (m_spriteram[(currentsprite * 8) + 0] & 0x0000ffff) >> 0; // should the offsets also be sign extended? xpos += (spriteoffsx); @@ -289,17 +288,17 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl xpos = util::sext(xpos, 10); ypos = util::sext(ypos, 10); - bool blend = (m_spriteram[(currentsprite * 8) + 4] & 0x00800000); - uint16_t group = (m_spriteram[(currentsprite * 8) + 4] & 0x00700000) >> 8; - bool checkerboard = (m_spriteram[(currentsprite * 8) + 4] & 0x04000000); - uint8_t mosaic = (m_spriteram[(currentsprite * 8) + 4] & 0xf0000000) >> 28; + const bool blend = (m_spriteram[(currentsprite * 8) + 4] & 0x00800000); + const u16 group = (m_spriteram[(currentsprite * 8) + 4] & 0x00700000) >> 8; + const bool checkerboard = (m_spriteram[(currentsprite * 8) + 4] & 0x04000000); + const u8 mosaic = (m_spriteram[(currentsprite * 8) + 4] & 0xf0000000) >> 28; - int yflip = (m_spriteram[(currentsprite * 8) + 4] & 0x01000000) >> 24; - int xflip = (m_spriteram[(currentsprite * 8) + 4] & 0x02000000) >> 25; + const int yflip = (m_spriteram[(currentsprite * 8) + 4] & 0x01000000) >> 24; + const int xflip = (m_spriteram[(currentsprite * 8) + 4] & 0x02000000) >> 25; - int chainy = (m_spriteram[(currentsprite * 8) + 2] & 0x0000000f); - int chainx = (m_spriteram[(currentsprite * 8) + 2] & 0x000000f0) >> 4; - int chaini = (m_spriteram[(currentsprite * 8) + 2] & 0x00000100); + const int chainy = (m_spriteram[(currentsprite * 8) + 2] & 0x0000000f); + const int chainx = (m_spriteram[(currentsprite * 8) + 2] & 0x000000f0) >> 4; + const int chaini = (m_spriteram[(currentsprite * 8) + 2] & 0x00000100); if (!chaini) { @@ -310,8 +309,8 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl nextsprite = currentsprite + ((chainx + 1) * (chainy + 1)); } - uint32_t zoomy = (m_spriteram[(currentsprite * 8) + 1] & 0xffff0000) >> 16; - uint32_t zoomx = (m_spriteram[(currentsprite * 8) + 1] & 0x0000ffff) >> 0; + const u32 zoomy = (m_spriteram[(currentsprite * 8) + 1] & 0xffff0000) >> 16; + const u32 zoomx = (m_spriteram[(currentsprite * 8) + 1] & 0x0000ffff) >> 0; /* Calculate the zoom */ int zoom_factor = (m_spriteregs[0] & 0x08000000) ? 0x1000 : 0x100; @@ -335,7 +334,7 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl continue; } - int32_t dx, dy; + s32 dx, dy; if (zoom_factor == 0x100) { @@ -349,8 +348,8 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl } - uint32_t full_srcpix_y = 0; - uint32_t full_dstheight = 0; + u32 full_srcpix_y = 0; + u32 full_dstheight = 0; do { full_srcpix_y += dy; @@ -359,7 +358,7 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl int realline = 0; int mosaic_y_counter = 0; - for (int32_t curyy = 0; curyy <= full_dstheight - 1; curyy++) + for (s32 curyy = 0; curyy <= full_dstheight - 1; curyy++) { if (!mosaic) { @@ -380,10 +379,10 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl if (ypos <= cliprect.bottom() && ypos >= cliprect.top()) { - uint32_t full_srcpix_y2 = realline * dy; - int used_ysource_pos = full_srcpix_y2 >> 16; - int ytilebbb = used_ysource_pos / 0x10; - int use_tile_line = used_ysource_pos & 0xf; + const u32 full_srcpix_y2 = realline * dy; + const int used_ysource_pos = full_srcpix_y2 >> 16; + const int ytilebbb = used_ysource_pos / 0x10; + const int use_tile_line = used_ysource_pos & 0xf; draw_sprite_line(screen, cliprect, use_tile_line, ypos, xpos, chainx, dx, dy, ytilebbb, chaini, currentsprite, chainy, xflip, yflip, zval, zsort, blend, group, checkerboard, mosaic); } ypos++; @@ -394,16 +393,16 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl } -inline void hng64_state::draw_sprite_line(screen_device& screen, const rectangle& cliprect, int32_t curyy, int16_t ypos, int16_t xpos, int chainx, int32_t dx, int32_t dy, int ytileblock, int chaini, int currentsprite, int chainy, int xflip, int yflip, uint16_t zval, bool zsort, bool blend, uint16_t group, bool checkerboard, uint8_t mosaic) +inline void hng64_state::draw_sprite_line(screen_device& screen, const rectangle& cliprect, s32 curyy, s16 ypos, s16 xpos, int chainx, s32 dx, s32 dy, int ytileblock, int chaini, int currentsprite, int chainy, int xflip, int yflip, u16 zval, bool zsort, bool blend, u16 group, bool checkerboard, u8 mosaic) { - uint32_t srcpix_x = 0; - uint16_t srcpix = 0; + u32 srcpix_x = 0; + u16 srcpix = 0; - uint8_t mosaic_count_x = 0; + u8 mosaic_count_x = 0; for (int xdrw = 0; xdrw <= chainx; xdrw++) { - uint32_t dstwidth = 0; + u32 dstwidth = 0; do { srcpix_x += dx; @@ -411,9 +410,9 @@ inline void hng64_state::draw_sprite_line(screen_device& screen, const rectangle } while (srcpix_x < 0x100000); srcpix_x &= 0x0fffff; - uint32_t tileno; - uint16_t pal; - uint8_t gfxregion; + u32 tileno; + u16 pal; + u8 gfxregion; get_tile_details(chaini, currentsprite, xdrw, ytileblock, chainx, chainy, xflip, yflip, tileno, pal, gfxregion); zoom_transpen(m_sprite_bitmap, m_sprite_zbuffer, cliprect, m_gfxdecode->gfx(gfxregion), tileno, pal, xflip, yflip, xpos, ypos, dx, dy, dstwidth, 0, zval, zsort, blend, group, checkerboard, mosaic, mosaic_count_x, curyy, srcpix); diff --git a/src/mame/snk/hng64_v.cpp b/src/mame/snk/hng64_v.cpp index 0b2998676dd..4874fae2fad 100644 --- a/src/mame/snk/hng64_v.cpp +++ b/src/mame/snk/hng64_v.cpp @@ -15,165 +15,84 @@ #define HNG64_VIDEO_DEBUG 0 -void hng64_state::hng64_mark_all_tiles_dirty(int tilemap) +void hng64_state::mark_all_tiles_dirty(int tilemap) { m_tilemap[tilemap].m_tilemap_8x8->mark_all_dirty(); m_tilemap[tilemap].m_tilemap_16x16->mark_all_dirty(); m_tilemap[tilemap].m_tilemap_16x16_alt->mark_all_dirty(); } -void hng64_state::hng64_mark_tile_dirty(int tilemap, int tile_index) +void hng64_state::mark_tile_dirty(int tilemap, int tile_index) { m_tilemap[tilemap].m_tilemap_8x8->mark_tile_dirty(tile_index); m_tilemap[tilemap].m_tilemap_16x16->mark_tile_dirty(tile_index); m_tilemap[tilemap].m_tilemap_16x16_alt->mark_tile_dirty(tile_index); } -// make this a template function! // pppppppp ffattttt tttttttt tttttttt -#define HNG64_GET_TILE_INFO \ -{ \ - uint16_t tilemapinfo = (m_videoregs[reg]>>shift)&0xffff; \ - int tileno,pal, flip; \ - \ - tileno = m_videoram[tile_index+(offset/4)]; \ - \ - pal = (tileno&0xff000000)>>24; \ - flip =(tileno&0x00c00000)>>22; \ - \ - if (tileno&0x200000) \ - { \ - if ((m_videoregs[0x01] >> 16) & 0x0001) \ - tileno = (tileno & m_videoregs[0x0b]) | m_videoregs[0x0c]; \ - } \ - \ - tileno &= 0x1fffff; \ - \ - if (size==0) \ - { \ - if (tilemapinfo&0x400) \ - { \ - tileinfo.set(1,tileno>>1,pal>>4,TILE_FLIPYX(flip)); \ - } \ - else \ - { \ - tileinfo.set(0,tileno, pal,TILE_FLIPYX(flip)); \ - } \ - } \ - else \ - { \ - if (tilemapinfo&0x400) \ - { \ - tileinfo.set(3,tileno>>3,pal>>4,TILE_FLIPYX(flip)); \ - } \ - else \ - { \ - tileinfo.set(2,tileno>>2, pal,TILE_FLIPYX(flip)); \ - } \ - } \ -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile0_8x8_info) -{ - int offset = 0x00000; - int size = 0; - int reg = 0x02; - int shift = 16; - - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile0_16x16_info) +template <u8 Which, u8 Size> +TILE_GET_INFO_MEMBER(hng64_state::get_tile_info) { - int offset = 0x00000; - int size = 1; - int reg = 0x02; - int shift = 16; + const u16 tilemapinfo = get_tileregs(Which); - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile1_8x8_info) -{ - int offset = 0x10000; - int size = 0; - int reg = 0x02; - int shift = 0; + u32 tileno = m_videoram[tile_index + (Which << 14)]; - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile1_16x16_info) -{ - int offset = 0x10000; - int size = 1; - int reg = 0x02; - int shift = 0; + const u32 pal = (tileno & 0xff000000) >> 24; + const int flip =(tileno & 0x00c00000) >> 22; - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile2_8x8_info) -{ - int offset = 0x20000; - int size = 0; - int reg = 0x03; - int shift = 16; - - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile2_16x16_info) -{ - int offset = 0x20000; - int size = 1; - int reg = 0x03; - int shift = 16; - - HNG64_GET_TILE_INFO -} - -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile3_8x8_info) -{ - int offset = 0x30000; - int size = 0; - int reg = 0x03; - int shift = 0; - - HNG64_GET_TILE_INFO -} + if (BIT(tileno, 21)) + { + if (BIT(m_videoregs[0x01], 16)) + tileno = (tileno & m_videoregs[0x0b]) | m_videoregs[0x0c]; + } -TILE_GET_INFO_MEMBER(hng64_state::get_hng64_tile3_16x16_info) -{ - int offset = 0x30000; - int size = 1; - int reg = 0x03; - int shift = 0; + tileno &= 0x1fffff; - HNG64_GET_TILE_INFO + if (Size == 0) + { + if (BIT(tilemapinfo, 10)) + { + tileinfo.set(1, tileno >> 1, pal >> 4, TILE_FLIPYX(flip)); + } + else + { + tileinfo.set(0, tileno, pal, TILE_FLIPYX(flip)); + } + } + else + { + if (BIT(tilemapinfo, 10)) + { + tileinfo.set(3, tileno >> 3, pal >> 4, TILE_FLIPYX(flip)); + } + else + { + tileinfo.set(2, tileno >> 2, pal, TILE_FLIPYX(flip)); + } + } } -void hng64_state::hng64_videoram_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::videoram_w(offs_t offset, u32 data, u32 mem_mask) { const int realoff = (offset * 4); COMBINE_DATA(&m_videoram[offset]); if ((realoff >= 0) && (realoff < 0x10000)) { - hng64_mark_tile_dirty(0, offset & 0x3fff); + mark_tile_dirty(0, offset & 0x3fff); } else if ((realoff >= 0x10000) && (realoff < 0x20000)) { - hng64_mark_tile_dirty(1, offset & 0x3fff); + mark_tile_dirty(1, offset & 0x3fff); } else if ((realoff >= 0x20000) && (realoff < 0x30000)) { - hng64_mark_tile_dirty(2, offset & 0x3fff); + mark_tile_dirty(2, offset & 0x3fff); } else if ((realoff >= 0x30000) && (realoff < 0x40000)) { - hng64_mark_tile_dirty(3, offset & 0x3fff); + mark_tile_dirty(3, offset & 0x3fff); } // Offsets 0x40000 - 0x58000 are for "floor" scanline control @@ -191,25 +110,25 @@ void hng64_state::hng64_videoram_w(offs_t offset, uint32_t data, uint32_t mem_ma #define HNG64_ROZ_PLOT_PIXEL(INPUT_VAL) \ do { \ if (drawformat == 1) \ - *(uint32_t *)dest = clut[INPUT_VAL]; \ + *(u32 *)dest = clut[INPUT_VAL]; \ else if (drawformat == 2) \ - *(uint32_t *)dest = add_blend_r32(*(uint32_t *)dest, clut[INPUT_VAL]); \ + *(u32 *)dest = add_blend_r32(*(u32 *)dest, clut[INPUT_VAL]); \ else if (drawformat == 3) \ - *(uint32_t *)dest = alpha_blend_r32(*(uint32_t *)dest, clut[INPUT_VAL], alpha); \ + *(u32 *)dest = alpha_blend_r32(*(u32 *)dest, clut[INPUT_VAL], alpha); \ } while (0) -void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, - int wraparound, uint8_t drawformat, uint8_t alpha, uint8_t mosaic, uint8_t tm, int splitside) +void hng64_state::tilemap_draw_roz_core_line(screen_device &screen, bitmap_rgb32 &dest, const rectangle &cliprect, tilemap_t *tmap, + int wraparound, u8 drawformat, u8 alpha, u8 mosaic, u8 tm, int splitside) { int source_line_to_use = cliprect.min_y; source_line_to_use = (source_line_to_use / (mosaic+1)) * (mosaic+1); int xinc, xinc2, yinc, yinc2; - int32_t xtopleft; - int32_t ytopleft; - uint16_t scrollbase = get_scrollbase(tm); - uint16_t tileregs = get_tileregs(tm); - const uint8_t not_line_mode = (tileregs & 0x0800) >> 11; + s32 xtopleft; + s32 ytopleft; + const u16 scrollbase = get_scrollbase(tm); + const u16 tileregs = get_tileregs(tm); + const u8 not_line_mode = (tileregs & 0x0800) >> 11; if (not_line_mode) { @@ -252,12 +171,12 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap #endif xtopleft = (m_videoram[(0x40000 + (scrollbase << 4)) / 4]); - const int32_t xalt = (m_videoram[(0x40004 + (scrollbase << 4)) / 4]); // middle screen point - const int32_t xmiddle = (m_videoram[(0x40010 + (scrollbase << 4)) / 4]); + const s32 xalt = (m_videoram[(0x40004 + (scrollbase << 4)) / 4]); // middle screen point + const s32 xmiddle = (m_videoram[(0x40010 + (scrollbase << 4)) / 4]); ytopleft = (m_videoram[(0x40008 + (scrollbase << 4)) / 4]); - const int32_t yalt = (m_videoram[(0x40018 + (scrollbase << 4)) / 4]); // middle screen point - const int32_t ymiddle = (m_videoram[(0x4000c + (scrollbase << 4)) / 4]); + const s32 yalt = (m_videoram[(0x40018 + (scrollbase << 4)) / 4]); // middle screen point + const s32 ymiddle = (m_videoram[(0x4000c + (scrollbase << 4)) / 4]); xinc = (xmiddle - xtopleft) / 512; yinc = (ymiddle - ytopleft) / 512; @@ -281,10 +200,10 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap m_videoram[(0x4001c + (scrollbase << 4)) / 4]); #endif - int32_t xmiddle; - int32_t ymiddle; + s32 xmiddle; + s32 ymiddle; - const uint32_t& global_tileregs = m_videoregs[0x00]; + const u32& global_tileregs = m_videoregs[0x00]; const int global_zoom_disable = global_tileregs & 0x00010000; if (global_zoom_disable) // disable all scrolling / zoom (test screen) (maybe) { @@ -333,10 +252,10 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap else // line mode { const int global_alt_scroll_register_format = m_videoregs[0x00] & 0x04000000; - int32_t xmiddle; - int32_t ymiddle; + s32 xmiddle; + s32 ymiddle; - const uint32_t& global_tileregs = m_videoregs[0x00]; + const u32& global_tileregs = m_videoregs[0x00]; const int global_zoom_disable = global_tileregs & 0x00010000; if (global_zoom_disable) // disable all scrolling / zoom (test screen) (maybe) { @@ -352,12 +271,12 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap } else { - uint16_t line = source_line_to_use; + u16 line = source_line_to_use; xtopleft = (m_videoram[(0x40000 + (scrollbase << 4)) / 4]); xmiddle = (m_videoram[(0x40004 + (scrollbase << 4)) / 4]); // middle screen point - uint32_t xtopleft2 = (m_videoram[(0x40000 + (line * 0x10) + (scrollbase << 4)) / 4]); - uint32_t xmiddle2 = (m_videoram[(0x40004 + (line * 0x10) + (scrollbase << 4)) / 4]); // middle screen point + u32 xtopleft2 = (m_videoram[(0x40000 + (line * 0x10) + (scrollbase << 4)) / 4]); + u32 xmiddle2 = (m_videoram[(0x40004 + (line * 0x10) + (scrollbase << 4)) / 4]); // middle screen point if ((xtopleft2 & 0xff) == 0x00)// set to 0x00 if we should use the line data? xtopleft = xtopleft2; @@ -386,8 +305,8 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap } - uint32_t startx = xtopleft; - uint32_t starty = ytopleft; + u32 startx = xtopleft; + u32 starty = ytopleft; const int incxx = xinc << 1; const int incxy = yinc2 << 1; const int incyx = xinc2 << 1; @@ -398,12 +317,12 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap pen_t* clut; // allow one of the 2 pairs of fade values to be used (complete guess! but fatfurwa turns this bit on whenever it wants to do a fade effect and off when it's done) - if ((get_tileregs(tm) & 0x0080) >> 7) + if (BIT(get_tileregs(tm), 7)) { // which one depends on target layer? (also complete guess!) // (buriki intro suggests this is wrong, it should be fading tilemaps to black on the discipline name screens with a full subtractive blend, but picks the wrong register? // as we're already using this to decide which layer we're on for blending, it's probably not got a double use) - if (get_tileregs(tm) & 0x0020) + if (BIT(get_tileregs(tm), 5)) { clut = (pen_t*)&m_palette_fade0->pen(0); } @@ -425,9 +344,9 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap const int ymask = srcbitmap.height()-1; const int widthshifted = srcbitmap.width() << 16; const int heightshifted = srcbitmap.height() << 16; - uint32_t priority = 0; - uint8_t mask = 0x1f; - uint8_t value = 0x10; + u32 priority = 0; + u8 mask = 0x1f; + u8 value = 0x10; /* pre-advance based on the cliprect */ startx += cliprect.min_x * incxx + source_line_to_use * incyx; @@ -457,23 +376,23 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap { /* initialize X counters */ int x = sx; - uint32_t cx = startx; - uint32_t cy = starty >> 16; + u32 cx = startx; + u32 cy = starty >> 16; /* get source and priority pointers */ - uint8_t *pri = &priority_bitmap.pix(sy, sx); - uint16_t const *const src = &srcbitmap.pix(cy); - uint8_t const *const maskptr = &flagsmap.pix(cy); - uint32_t *dest = &destbitmap.pix(sy, sx); + u8 *pri = &priority_bitmap.pix(sy, sx); + u16 const *const src = &srcbitmap.pix(cy); + u8 const *const maskptr = &flagsmap.pix(cy); + u32 *dest = &destbitmap.pix(sy, sx); /* loop over columns */ int mosaic_counter = 0; - uint16_t masksrc = 0; - uint16_t datasrc = 0; + u16 masksrc = 0; + u16 datasrc = 0; while (x <= ex && cx < widthshifted) { - uint16_t srcoffset = cx >> 16; + u16 srcoffset = cx >> 16; if (mosaic_counter == 0) { @@ -506,22 +425,22 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap { /* initialize X counters */ int x = sx; - uint32_t cx = startx; - uint32_t cy = starty; + u32 cx = startx; + u32 cy = starty; /* get dest and priority pointers */ - uint32_t *dest = &destbitmap.pix(sy, sx); - uint8_t *pri = &priority_bitmap.pix(sy, sx); + u32 *dest = &destbitmap.pix(sy, sx); + u8 *pri = &priority_bitmap.pix(sy, sx); /* loop over columns */ int mosaic_counter = 0; - uint16_t masksrc = 0; - uint16_t datasrc = 0; + u16 masksrc = 0; + u16 datasrc = 0; while (x <= ex) { - uint16_t srcoffset = (cx >> 16) & xmask; - uint16_t srcyoffset = (cy >> 16) & ymask; + u16 srcoffset = (cx >> 16) & xmask; + u16 srcyoffset = (cy >> 16) & ymask; if (mosaic_counter == 0) { @@ -553,22 +472,22 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap { /* initialize X counters */ int x = sx; - uint32_t cx = startx; - uint32_t cy = starty; + u32 cx = startx; + u32 cy = starty; /* get dest and priority pointers */ - uint32_t *dest = &destbitmap.pix(sy, sx); - uint8_t *pri = &priority_bitmap.pix(sy, sx); + u32 *dest = &destbitmap.pix(sy, sx); + u8 *pri = &priority_bitmap.pix(sy, sx); int mosaic_counter = 0; - uint16_t masksrc = 0; - uint16_t datasrc = 0; + u16 masksrc = 0; + u16 datasrc = 0; /* loop over columns */ while (x <= ex) { - uint16_t srcoffset = cx >> 16; - uint16_t srcyoffset = cy >> 16; + u16 srcoffset = cx >> 16; + u16 srcyoffset = cy >> 16; /* plot if we're within the bitmap and we match the mask */ @@ -607,7 +526,7 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap * Video Regs Format (appear to just be tilemap regs) * -------------------------------------------------- * - * uint32_t | Bits | Use + * u32 | Bits | Use * | 3322 2222 2222 1111 1111 11 | * -------+-1098-7654-3210-9876-5432-1098-7654-3210-+---------------- * 0 | ---- -Cdd ---- -??Z ---- ---- ---- --uu | C = global complex zoom @@ -647,12 +566,12 @@ void hng64_state::hng64_tilemap_draw_roz_core_line(screen_device &screen, bitmap -uint16_t hng64_state::get_tileregs(int tm) +u16 hng64_state::get_tileregs(int tm) { return (m_videoregs[0x02 + BIT(tm, 1)] >> (BIT(tm, 0) ? 0 : 16)) & 0x0000ffff; } -uint16_t hng64_state::get_scrollbase(int tm) +u16 hng64_state::get_scrollbase(int tm) { return (m_videoregs[0x04 + BIT(tm, 1)] >> (BIT(tm, 0) ? 0 : 16)) & 0x00003fff; } @@ -662,15 +581,15 @@ int hng64_state::get_blend_mode(int tm) // this is based on xrally and sams64/sams64_2 use, it could be incorrect // it doesn't seem to be 100% on sams64_2 select screen when the mode select circle moves down - that is a blended sprite and blended tilemap mixing in a weird way to produce a darker than expected image as there are can be no other components in said mix - uint8_t blendmode = 1; - if ((get_tileregs(tm) & 0x0020) >> 5) // for layers with L(1) + u8 blendmode = 1; + if (BIT(get_tileregs(tm), 5)) // for layers with L(1) { - if ((m_tcram[0x0c / 4] >> 2) & 0x1) + if (BIT(m_tcram[0x0c / 4], 2)) blendmode = 2; } else // for layers with L(0) { - if ((m_tcram[0x0c / 4] >> 26) & 0x1) + if (BIT(m_tcram[0x0c / 4], 26)) blendmode = 2; } @@ -678,7 +597,7 @@ int hng64_state::get_blend_mode(int tm) } -void hng64_state::hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm, int flags, int line) +void hng64_state::draw_tilemap(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int tm, int flags, int line) { // Useful bits from the global tilemap flags const int global_dimensions = (m_videoregs[0x00] & 0x03000000) >> 24; @@ -689,14 +608,14 @@ void hng64_state::hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, #endif // Determine which tilemap registers and scroll base this tilemap uses - uint16_t tileregs = get_tileregs(tm); + const u16 tileregs = get_tileregs(tm); // Useful bits from the tilemap registers - const uint8_t mosaic = (tileregs & 0xf000) >> 12; - //const uint8_t bpp = (tileregs & 0x0400) >> 10; // not used? - const uint8_t big = (tileregs & 0x0200) >> 9; - const uint8_t enable = (tileregs & 0x0040) >> 6; - const uint8_t wrap = (tileregs & 0x0100) >> 8; + const u8 mosaic = (tileregs & 0xf000) >> 12; + //const u8 bpp = BIT(tileregs, 10); // not used? + const u8 big = BIT(tileregs, 9); + const u8 enable = BIT(tileregs, 6); + const u8 wrap = BIT(tileregs, 8); // this bit is used to disable tilemaps, note on fatfurwa a raster interrupt is used to change this mid-screen, swapping between // the background layers and the floor being enabled! @@ -707,7 +626,7 @@ void hng64_state::hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, // Select the proper tilemap size tilemap_t* tilemap = nullptr; - if (global_dimensions==0) + if (global_dimensions == 0) { if (big) tilemap = m_tilemap[tm].m_tilemap_16x16; else tilemap = m_tilemap[tm].m_tilemap_8x8; @@ -729,25 +648,25 @@ void hng64_state::hng64_drawtilemap(screen_device &screen, bitmap_rgb32 &bitmap, // buriki also turns on bit 0x00000002 and the effect is expected to apply to tm2 and tm3 at least (tm0/tm1 not used at this time) // sams64 does not initialize bit 0x00000002 though, only 0x00000001 to 0 - const int global_split_format = m_videoregs[0x00] & 0x00000001; + const int global_split_format = BIT(m_videoregs[0x00], 0); if (global_split_format) { clip.min_x = 256; clip.max_x = 512; - hng64_tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 1); + tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 1); clip.min_x = 0; clip.max_x = 256; - hng64_tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 2); + tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 2); } else { - hng64_tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 0); + tilemap_draw_roz_core_line(screen, bitmap, clip, tilemap, wrap, get_blend_mode(tm), 0x80, mosaic, tm, 0); } } -void hng64_state::mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, const rectangle& cliprect, uint16_t priority, int y) +void hng64_state::mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, const rectangle& cliprect, u16 priority, int y) { // this correctly allows buriki intro sprites to use regular alpha, not additive // while also being correct for sams64, which wants additive, but appears to be @@ -755,20 +674,20 @@ void hng64_state::mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, c // // the 6 regs around here have the same values in fatfur and buriki, so are unlikely // to control the blend type. - //uint8_t spriteblendtype = (m_tcram[0x10 / 4] >> 16) & 0x10; + //u8 spriteblendtype = (m_tcram[0x10 / 4] >> 16) & 0x10; // would be an odd place for it, after the 'vblank' flag but... - uint8_t spriteblendtype = (m_tcram[0x4c / 4] >> 16) & 0x01; + const u8 spriteblendtype = BIT(m_tcram[0x4c / 4], 16); pen_t const* const spriteclut = &m_palette->pen(0); if (true) { - const uint16_t* spritesrc = &m_sprite_bitmap.pix(y, cliprect.min_x); - uint32_t* spritedst = &bitmap.pix(y, cliprect.min_x); + const u16* spritesrc = &m_sprite_bitmap.pix(y, cliprect.min_x); + u32* spritedst = &bitmap.pix(y, cliprect.min_x); for (int x = cliprect.min_x; x <= cliprect.max_x; x++) { - uint16_t srcpix = *spritesrc; + const u16 srcpix = *spritesrc; if (srcpix & 0x0fff) { // if ((srcpix & 0x7000) == 0x7000) // buriki jumbotron (behind all tilemaps, behind 3d) (behind tilemap prio 1b) @@ -789,7 +708,7 @@ void hng64_state::mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, c if (srcpix & 0x8000) { if (spriteblendtype) - *spritedst = alpha_blend_r32(*(uint32_t*)spritedst, spriteclut[srcpix & 0x0fff], 0x80); + *spritedst = alpha_blend_r32(*(u32*)spritedst, spriteclut[srcpix & 0x0fff], 0x80); else *spritedst = add_blend_r32(*spritedst, spriteclut[srcpix & 0x0fff]); } @@ -807,7 +726,7 @@ void hng64_state::mixsprites_test(screen_device& screen, bitmap_rgb32& bitmap, c } } -uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +u32 hng64_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { #if 0 // press in sams64_2 attract mode for a nice debug screen from the game @@ -840,20 +759,20 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b draw_sprites_buffer(screen, cliprect); // set during transitions, could be 'disable all palette output'? - if ((m_tcram[0x24 / 4] >> 16) & 0x0002) + if (BIT(m_tcram[0x24 / 4], 17)) return 0; // If the auto-animation mask or bits have changed search for tiles using them and mark as dirty - uint32_t animmask; + u32 animmask; // this bit either disables the feature entirely, or maybe disables the latching of these animation registers (leaving them in last used state) - if ((m_videoregs[0x01] >> 16) & 0x0001) + if (BIT(m_videoregs[0x01], 16)) animmask = m_videoregs[0x0b]; else animmask = 0xffffffff; - const uint32_t animbits = m_videoregs[0x0c]; + const u32 animbits = m_videoregs[0x0c]; if ((m_old_animmask != animmask) || (m_old_animbits != animbits)) { int tile_index; @@ -861,19 +780,19 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b { if (m_videoram[tile_index + (0x00000 / 4)] & 0x200000) { - hng64_mark_tile_dirty(0, tile_index); + mark_tile_dirty(0, tile_index); } if (m_videoram[tile_index + (0x10000 / 4)] & 0x200000) { - hng64_mark_tile_dirty(1, tile_index); + mark_tile_dirty(1, tile_index); } if (m_videoram[tile_index + (0x20000 / 4)] & 0x200000) { - hng64_mark_tile_dirty(2, tile_index); + mark_tile_dirty(2, tile_index); } if (m_videoram[tile_index + (0x30000 / 4)] & 0x200000) { - hng64_mark_tile_dirty(3, tile_index); + mark_tile_dirty(3, tile_index); } } @@ -882,17 +801,17 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b } // If any magic bits have been touched, mark every tilemap dirty - uint16_t tileflags[4]; + u16 tileflags[4]; tileflags[0] = m_videoregs[0x02] >> 16; tileflags[1] = m_videoregs[0x02] & 0xffff; tileflags[2] = m_videoregs[0x03] >> 16; tileflags[3] = m_videoregs[0x03] & 0xffff; - const uint16_t IMPORTANT_DIRTY_TILEFLAG_MASK = 0x0600; + const u16 IMPORTANT_DIRTY_TILEFLAG_MASK = 0x0600; for (int i = 0; i < 4; i++) { if ((m_old_tileflags[i] & IMPORTANT_DIRTY_TILEFLAG_MASK) != (tileflags[i] & IMPORTANT_DIRTY_TILEFLAG_MASK)) { - hng64_mark_all_tiles_dirty(i); + mark_all_tiles_dirty(i); m_old_tileflags[i] = tileflags[i]; } } @@ -908,13 +827,13 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b { for (int j = 0; j < 4; j++) { - uint16_t pri = get_tileregs(j) & 0x1f; + const u16 pri = get_tileregs(j) & 0x1f; if (pri == i) - hng64_drawtilemap(screen, bitmap, cliprect, j, 0, y); + draw_tilemap(screen, bitmap, cliprect, j, 0, y); } - if ((i&3) == 0) + if ((i & 3) == 0) mixsprites_test(screen, bitmap, cliprect, (i/4)<<12, y); } } @@ -931,19 +850,19 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b */ // 3d gets drawn next - uint16_t palbase = 0x000; - if (m_fbcontrol[2] & 0x20) + u16 palbase = 0x000; + if (BIT(m_fbcontrol[2], 5)) { if (!m_roadedge_3d_hack) palbase = 0x800; } rectangle visarea = m_screen->visible_area(); - int ysize = visarea.max_y - visarea.min_y; + const int ysize = visarea.max_y - visarea.min_y; if (ysize) { - int yinc = (512 << 16) / ysize; + const int yinc = (512 << 16) / ysize; pen_t const* const clut_3d = &m_palette_3d->pen(0); if (!(m_fbcontrol[0] & 0x01)) @@ -959,14 +878,14 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b // Blit the color buffer into the primary bitmap for (int y = cliprect.min_y; y <= cliprect.max_y; y++) { - int realy = (((y-visarea.min_y) * yinc) >> 16); + const int realy = (((y-visarea.min_y) * yinc) >> 16); - const uint16_t* src = &m_poly_renderer->colorBuffer3d()[((realy) & 0x1ff) * 512]; - uint32_t* dst = &bitmap.pix(y, cliprect.min_x); + const u16* src = &m_poly_renderer->colorBuffer3d()[((realy) & 0x1ff) * 512]; + u32* dst = &bitmap.pix(y, cliprect.min_x); for (int x = cliprect.min_x; x <= cliprect.max_x; x++) { - uint16_t srcpix = src[((cliprect.min_x + x) + xscroll) & 0x1ff]; + const u16 srcpix = src[((cliprect.min_x + x) + xscroll) & 0x1ff]; if (srcpix & 0x07ff) { // format in our framebuffer is llll appp pppp pppp @@ -974,7 +893,7 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b // our m_palette_3d has 16 copies of the palette at different brightness levels, so we can pass directly if (srcpix & 0x0800) { - *dst = alpha_blend_r32(*(uint32_t*)dst, clut_3d[(srcpix & 0xf7ff) | palbase], 0x80); + *dst = alpha_blend_r32(*(u32*)dst, clut_3d[(srcpix & 0xf7ff) | palbase], 0x80); } else { @@ -995,13 +914,13 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b { for (int j = 0; j < 4; j++) { - uint16_t pri = get_tileregs(j) & 0x1f; + const u16 pri = get_tileregs(j) & 0x1f; if (pri == i) - hng64_drawtilemap(screen, bitmap, cliprect, j, 0, y); + draw_tilemap(screen, bitmap, cliprect, j, 0, y); } - if ((i&3) == 0) + if ((i & 3) == 0) mixsprites_test(screen, bitmap, cliprect, (i/4)<<12, y); } } @@ -1222,10 +1141,10 @@ uint32_t hng64_state::screen_update_hng64(screen_device &screen, bitmap_rgb32 &b return 0; } -void hng64_state::screen_vblank_hng64(int state) +void hng64_state::screen_vblank(int state) { // rising edge and buffer swap - if (state && (m_tcram[0x50 / 4] & 0x10000)) + if (state && BIT(m_tcram[0x50 / 4], 16)) clear3d(); } @@ -1233,7 +1152,7 @@ void hng64_state::screen_vblank_hng64(int state) /* Transition Control Video Registers **OUTDATED, see notes with popmessage** * ---------------------------------- * - * uint32_t | Bits | Use + * u32 | Bits | Use * | 3322 2222 2222 1111 1111 11 | * -------+-1098-7654-3210-9876-5432-1098-7654-3210-+---------------- * 0 | | @@ -1271,12 +1190,11 @@ void hng64_state::screen_vblank_hng64(int state) -inline void hng64_state::set_palette_entry_with_faderegs(int entry, uint8_t r, uint8_t g, uint8_t b, uint32_t rgbfade, uint8_t r_mode, uint8_t g_mode, uint8_t b_mode, palette_device *palette) +inline void hng64_state::set_palette_entry_with_faderegs(int entry, u8 r, u8 g, u8 b, u32 rgbfade, u8 r_mode, u8 g_mode, u8 b_mode, palette_device *palette) { - - int r_fadeval = (rgbfade >> 16) & 0xff; - int g_fadeval = (rgbfade >> 8) & 0xff; - int b_fadeval = (rgbfade >> 0) & 0xff; + const int r_fadeval = (rgbfade >> 16) & 0xff; + const int g_fadeval = (rgbfade >> 8) & 0xff; + const int b_fadeval = (rgbfade >> 0) & 0xff; int r_new = r; int g_new = g; @@ -1342,7 +1260,7 @@ inline void hng64_state::set_palette_entry_with_faderegs(int entry, uint8_t r, u palette->set_pen_color(entry, r_new, g_new, b_new); } -inline void hng64_state::set_single_palette_entry(int entry, uint8_t r, uint8_t g, uint8_t b) +inline void hng64_state::set_single_palette_entry(int entry, u8 r, u8 g, u8 b) { m_palette->set_pen_color(entry, r, g, b); @@ -1357,9 +1275,9 @@ inline void hng64_state::set_single_palette_entry(int entry, uint8_t r, uint8_t // be multipled, reducing overall brightness, not increasing beyond max? for (int intensity = 0; intensity < 0x10; intensity++) { - uint16_t newr = r + (intensity << 2); - uint16_t newg = g + (intensity << 2); - uint16_t newb = b + (intensity << 2); + u16 newr = r + (intensity << 2); + u16 newg = g + (intensity << 2); + u16 newb = b + (intensity << 2); if (newr > 255) newr = 255; @@ -1378,15 +1296,15 @@ inline void hng64_state::set_single_palette_entry(int entry, uint8_t r, uint8_t void hng64_state::update_palette_entry(int entry) { - uint32_t data = m_paletteram[entry]; + const u32 data = m_paletteram[entry]; - int16_t r = (data >> 16) & 0xff; - int16_t g = (data >> 8) & 0xff; - int16_t b = (data >> 0) & 0xff; + s16 r = (data >> 16) & 0xff; + s16 g = (data >> 8) & 0xff; + s16 b = (data >> 0) & 0xff; for (int i = 0; i < 8; i++) { - uint32_t tcdata = m_tcram[(0x28 / 4) + i]; + const u32 tcdata = m_tcram[(0x28 / 4) + i]; // correct for buriki (jumbotron fading images) and xrally / roadedge (palette effect on front of car in first person view) // @@ -1396,15 +1314,15 @@ void hng64_state::update_palette_entry(int entry) // // ** this is instead meant to apply to the tm0 in fatfurwa, basically a full screen blended layer so IS being applied to the // correct palettes, it's currently a blend / priority issue causing it to not show - uint8_t tcregion = (tcdata & 0x0f000000) >> 24; + const u8 tcregion = (tcdata & 0x0f000000) >> 24; if (tcregion == (entry >> 8)) { - uint8_t bmod = (tcdata >> 16) & 0xff; - uint8_t gmod = (tcdata >> 8) & 0xff; - uint8_t rmod = (tcdata >> 0) & 0xff; + const u8 bmod = (tcdata >> 16) & 0xff; + const u8 gmod = (tcdata >> 8) & 0xff; + const u8 rmod = (tcdata >> 0) & 0xff; - uint8_t tcreg = (m_tcram[0x24 / 4] >> (i << 1)) & 3; + const u8 tcreg = (m_tcram[0x24 / 4] >> (i << 1)) & 3; switch (tcreg) { case 0x00: // this entry is disabled @@ -1440,28 +1358,26 @@ void hng64_state::update_palette_entry(int entry) set_single_palette_entry(entry, r, g, b); } -void hng64_state::pal_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::pal_w(offs_t offset, u32 data, u32 mem_mask) { COMBINE_DATA(&m_paletteram[offset]); update_palette_entry(offset); } // Transition Control memory. -void hng64_state::tcram_w(offs_t offset, uint32_t data, uint32_t mem_mask) +void hng64_state::tcram_w(offs_t offset, u32 data, u32 mem_mask) { - uint32_t *hng64_tcram = m_tcram; - - uint32_t old_data = hng64_tcram[offset]; - COMBINE_DATA(&hng64_tcram[offset]); + const u32 old_data = m_tcram[offset]; + COMBINE_DATA(&m_tcram[offset]); if (offset == 0x02) { rectangle visarea = m_screen->visible_area(); - const uint16_t min_x = (hng64_tcram[1] & 0xffff0000) >> 16; - const uint16_t min_y = (hng64_tcram[1] & 0x0000ffff) >> 0; - const uint16_t max_x = (hng64_tcram[2] & 0xffff0000) >> 16; - const uint16_t max_y = (hng64_tcram[2] & 0x0000ffff) >> 0; + const u16 min_x = (m_tcram[1] & 0xffff0000) >> 16; + const u16 min_y = (m_tcram[1] & 0x0000ffff) >> 0; + const u16 max_x = (m_tcram[2] & 0xffff0000) >> 16; + const u16 max_y = (m_tcram[2] & 0x0000ffff) >> 0; if (max_x == 0 || max_y == 0) // bail out if values are invalid, Fatal Fury WA sets this to disable the screen. { @@ -1485,17 +1401,17 @@ void hng64_state::tcram_w(offs_t offset, uint32_t data, uint32_t mem_mask) if ((offset >= (0x28 / 4)) && (offset < (0x48 / 4))) { - uint32_t new_data = hng64_tcram[offset]; + const u32 new_data = m_tcram[offset]; if (old_data != new_data) { // the old blend value no longer applies, so update the colours referenced by that - uint8_t old_tcregion = (old_data & 0x0f000000) >> 24; + u8 old_tcregion = (old_data & 0x0f000000) >> 24; for (int i = 0; i < 0x100; i++) { update_palette_entry((old_tcregion * 0x100) + i); } // update the colours referenced by the new blend register - uint8_t new_tcregion = (new_data & 0x0f000000) >> 24; + u8 new_tcregion = (new_data & 0x0f000000) >> 24; for (int i = 0; i < 0x100; i++) { update_palette_entry((new_tcregion * 0x100) + i); @@ -1506,7 +1422,7 @@ void hng64_state::tcram_w(offs_t offset, uint32_t data, uint32_t mem_mask) if ((offset == (0x24 / 4)) || (offset == (0x14 / 4)) || (offset == (0x18 / 4)) || (offset == (0x1c / 4))) { // lazy, just update the lot - uint32_t new_data = hng64_tcram[offset]; + const u32 new_data = m_tcram[offset]; if (old_data != new_data) { for (int i = 0; i < 0x1000; i++) @@ -1517,7 +1433,7 @@ void hng64_state::tcram_w(offs_t offset, uint32_t data, uint32_t mem_mask) } } -uint32_t hng64_state::tcram_r(offs_t offset) +u32 hng64_state::tcram_r(offs_t offset) { /* is this really a port? this seems treated like RAM otherwise, check if there's code anywhere to write the desired value here instead */ @@ -1537,21 +1453,21 @@ void hng64_state::video_start() m_old_tileflags[2] = -1; m_old_tileflags[3] = -1; - m_tilemap[0].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile0_8x8_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[0].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile0_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[0].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile0_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 + m_tilemap[0].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<0, 0>))), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[0].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<0, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[0].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<0, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 - m_tilemap[1].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile1_8x8_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[1].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile1_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[1].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile1_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 + m_tilemap[1].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<1, 0>))), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[1].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<1, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[1].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<1, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 - m_tilemap[2].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile2_8x8_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[2].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile2_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[2].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile2_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 + m_tilemap[2].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<2, 0>))), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[2].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<2, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[2].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<2, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 - m_tilemap[3].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile3_8x8_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[3].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile3_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 - m_tilemap[3].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(hng64_state::get_hng64_tile3_16x16_info)), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 + m_tilemap[3].m_tilemap_8x8 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<3, 0>))), TILEMAP_SCAN_ROWS, 8, 8, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[3].m_tilemap_16x16 = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<3, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); // 128x128x4 = 0x10000 + m_tilemap[3].m_tilemap_16x16_alt = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, NAME((&hng64_state::get_tile_info<3, 1>))), TILEMAP_SCAN_ROWS, 16, 16, 256, 64); // 128x128x4 = 0x10000 for (auto &elem : m_tilemap) { @@ -1564,11 +1480,11 @@ void hng64_state::video_start() m_poly_renderer = std::make_unique<hng64_poly_renderer>(*this); // 3d information - m_dl = std::make_unique<uint16_t[]>(0x100); + m_dl = std::make_unique<u16[]>(0x100); m_polys.resize(HNG64_MAX_POLYGONS); m_texturerom = memregion("textures0")->base(); - m_vertsrom = (uint16_t*)memregion("verts")->base(); + m_vertsrom = (u16 *)memregion("verts")->base(); m_vertsrom_size = memregion("verts")->bytes(); m_screen->register_screen_bitmap(m_sprite_bitmap); |
