Search
lxdream.org :: lxdream/src/sh4/sh4mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4mem.c
changeset 418:b9b14afa0959
prev406:9289b62f8f33
next419:09f85e586ff2
author nkeynes
date Thu Oct 04 08:47:52 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Add explicit branch cases for main ram - yes it's faster...
file annotate diff log raw
1.1 --- a/src/sh4/sh4mem.c Fri Sep 28 07:25:22 2007 +0000
1.2 +++ b/src/sh4/sh4mem.c Thu Oct 04 08:47:52 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: sh4mem.c,v 1.24 2007-09-28 07:25:22 nkeynes Exp $
1.6 + * $Id: sh4mem.c,v 1.25 2007-10-04 08:47:52 nkeynes Exp $
1.7 * sh4mem.c is responsible for the SH4's access to memory (including memory
1.8 * mapped I/O), using the page maps created in mem.c
1.9 *
1.10 @@ -65,6 +65,7 @@
1.11
1.12 extern struct mem_region mem_rgn[];
1.13 extern struct mmio_region *P4_io[];
1.14 +char *sh4_main_ram;
1.15
1.16 int32_t sh4_read_p4( uint32_t addr )
1.17 {
1.18 @@ -130,10 +131,11 @@
1.19
1.20 CHECK_READ_WATCH(addr,4);
1.21
1.22 - if( addr >= 0xE0000000 ) /* P4 Area, handled specially */
1.23 + if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.24 return sh4_read_p4( addr );
1.25 -
1.26 - if( (addr&0x1F800000) == 0x04000000 ) {
1.27 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.28 + return *(int32_t *)(sh4_main_ram + (addr&0x00FFFFFF));
1.29 + } else if( (addr&0x1F800000) == 0x04000000 ) {
1.30 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.31 pvr2_render_buffer_invalidate(addr, FALSE);
1.32 } else if( (addr&0x1F800000) == 0x05000000 ) {
1.33 @@ -161,10 +163,11 @@
1.34
1.35 CHECK_READ_WATCH(addr,2);
1.36
1.37 - if( addr >= 0xE0000000 ) /* P4 Area, handled specially */
1.38 + if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.39 return SIGNEXT16(sh4_read_p4( addr ));
1.40 -
1.41 - if( (addr&0x1F800000) == 0x04000000 ) {
1.42 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.43 + return SIGNEXT16(*(int16_t *)(sh4_main_ram + (addr&0x00FFFFFF)));
1.44 + } else if( (addr&0x1F800000) == 0x04000000 ) {
1.45 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.46 pvr2_render_buffer_invalidate(addr, FALSE);
1.47 } else if( (addr&0x1F800000) == 0x05000000 ) {
1.48 @@ -192,9 +195,11 @@
1.49
1.50 CHECK_READ_WATCH(addr,1);
1.51
1.52 - if( addr >= 0xE0000000 ) /* P4 Area, handled specially */
1.53 + if( addr >= 0xE0000000 ) { /* P4 Area, handled specially */
1.54 return SIGNEXT8(sh4_read_p4( addr ));
1.55 - if( (addr&0x1F800000) == 0x04000000 ) {
1.56 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.57 + return SIGNEXT8(*(int8_t *)(sh4_main_ram + (addr&0x00FFFFFF)));
1.58 + } else if( (addr&0x1F800000) == 0x04000000 ) {
1.59 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.60 pvr2_render_buffer_invalidate(addr, FALSE);
1.61 } else if( (addr&0x1F800000) == 0x05000000 ) {
1.62 @@ -213,7 +218,6 @@
1.63 TRACE_IO( "Byte read %02X <= %08X", page, (addr&0xFFF), val&0xFF, addr );
1.64 return val;
1.65 } else {
1.66 - // fprintf( stderr, "MOV.B %02X <= %08X\n",(uint32_t)*(uint8_t *)(page+(addr&0xFFF)), addr );
1.67 return SIGNEXT8(*(int8_t *)(page+(addr&0xFFF)));
1.68 }
1.69 }
1.70 @@ -228,9 +232,11 @@
1.71 if( addr >= 0xE0000000 ) {
1.72 sh4_write_p4( addr, val );
1.73 return;
1.74 - }
1.75 - if( (addr&0x1F800000) == 0x04000000 ||
1.76 - (addr&0x1F800000) == 0x11000000 ) {
1.77 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.78 + *(uint32_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.79 + return;
1.80 + } else if( (addr&0x1F800000) == 0x04000000 ||
1.81 + (addr&0x1F800000) == 0x11000000 ) {
1.82 texcache_invalidate_page(addr& 0x7FFFFF);
1.83 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.84 pvr2_render_buffer_invalidate(addr, TRUE);
1.85 @@ -273,8 +279,10 @@
1.86 if( addr >= 0xE0000000 ) {
1.87 sh4_write_p4( addr, (int16_t)val );
1.88 return;
1.89 - }
1.90 - if( (addr&0x1F800000) == 0x04000000 ||
1.91 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.92 + *(uint16_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.93 + return;
1.94 + } else if( (addr&0x1F800000) == 0x04000000 ||
1.95 (addr&0x1F800000) == 0x11000000 ) {
1.96 texcache_invalidate_page(addr& 0x7FFFFF);
1.97 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.98 @@ -312,9 +320,11 @@
1.99 if( addr >= 0xE0000000 ) {
1.100 sh4_write_p4( addr, (int8_t)val );
1.101 return;
1.102 - }
1.103 - if( (addr&0x1F800000) == 0x04000000 ||
1.104 - (addr&0x1F800000) == 0x11000000 ) {
1.105 + } else if( (addr&0x1C000000) == 0x0C000000 ) {
1.106 + *(uint8_t *)(sh4_main_ram + (addr&0x00FFFFFF)) = val;
1.107 + return;
1.108 + } else if( (addr&0x1F800000) == 0x04000000 ||
1.109 + (addr&0x1F800000) == 0x11000000 ) {
1.110 texcache_invalidate_page(addr& 0x7FFFFF);
1.111 addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.112 pvr2_render_buffer_invalidate(addr, TRUE);
.