Previous 15994 Revisions Next

r12307 Saturday 23rd July, 2011 at 17:58:55 UTC by Angelo Salese
Last one for today
[src/mess/drivers]z100.c

src/mess/drivers/z100.c
r12306r12307
66
77   TODO:
88   - remove parity check IRQ patch (understand what it really wants there!)
9   - video RAM banks not fully understood
910
1011============================================================================
1112
r12306r12307
148149      : driver_device(mconfig, type, tag)
149150   { }
150151
152   UINT8 *m_tvram;
151153   UINT8 *m_gvram;
152   UINT8 m_keyb_press;
154   UINT8 m_keyb_press,m_keyb_status;
155   UINT8 m_tbank;
156   UINT8 m_gbank;
157   UINT8 m_clr_val;
158   UINT8 m_crtc_vreg[0x100],m_crtc_index;
159
160   mc6845_device *m_mc6845;
161
153162};
154163
164#define mc6845_h_char_total    (state->m_crtc_vreg[0])
165#define mc6845_h_display      (state->m_crtc_vreg[1])
166#define mc6845_h_sync_pos      (state->m_crtc_vreg[2])
167#define mc6845_sync_width      (state->m_crtc_vreg[3])
168#define mc6845_v_char_total      (state->m_crtc_vreg[4])
169#define mc6845_v_total_adj      (state->m_crtc_vreg[5])
170#define mc6845_v_display      (state->m_crtc_vreg[6])
171#define mc6845_v_sync_pos      (state->m_crtc_vreg[7])
172#define mc6845_mode_ctrl      (state->m_crtc_vreg[8])
173#define mc6845_tile_height      (state->m_crtc_vreg[9]+1)
174#define mc6845_cursor_y_start   (state->m_crtc_vreg[0x0a])
175#define mc6845_cursor_y_end    (state->m_crtc_vreg[0x0b])
176#define mc6845_start_addr      (((state->m_crtc_vreg[0x0c]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0d] & 0xff))
177#define mc6845_cursor_addr     (((state->m_crtc_vreg[0x0e]<<8) & 0x3f00) | (state->m_crtc_vreg[0x0f] & 0xff))
178#define mc6845_light_pen_addr   (((state->m_crtc_vreg[0x10]<<8) & 0x3f00) | (state->m_crtc_vreg[0x11] & 0xff))
179#define mc6845_update_addr     (((state->m_crtc_vreg[0x12]<<8) & 0x3f00) | (state->m_crtc_vreg[0x13] & 0xff))
180
181
155182static VIDEO_START( z100 )
156183{
184   z100_state *state = machine.driver_data<z100_state>();
157185
186   state->m_tvram = auto_alloc_array_clear(machine, UINT8, 0x30000);
187   state->m_gvram = auto_alloc_array_clear(machine, UINT8, 0x30000*3);
158188}
159189
160190static SCREEN_UPDATE( z100 )
r12306r12307
162192   z100_state *state = screen->machine().driver_data<z100_state>();
163193   int x,y,xi,yi;
164194   int dot;
195   UINT32 count;
196   int r,g,b;
165197
166198   bitmap_fill(bitmap, cliprect, 0);
167199
168   for (y=0;y<25;y++)
200   count = 0;
201   for(y=0;y<216;y++)
169202   {
170      for(x=0;x<80;x++)
203      for(x=0;x<1024;x+=8)
171204      {
205         for(xi=0;xi<8;xi++)
206         {
207            b = ((state->m_gvram[count+0x20000] >> (7-xi)) & 1) << 0;
208            r = ((state->m_gvram[count+0x00000] >> (7-xi)) & 1) << 1;
209            g = ((state->m_gvram[count+0x10000] >> (7-xi)) & 1) << 2;
210
211            if(y < 216 && x+xi < 640) /* TODO: safety check */
212               *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine().pens[r|g|b];
213         }
214
215         count++;
216      }
217   }
218
219   for(y=0;y<mc6845_v_display;y++)
220   {
221      for(x=0;x<mc6845_h_display;x++)
222      {
172223         UINT32 base_offs,attr_offs;
173224         int color;
174225
175226         attr_offs = 0x20000 + y * 0x800 + x + 0x500;
176227
177         color = state->m_gvram[attr_offs] & 7;
228         color = state->m_tvram[attr_offs] & 7;
178229
179         for(yi=0;yi<8;yi++)
230         for(yi=0;yi<mc6845_tile_height;yi++)
180231         {
181232            base_offs = 0x20000 + y * 0x800 + yi * 0x80 + x;
182233
183234            for(xi=0;xi<8;xi++)
184235            {
185               dot = ((state->m_gvram[base_offs] >> (7-xi)) & 1);
236               dot = ((state->m_tvram[base_offs] >> (7-xi)) & 1);
186237
187238               if(dot)
188                  if(y*8+yi < 216 && x*8+xi < 640) /* TODO: safety check */
189                     *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = screen->machine().pens[color];
239                  if(y*mc6845_tile_height+yi < 216 && x*8+xi < 640) /* TODO: safety check */
240                     *BITMAP_ADDR16(bitmap, y*mc6845_tile_height+yi, x*8+xi) = screen->machine().pens[color];
190241            }
191242         }
192243      }
r12306r12307
195246    return 0;
196247}
197248
249static READ8_HANDLER( z100_vram_r )
250{
251   z100_state *state = space->machine().driver_data<z100_state>();
252   UINT8 res;
253
254   res = 0;
255
256   if(state->m_gbank == 0xf)
257      res |= state->m_tvram[offset & 0x3ffff];
258   else if(state->m_gbank & 7)
259      res |= state->m_gvram[offset];
260
261   return res;
262}
263
264static WRITE8_HANDLER( z100_vram_w )
265{
266   z100_state *state = space->machine().driver_data<z100_state>();
267
268   if(state->m_gbank == 0xf)
269      state->m_tvram[offset & 0x3ffff] = data;
270   else
271   {
272      int i;
273
274      for(i=0;i<3;i++)
275      {
276         if(state->m_gbank & (1 << i))
277            state->m_gvram[(offset & 0xffff)+0x10000*i] = data;
278      }
279   }
280}
281
198282static ADDRESS_MAP_START(z100_mem, AS_PROGRAM, 8)
199283   ADDRESS_MAP_UNMAP_HIGH
200284   AM_RANGE(0x00000,0x1ffff) AM_RAM // 128 KB RAM
201285//   AM_RANGE(0xb0000,0xbffff) AM_ROM // expansion ROM
202   AM_RANGE(0xc0000,0xeffff) AM_RAM AM_BASE_MEMBER(z100_state,m_gvram) // Blue / Red / Green
286   AM_RANGE(0xc0000,0xeffff) AM_READWRITE(z100_vram_r,z100_vram_w) // Blue / Red / Green
203287//   AM_RANGE(0xfbffa,0xfbffb) // expansion ROM check ID 0x4550
204288   AM_RANGE(0xfc000,0xfffff) AM_ROM AM_REGION("ipl", 0)
205289ADDRESS_MAP_END
r12306r12307
208292{
209293   z100_state *state = space->machine().driver_data<z100_state>();
210294
295   if(state->m_keyb_press)
296   {
297      UINT8 res;
298
299      res = state->m_keyb_press;
300
301      state->m_keyb_press = 0;
302      return res;
303   }
304
211305   return state->m_keyb_press;
212306}
213307
214308static READ8_HANDLER(keyb_status_r)
215309{
216   return 1;
310   z100_state *state = space->machine().driver_data<z100_state>();
311
312   if(state->m_keyb_status)
313   {
314      state->m_keyb_status = 0;
315      return 1;
316   }
317
318   return state->m_keyb_status;
217319}
218320
219321static WRITE8_HANDLER(keyb_command_w)
r12306r12307
221323   // ...
222324}
223325
326static WRITE8_HANDLER( z100_6845_address_w )
327{
328   z100_state *state = space->machine().driver_data<z100_state>();
329
330   state->m_crtc_index = data;
331   state->m_mc6845->address_w(*space, offset, data);
332}
333
334static WRITE8_HANDLER( z100_6845_data_w )
335{
336   z100_state *state = space->machine().driver_data<z100_state>();
337
338   state->m_crtc_vreg[state->m_crtc_index] = data;
339   state->m_mc6845->register_w(*space, offset, data);
340}
341
224342static ADDRESS_MAP_START( z100_io , AS_IO, 8)
225343   ADDRESS_MAP_UNMAP_HIGH
226344//   AM_RANGE (0x98, 0x98) Z-205 max number
227345//   AM_RANGE (0xae, 0xaf) Z-217 disk controller
228346//   AM_RANGE (0xb0, 0xb1) Z-207 disk controller
229347   AM_RANGE (0xd8, 0xdb) AM_DEVREADWRITE_MODERN("pia0", pia6821_device, read, write)
230   AM_RANGE (0xdc, 0xdc) AM_DEVWRITE_MODERN("crtc", mc6845_device, address_w)
231   AM_RANGE (0xdd, 0xdd) AM_DEVWRITE_MODERN("crtc", mc6845_device, register_w)
348   AM_RANGE (0xdc, 0xdc) AM_WRITE(z100_6845_address_w)
349   AM_RANGE (0xdd, 0xdd) AM_WRITE(z100_6845_data_w)
232350//   AM_RANGE (0xde, 0xde) light pen
233351   AM_RANGE (0xe0, 0xe3) AM_DEVREADWRITE_MODERN("pia1", pia6821_device, read, write)
234352//   AM_RANGE (0xe4, 0xe7) 8253 PIT
r12306r12307
254372   {
255373      state->m_keyb_press = (UINT8)(FPTR)(param) & 0x7f;
256374      //pic8259_ir1_w(field.machine().device("pic8259_master"), 1);
375      state->m_keyb_status = 1;
257376   }
258377
259378   if(oldval && !newval)
379   {
260380      state->m_keyb_press = 0;
381      state->m_keyb_status = 0;
382   }
261383}
262384
263385/* Input ports */
r12306r12307
323445   PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x2f)
324446
325447   PORT_START("KEY6") // 0x30 - 0x37
326   PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x30)
327   PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x31)
328   PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x32)
329   PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x33)
330   PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x34)
331   PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x35)
332   PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x36)
333   PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x37)
448   PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_IMPULSE(1) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x30)
449   PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x31)
450   PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x32)
451   PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x33)
452   PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x34)
453   PORT_BIT(0x20,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x35)
454   PORT_BIT(0x40,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x36)
455   PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x37)
334456
335457   PORT_START("KEY7") // 0x38 - 0x3f
336   PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x38)
337   PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x39)
458   PORT_BIT(0x01,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x38)
459   PORT_BIT(0x02,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x39)
338460   PORT_BIT(0x04,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x3a)
339461   PORT_BIT(0x08,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x3b)
340462   PORT_BIT(0x10,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x3c)
r12306r12307
461583   NULL      /* update address callback */
462584};
463585
464static WRITE8_DEVICE_HANDLER( video_pia_porta_w )
586static WRITE8_DEVICE_HANDLER( video_pia_A_w )
465587{
588   z100_state *state = device->machine().driver_data<z100_state>();
589
466590 /*
467591    x--- ---- -> disable video RAM
468592   -x-- ---- -> not write multiple blue
r12306r12307
473597     ---- --x- -> enable green display
474598    ---- ---x -> enable red display
475599    */
600    if(data != 0x08 && data != 0xf8)
601    printf("%02x\n",data);
602
603    state->m_gbank = ((data & 0xf0) >> 4) ^ 0xf;
476604}
477605
606/* clear screen */
607static WRITE_LINE_DEVICE_HANDLER( video_pia_CA2_w )
608{
609   z100_state *drvstate = device->machine().driver_data<z100_state>();
610   int i;
611
612   for(i=0;i<0x10000;i++)
613      drvstate->m_tvram[i] = drvstate->m_clr_val;
614
615   for(i=0;i<0x30000;i++)
616      drvstate->m_gvram[i] = drvstate->m_clr_val;
617}
618
619static WRITE8_DEVICE_HANDLER( video_pia_CB2_w )
620{
621   z100_state *state = device->machine().driver_data<z100_state>();
622
623   state->m_clr_val = (data & 1) ? 0x00 : 0xff;
624}
625
478626static const pia6821_interface pia0_intf =
479627{
480628   DEVCB_NULL,      /* port A in */
r12306r12307
483631   DEVCB_NULL,      /* line CB1 in */
484632   DEVCB_NULL,      /* line CA2 in */
485633   DEVCB_NULL,      /* line CB2 in */
486   DEVCB_HANDLER(video_pia_porta_w),      /* port A out */
634   DEVCB_HANDLER(video_pia_A_w),      /* port A out */
487635   DEVCB_NULL,      /* port B out */
488   DEVCB_NULL,      /* line CA2 out */
489   DEVCB_NULL,      /* port CB2 out */
636   DEVCB_LINE(video_pia_CA2_w),      /* line CA2 out */
637   DEVCB_HANDLER(video_pia_CB2_w),      /* port CB2 out */
490638   DEVCB_NULL,      /* IRQA */
491639   DEVCB_NULL      /* IRQB */
492640};
r12306r12307
514662
515663static MACHINE_START(z100)
516664{
517//   z100_state *state = machine.driver_data<z100_state>();
665   z100_state *state = machine.driver_data<z100_state>();
518666
519667   device_set_irq_callback(machine.device("maincpu"), z100_irq_callback);
668   state->m_mc6845 = machine.device<mc6845_device>("crtc");
520669}
521670
522671static MACHINE_RESET(z100)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team