Advertisement
Zeda

getByte

Aug 22nd, 2016
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. axe = 1
  2. #define bcall(x) rst 28h \ .dw x
  3. .db $BB,$6D
  4. .org $9D95
  5.     di
  6.     xor a
  7.     out (8),a
  8.     call getsync
  9.     ret nc
  10.     call getb \ ld l,a
  11.     ld h,0
  12. ;    call getb \ ld h,a
  13.     bcall(4792h)
  14.     bcall(4156h
  15.     bcall(4ABFh)
  16.     ret
  17. getsync:
  18.     ld a,$FE
  19.     out (1),a
  20.     in a,(1)
  21.     and 40h
  22.     ret z
  23.     in a,(0)
  24.     dec a
  25.     jp nz,$-8
  26.     scf
  27.     ret
  28.  
  29. getb:
  30. ;;I wrote a routine for a significant overhaul of Axe's routine.
  31. ;;The core part is a completely different design and algorithm, (much faster and somewhat smaller, just as accurate)
  32. ;;the syncing part at the beginning is mostly the same (but completely rewritten for this application).
  33.     or a
  34.     in a,(0)
  35.     dec a
  36.     ret nz          ;If not, then go back
  37.     inc a
  38.     out (0),a       ;Relay a confirmation
  39.     ex (sp),hl      ;Wait at until confirmation is read (59 T-states minimum)
  40.     ex (sp),hl
  41.     push bc
  42.     dec a           ;Store received byte in l
  43.     ld bc,$08AA     ;Bit counter in b, bit mask in c
  44.     out (0),a       ;Reset the ports to receive data
  45.  
  46. _:
  47.     in a,(0)
  48.     xor c
  49.     rra
  50.     jr c,-_
  51.     in a,(0)
  52.     rra
  53.     rra
  54.     rr c
  55.     djnz -_
  56.     ld a,c
  57.     pop bc
  58.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement