Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   .macro delay_short
  2.     .if (\1 <= 13)
  3.       .if (\1 = 0)
  4.         ; nothing
  5.       .endif
  6.       .if (\1 = 2)
  7.         nop
  8.       .endif
  9.       .if (\1 = 3)
  10.         sta <delay_temp
  11.       .endif
  12.       .if (\1 = 4)
  13.         nop
  14.         nop
  15.       .endif
  16.       .if (\1 = 5)
  17.         sta <delay_temp
  18.         nop
  19.       .endif
  20.       .if (\1 = 6)
  21.         nop
  22.         nop
  23.         nop
  24.       .endif
  25.       .if (\1 = 7)
  26.         php
  27.         plp
  28.       .endif
  29.       .if (\1 = 8)
  30.         nop
  31.         nop
  32.         nop
  33.         nop
  34.       .endif
  35.       .if (\1 = 9)
  36.         php
  37.         plp
  38.         nop
  39.       .endif
  40.       .if (\1 = 10)
  41.         sta <delay_temp
  42.         php
  43.         plp
  44.       .endif
  45.       .if (\1 = 11)
  46.         php
  47.         plp
  48.         nop
  49.         nop
  50.       .endif
  51.       .if (\1 = 12)
  52.         sta <delay_temp
  53.         php
  54.         plp
  55.         nop
  56.       .endif
  57.       .if (\1 = 13)
  58.         php
  59.         plp
  60.         nop
  61.         nop
  62.         nop
  63.       .endif
  64.     .else
  65.       .if (\1 & 1)
  66.         sta <delay_temp
  67.         jsr delay_unrolled-((\1-15)/2)
  68.       .else
  69.         jsr delay_unrolled-((\1-12)/2)
  70.       .endif
  71.     .endif
  72.   .endm
  73.  
  74.  
  75. max_short_delay = 41
  76.  
  77.   .macro eatcycles
  78.     .if (\1 > max_short_delay)
  79.       php
  80.       pha
  81.       delay_nosave (\1 - 14)
  82.       pla
  83.       plp
  84.     .else
  85.       delay_short \1
  86.     .endif
  87.   .endm
  88.  
  89.   .macro delay_nosave
  90.     ; 255+27   = maximum delay using delay_a_25_clocks
  91.     ; 27       = minimum delay using delay_a_25_clocks
  92.  
  93.     .if (\1 >= 27)
  94.     lda #LOW(\1 - 27)
  95. ;    lda #<(\1 - 27)
  96.     jsr delay_a_25_clocks
  97.     .endif
  98.     .if (\1 < 27)
  99.     delay_short \1
  100.     .endif
  101.   .endm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement