src/mess/audio/socrates.c
| r5392 | r5393 | |
| 15 | 15 | { |
| 16 | 16 | sound_stream *stream; |
| 17 | 17 | 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 */ |
| 20 | 20 | UINT8 channel3; /* channel 3 weird register */ |
| 21 | 21 | UINT8 state[3]; /* output states for channels 1,2,3 */ |
| 22 | 22 | UINT8 accum[3]; /* accumulators for channels 1,2,3 */ |
| 23 | | UINT8 DAC_output; /* output */ |
| 23 | UINT16 DAC_output; /* output */ |
| 24 | 24 | } SocratesASIC; |
| 25 | 25 | |
| 26 | 26 | |
| r5392 | r5393 | |
| 33 | 33 | return (SocratesASIC *)device->token; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | static const UINT8 volumeLUT[16] = |
| 37 | { |
| 38 | 0, 61, 100, 132, 158, 183, 201, 218, |
| 39 | 233, 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. |
| 36 | 42 | static void socrates_snd_clock(SocratesASIC *chip) /* called once per clock */ |
| 37 | 43 | { |
| 38 | 44 | int channel; |
| 39 | 45 | for (channel = 0; channel < 2; channel++) |
| 40 | 46 | { |
| 41 | | if (chip->accum[channel] == 0) |
| 47 | if ((chip->accum[channel] == 0) && chip->enable[channel]) |
| 42 | 48 | { |
| 43 | 49 | chip->state[channel] = (chip->state[channel]^0x1); |
| 44 | 50 | chip->accum[channel] = chip->freq[channel]; |
| 45 | 51 | } |
| 52 | else if (chip->enable[channel]) |
| 53 | { |
| 54 | chip->accum[channel]--; |
| 55 | } |
| 46 | 56 | else |
| 47 | | chip->accum[channel]--; |
| 57 | { |
| 58 | chip->accum[channel] = 0; // channel is disabled |
| 59 | chip->state[channel] = 0; |
| 60 | } |
| 48 | 61 | } |
| 49 | 62 | // 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); |
| 52 | 65 | // add channel 3 to dac output here |
| 53 | 66 | } |
| 54 | 67 | |
| r5392 | r5393 | |
| 70 | 83 | for (i = 0; i < samples; i++) |
| 71 | 84 | { |
| 72 | 85 | 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); |
| 74 | 87 | } |
| 75 | 88 | } |
| 76 | 89 | |
| r5392 | r5393 | |
| 86 | 99 | { |
| 87 | 100 | SocratesASIC *chip = get_safe_token(device); |
| 88 | 101 | 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 */ |
| 91 | 104 | chip->channel3 = 0x00; /* channel 3 weird register */ |
| 92 | 105 | chip->DAC_output = 0x00; /* output */ |
| 93 | 106 | chip->state[0] = chip->state[1] = chip->state[2] = 0; |
| r5392 | r5393 | |
| 114 | 127 | { |
| 115 | 128 | SocratesASIC *chip = get_safe_token(device); |
| 116 | 129 | stream_update(chip->stream); |
| 117 | | chip->vol_ch1 = data&0xF; |
| 130 | chip->vol[0] = data&0xF; |
| 131 | chip->enable[0] = (data&0x10)>>4; |
| 118 | 132 | } |
| 119 | 133 | |
| 120 | 134 | void socrates_snd_reg3_w(const device_config *device, int data) |
| 121 | 135 | { |
| 122 | 136 | SocratesASIC *chip = get_safe_token(device); |
| 123 | 137 | stream_update(chip->stream); |
| 124 | | chip->vol_ch2 = data&0xF; |
| 138 | chip->vol[1] = data&0xF; |
| 139 | chip->enable[1] = (data&0x10)>>4; |
| 125 | 140 | } |
| 126 | 141 | |
| 127 | 142 | void socrates_snd_reg4_w(const device_config *device, int data) |
src/mess/drivers/socrates.c
| r5392 | r5393 | |
| 6 | 6 | * |
| 7 | 7 | * (driver structure copied from vtech1.c) |
| 8 | 8 | TODO: |
| 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) |
| 10 | 10 | hook up hblank |
| 11 | 11 | hook up mouse |
| 12 | 12 | 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 |
| 15 | 13 | find and hook up any timers/interrupt controls |
| 16 | 14 | |
| 17 | 15 | |
| r5392 | r5393 | |
| 236 | 234 | return 0xF3; |
| 237 | 235 | } |
| 238 | 236 | |
| 239 | | WRITE8_HANDLER( unknownlatch_30 ) // writes to i/o 0x3x do SOMETHING, possibly waitstate related (may halt cpu until vblank start?) |
| 237 | WRITE8_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 |
| 240 | 238 | { |
| 241 | 239 | //logerror("write to i/o 0x30, data %x\n", data); // too annoying to leave enabled |
| 242 | 240 | } |
| r5392 | r5393 | |
| 244 | 242 | READ8_HANDLER( status_and_speech ) // read 0x4x, some sort of status reg |
| 245 | 243 | { |
| 246 | 244 | // 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? |
| 248 | 246 | // bit 5 - vblank status, high when not in vblank |
| 249 | 247 | // bit 4 - hblank status, high when not in hblank |
| 250 | 248 | // bit 3 - speech chip bit 3 |
| r5392 | r5393 | |
| 345 | 343 | 1101 |
| 346 | 344 | 1110 SSTART (same as start but syspd speed is ignored and forced to be set to 9 (scale = 1.0)) |
| 347 | 345 | 1111 |
| 348 | | */ |
| 346 | end hd38880 info.*/ |
| 349 | 347 | /* the socrates speech chip does not QUITE match the hd38880 though, but is very similar */ |
| 350 | 348 | switch(data&0xF0) |
| 351 | 349 | { |
| r5392 | r5393 | |
| 647 | 645 | AM_RANGE(0x10, 0x17) AM_READWRITE(read_f3, socrates_sound_w) AM_MIRROR (0x8) /* sound section: |
| 648 | 646 | 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) |
| 649 | 647 | 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 |
| 653 | 656 | */ |
| 654 | 657 | AM_RANGE(0x20, 0x21) AM_READWRITE(read_f3, socrates_scroll_w) AM_MIRROR (0xe) /* graphics section: |
| 655 | 658 | 0x20 - W - lsb offset of screen display |
| r5392 | r5393 | |
| 863 | 866 | static INTERRUPT_GEN( assert_irq ) |
| 864 | 867 | { |
| 865 | 868 | 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. |
| 868 | 871 | socrates.vblankstate = 1; |
| 869 | 872 | } |
| 870 | 873 | |
| r5392 | r5393 | |
| 906 | 909 | ROM_START(socrates) |
| 907 | 910 | ROM_REGION(0x80000, "maincpu", 0) |
| 908 | 911 | /* 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") |
| 909 | 936 | ROM_LOAD("27-00817-000-000.u1", 0x00000, 0x40000, CRC(80f5aa20) SHA1(4fd1ff7f78b5dd2582d5de6f30633e4e4f34ca8f)) |
| 937 | ROM_SYSTEM_BIOS( 0, "nocart", "Socrates w/o cartridge installed") |
| 910 | 938 | 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 |
| 912 | 955 | |
| 913 | 956 | ROM_REGION(0x10000, "vram", 0) |
| 914 | 957 | ROM_FILL(0x0000, 0xffff, 0xff) /* fill with ff, driver_init changes this to the 'correct' startup pattern */ |