killgbl.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* $Id$
  2. * MegaZeux
  3. *
  4. * Copyright (C) 1996 Greg Janson
  5. * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <stdio.h>
  22. struct Robot {
  23. unsigned int program_length;
  24. unsigned int program_location;//Offsetted from start of global robot memory
  25. char robot_name[15];
  26. unsigned char robot_char;
  27. unsigned int cur_prog_line;//Location of start of line (pt to FF for none)
  28. unsigned char pos_within_line;//Countdown for GO and WAIT
  29. unsigned char robot_cycle;
  30. unsigned char cycle_count;
  31. unsigned char bullet_type;
  32. unsigned char is_locked;
  33. unsigned char can_lavawalk;//Can always travel on fire
  34. unsigned char walk_dir;//1-4, of course
  35. unsigned char last_touch_dir;//1-4, of course
  36. unsigned char last_shot_dir;//1-4, of course
  37. int xpos,ypos;//Used for IF ALIGNED "robot", THISX/THISY, PLAYERDIST,
  38. //HORIZPLD, VERTPLD, and others. Keep udpated at all
  39. //times. Set to -1/-1 for global robot.
  40. char status;//0=Un-run yet, 1=Was run but only END'd, WAIT'd, or was
  41. //inactive, 2=To be re-run on a second robot-run due to a
  42. //rec'd message
  43. int blank;//Always 0
  44. char used;//Set to 1 if used onscreen, 0 if not
  45. int loop_count;//Loop count. Loops go back to first seen LOOP
  46. //START, loop at first seen LOOP #, and an ABORT
  47. //LOOP jumps to right after first seen LOOP #.
  48. } glorob;
  49. //Take a .MZX file (UN-pw-protected) and delete any global robot
  50. void main(int argc,char **argv) {
  51. int t1,t2;
  52. if(argc<2) {
  53. printf("\n\nUsage: KILLGBL FILE.MZX\nThis will totally eradicate the global robot from a .MZX file.\n\n\a");
  54. return;
  55. }
  56. printf("\n\nDeleting the global robot in %s... (WARNING!: No error checks performs!)\n\n",argv[1]);
  57. FILE *fp=fopen(argv[1],"rb+");
  58. //find location
  59. fseek(fp,4230,SEEK_SET);
  60. long where;
  61. fread(&where,1,4,fp);
  62. fseek(fp,where,SEEK_SET);
  63. fread(&glorob,1,sizeof(Robot),fp);
  64. t1=glorob.program_location;
  65. for(t2=0;t2<sizeof(Robot);t2++) {
  66. ((char far *)(&glorob))[t2]=0;
  67. }
  68. glorob.program_length=2;
  69. glorob.robot_cycle=1;
  70. glorob.program_location=t1;
  71. glorob.cur_prog_line=1;
  72. glorob.robot_char=2;
  73. glorob.bullet_type=1;
  74. fseek(fp,where,SEEK_SET);
  75. fwrite(&glorob,1,sizeof(Robot),fp);
  76. fputc(0xFF,fp);
  77. fputc(0x00,fp);
  78. fclose(fp);
  79. }