SHARE
TWEET

new_1.z80

a guest Dec 24th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define     progStart   $d000
  2. #define     usr         $f7f8
  3. #define     boardHi     $c0
  4. ;#define    board       boardHi||00
  5. #define     bonus       $c010
  6.  
  7. .org        progStart-7
  8.  
  9. ; Header
  10. .db         $fe
  11. .dw         progStart
  12. .dw         progEnd-1
  13. .dw         progStart
  14.  
  15. progStart:
  16.     ret
  17.  
  18. getAddress:
  19.     ld a, c
  20.     add a, a
  21.     add a, a
  22.     add a, b
  23.     ld l, a
  24.     lh h, boardHi
  25.     ret
  26.  
  27. setValue:
  28.     ex af, af'
  29.     call getAddress
  30.     ex af, af'
  31.     ld (hl), a
  32.     ret
  33.  
  34. getValue:
  35.     call getAddress
  36.     ld a, (hl)
  37.     ret
  38.  
  39. upBonus:
  40. powerOf2:
  41. ; 1 <= a <= 15
  42.     ld lh, 1
  43. po2_loop:
  44.     add hl, hl
  45.     dec a
  46.     jr nz, po2_loop
  47.     ex de, hl
  48.     ld hl, (bonus)
  49.     add hl, de
  50.     ld (bonus), hl
  51.     ret
  52.  
  53. zeroNext_Vertical:
  54.     push bc
  55.     ld b, e
  56.     xor a
  57.     call setValue
  58.     pop bc
  59.     ret
  60.  
  61. zeroNext_Horizontal:
  62.     push bc
  63.     ld c, e
  64.     xor a
  65.     call setValue
  66.     pop bc
  67.     ret
  68.  
  69. up:
  70.     ld c, 0
  71. up_startOuterLoop:
  72.     lb b, 0
  73. up_StartInnerLoop:
  74.     push bc
  75.     inc b
  76. up_findNext:
  77.     call getValue
  78.     cp 0
  79.     jrnz, up_foundNext
  80.     inc b
  81.     ld a, 3
  82.     cp b
  83.     jrc up_findNext
  84.     pop bc
  85.     jr up_endOuterLoop 
  86. up_foundNext:
  87.     ld d, a                 ; d = V1
  88.     ld e, b                 ; e = Y1
  89.     pop bc
  90.     call getValue           ; a = V
  91.     cp 0
  92.     jrnz, up_notZero
  93.     ld a, d
  94.     call setValue
  95.     call zeroNext_Vertical
  96.     ; push bc
  97.     ; ld b, e
  98.     ; inc b
  99.     ; jr up_findNext
  100.     jr up_startInnerLoop
  101. up_notZero:
  102.     cp d
  103.     jr up_endInnerLoop
  104.     inc a
  105.     call setValue
  106.     call upBonus
  107.     call zeroNext_Vertical
  108. up_endInnerLoop:
  109.     inc b
  110.     ld a, 2
  111.     cp b
  112.     jrnc, up_startInnerLoop
  113.  
  114. up_endOuterLoop:
  115.     inc c
  116.     ld a, 3
  117.     cp c
  118.     jrnc, up_startOuterLoop
  119.  
  120.     ret
  121.  
  122.    
  123. progEnd:
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top