2001-07-03 20:24:28 +00:00
|
|
|
;
|
|
|
|
; Maciej 'YTM/Elysium' Witkowiak
|
|
|
|
;
|
|
|
|
; 2.7.2001
|
|
|
|
;
|
|
|
|
; Wrapper for GEOS standard input device interface
|
|
|
|
;
|
2001-09-13 16:00:55 +00:00
|
|
|
|
2001-07-03 20:24:28 +00:00
|
|
|
.export _mouse_init, _mouse_done
|
|
|
|
.export _mouse_hide, _mouse_show
|
2001-09-10 18:42:50 +00:00
|
|
|
.export _mouse_box
|
|
|
|
.export _mouse_pos, _mouse_info
|
2001-07-03 20:24:28 +00:00
|
|
|
.export _mouse_move, _mouse_buttons
|
2001-09-10 18:42:50 +00:00
|
|
|
|
2001-09-13 16:00:55 +00:00
|
|
|
.import popsreg, addysp1
|
2001-09-10 18:42:50 +00:00
|
|
|
.importzp sp, sreg, ptr1
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
.include "../inc/const.inc"
|
|
|
|
.include "../inc/jumptab.inc"
|
|
|
|
.include "../inc/geossym.inc"
|
|
|
|
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
2001-09-13 16:00:55 +00:00
|
|
|
; unsigned char __fastcall__ mouse_init (unsigned char type);
|
2001-07-03 20:24:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_init:
|
|
|
|
jsr StartMouseMode
|
|
|
|
jsr MouseOff
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta mouseTop
|
|
|
|
sta mouseLeft
|
|
|
|
sta mouseLeft+1
|
|
|
|
lda #199
|
|
|
|
sta mouseBottom
|
2001-10-27 17:07:19 +00:00
|
|
|
lda graphMode
|
|
|
|
bpl _mse_screen320
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2001-10-27 17:07:19 +00:00
|
|
|
lda #<639 ; 80 columns on C128
|
|
|
|
ldx #>639
|
|
|
|
bne _mse_storex
|
|
|
|
_mse_screen320:
|
|
|
|
lda #<319 ; 40 columns on C64/C128
|
|
|
|
ldx #>319
|
|
|
|
_mse_storex:
|
|
|
|
sta mouseRight
|
|
|
|
stx mouseRight+1
|
|
|
|
_mse_initend:
|
2001-07-03 20:24:28 +00:00
|
|
|
lda #0
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; void mouse_done (void);
|
|
|
|
;
|
|
|
|
_mouse_done:
|
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; void mouse_hide (void);
|
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_hide = MouseOff
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; void mouse_show (void);
|
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_show = MouseUp
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
|
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_box:
|
2001-09-10 18:42:50 +00:00
|
|
|
ldy #0 ; Stack offset
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
sta mouseBottom
|
|
|
|
|
|
|
|
lda (sp),y
|
|
|
|
sta mouseRight
|
|
|
|
iny
|
|
|
|
lda (sp),y
|
|
|
|
sta mouseRight+1 ; maxx
|
|
|
|
|
|
|
|
iny
|
|
|
|
lda (sp),y
|
|
|
|
sta mouseTop
|
2001-09-10 18:42:50 +00:00
|
|
|
iny ; Skip high byte
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
iny
|
|
|
|
lda (sp),y
|
|
|
|
sta mouseLeft
|
|
|
|
iny
|
|
|
|
lda (sp),y
|
|
|
|
sta mouseLeft+1 ; minx
|
|
|
|
|
|
|
|
jmp addysp1 ; Drop params, return
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
2001-09-10 18:42:50 +00:00
|
|
|
; void __fastcall__ mouse_pos (struct mouse_pos* pos);
|
|
|
|
; /* Return the current mouse position */
|
2001-07-03 20:24:28 +00:00
|
|
|
;
|
|
|
|
|
2001-09-10 18:42:50 +00:00
|
|
|
_mouse_pos:
|
|
|
|
sta ptr1
|
|
|
|
stx ptr1+1 ; Remember the argument pointer
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2001-09-10 18:42:50 +00:00
|
|
|
ldy #0 ; Structure offset
|
2001-07-03 20:24:28 +00:00
|
|
|
|
2001-09-10 22:11:19 +00:00
|
|
|
php
|
|
|
|
sei ; Disable interrupts
|
2001-09-10 18:42:50 +00:00
|
|
|
|
|
|
|
lda mouseXPos ; Transfer the position
|
|
|
|
sta (ptr1),y
|
|
|
|
lda mouseXPos+1
|
|
|
|
iny
|
|
|
|
sta (ptr1),y
|
|
|
|
lda mouseYPos
|
|
|
|
iny
|
|
|
|
sta (ptr1),y
|
|
|
|
lda #$00
|
|
|
|
iny
|
|
|
|
sta (ptr1),y
|
|
|
|
|
2001-09-10 22:11:19 +00:00
|
|
|
plp ; Reenable interrupts
|
2001-09-10 18:42:50 +00:00
|
|
|
rts ; Done
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
2001-09-10 18:42:50 +00:00
|
|
|
; void __fastcall__ mouse_info (struct mouse_info* info);
|
|
|
|
; /* Return the state of the mouse buttons and the position of the mouse */
|
2001-07-03 20:24:28 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_info:
|
|
|
|
|
2001-09-10 18:42:50 +00:00
|
|
|
; We're cheating here to keep the code smaller: The first fields of the
|
|
|
|
; mouse_info struct are identical to the mouse_pos struct, so we will just
|
|
|
|
; call _mouse_pos to initialize the struct pointer and fill the position
|
|
|
|
; fields.
|
|
|
|
|
|
|
|
jsr _mouse_pos
|
|
|
|
|
|
|
|
; Fill in the button state
|
|
|
|
|
|
|
|
jsr _mouse_buttons ; Will not touch ptr1
|
|
|
|
iny
|
|
|
|
sta (ptr1),y
|
|
|
|
|
|
|
|
rts
|
2001-07-03 20:24:28 +00:00
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; void __fastcall__ mouse_move (int x, int y);
|
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_move:
|
|
|
|
jsr popsreg ; Get X
|
2001-09-10 22:11:19 +00:00
|
|
|
php
|
|
|
|
sei ; Disable interrupts
|
2001-07-03 20:24:28 +00:00
|
|
|
sta mouseYPos
|
|
|
|
lda sreg
|
|
|
|
ldx sreg+1
|
|
|
|
sta mouseXPos
|
|
|
|
stx mouseXPos+1
|
2001-09-10 22:11:19 +00:00
|
|
|
plp ; Enable interrupts
|
2001-07-03 20:24:28 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
; --------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; unsigned char mouse_buttons (void);
|
|
|
|
;
|
|
|
|
|
|
|
|
_mouse_buttons:
|
|
|
|
lda pressFlag
|
|
|
|
and #SET_MOUSE
|
|
|
|
lsr
|
|
|
|
rts
|
2001-09-10 18:42:50 +00:00
|
|
|
|