~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to docs/DSP/DSP_InterC/DSP_InterC/DSPExt.cpp

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*====================================================================
 
2
 
 
3
   filename:     opcodes.h
 
4
   project:      GameCube DSP Tool (gcdsp)
 
5
   created:      2005.03.04
 
6
   mail:                  duddie@walla.com
 
7
 
 
8
   Copyright (c) 2005 Duddie
 
9
 
 
10
   This program is free software; you can redistribute it and/or
 
11
   modify it under the terms of the GNU General Public License
 
12
   as published by the Free Software Foundation; either version 2
 
13
   of the License, or (at your option) any later version.
 
14
 
 
15
   This program is distributed in the hope that it will be useful,
 
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
   GNU General Public License for more details.
 
19
 
 
20
   You should have received a copy of the GNU General Public License
 
21
   along with this program; if not, write to the Free Software
 
22
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
23
 
 
24
   ====================================================================*/
 
25
//
 
26
//
 
27
// At the moment just ls and sl are using the prolog
 
28
// perhaps all actions on r03 must be in the prolog
 
29
//
 
30
#include <stdafx.h>
 
31
 
 
32
#include "OutBuffer.h"
 
33
 
 
34
 
 
35
 
 
36
//
 
37
void dsp_op_ext_r_epi(uint16 _Opcode)
 
38
{
 
39
        uint8 op  = (_Opcode >> 2) & 0x3;
 
40
        uint8 reg = _Opcode & 0x3;
 
41
 
 
42
        switch (op)
 
43
        {
 
44
            case 0x00:
 
45
                        OutBuffer::AddCode("Error: dsp_op_ext_r_epi");
 
46
                    break;
 
47
 
 
48
            case 0x01:
 
49
                        OutBuffer::AddCode("%s--", OutBuffer::GetRegName(reg));
 
50
                    // g_dsp.r[reg]--;
 
51
                    break;
 
52
 
 
53
            case 0x02:
 
54
                        OutBuffer::AddCode("%s++", OutBuffer::GetRegName(reg));
 
55
                    //g_dsp.r[reg]++;
 
56
                    break;
 
57
 
 
58
            case 0x03:
 
59
                        OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(reg), OutBuffer::GetRegName(reg+4));
 
60
                    // g_dsp.r[reg] += g_dsp.r[reg + 4];
 
61
                    break;
 
62
        }
 
63
}
 
64
 
 
65
 
 
66
void dsp_op_ext_mv(uint16 _Opcode)
 
67
{
 
68
        uint8 sreg = _Opcode & 0x3;
 
69
        uint8 dreg = ((_Opcode >> 2) & 0x3);
 
70
 
 
71
        OutBuffer::AddCode("%s = %s", OutBuffer::GetRegName(dreg + 0x18), OutBuffer::GetRegName(sreg + 0x1c));
 
72
 
 
73
        // g_dsp.r[dreg + 0x18] = g_dsp.r[sreg + 0x1c];
 
74
}
 
75
 
 
76
 
 
77
void dsp_op_ext_s(uint16 _Opcode)
 
78
{
 
79
        uint8 dreg = _Opcode & 0x3;
 
80
        uint8 sreg = ((_Opcode >> 3) & 0x3) + 0x1c;
 
81
 
 
82
        OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
 
83
        // dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]);
 
84
 
 
85
        if (_Opcode & 0x04)
 
86
        {
 
87
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(dreg+4));
 
88
                // g_dsp.r[dreg] += g_dsp.r[dreg + 4];
 
89
        }
 
90
        else
 
91
        {
 
92
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(dreg));
 
93
                //g_dsp.r[dreg]++;
 
94
        }
 
95
}
 
96
 
 
97
 
 
98
void dsp_op_ext_l(uint16 _Opcode)
 
99
{
 
100
        uint8 sreg = _Opcode & 0x3;
 
101
        uint8 dreg = ((_Opcode >> 3) & 0x7) + 0x18;
 
102
 
 
103
        OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
 
104
        // uint16 val = dsp_dmem_read(g_dsp.r[sreg]);
 
105
        // g_dsp.r[dreg] = val;
 
106
 
 
107
        if (_Opcode & 0x04)
 
108
        {
 
109
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(sreg), OutBuffer::GetRegName(sreg+4));
 
110
                // g_dsp.r[sreg] += g_dsp.r[sreg + 4];
 
111
        }
 
112
        else
 
113
        {
 
114
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(sreg));
 
115
                // g_dsp.r[sreg]++;
 
116
        }
 
117
}
 
118
 
 
119
 
 
120
void dsp_op_ext_ls_pro(uint16 _Opcode)
 
121
{
 
122
        uint8 areg = (_Opcode & 0x1) + 0x1e;
 
123
 
 
124
        OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(areg));
 
125
        // dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]);
 
126
 
 
127
        if (_Opcode & 0x8)
 
128
        {
 
129
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(0x07));
 
130
                // g_dsp.r[0x03] += g_dsp.r[0x07];
 
131
        }
 
132
        else
 
133
        {
 
134
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
 
135
                // g_dsp.r[0x03]++;
 
136
        }
 
137
}
 
138
 
 
139
 
 
140
void dsp_op_ext_ls_epi(uint16 _Opcode)
 
141
{
 
142
        uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
 
143
 
 
144
        OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x00));
 
145
        // uint16 val = dsp_dmem_read(g_dsp.r[0x00]);
 
146
        // dsp_op_write_reg(dreg, val);
 
147
 
 
148
        if (_Opcode & 0x4)
 
149
        {
 
150
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(0x04));
 
151
                // g_dsp.r[0x00] += g_dsp.r[0x04];
 
152
        }
 
153
        else
 
154
        {
 
155
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x00));
 
156
                // g_dsp.r[0x00]++;
 
157
        }
 
158
}
 
159
 
 
160
 
 
161
void dsp_op_ext_sl_pro(uint16 _Opcode)
 
162
{
 
163
        uint8 areg = (_Opcode & 0x1) + 0x1e;
 
164
 
 
165
        OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(areg));
 
166
        // dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]);
 
167
 
 
168
        if (_Opcode & 0x4)
 
169
        {
 
170
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(0x04));
 
171
                // g_dsp.r[0x00] += g_dsp.r[0x04];
 
172
        }
 
173
        else
 
174
        {
 
175
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x00));
 
176
                // g_dsp.r[0x00]++;
 
177
        }
 
178
}
 
179
 
 
180
 
 
181
void dsp_op_ext_sl_epi(uint16 _Opcode)
 
182
{
 
183
        uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
 
184
 
 
185
        OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x03));
 
186
        // uint16 val = dsp_dmem_read(g_dsp.r[0x03]);
 
187
        // dsp_op_write_reg(dreg, val);
 
188
 
 
189
        if (_Opcode & 0x8)
 
190
        {
 
191
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(0x07));
 
192
                // g_dsp.r[0x03] += g_dsp.r[0x07];
 
193
        }
 
194
        else
 
195
        {
 
196
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
 
197
                // g_dsp.r[0x03]++;
 
198
        }
 
199
}
 
200
 
 
201
 
 
202
void dsp_op_ext_ld(uint16 _Opcode)
 
203
{
 
204
        uint8 dreg1 = (((_Opcode >> 5) & 0x1) << 1) + 0x18;
 
205
        uint8 dreg2 = (((_Opcode >> 4) & 0x1) << 1) + 0x19;
 
206
        uint8 sreg = _Opcode & 0x3;
 
207
 
 
208
        OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg1), OutBuffer::GetRegName(sreg));
 
209
        OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg2), OutBuffer::GetRegName(0x03));
 
210
 
 
211
        // g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]);
 
212
        // g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]);
 
213
 
 
214
        if (_Opcode & 0x04)
 
215
        {
 
216
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(sreg), OutBuffer::GetRegName(sreg + 0x04));
 
217
                // g_dsp.r[sreg] += g_dsp.r[sreg + 0x04];
 
218
        }
 
219
        else
 
220
        {
 
221
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(sreg));
 
222
                // g_dsp.r[sreg]++;
 
223
        }
 
224
 
 
225
        if (_Opcode & 0x08)
 
226
        {
 
227
                OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(sreg + 0x07));
 
228
                // g_dsp.r[0x03] += g_dsp.r[0x07];
 
229
        }
 
230
        else
 
231
        {
 
232
                OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
 
233
                // g_dsp.r[0x03]++;
 
234
        }
 
235
}
 
236
 
 
237
 
 
238
// ================================================================================
 
239
//
 
240
//
 
241
//
 
242
// ================================================================================
 
243
 
 
244
void dsp_op_ext_ops_pro(uint16 _Opcode)
 
245
{
 
246
        if ((_Opcode & 0xFF) == 0){return;}
 
247
 
 
248
        switch ((_Opcode >> 4) & 0xf)
 
249
        {
 
250
            case 0x00:
 
251
                    dsp_op_ext_r_epi(_Opcode);
 
252
                    break;
 
253
 
 
254
            case 0x01:
 
255
                    dsp_op_ext_mv(_Opcode);
 
256
                    break;
 
257
 
 
258
            case 0x02:
 
259
            case 0x03:
 
260
                    dsp_op_ext_s(_Opcode);
 
261
                    break;
 
262
 
 
263
            case 0x04:
 
264
            case 0x05:
 
265
            case 0x06:
 
266
            case 0x07:
 
267
                    dsp_op_ext_l(_Opcode);
 
268
                    break;
 
269
 
 
270
            case 0x08:
 
271
            case 0x09:
 
272
            case 0x0a:
 
273
            case 0x0b:
 
274
 
 
275
                    if (_Opcode & 0x2)
 
276
                    {
 
277
                            dsp_op_ext_sl_pro(_Opcode);
 
278
                    }
 
279
                    else
 
280
                    {
 
281
                            dsp_op_ext_ls_pro(_Opcode);
 
282
                    }
 
283
 
 
284
                    return;
 
285
 
 
286
            case 0x0c:
 
287
            case 0x0d:
 
288
            case 0x0e:
 
289
            case 0x0f:
 
290
                    dsp_op_ext_ld(_Opcode);
 
291
                    break;
 
292
        }
 
293
}
 
294
 
 
295
 
 
296
void dsp_op_ext_ops_epi(uint16 _Opcode)
 
297
{
 
298
        if ((_Opcode & 0xFF) == 0){return;}
 
299
 
 
300
        switch ((_Opcode >> 4) & 0xf)
 
301
        {
 
302
            case 0x08:
 
303
            case 0x09:
 
304
            case 0x0a:
 
305
            case 0x0b:
 
306
 
 
307
                    if (_Opcode & 0x2)
 
308
                    {
 
309
                            dsp_op_ext_sl_epi(_Opcode);
 
310
                    }
 
311
                    else
 
312
                    {
 
313
                            dsp_op_ext_ls_epi(_Opcode);
 
314
                    }
 
315
 
 
316
                    return;
 
317
        }
 
318
}
 
319
 
 
320