From 3ea0df952c62d00b41a7a8e031d52fd68f9fef1b Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Oct 2025 23:25:13 +0900 Subject: [PATCH] snk/hng64.cpp: Further cleanups from https://github.com/mamedev/mame/pull/14275 - Fix error in required_region_ptr - Move logmacro include in ipp file into hng64_v.cpp - Fix possibly transparent pen issue - Make some variables constant - Minor optimization - Reduce duplicates - Use BIT for single bit values --- src/mame/snk/hng64.h | 2 +- src/mame/snk/hng64_3d.ipp | 14 -------------- src/mame/snk/hng64_sprite.ipp | 31 ++++++++++--------------------- src/mame/snk/hng64_v.cpp | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 36 deletions(-) diff --git a/src/mame/snk/hng64.h b/src/mame/snk/hng64.h index 33f3eb83ee45c..6bbe82131223c 100644 --- a/src/mame/snk/hng64.h +++ b/src/mame/snk/hng64.h @@ -161,7 +161,7 @@ class hng64_state : public driver_device m_mainram(*this, "mainram"), m_cart(*this, "gameprg"), m_sysregs(*this, "sysregs"), - m_rombase(*this, "user1"), + m_rombase(*this, "bios"), m_spriteram(*this, "spriteram"), m_spriteregs(*this, "spriteregs"), m_videoram(*this, "videoram"), diff --git a/src/mame/snk/hng64_3d.ipp b/src/mame/snk/hng64_3d.ipp index 1ab4bf9467dce..f7b298514ec14 100644 --- a/src/mame/snk/hng64_3d.ipp +++ b/src/mame/snk/hng64_3d.ipp @@ -5,20 +5,6 @@ /// 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(state.machine()) diff --git a/src/mame/snk/hng64_sprite.ipp b/src/mame/snk/hng64_sprite.ipp index bcb13e3c1cae9..377aa7e749cca 100644 --- a/src/mame/snk/hng64_sprite.ipp +++ b/src/mame/snk/hng64_sprite.ipp @@ -101,12 +101,12 @@ do \ if (curx & 1) \ { \ if (!(ypos & 1)) \ - srcpix = 0; \ + srcpix = trans_pen; \ } \ else \ { \ if ((ypos & 1)) \ - srcpix = 0; \ + srcpix = trans_pen; \ } \ } \ } \ @@ -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); - s32 destendx = xpos + dstwidth - 1; - u32 leftovers = (destendx + 1 - xpos); + const s32 destendx = xpos + dstwidth - 1; + const u32 leftovers = (destendx + 1 - xpos); drawline(dest, destz, cliprect, gfx, code, color, flipy, xpos, @@ -221,7 +221,7 @@ inline void hng64_state::get_tile_details(bool chain, u16 spritenum, u8 xtile, u tileno = (m_spriteram[(spritenum * 8) + 4] & 0x0007ffff); pal = (m_spriteram[(spritenum * 8) + 3] & 0x00ff0000) >> 16; - if (m_spriteregs[0] & 0x00800000) //bpp switch + if (BIT(m_spriteregs[0], 23)) //bpp switch { gfxregion = 4; } @@ -238,7 +238,7 @@ inline void hng64_state::get_tile_details(bool chain, u16 spritenum, u8 xtile, u { tileno = (m_spriteram[((spritenum + offset) * 8) + 4] & 0x0007ffff); pal = (m_spriteram[((spritenum + offset) * 8) + 3] & 0x00ff0000) >> 16; - if (m_spriteregs[0] & 0x00800000) //bpp switch + if (BIT(m_spriteregs[0], 23)) //bpp switch { gfxregion = 4; } @@ -263,7 +263,7 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl // 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? - const bool zsort = !(m_spriteregs[0] & 0x01000000); + const bool zsort = BIT(~m_spriteregs[0], 24); if (zsort) m_sprite_zbuffer.fill(0x0000, cliprect); @@ -313,7 +313,7 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl const u32 zoomx = (m_spriteram[(currentsprite * 8) + 1] & 0x0000ffff) >> 0; /* Calculate the zoom */ - int zoom_factor = (m_spriteregs[0] & 0x08000000) ? 0x1000 : 0x100; + const u8 zoom_shift = BIT(m_spriteregs[0], 27) ? 4 : 8; /* Sprites after 'Fair and Square' have a zoom of 0 in sams64 for one frame, they shouldn't be seen? */ if (!zoomx || !zoomy) @@ -334,19 +334,8 @@ void hng64_state::draw_sprites_buffer(screen_device& screen, const rectangle& cl continue; } - s32 dx, dy; - - if (zoom_factor == 0x100) - { - dx = zoomx << 8; - dy = zoomy << 8; - } - else - { - dx = zoomx << 4; - dy = zoomy << 4; - } - + const s32 dx = zoomx << zoom_shift; + const s32 dy = zoomy << zoom_shift; u32 full_srcpix_y = 0; u32 full_dstheight = 0; diff --git a/src/mame/snk/hng64_v.cpp b/src/mame/snk/hng64_v.cpp index 4874fae2fad40..14c6a3615b30a 100644 --- a/src/mame/snk/hng64_v.cpp +++ b/src/mame/snk/hng64_v.cpp @@ -3,6 +3,20 @@ #include "emu.h" #include "hng64.h" +#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__) + /* final mix can clearly only process 2 possibilities for any screen pixel; a 'top' and 'bottom' pixel option one of those can be blended.