A2USB: Apple II Mouse Interface Card & USB Support

36 posts / 0 new
Last post
MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
A2USB: Apple II Mouse Interface Card & USB Support

I wrote a blog article on a new firmware project: A2USB. Adds USB support to the well-known A2VGA boards and emulates an Apple II Mouse Interface Card - connecting a standard USB mouse.

Currently requires a bit of tinkering - as described in the blog. Already works really well, but still needs testing on more and other machines.

Creating this forum topic for possible discussions - in case someone wanted to give this a try...

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
I'm definitely going to try

I'm definitely going to try it...  I found I have a Miceo USB to USB-A adapter, but alas 2N7000 MOSFET trassistor I do not have in stock.  I will also have to search for a wired USB mouse, as I mostly only use wireless ones these days.  But I know I have at least one or two old wired ones around here somewhere.

 

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
Wireless

A simple transistor instead of the MOSFET would also work, like a standard BC548 or BC238...

Good point with the wireless mouse. I hadn't tested that yet. If you have a wireless mouse with a USB receiver, than these also work. Just plug the receiver into the adapter cable. I tested my Logitech wireless mouse, and its USB receiver just acts as a standard HID device, no special driver required. Bluetooth mice would probably not work (well, unless their receiver modules were too smart and could also act as HID devices).

Unfortunately USB HUBs don't work yet. Hopefully this can be added at some point. I'm looking forward to connect the Apple II to my desktop switch, so I can switch my desktop mouse between work, home and Apple II... :)

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
Awesome! Can't wait to try it

Awesome! Can't wait to try it!

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
I'll have to look and see if

I'll have to look and see if I have a BC548 or BC238.  I do have wireless mice with a USB receiver.  In a way that might actually make it simpler since there would be no cable that would need to go outside the Apple II.

 

Anyway, I already orderd some 2N7000 and a couple more Micro USB->USB-A adapters.

 

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
Alas I just looked at my

Alas I just looked at my parts stash and I don't have any BC548 or BC238 either. I guess I will have to wait until the batch of 2N7000 I ordered show up which is supposed to be Thursday.

 

 

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
I couldn't wait so I tried

I couldn't wait so I tried doing the mod with a 2N3904...  And...  It works!

 

 

The first wireless USB mouse I tried was a cheap generic one...  that for whatever reason did not work.  However it did work with a Logitech.

 

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
softwarejanitor wrote:I
softwarejanitor wrote:

I couldn't wait so I tried doing the mod with a 2N3904...  And...  It works!

 

Hahaha, excellent, I like that spirit. "When you can't wait till Thursday...". :) *virtualhighfive*

Very good, which machine did you test this with? Apple ][, //e?

Btw, the LED on the PICO briefly flashes whenever the mouse is moved or a button is pressed. And that's completely independent of what the 6502 does. That's a quick way to test if the mouse was detected. And it's ok to plug/unplug the mouse while the machine is on. After all, it's just a normal USB connection, like any other.

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
It might be useful for

It might be useful for someone to create a version of the PCB that deletes the provisions for the VGA connector and the resistors associated with it and integrates the mods for the USB to be active.  That would make the board slightly smaller since those components don't need to ne installed if you are going to use it as a Z80 card or for the A2USB as a mouse card.

 

Another thing is this is making me think of all kinds of other cards that could be emulated...  Like a Super Serial Card that could have super large FIFOs instead of the single byte that the 6551 chip does.

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
MacFly wrote:softwarejanitor
MacFly wrote:
softwarejanitor wrote:

I couldn't wait so I tried doing the mod with a 2N3904...  And...  It works!

 

Hahaha, excellent, I like that spirit. "When you can't wait till Thursday...". :) *virtualhighfive*

Very good, which machine did you test this with? Apple ][, //e?

Btw, the LED on the PICO briefly flashes w

 

 

Test was done on one on one of the many //e units I have.  I have several sitting here that I am planning to list on eBay soon.

 

I can run the test on a couple of ][+ clones I have here if you like.  I have a Pineapple, a Micro II and a another generitc Hong Kong/Taiwan made clone handy plus another couple //e units including a Platinum.

 

The main reason I did the test on a //e is that I wanted to make sure it worked with Dazzle Draw.  I also tested Mousepaint and GEOS.  Those were what I had handy as far as software that uses a Mouse.  I should look up other software and go grab it from Asimov or wheterer and throw it on the SD card I have in my SDiak II or one of the FloppyEmu that I have.

 

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
Anyway, I used a 2N3904

Anyway, I used a 2N3904 because I bought a 100 pack of them recently.  It was like a buck more than 25 from another seller...  I have some others on hand, and I might have tried a 2N2222 but I on;t have a handfun of those...  If the 2N3904 hadn't worked a 2N2222 probably would have been the next one I tried.

 

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
I modified another one of my

I modified another one of my cards into an A2USB. so now I've got two cards working.

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
softwarejanitor wrote:I
softwarejanitor wrote:

I couldn't wait so I tried doing the mod with a 2N3904...  And...  It works!

...

 

Could you try it with your ESP32 SoftCard by running the MOUSE command? I do some crazy stuff in order to make the Apple Mouse II be able to go infinitely far in any direction by continuously resetting its bounds and I am really curious if it works on this as well. I won't be able to try it myself until much later. Thanks!

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
softwarejanitor wrote:I can
softwarejanitor wrote:
I can run the test on a couple of ][+ clones I have here if you like.

 

It would be interesting to know if the card worked in various machines. That was the main point I still worry about. I can test the card's API and with different software. But I can't be sure whether the card now works reliably in any machine, where timing and crystals will slightly vary. And, as I wrote in the blog, initially I was having major reliability issues with the bus interface - though I hadn't even changed anything, so the timing was identical to the original A2VGA firmware. I tweaked it slightly, which completely fixed the issues for me. But it's possible that it needs more tweaking to also work with any other machine.

 

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
CVT wrote:softwarejanitor
CVT wrote:
softwarejanitor wrote:

I couldn't wait so I tried doing the mod with a 2N3904...  And...  It works!

...

 

Could you try it with your ESP32 SoftCard by running the MOUSE command? I do some crazy stuff in order to make the Apple Mouse II be able to go infinitely far in any direction by continuou

 

 

Good idea.  I can do that.  The ESP32 Softcard is installed in a different //e right now but I can put an A2USB card in there and give it a try.

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
MacFly wrote:softwarejanitor
MacFly wrote:
softwarejanitor wrote:
I can run the test on a couple of ][+ clones I have here if you like.

 

It would be interesting to know if the card worked in various machines. That was the main point I still worry about. I can test the card's API and with different software. But I can't be sure whether the card now works reliabl

 

 

I will try it in the clones I have handy here as well as a couple other //e including the one with the ESP32 Softcard as requested by CVT.

 

Probably not until tomorrow or maybe Thursday though, as I have some stuff I need to get done tonight.

 

 

 

Offline
Last seen: 1 month 19 hours ago
Joined: May 2 2013 - 20:14
Posts: 48
Excellent work!
My own Apple II C Plus has a hardware error that permit mouse movement detection in only three directions. It would be really cool to see something like this developed for that machine.
CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
jegs2 wrote: My own Apple II
jegs2 wrote: My own Apple II C Plus has a hardware error that permit mouse movement detection in only three directions. It would be really cool to see something like this developed for that machine.

 

Hmm, I am not sure how it would work on a machine that already has a mouse. Most programs auto-detect the slot of the mouse interface card by the specific signature the firmware returns and I don't know of any that can work with two mice. However if you can somehow disable the onboard mouse interface of the Apple IIc by removing a chip or something, I'm pretty sure it will work.

 

Perhaps one of the things to test is what happen on an Apple II+/IIe when there is already a mouse card. Will it simply go with whichever has the lowest slot number?

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
Where would you put it in a /

Where would you put it in a //c+?  There are no slots.  I think there might be some kind of memory card connector in there but not sure if it has all the needed signal available.  I suppose you'd have to plug into the CPU socket.

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
LOL! That might be a bigger problem
softwarejanitor wrote:

Where would you put it in a //c+?  There are no slots. 

...

 

LOL! That might be a bigger problem indeed!

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
jegs2 wrote:My own Apple II C
jegs2 wrote:
My own Apple II C Plus has a hardware error that permit mouse movement detection in only three directions.

 

Yeah, no expansion slots in the IIc, unfortunately... However, from what you describe, it sounds repairable. You probably already excluded the mouse as the cause. If the IIc itself is broken, then in this case it's almost certainly either just a simple connection issue (the connector or a trace on the motherboard not making proper contact), or otherwise it has to be UF2, SN74LS251.

This IC is a multiplexer and connects the movement direction signals from the mouse port. It's the only element of the mainboard which could affect only one (of the three) directions to fail. Everything that happens after the multiplexer would affect both X and Y directions.

And luckily, that's a standard component. Still made today and cheap. Worth a try.

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
I was going to order this

I was going to order this compact MicroUSB to USB adapter from AliExpress for my Logitech wireless mouse, but I was in a local electronics store today and found a regular version for about a dollar. It's a bit chonky, but it still fits perfectly. So I bridged VBUS to VSYS, flashed the Pico, put the card in my Apple II+ and it worked right away! I didn't even need to add the transistor, because I only wanted to test it on the ESP32 SoftCard, which only does polling and it doesn't need the IRQ.

 

This is such an amazing contribution to the Apple II platform! The original Apple Mouse II + interface card in good condition are not easy to find.

 

Online
Last seen: 1 hour 25 min ago
Joined: Mar 12 2023 - 16:49
Posts: 18
Interrupt generation

Great new take on this card and also a modern interpretation of the mouse card. Thank you for your efforts.

I am following this project with great interest, having previously thought about how to put a modern take on the mouse card.

You have previously said that you have the BASIC mode operation running and that you are looking at the interrupt mode used by other software.

It all comes down to knowing when Vertical Blanking  on any slot other than 7 is active.

As I do not own an orignal mouse card or even the the new card yet, all my assumptions come from reading documentation.

From the documentation I have read on this subject, the famous Vapour Lock code was used to activate the vertiacl blanking time slot on the Apple mouse card, which in turn allowed the mouse card a safe time slot to transferr bytes to the Apple memory.

Does this new A2USB card need to use the Vapour Lock code? 

Regards Crusty

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
It can do the simple polling

It can do the simple polling w/o the hardware mod.  The mod to the card facilitaties the interrupt code.  That has already been implemented. It has already been tested with code that uses the inettupt modes.  I've personally tested it with things like Dazzle Draw and GEOS.  I have also tested it with MousePaint, but I think that only needs polling.

 

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
Vertical Blanking

Yes, interrupts are working with the A2USB - if the A2VGA card is modified with the option to trigger the IRQ.

 

Concerning vertical blanking, this is how the original Mouse Card did the synchronization:

  • The mouse card's ROM routine blocks and waits during initialization: it waits for an exact moment where the video state changes from DRAW to BLANKING ($C019: 1=>0 transition). It then sends a command to the Mouse Card's slave controller.
  • The slave controller now knows an exact moment where a video blanking event started. It uses this to reset its MC6805 internal timer, which drives an internal interrupt.
  • The  slave controller's clock source is driven by the 6502 clock (they used the 2MHz/Q3 clock, but it's still the same source). So there cannot be any clock drift between the 6502 and the 6805 (no separate crystals generating slightly drifting clocks). And since the same clock also drives the video output, there is also no clock drift between the video subsystem and the mouse controller's 6805.
  • The 6805's interrupt routine does the necessary calculation: it knows exactly how many clock cycles it takes from one blanking event to the next. So it just keeps track of the time and perfectly rewinds its internal timer as necessary.

That is already the whole trick - how they enabled the slave controller to trigger VBL synchronous interrupts, though it only got a notification about a single VBL event during initialization.

 

Now, having said that, here's a current limitation: :)

  • Right now, I haven't actually implemented the synchronous feature. The VBL interrupt works - triggers at 60 Hz or 50 Hz, as configured. But it's not synchronous to the screen (yet). I will eventually add that. The same method as for the original 6805 should work. The PICO itself is not driven by the 6502 clock, however, it does have access to it: it "sees" every single bus cycle. So it can count cycles to keep track of the periodic VBL, just as the original 6805 did.

 

Edit:

Oh, and there is one more and important limitation:

  • Those who are using any of the current A2VGA cards (doesn't matter which variant): none of these cards is currently producing video output which was synchronized with the Apple II. So, while the Apple II does keep track of VBL, the A2VGA card's VGA output is just driven by the PICO's own internal clock (derived from the PICO's separate crystal).
  • So even when I change the A2USB implementation, so that VBL mouse interrupts are actually synchronous with the Apple II's VBL, it would only make a difference when using the Apple II's original video output.
  • The missing sync feature for the A2VGA card is actually a known limitation of the current designs. There was a talk at last year's KansasFest where this was discussed...
Online
Last seen: 1 hour 25 min ago
Joined: Mar 12 2023 - 16:49
Posts: 18
Vertical Blanking
MacFly wrote:

Yes, interrupts are working with the A2USB - if the A2VGA card is modified with the option to trigger the IRQ.

 

Concerning vertical blanking, this is how the original Mouse Card did the synchronization:

  • The mouse card's ROM routine blocks and waits during initialization: it waits for an exact moment where the video state changes from DRAW to BLANKING ($C019: 1=>0

Many thanks for the detailed explanation, much apreciated.

 

Regards

Crusty

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
Ralle just surprised me with an updated PCB...
  • A2VGA PCB v1.6 introduces optional A2USB/IRQ support.
  • His schematics show which elements are optional (when making PCBs for VGA vs USB/IRQ).
  • He also added a polyfuse, instead of just adding the jumper to connect VBUS/VSYS. Better protection of your Apple II & power-supply, in case the attached mouse/cable caused a short.

 

And there is also another project underway,  more focussed on I/O and with other advantages. This will also support the A2USB/IRQ option. But there is no release yet, and it's not my project, so you have to look forward to the details.

New stuff for the Apple II just keeps coming! :) (Apple ][ Forever!)

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
That V1.6 board looks super

That V1.6 board looks super nice.  Either Ralle is readig AppleFritter or someone on here is in communication with him.  Is that you MacFly?  I've occasionally corresponded with him on FB, but it would be cool if he was active here.

 

The I/O oriented board sounds super interesting.  I could see interfacing an SD card or one of the USB modules like the CH376S instead of the VGA connector.  The software using the 3 74LVC245 and ATF22V10 to Pico could probably emulate either a Disk ][ type interface, SmartPort or even others.  ProDOS block device, ProFile, other hard drive interface...  Corvus maybe?  The sky is basically the limit with these "software based devices".

 

 

Online
Last seen: 3 min 6 sec ago
Joined: Jun 29 2018 - 16:55
Posts: 557
Very nice.  First update

Very nice.  First update since 1.2 that I would consider a new pcb run for. Keep up the good work guys. 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
skate323k137 wrote:Very nice.
skate323k137 wrote:

Very nice.  First update since 1.2 that I would consider a new pcb run for. Keep up the good work guys. 

Same here.  I made 3 of the V1.1 boards and 5 V1.2  boards...  I just ordered 5 V1/6 PCBs from JLCPCB today.  I'll have to order some more RPi Picos...  I think I have everything else I need.

 

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
A2 Desktop

A2 Desktop also seems to work without the need for the IRQ mod.

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
VBL synchronous interrupts

Yes, A2Desktop also only uses polling. It's only drawing a tiny mouse cursor, so using the interrupt to update during "vertical blanking" of the CRT isn't that important.

You can also use MousePaint's tutorial (pressing RETURN in the beginning), it also doesn't use interrupts. With MousePaint it's just the main application which does.

(Btw, are the issues with the slots of your IIe already resolved? :-)) )

 

And concerning A2USB: I now also have the "VBL" (vertical blanking) synchronous feature implemented. Going to push this later to GitHub. It's just a matter of counting the bus cycles - and knowing exactly how many 6502 bus cycles there are for each screen interval (for PAL and NTSC). It actually does make a lot of difference with MousePaint. It's because it is using fairly large mouse cursors, depending on which tool is selected. When the interrupts are not VBL synchronous, there is a lot of flickering when moving the mouse. With the synchronous feature working, the flickering is completely gone (since the mouse cursor is redrawn during CRT blanking then). As described above, this only really helps with a real CRT connectect. A2VGA output, for example, itself isn't synchronized with the Apple II's VBL - so it still flickers. In fact, A2VGA would probably also flicker with games and other applications, which try to use the vertical blanking phase to update the graphics screen.

So, feature-wise the Mouse Card Emulation should now be complete. At least that was the last missing feature I was aware of.

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
So I take it we need to

So I take it we need to update the code on our Picos?

 

MacFly's picture
Offline
Last seen: 8 hours 53 min ago
Joined: Nov 7 2019 - 13:49
Posts: 442
softwarejanitor wrote:So I
softwarejanitor wrote:

So I take it we need to update the code on our Picos?

 

No one has to, of course, and there were no bugfixes, but if you wanted the synchronous interrupt feature, you can now install the latest firmware:

https://github.com/ThorstenBr/A2USB/releases

 

Actually, since I could only test it with PAL machines, and you probably have a real NTSC CRT for your Apple II, you could be so kind and test the NTSC variant. :)

 

With the old firmware, start MousePaint, open the drawing area and select the large "hand tool" (the pen or large brush also works well). Now quickly move the mouse cursor on the screen. You should see noticable flickering (since MousePaint is removing and redrawing the cursor while the screen is displaying).

Then, try the same after updating to the new firmware (using the NTSC firmware variant, in your case). The flickering should be gone after the update. The mouse cursor is now redrawn during the CRT blanking phase, so the intermediate effects are hidden.

As described earlier, only works with a real CRT, not with the A2VGA output (A2VGA output isn't synchronous to the Apple II's video state).

 

Offline
Last seen: 2 hours 6 min ago
Joined: Jul 5 2018 - 09:44
Posts: 2464
I do actually have a couple

I do actually have a couple NTSC CRTs here handy...  albeit they are both monocrhome.  Mostly I have been using a modern display either with a NTSC->HDMI adapter or more centenltly the A2VGA boards.  I understand the desire to test the NTSC output for sync though so I can do that, probably tomorrow.

 

 

CVT
CVT's picture
Offline
Last seen: 1 hour 43 min ago
Joined: Aug 9 2022 - 00:48
Posts: 951
The "more elegant" USB

The "more elegant" USB adapter from AliExpress mentioned in Post #22 arrived: (There is an even more elegant one: click!)

 

Log in or register to post comments