vrender0.c: converted to be a device [Fabio Priuli]

crystal.c: added driver data class [Fabio Priuli]
This commit is contained in:
Fabio Priuli 2010-04-26 22:19:05 +00:00
parent 931e9aa86c
commit 2d27ac37d5
4 changed files with 732 additions and 534 deletions

View File

@ -114,6 +114,8 @@ static DEVICE_START( vrender0 )
memset(VR0->SOUNDREGS,0,sizeof(VR0->SOUNDREGS)); memset(VR0->SOUNDREGS,0,sizeof(VR0->SOUNDREGS));
VR0->stream = stream_create(device, 0, 2, 44100, VR0, VR0_Update); VR0->stream = stream_create(device, 0, 2, 44100, VR0, VR0_Update);
state_save_register_device_item_array(device, 0, VR0->SOUNDREGS);
} }
WRITE32_DEVICE_HANDLER(vr0_snd_write) WRITE32_DEVICE_HANDLER(vr0_snd_write)

View File

@ -124,63 +124,89 @@ Notes:
#define IDLE_LOOP_SPEEDUP #define IDLE_LOOP_SPEEDUP
class crystal_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crystal_state(machine)); }
crystal_state(running_machine &machine) { }
/* memory pointers */
UINT32 * workram;
UINT32 * textureram;
UINT32 * frameram;
UINT32 * sysregs;
UINT32 * vidregs;
// UINT32 * nvram; // currently this uses generic nvram handling
#ifdef IDLE_LOOP_SPEEDUP #ifdef IDLE_LOOP_SPEEDUP
static UINT8 FlipCntRead; UINT8 FlipCntRead;
#endif #endif
static UINT32 *workram,*textureram,*frameram; UINT32 Bank;
static UINT32 *sysregs,*vidregs; UINT8 FlipCount, IntHigh;
static UINT32 Bank; UINT32 Timerctrl[4];
static UINT8 FlipCount,IntHigh; emu_timer *Timer[4];
static UINT32 Timerctrl[4]; UINT32 FlashCmd, PIO;
static emu_timer *Timer[4]; UINT32 DMActrl[2];
static UINT32 FlashCmd,PIO; UINT8 OldPort4;
static UINT32 DMActrl[2]; UINT32 *ResetPatch;
static UINT8 OldPort4;
static UINT32 *ResetPatch; running_device *maincpu;
running_device *ds1302;
running_device *vr0video;
};
static void IntReq( running_machine *machine, int num ) static void IntReq( running_machine *machine, int num )
{ {
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); crystal_state *state = (crystal_state *)machine->driver_data;
const address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM);
UINT32 IntEn = memory_read_dword(space, 0x01800c08); UINT32 IntEn = memory_read_dword(space, 0x01800c08);
UINT32 IntPend = memory_read_dword(space, 0x01800c0c); UINT32 IntPend = memory_read_dword(space, 0x01800c0c);
if (IntEn & (1 << num)) if (IntEn & (1 << num))
{ {
IntPend |= (1 << num); IntPend |= (1 << num);
memory_write_dword(space, 0x01800c0c, IntPend); memory_write_dword(space, 0x01800c0c, IntPend);
cputag_set_input_line(machine, "maincpu", SE3208_INT, ASSERT_LINE); cpu_set_input_line(state->maincpu, SE3208_INT, ASSERT_LINE);
} }
#ifdef IDLE_LOOP_SPEEDUP #ifdef IDLE_LOOP_SPEEDUP
FlipCntRead = 0; state->FlipCntRead = 0;
cputag_resume(machine, "maincpu", SUSPEND_REASON_SPIN); cpu_resume(state->maincpu, SUSPEND_REASON_SPIN);
#endif #endif
} }
static READ32_HANDLER( FlipCount_r ) static READ32_HANDLER( FlipCount_r )
{ {
crystal_state *state = (crystal_state *)space->machine->driver_data;
#ifdef IDLE_LOOP_SPEEDUP #ifdef IDLE_LOOP_SPEEDUP
UINT32 IntPend = memory_read_dword(space, 0x01800c0c); UINT32 IntPend = memory_read_dword(space, 0x01800c0c);
FlipCntRead++; state->FlipCntRead++;
if(FlipCntRead >= 16 && !IntPend && FlipCount != 0) if (state->FlipCntRead >= 16 && !IntPend && state->FlipCount != 0)
cputag_suspend(space->machine, "maincpu", SUSPEND_REASON_SPIN, 1); cpu_suspend(state->maincpu, SUSPEND_REASON_SPIN, 1);
#endif #endif
return ((UINT32) FlipCount)<<16; return ((UINT32) state->FlipCount) << 16;
} }
static WRITE32_HANDLER( FlipCount_w ) static WRITE32_HANDLER( FlipCount_w )
{ {
crystal_state *state = (crystal_state *)space->machine->driver_data;
if (mem_mask & 0x00ff0000) if (mem_mask & 0x00ff0000)
{ {
int fc = (data >> 16) & 0xff; int fc = (data >> 16) & 0xff;
if (fc == 1) if (fc == 1)
FlipCount++; state->FlipCount++;
else if (fc == 0) else if (fc == 0)
FlipCount = 0; state->FlipCount = 0;
} }
} }
static READ32_HANDLER( Input_r ) static READ32_HANDLER( Input_r )
{ {
crystal_state *state = (crystal_state *)space->machine->driver_data;
if (offset == 0) if (offset == 0)
return input_port_read(space->machine, "P1_P2"); return input_port_read(space->machine, "P1_P2");
else if (offset == 1) else if (offset == 1)
@ -188,11 +214,11 @@ static READ32_HANDLER(Input_r)
else if( offset == 2) else if( offset == 2)
{ {
UINT8 Port4 = input_port_read(space->machine, "SYSTEM"); UINT8 Port4 = input_port_read(space->machine, "SYSTEM");
if(!(Port4 & 0x10) && ((OldPort4^Port4) & 0x10)) //coin buttons trigger IRQs if (!(Port4 & 0x10) && ((state->OldPort4 ^ Port4) & 0x10)) //coin buttons trigger IRQs
IntReq(space->machine, 12); IntReq(space->machine, 12);
if(!(Port4 & 0x20) && ((OldPort4^Port4) & 0x20)) if (!(Port4 & 0x20) && ((state->OldPort4 ^ Port4) & 0x20))
IntReq(space->machine, 19); IntReq(space->machine, 19);
OldPort4 = Port4; state->OldPort4 = Port4;
return /*dips*/input_port_read(space->machine, "DSW") | (Port4 << 16); return /*dips*/input_port_read(space->machine, "DSW") | (Port4 << 16);
} }
return 0; return 0;
@ -200,29 +226,32 @@ static READ32_HANDLER(Input_r)
static WRITE32_HANDLER( IntAck_w ) static WRITE32_HANDLER( IntAck_w )
{ {
crystal_state *state = (crystal_state *)space->machine->driver_data;
UINT32 IntPend = memory_read_dword(space, 0x01800c0c); UINT32 IntPend = memory_read_dword(space, 0x01800c0c);
if (mem_mask & 0xff) if (mem_mask & 0xff)
{ {
IntPend &= ~(1 << (data & 0x1f)); IntPend &= ~(1 << (data & 0x1f));
memory_write_dword(space, 0x01800c0c, IntPend); memory_write_dword(space, 0x01800c0c, IntPend);
if (!IntPend) if (!IntPend)
cputag_set_input_line(space->machine, "maincpu", SE3208_INT, CLEAR_LINE); cpu_set_input_line(state->maincpu, SE3208_INT, CLEAR_LINE);
} }
if (mem_mask & 0xff00) if (mem_mask & 0xff00)
IntHigh = (data >> 8) & 7; state->IntHigh = (data >> 8) & 7;
} }
static IRQ_CALLBACK( icallback ) static IRQ_CALLBACK( icallback )
{ {
crystal_state *state = (crystal_state *)device->machine->driver_data;
const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM); const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
UINT32 IntPend = memory_read_dword(space, 0x01800c0c); UINT32 IntPend = memory_read_dword(space, 0x01800c0c);
int i; int i;
for (i = 0; i < 32; ++i) for (i = 0; i < 32; ++i)
{ {
if(IntPend & (1 << i)) if (BIT(IntPend, i))
{ {
return (IntHigh << 5) | i; return (state->IntHigh << 5) | i;
} }
} }
return 0; //This should never happen return 0; //This should never happen
@ -230,37 +259,43 @@ static IRQ_CALLBACK(icallback)
static WRITE32_HANDLER( Banksw_w ) static WRITE32_HANDLER( Banksw_w )
{ {
Bank=(data>>1)&7; crystal_state *state = (crystal_state *)space->machine->driver_data;
if(Bank<=2)
memory_set_bankptr(space->machine, "bank1",memory_region(space->machine, "user1")+Bank*0x1000000); state->Bank = (data >> 1) & 7;
if (state->Bank <= 2)
memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "user1") + state->Bank * 0x1000000);
else else
memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "user2")); memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "user2"));
} }
static TIMER_CALLBACK( Timercb ) static TIMER_CALLBACK( Timercb )
{ {
crystal_state *state = (crystal_state *)machine->driver_data;
int which = (int)(FPTR)ptr; int which = (int)(FPTR)ptr;
static const int num[] = { 0, 1, 9, 10 }; static const int num[] = { 0, 1, 9, 10 };
if(!(Timerctrl[which]&2)) if (!(state->Timerctrl[which] & 2))
Timerctrl[which]&=~1; state->Timerctrl[which] &= ~1;
IntReq(machine, num[which]); IntReq(machine, num[which]);
} }
INLINE void Timer_w( const address_space *space, int which, UINT32 data, UINT32 mem_mask ) INLINE void Timer_w( const address_space *space, int which, UINT32 data, UINT32 mem_mask )
{ {
if(((data^Timerctrl[which])&1) && (data&1)) //Timer activate crystal_state *state = (crystal_state *)space->machine->driver_data;
if (((data ^ state->Timerctrl[which]) & 1) && (data & 1)) //Timer activate
{ {
int PD = (data >> 8) & 0xff; int PD = (data >> 8) & 0xff;
int TCV = memory_read_dword(space, 0x01801404 + which * 8); int TCV = memory_read_dword(space, 0x01801404 + which * 8);
attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1)); attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
if(Timerctrl[which]&2) if (state->Timerctrl[which] & 2)
timer_adjust_periodic(Timer[which],period,0,period); timer_adjust_periodic(state->Timer[which], period, 0, period);
else else
timer_adjust_oneshot(Timer[which],period,0); timer_adjust_oneshot(state->Timer[which], period, 0);
} }
COMBINE_DATA(&Timerctrl[which]); COMBINE_DATA(&state->Timerctrl[which]);
} }
static WRITE32_HANDLER( Timer0_w ) static WRITE32_HANDLER( Timer0_w )
@ -270,7 +305,8 @@ static WRITE32_HANDLER(Timer0_w)
static READ32_HANDLER( Timer0_r ) static READ32_HANDLER( Timer0_r )
{ {
return Timerctrl[0]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->Timerctrl[0];
} }
static WRITE32_HANDLER( Timer1_w ) static WRITE32_HANDLER( Timer1_w )
@ -280,7 +316,8 @@ static WRITE32_HANDLER(Timer1_w)
static READ32_HANDLER( Timer1_r ) static READ32_HANDLER( Timer1_r )
{ {
return Timerctrl[1]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->Timerctrl[1];
} }
static WRITE32_HANDLER( Timer2_w ) static WRITE32_HANDLER( Timer2_w )
@ -290,7 +327,8 @@ static WRITE32_HANDLER(Timer2_w)
static READ32_HANDLER( Timer2_r ) static READ32_HANDLER( Timer2_r )
{ {
return Timerctrl[2]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->Timerctrl[2];
} }
static WRITE32_HANDLER( Timer3_w ) static WRITE32_HANDLER( Timer3_w )
@ -300,24 +338,27 @@ static WRITE32_HANDLER(Timer3_w)
static READ32_HANDLER( Timer3_r ) static READ32_HANDLER( Timer3_r )
{ {
return Timerctrl[3]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->Timerctrl[3];
} }
static READ32_HANDLER( FlashCmd_r ) static READ32_HANDLER( FlashCmd_r )
{ {
if((FlashCmd&0xff)==0xff) crystal_state *state = (crystal_state *)space->machine->driver_data;
if ((state->FlashCmd & 0xff) == 0xff)
{ {
if(Bank<=2) if (state->Bank <= 2)
{ {
UINT32 *ptr=(UINT32*)(memory_region(space->machine, "user1")+Bank*0x1000000); UINT32 *ptr = (UINT32*)(memory_region(space->machine, "user1") + state->Bank * 0x1000000);
return ptr[0]; return ptr[0];
} }
else else
return 0xffffffff; return 0xffffffff;
} }
if((FlashCmd&0xff)==0x90) if ((state->FlashCmd & 0xff) == 0x90)
{ {
if(Bank<=2) if (state->Bank <= 2)
return 0x00180089; //Intel 128MBit return 0x00180089; //Intel 128MBit
else else
return 0xffffffff; return 0xffffffff;
@ -327,38 +368,42 @@ static READ32_HANDLER(FlashCmd_r)
static WRITE32_HANDLER( FlashCmd_w ) static WRITE32_HANDLER( FlashCmd_w )
{ {
FlashCmd=data; crystal_state *state = (crystal_state *)space->machine->driver_data;
state->FlashCmd = data;
} }
static READ32_HANDLER( PIO_r ) static READ32_HANDLER( PIO_r )
{ {
return PIO; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->PIO;
} }
static WRITE32_HANDLER( PIO_w ) static WRITE32_HANDLER( PIO_w )
{ {
running_device *ds1302 = devtag_get_device(space->machine, "rtc"); crystal_state *state = (crystal_state *)space->machine->driver_data;
UINT32 RST = data & 0x01000000; UINT32 RST = data & 0x01000000;
UINT32 CLK = data & 0x02000000; UINT32 CLK = data & 0x02000000;
UINT32 DAT = data & 0x10000000; UINT32 DAT = data & 0x10000000;
if (!RST) if (!RST)
ds1302->reset(); state->ds1302->reset();
ds1302_dat_w(ds1302, 0, DAT ? 1 : 0); ds1302_dat_w(state->ds1302, 0, DAT ? 1 : 0);
ds1302_clk_w(ds1302, 0, CLK ? 1 : 0); ds1302_clk_w(state->ds1302, 0, CLK ? 1 : 0);
if (ds1302_read(ds1302, 0)) if (ds1302_read(state->ds1302, 0))
memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) | 0x10000000); memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) | 0x10000000);
else else
memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) & (~0x10000000)); memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) & (~0x10000000));
COMBINE_DATA(&PIO); COMBINE_DATA(&state->PIO);
} }
INLINE void DMA_w( const address_space *space, int which, UINT32 data, UINT32 mem_mask ) INLINE void DMA_w( const address_space *space, int which, UINT32 data, UINT32 mem_mask )
{ {
if(((data^DMActrl[which])&(1<<10)) && (data&(1<<10))) //DMAOn crystal_state *state = (crystal_state *)space->machine->driver_data;
if (((data ^ state->DMActrl[which]) & (1 << 10)) && (data & (1 << 10))) //DMAOn
{ {
UINT32 CTR = data; UINT32 CTR = data;
UINT32 SRC = memory_read_dword(space, 0x01800804 + which * 0x10); UINT32 SRC = memory_read_dword(space, 0x01800804 + which * 0x10);
@ -394,12 +439,13 @@ INLINE void DMA_w(const address_space *space, int which, UINT32 data, UINT32 mem
memory_write_dword(space, 0x0180080C + which * 0x10, 0); memory_write_dword(space, 0x0180080C + which * 0x10, 0);
IntReq(space->machine, 7 + which); IntReq(space->machine, 7 + which);
} }
COMBINE_DATA(&DMActrl[which]); COMBINE_DATA(&state->DMActrl[which]);
} }
static READ32_HANDLER(DMA0_r) static READ32_HANDLER(DMA0_r)
{ {
return DMActrl[0]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->DMActrl[0];
} }
static WRITE32_HANDLER(DMA0_w) static WRITE32_HANDLER(DMA0_w)
@ -409,7 +455,8 @@ static WRITE32_HANDLER(DMA0_w)
static READ32_HANDLER(DMA1_r) static READ32_HANDLER(DMA1_r)
{ {
return DMActrl[1]; crystal_state *state = (crystal_state *)space->machine->driver_data;
return state->DMActrl[1];
} }
static WRITE32_HANDLER(DMA1_w) static WRITE32_HANDLER(DMA1_w)
@ -425,34 +472,34 @@ static ADDRESS_MAP_START( crystal_mem, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x01280000, 0x01280003) AM_WRITE(Banksw_w) AM_RANGE(0x01280000, 0x01280003) AM_WRITE(Banksw_w)
AM_RANGE(0x01400000, 0x0140ffff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) AM_RANGE(0x01400000, 0x0140ffff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
AM_RANGE(0x01801400, 0x01801403) AM_READ(Timer0_r) AM_WRITE(Timer0_w) AM_RANGE(0x01801400, 0x01801403) AM_READWRITE(Timer0_r, Timer0_w)
AM_RANGE(0x01801408, 0x0180140b) AM_READ(Timer1_r) AM_WRITE(Timer1_w) AM_RANGE(0x01801408, 0x0180140b) AM_READWRITE(Timer1_r, Timer1_w)
AM_RANGE(0x01801410, 0x01801413) AM_READ(Timer2_r) AM_WRITE(Timer2_w) AM_RANGE(0x01801410, 0x01801413) AM_READWRITE(Timer2_r, Timer2_w)
AM_RANGE(0x01801418, 0x0180141b) AM_READ(Timer3_r) AM_WRITE(Timer3_w) AM_RANGE(0x01801418, 0x0180141b) AM_READWRITE(Timer3_r, Timer3_w)
AM_RANGE(0x01802004, 0x01802007) AM_WRITE(PIO_w) AM_READ(PIO_r) AM_RANGE(0x01802004, 0x01802007) AM_READWRITE(PIO_r, PIO_w)
AM_RANGE(0x01800800, 0x01800803) AM_READ(DMA0_r) AM_WRITE(DMA0_w) AM_RANGE(0x01800800, 0x01800803) AM_READWRITE(DMA0_r, DMA0_w)
AM_RANGE(0x01800810, 0x01800813) AM_READ(DMA1_r) AM_WRITE(DMA1_w) AM_RANGE(0x01800810, 0x01800813) AM_READWRITE(DMA1_r, DMA1_w)
AM_RANGE(0x01800c04, 0x01800c07) AM_WRITE(IntAck_w) AM_RANGE(0x01800c04, 0x01800c07) AM_WRITE(IntAck_w)
AM_RANGE(0x01800000, 0x0180ffff) AM_RAM AM_BASE(&sysregs) AM_RANGE(0x01800000, 0x0180ffff) AM_RAM AM_BASE_MEMBER(crystal_state, sysregs)
AM_RANGE(0x02000000, 0x027fffff) AM_RAM AM_BASE(&workram) AM_RANGE(0x02000000, 0x027fffff) AM_RAM AM_BASE_MEMBER(crystal_state, workram)
AM_RANGE(0x030000a4, 0x030000a7) AM_READ(FlipCount_r) AM_WRITE(FlipCount_w) AM_RANGE(0x030000a4, 0x030000a7) AM_READWRITE(FlipCount_r, FlipCount_w)
AM_RANGE(0x03000000, 0x0300ffff) AM_RAM AM_BASE(&vidregs) AM_RANGE(0x03000000, 0x0300ffff) AM_RAM AM_BASE_MEMBER(crystal_state, vidregs)
AM_RANGE(0x03800000, 0x03ffffff) AM_RAM AM_BASE(&textureram) AM_RANGE(0x03800000, 0x03ffffff) AM_RAM AM_BASE_MEMBER(crystal_state, textureram)
AM_RANGE(0x04000000, 0x047fffff) AM_RAM AM_BASE(&frameram) AM_RANGE(0x04000000, 0x047fffff) AM_RAM AM_BASE_MEMBER(crystal_state, frameram)
AM_RANGE(0x04800000, 0x04800fff) AM_DEVREADWRITE("vrender", vr0_snd_read, vr0_snd_write) AM_RANGE(0x04800000, 0x04800fff) AM_DEVREADWRITE("vrender", vr0_snd_read, vr0_snd_write)
AM_RANGE(0x05000000, 0x05000003) AM_READ(FlashCmd_r) AM_WRITE(FlashCmd_w) AM_RANGE(0x05000000, 0x05000003) AM_READWRITE(FlashCmd_r, FlashCmd_w)
AM_RANGE(0x05000000, 0x05ffffff) AM_ROMBANK("bank1") AM_RANGE(0x05000000, 0x05ffffff) AM_ROMBANK("bank1")
AM_RANGE(0x44414F4C, 0x44414F7F) AM_RAM AM_BASE(&ResetPatch) AM_RANGE(0x44414F4C, 0x44414F7F) AM_RAM AM_BASE_MEMBER(crystal_state, ResetPatch)
ADDRESS_MAP_END ADDRESS_MAP_END
static void PatchReset(void) static void PatchReset( running_machine *machine )
{ {
//The test menu reset routine seems buggy //The test menu reset routine seems buggy
//it reads the reset vector from 0x02000000 but it should be //it reads the reset vector from 0x02000000 but it should be
@ -476,6 +523,8 @@ loop:
JMP Loop1 JMP Loop1
*/ */
crystal_state *state = (crystal_state *)machine->driver_data;
#if 1 #if 1
static const UINT32 Patch[] = static const UINT32 Patch[] =
{ {
@ -487,7 +536,7 @@ loop:
0xdef4d4fa 0xdef4d4fa
}; };
memcpy(ResetPatch,Patch,sizeof(Patch)); memcpy(state->ResetPatch, Patch, sizeof(Patch));
#else #else
static const UINT8 Patch[] = static const UINT8 Patch[] =
{ {
@ -496,55 +545,71 @@ loop:
0x20,0x3A,0xD0,0xA1,0xFA,0xD4,0xF4,0xDE 0x20,0x3A,0xD0,0xA1,0xFA,0xD4,0xF4,0xDE
}; };
memcpy(ResetPatch,Patch,sizeof(Patch)); memcpy(state->ResetPatch, Patch, sizeof(Patch));
#endif #endif
} }
static MACHINE_START( crystal ) static MACHINE_START( crystal )
{ {
crystal_state *state = (crystal_state *)machine->driver_data;
int i; int i;
state->maincpu = devtag_get_device(machine, "maincpu");
state->ds1302 = devtag_get_device(machine, "rtc");
state->vr0video = devtag_get_device(machine, "vr0");
cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), icallback); cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), icallback);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
Timer[i] = timer_alloc(machine, Timercb, (void*)(FPTR)i); state->Timer[i] = timer_alloc(machine, Timercb, (void*)(FPTR)i);
PatchReset(); PatchReset(machine);
// save states
#ifdef IDLE_LOOP_SPEEDUP
state_save_register_global(machine, state->FlipCntRead);
#endif
state_save_register_global(machine, state->Bank);
state_save_register_global(machine, state->FlipCount);
state_save_register_global(machine, state->IntHigh);
state_save_register_global_array(machine, state->Timerctrl);
state_save_register_global(machine, state->OldPort4);
state_save_register_global(machine, state->FlashCmd);
state_save_register_global(machine, state->PIO);
state_save_register_global_array(machine, state->DMActrl);
state_save_register_global(machine, state->OldPort4);
} }
static MACHINE_RESET( crystal ) static MACHINE_RESET( crystal )
{ {
crystal_state *state = (crystal_state *)machine->driver_data;
int i; int i;
memset(sysregs, 0, 0x10000); memset(state->sysregs, 0, 0x10000);
memset(vidregs, 0, 0x10000); memset(state->vidregs, 0, 0x10000);
FlipCount = 0; state->FlipCount = 0;
IntHigh = 0; state->IntHigh = 0;
cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), icallback); cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), icallback);
Bank = 0; state->Bank = 0;
memory_set_bankptr(machine, "bank1", memory_region(machine, "user1") + 0); memory_set_bankptr(machine, "bank1", memory_region(machine, "user1") + 0);
FlashCmd = 0xff; state->FlashCmd = 0xff;
OldPort4 = 0; state->OldPort4 = 0;
DMActrl[0] = 0; state->DMActrl[0] = 0;
DMActrl[1] = 0; state->DMActrl[1] = 0;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
Timerctrl[i] = 0; state->Timerctrl[i] = 0;
timer_adjust_oneshot(Timer[i], attotime_never, 0); timer_adjust_oneshot(state->Timer[i], attotime_never, 0);
} }
vr0_snd_set_areas(devtag_get_device(machine, "vrender"), textureram, frameram); vr0_snd_set_areas(devtag_get_device(machine, "vrender"), state->textureram, state->frameram);
#ifdef IDLE_LOOP_SPEEDUP #ifdef IDLE_LOOP_SPEEDUP
FlipCntRead = 0; state->FlipCntRead = 0;
#endif #endif
PatchReset(); PatchReset(machine);
}
static VIDEO_START(crystal)
{
vrender0_init(machine);
} }
static UINT16 GetVidReg( const address_space *space, UINT16 reg ) static UINT16 GetVidReg( const address_space *space, UINT16 reg )
@ -560,10 +625,10 @@ static void SetVidReg(const address_space *space, UINT16 reg, UINT16 val)
static VIDEO_UPDATE( crystal ) static VIDEO_UPDATE( crystal )
{ {
crystal_state *state = (crystal_state *)screen->machine->driver_data;
const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM); const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
int DoFlip; int DoFlip;
UINT32 B0 = 0x0; UINT32 B0 = 0x0;
UINT32 B1 = (GetVidReg(space, 0x90) & 0x8000) ? 0x400000 : 0x100000; UINT32 B1 = (GetVidReg(space, 0x90) & 0x8000) ? 0x400000 : 0x100000;
UINT16 *Front, *Back; UINT16 *Front, *Back;
@ -575,17 +640,17 @@ static VIDEO_UPDATE(crystal)
if (GetVidReg(space, 0x8e) & 1) if (GetVidReg(space, 0x8e) & 1)
{ {
Front = (UINT16*) (frameram + B1 / 4); Front = (UINT16*) (state->frameram + B1 / 4);
Back = (UINT16*) (frameram + B0 / 4); Back = (UINT16*) (state->frameram + B0 / 4);
} }
else else
{ {
Front = (UINT16*) (frameram + B0 / 4); Front = (UINT16*) (state->frameram + B0 / 4);
Back = (UINT16*) (frameram + B1 / 4); Back = (UINT16*) (state->frameram + B1 / 4);
} }
Visible = (UINT16*) Front; Visible = (UINT16*) Front;
DrawDest = (UINT16 *) frameram; DrawDest = (UINT16 *) state->frameram;
if (GetVidReg(space, 0x8c) & 0x80) if (GetVidReg(space, 0x8c) & 0x80)
@ -602,7 +667,7 @@ static VIDEO_UPDATE(crystal)
tail = GetVidReg(space, 0x80); tail = GetVidReg(space, 0x80);
while ((head & 0x7ff) != (tail & 0x7ff)) while ((head & 0x7ff) != (tail & 0x7ff))
{ {
DoFlip = vrender0_ProcessPacket(space, 0x03800000 + head * 64, DrawDest, (UINT8*)textureram); DoFlip = vrender0_ProcessPacket(state->vr0video, 0x03800000 + head * 64, DrawDest, (UINT8*)state->textureram);
head++; head++;
head &= 0x7ff; head &= 0x7ff;
if (DoFlip) if (DoFlip)
@ -621,6 +686,7 @@ static VIDEO_UPDATE(crystal)
static VIDEO_EOF(crystal) static VIDEO_EOF(crystal)
{ {
crystal_state *state = (crystal_state *)machine->driver_data;
const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
UINT16 head, tail; UINT16 head, tail;
int DoFlip = 0; int DoFlip = 0;
@ -640,8 +706,8 @@ static VIDEO_EOF(crystal)
SetVidReg(space, 0x82, head); SetVidReg(space, 0x82, head);
if (DoFlip) if (DoFlip)
{ {
if(FlipCount) if (state->FlipCount)
FlipCount--; state->FlipCount--;
} }
} }
@ -736,8 +802,15 @@ static const vr0_interface vr0_config =
0x04800000 0x04800000
}; };
static const vr0video_interface vr0video_config =
{
"maincpu"
};
static MACHINE_DRIVER_START( crystal ) static MACHINE_DRIVER_START( crystal )
MDRV_DRIVER_DATA(crystal_state)
MDRV_CPU_ADD("maincpu", SE3208, 43000000) MDRV_CPU_ADD("maincpu", SE3208, 43000000)
MDRV_CPU_PROGRAM_MAP(crystal_mem) MDRV_CPU_PROGRAM_MAP(crystal_mem)
MDRV_CPU_VBLANK_INT("screen", crystal_interrupt) MDRV_CPU_VBLANK_INT("screen", crystal_interrupt)
@ -754,10 +827,11 @@ static MACHINE_DRIVER_START( crystal )
MDRV_SCREEN_SIZE(320, 240) MDRV_SCREEN_SIZE(320, 240)
MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239)
MDRV_VIDEO_START(crystal)
MDRV_VIDEO_UPDATE(crystal) MDRV_VIDEO_UPDATE(crystal)
MDRV_VIDEO_EOF(crystal) MDRV_VIDEO_EOF(crystal)
MDRV_VIDEO_VRENDER0_ADD("vr0", vr0video_config)
MDRV_PALETTE_INIT(RRRRR_GGGGGG_BBBBB) MDRV_PALETTE_INIT(RRRRR_GGGGGG_BBBBB)
MDRV_PALETTE_LENGTH(65536) MDRV_PALETTE_LENGTH(65536)

View File

@ -20,50 +20,6 @@ Missing:
**************/ **************/
static UINT16 InternalPalette[256];
static UINT32 LastPalUpdate;
/*
Pick a rare enough color to disable transparency (that way I save a cmp per loop to check
if I must draw transparent or not. The palette build will take this color in account so
no color in the palette will have this value
*/
#define NOTRANSCOLOR 0xecda
#define RGB32(r,g,b) ((r<<16)|(g<<8)|(b<<0))
#define RGB16(r,g,b) ((r&0xf8)<<8)|((g&0xfc)<<3)|((b&0xf8)>>3)
INLINE UINT16 RGB32TO16(UINT32 rgb)
{
return (((rgb>>(16+3))&0x1f)<<11)|(((rgb>>(8+2))&0x3f)<<5)|(((rgb>>(3))&0x1f)<<0);
}
typedef struct
{
UINT32 Tx;
UINT32 Ty;
UINT32 Txdx;
UINT32 Tydx;
UINT32 Txdy;
UINT32 Tydy;
UINT32 SrcAlphaColor;
UINT32 SrcBlend;
UINT32 DstAlphaColor;
UINT32 DstBlend;
UINT32 ShadeColor;
UINT32 TransColor;
UINT32 TileOffset;
UINT32 FontOffset;
UINT32 PalOffset;
UINT32 PaletteBank;
UINT32 TextureMode;
UINT32 PixelFormat;
UINT32 Width;
UINT32 Height;
} _RenderState;
static _RenderState RenderState;
typedef struct typedef struct
{ {
UINT16 *Dest; UINT16 *Dest;
@ -94,6 +50,81 @@ typedef struct
UINT32 DstColor; UINT32 DstColor;
} _Quad; } _Quad;
typedef struct
{
UINT32 Tx;
UINT32 Ty;
UINT32 Txdx;
UINT32 Tydx;
UINT32 Txdy;
UINT32 Tydy;
UINT32 SrcAlphaColor;
UINT32 SrcBlend;
UINT32 DstAlphaColor;
UINT32 DstBlend;
UINT32 ShadeColor;
UINT32 TransColor;
UINT32 TileOffset;
UINT32 FontOffset;
UINT32 PalOffset;
UINT32 PaletteBank;
UINT32 TextureMode;
UINT32 PixelFormat;
UINT32 Width;
UINT32 Height;
} _RenderState;
typedef struct _vr0video_state vr0video_state;
struct _vr0video_state
{
running_device *cpu;
UINT16 InternalPalette[256];
UINT32 LastPalUpdate;
_RenderState RenderState;
};
/*****************************************************************************
INLINE FUNCTIONS
*****************************************************************************/
INLINE vr0video_state *get_safe_token( running_device *device )
{
assert(device != NULL);
assert(device->token != NULL);
assert(device->type == VRENDER0_VIDEO);
return (vr0video_state *)device->token;
}
INLINE const vr0video_interface *get_interface( running_device *device )
{
assert(device != NULL);
assert(device->type == VRENDER0_VIDEO);
return (const vr0video_interface *) device->baseconfig().static_config;
}
/*****************************************************************************
IMPLEMENTATION
*****************************************************************************/
/*
Pick a rare enough color to disable transparency (that way I save a cmp per loop to check
if I must draw transparent or not. The palette build will take this color in account so
no color in the palette will have this value
*/
#define NOTRANSCOLOR 0xecda
#define RGB32(r,g,b) ((r << 16) | (g << 8) | (b << 0))
#define RGB16(r,g,b) ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3)
INLINE UINT16 RGB32TO16(UINT32 rgb)
{
return (((rgb >> (16 + 3)) & 0x1f) << 11) | (((rgb >> (8 + 2)) & 0x3f) << 5) | (((rgb >> (3)) & 0x1f) << 0);
}
#define EXTRACTR8(Src) (((Src >> 11) << 3) & 0xff) #define EXTRACTR8(Src) (((Src >> 11) << 3) & 0xff)
#define EXTRACTG8(Src) (((Src >> 5) << 2) & 0xff) #define EXTRACTG8(Src) (((Src >> 5) << 2) & 0xff)
#define EXTRACTB8(Src) (((Src >> 0) << 3) & 0xff) #define EXTRACTB8(Src) (((Src >> 0) << 3) & 0xff)
@ -147,6 +178,7 @@ static UINT16 Alpha(_Quad *Quad,UINT16 Src,UINT16 Dst)
smulr = smulg = smulb = 0; smulr = smulg = smulb = 0;
break; break;
} }
if (Quad->SrcAlpha & 0x20) if (Quad->SrcAlpha & 0x20)
{ {
smulr = 0x100 - smulr; smulr = 0x100 - smulr;
@ -183,6 +215,7 @@ static UINT16 Alpha(_Quad *Quad,UINT16 Src,UINT16 Dst)
dmulr = dmulg = dmulb = 0; dmulr = dmulg = dmulb = 0;
break; break;
} }
if (Quad->DstAlpha&0x20) if (Quad->DstAlpha&0x20)
{ {
dmulr = 0x100 - dmulr; dmulr = 0x100 - dmulr;
@ -194,12 +227,15 @@ static UINT16 Alpha(_Quad *Quad,UINT16 Src,UINT16 Dst)
dcr = (scr * smulr + dcr * dmulr) >> 8; dcr = (scr * smulr + dcr * dmulr) >> 8;
if (dcr > 0xff) if (dcr > 0xff)
dcr = 0xff; dcr = 0xff;
dcg = (scg * smulg + dcg * dmulg) >> 8; dcg = (scg * smulg + dcg * dmulg) >> 8;
if (dcg > 0xff) if (dcg > 0xff)
dcg = 0xff; dcg = 0xff;
dcb = (scb * smulb + dcb * dmulb) >> 8; dcb = (scb * smulb + dcb * dmulb) >> 8;
if (dcb > 0xff) if (dcb > 0xff)
dcb = 0xff; dcb = 0xff;
return RGB16(dcr, dcg, dcb); return RGB16(dcr, dcg, dcb);
} }
@ -364,15 +400,11 @@ static const _DrawTemplate DrawTile[]=
#define Packet(i) memory_read_word(space, PacketPtr + 2 * i) #define Packet(i) memory_read_word(space, PacketPtr + 2 * i)
void vrender0_init(running_machine *machine)
{
memset(InternalPalette, 0, sizeof(InternalPalette));
LastPalUpdate=0xffffffff;
}
//Returns TRUE if the operation was a flip (sync or async) //Returns TRUE if the operation was a flip (sync or async)
int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *Dest,UINT8 *TEXTURE) int vrender0_ProcessPacket(running_device *device, UINT32 PacketPtr, UINT16 *Dest, UINT8 *TEXTURE)
{ {
vr0video_state *vr0 = get_safe_token(device);
const address_space *space = cpu_get_address_space(vr0->cpu, ADDRESS_SPACE_PROGRAM);
UINT32 Dx = Packet(1) & 0x3ff; UINT32 Dx = Packet(1) & 0x3ff;
UINT32 Dy = Packet(2) & 0x1ff; UINT32 Dy = Packet(2) & 0x1ff;
UINT32 Endx = Packet(3) & 0x3ff; UINT32 Endx = Packet(3) & 0x3ff;
@ -382,77 +414,76 @@ int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *
if (Packet0 & 0x81) //Sync or ASync flip if (Packet0 & 0x81) //Sync or ASync flip
{ {
LastPalUpdate=0xffffffff; //Force update palette next frame vr0->LastPalUpdate = 0xffffffff; //Force update palette next frame
return 1; return 1;
} }
if (Packet0 & 0x200) if (Packet0 & 0x200)
{ {
RenderState.Tx=Packet(5)|((Packet(6)&0x1F)<<16); vr0->RenderState.Tx = Packet(5) | ((Packet(6) & 0x1f) << 16);
RenderState.Ty=Packet(7)|((Packet(8)&0x1F)<<16); vr0->RenderState.Ty = Packet(7) | ((Packet(8) & 0x1f) << 16);
} }
else else
{ {
RenderState.Tx=0; vr0->RenderState.Tx = 0;
RenderState.Ty=0; vr0->RenderState.Ty = 0;
} }
if (Packet0 & 0x400) if (Packet0 & 0x400)
{ {
RenderState.Txdx=Packet(9)|((Packet(10)&0x1F)<<16); vr0->RenderState.Txdx = Packet(9) | ((Packet(10) & 0x1f) << 16);
RenderState.Tydx=Packet(11)|((Packet(12)&0x1F)<<16); vr0->RenderState.Tydx = Packet(11) | ((Packet(12) & 0x1f) << 16);
RenderState.Txdy=Packet(13)|((Packet(14)&0x1F)<<16); vr0->RenderState.Txdy = Packet(13) | ((Packet(14) & 0x1f) << 16);
RenderState.Tydy=Packet(15)|((Packet(16)&0x1F)<<16); vr0->RenderState.Tydy = Packet(15) | ((Packet(16) & 0x1f) << 16);
} }
else else
{ {
RenderState.Txdx=1<<9; vr0->RenderState.Txdx = 1 << 9;
RenderState.Tydx=0; vr0->RenderState.Tydx = 0;
RenderState.Txdy=0; vr0->RenderState.Txdy = 0;
RenderState.Tydy=1<<9; vr0->RenderState.Tydy = 1 << 9;
} }
if (Packet0 & 0x800) if (Packet0 & 0x800)
{ {
RenderState.SrcAlphaColor=Packet(17)|((Packet(18)&0xff)<<16); vr0->RenderState.SrcAlphaColor = Packet(17) | ((Packet(18) & 0xff) << 16);
RenderState.SrcBlend=(Packet(18)>>8)&0x3f; vr0->RenderState.SrcBlend = (Packet(18) >> 8) & 0x3f;
RenderState.DstAlphaColor=Packet(19)|((Packet(20)&0xff)<<16); vr0->RenderState.DstAlphaColor = Packet(19) | ((Packet(20) & 0xff) << 16);
RenderState.DstBlend=(Packet(20)>>8)&0x3f; vr0->RenderState.DstBlend = (Packet(20) >> 8) & 0x3f;
} }
if (Packet0 & 0x1000) if (Packet0 & 0x1000)
RenderState.ShadeColor=Packet(21)|((Packet(22)&0xFF)<<16); vr0->RenderState.ShadeColor = Packet(21) | ((Packet(22) & 0xff) << 16);
if (Packet0 & 0x2000) if (Packet0 & 0x2000)
RenderState.TransColor=Packet(23)|((Packet(24)&0xFF)<<16); vr0->RenderState.TransColor = Packet(23) | ((Packet(24) & 0xff) << 16);
if (Packet0 & 0x4000) if (Packet0 & 0x4000)
{ {
RenderState.TileOffset=Packet(25); vr0->RenderState.TileOffset = Packet(25);
RenderState.FontOffset=Packet(26); vr0->RenderState.FontOffset = Packet(26);
RenderState.PalOffset=Packet(27)>>3; vr0->RenderState.PalOffset = Packet(27) >> 3;
RenderState.PaletteBank=(Packet(28)>>8)&0xF; vr0->RenderState.PaletteBank = (Packet(28) >> 8) & 0xf;
RenderState.TextureMode=Packet(28)&0x1000; vr0->RenderState.TextureMode = Packet(28) & 0x1000;
RenderState.PixelFormat=(Packet(28)>>6)&3; vr0->RenderState.PixelFormat = (Packet(28) >> 6) & 3;
RenderState.Width =8<<((Packet(28)>>0)&0x7); vr0->RenderState.Width = 8 << ((Packet(28) >> 0) & 0x7);
RenderState.Height=8<<((Packet(28)>>3)&0x7); vr0->RenderState.Height = 8 << ((Packet(28) >> 3) & 0x7);
} }
if (Packet0 & 0x40 && vr0->RenderState.PalOffset != vr0->LastPalUpdate)
if(Packet0&0x40 && RenderState.PalOffset!=LastPalUpdate)
{ {
UINT32 *Pal=(UINT32*) (TEXTURE+1024*RenderState.PalOffset); UINT32 *Pal = (UINT32*) (TEXTURE + 1024 * vr0->RenderState.PalOffset);
UINT16 Trans=RGB32TO16(RenderState.TransColor); UINT16 Trans = RGB32TO16(vr0->RenderState.TransColor);
int i; int i;
for (i = 0; i < 256; ++i) for (i = 0; i < 256; ++i)
{ {
UINT32 p = Pal[i]; UINT32 p = Pal[i];
UINT16 v = RGB32TO16(p); UINT16 v = RGB32TO16(p);
if((v==Trans && p!=RenderState.TransColor) || v==NOTRANSCOLOR) //Error due to conversion. caused transparent if ((v == Trans && p != vr0->RenderState.TransColor) || v == NOTRANSCOLOR) //Error due to conversion. caused transparent
{ {
if ((v & 0x1f) != 0x1f) if ((v & 0x1f) != 0x1f)
v++; //Make the color a bit different (blueish) so it's not v++; //Make the color a bit different (blueish) so it's not
else else
v--; v--;
} }
InternalPalette[i]=v; //made transparent by mistake vr0->InternalPalette[i] = v; //made transparent by mistake
} }
LastPalUpdate=RenderState.PalOffset; vr0->LastPalUpdate = vr0->RenderState.PalOffset;
} }
if (Packet0 & 0x100) if (Packet0 & 0x100)
@ -465,10 +496,10 @@ int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *
if (Packet0 & 2) if (Packet0 & 2)
{ {
Quad.SrcAlpha=RenderState.SrcBlend; Quad.SrcAlpha = vr0->RenderState.SrcBlend;
Quad.DstAlpha=RenderState.DstBlend; Quad.DstAlpha = vr0->RenderState.DstBlend;
Quad.SrcColor=RenderState.SrcAlphaColor; Quad.SrcColor = vr0->RenderState.SrcAlphaColor;
Quad.DstColor=RenderState.DstAlphaColor; Quad.DstColor = vr0->RenderState.DstAlphaColor;
Mode = 1; Mode = 1;
} }
else else
@ -480,15 +511,15 @@ int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *
Quad.Dest = (UINT16*) Dest; Quad.Dest = (UINT16*) Dest;
Quad.Dest = Quad.Dest + Dx + (Dy * Quad.Pitch); Quad.Dest = Quad.Dest + Dx + (Dy * Quad.Pitch);
Quad.Tx=RenderState.Tx; Quad.Tx = vr0->RenderState.Tx;
Quad.Ty=RenderState.Ty; Quad.Ty = vr0->RenderState.Ty;
Quad.Txdx=RenderState.Txdx; Quad.Txdx = vr0->RenderState.Txdx;
Quad.Tydx=RenderState.Tydx; Quad.Tydx = vr0->RenderState.Tydx;
Quad.Txdy=RenderState.Txdy; Quad.Txdy = vr0->RenderState.Txdy;
Quad.Tydy=RenderState.Tydy; Quad.Tydy = vr0->RenderState.Tydy;
if (Packet0 & 0x10) if (Packet0 & 0x10)
{ {
Quad.Shade=RenderState.ShadeColor; Quad.Shade = vr0->RenderState.ShadeColor;
if (!Mode) //Alpha includes Shade if (!Mode) //Alpha includes Shade
Mode = 2; Mode = 2;
/* /*
@ -501,28 +532,81 @@ int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *
} }
else else
Quad.Shade = RGB32(255,255,255); Quad.Shade = RGB32(255,255,255);
Quad.TransColor=RenderState.TransColor; Quad.TransColor = vr0->RenderState.TransColor;
Quad.TWidth=RenderState.Width; Quad.TWidth = vr0->RenderState.Width;
Quad.THeight=RenderState.Height; Quad.THeight = vr0->RenderState.Height;
Quad.Trans = Packet0 & 4; Quad.Trans = Packet0 & 4;
//Quad.Trans = 0; //Quad.Trans = 0;
Quad.Clamp = Packet0 & 0x20; Quad.Clamp = Packet0 & 0x20;
if (Packet0 & 0x8) //Texture Enable if (Packet0 & 0x8) //Texture Enable
{ {
Quad.u.Imageb=TEXTURE+128*RenderState.FontOffset; Quad.u.Imageb = TEXTURE + 128 * vr0->RenderState.FontOffset;
Quad.Tile=(UINT16*) (TEXTURE+128*RenderState.TileOffset); Quad.Tile = (UINT16*) (TEXTURE + 128 * vr0->RenderState.TileOffset);
if(!RenderState.PixelFormat) if (!vr0->RenderState.PixelFormat)
Quad.Pal=InternalPalette+(RenderState.PaletteBank*16); Quad.Pal = vr0->InternalPalette + (vr0->RenderState.PaletteBank * 16);
else else
Quad.Pal=InternalPalette; Quad.Pal = vr0->InternalPalette;
if(RenderState.TextureMode) //Tiled if (vr0->RenderState.TextureMode) //Tiled
DrawTile[RenderState.PixelFormat+4*Mode](&Quad); DrawTile[vr0->RenderState.PixelFormat + 4 * Mode](&Quad);
else else
DrawImage[RenderState.PixelFormat+4*Mode](&Quad); DrawImage[vr0->RenderState.PixelFormat + 4 * Mode](&Quad);
} }
else else
DrawQuadFill(&Quad); DrawQuadFill(&Quad);
} }
return 0; return 0;
} }
/*****************************************************************************
DEVICE INTERFACE
*****************************************************************************/
static DEVICE_START( vr0video )
{
vr0video_state *vr0 = get_safe_token(device);
const vr0video_interface *intf = get_interface(device);
vr0->cpu = devtag_get_device(device->machine, intf->cpu);
state_save_register_device_item_array(device, 0, vr0->InternalPalette);
state_save_register_device_item(device, 0, vr0->LastPalUpdate);
state_save_register_device_item(device, 0, vr0->RenderState.Tx);
state_save_register_device_item(device, 0, vr0->RenderState.Ty);
state_save_register_device_item(device, 0, vr0->RenderState.Txdx);
state_save_register_device_item(device, 0, vr0->RenderState.Tydx);
state_save_register_device_item(device, 0, vr0->RenderState.Txdy);
state_save_register_device_item(device, 0, vr0->RenderState.Tydy);
state_save_register_device_item(device, 0, vr0->RenderState.SrcAlphaColor);
state_save_register_device_item(device, 0, vr0->RenderState.SrcBlend);
state_save_register_device_item(device, 0, vr0->RenderState.DstAlphaColor);
state_save_register_device_item(device, 0, vr0->RenderState.DstBlend);
state_save_register_device_item(device, 0, vr0->RenderState.ShadeColor);
state_save_register_device_item(device, 0, vr0->RenderState.TransColor);
state_save_register_device_item(device, 0, vr0->RenderState.TileOffset);
state_save_register_device_item(device, 0, vr0->RenderState.FontOffset);
state_save_register_device_item(device, 0, vr0->RenderState.PalOffset);
state_save_register_device_item(device, 0, vr0->RenderState.PaletteBank);
state_save_register_device_item(device, 0, vr0->RenderState.TextureMode);
state_save_register_device_item(device, 0, vr0->RenderState.PixelFormat);
state_save_register_device_item(device, 0, vr0->RenderState.Width);
state_save_register_device_item(device, 0, vr0->RenderState.Height);
}
static DEVICE_RESET( vr0video )
{
vr0video_state *vr0 = get_safe_token(device);
memset(vr0->InternalPalette, 0, sizeof(vr0->InternalPalette));
vr0->LastPalUpdate = 0xffffffff;
}
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
#define DEVTEMPLATE_ID( p, s ) p##vr0video##s
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
#define DEVTEMPLATE_NAME "VRender0"
#define DEVTEMPLATE_FAMILY "???"
#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO
#include "devtempl.h"

View File

@ -1,2 +1,40 @@
extern void vrender0_init(running_machine *machine); #ifndef __VR0VIDEO_H__
extern int vrender0_ProcessPacket(const address_space *space, UINT32 PacketPtr,UINT16 *Dest,UINT8 *TEXTURE); #define __VR0VIDEO_H__
#include "devcb.h"
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
typedef struct _vr0video_interface vr0video_interface;
struct _vr0video_interface
{
const char *cpu;
};
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
DEVICE_GET_INFO( vr0video );
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define VIDEO_VRENDER0 DEVICE_GET_INFO_NAME( vr0video )
#define MDRV_VIDEO_VRENDER0_ADD(_tag, _interface) \
MDRV_DEVICE_ADD(_tag, VIDEO_VRENDER0, 0) \
MDRV_DEVICE_CONFIG(_interface)
/***************************************************************************
DEVICE I/O FUNCTIONS
***************************************************************************/
extern int vrender0_ProcessPacket(running_device *device, UINT32 PacketPtr, UINT16 *Dest, UINT8 *TEXTURE);
#endif /* __VR0VIDEO_H__ */