1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-05-28 13:41:31 +00:00

Update and reorganize documentation

This commit is contained in:
Karol Stasiak 2020-03-31 19:07:35 +02:00
parent 80018a55b4
commit 9ffd303583
22 changed files with 293 additions and 175 deletions

View File

@ -8,11 +8,15 @@
* Various improvements to the C64 libraries (thanks to @bsutherland).
* Added detection for various PET variants and implemented `readkey` for PET.
* Added `breakpoint` macro (#44).
* **Potentially breaking change!** Added `min`, `max` and `if` compile-time functions.
* Added experimental `signed16` and `unsigned16` types.
* Added experimental `signed16` and `unsigned16` types. Added `putsigned16` function.
* Fixed `scrstr2word` in some rare encoding combinations.
* Added warnings for calling from one segment to another overlapping one.
@ -20,6 +24,8 @@
* Create output directories when needed (#21).
* Allow defining different output formats for different segments when outputting one file per segment.
* Fixed multiple optimization bugs (#32, #38, #41, #46 and others) thanks to @agg23 for detailed bug reports!
* 6502: Fix boolean arrays and pointers (#28).

View File

@ -34,6 +34,8 @@
* [Inline 8080/LR35902/Z80 assembly syntax](lang/assemblyz80.md)
* [Inline 6809 assembly syntax](lang/assembly6809.md)
* [Important guidelines regarding reentrancy](lang/reentrancy.md)
* [List of keywords](lang/keywords.md)
@ -46,23 +48,35 @@
* [`stdio` module](stdlib/stdio.md)
* [Modules for reading input devices](stdlib/input.md)
* Reading input devices:
* [`joy` module](stdlib/joy.md)
* [`keyboard` module](stdlib/keyboard.md)
* [`mouse` module](stdlib/mouse.md)
* [`encconv` module](stdlib/encconv.md)
* [Other cross-platform modules (`keyboard`, `err`, `random`)](stdlib/other.md)
* [Other cross-platform modules (`err`, `random`)](stdlib/other.md)
* [Definitions available on only some platforms](stdlib/frequent.md)
* Platform-specific modules:
* [C64-only modules](stdlib/c64.md)
* [Definitions available on only some platforms](stdlib/frequent.md)
* [`cbm_file` module](stdlib/cbm_file.md)
* [NES-only modules](stdlib/nes.md)
* [Game Boyonly modules](stdlib/gb.md)
* [X16only modules](stdlib/x16.md)
* [C64-only modules](stdlib/c64.md)
* [PET-only modules](stdlib/cbm_pet.md)
* [`cbm_file` module](stdlib/cbm_file.md)
* [NES-only modules](stdlib/nes.md)
* [Atari Lynx-only modules](stdlib/lynx.md)
* [Game Boyonly modules](stdlib/gb.md)
* [X16only modules](stdlib/x16.md)
## Implementation details

View File

@ -219,6 +219,8 @@ Default: `main,*`
* `d88` - a D88 floppy disk image for PC-88
* `tap` - a tape disk image for ZX Spectrum
* `format_segment_NAME` if using the `per_segment` style, overrides the format for the given segment
* `extension` target file extension, with or without the dot

View File

@ -48,25 +48,35 @@
* [`stdio` module](stdlib/stdio.md)
* [Modules for reading input devices](stdlib/input.md)
* Reading input devices:
* [`joy` module](stdlib/joy.md)
* [`keyboard` module](stdlib/keyboard.md)
* [`mouse` module](stdlib/mouse.md)
* [`encconv` module](stdlib/encconv.md)
* [Other cross-platform modules (`keyboard`, `err`, `random`)](stdlib/other.md)
* [Other cross-platform modules (`err`, `random`)](stdlib/other.md)
* [Definitions available on only some platforms](stdlib/frequent.md)
* Platform-specific modules:
* [C64-only modules](stdlib/c64.md)
* [Definitions available on only some platforms](stdlib/frequent.md)
* [`cbm_file` module](stdlib/cbm_file.md)
* [NES-only modules](stdlib/nes.md)
* [Atari Lynx-only modules](stdlib/lynx.md)
* [Game Boyonly modules](stdlib/gb.md)
* [X16only modules](stdlib/x16.md)
* [C64-only modules](stdlib/c64.md)
* [PET-only modules](stdlib/cbm_pet.md)
* [`cbm_file` module](stdlib/cbm_file.md)
* [NES-only modules](stdlib/nes.md)
* [Atari Lynx-only modules](stdlib/lynx.md)
* [Game Boyonly modules](stdlib/gb.md)
* [X16only modules](stdlib/x16.md)
## Implementation details

View File

@ -54,10 +54,12 @@ The following features are defined based on the chosen CPU and compilation optio
`CPUFEATURE_8080`, `CPUFEATURE_8085`, `CPUFEATURE_GAMEBOY`, `CPUFEATURE_Z80`,
`CPUFEATURE_6502_ILLEGALS`, `CPUFEATURE_8085_ILLEGALS`, `CPUFEATURE_Z80_ILLEGALS`, `CPUFEATURE_Z80_NEXT` 1 if given instruction subset is enabled, 0 otherwise
* `ENCCONV_SUPPORTED` - 1 if the module `encconv` supports the function `to_screencode` and other related funtions, 0 otherwise.
* `ENCCONV_SUPPORTED` - 1 if the module `encconv` supports the function `to_screencode` and other related functions, 0 otherwise.
* `ENCODING_SAME` - 1 if the encodings `default` and `src` are the same, 0 otherwise.
* `DECIMALS_SAME` - 1 if the encodings `default` and `src` have the same string terminator and decimal digits `'0'`-`'9'`, 0 otherwise.
* `NULLCHAR_SAME` - 1 if the encodings `default` and `src` have the same string terminator, 0 otherwise.
* `NULLCHAR` the value of the `nullchar` constant
@ -90,38 +92,37 @@ See [the ROM vs RAM guide](../api/rom-vs-ram.md) for more information.
### Commonly used features
These features are frequently defined in the platform definition file.
Some libraries may require that some of these be defined.
* `WIDESCREEN` 1 if the horizontal screen resolution, ignoring borders, is greater than 256, 0 otherwise
* `CBM` 1 if the target is an 8-bit Commodore computer (or a compatible one), 0 otherwise
* `CBM_64_COMPAT` 1 if the target is an 8-bit Commodore computer compatible with Commodore 64, 0 otherwise
* `CBM_64_CRT` 1 if the target is a cartridge for Commodore 64, 0 otherwise
* `CBM_264` 1 if the target is an 8-bit Commodore computer from the 264 line, 0 otherwise
* `KEYBOARD` 1 if the target has a keyboard, 0 otherwise
* `JOYSTICKS` the maximum number of joysticks using standard hardware configurations, may be 0
* `HAS_BITMAP_MODE` 1 if the target has a display mode with every pixel addressable, 0 otherwise
* `MOS_6510` 1 if the target uses a MOS 6510-compatible processor (with an I/O port at $0000/$0001)
* `CPM` 1 if the target is CP/M, 0 otherwise
* `IBM_PC` 1 if the target is IBM PC, 0 otherwise
* `MSX` 1 if the target is MSX, 0 otherwise
* `NTSC` 1 if the target is NTSC, 0 otherwise
* `PAL` 1 if the target is PAL, 0 otherwise
* `NULLPTR` physical value of `nullptr`, default 0
### Target-specific features
These features are used to identify the target machine in multiplatform programs and libraries:
* `CBM` 1 if the target is an 8-bit Commodore computer (or a compatible one), 0 otherwise
(for more Commodore-related preprocessor options, see [Preprocessor options for Commodore computer targets](./preprocessor_cbm.md))
* `AMSTRAD_CPC`, `ATARI_2600`, `ATARI_8`, `ATARI_LYNX`, `APPLE_2`, `BBC_MICRO`,
`COMMANDER_X16`, `CPM`, `GAMEBOY`, `IBM_PC`, `MSX`, `NEC_PC_88`, `NES`, `ZX_SPECTRUM`
1 if the target is the machine in question, 0 otherwise
* `VERA_VERSION` on Commander X16, the version of the VERA chip: `7` for 0.7, `8` for 0.8
### Built-in preprocessor functions and operators
The `defined` function returns 1 if the feature is defined, 0 otherwise.

View File

@ -0,0 +1,38 @@
[< back to index](../doc_index.md)
# Preprocessor options for Commodore computer targets
All Commodore targets define the `CBM` feature as 1.
### Target detection
* `CBM_PET` 1 if the target is PET, 0 otherwise
* `CBM_VIC` 1 if the target is VIC-20, 0 otherwise
* `CBM_264` 1 if the target is an 8-bit Commodore computer from the 264 line, 0 otherwise
* `MOS_6510` 1 if the target uses a MOS 6510-compatible processor (with an I/O port at $0000/$0001)
* `CBM_64` 1 if the target is Commodore 64, 0 otherwise
* `CBM_64_CRT` 1 if the target is a cartridge for Commodore 64, 0 otherwise
* `LUNIX` 1 if the target is Commodore 64 running Lunix, 0 otherwise
* `CBM_128` 1 if the target is Commodore 128, 0 otherwise
* `CBM_64_COMPAT` 1 if the target is an 8-bit Commodore computer compatible with Commodore 64
(for example, C128, C65, Mega 65), but not Commodore 64 itself, 0 otherwise
### Feature enabling
Due to incompatibilities between different versions of Commodore PET,
certain libraries can be configured to support only some ROM revisions.
By default, all of these are enabled:
* `PET2000_SUPPORT` set this to 1 to enable support for PET 2001 with the original ROMs (BASIC 1.0), set it to 0 to disable it
* `PET3000_SUPPORT` set this to 1 to enable support for PET 3000 series with the upgraded ROMs (BASIC 2.0), set it to 0 to disable it
* `PET4000_SUPPORT` set this to 1 to enable support for PET 4000 with the 4.0 ROMs (BASIC 4.0), set it to 0 to disable it

View File

@ -22,7 +22,7 @@ TODO
## c1531
The `c1531` module implements a Commodore 1531 proportional mouse driver compatible with the `mouse` module.
The `c1531` module implements a Commodore 1531 proportional mouse driver compatible with the [`mouse` module](./mouse.md).
#### `void c1531_mouse()`
@ -36,7 +36,7 @@ Defines the `c1531` module as the default module for reading mouse input.
## c64_joy
The `c64_joy` module implements a joystick driver compatible with the `joy` module.
The `c64_joy` module implements a joystick driver compatible with the [`joy` module](./joy.md).
#### `void read_joy2()`

26
docs/stdlib/cbm_pet.md Normal file
View File

@ -0,0 +1,26 @@
[< back to index](../doc_index.md)
# Commodore PET-oriented modules
## pet_kernal module
The `pet_kernal` module is imported automatically on the PET target.
It provides access to Kernal routines.
TODO
#### asm set_zero is_pet2000()
Returns true if the current machine has the original ROM (usually, the PET 2000 series).
When calling from assembly, the result is stored in the Z flag.
#### asm set_zero is_pet3000()
Returns true if the current machine has the upgraded ROM (usually, the PET 3000 series).
When calling from assembly, the result is stored in the Z flag.
#### asm set_zero is_pet4000()
Returns true if the current machine has the 4.0 ROM (usually, the PET 4000 series).
When calling from assembly, the result is stored in the Z flag.

View File

@ -87,21 +87,6 @@ Various colour constants.
Available for: VIC-20, C64, C128, C264 series, ZX Spectrum.
#### `macro void memory_barrier()`
Informs the optimizer that at this point arbitrary memory has been accessed and either read or written by an external device.
The optimizer should not optimize any memory accesses across that macro.
Available for: all targets.
#### `macro void breakpoint()`
If the `-fbreakpoints` option is selected (default), then it emits a memory barrier,
and also outputs a breakpoint to the label file (if the format of the label file allows it).
If the `-fno-breakpoints` option is selected, then it does nothing.
Available for: all targets.

View File

@ -15,7 +15,7 @@ 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.
Provides an interface for reading joypads that is compatible with the [`joy` module](./joy.md).
#### `alias input_a = input_btn`

View File

@ -1,73 +0,0 @@
[< back to index](../doc_index.md)
## joy
The module contains global variables representing the state of the one-button joystick.
If the program is not using any joystick driver, the state of these variables is undefined.
To actually use this module, an appropriate joystick module must be used, such as `c64_joy`, `nes_joy` or `gb_joy`.
#### `sbyte input_dx`
Horizontal joystick movement. 1 if right, -1 if left, 0 if neither.
#### `sbyte input_dy`
Vertical joystick movement. 1 if down, -1 if up, 0 if neither.
#### `byte input_btn`
1 if main button pressed, 0 if not pressed.
#### `void reset_joy()`
Resets the state variables.
The default implementation resets only the main button.
May be overridden by a strong alias on some platforms that have more buttons.
## null_joy_default
This module set the default joystick to no joystick.
#### `alias read_joy`
A reserved name for reading the default joystick.
## mouse
The `mouse` module automatically imports the `x_coord` module.
The module contains global variables representing the state of the mouse.
If the program is not using any mouse driver, the state of these variables is undefined.
To actually use this module, an appropriate mouse module must be used, such as `c1531`.
#### `x_coord mouse_x`
Mouse X position.
#### `byte mouse_y`
Mouse Y position.
#### `byte mouse_lbm`
1 if the left mouse button is being pressed, 0 otherwise
#### `byte mouse_rbm`
1 if the right mouse button is being pressed, 0 otherwise
## `x_coord` module
#### `alias x_coord`
The type for representing horizontal screen coordinates.
It's `byte` if the screen is 256 pixels wide or less,
or `word` if the screen is more that 256 pixels wide.
## null_mouse_default
This module set the default mouse to no mouse.
#### `void read_mouse()`

35
docs/stdlib/joy.md Normal file
View File

@ -0,0 +1,35 @@
[< back to index](../doc_index.md)
## joy
The module contains global variables representing the state of the one-button joystick.
If the program is not using any joystick driver, the state of these variables is undefined.
To actually use this module, an appropriate joystick module must be used,
such as [`c64_joy`](./c64.md), [`nes_joy`](./nes.md), [`gb_joy`](./gb.md) or [`x16_joy`](./x16.md).
#### `sbyte input_dx`
Horizontal joystick movement. 1 if right, -1 if left, 0 if neither.
#### `sbyte input_dy`
Vertical joystick movement. 1 if down, -1 if up, 0 if neither.
#### `byte input_btn`
1 if main button pressed, 0 if not pressed.
#### `void reset_joy()`
Resets the state variables.
The default implementation resets only the main button.
May be overridden by a strong alias on some platforms that have more buttons.
## null_joy_default
This module set the default joystick to no joystick.
#### `alias read_joy`
A reserved name for reading the default joystick.

34
docs/stdlib/keyboard.md Normal file
View File

@ -0,0 +1,34 @@
[< back to index](../doc_index.md)
## keyboard
The `keyboard` module provides support for reading keypresses from the keyboard.
Not supported on all targets.
For reading entire lines of text from the keyboard, see the `readline` and `readword` functions
in [the frequently provided definitions](./frequent.md).
#### `byte readkey()`
Waits for and reads a single keypress.
The returning values may vary between platforms:
* letters may be uppercase or lowercase
* modifier keys may be applied or ignored
Available for:
Commodore 64 (requires KERNAL),
Commodore 16 or Plus/4 (requires KERNAL),
Commodore 128 (requires KERNAL),
Commodore PET (requires KERNAL),
VIC 20 (requires KERNAL),
Atari,
Amstrad CPC,
ZX Spectrum,
NEC PC-88.
#### `const byte KEY_ENTER`
Key code for the Enter/Return key. Usually 13, but not always.

View File

@ -4,9 +4,9 @@
## atari_lynx_hardware
The `atari_lynx_hardware` module is imported automatically on NES targets.
The `atari_lynx_hardware` module is imported automatically on Atari Lynx targets.
It also implements a joystick API compatible with the `joy` module.
It also implements a joystick API compatible with the [`joy` module](./joy.md).
TODO

41
docs/stdlib/mouse.md Normal file
View File

@ -0,0 +1,41 @@
[< back to index](../doc_index.md)
## mouse
The `mouse` module automatically imports the `x_coord` module.
The module contains global variables representing the state of the mouse.
If the program is not using any mouse driver, the state of these variables is undefined.
To actually use this module, an appropriate mouse module must be used, such as [`c1531`](./c64.md).
#### `x_coord mouse_x`
Mouse X position.
#### `byte mouse_y`
Mouse Y position.
#### `byte mouse_lbm`
1 if the left mouse button is being pressed, 0 otherwise
#### `byte mouse_rbm`
1 if the right mouse button is being pressed, 0 otherwise
## x_coord
#### `alias x_coord`
The type for representing horizontal screen coordinates.
It's `byte` if the screen is 256 pixels wide or less,
or `word` if the screen is more that 256 pixels wide.
## null_mouse_default
This module set the default mouse to null mouse.
The null mouse has no button pressed and the cursos is fixed at coordinates (0,0).
#### `void read_mouse()`

View File

@ -26,7 +26,7 @@ Available variables:
#### `byte strobe_joypad()`
Updates joypad1 by querying for new button states.
Strobes joypads in preparation for reading new joypad states.
#### `byte read_joypad1()`
@ -99,7 +99,7 @@ Switches nametable mirroring to horizontal.
## nes_joy
Provides an interface for reading joypads that is compatible with the `joy` module.
Provides an interface for reading joypads that is compatible with the [`joy` module](./joy.md).
#### `alias input_a = input_btn`

View File

@ -1,34 +1,5 @@
[< back to index](../doc_index.md)
## keyboard
The `keyboard` module provides support for reading keypresses from the keyboard.
Not supported on all targets.
#### `byte readkey()`
Waits for and reads a single keypress.
The returning values may vary between platforms:
* letters may be uppercase or lowercase
* modifier keys may be applied or ignored
Available for:
Commodore 64 (requires KERNAL),
Commodore 16 or Plus/4 (requires KERNAL),
Commodore 128 (requires KERNAL),
VIC 20 (requires KERNAL),
Atari,
Amstrad CPC,
ZX Spectrum,
NEC PC-88.
#### `const byte KEY_ENTER`
Key code for the Enter/Return key. Usually 13, but not always.
## err
#### `enum error_number`

View File

@ -3,7 +3,8 @@
## stdio
The `stdio` module automatically imports the `string` and `err` modules.
It requires an implementation of `void putchar(byte a)` and therefore works only on targets with console output.
It requires an implementation of `void putchar(byte a)` and therefore works only on targets with console output
(see [the frequently provided definitions](./frequent.md) for details).
On targets with idiosyncratic behaviour of `putchar`, functions in this module inherit that behaviour.
#### `void putstr(pointer str, byte len)`
@ -19,6 +20,10 @@ If the string is longer than 255 bytes, then the behaviour is undefined (might e
Prints the decimal representation of the 16-bit unsigned integer `w`.
#### `void putsigned16(signed16 w)`
Prints the decimal representation of the 16-bit signed integer `w`.
#### `void ensure_mixedcase()`
On targets that have separate all-caps and mixed-case modes (like most Commodore machines), switches to the mixed-case mode.

View File

@ -31,3 +31,21 @@ Returns an ASCII representation of the lower nibble of the given byte.
#### `macro asm void panic()`
Crashes the program.
## Standard macros available without any import
#### `macro void memory_barrier()`
Informs the optimizer that at this point arbitrary memory has been accessed and either read or written by an external device.
The optimizer should not optimize any memory accesses across that macro.
Available for: all targets.
#### `macro void breakpoint()`
If the `-fbreakpoints` option is selected (default), then it emits a memory barrier,
and also outputs a breakpoint to the label file (if the format of the label file allows it).
If the `-fno-breakpoints` option is selected, then it does nothing.
Available for: all targets.

View File

@ -2,7 +2,7 @@
## string
The `string` module automatically imports the `err` module.
The `string` module automatically imports the [`err` module](./other.md).
All the functions are designed to work for the strings in the default encoding.
If passed a string in an encoding that has a different null terminator,
@ -40,7 +40,7 @@ Modifies the given null-terminated buffer by appending a null-terminated string
## scrstring
The `scrstring` module automatically imports the `string` and `err` modules.
The `scrstring` module automatically imports the `string` and [`err`](./other.md). modules.
It contains functions for handling strings in the screen encoding with the same semantics as the functions from the string module.

View File

@ -5,13 +5,14 @@
**WARNING!** Commander X16 is not yet a finalised design.
Therefore, both the device itself and the modules for its support may change at any moment.
## x16_kernal module
## x16_kernal
The `x16_kernal` module is imported automatically on the X16 target.
Currently, it automatically imports the [`c64_kernal` module](./c64.md).
## `x16_hardware` module
## x16_hardware
The `x16_hardware` module is imported automatically on the X16 target.
@ -78,7 +79,8 @@ Hardware register values for a sprite:
Various addresses in the VERA memory space.
## `x16_joy` module
## x16_joy
The `x16_joy` module implements a joystick driver compatible with the `joy` module.

View File

@ -36,12 +36,15 @@ nav:
- stdlib module: stdlib/stdlib.md
- string and scrstring modules: stdlib/string.md
- stdio module: stdlib/stdio.md
- keyboard, err, random: stdlib/other.md
- joy, mouse, x_coord: stdlib/input.md
- err and random modules: stdlib/other.md
- keyboard module: stdlib/keyboard.md
- mouse and x_coord modules: stdlib/mouse.md
- joy module: stdlib/joy.md
- encconv module: stdlib/encconv.md
- Platform-dependent modules: stdlib/frequent.md
- Platform-dependent definitions: stdlib/frequent.md
- cbm_file module: stdlib/cbm_file.md
- C64-only modules: stdlib/c64.md
- PET-only modules: stdlib/cbm_pet.md
- NES-only modules: stdlib/nes.md
- Lynx-only modules: stdlib/lynx.md
- Game Boyonly modules: stdlib/gb.md