d9e74a6f |
1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus-rsp-hle - alist.c * |
3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
4 | * Copyright (C) 2012 Bobby Smiles * |
5 | * Copyright (C) 2009 Richard Goedeken * |
6 | * Copyright (C) 2002 Hacktarux * |
7 | * * |
8 | * This program is free software; you can redistribute it and/or modify * |
9 | * it under the terms of the GNU General Public License as published by * |
10 | * the Free Software Foundation; either version 2 of the License, or * |
11 | * (at your option) any later version. * |
12 | * * |
13 | * This program is distributed in the hope that it will be useful, * |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 | * GNU General Public License for more details. * |
17 | * * |
18 | * You should have received a copy of the GNU General Public License * |
19 | * along with this program; if not, write to the * |
20 | * Free Software Foundation, Inc., * |
21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
22 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
23 | |
24 | #include "hle.h" |
25 | #include "alist_internal.h" |
26 | |
27 | // FIXME: this decomposition into 3 ABI is not accurate, |
28 | // there are a least 9 or 10 different ABI, each with one or a few revisions |
29 | // for a total of almost 16 differents audio ucode. |
30 | // |
31 | // ABI2 in fact is a mix of at least 7 differents ABI which are mostly compatible |
32 | // but not totally, that's why there is a isZeldaABI/isMKABI workaround. |
33 | // |
34 | extern const acmd_callback_t ABI1[0x10]; |
35 | extern const acmd_callback_t ABI2[0x20]; |
36 | extern const acmd_callback_t ABI3[0x10]; |
37 | |
38 | /* local functions */ |
39 | static void alist_process(const acmd_callback_t abi[], unsigned int abi_size) |
40 | { |
41 | u32 inst1, inst2; |
42 | unsigned int acmd; |
43 | const OSTask_t * const task = get_task(); |
44 | |
45 | const unsigned int *alist = (unsigned int*)(rsp.RDRAM + task->data_ptr); |
46 | const unsigned int * const alist_end = alist + (task->data_size >> 2); |
47 | |
48 | while (alist != alist_end) |
49 | { |
50 | inst1 = *(alist++); |
51 | inst2 = *(alist++); |
52 | |
53 | acmd = inst1 >> 24; |
54 | |
55 | if (acmd < abi_size) |
56 | { |
57 | (*abi[acmd])(inst1, inst2); |
58 | } |
59 | else |
60 | { |
61 | DebugMessage(M64MSG_WARNING, "Invalid ABI command %u", acmd); |
62 | } |
63 | } |
64 | } |
65 | |
66 | /* global functions */ |
67 | void alist_process_ABI1() |
68 | { |
69 | alist_process(ABI1, 0x10); |
70 | } |
71 | |
72 | void alist_process_ABI2() |
73 | { |
74 | alist_process(ABI2, 0x20); |
75 | } |
76 | |
77 | void alist_process_ABI3() |
78 | { |
79 | alist_process(ABI3, 0x10); |
80 | } |
81 | |
82 | |