diff --git a/docs/api/famicom-programming-guide.md b/docs/api/famicom-programming-guide.md index ffd99941..36d1e1d4 100644 --- a/docs/api/famicom-programming-guide.md +++ b/docs/api/famicom-programming-guide.md @@ -40,7 +40,7 @@ Therefore, it's recommended to stick to mappers that have a fixed bank at the en Mappers that should be fine: NROM (0), CNROM (1), UxROM(2), MMC2 (9), MMC3 (4), MMC4 (10), MMC6 (4). -Mappers that can have arbitrary bank at the end and are therefore not recommended: MMC1 (1), MMC5 (5). +Mappers that can have arbitrary bank at the end are therefore not recommended: MMC1 (1), MMC5 (5). You should define at least three segments: diff --git a/docs/api/rom-vs-ram.md b/docs/api/rom-vs-ram.md index 8857476a..d648e2fa 100644 --- a/docs/api/rom-vs-ram.md +++ b/docs/api/rom-vs-ram.md @@ -23,13 +23,13 @@ It is imported automatically, you don't need to add any import statements. If you are targeting both RAM-based and ROM-based platforms, wrap the call in `#if INIT_RW_MEMORY`...`#endif`, as the `init_rw_memory` function is not available for RAM-based targets. For example: - void main() { - #if INIT_RW_MEMORY - // do a bankswitch to the SEGMENT segment if applicable - init_rw_memory() - #endif - // ... rest of the code - } + void main() { + #if INIT_RW_MEMORY + // do a bankswitch to the SEGMENT segment if applicable + init_rw_memory() + #endif + // ... rest of the code + } If the default implementation of `init_rw_memory` is unsatisfactory for your needs, consider implementing your own and putting it in the `init_rw_memory` module diff --git a/docs/lang/literals.md b/docs/lang/literals.md index 8269f1a1..23310afc 100644 --- a/docs/lang/literals.md +++ b/docs/lang/literals.md @@ -89,17 +89,25 @@ However, if the command-line option `-flenient-encoding` is used, then literals using `default` and `scr` encodings replace unsupported characters with supported ones. If the replacement is one character long, only a warning is issued, otherwise an error is raised. +## Struct constructors + +You can create a constant of a given struct type by listing constant values of fields as arguments: + + struct point { word x, word y } + point(5,6) + + ## Array initialisers An array is initialized with either: -* a string literal +* (only byte arrays) a string literal -* a `file` expression +* (only byte arrays) a `file` expression * a `for`-style expression -* a format, followed by an array initializer: +* (only byte arrays) a format, followed by an array initializer: * `@word` (=`@word_le`): for every term of the array initializer, emit two bytes, first being the low byte of the value, second being the high byte: `@word [$1122]` is equivalent to `[$22, $11]` @@ -114,18 +122,18 @@ An array is initialized with either: * `@struct`: every term of the initializer is interpreted as a struct constructor (see below) and treated as a list of bytes with no padding `@struct [s(1, 2)]` is equivalent to `[1, 2]` when `struct s {byte x, byte y}` is defined - `@struct [s(1, 2), s(3, 4)]` is equivalent to `[1, 0, 2, 0, 3, 0, 4, 0]` when `struct s {word x, word y}` is defined - + `@struct [s(1, 2), s(3, 4)]` is equivalent to `[1, 0, 2, 0, 3, 0, 4, 0]` on little-endian machines when `struct s {word x, word y}` is defined -* a list of byte literals and/or other array initializers, surrounded by brackets: +* a list of literals and/or other array initializers, surrounded by brackets: - - array a = [1, 2] - array b = "----" scr - array c = ["hello world!" ascii, 13] - array d = file("d.bin") - array e = file("d.bin", 128, 256) - array f = for x,0,until,8 [x * 3 + 5] // equivalent to [5, 8, 11, 14, 17, 20, 23, 26] + array a = [1, 2] + array b = "----" scr + array c = ["hello world!" ascii, 13] + array d = file("d.bin") + array e = file("d.bin", 128, 256) + array f = for x,0,until,8 [x * 3 + 5] // equivalent to [5, 8, 11, 14, 17, 20, 23, 26] + array(point) g = [point(2,3), point(5,6)] + array(point) i = for x,0,until,100 [point(x, x+1)] Trailing commas (`[1, 2,]`) are not allowed. diff --git a/docs/lang/text.md b/docs/lang/text.md index cba362b9..42f1c4a1 100644 --- a/docs/lang/text.md +++ b/docs/lang/text.md @@ -69,7 +69,7 @@ control codes for changing the text background color ##### Escape sequence availability -Encoding | new line | braces | backspace | cursor movement | text colour and reverse | background colour +Encoding | new line | braces | backspace | cursor movement | text colour, reverse | background colour --|--|--|--|--|--|-- `pet` | yes | no | no | yes | yes | no `petscr` | no | no | no | no | no | no diff --git a/src/test/scala/millfork/test/ArraySuite.scala b/src/test/scala/millfork/test/ArraySuite.scala index 44804677..3fcdb34d 100644 --- a/src/test/scala/millfork/test/ArraySuite.scala +++ b/src/test/scala/millfork/test/ArraySuite.scala @@ -412,6 +412,7 @@ class ArraySuite extends FunSuite with Matchers { | | array(word) a = [1,2,3] | array(coord) c = [coord(1,2),coord(3,4)] + | array(coord) h @$8000 = for i,0,until,100 [coord(i,i)] | | word output @$c000 | coord output2 @$c002