Pdawg
Micro-optimizing a Z80 emulators' pipeline. **Unsafe code**
so, i'm writing an emulator, and i'm trying to squeeze as much perf as i can out of hot paths. this seemingly simple fetch operation consumes about a third of the CPU time:
my memory class looks like this:
i know, it's a bit messy, and it's not really safe either, but boy does it give some perf gains. it's worth it. also, the array wont change size so it should be alright.
my registers are in a similar situation. the register set is actually an array of bytes that are accessed using constant indexers into said array, like this:
but, this is a Z80, meaning it also has 16-bit register pairs. this is important, because you can either access it as its high and low parts, or its entire pair, meaning that the exposed pairs depend on this same array, so i implemented them using properties
with all of this in mind, how can i make that fetch instruction faster and use less CPU time?
215 replies
Optimizing the pipeline on my Z80 emulator
Hello! I've come to ask you all a question about optimization of lambda expressions. Currently, my pipeline looks like this:
This is nice because it's very reusable, but, lambda indirection to convert the
LD_R_R(C, B)
into an anonymous call takes time. In this case, it seems like lambdas are pretty slow. How should I go about optimizing this while still keeping it reusable?17 replies
✅ Consuming external .winmd file in Cs/WinRT
Hello! I have a winmd file from a GitHub repo that contains some extra metadata in Windows.UI.Xaml.Hosting. How can I make Cs/WinRT consume it for use in my program? I got C++/WinRT to do it, but I'm not sure how to do it in Cs/WinRT.
2 replies
Plugin system not casting properly
I'm trying to make a plugin system for my app, which does this:
The
IPlugin
instance is null, so calling plugin.Initialize()
throws an NRE. The thing is, it should work just fine, given my plugin code:
And yes, they both reference the same exact interface, defined in GyroShell.Library.Interfaces
.
Lastly, I've tried debugging this and nothing should go wrong. It tries to cast the PluginRoot
class to an IPlugin
, which should work since it properly implements the interface, but it just fails. No exceptions are thrown.58 replies
❔ Set item to null inside a list
Hey! I am trying to remove some items from a JSON object (created like
var model = new ObjectModel{}
). Inside of the object model is a Pages<PagesResource>
list, and inside of that is the IconBindings object. I need to be able to set it to null. It’s hard to explain, so here’s the source code (and there is a comment on what I need to do): https://github.com/Pdawg-bytes/webtile-json-serializer3 replies
❔ Adding logic into a JSON serializer
Hey everyone! I need to add logic into a json object, but I can't add any code in there or else it'll break. Here is what I mean: If I have a
Dictionary
named Icons, I need to say foreach item selected from the filepicker, create a new keypair in the Dictionary
. Basically, the user selects a few .png files, the code needs to copy them to a folder and add those names to the dictionary. Here is my current code that is a static dictionary:
11 replies
❔ How can I access a member of a different class in a dictionary
Hey! I'm trying to refactor my old JSON serializer code, but I ran into an issue. I can't access a string in another class named
RssTitle
. In this Content
property, there are 3 different strings that I need to access, RssTitle, RssDesc, and RssPubDate. When I use a dictionary like this:
It can't access those 3 strings, and just says that RssTitle does not exist in the current context
. Here is the data model behind this code
If I use a List
, like this: public List<ContentList> Content { get; set; }
, it creates an array in the serialized JSON. I need it to not be an array. Here's what the final JSON looks like:
I need it to look like this:
6 replies