Skip to content

Commit 25778ef

Browse files
authored
kaneko/kaneko_rlespr.cpp: Renamed Super Kaneko Nova sprite device and cleaned up code. (#15244)
Also fixed save state and debugger issues.
1 parent 1050207 commit 25778ef

9 files changed

Lines changed: 686 additions & 670 deletions

File tree

src/mame/kaneko/galpani3.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ Dumped by Uki
6464
*/
6565

6666
#include "emu.h"
67+
68+
#include "kaneko_grap2.h"
69+
#include "kaneko_rlespr.h"
70+
#include "kaneko_toybox.h"
71+
6772
#include "cpu/m68000/m68000.h"
6873
#include "machine/eepromser.h"
69-
#include "kaneko_toybox.h"
7074
#include "machine/timer.h"
7175
#include "machine/watchdog.h"
7276
#include "sound/ymz280b.h"
73-
#include "kaneko_grap2.h"
74-
#include "sknsspr.h"
77+
7578
#include "emupal.h"
7679
#include "screen.h"
7780
#include "speaker.h"
@@ -91,8 +94,7 @@ class galpani3_state : public driver_device
9194
m_paletteram(*this, "palette"),
9295
m_spriteram(*this, "spriteram"),
9396
m_priority_buffer(*this, "priority_buffer"),
94-
m_sprregs(*this, "sprregs"),
95-
m_sprite_bitmap(1024, 1024)
97+
m_sprregs(*this, "sprregs")
9698
{ }
9799

98100
void galpani3(machine_config &config) ATTR_COLD;
@@ -104,21 +106,20 @@ class galpani3_state : public driver_device
104106
required_device<cpu_device> m_maincpu;
105107
required_device_array<kaneko_grap2_device, 3> m_grap2;
106108
required_device<palette_device> m_palette;
107-
required_device<sknsspr_device> m_spritegen;
109+
required_device<kaneko_rlespr_device> m_spritegen;
108110

109111
required_shared_ptr<u16> m_paletteram;
110112
required_shared_ptr<u16> m_spriteram;
111113
required_shared_ptr<u16> m_priority_buffer;
112114
required_shared_ptr<u16> m_sprregs;
113115

114-
bitmap_ind16 m_sprite_bitmap;
115116
u16 m_priority_buffer_scrollx = 0;
116117
u16 m_priority_buffer_scrolly = 0;
117118
std::unique_ptr<u32 []> m_spriteram32;
118119
std::unique_ptr<u32 []> m_spc_regs;
119120

120-
void sprite32_w(offs_t offset, u16 data, u16 mem_mask = ~0);
121-
void sprite32regs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
121+
void spriteram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
122+
void spriteregs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
122123
void priority_buffer_scrollx_w(u16 data);
123124
void priority_buffer_scrolly_w(u16 data);
124125

@@ -153,9 +154,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(galpani3_state::scanline) // 2, 3, 5 ?
153154

154155
void galpani3_state::video_start()
155156
{
156-
/* so we can use kaneko/sknsspr.cpp */
157-
m_spritegen->skns_sprite_kludge(0,0);
158-
157+
/* so we can use kaneko/kaneko_rlespr.cpp */
159158
m_spriteram32 = make_unique_clear<u32 []>(0x4000 / 4);
160159
m_spc_regs = make_unique_clear<u32 []>(0x40 / 4);
161160

@@ -171,13 +170,13 @@ u32 galpani3_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, c
171170

172171
bitmap.fill(0, cliprect);
173172

174-
m_spritegen->skns_draw_sprites(m_sprite_bitmap, cliprect, m_spriteram32.get(), 0x4000, m_spc_regs.get());
173+
m_spritegen->draw_sprites(cliprect, m_spriteram32.get(), 0x4000, m_spc_regs.get());
175174

176175
// popmessage("%02x %02x", m_grap2[0]->framebuffer1_fbbright2_r(), m_grap2[1]->framebuffer1_fbbright2_r());
177176

178177
for (int drawy = cliprect.min_y; drawy <= cliprect.max_y; drawy++)
179178
{
180-
u16 const *const sprline = &m_sprite_bitmap.pix(drawy);
179+
u16 const *const sprline = &m_spritegen->bitmap().pix(drawy);
181180
u16 const *const srcline1 = m_grap2[0]->framebuffer() + ((drawy + m_grap2[0]->framebuffer_scrolly() + 11) & 0x1ff) * 0x200;
182181
u16 const *const srcline2 = m_grap2[1]->framebuffer() + ((drawy + m_grap2[1]->framebuffer_scrolly() + 11) & 0x1ff) * 0x200;
183182
u16 const *const srcline3 = m_grap2[2]->framebuffer() + ((drawy + m_grap2[2]->framebuffer_scrolly() + 11) & 0x1ff) * 0x200;
@@ -379,14 +378,14 @@ static INPUT_PORTS_START( galpani3 )
379378
INPUT_PORTS_END
380379

381380

382-
void galpani3_state::sprite32_w(offs_t offset, u16 data, u16 mem_mask)
381+
void galpani3_state::spriteram_w(offs_t offset, u16 data, u16 mem_mask)
383382
{
384383
COMBINE_DATA(&m_spriteram[offset]);
385384
offset >>= 1;
386385
m_spriteram32[offset] = (m_spriteram[offset * 2 + 1] << 16) | (m_spriteram[offset * 2]);
387386
}
388387

389-
void galpani3_state::sprite32regs_w(offs_t offset, u16 data, u16 mem_mask)
388+
void galpani3_state::spriteregs_w(offs_t offset, u16 data, u16 mem_mask)
390389
{
391390
COMBINE_DATA(&m_sprregs[offset]);
392391
offset >>= 1;
@@ -411,8 +410,8 @@ void galpani3_state::main_map(address_map &map)
411410
map(0x200000, 0x20ffff).ram(); // area [B] - Work RAM
412411
map(0x280000, 0x287fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // area [A] - palette for sprites
413412

414-
map(0x300000, 0x303fff).ram().w(FUNC(galpani3_state::sprite32_w)).share(m_spriteram);
415-
map(0x380000, 0x38003f).ram().w(FUNC(galpani3_state::sprite32regs_w)).share(m_sprregs);
413+
map(0x300000, 0x303fff).ram().w(FUNC(galpani3_state::spriteram_w)).share(m_spriteram);
414+
map(0x380000, 0x38003f).ram().w(FUNC(galpani3_state::spriteregs_w)).share(m_sprregs);
416415

417416
map(0x400000, 0x40ffff).ram().share("mcuram"); // area [C]
418417

@@ -465,7 +464,9 @@ void galpani3_state::galpani3(machine_config &config)
465464

466465
PALETTE(config, m_palette).set_format(palette_device::xGRB_555, 0x4000);
467466

468-
SKNS_SPRITE(config, m_spritegen, 0);
467+
KANEKO_RLESPR(config, m_spritegen, 0);
468+
m_spritegen->set_screen("screen");
469+
m_spritegen->set_sprite_kludge(0, 0);
469470

470471
KANEKO_GRAP2(config, m_grap2[0], 0).set_device_rom_tag("rlebg");
471472

src/mame/kaneko/jchan.cpp

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,18 @@ JC-301-00 W11 9510K7059 23C16000 U85
154154
*/
155155

156156
#include "emu.h"
157+
158+
#include "kaneko_rlespr.h"
159+
#include "kaneko_tmap.h"
160+
#include "kaneko_toybox.h"
161+
157162
#include "cpu/m68000/m68000.h"
158163
#include "machine/eepromser.h"
159164
#include "machine/nvram.h"
160165
#include "machine/timer.h"
161166
#include "machine/watchdog.h"
162167
#include "sound/ymz280b.h"
163-
#include "sknsspr.h"
164-
#include "kaneko_tmap.h"
165-
#include "kaneko_toybox.h"
168+
166169
#include "emupal.h"
167170
#include "screen.h"
168171
#include "speaker.h"
@@ -194,11 +197,14 @@ class jchan_state : public driver_device
194197

195198
void init_jchan();
196199

200+
protected:
201+
virtual void video_start() override ATTR_COLD;
202+
197203
private:
198204
required_device<cpu_device> m_maincpu;
199205
required_device<cpu_device> m_subcpu;
200206
required_device<palette_device> m_palette;
201-
required_device_array<sknsspr_device, 2> m_spritegen;
207+
required_device_array<kaneko_rlespr_device, 2> m_spritegen;
202208
required_device<kaneko_view2_tilemap_device> m_view2;
203209

204210
required_shared_ptr_array<u16, 2> m_spriteram;
@@ -211,24 +217,21 @@ class jchan_state : public driver_device
211217
required_ioport m_io_system;
212218
required_ioport m_io_extra;
213219

214-
std::unique_ptr<bitmap_ind16> m_sprite_bitmap[2];
215220
std::unique_ptr<u32[]> m_sprite_ram32[2];
216221
std::unique_ptr<u32[]> m_sprite_regs32[2];
217-
int m_irq_sub_enable;
222+
bool m_irq_sub_enable = false;
218223

219224
void ctrl_w(u16 data);
220225
u16 ctrl_r(offs_t offset);
221226
void main2sub_cmd_w(offs_t offset, u16 data, u16 mem_mask = ~0);
222227
void sub2main_cmd_w(offs_t offset, u16 data, u16 mem_mask = ~0);
223-
template<int Chip> void sknsspr_sprite32regs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
224-
225-
virtual void video_start() override ATTR_COLD;
228+
template<int Chip> void spriteregs_w(offs_t offset, u16 data, u16 mem_mask = ~0);
226229

227230
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
228231

229232
TIMER_DEVICE_CALLBACK_MEMBER(vblank);
230-
void jchan_main(address_map &map) ATTR_COLD;
231-
void jchan_sub(address_map &map) ATTR_COLD;
233+
void main_map(address_map &map) ATTR_COLD;
234+
void sub_map(address_map &map) ATTR_COLD;
232235
};
233236

234237

@@ -280,7 +283,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(jchan_state::vblank)
280283

281284
void jchan_state::video_start()
282285
{
283-
/* so we can use sknsspr.cpp */
286+
/* so we can use kaneko/kaneko_rlespr.cpp */
284287
for (int chip = 0; chip < 2; chip++)
285288
{
286289
const u32 size = m_spriteram[chip].bytes() / 4;
@@ -291,12 +294,6 @@ void jchan_state::video_start()
291294
m_sprite_regs32[0] = std::make_unique<u32[]>(0x40/4);
292295
m_sprite_regs32[1] = std::make_unique<u32[]>(0x40/4);
293296

294-
m_sprite_bitmap[0] = std::make_unique<bitmap_ind16>(1024,1024);
295-
m_sprite_bitmap[1] = std::make_unique<bitmap_ind16>(1024,1024);
296-
297-
m_spritegen[0]->skns_sprite_kludge(0,0);
298-
m_spritegen[1]->skns_sprite_kludge(0,0);
299-
300297
save_item(NAME(m_irq_sub_enable));
301298
save_pointer(NAME(m_sprite_regs32[0]), 0x40/4);
302299
save_pointer(NAME(m_sprite_regs32[1]), 0x40/4);
@@ -318,16 +315,16 @@ u32 jchan_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, cons
318315

319316
for (int chip = 0; chip < 2; chip++)
320317
{
321-
m_spritegen[chip]->skns_draw_sprites(*m_sprite_bitmap[chip], cliprect, m_sprite_ram32[chip].get(), 0x4000, m_sprite_regs32[chip].get());
318+
m_spritegen[chip]->draw_sprites(cliprect, m_sprite_ram32[chip].get(), 0x4000, m_sprite_regs32[chip].get());
322319
}
323320

324321
bitmap_ind8 *tile_primap = &screen.priority();
325322

326323
// TODO : verify sprite-tile priorities from real hardware, Check what 15 bit of palette actually working
327324
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
328325
{
329-
u16 const *const src1 = &m_sprite_bitmap[0]->pix(y);
330-
u16 const *const src2 = &m_sprite_bitmap[1]->pix(y);
326+
u16 const *const src1 = &m_spritegen[0]->bitmap().pix(y);
327+
u16 const *const src2 = &m_spritegen[1]->bitmap().pix(y);
331328
u8 *const tilepri = &tile_primap->pix(y);
332329
u16 *const dst = &bitmap.pix(y);
333330

@@ -408,7 +405,7 @@ u32 jchan_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, cons
408405

409406
void jchan_state::ctrl_w(u16 data)
410407
{
411-
m_irq_sub_enable = data & 0x8000; // hack / guess!
408+
m_irq_sub_enable = BIT(data, 15); // hack / guess!
412409
}
413410

414411
u16 jchan_state::ctrl_r(offs_t offset)
@@ -419,7 +416,10 @@ u16 jchan_state::ctrl_r(offs_t offset)
419416
case 2/2: return m_io_p2->read();
420417
case 4/2: return m_io_system->read();
421418
case 6/2: return m_io_extra->read();
422-
default: logerror("ctrl_r unknown!"); break;
419+
default:
420+
if (!machine().side_effects_disabled())
421+
logerror("%s: ctrl_r unknown!", machine().describe_context());
422+
break;
423423
}
424424
return m_ctrl[offset];
425425
}
@@ -446,15 +446,15 @@ void jchan_state::sub2main_cmd_w(offs_t offset, u16 data, u16 mem_mask)
446446

447447
/* ram convert for suprnova (requires 32-bit stuff) */
448448
template<int Chip>
449-
void jchan_state::sknsspr_sprite32regs_w(offs_t offset, u16 data, u16 mem_mask)
449+
void jchan_state::spriteregs_w(offs_t offset, u16 data, u16 mem_mask)
450450
{
451451
COMBINE_DATA(&m_sprregs[Chip][offset]);
452452
offset >>= 1;
453453
m_sprite_regs32[Chip][offset] = (m_sprregs[Chip][offset * 2 + 1] << 16) | (m_sprregs[Chip][offset * 2]);
454454
}
455455

456456

457-
void jchan_state::jchan_main(address_map &map)
457+
void jchan_state::main_map(address_map &map)
458458
{
459459
map(0x000000, 0x1fffff).rom();
460460
map(0x200000, 0x20ffff).ram(); // Work RAM - [A] grid tested, cleared ($9d6-$a54)
@@ -470,7 +470,7 @@ void jchan_state::jchan_main(address_map &map)
470470

471471
/* 1st sprite layer */
472472
map(0x500000, 0x503fff).ram().share("spriteram_1");
473-
map(0x600000, 0x60003f).ram().w(FUNC(jchan_state::sknsspr_sprite32regs_w<0>)).share("sprregs_1");
473+
map(0x600000, 0x60003f).ram().w(FUNC(jchan_state::spriteregs_w<0>)).share("sprregs_1");
474474

475475
map(0x700000, 0x70ffff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // palette
476476

@@ -480,7 +480,7 @@ void jchan_state::jchan_main(address_map &map)
480480
}
481481

482482

483-
void jchan_state::jchan_sub(address_map &map)
483+
void jchan_state::sub_map(address_map &map)
484484
{
485485
map(0x000000, 0x0fffff).rom();
486486
map(0x100000, 0x10ffff).ram(); // Work RAM - grid tested, cleared ($612-$6dc)
@@ -493,7 +493,7 @@ void jchan_state::jchan_sub(address_map &map)
493493

494494
/* background sprites */
495495
map(0x700000, 0x703fff).ram().share("spriteram_2");
496-
map(0x780000, 0x78003f).ram().w(FUNC(jchan_state::sknsspr_sprite32regs_w<1>)).share("sprregs_2");
496+
map(0x780000, 0x78003f).ram().w(FUNC(jchan_state::spriteregs_w<1>)).share("sprregs_2");
497497

498498
map(0x800000, 0x800003).w("ymz", FUNC(ymz280b_device::write)).umask16(0x00ff); // sound
499499

@@ -590,11 +590,11 @@ INPUT_PORTS_END
590590
void jchan_state::jchan(machine_config &config)
591591
{
592592
M68000(config, m_maincpu, 16000000);
593-
m_maincpu->set_addrmap(AS_PROGRAM, &jchan_state::jchan_main);
593+
m_maincpu->set_addrmap(AS_PROGRAM, &jchan_state::main_map);
594594
TIMER(config, "scantimer").configure_scanline(FUNC(jchan_state::vblank), "screen", 0, 1);
595595

596596
M68000(config, m_subcpu, 16000000);
597-
m_subcpu->set_addrmap(AS_PROGRAM, &jchan_state::jchan_sub);
597+
m_subcpu->set_addrmap(AS_PROGRAM, &jchan_state::sub_map);
598598

599599
WATCHDOG_TIMER(config, "watchdog");
600600

@@ -611,7 +611,11 @@ void jchan_state::jchan(machine_config &config)
611611
m_view2->set_palette(m_palette);
612612

613613
for (auto &spritegen : m_spritegen)
614-
SKNS_SPRITE(config, spritegen, 0);
614+
{
615+
KANEKO_RLESPR(config, spritegen, 0);
616+
spritegen->set_screen("screen");
617+
spritegen->set_sprite_kludge(0, 0);
618+
}
615619

616620
KANEKO_TOYBOX(config, "toybox", "eeprom", "DSW1", "mcuram", "mcudata");
617621

0 commit comments

Comments
 (0)