Vic-20 mouse driver & demo program for NEOS mouse

Basic and Machine Language

Moderator: Moderators

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Vic-20 mouse driver & demo program for NEOS mouse

Postby Kakemoms » Tue Sep 29, 2015 1:58 pm

Here is a working demo program w/driver for using the NEOS mouse on the Vic-20: (deleted, see newer versions)



I am hoping you can include it in all the nice drawing programs out there! :wink:

Update: For a smaller mouse driver with pointer that runs on an unexpanded Vic-20 look in this tread. For convinience I also post the .prg here (see tread for sourcecode):

VICE version (Unexpanded/3k Vic-20) - use Alt+Q to enable paddle input

Updated: Vic-20 with NEOS mouse (Unexpanded Vic-20) - Also runs on VICE version 2.4.23 or later (a bug may end in swapped axes in VICE).


Edit: For a cut-down version which only shows coordinates (from post on page 2):

Update: fixed this so it works without pin4 (sorry about that):

Here is a bare version of the NEOS mouse driver which shows x-coordinate and y-coordinate on screen, but no pointer/gfx. Its 360 bytes (from 7320). Source code is here. It also shifts basic memory end to 7368, leaving you with 3272 bytes free basic mem..
Last edited by Kakemoms on Fri Dec 04, 2015 12:24 pm, edited 9 times in total.

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Re: Vic-20 mouse pointer demo for NEOS mouse

Postby Kakemoms » Thu Oct 01, 2015 3:00 pm

Edited: 19-Oct-2015, 2-Nov-2015

NEW VERSION UPLOADED 2-Nov-2015. Tested and debugged on a real Vic-20: NM.PRG

To do anything useful you need a 8K+ expansion for this.

I added a "menu" line at the bottom (for demonstration). You can leftclick at "LIST" and it will list the current program. "LOAD" will load the directory of device 8 and list it (I found the bug and removed it, so its working now).

I also fixed the mouse characters so that they do not get into the command/basic lines that are punched in. Scrolling also works, but there is still a bug if the pointer is left at the bottom line. Will fix that later.

You can run the demo it in the emulator, but the pointer will only travel accross the screen as VICE doesn't emulate any mouse.

There is still an interference with joy3 and keyboard between NEOS mouse and the Vic-20. This demo does not use the joy3 connection, so you can open your mouse and detach it to get the "2" and "4" keys back. I may put in a workaround later (e.g mapping "2" and "4" to function keys) if I can't find another solution. In some instances I can get the "2" key to work, but its not stable.

Update: The get both full keyboard and mouse working, I bougth a joystick extension lead on ebay and broke off pin4.
Last edited by Kakemoms on Tue Nov 10, 2015 5:21 am, edited 3 times in total.

User avatar
pixel
Vic 20 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby pixel » Sat Oct 03, 2015 6:48 pm

Groovy. Makes me dream of a VIC GUI.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
tokra
Vic 20 Nerd
Posts: 814
Joined: Tue Apr 27, 2010 5:32 pm
Location: Germany

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby tokra » Sun Oct 04, 2015 12:50 am

Why dream?

viewtopic.php?f=15&t=4140&start=28

viewtopic.php?t=4374

viewtopic.php?f=2&t=4713

Maybe the mouse-driver could be adapted to VIC GUI

User avatar
pixel
Vic 20 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby pixel » Sun Oct 04, 2015 5:18 am

tokra wrote:Why dream?

Äck! :shock:
Now I'm dreaming of more open–source stuff for the VIC. So much cool stuff gets forgotten too easily or cannot be reused. Sad.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Kakemoms » Thu Oct 08, 2015 1:59 pm

pixel wrote:
tokra wrote:Why dream?

Äck! :shock:
Now I'm dreaming of more open–source stuff for the VIC. So much cool stuff gets forgotten too easily or cannot be reused. Sad.


Open source is really not the issue. Open interface is what is needed. The real problem with all extensions out there is that they are more or less working as stand-alone-programs and fail to give any protocol on which to communicate or interact with them.

I was hoping to do something about that, but it takes a lot of time to get gfx streamlined with the kernal. Plus, it would be nice to have a STANDARD protocol to which all extensions/utilities/drivers could use to work together. So maybe we ought to start by writing a library for the kernal. Maybe it has already been done, who knows?

User avatar
pixel
Vic 20 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby pixel » Thu Oct 08, 2015 6:35 pm

Open source is not the problem? The last time stamp reads 2010. You can't have a standard protocol without a bunch of people learning from each other's mistakes (EDIT: across all levels).
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Kakemoms » Fri Oct 09, 2015 12:54 pm

pixel wrote:Open source is not the problem? The last time stamp reads 2010. You can't have a standard protocol without a bunch of people learning from each other's mistakes (EDIT: across all levels).


Well, its assembly.. you can always disassemble it if you just want to modify his code. Try Ida.

Anyway, let my give an example:
-> kernal.library is an array of function calls:

word target = address in which function resides
byte noparm = parameters expected:
bit0= pass A
bit1= pass X
bit2= pass Y
bit3= pass Stack pointer
bit4-7= pass Stack (0-15 bytes)
E.g. each library function has 3 bytes.

A function call to library is like this:

Optional:
PHA stack bytes (0-15)
PHA stack pointer
PHA Y
PHA X
PHA A
Required:
PHA noparm
PHA function (0-255, library function number)
JSR library-start-address
Optional:
PLA stack bytes (0-15)
PLA stack pointer
PLA Y
PLA X
PLA A

The actual library calling is done by the library-code which is the "main" library handler (e.g. the only kernal addon). It takes the stack parameters and put them were they are expected, then pushes them back to the stack.

And so on..
------------------------------

So why all this fuzz to call the kernal? The answer is code interfacing! If you have an kernal extension/replacement and simply put in a new kernal.library, the program will still work with the new kernal extension! Not only basic but all assembly that uses libraries for function calls. So a first interpretation would probably be to make the "libraritize" program in which older programs can be forced to use the libraries. Not easy, but possible. Then you can start building a ecosystem on that.

For example: You have a GUI in which you use joystick for mouse movement. You utilize joyport.library to read a joystick-mouse. Now, a new mouse comes along and they all want it to work, so it simply replaces the joyport.library and magically the old GUI works with the new mouse.
Last edited by Kakemoms on Sun Nov 01, 2015 11:17 am, edited 1 time in total.

User avatar
pixel
Vic 20 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby pixel » Sat Oct 10, 2015 5:51 am

Kakemoms wrote:Well, its assembly.. you can always disassemble it if you just want to modify his code. Try Ida.

If this is assembly I'm gonna eat a broom and put a video of it on youtube. :mrgreen:
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
Mike
Herr VC
Posts: 3001
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Mike » Sat Oct 10, 2015 6:33 am

My programs on the VIC-20 work fine without that abstraction level bullshit.

User avatar
pixel
Vic 20 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby pixel » Sat Oct 10, 2015 7:35 am

Mike wrote:My programs on the VIC-20 work fine without that abstraction level bullshit.

D…dude… -=+< friendly >+=- computer. With sugar on top. *dug* :)

Interesting idea but my musings were merely philosophical.

At least things happen here constantly…
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
Mike
Herr VC
Posts: 3001
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Mike » Sat Oct 10, 2015 7:48 am

@pixel: PM sent

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Kakemoms » Sun Oct 11, 2015 8:56 am

pixel wrote:
Kakemoms wrote:Well, its assembly.. you can always disassemble it if you just want to modify his code. Try Ida.

If this is assembly I'm gonna eat a broom and put a video of it on youtube. :mrgreen:


Well, I wouldn't trust you gfx magicians on it being real, but it would be an interesting video.

User avatar
Kakemoms
Vic 20 Afficionado
Posts: 483
Joined: Sun Feb 15, 2015 8:45 am

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Kakemoms » Sun Oct 11, 2015 9:03 am

Mike wrote:My programs on the VIC-20 work fine without that abstraction level bullshit.


Well, I would rather call it an unabstraction level to make a code interface standarized in a library. It would allow more people to understand and use the code as well.

Kananga
Vic 20 Afficionado
Posts: 317
Joined: Mon Mar 08, 2010 2:11 pm

Re: Vic-20 mouse driver & demo program for NEOS mouse

Postby Kananga » Sun Oct 18, 2015 12:52 pm

Kakemoms wrote:
pixel wrote:Open source is not the problem? The last time stamp reads 2010. You can't have a standard protocol without a bunch of people learning from each other's mistakes (EDIT: across all levels).


Well, its assembly.. you can always disassemble it if you just want to modify his code. Try Ida.


You don't have to disassemble, just grab the code here and feel free to improve it: http://sourceforge.net/projects/vin20/
(Included is a preview of a dynamic loader called "LibTool65" and tools for the FE3)

As for the standard protocol:

The GUI is a prototype and just meant to demonstrate the possibility of having a GUI on the VIC 20 at all.
I personally use the diskmenu.prg every time I start my VIC-20 and it does all I need, so I never had the urge to add features.

For a real GUI you need a loader that is able to load drivers for your hardware and dynamically load and remove user programs. Having it all compiled into one big program would eat up too much of the precious memory.
And, of course, an interface or protocol to access the kernel functions.

Unfortunately, I did not have the time to program all that, yet.
Buy the new Bug-Wizard, the first 100 bugs are free!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 3 guests