Geekboy

Untitled

Mar 30th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. keyreaderplus:
  2. ;The original scheme was a "FlexInt" that ran the menu code twice per cycle,
  3. ;allowing or running the keyreader twice each game cycle. Really ingenious.
  4. ;And very fast.
  5.  
  6. ; call keyreader
  7. ; ld hl,(keyread)
  8. ; ld a,(keyoutput)
  9. ; push hl
  10. ;  push af
  11. ;   ld hl,$FFFF
  12. ;   ld (keyread),hl
  13. ;   ld a,$FF
  14. ;   ld (keyoutput),a
  15. ;   ld hl,_
  16. ;   push hl
  17. ;   ld hl,(islotbank+3)
  18. ;   jp (hl)
  19. ;_ pop af
  20. ; pop hl
  21. ; ld (keyread),hl
  22. ; ld (keyoutput),a
  23. ; ret
  24. keyreader:
  25.  push hl
  26.   call getkey
  27.   cpl
  28.   or a
  29.   jr nz,$+6
  30.   res keyprimed,(iy+sysflags)
  31.   cpl
  32.   bit keyprimed,(iy+sysflags)
  33.   jr nz,gkwreset-2   ;wait until keypad is completely released
  34.   ld l,a
  35.   ld a,(keyread)
  36.   cp L
  37.   jr nz,gkwreset    ;if previous key does not match, set this key instead.
  38.   ld hl,(keyread)   ;H=keywait. A=copy
  39.   dec h
  40.   jr nz,gkwdonotdokey  ;reset key if counter isn't up.
  41.   ld h,5
  42.   ld (keyread),hl
  43.   ld a,l
  44.   ld (keyoutput),a
  45.  pop hl
  46.  ret
  47.   ld l,$FF
  48. gkwreset:
  49.   ld a,14
  50.   ld (keywait),a
  51.   ld a,l
  52.   ld (keyread),a
  53.   ld (keyoutput),a
  54.  pop hl
  55.  ret
  56. gkwdonotdokey:
  57.   ld a,$FF
  58.   ld (keyread),hl
  59.   ld (keyoutput),a
  60.  pop hl
  61.  ret
  62. getkey:
  63.  ld a,$FF
  64.  out (1),a
  65.  push hl \ pop hl
  66.  ld a,$BE
  67.  out (1),a
  68.  push hl \ pop hl  ;11    ;| /  7    6   5   4  3   2    1    0
  69.  in a,(1)          ;11 22 ;|/  del mode 2nd y= up right left down
  70.  ret
Advertisement
Add Comment
Please, Sign In to add comment