Vic-20 mouse driver & demo program for NEOS mouse

Basic and Machine Language

Moderator: Moderators

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

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

Postby Kakemoms » Sat Dec 05, 2015 11:42 am

blackystardust wrote:Thank you for investigating and timing results, thanks to you the neos mouse emulation in vice should now be working as it should.


My pleasure. Its really nice to know I have done something new on a Vic-20 after 34 years in existence! With xvic supporting NEOS I will try to make a game.

By the way, do you have any links for drivers of the other mouse options in xvic? I see the 1351 there, but will it work on the vic-20? (I bought one a month ago, so it would be nice if there was a way).

blackystardust
Vic 20 Newbie
Posts: 12
Joined: Sat Jan 14, 2006 6:31 pm

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

Postby blackystardust » Sat Dec 05, 2015 12:54 pm

No drivers afaik.

I used the criterion of having a potentiometer for any device that uses those lines to show up on those emus, and having a light pen pin/counter for light pens to show up.

So whether they actually work is upto the programmer/experimenter ;)

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

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

Postby Kakemoms » Mon Dec 28, 2015 9:02 am

Here is a couple of pictures for the extension cable modification. E.g. you simply buy an Amiga/Atari joystick extension cable and break off pin4 on the male connector. It leaves the NEOS mouse intact:
Attachments
NEOS-cable.jpg
NEOS-cable2.jpg

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Fri Apr 28, 2017 8:47 am

necroing this thread - i am interested in the test program(s) from the first post - but the links are dead.... could anyone repost them, please?

polluks
Vic 20 Newbie
Posts: 9
Joined: Sat Apr 29, 2017 4:53 pm
Website: http://www.bilskaja.de
Location: Germany
Occupation: FI

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

Postby polluks » Sat Apr 29, 2017 5:21 pm

VC20 [WGA103574] + UltiMem

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Sat Apr 29, 2017 6:45 pm

that looks good, thx :)

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Fri May 05, 2017 2:24 pm

mmmh so, i played around with this.... i can make the regular version work, but it blocks (some of) the keyboard. i tried to fix it with ignoring joy3 bit - but somehow didnt manage to patch this driver to work properly without it.... could someone provide working code for that, please?

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

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

Postby Kakemoms » Mon May 08, 2017 6:35 am

Oh sorry about that! I have them all on onedrive, but MS is corrupting all the links after a while. Here is the code for the mousepointer with text output:

Code: Select all

; Mouse driver for unexpanded Vic-20

; 10 SYS7329

*=$1001

        BYTE    $0B, $10, $0A, $00, $9E, $37, $33, $32, $30, $00, $11, $10, $14, $00, $A2, $00, $00, $00



*=$1C98

mouseinit
; For unexpanded Vic-20: Only shows position of mouse on screen, no gfx

        lda     #$1C
        sta     $38     ;basic ends here!
        lda     #$c8
        sta     $37     ;basic ends here!


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

        lda #$56     ;length of timer low & high byte

        sta $9116     ; load the timer 1 low byte
        sta $9126     ; load the timer low byte counter


        sta $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

$E404

mouseirq

mousestart                      ;Routine to read NEOS mouse data

;        LDA     $9111
;        AND     #16     ;=#32 for NEOS or #16 in VICE
;        CMP     #0
;        BNE     nofire
        ; fire pressed! So do something here.
;        LDA     $CE          ; get character under cursor
;        LDX     $0287                ; get colour under cursor
;        LDY     #$00                    ; clear Y
;        STY     $CF          ; clear cursor blink phase
;        JSR     $EAA1   ; Write character A
;        LDY     xval8
;        LDX     yval8
;        JSR     $E50C   ; Set new cursor positions
nofire

        LDA     $9111
        PHA
        LDA     $9113
        PHA

        LDA     #$FF
        STA     $96

        LDA     $9113           ; Set direction
        AND     #%11000000      ; Bit 5 output
        ORA     #%00100000      ; Bit 5 output
        STA     $9113           ; Set direction
        LDX     #17

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     #0 ;#$80    ; S3  #0 without pin4
        STA     $3
        LDA     $9111
        AND     #%00011100      ; S2, S1, S0
        ASL
        ASL
        ORA     $3      ; Add bit 7
        STA     $3

        LDX     #$FF
        STX     $9122   ; Set VIA2 to listen for keyboard again

        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     #0 ;#$80    ; S3  #0 without pin4
        LSR
        LSR
        LSR
        LSR
        ORA     $3
        STA     $3
        LDA     $9111
        AND     #%00011100      ; S2, S1, S0
        LSR
        LSR
        ORA     $3      ; Add other bits
;        STA     $3
; set negative bit without joy3 signal:
        asl
        clc
        bpl     *+5
        sec                ;compensate for missing bit7
        ora     #%00010000 ;compensate for missing bit3
        ror
        sta     $3
        LDX     #$FF
        STX     $9122   ; Set VIA2 to listen for keyboard again



        INC     $96
        BNE     mousecalc
        STA     $4      ;x-value here
        LDX     #5
        JSR     waitsome
        LDX     #5
        JMP     mouseloop
mousecalc               ; use delta values to calculate new postitions
        PLA
        STA     $9113
        PLA
        STA     $9111


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

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

        ; For debug in VICE:
;        lda     #$ff
;        sec
;        sbc     $9008
;        sta     xval
;        lda     $9009

;        sta     yval

mouseprint              ;Routine to put mouse x&y on screen

        LDA     $5
        STA     sval
        LDA     #0
        STA     star
        LDA     #24     ;"X"
        JSR     showvalue
        LDA     $6
        STA     sval
        LDA     #6
        STA     star
        LDA     #25     ;"Y"
        JSR     showvalue


        JMP     $eabf     ; return to normal IRQ

waitsome

        DEX
        BNE     waitsome
        RTS

showvalue               ; shows an integer value
        LDX     star
        STA     $1E00,X
        LDA     #"="
        STA     $1E01,X

        LDA     sval
        JSR     div10
        TAY
        JSR     div10
        TAX
        JSR     mult10
        STA     $3
        TYA
        SEC
        SBC     $3      ; tenths
        CLC
        ADC     #48
        STA     $96      ;temp storage
        TXA
        ADC     #48
        LDX     star
        STA     $1E02,X   ; hundreds
        LDA     $96
        STA     $1E03,X   ; hundreds
        TYA     
        JSR     mult10
        STA     $3
        LDA     sval
        SEC
        SBC     $3
        CLC
        ADC     #48
        LDX     star
        STA     $1E04,X   ; 0-9
        LDA     #2
        STA     $9600,X
        STA     $9601,X
        STA     $9602,X
        STA     $9603,X
        STA     $9604,X
        RTS

sval    byte 0
star    byte 0

div10
        lsr
        sta  $4 ;1/2
        lsr
        adc  $4 ;1/4+1/2=3/4
        ror
        lsr
        lsr
        adc  $4 ;3/32+16/32=19/32
        ror
        adc  $4 ;19/64+32/64=51/64
        ror
        lsr
        lsr     ;51/512
        rts

mult10  ; 2+8
        asl
        sta     $4
        asl
        asl
        clc
        adc     $4
        rts

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Mon May 08, 2017 7:59 pm

soooo :)

i have merged the various sources/programs into one demo/test program, see here. its not perfect though:
- it no more works alongside of basic, i didnt bother to fix that (its good enough for testing and showing how it works as it is)
- the NTSC timing is broken, i didnt bother to fix that either

however, it now can conditionally be assembled for expanded and unexpanded VIC20, and is prepared for PAL/NTSC. i have also put back (also conditionally) the code that uses joy3.

also, i noticed that the original code checks bit4 of $9111 (joy2) for the mouse button status - does that actually work? that totally contradicts everything i learned so far on the NEOS mouse :) i changed that to use POTX instead, which equals the right mouse button on NEOS - and which also is the only button used in the original "mouse cheese" program (see the "readmouse" function in this program, which is ripped from that mouse cheese paint program), and the only one mentioned in the NEOS manual

does someone with a NEOS mouse here also have a C64? if the left button can really be checked like this, we should perhaps also emulate that correctly (and put it into the test programs) :)

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Thu May 11, 2017 5:25 pm

noone? :)

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

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

Postby Kakemoms » Fri May 12, 2017 5:27 am

Ah, well I have a C64 somewere but I really only use my 5 Vic-20's. And rarely my A1200..

Anyway, the code was constructed from the original source for NEOS Mouse & Cheese that was for the C64. I have to search to find that disassembly. But the left mouse button at least worked fine with my original demo (in which you could move the cursor position around by clicking the left mouse button).

I will post it here if I find it (the disassembly).

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Fri May 12, 2017 8:44 am

uhm. but the mouse cheese program does not use the left button at all? *shrug* are they different versions perhaps? mmmh

User avatar
pixel
Vic 20 Nerd
Posts: 867
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 May 13, 2017 2:00 am

Github to the rescue! Will try to make this work for that ball game. Found a GEOS and a 1351 mouse.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

groepaz
Vic 20 Nerd
Posts: 548
Joined: Wed Aug 25, 2010 5:30 pm

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

Postby groepaz » Sat May 13, 2017 8:50 am

1351 wont work on vic20 :/

Kakemoms: if you dont find that disassembly - even knowing what version of mouse cheese you disassembled would help (easy enough to find the mouse stuff ...)

User avatar
pixel
Vic 20 Nerd
Posts: 867
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 May 13, 2017 4:45 pm

groepaz wrote:1351 wont work on vic20 :/

Good to know! Went over that handlebar once too often. ;)
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest