1 /* terra.c: Terrain editor
3 * Micropolis, Unix Version. This game was released for the Unix platform
4 * in or about 1990 and has been modified for inclusion in the One Laptop
5 * Per Child program. Copyright (C) 1989 - 2007 Electronic Arts Inc. If
6 * you need assistance with this program, you may contact:
7 * http://wiki.laptop.org/go/Micropolis or email micropolis@laptop.org.
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program. If
19 * not, see <http://www.gnu.org/licenses/>.
21 * ADDITIONAL TERMS per GNU GPL Section 7
23 * No trademark or publicity rights are granted. This license does NOT
24 * give you any right, title or interest in the trademark SimCity or any
25 * other Electronic Arts trademark. You may not distribute any
26 * modification of this program using the trademark SimCity or claim any
27 * affliation or association with Electronic Arts Inc. or its employees.
29 * Any propagation or conveyance of this program must include this
30 * copyright notice and these terms.
32 * If you convey this program (or any modifications of it) and assume
33 * contractual liability for the program to recipients of it, you agree
34 * to indemnify Electronic Arts for any liability that those contractual
35 * assumptions impose on Electronic Arts.
37 * You may not misrepresent the origins of this program; modified
38 * versions of the program must be marked as such and not identified as
39 * the original program.
41 * This disclaimer supplements the one included in the General Public
42 * License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
43 * PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
44 * OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
45 * SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
46 * DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
47 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
48 * FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
49 * RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
50 * USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
51 * INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
52 * MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
53 * UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
54 * WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
55 * CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
56 * ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
57 * JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
58 * WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
59 * CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
63 /* terra.c - terrain editor for Sim City
66 1194 Spring Valley Commons
71 #include "..\sim\sim.h"
72 #include "..\gr\menu.h"
73 #include "..\gr\grdef.h"
74 #include "..\terra\tmenu.h"
75 #include "..\ed\eddef.h"
76 #include "..\ed\edext.h"
81 #include <sys\types.h>
87 extern MOUSESTATE near mouse_state
;
89 extern char realMouseFlag
;
91 extern long lastEvent
, TickCount(); /* from ..\sim\main.c */
92 extern long policeFund
, fireFund
, transFund
;
94 char CreateWithIsland
;
98 int UndoMapBuffer1
[WORLD_X
*WORLD_Y
];
99 int UndoMapBuffer2
[WORLD_X
*WORLD_Y
];
100 int UndoMapBuffer3
[WORLD_X
*WORLD_Y
];
101 int UndoMapBuffer4
[WORLD_X
*WORLD_Y
];
102 int *UndoMap
[UMaps
]={UndoMapBuffer1
,UndoMapBuffer2
,UndoMapBuffer3
,UndoMapBuffer4
}; /* maps for fill undos */
103 int UndoMaps
; /* number of occupied undo maps */
105 char x
,y
; /* coordinate of undo */
106 int val
; /* cell value */
107 } UndoRec
[URecs
]; /* putdown undos */
108 int UndoHead
=0,UndoTail
=0;
110 char fillState
=0; /* flag telling if fill mode is on or off */
112 int treeLevel
=50; /* level for tree creation */
113 int lakeLevel
=50; /* level for lake creation */
114 int curvLevel
=50; /* level for river curviness */
116 /* ========================================================== */
118 void ClearUndo() /* clear all undo records */
120 UndoMaps
=UndoHead
=UndoTail
=0; /* kill undo pointers */
121 DrawAllEdIcons(UPDATE
); /* update undo icon */
124 void AddUndo(pos
) /* add undo record */
125 Point pos
; /* position to add to undo */
128 if(pos
.h
!= -1 || pos
.v
!= -1) { /* if they're not setting to undo the entire map */
129 if(pos
.h
> WORLD_X
|| pos
.v
> WORLD_Y
|| pos
.h
< 0 || pos
.v
< 0) { /* if out of bounds */
130 return; /* do nothing */
133 if(pos
.h
== -1 && pos
.v
== -1) { /* if undo entire map */
134 register int tem
; /* temporary counter */
135 register int x
,y
; /* temporary coordinates */
137 if(UndoMaps
== UMaps
) { /* if there are already five undo maps */
138 while(UndoRec
[UndoTail
].x
!= -1 || UndoRec
[UndoTail
].y
!= -1) { /* until we find the last map undo */
139 UndoTail
=Bound(0,UndoTail
+1,URecs
-1); /* move tail */
141 UndoTail
=Bound(0,UndoTail
+1,URecs
-1); /* move tail to kill the last map */
143 for(tem
=0;tem
< UndoMaps
;tem
++) { /* for each map */
144 for(x
=0;x
< WORLD_X
*WORLD_Y
;x
++) {
145 *(UndoMap
[tem
]+x
)=*(UndoMap
[tem
+1]+x
);
149 for(x
=0;x
< WORLD_X
*WORLD_Y
;x
++) {
150 *(UndoMap
[UndoMaps
]+x
)=*((int*)Map
+x
); /* save current map */
152 UndoMaps
++; /* one more map saved */
154 UndoRec
[UndoHead
].x
=pos
.h
; /* set x and y position */
155 UndoRec
[UndoHead
].y
=pos
.v
;
156 UndoRec
[UndoHead
].val
=Map
[pos
.h
][pos
.v
]; /* set map value */
157 UndoHead
=Bound(0,UndoHead
+1,URecs
-1); /* move head */
158 if(UndoHead
== UndoTail
) { /* if we pushed the tail up */
159 UndoTail
=Bound(0,UndoTail
+1,URecs
-1); /* move tail */
163 void Undo() /* undo one map operation */
167 if(UndoHead
== UndoTail
) { /* if there's nothing to undo */
168 MakeSound(7); /* bad sound */
169 return; /* do nothing */
171 UndoHead
=Bound(0,UndoHead
-1,URecs
-1); /* set new head */
172 if(UndoRec
[UndoHead
].x
== -1) { /* if the entire map changed */
173 register int tem
; /* temporary counter */
174 register int x
,y
; /* temporary coordinates */
176 for(x
=0;x
< WORLD_X
*WORLD_Y
;x
++) {
177 *((int*)Map
+x
)=*(UndoMap
[UndoMaps
-1]+x
); /* set undo map */
179 UndoMaps
--; /* one less map */
181 Map
[UndoRec
[UndoHead
].x
][UndoRec
[UndoHead
].y
]=UndoRec
[UndoHead
].val
; /* set old value */
184 UpdateOurMaps(); /* update big and small maps */
187 /* ======================================================================== */
196 PrintLock("DoEvent - get event ");
198 GetMouseEvent(&event
);
201 PrintLock("DoEvent ");
204 switch(object
&0xff00)
206 case 0: DoMenu(object
);
226 UpdateOurSmallMap() /* update small map */
228 register int tem
; /* temporary counter */
230 MouseHide(); /* hide mouse */
231 DrawSmallMap(); /* updates small map */
232 for(tem
=0;tem
< WORLD_X
*WORLD_Y
;tem
++) {
233 *((int*)lastSmallMap
+tem
)=(*((int*)Map
+tem
))&LOMASK
; /* copy map */
235 MouseShow(); /* show mouse */
238 UpdateOurMaps() /* update edit and map widnows */
240 UpdateMapCursorOff(); /* turn off map cursor */
241 MouseHide(); /* hide mouse */
242 DrawBigMap(); /* updates large map */
243 MouseShow(); /* show mouse */
245 DrawAllEdIcons(UPDATE
); /* update icons */
246 UpdateMapCursorOn(); /* turn map cursor on */
249 /* ======================================================================== */
253 static char far
*popGameLevelStrs
[]={"Easy","Medium","Hard",NULL
};
254 int cur_windowActive
; /* current active window */
255 register int x
,y
; /* temporary integers */
258 char *savePtr
; /* pointer to saved rectangle */
266 /* /* Load a scenario - if it fails we need to redraw the */
268 /* if (!LoadScenario()) {
271 /* ClearUndo(); /* clear undo records */
273 /* SelectNewWindow(EDWINDOW); /* enable edit window */
274 /* SelectNewWindow(MAPWINDOW); /* enable map window */
278 Quit("Micropolis Terrain Editor");
280 case MNU_SoundToggle
: /* sound on/off */
283 ShowSelectedOptions();
289 if (LoadGame(NULL
,NO
))
291 SelectNewWindow(EDWINDOW
); /* enable edit window */
292 SelectNewWindow(MAPWINDOW
); /* enable map window */
293 ClearUndo(); /* clear undo records */
296 SaveGame(lastFileName
);
301 case MNUNEW
: /* Start new game */
302 if (Verify("NEW GAME")) {
305 transFund
=policeFund
=fireFund
=65535L;
308 ClearUndo(); /* clear undo records */
310 SelectNewWindow(EDWINDOW
); /* enable edit window */
311 SelectNewWindow(MAPWINDOW
); /* enable map window */
316 case MNU_SmoothTrees
:
319 case MNU_ClearMap
: /* if map is to be cleared */
320 AddUndo(-1,-1); /* save map */
321 rax_ClearMap(); /* clear map (..\sim\mapgener.c) */
322 GameLevel
=0; /* assume game is easy */
325 case MNU_ClearUnnatural
: /* if unnatural objects are to be cleared */
326 AddUndo(-1,-1); /* save map */
327 for(x
=0;x
< WORLD_X
;x
++) {
328 for(y
=0;y
< WORLD_Y
;y
++) {
329 if((Map
[x
][y
]&LOMASK
) > 37) { /* get rid of everything unnatural */
330 Map
[x
][y
]=0; /* turn it into dirt */
335 UpdateOurMaps(); /* update both windows */
337 case MNU_GenerateRandom
: /* if random map is to be generated */
338 if(SetTerrainParameters()) { /* allow user to set terrain generation parameters */
339 CenterRect(&msgBox
, 20, 5);
340 msgRect
=*AdjRect(&msgBox
);
341 savePtr
=GSaveRect(&msgRect
); /* save rectangle */
342 GRectFill(&msgRect
, WHITE
|PWHITE
);
343 GSetAttrib(DGREEN
, DGREEN
, PBLACK
);
344 GRectOutline(&msgRect
, 4);
345 GSetAttrib(LGREEN
, LGREEN
, PMGREY
);
346 GRectOutline(&msgRect
, 2);
347 GSetAttrib(DBLUE
, WHITE
, PWHITE
|PINV
);
348 CenterPrint(&msgBox
, msgBox
.top
+2, "Now terraforming");
350 AddUndo(-1,-1); /* save map */
351 rax_ClearMap(); /* make river map */
353 if(CreateWithIsland
) { /* if we're creating an island */
354 rax_MakeIsland(); /* make an island */
356 if(curvLevel
) { /* if we're supposedly creating an island */
357 rax_DoRivers(); /* create river */
359 if(lakeLevel
) { /* if there are to be lakes */
360 rax_MakeLakes(); /* add lakes */
362 rax_SmoothRiver(); /* smooth out river */
363 if(treeLevel
) { /* if we're creating a woodsy terrain */
364 rax_DoTrees(); /* add trees */
366 rax_SmoothTrees(); /* smooth trees */
367 rax_SmoothTrees(); /* smooth trees */
369 GRestoreRect(&msgRect
,savePtr
); /* restore rectangle */
374 case MNU_SmoothRiver
: /* if water is to be smoothed */
377 case MNU_SmoothBoth
: /* if both are to be smoothed */
378 smoothFlag
=3; /* Both */
380 CenterRect(&msgBox
, 16, 5);
381 msgRect
=*AdjRect(&msgBox
);
382 savePtr
=GSaveRect(&msgRect
); /* save rectangle */
383 GRectFill(&msgRect
, WHITE
|PWHITE
);
384 GSetAttrib(DGREEN
, DGREEN
, PBLACK
);
385 GRectOutline(&msgRect
, 4);
386 GSetAttrib(LGREEN
, LGREEN
, PMGREY
);
387 GRectOutline(&msgRect
, 2);
388 GSetAttrib(DBLUE
, WHITE
, PWHITE
|PINV
);
389 CenterPrint(&msgBox
, msgBox
.top
+2, "Smoothing...");
391 AddUndo(-1,-1); /* save map */
392 if (smoothFlag
& 2) /* If water smooth flag set */
394 rax_WaterEdges(); /* make sure water edges are ok */
403 GRestoreRect(&msgRect
,savePtr
); /* restore rectangle */
406 case MNU_RandomIsland
: /* if random Island toggle */
407 CreateWithIsland
^=1; /* toggle state of flag */
408 ShowSelectedOptions(); /* update menu flag status */
411 case MNU_GameLevel
: /* if game level */
412 /* GameLevel++; /* add one for PopUpMenuBox */
413 /* PopUpMenuBox(&GameLevel, popGameLevelStrs);
416 tmpFunds
=totalFunds
; /* Don't alter the amount of funds! */
417 ChooseGameLevel(); /* get city name & level from user */
420 NewName(); /* set the name of the city */
422 case MNU_GameYear
: /* if game year */
423 SetGameYear(); /* allow user to set the game year */
426 case MNU_EditWindow
: /* if edit window */
427 SelectNewWindow(EDWINDOW
); /* bring the edit window to the foreground */
429 case MNU_MapWindow
: /* if map window */
430 SelectNewWindow(MAPWINDOW
); /* bring the map window to the foreground */
434 /* unimplemented option */
446 object
=ePtr
->object
&0xff;
449 { /* Must be an icon */
450 SetWandState(object
&0xf, YES
);
454 case 0: DoEdMapEvent(ePtr
);
456 case 2: DoMoveWindow(ePtr
, edWinList
);
458 case 8: ResizeEdWindow(ePtr
);
463 /* ======================================================================== */
469 object
=ePtr
->object
&0xff;
473 { case 0: DoMapWindowEvent(ePtr
); /* move locus of edit window */
475 case 2: DoMoveMap(ePtr
); /* move window */
481 void EditTerra() /* main program entry point */
483 int updateWait
=0, updateWait2
=0;
486 ShowSelectedOptions(); /* update menu flag status */
487 GameLevel
=0; /* assume game is easy */
489 transFund
=policeFund
=fireFund
=65535L;
492 EnableMenus(); /* make sure menus are enabled */
495 long lastMapCursor
; /* time value for map window cursor flashing */
497 if (WaitedEnough(&lastMapCursor
,2))
498 { /* if we should flash the map cursor */
499 UpdateMapCursor(); /* update the map cursor */
503 if (!menuActive
) /* if no menus are active */
506 if (CheckKeyState(CNTRLSCAN
)) /* Is the control key hit? */
512 if (CheckKeyState(HOMESCAN
)) /* Home arrow */
515 if (CheckKeyState(PGUPSCAN
)) /* PgUp arrow */
518 if (CheckKeyState(ENDSCAN
)) /* End arrow */
521 if (CheckKeyState(PGDNSCAN
)) /* PgDn arrow */
524 if (CheckKeyState(RIGHTSCAN
)) /* Right arrow */
526 if (CheckKeyState(LEFTSCAN
)) /* Left arrow */
528 if (CheckKeyState(UPSCAN
)) /* Up arrow */
530 if (CheckKeyState(DOWNSCAN
)) /* Down arrow */
544 if (mouse_state
.x
<= 1)
551 } else if (mouse_state
.x
>= screenWidth
-6)
553 if (MapX
+edWinWid
< WORLD_X
)
559 if (mouse_state
.y
< 1 )
567 else if (mouse_state
.y
>= screenHeight
-6)
569 if (MapY
+edWinLen
< WORLD_Y
)
578 DisableMenus(); /* locks to current process */
579 newMapFlags
[CYMAP
]=0;
588 } /* End of "if (!ScrollLock" */
589 } /* End if if (!menuActive) */
590 if (KBHit() || CheckMouseEvents()) /* if an event happened */
596 while (CheckMouseEvents())
599 lastEvent
=TickCount();
603 if (WaitedEnough(&updateWait
, 18*3))
609 OutStr("\nMAIN: re-enable");
612 EnableMenus(); /* Make sure the menus are enabled */
615 OutStr("\nMAIN: copyok, pass");
620 OutStr("\nMAIN: copy not OK");
625 SetGameYear() /* get game year */
628 static char *label
="Enter Game Year:"; /* label for window */
630 char dateBuffer
[10]; /* buffer for date */
633 int len
, x
, y
, i
,c
, optLens
[8];
642 CenterRect(&verBox
,18,5);
644 tmpBox
=*AdjRect(&verBox
);
645 savePtr
=GSaveRect(&tmpBox
);
647 GRectFill(&tmpBox
,BUDGFC
+PMGREY
);
648 GSetAttrib(BUDGBC
,BUDGBC
,PWHITE
);
649 GRectOutline(&tmpBox
, 4);
650 /* Outline outline in BLACK */
651 GSetAttrib(BLACK
,BLACK
,PBLACK
);
652 GRectOutline(&tmpBox
,1);
653 GSetAttrib(BUDGBC
,BUDGFC
,PINV
|PWHITE
);
654 PrintRectLines(&verBox
,verBox
.top
,label
);
658 GSetAttrib(BUDGBC
,BUDBOXC
,PINV
|PWHITE
);
660 /* GSetAttrib(BUDGBC,BUDBOXC,0); */
661 /* TempFullScreenCursor(); */
663 sprintf(dateBuffer
,"%4d",(CityTime
/48)+1900); /* set date */
664 GetStrSetNum(); /* Numbers only */
665 GetStrn(verBox
.left
+6,verBox
.top
+3,dateBuffer
,5,1); /* allow user to edit the date and set eos */
666 GetStrSetAll(); /* allow any alphnum input */
667 if(strlen(dateBuffer
) == 4) { /* if they entered a good date */
668 tmpTime
=(atoi(dateBuffer
)-1900)*48L; /* set new date */
671 } else { /* if not the correct length */
672 MakeSound(7); /* this should be CANTSND for bad date */
674 for(i
=0;i
< 100;i
++) { /* kill any and all events */
675 GetMouseEvent(&event
); /* get event */
677 /* RemoveTempCursor(); */
678 GRestoreRect(&tmpBox
,savePtr
);
679 DoDate(); /* update the date in the edit window */
682 int PSBound(a
,n
,b
) /* return number between a and b */
689 /* here is the concept for SetTerrainParameters():
690 ZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?
692 3 Terrain Creation Parameters 3
694 3 Number Number River 3
695 3 of Trees of Lakes Curviness 3
697 3 \11 xxx% \10 \11 xxx% \10 \11 xxx% \10 3
699 3 ZDDDDDDDD? ZDDDDDDDD? 3
700 3 3 Go 3 3 Cancel 3 3
701 3 @DDDDDDDDY @DDDDDDDDY 3
702 @DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDY
704 SetTerrainParameters() /* allow user to set up terrain grneration parameters */
706 char *savePtr
; /* pointer to saved screen data */
707 char temStr
[20]; /* temporary string for percentages */
708 EVENT event
; /* temporary event */
709 int atButton
=0; /* current button we're at */
710 int buttonDown
=0; /* flag telling if mouse button is down */
711 int goFlag
=0; /* flag telling if terrain is to be generated */
712 long startTime
; /* temporary timer value */
713 int tem
; /* temporary counter */
714 int x
,y
; /* temporary positions */
715 Rect wRect
; /* rectangle showing extents of window */
716 Rect tmpRect
; /* temporary rectangle for adjusted window rectangle */
717 Point buttonPos
[8]; /* positions of buttons */
719 FlushKeys(); /* do something...flush keyboard buffer? */
721 CenterRect(&wRect
,36,10); /* center our window */
723 tmpRect
=*AdjRect(&wRect
);
724 savePtr
=GSaveRect(&tmpRect
);
726 GRectFill(&tmpRect
,BUDGFC
+PMGREY
);
727 GSetAttrib(BUDGBC
,BUDGBC
,PWHITE
);
728 GRectOutline(&tmpRect
,4);
729 /* Outline outline in BLACK */
730 GSetAttrib(BLACK
,BLACK
,PBLACK
);
731 GRectOutline(&tmpRect
,1);
732 GSetAttrib(BUDGBC
,BUDGFC
,PINV
|PWHITE
);
733 PrintRectLines(&wRect
,wRect
.top
,"Terrain Creation Parameters");
735 y
=(wRect
.top
+2)*fontHeight
;
736 GPPrintf(x
+(1*8),y
+(1*fontHeight
)-3," Number Number River ");
737 GPPrintf(x
+(1*8),y
+(2*fontHeight
)-3,"of Trees of Lakes Curviness");
739 buttonPos
[0].h
=wRect
.left
+3; /* positions of buttons */
740 buttonPos
[1].h
=wRect
.left
+10;
741 buttonPos
[2].h
=wRect
.left
+14;
742 buttonPos
[3].h
=wRect
.left
+21;
743 buttonPos
[4].h
=wRect
.left
+25;
744 buttonPos
[5].h
=wRect
.left
+32;
745 for(tem
=0;tem
< 6;tem
++) {
746 buttonPos
[tem
].v
=wRect
.top
+5; /* set vertical position */
748 buttonPos
[6].h
=wRect
.left
+3;
749 buttonPos
[7].h
=wRect
.left
+25;
750 buttonPos
[6].v
=buttonPos
[7].v
=wRect
.top
+8;
752 GSetAttrib(BUDGBC
,BUDBOXC
,PINV
|PWHITE
);
753 for(tem
=0;tem
< 3;tem
++) { /* for each set of value buttons */
754 AddTextButton(buttonPos
[tem
*2],"\11",0x800+tem
*2); /* add button */
755 AddTextButton(buttonPos
[tem
*2+1],"\10",0x801+tem
*2); /* add button */
757 AddTextButton(buttonPos
[6]," Go ",0x806); /* add 'go' button */
758 AddTextButton(buttonPos
[7]," Cancel ",0x807); /* add 'cancel' button */
760 /* output initial values */
761 GSetAttrib(BUDGBC
,BUDGFC
,PINV
|PWHITE
);
762 sprintf(temStr
,"%3d%%%%",treeLevel
); /* get string for tree level */
763 GPPrintf(x
+(3*8),y
+(3*fontHeight
),temStr
); /* output string */
764 sprintf(temStr
,"%3d%%%%",lakeLevel
); /* get string for lake level */
765 GPPrintf(x
+(14*8),y
+(3*fontHeight
),temStr
); /* output string */
766 sprintf(temStr
,"%3d%%%%",curvLevel
); /* get string for curviness level */
767 GPPrintf(x
+(25*8),y
+(3*fontHeight
),temStr
); /* output string */
769 /* GSetAttrib(BUDGBC,BUDBOXC,0); */
770 TempFullScreenCursor(); /* give us a cursor */
772 while(1) { /* until break */
773 if(0) { /* never unless below code calls it */
775 SetMouseAtButton(atButton
+0x800);
777 while (KBHit()) /* Clear any keys pressed */
780 { case 27: /* if escape */
781 case 'C': /* (or 'cancel') */
783 goFlag
=0; /* don't create random terrain */
785 case 13: /* if carriage return */
786 case 'G': /* (or 'go') */
788 goFlag
=1; /* create random terrain */
790 case '+': atButton
=((atButton
+1) % 8); /* for each button */
793 atButton
=(atButton
)?(atButton
-1):7;
797 if(CheckMouseEvents()) { /* if there's an activity */
798 GetMouseEvent(&event
); /* get event */
800 switch(event
.object
) { /* get event id */
801 case 0x800: /* if - trees */
802 treeLevel
=PSBound(0,treeLevel
-1,100);
803 goto updateValues
; /* update values */
804 case 0x801: /* if + trees */
805 treeLevel
=PSBound(0,treeLevel
+1,100);
806 goto updateValues
; /* update values */
807 case 0x802: /* if - lakes */
808 lakeLevel
=PSBound(0,lakeLevel
-1,100);
809 goto updateValues
; /* update values */
810 case 0x803: /* if + lakes */
811 lakeLevel
=PSBound(0,lakeLevel
+1,100);
812 goto updateValues
; /* update values */
813 case 0x804: /* if - curviness */
814 curvLevel
=PSBound(0,curvLevel
-1,100);
815 goto updateValues
; /* update values */
816 case 0x805: /* if + curviness */
817 curvLevel
=PSBound(0,curvLevel
+1,100);
818 goto updateValues
; /* update values */
819 case 0x806: /* if 'go' */
820 goFlag
=1; /* return flag telling to create terrain */
822 case 0x807: /* if 'cancel' */
823 goFlag
=0; /* return flag telling to create terrain */
826 if(0) { /* only if above code calls us */
828 RemoveTempCursor(); /* remove cursor from screen */
829 GSetAttrib(BUDGBC
,BUDGFC
,PINV
|PWHITE
);
830 sprintf(temStr
,"%3d%%%%",treeLevel
); /* get string for tree level */
831 GPPrintf(x
+(3*8),y
+(3*fontHeight
),temStr
); /* output string */
832 sprintf(temStr
,"%3d%%%%",lakeLevel
); /* get string for lake level */
833 GPPrintf(x
+(14*8),y
+(3*fontHeight
),temStr
); /* output string */
834 sprintf(temStr
,"%3d%%%%",curvLevel
); /* get string for curviness level */
835 GPPrintf(x
+(25*8),y
+(3*fontHeight
),temStr
); /* output string */
836 TempFullScreenCursor(); /* put cursor back */
837 if(!buttonDown
) { /* if button was not down */
838 buttonDown
=1; /* set button down flag */
839 startTime
=TickCount(); /* get current time */
840 while(StillDown()) { /* while a button is down */
841 if(TickCount()-startTime
> 5) { /* if autorepeat is up */
845 buttonDown
=0; /* button is no longer down */
846 } else { /* if button is already down */
847 if(StillDown()) { /* if button is still down */
848 startTime
=TickCount(); /* get current time */
849 while(startTime
== TickCount()) ; /* wait for 1/18th of a second */
852 buttonDown
=0; /* no button is down */
855 if(event
.object
== 0x806 || event
.object
== 0x807) { /* if one of the exit buttons */
857 break; /* exit loop */
862 for(tem
=0x800;tem
<= 0x809;tem
++) { /* remove buttons from hot list */
865 RemoveTempCursor(); /* remove our cursor */
866 GRestoreRect(&tmpRect
,savePtr
);
867 return goFlag
; /* return flag telling if terrain is to be created */