edit.cpp 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408
  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. //Password completely removed -Koj
  22. //Took out SMZX -Koji
  23. //Editing the world!
  24. #include "helpsys.h"
  25. #include "runrobot.h"
  26. #include "scrdisp.h"
  27. #include "scrdump.h"
  28. #include "sfx.h"
  29. #include "sfx_edit.h"
  30. #include "counter.h"
  31. #include "game.h"
  32. #include "fill.h"
  33. #include "meter.h"
  34. //#include "password.h"
  35. #include "egacode.h"
  36. #include "block.h"
  37. #include "pal_ed.h"
  38. #include "char_ed.h"
  39. #include "edit_di.h"
  40. #include "beep.h"
  41. #include "boardmem.h"
  42. #include "intake.h"
  43. #include "mod.h"
  44. #include "param.h"
  45. #include "error.h"
  46. #include "idarray.h"
  47. #include "ems.h"
  48. #include "meminter.h"
  49. #include "cursor.h"
  50. #include "retrace.h"
  51. #include "string.h"
  52. #include "edit.h"
  53. #include "ezboard.h"
  54. #include "data.h"
  55. #include "const.h"
  56. #include "graphics.h"
  57. #include "window.h"
  58. #include "getkey.h"
  59. #include "palette.h"
  60. #include "idput.h"
  61. #include "hexchar.h"
  62. #include <dos.h>
  63. #include "roballoc.h"
  64. #include "saveload.h"
  65. #include <stdio.h>
  66. #include "blink.h"
  67. #include "cursor.h"
  68. #include "counter.h"
  69. /* Edit menu- (w/box ends on sides) Current menu name is highlighted. The
  70. bottom section zooms to show a list of options for the current menu,
  71. although all keys are available at all times. PGUP/PGDN changes menu.
  72. The menus are shown in listed order. [draw] can be [text]. (in which case
  73. there is the words "Type to place text" after the ->) [draw] can also be
  74. [place] or [block]. The options DRAW, TEXT, DEBUG, BLOCK, MOD, and DEF.
  75. COLORS are highlighted white (instead of green) when active. Debug mode
  76. pops up a small window in the lower left corner, which rushes to the right
  77. side and back when the cursor reaches 3/4 of the way towards it,
  78. horizontally. The menu itself is 15 lines wide and 7 lines high. The
  79. board display, w/o the debug menu, is 19 lines high and 80 lines wide.
  80. Note: SAVE is highlighted white if the world has changed since last load
  81. or save.
  82. The commands with ! instead of : have not been implemented yet.
  83. The menu line turns to "Overlay editing-" and the lower portion shows
  84. overlay commands on overlay mode.
  85. ÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  86. X/Y: 99/99³
  87. Board: 000³
  88. Mem: 0000k³
  89. EMS: 0000k³
  90. Robot memory-³
  91. 64.0/64k 100%³
  92. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  93. WORLD BOARD THING CURSOR SHOW MISC Drawing:_!_ (_#_ PushableRobot p00)
  94. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  95. L:Load S:Save G:Global Info Alt+R:Restart Alt+T:Test *:Protection
  96. Alt+S:Status Info Alt+C:Char Edit Alt+E:Palette Alt+F:Sound Effects
  97. Alt+Z:Clear X:Exits Alt+P:Size/Pos I:Info A:Add D:Delete V:View
  98. Alt+I:Import Alt+X:Export B:Select Board Alt+O:Edit Overlay
  99. F3:Terrain F4:Item F5:Creature F6:Puzzle F7:Transport F8:Element
  100. F9:Misc F10:Objects P:Parameter C:Color
  101. :Move Space:Place Enter:Modify+Grab Alt+M:Modify Ins:Grab Del:Delete
  102. F:Fill Tab:Draw F2:Text Alt+B:Block Alt+:Move 10
  103. Shift+F1:Show InvisWalls Shift+F2:Show Robots Shift+F3:Show Fakes
  104. Shift+F4:Show Spaces
  105. F1!Help R:Redraw Screen Alt+A:Select Char Set Alt+D:Default Colors
  106. ESC:Exit Alt+L:Test SAM Alt+Y:Debug Mode Alt+N:Music
  107. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄPgup/Pgdn:MenuÄ
  108. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  109. OVERLAY EDITING- (Alt+O to end) Current:_!_ (_#_ Character p00)
  110. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  111. :Move Space:Place Ins:Grab Enter:Character Del:Delete F:Fill
  112. C:Color Alt+B:Block Tab:Draw Alt+:Move 10 Alt+S:Show level F2:Text
  113. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  114. Undocumented keys:
  115. End: LR corner
  116. Home: UL corner
  117. ESC: Cancel mode/overlay mode if active (otherwise exit)
  118. Backspace: Delete (move left one in text)
  119. Alt+W: redraw screen
  120. */
  121. /* Editing data */
  122. int draw_mode=0;//1 for on, 2 for text, 3 for block, 4 for block place.
  123. //+128 for overlay.
  124. int curr_color=7,curr_thing=0,curr_param=0;//Current. Param 0 for robot/etc
  125. //is temp. storage to be deleted
  126. //or realigned upon first
  127. //placement. Other params mean
  128. //to copy on placement.
  129. char curr_menu=0;//Current menu, 0 thru 5.
  130. char def_color_mode=1;//If default colors are on.
  131. char debug_mode=0,debug_x=0;//If debug mode is on, and X position of box.
  132. int x_pos=0,y_pos=0;//Current screen cursor position.
  133. int x_top_pos=0,y_top_pos=0;//Current x/y position in array of screen
  134. #define ARRAY_X (x_pos+x_top_pos)
  135. #define ARRAY_Y (y_pos+y_top_pos)
  136. #define ARRAY_OFFS (ARRAY_X+ARRAY_Y*max_bxsiz)
  137. char changed=0;//Whether world has changed since a load or save.
  138. //Whether to update menu and/or view, whether to fade in
  139. char update_menu=1,fade_in=1,update_view=1;
  140. //Remembers one corner of a block cmd or the starting position for a text cmd
  141. int save_x,save_y;
  142. int save_x2,save_y2;
  143. char blk_cmd;
  144. //Whether to show non-overlay when editing overlay
  145. char show_level=1;
  146. /* Menu data */
  147. #define NUM_MENUS 6
  148. char far menu_names[NUM_MENUS][9]={
  149. " WORLD "," BOARD "," THING "," CURSOR "," SHOW "," MISC " };
  150. char far draw_names[6][10]={ " Current:"," Drawing:"," Text:"," Block:",
  151. " Block:"," Import:" };
  152. char far text_help[19]="Type to place text";
  153. char far block_help[28]="Press ENTER on other corner";
  154. char far block_help2[27]="Press ENTER to place block";
  155. char far block_help3[26]="Press ENTER to place ANSi";
  156. char far menu_help[15]="Pgup/Pgdn:Menu";
  157. char far *menu_lines[NUM_MENUS][2]={ {
  158. " L:LoadS:Save G:Global Info Alt+R:Restart Alt+T:Test",
  159. " Alt+S:Status Info Alt+C:Char Edit Alt+E:Palette Alt+F:Sound Effects"
  160. } , {
  161. " Alt+Z:Clear X:Exits Alt+P:Size/Pos I:Info A:Add D:Delete V:View",
  162. " Alt+I:Import Alt+X:Export B:Select Board Alt+O:Edit Overlay"
  163. } , {
  164. " F3:Terrain F4:Item F5:Creature F6:Puzzle F7:Transport F8:Element",
  165. " F9:MiscF10:Objects P:Parameter C:Color"
  166. } , {
  167. " :Move Space:Place Enter:Modify+Grab Alt+M:Modify Ins:Grab Del:Delete",
  168. " F:Fill Tab:DrawF2:Text Alt+B:Block Alt+:Move 10"
  169. } , {
  170. " Shift+F1:Show InvisWalls Shift+F2:Show Robots Shift+F3:Show Fakes",
  171. " Shift+F4:Show Spaces"
  172. } , {
  173. " F1:Help R:Redraw Screen Alt+A:Select Char Set Alt+D:Default Colors",
  174. " ESC:Exit Alt+L:Test SAM Alt+Y:Debug Mode Alt+N:Music Alt+8:Mod *"
  175. } };
  176. int far menu_keys[NUM_MENUS+1][2][28]={ {
  177. { 6,'L',5,0,6,'S',2,0,13,'G',4,0,13,-19,2,0,10,-20,2,0,12,'*',2,0 },
  178. { 17,-31,2,0,15,-46,2,0,13,-18,2,0,19,-33,7,0 }
  179. },{
  180. { 11,-44,3,0,7,'X',7,0,14,-25,2,0,6,'I',2,0,5,'A',2,0,8,'D',2,0,6,'V',2,0 },
  181. { 12,-23,2,0,12,-45,2,0,14,'B',2,0,18,-24,2,0 }
  182. },{
  183. { 10,-61,2,0,7,-62,6,0,11,-63,2,0,9,-64,2,0,12,-65,2,0,10,-66,4,0 },
  184. { 7,-67,5,0,11,-68,2,0,11,'P',2,0,7,'C',32,0 }
  185. },{
  186. { 9,0,11,' ',2,0,17,13,2,0,12,-50,2,0,8,-82,2,0,10,-83,2,0 },
  187. { 6,'F',3,0,8,9,5,0,7,-60,12,0,11,-48,22,0 }
  188. },{
  189. { 24,-84,2,0,20,-85,2,0,19,-86,10,0 },
  190. { 20,-87,57,0 }
  191. },{
  192. { 7,-59,4,0,15,'R',2,0,21,-30,2,0,20,-32,6,0 },
  193. { 8,27,3,0,14,-38,3,0,16,-21,7,0,11,-49,15,0 }
  194. },{
  195. { 9,0,11,' ',2,0,8,-82,2,0,15,13,2,0,10,-83,8,0,6,'F',4,0 },
  196. { 7,'C',2,0,11,-48,2,0,8,9,19,0,16,-31,2,0,7,-60,3,0 } } };
  197. char far *overlay_menu_lines[4]={
  198. " OVERLAY EDITING- (Alt+O to end)",
  199. " :Move Space:Place Ins:Grab Enter:Character Del:Delete F:Fill",
  200. " C:Color Alt+B:Block Tab:Draw Alt+:Move 10 Alt+S:Show level F2:Text",
  201. "Character" };
  202. void add_ext(char far *str,char far *ext) {
  203. int t1,t2=str_len(str);
  204. //check for existing ext.
  205. for(t1=0;t1<t2;t1++)
  206. if(str[t1]=='.') break;
  207. if(t1<t2) return;
  208. str[8]=0;//Limit main filename section to 8 chars
  209. str_cat(str,ext);
  210. }
  211. void edit_world(void) {
  212. int t1,t2,t3,t4,t5,t6,t7,t8,t9,t0;
  213. int key;
  214. char temp[20];
  215. char ansi[15];
  216. long tlong1,tlong2;
  217. char r,g,b;
  218. FILE *fp;
  219. set_context(80);
  220. error_mode=0;
  221. //Clear world on entrance
  222. clear_world();
  223. clear_zero_objects();
  224. scroll_color=15;
  225. scroll_base_color=143;
  226. scroll_corner_color=135;
  227. scroll_pointer_color=128;
  228. scroll_title_color=143;
  229. scroll_arrow_color=142;
  230. //Setup most variables
  231. draw_mode=curr_thing=curr_param=curr_menu=x_pos=y_pos=changed=
  232. x_top_pos=y_top_pos=0;
  233. curr_color=update_menu=fade_in=7;
  234. show_level=1;
  235. debug_x=65;
  236. //Set page
  237. current_page=0;
  238. current_pg_seg=VIDEO_SEG;
  239. //Clear screen
  240. clear_screen(1824,current_pg_seg);
  241. m_show();
  242. //Normally cursor is moved right after key interpretation.
  243. move_cursor(x_pos,y_pos);
  244. cursor_solid();
  245. do {
  246. //If NOTHING was changed, do NOT page flip
  247. set_counter("HELP_MENU",1);
  248. if(!(update_view|update_menu|fade_in)) {
  249. m_hide();
  250. goto no_pflip;
  251. }
  252. //Pre-page flip
  253. current_pg_seg=VIDEO_NUM2SEG(!current_page);
  254. //Draw view OR copy view from old page
  255. if(update_view) {
  256. //Fill area to blot out overflow
  257. fill_line(1520,0,0,EC_NA_FILL*256+177,current_pg_seg);
  258. if(draw_mode<128) {
  259. overlay_mode|=128;
  260. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  261. overlay_mode&=~128;
  262. }
  263. else {
  264. //ALWAYS shown as a normal overlay.
  265. t1=overlay_mode;
  266. overlay_mode=1;
  267. if(!show_level) overlay_mode|=64;
  268. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  269. overlay_mode=t1;
  270. }
  271. //Highlight block, if any
  272. if((draw_mode&127)==3) {
  273. //From t1/t2 to t3/t4
  274. t1=save_x;
  275. t2=save_y;
  276. t3=ARRAY_X;
  277. t4=ARRAY_Y;
  278. if(t3<t1) {
  279. t5=t1;
  280. t1=t3;
  281. t3=t5;
  282. }
  283. if(t4<t2) {
  284. t5=t2;
  285. t2=t4;
  286. t4=t5;
  287. }
  288. //Offset by xy_top_pos
  289. t1-=x_top_pos;
  290. t2-=y_top_pos;
  291. t3-=x_top_pos;
  292. t4-=y_top_pos;
  293. //Clip to screen
  294. if(t1<0) t1=0;
  295. if(t2<0) t2=0;
  296. if(t3>79) t3=79;
  297. if(t4>18) t4=18;
  298. //t3 becomes WIDTH
  299. t3=t3-t1+1;
  300. //Highlight block
  301. for(;t2<=t4;t2++)
  302. color_line(t3,t1,t2,159,current_pg_seg);
  303. }
  304. }
  305. else {
  306. //Copy 19 lines of 80 chars of 2 bytes each.
  307. m_hide();
  308. mem_cpy((char far *)MK_FP(current_pg_seg,0),
  309. (char far *)MK_FP(VIDEO_NUM2SEG(current_page),0),3040);
  310. m_show();
  311. }
  312. //Draw menu (draw debug if view updated)
  313. if(update_menu|update_view) {
  314. if(debug_mode) {
  315. draw_debug_box();
  316. update_view=0;
  317. }
  318. //Draw box
  319. if(update_menu) {
  320. draw_window_box(0,19,79,24,current_pg_seg,EC_MAIN_BOX,
  321. EC_MAIN_BOX_DARK,EC_MAIN_BOX_CORNER,0);
  322. draw_window_box(0,21,79,24,current_pg_seg,EC_MAIN_BOX,
  323. EC_MAIN_BOX_DARK,EC_MAIN_BOX_CORNER,0);
  324. draw_char(196,EC_MAIN_BOX_CORNER,78,21,current_pg_seg);
  325. draw_char(217,EC_MAIN_BOX_DARK,79,21,current_pg_seg);
  326. //Write menu names
  327. if(draw_mode<128) {
  328. t3=1;//X position
  329. for(t1=0;t1<NUM_MENUS;t1++) {
  330. t2=EC_MENU_NAME;//Pick the color
  331. if(t1==curr_menu) t2=EC_CURR_MENU_NAME;
  332. //Write it
  333. write_string(menu_names[t1],t3,20,t2,current_pg_seg);
  334. //Add to x
  335. t3+=str_len(menu_names[t1]);
  336. }
  337. }
  338. else {
  339. write_string(overlay_menu_lines[0],1,20,EC_MENU_NAME,
  340. current_pg_seg);
  341. t3=42;
  342. }
  343. //Write mode string
  344. write_string(draw_names[draw_mode&127],t3,20,EC_MODE_STR,current_pg_seg);
  345. t3+=str_len(draw_names[draw_mode&127]);
  346. //Write help or current thing
  347. if((draw_mode&127)==2) write_string(text_help,t3,20,EC_MODE_HELP,
  348. current_pg_seg);
  349. else if((draw_mode&127)==3) write_string(block_help,t3,20,EC_MODE_HELP,
  350. current_pg_seg);
  351. else if((draw_mode&127)==4) write_string(block_help2,t3,20,EC_MODE_HELP,
  352. current_pg_seg);
  353. else if((draw_mode&127)==5) write_string(block_help3,t3,20,EC_MODE_HELP,
  354. current_pg_seg);
  355. else {
  356. //Current thing
  357. draw_char(' ',7,t3,20,current_pg_seg);
  358. draw_char(' ',7,t3+2,20,current_pg_seg);
  359. //Use id_put
  360. if(draw_mode<128) {
  361. t1=level_id[0];
  362. t2=level_color[0];
  363. t4=level_param[0];
  364. t5=level_under_color[0];
  365. level_id[0]=curr_thing;
  366. level_color[0]=curr_color;
  367. level_param[0]=curr_param;
  368. level_under_color[0]=0;
  369. overlay_mode|=128;
  370. id_put(t3+1,20,0,0,0,0,current_pg_seg);
  371. overlay_mode&=~128;
  372. level_id[0]=t1;
  373. level_color[0]=t2;
  374. level_param[0]=t4;
  375. level_under_color[0]=t5;
  376. }
  377. else draw_char(curr_param,curr_color,t3+1,20,current_pg_seg);
  378. //Space and '('
  379. t3+=4;
  380. draw_char('(',EC_CURR_THING,t3++,20,current_pg_seg);
  381. //Color symbol
  382. draw_color_box(curr_color,0,t3,20,current_pg_seg);
  383. //Name of thing
  384. if(draw_mode&128) {
  385. write_string(overlay_menu_lines[3],t3+4,20,EC_CURR_THING,
  386. current_pg_seg);
  387. t3+=str_len(overlay_menu_lines[3])+5;
  388. }
  389. else {
  390. write_string(thing_names[curr_thing],t3+4,20,EC_CURR_THING,
  391. current_pg_seg);
  392. t3+=str_len(thing_names[curr_thing])+5;
  393. }
  394. //Parameter (DON'T SHOW for robots/etc unless RPARAM def'd)
  395. #ifndef RPARAM
  396. if(curr_thing<122) {
  397. #endif
  398. draw_char('p',EC_CURR_PARAM,t3++,20,current_pg_seg);
  399. write_hex_byte(curr_param,EC_CURR_PARAM,t3,20,current_pg_seg);
  400. t3+=2;
  401. #ifndef RPARAM
  402. }
  403. else t3--;
  404. #endif
  405. //')'
  406. draw_char(')',EC_CURR_THING,t3,20,current_pg_seg);
  407. //Done
  408. }
  409. //Draw current menu
  410. if(draw_mode&128) {
  411. write_string(overlay_menu_lines[1],1,22,EC_OPTION,current_pg_seg);
  412. write_string(overlay_menu_lines[2],1,23,EC_OPTION,current_pg_seg);
  413. }
  414. else {
  415. write_string(menu_lines[curr_menu][0],1,22,EC_OPTION,current_pg_seg);
  416. write_string(menu_lines[curr_menu][1],1,23,EC_OPTION,current_pg_seg);
  417. }
  418. //Highlight any current options
  419. if(draw_mode&128) {
  420. if(show_level)
  421. color_line(16,51,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  422. if(draw_mode==129)
  423. color_line(8,24,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  424. else if(draw_mode==130)
  425. color_line(7,69,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  426. else if((draw_mode==131)||(draw_mode==132))
  427. color_line(11,11,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  428. }
  429. else if(curr_menu==0) {
  430. if(changed)
  431. color_line(6,13,22,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  432. }
  433. else if(curr_menu==3) {
  434. if(draw_mode==1)
  435. color_line(8,11,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  436. else if(draw_mode==2)
  437. color_line(7,24,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  438. else if((draw_mode==3)||(draw_mode==4))
  439. color_line(11,43,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  440. }
  441. else if(curr_menu==5) {
  442. if(def_color_mode)
  443. color_line(20,53,22,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  444. if(mod_playing[0]!=0)
  445. color_line(11,53,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  446. if(debug_mode)
  447. color_line(16,30,23,EC_HIGHLIGHTED_OPTION,current_pg_seg);
  448. }
  449. //Write menu help string
  450. if(draw_mode<128)
  451. write_string(menu_help,64,24,EC_CURR_PARAM,current_pg_seg);
  452. //Done!
  453. }
  454. else {//Otherwise copy menu
  455. m_hide();
  456. mem_cpy((char far *)MK_FP(current_pg_seg,3040),
  457. (char far *)MK_FP(VIDEO_NUM2SEG(current_page),3040),960);
  458. m_show();
  459. }
  460. //Menu is updated
  461. update_menu=0;
  462. }
  463. else {//Otherwise copy menu
  464. m_hide();
  465. mem_cpy((char far *)MK_FP(current_pg_seg,3040),
  466. (char far *)MK_FP(VIDEO_NUM2SEG(current_page),3040),960);
  467. m_show();
  468. }
  469. //Page flip
  470. current_page=1-current_page;
  471. //Page flip automatically doesn't occur until NEXT retrace.
  472. //But we wait until then so we don't start writing on the
  473. //visible page!
  474. m_hide();
  475. page_flip(current_page);
  476. move_cursor(x_pos,y_pos);
  477. cursor_solid();
  478. m_vidseg(current_pg_seg);
  479. wait_retrace();
  480. //Fade in (used upon entrance)
  481. if(fade_in) {
  482. vquick_fadein();
  483. fade_in=0;
  484. //Turn cursor on
  485. cursor_solid();
  486. }
  487. no_pflip:
  488. //Move cursor done at end of loop
  489. if(debug_mode) {
  490. write_number(ARRAY_X,EC_DEBUG_NUMBER,debug_x+7,13,current_pg_seg,3);
  491. write_number(ARRAY_Y,EC_DEBUG_NUMBER,debug_x+11,13,current_pg_seg,3);
  492. }
  493. //Highlight cursor - Save old color/char and fiddle with it
  494. t1=t2=*(unsigned char far *)MK_FP(current_pg_seg,((x_pos+y_pos*80)<<1)+1);
  495. //If same fg/bk, flip the bk brightness
  496. if((t1&15)==((t1&240)>>4)) t1^=128;
  497. *(unsigned char far *)MK_FP(current_pg_seg,((x_pos+y_pos*80)<<1)+1)=t1;
  498. //Check character- if it is a 219, change to a space.
  499. //If it is a ², make it a °.
  500. t1=t3=*(unsigned char far *)MK_FP(current_pg_seg,(x_pos+y_pos*80)<<1);
  501. if(t1==219) t1=32;
  502. if(t1==178) t1=176;
  503. *(unsigned char far *)MK_FP(current_pg_seg,(x_pos+y_pos*80)<<1)=t1;
  504. //Get key
  505. m_show();
  506. key=getkey();
  507. m_hide();
  508. //Fix cursor
  509. *(unsigned char far *)MK_FP(current_pg_seg,((x_pos+y_pos*80)<<1)+1)=t2;
  510. *(unsigned char far *)MK_FP(current_pg_seg,(x_pos+y_pos*80)<<1)=t3;
  511. m_show();
  512. //Act upon key
  513. cursor_off();
  514. //Check for text mode...
  515. if(((draw_mode&127)==2)&&((key>=32)&&(key<=255))) {
  516. //Place a character.
  517. changed=1;
  518. if(!(draw_mode&128)) {
  519. if(level_id[ARRAY_OFFS]==127) goto move_right;//No overwriting player
  520. //If top thing at position is a robot/etc, deallocate it. If it
  521. //is the CURRENT thing, copy to #0 first
  522. t1=level_id[ARRAY_OFFS];
  523. if(t1==122) {//(sensor)
  524. if((level_param[ARRAY_OFFS]==curr_param)&&(curr_thing==122))
  525. copy_sensor(0,curr_param);
  526. clear_sensor(level_param[ARRAY_OFFS]);
  527. curr_param=0;
  528. }
  529. else if((t1==123)||(t1==124)) {//(robot)
  530. if((level_param[ARRAY_OFFS]==curr_param)&&
  531. ((curr_thing==123)||(curr_thing==124)))
  532. copy_robot(0,curr_param);//No mem. = too bad
  533. clear_robot(level_param[ARRAY_OFFS]);
  534. curr_param=0;
  535. }
  536. else if((t1==125)||(t1==126)) {//(scroll)
  537. if((level_param[ARRAY_OFFS]==curr_param)&&
  538. ((curr_thing==125)||(curr_thing==126)))
  539. copy_scroll(0,curr_param);//No mem. = too bad
  540. clear_scroll(level_param[ARRAY_OFFS]);
  541. curr_param=0;
  542. }
  543. //Place.
  544. id_place(ARRAY_X,ARRAY_Y,77,curr_color,key);
  545. }
  546. else {
  547. //Overlay mode
  548. overlay[ARRAY_OFFS]=key;
  549. overlay_color[ARRAY_OFFS]=curr_color;
  550. }
  551. update_view=1;
  552. //Increase x position if possible
  553. goto move_right;
  554. }
  555. //Ensure uppercase
  556. if((key>='a')&&(key<='z')) key-=32;
  557. //Fix for block mode
  558. if(((draw_mode&127)==3)||((draw_mode&127)==4)||((draw_mode&127)==5))
  559. if((key==' ')||(key==13)) key=-48;
  560. re_evaul_key:
  561. switch(key) {
  562. case ']'://Screen .PCX dump
  563. dump_screen();
  564. break;
  565. case MOUSE_EVENT://Mouse click
  566. //Possibilities-
  567. //
  568. //1) Mouse is in upper menu area.
  569. // a) Mouse will change current menu/exit overlay mode (left)
  570. // b) Mouse will change current color (right)
  571. //2) Mouse is in lower menu area.
  572. // a) Mouse will choose menu command.
  573. // b) Mouse will change current menu. (Pgup/Pgdn)
  574. //3) Mouse is in level area- move cursor and place.
  575. //4) Mouse is anywhere else- do nothing.
  576. if(mouse_event.cy==20) {//#1
  577. if(mouse_event.cx<42) {//#1a
  578. if(draw_mode&128) goto overlay_off;
  579. //Determine menu to switch to.
  580. t1=1;
  581. for(t2=0;t2<NUM_MENUS;t2++) {
  582. t1+=str_len(menu_names[t2]);
  583. if(mouse_event.cx<t1) break;
  584. }
  585. if(t2>=NUM_MENUS) t2=NUM_MENUS-1;
  586. curr_menu=t2;
  587. update_menu=1;
  588. break;
  589. }
  590. else goto change_color;//#1b
  591. }
  592. else if(mouse_event.cy>21) {//#2
  593. if(mouse_event.cy<24) {//#2a
  594. if((mouse_event.cx<2)||(mouse_event.cx==79)) break;
  595. if(draw_mode&128) t1=NUM_MENUS;
  596. else t1=curr_menu;
  597. t2=mouse_event.cy-22;
  598. t3=mouse_event.cx-2;
  599. t4=0;
  600. do {
  601. t3-=menu_keys[t1][t2][t4];
  602. if(t3<0) break;
  603. t4+=2;
  604. } while(1);
  605. key=menu_keys[t1][t2][t4+1];
  606. goto re_evaul_key;
  607. }
  608. else {//#2b
  609. if(mouse_event.cx<68) goto prev_menu;
  610. else goto next_menu;
  611. }
  612. }
  613. //#3 or #4?
  614. if(mouse_event.cy>18) break;
  615. if(mouse_event.cx>=board_xsiz) break;
  616. if(mouse_event.cy>=board_ysiz) break;
  617. //#3- Move cursor and place.
  618. x_pos=mouse_event.cx;
  619. y_pos=mouse_event.cy;
  620. //Move debug window?
  621. if((debug_x==65)&&(x_pos>59)) {
  622. debug_x=0;
  623. update_view=1;
  624. }
  625. if((debug_x==0)&&(x_pos<20)) {
  626. debug_x=65;
  627. update_view=1;
  628. }
  629. goto place;
  630. case -20://Alt+T
  631. //Test
  632. //if(protection_method!=NO_PROTECTION) {
  633. // error("Can't test password-protected world",0,24,
  634. // current_pg_seg,0x2001);
  635. // break;
  636. // }
  637. if((curr_thing==122)&&(curr_param==0)) {
  638. clear_sensor(0);
  639. curr_thing=0;
  640. }
  641. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0)) {
  642. clear_robot(0);
  643. curr_thing=0;
  644. }
  645. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0)) {
  646. clear_scroll(0);
  647. curr_thing=0;
  648. }
  649. //Temporary save
  650. str_cpy(temp,curr_file);
  651. t1=curr_board;
  652. store_current();
  653. save_world("test_$$$.mzx");
  654. select_current(t1);
  655. //Turn cheats on and fade out
  656. cheats_active+=5;
  657. vquick_fadeout();
  658. //Play
  659. clear_game_params();
  660. set_counter("TIME",time_limit);
  661. send_robot_def(0,11);
  662. send_robot_def(0,10);
  663. m_hide();
  664. player_restart_x=player_x;
  665. player_restart_y=player_y;
  666. play_game(1);
  667. cheats_active-=5;
  668. //Clear screen
  669. clear_screen(1824,current_pg_seg);
  670. //Palette
  671. default_palette();
  672. for(t2=0;t2<16;t2++)
  673. set_color_intensity(t2,100);
  674. insta_fadein();
  675. m_show();
  676. //Reload
  677. clear_world();
  678. if(load_world("test_$$$.mzx",2)) {
  679. clear_world();
  680. select_current(0);
  681. update_view=update_menu=1;
  682. curr_file[0]=0;
  683. break;
  684. }
  685. select_current(t1);
  686. unlink("test_$$$.mzx");
  687. insta_fadeout();
  688. fade_in=1;
  689. update_view=update_menu=1;
  690. str_cpy(curr_file,temp);
  691. break;
  692. case -33://AltF
  693. //Edit SFX
  694. sfx_edit();
  695. changed=1;
  696. break;
  697. case -17://AltW
  698. //Re-init screen
  699. vga_16p_mode();
  700. ega_14p_mode();
  701. cursor_off();
  702. blink_off();
  703. ec_update_set();
  704. update_palette(0);
  705. changed=1;
  706. update_menu=1;
  707. break;
  708. case 'F'://F
  709. //Fill
  710. //Just, well, fill! Fill function takes care of all
  711. //robot copying/deleting/etc, filling something over
  712. //itself, (same OR different param) and filling with/over
  713. //the player. (not allowed) Only precaution- copy current
  714. //robot to #0 first.
  715. if(draw_mode&128)
  716. fill_overlay(ARRAY_X,ARRAY_Y,curr_param,curr_color);
  717. else {
  718. if((curr_thing==122)&&(curr_param)) {
  719. copy_sensor(0,curr_param);
  720. sensors[0].used=1;
  721. curr_param=0;
  722. }
  723. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param)) {
  724. copy_robot(0,curr_param);
  725. robots[0].used=1;
  726. curr_param=0;
  727. }
  728. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param)) {
  729. copy_scroll(0,curr_param);
  730. scrolls[0].used=1;
  731. curr_param=0;
  732. }
  733. fill_area(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  734. }
  735. //Was our current object overwritten?
  736. if((curr_thing==122)&&(!sensors[curr_param].used))
  737. curr_thing=0;
  738. else if(((curr_thing==123)||(curr_thing==124))&&
  739. (!robots[curr_param].used))
  740. curr_thing=0;
  741. else if(((curr_thing==125)||(curr_thing==126))&&
  742. (!scrolls[curr_param].used))
  743. curr_thing=0;
  744. changed=1;
  745. update_view=update_menu=1;
  746. break;
  747. case 'V'://V
  748. //View
  749. if(draw_mode&128) break;
  750. scroll_x=scroll_y=0;
  751. do {
  752. //Select OTHER page for seg
  753. current_pg_seg=VIDEO_NUM2SEG(!current_page);
  754. //Draw border
  755. draw_viewport();
  756. //Figure out x/y of top
  757. calculate_xytop(t1,t2);
  758. //Draw screen
  759. draw_game_window(t1,t2,current_pg_seg);
  760. //Page flip
  761. current_page=1-current_page;
  762. page_flip(current_page);
  763. m_vidseg(current_pg_seg);
  764. //Retrace
  765. wait_retrace();
  766. //Movement
  767. if(keywaiting()) {
  768. key=getkey();
  769. switch(key) {
  770. case -72://Up
  771. scroll_y--;
  772. break;
  773. case -80://Down
  774. scroll_y++;
  775. break;
  776. case -75://Left
  777. scroll_x--;
  778. break;
  779. case -77://Right
  780. scroll_x++;
  781. break;
  782. case -71://Home
  783. case -79://End
  784. scroll_x=scroll_y=0;
  785. break;
  786. }
  787. }
  788. } while(key!=27);
  789. scroll_x=scroll_y=0;
  790. update_view=update_menu=key=1;
  791. break;
  792. case -23://AltI
  793. //Import
  794. if(draw_mode&128) break;
  795. //Choose import mode
  796. t1=import_type();
  797. if(t1==-1) break;
  798. //Import as...
  799. switch(t1) {
  800. case 0:
  801. //...board file.
  802. if(choose_file("*.MZB",temp,"Choose board to import")) break;
  803. //Open file.
  804. fp=fopen(temp,"rb");
  805. if(fp==NULL) {
  806. error("Error importing board",1,24,current_pg_seg,0x1501);
  807. break;
  808. }
  809. //Verify header
  810. fread(temp,1,3,fp);
  811. temp[3]=0;
  812. if(str_cmp(temp,"\xFFMB")) {
  813. //Either a ver 1.0? file or corrupted
  814. error("Error importing board",1,24,current_pg_seg,0x1502);
  815. break;
  816. }
  817. //Get file ver.
  818. t1=fgetc(fp);
  819. if(t1!='2') {
  820. //Not a ver 2.00 file
  821. error("Board is from a more recent version of MegaZeux",
  822. 0,24,current_pg_seg,0x1601);
  823. break;
  824. }
  825. //Read board- Store current...
  826. //If current object is a robot/etc of not #0, copy to #0.
  827. if((curr_thing==122)&&(curr_param!=0)) {
  828. copy_sensor(0,curr_param);
  829. curr_param=0;
  830. }
  831. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  832. //No room = forget it!
  833. if(!copy_robot(0,curr_param)) curr_param=0;
  834. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  835. //No room = forget it!
  836. if(!copy_scroll(0,curr_param)) curr_param=0;
  837. //Clear current
  838. clear_current();
  839. //Get size of board
  840. tlong1=ftell(fp);
  841. fseek(fp,-BOARD_NAME_SIZE,SEEK_END);
  842. tlong2=ftell(fp);
  843. fseek(fp,tlong1,SEEK_SET);
  844. tlong2-=tlong1;
  845. //tlong2=board size
  846. //no space allocated to current
  847. //allocate space and set vars
  848. if(allocate_board_space(tlong2,curr_board))//Exit only
  849. error("Out of memory and/or disk space",2,4,
  850. current_pg_seg,0x0205);
  851. //allocated, set vars
  852. board_sizes[curr_board]=tlong2;
  853. //Read board
  854. disk_board(curr_board,fp,1,0);
  855. //Load into current
  856. select_current(curr_board);
  857. //Load board name from file
  858. fread(&board_list[curr_board*BOARD_NAME_SIZE],1,
  859. BOARD_NAME_SIZE,fp);
  860. //Done.
  861. fclose(fp);
  862. break;
  863. case 1:
  864. //Character set
  865. if(choose_file("*.CHR",temp,"Choose character set")) break;
  866. //Open file.
  867. if(ec_load_set(temp))
  868. error("Error importing char. set",1,24,current_pg_seg,0x1801);
  869. break;
  870. case 2:
  871. case 6:
  872. //Ansi file
  873. if(choose_file("*.ANS",ansi,"Choose ANSi file")) break;
  874. //Get type of import
  875. t2=import_ansi_obj_type();
  876. if(t2==-1) break;
  877. //Check if overlay
  878. if(t2==3) {
  879. if(overlay_mode==0) {
  880. error("Overlay mode is not on (see Board Info)",0,24,
  881. current_pg_seg,0x1103);
  882. break;
  883. }
  884. }
  885. //Import
  886. if(t2==0) t2=5;
  887. else if(t2==1) t2=17;
  888. else if(t2==2) t2=77;
  889. else t2=0;
  890. if(t1==2) import_ansi(ansi,t2,curr_thing,curr_param);
  891. else {
  892. blk_cmd=t2;
  893. draw_mode=(draw_mode&128)+5;
  894. update_view=update_menu=1;
  895. }
  896. break;
  897. case 3:
  898. //Import world
  899. if(choose_file("*.MZX",temp,"Choose world to import")) break;
  900. //Open file
  901. fp=fopen(temp,"rb");
  902. if(fp==NULL) {
  903. error("Error importing world",1,24,current_pg_seg,0x1A01);
  904. break;
  905. }
  906. //Check for password protection and world type
  907. fseek(fp,25,SEEK_SET);
  908. if(fgetc(fp)!=0) {
  909. /*error("Cannot import password protected world",0,
  910. 24,current_pg_seg,0x1B01);
  911. fclose(fp);
  912. break;*/
  913. }
  914. if(fgetc(fp)!='M') {
  915. error("Error importing world",1,24,current_pg_seg,0x1A02);
  916. fclose(fp);
  917. break;
  918. }
  919. t1=fgetc(fp);
  920. if(t1=='X') {
  921. error("World is from version 1- Use conversion program",
  922. 0,24,current_pg_seg,0x1C01);
  923. fclose(fp);
  924. break;
  925. }
  926. //Version and pw okay
  927. fseek(fp,4234,SEEK_SET);
  928. t1=fgetc(fp);//Number of boards
  929. if(t1==0) {
  930. //SFX- Skip
  931. fread(&t1,1,2,fp);
  932. fseek(fp,t1,SEEK_CUR);
  933. t9=3+t1;
  934. t1=fgetc(fp);
  935. }
  936. else t9=0;//Size of SFX section
  937. //Count OUR empty boards
  938. t2=0;
  939. for(t3=0;t3<NUM_BOARDS;t3++)
  940. if(board_where[t3]==W_NOWHERE) t2++;
  941. //Compare
  942. if(t1>t2) {
  943. //Too many-
  944. if(t2==0) {
  945. error("No available boards",1,24,current_pg_seg,0x0B02);
  946. fclose(fp);
  947. break;
  948. }
  949. if(error("Too many boards- only partial import will be done",
  950. 0,25,current_pg_seg,0x1D01)==1) {
  951. fclose(fp);
  952. break;//Fail
  953. }
  954. //They chose OK, so import as many as possible.
  955. }
  956. //Import t1 boards- Mark as importable by setting
  957. //type to W_IMPORT, offset to file area, and size
  958. //properly. Also sets title.
  959. t3=0;//Current board to change (out of NUM_BOARDS)
  960. t4=0;//Current board within MZX file (out of t1)
  961. do {
  962. //Find next empty board
  963. do {
  964. t3++;
  965. if(t3>=NUM_BOARDS) break;
  966. } while(board_where[t3]!=W_NOWHERE);
  967. if(t3>=NUM_BOARDS) break;//Done
  968. //Import to board t3- get title
  969. fread(&board_list[BOARD_NAME_SIZE*t3],1,
  970. BOARD_NAME_SIZE,fp);
  971. //Jump to board size/offset, saving curr. position
  972. tlong1=ftell(fp);
  973. //Tlong2=Position of size/offsets
  974. tlong2=4235+t9+(t1*BOARD_NAME_SIZE);
  975. //Increase to position of size/offset for current board
  976. tlong2+=t4*8;
  977. //Jump
  978. fseek(fp,tlong2,SEEK_SET);
  979. //Read size and offset
  980. fread(&board_sizes[t3],4,1,fp);
  981. fread(&board_offsets[t3].offset,4,1,fp);
  982. //Set where
  983. board_where[t3]=W_IMPORT;
  984. //Return to names
  985. fseek(fp,tlong1,SEEK_SET);
  986. //Next board...
  987. } while((++t4)<t1);
  988. //Now actually IMPORT each board- % meter used
  989. save_screen(current_pg_seg);
  990. t2=0;//Keeps track of number of boards imported
  991. //t4=Max number of boards we'll import
  992. meter("Importing world...",current_pg_seg,t2,t4);
  993. for(t1=0;t1<NUM_BOARDS;t1++) {
  994. //Import this board?
  995. if(board_where[t1]!=W_IMPORT) continue;
  996. //Save file offset
  997. tlong1=board_offsets[t1].offset;
  998. //Allocate space...
  999. board_where[t1]=W_NOWHERE;
  1000. if(allocate_board_space(board_sizes[t1],t1)) {
  1001. fclose(fp);
  1002. restore_screen(current_pg_seg);
  1003. error("Out of memory and/or disk space",2,4,
  1004. current_pg_seg,0x0206);
  1005. }
  1006. //Read in board.
  1007. fseek(fp,tlong1,SEEK_SET);
  1008. disk_board(t1,fp,1,0);
  1009. //Next!
  1010. meter_interior(current_pg_seg,++t2,t4);
  1011. }
  1012. //Done!
  1013. fclose(fp);
  1014. restore_screen(current_pg_seg);
  1015. break;
  1016. case 4:
  1017. //Palette file
  1018. if(choose_file("*.PAL",temp,"Choose palette file")) break;
  1019. //Open file.
  1020. fp=fopen(temp,"rb");
  1021. if(fp==NULL) {
  1022. error("Error importing palette",1,24,current_pg_seg,0x2401);
  1023. break;
  1024. }
  1025. for(t1=0;t1<16;t1++) {
  1026. r=fgetc(fp);
  1027. g=fgetc(fp);
  1028. b=fgetc(fp);
  1029. set_rgb(t1,r,g,b);
  1030. }
  1031. update_palette();
  1032. //Done.
  1033. fclose(fp);
  1034. break;
  1035. case 5:
  1036. //SFX file
  1037. if(choose_file("*.SFX",temp,"Choose SFX file")) break;
  1038. //Open file.
  1039. fp=fopen(temp,"rb");
  1040. if(fp==NULL) {
  1041. error("Error importing .SFX file",1,24,current_pg_seg,0x3001);
  1042. break;
  1043. }
  1044. custom_sfx_on=1;
  1045. for(t1=0;t1<NUM_SFX;t1++)
  1046. fread(&custom_sfx[69*t1],1,69,fp);
  1047. //Done.
  1048. fclose(fp);
  1049. break;
  1050. }
  1051. changed=1;
  1052. update_view=update_menu=1;
  1053. break;
  1054. case -45://AltX
  1055. //Export
  1056. if(draw_mode&128) break;
  1057. //Confirm pw
  1058. //if(check_pw()) break;
  1059. //Choose export mode
  1060. t1=export_type();
  1061. if(t1==-1) break;
  1062. //Get file name
  1063. temp[0]=0;
  1064. if(save_file_dialog("Export","Save as: ",temp)) break;
  1065. //Export as...
  1066. switch(t1) {
  1067. case 0:
  1068. //...board file.
  1069. add_ext(temp,".MZB");
  1070. //Open file.
  1071. fp=fopen(temp,"wb");
  1072. if(fp==NULL) {
  1073. error("Error exporting board",1,24,current_pg_seg,0x1201);
  1074. break;
  1075. }
  1076. //Save header.
  1077. fwrite("\xFFMB2",1,4,fp);
  1078. //Write board- Store it...
  1079. //If current object is a robot/etc of not #0, copy to #0.
  1080. if((curr_thing==122)&&(curr_param!=0)) {
  1081. copy_sensor(0,curr_param);
  1082. curr_param=0;
  1083. }
  1084. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  1085. //No room = forget it!
  1086. if(!copy_robot(0,curr_param)) curr_param=0;
  1087. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  1088. //No room = forget it!
  1089. if(!copy_scroll(0,curr_param)) curr_param=0;
  1090. //Store current
  1091. store_current();
  1092. //Save board
  1093. disk_board(curr_board,fp,0,0);
  1094. //Reload current
  1095. select_current(curr_board);
  1096. update_view=update_menu=1;
  1097. //Save board name to file
  1098. fwrite(&board_list[curr_board*BOARD_NAME_SIZE],1,
  1099. BOARD_NAME_SIZE,fp);
  1100. //Done.
  1101. fclose(fp);
  1102. break;
  1103. case 1:
  1104. //Character set
  1105. add_ext(temp,".CHR");
  1106. //Open file.
  1107. if(ec_save_set(temp))
  1108. error("Error exporting char. set",1,24,current_pg_seg,0x1301);
  1109. break;
  1110. case 2:
  1111. //Ansi file
  1112. add_ext(temp,".ANS");
  1113. case 3:
  1114. //Text file
  1115. if(t1==3) add_ext(temp,".TXT");
  1116. //Overlays as they normally would be.
  1117. //Save. (auto clips)
  1118. export_ansi(temp,0,0,board_xsiz,board_ysiz,t1-2);
  1119. //Done.
  1120. break;
  1121. case 4:
  1122. //Palette file
  1123. add_ext(temp,".PAL");
  1124. fp=fopen(temp,"wb");
  1125. if(fp==NULL) {
  1126. error("Error exporting palette",1,24,current_pg_seg,0x2E01);
  1127. break;
  1128. }
  1129. for(t1=0;t1<16;t1++) {
  1130. get_rgb(t1,r,g,b);
  1131. fputc(r,fp);
  1132. fputc(g,fp);
  1133. fputc(b,fp);
  1134. }
  1135. fclose(fp);
  1136. break;
  1137. case 5:
  1138. //SFX file
  1139. add_ext(temp,".SFX");
  1140. fp=fopen(temp,"wb");
  1141. if(fp==NULL) {
  1142. error("Error exporting .SFX file",1,24,current_pg_seg,0x2F01);
  1143. break;
  1144. }
  1145. for(t1=0;t1<NUM_SFX;t1++) {
  1146. if(custom_sfx_on)
  1147. fwrite(&custom_sfx[69*t1],1,69,fp);
  1148. else fwrite(sfx_strs[t1],1,69,fp);
  1149. }
  1150. fclose(fp);
  1151. break;
  1152. }
  1153. break;
  1154. /*case '*':// *
  1155. //Password
  1156. if(draw_mode&128) break;
  1157. password_dialog();
  1158. changed=1;
  1159. break;*/
  1160. case -30://AltA
  1161. //Select char set
  1162. if(draw_mode&128) break;
  1163. t1=choose_char_set();
  1164. if(t1==-1) break;
  1165. switch(t1) {
  1166. case 0:
  1167. //Megazeux default
  1168. ec_load_mzx();
  1169. break;
  1170. case 1:
  1171. //Blank
  1172. ec_load_mzx();
  1173. //Characters to leave alone-
  1174. //32 through 126 (text)
  1175. //0 (already blank)
  1176. //16-18, 24-27, 29-31 (arrows)
  1177. //176-223 (lines/blocks)
  1178. //254 (square)
  1179. //249-250 (dots)
  1180. //251 (check mark)
  1181. //7 (circle)
  1182. //
  1183. //Blanken all others.
  1184. //
  1185. //Series to blanken-
  1186. //1-6, 8-15, 19-23, 28, 127-175, 224-248, 252-253
  1187. for(t1=1;t1<=6;t1++)
  1188. for(t2=0;t2<14;t2++)
  1189. ec_change_byte_nou(t1,t2,0);
  1190. for(t1=8;t1<=15;t1++)
  1191. for(t2=0;t2<14;t2++)
  1192. ec_change_byte_nou(t1,t2,0);
  1193. for(t1=19;t1<=23;t1++)
  1194. for(t2=0;t2<14;t2++)
  1195. ec_change_byte_nou(t1,t2,0);
  1196. for(t1=127;t1<=175;t1++)
  1197. for(t2=0;t2<14;t2++)
  1198. ec_change_byte_nou(t1,t2,0);
  1199. for(t1=224;t1<=248;t1++)
  1200. for(t2=0;t2<14;t2++)
  1201. ec_change_byte_nou(t1,t2,0);
  1202. for(t2=0;t2<14;t2++) {
  1203. ec_change_byte_nou(28,t2,0);
  1204. ec_change_byte_nou(252,t2,0);
  1205. ec_change_byte_nou(253,t2,0);
  1206. ec_change_byte_nou(255,t2,0);
  1207. }
  1208. ec_update_set();
  1209. break;
  1210. }
  1211. changed=1;
  1212. break;
  1213. case -48://AltB
  1214. //Block mode
  1215. if((draw_mode&127)==0) {
  1216. //Turn ON.
  1217. draw_mode=3+(draw_mode&128);
  1218. save_x=ARRAY_X;
  1219. save_y=ARRAY_Y;
  1220. update_view=update_menu=1;
  1221. break;
  1222. }
  1223. else if(((draw_mode&127)!=3)&&((draw_mode&127)!=4)) {
  1224. if((draw_mode&127)==5)//Place ANSi
  1225. import_ansi(ansi,blk_cmd,curr_thing,curr_param,ARRAY_X,ARRAY_Y);
  1226. //Turn other mode OFF.
  1227. draw_mode&=128;
  1228. update_view=update_menu=1;
  1229. break;
  1230. }
  1231. else if((draw_mode&127)==4) {
  1232. //Block destination chosen.
  1233. t1=ARRAY_X;
  1234. t2=ARRAY_Y;
  1235. if(((save_x2-save_x)+t1)>=board_xsiz)
  1236. save_x2=save_x+board_xsiz-t1-1;
  1237. if(((save_y2-save_y)+t2)>=board_ysiz)
  1238. save_y2=save_y+board_ysiz-t2-1;
  1239. switch(blk_cmd) {
  1240. case 0://Copy
  1241. //Do ULeft->LRight or LRight->ULeft?
  1242. if((t1==save_x)&&(t2==save_y)) break;//Done
  1243. if((t1<save_x)||((t1==save_x)&&(t2<save_y))) {
  1244. //Copy starting at UL, going by columns.
  1245. for(t3=save_x;t3<=save_x2;t3++) {
  1246. for(t4=save_y;t4<=save_y2;t4++) {
  1247. t5=t3+t4*max_bxsiz;
  1248. t6=((t3-save_x)+t1)+((t4-save_y)+t2)*max_bxsiz;
  1249. //Copy from t5 to t6
  1250. if(draw_mode&128) {
  1251. //Overlay-
  1252. overlay[t6]=overlay[t5];
  1253. overlay_color[t6]=overlay_color[t5];
  1254. continue;
  1255. }
  1256. //Clear anything there...
  1257. t7=level_id[t6];
  1258. if(t7==127) continue;//No copy over player
  1259. if(t7==122) {//(sensor)
  1260. //Clear, copying to 0 first if param==curr
  1261. if((level_param[t6]==curr_param)&&
  1262. (curr_thing==122)) {
  1263. copy_sensor(0,curr_param);
  1264. curr_param=0;
  1265. }
  1266. clear_sensor(level_param[t6]);
  1267. }
  1268. else if((t7==123)||(t7==124)) {//(robot)
  1269. //Clear, copying to 0 first if param==curr
  1270. if((level_param[t6]==curr_param)&&
  1271. ((curr_thing==123)||(curr_thing==124))) {
  1272. copy_robot(0,curr_param);
  1273. curr_param=0;
  1274. }
  1275. clear_robot(level_param[t6]);
  1276. }
  1277. else if((t7==125)||(t7==126)) {//(scroll)
  1278. //Clear, copying to 0 first if param==curr
  1279. if((level_param[t6]==curr_param)&&
  1280. ((curr_thing==125)||(curr_thing==126))) {
  1281. copy_scroll(0,curr_param);
  1282. curr_param=0;
  1283. }
  1284. clear_scroll(level_param[t6]);
  1285. }
  1286. //Copy any robot/scroll at t5
  1287. t7=level_id[t5];
  1288. t8=level_param[t5];
  1289. if(t7==122) {//(sensor)
  1290. //...make a copy...
  1291. if(!(t9=find_sensor())) {
  1292. error("No available sensors",1,24,current_pg_seg,0x0801);
  1293. break;
  1294. }
  1295. copy_sensor(t9,t8);
  1296. t8=t9;
  1297. }
  1298. if((t7==123)||(t7==124)) {//(robot)
  1299. //...make a copy...
  1300. if(!(t9=find_robot())) {
  1301. error("No available robots",1,24,current_pg_seg,0x0901);
  1302. break;
  1303. }
  1304. if(copy_robot(t9,t8)) {
  1305. robots[t9].used=0;
  1306. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  1307. break;
  1308. }
  1309. //...and deallocate original if it was number 0.
  1310. t8=t9;
  1311. }
  1312. if((t7==125)||(t7==126)) {//(scroll)
  1313. //...make a copy...
  1314. if(!(t9=find_scroll())) {
  1315. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  1316. break;
  1317. }
  1318. if(copy_scroll(t9,t8)) {
  1319. robots[t9].used=0;
  1320. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  1321. break;
  1322. }
  1323. t8=t9;
  1324. }
  1325. //Player?
  1326. if(t7==127) {
  1327. level_id[t6]=level_param[t6]=
  1328. level_under_id[t6]=level_under_param[t6]=0;
  1329. level_color[t6]=level_under_color[t6]=7;
  1330. }
  1331. else {
  1332. //Place
  1333. level_id[t6]=t7;
  1334. level_param[t6]=t8;
  1335. level_color[t6]=level_color[t5];
  1336. level_under_id[t6]=level_under_id[t5];
  1337. level_under_color[t6]=level_under_color[t5];
  1338. level_under_param[t6]=level_under_param[t5];
  1339. }
  1340. //Loop. (whew!)
  1341. }
  1342. }
  1343. //Done (UL -> LR)
  1344. }
  1345. else {
  1346. //Copy starting at LR, going left by columns.
  1347. for(t3=save_x2;t3>=save_x;t3--) {
  1348. for(t4=save_y2;t4>=save_y;t4--) {
  1349. t5=t3+t4*max_bxsiz;
  1350. t6=((t3-save_x)+t1)+((t4-save_y)+t2)*max_bxsiz;
  1351. //Copy from t5 to t6
  1352. if(draw_mode&128) {
  1353. //Overlay-
  1354. overlay[t6]=overlay[t5];
  1355. overlay_color[t6]=overlay_color[t5];
  1356. continue;
  1357. }
  1358. //Clear anything there...
  1359. t7=level_id[t6];
  1360. if(t7==127) continue;//No copy over player
  1361. if(t7==122) {//(sensor)
  1362. //Clear, copying to 0 first if param==curr
  1363. if((level_param[t6]==curr_param)&&
  1364. (curr_thing==122)) {
  1365. copy_sensor(0,curr_param);
  1366. curr_param=0;
  1367. }
  1368. clear_sensor(level_param[t6]);
  1369. }
  1370. else if((t7==123)||(t7==124)) {//(robot)
  1371. //Clear, copying to 0 first if param==curr
  1372. if((level_param[t6]==curr_param)&&
  1373. ((curr_thing==123)||(curr_thing==124))) {
  1374. copy_robot(0,curr_param);
  1375. curr_param=0;
  1376. }
  1377. clear_robot(level_param[t6]);
  1378. }
  1379. else if((t7==125)||(t7==126)) {//(scroll)
  1380. //Clear, copying to 0 first if param==curr
  1381. if((level_param[t6]==curr_param)&&
  1382. ((curr_thing==125)||(curr_thing==126))) {
  1383. copy_scroll(0,curr_param);
  1384. curr_param=0;
  1385. }
  1386. clear_scroll(level_param[t6]);
  1387. }
  1388. //Copy any robot/scroll at t5
  1389. t7=level_id[t5];
  1390. t8=level_param[t5];
  1391. if(t7==122) {//(sensor)
  1392. //...make a copy...
  1393. if(!(t9=find_sensor())) {
  1394. error("No available sensors",1,24,current_pg_seg,0x0801);
  1395. break;
  1396. }
  1397. copy_sensor(t9,t8);
  1398. t8=t9;
  1399. }
  1400. if((t7==123)||(t7==124)) {//(robot)
  1401. //...make a copy...
  1402. if(!(t9=find_robot())) {
  1403. error("No available robots",1,24,current_pg_seg,0x0901);
  1404. break;
  1405. }
  1406. if(copy_robot(t9,t8)) {
  1407. robots[t9].used=0;
  1408. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  1409. break;
  1410. }
  1411. //...and deallocate original if it was number 0.
  1412. t8=t9;
  1413. }
  1414. if((t7==125)||(t7==126)) {//(scroll)
  1415. //...make a copy...
  1416. if(!(t9=find_scroll())) {
  1417. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  1418. break;
  1419. }
  1420. if(copy_scroll(t9,t8)) {
  1421. robots[t9].used=0;
  1422. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  1423. break;
  1424. }
  1425. t8=t9;
  1426. }
  1427. //Player?
  1428. if(t7==127) {
  1429. level_id[t6]=level_param[t6]=
  1430. level_under_id[t6]=level_under_param[t6]=0;
  1431. level_color[t6]=level_under_color[t6]=7;
  1432. }
  1433. else {
  1434. //Place
  1435. level_id[t6]=t7;
  1436. level_param[t6]=t8;
  1437. level_color[t6]=level_color[t5];
  1438. level_under_id[t6]=level_under_id[t5];
  1439. level_under_color[t6]=level_under_color[t5];
  1440. level_under_param[t6]=level_under_param[t5];
  1441. }
  1442. //Loop. (whew!)
  1443. }
  1444. }
  1445. //Done (UL -> LR)
  1446. }
  1447. break;
  1448. case 6://Copy (to/from overlay)
  1449. //If from overlay to main, ask if we want it to become
  1450. //CustomFloor, CustomBlock, or Text.
  1451. if(draw_mode<128) {
  1452. t9=rtoo_obj_type();
  1453. if(t9==-1) break;
  1454. if(t9==0) t9=5;
  1455. else if(t9==1) t9=17;
  1456. else t9=77;
  1457. }
  1458. //Copy starting at UL, going by columns.
  1459. for(t3=save_x;t3<=save_x2;t3++) {
  1460. for(t4=save_y;t4<=save_y2;t4++) {
  1461. t5=t3+t4*max_bxsiz;
  1462. t6=((t3-save_x)+t1)+((t4-save_y)+t2)*max_bxsiz;
  1463. //Copy from t5 to t6
  1464. if(draw_mode&128) {
  1465. //TO Overlay- Use magic id draw function
  1466. overlay_mode|=128;//DON'T do overlay
  1467. id_put(0,0,t3,t4,0,0,current_pg_seg);
  1468. overlay_mode&=~128;
  1469. //Use color/char at 0/0
  1470. overlay[t6]=*(char far *)MK_FP(current_pg_seg,0);
  1471. overlay_color[t6]=*(char far *)MK_FP(current_pg_seg,1);
  1472. continue;
  1473. }
  1474. //FROM overlay...
  1475. //Clear anything there...
  1476. t7=level_id[t6];
  1477. if(t7==127) continue;//No copy over player
  1478. if(t7==122) {//(sensor)
  1479. //Clear, copying to 0 first if param==curr
  1480. if((level_param[t6]==curr_param)&&
  1481. (curr_thing==122)) {
  1482. copy_sensor(0,curr_param);
  1483. curr_param=0;
  1484. }
  1485. clear_sensor(level_param[t6]);
  1486. }
  1487. else if((t7==123)||(t7==124)) {//(robot)
  1488. //Clear, copying to 0 first if param==curr
  1489. if((level_param[t6]==curr_param)&&
  1490. ((curr_thing==123)||(curr_thing==124))) {
  1491. copy_robot(0,curr_param);
  1492. curr_param=0;
  1493. }
  1494. clear_robot(level_param[t6]);
  1495. }
  1496. else if((t7==125)||(t7==126)) {//(scroll)
  1497. //Clear, copying to 0 first if param==curr
  1498. if((level_param[t6]==curr_param)&&
  1499. ((curr_thing==125)||(curr_thing==126))) {
  1500. copy_scroll(0,curr_param);
  1501. curr_param=0;
  1502. }
  1503. clear_scroll(level_param[t6]);
  1504. }
  1505. //Copy as ID type t9 UNLESS it's a space
  1506. if(overlay[t5]==32) {
  1507. level_id[t6]=level_param[t6]=0;
  1508. level_color[t6]=7;
  1509. }
  1510. else {
  1511. level_id[t6]=t9;
  1512. level_param[t6]=overlay[t5];
  1513. level_color[t6]=overlay_color[t5];
  1514. }
  1515. level_under_id[t6]=level_under_param[t6]=0;
  1516. level_under_color[t6]=7;
  1517. //Loop.
  1518. }
  1519. }
  1520. //Done
  1521. break;
  1522. case 1://Move
  1523. //Do ULeft->LRight or LRight->ULeft?
  1524. if((t1==save_x)&&(t2==save_y)) break;//Done
  1525. if((t1<save_x)||((t1==save_x)&&(t2<save_y))) {
  1526. //Move starting at UL, going by columns.
  1527. for(t3=save_x;t3<=save_x2;t3++) {
  1528. for(t4=save_y;t4<=save_y2;t4++) {
  1529. t5=t3+t4*max_bxsiz;
  1530. t6=((t3-save_x)+t1)+((t4-save_y)+t2)*max_bxsiz;
  1531. //Move from t5 to t6
  1532. if(draw_mode&128) {
  1533. //Overlay-
  1534. overlay[t6]=overlay[t5];
  1535. overlay_color[t6]=overlay_color[t5];
  1536. overlay[t5]=32;
  1537. overlay_color[t5]=7;
  1538. continue;
  1539. }
  1540. //Clear anything there...
  1541. t7=level_id[t6];
  1542. if(t7==127) continue;//No copy over player
  1543. if(t7==122) {//(sensor)
  1544. //Clear, copying to 0 first if param==curr
  1545. if((level_param[t6]==curr_param)&&
  1546. (curr_thing==122)) {
  1547. copy_sensor(0,curr_param);
  1548. curr_param=0;
  1549. }
  1550. clear_sensor(level_param[t6]);
  1551. }
  1552. else if((t7==123)||(t7==124)) {//(robot)
  1553. //Clear, copying to 0 first if param==curr
  1554. if((level_param[t6]==curr_param)&&
  1555. ((curr_thing==123)||(curr_thing==124))) {
  1556. copy_robot(0,curr_param);
  1557. curr_param=0;
  1558. }
  1559. clear_robot(level_param[t6]);
  1560. }
  1561. else if((t7==125)||(t7==126)) {//(scroll)
  1562. //Clear, copying to 0 first if param==curr
  1563. if((level_param[t6]==curr_param)&&
  1564. ((curr_thing==125)||(curr_thing==126))) {
  1565. copy_scroll(0,curr_param);
  1566. curr_param=0;
  1567. }
  1568. clear_scroll(level_param[t6]);
  1569. }
  1570. //move
  1571. level_id[t6]=level_id[t5];
  1572. level_param[t6]=level_param[t5];
  1573. level_color[t6]=level_color[t5];
  1574. level_under_id[t6]=level_under_id[t5];
  1575. level_under_color[t6]=level_under_color[t5];
  1576. level_under_param[t6]=level_under_param[t5];
  1577. id_clear(t3,t4);
  1578. //Loop.
  1579. }
  1580. }
  1581. //Done (UL -> LR)
  1582. }
  1583. else {
  1584. //Move starting at LR, going left by columns.
  1585. for(t3=save_x2;t3>=save_x;t3--) {
  1586. for(t4=save_y2;t4>=save_y;t4--) {
  1587. t5=t3+t4*max_bxsiz;
  1588. t6=((t3-save_x)+t1)+((t4-save_y)+t2)*max_bxsiz;
  1589. //Move from t5 to t6
  1590. if(draw_mode&128) {
  1591. //Overlay-
  1592. overlay[t6]=overlay[t5];
  1593. overlay_color[t6]=overlay_color[t5];
  1594. overlay[t5]=32;
  1595. overlay_color[t5]=7;
  1596. continue;
  1597. }
  1598. //Clear anything there...
  1599. t7=level_id[t6];
  1600. if(t7==127) continue;//No copy over player
  1601. if(t7==122) {//(sensor)
  1602. //Clear, copying to 0 first if param==curr
  1603. if((level_param[t6]==curr_param)&&
  1604. (curr_thing==122)) {
  1605. copy_sensor(0,curr_param);
  1606. curr_param=0;
  1607. }
  1608. clear_sensor(level_param[t6]);
  1609. }
  1610. else if((t7==123)||(t7==124)) {//(robot)
  1611. //Clear, copying to 0 first if param==curr
  1612. if((level_param[t6]==curr_param)&&
  1613. ((curr_thing==123)||(curr_thing==124))) {
  1614. copy_robot(0,curr_param);
  1615. curr_param=0;
  1616. }
  1617. clear_robot(level_param[t6]);
  1618. }
  1619. else if((t7==125)||(t7==126)) {//(scroll)
  1620. //Clear, copying to 0 first if param==curr
  1621. if((level_param[t6]==curr_param)&&
  1622. ((curr_thing==125)||(curr_thing==126))) {
  1623. copy_scroll(0,curr_param);
  1624. curr_param=0;
  1625. }
  1626. clear_scroll(level_param[t6]);
  1627. }
  1628. //Move
  1629. level_id[t6]=level_id[t5];
  1630. level_param[t6]=level_param[t5];
  1631. level_color[t6]=level_color[t5];
  1632. level_under_id[t6]=level_under_id[t5];
  1633. level_under_color[t6]=level_under_color[t5];
  1634. level_under_param[t6]=level_under_param[t5];
  1635. id_clear(t3,t4);
  1636. //Loop.
  1637. }
  1638. }
  1639. //Done (UL -> LR)
  1640. }
  1641. break;
  1642. }
  1643. draw_mode&=128;
  1644. changed=1;
  1645. update_view=update_menu=1;
  1646. break;
  1647. }
  1648. //Finish block
  1649. draw_mode&=128;
  1650. save_x2=ARRAY_X;
  1651. save_y2=ARRAY_Y;
  1652. if(save_x>save_x2) {
  1653. t1=save_x;
  1654. save_x=save_x2;
  1655. save_x2=t1;
  1656. }
  1657. if(save_y>save_y2) {
  1658. t1=save_y;
  1659. save_y=save_y2;
  1660. save_y2=t1;
  1661. }
  1662. //Redraw
  1663. update_view=update_menu=1;
  1664. //Ask function
  1665. t1=block_cmd();
  1666. if(t1==-1) break;
  1667. //Do function t1
  1668. switch(t1) {
  1669. case 0:
  1670. //Copy
  1671. blk_cmd=t1;
  1672. draw_mode+=4;
  1673. break;
  1674. case 1:
  1675. //Move
  1676. blk_cmd=t1;
  1677. draw_mode+=4;
  1678. break;
  1679. case 2:
  1680. //Clear
  1681. for(t1=save_x;t1<=save_x2;t1++) {
  1682. for(t2=save_y;t2<=save_y2;t2++) {
  1683. if(draw_mode<128) {
  1684. t3=level_id[t1+t2*max_bxsiz];
  1685. if(t3==127) continue;//Player
  1686. if(t3==122) {//(sensor)
  1687. //Clear, copying to 0 first if param==curr
  1688. if((level_param[t1+t2*max_bxsiz]==curr_param)&&
  1689. (curr_thing==122)) {
  1690. copy_sensor(0,curr_param);
  1691. curr_param=0;
  1692. }
  1693. clear_sensor(level_param[t1+t2*max_bxsiz]);
  1694. }
  1695. else if((t3==123)||(t3==124)) {//(robot)
  1696. //Clear, copying to 0 first if param==curr
  1697. if((level_param[t1+t2*max_bxsiz]==curr_param)&&
  1698. ((curr_thing==123)||(curr_thing==124))) {
  1699. copy_robot(0,curr_param);
  1700. curr_param=0;
  1701. }
  1702. clear_robot(level_param[t1+t2*max_bxsiz]);
  1703. }
  1704. else if((t3==125)||(t3==126)) {//(scroll)
  1705. //Clear, copying to 0 first if param==curr
  1706. if((level_param[t1+t2*max_bxsiz]==curr_param)&&
  1707. ((curr_thing==125)||(curr_thing==126))) {
  1708. copy_scroll(0,curr_param);
  1709. curr_param=0;
  1710. }
  1711. clear_scroll(level_param[t1+t2*max_bxsiz]);
  1712. }
  1713. //Clear
  1714. id_clear(t1,t2);
  1715. }
  1716. else {
  1717. overlay[t1+t2*max_bxsiz]=32;
  1718. overlay_color[t1+t2*max_bxsiz]=7;
  1719. }
  1720. }
  1721. }
  1722. changed=1;
  1723. break;
  1724. case 3:
  1725. //Flip
  1726. if(draw_mode<128) {
  1727. t4=((save_y2-save_y)>>1)+save_y;
  1728. for(t1=save_x;t1<=save_x2;t1++) {
  1729. for(t2=save_y,t3=save_y2;t2<=t4;t2++,t3--) {
  1730. t5=level_id[t1+t2*max_bxsiz];
  1731. level_id[t1+t2*max_bxsiz]=level_id[t1+t3*max_bxsiz];
  1732. level_id[t1+t3*max_bxsiz]=t5;
  1733. t5=level_color[t1+t2*max_bxsiz];
  1734. level_color[t1+t2*max_bxsiz]=level_color[t1+t3*max_bxsiz];
  1735. level_color[t1+t3*max_bxsiz]=t5;
  1736. t5=level_param[t1+t2*max_bxsiz];
  1737. level_param[t1+t2*max_bxsiz]=level_param[t1+t3*max_bxsiz];
  1738. level_param[t1+t3*max_bxsiz]=t5;
  1739. t5=level_under_id[t1+t2*max_bxsiz];
  1740. level_under_id[t1+t2*max_bxsiz]=level_under_id[t1+t3*max_bxsiz];
  1741. level_under_id[t1+t3*max_bxsiz]=t5;
  1742. t5=level_under_color[t1+t2*max_bxsiz];
  1743. level_under_color[t1+t2*max_bxsiz]=level_under_color[t1+t3*max_bxsiz];
  1744. level_under_color[t1+t3*max_bxsiz]=t5;
  1745. t5=level_under_param[t1+t2*max_bxsiz];
  1746. level_under_param[t1+t2*max_bxsiz]=level_under_param[t1+t3*max_bxsiz];
  1747. level_under_param[t1+t3*max_bxsiz]=t5;
  1748. }
  1749. }
  1750. }
  1751. else {
  1752. t4=((save_y2-save_y)>>1)+save_y;
  1753. for(t1=save_x;t1<=save_x2;t1++) {
  1754. for(t2=save_y,t3=save_y2;t2<=t4;t2++,t3--) {
  1755. t5=overlay[t1+t2*max_bxsiz];
  1756. overlay[t1+t2*max_bxsiz]=overlay[t1+t3*max_bxsiz];
  1757. overlay[t1+t3*max_bxsiz]=t5;
  1758. t5=overlay_color[t1+t2*max_bxsiz];
  1759. overlay_color[t1+t2*max_bxsiz]=overlay_color[t1+t3*max_bxsiz];
  1760. overlay_color[t1+t3*max_bxsiz]=t5;
  1761. }
  1762. }
  1763. }
  1764. changed=1;
  1765. break;
  1766. case 4:
  1767. //Mirror
  1768. if(draw_mode<128) {
  1769. t4=((save_x2-save_x)>>1)+save_x;
  1770. for(t1=save_x,t3=save_x2;t1<=t4;t1++,t3--) {
  1771. for(t2=save_y;t2<=save_y2;t2++) {
  1772. t5=level_id[t1+t2*max_bxsiz];
  1773. level_id[t1+t2*max_bxsiz]=level_id[t3+t2*max_bxsiz];
  1774. level_id[t3+t2*max_bxsiz]=t5;
  1775. t5=level_color[t1+t2*max_bxsiz];
  1776. level_color[t1+t2*max_bxsiz]=level_color[t3+t2*max_bxsiz];
  1777. level_color[t3+t2*max_bxsiz]=t5;
  1778. t5=level_param[t1+t2*max_bxsiz];
  1779. level_param[t1+t2*max_bxsiz]=level_param[t3+t2*max_bxsiz];
  1780. level_param[t3+t2*max_bxsiz]=t5;
  1781. t5=level_under_id[t1+t2*max_bxsiz];
  1782. level_under_id[t1+t2*max_bxsiz]=level_under_id[t3+t2*max_bxsiz];
  1783. level_under_id[t3+t2*max_bxsiz]=t5;
  1784. t5=level_under_color[t1+t2*max_bxsiz];
  1785. level_under_color[t1+t2*max_bxsiz]=level_under_color[t3+t2*max_bxsiz];
  1786. level_under_color[t3+t2*max_bxsiz]=t5;
  1787. t5=level_under_param[t1+t2*max_bxsiz];
  1788. level_under_param[t1+t2*max_bxsiz]=level_under_param[t3+t2*max_bxsiz];
  1789. level_under_param[t3+t2*max_bxsiz]=t5;
  1790. }
  1791. }
  1792. }
  1793. else {
  1794. t4=((save_x2-save_x)>>1)+save_x;
  1795. for(t1=save_x,t3=save_x2;t1<=t4;t1++,t3--) {
  1796. for(t2=save_y;t2<=save_y2;t2++) {
  1797. t5=overlay[t1+t2*max_bxsiz];
  1798. overlay[t1+t2*max_bxsiz]=overlay[t3+t2*max_bxsiz];
  1799. overlay[t3+t2*max_bxsiz]=t5;
  1800. t5=overlay_color[t1+t2*max_bxsiz];
  1801. overlay_color[t1+t2*max_bxsiz]=overlay_color[t3+t2*max_bxsiz];
  1802. overlay_color[t3+t2*max_bxsiz]=t5;
  1803. }
  1804. }
  1805. }
  1806. changed=1;
  1807. break;
  1808. case 5:
  1809. //Paint
  1810. if(draw_mode<128) {
  1811. for(t1=save_x;t1<=save_x2;t1++)
  1812. for(t2=save_y;t2<=save_y2;t2++)
  1813. level_color[t1+t2*max_bxsiz]=curr_color;
  1814. }
  1815. else {
  1816. for(t1=save_x;t1<=save_x2;t1++)
  1817. for(t2=save_y;t2<=save_y2;t2++)
  1818. overlay_color[t1+t2*max_bxsiz]=curr_color;
  1819. }
  1820. changed=1;
  1821. break;
  1822. case 6:
  1823. //Main <-> overlay
  1824. if(overlay_mode==0) {
  1825. error("Overlay mode is not on (see Board Info)",0,24,
  1826. current_pg_seg,0x1102);
  1827. break;
  1828. }
  1829. blk_cmd=t1;
  1830. if(draw_mode<128) {
  1831. //Clear current object...
  1832. if((curr_thing==122)&&(curr_param==0))
  1833. clear_sensor(0);
  1834. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0))
  1835. clear_robot(0);
  1836. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0))
  1837. clear_scroll(0);
  1838. curr_thing=0;
  1839. curr_color=7;
  1840. curr_param=32;
  1841. //Draw mode fix
  1842. draw_mode=132;
  1843. //Update
  1844. update_menu=update_view=1;
  1845. //Done
  1846. break;
  1847. }
  1848. //Turn off-
  1849. curr_thing=0;
  1850. curr_color=7;
  1851. curr_param=0;
  1852. //Draw mode fix
  1853. draw_mode=4;
  1854. //Update
  1855. update_menu=update_view=1;
  1856. break;
  1857. case 7:
  1858. //Pw check
  1859. //if(protection_method==NO_SAVING)
  1860. //if(check_pw()) break;
  1861. //Save as ANSi
  1862. temp[0]=0;
  1863. if(save_file_dialog("Block ANSi Save","Save block as: ",temp))
  1864. break;
  1865. add_ext(temp,".ANS");
  1866. t1=overlay_mode;
  1867. if(draw_mode&128) overlay_mode=1|(64*(show_level==0));
  1868. else overlay_mode=128;
  1869. export_ansi(temp,save_x,save_y,save_x2,save_y2,0);
  1870. overlay_mode=t1;
  1871. break;
  1872. }
  1873. break;
  1874. case -24://AltO
  1875. //Overlay mode
  1876. //Turn on-
  1877. if(draw_mode<128) {
  1878. //Is overlay mode ON !?
  1879. if(overlay_mode==0) {
  1880. error("Overlay mode is not on (see Board Info)",0,24,
  1881. current_pg_seg,0x1101);
  1882. break;
  1883. }
  1884. //Clear current object...
  1885. if((curr_thing==122)&&(curr_param==0))
  1886. clear_sensor(0);
  1887. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0))
  1888. clear_robot(0);
  1889. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0))
  1890. clear_scroll(0);
  1891. curr_thing=0;
  1892. curr_color=7;
  1893. curr_param=32;
  1894. //Draw mode fix
  1895. draw_mode=128;
  1896. //Update
  1897. update_menu=update_view=1;
  1898. //Done
  1899. context=81;
  1900. break;
  1901. }
  1902. overlay_off:
  1903. context=80;
  1904. //Turn off-
  1905. curr_thing=0;
  1906. curr_color=7;
  1907. curr_param=0;
  1908. //Draw mode fix
  1909. draw_mode=0;
  1910. //Update
  1911. update_menu=update_view=1;
  1912. break;
  1913. case -46://AltC
  1914. if(draw_mode&128) break;
  1915. //Edit char set
  1916. char_editor();
  1917. changed=1;
  1918. break;
  1919. case -18://AltE
  1920. if(draw_mode&128) break;
  1921. //Edit palette
  1922. palette_editor();
  1923. changed=1;
  1924. break;
  1925. case 'G'://G
  1926. if(draw_mode&128) break;
  1927. //Global info
  1928. global_info();
  1929. changed=1;
  1930. update_menu=update_view=1;
  1931. break;
  1932. case -84://ShF1
  1933. if(draw_mode&128) break;
  1934. //Show invisible walls
  1935. //Loop, fiddling with global chars and showing.
  1936. t1=id_chars[71];
  1937. overlay_mode|=128;
  1938. do {
  1939. id_chars[71]=178;
  1940. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1941. id_chars[71]=176;
  1942. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1943. } while(!keywaiting());
  1944. overlay_mode&=~128;
  1945. getkey();
  1946. id_chars[71]=t1;
  1947. update_view=1;
  1948. break;
  1949. case -85://ShF2
  1950. if(draw_mode&128) break;
  1951. //Show robots
  1952. //Loop, fiddling with global chars and showing.
  1953. overlay_mode|=128;
  1954. do {
  1955. id_chars[123]='!';
  1956. id_chars[124]='!';
  1957. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1958. id_chars[123]=0;
  1959. id_chars[124]=0;
  1960. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1961. } while(!keywaiting());
  1962. overlay_mode&=~128;
  1963. getkey();
  1964. update_menu=1;//Redraw debug menu if needed
  1965. break;
  1966. case -86://ShF3
  1967. if(draw_mode&128) break;
  1968. //Show fakes
  1969. //Loop, fiddling with global chars and showing.
  1970. t1=id_chars[13];
  1971. t2=id_chars[14];
  1972. t3=id_chars[15];
  1973. t4=id_chars[16];
  1974. overlay_mode|=128;
  1975. do {
  1976. for(t5=13;t5<20;t5++) id_chars[t5]='#';
  1977. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1978. for(t5=13;t5<20;t5++) id_chars[t5]=177;
  1979. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  1980. } while(!keywaiting());
  1981. overlay_mode&=~128;
  1982. getkey();
  1983. id_chars[13]=t1;
  1984. id_chars[14]=t2;
  1985. id_chars[15]=t3;
  1986. id_chars[16]=t4;
  1987. id_chars[17]=255;
  1988. id_chars[18]=0;
  1989. id_chars[19]=0;
  1990. update_view=1;
  1991. break;
  1992. case -87://ShF4
  1993. if(draw_mode&128) break;
  1994. //Show spaces
  1995. //Loop, fiddling with global chars and showing.
  1996. t1=id_chars[0];
  1997. overlay_mode|=128;
  1998. do {
  1999. id_chars[0]='O';
  2000. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  2001. id_chars[0]='*';
  2002. draw_edit_window(x_top_pos,y_top_pos,current_pg_seg);
  2003. } while(!keywaiting());
  2004. overlay_mode&=~128;
  2005. getkey();
  2006. id_chars[0]=t1;
  2007. update_view=1;
  2008. break;/*
  2009. case -90://ShF7
  2010. set_counter("SMZX_MODE",smzx_mode + 1, 0);
  2011. update_view=update_menu=1;
  2012. break; */
  2013. case 'I'://I
  2014. if(draw_mode&128) break;
  2015. //Board info
  2016. board_info();
  2017. changed=1;
  2018. break;
  2019. case -25://AltP
  2020. if(draw_mode&128) break;
  2021. t1=board_xsiz;
  2022. t2=board_ysiz;
  2023. t3=max_bxsiz;
  2024. t4=max_bysiz;
  2025. //Size/pos
  2026. size_pos();
  2027. //Fix x/y
  2028. if(ARRAY_X>=board_xsiz) x_pos=x_top_pos=0;
  2029. if(ARRAY_Y>=board_ysiz) y_pos=y_top_pos=0;
  2030. if((x_top_pos+80)>board_xsiz) x_top_pos=0;
  2031. if((y_top_pos+19)>board_ysiz) x_top_pos=0;
  2032. //Board size change?
  2033. if((t1!=board_xsiz)||(t2!=board_ysiz)||(t3!=max_bxsiz)||
  2034. (t4!=max_bysiz)) {
  2035. //Yep. save board to file, using old sizes.
  2036. fp=fopen("~EDITRSZ.TMP","wb+");
  2037. if(fp==NULL) {
  2038. error("Error accessing temp file, ~EDITRSZ.TMP",1,24,
  2039. current_pg_seg,0x3601);
  2040. break;
  2041. }
  2042. for(t5=0;t5<t1;t5++) {
  2043. for(t6=0;t6<t2;t6++) {
  2044. fputc(level_id[t5+t6*t3],fp);
  2045. fputc(level_color[t5+t6*t3],fp);
  2046. fputc(level_param[t5+t6*t3],fp);
  2047. fputc(level_under_id[t5+t6*t3],fp);
  2048. fputc(level_under_color[t5+t6*t3],fp);
  2049. fputc(level_under_param[t5+t6*t3],fp);
  2050. fputc(overlay[t5+t6*t3],fp);
  2051. fputc(overlay_color[t5+t6*t3],fp);
  2052. }
  2053. }
  2054. fseek(fp,0,SEEK_SET);
  2055. //Now clear board...
  2056. for(t5=0;t5<10000;t5++) {
  2057. level_id[t5]=level_under_id[t5]=0;
  2058. level_param[t5]=level_under_param[t5]=0;
  2059. level_color[t5]=level_under_color[t5]=overlay_color[t5]=7;
  2060. overlay[t5]=32;
  2061. }
  2062. t0=0;//We didn't clear the player yet
  2063. //And reload
  2064. for(t5=0;t5<t1;t5++) {
  2065. for(t6=0;t6<t2;t6++) {
  2066. if((t5>=board_xsiz)||(t6>=board_ysiz)) {
  2067. //Not being placed. If a robot/scroll, delete
  2068. t7=fgetc(fp);
  2069. t8=fgetc(fp);//color
  2070. t9=fgetc(fp);//param
  2071. if(t7==127) t0=1;//player
  2072. else if(t7==122) {//(sensor)
  2073. //Clear, copying to 0 first if param==curr
  2074. if((t9==curr_param)&&
  2075. (curr_thing==122)) {
  2076. copy_sensor(0,curr_param);
  2077. curr_param=0;
  2078. }
  2079. clear_sensor(t9);
  2080. }
  2081. else if((t7==123)||(t7==124)) {//(robot)
  2082. //Clear, copying to 0 first if param==curr
  2083. if((t9==curr_param)&&
  2084. ((curr_thing==123)||(curr_thing==124))) {
  2085. copy_robot(0,curr_param);
  2086. curr_param=0;
  2087. }
  2088. clear_robot(t9);
  2089. }
  2090. else if((t7==125)||(t7==126)) {//(scroll)
  2091. //Clear, copying to 0 first if param==curr
  2092. if((t9==curr_param)&&
  2093. ((curr_thing==125)||(curr_thing==126))) {
  2094. copy_scroll(0,curr_param);
  2095. curr_param=0;
  2096. }
  2097. clear_scroll(t9);
  2098. }
  2099. //Under...
  2100. t7=fgetc(fp);
  2101. t8=fgetc(fp);
  2102. t9=fgetc(fp);
  2103. if(t7==122) {//(sensor)
  2104. //Clear, copying to 0 first if param==curr
  2105. if((t9==curr_param)&&
  2106. (curr_thing==122)) {
  2107. copy_sensor(0,curr_param);
  2108. curr_param=0;
  2109. }
  2110. clear_sensor(t9);
  2111. }
  2112. //Overlay...
  2113. fgetc(fp);
  2114. fgetc(fp);
  2115. }
  2116. else {
  2117. //Place into new board
  2118. t7=t5+t6*max_bxsiz;
  2119. level_id[t7]=fgetc(fp);
  2120. level_color[t7]=fgetc(fp);
  2121. level_param[t7]=fgetc(fp);
  2122. level_under_id[t7]=fgetc(fp);
  2123. level_under_color[t7]=fgetc(fp);
  2124. level_under_param[t7]=fgetc(fp);
  2125. overlay[t7]=fgetc(fp);
  2126. overlay_color[t7]=fgetc(fp);
  2127. }
  2128. }
  2129. }
  2130. if(t0) {
  2131. //Place player at first empty space
  2132. t4=0;
  2133. for(t1=0;t1<board_xsiz;t1++) {
  2134. for(t2=0;t2<board_ysiz;t2++) {
  2135. t3=level_id[t1+t2*max_bxsiz];
  2136. if(t3<120) t4=t1+t2*max_bxsiz;
  2137. if(level_id[t1+t2*max_bxsiz]) continue;
  2138. id_place(t1,t2,127,0,0);
  2139. goto donneth;
  2140. }
  2141. }
  2142. //Put at first non-robot/scroll/sign/sensor
  2143. offs_place_id(t4,0,127,0,0);
  2144. }
  2145. fclose(fp);
  2146. unlink("~EDITRSZ.TMP");
  2147. }
  2148. donneth:
  2149. changed=1;
  2150. update_menu=update_view=1;
  2151. break;
  2152. case 'X'://X
  2153. if(draw_mode&128) break;
  2154. //Exits
  2155. board_exits();
  2156. changed=1;
  2157. break;
  2158. case -31://AltS
  2159. if(draw_mode&128) {
  2160. //Whether to show level in overlay mode
  2161. update_view=update_menu=1;
  2162. show_level^=1;
  2163. break;
  2164. }
  2165. //Status counter info
  2166. status_counter_info();
  2167. changed=1;
  2168. break;
  2169. case -19://AltR
  2170. if(draw_mode&128) break;
  2171. //Restart
  2172. if(!confirm("Clear ALL- Are you sure?")) {
  2173. //If current object is a robot/etc of not #0, copy to #0.
  2174. if((curr_thing==122)&&(curr_param!=0)) {
  2175. copy_sensor(0,curr_param);
  2176. curr_param=0;
  2177. }
  2178. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2179. //No room = forget it!
  2180. if(!copy_robot(0,curr_param)) curr_param=0;
  2181. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2182. //No room = forget it!
  2183. if(!copy_scroll(0,curr_param)) curr_param=0;
  2184. //If pw-protection is NO_SAVING, clear curr_objects
  2185. //if(protection_method==NO_SAVING) {
  2186. // clear_zero_objects();
  2187. // curr_thing=curr_param=0;
  2188. // curr_color=7;
  2189. // }
  2190. clear_world();
  2191. changed=0;
  2192. update_menu=update_view=1;
  2193. draw_mode=0;
  2194. }
  2195. break;
  2196. case 'L'://L
  2197. if(draw_mode&128) break;
  2198. //Changed?
  2199. if(changed)
  2200. if(confirm("Load: World has not been saved, are you sure?")) break;
  2201. //Load world
  2202. if(!choose_file("*.MZX",temp,"Choose world to load",1)) {
  2203. //If current object is a robot/etc of not #0, copy to #0.
  2204. if((curr_thing==122)&&(curr_param!=0)) {
  2205. copy_sensor(0,curr_param);
  2206. curr_param=0;
  2207. }
  2208. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2209. //No room = forget it!
  2210. if(!copy_robot(0,curr_param)) curr_param=0;
  2211. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2212. //No room = forget it!
  2213. if(!copy_scroll(0,curr_param)) curr_param=0;
  2214. //If pw-protection is NO_SAVING, clear curr_objects
  2215. //if(protection_method==NO_SAVING) {
  2216. // clear_zero_objects();
  2217. // curr_thing=curr_param=0;
  2218. // curr_color=7;
  2219. // }
  2220. //Swap out current board...
  2221. store_current();
  2222. clear_current();
  2223. //Load game
  2224. if(load_world(temp,1)) {
  2225. select_current(curr_board);
  2226. break;
  2227. }
  2228. //Swap in starting board
  2229. if(board_where[first_board]!=W_NOWHERE)
  2230. select_current(first_board);
  2231. else select_current(0);
  2232. changed=0;
  2233. update_menu=update_view=1;
  2234. x_pos=x_top_pos=y_pos=y_top_pos=draw_mode=0;
  2235. //Copy filename
  2236. str_cpy(curr_file,temp);
  2237. }
  2238. break;
  2239. case 'S'://S
  2240. if(draw_mode&128) break;
  2241. //Pw check
  2242. //if(protection_method==NO_SAVING)
  2243. // if(check_pw()) break;
  2244. //Save world
  2245. if(!save_world_dialog()) {
  2246. //Name in curr_file...
  2247. if(curr_file[0]==0) break;
  2248. add_ext(curr_file,".MZX");
  2249. //Check for an overwrite
  2250. if((fp=fopen(curr_file,"rb"))!=NULL) {
  2251. fclose(fp);
  2252. if(confirm("File exists- Overwrite?")) break;
  2253. }
  2254. //If current object is a robot/etc of not #0, copy to #0.
  2255. if((curr_thing==122)&&(curr_param!=0)) {
  2256. copy_sensor(0,curr_param);
  2257. curr_param=0;
  2258. }
  2259. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2260. //No room = forget it!
  2261. if(!copy_robot(0,curr_param)) curr_param=0;
  2262. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2263. //No room = forget it!
  2264. if(!copy_scroll(0,curr_param)) curr_param=0;
  2265. //Store current
  2266. store_current();
  2267. //Save entire game
  2268. save_world(curr_file);
  2269. //Reload current
  2270. select_current(curr_board);
  2271. changed=0;
  2272. update_view=update_menu=1;
  2273. }
  2274. break;
  2275. case 'D'://D
  2276. if(draw_mode&128) break;
  2277. //Delete board
  2278. //Choose which one...
  2279. t1=choose_board(curr_board,"Delete board:",current_pg_seg);
  2280. if(t1>0) {
  2281. if(confirm("DELETE BOARD- Are you sure?")) break;
  2282. //Deleting board t1. Current?
  2283. if(curr_board==t1) {
  2284. //Fix objects and swap to 0
  2285. //If current object is a robot/etc of not #0, copy to #0.
  2286. if((curr_thing==122)&&(curr_param!=0)) {
  2287. copy_sensor(0,curr_param);
  2288. curr_param=0;
  2289. }
  2290. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2291. //No room = forget it!
  2292. if(!copy_robot(0,curr_param)) curr_param=0;
  2293. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2294. //No room = forget it!
  2295. if(!copy_scroll(0,curr_param)) curr_param=0;
  2296. swap_with(0);
  2297. //Update x/y
  2298. if(ARRAY_X>=board_xsiz) x_pos=x_top_pos=0;
  2299. if(ARRAY_Y>=board_ysiz) y_pos=y_top_pos=0;
  2300. if((x_top_pos+80)>board_xsiz) x_top_pos=0;
  2301. if((y_top_pos+19)>board_ysiz) x_top_pos=0;
  2302. }
  2303. //Delete it if it isn't already
  2304. if(board_where[t1]!=W_NOWHERE) delete_board(t1);
  2305. //Fix starting board if neccessary
  2306. if(t1==first_board) first_board=0;
  2307. changed=1;
  2308. }
  2309. update_view=update_menu=1;
  2310. break;
  2311. case 'B'://B
  2312. if(draw_mode&128) break;
  2313. //Select board
  2314. //If current object is a robot/etc of not #0, copy to #0.
  2315. if((curr_thing==122)&&(curr_param!=0)) {
  2316. copy_sensor(0,curr_param);
  2317. curr_param=0;
  2318. }
  2319. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2320. //No room = forget it!
  2321. if(!copy_robot(0,curr_param)) curr_param=0;
  2322. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2323. //No room = forget it!
  2324. if(!copy_scroll(0,curr_param)) curr_param=0;
  2325. //Choose...
  2326. t1=choose_board(curr_board,"Select current board:",current_pg_seg);
  2327. if(t1>=0) swap_with(t1);
  2328. draw_mode=0;
  2329. update_view=update_menu=1;
  2330. //Update x/y
  2331. if(ARRAY_X>=board_xsiz) x_pos=x_top_pos=0;
  2332. if(ARRAY_Y>=board_ysiz) y_pos=y_top_pos=0;
  2333. if((x_top_pos+80)>board_xsiz) x_top_pos=0;
  2334. if((y_top_pos+19)>board_ysiz) y_top_pos=0;
  2335. break;
  2336. case 'A'://A
  2337. if(draw_mode&128) break;
  2338. //Add board
  2339. //Search for empty...
  2340. for(t1=0;t1<NUM_BOARDS;t1++)
  2341. if(board_where[t1]==W_NOWHERE) break;
  2342. if(t1>=NUM_BOARDS) {
  2343. error("No available boards",1,24,current_pg_seg,0x0B01);
  2344. break;
  2345. }
  2346. //Input a name
  2347. m_hide();
  2348. save_screen(current_pg_seg);
  2349. draw_window_box(16,12,64,14,current_pg_seg,EC_DEBUG_BOX,
  2350. EC_DEBUG_BOX_DARK,EC_DEBUG_BOX_CORNER);
  2351. write_string("Name for new board:",18,13,EC_DEBUG_LABEL,
  2352. current_pg_seg);
  2353. update_menu=update_view=1;
  2354. board_list[t1*BOARD_NAME_SIZE]=0;
  2355. m_show();
  2356. if(intake(&board_list[t1*BOARD_NAME_SIZE],BOARD_NAME_SIZE-1,
  2357. 38,13,current_pg_seg,15,1,0)==27) {
  2358. restore_screen(current_pg_seg);
  2359. break;
  2360. }
  2361. restore_screen(current_pg_seg);
  2362. //If current object is a robot/etc of not #0, copy to #0.
  2363. if((curr_thing==122)&&(curr_param!=0)) {
  2364. copy_sensor(0,curr_param);
  2365. curr_param=0;
  2366. }
  2367. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  2368. //No room = forget it!
  2369. if(!copy_robot(0,curr_param)) curr_param=0;
  2370. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  2371. //No room = forget it!
  2372. if(!copy_scroll(0,curr_param)) curr_param=0;
  2373. //Store current
  2374. store_current();
  2375. //Add at number t1
  2376. clear_current_and_select(t1);
  2377. board_where[curr_board=t1]=W_CURRENT;
  2378. board_sizes[t1]=0;
  2379. changed=1;
  2380. //No need to fix x/y position since sizing info is taken
  2381. //from current board.
  2382. break;
  2383. case 27://ESC
  2384. //ESC cancels draw mode if any, instead of exiting
  2385. if((draw_mode&127)>0) {
  2386. draw_mode&=128;
  2387. update_view=update_menu=1;
  2388. key=0;
  2389. }
  2390. //If none, tries to cancel overlay mode
  2391. else if(draw_mode&128) {
  2392. key=0;
  2393. goto overlay_off;
  2394. }
  2395. //Else we will exit-
  2396. else if(changed)
  2397. if(confirm("Exit: World has not been saved, are you sure?")) {
  2398. key=0;
  2399. break;
  2400. }
  2401. break;
  2402. case -81://Pgdn
  2403. next_menu:
  2404. if(draw_mode&128) break;
  2405. if(curr_menu<(NUM_MENUS-1)) curr_menu++;
  2406. else curr_menu=0;
  2407. update_menu=1;
  2408. break;
  2409. case -73://Pgup
  2410. prev_menu:
  2411. if(draw_mode&128) break;
  2412. if(curr_menu>0) curr_menu--;
  2413. else curr_menu=NUM_MENUS-1;
  2414. update_menu=1;
  2415. break;
  2416. case -71://Home
  2417. x_pos=y_pos=x_top_pos=y_top_pos=0;
  2418. update_view=1;
  2419. debug_x=65;
  2420. break;
  2421. case -79://End
  2422. if(board_xsiz<80) {
  2423. x_top_pos=0;
  2424. x_pos=board_xsiz-1;
  2425. }
  2426. else {
  2427. x_pos=79;
  2428. x_top_pos=board_xsiz-x_pos-1;
  2429. }
  2430. if(board_ysiz<19) {
  2431. y_top_pos=0;
  2432. y_pos=board_ysiz-1;
  2433. }
  2434. else {
  2435. y_pos=18;
  2436. y_top_pos=board_ysiz-y_pos-1;
  2437. }
  2438. update_view=1;
  2439. debug_x=0;
  2440. break;
  2441. case -77://Right
  2442. case -157://AltRight
  2443. move_right:
  2444. if(key==-157) t1=10;
  2445. else t1=1;
  2446. for(;t1>0;t1--) {//By amount
  2447. //At edge?
  2448. if(ARRAY_X<(board_xsiz-1)) {
  2449. //Nope- Do a little incrementing.
  2450. //If x position < 74, move right one.
  2451. //Else scroll right one, unless can't, then
  2452. //move right one.
  2453. if(x_pos<74) x_pos++;
  2454. else {
  2455. if((x_top_pos+80)<board_xsiz) {
  2456. x_top_pos++;
  2457. update_view=1;
  2458. }
  2459. else x_pos++;
  2460. }
  2461. //Move debug window?
  2462. if((debug_x==65)&&(x_pos>59)) {
  2463. debug_x=0;
  2464. update_view=1;
  2465. }
  2466. //Draw? (only if not last movement)
  2467. if((t1)&&((draw_mode&127)==1)) {
  2468. if(draw_mode&128) {
  2469. overlay[ARRAY_OFFS]=curr_param;
  2470. overlay_color[ARRAY_OFFS]=curr_color;
  2471. update_view=1;
  2472. }
  2473. else if(level_id[ARRAY_OFFS]!=127) {//No overwriting player
  2474. //If a robot/scroll/sensor...
  2475. if(curr_thing==122) {//(sensor)
  2476. //...make a copy...
  2477. if(!(t2=find_sensor())) {
  2478. error("No available sensors",1,24,current_pg_seg,0x0801);
  2479. break;
  2480. }
  2481. copy_sensor(t2,curr_param);
  2482. //...and deallocate original if it was number 0.
  2483. if(curr_param==0) clear_sensor(0);
  2484. curr_param=t2;
  2485. }
  2486. if((curr_thing==123)||(curr_thing==124)) {//(robot)
  2487. //...make a copy...
  2488. if(!(t2=find_robot())) {
  2489. error("No available robots",1,24,current_pg_seg,0x0901);
  2490. break;
  2491. }
  2492. if(copy_robot(t2,curr_param)) {
  2493. robots[t2].used=0;
  2494. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  2495. break;
  2496. }
  2497. //...and deallocate original if it was number 0.
  2498. if(curr_param==0) clear_robot(0);
  2499. curr_param=t2;
  2500. }
  2501. if((curr_thing==125)||(curr_thing==126)) {//(scroll)
  2502. //...make a copy...
  2503. if(!(t2=find_scroll())) {
  2504. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  2505. break;
  2506. }
  2507. if(copy_scroll(t2,curr_param)) {
  2508. robots[t2].used=0;
  2509. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  2510. break;
  2511. }
  2512. //...and deallocate original if it was number 0.
  2513. if(curr_param==0) clear_scroll(0);
  2514. curr_param=t2;
  2515. }
  2516. //Search and erase old players if placing a player.
  2517. if(curr_thing==127)
  2518. for(t2=0;t2<board_xsiz;t2++)
  2519. for(t3=0;t3<board_ysiz;t3++)
  2520. if(level_id[t2+t3*max_bxsiz]==127)
  2521. id_remove_top(t2,t3);
  2522. //If top thing at position is a robot/etc, deallocate it.
  2523. t2=level_id[ARRAY_OFFS];
  2524. if((t2==122)&&(curr_thing!=127)) //(sensor)
  2525. clear_sensor(level_param[ARRAY_OFFS]);
  2526. else if((t2==123)||(t2==124)) //(robot)
  2527. clear_robot(level_param[ARRAY_OFFS]);
  2528. else if((t2==125)||(t2==126)) //(scroll)
  2529. clear_scroll(level_param[ARRAY_OFFS]);
  2530. //Place.
  2531. id_place(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  2532. }
  2533. }
  2534. }
  2535. }
  2536. if((draw_mode&127)==1) goto place;
  2537. if((draw_mode&127)==3) update_view=1;
  2538. break;
  2539. case -75://Left
  2540. case -155://AltLeft
  2541. if(key==-155) t1=10;
  2542. else t1=1;
  2543. for(;t1>0;t1--) {//By amount
  2544. //At edge?
  2545. if(ARRAY_X>0) {
  2546. //Nope- Do a little decrementing.
  2547. //If x position > 5, move left one.
  2548. //Else scroll left one, unless can't, then
  2549. //move left one.
  2550. if(x_pos>5) x_pos--;
  2551. else {
  2552. if(x_top_pos>0) {
  2553. x_top_pos--;
  2554. update_view=1;
  2555. }
  2556. else x_pos--;
  2557. }
  2558. //Move debug window?
  2559. if((debug_x==0)&&(x_pos<20)) {
  2560. debug_x=65;
  2561. update_view=1;
  2562. }
  2563. //Draw? (only if not last movement)
  2564. if((t1)&&((draw_mode&127)==1)) {
  2565. if(draw_mode&128) {
  2566. overlay[ARRAY_OFFS]=curr_param;
  2567. overlay_color[ARRAY_OFFS]=curr_color;
  2568. update_view=1;
  2569. }
  2570. else if(level_id[ARRAY_OFFS]!=127) {//No overwriting player
  2571. //If a robot/scroll/sensor...
  2572. if(curr_thing==122) {//(sensor)
  2573. //...make a copy...
  2574. if(!(t2=find_sensor())) {
  2575. error("No available sensors",1,24,current_pg_seg,0x0801);
  2576. break;
  2577. }
  2578. copy_sensor(t2,curr_param);
  2579. //...and deallocate original if it was number 0.
  2580. if(curr_param==0) clear_sensor(0);
  2581. curr_param=t2;
  2582. }
  2583. if((curr_thing==123)||(curr_thing==124)) {//(robot)
  2584. //...make a copy...
  2585. if(!(t2=find_robot())) {
  2586. error("No available robots",1,24,current_pg_seg,0x0901);
  2587. break;
  2588. }
  2589. if(copy_robot(t2,curr_param)) {
  2590. robots[t2].used=0;
  2591. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  2592. break;
  2593. }
  2594. //...and deallocate original if it was number 0.
  2595. if(curr_param==0) clear_robot(0);
  2596. curr_param=t2;
  2597. }
  2598. if((curr_thing==125)||(curr_thing==126)) {//(scroll)
  2599. //...make a copy...
  2600. if(!(t2=find_scroll())) {
  2601. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  2602. break;
  2603. }
  2604. if(copy_scroll(t2,curr_param)) {
  2605. robots[t2].used=0;
  2606. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  2607. break;
  2608. }
  2609. //...and deallocate original if it was number 0.
  2610. if(curr_param==0) clear_scroll(0);
  2611. curr_param=t2;
  2612. }
  2613. //Search and erase old players if placing a player.
  2614. if(curr_thing==127)
  2615. for(t2=0;t2<board_xsiz;t2++)
  2616. for(t3=0;t3<board_ysiz;t3++)
  2617. if(level_id[t2+t3*max_bxsiz]==127)
  2618. id_remove_top(t2,t3);
  2619. //If top thing at position is a robot/etc, deallocate it.
  2620. t2=level_id[ARRAY_OFFS];
  2621. if((t2==122)&&(curr_thing!=127)) //(sensor)
  2622. clear_sensor(level_param[ARRAY_OFFS]);
  2623. else if((t2==123)||(t2==124)) //(robot)
  2624. clear_robot(level_param[ARRAY_OFFS]);
  2625. else if((t2==125)||(t2==126)) //(scroll)
  2626. clear_scroll(level_param[ARRAY_OFFS]);
  2627. //Place.
  2628. id_place(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  2629. }
  2630. }
  2631. }
  2632. }
  2633. if((draw_mode&127)==1) goto place;
  2634. if((draw_mode&127)==3) update_view=1;
  2635. break;
  2636. case 8://Backspace
  2637. //Delete to the left...first move left in text mode
  2638. //At edge?
  2639. if((ARRAY_X>0)&&((draw_mode&127)==2)) {
  2640. //Nope- Do a little decrementing.
  2641. //If x position > 5, move left one.
  2642. //Else scroll left one, unless can't, then
  2643. //move left one.
  2644. if(x_pos>5) x_pos--;
  2645. else {
  2646. if(x_top_pos>0) x_top_pos--;
  2647. else x_pos--;
  2648. }
  2649. //Move debug window?
  2650. if((debug_x==0)&&(x_pos<20)) debug_x=65;
  2651. }
  2652. //Jump to delete
  2653. goto erase;
  2654. case -80://Down
  2655. case -160://AltDown
  2656. move_down:
  2657. if(key==-160) t1=10;
  2658. else t1=1;
  2659. for(;t1>0;t1--) {//By amount
  2660. //At edge?
  2661. if(ARRAY_Y<(board_ysiz-1)) {
  2662. //Nope- Do a little incrementing.
  2663. //If y position < 14, move down one.
  2664. //Else scroll down one, unless can't, then
  2665. //move down one.
  2666. if(y_pos<14) y_pos++;
  2667. else {
  2668. if((y_top_pos+19)<board_ysiz) {
  2669. y_top_pos++;
  2670. update_view=1;
  2671. }
  2672. else y_pos++;
  2673. }
  2674. //Draw? (only if not last movement)
  2675. if((t1)&&((draw_mode&127)==1)) {
  2676. if(draw_mode&128) {
  2677. overlay[ARRAY_OFFS]=curr_param;
  2678. overlay_color[ARRAY_OFFS]=curr_color;
  2679. update_view=1;
  2680. }
  2681. else if(level_id[ARRAY_OFFS]!=127) {//No overwriting player
  2682. //If a robot/scroll/sensor...
  2683. if(curr_thing==122) {//(sensor)
  2684. //...make a copy...
  2685. if(!(t2=find_sensor())) {
  2686. error("No available sensors",1,24,current_pg_seg,0x0801);
  2687. break;
  2688. }
  2689. copy_sensor(t2,curr_param);
  2690. //...and deallocate original if it was number 0.
  2691. if(curr_param==0) clear_sensor(0);
  2692. curr_param=t2;
  2693. }
  2694. if((curr_thing==123)||(curr_thing==124)) {//(robot)
  2695. //...make a copy...
  2696. if(!(t2=find_robot())) {
  2697. error("No available robots",1,24,current_pg_seg,0x0901);
  2698. break;
  2699. }
  2700. if(copy_robot(t2,curr_param)) {
  2701. robots[t2].used=0;
  2702. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  2703. break;
  2704. }
  2705. //...and deallocate original if it was number 0.
  2706. if(curr_param==0) clear_robot(0);
  2707. curr_param=t2;
  2708. }
  2709. if((curr_thing==125)||(curr_thing==126)) {//(scroll)
  2710. //...make a copy...
  2711. if(!(t2=find_scroll())) {
  2712. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  2713. break;
  2714. }
  2715. if(copy_scroll(t2,curr_param)) {
  2716. robots[t2].used=0;
  2717. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  2718. break;
  2719. }
  2720. //...and deallocate original if it was number 0.
  2721. if(curr_param==0) clear_scroll(0);
  2722. curr_param=t2;
  2723. }
  2724. //Search and erase old players if placing a player.
  2725. if(curr_thing==127)
  2726. for(t2=0;t2<board_xsiz;t2++)
  2727. for(t3=0;t3<board_ysiz;t3++)
  2728. if(level_id[t2+t3*max_bxsiz]==127)
  2729. id_remove_top(t2,t3);
  2730. //If top thing at position is a robot/etc, deallocate it.
  2731. t2=level_id[ARRAY_OFFS];
  2732. if((t2==122)&&(curr_thing!=127)) //(sensor)
  2733. clear_sensor(level_param[ARRAY_OFFS]);
  2734. else if((t2==123)||(t2==124)) //(robot)
  2735. clear_robot(level_param[ARRAY_OFFS]);
  2736. else if((t2==125)||(t2==126)) //(scroll)
  2737. clear_scroll(level_param[ARRAY_OFFS]);
  2738. //Place.
  2739. id_place(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  2740. }
  2741. }
  2742. }
  2743. }
  2744. if((draw_mode&127)==1) goto place;
  2745. if((draw_mode&127)==3) update_view=1;
  2746. break;
  2747. case -72://Up
  2748. case -152://AltUp
  2749. if(key==-152) t1=10;
  2750. else t1=1;
  2751. for(;t1>0;t1--) {//By amount
  2752. //At edge?
  2753. if(ARRAY_Y>0) {
  2754. //Nope- Do a little decrementing.
  2755. //If y position > 4, move up one.
  2756. //Else scroll up one, unless can't, then
  2757. //move up one.
  2758. if(y_pos>4) y_pos--;
  2759. else {
  2760. if(y_top_pos>0) {
  2761. y_top_pos--;
  2762. update_view=1;
  2763. }
  2764. else y_pos--;
  2765. }
  2766. //Draw? (only if not last movement)
  2767. if((t1)&&((draw_mode&127)==1)) {
  2768. if(draw_mode&128) {
  2769. overlay[ARRAY_OFFS]=curr_param;
  2770. overlay_color[ARRAY_OFFS]=curr_color;
  2771. update_view=1;
  2772. }
  2773. else if(level_id[ARRAY_OFFS]!=127) {//No overwriting player
  2774. //If a robot/scroll/sensor...
  2775. if(curr_thing==122) {//(sensor)
  2776. //...make a copy...
  2777. if(!(t2=find_sensor())) {
  2778. error("No available sensors",1,24,current_pg_seg,0x0801);
  2779. break;
  2780. }
  2781. copy_sensor(t2,curr_param);
  2782. //...and deallocate original if it was number 0.
  2783. if(curr_param==0) clear_sensor(0);
  2784. curr_param=t2;
  2785. }
  2786. if((curr_thing==123)||(curr_thing==124)) {//(robot)
  2787. //...make a copy...
  2788. if(!(t2=find_robot())) {
  2789. error("No available robots",1,24,current_pg_seg,0x0901);
  2790. break;
  2791. }
  2792. if(copy_robot(t2,curr_param)) {
  2793. robots[t2].used=0;
  2794. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  2795. break;
  2796. }
  2797. //...and deallocate original if it was number 0.
  2798. if(curr_param==0) clear_robot(0);
  2799. curr_param=t2;
  2800. }
  2801. if((curr_thing==125)||(curr_thing==126)) {//(scroll)
  2802. //...make a copy...
  2803. if(!(t2=find_scroll())) {
  2804. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  2805. break;
  2806. }
  2807. if(copy_scroll(t2,curr_param)) {
  2808. robots[t2].used=0;
  2809. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  2810. break;
  2811. }
  2812. //...and deallocate original if it was number 0.
  2813. if(curr_param==0) clear_scroll(0);
  2814. curr_param=t2;
  2815. }
  2816. //Search and erase old players if placing a player.
  2817. if(curr_thing==127)
  2818. for(t2=0;t2<board_xsiz;t2++)
  2819. for(t3=0;t3<board_ysiz;t3++)
  2820. if(level_id[t2+t3*max_bxsiz]==127)
  2821. id_remove_top(t2,t3);
  2822. //If top thing at position is a robot/etc, deallocate it.
  2823. t2=level_id[ARRAY_OFFS];
  2824. if((t2==122)&&(curr_thing!=127)) //(sensor)
  2825. clear_sensor(level_param[ARRAY_OFFS]);
  2826. else if((t2==123)||(t2==124)) //(robot)
  2827. clear_robot(level_param[ARRAY_OFFS]);
  2828. else if((t2==125)||(t2==126)) //(scroll)
  2829. clear_scroll(level_param[ARRAY_OFFS]);
  2830. //Place.
  2831. id_place(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  2832. }
  2833. }
  2834. }
  2835. }
  2836. if((draw_mode&127)==1) goto place;
  2837. if((draw_mode&127)==3) update_view=1;
  2838. break;
  2839. case -21://AltY
  2840. //Toggle debug
  2841. debug_mode=!debug_mode;
  2842. update_view=update_menu=1;
  2843. break;
  2844. case -32://AltD
  2845. if(draw_mode&128) break;
  2846. //Toggle default colors
  2847. def_color_mode=!def_color_mode;
  2848. update_menu=1;
  2849. break;
  2850. case 32://Space
  2851. //Place, making copies properly for robots/scrolls/sensors,
  2852. //not deleting the player, and moving the player from it's
  2853. //original position if placed.
  2854. //If same id/color, erase
  2855. if(draw_mode&128) {
  2856. if((overlay[ARRAY_OFFS]==curr_param)&&
  2857. (overlay_color[ARRAY_OFFS]==curr_color)) goto erase;
  2858. }
  2859. else {
  2860. if((level_id[ARRAY_OFFS]==curr_thing)&&
  2861. (level_color[ARRAY_OFFS]==curr_color)) goto erase;
  2862. }
  2863. place:
  2864. changed=1;
  2865. //(place: label here since drawing and new things should
  2866. //ALWAYS work)
  2867. if(draw_mode&128) {
  2868. overlay[ARRAY_OFFS]=curr_param;
  2869. overlay_color[ARRAY_OFFS]=curr_color;
  2870. update_view=1;
  2871. break;
  2872. }
  2873. if(level_id[ARRAY_OFFS]==127) break;//No overwriting player
  2874. //If a robot/scroll/sensor...
  2875. if(curr_thing==122) {//(sensor)
  2876. //...make a copy...
  2877. if(!(t1=find_sensor())) {
  2878. error("No available sensors",1,24,current_pg_seg,0x0801);
  2879. break;
  2880. }
  2881. copy_sensor(t1,curr_param);
  2882. //...and deallocate original if it was number 0.
  2883. if(curr_param==0) clear_sensor(0);
  2884. curr_param=t1;
  2885. }
  2886. if((curr_thing==123)||(curr_thing==124)) {//(robot)
  2887. //...make a copy...
  2888. if(!(t1=find_robot())) {
  2889. error("No available robots",1,24,current_pg_seg,0x0901);
  2890. break;
  2891. }
  2892. if(copy_robot(t1,curr_param)) {
  2893. robots[t1].used=0;
  2894. error("Out of robot memory",1,21,current_pg_seg,0x0502);
  2895. break;
  2896. }
  2897. //...and deallocate original if it was number 0.
  2898. if(curr_param==0) clear_robot(0);
  2899. curr_param=t1;
  2900. }
  2901. if((curr_thing==125)||(curr_thing==126)) {//(scroll)
  2902. //...make a copy...
  2903. if(!(t1=find_scroll())) {
  2904. error("No available scrolls",1,24,current_pg_seg,0x0A01);
  2905. break;
  2906. }
  2907. if(copy_scroll(t1,curr_param)) {
  2908. robots[t1].used=0;
  2909. error("Out of robot memory",1,21,current_pg_seg,0x0503);
  2910. break;
  2911. }
  2912. //...and deallocate original if it was number 0.
  2913. if(curr_param==0) clear_scroll(0);
  2914. curr_param=t1;
  2915. }
  2916. //Search and erase old players if placing a player.
  2917. if(curr_thing==127)
  2918. for(t1=0;t1<board_xsiz;t1++)
  2919. for(t2=0;t2<board_ysiz;t2++)
  2920. if(level_id[t1+t2*max_bxsiz]==127)
  2921. id_remove_top(t1,t2);
  2922. //If top thing at position is a robot/etc, deallocate it.
  2923. t1=level_id[ARRAY_OFFS];
  2924. if((t1==122)&&(curr_thing!=127)) //(sensor)
  2925. clear_sensor(level_param[ARRAY_OFFS]);
  2926. else if((t1==123)||(t1==124)) //(robot)
  2927. clear_robot(level_param[ARRAY_OFFS]);
  2928. else if((t1==125)||(t1==126)) //(scroll)
  2929. clear_scroll(level_param[ARRAY_OFFS]);
  2930. //Place.
  2931. id_place(ARRAY_X,ARRAY_Y,curr_thing,curr_color,curr_param);
  2932. update_view=1;
  2933. break;
  2934. case -83://Del
  2935. erase:
  2936. changed=1;
  2937. //Erase
  2938. if(draw_mode&128) {
  2939. overlay[ARRAY_OFFS]=32;
  2940. overlay_color[ARRAY_OFFS]=7;
  2941. update_view=1;
  2942. break;
  2943. }
  2944. //Special for robots/scrolls/sensors
  2945. t1=level_id[ARRAY_OFFS];
  2946. if(t1==122) {//(sensor)
  2947. //Clear, copying to 0 first if param==curr
  2948. if((level_param[ARRAY_OFFS]==curr_param)&&
  2949. (curr_thing==122)) {
  2950. copy_sensor(0,curr_param);
  2951. curr_param=0;
  2952. }
  2953. clear_sensor(level_param[ARRAY_OFFS]);
  2954. }
  2955. else if((t1==123)||(t1==124)) {//(robot)
  2956. //Clear, copying to 0 first if param==curr
  2957. if((level_param[ARRAY_OFFS]==curr_param)&&
  2958. ((curr_thing==123)||(curr_thing==124))) {
  2959. copy_robot(0,curr_param);
  2960. curr_param=0;
  2961. }
  2962. clear_robot(level_param[ARRAY_OFFS]);
  2963. }
  2964. else if((t1==125)||(t1==126)) {//(scroll)
  2965. //Clear, copying to 0 first if param==curr
  2966. if((level_param[ARRAY_OFFS]==curr_param)&&
  2967. ((curr_thing==125)||(curr_thing==126))) {
  2968. copy_scroll(0,curr_param);
  2969. curr_param=0;
  2970. }
  2971. clear_scroll(level_param[ARRAY_OFFS]);
  2972. }
  2973. else if(t1==127) break;//No kill player
  2974. //Clear
  2975. id_clear(ARRAY_X,ARRAY_Y);
  2976. update_view=1;
  2977. break;
  2978. case 'C'://C
  2979. change_color:
  2980. //Change color
  2981. t1=color_selection(curr_color,current_pg_seg);
  2982. if(t1>-1) {
  2983. curr_color=t1;
  2984. update_menu=1;
  2985. }
  2986. break;
  2987. case -61://F3
  2988. case -62://F4
  2989. case -63://F5
  2990. case -64://F6
  2991. case -65://F7
  2992. case -66://F8
  2993. case -67://F9
  2994. case -68://F10
  2995. if(draw_mode&128) break;
  2996. //Over player?
  2997. if(level_id[ARRAY_OFFS]==127) {//No overwriting player
  2998. error("Cannot overwrite player- move him first",0,24,
  2999. current_pg_seg,0x3E01);
  3000. break;
  3001. }
  3002. //Unselecting #0?
  3003. if((curr_thing==122)&&(curr_param==0)) {
  3004. clear_sensor(0);
  3005. curr_thing=0;
  3006. }
  3007. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0)) {
  3008. clear_robot(0);
  3009. curr_thing=0;
  3010. }
  3011. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0)) {
  3012. clear_scroll(0);
  3013. curr_thing=0;
  3014. }
  3015. //Thing menus
  3016. t1=(-key)-61;//Menu # from 0 to 7
  3017. t2=list_menu(thing_menus[t1],20,tmenu_titles[t1],0,
  3018. tmenu_num_choices[t1],current_pg_seg);
  3019. if(t2>-1) {
  3020. t1=tmenu_thing_ids[t1][t2];
  3021. //Set param
  3022. t2=edit_param(t1,-1);
  3023. if(t2<0) break;//ESC
  3024. curr_thing=t1;//Thing
  3025. curr_param=t2;//Param
  3026. if(def_color_mode)//Set color
  3027. if(def_colors[curr_thing])
  3028. curr_color=def_colors[curr_thing];
  3029. update_menu=1;
  3030. goto place;//Now PLACE it!
  3031. }
  3032. break;
  3033. case -82://Insert
  3034. if(draw_mode&128) {
  3035. curr_param=overlay[ARRAY_OFFS];
  3036. curr_color=overlay_color[ARRAY_OFFS];
  3037. update_menu=1;
  3038. break;
  3039. }
  3040. //Grab. Only special case is if current is a sensor/etc. with
  3041. //param 0, then must free mem.
  3042. if((curr_thing==122)&&(curr_param==0))
  3043. clear_sensor(0);
  3044. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0))
  3045. clear_robot(0);
  3046. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0))
  3047. clear_scroll(0);
  3048. //Grab (gets objects properly, as a reference to copy from)
  3049. curr_thing=level_id[ARRAY_OFFS];
  3050. curr_param=level_param[ARRAY_OFFS];
  3051. curr_color=level_color[ARRAY_OFFS];
  3052. update_menu=1;
  3053. break;
  3054. case -50://AltM
  3055. if(draw_mode&128) break;
  3056. //Modify- Edit parameter of thing UNDER cursor. If it is our
  3057. //current object, we first copy ourselves to #0.
  3058. if((level_id[ARRAY_OFFS]==curr_thing)&&
  3059. (level_param[ARRAY_OFFS]==curr_param)) {
  3060. if(curr_thing==122) {
  3061. copy_sensor(0,curr_param);
  3062. curr_param=0;
  3063. }
  3064. else if((curr_thing==123)||(curr_thing==124)) {
  3065. //If out of mem, just don't copy!
  3066. if(!copy_robot(0,curr_param)) curr_param=0;
  3067. }
  3068. else if((curr_thing==125)||(curr_thing==126)) {
  3069. //If out of mem, just don't copy!
  3070. if(!copy_scroll(0,curr_param)) curr_param=0;
  3071. }
  3072. }
  3073. t2=edit_param(level_id[ARRAY_OFFS],level_param[ARRAY_OFFS]);
  3074. if(t2>-1) {
  3075. changed=1;
  3076. level_param[ARRAY_OFFS]=t2;
  3077. }
  3078. break;
  3079. case 13://Enter
  3080. update_view=1;
  3081. //(special for text mode)
  3082. if((draw_mode&127)==2) {
  3083. x_top_pos=save_x-5;
  3084. x_pos=5;
  3085. if(save_x<5) {
  3086. x_top_pos=0;
  3087. x_pos=save_x;
  3088. }
  3089. else if((save_x+75)>board_xsiz) {
  3090. x_top_pos=board_xsiz-80;
  3091. x_pos=save_x-x_top_pos;
  3092. if(x_top_pos<0) {
  3093. x_top_pos=0;
  3094. x_pos=save_x;
  3095. }
  3096. if(x_pos<0) x_pos=0;
  3097. }
  3098. goto move_down;
  3099. }
  3100. if(draw_mode&128) {
  3101. t1=char_selection(curr_param,current_pg_seg);
  3102. if(t1>=0) curr_param=t1;
  3103. update_menu=1;
  3104. break;
  3105. }
  3106. //Modify at cursor and grab. Only special case is if current
  3107. //is an object param #0. Grabbing objects works because our
  3108. //copy is supposed to be an exact duplicate, and we make copies
  3109. //during placement.
  3110. if((curr_thing==122)&&(curr_param==0))
  3111. clear_sensor(0);
  3112. else if(((curr_thing==123)||(curr_thing==124))&&(curr_param==0))
  3113. clear_robot(0);
  3114. else if(((curr_thing==125)||(curr_thing==126))&&(curr_param==0))
  3115. clear_scroll(0);
  3116. //Grab
  3117. curr_thing=level_id[ARRAY_OFFS];
  3118. curr_param=level_param[ARRAY_OFFS];
  3119. curr_color=level_color[ARRAY_OFFS];
  3120. //Modify
  3121. t2=edit_param(curr_thing,curr_param);
  3122. if(t2>-1) {
  3123. curr_param=t2;
  3124. changed=1;
  3125. }
  3126. //Save
  3127. level_param[ARRAY_OFFS]=curr_param;
  3128. update_menu=1;
  3129. break;
  3130. case 'P'://P
  3131. if(draw_mode&128) break;
  3132. //Edit parameter of current thing.
  3133. t2=edit_param(curr_thing,curr_param);
  3134. if(t2>-1) curr_param=t2;
  3135. update_menu=1;
  3136. break;
  3137. case 'R'://R
  3138. //Redraw screen
  3139. update_view=update_menu=1;
  3140. break;
  3141. case 9://Tab
  3142. //Toggle draw
  3143. if((draw_mode&127)==0) draw_mode=1+(draw_mode&128);
  3144. else draw_mode&=128;
  3145. update_menu=update_view=1;
  3146. if(draw_mode&127) goto place;
  3147. break;
  3148. case -44://AltZ
  3149. if(draw_mode&128) break;
  3150. //Clear board
  3151. if(!confirm("Clear board- Are you sure?")) {
  3152. //Save current objects
  3153. if((curr_thing==122)&&(curr_param!=0)) {
  3154. copy_sensor(0,curr_param);
  3155. curr_param=0;
  3156. }
  3157. if(((curr_thing==123)||(curr_thing==124))&&(curr_param!=0))
  3158. //No room- forget it!
  3159. if(!copy_robot(0,curr_param)) curr_param=0;
  3160. if(((curr_thing==125)||(curr_thing==126))&&(curr_param!=0))
  3161. //No room- forget it!
  3162. if(!copy_scroll(0,curr_param)) curr_param=0;
  3163. //No need to fix x/y position since board size remains
  3164. clear_current();
  3165. changed=1;
  3166. update_view=update_menu=1;
  3167. draw_mode=0;
  3168. }
  3169. break;
  3170. case -49://AltN
  3171. if(draw_mode&128) break;
  3172. //Mod
  3173. update_menu=1;
  3174. //Turn off module if one present...
  3175. if(mod_playing[0]!=0) end_mod();
  3176. //...else new module
  3177. else {
  3178. if(choose_file(NULL,temp,"Choose a module file")) break;
  3179. load_mod(temp);
  3180. }
  3181. changed=1;
  3182. break;
  3183. case -127://Alt8
  3184. if(draw_mode&128) break;
  3185. //Mod
  3186. update_menu=1;
  3187. //Turn off module if one present...
  3188. if(mod_playing[0]!=0) end_mod();
  3189. //...else new module
  3190. str_cpy(mod_playing,"*");
  3191. changed=1;
  3192. break;
  3193. case -38://AltL
  3194. if(draw_mode&128) break;
  3195. //Sample
  3196. update_menu=1;
  3197. //Choose and play sample
  3198. if(choose_file("*.SAM",temp,"Choose a .SAM file")) break;
  3199. play_sample(428,temp);
  3200. break;
  3201. case -60://F2
  3202. //Text
  3203. update_menu=1;
  3204. if((draw_mode&127)==0) {
  3205. draw_mode=2+(draw_mode&128);//Text mode
  3206. save_x=ARRAY_X;//Remember our position for ENTER.
  3207. }
  3208. else draw_mode&=128;
  3209. break;
  3210. }
  3211. move_cursor(x_pos,y_pos);
  3212. cursor_solid();
  3213. //Loop if not exiting
  3214. } while(key!=27);
  3215. cursor_off();
  3216. vquick_fadeout();
  3217. clear_sfx_queue();
  3218. //Exit with mouse on
  3219. error_mode=2;
  3220. pop_context();
  3221. }
  3222. //Arrays for 'thing' menus
  3223. char tmenu_num_choices[8]={ 17,14,18,8,6,11,12,10 };
  3224. char far *tmenu_titles[8]={ "Terrains","Items","Creatures","Puzzle Pieces",
  3225. "Transport","Elements","Miscellaneous","Objects" };
  3226. char far *thing_menus[8]={//Each 'item' is 20 char long, including '\0'.
  3227. //Terrain (F3)
  3228. "Space ~1 \0\
  3229. Normal ~E²\0\
  3230. Solid ~DÛ\0\
  3231. Tree ~A\0\
  3232. Line ~BÍ\0\
  3233. Custom Block ~F?\0\
  3234. Breakaway ~C±\0\
  3235. Custom Break ~F?\0\
  3236. Fake ~9²\0\
  3237. Carpet ~4±\0\
  3238. Floor ~6°\0\
  3239. Tiles ~0þ\0\
  3240. Custom Floor ~F?\0\
  3241. Web ~7Å\0\
  3242. Thick Web ~7Î\0\
  3243. Forest ~2²\0\
  3244. Invis. Wall ~1 ",
  3245. //Item (F4)
  3246. "Gem ~A\0\
  3247. Magic Gem ~E\0\
  3248. Health ~C\0\
  3249. Ring ~E\x9\0\
  3250. Potion ~B–\0\
  3251. Energizer ~D\0\
  3252. Ammo ~3¤\0\
  3253. Bomb ~8 \0\
  3254. Key ~F \0\
  3255. Lock ~F\xA\0\
  3256. Coin ~E\0\
  3257. Life ~B›\0\
  3258. Pouch ~7Ÿ\0\
  3259. Chest ~6 ",
  3260. //Creature (F5)
  3261. "Snake ~2ë\0\
  3262. Eye ~Fì\0\
  3263. Thief ~C\0\
  3264. Slime Blob ~A*\0\
  3265. Runner ~4\0\
  3266. Ghost ~7ê\0\
  3267. Dragon ~4\0\
  3268. Fish ~Eà\0\
  3269. Shark ~7\0\
  3270. Spider ~7•\0\
  3271. Goblin ~D\0\
  3272. Spitting Tiger ~Bã\0\
  3273. Bear ~6¬\0\
  3274. Bear Cub ~6­\0\
  3275. Lazer Gun ~4Î\0\
  3276. Bullet Gun ~F\0\
  3277. Spinning Gun ~F\0\
  3278. Missile Gun ~8",
  3279. //Puzzle (F6)
  3280. "Boulder ~7é\0\
  3281. Crate ~6þ\0\
  3282. Custom Push ~F?\0\
  3283. Box ~Eþ\0\
  3284. Custom Box ~F?\0\
  3285. Pusher ~D\0\
  3286. Slider NS ~D\0\
  3287. Slider EW ~D",
  3288. //Tranport (F7)
  3289. "Stairs ~A¢\0\
  3290. Cave ~6¡\0\
  3291. Transport ~E<\0\
  3292. Whirlpool ~B—\0\
  3293. CWRotate ~9/\0\
  3294. CCWRotate ~9\\",
  3295. //Element (F8)
  3296. "Still Water ~9°\0\
  3297. N Water ~9\x18\0\
  3298. S Water ~9\x19\0\
  3299. E Water ~9\x1A\0\
  3300. W Water ~9\x1B\0\
  3301. Ice ~Bý\0\
  3302. Lava ~C²\0\
  3303. Fire ~E±\0\
  3304. Goop ~8°\0\
  3305. Lit Bomb ~8«\0\
  3306. Explosion ~E±",
  3307. //Misc (F9)
  3308. "Door ~6Ä\0\
  3309. Gate ~8\0\
  3310. Ricochet Panel ~9/\0\
  3311. Ricochet ~A*\0\
  3312. Mine ~C�\0\
  3313. Spike ~8\0\
  3314. Custom Hurt ~F?\0\
  3315. Text ~F?\0\
  3316. N Moving Wall ~F?\0\
  3317. S Moving Wall ~F?\0\
  3318. E Moving Wall ~F?\0\
  3319. W Moving Wall ~F?",
  3320. //Objects (F10)
  3321. "Robot ~F?\0\
  3322. Pushable Robot ~F?\0\
  3323. Player ~B\0\
  3324. Scroll ~Fè\0\
  3325. Sign ~6â\0\
  3326. Sensor ~F?\0\
  3327. Bullet ~Fù\0\
  3328. Missile ~8\0\
  3329. Seeker ~A/\0\
  3330. Shooting Fire ~E" };
  3331. char tmenu_thing_ids[8][18]={
  3332. //Terrain (F3)
  3333. { 0,1,2,3,4,5,6,7,13,14,15,16,17,18,19,65,71 },
  3334. //Item (F4)
  3335. { 28,29,30,31,32,33,35,36,39,40,50,66,55,27 },
  3336. //Creature (F5)
  3337. { 80,81,82,83,84,85,86,87,88,89,90,91,94,95,60,92,93,97 },
  3338. //Puzzle (F6)
  3339. { 8,9,10,11,12,56,57,58 },
  3340. //Tranport (F7)
  3341. { 43,44,49,67,45,46 },
  3342. //Element (F8)
  3343. { 20,21,22,23,24,25,26,63,34,37,38 },
  3344. //Misc (F9)
  3345. { 41,47,72,73,74,75,76,77,51,52,53,54 },
  3346. //Objects (F10)
  3347. { 124,123,127,126,125,122,61,62,79,78 } };
  3348. //Default colors
  3349. unsigned char def_colors[128]={
  3350. 7,0,0,10,0,0,0,0,7,6,0,0,0,0,0,0,0,0,7,7,25,25,25,25,25,59,76,6,0,0,12,14,//0-31
  3351. 11,15,24,3,8,8,239,0,0,0,0,0,0,0,0,8,8,0,14,0,0,0,0,7,0,0,0,0,4,15,8,12,//32-63
  3352. 0,2,11,31,31,31,31,0,9,10,12,8,0,0,14,10,2,15,12,10,4,7,4,14,7,7,2,11,15,15,6,6,//64-95
  3353. 0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,15,27 };//96-127
  3354. void draw_debug_box(char ypos) {
  3355. int t1;
  3356. draw_window_box(debug_x,ypos,debug_x+14,24,current_pg_seg,
  3357. EC_DEBUG_BOX,EC_DEBUG_BOX_DARK,EC_DEBUG_BOX_CORNER,0);
  3358. write_string("X/Y: /\nBoard:\nMem: k\nEMS: k\nRobot memory-\n . /61k %",
  3359. debug_x+1,ypos+1,EC_DEBUG_LABEL,current_pg_seg);
  3360. write_number(curr_board,EC_DEBUG_NUMBER,debug_x+13,ypos+2,
  3361. current_pg_seg,0,1);
  3362. write_number((int)(farcoreleft()>>10),EC_DEBUG_NUMBER,
  3363. debug_x+12,ypos+3,current_pg_seg,0,1);
  3364. write_number(free_mem_EMS()<<4,EC_DEBUG_NUMBER,debug_x+12,ypos+4,
  3365. current_pg_seg,0,1);
  3366. t1=robot_free_mem/102;
  3367. write_number(t1/10,EC_DEBUG_NUMBER,debug_x+2,ypos+6,current_pg_seg,
  3368. 0,1);
  3369. write_number(t1%10,EC_DEBUG_NUMBER,debug_x+4,ypos+6,current_pg_seg,1);
  3370. t1=(unsigned int)(robot_free_mem*100L/62464L);
  3371. write_number(t1,EC_DEBUG_NUMBER,debug_x+12,ypos+6,current_pg_seg,0,1);
  3372. }