From: notaz Date: Thu, 1 Nov 2007 19:24:13 +0000 (+0000) Subject: psp memhandlers, vsync, stuff X-Git-Tag: v1.85~629 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ec29f016cdeb3100dbb433dd9041e81542765bd;p=picodrive.git psp memhandlers, vsync, stuff git-svn-id: file:///home/notaz/opt/svn/PicoDrive@289 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/Memory.c b/Pico/Memory.c index 2b869246..26be0129 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -28,7 +28,6 @@ u32 PicoRead8(u32 a); u32 PicoRead16(u32 a); void PicoWrite8(u32 a,u8 d); void PicoWriteRomHW_SSF2(u32 a,u32 d); -void PicoWriteRomHW_in1 (u32 a,u32 d); #endif @@ -424,7 +423,7 @@ end: // ----------------------------------------------------------------- // Write Ram -#ifndef _ASM_MEMORY_C +#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d) { #ifdef __debug_io diff --git a/Pico/Memory.s b/Pico/Memory.s index 93c503d5..732e6b85 100644 --- a/Pico/Memory.s +++ b/Pico/Memory.s @@ -10,6 +10,7 @@ .include "port_config.s" .text +.align 4 @ default jump tables @@ -119,6 +120,7 @@ m_read32_def_table: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .bss +.align 4 @.section .bss, "brw" @.data @@ -136,6 +138,7 @@ m_read32_table: @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ .text +.align 4 .global PicoMemReset .global PicoRead8 @@ -184,7 +187,7 @@ PicoMemReset: @ update memhandlers according to ROM size ldr r1, =m_read8_above_rom ldr r0, =m_read8_table - mov r2, #16 + mov r2, #20 1: sub r2, r2, #1 cmp r2, r12 @@ -196,7 +199,7 @@ PicoMemReset: 2: ldr r1, =m_read16_above_rom ldr r0, =m_read16_table - mov r2, #16 + mov r2, #20 1: sub r2, r2, #1 cmp r2, r12 @@ -208,7 +211,7 @@ PicoMemReset: 2: ldr r1, =m_read32_above_rom ldr r0, =m_read32_table - mov r2, #16 + mov r2, #20 1: sub r2, r2, #1 cmp r2, r12 @@ -653,7 +656,7 @@ m_read32_rom4: @ 0x200000 - 0x27ffff, SRAM area (does any game do long reads?) add r0, r1, #2 bl SRAMRead ldmfd sp!,{r1,lr} - orr r0, r1, r0, lsl #16 + orr r0, r0, r1, lsl #16 orr r0, r0, r0, lsl #8 bx lr m_read32_nosram: diff --git a/Pico/MemoryCmn.c b/Pico/MemoryCmn.c index 219a0940..f31a11e9 100644 --- a/Pico/MemoryCmn.c +++ b/Pico/MemoryCmn.c @@ -168,7 +168,7 @@ static #endif void OtherWrite8(u32 a,u32 d) { -#ifndef _ASM_MEMORY_C +#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) if ((a&0xe700f9)==0xc00011||(a&0xff7ff9)==0xa07f11) { if(PicoOpt&2) SN76496Write(d); return; } // PSG Sound if ((a&0xff4000)==0xa00000) { if(!(Pico.m.z80Run&1)) Pico.zram[a&0x1fff]=(u8)d; return; } // Z80 ram if ((a&0xff6000)==0xa04000) { if(PicoOpt&1) emustatus|=YM2612Write(a&3, d)&1; return; } // FM Sound @@ -180,7 +180,7 @@ void OtherWrite8(u32 a,u32 d) if(!(d&1)) z80_reset(); return; } -#ifndef _ASM_MEMORY_C +#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS) if ((a&0xff7f00)==0xa06000) // Z80 BANK register { Pico.m.z80_bank68k>>=1; diff --git a/Pico/Memory_amips.s b/Pico/Memory_amips.s new file mode 100644 index 00000000..0fab4f4f --- /dev/null +++ b/Pico/Memory_amips.s @@ -0,0 +1,761 @@ +# vim:filetype=mips + +# memory handlers with banking support for SSF II - The New Challengers +# mostly based on Gens code + +# (c) Copyright 2007, Grazvydas "notaz" Ignotas +# All Rights Reserved + + +.set noreorder +.set noat + +.text +.align 4 + +# default jump tables + +m_read8_def_table: + .long m_read8_rom0 # 0x000000 - 0x07FFFF + .long m_read8_rom1 # 0x080000 - 0x0FFFFF + .long m_read8_rom2 # 0x100000 - 0x17FFFF + .long m_read8_rom3 # 0x180000 - 0x1FFFFF + .long m_read8_rom4 # 0x200000 - 0x27FFFF + .long m_read8_rom5 # 0x280000 - 0x2FFFFF + .long m_read8_rom6 # 0x300000 - 0x37FFFF + .long m_read8_rom7 # 0x380000 - 0x3FFFFF + .long m_read8_rom8 # 0x400000 - 0x47FFFF - for all those large ROM hacks + .long m_read8_rom9 # 0x480000 - 0x4FFFFF + .long m_read8_romA # 0x500000 - 0x57FFFF + .long m_read8_romB # 0x580000 - 0x5FFFFF + .long m_read8_romC # 0x600000 - 0x67FFFF + .long m_read8_romD # 0x680000 - 0x6FFFFF + .long m_read8_romE # 0x700000 - 0x77FFFF + .long m_read8_romF # 0x780000 - 0x7FFFFF + .long m_read8_rom10 # 0x800000 - 0x87FFFF + .long m_read8_rom11 # 0x880000 - 0x8FFFFF + .long m_read8_rom12 # 0x900000 - 0x97FFFF + .long m_read8_rom13 # 0x980000 - 0x9FFFFF + .long m_read8_misc # 0xA00000 - 0xA7FFFF + .long m_read_null # 0xA80000 - 0xAFFFFF + .long m_read_null # 0xB00000 - 0xB7FFFF + .long m_read_null # 0xB80000 - 0xBFFFFF + .long m_read8_vdp # 0xC00000 - 0xC7FFFF + .long m_read8_vdp # 0xC80000 - 0xCFFFFF + .long m_read8_vdp # 0xD00000 - 0xD7FFFF + .long m_read8_vdp # 0xD80000 - 0xDFFFFF + .long m_read8_ram # 0xE00000 - 0xE7FFFF + .long m_read8_ram # 0xE80000 - 0xEFFFFF + .long m_read8_ram # 0xF00000 - 0xF7FFFF + .long m_read8_ram # 0xF80000 - 0xFFFFFF + +m_read16_def_table: + .long m_read16_rom0 # 0x000000 - 0x07FFFF + .long m_read16_rom1 # 0x080000 - 0x0FFFFF + .long m_read16_rom2 # 0x100000 - 0x17FFFF + .long m_read16_rom3 # 0x180000 - 0x1FFFFF + .long m_read16_rom4 # 0x200000 - 0x27FFFF + .long m_read16_rom5 # 0x280000 - 0x2FFFFF + .long m_read16_rom6 # 0x300000 - 0x37FFFF + .long m_read16_rom7 # 0x380000 - 0x3FFFFF + .long m_read16_rom8 # 0x400000 - 0x47FFFF + .long m_read16_rom9 # 0x480000 - 0x4FFFFF + .long m_read16_romA # 0x500000 - 0x57FFFF + .long m_read16_romB # 0x580000 - 0x5FFFFF + .long m_read16_romC # 0x600000 - 0x67FFFF + .long m_read16_romD # 0x680000 - 0x6FFFFF + .long m_read16_romE # 0x700000 - 0x77FFFF + .long m_read16_romF # 0x780000 - 0x7FFFFF + .long m_read16_rom10 # 0x800000 - 0x87FFFF + .long m_read16_rom11 # 0x880000 - 0x8FFFFF + .long m_read16_rom12 # 0x900000 - 0x97FFFF + .long m_read16_rom13 # 0x980000 - 0x9FFFFF + .long m_read16_misc # 0xA00000 - 0xA7FFFF + .long m_read_null # 0xA80000 - 0xAFFFFF + .long m_read_null # 0xB00000 - 0xB7FFFF + .long m_read_null # 0xB80000 - 0xBFFFFF + .long m_read16_vdp # 0xC00000 - 0xC7FFFF + .long m_read16_vdp # 0xC80000 - 0xCFFFFF + .long m_read16_vdp # 0xD00000 - 0xD7FFFF + .long m_read16_vdp # 0xD80000 - 0xDFFFFF + .long m_read16_ram # 0xE00000 - 0xE7FFFF + .long m_read16_ram # 0xE80000 - 0xEFFFFF + .long m_read16_ram # 0xF00000 - 0xF7FFFF + .long m_read16_ram # 0xF80000 - 0xFFFFFF + +m_read32_def_table: + .long m_read32_rom0 # 0x000000 - 0x07FFFF + .long m_read32_rom1 # 0x080000 - 0x0FFFFF + .long m_read32_rom2 # 0x100000 - 0x17FFFF + .long m_read32_rom3 # 0x180000 - 0x1FFFFF + .long m_read32_rom4 # 0x200000 - 0x27FFFF + .long m_read32_rom5 # 0x280000 - 0x2FFFFF + .long m_read32_rom6 # 0x300000 - 0x37FFFF + .long m_read32_rom7 # 0x380000 - 0x3FFFFF + .long m_read32_rom8 # 0x400000 - 0x47FFFF + .long m_read32_rom9 # 0x480000 - 0x4FFFFF + .long m_read32_romA # 0x500000 - 0x57FFFF + .long m_read32_romB # 0x580000 - 0x5FFFFF + .long m_read32_romC # 0x600000 - 0x67FFFF + .long m_read32_romD # 0x680000 - 0x6FFFFF + .long m_read32_romE # 0x700000 - 0x77FFFF + .long m_read32_romF # 0x780000 - 0x7FFFFF + .long m_read32_rom10 # 0x800000 - 0x87FFFF + .long m_read32_rom11 # 0x880000 - 0x8FFFFF + .long m_read32_rom12 # 0x900000 - 0x97FFFF + .long m_read32_rom13 # 0x980000 - 0x9FFFFF + .long m_read32_misc # 0xA00000 - 0xA7FFFF + .long m_read_null # 0xA80000 - 0xAFFFFF + .long m_read_null # 0xB00000 - 0xB7FFFF + .long m_read_null # 0xB80000 - 0xBFFFFF + .long m_read32_vdp # 0xC00000 - 0xC7FFFF + .long m_read32_vdp # 0xC80000 - 0xCFFFFF + .long m_read32_vdp # 0xD00000 - 0xD7FFFF + .long m_read32_vdp # 0xD80000 - 0xDFFFFF + .long m_read32_ram # 0xE00000 - 0xE7FFFF + .long m_read32_ram # 0xE80000 - 0xEFFFFF + .long m_read32_ram # 0xF00000 - 0xF7FFFF + .long m_read32_ram # 0xF80000 - 0xFFFFFF + + +# ############################################################################# + +.bss +.align 4 + +# used tables +m_read8_table: + .skip 32*4 + +m_read16_table: + .skip 32*4 + +m_read32_table: + .skip 32*4 + + +# ############################################################################# + +.text +.align 4 + +.global PicoMemReset +.global PicoRead8 +.global PicoRead16 +.global PicoRead32 +.global PicoWriteRomHW_SSF2 + +.global m_read8_def_table +.global m_read8_table + +.macro PicoMemResetCopyDef dst_table src_table + lui $t0, %hi(\dst_table) + addiu $t0, %lo(\dst_table) + lui $t1, %hi(\src_table) + addiu $t1, %lo(\src_table) + li $t2, 32 +1: + lw $t3, 0($t1) + sw $t3, 0($t0) + addiu $t2, -1 + addiu $t1, 4 + bnez $t2, 1b + addiu $t0, 4 +.endm + +# $t4 = 4 +.macro PicoMemResetRomArea dst_table ar_label + lui $t0, %hi(\dst_table) + addiu $t0, %lo(\dst_table) + lui $t1, %hi(\ar_label) + addiu $t1, %lo(\ar_label) + li $t2, 20 +1: + beq $t2, $v1, 2f + addiu $t2, -1 + sll $t3, $t2, 2 + beq $t2, $t4, 1b # do not touch the SRAM area + addu $t3, $t0 + j 1b + sw $t1, 0($t3) +2: +.endm + + +PicoMemReset: + lui $v1, %hi(Pico+0x22204) + lw $v1, %lo(Pico+0x22204)($v1) # romsize + lui $t0, 8 + addu $v1, $t0 + addiu $v1, -1 + srl $v1, 19 + + PicoMemResetCopyDef m_read8_table m_read8_def_table + PicoMemResetCopyDef m_read16_table m_read16_def_table + PicoMemResetCopyDef m_read32_table m_read32_def_table + + # update memhandlers according to ROM size + li $t4, 4 + PicoMemResetRomArea m_read8_table m_read8_above_rom + PicoMemResetRomArea m_read16_table m_read16_above_rom + PicoMemResetRomArea m_read32_table m_read32_above_rom + + jr $ra + nop + +# ############################################################################# + +.macro PicoReadJump table + lui $t0, %hi(\table) + srl $t1, $a0, 19 + ins $t0, $t1, 2, 5 + lw $t0, %lo(\table)($t0) + ins $a0, $0, 24, 8 + jr $t0 + nop +.endm + +PicoRead8: # u32 a + PicoReadJump m_read8_table + +PicoRead16: # u32 a + PicoReadJump m_read16_table + +PicoRead32: # u32 a + PicoReadJump m_read32_table + +# ############################################################################# + +m_read_null: + jr $ra + li $v0, 0 + +m_read_neg1: + jr $ra + addiu $v0, $0, 0xffff + +# loads &Pico.rom to $t3 +.macro m_read_rom_try_sram is200000 size + lui $t2, %hi(SRam) + addiu $t2, %lo(SRam) + lui $t3, %hi(Pico+0x22200) + lw $t1, 8($t2) # SRam.end +.if \is200000 + ins $a0, $0, 19, 13 + lui $t4, 0x20 + or $a0, $t4 +.endif + subu $t4, $a0, $t1 + bgtz $t4, 1f + addiu $t3, %lo(Pico+0x22200) + lw $t1, 4($t2) # SRam.start + subu $t4, $t1, $a0 + bgtz $t4, 1f + nop + lb $t1, 0x11($t3) # Pico.m.sram_reg + andi $t4, $t1, 5 + beqz $t4, 1f + nop +.if \size == 8 + j SRAMRead + nop +.elseif \size == 16 + addiu $sp, -4 + jal SRAMRead + sw $ra, 0($sp) + lw $ra, 0($sp) + addiu $sp, 4 + jr $ra + ins $v0, $v0, 8, 8 +.else + addiu $sp, -8 + sw $a0, 4($sp) + jal SRAMRead + sw $ra, 0($sp) + lw $a0, 4($sp) + sw $v0, 4($sp) + jal SRAMRead + addiu $a0, 2 + lw $v1, 4($sp) + lw $ra, 0($sp) + addiu $sp, 8 + ins $v0, $v1, 16, 16 + sll $t0, $v0, 8 + jr $ra + or $v0, $t0 +.endif +# m_read_nosram: +1: +.endm + +.macro m_read8_rom sect + lui $t0, %hi(Pico+0x22200) + lw $t0, %lo(Pico+0x22200)($t0) # rom + xori $a0, 1 + ins $a0, $0, 19, 13 +.if \sect + lui $t1, 8*\sect + addu $a0, $t1 +.endif + addu $t0, $a0 + jr $ra + lb $v0, 0($t0) +.endm + + +m_read8_rom0: # 0x000000 - 0x07ffff + m_read8_rom 0 + +m_read8_rom1: # 0x080000 - 0x0fffff + m_read8_rom 1 + +m_read8_rom2: # 0x100000 - 0x17ffff + m_read8_rom 2 + +m_read8_rom3: # 0x180000 - 0x1fffff + m_read8_rom 3 + +m_read8_rom4: # 0x200000 - 0x27ffff, SRAM area + m_read_rom_try_sram 1 8 + lw $t1, 4($t3) # romsize + subu $t4, $t1, $a0 + blez $t4, m_read_null + lw $t1, 0($t3) # rom + xori $a0, 1 + addu $t1, $a0 + jr $ra + lb $v0, 0($t1) + +m_read8_rom5: # 0x280000 - 0x2fffff + m_read8_rom 5 + +m_read8_rom6: # 0x300000 - 0x37ffff + m_read8_rom 6 + +m_read8_rom7: # 0x380000 - 0x3fffff + m_read8_rom 7 + +m_read8_rom8: # 0x400000 - 0x47ffff + m_read8_rom 8 + +m_read8_rom9: # 0x480000 - 0x4fffff + m_read8_rom 9 + +m_read8_romA: # 0x500000 - 0x57ffff + m_read8_rom 0xA + +m_read8_romB: # 0x580000 - 0x5fffff + m_read8_rom 0xB + +m_read8_romC: # 0x600000 - 0x67ffff + m_read8_rom 0xC + +m_read8_romD: # 0x680000 - 0x6fffff + m_read8_rom 0xD + +m_read8_romE: # 0x700000 - 0x77ffff + m_read8_rom 0xE + +m_read8_romF: # 0x780000 - 0x7fffff + m_read8_rom 0xF + +m_read8_rom10: # 0x800000 - 0x87ffff + m_read8_rom 0x10 + +m_read8_rom11: # 0x880000 - 0x8fffff + m_read8_rom 0x11 + +m_read8_rom12: # 0x900000 - 0x97ffff + m_read8_rom 0x12 + +m_read8_rom13: # 0x980000 - 0x9fffff + m_read8_rom 0x13 + + +m_read8_misc: + srl $t0, $a0, 5 + sll $t0, $t0, 5 + lui $t1, 0xa1 + bne $t0, $t1, m_read8_misc2 + andi $t0, $a0, 0x1e +m_read8_misc_io: + beqz $t0, m_read8_misc_hwreg + sub $t1, $t0, 4 + bgtz $t1, m_read8_misc_ioports + nop + slti $a0, $t0, 4 + xori $a0, 1 + j PadRead + nop + +m_read8_misc_hwreg: + lui $v0, %hi(Pico+0x2220f) + jr $ra + lb $v0, %lo(Pico+0x2220f)($v0) + +m_read8_misc_ioports: + lui $v0, %hi(Pico+0x22000) + ins $v0, $t0, 0, 5 + jr $ra + lb $v0, %lo(Pico+0x22000)($v0) + +m_read8_misc2: + lui $t0, 0xa1 + ori $t0, 0x1100 + bne $a0, $t0, m_read8_misc3 + srl $t0, $a0, 16 + j z80ReadBusReq + +m_read8_misc3: + addiu $t0, 0xff60 # expecting 0xa0 to get 0 + bnez $t0, m_read8_misc4 + + # z80 area + andi $t0, $a0, 0x4000 + bnez $t0, m_read8_z80_misc + andi $t0, $a0, 0x6000 + j z80Read8 # z80 RAM + +m_read8_z80_misc: + addiu $t0, 0xc000 # expecting 0x4000 to get 0 + bnez $t0, m_read_neg1 # invalid + + lui $t0, %hi(PicoOpt) + lw $t0, %lo(PicoOpt)($t0) + andi $t0, 1 + beqz $t0, m_read8_fake_ym2612 + lui $t0, %hi(Pico+0x22208) + j YM2612Read_ + nop + +m_read8_fake_ym2612: + lb $v0, %lo(Pico+0x22208)($t0) # Pico.m.rotate + addiu $t1, $v0, 1 + jr $ra + sb $t1, %lo(Pico+0x22208)($t0) + +# delay slot friendly +.macro m_read8_call16 funcname + andi $t0, $a0, 1 + beqz $t0, 1f + li $a1, 8 # not always needed, but shouln't cause problems + j \funcname # odd address + nop +1: + addiu $sp, -4 + sw $ra, 0($sp) + jal \funcname + xori $a0, 1 + lw $ra, 0($sp) + addiu $sp, 4 + jr $ra + srl $v0, 8 +.endm + +m_read8_misc4: + # if everything else fails, use generic handler + m_read8_call16 OtherRead16 + +m_read8_vdp: + ext $t0, $a0, 16, 3 + andi $t1, $a0, 0xe0 + or $t0, $t1 + bnez $t0, m_read_null # invalid address + m_read8_call16 PicoVideoRead + +m_read8_ram: + lui $t0, %hi(Pico) + ins $t0, $a0, 0, 16 + xori $t0, 1 + jr $ra + lb $v0, %lo(Pico)($t0) + +m_read8_above_rom: + # might still be SRam (Micro Machines, HardBall '95) + m_read_rom_try_sram 0 8 + m_read8_call16 OtherRead16End + +# ############################################################################# + +.macro m_read16_rom sect + lui $t0, %hi(Pico+0x22200) + lw $t0, %lo(Pico+0x22200)($t0) # rom + ins $a0, $0, 0, 1 + ins $a0, $0, 19, 13 +.if \sect + lui $t1, 8*\sect + addu $a0, $t1 +.endif + addu $t0, $a0 + jr $ra + lh $v0, 0($t0) +.endm + + +m_read16_rom0: # 0x000000 - 0x07ffff + m_read16_rom 0 + +m_read16_rom1: # 0x080000 - 0x0fffff + m_read16_rom 1 + +m_read16_rom2: # 0x100000 - 0x17ffff + m_read16_rom 2 + +m_read16_rom3: # 0x180000 - 0x1fffff + m_read16_rom 3 + +m_read16_rom4: # 0x200000 - 0x27ffff, SRAM area + m_read_rom_try_sram 1 16 + lw $t1, 4($t3) # romsize + subu $t4, $t1, $a0 + blez $t4, m_read_null + lw $t1, 0($t3) # rom + ins $a0, $0, 0, 1 + addu $t1, $a0 + jr $ra + lh $v0, 0($t1) + +m_read16_rom5: # 0x280000 - 0x2fffff + m_read16_rom 5 + +m_read16_rom6: # 0x300000 - 0x37ffff + m_read16_rom 6 + +m_read16_rom7: # 0x380000 - 0x3fffff + m_read16_rom 7 + +m_read16_rom8: # 0x400000 - 0x47ffff + m_read16_rom 8 + +m_read16_rom9: # 0x480000 - 0x4fffff + m_read16_rom 9 + +m_read16_romA: # 0x500000 - 0x57ffff + m_read16_rom 0xA + +m_read16_romB: # 0x580000 - 0x5fffff + m_read16_rom 0xB + +m_read16_romC: # 0x600000 - 0x67ffff + m_read16_rom 0xC + +m_read16_romD: # 0x680000 - 0x6fffff + m_read16_rom 0xD + +m_read16_romE: # 0x700000 - 0x77ffff + m_read16_rom 0xE + +m_read16_romF: # 0x780000 - 0x7fffff + m_read16_rom 0xF + +m_read16_rom10: # 0x800000 - 0x87ffff + m_read16_rom 0x10 + +m_read16_rom11: # 0x880000 - 0x8fffff + m_read16_rom 0x11 + +m_read16_rom12: # 0x900000 - 0x97ffff + m_read16_rom 0x12 + +m_read16_rom13: # 0x980000 - 0x9fffff + m_read16_rom 0x13 + +m_read16_misc: + ins $a0, $0, 0, 1 + j OtherRead16 + li $a1, 16 + +m_read16_vdp: + ext $t0, $a0, 16, 3 + andi $t1, $a0, 0xe0 + or $t0, $t1 + bnez $t0, m_read_null # invalid address + ins $a0, $0, 0, 1 + j PicoVideoRead + nop + +m_read16_ram: + lui $t0, %hi(Pico) + ins $a0, $0, 0, 1 + ins $t0, $a0, 0, 16 + jr $ra + lh $v0, %lo(Pico)($t0) + +m_read16_above_rom: + # might still be SRam + m_read_rom_try_sram 0 16 + j OtherRead16End + ins $a0, $0, 0, 1 + +# ############################################################################# + +.macro m_read32_rom sect + lui $t0, %hi(Pico+0x22200) + lw $t0, %lo(Pico+0x22200)($t0) # rom + ins $a0, $0, 0, 1 + ins $a0, $0, 19, 13 +.if \sect + lui $t1, 8*\sect + addu $a0, $t1 +.endif + addu $t0, $a0 + lh $v1, 0($t0) + lh $v0, 2($t0) + jr $ra + ins $v0, $v1, 16, 16 +.endm + + +m_read32_rom0: # 0x000000 - 0x07ffff + m_read32_rom 0 + +m_read32_rom1: # 0x080000 - 0x0fffff + m_read32_rom 1 + +m_read32_rom2: # 0x100000 - 0x17ffff + m_read32_rom 2 + +m_read32_rom3: # 0x180000 - 0x1fffff + m_read32_rom 3 + +m_read32_rom4: # 0x200000 - 0x27ffff, SRAM area + m_read_rom_try_sram 1 32 + lw $t1, 4($t3) # romsize + subu $t4, $t1, $a0 + blez $t4, m_read_null + lw $t1, 0($t3) # rom + ins $a0, $0, 0, 1 + addu $t1, $a0 + lh $v1, 0($t1) + lh $v0, 2($t1) + jr $ra + ins $v0, $v1, 16, 16 + +m_read32_rom5: # 0x280000 - 0x2fffff + m_read32_rom 5 + +m_read32_rom6: # 0x300000 - 0x37ffff + m_read32_rom 6 + +m_read32_rom7: # 0x380000 - 0x3fffff + m_read32_rom 7 + +m_read32_rom8: # 0x400000 - 0x47ffff + m_read32_rom 8 + +m_read32_rom9: # 0x480000 - 0x4fffff + m_read32_rom 9 + +m_read32_romA: # 0x500000 - 0x57ffff + m_read32_rom 0xA + +m_read32_romB: # 0x580000 - 0x5fffff + m_read32_rom 0xB + +m_read32_romC: # 0x600000 - 0x67ffff + m_read32_rom 0xC + +m_read32_romD: # 0x680000 - 0x6fffff + m_read32_rom 0xD + +m_read32_romE: # 0x700000 - 0x77ffff + m_read32_rom 0xE + +m_read32_romF: # 0x780000 - 0x7fffff + m_read32_rom 0xF + +m_read32_rom10: # 0x800000 - 0x87ffff + m_read32_rom 0x10 + +m_read32_rom11: # 0x880000 - 0x8fffff + m_read32_rom 0x11 + +m_read32_rom12: # 0x900000 - 0x97ffff + m_read32_rom 0x12 + +m_read32_rom13: # 0x980000 - 0x9fffff + m_read32_rom 0x13 + +.macro m_read32_call16 func need_a1=0 + addiu $sp, -8 + sw $ra, 0($sp) + sw $s0, 4($sp) +.if \need_a1 + li $a1, 16 +.endif + jal \func + move $s0, $a0 + + addu $a0, $s0, 2 +.if \need_a1 + li $a1, 16 +.endif + jal \func + move $s0, $v0 + + ins $v0, $s0, 16, 16 + lw $ra, 0($sp) + lw $s0, 4($sp) + jr $ra + addiu $sp, 8 +.endm + +m_read32_misc: + ins $a0, $0, 0, 1 + m_read32_call16 OtherRead16, 1 + +m_read32_vdp: + ext $t0, $a0, 16, 3 + andi $t1, $a0, 0xe0 + or $t0, $t1 + bnez $t0, m_read_null # invalid address + ins $a0, $0, 0, 1 + m_read32_call16 PicoVideoRead + +m_read32_ram: + lui $t0, %hi(Pico) + ins $a0, $0, 0, 1 + ins $t0, $a0, 0, 16 + lh $v1, %lo(Pico)($t0) + lh $v0, %lo(Pico+2)($t0) + jr $ra + ins $v0, $v1, 16, 16 + +m_read32_above_rom: + # might still be SRam + m_read_rom_try_sram 0 32 + ins $a0, $0, 0, 1 + m_read32_call16 OtherRead16End + +# ############################################################################# + +.macro PicoWriteRomHW_SSF2_ls def_table table + lui $t3, %hi(\def_table) + ins $t3, $a1, 2, 5 + lw $t0, %lo(\def_table)($t3) + lui $t2, %hi(\table) + ins $t2, $a0, 2, 3 + sw $t0, %lo(\table)($t2) +.endm + +PicoWriteRomHW_SSF2: # u32 a, u32 d + ext $a0, $a0, 1, 3 + bnez $a0, pwr_banking + + # sram register + lui $t0, %hi(Pico+0x22211) + lb $t1, %lo(Pico+0x22211)($t0) # Pico.m.sram_reg + ins $t1, $a1, 0, 2 + jr $ra + sb $t1, %lo(Pico+0x22211)($t0) + +pwr_banking: + andi $a1, 0x1f + + PicoWriteRomHW_SSF2_ls m_read8_def_table m_read8_table + PicoWriteRomHW_SSF2_ls m_read16_def_table m_read16_table + PicoWriteRomHW_SSF2_ls m_read32_def_table m_read32_table + + jr $ra + nop + diff --git a/Pico/cd/Pico.c b/Pico/cd/Pico.c index def0a418..92dfe852 100644 --- a/Pico/cd/Pico.c +++ b/Pico/cd/Pico.c @@ -87,7 +87,7 @@ static __inline void SekRunM68k(int cyc) { int cyc_do; SekCycleAim+=cyc; - if((cyc_do=SekCycleAim-SekCycleCnt) < 0) return; + if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; #if defined(EMU_C68K) PicoCpuCM68k.cycles=cyc_do; CycloneRun(&PicoCpuCM68k); @@ -105,7 +105,7 @@ static __inline void SekRunS68k(int cyc) { int cyc_do; SekCycleAimS68k+=cyc; - if((cyc_do=SekCycleAimS68k-SekCycleCntS68k) < 0) return; + if ((cyc_do=SekCycleAimS68k-SekCycleCntS68k) <= 0) return; #if defined(EMU_C68K) PicoCpuCS68k.cycles=cyc_do; CycloneRun(&PicoCpuCS68k); diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index aa2acb2e..68106bc3 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -254,9 +254,9 @@ PICO_INTERNAL int PsndRender(int offset, int length) SN76496Update(PsndOut+offset, length, stereo); // Add in the stereo FM buffer - if (PicoOpt & 1) + if (PicoOpt & 1) { buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1); - else + } else memset32(buf32, 0, length<, 16_bit_mode // craigix_ram, confirm_save, show_cd_leds, confirm_load // A_SNs_gamma, perfect_vsync, giz_scanlines, giz_dblbuff + // vsync_mode int PicoOpt; // used for config saving only, see Pico.h int PsndRate; // ditto int PicoRegion; // ditto diff --git a/platform/common/menu.h b/platform/common/menu.h index cd7fa446..2635967d 100644 --- a/platform/common/menu.h +++ b/platform/common/menu.h @@ -70,6 +70,7 @@ typedef enum MA_OPT3_PRES_NOSCALE, MA_OPT3_PRES_FULLSCR, MA_OPT3_FILTERING, + MA_OPT3_VSYNC, MA_OPT3_DONE, MA_CDOPT_TESTBIOS_USA, MA_CDOPT_TESTBIOS_EUR, diff --git a/platform/gizmondo/Makefile b/platform/gizmondo/Makefile index 6581e4ff..e756fdaa 100644 --- a/platform/gizmondo/Makefile +++ b/platform/gizmondo/Makefile @@ -14,7 +14,7 @@ amalgamate = 0 -DEFINC = -I../.. -I. -D__GIZ__ -D_UNZIP_SUPPORT -DNO_SYNC +DEFINC = -I../.. -I. -D__GIZ__ -DNO_SYNC COPT_COMMON = -Wall -Winline ifeq ($(DEBUG),) COPT_COMMON += -O2 -ftracer -fomit-frame-pointer -fstrict-aliasing -ffast-math diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index 6e501a89..6fc189d9 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -1357,7 +1357,7 @@ static void draw_menu_credits(void) y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,"); + text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,"); text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); diff --git a/platform/gp2x/Makefile b/platform/gp2x/Makefile index 595db535..0e2ffe41 100644 --- a/platform/gp2x/Makefile +++ b/platform/gp2x/Makefile @@ -31,7 +31,7 @@ else use_cyclone = 1 endif -DEFINC = -I../.. -I. -DARM -D__GP2X__ -D_UNZIP_SUPPORT # -DBENCHMARK +DEFINC = -I../.. -I. -DARM -D__GP2X__ # -DBENCHMARK COPT_COMMON = -static -Wall -Winline ifeq ($(DEBUG),) COPT_COMMON += -O2 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index a60e4d80..7dd2e585 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -1394,7 +1394,7 @@ static void draw_menu_credits(void) text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,"); + text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,"); text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); diff --git a/platform/psp/Makefile b/platform/psp/Makefile index aecad367..49f9f7b9 100644 --- a/platform/psp/Makefile +++ b/platform/psp/Makefile @@ -10,7 +10,7 @@ amalgamate = 0 #up = 1 -CFLAGS += -I../.. -I. -D_UNZIP_SUPPORT -DNO_SYNC -D_ASM_DRAW_C_MIPS # -DBENCHMARK +CFLAGS += -I../.. -I. -DNO_SYNC CFLAGS += -Wall -Winline -G0 ifeq ($(DEBUG),) CFLAGS += -O2 -ftracer -fstrength-reduce -ffast-math @@ -37,7 +37,7 @@ OBJS += ../../PicoAll.o else OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Memory.o ../../Pico/Misc.o \ ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o \ - ../../Pico/Patch.o ../../Pico/Draw_amips.o + ../../Pico/Patch.o ../../Pico/Draw_amips.o ../../Pico/Memory_amips.o # Pico - CD OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \ @@ -82,7 +82,7 @@ LIBS += -lpng -lm -lpspgu -lpsppower -Wl,-Map=PicoDrive.map -lpspaudio TARGET = PicoDrive EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = PICODRIVE -#PSP_EBOOT_ICON = .png +PSP_EBOOT_ICON = data/icon.png #PSP_EBOOT_PIC1 = .png CUSTOM_CLEAN = myclean @@ -103,16 +103,24 @@ AS := psp-as ../../cpu/musashi/m68kops.c : make -C ../../cpu/musashi +../../cpu/fame/famec.o : ../../cpu/fame/famec.c + @echo ">>>" $< + $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ + +../../Pico/Memory.o : ../../Pico/Memory.c + @echo ">>>" $< + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_MEMORY_C -D_ASM_MEMORY_C_AMIPS + +../../Pico/Draw.o : ../../Pico/Draw.c + @echo ">>>" $< + $(CC) $(CFLAGS) -c $< -o $@ -D_ASM_DRAW_C_MIPS + readme.txt: ../../tools/textfilter ../base_readme.txt ../../tools/textfilter ../base_readme.txt $@ PSP ../../tools/textfilter: ../../tools/textfilter.c make -C ../../tools/ textfilter -../../cpu/fame/famec.o : ../../cpu/fame/famec.c - @echo ">>>" $< - $(CC) $(CFLAGS) -Wno-unused -c $< -o $@ - data/bg32.o: data/bg32.bin bin2o -i $< $@ bgdatac32 diff --git a/platform/psp/data/icon.png b/platform/psp/data/icon.png new file mode 100644 index 00000000..757a40b4 Binary files /dev/null and b/platform/psp/data/icon.png differ diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 0e64f2a2..3f645ed1 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -15,7 +15,7 @@ #include "../common/lprintf.h" #include "../../Pico/PicoInt.h" -#define OSD_FPS_X 420 +#define OSD_FPS_X 424 // additional pspaudio imports, credits to crazyc int sceAudio_38553111(unsigned short samples, unsigned short freq, char unknown); // play with conversion? @@ -35,7 +35,7 @@ int reset_timing = 0; // do we need this? static void sound_init(void); static void sound_deinit(void); -static void blit2(const char *fps, const char *notice); +static void blit2(const char *fps, const char *notice, int lagging_behind); static void clearArea(int full); void emu_noticeMsgUpdated(void) @@ -133,7 +133,7 @@ void emu_setDefaultConfig(void) currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.Frameskip = -1; // auto currentConfig.volume = 50; - currentConfig.CPUclock = 222; + currentConfig.CPUclock = 333; currentConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU currentConfig.KeyBinds[ 6] = 1<<1; currentConfig.KeyBinds[ 7] = 1<<2; @@ -361,7 +361,7 @@ static void cd_leds(void) p = (unsigned int *)((short *)psp_screen + 512*2+4+2); col_g = (old_reg & 2) ? 0x06000600 : 0; - col_r = (old_reg & 1) ? 0xc000c000 : 0; + col_r = (old_reg & 1) ? 0x00180018 : 0; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 512/2 - 12/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 512/2 - 12/2; *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; @@ -402,11 +402,9 @@ void blit1(void) } -static void blit2(const char *fps, const char *notice) +static void blit2(const char *fps, const char *notice, int lagging_behind) { - int emu_opt = currentConfig.EmuOpt; - - sceGuSync(0,0); + int vsync = 0, emu_opt = currentConfig.EmuOpt; if (notice || (emu_opt & 2)) { if (notice) osd_text(4, notice, 0); @@ -418,7 +416,11 @@ static void blit2(const char *fps, const char *notice) if ((emu_opt & 0x400) && (PicoMCD & 1)) cd_leds(); - psp_video_flip(0); + if (currentConfig.EmuOpt & 0x2000) { // want vsync + if (!(currentConfig.EmuOpt & 0x10000) || !lagging_behind) vsync = 1; + } + + psp_video_flip(vsync); } // clears whole screen or just the notice area (in all buffers) @@ -666,7 +668,8 @@ static void RunEvents(unsigned int which) (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save { int keys; - blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)"); + sceGuSync(0,0); + blit2("", (which & 0x1000) ? "LOAD STATE? (X=yes, O=no)" : "OVERWRITE SAVE? (X=yes, O=no)", 0); while( !((keys = psp_pad_read(1)) & (BTN_X|BTN_CIRCLE)) ) psp_msleep(50); if (keys & BTN_CIRCLE) do_it = 0; @@ -966,12 +969,14 @@ void emu_Loop(void) PicoFrame(); - blit2(fpsbuff, notice); + sceGuSync(0,0); // check time tval = sceKernelGetSystemTimeLow(); tval_diff = (int)(tval - tval_thissec) << 8; + blit2(fpsbuff, notice, tval_diff > lim_time); + if (currentConfig.Frameskip < 0 && tval_diff - lim_time >= (300000<<8)) // slowdown detection reset_timing = 1; else if (PsndOut != NULL || currentConfig.Frameskip < 0) diff --git a/platform/psp/menu.c b/platform/psp/menu.c index 32c41152..2231d95d 100644 --- a/platform/psp/menu.c +++ b/platform/psp/menu.c @@ -962,6 +962,7 @@ menu_entry opt3_entries[] = { NULL, MB_NONE, MA_OPT3_HSCALE32, NULL, 0, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT3_HSCALE40, NULL, 0, 0, 0, 1 }, { NULL, MB_ONOFF, MA_OPT3_FILTERING, ¤tConfig.scaling, 1, 0, 0, 1 }, + { NULL, MB_NONE, MA_OPT3_VSYNC, NULL, 0, 0, 0, 1 }, { "Set to unscaled centered", MB_NONE, MA_OPT3_PRES_NOSCALE, NULL, 0, 0, 0, 1 }, { "Set to fullscreen", MB_NONE, MA_OPT3_PRES_FULLSCR, NULL, 0, 0, 0, 1 }, { "done", MB_NONE, MA_OPT3_DONE, NULL, 0, 0, 0, 1 }, @@ -986,6 +987,13 @@ static void menu_opt3_cust_draw(const menu_entry *entry, int x, int y, void *par case MA_OPT3_FILTERING: text_out16(x, y, "Bilinear filtering %s", currentConfig.scaling?"ON":"OFF"); break; + case MA_OPT3_VSYNC: { + char *val = " never"; + if (currentConfig.EmuOpt & 0x2000) + val = (currentConfig.EmuOpt & 0x10000) ? "sometimes" : " always"; + text_out16(x, y, "Wait for vsync %s", val); + break; + } default: break; } } @@ -1023,11 +1031,11 @@ static void menu_opt3_preview(int is_32col) static void draw_dispmenu_options(int menu_sel) { - int tl_x = 80+25, tl_y = 16+50; + int tl_x = 80, tl_y = 16+50; menu_draw_begin(); - menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 252); + menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 316); me_draw(opt3_entries, OPT3_ENTRY_COUNT, tl_x, tl_y, menu_opt3_cust_draw, NULL); @@ -1043,7 +1051,7 @@ static void dispmenu_loop_options(void) menu_sel_max = me_count_enabled(opt3_entries, OPT3_ENTRY_COUNT) - 1; - for(;;) + for (;;) { draw_dispmenu_options(menu_sel); inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_X|BTN_CIRCLE); @@ -1056,12 +1064,19 @@ static void dispmenu_loop_options(void) if (inp & (BTN_LEFT|BTN_RIGHT)) // multi choise { float *setting = NULL; + int tmp; me_process(opt3_entries, OPT3_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0); switch (selected_id) { case MA_OPT3_SCALE: setting = ¤tConfig.scale; break; case MA_OPT3_HSCALE40: setting = ¤tConfig.hscale40; is_32col = 0; break; case MA_OPT3_HSCALE32: setting = ¤tConfig.hscale32; is_32col = 1; break; case MA_OPT3_FILTERING:menu_opt3_preview(is_32col); break; + case MA_OPT3_VSYNC: tmp = ((currentConfig.EmuOpt>>13)&1) | ((currentConfig.EmuOpt>>15)&2); + tmp = (inp & BTN_LEFT) ? (tmp>>1) : ((tmp<<1)|1); + if (tmp > 3) tmp = 3; + currentConfig.EmuOpt &= ~0x12000; + currentConfig.EmuOpt |= ((tmp&2)<<15) | ((tmp&1)<<13); + break; default: break; } if (setting != NULL) { @@ -1462,12 +1477,15 @@ static void draw_menu_credits(void) y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: base code of PicoDrive"); + text_out16(tl_x, (y+=10), "fDave: base code of PicoDrive"); + text_out16(tl_x, (y+=10), "Chui: Fame/C"); + text_out16(tl_x, (y+=10), "NJ: CZ80"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); - text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); text_out16(tl_x, (y+=10), "Stephane Dallongeville:"); - text_out16(tl_x, (y+=10), " opensource Gens"); + text_out16(tl_x, (y+=10), " Gens code, base of Fame/C, CZ80"); + text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); text_out16(tl_x, (y+=10), "Haze: Genesis hw info"); + text_out16(tl_x, (y+=10), "ps2dev.org people: PSP SDK/code"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); menu_draw_end();