Best mouse for Vic-20

Modding and Technical Issues

Moderator: Moderators

Post Reply
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Best mouse for Vic-20

Post by Kakemoms »

You heard right. What is the best mouse for the Vic-20?

As I understand it, the 1350 is a joystick-mode mouse. The 1351 is more paddle-like and gives you a position using two potmeters which is digitized through the paddle inputs. A third option is the Neos mouse which works more like the 1351 but with some work going on inside it to give relative positions to the machine (http://www.c64-wiki.com/index.php/NEOS_Mouse).

Any incompability issues between c64 and vic-20 joystick ports?
User avatar
orion70
VICtalian
Posts: 4343
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: Best mouse for Vic-20

Post by orion70 »

Working on a GEOS for VIC? :P
(if so, I promptly withdraw my tongue)
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

orion70 wrote:Working on a GEOS for VIC? :P
(if so, I promptly withdraw my tongue)
Well, I have the gfx mode, screen scroll, clear and print routines working on a 200x176 bitmap. Its still not fully kernal transparent but I hope it gets there.

Anyway I thought that adding a mouse pointer was rather interesting, so we'll see were it goes. I bought a Neos mouse which will require some reverse engineering to get working...
User avatar
tokra
Vic 20 Scientist
Posts: 1129
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: Best mouse for Vic-20

Post by tokra »

The 1351 mouse does not work on the VIC-20. This has been tested before. However, further down the thread there is a prototype for an Amiga-mouse-driver. I have tested this successfully on my PAL VIC-20.
User avatar
orion70
VICtalian
Posts: 4343
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: Best mouse for Vic-20

Post by orion70 »

Kakemoms wrote:Well, I have the gfx mode, screen scroll, clear and print routines working on a 200x176 bitmap. Its still not fully kernal transparent but I hope it gets there.
Woops, tongue back in cheeck then :). Always dreamed of a graphic environment for the VIC, ever since Mike and I were playing with the idea of a "VIC desktop".
Windows-based OS then? Or something more similar to a collection of utilities, tied together via point-and-click graphics (à la Magic Desk, like in our draft)?
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

tokra wrote:The 1351 mouse does not work on the VIC-20. This has been tested before. However, further down the thread there is a prototype for an Amiga-mouse-driver. I have tested this successfully on my PAL VIC-20.
Yea I was afraid of this. I just read your link's links and it seems like there is some issue with the POTX&Y vs SID internal clock with the analog mode of 1351. Fortunately the NEOS mouse has been reported to work with the Vic-20 http://www.softwolves.com/arkiv/cbm-hac ... 14030.html so I have something to play with there..
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

orion70 wrote:
Kakemoms wrote:Well, I have the gfx mode, screen scroll, clear and print routines working on a 200x176 bitmap. Its still not fully kernal transparent but I hope it gets there.
Woops, tongue back in cheeck then :). Always dreamed of a graphic environment for the VIC, ever since Mike and I were playing with the idea of a "VIC desktop".
Windows-based OS then? Or something more similar to a collection of utilities, tied together via point-and-click graphics (à la Magic Desk, like in our draft)?
The current idea is to make it invisible to basic so that all commands work as usual. E.g. it simply hijacks the screen&character in/out routines of the kernal and replaces them. In that way you will simply see a screen with 33 columns of 6-bit wide characters and 22 lines. So you would have somewhat backward compability with basic programs.

There is no reason it can't be implemented as "windows" on a screen, but the limited memory will not allow for too much overlay. Maybe a non-background saving version will be first if I go there. Time will show.
TNT
Vic 20 Hobbyist
Posts: 121
Joined: Wed Apr 29, 2009 5:46 am

Re: Best mouse for Vic-20

Post by TNT »

You can also use PS/2 mouse with an adapter. Here is my driver for C64 + user port, but it can easily be changed to use any I/O pins. It supports mouse wheel and up to five buttons.
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

TNT wrote:You can also use PS/2 mouse with an adapter. Here is my driver for C64 + user port, but it can easily be changed to use any I/O pins. It supports mouse wheel and up to five buttons.
Yea, I thought about using an adapter and I want to try this:

http://www.lemon64.com/forum/viewtopic. ... 51c8865ad3

I have some arduino boards laying around so once I get the time I will try to implement an interface to Vic. Maybe it works out of the box, but probably not. I am playing with the idea of putting a nano into an Amiga mouse (e.g. 1352 which is much more common). Might be fun.

The "Nice text" code is 95% finished in a beta form so I can use it for writing basic programs in 33 columns. There are a few bugs, so it will take a little more time until I dump it here. Graphically it uses ROM characters (compressed into 6 bits) and I only changed the cursor that now shows like a box.

First version will be text only and without mouse support, but bear with me.. before my kids learn assembler I can't do it faster. :lol:
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

Well, I bought a NEOS mouse cheese and plugged it into the Vic-20 which is responding... (some deleted text)

Edit: I found a disassembly at http://www.ntrautanen.fi/computers/commodore/cheese.htm (in finnish though)
I can confirm that the same code is within Cheese paint, but shifted so that it resides from $3c00. I can also confirm that the NEOS mouse emulation in VICE is broken.

Edit2:
Here is current code for the Vic-20 AND IT WORKS! :D :D :D

Edit3:
The code now shows both x-position and y-position of a "pointer". They move quite smooth and accurate with the NEOS mouse and are very fast. This small demo does not contain any gfx, so it is intended only for someone wanting to test the NEOS mouse on a Vic-20 (and include the code in their program).

Edit4: Fixed two bugs

Happy coding!

Code: Select all

; Mouse driver

*=9999

        JMP     mouseinit

mouseirq
        LDA     $9111
        PHA
        LDA     $9113
        PHA



        LDA     #0
        STA     $3
        STA     $4
        STA     $0

        LDA     $9113
        AND     #%11000000	 ;Retain bit 6&7
        ORA	   #%00100000      ; Bit 5 output
        STA     $9113           ; Set direction
        LDX     #8

mouseloop

        LDA     $9111
        AND     #%11011111      ; Clear bit 5
        STA     $9111           ; Trigger NEOS mouse
        JSR     waitsome

        LDX     #$7F
        STX     $9122   ; Set VIA2 to listen for joystickport
        LDA     $9120
        AND     #$80    ; S3
        LDX     #$FF
        STX     $9122   ; Set VIA2 to listen for keyboard again
        STA     $3
        LDA     $9111
        AND     #%00011100      ; S2, S1, S0
        ASL
        ASL
        ORA     $3      ; Add bit 7
        STA     $3

        LDA     $9111
        ORA     #%00100000      ; set bit 5
        STA     $9111           ; Trigger NEOS mouse
        LDX     #5
        JSR     waitsome

        LDX     #$7F
        STX     $9122   ; Set VIA2 to listen for joystickport
        LDA     $9120
        AND     #$80    ; S3
        LDX     #$FF
        STX     $9122   ; Set VIA2 to listen for keyboard again
        LSR
        LSR
        LSR
        LSR
        ORA     $3
        STA     $3
        LDA     $9111
        AND     #%00011100      ; S2, S1, S0
        LSR
        LSR
        ORA     $3      ; Add other bits
        STA     $3
        LDX     $0
        CPX     #0
        BNE     mousecalc
        INC     $0
        STA     $4      ;x-value here
        LDX     #5
        JMP     mouseloop
mousecalc               ; use delta values to calculate new postitions
        PLA
        STA     $9113
        PLA
        STA     $9111


        sec
        lda     xval    ;low byte
        sbc     $4      ;add delta x (signed)
        sta     xval

        sec
        lda     yval    ;low byte
        sbc     $3      ;add delta x (signed)
        sta     yval
        

mouseprint
        LDA     xval
        STA     sval
        LDA     #0
        STA     star
        LDA     #24     ;"X"
        JSR     showvalue
        LDA     yval
        STA     sval
        LDA     #6
        STA     star
        LDA     #25     ;"Y"
        JSR     showvalue

mouseirqend

        JMP     $eabf     ; return to normal IRQ

xval    word 0
yval    word 0


waitsome
        NOP
        NOP
        NOP
        DEX
        BNE     waitsome
        RTS

showvalue               ; shows an integer value
        LDX     star
        STA     $1000,X
        LDA     #"="
        STA     $1001,X

        LDA     sval
        JSR     div10
        TAY
        JSR     div10
        TAX
        JSR     mult10
        STA     $6
        TYA
        SEC
        SBC     $6      ; tenths
        CLC
        ADC     #48
        STA     $0      ;temp storage
        TXA
        ADC     #48
        LDX     star
        STA     $1002,X   ; hundreds
        LDA     $0
        STA     $1003,X   ; hundreds
        TYA     
        JSR     mult10
        STA     $6
        LDA     sval
        SEC
        SBC     $6
        CLC
        ADC     #48
        LDX     star
        STA     $1004,X   ; 0-9
        LDA     #2
        STA     $9400,X
        STA     $9401,X
        STA     $9402,X
        STA     $9403,X
        STA     $9404,X
        RTS

sval    byte 0
star    byte 0

div10
        lsr
        sta  $5
        lsr
        adc  $5
        ror
        lsr
        lsr
        adc  $5
        ror
        adc  $5
        ror
        lsr
        lsr
        rts

mult10
        asl
        sta     $5
        asl
        asl
        clc
        adc     $5
        rts


mouseinit
        lda #$7f
        sta $912e     ; disable and acknowledge interrupts
        sta $912d
sync                  ;synchronize with the screen
        ldx #28       ; wait for this raster line (times 2)
resync
        cpx $9004
        bne resync

timers
        lda #$40      ; enable Timer A free run of both VIAs
        sta $911b
        sta $912b

        lda timerv      ;length of timer low byte
        ldx timerv+1    ; length of timer high byte
        sta $9116     ; load the timer 1 low byte
        sta $9126     ; load the timer low byte counter

        stx $9125     ; start the IRQ timer A (high byte latch)
        ldy #10       ; spend some time
        dey           ; before starting the reference timer
        bne *-1
        stx $9115     ; start the reference timer

pointers
        lda #<mouseirq     ; set the raster IRQ routine pointer
        sta $314
        lda #>mouseirq
        sta $315
        lda #$c0
        sta $912e     ; enable Timer A underflow interrupts
        rts           ; return

timerv word 21849       ;once per screen update

The code was tested on a Vic-20 with 24K+ RAM and NEOS mouse. It reads delta-x and delta-y from the mouse using 3 bits of the joyport by VIA1 and 1 bit of the joyport by VIA2. Each 4 bits (halfbyte) is triggered using fire/lightpen output by VIA1.

For some reason the key "2" stops working and the key "4" only displays "$" after the NEOS mouse start sending data (this state can be triggered by simply pressing the mouse button, no program needed!). It may be my Vic-20, it may be the mouse or it could be a general incompability issue. I need to look more into this to see if there is a fix. All other keys seems to work as normal.
Last edited by Kakemoms on Wed Nov 04, 2015 10:57 am, edited 1 time in total.
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

Just to update a little: In the program section you can find a short program that shows a mouse pointer on a vic-20 using the NEOS mouse. I will keep updating the demo and put any updates there.

A strange behavious of the NEOS mouse has been that the "2" key stops working and the "4" key starts showin "$" or other random characters once you press the NEOS mouse button. I had to test this on another Vic-20 and can confirm that this happends on all Vic-20 machines WITH memory expansion.

Now, I have a 16K RAM expansion that is actually a 24K or 32K expansion, so it may be connected to this particular expansion. Anyway, it is reproducible and a (short-term) solution was to simply remove the memory expansion. Since my graphical Vic-20 environment needs 16K+ expansion I will need to test this further to find a solution. I also tested two power supplies (both C briks), so I don't think its a unstability in the power. The VIC chips also work as they should.

If anyone has seen this behaviour with joysticks/lightpens on a vic-20, I would like to know.

And just for the fun of it: My Vic-20 connected to a new LG UltraHDTV :wink:
Kakemoms
Vic 20 Nerd
Posts: 740
Joined: Sun Feb 15, 2015 8:45 am

Re: Best mouse for Vic-20

Post by Kakemoms »

I have tested the mouse with Darktronic 3-32K expansion and somehow I have tricked myself. The NEOS mouse interference is connected to how the NEOS keeps sending data after it has been triggered. On Vic-20 the pin4 (joy left) of the control port is connected to the same pin as keyboard column7. As it is impossible to switch off the output of the mouse once it has been triggered (or so it seems), so column7 data gets confused as the NEOS mouse continually modifies bit7 of $9120. A quickfix may be to cut the wire which goes to pin4 of the controlport (in the mouse) and modify drivers.

Edit: the non-working load command was a bug. E.g. I modified bit7&6 of $9113 during the interrupt. Just retain the bitvalues and you are fine.

Update: Comparing schematics between C64 (for which the NEOS was designed) and Vic-20, the C-64 lines (joy0-3) are ALL connected to different keyboard input lines. So why do we not see NEOS-keyboard interference on the C64? Very strange indeed.

Update2: Instead of cutting wires in your NEOS mouse, I used this joystick extension lead and broke off pin4. A longer mouse lead is added bonus.
Post Reply