| | 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 <stdint.h> |
| | 25 | #include "m64p_plugin.h" |
| | 26 | #include "m64p_types.h" |
| | 27 | |
| | 28 | #include "hle.h" |
| | 29 | #include "alist_internal.h" |
| | 30 | #include "alist.h" |
| | 31 | |
| | 32 | /* local functions */ |
| | 33 | static void alist_process(const acmd_callback_t abi[], unsigned int abi_size) |
| | 34 | { |
| | 35 | uint32_t inst1, inst2; |
| | 36 | unsigned int acmd; |
| | 37 | const OSTask_t *const task = get_task(); |
| | 38 | |
| | 39 | const unsigned int *alist = (unsigned int *)(rsp.RDRAM + task->data_ptr); |
| | 40 | const unsigned int *const alist_end = alist + (task->data_size >> 2); |
| | 41 | |
| | 42 | while (alist != alist_end) { |
| | 43 | inst1 = *(alist++); |
| | 44 | inst2 = *(alist++); |
| | 45 | |
| | 46 | acmd = inst1 >> 24; |
| | 47 | |
| | 48 | if (acmd < abi_size) |
| | 49 | (*abi[acmd])(inst1, inst2); |
| | 50 | else |
| | 51 | DebugMessage(M64MSG_WARNING, "Invalid ABI command %u", acmd); |
| | 52 | } |
| | 53 | } |
| | 54 | |
| | 55 | /* global functions */ |
| | 56 | void alist_process_ABI1(void) |
| | 57 | { |
| | 58 | alist_process(ABI1, 0x10); |
| | 59 | } |
| | 60 | |
| | 61 | void alist_process_ABI2(void) |
| | 62 | { |
| | 63 | alist_process(ABI2, 0x20); |
| | 64 | } |
| | 65 | |
| | 66 | void alist_process_ABI3(void) |
| | 67 | { |
| | 68 | alist_process(ABI3, 0x10); |
| | 69 | } |
| | 70 | |