-The Plan 9 software is provided under the terms of the
-Lucent Public License, Version 1.02, reproduced in the
-file /lib/legal/lpl, with the following notable exceptions:
+Plan 9 from Bell Labs is provided under the terms of the Lucent Public License,
+Version 1.02, reproduced in the file /lib/legal/lpl.
+
+Any additions or changes (as recorded in Mercurial history) made by 9front are provided
+under the terms of the MIT License, reproduced in the file /lib/legal/mit, unless
+otherwise indicated.
+
+The following exceptions apply:
1. No right is granted to create derivative works of or
to redistribute (other than with the Plan 9 Operating System)
These directories contain material copyrights by B&H Inc. and Y&Y Inc.
2. The printer fonts identified in subdirectory /sys/lib/ghostscript/font
- are subject to the GNU GPL, reproduced in the file /lib/legal/gpl.
+ are subject to the GNU GPL, version 2, reproduced in the file /lib/legal/gpl.
3. The ghostscript program in the subdirectory /sys/src/cmd/gs is
covered by the Aladdin Free Public License, reproduced in the file
/lib/legal/afpl.
+4. The Python programming language in the subdirectories /sys/src/cmd/python and
+ /sys/lib/python is covered by the Python Software Foundation License, reproduced
+ in the file /sys/src/cmd/python/LICENSE.
+
+5. The Mercurial version control system in the subdirectories /sys/src/cmd/hg and
+ /sys/lib/mercurial is covered by the GNU GPL, version 2, reproduced in
+ the file /lib/legal/gpl.
+
Other, less notable exceptions are marked in the file tree with
COPYING, COPYRIGHT, or LICENSE files.
--- /dev/null
+Copyright (c) 20XX 9front
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
universe.
.SS Mouse commands
.PP
-New planetary bodies can be created with mouse button 1.
-Holding button 1 will reposition the body.
+Holding mouse button 1 while dragging repositions the visible region of
+the galaxy. Holding mouse button 2 while dragging up or down zooms the
+visible region of the galaxy in or out, respectively.
+Mouse button 3 opens a menu with the following options:
+.TP
+.B "new body"
+Creates a new galactic body.
+Holding button 1 positions the body.
Holding a button 1-2 chord changes the mass/size
of the body. Holding a button 1-3 chord
changes the initial velocity of the body. Releasing button 1
restarts the simulator with the new body in motion. When new
bodies are created, the simulator maintains the Galilean (inertial)
reference frame where the center of mass of the galaxy is at rest.
-.PP
-Mouse button 2 repositions the visible region of the galaxy by dragging.
-.PP
-Mouse button 3 opens a menu with the following options:
-.TP
-.B zoom
-Prompts for a floating point value to change the scale of the
-simulation. E.g. a value of 2 will halve the scale (zoom in)
-and a value of 0.5 will double the scale (zoom out).
.TP
.B speed
Prompts for a floating point value to change the speed of
0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, }
};
+Cursor zoomcursor = {
+ {-7, -7},
+ {0x1F, 0xF8, 0x3F, 0xFC, 0x7F, 0xFE, 0xFB, 0xDF,
+ 0xF3, 0xCF, 0xE3, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xE3, 0xC7, 0xF3, 0xCF,
+ 0x7B, 0xDF, 0x7F, 0xFE, 0x3F, 0xFC, 0x1F, 0xF8, },
+ {0x00, 0x00, 0x0F, 0xF0, 0x31, 0x8C, 0x21, 0x84,
+ 0x41, 0x82, 0x41, 0x82, 0x41, 0x82, 0x7F, 0xFE,
+ 0x7F, 0xFE, 0x41, 0x82, 0x41, 0x82, 0x41, 0x82,
+ 0x21, 0x84, 0x31, 0x8C, 0x0F, 0xF0, 0x00, 0x00, }
+};
+
Cursor pausecursor={
0, 0,
0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x07, 0xe0,
enum {
STK = 8192,
- ZOOM = 0,
+ DOBODY = 0,
SPEED,
GRAV,
SAVE,
LIM = 10,
dt²;
char *file;
-int showv, showa, throttle;
+int showv, showa, throttle, paused;
char *menustr[] = {
+ [DOBODY] "new body",
[SAVE] "save",
[LOAD] "load",
- [ZOOM] "zoom",
[SPEED] "speed",
[GRAV] "gravity",
[EXIT] "exit",
void
pause(int p, int id)
{
- static int paused, pid = -1;
+ static int pid = -1;
switch(p) {
default:
double f;
Body *b;
- pause(0, 0);
+ for(;;) {
+ readmouse(mc);
+ if(mc->buttons == 0)
+ continue;
+ if(mc->buttons == 1)
+ break;
+ return;
+ }
+
b = body();
setpos(b);
setvel(b);
gc = center();
orig.x += gc.x / scale;
orig.y += gc.y / scale;
-
- pause(1, 0);
}
char*
Point oldp, off;
setcursor(mc, &crosscursor);
- pause(0, 0);
oldp = mc->xy;
for(;;) {
readmouse(mc);
- if(mc->buttons != 2)
+ if(mc->buttons != 1)
break;
off = subpt(mc->xy, oldp);
oldp = mc->xy;
+ pause(0, 0);
orig = addpt(orig, off);
drawglxy();
+ pause(1, 0);
+ }
+ setcursor(mc, cursor);
+}
+
+void
+dozoom(void)
+{
+ Point z, d;
+ double f, olds;
+
+ setcursor(mc, &zoomcursor);
+
+ z = mc->xy;
+ olds = scale;
+ for(;;) {
+ readmouse(mc);
+ if(mc->buttons != 2)
+ break;
+ d = subpt(mc->xy, z);
+ f = tanh((double)d.y/200) + 1;
+ pause(0, 0);
+ scale = f*olds;
+ drawglxy();
+ pause(1, 0);
}
+
setcursor(mc, cursor);
pause(1, 0);
}
pause(0, 0);
switch(menuhit(3, mc, &menu, nil)) {
+ case DOBODY:
+ dobody();
+ break;
case SAVE:
s = getinput("Enter file:", file);
if(s == nil || *s == '\0')
load(fd);
close(fd);
break;
- case ZOOM:
- s = getinput("Zoom multiplier:", nil);
- if(s == nil || *s == '\0')
- break;
- z = strtod(s, nil);
- free(s);
- if(z <= 0)
- break;
- scale /= z;
- break;
case SPEED:
s = getinput("Speed multiplier:", nil);
if(s == nil || *s == '\0')
readmouse(mc);
switch(mc->buttons) {
case 1:
- dobody();
+ domove();
break;
case 2:
- domove();
+ dozoom();
break;
case 4:
domenu();
{
Keyboardctl *realkc;
Rune r;
- static int paused;
threadsetname("keyboard");
realkc = initkeyboard(nil);
showa ^= 1;
break;
case ' ':
- paused ^= 1;
if(paused) {
- cursor = &pausecursor;
- pause(0, 1);
- } else {
cursor = nil;
pause(1, 1);
+ } else {
+ cursor = &pausecursor;
+ pause(0, 1);
}
setcursor(mc, cursor);
}
+ drawglxy();
}
}