Jump to content
IGNORED

DLI and PROCEED interrupts, handling nested?


Recommended Posts

The 2-bit Gray code is also called "quadrature" encoding, because the two bits are 90° out of phase. The two bits are often called A and B.

 

One trick is to wire A to an edge-triggered interrupt. The interrupt routine would simply INC position if B is high or DEC position if B is low. Simple, but you get less position resolution that way.

  • Like 1
Link to comment
Share on other sites

If you (or @tschak909) want to get into the guts of Trak-Ball stuff, Dan Kramer is very active on Facebook and one of the Admins of Trak-Ball fan group as well. For those who don’t know, Dan was the designer of the CX-22 (and the CX-53 Trak-Ball for the 5200) as well. When my 5200 Trak-Ball arrived from eBay DOA, Dan walked me through the schematics and his first suggestion brought it back to life with a single 45 cent IC. :)

  • Like 3
Link to comment
Share on other sites

  • 1 year later...
On 6/24/2020 at 7:04 AM, ClausB said:

 

One trick is to wire A to an edge-triggered interrupt. The interrupt routine would simply INC position if B is high or DEC position if B is low. Simple, but you get less position resolution that way.

I was trying to understand the Missile Command code that manages the Trackball/St Mouse, as it compatible with both true TB mouse and Atari ST.

The code is very simple and it is similar to what @ClausB has written: detecting the edges and decide direction using only one bit:

    LDA $D300    ;PORTA
    TAX         ;SAVE for later
    EOR TBOLD   ;DETECT RISING...
    AND TBOLD   ;...EDGES OF PORTA
    STX TBOLD   ;SAVE FOR NEXT PASS
    LSR
    LSR
    BCC MOUSE.NOMOVE ;NO RISING EDGE BIT1 SO EXIT
    TXA        ;SO BIT1 MOVED FROM 0->1...
    LSR        ;.. REPEAT AND CHECK BIT0
    BCC MOUSE.MINUS  ;NO RISING EDGE BIT0 SO MOVE RIGHT
MOUSE.PLUS             
    ;do something....mouse/tb one direction
MOUSE.NOMOVE
	;do your pla, rti, etc
MOUSE.MINUS
	;do something....mouse/tb the other direction

The interesting thing about this code is that it is super short and also compatible with both devices as I already said. In missile command is used every 3 or so DLIs with excellent results. In my case, I am using it in all DL lines ($84, in every line of Antic 4).

The code linked by @Mathy looks to me that works better in terms of not need to be called that frequently (not really sure, yet), and it makes more logical sense but it only works for st mouse. This was my take on that code:

;                    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15
TABLA.MOUSE .BYTE    0, 255,   1,   0,   1,   0,   0, 255, 255,   0,   0,   1,   0,   1, 255,   0    
LDA $D300	;PORTA
    AND #$03    ;KEEP LEFT&RIGHT BITS
    TAY	        ;save for later
    ORA TBOLD   ;put new and old bits together side by side (32|10 = OLD|NEW)
    TAX         ;This is my index for the table
    TYA         ;back to bits left&right
    ASL         ;move them to the right
    ASL
    STA TBOLD   ;save them for next pass
    LDA TABLA.MOUSE,X
    BMI MOUSE.MINUS  ;1st- check if minus
    BEQ MOUSE.NOMOVE ;2nd- Check if zero
;3rd, it is not zero (nor negative) so MOUSE.PLUS

In conclusion, it seems that the code in Missile Command works with ST Mouse by pure luck , but I might be totally wrong...

 

 

 

  • Like 2
Link to comment
Share on other sites

Those devices both work the same - 2 bits per axis on the joystick representing each axis with a grey code.

The ST mouse and 7800 sticks are only partly compatible though - the second button goes to a paddle input but it doesn't generate a value.

I'm fairly sure there's a mod around for one or both that involves a resistor change that makes the button detectable but still remains compatible on it's original machine.

The Amiga mouse also works the same but for whatever reason the bit assignment is different so it's not directly compatible.  There were aftermarket mice available for Amiga/ST which had a switch so the proper encoding would be sent to the host.

 

I've not dived into the trakball code in these games but it's fairly likely it's only doing one sample per frame.  For more precision you'd want multiple samples.

IMO probably the best method would be to do the sampling multiple times during the screen draw then combine and process them during VBlank.

Edited by Rybags
Link to comment
Share on other sites

Yep, bit 0 and 3 reversed. So interchanging pin 1 and 4 transform an Amiga mouse to Atari. 

However, I was trying to point out how the routine used in Missile Command works with TBs and mice, two different devices, essentially the same, but with differences in the Atari implementation. 

Trak-ball and ST mouse are similar but they don't work exactly the same. Trak-ball add some flip flops, while ST mouse does not. 

The second code posted does not work with CX-22 nor with CX-80.

I will keep doing experiments. I am trying to add TB/mouse/driving controller support to and old pong/breakout clone. 

Edit: BTW, thanks Mathy for the code in your webpage. It was very very good information, and I also allowed me to discover Mega Magazine... nice set of articles...

 

 

Edited by manterola
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...