| 1 | /* |
| 2 | * (C) GraÅžvydas "notaz" Ignotas, 2011 |
| 3 | * |
| 4 | * This work is licensed under the terms of GNU GPL version 2 or later. |
| 5 | * See the COPYING file in the top-level directory. |
| 6 | */ |
| 7 | |
| 8 | static int pcsx_direct_read(int type, u_int addr, int cc_adj, int cc, int rs, int rt) |
| 9 | { |
| 10 | if ((addr & 0xfffff000) == 0x1f801000) { |
| 11 | u_int t; |
| 12 | switch (addr & 0xffff) { |
| 13 | case 0x1120: // rcnt2 count |
| 14 | if (rt < 0) goto dont_care; |
| 15 | if (cc < 0) return 0; |
| 16 | emit_readword((int)&rcnts[2].mode, HOST_TEMPREG); |
| 17 | emit_readword((int)&rcnts[2].cycleStart, rt); |
| 18 | emit_testimm(HOST_TEMPREG, 0x200); |
| 19 | emit_readword((int)&last_count, HOST_TEMPREG); |
| 20 | emit_sub(HOST_TEMPREG, rt, HOST_TEMPREG); |
| 21 | emit_add(HOST_TEMPREG, cc, HOST_TEMPREG); |
| 22 | if (cc_adj) |
| 23 | emit_addimm(HOST_TEMPREG, cc_adj, rt); |
| 24 | emit_shrne_imm(rt, 3, rt); |
| 25 | mov_loadtype_adj(type!=LOADW_STUB?type:LOADH_STUB, rt, rt); |
| 26 | goto hit; |
| 27 | case 0x1104: |
| 28 | case 0x1114: |
| 29 | case 0x1124: // rcnt mode |
| 30 | if (rt < 0) return 0; |
| 31 | t = (addr >> 4) & 3; |
| 32 | emit_readword((int)&rcnts[t].mode, rt); |
| 33 | emit_andimm(rt, ~0x1800, HOST_TEMPREG); |
| 34 | emit_writeword(HOST_TEMPREG, (int)&rcnts[t].mode); |
| 35 | mov_loadtype_adj(type, rt, rt); |
| 36 | goto hit; |
| 37 | } |
| 38 | } |
| 39 | else { |
| 40 | if (rt < 0) |
| 41 | goto dont_care; |
| 42 | } |
| 43 | |
| 44 | return 0; |
| 45 | |
| 46 | hit: |
| 47 | assem_debug("pcsx_direct_read %08x end\n", addr); |
| 48 | return 1; |
| 49 | |
| 50 | dont_care: |
| 51 | assem_debug("pcsx_direct_read %08x dummy\n", addr); |
| 52 | return 1; |
| 53 | } |
| 54 | |
| 55 | // vim:shiftwidth=2:expandtab |