1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-12-27 04:29:34 +00:00

Improvements to mouse support. Added the y_coord type. Renamed x_coord module to coord.

This commit is contained in:
Karol Stasiak 2020-05-01 15:18:34 +02:00
parent 7f9bd18bdd
commit 3e33660c2e
9 changed files with 59 additions and 20 deletions

View File

@ -26,6 +26,10 @@ There are no built-in encodings now, the include path needs to contain the neces
* **Potentially breaking change!** Changed default encoding for CPC to `cpc_en`.
* **Potentially breaking change!** Changed the type of `mouse_lbm` and `mouse_rbm` to `bool`. Added `mouse_mbm`
* Renamed the `x_coord` module to `coord`. Added the `y_coord` type and `TALLSCREEN` preprocessor feature.
* Allow importing modules from subdirectories.
* Allow placing platform definitions in a dedicated subdirectory.

View File

@ -97,8 +97,12 @@ 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
* `TALLSCREEN` 1 if the vertical screen resolution, ignoring borders, is greater than 256, 0 otherwise
* `KEYBOARD` 1 if the target has a keyboard, 0 otherwise
* `USE_MOUSE_MBM` set this to 1 if you want to enable middle button support for the mouse.
* `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

View File

@ -2,7 +2,7 @@
## mouse
The `mouse` module automatically imports the `x_coord` module.
The `mouse` module automatically imports the `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.
@ -13,19 +13,24 @@ To actually use this module, an appropriate mouse module must be used, such as [
Mouse X position.
#### `byte mouse_y`
#### `y_coord mouse_y`
Mouse Y position.
#### `byte mouse_lbm`
#### `bool mouse_lbm`
1 if the left mouse button is being pressed, 0 otherwise
`true` if the left mouse button is being pressed, `false` otherwise
#### `byte mouse_mbm`
`true` if the middle mouse button is being pressed, `false` otherwise.
Available only if `USE_MOUSE_MBM` is set and non-zero.
#### `byte mouse_rbm`
1 if the right mouse button is being pressed, 0 otherwise
`true` if the right mouse button is being pressed, `false` otherwise
## x_coord
## coord
#### `alias x_coord`
@ -33,6 +38,12 @@ 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.
#### `alias y_coord`
The type for representing vertical screen coordinates.
It's `byte` if the screen is 256 pixels tall or less,
or `word` if the screen is more that 256 pixels tall.
## null_mouse_default
This module set the default mouse to null mouse.

View File

@ -64,6 +64,9 @@ void c1531_mouse () {
byte value
poke($dc03, 0)
value = peek($dc01)
mouse_rbm = (value & 1) ^ 1
if value & 16 == 0 { mouse_lbm = 1 } else { mouse_lbm = 0}
mouse_rbm = bool((value & 1) ^ 1)
mouse_lbm = value & 16 == 0
#if USE_MOUSE_MBM
mouse_mbm = false
#endif
}

12
include/coord.mfk Normal file
View File

@ -0,0 +1,12 @@
#if WIDESCREEN
alias x_coord = word
#else
alias x_coord = byte
#endif
#if TALLSCREEN
alias y_coord = word
#else
alias y_coord = byte
#endif

View File

@ -1,16 +1,21 @@
// Generic module for mouse support
// Resolutions up to 512x256 are supported
import x_coord
import coord
// Mouse X coordinate
x_coord mouse_x
// Mouse Y coordinate
byte mouse_y
y_coord mouse_y
// Left mouse button pressed
byte mouse_lbm
bool mouse_lbm
#if USE_MOUSE_MBM
// Middle mouse button pressed
bool mouse_mbm
#endif
// Right mouse button pressed
byte mouse_rbm
bool mouse_rbm

View File

@ -5,6 +5,9 @@ import mouse
void read_mouse() {
mouse_x = 0
mouse_y = 0
mouse_lbm = 0
mouse_rbm = 0
mouse_lbm = false
#if USE_MOUSE_MBM
mouse_mbm = false
#endif
mouse_rbm = false
}

View File

@ -1,6 +1,3 @@
#warn Module x_coord is deprecated, use coord
#if WIDESCREEN
alias x_coord = word
#else
alias x_coord = byte
#endif
import coord

View File

@ -39,7 +39,7 @@ nav:
- stdio module: stdlib/stdio.md
- err and random modules: stdlib/other.md
- keyboard module: stdlib/keyboard.md
- mouse and x_coord modules: stdlib/mouse.md
- mouse and coord modules: stdlib/mouse.md
- joy module: stdlib/joy.md
- encconv module: stdlib/encconv.md
- Platform-dependent definitions: stdlib/frequent.md