Previous 15994 Revisions Next

r3797 Tuesday 9th December, 2008 at 07:57:58 UTC by Curt Coder
[SG1000] Moved variables to driver state.
[src/mess/drivers]sg1000.c
[src/mess/includes]sg1000.h*

src/mess/includes/sg1000.h
r0r3797
1#ifndef __SG1000__
2#define __SG1000__
3 
4#define SCREEN_TAG   "main"
5 
6#define IS_CARTRIDGE_TV_DRAW(ptr) \
7   (!strncmp("annakmn", (const char *)&ptr[0x13b3], 7))
8 
9#define IS_CARTRIDGE_THE_CASTLE(ptr) \
10   (!strncmp("ASCII 1986", (const char *)&ptr[0x1cc3], 10))
11 
12#define IS_CARTRIDGE_BASIC_LEVEL_III(ptr) \
13   (!strncmp("SC-3000 BASIC Level 3 ver 1.0", (const char *)&ptr[0x6a20], 29))
14 
15#define IS_CARTRIDGE_MUSIC_EDITOR(ptr) \
16   (!strncmp("PIANO", (const char *)&ptr[0x0841], 5))
17 
18typedef struct _sg1000_state sg1000_state;
19struct _sg1000_state
20{
21   /* keyboard state */
22   UINT8 keylatch;
23 
24   /* TV Draw state */
25   UINT8 tvdraw_data;
26 
27   /* floppy state */
28   int fdc_irq;
29   int fdc_index;
30};
31 
32#endif
src/mess/drivers/sg1000.c
r3796r3797
5353
5454    TODO:
5555
56   - move variables to driver state
5756   - OMV keyboard
5857   - SC-3000 return instruction referenced by R when reading ports 60-7f,e0-ff
5958   - connect the PSG /READY signal
r3796r3797
6564*/
6665
6766#include "driver.h"
67#include "includes/sg1000.h"
68#include "deprecat.h"
6869#include "devices/basicdsk.h"
6970#include "devices/cartslot.h"
7071#include "devices/cassette.h"
r3796r3797
7778#include "sound/sn76496.h"
7879#include "video/tms9928a.h"
7980
80#define IS_CARTRIDGE_TV_DRAW(ptr) \
81   (!strncmp("annakmn", (const char *)&ptr[0x13b3], 7))
82
83#define IS_CARTRIDGE_THE_CASTLE(ptr) \
84   (!strncmp("ASCII 1986", (const char *)&ptr[0x1cc3], 10))
85
86#define IS_CARTRIDGE_BASIC_LEVEL_III(ptr) \
87   (!strncmp("SC-3000 BASIC Level 3 ver 1.0", (const char *)&ptr[0x6a20], 29))
88
89#define IS_CARTRIDGE_MUSIC_EDITOR(ptr) \
90   (!strncmp("PIANO", (const char *)&ptr[0x0841], 5))
91
9281static const device_config *cassette_device_image(running_machine *machine)
9382{
9483   return devtag_get_device(machine, CASSETTE, "cassette");
r3796r3797
111100
112101*/
113102
114static UINT8 tvdraw_data;
115
116103static WRITE8_HANDLER( tvdraw_axis_w )
117104{
105   sg1000_state *state = space->machine->driver_data;
106
118107   if (data & 0x01)
119108   {
120      tvdraw_data = input_port_read(space->machine, "TVDRAW_X");
109      state->tvdraw_data = input_port_read(space->machine, "TVDRAW_X");
121110
122      if (tvdraw_data < 4) tvdraw_data = 4;
123      if (tvdraw_data > 251) tvdraw_data = 251;
111      if (state->tvdraw_data < 4) state->tvdraw_data = 4;
112      if (state->tvdraw_data > 251) state->tvdraw_data = 251;
124113   }
125114   else
126115   {
127      tvdraw_data = input_port_read(space->machine, "TVDRAW_Y") + 32;
116      state->tvdraw_data = input_port_read(space->machine, "TVDRAW_Y") + 32;
128117   }
129118}
130119
r3796r3797
135124
136125static READ8_HANDLER( tvdraw_data_r )
137126{
138   return tvdraw_data;
127   sg1000_state *state = space->machine->driver_data;
128
129   return state->tvdraw_data;
139130}
140131
141132static READ8_HANDLER( sg1000_joysel_r )
r3796r3797
215206
216207static INPUT_CHANGED( trigger_nmi )
217208{
218   cpu_set_input_line(field->port->machine->cpu[0], INPUT_LINE_NMI, (input_port_read(field->port->machine, "NMI") ? CLEAR_LINE : ASSERT_LINE));
209   cputag_set_input_line(field->port->machine, "main", INPUT_LINE_NMI, (input_port_read(field->port->machine, "NMI") ? CLEAR_LINE : ASSERT_LINE));
219210}
220211
221212static INPUT_PORTS_START( tvdraw )
r3796r3797
451442
452443static void sg1000_vdp_interrupt(running_machine *machine, int state)
453444{
454   cpu_set_input_line(machine->cpu[0], INPUT_LINE_IRQ0, state);
445   cputag_set_input_line(machine, "main", INPUT_LINE_IRQ0, state);
455446}
456447
457448static const TMS9928a_interface tms9928a_interface =
r3796r3797
480471
481472static MACHINE_START( sg1000 )
482473{
474   sg1000_state *state = machine->driver_data;
475
483476   /* configure VDP */
484477   TMS9928A_configure(&tms9928a_interface);
485478
r3796r3797
487480   timer_set(machine, attotime_zero, NULL, 0, lightgun_tick);
488481
489482   /* register for state saving */
490   state_save_register_global(machine, tvdraw_data);
483   state_save_register_global(machine, state->tvdraw_data);
491484}
492485
493486// SC-3000
494487
495static int keylatch;
496
497488static READ8_DEVICE_HANDLER( sc3000_ppi8255_a_r )
498489{
499   static const char *const keynames[] = { "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7" };
500
501490   /*
502491        Signal  Description
503492
r3796r3797
511500        PA7     Keyboard input
512501    */
513502
514   return input_port_read(device->machine, keynames[keylatch]);
503   sg1000_state *state = device->machine->driver_data;
504
505   static const char *const keynames[] = { "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7" };
506
507   return input_port_read(device->machine, keynames[state->keylatch]);
515508}
516509
517510static READ8_DEVICE_HANDLER( sc3000_ppi8255_b_r )
518511{
519   static const char *const keynames[] = { "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7" };
520
521512   /*
522513        Signal  Description
523514
r3796r3797
531522        PB7     Cassette tape input
532523    */
533524
525   sg1000_state *state = device->machine->driver_data;
526
527   static const char *const keynames[] = { "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7" };
528
534529   /* keyboard */
535   UINT8 data = input_port_read(device->machine, keynames[keylatch]);
530   UINT8 data = input_port_read(device->machine, keynames[state->keylatch]);
536531
537532   /* cartridge contact */
538533   data |= 0x10;
r3796r3797
561556        PC7     /FEED to printer
562557    */
563558
559   sg1000_state *state = device->machine->driver_data;
560
564561   /* keyboard */
565   keylatch = data & 0x07;
562   state->keylatch = data & 0x07;
566563
567564   /* cassette */
568565   cassette_output(cassette_device_image(device->machine), BIT(data, 4) ? +1.0 : -1.0);
r3796r3797
582579
583580static MACHINE_START( sc3000 )
584581{
582   sg1000_state *state = machine->driver_data;
583
585584   /* configure VDP */
586585   TMS9928A_configure(&tms9928a_interface);
587586
r3796r3797
589588   timer_set(machine, attotime_zero, NULL, 0, lightgun_tick);
590589
591590   /* register for state saving */
592   state_save_register_global(machine, tvdraw_data);
593   state_save_register_global(machine, keylatch);
591   state_save_register_global(machine, state->tvdraw_data);
592   state_save_register_global(machine, state->keylatch);
594593}
595594
596595// SF-7000
597596
598static int sf7000_fdc_int;
599static int sf7000_fdc_index;
600
601597static READ8_DEVICE_HANDLER( sf7000_ppi8255_a_r )
602598{
603599   /*
r3796r3797
613609        PA7
614610    */
615611
612   sg1000_state *state = device->machine->driver_data;
613
616614   int centronics_handshake = centronics_read_handshake(1);
617615   int busy = 0;
618616
r3796r3797
621619      busy = 0x02;
622620   }
623621
624   return (sf7000_fdc_index << 2) | busy | sf7000_fdc_int;
622   return (state->fdc_index << 2) | busy | state->fdc_irq;
625623}
626624
627625static WRITE8_DEVICE_HANDLER( sf7000_ppi8255_b_w )
r3796r3797
700698/* callback for /INT output from FDC */
701699static void sf7000_fdc_interrupt(int state)
702700{
703   sf7000_fdc_int = state;
701   sg1000_state *driver_state = Machine->driver_data; // TODO
702
703   driver_state->fdc_irq = state;
704704}
705705
706706static void sf7000_fdc_index_callback(const device_config *img, int state)
707707{
708   sf7000_fdc_index = state;
708   sg1000_state *driver_state = img->machine->driver_data;
709
710   driver_state->fdc_index = state;
709711}
710712
711713static const struct nec765_interface sf7000_nec765_interface =
r3796r3797
723725
724726static MACHINE_START( sf7000 )
725727{
728   sg1000_state *state = machine->driver_data;
729
726730   /* configure VDP */
727731   TMS9928A_configure(&tms9928a_interface);
728732
r3796r3797
739743   memory_configure_bank(machine, 2, 0, 1, mess_ram, 0);
740744
741745   /* register for state saving */
742   state_save_register_global(machine, keylatch);
743   state_save_register_global(machine, sf7000_fdc_int);
744   state_save_register_global(machine, sf7000_fdc_index);
746   state_save_register_global(machine, state->keylatch);
747   state_save_register_global(machine, state->fdc_irq);
748   state_save_register_global(machine, state->fdc_index);
745749}
746750
747751static MACHINE_RESET( sf7000 )
r3796r3797
753757/* Machine Drivers */
754758
755759static MACHINE_DRIVER_START( sg1000 )
760   MDRV_DRIVER_DATA(sg1000_state)
761
756762   /* basic machine hardware */
757763   MDRV_CPU_ADD("main", Z80, XTAL_10_738635MHz/3)
758764   MDRV_CPU_PROGRAM_MAP(sg1000_map, 0)
r3796r3797
785791};
786792
787793static MACHINE_DRIVER_START( sc3000 )
794   MDRV_DRIVER_DATA(sg1000_state)
795
788796   /* basic machine hardware */
789797   MDRV_CPU_ADD("main", Z80, XTAL_10_738635MHz/3) // LH0080A
790798   MDRV_CPU_PROGRAM_MAP(sc3000_map, 0)
r3796r3797
815823MACHINE_DRIVER_END
816824
817825static MACHINE_DRIVER_START( sf7000 )
826   MDRV_DRIVER_DATA(sg1000_state)
827
818828   /* basic machine hardware */
819829   MDRV_CPU_ADD("main", Z80, XTAL_10_738635MHz/3)
820830   MDRV_CPU_PROGRAM_MAP(sf7000_map, 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team