Previous 15994 Revisions Next

r5362 Thursday 6th August, 2009 at 20:45:11 UTC by Jonathan Gevaryahu
[socrates] added sound core, hooked up sound, marked driver as working with imperfect sound (sound still has some volume/odd stuttering/lack of lowpass/other issues, also speech is missing)
[src/mess]mess.mak
[src/mess/audio]socrates.c* socrates.h*
[src/mess/drivers]socrates.c

src/mess/audio/socrates.c
r0r5362
1/***************************************************************************
2
3    audio/socrates.c
4
5    This handles the two squarewaves (plus the one weird wave) channels
6    on the V-tech Socrates system 27-0769 ASIC.
7
8****************************************************************************/
9
10#include "sndintrf.h"
11#include "streams.h"
12#include "socrates.h"
13
14typedef struct
15{
16   sound_stream *stream;
17   UINT8 freq[2]; /* channel 1,2 frequencies */
18   UINT8 vol_ch1; /* channel 1 volume */
19   UINT8 vol_ch2; /* channel 2 volume */
20   UINT8 channel3; /* channel 3 weird register */
21   UINT8 state[3]; /* output states for channels 1,2,3 */
22   UINT8 accum[3]; /* accumulators for channels 1,2,3 */
23   UINT8 DAC_output; /* output */
24} SocratesASIC;
25
26
27INLINE SocratesASIC *get_safe_token(const device_config *device)
28{
29   assert(device != NULL);
30   assert(device->token != NULL);
31   assert(device->type == SOUND);
32   assert(sound_get_type(device) == SOUND_SOCRATES);
33   return (SocratesASIC *)device->token;
34}
35
36static void socrates_snd_clock(SocratesASIC *chip) /* called once per clock */
37{
38   int channel;
39   for (channel = 0; channel < 2; channel++)
40   {
41      if (chip->accum[channel] == 0)
42      {
43      chip->state[channel] = (chip->state[channel]^0x1);
44      chip->accum[channel] = chip->freq[channel];
45      }
46      else
47      chip->accum[channel]--;
48   }
49   // handle channel 3 here
50   chip->DAC_output = (chip->state[0]?(chip->vol_ch1<<3):0);
51   chip->DAC_output += (chip->state[1]?(chip->vol_ch2<<2):0);
52   // add channel 3 to dac output here
53}
54
55/*************************************
56 *
57 *  Stream updater
58 *
59 *************************************/
60static STREAM_UPDATE( socrates_snd_pcm_update )
61{
62   INT32 mix[48000];
63   INT32 *mixp;
64   SocratesASIC *chip = (SocratesASIC *)param;
65   int i;
66
67   memset(mix, 0, sizeof(mix));
68
69   mixp = &mix[0];
70   for (i = 0; i < samples; i++)
71   {
72      socrates_snd_clock(chip);
73      outputs[0][i] = (((int)chip->DAC_output<<8)|(int)chip->DAC_output);
74   }
75}
76   
77
78
79/*************************************
80 *
81 *  Sound handler start
82 *
83 *************************************/
84
85static DEVICE_START( socrates_snd )
86{
87   SocratesASIC *chip = get_safe_token(device);
88   chip->freq[0] = chip->freq[1] = 0xff; /* channel 1,2 frequency */
89   chip->vol_ch1 = 0x01; /* channel 1 volume */
90   chip->vol_ch2 = 0x01; /* channel 2 volume */
91   chip->channel3 = 0x00; /* channel 3 weird register */
92   chip->DAC_output = 0x00; /* output */
93   chip->state[0] = chip->state[1] = chip->state[2] = 0;
94   chip->accum[0] = chip->accum[1] = chip->accum[2] = 0xFF;
95   chip->stream = stream_create(device, 0, 1, device->clock ? device->clock : device->machine->sample_rate, chip, socrates_snd_pcm_update);
96}
97
98
99void socrates_snd_reg0_w(const device_config *device, int data)
100{
101   SocratesASIC *chip = get_safe_token(device);
102   stream_update(chip->stream);
103   chip->freq[0] = data;
104}
105
106void socrates_snd_reg1_w(const device_config *device, int data)
107{
108   SocratesASIC *chip = get_safe_token(device);
109   stream_update(chip->stream);
110   chip->freq[1] = data;
111}
112
113void socrates_snd_reg2_w(const device_config *device, int data)
114{
115   SocratesASIC *chip = get_safe_token(device);
116   stream_update(chip->stream);
117   chip->vol_ch1 = data&0xF;
118}
119
120void socrates_snd_reg3_w(const device_config *device, int data)
121{
122   SocratesASIC *chip = get_safe_token(device);
123   stream_update(chip->stream);
124   chip->vol_ch2 = data&0xF;
125}
126
127void socrates_snd_reg4_w(const device_config *device, int data)
128{
129   SocratesASIC *chip = get_safe_token(device);
130   stream_update(chip->stream);
131   chip->channel3 = data;
132}
133
134
135/**************************************************************************
136 * Generic get_info
137 **************************************************************************/
138
139DEVICE_GET_INFO( socrates_snd )
140{
141   switch (state)
142   {
143      /* --- the following bits of info are returned as 64-bit signed integers --- */
144      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(SocratesASIC);            break;
145
146      /* --- the following bits of info are returned as pointers to data or functions --- */
147      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME( socrates_snd );   break;
148
149      /* --- the following bits of info are returned as NULL-terminated strings --- */
150      case DEVINFO_STR_NAME:                     strcpy(info->s, "Socrates Sound");               break;
151      case DEVINFO_STR_FAMILY:               strcpy(info->s, "Socrates Sound");               break;
152      case DEVINFO_STR_VERSION:               strcpy(info->s, "1.0");                  break;
153      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);               break;
154      case DEVINFO_STR_CREDITS:               strcpy(info->s, "Copyright Jonathan Gevaryahu and The MESS Team"); break;
155   }
156}
src/mess/audio/socrates.h
r0r5362
1#pragma once
2
3#ifndef __SOCR_SND_H__
4#define __SOCR_SND_H__
5
6void socrates_snd_reg0_w(const device_config *device, int data);
7void socrates_snd_reg1_w(const device_config *device, int data);
8void socrates_snd_reg2_w(const device_config *device, int data);
9void socrates_snd_reg3_w(const device_config *device, int data);
10void socrates_snd_reg4_w(const device_config *device, int data);
11
12DEVICE_GET_INFO( socrates_snd );
13#define SOUND_SOCRATES DEVICE_GET_INFO_NAME( socrates_snd )
14
15#endif /* __SOCR_SND_H__ */
16
src/mess/mess.mak
r5361r5362
228228SOUNDS += SID8580
229229SOUNDS += SP0256
230230#SOUNDS += DIGITALKER
231SOUNDS += SOCRATES
231232
232233
233234#-------------------------------------------------
r5361r5362
14341435   $(MESS_FORMATS)/vt_cas.o   \
14351436   $(MESS_FORMATS)/vt_dsk.o   \
14361437   $(MESS_DRIVERS)/crvision.o   \
1438   $(MESS_AUDIO)/socrates.o   \
14371439   $(MESS_DRIVERS)/socrates.o   \
14381440
14391441$(MESSOBJ)/xerox.a:            \
r5361r5362
14941496$(MESS_DRIVERS)/poly880.o:   $(MESS_LAYOUT)/poly880.lh
14951497$(MESS_VIDEO)/pc8401a.o:   $(MESS_LAYOUT)/pc8500.lh
14961498$(MESS_DRIVERS)/px4.o:      $(MESS_LAYOUT)/px4.lh
1497$(MESS_DRIVERS)/socrates.o:   $(MESS_LAYOUT)/socrates.lh
14981499$(MESS_DRIVERS)/stopthie.o:   $(MESS_LAYOUT)/stopthie.lh
14991500$(MESS_DRIVERS)/super80.o:   $(MESS_LAYOUT)/super80.lh
15001501$(MESS_DRIVERS)/svision.o:   $(MESS_LAYOUT)/svision.lh
src/mess/drivers/socrates.c
r5361r5362
7575#include "driver.h"
7676#include "cpu/z80/z80.h"
7777#include "socrates.lh"
78//#include "sound/beep.h"
78#include "audio/socrates.h"
7979
8080/* Defines */
8181#undef EMULATE_SPEECH // tries miserably to emulate the speech chip readback. works for the first packet, which causes socrates to crash on the second one.
r5361r5362
608608
609609static WRITE8_HANDLER(socrates_sound_w)
610610{
611   const device_config *socr_snd = devtag_get_device(space->machine, "soc_snd");
611612   switch(offset)
612613   {
613614      case 0:
614      //beep_set_frequency(channel1, (int)((13982.6)/(data+1)));
615      socrates_snd_reg0_w(socr_snd, data);
615616      break;
616617      case 1:
617      //beep_set_frequency(channel2, (int)((13982.6)/(data+1)));
618      socrates_snd_reg1_w(socr_snd, data);
618619      break;
619620      case 2:
620      //beep_set_volume(channel1, data/4);
621      socrates_snd_reg2_w(socr_snd, data);
621622      break;
622623      case 3:
623      //beep_set_volume(channel2, data/8);
624      socrates_snd_reg3_w(socr_snd, data);
624625      break;
625626      case 4: case 5: case 6: case 7: default:
627      socrates_snd_reg4_w(socr_snd, data);
626628      break;
627629   }
628630}
r5361r5362
879881    MDRV_MACHINE_RESET(socrates)
880882
881883    /* video hardware */
882   //MDRV_DEFAULT_LAYOUT(layout_socrates)
883884   MDRV_SCREEN_ADD("screen", RASTER)
884885   MDRV_SCREEN_REFRESH_RATE(60)
885886   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
r5361r5362
892893   MDRV_VIDEO_UPDATE(socrates)
893894
894895    /* sound hardware */
895   //MDRV_SPEAKER_STANDARD_MONO("mono")
896   //MDRV_SOUND_ADD("beep", BEEP, 0)
897   //MDRV_SOUND_ADD("beep2", BEEP, 0)
898   //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_4772MHz/(512+256)) /* this is correct, as strange as it sounds. */
899   //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
896   MDRV_SPEAKER_STANDARD_MONO("mono")
897   MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_4772MHz/(512+256)) // this is correct, as strange as it sounds.
898   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
900899
901
902900MACHINE_DRIVER_END
903901
904902
r5361r5362
964962******************************************************************************/
965963
966964/*    YEAR  NAME        PARENT      COMPAT  MACHINE     INPUT   INIT CONFIG      COMPANY                     FULLNAME                            FLAGS */
967COMP( 1988, socrates,   0,          0,      socrates,   socrates, socrates,   socrates,   "V-tech",        "Socrates Educational Video System",                        GAME_NOT_WORKING )
968COMP( 1988, socratfc,   socrates,   0,      socrates,   socrates, socrates,   socrates,   "V-tech",        "Socrates SAITOUT",                        GAME_NOT_WORKING )
965COMP( 1988, socrates,   0,          0,      socrates,   socrates, socrates,   socrates,   "V-tech",        "Socrates Educational Video System", GAME_IMPERFECT_SOUND )
966COMP( 1988, socratfc,   socrates,   0,      socrates,   socrates, socrates,   socrates,   "V-tech",        "Socrates SAITOUT", GAME_IMPERFECT_SOUND )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team