cff531af |
1 | /* |
2 | * basic, incomplete SSP160x (SSP1601?) interpreter |
3 | * |
4 | * Copyright (c) GraÅžvydas "notaz" Ignotas, 2008 |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: |
8 | * * Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * * Neither the name of the organization nor the |
14 | * names of its contributors may be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
f8ef8ff7 |
28 | |
29 | // register names |
30 | enum { |
31 | SSP_GR0, SSP_X, SSP_Y, SSP_A, |
32 | SSP_ST, SSP_STACK, SSP_PC, SSP_P, |
33 | SSP_PM0, SSP_PM1, SSP_PM2, SSP_XST, |
34 | SSP_PM4, SSP_gr13, SSP_PMC, SSP_AL |
35 | }; |
36 | |
37 | typedef union |
38 | { |
39 | unsigned int v; |
40 | struct { |
41 | unsigned short l; |
42 | unsigned short h; |
43 | }; |
44 | } ssp_reg_t; |
45 | |
46 | typedef struct |
47 | { |
48 | union { |
5c129565 |
49 | unsigned short RAM[256*2]; // 000 2 internal RAM banks |
f8ef8ff7 |
50 | struct { |
51 | unsigned short RAM0[256]; |
52 | unsigned short RAM1[256]; |
53 | }; |
54 | }; |
5c129565 |
55 | ssp_reg_t gr[16]; // 400 general registers |
f8ef8ff7 |
56 | union { |
5c129565 |
57 | unsigned char r[8]; // 440 BANK pointers |
f8ef8ff7 |
58 | struct { |
59 | unsigned char r0[4]; |
60 | unsigned char r1[4]; |
61 | }; |
62 | }; |
5c129565 |
63 | unsigned short stack[6]; // 448 |
64 | unsigned int pmac_read[6]; // 454 read modes/addrs for PM0-PM5 |
65 | unsigned int pmac_write[6]; // 46c write ... |
f8ef8ff7 |
66 | // |
30752975 |
67 | #define SSP_PMC_HAVE_ADDR 0x0001 // address written to PMAC, waiting for mode |
68 | #define SSP_PMC_SET 0x0002 // PMAC is set |
d26dc685 |
69 | #define SSP_WAIT_PM0 0x2000 // bit1 in PM0 |
b9c1d012 |
70 | #define SSP_WAIT_30FE06 0x4000 // ssp tight loops on 30FE06 to become non-zero |
6e39239f |
71 | #define SSP_WAIT_30FE08 0x8000 // same for 30FE06 |
d26dc685 |
72 | #define SSP_WAIT_MASK 0xe000 |
5c129565 |
73 | unsigned int emu_status; // 484 |
d274c33b |
74 | /* used by recompiler only: */ |
e122fae6 |
75 | struct { |
76 | unsigned int ptr_rom; // 488 |
77 | unsigned int ptr_iram_rom; // 48c |
78 | unsigned int ptr_dram; // 490 |
79 | unsigned int iram_dirty; // 494 |
71bb1b7b |
80 | unsigned int iram_context; // 498 |
81 | unsigned int ptr_btable; // 49c |
82 | unsigned int ptr_btable_iram; // 4a0 |
83 | unsigned int tmp0; // 4a4 |
45883918 |
84 | unsigned int tmp1; // 4a8 |
85 | unsigned int tmp2; // 4ac |
e122fae6 |
86 | } drc; |
f8ef8ff7 |
87 | } ssp1601_t; |
88 | |
89 | |
90 | void ssp1601_reset(ssp1601_t *ssp); |
017512f2 |
91 | void ssp1601_run(int cycles); |
f8ef8ff7 |
92 | |