jedi.cpp : Updates

Simplify handlers, Add gfxdecode for debug, Add palette_device for palette handling, Reduce runtime tag lookups, Fix some drawing routines, Reduce unnecessary lines, Fix namings, Spacings, Use shorter / correct type values, Add notes
This commit is contained in:
cam900 2019-06-03 15:59:43 +09:00
parent 2d48854ecc
commit 06a52b45db
4 changed files with 202 additions and 157 deletions

View File

@ -22,7 +22,7 @@
*
*************************************/
WRITE8_MEMBER(jedi_state::irq_ack_w)
void jedi_state::irq_ack_w(u8 data)
{
m_audiocpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
}
@ -43,7 +43,7 @@ WRITE_LINE_MEMBER(jedi_state::audio_reset_w)
}
READ8_MEMBER(jedi_state::audio_comm_stat_r)
u8 jedi_state::audio_comm_stat_r()
{
return (m_soundlatch->pending_r() << 7) | (m_sacklatch->pending_r() << 6);
}
@ -62,19 +62,19 @@ CUSTOM_INPUT_MEMBER(jedi_state::jedi_audio_comm_stat_r)
*
*************************************/
WRITE8_MEMBER(jedi_state::speech_strobe_w)
void jedi_state::speech_strobe_w(offs_t offset, u8 data)
{
m_tms->wsq_w(BIT(offset, 8));
}
READ8_MEMBER(jedi_state::speech_ready_r)
u8 jedi_state::speech_ready_r()
{
return m_tms->readyq_r() << 7;
}
WRITE8_MEMBER(jedi_state::speech_reset_w)
void jedi_state::speech_reset_w(u8 data)
{
// Flip-flop at 8C controls the power supply to the TMS5220 (through transistors Q6 and Q7)
m_tms->set_output_gain(ALL_OUTPUTS, BIT(data, 0) ? 1.0 : 0.0);

View File

@ -121,7 +121,6 @@
#include "includes/jedi.h"
/*************************************
*
* Interrupt handling
@ -144,13 +143,12 @@ TIMER_CALLBACK_MEMBER(jedi_state::generate_interrupt)
}
WRITE8_MEMBER(jedi_state::main_irq_ack_w)
void jedi_state::main_irq_ack_w(u8 data)
{
m_maincpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
}
/*************************************
*
* Start
@ -164,11 +162,10 @@ void jedi_state::machine_start()
m_interrupt_timer->adjust(m_screen->time_until_pos(32), 32);
/* configure the banks */
membank("bank1")->configure_entries(0, 3, memregion("maincpu")->base() + 0x10000, 0x4000);
m_mainbank->configure_entries(0, 3, memregion("maincpu")->base() + 0x10000, 0x4000);
}
/*************************************
*
* Reset
@ -182,22 +179,20 @@ void jedi_state::machine_reset()
}
/*************************************
*
* Main program ROM banking
*
*************************************/
WRITE8_MEMBER(jedi_state::rom_banksel_w)
void jedi_state::rom_banksel_w(u8 data)
{
if (data & 0x01) membank("bank1")->set_entry(0);
if (data & 0x02) membank("bank1")->set_entry(1);
if (data & 0x04) membank("bank1")->set_entry(2);
if (data & 0x01) m_mainbank->set_entry(0);
if (data & 0x02) m_mainbank->set_entry(1);
if (data & 0x04) m_mainbank->set_entry(2);
}
/*************************************
*
* I/O ports
@ -216,7 +211,6 @@ WRITE_LINE_MEMBER(jedi_state::coin_counter_right_w)
}
/*************************************
*
* X2212-30 NOVRAM
@ -236,14 +230,14 @@ WRITE8_MEMBER(jedi_state::novram_data_w)
}
WRITE8_MEMBER(jedi_state::novram_recall_w)
void jedi_state::novram_recall_w(offs_t offset, u8 data)
{
m_novram[0]->recall(BIT(offset, 0));
m_novram[1]->recall(BIT(offset, 0));
}
WRITE8_MEMBER(jedi_state::novram_store_w)
void jedi_state::novram_store_w(u8 data)
{
m_novram[0]->store(1);
m_novram[1]->store(1);
@ -252,7 +246,6 @@ WRITE8_MEMBER(jedi_state::novram_store_w)
}
/*************************************
*
* Main CPU memory handlers
@ -277,18 +270,18 @@ void jedi_state::main_map(address_map &map)
map(0x1f00, 0x1f00).mirror(0x007f).nopr().w("soundlatch", FUNC(generic_latch_8_device::write));
map(0x1f80, 0x1f80).mirror(0x007f).nopr().w(FUNC(jedi_state::rom_banksel_w));
map(0x2000, 0x27ff).ram().share("backgroundram");
map(0x2800, 0x2fff).ram().share("paletteram");
map(0x2800, 0x2bff).ram().w(m_palette, FUNC(palette_device::write8)).share("palette");
map(0x2c00, 0x2fff).ram().w(m_palette, FUNC(palette_device::write8_ext)).share("palette_ext");
map(0x3000, 0x37bf).ram().share("foregroundram");
map(0x37c0, 0x3bff).ram().share("spriteram");
map(0x3c00, 0x3c01).mirror(0x00fe).nopr().w(FUNC(jedi_state::jedi_vscroll_w));
map(0x3d00, 0x3d01).mirror(0x00fe).nopr().w(FUNC(jedi_state::jedi_hscroll_w));
map(0x3c00, 0x3c01).mirror(0x00fe).nopr().w(FUNC(jedi_state::vscroll_w));
map(0x3d00, 0x3d01).mirror(0x00fe).nopr().w(FUNC(jedi_state::hscroll_w));
map(0x3e00, 0x3e00).mirror(0x01ff).writeonly().share("smoothing_table");
map(0x4000, 0x7fff).bankr("bank1");
map(0x4000, 0x7fff).bankr("mainbank");
map(0x8000, 0xffff).rom();
}
/*************************************
*
* Port definitions
@ -321,7 +314,6 @@ static INPUT_PORTS_START( jedi )
INPUT_PORTS_END
/*************************************
*
* Machine driver
@ -364,7 +356,6 @@ void jedi_state::jedi(machine_config &config)
}
/*************************************
*
* ROM definitions
@ -383,14 +374,14 @@ ROM_START( jedi )
ROM_LOAD( "136030-133.01c", 0x8000, 0x4000, CRC(6c601c69) SHA1(618b77800bbbb4db34a53ca974a71bdaf89b5930) )
ROM_LOAD( "136030-134.01a", 0xC000, 0x4000, CRC(5e36c564) SHA1(4b0afceb9a1d912f1d5c1f26928d244d5b14ea4a) )
ROM_REGION( 0x02000, "gfx1",0 )
ROM_REGION( 0x02000, "tx_gfx",0 )
ROM_LOAD( "136030-215.11t", 0x00000, 0x2000, CRC(3e49491f) SHA1(ade5e846069c2fa6edf667469d13ce5a6a45c06d) ) /* Alphanumeric */
ROM_REGION( 0x10000, "gfx2",0 )
ROM_REGION( 0x10000, "bg_gfx",0 )
ROM_LOAD( "136030-126.06r", 0x00000, 0x8000, CRC(9c55ece8) SHA1(b8faa23314bb0d199ef46199bfabd9cb17510dd3) ) /* Playfield */
ROM_LOAD( "136030-127.06n", 0x08000, 0x8000, CRC(4b09dcc5) SHA1(d46b5f4fb69c4b8d823dd9c4d92f8713badfa44a) )
ROM_REGION( 0x20000, "gfx3", 0 )
ROM_REGION( 0x20000, "spr_gfx", 0 )
ROM_LOAD( "136030-130.01h", 0x00000, 0x8000, CRC(2646a793) SHA1(dcb5fd50eafbb27565bce099a884be83a9d82285) ) /* Sprites */
ROM_LOAD( "136030-131.01f", 0x08000, 0x8000, CRC(60107350) SHA1(ded03a46996d3f2349df7f59fd435a7ad6ed465e) )
ROM_LOAD( "136030-128.01m", 0x10000, 0x8000, CRC(24663184) SHA1(5eba142ed926671ee131430944e59f21a55a5c57) )
@ -410,7 +401,6 @@ ROM_START( jedi )
ROM_END
/*************************************
*
* Game drivers

View File

@ -13,8 +13,10 @@
#include "machine/gen_latch.h"
#include "machine/x2212.h"
#include "sound/tms5220.h"
#include "emupal.h"
#include "screen.h"
#define DEBUG_GFXDECODE 0 // GFX layout for debug
/* oscillators and clocks */
#define JEDI_MAIN_CPU_OSC (XTAL(10'000'000))
@ -31,47 +33,57 @@ public:
jedi_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_backgroundram(*this, "backgroundram"),
m_paletteram(*this, "paletteram"),
m_foregroundram(*this, "foregroundram"),
m_spriteram(*this, "spriteram"),
m_smoothing_table(*this, "smoothing_table"),
m_tx_gfx(*this, "tx_gfx"),
m_bg_gfx(*this, "bg_gfx"),
m_spr_gfx(*this, "spr_gfx"),
m_proms(*this, "proms"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_soundlatch(*this, "soundlatch"),
m_sacklatch(*this, "sacklatch"),
m_tms(*this, "tms"),
m_novram(*this, "novram12%c", 'b'),
m_screen(*this, "screen")
#ifdef DEBUG_GFXDECODE
m_gfxdecode(*this, "gfxdecode"),
#endif
m_palette(*this, "palette"),
m_screen(*this, "screen"),
m_mainbank(*this, "mainbank")
{ }
DECLARE_CUSTOM_INPUT_MEMBER(jedi_audio_comm_stat_r);
void jedi(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
DECLARE_WRITE8_MEMBER(main_irq_ack_w);
DECLARE_WRITE8_MEMBER(rom_banksel_w);
void main_irq_ack_w(u8 data);
void rom_banksel_w(u8 data);
DECLARE_WRITE_LINE_MEMBER(coin_counter_left_w);
DECLARE_WRITE_LINE_MEMBER(coin_counter_right_w);
DECLARE_READ8_MEMBER(novram_data_r);
DECLARE_WRITE8_MEMBER(novram_data_w);
DECLARE_WRITE8_MEMBER(novram_recall_w);
DECLARE_WRITE8_MEMBER(novram_store_w);
DECLARE_WRITE8_MEMBER(jedi_vscroll_w);
DECLARE_WRITE8_MEMBER(jedi_hscroll_w);
DECLARE_WRITE8_MEMBER(irq_ack_w);
void novram_recall_w(offs_t offset, u8 data);
void novram_store_w(u8 data);
void vscroll_w(offs_t offset, u8 data);
void hscroll_w(offs_t offset, u8 data);
void irq_ack_w(u8 data);
DECLARE_WRITE_LINE_MEMBER(audio_reset_w);
DECLARE_READ8_MEMBER(audio_comm_stat_r);
DECLARE_WRITE8_MEMBER(speech_strobe_w);
DECLARE_READ8_MEMBER(speech_ready_r);
DECLARE_WRITE8_MEMBER(speech_reset_w);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
u8 audio_comm_stat_r();
void speech_strobe_w(offs_t offset, u8 data);
u8 speech_ready_r();
void speech_reset_w(u8 data);
DECLARE_WRITE_LINE_MEMBER(foreground_bank_w);
DECLARE_WRITE_LINE_MEMBER(video_off_w);
uint32_t screen_update_jedi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
TIMER_CALLBACK_MEMBER(generate_interrupt);
void get_pens(pen_t *pens);
static rgb_t jedi_IRGB_3333(u32 raw);
void do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect);
void draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle &cliprect);
void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect);
@ -84,13 +96,16 @@ private:
emu_timer *m_interrupt_timer;
/* video state */
required_shared_ptr<uint8_t> m_backgroundram;
required_shared_ptr<uint8_t> m_paletteram;
required_shared_ptr<uint8_t> m_foregroundram;
required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_smoothing_table;
uint32_t m_vscroll;
uint32_t m_hscroll;
required_shared_ptr<u8> m_backgroundram;
required_shared_ptr<u8> m_foregroundram;
required_shared_ptr<u8> m_spriteram;
required_shared_ptr<u8> m_smoothing_table;
required_region_ptr<u8> m_tx_gfx;
required_region_ptr<u8> m_bg_gfx;
required_region_ptr<u8> m_spr_gfx;
required_region_ptr<u8> m_proms;
u32 m_vscroll;
u32 m_hscroll;
bool m_foreground_bank;
bool m_video_off;
@ -100,7 +115,12 @@ private:
required_device<generic_latch_8_device> m_sacklatch;
required_device<tms5220_device> m_tms;
required_device_array<x2212_device, 2> m_novram;
#ifdef DEBUG_GFXDECODE
required_device<gfxdecode_device> m_gfxdecode;
#endif
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
required_memory_bank m_mainbank;
};
#endif // MAME_INCLUDES_JEDI_H

View File

@ -19,9 +19,7 @@
#include "emu.h"
#include "includes/jedi.h"
#define NUM_PENS (0x1000)
#include <algorithm>
/*************************************
@ -32,6 +30,37 @@
void jedi_state::video_start()
{
#ifdef DEBUG_GFXDECODE
/* the sprite pixel determines pen address bits A4-A7 */
gfx_element *gx0 = m_gfxdecode->gfx(2);
// allocate memory for the assembled data
u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
// loop over elements
u8 *dest = srcdata;
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
// loop over height
for (int y = 0; y < gx0->height(); y++)
{
const u8 *c0 = c0base;
for (int x = 0; x < gx0->width(); x++)
{
const u8 pix = (*c0++ & 0xf);
*dest++ = pix << 4;
}
c0base += gx0->rowbytes();
}
}
gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_granularity(1);
#endif
/* register for saving */
save_item(NAME(m_vscroll));
save_item(NAME(m_hscroll));
@ -78,62 +107,45 @@ WRITE_LINE_MEMBER(jedi_state::video_off_w)
*
*************************************/
void jedi_state::get_pens(pen_t *pens)
rgb_t jedi_state::jedi_IRGB_3333(u32 raw)
{
offs_t offs;
const u8 intensity = (raw >> 9) & 7;
u8 bits = (raw >> 6) & 7;
const u8 r = 5 * bits * intensity;
bits = (raw >> 3) & 7;
const u8 g = 5 * bits * intensity;
bits = (raw >> 0) & 7;
const u8 b = 5 * bits * intensity;
for (offs = 0; offs < NUM_PENS; offs++)
{
int r, g, b, bits, intensity;
uint16_t color = m_paletteram[offs] | (m_paletteram[offs | 0x400] << 8);
intensity = (color >> 9) & 7;
bits = (color >> 6) & 7;
r = 5 * bits * intensity;
bits = (color >> 3) & 7;
g = 5 * bits * intensity;
bits = (color >> 0) & 7;
b = 5 * bits * intensity;
pens[offs] = rgb_t(r, g, b);
}
return rgb_t(r, g, b);
}
void jedi_state::do_pen_lookup(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
int y, x;
pen_t pens[NUM_PENS];
get_pens(pens);
for (y = cliprect.top(); y <= cliprect.bottom(); y++)
for(x = cliprect.left(); x <= cliprect.right(); x++)
bitmap.pix32(y, x) = pens[bitmap.pix32(y, x)];
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
for(int x = cliprect.left(); x <= cliprect.right(); x++)
bitmap.pix32(y, x) = m_palette->pen(bitmap.pix32(y, x));
}
/*************************************
*
* Scroll offsets
*
*************************************/
WRITE8_MEMBER(jedi_state::jedi_vscroll_w)
void jedi_state::vscroll_w(offs_t offset, u8 data)
{
m_vscroll = data | (offset << 8);
}
WRITE8_MEMBER(jedi_state::jedi_hscroll_w)
void jedi_state::hscroll_w(offs_t offset, u8 data)
{
m_hscroll = data | (offset << 8);
}
/*************************************
*
* Background/text layer drawing
@ -143,44 +155,32 @@ WRITE8_MEMBER(jedi_state::jedi_hscroll_w)
void jedi_state::draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
int y;
int background_line_buffer[0x200]; /* RAM chip at 2A */
u8 background_line_buffer[0x200]; /* RAM chip at 2A */
uint8_t *tx_gfx = memregion("gfx1")->base();
uint8_t *bg_gfx = memregion("gfx2")->base();
uint8_t *prom1 = &memregion("proms")->base()[0x0000 | ((*m_smoothing_table & 0x03) << 8)];
uint8_t *prom2 = &memregion("proms")->base()[0x0800 | ((*m_smoothing_table & 0x03) << 8)];
int vscroll = m_vscroll;
int hscroll = m_hscroll;
int tx_bank = m_foreground_bank;
uint8_t *tx_ram = m_foregroundram;
uint8_t *bg_ram = m_backgroundram;
const u8 *prom1 = &m_proms[0x0000 | ((*m_smoothing_table & 0x03) << 8)];
const u8 *prom2 = &m_proms[0x0800 | ((*m_smoothing_table & 0x03) << 8)];
memset(background_line_buffer, 0, 0x200 * sizeof(int));
std::fill(std::begin(background_line_buffer), std::end(background_line_buffer), 0);
for (y = cliprect.top(); y <= cliprect.bottom(); y++)
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
int x;
int bg_last_col = 0;
u8 bg_last_col = 0;
for (x = cliprect.left(); x <= cliprect.right(); x += 2)
for (int x = cliprect.left(); x <= cliprect.right(); x += 2)
{
int tx_col1, tx_col2, bg_col;
int bg_tempcol;
offs_t tx_gfx_offs, bg_gfx_offs;
int tx_data, bg_data1, bg_data2;
u16 tx_col1, tx_col2, bg_col;
int sy = y + vscroll;
int sx = x + hscroll;
const int sy = y + m_vscroll;
int sx = x + m_hscroll;
/* determine offsets into video memory */
offs_t tx_offs = ((y & 0xf8) << 3) | (x >> 3);
offs_t bg_offs = ((sy & 0x1f0) << 1) | ((sx & 0x1f0) >> 4);
const offs_t tx_offs = ((y & 0xf8) << 3) | (x >> 3);
const offs_t bg_offs = ((sy & 0x1f0) << 1) | ((sx & 0x1f0) >> 4);
/* get the character codes */
int tx_code = (tx_bank << 8) | tx_ram[tx_offs];
int bg_bank = bg_ram[0x0400 | bg_offs];
int bg_code = bg_ram[0x0000 | bg_offs] |
const int tx_code = (m_foreground_bank << 8) | m_foregroundram[tx_offs];
const int bg_bank = m_backgroundram[0x0400 | bg_offs];
const int bg_code = m_backgroundram[0x0000 | bg_offs] |
((bg_bank & 0x01) << 8) |
((bg_bank & 0x08) << 6) |
((bg_bank & 0x02) << 9);
@ -190,24 +190,24 @@ void jedi_state::draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle
sx = sx ^ 0x0f;
/* calculate the address of the gfx data */
tx_gfx_offs = (tx_code << 4) | ((y & 0x07) << 1) | ((( x & 0x04) >> 2));
bg_gfx_offs = (bg_code << 4) | (sy & 0x0e) | (((sx & 0x08) >> 3));
const offs_t tx_gfx_offs = (tx_code << 4) | ((y & 0x07) << 1) | ((( x & 0x04) >> 2));
const offs_t bg_gfx_offs = (bg_code << 4) | (sy & 0x0e) | (((sx & 0x08) >> 3));
/* get the gfx data */
tx_data = tx_gfx[ tx_gfx_offs];
bg_data1 = bg_gfx[0x0000 | bg_gfx_offs];
bg_data2 = bg_gfx[0x8000 | bg_gfx_offs];
const u8 tx_data = m_tx_gfx[ tx_gfx_offs];
const u8 bg_data1 = m_bg_gfx[0x0000 | bg_gfx_offs];
const u8 bg_data2 = m_bg_gfx[0x8000 | bg_gfx_offs];
/* the text layer pixel determines pen address bits A8 and A9 */
if (x & 0x02)
{
tx_col1 = ((tx_data & 0x0c) << 6);
tx_col2 = ((tx_data & 0x03) << 8);
tx_col1 = ((tx_data & 0x0c) << 6);
tx_col2 = ((tx_data & 0x03) << 8);
}
else
{
tx_col1 = ((tx_data & 0xc0) << 2);
tx_col2 = ((tx_data & 0x30) << 4);
tx_col1 = ((tx_data & 0xc0) << 2);
tx_col2 = ((tx_data & 0x30) << 4);
}
/* the background pixel determines pen address bits A0-A3 */
@ -222,7 +222,7 @@ void jedi_state::draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle
/* the first pixel is smoothed via a lookup using the current and last pixel value -
the next pixel just uses the current value directly. After we done with a pixel
save it for later in the line buffer RAM */
bg_tempcol = prom1[(bg_last_col << 4) | bg_col];
const u8 bg_tempcol = prom1[(bg_last_col << 4) | bg_col];
bitmap.pix32(y, x + 0) = tx_col1 | prom2[(background_line_buffer[x + 0] << 4) | bg_tempcol];
bitmap.pix32(y, x + 1) = tx_col2 | prom2[(background_line_buffer[x + 1] << 4) | bg_col];
background_line_buffer[x + 0] = bg_tempcol;
@ -234,7 +234,6 @@ void jedi_state::draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle
}
/*************************************
*
* Sprite drawing
@ -243,27 +242,21 @@ void jedi_state::draw_background_and_text(bitmap_rgb32 &bitmap, const rectangle
void jedi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
offs_t offs;
uint8_t *spriteram = m_spriteram;
uint8_t *gfx3 = memregion("gfx3")->base();
for (offs = 0x00; offs < 0x30; offs++)
for (offs_t offs = 0x00; offs < 0x30; offs++)
{
int sy;
int y_size;
uint8_t *gfx;
/* coordinates adjustments made to match screenshot */
uint8_t y = 240 - spriteram[offs + 0x80] + 1;
int flip_x = spriteram[offs + 0x40] & 0x10;
int flip_y = spriteram[offs + 0x40] & 0x20;
int tall = spriteram[offs + 0x40] & 0x08;
u8 y = 240 - m_spriteram[offs + 0x80] + 1;
const bool flip_x = m_spriteram[offs + 0x40] & 0x10;
const bool flip_y = m_spriteram[offs + 0x40] & 0x20;
const bool tall = m_spriteram[offs + 0x40] & 0x08;
/* shuffle the bank bits in */
uint16_t code = spriteram[offs] |
((spriteram[offs + 0x40] & 0x04) << 8) |
((spriteram[offs + 0x40] & 0x40) << 3) |
((spriteram[offs + 0x40] & 0x02) << 7);
u16 code = m_spriteram[offs] |
((m_spriteram[offs + 0x40] & 0x04) << 8) |
((m_spriteram[offs + 0x40] & 0x40) << 3) |
((m_spriteram[offs + 0x40] & 0x02) << 7);
/* adjust for double-height */
if (tall)
@ -275,15 +268,14 @@ void jedi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
else
y_size = 0x10;
gfx = &gfx3[code << 5];
const u8 *gfx = &m_spr_gfx[code << 5];
if (flip_y)
y = y + y_size - 1;
for (sy = 0; sy < y_size; sy++)
for (int sy = 0; sy < y_size; sy++)
{
int i;
uint16_t x = spriteram[offs + 0x100] + ((spriteram[offs + 0x40] & 0x01) << 8) - 2;
u16 x = m_spriteram[offs + 0x100] + ((m_spriteram[offs + 0x40] & 0x01) << 8) - 2;
if ((y < cliprect.top()) || (y > cliprect.bottom()))
continue;
@ -291,16 +283,15 @@ void jedi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
if (flip_x)
x = x + 7;
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
int sx;
uint8_t data1 = *(0x00000 + gfx);
uint8_t data2 = *(0x10000 + gfx);
u8 data1 = *(0x00000 + gfx);
u8 data2 = *(0x10000 + gfx);
for (sx = 0; sx < 4; sx++)
for (int sx = 0; sx < 4; sx++)
{
/* the sprite pixel determines pen address bits A4-A7 */
uint32_t col = ((data1 & 0x80) >> 0) | ((data1 & 0x08) << 3) | ((data2 & 0x80) >> 2) | ((data2 & 0x08) << 1);
const u32 col = ((data1 & 0x80) >> 0) | ((data1 & 0x08) << 3) | ((data2 & 0x80) >> 2) | ((data2 & 0x08) << 1);
x = x & 0x1ff;
@ -329,14 +320,13 @@ void jedi_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
}
/*************************************
*
* Core video refresh
*
*************************************/
uint32_t jedi_state::screen_update_jedi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
u32 jedi_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
/* if no video, clear it all to black */
if (m_video_off)
@ -354,18 +344,63 @@ uint32_t jedi_state::screen_update_jedi(screen_device &screen, bitmap_rgb32 &bit
}
/*************************************
*
* Machine driver
*
*************************************/
#ifdef DEBUG_GFXDECODE
static const gfx_layout text_layout =
{
8, 8,
RGN_FRAC(1,1),
2,
{ 0, 1 },
{ STEP8(0, 2) },
{ STEP8(0, 2*8) },
8*8*2
};
static const gfx_layout bg_layout =
{
8, 8,
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 },
{ STEP4(0, 1), STEP4(4*2, 1) },
{ STEP8(0, 4*2*2) },
8*8*2
};
static const gfx_layout sprite_layout =
{
8, 16,
RGN_FRAC(1,2),
4,
{ 0, 4, RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+4 },
{ STEP4(0, 1), STEP4(4*2, 1) },
{ STEP16(0, 4*2*2) },
8*16*2
};
static GFXDECODE_START( gfx_jedi )
GFXDECODE_ENTRY( "tx_gfx", 0, text_layout, 0, 0x400/0x04 )
GFXDECODE_SCALE( "bg_gfx", 0, bg_layout, 0, 0x400/0x10, 2, 2 ) // 8x8 but internally expanded related with smoothing
GFXDECODE_ENTRY( "spr_gfx", 0, sprite_layout, 0, 0x310 )
GFXDECODE_END
#endif
void jedi_state::jedi_video(machine_config &config)
{
#ifdef DEBUG_GFXDECODE
GFXDECODE(config, m_gfxdecode, m_palette, gfx_jedi);
#endif
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60);
m_screen->set_size(64*8, 262); /* verify vert size */
m_screen->set_visarea(0*8, 37*8-1, 0*8, 30*8-1);
m_screen->set_screen_update(FUNC(jedi_state::screen_update_jedi));
m_screen->set_screen_update(FUNC(jedi_state::screen_update));
PALETTE(config, m_palette).set_format(2, &jedi_state::jedi_IRGB_3333, 0x400);
}