Test

Started by
62 comments, last by Michael Tanczos 19 years, 9 months ago
<div align="center">Testing <span class="forumcell">rawr!</span> Blah Red Text Test STRIKE! Blah
Advertisement
Just out of curiosity, the avatar posting guidelines clearly says (or at least said when I was exploring the contorl panel last time) *NO ANIMATED GIFS* so why is half the staff and moderators using them?
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Moderators and staff don't have that rule.

---
Michael Tanczos
Makes sense, maybe a clarifictaion on the avatar upload would be in order then? Just to stop more people from wondering why staff and mods are above the law in such a trivial matter :)
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Warcraft3 owns =P

[ test ]
haha
Staff
Moderator
[/test ]

Michael, the HTML font tag still works ;P
I don't think I would want to introduce more complexity if not necessary. There are plenty of rules on the forums that we have but don't justify. In this particular instance we just wanted to keep avatar annoyance to a minimum.

---
Michael Tanczos
I know. I'm testing out a different regular expression component than the built-in microsoft one. The damn thing has been performing so piss poorly that it has repeatedly caused our server to crash.. luckily IIS 6.0 is so fault-tolerant that nobody hardly ever notices.

---
Michael Tanczos
Testing:

#include <iostream.h>#include <stdlib.h>#include <time.h>#include <conio.h>struct tnode;typedef tnode* nodeptr;struct tnode  {      int data;      int balance;      int height;      int numchildren;      int multiplicity;      unsigned char active;      tnode *rchild;      tnode *lchild;  };int max (int x, int y)  {    if (x > y) return x;    return y;  }void calculate (nodeptr node)  {   int trchild = 0;   int tlchild = 0;   node->numchildren = 0;   if (node->lchild != NULL)     {       tlchild = node->lchild->height + 1;       node->numchildren += node->lchild->numchildren;     }   if (node->rchild != NULL)     {       trchild = node->rchild->height + 1;       node->numchildren += node->rchild->numchildren;     }   node->numchildren++;   node->height = max (tlchild-1, trchild-1) + 1;   node->balance = tlchild - trchild;  }void left_rotate (nodeptr &root)  {    nodeptr tmp1;    
Testing:

#include <iostream.h>#include <stdlib.h>#include <time.h>#include <conio.h>//#define USE_AVL          // Comment out if you want to utilize unbalanced                         // trees#define  PRE_ORDER    1#define   IN_ORDER    2#define POST_ORDER    3struct tnode;typedef tnode* nodeptr;struct tnode  {      int data;      int balance;      int height;      int numchildren;      int multiplicity;      unsigned char active;      tnode *rchild;      tnode *lchild;  };int max (int x, int y)  {    if (x > y) return x;    return y;  }void calculate (nodeptr node)  {   int trchild = 0;   int tlchild = 0;   node->numchildren = 0;   if (node->lchild != NULL)     {       tlchild = node->lchild->height + 1;       node->numchildren += node->lchild->numchildren;     }   if (node->rchild != NULL)     {       trchild = node->rchild->height + 1;       node->numchildren += node->rchild->numchildren;     }   node->numchildren++;   node->height = max (tlchild-1, trchild-1) + 1;   node->balance = tlchild - trchild;  }void left_rotate (nodeptr &root)  {    nodeptr tmp1;    // Rotate left-left    tmp1 = root->lchild;    root->lchild = tmp1->rchild;    tmp1->rchild = root;    root = tmp1;  }void right_rotate (nodeptr &root)  {    nodeptr tmp1;    // Right right    tmp1 = root->rchild;    root->rchild = tmp1->lchild;    tmp1->lchild = root;    root = tmp1;  }void insert (nodeptr &root, int value){  int compv;   if (root != NULL)  // True in most cases, so place first     {       // Strictly for portability cases       value > root->data ? compv =  1 :       value < root->data ? compv = -1 : compv = 0;       switch (compv)       {         case -1 : // Less than root value                   insert (root->lchild, value);                   break;         case  1 : // Greater than root value                   insert (root->rchild, value);                   break;         case  0 : // Equal to root value                   if (!root->active)                     root->active = 1;                   else                     root->multiplicity++;                   return;                   break;       }       // Calculate new balance and height       calculate (root);#ifdef USE_AVL       // Check for imbalance       if (root->balance == 2)         {           // left left           if (root->lchild->balance == 1)             {               left_rotate (root);             }           else           // left right           if (root->lchild->balance < 0)             {               right_rotate (root->lchild);               left_rotate (root);             }           calculate (root->lchild);           calculate (root->rchild);           calculate (root);         }       else       if (root->balance == -2)         {           // right right           if (root->rchild->balance == -1)             {               right_rotate (root);             }           else           // right left           if (root->rchild->balance > 0)             {               left_rotate (root->rchild);               right_rotate (root);             }           calculate (root->lchild);           calculate (root->rchild);           calculate (root);         }#endif     }   else     {       // Create Node       root = new tnode;       root->lchild = NULL;       root->rchild = NULL;       root->multiplicity = 0;       root->data = value;       root->active = 1;       root->height = 0;       root->balance = 0;       root->numchildren = 1;     }}nodeptr find (nodeptr root, int value){  int compv;  nodeptr retnode = NULL;   if (root != NULL)     {       // Strictly for portability cases       value > root->data ? compv = -1 :       value < root->data ? compv =  1 : compv = 0;       switch (compv)       {         case -1 : // Less than root value                   retnode = find (root->lchild, value);                   break;         case 1  : // Greater than root value                   retnode = find (root->rchild, value);                   break;         case 0  : // Equal to root value                   if (root->active)                     return root;                   break;       }    }  return retnode;  // Value not found in tree if still NULL}void remove (nodeptr root, int value)  {    nodeptr tmp;    tmp = find (root, value);    tmp->active = 0;    tmp->multiplicity = 0;  }        // traversed = zero nodes        // node = root        // while curnode->numchildren does not equal median        //   >>if node->lchild != NULL        //     if node->lchild->numchildren + traversed + 1 > median        //       node = node->rchild        //     else        //       traversed = node->lchild->numchildren + 1        //       node = node->lchild        //       median = median - traversednodeptr find_median (nodeptr root)  {    nodeptr node;    int     midp,            chcount = 0,            trav    = 0;    // Quick check to see if tree has at least one node    if (root == NULL) return NULL;    // Calculate traversal midpoint    midp = (root->numchildren + root->numchildren % 2) >> 1;    node = root;    while (chcount != midp)      {        // Child count is equal to the number of traversed nodes        // plus the current node        chcount = trav + 1;        // We increase the child count to the number of children in        // the current node's left child *if* there *are* children.        if (node->lchild != NULL) chcount += node->lchild->numchildren;        // If there are too few children in the left subtree to contain        // the calculated ordered midpoint (midp)        if (chcount < midp)          {             // Set the traversed node count equal to the number of             // child nodes of node + 1             trav = chcount;             // Continue on from right child             node = node->rchild;          }        else if (midp != chcount)          {             // Re-adjust median and calculate using smaller midpoint (midp)             midp -= trav;             trav = 0;             // Continue on from left child             node = node->lchild;          }     }    return node;  }void output_tree (nodeptr currptr, int order)  {    //    // pre-order    //    if (order == PRE_ORDER)       cout << currptr->data << endl;    // Traverse left children    if (currptr->lchild != NULL)      output_tree (currptr->lchild, order);    //    // in-order    //    if (order == IN_ORDER)      cout << currptr->data << endl;    // Traverse right children    if (currptr->rchild != NULL)      output_tree (currptr->rchild, order);    //    // post-order    //    if (order == POST_ORDER)      cout << currptr->data << endl;    return;  }void delete_tree (nodeptr &currptr)  {    // Delete nodes in post order    // Traverse left children    if (currptr->lchild != NULL)      delete_tree (currptr->lchild);    // Traverse right children    if (currptr->rchild != NULL)      delete_tree (currptr->rchild);    delete currptr;    return;  }int main (){  tnode *root = NULL;  int insrt;  clrscr ();  srand (time (0));  for (int i = 1; i <= 90; i++)    {     insrt = i;//rand () % 2048;     insert (root, insrt);//     cout << "Inserted : " << insrt << " , Value of Root : " << root->data << endl;//     cout << "Root height = " << root->height << endl;    }//    calculate (root);/*    cout << "------------------------------------------------------------" << endl;    cout << "Root : " << endl;    cout << "Comp = " << root->data << "   Heig = " << root->height << endl;    cout << "Num children = " << root->numchildren << endl;    cout << "   Bal = " << root->balance << endl;    cout << "   L Comp = " << root->lchild->data << "   L Heig = " << root->lchild->height;    cout << "   L Bal = " << root->lchild->balance << endl;    cout << "     L L Comp = " << root->lchild->lchild->data << "   L L Heig = " << root->lchild->lchild->height;    cout << "   L L Bal = " << root->lchild->lchild->balance << endl;    cout << "     L R Comp = " << root->lchild->rchild->data << "   L R Heig = " << root->lchild->rchild->height;    cout << "   L R Bal = " << root->lchild->rchild->balance << endl;    cout << "   R Comp = " << root->rchild->data << "   R Heig = " << root->rchild->height;    cout << "   R Bal = " << root->rchild->balance << endl;    cout << "     R L Comp = " << root->rchild->lchild->data << "   R L Heig = " << root->rchild->lchild->height;    cout << "   R L Bal = " << root->rchild->lchild->balance << endl;    cout << "     R R Comp = " << root->rchild->rchild->data << "   R R Heig = " << root->rchild->rchild->height;    cout << "   R R Bal = " << root->rchild->rchild->balance << endl;    cout << "------------------------------------------------------------" << endl;*/    cout << "The Median is : " << find_median (root)->data << endl;    delete_tree (root);//  output_tree (root, IN_ORDER);}



// This example is from _Java Examples in a Nutshell_. (http://www.oreilly.com)// Copyright (c) 1997 by David Flanagan// This example is provided WITHOUT ANY WARRANTY either expressed or implied.// You may study, use, modify, and distribute it for non-commercial purposes.// For any commercial use, see http://www.davidflanagan.com/javaexamplesimport java.rmi.*;import java.rmi.server.*;import java.rmi.registry.*;import java.io.*;import java.util.*;import Mud.*;/**  * This class implements the RemoteMudPlace interface and exports a * bunch of remote methods that are at the heart of the MUD.  The * MudClient interacts primarily with these methods.  See the comment * for RemoteMudPlace for an overview. * The MudPlace class is Serializable so that places can be saved to disk * along with the MudServer that contains them.  Note, however that the * names and people fields are marked transient, so they are not serialized * along with the place (because it wouldn't make sense to try to save * RemoteMudPerson objects, even if they could be serialized). **/public class MudPlace extends UnicastRemoteObject                        implements RemoteMudPlace, Serializable {  String placename, description;          // information about the place itself  Vector exits = new Vector();            // names of exits from this place  Vector destinations = new Vector();     // where the exits go to  Vector things = new Vector();           // names of things in this place  Vector descriptions = new Vector();     // descriptions of those things  transient Vector names = new Vector();  // names of people in this place  transient Vector people = new Vector(); // the RemoteMudPerson objects  MudServer server;                       // the server for this place  /** A no-arg constructor for de-serialization only.  Do not call it */  public MudPlace() throws RemoteException { super(); }  /**   * This constructor creates a place, and calls a server method   * to register the object so that it will be accessible by name   **/  public MudPlace(MudServer server, String placename, String description)        throws RemoteException, PlaceAlreadyExists {    this.server = server;    this.placename = placename;     this.description = description;    server.setPlaceName(this, placename);  // Register the place  }  /** This remote method returns the name of this place */  public String getPlaceName() throws RemoteException { return placename; }  /** This remote method returns the description of this place */  public String getDescription() throws RemoteException { return description; }  /** This remote method returns a Vector of names of people in this place */  public Vector getNames() throws RemoteException { return names; }  /** This remote method returns a Vector of names of things in this place */  public Vector getThings() throws RemoteException { return things; }  /** This remote method returns a Vector of names of exits from this place */  public Vector getExits() throws RemoteException { return exits; }  /**    * This remote method returns a RemoteMudPerson object corresponding to   * the specified name, or throws an exception if no such person is here    **/  public RemoteMudPerson getPerson(String name)        throws RemoteException, NoSuchPerson {    synchronized(names) {      // What about when there are 2 of the same name?      int i = names.indexOf(name);      if (i == -1) throw new NoSuchPerson();      return (RemoteMudPerson) people.elementAt(i);    }  }    /**    * This remote method returns a description of the named thing, or   * throws an exception if no such thing is in this place.   **/  public String examineThing(String name) throws RemoteException, NoSuchThing {    synchronized(things) {      int i = things.indexOf(name);      if (i == -1) throw new NoSuchThing();      return (String) descriptions.elementAt(i);    }  }  /**    * This remote method moves the specified RemoteMudPerson from this place   * in the named direction (i.e. through the named exit) to whatever place   * is there.  It throws exceptions if the specified person isn't in this   * place to begin with, or if they are already in the place through the exit   * or if the exit doesn't exist, or if the exit links to another MUD server   * and the server is not functioning.   **/  public RemoteMudPlace go(RemoteMudPerson who, String direction)        throws RemoteException, NotThere, AlreadyThere, NoSuchExit, LinkFailed {    // Make sure the direction is valid, and get destination if it is    Object destination;    synchronized(exits) {      int i = exits.indexOf(direction);      if (i == -1) throw new NoSuchExit();      destination = destinations.elementAt(i);    }    // If destination is a string, it is a place on another server, so connect     // to that server.  Otherwise, it is a place already on this server.      // Throw an exception if we can't connect to the server.    RemoteMudPlace newplace;    if (destination instanceof String) {      try {         String t = (String) destination;        int pos = t.indexOf('@');        String url = t.substring(0, pos);        String placename = t.substring(pos+1);        RemoteMudServer s = (RemoteMudServer) Naming.lookup(url);        newplace = s.getNamedPlace(placename);      }       catch (Exception e) { throw new LinkFailed(); }     }    // If the destination is not a string, then it is a Place    else newplace = (RemoteMudPlace) destination;    // Make sure the person is here and get their name.      // Throw an exception if they are not here    String name = verifyPresence(who);    // Move the person out of here, and tell everyone who remains about it.    this.exit(who, name + " has gone " + direction);          // Put the person into the new place.      // Send a message to everyone already in that new place    String fromwhere;    if (newplace instanceof MudPlace) // going to a local place      fromwhere = placename;    else      fromwhere = server.getMudName() + "." + placename;    newplace.enter(who, name, name + " has arrived from: " + fromwhere);    // Return the new RemoteMudPlace object to the client so they    // know where they are now at.    return newplace;  }  /**    * This remote method sends a message to everyone in the room.  Used to   * say things to everyone.  Requires that the speaker be in this place.   **/  public void speak(RemoteMudPerson speaker, String msg)        throws RemoteException, NotThere {    String name = verifyPresence(speaker);    tellEveryone(name + ":" + msg);  }  /**    * This remote method sends a message to everyone in the room.  Used to   * do things that people can see.  Requires that the actor be in this place.   **/  public void act(RemoteMudPerson actor, String msg)        throws RemoteException, NotThere {    String name = verifyPresence(actor);    tellEveryone(name + " " + msg);  }  /**    * This remote method creates a new thing in this room.   * It requires that the creator be in this room.   **/  public void createThing(RemoteMudPerson creator,                          String name, String description)        throws RemoteException, NotThere, AlreadyThere {    // Make sure the creator is here    String creatorname = verifyPresence(creator);    synchronized(things) {      // Make sure there isn't already something with this name.        if (things.indexOf(name) != -1) throw new AlreadyThere();      // Add the thing name and descriptions to the appropriate lists      things.addElement(name);      descriptions.addElement(description);    }    // Tell everyone about the new thing and its creator    tellEveryone(creatorname + " has created a " + name);  }  /**   * Remove a thing from this room.  Throws exceptions if the person   * who removes it isn't themselves in the room, or if there is no   * such thing here.   **/  public void destroyThing(RemoteMudPerson destroyer, String thing)        throws RemoteException, NotThere, NoSuchThing {    // Verify that the destroyer is here    String name = verifyPresence(destroyer);    synchronized(things) {      // Verify that there is a thing by that name in this room      int i = things.indexOf(thing);      if (i == -1) throw new NoSuchThing();      // And remove its name and description from the lists      things.removeElementAt(i);      descriptions.removeElementAt(i);    }    // Let everyone know of the demise of this thing.    tellEveryone(name + " had destroyed the " + thing);  }  /**   * Create a new place in this MUD, with the specified name an description.    * The new place is accessible from this place through   * the specified exit, and this place is accessible from the new place    * through the specified entrance.  The creator must be in this place   * in order to create a exit from this place.   **/  public void createPlace(RemoteMudPerson creator,                          String exit, String entrance, String name,                           String description)        throws RemoteException,NotThere,ExitAlreadyExists,PlaceAlreadyExists {    // Verify that the creator is actually here in this place    String creatorname = verifyPresence(creator);    synchronized(exits) {  // Only allow one client to change exits at a time      // Check that the exit doesn't already exist.      if (exits.indexOf(exit) != -1) throw new ExitAlreadyExists();      // Create the new place, registering its name with the server      MudPlace destination = new MudPlace(server, name, description);      // Link from there back to here      destination.exits.addElement(entrance);      destination.destinations.addElement(this);      // And link from here to there      exits.addElement(exit);      destinations.addElement(destination);    }    // Let everyone know about the new exit, and the new place beyond    tellEveryone(creatorname + " has created a new place: " + exit);  }  /**   * Create a new exit from this mud, linked to a named place in a named   * MUD on a named host (this can also be used to link to a named place in    * the current MUD, of course).  Because of the possibilities of deadlock,   * this method only links from here to there; it does not create a return   * exit from there to here.  That must be done with a separate call.   **/  public void linkTo(RemoteMudPerson linker, String exit,                      String hostname, String mudname, String placename)        throws RemoteException, NotThere, ExitAlreadyExists, NoSuchPlace {    // Verify that the linker is actually here     String name = verifyPresence(linker);    // Check that the link target actually exists.  Throw NoSuchPlace if not.    // Note that NoSuchPlace may also mean "NoSuchMud" or "MudNotResponding".    String url = "rmi://" + hostname + '/' + Mud.mudPrefix + mudname;    try {      RemoteMudServer s = (RemoteMudServer) Naming.lookup(url);      RemoteMudPlace destination = s.getNamedPlace(placename);    }    catch (Exception e) { throw new NoSuchPlace(); }        synchronized(exits) {      // Check that the exit doesn't already exist.      if (exits.indexOf(exit) != -1) throw new ExitAlreadyExists();      // Add the exit, to the list of exit names      exits.addElement(exit);      // And add the destination to the list of destinations.  Note that      // the destination is stored as a string rather than as a RemoteMudPlace.      // This is because if the remote server goes down then comes back up      // again, a RemoteMudPlace is not valid, but the string still is.      destinations.addElement(url + '@' + placename);    }    // Let everyone know about the new exit and where it leads    tellEveryone(name + " has linked " + exit + " to " +                  "'" + placename + "' in MUD '" + mudname +                  "' on host " + hostname);  }  /**   * Close an exit that leads out of this place.   * It does not close the return exit from there back to here.   * Note that this method does not destroy the place that the exit leads to.   * In the current implementation, there is no way to destroy a place.   **/  public void close(RemoteMudPerson who, String exit)        throws RemoteException, NotThere, NoSuchExit {    // check that the person closing the exit is actually here    String name = verifyPresence(who);    synchronized(exits) {      // Check that the exit exists      int i = exits.indexOf(exit);      if (i == -1) throw new NoSuchExit();      // Remove it and its destination from the lists      exits.removeElementAt(i);      destinations.removeElementAt(i);    }    // Let everyone know that the exit doesn't exist anymore    tellEveryone(name + " has closed exit " + exit);  }  /**    * Remove a person from this place.  If there is a message, send it to    * everyone who is left in this place.  If the specified person is not here,   * this method does nothing and does not throw an exception.  This method   * is called by go(), and the client should call it when the user quits.   * The client should not allow the user to invoke it directly, however.   **/  public void exit(RemoteMudPerson who, String message) throws RemoteException{    String name;    synchronized(names) {      int i = people.indexOf(who);      if (i == -1) return;      names.removeElementAt(i);      people.removeElementAt(i);    }    if (message != null) tellEveryone(message);  }  /**    * This method puts a person into this place, assigning them the   * specified name, and displaying a message to anyone else who is in   * that place.  This method is called by go(), and the client should   * call it to initially place a person into the MUD.  Once the person   * is in the MUD, however, the client should restrict them to using go()   * and should not allow them to call this method directly.   * If there have been networking problems, a client might call this method   * to restore a person to this place, in case they've been bumped out.   * (A person will be bumped out of a place if the server tries to send   * a message to them and gets a RemoteException.)   **/  public void enter(RemoteMudPerson who, String name, String message)        throws RemoteException, AlreadyThere {    // Send the message to everyone who is already here.    if (message != null) tellEveryone(message);    // Add the person to this place.    synchronized (names) {      if (people.indexOf(who) != -1) throw new AlreadyThere();      names.addElement(name);      people.addElement(who);    }  }  /**   * This final remote method returns the server object for the MUD in which   * this place exists.  The client should not allow the user to invoke this   * method.   **/  public RemoteMudServer getServer() throws RemoteException { return server; }  /**    * Create and start a thread that sends out a message everyone in this place.   * If it gets a RemoteException talking to a person, it silently removes    * that person from this place.  This is not a remote method, but is used   * internally by a number of remote methods.   **/  protected void tellEveryone(final String message) {    // If there is no-one here, don't bother sending the message!    if (people.size() == 0) return;    // Make a copy of the people here now.  The message is sent asynchronously    // and the list of people in the room may change before the message is    // sent to everyone.    final Vector recipients = (Vector) people.clone();    // Create and start a thread to send the message, using an anonymous    // class.  We do this because sending the message to everyone in this     // place might take some time, (particularly on a slow or flaky network)     // and we don't want to wait.    new Thread() {      public void run() {        // Loop through the recipients        for(int i = 0; i < recipients.size(); i++) {          RemoteMudPerson person = (RemoteMudPerson)recipients.elementAt(i);          // Try to send the message to each one.          try { person.tell(message); }           // If it fails, assume that that person's client or network has          // failed, and silently remove them from this place.          catch (RemoteException e) {             try { MudPlace.this.exit(person, null); }             catch (Exception ex) {}           }        }      }    }.start();  }  /**   * This convenience method checks whether the specified person is here.   * If so, it returns their name.  If not it throws a NotThere exception   **/  protected String verifyPresence(RemoteMudPerson who) throws NotThere {    int i = people.indexOf(who);    if (i == -1) throw new NotThere();    else return (String) names.elementAt(i);  }  /**   * This method is used for custom de-serialization.  Since the vectors of   * people and of their names are transient, they are not serialized with   * the rest of this place.  Therefore, when the place is de-serialized, those   * vectors have to be recreated (empty).   **/  private void readObject(ObjectInputStream in)        throws IOException, ClassNotFoundException {    in.defaultReadObject();  // Read most of the object as normal    names = new Vector();    // Then recreate the names vector    people = new Vector();   // and recreate the people vector  }                       /** This constant is a version number for serialization */  static final long serialVersionUID = 5090967989223703026L;}



<%' VBScript Directory Selection Code' Written by Michael A. Tanczos' You may use this code in any shape or form, for any capacity commercial or non-commercial, ' as long as my name remains intact above.  If you are redistributing this code not as part' of an overall package, this notice must also remain intact.dim strRootDir, strUnknownFileImage, strFolderImage' Modifiable Constants (by you)Const intMaxExtensions = 10   ' Size of file extension array, if you need to add more extensions you must increase thisConst intFilesPerColumn = 9   ' Files per column in the non descriptive file listing modeConst boolPickDirectoryMode = false ' If you want your user to pick a directory instead of a file, use thisConst boolReverseSlash = false	' If you want the dialog to return url compatible file paths, set this to true 								' (\file\path\blah.htm instead of /file/path/blah.htm)' Modifiable VariablesstrUnknownFileImage = "icons/unknown.gif" 	' Icon for unrecognized file types (file types not in the ExtensionImageHash)strFolderImage = "icons/folder.gif"			' Icon for directoriesstrRootDir = server.mappath("/")  ' If you want the file dialog to start at the root directory for your web site'strRootDir = server.mappath(".")  ' Perhaps you'd like to start in the directory this script is in?'========================================================================================================================' Other constantsConst FType_directory = 1Const FType_file = 2' File descriptor classClass FileObj	Public Name	Public Extension	Public ShortPath	Public FType  	Public Size	Public Desc	Public DateLastModifiedEnd Class' File extension classClass FileExtension	Public Desc	Public Extension	Public Pattern	Public EnabledEnd Classdim intNumfiles			' Number of files read from current directorydim DirList ()			' Array of FileObj objectsdim ExtensionList ()	' Array of FileExtension objectsdim ExtensionImageHash	' Dictionary object containing file extensions as keys, icon paths as valuesdim ExtCnt				' Number of extensions added by CreateExtensionList' Modify this function to enable or disable extension typesfunction CreateExtensionList	redim ExtensionList (intMaxExtensions)			ExtCnt = 0	set ExtensionImageHash = Server.CreateObject("Scripting.Dictionary")		set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "All Files"	ExtensionList(ExtCnt).Extension = "*.*"	ExtensionList(ExtCnt).Pattern = ".*"	ExtensionList(ExtCnt).Enabled = true	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "HTML"	ExtensionList(ExtCnt).Extension = "*.htm,*.html"	ExtensionList(ExtCnt).Pattern = ".*\.(htm|html)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("htm") = "icons/html.gif"		ExtensionImageHash("html") = "icons/html.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "Text"	ExtensionList(ExtCnt).Extension = "*.txt,*.log"	ExtensionList(ExtCnt).Pattern = ".*\.(txt|log)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("txt") = "icons/txt.gif"		ExtensionImageHash("log") = "icons/txt.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "ASP"	ExtensionList(ExtCnt).Extension = "*.asp"	ExtensionList(ExtCnt).Pattern = ".*\.(asp)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("asp") = "icons/asp.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "Images"	ExtensionList(ExtCnt).Extension = "*.jpg,*.gif,*.png,..."	ExtensionList(ExtCnt).Pattern = ".*\.(jpg|gif|png|tga|pcx|psd)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("jpg") = "icons/image.gif"		ExtensionImageHash("gif") = "icons/image.gif"		ExtensionImageHash("png") = "icons/image.gif"		ExtensionImageHash("tga") = "icons/image.gif"		ExtensionImageHash("pcx") = "icons/image.gif"		ExtensionImageHash("psd") = "icons/image.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "Javascript"	ExtensionList(ExtCnt).Extension = "*.js"	ExtensionList(ExtCnt).Pattern = ".*\.(js)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("js") = "icons/js.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "Zip Files"	ExtensionList(ExtCnt).Extension = "*.zip"	ExtensionList(ExtCnt).Pattern = ".*\.(zip)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("zip") = "icons/zip.gif"	ExtCnt = ExtCnt + 1	set ExtensionList (ExtCnt) = new FileExtension	ExtensionList(ExtCnt).Desc = "Executables"	ExtensionList(ExtCnt).Extension = "*.exe,*.cgi"	ExtensionList(ExtCnt).Pattern = ".*\.(exe|cgi)"	ExtensionList(ExtCnt).Enabled = true		ExtensionImageHash("exe") = "icons/exe.gif"		ExtensionImageHash("cgi") = "icons/exe.gif"	ExtCnt = ExtCnt + 1	' Add additional file types here as desired		'set ExtensionList (ExtCnt) = new FileExtension	'ExtensionList(ExtCnt).Desc = "My File Type (Video Files)"	'ExtensionList(ExtCnt).Extension = "*.mov, *.mpg, *.avi"	'ExtensionList(ExtCnt).Pattern = ".*\.(mov|mpg|avi)"	'ExtensionList(ExtCnt).Enabled = true	'	ExtensionImageHash("mov") = "icons/video.gif"  ' Place a video.gif icon in the icons directory, or just use one of the other icons	'	ExtensionImageHash("mpg") = "icons/video.gif"	'	ExtensionImageHash("avi") = "icons/video.gif"	'ExtCnt = ExtCnt + 1	end function'========================================================================================================================' DO NOT EDIT BELOW THIS LINE'========================================================================================================================' Unallocates memory used up by the extension list, honestly I don't know if this is necessary' but I would do it in any other language so I'm not going to make an exception with ASPfunction DestroyExtensionList	for ext = 0 to UBound(ExtensionList)		if (isObject (ExtensionList (ext))) then			set ExtensionList (ext) = nothing		end if	next		set ExtensionImageHash = nothingend function' Creates a listing of directories and files from a given directory (set by either strRootDir ' or the 'path' querystring variable)function CreateFileList (strDirectory, intExtension)	dim filesys, folder, intWorkingCount, objRegEx	intWorkingCount = 0		Set filesys = CreateObject("Scripting.FileSystemObject")	Set folder = filesys.GetFolder(strDirectory)      Set objRegEx = New RegExp 	' Initialize regular expression settings    objRegEx.Global = True    objRegEx.IgnoreCase = True    objRegEx.Pattern = ExtensionList(intExtension).Pattern	' Resize the directory listing to equal the number of folders found	Redim Preserve DirList(folder.SubFolders.Count) 		For Each dir in folder.SubFolders			set DirList(intWorkingCount) = new FileObj		DirList(intWorkingCount).Name = dir.name		DirList(intWorkingCount).Extension = ""		DirList(intWorkingCount).FType = FType_directory		DirList(intWorkingCount).ShortPath = mid(dir.Path, len(strRootDir)+1)		DirList(intWorkingCount).Size = CLng(dir.size / 1024) & "KB"		DirList(intWorkingCount).Desc = dir.Type		DirList(intWorkingCount).DateLastModified = dir.DateLastModified				intWorkingCount = intWorkingCount + 1	Next   	' If we are in directory picking mode, then it isn't necessary to add files to the listing	if (not boolPickDirectoryMode) then		' Resize the directory listing to include the previous folders, plus any new files found			ReDim Preserve DirList (intWorkingCount + folder.Files.Count) 			For Each fil in folder.Files 						' Test file name to see if it matches the currently selected wildcard pattern			if (objRegEx.Test (fil.name)) then							set DirList(intWorkingCount) = new FileObj				DirList(intWorkingCount).Name = fil.name				DirList(intWorkingCount).FType = FType_file				DirList(intWorkingCount).Extension = filesys.GetExtensionName(fil.path)				DirList(intWorkingCount).ShortPath = mid(fil.Path, len(RootDir)+1)				DirList(intWorkingCount).Size = CLng(fil.size / 1024) & "KB"				DirList(intWorkingCount).Desc = fil.Type				DirList(intWorkingCount).DateLastModified = fil.DateLastModified								intWorkingCount = intWorkingCount + 1			end if		Next   			end if		intNumfiles = intWorkingCount	' Resize directory to equal the number of files found exactly (wildcards may have trimmed the list a bit)	ReDim Preserve DirList (intNumfiles) 	end function' Unallocates memory utilized by the directory listingsub DestroyFileList	for fn = 0 to intNumfiles-1		if (isObject (DirList(fn))) then			set DirList(fn) = nothing		end if		nextend sub' Prints an individual file/directory along with it's associated linksub PrintFile (FileObj_File)	mask = ""	if (request.querystring("mask") <> "") then		mask = "&mask=" & request.querystring("mask")	end if	lm = ""	if (request.querystring("lm") <> "") then		lm = "&lm=" & request.querystring("lm")	end if		response.write " "			select case FileObj_File.Ftype		case FType_directory: 			if (not boolPickDirectoryMode) then				response.write "<img src=""" & strFolderImage & """ border=0><a href=""dirlist.asp?path=" & server.UrlEncode(FileObj_File.shortpath) & mask & lm & """>" & FileObj_File.name & "</a> "			else				response.write "<img src=""" & strFolderImage & """ border=0><a href=""javascript:SelectDirectory('" & replace(FileObj_File.shortpath,"\","\\") & "','dirlist.asp?path=" & server.UrlEncode(replace(FileObj_File.shortpath,"\","\\")) & mask & lm & "')"">" & FileObj_File.name & "</a> "						end if			case FType_file:			if (ExtensionImageHash(FileObj_File.Extension) = "") then				response.write "<img src=""" & strUnknownFileImage & """ border=0>" 			else				response.write "<img src=""" & ExtensionImageHash(FileObj_File.Extension) & """ border=0>" 			end if								response.write "<a href=""javascript:SelectFile('" & FileObj_File.name & "')"">" & FileObj_File.name & "</a> "	end select		end sub' Prints a neatly formatted table of directories/files in non-detailed formsub PrintListNonDetailed	dim intNumColumns, intFileNo	intNumColumns = CInt(intNumfiles / intFilesPerColumn)	intColWidth = CInt(100/(intNumColumns+1))	response.write "<tr><td><img src=""icons/clear.gif"" height=""4""></td></tr>"		for row = 0 to intFilesPerColumn-1			response.write "<tr>"				for col = 0 to intNumColumns					intFileNo = col * intFilesPerColumn + row						response.write "<td nowrap width=""" & intColWidth & "%"">"				if (intFileNo < intNumfiles) then				PrintFile DirList(intFileNo) 			else					response.write " "			end if				response.write "</td>"				next				response.write "</tr>"			nextend sub' Prints a neatly formatted table of directories/files in detailed formsub PrintListDetailed	response.write "<tr><td bgcolor=""#C0C0C0""> Name</td><td bgcolor=""#C0C0C0"" align=""right"">Size  </td><td bgcolor=""#C0C0C0"">Type</td><td bgcolor=""#C0C0C0"">Last Modified</td></tr>" & vbcrlf	response.write "<tr><td><img src=""icons/clear.gif"" height=""4""></td></tr>"		for intFileNo = 0 to intNumfiles-1		response.write "<tr><td nowrap>"		PrintFile DirList(intFileNo) 		response.write "</td><td align=""right"" nowrap>" & DirList(intFileNo).Size & "  </td><td nowrap>" & DirList(intFileNo).Desc & "  </td><td class=td2 nowrap>" & DirList(intFileNo).DateLastModified & "</td>"			response.write "</tr>"	next	response.write "</tr>"end sub' Prints a neatly formatted table of directories/files in a form specified by intmode, where intmode is' 1 non-detailed, 2 detailedsub PrintList (intmode)	if (intmode > 2 or intmode < 1) then		intmode = 1	end if		if (intNumfiles = 0) then		if (not boolPickDirectoryMode) then			response.write "<tr><td><br> There are no matching files in this directory</td></tr>"		else			response.write "<tr><td><br> There are no subdirectories under this directory</td></tr>"		end if		else		select case intmode			case 1: PrintListNonDetailed				case 2: PrintListDetailed		end select	end if		end sub%>



; Fireworks - with MMX blur and light effects; by ronybc from Kerala,INDIA ; website: http://www.ronybc.8k.com.686p.MMX.model flat,stdcalloption casemap:noneinclude \masm32\include\windows.incinclude \masm32\include\kernel32.incinclude \masm32\include\gdi32.incinclude \masm32\include\user32.incincludelib \masm32\lib\kernel32.libincludelib \masm32\lib\gdi32.libincludelib \masm32\lib\user32.lib; struct spark {float x,xv,y,yv;};; struct FireShell {DWORD life; float air; spark d[250];};; sizeof FireShell = 250*4*4+8 = 4008 bytesEXX   EQU 4EXY   EQU 8AIR   EQU 12SPARC EQU 16.dataClassName db "apocalypse",0AppName   db "Fireworks MMX ...by ronybc",0,0,0,0,0,0info      db "Fireworks Version: 3.40229 - Freeware",13,10          db  13,10          db "WARNING: This is a Fireware, softwares that push CPU temperature",13,10          db "to its maximum. It does No harm, but overclockers better stay away :)",13,10          db "Entire source code of this program is free available at my website. ",13,10          db  13,10          db "If you like the work, help the author with donations.",13,10          db "see http://www.ronybc.8k.com/support.htm",13,10          db  13,10          db "SPACE &;; ENTER keys toggles 'Gravity and Air' and",13,10          db "'Light and Smoke' effects respectively.",13,10          db "And clicks explode..! close clicks produce more light",13,10          db  13,10          db "Manufactured, bottled and distributed by",13,10          db "Silicon Fumes Digital Distilleries, Kerala, INDIA",13,10          db 13,10          db "Copyright 1999-2004 © Rony B Chandran. All Rights Reserved",13,10          db 13,10          db "This isn't the Final Version",13,10          db "check http://www.ronybc.8k.com for updates and more",0seed      dd 2037280626wwidth    dd 680               ; 1:1.618, The ratio of beauty ;)wheight   dd 420               ; smaller the window faster the firesmaxx      dd 123               ; 123: values set on executionmaxy      dd 123               ; this thing is best for comparinglightx    dd 123               ; cpu performance.lighty    dd 123flash     dd 123flfactor  dd 0.92adg       dd 0.00024           ; 0.00096 acceleration due to gravityxcut      dd 0.00064nb        dd 5                 ; number of shellsnd        dd 400               ; sparks per shellsb        dd 0                 ; value set on executionmaxpower  dd 5minlife   dd 500               ; altered @WndProc:WM_COMMAND:1300motionQ   dd 16                ; 01-25, altered @WndProc:WM_COMMAND:1210fcount    dd 0GMode     dd 1                 ; atmosphere or outer-spaceCMode     dd 0                 ; color shifterEMode     dd 1                 ; special effectsclick     dd 0stop      dd 0fadelvl   dd 1chemtable dd 00e0a0ffh, 00f08030h, 00e6c080h, 0040b070h,  00aad580hbminf     BITMAPINFO &lt;<40,0,0,1,24,0,0,0,0,0,0>>.data?hInstance HINSTANCE ?hwnd      LPVOID ?hmnu      HWND ?wnddc     HDC ?hFThread  HANDLE ?hHeap     HANDLE ?idThread1 DWORD ?idThread2 DWORD ?bitmap1   LPVOID ?bitmap2   LPVOID ?hFShells  LPVOID ?msg       MSG &lt;>wc        WNDCLASSEX &lt;>.coderandom PROC base:DWORD         ; Park Miller random number algorithm    mov eax, seed              ; from M32lib/nrand.asm    xor edx, edx    mov ecx, 127773    div ecx    mov ecx, eax    mov eax, 16807    mul edx    mov edx, ecx    mov ecx, eax    mov eax, 2836    mul edx    sub ecx, eax    xor edx, edx    mov eax, ecx    mov seed, ecx    div base    mov eax, edx    retrandom ENDP; -------------------------------------------------------------------------Light_Flash3 PROC x1:DWORD, y1:DWORD, lum:DWORD, src:DWORD, des:DWORD    LOCAL mx:DWORD, my:DWORD, x2:DWORD, y2:DWORD, tff:DWORD    mov eax,lum    shr eax,1                  ; Light_Flash: dynamic 2D lighting routine    mov lum,eax                ; does not uses any pre-computed data    mov tff,255                ; ie. pure light frum tha melting cpu core :)    mov eax,maxx    mov mx,eax    mov eax,maxy    dec eax    mov my,eax    mov esi,src    mov edi,des    xor eax,eax    mov y2,eaxylp3:                          ; 2x2 instead of per pixel lighting     xor eax,eax                ; half the quality, but higher speed    mov x2,eaxxlp3:    mov eax,y2    sub eax,y1    imul eax    mov ebx,x2    sub ebx,x1    imul ebx,ebx    add eax,ebx    mov edx,lum    imul edx,edx    xor ebx,ebx    cmp eax,edx    ja @F                      ; jump to end causes time waves    push eax    fild dword ptr[esp]    fsqrt    fidiv lum                  ; this code is -nonlinear-    fld1    fsubrp st(1),st(0)    fmul st(0),st(0)           ; curve    fmul st(0),st(0)           ; curve more    fimul tff    fistp dword ptr[esp]    pop ebx    imul ebx,01010101h@@:    mov eax,y2    imul maxx    add eax,x2    lea eax,[eax+eax*2]    mov edx,maxx    lea edx,[edx+edx*2]    add edx,eax        movd MM2,ebx               ; simply add with saturation    movq MM0,[esi+eax]         ; gamma correction is against this code    psllq MM2,32    movq MM1,[esi+edx]    movd MM3,ebx    por MM2,MM3    paddusb MM0,MM2    movd [edi+eax],MM0    paddusb MM1,MM2    psrlq MM0,32    movd [edi+edx],MM1    movd ebx,MM0    psrlq MM1,32    mov [edi+eax+4],bx    movd ecx,MM1    mov [edi+edx+4],cx    emms@@:    mov eax,x2    add eax,2    mov x2,eax    cmp eax,mx    jbe xlp3    mov eax,y2    add eax,2    mov y2,eax    cmp eax,my    jbe ylp3    retLight_Flash3 ENDP; -------------------------------------------------------------------------Blur_MMX2 PROC                 ; 24bit color version    mov edi,bitmap2            ; (Developed under an old SiS6326 graphic card    mov esi,bitmap1            ;  which prefers 24bit for faster operation)    mov bitmap1,edi            ;  Note: SiS315 is excellent, good rendering quality    mov bitmap2,esi    pxor MM7,MM7    mov eax,fadelvl    imul eax,00010001h    mov [ebp-4],eax    mov [ebp-8],eax    movq MM6,[ebp-8]    mov eax,maxx    lea eax,[eax+eax*2]    mov ebx,eax    imul maxy    push eax                   ; maxy*maxx*3    lea edx,[ebx-3]    lea ebx,[ebx+3]    neg edx    xor eax,eax    lea esi,[esi-3]@@:    movd MM0,[esi]             ; code enlarged version    punpcklbw MM0,MM7          ; optimized for speed, not size    movd MM1,[esi+8]    movd MM2,[esi+16]    punpcklbw MM1,MM7    punpcklbw MM2,MM7        movd MM3,[esi+6]    movd MM4,[esi+14]    movd MM5,[esi+22]    punpcklbw MM3,MM7    paddw MM0,MM3    punpcklbw MM4,MM7    paddw MM1,MM4    punpcklbw MM5,MM7    paddw MM2,MM5    movd MM3,[esi+ebx]    punpcklbw MM3,MM7    paddw MM0,MM3    movd MM4,[esi+ebx+8]    movd MM5,[esi+ebx+16]    punpcklbw MM4,MM7    paddw MM1,MM4    punpcklbw MM5,MM7    paddw MM2,MM5    movd MM3,[esi+edx]    punpcklbw MM3,MM7    paddw MM0,MM3    movd MM4,[esi+edx+8]    movd MM5,[esi+edx+16]    punpcklbw MM4,MM7    paddw MM1,MM4    punpcklbw MM5,MM7    paddw MM2,MM5    psrlw MM0,2                ; neibours only, ie. smoky blur    psrlw MM1,2    psrlw MM2,2    psubusw MM0,MM6            ; fade    psubusw MM1,MM6    psubusw MM2,MM6    packuswb MM0,MM7    lea esi,[esi+12]    packuswb MM1,MM7    packuswb MM2,MM7    movd [edi+eax],MM0    movd [edi+eax+8],MM1    movd [edi+eax+16],MM2    lea eax,[eax+12]    cmp eax,[esp]    jbe @B    pop eax    emms                       ; free fpu registers for following    ret                        ; floating-point functionsBlur_MMX2 ENDP; -------------------------------------------------------------------------FShell_explodeOS PROC hb:DWORD    mov edi,hb    add edi,SPARC    mov eax,nd    dec eax    shl eax,4@@:    fld dword ptr[edi+eax]     ; x coordinate    fadd dword ptr[edi+eax+4]  ; x velocity    fstp dword ptr[edi+eax]    fld dword ptr[edi+eax+8]   ; y coordinate    fadd dword ptr[edi+eax+12] ; y velocity    fstp dword ptr[edi+eax+8]    sub eax,16    jnc @B    dec dword ptr[edi-SPARC]    mov eax,[edi-SPARC]        ; return(--life)    retFShell_explodeOS ENDP; -------------------------------------------------------------------------FShell_explodeAG PROC hb:DWORD    mov edi,hb    fld adg                    ; acceleration due to gravity    fld dword ptr[edi+AIR]     ; air resistance    add edi,SPARC    mov eax,nd    dec eax    shl eax,4@@:    fld dword ptr[edi+eax+4]   ; x velocity    fmul st(0),st(1)           ; deceleration by air    fst dword ptr[edi+eax+4]    fadd dword ptr[edi+eax]    ; x coordinate    fstp dword ptr[edi+eax]    fld dword ptr[edi+eax+12]  ; y velocity    fmul st(0),st(1)           ; deceleration by air    fadd st(0),st(2)           ; gravity    fst dword ptr[edi+eax+12]    fadd dword ptr[edi+eax+8]  ; y coordinate    fstp dword ptr[edi+eax+8]    sub eax,16    jnc @B    fcompp                     ; marks st(0) and st(1) empty    dec dword ptr[edi-SPARC]    mov eax,[edi-SPARC]        ; return(--life)    retFShell_explodeAG ENDP; -------------------------------------------------------------------------FShell_render PROC hb:DWORD, color:DWORD    LOCAL expx:DWORD, expy:DWORD    mov edi,hb    mov eax,[edi+EXX]    mov expx,eax    mov eax,[edi+EXY]    mov expy,eax    add edi,SPARC    mov ebx,color    dec ebx    ;and ebx,3    mov ecx,offset chemtable    mov edx,hFShells           ; floats are beautiful, and cheap source of    add edx,32                 ; the chemical used for multi colored fires    mov eax,CMode    or eax,eax    cmovz edx,ecx    mov edx,[edx+ebx*4]    mov ecx,nd    dec ecx    shl ecx,4    mov esi,bitmap1    push maxy                  ; using stack adds speed    push maxx                  ; (local variables)    push edx@@:    fld dword ptr[edi+ecx+4]    fabs    fld xcut                   ; low cost code for independant burnouts    fcomip st(0),st(1)    fistp dword ptr[esp-4]    jae forget    fld dword ptr[edi+ecx]    fistp dword ptr[esp-4]    fld dword ptr[edi+ecx+8]    fistp dword ptr[esp-8]    mov eax,[esp-8]    cmp eax,[esp+8]    jae forget    mov ebx,[esp-4]    cmp ebx,[esp+4]    jae forget    imul dword ptr[esp+4]    add eax,ebx    lea eax,[eax+eax*2]    mov edx,[esp]    mov [esi+eax],dx    shr edx,16    mov [esi+eax+2],dlforget:    sub ecx,16    jnc @B    ;add esp,12  'leave'ing (ENDP)    retFShell_render ENDP; -------------------------------------------------------------------------FShell_recycle PROC hb:DWORD, x:DWORD, y:DWORD    mov edi,hb    mov eax,x    mov [edi+EXX],eax    mov eax,y    mov [edi+EXY],eax    mov eax,x    mov lightx,eax             ; Light last one    mov eax,y    mov lighty,eax    mov eax,flash              ; having only one light source    add eax,3200               ; 3200 million jouls...!     mov flash,eax              ; add if previous lighting not extinguished    invoke random,20    inc eax    imul minlife    mov ebx,eax                ; sync explosions by mouse clicks with rest    mov eax,[edi]              ; by maintaining minimum delay of 'minlife'    xor edx,edx    idiv minlife    add edx,ebx    mov [edi],edx    invoke random,30           ; like its real world counterpart, creation process    add eax,10                 ; is long and boring but the end product is explodin..    mov [esp-4],eax            ; refer C++ source also. Most of the below area    mov eax,10000              ; is blind translation of that original C code    mov [esp-8],eax            ; i crawled on that code as a Human C compiler...!    fld1    fild dword ptr[esp-4]    fidiv dword ptr[esp-8]    fsubp st(1),st(0)    fstp dword ptr[edi+AIR]    add edi,SPARC    fild y    fild x    mov eax,1000    mov [esp-4],eax    fild dword ptr[esp-4]      ; 1000 (constant)    invoke random,maxpower    inc eax    mov [esp-4],eax    fild dword ptr[esp-4]      ; power    mov ecx,nd    dec ecx    shl ecx,4@@:    push ecx    invoke random,2000    mov [esp-4],eax    fild dword ptr[esp-4]    fsub st(0),st(2)    fdiv st(0),st(2)    fmul st(0),st(1)    mov ecx,[esp]    fstp dword ptr[edi+ecx+4]    fld st(0)    fmul st(0),st(0)    fld dword ptr[edi+ecx+4]    fmul st(0),st(0)    fsubp st(1),st(0)    fsqrt    invoke random,2000    mov [esp-4],eax    fild dword ptr[esp-4]    fsub st(0),st(3)    fdiv st(0),st(3)    fmulp st(1),st(0)    mov ecx,[esp]    fstp dword ptr[edi+ecx+12]    fld st(2)    fstp dword ptr[edi+ecx]    fld st(3)    fstp dword ptr[edi+ecx+8]    pop ecx    sub ecx,16    jnc @B    fcompp    fcompp    retFShell_recycle ENDP; -------------------------------------------------------------------------FireThread:    invoke SetThreadPriority,idThread1,THREAD_PRIORITY_HIGHEST    invoke GetDC,hwnd    mov wnddc,eax    invoke GetProcessHeap    mov hHeap,eax    invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,4194304    add eax,4096               ; blur: -1'th line problem    mov bitmap1,eax    invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,4194304    add eax,4096               ; blur: -1'th line problem    mov bitmap2,eax    mov eax,nd    shl eax,4    add eax,SPARC    mov sb,eax                 ; size of FShell = nd*16+8    imul nb                    ; array size   = nb*sb    invoke HeapAlloc,hHeap,HEAP_ZERO_MEMORY,eax    mov hFShells,eax    finit                      ; initialise floating point unit    mov ax,07fh                ; low precision floats    mov word ptr[esp-4],ax     ; fireworks... not space rockets    fldcw word ptr[esp-4]    sub ebp,12                 ; as 3 local variables    mov eax,nb    mov [ebp],eax    mov eax,hFShells    mov [ebp+4],eaxinitshells:    ;mov eax,maxx              ; naah... not needed    ;shr eax,1                 ; trusting auto-zero    ;invoke FShell_recycle,[ebp+4],eax,maxy    ;mov eax,sb    ;add [ebp+4],eax    ;dec dword ptr[ebp]    ;jnz initFShells    ;mov flash,6400lp1:    mov eax,motionQ    mov dword ptr[ebp+8],eaxlp2:    mov eax,nb    mov [ebp],eax    mov eax,hFShells    mov [ebp+4],eaxlp3:    invoke FShell_render,[ebp+4],[ebp]    mov eax,GMode    mov ecx,offset FShell_explodeAG    mov ebx,offset FShell_explodeOS    test eax,eax    cmovz ecx,ebx    push [ebp+4]    call ecx    test eax,eax    jns @F    invoke random,maxy    push eax    mov eax,maxx    add eax,eax    invoke random,eax    mov edx,maxx    shr edx,1    sub eax,edx    push eax    push [ebp+4]    call FShell_recycle@@:    mov eax,sb    add [ebp+4],eax    dec dword ptr[ebp]    jnz lp3    dec dword ptr[ebp+8]    jnz lp2    mov eax,EMode    test eax,eax    jz r1    mov eax,CMode              ; switch pre/post blur according to -    test eax,eax               ; current chemical in fire    jz @F    invoke Blur_MMX2@@:    invoke Light_Flash3,lightx,lighty,flash,bitmap1,bitmap2    invoke SetDIBitsToDevice,wnddc,0,0,maxx,maxy,           0,0,0,maxy,bitmap2,ADDR bminf,DIB_RGB_COLORS    mov eax,CMode    test eax,eax    jnz r2    invoke Blur_MMX2    jmp r2r1:    invoke SetDIBitsToDevice,wnddc,0,0,maxx,maxy,           0,0,0,maxy,bitmap1,ADDR bminf,DIB_RGB_COLORS    mov eax,maxx    imul maxy    lea eax,[eax+eax*2]    invoke RtlZeroMemory,bitmap1,eaxr2:    inc fcount                 ; count the frames    fild flash    fmul flfactor    fistp flash    invoke Sleep,5             ; control, if frames rate goes too high    mov eax,stop    test eax,eax    jz lp1    invoke ReleaseDC,hwnd,wnddc     invoke HeapFree,hHeap,0,bitmap1    invoke HeapFree,hHeap,0,bitmap2    invoke HeapFree,hHeap,0,hFShells    mov idThread1,-1    invoke ExitThread,2003    hlt                        ; ...! i8085 memories; -------------------------------------------------------------------------.data fps  db 64 dup (0) fmat db "fps = %u   [www.ronybc.8k.com]",0.codeMoniThread:    invoke Sleep,1000    invoke wsprintf,ADDR fps,ADDR fmat,fcount    invoke SetWindowText,hwnd,ADDR fps    xor eax,eax    mov fcount,eax    mov eax,stop    test eax,eax    jz MoniThread    mov idThread2,-1    invoke ExitThread,2003; -------------------------------------------------------------------------Switch PROC oMode:DWORD, iid:DWORD    xor eax,eax    mov edx,oMode    or al,byte ptr [edx]    setz  byte ptr [edx]    mov eax,[edx]    mov ebx,MF_CHECKED    shl eax,3    and eax,ebx    or eax,MF_BYCOMMAND    invoke CheckMenuItem,hmnu,iid,eax    retSwitch ENDP; -------------------------------------------------------------------------WndProc PROC hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM    .IF uMsg==WM_MOUSEMOVE &;& wParam==MK_CONTROL        xor edx,edx        mov flash,2400        mov eax,lParam        mov dx,ax        shr eax,16        mov lightx,edx        mov lighty,eax    .ELSEIF uMsg==WM_SIZE &;& wParam!=SIZE_MINIMIZED        xor edx,edx        mov eax,lParam        mov dx,ax        shr eax,16        shr edx,2        shl edx,2        mov maxx,edx        mov maxy,eax        mov bminf.bmiHeader.biWidth,edx        neg eax          ; -maxy        mov bminf.bmiHeader.biHeight,eax    .ELSEIF uMsg==WM_KEYDOWN &;& wParam==VK_SPACE        invoke Switch,OFFSET GMode,1200    .ELSEIF uMsg==WM_KEYDOWN &;& wParam==VK_RETURN        invoke Switch,OFFSET EMode,1220        mov flash,0    .ELSEIF uMsg==WM_RBUTTONDOWN        invoke MessageBox,hWnd,ADDR info,ADDR AppName,MB_OK or MB_ICONASTERISK    .ELSEIF uMsg==WM_LBUTTONDOWN        xor edx,edx        mov eax,lParam        mov dx,ax        shr eax,16        push eax        push edx        mov edx,nb        dec edx        mov eax,click        dec eax        cmovs eax,edx        mov click,eax        imul sb        add eax,hFShells        push eax        call FShell_recycle    .ELSEIF uMsg==WM_CLOSE        mov stop,1                  ; stop running threads        invoke Sleep,100            ; avoid FireThread drawing without window        invoke DestroyWindow,hwnd        invoke PostQuitMessage,0    .ELSEIF uMsg==WM_COMMAND       .IF wParam==1010        invoke SendMessage,hwnd,WM_CLOSE,0,0       .ELSEIF wParam==1000        invoke SuspendThread,hFThread ; suffering technical difiiculties :)        mov eax,maxx                  ; major motiv - to see ZeroMem in acion        imul maxy        lea eax,[eax+eax*2]        invoke RtlZeroMemory,bitmap1,eax ; this thing is fast,        invoke RtlZeroMemory,bitmap2,eax ; but hidden from some API docs        push nb        push hFShells    @@:         mov eax,maxx       ;shr eax,1         shr eax,2         mov edx,[esp+4]         dec edx         imul eax,edx        mov ebx,maxy        shr ebx,1        invoke FShell_recycle,[esp+8],eax,ebx        mov eax,sb        add [esp],eax        dec dword ptr[esp+4]        jnz @B        ;mov flash,6400        invoke ResumeThread,hFThread        pop eax        pop eax       .ELSEIF wParam==1200        invoke Switch,OFFSET GMode,1200       .ELSEIF wParam==1210        invoke Switch,OFFSET CMode,1210        mov ecx,CMode        mov eax,16        shr eax,cl        mov motionQ,eax        ; changing motionQ affects speed       .ELSEIF wParam==1220        invoke Switch,OFFSET EMode,1220        mov flash,0       .ELSEIF wParam==1300        invoke CheckMenuItem,hmnu,1310,MF_BYCOMMAND or MF_UNCHECKED        invoke CheckMenuItem,hmnu,1300,MF_BYCOMMAND or MF_CHECKED        mov minlife,500        ; long interval between shoots       .ELSEIF wParam==1310        invoke CheckMenuItem,hmnu,1300,MF_BYCOMMAND or MF_UNCHECKED        invoke CheckMenuItem,hmnu,1310,MF_BYCOMMAND or MF_CHECKED        mov minlife,100        ; short interval       .ELSEIF wParam==1400        invoke MessageBox,hWnd,ADDR info,ADDR AppName,MB_OK or MB_ICONASTERISK       .ENDIF    .ELSE        invoke DefWindowProc,hWnd,uMsg,wParam,lParam                ret    .ENDIF    xor eax,eax    retWndProc ENDP; -------------------------------------------------------------------------start:    invoke GetModuleHandle,NULL    mov hInstance,eax    mov wc.hInstance,eax    mov wc.cbSize,SIZEOF WNDCLASSEX    mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNCLIENT    mov wc.lpfnWndProc,OFFSET WndProc    mov wc.cbClsExtra,NULL    mov wc.cbWndExtra,NULL    mov wc.hbrBackground,COLOR_MENUTEXT    mov wc.lpszMenuName,NULL    mov wc.lpszClassName,OFFSET ClassName    invoke LoadCursor,NULL,IDC_ARROW    mov wc.hCursor,eax    invoke LoadIcon,hInstance,500    mov wc.hIcon,eax    mov wc.hIconSm,eax    invoke RegisterClassEx,ADDR wc    invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,ADDR ClassName,ADDR AppName,                          WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,                          CW_USEDEFAULT,wwidth,wheight,NULL,NULL,                          hInstance,NULL    mov hwnd,eax    add seed,eax          ;)    invoke LoadMenu,hInstance,600    mov hmnu,eax    invoke SetMenu,hwnd,eax    invoke CheckMenuItem,hmnu,1200,MF_BYCOMMAND or MF_CHECKED    invoke CheckMenuItem,hmnu,1220,MF_BYCOMMAND or MF_CHECKED    invoke CheckMenuItem,hmnu,1300,MF_BYCOMMAND or MF_CHECKED    invoke ShowWindow,hwnd,SW_SHOWNORMAL    invoke UpdateWindow,hwnd    invoke CreateThread,0,4096,ADDR MoniThread,0,0,ADDR idThread1    invoke CreateThread,0,4096,ADDR FireThread,0,0,ADDR idThread2    mov hFThread,eax    MsgLoop:        invoke GetMessage,ADDR msg,0,0,0        test eax,eax        jz EndLoop        invoke TranslateMessage,ADDR msg        invoke DispatchMessage,ADDR msg        jmp MsgLoop    EndLoop:    @@: mov eax,idThread1        or  eax,idThread2        not eax        and eax,eax        jnz @B    invoke ExitProcess,eaxend start
Testing..

// Ring, Complex, Polynomial// This program requires .NET version [2].[0]// Peter Sestoft (sestoft@dina.kvl.dk) * [2001]-[12]-[12]// Using an abstract class as constraint, recursive constraints// involving the class itself, a class as a constraint on a struct,// etc.// Alas, operators are static, and therefore cannot be specified in// interfaces or abstract classes.using System;interface Ring<E>   where E : Ring<E> {  E Zero();	// Lack of constructor or static specification  E Plus(E e);  E Times(E e);  E Negate();  E Minus(E e);}// A Ring adapter that saves us from defining Minus in subclassesabstract class RingC<E> : Ring<E>   where E : Ring<E> {  public abstract E Zero();  public abstract E Plus(E e);  public abstract E Times(E e);  public abstract E Negate();  public E Minus(E e) {    return this.Plus(e.Negate());  }}// The complex numbersstruct Complex : Ring<Complex> {   private double re, im;  public Complex(double re, double im) {    this.re = re; this.im = im;  }  public Complex Zero() {    return new Complex([0].[0], [0].[0]);  }  public Complex Plus(Complex that) {    return new Complex(re + that.re, im + that.im);  }  public Complex Negate() {    return new Complex(-re, -im);  }  public Complex Minus(Complex that) {    return new Complex(re - that.re, im - that.im);  }  public Complex Conjugate() {    return new Complex(re, -im);  }  public Complex Times(Complex that) {    return new Complex(re * that.re - im * that.im, 		       im * that.re + re * that.im);   }  public static Complex operator +(Complex z[1], Complex z[2]) {    return z[1].Plus(z[2]);  }  public static Complex operator *(Complex z[1], Complex z[2]) {    return z[1].Times(z[2]);  }  public static Complex operator *(Complex z, double r) {    return new Complex(z.re * r, z.im * r);  }  public static Complex operator *(double r, Complex z) {    return new Complex(z.re * r, z.im * r);  }  public static Complex operator -(Complex z[1]) {    return z[1].Negate();  }  public static Complex operator ~(Complex z[1]) {    return z[1].Conjugate();  }}// The ring of polynomialsclass Polynomial<E> : RingC< Polynomial<E>>   where E : Ring<E> {   // Coefficients of x^[0], x^[1], ...; absent coefficients are zero.  // Invariant: cs != null && cs.Length >= [1], so cs[[0]].Zero() is a zero for E.  private readonly E[] cs;      public Polynomial(E[] cs) {	    this.cs = cs;  }  public Polynomial(E s) : this(new E[] { s }) { }	// Constant s  public override Polynomial<E> Zero() {    return new Polynomial<E>(cs[[0]].Zero());  }  public override Polynomial<E> Plus(Polynomial<E> that) {    int newlen = Math.Max(this.cs.Length, that.cs.Length);    int minlen = Math.Min(this.cs.Length, that.cs.Length);    E[] newcs = new E[newlen];    if (this.cs.Length <= that.cs.Length) {      for (int i=[0]; i<minlen; i++)	newcs = this.cs.Plus(that.cs);      for (int i=minlen; i<newlen; i++)	newcs = that.cs;    } else {      for (int i=[0]; i<minlen; i++)	newcs = this.cs.Plus(that.cs);      for (int i=minlen; i<newlen; i++)	newcs = this.cs;    }    return new Polynomial<E>(newcs);  }  public override Polynomial<E> Times(Polynomial<E> that) {    int newlen = Math.Max([1], this.cs.Length + that.cs.Length - [1]);    E[] newcs = new E[newlen];    E zero = cs[[0]].Zero();    for (int i=[0]; i<newlen; i++) {      E sum = zero.Zero();      int start = Math.Max([0], i-that.cs.Length+[1]);      int stop  = Math.Min(i, this.cs.Length-[1]);      for (int j=start; j<=stop; j++) {	// assert [0]<=j && j<this.cs.Length && [0]<=i-j && i-j<that.cs.Length;	sum = sum.Plus(this.cs[j].Times(that.cs[i-j]));      }      newcs = sum;    }    return new Polynomial<E>(newcs);  }  public override Polynomial<E> Negate() {    int newlen = cs.Length;    E[] newcs = new E[newlen];    for (int i=[0]; i<newlen; i++)      newcs = cs.Negate();    return new Polynomial<E>(newcs);  }  public static Polynomial<E> operator + (Polynomial<E> p[1], 					  Polynomial<E> p[2]) {    return p[1].Plus(p[2]);  }  public static Polynomial<E> operator + (Polynomial<E> p[1], E s) {    return p[1] + new Polynomial<E>(s);  }  public static Polynomial<E> operator * (Polynomial<E> p[1], 					  Polynomial<E> p[2]) {    return p[1].Times(p[2]);  }  public static Polynomial<E> operator * (Polynomial<E> p[1], E s) {    return p[1].Times(new Polynomial<E>(s));  }  public static Polynomial<E> operator * (E s, Polynomial<E> p[1]) {    return new Polynomial<E>(s).Times(p[1]);  }  public static Polynomial<E> operator - (Polynomial<E> p[1]) {    return p[1].Negate();  }  public E Evaluate(E x) {    E res = x.Zero();    for (int i=cs.Length-[1]; i>=[0]; i--)      res = res.Times(x).Plus(cs);    return res;  }  public E this[E e] {    get { return Evaluate(e); }  }}// Trying itclass TestRing {   static void Main(string[] args) {    Complex one = new Complex([1].[0], [0].[0]);    Complex i = new Complex([0].[0], [1].[0]);    Polynomial<Complex> p[1] =       new Polynomial<Complex>(new Complex[] { one, i * [2].[0], i });    Polynomial<Complex> p[2], p[3];    p[2] = p[1] * new Complex([7].[0], [0].[0]) + p[1] * p[1];    p[3] = new Polynomial<Complex>(new Complex([0], [0]));    p[3] += p[2];    p[3] += new Complex([6].[0], [0].[0]) * p[2];  }}

This topic is closed to new replies.

Advertisement