From 93cb850ad79a7af7005e413f26efeb0941bf7d96 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 27 Jan 2020 19:26:26 -0500 Subject: s3c24xx, s3c44b0: Replace get_read_ptr with memory_access_cache (nw) --- src/devices/machine/s3c2400.h | 2 ++ src/devices/machine/s3c2410.h | 2 ++ src/devices/machine/s3c2440.h | 2 ++ src/devices/machine/s3c24xx.hxx | 44 +++++++++++++++++------------------------ src/devices/machine/s3c44b0.cpp | 20 +++++++------------ src/devices/machine/s3c44b0.h | 2 ++ 6 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/devices/machine/s3c2400.h b/src/devices/machine/s3c2400.h index e8aeb2b14fc..8ffff4968ff 100644 --- a/src/devices/machine/s3c2400.h +++ b/src/devices/machine/s3c2400.h @@ -455,6 +455,8 @@ private: required_device m_palette; required_device m_screen; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; + memcon_t m_memcon; usbhost_t m_usbhost; irq_t m_irq; diff --git a/src/devices/machine/s3c2410.h b/src/devices/machine/s3c2410.h index 8094c109128..dd87eba239f 100644 --- a/src/devices/machine/s3c2410.h +++ b/src/devices/machine/s3c2410.h @@ -563,6 +563,8 @@ private: required_device m_palette; required_device m_screen; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; + uint8_t m_steppingstone[4*1024]; memcon_t m_memcon; usbhost_t m_usbhost; diff --git a/src/devices/machine/s3c2440.h b/src/devices/machine/s3c2440.h index a29f7d8c765..40a92776c3f 100644 --- a/src/devices/machine/s3c2440.h +++ b/src/devices/machine/s3c2440.h @@ -608,6 +608,8 @@ private: required_device m_palette; required_device m_screen; + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; + uint8_t m_steppingstone[4*1024]; memcon_t m_memcon; usbhost_t m_usbhost; diff --git a/src/devices/machine/s3c24xx.hxx b/src/devices/machine/s3c24xx.hxx index 70500b7d30c..63e8dfbd2d7 100644 --- a/src/devices/machine/s3c24xx.hxx +++ b/src/devices/machine/s3c24xx.hxx @@ -294,20 +294,17 @@ void S3C24_CLASS_NAME::s3c24xx_lcd_dma_init() #if 0 uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read() { - address_space& space = m_cpu->space( AS_PROGRAM); - uint8_t *vram, data[4]; - vram = (uint8_t *)space.get_read_ptr( m_lcd.vramaddr_cur); + uint8_t data[4]; for (int i = 0; i < 2; i++) { - data[i*2+0] = *vram++; - data[i*2+1] = *vram++; + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1); m_lcd.vramaddr_cur += 2; m_lcd.pagewidth_cur++; if (m_lcd.pagewidth_cur >= m_lcd.pagewidth_max) { m_lcd.vramaddr_cur += m_lcd.offsize << 1; m_lcd.pagewidth_cur = 0; - vram = (uint8_t *)space.get_read_ptr( m_lcd.vramaddr_cur); } } if (m_lcd.hwswp == 0) @@ -337,9 +334,7 @@ uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read() uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read() { - address_space& space = m_cpu->space( AS_PROGRAM); - uint8_t *vram, data[4]; - vram = (uint8_t *)space.get_read_ptr( m_lcd.vramaddr_cur); + uint8_t data[4]; for (int i = 0; i < 2; i++) { if (m_lcd.hwswp == 0) @@ -348,39 +343,39 @@ uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read() { if ((m_lcd.vramaddr_cur & 2) == 0) { - data[i*2+0] = *(vram + 3); - data[i*2+1] = *(vram + 2); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 3); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 2); } else { - data[i*2+0] = *(vram - 1); - data[i*2+1] = *(vram - 2); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur - 1); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur - 2); } } else { - data[i*2+0] = *(vram + 0); - data[i*2+1] = *(vram + 1); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1); } } else { if (m_lcd.bswp == 0) { - data[i*2+0] = *(vram + 1); - data[i*2+1] = *(vram + 0); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 1); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 0); } else { if ((m_lcd.vramaddr_cur & 2) == 0) { - data[i*2+0] = *(vram + 2); - data[i*2+1] = *(vram + 3); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur + 2); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur + 3); } else { - data[i*2+0] = *(vram - 2); - data[i*2+1] = *(vram - 1); + data[i*2+0] = m_cache->read_byte(m_lcd.vramaddr_cur - 2); + data[i*2+1] = m_cache->read_byte(m_lcd.vramaddr_cur - 1); } } } @@ -390,11 +385,6 @@ uint32_t S3C24_CLASS_NAME::s3c24xx_lcd_dma_read() { m_lcd.vramaddr_cur += m_lcd.offsize << 1; m_lcd.pagewidth_cur = 0; - vram = (uint8_t *)space.get_read_ptr( m_lcd.vramaddr_cur); - } - else - { - vram += 2; } } if (m_flags & S3C24XX_INTERFACE_LCD_REVERSE) @@ -758,6 +748,8 @@ void S3C24_CLASS_NAME::s3c24xx_video_start() { m_lcd.bitmap[0] = std::make_unique(m_screen->width(), m_screen->height()); m_lcd.bitmap[1] = std::make_unique(m_screen->width(), m_screen->height()); + + m_cache = m_cpu->space(AS_PROGRAM).cache<2, 0, ENDIANNESS_LITTLE>(); } void S3C24_CLASS_NAME::bitmap_blend( bitmap_rgb32 &bitmap_dst, bitmap_rgb32 &bitmap_src_1, bitmap_rgb32 &bitmap_src_2) diff --git a/src/devices/machine/s3c44b0.cpp b/src/devices/machine/s3c44b0.cpp index 0c56bb51a17..8478f54bc58 100644 --- a/src/devices/machine/s3c44b0.cpp +++ b/src/devices/machine/s3c44b0.cpp @@ -264,6 +264,7 @@ void s3c44b0_device::device_start() m_data_r_cb.resolve_safe(0); m_data_w_cb.resolve(); + m_cache = m_cpu->space(AS_PROGRAM).cache<2, 0, ENDIANNESS_LITTLE>(); for (int i = 0; i < 6; i++) m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::pwm_timer_exp),this)); for (auto & elem : m_uart) elem.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::uart_timer_exp),this)); @@ -536,27 +537,25 @@ void s3c44b0_device::lcd_dma_init() void s3c44b0_device::lcd_dma_read(int count, uint8_t *data) { - address_space &space = m_cpu->space(AS_PROGRAM); - uint8_t *vram = (uint8_t *)space.get_read_ptr(m_lcd.vramaddr_cur); for (int i = 0; i < count / 2; i++) { if (m_lcd.bswp == 0) { if ((m_lcd.vramaddr_cur & 2) == 0) { - data[0] = *(vram + 3); - data[1] = *(vram + 2); + data[0] = m_cache->read_byte(m_lcd.vramaddr_cur + 3); + data[1] = m_cache->read_byte(m_lcd.vramaddr_cur + 2); } else { - data[0] = *(vram - 1); - data[1] = *(vram - 2); + data[0] = m_cache->read_byte(m_lcd.vramaddr_cur - 1); + data[1] = m_cache->read_byte(m_lcd.vramaddr_cur - 2); } } else { - data[0] = *(vram + 0); - data[1] = *(vram + 1); + data[0] = m_cache->read_byte(m_lcd.vramaddr_cur + 0); + data[1] = m_cache->read_byte(m_lcd.vramaddr_cur + 1); } m_lcd.vramaddr_cur += 2; m_lcd.pagewidth_cur++; @@ -568,11 +567,6 @@ void s3c44b0_device::lcd_dma_read(int count, uint8_t *data) lcd_dma_reload(); } m_lcd.pagewidth_cur = 0; - vram = (uint8_t *)space.get_read_ptr(m_lcd.vramaddr_cur); - } - else - { - vram += 2; } data += 2; } diff --git a/src/devices/machine/s3c44b0.h b/src/devices/machine/s3c44b0.h index f4f194ce3c8..bebddc710ac 100644 --- a/src/devices/machine/s3c44b0.h +++ b/src/devices/machine/s3c44b0.h @@ -599,6 +599,8 @@ private: devcb_write_line m_sda_w_cb; devcb_read32 m_data_r_cb; devcb_write16 m_data_w_cb; + + memory_access_cache<2, 0, ENDIANNESS_LITTLE> *m_cache; }; DECLARE_DEVICE_TYPE(S3C44B0, s3c44b0_device) -- cgit v1.2.3