1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-20 18:16:35 +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
+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.