Previous 15994 Revisions Next

r9685 Sunday 28th November, 2010 at 16:34:39 UTC by Nathan Woods
More Atari Ace stuff. [Atari Ace]
[src/mess/drivers]m20.c mccpm.c mes.c microdec.c mycom.c nanos.c ob68k1a.c palm.c pc2000.c pce220.c pcm.c pimps.c pk8000.c plan80.c pockstat.c prestige.c pv1000.c pv9234.c pyl601.c rx78.c scv.c spc1000.c ssem.c sun1.c ti99_2.c tk80bs.c tm990189.c tricep.c tutor.c tvc.c vt100.c zrt80.c

src/mess/drivers/plan80.c
r9684r9685
99#include "emu.h"
1010#include "cpu/i8085/i8085.h"
1111
12static UINT8* plan80_video_ram;
12
13class plan80_state : public driver_device
14{
15public:
16   plan80_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   UINT8* video_ram;
20};
21
22
1323static ADDRESS_MAP_START(plan80_mem, ADDRESS_SPACE_PROGRAM, 8)
1424   ADDRESS_MAP_UNMAP_HIGH
1525   AM_RANGE(0x0000, 0xefff) AM_RAM
16   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&plan80_video_ram)
26   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE_MEMBER(plan80_state, video_ram)
1727   AM_RANGE(0xf800, 0xffff) AM_ROM
1828ADDRESS_MAP_END
1929
r9684r9685
3646
3747static VIDEO_UPDATE( plan80 )
3848{
49   plan80_state *state = screen->machine->driver_data<plan80_state>();
3950   UINT8 *gfx = memory_region(screen->machine, "gfx");
4051   int x,y,j,b;
4152   UINT16 addr;
r9684r9685
4556      addr = y*64;
4657      for(x = 0; x < 48; x++ )
4758      {
48         UINT8 code = plan80_video_ram[addr + x];
59         UINT8 code = state->video_ram[addr + x];
4960         for(j = 0; j < 8; j++ )
5061         {
5162            UINT8 val = gfx[code*8 + j];
r9684r9685
7990GFXDECODE_END
8091
8192
82static MACHINE_CONFIG_START( plan80, driver_device )
93static MACHINE_CONFIG_START( plan80, plan80_state )
8394    /* basic machine hardware */
8495    MDRV_CPU_ADD("maincpu",I8080, 2048000)
8596    MDRV_CPU_PROGRAM_MAP(plan80_mem)
src/mess/drivers/mycom.c
r9684r9685
5656#include "devices/flopdrv.h"
5757#include "formats/basicdsk.h"
5858
59static running_device *mc6845;
60static running_device *mycom_audio;
61static running_device *mycom_cassette;
62static running_device *mycom_fdc;
63static UINT8 *vram;
64static UINT8 *gfx_rom;
65static UINT16 vram_addr;
66static UINT8 keyb_press,keyb_press_flag;
67static UINT8 mycom_0a,sn_we;
68static UINT32 upper_sw;
69static UINT8 *RAM;
7059
60class mycom_state : public driver_device
61{
62public:
63   mycom_state(running_machine &machine, const driver_device_config_base &config)
64      : driver_device(machine, config) { }
65
66   running_device *mc6845;
67   running_device *audio;
68   running_device *cassette;
69   running_device *fdc;
70   UINT8 *vram;
71   UINT8 *gfx_rom;
72   UINT16 vram_addr;
73   UINT8 keyb_press;
74   UINT8 keyb_press_flag;
75   UINT8 _0a;
76   UINT8 sn_we;
77   UINT32 upper_sw;
78   UINT8 *RAM;
79};
80
81
82
7183static VIDEO_START( mycom )
7284{
73   mc6845 = machine->device("crtc");
74   vram = memory_region(machine, "vram");
75   gfx_rom = memory_region(machine, "gfx");
85   mycom_state *state = machine->driver_data<mycom_state>();
86   state->mc6845 = machine->device("crtc");
87   state->vram = memory_region(machine, "vram");
88   state->gfx_rom = memory_region(machine, "gfx");
7689}
7790
7891static VIDEO_UPDATE( mycom )
7992{
80   mc6845_update(mc6845, bitmap, cliprect);
93   mycom_state *state = screen->machine->driver_data<mycom_state>();
94   mc6845_update(state->mc6845, bitmap, cliprect);
8195   return 0;
8296}
8397
8498static MC6845_UPDATE_ROW( mycom_update_row )
8599{
100   mycom_state *state = device->machine->driver_data<mycom_state>();
86101   UINT8 chr,gfx=0,z;
87102   UINT16 mem,x;
88103   UINT16 *p = BITMAP_ADDR16(bitmap, y, 0);
89104
90   if (mycom_0a & 0x40)
105   if (state->_0a & 0x40)
91106   {
92107      for (x = 0; x < x_count; x++)               // lores pixels
93108      {
94109         UINT8 dbit=1;
95110         if (x == cursor_x) dbit=0;
96111         mem = (ma + x) & 0x7ff;
97         chr = vram[mem];
112         chr = state->vram[mem];
98113         z = ra / 3;
99114         *p++ = BIT( chr, z ) ? dbit: dbit^1;
100115         *p++ = BIT( chr, z ) ? dbit: dbit^1;
r9684r9685
118133            gfx = inv;   // some blank spacing lines
119134         else
120135         {
121            chr = vram[mem];
122            gfx = gfx_rom[(chr<<3) | ra] ^ inv;
136            chr = state->vram[mem];
137            gfx = state->gfx_rom[(chr<<3) | ra] ^ inv;
123138         }
124139
125140         /* Display a scanline of a character */
r9684r9685
137152
138153static WRITE8_HANDLER( mycom_00_w )
139154{
155   mycom_state *state = space->machine->driver_data<mycom_state>();
140156   switch(data)
141157   {
142158      case 0x00: memory_set_bank(space->machine, "boot", 1); break;
143159      case 0x01: memory_set_bank(space->machine, "boot", 0); break;
144      case 0x02: upper_sw = 0x10000; break;
145      case 0x03: upper_sw = 0x0c000; break;
160      case 0x02: state->upper_sw = 0x10000; break;
161      case 0x03: state->upper_sw = 0x0c000; break;
146162   }
147163}
148164
149165static READ8_HANDLER( mycom_upper_r )
150166{
151   return RAM[offset | upper_sw];
167   mycom_state *state = space->machine->driver_data<mycom_state>();
168   return state->RAM[offset | state->upper_sw];
152169}
153170
154171static WRITE8_HANDLER( mycom_upper_w )
155172{
156   RAM[offset | 0xc000] = data;
173   mycom_state *state = space->machine->driver_data<mycom_state>();
174   state->RAM[offset | 0xc000] = data;
157175}
158176
159177static READ8_HANDLER( vram_data_r )
160178{
161   return vram[vram_addr];
179   mycom_state *state = space->machine->driver_data<mycom_state>();
180   return state->vram[state->vram_addr];
162181}
163182
164183static WRITE8_HANDLER( vram_data_w )
165184{
166   vram[vram_addr] = data;
185   mycom_state *state = space->machine->driver_data<mycom_state>();
186   state->vram[state->vram_addr] = data;
167187}
168188
169189static ADDRESS_MAP_START(mycom_map, ADDRESS_SPACE_PROGRAM, 8)
r9684r9685
312332
313333static WRITE8_DEVICE_HANDLER( mycom_04_w )
314334{
315   vram_addr = (vram_addr & 0x700) | data;
335   mycom_state *state = device->machine->driver_data<mycom_state>();
336   state->vram_addr = (state->vram_addr & 0x700) | data;
316337
317   sn_we = data;
338   state->sn_we = data;
318339   /* doesn't work? */
319340   //printf(":%X ",data);
320   //if(sn_we)
321     //sn76496_w(mycom_audio, 0, data);
341   //if(state->sn_we)
342     //sn76496_w(state->audio, 0, data);
322343}
323344
324345static WRITE8_DEVICE_HANDLER( mycom_06_w )
325346{
326   vram_addr = (vram_addr & 0x0ff) | ((data & 0x007) << 8);
347   mycom_state *state = device->machine->driver_data<mycom_state>();
348   state->vram_addr = (state->vram_addr & 0x0ff) | ((data & 0x007) << 8);
327349}
328350
329351static READ8_DEVICE_HANDLER( mycom_08_r )
330352{
353   mycom_state *state = device->machine->driver_data<mycom_state>();
331354   /*
332355    x--- ---- display flag
333356    ---- --x- keyboard shift
r9684r9685
335358    */
336359   UINT8 data = 0;
337360
338   data = keyb_press_flag; //~keyb_press_flag & 1;
361   data = state->keyb_press_flag; //~state->keyb_press_flag & 1;
339362
340   if (cassette_input(mycom_cassette) > 0.03) // not working
363   if (cassette_input(state->cassette) > 0.03) // not working
341364      data+=4;
342365
343366   return data;
r9684r9685
356379
357380static READ8_DEVICE_HANDLER( mycom_05_r )
358381{
359   return keyb_press;
382   mycom_state *state = device->machine->driver_data<mycom_state>();
383   return state->keyb_press;
360384}
361385
362386static WRITE8_DEVICE_HANDLER( mycom_0a_w )
363387{
388   mycom_state *state = device->machine->driver_data<mycom_state>();
364389   /*
365390    x--- ---- width 80/40 (0 = 80, 1 = 40)
366391    -x-- ---- video mode (0= tile, 1 = bitmap)
r9684r9685
372397    ---- ---x printer strobe
373398    */
374399
375   if ((mycom_0a & 8) != (data & 8))
376      cassette_change_state(mycom_cassette,
400   if ((state->_0a & 8) != (data & 8))
401      cassette_change_state(state->cassette,
377402      (data & 8) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
378403
379404   if (data & 8) // motor on
380      cassette_output(mycom_cassette, (data & 4) ? -1.0 : +1.0);
405      cassette_output(state->cassette, (data & 4) ? -1.0 : +1.0);
381406
382   if ((data & 0x80) != (mycom_0a & 0x80))
383      mc6845_set_clock(mc6845, (data & 0x80) ? 1008000 : 2016000);
407   if ((data & 0x80) != (state->_0a & 0x80))
408      mc6845_set_clock(state->mc6845, (data & 0x80) ? 1008000 : 2016000);
384409
385   mycom_0a = data;
410   state->_0a = data;
386411
387412   /* Info about sound
388413   - uses a SN76489N chip at an unknown clock
r9684r9685
394419
395420   // no sound comes out
396421   if ((data & 0x30)==0)
397      sn76496_w(mycom_audio, 0, sn_we);
422      sn76496_w(state->audio, 0, state->sn_we);
398423}
399424
400425static I8255A_INTERFACE( ppi8255_intf_0 )
r9684r9685
441466
442467static TIMER_CALLBACK( mycom_kbd )
443468{
469   mycom_state *state = machine->driver_data<mycom_state>();
444470   UINT8 x, y, scancode = 0;
445471   UINT16 pressed[9];
446472   char kbdrow[2];
447473   UINT8 modifiers = input_port_read(machine, "XX");
448474   UINT8 shift_pressed = (modifiers & 2) >> 1;
449   keyb_press_flag = 0;
475   state->keyb_press_flag = 0;
450476
451477   /* see what is pressed */
452478   for (x = 0; x < 9; x++)
r9684r9685
466492            if (BIT(pressed[x], y))
467493            {
468494               scancode = ((x + y * 9) << 1) + shift_pressed + 1;
469               keyb_press_flag = 1;
470               keyb_press = mycom_keyval[scancode];
495               state->keyb_press_flag = 1;
496               state->keyb_press = mycom_keyval[scancode];
471497            }
472498         }
473499      }
474500   }
475501
476   if (keyb_press_flag)
502   if (state->keyb_press_flag)
477503   {
478      if (modifiers & 1) keyb_press &= 0xbf;
479      if (modifiers & 4) keyb_press |= 0x80;
504      if (modifiers & 1) state->keyb_press &= 0xbf;
505      if (modifiers & 4) state->keyb_press |= 0x80;
480506   }
481507}
482508
483509static MACHINE_START(mycom)
484510{
485   mycom_audio = machine->device("sn1");
486   mycom_cassette = machine->device("cassette");
487   mycom_fdc = machine->device("fdc");
488   RAM = memory_region(machine, "maincpu");
511   mycom_state *state = machine->driver_data<mycom_state>();
512   state->audio = machine->device("sn1");
513   state->cassette = machine->device("cassette");
514   state->fdc = machine->device("fdc");
515   state->RAM = memory_region(machine, "maincpu");
489516   timer_pulse(machine, ATTOTIME_IN_HZ(20), NULL, 0, mycom_kbd);
490517}
491518
492519static MACHINE_RESET(mycom)
493520{
521   mycom_state *state = machine->driver_data<mycom_state>();
494522   memory_set_bank(machine, "boot", 1);
495   upper_sw = 0x10000;
496   mycom_0a = 0;
523   state->upper_sw = 0x10000;
524   state->_0a = 0;
497525}
498526
499527static DRIVER_INIT( mycom )
r9684r9685
502530   memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x10000);
503531}
504532
505static MACHINE_CONFIG_START( mycom, driver_device )
533static MACHINE_CONFIG_START( mycom, mycom_state )
506534   /* basic machine hardware */
507535   MDRV_CPU_ADD("maincpu",Z80, XTAL_10MHz / 4)
508536   MDRV_CPU_PROGRAM_MAP(mycom_map)
src/mess/drivers/spc1000.c
r9684r9685
1515#include "devices/cassette.h"
1616#include "devices/messram.h"
1717
18static UINT8 IPLK;
19static UINT8 *spc1000_video_ram;
20static UINT8 GMODE;
2118
19class spc1000_state : public driver_device
20{
21public:
22   spc1000_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
24
25   UINT8 IPLK;
26   UINT8 *video_ram;
27   UINT8 GMODE;
28};
29
30
31
2232static ADDRESS_MAP_START(spc1000_mem, ADDRESS_SPACE_PROGRAM, 8)
2333   ADDRESS_MAP_UNMAP_HIGH
2434   AM_RANGE( 0x0000, 0x7fff ) AM_READ_BANK("bank1") AM_WRITE_BANK("bank2")
r9684r9685
2737
2838static WRITE8_HANDLER(spc1000_iplk_w)
2939{
30   IPLK = IPLK ? 0 : 1;
31   if (IPLK == 1) {
40   spc1000_state *state = space->machine->driver_data<spc1000_state>();
41   state->IPLK = state->IPLK ? 0 : 1;
42   if (state->IPLK == 1) {
3243      memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu"));
3344      memory_set_bankptr(space->machine, "bank3", memory_region(space->machine, "maincpu"));
3445   } else {
r9684r9685
3950
4051static READ8_HANDLER(spc1000_iplk_r)
4152{
42   IPLK = IPLK ? 0 : 1;
43   if (IPLK == 1) {
53   spc1000_state *state = space->machine->driver_data<spc1000_state>();
54   state->IPLK = state->IPLK ? 0 : 1;
55   if (state->IPLK == 1) {
4456      memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu"));
4557      memory_set_bankptr(space->machine, "bank3", memory_region(space->machine, "maincpu"));
4658   } else {
r9684r9685
5466
5567static WRITE8_HANDLER(spc1000_video_ram_w)
5668{
57   spc1000_video_ram[offset] = data;
69   spc1000_state *state = space->machine->driver_data<spc1000_state>();
70   state->video_ram[offset] = data;
5871}
5972
6073static READ8_HANDLER(spc1000_video_ram_r)
6174{
62   return spc1000_video_ram[offset];
75   spc1000_state *state = space->machine->driver_data<spc1000_state>();
76   return state->video_ram[offset];
6377}
6478
6579static READ8_HANDLER(spc1000_keyboard_r) {
r9684r9685
7286
7387static WRITE8_DEVICE_HANDLER(spc1000_gmode_w)
7488{
75   GMODE = data;
89   spc1000_state *state = device->machine->driver_data<spc1000_state>();
90   state->GMODE = data;
7691
77   // GMODE layout: CSS|NA|PS2|PS1|~A/G|GM0|GM1|NA
92   // state->GMODE layout: CSS|NA|PS2|PS1|~A/G|GM0|GM1|NA
7893   //  [PS2,PS1] is used to set screen 0/1 pages
7994   mc6847_gm1_w(device, BIT(data, 1));
8095   mc6847_gm0_w(device, BIT(data, 2));
r9684r9685
8499
85100static READ8_DEVICE_HANDLER(spc1000_gmode_r)
86101{
87   return GMODE;
102   spc1000_state *state = device->machine->driver_data<spc1000_state>();
103   return state->GMODE;
88104}
89105
90106static ADDRESS_MAP_START( spc1000_io , ADDRESS_SPACE_IO, 8)
r9684r9685
194210
195211static MACHINE_RESET(spc1000)
196212{
213   spc1000_state *state = machine->driver_data<spc1000_state>();
197214   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
198215
199216   memory_install_read_bank(space, 0x0000, 0x7fff, 0, 0, "bank1");
r9684r9685
207224   memory_set_bankptr(machine, "bank3", memory_region(machine, "maincpu"));
208225   memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x8000);
209226
210   IPLK = 1;
227   state->IPLK = 1;
211228}
212229
213230static READ8_DEVICE_HANDLER( spc1000_mc6847_videoram_r )
214231{
215   // GMODE layout: CSS|NA|PS2|PS1|~A/G|GM0|GM1|NA
232   spc1000_state *state = device->machine->driver_data<spc1000_state>();
233   // state->GMODE layout: CSS|NA|PS2|PS1|~A/G|GM0|GM1|NA
216234   //  [PS2,PS1] is used to set screen 0/1 pages
217   if ( !BIT(GMODE, 3) ) {   // text mode (~A/G set to A)
218      unsigned int page = (BIT(GMODE, 5) << 1) | BIT(GMODE, 4);
219      mc6847_inv_w(device, BIT(spc1000_video_ram[offset+page*0x200+0x800], 0));
220      mc6847_css_w(device, BIT(spc1000_video_ram[offset+page*0x200+0x800], 1));
221      mc6847_as_w(device, BIT(spc1000_video_ram[offset+page*0x200+0x800], 2));
222      mc6847_intext_w(device, BIT(spc1000_video_ram[offset+page*0x200+0x800], 3));
223      return spc1000_video_ram[offset+page*0x200];
235   if ( !BIT(state->GMODE, 3) ) {   // text mode (~A/G set to A)
236      unsigned int page = (BIT(state->GMODE, 5) << 1) | BIT(state->GMODE, 4);
237      mc6847_inv_w(device, BIT(state->video_ram[offset+page*0x200+0x800], 0));
238      mc6847_css_w(device, BIT(state->video_ram[offset+page*0x200+0x800], 1));
239      mc6847_as_w(device, BIT(state->video_ram[offset+page*0x200+0x800], 2));
240      mc6847_intext_w(device, BIT(state->video_ram[offset+page*0x200+0x800], 3));
241      return state->video_ram[offset+page*0x200];
224242   } else {   // graphics mode: uses full 6KB of VRAM
225      return spc1000_video_ram[offset];
243      return state->video_ram[offset];
226244   }
227245}
228246
229247
230248static UINT8 spc1000_get_char_rom(running_machine *machine, UINT8 ch, int line)
231249{
232   return spc1000_video_ram[0x1000+(ch&0x7F)*16+line];
250   spc1000_state *state = machine->driver_data<spc1000_state>();
251   return state->video_ram[0x1000+(ch&0x7F)*16+line];
233252}
234253
235254static VIDEO_START( spc1000 )
236255{
237   spc1000_video_ram = auto_alloc_array(machine, UINT8, 0x2000);
256   spc1000_state *state = machine->driver_data<spc1000_state>();
257   state->video_ram = auto_alloc_array(machine, UINT8, 0x2000);
238258}
239259
240260static VIDEO_UPDATE( spc1000 )
r9684r9685
274294   DEVCB_NULL                           // RS (output)
275295};
276296
277static MACHINE_CONFIG_START( spc1000, driver_device )
297static MACHINE_CONFIG_START( spc1000, spc1000_state )
278298   /* basic machine hardware */
279299   MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
280300   MDRV_CPU_PROGRAM_MAP(spc1000_mem)
src/mess/drivers/palm.c
r9684r9685
1616#include "debugger.h"
1717#include "devices/messram.h"
1818
19
20class palm_state : public driver_device
21{
22public:
23   palm_state(running_machine &machine, const driver_device_config_base &config)
24      : driver_device(machine, config) { }
25
26   UINT8 port_f_latch;
27   UINT16 spim_data;
28};
29
1930static offs_t palm_dasm_override(device_t &device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options);
2031
21static UINT8 port_f_latch;
22static UINT16 spim_data;
2332
2433/***************************************************************************
2534    MACHINE HARDWARE
r9684r9685
4958
5059static WRITE8_DEVICE_HANDLER( palm_port_f_out )
5160{
52    port_f_latch = data;
61   palm_state *state = device->machine->driver_data<palm_state>();
62    state->port_f_latch = data;
5363}
5464
5565static READ8_DEVICE_HANDLER( palm_port_c_in )
r9684r9685
5969
6070static READ8_DEVICE_HANDLER( palm_port_f_in )
6171{
62    return port_f_latch;
72   palm_state *state = device->machine->driver_data<palm_state>();
73    return state->port_f_latch;
6374}
6475
6576static WRITE16_DEVICE_HANDLER( palm_spim_out )
6677{
67    spim_data = data;
78   palm_state *state = device->machine->driver_data<palm_state>();
79    state->spim_data = data;
6880}
6981
7082static READ16_DEVICE_HANDLER( palm_spim_in )
7183{
72    return spim_data;
84   palm_state *state = device->machine->driver_data<palm_state>();
85    return state->spim_data;
7386}
7487
7588static void palm_spim_exchange( running_device *device )
7689{
90   palm_state *state = device->machine->driver_data<palm_state>();
7791    UINT8 x = input_port_read(device->machine, "PENX");
7892    UINT8 y = input_port_read(device->machine, "PENY");
7993
80    switch( port_f_latch & 0x0f )
94    switch( state->port_f_latch & 0x0f )
8195    {
8296        case 0x06:
83            spim_data = (0xff - x) * 2;
97            state->spim_data = (0xff - x) * 2;
8498            break;
8599
86100        case 0x09:
87            spim_data = (0xff - y) * 2;
101            state->spim_data = (0xff - y) * 2;
88102            break;
89103    }
90104}
91105
92106static MACHINE_START( palm )
93107{
108   palm_state *state = machine->driver_data<palm_state>();
94109    address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
95110    memory_install_read_bank (space, 0x000000, messram_get_size(machine->device("messram")) - 1, messram_get_size(machine->device("messram")) - 1, 0, "bank1");
96111    memory_install_write_bank(space, 0x000000, messram_get_size(machine->device("messram")) - 1, messram_get_size(machine->device("messram")) - 1, 0, "bank1");
97112    memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")));
98113
99    state_save_register_global(machine, port_f_latch);
100    state_save_register_global(machine, spim_data);
114    state_save_register_global(machine, state->port_f_latch);
115    state_save_register_global(machine, state->spim_data);
101116   if (machine->device<cpu_device>("maincpu")->debug()) {
102117      machine->device<cpu_device>("maincpu")->debug()->set_dasm_override(palm_dasm_override);
103118   }
r9684r9685
171186};
172187
173188
174static MACHINE_CONFIG_START( palm, driver_device )
189static MACHINE_CONFIG_START( palm, palm_state )
175190
176191    /* basic machine hardware */
177192    MDRV_CPU_ADD( "maincpu", M68000, 32768*506 )        /* 16.580608 MHz */
src/mess/drivers/tm990189.c
r9684r9685
4747#include "sound/wave.h"
4848#include "machine/serial.h"
4949
50static int load_state;
51static int ic_state;
5250
53static int digitsel;
54static int segment;
51class tm990189_state : public driver_device
52{
53public:
54   tm990189_state(running_machine &machine, const driver_device_config_base &config)
55      : driver_device(machine, config) { }
5556
56static emu_timer *displayena_timer;
57   int load_state;
58   int ic_state;
59   int digitsel;
60   int segment;
61   emu_timer *displayena_timer;
62   UINT8 segment_state[10];
63   UINT8 old_segment_state[10];
64   UINT8 LED_state;
65   emu_timer *joy1x_timer;
66   emu_timer *joy1y_timer;
67   emu_timer *joy2x_timer;
68   emu_timer *joy2y_timer;
69   int LED_display_window_left;
70   int LED_display_window_top;
71   int LED_display_window_width;
72   int LED_display_window_height;
73   device_image_interface *rs232_fp;
74   UINT8 rs232_rts;
75   emu_timer *rs232_input_timer;
76};
77
78
79
80
5781#define displayena_duration ATTOTIME_IN_USEC(4500)   /* Can anyone confirm this? 74LS123 connected to C=0.1uF and R=100kOhm */
58static UINT8 segment_state[10];
59static UINT8 old_segment_state[10];
60static UINT8 LED_state;
6182
62static emu_timer *joy1x_timer;
63static emu_timer *joy1y_timer;
64static emu_timer *joy2x_timer;
65static emu_timer *joy2y_timer;
6683
6784enum
6885{
r9684r9685
7491   0xFF,0x00,0x00   /* red for LEDs */
7592};
7693
77static int LED_display_window_left;
78static int LED_display_window_top;
79static int LED_display_window_width;
80static int LED_display_window_height;
8194
8295static void hold_load(running_machine *machine);
8396
8497
85static device_image_interface *rs232_fp;
86static UINT8 rs232_rts;
87static emu_timer *rs232_input_timer;
8898
8999static MACHINE_RESET( tm990_189 )
90100{
r9684r9685
93103
94104static MACHINE_START( tm990_189 )
95105{
96   displayena_timer = timer_alloc(machine, NULL, NULL);
106   tm990189_state *state = machine->driver_data<tm990189_state>();
107   state->displayena_timer = timer_alloc(machine, NULL, NULL);
97108}
98109static const TMS9928a_interface tms9918_interface =
99110{
r9684r9685
105116
106117static MACHINE_START( tm990_189_v )
107118{
119   tm990189_state *state = machine->driver_data<tm990189_state>();
108120   TMS9928A_configure(&tms9918_interface);
109121
110   displayena_timer = timer_alloc(machine, NULL, NULL);
122   state->displayena_timer = timer_alloc(machine, NULL, NULL);
111123
112   joy1x_timer = timer_alloc(machine, NULL, NULL);
113   joy1y_timer = timer_alloc(machine, NULL, NULL);
114   joy2x_timer = timer_alloc(machine, NULL, NULL);
115   joy2y_timer = timer_alloc(machine, NULL, NULL);
124   state->joy1x_timer = timer_alloc(machine, NULL, NULL);
125   state->joy1y_timer = timer_alloc(machine, NULL, NULL);
126   state->joy2x_timer = timer_alloc(machine, NULL, NULL);
127   state->joy2y_timer = timer_alloc(machine, NULL, NULL);
116128}
117129
118130static MACHINE_RESET( tm990_189_v )
r9684r9685
141153
142154static VIDEO_EOF( tm990_189 )
143155{
156   tm990189_state *state = machine->driver_data<tm990189_state>();
144157   int i;
145158
146159   for (i=0; i<10; i++)
147      segment_state[i] = 0;
160      state->segment_state[i] = 0;
148161}
149162
150INLINE void draw_digit(void)
163INLINE void draw_digit(tm990189_state *state)
151164{
152   segment_state[digitsel] |= ~segment;
165   state->segment_state[state->digitsel] |= ~state->segment;
153166}
154167
155static void update_common(bitmap_t *bitmap,
168static void update_common(running_machine *machine, bitmap_t *bitmap,
156169                     int display_x, int display_y,
157170                     int LED14_x, int LED14_y,
158171                     int LED56_x, int LED56_y,
159172                     int LED7_x, int LED7_y,
160173                     pen_t fore_color, pen_t back_color)
161174{
175   tm990189_state *state = machine->driver_data<tm990189_state>();
162176   int i, j;
163177   static const struct{ int x, y; int w, h; } bounds[8] =
164178   {
r9684r9685
174188
175189   for (i=0; i<10; i++)
176190   {
177      old_segment_state[i] |= segment_state[i];
191      state->old_segment_state[i] |= state->segment_state[i];
178192
179193      for (j=0; j<8; j++)
180194         plot_box(bitmap, display_x + i*16 + bounds[j].x, display_y + bounds[j].y,
181195                  bounds[j].w, bounds[j].h,
182                  (old_segment_state[i] & (1 << j)) ? fore_color : back_color);
196                  (state->old_segment_state[i] & (1 << j)) ? fore_color : back_color);
183197
184      old_segment_state[i] = segment_state[i];
198      state->old_segment_state[i] = state->segment_state[i];
185199   }
186200
187201   for (i=0; i<4; i++)
188202   {
189203      plot_box(bitmap, LED14_x + 48+4 - i*16, LED14_y + 4, 8, 8,
190               (LED_state & (1 << i)) ? fore_color : back_color);
204               (state->LED_state & (1 << i)) ? fore_color : back_color);
191205   }
192206
193207   plot_box(bitmap, LED7_x+4, LED7_y+4, 8, 8,
194            (LED_state & 0x10) ? fore_color : back_color);
208            (state->LED_state & 0x10) ? fore_color : back_color);
195209
196210   plot_box(bitmap, LED56_x+16+4, LED56_y+4, 8, 8,
197            (LED_state & 0x20) ? fore_color : back_color);
211            (state->LED_state & 0x20) ? fore_color : back_color);
198212
199213   plot_box(bitmap, LED56_x+4, LED56_y+4, 8, 8,
200            (LED_state & 0x40) ? fore_color : back_color);
214            (state->LED_state & 0x40) ? fore_color : back_color);
201215}
202216
203217static VIDEO_UPDATE( tm990_189 )
204218{
205   update_common(bitmap, 580, 150, 110, 508, 387, 456, 507, 478, 1, 0);
219   update_common(screen->machine, bitmap, 580, 150, 110, 508, 387, 456, 507, 478, 1, 0);
206220   return 0;
207221}
208222
209223static VIDEO_START( tm990_189_v )
210224{
225   tm990189_state *state = machine->driver_data<tm990189_state>();
211226   screen_device *screen = screen_first(*machine);
212227   const rectangle &visarea = screen->visible_area();
213228
214229   /* NPW 27-Feb-2006 - ewwww gross!!! maybe this can be fixed when
215230     * multimonitor support is added?*/
216   LED_display_window_left = visarea.min_x;
217   LED_display_window_top = visarea.max_y - 32;
218   LED_display_window_width = visarea.max_x - visarea.min_x;
219   LED_display_window_height = 32;
231   state->LED_display_window_left = visarea.min_x;
232   state->LED_display_window_top = visarea.max_y - 32;
233   state->LED_display_window_width = visarea.max_x - visarea.min_x;
234   state->LED_display_window_height = 32;
220235}
221236
222237static VIDEO_UPDATE( tm990_189_v )
223238{
239   tm990189_state *state = screen->machine->driver_data<tm990189_state>();
224240   VIDEO_UPDATE_CALL(tms9928a);
225241
226   plot_box(bitmap, LED_display_window_left, LED_display_window_top, LED_display_window_width, LED_display_window_height, screen->machine->pens[1]);
227   update_common(bitmap,
228               LED_display_window_left, LED_display_window_top,
229               LED_display_window_left, LED_display_window_top+16,
230               LED_display_window_left+80, LED_display_window_top+16,
231               LED_display_window_left+128, LED_display_window_top+16,
242   plot_box(bitmap, state->LED_display_window_left, state->LED_display_window_top, state->LED_display_window_width, state->LED_display_window_height, screen->machine->pens[1]);
243   update_common(screen->machine, bitmap,
244               state->LED_display_window_left, state->LED_display_window_top,
245               state->LED_display_window_left, state->LED_display_window_top+16,
246               state->LED_display_window_left+80, state->LED_display_window_top+16,
247               state->LED_display_window_left+128, state->LED_display_window_top+16,
232248               6, 1);
233249   return 0;
234250}
r9684r9685
239255
240256static void field_interrupts(running_machine *machine)
241257{
242   if (load_state)
258   tm990189_state *state = machine->driver_data<tm990189_state>();
259   if (state->load_state)
243260      cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, 2);
244261   else
245      cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, ic_state);
262      cputag_set_input_line_and_vector(machine, "maincpu", 0, ASSERT_LINE, state->ic_state);
246263}
247264
248265/*
r9684r9685
251268
252269static TIMER_CALLBACK(clear_load)
253270{
254   load_state = FALSE;
271   tm990189_state *state = machine->driver_data<tm990189_state>();
272   state->load_state = FALSE;
255273   field_interrupts(machine);
256274}
257275
258276static void hold_load(running_machine *machine)
259277{
260   load_state = TRUE;
278   tm990189_state *state = machine->driver_data<tm990189_state>();
279   state->load_state = TRUE;
261280   field_interrupts(machine);
262281   timer_set(machine, ATTOTIME_IN_MSEC(100), NULL, 0, clear_load);
263282}
r9684r9685
268287
269288static TMS9901_INT_CALLBACK ( usr9901_interrupt_callback )
270289{
271   ic_state = ic & 7;
290   tm990189_state *state = device->machine->driver_data<tm990189_state>();
291   state->ic_state = ic & 7;
272292
273   if (!load_state)
293   if (!state->load_state)
274294      field_interrupts(device->machine);
275295}
276296
277297static WRITE8_DEVICE_HANDLER( usr9901_led_w )
278298{
299   tm990189_state *state = device->machine->driver_data<tm990189_state>();
279300   if (data)
280      LED_state |= (1 << offset);
301      state->LED_state |= (1 << offset);
281302   else
282      LED_state &= ~(1 << offset);
303      state->LED_state &= ~(1 << offset);
283304}
284305
285306static TMS9901_INT_CALLBACK( sys9901_interrupt_callback )
r9684r9685
291312
292313static READ8_DEVICE_HANDLER( sys9901_r0 )
293314{
315   tm990189_state *state = device->machine->driver_data<tm990189_state>();
294316   int reply = 0x00;
295317   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", "LINE8" };
296318
297319   /* keyboard read */
298   if (digitsel < 9)
299      reply |= input_port_read(device->machine, keynames[digitsel]) << 1;
320   if (state->digitsel < 9)
321      reply |= input_port_read(device->machine, keynames[state->digitsel]) << 1;
300322
301323   /* tape input */
302324   if (cassette_input(device->machine->device("cassette")) > 0.0)
r9684r9685
307329
308330static WRITE8_DEVICE_HANDLER( sys9901_digitsel_w )
309331{
332   tm990189_state *state = device->machine->driver_data<tm990189_state>();
310333   if (data)
311      digitsel |= 1 << offset;
334      state->digitsel |= 1 << offset;
312335   else
313      digitsel &= ~ (1 << offset);
336      state->digitsel &= ~ (1 << offset);
314337}
315338
316339static WRITE8_DEVICE_HANDLER( sys9901_segment_w )
317340{
341   tm990189_state *state = device->machine->driver_data<tm990189_state>();
318342   if (data)
319      segment |= 1 << (offset-4);
343      state->segment |= 1 << (offset-4);
320344   else
321345   {
322      segment &= ~ (1 << (offset-4));
323      if ((attotime_compare(timer_timeleft(displayena_timer), attotime_zero) > 0) && (digitsel < 10))
324         draw_digit();
346      state->segment &= ~ (1 << (offset-4));
347      if ((attotime_compare(timer_timeleft(state->displayena_timer), attotime_zero) > 0) && (state->digitsel < 10))
348         draw_digit(state);
325349   }
326350}
327351
328352static WRITE8_DEVICE_HANDLER( sys9901_dsplytrgr_w )
329353{
330   if ((!data) && (digitsel < 10))
354   tm990189_state *state = device->machine->driver_data<tm990189_state>();
355   if ((!data) && (state->digitsel < 10))
331356   {
332      timer_reset(displayena_timer, displayena_duration);
333      draw_digit();
357      timer_reset(state->displayena_timer, displayena_duration);
358      draw_digit(state);
334359   }
335360}
336361
337362static WRITE8_DEVICE_HANDLER( sys9901_shiftlight_w )
338363{
364   tm990189_state *state = device->machine->driver_data<tm990189_state>();
339365   if (data)
340      LED_state |= 0x10;
366      state->LED_state |= 0x10;
341367   else
342      LED_state &= ~0x10;
368      state->LED_state &= ~0x10;
343369}
344370
345371static WRITE8_DEVICE_HANDLER( sys9901_spkrdrive_w )
r9684r9685
359385
360386static TIMER_CALLBACK(rs232_input_callback)
361387{
388   //tm990189_state *state = machine->driver_data<tm990189_state>();
362389   UINT8 buf;
363390   device_image_interface *image = (device_image_interface *)(ptr);
364   if (/*rs232_rts &&*/ /*(mame_ftell(rs232_fp) < mame_fsize(rs232_fp))*/1)
391   if (/*state->rs232_rts &&*/ /*(mame_ftell(state->rs232_fp) < mame_fsize(state->rs232_fp))*/1)
365392   {
366393      if (image->fread(&buf, 1) == 1)
367394         tms9902_push_data(machine->device("tms9902"), buf);
r9684r9685
373400*/
374401static DEVICE_IMAGE_LOAD( tm990_189_rs232 )
375402{
403   tm990189_state *state = image.device().machine->driver_data<tm990189_state>();
376404   tms9902_set_dsr(image.device().machine->device("tms9902"), 1);
377   rs232_input_timer = timer_alloc(image.device().machine, rs232_input_callback, (void*)image);
378   timer_adjust_periodic(rs232_input_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(10));
405   state->rs232_input_timer = timer_alloc(image.device().machine, rs232_input_callback, (void*)image);
406   timer_adjust_periodic(state->rs232_input_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(10));
379407
380408   return IMAGE_INIT_PASS;
381409}
r9684r9685
385413*/
386414static DEVICE_IMAGE_UNLOAD( tm990_189_rs232 )
387415{
416   tm990189_state *state = image.device().machine->driver_data<tm990189_state>();
388417   tms9902_set_dsr(image.device().machine->device("tms9902"), 0);
389418
390   timer_reset(rs232_input_timer, attotime_never);   /* FIXME - timers should only be allocated once */
419   timer_reset(state->rs232_input_timer, attotime_never);   /* FIXME - timers should only be allocated once */
391420}
392421
393422DEVICE_GET_INFO( tm990_189_rs232 )
r9684r9685
414443
415444static TMS9902_RST_CALLBACK( rts_callback )
416445{
417   rs232_rts = RTS;
446   tm990189_state *state = device->machine->driver_data<tm990189_state>();
447   state->rs232_rts = RTS;
418448   tms9902_set_cts(device, RTS);
419449}
420450
421451static TMS9902_XMIT_CALLBACK( xmit_callback )
422452{
453   tm990189_state *state = device->machine->driver_data<tm990189_state>();
423454   UINT8 buf = data;
424455
425   if (rs232_fp)
426      rs232_fp->fwrite(&buf, 1);
456   if (state->rs232_fp)
457      state->rs232_fp->fwrite(&buf, 1);
427458}
428459
429460/*
r9684r9685
432463
433464static WRITE8_HANDLER(ext_instr_decode)
434465{
466   tm990189_state *state = space->machine->driver_data<tm990189_state>();
435467   int ext_op_ID;
436468
437469   ext_op_ID = ((offset+0x800) >> 11) & 0x3;
r9684r9685
446478      break;
447479
448480   case 5: /* CKON: set DECKCONTROL */
449      LED_state |= 0x20;
481      state->LED_state |= 0x20;
450482      {
451483         running_device *img = space->machine->device("cassette");
452484         cassette_change_state(img, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
r9684r9685
454486      break;
455487
456488   case 6: /* CKOF: clear DECKCONTROL */
457      LED_state &= ~0x20;
489      state->LED_state &= ~0x20;
458490      {
459491         running_device *img = space->machine->device("cassette");
460492         cassette_change_state(img, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
r9684r9685
469501
470502static void idle_callback(running_device *device, int state)
471503{
504   tm990189_state *drvstate = device->machine->driver_data<tm990189_state>();
472505   if (state)
473      LED_state |= 0x40;
506      drvstate->LED_state |= 0x40;
474507   else
475      LED_state &= ~0x40;
508      drvstate->LED_state &= ~0x40;
476509}
477510
478511/*
r9684r9685
524557
525558static READ8_HANDLER(video_joy_r)
526559{
560   tm990189_state *state = space->machine->driver_data<tm990189_state>();
527561   int reply = input_port_read(space->machine, "BUTTONS");
528562
529563
530   if (attotime_compare(timer_timeleft(joy1x_timer), attotime_zero) < 0)
564   if (attotime_compare(timer_timeleft(state->joy1x_timer), attotime_zero) < 0)
531565      reply |= 0x01;
532566
533   if (attotime_compare(timer_timeleft(joy1y_timer), attotime_zero) < 0)
567   if (attotime_compare(timer_timeleft(state->joy1y_timer), attotime_zero) < 0)
534568      reply |= 0x02;
535569
536   if (attotime_compare(timer_timeleft(joy2x_timer), attotime_zero) < 0)
570   if (attotime_compare(timer_timeleft(state->joy2x_timer), attotime_zero) < 0)
537571      reply |= 0x08;
538572
539   if (attotime_compare(timer_timeleft(joy2y_timer), attotime_zero) < 0)
573   if (attotime_compare(timer_timeleft(state->joy2y_timer), attotime_zero) < 0)
540574      reply |= 0x10;
541575
542576   return reply;
r9684r9685
544578
545579static WRITE8_HANDLER(video_joy_w)
546580{
547   timer_reset(joy1x_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY1_X")*28+28));
548   timer_reset(joy1y_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY1_Y")*28+28));
549   timer_reset(joy2x_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY2_X")*28+28));
550   timer_reset(joy2y_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY2_Y")*28+28));
581   tm990189_state *state = space->machine->driver_data<tm990189_state>();
582   timer_reset(state->joy1x_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY1_X")*28+28));
583   timer_reset(state->joy1y_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY1_Y")*28+28));
584   timer_reset(state->joy2x_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY2_X")*28+28));
585   timer_reset(state->joy2y_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY2_Y")*28+28));
551586}
552587
553588/* user tms9901 setup */
r9684r9685
754789   idle_callback
755790};
756791
757static MACHINE_CONFIG_START( tm990_189, driver_device )
792static MACHINE_CONFIG_START( tm990_189, tm990189_state )
758793   /* basic machine hardware */
759794   /* TMS9980 CPU @ 2.0 MHz */
760795   MDRV_CPU_ADD("maincpu", TMS9980, 2000000)
r9684r9685
805840#define TOP_BORDER_60HZ      27
806841#define BOTTOM_BORDER_60HZ   24
807842
808static MACHINE_CONFIG_START( tm990_189_v, driver_device )
843static MACHINE_CONFIG_START( tm990_189_v, tm990189_state )
809844   /* basic machine hardware */
810845   /* TMS9980 CPU @ 2.0 MHz */
811846   MDRV_CPU_ADD("maincpu", TMS9980, 2000000)
src/mess/drivers/m20.c
r9684r9685
1919#include "cpu/i86/i86.h"
2020#include "video/mc6845.h"
2121
22
23class m20_state : public driver_device
24{
25public:
26   m20_state(running_machine &machine, const driver_device_config_base &config)
27      : driver_device(machine, config) { }
28
29   UINT16 *vram;
30};
31
32
2233#define MAIN_CLOCK 4000000 /* 4 MHz */
2334#define PIXEL_CLOCK XTAL_4_433619MHz
2435
25static UINT16 *m20_vram;
2636
2737static VIDEO_START( m20 )
2838{
r9684r9685
3040
3141static VIDEO_UPDATE( m20 )
3242{
43   m20_state *state = screen->machine->driver_data<m20_state>();
3344   int x,y,i;
3445   UINT8 pen;
3546   UINT32 count;
r9684r9685
4455      {
4556         for (i = 0; i < 16; i++)
4657         {
47            pen = (m20_vram[count]) >> (15 - i) & 1;
58            pen = (state->vram[count]) >> (15 - i) & 1;
4859
4960            if ((x + i) <= screen->visible_area().max_x && (y + 0) < screen->visible_area().max_y)
5061               *BITMAP_ADDR32(bitmap, y, x + i) = screen->machine->pens[pen];
r9684r9685
6172   AM_RANGE( 0x00000, 0x01fff ) AM_ROM AM_REGION("maincpu",0x10000)
6273   AM_RANGE( 0x40000, 0x41fff ) AM_ROM AM_REGION("maincpu",0x10000) //mirror
6374
64   AM_RANGE( 0x30000, 0x33fff ) AM_RAM AM_BASE(&m20_vram)//base vram
75   AM_RANGE( 0x30000, 0x33fff ) AM_RAM AM_BASE_MEMBER(m20_state, vram)//base vram
6576//  AM_RANGE( 0x34000, 0x37fff ) AM_RAM //extra vram for bitmap mode
6677//  AM_RANGE( 0x20000, 0x2???? ) //work RAM?
6778//
r9684r9685
136147   NULL      /* update address callback */
137148};
138149
139static MACHINE_CONFIG_START( m20, driver_device )
150static MACHINE_CONFIG_START( m20, m20_state )
140151    /* basic machine hardware */
141152    MDRV_CPU_ADD("maincpu", Z8001, MAIN_CLOCK)
142153    MDRV_CPU_PROGRAM_MAP(m20_mem)
src/mess/drivers/ssem.c
r9684r9685
99#include "devices/cartslot.h"
1010#include <stdarg.h>
1111
12static UINT8 *store;
13static UINT8 store_line = 0;
1412
13class ssem_state : public driver_device
14{
15public:
16   ssem_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   UINT8 *store;
20   UINT8 store_line;
21};
22
23
24
1525/****************************************************\
1626* General helper functions                           *
1727\****************************************************/
r9684r9685
4252\****************************************************/
4353
4454static ADDRESS_MAP_START( ssem_map, ADDRESS_SPACE_PROGRAM, 8 )
45    AM_RANGE(0x00, 0x7f) AM_RAM AM_BASE(&store)// Primary store
55    AM_RANGE(0x00, 0x7f) AM_RAM AM_BASE_MEMBER(ssem_state, store)// Primary store
4656ADDRESS_MAP_END
4757
4858/****************************************************\
r9684r9685
6979
7080static INPUT_CHANGED( panel_check )
7181{
82   ssem_state *state = field->port->machine->driver_data<ssem_state>();
7283    UINT8 edit0_state = input_port_read(field->port->machine, "EDIT0");
7384    UINT8 edit1_state = input_port_read(field->port->machine, "EDIT1");
7485    UINT8 edit2_state = input_port_read(field->port->machine, "EDIT2");
r9684r9685
7990    switch( (int)(FPTR)param )
8091    {
8192        case PANEL_BIT0:
82            if(edit0_state & 0x01) store[(store_line << 2) | 0] ^= 0x80;
93            if(edit0_state & 0x01) state->store[(state->store_line << 2) | 0] ^= 0x80;
8394            break;
8495        case PANEL_BIT1:
85            if(edit0_state & 0x02) store[(store_line << 2) | 0] ^= 0x40;
96            if(edit0_state & 0x02) state->store[(state->store_line << 2) | 0] ^= 0x40;
8697            break;
8798        case PANEL_BIT2:
88            if(edit0_state & 0x04) store[(store_line << 2) | 0] ^= 0x20;
99            if(edit0_state & 0x04) state->store[(state->store_line << 2) | 0] ^= 0x20;
89100            break;
90101        case PANEL_BIT3:
91            if(edit0_state & 0x08) store[(store_line << 2) | 0] ^= 0x10;
102            if(edit0_state & 0x08) state->store[(state->store_line << 2) | 0] ^= 0x10;
92103            break;
93104        case PANEL_BIT4:
94            if(edit0_state & 0x10) store[(store_line << 2) | 0] ^= 0x08;
105            if(edit0_state & 0x10) state->store[(state->store_line << 2) | 0] ^= 0x08;
95106            break;
96107        case PANEL_BIT5:
97            if(edit0_state & 0x20) store[(store_line << 2) | 0] ^= 0x04;
108            if(edit0_state & 0x20) state->store[(state->store_line << 2) | 0] ^= 0x04;
98109            break;
99110        case PANEL_BIT6:
100            if(edit0_state & 0x40) store[(store_line << 2) | 0] ^= 0x02;
111            if(edit0_state & 0x40) state->store[(state->store_line << 2) | 0] ^= 0x02;
101112            break;
102113        case PANEL_BIT7:
103            if(edit0_state & 0x80) store[(store_line << 2) | 0] ^= 0x01;
114            if(edit0_state & 0x80) state->store[(state->store_line << 2) | 0] ^= 0x01;
104115            break;
105116        case PANEL_BIT8:
106            if(edit1_state & 0x01) store[(store_line << 2) | 1] ^= 0x80;
117            if(edit1_state & 0x01) state->store[(state->store_line << 2) | 1] ^= 0x80;
107118            break;
108119        case PANEL_BIT9:
109            if(edit1_state & 0x02) store[(store_line << 2) | 1] ^= 0x40;
120            if(edit1_state & 0x02) state->store[(state->store_line << 2) | 1] ^= 0x40;
110121            break;
111122        case PANEL_BIT10:
112            if(edit1_state & 0x04) store[(store_line << 2) | 1] ^= 0x20;
123            if(edit1_state & 0x04) state->store[(state->store_line << 2) | 1] ^= 0x20;
113124            break;
114125        case PANEL_BIT11:
115            if(edit1_state & 0x08) store[(store_line << 2) | 1] ^= 0x10;
126            if(edit1_state & 0x08) state->store[(state->store_line << 2) | 1] ^= 0x10;
116127            break;
117128        case PANEL_BIT12:
118            if(edit1_state & 0x10) store[(store_line << 2) | 1] ^= 0x08;
129            if(edit1_state & 0x10) state->store[(state->store_line << 2) | 1] ^= 0x08;
119130            break;
120131        case PANEL_BIT13:
121            if(edit1_state & 0x20) store[(store_line << 2) | 1] ^= 0x04;
132            if(edit1_state & 0x20) state->store[(state->store_line << 2) | 1] ^= 0x04;
122133            break;
123134        case PANEL_BIT14:
124            if(edit1_state & 0x40) store[(store_line << 2) | 1] ^= 0x02;
135            if(edit1_state & 0x40) state->store[(state->store_line << 2) | 1] ^= 0x02;
125136            break;
126137        case PANEL_BIT15:
127            if(edit1_state & 0x80) store[(store_line << 2) | 1] ^= 0x01;
138            if(edit1_state & 0x80) state->store[(state->store_line << 2) | 1] ^= 0x01;
128139            break;
129140        case PANEL_BIT16:
130            if(edit2_state & 0x01) store[(store_line << 2) | 2] ^= 0x80;
141            if(edit2_state & 0x01) state->store[(state->store_line << 2) | 2] ^= 0x80;
131142            break;
132143        case PANEL_BIT17:
133            if(edit2_state & 0x02) store[(store_line << 2) | 2] ^= 0x40;
144            if(edit2_state & 0x02) state->store[(state->store_line << 2) | 2] ^= 0x40;
134145            break;
135146        case PANEL_BIT18:
136            if(edit2_state & 0x04) store[(store_line << 2) | 2] ^= 0x20;
147            if(edit2_state & 0x04) state->store[(state->store_line << 2) | 2] ^= 0x20;
137148            break;
138149        case PANEL_BIT19:
139            if(edit2_state & 0x08) store[(store_line << 2) | 2] ^= 0x10;
150            if(edit2_state & 0x08) state->store[(state->store_line << 2) | 2] ^= 0x10;
140151            break;
141152        case PANEL_BIT20:
142            if(edit2_state & 0x10) store[(store_line << 2) | 2] ^= 0x08;
153            if(edit2_state & 0x10) state->store[(state->store_line << 2) | 2] ^= 0x08;
143154            break;
144155        case PANEL_BIT21:
145            if(edit2_state & 0x20) store[(store_line << 2) | 2] ^= 0x04;
156            if(edit2_state & 0x20) state->store[(state->store_line << 2) | 2] ^= 0x04;
146157            break;
147158        case PANEL_BIT22:
148            if(edit2_state & 0x40) store[(store_line << 2) | 2] ^= 0x02;
159            if(edit2_state & 0x40) state->store[(state->store_line << 2) | 2] ^= 0x02;
149160            break;
150161        case PANEL_BIT23:
151            if(edit2_state & 0x80) store[(store_line << 2) | 2] ^= 0x01;
162            if(edit2_state & 0x80) state->store[(state->store_line << 2) | 2] ^= 0x01;
152163            break;
153164        case PANEL_BIT24:
154            if(edit3_state & 0x01) store[(store_line << 2) | 3] ^= 0x80;
165            if(edit3_state & 0x01) state->store[(state->store_line << 2) | 3] ^= 0x80;
155166            break;
156167        case PANEL_BIT25:
157            if(edit3_state & 0x02) store[(store_line << 2) | 3] ^= 0x40;
168            if(edit3_state & 0x02) state->store[(state->store_line << 2) | 3] ^= 0x40;
158169            break;
159170        case PANEL_BIT26:
160            if(edit3_state & 0x04) store[(store_line << 2) | 3] ^= 0x20;
171            if(edit3_state & 0x04) state->store[(state->store_line << 2) | 3] ^= 0x20;
161172            break;
162173        case PANEL_BIT27:
163            if(edit3_state & 0x08) store[(store_line << 2) | 3] ^= 0x10;
174            if(edit3_state & 0x08) state->store[(state->store_line << 2) | 3] ^= 0x10;
164175            break;
165176        case PANEL_BIT28:
166            if(edit3_state & 0x10) store[(store_line << 2) | 3] ^= 0x08;
177            if(edit3_state & 0x10) state->store[(state->store_line << 2) | 3] ^= 0x08;
167178            break;
168179        case PANEL_BIT29:
169            if(edit3_state & 0x20) store[(store_line << 2) | 3] ^= 0x04;
180            if(edit3_state & 0x20) state->store[(state->store_line << 2) | 3] ^= 0x04;
170181            break;
171182        case PANEL_BIT30:
172            if(edit3_state & 0x40) store[(store_line << 2) | 3] ^= 0x02;
183            if(edit3_state & 0x40) state->store[(state->store_line << 2) | 3] ^= 0x02;
173184            break;
174185        case PANEL_BIT31:
175            if(edit3_state & 0x80) store[(store_line << 2) | 3] ^= 0x01;
186            if(edit3_state & 0x80) state->store[(state->store_line << 2) | 3] ^= 0x01;
176187            break;
177188        case PANEL_LNUP:
178189            if(misc_state & 0x01)
179190            {
180                store_line--;
191                state->store_line--;
181192            }
182193            break;
183194        case PANEL_LNDN:
184195            if(misc_state & 0x02)
185196            {
186                store_line++;
197                state->store_line++;
187198            }
188199            break;
189200        case PANEL_HALT:
r9684r9685
430441
431442static VIDEO_UPDATE( ssem )
432443{
444   ssem_state *state = screen->machine->driver_data<ssem_state>();
433445    UINT32 line = 0;
434446    running_device *ssem_cpu = screen->machine->device("maincpu");
435447    UINT32 accum = cpu_get_reg(ssem_cpu, SSEM_A);
r9684r9685
438450
439451    for(line = 0; line < 32; line++)
440452    {
441        word = (store[(line << 2) | 0] << 24) |
442               (store[(line << 2) | 1] << 16) |
443               (store[(line << 2) | 2] <<  8) |
444               (store[(line << 2) | 3] <<  0);
453        word = (state->store[(line << 2) | 0] << 24) |
454               (state->store[(line << 2) | 1] << 16) |
455               (state->store[(line << 2) | 2] <<  8) |
456               (state->store[(line << 2) | 3] <<  0);
445457        for(bit = 0; bit < 32; bit++)
446458        {
447459            if(word & (1 << (31 - bit)))
448460            {
449                glyph_print(screen->machine, bitmap, bit << 3, line << 3, "%c", line == store_line ? 4 : 2);
461                glyph_print(screen->machine, bitmap, bit << 3, line << 3, "%c", line == state->store_line ? 4 : 2);
450462            }
451463            else
452464            {
453                glyph_print(screen->machine, bitmap, bit << 3, line << 3, "%c", line == store_line ? 3 : 1);
465                glyph_print(screen->machine, bitmap, bit << 3, line << 3, "%c", line == state->store_line ? 3 : 1);
454466            }
455467        }
456468    }
r9684r9685
467479        }
468480    }
469481
470    word = reverse((store[(store_line << 2) | 0] << 24) |
471                   (store[(store_line << 2) | 1] << 16) |
472                   (store[(store_line << 2) | 2] <<  8) |
473                   (store[(store_line << 2) | 3] <<  0));
474    glyph_print(screen->machine, bitmap, 0, 272, "LINE:%02d  VALUE:%08x  HALT:%d", store_line, word, cpu_get_reg(ssem_cpu, SSEM_HALT));
482    word = reverse((state->store[(state->store_line << 2) | 0] << 24) |
483                   (state->store[(state->store_line << 2) | 1] << 16) |
484                   (state->store[(state->store_line << 2) | 2] <<  8) |
485                   (state->store[(state->store_line << 2) | 3] <<  0));
486    glyph_print(screen->machine, bitmap, 0, 272, "LINE:%02d  VALUE:%08x  HALT:%d", state->store_line, word, cpu_get_reg(ssem_cpu, SSEM_HALT));
475487    return 0;
476488}
477489
r9684r9685
500512
501513static DEVICE_IMAGE_LOAD(ssem_store)
502514{
515   ssem_state *state = image.device().machine->driver_data<ssem_state>();
503516    const char* image_name = image.filename();
504517    char image_ext[5] = { 0 };
505518    char image_line[100] = { 0 };
r9684r9685
540553                    }
541554                }
542555
543                store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
544                store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
545                store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
546                store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
556                state->store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
557                state->store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
558                state->store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
559                state->store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
547560            }
548561            else if(strcmp(image_ext, ".asm") == 0)
549562            {
r9684r9685
594607                    word = 0x00070000 | unsigned_value;
595608                }
596609
597                store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
598                store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
599                store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
600                store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
610                state->store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
611                state->store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
612                state->store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
613                state->store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
601614            }
602615        }
603616    }
r9684r9685
611624
612625static MACHINE_RESET( ssem )
613626{
614    store_line = 0;
627   ssem_state *state = machine->driver_data<ssem_state>();
628    state->store_line = 0;
615629}
616630
617static MACHINE_CONFIG_START( ssem, driver_device )
631static MACHINE_CONFIG_START( ssem, ssem_state )
618632    /* basic machine hardware */
619633    MDRV_CPU_ADD("maincpu", SSEM, 700)
620634    MDRV_CPU_PROGRAM_MAP(ssem_map)
src/mess/drivers/tvc.c
r9684r9685
1111#include "video/mc6845.h"
1212#include "devices/messram.h"
1313
14static UINT8 tvc_video_mode = 0;
15static UINT8 tvc_keyline = 0;
16static UINT8 tvc_flipflop;
1714
15class tvc_state : public driver_device
16{
17public:
18   tvc_state(running_machine &machine, const driver_device_config_base &config)
19      : driver_device(machine, config) { }
20
21   UINT8 video_mode;
22   UINT8 keyline;
23   UINT8 flipflop;
24   UINT8 col[4];
25};
26
27
28
1829static void tvc_set_mem_page(running_machine *machine, UINT8 data)
1930{
2031   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
r9684r9685
7485
7586static WRITE8_HANDLER( tvc_video_mode_w )
7687{
77   tvc_video_mode = data & 0x03;
88   tvc_state *state = space->machine->driver_data<tvc_state>();
89   state->video_mode = data & 0x03;
7890}
7991
80static UINT8 col[4];
8192
8293static WRITE8_HANDLER( tvc_palette_w )
8394{
95   tvc_state *state = space->machine->driver_data<tvc_state>();
8496   //  0 I 0 R | 0 G 0 B
8597   //  0 0 0 0 | I R G B
8698   int i = ((data&0x40)>>3) | ((data&0x10)>>2) | ((data&0x04)>>1) | (data&0x01);
8799
88   col[offset] = i;
100   state->col[offset] = i;
89101}
90102
91103static WRITE8_HANDLER( tvc_keyboard_w )
92104{
93   tvc_keyline = data;
105   tvc_state *state = space->machine->driver_data<tvc_state>();
106   state->keyline = data;
94107}
95108
96109static READ8_HANDLER( tvc_keyboard_r )
97110{
111   tvc_state *state = space->machine->driver_data<tvc_state>();
98112   static const char *const keynames[] = {
99113      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
100114      "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF"
101115   };
102   return input_port_read(space->machine, keynames[tvc_keyline & 0x0f]);
116   return input_port_read(space->machine, keynames[state->keyline & 0x0f]);
103117}
104118
105119static READ8_HANDLER( tvc_flipflop_r )
106120{
107   return tvc_flipflop;
121   tvc_state *state = space->machine->driver_data<tvc_state>();
122   return state->flipflop;
108123}
109124
110125static WRITE8_HANDLER( tvc_flipflop_w )
111126{
112   tvc_flipflop |= 0x10;
127   tvc_state *state = space->machine->driver_data<tvc_state>();
128   state->flipflop |= 0x10;
113129}
114130static READ8_HANDLER( tvc_port59_r )
115131{
r9684r9685
237253
238254static MACHINE_START(tvc)
239255{
256   tvc_state *state = machine->driver_data<tvc_state>();
240257   int i;
241258
242259   for (i=0; i<4; i++)
243      col[i] = i;
260      state->col[i] = i;
244261
245   tvc_flipflop = 0xff;
262   state->flipflop = 0xff;
246263}
247264
248265static MACHINE_RESET(tvc)
249266{
267   tvc_state *state = machine->driver_data<tvc_state>();
250268   memset(messram_get_ptr(machine->device("messram")),0,(64+14)*1024);
251269   tvc_set_mem_page(machine, 0);
252   tvc_video_mode = 0;
270   state->video_mode = 0;
253271}
254272
255273static VIDEO_START( tvc )
r9684r9685
265283
266284static MC6845_UPDATE_ROW( tvc_update_row )
267285{
286   tvc_state *state = device->machine->driver_data<tvc_state>();
268287   UINT16  *p = BITMAP_ADDR16(bitmap, y, 0);
269288   int i;
270289
271   switch(tvc_video_mode) {
290   switch(state->video_mode) {
272291      case 0 :
273292            for ( i = 0; i < x_count; i++ )
274293            {
275294               UINT16 offset = i  + (y * 64);
276295               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
277               *p = col[(data >> 7)]; p++;
278               *p = col[(data >> 6)]; p++;
279               *p = col[(data >> 5)]; p++;
280               *p = col[(data >> 4)]; p++;
281               *p = col[(data >> 3)]; p++;
282               *p = col[(data >> 2)]; p++;
283               *p = col[(data >> 1)]; p++;
284               *p = col[(data >> 0)]; p++;
296               *p = state->col[(data >> 7)]; p++;
297               *p = state->col[(data >> 6)]; p++;
298               *p = state->col[(data >> 5)]; p++;
299               *p = state->col[(data >> 4)]; p++;
300               *p = state->col[(data >> 3)]; p++;
301               *p = state->col[(data >> 2)]; p++;
302               *p = state->col[(data >> 1)]; p++;
303               *p = state->col[(data >> 0)]; p++;
285304            }
286305            break;
287306      case 1 :
r9684r9685
289308            {
290309               UINT16 offset = i  + (y * 64);
291310               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
292               *p = col[BIT(data,7)*2 + BIT(data,3)]; p++;
293               *p = col[BIT(data,7)*2 + BIT(data,3)]; p++;
294               *p = col[BIT(data,6)*2 + BIT(data,2)]; p++;
295               *p = col[BIT(data,6)*2 + BIT(data,2)]; p++;
296               *p = col[BIT(data,5)*2 + BIT(data,1)]; p++;
297               *p = col[BIT(data,5)*2 + BIT(data,1)]; p++;
298               *p = col[BIT(data,4)*2 + BIT(data,0)]; p++;
299               *p = col[BIT(data,4)*2 + BIT(data,0)]; p++;
311               *p = state->col[BIT(data,7)*2 + BIT(data,3)]; p++;
312               *p = state->col[BIT(data,7)*2 + BIT(data,3)]; p++;
313               *p = state->col[BIT(data,6)*2 + BIT(data,2)]; p++;
314               *p = state->col[BIT(data,6)*2 + BIT(data,2)]; p++;
315               *p = state->col[BIT(data,5)*2 + BIT(data,1)]; p++;
316               *p = state->col[BIT(data,5)*2 + BIT(data,1)]; p++;
317               *p = state->col[BIT(data,4)*2 + BIT(data,0)]; p++;
318               *p = state->col[BIT(data,4)*2 + BIT(data,0)]; p++;
300319            }
301320            break;
302321      default:
r9684r9685
304323            {
305324               UINT16 offset = i  + (y * 64);
306325               UINT8 data = messram_get_ptr(device->machine->device("messram"))[ offset + 0x10000];
307               *p = col[(data >> 4) & 0xf]; p++;
308               *p = col[(data >> 4) & 0xf]; p++;
309               *p = col[(data >> 4) & 0xf]; p++;
310               *p = col[(data >> 4) & 0xf]; p++;
311               *p = col[(data >> 0) & 0xf]; p++;
312               *p = col[(data >> 0) & 0xf]; p++;
313               *p = col[(data >> 0) & 0xf]; p++;
314               *p = col[(data >> 0) & 0xf]; p++;
326               *p = state->col[(data >> 4) & 0xf]; p++;
327               *p = state->col[(data >> 4) & 0xf]; p++;
328               *p = state->col[(data >> 4) & 0xf]; p++;
329               *p = state->col[(data >> 4) & 0xf]; p++;
330               *p = state->col[(data >> 0) & 0xf]; p++;
331               *p = state->col[(data >> 0) & 0xf]; p++;
332               *p = state->col[(data >> 0) & 0xf]; p++;
333               *p = state->col[(data >> 0) & 0xf]; p++;
315334            }
316335            break;
317336
r9684r9685
361380
362381static INTERRUPT_GEN( tvc_interrupt )
363382{
364   tvc_flipflop  &= ~0x10;
383   tvc_state *state = device->machine->driver_data<tvc_state>();
384   state->flipflop  &= ~0x10;
365385   cpu_set_input_line(device, 0, HOLD_LINE);
366386}
367387
368static MACHINE_CONFIG_START( tvc, driver_device )
388static MACHINE_CONFIG_START( tvc, tvc_state )
369389    /* basic machine hardware */
370390    MDRV_CPU_ADD("maincpu",Z80, 3125000)
371391    MDRV_CPU_PROGRAM_MAP(tvc_mem)
src/mess/drivers/tk80bs.c
r9684r9685
1616#include "machine/i8255a.h"
1717
1818
19class tk80bs_state : public driver_device
20{
21public:
22   tk80bs_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
1924
25   UINT8 *vram;
26   UINT8 keyb_press;
27   UINT8 keyb_press_flag;
28   UINT8 shift_press_flag;
29};
30
31
32
33
2034static VIDEO_START( tk80 )
2135{
2236}
r9684r9685
4660{
4761}
4862
49static UINT8 *vram;
50static UINT8 keyb_press,keyb_press_flag,shift_press_flag;
5163
5264static VIDEO_START( tk80bs )
5365{
r9684r9685
5567
5668static VIDEO_UPDATE( tk80bs )
5769{
70   tk80bs_state *state = screen->machine->driver_data<tk80bs_state>();
5871   int x,y;
5972   int count;
6073
r9684r9685
6477   {
6578      for(x=0;x<32;x++)
6679      {
67         int tile = vram[count];
80         int tile = state->vram[count];
6881
6982         drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[0], tile, 0, 0, 0, x*8, y*8);
7083
r9684r9685
7891/* FIXME: current i8255 core doesn't seem to like this system at all, so we use custom code here for now */
7992static READ8_HANDLER( ppi_custom_r )
8093{
94   tk80bs_state *state = space->machine->driver_data<tk80bs_state>();
8195//  printf("%02x\n",offset);
8296
8397   switch(offset+0x7dfc)
8498   {
85      case 0x7dfc: keyb_press_flag = 0; return keyb_press;
99      case 0x7dfc: state->keyb_press_flag = 0; return state->keyb_press;
86100      case 0x7dfd: return 0xff;
87      case 0x7dfe: return keyb_press_flag << 5; //keyboard flag
101      case 0x7dfe: return state->keyb_press_flag << 5; //keyboard flag
88102   }
89103
90104   return 0xff;
r9684r9685
107121   AM_RANGE(0x7df8, 0x7df9) AM_NOP // i8251 sio
108122//  AM_RANGE(0x7dfc, 0x7dff) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w)
109123   AM_RANGE(0x7dfc, 0x7dff) AM_READWRITE(ppi_custom_r,ppi_custom_w)
110   AM_RANGE(0x7e00, 0x7fff) AM_RAM AM_BASE(&vram) // video ram
124   AM_RANGE(0x7e00, 0x7fff) AM_RAM AM_BASE_MEMBER(tk80bs_state, vram) // video ram
111125   AM_RANGE(0x8000, 0xcfff) AM_RAM // RAM
112126   AM_RANGE(0xd000, 0xefff) AM_ROM // BASIC
113127   AM_RANGE(0xf000, 0xffff) AM_ROM // BSMON
r9684r9685
230244
231245static TIMER_CALLBACK( keyboard_callback )
232246{
247   tk80bs_state *state = machine->driver_data<tk80bs_state>();
233248   const char* portnames[3] = { "key1","key2","key3" };
234249   int i,port_i,scancode;
235250   UINT8 keymod = input_port_read(machine,"key_modifiers") & 0x1f;
236251   scancode = 0;
237252
238   shift_press_flag = ((keymod & 0x02) >> 1);
253   state->shift_press_flag = ((keymod & 0x02) >> 1);
239254
240255   for(port_i=0;port_i<3;port_i++)
241256   {
r9684r9685
247262            {
248263               scancode |= 0x80;
249264            }
250            if(!shift_press_flag)  // shift not pressed
265            if(!state->shift_press_flag)  // shift not pressed
251266            {
252267               //if(scancode >= 0x41 && scancode < 0x5b)
253268               //  scancode += 0x20;  // lowercase doesn't exist here
r9684r9685
269284               if(scancode == 0x3c)
270285                  scancode = 0x3e;
271286            }
272            keyb_press = scancode;
273            keyb_press_flag = 1;
287            state->keyb_press = scancode;
288            state->keyb_press_flag = 1;
274289            return;
275290         }
276291         scancode++;
r9684r9685
332347};
333348
334349
335static MACHINE_CONFIG_START( tk80, driver_device )
350static MACHINE_CONFIG_START( tk80, tk80bs_state )
336351    /* basic machine hardware */
337352    MDRV_CPU_ADD("maincpu",I8080, XTAL_1MHz)
338353    MDRV_CPU_PROGRAM_MAP(tk80_mem)
r9684r9685
356371    MDRV_VIDEO_UPDATE(tk80)
357372MACHINE_CONFIG_END
358373
359static MACHINE_CONFIG_START( tk80bs, driver_device )
374static MACHINE_CONFIG_START( tk80bs, tk80bs_state )
360375    /* basic machine hardware */
361376    MDRV_CPU_ADD("maincpu",I8080, XTAL_1MHz) //unknown clock
362377    MDRV_CPU_PROGRAM_MAP(tk80bs_mem)
src/mess/drivers/ti99_2.c
r9684r9685
8989      : driver_device(machine, config) { }
9090
9191   UINT8 *videoram;
92   int ROM_paged;
93   int irq_state;
94   int KeyRow;
9295};
9396
9497
95static int ROM_paged;
96static int irq_state;
9798
9899static DRIVER_INIT( ti99_2_24 )
99100{
101   ti99_2_state *state = machine->driver_data<ti99_2_state>();
100102   /* no ROM paging */
101   ROM_paged = 0;
103   state->ROM_paged = 0;
102104}
103105
104106static DRIVER_INIT( ti99_2_32 )
105107{
108   ti99_2_state *state = machine->driver_data<ti99_2_state>();
106109   /* ROM paging enabled */
107   ROM_paged = 1;
110   state->ROM_paged = 1;
108111}
109112
110113#define TI99_2_32_ROMPAGE0 (memory_region(space->machine, "maincpu")+0x4000)
r9684r9685
112115
113116static MACHINE_RESET( ti99_2 )
114117{
115   irq_state = ASSERT_LINE;
116   if (! ROM_paged)
118   ti99_2_state *state = machine->driver_data<ti99_2_state>();
119   state->irq_state = ASSERT_LINE;
120   if (! state->ROM_paged)
117121      memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu")+0x4000);
118122   else
119123      memory_set_bankptr(machine, "bank1", (memory_region(machine, "maincpu")+0x4000));
r9684r9685
121125
122126static INTERRUPT_GEN( ti99_2_vblank_interrupt )
123127{
124   cpu_set_input_line(device, 1, irq_state);
125   irq_state = (irq_state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE;
128   ti99_2_state *state = device->machine->driver_data<ti99_2_state>();
129   cpu_set_input_line(device, 1, state->irq_state);
130   state->irq_state = (state->irq_state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE;
126131}
127132
128133
r9684r9685
210215*/
211216
212217/* current keyboard row */
213static int KeyRow = 0;
214218
215219/* write the current keyboard row */
216220static WRITE8_HANDLER ( ti99_2_write_kbd )
217221{
222   ti99_2_state *state = space->machine->driver_data<ti99_2_state>();
218223   offset &= 0x7;  /* other address lines are not decoded */
219224
220225   if (offset <= 2)
221226   {
222227      /* this implementation is just a guess */
223228      if (data)
224         KeyRow |= 1 << offset;
229         state->KeyRow |= 1 << offset;
225230      else
226         KeyRow &= ~ (1 << offset);
231         state->KeyRow &= ~ (1 << offset);
227232   }
228233   /* now, we handle ROM paging */
229   if (ROM_paged)
234   if (state->ROM_paged)
230235   {   /* if we have paged ROMs, page according to S0 keyboard interface line */
231      memory_set_bankptr(space->machine, "bank1", (KeyRow == 0) ? TI99_2_32_ROMPAGE1 : TI99_2_32_ROMPAGE0);
236      memory_set_bankptr(space->machine, "bank1", (state->KeyRow == 0) ? TI99_2_32_ROMPAGE1 : TI99_2_32_ROMPAGE0);
232237   }
233238}
234239
r9684r9685
262267/* read keys in the current row */
263268static  READ8_HANDLER ( ti99_2_read_kbd )
264269{
270   ti99_2_state *state = space->machine->driver_data<ti99_2_state>();
265271   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
266272
267   return input_port_read(space->machine, keynames[KeyRow]);
273   return input_port_read(space->machine, keynames[state->KeyRow]);
268274}
269275
270276static  READ8_HANDLER ( ti99_2_read_misc_cru )
src/mess/drivers/mes.c
r9684r9685
99#include "emu.h"
1010#include "cpu/z80/z80.h"
1111
12static const UINT8 *FNT;
13static const UINT8 *videoram;
1412
13class mes_state : public driver_device
14{
15public:
16   mes_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   const UINT8 *FNT;
20   const UINT8 *videoram;
21};
22
23
24
1525static ADDRESS_MAP_START(mes_mem, ADDRESS_SPACE_PROGRAM, 8)
1626   ADDRESS_MAP_UNMAP_HIGH
1727   AM_RANGE(0x0000, 0x0fff) AM_ROM
r9684r9685
3242
3343static VIDEO_START( mes )
3444{
35   FNT = memory_region(machine, "chargen");
36   videoram = memory_region(machine, "maincpu")+0xf000;
45   mes_state *state = machine->driver_data<mes_state>();
46   state->FNT = memory_region(machine, "chargen");
47   state->videoram = memory_region(machine, "maincpu")+0xf000;
3748}
3849
3950/* This system appears to have 2 screens. Not implemented.
4051    Also the screen dimensions are a guess. */
4152static VIDEO_UPDATE( mes )
42{   //static UINT8 framecnt=0;
53{
54   mes_state *state = screen->machine->driver_data<mes_state>();   //static UINT8 framecnt=0;
4355   UINT8 y,ra,chr,gfx;
4456   UINT16 sy=0,ma=0,x,xx;
4557
r9684r9685
5769            gfx = 0;
5870            if (ra < 9)
5971            {
60               chr = videoram[xx++];
72               chr = state->videoram[xx++];
6173
6274            //   /* Take care of flashing characters */
6375            //   if ((chr < 0x80) && (framecnt & 0x08))
r9684r9685
6779                  x--;
6880               else
6981               {
70                  gfx = FNT[(chr<<4) | ra ];
82                  gfx = state->FNT[(chr<<4) | ra ];
7183
7284                  /* Display a scanline of a character */
7385                  *p++ = ( gfx & 0x80 ) ? 1 : 0;
r9684r9685
8799   return 0;
88100}
89101
90static MACHINE_CONFIG_START( mes, driver_device )
102static MACHINE_CONFIG_START( mes, mes_state )
91103    /* basic machine hardware */
92104    MDRV_CPU_ADD("maincpu", Z80, XTAL_16MHz / 4)
93105    MDRV_CPU_PROGRAM_MAP(mes_mem)
src/mess/drivers/mccpm.c
r9684r9685
1111#include "cpu/z80/z80.h"
1212#include "machine/terminal.h"
1313
14static UINT8 *mccpm_ram;
15static UINT8 term_data;
1614
15class mccpm_state : public driver_device
16{
17public:
18   mccpm_state(running_machine &machine, const driver_device_config_base &config)
19      : driver_device(machine, config) { }
20
21   UINT8 *ram;
22   UINT8 term_data;
23};
24
25
26
1727static WRITE8_HANDLER( mccpm_f0_w )
1828{
1929   running_device *terminal = space->machine->device("terminal");
r9684r9685
2333
2434static READ8_HANDLER( mccpm_f0_r )
2535{
26   UINT8 ret = term_data;
27   term_data = 0;
36   mccpm_state *state = space->machine->driver_data<mccpm_state>();
37   UINT8 ret = state->term_data;
38   state->term_data = 0;
2839   return ret;
2940}
3041
3142static ADDRESS_MAP_START(mccpm_mem, ADDRESS_SPACE_PROGRAM, 8)
3243   ADDRESS_MAP_UNMAP_HIGH
33   AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE(&mccpm_ram)
44   AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE_MEMBER(mccpm_state, ram)
3445ADDRESS_MAP_END
3546
3647static ADDRESS_MAP_START( mccpm_io , ADDRESS_SPACE_IO, 8)
r9684r9685
4758
4859static MACHINE_RESET(mccpm)
4960{
61   mccpm_state *state = machine->driver_data<mccpm_state>();
5062   UINT8* bios = memory_region(machine, "maincpu");
5163
52   memcpy(mccpm_ram,bios, 0x1000);
64   memcpy(state->ram,bios, 0x1000);
5365}
5466
5567static WRITE8_DEVICE_HANDLER( mccpm_kbd_put )
5668{
57   term_data = data;
69   mccpm_state *state = device->machine->driver_data<mccpm_state>();
70   state->term_data = data;
5871}
5972
6073static GENERIC_TERMINAL_INTERFACE( mccpm_terminal_intf )
r9684r9685
6275   DEVCB_HANDLER(mccpm_kbd_put)
6376};
6477
65static MACHINE_CONFIG_START( mccpm, driver_device )
78static MACHINE_CONFIG_START( mccpm, mccpm_state )
6679   /* basic machine hardware */
6780   MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
6881   MDRV_CPU_PROGRAM_MAP(mccpm_mem)
src/mess/drivers/tutor.c
r9684r9685
167167#include "sound/sn76496.h"
168168#include "machine/ctronics.h"
169169
170
171class tutor_state : public driver_device
172{
173public:
174   tutor_state(running_machine &machine, const driver_device_config_base &config)
175      : driver_device(machine, config) { }
176
177   char cartridge_enable;
178   char tape_interrupt_enable;
179   emu_timer *tape_interrupt_timer;
180   UINT8 printer_data;
181   char printer_strobe;
182};
183
184
170185/* mapper state */
171static char cartridge_enable;
172186
173187/* tape interface state */
174188static TIMER_CALLBACK(tape_interrupt_handler);
175189
176static char tape_interrupt_enable;
177static emu_timer *tape_interrupt_timer;
178190
179191/* parallel interface state */
180static UINT8 printer_data;
181static char printer_strobe;
182192
183193enum
184194{
r9684r9685
189199
190200static DRIVER_INIT(tutor)
191201{
192   tape_interrupt_timer = timer_alloc(machine, tape_interrupt_handler, NULL);
202   tutor_state *state = machine->driver_data<tutor_state>();
203   state->tape_interrupt_timer = timer_alloc(machine, tape_interrupt_handler, NULL);
193204
194205   memory_configure_bank(machine, "bank1", 0, 1, memory_region(machine, "maincpu") + basic_base, 0);
195206   memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "maincpu") + cartridge_base, 0);
r9684r9685
219230
220231static MACHINE_RESET(tutor)
221232{
222   cartridge_enable = 0;
233   tutor_state *state = machine->driver_data<tutor_state>();
234   state->cartridge_enable = 0;
223235
224   tape_interrupt_enable = 0;
236   state->tape_interrupt_enable = 0;
225237
226   printer_data = 0;
227   printer_strobe = 0;
238   state->printer_data = 0;
239   state->printer_strobe = 0;
228240}
229241
230242static INTERRUPT_GEN( tutor_vblank_interrupt )
r9684r9685
326338
327339static WRITE8_HANDLER(tutor_mapper_w)
328340{
341   tutor_state *state = space->machine->driver_data<tutor_state>();
329342   switch (offset)
330343   {
331344   case 0x00:
r9684r9685
334347
335348   case 0x08:
336349      /* disable cartridge ROM, enable BASIC ROM at base >8000 */
337      cartridge_enable = 0;
350      state->cartridge_enable = 0;
338351      memory_set_bank(space->machine, "bank1", 0);
339352      break;
340353
341354   case 0x0c:
342355      /* enable cartridge ROM, disable BASIC ROM at base >8000 */
343      cartridge_enable = 1;
356      state->cartridge_enable = 1;
344357      memory_set_bank(space->machine, "bank1", 1);
345358      break;
346359
r9684r9685
372385
373386static TIMER_CALLBACK(tape_interrupt_handler)
374387{
375   //assert(tape_interrupt_enable);
388   //tutor_state *state = machine->driver_data<tutor_state>();
389   //assert(state->tape_interrupt_enable);
376390   cputag_set_input_line(machine, "maincpu", 1, (cassette_input(machine->device("cassette")) > 0.0) ? ASSERT_LINE : CLEAR_LINE);
377391}
378392
r9684r9685
385399/* memory handler */
386400static WRITE8_HANDLER(tutor_cassette_w)
387401{
402   tutor_state *state = space->machine->driver_data<tutor_state>();
388403   if (offset & /*0x1f*/0x1e)
389404      logerror("unknown port in %s %d\n", __FILE__, __LINE__);
390405
r9684r9685
401416      case 1:
402417         /* interrupt control??? */
403418         //logerror("ignoring write of %d to cassette port 1\n", data);
404         if (tape_interrupt_enable != ! data)
419         if (state->tape_interrupt_enable != ! data)
405420         {
406            tape_interrupt_enable = ! data;
407            if (tape_interrupt_enable)
408               timer_adjust_periodic(tape_interrupt_timer, /*ATTOTIME_IN_HZ(44100)*/attotime_zero, 0, ATTOTIME_IN_HZ(44100));
421            state->tape_interrupt_enable = ! data;
422            if (state->tape_interrupt_enable)
423               timer_adjust_periodic(state->tape_interrupt_timer, /*ATTOTIME_IN_HZ(44100)*/attotime_zero, 0, ATTOTIME_IN_HZ(44100));
409424            else
410425            {
411               timer_adjust_oneshot(tape_interrupt_timer, attotime_never, 0);
426               timer_adjust_oneshot(state->tape_interrupt_timer, attotime_never, 0);
412427               cputag_set_input_line(space->machine, "maincpu", 1, CLEAR_LINE);
413428            }
414429         }
r9684r9685
669684   NULL      /* no IDLE callback */
670685};
671686
672static MACHINE_CONFIG_START( tutor, driver_device )
687static MACHINE_CONFIG_START( tutor, tutor_state )
673688   /* basic machine hardware */
674689   /* TMS9995 CPU @ 10.7 MHz */
675690   MDRV_CPU_ADD("maincpu", TMS9995, 10700000)
src/mess/drivers/tricep.c
r9684r9685
1010#include "cpu/m68000/m68000.h"
1111#include "machine/terminal.h"
1212
13static UINT16* tricep_ram;
1413
14class tricep_state : public driver_device
15{
16public:
17   tricep_state(running_machine &machine, const driver_device_config_base &config)
18      : driver_device(machine, config) { }
19
20   UINT16* ram;
21};
22
23
24
1525static READ16_HANDLER(tricep_terminal_r)
1626{
1727   return 0xffff;
r9684r9685
2535
2636static ADDRESS_MAP_START(tricep_mem, ADDRESS_SPACE_PROGRAM, 16)
2737   ADDRESS_MAP_UNMAP_HIGH
28   AM_RANGE(0x00000000, 0x0007ffff) AM_RAM AM_BASE(&tricep_ram)
38   AM_RANGE(0x00000000, 0x0007ffff) AM_RAM AM_BASE_MEMBER(tricep_state, ram)
2939   AM_RANGE(0x00fd0000, 0x00fd1fff) AM_ROM AM_REGION("user1",0)
3040   AM_RANGE(0x00ff0028, 0x00ff0029) AM_READWRITE(tricep_terminal_r,tricep_terminal_w)
3141ADDRESS_MAP_END
r9684r9685
3848
3949static MACHINE_RESET(tricep)
4050{
51   tricep_state *state = machine->driver_data<tricep_state>();
4152   UINT8* user1 = memory_region(machine, "user1");
4253
43   memcpy((UINT8*)tricep_ram,user1,0x2000);
54   memcpy((UINT8*)state->ram,user1,0x2000);
4455
4556   machine->device("maincpu")->reset();
4657}
r9684r9685
5465   DEVCB_HANDLER(tricep_kbd_put)
5566};
5667
57static MACHINE_CONFIG_START( tricep, driver_device )
68static MACHINE_CONFIG_START( tricep, tricep_state )
5869    /* basic machine hardware */
5970    MDRV_CPU_ADD("maincpu",M68000, XTAL_8MHz)
6071    MDRV_CPU_PROGRAM_MAP(tricep_mem)
src/mess/drivers/pockstat.c
r9684r9685
3434#include "devices/cartslot.h"
3535#include "sound/dac.h"
3636
37#define MAX_PS_TIMERS   3
38
39typedef struct
40{
41   UINT32 control;
42   UINT32 stat;
43   UINT32 valid;
44   UINT32 wait1;
45   UINT32 wait2;
46   UINT32 entry[16];
47   UINT32 serial;
48} ps_ftlb_regs_t;
49
50typedef struct
51{
52   UINT32 hold;
53   UINT32 status;
54   UINT32 enable;
55   UINT32 mask;
56} ps_intc_regs_t;
57
58typedef struct
59{
60   UINT32 period;
61   UINT32 count;
62   UINT32 control;
63   emu_timer *timer;
64} ps_timer_t;
65
66typedef struct
67{
68   ps_timer_t timer[MAX_PS_TIMERS];
69} ps_timer_regs_t;
70
71typedef struct
72{
73   UINT32 mode;
74   UINT32 control;
75} ps_clock_regs_t;
76
77#define PS_CLOCK_STEADY      0x10
78
79typedef struct
80{
81   UINT32 mode;
82   UINT32 control;
83   UINT32 time;
84   UINT32 date;
85   emu_timer *timer;
86} ps_rtc_regs_t;
87
88
89
90class pockstat_state : public driver_device
91{
92public:
93   pockstat_state(running_machine &machine, const driver_device_config_base &config)
94      : driver_device(machine, config) { }
95
96   UINT32 *lcd_buffer;
97   ps_ftlb_regs_t ftlb_regs;
98   ps_intc_regs_t intc_regs;
99   ps_timer_regs_t timer_regs;
100   ps_clock_regs_t clock_regs;
101   ps_rtc_regs_t rtc_regs;
102   UINT32 lcd_control;
103   INT32 ps_flash_write_enable_count;
104   INT32 ps_flash_write_count;
105};
106
107
37108#define DEFAULT_CLOCK   2000000
38109
39110static const int CPU_FREQ[16] =
r9684r9685
77148#define verboselog(x,y,z,...)
78149#endif
79150
80static UINT32 *lcd_buffer;
81151
82152// Flash TLB
83153static READ32_HANDLER( ps_ftlb_r );
r9684r9685
104174static READ32_HANDLER( ps_rtc_r );
105175static WRITE32_HANDLER( ps_rtc_w );
106176
107typedef struct
108{
109   UINT32 control;
110   UINT32 stat;
111   UINT32 valid;
112   UINT32 wait1;
113   UINT32 wait2;
114   UINT32 entry[16];
115   UINT32 serial;
116} ps_ftlb_regs_t;
117
118typedef struct
119{
120   UINT32 hold;
121   UINT32 status;
122   UINT32 enable;
123   UINT32 mask;
124} ps_intc_regs_t;
125
126177#define PS_INT_BTN_ACTION      0x00000001 // "Action button"
127178#define PS_INT_BTN_RIGHT      0x00000002 // "Right button"
128179#define PS_INT_BTN_LEFT         0x00000004 // "Left button"
r9684r9685
141192#define PS_INT_FIQ_MASK         0x00002040
142193#define PS_INT_STATUS_MASK      0x0000021f
143194
144#define MAX_PS_TIMERS   3
145
146typedef struct
147{
148   UINT32 period;
149   UINT32 count;
150   UINT32 control;
151   emu_timer *timer;
152} ps_timer_t;
153
154typedef struct
155{
156   ps_timer_t timer[MAX_PS_TIMERS];
157} ps_timer_regs_t;
158
159typedef struct
160{
161   UINT32 mode;
162   UINT32 control;
163} ps_clock_regs_t;
164
165#define PS_CLOCK_STEADY      0x10
166
167typedef struct
168{
169   UINT32 mode;
170   UINT32 control;
171   UINT32 time;
172   UINT32 date;
173   emu_timer *timer;
174} ps_rtc_regs_t;
175
176static ps_ftlb_regs_t ftlb_regs;
177static ps_intc_regs_t intc_regs;
178static ps_timer_regs_t timer_regs;
179static ps_clock_regs_t clock_regs;
180static ps_rtc_regs_t rtc_regs;
181
182195static READ32_HANDLER( ps_ftlb_r )
183196{
197   pockstat_state *state = space->machine->driver_data<pockstat_state>();
184198   switch(offset)
185199   {
186200      case 0x0000/4:
187         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Control = %08x & %08x\n", ftlb_regs.control, mem_mask );
188         return ftlb_regs.control | 1; // ???
201         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Control = %08x & %08x\n", state->ftlb_regs.control, mem_mask );
202         return state->ftlb_regs.control | 1; // ???
189203      case 0x0004/4:
190         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_STAT) = %08x & %08x\n", ftlb_regs.stat, mem_mask );
191         return ftlb_regs.stat;
204         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_STAT) = %08x & %08x\n", state->ftlb_regs.stat, mem_mask );
205         return state->ftlb_regs.stat;
192206      case 0x0008/4:
193         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Valid Tag = %08x & %08x\n", ftlb_regs.valid, mem_mask );
194         return ftlb_regs.valid;
207         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Valid Tag = %08x & %08x\n", state->ftlb_regs.valid, mem_mask );
208         return state->ftlb_regs.valid;
195209      case 0x000c/4:
196         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT1) = %08x & %08x\n", ftlb_regs.wait1, mem_mask );
197         return ftlb_regs.wait1;
210         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT1) = %08x & %08x\n", state->ftlb_regs.wait1, mem_mask );
211         return state->ftlb_regs.wait1;
198212      case 0x0010/4:
199         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT2) = %08x & %08x\n", ftlb_regs.wait2 | 0x04, mem_mask );
200         return ftlb_regs.wait2 | 0x04;
213         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_WAIT2) = %08x & %08x\n", state->ftlb_regs.wait2 | 0x04, mem_mask );
214         return state->ftlb_regs.wait2 | 0x04;
201215      case 0x0100/4:
202216      case 0x0104/4:
203217      case 0x0108/4:
r9684r9685
214228      case 0x0134/4:
215229      case 0x0138/4:
216230      case 0x013c/4:
217         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Entry %d = %08x & %08x\n", offset - 0x100/4, ftlb_regs.entry[offset - 0x100/4], mem_mask );
218         return ftlb_regs.entry[offset - 0x100/4];
231         verboselog(space->machine, 0, "ps_ftlb_r: FlashROM TLB Entry %d = %08x & %08x\n", offset - 0x100/4, state->ftlb_regs.entry[offset - 0x100/4], mem_mask );
232         return state->ftlb_regs.entry[offset - 0x100/4];
219233      case 0x0300/4:
220         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_SN) = %08x & %08x\n", ftlb_regs.serial, mem_mask );
221         return ftlb_regs.serial;
234         verboselog(space->machine, 0, "ps_ftlb_r: Unknown (F_SN) = %08x & %08x\n", state->ftlb_regs.serial, mem_mask );
235         return state->ftlb_regs.serial;
222236      default:
223237         verboselog(space->machine, 0, "ps_ftlb_r: Unknown Register %08x & %08x\n", 0x06000000 + (offset << 2), mem_mask );
224238         break;
r9684r9685
228242
229243static WRITE32_HANDLER( ps_ftlb_w )
230244{
245   pockstat_state *state = space->machine->driver_data<pockstat_state>();
231246   switch(offset)
232247   {
233248      case 0x0000/4:
234249         verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Control = %08x & %08x\n", data, mem_mask );
235         COMBINE_DATA(&ftlb_regs.control);
250         COMBINE_DATA(&state->ftlb_regs.control);
236251         break;
237252      case 0x0004/4:
238253         verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_STAT) = %08x & %08x\n", data, mem_mask );
239         COMBINE_DATA(&ftlb_regs.stat);
254         COMBINE_DATA(&state->ftlb_regs.stat);
240255         break;
241256      case 0x0008/4:
242257         verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Valid Tag = %08x & %08x\n", data, mem_mask );
243         COMBINE_DATA(&ftlb_regs.valid);
258         COMBINE_DATA(&state->ftlb_regs.valid);
244259         break;
245260      case 0x000c/4:
246261         verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_WAIT1) = %08x & %08x\n", data, mem_mask );
247         COMBINE_DATA(&ftlb_regs.wait1);
262         COMBINE_DATA(&state->ftlb_regs.wait1);
248263         break;
249264      case 0x0010/4:
250265         verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_WAIT2) = %08x & %08x\n", data, mem_mask );
251         COMBINE_DATA(&ftlb_regs.wait2);
266         COMBINE_DATA(&state->ftlb_regs.wait2);
252267         break;
253268      case 0x0100/4:
254269      case 0x0104/4:
r9684r9685
267282      case 0x0138/4:
268283      case 0x013c/4:
269284         verboselog(space->machine, 0, "ps_ftlb_w: FlashROM TLB Entry %d = %08x & %08x\n", offset - 0x100/4, data, mem_mask );
270         COMBINE_DATA(&ftlb_regs.entry[offset - 0x100/4]);
285         COMBINE_DATA(&state->ftlb_regs.entry[offset - 0x100/4]);
271286         break;
272287      case 0x0300/4:
273288         verboselog(space->machine, 0, "ps_ftlb_w: Unknown (F_SN) = %08x & %08x\n", data, mem_mask );
274         COMBINE_DATA(&ftlb_regs.serial);
289         COMBINE_DATA(&state->ftlb_regs.serial);
275290         break;
276291      default:
277292         verboselog(space->machine, 0, "ps_ftlb_w: Unknown Register %08x = %08x & %08x\n", 0x06000000 + (offset << 2), data, mem_mask );
r9684r9685
281296
282297static UINT32 ps_intc_get_interrupt_line(running_machine *machine, UINT32 line)
283298{
284   return intc_regs.status & line;
299   pockstat_state *state = machine->driver_data<pockstat_state>();
300   return state->intc_regs.status & line;
285301}
286302
287303static void ps_intc_set_interrupt_line(running_machine *machine, UINT32 line, int state)
288304{
289   //printf( "%08x %d %08x %08x %08x\n", line, state, intc_regs.hold, intc_regs.status, intc_regs.enable );
305   pockstat_state *drvstate = machine->driver_data<pockstat_state>();
306   //printf( "%08x %d %08x %08x %08x\n", line, state, drvstate->intc_regs.hold, drvstate->intc_regs.status, drvstate->intc_regs.enable );
290307   if(line)
291308   {
292309      if(state)
293310      {
294         intc_regs.status |= line & PS_INT_STATUS_MASK;
295         intc_regs.hold |= line &~ PS_INT_STATUS_MASK;
296         //printf( " Setting %08x, status = %08x, hold = %08x\n", line, intc_regs.status, intc_regs.hold );
311         drvstate->intc_regs.status |= line & PS_INT_STATUS_MASK;
312         drvstate->intc_regs.hold |= line &~ PS_INT_STATUS_MASK;
313         //printf( " Setting %08x, status = %08x, hold = %08x\n", line, drvstate->intc_regs.status, drvstate->intc_regs.hold );
297314      }
298315      else
299316      {
300         intc_regs.status &= ~line;
301         intc_regs.hold &= ~line;
302         //printf( "Clearing %08x, status = %08x, hold = %08x\n", line, intc_regs.status, intc_regs.hold );
317         drvstate->intc_regs.status &= ~line;
318         drvstate->intc_regs.hold &= ~line;
319         //printf( "Clearing %08x, status = %08x, hold = %08x\n", line, drvstate->intc_regs.status, drvstate->intc_regs.hold );
303320      }
304321   }
305   if(intc_regs.hold & intc_regs.enable & PS_INT_IRQ_MASK)
322   if(drvstate->intc_regs.hold & drvstate->intc_regs.enable & PS_INT_IRQ_MASK)
306323   {
307324      cpu_set_input_line(machine->device("maincpu"), ARM7_IRQ_LINE, ASSERT_LINE);
308325   }
r9684r9685
310327   {
311328      cpu_set_input_line(machine->device("maincpu"), ARM7_IRQ_LINE, CLEAR_LINE);
312329   }
313   if(intc_regs.hold & intc_regs.enable & PS_INT_FIQ_MASK)
330   if(drvstate->intc_regs.hold & drvstate->intc_regs.enable & PS_INT_FIQ_MASK)
314331   {
315332      cpu_set_input_line(machine->device("maincpu"), ARM7_FIRQ_LINE, ASSERT_LINE);
316333   }
r9684r9685
322339
323340static READ32_HANDLER( ps_intc_r )
324341{
342   pockstat_state *state = space->machine->driver_data<pockstat_state>();
325343   switch(offset)
326344   {
327345      case 0x0000/4:
328         verboselog(space->machine, 0, "ps_intc_r: Held Interrupt = %08x & %08x\n", intc_regs.hold, mem_mask );
329         return intc_regs.hold;
346         verboselog(space->machine, 0, "ps_intc_r: Held Interrupt = %08x & %08x\n", state->intc_regs.hold, mem_mask );
347         return state->intc_regs.hold;
330348      case 0x0004/4:
331         verboselog(space->machine, 0, "ps_intc_r: Interrupt Status = %08x & %08x\n", intc_regs.status, mem_mask );
332         return intc_regs.status;
349         verboselog(space->machine, 0, "ps_intc_r: Interrupt Status = %08x & %08x\n", state->intc_regs.status, mem_mask );
350         return state->intc_regs.status;
333351      case 0x0008/4:
334         verboselog(space->machine, 0, "ps_intc_r: Interrupt Enable = %08x & %08x\n", intc_regs.enable, mem_mask );
335         return intc_regs.enable;
352         verboselog(space->machine, 0, "ps_intc_r: Interrupt Enable = %08x & %08x\n", state->intc_regs.enable, mem_mask );
353         return state->intc_regs.enable;
336354      case 0x000c/4:
337355         verboselog(space->machine, 0, "ps_intc_r: Interrupt Mask (Invalid Read) = %08x & %08x\n", 0, mem_mask );
338356         return 0;
r9684r9685
348366
349367static WRITE32_HANDLER( ps_intc_w )
350368{
369   pockstat_state *state = space->machine->driver_data<pockstat_state>();
351370   switch(offset)
352371   {
353372      case 0x0000/4:
r9684r9685
358377         break;
359378      case 0x0008/4:
360379         verboselog(space->machine, 0, "ps_intc_w: Interrupt Enable = %08x & %08x\n", data, mem_mask );
361         intc_regs.enable |= data;
362         //COMBINE_DATA(&intc_regs.enable);
363         //intc_regs.status &= intc_regs.enable;
364         //intc_regs.hold &= intc_regs.enable;
380         state->intc_regs.enable |= data;
381         //COMBINE_DATA(&state->intc_regs.enable);
382         //state->intc_regs.status &= state->intc_regs.enable;
383         //state->intc_regs.hold &= state->intc_regs.enable;
365384         ps_intc_set_interrupt_line(space->machine, 0, 0);
366385         break;
367386      case 0x000c/4:
368387         verboselog(space->machine, 0, "ps_intc_w: Interrupt Mask = %08x & %08x\n", data, mem_mask );
369         intc_regs.enable &= ~data;
370         COMBINE_DATA(&intc_regs.mask);
371         //intc_regs.status &= intc_regs.enable;
372         //intc_regs.hold &= intc_regs.enable;
388         state->intc_regs.enable &= ~data;
389         COMBINE_DATA(&state->intc_regs.mask);
390         //state->intc_regs.status &= state->intc_regs.enable;
391         //state->intc_regs.hold &= state->intc_regs.enable;
373392         ps_intc_set_interrupt_line(space->machine, 0, 0);
374393         break;
375394      case 0x0010/4:
376395         verboselog(space->machine, 0, "ps_intc_w: Interrupt Acknowledge = %08x & %08x\n", data, mem_mask );
377         intc_regs.hold &= ~data;
378         intc_regs.status &= ~data;
396         state->intc_regs.hold &= ~data;
397         state->intc_regs.status &= ~data;
379398         ps_intc_set_interrupt_line(space->machine, 0, 0);
380         //COMBINE_DATA(&intc_regs.acknowledge);
399         //COMBINE_DATA(&state->intc_regs.acknowledge);
381400         break;
382401      default:
383402         verboselog(space->machine, 0, "ps_intc_w: Unknown Register %08x = %08x & %08x\n", 0x0a000000 + (offset << 2), data, mem_mask );
r9684r9685
387406
388407static TIMER_CALLBACK( timer_tick )
389408{
409   pockstat_state *state = machine->driver_data<pockstat_state>();
390410   ps_intc_set_interrupt_line(machine, param == 2 ? PS_INT_TIMER2 : (param == 1 ? PS_INT_TIMER1 : PS_INT_TIMER0), 1);
391411   //printf( "Timer %d is calling back\n", param );
392   timer_regs.timer[param].count = timer_regs.timer[param].period;
412   state->timer_regs.timer[param].count = state->timer_regs.timer[param].period;
393413   ps_timer_start(machine, param);
394414}
395415
396416static void ps_timer_start(running_machine *machine, int index)
397417{
418   pockstat_state *state = machine->driver_data<pockstat_state>();
398419   int divisor = 1;
399420   attotime period;
400   switch(timer_regs.timer[index].control & 3)
421   switch(state->timer_regs.timer[index].control & 3)
401422   {
402423      case 0:
403424      case 3:
r9684r9685
410431         divisor = 256;
411432         break;
412433   }
413   period = attotime_mul(ATTOTIME_IN_HZ(CPU_FREQ[clock_regs.mode & 0x0f] / 2), divisor);
414   period = attotime_mul(period, timer_regs.timer[index].count);
415   timer_adjust_oneshot(timer_regs.timer[index].timer, period, index);
434   period = attotime_mul(ATTOTIME_IN_HZ(CPU_FREQ[state->clock_regs.mode & 0x0f] / 2), divisor);
435   period = attotime_mul(period, state->timer_regs.timer[index].count);
436   timer_adjust_oneshot(state->timer_regs.timer[index].timer, period, index);
416437}
417438
418439static READ32_HANDLER( ps_timer_r )
419440{
441   pockstat_state *state = space->machine->driver_data<pockstat_state>();
420442   switch(offset)
421443   {
422444      case 0x0000/4:
423445      case 0x0010/4:
424446      case 0x0020/4:
425         verboselog(space->machine, 0, "ps_timer_r: Timer %d Period = %08x & %08x\n", offset / (0x10/4), timer_regs.timer[offset / (0x10/4)].period, mem_mask );
426         return timer_regs.timer[offset / (0x10/4)].period;
447         verboselog(space->machine, 0, "ps_timer_r: Timer %d Period = %08x & %08x\n", offset / (0x10/4), state->timer_regs.timer[offset / (0x10/4)].period, mem_mask );
448         return state->timer_regs.timer[offset / (0x10/4)].period;
427449      case 0x0004/4:
428450      case 0x0014/4:
429451      case 0x0024/4:
430         verboselog(space->machine, 0, "ps_timer_r: Timer %d Count = %08x & %08x\n", offset / (0x10/4), timer_regs.timer[offset / (0x10/4)].count, mem_mask );
431         if(timer_regs.timer[offset / (0x10/4)].control & 4)
452         verboselog(space->machine, 0, "ps_timer_r: Timer %d Count = %08x & %08x\n", offset / (0x10/4), state->timer_regs.timer[offset / (0x10/4)].count, mem_mask );
453         if(state->timer_regs.timer[offset / (0x10/4)].control & 4)
432454         {
433            timer_regs.timer[offset / (0x10/4)].count--;
434            if(timer_regs.timer[offset / (0x10/4)].count > timer_regs.timer[offset / (0x10/4)].period)
455            state->timer_regs.timer[offset / (0x10/4)].count--;
456            if(state->timer_regs.timer[offset / (0x10/4)].count > state->timer_regs.timer[offset / (0x10/4)].period)
435457            {
436               timer_regs.timer[offset / (0x10/4)].count = timer_regs.timer[offset / (0x10/4)].period;
458               state->timer_regs.timer[offset / (0x10/4)].count = state->timer_regs.timer[offset / (0x10/4)].period;
437459            }
438            return --timer_regs.timer[offset / (0x10/4)].count;
460            return --state->timer_regs.timer[offset / (0x10/4)].count;
439461         }
440         return timer_regs.timer[offset / (0x10/4)].count;
462         return state->timer_regs.timer[offset / (0x10/4)].count;
441463      case 0x0008/4:
442464      case 0x0018/4:
443465      case 0x0028/4:
444         verboselog(space->machine, 0, "ps_timer_r: Timer %d Control = %08x & %08x\n", offset / (0x10/4), timer_regs.timer[offset / (0x10/4)].control, mem_mask );
445         return timer_regs.timer[offset / (0x10/4)].control;
466         verboselog(space->machine, 0, "ps_timer_r: Timer %d Control = %08x & %08x\n", offset / (0x10/4), state->timer_regs.timer[offset / (0x10/4)].control, mem_mask );
467         return state->timer_regs.timer[offset / (0x10/4)].control;
446468      default:
447469         verboselog(space->machine, 0, "ps_timer_r: Unknown Register %08x & %08x\n", 0x0a800000 + (offset << 2), mem_mask );
448470         break;
r9684r9685
452474
453475static WRITE32_HANDLER( ps_timer_w )
454476{
477   pockstat_state *state = space->machine->driver_data<pockstat_state>();
455478   switch(offset)
456479   {
457480      case 0x0000/4:
458481      case 0x0010/4:
459482      case 0x0020/4:
460483         verboselog(space->machine, 0, "ps_timer_w: Timer %d Period = %08x & %08x\n", offset / (0x10/4), data, mem_mask );
461         COMBINE_DATA(&timer_regs.timer[offset / (0x10/4)].period);
484         COMBINE_DATA(&state->timer_regs.timer[offset / (0x10/4)].period);
462485         break;
463486      case 0x0004/4:
464487      case 0x0014/4:
465488      case 0x0024/4:
466489         verboselog(space->machine, 0, "ps_timer_w: Timer %d Count = %08x & %08x\n", offset / (0x10/4), data, mem_mask );
467         COMBINE_DATA(&timer_regs.timer[offset / (0x10/4)].count);
490         COMBINE_DATA(&state->timer_regs.timer[offset / (0x10/4)].count);
468491         break;
469492      case 0x0008/4:
470493      case 0x0018/4:
471494      case 0x0028/4:
472495         verboselog(space->machine, 0, "ps_timer_w: Timer %d Control = %08x & %08x\n", offset / (0x10/4), data, mem_mask );
473         COMBINE_DATA(&timer_regs.timer[offset / (0x10/4)].control);
474         if(timer_regs.timer[offset / (0x10/4)].control & 4)
496         COMBINE_DATA(&state->timer_regs.timer[offset / (0x10/4)].control);
497         if(state->timer_regs.timer[offset / (0x10/4)].control & 4)
475498         {
476499            ps_timer_start(space->machine, offset / (0x10/4));
477500         }
478501         else
479502         {
480            timer_adjust_oneshot(timer_regs.timer[offset / (0x10/4)].timer, attotime_never, offset / (0x10/4));
503            timer_adjust_oneshot(state->timer_regs.timer[offset / (0x10/4)].timer, attotime_never, offset / (0x10/4));
481504         }
482505         break;
483506      default:
r9684r9685
488511
489512static READ32_HANDLER( ps_clock_r )
490513{
514   pockstat_state *state = space->machine->driver_data<pockstat_state>();
491515   switch(offset)
492516   {
493517      case 0x0000/4:
494         verboselog(space->machine, 0, "ps_clock_r: Clock Mode = %08x & %08x\n", clock_regs.mode | 0x10, mem_mask );
495         return clock_regs.mode | PS_CLOCK_STEADY;
518         verboselog(space->machine, 0, "ps_clock_r: Clock Mode = %08x & %08x\n", state->clock_regs.mode | 0x10, mem_mask );
519         return state->clock_regs.mode | PS_CLOCK_STEADY;
496520      case 0x0004/4:
497         verboselog(space->machine, 0, "ps_clock_r: Clock Control = %08x & %08x\n", clock_regs.control, mem_mask );
498         return clock_regs.control;
521         verboselog(space->machine, 0, "ps_clock_r: Clock Control = %08x & %08x\n", state->clock_regs.control, mem_mask );
522         return state->clock_regs.control;
499523      default:
500524         verboselog(space->machine, 0, "ps_clock_r: Unknown Register %08x & %08x\n", 0x0b000000 + (offset << 2), mem_mask );
501525         break;
r9684r9685
505529
506530static WRITE32_HANDLER( ps_clock_w )
507531{
532   pockstat_state *state = space->machine->driver_data<pockstat_state>();
508533   switch(offset)
509534   {
510535      case 0x0000/4:
511536         verboselog(space->machine, 0, "ps_clock_w: Clock Mode = %08x & %08x\n", data, mem_mask );
512         COMBINE_DATA(&clock_regs.mode);
513         cputag_set_clock(space->machine, "maincpu", CPU_FREQ[clock_regs.mode & 0x0f]);
537         COMBINE_DATA(&state->clock_regs.mode);
538         cputag_set_clock(space->machine, "maincpu", CPU_FREQ[state->clock_regs.mode & 0x0f]);
514539         break;
515540      case 0x0004/4:
516541         verboselog(space->machine, 0, "ps_clock_w: Clock Control = %08x & %08x\n", data, mem_mask );
517         COMBINE_DATA(&clock_regs.control);
542         COMBINE_DATA(&state->clock_regs.control);
518543         break;
519544      default:
520545         verboselog(space->machine, 0, "ps_clock_w: Unknown Register %08x = %08x & %08x\n", 0x0b000000 + (offset << 2), data, mem_mask );
r9684r9685
524549
525550static TIMER_CALLBACK( rtc_tick )
526551{
552   pockstat_state *state = machine->driver_data<pockstat_state>();
527553   //printf( "RTC is calling back\n" );
528554   ps_intc_set_interrupt_line(machine, PS_INT_RTC, ps_intc_get_interrupt_line(machine, PS_INT_RTC) ? 0 : 1);
529   if(!(rtc_regs.mode & 1))
555   if(!(state->rtc_regs.mode & 1))
530556   {
531      rtc_regs.time++;
532      if((rtc_regs.time & 0x0000000f) == 0x0000000a)
557      state->rtc_regs.time++;
558      if((state->rtc_regs.time & 0x0000000f) == 0x0000000a)
533559      {
534         rtc_regs.time &= 0xfffffff0;
535         rtc_regs.time += 0x00000010;
536         if((rtc_regs.time & 0x000000ff) == 0x00000060)
560         state->rtc_regs.time &= 0xfffffff0;
561         state->rtc_regs.time += 0x00000010;
562         if((state->rtc_regs.time & 0x000000ff) == 0x00000060)
537563         {
538            rtc_regs.time &= 0xffffff00;
539            rtc_regs.time += 0x00000100;
540            if((rtc_regs.time & 0x00000f00) == 0x00000a00)
564            state->rtc_regs.time &= 0xffffff00;
565            state->rtc_regs.time += 0x00000100;
566            if((state->rtc_regs.time & 0x00000f00) == 0x00000a00)
541567            {
542               rtc_regs.time &= 0xfffff0ff;
543               rtc_regs.time += 0x00001000;
544               if((rtc_regs.time & 0x0000ff00) == 0x00006000)
568               state->rtc_regs.time &= 0xfffff0ff;
569               state->rtc_regs.time += 0x00001000;
570               if((state->rtc_regs.time & 0x0000ff00) == 0x00006000)
545571               {
546                  rtc_regs.time &= 0xffff00ff;
547                  rtc_regs.time += 0x00010000;
548                  if((rtc_regs.time & 0x00ff0000) == 0x00240000)
572                  state->rtc_regs.time &= 0xffff00ff;
573                  state->rtc_regs.time += 0x00010000;
574                  if((state->rtc_regs.time & 0x00ff0000) == 0x00240000)
549575                  {
550                     rtc_regs.time &= 0xff00ffff;
551                     rtc_regs.time += 0x01000000;
552                     if((rtc_regs.time & 0x0f000000) == 0x08000000)
576                     state->rtc_regs.time &= 0xff00ffff;
577                     state->rtc_regs.time += 0x01000000;
578                     if((state->rtc_regs.time & 0x0f000000) == 0x08000000)
553579                     {
554                        rtc_regs.time &= 0xf0ffffff;
555                        rtc_regs.time |= 0x01000000;
580                        state->rtc_regs.time &= 0xf0ffffff;
581                        state->rtc_regs.time |= 0x01000000;
556582                     }
557583                  }
558                  else if((rtc_regs.time & 0x000f0000) == 0x000a0000)
584                  else if((state->rtc_regs.time & 0x000f0000) == 0x000a0000)
559585                  {
560                     rtc_regs.time &= 0xfff0ffff;
561                     rtc_regs.time += 0x00100000;
586                     state->rtc_regs.time &= 0xfff0ffff;
587                     state->rtc_regs.time += 0x00100000;
562588                  }
563589               }
564590            }
565591         }
566592      }
567593   }
568   timer_adjust_oneshot(rtc_regs.timer, ATTOTIME_IN_HZ(1), 0);
594   timer_adjust_oneshot(state->rtc_regs.timer, ATTOTIME_IN_HZ(1), 0);
569595}
570596
571597static READ32_HANDLER( ps_rtc_r )
572598{
599   pockstat_state *state = space->machine->driver_data<pockstat_state>();
573600   switch(offset)
574601   {
575602      case 0x0000/4:
576         verboselog(space->machine, 0, "ps_rtc_r: RTC Mode = %08x & %08x\n", rtc_regs.mode, mem_mask );
577         return rtc_regs.mode;
603         verboselog(space->machine, 0, "ps_rtc_r: RTC Mode = %08x & %08x\n", state->rtc_regs.mode, mem_mask );
604         return state->rtc_regs.mode;
578605      case 0x0004/4:
579         verboselog(space->machine, 0, "ps_rtc_r: RTC Control = %08x & %08x\n", rtc_regs.control, mem_mask );
580         return rtc_regs.control;
606         verboselog(space->machine, 0, "ps_rtc_r: RTC Control = %08x & %08x\n", state->rtc_regs.control, mem_mask );
607         return state->rtc_regs.control;
581608      case 0x0008/4:
582         verboselog(space->machine, 0, "ps_rtc_r: RTC Time = %08x & %08x\n", rtc_regs.time, mem_mask );
583         return rtc_regs.time;
609         verboselog(space->machine, 0, "ps_rtc_r: RTC Time = %08x & %08x\n", state->rtc_regs.time, mem_mask );
610         return state->rtc_regs.time;
584611      case 0x000c/4:
585         verboselog(space->machine, 0, "ps_rtc_r: RTC Date = %08x & %08x\n", rtc_regs.date, mem_mask );
586         return rtc_regs.date;
612         verboselog(space->machine, 0, "ps_rtc_r: RTC Date = %08x & %08x\n", state->rtc_regs.date, mem_mask );
613         return state->rtc_regs.date;
587614      default:
588615         verboselog(space->machine, 0, "ps_rtc_r: Unknown Register %08x & %08x\n", 0x0b800000 + (offset << 2), mem_mask );
589616         break;
r9684r9685
593620
594621static WRITE32_HANDLER( ps_rtc_w )
595622{
623   pockstat_state *state = space->machine->driver_data<pockstat_state>();
596624   switch(offset)
597625   {
598626      case 0x0000/4:
599627         verboselog(space->machine, 0, "ps_rtc_w: RTC Mode = %08x & %08x\n", data, mem_mask );
600         COMBINE_DATA(&rtc_regs.mode);
628         COMBINE_DATA(&state->rtc_regs.mode);
601629         break;
602630      case 0x0004/4:
603631         verboselog(space->machine, 0, "ps_rtc_w: RTC Control = %08x & %08x\n", data, mem_mask );
604         if(rtc_regs.control == 1 && data == 1)
632         if(state->rtc_regs.control == 1 && data == 1)
605633         {
606            switch(rtc_regs.mode >> 1)
634            switch(state->rtc_regs.mode >> 1)
607635            {
608636               case 0: // Seconds
609                  rtc_regs.time += 0x00000001;
610                  if((rtc_regs.time & 0x0000000f) == 0x0000000a)
637                  state->rtc_regs.time += 0x00000001;
638                  if((state->rtc_regs.time & 0x0000000f) == 0x0000000a)
611639                  {
612                     rtc_regs.time &= 0xfffffff0;
613                     rtc_regs.time += 0x00000010;
614                     if((rtc_regs.time & 0x000000ff) == 0x00000060)
640                     state->rtc_regs.time &= 0xfffffff0;
641                     state->rtc_regs.time += 0x00000010;
642                     if((state->rtc_regs.time & 0x000000ff) == 0x00000060)
615643                     {
616                        rtc_regs.time &= 0xffffff00;
644                        state->rtc_regs.time &= 0xffffff00;
617645                     }
618646                  }
619647                  break;
620648               case 1: // Minutes
621                  rtc_regs.time += 0x00000100;
622                  if((rtc_regs.time & 0x00000f00) == 0x00000a00)
649                  state->rtc_regs.time += 0x00000100;
650                  if((state->rtc_regs.time & 0x00000f00) == 0x00000a00)
623651                  {
624                     rtc_regs.time &= 0xfffff0ff;
625                     rtc_regs.time += 0x00001000;
626                     if((rtc_regs.time & 0x0000ff00) == 0x00006000)
652                     state->rtc_regs.time &= 0xfffff0ff;
653                     state->rtc_regs.time += 0x00001000;
654                     if((state->rtc_regs.time & 0x0000ff00) == 0x00006000)
627655                     {
628                        rtc_regs.time &= 0xffff00ff;
656                        state->rtc_regs.time &= 0xffff00ff;
629657                     }
630658                  }
631659                  break;
632660               case 2: // Hours
633                  rtc_regs.time += 0x00010000;
634                  if((rtc_regs.time & 0x00ff0000) == 0x00240000)
661                  state->rtc_regs.time += 0x00010000;
662                  if((state->rtc_regs.time & 0x00ff0000) == 0x00240000)
635663                  {
636                     rtc_regs.time &= 0xff00ffff;
664                     state->rtc_regs.time &= 0xff00ffff;
637665                  }
638                  else if((rtc_regs.time & 0x000f0000) == 0x000a0000)
666                  else if((state->rtc_regs.time & 0x000f0000) == 0x000a0000)
639667                  {
640                     rtc_regs.time &= 0xfff0ffff;
641                     rtc_regs.time += 0x00100000;
668                     state->rtc_regs.time &= 0xfff0ffff;
669                     state->rtc_regs.time += 0x00100000;
642670                  }
643671                  break;
644672               case 3: // Day of the week
645                  rtc_regs.time += 0x01000000;
646                  if((rtc_regs.time & 0x0f000000) == 0x08000000)
673                  state->rtc_regs.time += 0x01000000;
674                  if((state->rtc_regs.time & 0x0f000000) == 0x08000000)
647675                  {
648                     rtc_regs.time &= 0xf0ffffff;
649                     rtc_regs.time |= 0x01000000;
676                     state->rtc_regs.time &= 0xf0ffffff;
677                     state->rtc_regs.time |= 0x01000000;
650678                  }
651679                  break;
652680               case 4: // Day
653                  rtc_regs.date += 0x00000001;
654                  if((rtc_regs.date & 0x000000ff) == 0x00000032)
681                  state->rtc_regs.date += 0x00000001;
682                  if((state->rtc_regs.date & 0x000000ff) == 0x00000032)
655683                  {
656                     rtc_regs.date &= 0xffffff00;
684                     state->rtc_regs.date &= 0xffffff00;
657685                  }
658                  else if((rtc_regs.date & 0x0000000f) == 0x0000000a)
686                  else if((state->rtc_regs.date & 0x0000000f) == 0x0000000a)
659687                  {
660                     rtc_regs.date &= 0xfffffff0;
661                     rtc_regs.date += 0x00000010;
688                     state->rtc_regs.date &= 0xfffffff0;
689                     state->rtc_regs.date += 0x00000010;
662690                  }
663691                  break;
664692               case 5: // Month
665                  rtc_regs.date += 0x00000100;
666                  if((rtc_regs.date & 0x0000ff00) == 0x00001300)
693                  state->rtc_regs.date += 0x00000100;
694                  if((state->rtc_regs.date & 0x0000ff00) == 0x00001300)
667695                  {
668                     rtc_regs.date &= 0xffffff00;
669                     rtc_regs.date |= 0x00000001;
696                     state->rtc_regs.date &= 0xffffff00;
697                     state->rtc_regs.date |= 0x00000001;
670698                  }
671                  else if((rtc_regs.date & 0x00000f00) == 0x00000a00)
699                  else if((state->rtc_regs.date & 0x00000f00) == 0x00000a00)
672700                  {
673                     rtc_regs.date &= 0xfffff0ff;
674                     rtc_regs.date += 0x00001000;
701                     state->rtc_regs.date &= 0xfffff0ff;
702                     state->rtc_regs.date += 0x00001000;
675703                  }
676704                  break;
677705               case 6: // Year (LSB)
678                  rtc_regs.date += 0x00010000;
679                  if((rtc_regs.date & 0x000f0000) == 0x000a0000)
706                  state->rtc_regs.date += 0x00010000;
707                  if((state->rtc_regs.date & 0x000f0000) == 0x000a0000)
680708                  {
681                     rtc_regs.date &= 0xfff0ffff;
682                     rtc_regs.date += 0x00100000;
683                     if((rtc_regs.date & 0x00f00000) == 0x00a00000)
709                     state->rtc_regs.date &= 0xfff0ffff;
710                     state->rtc_regs.date += 0x00100000;
711                     if((state->rtc_regs.date & 0x00f00000) == 0x00a00000)
684712                     {
685                        rtc_regs.date &= 0xff00ffff;
713                        state->rtc_regs.date &= 0xff00ffff;
686714                     }
687715                  }
688716                  break;
689717               case 7: // Year (MSB)
690718                  break;
691719            }
692            rtc_regs.control = 0;
720            state->rtc_regs.control = 0;
693721         }
694         else if(rtc_regs.control == 0)
722         else if(state->rtc_regs.control == 0)
695723         {
696            COMBINE_DATA(&rtc_regs.control);
724            COMBINE_DATA(&state->rtc_regs.control);
697725         }
698726         break;
699727      default:
r9684r9685
702730   }
703731}
704732
705static UINT32 lcd_control;
706733
707734static READ32_HANDLER( ps_lcd_r )
708735{
736   pockstat_state *state = space->machine->driver_data<pockstat_state>();
709737   switch(offset)
710738   {
711739      case 0x0000/4:
712         verboselog(space->machine, 0, "ps_lcd_r: LCD Control = %08x & %08x\n", lcd_control | 0x100, mem_mask );
713         return lcd_control;
740         verboselog(space->machine, 0, "ps_lcd_r: LCD Control = %08x & %08x\n", state->lcd_control | 0x100, mem_mask );
741         return state->lcd_control;
714742      default:
715743         verboselog(space->machine, 0, "ps_lcd_r: Unknown Register %08x & %08x\n", 0x0d000000 + (offset << 2), mem_mask );
716744         break;
r9684r9685
720748
721749static WRITE32_HANDLER( ps_lcd_w )
722750{
751   pockstat_state *state = space->machine->driver_data<pockstat_state>();
723752   switch(offset)
724753   {
725754      case 0x0000/4:
726755         verboselog(space->machine, 0, "ps_lcd_w: LCD Control = %08x & %08x\n", data, mem_mask );
727         COMBINE_DATA(&lcd_control);
756         COMBINE_DATA(&state->lcd_control);
728757         break;
729758      default:
730759         verboselog(space->machine, 0, "ps_lcd_w: Unknown Register %08x = %08x & %08x\n", 0x0d000000 + (offset << 2), data, mem_mask );
r9684r9685
745774
746775static READ32_HANDLER(ps_rombank_r)
747776{
777   pockstat_state *state = space->machine->driver_data<pockstat_state>();
748778   INT32 bank = (offset >> 11) & 0x0f;
749779   int index = 0;
750780   for(index = 0; index < 32; index++)
751781   {
752      if(ftlb_regs.valid & (1 << index))
782      if(state->ftlb_regs.valid & (1 << index))
753783      {
754         if(ftlb_regs.entry[index] == bank)
784         if(state->ftlb_regs.entry[index] == bank)
755785         {
756786            //printf( "Address %08x is assigned to %08x in entry %d\n", 0x02000000 + (offset << 2), index * 0x2000 + ((offset << 2) & 0x1fff), index );
757787            return ((UINT32*)memory_region(space->machine, "flash"))[index * (0x2000/4) + (offset & (0x1fff/4))];
r9684r9685
761791   return ((UINT32*)memory_region(space->machine, "flash"))[offset & 0x7fff];
762792}
763793
764static INT32 ps_flash_write_enable_count;
765static INT32 ps_flash_write_count;
766794
767795// Horrible hack, probably wrong
768796static WRITE32_HANDLER(ps_flash_w)
769797{
798   pockstat_state *state = space->machine->driver_data<pockstat_state>();
770799   if(offset == (0x55a8/4))
771800   {
772      ps_flash_write_enable_count++;
801      state->ps_flash_write_enable_count++;
773802      return;
774803   }
775804   if(offset == (0x2a54/4))
776805   {
777      ps_flash_write_enable_count++;
806      state->ps_flash_write_enable_count++;
778807      return;
779808   }
780   if(ps_flash_write_enable_count == 3)
809   if(state->ps_flash_write_enable_count == 3)
781810   {
782      ps_flash_write_enable_count = 0;
783      ps_flash_write_count = 0x40;
811      state->ps_flash_write_enable_count = 0;
812      state->ps_flash_write_count = 0x40;
784813      return;
785814   }
786   if(ps_flash_write_count)
815   if(state->ps_flash_write_count)
787816   {
788      ps_flash_write_count--;
817      state->ps_flash_write_count--;
789818      COMBINE_DATA(&((UINT32*)memory_region(space->machine, "flash"))[offset]);
790819   }
791820}
r9684r9685
817846   AM_RANGE(0x0b000000, 0x0b000007) AM_READWRITE(ps_clock_r, ps_clock_w)
818847   AM_RANGE(0x0b800000, 0x0b80000f) AM_READWRITE(ps_rtc_r, ps_rtc_w)
819848   AM_RANGE(0x0d000000, 0x0d000003) AM_READWRITE(ps_lcd_r, ps_lcd_w)
820   AM_RANGE(0x0d000100, 0x0d00017f) AM_RAM AM_BASE(&lcd_buffer)
849   AM_RANGE(0x0d000100, 0x0d00017f) AM_RAM AM_BASE_MEMBER(pockstat_state, lcd_buffer)
821850   AM_RANGE(0x0d80000c, 0x0d80000f) AM_READWRITE(ps_audio_r, ps_audio_w)
822851   AM_RANGE(0x0d800014, 0x0d800017) AM_WRITE(ps_dac_w)
823852ADDRESS_MAP_END
r9684r9685
835864
836865static MACHINE_START( pockstat )
837866{
867   pockstat_state *state = machine->driver_data<pockstat_state>();
838868   int index = 0;
839869   for(index = 0; index < 3; index++)
840870   {
841      timer_regs.timer[index].timer = timer_alloc(machine, timer_tick, 0);
842      timer_adjust_oneshot(timer_regs.timer[index].timer, attotime_never, index);
871      state->timer_regs.timer[index].timer = timer_alloc(machine, timer_tick, 0);
872      timer_adjust_oneshot(state->timer_regs.timer[index].timer, attotime_never, index);
843873   }
844874
845   rtc_regs.time = 0x01000000;
846   rtc_regs.date = 0x19990101;
875   state->rtc_regs.time = 0x01000000;
876   state->rtc_regs.date = 0x19990101;
847877
848   rtc_regs.timer = timer_alloc(machine, rtc_tick, 0);
849   timer_adjust_oneshot(rtc_regs.timer, ATTOTIME_IN_HZ(1), index);
878   state->rtc_regs.timer = timer_alloc(machine, rtc_tick, 0);
879   timer_adjust_oneshot(state->rtc_regs.timer, ATTOTIME_IN_HZ(1), index);
850880
851   state_save_register_global(machine, ftlb_regs.control);
852   state_save_register_global(machine, ftlb_regs.stat);
853   state_save_register_global(machine, ftlb_regs.valid);
854   state_save_register_global(machine, ftlb_regs.wait1);
855   state_save_register_global(machine, ftlb_regs.wait2);
856   state_save_register_global_array(machine, ftlb_regs.entry);
881   state_save_register_global(machine, state->ftlb_regs.control);
882   state_save_register_global(machine, state->ftlb_regs.stat);
883   state_save_register_global(machine, state->ftlb_regs.valid);
884   state_save_register_global(machine, state->ftlb_regs.wait1);
885   state_save_register_global(machine, state->ftlb_regs.wait2);
886   state_save_register_global_array(machine, state->ftlb_regs.entry);
857887
858   state_save_register_global(machine, intc_regs.hold);
859   state_save_register_global(machine, intc_regs.status);
860   state_save_register_global(machine, intc_regs.enable);
861   state_save_register_global(machine, intc_regs.mask);
888   state_save_register_global(machine, state->intc_regs.hold);
889   state_save_register_global(machine, state->intc_regs.status);
890   state_save_register_global(machine, state->intc_regs.enable);
891   state_save_register_global(machine, state->intc_regs.mask);
862892
863   state_save_register_global(machine, timer_regs.timer[0].period);
864   state_save_register_global(machine, timer_regs.timer[0].count);
865   state_save_register_global(machine, timer_regs.timer[0].control);
866   state_save_register_global(machine, timer_regs.timer[1].period);
867   state_save_register_global(machine, timer_regs.timer[1].count);
868   state_save_register_global(machine, timer_regs.timer[1].control);
869   state_save_register_global(machine, timer_regs.timer[2].period);
870   state_save_register_global(machine, timer_regs.timer[2].count);
871   state_save_register_global(machine, timer_regs.timer[2].control);
893   state_save_register_global(machine, state->timer_regs.timer[0].period);
894   state_save_register_global(machine, state->timer_regs.timer[0].count);
895   state_save_register_global(machine, state->timer_regs.timer[0].control);
896   state_save_register_global(machine, state->timer_regs.timer[1].period);
897   state_save_register_global(machine, state->timer_regs.timer[1].count);
898   state_save_register_global(machine, state->timer_regs.timer[1].control);
899   state_save_register_global(machine, state->timer_regs.timer[2].period);
900   state_save_register_global(machine, state->timer_regs.timer[2].count);
901   state_save_register_global(machine, state->timer_regs.timer[2].control);
872902
873   state_save_register_global(machine, clock_regs.mode);
874   state_save_register_global(machine, clock_regs.control);
903   state_save_register_global(machine, state->clock_regs.mode);
904   state_save_register_global(machine, state->clock_regs.control);
875905
876   state_save_register_global(machine, rtc_regs.mode);
877   state_save_register_global(machine, rtc_regs.control);
878   state_save_register_global(machine, rtc_regs.time);
879   state_save_register_global(machine, rtc_regs.date);
906   state_save_register_global(machine, state->rtc_regs.mode);
907   state_save_register_global(machine, state->rtc_regs.control);
908   state_save_register_global(machine, state->rtc_regs.time);
909   state_save_register_global(machine, state->rtc_regs.date);
880910
881   state_save_register_global(machine, ps_flash_write_enable_count);
882   state_save_register_global(machine, ps_flash_write_count);
911   state_save_register_global(machine, state->ps_flash_write_enable_count);
912   state_save_register_global(machine, state->ps_flash_write_count);
883913}
884914
885915static MACHINE_RESET( pockstat )
886916{
917   pockstat_state *state = machine->driver_data<pockstat_state>();
887918   cpu_set_reg(machine->device("maincpu"), STATE_GENPC, 0x4000000);
888919
889   ps_flash_write_enable_count = 0;
890   ps_flash_write_count = 0;
920   state->ps_flash_write_enable_count = 0;
921   state->ps_flash_write_count = 0;
891922}
892923
893924static VIDEO_UPDATE( pockstat )
894925{
926   pockstat_state *state = screen->machine->driver_data<pockstat_state>();
895927   int x = 0;
896928   int y = 0;
897929   for(y = 0; y < 32; y++)
r9684r9685
899931      UINT32 *scanline = BITMAP_ADDR32(bitmap, y, 0);
900932      for(x = 0; x < 32; x++)
901933      {
902         if(lcd_control != 0) // Hack
934         if(state->lcd_control != 0) // Hack
903935         {
904            if(lcd_buffer[y] & (1 << x))
936            if(state->lcd_buffer[y] & (1 << x))
905937            {
906938               scanline[x] = 0x00000000;
907939            }
r9684r9685
945977   return IMAGE_INIT_PASS;
946978}
947979
948static MACHINE_CONFIG_START( pockstat, driver_device )
980static MACHINE_CONFIG_START( pockstat, pockstat_state )
949981   /* basic machine hardware */
950982   MDRV_CPU_ADD("maincpu", ARM7, DEFAULT_CLOCK)
951983   MDRV_CPU_PROGRAM_MAP(pockstat_mem)
src/mess/drivers/ob68k1a.c
r9684r9685
99#include "emu.h"
1010#include "cpu/m68000/m68000.h"
1111
12static UINT16* ob68k1a_ram;
1312
13class ob68k1a_state : public driver_device
14{
15public:
16   ob68k1a_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   UINT16* ram;
20};
21
22
23
1424static ADDRESS_MAP_START(ob68k1a_mem, ADDRESS_SPACE_PROGRAM, 16)
1525   ADDRESS_MAP_UNMAP_HIGH
16   AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_BASE(&ob68k1a_ram) // 32 KB RAM up to 128K
26   AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_BASE_MEMBER(ob68k1a_state, ram) // 32 KB RAM up to 128K
1727   AM_RANGE(0x00fe0000, 0x00feffff) AM_ROM AM_REGION("user1",0)   
1828ADDRESS_MAP_END
1929
r9684r9685
2333
2434
2535static MACHINE_RESET(ob68k1a)
26{   
36{
37   ob68k1a_state *state = machine->driver_data<ob68k1a_state>();   
2738   UINT8* user1 = memory_region(machine, "user1");
2839
29   memcpy((UINT8*)ob68k1a_ram,user1,0x8000);
40   memcpy((UINT8*)state->ram,user1,0x8000);
3041
3142   machine->device("maincpu")->reset();
3243}
r9684r9685
4051    return 0;
4152}
4253
43static MACHINE_CONFIG_START( ob68k1a, driver_device )
54static MACHINE_CONFIG_START( ob68k1a, ob68k1a_state )
4455    /* basic machine hardware */
4556    MDRV_CPU_ADD("maincpu",M68000, XTAL_10MHz)
4657    MDRV_CPU_PROGRAM_MAP(ob68k1a_mem)
src/mess/drivers/nanos.c
r9684r9685
1717#include "formats/basicdsk.h"
1818#include "devices/messram.h"
1919
20static const UINT8 *FNT;
2120
21class nanos_state : public driver_device
22{
23public:
24   nanos_state(running_machine &machine, const driver_device_config_base &config)
25      : driver_device(machine, config) { }
26
27   const UINT8 *FNT;
28   UINT8 key_command;
29   UINT8 last_code;
30   UINT8 key_pressed;
31};
32
33
34
2235static ADDRESS_MAP_START(nanos_mem, ADDRESS_SPACE_PROGRAM, 8)
2336   AM_RANGE( 0x0000, 0x0fff ) AM_READ_BANK("bank1") AM_WRITE_BANK("bank3")
2437   AM_RANGE( 0x1000, 0xffff ) AM_RAMBANK("bank2")
r9684r9685
227240
228241static VIDEO_START( nanos )
229242{
230   FNT = memory_region(machine, "gfx1");
243   nanos_state *state = machine->driver_data<nanos_state>();
244   state->FNT = memory_region(machine, "gfx1");
231245}
232246
233247static VIDEO_UPDATE( nanos )
234248{
249   nanos_state *state = screen->machine->driver_data<nanos_state>();
235250//  static UINT8 framecnt=0;
236251   UINT8 y,ra,chr,gfx;
237252   UINT16 sy=0,ma=0,x;
r9684r9685
251266               chr = messram_get_ptr(screen->machine->device("messram"))[0xf800+ x];
252267
253268               /* get pattern of pixels for that character scanline */
254               gfx = FNT[(chr<<3) | ra ];
269               gfx = state->FNT[(chr<<3) | ra ];
255270            }
256271            else
257272               gfx = 0;
r9684r9685
272287   return 0;
273288}
274289
275static UINT8 key_command;
276static UINT8 last_code = 0;
277static UINT8 key_pressed;
278290static READ8_DEVICE_HANDLER (nanos_port_a_r)
279291{
292   nanos_state *state = device->machine->driver_data<nanos_state>();
280293   UINT8 retVal;
281   if (key_command==0)  {
282      return key_pressed;
294   if (state->key_command==0)  {
295      return state->key_pressed;
283296   } else {
284      retVal = last_code;
285      last_code = 0;
297      retVal = state->last_code;
298      state->last_code = 0;
286299      return retVal;
287300   }
288301}
r9684r9685
295308
296309static WRITE8_DEVICE_HANDLER (nanos_port_b_w)
297310{
298   key_command = BIT(data,1);
311   nanos_state *state = device->machine->driver_data<nanos_state>();
312   state->key_command = BIT(data,1);
299313   if (BIT(data,7)) {
300314      memory_set_bankptr(device->machine, "bank1", memory_region(device->machine, "maincpu"));
301315   } else {
r9684r9685
316330
317331static TIMER_CALLBACK(keyboard_callback)
318332{
333   nanos_state *state = machine->driver_data<nanos_state>();
319334   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6" };
320335
321336   int i;
r9684r9685
323338   UINT8 key_code = 0;
324339   UINT8 shift = input_port_read(machine, "LINEC") & 0x02 ? 1 : 0;
325340   UINT8 ctrl =  input_port_read(machine, "LINEC") & 0x01 ? 1 : 0;
326   key_pressed = 0xff;
341   state->key_pressed = 0xff;
327342   for(i = 0; i < 7; i++)
328343   {
329344
r9684r9685
389404               case 7: key_code = 0x0A; break; // LF
390405            }
391406         }
392         last_code = key_code;
407         state->last_code = key_code;
393408      }
394409   }
395410   if (key_code==0){
396      key_pressed = 0xf7;
411      state->key_pressed = 0xf7;
397412   }
398413}
399414
400415static MACHINE_START(nanos)
401416{
402   key_pressed = 0xff;
417   nanos_state *state = machine->driver_data<nanos_state>();
418   state->key_pressed = 0xff;
403419   timer_pulse(machine, ATTOTIME_IN_HZ(24000), NULL, 0, keyboard_callback);
404420}
405421
r9684r9685
478494   GFXDECODE_ENTRY( "gfx1", 0x0000, nanos_charlayout, 0, 1 )
479495GFXDECODE_END
480496
481static MACHINE_CONFIG_START( nanos, driver_device )
497static MACHINE_CONFIG_START( nanos, nanos_state )
482498   /* basic machine hardware */
483499   MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
484500   MDRV_CPU_PROGRAM_MAP(nanos_mem)
src/mess/drivers/pv1000.c
r9684r9685
1414DEFINE_LEGACY_SOUND_DEVICE(PV1000,pv1000_sound);
1515
1616
17class d65010_state : public driver_device {
17class d65010_state : public driver_device
18{
1819public:
1920   d65010_state(running_machine &machine, const driver_device_config_base &config)
2021      : driver_device(machine, config) { }
r9684r9685
3435
3536   running_device *maincpu;
3637   screen_device *screen;
38   UINT8 *ram;
3739};
3840
3941
40static UINT8 *pv1000_ram;
41
42
4342static WRITE8_HANDLER( pv1000_io_w );
4443static READ8_HANDLER( pv1000_io_r );
4544static WRITE8_HANDLER( pv1000_gfxram_w );
r9684r9685
4746
4847static ADDRESS_MAP_START( pv1000, ADDRESS_SPACE_PROGRAM, 8 )
4948   AM_RANGE( 0x0000, 0x3fff ) AM_MIRROR( 0x4000 ) AM_ROM AM_REGION( "cart", 0 )
50   AM_RANGE( 0xb800, 0xbbff ) AM_RAM AM_BASE( &pv1000_ram )
49   AM_RANGE( 0xb800, 0xbbff ) AM_RAM AM_BASE_MEMBER( d65010_state, ram )
5150   AM_RANGE( 0xbc00, 0xbfff ) AM_RAM_WRITE( pv1000_gfxram_w ) AM_REGION( "gfxram", 0 )
5251ADDRESS_MAP_END
5352
r9684r9685
220219   {
221220      for ( x = 0; x < 32; x++ )
222221      {
223         UINT16 tile = pv1000_ram[ y * 32 + x ];
222         UINT16 tile = state->ram[ y * 32 + x ];
224223
225224         if ( tile < 0xe0 )
226225         {
src/mess/drivers/prestige.c
r9684r9685
7979#include "devices/messram.h"
8080#include "devices/cartslot.h"
8181
82static UINT8 bank[6];
8382
83class prestige_state : public driver_device
84{
85public:
86   prestige_state(running_machine &machine, const driver_device_config_base &config)
87      : driver_device(machine, config) { }
88
89   UINT8 bank[6];
90};
91
92
93
8494static READ8_HANDLER( bankswitch_r )
8595{
86   return bank[offset];
96   prestige_state *state = space->machine->driver_data<prestige_state>();
97   return state->bank[offset];
8798}
8899
89100static WRITE8_HANDLER( bankswitch_w )
90101{
102   prestige_state *state = space->machine->driver_data<prestige_state>();
91103   address_space *program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
92104
93105   switch (offset)
r9684r9685
101113      break;
102114
103115   case 2:
104      if (bank[5] == 0x0c)
116      if (state->bank[5] == 0x0c)
105117      {
106118         memory_set_bank(space->machine, "bank3", 0x40 + BIT(data, 7));
107119      }
r9684r9685
130142      }
131143   }
132144
133   bank[offset] = data;
145   state->bank[offset] = data;
134146}
135147
136148static ADDRESS_MAP_START(prestige_mem, ADDRESS_SPACE_PROGRAM, 8)
r9684r9685
210222   return IMAGE_INIT_FAIL;
211223}
212224
213static MACHINE_CONFIG_START( prestige, driver_device )
225static MACHINE_CONFIG_START( prestige, prestige_state )
214226    /* basic machine hardware */
215227    MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
216228    MDRV_CPU_PROGRAM_MAP(prestige_mem)
src/mess/drivers/pk8000.c
r9684r9685
1717#include "includes/pk8000.h"
1818#include "devices/messram.h"
1919
20static UINT8 keyboard_line;
2120
21class pk8000_state : public driver_device
22{
23public:
24   pk8000_state(running_machine &machine, const driver_device_config_base &config)
25      : driver_device(machine, config) { }
26
27   UINT8 keyboard_line;
28};
29
30
31
2232static running_device *cassette_device_image(running_machine *machine)
2333{
2434   return machine->device("cassette");
r9684r9685
8999
90100static READ8_DEVICE_HANDLER(pk8000_80_portb_r)
91101{
102   pk8000_state *state = device->machine->driver_data<pk8000_state>();
92103   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", "LINE8", "LINE9" };
93   if(keyboard_line>9) {
104   if(state->keyboard_line>9) {
94105      return 0xff;
95106   }
96   return input_port_read(device->machine,keynames[keyboard_line]);
107   return input_port_read(device->machine,keynames[state->keyboard_line]);
97108}
98109
99110static WRITE8_DEVICE_HANDLER(pk8000_80_portc_w)
100111{
101   keyboard_line = data & 0x0f;
112   pk8000_state *state = device->machine->driver_data<pk8000_state>();
113   state->keyboard_line = data & 0x0f;
102114
103115   speaker_level_w(device->machine->device("speaker"), BIT(data,7));
104116
r9684r9685
324336   NULL
325337};
326338
327static MACHINE_CONFIG_START( pk8000, driver_device )
339static MACHINE_CONFIG_START( pk8000, pk8000_state )
328340    /* basic machine hardware */
329341    MDRV_CPU_ADD("maincpu",I8080, 1780000)
330342    MDRV_CPU_PROGRAM_MAP(pk8000_mem)
src/mess/drivers/pce220.c
r9684r9685
1414#include "cpu/z80/z80.h"
1515#include "devices/messram.h"
1616
17static UINT8 bank_num;
18static UINT16 lcd_index_row,lcd_index_col;
1917
18class pce220_state : public driver_device
19{
20public:
21   pce220_state(running_machine &machine, const driver_device_config_base &config)
22      : driver_device(machine, config) { }
23
24   UINT8 bank_num;
25   UINT16 lcd_index_row;
26   UINT16 lcd_index_col;
27   UINT8 lcd_timer;
28};
29
30
31
2032static VIDEO_START( pce220 )
2133{
2234}
r9684r9685
5870
5971static WRITE8_HANDLER( lcd_control_w )
6072{
73   pce220_state *state = space->machine->driver_data<pce220_state>();
6174   if((data & 0xb8) == 0xb8)
62      lcd_index_row = (data & 0x07);
75      state->lcd_index_row = (data & 0x07);
6376   if((data & 0x40) == 0x40)
64      lcd_index_col = (data & 0x3f);
77      state->lcd_index_col = (data & 0x3f);
6578}
6679
6780static WRITE8_HANDLER( lcd_data_w )
6881{
82   pce220_state *state = space->machine->driver_data<pce220_state>();
6983   UINT8 *vram = memory_region(space->machine, "lcd_vram");
7084
71   vram[lcd_index_row*0x40|lcd_index_col] = data;
85   vram[state->lcd_index_row*0x40|state->lcd_index_col] = data;
7286
73   gfx_element_mark_dirty(space->machine->gfx[0], (lcd_index_row*0x40|lcd_index_col)/5);
74   lcd_index_col++;
87   gfx_element_mark_dirty(space->machine->gfx[0], (state->lcd_index_row*0x40|state->lcd_index_col)/5);
88   state->lcd_index_col++;
7589}
7690
7791static READ8_HANDLER( rom_bank_r )
7892{
79   return bank_num;
93   pce220_state *state = space->machine->driver_data<pce220_state>();
94   return state->bank_num;
8095}
8196
8297static WRITE8_HANDLER( rom_bank_w )
8398{
99   pce220_state *state = space->machine->driver_data<pce220_state>();
84100   UINT8 bank2 = data & 0x07; // bits 0,1,2
85101   UINT8 bank1 = (data & 0x70) >> 4; // bits 4,5,6
86102
87   bank_num = data;
103   state->bank_num = data;
88104
89105   memory_set_bankptr(space->machine, "bank3", memory_region(space->machine, "user1") + 0x4000 * bank1);
90106   memory_set_bankptr(space->machine, "bank4", memory_region(space->machine, "user1") + 0x4000 * bank2);
r9684r9685
113129}
114130
115131/* TODO */
116static UINT8 lcd_timer;
117132
118133static READ8_HANDLER( timer_lcd_r )
119134{
r9684r9685
122137
123138static WRITE8_HANDLER( timer_lcd_w )
124139{
125   lcd_timer = data & 1;
140   pce220_state *state = space->machine->driver_data<pce220_state>();
141   state->lcd_timer = data & 1;
126142}
127143
128144static READ8_HANDLER( port15_r )
r9684r9685
208224   GFXDECODE_ENTRY( "lcd_vram",   0x00000, test_decode,    0, 1 )
209225GFXDECODE_END
210226
211static MACHINE_CONFIG_START( pce220, driver_device )
227static MACHINE_CONFIG_START( pce220, pce220_state )
212228    /* basic machine hardware */
213229    MDRV_CPU_ADD("maincpu",Z80, 3072000 ) // CMOS-SC7852
214230    MDRV_CPU_PROGRAM_MAP(pce220_mem)
src/mess/drivers/pv9234.c
r9684r9685
99#include "emu.h"
1010#include "cpu/arm7/arm7.h"
1111
12static UINT32 *powervu_ram;
1312
13class pv9234_state : public driver_device
14{
15public:
16   pv9234_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   UINT32 *powervu_ram;
20};
21
22
23
1424static WRITE32_HANDLER( debug_w )
1525{
1626   printf("%02x %c\n",data,data);
r9684r9685
1828
1929static ADDRESS_MAP_START(pv9234_map, ADDRESS_SPACE_PROGRAM, 32)
2030   AM_RANGE(0x000080cc, 0x000080cf) AM_WRITE(debug_w)
21   AM_RANGE(0x0003e000, 0x0003efff) AM_RAM AM_BASE(&powervu_ram)
31   AM_RANGE(0x0003e000, 0x0003efff) AM_RAM AM_BASE_MEMBER(pv9234_state, powervu_ram)
2232   AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_REGION("maincpu",0) //FLASH ROM!
2333   AM_RANGE(0x00080000, 0x00087fff) AM_MIRROR(0x78000) AM_RAM AM_SHARE("share1")//mirror is a guess, writes a prg at 0xc0200 then it jumps at b0200 (!)
2434   AM_RANGE(0xe0000000, 0xe0007fff) AM_MIRROR(0x0fff8000) AM_RAM AM_SHARE("share1")
r9684r9685
3242
3343static MACHINE_RESET(pv9234)
3444{
45   pv9234_state *state = machine->driver_data<pv9234_state>();
3546   int i;
3647
3748   for(i=0;i<0x1000/4;i++)
38      powervu_ram[i] = 0;
49      state->powervu_ram[i] = 0;
3950}
4051
4152static VIDEO_START( pv9234 )
r9684r9685
4758    return 0;
4859}
4960
50static MACHINE_CONFIG_START( pv9234, driver_device )
61static MACHINE_CONFIG_START( pv9234, pv9234_state )
5162    /* basic machine hardware */
5263    MDRV_CPU_ADD("maincpu", ARM7, 4915000) //probably a more powerful clone.
5364    MDRV_CPU_PROGRAM_MAP(pv9234_map)
src/mess/drivers/vt100.c
r9684r9685
1919#include "video/vtvideo.h"
2020#include "vt100.lh"
2121
22static UINT8 *vt100_ram;
23static UINT8 vt100_keyboard_int;
24static UINT8 vt100_receiver_int;
25static UINT8 vt100_vertical_int;
2622
27static double vt100_send_baud_rate;
28static double vt100_recv_baud_rate;
23class vt100_state : public driver_device
24{
25public:
26   vt100_state(running_machine &machine, const driver_device_config_base &config)
27      : driver_device(machine, config) { }
2928
29   UINT8 *ram;
30   UINT8 keyboard_int;
31   UINT8 receiver_int;
32   UINT8 vertical_int;
33   double send_baud_rate;
34   double recv_baud_rate;
35   UINT8 key_scan;
36};
37
38
39
40
3041static ADDRESS_MAP_START(vt100_mem, ADDRESS_SPACE_PROGRAM, 8)
3142   ADDRESS_MAP_UNMAP_HIGH
3243    AM_RANGE( 0x0000, 0x1fff ) AM_ROM  // ROM ( 4 * 2K)
33    AM_RANGE( 0x2000, 0x2bff ) AM_RAM AM_BASE(&vt100_ram) // Screen and scratch RAM
44    AM_RANGE( 0x2000, 0x2bff ) AM_RAM AM_BASE_MEMBER(vt100_state, ram) // Screen and scratch RAM
3445    AM_RANGE( 0x2c00, 0x2fff ) AM_RAM  // AVO Screen RAM
3546    AM_RANGE( 0x3000, 0x3fff ) AM_RAM  // AVO Attribute RAM (4 bits wide)
3647    // 0x4000, 0x7fff is unassigned
r9684r9685
4960// 7 - Keyboard TBMT H
5061static READ8_HANDLER(vt100_flags_r)
5162{
63   vt100_state *state = space->machine->driver_data<vt100_state>();
5264   UINT8 retVal = 0;
5365   retVal |= vt_video_lba7_r(space->machine->device("vt100_video"),0) * 0x40;
54   retVal |= vt100_keyboard_int * 0x80;
66   retVal |= state->keyboard_int * 0x80;
5567   return retVal;
5668}
5769
58static UINT8 vt100_key_scan = 0;
5970
6071static TIMER_CALLBACK(keyboard_callback)
6172{
73   vt100_state *state = machine->driver_data<vt100_state>();
6274   int i;
6375   static const char *const keynames[] = {
6476      "LINE0", "LINE1", "LINE2", "LINE3",
r9684r9685
6779      "LINEC", "LINED", "LINEE", "LINEF"
6880   };
6981   UINT8 code;
70   if (vt100_key_scan == 1) {
82   if (state->key_scan == 1) {
7183      for(i = 0; i < 16; i++)
7284      {
7385         code =   input_port_read(machine, keynames[i]);
7486         if (code!=0xff) {
75            vt100_keyboard_int = 1;
87            state->keyboard_int = 1;
7688            cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE);
7789         }
7890      }
r9684r9685
8294
8395static WRITE8_HANDLER(vt100_keyboard_w)
8496{
97   vt100_state *state = space->machine->driver_data<vt100_state>();
8598
8699   running_device *speaker = space->machine->device("speaker");
87100
r9684r9685
92105   output_set_value("l2_led",     BIT(data,2) ? 0 : 1);
93106   output_set_value("l3_led",     BIT(data,1) ? 0 : 1);
94107   output_set_value("l4_led",     BIT(data,0) ? 0 : 1);
95   vt100_key_scan = BIT(data,6);
108   state->key_scan = BIT(data,6);
96109   speaker_level_w(speaker, BIT(data,7));
97110}
98111
r9684r9685
102115}
103116static WRITE8_HANDLER(vt100_baud_rate_w)
104117{
118   vt100_state *state = space->machine->driver_data<vt100_state>();
105119   static const double baud_rate[] = {
106120      50, 75, 110, 134.5, 150, 200, 300, 600, 1200,
107121      1800, 2000, 2400, 3600, 4800, 9600, 19200
108122   };
109123
110   vt100_send_baud_rate = baud_rate[(data >>4) & 0x0f];
111   vt100_recv_baud_rate = baud_rate[data & 0x0f];
124   state->send_baud_rate = baud_rate[(data >>4) & 0x0f];
125   state->recv_baud_rate = baud_rate[data & 0x0f];
112126}
113127
114128static WRITE8_HANDLER(vt100_nvr_latch_w)
r9684r9685
274288//          all other set to 1
275289static IRQ_CALLBACK(vt100_irq_callback)
276290{
277   UINT8 retVal = 0xc7 | (0x08 * vt100_keyboard_int) | (0x10 * vt100_receiver_int) | (0x20 * vt100_vertical_int);
278   vt100_receiver_int = 0;
291   vt100_state *state = device->machine->driver_data<vt100_state>();
292   UINT8 retVal = 0xc7 | (0x08 * state->keyboard_int) | (0x10 * state->receiver_int) | (0x20 * state->vertical_int);
293   state->receiver_int = 0;
279294   return retVal;
280295}
281296
r9684r9685
286301
287302static MACHINE_RESET(vt100)
288303{
289   vt100_keyboard_int = 0;
290   vt100_receiver_int = 0;
291   vt100_vertical_int = 0;
304   vt100_state *state = machine->driver_data<vt100_state>();
305   state->keyboard_int = 0;
306   state->receiver_int = 0;
307   state->vertical_int = 0;
292308   output_set_value("online_led",1);
293309   output_set_value("local_led", 1);
294310   output_set_value("locked_led",1);
r9684r9685
297313   output_set_value("l3_led",     1);
298314   output_set_value("l4_led",     1);
299315
300   vt100_key_scan = 0;
316   state->key_scan = 0;
301317
302318   cpu_set_irq_callback(machine->device("maincpu"), vt100_irq_callback);
303319}
304320
305321static READ8_DEVICE_HANDLER (vt100_read_video_ram_r )
306322{
307   return vt100_ram[offset];
323   vt100_state *state = device->machine->driver_data<vt100_state>();
324   return state->ram[offset];
308325}
309326
310327static WRITE8_DEVICE_HANDLER (vt100_clear_video_interrupt)
311328{
312   vt100_vertical_int = 0;
329   vt100_state *state = device->machine->driver_data<vt100_state>();
330   state->vertical_int = 0;
313331}
314332
315333static const vt_video_interface vt100_video_interface = {
r9684r9685
321339
322340static INTERRUPT_GEN( vt100_vertical_interrupt )
323341{
324   vt100_vertical_int = 1;
342   vt100_state *state = device->machine->driver_data<vt100_state>();
343   state->vertical_int = 1;
325344   cpu_set_input_line(device, 0, HOLD_LINE);
326345}
327346
r9684r9685
346365
347366#define XTAL_24_8832MHz    24883200
348367
349static MACHINE_CONFIG_START( vt100, driver_device )
368static MACHINE_CONFIG_START( vt100, vt100_state )
350369   /* basic machine hardware */
351370   MDRV_CPU_ADD("maincpu",I8080, XTAL_24_8832MHz / 9)
352371   MDRV_CPU_PROGRAM_MAP(vt100_mem)
src/mess/drivers/microdec.c
r9684r9685
1212#include "devices/flopdrv.h"
1313#include "machine/terminal.h"
1414
15static UINT8 received_char = 0;
1615
16class microdec_state : public driver_device
17{
18public:
19   microdec_state(running_machine &machine, const driver_device_config_base &config)
20      : driver_device(machine, config) { }
21
22   UINT8 received_char;
23};
24
25
26
1727static WRITE8_HANDLER(microdec_terminal_w)
1828{
1929   running_device *devconf = space->machine->device("terminal");
r9684r9685
2232
2333static READ8_HANDLER(microdec_terminal_status_r)
2434{
25   if (received_char!=0) return 3; // char received
35   microdec_state *state = space->machine->driver_data<microdec_state>();
36   if (state->received_char!=0) return 3; // char received
2637   return 1; // ready
2738}
2839
2940static READ8_HANDLER(microdec_terminal_r)
3041{
31   UINT8 retVal = received_char;
32   received_char = 0;
42   microdec_state *state = space->machine->driver_data<microdec_state>();
43   UINT8 retVal = state->received_char;
44   state->received_char = 0;
3345   return retVal;
3446}
3547
r9684r9685
5668
5769static MACHINE_RESET(microdec)
5870{
59   received_char = 0;
71   microdec_state *state = machine->driver_data<microdec_state>();
72   state->received_char = 0;
6073}
6174
6275static WRITE8_DEVICE_HANDLER( microdec_kbd_put )
6376{
64   received_char = data;
77   microdec_state *state = device->machine->driver_data<microdec_state>();
78   state->received_char = data;
6579}
6680
6781static GENERIC_TERMINAL_INTERFACE( microdec_terminal_intf )
r9684r9685
94108   NULL
95109};
96110
97static MACHINE_CONFIG_START( microdec, driver_device )
111static MACHINE_CONFIG_START( microdec, microdec_state )
98112    /* basic machine hardware */
99113    MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
100114    MDRV_CPU_PROGRAM_MAP(microdec_mem)
src/mess/drivers/pimps.c
r9684r9685
1010#include "cpu/i8085/i8085.h"
1111#include "machine/terminal.h"
1212
13
14class pimps_state : public driver_device
15{
16public:
17   pimps_state(running_machine &machine, const driver_device_config_base &config)
18      : driver_device(machine, config) { }
19
20   UINT8 received_char;
21};
22
23
1324// should be 8251 UART
1425
15static UINT8 received_char = 0;
1626
1727static READ8_HANDLER(pimps_terminal_status_r)
1828{
19   if (received_char!=0) return 3; // char received
29   pimps_state *state = space->machine->driver_data<pimps_state>();
30   if (state->received_char!=0) return 3; // char received
2031   return 1; // ready
2132}
2233
2334static READ8_DEVICE_HANDLER(pimps_terminal_r)
2435{
25   UINT8 retVal = received_char;
26   received_char = 0;
36   pimps_state *state = device->machine->driver_data<pimps_state>();
37   UINT8 retVal = state->received_char;
38   state->received_char = 0;
2739   return retVal;
2840}
2941
r9684r9685
4759
4860static MACHINE_RESET(pimps)
4961{
50   received_char = 0;
62   pimps_state *state = machine->driver_data<pimps_state>();
63   state->received_char = 0;
5164}
5265
5366static WRITE8_DEVICE_HANDLER( pimps_kbd_put )
5467{
55   received_char = data;
68   pimps_state *state = device->machine->driver_data<pimps_state>();
69   state->received_char = data;
5670}
5771
5872static GENERIC_TERMINAL_INTERFACE( pimps_terminal_intf )
r9684r9685
6074   DEVCB_HANDLER(pimps_kbd_put)
6175};
6276
63static MACHINE_CONFIG_START( pimps, driver_device )
77static MACHINE_CONFIG_START( pimps, pimps_state )
6478    /* basic machine hardware */
6579    MDRV_CPU_ADD("maincpu",I8085A, XTAL_2MHz)
6680    MDRV_CPU_PROGRAM_MAP(pimps_mem)
src/mess/drivers/pc2000.c
r9684r9685
99#include "emu.h"
1010#include "cpu/z80/z80.h"
1111
12static int lcd_vram_index;
13static UINT8 mux_data;
14static UINT8 *wram;
1512
13class pc2000_state : public driver_device
14{
15public:
16   pc2000_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   int lcd_vram_index;
20   UINT8 mux_data;
21   UINT8 *wram;
22};
23
24
25
1626static VIDEO_START( pc2000 )
1727{
1828}
1929
2030static VIDEO_UPDATE( pc2000 )
2131{
32   pc2000_state *state = screen->machine->driver_data<pc2000_state>();
2233   int x,y;
2334   UINT8 *vram = memory_region(screen->machine, "lcd_vram");
2435
r9684r9685
3243      }
3344   }
3445
35   popmessage("%c %02x",wram[0xce4],wram[0xce4]); //dce4
46   popmessage("%c %02x",state->wram[0xce4],state->wram[0xce4]); //dce4
3647    return 0;
3748}
3849
3950static WRITE8_HANDLER( lcd_vram_addr_w )
4051{
41   lcd_vram_index = data;
52   pc2000_state *state = space->machine->driver_data<pc2000_state>();
53   state->lcd_vram_index = data;
4254}
4355
4456static WRITE8_HANDLER( lcd_vram_data_w )
4557{
58   pc2000_state *state = space->machine->driver_data<pc2000_state>();
4659   UINT8 *vram = memory_region(space->machine, "lcd_vram");
4760
48   vram[lcd_vram_index] = data;
61   vram[state->lcd_vram_index] = data;
4962}
5063
5164
5265/* TODO: put a breakpoint at 1625 and test the inputs, writes at dce4 are the scancode values */
5366static READ8_HANDLER( key_matrix_10_r )
5467{
55   switch(mux_data)
68   pc2000_state *state = space->machine->driver_data<pc2000_state>();
69   switch(state->mux_data)
5670   {
5771      case 0x01: return input_port_read(space->machine, "IN0");
5872      case 0x02: return input_port_read(space->machine, "IN1");
r9684r9685
6983
7084static READ8_HANDLER( key_matrix_11_r )
7185{
72   switch(mux_data)
86   pc2000_state *state = space->machine->driver_data<pc2000_state>();
87   switch(state->mux_data)
7388   {
7489      case 0x01: return input_port_read(space->machine, "IN8");
7590      case 0x02: return input_port_read(space->machine, "IN9");
r9684r9685
86101
87102static WRITE8_HANDLER( key_matrix_w )
88103{
89   mux_data = data;
104   pc2000_state *state = space->machine->driver_data<pc2000_state>();
105   state->mux_data = data;
90106}
91107
92108static WRITE8_HANDLER( rombank_w )
r9684r9685
101117   AM_RANGE(0x0000, 0x3fff) AM_ROM AM_REGION("bios", 0x00000)
102118   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
103119   AM_RANGE(0x8000, 0xbfff) AM_READNOP //  0x8000 - 0xbfff tests a cartridge, header is 0x55 0xaa 0x59 0x45, if it succeeds a jump at 0x8004 occurs
104   AM_RANGE(0xd000, 0xdfff) AM_RAM AM_BASE(&wram)
120   AM_RANGE(0xd000, 0xdfff) AM_RAM AM_BASE_MEMBER(pc2000_state, wram)
105121   AM_RANGE(0xf000, 0xffff) AM_ROM AM_REGION("bios", 0x10000) //tied with rom bank at I/O 3
106122ADDRESS_MAP_END
107123
r9684r9685
469485GFXDECODE_END
470486
471487
472static MACHINE_CONFIG_START( pc2000, driver_device )
488static MACHINE_CONFIG_START( pc2000, pc2000_state )
473489    /* basic machine hardware */
474490    MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz) /* probably not accurate */
475491    MDRV_CPU_PROGRAM_MAP(pc2000_mem)
src/mess/drivers/rx78.c
r9684r9685
4848#include "sound/wave.h"
4949#include "devices/messram.h"
5050
51
52class rx78_state : public driver_device
53{
54public:
55   rx78_state(running_machine &machine, const driver_device_config_base &config)
56      : driver_device(machine, config) { }
57
58   running_device *cassette;
59   UINT8 vram_read_bank;
60   UINT8 vram_write_bank;
61   UINT8 pal_reg[7];
62   UINT8 pri_mask;
63   UINT8 key_mux;
64};
65
66
5167#define MASTER_CLOCK XTAL_28_63636MHz
5268
53static running_device *rx78_cassette;
5469
5570static WRITE8_HANDLER( rx78_f0_w )
5671{
57   cassette_output(rx78_cassette, (data & 1) ? -1.0 : +1.0);
72   rx78_state *state = space->machine->driver_data<rx78_state>();
73   cassette_output(state->cassette, (data & 1) ? -1.0 : +1.0);
5874}
5975
6076static READ8_HANDLER( rx78_f0_r )
6177{
78   rx78_state *state = space->machine->driver_data<rx78_state>();
6279   UINT8 data = 0;
6380
64   if (cassette_input(rx78_cassette) > 0.03)
81   if (cassette_input(state->cassette) > 0.03)
6582      data++;
6683
6784   return data;
6885}
6986
7087
71static UINT8 vram_read_bank,vram_write_bank,pal_reg[7],pri_mask;
7288
7389static VIDEO_START( rx78 )
7490{
r9684r9685
7692
7793static VIDEO_UPDATE( rx78 )
7894{
95   rx78_state *state = screen->machine->driver_data<rx78_state>();
7996   UINT8 *vram = memory_region(screen->machine,"vram");
8097   int x,y,count;
8198
r9684r9685
92109         for (i = 0; i < 8; i++)
93110         {
94111            /* bg color */
95            pen[0] = (pri_mask & 0x08) ? (vram[count + 0x6000] >> (i)) : 0x00;
96            pen[1] = (pri_mask & 0x10) ? (vram[count + 0x8000] >> (i)) : 0x00;
97            pen[2] = (pri_mask & 0x20) ? (vram[count + 0xa000] >> (i)) : 0x00;
112            pen[0] = (state->pri_mask & 0x08) ? (vram[count + 0x6000] >> (i)) : 0x00;
113            pen[1] = (state->pri_mask & 0x10) ? (vram[count + 0x8000] >> (i)) : 0x00;
114            pen[2] = (state->pri_mask & 0x20) ? (vram[count + 0xa000] >> (i)) : 0x00;
98115
99116            color  = ((pen[0] & 1) << 0);
100117            color |= ((pen[1] & 1) << 1);
r9684r9685
104121               *BITMAP_ADDR16(bitmap, y, x+i) = screen->machine->pens[color];
105122
106123            /* fg color */
107            pen[0] = (pri_mask & 0x01) ? (vram[count + 0x0000] >> (i)) : 0x00;
108            pen[1] = (pri_mask & 0x02) ? (vram[count + 0x2000] >> (i)) : 0x00;
109            pen[2] = (pri_mask & 0x04) ? (vram[count + 0x4000] >> (i)) : 0x00;
124            pen[0] = (state->pri_mask & 0x01) ? (vram[count + 0x0000] >> (i)) : 0x00;
125            pen[1] = (state->pri_mask & 0x02) ? (vram[count + 0x2000] >> (i)) : 0x00;
126            pen[2] = (state->pri_mask & 0x04) ? (vram[count + 0x4000] >> (i)) : 0x00;
110127
111128            color  = ((pen[0] & 1) << 0);
112129            color |= ((pen[1] & 1) << 1);
r9684r9685
122139   return 0;
123140}
124141
125static UINT8 key_mux;
126142
127143static READ8_HANDLER( key_r )
128144{
145   rx78_state *state = space->machine->driver_data<rx78_state>();
129146   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3",
130147                                           "KEY4", "KEY5", "KEY6", "KEY7",
131148                                           "KEY8", "JOY1P_0","JOY1P_1","JOY1P_2",
132149                                           "JOY2P_0", "JOY2P_1", "JOY2P_2", "UNUSED" };
133150
134   if(key_mux == 0x30) //status read
151   if(state->key_mux == 0x30) //status read
135152   {
136153      int res,i;
137154
r9684r9685
142159      return res;
143160   }
144161
145   if(key_mux >= 1 && key_mux <= 15)
146      return input_port_read(space->machine, keynames[key_mux - 1]);
162   if(state->key_mux >= 1 && state->key_mux <= 15)
163      return input_port_read(space->machine, keynames[state->key_mux - 1]);
147164
148165   return 0;
149166}
150167
151168static WRITE8_HANDLER( key_w )
152169{
153   key_mux = data;
170   rx78_state *state = space->machine->driver_data<rx78_state>();
171   state->key_mux = data;
154172}
155173
156174static READ8_HANDLER( rx78_vram_r )
157175{
176   rx78_state *state = space->machine->driver_data<rx78_state>();
158177   UINT8 *vram = memory_region(space->machine,"vram");
159178
160   if(vram_read_bank == 0 || vram_read_bank > 6)
179   if(state->vram_read_bank == 0 || state->vram_read_bank > 6)
161180      return 0xff;
162181
163   return vram[offset + ((vram_read_bank - 1) * 0x2000)];
182   return vram[offset + ((state->vram_read_bank - 1) * 0x2000)];
164183}
165184
166185static WRITE8_HANDLER( rx78_vram_w )
167186{
187   rx78_state *state = space->machine->driver_data<rx78_state>();
168188   UINT8 *vram = memory_region(space->machine,"vram");
169189
170   if(vram_write_bank & 0x01) { vram[offset + 0 * 0x2000] = data; }
171   if(vram_write_bank & 0x02) { vram[offset + 1 * 0x2000] = data; }
172   if(vram_write_bank & 0x04) { vram[offset + 2 * 0x2000] = data; }
173   if(vram_write_bank & 0x08) { vram[offset + 3 * 0x2000] = data; }
174   if(vram_write_bank & 0x10) { vram[offset + 4 * 0x2000] = data; }
175   if(vram_write_bank & 0x20) { vram[offset + 5 * 0x2000] = data; }
190   if(state->vram_write_bank & 0x01) { vram[offset + 0 * 0x2000] = data; }
191   if(state->vram_write_bank & 0x02) { vram[offset + 1 * 0x2000] = data; }
192   if(state->vram_write_bank & 0x04) { vram[offset + 2 * 0x2000] = data; }
193   if(state->vram_write_bank & 0x08) { vram[offset + 3 * 0x2000] = data; }
194   if(state->vram_write_bank & 0x10) { vram[offset + 4 * 0x2000] = data; }
195   if(state->vram_write_bank & 0x20) { vram[offset + 5 * 0x2000] = data; }
176196}
177197
178198static WRITE8_HANDLER( vram_read_bank_w )
179199{
180   vram_read_bank = data;
200   rx78_state *state = space->machine->driver_data<rx78_state>();
201   state->vram_read_bank = data;
181202}
182203
183204static WRITE8_HANDLER( vram_write_bank_w )
184205{
185   vram_write_bank = data;
206   rx78_state *state = space->machine->driver_data<rx78_state>();
207   state->vram_write_bank = data;
186208}
187209
188210static WRITE8_HANDLER( vdp_reg_w )
189211{
212   rx78_state *state = space->machine->driver_data<rx78_state>();
190213   UINT8 r,g,b,res,i;
191214
192   pal_reg[offset] = data;
215   state->pal_reg[offset] = data;
193216
194217   for(i=0;i<16;i++)
195218   {
196      res = ((i & 1) ? pal_reg[0 + (i & 8 ? 3 : 0)] : 0) | ((i & 2) ? pal_reg[1 + (i & 8 ? 3 : 0)] : 0) | ((i & 4) ? pal_reg[2 + (i & 8 ? 3 : 0)] : 0);
197      if(res & pal_reg[6]) //color mask, TODO: check this
198         res &= pal_reg[6];
219      res = ((i & 1) ? state->pal_reg[0 + (i & 8 ? 3 : 0)] : 0) | ((i & 2) ? state->pal_reg[1 + (i & 8 ? 3 : 0)] : 0) | ((i & 4) ? state->pal_reg[2 + (i & 8 ? 3 : 0)] : 0);
220      if(res & state->pal_reg[6]) //color mask, TODO: check this
221         res &= state->pal_reg[6];
199222
200223      r = (res & 0x11) == 0x11 ? 0xff : ((res & 0x11) == 0x01 ? 0x7f : 0x00);
201224      g = (res & 0x22) == 0x22 ? 0xff : ((res & 0x22) == 0x02 ? 0x7f : 0x00);
r9684r9685
218241
219242static WRITE8_HANDLER( vdp_pri_mask_w )
220243{
221   pri_mask = data;
244   rx78_state *state = space->machine->driver_data<rx78_state>();
245   state->pri_mask = data;
222246}
223247
224248
r9684r9685
375399
376400static MACHINE_RESET(rx78)
377401{
378   rx78_cassette = machine->device("cassette");
402   rx78_state *state = machine->driver_data<rx78_state>();
403   state->cassette = machine->device("cassette");
379404}
380405
381406static DEVICE_IMAGE_LOAD( rx78_cart )
r9684r9685
426451   GFXDECODE_ENTRY( "maincpu", 0x1a27, rx78_charlayout, 0, 8 )
427452GFXDECODE_END
428453
429static MACHINE_CONFIG_START( rx78, driver_device )
454static MACHINE_CONFIG_START( rx78, rx78_state )
430455   /* basic machine hardware */
431456   MDRV_CPU_ADD("maincpu",Z80, MASTER_CLOCK/7)   // unknown divider
432457   MDRV_CPU_PROGRAM_MAP(rx78_mem)
src/mess/drivers/sun1.c
r9684r9685
1515#include "machine/upd7201.h"
1616#include "machine/terminal.h"
1717
18static UINT16* sun1_ram;
1918
19class sun1_state : public driver_device
20{
21public:
22   sun1_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
24
25   UINT16* ram;
26};
27
28
29
2030// Just hack to show output since upd7201 is not implemented yet
2131
2232static READ16_HANDLER(sun1_upd7201_r)
r9684r9685
3242
3343static ADDRESS_MAP_START(sun1_mem, ADDRESS_SPACE_PROGRAM, 16)
3444   ADDRESS_MAP_UNMAP_HIGH
35   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE(&sun1_ram) // 512 KB RAM / ROM at boot
45   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE_MEMBER(sun1_state, ram) // 512 KB RAM / ROM at boot
3646   AM_RANGE(0x00200000, 0x00203fff) AM_ROM AM_REGION("user1",0)
3747   AM_RANGE(0x00600000, 0x00600007) AM_READWRITE( sun1_upd7201_r, sun1_upd7201_w )
3848ADDRESS_MAP_END
r9684r9685
4555
4656static MACHINE_RESET(sun1)
4757{
58   sun1_state *state = machine->driver_data<sun1_state>();
4859   UINT8* user1 = memory_region(machine, "user1");
4960
50   memcpy((UINT8*)sun1_ram,user1,0x4000);
61   memcpy((UINT8*)state->ram,user1,0x4000);
5162
5263   machine->device("maincpu")->reset();
5364}
r9684r9685
6374};
6475
6576
66static MACHINE_CONFIG_START( sun1, driver_device )
77static MACHINE_CONFIG_START( sun1, sun1_state )
6778    /* basic machine hardware */
6879    MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz)
6980    MDRV_CPU_PROGRAM_MAP(sun1_mem)
src/mess/drivers/pyl601.c
r9684r9685
1414#include "machine/upd765.h"
1515#include "devices/messram.h"
1616
17static UINT8 rom_page;
18static UINT32 vdisk_addr = 0;
19static UINT8 key_code;
20static UINT8 keyboard_clk = 0x00;
21static UINT8 video_mode = 0x00;
22static UINT8 tick50_mark = 0x00;
2317
18class pyl601_state : public driver_device
19{
20public:
21   pyl601_state(running_machine &machine, const driver_device_config_base &config)
22      : driver_device(machine, config) { }
23
24   UINT8 rom_page;
25   UINT32 vdisk_addr;
26   UINT8 key_code;
27   UINT8 keyboard_clk;
28   UINT8 video_mode;
29   UINT8 tick50_mark;
30   UINT8 floppy_ctrl;
31};
32
33
34
2435static READ8_HANDLER (rom_page_r)
2536{
26   return rom_page;
37   pyl601_state *state = space->machine->driver_data<pyl601_state>();
38   return state->rom_page;
2739}
2840
2941static WRITE8_HANDLER (rom_page_w)
3042{
31   rom_page =data;
43   pyl601_state *state = space->machine->driver_data<pyl601_state>();
44   state->rom_page =data;
3245   if (data & 8)
3346   {
3447      int chip = (data >> 4) % 5;
r9684r9685
4457
4558static WRITE8_HANDLER (vdisk_page_w)
4659{
47   vdisk_addr = (vdisk_addr & 0x0ffff) | ((data & 0x0f)<<16);
60   pyl601_state *state = space->machine->driver_data<pyl601_state>();
61   state->vdisk_addr = (state->vdisk_addr & 0x0ffff) | ((data & 0x0f)<<16);
4862}
4963
5064static WRITE8_HANDLER (vdisk_h_w)
5165{
52   vdisk_addr = (vdisk_addr & 0xf00ff) | (data<<8);
66   pyl601_state *state = space->machine->driver_data<pyl601_state>();
67   state->vdisk_addr = (state->vdisk_addr & 0xf00ff) | (data<<8);
5368}
5469
5570static WRITE8_HANDLER (vdisk_l_w)
5671{
57   vdisk_addr = (vdisk_addr & 0xfff00) | data;
72   pyl601_state *state = space->machine->driver_data<pyl601_state>();
73   state->vdisk_addr = (state->vdisk_addr & 0xfff00) | data;
5874}
5975
6076static WRITE8_HANDLER (vdisk_data_w)
6177{
62   messram_get_ptr(space->machine->device("messram"))[0x10000 + (vdisk_addr & 0x7ffff)] = data;
63   vdisk_addr++;
64   vdisk_addr&=0x7ffff;
78   pyl601_state *state = space->machine->driver_data<pyl601_state>();
79   messram_get_ptr(space->machine->device("messram"))[0x10000 + (state->vdisk_addr & 0x7ffff)] = data;
80   state->vdisk_addr++;
81   state->vdisk_addr&=0x7ffff;
6582}
6683
6784static READ8_HANDLER (vdisk_data_r)
6885{
69   UINT8 retVal = messram_get_ptr(space->machine->device("messram"))[0x10000 + (vdisk_addr & 0x7ffff)];
70   vdisk_addr++;
71   vdisk_addr &= 0x7ffff;
86   pyl601_state *state = space->machine->driver_data<pyl601_state>();
87   UINT8 retVal = messram_get_ptr(space->machine->device("messram"))[0x10000 + (state->vdisk_addr & 0x7ffff)];
88   state->vdisk_addr++;
89   state->vdisk_addr &= 0x7ffff;
7290   return retVal;
7391}
7492
r9684r9685
87105
88106static READ8_HANDLER ( keyboard_r )
89107{
90   return key_code;
108   pyl601_state *state = space->machine->driver_data<pyl601_state>();
109   return state->key_code;
91110}
92111
93112static READ8_HANDLER ( keycheck_r )
94113{
114   pyl601_state *state = space->machine->driver_data<pyl601_state>();
95115   UINT8 retVal = 0x3f;
96116   UINT8 *keyboard = memory_region(space->machine, "keyboard");
97117   UINT16 row1 = input_port_read(space->machine, "ROW1");
r9684r9685
111131      addr |=  ((row2 == 0x00) ? 1 : 0) << 9;
112132      addr |=  ((row1 == 0x00) ? 1 : 0) << 10;
113133
114      key_code = keyboard[addr];
115      keyboard_clk = ~keyboard_clk;
134      state->key_code = keyboard[addr];
135      state->keyboard_clk = ~state->keyboard_clk;
116136
117      if (keyboard_clk)
137      if (state->keyboard_clk)
118138         retVal |= 0x80;
119139   }
120140   return retVal;
r9684r9685
123143
124144static WRITE8_HANDLER (video_mode_w)
125145{
126   video_mode = data;
146   pyl601_state *state = space->machine->driver_data<pyl601_state>();
147   state->video_mode = data;
127148}
128149static READ8_HANDLER (video_mode_r)
129150{
130   return video_mode;
151   pyl601_state *state = space->machine->driver_data<pyl601_state>();
152   return state->video_mode;
131153}
132154
133155static READ8_HANDLER (timer_r)
134156{
135   UINT8 retVal= tick50_mark | 0x37;
136   tick50_mark = 0;
157   pyl601_state *state = space->machine->driver_data<pyl601_state>();
158   UINT8 retVal= state->tick50_mark | 0x37;
159   state->tick50_mark = 0;
137160   return retVal;
138161}
139162
r9684r9685
155178{
156179   return get_floppy_image(device->machine, (floppy_index & 1)^1);
157180}
158static UINT8 floppy_ctrl = 0;
159181static WRITE8_HANDLER( floppy_w )
160182{
183   pyl601_state *state = space->machine->driver_data<pyl601_state>();
161184   // bit 0 is reset (if zero)
162185   // bit 1 is TC state
163186   // bit 2 is drive selected
r9684r9685
173196
174197   upd765_tc_w(floppy, BIT(data,1));
175198
176   floppy_ctrl = data;
199   state->floppy_ctrl = data;
177200}
178201static READ8_HANDLER (floppy_r)
179202{
180   return floppy_ctrl;
203   pyl601_state *state = space->machine->driver_data<pyl601_state>();
204   return state->floppy_ctrl;
181205}
182206
183207static const struct upd765_interface pyldin_upd765_interface =
r9684r9685
318342
319343static MACHINE_RESET(pyl601)
320344{
321   key_code = 0xff;
345   pyl601_state *state = machine->driver_data<pyl601_state>();
346   state->key_code = 0xff;
322347   memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x0000);
323348   memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0xc000);
324349   memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xe000);
r9684r9685
342367
343368static MC6845_UPDATE_ROW( pyl601_update_row )
344369{
370   pyl601_state *state = device->machine->driver_data<pyl601_state>();
345371   UINT8 *charrom = memory_region(device->machine, "gfx1");
346372
347373   int column, bit, i;
348374   UINT8 data;
349   if (BIT(video_mode, 5) == 0)
375   if (BIT(state->video_mode, 5) == 0)
350376   {
351377      for (column = 0; column < x_count; column++)
352378      {
r9684r9685
387413
388414static MC6845_UPDATE_ROW( pyl601a_update_row )
389415{
416   pyl601_state *state = device->machine->driver_data<pyl601_state>();
390417   UINT8 *charrom = memory_region(device->machine, "gfx1");
391418
392419   int column, bit, i;
393420   UINT8 data;
394   if (BIT(video_mode, 5) == 0)
421   if (BIT(state->video_mode, 5) == 0)
395422   {
396423      for (column = 0; column < x_count; column++)
397424      {
r9684r9685
463490
464491static INTERRUPT_GEN( pyl601_interrupt )
465492{
466   tick50_mark = 0x80;
493   pyl601_state *state = device->machine->driver_data<pyl601_state>();
494   state->tick50_mark = 0x80;
467495   cpu_set_input_line(device, 0, HOLD_LINE);
468496}
469497
r9684r9685
523551   GFXDECODE_ENTRY( "gfx1", 0x0000, pyl601a_charlayout, 0, 1 )
524552GFXDECODE_END
525553
526static MACHINE_CONFIG_START( pyl601, driver_device )
554static MACHINE_CONFIG_START( pyl601, pyl601_state )
527555   /* basic machine hardware */
528556   MDRV_CPU_ADD("maincpu",M6800, XTAL_1MHz)
529557   MDRV_CPU_PROGRAM_MAP(pyl601_mem)
src/mess/drivers/scv.c
r9684r9685
3838};
3939
4040
41static UINT8 *scv_vram;
4241
4342
4443static ADDRESS_MAP_START( scv_mem, ADDRESS_SPACE_PROGRAM, 8 )
4544   AM_RANGE( 0x0000, 0x0fff ) AM_ROM      /* BIOS */
4645
47   AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_BASE( &scv_vram )   /* VRAM + 4 registers */
46   AM_RANGE( 0x2000, 0x3403 ) AM_RAM AM_BASE_MEMBER(scv_state, vram )   /* VRAM + 4 registers */
4847
4948   AM_RANGE( 0x3600, 0x3600 ) AM_DEVWRITE( "upd1771c", upd1771_w )
5049
r9684r9685
449448}
450449
451450
452INLINE void draw_sprite( bitmap_t *bitmap, UINT8 x, UINT8 y, UINT8 tile_idx, UINT8 col, UINT8 left, UINT8 right, UINT8 top, UINT8 bottom, UINT8 clip_y )
451INLINE void draw_sprite( scv_state *state, bitmap_t *bitmap, UINT8 x, UINT8 y, UINT8 tile_idx, UINT8 col, UINT8 left, UINT8 right, UINT8 top, UINT8 bottom, UINT8 clip_y )
453452{
454453   int j;
455454
456455   y += clip_y * 2;
457456   for ( j = clip_y * 4; j < 32; j += 4 )
458457   {
459      UINT8 pat0 = scv_vram[ tile_idx * 32 + j + 0 ];
460      UINT8 pat1 = scv_vram[ tile_idx * 32 + j + 1 ];
461      UINT8 pat2 = scv_vram[ tile_idx * 32 + j + 2 ];
462      UINT8 pat3 = scv_vram[ tile_idx * 32 + j + 3 ];
458      UINT8 pat0 = state->vram[ tile_idx * 32 + j + 0 ];
459      UINT8 pat1 = state->vram[ tile_idx * 32 + j + 1 ];
460      UINT8 pat2 = state->vram[ tile_idx * 32 + j + 2 ];
461      UINT8 pat3 = state->vram[ tile_idx * 32 + j + 3 ];
463462
464463      if ( ( top && j < 16 ) || ( bottom && j >= 16 ) )
465464      {
r9684r9685
561560
562561static VIDEO_UPDATE( scv )
563562{
563   scv_state *state = screen->machine->driver_data<scv_state>();
564564   int x, y;
565   UINT8 fg = scv_vram[0x1403] >> 4;
566   UINT8 bg = scv_vram[0x1403] & 0x0f;
567   UINT8 gr_fg = scv_vram[0x1401] >> 4;
568   UINT8 gr_bg = scv_vram[0x1401] & 0x0f;
569   int clip_x = ( scv_vram[0x1402] & 0x0f ) * 2;
570   int clip_y = scv_vram[0x1402] >> 4;
565   UINT8 fg = state->vram[0x1403] >> 4;
566   UINT8 bg = state->vram[0x1403] & 0x0f;
567   UINT8 gr_fg = state->vram[0x1401] >> 4;
568   UINT8 gr_bg = state->vram[0x1401] & 0x0f;
569   int clip_x = ( state->vram[0x1402] & 0x0f ) * 2;
570   int clip_y = state->vram[0x1402] >> 4;
571571
572572   /* Clear the screen */
573573   bitmap_fill( bitmap, cliprect, gr_bg );
r9684r9685
578578      int text_y = 0;
579579
580580      if ( y < clip_y )
581         text_y = ( scv_vram[0x1400] & 0x80 ) ? 0 : 1;
581         text_y = ( state->vram[0x1400] & 0x80 ) ? 0 : 1;
582582      else
583         text_y = ( scv_vram[0x1400] & 0x80 ) ? 1 : 0;
583         text_y = ( state->vram[0x1400] & 0x80 ) ? 1 : 0;
584584
585585      for ( x = 0; x < 32; x++ )
586586      {
587587         int text_x = 0;
588         UINT8 d = scv_vram[ 0x1000 + y * 32 + x ];
588         UINT8 d = state->vram[ 0x1000 + y * 32 + x ];
589589
590590         if ( x < clip_x )
591            text_x = ( scv_vram[0x1400] & 0x40 ) ? 0 : 1;
591            text_x = ( state->vram[0x1400] & 0x40 ) ? 0 : 1;
592592         else
593            text_x = ( scv_vram[0x1400] & 0x40 ) ? 1 : 0;
593            text_x = ( state->vram[0x1400] & 0x40 ) ? 1 : 0;
594594
595595         if ( text_x && text_y )
596596         {
r9684r9685
600600         }
601601         else
602602         {
603            switch ( scv_vram[0x1400] & 0x03 )
603            switch ( state->vram[0x1400] & 0x03 )
604604            {
605605            case 0x01:      /* Semi graphics mode */
606606               draw_semi_graph( bitmap, x * 8    , y * 16     , d & 0x80, gr_fg );
r9684r9685
624624   }
625625
626626   /* Draw sprites if enabled */
627   if ( scv_vram[0x1400] & 0x10 )
627   if ( state->vram[0x1400] & 0x10 )
628628   {
629629      int i;
630630
631631      for ( i = 0; i < 128; i++ )
632632      {
633         UINT8 spr_y = scv_vram[ 0x1200 + i * 4 ] & 0xfe;
634         UINT8 y_32 = scv_vram[ 0x1200 + i * 4 ] & 0x01;      /* Xx32 sprite */
635         UINT8 clip = scv_vram[ 0x1201 + i * 4 ] >> 4;
636         UINT8 col = scv_vram[ 0x1201 + i * 4 ] & 0x0f;
637         UINT8 spr_x = scv_vram[ 0x1202 + i * 4 ] & 0xfe;
638         UINT8 x_32 = scv_vram[ 0x1202 + i * 4 ] & 0x01;      /* 32xX sprite */
639         UINT8 tile_idx = scv_vram[ 0x1203 + i * 4 ] & 0x7f;
640         UINT8 half = scv_vram[ 0x1203 + i * 4] & 0x80;
633         UINT8 spr_y = state->vram[ 0x1200 + i * 4 ] & 0xfe;
634         UINT8 y_32 = state->vram[ 0x1200 + i * 4 ] & 0x01;      /* Xx32 sprite */
635         UINT8 clip = state->vram[ 0x1201 + i * 4 ] >> 4;
636         UINT8 col = state->vram[ 0x1201 + i * 4 ] & 0x0f;
637         UINT8 spr_x = state->vram[ 0x1202 + i * 4 ] & 0xfe;
638         UINT8 x_32 = state->vram[ 0x1202 + i * 4 ] & 0x01;      /* 32xX sprite */
639         UINT8 tile_idx = state->vram[ 0x1203 + i * 4 ] & 0x7f;
640         UINT8 half = state->vram[ 0x1203 + i * 4] & 0x80;
641641         UINT8 left = 1;
642642         UINT8 right = 1;
643643         UINT8 top = 1;
r9684r9685
681681         }
682682
683683         /* Check if 2 color sprites are enabled */
684         if ( ( scv_vram[0x1400] & 0x20 ) && ( i & 0x20 ) )
684         if ( ( state->vram[0x1400] & 0x20 ) && ( i & 0x20 ) )
685685         {
686686            /* 2 color sprite handling */
687            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
687            draw_sprite( state, bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
688688            if ( x_32 || y_32 )
689689            {
690690               static const UINT8 spr_2col_lut0[16] = { 0, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1, 1 };
691691               static const UINT8 spr_2col_lut1[16] = { 0, 1, 8, 11, 2, 3, 10, 9, 4, 5, 12, 13, 6, 7, 14, 15 };
692692
693               draw_sprite( bitmap, spr_x, spr_y, tile_idx + 8 * x_32 + y_32, ( i & 0x40 ) ? spr_2col_lut1[col] : spr_2col_lut0[col], left, right, top, bottom, clip );
693               draw_sprite( state, bitmap, spr_x, spr_y, tile_idx + 8 * x_32 + y_32, ( i & 0x40 ) ? spr_2col_lut1[col] : spr_2col_lut0[col], left, right, top, bottom, clip );
694694            }
695695         }
696696         else
697697         {
698698            /* regular sprite handling */
699            draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
699            draw_sprite( state, bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip );
700700            if ( x_32 )
701701            {
702               draw_sprite( bitmap, spr_x + 16, spr_y, tile_idx + 8, col, 1, 1, top, bottom, clip );
702               draw_sprite( state, bitmap, spr_x + 16, spr_y, tile_idx + 8, col, 1, 1, top, bottom, clip );
703703            }
704704            if ( y_32 )
705705            {
706706               clip &= 0x07;
707               draw_sprite( bitmap, spr_x, spr_y + 16, tile_idx + 1, col, left, right, 1, 1, clip );
707               draw_sprite( state, bitmap, spr_x, spr_y + 16, tile_idx + 1, col, left, right, 1, 1, clip );
708708               if ( x_32 )
709709               {
710                  draw_sprite( bitmap, spr_x + 16, spr_y + 16, tile_idx + 9, col, 1, 1, 1, 1, clip );
710                  draw_sprite( state, bitmap, spr_x + 16, spr_y + 16, tile_idx + 9, col, 1, 1, 1, 1, clip );
711711               }
712712            }
713713         }
src/mess/drivers/zrt80.c
r9684r9685
1111#include "video/mc6845.h"
1212#include "machine/ins8250.h"
1313
14static UINT8 *video_ram;
1514
15class zrt80_state : public driver_device
16{
17public:
18   zrt80_state(running_machine &machine, const driver_device_config_base &config)
19      : driver_device(machine, config) { }
20
21   UINT8 *video_ram;
22};
23
24
25
1626static ADDRESS_MAP_START(zrt80_mem, ADDRESS_SPACE_PROGRAM, 8)
1727   ADDRESS_MAP_UNMAP_HIGH
1828   AM_RANGE(0x0000, 0x0fff) AM_ROM // Z25 - Main firmware
1929   AM_RANGE(0x1000, 0x1fff) AM_ROM // Z24 - Expansion
2030   AM_RANGE(0x4000, 0x43ff) AM_RAM   // Board RAM
2131   // Normaly video RAM is 0x800 but could be expanded up to 8K
22   AM_RANGE(0xc000, 0xdfff) AM_RAM    AM_BASE(&video_ram) // Video RAM
32   AM_RANGE(0xc000, 0xdfff) AM_RAM    AM_BASE_MEMBER(zrt80_state, video_ram) // Video RAM
2333
2434ADDRESS_MAP_END
2535
r9684r9685
133143
134144static MC6845_UPDATE_ROW( zrt80_update_row )
135145{
146   zrt80_state *state = device->machine->driver_data<zrt80_state>();
136147   UINT8 *charrom = memory_region(device->machine, "chargen");
137148
138149   int column, bit;
139150
140151   for (column = 0; column < x_count; column++)
141152   {
142      UINT8 code = video_ram[ma + column] & 0x7f;
153      UINT8 code = state->video_ram[ma + column] & 0x7f;
143154      UINT16 addr = code << 4 | (ra & 0x0f);
144155      UINT8 data = charrom[addr & 0x7ff];
145156
r9684r9685
204215   GFXDECODE_ENTRY( "chargen", 0x0000, zrt80_charlayout, 0, 1 )
205216GFXDECODE_END
206217
207static MACHINE_CONFIG_START( zrt80, driver_device )
218static MACHINE_CONFIG_START( zrt80, zrt80_state )
208219   /* basic machine hardware */
209220   MDRV_CPU_ADD("maincpu",Z80, XTAL_2_4576MHz)
210221   MDRV_CPU_PROGRAM_MAP(zrt80_mem)
src/mess/drivers/pcm.c
r9684r9685
99#include "emu.h"
1010#include "cpu/z80/z80.h"
1111
12static UINT8 *pcm_video_ram;
1312
13class pcm_state : public driver_device
14{
15public:
16   pcm_state(running_machine &machine, const driver_device_config_base &config)
17      : driver_device(machine, config) { }
18
19   UINT8 *video_ram;
20};
21
22
23
1424static ADDRESS_MAP_START(pcm_mem, ADDRESS_SPACE_PROGRAM, 8)
1525   ADDRESS_MAP_UNMAP_HIGH
1626    AM_RANGE( 0x0000, 0x1fff ) AM_ROM  // ROM
1727    AM_RANGE( 0x2000, 0xf7ff ) AM_RAM  // RAM
18    AM_RANGE( 0xf800, 0xffff ) AM_RAM AM_BASE(&pcm_video_ram) // Video RAM
28    AM_RANGE( 0xf800, 0xffff ) AM_RAM AM_BASE_MEMBER(pcm_state, video_ram) // Video RAM
1929ADDRESS_MAP_END
2030
2131static ADDRESS_MAP_START( pcm_io , ADDRESS_SPACE_IO, 8)
r9684r9685
3545
3646static VIDEO_UPDATE( pcm )
3747{
48   pcm_state *state = screen->machine->driver_data<pcm_state>();
3849   UINT8 code;
3950   UINT8 line;
4051   int y, x, j, b;
r9684r9685
4556   {
4657      for (x = 0; x < 64; x++)
4758      {
48         code = pcm_video_ram[(0x400 + y*64 + x) & 0x7ff];
59         code = state->video_ram[(0x400 + y*64 + x) & 0x7ff];
4960         for(j = 0; j < 8; j++ )
5061         {
5162            line = gfx[code*8 + j];
r9684r9685
6071}
6172
6273
63static MACHINE_CONFIG_START( pcm, driver_device )
74static MACHINE_CONFIG_START( pcm, pcm_state )
6475    /* basic machine hardware */
6576    MDRV_CPU_ADD("maincpu",Z80, XTAL_10MHz /4)
6677    MDRV_CPU_PROGRAM_MAP(pcm_mem)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team