diff --git a/Docs/Tutorials/PLASMA/User Manual.md b/Docs/Tutorials/PLASMA/User Manual.md index aae197bb..4e255e90 100644 --- a/Docs/Tutorials/PLASMA/User Manual.md +++ b/Docs/Tutorials/PLASMA/User Manual.md @@ -269,6 +269,28 @@ def strlen(strptr) return ^strptr end ``` +Pointers to structures or arrays can be referenced with the `->` and `=>` operators, pointing to `byte` or `word` sized elements. +``` +const elem_id = 0 +const elem_addr = 1 + +def addentry(entry, id, addr) + entry->elem_id = id ; set ID byte + entry=>elem_addr = addr ; set address + return entry + 3 ; return next enry address +end +``` +The above is equivalent to: +``` +const elem_id = 0 +const elem_addr = 1 + +def addentry(entry, id, addr) + (entry).elem_id = id ; set ID byte + (entry):elem_addr = addr ; set address + return entry + 3 ; return next enry address +end +``` ##### Addresses of Data/Code Along with dereferencing a pointer, there is the question of getting the address of a variable. The `@` operator prepended to a variable name or a function definition name, will return the address of the variable/definition. From the previous example, the call to `strlen` would look like: @@ -403,13 +425,16 @@ The complex test case is handled with `when`. Basically a `if`, `elsifF`, `else` when key is 'A' ; handle A character + break is 'B' ; handle B character + break ``` ... ``` is 'Z' ; handle Z character + break otherwise ; Not a known key wend @@ -424,12 +449,15 @@ byte a when TRUE is (a <= 10) ; 10 or less + break is (a > 10) AND (a < 20) ; between 10 and 20 + break is (a >= 20) ; 20 or greater wend ``` +A `when` clause can fall-through to the following clause, just like C `switch` statements by leaving out the `break` at the end of a clause. ##### FOR \ [STEP]/NEXT Iteration over a range is handled with the `for`/`next` loop. When iterating from a smaller to larger value, the `to` construct is used; when iterating from larger to smaller, the `downto` construct is used. diff --git a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java index 414569d9..ee7501bd 100644 --- a/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java +++ b/OutlawEditor/src/main/java/org/badvision/outlaweditor/MapEditor.java @@ -29,6 +29,7 @@ import org.badvision.outlaweditor.data.TileUtils; import org.badvision.outlaweditor.data.xml.Map; import org.badvision.outlaweditor.data.xml.Script; import org.badvision.outlaweditor.data.xml.Tile; +import org.badvision.outlaweditor.ui.ToolType; /** * @@ -118,11 +119,17 @@ public class MapEditor extends Editor implements EventH public void assignScript(Script script, double x, double y) { int xx = (int) (x / tileWidth); int yy = (int) (y / tileHeight); - System.out.println("Dropped " + script.getName() + " at " + xx + "," + yy); getCurrentMap().putLocationScript(xx, yy, script); redraw(); } + public void unassignScripts(double x, double y) { + int xx = (int) (x / tileWidth); + int yy = (int) (y / tileHeight); + getCurrentMap().removeLocationScripts(xx, yy); + redraw(); + } + public void togglePanZoom() { anchorPane.getChildren().stream().filter((n) -> !(n == drawCanvas)).forEach((n) -> { n.setVisible(!n.isVisible()); @@ -238,8 +245,8 @@ public class MapEditor extends Editor implements EventH } } - private static final int dashLength=3; - + private static final int dashLength = 3; + private void highlightScripts(int x, int y, List