• A closer look at NEWPAD subrom routine

    08/27/2019 at 05:26 0 comments

    After spent some time unsuccessfully looking for precise information about the Mouse protocol used by MSX computers I got a subrom binary to disassemble and take a look.

    Mouse reading is performed by NEWPAD subroutine at address 0x1ad but the reading effectively occurs after addres 0x3509:

    The Mouse routine reads 6 nibbles (0..5) in sequence, cadenced by the (toggling of) pin 8. Small delay loops are inserted between readings. Both the Mouse and the Trackball reset their internal counters after one edge of the Pulse signal.

    The 5h nibble read might be the High order nibble for the Mouse or the delta Y value for a trackball. 

    Given the typical DPI resolution of the MSX mouse no displacement above 16 steps should be observed, then the expected value for the 5th nibble should be 0b0000 for positive displacement or 0b1111 for negative displacement.

    The trackball is a much less resolution device and uses solely 4 bits, nevertheless as the mouse only a small amount of displacement should be observed (zero or one count up/down). 

    One of the curious aspects of the trackball is that it uses an inverted sign bit, which means "0" displacement is represented by 0b1000, and that is the key for the NEWPAD routine to differentiate a trackball from a mouse. 

    ; Nibble 5:  Trackball: Delta Y, inverted Sign bit
    ;            (7) 0111  (-1) minus one
    ;            (8) 1000  ( 0) zero
    ;            (9) 1001  (+1) one plus
    ;            Mouse: Delta X high nibble, normal sign bit 
    ;            ( 0) 0000  ( 0) Zero 
    ;            (15) 1111  (-1) Minus one
    xor 08h    ; Turn values 7, 8, 9 into 15, 0 and 1
    sub 02h    ; Turn 15, 0 and 1 into 13, 14 and 15
    cp 0dh     ; Trackball should greater or equal 13
    jr c,returnMouse ; values less than 13

    The brief positive pulse issued after the 6th nibble is read has the purpose of reset the internal Y counter of a mouse, as registers should be read in pairs (4 nibbles).

  • SMS Paddles on Sinclair ZX computers

    07/23/2019 at 04:50 0 comments

    Sinclai ZX computers (ZX81/Spectrum) don't ship with a joystick port but they can count on the ubiquitous Kempston interface to provide 4 directional lines plus 3 buttons and that is more than enough to connect a Sega Master System HPD-200 paddle controller.

    Paddle detection and reading code provided by SMS POWER. I/O address changed to match Kempston (0x1F), though.

    A simple hardware adapter is necessary in between the Kempston interface and the HPD-200 paddle

    An alternative for the HPD-200 is to build a DIY SMS/MarkIII paddle controller by Raphaël Assénat. In such case the wiring can be modified to route the  signals from  pins 5,7 and 9 thus dispensing the use of the adapter.

    Example code (work still in progress) available at my github repository.

  • CP297s

    07/02/2019 at 00:37 0 comments

    PCB for ZX97 lite on a CP200s case. Kicad files available at github