www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - PSP emulator written in D

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Just found this. Seems pretty interesting. Anyone know more about the 
developer?

http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/

One thing I like is the use of CustomFloat for defining half-floating 
point numbers - one application I had in mind when defining CustomFloat. 
Glad to see it works (after the community fixed it :o)).


Andrei
Aug 09 2011
parent reply Stephan <spam extrawurst.org> writes:
On 09.08.2011 17:13, Andrei Alexandrescu wrote:
 Just found this. Seems pretty interesting. Anyone know more about the
 developer?

 http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/

 One thing I like is the use of CustomFloat for defining half-floating
 point numbers - one application I had in mind when defining CustomFloat.
 Glad to see it works (after the community fixed it :o)).


 Andrei

Nice - is the code to find somewhere ??
Aug 09 2011
next sibling parent reply "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Tue, 09 Aug 2011 17:31:05 +0200, Stephan wrote:

 On 09.08.2011 17:13, Andrei Alexandrescu wrote:
 Just found this. Seems pretty interesting. Anyone know more about the
 developer?

 http://www.appleumbrella.com/2011/08/d-psp-emulator-svn-r306/

 One thing I like is the use of CustomFloat for defining half-floating
 point numbers - one application I had in mind when defining
 CustomFloat. Glad to see it works (after the community fixed it :o)).


 Andrei

Nice - is the code to find somewhere ??

http://code.google.com/p/pspemu/
Aug 09 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Lars T. Kyllingstad:

 http://code.google.com/p/pspemu/

Thank you for the link. I think there is enough evidence that it is possible to use D (V.1) to write some video games. It's one of the very few niches where D has shown some more appreciation. So to blow on this tiny fire, do you know ways to improve the D2 language and D2 Phobos to help game development? ----------------- Some comments on the source code: The author seems to believe that the right way to name D modules is with a starting uppercase, like "Event.d". In the modules I see a large amount of array appends (~=), the author maybe thinks those are efficient operations, as in C++ vectors. To simulate a CPU computed gotos help performance. Interpreters are common, computed gotos are useful to run finite state machines too (and in computational biology I have had to build such machines. I have used computed gotos of GNU-C to speed up code). This again shows that some common basic exceptions are needed in Phobos: http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/Exceptions.d ----------------- With the idea recently discussed this code: http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/core/EmulatorState.d this(Interrupts interrupts, Memory memory, IBattery battery, IDisplay display, Controller controller, Gpu gpu, Cpu cpu) { this.interrupts = interrupts; this.memory = memory; this.battery = battery; this.display = display; this.controller = controller; this.runningState = runningState; this.gpu = gpu; this.cpu = cpu; resetVariables(); } Becomes: this(this.interrupts, this.memory, this.battery, this.display, this.controller, this.gpu, this.cpu) { this.runningState = runningState; resetVariables(); } This is not just shorter, it's more DRY and less bug-prone. ----------------- This page: http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/core/Memory.d Contains code like: class InvalidAddressException : public MemoryException { I think that "public" needs to become a syntax error. ----------------- This is bad code, I didn't even know D supports empty catch: http://pspemu.googlecode.com/svn/trunk/src/pspemu/utils/Expression.d static long parseString(string s, long default_value = 0) { if (s.length > 0) { try { ... } catch { } } return default_value; } ----------------- That asm code for the float[4] vectors are cute, unfortunately they kill inlining with DMD, so they often produce slower code: http://pspemu.googlecode.com/svn/trunk/src/pspemu/utils/MathUtils.d ----------------- This seems at home in Phobos too: http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/utils/Types.d Bye, bearophile
Aug 09 2011
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
bearophile wrote:
 This is bad code, I didn't even know D supports empty catch:


 http://pspemu.googlecode.com/svn/trunk/src/pspemu/utils/Expression.d

 static long parseString(string s, long default_value = 0) {
     if (s.length > 0) {
         try {
             ...
         } catch {
         }
     }
     return default_value;
 }

That he is using an empty catch is actually not too bad compared to the fact that what he intends to catch is an AssertError from the preceding function, which is an actual bug, not just bad practice.
Aug 09 2011
prev sibling next sibling parent reply KennyTM~ <kennytm gmail.com> writes:
On Aug 10, 11 05:15, bearophile wrote:
 This again shows that some common basic exceptions are needed in Phobos:
 http://code.google.com/p/pspemu/source/browse/trunk/src/pspemu/Exceptions.d

These exceptions are not common or basic. I think it's better to make constructors inheritable when there are no new members, or add something like this to std.exception: --------------- mixin template ExceptionConstructors() { this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) { super(msg, file, line, next); } this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) { super(msg, next, file, line); } } --------------- So those custom exceptions can be created as class TimeoutException : Exception { mixin ExceptionConstructors; }
Aug 09 2011
parent bearophile <bearophileHUGS lycos.com> writes:
KennyTM~:

 These exceptions are not common or basic.

You are right, sorry. I meant common ones like this: http://d.puremagic.com/issues/show_bug.cgi?id=6410 Bye, bearophile
Aug 10 2011
prev sibling parent reply Peter Alexander <peter.alexander.au gmail.com> writes:
On 9/08/11 10:15 PM, bearophile wrote:
 So to blow on this tiny fire, do you know ways to improve the D2 language and
D2 Phobos to help game development?

There's different levels of game developer. Indies will mostly want convenience, but AAA developers need control. For example, a good vector + matrix + quaternion math library would be great for indies, but AAA developers would likely write their own, even if the library was highly optimised with SIMD, floatInVec etc. SIMD intrinsics are obviously essential for AAA development. The garbage collector is something that still needs work. My current project has several second stalls every once in a while due to the GC (indies might be happy to miss a frame or two (30-60ms) but AAA developers won't, so you either don't use the GC, or it has to collect in under a couple of ms). I managed to remove all my per-frame allocations, but this was not easy. I had to modify my druntime to print out when allocations where happening to find them (most were those static array initialisations that I often talk about). Of course, having libraries available for audio/image loading/manipulation is helpful, and bindings for OpenGL etc. but those are already available through Derelict. I don't think they need to be in Phobos. The most important thing at the moment is just to get the language into a usable state and to get all the advertised features working. We also need more tutorials and resources to explain the subtler parts of D2 (e.g. when, why and how template alias parameters work).
Aug 10 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Peter Alexander:

There's different levels of game developer. Indies will mostly want
convenience, but AAA developers need control.<

Right. Both groups are important.
For example, a good vector + matrix + quaternion math library would be great
for indies, but AAA developers would likely write their own, even if the
library was highly optimised with SIMD, floatInVec etc.<

A 2D/3D/4D vector is good to have in Phobos. (Quaternion are optional).
SIMD intrinsics are obviously essential for AAA development.<

The problem is they change as time goes. So instead of adding a ton of those (ugly) intrinsics, I suggest to add a meta-feature to D: a syntax to write inlin-able asm expressions (as present in LDC). With this syntax, SIMD intrinsics become library (even Phobos) code to standardize.
I had to modify my druntime to print out when allocations where happening to
find them (most were those static array initialisations that I often talk
about).<

This is useful. Why don't you create a patch that (when a specific compiler switch is on) lists at compile-time all heap allocations and closure allocations of a compilation unit?
The most important thing at the moment is just to get the language into a
usable state<

This will take time, and you can't rush it. Thank you for the answers, bye, bearophile
Aug 10 2011
parent reply Peter Alexander <peter.alexander.au gmail.com> writes:
On 10/08/11 12:21 PM, bearophile wrote:
 A 2D/3D/4D vector is good to have in Phobos. (Quaternion are optional).

Quaternions are important for fast 3D rotations, but yes, vectors are most important.
 SIMD intrinsics are obviously essential for AAA development.<

The problem is they change as time goes. So instead of adding a ton of those (ugly) intrinsics, I suggest to add a meta-feature to D: a syntax to write inlin-able asm expressions (as present in LDC). With this syntax, SIMD intrinsics become library (even Phobos) code to standardize.

The problem with that approach is that the compiler doesn't know about them and will likely have trouble optimising. GCC will optimise SIMD intrinsic math in the same way that it optimises scalar math. Also, unless I'm mistaken, you can't use inline assembly to define a vector type whose storage is an xmm register. In GCC, you'd do typedef __m128 Vec4; or at least struct Vec4 { __m128 m_xyzw; }; This ensures that when you return them or pass them into a function then they are passed in registers and don't have to go through memory. Can you do that in LDC? (I'm not familiar with it).
 I had to modify my druntime to print out when allocations where happening to
find them (most were those static array initialisations that I often talk
about).<

This is useful. Why don't you create a patch that (when a specific compiler switch is on) lists at compile-time all heap allocations and closure allocations of a compilation unit?

I will do if/when I find time.
Aug 10 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Peter Alexander:

 Can you do that in LDC? (I'm not familiar with it).

They can't do that, I think: http://www.dsource.org/projects/ldc/wiki/InlineAsmExpressions
 I will do if/when I find time.

Good. This enhancement request asks for just closures, but listing general heap allocations too is possible: http://d.puremagic.com/issues/show_bug.cgi?id=5070 Regarding your problem of the "static array initialisations", it will be eventually fixed, I presume. Don has said it's not too much hard to fix, and I think it's worth fixing. Bye, bearophile
Aug 10 2011
prev sibling parent Trass3r <un known.com> writes:
 The garbage collector is something that still needs work. My current  
 project has several second stalls every once in a while due to the GC  
 (indies might be happy to miss a frame or two (30-60ms) but AAA  
 developers won't, so you either don't use the GC, or it has to collect  
 in under a couple of ms).

There already is a concurrent GC which might be of interest for you.
Aug 10 2011