Search
lxdream.org :: lxdream/src/pvr2/pvr2mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/pvr2mem.c
changeset 929:fd8cb0c82f5f
prev869:b6f38c7ee7a3
next931:430048ea8b71
author nkeynes
date Sat Dec 20 03:01:40 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change First pass experiment using cached decoding.
file annotate diff log raw
1.1 --- a/src/pvr2/pvr2mem.c Fri Oct 10 00:09:37 2008 +0000
1.2 +++ b/src/pvr2/pvr2mem.c Sat Dec 20 03:01:40 2008 +0000
1.3 @@ -18,12 +18,122 @@
1.4 #include <string.h>
1.5 #include <stdio.h>
1.6 #include <errno.h>
1.7 +#include "sh4/sh4core.h"
1.8 #include "pvr2.h"
1.9 #include "asic.h"
1.10 #include "dream.h"
1.11
1.12 extern unsigned char *video_base;
1.13
1.14 +/************************* VRAM32 address space ***************************/
1.15 +
1.16 +static int32_t FASTCALL pvr2_vram32_read_long( sh4addr_t addr )
1.17 +{
1.18 + pvr2_render_buffer_invalidate(addr, FALSE);
1.19 + return *((int32_t *)(video_base+(addr&0x007FFFFF)));
1.20 +}
1.21 +static int32_t FASTCALL pvr2_vram32_read_word( sh4addr_t addr )
1.22 +{
1.23 + pvr2_render_buffer_invalidate(addr, FALSE);
1.24 + return SIGNEXT16(*((int16_t *)(video_base+(addr&0x007FFFFF))));
1.25 +}
1.26 +static int32_t FASTCALL pvr2_vram32_read_byte( sh4addr_t addr )
1.27 +{
1.28 + pvr2_render_buffer_invalidate(addr, FALSE);
1.29 + return SIGNEXT8(*((int8_t *)(video_base+(addr&0x007FFFFF))));
1.30 +}
1.31 +static void FASTCALL pvr2_vram32_write_long( sh4addr_t addr, uint32_t val )
1.32 +{
1.33 + pvr2_render_buffer_invalidate(addr, TRUE);
1.34 + *(uint32_t *)(video_base + (addr&0x007FFFFF)) = val;
1.35 +}
1.36 +static void FASTCALL pvr2_vram32_write_word( sh4addr_t addr, uint32_t val )
1.37 +{
1.38 + pvr2_render_buffer_invalidate(addr, TRUE);
1.39 + *(uint16_t *)(video_base + (addr&0x007FFFFF)) = (uint16_t)val;
1.40 +}
1.41 +static void FASTCALL pvr2_vram32_write_byte( sh4addr_t addr, uint32_t val )
1.42 +{
1.43 + pvr2_render_buffer_invalidate(addr, TRUE);
1.44 + *(uint8_t *)(video_base + (addr&0x007FFFFF)) = (uint8_t)val;
1.45 +}
1.46 +static void FASTCALL pvr2_vram32_read_burst( unsigned char *dest, sh4addr_t addr )
1.47 +{
1.48 + // Render buffers pretty much have to be (at least) 32-byte aligned
1.49 + pvr2_render_buffer_invalidate(addr, FALSE);
1.50 + memcpy( dest, (video_base + (addr&0x007FFFFF)), 32 );
1.51 +}
1.52 +static void FASTCALL pvr2_vram32_write_burst( sh4addr_t addr, unsigned char *src )
1.53 +{
1.54 + // Render buffers pretty much have to be (at least) 32-byte aligned
1.55 + pvr2_render_buffer_invalidate(addr, TRUE);
1.56 + memcpy( (video_base + (addr&0x007FFFFF)), src, 32 );
1.57 +}
1.58 +
1.59 +struct mem_region_fn mem_region_vram32 = { pvr2_vram32_read_long, pvr2_vram32_write_long,
1.60 + pvr2_vram32_read_word, pvr2_vram32_write_word,
1.61 + pvr2_vram32_read_byte, pvr2_vram32_write_byte,
1.62 + pvr2_vram32_read_burst, pvr2_vram32_write_burst };
1.63 +
1.64 +/************************* VRAM64 address space ***************************/
1.65 +
1.66 +#define TRANSLATE_VIDEO_64BIT_ADDRESS(a) ( (((a)&0x00FFFFF8)>>1)|(((a)&0x00000004)<<20)|((a)&0x03) )
1.67 +
1.68 +static int32_t FASTCALL pvr2_vram64_read_long( sh4addr_t addr )
1.69 +{
1.70 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.71 + pvr2_render_buffer_invalidate(addr, FALSE);
1.72 + return *((int32_t *)(video_base+(addr&0x007FFFFF)));
1.73 +}
1.74 +static int32_t FASTCALL pvr2_vram64_read_word( sh4addr_t addr )
1.75 +{
1.76 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.77 + pvr2_render_buffer_invalidate(addr, FALSE);
1.78 + return SIGNEXT16(*((int16_t *)(video_base+(addr&0x007FFFFF))));
1.79 +}
1.80 +static int32_t FASTCALL pvr2_vram64_read_byte( sh4addr_t addr )
1.81 +{
1.82 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.83 + pvr2_render_buffer_invalidate(addr, FALSE);
1.84 + return SIGNEXT8(*((int8_t *)(video_base+(addr&0x007FFFFF))));
1.85 +}
1.86 +static void FASTCALL pvr2_vram64_write_long( sh4addr_t addr, uint32_t val )
1.87 +{
1.88 + texcache_invalidate_page(addr& 0x007FFFFF);
1.89 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.90 + pvr2_render_buffer_invalidate(addr, TRUE);
1.91 + *(uint32_t *)(video_base + (addr&0x007FFFFF)) = val;
1.92 +}
1.93 +static void FASTCALL pvr2_vram64_write_word( sh4addr_t addr, uint32_t val )
1.94 +{
1.95 + texcache_invalidate_page(addr& 0x007FFFFF);
1.96 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.97 + pvr2_render_buffer_invalidate(addr, TRUE);
1.98 + *(uint16_t *)(video_base + (addr&0x007FFFFF)) = (uint16_t)val;
1.99 +}
1.100 +static void FASTCALL pvr2_vram64_write_byte( sh4addr_t addr, uint32_t val )
1.101 +{
1.102 + texcache_invalidate_page(addr& 0x007FFFFF);
1.103 + addr = TRANSLATE_VIDEO_64BIT_ADDRESS(addr);
1.104 + pvr2_render_buffer_invalidate(addr, TRUE);
1.105 + *(uint8_t *)(video_base + (addr&0x007FFFFF)) = (uint8_t)val;
1.106 +}
1.107 +static void FASTCALL pvr2_vram64_read_burst( unsigned char *dest, sh4addr_t addr )
1.108 +{
1.109 + pvr2_vram64_read( dest, addr, 32 );
1.110 +}
1.111 +static void FASTCALL pvr2_vram64_write_burst( sh4addr_t addr, unsigned char *src )
1.112 +{
1.113 + pvr2_vram64_write( addr, src, 32 );
1.114 +}
1.115 +
1.116 +struct mem_region_fn mem_region_vram64 = { pvr2_vram64_read_long, pvr2_vram64_write_long,
1.117 + pvr2_vram64_read_word, pvr2_vram64_write_word,
1.118 + pvr2_vram64_read_byte, pvr2_vram64_write_byte,
1.119 + pvr2_vram64_read_burst, pvr2_vram64_write_burst };
1.120 +
1.121 +
1.122 +
1.123 void pvr2_dma_write( sh4addr_t destaddr, unsigned char *src, uint32_t count )
1.124 {
1.125 int region;
.