Skip to content

Commit

Permalink
[VIDBRAIN] Separated video chip to own device. (nw)
Browse files Browse the repository at this point in the history
git-svn-id: svn://messdev.no-ip.org/mess@15128 9849079f-6229-0410-a07f-84406ce305ba
  • Loading branch information
curtcoder committed May 9, 2012
1 parent 698709e commit 512d5a5
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 203 deletions.
80 changes: 67 additions & 13 deletions src/mess/drivers/vidbrain.c
Expand Up @@ -17,6 +17,7 @@
TODO:
- video interrupts
- R-2R ladder DAC
- reset on cartridge unload
- use machine/f3853.h
- joystick scan timer 555
Expand Down Expand Up @@ -90,7 +91,7 @@ READ8_MEMBER( vidbrain_state::keyboard_r )
if (BIT(m_keylatch, 5)) data |= ioport("IO05")->read();
if (BIT(m_keylatch, 6)) data |= ioport("IO06")->read();
if (BIT(m_keylatch, 7)) data |= ioport("IO07")->read();
if (!BIT(m_cmd, 4)) data |= ioport("UV201-31")->read();
if (!m_uv->kbd_r()) data |= ioport("UV201-31")->read();

return data;
}
Expand Down Expand Up @@ -129,6 +130,12 @@ WRITE8_MEMBER( vidbrain_state::sound_w )

// joystick enable
m_joy_enable = BIT(data, 7);

if (m_joy_enable)
{
// TODO calculate NE555 firing time based on input port values
//timer_set(attotime::from_msec(t), TIMER_JOYSTICK);
}
}


Expand All @@ -151,7 +158,7 @@ void vidbrain_state::interrupt_check()
break;
}

device_set_input_line(m_maincpu, F8_INPUT_LINE_INT_REQ, interrupt);
m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, interrupt);
}


Expand All @@ -166,27 +173,27 @@ WRITE8_MEMBER( vidbrain_state::f3853_w )
case 0:
// interrupt vector address high
m_vector = (data << 8) | (m_vector & 0xff);
logerror("F3853 Interrupt Vector %04x\n", m_vector);
logerror("%s: F3853 Interrupt Vector %04x\n", machine().describe_context(), m_vector);
break;

case 1:
// interrupt vector address low
m_vector = (m_vector & 0xff00) | data;
logerror("F3853 Interrupt Vector %04x\n", m_vector);
logerror("%s: F3853 Interrupt Vector %04x\n", machine().describe_context(), m_vector);
break;

case 2:
// interrupt control
m_int_enable = data & 0x03;
logerror("F3853 Interrupt Control %u\n", m_int_enable);
logerror("%s: F3853 Interrupt Control %u\n", machine().describe_context(), m_int_enable);
interrupt_check();

if (m_int_enable == 0x03) fatalerror("F3853 Timer not supported!");
break;

case 3:
// timer 8-bit polynomial counter
fatalerror("F3853 Timer not supported!");
fatalerror("%s: F3853 Timer not supported!", machine().describe_context());
break;
}
}
Expand All @@ -203,7 +210,7 @@ WRITE8_MEMBER( vidbrain_state::f3853_w )

static ADDRESS_MAP_START( vidbrain_mem, AS_PROGRAM, 8, vidbrain_state )
AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0xc000) AM_ROM
AM_RANGE(0x0800, 0x08ff) AM_READWRITE(vlsi_r, vlsi_w)
AM_RANGE(0x0800, 0x08ff) AM_MIRROR(0x0300) AM_DEVREADWRITE(UV201_TAG, uv201_device, read, write)
AM_RANGE(0x0c00, 0x0fff) AM_MIRROR(0xe000) AM_RAM
AM_RANGE(0x1000, 0x1fff) AM_MIRROR(0xe000) AM_ROM
AM_RANGE(0x2000, 0x27ff) AM_MIRROR(0xc000) AM_ROM
Expand Down Expand Up @@ -367,8 +374,7 @@ static void f3853_int_req_w(device_t *device, UINT16 addr, int level)
{
vidbrain_state *state = device->machine().driver_data<vidbrain_state>();

device_set_input_line_vector(state->m_maincpu, F8_INPUT_LINE_INT_REQ, addr);

state->m_vector = addr;
state->m_maincpu->set_input_line(F8_INPUT_LINE_INT_REQ, level);
}

Expand All @@ -378,6 +384,29 @@ static const f3853_interface smi_intf =
};


//-------------------------------------------------
// UV201_INTERFACE( uv_intf )
//-------------------------------------------------

WRITE_LINE_MEMBER( vidbrain_state::ext_int_w )
{
if (state)
{
m_ext_int_latch = state;
interrupt_check();
}
}

static UINT8 memory_read_byte(address_space *space, offs_t address) { return space->read_byte(address); }

static UV201_INTERFACE( uv_intf )
{
SCREEN_TAG,
DEVCB_DRIVER_LINE_MEMBER(vidbrain_state, ext_int_w),
DEVCB_MEMORY_HANDLER(F3850_TAG, PROGRAM, memory_read_byte)
};



//**************************************************************************
// MACHINE INITIALIZATION
Expand All @@ -391,20 +420,34 @@ static IRQ_CALLBACK( vidbrain_int_ack )
{
vidbrain_state *state = device->machine().driver_data<vidbrain_state>();

UINT16 vector = state->m_vector;

switch (state->m_int_enable)
{
case 1:
vector |= 0x80;
state->m_ext_int_latch = 0;
break;

case 3:
vector &= ~0x80;
state->m_timer_int_latch = 0;
break;
}

state->interrupt_check();

return state->m_vector;
return vector;
}


//-------------------------------------------------
// device_timer - handler timer events
//-------------------------------------------------

void vidbrain_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
m_uv->ext_int_w(0);
}


Expand All @@ -428,6 +471,17 @@ void vidbrain_state::machine_start()
}


//-------------------------------------------------
// MACHINE_RESET( vidbrain )
//-------------------------------------------------

void vidbrain_state::machine_reset()
{
m_int_enable = 0;
m_ext_int_latch = 0;
m_timer_int_latch = 0;
}


//**************************************************************************
// MACHINE CONFIGURATION
Expand All @@ -444,8 +498,8 @@ static MACHINE_CONFIG_START( vidbrain, vidbrain_state )
MCFG_CPU_IO_MAP(vidbrain_io)

// video hardware
MCFG_FRAGMENT_ADD(vidbrain_video)

MCFG_UV201_ADD(UV201_TAG, SCREEN_TAG, XTAL_14_31818MHz, uv_intf)
// sound hardware
MCFG_SPEAKER_STANDARD_MONO("mono")

Expand Down Expand Up @@ -493,4 +547,4 @@ ROM_END
//**************************************************************************

// YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS
COMP( 1977, vidbrain, 0, 0, vidbrain, vidbrain, 0, "VideoBrain Computer Company", "VideoBrain FamilyComputer", GAME_NOT_WORKING )
COMP( 1977, vidbrain, 0, 0, vidbrain, vidbrain, 0, "VideoBrain Computer Company", "VideoBrain FamilyComputer", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
37 changes: 12 additions & 25 deletions src/mess/includes/vidbrain.h
Expand Up @@ -9,13 +9,13 @@
#include "machine/f3853.h"
#include "machine/ram.h"
#include "sound/discrete.h"
#include "video/uv201.h"

#define F3850_TAG "cd34"
#define F3853_TAG "cd5"
#define UV201_TAG "uv201"
#define SCREEN_TAG "screen"
#define DISCRETE_TAG "discrete"
#define TIMER_Y_ODD_TAG "odd"
#define TIMER_Y_EVEN_TAG "even"

class vidbrain_state : public driver_device
{
Expand All @@ -24,37 +24,34 @@ class vidbrain_state : public driver_device
: driver_device(mconfig, type, tag),
m_maincpu(*this, F3850_TAG),
m_smi(*this, F3853_TAG),
m_uv(*this, UV201_TAG),
m_discrete(*this, DISCRETE_TAG),
m_screen(*this, SCREEN_TAG),
m_timer_y_odd(*this, TIMER_Y_ODD_TAG),
m_timer_y_even(*this, TIMER_Y_EVEN_TAG)
m_screen(*this, SCREEN_TAG)
{ }

required_device<cpu_device> m_maincpu;
required_device<f3853_device> m_smi;
required_device<uv201_device> m_uv;
required_device<device_t> m_discrete;
required_device<screen_device> m_screen;
required_device<timer_device> m_timer_y_odd;
required_device<timer_device> m_timer_y_even;

virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
virtual void machine_start();
virtual void machine_reset();

virtual void video_start();
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
enum
{
TIMER_JOYSTICK
};

DECLARE_WRITE8_MEMBER( keyboard_w );
DECLARE_READ8_MEMBER( keyboard_r );
DECLARE_WRITE8_MEMBER( sound_w );
DECLARE_WRITE8_MEMBER( f3853_w );
DECLARE_READ8_MEMBER( vlsi_r );
DECLARE_WRITE8_MEMBER( vlsi_w );
DECLARE_INPUT_CHANGED_MEMBER( trigger_reset );
DECLARE_WRITE_LINE_MEMBER( ext_int_w );

void interrupt_check();
int get_field_vpos();
int get_field();
void set_y_interrupt();
void do_partial_update();

// F3853 SMI state
UINT16 m_vector;
Expand All @@ -66,16 +63,6 @@ class vidbrain_state : public driver_device
UINT8 m_keylatch;
int m_joy_enable;

// video state
UINT8 m_vlsi_ram[0x90];
UINT8 m_y_int;
UINT8 m_fmod;
UINT8 m_bg;
UINT8 m_cmd;
UINT8 m_freeze_x;
UINT16 m_freeze_y;
int m_field;

// sound state
int m_sound_clk;
};
Expand Down
4 changes: 2 additions & 2 deletions src/mess/mess.mak
Expand Up @@ -1803,11 +1803,11 @@ $(MESSOBJ)/veb.a: \

$(MESSOBJ)/vidbrain.a: \
$(MESS_DRIVERS)/vidbrain.o \
$(MESS_VIDEO)/vidbrain.o \
$(MESS_VIDEO)/uv201.o \

$(MESSOBJ)/videoton.a: \
$(MESS_DRIVERS)/tvc.o \
$(MESS_AUDIO)/tvc.o \
$(MESS_AUDIO)/tvc.o \

$(MESSOBJ)/visual.a: \
$(MESS_DRIVERS)/v1050.o \
Expand Down

0 comments on commit 512d5a5

Please sign in to comment.