Previous 15994 Revisions Next

r1302 Monday 19th November, 2007 at 21:52:10 UTC by Justin Kerk
1. Fix SVN properties
2. Fix version number in messnew.txt
[docs]messnew.txt
[src/emu/cpu/mips]mdrc64.c
[src/emu/machine]53c810.c 53c810.h 6522via.c 6522via.h 6526cia.c 6526cia.h 6532riot.c 6532riot.h 6821pia.c 6821pia.h 6840ptm.c 6840ptm.h 6850acia.c 6850acia.h 74123.c 74123.h 74148.c 74148.h 74153.c 74153.h 74181.c 74181.h 7474.c 7474.h 8042kbdc.c 8042kbdc.h 8237dma.c 8237dma.h 8255ppi.c 8255ppi.h adc083x.c adc083x.h adc1213x.c adc1213x.h am53cf96.c am53cf96.h at28c16.c at28c16.h ds1302.c ds1302.h ds2401.c ds2401.h ds2404.c ds2404.h idectrl.c idectrl.h intelfsh.c intelfsh.h laserdsc.c laserdsc.h mb3773.c mb3773.h mb87078.c mb87078.h mc146818.c mc146818.h msm6242.c msm6242.h pc16552d.c pc16552d.h pci.c pci.h pd4990a.c pd4990a.h pic8259.c pic8259.h pit8253.c pit8253.h roc10937.c roc10937.h rp5h01.c rp5h01.h rtc65271.c rtc65271.h scsicd.c scsidev.h scsihd.c smc91c9x.c smc91c9x.h timekpr.c timekpr.h tmp68301.c tmp68301.h upd4701.c upd4701.h wd33c93.c wd33c93.h x76f041.c x76f041.h x76f100.c x76f100.h z80ctc.c z80ctc.h z80pio.c z80pio.h z80sio.c z80sio.h
[src/emu/video]cdp1869.c cdp1869.h crtc6845.c crtc6845.h poly.c poly.h s2636.c s2636.h tlc34076.c tlc34076.h tms34061.c tms34061.h tms9928a.c tms9928a.h v9938.c v9938.h v9938mod.c vooddefs.h voodoo.c voodoo.h
[src/mame/machine]pitnrun.c
[src/mess/audio]pc.h
[src/mess/drivers]acrnsys1.c ex800.c glasgow.c
[src/mess/video]zx8301.c zx8301.h
[src/osd/sdl]sdlsync.h
[src/osd/winui]mkhelp.c winui.mak
[src/osd/winui/res]horz.ico vert.ico

src/mame/machine/pitnrun.c
r1301r1302
1/***************************************************************************
2 
3    Pit&Run
4 
5    Based on TaitsoSJ driver
6    68705 has access to Z80 memory space
7 
8***************************************************************************/
9 
10#include "driver.h"
11#include "cpu/m6805/m6805.h"
12 
13 
14static UINT8 fromz80,toz80;
15static int zaccept,zready;
16 
17MACHINE_RESET( pitnrun )
18{
19   zaccept = 1;
20   zready = 0;
21   cpunum_set_input_line(2,0,CLEAR_LINE);
22}
23 
24static TIMER_CALLBACK( pitnrun_mcu_real_data_r )
25{
26   zaccept = 1;
27}
28 
29READ8_HANDLER( pitnrun_mcu_data_r )
30{
31   timer_call_after_resynch(0,pitnrun_mcu_real_data_r);
32   return toz80;
33}
34 
35static TIMER_CALLBACK( pitnrun_mcu_real_data_w )
36{
37   zready = 1;
38   cpunum_set_input_line(2,0,ASSERT_LINE);
39   fromz80 = param;
40}
41 
42WRITE8_HANDLER( pitnrun_mcu_data_w )
43{
44   timer_call_after_resynch(data,pitnrun_mcu_real_data_w);
45}
46 
47READ8_HANDLER( pitnrun_mcu_status_r )
48{
49   /* mcu synchronization */
50   cpu_yielduntil_time (ATTOTIME_IN_USEC(5));
51   /* bit 0 = the 68705 has read data from the Z80 */
52   /* bit 1 = the 68705 has written data for the Z80 */
53   return ~((zready << 1) | (zaccept << 0));
54}
55 
56static UINT8 portA_in,portA_out;
57 
58READ8_HANDLER( pitnrun_68705_portA_r )
59{
60   return portA_in;
61}
62 
63WRITE8_HANDLER( pitnrun_68705_portA_w )
64{
65   portA_out = data;
66}
67 
68 
69 
70/*
71 *  Port B connections:
72 *
73 *  all bits are logical 1 when read (+5V pullup)
74 *
75 *  0   W  !68INTRQ
76 *  1   W  !68LRD (enables latch which holds command from the Z80)
77 *  2   W  !68LWR (loads the latch which holds data for the Z80, and sets a
78 *                 status bit so the Z80 knows there's data waiting)
79 *  3   W  to Z80 !BUSRQ (aka !WAIT) pin
80 *  4   W  !68WRITE (triggers write to main Z80 memory area )
81 *  5   W  !68READ (triggers read from main Z80 memory area )
82 *  6   W  !LAL (loads the latch which holds the low 8 bits of the address of
83 *               the main Z80 memory location to access)
84 *  7   W  !UAL (loads the latch which holds the high 8 bits of the address of
85 *               the main Z80 memory location to access)
86 */
87 
88READ8_HANDLER( pitnrun_68705_portB_r )
89{
90   return 0xff;
91}
92 
93static int address;
94 
95static TIMER_CALLBACK( pitnrun_mcu_data_real_r )
96{
97   zready = 0;
98}
99 
100static TIMER_CALLBACK( pitnrun_mcu_status_real_w )
101{
102   toz80 = param;
103   zaccept = 0;
104}
105 
106WRITE8_HANDLER( pitnrun_68705_portB_w )
107{
108   if (~data & 0x02)
109   {
110      /* 68705 is going to read data from the Z80 */
111      timer_call_after_resynch(0,pitnrun_mcu_data_real_r);
112      cpunum_set_input_line(2,0,CLEAR_LINE);
113      portA_in = fromz80;
114   }
115   if (~data & 0x04)
116   {
117      /* 68705 is writing data for the Z80 */
118      timer_call_after_resynch(portA_out,pitnrun_mcu_status_real_w);
119   }
120   if (~data & 0x10)
121   {
122    memory_set_context(0);
123      program_write_byte(address, portA_out);
124    memory_set_context(2);
125   }
126   if (~data & 0x20)
127   {
128        memory_set_context(0);
129            portA_in = program_read_byte(address);
130        memory_set_context(2);
131   }
132   if (~data & 0x40)
133   {
134      address = (address & 0xff00) | portA_out;
135   }
136   if (~data & 0x80)
137   {
138      address = (address & 0x00ff) | (portA_out << 8);
139   }
140}
141 
142/*
143 *  Port C connections:
144 *
145 *  0   R  ZREADY (1 when the Z80 has written a command in the latch)
146 *  1   R  ZACCEPT (1 when the Z80 has read data from the latch)
147 *  2   R  from Z80 !BUSAK pin
148 *  3   R  68INTAK (goes 0 when the interrupt request done with 68INTRQ
149 *                  passes through)
150 */
151 
152READ8_HANDLER( pitnrun_68705_portC_r )
153{
154   return (zready << 0) | (zaccept << 1);
155}
156 
157 
158 
1/***************************************************************************
2
3    Pit&Run
4
5    Based on TaitsoSJ driver
6    68705 has access to Z80 memory space
7
8***************************************************************************/
9
10#include "driver.h"
11#include "cpu/m6805/m6805.h"
12
13
14static UINT8 fromz80,toz80;
15static int zaccept,zready;
16
17MACHINE_RESET( pitnrun )
18{
19   zaccept = 1;
20   zready = 0;
21   cpunum_set_input_line(2,0,CLEAR_LINE);
22}
23
24static TIMER_CALLBACK( pitnrun_mcu_real_data_r )
25{
26   zaccept = 1;
27}
28
29READ8_HANDLER( pitnrun_mcu_data_r )
30{
31   timer_call_after_resynch(0,pitnrun_mcu_real_data_r);
32   return toz80;
33}
34
35static TIMER_CALLBACK( pitnrun_mcu_real_data_w )
36{
37   zready = 1;
38   cpunum_set_input_line(2,0,ASSERT_LINE);
39   fromz80 = param;
40}
41
42WRITE8_HANDLER( pitnrun_mcu_data_w )
43{
44   timer_call_after_resynch(data,pitnrun_mcu_real_data_w);
45}
46
47READ8_HANDLER( pitnrun_mcu_status_r )
48{
49   /* mcu synchronization */
50   cpu_yielduntil_time (ATTOTIME_IN_USEC(5));
51   /* bit 0 = the 68705 has read data from the Z80 */
52   /* bit 1 = the 68705 has written data for the Z80 */
53   return ~((zready << 1) | (zaccept << 0));
54}
55
56static UINT8 portA_in,portA_out;
57
58READ8_HANDLER( pitnrun_68705_portA_r )
59{
60   return portA_in;
61}
62
63WRITE8_HANDLER( pitnrun_68705_portA_w )
64{
65   portA_out = data;
66}
67
68
69
70/*
71 *  Port B connections:
72 *
73 *  all bits are logical 1 when read (+5V pullup)
74 *
75 *  0   W  !68INTRQ
76 *  1   W  !68LRD (enables latch which holds command from the Z80)
77 *  2   W  !68LWR (loads the latch which holds data for the Z80, and sets a
78 *                 status bit so the Z80 knows there's data waiting)
79 *  3   W  to Z80 !BUSRQ (aka !WAIT) pin
80 *  4   W  !68WRITE (triggers write to main Z80 memory area )
81 *  5   W  !68READ (triggers read from main Z80 memory area )
82 *  6   W  !LAL (loads the latch which holds the low 8 bits of the address of
83 *               the main Z80 memory location to access)
84 *  7   W  !UAL (loads the latch which holds the high 8 bits of the address of
85 *               the main Z80 memory location to access)
86 */
87
88READ8_HANDLER( pitnrun_68705_portB_r )
89{
90   return 0xff;
91}
92
93static int address;
94
95static TIMER_CALLBACK( pitnrun_mcu_data_real_r )
96{
97   zready = 0;
98}
99
100static TIMER_CALLBACK( pitnrun_mcu_status_real_w )
101{
102   toz80 = param;
103   zaccept = 0;
104}
105
106WRITE8_HANDLER( pitnrun_68705_portB_w )
107{
108   if (~data & 0x02)
109   {
110      /* 68705 is going to read data from the Z80 */
111      timer_call_after_resynch(0,pitnrun_mcu_data_real_r);
112      cpunum_set_input_line(2,0,CLEAR_LINE);
113      portA_in = fromz80;
114   }
115   if (~data & 0x04)
116   {
117      /* 68705 is writing data for the Z80 */
118      timer_call_after_resynch(portA_out,pitnrun_mcu_status_real_w);
119   }
120   if (~data & 0x10)
121   {
122    memory_set_context(0);
123      program_write_byte(address, portA_out);
124    memory_set_context(2);
125   }
126   if (~data & 0x20)
127   {
128        memory_set_context(0);
129            portA_in = program_read_byte(address);
130        memory_set_context(2);
131   }
132   if (~data & 0x40)
133   {
134      address = (address & 0xff00) | portA_out;
135   }
136   if (~data & 0x80)
137   {
138      address = (address & 0x00ff) | (portA_out << 8);
139   }
140}
141
142/*
143 *  Port C connections:
144 *
145 *  0   R  ZREADY (1 when the Z80 has written a command in the latch)
146 *  1   R  ZACCEPT (1 when the Z80 has read data from the latch)
147 *  2   R  from Z80 !BUSAK pin
148 *  3   R  68INTAK (goes 0 when the interrupt request done with 68INTRQ
149 *                  passes through)
150 */
151
152READ8_HANDLER( pitnrun_68705_portC_r )
153{
154   return (zready << 0) | (zaccept << 1);
155}
156
157
158
src/osd/winui/mkhelp.c
r1301r1302
1/***************************************************************************
2 
3    mkhelp.c
4 
5    Simple resource HIDC to Help entry tool.
6 
7    MSH - 20070815
8 
9***************************************************************************/
10 
11#include <stdio.h>
12#include "osdcore.h"
13 
14 
15int compare( const void *arg1, const void *arg2 );
16void extract_help_ids(const char *buffer, FILE *fp);
17 
18/*-------------------------------------------------
19    main - primary entry point
20-------------------------------------------------*/
21 
22int main(int argc, char *argv[])
23{
24   const char *resourcefile, *varname, *type;
25   FILE *src, *dst;
26   char *buffer;
27   int bytes;
28 
29   varname = "dwHelpIDs";
30   type = "DWORD";
31 
32   /* needs at least three arguments */
33   if (argc < 1)
34   {
35      fprintf(stderr,
36         "Usage:\n"
37         "  mkhelp <resource.rc>\n"
38         "\n"
39         "The default <type> is DWORD, with an assumed NULL terminator pair\n"
40      );
41      return 0;
42   }
43 
44   /* extract arguments */
45   resourcefile = argv[1];
46 
47   /* open source file */
48   src = fopen(resourcefile, "rb");
49   if (src == NULL)
50   {
51      fprintf(stderr, "Unable to open resource file '%s'\n", resourcefile);
52      return 1;
53   }
54 
55   /* determine file size */
56   fseek(src, 0, SEEK_END);
57   bytes = ftell(src);
58   fseek(src, 0, SEEK_SET);
59 
60   /* allocate memory */
61   buffer = malloc(bytes + 1);
62   if (buffer == NULL)
63   {
64      fprintf(stderr, "Out of memory allocating %d byte buffer\n", bytes);
65      return 1;
66   }
67 
68   /* read the source file */
69   fread(buffer, 1, bytes, src);
70   buffer[bytes] = 0;
71   fclose(src);
72 
73   /* open dest file */
74   dst = stdout;
75 
76   fprintf(dst,"/*\n * Help ID array - Generated by mkhelp\n */\n\n");
77   fprintf(dst, "#include <windows.h>\n#include \"resource.h\"\n#include \"resource.hm\"\n\n");
78   /* write the initial header */
79   fprintf(dst, "const %s %s[] =\n{\n", type, varname);
80 
81   extract_help_ids(buffer, dst);
82 
83   fprintf(dst, "\n};\n");
84 
85   /* close the files */
86   free(buffer);
87//   fclose(dst);
88   return 0;
89}
90 
91int compare( const void *arg1, const void *arg2 )
92{
93   /* Compare all of both strings: */
94   return _stricmp( * ( char** ) arg1, * ( char** ) arg2 );
95}
96 
97void extract_help_ids(const char *buffer, FILE *fp)
98{
99   const char *ptr = buffer;
100   char **help_ids = malloc(500 * sizeof(char *));
101   int num_help_id = 0;
102   int i;
103 
104   memset(help_ids, '\0', sizeof(help_ids));
105 
106   while(*ptr) {
107      if (strncmp("HIDC_", ptr, 5) == 0) {
108         char id_name[128];
109         char *end = id_name;
110         char *id;
111         memset(id_name, '\0', sizeof(id_name));
112         while (*ptr && *ptr != '\x0d' && *ptr != '\x0a' ) {
113            *end++ = *ptr++;
114         }
115         id = malloc(strlen(id_name));
116         memset(id, '\0', strlen(id_name));
117         memcpy(id, &id_name[1], strlen(&id_name[1]));
118         help_ids[num_help_id] = id;
119         num_help_id++;
120      } else {
121         ptr++;
122      }
123   }
124 
125   /* Sort using Quicksort algorithm: */
126   qsort( (void *)help_ids, (size_t)num_help_id, sizeof( char * ), compare );
127 
128   // Now print them out.
129   ptr = help_ids[0];
130   for (i = 0; i < num_help_id; i++) {
131      if (i > 0) {
132         if (strcmp(ptr, help_ids[i]) == 0) {
133                continue;
134         }
135      }
136      fprintf(fp, "\t%-30s,H%s,\n", help_ids[i], help_ids[i]);
137      ptr = help_ids[i];
138   }
139   fprintf(fp, "\t%-30i,%i\n", 0, 0);
140 
141   // free our allocations.
142   for (i = 0; i < num_help_id; i++) {
143      free(help_ids[i]);
144   }
145   free (help_ids);
146}
147 
1/***************************************************************************
2
3    mkhelp.c
4
5    Simple resource HIDC to Help entry tool.
6
7    MSH - 20070815
8
9***************************************************************************/
10
11#include <stdio.h>
12#include "osdcore.h"
13
14
15int compare( const void *arg1, const void *arg2 );
16void extract_help_ids(const char *buffer, FILE *fp);
17
18/*-------------------------------------------------
19    main - primary entry point
20-------------------------------------------------*/
21
22int main(int argc, char *argv[])
23{
24   const char *resourcefile, *varname, *type;
25   FILE *src, *dst;
26   char *buffer;
27   int bytes;
28
29   varname = "dwHelpIDs";
30   type = "DWORD";
31
32   /* needs at least three arguments */
33   if (argc < 1)
34   {
35      fprintf(stderr,
36         "Usage:\n"
37         "  mkhelp <resource.rc>\n"
38         "\n"
39         "The default <type> is DWORD, with an assumed NULL terminator pair\n"
40      );
41      return 0;
42   }
43
44   /* extract arguments */
45   resourcefile = argv[1];
46
47   /* open source file */
48   src = fopen(resourcefile, "rb");
49   if (src == NULL)
50   {
51      fprintf(stderr, "Unable to open resource file '%s'\n", resourcefile);
52      return 1;
53   }
54
55   /* determine file size */
56   fseek(src, 0, SEEK_END);
57   bytes = ftell(src);
58   fseek(src, 0, SEEK_SET);
59
60   /* allocate memory */
61   buffer = malloc(bytes + 1);
62   if (buffer == NULL)
63   {
64      fprintf(stderr, "Out of memory allocating %d byte buffer\n", bytes);
65      return 1;
66   }
67
68   /* read the source file */
69   fread(buffer, 1, bytes, src);
70   buffer[bytes] = 0;
71   fclose(src);
72
73   /* open dest file */
74   dst = stdout;
75
76   fprintf(dst,"/*\n * Help ID array - Generated by mkhelp\n */\n\n");
77   fprintf(dst, "#include <windows.h>\n#include \"resource.h\"\n#include \"resource.hm\"\n\n");
78   /* write the initial header */
79   fprintf(dst, "const %s %s[] =\n{\n", type, varname);
80
81   extract_help_ids(buffer, dst);
82
83   fprintf(dst, "\n};\n");
84
85   /* close the files */
86   free(buffer);
87//   fclose(dst);
88   return 0;
89}
90
91int compare( const void *arg1, const void *arg2 )
92{
93   /* Compare all of both strings: */
94   return _stricmp( * ( char** ) arg1, * ( char** ) arg2 );
95}
96
97void extract_help_ids(const char *buffer, FILE *fp)
98{
99   const char *ptr = buffer;
100   char **help_ids = malloc(500 * sizeof(char *));
101   int num_help_id = 0;
102   int i;
103
104   memset(help_ids, '\0', sizeof(help_ids));
105
106   while(*ptr) {
107      if (strncmp("HIDC_", ptr, 5) == 0) {
108         char id_name[128];
109         char *end = id_name;
110         char *id;
111         memset(id_name, '\0', sizeof(id_name));
112         while (*ptr && *ptr != '\x0d' && *ptr != '\x0a' ) {
113            *end++ = *ptr++;
114         }
115         id = malloc(strlen(id_name));
116         memset(id, '\0', strlen(id_name));
117         memcpy(id, &id_name[1], strlen(&id_name[1]));
118         help_ids[num_help_id] = id;
119         num_help_id++;
120      } else {
121         ptr++;
122      }
123   }
124
125   /* Sort using Quicksort algorithm: */
126   qsort( (void *)help_ids, (size_t)num_help_id, sizeof( char * ), compare );
127
128   // Now print them out.
129   ptr = help_ids[0];
130   for (i = 0; i < num_help_id; i++) {
131      if (i > 0) {
132         if (strcmp(ptr, help_ids[i]) == 0) {
133                continue;
134         }
135      }
136      fprintf(fp, "\t%-30s,H%s,\n", help_ids[i], help_ids[i]);
137      ptr = help_ids[i];
138   }
139   fprintf(fp, "\t%-30i,%i\n", 0, 0);
140
141   // free our allocations.
142   for (i = 0; i < num_help_id; i++) {
143      free(help_ids[i]);
144   }
145   free (help_ids);
146}
147
src/osd/winui/winui.mak
r1301r1302
1###########################################################################
2#
3#   winui.mak
4#
5#   winui (Mame32) makefile
6#
7#   Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8#   Visit http://mamedev.org for licensing and usage restrictions.
9#
10###########################################################################
11 
12 
13###########################################################################
14#################   BEGIN USER-CONFIGURABLE OPTIONS   #####################
15###########################################################################
16 
17 
18#-------------------------------------------------
19# specify build options; see each option below
20# for details
21#-------------------------------------------------
22 
23# uncomment next line to enable a build using Microsoft tools
24# MSVC_BUILD = 1
25 
26# uncomment next line to use cygwin compiler
27# CYGWIN_BUILD = 1
28 
29# uncomment next line to enable multi-monitor stubs on Windows 95/NT
30# you will need to find multimon.h and put it into your include
31# path in order to make this work
32# WIN95_MULTIMON = 1
33 
34# uncomment next line to enable a Unicode build
35# UNICODE = 1
36 
37 
38 
39###########################################################################
40##################   END USER-CONFIGURABLE OPTIONS   ######################
41###########################################################################
42 
43 
44#-------------------------------------------------
45# append "32" to the emulator name 
46#-------------------------------------------------
47 
48EMULATOR = $(FULLNAME)32$(EXE)
49 
50 
51 
52#-------------------------------------------------
53# object and source roots
54#-------------------------------------------------
55 
56WINSRC = $(SRC)/osd/windows
57WINOBJ = $(OBJ)/osd/windows
58 
59OBJDIRS += $(WINOBJ)
60 
61# add ui specific src/objs
62UISRC = $(SRC)/osd/$(OSD)
63UIOBJ = $(OBJ)/osd/$(OSD)
64 
65OBJDIRS += $(UIOBJ)
66 
67 
68 
69#-------------------------------------------------
70# configure the resource compiler
71#-------------------------------------------------
72 
73RC = @windres --use-temp-file
74 
75RCDEFS = -DNDEBUG -D_WIN32_IE=0x0400
76 
77# include UISRC direcotry
78RCFLAGS = -O coff -I $(UISRC) -I $(UIOBJ)
79 
80 
81 
82#-------------------------------------------------
83# overrides for the CYGWIN compiler
84#-------------------------------------------------
85 
86ifdef CYGWIN_BUILD
87CFLAGS   += -mno-cygwin
88LDFLAGS   += -mno-cygwin
89endif
90 
91 
92 
93#-------------------------------------------------
94# overrides for the MSVC compiler
95#-------------------------------------------------
96 
97ifdef MSVC_BUILD
98 
99VCONV = $(WINOBJ)/vconv$(EXE)
100 
101# replace the various compilers with vconv.exe prefixes
102CC = @$(VCONV) gcc -I.
103LD = @$(VCONV) ld /profile
104AR = @$(VCONV) ar
105RC = @$(VCONV) windres
106 
107# make sure we use the multithreaded runtime
108ifdef DEBUG
109CC += /MTd
110else
111CC += /MT
112endif
113 
114# turn on link-time codegen if the MAXOPT flag is also set
115ifdef MAXOPT
116CC += /GL
117LD += /LTCG
118endif
119 
120ifdef PTR64
121CC += /wd4267 /wd4312 /Wp64
122endif
123 
124# add some VC++-specific defines
125DEFS += -D_CRT_SECURE_NO_DEPRECATE -DXML_STATIC -D__inline__=__inline -Dsnprintf=_snprintf -Dvsnprintf=_vsnprintf
126 
127# make msvcprep into a pre-build step
128# OSPREBUILD = $(VCONV)
129 
130# add VCONV to the build tools
131BUILD += $(VCONV)
132 
133$(VCONV): $(WINOBJ)/vconv.o
134   @echo Linking $@...
135ifdef PTR64
136   @link.exe /nologo $^ version.lib bufferoverflowu.lib /out:$@
137else
138   @link.exe /nologo $^ version.lib /out:$@
139endif
140 
141$(WINOBJ)/vconv.o: $(WINSRC)/vconv.c
142   @echo Compiling $<...
143   @cl.exe /nologo /O1 -D_CRT_SECURE_NO_DEPRECATE -c $< /Fo$@
144 
145endif
146 
147 
148 
149#-------------------------------------------------
150# due to quirks of using /bin/sh, we need to
151# explicitly specify the current path
152#-------------------------------------------------
153 
154CURPATH = ./
155 
156 
157 
158#-------------------------------------------------
159# Windows-specific debug objects and flags
160#-------------------------------------------------
161 
162# define the x64 ABI to be Windows
163DEFS += -DX64_WINDOWS_ABI
164 
165# debug build: enable guard pages on all memory allocations
166ifdef DEBUG
167#DEFS += -DMALLOC_DEBUG
168LDFLAGS += -Wl,--allow-multiple-definition
169endif
170 
171ifdef UNICODE
172DEFS += -DUNICODE -D_UNICODE
173endif
174 
175 
176 
177#-------------------------------------------------
178# Windows-specific flags and libraries
179#-------------------------------------------------
180 
181# add our prefix files to the mix, include WINSRC in UI build
182CFLAGS += -include $(WINSRC)/winprefix.h -I$(WINSRC)
183 
184ifdef WIN95_MULTIMON
185CFLAGS += -DWIN95_MULTIMON
186endif
187 
188# add the windows libaries, 3 additional libs at the end for UI
189LIBS += \
190   -luser32 \
191   -lgdi32 \
192   -lddraw \
193   -ldsound \
194   -ldinput \
195   -ldxguid \
196   -lwinmm \
197   -ladvapi32 \
198   -lcomctl32 \
199   -lshlwapi \
200 
201# add -mwindows for UI
202LDFLAGSEMULATOR += \
203   -mwindows \
204   -lkernel32 \
205   -lshell32 \
206   -lcomdlg32 \
207 
208 
209ifdef PTR64
210LIBS += -lbufferoverflowu
211endif
212 
213 
214 
215#-------------------------------------------------
216# OSD core library
217#-------------------------------------------------
218# still not sure what to do about main.
219 
220OSDCOREOBJS = \
221   $(WINOBJ)/strconv.o   \
222   $(WINOBJ)/windir.o \
223   $(WINOBJ)/winfile.o \
224   $(WINOBJ)/winmisc.o \
225   $(WINOBJ)/winsync.o \
226   $(WINOBJ)/wintime.o \
227   $(WINOBJ)/winutf8.o \
228   $(WINOBJ)/winutil.o \
229   $(WINOBJ)/winwork.o \
230 
231# if malloc debugging is enabled, include the necessary code
232ifneq ($(findstring MALLOC_DEBUG,$(DEFS)),)
233OSDCOREOBJS += \
234   $(WINOBJ)/winalloc.o
235endif
236 
237$(LIBOCORE): $(OSDCOREOBJS)
238 
239 
240 
241#-------------------------------------------------
242# OSD Windows library
243#-------------------------------------------------
244 
245OSDOBJS = \
246   $(WINOBJ)/d3d8intf.o \
247   $(WINOBJ)/d3d9intf.o \
248   $(WINOBJ)/drawd3d.o \
249   $(WINOBJ)/drawdd.o \
250   $(WINOBJ)/drawgdi.o \
251   $(WINOBJ)/drawnone.o \
252   $(WINOBJ)/input.o \
253   $(WINOBJ)/output.o \
254   $(WINOBJ)/sound.o \
255   $(WINOBJ)/video.o \
256   $(WINOBJ)/window.o \
257   $(WINOBJ)/winmain.o \
258 
259 
260# add UI objs
261OSDOBJS += \
262   $(UIOBJ)/m32util.o \
263   $(UIOBJ)/directinput.o \
264   $(UIOBJ)/dijoystick.o \
265   $(UIOBJ)/directdraw.o \
266   $(UIOBJ)/directories.o \
267   $(UIOBJ)/audit32.o \
268   $(UIOBJ)/columnedit.o \
269   $(UIOBJ)/screenshot.o \
270   $(UIOBJ)/treeview.o \
271   $(UIOBJ)/splitters.o \
272   $(UIOBJ)/bitmask.o \
273   $(UIOBJ)/datamap.o \
274   $(UIOBJ)/dxdecode.o \
275   $(UIOBJ)/picker.o \
276   $(UIOBJ)/properties.o \
277   $(UIOBJ)/tabview.o \
278   $(UIOBJ)/help.o \
279   $(UIOBJ)/history.o \
280   $(UIOBJ)/dialogs.o \
281   $(UIOBJ)/m32opts.o \
282   $(UIOBJ)/layout.o \
283   $(UIOBJ)/datafile.o \
284   $(UIOBJ)/dirwatch.o \
285   $(UIOBJ)/win32ui.o \
286   $(UIOBJ)/helpids.o \
287 
288 
289# extra dependencies
290$(WINOBJ)/drawdd.o :    $(SRC)/emu/rendersw.c
291$(WINOBJ)/drawgdi.o :   $(SRC)/emu/rendersw.c
292 
293# add debug-specific files
294ifdef DEBUG
295OSDOBJS += \
296   $(WINOBJ)/debugwin.o
297endif
298 
299# add our UI resources
300RESFILE += $(UIOBJ)/mame32.res
301 
302$(LIBOSD): $(OSDOBJS)
303 
304EMUMAIN = $(UIOBJ)/m32main.o
305 
306 
307 
308#-------------------------------------------------
309# rule for making the ledutil sample
310#
311# Don't build for an MSVC_BUILD
312#-------------------------------------------------
313 
314ledutil$(EXE): $(WINOBJ)/ledutil.o $(WINOBJ)/main.o $(LIBOCORE)
315   @echo Linking $@...
316   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
317 
318TOOLS += ledutil$(EXE)
319 
320 
321 
322#-------------------------------------------------
323# rules for creating helpids.c 
324#-------------------------------------------------
325 
326$(UISRC)/helpids.c : $(UIOBJ)/mkhelp$(EXE) $(UISRC)/resource.h $(UISRC)/resource.hm $(UISRC)/mame32.rc
327   $(UIOBJ)/mkhelp$(EXE) $(UISRC)/mame32.rc >$@
328 
329# rule to build the generator
330$(UIOBJ)/mkhelp$(EXE): $(UIOBJ)/mkhelp.o $(LIBOCORE)
331   @echo Linking $@...
332   $(LD) $(LDFLAGS) $(OSDBGLDFLAGS) $^ $(LIBS) -o $@
333 
334 
335 
336#-------------------------------------------------
337# rule for making the verinfo tool
338#-------------------------------------------------
339 
340VERINFO = $(UIOBJ)/verinfo$(EXE)
341 
342$(VERINFO): $(UIOBJ)/verinfo.o $(LIBOCORE)
343   @echo Linking $@...
344   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
345 
346BUILD += $(VERINFO)
347 
348 
349 
350#-------------------------------------------------
351# Specific rele to compile verinfo util.
352#-------------------------------------------------
353 
354$(UIOBJ)/verinfo.o : $(WINSRC)/verinfo.c
355   @echo Compiling $<...
356   $(CC) -DWINUI $(CDEFS) $(CFLAGS) -c $< -o $@
357 
358 
359 
360#-------------------------------------------------
361# generic rule for the resource compiler for UI
362#-------------------------------------------------
363 
364$(UIOBJ)/mame32.res: $(UISRC)/mame32.rc $(UIOBJ)/mamevers.rc
365   @echo Compiling mame32 resources $<...
366   $(RC) $(RCDEFS) $(RCFLAGS) -o $@ -i $<
367 
368 
369 
370#-------------------------------------------------
371# rules for resource file
372#-------------------------------------------------
373 
374$(UIOBJ)/mame32.res: $(UISRC)/mame32.rc $(UIOBJ)/mamevers.rc
375 
376$(UIOBJ)/mamevers.rc: $(VERINFO) $(SRC)/version.c
377   @echo Emitting $@...
378   @$(VERINFO) $(SRC)/version.c > $@
379 
380 
381 
382 
383#####  End windui.mak ##############################################
384 
1###########################################################################
2#
3#   winui.mak
4#
5#   winui (Mame32) makefile
6#
7#   Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8#   Visit http://mamedev.org for licensing and usage restrictions.
9#
10###########################################################################
11
12
13###########################################################################
14#################   BEGIN USER-CONFIGURABLE OPTIONS   #####################
15###########################################################################
16
17
18#-------------------------------------------------
19# specify build options; see each option below
20# for details
21#-------------------------------------------------
22
23# uncomment next line to enable a build using Microsoft tools
24# MSVC_BUILD = 1
25
26# uncomment next line to use cygwin compiler
27# CYGWIN_BUILD = 1
28
29# uncomment next line to enable multi-monitor stubs on Windows 95/NT
30# you will need to find multimon.h and put it into your include
31# path in order to make this work
32# WIN95_MULTIMON = 1
33
34# uncomment next line to enable a Unicode build
35# UNICODE = 1
36
37
38
39###########################################################################
40##################   END USER-CONFIGURABLE OPTIONS   ######################
41###########################################################################
42
43
44#-------------------------------------------------
45# append "32" to the emulator name
46#-------------------------------------------------
47
48EMULATOR = $(FULLNAME)32$(EXE)
49
50
51
52#-------------------------------------------------
53# object and source roots
54#-------------------------------------------------
55
56WINSRC = $(SRC)/osd/windows
57WINOBJ = $(OBJ)/osd/windows
58
59OBJDIRS += $(WINOBJ)
60
61# add ui specific src/objs
62UISRC = $(SRC)/osd/$(OSD)
63UIOBJ = $(OBJ)/osd/$(OSD)
64
65OBJDIRS += $(UIOBJ)
66
67
68
69#-------------------------------------------------
70# configure the resource compiler
71#-------------------------------------------------
72
73RC = @windres --use-temp-file
74
75RCDEFS = -DNDEBUG -D_WIN32_IE=0x0400
76
77# include UISRC direcotry
78RCFLAGS = -O coff -I $(UISRC) -I $(UIOBJ)
79
80
81
82#-------------------------------------------------
83# overrides for the CYGWIN compiler
84#-------------------------------------------------
85
86ifdef CYGWIN_BUILD
87CFLAGS   += -mno-cygwin
88LDFLAGS   += -mno-cygwin
89endif
90
91
92
93#-------------------------------------------------
94# overrides for the MSVC compiler
95#-------------------------------------------------
96
97ifdef MSVC_BUILD
98
99VCONV = $(WINOBJ)/vconv$(EXE)
100
101# replace the various compilers with vconv.exe prefixes
102CC = @$(VCONV) gcc -I.
103LD = @$(VCONV) ld /profile
104AR = @$(VCONV) ar
105RC = @$(VCONV) windres
106
107# make sure we use the multithreaded runtime
108ifdef DEBUG
109CC += /MTd
110else
111CC += /MT
112endif
113
114# turn on link-time codegen if the MAXOPT flag is also set
115ifdef MAXOPT
116CC += /GL
117LD += /LTCG
118endif
119
120ifdef PTR64
121CC += /wd4267 /wd4312 /Wp64
122endif
123
124# add some VC++-specific defines
125DEFS += -D_CRT_SECURE_NO_DEPRECATE -DXML_STATIC -D__inline__=__inline -Dsnprintf=_snprintf -Dvsnprintf=_vsnprintf
126
127# make msvcprep into a pre-build step
128# OSPREBUILD = $(VCONV)
129
130# add VCONV to the build tools
131BUILD += $(VCONV)
132
133$(VCONV): $(WINOBJ)/vconv.o
134   @echo Linking $@...
135ifdef PTR64
136   @link.exe /nologo $^ version.lib bufferoverflowu.lib /out:$@
137else
138   @link.exe /nologo $^ version.lib /out:$@
139endif
140
141$(WINOBJ)/vconv.o: $(WINSRC)/vconv.c
142   @echo Compiling $<...
143   @cl.exe /nologo /O1 -D_CRT_SECURE_NO_DEPRECATE -c $< /Fo$@
144
145endif
146
147
148
149#-------------------------------------------------
150# due to quirks of using /bin/sh, we need to
151# explicitly specify the current path
152#-------------------------------------------------
153
154CURPATH = ./
155
156
157
158#-------------------------------------------------
159# Windows-specific debug objects and flags
160#-------------------------------------------------
161
162# define the x64 ABI to be Windows
163DEFS += -DX64_WINDOWS_ABI
164
165# debug build: enable guard pages on all memory allocations
166ifdef DEBUG
167#DEFS += -DMALLOC_DEBUG
168LDFLAGS += -Wl,--allow-multiple-definition
169endif
170
171ifdef UNICODE
172DEFS += -DUNICODE -D_UNICODE
173endif
174
175
176
177#-------------------------------------------------
178# Windows-specific flags and libraries
179#-------------------------------------------------
180
181# add our prefix files to the mix, include WINSRC in UI build
182CFLAGS += -include $(WINSRC)/winprefix.h -I$(WINSRC)
183
184ifdef WIN95_MULTIMON
185CFLAGS += -DWIN95_MULTIMON
186endif
187
188# add the windows libaries, 3 additional libs at the end for UI
189LIBS += \
190   -luser32 \
191   -lgdi32 \
192   -lddraw \
193   -ldsound \
194   -ldinput \
195   -ldxguid \
196   -lwinmm \
197   -ladvapi32 \
198   -lcomctl32 \
199   -lshlwapi \
200
201# add -mwindows for UI
202LDFLAGSEMULATOR += \
203   -mwindows \
204   -lkernel32 \
205   -lshell32 \
206   -lcomdlg32 \
207
208
209ifdef PTR64
210LIBS += -lbufferoverflowu
211endif
212
213
214
215#-------------------------------------------------
216# OSD core library
217#-------------------------------------------------
218# still not sure what to do about main.
219
220OSDCOREOBJS = \
221   $(WINOBJ)/strconv.o   \
222   $(WINOBJ)/windir.o \
223   $(WINOBJ)/winfile.o \
224   $(WINOBJ)/winmisc.o \
225   $(WINOBJ)/winsync.o \
226   $(WINOBJ)/wintime.o \
227   $(WINOBJ)/winutf8.o \
228   $(WINOBJ)/winutil.o \
229   $(WINOBJ)/winwork.o \
230
231# if malloc debugging is enabled, include the necessary code
232ifneq ($(findstring MALLOC_DEBUG,$(DEFS)),)
233OSDCOREOBJS += \
234   $(WINOBJ)/winalloc.o
235endif
236
237$(LIBOCORE): $(OSDCOREOBJS)
238
239
240
241#-------------------------------------------------
242# OSD Windows library
243#-------------------------------------------------
244
245OSDOBJS = \
246   $(WINOBJ)/d3d8intf.o \
247   $(WINOBJ)/d3d9intf.o \
248   $(WINOBJ)/drawd3d.o \
249   $(WINOBJ)/drawdd.o \
250   $(WINOBJ)/drawgdi.o \
251   $(WINOBJ)/drawnone.o \
252   $(WINOBJ)/input.o \
253   $(WINOBJ)/output.o \
254   $(WINOBJ)/sound.o \
255   $(WINOBJ)/video.o \
256   $(WINOBJ)/window.o \
257   $(WINOBJ)/winmain.o \
258
259
260# add UI objs
261OSDOBJS += \
262   $(UIOBJ)/m32util.o \
263   $(UIOBJ)/directinput.o \
264   $(UIOBJ)/dijoystick.o \
265   $(UIOBJ)/directdraw.o \
266   $(UIOBJ)/directories.o \
267   $(UIOBJ)/audit32.o \
268   $(UIOBJ)/columnedit.o \
269   $(UIOBJ)/screenshot.o \
270   $(UIOBJ)/treeview.o \
271   $(UIOBJ)/splitters.o \
272   $(UIOBJ)/bitmask.o \
273   $(UIOBJ)/datamap.o \
274   $(UIOBJ)/dxdecode.o \
275   $(UIOBJ)/picker.o \
276   $(UIOBJ)/properties.o \
277   $(UIOBJ)/tabview.o \
278   $(UIOBJ)/help.o \
279   $(UIOBJ)/history.o \
280   $(UIOBJ)/dialogs.o \
281   $(UIOBJ)/m32opts.o \
282   $(UIOBJ)/layout.o \
283   $(UIOBJ)/datafile.o \
284   $(UIOBJ)/dirwatch.o \
285   $(UIOBJ)/win32ui.o \
286   $(UIOBJ)/helpids.o \
287
288
289# extra dependencies
290$(WINOBJ)/drawdd.o :    $(SRC)/emu/rendersw.c
291$(WINOBJ)/drawgdi.o :   $(SRC)/emu/rendersw.c
292
293# add debug-specific files
294ifdef DEBUG
295OSDOBJS += \
296   $(WINOBJ)/debugwin.o
297endif
298
299# add our UI resources
300RESFILE += $(UIOBJ)/mame32.res
301
302$(LIBOSD): $(OSDOBJS)
303
304EMUMAIN = $(UIOBJ)/m32main.o
305
306
307
308#-------------------------------------------------
309# rule for making the ledutil sample
310#
311# Don't build for an MSVC_BUILD
312#-------------------------------------------------
313
314ledutil$(EXE): $(WINOBJ)/ledutil.o $(WINOBJ)/main.o $(LIBOCORE)
315   @echo Linking $@...
316   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
317
318TOOLS += ledutil$(EXE)
319
320
321
322#-------------------------------------------------
323# rules for creating helpids.c
324#-------------------------------------------------
325
326$(UISRC)/helpids.c : $(UIOBJ)/mkhelp$(EXE) $(UISRC)/resource.h $(UISRC)/resource.hm $(UISRC)/mame32.rc
327   $(UIOBJ)/mkhelp$(EXE) $(UISRC)/mame32.rc >$@
328
329# rule to build the generator
330$(UIOBJ)/mkhelp$(EXE): $(UIOBJ)/mkhelp.o $(LIBOCORE)
331   @echo Linking $@...
332   $(LD) $(LDFLAGS) $(OSDBGLDFLAGS) $^ $(LIBS) -o $@
333
334
335
336#-------------------------------------------------
337# rule for making the verinfo tool
338#-------------------------------------------------
339
340VERINFO = $(UIOBJ)/verinfo$(EXE)
341
342$(VERINFO): $(UIOBJ)/verinfo.o $(LIBOCORE)
343   @echo Linking $@...
344   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
345
346BUILD += $(VERINFO)
347
348
349
350#-------------------------------------------------
351# Specific rele to compile verinfo util.
352#-------------------------------------------------
353
354$(UIOBJ)/verinfo.o : $(WINSRC)/verinfo.c
355   @echo Compiling $<...
356   $(CC) -DWINUI $(CDEFS) $(CFLAGS) -c $< -o $@
357
358
359
360#-------------------------------------------------
361# generic rule for the resource compiler for UI
362#-------------------------------------------------
363
364$(UIOBJ)/mame32.res: $(UISRC)/mame32.rc $(UIOBJ)/mamevers.rc
365   @echo Compiling mame32 resources $<...
366   $(RC) $(RCDEFS) $(RCFLAGS) -o $@ -i $<
367
368
369
370#-------------------------------------------------
371# rules for resource file
372#-------------------------------------------------
373
374$(UIOBJ)/mame32.res: $(UISRC)/mame32.rc $(UIOBJ)/mamevers.rc
375
376$(UIOBJ)/mamevers.rc: $(VERINFO) $(SRC)/version.c
377   @echo Emitting $@...
378   @$(VERINFO) $(SRC)/version.c > $@
379
380
381
382
383#####  End windui.mak ##############################################
384
src/mess/audio/pc.h
r1301r1302
1/***************************************************************************
2 
3   audio/pc.h
4 
5   Functions to emulate a PC PIC timer 2 used for simple tone generation
6 
7   TODO:
8   Add support for the SN76496 used in the Tandy1000/PCjr
9   It most probably is on port 0xc0, but I'm not sure...
10 
11****************************************************************************/
12 
13#ifndef __AUDIO_PC_H__
14#define __AUDIO_PC_H__
15 
16#include "driver.h"
17 
18extern const struct CustomSound_interface pc_sound_interface;
19void pc_sh_update(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
20void pc_sh_speaker(int mode);
21 
22void pc_sh_speaker_change_clock(double pc_clock);
23 
24#endif /* __AUDIO_PC_H__ */
1/***************************************************************************
2
3   audio/pc.h
4
5   Functions to emulate a PC PIC timer 2 used for simple tone generation
6
7   TODO:
8   Add support for the SN76496 used in the Tandy1000/PCjr
9   It most probably is on port 0xc0, but I'm not sure...
10
11****************************************************************************/
12
13#ifndef __AUDIO_PC_H__
14#define __AUDIO_PC_H__
15
16#include "driver.h"
17
18extern const struct CustomSound_interface pc_sound_interface;
19void pc_sh_update(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
20void pc_sh_speaker(int mode);
21
22void pc_sh_speaker_change_clock(double pc_clock);
23
24#endif /* __AUDIO_PC_H__ */
src/mess/video/zx8301.c
r1301r1302
1#include "video/zx8301.h"
2 
3typedef struct
4{
5   int dispoff;
6   int mode8;
7   int base;
8   int flash;
9} ZX8301_VIDEO_CONFIG;
10 
11static ZX8301_VIDEO_CONFIG zx8301;
12 
13static const int ZX8301_COLOR_MODE4[] = { 0, 2, 4, 7 };
14 
15static emu_timer *zx8301_flash_timer;
16 
17static TIMER_CALLBACK(zx8301_flash_tick)
18{
19   zx8301.flash = zx8301.flash ? 0 : 1;
20}
21 
22PALETTE_INIT( zx8301 )
23{
24   palette_set_color_rgb(machine, 0, 0x00, 0x00, 0x00 ); // black
25   palette_set_color_rgb(machine, 1, 0x00, 0x00, 0xff ); // blue
26   palette_set_color_rgb(machine, 2, 0xff, 0x00, 0x00 ); // red
27   palette_set_color_rgb(machine, 3, 0xff, 0x00, 0xff ); // magenta
28   palette_set_color_rgb(machine, 4, 0x00, 0xff, 0x00 ); // green
29   palette_set_color_rgb(machine, 5, 0x00, 0xff, 0xff ); // cyan
30   palette_set_color_rgb(machine, 6, 0xff, 0xff, 0x00 ); // yellow
31   palette_set_color_rgb(machine, 7, 0xff, 0xff, 0xff ); // whit
32}
33 
34WRITE8_HANDLER( zx8301_control_w )
35{
36   zx8301.dispoff = BIT(data, 1);
37   zx8301.mode8 = BIT(data, 3);
38   zx8301.base = BIT(data, 7);
39}
40 
41static void zx8301_draw_screen(mame_bitmap *bitmap)
42{
43   UINT32 addr = zx8301.base << 15;
44   int y, word, pixel;
45 
46   if (zx8301.mode8)
47   {
48      // mode 8/256 GFGFGFGF RBRBRBRB
49 
50      for (y = 0; y < 256; y++)
51      {
52         int x = 0;
53 
54         for (word = 0; word < 64; word++)
55         {
56            UINT8 byte_high = videoram[addr++];
57            UINT8 byte_low = videoram[addr++];
58 
59            for (pixel = 0; pixel < 4; pixel++)
60            {
61               int red = BIT(byte_low, 7);
62               int green = BIT(byte_high, 7);
63               int blue = BIT(byte_low, 6);
64               int flash = BIT(byte_high, 6);
65 
66               int color = (green << 2) | (red << 1) | blue;
67 
68               if (flash && zx8301.flash)
69               {
70                  color = 0;
71               }
72 
73               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color];
74               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color];
75 
76               byte_high <<= 2;
77               byte_low <<= 2;
78            }
79         }
80      }
81   }
82   else
83   {
84      // mode 4/512 GGGGGGGG RRRRRRRR
85 
86      for (y = 0; y < 256; y++)
87      {
88         int x = 0;
89 
90         for (word = 0; word < 64; word++)
91         {
92            UINT8 byte_high = videoram[addr++];
93            UINT8 byte_low = videoram[addr++];
94 
95            for (pixel = 0; pixel < 8; pixel++)
96            {
97               int red = BIT(byte_low, 7);
98               int green = BIT(byte_high, 7);
99               int color = (green << 1) | red;
100 
101               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[ZX8301_COLOR_MODE4[color]];
102 
103               byte_high <<= 1;
104               byte_low <<= 1;
105            }
106         }
107      }
108   }
109}
110 
111VIDEO_START( zx8301 )
112{
113   zx8301_flash_timer = timer_alloc(zx8301_flash_tick);
114   timer_adjust(zx8301_flash_timer, ATTOTIME_IN_HZ(2), 0, ATTOTIME_IN_HZ(2));
115 
116   state_save_register_global(zx8301.dispoff);
117   state_save_register_global(zx8301.mode8);
118   state_save_register_global(zx8301.base);
119   state_save_register_global(zx8301.flash);
120}
121 
122VIDEO_UPDATE( zx8301 )
123{
124   if (!zx8301.dispoff)
125   {
126      zx8301_draw_screen(bitmap);
127   }
128   else
129   {
130      fillbitmap(bitmap, get_black_pen(Machine), cliprect);
131   }
132 
133   return 0;
134}
1#include "video/zx8301.h"
2
3typedef struct
4{
5   int dispoff;
6   int mode8;
7   int base;
8   int flash;
9} ZX8301_VIDEO_CONFIG;
10
11static ZX8301_VIDEO_CONFIG zx8301;
12
13static const int ZX8301_COLOR_MODE4[] = { 0, 2, 4, 7 };
14
15static emu_timer *zx8301_flash_timer;
16
17static TIMER_CALLBACK(zx8301_flash_tick)
18{
19   zx8301.flash = zx8301.flash ? 0 : 1;
20}
21
22PALETTE_INIT( zx8301 )
23{
24   palette_set_color_rgb(machine, 0, 0x00, 0x00, 0x00 ); // black
25   palette_set_color_rgb(machine, 1, 0x00, 0x00, 0xff ); // blue
26   palette_set_color_rgb(machine, 2, 0xff, 0x00, 0x00 ); // red
27   palette_set_color_rgb(machine, 3, 0xff, 0x00, 0xff ); // magenta
28   palette_set_color_rgb(machine, 4, 0x00, 0xff, 0x00 ); // green
29   palette_set_color_rgb(machine, 5, 0x00, 0xff, 0xff ); // cyan
30   palette_set_color_rgb(machine, 6, 0xff, 0xff, 0x00 ); // yellow
31   palette_set_color_rgb(machine, 7, 0xff, 0xff, 0xff ); // whit
32}
33
34WRITE8_HANDLER( zx8301_control_w )
35{
36   zx8301.dispoff = BIT(data, 1);
37   zx8301.mode8 = BIT(data, 3);
38   zx8301.base = BIT(data, 7);
39}
40
41static void zx8301_draw_screen(mame_bitmap *bitmap)
42{
43   UINT32 addr = zx8301.base << 15;
44   int y, word, pixel;
45
46   if (zx8301.mode8)
47   {
48      // mode 8/256 GFGFGFGF RBRBRBRB
49
50      for (y = 0; y < 256; y++)
51      {
52         int x = 0;
53
54         for (word = 0; word < 64; word++)
55         {
56            UINT8 byte_high = videoram[addr++];
57            UINT8 byte_low = videoram[addr++];
58
59            for (pixel = 0; pixel < 4; pixel++)
60            {
61               int red = BIT(byte_low, 7);
62               int green = BIT(byte_high, 7);
63               int blue = BIT(byte_low, 6);
64               int flash = BIT(byte_high, 6);
65
66               int color = (green << 2) | (red << 1) | blue;
67
68               if (flash && zx8301.flash)
69               {
70                  color = 0;
71               }
72
73               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color];
74               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color];
75
76               byte_high <<= 2;
77               byte_low <<= 2;
78            }
79         }
80      }
81   }
82   else
83   {
84      // mode 4/512 GGGGGGGG RRRRRRRR
85
86      for (y = 0; y < 256; y++)
87      {
88         int x = 0;
89
90         for (word = 0; word < 64; word++)
91         {
92            UINT8 byte_high = videoram[addr++];
93            UINT8 byte_low = videoram[addr++];
94
95            for (pixel = 0; pixel < 8; pixel++)
96            {
97               int red = BIT(byte_low, 7);
98               int green = BIT(byte_high, 7);
99               int color = (green << 1) | red;
100
101               *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[ZX8301_COLOR_MODE4[color]];
102
103               byte_high <<= 1;
104               byte_low <<= 1;
105            }
106         }
107      }
108   }
109}
110
111VIDEO_START( zx8301 )
112{
113   zx8301_flash_timer = timer_alloc(zx8301_flash_tick);
114   timer_adjust(zx8301_flash_timer, ATTOTIME_IN_HZ(2), 0, ATTOTIME_IN_HZ(2));
115
116   state_save_register_global(zx8301.dispoff);
117   state_save_register_global(zx8301.mode8);
118   state_save_register_global(zx8301.base);
119   state_save_register_global(zx8301.flash);
120}
121
122VIDEO_UPDATE( zx8301 )
123{
124   if (!zx8301.dispoff)
125   {
126      zx8301_draw_screen(bitmap);
127   }
128   else
129   {
130      fillbitmap(bitmap, get_black_pen(Machine), cliprect);
131   }
132
133   return 0;
134}
src/mess/video/zx8301.h
r1301r1302
1#include "driver.h"
2#include "video/generic.h"
3 
4WRITE8_HANDLER( zx8301_control_w );
5 
6PALETTE_INIT( zx8301 );
7VIDEO_START( zx8301 );
8VIDEO_UPDATE( zx8301 );
1#include "driver.h"
2#include "video/generic.h"
3
4WRITE8_HANDLER( zx8301_control_w );
5
6PALETTE_INIT( zx8301 );
7VIDEO_START( zx8301 );
8VIDEO_UPDATE( zx8301 );
src/mess/drivers/glasgow.c
r1301r1302
1/***************************************************************************
2Mephisto Glasgow 3 S chess computer
3Dirk V.
4sp_rinter@gmx.de
5 
668000 CPU
764 KB ROM
816 KB RAM
94 Digit LC Display
10 
113* 74LS138  Decoder/Multiplexer
121*74LS74    Dual positive edge triggered D Flip Flop
131*74LS139 1of4 Demultiplexer
141*74LS05    HexInverter
151*NE555     R=100K C=10uF
162*74LS04  Hex Inverter
171*74LS164   8 Bit Shift register
181*74121 Monostable Multivibrator with Schmitt Trigger Inputs
191*74LS20 Dual 4 Input NAND GAte
201*74LS367 3 State Hex Buffers
21 
22 
23***************************************************************************/
24 
25#include "driver.h"
26#include "cpu/m68000/m68k.h"
27#include "cpu/m68000/m68000.h"
28#include "glasgow.lh"
29#include "sound/beep.h"
30 
31#include "render.h"
32#include "rendlay.h"
33 
34static UINT8 lcd_shift_counter;
35// static UINT8 led_status;
36static UINT8 led7;
37static UINT8 key_low,
38       key_hi,
39       key_select,
40       irq_flag,
41       lcd_invert,
42       key_selector;
43       UINT8 board_value;
44static UINT16 beeper;
45 
46 
47  #define MOUSE_X      56
48  #define MOUSE_Y      56
49  #define MAX_X         530
50  #define MAX_Y         660
51  #define MOUSE_SPEED   3
52 
53  #define MIN_BOARD_X   60.0
54  #define MAX_BOARD_X   480.0
55 
56  #define MIN_BOARD_Y   60.0
57  #define MAX_BOARD_Y   480.0
58 
59  #define MIN_CURSOR_X   -10
60  #define MAX_CURSOR_X   496
61 
62  #define MIN_CURSOR_Y   0
63  #define MAX_CURSOR_Y   622
64 
65  static INT16 m_x, m_y;
66  static UINT8 m_button1 , m_button2;
67  static UINT8 MOUSE_MOVE = 0;
68  static UINT8 MOUSE_BUTTON1_WAIT = 0;
69  static UINT8 MOUSE_BUTTON2_WAIT = 0;
70 
71  static UINT16 Line18_LED;
72  static UINT16 Line18_REED;
73 
74  static UINT8 read_board_flag;
75 
76  static  char EMP[4] = "EMP";
77  static  char NO_PIECE[4]  = "NOP";
78 
79 
80  typedef struct {
81       unsigned int field;
82      unsigned int x;
83      unsigned int y;
84       unsigned char piece[4];
85  } BOARD_FIELD;
86 
87 
88   #define WR   12
89   #define WB   13
90   #define WKN   14
91   #define WQ   15
92   #define WK   16
93 
94   #define BP   21
95   #define BR   22
96   #define BB   23
97   #define BKN   24
98   #define BQ   25
99   #define BK   26
100 
101 
102 
103    BOARD_FIELD m_board[8][8];
104 
105    BOARD_FIELD start_board[8][8] =
106   {
107      { { 7,44,434,"WR1"}, { 6,100,434,"WN1"}, { 5,156,434,"WB1"}, { 4,212,434,"WQ1"}, { 3,268,434,"WK"}, { 2,324,434,"WB2"}, { 1,380,434,"WN2"}, { 0,436,434,"WR2"} },
108      { {15,44,378,"WP1"}, {14,100,378,"WP2"}, {13,156,378,"WP3"}, {12,212,378,"WP4"}, {11,268,378,"WP5"}, {10,324,378,"WP6"}, { 9,380,378,"WP7"}, { 8,436,378,"WP8"} },
109 
110      { {23,44,322, "EMP"}, {22,100,322, "EMP"}, {21,156,322, "EMP"}, {20,212,322, "EMP"}, {19,268,322, "EMP"}, {18,324,322, "EMP"}, {17,380,322, "EMP"}, {16,436,322, "EMP"} },
111      { {31,44,266, "EMP"}, {30,100,266, "EMP"}, {29,156,266, "EMP"}, {28,212,266, "EMP"}, {27,268,266, "EMP"}, {26,324,266, "EMP"}, {25,380,266, "EMP"}, {24,436,266, "EMP"} },
112      { {39,44,210, "EMP"}, {38,100,210, "EMP"}, {37,156,210, "EMP"}, {36,212,210, "EMP"}, {35,268,210, "EMP"}, {34,324,210, "EMP"}, {33,380,210, "EMP"}, {32,436,210, "EMP"} },
113      { {47,44,154, "EMP"}, {46,100,154, "EMP"}, {45,156,154, "EMP"}, {44,212,154, "EMP"}, {43,268,154, "EMP"}, {42,324,154, "EMP"}, {41,380,154, "EMP"}, {40,436,154, "EMP"} },
114 
115      { {55,44,100,"BP1"}, {54,100,100,"BP2"}, {53,156,100,"BP3"}, {52,212,100,"BP4"}, {51,268,100,"BP5"}, {50,324,100,"BP6"}, {49,380,100,"BP7"}, {48,436,100,"BP8"} },
116      { {63,44,44 ,"BR1"}, {62,100,44 ,"BN1"}, {61,156,44 ,"BB1"}, {60,212,44 ,"BQ1"}, {59,268,44 ,"BK"}, {58,324,44 ,"BB2"}, {57,380,44 ,"BN2"}, {56,436,44 ,"BR2"} }
117 
118   };
119 
120 
121   static BOARD_FIELD cursor_field;
122 
123 
124     typedef struct {
125       unsigned char piece[4];
126      unsigned int selected;
127      unsigned int set;
128  } P_STATUS;
129 
130 
131    static P_STATUS all_pieces[48] =
132    {
133       {"WR1",0,0}, {"WN1",0,0},{"WB1",0,0}, {"WQ1",0,0},  {"WK",0,0},  {"WB2",0,0}, {"WN2",0,0}, {"WR2",0,0},
134       {"WP1",0,0}, {"WP2",0,0},{"WP3",0,0}, {"WP4",0,0}, {"WP5",0,0},  {"WP6",0,0}, {"WP7",0,0}, {"WP8",0,0},
135 
136 
137      {"BP1",0,0}, {"BP2",0,0},{"BP3",0,0}, {"BP4",0,0}, {"BP5",0,0},  {"BP6",0,0}, {"BP7",0,0}, {"BP8",0,0},
138       {"BR1",0,0}, {"BN1",0,0},{"BB1",0,0}, {"BQ1",0,0},  {"BK",0,0},  {"BB2",0,0}, {"BN2",0,0}, {"BR2",0,0},
139 
140 
141        {"BQ2",0,0}, {"BQ3",0,0}, {"BQ4",0,0}, {"BQ5",0,0}, {"BQ6",0,0}, {"BQ7",0,0},
142 
143 
144      {"WQ2",0,0}, {"WQ3",0,0}, {"WQ4",0,0}, {"WQ5",0,0}, {"WQ6",0,0}, {"WQ7",0,0}
145 
146    };
147 
148     static UINT8 start_i;
149 
150 
151  struct _render_target
152{
153   render_target *      next;            /* keep a linked list of targets */
154   layout_view *      curview;         /* current view */
155   layout_file *      filelist;         /* list of layout files */
156   UINT32            flags;            /* creation flags */
157   render_primitive_list primlist[2];/* list of primitives */
158   int               listindex;         /* index of next primlist to use */
159   INT32            width;            /* width in pixels */
160   INT32            height;            /* height in pixels */
161   render_bounds      bounds;            /* bounds of the target */
162   float            pixel_aspect;      /* aspect ratio of individual pixels */
163   float            max_refresh;      /* maximum refresh rate, 0 or if none */
164   int               orientation;      /* orientation */
165   int               layerconfig;      /* layer configuration */
166   layout_view *      base_view;         /* the view at the time of first frame */
167   int               base_orientation;   /* the orientation at the time of first frame */
168   int               base_layerconfig;   /* the layer configuration at the time of first frame */
169   int               maxtexwidth;      /* maximum width of a texture */
170   int               maxtexheight;      /* maximum height of a texture */
171};
172 
173  static render_target *my_target;
174 
175  static view_item *my_cursor;
176 
177  static void set_cursor (view_item *view_cursor);
178 
179  static view_item *get_view_item(render_target *target, const char *v_name);
180 
181  static BOARD_FIELD  get_field( float i_x, float i_y, UINT8 mouse_move);
182  static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag);
183 
184  static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y );
185 
186  static void set_render_board(void);
187  static void clear_layout(void);
188  static void set_status_of_pieces(void);
189 
190  static char * get_non_set_pieces(const char *cur_piece);
191 
192  static unsigned int out_of_board( float x0, float y0);
193 
194 
195 
196// Used by Glasgow and Dallas
197static WRITE16_HANDLER ( write_lcd_gg )
198{
199  UINT8 lcd_data;
200  lcd_data = data>>8;
201  if (led7==0) output_set_digit_value(lcd_shift_counter,lcd_data);
202  lcd_shift_counter--;
203  lcd_shift_counter&=3;
204//  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
205}
206 
207static WRITE16_HANDLER ( write_lcd )
208{
209  UINT8 lcd_data;
210  lcd_data = data>>8;
211  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
212  lcd_shift_counter--;
213  lcd_shift_counter&=3;
214//  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
215}
216static WRITE16_HANDLER ( write_lcd_flag )
217{
218  UINT8 lcd_flag;
219  lcd_invert=0;
220  lcd_flag=data>>8;
221  //beep_set_state(0,lcd_flag&1?1:0);
222  if (lcd_flag == 0) key_selector=1;
223  if (lcd_flag!=0) led7=255;else led7=0;
224//  logerror("LCD Flag 16  = %x \n  ",data);
225}
226 
227 
228static WRITE16_HANDLER ( write_lcd_flag_gg )
229{
230  UINT8 lcd_flag;
231  lcd_flag=data>>8;
232  beep_set_state(0,lcd_flag&1?1:0);
233  if (lcd_flag == 0) key_selector=1;
234  if (lcd_flag!=0) led7=255;else led7=0;
235 
236//  logerror("LCD Flag gg  = %x \n  ",lcd_flag);
237}
238 
239static WRITE16_HANDLER ( write_keys )
240{
241 key_select=data>>8;
242// logerror("Write Key   = %x \n  ",data);
243}
244 
245static WRITE16_HANDLER ( write_board )
246{
247UINT8 beep_flag;
248 
249Line18_REED=data>>8;
250 
251// LED's or REED's ?
252//
253if (read_board_flag)
254   {
255   Line18_LED=0;
256   read_board_flag=0;
257   }
258else
259   {
260   Line18_LED=data>>8;
261   }
262 
263//logerror("write_board Line18_LED   = %x \n  ", Line18_LED);
264//logerror("write_board Line18_REED   = %x \n  ",Line18_REED);
265 
266lcd_invert=1;
267beep_flag=data>>8;
268//if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
269//logerror("Write Beeper   = %x \n  ",data);
270 beeper=data;
271}
272 
273static WRITE16_HANDLER ( write_irq_flag )
274{
275 
276 beep_set_state(0,data&0x100);
277 logerror("Write 0x800004   = %x \n  ",data);
278 irq_flag=1;
279 beeper=data;
280}
281 
282static READ16_HANDLER(read_keys) // Glasgow, Dallas
283{
284  UINT16 data;
285  data=0x0300;
286  key_low=readinputport(0x00);
287  key_hi=readinputport(0x01);
288//logerror("Keyboard Offset = %x Data = %x\n  ",offset,data);
289  if (key_select==key_low){data=data&0x100;}
290  if (key_select==key_hi){data=data&0x200;}
291  return data;
292}
293 
294static READ16_HANDLER(read_newkeys16)  //Amsterdam, Roma
295{
296 UINT16 data;
297 
298 if (key_selector==0) data=readinputport(0x00);else data=readinputport(0x01);
299 logerror("read Keyboard Offset = %x Data = %x   Select = %x \n  ",offset,data,key_selector);
300 data=data<<8;
301 return data ;
302}
303 
304static READ16_HANDLER(read_board)
305{
306     UINT8 i_18, i_AH;
307     UINT16 data;
308 
309     data = 0xff;
310 
311      for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
312         {
313 
314// Looking for cleared bit in Line18 -> current line
315//
316      if ( !(Line18_REED & (1<<i_18)) )
317           {
318 
319// if there is a piece on the field -> set bit in data
320//
321           for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
322            {
323               if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
324               {
325                  data &= ~(1 << i_AH);  // clear bit
326               }
327            }
328         }
329       }
330 
331         data = data<<8;
332 
333      read_board_flag = TRUE;
334 
335      logerror("read_board_data = %x \n  ", data);
336 
337 
338//     return 0xff00;   // Mephisto need it for working
339 
340 
341      return data;
342 
343}
344 
345static WRITE16_HANDLER(write_beeper)
346{
347//  logerror("Write Board   = %x \n  ",data>>8);
348 
349    UINT8 i_AH, i_18;
350    UINT16 LineAH = 0;
351 
352   UINT8 LED;
353 
354 
355//    logerror("Write Board   = %x \n  ",data);
356 
357    LineAH = data>>8;
358 
359   if (LineAH && Line18_LED)
360   {
361 
362//  logerror("Line18_LED   = %x \n  ",Line18_LED);
363//  logerror("LineAH   = %x \n  ",LineAH);
364 
365      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
366      {
367 
368         if ( LineAH & (1<<i_AH) )
369            {
370            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
371            {
372               if ( !(Line18_LED & (1<<i_18)) )
373                  {
374 
375//                  logerror("i_18   = %d \n  ",i_18);
376//                  logerror("i_AH   = %d \n  ",i_AH);
377//                  logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
378 
379                        LED = m_board[i_18][i_AH].field;
380 
381                        output_set_led_value( LED, 1 );
382 
383//  LED on
384                  }
385               else
386                  {
387//  LED off
388 
389                     } // End IF 18
390            } // End For 18
391           } // End IF AH
392 
393      } // End For AH
394 
395   } // End IF LineAH
396 
397   else
398   {
399//  No LED  -> all LED's off
400      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
401         {
402         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
403            {
404// LED off
405                 LED = m_board[i_18][i_AH].field;
406                 output_set_led_value( LED, 0 );
407 
408             } //End For 18
409         } // End For AH
410 
411   } //End ELSE LineAH
412 
413}
414 
415/*
416static READ16_HANDLER(read_test)
417{
418  logerror("read test Offset = %x Data = %x\n  ",offset,data);
419  return 0xffff;    // Mephisto need it for working
420}
421 
422*/
423 
424/*
425 
426    *****           32 Bit Read and write Handler   ***********
427 
428*/
429 
430static WRITE32_HANDLER ( write_lcd32 )
431{
432  UINT8 lcd_data;
433  lcd_data = data>>8;
434  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
435  lcd_shift_counter--;
436  lcd_shift_counter&=3;
437  //logerror("LCD Offset = %d Data   = %x \n  ",offset,lcd_data);
438}
439static WRITE32_HANDLER ( write_lcd_flag32 )
440{
441  UINT8 lcd_flag;
442  lcd_invert=0;
443  lcd_flag=data>>24;
444  if (lcd_flag == 0) key_selector=1;
445  logerror("LCD Flag 32  = %x \n  ",lcd_flag);
446  //beep_set_state(0,lcd_flag&1?1:0);
447  if (lcd_flag!=0) led7=255;else led7=0;
448}
449 
450 
451static WRITE32_HANDLER ( write_keys32 )
452{
453 lcd_invert=1;
454 key_select=data;
455 logerror("Write Key = %x \n  ",key_select);
456}
457 
458static READ32_HANDLER(read_newkeys32) // Dallas 32, Roma 32
459{
460 UINT32 data;
461 if (key_selector==0) data=readinputport(0x00);else data=readinputport(0x01);
462 //if (key_selector==1) data=readinputport(0x00);else data=0;
463 logerror("read Keyboard Offset = %x Data = %x\n  ",offset,data);
464 data=data<<24;
465 return data ;
466}
467 
468 
469 
470static READ32_HANDLER(read_board32)
471{
472  logerror("read board 32 Offset = %x \n  ",offset);
473  return 0x00000000;
474}
475 
476 
477 
478static WRITE32_HANDLER(write_board32)
479{
480 UINT8 board;
481 board=data>>24;
482 if (board==0xff) key_selector=0;
483 logerror("Write Board   = %x \n  ",data);
484}
485 
486 
487static WRITE32_HANDLER ( write_beeper32 )
488{
489  beep_set_state(0,data&0x01000000);
490 logerror("Write 0x8000004   = %x \n  ",data);
491 irq_flag=1;
492 beeper=data;
493}
494 
495static TIMER_CALLBACK( update_nmi )
496{
497   // if (irq_flag==0)cpunum_set_input_line_and_vector(0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
498   cpunum_set_input_line_and_vector(0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
499 
500}
501 
502static TIMER_CALLBACK( update_nmi32 )
503{
504   cpunum_set_input_line_and_vector(0,  MC68020_IRQ_7, PULSE_LINE, MC68020_INT_ACK_AUTOVECTOR);
505}
506 
507static MACHINE_START( glasgow )
508{
509  key_selector=0;
510  irq_flag=0;
511  lcd_shift_counter=3;
512   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi);
513  beep_set_frequency(0, 44);
514}
515 
516 
517static MACHINE_START( dallas32 )
518{
519  lcd_shift_counter=3;
520 
521   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi32);
522  beep_set_frequency(0, 44);
523}
524 
525 
526static MACHINE_RESET( glasgow )
527{
528   lcd_shift_counter=3;
529 
530    clear_layout();
531    set_render_board();
532    set_status_of_pieces();
533}
534 
535 
536 
537static VIDEO_START( glasgow )
538{
539}
540 
541static VIDEO_UPDATE( glasgow )
542{
543//  INT32 lg_x, lg_y;
544//    UINT8 p_key;
545 
546    char *piece;
547 
548   float save_x, save_y;
549 
550   my_target = render_get_ui_target();
551 
552// Get view item of cursor
553//
554//   my_cursor = my_target->curview->itemlist[3]->next;
555   if (my_cursor == NULL)
556      my_cursor = get_view_item(my_target,"CURSOR_1");
557 
558//  my_cursor = my_target->curview->itemlist[2];
559 
560// Mouse movement
561//
562   if (my_cursor != NULL)
563      set_cursor (my_cursor);
564 
565   m_button1=readinputport(0x04);
566    m_button2=readinputport(0x05);
567 
568    if ( m_button1) MOUSE_BUTTON1_WAIT = 0;
569 
570    if ( m_button1 != 1 && !MOUSE_BUTTON1_WAIT )
571      {
572 
573         MOUSE_BUTTON1_WAIT = 1;
574 
575         if (MOUSE_MOVE == 0)
576            {
577 
578            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
579            if ( strcmp((char *)cursor_field.piece, "0") && (strcmp((char *)cursor_field.piece, EMP))  && strcmp(my_cursor->name, (char *)cursor_field.piece ) )
580               {
581               update_board(my_target,cursor_field, 0);
582 
583               my_cursor->color.a = 0;
584 
585               my_cursor = get_view_item(my_target, (char *)cursor_field.piece);
586               my_cursor->color.a = 0.5;
587 
588               MOUSE_MOVE = 1;
589 
590               }
591            } // ENDIF MOUSE_MOVE
592         else
593            {
594 
595            save_x = my_cursor->rawbounds.x0;
596            save_y = my_cursor->rawbounds.y0;
597 
598            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
599            if ( strcmp((char *)cursor_field.piece, "0") && strcmp(my_cursor->name, "CURSOR_1") )
600               {
601 
602// Put piece back to board
603//
604                 strcpy((char *)cursor_field.piece, (char *)my_cursor->name);
605               update_board(my_target,cursor_field, 1);
606               my_cursor->color.a = 1;
607 
608// Set piece to field
609//
610               calculate_bounds(my_cursor, (float) cursor_field.x, (float) cursor_field.y, 0 ,0  );
611 
612 
613// Get old cursor and set new x,y
614//
615               my_cursor = get_view_item(my_target,"CURSOR_1");
616               my_cursor->color.a = 1;
617 
618               calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_Y  );
619 
620               MOUSE_MOVE = 0;
621 
622               }//ENDIF curosr_field
623 
624// piece is set out of board -> remove it
625//
626        if  ( out_of_board(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0) )
627         {
628 
629         save_x = my_cursor->rawbounds.x0;
630         save_y = my_cursor->rawbounds.y0;
631 
632            my_cursor->color.a = 0;
633         my_cursor = get_view_item(my_target,"CURSOR_1");
634         my_cursor->color.a = 1;
635         calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_X  );
636 
637         MOUSE_MOVE = 0;
638         }
639 
640         }//ELSE MOUSE_MOVE
641 
642       } // ENDIF m_button1
643 
644 
645// right mouse button -> set pieces
646//
647   if ( m_button2) MOUSE_BUTTON2_WAIT = 0;
648    if ( m_button2 != 1 && !MOUSE_BUTTON2_WAIT )
649      {
650 
651      MOUSE_BUTTON2_WAIT = 1;
652 
653// save cursor position
654//
655      save_x = my_cursor->rawbounds.x0;
656      save_y = my_cursor->rawbounds.y0;
657 
658// cursor off
659//
660      my_cursor->color.a = 0;
661 
662// change cursor to piece
663//
664        piece = get_non_set_pieces(my_cursor->name);
665 
666      if (strcmp(piece,NO_PIECE))
667         {
668         my_cursor = get_view_item(my_target,piece);
669         my_cursor->color.a = 0.5;
670 
671         calculate_bounds(my_cursor, save_x, save_y, 0 ,0  );
672 
673         MOUSE_MOVE = 1;
674         }
675      else
676         {
677           my_cursor = get_view_item(my_target,"CURSOR_1");
678         my_cursor->color.a = 1;
679            calculate_bounds(my_cursor, save_x, save_y, MOUSE_X ,MOUSE_X  );
680         MOUSE_MOVE = 0;
681         }
682 
683      }
684 
685// Put Item back to render
686//
687    render_set_ui_target (my_target);
688 
689      return 0;
690}
691 
692 
693static ADDRESS_MAP_START(glasgow_mem, ADDRESS_SPACE_PROGRAM, 16)
694   AM_RANGE( 0x0000, 0xffff ) AM_ROM
695   AM_RANGE( 0x00ff0000, 0x00ff0001)  AM_MIRROR ( 0xfe0000 ) AM_WRITE     ( write_lcd_gg )
696  AM_RANGE( 0x00ff0002, 0x00ff0003)  AM_MIRROR ( 0xfe0002 ) AM_READWRITE ( read_keys,write_keys )
697  AM_RANGE( 0x00ff0004, 0x00ff0005)  AM_MIRROR ( 0xfe0004 ) AM_WRITE     ( write_lcd_flag_gg )
698  AM_RANGE( 0x00ff0006, 0x00ff0007)  AM_MIRROR ( 0xfe0006 ) AM_READWRITE ( read_board, write_beeper )
699  AM_RANGE( 0x00ff0008, 0x00ff0009)  AM_MIRROR ( 0xfe0008 ) AM_WRITE     ( write_board )
700  AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_MIRROR ( 0xfeC000 ) AM_RAM      // 16KB
701ADDRESS_MAP_END
702 
703 
704static ADDRESS_MAP_START(amsterd_mem, ADDRESS_SPACE_PROGRAM, 16)
705   // ADDRESS_MAP_FLAGS( AMEF_ABITS(19) )
706    AM_RANGE( 0x0000, 0xffff )         AM_ROM
707    AM_RANGE( 0x00800002, 0x00800003)  AM_WRITE( write_lcd )
708    AM_RANGE( 0x00800008, 0x00800009)  AM_WRITE( write_lcd_flag )
709    AM_RANGE( 0x00800004, 0x00800005)  AM_WRITE( write_irq_flag )
710    AM_RANGE( 0x00800010, 0x00800011)  AM_WRITE( write_board )
711    AM_RANGE( 0x00800020, 0x00800021)  AM_READ ( read_board )
712    AM_RANGE( 0x00800040, 0x00800041)  AM_READ ( read_newkeys16 )
713    AM_RANGE( 0x00800088, 0x00800089)  AM_WRITE( write_beeper )
714    AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_RAM      // 16KB
715ADDRESS_MAP_END
716 
717 
718static ADDRESS_MAP_START(dallas32_mem, ADDRESS_SPACE_PROGRAM, 32)
719     //ADDRESS_MAP_FLAGS( AMEF_ABITS(17) )
720     AM_RANGE( 0x0000, 0xffff )        AM_ROM
721     AM_RANGE( 0x00800000, 0x00800003) AM_WRITE ( write_lcd32 )
722     AM_RANGE( 0x00800004, 0x00800007) AM_WRITE ( write_beeper32 )
723     AM_RANGE( 0x00800008, 0x0080000B) AM_WRITE ( write_lcd_flag32 )
724     AM_RANGE( 0x00800010, 0x00800013) AM_WRITE ( write_board32 )
725     AM_RANGE( 0x00800020, 0x00800023) AM_READ  ( read_board32 )
726     AM_RANGE( 0x00800040, 0x00800043) AM_READ  ( read_newkeys32 )
727     AM_RANGE( 0x00800088, 0x0080008b) AM_WRITE ( write_keys32 )
728     AM_RANGE( 0x0010000, 0x001FFFF)   AM_RAM      // 64KB
729ADDRESS_MAP_END
730 
731static INPUT_PORTS_START( new_keyboard ) //Amsterdam, Dallas 32, Roma, Roma 32
732  PORT_START
733  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A )
734  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B )
735  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C )
736  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D )
737  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E )
738  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F )
739  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_1 )
740  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_2 )
741  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_3 )
742  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_4 )
743  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_5 )
744  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_6 )
745  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_9 )
746  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_0 )
747  PORT_START
748  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
749  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
750  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3 )
751  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4 )
752  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLR") PORT_CODE(KEYCODE_F5 )
753  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
754  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G )
755  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H )
756  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_7 )
757  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_8 )
758INPUT_PORTS_END
759 
760 
761 
762static INPUT_PORTS_START( old_keyboard )   //Glasgow,Dallas
763  PORT_START
764    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_9 )
765    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CL")  PORT_CODE(KEYCODE_F5 )
766    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C )
767    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_3 )
768    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
769    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D )
770    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_4 )
771    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A )
772    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_1 )
773    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F )
774    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_6 )
775    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B )
776    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_2 )
777  PORT_START
778    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E )
779    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_5 )
780    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
781    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_0 )
782    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
783    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H )
784    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_8 )
785    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3)
786    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G )
787    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_7 )
788    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
789 
790      PORT_START
791   PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X)  PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
792 
793    PORT_START
794   PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
795 
796   PORT_START
797   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
798 
799      PORT_START
800   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
801 
802 
803INPUT_PORTS_END
804 
805 
806 
807static MACHINE_DRIVER_START(glasgow )
808    /* basic machine hardware */
809    MDRV_CPU_ADD_TAG("main", M68000, 12000000)
810     MDRV_CPU_PROGRAM_MAP(glasgow_mem, 0)
811     MDRV_MACHINE_START( glasgow )
812     MDRV_MACHINE_RESET( glasgow )
813    /* video hardware */
814    MDRV_SCREEN_REFRESH_RATE(60)
815    MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
816 
817    MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
818    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
819    MDRV_SCREEN_SIZE(640, 480)
820    MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
821    MDRV_PALETTE_LENGTH(4)
822 
823    MDRV_DEFAULT_LAYOUT(layout_glasgow)
824    MDRV_SPEAKER_STANDARD_MONO("mono")
825     MDRV_SOUND_ADD(BEEP, 0)
826     MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
827    MDRV_VIDEO_START(glasgow)
828    MDRV_VIDEO_UPDATE(glasgow)
829MACHINE_DRIVER_END
830 
831 
832static MACHINE_DRIVER_START(amsterd )
833   MDRV_IMPORT_FROM( glasgow )
834   /* basic machine hardware */
835   MDRV_CPU_MODIFY("main")
836   MDRV_CPU_PROGRAM_MAP(amsterd_mem, 0)
837MACHINE_DRIVER_END
838 
839 
840static MACHINE_DRIVER_START(dallas32 )
841   MDRV_IMPORT_FROM( glasgow )
842   /* basic machine hardware */
843   MDRV_CPU_REPLACE("main", M68020, 14000000)
844   MDRV_CPU_PROGRAM_MAP(dallas32_mem, 0)
845   MDRV_MACHINE_START( dallas32 )
846MACHINE_DRIVER_END
847 
848 
849/***************************************************************************
850  ROM definitions
851***************************************************************************/
852 
853ROM_START( glasgow )
854    ROM_REGION( 0x10000, REGION_CPU1, 0 )
855    //ROM_LOAD("glasgow.rom", 0x000000, 0x10000, CRC(3e73eff3) )
856    ROM_LOAD16_BYTE("me3_3_1u.410",0x00000, 0x04000,CRC(bc8053ba) SHA1(57ea2d5652bfdd77b17d52ab1914de974bd6be12))
857    ROM_LOAD16_BYTE("me3_1_1l.410",0x00001, 0x04000,CRC(d5263c39) SHA1(1bef1cf3fd96221eb19faecb6ec921e26ac10ac4))
858    ROM_LOAD16_BYTE("me3_4_2u.410",0x08000, 0x04000,CRC(8dba504a) SHA1(6bfab03af835cdb6c98773164d32c76520937efe))
859    ROM_LOAD16_BYTE("me3_2_2l.410",0x08001, 0x04000,CRC(b3f27827) SHA1(864ba897d24024592d08c4ae090aa70a2cc5f213))
860ROM_END
861 
862ROM_START( amsterd )
863    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
864    //ROM_LOAD16_BYTE("output.bin", 0x000000, 0x10000, CRC(3e73eff3) )
865    ROM_LOAD16_BYTE("amsterda-u.bin",0x00000, 0x05a00,CRC(16cefe29) SHA1(9f8c2896e92fbfd47159a59cb5e87706092c86f4))
866    ROM_LOAD16_BYTE("amsterda-l.bin",0x00001, 0x05a00,CRC(c859dfde) SHA1(b0bca6a8e698c322a8c597608db6735129d6cdf0))
867ROM_END
868 
869 
870ROM_START( dallas )
871    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
872    ROM_LOAD16_BYTE("dal_g_pr.dat",0x00000, 0x04000,CRC(66deade9) SHA1(07ec6b923f2f053172737f1fc94aec84f3ea8da1))
873    ROM_LOAD16_BYTE("dal_g_pl.dat",0x00001, 0x04000,CRC(c5b6171c) SHA1(663167a3839ed7508ecb44fd5a1b2d3d8e466763))
874    ROM_LOAD16_BYTE("dal_g_br.dat",0x08000, 0x04000,CRC(e24d7ec7) SHA1(a936f6fcbe9bfa49bf455f2d8a8243d1395768c1))
875    ROM_LOAD16_BYTE("dal_g_bl.dat",0x08001, 0x04000,CRC(144a15e2) SHA1(c4fcc23d55fa5262f5e01dbd000644a7feb78f32))
876ROM_END
877 
878ROM_START( dallas16 )
879    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
880    ROM_LOAD16_BYTE("dallas-u.bin",0x00000, 0x06f00,CRC(8c1462b4) SHA1(8b5f5a774a835446d08dceacac42357b9e74cfe8))
881    ROM_LOAD16_BYTE("dallas-l.bin",0x00001, 0x06f00,CRC(f0d5bc03) SHA1(4b1b9a71663d5321820b4cf7da205e5fe5d3d001))
882ROM_END
883 
884ROM_START( roma )
885    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
886    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd))
887ROM_END
888 
889ROM_START( dallas32 )
890    ROM_REGION( 0x10000, REGION_CPU1, 0 )
891    ROM_LOAD("dallas32.epr", 0x000000, 0x10000, CRC(83b9ff3f) SHA1(97bf4cb3c61f8ec328735b3c98281bba44b30a28) )
892ROM_END
893 
894ROM_START( roma32 )
895    ROM_REGION( 0x10000, REGION_CPU1, 0 )
896    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd) )
897ROM_END
898 
899/***************************************************************************
900  System config
901***************************************************************************/
902 
903 
904 
905/***************************************************************************
906  Game drivers
907***************************************************************************/
908 
909/*     YEAR, NAME,     PARENT,   BIOS, COMPAT MACHINE,INPUT,          INIT,     CONFIG, COMPANY,                      FULLNAME,                 FLAGS */
910CONS(  1984, glasgow,  0,        0,    glasgow,       old_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto III S Glasgow", 0)
911CONS(  1984, amsterd,  0,        0,    amsterd,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Amsterdam",     0)
912CONS(  1984, dallas,   0,        0,    glasgow,       old_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas",        0)
913CONS(  1984, roma,     0,        0,    glasgow,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Roma",          0)
914CONS(  1984, dallas32, 0,        0,    dallas32,      new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 32 Bit", 0)
915CONS(  1984, roma32,   0,        0,    dallas32,      new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Roma 32 Bit",   0)
916CONS(  1984, dallas16, 0,        0,    amsterd,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 16 Bit", 0)
917 
918 
919 
920static void set_cursor (view_item *view_cursor)
921  {
922 
923   static INT16 save_x, save_y;
924   static float diff_x, diff_y, del_x, del_y;
925 
926    save_x = m_x;
927   save_y = m_y;
928 
929    m_x=readinputport(0x02);
930    m_y=readinputport(0x03);
931 
932//    logerror("m_x   = %d \n  ",m_x);
933//    logerror("m_y   = %d \n  ",m_y);
934 
935    diff_x = (float) (save_x - m_x) / MOUSE_SPEED;
936    diff_y = (float) (save_y - m_y) / MOUSE_SPEED;
937 
938    del_x = view_cursor->rawbounds.x1 - view_cursor->rawbounds.x0;
939    del_y = view_cursor->rawbounds.y1 - view_cursor->rawbounds.y0;
940 
941// Set Cursor, depending on limits
942//
943      view_cursor->rawbounds.x0 =   view_cursor->rawbounds.x0 - diff_x;
944 
945      if ( view_cursor->rawbounds.x0 > MAX_CURSOR_X )
946           view_cursor->rawbounds.x0 = MAX_CURSOR_X;
947 
948     if ( view_cursor->rawbounds.x0 < MIN_CURSOR_X )
949           view_cursor->rawbounds.x0 = MIN_CURSOR_X;
950 
951      view_cursor->rawbounds.y0 =   view_cursor->rawbounds.y0 - diff_y;
952 
953      if ( view_cursor->rawbounds.y0 > MAX_CURSOR_Y )
954           view_cursor->rawbounds.y0 = MAX_CURSOR_Y;
955 
956     if ( view_cursor->rawbounds.y0 < MIN_CURSOR_Y )
957         view_cursor->rawbounds.y0 = MIN_CURSOR_Y;
958 
959      view_cursor->rawbounds.x1 = view_cursor->rawbounds.x0 + del_x;
960      view_cursor->rawbounds.y1 = view_cursor->rawbounds.y0 + del_y;
961 
962// Calculate bounds
963//
964     view_cursor->bounds.x0 = view_cursor->rawbounds.x0 / MAX_X;
965     view_cursor->bounds.y0 = view_cursor->rawbounds.y0 / MAX_Y;
966     view_cursor->bounds.x1 = view_cursor->rawbounds.x1 / MAX_X;
967     view_cursor->bounds.y1 = view_cursor->rawbounds.y1 / MAX_Y;
968 
969  }
970 
971//render_target *render_target_get_indexed
972 
973 
974view_item *get_view_item(render_target *target, const char *v_name)
975{
976 
977 view_item *cur_view;
978 cur_view = target->curview->itemlist[3]->next;
979 
980 for (; cur_view != NULL; cur_view = cur_view->next)
981 {
982   if (!strcmp(cur_view->name, v_name))
983      {
984      return (cur_view);
985      }
986 }
987 
988return (NULL);
989}
990 
991 
992BOARD_FIELD get_field( float i_x, float i_y, UINT8 mouse_move)
993{
994UINT8 i_AH, i_18;
995float corr_x, corr_y;
996 
997 
998float f_x, f_y;
999 
1000BOARD_FIELD null_board  = { 0,0,0,"0"};
1001 
1002 
1003// Correction of mouse pointer
1004//
1005     if (!mouse_move)
1006      {
1007      corr_x = i_x+29.0;
1008      corr_y = i_y+22.0;
1009      }else
1010       {
1011      corr_x = i_x+28;
1012      corr_y = i_y+28;
1013      }
1014 
1015// Loop über alle Spalten
1016      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1017      {
1018 
1019            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1020            {
1021             f_x =   (float) m_board [i_18] [i_AH].x;
1022             f_y =   (float) m_board [i_18] [i_AH].y;
1023 
1024                if (   ( corr_x >= f_x  && corr_x <= f_x+56 ) && ( corr_y >= f_y  && corr_y <= f_y+56 ) )
1025             {
1026             return (m_board [i_18] [i_AH]);
1027             }
1028 
1029            }
1030      }
1031 
1032return (null_board);
1033}
1034 
1035 
1036static unsigned int out_of_board( float x0, float y0)
1037{
1038 
1039   if ( ( x0 >= MIN_BOARD_X  && x0 <= MAX_BOARD_X ) && ( y0 >= MIN_BOARD_Y  && y0 <= MAX_BOARD_Y ) )
1040      {
1041      return (0);
1042      }
1043   else
1044      {
1045      return (1);
1046      }
1047}
1048 
1049 
1050 
1051static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag)
1052{
1053 
1054   UINT8 i_18, i_AH;
1055 
1056   view_item *view_item;
1057 
1058   div_t div_result;
1059 
1060   div_result = div(board_field.field, 8);
1061 
1062   i_18 = div_result.quot;
1063   i_AH = 7 - div_result.rem;
1064 
1065   if (update_clear_flag)
1066   {
1067// there is already a piece on target field - > set it invisible
1068//
1069      view_item = get_view_item(target, (char *)m_board[i_18][i_AH].piece);
1070      if (view_item != NULL)
1071         {
1072         view_item->color.a = 0;
1073         }
1074      strcpy ((char *)&m_board[i_18][i_AH].piece[0], (char *)&board_field.piece[0]);
1075   }else
1076   {
1077      strcpy ((char *)m_board[i_18][i_AH].piece, EMP);
1078   }
1079 
1080   set_status_of_pieces();
1081 
1082}
1083 
1084 static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y )
1085  {
1086 
1087   static float del_x, del_y;
1088 
1089      if (new_del_x)
1090      {
1091      del_x = new_del_x;
1092      }
1093     else
1094      {
1095      del_x = view_item->rawbounds.x1 - view_item->rawbounds.x0;
1096      }
1097 
1098      if (new_del_y)
1099      {
1100      del_y = new_del_y;
1101      }
1102     else
1103      {
1104      del_y = view_item->rawbounds.y1 - view_item->rawbounds.y0;
1105      }
1106 
1107      view_item->rawbounds.x0 = new_x0;
1108      view_item->rawbounds.y0 = new_y0;
1109      view_item->rawbounds.x1 = view_item->rawbounds.x0 + del_x;
1110      view_item->rawbounds.y1 = view_item->rawbounds.y0 + del_y;
1111 
1112// Calculate bounds
1113//
1114     view_item->bounds.x0 = view_item->rawbounds.x0 / MAX_X;
1115     view_item->bounds.y0 = view_item->rawbounds.y0 / MAX_Y;
1116     view_item->bounds.x1 = view_item->rawbounds.x1 / MAX_X;
1117     view_item->bounds.y1 = view_item->rawbounds.y1 / MAX_Y;
1118 
1119  }
1120 
1121 
1122static void set_render_board()
1123   {
1124 
1125    view_item *view_item;
1126    UINT8 i_AH, i_18;
1127 
1128   my_target = render_get_ui_target();
1129 
1130 
1131    for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1132      {
1133         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1134         {
1135 
1136// copy start postition to m_board
1137//
1138            m_board[i_18][i_AH] = start_board [i_18] [i_AH];
1139 
1140// Get view item of this piece
1141//
1142         if (strcmp((char *)m_board[i_18][i_AH].piece, EMP))
1143            {
1144            view_item = get_view_item(my_target, (char *)m_board[i_18][i_AH].piece);
1145 
1146// change all pieces
1147//
1148            if (view_item != NULL)
1149               {
1150               calculate_bounds(view_item, m_board[i_18][i_AH].x, m_board[i_18][i_AH].y, 0, 0 );
1151               view_item->color.a = 1.0;
1152               }//ENDIF view_item
1153 
1154            } // ENDIF strcmp
1155         }// FOR i_18
1156      }// FOR i_AH
1157 
1158    render_set_ui_target (my_target);
1159 
1160   }
1161 
1162static void clear_layout()
1163   {
1164 
1165    view_item *view_item;
1166    UINT8 i;
1167 
1168   my_target = render_get_ui_target();
1169 
1170   for ( i = 0; i < 44; i = i + 1)
1171      {
1172         view_item = get_view_item(my_target,(char *)all_pieces[i].piece);
1173       if (view_item != NULL)
1174         {
1175         view_item->color.a = 0.0;
1176         }
1177      }
1178 
1179    render_set_ui_target (my_target);
1180 
1181   }
1182 
1183 
1184 
1185static void set_status_of_pieces()
1186   {
1187 
1188    UINT8 i_AH, i_18 , i;
1189    BOARD_FIELD field;
1190 
1191 
1192   for ( i = 0; i < 47; i = i + 1)
1193      {
1194 
1195        all_pieces[i].set = 0;
1196 
1197       for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1198         {
1199         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1200            {
1201 
1202// set status depending piece is in game or not
1203//
1204            field = m_board[i_18][i_AH];
1205 
1206            if (!strcmp((char *)m_board[i_18][i_AH].piece, (char *) all_pieces[i].piece))
1207               {
1208               all_pieces[i].set = 1;
1209               break;
1210               }
1211 
1212            } // END for i_18=0
1213 
1214         if (all_pieces[i].set) break;
1215 
1216         }// END for i_AH=0
1217      } // END for i=0
1218 
1219   }
1220 
1221 
1222static char *get_non_set_pieces(const char *cur_piece)
1223{
1224   UINT8 i=0;
1225 
1226   do
1227      {
1228 
1229      start_i = start_i+1;
1230      if ( start_i ==  44) start_i = 0;
1231 
1232 
1233       if (!all_pieces[start_i].set && ( all_pieces[start_i].piece[0] != cur_piece[0] ||
1234                                        all_pieces[start_i].piece[1] != cur_piece[1]) )
1235           {
1236         return ((char *)&all_pieces[start_i].piece[0]);
1237         }
1238 
1239      i=i+1;
1240}
1241   while (i != 44);
1242 
1243   return (NO_PIECE);
1244}
1245 
1246 
1/***************************************************************************
2Mephisto Glasgow 3 S chess computer
3Dirk V.
4sp_rinter@gmx.de
5
668000 CPU
764 KB ROM
816 KB RAM
94 Digit LC Display
10
113* 74LS138  Decoder/Multiplexer
121*74LS74    Dual positive edge triggered D Flip Flop
131*74LS139 1of4 Demultiplexer
141*74LS05    HexInverter
151*NE555     R=100K C=10uF
162*74LS04  Hex Inverter
171*74LS164   8 Bit Shift register
181*74121 Monostable Multivibrator with Schmitt Trigger Inputs
191*74LS20 Dual 4 Input NAND GAte
201*74LS367 3 State Hex Buffers
21
22
23***************************************************************************/
24
25#include "driver.h"
26#include "cpu/m68000/m68k.h"
27#include "cpu/m68000/m68000.h"
28#include "glasgow.lh"
29#include "sound/beep.h"
30
31#include "render.h"
32#include "rendlay.h"
33
34static UINT8 lcd_shift_counter;
35// static UINT8 led_status;
36static UINT8 led7;
37static UINT8 key_low,
38       key_hi,
39       key_select,
40       irq_flag,
41       lcd_invert,
42       key_selector;
43       UINT8 board_value;
44static UINT16 beeper;
45
46
47  #define MOUSE_X      56
48  #define MOUSE_Y      56
49  #define MAX_X         530
50  #define MAX_Y         660
51  #define MOUSE_SPEED   3
52
53  #define MIN_BOARD_X   60.0
54  #define MAX_BOARD_X   480.0
55
56  #define MIN_BOARD_Y   60.0
57  #define MAX_BOARD_Y   480.0
58
59  #define MIN_CURSOR_X   -10
60  #define MAX_CURSOR_X   496
61
62  #define MIN_CURSOR_Y   0
63  #define MAX_CURSOR_Y   622
64
65  static INT16 m_x, m_y;
66  static UINT8 m_button1 , m_button2;
67  static UINT8 MOUSE_MOVE = 0;
68  static UINT8 MOUSE_BUTTON1_WAIT = 0;
69  static UINT8 MOUSE_BUTTON2_WAIT = 0;
70
71  static UINT16 Line18_LED;
72  static UINT16 Line18_REED;
73
74  static UINT8 read_board_flag;
75
76  static  char EMP[4] = "EMP";
77  static  char NO_PIECE[4]  = "NOP";
78
79
80  typedef struct {
81       unsigned int field;
82      unsigned int x;
83      unsigned int y;
84       unsigned char piece[4];
85  } BOARD_FIELD;
86
87
88   #define WR   12
89   #define WB   13
90   #define WKN   14
91   #define WQ   15
92   #define WK   16
93
94   #define BP   21
95   #define BR   22
96   #define BB   23
97   #define BKN   24
98   #define BQ   25
99   #define BK   26
100
101
102
103    BOARD_FIELD m_board[8][8];
104
105    BOARD_FIELD start_board[8][8] =
106   {
107      { { 7,44,434,"WR1"}, { 6,100,434,"WN1"}, { 5,156,434,"WB1"}, { 4,212,434,"WQ1"}, { 3,268,434,"WK"}, { 2,324,434,"WB2"}, { 1,380,434,"WN2"}, { 0,436,434,"WR2"} },
108      { {15,44,378,"WP1"}, {14,100,378,"WP2"}, {13,156,378,"WP3"}, {12,212,378,"WP4"}, {11,268,378,"WP5"}, {10,324,378,"WP6"}, { 9,380,378,"WP7"}, { 8,436,378,"WP8"} },
109
110      { {23,44,322, "EMP"}, {22,100,322, "EMP"}, {21,156,322, "EMP"}, {20,212,322, "EMP"}, {19,268,322, "EMP"}, {18,324,322, "EMP"}, {17,380,322, "EMP"}, {16,436,322, "EMP"} },
111      { {31,44,266, "EMP"}, {30,100,266, "EMP"}, {29,156,266, "EMP"}, {28,212,266, "EMP"}, {27,268,266, "EMP"}, {26,324,266, "EMP"}, {25,380,266, "EMP"}, {24,436,266, "EMP"} },
112      { {39,44,210, "EMP"}, {38,100,210, "EMP"}, {37,156,210, "EMP"}, {36,212,210, "EMP"}, {35,268,210, "EMP"}, {34,324,210, "EMP"}, {33,380,210, "EMP"}, {32,436,210, "EMP"} },
113      { {47,44,154, "EMP"}, {46,100,154, "EMP"}, {45,156,154, "EMP"}, {44,212,154, "EMP"}, {43,268,154, "EMP"}, {42,324,154, "EMP"}, {41,380,154, "EMP"}, {40,436,154, "EMP"} },
114
115      { {55,44,100,"BP1"}, {54,100,100,"BP2"}, {53,156,100,"BP3"}, {52,212,100,"BP4"}, {51,268,100,"BP5"}, {50,324,100,"BP6"}, {49,380,100,"BP7"}, {48,436,100,"BP8"} },
116      { {63,44,44 ,"BR1"}, {62,100,44 ,"BN1"}, {61,156,44 ,"BB1"}, {60,212,44 ,"BQ1"}, {59,268,44 ,"BK"}, {58,324,44 ,"BB2"}, {57,380,44 ,"BN2"}, {56,436,44 ,"BR2"} }
117
118   };
119
120
121   static BOARD_FIELD cursor_field;
122
123
124     typedef struct {
125       unsigned char piece[4];
126      unsigned int selected;
127      unsigned int set;
128  } P_STATUS;
129
130
131    static P_STATUS all_pieces[48] =
132    {
133       {"WR1",0,0}, {"WN1",0,0},{"WB1",0,0}, {"WQ1",0,0},  {"WK",0,0},  {"WB2",0,0}, {"WN2",0,0}, {"WR2",0,0},
134       {"WP1",0,0}, {"WP2",0,0},{"WP3",0,0}, {"WP4",0,0}, {"WP5",0,0},  {"WP6",0,0}, {"WP7",0,0}, {"WP8",0,0},
135
136
137      {"BP1",0,0}, {"BP2",0,0},{"BP3",0,0}, {"BP4",0,0}, {"BP5",0,0},  {"BP6",0,0}, {"BP7",0,0}, {"BP8",0,0},
138       {"BR1",0,0}, {"BN1",0,0},{"BB1",0,0}, {"BQ1",0,0},  {"BK",0,0},  {"BB2",0,0}, {"BN2",0,0}, {"BR2",0,0},
139
140
141        {"BQ2",0,0}, {"BQ3",0,0}, {"BQ4",0,0}, {"BQ5",0,0}, {"BQ6",0,0}, {"BQ7",0,0},
142
143
144      {"WQ2",0,0}, {"WQ3",0,0}, {"WQ4",0,0}, {"WQ5",0,0}, {"WQ6",0,0}, {"WQ7",0,0}
145
146    };
147
148     static UINT8 start_i;
149
150
151  struct _render_target
152{
153   render_target *      next;            /* keep a linked list of targets */
154   layout_view *      curview;         /* current view */
155   layout_file *      filelist;         /* list of layout files */
156   UINT32            flags;            /* creation flags */
157   render_primitive_list primlist[2];/* list of primitives */
158   int               listindex;         /* index of next primlist to use */
159   INT32            width;            /* width in pixels */
160   INT32            height;            /* height in pixels */
161   render_bounds      bounds;            /* bounds of the target */
162   float            pixel_aspect;      /* aspect ratio of individual pixels */
163   float            max_refresh;      /* maximum refresh rate, 0 or if none */
164   int               orientation;      /* orientation */
165   int               layerconfig;      /* layer configuration */
166   layout_view *      base_view;         /* the view at the time of first frame */
167   int               base_orientation;   /* the orientation at the time of first frame */
168   int               base_layerconfig;   /* the layer configuration at the time of first frame */
169   int               maxtexwidth;      /* maximum width of a texture */
170   int               maxtexheight;      /* maximum height of a texture */
171};
172
173  static render_target *my_target;
174
175  static view_item *my_cursor;
176
177  static void set_cursor (view_item *view_cursor);
178
179  static view_item *get_view_item(render_target *target, const char *v_name);
180
181  static BOARD_FIELD  get_field( float i_x, float i_y, UINT8 mouse_move);
182  static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag);
183
184  static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y );
185
186  static void set_render_board(void);
187  static void clear_layout(void);
188  static void set_status_of_pieces(void);
189
190  static char * get_non_set_pieces(const char *cur_piece);
191
192  static unsigned int out_of_board( float x0, float y0);
193
194
195
196// Used by Glasgow and Dallas
197static WRITE16_HANDLER ( write_lcd_gg )
198{
199  UINT8 lcd_data;
200  lcd_data = data>>8;
201  if (led7==0) output_set_digit_value(lcd_shift_counter,lcd_data);
202  lcd_shift_counter--;
203  lcd_shift_counter&=3;
204//  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
205}
206
207static WRITE16_HANDLER ( write_lcd )
208{
209  UINT8 lcd_data;
210  lcd_data = data>>8;
211  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
212  lcd_shift_counter--;
213  lcd_shift_counter&=3;
214//  logerror("LCD Offset = %d Data low  = %x \n  ",offset,lcd_data);
215}
216static WRITE16_HANDLER ( write_lcd_flag )
217{
218  UINT8 lcd_flag;
219  lcd_invert=0;
220  lcd_flag=data>>8;
221  //beep_set_state(0,lcd_flag&1?1:0);
222  if (lcd_flag == 0) key_selector=1;
223  if (lcd_flag!=0) led7=255;else led7=0;
224//  logerror("LCD Flag 16  = %x \n  ",data);
225}
226
227
228static WRITE16_HANDLER ( write_lcd_flag_gg )
229{
230  UINT8 lcd_flag;
231  lcd_flag=data>>8;
232  beep_set_state(0,lcd_flag&1?1:0);
233  if (lcd_flag == 0) key_selector=1;
234  if (lcd_flag!=0) led7=255;else led7=0;
235
236//  logerror("LCD Flag gg  = %x \n  ",lcd_flag);
237}
238
239static WRITE16_HANDLER ( write_keys )
240{
241 key_select=data>>8;
242// logerror("Write Key   = %x \n  ",data);
243}
244
245static WRITE16_HANDLER ( write_board )
246{
247UINT8 beep_flag;
248
249Line18_REED=data>>8;
250
251// LED's or REED's ?
252//
253if (read_board_flag)
254   {
255   Line18_LED=0;
256   read_board_flag=0;
257   }
258else
259   {
260   Line18_LED=data>>8;
261   }
262
263//logerror("write_board Line18_LED   = %x \n  ", Line18_LED);
264//logerror("write_board Line18_REED   = %x \n  ",Line18_REED);
265
266lcd_invert=1;
267beep_flag=data>>8;
268//if ((beep_flag &02)== 0) key_selector=0;else key_selector=1;
269//logerror("Write Beeper   = %x \n  ",data);
270 beeper=data;
271}
272
273static WRITE16_HANDLER ( write_irq_flag )
274{
275
276 beep_set_state(0,data&0x100);
277 logerror("Write 0x800004   = %x \n  ",data);
278 irq_flag=1;
279 beeper=data;
280}
281
282static READ16_HANDLER(read_keys) // Glasgow, Dallas
283{
284  UINT16 data;
285  data=0x0300;
286  key_low=readinputport(0x00);
287  key_hi=readinputport(0x01);
288//logerror("Keyboard Offset = %x Data = %x\n  ",offset,data);
289  if (key_select==key_low){data=data&0x100;}
290  if (key_select==key_hi){data=data&0x200;}
291  return data;
292}
293
294static READ16_HANDLER(read_newkeys16)  //Amsterdam, Roma
295{
296 UINT16 data;
297
298 if (key_selector==0) data=readinputport(0x00);else data=readinputport(0x01);
299 logerror("read Keyboard Offset = %x Data = %x   Select = %x \n  ",offset,data,key_selector);
300 data=data<<8;
301 return data ;
302}
303
304static READ16_HANDLER(read_board)
305{
306     UINT8 i_18, i_AH;
307     UINT16 data;
308
309     data = 0xff;
310
311      for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
312         {
313
314// Looking for cleared bit in Line18 -> current line
315//
316      if ( !(Line18_REED & (1<<i_18)) )
317           {
318
319// if there is a piece on the field -> set bit in data
320//
321           for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
322            {
323               if (strcmp ((char *)m_board[i_18][i_AH].piece, EMP))
324               {
325                  data &= ~(1 << i_AH);  // clear bit
326               }
327            }
328         }
329       }
330
331         data = data<<8;
332
333      read_board_flag = TRUE;
334
335      logerror("read_board_data = %x \n  ", data);
336
337
338//     return 0xff00;   // Mephisto need it for working
339
340
341      return data;
342
343}
344
345static WRITE16_HANDLER(write_beeper)
346{
347//  logerror("Write Board   = %x \n  ",data>>8);
348
349    UINT8 i_AH, i_18;
350    UINT16 LineAH = 0;
351
352   UINT8 LED;
353
354
355//    logerror("Write Board   = %x \n  ",data);
356
357    LineAH = data>>8;
358
359   if (LineAH && Line18_LED)
360   {
361
362//  logerror("Line18_LED   = %x \n  ",Line18_LED);
363//  logerror("LineAH   = %x \n  ",LineAH);
364
365      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
366      {
367
368         if ( LineAH & (1<<i_AH) )
369            {
370            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
371            {
372               if ( !(Line18_LED & (1<<i_18)) )
373                  {
374
375//                  logerror("i_18   = %d \n  ",i_18);
376//                  logerror("i_AH   = %d \n  ",i_AH);
377//                  logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
378
379                        LED = m_board[i_18][i_AH].field;
380
381                        output_set_led_value( LED, 1 );
382
383//  LED on
384                  }
385               else
386                  {
387//  LED off
388
389                     } // End IF 18
390            } // End For 18
391           } // End IF AH
392
393      } // End For AH
394
395   } // End IF LineAH
396
397   else
398   {
399//  No LED  -> all LED's off
400      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
401         {
402         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
403            {
404// LED off
405                 LED = m_board[i_18][i_AH].field;
406                 output_set_led_value( LED, 0 );
407
408             } //End For 18
409         } // End For AH
410
411   } //End ELSE LineAH
412
413}
414
415/*
416static READ16_HANDLER(read_test)
417{
418  logerror("read test Offset = %x Data = %x\n  ",offset,data);
419  return 0xffff;    // Mephisto need it for working
420}
421
422*/
423
424/*
425
426    *****           32 Bit Read and write Handler   ***********
427
428*/
429
430static WRITE32_HANDLER ( write_lcd32 )
431{
432  UINT8 lcd_data;
433  lcd_data = data>>8;
434  output_set_digit_value(lcd_shift_counter,lcd_invert&1?lcd_data^0xff:lcd_data);
435  lcd_shift_counter--;
436  lcd_shift_counter&=3;
437  //logerror("LCD Offset = %d Data   = %x \n  ",offset,lcd_data);
438}
439static WRITE32_HANDLER ( write_lcd_flag32 )
440{
441  UINT8 lcd_flag;
442  lcd_invert=0;
443  lcd_flag=data>>24;
444  if (lcd_flag == 0) key_selector=1;
445  logerror("LCD Flag 32  = %x \n  ",lcd_flag);
446  //beep_set_state(0,lcd_flag&1?1:0);
447  if (lcd_flag!=0) led7=255;else led7=0;
448}
449
450
451static WRITE32_HANDLER ( write_keys32 )
452{
453 lcd_invert=1;
454 key_select=data;
455 logerror("Write Key = %x \n  ",key_select);
456}
457
458static READ32_HANDLER(read_newkeys32) // Dallas 32, Roma 32
459{
460 UINT32 data;
461 if (key_selector==0) data=readinputport(0x00);else data=readinputport(0x01);
462 //if (key_selector==1) data=readinputport(0x00);else data=0;
463 logerror("read Keyboard Offset = %x Data = %x\n  ",offset,data);
464 data=data<<24;
465 return data ;
466}
467
468
469
470static READ32_HANDLER(read_board32)
471{
472  logerror("read board 32 Offset = %x \n  ",offset);
473  return 0x00000000;
474}
475
476
477
478static WRITE32_HANDLER(write_board32)
479{
480 UINT8 board;
481 board=data>>24;
482 if (board==0xff) key_selector=0;
483 logerror("Write Board   = %x \n  ",data);
484}
485
486
487static WRITE32_HANDLER ( write_beeper32 )
488{
489  beep_set_state(0,data&0x01000000);
490 logerror("Write 0x8000004   = %x \n  ",data);
491 irq_flag=1;
492 beeper=data;
493}
494
495static TIMER_CALLBACK( update_nmi )
496{
497   // if (irq_flag==0)cpunum_set_input_line_and_vector(0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
498   cpunum_set_input_line_and_vector(0,  MC68000_IRQ_7, PULSE_LINE, MC68000_INT_ACK_AUTOVECTOR);
499
500}
501
502static TIMER_CALLBACK( update_nmi32 )
503{
504   cpunum_set_input_line_and_vector(0,  MC68020_IRQ_7, PULSE_LINE, MC68020_INT_ACK_AUTOVECTOR);
505}
506
507static MACHINE_START( glasgow )
508{
509  key_selector=0;
510  irq_flag=0;
511  lcd_shift_counter=3;
512   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi);
513  beep_set_frequency(0, 44);
514}
515
516
517static MACHINE_START( dallas32 )
518{
519  lcd_shift_counter=3;
520
521   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi32);
522  beep_set_frequency(0, 44);
523}
524
525
526static MACHINE_RESET( glasgow )
527{
528   lcd_shift_counter=3;
529
530    clear_layout();
531    set_render_board();
532    set_status_of_pieces();
533}
534
535
536
537static VIDEO_START( glasgow )
538{
539}
540
541static VIDEO_UPDATE( glasgow )
542{
543//  INT32 lg_x, lg_y;
544//    UINT8 p_key;
545
546    char *piece;
547
548   float save_x, save_y;
549
550   my_target = render_get_ui_target();
551
552// Get view item of cursor
553//
554//   my_cursor = my_target->curview->itemlist[3]->next;
555   if (my_cursor == NULL)
556      my_cursor = get_view_item(my_target,"CURSOR_1");
557
558//  my_cursor = my_target->curview->itemlist[2];
559
560// Mouse movement
561//
562   if (my_cursor != NULL)
563      set_cursor (my_cursor);
564
565   m_button1=readinputport(0x04);
566    m_button2=readinputport(0x05);
567
568    if ( m_button1) MOUSE_BUTTON1_WAIT = 0;
569
570    if ( m_button1 != 1 && !MOUSE_BUTTON1_WAIT )
571      {
572
573         MOUSE_BUTTON1_WAIT = 1;
574
575         if (MOUSE_MOVE == 0)
576            {
577
578            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
579            if ( strcmp((char *)cursor_field.piece, "0") && (strcmp((char *)cursor_field.piece, EMP))  && strcmp(my_cursor->name, (char *)cursor_field.piece ) )
580               {
581               update_board(my_target,cursor_field, 0);
582
583               my_cursor->color.a = 0;
584
585               my_cursor = get_view_item(my_target, (char *)cursor_field.piece);
586               my_cursor->color.a = 0.5;
587
588               MOUSE_MOVE = 1;
589
590               }
591            } // ENDIF MOUSE_MOVE
592         else
593            {
594
595            save_x = my_cursor->rawbounds.x0;
596            save_y = my_cursor->rawbounds.y0;
597
598            cursor_field = get_field(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0, MOUSE_MOVE);
599            if ( strcmp((char *)cursor_field.piece, "0") && strcmp(my_cursor->name, "CURSOR_1") )
600               {
601
602// Put piece back to board
603//
604                 strcpy((char *)cursor_field.piece, (char *)my_cursor->name);
605               update_board(my_target,cursor_field, 1);
606               my_cursor->color.a = 1;
607
608// Set piece to field
609//
610               calculate_bounds(my_cursor, (float) cursor_field.x, (float) cursor_field.y, 0 ,0  );
611
612
613// Get old cursor and set new x,y
614//
615               my_cursor = get_view_item(my_target,"CURSOR_1");
616               my_cursor->color.a = 1;
617
618               calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_Y  );
619
620               MOUSE_MOVE = 0;
621
622               }//ENDIF curosr_field
623
624// piece is set out of board -> remove it
625//
626        if  ( out_of_board(my_cursor->rawbounds.x0,my_cursor->rawbounds.y0) )
627         {
628
629         save_x = my_cursor->rawbounds.x0;
630         save_y = my_cursor->rawbounds.y0;
631
632            my_cursor->color.a = 0;
633         my_cursor = get_view_item(my_target,"CURSOR_1");
634         my_cursor->color.a = 1;
635         calculate_bounds(my_cursor, save_x, save_y,MOUSE_X ,MOUSE_X  );
636
637         MOUSE_MOVE = 0;
638         }
639
640         }//ELSE MOUSE_MOVE
641
642       } // ENDIF m_button1
643
644
645// right mouse button -> set pieces
646//
647   if ( m_button2) MOUSE_BUTTON2_WAIT = 0;
648    if ( m_button2 != 1 && !MOUSE_BUTTON2_WAIT )
649      {
650
651      MOUSE_BUTTON2_WAIT = 1;
652
653// save cursor position
654//
655      save_x = my_cursor->rawbounds.x0;
656      save_y = my_cursor->rawbounds.y0;
657
658// cursor off
659//
660      my_cursor->color.a = 0;
661
662// change cursor to piece
663//
664        piece = get_non_set_pieces(my_cursor->name);
665
666      if (strcmp(piece,NO_PIECE))
667         {
668         my_cursor = get_view_item(my_target,piece);
669         my_cursor->color.a = 0.5;
670
671         calculate_bounds(my_cursor, save_x, save_y, 0 ,0  );
672
673         MOUSE_MOVE = 1;
674         }
675      else
676         {
677           my_cursor = get_view_item(my_target,"CURSOR_1");
678         my_cursor->color.a = 1;
679            calculate_bounds(my_cursor, save_x, save_y, MOUSE_X ,MOUSE_X  );
680         MOUSE_MOVE = 0;
681         }
682
683      }
684
685// Put Item back to render
686//
687    render_set_ui_target (my_target);
688
689      return 0;
690}
691
692
693static ADDRESS_MAP_START(glasgow_mem, ADDRESS_SPACE_PROGRAM, 16)
694   AM_RANGE( 0x0000, 0xffff ) AM_ROM
695   AM_RANGE( 0x00ff0000, 0x00ff0001)  AM_MIRROR ( 0xfe0000 ) AM_WRITE     ( write_lcd_gg )
696  AM_RANGE( 0x00ff0002, 0x00ff0003)  AM_MIRROR ( 0xfe0002 ) AM_READWRITE ( read_keys,write_keys )
697  AM_RANGE( 0x00ff0004, 0x00ff0005)  AM_MIRROR ( 0xfe0004 ) AM_WRITE     ( write_lcd_flag_gg )
698  AM_RANGE( 0x00ff0006, 0x00ff0007)  AM_MIRROR ( 0xfe0006 ) AM_READWRITE ( read_board, write_beeper )
699  AM_RANGE( 0x00ff0008, 0x00ff0009)  AM_MIRROR ( 0xfe0008 ) AM_WRITE     ( write_board )
700  AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_MIRROR ( 0xfeC000 ) AM_RAM      // 16KB
701ADDRESS_MAP_END
702
703
704static ADDRESS_MAP_START(amsterd_mem, ADDRESS_SPACE_PROGRAM, 16)
705   // ADDRESS_MAP_FLAGS( AMEF_ABITS(19) )
706    AM_RANGE( 0x0000, 0xffff )         AM_ROM
707    AM_RANGE( 0x00800002, 0x00800003)  AM_WRITE( write_lcd )
708    AM_RANGE( 0x00800008, 0x00800009)  AM_WRITE( write_lcd_flag )
709    AM_RANGE( 0x00800004, 0x00800005)  AM_WRITE( write_irq_flag )
710    AM_RANGE( 0x00800010, 0x00800011)  AM_WRITE( write_board )
711    AM_RANGE( 0x00800020, 0x00800021)  AM_READ ( read_board )
712    AM_RANGE( 0x00800040, 0x00800041)  AM_READ ( read_newkeys16 )
713    AM_RANGE( 0x00800088, 0x00800089)  AM_WRITE( write_beeper )
714    AM_RANGE( 0x00ffC000, 0x00ffFFFF)  AM_RAM      // 16KB
715ADDRESS_MAP_END
716
717
718static ADDRESS_MAP_START(dallas32_mem, ADDRESS_SPACE_PROGRAM, 32)
719     //ADDRESS_MAP_FLAGS( AMEF_ABITS(17) )
720     AM_RANGE( 0x0000, 0xffff )        AM_ROM
721     AM_RANGE( 0x00800000, 0x00800003) AM_WRITE ( write_lcd32 )
722     AM_RANGE( 0x00800004, 0x00800007) AM_WRITE ( write_beeper32 )
723     AM_RANGE( 0x00800008, 0x0080000B) AM_WRITE ( write_lcd_flag32 )
724     AM_RANGE( 0x00800010, 0x00800013) AM_WRITE ( write_board32 )
725     AM_RANGE( 0x00800020, 0x00800023) AM_READ  ( read_board32 )
726     AM_RANGE( 0x00800040, 0x00800043) AM_READ  ( read_newkeys32 )
727     AM_RANGE( 0x00800088, 0x0080008b) AM_WRITE ( write_keys32 )
728     AM_RANGE( 0x0010000, 0x001FFFF)   AM_RAM      // 64KB
729ADDRESS_MAP_END
730
731static INPUT_PORTS_START( new_keyboard ) //Amsterdam, Dallas 32, Roma, Roma 32
732  PORT_START
733  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A )
734  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B )
735  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C )
736  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D )
737  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E )
738  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F )
739  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_1 )
740  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_2 )
741  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_3 )
742  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_4 )
743  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_5 )
744  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_6 )
745  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_9 )
746  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_0 )
747  PORT_START
748  PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
749  PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
750  PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3 )
751  PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4 )
752  PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLR") PORT_CODE(KEYCODE_F5 )
753  PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
754  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G )
755  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H )
756  PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_7 )
757  PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_8 )
758INPUT_PORTS_END
759
760
761
762static INPUT_PORTS_START( old_keyboard )   //Glasgow,Dallas
763  PORT_START
764    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9")   PORT_CODE(KEYCODE_9 )
765    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CL")  PORT_CODE(KEYCODE_F5 )
766    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_C )
767    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C3")  PORT_CODE(KEYCODE_3 )
768    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENT") PORT_CODE(KEYCODE_ENTER )
769    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_D )
770    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D4")  PORT_CODE(KEYCODE_4 )
771    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_A )
772    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A1")  PORT_CODE(KEYCODE_1 )
773    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_F )
774    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6")  PORT_CODE(KEYCODE_6 )
775    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_B )
776    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B2")  PORT_CODE(KEYCODE_2 )
777  PORT_START
778    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_E )
779    PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E5")  PORT_CODE(KEYCODE_5 )
780    PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INF") PORT_CODE(KEYCODE_F1 )
781    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0")   PORT_CODE(KEYCODE_0 )
782    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("POS") PORT_CODE(KEYCODE_F2 )
783    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_H )
784    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H8")  PORT_CODE(KEYCODE_8 )
785    PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEV") PORT_CODE(KEYCODE_F3)
786    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_G )
787    PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G7")  PORT_CODE(KEYCODE_7 )
788    PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MEM") PORT_CODE(KEYCODE_F4)
789
790      PORT_START
791   PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X)  PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
792
793    PORT_START
794   PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 65535)    PORT_PLAYER(1)
795
796   PORT_START
797   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
798
799      PORT_START
800   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
801
802
803INPUT_PORTS_END
804
805
806
807static MACHINE_DRIVER_START(glasgow )
808    /* basic machine hardware */
809    MDRV_CPU_ADD_TAG("main", M68000, 12000000)
810     MDRV_CPU_PROGRAM_MAP(glasgow_mem, 0)
811     MDRV_MACHINE_START( glasgow )
812     MDRV_MACHINE_RESET( glasgow )
813    /* video hardware */
814    MDRV_SCREEN_REFRESH_RATE(60)
815    MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
816
817    MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
818    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
819    MDRV_SCREEN_SIZE(640, 480)
820    MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
821    MDRV_PALETTE_LENGTH(4)
822
823    MDRV_DEFAULT_LAYOUT(layout_glasgow)
824    MDRV_SPEAKER_STANDARD_MONO("mono")
825     MDRV_SOUND_ADD(BEEP, 0)
826     MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
827    MDRV_VIDEO_START(glasgow)
828    MDRV_VIDEO_UPDATE(glasgow)
829MACHINE_DRIVER_END
830
831
832static MACHINE_DRIVER_START(amsterd )
833   MDRV_IMPORT_FROM( glasgow )
834   /* basic machine hardware */
835   MDRV_CPU_MODIFY("main")
836   MDRV_CPU_PROGRAM_MAP(amsterd_mem, 0)
837MACHINE_DRIVER_END
838
839
840static MACHINE_DRIVER_START(dallas32 )
841   MDRV_IMPORT_FROM( glasgow )
842   /* basic machine hardware */
843   MDRV_CPU_REPLACE("main", M68020, 14000000)
844   MDRV_CPU_PROGRAM_MAP(dallas32_mem, 0)
845   MDRV_MACHINE_START( dallas32 )
846MACHINE_DRIVER_END
847
848
849/***************************************************************************
850  ROM definitions
851***************************************************************************/
852
853ROM_START( glasgow )
854    ROM_REGION( 0x10000, REGION_CPU1, 0 )
855    //ROM_LOAD("glasgow.rom", 0x000000, 0x10000, CRC(3e73eff3) )
856    ROM_LOAD16_BYTE("me3_3_1u.410",0x00000, 0x04000,CRC(bc8053ba) SHA1(57ea2d5652bfdd77b17d52ab1914de974bd6be12))
857    ROM_LOAD16_BYTE("me3_1_1l.410",0x00001, 0x04000,CRC(d5263c39) SHA1(1bef1cf3fd96221eb19faecb6ec921e26ac10ac4))
858    ROM_LOAD16_BYTE("me3_4_2u.410",0x08000, 0x04000,CRC(8dba504a) SHA1(6bfab03af835cdb6c98773164d32c76520937efe))
859    ROM_LOAD16_BYTE("me3_2_2l.410",0x08001, 0x04000,CRC(b3f27827) SHA1(864ba897d24024592d08c4ae090aa70a2cc5f213))
860ROM_END
861
862ROM_START( amsterd )
863    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
864    //ROM_LOAD16_BYTE("output.bin", 0x000000, 0x10000, CRC(3e73eff3) )
865    ROM_LOAD16_BYTE("amsterda-u.bin",0x00000, 0x05a00,CRC(16cefe29) SHA1(9f8c2896e92fbfd47159a59cb5e87706092c86f4))
866    ROM_LOAD16_BYTE("amsterda-l.bin",0x00001, 0x05a00,CRC(c859dfde) SHA1(b0bca6a8e698c322a8c597608db6735129d6cdf0))
867ROM_END
868
869
870ROM_START( dallas )
871    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
872    ROM_LOAD16_BYTE("dal_g_pr.dat",0x00000, 0x04000,CRC(66deade9) SHA1(07ec6b923f2f053172737f1fc94aec84f3ea8da1))
873    ROM_LOAD16_BYTE("dal_g_pl.dat",0x00001, 0x04000,CRC(c5b6171c) SHA1(663167a3839ed7508ecb44fd5a1b2d3d8e466763))
874    ROM_LOAD16_BYTE("dal_g_br.dat",0x08000, 0x04000,CRC(e24d7ec7) SHA1(a936f6fcbe9bfa49bf455f2d8a8243d1395768c1))
875    ROM_LOAD16_BYTE("dal_g_bl.dat",0x08001, 0x04000,CRC(144a15e2) SHA1(c4fcc23d55fa5262f5e01dbd000644a7feb78f32))
876ROM_END
877
878ROM_START( dallas16 )
879    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
880    ROM_LOAD16_BYTE("dallas-u.bin",0x00000, 0x06f00,CRC(8c1462b4) SHA1(8b5f5a774a835446d08dceacac42357b9e74cfe8))
881    ROM_LOAD16_BYTE("dallas-l.bin",0x00001, 0x06f00,CRC(f0d5bc03) SHA1(4b1b9a71663d5321820b4cf7da205e5fe5d3d001))
882ROM_END
883
884ROM_START( roma )
885    ROM_REGION16_BE( 0x1000000, REGION_CPU1, 0 )
886    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd))
887ROM_END
888
889ROM_START( dallas32 )
890    ROM_REGION( 0x10000, REGION_CPU1, 0 )
891    ROM_LOAD("dallas32.epr", 0x000000, 0x10000, CRC(83b9ff3f) SHA1(97bf4cb3c61f8ec328735b3c98281bba44b30a28) )
892ROM_END
893
894ROM_START( roma32 )
895    ROM_REGION( 0x10000, REGION_CPU1, 0 )
896    ROM_LOAD("roma32.bin", 0x000000, 0x10000, CRC(587d03bf) SHA1(504e9ff958084700076d633f9c306fc7baf64ffd) )
897ROM_END
898
899/***************************************************************************
900  System config
901***************************************************************************/
902
903
904
905/***************************************************************************
906  Game drivers
907***************************************************************************/
908
909/*     YEAR, NAME,     PARENT,   BIOS, COMPAT MACHINE,INPUT,          INIT,     CONFIG, COMPANY,                      FULLNAME,                 FLAGS */
910CONS(  1984, glasgow,  0,        0,    glasgow,       old_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto III S Glasgow", 0)
911CONS(  1984, amsterd,  0,        0,    amsterd,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Amsterdam",     0)
912CONS(  1984, dallas,   0,        0,    glasgow,       old_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas",        0)
913CONS(  1984, roma,     0,        0,    glasgow,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Roma",          0)
914CONS(  1984, dallas32, 0,        0,    dallas32,      new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 32 Bit", 0)
915CONS(  1984, roma32,   0,        0,    dallas32,      new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Roma 32 Bit",   0)
916CONS(  1984, dallas16, 0,        0,    amsterd,       new_keyboard,   NULL,     NULL,   "Hegener & Glaser Muenchen",  "Mephisto Dallas 16 Bit", 0)
917
918
919
920static void set_cursor (view_item *view_cursor)
921  {
922
923   static INT16 save_x, save_y;
924   static float diff_x, diff_y, del_x, del_y;
925
926    save_x = m_x;
927   save_y = m_y;
928
929    m_x=readinputport(0x02);
930    m_y=readinputport(0x03);
931
932//    logerror("m_x   = %d \n  ",m_x);
933//    logerror("m_y   = %d \n  ",m_y);
934
935    diff_x = (float) (save_x - m_x) / MOUSE_SPEED;
936    diff_y = (float) (save_y - m_y) / MOUSE_SPEED;
937
938    del_x = view_cursor->rawbounds.x1 - view_cursor->rawbounds.x0;
939    del_y = view_cursor->rawbounds.y1 - view_cursor->rawbounds.y0;
940
941// Set Cursor, depending on limits
942//
943      view_cursor->rawbounds.x0 =   view_cursor->rawbounds.x0 - diff_x;
944
945      if ( view_cursor->rawbounds.x0 > MAX_CURSOR_X )
946           view_cursor->rawbounds.x0 = MAX_CURSOR_X;
947
948     if ( view_cursor->rawbounds.x0 < MIN_CURSOR_X )
949           view_cursor->rawbounds.x0 = MIN_CURSOR_X;
950
951      view_cursor->rawbounds.y0 =   view_cursor->rawbounds.y0 - diff_y;
952
953      if ( view_cursor->rawbounds.y0 > MAX_CURSOR_Y )
954           view_cursor->rawbounds.y0 = MAX_CURSOR_Y;
955
956     if ( view_cursor->rawbounds.y0 < MIN_CURSOR_Y )
957         view_cursor->rawbounds.y0 = MIN_CURSOR_Y;
958
959      view_cursor->rawbounds.x1 = view_cursor->rawbounds.x0 + del_x;
960      view_cursor->rawbounds.y1 = view_cursor->rawbounds.y0 + del_y;
961
962// Calculate bounds
963//
964     view_cursor->bounds.x0 = view_cursor->rawbounds.x0 / MAX_X;
965     view_cursor->bounds.y0 = view_cursor->rawbounds.y0 / MAX_Y;
966     view_cursor->bounds.x1 = view_cursor->rawbounds.x1 / MAX_X;
967     view_cursor->bounds.y1 = view_cursor->rawbounds.y1 / MAX_Y;
968
969  }
970
971//render_target *render_target_get_indexed
972
973
974view_item *get_view_item(render_target *target, const char *v_name)
975{
976
977 view_item *cur_view;
978 cur_view = target->curview->itemlist[3]->next;
979
980 for (; cur_view != NULL; cur_view = cur_view->next)
981 {
982   if (!strcmp(cur_view->name, v_name))
983      {
984      return (cur_view);
985      }
986 }
987
988return (NULL);
989}
990
991
992BOARD_FIELD get_field( float i_x, float i_y, UINT8 mouse_move)
993{
994UINT8 i_AH, i_18;
995float corr_x, corr_y;
996
997
998float f_x, f_y;
999
1000BOARD_FIELD null_board  = { 0,0,0,"0"};
1001
1002
1003// Correction of mouse pointer
1004//
1005     if (!mouse_move)
1006      {
1007      corr_x = i_x+29.0;
1008      corr_y = i_y+22.0;
1009      }else
1010       {
1011      corr_x = i_x+28;
1012      corr_y = i_y+28;
1013      }
1014
1015// Loop über alle Spalten
1016      for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1017      {
1018
1019            for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1020            {
1021             f_x =   (float) m_board [i_18] [i_AH].x;
1022             f_y =   (float) m_board [i_18] [i_AH].y;
1023
1024                if (   ( corr_x >= f_x  && corr_x <= f_x+56 ) && ( corr_y >= f_y  && corr_y <= f_y+56 ) )
1025             {
1026             return (m_board [i_18] [i_AH]);
1027             }
1028
1029            }
1030      }
1031
1032return (null_board);
1033}
1034
1035
1036static unsigned int out_of_board( float x0, float y0)
1037{
1038
1039   if ( ( x0 >= MIN_BOARD_X  && x0 <= MAX_BOARD_X ) && ( y0 >= MIN_BOARD_Y  && y0 <= MAX_BOARD_Y ) )
1040      {
1041      return (0);
1042      }
1043   else
1044      {
1045      return (1);
1046      }
1047}
1048
1049
1050
1051static void update_board(render_target *target, BOARD_FIELD board_field, unsigned int update_clear_flag)
1052{
1053
1054   UINT8 i_18, i_AH;
1055
1056   view_item *view_item;
1057
1058   div_t div_result;
1059
1060   div_result = div(board_field.field, 8);
1061
1062   i_18 = div_result.quot;
1063   i_AH = 7 - div_result.rem;
1064
1065   if (update_clear_flag)
1066   {
1067// there is already a piece on target field - > set it invisible
1068//
1069      view_item = get_view_item(target, (char *)m_board[i_18][i_AH].piece);
1070      if (view_item != NULL)
1071         {
1072         view_item->color.a = 0;
1073         }
1074      strcpy ((char *)&m_board[i_18][i_AH].piece[0], (char *)&board_field.piece[0]);
1075   }else
1076   {
1077      strcpy ((char *)m_board[i_18][i_AH].piece, EMP);
1078   }
1079
1080   set_status_of_pieces();
1081
1082}
1083
1084 static void calculate_bounds(view_item *view_item, float new_x0, float new_y0, float new_del_x, float new_del_y )
1085  {
1086
1087   static float del_x, del_y;
1088
1089      if (new_del_x)
1090      {
1091      del_x = new_del_x;
1092      }
1093     else
1094      {
1095      del_x = view_item->rawbounds.x1 - view_item->rawbounds.x0;
1096      }
1097
1098      if (new_del_y)
1099      {
1100      del_y = new_del_y;
1101      }
1102     else
1103      {
1104      del_y = view_item->rawbounds.y1 - view_item->rawbounds.y0;
1105      }
1106
1107      view_item->rawbounds.x0 = new_x0;
1108      view_item->rawbounds.y0 = new_y0;
1109      view_item->rawbounds.x1 = view_item->rawbounds.x0 + del_x;
1110      view_item->rawbounds.y1 = view_item->rawbounds.y0 + del_y;
1111
1112// Calculate bounds
1113//
1114     view_item->bounds.x0 = view_item->rawbounds.x0 / MAX_X;
1115     view_item->bounds.y0 = view_item->rawbounds.y0 / MAX_Y;
1116     view_item->bounds.x1 = view_item->rawbounds.x1 / MAX_X;
1117     view_item->bounds.y1 = view_item->rawbounds.y1 / MAX_Y;
1118
1119  }
1120
1121
1122static void set_render_board()
1123   {
1124
1125    view_item *view_item;
1126    UINT8 i_AH, i_18;
1127
1128   my_target = render_get_ui_target();
1129
1130
1131    for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1132      {
1133         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1134         {
1135
1136// copy start postition to m_board
1137//
1138            m_board[i_18][i_AH] = start_board [i_18] [i_AH];
1139
1140// Get view item of this piece
1141//
1142         if (strcmp((char *)m_board[i_18][i_AH].piece, EMP))
1143            {
1144            view_item = get_view_item(my_target, (char *)m_board[i_18][i_AH].piece);
1145
1146// change all pieces
1147//
1148            if (view_item != NULL)
1149               {
1150               calculate_bounds(view_item, m_board[i_18][i_AH].x, m_board[i_18][i_AH].y, 0, 0 );
1151               view_item->color.a = 1.0;
1152               }//ENDIF view_item
1153
1154            } // ENDIF strcmp
1155         }// FOR i_18
1156      }// FOR i_AH
1157
1158    render_set_ui_target (my_target);
1159
1160   }
1161
1162static void clear_layout()
1163   {
1164
1165    view_item *view_item;
1166    UINT8 i;
1167
1168   my_target = render_get_ui_target();
1169
1170   for ( i = 0; i < 44; i = i + 1)
1171      {
1172         view_item = get_view_item(my_target,(char *)all_pieces[i].piece);
1173       if (view_item != NULL)
1174         {
1175         view_item->color.a = 0.0;
1176         }
1177      }
1178
1179    render_set_ui_target (my_target);
1180
1181   }
1182
1183
1184
1185static void set_status_of_pieces()
1186   {
1187
1188    UINT8 i_AH, i_18 , i;
1189    BOARD_FIELD field;
1190
1191
1192   for ( i = 0; i < 47; i = i + 1)
1193      {
1194
1195        all_pieces[i].set = 0;
1196
1197       for ( i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
1198         {
1199         for ( i_18 = 0; i_18 < 8; i_18 = i_18 + 1)
1200            {
1201
1202// set status depending piece is in game or not
1203//
1204            field = m_board[i_18][i_AH];
1205
1206            if (!strcmp((char *)m_board[i_18][i_AH].piece, (char *) all_pieces[i].piece))
1207               {
1208               all_pieces[i].set = 1;
1209               break;
1210               }
1211
1212            } // END for i_18=0
1213
1214         if (all_pieces[i].set) break;
1215
1216         }// END for i_AH=0
1217      } // END for i=0
1218
1219   }
1220
1221
1222static char *get_non_set_pieces(const char *cur_piece)
1223{
1224   UINT8 i=0;
1225
1226   do
1227      {
1228
1229      start_i = start_i+1;
1230      if ( start_i ==  44) start_i = 0;
1231
1232
1233       if (!all_pieces[start_i].set && ( all_pieces[start_i].piece[0] != cur_piece[0] ||
1234                                        all_pieces[start_i].piece[1] != cur_piece[1]) )
1235           {
1236         return ((char *)&all_pieces[start_i].piece[0]);
1237         }
1238
1239      i=i+1;
1240}
1241   while (i != 44);
1242
1243   return (NO_PIECE);
1244}
1245
1246
src/mess/drivers/ex800.c
r1301r1302
1/******************************************************************************
2 Epson EX-800 Dot Matrix printer
3 
4 Written by Dirk Best, October 2007
5 
6 --
7 
8 Main CPU is a UPD7810H6 running at 12 MHz.
9 
10 --
11 
12 On startup, the ports are initialized as follows:
13 
14 Port A lines PA0-PA7 are configured as output
15 Port B lines PB0-PB7 are configured as output
16 Port C lines PC2, PC4 and PC5 are configured as output
17        the other lines are control lines
18        PC0: TxD output
19        PC1: RxD input
20        PC3: TI input
21        PC6: CO0 output
22        PC7: CO1 output
23         
24The I/O lines are connected as follows:         
25 
26PA0: \
27PA1:  Carriage motor
28PA2:  driving pulses
29PA3: /
30PA4: High when carriage assembly reaches either end
31PA5: High when carriage assembly reaches either end
32PA6: Bank 0
33PA7: Bank 1
34 
35PB0: Line feed motor driving pulses
36PB1: Line feed motor driving pulses
37PB2: Line feed motor current control
38PB3: LED09, Online
39PB4: (used for serial port)
40PB5: ERR signal
41PB6: ACKNLG signal, data received at printer
42PB7: LED12, Paper empty
43 
44PC0: TxD output
45PC1: RxD input
46PC2:
47PC3: TI input
48PC4:
49PC5:
50PC6: PWD signal of 5a
51PC7: Buzzer
52 
53PD0-7: Data bus D0-D7
54 
55PF0-7: Address bus A8-A15
56 
57AN0: DSW 2
58AN1: DSW 1
59AN2:
60AN3:
61AN4: Print head operating temperature sensor
62AN5: Scanner Unit, Color Home sensor
63AN6:
64AN7: Color Home sensor adjust
65     
66INT: Online switch     
67 
68 
69Gate array 5a (parallel port, printer head)
70 
71IN0-IN7: DATA1 to DATA8 from parallel port
72HD1-HD9: Head driving pulses
73STROBE: STROBE signal
74PWD: PC6 of CPU
75ALE: ALE of CPU
76 
77Gate array 7a (inputs)
78 
79- activated when carriage assembly reaches either end?
80 
81PA0: Draft switch
82PA1: NLQ Roman switch
83PA2: Pica switch
84PA3: NLQ sans-serif switch
85PA4: Elite switch
86PA5: Proportional switch
87PA6: Normal switch
88PA7: Condensed switch
89 
90PB0: Form feed switch
91PB1: Line feed switch
92PB2: Autoload switch
93PB3: Low when paper empty
94PB4: Low when carriage assembly is in home position
95PB5: SLCTIN (connected to parallel port), disable with DSW2-1
96PB6: AUTO FEEDXT (connected to parallel port), disable with DSW2-4
97       "When this signal is LOW, the paper is automatically fed 1 line after
98        printing."
99PB7:
100 
101PC0: Dipswitch SW1-1 and SW1-2, Draft LED
102PC1: Dipswitch SW1-3 and SW1-4, Roman LED
103PC2: Dipswitch SW1-5 and SW1-6, Pica LED
104PC3: Dipswitch SW1-7 and SW1-8, Sans-Serif LED
105PC4: Dipswitch SW2-2 and SW2-3, Elite LED
106PC5: Dipswitch SW2-5 and SW2-6, Proportional LED
107PC6: Normal LED
108PC7: Condensed LED
109 
110--
111 
112LED state on startup:
113 
114The power light comes on, then draft, pica and normal. If there is no paper,
115the paper empty LED comes on.
116 
117Power LED is green, selectype LED is orange, paper out LED is red.
118 
119--
120 
121TODO:  - The UPD7810 core is missing analog port emulation
122       - Figure out the gate arrays (using trojan code?)
123       - (much later) write an interface so that other drivers can hook
124         into this one and use to print
125 
126 
127******************************************************************************/
128 
129#include "driver.h"
130#include "cpu/upd7810/upd7810.h"
131#include "sound/beep.h"
132 
133#define PA0 (data & 0x01)
134#define PA1 (data & 0x02)
135#define PA2 (data & 0x04)
136#define PA3 (data & 0x08)
137#define PA4 (data & 0x10)
138#define PA5 (data & 0x20)
139#define PA6 (data & 0x40)
140#define PA7 (data & 0x80)
141 
142#define PB0 (data & 0x01)
143#define PB1 (data & 0x02)
144#define PB2 (data & 0x04)
145#define PB3 (data & 0x08)
146#define PB4 (data & 0x10)
147#define PB5 (data & 0x20)
148#define PB6 (data & 0x40)
149#define PB7 (data & 0x80)
150 
151#define PC0 (data & 0x01)
152#define PC1 (data & 0x02)
153#define PC2 (data & 0x04)
154#define PC3 (data & 0x08)
155#define PC4 (data & 0x10)
156#define PC5 (data & 0x20)
157#define PC6 (data & 0x40)
158#define PC7 (data & 0x80)
159 
160 
161/******************************************************************************
162 Misc (will be moved to other files)
163******************************************************************************/
164 
165 
166/* The ON LINE switch is directly connected to the INT1 input of the CPU */
167static void online_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
168{
169   static int state = ASSERT_LINE;
170 
171   if (newvalue)
172   {
173      cpunum_set_input_line(0, UPD7810_INTF1, state);
174      state = (state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE;
175   }
176}
177 
178 
179static void feed_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
180{
181 
182}
183 
184 
185static void selectype_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
186{
187 
188}
189 
190 
191static DRIVER_INIT(ex800)
192{
193   input_port_set_changed_callback(port_tag_to_index("ONLISW"), 0xff, online_switch, NULL);
194   input_port_set_changed_callback(port_tag_to_index("FEED"), 0xff, feed_switch, NULL);
195   input_port_set_changed_callback(port_tag_to_index("SelecType"), 0xff, selectype_switch, NULL);
196}
197 
198 
199static MACHINE_START(ex800)
200{
201   /* Setup beep */
202   beep_set_state(0, 0);
203   beep_set_frequency(0, 4000); /* measured at 4000 hz */   
204}
205 
206 
207#if 0
208static VIDEO_START(ex800)
209{
210}
211 
212 
213static VIDEO_UPDATE(ex800)
214{
215   return 0;
216}
217#endif
218 
219 
220static READ8_HANDLER(ex800_porta_r)
221{
222   logerror("PA R @%x\n", activecpu_get_pc());
223   return mame_rand(Machine);
224}
225 
226static READ8_HANDLER(ex800_portb_r)
227{
228   logerror("PB R @%x\n", activecpu_get_pc());
229   return mame_rand(Machine);
230}
231 
232static READ8_HANDLER(ex800_portc_r)
233{
234   logerror("PC R @%x\n", activecpu_get_pc());
235   return mame_rand(Machine);
236}
237 
238static WRITE8_HANDLER(ex800_porta_w)
239{
240   if (PA6) logerror("BNK0 selected.\n");
241   if (PA7) logerror("BNK1 selected.\n");
242   
243   logerror("PA W %x @%x\n", data, activecpu_get_pc());
244}
245 
246static WRITE8_HANDLER(ex800_portb_w)
247{
248   if (data & 3)
249      logerror("PB0/1 Line feed @%x\n", activecpu_get_pc());
250   if (!(data & 4))
251      logerror("PB2 Line feed @%x\n", activecpu_get_pc());
252   if (data & 8)
253      logerror("PB3 Online LED on @%x\n", activecpu_get_pc());
254   else
255      logerror("PB3 Online LED off @%x\n", activecpu_get_pc());
256   if (data & 16)
257      logerror("PB4 Serial @%x\n", activecpu_get_pc());
258   if (data & 32)
259      logerror("PB4 Serial @%x\n", activecpu_get_pc());
260   if (data & 64)
261      logerror("PB4 Serial @%x\n", activecpu_get_pc());
262   if (data & 128)
263      logerror("PB3 Paper empty LED on @%x\n", activecpu_get_pc());
264   else
265      logerror("PB3 Paper empty LED off @%x\n", activecpu_get_pc());
266   
267//   logerror("PB W %x @%x\n", data, activecpu_get_pc());
268}
269 
270static WRITE8_HANDLER(ex800_portc_w)
271{
272   if (data & 0x80)
273      beep_set_state(0, 0);
274   else
275      beep_set_state(0, 1);
276   
277   logerror("PC W %x @%x\n", data, activecpu_get_pc());
278}
279 
280 
281/* Memory mapped I/O access */
282 
283static READ8_HANDLER(ex800_devsel_r)
284{
285   logerror("DEVSEL R @%x with offset %x\n", activecpu_get_pc(), offset);
286   return mame_rand(Machine);
287}
288 
289static WRITE8_HANDLER(ex800_devsel_w)
290{
291   logerror("DEVSEL W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
292}
293 
294static READ8_HANDLER(ex800_gate5a_r)
295{
296   logerror("GATE5A R @%x with offset %x\n", activecpu_get_pc(), offset);
297   return mame_rand(Machine);
298}
299 
300static WRITE8_HANDLER(ex800_gate5a_w)
301{
302   logerror("GATE5A W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
303}
304 
305static READ8_HANDLER(ex800_iosel_r)
306{
307   logerror("IOSEL R @%x with offset %x\n", activecpu_get_pc(), offset);
308   return mame_rand(Machine);
309}
310 
311static WRITE8_HANDLER(ex800_iosel_w)
312{
313   logerror("IOSEL W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
314}
315 
316static READ8_HANDLER(ex800_gate7a_r)
317{
318   logerror("GATE7A R @%x with offset %x\n", activecpu_get_pc(), offset);
319   return mame_rand(Machine);
320}
321 
322static WRITE8_HANDLER(ex800_gate7a_w)
323{
324   logerror("GATE7A W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
325}
326 
327 
328 
329/******************************************************************************
330 Address Maps
331******************************************************************************/
332 
333 
334static ADDRESS_MAP_START( ex800_mem, ADDRESS_SPACE_PROGRAM, 8 )
335   AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION(REGION_CPU1, 0)
336   AM_RANGE(0x8000, 0xbfff) AM_RAM /* external RAM */
337   AM_RANGE(0xc000, 0xc7ff) AM_MIRROR(0x1800) AM_READWRITE(ex800_devsel_r, ex800_devsel_w)
338   AM_RANGE(0xe000, 0xe7ff) AM_READWRITE(ex800_gate5a_r, ex800_gate5a_w)
339   AM_RANGE(0xe800, 0xefff) AM_READWRITE(ex800_iosel_r, ex800_iosel_w)
340   AM_RANGE(0xf000, 0xf001) AM_MIRROR(0x07fc) AM_READ(ex800_gate7a_r)
341   AM_RANGE(0xf002, 0xf003) AM_MIRROR(0x07fc) AM_WRITE(ex800_gate7a_w)
342   AM_RANGE(0xf800, 0xfeff) AM_NOP /* not connected */
343   AM_RANGE(0xff00, 0xffff) AM_RAM /* internal CPU RAM */
344ADDRESS_MAP_END
345 
346 
347static ADDRESS_MAP_START( ex800_io, ADDRESS_SPACE_IO, 8 )
348   AM_RANGE(UPD7810_PORTA, UPD7810_PORTA) AM_READ(ex800_porta_r) AM_WRITE(ex800_porta_w)
349   AM_RANGE(UPD7810_PORTB, UPD7810_PORTB) AM_READ(ex800_portb_r) AM_WRITE(ex800_portb_w)
350   AM_RANGE(UPD7810_PORTC, UPD7810_PORTC) AM_READ(ex800_portc_r) AM_WRITE(ex800_portc_w)
351ADDRESS_MAP_END
352 
353 
354 
355/******************************************************************************
356 Inputs and DIP switches
357******************************************************************************/
358 
359 
360static INPUT_PORTS_START( ex800 )
361   PORT_START_TAG("ONLISW")
362   PORT_BIT(0xfe, IP_ACTIVE_HIGH, IPT_UNUSED)
363   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON LINE")   PORT_CODE(KEYCODE_F9)
364 
365   PORT_START_TAG("FEED")
366   PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED)
367   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FORM FEED") PORT_CODE(KEYCODE_F10)
368   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_F11)
369   
370   PORT_START_TAG("SelecType")
371   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Draft")          PORT_CODE(KEYCODE_F8)
372   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NLQ Roman")      PORT_CODE(KEYCODE_F7)
373   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Pica")           PORT_CODE(KEYCODE_F6)
374   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NLQ Sans Serif") PORT_CODE(KEYCODE_F5)
375   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Elite")          PORT_CODE(KEYCODE_F4)
376   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Proportional")   PORT_CODE(KEYCODE_F3)
377   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(DEF_STR(Normal))  PORT_CODE(KEYCODE_F2)
378   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Condensed")      PORT_CODE(KEYCODE_F1)
379   
380   PORT_START_TAG("DSW_1")
381   PORT_DIPNAME(0x01, 0x00, "Condensed characters")
382   PORT_DIPSETTING(   0x00, DEF_STR(Off))
383   PORT_DIPSETTING(   0x01, DEF_STR(On))
384   PORT_DIPNAME(0x02, 0x00, "Slashed zero")
385   PORT_DIPSETTING(   0x00, DEF_STR(Off))
386   PORT_DIPSETTING(   0x02, DEF_STR(On))
387   PORT_DIPNAME(0x04, 0x00, "Character table")
388   PORT_DIPSETTING(   0x00, "Italics")
389   PORT_DIPSETTING(   0x04, "Graphics")
390   PORT_DIPNAME(0x08, 0x00, "Printer commands")
391   PORT_DIPSETTING(   0x00, "ESC/P")
392   PORT_DIPSETTING(   0x08, "IBM printer emulation")
393   PORT_DIPNAME(0x10, 0x00, "Print quality")
394   PORT_DIPSETTING(   0x00, "Draft")
395   PORT_DIPSETTING(   0x10, "NLQ")
396   PORT_DIPNAME(0xe0, 0x00, "Int. character set")
397   PORT_DIPSETTING(   0x00, DEF_STR(USA))
398   PORT_DIPSETTING(   0x20, DEF_STR(French))
399   PORT_DIPSETTING(   0x30, DEF_STR(German))
400   PORT_DIPSETTING(   0x40, "UK")
401   PORT_DIPSETTING(   0x50, "Danish")
402   PORT_DIPSETTING(   0x60, "Swedish")
403   PORT_DIPSETTING(   0x70, DEF_STR(Italian))
404   PORT_DIPSETTING(   0x80, DEF_STR(Spanish))
405 
406   PORT_START_TAG("DSW_2")
407   PORT_DIPNAME(0x01, 0x00, "Page length")
408   PORT_DIPSETTING(   0x00, "11 inch")
409   PORT_DIPSETTING(   0x01, "12 inch")
410   PORT_DIPNAME(0x02, 0x00, "Auto. sheet feeder")
411   PORT_DIPSETTING(   0x00, "Canceled")
412   PORT_DIPSETTING(   0x02, "Selected")
413   PORT_DIPNAME(0x04, 0x00, "Skip-over-perforation")
414   PORT_DIPSETTING(   0x00, DEF_STR(None))
415   PORT_DIPSETTING(   0x04, "1 inch")
416   PORT_DIPNAME(0x08, 0x00, "Add LF after CR")
417   PORT_DIPSETTING(   0x00, "CR only")
418   PORT_DIPSETTING(   0x08, "CR + LF")
419   PORT_DIPNAME(0x30, 0x00, "Interface type")
420   PORT_DIPSETTING(   0x00, "Parallel")
421   PORT_DIPSETTING(   0x10, "Serial (odd parity)")
422   PORT_DIPSETTING(   0x20, "Serial (even parity)")
423   PORT_DIPSETTING(   0x30, "Serial (no parity)")
424   PORT_DIPNAME(0xc0, 0x00, "Baud rate")
425   PORT_DIPSETTING(   0x00, "9600")
426   PORT_DIPSETTING(   0x40, "4800")
427   PORT_DIPSETTING(   0x80, "1200")
428   PORT_DIPSETTING(   0xc0, "300")   
429INPUT_PORTS_END
430 
431 
432 
433/******************************************************************************
434 CPU config
435******************************************************************************/
436 
437 
438static UPD7810_CONFIG ex800_cpu_config =
439{
440    TYPE_7810,
441    0
442};
443 
444 
445 
446/******************************************************************************
447 Machine Drivers
448******************************************************************************/
449 
450 
451static MACHINE_DRIVER_START(ex800)
452    /* basic machine hardware */
453    MDRV_CPU_ADD_TAG("main", UPD7810, 12000000)  /* 12 Mhz? */
454    MDRV_CPU_CONFIG(ex800_cpu_config)
455    MDRV_CPU_PROGRAM_MAP(ex800_mem, 0)
456   MDRV_CPU_IO_MAP(ex800_io, 0)
457 
458   MDRV_MACHINE_START(ex800)
459   
460   /* "video" hardware */
461   MDRV_SCREEN_REFRESH_RATE(60)
462   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
463//   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
464//   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
465//   MDRV_SCREEN_SIZE(480, 640)
466//   MDRV_SCREEN_VISIBLE_AREA(0, 479, 0, 639)   
467//   MDRV_PALETTE_LENGTH(4)
468 
469//   MDRV_VIDEO_START(ex800)
470//   MDRV_VIDEO_UPDATE(ex800)
471 
472   /* audio hardware */
473   MDRV_SPEAKER_STANDARD_MONO("mono")
474   MDRV_SOUND_ADD(BEEP, 0)
475   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
476MACHINE_DRIVER_END
477 
478 
479 
480/******************************************************************************
481 ROM Definitions
482******************************************************************************/
483 
484 
485ROM_START( ex800 )
486    ROM_REGION(0x8000, REGION_CPU1, 0)
487   ROM_LOAD("w8_pe9.9b", 0x0000, 0x8000, CRC(6dd41e9b) SHA1(8e30ead727b9317154742efd881206e9f9bbf95b))
488ROM_END
489 
490 
491 
492/******************************************************************************
493 Drivers
494******************************************************************************/
495 
496 
497/*    YEAR  NAME   PARENT  COMPAT  MACHINE INPUT  INIT   CONFIG COMPANY  FULLNAME  FLAGS */
498COMP( 1986, ex800,      0,      0, ex800,  ex800, ex800, NULL,  "Epson", "EX-800", GAME_NO_SOUND | GAME_NOT_WORKING)
1/******************************************************************************
2 Epson EX-800 Dot Matrix printer
3 
4 Written by Dirk Best, October 2007
5 
6 --
7 
8 Main CPU is a UPD7810H6 running at 12 MHz.
9 
10 --
11 
12 On startup, the ports are initialized as follows:
13 
14 Port A lines PA0-PA7 are configured as output
15 Port B lines PB0-PB7 are configured as output
16 Port C lines PC2, PC4 and PC5 are configured as output
17        the other lines are control lines
18        PC0: TxD output
19        PC1: RxD input
20        PC3: TI input
21        PC6: CO0 output
22        PC7: CO1 output
23       
24The I/O lines are connected as follows:       
25
26PA0: \
27PA1:  Carriage motor
28PA2:  driving pulses
29PA3: /
30PA4: High when carriage assembly reaches either end
31PA5: High when carriage assembly reaches either end
32PA6: Bank 0
33PA7: Bank 1
34
35PB0: Line feed motor driving pulses
36PB1: Line feed motor driving pulses
37PB2: Line feed motor current control
38PB3: LED09, Online
39PB4: (used for serial port)
40PB5: ERR signal
41PB6: ACKNLG signal, data received at printer
42PB7: LED12, Paper empty
43
44PC0: TxD output
45PC1: RxD input
46PC2:
47PC3: TI input
48PC4:
49PC5:
50PC6: PWD signal of 5a
51PC7: Buzzer
52
53PD0-7: Data bus D0-D7
54
55PF0-7: Address bus A8-A15
56
57AN0: DSW 2
58AN1: DSW 1
59AN2:
60AN3:
61AN4: Print head operating temperature sensor
62AN5: Scanner Unit, Color Home sensor
63AN6:
64AN7: Color Home sensor adjust
65   
66INT: Online switch   
67
68
69Gate array 5a (parallel port, printer head)
70
71IN0-IN7: DATA1 to DATA8 from parallel port
72HD1-HD9: Head driving pulses
73STROBE: STROBE signal
74PWD: PC6 of CPU
75ALE: ALE of CPU
76
77Gate array 7a (inputs)
78
79- activated when carriage assembly reaches either end?
80
81PA0: Draft switch
82PA1: NLQ Roman switch
83PA2: Pica switch
84PA3: NLQ sans-serif switch
85PA4: Elite switch
86PA5: Proportional switch
87PA6: Normal switch
88PA7: Condensed switch
89
90PB0: Form feed switch
91PB1: Line feed switch
92PB2: Autoload switch
93PB3: Low when paper empty
94PB4: Low when carriage assembly is in home position
95PB5: SLCTIN (connected to parallel port), disable with DSW2-1
96PB6: AUTO FEEDXT (connected to parallel port), disable with DSW2-4
97       "When this signal is LOW, the paper is automatically fed 1 line after
98        printing."
99PB7:
100
101PC0: Dipswitch SW1-1 and SW1-2, Draft LED
102PC1: Dipswitch SW1-3 and SW1-4, Roman LED
103PC2: Dipswitch SW1-5 and SW1-6, Pica LED
104PC3: Dipswitch SW1-7 and SW1-8, Sans-Serif LED
105PC4: Dipswitch SW2-2 and SW2-3, Elite LED
106PC5: Dipswitch SW2-5 and SW2-6, Proportional LED
107PC6: Normal LED
108PC7: Condensed LED
109
110--
111
112LED state on startup:
113
114The power light comes on, then draft, pica and normal. If there is no paper,
115the paper empty LED comes on.
116
117Power LED is green, selectype LED is orange, paper out LED is red.
118
119--
120
121TODO:  - The UPD7810 core is missing analog port emulation
122       - Figure out the gate arrays (using trojan code?)
123       - (much later) write an interface so that other drivers can hook
124         into this one and use to print
125
126
127******************************************************************************/
128
129#include "driver.h"
130#include "cpu/upd7810/upd7810.h"
131#include "sound/beep.h"
132
133#define PA0 (data & 0x01)
134#define PA1 (data & 0x02)
135#define PA2 (data & 0x04)
136#define PA3 (data & 0x08)
137#define PA4 (data & 0x10)
138#define PA5 (data & 0x20)
139#define PA6 (data & 0x40)
140#define PA7 (data & 0x80)
141
142#define PB0 (data & 0x01)
143#define PB1 (data & 0x02)
144#define PB2 (data & 0x04)
145#define PB3 (data & 0x08)
146#define PB4 (data & 0x10)
147#define PB5 (data & 0x20)
148#define PB6 (data & 0x40)
149#define PB7 (data & 0x80)
150
151#define PC0 (data & 0x01)
152#define PC1 (data & 0x02)
153#define PC2 (data & 0x04)
154#define PC3 (data & 0x08)
155#define PC4 (data & 0x10)
156#define PC5 (data & 0x20)
157#define PC6 (data & 0x40)
158#define PC7 (data & 0x80)
159
160
161/******************************************************************************
162 Misc (will be moved to other files)
163******************************************************************************/
164
165
166/* The ON LINE switch is directly connected to the INT1 input of the CPU */
167static void online_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
168{
169   static int state = ASSERT_LINE;
170
171   if (newvalue)
172   {
173      cpunum_set_input_line(0, UPD7810_INTF1, state);
174      state = (state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE;
175   }
176}
177
178
179static void feed_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
180{
181
182}
183
184
185static void selectype_switch(void *param, UINT32 oldvalue, UINT32 newvalue)
186{
187
188}
189
190
191static DRIVER_INIT(ex800)
192{
193   input_port_set_changed_callback(port_tag_to_index("ONLISW"), 0xff, online_switch, NULL);
194   input_port_set_changed_callback(port_tag_to_index("FEED"), 0xff, feed_switch, NULL);
195   input_port_set_changed_callback(port_tag_to_index("SelecType"), 0xff, selectype_switch, NULL);
196}
197
198
199static MACHINE_START(ex800)
200{
201   /* Setup beep */
202   beep_set_state(0, 0);
203   beep_set_frequency(0, 4000); /* measured at 4000 hz */   
204}
205
206
207#if 0
208static VIDEO_START(ex800)
209{
210}
211
212
213static VIDEO_UPDATE(ex800)
214{
215   return 0;
216}
217#endif
218
219
220static READ8_HANDLER(ex800_porta_r)
221{
222   logerror("PA R @%x\n", activecpu_get_pc());
223   return mame_rand(Machine);
224}
225
226static READ8_HANDLER(ex800_portb_r)
227{
228   logerror("PB R @%x\n", activecpu_get_pc());
229   return mame_rand(Machine);
230}
231
232static READ8_HANDLER(ex800_portc_r)
233{
234   logerror("PC R @%x\n", activecpu_get_pc());
235   return mame_rand(Machine);
236}
237
238static WRITE8_HANDLER(ex800_porta_w)
239{
240   if (PA6) logerror("BNK0 selected.\n");
241   if (PA7) logerror("BNK1 selected.\n");
242   
243   logerror("PA W %x @%x\n", data, activecpu_get_pc());
244}
245
246static WRITE8_HANDLER(ex800_portb_w)
247{
248   if (data & 3)
249      logerror("PB0/1 Line feed @%x\n", activecpu_get_pc());
250   if (!(data & 4))
251      logerror("PB2 Line feed @%x\n", activecpu_get_pc());
252   if (data & 8)
253      logerror("PB3 Online LED on @%x\n", activecpu_get_pc());
254   else
255      logerror("PB3 Online LED off @%x\n", activecpu_get_pc());
256   if (data & 16)
257      logerror("PB4 Serial @%x\n", activecpu_get_pc());
258   if (data & 32)
259      logerror("PB4 Serial @%x\n", activecpu_get_pc());
260   if (data & 64)
261      logerror("PB4 Serial @%x\n", activecpu_get_pc());
262   if (data & 128)
263      logerror("PB3 Paper empty LED on @%x\n", activecpu_get_pc());
264   else
265      logerror("PB3 Paper empty LED off @%x\n", activecpu_get_pc());
266   
267//   logerror("PB W %x @%x\n", data, activecpu_get_pc());
268}
269
270static WRITE8_HANDLER(ex800_portc_w)
271{
272   if (data & 0x80)
273      beep_set_state(0, 0);
274   else
275      beep_set_state(0, 1);
276   
277   logerror("PC W %x @%x\n", data, activecpu_get_pc());
278}
279
280
281/* Memory mapped I/O access */
282
283static READ8_HANDLER(ex800_devsel_r)
284{
285   logerror("DEVSEL R @%x with offset %x\n", activecpu_get_pc(), offset);
286   return mame_rand(Machine);
287}
288
289static WRITE8_HANDLER(ex800_devsel_w)
290{
291   logerror("DEVSEL W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
292}
293
294static READ8_HANDLER(ex800_gate5a_r)
295{
296   logerror("GATE5A R @%x with offset %x\n", activecpu_get_pc(), offset);
297   return mame_rand(Machine);
298}
299
300static WRITE8_HANDLER(ex800_gate5a_w)
301{
302   logerror("GATE5A W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
303}
304
305static READ8_HANDLER(ex800_iosel_r)
306{
307   logerror("IOSEL R @%x with offset %x\n", activecpu_get_pc(), offset);
308   return mame_rand(Machine);
309}
310
311static WRITE8_HANDLER(ex800_iosel_w)
312{
313   logerror("IOSEL W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
314}
315
316static READ8_HANDLER(ex800_gate7a_r)
317{
318   logerror("GATE7A R @%x with offset %x\n", activecpu_get_pc(), offset);
319   return mame_rand(Machine);
320}
321
322static WRITE8_HANDLER(ex800_gate7a_w)
323{
324   logerror("GATE7A W %x @%x with offset %x\n", data, activecpu_get_pc(), offset);
325}
326
327
328
329/******************************************************************************
330 Address Maps
331******************************************************************************/
332
333
334static ADDRESS_MAP_START( ex800_mem, ADDRESS_SPACE_PROGRAM, 8 )
335   AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION(REGION_CPU1, 0)
336   AM_RANGE(0x8000, 0xbfff) AM_RAM /* external RAM */
337   AM_RANGE(0xc000, 0xc7ff) AM_MIRROR(0x1800) AM_READWRITE(ex800_devsel_r, ex800_devsel_w)
338   AM_RANGE(0xe000, 0xe7ff) AM_READWRITE(ex800_gate5a_r, ex800_gate5a_w)
339   AM_RANGE(0xe800, 0xefff) AM_READWRITE(ex800_iosel_r, ex800_iosel_w)
340   AM_RANGE(0xf000, 0xf001) AM_MIRROR(0x07fc) AM_READ(ex800_gate7a_r)
341   AM_RANGE(0xf002, 0xf003) AM_MIRROR(0x07fc) AM_WRITE(ex800_gate7a_w)
342   AM_RANGE(0xf800, 0xfeff) AM_NOP /* not connected */
343   AM_RANGE(0xff00, 0xffff) AM_RAM /* internal CPU RAM */
344ADDRESS_MAP_END
345
346
347static ADDRESS_MAP_START( ex800_io, ADDRESS_SPACE_IO, 8 )
348   AM_RANGE(UPD7810_PORTA, UPD7810_PORTA) AM_READ(ex800_porta_r) AM_WRITE(ex800_porta_w)
349   AM_RANGE(UPD7810_PORTB, UPD7810_PORTB) AM_READ(ex800_portb_r) AM_WRITE(ex800_portb_w)
350   AM_RANGE(UPD7810_PORTC, UPD7810_PORTC) AM_READ(ex800_portc_r) AM_WRITE(ex800_portc_w)
351ADDRESS_MAP_END
352
353
354
355/******************************************************************************
356 Inputs and DIP switches
357******************************************************************************/
358
359
360static INPUT_PORTS_START( ex800 )
361   PORT_START_TAG("ONLISW")
362   PORT_BIT(0xfe, IP_ACTIVE_HIGH, IPT_UNUSED)
363   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON LINE")   PORT_CODE(KEYCODE_F9)
364
365   PORT_START_TAG("FEED")
366   PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNUSED)
367   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FORM FEED") PORT_CODE(KEYCODE_F10)
368   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_F11)
369   
370   PORT_START_TAG("SelecType")
371   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Draft")          PORT_CODE(KEYCODE_F8)
372   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NLQ Roman")      PORT_CODE(KEYCODE_F7)
373   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Pica")           PORT_CODE(KEYCODE_F6)
374   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NLQ Sans Serif") PORT_CODE(KEYCODE_F5)
375   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Elite")          PORT_CODE(KEYCODE_F4)
376   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Proportional")   PORT_CODE(KEYCODE_F3)
377   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(DEF_STR(Normal))  PORT_CODE(KEYCODE_F2)
378   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Condensed")      PORT_CODE(KEYCODE_F1)
379   
380   PORT_START_TAG("DSW_1")
381   PORT_DIPNAME(0x01, 0x00, "Condensed characters")
382   PORT_DIPSETTING(   0x00, DEF_STR(Off))
383   PORT_DIPSETTING(   0x01, DEF_STR(On))
384   PORT_DIPNAME(0x02, 0x00, "Slashed zero")
385   PORT_DIPSETTING(   0x00, DEF_STR(Off))
386   PORT_DIPSETTING(   0x02, DEF_STR(On))
387   PORT_DIPNAME(0x04, 0x00, "Character table")
388   PORT_DIPSETTING(   0x00, "Italics")
389   PORT_DIPSETTING(   0x04, "Graphics")
390   PORT_DIPNAME(0x08, 0x00, "Printer commands")
391   PORT_DIPSETTING(   0x00, "ESC/P")
392   PORT_DIPSETTING(   0x08, "IBM printer emulation")
393   PORT_DIPNAME(0x10, 0x00, "Print quality")
394   PORT_DIPSETTING(   0x00, "Draft")
395   PORT_DIPSETTING(   0x10, "NLQ")
396   PORT_DIPNAME(0xe0, 0x00, "Int. character set")
397   PORT_DIPSETTING(   0x00, DEF_STR(USA))
398   PORT_DIPSETTING(   0x20, DEF_STR(French))
399   PORT_DIPSETTING(   0x30, DEF_STR(German))
400   PORT_DIPSETTING(   0x40, "UK")
401   PORT_DIPSETTING(   0x50, "Danish")
402   PORT_DIPSETTING(   0x60, "Swedish")
403   PORT_DIPSETTING(   0x70, DEF_STR(Italian))
404   PORT_DIPSETTING(   0x80, DEF_STR(Spanish))
405
406   PORT_START_TAG("DSW_2")
407   PORT_DIPNAME(0x01, 0x00, "Page length")
408   PORT_DIPSETTING(   0x00, "11 inch")
409   PORT_DIPSETTING(   0x01, "12 inch")
410   PORT_DIPNAME(0x02, 0x00, "Auto. sheet feeder")
411   PORT_DIPSETTING(   0x00, "Canceled")
412   PORT_DIPSETTING(   0x02, "Selected")
413   PORT_DIPNAME(0x04, 0x00, "Skip-over-perforation")
414   PORT_DIPSETTING(   0x00, DEF_STR(None))
415   PORT_DIPSETTING(   0x04, "1 inch")
416   PORT_DIPNAME(0x08, 0x00, "Add LF after CR")
417   PORT_DIPSETTING(   0x00, "CR only")
418   PORT_DIPSETTING(   0x08, "CR + LF")
419   PORT_DIPNAME(0x30, 0x00, "Interface type")
420   PORT_DIPSETTING(   0x00, "Parallel")
421   PORT_DIPSETTING(   0x10, "Serial (odd parity)")
422   PORT_DIPSETTING(   0x20, "Serial (even parity)")
423   PORT_DIPSETTING(   0x30, "Serial (no parity)")
424   PORT_DIPNAME(0xc0, 0x00, "Baud rate")
425   PORT_DIPSETTING(   0x00, "9600")
426   PORT_DIPSETTING(   0x40, "4800")
427   PORT_DIPSETTING(   0x80, "1200")
428   PORT_DIPSETTING(   0xc0, "300")   
429INPUT_PORTS_END
430
431
432
433/******************************************************************************
434 CPU config
435******************************************************************************/
436
437
438static UPD7810_CONFIG ex800_cpu_config =
439{
440    TYPE_7810,
441    0
442};
443
444
445
446/******************************************************************************
447 Machine Drivers
448******************************************************************************/
449
450
451static MACHINE_DRIVER_START(ex800)
452    /* basic machine hardware */
453    MDRV_CPU_ADD_TAG("main", UPD7810, 12000000)  /* 12 Mhz? */
454    MDRV_CPU_CONFIG(ex800_cpu_config)
455    MDRV_CPU_PROGRAM_MAP(ex800_mem, 0)
456   MDRV_CPU_IO_MAP(ex800_io, 0)
457
458   MDRV_MACHINE_START(ex800)
459   
460   /* "video" hardware */
461   MDRV_SCREEN_REFRESH_RATE(60)
462   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
463//   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
464//   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
465//   MDRV_SCREEN_SIZE(480, 640)
466//   MDRV_SCREEN_VISIBLE_AREA(0, 479, 0, 639)   
467//   MDRV_PALETTE_LENGTH(4)
468
469//   MDRV_VIDEO_START(ex800)
470//   MDRV_VIDEO_UPDATE(ex800)
471
472   /* audio hardware */
473   MDRV_SPEAKER_STANDARD_MONO("mono")
474   MDRV_SOUND_ADD(BEEP, 0)
475   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
476MACHINE_DRIVER_END
477
478
479
480/******************************************************************************
481 ROM Definitions
482******************************************************************************/
483
484
485ROM_START( ex800 )
486    ROM_REGION(0x8000, REGION_CPU1, 0)
487   ROM_LOAD("w8_pe9.9b", 0x0000, 0x8000, CRC(6dd41e9b) SHA1(8e30ead727b9317154742efd881206e9f9bbf95b))
488ROM_END
489
490
491
492/******************************************************************************
493 Drivers
494******************************************************************************/
495
496
497/*    YEAR  NAME   PARENT  COMPAT  MACHINE INPUT  INIT   CONFIG COMPANY  FULLNAME  FLAGS */
498COMP( 1986, ex800,      0,      0, ex800,  ex800, ex800, NULL,  "Epson", "EX-800", GAME_NO_SOUND | GAME_NOT_WORKING)
src/mess/drivers/acrnsys1.c
r1301r1302
1/******************************************************************************
2 Acorn System 1 (Microcomputer Kit)
3 
4 Skeleton driver
5 
6 Written by Dirk Best October 2007
7 
8 TODO: Emulate the National Semiconductor INS8154
9 
10******************************************************************************/
11 
12#include "driver.h"
13#include "inputx.h"
14 
15/* Layout */
16#include "acrnsys1.lh"
17 
18 
19 
20/******************************************************************************
21 Memory Maps
22******************************************************************************/
23 
24 
25static ADDRESS_MAP_START( acrnsys1_map, ADDRESS_SPACE_PROGRAM, 8 )
26   AM_RANGE(0x0000, 0x03ff) AM_RAM
27//   AM_RANGE(0x0e00, 0x0e7f) AM_MIRROR(0x100) AM_READWRITE(ins8154_0_r, ins8154_0_w)
28   AM_RANGE(0x0e80, 0x0eff) AM_MIRROR(0x100) AM_RAM
29   AM_RANGE(0xfe00, 0xffff) AM_MIRROR(0x600) AM_ROM
30ADDRESS_MAP_END
31 
32 
33 
34/******************************************************************************
35 Input Ports
36******************************************************************************/
37 
38 
39static INPUT_PORTS_START( acrnsys1 )
40   PORT_START_TAG("keyboard_0")
41   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M')
42   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G')
43   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P')
44   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S')
45   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L')
46   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
47   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP)   PORT_CHAR(UCHAR_MAMEKEY(UP))
48   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
49 
50   PORT_START_TAG("keyboard_1")
51   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
52   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9')
53   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A')
54   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B')
55   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
56   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D')
57   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E')
58   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
59 
60   PORT_START_TAG("keyboard_2")
61   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
62   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
63   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
64   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
65   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
66   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
67   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
68   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7')
69 
70   PORT_START_TAG("reset")
71   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RST") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
72   PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED)
73INPUT_PORTS_END
74 
75 
76 
77/******************************************************************************
78 Machine Drivers
79******************************************************************************/
80 
81 
82static MACHINE_DRIVER_START( acrnsys1 )
83   /* basic machine hardware */
84   MDRV_CPU_ADD(M6502, 1008000)  /* 1.008 MHz */
85   MDRV_CPU_PROGRAM_MAP(acrnsys1_map, 0)
86 
87   /* "video" hardware */
88   MDRV_DEFAULT_LAYOUT(layout_acrnsys1)
89   MDRV_SCREEN_REFRESH_RATE(60)
90   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
91MACHINE_DRIVER_END
92 
93 
94 
95/******************************************************************************
96 ROM Definitions
97******************************************************************************/
98 
99 
100ROM_START( acrnsys1 )
101   ROM_REGION(0x10000, REGION_CPU1, 0)
102   ROM_LOAD("acrnsys1.bin", 0xfe00, 0x0200, CRC(43dcfc16) SHA1(b987354c55beb5e2ced761970c3339b895a8c09d))
103ROM_END
104 
105 
106 
107/******************************************************************************
108 System Config
109******************************************************************************/
110 
111 
112SYSTEM_CONFIG_START( acrnsys1 )
113SYSTEM_CONFIG_END
114 
115 
116 
117/******************************************************************************
118 Drivers
119******************************************************************************/
120 
121 
122/*    YEAR  NAME      PARENT COMPAT MACHINE   INPUT     INIT CONFIG    COMPANY  FULLNAME    FLAGS */
123COMP( 1978, acrnsys1, 0,     0,     acrnsys1, acrnsys1, 0,   acrnsys1, "Acorn", "System 1", GAME_NOT_WORKING )
1/******************************************************************************
2 Acorn System 1 (Microcomputer Kit)
3 
4 Skeleton driver
5
6 Written by Dirk Best October 2007
7
8 TODO: Emulate the National Semiconductor INS8154
9
10******************************************************************************/
11
12#include "driver.h"
13#include "inputx.h"
14
15/* Layout */
16#include "acrnsys1.lh"
17
18
19
20/******************************************************************************
21 Memory Maps
22******************************************************************************/
23
24
25static ADDRESS_MAP_START( acrnsys1_map, ADDRESS_SPACE_PROGRAM, 8 )
26   AM_RANGE(0x0000, 0x03ff) AM_RAM
27//   AM_RANGE(0x0e00, 0x0e7f) AM_MIRROR(0x100) AM_READWRITE(ins8154_0_r, ins8154_0_w)
28   AM_RANGE(0x0e80, 0x0eff) AM_MIRROR(0x100) AM_RAM
29   AM_RANGE(0xfe00, 0xffff) AM_MIRROR(0x600) AM_ROM
30ADDRESS_MAP_END
31
32
33
34/******************************************************************************
35 Input Ports
36******************************************************************************/
37
38
39static INPUT_PORTS_START( acrnsys1 )
40   PORT_START_TAG("keyboard_0")
41   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M')
42   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G')
43   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P')
44   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S')
45   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L')
46   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
47   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x91") PORT_CODE(KEYCODE_UP)   PORT_CHAR(UCHAR_MAMEKEY(UP))
48   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\xE2\x86\x93") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
49
50   PORT_START_TAG("keyboard_1")
51   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
52   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9')
53   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A')
54   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B')
55   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
56   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D')
57   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E')
58   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
59
60   PORT_START_TAG("keyboard_2")
61   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
62   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
63   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
64   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
65   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
66   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
67   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
68   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7')
69
70   PORT_START_TAG("reset")
71   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RST") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
72   PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED)
73INPUT_PORTS_END
74
75
76
77/******************************************************************************
78 Machine Drivers
79******************************************************************************/
80
81
82static MACHINE_DRIVER_START( acrnsys1 )
83   /* basic machine hardware */
84   MDRV_CPU_ADD(M6502, 1008000)  /* 1.008 MHz */
85   MDRV_CPU_PROGRAM_MAP(acrnsys1_map, 0)
86
87   /* "video" hardware */
88   MDRV_DEFAULT_LAYOUT(layout_acrnsys1)
89   MDRV_SCREEN_REFRESH_RATE(60)
90   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
91MACHINE_DRIVER_END
92
93
94
95/******************************************************************************
96 ROM Definitions
97******************************************************************************/
98
99
100ROM_START( acrnsys1 )
101   ROM_REGION(0x10000, REGION_CPU1, 0)
102   ROM_LOAD("acrnsys1.bin", 0xfe00, 0x0200, CRC(43dcfc16) SHA1(b987354c55beb5e2ced761970c3339b895a8c09d))
103ROM_END
104
105
106
107/******************************************************************************
108 System Config
109******************************************************************************/
110
111
112SYSTEM_CONFIG_START( acrnsys1 )
113SYSTEM_CONFIG_END
114
115
116
117/******************************************************************************
118 Drivers
119******************************************************************************/
120
121
122/*    YEAR  NAME      PARENT COMPAT MACHINE   INPUT     INIT CONFIG    COMPANY  FULLNAME    FLAGS */
123COMP( 1978, acrnsys1, 0,     0,     acrnsys1, acrnsys1, 0,   acrnsys1, "Acorn", "System 1", GAME_NOT_WORKING )
docs/messnew.txt
r1301r1302
7676
7777Source Changes:
7878----------------
79- The core is based on MAME 0.120u4.  This incorporates all features of the
79- The core is based on MAME 0.121.  This incorporates all features of the
8080  update to this core.  [MAME team]
8181
8282

Previous 15994 Revisions Next


© 1998-2018 The MESS Team