1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-21 09:16:34 +00:00

Library improvements

This commit is contained in:
Karol Stasiak
2018-12-17 17:18:29 +01:00
parent 7616c246ee
commit 585407e9bb
38 changed files with 554 additions and 70 deletions
+9 -3
View File
@@ -3,8 +3,8 @@
# Target platforms
Currently, Millfork supports creating disk- or tape-based programs
for Commodore, Apple, BBC and Atari 8-bit computers, NEC PC-88, ZX Spectrum 48k,
and cartridge-based programs for Famicom/NES and Atari 2600,
for Commodore, Apple, BBC and Atari 8-bit computers, NEC PC-88, ZX Spectrum 48k, CP/M,
and cartridge-based programs for Commodore 64, VIC-20, Famicom/NES and Atari 2600,
but it may be expanded to support other 6502-based and Z80-based platforms in the future.
To add a custom platform yourself, see [the custom platform adding guide](./custom-platform.md).
@@ -15,6 +15,10 @@ The following platforms are currently supported:
* `c64` Commodore 64
* `c64_crt8k` Commodore 64, 8K ROM cartridge
* `c64_crt16k` Commodore 64, 16K ROM cartridge
* `c64_scpu` Commodore 64 with SuperCPU in emulation mode
* `c64_scpu16` Commodore 64 with SuperCPU in native, 16-bit mode (very buggy)
@@ -33,6 +37,8 @@ Read [the LUnix programming guide](./lunix-programming-guide.md) for more info.
* `vic20_8k` Commodore VIC-20 with 8K or 16K memory expansion
* `vic20_a000` Commodore VIC-20, 8K ROM cartridge at $A000
* `c128` Commodore 128 in its native mode
* `pet` Commodore PET
@@ -55,7 +61,7 @@ Read [the BBC Micro programming guide](./bbcmicro-programming-guide.md) for more
The compiler only emits raw binaries, not disk images.
Read [the Apple 2 programming guide](./apple2-programming-guide.md) for more info.
* `pc88` NEC PC-88 (no ROM routines are mapped yet)
* `pc88` NEC PC-88
* `zxspectrum` Sinclair ZX Spectrum 48k
+4
View File
@@ -39,8 +39,12 @@
* [`stdlib` module](stdlib/stdlib.md)
* [Modules for reading input devices](stdlib/input.md)
* [Other cross-platform modules](stdlib/other.md)
* [Definitions available on only some platforms](stdlib/frequent.md)
* [C64-only modules](stdlib/c64.md)
* [NES-only modules](stdlib/nes.md)
+40 -3
View File
@@ -8,16 +8,53 @@ The `c64_kernal` module is imported automatically on the C64 target.
TODO
## `c64_basic` module
## c64_basic module
TODO
## `c1531_mouse` module
## c64_hardware
TODO
## c1531_mouse
The `c1531_mouse` module implements a Commodore 1531 proportional mouse driver compatible with the `mouse` module.
#### `void c1531_mouse ()`
#### `void c1531_mouse()`
Updates the state of the mouse.
## c1531_mouse_default
Defines the `c1531` module as the default module for reading mouse input.
#### `alias read_mouse = c1531_mouse`
## c64_joy
The `c64_joy` module implements a joystick driver compatible with the `joy` module.
#### `void read_joy2()`
Reads the joystick from the port 2.
#### `void read_joy1()`
Reads the joystick from the port 1.
#### `void read_also_joy2()`
Reads the joystick from the port 2 and adds its readouts to the current readouts.
#### `void read_also_joy1()`
Reads the joystick from the port 1 and adds its readouts to the current readouts.
## c64_joy2_default
Defines the joystick in port 2 as the default joystick.
#### `alias read_joy = read_joy2`
+42
View File
@@ -0,0 +1,42 @@
[< back to index](../index.md)
Definitions on the following list are frequently provided by the default automatically-imported modules.
However, as they are not the part of the standard library, they might not be available on all targets:
#### `void putchar(byte char)`
Prints a single character.
Available for: all computer targets.
#### `void new_line()`
Moves the cursor to the next line.
Available for: all computer targets.
#### `void bell()`
Beeps.
Available for: Apple 2, ZX Spectrum.
#### `void set_bg_color(byte color)`
Sets the screen background color.
Available for: C64, VIC-20, C64, C264 series.
#### `void set_border(byte color)`
Sets the screen border color.
Available for: VIC-20, C64, C264 series, ZX Spectrum.
#### `const byte black, white, red, green, blue, cyan, purple, yellow`
Various colour constants.
Available for: VIC-20, C64, C264 series, ZX Spectrum.
+66
View File
@@ -0,0 +1,66 @@
[< back to index](../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.
#### `sbyte input_dx`
Horizontal joystick movement. 1 if right, -1 if left, 0 if neither.
#### `sbyte input_dy`
Vertical joystick movement. 1 if right, -1 if left, 0 if neither.
#### `byte input_btn`
1 if main button pressed, 0 id not pressed.
#### `void reset_joy()`
Resets the state variables.
For platforms with more than one button, this resets only the main button state.
## null_joy_default
This module set the default joystick to no joystick.
#### `alias read_joy`
## 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.
#### `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 joystick to no joystick.
#### `void read_mouse()`
+50 -3
View File
@@ -2,13 +2,13 @@
# NES/Famicom-oriented modules
## `nes_hardware` module
## nes_hardware
The `nes_hardware` module is imported automatically on NES targets.
TODO
## `nes_mmc4` module
## nes_mmc4
The `nes_mmc4` module is imported automatically on the NES MMC4 target.
and contains routines related to MMC4 bankswitching.
@@ -37,4 +37,51 @@ Switches nametable mirroring to vertical.
#### `void set_horizontal_mirroring()`
Switches nametable mirroring to horizontal.
Switches nametable mirroring to horizontal.
## nes_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_joy1()`
Reads the joypad from the port 1.
#### `void read_joy2()`
Reads the joypad from the port 2.
#### `void read_also_joy1()`
Reads the joypad from the port 1 and adds its readouts to the current readouts.
#### `void read_also_joy2()`
Reads the joypad from the port 2 and adds its readouts to the current readouts.
#### `void nes_reset_joy()`
Resets the state variables.
Unlike `reset_joy`, this resets all the NES button states.
## nes_joy1_default
Defines the joystick in port 1 as the default joystick.
#### `alias read_joy = read_joy1`
+2 -33
View File
@@ -1,6 +1,6 @@
[< back to index](../index.md)
## `stdio` module
## stdio
The `stdio` module automatically imports the `string` module.
It requires an implementation of `void putchar(byte a)` and therefore works only on targets with console output.
@@ -14,40 +14,9 @@ Prints a string of length `len` located at address `str`.
Prints a null-terminated string located at address `str`.
If the string is longer than 255 bytes, then the behaviour is undefined (might even crash).
## `string` module
## string
#### `byte strzlen(pointer str)`
Calculates the length of a null-terminated string.
If the string is longer than 255 bytes, then the behaviour is undefined (might even crash).
## `mouse` module
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.
#### `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.
+2 -2
View File
@@ -1,6 +1,6 @@
[< back to index](../index.md)
## `stdlib` module
## stdlib
The `stdlib` module is automatically imported on most targets.
@@ -30,4 +30,4 @@ Returns an ASCII representation of the lower nibble of the given byte.
#### `macro asm void panic()`
Crashes the program.
Crashes the program.