You are not logged in.

#1 2015-08-29 21:08:00

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Stupid Arduino Tricks

Borrowing from jt's comments, I thought I'd start a new thread on stupid arduino tricks.

Here's today's stupid arduino trick:
20.jpg

Since doing the PS2 ADB adapter with the stm32f0 processor, I've thought about trying to do it on the arduino.  The problem was my ADB implementation was much too slow to work on the arduino.  The stm32f0 is crazy fast in comparison.  I've still toyed with the idea on and off for a year or three, even making up small PCBs with the arduino mini pro, adb, and ps2 connectors.

Today I decided to spend some time with it.  I adapted some code from here, which is great stuff BTW, but the ADB implementation is host only, and I'm trying to be an ADB device.  Still, it's great code, well tuned, and didn't take too long to get the basics working.  Right now, I've got a basic mouse device working without SRQ (meaning, I can only talk when spoken to, I can't request to be spoken to), but it's enough to demo that it's working.
Then just for kicks, I glued in this PS2 mouse code to complete the PS2 mouse to ADB adapter.  It "works", but the sampling rate is much too slow to actually be very useful.  The ADB code I built on is very well tuned.  The PS2 code, not so much.  So there's definitely room for improvement, and I'm hopeful I can make it into something useful.
Maybe even an ADB joystick, eventually.  wink

Offline

#2 2015-08-29 22:57:51

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Hah.  Sweet.  PS2 mouse to ADB working through arduino.  Fully working, SRQ and completely workable sample rate.  Higher than a stock apple mouse, which is both good and bad.  High sample rate, but the mouse really wants to talk on the bus all the time.  smile  Sweet!

Offline

#3 2015-08-30 01:17:49

uniserver
Member
From: Sf, Mi
Registered: 2014-05-15
Posts: 956
Website

Re: Stupid Arduino Tricks

smile


#I Re-Cap √Mac √NeTX √Amiga Boards - A/B - PSU# (MacCaps.com)  Modern SCSI HD's - For Old Macs - Pre Cfg'd - 10k RPM! 73gb!! $50 + free shipping  -- Mac 128K Re-Ram kits (16 Chips) $35 + shipping, Floppy Issues?-> Bourns Filter Solution 128k - SE/30, $16 + shipping

Offline

#4 2015-08-30 01:52:45

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

In my investigations of joysticks, I've got Hellcats and F/A-18 Hornet installed and they have no prefs for joystick settings.  I installed the Gravis MouseStick joystick drivers, and it looks like ADB joysticks were essentially a programmable mouse and keyboard in one.  Before launching the game, you go into the joystick prefs, and they'd typically have a predefined configuration for a particular game.  That would configure the "keyboard" in the joystick to send certain keycodes for particular buttons.  The x/y axis of the joystick would just be a relative mouse device.

That kind of puts the burden on the maker of the joystick and the user instead of the OS and game vendor, but I guess that fits with SJ saying "the mac is a tool, not a toy".

Offline

#5 2015-08-30 03:41:03

LCGuy
Administrator
From: Sydney, Australia
Registered: 2014-05-13
Posts: 855

Re: Stupid Arduino Tricks

Strange - I have F/A-18 Hornet 1.1.2 and it allows you to select what type of joystick you have, and from memory a few other settings.

Offline

#6 2015-08-30 16:39:44

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Yeah, F/A-18 Hornet 2.0.0 has a setting in prefs for "joystick", but I'm not really sure what it does.  I don't actually have a joystick, so it's not like it's actually selecting a physical device (like if I had 2 joysticks, it would be selecting one of the two).  I'm guessing it's just configuring some settings like acceleration of the x/y axes and maybe inverting the y axis?  I'm not really sure.
fa18prefs.png

But other games like Hellcats that work with joysticks have no settings at all, while the joystick drivers have all kinds of settings and presets for specific games, which leads me to believe the game's joystick setting is just some tweaks to how the mouse inputs are interpreted.

Offline

#7 2015-08-30 19:54:45

jt
Member
From: Bermuda Triangle, NC USA
Registered: 2014-05-21
Posts: 1,469

Re: Stupid Arduino Tricks

I thought I'd posted the first reply yesterday, but it looks like I lost it, but it's better now that you've got it cooking:

cool Not so stupid Arduino trick! Nice. wink

Heh! All this talk of Hellcats had me harvesting about a dozen flight SIMs and Manuals today. Which Hellcat game/rev. are you flying, LC? The only game I've done much of anything with since Red Baron on C64 was the Warbirds demo back around 2002-2004(?) but now I've got 2.75 + Manual, which should help with the 2.77 rev. which is probably what I played back in the day.

Offline

#8 2015-08-30 20:22:15

LCGuy
Administrator
From: Sydney, Australia
Registered: 2014-05-13
Posts: 855

Re: Stupid Arduino Tricks

Hellcats Over The Pacific - like bbraun said, no settings for the joystick in my version of Hellcats.

Offline

#9 2015-08-30 21:20:10

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Well, curiosity got the better of me, and I bought an adb gravis joystick off ebay.  I'll have to poke at it after it arrives.  If x/y is mapped to mouse movements I'm curious what increment values it uses and whatnot.  Plus looking at the presets and everything.  Doing the presets on the controller, with one one of these LCDs to select from, would eliminate the need for drivers, maybe.

Offline

#10 2015-08-30 22:36:16

MJ313
Member
Registered: 2014-09-23
Posts: 498

Re: Stupid Arduino Tricks

jt wrote:

Heh! All this talk of Hellcats had me harvesting about a dozen flight SIMs and Manuals today.

I hope you picked up Falcon MC (or 2.2 for your SE/30). I always liked it more than F/A-18.

Last edited by MJ313 (2015-08-30 22:36:55)

Offline

#11 2015-08-31 00:51:57

jt
Member
From: Bermuda Triangle, NC USA
Registered: 2014-05-21
Posts: 1,469

Re: Stupid Arduino Tricks

I've got the manuals for MICROPROSE/MacSoft's Falcon 4.0 and (I think) the media somewhere, but it looks way more complicated than I'd like to get. Simple dogfighting is what I like to do most, sinking the fleet in Warbirds is a lot of fun. I like to try to fly through the hangar deck on the carrier most of all. SPLAT!!! yikes Now that's a stupid Flight SIM trick!

SE/30 was DOA on arrival, I'm lookin' at OS9 on the DA/466 for my sometime gaming fun.

Offline

#12 2015-08-31 17:35:48

Eudimorphodon
Member
Registered: 2014-09-02
Posts: 525

Re: Stupid Arduino Tricks

bbraun wrote:

Well, curiosity got the better of me, and I bought an adb gravis joystick off ebay.  I'll have to poke at it after it arrives.  If x/y is mapped to mouse movements I'm curious what increment values it uses and whatnot.

I'm curious myself how that works. Are the joysticks analog or digital? If they're analog I wonder if all they do is virtually "spin the wheel" in a given direction at a speed proportional to the stick deflection. So, for instance, if you have it hard right the input is the same as if you were holding your mouse on a high-speed treadmill that direction; back off and the treadmill slows down, push up and the angle of the mouse relative to the treadmill changes, etc.


Flap Different.

Offline

#13 2015-09-01 00:25:31

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Yeah, that's what I'm thinking, they're analog and there's some acceleration factor depending on how far over you are, and if so, knowing what that acceleration factor is could be interesting if I did plan on making my own.

And again, I couldn't leave well enough alone, and now I have keyboard and mouse working simultaneously.  The trick to getting everything working well was remembering that in PS2, the host can hold the clock low, inhibiting device communication.  So while I'm busy polling, I can make the device buffer information for a few dozen microseconds if necessary.  But, totally usable.  So, now PS2 keyboard/mouse to ADB adapter, now in a much smaller form factor.  And cheaper too!  It's about 50cm x 40cm or something.

Offline

#14 2015-09-02 00:56:15

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Ok, so getting ADB working on the arduino was just the starter, and the PS2 conversion was just to prove it worked.
On to more interesting things:
I can now get a IIsi (and probably IIci, IIvi, IIvx, and Performa 600, and possibly all later models) to enter test mode through ADB.
Here's the data capture of a TechStep doing the the ADB power on, using Saleae's Logic (free download to be able to read the file): http://synack.net/~bbraun/macsrc/TechSt … .logicdata
Basically it is doing a soft power on, releasing the power line, then after the machine comes up, it is holding the power line low again.  The IIsi sends a TALK register 2 request to the "keyboard", which is the keyboard register that contains the modifier key state.
The TechStep responds with 0xED, followed by 10x of 0xEE.  The high order bit is supposed to be reserved, and the other buttons supposedly held down are delete, capslock, reset, control, shift, option.

I've been able to reproduce the sequence using the arduino, and can kick the thing into test mode with an arduino dongle.

Offline

#15 2015-09-02 03:58:19

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

In an effort to understand what the techstep is doing so that it could potentially be duplicated, I hooked up a minidin8 breakout board from dougg3, and captured some diagnostics between the techstep and the IIsi.  Logs are here:
http://synack.net/~bbraun/techstep/iisilogs/
They're logs from the screen command line tool just doing:

sudo screen -L  /dev/tty.USA28145P1.1 9600

The output is mostly ASCII, but not always.
Now I guess I get the job of digging through the logs, and comparing it to ROM disassembly to figure out what it's doing.  smile

Offline

#16 2015-09-02 18:48:55

bigmessowires
Member
Registered: 2014-05-15
Posts: 183

Re: Stupid Arduino Tricks

Wow, nice! You're blazing a new trail there with the TechStep stuff. I shall be subscribing to your newsletter for further updates. :-)

Offline

#17 2015-09-02 19:31:33

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Thanks!  Yeah, there's a lot going on here so it's a bit much as a toy project, but a little here and there will make progress I hope.

There's also a way to enter the test mode via the scsi connector, which is what earlier machines used, I think.  I'm pretty sure the ADB approach is only used on Egret machines, which would be the IIsi and later, but this particular ROM pack for the TechStep includes the IIci, IIsi, IIvx and its family, so maybe there's an ADB way to get the IIci into test mode?  I'm not sure, I don't have a IIci so can't test at the moment.  It's possible the IIci is SCSI only as well.  I still need to figure out how the SCSI mode works.

Those logs of the transactions are from the TechStep's receive pin, so they're what the IIsi is sending back to the TechStep, not what the TechStep is sending.  The ROM echos the commands it received, but not the arguments, so like when *T is in the log, it didn't capture what test was being executed.  I'll try to get logs from the other side as well so they can be matched up.
Another interesting thing to note is the IIsi side will send the response to the command before it echos the command.  So the binary bits in the log that precede the *R are the results being reported, followed by the echoing of *R.

I started this wiki page a couple years ago when I was looking into this before, so I'll try to keep it updated with the findings from this project.

Offline

#18 2015-09-03 00:54:54

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

I guess all this turning the machine on and off made my IIsi very upset, and the PSU popped a cap or something.  That wonderful smell of electrolytic fluid, the machine won't turn on, and after I disassembled the PSU, there's wet goo everywhere.  Maybe a recapping will fix it, if it didn't asplode something else in the process.

The joystick arrived today, and I can confirm that it is a keyboard/mouse device as far as ADB and the OS is concerned.  The x/y axes are mouse movements, but instead of putting the mouse on a treadmill, moving the stick causes the mouse to move a fixed amount on that axis.  So I move the stick right halfway, and it moves the cursor say 200 pixels.  I hold the stick there, the mouse does not move.  I move the stick all the way over, it moves the cursor another 200 pixels right.  I move the stick back to the center, and it moves the cursor left by ~400 pixels, so it's back where it started.  It's also a linear function that governs how far the cursor moves relative to joystick movement.  It is unaffected by how fast you move the joystick, and the cursor moves the same amount in the first half of the joystick's movement as it does the second half.
By default, the firing button is a mouse click, and the other 4 buttons on the thing are keyboard buttons.
But all this can be changed.  The buttons can be mapped back and forth as mouse clicks or keyboard buttons (any button you want), but the joystick x/y axes can be mapped as arrow buttons (or presumably any other button).  The amount of configuration it offers is pretty impressive, but I suppose it has to be considering it has to handle whatever mouse/keyboard controls any random game happens to use.

Offline

#19 2015-09-04 20:29:57

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Bummer, recapping the IIsi's PSU got a single chime, then failure, and the thing doesn't power on anymore.  Oh well, scratch one IIsi PSU.  Time to move on to a different machine I think.

Offline

#20 2015-09-05 13:18:57

jt
Member
From: Bermuda Triangle, NC USA
Registered: 2014-05-21
Posts: 1,469

Re: Stupid Arduino Tricks

iisitestspositive1.jpg

Offline

#21 2015-09-05 22:41:50

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Heh, I'm not that desperate yet.  smile

I've been updating the wiki with some basics from my the serial captures earlier.  I added the ADB information, some additional commands the diagnostic mode takes, and an annotated transaction that the TechStep issues for the "Identify CPUID" command, which really just returns the model number of the machine, and optionally ROM version.  For what is essentially the most basic command the TechStep can issue, it's pretty involved.  There's still a part I'm not understanding:
The techstep is loading 2e7c000e00004ed6 into address 0x44000 of the machine, and executing it.  When the ROM executes the code, it jumps to the specified address, but before it does, it stores the address after the jmp in register A6.
The disassembly of that code (I think) is:

movea.l #$000e0000, a7 ; stack pointer
jmp (a6)

So basically, it's just setting the stack pointer.  The part I'm a little less clear on, is afterwards it is retrieving the status of the command, which is essentially just getting the value of register D6, and it contains 0x1dc.  I'm unsure where that might have come from.

Offline

#22 2015-09-05 23:22:04

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

Figured it out.  The *D command checksums the data it receives and stores the checksum in register D6.  So 0x1DC is the checksum for 2e7c000e00004ed6.
Kinda backward to check the checksum after you've executed the code, but hey.  That's what it does.

Offline

#23 2015-09-06 01:02:42

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

I put captures of both rx and tx sides for a P600 here.  I haven't gone all through the captures yet though.  There's a lot of floppy related tests that I didn't get through, partly because it seemed to fail doing even basic tests on the floppy drive that I thought was working.  Probably good data to have anyway, but wasn't what I was looking for.

There's also a lot of SCSI tests that I don't think I'll be able to reproduce easily.  The techstep has an NCR5380 SCSI chip in it, and is capable of doing actual SCSI operations, which I won't be able to easily reproduce.

Offline

#24 2015-09-06 04:47:15

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

I plugged in the SCSI analyzer and captured the techstep attempting to put the machine into test mode.  I didn't have any other devices on the bus, just to simplify the capture, although if anyone is interested, I can try putting a disk at scsi id 0 just to see.

The analyzer is an Ancot SCSI-bus Analyzer Model DSC-216, and the manual that documents the file formats it saves is here.
I put the captures here.  I think the most useful are the compact which is kind of an overview, and the structured formats.

From my understanding of the capture, the TechStep is pretending to be a disk at scsi id 6.
There are 6 read commands for 5 blocks (512 bytes) in the order of: block 0, 4, 1, 2, 3, and 1 again.
The links there are hexdumps of the blocks the TechStep is sending back to the host, taken from the structured-formatted capture file.

Offline

#25 2015-09-06 06:16:24

bbraun
Member
Registered: 2014-05-29
Posts: 1,064
Website

Re: Stupid Arduino Tricks

I'm working on decoding the blocks to understand what is going on.  Here's the first 3 blocks:

block0:
sig: $4552
block size: $200
block count: 6
device type: 1
device id: 1
sbData: 0
driver count: 1
driver's starting block: 4
driver size (in blocks): 1
driver type: 1 (mac)
the rest is 0's

block1: partition map
sig: $504D
# of blocks in partition map: 3
pysical start block of partition: 5
number of blocks in partition: 1
Partition Name: MacOS
Partition Type: Apple_HFS
the rest is 0's

block2: also partition map
sig: $504D
# of blocks in partition map: 3
pysical start block of partition: 1
number of blocks in partition: 3
Partition Name: APPLE
Partition Type: Apple_Partition_
the rest is 0's

block3: also partition map
sig: $504D
# of blocks in partition map: 2
pysical start block of partition: 1
number of blocks in partition: 2
Partition Name: _Macintosh
Partition Type: Apple_Drover (actually Drover, not Driver!)
the rest is 0's

The fourth block is the disk's driver, although I'm not familiar with the format it's in.  The "How the ROM Loads SCSI and ATA Drivers" section of this document essentially says it should just be straight code that will be executed starting at offset 0.  But I'm trying to make heads or tails of the code.  Here's the raw hex:

00000000  3e 7c 40 00 2e bc 00 80  46 fc f0 16 40 00 2e 7c  |>|@.....F...@..||
00000010  50 f2 60 00 1e bc 00 47  3e 7c 27 00 30 3c 20 01  |P.`....G>|'.0< .|
00000020  4e 7b 00 02 2e 3c 03 02  00 00 20 38 00 7c 21 c0  |N{...<.... 8.|!.|
00000030  00 bc 4e 4f 00 00 00 00  3e 7c 40 00 2e bc 00 80  |..NO....>|@.....|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200

The partition map blocks are basically just minimal stubs, enough to satisfy the ROM.  The actual meat is the driver code in block 4.

Offline

Board footer

About ThinkClassic

ThinkClassic specialises in the use, maintenance, repair, restoration and modification of vintage computers and peripherals.