MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Resolution",
        "continue": "gapcontinue||"
    },
    "query": {
        "pages": {
            "57": {
                "pageid": 57,
                "ns": 0,
                "title": "Reading Controllers",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "== Wait for controller movement ==\n\n\nThe simplest use of hand controller is to just pause and wait for a movement, this subroutine does just that, you call it with:\n<pre>\n; Add this subroutine call to your code:\n\n\tpi\twait.4.controller.input\n\n; Movement from either Hand Controller will continue the program\n\n\n; here's the actual subroutine, copy and paste to your program where convenient\n\nwait.4.controller.input:\n\t; see if one of the hand controllers has moved\n\tclr\t\t\t\t\t\t; clear accumulator \n\touts\t0\t\t\t\t\t; enable input from both hand controllers\n\touts\t1\t\t\t\t\t; clear latch of port of right hand controller\n\touts\t4\t\t\t\t\t; clear latch of port of left hand controller\n\tins\t1\t\t\t\t\t; fetch inverted data from right hand controller\n\tcom\t\t\t\t\t\t; invert controller data (a %1 now means active)\n\tbnz\twait.4.controller.input.end\t\t; if no movement then input is 0 -> no branch\n\t; check the other controller\n\tins\t4\t\t\t\t\t; fetch inverted data from left hand controller\n\tcom\t\t\t\t\t\t; invert controller data (if bit is 1 it means active)\n\tbz\twait.4.controller.input\t\t\t; if there's no indata repeat\n\nwait.4.controller.input.end:\n\tpop\t\t\t\t\t\t; return from subroutine, controller data in A\n</pre>\n\n== Controller directions in the register ==\n\nAfter the hand controller data has been read from the port latch a 1 means inactive and 0 means active. \nIt's common to want the 1 showing active signal therefore it's inverted with the com opcode as seen above. \nThis is not a necessary step, port data could just as easily be used and save a machine cycle.\n\nThe 8 bits are stored in Accumulator (A) and the bits mean this:\n\n<pre>\n        direction\nbit  0  right\nbit  1  left\nbit  2  backward\nbit  3  forward\nbit  4  counterclockwise\nbit  5  clockwise\nbit  6  pull up\nbit  7  push down\n\n\nPort-data\n%00000001  right\n%00000010  left\n%00000100  backward\n%00001000  forward\n%00010000  counterclockwise\n%00100000  clockwise\n%01000000  pull up\n%10000000  push down\n\nCombinations are possible to:\n%10000010  push down + left\n\nThere are combinations that are impossible with a normal fully functional controller since they are opposite directions:\n%11000000  push down + pull up\n\nThe \"Jet Stick\" however could do this as the fire button is parallel to the push down function.\n</pre>\n\nAfter reading the controller/s it's handy to store it in a register (or in available RAM) for use later <br>\nunless checking directly which direction was chosen. <br>\nImagine you have written a game where you can move forward, backward, right or left with the right hand controller. <br>\nIf we store the result of the controller in register 8, this is how to do it:\n\n== Store result for later use ==\n\n\n<pre>\nstore.right.controller.input:\n\t\n\tclr\n\touts\t0\n\touts\t1\t\t\t\t\t\t; check right hand controller\n\tins\t1\n\tcom\t\t\t\t\t\t\t; re-invert controller data\n\tlr\t8, A\t\t\t\t\t\t; store result in register 8\n\nstore.right.controller.input.end:\n\n\nLater in the program we can load the movement and mask away the directions we're interested in.\n\n\n\t; \tprogram program\n\t; \t...\n\t\n\tlr\tA, 8\t\t\t\t\t\t; copy register 8 to Ackumulator\n\tni\t%00001111\t\t\t\t\t; AND result and only keep the last nibble\n\tlr\t8, A\t\t\t\t\t\t; back up result in r8 again\n\n\t;\t...\n\t;\tprogram continues\n\n\nWe now have one of these bit patterns in r8:\n\n%00000000\tno movement\n%00000001\tright\n%00000010\tleft\n%00000100\tbackward\n%00000101\tbackward + right\n%00000110\tbackward + left\n%00001000\tforward\n%00001001\tforward + right\n%00001010\tforward + left\n\nNothing else is possible with your normal controller unless something is broken.\n\nThe controller value can then be compared to the values above to decide what to do next, move the player perhaps.\n\n</pre>\n\n== Reading the four console buttons ==\n\nThere's a routine in the Channel F firmware that can be used directly if needed.<br>\nIt starts at $00C1, stores the result in register 4, register 5 and 6 are also used. \n\nPort 0 needs to be cleared at least once in the code before reading buttons:\n<pre>\n                clr\n                outs\t0\n</pre>\n\n<pre>\nreadbuts:       ins  0                    ; $00C1 - read buttons\n                com                       ; Invert port data, 1 now means pushed\n                ni   $0F                  ; Just keep button data\n                bz   readbuts             ; \n                lr   $4, A                ; Button indata now in r4\n\n                li   $FF                  ; Set r5 to $FF and decrease it\n                lr   5, A                 ; \ndebounce:       ds   5                    ; \n                bnz  debounce             ; \n\n                br   delay                ; Also do a delay (for some reason)\n\n                ; Delay routine is located earlier in the code:\n\ndelay:          li   $FF                  ;$008F - parameter in r5, uses r6\n                lr   6, A                 ;\ndlyloop:        ds   6                    ;\n                bnz  dlyloop              ;\n                ds   5                    ; Loops another time if value is set in r5\n                bnz  delay                ;\n\n                pop                       ;\n</pre>\n\n\nIn your code you can now use the button data to check which buttons/combos are set.\n<pre>\n\tlr\tA, 4\t\t\t\t; load button result into Ackumulator again\n\tni\t%00000010\t\t\t; mask out button #2\n\tbnz\tmain.buttons.used.two\t\t; not zero means button 2 was pressed\n\tlr\tA, 4\t\t\t\t; load read result into A again\n\tni\t%00000001\t\t\t; check if it was button #1\n\tbnz\tmain.buttons.used.one\t\t; if that's not 0 it means button 1 was held\n\n\tbr\tmain.continue\t\t\t; continue program\n</pre>\n\nThe intelligent reader has already figured out the rest of the inputs available:\n\n<pre>\n-----4321\n%00000001  button 1\n%00000010  button 2\n%00000011\n%00000100  button 3\n%00000101\n%00000110\n%00000111\n%00001000  button 4\n%00001001\n%00001010\n%00001011\n%00001100  button 4 + 3\n%00001101\n%00001110\n%00001111   all buttons pressed\n</pre>\n\n== Quickest controller read ==\n<pre>\nreadController:\n\tclr\n\touts\t0\n\touts\t1\n\tins\t1\n\tpop\n</pre>\n\nThis one only reads data for right controller as port read is faster on the CPU where right controller is hooked up. \nData is not inverted, for an active movement the bit is set to 0, any masking is done in the main program if needed.\n\n\n== Conclusion ==\n\nRead right hand controller this way:\n<pre>\n\tclr\n\touts\t0\n\touts\t1\n\tins\t1\n\tcom\t\t\n</pre>\n\nRead left hand controller this way:\n<pre>\n\tclr\n\touts\t4\n\tins\t4\n\tcom\n\n</pre>\n\nRead buttons with:\n\n<pre>\n\tclr\n\touts\t0\n\tins\t0\n\tcom\n\n\t; you may need to debounce as described above\n</pre>\n\n'''And you have the result in A'''"
                    }
                ]
            },
            "58": {
                "pageid": 58,
                "ns": 0,
                "title": "Register",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "There are two types of registers in the Channel F. The first type are the 64 bytes of [[RAM]], located on the [[F8]] itself, called the [[scratchpad registers]]. These can be used in mathematical computations or to store data. The second type of registers in the F8 are the working registers. These are the [[accumulator]], [[ISAR]], [[status register]], [[data counter]], and [[program counter]], which are internal registers that fill certain roles in the F8.\n\nThe scratchpad registers can be accessed in one of two ways. The first way is to specify the number of the register, which can be from 0-11, or to use the register name where allowed ''(see below)'' to access registers directly. Numbers 12, 13 and 14 are used to address ISAR and is the same as S, I and D which means ISAR directly, ISAR and then increased and finally ISAR that is then decreased, these numbers are not used to address registers 12,13 and 14. \nRegisters 16-63 can't be accessed in this direct manner but can only be accessed via the '''ISAR'''. You can load the ISAR with two octal numbers specifying which of the 64 scratchpad registers you want to use. Register 16-23 has the octal address 20-27, register 24-31 are octal 30-37, etc until the last one that is octal 77 (register 63, the 64th register).\n\n== Register Reference ==\n\nBelow is a table showing how registers can be accessed and transferred:\n\n<table border=\"1\" cellspacing=\"1\" cellpadding=\"4\" style=\"width: 75%\">\n\n <tr>\n  <th colspan=\"2\">''LR'' Instruction Operands</th>\n  <th rowspan=\"2\">Loads Register</th>\n  <th rowspan=\"2\">From Register</th>\n\n  <th rowspan=\"2\">With</th>\n </tr>\n\n <tr>\n  <th>Destination</th>\n\n  <th>Source</th>\n </tr>\n\n <tr>\n  <td>A</td>\n\n  <td>KU</td>\n  <td>Accumulator</td>\n  <td>Scratchpad register 12</td>\n  <td>8-bit contents</td>\n\n </tr>\n\n <tr>\n  <td>A</td>\n  <td>KL</td>\n\n  <td>Accumulator</td>\n  <td>Scratchpad register 13</td>\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n  <td>A</td>\n  <td>QU</td>\n  <td>Accumulator</td>\n\n  <td>Scratchpad register 14</td>\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n\n  <td>A</td>\n  <td>QL</td>\n  <td>Accumulator</td>\n  <td>Scratchpad register 15</td>\n\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n  <td>KU</td>\n\n  <td>A</td>\n  <td>Scratchpad register 12</td>\n  <td>Accumulator</td>\n  <td>8-bit contents</td>\n\n </tr>\n\n <tr>\n  <td>KL</td>\n  <td>A</td>\n\n  <td>Scratchpad register 13</td>\n  <td>Accumulator</td>\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n  <td>QU</td>\n  <td>A</td>\n  <td>Scratchpad register 14</td>\n\n  <td>Accumulator</td>\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n\n  <td>QL</td>\n  <td>A</td>\n  <td>Scratchpad register 15</td>\n  <td>Accumulator</td>\n\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n  <td>K</td>\n\n  <td>P</td>\n  <td>\nScratchpad register 12<br/>\nScratchpad register 13\n  </td>\n  <td>\n\nProgram counter PC1<br />\nProgram counter PC1\n  </td>\n  <td>\nHigh order 8-bit byte<br />\nLow order 8-bit byte\n  </td>\n </tr>\n\n <tr>\n  <td>P</td>\n  <td>K</td>\n  <td>\n\nHigh order byte of PC1<br />\nLow order byte of PC1\n  </td>\n  <td>\nScratchpad register 12<br />\nScratchpad register 13\n  </td>\n  <td>\n\n8-bit contents\n8-bit contents\n  </td>\n </tr>\n\n <tr>\n  <td>A</td>\n  <td>IS</td>\n\n  <td>Accumulator</td>\n  <td>ISAR</td>\n  <td>Low order 6-bits</td>\n </tr>\n\n <tr>\n  <td>IS</td>\n  <td>A</td>\n  <td>&nbsp;</td>\n\n  <td>Accumulator</td>\n  <td>\n00XXXXXX<br />\nX's are ISAR contents\n  </td>\n </tr>\n\n <tr>\n  <td>P0</td>\n  <td>Q</td>\n  <td>\n\nHigh order byte of PC0<br />\nLow order byte of PC0\n  </td>\n  <td>\nScratchpad register 14<br />\nScratchpad register 15\n  </td>\n  <td>\n\n8-bit contents<br />\n8-bit contents\n  </td>\n </tr>\n\n <tr>\n  <td>Q</td>\n\n  <td>DC</td>\n  <td>\nScratchpad register 14<br />\nScratchpad register 15\n  </td>\n  <td>\n\nData counter registers DC0<br />\nData counter registers DC0\n  </td>\n  <td>\nHigh order byte<br />\nLow order byte\n  </td>\n </tr>\n\n <tr>\n  <td>DC</td>\n  <td>Q</td>\n  <td>\n\nHigh order byte of DC0<br />\nLow order byte of DC0\n  </td>\n  <td>\nScratchpad register 14<br />\nScratchpad register 15\n  </td>\n  <td>\n\n8-bit contents<br />\n8-bit contents\n  </td>\n </tr>\n\n <tr>\n  <td>DC</td>\n\n  <td>H</td>\n  <td>\nHigh order byte of DC0<br />\nLow order byte of DC0\n  </td>\n  <td>\n\nScratchpad register 10<br />\nScratchpad register 11\n  </td>\n  <td>\n8-bit contents<br />\n8-bit contents\n  </td>\n </tr>\n\n <tr>\n  <td>H</td>\n  <td>DC</td>\n  <td>\n\nScratchpad register<br />\nScratchpad register\n  </td>\n  <td>\nData counter register<br />\nData counter register\n  </td>\n  <td>\n\nHigh order byte<br />\nLow order byte\n  </td>\n </tr>\n\n <tr>\n  <td>W</td>\n\n  <td>J</td>\n  <td>Status register (W)</td>\n  <td>Scratchpad register 9</td>\n  <td>Low order 5 bits</td>\n\n </tr>\n\n <tr>\n  <td>J</td>\n  <td>W</td>\n\n  <td>Scratchpad register 9</td>\n  <td>Status register (W)</td>\n  <td>\n000X XXXX<br />\nX's are contents of status register\n  </td>\n\n </tr>\n\n <tr>\n  <td>A</td>\n  <td>(Sreg)*</td>\n\n  <td>Accumulator</td>\n  <td>Scratchpad register (Sreg)</td>\n  <td>8-bit contents</td>\n </tr>\n\n <tr>\n  <td>(Sreg)*</td>\n  <td>A</td>\n  <td>Scratchpad register (Sreg)</td>\n\n  <td>Accumulator</td>\n  <td>8-bit contents</td>\n </tr>\n</table>\n\n''* Sreg is either a digit representing a scratchpad register (0-15), or the letter S, I (increase) or D (decrease) for the ISAR addressed register. Instead of using S, I or D, you can also use 12, 13 or 14. Note that these letters don't adress scratchpad registers 12, 13 or 14, but is an alternative to S, I or D.''"
                    }
                ]
            }
        }
    }
}