i186: fix timer read (nw)

(mess) rmnimbus: bit of refactoring and cleanup, fix some video ram reads and writes, use eepromser and remove er59256 (nw)
This commit is contained in:
cracyc 2014-06-18 03:10:07 +00:00
parent dd842afff6
commit 2df40a8073
12 changed files with 226 additions and 704 deletions

2
.gitattributes vendored
View File

@ -2584,8 +2584,6 @@ src/emu/machine/eepromser.c svneol=native#text/plain
src/emu/machine/eepromser.h svneol=native#text/plain
src/emu/machine/er2055.c svneol=native#text/plain
src/emu/machine/er2055.h svneol=native#text/plain
src/emu/machine/er59256.c svneol=native#text/plain
src/emu/machine/er59256.h svneol=native#text/plain
src/emu/machine/f3853.c svneol=native#text/plain
src/emu/machine/f3853.h svneol=native#text/plain
src/emu/machine/fdc_pll.c svneol=native#text/plain

View File

@ -1008,6 +1008,7 @@ void i80186_cpu_device::device_timer(emu_timer &timer, device_timer_id id, int p
count = count ? count : 0x10000;
t->int_timer->adjust((attotime::from_hz(clock()/8) * count), which);
t->count = 0;
if (LOG_TIMER) logerror(" Repriming interrupt\n");
}
else
@ -1041,7 +1042,11 @@ void i80186_cpu_device::internal_timer_sync(int which)
/* if we have a timing timer running, adjust the count */
if (t->time_timer_active && !(t->control & 0x0c))
{
t->last_time = t->time_timer->elapsed();
attotime current_time = t->time_timer->elapsed();
int net_clocks = ((current_time - t->last_time) * (clock()/8)).seconds;
t->last_time = current_time;
t->count = t->count + net_clocks;
}
}

View File

@ -2077,7 +2077,7 @@ bool i8086_common_cpu_device::common_op(UINT8 op)
break;
case 0xf4: // i_hlt
logerror("%s: %06x: HALT\n", tag(), pc());
//logerror("%s: %06x: HALT\n", tag(), pc());
m_icount = 0;
m_halt = true;
break;

View File

@ -1,203 +0,0 @@
/*********************************************************************
er59256.c
Microchip ER59256 serial eeprom.
*********************************************************************/
#include "emu.h"
#include "er59256.h"
/* LOGLEVEL 0=no logging, 1=just commands and data, 2=everything ! */
#define LOGLEVEL 0
#define LOG(level, ...) if(LOGLEVEL>=level) logerror(__VA_ARGS__)
#define LOG_BITS(bits) logerror("CS=%d CK=%d DI=%d DO=%d", (bits&CS_MASK) ? 1 : 0, (bits&CK_MASK) ? 1 : 0, (bits&DI_MASK) ? 1 : 0, (bits&DO_MASK) ? 1 : 0)
const device_type ER59256 = &device_creator<er59256_device>;
er59256_device::er59256_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, ER59256, "Microchip ER59256 serial eeprom.", tag, owner, clock, "er59256", __FILE__),
m_io_bits(0),
m_old_io_bits(0),
m_in_shifter(0),
m_out_shifter(0),
m_bitcount(0),
m_command(0),
m_flags(0)
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void er59256_device::device_config_complete()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void er59256_device::device_start()
{
// Start with rom defaulted to erased
memset(&m_eerom, 0xFF, EEROM_WORDS*2);
m_command=CMD_INVALID;
m_flags&= ~FLAG_DATA_LOADED;
save_item(NAME(m_eerom));
save_item(NAME(m_io_bits));
save_item(NAME(m_old_io_bits));
save_item(NAME(m_in_shifter));
save_item(NAME(m_out_shifter));
save_item(NAME(m_bitcount));
save_item(NAME(m_command));
save_item(NAME(m_flags));
}
//-------------------------------------------------
// device_stop - device-specific stop
//-------------------------------------------------
void er59256_device::device_stop()
{
/* Save contents of eerom */
}
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
void er59256_device::preload_rom(const UINT16 *rom_data, int count)
{
int WordNo;
logerror("Preloading %d words of data\n",count);
if(count>EEROM_WORDS)
memcpy(&m_eerom,rom_data,count*2);
else
memcpy(&m_eerom,rom_data,EEROM_WORDS*2);
for(WordNo=0;WordNo<EEROM_WORDS;WordNo++)
logerror("%04X ",m_eerom[WordNo]);
logerror("\n");
}
UINT8 er59256_device::data_loaded()
{
return (m_flags & FLAG_DATA_LOADED) ? 1 : 0;
}
void er59256_device::set_iobits(UINT8 newbits)
{
//UINT32 bit;
// Make sure we only apply valid bits
newbits&=ALL_MASK;
if(LOGLEVEL>1)
{
logerror("er59256:newbits=%02X : ",newbits);
LOG_BITS(newbits);
logerror(" io_bits=%02X : ",m_io_bits);
LOG_BITS(m_io_bits);
logerror(" old_io_bits=%02X : ",m_old_io_bits);
LOG_BITS(m_old_io_bits);
logerror(" bitcount=%d, in_shifter=%04X, out_shifter=%05X, flags=%02X\n",m_bitcount,m_in_shifter,m_out_shifter,m_flags);
}
// Only do anything if the inputs have changed
if((newbits&IN_MASK)!=(m_io_bits&IN_MASK))
{
// save the current state, then set the new one, remembering to preserve data out
m_old_io_bits=m_io_bits;
m_io_bits=(newbits & ~DO_MASK) | (m_old_io_bits&DO_MASK);
if(CS_RISE())
{
m_flags&=~FLAG_START_BIT;
m_command=CMD_INVALID;
}
if(LOGLEVEL>1)
{
if(CK_RISE()) logerror("er59256:CK rise\n");
if(CS_RISE()) logerror("er59256:CS rise\n");
if(CK_FALL()) logerror("er59256:CK fall\n");
if(CS_FALL()) logerror("er59256:CS fall\n");
}
if(CK_RISE() && CS_VALID())
{
if((STARTED()==0) && (GET_DI()==1))
{
m_bitcount=0;
m_flags|=FLAG_START_BIT;
}
else
{
SHIFT_IN();
m_bitcount++;
if(m_bitcount==CMD_BITLEN)
decode_command();
if((m_bitcount==WRITE_BITLEN) && ((m_command & CMD_MASK)==CMD_WRITE))
{
m_eerom[m_command & ADDR_MASK]=m_in_shifter;
LOG(1,"er59256:write[%02X]=%04X\n",(m_command & ADDR_MASK),m_in_shifter);
m_command=CMD_INVALID;
}
LOG(1,"out_shifter=%05X, io_bits=%02X\n",m_out_shifter,m_io_bits);
SHIFT_OUT();
}
LOG(2,"io_bits:out=%02X\n",m_io_bits);
}
}
}
UINT8 er59256_device::get_iobits()
{
return m_io_bits;
}
void er59256_device::decode_command()
{
m_out_shifter=0x0000;
m_command=(m_in_shifter & (CMD_MASK | ADDR_MASK));
switch(m_command & CMD_MASK)
{
case CMD_READ : m_out_shifter=m_eerom[m_command & ADDR_MASK];
LOG(1,"er59256:read[%02X]=%04X\n",(m_command&ADDR_MASK),m_eerom[m_command & ADDR_MASK]);
break;
case CMD_WRITE : break;
case CMD_ERASE : if (WRITE_ENABLED()) m_eerom[m_command & ADDR_MASK]=0xFF;
LOG(1,"er59256:erase[%02X]\n",(m_command&ADDR_MASK));
break;
case CMD_EWEN : m_flags|=FLAG_WRITE_EN;
LOG(1,"er59256:erase/write enabled\n");
break;
case CMD_EWDS : m_flags&=~FLAG_WRITE_EN;
LOG(1,"er59256:erase/write disabled\n");
break;
case CMD_ERAL : if (WRITE_ENABLED()) memset(&m_eerom, 0xFF, EEROM_WORDS*2);
LOG(1,"er59256:erase all\n");
break;
}
if ((m_command & CMD_MASK)!=CMD_WRITE)
m_command=CMD_INVALID;
}

View File

@ -1,132 +0,0 @@
/*********************************************************************
er59256.h
Microchip ER59256 serial eeprom.
*********************************************************************/
#ifndef _ER59256_H_
#define _ER59256_H_
#define EEROM_WORDS 0x10
/***************************************************************************
MACROS
***************************************************************************/
class er59256_device : public device_t
{
public:
er59256_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~er59256_device() {}
void set_iobits(UINT8 newbits);
UINT8 get_iobits();
void preload_rom(const UINT16 *rom_data, int count);
UINT8 data_loaded();
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_stop();
private:
// internal state
/* The actual memory */
UINT16 m_eerom[EEROM_WORDS];
/* Bits as they appear on the io pins, current state */
UINT8 m_io_bits;
/* Bits as they appear on the io pins, previous state */
UINT8 m_old_io_bits;
/* the 16 bit shift in/out reg */
UINT16 m_in_shifter;
UINT32 m_out_shifter;
/* Count of bits received since last CS low->high */
UINT8 m_bitcount;
/* Command & addresss */
UINT8 m_command;
/* Write enable and write in progress flags */
UINT8 m_flags;
void decode_command();
};
extern const device_type ER59256;
#define MCFG_ER59256_ADD(_tag) \
MCFG_DEVICE_ADD((_tag), ER59256, 0)
/***************************************************************************
CONSTANTS
***************************************************************************/
#define CK_SHIFT 0x00
#define DI_SHIFT 0x01
#define DO_SHIFT 0x02
#define CS_SHIFT 0x03
#define CK_MASK (1<<CK_SHIFT)
#define DI_MASK (1<<DI_SHIFT)
#define DO_MASK (1<<DO_SHIFT)
#define CS_MASK (1<<CS_SHIFT)
#define ALL_MASK (CK_MASK | DI_MASK | DO_MASK | CS_MASK)
#define IN_MASK (CK_MASK | DI_MASK | CS_MASK)
#define GET_CK() ((m_io_bits & CK_MASK) >> CK_SHIFT)
#define GET_DI() ((m_io_bits & DI_MASK) >> DI_SHIFT)
#define GET_DO() ((m_io_bits & DO_MASK) >> DO_SHIFT)
#define GET_CS() ((m_io_bits & CS_MASK) >> CS_SHIFT)
#define SET_CK(data) m_io_bits=((m_io_bits & ~CK_MASK) | ((data & 0x01) << CK_SHIFT))
#define SET_DI(data) m_io_bits=((m_io_bits & ~DI_MASK) | ((data & 0x01) << DI_SHIFT))
#define SET_DO(data) m_io_bits=((m_io_bits & ~DO_MASK) | ((data & 0x01) << DO_SHIFT))
#define SET_CS(data) m_io_bits=((m_io_bits & ~CS_MASK) | ((data & 0x01) << CS_SHIFT))
#define CK_RISE() ((m_io_bits & CK_MASK) & ~(m_old_io_bits & CK_MASK))
#define CS_RISE() ((m_io_bits & CS_MASK) & ~(m_old_io_bits & CS_MASK))
#define CS_VALID() ((m_io_bits & CS_MASK) & (m_old_io_bits & CS_MASK))
#define CK_FALL() (~(m_io_bits & CK_MASK) & (m_old_io_bits & CK_MASK))
#define CS_FALL() (~(m_io_bits & CS_MASK) & (m_old_io_bits & CS_MASK))
#define SHIFT_IN() m_in_shifter=(m_in_shifter<<1) | GET_DI()
#define SHIFT_OUT() SET_DO((m_out_shifter & 0x10000)>>16); m_out_shifter=(m_out_shifter<<1)
#define CMD_READ 0x80
#define CMD_WRITE 0x40
#define CMD_ERASE 0xC0
#define CMD_EWEN 0x30
#define CMD_EWDS 0x00
#define CMD_ERAL 0x20
#define CMD_INVALID 0xF0
#define CMD_MASK 0xF0
#define ADDR_MASK 0x0F
// CMD_BITLEN is 1 start bit plus 4 command bits plus 4 address bits
#define CMD_BITLEN 8
#define DATA_BITLEN 16
#define WRITE_BITLEN CMD_BITLEN+DATA_BITLEN
#define FLAG_WRITE_EN 0x01
#define FLAG_START_BIT 0x02
#define FLAG_DATA_LOADED 0x04
#define WRITE_ENABLED() ((m_flags & FLAG_WRITE_EN) ? 1 : 0)
#define STARTED() ((m_flags & FLAG_START_BIT) ? 1 : 0)
#endif

View File

@ -541,15 +541,6 @@ ifneq ($(filter ER2055,$(MACHINES)),)
MACHINEOBJS += $(MACHINEOBJ)/er2055.o
endif
#-------------------------------------------------
#
#@src/emu/machine/er59256.h,MACHINES += ER59256
#-------------------------------------------------
ifneq ($(filter ER59256,$(MACHINES)),)
MACHINEOBJS += $(MACHINEOBJ)/er59256.o
endif
#-------------------------------------------------
#
#@src/emu/machine/f3853.h,MACHINES += F3853

View File

@ -398,7 +398,6 @@ MACHINES += E0516
MACHINES += E05A03
MACHINES += EEPROMDEV
MACHINES += ER2055
MACHINES += ER59256
MACHINES += F3853
#MACHINES += HD63450
#MACHINES += HD64610

View File

@ -18,29 +18,6 @@
#include "bus/rs232/rs232.h"
#include "machine/rmnkbd.h"
const unsigned char nimbus_palette[SCREEN_NO_COLOURS][3] =
{
/*normal brightness */
{ 0x00,0x00,0x00 }, /* black */
{ 0x00,0x00,0x80 }, /* blue */
{ 0x80,0x00,0x00 }, /* red */
{ 0x80,0x00,0x80 }, /* magenta */
{ 0x00,0x80,0x00 }, /* green */
{ 0x00,0x80,0x80 }, /* cyan */
{ 0x80,0x80,0x00 }, /* yellow */
{ 0x80,0x80,0x80 }, /* light grey */
/*enhanced brightness*/
{ 0x40,0x40,0x40 }, /* dark grey */
{ 0x00,0x00,0xFF }, /* light blue */
{ 0xFF,0x00,0x00 }, /* light red */
{ 0xFF,0x00,0xFF }, /* light magenta */
{ 0x00,0xFF,0x00 }, /* light green */
{ 0x00,0xFF,0xFF }, /* light cyan */
{ 0xFF,0xFF,0x00 }, /* yellow */
{ 0xFF,0xFF,0xFF } /* white */
};
static SLOT_INTERFACE_START(rmnimbus_floppies)
SLOT_INTERFACE( "35dd", FLOPPY_35_DD )
SLOT_INTERFACE_END
@ -63,7 +40,6 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START(nimbus_io, AS_IO, 16, rmnimbus_state )
AM_RANGE( 0x0000, 0x0031) AM_READWRITE(nimbus_video_io_r, nimbus_video_io_w)
AM_RANGE( 0x0032, 0x007f) AM_READWRITE(nimbus_io_r, nimbus_io_w)
AM_RANGE( 0x0080, 0x0081) AM_READWRITE8(nimbus_mcu_r, nimbus_mcu_w, 0x00FF)
AM_RANGE( 0x0092, 0x0093) AM_READWRITE8(nimbus_iou_r, nimbus_iou_w, 0x00FF)
AM_RANGE( 0x00A4, 0x00A5) AM_READWRITE8(nimbus_mouse_js_r, nimbus_mouse_js_w, 0x00FF)
@ -106,27 +82,23 @@ INPUT_PORTS_END
static ADDRESS_MAP_START(nimbus_iocpu_mem, AS_PROGRAM, 8, rmnimbus_state )
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x2000, 0x7fff) AM_RAM
//AM_RANGE(0x2000, 0x7fff) AM_RAM
ADDRESS_MAP_END
static ADDRESS_MAP_START( nimbus_iocpu_io , AS_IO, 8, rmnimbus_state )
ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x00000, 0x000FF) AM_READWRITE(nimbus_pc8031_iou_r, nimbus_pc8031_iou_w)
AM_RANGE(0x00010, 0x07fff) AM_RAM
//AM_RANGE(0x00010, 0x07fff) AM_RAM
AM_RANGE(0x20000, 0x20004) AM_READWRITE(nimbus_pc8031_port_r, nimbus_pc8031_port_w)
ADDRESS_MAP_END
PALETTE_INIT_MEMBER(rmnimbus_state, rmnimbus)
static const UINT16 def_config[16] =
{
int colourno;
for ( colourno = 0; colourno < SCREEN_NO_COLOURS; colourno++ )
{
palette.set_pen_color(colourno, nimbus_palette[colourno][RED], nimbus_palette[colourno][GREEN], nimbus_palette[colourno][BLUE]);
}
}
0x0280, 0x017F, 0xE824, 0x8129,
0x0329, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x8893, 0x2025, 0xB9E6
};
static MACHINE_CONFIG_START( nimbus, rmnimbus_state )
/* basic machine hardware */
@ -144,21 +116,16 @@ static MACHINE_CONFIG_START( nimbus, rmnimbus_state )
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_RAW_PARAMS( XTAL_4_433619MHz*2,650,0,640,260,0,250)
// MCFG_SCREEN_REFRESH_RATE(50)
// MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
MCFG_SCREEN_UPDATE_DRIVER(rmnimbus_state, screen_update_nimbus)
MCFG_SCREEN_VBLANK_DRIVER(rmnimbus_state, screen_eof_nimbus)
MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
//MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
MCFG_SCREEN_PALETTE("palette")
MCFG_PALETTE_ADD("palette", SCREEN_NO_COLOURS)
MCFG_PALETTE_INIT_OWNER(rmnimbus_state, rmnimbus)
// MCFG_SCREEN_SIZE(650, 260)
// MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 249)
/* Backing storage */
MCFG_WD2793x_ADD(FDC_TAG, 1000000)
MCFG_WD_FDC_FORCE_READY
MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(rmnimbus_state,nimbus_fdc_intrq_w))
MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(rmnimbus_state,nimbus_fdc_drq_w))
MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":0", rmnimbus_floppies, "35dd", isa8_fdc_device::floppy_formats)
@ -205,7 +172,8 @@ static MACHINE_CONFIG_START( nimbus, rmnimbus_state )
MCFG_RS232_RI_HANDLER(DEVWRITELINE(Z80SIO_TAG, z80dart_device, rib_w))
MCFG_RS232_CTS_HANDLER(DEVWRITELINE(Z80SIO_TAG, z80dart_device, ctsb_w))
MCFG_ER59256_ADD(ER59256_TAG)
MCFG_EEPROM_SERIAL_93C06_ADD(ER59256_TAG)
MCFG_EEPROM_DATA(def_config,sizeof(def_config))
MCFG_DEVICE_ADD(VIA_TAG, VIA6522, 1000000)
MCFG_VIA6522_WRITEPA_HANDLER(DEVWRITE8("cent_data_out", output_latch_device, write))

View File

@ -12,7 +12,7 @@
#include "bus/scsi/scsi.h"
#include "machine/6522via.h"
#include "machine/ram.h"
#include "machine/er59256.h"
#include "machine/eepromser.h"
#include "sound/ay8910.h"
#include "sound/msm5205.h"
#include "bus/centronics/ctronics.h"
@ -20,134 +20,12 @@
#define MAINCPU_TAG "maincpu"
#define IOCPU_TAG "iocpu"
#define num_ioports 0x80
#define SCREEN_WIDTH_PIXELS 640
#define SCREEN_HEIGHT_LINES 250
#define SCREEN_NO_COLOURS 16
#define NO_VIDREGS (0x30/2)
/* Nimbus sub-bios structures for debugging */
struct t_area_params
{
UINT16 ofs_brush;
UINT16 seg_brush;
UINT16 ofs_data;
UINT16 seg_data;
UINT16 count;
};
struct t_plot_string_params
{
UINT16 ofs_font;
UINT16 seg_font;
UINT16 ofs_data;
UINT16 seg_data;
UINT16 x;
UINT16 y;
UINT16 length;
};
struct t_nimbus_brush
{
UINT16 style;
UINT16 style_index;
UINT16 colour1;
UINT16 colour2;
UINT16 transparency;
UINT16 boundary_spec;
UINT16 boundary_colour;
UINT16 save_colour;
};
// Static data related to Floppy and SCSI hard disks
struct nimbus_drives_t
{
UINT8 reg400;
UINT8 reg418;
UINT8 drq_ff;
UINT8 int_ff;
};
/* 8031 Peripheral controler */
struct ipc_interface_t
{
UINT8 ipc_in;
UINT8 ipc_out;
UINT8 status_in;
UINT8 status_out;
UINT8 int_8c_pending;
UINT8 int_8e_pending;
UINT8 int_8f_pending;
};
/* Mouse/Joystick */
struct mouse_joy_state
{
UINT8 m_mouse_px;
UINT8 m_mouse_py;
UINT8 m_mouse_x;
UINT8 m_mouse_y;
UINT8 m_mouse_pc;
UINT8 m_mouse_pcx;
UINT8 m_mouse_pcy;
UINT8 m_intstate_x;
UINT8 m_intstate_y;
UINT8 m_reg0a4;
emu_timer *m_mouse_timer;
};
/*----------- defined in drivers/rmnimbus.c -----------*/
extern const unsigned char nimbus_palette[SCREEN_NO_COLOURS][3];
/*----------- defined in machine/rmnimbus.c -----------*/
/* 80186 Internal */
/* external int priority masks */
#define EXTINT_CTRL_PRI_MASK 0x07
#define EXTINT_CTRL_MSK 0x08
#define EXTINT_CTRL_LTM 0x10
#define EXTINT_CTRL_CASCADE 0x20
#define EXTINT_CTRL_SFNM 0x40
/* DMA control register */
#define DEST_MIO 0x8000
#define DEST_DECREMENT 0x4000
#define DEST_INCREMENT 0x2000
#define DEST_NO_CHANGE (DEST_DECREMENT | DEST_INCREMENT)
#define DEST_INCDEC_MASK (DEST_DECREMENT | DEST_INCREMENT)
#define SRC_MIO 0X1000
#define SRC_DECREMENT 0x0800
#define SRC_INCREMENT 0x0400
#define SRC_NO_CHANGE (SRC_DECREMENT | SRC_INCREMENT)
#define SRC_INCDEC_MASK (SRC_DECREMENT | SRC_INCREMENT)
#define TERMINATE_ON_ZERO 0x0200
#define INTERRUPT_ON_ZERO 0x0100
#define SYNC_MASK 0x00C0
#define SYNC_SOURCE 0x0040
#define SYNC_DEST 0x0080
#define CHANNEL_PRIORITY 0x0020
#define TIMER_DRQ 0x0010
#define CHG_NOCHG 0x0004
#define ST_STOP 0x0002
#define BYTE_WORD 0x0001
/* Nimbus specific */
@ -176,8 +54,6 @@ extern const unsigned char nimbus_palette[SCREEN_NO_COLOURS][3];
#define HIBLOCK_BASE_MASK 0x08
#define HIBLOCK_SELECT_MASK 0x10
/* Z80 SIO for keyboard */
#define Z80SIO_TAG "z80sio"
@ -266,19 +142,6 @@ enum
#define VIA_INT 0x03
/*----------- defined in video/rmnimbus.c -----------*/
#define RED 0
#define GREEN 1
#define BLUE 2
#define LINEAR_ADDR(seg,ofs) ((seg<<4)+ofs)
#define OUTPUT_SEGOFS(mess,seg,ofs) logerror("%s=%04X:%04X [%08X]\n",mess,seg,ofs,((seg<<4)+ofs))
@ -300,7 +163,8 @@ public:
m_scsi_data_in(*this, "scsi_data_in"),
m_scsi_ctrl_out(*this, "scsi_ctrl_out"),
m_fdc(*this, FDC_TAG),
m_z80sio(*this, Z80SIO_TAG)
m_z80sio(*this, Z80SIO_TAG),
m_screen(*this, "screen")
{
}
@ -308,7 +172,7 @@ public:
required_device<msm5205_device> m_msm;
required_device<SCSI_PORT_DEVICE> m_scsibus;
required_device<ram_device> m_ram;
required_device<er59256_device> m_eeprom;
required_device<eeprom_serial_93cxx_device> m_eeprom;
required_device<via6522_device> m_via;
required_device<centronics_device> m_centronics;
required_device<palette_device> m_palette;
@ -317,24 +181,25 @@ public:
required_device<output_latch_device> m_scsi_ctrl_out;
required_device<wd2793_t> m_fdc;
required_device<z80sio2_device> m_z80sio;
required_device<screen_device> m_screen;
bitmap_ind16 m_video_mem;
UINT32 m_debug_machine;
nimbus_drives_t m_nimbus_drives;
ipc_interface_t m_ipc_interface;
UINT8 m_mcu_reg080;
UINT8 m_iou_reg092;
UINT8 m_last_playmode;
mouse_joy_state m_nimbus_mouse;
UINT8 m_ay8910_a;
UINT16 m_IOPorts[num_ioports];
UINT8 m_sio_int_state;
UINT8 m_video_mem[SCREEN_WIDTH_PIXELS][SCREEN_HEIGHT_LINES];
UINT16 m_vidregs[NO_VIDREGS];
UINT8 m_bpp;
UINT16 m_pixel_mask;
UINT8 m_hs_count;
UINT32 m_debug_video;
UINT8 m_vector;
UINT8 m_eeprom_bits;
UINT8 m_eeprom_state;
DECLARE_READ8_MEMBER(nimbus_mcu_r);
DECLARE_WRITE8_MEMBER(nimbus_mcu_w);
DECLARE_READ16_MEMBER(nimbus_io_r);
@ -356,16 +221,12 @@ public:
DECLARE_WRITE8_MEMBER(nimbus_mouse_js_w);
DECLARE_READ16_MEMBER(nimbus_video_io_r);
DECLARE_WRITE16_MEMBER(nimbus_video_io_w);
DECLARE_DRIVER_INIT(nimbus);
virtual void machine_start();
virtual void machine_reset();
virtual void video_start();
virtual void video_reset();
DECLARE_PALETTE_INIT(rmnimbus);
UINT32 screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void screen_eof_nimbus(screen_device &screen, bool state);
TIMER_CALLBACK_MEMBER(keyscan_callback);
TIMER_CALLBACK_MEMBER(mouse_callback);
DECLARE_WRITE_LINE_MEMBER(sio_interrupt);
DECLARE_WRITE_LINE_MEMBER(nimbus_fdc_intrq_w);
DECLARE_WRITE_LINE_MEMBER(nimbus_fdc_drq_w);
@ -378,12 +239,10 @@ public:
DECLARE_WRITE_LINE_MEMBER(write_scsi_req);
DECLARE_WRITE_LINE_MEMBER(nimbus_msm5205_vck);
DECLARE_WRITE_LINE_MEMBER(write_scsi_iena);
DECLARE_WRITE_LINE_MEMBER(keyboard_clk);
UINT8 get_pixel(UINT16 x, UINT16 y);
UINT16 read_pixel_line(UINT16 x, UINT16 y, UINT8 width);
UINT16 read_pixel_data(UINT16 x, UINT16 y);
UINT16 read_reg_00A();
void set_pixel(UINT16 x, UINT16 y, UINT8 colour);
void set_pixel40(UINT16 x, UINT16 y, UINT8 colour);
void write_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 width);
@ -423,4 +282,53 @@ public:
int m_scsi_io;
int m_scsi_cd;
int m_scsi_req;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
enum
{
TIMER_MOUSE
};
// Static data related to Floppy and SCSI hard disks
struct
{
UINT8 reg400;
UINT8 reg418;
UINT8 drq_ff;
UINT8 int_ff;
} m_nimbus_drives;
/* 8031 Peripheral controler */
struct
{
UINT8 ipc_in;
UINT8 ipc_out;
UINT8 status_in;
UINT8 status_out;
UINT8 int_8c_pending;
UINT8 int_8e_pending;
UINT8 int_8f_pending;
} m_ipc_interface;
/* Mouse/Joystick */
struct
{
UINT8 m_mouse_px;
UINT8 m_mouse_py;
UINT8 m_mouse_x;
UINT8 m_mouse_y;
UINT8 m_mouse_pc;
UINT8 m_mouse_pcx;
UINT8 m_mouse_pcy;
UINT8 m_intstate_x;
UINT8 m_intstate_y;
UINT8 m_reg0a4;
emu_timer *m_mouse_timer;
} m_nimbus_mouse;
};

View File

@ -64,7 +64,6 @@ chdman createhd -o ST125N.chd -chs 407,4,26 -ss 512
/* Defines, constants, and global variables */
/*-------------------------------------------------------------------------*/
/* CPU 80186 */
#define LOG_KEYBOARD 0
#define LOG_SIO 0
#define LOG_DISK_FDD 0
@ -87,19 +86,39 @@ chdman createhd -o ST125N.chd -chs 407,4,26 -ss 512
#define DECODE_BIOS_RAW 0x0000004
#define DECODE_DOS21 0x0000008
static const UINT16 def_config[16] =
/* Nimbus sub-bios structures for debugging */
struct t_area_params
{
0x0280, 0x017F, 0xE822, 0x8129,
0x0329, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x8796, 0x2025, 0xB9E6
UINT16 ofs_brush;
UINT16 seg_brush;
UINT16 ofs_data;
UINT16 seg_data;
UINT16 count;
};
/* Memory controler */
struct t_plot_string_params
{
UINT16 ofs_font;
UINT16 seg_font;
UINT16 ofs_data;
UINT16 seg_data;
UINT16 x;
UINT16 y;
UINT16 length;
};
/* IO Unit */
/* Sound */
struct t_nimbus_brush
{
UINT16 style;
UINT16 style_index;
UINT16 colour1;
UINT16 colour2;
UINT16 transparency;
UINT16 boundary_spec;
UINT16 boundary_colour;
UINT16 save_colour;
};
static void execute_debug_irq(running_machine &machine, int ref, int params, const char *param[]);
@ -152,11 +171,8 @@ void rmnimbus_state::machine_reset()
rmni_sound_reset();
memory_reset();
mouse_js_reset();
}
DRIVER_INIT_MEMBER(rmnimbus_state,nimbus)
{
/* USER VIA 6522 port B is connected to the BBC user port */
/* USER VIA 6522 port B is connected to the BBC user port */
m_via->write_pb0(1);
m_via->write_pb1(1);
m_via->write_pb2(1);
@ -169,7 +185,7 @@ DRIVER_INIT_MEMBER(rmnimbus_state,nimbus)
void rmnimbus_state::machine_start()
{
m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::mouse_callback),this));
m_nimbus_mouse.m_mouse_timer=timer_alloc(TIMER_MOUSE);
/* setup debug commands */
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
@ -779,9 +795,6 @@ static void decode_dos21(device_t *device,offs_t pc)
logerror("CS=%04X, DS=%04X, ES=%04X, SS=%04X\n",cs,ds,es,ss);
logerror("SI=%04X, DI=%04X, BP=%04X\n",si,di,bp);
logerror("=======================================================================\n");
if((ax & 0xff00)==0x0900)
debugger_break(device->machine());
}
@ -962,31 +975,6 @@ void rmnimbus_state::memory_reset()
nimbus_bank_memory();
}
READ16_MEMBER(rmnimbus_state::nimbus_io_r)
{
int pc=space.device().safe_pc();
logerror("Nimbus IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2)+0x30,mem_mask,m_IOPorts[offset]);
switch (offset*2)
{
default : return m_IOPorts[offset];
}
return 0;
}
WRITE16_MEMBER(rmnimbus_state::nimbus_io_w)
{
int pc=space.device().safe_pc();
logerror("Nimbus IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2)+0x30,mem_mask);
switch (offset*2)
{
default : COMBINE_DATA(&m_IOPorts[offset]); break;
}
}
/*
Z80SIO, used for the keyboard interface
@ -1255,9 +1243,6 @@ void rmnimbus_state::pc8031_reset()
logerror("peripheral controler reset\n");
memset(&m_ipc_interface,0,sizeof(m_ipc_interface));
if(!m_eeprom->data_loaded())
m_eeprom->preload_rom(def_config,ARRAY_LENGTH(def_config));
}
@ -1395,7 +1380,9 @@ READ8_MEMBER(rmnimbus_state::nimbus_pc8031_port_r)
switch(offset)
{
case 0x01 : result=m_eeprom->get_iobits();
case 0x01:
result = (m_eeprom_bits & ~4) | (m_eeprom->do_read() << 2);
break;
}
return result;
@ -1407,7 +1394,22 @@ WRITE8_MEMBER(rmnimbus_state::nimbus_pc8031_port_w)
switch (offset)
{
case 0x01 : m_eeprom->set_iobits((data&0x0F));
case 0x01:
m_eeprom->cs_write((data & 8) ? 1 : 0);
if(!(data & 8))
m_eeprom_state = 0;
else if(!(data & 2) || (m_eeprom_state == 2))
m_eeprom_state = 2;
else if((data & 8) && (!(m_eeprom_bits & 8)))
m_eeprom_state = 1;
else if((!(data & 1)) && (m_eeprom_bits & 1) && (m_eeprom_state == 1))
m_eeprom_state = 2; //wait until 1 clk after cs rises to set di else it's seen as a start bit
m_eeprom->di_write(((data & 2) && (m_eeprom_state == 2)) ? 1 : 0);
m_eeprom->clk_write((data & 1) ? 1 : 0);
m_eeprom_bits = data;
break;
}
if(LOG_PC8031_PORT)
@ -1450,6 +1452,7 @@ WRITE8_MEMBER(rmnimbus_state::nimbus_iou_w)
void rmnimbus_state::iou_reset()
{
m_iou_reg092=0x00;
m_eeprom_state = 0;
}
/*
@ -1506,24 +1509,22 @@ static const int MOUSE_XYB[3][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0,
void rmnimbus_state::mouse_js_reset()
{
mouse_joy_state *state = &m_nimbus_mouse;
state->m_mouse_px=0;
state->m_mouse_py=0;
state->m_mouse_x=128;
state->m_mouse_y=128;
state->m_mouse_pc=0;
state->m_mouse_pcx=0;
state->m_mouse_pcy=0;
state->m_intstate_x=0;
state->m_intstate_y=0;
state->m_reg0a4=0xC0;
m_nimbus_mouse.m_mouse_px=0;
m_nimbus_mouse.m_mouse_py=0;
m_nimbus_mouse.m_mouse_x=128;
m_nimbus_mouse.m_mouse_y=128;
m_nimbus_mouse.m_mouse_pc=0;
m_nimbus_mouse.m_mouse_pcx=0;
m_nimbus_mouse.m_mouse_pcy=0;
m_nimbus_mouse.m_intstate_x=0;
m_nimbus_mouse.m_intstate_y=0;
m_nimbus_mouse.m_reg0a4=0xC0;
// Setup timer to poll the mouse
state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000));
m_nimbus_mouse.m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000));
}
TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
UINT8 x = 0;
UINT8 y = 0;
@ -1534,10 +1535,7 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
int xint;
int yint;
mouse_joy_state *state = &m_nimbus_mouse;
state->m_reg0a4 = ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
m_nimbus_mouse.m_reg0a4 = ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
x = ioport(MOUSEX_TAG)->read();
y = ioport(MOUSEY_TAG)->read();
@ -1548,65 +1546,65 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
//logerror("poll_mouse()\n");
if (x == state->m_mouse_x)
if (x == m_nimbus_mouse.m_mouse_x)
{
state->m_mouse_px = MOUSE_PHASE_STATIC;
m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_STATIC;
}
else if (x > state->m_mouse_x)
else if (x > m_nimbus_mouse.m_mouse_x)
{
state->m_mouse_px = MOUSE_PHASE_POSITIVE;
m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_POSITIVE;
}
else if (x < state->m_mouse_x)
else if (x < m_nimbus_mouse.m_mouse_x)
{
state->m_mouse_px = MOUSE_PHASE_NEGATIVE;
m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_NEGATIVE;
}
if (y == state->m_mouse_y)
if (y == m_nimbus_mouse.m_mouse_y)
{
state->m_mouse_py = MOUSE_PHASE_STATIC;
m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_STATIC;
}
else if (y > state->m_mouse_y)
else if (y > m_nimbus_mouse.m_mouse_y)
{
state->m_mouse_py = MOUSE_PHASE_POSITIVE;
m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_POSITIVE;
}
else if (y < state->m_mouse_y)
else if (y < m_nimbus_mouse.m_mouse_y)
{
state->m_mouse_py = MOUSE_PHASE_NEGATIVE;
m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_NEGATIVE;
}
switch (state->m_mouse_px)
switch (m_nimbus_mouse.m_mouse_px)
{
case MOUSE_PHASE_STATIC : break;
case MOUSE_PHASE_POSITIVE : state->m_mouse_pcx++; break;
case MOUSE_PHASE_NEGATIVE : state->m_mouse_pcx--; break;
case MOUSE_PHASE_POSITIVE : m_nimbus_mouse.m_mouse_pcx++; break;
case MOUSE_PHASE_NEGATIVE : m_nimbus_mouse.m_mouse_pcx--; break;
}
state->m_mouse_pcx &= 0x03;
m_nimbus_mouse.m_mouse_pcx &= 0x03;
switch (state->m_mouse_py)
switch (m_nimbus_mouse.m_mouse_py)
{
case MOUSE_PHASE_STATIC : break;
case MOUSE_PHASE_POSITIVE : state->m_mouse_pcy++; break;
case MOUSE_PHASE_NEGATIVE : state->m_mouse_pcy--; break;
case MOUSE_PHASE_POSITIVE : m_nimbus_mouse.m_mouse_pcy++; break;
case MOUSE_PHASE_NEGATIVE : m_nimbus_mouse.m_mouse_pcy--; break;
}
state->m_mouse_pcy &= 0x03;
m_nimbus_mouse.m_mouse_pcy &= 0x03;
// mxb = MOUSE_XYB[state->m_mouse_px][state->m_mouse_pcx]; // XB
// mxa = MOUSE_XYA[state->m_mouse_px][state->m_mouse_pcx]; // XA
// mya = MOUSE_XYA[state->m_mouse_py][state->m_mouse_pcy]; // YA
// myb = MOUSE_XYB[state->m_mouse_py][state->m_mouse_pcy]; // YB
// mxb = MOUSE_XYB[state.m_mouse_px][state->m_mouse_pcx]; // XB
// mxa = MOUSE_XYA[state.m_mouse_px][state->m_mouse_pcx]; // XA
// mya = MOUSE_XYA[state.m_mouse_py][state->m_mouse_pcy]; // YA
// myb = MOUSE_XYB[state.m_mouse_py][state->m_mouse_pcy]; // YB
mxb = MOUSE_XYB[1][state->m_mouse_pcx]; // XB
mxa = MOUSE_XYA[1][state->m_mouse_pcx]; // XA
mya = MOUSE_XYA[1][state->m_mouse_pcy]; // YA
myb = MOUSE_XYB[1][state->m_mouse_pcy]; // YB
mxb = MOUSE_XYB[1][m_nimbus_mouse.m_mouse_pcx]; // XB
mxa = MOUSE_XYA[1][m_nimbus_mouse.m_mouse_pcx]; // XA
mya = MOUSE_XYA[1][m_nimbus_mouse.m_mouse_pcy]; // YA
myb = MOUSE_XYB[1][m_nimbus_mouse.m_mouse_pcy]; // YB
if ((state->m_mouse_py!=MOUSE_PHASE_STATIC) || (state->m_mouse_px!=MOUSE_PHASE_STATIC))
if ((m_nimbus_mouse.m_mouse_py!=MOUSE_PHASE_STATIC) || (m_nimbus_mouse.m_mouse_px!=MOUSE_PHASE_STATIC))
{
// logerror("mouse_px=%02X, mouse_py=%02X, mouse_pcx=%02X, mouse_pcy=%02X\n",
// state->m_mouse_px,state->m_mouse_py,state->m_mouse_pcx,state->m_mouse_pcy);
// state.m_mouse_px,state->m_mouse_py,state->m_mouse_pcx,state->m_mouse_pcy);
// logerror("mxb=%02x, mxa=%02X (mxb ^ mxa)=%02X, (ay8910_a & 0xC0)=%02X, (mxb ^ mxa) ^ ((ay8910_a & 0x80) >> 7)=%02X\n",
// mxb,mxa, (mxb ^ mxa) , (state->m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6));
// mxb,mxa, (mxb ^ mxa) , (state.m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6));
}
intstate_x = (mxb ^ mxa) ^ ((m_ay8910_a & 0x40) >> 6);
@ -1614,8 +1612,8 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
if (MOUSE_INT_ENABLED(this))
{
if ((intstate_x==1) && (state->m_intstate_x==0))
// if (intstate_x!=state->m_intstate_x)
if ((intstate_x==1) && (m_nimbus_mouse.m_intstate_x==0))
// if (intstate_x!=state.m_intstate_x)
{
xint=mxa ? EXTERNAL_INT_MOUSE_XR : EXTERNAL_INT_MOUSE_XL;
@ -1624,8 +1622,8 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
// logerror("Xint:%02X, mxb=%02X\n",xint,mxb);
}
if ((intstate_y==1) && (state->m_intstate_y==0))
// if (intstate_y!=state->m_intstate_y)
if ((intstate_y==1) && (m_nimbus_mouse.m_intstate_y==0))
// if (intstate_y!=state.m_intstate_y)
{
yint=myb ? EXTERNAL_INT_MOUSE_YU : EXTERNAL_INT_MOUSE_YD;
@ -1635,24 +1633,24 @@ TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
}
else
{
state->m_reg0a4 &= 0xF0;
state->m_reg0a4 |= ( mxb & 0x01) << 3; // XB
state->m_reg0a4 |= (~mxb & 0x01) << 2; // XA
state->m_reg0a4 |= (~myb & 0x01) << 1; // YA
state->m_reg0a4 |= ( myb & 0x01) << 0; // YB
m_nimbus_mouse.m_reg0a4 &= 0xF0;
m_nimbus_mouse.m_reg0a4 |= ( mxb & 0x01) << 3; // XB
m_nimbus_mouse.m_reg0a4 |= (~mxb & 0x01) << 2; // XA
m_nimbus_mouse.m_reg0a4 |= (~myb & 0x01) << 1; // YA
m_nimbus_mouse.m_reg0a4 |= ( myb & 0x01) << 0; // YB
}
state->m_mouse_x = x;
state->m_mouse_y = y;
m_nimbus_mouse.m_mouse_x = x;
m_nimbus_mouse.m_mouse_y = y;
if ((state->m_mouse_py!=MOUSE_PHASE_STATIC) || (state->m_mouse_px!=MOUSE_PHASE_STATIC))
if ((m_nimbus_mouse.m_mouse_py!=MOUSE_PHASE_STATIC) || (m_nimbus_mouse.m_mouse_px!=MOUSE_PHASE_STATIC))
{
// logerror("pc=%05X, reg0a4=%02X, reg092=%02X, ay_a=%02X, x=%02X, y=%02X, px=%02X, py=%02X, intstate_x=%02X, intstate_y=%02X\n",
// pc,state->m_reg0a4,state->m_iou_reg092,state->m_ay8910_a,state->m_mouse_x,state->m_mouse_y,state->m_mouse_px,state->m_mouse_py,intstate_x,intstate_y);
// pc,state.m_reg0a4,state->m_iou_reg092,state->m_ay8910_a,state->m_mouse_x,state->m_mouse_y,state->m_mouse_px,state->m_mouse_py,intstate_x,intstate_y);
}
state->m_intstate_x=intstate_x;
state->m_intstate_y=intstate_y;
m_nimbus_mouse.m_intstate_x=intstate_x;
m_nimbus_mouse.m_intstate_y=intstate_y;
}
READ8_MEMBER(rmnimbus_state::nimbus_mouse_js_r)
@ -1673,11 +1671,10 @@ READ8_MEMBER(rmnimbus_state::nimbus_mouse_js_r)
*/
UINT8 result;
//int pc=m_maincpu->_pc();
mouse_joy_state *state = &m_nimbus_mouse;
if (ioport("config")->read() & 0x01)
{
result=state->m_reg0a4;
result=m_nimbus_mouse.m_reg0a4;
//logerror("mouse_js_r: pc=%05X, result=%02X\n",pc,result);
}
else

View File

@ -387,7 +387,6 @@ MACHINES += E0516
MACHINES += E05A03
MACHINES += EEPROMDEV
MACHINES += ER2055
MACHINES += ER59256
MACHINES += F3853
MACHINES += HD63450
MACHINES += HD64610

View File

@ -64,9 +64,6 @@
#define IS_80COL (m_vidregs[reg026]&MASK_4080)
#define IS_XOR (m_vidregs[reg022]&XOR_MASK)
#define DEBUG_TEXT 0x01
#define DEBUG_DB 0x02
#define DEBUG_PIXEL 0x04
@ -90,10 +87,10 @@ READ16_MEMBER(rmnimbus_state::nimbus_video_io_r)
{
case reg000 : result=m_vidregs[reg000]; break;
case reg002 : result=m_vidregs[reg002]; break;
case reg004 : result=m_vidregs[reg004]; break;
case reg004 : result=read_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C]); break;
case reg006 : result=m_vidregs[reg006]; break;
case reg008 : result=m_vidregs[reg008]; break;
case reg00A : result=read_reg_00A(); break;
case reg00A : result=read_pixel_data(++m_vidregs[reg002],m_vidregs[reg00C]); break;
case reg00C : result=m_vidregs[reg00C]; break;
case reg00E : result=m_vidregs[reg00E]; break;
@ -110,7 +107,7 @@ READ16_MEMBER(rmnimbus_state::nimbus_video_io_r)
case reg022 : result=m_vidregs[reg022]; break;
case reg024 : result=m_vidregs[reg024]; break;
case reg026 : result=m_vidregs[reg026]; break;
case reg028 : result=m_hs_count; break; //result=m_vidregs[reg028]; break;
case reg028 : result=m_screen->vpos() % 0xb; break; //result=m_vidregs[reg028]; break;
case reg02A : result=m_vidregs[reg02A]; break;
case reg02C : result=m_vidregs[reg02C]; break;
case reg02E : result=m_vidregs[reg02E]; break;
@ -130,9 +127,9 @@ UINT8 rmnimbus_state::get_pixel(UINT16 x, UINT16 y)
if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES))
{
if(IS_80COL)
result=m_video_mem[x][y];
result=m_video_mem.pix16(y, x);
else
result=m_video_mem[x*2][y];
result=m_video_mem.pix16(y, x*2);
}
return result;
@ -187,7 +184,9 @@ UINT16 rmnimbus_state::read_pixel_data(UINT16 x, UINT16 y)
case 0x03 : break;
case 0x04 : break;
case 0x04 : m_bpp=2; m_pixel_mask=0xC0;
result=read_pixel_line(x,y,8);
break;
case 0x05 : break;
@ -225,12 +224,6 @@ UINT16 rmnimbus_state::read_pixel_data(UINT16 x, UINT16 y)
return result;
}
UINT16 rmnimbus_state::read_reg_00A()
{
return read_pixel_data(++m_vidregs[reg002],m_vidregs[reg00C]);
}
/*
Write to the video registers, the default action is to write to the array of registers.
If a register also needs some special action call the action function for that register.
@ -298,9 +291,9 @@ void rmnimbus_state::set_pixel(UINT16 x, UINT16 y, UINT8 colour)
if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES))
{
if(IS_XOR)
m_video_mem[x][y]^=colour;
m_video_mem.pix16(y, x)^=colour;
else
m_video_mem[x][y]=colour;
m_video_mem.pix16(y, x)=colour;
}
}
@ -353,7 +346,7 @@ void rmnimbus_state::move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 w
pixelx=(x*width)+pixelno;
if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL))
logerror("pixelx=%04X\n",pixelx);
m_video_mem[pixelx][m_vidregs[reg020]]=m_video_mem[pixelx][y];
m_video_mem.pix16(m_vidregs[reg020], pixelx)=m_video_mem.pix16(y, pixelx);
}
}
@ -369,8 +362,8 @@ void rmnimbus_state::move_pixel_line(UINT16 x, UINT16 y, UINT16 data, UINT8 w
001 2bpp, using the first 4 colours of the pallette
010
011
100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with the lower byte
containing the pixel data for two pixels.
100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with existing pixels then ored
with the lower byte containing the pixel data for two pixels.
101 Move pixel data at x,reg020 to x,y, used for scrolling.
110 if 40 col
4bpp, 16 bit word containing the pixel data for 4 pixels.
@ -410,7 +403,7 @@ void rmnimbus_state::write_pixel_data(UINT16 x, UINT16 y, UINT16 data)
break;
case 0x04 : m_bpp=2; m_pixel_mask=0xC0;
write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8);
write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,8)),8);
break;
case 0x05 : move_pixel_line(x,y,data,16);
@ -446,7 +439,7 @@ void rmnimbus_state::write_pixel_data(UINT16 x, UINT16 y, UINT16 data)
break;
case 0x04 : m_bpp=4; m_pixel_mask=0xF0;
write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8);
write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,8)),8);
break;
case 0x05 : move_pixel_line(x,y,data,16);
@ -492,14 +485,14 @@ void rmnimbus_state::write_reg_012()
void rmnimbus_state::write_reg_014()
{
write_pixel_data(m_vidregs[reg002],m_vidregs[reg00C]++,m_vidregs[reg014]);
write_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C],m_vidregs[reg014]);
}
void rmnimbus_state::write_reg_016()
{
m_vidregs[reg002]=m_vidregs[reg016];
write_pixel_data(m_vidregs[reg002],m_vidregs[reg00C]++,FG_COLOUR);
write_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C],FG_COLOUR);
}
@ -541,7 +534,6 @@ void rmnimbus_state::change_palette(UINT8 bank, UINT16 colours, UINT8 regno)
UINT8 colourno;
UINT16 mask;
UINT8 shifts;
UINT8 paletteidx;
UINT8 colourmax;
UINT8 first;
@ -561,11 +553,12 @@ void rmnimbus_state::change_palette(UINT8 bank, UINT16 colours, UINT8 regno)
// loop over changing colours
for(colourno=first; colourno<(first+colourmax); colourno++)
{
paletteidx=(colours & mask) >> shifts;
m_palette->set_pen_color(colourno, nimbus_palette[paletteidx][RED], nimbus_palette[paletteidx][GREEN], nimbus_palette[paletteidx][BLUE]);
int paletteidx=(colours & mask) >> shifts;
int i = (paletteidx & 8) >> 3;
m_palette->set_pen_color(colourno, pal2bit((paletteidx & 2) | i), pal2bit(((paletteidx & 4) >> 1) | i), pal2bit(((paletteidx & 1) << 1) | i));
if(DEBUG_SET(DEBUG_TEXT))
logerror("set colourno[%02X](r,g,b)=(%02X,%02X,%02X), paletteidx=%02X\n",colourno, nimbus_palette[paletteidx][RED], nimbus_palette[paletteidx][GREEN], nimbus_palette[paletteidx][BLUE],paletteidx);
logerror("set colourno[%02X], paletteidx=%02X\n",colourno, paletteidx);
mask=mask<<4;
shifts+=4;
}
@ -610,6 +603,10 @@ void rmnimbus_state::video_start()
logerror("video_start\n");
m_screen->register_screen_bitmap(m_video_mem);
save_item(NAME(m_vidregs));
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
{
debug_console_register_command(machine(), "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
@ -617,34 +614,29 @@ void rmnimbus_state::video_start()
}
}
PALETTE_INIT_MEMBER(rmnimbus_state, rmnimbus)
{
int colourno;
for ( colourno = 0; colourno < SCREEN_NO_COLOURS; colourno++ )
{
int i = (colourno & 8) >> 3;
palette.set_pen_color(colourno, pal2bit((colourno & 2) | i), pal2bit(((colourno & 4) >> 1) | i), pal2bit(((colourno & 1) << 1) | i));
}
}
void rmnimbus_state::video_reset()
{
// When we reset clear the video registers and video memory.
memset(&m_vidregs,0x00,sizeof(m_vidregs));
memset(&m_video_mem,0,sizeof(m_video_mem));
m_bpp=4; // bits per pixel
logerror("Video reset\n");
}
void rmnimbus_state::screen_eof_nimbus(screen_device &screen, bool state)
{
// logerror("screen_eof_nimbus\n");
}
UINT32 rmnimbus_state::screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int XCoord;
int YCoord = screen.vpos();
for(XCoord=0;XCoord<SCREEN_WIDTH_PIXELS;XCoord++)
{
bitmap.pix16(YCoord, XCoord)=m_video_mem[XCoord][YCoord];
}
m_hs_count++;
if((m_hs_count & 0x000F)>0x0A)
m_hs_count&=0xFFF0;
copybitmap(bitmap, m_video_mem, 0, 0, 0, 0, cliprect);
return 0;
}