Previous 15994 Revisions Next

r10068 Monday 17th January, 2011 at 11:31:21 UTC by Robbbert
[PEGASUS] Modernised.
[src/mess/drivers]pegasus.c
[src/mess/includes]pegasus.h
[src/mess/video]pegasus.c

src/mess/video/pegasus.c
r10067r10068
166166   else
167167   if (!mcm6571a_shift[code])
168168   {
169      if (line < 1)
170         return 0;
171      else
172      if (line < 10)
169      if ((line) && (line < 10))
173170         return mcm6571a[code*9 + line - 1];
174      else
175         return 0;
176171   }
177172   else
178173   {
179      if (line < 4)
180         return 0;
181      else
182      if (line <13)
174      if ((line > 3) && (line < 13))
183175         return mcm6571a[code*9 + line - 4];
184      else
185         return 0;
186176   }
187   return 0;
188177
178   return 0;
189179}
190180
191181VIDEO_UPDATE( pegasus )
r10067r10068
193183   pegasus_state *state = screen->machine->driver_data<pegasus_state>();
194184   UINT16 addr,xpos,x,y;
195185   UINT8 b,j,l,code,inv;
196   UINT8 *FNT = screen->machine->region("pcg")->base();
197   UINT8 pcg_mode = state->control_bits & 2;
186   UINT8 pcg_mode = state->m_control_bits & 2;
198187
199188   for(y = 0; y < 16; y++ )
200189   {
r10067r10068
202191      xpos = 0;
203192      for(x = 0; x < 32; x++ )
204193      {
205         code = state->video_ram[addr|x];
194         code = state->m_videoram[addr|x];
206195         inv = (code >> 7) ^ 1;
207196         for(j = 0; j < 16; j++ )
208197         {
209            l = get_mcm6571a_line(code &0x7f, j, pcg_mode, FNT);
198            l = get_mcm6571a_line(code &0x7f, j, pcg_mode, state->m_pcgram);
210199            for(b = 0; b < 8; b++ )
211200               *BITMAP_ADDR16(bitmap, (y<<4)|j, xpos+b ) =  inv ^ ((l >> (7-b)) & 1);
212201         }
src/mess/includes/pegasus.h
r10067r10068
1#include "cpu/m6809/m6809.h"
2#include "machine/6821pia.h"
3#include "imagedev/cartslot.h"
4#include "imagedev/cassette.h"
5
16class pegasus_state : public driver_device
27{
38public:
r10067r10068
27   pegasus_state(running_machine &machine, const driver_device_config_base &config)
3      : driver_device(machine, config) { }
8      : driver_device(machine, config),
9   m_maincpu(*this, "maincpu"),
10   m_cass(*this, "cassette"),
11   m_pia_s(*this, "pia_s"),
12   m_pia_u(*this, "pia_u")
13   { }
414
5   UINT8 kbd_row;
6   UINT8 kbd_irq;
7   device_t *cass;
8   UINT8 *FNT;
9   UINT8 control_bits;
10   UINT8 *video_ram;
15   required_device<cpu_device> m_maincpu;
16   required_device<device_t> m_cass;
17   required_device<device_t> m_pia_s;
18   required_device<device_t> m_pia_u;
19   DECLARE_READ8_MEMBER( pegasus_keyboard_r );
20   DECLARE_READ8_MEMBER( pegasus_protection_r );
21   DECLARE_READ8_MEMBER( pegasus_pcg_r );
22   DECLARE_WRITE8_MEMBER( pegasus_controls_w );
23   DECLARE_WRITE8_MEMBER( pegasus_keyboard_w );
24   DECLARE_WRITE8_MEMBER( pegasus_pcg_w );
25   DECLARE_READ_LINE_MEMBER( pegasus_keyboard_irq );
26   DECLARE_READ_LINE_MEMBER( pegasus_cassette_r );
27   DECLARE_WRITE_LINE_MEMBER( pegasus_cassette_w );
28   DECLARE_WRITE_LINE_MEMBER( pegasus_firq_clr );
29   UINT8 m_kbd_row;
30   UINT8 m_kbd_irq;
31   UINT8 *m_pcgram;
32   UINT8 *m_videoram;
33   UINT8 m_control_bits;
1134};
src/mess/drivers/pegasus.c
r10067r10068
2828    - Work on the other non-working programs
2929
3030****************************************************************************/
31#define ADDRESS_MAP_MODERN
3132
3233#include "emu.h"
33#include "cpu/m6809/m6809.h"
34#include "machine/6821pia.h"
35#include "imagedev/cartslot.h"
36#include "imagedev/cassette.h"
3734#include "includes/pegasus.h"
3835
3936static TIMER_DEVICE_CALLBACK( pegasus_firq )
r10067r10068
4239   cpu_set_input_line(cpu, M6809_FIRQ_LINE, HOLD_LINE);
4340}
4441
45static WRITE_LINE_DEVICE_HANDLER( pegasus_firq_clr )
42WRITE_LINE_MEMBER( pegasus_state::pegasus_firq_clr )
4643{
47   cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, CLEAR_LINE);
44   cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, CLEAR_LINE);
4845}
4946
50static READ8_DEVICE_HANDLER( pegasus_keyboard_r )
47READ8_MEMBER( pegasus_state::pegasus_keyboard_r )
5148{
52   pegasus_state *state = device->machine->driver_data<pegasus_state>();
5349   static const char *const keynames[] = { "X0", "X1", "X2", "X3", "X4", "X5", "X6", "X7" };
5450   UINT8 bit,data = 0xff;
5551   for (bit = 0; bit < 8; bit++)
56      if (!BIT(state->kbd_row, bit)) data &= input_port_read(device->machine, keynames[bit]);
52      if (!BIT(m_kbd_row, bit)) data &= input_port_read(machine, keynames[bit]);
5753
58   state->kbd_irq = (data == 0xff) ? 1 : 0;
59   if (state->control_bits & 8) data<<=4;
54   m_kbd_irq = (data == 0xff) ? 1 : 0;
55   if (m_control_bits & 8) data<<=4;
6056   return data;
6157}
6258
63static WRITE8_DEVICE_HANDLER( pegasus_keyboard_w )
59WRITE8_MEMBER( pegasus_state::pegasus_keyboard_w )
6460{
65   pegasus_state *state = device->machine->driver_data<pegasus_state>();
66   state->kbd_row = data;
61   m_kbd_row = data;
6762}
6863
69static WRITE8_DEVICE_HANDLER( pegasus_controls )
64WRITE8_MEMBER( pegasus_state::pegasus_controls_w )
7065{
71   pegasus_state *state = device->machine->driver_data<pegasus_state>();
7266/*  d0,d2 - not emulated
7367    d0 - Blank - Video blanking
7468    d1 - Char - select character rom or ram
r10067r10068
7670    d3 - Asc - Select which half of the keyboard to read
7771*/
7872
79   state->control_bits = data;
73   m_control_bits = data;
8074}
8175
82static READ_LINE_DEVICE_HANDLER( pegasus_keyboard_irq )
76READ_LINE_MEMBER( pegasus_state::pegasus_keyboard_irq )
8377{
84   pegasus_state *state = device->machine->driver_data<pegasus_state>();
85   return state->kbd_irq;
78   return m_kbd_irq;
8679}
8780
88static READ_LINE_DEVICE_HANDLER( pegasus_cassette_r )
81READ_LINE_MEMBER( pegasus_state::pegasus_cassette_r )
8982{
90   pegasus_state *state = device->machine->driver_data<pegasus_state>();
91   return cassette_input(state->cass);
83   return cassette_input(m_cass);
9284}
9385
94static WRITE_LINE_DEVICE_HANDLER( pegasus_cassette_w )
86WRITE_LINE_MEMBER( pegasus_state::pegasus_cassette_w )
9587{
96   pegasus_state *drvstate = device->machine->driver_data<pegasus_state>();
97   cassette_output(drvstate->cass, state ? 1 : -1);
88   cassette_output(m_cass, state ? 1 : -1);
9889}
9990
100static READ8_HANDLER( pegasus_pcg_r )
91READ8_MEMBER( pegasus_state::pegasus_pcg_r )
10192{
102   pegasus_state *state = space->machine->driver_data<pegasus_state>();
103   UINT8 code = state->video_ram[offset] & 0x7f;
104   return state->FNT[(code << 4) | (~state->kbd_row & 15)];
93   UINT8 code = m_videoram[offset] & 0x7f;
94   return m_pcgram[(code << 4) | (~m_kbd_row & 15)];
10595}
10696
107static WRITE8_HANDLER( pegasus_pcg_w )
97WRITE8_MEMBER( pegasus_state::pegasus_pcg_w )
10898{
109   pegasus_state *state = space->machine->driver_data<pegasus_state>();
110//  if (state->control_bits & 2)
99//  if (state->m_control_bits & 2)
111100   {
112      UINT8 code = state->video_ram[offset] & 0x7f;
113      state->FNT[(code << 4) | (~state->kbd_row & 15)] = data;
101      UINT8 code = m_videoram[offset] & 0x7f;
102      m_pcgram[(code << 4) | (~m_kbd_row & 15)] = data;
114103   }
115104}
116105
117106/* Must return the A register except when it is doing a rom search */
118static READ8_HANDLER( pegasus_protection_r )
107READ8_MEMBER( pegasus_state::pegasus_protection_r )
119108{
120   UINT8 data = cpu_get_reg(space->machine->device("maincpu"), M6809_A);
109   UINT8 data = cpu_get_reg(m_maincpu, M6809_A);
121110   if (data == 0x20) data = 0xff;
122111   return data;
123112}
124113
125static ADDRESS_MAP_START(pegasus_mem, ADDRESS_SPACE_PROGRAM, 8)
114static ADDRESS_MAP_START(pegasus_mem, ADDRESS_SPACE_PROGRAM, 8, pegasus_state)
126115   ADDRESS_MAP_UNMAP_HIGH
127116   AM_RANGE(0x0000, 0x2fff) AM_ROM
128117   AM_RANGE(0xb000, 0xbdff) AM_RAM
129   AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE_MEMBER(pegasus_state, video_ram)
118   AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE(m_videoram)
130119   AM_RANGE(0xc000, 0xdfff) AM_ROM AM_WRITENOP
131120   AM_RANGE(0xe000, 0xe1ff) AM_READ(pegasus_protection_r)
132121   AM_RANGE(0xe200, 0xe3ff) AM_READWRITE(pegasus_pcg_r,pegasus_pcg_w)
133   AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_u", pia6821_r, pia6821_w)
134   AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_s", pia6821_r, pia6821_w)
122   AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_u", pia6821_r, pia6821_w)
123   AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_s", pia6821_r, pia6821_w)
135124   AM_RANGE(0xf000, 0xffff) AM_ROM
136125ADDRESS_MAP_END
137126
138static ADDRESS_MAP_START(pegasusm_mem, ADDRESS_SPACE_PROGRAM, 8)
127static ADDRESS_MAP_START(pegasusm_mem, ADDRESS_SPACE_PROGRAM, 8, pegasus_state)
139128   ADDRESS_MAP_UNMAP_HIGH
140129   AM_RANGE(0x0000, 0x2fff) AM_ROM
141130   AM_RANGE(0x5000, 0xbdff) AM_RAM
142   AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE_MEMBER(pegasus_state, video_ram)
131   AM_RANGE(0xbe00, 0xbfff) AM_RAM AM_BASE(m_videoram)
143132   AM_RANGE(0xc000, 0xdfff) AM_ROM AM_WRITENOP
144133   AM_RANGE(0xe000, 0xe1ff) AM_READ(pegasus_protection_r)
145134   AM_RANGE(0xe200, 0xe3ff) AM_READWRITE(pegasus_pcg_r,pegasus_pcg_w)
146   AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_u", pia6821_r, pia6821_w)
147   AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE("pegasus_pia_s", pia6821_r, pia6821_w)
135   AM_RANGE(0xe400, 0xe403) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_u", pia6821_r, pia6821_w)
136   AM_RANGE(0xe600, 0xe603) AM_MIRROR(0x1fc) AM_DEVREADWRITE_LEGACY("pia_s", pia6821_r, pia6821_w)
148137   AM_RANGE(0xf000, 0xffff) AM_ROM
149138ADDRESS_MAP_END
150139
r10067r10068
235224static const pia6821_interface pegasus_pia_s_intf=
236225{
237226   DEVCB_NULL,                  /* port A input */
238   DEVCB_HANDLER(pegasus_keyboard_r),         /* port B input */
239   DEVCB_LINE(pegasus_cassette_r),            /* CA1 input */
240   DEVCB_LINE(pegasus_keyboard_irq),         /* CB1 input */
227   DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_keyboard_r),   /* port B input */
228   DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_cassette_r), /* CA1 input */
229   DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_keyboard_irq), /* CB1 input */
241230   DEVCB_NULL,                  /* CA2 input */
242231   DEVCB_NULL,                  /* CB2 input */
243   DEVCB_HANDLER(pegasus_keyboard_w),         /* port A output */
244   DEVCB_HANDLER(pegasus_controls),         /* port B output */
245   DEVCB_LINE(pegasus_cassette_w),            /* CA2 output */
246   DEVCB_DEVICE_LINE("maincpu", pegasus_firq_clr),      /* CB2 output */
232   DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_keyboard_w),   /* port A output */
233   DEVCB_DRIVER_MEMBER(pegasus_state, pegasus_controls_w),   /* port B output */
234   DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_cassette_w), /* CA2 output */
235   DEVCB_DRIVER_LINE_MEMBER(pegasus_state, pegasus_firq_clr), /* CB2 output */
247236   DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE),   /* IRQA output */
248237   DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE)      /* IRQB output */
249238};
r10067r10068
337326static MACHINE_START( pegasus )
338327{
339328   pegasus_state *state = machine->driver_data<pegasus_state>();
340   state->cass = machine->device("cassette");
341   state->FNT = machine->region("pcg")->base();
329   state->m_pcgram = machine->region("pcg")->base();
342330}
343331
344332static MACHINE_RESET( pegasus )
345333{
346334   pegasus_state *state = machine->driver_data<pegasus_state>();
347   state->kbd_row = 0;
348   state->kbd_irq = 1;
349   state->control_bits = 0;
335   state->m_kbd_row = 0;
336   state->m_kbd_irq = 1;
337   state->m_control_bits = 0;
350338}
351339
352340static DRIVER_INIT( pegasus )
r10067r10068
374362   MCFG_VIDEO_UPDATE(pegasus)
375363
376364   /* devices */
377   MCFG_PIA6821_ADD( "pegasus_pia_s", pegasus_pia_s_intf )
378   MCFG_PIA6821_ADD( "pegasus_pia_u", pegasus_pia_u_intf )
365   MCFG_PIA6821_ADD( "pia_s", pegasus_pia_s_intf )
366   MCFG_PIA6821_ADD( "pia_u", pegasus_pia_u_intf )
379367   MCFG_CARTSLOT_ADD("cart1")
380368   MCFG_CARTSLOT_EXTENSION_LIST("bin")
381369   MCFG_CARTSLOT_LOAD(pegasus_cart_1)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team