[Core/CD] optimized accesses to CDC RAM on little-endian platforms

This commit is contained in:
ekeeke 2019-11-25 17:25:34 +01:00
parent 48e3321261
commit 364d186789
5 changed files with 16 additions and 41 deletions

View File

@ -1,8 +1,8 @@
/*************************************************************************************** /***************************************************************************************
* Genesis Plus * Genesis Plus
* CD data controller (LC89510 compatible) * CD data controller (LC8951x compatible)
* *
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX) * Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -639,13 +639,8 @@ unsigned short cdc_host_r(void)
/* check if data is available */ /* check if data is available */
if (scd.regs[0x04>>1].byte.h & 0x40) if (scd.regs[0x04>>1].byte.h & 0x40)
{ {
/* read data word from CDC RAM buffer */ /* read 16-bit word from CDC RAM buffer (big-endian format) */
uint16 data = *(uint16 *)(cdc.ram + (cdc.dac.w & 0x3ffe)); uint16 data = READ_WORD(cdc.ram, cdc.dac.w & 0x3ffe);
#ifdef LSB_FIRST
/* source data is stored in big endian format */
data = ((data >> 8) | (data << 8)) & 0xffff;
#endif
#ifdef LOG_CDC #ifdef LOG_CDC
error("CDC host read 0x%04x -> 0x%04x (dbc=0x%x) (%X)\n", cdc.dac.w, data, cdc.dbc.w, s68k.pc); error("CDC host read 0x%04x -> 0x%04x (dbc=0x%x) (%X)\n", cdc.dac.w, data, cdc.dbc.w, s68k.pc);

View File

@ -1,8 +1,8 @@
/*************************************************************************************** /***************************************************************************************
* Genesis Plus * Genesis Plus
* CD data controller (LC89510 compatible) * CD data controller (LC8951x compatible)
* *
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX) * Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* CD graphics processor * CD graphics processor
* *
* Copyright (C) 2012 Eke-Eke (Genesis Plus GX) * Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -60,13 +60,8 @@ void word_ram_0_dma_w(unsigned int words)
/* DMA transfer */ /* DMA transfer */
while (words--) while (words--)
{ {
/* read 16-bit word from CDC buffer */ /* read 16-bit word from CDC RAM buffer (big-endian format) */
data = *(uint16 *)(cdc.ram + src_index); data = READ_WORD(cdc.ram, src_index);
#ifdef LSB_FIRST
/* source data is stored in big endian format */
data = ((data >> 8) | (data << 8)) & 0xffff;
#endif
/* write 16-bit word to WORD-RAM */ /* write 16-bit word to WORD-RAM */
*(uint16 *)(scd.word_ram[0] + dst_index) = data ; *(uint16 *)(scd.word_ram[0] + dst_index) = data ;
@ -98,13 +93,8 @@ void word_ram_1_dma_w(unsigned int words)
/* DMA transfer */ /* DMA transfer */
while (words--) while (words--)
{ {
/* read 16-bit word from CDC buffer */ /* read 16-bit word from CDC RAM buffer (big-endian format) */
data = *(uint16 *)(cdc.ram + src_index); data = READ_WORD(cdc.ram, src_index);
#ifdef LSB_FIRST
/* source data is stored in big endian format */
data = ((data >> 8) | (data << 8)) & 0xffff;
#endif
/* write 16-bit word to WORD-RAM */ /* write 16-bit word to WORD-RAM */
*(uint16 *)(scd.word_ram[1] + dst_index) = data ; *(uint16 *)(scd.word_ram[1] + dst_index) = data ;
@ -136,13 +126,8 @@ void word_ram_2M_dma_w(unsigned int words)
/* DMA transfer */ /* DMA transfer */
while (words--) while (words--)
{ {
/* read 16-bit word from CDC buffer */ /* read 16-bit word from CDC RAM buffer (big-endian format) */
data = *(uint16 *)(cdc.ram + src_index); data = READ_WORD(cdc.ram, src_index);
#ifdef LSB_FIRST
/* source data is stored in big endian format */
data = ((data >> 8) | (data << 8)) & 0xffff;
#endif
/* write 16-bit word to WORD-RAM */ /* write 16-bit word to WORD-RAM */
*(uint16 *)(scd.word_ram_2M + dst_index) = data ; *(uint16 *)(scd.word_ram_2M + dst_index) = data ;

View File

@ -2,7 +2,7 @@
* Genesis Plus * Genesis Plus
* CD graphics processor * CD graphics processor
* *
* Copyright (C) 2012 Eke-Eke (Genesis Plus GX) * Copyright (C) 2012-2019 Eke-Eke (Genesis Plus GX)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -101,13 +101,8 @@ void prg_ram_dma_w(unsigned int words)
/* DMA transfer */ /* DMA transfer */
while (words--) while (words--)
{ {
/* read 16-bit word from CDC buffer */ /* read 16-bit word from CDC RAM buffer (big-endian format) */
data = *(uint16 *)(cdc.ram + src_index); data = READ_WORD(cdc.ram, src_index);
#ifdef LSB_FIRST
/* source data is stored in big endian format */
data = ((data >> 8) | (data << 8)) & 0xffff;
#endif
/* write 16-bit word to PRG-RAM */ /* write 16-bit word to PRG-RAM */
*(uint16 *)(scd.prg_ram + dst_index) = data ; *(uint16 *)(scd.prg_ram + dst_index) = data ;