mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
get rid of custom memcpy funcs
not used for anything important, just a maintenance burden
This commit is contained in:
parent
ba11a48115
commit
fdcfd32374
9 changed files with 7 additions and 198 deletions
45
pico/misc.c
45
pico/misc.c
|
@ -87,35 +87,6 @@ const unsigned char hcounts_32[] = {
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ASM_MISC_C
|
#ifndef _ASM_MISC_C
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int b0;
|
|
||||||
int b1;
|
|
||||||
int b2;
|
|
||||||
int b3;
|
|
||||||
int b4;
|
|
||||||
int b5;
|
|
||||||
int b6;
|
|
||||||
int b7;
|
|
||||||
} intblock;
|
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count)
|
|
||||||
{
|
|
||||||
if ((((long)dest | (long)src) & 3) == 0)
|
|
||||||
{
|
|
||||||
if (count >= 32) {
|
|
||||||
memcpy32((int *)dest, (int *)src, count/2);
|
|
||||||
count&=1;
|
|
||||||
} else {
|
|
||||||
for (; count >= 2; count -= 2, dest+=2, src+=2)
|
|
||||||
*(int *)dest = *(int *)src;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (count--)
|
|
||||||
*dest++ = *src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
|
PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
|
||||||
{
|
{
|
||||||
unsigned char *src_ = src;
|
unsigned char *src_ = src;
|
||||||
|
@ -125,22 +96,6 @@ PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _ASM_MISC_C_AMIPS
|
#ifndef _ASM_MISC_C_AMIPS
|
||||||
PICO_INTERNAL_ASM void memcpy32(void *dest_in, const void *src_in, int count)
|
|
||||||
{
|
|
||||||
const intblock *bs = (intblock *) src_in;
|
|
||||||
intblock *bd = (intblock *) dest_in;
|
|
||||||
const int *src;
|
|
||||||
int *dest;
|
|
||||||
|
|
||||||
for (; count >= sizeof(*bd)/4; count -= sizeof(*bd)/4)
|
|
||||||
*bd++ = *bs++;
|
|
||||||
|
|
||||||
dest = (int *)bd; src = (const int *)bs;
|
|
||||||
while (count--)
|
|
||||||
*dest++ = *src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PICO_INTERNAL_ASM void memset32(void *dest_in, int c, int count)
|
PICO_INTERNAL_ASM void memset32(void *dest_in, int c, int count)
|
||||||
{
|
{
|
||||||
int *dest = dest_in;
|
int *dest = dest_in;
|
||||||
|
|
|
@ -101,78 +101,4 @@ ms32u_return:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
|
||||||
.globl memcpy32 # int *dest, int *src, int count
|
|
||||||
|
|
||||||
memcpy32:
|
|
||||||
mc32_aloop:
|
|
||||||
andi $t0, $a0, 0x3f
|
|
||||||
beqz $t0, mc32_bloop_prep
|
|
||||||
nop
|
|
||||||
lw $t1, 0($a1)
|
|
||||||
addiu $a2, -1
|
|
||||||
sw $t1, 0($a0)
|
|
||||||
beqz $a2, mc32_return
|
|
||||||
addiu $a0, 4
|
|
||||||
j mc32_aloop
|
|
||||||
addiu $a1, 4
|
|
||||||
|
|
||||||
mc32_bloop_prep:
|
|
||||||
srl $t0, $a2, 4 # we will do 64 bytes per iteration (cache line)
|
|
||||||
beqz $t0, mc32_bloop_end
|
|
||||||
|
|
||||||
mc32_bloop:
|
|
||||||
addiu $t0, -1
|
|
||||||
cache 0x18, ($a0) # create dirty exclusive
|
|
||||||
lw $t2, 0x00($a1)
|
|
||||||
lw $t3, 0x04($a1)
|
|
||||||
lw $t4, 0x08($a1)
|
|
||||||
lw $t5, 0x0c($a1)
|
|
||||||
lw $t6, 0x10($a1)
|
|
||||||
lw $t7, 0x14($a1)
|
|
||||||
lw $t8, 0x18($a1)
|
|
||||||
lw $t9, 0x1c($a1)
|
|
||||||
sw $t2, 0x00($a0)
|
|
||||||
sw $t3, 0x04($a0)
|
|
||||||
sw $t4, 0x08($a0)
|
|
||||||
sw $t5, 0x0c($a0)
|
|
||||||
sw $t6, 0x10($a0)
|
|
||||||
sw $t7, 0x14($a0)
|
|
||||||
sw $t8, 0x18($a0)
|
|
||||||
sw $t9, 0x1c($a0)
|
|
||||||
lw $t2, 0x20($a1)
|
|
||||||
lw $t3, 0x24($a1)
|
|
||||||
lw $t4, 0x28($a1)
|
|
||||||
lw $t5, 0x2c($a1)
|
|
||||||
lw $t6, 0x30($a1)
|
|
||||||
lw $t7, 0x34($a1)
|
|
||||||
lw $t8, 0x38($a1)
|
|
||||||
lw $t9, 0x3c($a1)
|
|
||||||
sw $t2, 0x20($a0)
|
|
||||||
sw $t3, 0x24($a0)
|
|
||||||
sw $t4, 0x28($a0)
|
|
||||||
sw $t5, 0x2c($a0)
|
|
||||||
sw $t6, 0x30($a0)
|
|
||||||
sw $t7, 0x34($a0)
|
|
||||||
sw $t8, 0x38($a0)
|
|
||||||
sw $t9, 0x3c($a0)
|
|
||||||
addiu $a0, 0x40
|
|
||||||
bnez $t0, mc32_bloop
|
|
||||||
addiu $a1, 0x40
|
|
||||||
|
|
||||||
mc32_bloop_end:
|
|
||||||
andi $a2, $a2, 0x0f
|
|
||||||
beqz $a2, mc32_return
|
|
||||||
|
|
||||||
mc32_cloop:
|
|
||||||
lw $t1, 0($a1)
|
|
||||||
addiu $a2, -1
|
|
||||||
addiu $a1, 4
|
|
||||||
sw $t1, 0($a0)
|
|
||||||
bnez $a2, mc32_cloop
|
|
||||||
addiu $a0, 4
|
|
||||||
|
|
||||||
mc32_return:
|
|
||||||
jr $ra
|
|
||||||
nop
|
|
||||||
|
|
||||||
# vim:filetype=mips
|
# vim:filetype=mips
|
||||||
|
|
|
@ -6,44 +6,6 @@
|
||||||
* See COPYING file in the top-level directory.
|
* See COPYING file in the top-level directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.global memcpy16 @ unsigned short *dest, unsigned short *src, int count
|
|
||||||
|
|
||||||
memcpy16:
|
|
||||||
eor r3, r0, r1
|
|
||||||
tst r3, #2
|
|
||||||
bne mcp16_cant_align
|
|
||||||
|
|
||||||
tst r0, #2
|
|
||||||
ldrneh r3, [r1], #2
|
|
||||||
subne r2, r2, #1
|
|
||||||
strneh r3, [r0], #2
|
|
||||||
|
|
||||||
subs r2, r2, #4
|
|
||||||
bmi mcp16_fin
|
|
||||||
|
|
||||||
mcp16_loop:
|
|
||||||
ldmia r1!, {r3,r12}
|
|
||||||
subs r2, r2, #4
|
|
||||||
stmia r0!, {r3,r12}
|
|
||||||
bpl mcp16_loop
|
|
||||||
|
|
||||||
mcp16_fin:
|
|
||||||
tst r2, #2
|
|
||||||
ldrne r3, [r1], #4
|
|
||||||
strne r3, [r0], #4
|
|
||||||
ands r2, r2, #1
|
|
||||||
bxeq lr
|
|
||||||
|
|
||||||
mcp16_cant_align:
|
|
||||||
ldrh r3, [r1], #2
|
|
||||||
subs r2, r2, #1
|
|
||||||
strh r3, [r0], #2
|
|
||||||
bne mcp16_cant_align
|
|
||||||
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ 0x12345678 -> 0x34127856
|
@ 0x12345678 -> 0x34127856
|
||||||
@ r4=temp, lr=0x00ff00ff
|
@ r4=temp, lr=0x00ff00ff
|
||||||
.macro bswap reg
|
.macro bswap reg
|
||||||
|
@ -52,7 +14,6 @@ mcp16_cant_align:
|
||||||
orr \reg, \reg, r4, lsl #8
|
orr \reg, \reg, r4, lsl #8
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
|
||||||
@ dest must be halfword aligned, src can be unaligned
|
@ dest must be halfword aligned, src can be unaligned
|
||||||
.global memcpy16bswap @ unsigned short *dest, void *src, int count
|
.global memcpy16bswap @ unsigned short *dest, void *src, int count
|
||||||
|
|
||||||
|
@ -121,37 +82,6 @@ mcp16bs_cant_align2:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.global memcpy32 @ int *dest, int *src, int count
|
|
||||||
|
|
||||||
memcpy32:
|
|
||||||
stmfd sp!, {r4,lr}
|
|
||||||
|
|
||||||
subs r2, r2, #4
|
|
||||||
bmi mcp32_fin
|
|
||||||
|
|
||||||
mcp32_loop:
|
|
||||||
ldmia r1!, {r3,r4,r12,lr}
|
|
||||||
subs r2, r2, #4
|
|
||||||
stmia r0!, {r3,r4,r12,lr}
|
|
||||||
bpl mcp32_loop
|
|
||||||
|
|
||||||
mcp32_fin:
|
|
||||||
tst r2, #3
|
|
||||||
ldmeqfd sp!, {r4,pc}
|
|
||||||
tst r2, #1
|
|
||||||
ldrne r3, [r1], #4
|
|
||||||
strne r3, [r0], #4
|
|
||||||
|
|
||||||
mcp32_no_unal1:
|
|
||||||
tst r2, #2
|
|
||||||
ldmneia r1!, {r3,r12}
|
|
||||||
ldmfd sp!, {r4,lr}
|
|
||||||
stmneia r0!, {r3,r12}
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.global memset32 @ int *dest, int c, int count
|
.global memset32 @ int *dest, int c, int count
|
||||||
|
|
||||||
memset32:
|
memset32:
|
||||||
|
|
|
@ -287,7 +287,7 @@ static void FinalizeLine8bitM4(int line)
|
||||||
if (!(PicoOpt & POPT_DIS_32C_BORDER))
|
if (!(PicoOpt & POPT_DIS_32C_BORDER))
|
||||||
pd += 32;
|
pd += 32;
|
||||||
|
|
||||||
memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4);
|
memcpy(pd, Pico.est.HighCol + 8, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PicoDrawSetOutputMode4(pdso_t which)
|
void PicoDrawSetOutputMode4(pdso_t which)
|
||||||
|
|
|
@ -825,9 +825,7 @@ unsigned char PicoVideoRead8HV_L(void);
|
||||||
extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask);
|
extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask);
|
||||||
|
|
||||||
// misc.c
|
// misc.c
|
||||||
PICO_INTERNAL_ASM void memcpy16(unsigned short *dest, unsigned short *src, int count);
|
|
||||||
PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);
|
PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);
|
||||||
PICO_INTERNAL_ASM void memcpy32(void *dest, const void *src, int count); // 32bit word count
|
|
||||||
PICO_INTERNAL_ASM void memset32(void *dest, int c, int count);
|
PICO_INTERNAL_ASM void memset32(void *dest, int c, int count);
|
||||||
|
|
||||||
// eeprom.c
|
// eeprom.c
|
||||||
|
|
|
@ -891,7 +891,7 @@ int emu_save_load_game(int load, int sram)
|
||||||
sram_size = 0x12000;
|
sram_size = 0x12000;
|
||||||
sram_data = Pico.sv.data;
|
sram_data = Pico.sv.data;
|
||||||
if (sram_data)
|
if (sram_data)
|
||||||
memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4);
|
memcpy(sram_data, Pico_mcd->bram, 0x2000);
|
||||||
} else {
|
} else {
|
||||||
sram_size = 0x2000;
|
sram_size = 0x2000;
|
||||||
sram_data = Pico_mcd->bram;
|
sram_data = Pico_mcd->bram;
|
||||||
|
@ -913,7 +913,7 @@ int emu_save_load_game(int load, int sram)
|
||||||
ret = ret > 0 ? 0 : -1;
|
ret = ret > 0 ? 0 : -1;
|
||||||
fclose(sramFile);
|
fclose(sramFile);
|
||||||
if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))
|
if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))
|
||||||
memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);
|
memcpy(Pico_mcd->bram, sram_data, 0x2000);
|
||||||
} else {
|
} else {
|
||||||
// sram save needs some special processing
|
// sram save needs some special processing
|
||||||
// see if we have anything to save
|
// see if we have anything to save
|
||||||
|
|
|
@ -391,7 +391,7 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
|
||||||
ym_active_chs = shared_ctl->ym_active_chs;
|
ym_active_chs = shared_ctl->ym_active_chs;
|
||||||
|
|
||||||
// mix in ym buffer. is_buf_empty means nobody mixed there anything yet and it may contain trash
|
// mix in ym buffer. is_buf_empty means nobody mixed there anything yet and it may contain trash
|
||||||
if (is_buf_empty && ym_active_chs) memcpy32(buffer, ym_buf, length<<stereo);
|
if (is_buf_empty && ym_active_chs) memcpy(buffer, ym_buf, length << (stereo + 2));
|
||||||
else memset32(buffer, 0, length<<stereo);
|
else memset32(buffer, 0, length<<stereo);
|
||||||
|
|
||||||
if (shared_ctl->writebuffsel == 1) {
|
if (shared_ctl->writebuffsel == 1) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num)
|
||||||
ld_left = ld_lines;
|
ld_left = ld_lines;
|
||||||
|
|
||||||
EmuScanBegin16_ld(num);
|
EmuScanBegin16_ld(num);
|
||||||
memcpy32(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4);
|
memcpy(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8);
|
||||||
if (emu_scan_end)
|
if (emu_scan_end)
|
||||||
emu_scan_end(ld_counter);
|
emu_scan_end(ld_counter);
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ static int make_local_pal_md(int fast_mode)
|
||||||
bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40);
|
bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess
|
memcpy(localPal + 0x80, localPal, 0x40 * 4); // for spr prio mess
|
||||||
|
|
||||||
return pallen;
|
return pallen;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ static void do_pal_update(int allow_sh, int allow_as)
|
||||||
}
|
}
|
||||||
else if (allow_as && (Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI))
|
else if (allow_as && (Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI))
|
||||||
{
|
{
|
||||||
memcpy32((int *)dpal+0x80/2, (void *)localPal, 0x40*2/4);
|
memcpy(dpal + 0x80/2, localPal, 0x40*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue