- USBMouse
- 08 Jun 2007 09:07:17 pm
- Last edited by elfprince13 on 08 Jun 2007 09:30:27 pm; edited 1 time in total
sadly, I'm no longer sure if this will be feasible as an SE. the code doesn't crash on calc, however without a mouse plugged in it drastically slows down the mouse movement. with a mouse plugged in you can't move the mouse at all, either by using the mouse, or by using the keys. my guess is that its because it has to reload and initialize the driver every mouse cycle.
anywho, its fairly small, so if kerm has almost any freespace (the module takes 326 bytes and it would take less if I hadn't had to be hackish to try and get it to work as an SE.
here's the code. if you want to compile it, plz to ask me for the include files.
Code:
anywho, its fairly small, so if kerm has almost any freespace (the module takes 326 bytes and it would take less if I hadn't had to be hackish to try and get it to work as an SE.
here's the code. if you want to compile it, plz to ask me for the include files.
Code:
;USB Browse
.nolist
#include "dcs6.inc"
USBDriverCall = 326 + $86ec
USBDriverBuf = USBDriverCall + 32
DBuf = USBDriverBuf+128
savesscreen = $86ec ;aka SERam
#include "usb8xspasm.inc"
_strcpy =$44E3
_MultAbyE =$8042
_memclear =$4c30
_findapp =$4c4e
;SEOffset equ $86ec
.list
.org 0
.db $BB,$6D ;ASM program header
.db $AB,$C9 ;ignore program; ret
SEStart:
.db $31,$87,$50 ;SE for DCS 5 and higher
.dw SEBoot-SEStart ;or .dw 0 if there is no boot section in this SE
.dw SEMouse-SEStart ;or .dw 0 if there is no mouse section in this SE
.dw 0 ;or .dw 0 if there is no unload section in this SE
SEBoot: ;if there is a boot section...
;...code...
in a,(6)
ld (ix),a
ret
SEOffset = SERam - $
SEMouse:
;ld d,0
;ret
;if there is a mouse section...
;...code...
in a,(2)
ld b,a
and 80h
jp z,TI83p+SEOffset
in a,(21h)
and 3
jp z,TI84p+SEOffset
bit 5,b
jp z,TI83p+SEOffset
TI84p:
.echo "SEoffset"
.echo (TI84p + SEOffset)
push ix
ld hl,uuAppName+SEOffset
rst 20h ;move 9 to op1
;bcall(_mov9toop1)
bcall(_findapp)
jp c,uuDone+SEOffset
ld de,USBDriverCall
ld hl,uuDriverCode+SEOffset
ld bc,uuDriverSize
ldir
ld (USBDriverCall+uuMod1 + 1),a
in a,(6)
ld (USBDriverCall+uuMod3 +1),a
or a
jp uuDone+SEOffset
uuAppName:
.db $14,"USBDRV8X",0
uuDriverCode:
push af
in a,(6)
ld (USBDriverCall+uuMod2 +1),a
call USBDriverCall+uuCall1
pop af
call USBDriverEntryPoint
push af
uuMod2 = $ - uuDriverCode
ld a,0
out (6),a
pop af
ret
uuCallBack:
uuMod3 = $-uuDriverCode
ld a,0
out (6),a
call Stub+SEOffset
uuCall1 EQU $-uuDriverCode
uuMod1 EQU $-uuDriverCode
ld a,0
out (6),a
ret
uuDriverSize = $ - uuDriverCode
uuDone:
offCallBack = uuCallBack-uuDriverCode
;in a,(6)
jp c,NOUSB+SEOffset
ld hl,USBDriverBuf
U_CALL(DriverInit)
jp c,USBERR+SEOffset
ld hl,DBuf
ld bc,256
bcall(_MemClear)
ld de,DBuf
ld b,0
U_CALL(MouseInit)
jp c,USBERR+SEOffset
U_CALL(MouseGetKey)
bit 0,b
jr nz,LeftClick
bit 1,b
jr nz,RightClick
bit mouseBitRight,c
jr nz,MoveRight
bit mouseBitLeft,c
jr nz,MoveLeft
bit mouseBitUp,c
jr nz,MoveUp
bit mouseBitDown,c
jr nz,MoveDown
U_CALL(HostKill)
U_CALL(DriverKill)
NOUSB:
pop ix
ld a,(ix)
out (6),a
ld d,0
ret
LeftClick:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,1
ret
RightClick:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,2
ret
MoveLeft:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,5
ret
MoveRight:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,6
ret
MoveUp:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,3
ret
MoveDown:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
ld d,4
ret
USBERR:
U_CALL(HostKill)
U_CALL(DriverKill)
pop ix
ld a,(ix)
out (6),a
TI83P:
ld d,0
Stub:
ret
MyRam = $ - SEMouse
.echo "Mouse Module Size:"
.echo $ - SEMouse
.end
END