Previous 15994 Revisions Next

r6793 Sunday 27th December, 2009 at 22:38:57 UTC by Phill Harvey-Smith
Second part of RM nimbus driver
[src/mess/drivers]rmnimbus.c*
[src/mess/includes]rmnimbus.h*
[src/mess/machine]rmnimbus.c*
[src/mess/video]rmnimbus.c*

src/mess/video/rmnimbus.c
r0r6793
1/*
2    video/rmnimbus.c
3     
4    Research machines Nimbus.
5     
6    2009-11-14, P.Harvey-Smith.
7     
8*/
9 
10#include "driver.h"
11#include "video/border.h"
12#include "memory.h"
13#include "debug/debugcpu.h"
14#include "debug/debugcon.h"
15#include "includes/rmnimbus.h"
16#include "mame.h"
17 
18#include "debug/debugcpu.h"
19#include "debug/debugcon.h"
20 
21UINT8 *video_mem;
22 
23#define BYTES_PER_LINE  160
24#define MAX_PIXELX_2BPP 639
25#define MAX_PIXELX_4BPP 319
26 
27#define WIDTH_MASK      0x03
28#define XOR_MASK        0x08
29 
30UINT16  reg002_x;
31UINT16  reg004;
32UINT16  reg010;
33UINT16  reg00C_y;
34UINT16  reg022; 
35UINT16  reg024;
36UINT16  reg026;
37UINT16  reg028;
38 
39UINT8   bpp;            // Bits / pixel
40UINT8   ppb;            // Pixels / byte
41UINT8   border_colour;
42 
43int debug_on;
44 
45static void set_pixel(UINT16 x, UINT16 y, UINT8 on_off);
46static void write_pixel_line(UINT16 x, UINT16 y, UINT16    data, UINT16    mem_mask, UINT8 width);
47static void write_pixel_data(UINT16 x, UINT16 y, UINT16    data, UINT16    mem_mask);
48static void write_reg_004(UINT16    data, UINT16    mem_mask);
49static void write_reg_010(UINT16    data, UINT16    mem_mask);
50static void write_reg_014(UINT16    data, UINT16    mem_mask);
51static void write_reg_01A(UINT16    data, UINT16    mem_mask);
52static void write_reg_026(UINT16    data, UINT16    mem_mask);
53 
54static void video_debug(running_machine *machine, int ref, int params, const char *param[]);
55 
56READ16_HANDLER (nimbus_video_io_r)
57{
58    int     pc=cpu_get_pc(space->cpu);
59    UINT16  result;
60         
61    switch (offset*2)
62    {
63        case    0x002   : result=reg002_x; break;
64        case    0x004   : result=reg004; break;
65        case    0x00C   : result=reg00C_y; break;
66        case    0x010   : result=reg010; break;
67        case    0x022   : result=reg022; break;
68        case    0x024   : result=reg024; break;
69        case    0x026   : result=reg024; break;
70        case    0x028   : result=reg028; break;
71        default         : result=0; break;
72    }
73 
74    if(debug_on & DEBUG_TEXT)
75        logerror("Nimbus video IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2),mem_mask,result);
76     
77    return result;
78}
79 
80WRITE16_HANDLER (nimbus_video_io_w)
81{
82    int pc=cpu_get_pc(space->cpu);
83 
84    if(debug_on & DEBUG_TEXT)
85        logerror("Nimbus video IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2),mem_mask);
86 
87    if(debug_on & DEBUG_DB)
88        logerror("dw %05X,%05X\n",(offset*2),data);
89     
90     
91    switch (offset*2)
92    {
93        case    0x002   : COMBINE_DATA(&reg002_x); break;
94        case    0x004   : write_reg_004(data,mem_mask); break;
95        case    0x00C   : COMBINE_DATA(&reg00C_y); break;
96        case    0x010   : write_reg_010(data,mem_mask); break;
97        case    0x014   : write_reg_014(data,mem_mask); break;
98        case    0x01A   : write_reg_01A(data,mem_mask); break;
99        case    0x022   : COMBINE_DATA(&reg022); break;
100        case    0x024   : COMBINE_DATA(&reg024); break;
101        case    0x026   : write_reg_026(data,mem_mask); break;
102        case    0x028   : COMBINE_DATA(&reg028); break;
103        default         : break;
104    }
105}
106 
107static void set_pixel(UINT16 x, UINT16 y, UINT8 on_off )
108{
109    offs_t  vaddr;
110    UINT8   rshifts;
111    UINT8   lshifts;
112    UINT8   last;
113    UINT8   mask;
114    UINT8   pixel_offset;
115    UINT8   colour;
116     
117    vaddr=(BYTES_PER_LINE*y)+(x / ppb);
118    pixel_offset=(x % ppb);
119    last=video_mem[vaddr];
120    colour=on_off ? (reg024&0x0F) : ((reg024&0xF0)>>4);
121     
122    if(bpp==2)
123    {
124        colour&=0x03;
125        rshifts=(pixel_offset%4)*2;
126        mask=~(0xC0>>rshifts);
127        lshifts=6-rshifts;
128    }
129    else
130    {
131        colour&=0x0F;
132        rshifts=(pixel_offset%2)*4;
133        mask=~(0xF0>>rshifts);
134        lshifts=4-rshifts;         
135    }
136     
137    if(reg022 & XOR_MASK)
138        video_mem[vaddr]=(video_mem[vaddr] & mask) ^ (colour<<(lshifts)); 
139    else
140        video_mem[vaddr]=(video_mem[vaddr] & mask) | (colour<<(lshifts)); 
141 
142    if(debug_on & DEBUG_TEXT)
143        logerror("set_pixel(X=%04X, y=%04x, pixel_offset=%02X, on_off=%02X), vaddr=%04X, mask=%02X, last=%02X, current=%02X\n",x,y,pixel_offset,on_off,vaddr,mask,last,video_mem[vaddr]);
144}
145 
146 
147static void write_pixel_line(UINT16 x, UINT16 y, UINT16    data, UINT16    mem_mask, UINT8 width)
148{
149    UINT8   bit;
150    UINT16  pixel_x;
151    UINT8   shifts;
152     
153    shifts=(width==4) ? 2 : 1;     
154     
155    for(bit=0x80, pixel_x=(x*width); bit>0; bit=(bit>>shifts), pixel_x++)
156    {
157        set_pixel(pixel_x,y,(data&bit));
158        if(width==16)
159            set_pixel(pixel_x+1,y,(data&bit));
160    }
161}
162 
163static void write_pixel_data(UINT16 x, UINT16 y, UINT16    data, UINT16    mem_mask)
164{     
165    switch (reg022 & WIDTH_MASK)
166    {
167        case 0x00   : write_pixel_line(x,y,data,mem_mask,16); break;
168        case 0x01   : write_pixel_line(x,y,data,mem_mask,8); break;
169        case 0x02   : write_pixel_line(x,y,data,mem_mask,8); break;
170        case 0x03   : set_pixel(x,y,(reg024&0x0F)); break;       
171    }
172}
173 
174static void write_reg_004(UINT16    data, UINT16    mem_mask)
175{
176    COMBINE_DATA(&reg004);
177     
178    reg002_x=1;
179    reg00C_y++;
180}
181 
182static void write_reg_010(UINT16    data, UINT16    mem_mask)
183{
184    write_pixel_data(0,reg00C_y,data,mem_mask);     
185}
186 
187static void write_reg_014(UINT16    data, UINT16    mem_mask)
188{   
189    write_pixel_data(reg002_x+1,reg00C_y,data,mem_mask);
190     
191    reg00C_y++;
192}
193 
194static void write_reg_01A(UINT16    data, UINT16    mem_mask)
195{
196    write_pixel_data(reg002_x+1,reg00C_y,data,mem_mask);   
197     
198    reg002_x++;
199}
200 
201static void write_reg_026(UINT16    data, UINT16    mem_mask)
202{
203    COMBINE_DATA(&reg026);
204 
205    switch (data & 0x30)
206    {
207        case    0x00    : bpp=4;
208        case    0x10    : bpp=2;
209        case    0x20    : bpp=2;
210        case    0x30    : bpp=2;         
211    }
212 
213    ppb=(8/bpp);
214 
215    border_colour=data & 0x0F;
216 
217    if(debug_on & DEBUG_TEXT)
218        logerror("reg 026 write, bpp=%02X, border_colour=%02X\n",bpp,border_colour);
219}
220 
221static void video_debug(running_machine *machine, int ref, int params, const char *param[])
222{
223    if(params>0)
224    {   
225        sscanf(param[0],"%d",&debug_on);         
226    }
227    else
228    {
229        debug_console_printf(machine,"Error usage : nimbus_vid_debug <debuglevel>\n");
230        debug_console_printf(machine,"Current debuglevel=%02X\n",debug_on);
231    }
232}
233 
234 
235VIDEO_START( nimbus )
236{
237    debug_on=0;
238     
239    reg002_x=0x0000;
240    reg00C_y=0x0000;
241     
242    reg022=0x0000;
243    reg024=0x0000;
244    reg028=0x0000;
245    bpp=4;          // bits per pixel
246 
247    logerror("VIDEO_START\n");
248    video_mem=(UINT8 *)memory_region_alloc(machine,VRAM_NAME,VRAM_SIZE,ROMREGION_8BIT);
249 
250    memset(video_mem,0,VRAM_SIZE); 
251     
252      if (machine->debug_flags & DEBUG_FLAG_ENABLED)
253   {
254        debug_console_register_command(machine, "nimbus_vid_debug", CMDFLAG_NONE, 0, 0, 1, video_debug);
255    }
256}
257 
258VIDEO_EOF( nimbus )
259{
260 
261//    logerror("VIDEO_EOF( nimbus )\n");
262}
263 
264VIDEO_UPDATE( nimbus )
265{
266    int     XCoord;
267    int     YCoord = video_screen_get_vpos(screen);
268    offs_t  vaddr;
269    UINT8   pixel_offset;
270    UINT8   shifts;
271    UINT8   pixel;
272     
273    UINT16  xmax;
274 
275    if (bpp==2) 
276        xmax=MAX_PIXELX_2BPP;
277    else
278        xmax=MAX_PIXELX_4BPP;
279 
280    vaddr=(YCoord*BYTES_PER_LINE)-1;
281     
282    for(XCoord=0;XCoord<xmax;XCoord++)
283    {
284        if ((XCoord % (8/bpp))==0)
285            vaddr++;
286             
287        pixel_offset=(XCoord % 8);
288             
289        if(bpp==2)
290        {
291            shifts=(pixel_offset%4)*2;
292            pixel=(video_mem[vaddr] & (0xC0>>shifts)) >> (6-shifts);
293        }
294        else
295        {
296            shifts=(pixel_offset%2)*4;
297            pixel=(video_mem[vaddr] & (0xF0>>shifts)) >> (4-shifts);
298        }
299             
300        *BITMAP_ADDR16(bitmap, YCoord, XCoord)=pixel;
301    }
302 
303    reg028++;
304    if((reg028 & 0x000F)>0x0A)
305        reg028&=0xFFF0;
306 
307 
308    return 0;
309}
310 
src/mess/includes/rmnimbus.h
r0r6793
1/* 
2    rmnimbus.c
3    Machine driver for the Research Machines Nimbus.
4     
5    Phill Harvey-Smith
6    2009-11-29.
7*/
8 
9#include "machine/z80sio.h"
10#include "machine/wd17xx.h"
11 
12#define DEBUG_TEXT  0x01
13#define DEBUG_DB    0x02
14 
15#define MAINCPU_TAG "maincpu"
16 
17DRIVER_INIT(nimbus);
18MACHINE_RESET(nimbus);
19MACHINE_START(nimbus);
20 
21/* 80186 Internal */
22READ16_HANDLER (i186_internal_port_r);
23WRITE16_HANDLER (i186_internal_port_w);
24 
25/* external int priority masks */
26 
27#define EXTINT_CTRL_PRI_MASK    0x07
28#define EXTINT_CTRL_MSK         0x08
29#define EXTINT_CTRL_LTM         0x10
30#define EXTINT_CTRL_CASCADE     0x20
31#define EXTINT_CTRL_SFNM        0x40
32 
33/* DMA control register */
34 
35#define DEST_MIO                0x8000
36#define DEST_DECREMENT          0x4000
37#define DEST_INCREMENT          0x2000
38#define DEST_NO_CHANGE          (DEST_DECREMENT | DEST_INCREMENT)
39#define DEST_INCDEC_MASK        (DEST_DECREMENT | DEST_INCREMENT)
40#define SRC_MIO                 0X1000
41#define SRC_DECREMENT           0x0800
42#define SRC_INCREMENT           0x0400
43#define SRC_NO_CHANGE           (SRC_DECREMENT | SRC_INCREMENT)
44#define SRC_INCDEC_MASK         (SRC_DECREMENT | SRC_INCREMENT)
45#define TERMINATE_ON_ZERO       0x0200
46#define INTERRUPT_ON_ZERO       0x0100
47#define SYNC_MASK               0x00C0
48#define SYNC_SOURCE             0x0040
49#define SYNC_DEST               0x0080
50#define CHANNEL_PRIORITY        0x0020
51#define TIMER_DRQ               0x0010
52#define CHG_NOCHG               0x0004
53#define ST_STOP                 0x0002
54#define BYTE_WORD               0x0001
55 
56/* Nimbus specific */
57READ16_HANDLER (nimbus_io_r);
58WRITE16_HANDLER (nimbus_io_w);
59 
60/* Z80 SIO for keyboard */
61 
62#define Z80SIO_TAG      "z80sio"
63#define NIMBUS_KEYROWS  1
64 
65extern const z80sio_interface sio_intf;
66 
67READ8_DEVICE_HANDLER( sio_r );
68WRITE8_DEVICE_HANDLER( sio_w );
69 
70void sio_interrupt(const device_config *device, int state);
71//WRITE8_DEVICE_HANDLER( sio_dtr_w );
72WRITE8_DEVICE_HANDLER( sio_serial_transmit );
73int sio_serial_receive( const device_config *device, int channel );
74 
75/* Floppy drive interface */
76 
77#define FDC_TAG                 "wd2793"
78 
79extern const wd17xx_interface nimbus_wd17xx_interface;
80 
81READ8_HANDLER( nimbus_fdc_r );
82WRITE8_HANDLER( nimbus_fdc_w );
83 
84#define NO_DRIVE_SELECTED   0xFF
85 
86 
87/* Video stuff */
88READ16_HANDLER (nimbus_video_io_r);
89WRITE16_HANDLER (nimbus_video_io_w);
90 
91VIDEO_START( nimbus );
92VIDEO_EOF( nimbus );
93VIDEO_UPDATE( nimbus );
94 
95#define VRAM_NAME   "nimbusvram"
96#define VRAM_SIZE   (64*1024)
97 
98 
99#define LINEAR_ADDR(seg,ofs)    ((seg<<4)+ofs)
100 
101/* Nimbus sub-bios structures for debugging */
102 
103typedef struct 
104{
105    UINT16  ofs_brush;
106    UINT16  seg_brush;
107    UINT16  ofs_data;
108    UINT16  seg_data;
109    UINT16  count;
110} t_area_params;
111 
112typedef struct 
113{
114    UINT16  ofs_font;
115    UINT16  seg_font;
116    UINT16  ofs_data;
117    UINT16  seg_data;
118    UINT16  x;
119    UINT16  y;
120    UINT16  length;
121} t_plot_string_params;
122 
123typedef struct
124{
125    UINT16  style;
126    UINT16  style_index;
127    UINT16  colour1;
128    UINT16  colour2;
129    UINT16  transparency;
130    UINT16  boundary_spec;
131    UINT16  boundary_colour;
132    UINT16  save_colour;
133} t_nimbus_brush;
134 
135#define OUTPUT_SEGOFS(mess,seg,ofs)  logerror("%s=%04X:%04X [%08X]\n",mess,seg,ofs,((seg<<4)+ofs))
136 
137 
138/*
139 
140    Grapics registers (best guesses)
141     
142    Addr    width   purpose
143     
144    0x000C  word    Y co-ordinate 
145    0x0012  word    X co-ordinate
146     
147    0x0014  byte
148    0x001A  word
149     
150*/
src/mess/machine/rmnimbus.c
r0r6793
1/* 
2    machine/rmnimbus.c
3     
4    Machine driver for the Research Machines Nimbus.
5     
6    Phill Harvey-Smith
7    2009-11-29.
8     
9    80186 internal DMA/Timer/PIC code borrowed from Compis driver.
10    Perhaps this needs merging into the 80186 core.....
11*/
12 
13 
14#include "driver.h"
15#include "memory.h"
16#include "cpu/i86/i86.h"
17#include "debug/debugcpu.h"
18#include "debug/debugcon.h"
19#include "devices/flopdrv.h"
20#include "machine/pic8259.h"
21#include "machine/pit8253.h"
22#include "machine/msm8251.h"
23#include "machine/z80sio.h"
24 
25#include "includes/rmnimbus.h"
26 
27/*-------------------------------------------------------------------------*/
28/* Defines, constants, and global variables                                */
29/*-------------------------------------------------------------------------*/
30 
31/* CPU 80186 */
32#define LATCH_INTS 1
33#define LOG_PORTS 0
34#define LOG_INTERRUPTS 0
35#define LOG_INTERRUPTS_EXT 0
36#define LOG_TIMER 0
37#define LOG_OPTIMIZATION 0
38#define LOG_DMA 1
39#define CPU_RESUME_TRIGGER   7123
40 
41/* 80186 internal stuff */
42struct mem_state
43{
44   UINT16       lower;
45   UINT16       upper;
46   UINT16       middle;
47   UINT16       middle_size;
48   UINT16       peripheral;
49};
50 
51struct timer_state
52{
53   UINT16       control;
54   UINT16       maxA;
55   UINT16       maxB;
56   UINT16       count;
57   emu_timer   *int_timer;
58   emu_timer   *time_timer;
59   UINT8       time_timer_active;
60   attotime   last_time;
61};
62 
63struct dma_state
64{
65   UINT32       source;
66   UINT32       dest;
67   UINT16       count;
68   UINT16       control;
69   UINT8       finished;
70   emu_timer   *finish_timer;
71};
72 
73struct intr_state
74{
75   UINT8   pending;
76   UINT16   ack_mask;
77   UINT16   priority_mask;
78   UINT16   in_service;
79   UINT16   request;
80   UINT16   status;
81   UINT16   poll_status;
82   UINT16   timer;
83   UINT16   dma[2];
84   UINT16   ext[4];
85    UINT16  ext_vector[2]; // external vectors, when in cascade mode
86};
87 
88static struct i186_state
89{
90   struct timer_state   timer[3];
91   struct dma_state   dma[2];
92   struct intr_state   intr;
93   struct mem_state   mem;
94} i186;
95 
96 
97/* Z80 SIO */
98 
99const z80sio_interface sio_intf =
100{
101   sio_interrupt,         /* interrupt handler */
102   0, //sio_dtr_w,            /* DTR changed handler */
103   0,                  /* RTS changed handler */
104   0,                  /* BREAK changed handler */
105   sio_serial_transmit,   /* transmit handler */
106   sio_serial_receive      /* receive handler */
107};
108 
109static UINT8    keyrows[NIMBUS_KEYROWS];
110 
111/* Floppy drives WD2793 */
112 
113static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w );
114static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w );
115 
116const wd17xx_interface nimbus_wd17xx_interface =
117{
118   DEVCB_LINE(nimbus_fdc_intrq_w),
119   DEVCB_LINE(nimbus_fdc_drq_w),
120   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
121};
122 
123static struct _nimbus_fdc
124{
125    UINT8 drq_enabled;
126    UINT8 irq_enabled;
127    UINT8 diskno;
128    UINT8 motor_on;
129} nimbus_fdc;
130 
131 
132static void drq_callback(running_machine *machine, int which);
133 
134static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[]);
135static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[]);
136static void execute_debug_key(running_machine *machine, int ref, int params, const char *param[]);
137 
138static int instruction_hook(const device_config *device, offs_t curpc);
139static void decode_subbios(const device_config *device,offs_t pc);
140static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si);
141static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si);
142static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si);
143static void fdc_reset(void);
144 
145 
146#define num_ioports 0x80
147static UINT16   IOPorts[num_ioports];
148 
149UINT8 nextkey;
150UINT8 sio_int_state;
151 
152/*************************************
153 *
154 *  80186 interrupt controller
155 *
156 *************************************/
157static IRQ_CALLBACK(int_callback)
158{
159    UINT8   vector;
160    UINT16  old;
161    UINT16  oldreq;
162 
163   if (LOG_INTERRUPTS)
164      logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time(device->machine)), i186.intr.poll_status & 0x1f);
165 
166   /* clear the interrupt */
167   cpu_set_input_line(device, 0, CLEAR_LINE);
168   i186.intr.pending = 0;
169 
170    oldreq=i186.intr.request;
171 
172   /* clear the request and set the in-service bit */
173#if LATCH_INTS
174   i186.intr.request &= ~i186.intr.ack_mask;
175#else
176   i186.intr.request &= ~(i186.intr.ack_mask & 0x0f);
177#endif
178 
179    if(i186.intr.request!=oldreq)
180        logerror("i186.intr.request changed from %02X to %02X\n",oldreq,i186.intr.request);
181 
182    old=i186.intr.in_service;
183 
184   i186.intr.in_service |= i186.intr.ack_mask;
185   
186    if (LOG_INTERRUPTS)
187        if(i186.intr.in_service!=old)
188            logerror("i186.intr.in_service changed from %02X to %02X\n",old,i186.intr.in_service);
189     
190    if (i186.intr.ack_mask == 0x0001)
191   {
192      switch (i186.intr.poll_status & 0x1f)
193      {
194         case 0x08:   i186.intr.status &= ~0x01;   break;
195         case 0x12:   i186.intr.status &= ~0x02;   break;
196         case 0x13:   i186.intr.status &= ~0x04;   break;
197      }
198   }
199   i186.intr.ack_mask = 0;
200 
201   /* a request no longer pending */
202   i186.intr.poll_status &= ~0x8000;
203 
204   /* return the vector */
205    switch(i186.intr.poll_status & 0x1F)
206    {
207        case 0x0C   : vector=(i186.intr.ext[0] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[0] : (i186.intr.poll_status & 0x1f); logerror("int 0x0c vector=%02X\n",vector); break;
208        case 0x0D   : vector=(i186.intr.ext[1] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[1] : (i186.intr.poll_status & 0x1f); logerror("int 0x0D vector=%02X\n",vector); break;
209        default :
210            vector=i186.intr.poll_status & 0x1f; break;
211    }
212 
213    if (LOG_INTERRUPTS_EXT)
214   {
215        logerror("i186.intr.ext[0]=%04X i186.intr.ext[1]=%04X\n",i186.intr.ext[0],i186.intr.ext[1]);
216        logerror("Ext vectors : %02X %02X\n",i186.intr.ext_vector[0],i186.intr.ext_vector[1]);
217        logerror("Calling vector %02X\n",vector);
218    }
219     
220    return vector;
221}
222 
223 
224static void update_interrupt_state(running_machine *machine)
225{   
226    int new_vector = 0;
227    int Priority;
228    int IntNo;
229 
230   if (LOG_INTERRUPTS) 
231        logerror("update_interrupt_status: req=%04X stat=%04X serv=%04X priority_mask=%4X\n", i186.intr.request, i186.intr.status, i186.intr.in_service, i186.intr.priority_mask);
232 
233   /* loop over priorities */
234   for (Priority = 0; Priority <= i186.intr.priority_mask; Priority++)
235   {
236      /* note: by checking 4 bits, we also verify that the mask is off */
237      if ((i186.intr.timer & 15) == Priority)
238      {
239         /* if we're already servicing something at this level, don't generate anything new */
240         if (i186.intr.in_service & 0x01)
241            return;
242 
243         /* if there's something pending, generate an interrupt */
244         if (i186.intr.status & 0x07)
245         {
246            if (i186.intr.status & 1)
247               new_vector = 0x08;
248            else if (i186.intr.status & 2)
249               new_vector = 0x12;
250            else if (i186.intr.status & 4)
251               new_vector = 0x13;
252            else
253               popmessage("Invalid timer interrupt!");
254 
255            /* set the clear mask and generate the int */
256            i186.intr.ack_mask = 0x0001;
257            goto generate_int;
258         }
259      }
260 
261      /* check DMA interrupts */
262      for (IntNo = 0; IntNo < 2; IntNo++)
263         if ((i186.intr.dma[IntNo] & 0x0F) == Priority)
264         {
265            /* if we're already servicing something at this level, don't generate anything new */
266            if (i186.intr.in_service & (0x04 << IntNo))
267               return;
268 
269            /* if there's something pending, generate an interrupt */
270            if (i186.intr.request & (0x04 << IntNo))
271            {
272               new_vector = 0x0a + IntNo;
273 
274               /* set the clear mask and generate the int */
275               i186.intr.ack_mask = 0x0004 << IntNo;
276               goto generate_int;
277            }
278         }
279 
280        //logerror("Checking external ints\n");
281      /* check external interrupts */
282      for (IntNo = 0; IntNo < 4; IntNo++)
283         if ((i186.intr.ext[IntNo] & 0x0F) == Priority)
284         {
285                if (LOG_INTERRUPTS)
286                    logerror("Int%d priority=%d\n",IntNo,Priority);
287                 
288                /* if we're already servicing something at this level, don't generate anything new */
289            if (i186.intr.in_service & (0x10 << IntNo))
290               return;
291 
292            /* if there's something pending, generate an interrupt */
293            if (i186.intr.request & (0x10 << IntNo))
294            {
295               /* otherwise, generate an interrupt for this request */
296               new_vector = 0x0c + IntNo;
297 
298               /* set the clear mask and generate the int */
299               i186.intr.ack_mask = 0x0010 << IntNo;
300                    logerror("External int !\n");
301               goto generate_int;
302            }
303         }
304   }
305   return;
306 
307generate_int:
308   /* generate the appropriate interrupt */
309   i186.intr.poll_status = 0x8000 | new_vector;
310   if (!i186.intr.pending)
311      cputag_set_input_line(machine, MAINCPU_TAG, 0, ASSERT_LINE);
312   i186.intr.pending = 1;
313   cpuexec_trigger(machine, CPU_RESUME_TRIGGER);
314   if (LOG_OPTIMIZATION) logerror("  - trigger due to interrupt pending\n");
315   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time(machine)), new_vector);
316}
317 
318 
319static void handle_eoi(running_machine *machine,int data)
320{
321    int Priority;
322    int IntNo;
323 
324   /* specific case */
325   if (!(data & 0x8000))
326   {
327      /* turn off the appropriate in-service bit */
328      switch (data & 0x1f)
329      {
330         case 0x08:   i186.intr.in_service &= ~0x01;   break;
331         case 0x12:   i186.intr.in_service &= ~0x01;   break;
332         case 0x13:   i186.intr.in_service &= ~0x01;   break;
333         case 0x0a:   i186.intr.in_service &= ~0x04;   break;
334         case 0x0b:   i186.intr.in_service &= ~0x08;   break;
335         case 0x0c:   i186.intr.in_service &= ~0x10;   break;
336         case 0x0d:   i186.intr.in_service &= ~0x20;   break;
337         case 0x0e:   i186.intr.in_service &= ~0x40;   break;
338         case 0x0f:   i186.intr.in_service &= ~0x80;   break;
339         default:   logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), data & 0x1f);
340      }
341      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time(machine)), data & 0x1f);
342   }
343 
344   /* non-specific case */
345   else
346   {
347      /* loop over priorities */
348      for (Priority = 0; Priority <= 7; Priority++)
349      {
350         /* check for in-service timers */
351         if ((i186.intr.timer & 0x07) == Priority && (i186.intr.in_service & 0x01))
352         {
353            i186.intr.in_service &= ~0x01;
354            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time(machine)));
355            return;
356         }
357 
358         /* check for in-service DMA interrupts */
359         for (IntNo = 0; IntNo < 2; IntNo++)
360            if ((i186.intr.dma[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x04 << IntNo)))
361            {
362               i186.intr.in_service &= ~(0x04 << IntNo);
363               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
364               return;
365            }
366 
367         /* check external interrupts */
368         for (IntNo = 0; IntNo < 4; IntNo++)
369            if ((i186.intr.ext[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x10 << IntNo)))
370            {
371               i186.intr.in_service &= ~(0x10 << IntNo);
372               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
373               return;
374            }
375      }
376   }
377}
378 
379/* Trigger an external interupt, optionally supplying the vector to take */
380static void external_int(running_machine *machine, UINT16 intno, UINT8 vector)
381{
382   if (LOG_INTERRUPTS_EXT) logerror("generating external int %02X, vector %02X\n",intno,vector);
383 
384   // Only 4 external ints
385    if(intno>3)
386    {
387        logerror("external_int() invalid external interupt no : 0x%02X (can only be 0..3)\n",intno);
388        return;
389    }
390     
391    // Only set external vector if cascade mode enabled, only valid for
392    // int 0 & int 1
393    if (intno<2)
394    {
395        if(i186.intr.ext[intno] & EXTINT_CTRL_CASCADE)
396            i186.intr.ext_vector[intno]=vector;
397    }
398     
399    // Turn on the requested request bit and handle interrupt
400    i186.intr.request |= (0x010 << intno);
401    update_interrupt_state(machine);
402}
403 
404 
405/*************************************
406 *
407 *  80186 internal timers
408 *
409 *************************************/
410 
411static TIMER_CALLBACK(internal_timer_int)
412{
413   int which = param;
414   struct timer_state *t = &i186.timer[which];
415 
416   if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which);
417 
418   /* set the max count bit */
419   t->control |= 0x0020;
420 
421   /* request an interrupt */
422   if (t->control & 0x2000)
423   {
424      i186.intr.status |= 0x01 << which;
425      update_interrupt_state(machine);
426      if (LOG_TIMER) logerror("  Generating timer interrupt\n");
427   }
428 
429   /* if we're continuous, reset */
430   if (t->control & 0x0001)
431   {
432      int count = t->maxA ? t->maxA : 0x10000;
433      timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which);
434      if (LOG_TIMER) logerror("  Repriming interrupt\n");
435   }
436   else
437      timer_adjust_oneshot(t->int_timer, attotime_never, which);
438}
439 
440 
441static void internal_timer_sync(int which)
442{
443   struct timer_state *t = &i186.timer[which];
444 
445   /* if we have a timing timer running, adjust the count */
446   if (t->time_timer_active)
447   {
448      attotime current_time = timer_timeelapsed(t->time_timer);
449      int net_clocks = attotime_mul(attotime_sub(current_time, t->last_time),  2000000).seconds;
450      t->last_time = current_time;
451 
452      /* set the max count bit if we passed the max */
453      if ((int)t->count + net_clocks >= t->maxA)
454         t->control |= 0x0020;
455 
456      /* set the new count */
457      if (t->maxA != 0)
458         t->count = (t->count + net_clocks) % t->maxA;
459      else
460         t->count = t->count + net_clocks;
461   }
462}
463 
464 
465static void internal_timer_update(running_machine *machine,
466                          int which,
467                                  int new_count,
468                                  int new_maxA,
469                                  int new_maxB,
470                                  int new_control)
471{
472   struct timer_state *t = &i186.timer[which];
473   int update_int_timer = 0;
474 
475    logerror("internal_timer_update: %d, new_count=%d, new_maxA=%d, new_maxB=%d,new_control=%d",which,new_count,new_maxA,new_maxB,new_control);
476 
477   /* if we have a new count and we're on, update things */
478   if (new_count != -1)
479   {
480      if (t->control & 0x8000)
481      {
482         internal_timer_sync(which);
483         update_int_timer = 1;
484      }
485      t->count = new_count;
486   }
487 
488   /* if we have a new max and we're on, update things */
489   if (new_maxA != -1 && new_maxA != t->maxA)
490   {
491      if (t->control & 0x8000)
492      {
493         internal_timer_sync(which);
494         update_int_timer = 1;
495      }
496      t->maxA = new_maxA;
497      if (new_maxA == 0)
498      {
499               new_maxA = 0x10000;
500      }
501   }
502 
503   /* if we have a new max and we're on, update things */
504   if (new_maxB != -1 && new_maxB != t->maxB)
505   {
506      if (t->control & 0x8000)
507      {
508         internal_timer_sync(which);
509         update_int_timer = 1;
510      }
511 
512      t->maxB = new_maxB;
513 
514      if (new_maxB == 0)
515      {
516               new_maxB = 0x10000;
517            }
518      }
519     
520 
521   /* handle control changes */
522   if (new_control != -1)
523   {
524      int diff;
525 
526      /* merge back in the bits we don't modify */
527      new_control = (new_control & ~0x1fc0) | (t->control & 0x1fc0);
528 
529      /* handle the /INH bit */
530      if (!(new_control & 0x4000))
531         new_control = (new_control & ~0x8000) | (t->control & 0x8000);
532      new_control &= ~0x4000;
533 
534      /* check for control bits we don't handle */
535      diff = new_control ^ t->control;
536      if (diff & 0x001c)
537        logerror("%05X:ERROR! -unsupported timer mode %04X\n",
538            cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
539 
540      /* if we have real changes, update things */
541      if (diff != 0)
542      {
543 
544         /* if we're going off, make sure our timers are gone */
545         if ((diff & 0x8000) && !(new_control & 0x8000))
546         {
547            /* compute the final count */
548            internal_timer_sync(which);
549 
550            /* nuke the timer and force the interrupt timer to be recomputed */
551            timer_adjust_oneshot(t->time_timer, attotime_never, which);
552            t->time_timer_active = 0;
553            update_int_timer = 1;
554         }
555 
556         /* if we're going on, start the timers running */
557         else if ((diff & 0x8000) && (new_control & 0x8000))
558         {
559            /* start the timing */
560            timer_adjust_oneshot(t->time_timer, attotime_never, which);
561            t->time_timer_active = 1;
562            update_int_timer = 1;
563         }
564 
565         /* if something about the interrupt timer changed, force an update */
566         if (!(diff & 0x8000) && (diff & 0x2000))
567         {
568            internal_timer_sync(which);
569            update_int_timer = 1;
570         }
571      }
572 
573      /* set the new control register */
574      t->control = new_control;
575   }
576 
577   /* update the interrupt timer */
578      if (update_int_timer)
579      {
580            if ((t->control & 0x8000) && (t->control & 0x2000))
581            {
582              int diff = t->maxA - t->count;
583               if (diff <= 0)
584                  diff += 0x10000;
585               timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which);
586               if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which);
587            }
588            else
589            {
590              timer_adjust_oneshot(t->int_timer, attotime_never, which);
591      }
592   }
593}
594 
595 
596 
597/*************************************
598 *
599 *  80186 internal DMA
600 *
601 *************************************/
602 
603static TIMER_CALLBACK(dma_timer_callback)
604{
605   int which = param;
606   struct dma_state *d = &i186.dma[which];
607 
608   /* force an update and see if we're really done */
609   //stream_update(dma_stream, 0);
610 
611   /* complete the status update */
612   d->control &= ~0x0002;
613   d->source += d->count;
614   d->count = 0;
615 
616   /* check for interrupt generation */
617   if (d->control & 0x0100)
618   {
619      if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source);
620      i186.intr.request |= 0x04 << which;
621      update_interrupt_state(machine);
622   }
623}
624 
625 
626static void update_dma_control(running_machine *machine, int which, int new_control)
627{
628   struct dma_state *d = &i186.dma[which];
629   int diff;
630 
631   /* handle the CHG bit */
632   if (!(new_control & CHG_NOCHG))
633     new_control = (new_control & ~ST_STOP) | (d->control & ST_STOP);
634   new_control &= ~CHG_NOCHG;
635 
636   /* check for control bits we don't handle */
637   diff = new_control ^ d->control;
638   if (diff & 0x6811)
639     logerror("%05X:ERROR! - unsupported DMA mode %04X\n",
640         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
641 
642   /* if we're going live, set a timer */
643   if ((diff & 0x0002) && (new_control & 0x0002))
644   {
645      /* make sure the parameters meet our expectations */
646      if ((new_control & 0xfe00) != 0x1600)
647      {
648         logerror("Unexpected DMA control %02X\n", new_control);
649      }
650      else if (/*!is_redline &&*/ ((d->dest & 1) || (d->dest & 0x3f) > 0x0b))
651      {
652         logerror("Unexpected DMA destination %02X\n", d->dest);
653      }
654      else if (/*is_redline && */ (d->dest & 0xf000) != 0x4000 && (d->dest & 0xf000) != 0x5000)
655      {
656         logerror("Unexpected DMA destination %02X\n", d->dest);
657      }
658 
659      /* otherwise, set a timer */
660      else
661      {
662//          int count = d->count;
663 
664         /* adjust for redline racer */
665            // int dacnum = (d->dest & 0x3f) / 2;
666 
667         if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
668 
669         d->finished = 0;
670/*          timer_adjust_oneshot(d->finish_timer,
671         ATTOTIME_IN_HZ(dac[dacnum].frequency) * (double)count, which);*/
672      }
673   }
674 
675   /* set the new control register */
676   d->control = new_control;
677}
678 
679static void drq_callback(running_machine *machine, int which)
680{
681    struct dma_state *dma = &i186.dma[which];
682   const address_space *memory_space   = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_PROGRAM);
683    const address_space *io_space       = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_IO);
684     
685    const address_space *src_space;
686    const address_space *dest_space;
687     
688    UINT16  dma_word;
689    UINT8   dma_byte;
690    UINT8   incdec_size;
691 
692    if (LOG_DMA)
693        logerror("Control=%04X, src=%05X, dest=%05X, count=%04X\n",dma->control,dma->source,dma->dest,dma->count);
694 
695    if(!(dma->control & ST_STOP))
696    {
697        logerror("%05X:ERROR! - drq%d with dma channel stopped\n",
698         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), which);
699           
700        return;
701    }
702 
703 
704    if(dma->control & DEST_MIO)
705    {
706        dest_space=memory_space;
707        logerror("dest=memory\n");
708    }
709    else
710    {
711        dest_space=io_space;
712        logerror("dest=I/O\n");
713    }
714     
715    if(dma->control & SRC_MIO)
716    {
717        src_space=memory_space;
718        logerror("src=memory\n");
719    }
720    else
721    {
722        src_space=io_space;
723        logerror("src=I/O\n");
724    }
725     
726    // Do the transfer
727    if(dma->control & BYTE_WORD)
728    {
729        //logerror("moving word\n");
730        dma_word=memory_read_word(src_space,dma->source);
731        memory_write_word(dest_space,dma->dest,dma_word);
732        incdec_size=2;
733    }
734    else
735    {
736        //logerror("moving byte\n");
737        dma_byte=memory_read_byte(src_space,dma->source);
738        memory_write_byte(dest_space,dma->dest,dma_byte);
739        incdec_size=1;
740    }
741     
742    // Increment or Decrement destination ans source pointers as needed
743    //logerror("incrementing destination\n");
744    switch (dma->control & DEST_INCDEC_MASK)
745    {
746        case DEST_DECREMENT     : dma->dest -= incdec_size;
747        case DEST_INCREMENT     : dma->dest += incdec_size;
748    }
749     
750    //logerror("incrementing source\n");
751    switch (dma->control & SRC_INCDEC_MASK)
752    {
753        case SRC_DECREMENT     : dma->source -= incdec_size;
754        case SRC_INCREMENT     : dma->source += incdec_size;
755    }
756     
757    // decrement count
758    dma->count -= 1;
759     
760    //logerror("Check term on zero\n");
761    // Terminate if count is zero, and terminate flag set
762    if((dma->control & TERMINATE_ON_ZERO) && (dma->count==0))
763    {
764        dma->control &= ~ST_STOP;
765        logerror("DMA terminated\n");
766    }
767     
768    //logerror("Check int on zero\n");
769    // Interrupt if count is zero, and interrupt flag set
770    if((dma->control & INTERRUPT_ON_ZERO) && (dma->count==0))
771    {
772      if (LOG_DMA) logerror("DMA%d - requesting interrupt: count = %04X, source = %04X\n", which, dma->count, dma->source);
773      i186.intr.request |= 0x04 << which;
774      update_interrupt_state(machine);       
775    }
776    logerror("DMA callback done\n");
777}
778 
779/*-------------------------------------------------------------------------*/
780/* Name: rmnimbus                                                            */
781/* Desc: CPU - Initialize the 80186 CPU                                    */
782/*-------------------------------------------------------------------------*/
783static void nimbus_cpu_init(running_machine *machine)
784{
785 
786    logerror("Machine reset\n");
787     
788   /* create timers here so they stick around */
789   i186.timer[0].int_timer = timer_alloc(machine, internal_timer_int, NULL);
790   i186.timer[1].int_timer = timer_alloc(machine, internal_timer_int, NULL);
791   i186.timer[2].int_timer = timer_alloc(machine, internal_timer_int, NULL);
792   i186.timer[0].time_timer = timer_alloc(machine, NULL, NULL);
793   i186.timer[1].time_timer = timer_alloc(machine, NULL, NULL);
794   i186.timer[2].time_timer = timer_alloc(machine, NULL, NULL);
795   i186.dma[0].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
796   i186.dma[1].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
797}
798 
799static void nimbus_cpu_reset(running_machine *machine)
800{
801      /* reset the interrupt state */
802   i186.intr.priority_mask       = 0x0007;
803   i186.intr.timer          = 0x000f;
804   i186.intr.dma[0]         = 0x000f;
805   i186.intr.dma[1]         = 0x000f;
806   i186.intr.ext[0]         = 0x000f;
807   i186.intr.ext[1]         = 0x000f;
808   i186.intr.ext[2]         = 0x000f;
809   i186.intr.ext[3]         = 0x000f;
810    i186.intr.in_service        = 0x0000;
811     
812    /* External vectors by default to internal int 0/1 vectors */
813    i186.intr.ext_vector[0]      = 0x000C;
814   i186.intr.ext_vector[1]      = 0x000D;
815   
816    i186.intr.pending           = 0x0000;
817   i186.intr.ack_mask          = 0x0000;
818   i186.intr.request           = 0x0000;
819   i186.intr.status            = 0x0000;
820   i186.intr.poll_status       = 0x0000;
821   
822    logerror("CPU reset done\n");
823}
824 
825READ16_HANDLER( i186_internal_port_r )
826{
827   int temp, which;
828 
829   switch (offset)
830   {
831      case 0x11:
832         logerror("%05X:ERROR - read from 80186 EOI\n", cpu_get_pc(space->cpu));
833         break;
834 
835      case 0x12:
836         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll\n", cpu_get_pc(space->cpu));
837         if (i186.intr.poll_status & 0x8000)
838            int_callback(cputag_get_cpu(space->machine, MAINCPU_TAG), 0);
839         return i186.intr.poll_status;
840 
841      case 0x13:
842         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll status\n", cpu_get_pc(space->cpu));
843         return i186.intr.poll_status;
844 
845      case 0x14:
846         if (LOG_PORTS) logerror("%05X:read 80186 interrupt mask\n", cpu_get_pc(space->cpu));
847         temp  = (i186.intr.timer  >> 3) & 0x01;
848         temp |= (i186.intr.dma[0] >> 1) & 0x04;
849         temp |= (i186.intr.dma[1] >> 0) & 0x08;
850         temp |= (i186.intr.ext[0] << 1) & 0x10;
851         temp |= (i186.intr.ext[1] << 2) & 0x20;
852         temp |= (i186.intr.ext[2] << 3) & 0x40;
853         temp |= (i186.intr.ext[3] << 4) & 0x80;
854         return temp;
855 
856      case 0x15:
857         if (LOG_PORTS) logerror("%05X:read 80186 interrupt priority mask\n", cpu_get_pc(space->cpu));
858         return i186.intr.priority_mask;
859 
860      case 0x16:
861         if (LOG_PORTS) logerror("%05X:read 80186 interrupt in-service\n", cpu_get_pc(space->cpu));
862         return i186.intr.in_service;
863 
864      case 0x17:
865         if (LOG_PORTS) logerror("%05X:read 80186 interrupt request\n", cpu_get_pc(space->cpu));
866         temp = i186.intr.request & ~0x0001;
867         if (i186.intr.status & 0x0007)
868            temp |= 1;
869         return temp;
870 
871      case 0x18:
872         if (LOG_PORTS) logerror("%05X:read 80186 interrupt status\n", cpu_get_pc(space->cpu));
873         return i186.intr.status;
874 
875      case 0x19:
876         if (LOG_PORTS) logerror("%05X:read 80186 timer interrupt control\n", cpu_get_pc(space->cpu));
877         return i186.intr.timer;
878 
879      case 0x1a:
880         if (LOG_PORTS) logerror("%05X:read 80186 DMA 0 interrupt control\n", cpu_get_pc(space->cpu));
881         return i186.intr.dma[0];
882 
883      case 0x1b:
884         if (LOG_PORTS) logerror("%05X:read 80186 DMA 1 interrupt control\n", cpu_get_pc(space->cpu));
885         return i186.intr.dma[1];
886 
887      case 0x1c:
888         if (LOG_PORTS) logerror("%05X:read 80186 INT 0 interrupt control\n", cpu_get_pc(space->cpu));
889         return i186.intr.ext[0];
890 
891      case 0x1d:
892         if (LOG_PORTS) logerror("%05X:read 80186 INT 1 interrupt control\n", cpu_get_pc(space->cpu));
893         return i186.intr.ext[1];
894 
895      case 0x1e:
896         if (LOG_PORTS) logerror("%05X:read 80186 INT 2 interrupt control\n", cpu_get_pc(space->cpu));
897         return i186.intr.ext[2];
898 
899      case 0x1f:
900         if (LOG_PORTS) logerror("%05X:read 80186 INT 3 interrupt control\n", cpu_get_pc(space->cpu));
901         return i186.intr.ext[3];
902 
903      case 0x28:
904      case 0x2c:
905      case 0x30:
906         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d count\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4);
907         which = (offset - 0x28) / 4;
908         if (!(offset & 1))
909            internal_timer_sync(which);
910         return i186.timer[which].count;
911 
912      case 0x29:
913      case 0x2d:
914      case 0x31:
915         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d max A\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4);
916         which = (offset - 0x29) / 4;
917         return i186.timer[which].maxA;
918 
919      case 0x2a:
920      case 0x2e:
921         logerror("%05X:read 80186 Timer %d max B\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4);
922         which = (offset - 0x2a) / 4;
923         return i186.timer[which].maxB;
924 
925      case 0x2b:
926      case 0x2f:
927      case 0x33:
928         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d control\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4);
929         which = (offset - 0x2b) / 4;
930         return i186.timer[which].control;
931 
932      case 0x50:
933         if (LOG_PORTS) logerror("%05X:read 80186 upper chip select\n", cpu_get_pc(space->cpu));
934         return i186.mem.upper;
935 
936      case 0x51:
937         if (LOG_PORTS) logerror("%05X:read 80186 lower chip select\n", cpu_get_pc(space->cpu));
938         return i186.mem.lower;
939 
940      case 0x52:
941         if (LOG_PORTS) logerror("%05X:read 80186 peripheral chip select\n", cpu_get_pc(space->cpu));
942         return i186.mem.peripheral;
943 
944      case 0x53:
945         if (LOG_PORTS) logerror("%05X:read 80186 middle chip select\n", cpu_get_pc(space->cpu));
946         return i186.mem.middle;
947 
948      case 0x54:
949         if (LOG_PORTS) logerror("%05X:read 80186 middle P chip select\n", cpu_get_pc(space->cpu));
950         return i186.mem.middle_size;
951 
952      case 0x60:
953      case 0x68:
954         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower source address\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8);
955         which = (offset - 0x60) / 8;
956//          stream_update(dma_stream, 0);
957         return i186.dma[which].source;
958 
959      case 0x61:
960      case 0x69:
961         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper source address\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8);
962         which = (offset - 0x61) / 8;
963//          stream_update(dma_stream, 0);
964         return i186.dma[which].source >> 16;
965 
966      case 0x62:
967      case 0x6a:
968         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower dest address\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8);
969         which = (offset - 0x62) / 8;
970//          stream_update(dma_stream, 0);
971         return i186.dma[which].dest;
972 
973      case 0x63:
974      case 0x6b:
975         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper dest address\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8);
976         which = (offset - 0x63) / 8;
977//          stream_update(dma_stream, 0);
978         return i186.dma[which].dest >> 16;
979 
980      case 0x64:
981      case 0x6c:
982         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d transfer count\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8);
983         which = (offset - 0x64) / 8;
984//          stream_update(dma_stream, 0);
985         return i186.dma[which].count;
986 
987      case 0x65:
988      case 0x6d:
989         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d control\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8);
990         which = (offset - 0x65) / 8;
991//          stream_update(dma_stream, 0);
992         return i186.dma[which].control;
993 
994      default:
995         logerror("%05X:read 80186 port %02X\n", cpu_get_pc(space->cpu), offset);
996         break;
997   }
998   return 0x00;
999}
1000 
1001/*************************************
1002 *
1003 *  80186 internal I/O writes
1004 *
1005 *************************************/
1006 
1007WRITE16_HANDLER( i186_internal_port_w )
1008{
1009   int temp, which, data16 = data;
1010 
1011   switch (offset)
1012   {
1013      case 0x11:
1014         if (LOG_PORTS) logerror("%05X:80186 EOI = %04X\n", cpu_get_pc(space->cpu), data16);
1015         handle_eoi(space->machine,0x8000);
1016         update_interrupt_state(space->machine);
1017         break;
1018 
1019      case 0x12:
1020         logerror("%05X:ERROR - write to 80186 interrupt poll = %04X\n", cpu_get_pc(space->cpu), data16);
1021         break;
1022 
1023      case 0x13:
1024         logerror("%05X:ERROR - write to 80186 interrupt poll status = %04X\n", cpu_get_pc(space->cpu), data16);
1025         break;
1026 
1027      case 0x14:
1028         if (LOG_PORTS) logerror("%05X:80186 interrupt mask = %04X\n", cpu_get_pc(space->cpu), data16);
1029         i186.intr.timer  = (i186.intr.timer  & ~0x08) | ((data16 << 3) & 0x08);
1030         i186.intr.dma[0] = (i186.intr.dma[0] & ~0x08) | ((data16 << 1) & 0x08);
1031         i186.intr.dma[1] = (i186.intr.dma[1] & ~0x08) | ((data16 << 0) & 0x08);
1032         i186.intr.ext[0] = (i186.intr.ext[0] & ~0x08) | ((data16 >> 1) & 0x08);
1033         i186.intr.ext[1] = (i186.intr.ext[1] & ~0x08) | ((data16 >> 2) & 0x08);
1034         i186.intr.ext[2] = (i186.intr.ext[2] & ~0x08) | ((data16 >> 3) & 0x08);
1035         i186.intr.ext[3] = (i186.intr.ext[3] & ~0x08) | ((data16 >> 4) & 0x08);
1036         update_interrupt_state(space->machine);
1037         break;
1038 
1039      case 0x15:
1040         if (LOG_PORTS) logerror("%05X:80186 interrupt priority mask = %04X\n", cpu_get_pc(space->cpu), data16);
1041         i186.intr.priority_mask = data16 & 0x0007;
1042         update_interrupt_state(space->machine);
1043         break;
1044 
1045      case 0x16:
1046         if (LOG_PORTS) logerror("%05X:80186 interrupt in-service = %04X\n", cpu_get_pc(space->cpu), data16);
1047         i186.intr.in_service = data16 & 0x00ff;
1048         update_interrupt_state(space->machine);
1049         break;
1050 
1051      case 0x17:
1052         if (LOG_PORTS) logerror("%05X:80186 interrupt request = %04X\n", cpu_get_pc(space->cpu), data16);
1053         i186.intr.request = (i186.intr.request & ~0x00c0) | (data16 & 0x00c0);
1054         update_interrupt_state(space->machine);
1055         break;
1056 
1057      case 0x18:
1058         if (LOG_PORTS) logerror("%05X:WARNING - wrote to 80186 interrupt status = %04X\n", cpu_get_pc(space->cpu), data16);
1059         i186.intr.status = (i186.intr.status & ~0x8007) | (data16 & 0x8007);
1060         update_interrupt_state(space->machine);
1061         break;
1062 
1063      case 0x19:
1064         if (LOG_PORTS) logerror("%05X:80186 timer interrupt contol = %04X\n", cpu_get_pc(space->cpu), data16);
1065         i186.intr.timer = data16 & 0x000f;
1066         break;
1067 
1068      case 0x1a:
1069         if (LOG_PORTS) logerror("%05X:80186 DMA 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1070         i186.intr.dma[0] = data16 & 0x000f;
1071         break;
1072 
1073      case 0x1b:
1074         if (LOG_PORTS) logerror("%05X:80186 DMA 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1075         i186.intr.dma[1] = data16 & 0x000f;
1076         break;
1077 
1078      case 0x1c:
1079         if (LOG_PORTS) logerror("%05X:80186 INT 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1080         i186.intr.ext[0] = data16 & 0x007f;
1081         break;
1082 
1083      case 0x1d:
1084         if (LOG_PORTS) logerror("%05X:80186 INT 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1085         i186.intr.ext[1] = data16 & 0x007f;
1086         break;
1087 
1088      case 0x1e:
1089         if (LOG_PORTS) logerror("%05X:80186 INT 2 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1090         i186.intr.ext[2] = data16 & 0x001f;
1091         break;
1092 
1093      case 0x1f:
1094         if (LOG_PORTS) logerror("%05X:80186 INT 3 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1095         i186.intr.ext[3] = data16 & 0x001f;
1096         break;
1097 
1098      case 0x28:
1099      case 0x2c:
1100      case 0x30:
1101         if (LOG_PORTS) logerror("%05X:80186 Timer %d count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4, data16);
1102         which = (offset - 0x28) / 4;
1103         internal_timer_update(space->machine,which, data16, -1, -1, -1);
1104         break;
1105 
1106      case 0x29:
1107      case 0x2d:
1108      case 0x31:
1109         if (LOG_PORTS) logerror("%05X:80186 Timer %d max A = %04X\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4, data16);
1110         which = (offset - 0x29) / 4;
1111         internal_timer_update(space->machine,which, -1, data16, -1, -1);
1112         break;
1113 
1114      case 0x2a:
1115      case 0x2e:
1116         if (LOG_PORTS) logerror("%05X:80186 Timer %d max B = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4, data16);
1117         which = (offset - 0x2a) / 4;
1118         internal_timer_update(space->machine,which, -1, -1, data16, -1);
1119         break;
1120 
1121      case 0x2b:
1122      case 0x2f:
1123      case 0x33:
1124         if (LOG_PORTS) logerror("%05X:80186 Timer %d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4, data16);
1125         which = (offset - 0x2b) / 4;
1126         internal_timer_update(space->machine,which, -1, -1, -1, data16);
1127         break;
1128 
1129      case 0x50:
1130         if (LOG_PORTS) logerror("%05X:80186 upper chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1131         i186.mem.upper = data16 | 0xc038;
1132         break;
1133 
1134      case 0x51:
1135         if (LOG_PORTS) logerror("%05X:80186 lower chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1136         i186.mem.lower = (data16 & 0x3fff) | 0x0038; printf("%X",i186.mem.lower);
1137         break;
1138 
1139      case 0x52:
1140         if (LOG_PORTS) logerror("%05X:80186 peripheral chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1141         i186.mem.peripheral = data16 | 0x0038;
1142         break;
1143 
1144      case 0x53:
1145         if (LOG_PORTS) logerror("%05X:80186 middle chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1146         i186.mem.middle = data16 | 0x01f8;
1147         break;
1148 
1149      case 0x54:
1150         if (LOG_PORTS) logerror("%05X:80186 middle P chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1151         i186.mem.middle_size = data16 | 0x8038;
1152 
1153         temp = (i186.mem.peripheral & 0xffc0) << 4;
1154         if (i186.mem.middle_size & 0x0040)
1155         {
1156//              install_mem_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1157//              install_mem_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1158         }
1159         else
1160         {
1161            temp &= 0xffff;
1162//              install_port_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1163//              install_port_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1164         }
1165 
1166         /* we need to do this at a time when the I86 context is swapped in */
1167         /* this register is generally set once at startup and never again, so it's a good */
1168         /* time to set it up */
1169         cpu_set_irq_callback(space->cpu, int_callback);
1170         break;
1171 
1172      case 0x60:
1173      case 0x68:
1174         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8, data16);
1175         which = (offset - 0x60) / 8;
1176//          stream_update(dma_stream, 0);
1177         i186.dma[which].source = (i186.dma[which].source & ~0x0ffff) | (data16 & 0x0ffff);
1178         break;
1179 
1180      case 0x61:
1181      case 0x69:
1182         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8, data16);
1183         which = (offset - 0x61) / 8;
1184//          stream_update(dma_stream, 0);
1185         i186.dma[which].source = (i186.dma[which].source & ~0xf0000) | ((data16 << 16) & 0xf0000);
1186         break;
1187 
1188      case 0x62:
1189      case 0x6a:
1190         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8, data16);
1191         which = (offset - 0x62) / 8;
1192//          stream_update(dma_stream, 0);
1193         i186.dma[which].dest = (i186.dma[which].dest & ~0x0ffff) | (data16 & 0x0ffff);
1194         break;
1195 
1196      case 0x63:
1197      case 0x6b:
1198         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8, data16);
1199         which = (offset - 0x63) / 8;
1200//          stream_update(dma_stream, 0);
1201         i186.dma[which].dest = (i186.dma[which].dest & ~0xf0000) | ((data16 << 16) & 0xf0000);
1202         break;
1203 
1204      case 0x64:
1205      case 0x6c:
1206         if (LOG_PORTS) logerror("%05X:80186 DMA%d transfer count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8, data16);
1207         which = (offset - 0x64) / 8;
1208//          stream_update(dma_stream, 0);
1209         i186.dma[which].count = data16;
1210         break;
1211 
1212      case 0x65:
1213      case 0x6d:
1214         if (LOG_PORTS) logerror("%05X:80186 DMA%d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8, data16);
1215         which = (offset - 0x65) / 8;
1216//          stream_update(dma_stream, 0);
1217         update_dma_control(space->machine, which, data16);
1218         break;
1219 
1220      case 0x7f:
1221         if (LOG_PORTS) logerror("%05X:80186 relocation register = %04X\n", cpu_get_pc(space->cpu), data16);
1222 
1223         /* we assume here there that this doesn't happen too often */
1224         /* plus, we can't really remove the old memory range, so we also assume that it's */
1225         /* okay to leave us mapped where we were */
1226         temp = (data16 & 0x0fff) << 8;
1227         if (data16 & 0x1000)
1228         {
1229            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1230            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1231         }
1232         else
1233         {
1234            temp &= 0xffff;
1235            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1236            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1237         }
1238/*          popmessage("Sound CPU reset");*/
1239         break;
1240 
1241      default:
1242         logerror("%05X:80186 port %02X = %04X\n", cpu_get_pc(space->cpu), offset, data16);
1243         break;
1244   }
1245}
1246 
1247MACHINE_RESET(nimbus)
1248{
1249   /* CPU */
1250   nimbus_cpu_reset(machine); 
1251    fdc_reset();
1252}
1253 
1254DRIVER_INIT(nimbus)
1255{
1256}
1257 
1258MACHINE_START( nimbus )
1259{
1260    /* init cpu */
1261    nimbus_cpu_init(machine);
1262     
1263   /* setup debug commands */
1264   if (machine->debug_flags & DEBUG_FLAG_ENABLED)
1265   {
1266      debug_console_register_command(machine, "nimbus_irq", CMDFLAG_NONE, 0, 0, 1, execute_debug_irq);
1267        debug_console_register_command(machine, "nimbus_intmasks", CMDFLAG_NONE, 0, 0, 0, execute_debug_intmasks);
1268        debug_console_register_command(machine, "nimbus_key", CMDFLAG_NONE, 0, 0, 1, execute_debug_key);
1269   
1270         
1271        /* set up the instruction hook */
1272        debug_cpu_set_instruction_hook(cputag_get_cpu(machine, MAINCPU_TAG), instruction_hook);
1273     
1274    }
1275}
1276 
1277static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[])
1278{
1279    int IntNo;
1280    int IntMask;
1281     
1282    if(params>0)
1283    {   
1284        sscanf(param[0],"%d",&IntNo);
1285         
1286        IntMask=0x0000;
1287     
1288        switch (IntNo)
1289        {
1290            case 0  : IntMask=0x010; break;
1291            case 1  : IntMask=0x020; break;
1292            case 2  : IntMask=0x040; break;
1293            case 3  : IntMask=0x080; break;
1294        }
1295         
1296        i186.intr.request |= IntMask;
1297        update_interrupt_state(machine);
1298         
1299        debug_console_printf(machine,"triggering IRQ%d, IntMask=%4.4X, i186.intr.request=%4.4X\n",IntNo,IntMask,i186.intr.request);
1300         
1301//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, HOLD_LINE );
1302//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, CLEAR_LINE );
1303         
1304    }
1305    else
1306    {
1307        debug_console_printf(machine,"Error, you must supply an intno to trigger\n");
1308    }
1309   
1310     
1311}
1312 
1313 
1314static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[])
1315{
1316    int IntNo;
1317     
1318     
1319    debug_console_printf(machine,"i186.intr.priority_mask=%4X\n",i186.intr.priority_mask);
1320    for(IntNo=0; IntNo<4; IntNo++)
1321    {
1322        debug_console_printf(machine,"extInt%d mask=%4X\n",IntNo,i186.intr.ext[IntNo]);
1323    }
1324     
1325    debug_console_printf(machine,"i186.intr.request   = %04X\n",i186.intr.request);
1326    debug_console_printf(machine,"i186.intr.ack_mask  = %04X\n",i186.intr.ack_mask);
1327    debug_console_printf(machine,"i186.intr.in_service= %04X\n",i186.intr.in_service);
1328}
1329 
1330static void execute_debug_key(running_machine *machine, int ref, int params, const char *param[])
1331{
1332    int Key;
1333     
1334    if(params>0)
1335    {   
1336        sscanf(param[0],"%d",&Key);
1337         
1338        nextkey=Key;
1339    }
1340    else
1341    {
1342        debug_console_printf(machine,"Error, you must supply a keycode\n");
1343    }
1344   
1345     
1346}
1347 
1348 
1349/*-----------------------------------------------
1350    instruction_hook - per-instruction hook
1351-----------------------------------------------*/
1352 
1353static int instruction_hook(const device_config *device, offs_t curpc)
1354{
1355    const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
1356    UINT8               *addr_ptr;
1357     
1358    addr_ptr = memory_get_read_ptr(space,curpc);
1359         
1360    if ((addr_ptr !=NULL) && (addr_ptr[0]==0xCD) && (addr_ptr[1]==0xF0))
1361        decode_subbios(device,curpc);
1362     
1363    return 0;
1364}
1365 
1366#define set_type(type_name)     sprintf(type_str,type_name)
1367#define set_drv(drv_name)       sprintf(drv_str,drv_name)
1368#define set_func(func_name)     sprintf(func_str,func_name)
1369 
1370static void decode_subbios(const device_config *device,offs_t pc)
1371{
1372    char    type_str[80];
1373    char    drv_str[80];
1374    char    func_str[80];
1375     
1376    void (*dump_dssi)(const device_config *,UINT16, UINT16) = NULL;
1377 
1378    const device_config *cpu = cputag_get_cpu(device->machine,MAINCPU_TAG);
1379     
1380    UINT16  ax = cpu_get_reg(cpu,I8086_AX);
1381    UINT16  bx = cpu_get_reg(cpu,I8086_BX);
1382    UINT16  cx = cpu_get_reg(cpu,I8086_CX);
1383    UINT16  ds = cpu_get_reg(cpu,I8086_DS);
1384    UINT16  si = cpu_get_reg(cpu,I8086_SI);
1385     
1386    logerror("=======================================================================\n");
1387    logerror("Sub-bios call at %08X, AX=%04X, BX=%04X, CX=%04X, DS:SI=%04X:%04X\n",pc,ax,bx,cx,ds,si);
1388 
1389    set_type("invalid");
1390    set_drv("invalid");
1391    set_func("invalid");
1392     
1393 
1394    switch (cx)
1395    {
1396        case 0   : 
1397        {
1398            set_type("t_mummu");
1399            set_drv("d_mummu");
1400             
1401            switch (ax)
1402            {
1403                case 0  : set_func("f_get_version_number"); break;
1404                case 1  : set_func("f_add_type_code"); break;
1405                case 2  : set_func("f_del_typc_code"); break;
1406                case 3  : set_func("f_get_TCB"); break;
1407                case 4  : set_func("f_add_driver_cdoe"); break;
1408                case 5  : set_func("f_del_driver_code"); break;
1409                case 6  : set_func("f_get_DCB"); break;
1410                case 7  : set_func("f_get_copyright"); break;
1411            }
1412        }; break;
1413         
1414        case 1   : 
1415        {
1416            set_type("t_character");
1417            set_drv("d_printer");
1418             
1419            switch(ax)
1420            {
1421                case 0  : set_func("f_get_version_number"); break;
1422                case 1  : set_func("f_get_output_status"); break;
1423                case 2  : set_func("f_output_character"); break;
1424                case 3  : set_func("f_get_input_status"); break;
1425                case 4  : set_func("f_get_and_remove"); break;
1426                case 5  : set_func("f_get_no_remove"); break;
1427                case 6  : set_func("f_get_last_and_remove"); break;
1428                case 7  : set_func("f_get_last_no_remove"); break;
1429                case 8  : set_func("f_set_IO_parameters"); break;
1430            }
1431        }; break;
1432         
1433        case 2   : 
1434        {
1435            set_type("t_disk");
1436             
1437            switch(bx)
1438            {
1439                case 0  : set_drv("d_floppy"); break;
1440                case 1  : set_drv("d_winchester"); break;
1441                case 2  : set_drv("d_tape"); break;
1442                case 3  : set_drv("d_rompack"); break;
1443                case 4  : set_drv("d_eeprom"); break;
1444            }
1445             
1446            switch(ax)
1447            {
1448                case 0  : set_func("f_get_version_number"); break;             
1449                case 1  : set_func("f_initialise_unit"); break;
1450                case 2  : set_func("f_pseudo_init_unit"); break;
1451                case 3  : set_func("f_get_device_status"); break;
1452                case 4  : set_func("f_read_n_sectors"); break;
1453                case 5  : set_func("f_write_n_sectors"); break;
1454                case 6  : set_func("f_verify_n_sectors"); break;
1455                case 7  : set_func("f_media_check"); break;
1456                case 8  : set_func("f_recalibrate"); break;
1457                case 9  : set_func("f_motors_off"); break;
1458            }
1459             
1460        }; break;
1461         
1462        case 3   : 
1463        {
1464            set_type("t_piconet");
1465            switch(ax)
1466            {
1467                case 0  : set_func("f_get_version_number"); break;             
1468            }
1469        }; break;
1470         
1471        case 4   : 
1472        {
1473            set_type("t_tick");
1474            set_drv("d_tick");
1475             
1476            switch(ax)
1477            {
1478                case 0  : set_func("f_get_version_number"); break; 
1479                case 1  : set_func("f_ticks_per_second"); break; 
1480                case 2  : set_func("f_link_tick_routine"); break; 
1481                case 3  : set_func("f_unlink_tick_routine"); break;             
1482            }
1483        }; break;
1484         
1485        case 5   : 
1486        {
1487            set_type("t_graphics_input");
1488            switch(ax)
1489            {
1490                case 0  : set_func("f_get_version_number"); break;             
1491            }
1492        }; break;
1493         
1494        case 6   : 
1495        {
1496            set_type("t_graphics_output");
1497            set_drv("d_ngc_screen");
1498 
1499            switch(ax)
1500            {
1501                case 0  : set_func("f_get_version_number");                 break; 
1502                case 1  : set_func("f_graphics_output_cold_start");         break; 
1503                case 2  : set_func("f_graphics_output_warm_start");         break; 
1504                case 3  : set_func("f_graphics_output_off");                break; 
1505                case 4  : set_func("f_reinit_graphics_output");             break; 
1506                case 5  : set_func("f_polymarker");                         break; 
1507                case 6  : set_func("f_polyline");                           break; 
1508                case 7  : set_func("f_fill_area"); dump_dssi=&decode_dssi_f_fill_area; break; 
1509                case 8  : set_func("f_flood_fill_area"); break; 
1510                case 9  : set_func("f_plot_character_string"); dump_dssi=&decode_dssi_f_plot_character_string; break; 
1511                case 10 : set_func("f_define_graphics_clipping_area"); break; 
1512                case 11 : set_func("f_enquire_clipping_area_limits"); break; 
1513                case 12 : set_func("f_select_graphics_clipping_area"); break; 
1514                case 13 : set_func("f_enq_selctd_graphics_clip_area"); break; 
1515                case 14 : set_func("f_set_clt_element"); break; 
1516                case 15 : set_func("f_enquire_clt_element"); break; 
1517                case 16 : set_func("f_set_new_clt"); dump_dssi=&decode_dssi_f_set_new_clt; break; 
1518                case 17 : set_func("f_enquire_clt_contents"); break; 
1519                case 18 : set_func("f_define_dithering_pattern"); break; 
1520                case 19 : set_func("f_enquire_dithering_pattern"); break; 
1521                case 20 : set_func("f_draw_sprite"); break; 
1522                case 21 : set_func("f_move_sprite"); break; 
1523                case 22 : set_func("f_erase_sprite"); break; 
1524                case 23 : set_func("f_read_pixel"); break; 
1525                case 24 : set_func("f_read_to_limit"); break; 
1526                case 25 : set_func("f_read_area_pixel"); break; 
1527                case 26 : set_func("f_write_area_pixel"); break; 
1528                case 27 : set_func("f_copy_area_pixel"); break; 
1529 
1530                case 29 : set_func("f_read_area_word"); break; 
1531                case 30 : set_func("f_write_area_word"); break; 
1532                case 31 : set_func("f_copy_area_word"); break; 
1533                case 32 : set_func("f_swap_area_word"); break; 
1534                case 33 : set_func("f_set_border_colour"); break; 
1535                case 34 : set_func("f_enquire_border_colour"); break; 
1536                case 35 : set_func("f_enquire_miscellaneous_data"); break; 
1537                case 36  : set_func("f_circle"); break; 
1538 
1539                case 38 : set_func("f_arc_of_ellipse"); break; 
1540                case 39 : set_func("f_isin"); break; 
1541                case 40 : set_func("f_icos"); break; 
1542                case 41 : set_func("f_define_hatching_pattern"); break; 
1543                case 42 : set_func("f_enquire_hatching_pattern"); break; 
1544                case 43 : set_func("f_enquire_display_line"); break; 
1545                case 44 : set_func("f_plonk_logo"); break; 
1546            }
1547        }; break;
1548         
1549        case 7   : 
1550        {
1551            set_type("t_zend");
1552            switch(ax)
1553            {
1554                case 0  : set_func("f_get_version_number"); break;             
1555            }
1556        }; break;
1557         
1558        case 8   : 
1559        {
1560            set_type("t_zep");
1561            switch(ax)
1562            {
1563                case 0  : set_func("f_get_version_number"); break;             
1564            }
1565        }; break;
1566         
1567        case 9   : 
1568        {
1569            set_type("t_raw_console");
1570             
1571            switch(bx)
1572            {
1573                case 0  : 
1574                {
1575                    set_drv("d_screen");
1576             
1577                    switch(ax)
1578                    {
1579                        case 0  : set_func("f_get_version_number"); break;             
1580                        case 1  : set_func("f_plonk_char"); break;
1581                        case 2  : set_func("f_plonk_cursor"); break;
1582                        case 3  : set_func("f_kill_cursor"); break;
1583                        case 4  : set_func("f_scroll"); break;
1584                        case 5  : set_func("f_width"); break;
1585                        case 6  : set_func("f_get_char_set"); break;
1586                        case 7  : set_func("f_set_char_set"); break;
1587                        case 8  : set_func("f_reset_char_set"); break;
1588                        case 9  : set_func("f_set_plonk_parameters"); break;
1589                        case 10 : set_func("f_set_cursor_flash_rate"); break;
1590                    }
1591                }; break;
1592             
1593                case 1  :
1594                {
1595                    set_drv("d_keyboard");
1596                     
1597                    switch(ax)
1598                    {
1599                        case 0  : set_func("f_get_version_number"); break;             
1600                        case 1  : set_func("f_init_keyboard"); break;
1601                        case 2  : set_func("f_get_last_key_code"); break;
1602                        case 3  : set_func("f_get_bitmap"); break;
1603                    }
1604                }; break;
1605            }
1606        }; break;
1607         
1608        case 10   : 
1609        {
1610            set_type("t_acoustics");
1611            switch(ax)
1612            {
1613                case 0  : set_func("f_get_version_number"); break;             
1614            }
1615        }; break;
1616         
1617        case 11   : 
1618        {
1619            set_type("t_hard_sums");
1620            switch(ax)
1621            {
1622                case 0  : set_func("f_get_version_number"); break;             
1623            }
1624        }; break;     
1625    }
1626     
1627    logerror("Type=%s, Driver=%s, Function=%s\n",type_str,drv_str,func_str);
1628     
1629    if(dump_dssi!=NULL)
1630        dump_dssi(device,ds,si);
1631    logerror("=======================================================================\n");
1632}
1633 
1634void *get_dssi_ptr(const address_space *space, UINT16   ds, UINT16 si)
1635{
1636    int             addr;
1637 
1638    addr=((ds<<4)+si);
1639    OUTPUT_SEGOFS("DS:SI",ds,si);
1640 
1641    return memory_get_read_ptr(space, addr);
1642}
1643 
1644static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si)
1645{
1646    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1647 
1648    UINT16          *addr_ptr;
1649    t_area_params   *area_params;
1650    t_nimbus_brush  *brush;
1651    int             cocount;
1652 
1653    area_params = get_dssi_ptr(space,ds,si);
1654     
1655    OUTPUT_SEGOFS("SegBrush:OfsBrush",area_params->seg_brush,area_params->ofs_brush);
1656    brush=memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_brush,area_params->ofs_brush));
1657     
1658    logerror("Brush params\n");
1659    logerror("Style=%04X,          StyleIndex=%04X\n",brush->style,brush->style_index);
1660    logerror("Colour1=%04X,        Colour2=%04X\n",brush->colour1,brush->colour2);
1661    logerror("transparency=%04X,   boundry_spec=%04X\n",brush->transparency,brush->boundary_spec);
1662    logerror("boundry colour=%04X, save colour=%04X\n",brush->boundary_colour,brush->save_colour);
1663             
1664     
1665    OUTPUT_SEGOFS("SegData:OfsData",area_params->seg_data,area_params->ofs_data);
1666     
1667    addr_ptr = memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_data,area_params->ofs_data));
1668    for(cocount=0; cocount < area_params->count; cocount++)
1669    {
1670        logerror("x=%d y=%d\n",addr_ptr[cocount*2],addr_ptr[(cocount*2)+1]);
1671    }
1672}
1673 
1674static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si)
1675{
1676    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1677 
1678    UINT8          *char_ptr;
1679    t_plot_string_params   *plot_string_params;
1680    int             charno;
1681       
1682    plot_string_params=get_dssi_ptr(space,ds,si);
1683     
1684    OUTPUT_SEGOFS("SegFont:OfsFont",plot_string_params->seg_font,plot_string_params->ofs_font);
1685    OUTPUT_SEGOFS("SegData:OfsData",plot_string_params->seg_data,plot_string_params->ofs_data);
1686     
1687    logerror("x=%d, y=%d, length=%d\n",plot_string_params->x,plot_string_params->y,plot_string_params->length);
1688     
1689    char_ptr=memory_get_read_ptr(space, LINEAR_ADDR(plot_string_params->seg_data,plot_string_params->ofs_data));
1690 
1691    if (plot_string_params->length==0xFFFF)
1692        logerror("%s",char_ptr);
1693    else
1694        for(charno=0;charno<plot_string_params->length;charno++)
1695            logerror("%c",char_ptr[charno]);
1696         
1697    logerror("\n");
1698}
1699 
1700static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si)
1701{
1702    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1703    UINT16  *new_colours;
1704    int     colour;
1705    new_colours=get_dssi_ptr(space,ds,si);
1706     
1707    OUTPUT_SEGOFS("SegColours:OfsColours",ds,si);
1708     
1709    for(colour=0;colour<16;colour++)
1710        logerror("colour #%02X=%04X\n",colour,new_colours[colour]);
1711     
1712}
1713 
1714READ16_HANDLER( nimbus_io_r )
1715{
1716    int pc=cpu_get_pc(space->cpu);
1717     
1718    logerror("Nimbus IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2)+0x30,mem_mask,IOPorts[offset]);
1719     
1720    switch (offset*2)
1721    {
1722        default         : return IOPorts[offset]; break;
1723    }
1724    return 0;
1725}
1726 
1727WRITE16_HANDLER( nimbus_io_w )
1728{
1729    int pc=cpu_get_pc(space->cpu);
1730 
1731    logerror("Nimbus IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2)+0x30,mem_mask);
1732     
1733    switch (offset*2)
1734    {
1735        default         : COMBINE_DATA(&IOPorts[offset]); break;
1736    }
1737}
1738 
1739/* 
1740 
1741Z80SIO, used for the keyboard interface 
1742 
1743*/
1744 
1745READ8_DEVICE_HANDLER( sio_r )
1746{
1747    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1748    UINT8 result = 0;
1749     
1750   switch (offset*2)
1751   {
1752        case 0 :
1753            result=z80sio_d_r(device, 0); 
1754            break;
1755        case 2 :
1756            result=z80sio_d_r(device, 1); 
1757            break;
1758        case 4 :
1759            result=z80sio_c_r(device, 0);
1760            break;
1761        case 6 :
1762            result=z80sio_c_r(device, 1);
1763            break;
1764   }
1765 
1766    logerror("Nimbus SIOR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0xF0,result);
1767 
1768   return result;
1769}
1770 
1771WRITE8_DEVICE_HANDLER( sio_w )
1772{
1773    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1774 
1775    logerror("Nimbus SIOW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0xF0);
1776 
1777   switch (offset*2)
1778   {
1779        case 0 :
1780            z80sio_d_w(device, 0, data);
1781            break;
1782        case 2 :
1783            z80sio_d_w(device, 1, data);
1784            break;
1785        case 4 :
1786            z80sio_c_w(device, 0, data);
1787            break;
1788        case 5 :
1789            z80sio_c_w(device, 1, data);
1790            break;
1791   }
1792}
1793 
1794/* Z80 SIO/2 */
1795 
1796void sio_interrupt(const device_config *device, int state)
1797{
1798    logerror("SIO Interrupt state=%02X\n",state);
1799 
1800    // Don't re-trigger if already active !
1801    if(state!=sio_int_state)
1802    {
1803        sio_int_state=state;
1804         
1805        if(state)
1806            external_int(device->machine,0,0x9C);
1807    }
1808}
1809 
1810WRITE8_DEVICE_HANDLER( sio_dtr_w )
1811{
1812   if (offset == 1)
1813   {
1814   }
1815}
1816 
1817WRITE8_DEVICE_HANDLER( sio_serial_transmit )
1818{
1819}
1820 
1821int sio_serial_receive( const device_config *device, int channel )
1822{
1823    UINT8   keyrow;
1824    UINT8   row;
1825    static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
1826                                             "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" };
1827    int     key;
1828 
1829   if(channel==0)
1830    {
1831        key=-1;
1832         
1833        //logerror("Read keyboard\n");
1834        for(row=0;row<NIMBUS_KEYROWS;row++)
1835        {
1836            keyrow=input_port_read(device->machine, keynames[row]);
1837            if(keyrows[row]!=keyrow)
1838            {
1839                keyrows[row]=keyrow;
1840                key=~keyrow & 0xff;
1841            }
1842        }
1843         
1844        if (nextkey!=0)
1845        {
1846            key=nextkey;
1847            nextkey=0;
1848        }
1849         
1850        if(key!=-1) 
1851            logerror("Keypressed=%02X\n",key);
1852         
1853        return key;
1854    }
1855    else
1856        return -1;
1857}
1858 
1859/* Floppy disk */
1860 
1861static void fdc_reset(void)
1862{
1863    nimbus_fdc.irq_enabled=0;
1864    nimbus_fdc.drq_enabled=0;
1865    nimbus_fdc.diskno=0;
1866    nimbus_fdc.motor_on=0;
1867}
1868 
1869static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w )
1870{
1871   logerror("nimbus_fdc_intrq_w(%d)\n", state);
1872 
1873    if(state && nimbus_fdc.irq_enabled)
1874    {
1875        external_int(device->machine,0,0x80);
1876    } 
1877}
1878 
1879static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w )
1880{
1881   logerror("nimbus_fdc_drq_w(%d)\n", state);
1882     
1883    if(state && nimbus_fdc.drq_enabled)
1884        drq_callback(device->machine,1);
1885}
1886 
1887READ8_HANDLER( nimbus_fdc_r )
1888{
1889      int result = 0;
1890   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1891    int pc=cpu_get_pc(space->cpu);
1892    const device_config *drive = devtag_get_device(space->machine, nimbus_wd17xx_interface.floppy_drive_tags[nimbus_fdc.diskno]);
1893   
1894    switch(offset*2)
1895   {
1896      case 0x08 :
1897         result = wd17xx_status_r(fdc, 0);
1898         logerror("Disk status=%2.2X\n",result);
1899         break;
1900      case 0x0A :
1901         result = wd17xx_track_r(fdc, 0);
1902         break;
1903      case 0x0C :
1904         result = wd17xx_sector_r(fdc, 0);
1905         break;
1906      case 0x0E :
1907         result = wd17xx_data_r(fdc, 0);
1908         break;
1909        case 0x10 :
1910            result = (nimbus_fdc.motor_on                                    ? 0x04 : 0x00) |
1911                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_INDEX) ? 0x00 : 0x02) |
1912                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_READY) ? 0x01 : 0x00);       
1913            break;
1914      default:
1915         break;
1916   }
1917 
1918    logerror("Nimbus FDCR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0x400,result);
1919 
1920   return result;
1921}
1922 
1923WRITE8_HANDLER( nimbus_fdc_w )
1924{
1925   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1926    int pc=cpu_get_pc(space->cpu);
1927 
1928    logerror("Nimbus FDCW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0x400);
1929 
1930    switch(offset*2)
1931   {
1932        case 0x00 :
1933            switch (data & 0x0F)
1934            {
1935                case 0x01 : nimbus_fdc.diskno=0; break;
1936                case 0x02 : nimbus_fdc.diskno=1; break;
1937                case 0x04 : nimbus_fdc.diskno=2; break;
1938                case 0x08 : nimbus_fdc.diskno=3; break;   
1939                //default : nimbus_fdc.diskno=NO_DRIVE_SELECTED; break; // no drive selected
1940            }
1941            if (nimbus_fdc.diskno!=NO_DRIVE_SELECTED)
1942            {
1943                wd17xx_set_drive(fdc, nimbus_fdc.diskno);
1944                wd17xx_set_side(fdc, (data & 0x10) ? 1 : 0);
1945            }
1946            nimbus_fdc.motor_on=(data & 0x20);
1947            nimbus_fdc.drq_enabled=(data & 0x80);
1948            nimbus_fdc.irq_enabled=1;
1949             
1950            // Nimbus FDC is hard wired for double density
1951            wd17xx_set_density(fdc, DEN_MFM_LO);
1952         break;
1953      case 0x08 :
1954         wd17xx_command_w(fdc, 0, data);
1955         break;
1956      case 0x0A :
1957         wd17xx_track_w(fdc, 0, data);
1958         break;
1959      case 0x0C :
1960         wd17xx_sector_w(fdc, 0, data);
1961         break;
1962      case 0x0E :
1963         wd17xx_data_w(fdc, 0, data);
1964         break;
1965   }
1966}
1967 
src/mess/drivers/rmnimbus.c
r0r6793
1/*
2    drivers/rmnimbus.c
3     
4    Research machines Nimbus.
5     
6    2009-11-14, P.Harvey-Smith.
7     
8*/
9 
10#include "driver.h"
11#include "image.h"
12#include "cpu/i86/i86.h"
13#include "devices/flopdrv.h"
14#include "devices/messram.h"
15#include "formats/flopimg.h"
16#include "formats/pc_dsk.h"
17#include "includes/rmnimbus.h"
18#include "machine/z80sio.h"
19 
20static const unsigned char nimbus_palette[] =
21{
22   /*normal brightness */
23   0x00,0x00,0x00,    /* black */
24   0x00,0x00,0x80,      /* blue */
25    0x80,0x00,0x00,      /* red */
26    0x80,0x00,0x80,      /* magenta */
27   0x00,0x80,0x00,    /* green */
28    0x00,0x80,0x80,      /* cyan */
29   0x80,0x80,0x00,      /* yellow */
30   0x80,0x80,0x80,      /* light grey */
31 
32   /*enhanced brightness*/
33   0x40,0x40,0x40,    /* dark grey */
34   0x00,0x00,0xFF,      /* light blue */
35   0xFF,0x00,0x00,      /* light red */
36   0xFF,0x00,0xFF,      /* light magenta */
37   0x00,0xFF,0x00,    /* light green */
38   0x00,0xFF,0xFF,      /* light cyan */
39   0xFF,0xFF,0x00,      /* yellow */
40   0xFF,0xFF,0xFF      /* white */
41};
42 
43static const floppy_config nimbus_floppy_config =
44{
45   DEVCB_NULL,
46   DEVCB_NULL,
47   DEVCB_NULL,
48   DEVCB_NULL,
49   DEVCB_NULL,
50   FLOPPY_DRIVE_DS_80,
51   FLOPPY_OPTIONS_NAME(pc),
52   DO_NOT_KEEP_GEOMETRY
53};
54 
55 
56static ADDRESS_MAP_START(nimbus_mem, ADDRESS_SPACE_PROGRAM, 16)
57    AM_RANGE( 0x00000, 0xEFFFF ) AM_RAM
58    AM_RANGE( 0xF0000, 0xFFFFF ) AM_ROM 
59ADDRESS_MAP_END
60 
61static ADDRESS_MAP_START(nimbus_io, ADDRESS_SPACE_IO, 16)
62    AM_RANGE( 0x0000, 0x002f) AM_READWRITE( nimbus_video_io_r, nimbus_video_io_w)
63    AM_RANGE( 0x0030, 0x00ef) AM_READWRITE( nimbus_io_r, nimbus_io_w)
64    AM_RANGE( 0X00f0, 0X00f7) AM_DEVREADWRITE8( Z80SIO_TAG, sio_r, sio_w, 0x00FF)
65    AM_RANGE( 0x0400, 0x041f) AM_READWRITE8( nimbus_fdc_r, nimbus_fdc_w, 0x00FF)
66   AM_RANGE( 0xff00, 0xffff) AM_READWRITE( i186_internal_port_r, i186_internal_port_w)/* CPU 80186         */
67ADDRESS_MAP_END
68 
69static INPUT_PORTS_START( nimbus )
70   PORT_START("KEY0") /* Key row  10 */
71   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
72   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
73   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
74   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
75   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
76   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
77   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7')
78    PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
79 
80INPUT_PORTS_END
81 
82 
83 
84 
85static PALETTE_INIT( nimbus )
86{
87   int i;
88 
89   for ( i = 0; i < sizeof(nimbus_palette) / 3; i++ ) {
90      palette_set_color_rgb(machine, i, nimbus_palette[i*3], nimbus_palette[i*3+1], nimbus_palette[i*3+2]);
91   }
92}
93 
94 
95static MACHINE_DRIVER_START( nimbus )
96    /* basic machine hardware */
97    MDRV_CPU_ADD(MAINCPU_TAG, I80186, 10000000)
98    MDRV_CPU_PROGRAM_MAP(nimbus_mem)
99    MDRV_CPU_IO_MAP(nimbus_io)
100 
101    MDRV_MACHINE_START( nimbus )
102 
103    MDRV_MACHINE_RESET(nimbus)
104     
105    /* video hardware */
106    MDRV_SCREEN_ADD("screen", RASTER)
107    MDRV_SCREEN_REFRESH_RATE(50)
108    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
109    MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
110     
111    MDRV_PALETTE_LENGTH(ARRAY_LENGTH(nimbus_palette) / 3)
112   MDRV_PALETTE_INIT( nimbus )
113   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
114 
115    MDRV_SCREEN_SIZE(650, 260)
116    MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 249)
117 
118    MDRV_VIDEO_START(nimbus)
119    MDRV_VIDEO_UPDATE(nimbus)
120    MDRV_VIDEO_EOF(nimbus)
121 
122 
123   MDRV_WD2793_ADD(FDC_TAG, nimbus_wd17xx_interface )
124   MDRV_FLOPPY_4_DRIVES_ADD(nimbus_floppy_config)
125     
126    MDRV_RAM_ADD("messram")
127   MDRV_RAM_DEFAULT_SIZE("512K")
128   MDRV_RAM_EXTRA_OPTIONS("1024K,1536K")
129     
130    /* Peripheral chips */
131    MDRV_Z80SIO_ADD(Z80SIO_TAG, 4000000, sio_intf)
132MACHINE_DRIVER_END
133 
134 
135ROM_START( nimbus )
136    ROM_REGION( 0x100000, MAINCPU_TAG, 0 )
137     
138//  ROM_LOAD16_BYTE("sys1-1.31a-16128-1986-06-18.rom", 0x0001, 0x8000, CRC(6416eb05) SHA1(1b640163a7efbc24381c7b24976a8609c066959b))
139//   ROM_RELOAD(0xf0001,0x8000)
140//  ROM_LOAD16_BYTE("sys2-1.31a-16129-1986-06-18.rom", 0x0000, 0x8000, CRC(b224359d) SHA1(456bbe37afcd4429cca76ba2d6bd534dfda3fc9c))
141//   ROM_RELOAD(0xf0000,0x8000)
142 
143    ROM_LOAD16_BYTE("sys-1-1.32f-22779-1989-10-20.rom", 0x0001, 0x8000, CRC(786c31e8) SHA1(da7f828f7f96087518bea1a3d89fee59b283b4ba))
144   ROM_RELOAD(0xf0001,0x8000)
145    ROM_LOAD16_BYTE("sys-2-1.32f-22779-1989-10-20.rom", 0x0000, 0x8000, CRC(0be3db64) SHA1(af806405ec6fbc20385705f90d5059a47de17b08))
146   ROM_RELOAD(0xf0000,0x8000)
147     
148ROM_END
149 
150/*    YEAR  NAME        PARENT  COMPAT  MACHINE INPUT   INIT  COMPANY  FULLNAME   FLAGS */
151COMP( 1986, nimbus,     0,      0,      nimbus, nimbus, 0,   "Research Machines", "nimbus", GAME_NO_SOUND | GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team