Advertisement
Guest User

hello.z80

a guest
May 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; doctorxyz 2018.05.20
  2. ; Patch p/ Carmen Sandiego
  3. ; Objetivo: O mouse funcionar na porta 1 do Zemmix (MSX 2+) e no Sony HB-FS1 (MSX 2)
  4. ; compilador online via http://clrhome.org/asm/
  5. ; codigo asm baseado em https://www.msx.org/wiki/Mouse/Trackball
  6. ; (Direct usage of mouse) para porta 1
  7. ; injetar no endereço $4166 do CARMEM.COM ou $EC66 do DSK
  8. ; padrão para achar via XVI32 -> 2A 47 CE 11 01 00 B7 ED 52 C2 8A 41
  9.  
  10. .org        $416F
  11.         JP NZ, GTMOUSP2
  12. GTMOUSP1:
  13.         LD    D,$93     ; Values for a mouse in port 1
  14.         LD    E,$10
  15.         JP GTMOUS
  16. GTMOUSP2:
  17.         LD    D,$EC     ; Values for a mouse in port 2
  18.         LD    E,$20
  19.         JP GTMOUS
  20. GTMOUS:
  21.         PUSH BC
  22.         LD    B, 30          ; Long delay for first read
  23.         CALL  GTOFS2          ; Read bit 7-4 of the x-offset
  24.         AND   0FH
  25.         RLCA
  26.         RLCA
  27.         RLCA
  28.         RLCA
  29.         LD    C,A
  30.         CALL  GTOFST          ; Read bit 3-0 of the x-offset
  31.         AND   $0F
  32.         OR    C
  33.         ld      ($C976), a             ; Store combined x-offset
  34.         CALL  GTOFST          ; Read bit 7-4 of the y-offset
  35.         AND   $0F
  36.         RLCA
  37.         RLCA
  38.         RLCA
  39.         RLCA
  40.         LD    C,A
  41.         CALL  GTOFST          ; Read bit 3-0 of the y-offset
  42.         AND   $0F
  43.         OR    C
  44.         ld      ($C975), a             ; Store combined y-offset
  45.         POP BC
  46.         JP $41DB
  47.  
  48. GTOFST:
  49.         LD    B, 10            ; Short delay
  50. GTOFS2:
  51.         LD    A,15            ; Read psg register 15 voor mouse
  52.         OUT   ($A0),A
  53.         LD    A,D
  54.         OUT   ($A1),A
  55.         XOR   E
  56.         LD    D,A
  57.  
  58. WAIT:
  59.         DJNZ  WAIT           ; Extra delay because the mouse is slow.
  60.  
  61.         LD    A,14
  62.         OUT   ($A0),A
  63.         IN    A,($A2)
  64.         RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement