Previous 15994 Revisions Next

r5393 Monday 10th August, 2009 at 03:48:55 UTC by Jonathan Gevaryahu
[Socrates] fix audio volume table (the real hardware is really WACKY). implement channel enable bit for the sound channels. add socrates cartridge pinout. add socrates cartridges as selectable bioses. add a few chip names/locations for cartridges.
[src/mess/audio]socrates.c
[src/mess/drivers]socrates.c

src/mess/audio/socrates.c
r5392r5393
1515{
1616   sound_stream *stream;
1717   UINT8 freq[2]; /* channel 1,2 frequencies */
18   UINT8 vol_ch1; /* channel 1 volume */
19   UINT8 vol_ch2; /* channel 2 volume */
18   UINT8 vol[2]; /* channel 1,2 volume */
19   UINT8 enable[2]; /* channel 1,2 enable */
2020   UINT8 channel3; /* channel 3 weird register */
2121   UINT8 state[3]; /* output states for channels 1,2,3 */
2222   UINT8 accum[3]; /* accumulators for channels 1,2,3 */
23   UINT8 DAC_output; /* output */
23   UINT16 DAC_output; /* output */
2424} SocratesASIC;
2525
2626
r5392r5393
3333   return (SocratesASIC *)device->token;
3434}
3535
36static const UINT8 volumeLUT[16] =
37{
380, 61, 100, 132, 158, 183, 201, 218,
39233, 242, 253, 255, 250, 240, 224, 211
40}; // this table is actually quite weird on the real console.
41// 0, 0.033, 0.055, 0.07175, 0.086, 0.1, 0.11, 0.119, 0.127, 0.132, 0.138, 0.139, 0.136, 0.131, 0.122, 0.115 are the voltage amplitudes for the steps on channel 2. the last four are particularly bizarre, probably caused by some sort of internal clipping.
3642static void socrates_snd_clock(SocratesASIC *chip) /* called once per clock */
3743{
3844   int channel;
3945   for (channel = 0; channel < 2; channel++)
4046   {
41      if (chip->accum[channel] == 0)
47      if ((chip->accum[channel] == 0) && chip->enable[channel])
4248      {
4349      chip->state[channel] = (chip->state[channel]^0x1);
4450      chip->accum[channel] = chip->freq[channel];
4551      }
52      else if (chip->enable[channel])
53      {
54      chip->accum[channel]--;
55      }
4656      else
47      chip->accum[channel]--;
57      {
58      chip->accum[channel] = 0; // channel is disabled
59      chip->state[channel] = 0;
60      }
4861   }
4962   // 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);
63   chip->DAC_output = (chip->state[0]?(volumeLUT[chip->vol[0]]*9.4):0); // channel 1 is ~2.4 times as loud as channel 2
64   chip->DAC_output += (chip->state[1]?(volumeLUT[chip->vol[1]]<<2):0);
5265   // add channel 3 to dac output here
5366}
5467
r5392r5393
7083   for (i = 0; i < samples; i++)
7184   {
7285      socrates_snd_clock(chip);
73      outputs[0][i] = (((int)chip->DAC_output<<8)|(int)chip->DAC_output);
86      outputs[0][i] = ((int)chip->DAC_output<<4);
7487   }
7588}
7689   
r5392r5393
8699{
87100   SocratesASIC *chip = get_safe_token(device);
88101   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 */
102   chip->vol[0] = chip->vol[1] = 0x07; /* channel 1,2 volume */
103   chip->enable[0] = chip->enable[1] = 0x01; /* channel 1,2 enable */
91104   chip->channel3 = 0x00; /* channel 3 weird register */
92105   chip->DAC_output = 0x00; /* output */
93106   chip->state[0] = chip->state[1] = chip->state[2] = 0;
r5392r5393
114127{
115128   SocratesASIC *chip = get_safe_token(device);
116129   stream_update(chip->stream);
117   chip->vol_ch1 = data&0xF;
130   chip->vol[0] = data&0xF;
131   chip->enable[0] = (data&0x10)>>4;
118132}
119133
120134void socrates_snd_reg3_w(const device_config *device, int data)
121135{
122136   SocratesASIC *chip = get_safe_token(device);
123137   stream_update(chip->stream);
124   chip->vol_ch2 = data&0xF;
138   chip->vol[1] = data&0xF;
139   chip->enable[1] = (data&0x10)>>4;
125140}
126141
127142void socrates_snd_reg4_w(const device_config *device, int data)
src/mess/drivers/socrates.c
r5392r5393
66* 
77*  (driver structure copied from vtech1.c)
88TODO:
9   fix glitches with keyboard input (can't spell "igloo" in scramble due to problem with double keys, letter entry in super painter doesn't work) <- is this still true?
9   fix glitches with keyboard input (double keys still don't work, super painter letter entry still doesn't work)
1010   hook up hblank
1111   hook up mouse
1212   add waitstates for ram access (lack of this causes the system to run way too fast)
13   hook up cartridges using the bios system
14   hook up sound regs
1513   find and hook up any timers/interrupt controls
1614   
1715
r5392r5393
236234 return 0xF3;
237235}
238236
239WRITE8_HANDLER( unknownlatch_30 ) // writes to i/o 0x3x do SOMETHING, possibly waitstate related (may halt cpu until vblank start?)
237WRITE8_HANDLER( unknownlatch_30 ) // writes to i/o 0x3x do SOMETHING, possibly waitstate related (may halt cpu until vblank start?) or involve status reg bit 6
240238{
241239//logerror("write to i/o 0x30, data %x\n", data); // too annoying to leave enabled
242240}
r5392r5393
244242READ8_HANDLER( status_and_speech ) // read 0x4x, some sort of status reg
245243{
246244// bit 7 - speech status: high when speech is playing, low when it is not (or when speech cart is not present)
247// bit 6 - unknown, usually set
245// bit 6 - unknown, usually set, may involve the writes to 0x30, possibly some sort of fixed-length timer?
248246// bit 5 - vblank status, high when not in vblank
249247// bit 4 - hblank status, high when not in hblank
250248// bit 3 - speech chip bit 3
r5392r5393
345343   1101
346344   1110   SSTART (same as start but syspd speed is ignored and forced to be set to 9 (scale = 1.0))
347345   1111
348*/
346end hd38880 info.*/
349347/* the socrates speech chip does not QUITE match the hd38880 though, but is very similar */
350348   switch(data&0xF0)
351349   {
r5392r5393
647645   AM_RANGE(0x10, 0x17) AM_READWRITE(read_f3, socrates_sound_w) AM_MIRROR (0x8) /* sound section:
648646        0x10 - W - frequency control for channel 1 (louder channel) - 01=high pitch, ff=low; time between 1->0/0->1 transitions = (XTAL_21_4772MHz/(512+256) / (freq_reg+1)) (note that this is double the actual frequency since each full low and high squarewave pulse is two transitions)
649647   0x11 - W - frequency control for channel 2 (softer channel) - 01=high pitch, ff=low; same equation as above
650   0x12 - W - 0b****VVVV volume control for channel 1
651   0x13 - W - 0b****VVVV volume control for channel 2
652   0x14-0x17 - ?DAC? related? makes noise when written to... code implies 0x16 and 0x17 are mirrors of 0x14 and 0x15 respectively.
648   0x12 - W - 0b***EVVVV enable, volume control for channel 1
649   0x13 - W - 0b***EVVVV enable, volume control for channel 2
650   0x14-0x17 - 0bE??????? enable, unknown for channel 3; produces well defined dmc waves when bit 7 is set, and one or two other bits
651   This may be some sort of debug register for serial-dmc banging out some internal rom from the asic, maybe color data?
652   No writes to ram seem to change the waveforms produced, in my limited testing.
653   0x80 produces about a very very quiet 1/8 duty cycle wave at 60hz or so
654   0xC0 produces a DMC wave read from an unknown address at around 342hz
655   0x
653656   */
654657   AM_RANGE(0x20, 0x21) AM_READWRITE(read_f3, socrates_scroll_w) AM_MIRROR (0xe) /* graphics section:
655658   0x20 - W - lsb offset of screen display
r5392r5393
863866static INTERRUPT_GEN( assert_irq )
864867{
865868   cpu_set_input_line(device, 0, ASSERT_LINE);
866   timer_set(device->machine, cpu_clocks_to_attotime(device, 144), NULL, 0, clear_irq_cb);
867// 144 is a complete and total guess, need to properly measure how many clocks/microseconds the int line is high for.
869   timer_set(device->machine, cpu_clocks_to_attotime(device, 44), NULL, 0, clear_irq_cb);
870// 44 is a complete and total guess, need to properly measure how many clocks/microseconds the int line is high for.
868871   socrates.vblankstate = 1;
869872}
870873
r5392r5393
906909ROM_START(socrates)
907910    ROM_REGION(0x80000, "maincpu", 0)
908911    /* Socrates US NTSC */
912   /* all cart roms are 28 pin 23c1000/tc531000 128Kx8 roms */
913   /* cart port pinout:
914   (looking into end of disk-shaped cartridge with label/top side pointing to the right)
915   A15 -> 19  18 -- VCC
916   A14 -> 20  17 <- A16
917   A13 -> 21  16 <- A12
918    A8 -> 22  15 <- A7
919    A9 -> 23  14 <- A6
920   A11 -> 24  13 <- A5
921    A3 -> 25  12 <- A4
922    A2 -> 26  11 <- A10
923    D7 <- 27  10 <- A1
924    D6 <- 28  9 <- A0
925    D5 <- 29  8 -> D0
926    D4 <- 30  7 -> D1
927    D3 <- 31  6 -> D2
928     ? ?? 32  5 ?? ?
929   A17 -> 33  4 ?? ?
930     ? ?? 34  3 ?? ?
931   /CE -> 35  2 ?? ?
932   GND -- 36  1 -- GND
933   Note that a17 goes to what would be pin 2 if a 32 pin rom were installed, which is not the case. (pins 1, 31 and 32 would be tied to vcc)
934   */
935    ROM_DEFAULT_BIOS("nocart")
909936    ROM_LOAD("27-00817-000-000.u1", 0x00000, 0x40000, CRC(80f5aa20) SHA1(4fd1ff7f78b5dd2582d5de6f30633e4e4f34ca8f))
937    ROM_SYSTEM_BIOS( 0, "nocart", "Socrates w/o cartridge installed")
910938    ROM_FILL(0x40000, 0x40000, 0xf3) /* fill empty space with 0xf3 */
911    ROM_LOAD_OPTIONAL("cartridge.bin", 0x40000, 0x20000, NO_DUMP)
939    ROM_SYSTEM_BIOS( 1, "maze", "Socrates w/Amazing Mazes cartridge installed")
940    ROMX_LOAD("27-5050-00.u1", 0x40000, 0x20000, CRC(95B84308) SHA1(32E065E8F48BAF0126C1B9AA111C291EC644E387), ROM_BIOS(2)) // Label: "(Vtech) 27-5050-00 // TC531000CP-L332 // (C)1989 VIDEO TECHNOLOGY // 8931EAI   JAPAN"; Alt label: "(Vtech) LH53101Y // (C)1989 VIDEO TECHNOLOGY // 8934 D"
941    ROM_SYSTEM_BIOS( 2, "world", "Socrates w/Around the World cartridge installed")
942    ROMX_LOAD("27-5013-00-0.u1", 0x40000, 0x20000, BAD_DUMP CRC(DD5C185A) SHA1(F179A28A38588AE8C7044AA8ADAAF9684F01791C), ROM_BIOS(3)) // Label: "(Vtech) 27-5013-00-0 // TC531000CP-L318 // (C)1989 VIDEO TECHNOLOGY // 8918EAI   JAPAN" (may not be a bad dump but crashes very quickly, will redump soon)
943    ROM_SYSTEM_BIOS( 3, "fracts", "Socrates w/Facts'N Fractions cartridge installed")
944    ROMX_LOAD("facts'n_fractions.bin", 0x40000, 0x20000, CRC(7118617B) SHA1(52268EF0ADB651AD62773FB2EBCB7506759B2686), ROM_BIOS(4))
945    ROM_SYSTEM_BIOS( 4, "hodge", "Socrates w/Hodge Podge cartridge installed")
946    ROMX_LOAD("hodge_podge.bin", 0x40000, 0x20000, CRC(19E1A301) SHA1(649A7791E97BCD0D31AC65A890FACB5753AB04A3), ROM_BIOS(5))
947    ROM_SYSTEM_BIOS( 5, "memory", "Socrates w/Facts'N Fractions cartridge installed")
948    ROMX_LOAD("memory_mania.bin", 0x40000, 0x20000, CRC(3C7FD651) SHA1(3118F53625553010EC95EA91DA8320CCE3DC7FE4), ROM_BIOS(6))
949    ROM_SYSTEM_BIOS( 6, "state", "Socrates w/Facts'N Fractions cartridge installed")
950    ROMX_LOAD("state_to_state.bin", 0x40000, 0x20000, CRC(5848379F) SHA1(961C9CA4F28A9E02AA1D67583B2D2ADF8EE5F10E), ROM_BIOS(7))
951// a cartridge called 'game master' is supposed to be here
952// an international-only? cartridge called 'puzzles' is supposed to be here
953// Cad professor mouse is supposed to be here
954// the touch pad cartridge is supposed to be here
912955
913956    ROM_REGION(0x10000, "vram", 0)
914957    ROM_FILL(0x0000, 0xffff, 0xff) /* fill with ff, driver_init changes this to the 'correct' startup pattern */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team