summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Phil Bennett <philipjbennett@users.noreply.github.com>2009-01-11 19:27:13 +0000
committer Phil Bennett <philipjbennett@users.noreply.github.com>2009-01-11 19:27:13 +0000
commitb9d25498410c911ccc354a1f350135120c76e2a0 (patch)
tree3196992773980415a65db0a29a3bb41f6ccb0d39
parent6d3532866331995951bb737f0058d1bec287221c (diff)
02805: turbosub, turbosba: Dropped lines in video output rendering
Added save state support.
-rw-r--r--src/emu/cpu/esrip/esrip.c166
-rw-r--r--src/mame/drivers/esripsys.c71
-rw-r--r--src/mame/includes/esripsys.h3
-rw-r--r--src/mame/video/esripsys.c150
4 files changed, 245 insertions, 145 deletions
diff --git a/src/emu/cpu/esrip/esrip.c b/src/emu/cpu/esrip/esrip.c
index 36b0597bc53..bb3e68c7061 100644
--- a/src/emu/cpu/esrip/esrip.c
+++ b/src/emu/cpu/esrip/esrip.c
@@ -1,6 +1,6 @@
/***************************************************************************
- escpustate->c
+ esrip.c
Implementation of the Entertainment Sciences
AM29116-based Real Time Image Processor
@@ -23,14 +23,12 @@
MACROS
***************************************************************************/
-#define ASSERT(x)
-//(assert(x))
#define RIP_PC (cpustate->pc | ((cpustate->status_out & 1) << 8))
#define _BIT(x, n) ((x) & (1 << (n)))
#define RISING_EDGE(old_val, new_val, bit) (!(old_val & (1 << bit)) && (new_val & (1 << bit)))
-#define UNHANDLED do {printf("%s:UNHANDLED (%x)\n", __FUNCTION__, inst); ASSERT(0);}while(0)
-#define INVALID do {printf("%s:INVALID (%x)\n", __FUNCTION__, inst); ASSERT(0);}while(0)
+#define UNHANDLED do {printf("%s:UNHANDLED (%x)\n", __FUNCTION__, inst); assert(0);} while (0)
+#define INVALID do {printf("%s:INVALID (%x)\n", __FUNCTION__, inst); assert(0);} while (0)
#define RAM_ADDR (inst & 0x1f)
#define MODE (inst & 0x8000)
@@ -94,19 +92,19 @@ typedef struct
UINT16 attr_latch;
UINT16 adl_latch;
UINT16 adr_latch;
+ UINT16 iaddr_latch;
UINT8 c_latch;
- UINT16 iaddr;
UINT16 fdt_cnt;
UINT16 ipt_cnt;
- UINT16 *ipt_ram;
- UINT8 *lbrm;
+ UINT8 fig;
+ UINT16 fig_cycles;
UINT8 *optable;
- UINT8 fig;
- UINT16 fig_cycles;
+ UINT16 *ipt_ram;
+ UINT8 *lbrm;
const device_config *device;
const address_space *program;
@@ -120,28 +118,19 @@ typedef struct
/***************************************************************************
- INITIALIZATION AND SHUTDOWN
+ PUBLIC FUNCTIONS
***************************************************************************/
UINT8 get_rip_status(const device_config *cpu)
{
esrip_state *cpustate = cpu->token;
-
return cpustate->status_out;
}
-/*
-static STATE_POSTLOAD( esrip_postload )
-{
-
-}
-*/
-
-//static void esrip_state_register(int index, const char *type)
-//{
-// state_save_register_item_pointer(type, index, cpustate->ipt_ram, IPT_RAM_SIZE / 2);
-//}
+/***************************************************************************
+ INITIALIZATION AND SHUTDOWN
+***************************************************************************/
enum
{
@@ -150,7 +139,6 @@ enum
ROTNR, BONR, BOR1, SONR, SHFTNR, PRTNR, TONR
} ops;
-
void make_ops(esrip_state *cpustate)
{
int inst;
@@ -260,16 +248,58 @@ static CPU_INIT( esrip )
cpustate->status_in = _config->status_in;
cpustate->draw = _config->draw;
+ /* Allocate image pointer table RAM */
cpustate->ipt_ram = auto_malloc(IPT_RAM_SIZE);
-//state_save_register_global_pointer(cpustate->ipt_ram, IPT_RAM_SIZE / 2); // TODO
-// esrip_state_register(index, "esrip");
cpustate->device = device;
cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
/* Create the instruction decode lookup table */
cpustate->optable = auto_malloc(65536);
make_ops(cpustate);
+
+ /* Register stuff for state saving */
+ state_save_register_device_item(device, 0, cpustate->acc);
+ state_save_register_device_item_array(device, 0, cpustate->ram);
+ state_save_register_device_item(device, 0, cpustate->d_latch);
+ state_save_register_device_item(device, 0, cpustate->i_latch);
+ state_save_register_device_item(device, 0, cpustate->result);
+ state_save_register_device_item(device, 0, cpustate->new_status);
+ state_save_register_device_item(device, 0, cpustate->status);
+ state_save_register_device_item(device, 0, cpustate->inst);
+ state_save_register_device_item(device, 0, cpustate->immflag);
+ state_save_register_device_item(device, 0, cpustate->ct);
+ state_save_register_device_item(device, 0, cpustate->t);
+ state_save_register_device_item(device, 0, cpustate->l1);
+ state_save_register_device_item(device, 0, cpustate->l2);
+ state_save_register_device_item(device, 0, cpustate->l3);
+ state_save_register_device_item(device, 0, cpustate->l4);
+ state_save_register_device_item(device, 0, cpustate->l5);
+ state_save_register_device_item(device, 0, cpustate->l6);
+ state_save_register_device_item(device, 0, cpustate->l7);
+ state_save_register_device_item(device, 0, cpustate->pl1);
+ state_save_register_device_item(device, 0, cpustate->pl2);
+ state_save_register_device_item(device, 0, cpustate->pl3);
+ state_save_register_device_item(device, 0, cpustate->pl4);
+ state_save_register_device_item(device, 0, cpustate->pl5);
+ state_save_register_device_item(device, 0, cpustate->pl6);
+ state_save_register_device_item(device, 0, cpustate->pl7);
+ state_save_register_device_item(device, 0, cpustate->pc);
+ state_save_register_device_item(device, 0, cpustate->status_out);
+ state_save_register_device_item(device, 0, cpustate->x_scale);
+ state_save_register_device_item(device, 0, cpustate->y_scale);
+ state_save_register_device_item(device, 0, cpustate->line_latch);
+ state_save_register_device_item(device, 0, cpustate->fig_latch);
+ state_save_register_device_item(device, 0, cpustate->attr_latch);
+ state_save_register_device_item(device, 0, cpustate->adl_latch);
+ state_save_register_device_item(device, 0, cpustate->adr_latch);
+ state_save_register_device_item(device, 0, cpustate->iaddr_latch);
+ state_save_register_device_item(device, 0, cpustate->c_latch);
+ state_save_register_device_item(device, 0, cpustate->fdt_cnt);
+ state_save_register_device_item(device, 0, cpustate->ipt_cnt);
+ state_save_register_device_item(device, 0, cpustate->fig);
+ state_save_register_device_item(device, 0, cpustate->fig_cycles);
+ state_save_register_device_item_pointer(device, 0, cpustate->ipt_ram, IPT_RAM_SIZE / sizeof(UINT16));
}
@@ -306,6 +336,9 @@ static CPU_EXIT( esrip )
}
+/***************************************************************************
+ PRIVATE FUNCTIONS
+***************************************************************************/
static int get_hblank(running_machine *machine)
{
@@ -358,7 +391,7 @@ INLINE int check_jmp(esrip_state *cpustate, running_machine *machine, UINT8 jmp_
}
}
else
- ASSERT(!"RIP: Invalid jump control");
+ assert(!"RIP: Invalid jump control");
return ret;
}
@@ -401,6 +434,10 @@ INLINE void calc_v_flag_sub(esrip_state *cpustate, UINT16 a, UINT16 b, UINT32 r)
}
+/***************************************************************************
+ INSTRUCTIONS
+***************************************************************************/
+
enum
{
ACC,
@@ -1614,10 +1651,13 @@ static CPU_EXECUTE( esrip )
{
esrip_state *cpustate = device->token;
int calldebugger = (device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0;
- UINT16 status = cpustate->status_in(device->machine);
-
+ UINT8 status;
+
cpustate->icount = cycles;
+ /* I think we can get away with placing this outside of the loop */
+ status = cpustate->status_in(device->machine);
+
/* Core execution loop */
do
{
@@ -1636,7 +1676,7 @@ static CPU_EXECUTE( esrip )
if (cpustate->fig_cycles)
{
- if(--cpustate->fig_cycles == 0)
+ if (--cpustate->fig_cycles == 0)
cpustate->fig = 0;
}
@@ -1761,7 +1801,7 @@ static CPU_EXECUTE( esrip )
cpustate->attr_latch = x_bus;
cpustate->fig = 1;
- cpustate->fig_cycles = cpustate->draw(device->machine, cpustate->adl_latch, cpustate->adr_latch, cpustate->fig_latch, cpustate->attr_latch, cpustate->iaddr, cpustate->c_latch, cpustate->x_scale, cpustate->line_latch);
+ cpustate->fig_cycles = cpustate->draw(device->machine, cpustate->adl_latch, cpustate->adr_latch, cpustate->fig_latch, cpustate->attr_latch, cpustate->iaddr_latch, cpustate->c_latch, cpustate->x_scale, cpustate->line_latch);
}
/* X-scale */
@@ -1777,7 +1817,7 @@ static CPU_EXECUTE( esrip )
/* Image ROM address */
if (RISING_EDGE(cpustate->pl3, cpustate->l3, 5))
- cpustate->iaddr = y_bus;
+ cpustate->iaddr_latch = y_bus;
/* IXLLD */
if (RISING_EDGE(cpustate->pl3, cpustate->l3, 6))
@@ -1815,7 +1855,7 @@ static CPU_EXECUTE( esrip )
/***************************************************************************
- DISASSEMBLY HOOK
+ DISASSEMBLY HOOK (TODO: FINISH)
***************************************************************************/
static CPU_DISASSEMBLE( esrip )
@@ -1862,35 +1902,35 @@ static CPU_DISASSEMBLE( esrip )
UINT8 ctrl3 = (inst_hi) & 0xff;
sprintf(buffer, "%.4x %c%c%c%c %.2x %s%s%s%s%s%s%s%s %c%s%s%s %c%c%c%c%c%c%c%c\n",
- ins,
- ctrl & 1 ? 'D' : ' ',
- ctrl & 2 ? ' ' : 'Y',
- ctrl & 4 ? 'S' : ' ',
- (~jmp_ctrl & 0x18) ? 'J' : ' ',
- jmp_dest,
- ctrl1 & 0x01 ? " " : "I ",
- ctrl1 & 0x02 ? " " : "FL",
- ctrl1 & 0x04 ? "FE" : " ",
- ctrl1 & 0x08 ? " " : "FR",
- ctrl1 & 0x10 ? " " : "IL",
- ctrl1 & 0x20 ? "IE" : " ",
- ctrl1 & 0x40 ? " " : "IR",
- ctrl1 & 0x80 ? " " : "IW",
-
- ctrl2 & 0x80 ? ' ' : 'O',
- ctrl2 & 0x40 ? " " : "IXLLD",
- ctrl2 & 0x20 ? " " : "IADLD",
- ctrl2 & 0x10 ? " " : "SCALD",
-
- ctrl3 & 0x01 ? ' ' : '0',
- ctrl3 & 0x02 ? ' ' : '1',
- ctrl3 & 0x04 ? ' ' : '2',
- ctrl3 & 0x08 ? ' ' : '3',
- ctrl3 & 0x10 ? ' ' : '4',
- ctrl3 & 0x20 ? ' ' : '5',
- ctrl3 & 0x40 ? ' ' : '6',
- ctrl3 & 0x80 ? ' ' : '7'
- );
+ ins,
+ ctrl & 1 ? 'D' : ' ',
+ ctrl & 2 ? ' ' : 'Y',
+ ctrl & 4 ? 'S' : ' ',
+ (~jmp_ctrl & 0x18) ? 'J' : ' ',
+ jmp_dest,
+ ctrl1 & 0x01 ? " " : "I ",
+ ctrl1 & 0x02 ? " " : "FL",
+ ctrl1 & 0x04 ? "FE" : " ",
+ ctrl1 & 0x08 ? " " : "FR",
+ ctrl1 & 0x10 ? " " : "IL",
+ ctrl1 & 0x20 ? "IE" : " ",
+ ctrl1 & 0x40 ? " " : "IR",
+ ctrl1 & 0x80 ? " " : "IW",
+
+ ctrl2 & 0x80 ? ' ' : 'O',
+ ctrl2 & 0x40 ? " " : "IXLLD",
+ ctrl2 & 0x20 ? " " : "IADLD",
+ ctrl2 & 0x10 ? " " : "SCALD",
+
+ ctrl3 & 0x01 ? ' ' : '0',
+ ctrl3 & 0x02 ? ' ' : '1',
+ ctrl3 & 0x04 ? ' ' : '2',
+ ctrl3 & 0x08 ? ' ' : '3',
+ ctrl3 & 0x10 ? ' ' : '4',
+ ctrl3 & 0x20 ? ' ' : '5',
+ ctrl3 & 0x40 ? ' ' : '6',
+ ctrl3 & 0x80 ? ' ' : '7'
+ );
return 1 | DASMFLAG_SUPPORTED;
}
@@ -2025,6 +2065,6 @@ CPU_GET_INFO( esrip )
case CPUINFO_STR_REGISTER + ESRIP_ADRL: sprintf(info->s, "ADRL: %04X", cpustate->adl_latch); break;
case CPUINFO_STR_REGISTER + ESRIP_ADRR: sprintf(info->s, "ADRR: %04X", cpustate->adr_latch); break;
case CPUINFO_STR_REGISTER + ESRIP_COLR: sprintf(info->s, "COLR: %04X", cpustate->c_latch); break;
- case CPUINFO_STR_REGISTER + ESRIP_IADDR: sprintf(info->s, "IADR: %04X", cpustate->iaddr); break;
+ case CPUINFO_STR_REGISTER + ESRIP_IADDR: sprintf(info->s, "IADR: %04X", cpustate->iaddr_latch); break;
}
}
diff --git a/src/mame/drivers/esripsys.c b/src/mame/drivers/esripsys.c
index a6c688d9dd7..8c2c7953827 100644
--- a/src/mame/drivers/esripsys.c
+++ b/src/mame/drivers/esripsys.c
@@ -9,24 +9,25 @@
ROMs wanted:
* Bouncer
- * Turbo Sub [later version] (uses 512kbit graphics ROMs)
+ * Turbo Sub [later version] (improved gameplay, uses 27512 ROMs)
Notes:
* 'turbosub' executes a series of hardware tests on startup.
To skip, hold down keypad '*' on reset.
* Hold '*' during the game to access the operator menu.
- Todo:
+ To do:
* TMS5220 speech. The game is sending speech play commands to
the sound CPU but any speech code greater than 2 is ignored (see $EC26).
I think most of the speech data is stored in the upper half of the
banked sound data ROMs but I don't know how or when the ROM
bank is switched :/
- * Determine if line drop outs occur on real hardware. Overclocking
- the RIP CPU eliminates them.
+ * Confirm that occasional line drop outs do occur on real hardware.
+ 14 sprites seems to be the maximum number that the RIP CPU can safely
+ process per line.
- * Implement collision detection hardware (not used by Turbo Sub).
+ * Implement collision detection hardware (unused by Turbo Sub).
****************************************************************************/
@@ -277,15 +278,15 @@ WRITE16_DEVICE_HANDLER( fdt_rip_w )
UINT8 rip_status_in(running_machine *machine)
{
- UINT8 _vblank = !video_screen_get_vblank(machine->primary_screen);
- UINT8 _hblank = !video_screen_get_hblank(machine->primary_screen);
- UINT8 v0 = video_screen_get_vpos(machine->primary_screen) & 1;
+ int vpos = video_screen_get_vpos(machine->primary_screen);
+ UINT8 _vblank = !(vpos >= ESRIPSYS_VBLANK_START);
+// UINT8 _hblank = !video_screen_get_hblank(machine->primary_screen);
return _vblank
- | (_hblank << 1)
+ | (esripsys_hblank << 1)
| (esripsys__12sel << 2)
| (_fbsel << 4)
- | (v0 << 5)
+ | ((vpos & 1) << 5)
| (f_status & 0x80);
}
@@ -529,7 +530,6 @@ static WRITE8_HANDLER( s_200f_w )
{
/* Bit 6 -> Reset latch U56A */
/* Bit 7 -> Clock latch U56B */
-
if (s_to_g_latch2 & 0x40)
{
u56a = 0;
@@ -597,9 +597,9 @@ static WRITE8_HANDLER( dac_w )
UINT16 dac_data = (dac_msb << 8) | data;
/*
- The 8-bit DAC modulates the 10-bit DAC.
- Shift down to prevent clipping.
- */
+ The 8-bit DAC modulates the 10-bit DAC.
+ Shift down to prevent clipping.
+ */
dac_signed_data_16_w(0, (dac_vol * dac_data) >> 1);
}
}
@@ -679,13 +679,37 @@ static DRIVER_INIT( esripsys )
ptm6840_config(machine, 0, &ptm_intf);
- memory_set_bankptr(machine, 2, &ROM[0x0000+0x0000]);
- memory_set_bankptr(machine, 3, &ROM[0x0000+0x4000]);
- memory_set_bankptr(machine, 4, &ROM[0x0000+0x8000]);
-
- /* TODO: Finish me! */
-// state_save_register_global_pointer(fdt_a, FDT_RAM_SIZE);
-// state_save_register_global_pointer(fdt_b, FDT_RAM_SIZE);
+ memory_set_bankptr(machine, 2, &ROM[0x0000]);
+ memory_set_bankptr(machine, 3, &ROM[0x4000]);
+ memory_set_bankptr(machine, 4, &ROM[0x8000]);
+
+ /* Register stuff for state saving */
+ state_save_register_global_pointer(machine, fdt_a, FDT_RAM_SIZE);
+ state_save_register_global_pointer(machine, fdt_b, FDT_RAM_SIZE);
+ state_save_register_global_pointer(machine, cmos_ram, CMOS_RAM_SIZE);
+
+ state_save_register_global(machine, g_iodata);
+ state_save_register_global(machine, g_ioaddr);
+ state_save_register_global(machine, coin_latch);
+ state_save_register_global(machine, keypad_status);
+ state_save_register_global(machine, g_status);
+ state_save_register_global(machine, f_status);
+ state_save_register_global(machine, io_firq_status);
+ state_save_register_global(machine, cmos_ram_a2_0);
+ state_save_register_global(machine, cmos_ram_a10_3);
+
+ state_save_register_global(machine, u56a);
+ state_save_register_global(machine, u56b);
+ state_save_register_global(machine, g_to_s_latch1);
+ state_save_register_global(machine, g_to_s_latch2);
+ state_save_register_global(machine, s_to_g_latch1);
+ state_save_register_global(machine, s_to_g_latch2);
+ state_save_register_global(machine, dac_msb);
+ state_save_register_global(machine, dac_vol);
+ state_save_register_global(machine, tms_data);
+
+ state_save_register_global(machine, _fasel);
+ state_save_register_global(machine, _fbsel);
}
static NVRAM_HANDLER( esripsys )
@@ -729,6 +753,7 @@ static MACHINE_DRIVER_START( esripsys )
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
MDRV_SCREEN_RAW_PARAMS(ESRIPSYS_PIXEL_CLOCK, ESRIPSYS_HTOTAL, ESRIPSYS_HBLANK_END, ESRIPSYS_HBLANK_START, ESRIPSYS_VTOTAL, ESRIPSYS_VBLANK_END, ESRIPSYS_VBLANK_START)
+ MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
MDRV_VIDEO_START(esripsys)
MDRV_VIDEO_UPDATE(esripsys)
@@ -988,5 +1013,5 @@ ROM_END
*
*************************************/
-GAME( 1985, turbosub, 0, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSCA)", GAME_IMPERFECT_SOUND )
-GAME( 1985, turbosba, turbosub, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSC6)", GAME_IMPERFECT_SOUND )
+GAME( 1985, turbosub, 0, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSCA)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
+GAME( 1985, turbosba, turbosub, esripsys, turbosub, esripsys, ROT0, "Entertainment Sciences", "Turbo Sub (prototype rev. TSC6)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
diff --git a/src/mame/includes/esripsys.h b/src/mame/includes/esripsys.h
index e7a3f66bf7a..212d0bef8e6 100644
--- a/src/mame/includes/esripsys.h
+++ b/src/mame/includes/esripsys.h
@@ -6,7 +6,7 @@
/* TODO */
#define ESRIPSYS_PIXEL_CLOCK (XTAL_25MHz / 2)
-#define ESRIPSYS_HTOTAL (512 + 141)
+#define ESRIPSYS_HTOTAL (512 + 141 + 2)
#define ESRIPSYS_HBLANK_START (512)
#define ESRIPSYS_HBLANK_END (0)
#define ESRIPSYS_VTOTAL (384 + 20)
@@ -26,6 +26,7 @@ enum
/*----------- defined in video/esripsys.c -----------*/
+extern int esripsys_hblank;
extern UINT8 *esripsys_pal_ram;
extern int esripsys_frame_vbl;
extern int esripsys__12sel;
diff --git a/src/mame/video/esripsys.c b/src/mame/video/esripsys.c
index 0b85eb3efce..48516ba267f 100644
--- a/src/mame/video/esripsys.c
+++ b/src/mame/video/esripsys.c
@@ -8,25 +8,37 @@
#include "cpu/m6809/m6809.h"
#include "esripsys.h"
-typedef struct _pixel_
+
+/*************************************
+ *
+ * Statics
+ *
+ *************************************/
+
+struct
{
- UINT8 colour;
- UINT8 intensity;
- UINT8 priority;
-} pixel;
+ UINT8 *colour_buf;
+ UINT8 *intensity_buf;
+ UINT8 *priority_buf;
+} line_buffer[2];
static emu_timer *hblank_end_timer;
static emu_timer *hblank_start_timer;
static UINT8 *fig_scale_table;
static UINT8 *scale_table;
-static pixel *line_buffer_1;
-static pixel *line_buffer_2;
-static int vcount;
static int video_firq;
static UINT8 bg_intensity;
+
+/*************************************
+ *
+ * Globals
+ *
+ *************************************/
+
+int esripsys_hblank;
int esripsys_video_firq_en;
int esripsys_frame_vbl;
int esripsys__12sel;
@@ -41,7 +53,7 @@ INTERRUPT_GEN( esripsys_vblank_irq )
static TIMER_CALLBACK( hblank_start_callback )
{
- int v = vcount;
+ int v = video_screen_get_vpos(machine->primary_screen);
if (video_firq)
{
@@ -49,26 +61,33 @@ static TIMER_CALLBACK( hblank_start_callback )
cpu_set_input_line(machine->cpu[ESRIPSYS_GAME_CPU], M6809_FIRQ_LINE, CLEAR_LINE);
}
- if (!(vcount % 6) && vcount && esripsys_video_firq_en && vcount < ESRIPSYS_VBLANK_START)
+ /* Not sure if this is totally accurate - I couldn't find the circuit that generates the FIRQs! */
+ if (!(v % 6) && v && esripsys_video_firq_en && v < ESRIPSYS_VBLANK_START)
{
video_firq = 1;
cpu_set_input_line(machine->cpu[ESRIPSYS_GAME_CPU], M6809_FIRQ_LINE, ASSERT_LINE);
}
/* Adjust for next scanline */
- if (++vcount >= ESRIPSYS_VTOTAL)
- vcount = 0;
+ if (++v >= ESRIPSYS_VTOTAL)
+ v = 0;
/* Set end of HBLANK timer */
- timer_adjust_oneshot(hblank_end_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HTOTAL-1), v);
+ timer_adjust_oneshot(hblank_end_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_END), v);
+ esripsys_hblank = 0;
}
static TIMER_CALLBACK( hblank_end_callback )
{
- video_screen_update_partial(machine->primary_screen, param);
+ int v = video_screen_get_vpos(machine->primary_screen);
+
+ if (v > 0)
+ video_screen_update_partial(machine->primary_screen, v - 1);
esripsys__12sel ^= 1;
- timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, vcount, ESRIPSYS_HBLANK_START), 0);
+ timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_START), 0);
+
+ esripsys_hblank = 1;
}
VIDEO_START( esripsys )
@@ -76,8 +95,13 @@ VIDEO_START( esripsys )
int i;
/* Allocate memory for the two 512-pixel line buffers */
- line_buffer_1 = auto_malloc(512 * sizeof(pixel));
- line_buffer_2 = auto_malloc(512 * sizeof(pixel));
+ line_buffer[0].colour_buf = auto_malloc(512);
+ line_buffer[0].intensity_buf = auto_malloc(512);
+ line_buffer[0].priority_buf = auto_malloc(512);
+
+ line_buffer[1].colour_buf = auto_malloc(512);
+ line_buffer[1].intensity_buf = auto_malloc(512);
+ line_buffer[1].priority_buf = auto_malloc(512);
/* Create and initialise the HBLANK timers */
hblank_start_timer = timer_alloc(machine, hblank_start_callback, NULL);
@@ -140,38 +164,50 @@ VIDEO_START( esripsys )
fig_scale_table[i * 64 + scale] = scaled_pixels - 1;
}
}
+
+ /* Register stuff for state saving */
+ state_save_register_global_pointer(machine, line_buffer[0].colour_buf, 512);
+ state_save_register_global_pointer(machine, line_buffer[0].intensity_buf, 512);
+ state_save_register_global_pointer(machine, line_buffer[0].priority_buf, 512);
+
+ state_save_register_global_pointer(machine, line_buffer[1].colour_buf, 512);
+ state_save_register_global_pointer(machine, line_buffer[1].intensity_buf, 512);
+ state_save_register_global_pointer(machine, line_buffer[1].priority_buf, 512);
+
+ state_save_register_global(machine, video_firq);
+ state_save_register_global(machine, bg_intensity);
+ state_save_register_global(machine, esripsys_hblank);
+ state_save_register_global(machine, esripsys_video_firq_en);
+ state_save_register_global(machine, esripsys_frame_vbl);
+ state_save_register_global(machine, esripsys__12sel);
}
VIDEO_UPDATE( esripsys )
{
- int x;
- int y;
- pixel *src;
+ int x, y;
- /* Select line buffer to scan out */
- if (esripsys__12sel)
- src = line_buffer_2;
- else
- src = line_buffer_1;
+ UINT8 *colour_buf = line_buffer[esripsys__12sel ? 0 : 1].colour_buf;
+ UINT8 *intensity_buf = line_buffer[esripsys__12sel ? 0 : 1].intensity_buf;
+ UINT8 *priority_buf = line_buffer[esripsys__12sel ? 0 : 1].priority_buf;
for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
{
- UINT32 *dest = BITMAP_ADDR32(bitmap, y, 0);
+ UINT32 *dest = BITMAP_ADDR32(bitmap, y, cliprect->min_x);
- for (x = cliprect->min_x; x <= cliprect->max_x; ++x)
+ for (x = 0; x < 512; ++x)
{
- int idx = src[x].colour;
+ int idx = colour_buf[x];
int r = (esripsys_pal_ram[idx] & 0xf);
int g = (esripsys_pal_ram[256 + idx] & 0xf);
int b = (esripsys_pal_ram[512 + idx] & 0xf);
- int i = src[x].intensity;
+ int i = intensity_buf[x];
*dest++ = MAKE_RGB(r*i, g*i, b*i);
/* Clear the line buffer as we scan out */
- src[x].colour = 0xff;
- src[x].intensity = bg_intensity;
- src[x].priority = 0;
+ colour_buf[x] = 0xff;
+ intensity_buf[x] = bg_intensity;
+ priority_buf[x] = 0;
}
}
@@ -186,7 +222,10 @@ WRITE8_HANDLER( esripsys_bg_intensity_w )
/* Draw graphics to a line buffer */
int esripsys_draw(running_machine *machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int line_latch)
{
- pixel *dst;
+ UINT8 *colour_buf = line_buffer[esripsys__12sel ? 1 : 0].colour_buf;
+ UINT8 *intensity_buf = line_buffer[esripsys__12sel ? 1 : 0].intensity_buf;
+ UINT8 *priority_buf = line_buffer[esripsys__12sel ? 1 : 0].priority_buf;
+
UINT8 pri = attr & 0xff;
UINT8 iny = (attr >> 8) & 0xf;
UINT8 pal = col << 4;
@@ -198,11 +237,6 @@ int esripsys_draw(running_machine *machine, int l, int r, int fig, int attr, int
if (xs_typ)
fig = fig_scale_table[fig * 64 + xs_val];
- if (esripsys__12sel)
- dst = line_buffer_1;
- else
- dst = line_buffer_2;
-
/* 8bpp case */
if (attr & 0x8000)
{
@@ -230,23 +264,23 @@ int esripsys_draw(running_machine *machine, int l, int r, int fig, int attr, int
UINT8 pix1 = rom_l[rom_addr];
UINT8 pix2 = rom_r[rom_addr];
- if ((UINT32)lpos < 512)
+ if (lpos < 512)
{
- if ((pri > dst[lpos].priority) && pix1 != 0xff)
+ if ((pri > priority_buf[lpos]) && pix1 != 0xff)
{
- dst[lpos].colour = pix1;
- dst[lpos].priority = pri;
- dst[lpos].intensity = iny;
+ colour_buf[lpos] = pix1;
+ priority_buf[lpos] = pri;
+ intensity_buf[lpos] = iny;
}
}
- if ((UINT32)rpos < 512)
+ if (rpos < 512)
{
- if ((pri > dst[rpos].priority) && pix2 != 0xff)
+ if ((pri > priority_buf[rpos]) && pix2 != 0xff)
{
- dst[rpos].colour = pix2;
- dst[rpos].priority = pri;
- dst[rpos].intensity = iny;
+ colour_buf[rpos] = pix2;
+ priority_buf[rpos] = pri;
+ intensity_buf[rpos] = iny;
}
}
@@ -307,23 +341,23 @@ int esripsys_draw(running_machine *machine, int l, int r, int fig, int attr, int
px1 = (px8 >> 4) & 0xf;
}
- if ((UINT32)lpos < 512)
+ if (lpos < 512)
{
- if ((pri > dst[lpos].priority) && px1 != 0xf)
+ if (pri > priority_buf[lpos] && px1 != 0xf)
{
- dst[lpos].colour = pal | px1;
- dst[lpos].priority = pri;
- dst[lpos].intensity = iny;
+ colour_buf[lpos] = pal | px1;
+ priority_buf[lpos] = pri;
+ intensity_buf[lpos] = iny;
}
}
- if ((UINT32)rpos < 512)
+ if (rpos < 512)
{
- if (pri > dst[rpos].priority && px2 != 0xf)
+ if (pri > priority_buf[rpos] && px2 != 0xf)
{
- dst[rpos].colour = pal | px2;
- dst[rpos].priority = pri;
- dst[rpos].intensity = iny;
+ colour_buf[rpos] = pal | px2;
+ priority_buf[rpos] = pri;
+ intensity_buf[rpos] = iny;
}
}