Previous 199869 Revisions Next

r31020 Wednesday 18th June, 2014 at 03:10:07 UTC by Carl
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)
[src/emu/cpu/i86]i186.c i86.c
[src/emu/machine]er59256.c er59256.h machine.mak
[src/mame]mame.mak
[src/mess]mess.mak
[src/mess/drivers]rmnimbus.c
[src/mess/includes]rmnimbus.h
[src/mess/machine]rmnimbus.c
[src/mess/video]rmnimbus.c

trunk/src/mame/mame.mak
r31019r31020
398398MACHINES += E05A03
399399MACHINES += EEPROMDEV
400400MACHINES += ER2055
401MACHINES += ER59256
402401MACHINES += F3853
403402#MACHINES += HD63450
404403#MACHINES += HD64610
trunk/src/emu/machine/er59256.c
r31019r31020
1/*********************************************************************
2
3    er59256.c
4
5    Microchip ER59256 serial eeprom.
6
7
8*********************************************************************/
9
10#include "emu.h"
11#include "er59256.h"
12
13/* LOGLEVEL 0=no logging, 1=just commands and data, 2=everything ! */
14
15#define LOGLEVEL            0
16
17#define LOG(level, ...)     if(LOGLEVEL>=level) logerror(__VA_ARGS__)
18#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)
19
20const device_type ER59256 = &device_creator<er59256_device>;
21
22er59256_device::er59256_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, ER59256, "Microchip ER59256 serial eeprom.", tag, owner, clock, "er59256", __FILE__),
24   m_io_bits(0),
25   m_old_io_bits(0),
26   m_in_shifter(0),
27   m_out_shifter(0),
28   m_bitcount(0),
29   m_command(0),
30   m_flags(0)
31{
32}
33
34//-------------------------------------------------
35//  device_config_complete - perform any
36//  operations now that the configuration is
37//  complete
38//-------------------------------------------------
39
40void er59256_device::device_config_complete()
41{
42}
43
44//-------------------------------------------------
45//  device_start - device-specific startup
46//-------------------------------------------------
47
48void er59256_device::device_start()
49{
50   // Start with rom defaulted to erased
51   memset(&m_eerom, 0xFF, EEROM_WORDS*2);
52
53   m_command=CMD_INVALID;
54
55   m_flags&= ~FLAG_DATA_LOADED;
56
57   save_item(NAME(m_eerom));
58   save_item(NAME(m_io_bits));
59   save_item(NAME(m_old_io_bits));
60   save_item(NAME(m_in_shifter));
61   save_item(NAME(m_out_shifter));
62   save_item(NAME(m_bitcount));
63   save_item(NAME(m_command));
64   save_item(NAME(m_flags));
65}
66
67//-------------------------------------------------
68//  device_stop - device-specific stop
69//-------------------------------------------------
70
71void er59256_device::device_stop()
72{
73   /* Save contents of eerom */
74}
75
76/***************************************************************************
77    IMPLEMENTATION
78***************************************************************************/
79
80void er59256_device::preload_rom(const UINT16 *rom_data, int count)
81{
82   int WordNo;
83
84   logerror("Preloading %d words of data\n",count);
85
86   if(count>EEROM_WORDS)
87      memcpy(&m_eerom,rom_data,count*2);
88   else
89      memcpy(&m_eerom,rom_data,EEROM_WORDS*2);
90
91   for(WordNo=0;WordNo<EEROM_WORDS;WordNo++)
92      logerror("%04X ",m_eerom[WordNo]);
93
94   logerror("\n");
95}
96
97UINT8 er59256_device::data_loaded()
98{
99   return (m_flags & FLAG_DATA_LOADED) ? 1 : 0;
100}
101
102void er59256_device::set_iobits(UINT8 newbits)
103{
104   //UINT32  bit;
105
106   // Make sure we only apply valid bits
107   newbits&=ALL_MASK;
108
109   if(LOGLEVEL>1)
110   {
111      logerror("er59256:newbits=%02X : ",newbits);
112      LOG_BITS(newbits);
113      logerror(" io_bits=%02X : ",m_io_bits);
114      LOG_BITS(m_io_bits);
115      logerror(" old_io_bits=%02X : ",m_old_io_bits);
116      LOG_BITS(m_old_io_bits);
117      logerror(" bitcount=%d, in_shifter=%04X, out_shifter=%05X, flags=%02X\n",m_bitcount,m_in_shifter,m_out_shifter,m_flags);
118   }
119   // Only do anything if the inputs have changed
120   if((newbits&IN_MASK)!=(m_io_bits&IN_MASK))
121   {
122      // save the current state, then set the new one, remembering to preserve data out
123      m_old_io_bits=m_io_bits;
124      m_io_bits=(newbits & ~DO_MASK) | (m_old_io_bits&DO_MASK);
125
126      if(CS_RISE())
127      {
128         m_flags&=~FLAG_START_BIT;
129         m_command=CMD_INVALID;
130      }
131
132      if(LOGLEVEL>1)
133      {
134         if(CK_RISE()) logerror("er59256:CK rise\n");
135         if(CS_RISE()) logerror("er59256:CS rise\n");
136         if(CK_FALL()) logerror("er59256:CK fall\n");
137         if(CS_FALL()) logerror("er59256:CS fall\n");
138      }
139
140      if(CK_RISE() && CS_VALID())
141      {
142         if((STARTED()==0) && (GET_DI()==1))
143         {
144            m_bitcount=0;
145            m_flags|=FLAG_START_BIT;
146         }
147         else
148         {
149            SHIFT_IN();
150            m_bitcount++;
151
152            if(m_bitcount==CMD_BITLEN)
153               decode_command();
154
155            if((m_bitcount==WRITE_BITLEN) && ((m_command & CMD_MASK)==CMD_WRITE))
156            {
157               m_eerom[m_command & ADDR_MASK]=m_in_shifter;
158               LOG(1,"er59256:write[%02X]=%04X\n",(m_command & ADDR_MASK),m_in_shifter);
159               m_command=CMD_INVALID;
160            }
161            LOG(1,"out_shifter=%05X, io_bits=%02X\n",m_out_shifter,m_io_bits);
162            SHIFT_OUT();
163         }
164
165         LOG(2,"io_bits:out=%02X\n",m_io_bits);
166      }
167   }
168}
169
170UINT8 er59256_device::get_iobits()
171{
172   return m_io_bits;
173}
174
175
176void er59256_device::decode_command()
177{
178   m_out_shifter=0x0000;
179   m_command=(m_in_shifter & (CMD_MASK | ADDR_MASK));
180
181   switch(m_command & CMD_MASK)
182   {
183      case CMD_READ   : m_out_shifter=m_eerom[m_command & ADDR_MASK];
184                     LOG(1,"er59256:read[%02X]=%04X\n",(m_command&ADDR_MASK),m_eerom[m_command & ADDR_MASK]);
185                     break;
186      case CMD_WRITE  : break;
187      case CMD_ERASE  : if (WRITE_ENABLED()) m_eerom[m_command & ADDR_MASK]=0xFF;
188                     LOG(1,"er59256:erase[%02X]\n",(m_command&ADDR_MASK));
189                     break;
190      case CMD_EWEN   : m_flags|=FLAG_WRITE_EN;
191                     LOG(1,"er59256:erase/write enabled\n");
192                     break;
193      case CMD_EWDS   : m_flags&=~FLAG_WRITE_EN;
194                     LOG(1,"er59256:erase/write disabled\n");
195                     break;
196      case CMD_ERAL   : if (WRITE_ENABLED()) memset(&m_eerom, 0xFF, EEROM_WORDS*2);
197                     LOG(1,"er59256:erase all\n");
198                     break;
199   }
200
201   if ((m_command & CMD_MASK)!=CMD_WRITE)
202      m_command=CMD_INVALID;
203}
trunk/src/emu/machine/er59256.h
r31019r31020
1/*********************************************************************
2
3    er59256.h
4
5    Microchip ER59256 serial eeprom.
6
7
8*********************************************************************/
9
10#ifndef _ER59256_H_
11#define _ER59256_H_
12
13#define EEROM_WORDS         0x10
14
15/***************************************************************************
16    MACROS
17***************************************************************************/
18
19class er59256_device : public device_t
20{
21public:
22   er59256_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
23   ~er59256_device() {}
24
25   void set_iobits(UINT8 newbits);
26   UINT8 get_iobits();
27   void preload_rom(const UINT16 *rom_data, int count);
28   UINT8 data_loaded();
29
30protected:
31   // device-level overrides
32   virtual void device_config_complete();
33   virtual void device_start();
34   virtual void device_stop();
35
36private:
37   // internal state
38
39   /* The actual memory */
40   UINT16  m_eerom[EEROM_WORDS];
41
42   /* Bits as they appear on the io pins, current state */
43   UINT8   m_io_bits;
44
45   /* Bits as they appear on the io pins, previous state */
46   UINT8   m_old_io_bits;
47
48
49   /* the 16 bit shift in/out reg */
50   UINT16  m_in_shifter;
51   UINT32  m_out_shifter;
52
53   /* Count of bits received since last CS low->high */
54   UINT8   m_bitcount;
55
56   /* Command & addresss */
57   UINT8   m_command;
58
59   /* Write enable and write in progress flags */
60   UINT8   m_flags;
61
62   void decode_command();
63};
64
65extern const device_type ER59256;
66
67
68#define MCFG_ER59256_ADD(_tag)  \
69   MCFG_DEVICE_ADD((_tag), ER59256, 0)
70
71/***************************************************************************
72    CONSTANTS
73***************************************************************************/
74
75#define CK_SHIFT            0x00
76#define DI_SHIFT            0x01
77#define DO_SHIFT            0x02
78#define CS_SHIFT            0x03
79
80#define CK_MASK             (1<<CK_SHIFT)
81#define DI_MASK             (1<<DI_SHIFT)
82#define DO_MASK             (1<<DO_SHIFT)
83#define CS_MASK             (1<<CS_SHIFT)
84
85#define ALL_MASK            (CK_MASK | DI_MASK | DO_MASK | CS_MASK)
86#define IN_MASK             (CK_MASK | DI_MASK | CS_MASK)
87
88#define GET_CK()         ((m_io_bits & CK_MASK) >> CK_SHIFT)
89#define GET_DI()         ((m_io_bits & DI_MASK) >> DI_SHIFT)
90#define GET_DO()         ((m_io_bits & DO_MASK) >> DO_SHIFT)
91#define GET_CS()         ((m_io_bits & CS_MASK) >> CS_SHIFT)
92
93#define SET_CK(data)    m_io_bits=((m_io_bits & ~CK_MASK) | ((data & 0x01) << CK_SHIFT))
94#define SET_DI(data)    m_io_bits=((m_io_bits & ~DI_MASK) | ((data & 0x01) << DI_SHIFT))
95#define SET_DO(data)    m_io_bits=((m_io_bits & ~DO_MASK) | ((data & 0x01) << DO_SHIFT))
96#define SET_CS(data)    m_io_bits=((m_io_bits & ~CS_MASK) | ((data & 0x01) << CS_SHIFT))
97
98#define CK_RISE()        ((m_io_bits & CK_MASK) & ~(m_old_io_bits & CK_MASK))
99#define CS_RISE()        ((m_io_bits & CS_MASK) & ~(m_old_io_bits & CS_MASK))
100#define CS_VALID()       ((m_io_bits & CS_MASK) & (m_old_io_bits & CS_MASK))
101
102#define CK_FALL()        (~(m_io_bits & CK_MASK) & (m_old_io_bits & CK_MASK))
103#define CS_FALL()        (~(m_io_bits & CS_MASK) & (m_old_io_bits & CS_MASK))
104
105
106#define SHIFT_IN()       m_in_shifter=(m_in_shifter<<1) | GET_DI()
107#define SHIFT_OUT()      SET_DO((m_out_shifter & 0x10000)>>16); m_out_shifter=(m_out_shifter<<1)
108
109#define CMD_READ            0x80
110#define CMD_WRITE           0x40
111#define CMD_ERASE           0xC0
112#define CMD_EWEN            0x30
113#define CMD_EWDS            0x00
114#define CMD_ERAL            0x20
115#define CMD_INVALID         0xF0
116
117#define CMD_MASK            0xF0
118#define ADDR_MASK           0x0F
119
120// CMD_BITLEN is 1 start bit plus 4 command bits plus 4 address bits
121#define CMD_BITLEN          8
122#define DATA_BITLEN         16
123#define WRITE_BITLEN        CMD_BITLEN+DATA_BITLEN
124
125#define FLAG_WRITE_EN       0x01
126#define FLAG_START_BIT      0x02
127#define FLAG_DATA_LOADED    0x04
128
129#define WRITE_ENABLED()  ((m_flags & FLAG_WRITE_EN) ? 1 : 0)
130#define STARTED()        ((m_flags & FLAG_START_BIT) ? 1 : 0)
131
132#endif
trunk/src/emu/machine/machine.mak
r31019r31020
543543
544544#-------------------------------------------------
545545#
546#@src/emu/machine/er59256.h,MACHINES += ER59256
547#-------------------------------------------------
548
549ifneq ($(filter ER59256,$(MACHINES)),)
550MACHINEOBJS += $(MACHINEOBJ)/er59256.o
551endif
552
553#-------------------------------------------------
554#
555546#@src/emu/machine/f3853.h,MACHINES += F3853
556547#-------------------------------------------------
557548
trunk/src/emu/cpu/i86/i86.c
r31019r31020
20772077         break;
20782078
20792079      case 0xf4: // i_hlt
2080         logerror("%s: %06x: HALT\n", tag(), pc());
2080         //logerror("%s: %06x: HALT\n", tag(), pc());
20812081         m_icount = 0;
20822082         m_halt = true;
20832083         break;
trunk/src/emu/cpu/i86/i186.c
r31019r31020
10081008
10091009            count = count ? count : 0x10000;
10101010            t->int_timer->adjust((attotime::from_hz(clock()/8) * count), which);
1011            t->count = 0;
10111012            if (LOG_TIMER) logerror("  Repriming interrupt\n");
10121013         }
10131014         else
r31019r31020
10411042   /* if we have a timing timer running, adjust the count */
10421043   if (t->time_timer_active && !(t->control & 0x0c))
10431044   {
1044      t->last_time = t->time_timer->elapsed();
1045      attotime current_time = t->time_timer->elapsed();
1046      int net_clocks = ((current_time - t->last_time) * (clock()/8)).seconds;
1047      t->last_time = current_time;
1048
1049      t->count = t->count + net_clocks;
10451050   }
10461051}
10471052
trunk/src/mess/drivers/rmnimbus.c
r31019r31020
1818#include "bus/rs232/rs232.h"
1919#include "machine/rmnkbd.h"
2020
21const unsigned char nimbus_palette[SCREEN_NO_COLOURS][3] =
22{
23   /*normal brightness */
24   { 0x00,0x00,0x00 },      /* black */
25   { 0x00,0x00,0x80 },      /* blue */
26   { 0x80,0x00,0x00 },      /* red */
27   { 0x80,0x00,0x80 },      /* magenta */
28   { 0x00,0x80,0x00 },      /* green */
29   { 0x00,0x80,0x80 },      /* cyan */
30   { 0x80,0x80,0x00 },      /* yellow */
31   { 0x80,0x80,0x80 },      /* light grey */
32
33   /*enhanced brightness*/
34   { 0x40,0x40,0x40 },      /* dark grey */
35   { 0x00,0x00,0xFF },      /* light blue */
36   { 0xFF,0x00,0x00 },      /* light red */
37   { 0xFF,0x00,0xFF },      /* light magenta */
38   { 0x00,0xFF,0x00 },      /* light green */
39   { 0x00,0xFF,0xFF },      /* light cyan */
40   { 0xFF,0xFF,0x00 },      /* yellow */
41   { 0xFF,0xFF,0xFF }       /* white */
42};
43
4421static SLOT_INTERFACE_START(rmnimbus_floppies)
4522   SLOT_INTERFACE( "35dd", FLOPPY_35_DD )
4623SLOT_INTERFACE_END
r31019r31020
6340
6441static ADDRESS_MAP_START(nimbus_io, AS_IO, 16, rmnimbus_state )
6542   AM_RANGE( 0x0000, 0x0031) AM_READWRITE(nimbus_video_io_r, nimbus_video_io_w)
66   AM_RANGE( 0x0032, 0x007f) AM_READWRITE(nimbus_io_r, nimbus_io_w)
6743   AM_RANGE( 0x0080, 0x0081) AM_READWRITE8(nimbus_mcu_r, nimbus_mcu_w, 0x00FF)
6844   AM_RANGE( 0x0092, 0x0093) AM_READWRITE8(nimbus_iou_r, nimbus_iou_w, 0x00FF)
6945   AM_RANGE( 0x00A4, 0x00A5) AM_READWRITE8(nimbus_mouse_js_r, nimbus_mouse_js_w, 0x00FF)
r31019r31020
10682static ADDRESS_MAP_START(nimbus_iocpu_mem, AS_PROGRAM, 8, rmnimbus_state )
10783   ADDRESS_MAP_UNMAP_HIGH
10884   AM_RANGE(0x0000, 0x1fff) AM_ROM
109   AM_RANGE(0x2000, 0x7fff) AM_RAM
85   //AM_RANGE(0x2000, 0x7fff) AM_RAM
11086ADDRESS_MAP_END
11187
11288static ADDRESS_MAP_START( nimbus_iocpu_io , AS_IO, 8, rmnimbus_state )
11389   ADDRESS_MAP_UNMAP_HIGH
11490   AM_RANGE(0x00000, 0x000FF) AM_READWRITE(nimbus_pc8031_iou_r, nimbus_pc8031_iou_w)
115   AM_RANGE(0x00010, 0x07fff) AM_RAM
91   //AM_RANGE(0x00010, 0x07fff) AM_RAM
11692   AM_RANGE(0x20000, 0x20004) AM_READWRITE(nimbus_pc8031_port_r, nimbus_pc8031_port_w)
11793ADDRESS_MAP_END
11894
119
120PALETTE_INIT_MEMBER(rmnimbus_state, rmnimbus)
95static const UINT16 def_config[16] =
12196{
122   int colourno;
97   0x0280, 0x017F, 0xE824, 0x8129,
98   0x0329, 0x0000, 0x0000, 0x0000,
99   0x0000, 0x0000, 0x0000, 0x0000,
100   0x0000, 0x8893, 0x2025, 0xB9E6
101};
123102
124   for ( colourno = 0; colourno < SCREEN_NO_COLOURS; colourno++ )
125   {
126      palette.set_pen_color(colourno, nimbus_palette[colourno][RED], nimbus_palette[colourno][GREEN], nimbus_palette[colourno][BLUE]);
127   }
128}
129
130
131103static MACHINE_CONFIG_START( nimbus, rmnimbus_state )
132104   /* basic machine hardware */
133105   MCFG_CPU_ADD(MAINCPU_TAG, I80186, 16000000) // the cpu is a 10Mhz part but the serial clocks are wrong unless it runs at 8Mhz
r31019r31020
144116   /* video hardware */
145117   MCFG_SCREEN_ADD("screen", RASTER)
146118   MCFG_SCREEN_RAW_PARAMS( XTAL_4_433619MHz*2,650,0,640,260,0,250)
147//  MCFG_SCREEN_REFRESH_RATE(50)
148//  MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
149119   MCFG_SCREEN_UPDATE_DRIVER(rmnimbus_state, screen_update_nimbus)
150   MCFG_SCREEN_VBLANK_DRIVER(rmnimbus_state, screen_eof_nimbus)
151   MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
120   //MCFG_SCREEN_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
152121   MCFG_SCREEN_PALETTE("palette")
153122
154123   MCFG_PALETTE_ADD("palette", SCREEN_NO_COLOURS)
155124   MCFG_PALETTE_INIT_OWNER(rmnimbus_state, rmnimbus)
156125
157//  MCFG_SCREEN_SIZE(650, 260)
158//  MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 249)
159
160126   /* Backing storage */
161127   MCFG_WD2793x_ADD(FDC_TAG, 1000000)
128   MCFG_WD_FDC_FORCE_READY
162129   MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(rmnimbus_state,nimbus_fdc_intrq_w))
163130   MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(rmnimbus_state,nimbus_fdc_drq_w))
164131   MCFG_FLOPPY_DRIVE_ADD(FDC_TAG":0", rmnimbus_floppies, "35dd", isa8_fdc_device::floppy_formats)
r31019r31020
205172   MCFG_RS232_RI_HANDLER(DEVWRITELINE(Z80SIO_TAG, z80dart_device, rib_w))
206173   MCFG_RS232_CTS_HANDLER(DEVWRITELINE(Z80SIO_TAG, z80dart_device, ctsb_w))
207174
208   MCFG_ER59256_ADD(ER59256_TAG)
175   MCFG_EEPROM_SERIAL_93C06_ADD(ER59256_TAG)
176   MCFG_EEPROM_DATA(def_config,sizeof(def_config))
209177
210178   MCFG_DEVICE_ADD(VIA_TAG, VIA6522, 1000000)
211179   MCFG_VIA6522_WRITEPA_HANDLER(DEVWRITE8("cent_data_out", output_latch_device, write))
trunk/src/mess/mess.mak
r31019r31020
387387MACHINES += E05A03
388388MACHINES += EEPROMDEV
389389MACHINES += ER2055
390MACHINES += ER59256
391390MACHINES += F3853
392391MACHINES += HD63450
393392MACHINES += HD64610
trunk/src/mess/machine/rmnimbus.c
r31019r31020
6464/* Defines, constants, and global variables                                */
6565/*-------------------------------------------------------------------------*/
6666
67/* CPU 80186 */
6867#define LOG_KEYBOARD        0
6968#define LOG_SIO             0
7069#define LOG_DISK_FDD        0
r31019r31020
8786#define DECODE_BIOS_RAW     0x0000004
8887#define DECODE_DOS21        0x0000008
8988
90static const UINT16 def_config[16] =
89/* Nimbus sub-bios structures for debugging */
90
91struct t_area_params
9192{
92   0x0280, 0x017F, 0xE822, 0x8129,
93   0x0329, 0x0000, 0x0000, 0x0000,
94   0x0000, 0x0000, 0x0000, 0x0000,
95   0x0000, 0x8796, 0x2025, 0xB9E6
93   UINT16  ofs_brush;
94   UINT16  seg_brush;
95   UINT16  ofs_data;
96   UINT16  seg_data;
97   UINT16  count;
9698};
9799
98/* Memory controler */
100struct t_plot_string_params
101{
102   UINT16  ofs_font;
103   UINT16  seg_font;
104   UINT16  ofs_data;
105   UINT16  seg_data;
106   UINT16  x;
107   UINT16  y;
108   UINT16  length;
109};
99110
100/* IO Unit */
111struct t_nimbus_brush
112{
113   UINT16  style;
114   UINT16  style_index;
115   UINT16  colour1;
116   UINT16  colour2;
117   UINT16  transparency;
118   UINT16  boundary_spec;
119   UINT16  boundary_colour;
120   UINT16  save_colour;
121};
101122
102/* Sound */
103123
104
105124static void execute_debug_irq(running_machine &machine, int ref, int params, const char *param[]);
106125static void nimbus_debug(running_machine &machine, int ref, int params, const char *param[]);
107126
r31019r31020
152171   rmni_sound_reset();
153172   memory_reset();
154173   mouse_js_reset();
155}
156174
157DRIVER_INIT_MEMBER(rmnimbus_state,nimbus)
158{
159/* USER VIA 6522 port B is connected to the BBC user port */
175   /* USER VIA 6522 port B is connected to the BBC user port */
160176   m_via->write_pb0(1);
161177   m_via->write_pb1(1);
162178   m_via->write_pb2(1);
r31019r31020
169185
170186void rmnimbus_state::machine_start()
171187{
172   m_nimbus_mouse.m_mouse_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::mouse_callback),this));
188   m_nimbus_mouse.m_mouse_timer=timer_alloc(TIMER_MOUSE);
173189
174190   /* setup debug commands */
175191   if (machine().debug_flags & DEBUG_FLAG_ENABLED)
r31019r31020
779795   logerror("CS=%04X, DS=%04X, ES=%04X, SS=%04X\n",cs,ds,es,ss);
780796   logerror("SI=%04X, DI=%04X, BP=%04X\n",si,di,bp);
781797   logerror("=======================================================================\n");
782
783   if((ax & 0xff00)==0x0900)
784      debugger_break(device->machine());
785798}
786799
787800
r31019r31020
962975   nimbus_bank_memory();
963976}
964977
965READ16_MEMBER(rmnimbus_state::nimbus_io_r)
966{
967   int pc=space.device().safe_pc();
968
969   logerror("Nimbus IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2)+0x30,mem_mask,m_IOPorts[offset]);
970
971   switch (offset*2)
972   {
973      default         : return m_IOPorts[offset];
974   }
975   return 0;
976}
977
978WRITE16_MEMBER(rmnimbus_state::nimbus_io_w)
979{
980   int pc=space.device().safe_pc();
981
982   logerror("Nimbus IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2)+0x30,mem_mask);
983
984   switch (offset*2)
985   {
986      default         : COMBINE_DATA(&m_IOPorts[offset]); break;
987   }
988}
989
990978/*
991979
992980Z80SIO, used for the keyboard interface
r31019r31020
12551243   logerror("peripheral controler reset\n");
12561244
12571245   memset(&m_ipc_interface,0,sizeof(m_ipc_interface));
1258
1259   if(!m_eeprom->data_loaded())
1260      m_eeprom->preload_rom(def_config,ARRAY_LENGTH(def_config));
12611246}
12621247
12631248
r31019r31020
13951380
13961381   switch(offset)
13971382   {
1398      case 0x01   : result=m_eeprom->get_iobits();
1383      case 0x01:
1384         result = (m_eeprom_bits & ~4) | (m_eeprom->do_read() << 2);
1385         break;
13991386   }
14001387
14011388   return result;
r31019r31020
14071394
14081395   switch (offset)
14091396   {
1410      case 0x01   : m_eeprom->set_iobits((data&0x0F));
1397      case 0x01:
1398         m_eeprom->cs_write((data & 8) ? 1 : 0);
1399
1400         if(!(data & 8))
1401            m_eeprom_state = 0;
1402         else if(!(data & 2) || (m_eeprom_state == 2))
1403            m_eeprom_state = 2;
1404         else if((data & 8) && (!(m_eeprom_bits & 8)))
1405            m_eeprom_state = 1;
1406         else if((!(data & 1)) && (m_eeprom_bits & 1) && (m_eeprom_state == 1))
1407            m_eeprom_state = 2; //wait until 1 clk after cs rises to set di else it's seen as a start bit
1408
1409         m_eeprom->di_write(((data & 2) && (m_eeprom_state == 2)) ? 1 : 0);
1410         m_eeprom->clk_write((data & 1) ? 1 : 0);
1411         m_eeprom_bits = data;
1412         break;
14111413   }
14121414
14131415   if(LOG_PC8031_PORT)
r31019r31020
14501452void rmnimbus_state::iou_reset()
14511453{
14521454   m_iou_reg092=0x00;
1455   m_eeprom_state = 0;
14531456}
14541457
14551458/*
r31019r31020
15061509
15071510void rmnimbus_state::mouse_js_reset()
15081511{
1509   mouse_joy_state *state = &m_nimbus_mouse;
1512   m_nimbus_mouse.m_mouse_px=0;
1513   m_nimbus_mouse.m_mouse_py=0;
1514   m_nimbus_mouse.m_mouse_x=128;
1515   m_nimbus_mouse.m_mouse_y=128;
1516   m_nimbus_mouse.m_mouse_pc=0;
1517   m_nimbus_mouse.m_mouse_pcx=0;
1518   m_nimbus_mouse.m_mouse_pcy=0;
1519   m_nimbus_mouse.m_intstate_x=0;
1520   m_nimbus_mouse.m_intstate_y=0;
1521   m_nimbus_mouse.m_reg0a4=0xC0;
15101522
1511   state->m_mouse_px=0;
1512   state->m_mouse_py=0;
1513   state->m_mouse_x=128;
1514   state->m_mouse_y=128;
1515   state->m_mouse_pc=0;
1516   state->m_mouse_pcx=0;
1517   state->m_mouse_pcy=0;
1518   state->m_intstate_x=0;
1519   state->m_intstate_y=0;
1520   state->m_reg0a4=0xC0;
1521
15221523   // Setup timer to poll the mouse
1523   state->m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000));
1524   m_nimbus_mouse.m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1000));
15241525}
15251526
1526TIMER_CALLBACK_MEMBER(rmnimbus_state::mouse_callback)
1527void rmnimbus_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
15271528{
15281529   UINT8   x = 0;
15291530   UINT8   y = 0;
r31019r31020
15341535   int     xint;
15351536   int     yint;
15361537
1537   mouse_joy_state *state = &m_nimbus_mouse;
1538
1539
1540   state->m_reg0a4 = ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
1538   m_nimbus_mouse.m_reg0a4 = ioport(MOUSE_BUTTON_TAG)->read() | 0xC0;
15411539   x = ioport(MOUSEX_TAG)->read();
15421540   y = ioport(MOUSEY_TAG)->read();
15431541
r31019r31020
15481546
15491547   //logerror("poll_mouse()\n");
15501548
1551   if (x == state->m_mouse_x)
1549   if (x == m_nimbus_mouse.m_mouse_x)
15521550   {
1553      state->m_mouse_px = MOUSE_PHASE_STATIC;
1551      m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_STATIC;
15541552   }
1555   else if (x > state->m_mouse_x)
1553   else if (x > m_nimbus_mouse.m_mouse_x)
15561554   {
1557      state->m_mouse_px = MOUSE_PHASE_POSITIVE;
1555      m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_POSITIVE;
15581556   }
1559   else if (x < state->m_mouse_x)
1557   else if (x < m_nimbus_mouse.m_mouse_x)
15601558   {
1561      state->m_mouse_px = MOUSE_PHASE_NEGATIVE;
1559      m_nimbus_mouse.m_mouse_px = MOUSE_PHASE_NEGATIVE;
15621560   }
15631561
1564   if (y == state->m_mouse_y)
1562   if (y == m_nimbus_mouse.m_mouse_y)
15651563   {
1566      state->m_mouse_py = MOUSE_PHASE_STATIC;
1564      m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_STATIC;
15671565   }
1568   else if (y > state->m_mouse_y)
1566   else if (y > m_nimbus_mouse.m_mouse_y)
15691567   {
1570      state->m_mouse_py = MOUSE_PHASE_POSITIVE;
1568      m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_POSITIVE;
15711569   }
1572   else if (y < state->m_mouse_y)
1570   else if (y < m_nimbus_mouse.m_mouse_y)
15731571   {
1574      state->m_mouse_py = MOUSE_PHASE_NEGATIVE;
1572      m_nimbus_mouse.m_mouse_py = MOUSE_PHASE_NEGATIVE;
15751573   }
15761574
1577   switch (state->m_mouse_px)
1575   switch (m_nimbus_mouse.m_mouse_px)
15781576   {
15791577      case MOUSE_PHASE_STATIC     : break;
1580      case MOUSE_PHASE_POSITIVE   : state->m_mouse_pcx++; break;
1581      case MOUSE_PHASE_NEGATIVE   : state->m_mouse_pcx--; break;
1578      case MOUSE_PHASE_POSITIVE   : m_nimbus_mouse.m_mouse_pcx++; break;
1579      case MOUSE_PHASE_NEGATIVE   : m_nimbus_mouse.m_mouse_pcx--; break;
15821580   }
1583   state->m_mouse_pcx &= 0x03;
1581   m_nimbus_mouse.m_mouse_pcx &= 0x03;
15841582
1585   switch (state->m_mouse_py)
1583   switch (m_nimbus_mouse.m_mouse_py)
15861584   {
15871585      case MOUSE_PHASE_STATIC     : break;
1588      case MOUSE_PHASE_POSITIVE   : state->m_mouse_pcy++; break;
1589      case MOUSE_PHASE_NEGATIVE   : state->m_mouse_pcy--; break;
1586      case MOUSE_PHASE_POSITIVE   : m_nimbus_mouse.m_mouse_pcy++; break;
1587      case MOUSE_PHASE_NEGATIVE   : m_nimbus_mouse.m_mouse_pcy--; break;
15901588   }
1591   state->m_mouse_pcy &= 0x03;
1589   m_nimbus_mouse.m_mouse_pcy &= 0x03;
15921590
1593//  mxb = MOUSE_XYB[state->m_mouse_px][state->m_mouse_pcx]; // XB
1594//  mxa = MOUSE_XYA[state->m_mouse_px][state->m_mouse_pcx]; // XA
1595//  mya = MOUSE_XYA[state->m_mouse_py][state->m_mouse_pcy]; // YA
1596//  myb = MOUSE_XYB[state->m_mouse_py][state->m_mouse_pcy]; // YB
1591//  mxb = MOUSE_XYB[state.m_mouse_px][state->m_mouse_pcx]; // XB
1592//  mxa = MOUSE_XYA[state.m_mouse_px][state->m_mouse_pcx]; // XA
1593//  mya = MOUSE_XYA[state.m_mouse_py][state->m_mouse_pcy]; // YA
1594//  myb = MOUSE_XYB[state.m_mouse_py][state->m_mouse_pcy]; // YB
15971595
1598   mxb = MOUSE_XYB[1][state->m_mouse_pcx]; // XB
1599   mxa = MOUSE_XYA[1][state->m_mouse_pcx]; // XA
1600   mya = MOUSE_XYA[1][state->m_mouse_pcy]; // YA
1601   myb = MOUSE_XYB[1][state->m_mouse_pcy]; // YB
1596   mxb = MOUSE_XYB[1][m_nimbus_mouse.m_mouse_pcx]; // XB
1597   mxa = MOUSE_XYA[1][m_nimbus_mouse.m_mouse_pcx]; // XA
1598   mya = MOUSE_XYA[1][m_nimbus_mouse.m_mouse_pcy]; // YA
1599   myb = MOUSE_XYB[1][m_nimbus_mouse.m_mouse_pcy]; // YB
16021600
1603   if ((state->m_mouse_py!=MOUSE_PHASE_STATIC) || (state->m_mouse_px!=MOUSE_PHASE_STATIC))
1601   if ((m_nimbus_mouse.m_mouse_py!=MOUSE_PHASE_STATIC) || (m_nimbus_mouse.m_mouse_px!=MOUSE_PHASE_STATIC))
16041602   {
16051603//        logerror("mouse_px=%02X, mouse_py=%02X, mouse_pcx=%02X, mouse_pcy=%02X\n",
1606//              state->m_mouse_px,state->m_mouse_py,state->m_mouse_pcx,state->m_mouse_pcy);
1604//              state.m_mouse_px,state->m_mouse_py,state->m_mouse_pcx,state->m_mouse_pcy);
16071605
16081606//        logerror("mxb=%02x, mxa=%02X (mxb ^ mxa)=%02X, (ay8910_a & 0xC0)=%02X, (mxb ^ mxa) ^ ((ay8910_a & 0x80) >> 7)=%02X\n",
1609//              mxb,mxa, (mxb ^ mxa) , (state->m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6));
1607//              mxb,mxa, (mxb ^ mxa) , (state.m_ay8910_a & 0xC0), (mxb ^ mxa) ^ ((state->m_ay8910_a & 0x40) >> 6));
16101608   }
16111609
16121610   intstate_x = (mxb ^ mxa) ^ ((m_ay8910_a & 0x40) >> 6);
r31019r31020
16141612
16151613   if (MOUSE_INT_ENABLED(this))
16161614   {
1617      if ((intstate_x==1) && (state->m_intstate_x==0))
1618//        if (intstate_x!=state->m_intstate_x)
1615      if ((intstate_x==1) && (m_nimbus_mouse.m_intstate_x==0))
1616//        if (intstate_x!=state.m_intstate_x)
16191617      {
16201618         xint=mxa ? EXTERNAL_INT_MOUSE_XR : EXTERNAL_INT_MOUSE_XL;
16211619
r31019r31020
16241622//            logerror("Xint:%02X, mxb=%02X\n",xint,mxb);
16251623      }
16261624
1627      if ((intstate_y==1) && (state->m_intstate_y==0))
1628//        if (intstate_y!=state->m_intstate_y)
1625      if ((intstate_y==1) && (m_nimbus_mouse.m_intstate_y==0))
1626//        if (intstate_y!=state.m_intstate_y)
16291627      {
16301628         yint=myb ? EXTERNAL_INT_MOUSE_YU : EXTERNAL_INT_MOUSE_YD;
16311629
r31019r31020
16351633   }
16361634   else
16371635   {
1638      state->m_reg0a4 &= 0xF0;
1639      state->m_reg0a4 |= ( mxb & 0x01) << 3; // XB
1640      state->m_reg0a4 |= (~mxb & 0x01) << 2; // XA
1641      state->m_reg0a4 |= (~myb & 0x01) << 1; // YA
1642      state->m_reg0a4 |= ( myb & 0x01) << 0; // YB
1636      m_nimbus_mouse.m_reg0a4 &= 0xF0;
1637      m_nimbus_mouse.m_reg0a4 |= ( mxb & 0x01) << 3; // XB
1638      m_nimbus_mouse.m_reg0a4 |= (~mxb & 0x01) << 2; // XA
1639      m_nimbus_mouse.m_reg0a4 |= (~myb & 0x01) << 1; // YA
1640      m_nimbus_mouse.m_reg0a4 |= ( myb & 0x01) << 0; // YB
16431641   }
16441642
1645   state->m_mouse_x = x;
1646   state->m_mouse_y = y;
1643   m_nimbus_mouse.m_mouse_x = x;
1644   m_nimbus_mouse.m_mouse_y = y;
16471645
1648   if ((state->m_mouse_py!=MOUSE_PHASE_STATIC) || (state->m_mouse_px!=MOUSE_PHASE_STATIC))
1646   if ((m_nimbus_mouse.m_mouse_py!=MOUSE_PHASE_STATIC) || (m_nimbus_mouse.m_mouse_px!=MOUSE_PHASE_STATIC))
16491647   {
16501648//        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",
1651//                 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);
1649//                 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);
16521650   }
16531651
1654   state->m_intstate_x=intstate_x;
1655   state->m_intstate_y=intstate_y;
1652   m_nimbus_mouse.m_intstate_x=intstate_x;
1653   m_nimbus_mouse.m_intstate_y=intstate_y;
16561654}
16571655
16581656READ8_MEMBER(rmnimbus_state::nimbus_mouse_js_r)
r31019r31020
16731671   */
16741672   UINT8 result;
16751673   //int pc=m_maincpu->_pc();
1676   mouse_joy_state *state = &m_nimbus_mouse;
16771674
16781675   if (ioport("config")->read() & 0x01)
16791676   {
1680      result=state->m_reg0a4;
1677      result=m_nimbus_mouse.m_reg0a4;
16811678      //logerror("mouse_js_r: pc=%05X, result=%02X\n",pc,result);
16821679   }
16831680   else
trunk/src/mess/includes/rmnimbus.h
r31019r31020
1212#include "bus/scsi/scsi.h"
1313#include "machine/6522via.h"
1414#include "machine/ram.h"
15#include "machine/er59256.h"
15#include "machine/eepromser.h"
1616#include "sound/ay8910.h"
1717#include "sound/msm5205.h"
1818#include "bus/centronics/ctronics.h"
r31019r31020
2020#define MAINCPU_TAG "maincpu"
2121#define IOCPU_TAG   "iocpu"
2222
23#define num_ioports             0x80
24
2523#define SCREEN_WIDTH_PIXELS     640
2624#define SCREEN_HEIGHT_LINES     250
2725#define SCREEN_NO_COLOURS       16
2826
2927#define NO_VIDREGS              (0x30/2)
3028
31/* Nimbus sub-bios structures for debugging */
3229
33struct t_area_params
34{
35   UINT16  ofs_brush;
36   UINT16  seg_brush;
37   UINT16  ofs_data;
38   UINT16  seg_data;
39   UINT16  count;
40};
41
42struct t_plot_string_params
43{
44   UINT16  ofs_font;
45   UINT16  seg_font;
46   UINT16  ofs_data;
47   UINT16  seg_data;
48   UINT16  x;
49   UINT16  y;
50   UINT16  length;
51};
52
53struct t_nimbus_brush
54{
55   UINT16  style;
56   UINT16  style_index;
57   UINT16  colour1;
58   UINT16  colour2;
59   UINT16  transparency;
60   UINT16  boundary_spec;
61   UINT16  boundary_colour;
62   UINT16  save_colour;
63};
64
65
66// Static data related to Floppy and SCSI hard disks
67struct nimbus_drives_t
68{
69   UINT8   reg400;
70   UINT8   reg418;
71
72   UINT8   drq_ff;
73   UINT8   int_ff;
74};
75
76/* 8031 Peripheral controler */
77struct ipc_interface_t
78{
79   UINT8   ipc_in;
80   UINT8   ipc_out;
81   UINT8   status_in;
82   UINT8   status_out;
83   UINT8   int_8c_pending;
84   UINT8   int_8e_pending;
85   UINT8   int_8f_pending;
86};
87
88/* Mouse/Joystick */
89struct mouse_joy_state
90{
91   UINT8   m_mouse_px;
92   UINT8   m_mouse_py;
93
94   UINT8   m_mouse_x;
95   UINT8   m_mouse_y;
96   UINT8   m_mouse_pc;
97   UINT8   m_mouse_pcx;
98   UINT8   m_mouse_pcy;
99
100   UINT8   m_intstate_x;
101   UINT8   m_intstate_y;
102
103   UINT8   m_reg0a4;
104
105   emu_timer   *m_mouse_timer;
106};
107
108
109/*----------- defined in drivers/rmnimbus.c -----------*/
110
111extern const unsigned char nimbus_palette[SCREEN_NO_COLOURS][3];
112
113
114/*----------- defined in machine/rmnimbus.c -----------*/
115
116
117
118
119/* 80186 Internal */
120
121/* external int priority masks */
122
123#define EXTINT_CTRL_PRI_MASK    0x07
124#define EXTINT_CTRL_MSK         0x08
125#define EXTINT_CTRL_LTM         0x10
126#define EXTINT_CTRL_CASCADE     0x20
127#define EXTINT_CTRL_SFNM        0x40
128
129/* DMA control register */
130
131#define DEST_MIO                0x8000
132#define DEST_DECREMENT          0x4000
133#define DEST_INCREMENT          0x2000
134#define DEST_NO_CHANGE          (DEST_DECREMENT | DEST_INCREMENT)
135#define DEST_INCDEC_MASK        (DEST_DECREMENT | DEST_INCREMENT)
136#define SRC_MIO                 0X1000
137#define SRC_DECREMENT           0x0800
138#define SRC_INCREMENT           0x0400
139#define SRC_NO_CHANGE           (SRC_DECREMENT | SRC_INCREMENT)
140#define SRC_INCDEC_MASK         (SRC_DECREMENT | SRC_INCREMENT)
141#define TERMINATE_ON_ZERO       0x0200
142#define INTERRUPT_ON_ZERO       0x0100
143#define SYNC_MASK               0x00C0
144#define SYNC_SOURCE             0x0040
145#define SYNC_DEST               0x0080
146#define CHANNEL_PRIORITY        0x0020
147#define TIMER_DRQ               0x0010
148#define CHG_NOCHG               0x0004
149#define ST_STOP                 0x0002
150#define BYTE_WORD               0x0001
151
15230/* Nimbus specific */
15331
15432/* External int vectors for chained interupts */
r31019r31020
17654#define HIBLOCK_BASE_MASK   0x08
17755#define HIBLOCK_SELECT_MASK 0x10
17856
179
180
18157/* Z80 SIO for keyboard */
18258
18359#define Z80SIO_TAG          "z80sio"
r31019r31020
266142
267143#define VIA_INT                 0x03
268144
269
270/*----------- defined in video/rmnimbus.c -----------*/
271
272
273
274
275
276
277
278#define RED                     0
279#define GREEN                   1
280#define BLUE                    2
281
282145#define LINEAR_ADDR(seg,ofs)    ((seg<<4)+ofs)
283146
284147#define OUTPUT_SEGOFS(mess,seg,ofs)  logerror("%s=%04X:%04X [%08X]\n",mess,seg,ofs,((seg<<4)+ofs))
r31019r31020
300163      m_scsi_data_in(*this, "scsi_data_in"),
301164      m_scsi_ctrl_out(*this, "scsi_ctrl_out"),
302165      m_fdc(*this, FDC_TAG),
303      m_z80sio(*this, Z80SIO_TAG)
166      m_z80sio(*this, Z80SIO_TAG),
167      m_screen(*this, "screen")
304168   {
305169   }
306170
r31019r31020
308172   required_device<msm5205_device> m_msm;
309173   required_device<SCSI_PORT_DEVICE> m_scsibus;
310174   required_device<ram_device> m_ram;
311   required_device<er59256_device> m_eeprom;
175   required_device<eeprom_serial_93cxx_device> m_eeprom;
312176   required_device<via6522_device> m_via;
313177   required_device<centronics_device> m_centronics;
314178   required_device<palette_device> m_palette;
r31019r31020
317181   required_device<output_latch_device> m_scsi_ctrl_out;
318182   required_device<wd2793_t> m_fdc;
319183   required_device<z80sio2_device> m_z80sio;
184   required_device<screen_device> m_screen;
320185
186   bitmap_ind16 m_video_mem;
187
321188   UINT32 m_debug_machine;
322   nimbus_drives_t m_nimbus_drives;
323   ipc_interface_t m_ipc_interface;
324189   UINT8 m_mcu_reg080;
325190   UINT8 m_iou_reg092;
326191   UINT8 m_last_playmode;
327   mouse_joy_state m_nimbus_mouse;
328192   UINT8 m_ay8910_a;
329   UINT16 m_IOPorts[num_ioports];
330193   UINT8 m_sio_int_state;
331   UINT8 m_video_mem[SCREEN_WIDTH_PIXELS][SCREEN_HEIGHT_LINES];
332194   UINT16 m_vidregs[NO_VIDREGS];
333195   UINT8 m_bpp;
334196   UINT16 m_pixel_mask;
335197   UINT8 m_hs_count;
336198   UINT32 m_debug_video;
337199   UINT8 m_vector;
200   UINT8 m_eeprom_bits;
201   UINT8 m_eeprom_state;
202
338203   DECLARE_READ8_MEMBER(nimbus_mcu_r);
339204   DECLARE_WRITE8_MEMBER(nimbus_mcu_w);
340205   DECLARE_READ16_MEMBER(nimbus_io_r);
r31019r31020
356221   DECLARE_WRITE8_MEMBER(nimbus_mouse_js_w);
357222   DECLARE_READ16_MEMBER(nimbus_video_io_r);
358223   DECLARE_WRITE16_MEMBER(nimbus_video_io_w);
359   DECLARE_DRIVER_INIT(nimbus);
360224   virtual void machine_start();
361225   virtual void machine_reset();
362226   virtual void video_start();
363227   virtual void video_reset();
364228   DECLARE_PALETTE_INIT(rmnimbus);
365229   UINT32 screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
366   void screen_eof_nimbus(screen_device &screen, bool state);
367   TIMER_CALLBACK_MEMBER(keyscan_callback);
368   TIMER_CALLBACK_MEMBER(mouse_callback);
369230   DECLARE_WRITE_LINE_MEMBER(sio_interrupt);
370231   DECLARE_WRITE_LINE_MEMBER(nimbus_fdc_intrq_w);
371232   DECLARE_WRITE_LINE_MEMBER(nimbus_fdc_drq_w);
r31019r31020
378239   DECLARE_WRITE_LINE_MEMBER(write_scsi_req);
379240   DECLARE_WRITE_LINE_MEMBER(nimbus_msm5205_vck);
380241   DECLARE_WRITE_LINE_MEMBER(write_scsi_iena);
381   DECLARE_WRITE_LINE_MEMBER(keyboard_clk);
382242
383243   UINT8 get_pixel(UINT16 x, UINT16 y);
384244   UINT16 read_pixel_line(UINT16 x, UINT16 y, UINT8 width);
385245   UINT16 read_pixel_data(UINT16 x, UINT16 y);
386   UINT16 read_reg_00A();
387246   void set_pixel(UINT16 x, UINT16 y, UINT8 colour);
388247   void set_pixel40(UINT16 x, UINT16 y, UINT8 colour);
389248   void write_pixel_line(UINT16 x, UINT16 y, UINT16    data, UINT8 width);
r31019r31020
423282   int m_scsi_io;
424283   int m_scsi_cd;
425284   int m_scsi_req;
285
286   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
287
288   enum
289   {
290      TIMER_MOUSE
291   };
292
293   // Static data related to Floppy and SCSI hard disks
294   struct
295   {
296      UINT8   reg400;
297      UINT8   reg418;
298
299      UINT8   drq_ff;
300      UINT8   int_ff;
301   } m_nimbus_drives;
302
303   /* 8031 Peripheral controler */
304   struct
305   {
306      UINT8   ipc_in;
307      UINT8   ipc_out;
308      UINT8   status_in;
309      UINT8   status_out;
310      UINT8   int_8c_pending;
311      UINT8   int_8e_pending;
312      UINT8   int_8f_pending;
313   } m_ipc_interface;
314
315   /* Mouse/Joystick */
316   struct
317   {
318      UINT8   m_mouse_px;
319      UINT8   m_mouse_py;
320
321      UINT8   m_mouse_x;
322      UINT8   m_mouse_y;
323      UINT8   m_mouse_pc;
324      UINT8   m_mouse_pcx;
325      UINT8   m_mouse_pcy;
326
327      UINT8   m_intstate_x;
328      UINT8   m_intstate_y;
329
330      UINT8   m_reg0a4;
331
332      emu_timer   *m_mouse_timer;
333   } m_nimbus_mouse;
426334};
trunk/src/mess/video/rmnimbus.c
r31019r31020
6464#define IS_80COL        (m_vidregs[reg026]&MASK_4080)
6565#define IS_XOR          (m_vidregs[reg022]&XOR_MASK)
6666
67
68
69
7067#define DEBUG_TEXT  0x01
7168#define DEBUG_DB    0x02
7269#define DEBUG_PIXEL 0x04
r31019r31020
9087   {
9188      case    reg000  : result=m_vidregs[reg000]; break;
9289      case    reg002  : result=m_vidregs[reg002]; break;
93      case    reg004  : result=m_vidregs[reg004]; break;
90      case    reg004  : result=read_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C]); break;
9491      case    reg006  : result=m_vidregs[reg006]; break;
9592      case    reg008  : result=m_vidregs[reg008]; break;
96      case    reg00A  : result=read_reg_00A(); break;
93      case    reg00A  : result=read_pixel_data(++m_vidregs[reg002],m_vidregs[reg00C]); break;
9794      case    reg00C  : result=m_vidregs[reg00C]; break;
9895      case    reg00E  : result=m_vidregs[reg00E]; break;
9996
r31019r31020
110107      case    reg022  : result=m_vidregs[reg022]; break;
111108      case    reg024  : result=m_vidregs[reg024]; break;
112109      case    reg026  : result=m_vidregs[reg026]; break;
113      case    reg028  : result=m_hs_count; break; //result=m_vidregs[reg028]; break;
110      case    reg028  : result=m_screen->vpos() % 0xb; break; //result=m_vidregs[reg028]; break;
114111      case    reg02A  : result=m_vidregs[reg02A]; break;
115112      case    reg02C  : result=m_vidregs[reg02C]; break;
116113      case    reg02E  : result=m_vidregs[reg02E]; break;
r31019r31020
130127   if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES))
131128   {
132129      if(IS_80COL)
133         result=m_video_mem[x][y];
130         result=m_video_mem.pix16(y, x);
134131      else
135         result=m_video_mem[x*2][y];
132         result=m_video_mem.pix16(y, x*2);
136133   }
137134
138135   return result;
r31019r31020
187184
188185         case 0x03   : break;
189186
190         case 0x04   : break;
187         case 0x04   : m_bpp=2; m_pixel_mask=0xC0;
188                     result=read_pixel_line(x,y,8);
189                     break;
191190
192191         case 0x05   : break;
193192
r31019r31020
225224   return result;
226225}
227226
228UINT16 rmnimbus_state::read_reg_00A()
229{
230   return read_pixel_data(++m_vidregs[reg002],m_vidregs[reg00C]);
231}
232
233
234227/*
235228    Write to the video registers, the default action is to write to the array of registers.
236229    If a register also needs some special action call the action function for that register.
r31019r31020
298291   if((x<SCREEN_WIDTH_PIXELS) && (y<SCREEN_HEIGHT_LINES))
299292   {
300293      if(IS_XOR)
301         m_video_mem[x][y]^=colour;
294         m_video_mem.pix16(y, x)^=colour;
302295      else
303         m_video_mem[x][y]=colour;
296         m_video_mem.pix16(y, x)=colour;
304297   }
305298}
306299
r31019r31020
353346      pixelx=(x*width)+pixelno;
354347      if(DEBUG_SET(DEBUG_TEXT | DEBUG_PIXEL))
355348         logerror("pixelx=%04X\n",pixelx);
356      m_video_mem[pixelx][m_vidregs[reg020]]=m_video_mem[pixelx][y];
349      m_video_mem.pix16(m_vidregs[reg020], pixelx)=m_video_mem.pix16(y, pixelx);
357350   }
358351}
359352
r31019r31020
369362    001 2bpp, using the first 4 colours of the pallette
370363    010
371364    011
372    100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with the lower byte
373              containing the pixel data for two pixels.
365    100 4bpp, must be a 16 bit word, of which the upper byte is a mask anded with existing pixels then ored
366              with the lower byte containing the pixel data for two pixels.
374367    101 Move pixel data at x,reg020 to x,y, used for scrolling.
375368    110 if 40 col
376369            4bpp, 16 bit word containing the pixel data for 4 pixels.
r31019r31020
410403                     break;
411404
412405         case 0x04   : m_bpp=2; m_pixel_mask=0xC0;
413                     write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8);
406                     write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,8)),8);
414407                     break;
415408
416409         case 0x05   : move_pixel_line(x,y,data,16);
r31019r31020
446439                     break;
447440
448441         case 0x04   : m_bpp=4; m_pixel_mask=0xF0;
449                     write_pixel_line(x,y,((data & 0xFF) & ((data & 0xFF00)>>8)),8);
442                     write_pixel_line(x,y,(((data & 0xFF00)>>8) & (data & 0xFF)) | (~((data & 0xFF00)>>8) & read_pixel_line(x,y,8)),8);
450443                     break;
451444
452445         case 0x05   : move_pixel_line(x,y,data,16);
r31019r31020
492485
493486void rmnimbus_state::write_reg_014()
494487{
495   write_pixel_data(m_vidregs[reg002],m_vidregs[reg00C]++,m_vidregs[reg014]);
488   write_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C],m_vidregs[reg014]);
496489}
497490
498491void rmnimbus_state::write_reg_016()
499492{
500493   m_vidregs[reg002]=m_vidregs[reg016];
501494
502   write_pixel_data(m_vidregs[reg002],m_vidregs[reg00C]++,FG_COLOUR);
495   write_pixel_data(m_vidregs[reg002],++m_vidregs[reg00C],FG_COLOUR);
503496}
504497
505498
r31019r31020
541534   UINT8   colourno;
542535   UINT16  mask;
543536   UINT8   shifts;
544   UINT8   paletteidx;
545537   UINT8   colourmax;
546538   UINT8   first;
547539
r31019r31020
561553   // loop over changing colours
562554   for(colourno=first; colourno<(first+colourmax); colourno++)
563555   {
564      paletteidx=(colours & mask) >> shifts;
565      m_palette->set_pen_color(colourno, nimbus_palette[paletteidx][RED], nimbus_palette[paletteidx][GREEN], nimbus_palette[paletteidx][BLUE]);
556      int paletteidx=(colours & mask) >> shifts;
557      int i = (paletteidx & 8) >> 3;
558      m_palette->set_pen_color(colourno, pal2bit((paletteidx & 2) | i), pal2bit(((paletteidx & 4) >> 1) | i), pal2bit(((paletteidx & 1) << 1) | i));
566559
567560      if(DEBUG_SET(DEBUG_TEXT))
568         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);
561         logerror("set colourno[%02X], paletteidx=%02X\n",colourno, paletteidx);
569562      mask=mask<<4;
570563      shifts+=4;
571564   }
r31019r31020
610603
611604   logerror("video_start\n");
612605
606   m_screen->register_screen_bitmap(m_video_mem);
607
608   save_item(NAME(m_vidregs));
609
613610   if (machine().debug_flags & DEBUG_FLAG_ENABLED)
614611   {
615612      debug_console_register_command(machine(), "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
r31019r31020
617614   }
618615}
619616
617PALETTE_INIT_MEMBER(rmnimbus_state, rmnimbus)
618{
619   int colourno;
620
621   for ( colourno = 0; colourno < SCREEN_NO_COLOURS; colourno++ )
622   {
623      int i = (colourno & 8) >> 3;
624      palette.set_pen_color(colourno, pal2bit((colourno & 2) | i), pal2bit(((colourno & 4) >> 1) | i), pal2bit(((colourno & 1) << 1) | i));
625   }
626}
627
620628void rmnimbus_state::video_reset()
621629{
622630   // When we reset clear the video registers and video memory.
623631   memset(&m_vidregs,0x00,sizeof(m_vidregs));
624   memset(&m_video_mem,0,sizeof(m_video_mem));
625632
626633   m_bpp=4;          // bits per pixel
627634   logerror("Video reset\n");
628635}
629636
630void rmnimbus_state::screen_eof_nimbus(screen_device &screen, bool state)
631{
632//    logerror("screen_eof_nimbus\n");
633}
634
635637UINT32 rmnimbus_state::screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
636638{
637   int     XCoord;
638   int     YCoord = screen.vpos();
639   copybitmap(bitmap, m_video_mem, 0, 0, 0, 0, cliprect);
639640
640   for(XCoord=0;XCoord<SCREEN_WIDTH_PIXELS;XCoord++)
641   {
642      bitmap.pix16(YCoord, XCoord)=m_video_mem[XCoord][YCoord];
643   }
644
645   m_hs_count++;
646   if((m_hs_count & 0x000F)>0x0A)
647      m_hs_count&=0xFFF0;
648
649641   return 0;
650642}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team