Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mouse support added to VDP protocol #104

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/equs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ VDPP_FLAG_POINT: EQU 00000100b
VDPP_FLAG_AUDIO: EQU 00001000b
VDPP_FLAG_MODE: EQU 00010000b
VDPP_FLAG_RTC: EQU 00100000b
VDPP_FLAG_MOUSE: EQU 01000000b
; VDPP_FLAG_BUFFERED: EQU 10000000b

; For GPIO
; PA not available on eZ80F92
Expand Down
10 changes: 9 additions & 1 deletion src/mos_api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ sysvar_scrRows: EQU 14h ; 1: Screen rows in characters
sysvar_scrColours: EQU 15h ; 1: Number of colours displayed
sysvar_scrpixelIndex: EQU 16h ; 1: Index of pixel data read from screen
sysvar_vkeycode: EQU 17h ; 1: Virtual key code from FabGL
sysvar_vkeydown EQU 18h ; 1: Virtual key state from FabGL (0=up, 1=down)
sysvar_vkeydown: EQU 18h ; 1: Virtual key state from FabGL (0=up, 1=down)
sysvar_vkeycount: EQU 19h ; 1: Incremented every time a key packet is received
sysvar_rtc: EQU 1Ah ; 6: Real time clock data
sysvar_spare: EQU 20h ; 2: Spare, previously used by rtc
Expand All @@ -162,6 +162,12 @@ sysvar_keyrate: EQU 24h ; 2: Keyboard repeat reat
sysvar_keyled: EQU 26h ; 1: Keyboard LED status
sysvar_scrMode: EQU 27h ; 1: Screen mode
sysvar_rtcEnable: EQU 28h ; 1: RTC enable flag (0: disabled, 1: use ESP32 RTC)
sysvar_mouseX: EQU 29h ; 2: Mouse X position
sysvar_mouseY: EQU 2Bh ; 2: Mouse Y position
sysvar_mouseButtons: EQU 2Dh ; 1: Mouse button state
sysvar_mouseWheel: EQU 2Eh ; 1: Mouse wheel delta
sysvar_mouseXDelta: EQU 2Fh ; 2: Mouse X delta
sysvar_mouseYDelta: EQU 31h ; 2: Mouse Y delta

; Flags for the VPD protocol
;
Expand All @@ -171,6 +177,8 @@ vdp_pflag_point: EQU 00000100b
vdp_pflag_audio: EQU 00001000b
vdp_pflag_mode: EQU 00010000b
vdp_pflag_rtc: EQU 00100000b
vdp_pflag_mouse: EQU 01000000b
; vdp_pflag_buffered: EQU 10000000b

;
; FatFS structures
Expand Down
25 changes: 23 additions & 2 deletions src/vdp_protocol.asm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
XREF _keydelay
XREF _keyrate
XREF _keyled
XREF _mouseX
XREF _gp
XREF _vpd_protocol_flags
XREF _vdp_protocol_state
Expand Down Expand Up @@ -142,7 +143,8 @@ vdp_protocol_vector: JP vdp_protocol_GP
JP vdp_protocol_AUDIO
JP vdp_protocol_MODE
JP vdp_protocol_RTC
JP vdp_protocol_KEYSTATE
JP vdp_protocol_KEYSTATE
JP vdp_protocol_MOUSE
;
vdp_protocol_vesize: EQU ($-vdp_protocol_vector)/4

Expand Down Expand Up @@ -309,4 +311,23 @@ vdp_protocol_KEYSTATE: LD HL, _vdp_protocol_data
LD DE, _keydelay
LD BC, 5
LDIR
RET
RET

; Mouse data
; Received after a mouse movement event, if mouse has been activated
;
; Word: X position
; Word: Y position
; Byte: Button state
; Byte: Wheel delta
; Word: X delta
; Word: Y delta
;
vdp_protocol_MOUSE: LD HL, _vdp_protocol_data
LD DE, _mouseX
LD BC, 10
LDIR
LD A, (_vpd_protocol_flags)
OR VDPP_FLAG_MOUSE
LD (_vpd_protocol_flags), A
RET
18 changes: 15 additions & 3 deletions src_startup/globals.asm
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,18 @@
XDEF _scrrows
XDEF _scrcolours
XDEF _scrpixelIndex
XDEF _rtc
XDEF _rtc
XDEF _keydelay
XDEF _keyrate
XDEF _keyled
XDEF _scrmode
XDEF _rtc_enable
XDEF _mouseX
XDEF _mouseY
XDEF _mouseButtons
XDEF _mouseWheel
XDEF _mouseXDelta
XDEF _mouseYDelta

XDEF _errno
XDEF _coldBoot
Expand Down Expand Up @@ -97,6 +103,12 @@ _keyrate: DS 2 ; + 24h: Keyboard repeat rate
_keyled: DS 1 ; + 26h: Keyboard LED status
_scrmode: DS 1 ; + 27h: Screen mode
_rtc_enable: DS 1 ; + 28h: RTC enable status
_mouseX: DS 2 ; + 29h: Mouse X position
_mouseY: DS 2 ; + 2Bh: Mouse Y position
_mouseButtons: DS 1 ; + 2Dh: Mouse left+right+middle buttons (bits 0-2, 0=up, 1=down)
_mouseWheel: DS 1 ; + 2Eh: Mouse wheel delta
_mouseXDelta: DS 2 ; + 2Fh: Mouse X delta
_mouseYDelta: DS 2 ; + 31h: Mouse Y delta

_errno: DS 3 ; extern int _errno
_coldBoot: DS 1 ; extern char _coldBoot
Expand Down Expand Up @@ -125,8 +137,8 @@ _keymap: DS 16 ; A bitmap of pressed keys
; Bit 2: Pixel point packet received
; Bit 3: Audio packet received
; Bit 4: Mode packet received
; Bit 5: Unused
; Bit 6: Unused
; Bit 5: RTC packet received
; Bit 6: Mouse packet received
; Bit 7: Unused
;
; VDP protocol variables
Expand Down