clarify PicoDrive's license
[picodrive.git] / pico / carthw / svp / ssp16.h
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  */
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 {
49                 unsigned short RAM[256*2];      // 000 2 internal RAM banks
50                 struct {
51                         unsigned short RAM0[256];
52                         unsigned short RAM1[256];
53                 };
54         };
55         ssp_reg_t gr[16];                       // 400 general registers
56         union {
57                 unsigned char r[8];             // 440 BANK pointers
58                 struct {
59                         unsigned char r0[4];
60                         unsigned char r1[4];
61                 };
62         };
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 ...
66         //
67         #define SSP_PMC_HAVE_ADDR       0x0001  // address written to PMAC, waiting for mode
68         #define SSP_PMC_SET             0x0002  // PMAC is set
69         #define SSP_WAIT_PM0            0x2000  // bit1 in PM0
70         #define SSP_WAIT_30FE06         0x4000  // ssp tight loops on 30FE06 to become non-zero
71         #define SSP_WAIT_30FE08         0x8000  // same for 30FE06
72         #define SSP_WAIT_MASK           0xe000
73         unsigned int emu_status;                // 484
74         /* used by recompiler only: */
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
80                 unsigned int iram_context;      // 498
81                 unsigned int ptr_btable;        // 49c
82                 unsigned int ptr_btable_iram;   // 4a0
83                 unsigned int tmp0;              // 4a4
84                 unsigned int tmp1;              // 4a8
85                 unsigned int tmp2;              // 4ac
86         } drc;
87 } ssp1601_t;
88
89
90 void ssp1601_reset(ssp1601_t *ssp);
91 void ssp1601_run(int cycles);
92