Skip to content

Commit

Permalink
[SMS] Remove pattern cache. Optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
OtherCrashOverride committed Jul 25, 2018
1 parent b0c1165 commit 71636ed
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 161 deletions.
23 changes: 12 additions & 11 deletions smsplusgx-go/components/smsplus/cpu/z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
*****************************************************************************/
#include "shared.h"
#include "z80.h"
#include <esp_attr.h>

#define VERBOSE 0

Expand Down Expand Up @@ -227,7 +228,7 @@ static UINT8 SZHV_dec[256]; /* zero, sign, half carry and overflow flags DEC r8
static UINT8 *SZHVC_add = 0;
static UINT8 *SZHVC_sub = 0;
#else
static UINT8 SZ[256] = { /* zero and sign flags */
static DRAM_ATTR const UINT8 SZ[256] = { /* zero and sign flags */
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
Expand All @@ -245,7 +246,7 @@ static UINT8 SZ[256] = { /* zero and sign flags */
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8 };

static UINT8 SZ_BIT[256] = {
static DRAM_ATTR const UINT8 SZ_BIT[256] = {
0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
Expand All @@ -263,7 +264,7 @@ static UINT8 SZ_BIT[256] = {
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8 };

static UINT8 SZP[256] = {
static DRAM_ATTR const UINT8 SZP[256] = {
0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, 0x08, 0x0c, 0x0c, 0x08, 0x0c, 0x08, 0x08, 0x0c,
0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x08, 0x08, 0x0c, 0x08, 0x0c, 0x0c, 0x08,
0x20, 0x24, 0x24, 0x20, 0x24, 0x20, 0x20, 0x24, 0x2c, 0x28, 0x28, 0x2c, 0x28, 0x2c, 0x2c, 0x28,
Expand All @@ -281,7 +282,7 @@ static UINT8 SZP[256] = {
0xa0, 0xa4, 0xa4, 0xa0, 0xa4, 0xa0, 0xa0, 0xa4, 0xac, 0xa8, 0xa8, 0xac, 0xa8, 0xac, 0xac, 0xa8,
0xa4, 0xa0, 0xa0, 0xa4, 0xa0, 0xa4, 0xa4, 0xa0, 0xa8, 0xac, 0xac, 0xa8, 0xac, 0xa8, 0xa8, 0xac };

static UINT8 SZHV_inc[256] = {
static DRAM_ATTR const UINT8 SZHV_inc[256] = {
0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
Expand All @@ -299,7 +300,7 @@ static UINT8 SZHV_inc[256] = {
0xb0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8,
0xb0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8, 0xa8 };

static UINT8 SZHV_dec[256] = {
static DRAM_ATTR const UINT8 SZHV_dec[256] = {
0x42, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x1a,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x1a,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x3a,
Expand All @@ -322,7 +323,7 @@ extern const UINT8 SZHVC_add[2 * 256 * 256];
extern const UINT8 SZHVC_sub[2*256*256];
#endif

static UINT8 cc_op[0x100] = {
static DRAM_ATTR const UINT8 cc_op[0x100] = {
4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4,
8,10, 7, 6, 4, 4, 7, 4,12,11, 7, 6, 4, 4, 7, 4,
7,10,16, 6, 4, 4, 7, 4, 7,11,16, 6, 4, 4, 7, 4,
Expand All @@ -340,7 +341,7 @@ static UINT8 cc_op[0x100] = {
5,10,10,19,10,11, 7,11, 5, 4,10, 4,10, 0, 7,11,
5,10,10, 4,10,11, 7,11, 5, 6,10, 4,10, 0, 7,11};

static UINT8 cc_cb[0x100] = {
static DRAM_ATTR const UINT8 cc_cb[0x100] = {
8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
Expand All @@ -358,7 +359,7 @@ static UINT8 cc_cb[0x100] = {
8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8};

static UINT8 cc_ed[0x100] = {
static DRAM_ATTR const UINT8 cc_ed[0x100] = {
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
Expand Down Expand Up @@ -396,7 +397,7 @@ static UINT8 cc_ed[0x100] = {
*/

/* illegal combo should return 4 + cc_op[i] */
static UINT8 cc_xy[0x100] ={
static DRAM_ATTR const UINT8 cc_xy[0x100] ={
8,14,11,10, 8, 8,11, 8, 8,15,11,10, 8, 8,11, 8,
12,14,11,10, 8, 8,11, 8,16,15,11,10, 8, 8,11, 8,
11,14,20,10, 9, 9,12, 8,11,15,20,10, 9, 9,12, 8,
Expand All @@ -414,7 +415,7 @@ static UINT8 cc_xy[0x100] ={
9,14,14,23,14,15,11,15, 9, 8,14, 8,14, 4,11,15,
9,14,14, 8,14,15,11,15, 9,10,14, 8,14, 4,11,15};

static UINT8 cc_xycb[0x100] = {
static DRAM_ATTR const UINT8 cc_xycb[0x100] = {
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
Expand All @@ -433,7 +434,7 @@ static UINT8 cc_xycb[0x100] = {
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23};

/* extra cycles if jr/jp/call taken and 'interrupt latency' on rst 0-7 */
static UINT8 cc_ex[0x100] = {
static DRAM_ATTR const UINT8 cc_ex[0x100] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* DJNZ */
5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, /* JR NZ/JR Z */
Expand Down
Loading

0 comments on commit 71636ed

Please sign in to comment.