Any docs?
Couldn't find one on nesdev (not unless there's a blurb about it in some huge all-in-one doc that I didn't check). Google didn't help much either. I quickly glanced at a few emus sources, but rather than try to decipher them, I'd much rather have a document covering how it works.
Thanks ^^
I don't have definitive documentation per se, but I do have a working implementation in my emulator, and it works something like this:
Write $4016:
D0 - Strobe, but inverted (write 0 to latch, write 1 to read data back)
D1 - Advance bit (write 0, 1, then read $4017), only valid when D0=1
Read $4017:
D2 - 1 if $4016.1 is clear, otherwise 0
D3 - Inverted serial data from latch if $4016.1 is set (returned upper bit first), otherwise 0
Note that you must account for the fact that strobing 4016.0 (0>1) and setting 4016.1 will advance the bit counter - this should cause it to advance to the first bit.
Data format:
xxxxxxxxyyyyyyyyba
a - 1 = "click" (press down on tablet surface?)
b - 0 = cursor is in top bar and not being clicked (1 otherwise)
yyyyyyyy - Cursor Y position, scaled to 0-255 (for emulator, take mouse.Y within 0-239, subtract 14, then multiply by 256/240)
xxxxxxxx - Cursor X position, scaled to 0-239 (for emulator, take mouse.X within 0-255, add 8, then multiply by 240/256)
The "subtract 14" and "add 8" were derived by disassembling the game's joypad code and reversing the transformations it performs on the input (by which it converts to on-screen coordinates).
One note - in order for the button panel at the top to work nicely, you need to click, hold, and then move the cursor at least 1 pixel before you release. This may itself be a bug in my implementation, but it's fairly minor.
Thanks!
After a lot of tinkering and messing around and debugging, I got it working.. although the 'click' sees a little unresponsive. There's a game where you click and drag puzzle pieces from one side to the other, and I can do it, but it doesn't want to "let go" of the pieces when I release the click. I've noticed this in NEStopia and Nintendulator as well, though.
I'm thinking it's just a side-effect of using a mouse instead of an actual stylus. You probably aren't expected to hold the button the whole time -- rather you just lift your pen when you want to release whereas, you can't lift the mouse -- so when using a mouse it feels as though you're dragging.
I see what you mean with the buttons at the top of the screen -- but I find I don't have to move the mouse at all in order to make them register -- although you do have to hold the button for a while (a quick click won't cut it). Moving/dragging the mouse doesn't seem necessary though -- but doing so makes you hold the button longer, which is probably why it seems to work.
Also -- to theorize and speculate (I could be waaaaay off base here) :
Perhaps the 'b' bit is a "stylus touching tablet" indicator (1=touching, 0=not touching). I couldn't make much sense out of its logic before looking at it that way.
I don't know what the actual tablet looks like (google image search has failed me) -- but I'm guessing it's a sort of pen that has a tip which pushes in when pressed and a rectangular surface with 7 stationary buttons across the top (above the actual drawing surface)
This would explain why the game exits the title screen once 'b' is set (starting the game would happen by simply touching the pen to the tablet -- but a full 'click' isn't necessary. I find it hard to believe that the actual game flashes the title screen as quickly as is done in emulators)
Also strangely, the games don't seem to look at the 'a' bit for the top 7 button presses -- only the 'b' bit is significant.
I would almost be willing to bet money though, that the top section is not part of the surface available to the main part of the tablet. This would explain why the Y position doesn't matter when you click in the top portion -- and why the X position is approximated (clicking between two buttons works). [edit] Either that, or there's some sort of protective thing over the top part of the tablet with 7 holes in it for the buttons. Man I would really love to see a picture of this thing [/edit]
I'm thinking of redoing a chunk of my tablet emulation with this in mind (maybe allow a way for the user to touch and release the tablet without actually pressing the button) just to see how it pans out. It certainly makes a whole lot more sense to me this way, though.
EDIT -
yeah.. treating 'b' this way really works out well. I'd put money on that being what that bit is for.
My apologies for the 6 year bump, but as a kid, I had a V-Tech Video Painter (the original model), and by looking at this Oeka Kids tablet, the two seem to be pretty similar.
On the Video Painter, you can touch the stylus to the tablet surface, and a little on-screen cursor will appear, but you don't actually "draw" anything until you hold down a large red button on the tablet itself (which is similar to the Oeka Kids' "click"). Alternatively, there's something like a "caps lock" button which changes the tablet's behavior such that touching the tablet surface is automatically considered a "click", and the Oeka game has a software option that does the same thing.
I was able to find a picture of the box here:
http://www.nakoko.com/uploads/items/258/25825/image/25825_75318.jpg, or by searching "oeka kids tablet" on google.
I don't see any "click" button on the Oeka tablet, but the "click lock" feature in the game shows the bottom part of the tablet highlighted, so maybe that gray bar is the click button.
Good point. I was thinking that it could separate between soft & hard pressure, for "touch" and "click" accordingly.
But now that you mention the button... I guess you are right... the japanese manual does actually show a picture with a hand on the gray bar:
http://www.nakoko.com/gallery/show/25825/name
Does anybody have a real Oeka Tablet at home and can tell how it works? Or can translate the "click" related part of the manual?
Idea for emulation using mouse: Left button to touch, right button (or space-bar, if this is preferred) to click.