home *** CD-ROM | disk | FTP | other *** search
- // ------------------------------------------------------------------
- // File: ASMINC.CPP
- // Path: ...\REHACK\GENERAL\ASMINC.CPP
- // Version: 0.01
- // Author: Pat Reilly
- // CIS Id: 71333,2764
- // Created On: 6/26/93
- // Modified On:
- // Description: This program goes through the base classes for REHACK and
- // prints (to STDOUT) an assembly .INC format which has the proper
- // offsets to difference class members and constants. For instance,
- // an equate is printed for the bool enum (see TYPES.HPP) like:
- // bool equ <N>
- // where <N> is sizeof(bool). Also the Point class' members will
- // have entries:
- // PointX equ <X>
- // PointY equ <Y>
- // Whenever new classes are added, or existing ones modified, the
- // class should have void makeInc() declared as a friend (so it can
- // access protected members) and members and constants should be
- // added to the makeInc() function so that they can be included in
- // this output.
- //
- // To use this program, just compile it, then execute it, using
- // DOS' redirection to send the output to the file REHACK.INC.
- // asminc > rehack.inc
- //
- // All REHACK assembly modules that require information from the
- // rest of the classes should INCLUDE rehack.inc.
- //
- // The member information is the offset to that member from a base
- // address. For example; if you have a Point instance which has an
- // address stored in DS:BX, then the offset to the 'x' member would
- // be:
- // mov [bx+PointX], 4
- // mov [bx+PointY], 3
- // This example will set the Point to (4,3).
- // Tabs: 4
- // ------------------------------------------------------------------
-
-
- #include "..\GENERAL\TYPES.HPP"
- #include "..\GENERAL\MISC.HPP"
- #include "..\EVENT\EVENT.HPP"
- #include "..\EVENT\EVENTQ.HPP"
- #include "..\WINDOW\WINDOW.HPP"
- #include <stdio.h>
- #include <stddef.h>
-
- // This file creates an asm .INC file for REHACK. When building the program,
- // this program should be executed so that the offsets within structures
- // are correct for the asm files.
-
-
- // Function makeEquate
- //
- // This function accepts a string name, and an unsigned value for its
- // offset within a class/structure, and prints it to STDOUT (cout). Output
- // format is:
- // <name> equ <ofs>
-
- void makeEquate(const char* name, unsigned ofs)
- {
- printf("%-30s equ %u\n", name, ofs);
- }
-
- // Function makeEquateStr
- //
- // This function accepts 2 strings and prints them as an equate:
- // <name> equ <str>
-
- void makeEquateStr(const char* name, const char* str)
- {
- printf("%-30s equ %-s\n", name, str);
- }
-
- // Function makeCommentStr
- //
- // This function accepts a string and prints it as a comment:
- // ; <str>
-
- void makeCommentStr(const char* str)
- {
- printf("; %s\n", str);
- }
-
- // Function makeSpace
- //
- // This function prints a newline.
-
- void makeSpace()
- {
- printf("\n");
- }
-
- // Function makeHeader
- // Prints a standard REHACK header.
-
- void makeHeader()
- {
- printf("; File: REHACK.INC\n");
- printf("; Path: ..\\GENERAL\\REHACK.INC\n");
- printf("; Version: 0.01\n");
- printf("; Author: Generated by ASMINC.EXE\n");
- printf("; CIS Id: Not applicable\n");
- printf("; Created on: " __DATE__ "\n");
- printf("; Modified on:\n");
- printf("; Description: INCLUDE file for all .ASM modules\n");
- printf("; Tabs: None.\n");
- }
-
- // Macro makeMember
- // Takes a Name (should NOT be enclosed in quotes), a class, and a member of
- // that class and calls makeEquate to print an equate that equates the offset
- // to that member to Name.
-
- #define makeMember(Name, Class, Member) makeEquate(#Name, offsetof(Class, Member))
-
- // Macro makeConstant
- // Takes a Name (should NOT be enclosed in quotes) and calls makeEquate to
- // equate the constant's value to its name.
-
- #define makeConstant(Name) makeEquate(#Name, Name)
-
- // Macro makeComment
- // Takes a Str (should NOT be enclosed in quotes) and calls makeCommentStr
- // to print it out as a comment.
-
- #define makeComment(Str) makeCommentStr(#Str)
-
- // Function makeInc
- //
- // This function prints a list of equates, comments and newlines for
- // inclusion in REHACK .asm files.
-
- void makeInc()
- {
- // Print REHACK header.
- makeHeader();
-
- // TYPES.HPP
- makeSpace();
- makeComment(TYPES.HPP);
- makeSpace();
-
- makeEquateStr("bool", (sizeof(bool) == sizeof(char)) ? "DB" : "DW");
- makeConstant(false);
- makeConstant(true);
-
- // MISC.HPP
- makeSpace();
- makeComment(MISC.HPP);
- makeSpace();
-
- makeMember(PointX, Point, x);
- makeMember(PointY, Point, y);
-
- makeMember(RectTopLeftX, Rect, topLeft.x);
- makeMember(RectTopLeftY, Rect, topLeft.y);
- makeMember(RectBottomRightX, Rect, bottomRight.x);
- makeMember(RectBottomRightY, Rect, bottomRight.y);
-
- // EVENT.HPP
- makeSpace();
- makeComment(EVENT.HPP);
- makeSpace();
-
- makeConstant(LeftBtn);
- makeConstant(RightBtn);
- makeConstant(CenterBtn);
-
- makeMember(PosDeviceEventButtons, PosDeviceEvent, buttons);
- makeMember(PosDeviceEventDblClicked, PosDeviceEvent, dblClicked);
- makeMember(PosDeviceEventLocation, PosDeviceEvent, location);
-
- makeMember(KeyCodeCode, KeyCode, code);
- makeMember(KeyCodeScan, KeyCode, scan);
-
- makeMember(KeyEventValue, KeyEvent, value);
- makeMember(KeyEventCharScan, KeyEvent, charScanValue);
-
- makeMember(MsgEventId, MsgEvent, id);
- makeMember(MsgEventPointer, MsgEvent, pointerValue);
- makeMember(MsgEventLong, MsgEvent, longValue);
- makeMember(MsgEventShort, MsgEvent, shortValue);
- makeMember(MsgEventPoint, MsgEvent, pointValue);
-
- makeConstant(IdNull);
- makeConstant(IdCancel);
- makeConstant(IdQuit);
-
- makeConstant(PosDeviceBtnDown);
- makeConstant(PosDeviceBtnUp);
- makeConstant(PosDeviceMove);
- makeConstant(PosDevice);
- makeConstant(KeyDown);
- makeConstant(KeyUp);
- makeConstant(Key);
- makeConstant(Broadcast);
- makeConstant(Message);
-
- makeMember(EventType, Event, type);
- makeMember(EventTicks, Event, ticks);
- makeMember(EventPosDevice, Event, posDevice);
- makeMember(EventKey, Event, key);
- makeMember(EventMsg, Event, msg);
-
- // EVENTQ.HPP
- makeSpace();
- makeComment(EVENTQ.HPP);
- makeSpace();
-
- makeConstant(StdEventQueueSize);
-
- makeMember(EventQueueBuffer, EventQueue, buffer);
- makeMember(EventQueueHead, EventQueue, head);
- makeMember(EventQueueTail, EventQueue, tail);
-
- // WINDOW\WINDOW.HPP
- makeSpace();
- makeComment(WINDOW.HPP);
- makeSpace();
-
- makeConstant(vfVisible);
- makeConstant(vfFocused);
- makeConstant(vfDisabled);
- makeConstant(vfModal);
- makeConstant(vfFocusable);
- makeConstant(vfPassFirstClick);
-
- makeMember(VisibleBounds, Visible, bounds);
- makeMember(VisibleFlags, Visible, flags);
- makeMember(VisibleOwner, Visible, owner);
- makeMember(VisibleNext, Visible, next);
- makeMember(VisibleModalReturnValue, Visible, modalReturnValue);
-
- makeMember(WindowBottomObj, Window, bottomObject);
- makeMember(WindowCurrentObj, Window, currentObject);
-
- // GAME\GAME.HPP
- makeSpace();
- makeComment(GAME.HPP);
- makeSpace();
- }
-
- int main()
- {
- makeInc();
- return 0;
- }
-