I just got back from the BaltoMSDN meeting, Geoff Snowman put on a good presentation about the ins and outs of crypto, and the only thing I can think to add to it is that when you're dealing with symmetric key encryption, the message needs to be secret as well as the key. If you can derive the message from the encrypted message, using the key, you can derive the key from the encrypted message using the original message.
A lot of hard-drive based crypting programs were compromised when people realized if the drive was formatted in FAT, they could look for the allocation table in the usual spot, get the encrypted version, then derive the key from the (known, static) unencrypted version. So, encrypting the data isn't enough, the contents must be scrambled too. Which goes to the point I tried to make about security holes never being found in the cryptology - the math is solid - they're always in the implemenation.
You can hash your users passwords in the database all you want, but if every client app logs into the database with the same user/pass combo, then that's the vector an attacker is going to use, and all your high talk about salting your hash is really just masturbation.
But, as far as important news.. I got around to updating the mono port of my emulator, which took about 5 minutes, really, since Unity does all the hard work, it's just a matter of registering the appropriate platform specific classes. What was weird, was that the 'callback' member was missing from the SDL bindings in the Tao framework.. What's even weirder, is that the framework hasn't been updated since 2005, so where the hell did it go and how could it have got gone? It could be something to do with running in a VM, but I never really knew type members could just 'disappear' like that. Very odd.. No sound for linux (well, flakey OpenAL based sound).
I also started work on an assembler. Once I've populated my 'instruction' structure I already use in my debugger, emitting the bytes is all but automatic. All I needed is a parser, and it's pretty easy work, regex does most of the heavy lifting as far as identifying addressing modes, which is really the only 'problem' to solve.
The only work left is to add a pass to replace labels with actual addresses, and a little more focus on making sure the syntax is in line with other popular 6502 assemblers.
My goal is to host this as a server side component, and to leverage some of the 'online IDE' ajax type stuff out there to put together an easy to use online environment for the homebrew community.
But it'll probably be on hold for awhile as I plan to be busy at work, but I may get it online this weekend.
Wednesday, March 17, 2010
Sunday, March 14, 2010
Silverlight Updates
I've spent a bunch of work bringing the Silverlight version up to speed, and have managed to clean up some code along the way..
New in Silverbulb:
Debugger support (currently just have the Machine Status view implemented)
Pattern and Name tables viewer
FPS Limiter for slow machines (sets Silverlight's max FPS only)
SRAM read/write to IsolatedStorage (automatic on poweron/poweroff)
SRAM read/write relies on the iNes header having the SRAM bit set properly. I haven't done anything to handle requesting more storage, and also should provide a way to purge out old saves, and a way to load/save them to a local file. Some sort of "cart data" management dialog is in order, though this should completely abstract the filesystem from the user.
New in Silverbulb:
Debugger support (currently just have the Machine Status view implemented)
Pattern and Name tables viewer
FPS Limiter for slow machines (sets Silverlight's max FPS only)
SRAM read/write to IsolatedStorage (automatic on poweron/poweroff)
SRAM read/write relies on the iNes header having the SRAM bit set properly. I haven't done anything to handle requesting more storage, and also should provide a way to purge out old saves, and a way to load/save them to a local file. Some sort of "cart data" management dialog is in order, though this should completely abstract the filesystem from the user.
Monday, March 8, 2010
Silverlight MediaStreamSource AudioBufferLength
Having end-users who've toyed with my emulator randomly complaining about sound pops or skips, I decided to sick a slider which would allow them ot set the AudioBufferLength of the MediaStreamSource which generates the sound.. However, it doesn't seem to affect the stream in real time. Hmm, I don't want to have to tear down and recreate the audio in real time, if avoidable. I wonder if there's a solution out there? Anybody?
Wednesday, March 3, 2010
What's in a name?
I was doing a little reading up on the System.Threading.Tasks namespace, and threading changes in general in .Net 4.0, and got a little bit confused by this. He says of ThreadPool.QueueUserWorkItem(), and I'll quote here:
Collection, Dictionary, Cluster, Glob, Bag, Bucket, whatever - define those structures however you want. Those words are rooted in neckbeard yap. Queue, priority queue, and stack have rigid mathematical definitions and cannot behave any other way. At least, not without cheesing me off.
The FIFO order is not something that is documented or guaranteed, but my personal guess is that too many applications rely on it, so I don’t see it changing any time soon.Not documented? Not guaranteed? Are you kidding me? It's called a Queue. Queue means FIFO. If it behaved any other way they'd be buried in bug reports. My personal guess is that even the best of us can get confused and miss basic principles. Not to insult the Moth, there is a ton of good information regarding parallelism on his blog, and I certainly recommend it.
Collection, Dictionary, Cluster, Glob, Bag, Bucket, whatever - define those structures however you want. Those words are rooted in neckbeard yap. Queue, priority queue, and stack have rigid mathematical definitions and cannot behave any other way. At least, not without cheesing me off.
Tuesday, March 2, 2010
CMAP For VS 2010
Just got back from the CMAP meeting, Antonio Chagoury did a presentation on some of the lipstick and mascara applied to VS 2010. I've been using it for awhile, and had already been taking advantage of some of the new IDE tweaks (the zoom feature kind of gets on my nerves, to be honest, I keep trying to scroll the code window up and end up staring down a semicolon 200 pt font ).
Some of the ASP.Net and WebForms stuff he showed off was informative, however, since I've not had too much professional exposure to that stuff. Would like to hear more about the threads debugger, profiling, debugging 64 bit apps, TFS and ClickOnce enhancements, but hey, you can only get through so much in an hour, and to be fair, not many folk nerd out on stuff like that how I do.
Free pizza. Free soda. Good times had by all. I just may start showing up at more CMAP events.
Some of the ASP.Net and WebForms stuff he showed off was informative, however, since I've not had too much professional exposure to that stuff. Would like to hear more about the threads debugger, profiling, debugging 64 bit apps, TFS and ClickOnce enhancements, but hey, you can only get through so much in an hour, and to be fair, not many folk nerd out on stuff like that how I do.
Free pizza. Free soda. Good times had by all. I just may start showing up at more CMAP events.
Horribly broken mid-screen bankswitching/mirroring
Oops.. Well, at least hardware and software renderers are rendering the same output. Not quite sure how I broke it, but I think I may be mapping VROM over top of VRAM, and thusly getting junk written on top of it. I need to impement a cart event debugger/logger, ASAP!
Update: Nah, the code that could have banskwitched a VROM into VRAM was incorrect, but unreachable in that mapper (Afterburner is the only game/cart/mapper that I know of that has nametables in rom only and bankswitches them). The code is a little bit complicated, because what I do is keep an array which holds the starting address for each 4k block of VROM, and bankswitching updates these pointers. To top that off, every time a bankswitch happens, this array is pushed onto the next level of a 2D array, the bankswitch cache, which holds every bankswitch that happened in a frame. I do this, because for the GPU version, I don't send pixels, but I send the information needed to draw the pixels (the current ppu status bytes, the bankswitch cache, a similarly implemented palette cache, the rom itself, and the vram).
So, a bankswitch, or a change to the mirror bits, triggers a call to UpdateBankSwitchCache, which pushes the current banks onto the stack. To cut down on redundancy, I decided to only to process a mirroring change, if the new mirroring was different (for a explanation of NES mirroring see the nesdev wiki). Well, the NES nerds might already see what I did wrong. if (this.mirroring != mirroring) is not enough. For one-screen mirroring, the location of the screen is also important. To me, this makes if (this.mirroring != mirroring && this.oneScreenOffset != oneScreenOffset).
So, the moral of the story, is make sure you are taking a step back and considering *all* pertinent variables before you optimize something. I'm also guilty of premature optimization, as the bankswitch cache is as of yet in no danger of overflowing. Theoretically, there could be thousands of bankswitches during a frame, it's up to the cart and mapper. Realistically, it's very unlikely, at least on conventional mappers in commercial carts.
So TMNT and others display just fine, once again. Happy turtlin'.
Update: Nah, the code that could have banskwitched a VROM into VRAM was incorrect, but unreachable in that mapper (Afterburner is the only game/cart/mapper that I know of that has nametables in rom only and bankswitches them). The code is a little bit complicated, because what I do is keep an array which holds the starting address for each 4k block of VROM, and bankswitching updates these pointers. To top that off, every time a bankswitch happens, this array is pushed onto the next level of a 2D array, the bankswitch cache, which holds every bankswitch that happened in a frame. I do this, because for the GPU version, I don't send pixels, but I send the information needed to draw the pixels (the current ppu status bytes, the bankswitch cache, a similarly implemented palette cache, the rom itself, and the vram).
So, a bankswitch, or a change to the mirror bits, triggers a call to UpdateBankSwitchCache, which pushes the current banks onto the stack. To cut down on redundancy, I decided to only to process a mirroring change, if the new mirroring was different (for a explanation of NES mirroring see the nesdev wiki). Well, the NES nerds might already see what I did wrong. if (this.mirroring != mirroring) is not enough. For one-screen mirroring, the location of the screen is also important. To me, this makes if (this.mirroring != mirroring && this.oneScreenOffset != oneScreenOffset).
So, the moral of the story, is make sure you are taking a step back and considering *all* pertinent variables before you optimize something. I'm also guilty of premature optimization, as the bankswitch cache is as of yet in no danger of overflowing. Theoretically, there could be thousands of bankswitches during a frame, it's up to the cart and mapper. Realistically, it's very unlikely, at least on conventional mappers in commercial carts.
So TMNT and others display just fine, once again. Happy turtlin'.
Monday, March 1, 2010
Silverlight, Binding, Notifications and Threads
It's always good practice to not do anything on the UI from anything but the thread it was created on, but with Silverlight it is law. This extends all the way to objects which implement INotifyPropertyChanged. If they are to raise the PropertyChanged event, they must raise it on the UI thread - or you have broken the law and go to jail without passing Go and collecting $200.
So, my solution is to make sure all my view models have a Dispatcher through which to send PropertyChanged events. This has to be bound when they are created, which makes the way I was resolving them from Unity a bit ugly - I must now register a Dispatcher instance in the unity container for it to be all good, or bind it later, when the view model is resolved.
Another rub is the lack of command binding in Silverlight, when it comes to reusing the view models I had already implemented for silverlight/gtkInstigator. I had stored my commands in a dictionary, and they were resolved through a value converter which would pull them out of the command dictionary by name. Well, for Silverlight, I am putting the command name into the Tag, and use the following code in the click handler:
Problems still to solve: refreshing the enabled/disabled statuses of my buttons, by watching for a PropertyChanged event with "Commands" as a parameter, then iterating through the commands dictionary and available buttons, and setting enabled/disabled to the return of CanExecute.
Passing parameters to commands is another problem which I've yet to have need to solve - all of my commands are simple parameterless actions, so far.
At least ICommand is there, and command binding will likely show up, so using the commanding pattern still makes a lot of sense, even if you have to roll up your sleeves.
So, my solution is to make sure all my view models have a Dispatcher through which to send PropertyChanged events. This has to be bound when they are created, which makes the way I was resolving them from Unity a bit ugly - I must now register a Dispatcher instance in the unity container for it to be all good, or bind it later, when the view model is resolved.
Dispatcher dispatcher;
public Dispatcher Dispatcher
{
get { return dispatcher; }
set { dispatcher = value; }
}
protected virtual void NotifyPropertyChanged(string propName)
{
if (PropertyChanged != null)
{
if (dispatcher != null)
{
dispatcher.BeginInvoke(new CommandExecuteHandler(SendProperty), propName);
}
}
}
void SendProperty(object prop)
{
string propName = prop as string;
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propName));
OnPropertyChanged(propName);
}Another rub is the lack of command binding in Silverlight, when it comes to reusing the view models I had already implemented for silverlight/gtkInstigator. I had stored my commands in a dictionary, and they were resolved through a value converter which would pull them out of the command dictionary by name. Well, for Silverlight, I am putting the command name into the Tag, and use the following code in the click handler:
private void Button_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var dc = DataContext as IViewModel;
if (button != null && dc != null)
{
if (dc.Commands.ContainsKey(button.Tag as string))
{
ICommandWrapper command = dc.Commands[button.Tag as string];
if (command.CanExecute(null))
{
command.Execute(null);
}
}
}
}Problems still to solve: refreshing the enabled/disabled statuses of my buttons, by watching for a PropertyChanged event with "Commands" as a parameter, then iterating through the commands dictionary and available buttons, and setting enabled/disabled to the return of CanExecute.
Passing parameters to commands is another problem which I've yet to have need to solve - all of my commands are simple parameterless actions, so far.
At least ICommand is there, and command binding will likely show up, so using the commanding pattern still makes a lot of sense, even if you have to roll up your sleeves.
Subscribe to:
Comments (Atom)