Pages

Thursday, March 22, 2012

A Congregate of Symmetry, Science and its Beauty

Hey Everyone,

Something I enjoy doing each day is thinking and contemplating reality. I have no qualifications in physiology or any major field of scientific research but I do have an advanced diploma in computer science as a programmer but even so, I do consider myself a scientist / theoretical physicist. All my perceptions and understandings of reality are self derived from my own perceptions and thoughts over the period of my life time. I strive for accuracy and refinement and I love learning new things and thinking about things I already know but in different ways, an introvert with a curious mind.

I went for a walk outside today and looked at the garden; I find beauty beyond just flowers, I see it in everything: the leaves, the structure of the plant or tree itself. I look up at the clouds, then back down to a stream of water and see a similar beauty. This innate yet subtle structure that many seem to overlook, the same structure that governs the way my brain forms a neural net, the way my veins grow to deliver blood to the rest of my body. Even in entropic systems where weathering effects the formations of the planets, all you need is a satellite with a camera or even a microscope and you'll see the same pattern of blood veins that I see in my arm. In all underlining systems that makes our universe form and yet derived from an elegantly simple iteration algorithm also known as a fractal.

Some people seem to want to find and preserve symmetry like an obsessive-compulsive disorder but usually just in a conventional way; like side by side in a mirror, but there's so much more to it than that. Circular symmetries exists like the splash of a rain drop as well as the notion of self-similarity where regardless of the position on a fractal, you'll see a similar pattern from your former position. Even if something doesn't appear symmetric, all you need to do is look a little closer or further away to find it.

As I was walking passed the spearmint I noticed it was starting to bloom. Normally a spearmint would be splitting leaves at 90 degree intervals; hence its iterative fractal structure but what intrigued me was the fact that the plant had changed the rule-set that founded that fractal in order to start growing flower buds. I'm not familiar with any articles on the subject but I'm sure there's one out there derived from the plants biological processors that result in this change but I was interested in how such biology and chemical reactions changed the fractal structure itself. I took some pictures so others could see the stages the plant was going through; each one at a different phase and some still making leaves, some making flowers as well as those in between.




(Edit) I'm now aware from a recent scientific article that plants / trees use molecular patterns that specify how different cells will stretch when a leaf grows which results in all the different leaf patterns, I'm guessing that all aspects of plant growth would derive from this pattern mechanism to facilitate the growth of stems and flowers too. Pretty amazing.

People say that science destroys the mystery which some people crave but that couldn't be further from the truth; Sci-Fi is one of the best mediums to date that spurs our imaginations and makes us think "there's so much more to discover, learn and to see what's possible" the so called thinking outside the box and that exact notion is why science is so wondrously exciting. The evidence is overwhelming as each and every day, new and wondrous things are being discovered, improved and devised that can help a huge number if not all institutions including our very lives and deepen our appreciation. New cures for cancers, better ways to make electricity; devices that can save Africa from poverty. I couldn't think of a more honest system than science, yes there's people who are dishonest who lie and make up fake science for money but real science doesn't lie, it will never let you down, it will always admit when it was wrong and seek out the answers. People imply that because of such scientific views that others like myself can't appreciate or understand what beauty is like they "apparently" can, lacking the aesthetics so to speak. I beg to differ; they fail to understand that not only can I see this beauty they speak of, but I can understand it in more ways than they could possibly imagine: thanks to science. To know why a flower is the colour you see, why the stem is green or red and why it smells so pleasing. Knowing these attributes of the flower feels like my appreciation and the beauty I see is amplified 10 fold. Science isn't cold or black and white, it's the reason you have colour TV, the reason you live a life at least 4 times that of your great great ancestors by creating life saving cures and not to mention the moments when medical scientists aka doctors and nurses spend over 15+ hours in a hospital operation room just to stabilize one person's life, the reason why I can see with my glasses and why I can fix something when it breaks, making my life and others around me so much better as a result. These people with such shallow perceptions might take science for granted but I am honoured and privileged to have science as a tool that I can wield to make this world a better place, to truly understand its beauty and to know implicitly why life and this earth I stand on is so precious.

The next time you want to be thankful for something, try thanking science and don't just wait for a "Special" day to do it either; for each day in your life is just as precious as the next.

Thank you for your time,
Ashton.

Monday, March 19, 2012

Tutorial - Dosbox Linear Scaler 4x and Greater

Hey Everyone,

I was just checking up on the status of a program called Dosbox to see how the development is going and started reading the forum, I noticed someone asking if additional linear scales could be added to the rendering context configuration. I actually did this myself when I needed the game to fit nicely on a 2560x1600 screen in window mode by modifying and recompiling the source code. So since I've done it before I decided I should write a nice "quickish" tutorial on how to do this for those who are curious or even have the same problem like I once had. Please note that this is only going to add additional ScaleNormal's; 2x, 3x, etc which doesn't include TV, RGB, Scan, HQ, Sai, Super, Advanced Mame or Interp. Also for those who are more familiar with programming and are comfortable with working out dependencies in your favourite IDE etc feel free to skip the steps and head straight to the code change section :)

Additionally someone has recently compiled a patch using this tutorial to add support for 4x, 5x and 6x which you can find at the DosBox Development Forum here: link :)

Please note that at the point of which I wrote this tutorial, Dosbox v0.74 was the latest revision so I can't promise this tutorial will still be accurate with additional future Dosbox updates and changes to the VGA scaler code. If this is the case then I will take a look at the changes and if possible, I'll make a new tutorial in the future :)

The first step is to obtain the source code, you can either download the latest stable build from here or you could download a subversion aggregation program to obtain the latest up to date version of the code, the one I use is called Tortoise SVN which you can download from here. Once you have that you can download the latest SVN repository of Dosbox by copying and pasting this link into your subversion's checkout process:

https://dosbox.svn.sourceforge.net/svnroot/dosbox/dosbox/trunk

The second step once you've downloaded the source code into your desired directory you'll need an editor for modifying the source code, I believe Dosbox supports a few including make files. Since I use the Windows operating system I like to edit code using Microsoft's visual studio which you can download the express version for free from here, the source code is written in C++ so I've linked the 2010 C++ Express edition.

The third step is to load the project into your editor, for those using visual studio they have provided an .sln project file that you can open in the editor, you can find this in "SVNFolder\dosbox\trunk\visualc_net". You may need to convert the project file to 2010 due to the project being built from an older visual studio version but the code will still work fine in 2010 after you convert it; Visual Studio will provide a window that will take you through the conversion process while also giving the option to backup the code in case the conversion fails.

The fourth step will be getting the code to compile without build errors; for the purposes of the tutorial and to make things easier I'll be omitting the screenshot ability as well as the debugging system of Dosbox so the code will compile with less hassle. First things first, create a folder for placing everything in; well need to download some dependencies for the Dosbox rendering context and networking subsystem. First you'll need to download SDL from here, at the bottom of the page where it says development libraries click on the appropriate file for your IDE and download it to your new folder. Second you'll need to download SDL_Net from here where it says binaries; download the appropriate developer package for your operating system, they'll contain "devel" in their names and download it to your new folder as well.

Extract both packages to their own folder and then decide where you'd like your global dependencies to exist for future projects like "C:\API Dependencies" or something like that so you have a nice place to put everything. Create two folders inside; one called SDL and the other SDL_Net, once you've done that open the SDL folder you extracted and drag and drop the include and lib folders to your new SDL API Dependencies folder. Then do the same for SDL_Net from your extraction folder to the dependencies SDL_Net folder.

Ok time to modify the Dosbox project settings so it knows where these files are and allow it to compile happily. Make sure you have the project open in Visual Studio 2010, you can optionally set the project to either debug mode or release mode; release being more efficient and result in a smaller exe file but remember that all these settings you are about to change will have to be done again for debug. Please note that release mode will take longer to compile due to additional code optimizations but the program will run a lot smoother as a result, after choosing that you can either hit Alt+F7 or go up to the top menu under "Project" and click on "Dosbox Properties" which will open the project settings dialogue. Click on "VC++ Directories", then click on "Include Directories" and an arrow will appear to the right side of the text area, click that and then click edit (I have no idea why the interface is like this so bare with it). After you do that you'll see a small window open up called "Include Directories", go back to your API Dependencies folder and locate the include folder for SDL and copy the directories path and then go back to the "Include Directories" window, double click on the white space or click the new path button and paste your SDL directory into it. Do the same for SDL_Net and then hit ok to close the window.

Further down the list you'll see another list called "Library Directories", this time you need to copy and paste the "Lib" folder directories of both SDL and SDL_Net into the libraries window then hit ok. So far so good, now on the right panel of your project settings you'll see something called "Linker", click this and then open up the "Additional Dependencies" list like you did with the include and library lists. Remove the references to "zlib.lib", "libpng.lib" and "curses.lib" then hit ok, this will remove the dependencies for the screenshot and debugging systems; you can add this back later if your willing to compile libpng and zlib yourself since Dosbox doesn't come with them, probably due to licensing or something and what's worse is some dependency developers don't even provide binaries or libraries so you can avoid compiling manually.

To finalise the removal of all external dependencies you'll need to open the "config.h" file located under "Source Files/visualc" and make sure both "C_DEBUG" and "C_SSHOT" are set to zero next to them. If you compile the code you should be left with one last error informing you that it can not find "afxres.h" which for some reason the express addition of visual studio doesn't come packaged with, to fix this last error double click on the error about the missing file and it will open the "winres.rc" file showing the include statement trying to find the missing header file, replace that line with this code section:

#include <Windows.h>

Ok with any luck you should have a compiled version of Dosbox, just make sure that when you place the exe outside of the IDE's compile folder to make sure you put both "SDL.dll" and "SDL_net.dll" which you can find inside the dependencies lib folder under x86 with it, otherwise it will crash. You should take note when you run the program that there's a reference to the config file that allows you to change Dosbox's settings written on the console that's unique for this SVN Build located at "C:\Users\Your Name\AppData\Local\DOSBox\dosbox-SVN.conf" for Windows 7 but write down where it says for your computer so you can change the settings later.

Code Change Section

Alrighty, now that we can run Dosbox from its source code we can begin to implement some upgrades for the VGA linear scaling system. First things first we must create a new definition for our new scaler type; under "Source Files/gui" you will find a header file called "render_scalers.h", open it and scroll down to the bottom. You should see this

extern ScalerSimpleBlock_t ScaleNormal2x;
extern ScalerSimpleBlock_t ScaleNormal3x;

Add this line just after them at whatever scale you desire:

extern ScalerSimpleBlock_t ScaleNormal4x;

In this case I'll be adding a 4x linear scaler. Now Open the file "render.cpp" under the gui folder and scroll down to line 291, you should see this:

if ( render.scale.size == 2 )
       simpleBlock = &ScaleNormal2x
else if ( render.scale.size == 3 )
       simpleBlock = &ScaleNormal3x;
else
       simpleBlock = &ScaleNormal1x;

Append your scaler as an additional else if line like this:

else if ( render.scale.size == 4 )
       simpleBlock = &ScaleNormal4x;

Scroll down to line 600 and add this:

else if (scaler == "normal4x") { render.scale.op = scalerOpNormal;render.scale.size = 4; }

Ok, now open up "render_templates.h" in the gui folder, then scroll down to line 241. Add this after the Normal3x's definition:

#define SCALERNAME        Normal4x
#define SCALERWIDTH        4
#define SCALERHEIGHT    4
#define SCALERFUNC                                \
    line0[0] = P;                                \
    line0[1] = P;                                \
    line0[2] = P;                                \
    line0[3] = P;                                \
    line1[0] = P;                                \
    line1[1] = P;                                \
    line1[2] = P;                                \
    line1[3] = P;                                \
    line2[0] = P;                                \
    line2[1] = P;                                \
    line2[2] = P;                                \
    line2[3] = P;                                \
    line3[0] = P;                                \
    line3[1] = P;                                \
    line3[2] = P;                                \
    line3[3] = P; 
#include "render_simple.h"
#undef SCALERNAME
#undef SCALERWIDTH
#undef SCALERHEIGHT
#undef SCALERFUNC

Alright, now we need to declare our scaler; open up "render_scalers.cpp" under gui and scroll down to line 242. Here you can see the definitions for the linear scalers, append this code after the definition of "ScaleNormal3x":

ScalerSimpleBlock_t ScaleNormal4x = {
    "Normal4x",
    GFX_CAN_8|GFX_CAN_15|GFX_CAN_16|GFX_CAN_32,
    4,4,{
{    Normal4x_8_8_L,        Normal4x_8_15_L ,    Normal4x_8_16_L ,    Normal4x_8_32_L },
{                 0,        Normal4x_15_15_L,    Normal4x_15_16_L,    Normal4x_15_32_L},
{                 0,        Normal4x_16_15_L,    Normal4x_16_16_L,    Normal4x_16_32_L},
{                 0,        Normal4x_32_15_L,    Normal4x_32_16_L,    Normal4x_32_32_L},
{    Normal4x_8_8_L,        Normal4x_9_15_L ,    Normal4x_9_16_L ,    Normal4x_9_32_L }
},{
{    Normal4x_8_8_R,        Normal4x_8_15_R ,    Normal4x_8_16_R ,    Normal4x_8_32_R },
{                 0,        Normal4x_15_15_R,    Normal4x_15_16_R,    Normal4x_15_32_R},
{                 0,        Normal4x_16_15_R,    Normal4x_16_16_R,    Normal4x_16_32_R},
{                 0,        Normal4x_32_15_R,    Normal4x_32_16_R,    Normal4x_32_32_R},
{    Normal4x_8_8_R,        Normal4x_9_15_R ,    Normal4x_9_16_R ,    Normal4x_9_32_R }
}};

Ok, now inside "render_simple.h" in the gui folder which in my case seems to be excluded for some reason. You can find it inside the SVN directory's gui folder manually, just drag and drop it into your IDE editor; feel free to add it to your "Source Files/gui" folder so you can always access it later. Now you can scroll down to line 68 and append this:

#if (SCALERHEIGHT > 3)
            PTYPE *line3 = WC[2];
#endif

This after line 79:

#if (SCALERHEIGHT > 3)
        PTYPE *line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
#endif

This after line 97:

#if (SCALERHEIGHT > 3)
                line3 += SCALERWIDTH;
#endif

Finally this after line 109:

#if (SCALERHEIGHT > 3)
            BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*3,WC[2], copyLen );
#endif

To use your new scaler as an available option, you can open up "dosbox.cpp" and go to line 389 where you can add this:

const char *scalers[] = {
        "none", "normal2x", "normal3x", "normal4x" 

Now compile the code and you'll be able to specify the "Normal4x" setting inside the Dosbox.conf file and your game should render larger than the 3x multiplier. If you would like the config file to show your scaler as an available option in the comments you'll need to delete the old config file first as this change will only effect the config when it's created by default; when one hasn't been found in the AppData directory.

And that's it! I hope this wasn't too much of a headache for people and that you enjoyed the tutorial. Feel free to explore what the changes do and see if you can work out how to add even more scalers to your code :)

Thanks for reading,
Ashton.

Wednesday, March 14, 2012

Education Re-Think

Hey Everyone,

When I was growing up I had a really hard time getting to my classes due to being sick most of the time and I also had an underlying social anxiety which didn't help either. There were a few good teachers during the time I was there but there was a large number of them who didn't really care at all about me or my education and would usually assume I was faking it. The days when I was home I would watch all the science shows that were on TV and learn through a path I built for myself; that worked for me because I was learning things of my own interest and at my own pace. I remember the things I learnt to this day because the information was important to me and I cared about it. I can barely remember a thing from the school's educational process and most of my memories are from the traumatic events caused from the teachers or students; a good example was when I was in year six and the teacher had the class stay in waiting for me to answer a question about fractions that I hadn't learnt yet due to my absence, I just sat there feeling like shit while all the kids looked at each other and at me. It wasn't until one of the kids whispered the answer to me like 30mins later before he allowed the students to leave for lunch, not only that he basically hated me because I wasn't that much into sports but I also had medical reasons too; I had flat feet so my feet had no arch and in turn no support so whenever I did any running or sports my feet would kill me and it wasn't for another year or two before I even got orthotics for my shoes. This same teacher had the nerve to try and hold me back for another year; another year of hell with him as my teacher, thankfully my parents knew better and said no but they had to put up a fight. My parents actually called up during that year and asked for him to set up homework for me but apparently he had "enough on his plate than to worry about 1 student". Thankfully most of the majority of my teachers were really nice to me and did the best they could in the current system, I actually preferred talking to them than the students as I liked more mature conversation. I had further problems at high school; getting a condition similar to Osgood-Schlatter or at least that's what the doctor referred to it as but essentially I damaged a tendon somehow in my knee which prevented me from going up and down stairs due to the amount of pain I would get from it and not only ended up on crutches but I had to move schools to one that had an elevator too, but before I left I was an A+ student in both mathematics and mandarin. The elevator which periodically broke down, sometimes while I was inside it too caused havoc on my further education; usually ending up having me go home while they wrote up homework for me. The days when I could get to class I was so disconnected from the current learning path since the students were at an entirely different point, the teachers would get annoyed with me too and wonder why I was doing so bad getting D's which didn't help me one bit. The whole time I was doing the best I could but all I could think of was how much better I learned when I simply stayed home, researching stuff on the internet and reading topics that I actually cared about. The last year of high school I ended up getting placed in a room on the ground level that they called the GAP or "alternative program" room which was essentially built to harbour all the kids who get into detention so they could learn while not bothering the other students. I'd always giggle when they asked what I had done to be in the room since they found me quiet and always working on my education; not the properties of a kid who gets in trouble. What amazed me was how nice they were and friendly and I too wondered why they were in the GAP class; I knew they must have done something that put them in detention a lot but my instincts told me that they were the same victims of a system that failed me. I worked in that class like I was In heaven; it was quiet and I could hear my own thoughts, hear the birds and I worked so much each day that my hands were covered in pencil carbon and my mind swimming in mathematics that I did that same day. A room designed for the worst of the worst students; my peace and harmony. By the end of the year I was in the top 10 students of the entire school with around 14 A+'s and received a special medal for it too which I had no idea I was going to receive until I was asked to go up onto the stage with the others, a student that barely saw 2 and a half school days a week until GAP.

My path to this point has been so unnecessarily bumpy, demoralising and painful that I knew from all my experience what the fault was; the "modern" educational system. I have never seen a more disgraceful, screwed up and flawed system in my life, the brute force method, the blind targeting of education that doesn't even care about the likes and dislikes of each individual student. None of the stuff I have learned through school has helped me in life and it's only because of my self teaching method that I know anything at all or have a career.  My pathway to becoming a technical designer; aka an artistic programmer started after I got to college. I stayed a term still battling my pain then left for the Academy of Interactive Entertainment to get an advanced diploma in computer science but sadly I had to wait 4 years due to an illness I got that gave me chronic fatigue before I managed to work my way through and got my certificate by the end of 2011.

I know I am only one person with one story but I know there are others which the education system fails each and everyday and I know there's a better way. I still can't believe that the archaic teaching system hasn't been thrown away into a garbage compactor years ago where it belongs. At the moment there's only a few schools right now trying out a new system spotted around the world but at that speed we will still be waiting for a better system for decades.

The flaws are so obvious and they're just chain reactions for further problems that make everything worse; like stress of teachers for example will and does effect how they teach, how they talk to students etc and this as well as the forced education that they might not be interested in will cause kids to misbehave and end up in detention.

One of the worst parts of school for me was the ignorant notion that all students must be in a brute forced social environment and in rooms of about 30 all together; some are even bigger, with groups of students facing each other. This design comes from an arrogant stereotyping I've seen in many an extroverted leader who blame the students who sit by themselves reading a book of having social disorders or even a mental condition because they are simply ignorant of anything different than themselves. Believe it or not, some of the most important and world renown revolutionaries were introverted; they changed the world for the better, getting up and talking which pulled them out of their comfort zone, not for their ego: because it mattered and would help others. There's statistical evidence that shows less social environments create higher quality work as a result due to the fact that people get to hear their own thoughts and don't get distracted. They also discovered that when you have constant social gatherings, people end up emulating the other people and stop thinking freely about their own tastes and likes to try and be more one with the group. It's always good to have a brainstorming session but only here and there like meetings at a cafe. There's a myriad of combinations of introversion and extroversion; it's not just one or the other: there's a whole gradient. To truly create a modern curriculum we can not and will not stereotype students based on their social interactions, some students just need their own space so let them be and you will be surprised. Schools need more private spaces for these students who prefer to read than to talk as well as large social rooms for the more extroverted social goers.

The principle of a proper educational system is a learning process founded on shown example, not the "work it out for yourself" the reinvent the wheel paradigm. I have learned 10,000x's the amount of information simply because someone bothered to show the answer on the internet or just told me and it's simply because I care that I will remember it forever, the reason why I care is because it's on the exact subject I am interested in; my interests, not the school's. You might think that having all the answers will prevent the student from learning but you will be surprised what a little curiosity can do when you show them a topic of their own interest. What we need to do is to get a professional from every field, every career path to build a new fun and enjoyable curriculum, including the fun hands on stuff like making goo in science class, not just the current fields of today either; we need to spur creativity to invent new paths and careers, the current system DESTROYS creativity and destroys what's best in each and everyone of us because it doesn't care about you: your talents, likes and tastes. We need a system that teaches each and every student based on what makes them happy as well as a variation subset where things are worded differently; I've found that simply how something is said can mean all the difference and each student may have a different version they need in order to learn from it: this includes visual vs textual examples. One of the problems with the current system is a disgraceful lack of support for students who can't get to school for medical or other reasons and since we now live in an age where most people can find an access point to the internet we should be implementing it into the system as well; this will encourage exploration and creativity but we will also have to make sure that even students without internet can still get a comforting experience, there's also local libraries with public internet access along with books that they can read. Other advantages of the internet will allow for a website to be designed for this new curriculum and allow students to log in to evaluate their current educational progress as well as gain feedback from the teachers, such a system would allow each individual student to learn at their own speed. Not only will this take a massive strain off the teachers which will only improve the educational process but the student will be more willing to learn too since it's more fun and not brute forced onto them. Who cares if a student is bad at maths; maybe they are an artist? so put them in front of MS-Paint or even Photoshop, maybe they are a musician? give them access to musical equipment, we can not stereotype like the current system does, we must encourage them to do the best they can at the speed at which they learn, on the subjects they care about, praise them for it and make them smile.

I know this might sound like something out of a book of fiction but one day I hope the word school sounds like a place everyone would want to go to each day, a place where you can learn and have fun doing so.

Thanks for reading,
Ashton.