Wednesday, December 23, 2015

ImageColorCounter

While working on my game I needed to be able to see how many different colors there were in an image. I figured there were online tools to do such an easy task but everywhere I looked it either was inaccurate or didn't do what I wanted. So I went out and made a small app which counts the different colors used in an image as well as displays how many times each color was used.

Download: http://www.mediafire.com/download/ochli36xrsy4eq9/ImageColorCounter.exe

Usage: Drag image over application.

Source (VB.Net):

Saturday, December 5, 2015

Game Project

     For several months now I have been working on a project much different and much more interesting than any of my previous ones (in my opinion). It has been very challenging (probably because of the way I decided to do it) and presented many obstacles which I needed to over come. This project is essentially a game or more specifically a game engine (a very simple 2D game engine). I started this project about 2 to 3 years ago with the thought of making a Pokemon game just for friends and family to play. That project eventually saw a dark fate when I managed to mess up my computer and lost all my work regarding it. Jump forward a little bit and I have revived that project though it has been altered a bit. I changed it from GDI+ to DX. Got CPU usage from around 15 to 20 percent (8 threaded CPU) down to less than 1 (depending on configuration used). While I still do plan on making a Pokemon game for friends and family I have been working on a type of fighting game as that has presented me the most challenge. The Pokemon game will most likely be my second project relating to games and will most definitely recycle the work done on the fighting game. There are several other features and updates that I have presented since my initial version which was lost but I don't feel they are interesting nor important enough to mention.

     Typically because I do not know if this project will ever amount to anything (or ever completed) I refrained from posting this on here and instead posted updates on my Facebook but I have recently been kicked out and unable to use my Facebook account (because I refused to use my real name nor do I plan on giving it to them). To continue posting updates I will have to resort to posting on here.

     Updates will be posted in oldest last and latest first order. All updates will have a date attributed to them.

[System Tested]
CPU: Intel Core i7 2600K @3.411Ghz
RAM: 8GB DDR3 @ 1600Mhz
GPU: Nvidia GTX 680
SSD: PNY 240GB

[APR 22 2016]
Moving everything over to MonoGame. Will hopefully provide Windows and Linux versions.

[JAN 21 2016]
I have since made some addition/changes but haven't gotten around to posting until now. I have added a "ColorPalette Management System" and a "PixelData Management System" they are in place to eventually replace the current "Sprite Management System" but currently all three are present for testing and debugging. I have worked out how I want to go about storing game assets (graphics in particular and sounds). Sounds will be in AAC format as there are no royalties involved in the usage of AAC media (unlike MP3). Several other formats are supported but AAC is recommended for reasons stated. Graphics Assets will be stored in a custom format/scheme. The game will have "CPT" (Color Palette Table) files which represent the colors of a particular palette and then another format "PID" (Pixel Image Data) which contains the representation of each pixel in bytes. The images are restricted to an Indexed8 depth meaning each sprite can have up to 256 predefined colors (in the CPT file). The two formats are separate because some sprites may share the same palette in which case it makes sense to reuse a palette instead of making a redundant copy in memory. The idea came about when exploring the GIF animated image format. I added a SoftwareRenderOnly mode for whats it's worth. Finally I moved around some things to better organize the project and workflow.

[JAN 12 2016]
Fixed and optimized my XorUInteger and XorULong structures to use for the engine. They are attempts at cheat prevention (for the simpletons but I'm sure the pros will still get around it). It basically works as you would think the name implies. It XORs the value with a randomly generated token so that the exact value is never stored. It also comes with checks to make sure the token is valid and that the return value hasn't been tampered with.
Source XorUInteger: http://pastebin.com/UVY8feZK
Source XorULong: http://pastebin.com/NJdXe5Ay

[JAN 11 2016]
Added mouse tracking although it isn't complete. Will have to get mouse tracking to properly scale with the window (Right now it works properly when the window is it's native resolution but any smaller and the tracking goes whack).

[JAN 08 2016]
Added a bit to the audio manager. Its able to stop any instance of audio that has been played. During playback an Instance ID is returned and that ID is used to distinguish that audio instance from the rest. That same ID will be used to stop playback of that audio instance if that instance is still playing, if not nothing will happen. Instances start with ID 1, if an ID of 0 is obtained that means the audio instance failed to play (most likely due to missing audio from collection).

[JAN 06 2016]
Improved the fullscreen, now fullscreening from a maximized windowed to fullscreen works and unfullscreening goes back to maximized bordered if it was previously so. Maximizing from a normal boredered window also maximizes and unmaximizes back to a normal window. With the addition of the new GameTimer I found that resizing the window doesn't impact the game much and so I removed the bit where it blacks the screen and suspends the layout until resize has completed so now you can see the game being resized as you resize it. This also gives the plus effect that the game doesn't blacks out when you move the window around. I fixed a problem with the mouse cursor showing over the game when it was specified not to so not when you want to hide the mouse cursor it wont show up anymore. Deleted some unnecessary functions and cleaned up some variables.

[JAN 05 2016]
I implemented my new GameTimer which provides more accurate control over frame-rate which still provides the low CPU usage of the older GameTimer.
I added a third buffer to try and mitigate some stutter I see.
I also hope that this fixes the inconsistencies between FPS on Intel vs AMD machines but will need more testing.
Source for the new GameTimer can be found here: http://tizzyt-archive.blogspot.com/2015/10/ticktimer.html

OLD GameTimer ex:

NEW GameTimer ex:


[JAN 04 2016]
Game now knows when its in focus or not so to grab inputs or not. Changed a bit of the rendering logic so it doesn't have draw queues (was made irrelevant with the buffers but forgot to take it out).

[DEC 30 2015]
Implemented my sound system. I haven't done too much testing but I know that it works. Essentially it is just my previous sound engine code I made a while back. It can do multiple instances of sounds and so a bunch of sound effects going at once shouldn't be a problem. The loading method is similar to the loading method I use for loading graphic assets. What to work on next I wonder.

[DEC 26 2015]
In addition to scaling I have implemented full screen. Full screen is mapped to F11. I might change it to Alt-Enter sometime later.

[DEC 23 2015]
Messing around with different image formats again and I think I will settle for the old fashion GIF format (or more accurately some of its concepts). GIF has a maximum color palette of 256 colors and so each pixel only takes one byte to represent a color. With about 3000 character sprites loaded into memory I figure that will be about a little over 1GB of memory. Of course this is excluding other things like background and effects as well as sound and game logic but I think its much more manageable now memory-wise. I played a bit with vectors and while memory becomes no longer an issue with simple sprites the more complex ones (ones with many angles) seem to be about the same or in some cases worst (though sprites looked so crisp and sharp, its a shame I couldn't use them). I might still use vectors for some things (large but simple effects) but not sure yet, but surprisingly vectors are pretty resource hungry (because they have to be calculated each time where as with an image it only needs to be drawn I figure).

[DEC 22 2015]
After scaling was implemented I had to center the view port but doing so revealed that everything would render to the edges of the window. I went ahead and implemented a constraint on the view port effectively creating a letterbox effect that has the same aspect ratio as the render resolution.
Ex (16:9 ratio):



[DEC 21 2015]
Got to implement scaling so now changing the size of the window wont crop or letterbox anything, instead everything is scaled up/down relative to the window and internal rendering resolution.

[DEC 13 2015]
Finished/Fixed dead zone correction for EZPAD. Download and source updated below.
Changed a couple things in terms of graphics.
Found a weird behavior where a frame sometimes drew an image out of place and of unspecified size, fixed it by having 2 buffers instead of one (buffer isn't used here in the normal sense of back buffers).

[DEC 12 2015]
Decided to redo the XInput lib for ease of use, flexibility and usage more straight forward.
New one is called EZPAD, Download and source is provided below (VB.NET).
Usage:
     Imports EZPAD
     Dim NewGamePad As New EZPAD(PLAYER.ONE)
     NewGamePad.UPDATE_STATE()
Download: http://www.mediafire.com/download/5hfp8k9h4jb7fx7/EZPAD.dll
Source: http://pastebin.com/kPMtLLy6
Old XPadMonitor Source: http://pastebin.com/m9r0cmGa

Sunday, October 18, 2015

Millisecond Timer

   So a while back I discovered that windows can't do microsecond accurate timers (at least not in a straight forward way). Windows is not real time operating system so events are triggered differently for different computers. There are ways like the MicroLib I found on the internet a while back but it is very resource hungry using up almost 100 percent of one of my cores. This is because it is essentially polling a stopwatch and seeing if the number of ticks is equal to or greater than the specified Tick which is calculated per computer. I have tried to modify it to be less resource hungry but my attempts failed. I recently found some code which utilizes the windows multimedia api to achieve a more accurate millisecond but it was only accurate down to the millisecond and cant achieve for example 16.7 milliseconds. I then thought hey I can put the two together. This millisecond timer can achieve closer to the specified millisecond like 16.7ms which is the duration of a frame in a 60FPS game. Now this isn't perfect but I'd think this is as good as it gets (for me its exactly what I needed). If there are better methods/alternatives please comment or if you have any suggestions or improvements.

[UPDATE JAN 05 2016]
I got around to redoing my GameTimer. The previous one was very inaccurate. For example I would specify 240FPS but it would give me ~230FPS and when specifying some other rates it is also all over the place. This new one addresses those as well as keeping all the features of the old one.

Source (VB.NET):

Sunday, September 6, 2015

Transparent JPG

[Update 8] A new and improved version is out, located here:
TransparentJPG 2

[Update 7] TransparentJPG.Dll quality default is now 80 and smoothing default is now 20. Progressive mode for the JpegEncoder is enabled potentially resulting in smaller file sizes. TransparentJPG has an added parameter for subsampling detail level. Options are 0 low (Default), 1 (medium), 2 (High). 2TJPG.exe has the added parameter as well.

[Revert 1] Changed back to using the LibJpeg.Dll. Smoothing is available again. Updated source below as well as the TransparentJPG.zip download and Latest Builds. The source for the version that is not reliant on LibJpeg.Dll will still be provided for reference.

[UPDATE 6] Removed the dependency for the LibJpeg.Dll which means that smoothing feature which helped save some space is now gone :( . I did so because I was given a 6Kx4K image to convert to TJPG and the converter (2TJPG.exe) kept crashing. I debugged it and found that LibJpeg was the problem. I am guessing that lib doesn't support images with such large resolutions? Either way I had to address the issue so I went and resorted to using Microsoft's built in encoder. It is slightly faster now due to not implementing the smoothing feature but file sizes will be slightly larger. The TransparentJPG.zip below has also been updated and contains (2TJPG.exe, TJPGviewer.exe, TransparentJPG.Dll). So essentially encoding will be different but decoding stays the same. The converter has also been updated in that it no longer supports the "Smoothing" parameter.

[UPDATE 5] Changed the color of the background squares of TJPGviewer.exe to a lighter shade(Grey) as well as made them 3x3 instead of 4x4 making them look less obtrusive.

[UPDATE 4] Optimized the code for saving TJPGs as well as removed all dependencies to LockBitmap.Dll(Removed from package). Also removed the CType to Byte() since it seemed redundant to the Decode method. Also provided SRC to TransparentJPG.DLL below.

[UPDATE 3] Changed the default values for conversion tool to quality=75 and smoothing=25. Also added a Decode method in TransparentJPG.Dll to get the pixel data, width and height of TJPG file. Also cleaned up the LoadTJPG function so that it doesn't rely on the LockBitmap.Dll though other things still need it, I will get to them soon.

[UPDATE 2] Fixed an issue with the converter (2TJPG.exe) where it would error and crash when given file paths that are valid and saying they aren't. Fixed version is provided in the "Latest Builds" link below.

[UPDATE 1] Added averaging when applying the mask to make the other bits of the alpha "useful" as well as provide a bit of compensation for rounding errors that jpeg compression might have. This has no impact on the encoding and only the decoding so file sizes are not affected though there is technically an impact on the resulting image visually it isn't noticeable and so negligible.
Moved all newer builds to a new location so people can grab this independent of the package I provided below:
Latest Builds: https://www.mediafire.com/folder/o2r7is9fsb279/Latest_Build
TransparentJPG: https://www.mediafire.com/folder/kjqpmfazac24c/TransparentJPG

     While working on my game I needed a way to import images and in my game people can share these images among each other via P2P. These images are almost always going to be grouped with tens if not hundreds, if not thousands of other images so I needed to pick an image file that is small in size. My next requirement was that the images needed to have transparency as a capability. Jpeg while small in size isn't capable of transparency. PNG has transparency but is much larger in size due to it being a lossless format. Another requirement was it needed to be compatible, I needed to work with an already existing format that most computers already know how to use so it wouldn't add time and complexity over compatibility. There exists much better solutions today but they are all either proprietary or there are no libs for them in use for .net which I need.

     I first thought hey I'll just take the pixel data from an image and limit it to 6 bits per channel then compress the whole thing which gave rise to a format I called TZI. While TZI proved to be a more acceptable format to my game than PNG I thought why don't I try a lossy attempt.

     I looked at Jpeg and I already knew the complexity behind its compression so I wasn't going to mess with the inner workings of Jpeg. Instead I thought of a hack about way to add transparency as another level on top of Jpeg. I did this by simply creating a mask via the images Alpha channel. I then removed all transparency from the image. The mask was then appended under the original image (with the alpha turned off). What you get then is an image with no transparency on top and a greyscale image of the Alpha channel on the bottom. I couldn't stop there, people randomly running into this image and viewing it as a typical Jpeg would be confused and the image shown isn't even in its intended form. And so I had to change its header so that people don't mix it with Jpeg files (even though this is essentially what this is). To reconstruct the original intended image I made an application which views the TransparentJPG files.

     The image is loaded in memory. The alpha mask is applied and then the image is essentially cropped to half its height. There is actually more detailed aspects going on behind the scenes and the workings is a bit different from how I explained it but I figure just a gist of how it works is good enough and easier to understand.

Code (VB.Net):


Code-not LibJpeg.Dll reliant (VB.Net):


Converter and Viewer Tools: http://www.mediafire.com/download/2p3tkx4yty2d0ai/TransparentJPG.zip

Samples: https://www.mediafire.com/folder/n0p76oq8p1t0v/Samples



Now because of the added height as well as the transparency bit the images will never be smaller than their original non-transparent JPG version (with the same quality etc).

    Here is an exact representation of an image with its header unchanged after the mask has been generated:


    Intended Image:


    Here is another example of how the images are encoded without the header change:


    Intended Image:

Friday, August 14, 2015

BitList

[UPDATE 3] Removed the unnecessary function ClearBits() and its calls to result in >3x performance increase on adding bits (benchmark times updated).

[UPDATE 2] Changed out arithmetic operators for bit-wise operators as well as omitting the use of Math.Floor for a result of ~20 percent speed increase in setting bits (benchmark times updated).

[UPDATE 1] Fixed a bug where the 8th bit added is always set to True(1).

I previously made a class called TBitArray with the purpose of storing individual bits. At the time I didn't know that .Net already had a BitArray class which I could use so I made mine. I then thought well if I have an array I might as well make a list version as well. At the time I never got around to it. Then time passed and I started work on my encoding schemes. I needed to store bits that would resize as needed but I was lazy and instead stored each bit as a byte (yeah waste of space I know). This time I am working on a potential image format for my game. For this format everything is encoded and decode by bits and so again I needed something that would resize as needed. This time though I actually got to working on it. I know that one can resize the BitArray that is built into .Net but I did some benchmarks and well its VERY slow. So with speed and dynamic size in mind I set out to create a BitList class to make my life easier for this and potentially future projects. And I am sharing it here for those who may want to use it. I will provide the benchmarks first to show the difference. If anyone has any suggestions please leave a comment :)


As you can see BitList is much faster at adding bits when size is unknown and where size needs to be changed dynamically.
If you know exactly the number of bits needed please use the built in BitArray instead as you can see it is much faster at setting bits.

This class was made for my purpose of adding bits and not the constant manipulation of bits in memory. So if you need to constantly add bits this might be for you. The bit manipulation implemented is only for light use as it is slower than bit manipulation with BitArray, though slow it is still reasonably fast. Just use it where appropriate is all I'm saying.

Note: This class only implements the functionality that I myself needed, it does not provide other functionality that a typical List(Of T) has. If you need them you may implement them yourself or I might add this when my needs apply. I guess this is much closer the a queue then a list but too lazy to rename it lol. I could have also used a BitArray to store the lookup table but anyone who wants to do that is free to.

Code (VB.Net):

Saturday, August 8, 2015

Agar.io with keyboard support

So my little brother's friend found this 'mod' for Agar.io that allows one to play the game via the keyboard but he didn't know how to use it. I took a look and it linked to some survey site which automatically if anyone knew anything about these things online and running into surveys etc... its all crap. So instead I decided to make an app that allows one to play Agar.io with keyboard.

Download: http://www.mediafire.com/download/a36m97k2qaarmag/Agar.io_Key.exe

Info: made in .NET via VB. Uses E, S, D, F for movement, and R to enable/disable keyboard movement support (and shows/hides the mouse cursor).

Saturday, August 1, 2015

Cleaning up a Yamaha PSR-310 keyboard

So I recently got a used keyboard because I wanted to learn piano eventually. The one I got was very dirty and there were scratch marks, the keys were stiff as well as stuck, and the lowest C key didn't even work. I thought hey lets clean this up and thus started my overnight project (started at ~12:30AM).

First I had to disassemble the keyboard of course:



The thing was nasty inside:



Is that semen?

There was a bit of rust


So I got to sanding



The membrane was nasty as all hell, cleaned it with a dirty shirt, I think it has to go in the trash now


SOOOO much better :)


Rubber pads are nice and clean as well

Now to get to the keys



As you can see its pretty nasty on the outside too



Black keys are cleaned though still wet


Put the membrane back into the keypad frame


Placed the rubber pads on aswell

Now to address the original issue, Time for some lube

Lubed highest key and first key pair and assembled

Onto the second

Third

Forth

Last

Finally placed the key assembly back into the keyboard enclosure

Consequently the lowest C key now works AWESOME lol. Completed ~5:30 AM.

I used soap, bleach, and alcohol as cleaning solutions.
Cotton swabs for fine cleaning and lubricating.
Regret using toilet paper to clean, as well as using my dirty shirt.

Thursday, May 28, 2015

[Release] JSXviewer 0.5b source

I don't know if I will ever get back to this but I decided that the program should be open a while back. It didn't really get that much attention and no one looked into improving/changing/rewriting/finishing/etc it. So I will post here in case people didn't know. The src is in VB.net and isn't commented as much as it should but here it is, do with it what you will lol.
Please if you have any suggestions or other feedback let me know in the comments.

Tuesday, April 21, 2015

[Planned] XwitchBot3

    Welp I haven't worked on/updated XwitchBot2 in forever but I do want to get back to it but I don't think anyone is using the plugin system to the extent I wanted, I don't think anyone besides myself has made any plugins for it. I don't plan on removing the plugin system or anything like that, if anything I want to expand it even more. I will be planning on potentially a third version of XwitchBot, one that is hopefully more polished then XwitchBot2. Now this is planned, whether or not it will ever be completed is another matter completely as I will be working on this in private if/when I am. I just wanted to say that I have been thinking about how XwitchBot's development has been, or lack thereof and wanted to stop neglecting it lol.

    Of course every reversion of XwitchBot has had a GUI overhaul and I think XwitchBot3 will be no different in that it too will most likely get a GUI overhaul. I'm picturing something similar to steam's UI but its not concrete yet a concept. There are other features that I think will benefit XwitchBot like possibly implementing some form of scripting. I don't know if I will be using an already available language or Frankenstein my own if I do plan on implementing one, of course implementing an existing one sounds much more practical.

    While this will be a reversion many aspects will be reused from XwitchBot2 just like how many aspects of XwitchBot2 were from XwitchBot. Things like I said the plugin system are there to stay, and the TwitchAPI from XwitchBot2 will still play a big part. I don't know what this blog post will ultimately amount to if anything but it's just ideas that I have been thinking about and of course if this comes to fruition XwitchBot3 is free, and will always be free like its always been.

UPDATE 8: Just another screenshot after fixing some UI alignments with some actual channels


UPDATE 7: Worked on the UI for each channel, some things are working now, still need to move several things around and implement others. Added donate button and home button that will eventually link to XwitchBot3 page but here is what it looks like so far:


UPDATE 6: Redoing the UI. It will be similar to XwitchBot2 versions but with adjustments to accommodate the new features. It isn't complete but much has been done. Currently it can connect to Twitch, Login using OAuth, Join channels. It cannot display messages or send them yet.


UPDATE 5: Got multichannel fully implemented and working, it also keeps track of the users in each channel. Added several MessageTypes for ease of plugin creation. Added proper parsing of initial twitch userlist (irc 353) and also added a type to tell the bot when the userlist ends (irc 366). Bot can only see registered users in the chat so the number of people shown on the bot vs the number of people on the stream will differ. Added MessageType (irc 421) for unknown commands so the bot notifies the user of any mishaps. Added parsing for originating channel of a message because the bot now has to keep track of messages from multiple channels. I will be implementing the ACTION aka /me MessageType and also the Points system as well as the AccessLevel system (differently levels have permissions to do different things). I also plan on slightly modifying the UI but only slightly since V2 UI is good enough.

UPDATE 4: Worked a bit on the YoutubeRequest class again. Added a bit more of the iframe API, I don't think ill add anymore of the API. Added a check for songs that don't start. Once a song is set to be played, and failed to start playing within 5 seconds the song will be skipped and the next song will be set to play. The duration to wait and see if the song starts can be changed (in milliseconds) in the constructor. There are 2 added events to the YoutubeRequest class. A polling event which presents the player's status such as song duration in seconds, the percentage of the song thats been buffered, the current position in seconds of the song, if the video is muted, and the current song's volume, as well as the current players state (is it playing, paused, etc), this polling is triggered every half second.

UPDATE 3: Well I will be changing some changes from UPDATE 2. In UPDATE 2 I planned on having the IRCclient be able to have multiple instances meaning each IRCclient establishes its own connection to the twitch server. I originally thought that because twitch's IRC is broken it couldn't join different channels through just one connection. From the website each tab I'd imagine creates a new connection and so I went to do it that way. Today though I remember a few of my friends who use HexChat to connect to twitch chat and I think I remembered them saying they can connect to different channels and so I went and tested. I can indeed connect to different and multiple channels. So I will be changing the bot in that respect. There will only be one instance of the IRC client again but It will be modified to handle multiple channels. I have also improved the message buffers and made the Message Structure simpler. The UserList is now moved inside of the IRCclient Class (it cant manage multiple channels yet, but will get to it). Because the PONG reply to PINGs is always the same (PONG :tmi.twitch.tv) I made it so that it replies only that and removed all parsing of the PING messages. When a PING is received a predefined byte array containing (PONG :tmi.twitch.tv) will be sent. Added more exception handling. Date/Time of messages in timestamps are set when the messages are received compared to previously where the Date/Time were set when the message was displayed in the chat. Sent message structure also has Date/Time now instead of setting the time when the message is displayed (this might be more accurate but timestamps might be out of order when displayed, I might change it back to how it was depending on how it turns out).

UPDATE 2: Reworking the core of the bot today. I made the IRCclient for the bot more robust. Put the message formatter (made because twitch's IRC protocol is broke as all hell) inside of the IRCclient class so that each instance of the IRCclient has its own formatter. Put the received message buffer and sending message buffers inside of the IRCclient class so that each IRCclient instance has its own buffers for the ability for multiple instances of an IRCclient (for multiple connections ex: connecting to multiple channels). Each IRCclient instance will have their own configuration (Server, Port, Channel, Nick, OAuth, etc). UserList parsing will also be available to each IRCclient instance so that it doesn't bunch users from all channels. Going to be moving the IRCclient class to Core class so plugins can access the IRCclient class (instead of making their own, which is a waste of time). Added PONG priority which will hold off on sending normal message so that PINGs are replied with PONGs sooner than later. Will be making a base class for the plugins interface so instead of implementing the XBPlgn interface, you inherit the XBextension class (you can still implement the interface if you want). Will be adding a database to the core of XwitchBot to keep records of things for the bot and for plugins as well (if needed). There will only be one instance of the database so that there is no conflicting records between plugins and the bot itself.

UPDATE 1: Worked on YouTubeRequest. Made a new class that implements more of the youtube player iframe API. It can play, pause, stop, seek, set volume, get duration and get the buffered percentage. I plan on reworking the plugin interface, and move the plugin system out of the bot and into the points system I will be implementing. The flow looks like this:
Messages>IRCclient>RecievedMessagesBuffer>PointsSystem>PluginSystem>Plugins
That way people can decide which plugins require points to use without programming each plugin to do so. I do plan on a UI overhaul but haven't yet thought of anything concrete.

Tuesday, March 10, 2015

Quick and Dirty .Net BigDecimal Implementation

[UPDATE 8] Added Conversion, Constructors, Comparisons, Operations for types Short, UShort, Byte, SByte.

[UPDATE 7] Added Ceiling, Floor, Truncate functions as well as fixed the Mod function. Added Ctype to/from byte arrays.
[TODO 3] Implement a BigDecimal rounding function that can round to a specified decimal place.

[UPDATE 6] Added a Random function which returns a random BigDecimal number with the specified number of significant digits.
[TODO 2] Fix modulus of negative numbers.

[UPDATE 5] Fixed constructors for Decimal, Double, and Single as arguments.

[UPDATE 4] Providing the new source code below.

[UPDATE 3] I rewrote the entire thing and improved the speed by ~5x to 10x. Removed all string manipulation hacks for calculations and added several other things for ease of use in code. I compiled it to a dll for ease of use.
Download: http://www.mediafire.com/download/yj56gd65616cu7v/BigDecimal.dll
Usage:
Reference the BigDecimal.Dll,
     "Import TizzyT"
     Optionally you can also "Import TizzyT.BigDecimal"
Ex:
     Dim bigNumber as BigDecimal = "51316561513854163416165416163163165613.1473415424496255785965457458965348754854856"
          or
     Dim bigNumber as New BigDecimal("51316561513854163416165416163163165613.1473415424496255785965457458965348754854856")
The constructors accepts these types as the parameter:
String, BigInteger, Decimal, Double, Integer, Long, Single, UInteger, ULong.
Supported Operators: /, *, -, +, ^, Mod, =, <, >, <=, >=, <>
There are no BitWise operators.

[TODO 1] Add e constant calculation function and Phi calculation function. Add pre-calculated values to the first 65535 digits for Pi and e (and other constants in the future) for fast lookup and only calculating when needed. Fix potential rounding issue in the divide function. Support parsing and simple calculations with imaginary numbers. Raising to decimal powers.

[UPDATE 2] Added Pi function which (calculates Pi to the specified decimal place).

[UPDATE 1] Added square root function (calculates the square root to a specified decimal place).

    Now many of us I'm sure have gone to Wolfram Alpha and have done some calculations and get very precise answers. I thought why cant I just make a calculator that runs on the computer instead of relying on a website. The problem here is that I typically write in .Net and as far as I know in .Net there isn't yet a BigDecimal implementation though I hear something called Rational Number will be in the future (correct me if I'm wrong). .Net as of 4.5 does include BigInteger though and I figured "hey I can surely manipulate that to do decimals". So by playing with powers of 10 and some string manipulation I threw together this quick and dirty BigDecimal implementation. It does most of the basic arithmetic operations (add, subtract, multiply, divide) and also includes modulus and a limited power operator (only decimals to integer powers allowed).
It also has most of the basic comparison operators (=,<>,>,<,>=,<=).

     I didn't implement a way to do powers (exponents) of decimal numbers to decimal numbers as I don't know of any way to do arithmetic that are to the power of a decimal number. This is one of many things Wolfram Alpha and other tools are still useful for. I did however add a power operator where you can raise a decimal number to an integer power. Again this was a quick and dirty implementation by use of an already existing BigInteger and some string manipulation so this is more of a workaround then a full and proper implementation. With all that said this works as it is intended and I just thought I'd share this for those who want to have such capabilities and/or not want to make their own or use one that others have made (for what ever reason). Below is the source in VB.net, feel free to critique it constructively or even suggest improvements/additions/corrections/other changes (they are always welcome) in the comments, even link to other/better implementations for others to learn from (including myself lol).

     Here is a brief and simplified explanation of how the operators work (take note of the number of digits after the decimal places, trailing zeros after the decimal are omitted).
How Addition is done:
     ex: 2.5 + 3.56
     250 + 356 = 606
     606 * 10^-2 = 6.06
How Subtraction is done:
     ex: 3.56 - 2.5
     356 - 250 = 106
     106 * 10^-2 = 1.06
How Mulitplication is done:
     ex: 1.23 * 2.34
     123 * 234 = 28782
     28782 * 10^-4 = 2.8782
How Division is done:
     ex: 2.75 / 1.23
     27500 / 123 = 223.5772...
     223.5772... * 10^-2 = 2.235772...
How Modulus is done:
     ex: 81.913 mod 1.89
     81913 mod 1890 = 643
     643 * 10^-3 = 0.643
How Powers is done:
     ex: 3.86 ^ 3
     386 ^ 3 = 57512456
     57512456 * 10^(-2 * 3) = 57.512456

Here is an example of what this BigDecimal can do:
-29904881154799326178521321561318483083459729644316160000768321084631624262879277725524837232512874501269189723158150646979348274909576646634501407346213852282090571467140400147783_._18387956244635430200491958026044099076018957040468456891742982019954636328243381756769819732303584718583212854736122624014489392565966217355695509628096970419381029887990526931898967457998680807367672273756904951032467189830062966412679369009462886580958333279494754935309708946817547646334519060461784118024038735185710860189063748402342861130577
*
5751924938051280223833858629501675273310948056012555014190229443738691691398479261795665007308040432731195362671005864806268338234894643060929333520217662547275713887745280398692580701613219578511545688593727384579400216343571287604699210898682409901033923592254977998928042776007128567167661764461451197309014749502640082135628831465593026815282225172036806167117327391851426784340266832879686969785482431161011282785148552226455709885783477185740418454692010461531139699177137747603724519366291555351081827755537285870661022388558239662190786473991577468995843919739761368997465938707076067624686764323911947153991511165379474331079151578602891362316550805454661607383094255347700102452925611494129497831220455765356914545838285121830226022147084604811_._485209203433392412988139774358020034502772971469229293225542494540235780020626731513983670906928733123343

Wolfram Alpha would show:


This will give:
-172010631683750011631176079635100632512013244572007775432003052061741528932456706083001536611193096484622166575907367022582529375403056568752074822302755095141705749035603368873993087184637206623936125077741562315269979582630307542103138837485919587574525593555179880851697392546867297871962651246670873381798031600455987658621905814271481025010371299023464068557582075120843141692643569603040719610403883441172974614752898206095324363859673141540896718756076235625588707331308369632854757249392548068974677743079393957197900647731970295656741222088267367125066341257683453363029468157717943954078353804877795513312209888179482890880751242235524454941490185521697979596299416656404943757921088267838665435536479783956085537537344245358014725997793150006008217624566831017875248663228026355877838648274813511813170883984822985170888041944419334079113344858945397015576199007001645366831336899975261719765525043062998876285207094159601_._64451178007533823634375369013823879310973576406237333385810760066596575526779234269950974308196349757681037340570364428921472113903604913391171361506598161298515062927800899848793991527144615663644225257812312313442943022512764968630618332043281176249948189766049626681715362863353932346845491296791798272977703881944317699353132567214725666489749891407117892159573738750826924897100577519286872165820424322663912528782448439048590873529321689369758911

New Source:


Old Source: http://pastebin.com/embed_js.php?i=jcNaUhuH

Free for non commercial use. All changes to source must be provide here.

Sunday, February 15, 2015

ExtensionBySignature

Here is a little app that will help rename files with the wrong or missing extension by getting its signature. You must know the signature before hand and the extension you wish to append to the file.

Download: http://www.mediafire.com/download/txac5cdc5a9tofh/ExtensionBySignature.exe

Instructions:
The program relies on a file called "sig.txt" to know what extensions and signatures to name and look for.
The format of the list is {extension}={signature}.
example for a .zip file: "zip=504B0304" without quotes.

Usage:
 ExtensionBySignature.exe [Input Directory(s)]
   or
 ExtensionBySignature.exe /n [Input Directory(s)]

Logging:
 Every session is saved in a log upon completion.

Arguments:
 /n , /N = NonDestructive mode (files will not be renamed but the log file will stay the same)

Note: Multiple input directories can be used, just make sure to space them from one each other and use quotes where appropriate. If a file already has an extension and the program is going to rename it, the new extension is appended to the end (keeping the old extension in the file name) for future reference in case knowledge of what the previous extension used is needed.

Source:

Wednesday, February 11, 2015

SysCommParser

Well here is something to kinda parse the syscon communication (not everything is parsed). It sorts out the packets and is able to output read and write operations to a file.
Apparently these dumps may contain the QA token and so be very careful with those files.

[UPDATE JAN 04 2015]
Zecoxao found some problems which I had to fix.
Link updated to v1.0.0.3.

[UPDATE JAN 04 2015]
Added parsing of commas (apparently the new logs use commas instead of ';').
Also added parsing of unlock instruction although not tested.
Download link updated with v1.0.0.1.

Download: http://www.mediafire.com/download/cc09aoxrglcbbpf/SysComParser.exe

PS: Brought about by zecoxao's request for the parser.

Tuesday, January 20, 2015

XMB Wave

     Here is a XMB wave video that I edited from the original to look a bit better (imo) and also to higher the resolution (1080). It might be used for video backgrounds or something, I just thought I'd leave it here.

Download: http://www.mediafire.com/watch/cbia0jcrpakpvk8/wave.avi


Here is the original to which I edited:


Differences:
1) This is the Blue XMB only.
2) The blue is more subtle than the one from the original video.
3) Made the sparkles smaller.
4) Wave is sharper.
5) Banding is corrected.

Thoughts about original video:
1) The video is a lower resolution then I would have liked.
2) The banding was pretty bad.
3) The video is not truly seamless but instead it kind of looks seamless (actually an overlay where 2 wave states are similar).
4) Bit rate was too low hindering the overall quality of the video (to be expected due to it being used for Dreamscene so I guess it's understandable).

Wednesday, January 7, 2015

Project Euler Problems

     The same friend of a friend that got me motivated to make the SudokuGen also showed me this website with these challenge problems and since I have nothing to do these days and am bored anyways, I thought I'd start solving them.