src/mess/audio/sblaster.c
| r14676 | r14677 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | audio/sblaster.c |
| 4 | | |
| 5 | | Soundblaster code |
| 6 | | |
| 7 | | ****************************************************************************/ |
| 8 | | |
| 9 | | #include "emu.h" |
| 10 | | #include "sblaster.h" |
| 11 | | #include "sound/dac.h" |
| 12 | | |
| 13 | | |
| 14 | | /* operation modes |
| 15 | | 0x10 output 8 bit direct |
| 16 | | 0x14 output 8 bit with dma |
| 17 | | 0x16 output 2 bit compression with dma |
| 18 | | 0x17 output 2 bit compression with dma and reference byte |
| 19 | | 0x74 output 4 bit compression with dma |
| 20 | | 0x75 output 4 bit compression with dma with reference byte |
| 21 | | 0x76 output 2.6 bit compression with dma |
| 22 | | 0x77 output 2.7 bit compression with dma and reference byte |
| 23 | | |
| 24 | | 0x20 input 8 bit direct |
| 25 | | 0x24 input 8 bit with dma |
| 26 | | |
| 27 | | 0xd1 speaker on |
| 28 | | 0xd3 speaker off |
| 29 | | 0xd8 read speaker |
| 30 | | |
| 31 | | 0x40 samplerate adjust |
| 32 | | |
| 33 | | 0x48 blockgroesse einstellen |
| 34 | | |
| 35 | | 0x80 interrupt after xx samples |
| 36 | | |
| 37 | | 0xd0 end dma |
| 38 | | 0xd4 continue dma |
| 39 | | |
| 40 | | 0xe1 read version |
| 41 | | |
| 42 | | 0x30 midi input |
| 43 | | 0x31 midi input with irq generation |
| 44 | | 0x32 midi input with time stamp |
| 45 | | 0x33 midi input with irq and time stamp |
| 46 | | 0x34 midi output mode |
| 47 | | 0x35 midi output with irq |
| 48 | | 0x37 midi output with time stamp and irq |
| 49 | | 0x38 midi output direct |
| 50 | | |
| 51 | | pro |
| 52 | | 0x48, 0x91 output 8 bit high speed 8bit with dma |
| 53 | | 0x48, 0x99 input 8 bit high speed 8bit with dma |
| 54 | | */ |
| 55 | | typedef enum { OFF, INPUT, OUTPUT } MODE; |
| 56 | | static struct { |
| 57 | | SOUNDBLASTER_CONFIG config; |
| 58 | | // int channel; |
| 59 | | |
| 60 | | MODE mode; |
| 61 | | int on; |
| 62 | | int dma; |
| 63 | | int frequency; |
| 64 | | int count; |
| 65 | | |
| 66 | | int input_state; |
| 67 | | int output_state; |
| 68 | | |
| 69 | | void *timer; |
| 70 | | } blaster={ {0} } ; |
| 71 | | |
| 72 | | void soundblaster_config(const SOUNDBLASTER_CONFIG *config) |
| 73 | | { |
| 74 | | blaster.config = *config; |
| 75 | | } |
| 76 | | |
| 77 | | #ifdef UNUSED_FUNCTION |
| 78 | | void soundblaster_reset(void) |
| 79 | | { |
| 80 | | if (blaster.timer) |
| 81 | | blaster.timer = NULL; |
| 82 | | blaster.on=0; |
| 83 | | blaster.mode=OFF; |
| 84 | | blaster.input_state=0; |
| 85 | | blaster.output_state=0; |
| 86 | | blaster.frequency=0; |
| 87 | | } |
| 88 | | |
| 89 | | int soundblaster_start(void) |
| 90 | | { |
| 91 | | channel = stream_init("PC speaker", 50, Machine->sample_rate, 0, pc_sh_update); |
| 92 | | return 0; |
| 93 | | } |
| 94 | | |
| 95 | | void soundblaster_stop(void) {} |
| 96 | | void soundblaster_update(void) {} |
| 97 | | #endif |
| 98 | | |
| 99 | | READ8_HANDLER( soundblaster_r ) |
| 100 | | { |
| 101 | | int data=0; |
| 102 | | switch (offset) { |
| 103 | | case 0xa: //data input |
| 104 | | switch (blaster.input_state) { |
| 105 | | case 0: |
| 106 | | data=0xaa; |
| 107 | | break; |
| 108 | | case 1: // version high |
| 109 | | data=blaster.config.version.major; |
| 110 | | blaster.input_state++; |
| 111 | | break; |
| 112 | | case 2: // version low |
| 113 | | data=blaster.config.version.minor; |
| 114 | | blaster.input_state=0; |
| 115 | | break; |
| 116 | | case 3: // speaker state |
| 117 | | data=blaster.on?0xff:0; |
| 118 | | blaster.input_state=0; |
| 119 | | break; |
| 120 | | } |
| 121 | | break; |
| 122 | | case 0xc: //status |
| 123 | | break; |
| 124 | | case 0xe: // busy |
| 125 | | data=0x80; |
| 126 | | break; |
| 127 | | } |
| 128 | | return data; |
| 129 | | } |
| 130 | | |
| 131 | | static int soundblaster_operation(int data) |
| 132 | | { |
| 133 | | switch (data) { |
| 134 | | case 0x10: /*play*/ return 1; |
| 135 | | case 0x40: /* set samplerate */ return 1; |
| 136 | | |
| 137 | | case 0xd0: /* dma break */ break; |
| 138 | | case 0xd4: /* dma continue */ break; |
| 139 | | case 0xd1: blaster.on=1; break; |
| 140 | | case 0xd3: blaster.on=0; break; |
| 141 | | case 0xd8: /* read speaker */ blaster.input_state=3; break; |
| 142 | | case 0xe1: /* read version */ blaster.input_state=1; break; |
| 143 | | } |
| 144 | | return 0; |
| 145 | | } |
| 146 | | |
| 147 | | WRITE8_HANDLER( soundblaster_w ) |
| 148 | | { |
| 149 | | device_t *dac_device = space->machine().device("dac"); |
| 150 | | |
| 151 | | switch (offset) { |
| 152 | | case 6: |
| 153 | | if (data!=0) { //reset |
| 154 | | } else { // reset off |
| 155 | | } |
| 156 | | break; |
| 157 | | case 0xc: //operation, data |
| 158 | | switch (blaster.output_state) { |
| 159 | | case 0: |
| 160 | | blaster.output_state=soundblaster_operation(data); |
| 161 | | break; |
| 162 | | case 1: |
| 163 | | blaster.frequency=(int)(1000000.0/(256-data)); |
| 164 | | blaster.output_state=0; |
| 165 | | break; |
| 166 | | case 10: |
| 167 | | dac_data_w(dac_device, data); |
| 168 | | blaster.output_state=0; |
| 169 | | break; |
| 170 | | } |
| 171 | | break; |
| 172 | | } |
| 173 | | } |