From: notaz Date: Sat, 14 Oct 2017 18:10:25 +0000 (+0300) Subject: get rid of custom memcpy funcs X-Git-Tag: v1.93~39 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=picodrive.git;a=commitdiff_plain;h=fdcfd323747dceacb1ec2e86919d437896635bb7 get rid of custom memcpy funcs not used for anything important, just a maintenance burden --- diff --git a/pico/misc.c b/pico/misc.c index a500ac8..47842e3 100644 --- a/pico/misc.c +++ b/pico/misc.c @@ -87,35 +87,6 @@ const unsigned char hcounts_32[] = { #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) { 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 -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) { int *dest = dest_in; diff --git a/pico/misc_amips.s b/pico/misc_amips.s index 3aa70c7..7c3f1ad 100644 --- a/pico/misc_amips.s +++ b/pico/misc_amips.s @@ -101,78 +101,4 @@ ms32u_return: 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 diff --git a/pico/misc_arm.s b/pico/misc_arm.s index 15662a7..56c7401 100644 --- a/pico/misc_arm.s +++ b/pico/misc_arm.s @@ -6,44 +6,6 @@ * 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 @ r4=temp, lr=0x00ff00ff .macro bswap reg @@ -52,7 +14,6 @@ mcp16_cant_align: orr \reg, \reg, r4, lsl #8 .endm - @ dest must be halfword aligned, src can be unaligned .global memcpy16bswap @ unsigned short *dest, void *src, int count @@ -121,37 +82,6 @@ mcp16bs_cant_align2: 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 memset32: diff --git a/pico/mode4.c b/pico/mode4.c index 55e6d10..0f3d766 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -287,7 +287,7 @@ static void FinalizeLine8bitM4(int line) if (!(PicoOpt & POPT_DIS_32C_BORDER)) pd += 32; - memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4); + memcpy(pd, Pico.est.HighCol + 8, 256); } void PicoDrawSetOutputMode4(pdso_t which) diff --git a/pico/pico_int.h b/pico/pico_int.h index d4fc835..e3bf03a 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -825,9 +825,7 @@ unsigned char PicoVideoRead8HV_L(void); extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask); // 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 memcpy32(void *dest, const void *src, int count); // 32bit word count PICO_INTERNAL_ASM void memset32(void *dest, int c, int count); // eeprom.c diff --git a/platform/common/emu.c b/platform/common/emu.c index 9535bfd..85e1ba7 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -891,7 +891,7 @@ int emu_save_load_game(int load, int sram) sram_size = 0x12000; sram_data = Pico.sv.data; if (sram_data) - memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4); + memcpy(sram_data, Pico_mcd->bram, 0x2000); } else { sram_size = 0x2000; sram_data = Pico_mcd->bram; @@ -913,7 +913,7 @@ int emu_save_load_game(int load, int sram) ret = ret > 0 ? 0 : -1; fclose(sramFile); 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 { // sram save needs some special processing // see if we have anything to save diff --git a/platform/gp2x/940ctl.c b/platform/gp2x/940ctl.c index 6ba13bd..ff79c88 100644 --- a/platform/gp2x/940ctl.c +++ b/platform/gp2x/940ctl.c @@ -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; // 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<writebuffsel == 1) { diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index c0bc71f..01fd162 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -280,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num) ld_left = ld_lines; 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) 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); } else - memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess + memcpy(localPal + 0x80, localPal, 0x40 * 4); // for spr prio mess return pallen; } diff --git a/platform/psp/emu.c b/platform/psp/emu.c index dd4381b..8373a21 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -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)) { - memcpy32((int *)dpal+0x80/2, (void *)localPal, 0x40*2/4); + memcpy(dpal + 0x80/2, localPal, 0x40*2); } }