All Projects → cspspemu → Cspspemu

cspspemu / Cspspemu

C# PSP Emulator (.NET Core 3.1)

Projects that are alternatives of or similar to Cspspemu

Ace
Asheron's Call server emulator.
Stars: ✭ 185 (+74.53%)
Mutual labels:  dotnet-core, emulator
PokemonBattleEngine
A C# library that can emulate Pokémon battles.
Stars: ✭ 92 (-13.21%)
Mutual labels:  emulator, dotnet-core
Ryujinx
Experimental Nintendo Switch Emulator written in C#
Stars: ✭ 10,983 (+10261.32%)
Mutual labels:  dotnet-core, emulator
Gopher2600
Gopher2600 is an Atari 2600/VCS Emulator.
Stars: ✭ 98 (-7.55%)
Mutual labels:  emulator
Softuni
SoftUni Courses
Stars: ✭ 98 (-7.55%)
Mutual labels:  dotnet-core
Azurite
!! This repository has now moved to https://github.com/azure/azurite !! A lightweight server clone of Azure Blob, Queue, and Table Storage that simulates most of the commands supported by it with minimal dependencies.
Stars: ✭ 103 (-2.83%)
Mutual labels:  emulator
Gbajs2
gbajs2 is a Game Boy Advance emulator written in Javascript from scratch using HTML5 technologies like Canvas and Web Audio. It is freely licensed and works in any modern browser without plugins.
Stars: ✭ 106 (+0%)
Mutual labels:  emulator
Dotnet Stellar Sdk
Stellar API SDK for .NET Core 2.x and .NET Standard 2.0
Stars: ✭ 97 (-8.49%)
Mutual labels:  dotnet-core
Pokemon
A Pokémon API that was made with .NET Core and the frontend with React.
Stars: ✭ 105 (-0.94%)
Mutual labels:  dotnet-core
Yakc
Yet another KC emulator
Stars: ✭ 102 (-3.77%)
Mutual labels:  emulator
Oscam Emu
Open Source Cam Emulator (patch only)
Stars: ✭ 101 (-4.72%)
Mutual labels:  emulator
Ish
Linux shell for iOS
Stars: ✭ 10,991 (+10268.87%)
Mutual labels:  emulator
Nes.swift
An NES emulator written in Swift
Stars: ✭ 103 (-2.83%)
Mutual labels:  emulator
L2dotnet
A server emulator for Lineage2 Interlude written in C#
Stars: ✭ 98 (-7.55%)
Mutual labels:  emulator
Aspnetcore App Workshop
This workshop has been migrated to https://github.com/dotnet-presentations/aspnetcore-app-workshop
Stars: ✭ 105 (-0.94%)
Mutual labels:  dotnet-core
Netcorecli Fsc
[DEPRECATED] F# and .NET Core SDK working together
Stars: ✭ 97 (-8.49%)
Mutual labels:  dotnet-core
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+1217.92%)
Mutual labels:  dotnet-core
Cronscheduler.aspnetcore
Cron Scheduler for AspNetCore 2.x/3.x or DotNetCore 2.x/3.x Self-hosted
Stars: ✭ 100 (-5.66%)
Mutual labels:  dotnet-core
Laines
Cycle-accurate NES emulator in ~1000 lines of code
Stars: ✭ 1,365 (+1187.74%)
Mutual labels:  emulator
Bap
Binary Analysis Platform
Stars: ✭ 1,385 (+1206.6%)
Mutual labels:  emulator

CSharp Psp Emulator

Actions Status Slack

Kaiten Patissier PSP

A PSP Emulator for >= .NET Core 3.0 made in C# by soywiz - Carlos Ballesteros Velasco

Work In Progress emulator

EMULATOR STATUS:

  • Cpu, Fpu and VFpu are almost fully implemented
  • Audio is implemented
  • Gpu still requires lots of works
  • Hle emulation has implemented lots of APIs (still lot of work left)
  • There are lot of homebrew games running
  • There are a growing number of commercial games running at full speed

KEY FEATURES:

Fully Managed and Disengaged

Being fully managed (thought it will need unsafe access) will allow to port to lots of platforms in the future: AKA: Linux, Mac, PS3, Android, future devices...

Very Fast Dynamic Recompilation

The quality of the generated code is fantastic.
Lots of MIPs instructions encodes in a single X86/64 instruction.
The registers are inlined in the CpuThreadState class, so access
to a register is as fast as accessing a non-virtual field.

Fast As Hell Memory Access (Currently on Windows/Linux only)

Using VirtualAlloc/mmap, allows all the PSP Memory Segments to be in a virtual space that fits the PSP Memory.
And since there is no DMA access on a HLE emulation, we can get a pointer just making an ADD operation between the base and the PSP address.
This is as fast as possible.

MainPtr = VirtualAlloc(Base + MainOffset, MainSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);

Very Fast Function Cache

Detect and access to a function cache features O(1),
adding a function cache O(log(n)),
and flushing a range or the whole Function Cache is as fast as possible too.
This is achieved with a Array that contains all the possible memory addresses and a SortedSet
that allows to know which functions have been generated and should be purged when invalidating instruction cache.

Very Fast Thread Switching

Each PSP Thread is a native Green Thread / Fiber. Since the PSP has a single core, and some games requres
thread scheduling, we simulate thread scheduling with fibers. Each PspThread have its own registers in an object,
so instead of restoring the registers, it just resumes the thread execution. Skiping completely the register restoring.
This model also allows to pause the execution of the code at any time very easy, even inside an HleFunction or even
in the future, if we optimize the function generation to detect JAL instructions and call delegates directly, inside
nested function calls.

Very clean HLE Emulation using CustomAttributes, LINQ, method mapping and XML Documentation

LINQ + functional-programming helps to make the code very clean, simple and easy to understand.

/// <summary>
/// Get the size of the largest free memory block.
/// </summary>
/// <returns>The size of the largest free memory block, in bytes.</returns>
[HlePspFunction(NID = 0xA291F107, FirmwareVersion = 150)]
public int sceKernelMaxFreeMemSize()
{
	return HleState.MemoryManager.GetPartition(HleMemoryManager.Partitions.User).ChildPartitions
		.Where(Partition => !Partition.Allocated)
		.OrderByDescending(Partition => Partition.Size)
		.First()
		.Size
	;
}

C# support of structs and pointers, allow the HLE functions to use pointers directly and seamlessly.

/// <summary>
/// Reads an entry from an opened file descriptor.
/// </summary>
/// <param name="FileHandle">Already opened file descriptor (using sceIoDopen)</param>
/// <param name="IoDirent">Pointer to an io_dirent_t structure to hold the file information</param>
/// <returns>
///		Read status
///		Equal to   0 - No more directory entries left
///		Great than 0 - More directory entired to go
///		Less  than 0 - Error
/// </returns>
[HlePspFunction(NID = 0xE3EB004C, FirmwareVersion = 150)]
public int sceIoDread(int FileHandle, HleIoDirent* IoDirent)
{
	var HleIoDrvFileArg = GetFileArgFromHandle(FileHandle);
	return HleIoDrvFileArg.HleIoDriver.IoDread(HleIoDrvFileArg, IoDirent);
}

Faster than the original PSP, than DPspEmu and than JPCSP

Most CPU/FPU/VFPU operations are something like 8x times faster than the original PSP on a modern computer.
Still the GPU implementation is still limited because of the Cpu <-> Gpu memory BUS. But probably will be enough in most cases.

KISS and DRY

With the "Keep It Simple Stupid" and "Don't Repeat Yourself" philosophies always in mind,
the quality of the core is a priority always over new features.

CPU/Gpu Instruction decoding, assembler and disassembler share a single table with the instruction descriptions that will allow generating the required code on the fly.

	// Arithmetic operations.
	ID("add",    VM("000000:rs:rt:rd:00000:100000"), "%d, %s, %t", ADDR_TYPE_NONE, 0),
	ID("addu",   VM("000000:rs:rt:rd:00000:100001"), "%d, %s, %t", ADDR_TYPE_NONE, 0),
	ID("addi",   VM("001000:rs:rt:imm16"          ), "%t, %s, %i", ADDR_TYPE_NONE, 0),

UnitTesting and Integration Tests

The idea is to create a full set of tests, testing the emulator interface, code generation, and HLE APIs.
UnitTests are integrated in the code, and HLE APIs are external integration tests in form of PSP executables than can be executed on any emulator to test APIs.
There is a project called pspautotests used by all the active emulators to test regressions and new APIs.

Fully Open Source

Project is on GitHub, so anyone can branch the project and perform Pull Requests helping to improve the code.

Created after 4 tries

I'm the creator of the D PSP Emulator. That emulator had 4 versions, every one was created almost from the scratch with different approaches and trying
to improve the quality of the code in each iteration.
The lack of a good IDE, the complicated structure of the D language, the horrible compilation times, caused that it taked too much time for everything,
and made it impossible to refactoring the code without days or weeks of work.
In this time I have learned lot of things, and since the .NET platform is fast enough, have "mono", and solves all my problems with D, it will be my final choice.

Final Words

The first emulator made by Noxa was a C# emulator too. It was for .NET 2.0. .NET and C# have evolved a lot since that 2.0 version. And now it is probably the best
platform/language out there. It has the right balance between ease, power and speed. Of course it lacks some stuff, but it is the language where less programming features I have missed.
I didn't used the pspplayer code as base because I wanted to make things with all the stuff I have learned this time and with a different approach.
I started the first version of my emulator using Noxa's pspplayer as base. I didn't managed to compile his code that time because of a mixed DLL x86/x64, and I wanted to learn to make an emulator.
I want to acknowledge all the great work of Noxa, because without all his first hard work, I hadn't learnt this all stuff.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].