diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0ba99a..d4eb25c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current version +* Preliminary experimental Game Boy support. + * Added `memory_barrier` macro. * Added `random` module. @@ -12,6 +14,8 @@ * Added hint for identifiers with typos. +* Aliases now also support subfields. + * 6502: Fixed optimizations using index registers. * Fixed volatile-related bugs. diff --git a/README.md b/README.md index d0daf7f6..6c6dcb83 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ For binary releases, see: https://github.com/KarolS/millfork/releases * CP/M * Atari 2600 (experimental) + + * Game Boy (experimental) * inline assembly diff --git a/docs/README.md b/docs/README.md index 9143baa9..1bcc2974 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,6 +53,8 @@ * [NES-only modules](stdlib/nes.md) +* [Game Boy–only modules](stdlib/gb.md) + ## Implementation details * [Variable storage](abi/variable-storage.md) diff --git a/docs/abi/undocumented.md b/docs/abi/undocumented.md index 0daa16ab..ae3a9ebb 100644 --- a/docs/abi/undocumented.md +++ b/docs/abi/undocumented.md @@ -7,7 +7,7 @@ Original 6502 processors accidentally supported a bunch of extra undocumented instructions. Millfork can emit them if so desired. -## Mnemonics +#### Mnemonics Since various assemblers use different mnemonics for undocumented opcodes, Millfork supports multiple mnemonics per opcode. The default one is given first: @@ -55,7 +55,7 @@ but Millfork can distinguish between them and the NMOS illegal instructions base \*\* AXS is also used for SAX in some assemblers. Millfork interprets AXS based on the addressing mode. -## Generation +#### Generation In order for the compiler to emit one of those opcodes, an appropriate CPU architecture must be chosen (`nmos` or `ricoh`) diff --git a/docs/api/gb-programming-guide.md b/docs/api/gb-programming-guide.md new file mode 100644 index 00000000..f263e02e --- /dev/null +++ b/docs/api/gb-programming-guide.md @@ -0,0 +1,22 @@ +[< back to index](../index.md) + +# Game Boy programming guide + +**This guide is incomplete. +Support for Game Boy targets is experimental and all information in this document may become obsolete.** + +## Program lifecycle + +The default Game Boy vectors are defined as following: + +The minimal Game Boy program thus looks like this: + + void main() { + // initialize things + while(true) { } + } + + void on_vblank() { + // do things + } + diff --git a/docs/api/target-platforms.md b/docs/api/target-platforms.md index dc9144d4..16bdafb3 100644 --- a/docs/api/target-platforms.md +++ b/docs/api/target-platforms.md @@ -78,6 +78,10 @@ The compiler emits tape images. * `zxspectrum_8080` – Sinclair ZX Spectrum 48k, using only Intel 8080 instructions +* `gb_small` – a tiny 32K Game Boy program. (experimental) +The compiler emits GB files. +Read [the Game Boy programming guide](./gb-programming-guide.md) for more info. + * `cpm` – CP/M on Intel 8080. The compiler emits COM files. diff --git a/docs/faq.md b/docs/faq.md index 4cacdf50..bf018cd3 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -18,7 +18,7 @@ The goal of Millfork is to succeed where Atalan failed. Large programs in Millfork have been developed for Commodore 64. Millfork was also tested (via emulators) to run trivial programs on other 8-bit Commodore computers, -Atari 8-bit computers, Apple II, BBC Micro, ZX Spectrum 48k, NEC PC-88, CP/M, NES, and Atari 2600. +Atari 8-bit computers, Apple II, BBC Micro, ZX Spectrum 48k, NEC PC-88, CP/M, NES, Game Boy and Atari 2600. Support for other devices using supported processors can be easily added, usually without even modifying the compiler. diff --git a/docs/index.md b/docs/index.md index 9143baa9..1bcc2974 100644 --- a/docs/index.md +++ b/docs/index.md @@ -53,6 +53,8 @@ * [NES-only modules](stdlib/nes.md) +* [Game Boy–only modules](stdlib/gb.md) + ## Implementation details * [Variable storage](abi/variable-storage.md) diff --git a/docs/lang/reentrancy.md b/docs/lang/reentrancy.md index f57a82fc..3cb15a0b 100644 --- a/docs/lang/reentrancy.md +++ b/docs/lang/reentrancy.md @@ -52,7 +52,7 @@ Since most automatic variables will be overwritten by the inner call, the functi In all other cases, the recursive call may cause undefined behaviour. The easiest, but suboptimal way to make a function recursion-safe is to make all local variables stack-allocated -and assigning all parameters to variables as soon as possible. This is slow though, so don't do it unless really necessary. +and assign all parameters to variables as soon as possible. This is slow though, so don't do it unless really necessary. ## Interrupt safety diff --git a/docs/lang/syntax.md b/docs/lang/syntax.md index a40550cf..d6a31a07 100644 --- a/docs/lang/syntax.md +++ b/docs/lang/syntax.md @@ -119,6 +119,10 @@ If the declared size and the size deduced from the `` don't matc * on 6502, it means that the array will not cross a page boundary * on Z80, it means that the array will not cross a page boundary +* `
` is a constant expression that defines where in the memory the array is or will be located. + +* `` is an array literal, see [Literals](./literals.md) + TODO ### Function declarations @@ -305,6 +309,7 @@ continue ### `asm` statements -See [Using assembly within Millfork programs](./assembly.md). +See [Using 6502 assembly within Millfork programs](./assembly.md) +or [Using 8080/LR35902/Z80 assembly within Millfork programs](./assemblyz80.md). \ No newline at end of file diff --git a/docs/stdlib/gb.md b/docs/stdlib/gb.md new file mode 100644 index 00000000..f6e97ee7 --- /dev/null +++ b/docs/stdlib/gb.md @@ -0,0 +1,38 @@ +[< back to index](../index.md) + +# Game Boy–oriented modules + +## gb_hardware + +The `gb_hardware` module is imported automatically on Game Boy targets. + +TODO + +## gb_header_small + +The `gb_header_small` module is imported automatically on small Game Boy targets. +It contains the default header for 32K Game Boy programs. + +## gb_joy + +Provides an interface for reading joypads that is compatible with the `joy` module. + +#### `alias input_a = input_btn` + +1 if A button pressed, 0 id not pressed. + +#### `byte input_b` + +1 if B button pressed, 0 id not pressed. + +#### `byte input_select` + +1 if Select button pressed, 0 id not pressed. + +#### `byte input_start` + +1 if Start button pressed, 0 id not pressed. + +#### `void read_joy()` + +Reads the joypad.