src/mess/drivers/tsispch.c
| r10807 | r10808 | |
| 72 | 72 | // unpack 24 bit data into 32 bit space |
| 73 | 73 | // TODO: unpack such that it can actually RUN as upd7725 code; this requires |
| 74 | 74 | // some shuffling: |
| 75 | | // data format as-is in dspsrc: |
| 76 | | // bit 7 6 5 4 3 2 1 0 |
| 77 | | // b1 15 16 17 18 19 20 21 22 >- needs to be flipped around |
| 78 | | // b2 XX 8 9 10 11 12 13 14 >- needs to be flipped around and the zero moved to bit 4 |
| 75 | // data format as-is in dspsrc: (L = always 0, X = doesn't matter) |
| 76 | // source dest |
| 77 | // bit 7 6 5 4 3 2 1 0 bit 7 6 5 4 3 2 1 0 |
| 78 | // for OP/RT: |
| 79 | // b1 15 16 17 18 19 20 21 22 -> 22 21 20 19 18 17 16 15 |
| 80 | // b2 L 8 9 10 11 12 13 14 -> 14 13 12 L 11 10 9 8 |
| 81 | // b3 0 1 2 3 4 5 6 7 -> 7 6 5 4 3 2 1 0 |
| 82 | // for JP: |
| 83 | // b1 15 16 17 18 19 20 21 22 -> 22 21 20 19 18 17 16 15 |
| 84 | // b2 L 8 9 10 11 12 13 14 -> 14 13 L L L 12 11 10 |
| 85 | // b3 0 1 2 3 4 5 6 7 -> 9 8 7 6 5 4 X X |
| 86 | // for LD: |
| 87 | // b1 15 16 17 18 19 20 21 22 -> 22 21 20 19 18 17 16 15 |
| 88 | // b2 L 8 9 10 11 12 13 14 -> 14 13 12 11 10 9 8 7 |
| 89 | // b3 0 1 2 3 4 5 6 7 -> 6 5 X X 3 2 1 0 |
| 79 | 90 | UINT8 byte1; |
| 80 | 91 | UINT8 byte2; |
| 81 | 92 | UINT8 byte3; |
| 82 | 93 | for (int i = 0; i < 0x600; i+= 3) |
| 83 | 94 | { |
| 84 | | byte1 = BIT(dspsrc[0+i],0)<<7; |
| 85 | | byte1 |= BIT(dspsrc[0+i],1)<<6; |
| 86 | | byte1 |= BIT(dspsrc[0+i],2)<<5; |
| 87 | | byte1 |= BIT(dspsrc[0+i],3)<<4; |
| 88 | | byte1 |= BIT(dspsrc[0+i],4)<<3; |
| 89 | | byte1 |= BIT(dspsrc[0+i],5)<<2; |
| 90 | | byte1 |= BIT(dspsrc[0+i],6)<<1; |
| 91 | | byte1 |= BIT(dspsrc[0+i],7)<<0; |
| 95 | byte1 = BIT(dspsrc[0+i],0)<<7; // bit 22 goes to bit 23 |
| 96 | byte1 |= BIT(dspsrc[0+i],1)<<6; // bit 21 goes to bit 22 |
| 97 | byte1 |= BIT(dspsrc[0+i],2)<<5; // bit 20 goes to bit 21 |
| 98 | byte1 |= BIT(dspsrc[0+i],3)<<4; // bit 19 goes to bit 20 |
| 99 | byte1 |= BIT(dspsrc[0+i],4)<<3; // bit 18 goes to bit 19 |
| 100 | byte1 |= BIT(dspsrc[0+i],5)<<2; // bit 17 goes to bit 18 |
| 101 | byte1 |= BIT(dspsrc[0+i],6)<<1; // bit 16 goes to bit 17 |
| 102 | byte1 |= BIT(dspsrc[0+i],7)<<0; // bit 15 goes to bit 16 |
| 92 | 103 | // here's where things get disgusting: if the first byte was an OP or RT, do the following: |
| 93 | 104 | if ((byte1&0x80) == 0x00) |
| 94 | 105 | { |
| 95 | | byte2 = BIT(dspsrc[1+i],0)<<7; |
| 96 | | byte2 |= BIT(dspsrc[1+i],1)<<6; |
| 97 | | byte2 |= BIT(dspsrc[1+i],2)<<5; |
| 98 | | byte2 |= BIT(dspsrc[1+i],7)<<4; // should be always 0 |
| 99 | | byte2 |= BIT(dspsrc[1+i],3)<<3; |
| 100 | | byte2 |= BIT(dspsrc[1+i],4)<<2; |
| 101 | | byte2 |= BIT(dspsrc[1+i],5)<<1; |
| 102 | | byte2 |= BIT(dspsrc[1+i],6)<<0; |
| 106 | byte2 = BIT(dspsrc[1+i],0)<<7; // bit 14 goes to bit 15 |
| 107 | byte2 |= BIT(dspsrc[1+i],1)<<6; // bit 13 goes to bit 14 |
| 108 | byte2 |= BIT(dspsrc[1+i],2)<<5; // bit 12 goes to bit 13 |
| 109 | byte2 |= BIT(dspsrc[1+i],7)<<4; // 0 goes to bit 12 |
| 110 | byte2 |= BIT(dspsrc[1+i],3)<<3; // bit 11 goes to bit 11 |
| 111 | byte2 |= BIT(dspsrc[1+i],4)<<2; // bit 10 goes to bit 10 |
| 112 | byte2 |= BIT(dspsrc[1+i],5)<<1; // bit 9 goes to bit 9 |
| 113 | byte2 |= BIT(dspsrc[1+i],6)<<0; // bit 8 goes to bit 8 |
| 103 | 114 | |
| 104 | | byte3 = BIT(dspsrc[2+i],0)<<7; |
| 105 | | byte3 |= BIT(dspsrc[2+i],1)<<6; |
| 106 | | byte3 |= BIT(dspsrc[2+i],2)<<5; |
| 107 | | byte3 |= BIT(dspsrc[2+i],3)<<4; |
| 108 | | byte3 |= BIT(dspsrc[2+i],4)<<3; |
| 109 | | byte3 |= BIT(dspsrc[2+i],5)<<2; |
| 110 | | byte3 |= BIT(dspsrc[2+i],6)<<1; |
| 111 | | byte3 |= BIT(dspsrc[2+i],7)<<0; |
| 115 | byte3 = BIT(dspsrc[2+i],0)<<7; // bit 7 goes to bit 7 |
| 116 | byte3 |= BIT(dspsrc[2+i],1)<<6; // bit 6 goes to bit 6 |
| 117 | byte3 |= BIT(dspsrc[2+i],2)<<5; // bit 5 goes to bit 5 |
| 118 | byte3 |= BIT(dspsrc[2+i],3)<<4; // bit 4 goes to bit 4 |
| 119 | byte3 |= BIT(dspsrc[2+i],4)<<3; // bit 3 goes to bit 3 |
| 120 | byte3 |= BIT(dspsrc[2+i],5)<<2; // bit 2 goes to bit 2 |
| 121 | byte3 |= BIT(dspsrc[2+i],6)<<1; // bit 1 goes to bit 1 |
| 122 | byte3 |= BIT(dspsrc[2+i],7)<<0; // bit 0 goes to bit 0 |
| 112 | 123 | } |
| 113 | 124 | else if ((byte1&0xC0) == 0x80) // jp instruction |
| 114 | 125 | { |
| 115 | | byte2 = BIT(dspsrc[1+i],0)<<7; // bit 15 goes to bit 15 |
| 116 | | byte2 |= BIT(dspsrc[1+i],1)<<6; // bit 14 goes to bit 14 |
| 126 | byte2 = BIT(dspsrc[1+i],0)<<7; // bit 14 goes to bit 15 |
| 127 | byte2 |= BIT(dspsrc[1+i],1)<<6; // bit 13 goes to bit 14 |
| 117 | 128 | byte2 |= BIT(dspsrc[1+i],7)<<5; // 0 goes to bit 13 |
| 118 | 129 | byte2 |= BIT(dspsrc[1+i],7)<<4; // 0 goes to bit 12 |
| 119 | 130 | byte2 |= BIT(dspsrc[1+i],7)<<3; // 0 goes to bit 11 |
| r10807 | r10808 | |
| 127 | 138 | byte3 |= BIT(dspsrc[2+i],1)<<4; // bit 6 goes to bit 4 |
| 128 | 139 | byte3 |= BIT(dspsrc[2+i],2)<<3; // bit 5 goes to bit 3 |
| 129 | 140 | byte3 |= BIT(dspsrc[2+i],3)<<2; // bit 4 goes to bit 2 |
| 130 | | byte3 |= BIT(dspsrc[2+i],6)<<1; |
| 131 | | byte3 |= BIT(dspsrc[2+i],7)<<0; |
| 141 | byte3 |= BIT(dspsrc[2+i],6)<<1; // bit 1/doesn't matter goes to bit 1 |
| 142 | byte3 |= BIT(dspsrc[2+i],7)<<0; // bit 0/doesn't matter goes to bit 0 |
| 132 | 143 | } |
| 133 | 144 | else // ld instruction |
| 134 | 145 | { |
| 135 | | byte2 = BIT(dspsrc[1+i],0)<<7; // bit 15 goes to bit 15 |
| 136 | | byte2 |= BIT(dspsrc[1+i],1)<<6; // bit 14 goes to bit 14 |
| 137 | | byte2 |= BIT(dspsrc[1+i],2)<<5; // bit 13 goes to bit 13 |
| 138 | | byte2 |= BIT(dspsrc[1+i],3)<<4; // bit 12 goes to bit 12 |
| 139 | | byte2 |= BIT(dspsrc[1+i],4)<<3; // bit 11 goes to bit 11 |
| 140 | | byte2 |= BIT(dspsrc[1+i],5)<<2; // bit 10 goes to bit 10 |
| 141 | | byte2 |= BIT(dspsrc[1+i],6)<<1; // bit 9 goes to bit 9 |
| 142 | | byte2 |= BIT(dspsrc[2+i],0)<<0; // bit 8 goes to bit 8 |
| 146 | byte2 = BIT(dspsrc[1+i],0)<<7; // bit 14 goes to bit 15 |
| 147 | byte2 |= BIT(dspsrc[1+i],1)<<6; // bit 13 goes to bit 14 |
| 148 | byte2 |= BIT(dspsrc[1+i],2)<<5; // bit 12 goes to bit 13 |
| 149 | byte2 |= BIT(dspsrc[1+i],3)<<4; // bit 11 goes to bit 12 |
| 150 | byte2 |= BIT(dspsrc[1+i],4)<<3; // bit 10 goes to bit 11 |
| 151 | byte2 |= BIT(dspsrc[1+i],5)<<2; // bit 9 goes to bit 10 |
| 152 | byte2 |= BIT(dspsrc[1+i],6)<<1; // bit 8 goes to bit 9 |
| 153 | byte2 |= BIT(dspsrc[2+i],0)<<0; // bit 7 goes to bit 8 |
| 143 | 154 | |
| 144 | | byte3 = BIT(dspsrc[2+i],1)<<7; // bit 7 goes to bit 7 |
| 145 | | byte3 |= BIT(dspsrc[2+i],2)<<6; // bit 6 goes to bit 6 |
| 146 | | byte3 |= BIT(dspsrc[2+i],3)<<5; // 0 goes to bit 5 |
| 147 | | byte3 |= BIT(dspsrc[2+i],3)<<4; // 0 goes to bit 4 |
| 155 | byte3 = BIT(dspsrc[2+i],1)<<7; // bit 6 goes to bit 7 |
| 156 | byte3 |= BIT(dspsrc[2+i],2)<<6; // bit 5 goes to bit 6 |
| 157 | byte3 |= BIT(dspsrc[2+i],3)<<5; // bit 4/doesn't matter goes to bit 5 |
| 158 | byte3 |= BIT(dspsrc[2+i],3)<<4; // bit 4/doesn't matter goes to bit 4 |
| 148 | 159 | byte3 |= BIT(dspsrc[2+i],4)<<3; // bit 3 goes to bit 3 |
| 149 | 160 | byte3 |= BIT(dspsrc[2+i],5)<<2; // bit 2 goes to bit 2 |
| 150 | 161 | byte3 |= BIT(dspsrc[2+i],6)<<1; // bit 1 goes to bit 1 |