Controllers: four pads that say what is held
The console says WHICH KEY WENT DOWN, which is the right shape for typing and the wrong one for playing. A game wants to know what is being held, this frame, possibly several things at once, and a stream of presses cannot say that: a key that is down and staying down sends nothing at all. Lunar Porter's thrust is a burn per press for exactly that reason. So a pad is its own device on ports 0x60 to 0x6F, reporting a LEVEL. One read gives every button at once, holding is the natural thing to express, two directions together cost nothing, and reading does not consume it - a game may ask twice in a frame and be told the same thing both times. Four of them, because a party is four. They cost a port each and nothing at all when unused. The directions are the low nibble so "which way" is an AND with 0x0F; the buttons are the high nibble for the same reason. 0x64 says which are really there, so a game can ask for a controller rather than sitting silent while somebody presses things at it. They never interrupt: a game polls once a frame because that is when it draws. KEY-UP ON THE CONSOLE WAS THE OTHER WAY TO DO THIS AND WAS REJECTED. A terminal hands over characters and can never report a key coming up however it is asked, so it would have been a thing that worked behind a window and silently did not down a wire. A separate device can honestly say it is not there. Voyager drives pad nought from the keyboard as well as from any real controller, OR-ed rather than chosen between, so a game written for a pad is playable on a machine with none and unplugging one mid-game does not leave somebody holding nothing. And a recorded path, which is what makes any of it testable: --pad names a file of one byte a frame, and the manifest has an eighth column for it. A BYTE A FRAME AND NOT A BYTE A READ - a level asked twice in one frame has to answer the same both times, and a file that advanced per read would depend on how the program happened to be written. Voyager's own tests run headless with nobody holding anything, so without this the device would be exercised only by somebody playing: the state the console's line editing was in when it broke twice in two days. 0x50 is the timer, not free. The block this went in was chosen after looking rather than before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
88ecb208f4
commit
fed1453e6e
@@ -602,6 +602,7 @@ If nothing is installed for the vector a device refused with, the machine stops
|
||||
| 0x30 - 0x3F | The screen. See The Screen. It brings video memory, which is unreachable until it is registered as a bank. | 0x14 |
|
||||
| 0x40 - 0x4F | The sound device. See Making A Noise. Four channels, played by writing to ports; it brings no memory. | 0x15 |
|
||||
| 0x50 - 0x54 | The timer. See Keeping Time. Counts the machine's cycles and says when a period has gone by. | 0x16 |
|
||||
| 0x60 - 0x6F | The game controllers. See Controllers. Four pads, polled, reporting what is held. | 0x17 |
|
||||
| 0xE0 - 0xEF | The memory controller. See The Memory Controller. | 0x03 |
|
||||
| 0xFF | The bus registry. See Asking What Is There. | 0x01 |
|
||||
|
||||
@@ -1167,8 +1168,48 @@ One thing to be careful of: the registry remembers which port it was asked about
|
||||
| 0x14 | Screen. |
|
||||
| 0x15 | Sound. |
|
||||
| 0x16 | Timer. |
|
||||
| 0x17 | Game controllers. |
|
||||
| 0x17 - 0xFF | Peripherals. |
|
||||
|
||||
## Controllers:
|
||||
|
||||
Four pads on ports 0x60 to 0x6F. Each one is **one byte, read, saying what is held right now**.
|
||||
|
||||
| Port | Holds |
|
||||
| --- | --- |
|
||||
| 0x60 - 0x63 | Pads 0 to 3. |
|
||||
| 0x64 | Which pads are there, one bit each. |
|
||||
| 0x65 - 0x6F | Reserved. |
|
||||
|
||||
| Bit | Button |
|
||||
| --- | --- |
|
||||
| 0x01 | Right |
|
||||
| 0x02 | Left |
|
||||
| 0x04 | Down |
|
||||
| 0x08 | Up |
|
||||
| 0x10 | A |
|
||||
| 0x20 | B |
|
||||
| 0x40 | Start |
|
||||
| 0x80 | Select |
|
||||
|
||||
The four directions are the low nibble, so *which way* is an `AND` with `0x0F` and needs no shifting. The four buttons are the high nibble for the same reason.
|
||||
|
||||
### Why This Is Not The Console:
|
||||
|
||||
The console says **which key went down**. That is the right shape for typing and the wrong one for playing: a game wants to know what is being held, this frame, possibly several things at once, and a stream of presses cannot say that. A key that is down and staying down sends nothing at all.
|
||||
|
||||
A pad reports a **level** rather than an event. One read gives every button at once, holding is the natural thing to express, and two directions together cost nothing. **Reading does not consume it** - a game may ask twice in a frame and be told the same thing both times, which an event queue cannot promise.
|
||||
|
||||
Key-up on the console would have been the other way to do it, and it was rejected: a terminal hands over characters and can never report a key coming up however it is asked, so it would have been a thing that worked behind a window and silently did not down a wire. A separate device can honestly say it is not there.
|
||||
|
||||
**They never interrupt.** A game polls once a frame because that is when it draws, and an interrupt for every button would be exactly the event model a pad exists to avoid.
|
||||
|
||||
### When There Is No Pad:
|
||||
|
||||
A pad that is not there reads as nothing held, which is the same as a pad nobody is touching. The difference matters only to whoever wants to explain it, so 0x64 says which are really there and a game can ask for a controller rather than sitting silent while somebody presses things at it.
|
||||
|
||||
`Programs/testPrograms/padTest.asm` reads one twice a frame to show that looking does not take it away.
|
||||
|
||||
## Keeping Time:
|
||||
|
||||
A period, in cycles, and a bit that says when one has gone by.
|
||||
|
||||
Reference in New Issue
Block a user