Previous 15994 Revisions Next

r9149 Friday 17th September, 2010 at 04:19:42 UTC by Miodrag Milanović
Fixed samcoupe state object repeat issue, also rename variable to state as in other drivers.
[src/mess/drivers]samcoupe.c
[src/mess/machine]samcoupe.c
[src/mess/video]samcoupe.c

src/mess/machine/samcoupe.c
r9148r9149
4444
4545static void samcoupe_install_ext_mem(address_space *space)
4646{
47   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
47   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
4848   UINT8 *mem;
4949
5050   /* bank 3 */
51   if (asic->lext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
52      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (asic->lext >> 6) * 0x100000 + (asic->lext & 0x3f) * 0x4000];
51   if (state->lext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
52      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->lext >> 6) * 0x100000 + (state->lext & 0x3f) * 0x4000];
5353   else
5454      mem = NULL;
5555
5656   samcoupe_update_bank(space, 3, mem, FALSE);
5757
5858   /* bank 4 */
59   if (asic->hext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
60      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (asic->hext >> 6) * 0x100000 + (asic->hext & 0x3f) * 0x4000];
59   if (state->hext >> 6 < messram_get_size(space->machine->device("messram")) >> 20)
60      mem = &messram_get_ptr(space->machine->device("messram"))[(messram_get_size(space->machine->device("messram")) & 0xfffff) + (state->hext >> 6) * 0x100000 + (state->hext & 0x3f) * 0x4000];
6161   else
6262      mem = NULL;
6363
r9148r9149
6868void samcoupe_update_memory(address_space *space)
6969{
7070   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
71   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
7271   const int PAGE_MASK = ((messram_get_size(space->machine->device("messram")) & 0xfffff) / 0x4000) - 1;
7372   UINT8 *rom = memory_region(space->machine, "maincpu");
7473   UINT8 *memory;
7574   int is_readonly;
7675
7776   /* BANK1 */
78    if (asic->lmpr & LMPR_RAM0)   /* Is ram paged in at bank 1 */
77    if (state->lmpr & LMPR_RAM0)   /* Is ram paged in at bank 1 */
7978   {
80      if ((asic->lmpr & 0x1F) <= PAGE_MASK)
81         memory = &messram_get_ptr(space->machine->device("messram"))[(asic->lmpr & PAGE_MASK) * 0x4000];
79      if ((state->lmpr & 0x1F) <= PAGE_MASK)
80         memory = &messram_get_ptr(space->machine->device("messram"))[(state->lmpr & PAGE_MASK) * 0x4000];
8281      else
8382         memory = NULL;   /* Attempt to page in non existant ram region */
8483      is_readonly = FALSE;
r9148r9149
9291
9392
9493   /* BANK2 */
95   if (((asic->lmpr + 1) & 0x1f) <= PAGE_MASK)
96      memory = &messram_get_ptr(space->machine->device("messram"))[((asic->lmpr + 1) & PAGE_MASK) * 0x4000];
94   if (((state->lmpr + 1) & 0x1f) <= PAGE_MASK)
95      memory = &messram_get_ptr(space->machine->device("messram"))[((state->lmpr + 1) & PAGE_MASK) * 0x4000];
9796   else
9897      memory = NULL;   /* Attempt to page in non existant ram region */
9998   samcoupe_update_bank(space, 2, memory, FALSE);
10099
101100   /* only update bank 3 and 4 when external memory is not enabled */
102   if (asic->hmpr & HMPR_MCNTRL)
101   if (state->hmpr & HMPR_MCNTRL)
103102   {
104103      samcoupe_install_ext_mem(space);
105104   }
106105   else
107106   {
108107      /* BANK3 */
109      if ((asic->hmpr & 0x1F) <= PAGE_MASK )
110         memory = &messram_get_ptr(space->machine->device("messram"))[(asic->hmpr & PAGE_MASK)*0x4000];
108      if ((state->hmpr & 0x1F) <= PAGE_MASK )
109         memory = &messram_get_ptr(space->machine->device("messram"))[(state->hmpr & PAGE_MASK)*0x4000];
111110      else
112111         memory = NULL;   /* Attempt to page in non existant ram region */
113112      samcoupe_update_bank(space, 3, memory, FALSE);
114113
115114
116115      /* BANK4 */
117      if (asic->lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
116      if (state->lmpr & LMPR_ROM1)   /* Is Rom1 paged in at bank 4 */
118117      {
119118         memory = rom + 0x4000;
120119         is_readonly = TRUE;
121120      }
122121      else
123122      {
124         if (((asic->hmpr + 1) & 0x1f) <= PAGE_MASK)
125            memory = &messram_get_ptr(space->machine->device("messram"))[((asic->hmpr + 1) & PAGE_MASK) * 0x4000];
123         if (((state->hmpr + 1) & 0x1f) <= PAGE_MASK)
124            memory = &messram_get_ptr(space->machine->device("messram"))[((state->hmpr + 1) & PAGE_MASK) * 0x4000];
126125         else
127126            memory = NULL;   /* Attempt to page in non existant ram region */
128127         is_readonly = FALSE;
r9148r9149
131130   }
132131
133132   /* video memory location */
134   if (asic->vmpr & 0x40)   /* if bit set in 2 bank screen mode */
135      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((asic->vmpr & 0x1e) & PAGE_MASK) * 0x4000];
133   if (state->vmpr & 0x40)   /* if bit set in 2 bank screen mode */
134      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1e) & PAGE_MASK) * 0x4000];
136135   else
137      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((asic->vmpr & 0x1f) & PAGE_MASK) * 0x4000];
136      state->videoram = &messram_get_ptr(space->machine->device("messram"))[((state->vmpr & 0x1f) & PAGE_MASK) * 0x4000];
138137}
139138
140139
141140WRITE8_HANDLER( samcoupe_ext_mem_w )
142141{
142   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
143143   address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
144   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
145144
146145   if (offset & 1)
147      asic->hext = data;
146      state->hext = data;
148147   else
149      asic->lext = data;
148      state->lext = data;
150149
151150   /* external RAM enabled? */
152   if (asic->hmpr & HMPR_MCNTRL)
151   if (state->hmpr & HMPR_MCNTRL)
153152   {
154153      samcoupe_install_ext_mem(space_program);
155154   }
r9148r9149
178177
179178static TIMER_CALLBACK( samcoupe_mouse_reset )
180179{
181   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
182   asic->mouse_index = 0;
180   samcoupe_state *state = machine->driver_data<samcoupe_state>();
181   state->mouse_index = 0;
183182}
184183
185184UINT8 samcoupe_mouse_r(running_machine *machine)
186185{
187   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
186   samcoupe_state *state = machine->driver_data<samcoupe_state>();
188187   UINT8 result;
189188
190189   /* on a read, reset the timer */
191   timer_adjust_oneshot(asic->mouse_reset, ATTOTIME_IN_USEC(50), 0);
190   timer_adjust_oneshot(state->mouse_reset, ATTOTIME_IN_USEC(50), 0);
192191
193192   /* update when we are about to read the first real values */
194   if (asic->mouse_index == 2)
193   if (state->mouse_index == 2)
195194   {
196195      /* update values */
197196      int mouse_x = input_port_read(machine, "mouse_x");
198197      int mouse_y = input_port_read(machine, "mouse_y");
199198
200      int mouse_dx = asic->mouse_x - mouse_x;
201      int mouse_dy = asic->mouse_y - mouse_y;
199      int mouse_dx = state->mouse_x - mouse_x;
200      int mouse_dy = state->mouse_y - mouse_y;
202201
203      asic->mouse_x = mouse_x;
204      asic->mouse_y = mouse_y;
202      state->mouse_x = mouse_x;
203      state->mouse_y = mouse_y;
205204
206205      /* button state */
207      asic->mouse_data[2] = input_port_read(machine, "mouse_buttons");
206      state->mouse_data[2] = input_port_read(machine, "mouse_buttons");
208207
209208      /* y-axis */
210      asic->mouse_data[3] = (mouse_dy & 0xf00) >> 8;
211      asic->mouse_data[4] = (mouse_dy & 0x0f0) >> 4;
212      asic->mouse_data[5] = (mouse_dy & 0x00f) >> 0;
209      state->mouse_data[3] = (mouse_dy & 0xf00) >> 8;
210      state->mouse_data[4] = (mouse_dy & 0x0f0) >> 4;
211      state->mouse_data[5] = (mouse_dy & 0x00f) >> 0;
213212
214213      /* x-axis */
215      asic->mouse_data[6] = (mouse_dx & 0xf00) >> 8;
216      asic->mouse_data[7] = (mouse_dx & 0x0f0) >> 4;
217      asic->mouse_data[8] = (mouse_dx & 0x00f) >> 0;
214      state->mouse_data[6] = (mouse_dx & 0xf00) >> 8;
215      state->mouse_data[7] = (mouse_dx & 0x0f0) >> 4;
216      state->mouse_data[8] = (mouse_dx & 0x00f) >> 0;
218217   }
219218
220219   /* get current value */
221   result = asic->mouse_data[asic->mouse_index++];
220   result = state->mouse_data[state->mouse_index++];
222221
223222   /* reset if we are at the end */
224   if (asic->mouse_index == sizeof(asic->mouse_data))
225      asic->mouse_index = 1;
223   if (state->mouse_index == sizeof(state->mouse_data))
224      state->mouse_index = 1;
226225
227226   return result;
228227}
229228
230229MACHINE_START( samcoupe )
231230{
232   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
233   asic->mouse_reset = timer_alloc(machine, samcoupe_mouse_reset, 0);
231   samcoupe_state *state = machine->driver_data<samcoupe_state>();
232   state->mouse_reset = timer_alloc(machine, samcoupe_mouse_reset, 0);
234233
235234   /* schedule our video updates */
236   asic->video_update_timer = timer_alloc(machine, sam_video_update_callback, NULL);
237   timer_adjust_oneshot(asic->video_update_timer, machine->primary_screen->time_until_pos(0, 0), 0);
235   state->video_update_timer = timer_alloc(machine, sam_video_update_callback, NULL);
236   timer_adjust_oneshot(state->video_update_timer, machine->primary_screen->time_until_pos(0, 0), 0);
238237}
239238
240239/***************************************************************************
r9148r9149
245244{
246245   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
247246   address_space *spaceio = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
248   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
247   samcoupe_state *state = machine->driver_data<samcoupe_state>();
249248
250   /* initialize asic */
251   asic->lmpr = 0x0f;      /* ROM0 paged in, ROM1 paged out RAM Banks */
252   asic->hmpr = 0x01;
253   asic->vmpr = 0x81;
254   asic->line_int = 0xff;  /* line interrupts disabled */
255   asic->status = 0x1f;    /* no interrupts active */
249   /* initialize state */
250   state->lmpr = 0x0f;      /* ROM0 paged in, ROM1 paged out RAM Banks */
251   state->hmpr = 0x01;
252   state->vmpr = 0x81;
253   state->line_int = 0xff;  /* line interrupts disabled */
254   state->status = 0x1f;    /* no interrupts active */
256255
257256   /* initialize mouse */
258   asic->mouse_index = 0;
259   asic->mouse_data[0] = 0xff;
260   asic->mouse_data[1] = 0xff;
257   state->mouse_index = 0;
258   state->mouse_data[0] = 0xff;
259   state->mouse_data[1] = 0xff;
261260
262261   if (input_port_read(machine, "config") & 0x01)
263262   {
src/mess/video/samcoupe.c
r9148r9149
3030{
3131   samcoupe_state *state = machine->driver_data<samcoupe_state>();
3232   UINT8 *videoram = state->videoram;
33   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
3433
3534   /* get start address */
3635   UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4);
r9148r9149
3837   for (int i = 0; i < (SAM_BLOCK*2)/4; i++)
3938   {
4039      /* draw 2 pixels (doublewidth) */
41      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = asic->clut[(*vram >> 4) & 0x0f];
42      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = asic->clut[(*vram >> 4) & 0x0f];
43      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = asic->clut[(*vram >> 0) & 0x0f];
44      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = asic->clut[(*vram >> 0) & 0x0f];
40      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = state->clut[(*vram >> 4) & 0x0f];
41      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = state->clut[(*vram >> 4) & 0x0f];
42      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = state->clut[(*vram >> 0) & 0x0f];
43      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = state->clut[(*vram >> 0) & 0x0f];
4544
4645      /* move to next address */
4746      vram++;
4847
4948      /* attribute register contains the third displayed byte */
5049      if (i == 2)
51         asic->attribute = *vram;
50         state->attribute = *vram;
5251   }
5352}
5453
r9148r9149
5655{
5756   samcoupe_state *state = machine->driver_data<samcoupe_state>();
5857   UINT8 *videoram = state->videoram;
59   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
6058
6159   /* get start address */
6260   UINT8 *vram = videoram + ((y - SAM_BORDER_TOP) * 128) + ((hpos - SAM_BORDER_LEFT) / 4);
r9148r9149
6462   for (int i = 0; i < (SAM_BLOCK*2)/4; i++)
6563   {
6664      /* draw 4 pixels */
67      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = asic->clut[(*vram >> 6) & 0x03];
68      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = asic->clut[(*vram >> 4) & 0x03];
69      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = asic->clut[(*vram >> 2) & 0x03];
70      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = asic->clut[(*vram >> 0) & 0x03];
65      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 0) = state->clut[(*vram >> 6) & 0x03];
66      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 1) = state->clut[(*vram >> 4) & 0x03];
67      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 2) = state->clut[(*vram >> 2) & 0x03];
68      *BITMAP_ADDR16(machine->generic.tmpbitmap, y, hpos + i * 4 + 3) = state->clut[(*vram >> 0) & 0x03];
7169
7270      /* move to next address */
7371      vram++;
7472
7573      /* attribute register contains the third displayed byte */
7674      if (i == 2)
77         asic->attribute = *vram;
75         state->attribute = *vram;
7876   }
7977}
8078
81static void draw_mode12_block(samcoupe_state *asic, bitmap_t *bitmap, int vpos, int hpos, UINT8 mask)
79static void draw_mode12_block(samcoupe_state *state, bitmap_t *bitmap, int vpos, int hpos, UINT8 mask)
8280{
8381   /* extract colors from attribute */
84   UINT8 ink = asic->clut[ATTR_FG(asic->attribute)];
85   UINT8 pap = asic->clut[ATTR_BG(asic->attribute)];
82   UINT8 ink = state->clut[ATTR_FG(state->attribute)];
83   UINT8 pap = state->clut[ATTR_BG(state->attribute)];
8684
8785   /* draw block of 8 pixels (doubled to 16) */
8886   for (int i = 0; i < SAM_BLOCK; i++)
r9148r9149
9694{
9795   samcoupe_state *state = machine->driver_data<samcoupe_state>();
9896   UINT8 *videoram = state->videoram;
99   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
10097
10198   int cell = (y - SAM_BORDER_TOP) * 32 + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2;
10299
103100   UINT8 mask = videoram[cell];
104   asic->attribute = videoram[cell + 0x2000];
101   state->attribute = videoram[cell + 0x2000];
105102
106   draw_mode12_block(asic, machine->generic.tmpbitmap, y, hpos, mask);
103   draw_mode12_block(state, machine->generic.tmpbitmap, y, hpos, mask);
107104}
108105
109106static void draw_mode1_line(running_machine *machine, int y, int hpos)
110107{
111108   samcoupe_state *state = machine->driver_data<samcoupe_state>();
112109   UINT8 *videoram = state->videoram;
113   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
114110
115111   UINT8 mask = videoram[((((y - SAM_BORDER_TOP) & 0xc0) << 5) | (((y - SAM_BORDER_TOP) & 0x07) << 8) | (((y - SAM_BORDER_TOP) & 0x38) << 2)) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2];
116   asic->attribute = videoram[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2];
112   state->attribute = videoram[32*192 + (((y - SAM_BORDER_TOP) & 0xf8) << 2) + (hpos - SAM_BORDER_LEFT) / SAM_BLOCK / 2];
117113
118   draw_mode12_block(asic, machine->generic.tmpbitmap, y, hpos, mask);
114   draw_mode12_block(state, machine->generic.tmpbitmap, y, hpos, mask);
119115}
120116
121117TIMER_CALLBACK( sam_video_update_callback )
122118{
123   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
124
119   samcoupe_state *state = machine->driver_data<samcoupe_state>();
125120   int vpos = machine->primary_screen->vpos();
126121   int hpos = machine->primary_screen->hpos();
127122
r9148r9149
136131   }
137132
138133   /* display disabled? (only in mode 3 or 4) */
139   if (BIT(asic->vmpr, 6) && BIT(asic->border, 7))
134   if (BIT(state->vmpr, 6) && BIT(state->border, 7))
140135   {
141136      plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, 0);
142137   }
r9148r9149
145140      /* border area? */
146141      if (vpos < SAM_BORDER_TOP || vpos >= SAM_BORDER_TOP + SAM_SCREEN_HEIGHT || hpos < SAM_BORDER_LEFT || hpos >= SAM_BORDER_LEFT + SAM_SCREEN_WIDTH)
147142      {
148         asic->attribute = 0xff;
149         plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, asic->clut[BORDER_COLOR(asic->border)]);
143         state->attribute = 0xff;
144         plot_box(machine->generic.tmpbitmap, hpos, vpos, SAM_BLOCK*2, 1, state->clut[BORDER_COLOR(state->border)]);
150145      }
151146      else
152147      {
153148         /* main screen area */
154         switch ((asic->vmpr & 0x60) >> 5)
149         switch ((state->vmpr & 0x60) >> 5)
155150         {
156151         case 0:   draw_mode1_line(machine, vpos, hpos); break;
157152         case 1:   draw_mode2_line(machine, vpos, hpos); break;
r9148r9149
162157   }
163158
164159   /* do we need to trigger the scanline interrupt (interrupt happens at the start of the right border before the specified line)? */
165   if (asic->line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (asic->line_int + SAM_BORDER_TOP - 1))
160   if (state->line_int < SAM_SCREEN_HEIGHT && hpos == SAM_BORDER_LEFT + SAM_SCREEN_WIDTH && vpos == (state->line_int + SAM_BORDER_TOP - 1))
166161      samcoupe_irq(machine->firstcpu, SAM_LINE_INT);
167162
168163   /* schedule next update */
169   timer_adjust_oneshot(asic->video_update_timer, machine->primary_screen->time_until_pos(next_vpos, next_hpos), 0);
164   timer_adjust_oneshot(state->video_update_timer, machine->primary_screen->time_until_pos(next_vpos, next_hpos), 0);
170165}
src/mess/drivers/samcoupe.c
r9148r9149
123123
124124static WRITE8_HANDLER( samcoupe_clut_w )
125125{
126   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
127   asic->clut[(offset >> 8) & 0x0f] = data & 0x7f;
126   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
127   state->clut[(offset >> 8) & 0x0f] = data & 0x7f;
128128}
129129
130130static READ8_HANDLER( samcoupe_status_r )
131131{
132   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
132   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
133133   UINT8 data = 0xe0;
134134
135135   /* bit 5-7, keyboard input */
r9148r9149
143143   if (!BIT(offset, 15)) data &= input_port_read(space->machine, "keyboard_row_7f") & 0xe0;
144144
145145   /* bit 0-4, interrupt source */
146   data |= asic->status;
146   data |= state->status;
147147
148148   return data;
149149}
150150
151151static WRITE8_HANDLER( samcoupe_line_int_w )
152152{
153   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
154   asic->line_int = data;
153   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
154   state->line_int = data;
155155}
156156
157157static READ8_HANDLER( samcoupe_lmpr_r )
158158{
159   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
160   return asic->lmpr;
159   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
160   return state->lmpr;
161161}
162162
163163static WRITE8_HANDLER( samcoupe_lmpr_w )
164164{
165165   address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
166   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
166   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
167167
168   asic->lmpr = data;
168   state->lmpr = data;
169169   samcoupe_update_memory(space_program);
170170}
171171
172172static READ8_HANDLER( samcoupe_hmpr_r )
173173{
174   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
175   return asic->hmpr;
174   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
175   return state->hmpr;
176176}
177177
178178static WRITE8_HANDLER( samcoupe_hmpr_w )
179179{
180180   address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
181   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
181   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
182182
183   asic->hmpr = data;
183   state->hmpr = data;
184184   samcoupe_update_memory(space_program);
185185}
186186
187187static READ8_HANDLER( samcoupe_vmpr_r )
188188{
189   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
190   return asic->vmpr;
189   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
190   return state->vmpr;
191191}
192192
193193static WRITE8_HANDLER( samcoupe_vmpr_w )
194194{
195195   address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
196   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
196   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
197197
198   asic->vmpr = data;
198   state->vmpr = data;
199199   samcoupe_update_memory(space_program);
200200}
201201
r9148r9149
250250{
251251   running_device *cassette = space->machine->device("cassette");
252252   running_device *speaker = space->machine->device("speaker");
253   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
253   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
254254
255   asic->border = data;
255   state->border = data;
256256
257257   /* bit 3, cassette output */
258258   cassette_output(cassette, BIT(data, 3) ? -1.0 : +1.0);
r9148r9149
263263
264264static READ8_HANDLER( samcoupe_attributes_r )
265265{
266   samcoupe_state *asic = space->machine->driver_data<samcoupe_state>();
267   return asic->attribute;
266   samcoupe_state *state = space->machine->driver_data<samcoupe_state>();
267   return state->attribute;
268268}
269269
270270static READ8_DEVICE_HANDLER( samcoupe_lpt1_busy_r )
r9148r9149
325325
326326static TIMER_CALLBACK( irq_off )
327327{
328   samcoupe_state *asic = machine->driver_data<samcoupe_state>();
329
328   samcoupe_state *state = machine->driver_data<samcoupe_state>();
330329   /* adjust STATUS register */
331   asic->status |= param;
330   state->status |= param;
332331
333332   /* clear interrupt */
334   if ((asic->status & 0x1f) == 0x1f)
333   if ((state->status & 0x1f) == 0x1f)
335334      cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
336335
337336}
338337
339338void samcoupe_irq(running_device *device, UINT8 src)
340339{
341   samcoupe_state *asic = device->machine->driver_data<samcoupe_state>();
340   samcoupe_state *state = device->machine->driver_data<samcoupe_state>();
342341
343342   /* assert irq and a timer to set it off again */
344343   cpu_set_input_line(device, 0, ASSERT_LINE);
345344   timer_set(device->machine, ATTOTIME_IN_USEC(20), NULL, src, irq_off);
346345
347346   /* adjust STATUS register */
348   asic->status &= ~src;
347   state->status &= ~src;
349348}
350349
351350static INTERRUPT_GEN( samcoupe_frame_interrupt )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team