Previous 15994 Revisions Next

r1965 Wednesday 12th March, 2008 at 17:22:44 UTC by Dirk Best
[ASTROCDE] Rewrote interrupt handling
[src/mess]mess.mak
[src/mess/drivers]astrocde.c
[src/mess/includes]astrocde.h
[src/mess/machine]astrocde.c
[src/mess/video]astrocde.c

src/mess/includes/astrocde.h
r1964r1965
1111#define XTAL_Y1  XTAL_14_31818MHz
1212
1313
14/*----------- defined in machine/astrocde.c -----------*/
14/*----------- defined in video/astrocde.c -----------*/
1515
16PALETTE_INIT( astrocade );
17
1618WRITE8_HANDLER( astrocade_interrupt_enable_w );
1719WRITE8_HANDLER( astrocade_interrupt_w );
1820WRITE8_HANDLER ( astrocade_interrupt_vector_w );
19MACHINE_RESET( astrocde );
20DRIVER_INIT( astrocde );
2121
22
23/*----------- defined in video/astrocde.c -----------*/
24
25PALETTE_INIT( astrocade );
2622READ8_HANDLER( astrocade_intercept_r );
2723WRITE8_HANDLER( astrocade_magic_expand_color_w );
2824WRITE8_HANDLER( astrocade_magic_control_w );
src/mess/video/astrocde.c
r1964r1965
3434static int LastShifter = 0;
3535static int astrocade_mode = 0;
3636
37static UINT8 interrupt_vector = 0;
38
39static int screen_interrupt_enabled;
40static int screen_interrupt_mode;
41static int screen_interrupt_line = 0;
42
43static int lightpen_interrupt_enabled;
44static int lightpen_interrupt_mode;
45
46
3747/* These are the bits of the Magic Register */
3848static const unsigned char SHIFT_MASK  = 0x03;
3949static const unsigned char ROTATE_MASK = 0x04;
r1964r1965
4252static const unsigned char XOR_MASK    = 0x20;
4353static const unsigned char FLOP_MASK   = 0x40;
4454
45/* ======================================================================= */
4655
47enum { FAKE_BLK,FAKE_YLW,FAKE_BLU,FAKE_RED,FAKE_WHT };
4856
57/*************************************
58 *
59 *  Palette
60 *
61 *************************************/
62
4963PALETTE_INIT( astrocade )
5064{
5165   /* This routine builds a palette using a transformation from */
r1964r1965
112126   }
113127}
114128
115WRITE8_HANDLER( astrocade_vertical_blank_w )
129
130
131/*************************************
132 *
133 *  Interrupts
134 *
135 *************************************/
136
137WRITE8_HANDLER( astrocade_interrupt_enable_w )
116138{
117   VerticalBlank = data;
139   screen_interrupt_enabled = data & 0x08;
140   screen_interrupt_mode = data & 0x04;
141
142   lightpen_interrupt_enabled = data & 0x02;
143   lightpen_interrupt_mode = data & 0x01;
144
145   LOG(("Interrupt Flag set to %02x\n",data & 0x0f));
118146}
119147
120READ8_HANDLER( astrocade_intercept_r )
148
149WRITE8_HANDLER( astrocade_interrupt_w )
121150{
122   int res;
151   /* in low res mode, only bits 1-7 are used */
152   screen_interrupt_line = astrocade_mode ? data : data >> 1;
153   
154   LOG(("Scanline interrupt set to %02x\n", screen_interrupt_line));
155}
123156
124   res = collision;
125   collision = 0;
126157
127   return res;
158WRITE8_HANDLER( astrocade_interrupt_vector_w )
159{
160   interrupt_vector = data;
128161}
129162
130163
131READ8_HANDLER( astrocade_video_retrace_r )
164
165/*************************************
166 *
167 *  VBlank
168 *
169 *************************************/
170
171WRITE8_HANDLER( astrocade_vertical_blank_w )
132172{
133    return video_screen_get_vpos(0);
173   VerticalBlank = data;
134174}
135175
136176
137/* Switches colour registers at this zone - 40 zones */
138/* Also sets the background colors */
139
140WRITE8_HANDLER ( astrocade_colour_split_w )
177READ8_HANDLER( astrocade_video_retrace_r )
141178{
142   ColourSplit = data&0x3f;
179    return video_screen_get_vpos(0);
180}
143181
144   if (astrocade_mode == 1)
145      ColourSplit <<= 1;
146182
147   BackgroundData = ((data&0xc0) >> 6) * 0x55;
148183
149   LOG(("Colour split set to %02d\n",ColourSplit));
150}
184/*************************************
185 *
186 *  Screen mode
187 *
188 *************************************/
151189
152/* This selects commercial (high res, arcade) or
153                  consumer (low res, astrocade) mode */
190/*-------------------------------------------------
191    astrocade_mode_w - this selects commercial
192    (high res, arcade) or consumer
193    (low res, astrocade) mode
194-------------------------------------------------*/
154195
155196WRITE8_HANDLER( astrocade_mode_w )
156197{
r1964r1965
163204      visarea.min_x = 0;
164205      visarea.max_x = 319;
165206      visarea.min_y = 0;
166      visarea.max_y = 203;
207      visarea.max_y = 255;
167208
168209      video_screen_configure(0, 455, 268, &visarea, HZ_TO_ATTOSECONDS(XTAL_Y1/2) * 268 * 455);
169210   }
r1964r1965
173214      visarea.min_x = 0;
174215      visarea.max_x = 159;
175216      visarea.min_y = 0;
176      visarea.max_y = 101;
217      visarea.max_y = 127;
177218
178219      video_screen_configure(0, 455, 134, &visarea, HZ_TO_ATTOSECONDS(XTAL_Y1/4) * 134 * 455);
179220   }
180221}
181222
182WRITE8_HANDLER ( astrocade_colour_register_w )
223
224
225/*************************************
226 *
227 *  Collisions
228 *
229 *************************************/
230
231READ8_HANDLER( astrocade_intercept_r )
183232{
233   int res;
234
235   res = collision;
236   collision = 0;
237
238   return res;
239}
240
241
242
243/*************************************
244 *
245 *  Colors
246 *
247 *************************************/
248
249/*-------------------------------------------------
250    astrocade_colour_split_w - switches colour
251    registers at this zone - 40 zones
252    also sets the background colors
253-------------------------------------------------*/
254
255WRITE8_HANDLER ( astrocade_colour_split_w )
256{
257   ColourSplit = data&0x3f;
258
259   if (astrocade_mode == 1)
260      ColourSplit <<= 1;
261
262   BackgroundData = ((data&0xc0) >> 6) * 0x55;
263
264   LOG(("Colour split set to %02d\n", ColourSplit));
265}
266
267WRITE8_HANDLER( astrocade_colour_register_w )
268{
184269   if(Colour[offset] != data)
185270    {
186271      Colour[offset] = data;
r1964r1965
213298}
214299
215300
216WRITE8_HANDLER ( astrocade_magic_expand_color_w )
301
302/*************************************
303 *
304 *  Magic RAM
305 *
306 *************************************/
307
308WRITE8_HANDLER( astrocade_magic_expand_color_w )
217309{
218310   //LOG(("%04x: magic_expand_color = %02x\n",cpu_getpc(),data));
219311
r1964r1965
221313}
222314
223315
224WRITE8_HANDLER ( astrocade_magic_control_w )
316WRITE8_HANDLER( astrocade_magic_control_w )
225317{
226318   //LOG(("%04x: magic_control = %02x\n",cpu_getpc(),data));
227319
r1964r1965
231323   magic_control = data;
232324}
233325
234WRITE8_HANDLER ( astrocade_magicram_w )
326
327WRITE8_HANDLER( astrocade_magicram_w )
235328{
236329   unsigned int data1,shift,bits,bibits,stib,k,old_data;
237330
r1964r1965
353446}
354447
355448
449
450/*************************************
451 *
452 *  Video update and interrupts
453 *
454 *************************************/
455
356456VIDEO_UPDATE( astrocde )
357457{
358458   int line = video_screen_get_vpos(0);
r1964r1965
362462
363463    int i;
364464
465    /* scanline interrupt? */
466   if (screen_interrupt_enabled && (line == screen_interrupt_line))
467      cpunum_set_input_line_and_vector(machine, 0, 0,
468         screen_interrupt_mode ? ASSERT_LINE : HOLD_LINE, interrupt_vector);
469   else
470      cpunum_set_input_line(machine, 0, 0, CLEAR_LINE);
471
365472   LeftLineColour[line] = LeftColourCheck;
366473   RightLineColour[line] = RightColourCheck;
367
474   
368475   for (i = 0; i < num_bytes; i++, memloc++)
369476   {
370477      int data, x;
src/mess/machine/astrocde.c
r1964r1965
1/**************************************************************************
2
3   Interrupt System Hardware for Bally/Midway games
4
5    Mike@Dissfulfils.co.uk
6
7**************************************************************************/
8
9#include "driver.h"
10#include "includes/astrocde.h"
11#include "cpu/z80/z80.h"
12
13#ifdef MAME_DEBUG
14#define VERBOSE 1
15#else
16#define VERBOSE 0
17#endif
18#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
19
20
21/****************************************************************************
22 * Scanline Interrupt System
23 ****************************************************************************/
24
25static emu_timer *scanline_timer;
26
27static int NextScanInt=0;         /* Normal */
28
29static int screen_interrupts_enabled;
30static int screen_interrupt_mode;
31static int lightpen_interrupts_enabled;
32static int lightpen_interrupt_mode;
33
34
35WRITE8_HANDLER ( astrocade_interrupt_enable_w )
36{
37
38   screen_interrupts_enabled = data & 0x08;
39   screen_interrupt_mode = data & 0x04;
40   lightpen_interrupts_enabled = data & 0x02;
41   lightpen_interrupt_mode = data & 0x01;
42
43   LOG(("Interrupt Flag set to %02x\n",data & 0x0f));
44}
45
46WRITE8_HANDLER ( astrocade_interrupt_w )
47{
48   /* A write to 0F triggers an interrupt at that scanline */
49
50   LOG(("Scanline interrupt set to %02x\n",data));
51
52   /* in low res mode, bits 1-7 are used */
53    NextScanInt = machine->screen[0].height == 134 ? data >> 1 : data;
54}
55
56
57static TIMER_CALLBACK( astrocde_scanline_callback )
58{
59   int scanline = video_screen_get_vpos(0);
60     
61   /* scanline interrupt? */
62   if (screen_interrupts_enabled && (screen_interrupt_mode == 0) && (scanline == NextScanInt))
63      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
64
65   /* are we on the last scanline? */
66   if (++scanline == machine->screen[0].height)
67      scanline = 0;
68
69   /* wait for next scanline */
70   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), 0);
71}
72
73
74WRITE8_HANDLER( astrocade_interrupt_vector_w )
75{
76   cpunum_set_input_line_vector(0, 0, data);
77   cpunum_set_input_line(machine, 0, 0, CLEAR_LINE);
78}
79
80
81MACHINE_RESET( astrocde )
82{
83   /* wait for the first scanline */
84   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0);
85}
86
87
88DRIVER_INIT( astrocde )
89{
90   scanline_timer = timer_alloc(astrocde_scanline_callback, NULL);
91}
src/mess/mess.mak
r1964r1965
757757
758758$(MESSOBJ)/bally.a:    \
759759   $(MESS_VIDEO)/astrocde.o \
760   $(MESS_MACHINE)/astrocde.o \
761760   $(MESS_DRIVERS)/astrocde.o
762761
763762$(MESSOBJ)/pcshare.a:               \
src/mess/drivers/astrocde.c
r1964r1965
227227   MDRV_CPU_PROGRAM_MAP(astrocade_mem, 0)
228228   MDRV_CPU_IO_MAP(astrocade_io, 0)
229229
230   MDRV_MACHINE_RESET(astrocde)
231
232230    /* video hardware */
233231   MDRV_SCREEN_ADD("main", RASTER)
234232   MDRV_SCREEN_RAW_PARAMS(XTAL_Y1/2, 455, 0, 320, 268, 0, 204)
235233   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
234
236235   MDRV_PALETTE_LENGTH(8*32)
237236   MDRV_PALETTE_INIT(astrocade)
238237
r1964r1965
285284 *
286285 *************************************/
287286
288/*    YEAR  NAME      PARENT    COMPAT    MACHINE   INPUT     INIT      CONFIG    COMPANY                FULLNAME                     FLAGS */
289CONS( 1978, astrocde, 0,        0,        astrocde, astrocde, astrocde, astrocde, "Bally Manufacturing", "Bally Professional Arcade", 0)
290CONS( 1977, astrocdw, astrocde, 0,        astrocde, astrocde, astrocde, astrocde, "Bally Manufacturing", "Bally Computer System",     0)
287/*    YEAR  NAME      PARENT    COMPAT    MACHINE   INPUT     INIT  CONFIG    COMPANY                FULLNAME                     FLAGS */
288CONS( 1978, astrocde, 0,        0,        astrocde, astrocde, 0,    astrocde, "Bally Manufacturing", "Bally Professional Arcade", 0)
289CONS( 1977, astrocdw, astrocde, 0,        astrocde, astrocde, 0,    astrocde, "Bally Manufacturing", "Bally Computer System",     0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team