1 /* $Id: macro.c,v 1.3 2004-12-19 14:52:48 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Routines for recording/playing/saving macros
23 static char rcsid[] = "$Id: macro.c,v 1.3 2004-12-19 14:52:48 btb Exp $";
52 #define MAX_NUM_EVENTS 10000
54 UI_EVENT * RecordBuffer;
56 int MacroNumEvents = 0;
59 static char filename[128] = "*.MIN";
63 if ( MacroStatus== UI_STATUS_NORMAL )
65 if (RecordBuffer) free( RecordBuffer );
66 MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
67 ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_MOUSE | UI_RECORD_KEYS );
68 MacroStatus = UI_STATUS_RECORDING;
75 if ( MacroStatus== UI_STATUS_NORMAL )
77 if (RecordBuffer) free( RecordBuffer );
78 MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
79 ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_KEYS );
80 MacroStatus = UI_STATUS_RECORDING;
87 if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
89 ui_set_playback_speed( 1 );
90 ui_play_events_realtime(MacroNumEvents, RecordBuffer);
91 MacroStatus = UI_STATUS_PLAYING;
98 if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
101 ui_play_events_fast(MacroNumEvents, RecordBuffer);
102 MacroStatus = UI_STATUS_FASTPLAY;
110 if (MacroNumEvents < 1 )
112 MessageBox( -2, -2, 1, "No macro has been defined to save!", "Oops" );
116 if (ui_get_filename( filename, "*.MAC", "SAVE MACRO" )) {
117 RecordBuffer[0].type = 7;
118 RecordBuffer[0].frame = 0;
119 RecordBuffer[0].data = MacroNumEvents;
120 WriteFile( filename, RecordBuffer, sizeof(UI_EVENT)*MacroNumEvents );
129 if (ui_get_filename( filename, "*.MAC", "LOAD MACRO" )) {
130 if (RecordBuffer) free( RecordBuffer );
131 RecordBuffer = (UI_EVENT *)ReadFile( filename, &length );
132 MacroNumEvents = RecordBuffer[0].data;
137 void macro_free_buffer()
146 char * MenuItems[] = { "Play fast",
153 x = MenuX( -1, -1, 6, MenuItems );