Previous 15994 Revisions Next

r3784 Monday 8th December, 2008 at 15:54:44 UTC by Curt Coder
[ATARIST] Moved most variables to driver state.
[src/mess/drivers]atarist.c
[src/mess/includes]atarist.h
[src/mess/video]atarist.c

src/mess/video/atarist.c
r3783r3784
1515#include "video/atarist.h"
1616#include "includes/atarist.h"
1717
18static struct SHIFTER
18INLINE pen_t atarist_shift_mode_0(running_machine *machine)
1919{
20   UINT32 base;
21   UINT32 ofs;
22   UINT8 sync;
23   UINT8 mode;
24   UINT16 palette[16];
25   UINT8 lineofs;  // STe
26   UINT8 pixelofs; // STe
27   UINT16 rr[4];
28   UINT16 ir[4];
29   int bitplane;
30   int shift;
31   int h, v;
32   int de;
33   int x_start, x_end, y_start, y_end, hblank_start, vblank_start;
34} shifter;
20   atarist_state *state = machine->driver_data;
3521
36static emu_timer *atarist_glue_timer;
37static emu_timer *atarist_shifter_timer;
38static const device_config *mfp;
22   int color = (BIT(state->shifter_rr[3], 15) << 3) | (BIT(state->shifter_rr[2], 15) << 2) | (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15);
3923
40INLINE pen_t atarist_shift_mode_0(running_machine *machine)
41{
42   int color = (BIT(shifter.rr[3], 15) << 3) | (BIT(shifter.rr[2], 15) << 2) | (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15);
24   state->shifter_rr[0] <<= 1;
25   state->shifter_rr[1] <<= 1;
26   state->shifter_rr[2] <<= 1;
27   state->shifter_rr[3] <<= 1;
4328
44   shifter.rr[0] <<= 1;
45   shifter.rr[1] <<= 1;
46   shifter.rr[2] <<= 1;
47   shifter.rr[3] <<= 1;
48
4929   return machine->pens[color];
5030}
5131
5232INLINE pen_t atarist_shift_mode_1(running_machine *machine)
5333{
54   int color = (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15);
34   atarist_state *state = machine->driver_data;
5535
56   shifter.rr[0] <<= 1;
57   shifter.rr[1] <<= 1;
58   shifter.shift++;
36   int color = (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15);
5937
60   if (shifter.shift == 16)
38   state->shifter_rr[0] <<= 1;
39   state->shifter_rr[1] <<= 1;
40   state->shifter_shift++;
41
42   if (state->shifter_shift == 16)
6143   {
62      shifter.rr[0] = shifter.rr[2];
63      shifter.rr[1] = shifter.rr[3];
64      shifter.rr[2] = shifter.rr[3] = 0;
65      shifter.shift = 0;
44      state->shifter_rr[0] = state->shifter_rr[2];
45      state->shifter_rr[1] = state->shifter_rr[3];
46      state->shifter_rr[2] = state->shifter_rr[3] = 0;
47      state->shifter_shift = 0;
6648   }
6749
6850   return machine->pens[color];
r3783r3784
7052
7153INLINE pen_t atarist_shift_mode_2(running_machine *machine)
7254{
73   int color = BIT(shifter.rr[0], 15);
55   atarist_state *state = machine->driver_data;
7456
75   shifter.rr[0] <<= 1;
76   shifter.shift++;
57   int color = BIT(state->shifter_rr[0], 15);
7758
78   switch (shifter.shift)
59   state->shifter_rr[0] <<= 1;
60   state->shifter_shift++;
61
62   switch (state->shifter_shift)
7963   {
8064   case 16:
81      shifter.rr[0] = shifter.rr[1];
82      shifter.rr[1] = shifter.rr[2];
83      shifter.rr[2] = shifter.rr[3];
84      shifter.rr[3] = 0;
65      state->shifter_rr[0] = state->shifter_rr[1];
66      state->shifter_rr[1] = state->shifter_rr[2];
67      state->shifter_rr[2] = state->shifter_rr[3];
68      state->shifter_rr[3] = 0;
8569      break;
8670
8771   case 32:
88      shifter.rr[0] = shifter.rr[1];
89      shifter.rr[1] = shifter.rr[2];
90      shifter.rr[2] = 0;
72      state->shifter_rr[0] = state->shifter_rr[1];
73      state->shifter_rr[1] = state->shifter_rr[2];
74      state->shifter_rr[2] = 0;
9175      break;
9276
9377   case 48:
94      shifter.rr[0] = shifter.rr[1];
95      shifter.rr[1] = 0;
96      shifter.shift = 0;
78      state->shifter_rr[0] = state->shifter_rr[1];
79      state->shifter_rr[1] = 0;
80      state->shifter_shift = 0;
9781      break;
9882   }
9983
10084   return machine->pens[color];
10185}
10286
103static TIMER_CALLBACK(atarist_shifter_tick)
87static TIMER_CALLBACK( atarist_shifter_tick )
10488{
89   atarist_state *state = machine->driver_data;
90
10591   int y = video_screen_get_vpos(machine->primary_screen);
10692   int x = video_screen_get_hpos(machine->primary_screen);
10793
10894   pen_t pen;
10995
110   switch (shifter.mode)
96   switch (state->shifter_mode)
11197   {
11298   case 0:
11399      pen = atarist_shift_mode_0(machine);
r3783r3784
131117
132118INLINE void atarist_shifter_load(running_machine *machine)
133119{
134   UINT8 *RAM = memory_region(machine, "main") + shifter.ofs;
120   atarist_state *state = machine->driver_data;
135121
136   shifter.ir[shifter.bitplane] = (RAM[1] << 8) | RAM[0];
137   shifter.bitplane++;
138   shifter.ofs += 2;
122   const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
123   UINT16 data = memory_read_word_16be(program, state->shifter_ofs);
139124
140   if (shifter.bitplane == 4)
125   state->shifter_ir[state->shifter_bitplane] = data;
126   state->shifter_bitplane++;
127   state->shifter_ofs += 2;
128
129   if (state->shifter_bitplane == 4)
141130   {
142      shifter.bitplane = 0;
131      state->shifter_bitplane = 0;
143132
144      shifter.rr[0] = shifter.ir[0];
145      shifter.rr[1] = shifter.ir[1];
146      shifter.rr[2] = shifter.ir[2];
147      shifter.rr[3] = shifter.ir[3];
133      state->shifter_rr[0] = state->shifter_ir[0];
134      state->shifter_rr[1] = state->shifter_ir[1];
135      state->shifter_rr[2] = state->shifter_ir[2];
136      state->shifter_rr[3] = state->shifter_ir[3];
148137   }
149138}
150139
151static TIMER_CALLBACK(atarist_glue_tick)
140static TIMER_CALLBACK( atarist_glue_tick )
152141{
142   atarist_state *state = machine->driver_data;
143
153144   int y = video_screen_get_vpos(machine->primary_screen);
154145   int x = video_screen_get_hpos(machine->primary_screen);
155146
156   int v = (y >= shifter.y_start) && (y < shifter.y_end);
157   int h = (x >= shifter.x_start) && (x < shifter.x_end);
147   int v = (y >= state->shifter_y_start) && (y < state->shifter_y_end);
148   int h = (x >= state->shifter_x_start) && (x < state->shifter_x_end);
158149
159150   int de = h && v;
160151
161   if (de != shifter.de)
152   if (de != state->shifter_de)
162153   {
163      mc68901_tbi_w(mfp, de);
164      shifter.de = de;
154      mc68901_tbi_w(state->mc68901, de);
155      state->shifter_de = de;
165156   }
166157
167158   if (de)
r3783r3784
169160      atarist_shifter_load(machine);
170161   }
171162
172   if ((y == shifter.vblank_start) && (x == 0))
163   if ((y == state->shifter_vblank_start) && (x == 0))
173164   {
174165      cpu_set_input_line(machine->cpu[0], M68K_IRQ_4, HOLD_LINE);
175      shifter.ofs = shifter.base;
166      state->shifter_ofs = state->shifter_base;
176167   }
177168
178   if (x == shifter.hblank_start)
169   if (x == state->shifter_hblank_start)
179170   {
180171      cpu_set_input_line(machine->cpu[0], M68K_IRQ_2, HOLD_LINE);
181      shifter.ofs += (shifter.lineofs * 2); // STe
172      state->shifter_ofs += (state->shifter_lineofs * 2); // STe
182173   }
183174}
184175
185static void atarist_set_screen_parameters(void)
176static void atarist_set_screen_parameters(running_machine *machine)
186177{
187   if (shifter.sync & 0x02)
178   atarist_state *state = machine->driver_data;
179
180   if (state->shifter_sync & 0x02)
188181   {
189      shifter.x_start = ATARIST_HBDEND_PAL;
190      shifter.x_end = ATARIST_HBDSTART_PAL;
191      shifter.y_start = ATARIST_VBDEND_PAL;
192      shifter.y_end = ATARIST_VBDSTART_PAL;
193      shifter.hblank_start = ATARIST_HBSTART_PAL;
194      shifter.vblank_start = ATARIST_VBSTART_PAL;
182      state->shifter_x_start = ATARIST_HBDEND_PAL;
183      state->shifter_x_end = ATARIST_HBDSTART_PAL;
184      state->shifter_y_start = ATARIST_VBDEND_PAL;
185      state->shifter_y_end = ATARIST_VBDSTART_PAL;
186      state->shifter_hblank_start = ATARIST_HBSTART_PAL;
187      state->shifter_vblank_start = ATARIST_VBSTART_PAL;
195188   }
196189   else
197190   {
198      shifter.x_start = ATARIST_HBDEND_NTSC;
199      shifter.x_end = ATARIST_HBDSTART_NTSC;
200      shifter.y_start = ATARIST_VBDEND_NTSC;
201      shifter.y_end = ATARIST_VBDSTART_NTSC;
202      shifter.hblank_start = ATARIST_HBSTART_NTSC;
203      shifter.vblank_start = ATARIST_VBSTART_NTSC;
191      state->shifter_x_start = ATARIST_HBDEND_NTSC;
192      state->shifter_x_end = ATARIST_HBDSTART_NTSC;
193      state->shifter_y_start = ATARIST_VBDEND_NTSC;
194      state->shifter_y_end = ATARIST_VBDSTART_NTSC;
195      state->shifter_hblank_start = ATARIST_HBSTART_NTSC;
196      state->shifter_vblank_start = ATARIST_VBSTART_NTSC;
204197   }
205198}
206199
r3783r3784
208201
209202READ16_HANDLER( atarist_shifter_base_r )
210203{
204   atarist_state *state = space->machine->driver_data;
205
211206   switch (offset)
212207   {
213208   case 0x00:
214      return (shifter.base >> 16) & 0x3f;
209      return (state->shifter_base >> 16) & 0x3f;
215210   case 0x01:
216      return (shifter.base >> 8) & 0xff;
211      return (state->shifter_base >> 8) & 0xff;
217212   }
218213
219214   return 0;
r3783r3784
221216
222217WRITE16_HANDLER( atarist_shifter_base_w )
223218{
219   atarist_state *state = space->machine->driver_data;
220
224221   switch (offset)
225222   {
226223   case 0x00:
227      shifter.base = (shifter.base & 0x00ff00) | (data & 0x3f) << 16;
228      logerror("SHIFTER Video Base Address %06x\n", shifter.base);
224      state->shifter_base = (state->shifter_base & 0x00ff00) | (data & 0x3f) << 16;
225      logerror("SHIFTER Video Base Address %06x\n", state->shifter_base);
229226      break;
230227   case 0x01:
231      shifter.base = (shifter.base & 0x3f0000) | (data & 0xff) << 8;
232      logerror("SHIFTER Video Base Address %06x\n", shifter.base);
228      state->shifter_base = (state->shifter_base & 0x3f0000) | (data & 0xff) << 8;
229      logerror("SHIFTER Video Base Address %06x\n", state->shifter_base);
233230      break;
234231   }
235232}
236233
237234READ16_HANDLER( atarist_shifter_counter_r )
238235{
236   atarist_state *state = space->machine->driver_data;
237
239238   switch (offset)
240239   {
241240   case 0x00:
242      return (shifter.ofs >> 16) & 0x3f;
241      return (state->shifter_ofs >> 16) & 0x3f;
243242   case 0x01:
244      return (shifter.ofs >> 8) & 0xff;
243      return (state->shifter_ofs >> 8) & 0xff;
245244   case 0x02:
246      return shifter.ofs & 0xff;
245      return state->shifter_ofs & 0xff;
247246   }
248247
249248   return 0;
r3783r3784
251250
252251READ8_HANDLER( atarist_shifter_sync_r )
253252{
254   return shifter.sync;
253   atarist_state *state = space->machine->driver_data;
254
255   return state->shifter_sync;
255256}
256257
257258WRITE8_HANDLER( atarist_shifter_sync_w )
258259{
259   shifter.sync = data;
260   logerror("SHIFTER Sync %x\n", shifter.sync);
261   atarist_set_screen_parameters();
260   atarist_state *state = space->machine->driver_data;
261
262   state->shifter_sync = data;
263   logerror("SHIFTER Sync %x\n", state->shifter_sync);
264   atarist_set_screen_parameters(space->machine);
262265}
263266
264267READ8_HANDLER( atarist_shifter_mode_r )
265268{
266   return shifter.mode;
269   atarist_state *state = space->machine->driver_data;
270
271   return state->shifter_mode;
267272}
268273
269274WRITE8_HANDLER( atarist_shifter_mode_w )
270275{
271   shifter.mode = data;
272   logerror("SHIFTER Mode %x\n", shifter.mode);
276   atarist_state *state = space->machine->driver_data;
277
278   state->shifter_mode = data;
279   logerror("SHIFTER Mode %x\n", state->shifter_mode);
273280}
274281
275282READ16_HANDLER( atarist_shifter_palette_r )
276283{
277   return shifter.palette[offset];
284   atarist_state *state = space->machine->driver_data;
285
286   return state->shifter_palette[offset];
278287}
279288
280289WRITE16_HANDLER( atarist_shifter_palette_w )
281290{
282   shifter.palette[offset] = data;
291   atarist_state *state = space->machine->driver_data;
292
293   state->shifter_palette[offset] = data;
283294   logerror("SHIFTER Palette[%x] = %x\n", offset, data);
284295
285296   palette_set_color_rgb(space->machine, offset, pal3bit(data >> 8), pal3bit(data >> 4), pal3bit(data));
r3783r3784
289300
290301READ16_HANDLER( atariste_shifter_base_low_r )
291302{
292   return shifter.base & 0xfe;
303   atarist_state *state = space->machine->driver_data;
304
305   return state->shifter_base & 0xfe;
293306}
294307
295308WRITE16_HANDLER( atariste_shifter_base_low_w )
296309{
297   shifter.base = (shifter.base & 0x3fff00) | (data & 0xfe);
298   logerror("SHIFTER Video Base Address %06x\n", shifter.base);
310   atarist_state *state = space->machine->driver_data;
311
312   state->shifter_base = (state->shifter_base & 0x3fff00) | (data & 0xfe);
313   logerror("SHIFTER Video Base Address %06x\n", state->shifter_base);
299314}
300315
301316READ16_HANDLER( atariste_shifter_counter_r )
302317{
318   atarist_state *state = space->machine->driver_data;
319
303320   switch (offset)
304321   {
305322   case 0x00:
306      return (shifter.ofs >> 16) & 0x3f;
323      return (state->shifter_ofs >> 16) & 0x3f;
307324   case 0x01:
308      return (shifter.ofs >> 8) & 0xff;
325      return (state->shifter_ofs >> 8) & 0xff;
309326   case 0x02:
310      return shifter.ofs & 0xfe;
327      return state->shifter_ofs & 0xfe;
311328   }
312329
313330   return 0;
r3783r3784
315332
316333WRITE16_HANDLER( atariste_shifter_counter_w )
317334{
335   atarist_state *state = space->machine->driver_data;
336
318337   switch (offset)
319338   {
320339   case 0x00:
321      shifter.ofs = (shifter.ofs & 0x00fffe) | (data & 0x3f) << 16;
322      logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs);
340      state->shifter_ofs = (state->shifter_ofs & 0x00fffe) | (data & 0x3f) << 16;
341      logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs);
323342      break;
324343   case 0x01:
325      shifter.ofs = (shifter.ofs & 0x3f00fe) | (data & 0xff) << 8;
326      logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs);
344      state->shifter_ofs = (state->shifter_ofs & 0x3f00fe) | (data & 0xff) << 8;
345      logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs);
327346      break;
328347   case 0x02:
329      shifter.ofs = (shifter.ofs & 0x3fff00) | (data & 0xfe);
330      logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs);
348      state->shifter_ofs = (state->shifter_ofs & 0x3fff00) | (data & 0xfe);
349      logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs);
331350      break;
332351   }
333352}
334353
335354WRITE16_HANDLER( atariste_shifter_palette_w )
336355{
356   atarist_state *state = space->machine->driver_data;
357
337358   int r = ((data >> 7) & 0x0e) | BIT(data, 11);
338359   int g = ((data >> 3) & 0x0e) | BIT(data, 7);
339360   int b = ((data << 1) & 0x0e) | BIT(data, 3);
340361
341   shifter.palette[offset] = data;
362   state->shifter_palette[offset] = data;
342363   logerror("SHIFTER palette %x = %x\n", offset, data);
343364
344365   palette_set_color_rgb(space->machine, offset, r, g, b);
r3783r3784
346367
347368READ16_HANDLER( atariste_shifter_lineofs_r )
348369{
349   return shifter.lineofs;
370   atarist_state *state = space->machine->driver_data;
371
372   return state->shifter_lineofs;
350373}
351374
352375WRITE16_HANDLER( atariste_shifter_lineofs_w )
353376{
354   shifter.lineofs = data & 0xff;
355   logerror("SHIFTER Line Offset %x\n", shifter.lineofs);
377   atarist_state *state = space->machine->driver_data;
378
379   state->shifter_lineofs = data & 0xff;
380   logerror("SHIFTER Line Offset %x\n", state->shifter_lineofs);
356381}
357382
358383READ16_HANDLER( atariste_shifter_pixelofs_r )
359384{
360   return shifter.pixelofs;
385   atarist_state *state = space->machine->driver_data;
386
387   return state->shifter_pixelofs;
361388}
362389
363390WRITE16_HANDLER( atariste_shifter_pixelofs_w )
364391{
365   shifter.pixelofs = data & 0x0f;
366   logerror("SHIFTER Pixel Offset %x\n", shifter.pixelofs);
392   atarist_state *state = space->machine->driver_data;
393
394   state->shifter_pixelofs = data & 0x0f;
395   logerror("SHIFTER Pixel Offset %x\n", state->shifter_pixelofs);
367396}
368397
369398/* Atari ST Blitter */
r3783r3784
388417   { 1, 1, 1, 1 }
389418};
390419
391static struct BLITTER
392{
393   UINT16 halftone[16];
394   INT16 src_inc_x, src_inc_y, dst_inc_x, dst_inc_y;
395   UINT32 src, dst;
396   UINT16 endmask1, endmask2, endmask3;
397   UINT16 xcount, ycount, xcountl;
398   UINT8 hop, op, ctrl, skew;
399   UINT32 srcbuf;
400} blitter;
401
402420static void atarist_blitter_source(running_machine *machine)
403421{
404   UINT8 *RAM = memory_region(machine, "main") + blitter.src;
422   atarist_state *state = machine->driver_data;
405423
406   if (blitter.src_inc_x < 0)
424   const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
425   UINT16 data = memory_read_word_16be(program, state->blitter_src);
426
427   if (state->blitter_src_inc_x < 0)
407428   {
408      blitter.srcbuf = (RAM[1] << 24) | (RAM[0] << 16) | (blitter.srcbuf >> 16);
429      state->blitter_srcbuf = (data << 16) | (state->blitter_srcbuf >> 16);
409430   }
410431   else
411432   {
412      blitter.srcbuf = (blitter.srcbuf << 16) | (RAM[1] << 8) | RAM[0];
433      state->blitter_srcbuf = (state->blitter_srcbuf << 16) | data;
413434   }
414435}
415436
416static UINT16 atarist_blitter_hop(void)
437static UINT16 atarist_blitter_hop(running_machine *machine)
417438{
418   UINT16 source = blitter.srcbuf >> (blitter.skew & 0x0f);
419   UINT16 halftone = blitter.halftone[blitter.ctrl & 0x0f];
439   atarist_state *state = machine->driver_data;
420440
421   if (blitter.ctrl & ATARIST_BLITTER_CTRL_SMUDGE)
441   UINT16 source = state->blitter_srcbuf >> (state->blitter_skew & 0x0f);
442   UINT16 halftone = state->blitter_halftone[state->blitter_ctrl & 0x0f];
443
444   if (state->blitter_ctrl & ATARIST_BLITTER_CTRL_SMUDGE)
422445   {
423      halftone = blitter.halftone[source & 0x0f];
446      halftone = state->blitter_halftone[source & 0x0f];
424447   }
425448
426   switch (blitter.hop)
449   switch (state->blitter_hop)
427450   {
428451   case 0:
429452      return 0xffff;
r3783r3784
440463
441464static void atarist_blitter_op(running_machine *machine, UINT16 s, UINT32 dstaddr, UINT16 mask)
442465{
443   UINT8 *dst = memory_region(machine, "main") + dstaddr;
444   UINT16 d = (dst[1] << 8) + dst[0];
466   atarist_state *state = machine->driver_data;
467   const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
468
469   UINT16 d = memory_read_word_16be(program, dstaddr);
445470   UINT16 result = 0;
446471
447   if (blitter.op & 0x08) result = (~s & ~d);
448   if (blitter.op & 0x04) result |= (~s & d);
449   if (blitter.op & 0x02) result |= (s & ~d);
450   if (blitter.op & 0x01) result |= (s & d);
472   if (state->blitter_op & 0x08) result = (~s & ~d);
473   if (state->blitter_op & 0x04) result |= (~s & d);
474   if (state->blitter_op & 0x02) result |= (s & ~d);
475   if (state->blitter_op & 0x01) result |= (s & d);
451476
452   dst[0] = result & 0xff;
453   dst[1] = (result >> 8) & 0xff;
477   memory_write_word_16be(program, dstaddr, result);
454478}
455479
456480static TIMER_CALLBACK( atarist_blitter_tick )
457481{
482   atarist_state *state = machine->driver_data;
483
458484   do
459485   {
460      if (blitter.skew & ATARIST_BLITTER_SKEW_FXSR)
486      if (state->blitter_skew & ATARIST_BLITTER_SKEW_FXSR)
461487      {
462488         atarist_blitter_source(machine);
463         blitter.src += blitter.src_inc_x;
489         state->blitter_src += state->blitter_src_inc_x;
464490      }
465491
466492      atarist_blitter_source(machine);
467      atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask1);
468      blitter.xcount--;
493      atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask1);
494      state->blitter_xcount--;
469495
470      while (blitter.xcount > 0)
496      while (state->blitter_xcount > 0)
471497      {
472         blitter.src += blitter.src_inc_x;
473         blitter.dst += blitter.dst_inc_x;
498         state->blitter_src += state->blitter_src_inc_x;
499         state->blitter_dst += state->blitter_dst_inc_x;
474500
475         if (blitter.xcount == 1)
501         if (state->blitter_xcount == 1)
476502         {
477            if (!(blitter.skew & ATARIST_BLITTER_SKEW_NFSR))
503            if (!(state->blitter_skew & ATARIST_BLITTER_SKEW_NFSR))
478504            {
479505               atarist_blitter_source(machine);
480506            }
481507
482            atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask3);
508            atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask3);
483509         }
484510         else
485511         {
486512            atarist_blitter_source(machine);
487            atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask2);
513            atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask2);
488514         }
489515
490         blitter.xcount--;
516         state->blitter_xcount--;
491517      }
492518
493      blitter.src += blitter.src_inc_y;
494      blitter.dst += blitter.dst_inc_y;
519      state->blitter_src += state->blitter_src_inc_y;
520      state->blitter_dst += state->blitter_dst_inc_y;
495521
496      if (blitter.dst_inc_y < 0)
522      if (state->blitter_dst_inc_y < 0)
497523      {
498         blitter.ctrl = (blitter.ctrl & 0xf0) | (((blitter.ctrl & 0x0f) - 1) & 0x0f);
524         state->blitter_ctrl = (state->blitter_ctrl & 0xf0) | (((state->blitter_ctrl & 0x0f) - 1) & 0x0f);
499525      }
500526      else
501527      {
502         blitter.ctrl = (blitter.ctrl & 0xf0) | (((blitter.ctrl & 0x0f) + 1) & 0x0f);
528         state->blitter_ctrl = (state->blitter_ctrl & 0xf0) | (((state->blitter_ctrl & 0x0f) + 1) & 0x0f);
503529      }
504530
505      blitter.xcount = blitter.xcountl;
506      blitter.ycount--;
531      state->blitter_xcount = state->blitter_xcountl;
532      state->blitter_ycount--;
507533   }
508   while (blitter.ycount > 0);
534   while (state->blitter_ycount > 0);
509535
510   blitter.ctrl &= 0x7f;
536   state->blitter_ctrl &= 0x7f;
511537}
512538
513539READ16_HANDLER( atarist_blitter_halftone_r )
514540{
515   return blitter.halftone[offset];
541   atarist_state *state = space->machine->driver_data;
542
543   return state->blitter_halftone[offset];
516544}
517545
518546READ16_HANDLER( atarist_blitter_src_inc_x_r )
519547{
520   return blitter.src_inc_x;
548   atarist_state *state = space->machine->driver_data;
549
550   return state->blitter_src_inc_x;
521551}
522552
523553READ16_HANDLER( atarist_blitter_src_inc_y_r )
524554{
525   return blitter.src_inc_y;
555   atarist_state *state = space->machine->driver_data;
556
557   return state->blitter_src_inc_y;
526558}
527559
528560READ16_HANDLER( atarist_blitter_src_r )
529561{
562   atarist_state *state = space->machine->driver_data;
563
530564   switch (offset)
531565   {
532566   case 0:
533      return (blitter.src >> 16) & 0xff;
567      return (state->blitter_src >> 16) & 0xff;
534568   case 1:
535      return blitter.src & 0xfffe;
569      return state->blitter_src & 0xfffe;
536570   }
537571
538572   return 0;
r3783r3784
540574
541575READ16_HANDLER( atarist_blitter_end_mask_r )
542576{
577   atarist_state *state = space->machine->driver_data;
578
543579   switch (offset)
544580   {
545581   case 0:
546      return blitter.endmask1;
582      return state->blitter_endmask1;
547583   case 1:
548      return blitter.endmask2;
584      return state->blitter_endmask2;
549585   case 2:
550      return blitter.endmask3;
586      return state->blitter_endmask3;
551587   }
552588
553589   return 0;
r3783r3784
555591
556592READ16_HANDLER( atarist_blitter_dst_inc_x_r )
557593{
558   return blitter.dst_inc_x;
594   atarist_state *state = space->machine->driver_data;
595
596   return state->blitter_dst_inc_x;
559597}
560598
561599READ16_HANDLER( atarist_blitter_dst_inc_y_r )
562600{
563   return blitter.dst_inc_y;
601   atarist_state *state = space->machine->driver_data;
602
603   return state->blitter_dst_inc_y;
564604}
565605
566606READ16_HANDLER( atarist_blitter_dst_r )
567607{
608   atarist_state *state = space->machine->driver_data;
609
568610   switch (offset)
569611   {
570612   case 0:
571      return (blitter.dst >> 16) & 0xff;
613      return (state->blitter_dst >> 16) & 0xff;
572614   case 1:
573      return blitter.dst & 0xfffe;
615      return state->blitter_dst & 0xfffe;
574616   }
575617
576618   return 0;
r3783r3784
578620
579621READ16_HANDLER( atarist_blitter_count_x_r )
580622{
581   return blitter.xcount;
623   atarist_state *state = space->machine->driver_data;
624
625   return state->blitter_xcount;
582626}
583627
584628READ16_HANDLER( atarist_blitter_count_y_r )
585629{
586   return blitter.ycount;
630   atarist_state *state = space->machine->driver_data;
631
632   return state->blitter_ycount;
587633}
588634
589635READ16_HANDLER( atarist_blitter_op_r )
590636{
637   atarist_state *state = space->machine->driver_data;
638
591639   if (ACCESSING_BITS_0_7)
592640   {
593      return blitter.hop;
641      return state->blitter_hop;
594642   }
595643   else
596644   {
597      return blitter.op;
645      return state->blitter_op;
598646   }
599647}
600648
601649READ16_HANDLER( atarist_blitter_ctrl_r )
602650{
651   atarist_state *state = space->machine->driver_data;
652
603653   if (ACCESSING_BITS_0_7)
604654   {
605      return blitter.ctrl;
655      return state->blitter_ctrl;
606656   }
607657   else
608658   {
609      return blitter.skew;
659      return state->blitter_skew;
610660   }
611661}
612662
613663WRITE16_HANDLER( atarist_blitter_halftone_w )
614664{
615   blitter.halftone[offset] = data;
665   atarist_state *state = space->machine->driver_data;
666
667   state->blitter_halftone[offset] = data;
616668}
617669
618670WRITE16_HANDLER( atarist_blitter_src_inc_x_w )
619671{
620   blitter.src_inc_x = data & 0xfffe;
672   atarist_state *state = space->machine->driver_data;
673
674   state->blitter_src_inc_x = data & 0xfffe;
621675}
622676
623677WRITE16_HANDLER( atarist_blitter_src_inc_y_w )
624678{
625   blitter.src_inc_y = data & 0xfffe;
679   atarist_state *state = space->machine->driver_data;
680
681   state->blitter_src_inc_y = data & 0xfffe;
626682}
627683
628684WRITE16_HANDLER( atarist_blitter_src_w )
629685{
686   atarist_state *state = space->machine->driver_data;
687
630688   switch (offset)
631689   {
632690   case 0:
633      blitter.src = (data & 0xff) | (blitter.src & 0xfffe);
691      state->blitter_src = (data & 0xff) | (state->blitter_src & 0xfffe);
634692   case 1:
635      blitter.src = (blitter.src & 0xff0000) | (data & 0xfffe);
693      state->blitter_src = (state->blitter_src & 0xff0000) | (data & 0xfffe);
636694   }
637695}
638696
639697WRITE16_HANDLER( atarist_blitter_end_mask_w )
640698{
699   atarist_state *state = space->machine->driver_data;
700
641701   switch (offset)
642702   {
643703   case 0:
644      blitter.endmask1 = data;
704      state->blitter_endmask1 = data;
645705   case 1:
646      blitter.endmask2 = data;
706      state->blitter_endmask2 = data;
647707   case 2:
648      blitter.endmask3 = data;
708      state->blitter_endmask3 = data;
649709   }
650710}
651711
652712WRITE16_HANDLER( atarist_blitter_dst_inc_x_w )
653713{
654   blitter.dst_inc_x = data & 0xfffe;
714   atarist_state *state = space->machine->driver_data;
715
716   state->blitter_dst_inc_x = data & 0xfffe;
655717}
656718
657719WRITE16_HANDLER( atarist_blitter_dst_inc_y_w )
658720{
659   blitter.dst_inc_y = data & 0xfffe;
721   atarist_state *state = space->machine->driver_data;
722
723   state->blitter_dst_inc_y = data & 0xfffe;
660724}
661725
662726WRITE16_HANDLER( atarist_blitter_dst_w )
663727{
728   atarist_state *state = space->machine->driver_data;
729
664730   switch (offset)
665731   {
666732   case 0:
667      blitter.dst = (data & 0xff) | (blitter.dst & 0xfffe);
733      state->blitter_dst = (data & 0xff) | (state->blitter_dst & 0xfffe);
668734   case 1:
669      blitter.dst = (blitter.dst & 0xff0000) | (data & 0xfffe);
735      state->blitter_dst = (state->blitter_dst & 0xff0000) | (data & 0xfffe);
670736   }
671737}
672738
673739WRITE16_HANDLER( atarist_blitter_count_x_w )
674740{
675   blitter.xcount = data;
741   atarist_state *state = space->machine->driver_data;
742
743   state->blitter_xcount = data;
676744}
677745
678746WRITE16_HANDLER( atarist_blitter_count_y_w )
679747{
680   blitter.ycount = data;
748   atarist_state *state = space->machine->driver_data;
749
750   state->blitter_ycount = data;
681751}
682752
683753WRITE16_HANDLER( atarist_blitter_op_w )
684754{
755   atarist_state *state = space->machine->driver_data;
756
685757   if (ACCESSING_BITS_0_7)
686758   {
687      blitter.hop = (data >> 8) & 0x03;
759      state->blitter_hop = (data >> 8) & 0x03;
688760   }
689761   else
690762   {
691      blitter.op = data & 0x0f;
763      state->blitter_op = data & 0x0f;
692764   }
693765}
694766
695767WRITE16_HANDLER( atarist_blitter_ctrl_w )
696768{
769   atarist_state *state = space->machine->driver_data;
770
697771   if (ACCESSING_BITS_0_7)
698772   {
699      blitter.ctrl = (data >> 8) & 0xef;
773      state->blitter_ctrl = (data >> 8) & 0xef;
700774
701      if (!(blitter.ctrl & ATARIST_BLITTER_CTRL_BUSY))
775      if (!(state->blitter_ctrl & ATARIST_BLITTER_CTRL_BUSY))
702776      {
703777         if ((data >> 8) & ATARIST_BLITTER_CTRL_BUSY)
704778         {
705            int nops = BLITTER_NOPS[blitter.op][blitter.hop]; // each NOP takes 4 cycles
779            int nops = BLITTER_NOPS[state->blitter_op][state->blitter_hop]; // each NOP takes 4 cycles
706780            timer_set(space->machine, ATTOTIME_IN_HZ((Y2/4)/(4*nops)), NULL, 0, atarist_blitter_tick);
707781         }
708782      }
709783   }
710784   else
711785   {
712      blitter.skew = data & 0xcf;
786      state->blitter_skew = data & 0xcf;
713787   }
714788}
715789
r3783r3784
717791
718792VIDEO_START( atarist )
719793{
720   mfp = device_list_find_by_tag(machine->config->devicelist, MC68901, MC68901_TAG);
794   atarist_state *state = machine->driver_data;
721795
722   atarist_shifter_timer = timer_alloc(machine, atarist_shifter_tick, NULL);
723   atarist_glue_timer = timer_alloc(machine, atarist_glue_tick, NULL);
796   state->shifter_timer = timer_alloc(machine, atarist_shifter_tick, NULL);
797   state->glue_timer = timer_alloc(machine, atarist_glue_tick, NULL);
724798
725   timer_adjust_periodic(atarist_shifter_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/4)); // 125 ns
726   timer_adjust_periodic(atarist_glue_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/16)); // 500 ns
799   timer_adjust_periodic(state->shifter_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/4)); // 125 ns
800   timer_adjust_periodic(state->glue_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/16)); // 500 ns
727801
728   memset(&shifter, 0, sizeof(shifter));
802   /* register for state saving */
803   state_save_register_global(machine, state->shifter_base);
804   state_save_register_global(machine, state->shifter_ofs);
805   state_save_register_global(machine, state->shifter_sync);
806   state_save_register_global(machine, state->shifter_mode);
807   state_save_register_global_array(machine, state->shifter_palette);
808   state_save_register_global(machine, state->shifter_lineofs);
809   state_save_register_global(machine, state->shifter_pixelofs);
810   state_save_register_global_array(machine, state->shifter_rr);
811   state_save_register_global_array(machine, state->shifter_ir);
812   state_save_register_global(machine, state->shifter_bitplane);
813   state_save_register_global(machine, state->shifter_shift);
814   state_save_register_global(machine, state->shifter_h);
815   state_save_register_global(machine, state->shifter_v);
816   state_save_register_global(machine, state->shifter_de);
729817
730   state_save_register_global(machine, shifter.base);
731   state_save_register_global(machine, shifter.ofs);
732   state_save_register_global(machine, shifter.sync);
733   state_save_register_global(machine, shifter.mode);
734   state_save_register_global_array(machine, shifter.palette);
735   state_save_register_global(machine, shifter.lineofs);
736   state_save_register_global(machine, shifter.pixelofs);
737   state_save_register_global_array(machine, shifter.rr);
738   state_save_register_global_array(machine, shifter.ir);
739   state_save_register_global(machine, shifter.bitplane);
740   state_save_register_global(machine, shifter.shift);
741   state_save_register_global(machine, shifter.h);
742   state_save_register_global(machine, shifter.v);
743   state_save_register_global(machine, shifter.de);
818   state_save_register_global_array(machine, state->blitter_halftone);
819   state_save_register_global(machine, state->blitter_src_inc_x);
820   state_save_register_global(machine, state->blitter_src_inc_y);
821   state_save_register_global(machine, state->blitter_dst_inc_x);
822   state_save_register_global(machine, state->blitter_dst_inc_y);
823   state_save_register_global(machine, state->blitter_src);
824   state_save_register_global(machine, state->blitter_dst);
825   state_save_register_global(machine, state->blitter_endmask1);
826   state_save_register_global(machine, state->blitter_endmask2);
827   state_save_register_global(machine, state->blitter_endmask3);
828   state_save_register_global(machine, state->blitter_xcount);
829   state_save_register_global(machine, state->blitter_ycount);
830   state_save_register_global(machine, state->blitter_xcountl);
831   state_save_register_global(machine, state->blitter_hop);
832   state_save_register_global(machine, state->blitter_op);
833   state_save_register_global(machine, state->blitter_ctrl);
834   state_save_register_global(machine, state->blitter_skew);
744835
745   state_save_register_global_array(machine, blitter.halftone);
746   state_save_register_global(machine, blitter.src_inc_x);
747   state_save_register_global(machine, blitter.src_inc_y);
748   state_save_register_global(machine, blitter.dst_inc_x);
749   state_save_register_global(machine, blitter.dst_inc_y);
750   state_save_register_global(machine, blitter.src);
751   state_save_register_global(machine, blitter.dst);
752   state_save_register_global(machine, blitter.endmask1);
753   state_save_register_global(machine, blitter.endmask2);
754   state_save_register_global(machine, blitter.endmask3);
755   state_save_register_global(machine, blitter.xcount);
756   state_save_register_global(machine, blitter.ycount);
757   state_save_register_global(machine, blitter.xcountl);
758   state_save_register_global(machine, blitter.hop);
759   state_save_register_global(machine, blitter.op);
760   state_save_register_global(machine, blitter.ctrl);
761   state_save_register_global(machine, blitter.skew);
836   atarist_set_screen_parameters(machine);
762837
763   atarist_set_screen_parameters();
764
765838   VIDEO_START_CALL(generic_bitmapped);
766839}
src/mess/includes/atarist.h
r3783r3784
11#ifndef __ATARI_ST__
22#define __ATARI_ST__
33
4#define SCREEN_TAG   "main"
45#define MC68901_TAG   "mc68901"
56#define LMC1992_TAG "lmc1992"
67
r3783r3784
1415#define Y200   XTAL_2_4576MHz
1516#define Y700   XTAL_10MHz
1617
18#define ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST   0x04
19#define ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO   0x02
20#define ATARIST_FLOPPY_STATUS_DMA_ERROR         0x01
21
22#define ATARIST_FLOPPY_MODE_WRITE            0x0100
23#define ATARIST_FLOPPY_MODE_FDC_ACCESS         0x0080
24#define ATARIST_FLOPPY_MODE_DMA_DISABLE         0x0040
25#define ATARIST_FLOPPY_MODE_SECTOR_COUNT      0x0010
26#define ATARIST_FLOPPY_MODE_HDC               0x0008
27#define ATARIST_FLOPPY_MODE_ADDRESS_MASK      0x0006
28
29#define ATARIST_FLOPPY_BYTES_PER_SECTOR         512
30
31enum
32{
33   IKBD_MOUSE_PHASE_STATIC = 0,
34   IKBD_MOUSE_PHASE_POSITIVE,
35   IKBD_MOUSE_PHASE_NEGATIVE
36};
37
1738typedef struct _atarist_state atarist_state;
1839struct _atarist_state
1940{
20   int dummy;   /* appease compiler */
41   /* memory state */
42   UINT8 mmu;
43   UINT16 megaste_cache;
44
45   /* keyboard state */
46   UINT8 ikbd_keylatch;
47   UINT8 ikbd_mouse_x;
48   UINT8 ikbd_mouse_y;
49   UINT8 ikbd_mouse_px;
50   UINT8 ikbd_mouse_py;
51   UINT8 ikbd_mouse_pc;
52   int acia_irq;
53
54   /* floppy state */
55   UINT32 fdc_dmabase;
56   UINT16 fdc_status;
57   UINT16 fdc_mode;
58   UINT8 fdc_sectors;
59   int fdc_dmabytes;
60   int fdc_irq;
61
62   /* shifter state */
63   UINT32 shifter_base;
64   UINT32 shifter_ofs;
65   UINT8 shifter_sync;
66   UINT8 shifter_mode;
67   UINT16 shifter_palette[16];
68   UINT8 shifter_lineofs;  // STe
69   UINT8 shifter_pixelofs; // STe
70   UINT16 shifter_rr[4];
71   UINT16 shifter_ir[4];
72   int shifter_bitplane;
73   int shifter_shift;
74   int shifter_h;
75   int shifter_v;
76   int shifter_de;
77   int shifter_x_start;
78   int shifter_x_end;
79   int shifter_y_start;
80   int shifter_y_end;
81   int shifter_hblank_start;
82   int shifter_vblank_start;
83
84   /* blitter state */
85   UINT16 blitter_halftone[16];
86   INT16 blitter_src_inc_x;
87   INT16 blitter_src_inc_y;
88   INT16 blitter_dst_inc_x;
89   INT16 blitter_dst_inc_y;
90   UINT32 blitter_src;
91   UINT32 blitter_dst;
92   UINT16 blitter_endmask1;
93   UINT16 blitter_endmask2;
94   UINT16 blitter_endmask3;
95   UINT16 blitter_xcount;
96   UINT16 blitter_ycount;
97   UINT16 blitter_xcountl;
98   UINT8 blitter_hop;
99   UINT8 blitter_op;
100   UINT8 blitter_ctrl;
101   UINT8 blitter_skew;
102   UINT32 blitter_srcbuf;
103
104   /* microwire state */
105   UINT16 mw_data;
106   UINT16 mw_mask;
107   int mw_shift;
108
109   /* DMA sound state */
110   UINT32 dmasnd_base;
111   UINT32 dmasnd_end;
112   UINT32 dmasnd_cntr;
113   UINT32 dmasnd_baselatch;
114   UINT32 dmasnd_endlatch;
115   UINT16 dmasnd_ctrl;
116   UINT16 dmasnd_mode;
117   UINT8 dmasnd_fifo[8];
118   UINT8 dmasnd_samples;
119   int dmasnd_active;
120
121   /* devices */
122   const device_config *mc68901;
123   const device_config *lmc1992;
124
125   /* timers */
126   emu_timer *glue_timer;
127   emu_timer *shifter_timer;
128   emu_timer *microwire_timer;
129   emu_timer *dmasound_timer;
21130};
22131
23132#endif
src/mess/drivers/atarist.c
r3783r3784
2020
2121    TODO:
2222
23   - move static variables to driver state
2324    - fix floppy interface
2425    - fix mouse
2526    - MSA disk image support
r3783r3784
3536
3637*/
3738
39static UINT8 mfp_rx, mfp_tx;
40static UINT8 ikbd_rx, ikbd_tx;
41static UINT8 acia_midi_rx = 1, acia_midi_tx = 1;
42
3843/* Floppy Disk Controller */
3944
40#define ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST   0x04
41#define ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO   0x02
42#define ATARIST_FLOPPY_STATUS_DMA_ERROR         0x01
43
44#define ATARIST_FLOPPY_MODE_WRITE            0x0100
45#define ATARIST_FLOPPY_MODE_FDC_ACCESS         0x0080
46#define ATARIST_FLOPPY_MODE_DMA_DISABLE         0x0040
47#define ATARIST_FLOPPY_MODE_SECTOR_COUNT      0x0010
48#define ATARIST_FLOPPY_MODE_HDC               0x0008
49#define ATARIST_FLOPPY_MODE_ADDRESS_MASK      0x0006
50
51#define ATARIST_FLOPPY_BYTES_PER_SECTOR         512
52
53static struct FDC
54{
55   UINT32 dmabase;
56   UINT16 status, mode;
57   UINT8 sectors;
58   int dmabytes;
59   int irq;
60} fdc;
61
6245static void atarist_fdc_dma_transfer(running_machine *machine)
6346{
64   UINT8 *RAM = memory_region(machine, "main");
47   const address_space *program = cputag_get_address_space(machine, "main", ADDRESS_SPACE_PROGRAM);
48   atarist_state *state = machine->driver_data;
6549
66   if ((fdc.mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0)
50   if ((state->fdc_mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0)
6751   {
68      while (fdc.sectors > 0)
52      while (state->fdc_sectors > 0)
6953      {
70         if (fdc.mode & ATARIST_FLOPPY_MODE_WRITE)
54         if (state->fdc_mode & ATARIST_FLOPPY_MODE_WRITE)
7155         {
72            wd17xx_data_w(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, RAM[fdc.dmabase]);
56            UINT8 data = memory_read_byte_8be(program, state->fdc_dmabase);
57
58            wd17xx_data_w(program, 0, data);
7359         }
7460         else
7561         {
76            RAM[fdc.dmabase] = wd17xx_data_r(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0);
62            UINT8 data = wd17xx_data_r(program, 0);
63
64            memory_write_byte_8be(program, state->fdc_dmabase, data);
7765         }
7866
79         fdc.dmabase++;
80         fdc.dmabytes--;
67         state->fdc_dmabase++;
68         state->fdc_dmabytes--;
8169
82         if (fdc.dmabytes == 0)
70         if (state->fdc_dmabytes == 0)
8371         {
84            fdc.sectors--;
72            state->fdc_sectors--;
8573
86            if (fdc.sectors == 0)
74            if (state->fdc_sectors == 0)
8775            {
88               fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
76               state->fdc_status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
8977            }
9078            else
9179            {
92               fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
80               state->fdc_dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
9381            }
9482         }
9583      }
r3783r3784
9886
9987static void atarist_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param)
10088{
89   atarist_state *state = machine->driver_data;
90
10191   switch (event)
10292   {
10393   case WD17XX_IRQ_SET:
104      fdc.irq = 1;
94      state->fdc_irq = 1;
10595      break;
10696
10797   case WD17XX_IRQ_CLR:
108      fdc.irq = 0;
98      state->fdc_irq = 0;
10999      break;
110100
111101   case WD17XX_DRQ_SET:
112      fdc.status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
102      state->fdc_status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
113103      atarist_fdc_dma_transfer(machine);
114104      break;
115105
116106   case WD17XX_DRQ_CLR:
117      fdc.status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
107      state->fdc_status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
118108      break;
119109   }
120110}
121111
122112static READ16_HANDLER( atarist_fdc_data_r )
123113{
124   if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
114   atarist_state *state = space->machine->driver_data;
115
116   if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
125117   {
126      return fdc.sectors;
118      return state->fdc_sectors;
127119   }
128120   else
129121   {
130      if (fdc.mode & ATARIST_FLOPPY_MODE_HDC)
122      if (state->fdc_mode & ATARIST_FLOPPY_MODE_HDC)
131123      {
132124         // HDC not implemented
133         fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
125         state->fdc_status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
134126
135127         return 0;
136128      }
137129      else
138130      {
139         return wd17xx_r(space, (fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1);
131         return wd17xx_r(space, (state->fdc_mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1);
140132      }
141133   }
142134}
143135
144136static WRITE16_HANDLER( atarist_fdc_data_w )
145137{
146   if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
138   atarist_state *state = space->machine->driver_data;
139
140   if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
147141   {
148142      if (data == 0)
149143      {
150         fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
144         state->fdc_status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
151145      }
152146      else
153147      {
154         fdc.status |= ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
148         state->fdc_status |= ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
155149      }
156150
157      fdc.sectors = data;
151      state->fdc_sectors = data;
158152   }
159153   else
160154   {
161      if (fdc.mode & ATARIST_FLOPPY_MODE_HDC)
155      if (state->fdc_mode & ATARIST_FLOPPY_MODE_HDC)
162156      {
163157         // HDC not implemented
164         fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
158         state->fdc_status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
165159      }
166160      else
167161      {
168         wd17xx_w(space, (fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1, data);
162         wd17xx_w(space, (state->fdc_mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1, data);
169163      }
170164   }
171165}
172166
173167static READ16_HANDLER( atarist_fdc_dma_status_r )
174168{
175   return fdc.status;
169   atarist_state *state = space->machine->driver_data;
170
171   return state->fdc_status;
176172}
177173
178174static WRITE16_HANDLER( atarist_fdc_dma_mode_w )
179175{
180   if ((data & ATARIST_FLOPPY_MODE_WRITE) != (fdc.mode & ATARIST_FLOPPY_MODE_WRITE))
176   atarist_state *state = space->machine->driver_data;
177
178   if ((data & ATARIST_FLOPPY_MODE_WRITE) != (state->fdc_mode & ATARIST_FLOPPY_MODE_WRITE))
181179   {
182      fdc.status = 0;
183      fdc.sectors = 0;
180      state->fdc_status = 0;
181      state->fdc_sectors = 0;
184182   }
185183
186   fdc.mode = data;
184   state->fdc_mode = data;
187185}
188186
189187static READ16_HANDLER( atarist_fdc_dma_base_r )
190188{
189   atarist_state *state = space->machine->driver_data;
190
191191   switch (offset)
192192   {
193193   case 0:
194      return (fdc.dmabase >> 16) & 0xff;
194      return (state->fdc_dmabase >> 16) & 0xff;
195195   case 1:
196      return (fdc.dmabase >> 8) & 0xff;
196      return (state->fdc_dmabase >> 8) & 0xff;
197197   case 2:
198      return fdc.dmabase & 0xff;
198      return state->fdc_dmabase & 0xff;
199199   }
200200
201201   return 0;
r3783r3784
203203
204204static WRITE16_HANDLER( atarist_fdc_dma_base_w )
205205{
206   atarist_state *state = space->machine->driver_data;
207
206208   switch (offset)
207209   {
208210   case 0:
209      fdc.dmabase = (fdc.dmabase & 0x00ffff) | ((data & 0xff) << 16);
211      state->fdc_dmabase = (state->fdc_dmabase & 0x00ffff) | ((data & 0xff) << 16);
210212      break;
211213   case 1:
212      fdc.dmabase = (fdc.dmabase & 0x0000ff) | ((data & 0xff) << 8);
214      state->fdc_dmabase = (state->fdc_dmabase & 0x0000ff) | ((data & 0xff) << 8);
213215      break;
214216   case 2:
215      fdc.dmabase = data & 0xff;
217      state->fdc_dmabase = data & 0xff;
216218      break;
217219   }
218220
219   fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
221   state->fdc_dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
220222}
221223
222224/* MMU */
223225
224static int mmu;
225
226226static READ16_HANDLER( atarist_mmu_r )
227227{
228   return mmu;
228   atarist_state *state = space->machine->driver_data;
229
230   return state->mmu;
229231}
230232
231233static WRITE16_HANDLER( atarist_mmu_w )
232234{
233   mmu = data & 0xff;
235   atarist_state *state = space->machine->driver_data;
236
237   state->mmu = data & 0xff;
234238}
235239
236240/* IKBD */
237241
238static struct IKBD
239{
240   UINT8 keylatch;
241   UINT8 mouse_x, mouse_y;
242   UINT8 mouse_px, mouse_py, mouse_pc;
243   UINT8 rx, tx;
244} ikbd;
245
246242static const int IKBD_MOUSE_XYA[3][4] = { { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 } };
247243static const int IKBD_MOUSE_XYB[3][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 } };
248244
249enum
250{
251   IKBD_MOUSE_PHASE_STATIC = 0,
252   IKBD_MOUSE_PHASE_POSITIVE,
253   IKBD_MOUSE_PHASE_NEGATIVE
254};
255
256245static READ8_HANDLER( ikbd_port1_r )
257246{
258247   /*
r3783r3784
270259
271260    */
272261
273   return ikbd.keylatch;
262   atarist_state *state = space->machine->driver_data;
263
264   return state->ikbd_keylatch;
274265}
275266
276267static READ8_HANDLER( ikbd_port2_r )
r3783r3784
287278
288279    */
289280
290   return (ikbd.tx << 3) | (input_port_read_safe(space->machine, "IKBD_JOY1", 0xff) & 0x06);
281   atarist_state *state = space->machine->driver_data;
282
283   return (ikbd_tx << 3) | (input_port_read_safe(space->machine, "IKBD_JOY1", 0xff) & 0x06);
291284}
292285
293286static WRITE8_HANDLER( ikbd_port2_w )
r3783r3784
304297
305298    */
306299
307   ikbd.rx = (data & 0x10) >> 4;
300   atarist_state *state = space->machine->driver_data;
301
302   ikbd_rx = (data & 0x10) >> 4;
308303}
309304
310305static WRITE8_HANDLER( ikbd_port3_w )
r3783r3784
324319
325320    */
326321
322   atarist_state *state = space->machine->driver_data;
323
327324   set_led_status(1, data & 0x01);
328325
329   if (~data & 0x02) ikbd.keylatch = input_port_read(space->machine, "P31");
330   if (~data & 0x04) ikbd.keylatch = input_port_read(space->machine, "P32");
331   if (~data & 0x08) ikbd.keylatch = input_port_read(space->machine, "P33");
332   if (~data & 0x10) ikbd.keylatch = input_port_read(space->machine, "P34");
333   if (~data & 0x20) ikbd.keylatch = input_port_read(space->machine, "P35");
334   if (~data & 0x40) ikbd.keylatch = input_port_read(space->machine, "P36");
335   if (~data & 0x80) ikbd.keylatch = input_port_read(space->machine, "P37");
326   if (~data & 0x02) state->ikbd_keylatch = input_port_read(space->machine, "P31");
327   if (~data & 0x04) state->ikbd_keylatch = input_port_read(space->machine, "P32");
328   if (~data & 0x08) state->ikbd_keylatch = input_port_read(space->machine, "P33");
329   if (~data & 0x10) state->ikbd_keylatch = input_port_read(space->machine, "P34");
330   if (~data & 0x20) state->ikbd_keylatch = input_port_read(space->machine, "P35");
331   if (~data & 0x40) state->ikbd_keylatch = input_port_read(space->machine, "P36");
332   if (~data & 0x80) state->ikbd_keylatch = input_port_read(space->machine, "P37");
336333}
337334
338335static READ8_HANDLER( ikbd_port4_r )
r3783r3784
352349
353350    */
354351
352   atarist_state *state = space->machine->driver_data;
353
355354   if (input_port_read(space->machine, "config") & 0x01)
356355   {
357356      /*
r3783r3784
367366      UINT8 x = input_port_read_safe(space->machine, "IKBD_MOUSEX", 0x00);
368367      UINT8 y = input_port_read_safe(space->machine, "IKBD_MOUSEY", 0x00);
369368
370      if (x == ikbd.mouse_x)
369      if (x == state->ikbd_mouse_x)
371370      {
372         ikbd.mouse_px = IKBD_MOUSE_PHASE_STATIC;
371         state->ikbd_mouse_px = IKBD_MOUSE_PHASE_STATIC;
373372      }
374      else if (x > ikbd.mouse_x)
373      else if (x > state->ikbd_mouse_x)
375374      {
376         ikbd.mouse_px = IKBD_MOUSE_PHASE_POSITIVE;
375         state->ikbd_mouse_px = IKBD_MOUSE_PHASE_POSITIVE;
377376      }
378      else if (x < ikbd.mouse_x)
377      else if (x < state->ikbd_mouse_x)
379378      {
380         ikbd.mouse_px = IKBD_MOUSE_PHASE_NEGATIVE;
379         state->ikbd_mouse_px = IKBD_MOUSE_PHASE_NEGATIVE;
381380      }
382381
383      if (y == ikbd.mouse_y)
382      if (y == state->ikbd_mouse_y)
384383      {
385         ikbd.mouse_py = IKBD_MOUSE_PHASE_STATIC;
384         state->ikbd_mouse_py = IKBD_MOUSE_PHASE_STATIC;
386385      }
387      else if (y > ikbd.mouse_y)
386      else if (y > state->ikbd_mouse_y)
388387      {
389         ikbd.mouse_py = IKBD_MOUSE_PHASE_POSITIVE;
388         state->ikbd_mouse_py = IKBD_MOUSE_PHASE_POSITIVE;
390389      }
391      else if (y < ikbd.mouse_y)
390      else if (y < state->ikbd_mouse_y)
392391      {
393         ikbd.mouse_py = IKBD_MOUSE_PHASE_NEGATIVE;
392         state->ikbd_mouse_py = IKBD_MOUSE_PHASE_NEGATIVE;
394393      }
395394
396      data |= IKBD_MOUSE_XYB[ikbd.mouse_px][ikbd.mouse_pc];      // XB
397      data |= IKBD_MOUSE_XYA[ikbd.mouse_px][ikbd.mouse_pc] << 1; // XA
398      data |= IKBD_MOUSE_XYA[ikbd.mouse_py][ikbd.mouse_pc] << 2; // YA
399      data |= IKBD_MOUSE_XYB[ikbd.mouse_py][ikbd.mouse_pc] << 3; // YB
395      data |= IKBD_MOUSE_XYB[state->ikbd_mouse_px][state->ikbd_mouse_pc];      // XB
396      data |= IKBD_MOUSE_XYA[state->ikbd_mouse_px][state->ikbd_mouse_pc] << 1; // XA
397      data |= IKBD_MOUSE_XYA[state->ikbd_mouse_py][state->ikbd_mouse_pc] << 2; // YA
398      data |= IKBD_MOUSE_XYB[state->ikbd_mouse_py][state->ikbd_mouse_pc] << 3; // YB
400399
401      ikbd.mouse_pc++;
400      state->ikbd_mouse_pc++;
402401
403      if (ikbd.mouse_pc == 4)
402      if (state->ikbd_mouse_pc == 4)
404403      {
405         ikbd.mouse_pc = 0;
404         state->ikbd_mouse_pc = 0;
406405      }
407406
408      ikbd.mouse_x = x;
409      ikbd.mouse_y = y;
407      state->ikbd_mouse_x = x;
408      state->ikbd_mouse_y = y;
410409
411410      return data;
412411   }
r3783r3784
433432
434433    */
435434
436   if (~data & 0x01) ikbd.keylatch = input_port_read(space->machine, "P40");
437   if (~data & 0x02) ikbd.keylatch = input_port_read(space->machine, "P41");
438   if (~data & 0x04) ikbd.keylatch = input_port_read(space->machine, "P42");
439   if (~data & 0x08) ikbd.keylatch = input_port_read(space->machine, "P43");
440   if (~data & 0x10) ikbd.keylatch = input_port_read(space->machine, "P44");
441   if (~data & 0x20) ikbd.keylatch = input_port_read(space->machine, "P45");
442   if (~data & 0x40) ikbd.keylatch = input_port_read(space->machine, "P46");
443   if (~data & 0x80) ikbd.keylatch = input_port_read(space->machine, "P47");
435   atarist_state *state = space->machine->driver_data;
436
437   if (~data & 0x01) state->ikbd_keylatch = input_port_read(space->machine, "P40");
438   if (~data & 0x02) state->ikbd_keylatch = input_port_read(space->machine, "P41");
439   if (~data & 0x04) state->ikbd_keylatch = input_port_read(space->machine, "P42");
440   if (~data & 0x08) state->ikbd_keylatch = input_port_read(space->machine, "P43");
441   if (~data & 0x10) state->ikbd_keylatch = input_port_read(space->machine, "P44");
442   if (~data & 0x20) state->ikbd_keylatch = input_port_read(space->machine, "P45");
443   if (~data & 0x40) state->ikbd_keylatch = input_port_read(space->machine, "P46");
444   if (~data & 0x80) state->ikbd_keylatch = input_port_read(space->machine, "P47");
444445}
445446
446447/* DMA Sound */
447448
448static struct DMASOUND
449{
450   UINT32 base, end, cntr;
451   UINT32 baselatch, endlatch;
452   UINT16 ctrl, mode;
453   UINT8 fifo[8];
454   UINT8 samples;
455   int active;
456} dmasound;
457
458449static const int DMASOUND_RATE[] = { Y2/640/8, Y2/640/4, Y2/640/2, Y2/640 };
459450
460static emu_timer *dmasound_timer;
461
462451static void atariste_dmasound_set_state(running_machine *machine, int level)
463452{
464   const device_config *mc68901 = device_list_find_by_tag(machine->config->devicelist, MC68901, MC68901_TAG);
453   atarist_state *state = machine->driver_data;
465454
466   dmasound.active = level;
467   mc68901_tai_w(mc68901, level);
455   state->dmasnd_active = level;
456   mc68901_tai_w(state->mc68901, level);
468457
469458   if (level == 0)
470459   {
471      dmasound.baselatch = dmasound.base;
472      dmasound.endlatch = dmasound.end;
460      state->dmasnd_baselatch = state->dmasnd_base;
461      state->dmasnd_endlatch = state->dmasnd_end;
473462   }
474463   else
475464   {
476      dmasound.cntr = dmasound.baselatch;
465      state->dmasnd_cntr = state->dmasnd_baselatch;
477466   }
478467}
479468
480469static TIMER_CALLBACK( atariste_dmasound_tick )
481470{
482   if (dmasound.samples == 0)
471   atarist_state *state = machine->driver_data;
472
473   if (state->dmasnd_samples == 0)
483474   {
484475      int i;
485476      UINT8 *RAM = memory_region(machine, "main");
486477
487478      for (i = 0; i < 8; i++)
488479      {
489         dmasound.fifo[i] = RAM[dmasound.cntr];
490         dmasound.cntr++;
491         dmasound.samples++;
480         state->dmasnd_fifo[i] = RAM[state->dmasnd_cntr];
481         state->dmasnd_cntr++;
482         state->dmasnd_samples++;
492483
493         if (dmasound.cntr == dmasound.endlatch)
484         if (state->dmasnd_cntr == state->dmasnd_endlatch)
494485         {
495486            atariste_dmasound_set_state(machine, 0);
496487            break;
r3783r3784
498489      }
499490   }
500491
501   if (dmasound.ctrl & 0x80)
492   if (state->dmasnd_ctrl & 0x80)
502493   {
503//      logerror("DMA sound left  %i\n", dmasound.fifo[7 - dmasound.samples]);
504      dmasound.samples--;
494//      logerror("DMA sound left  %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]);
495      state->dmasnd_samples--;
505496
506//      logerror("DMA sound right %i\n", dmasound.fifo[7 - dmasound.samples]);
507      dmasound.samples--;
497//      logerror("DMA sound right %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]);
498      state->dmasnd_samples--;
508499   }
509500   else
510501   {
511//      logerror("DMA sound mono %i\n", dmasound.fifo[7 - dmasound.samples]);
512      dmasound.samples--;
502//      logerror("DMA sound mono %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]);
503      state->dmasnd_samples--;
513504   }
514505
515   if ((dmasound.samples == 0) && (dmasound.active == 0))
506   if ((state->dmasnd_samples == 0) && (state->dmasnd_active == 0))
516507   {
517      if ((dmasound.ctrl & 0x03) == 0x03)
508      if ((state->dmasnd_ctrl & 0x03) == 0x03)
518509      {
519510         atariste_dmasound_set_state(machine, 1);
520511      }
521512      else
522513      {
523         timer_enable(dmasound_timer, 0);
514         timer_enable(state->dmasound_timer, 0);
524515      }
525516   }
526517}
527518
528519static READ16_HANDLER( atariste_sound_dma_control_r )
529520{
530   return dmasound.ctrl;
521   atarist_state *state = space->machine->driver_data;
522
523   return state->dmasnd_ctrl;
531524}
532525
533526static READ16_HANDLER( atariste_sound_dma_base_r )
534527{
528   atarist_state *state = space->machine->driver_data;
529
535530   switch (offset)
536531   {
537532   case 0x00:
538      return (dmasound.base >> 16) & 0x3f;
533      return (state->dmasnd_base >> 16) & 0x3f;
539534   case 0x01:
540      return (dmasound.base >> 8) & 0xff;
535      return (state->dmasnd_base >> 8) & 0xff;
541536   case 0x02:
542      return dmasound.base & 0xff;
537      return state->dmasnd_base & 0xff;
543538   }
544539
545540   return 0;
r3783r3784
547542
548543static READ16_HANDLER( atariste_sound_dma_counter_r )
549544{
545   atarist_state *state = space->machine->driver_data;
546
550547   switch (offset)
551548   {
552549   case 0x00:
553      return (dmasound.cntr >> 16) & 0x3f;
550      return (state->dmasnd_cntr >> 16) & 0x3f;
554551   case 0x01:
555      return (dmasound.cntr >> 8) & 0xff;
552      return (state->dmasnd_cntr >> 8) & 0xff;
556553   case 0x02:
557      return dmasound.cntr & 0xff;
554      return state->dmasnd_cntr & 0xff;
558555   }
559556
560557   return 0;
r3783r3784
562559
563560static READ16_HANDLER( atariste_sound_dma_end_r )
564561{
562   atarist_state *state = space->machine->driver_data;
563
565564   switch (offset)
566565   {
567566   case 0x00:
568      return (dmasound.end >> 16) & 0x3f;
567      return (state->dmasnd_end >> 16) & 0x3f;
569568   case 0x01:
570      return (dmasound.end >> 8) & 0xff;
569      return (state->dmasnd_end >> 8) & 0xff;
571570   case 0x02:
572      return dmasound.end & 0xff;
571      return state->dmasnd_end & 0xff;
573572   }
574573
575574   return 0;
r3783r3784
577576
578577static READ16_HANDLER( atariste_sound_mode_r )
579578{
580   return dmasound.mode;
579   atarist_state *state = space->machine->driver_data;
580
581   return state->dmasnd_mode;
581582}
582583
583584static WRITE16_HANDLER( atariste_sound_dma_control_w )
584585{
585   dmasound.ctrl = data & 0x03;
586   atarist_state *state = space->machine->driver_data;
586587
587   if (dmasound.ctrl & 0x01)
588   state->dmasnd_ctrl = data & 0x03;
589
590   if (state->dmasnd_ctrl & 0x01)
588591   {
589      if (!dmasound.active)
592      if (!state->dmasnd_active)
590593      {
591594         atariste_dmasound_set_state(space->machine, 1);
592         timer_adjust_periodic(dmasound_timer, attotime_zero, 0, ATTOTIME_IN_HZ(DMASOUND_RATE[dmasound.mode & 0x03]));
595         timer_adjust_periodic(state->dmasound_timer, attotime_zero, 0, ATTOTIME_IN_HZ(DMASOUND_RATE[state->dmasnd_mode & 0x03]));
593596      }
594597   }
595598   else
596599   {
597600      atariste_dmasound_set_state(space->machine, 0);
598      timer_enable(dmasound_timer, 0);
601      timer_enable(state->dmasound_timer, 0);
599602   }
600603}
601604
602605static WRITE16_HANDLER( atariste_sound_dma_base_w )
603606{
607   atarist_state *state = space->machine->driver_data;
608
604609   switch (offset)
605610   {
606611   case 0x00:
607      dmasound.base = (data << 16) & 0x3f0000;
612      state->dmasnd_base = (data << 16) & 0x3f0000;
608613      break;
609614   case 0x01:
610      dmasound.base = (dmasound.base & 0x3f00fe) | (data & 0xff) << 8;
615      state->dmasnd_base = (state->dmasnd_base & 0x3f00fe) | (data & 0xff) << 8;
611616      break;
612617   case 0x02:
613      dmasound.base = (dmasound.base & 0x3fff00) | (data & 0xfe);
618      state->dmasnd_base = (state->dmasnd_base & 0x3fff00) | (data & 0xfe);
614619      break;
615620   }
616621
617   if (!dmasound.active)
622   if (!state->dmasnd_active)
618623   {
619      dmasound.baselatch = dmasound.base;
624      state->dmasnd_baselatch = state->dmasnd_base;
620625   }
621626}
622627
623628static WRITE16_HANDLER( atariste_sound_dma_end_w )
624629{
630   atarist_state *state = space->machine->driver_data;
631
625632   switch (offset)
626633   {
627634   case 0x00:
628      dmasound.end = (data << 16) & 0x3f0000;
635      state->dmasnd_end = (data << 16) & 0x3f0000;
629636      break;
630637   case 0x01:
631      dmasound.end = (dmasound.end & 0x3f00fe) | (data & 0xff) << 8;
638      state->dmasnd_end = (state->dmasnd_end & 0x3f00fe) | (data & 0xff) << 8;
632639      break;
633640   case 0x02:
634      dmasound.end = (dmasound.end & 0x3fff00) | (data & 0xfe);
641      state->dmasnd_end = (state->dmasnd_end & 0x3fff00) | (data & 0xfe);
635642      break;
636643   }
637644
638   if (!dmasound.active)
645   if (!state->dmasnd_active)
639646   {
640      dmasound.endlatch = dmasound.end;
647      state->dmasnd_endlatch = state->dmasnd_end;
641648   }
642649}
643650
644651static WRITE16_HANDLER( atariste_sound_mode_w )
645652{
646   dmasound.mode = data & 0x8f;
653   atarist_state *state = space->machine->driver_data;
654
655   state->dmasnd_mode = data & 0x8f;
647656}
648657
649658/* Microwire */
650659
651static struct MICROWIRE
652{
653   UINT16 data, mask;
654   int shift;
655} mwire;
656
657static emu_timer *microwire_timer;
658
659660static void atariste_microwire_shift(running_machine *machine)
660661{
661   const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG);
662   atarist_state *state = machine->driver_data;
662663
663   if (BIT(mwire.mask, 15))
664   if (BIT(state->mw_mask, 15))
664665   {
665      lmc1992_data_w(lmc1992, BIT(mwire.data, 15));
666      lmc1992_clock_w(lmc1992, 1);
667      lmc1992_clock_w(lmc1992, 0);
666      lmc1992_data_w(state->lmc1992, BIT(state->mw_data, 15));
667      lmc1992_clock_w(state->lmc1992, 1);
668      lmc1992_clock_w(state->lmc1992, 0);
668669   }
669670
670671   // rotate mask and data left
671672
672   mwire.mask = (mwire.mask << 1) | BIT(mwire.mask, 15);
673   mwire.data = (mwire.data << 1) | BIT(mwire.data, 15);
674   mwire.shift++;
673   state->mw_mask = (state->mw_mask << 1) | BIT(state->mw_mask, 15);
674   state->mw_data = (state->mw_data << 1) | BIT(state->mw_data, 15);
675   state->mw_shift++;
675676}
676677
677678static TIMER_CALLBACK( atariste_microwire_tick )
678679{
679   const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG);
680   atarist_state *state = machine->driver_data;
680681
681   switch (mwire.shift)
682   switch (state->mw_shift)
682683   {
683684   case 0:
684      lmc1992_enable_w(lmc1992, 0);
685      lmc1992_enable_w(state->lmc1992, 0);
685686      atariste_microwire_shift(machine);
686687      break;
687688
r3783r3784
691692
692693   case 15:
693694      atariste_microwire_shift(machine);
694      lmc1992_enable_w(lmc1992, 1);
695      mwire.shift = 0;
696      timer_enable(microwire_timer, 0);
695      lmc1992_enable_w(state->lmc1992, 1);
696      state->mw_shift = 0;
697      timer_enable(state->microwire_timer, 0);
697698      break;
698699   }
699700}
700701
701702static READ16_HANDLER( atariste_microwire_data_r )
702703{
703   return mwire.data;
704   atarist_state *state = space->machine->driver_data;
705
706   return state->mw_data;
704707}
705708
706709static WRITE16_HANDLER( atariste_microwire_data_w )
707710{
708   if (!timer_enabled(microwire_timer))
711   atarist_state *state = space->machine->driver_data;
712
713   if (!timer_enabled(state->microwire_timer))
709714   {
710      mwire.data = data;
711      timer_adjust_periodic(microwire_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2));
715      state->mw_data = data;
716      timer_adjust_periodic(state->microwire_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2));
712717   }
713718}
714719
715720static READ16_HANDLER( atariste_microwire_mask_r )
716721{
717   return mwire.mask;
722   atarist_state *state = space->machine->driver_data;
723
724   return state->mw_mask;
718725}
719726
720727static WRITE16_HANDLER( atariste_microwire_mask_w )
721728{
722   if (!timer_enabled(microwire_timer))
729   atarist_state *state = space->machine->driver_data;
730
731   if (!timer_enabled(state->microwire_timer))
723732   {
724      mwire.mask = data;
733      state->mw_mask = data;
725734   }
726735}
727736
728737/* Mega STe Cache */
729738
730static UINT16 megaste_cache;
731
732739static READ16_HANDLER( megaste_cache_r )
733740{
734   return megaste_cache;
741   atarist_state *state = space->machine->driver_data;
742
743   return state->megaste_cache;
735744}
736745
737746static WRITE16_HANDLER( megaste_cache_w )
738747{
739   megaste_cache = data;
740   cpu_set_clock(space->machine->cpu[0], (data & 0x01) ? Y2/2 : Y2/4);
748   atarist_state *state = space->machine->driver_data;
749
750   state->megaste_cache = data;
751
752   cpu_set_clock(space->machine->cpu[0], BIT(data, 0) ? Y2/2 : Y2/4);
741753}
742754
743755/* ST Book */
r3783r3784
12661278
12671279static WRITE8_HANDLER( ym2149_port_a_w )
12681280{
1269   wd17xx_set_side((data & 0x01) ? 0 : 1);
1281   wd17xx_set_side(BIT(data, 0) ? 0 : 1);
12701282
1271   if (!(data & 0x02))
1283   if (!BIT(data, 1))
12721284   {
12731285      wd17xx_set_drive(0);
12741286   }
12751287
1276   if (!(data & 0x04))
1288   if (!BIT(data, 2))
12771289   {
12781290      wd17xx_set_drive(1);
12791291   }
r3783r3784
12811293   // 0x08 = RTS
12821294   // 0x10 = DTR
12831295
1284   centronics_write_handshake(0, (data & 0x20) ? 0 : CENTRONICS_STROBE, CENTRONICS_STROBE);
1296   centronics_write_handshake(0, BIT(data, 5) ? 0 : CENTRONICS_STROBE, CENTRONICS_STROBE);
12851297
12861298   // 0x40 = General Purpose Output
12871299   // 0x80 = Reserved
r3783r3784
13041316
13051317/* Machine Drivers */
13061318
1307static int acia_irq;
1308static UINT8 acia_midi_rx = 1, acia_midi_tx = 1;
1309
13101319static void acia_interrupt(const device_config *device, int state)
13111320{
1312   acia_irq = state;
1321   atarist_state *driver_state = device->machine->driver_data;
1322
1323   driver_state->acia_irq = state;
13131324}
13141325
13151326static const acia6850_interface acia_ikbd_intf =
13161327{
13171328   Y2/64,
13181329   Y2/64,
1319   &ikbd.rx,
1320   &ikbd.tx,
1330   &ikbd_rx,
1331   &ikbd_tx,
13211332   NULL,
13221333   NULL,
13231334   NULL,
r3783r3784
13531364
13541365    */
13551366
1367   atarist_state *state = device->machine->driver_data;
1368
13561369   UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7;
13571370
13581371   mc68901_tai_w(device, data & 0x01);
13591372
1360   data |= (acia_irq << 4);
1361   data |= (fdc.irq << 5);
1373   data |= (state->acia_irq << 4);
1374   data |= (state->fdc_irq << 5);
13621375   data |= (input_port_read(device->machine, "config") & 0x80);
13631376
13641377   return data;
r3783r3784
13661379
13671380static IRQ_CALLBACK( atarist_int_ack )
13681381{
1382   atarist_state *state = device->machine->driver_data;
1383
13691384   const device_config *mc68901 = device_list_find_by_tag(device->machine->config->devicelist, MC68901, MC68901_TAG);
13701385
13711386   if (irqline == M68K_IRQ_6)
r3783r3784
13811396   cpu_set_input_line(device->machine->cpu[0], M68K_IRQ_6, level);
13821397}
13831398
1384static UINT8 mfp_rx, mfp_tx;
1385
13861399static MC68901_INTERFACE( mfp_intf )
13871400{
13881401   Y2/8,
r3783r3784
14071420
14081421static void atarist_configure_memory(running_machine *machine)
14091422{
1423   const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
14101424   UINT8 *RAM = memory_region(machine, "main");
14111425
14121426   switch (mess_ram_size)
14131427   {
14141428   case 256 * 1024:
1415      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x03ffff, 0, 0, SMH_BANK1, SMH_BANK1);
1416      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x040000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1429      memory_install_readwrite16_handler(program, 0x000008, 0x03ffff, 0, 0, SMH_BANK1, SMH_BANK1);
1430      memory_install_readwrite16_handler(program, 0x040000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
14171431      break;
14181432   case 512 * 1024:
1419      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x07ffff, 0, 0, SMH_BANK1, SMH_BANK1);
1420      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x080000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1433      memory_install_readwrite16_handler(program, 0x000008, 0x07ffff, 0, 0, SMH_BANK1, SMH_BANK1);
1434      memory_install_readwrite16_handler(program, 0x080000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
14211435      break;
14221436   case 1024 * 1024:
1423      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x0fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1424      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1437      memory_install_readwrite16_handler(program, 0x000008, 0x0fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1438      memory_install_readwrite16_handler(program, 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
14251439      break;
14261440   case 2048 * 1024:
1427      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1428      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1441      memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1442      memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
14291443      break;
14301444   case 4096 * 1024:
1431      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1432      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2);
1445      memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1446      memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2);
14331447      break;
14341448   }
14351449
r3783r3784
14391453   memory_configure_bank(machine, 2, 0, 1, RAM + 0x200000, 0);
14401454   memory_set_bank(machine, 2, 0);
14411455
1442   memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1456   memory_install_readwrite16_handler(program, 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
14431457
14441458   memory_configure_bank(machine, 3, 0, 1, RAM + 0xfa0000, 0);
14451459   memory_set_bank(machine, 3, 0);
r3783r3784
14471461
14481462static void atarist_state_save(running_machine *machine)
14491463{
1450   memset(&fdc, 0, sizeof(fdc));
1464   atarist_state *state = machine->driver_data;
14511465
1452   fdc.status |= ATARIST_FLOPPY_STATUS_DMA_ERROR;
1466   state->fdc_status |= ATARIST_FLOPPY_STATUS_DMA_ERROR;
14531467
1454   memset(&ikbd, 0, sizeof(ikbd));
1455
1456   state_save_register_global(machine, mmu);
1457   state_save_register_global(machine, fdc.dmabase);
1458   state_save_register_global(machine, fdc.status);
1459   state_save_register_global(machine, fdc.mode);
1460   state_save_register_global(machine, fdc.sectors);
1461   state_save_register_global(machine, fdc.dmabytes);
1462   state_save_register_global(machine, fdc.irq);
1463   state_save_register_global(machine, ikbd.keylatch);
1464   state_save_register_global(machine, ikbd.mouse_x);
1465   state_save_register_global(machine, ikbd.mouse_y);
1466   state_save_register_global(machine, ikbd.mouse_px);
1467   state_save_register_global(machine, ikbd.mouse_py);
1468   state_save_register_global(machine, ikbd.mouse_pc);
1469   state_save_register_global(machine, ikbd.rx);
1470   state_save_register_global(machine, ikbd.tx);
1471   state_save_register_global(machine, acia_irq);
1468   state_save_register_global(machine, state->mmu);
1469   state_save_register_global(machine, state->fdc_dmabase);
1470   state_save_register_global(machine, state->fdc_status);
1471   state_save_register_global(machine, state->fdc_mode);
1472   state_save_register_global(machine, state->fdc_sectors);
1473   state_save_register_global(machine, state->fdc_dmabytes);
1474   state_save_register_global(machine, state->fdc_irq);
1475   state_save_register_global(machine, state->ikbd_keylatch);
1476   state_save_register_global(machine, state->ikbd_mouse_x);
1477   state_save_register_global(machine, state->ikbd_mouse_y);
1478   state_save_register_global(machine, state->ikbd_mouse_px);
1479   state_save_register_global(machine, state->ikbd_mouse_py);
1480   state_save_register_global(machine, state->ikbd_mouse_pc);
1481   state_save_register_global(machine, ikbd_rx);
1482   state_save_register_global(machine, ikbd_tx);
1483   state_save_register_global(machine, state->acia_irq);
14721484   state_save_register_global(machine, acia_midi_rx);
14731485   state_save_register_global(machine, acia_midi_tx);
14741486   state_save_register_global(machine, mfp_rx);
r3783r3784
14771489
14781490static MACHINE_START( atarist )
14791491{
1492   atarist_state *state = machine->driver_data;
1493
1494   /* configure RAM banking */
14801495   atarist_configure_memory(machine);
1481   atarist_state_save(machine);
14821496
1497   /* configure devices */
14831498   centronics_config(0, atarist_centronics_config);
14841499   wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL);
14851500
1501   /* set CPU interrupt callback */
14861502   cpu_set_irq_callback(machine->cpu[0], atarist_int_ack);
1503
1504   /* find devices */
1505   state->mc68901 = devtag_get_device(machine, MC68901, MC68901_TAG);
1506
1507   /* register for state saving */
1508   atarist_state_save(machine);
14871509}
14881510
14891511static const struct rp5c15_interface rtc_intf =
r3783r3784
14941516static MACHINE_START( megast )
14951517{
14961518   MACHINE_START_CALL(atarist);
1519
14971520   rp5c15_init(machine, &rtc_intf);
14981521}
14991522
r3783r3784
15141537
15151538    */
15161539
1540   atarist_state *state = device->machine->driver_data;
1541
15171542   UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7;
15181543
1519   data |= (acia_irq << 4);
1520   data |= (fdc.irq << 5);
1521   data |= (input_port_read(device->machine, "config") & 0x80) ^ (dmasound.active << 7);
1544   data |= (state->acia_irq << 4);
1545   data |= (state->fdc_irq << 5);
1546   data |= (input_port_read(device->machine, "config") & 0x80) ^ (state->dmasnd_active << 7);
15221547
15231548   return data;
15241549}
r3783r3784
15391564
15401565static void atariste_state_save(running_machine *machine)
15411566{
1567   atarist_state *state = machine->driver_data;
1568
15421569   atarist_state_save(machine);
15431570
1544   memset(&mwire, 0, sizeof(mwire));
1545   memset(&dmasound, 0, sizeof(dmasound));
1546
1547   state_save_register_global(machine, dmasound.base);
1548   state_save_register_global(machine, dmasound.end);
1549   state_save_register_global(machine, dmasound.cntr);
1550   state_save_register_global(machine, dmasound.baselatch);
1551   state_save_register_global(machine, dmasound.endlatch);
1552   state_save_register_global(machine, dmasound.ctrl);
1553   state_save_register_global(machine, dmasound.mode);
1554   state_save_register_global_array(machine, dmasound.fifo);
1555   state_save_register_global(machine, dmasound.samples);
1556   state_save_register_global(machine, dmasound.active);
1557
1558   state_save_register_global(machine, mwire.data);
1559   state_save_register_global(machine, mwire.mask);
1560   state_save_register_global(machine, mwire.shift);
1571   state_save_register_global(machine, state->dmasnd_base);
1572   state_save_register_global(machine, state->dmasnd_end);
1573   state_save_register_global(machine, state->dmasnd_cntr);
1574   state_save_register_global(machine, state->dmasnd_baselatch);
1575   state_save_register_global(machine, state->dmasnd_endlatch);
1576   state_save_register_global(machine, state->dmasnd_ctrl);
1577   state_save_register_global(machine, state->dmasnd_mode);
1578   state_save_register_global_array(machine, state->dmasnd_fifo);
1579   state_save_register_global(machine, state->dmasnd_samples);
1580   state_save_register_global(machine, state->dmasnd_active);
1581   state_save_register_global(machine, state->mw_data);
1582   state_save_register_global(machine, state->mw_mask);
1583   state_save_register_global(machine, state->mw_shift);
15611584}
15621585
15631586static MACHINE_START( atariste )
15641587{
1588   atarist_state *state = machine->driver_data;
1589
1590   /* configure RAM banking */
15651591   atarist_configure_memory(machine);
1566   atariste_state_save(machine);
15671592
1593   /* configure devices */
15681594   centronics_config(0, atarist_centronics_config);
15691595   wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL);
15701596
1597   /* set CPU interrupt callback */
15711598   cpu_set_irq_callback(machine->cpu[0], atarist_int_ack);
15721599
1573   dmasound_timer = timer_alloc(machine, atariste_dmasound_tick, NULL);
1574   microwire_timer = timer_alloc(machine, atariste_microwire_tick, NULL);
1600   /* allocate timers */
1601   state->dmasound_timer = timer_alloc(machine, atariste_dmasound_tick, NULL);
1602   state->microwire_timer = timer_alloc(machine, atariste_microwire_tick, NULL);
1603
1604   /* find devices */
1605   state->lmc1992 = devtag_get_device(machine, LMC1992, LMC1992_TAG);
1606
1607   /* register for state saving */
1608   atariste_state_save(machine);
15751609}
15761610
15771611static MACHINE_START( megaste )
15781612{
1579   machine_start_atariste(machine);
1580   state_save_register_global(machine, megaste_cache);
1613   atarist_state *state = machine->driver_data;
1614
1615   MACHINE_START_CALL(atariste);
1616
15811617   rp5c15_init(machine, &rtc_intf);
1618
1619   state_save_register_global(machine, state->megaste_cache);
15821620}
15831621
15841622static void stbook_configure_memory(running_machine *machine)
15851623{
1624   const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
15861625   UINT8 *RAM = memory_region(machine, "main");
15871626
15881627   switch (mess_ram_size)
15891628   {
15901629   case 1024 * 1024:
1591      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x07ffff, 0, 0x080000, SMH_BANK1, SMH_BANK1);
1592      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1630      memory_install_readwrite16_handler(program, 0x000008, 0x07ffff, 0, 0x080000, SMH_BANK1, SMH_BANK1);
1631      memory_install_readwrite16_handler(program, 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
15931632      break;
15941633   case 4096 * 1024:
1595      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1596      memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2);
1634      memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1);
1635      memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2);
15971636      break;
15981637   }
15991638
r3783r3784
16031642   memory_configure_bank(machine, 2, 0, 1, RAM + 0x200000, 0);
16041643   memory_set_bank(machine, 2, 0);
16051644
1606   memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
1645   memory_install_readwrite16_handler(program, 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP);
16071646
16081647   memory_configure_bank(machine, 3, 0, 1, RAM + 0xfa0000, 0);
16091648   memory_set_bank(machine, 3, 0);
r3783r3784
16731712
16741713    */
16751714
1715   atarist_state *state = device->machine->driver_data;
1716
16761717   UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7;
16771718
1678   data |= (acia_irq << 4);
1679   data |= (fdc.irq << 5);
1719   data |= (state->acia_irq << 4);
1720   data |= (state->fdc_irq << 5);
16801721
16811722   return data;
16821723}
r3783r3784
16971738
16981739static MACHINE_START( stbook )
16991740{
1741   atarist_state *state = machine->driver_data;
1742
1743   /* configure RAM banking */
17001744   stbook_configure_memory(machine);
1701   atariste_state_save(machine);
17021745
1703   state_save_register_global(machine, krxd);
1704   state_save_register_global(machine, ktxd);
1705
1746   /* configure devices */
17061747   centronics_config(0, atarist_centronics_config);
17071748   wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL);
17081749   rp5c15_init(machine, &rtc_intf);
17091750
1751   /* set CPU interrupt callback */
17101752   cpu_set_irq_callback(machine->cpu[0], atarist_int_ack);
1753
1754   /* find devices */
1755   state->mc68901 = devtag_get_device(machine, MC68901, MC68901_TAG);
1756
1757   /* register for state saving */
1758   atariste_state_save(machine);
1759   state_save_register_global(machine, krxd);
1760   state_save_register_global(machine, ktxd);
17111761}
17121762
17131763static MACHINE_DRIVER_START( atarist )
r3783r3784
20382088   switch(state)
20392089   {
20402090      /* --- the following bits of info are returned as 64-bit signed integers --- */
2041      case MESS_DEVINFO_INT_COUNT:                     info->i = 2; break;
2091      case MESS_DEVINFO_INT_COUNT:               info->i = 2; break;
20422092
20432093      /* --- the following bits of info are returned as pointers to data or functions --- */
2044      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break;
2094      case MESS_DEVINFO_PTR_LOAD:                  info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break;
20452095
20462096      /* --- the following bits of info are returned as NULL-terminated strings --- */
2047      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "st"); break;
2097      case MESS_DEVINFO_STR_FILE_EXTENSIONS:         strcpy(info->s = device_temp_str(), "st"); break;
20482098
20492099      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
20502100   }
r3783r3784
20762126   {
20772127      /* --- the following bits of info are returned as 64-bit signed integers --- */
20782128      case MESS_DEVINFO_INT_TYPE:                     info->i = IO_SERIAL; break;
2079      case MESS_DEVINFO_INT_COUNT:                     info->i = 1; break;
2129      case MESS_DEVINFO_INT_COUNT:                  info->i = 1; break;
20802130
20812131      /* --- the following bits of info are returned as pointers to data or functions --- */
2082      case MESS_DEVINFO_PTR_START:                     info->start = DEVICE_START_NAME(serial_device); break;
2132      case MESS_DEVINFO_PTR_START:                  info->start = DEVICE_START_NAME(serial_device); break;
20832133      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(atarist_serial); break;
20842134      case MESS_DEVINFO_PTR_UNLOAD:                  info->unload = DEVICE_IMAGE_UNLOAD_NAME(serial_device); break;
20852135
r3783r3784
20952145   {
20962146      /* --- the following bits of info are returned as 64-bit signed integers --- */
20972147      case MESS_DEVINFO_INT_TYPE:                     info->i = IO_SERIAL; break;
2098      case MESS_DEVINFO_INT_COUNT:                     info->i = 2; break;
2148      case MESS_DEVINFO_INT_COUNT:                  info->i = 2; break;
20992149
21002150      /* --- the following bits of info are returned as pointers to data or functions --- */
2101      case MESS_DEVINFO_PTR_START:                     info->start = DEVICE_START_NAME(serial_device); break;
2151      case MESS_DEVINFO_PTR_START:                  info->start = DEVICE_START_NAME(serial_device); break;
21022152      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(atarist_serial); break;
21032153      case MESS_DEVINFO_PTR_UNLOAD:                  info->unload = DEVICE_IMAGE_UNLOAD_NAME(serial_device); break;
21042154
r3783r3784
21172167   {
21182168      if (image_fread(image, ptr, filesize) == filesize)
21192169      {
2120         memory_install_readwrite16_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_BANK3, SMH_BANK3);
2170         memory_install_readwrite16_handler(cputag_get_address_space(image->machine, "main", ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_BANK3, SMH_BANK3);
21212171
21222172         return INIT_PASS;
21232173      }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team