Advertisement
AnthonyCagliano

Untitled

Jan 3rd, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. calcScore:
  2. ld hl,dieValues-1
  3. call getDieValue
  4. call getDieValue
  5. call getDieValue
  6. call getDieValue
  7. call getDieValue
  8. ; now we test the combo that is active. Score is either returned, or 0.
  9. ld a,(selectedCombo)
  10. or a \ jr z,isThreeOnes
  11. cp threeTwos \ jr z,isThreeTwos
  12. cp threeThrees \ jr z,isThreeThrees
  13. cp threeFours \ jr z,isThreeFours
  14. cp threeFives \ jr z,isThreeFives
  15. cp threeSixes \ jr z,isThreeSixes
  16. cp threeOfaKind \ jr z,isThreeOfaKind
  17. cp fourOfaKind \ jr z,isFourOfaKind
  18. cp fullHouse \ jr z,isFullHouse
  19. cp smStraight \ jr z,isSmStraight
  20. cp lgStraight \ jr z,isLgStraight
  21. cp chance \ jr z,isChance
  22. cp yatzee \ jr z,isYatzee
  23. showScore:
  24. ; render the possible score for this combo
  25. ret
  26.  
  27. isThreeOnes:
  28. ld a,(ctOnes)
  29. jr showScore
  30. isThreeTwos:
  31. ld a,(ctTwos)
  32. rla
  33. jr showScore
  34. isThreeThrees:
  35. ld a,(ctThrees)
  36. ld b,a \ rla \ add a,b
  37. jr showScore
  38. isThreeFours:
  39. ld a,(ctFours)
  40. rla \ rla
  41. jr showScore
  42. isThreeFives:
  43. ld a,(ctFives)
  44. ld b,a \ rla \ rla \ add a,b
  45. jr showScore
  46. isThreeSixes:
  47. ld a,(ctSixes)
  48. rla \ rla \ rla
  49. jr showScore
  50. isThreeOfaKind:
  51. ld a,2 \ jr {1@}
  52. isFourOfaKind:
  53. ld a,3
  54. @: ld hl,ctOnes-1
  55. call checkQty
  56.  
  57.  
  58. checkQty:
  59. inc hl \ ld b,a \ ld a,(hl)
  60. cp b \
  61.  
  62.  
  63.  
  64.  
  65. isChance:
  66. call sumtheDie
  67. jr showScore
  68.  
  69.  
  70.  
  71.  
  72. sumtheDie:
  73. ld hl,0 \ push ix \ dec ix \ ld b,5
  74. @: inc ix
  75. push bc \ ld b,0
  76. ld a,(iy) \ ld c,a \ add hl,bc
  77. pop bc \ djnz {-1@}
  78. pop ix \ ld a,l
  79.  
  80.  
  81.  
  82.  
  83. getDieValue:
  84. inc hl
  85. ld a,(hl) \ and %01111111 ; reset high byte in A, not in memory
  86. cp 1 \ jr nz,{1@}
  87. ld a,(ctOnes) \ inc a \ ld (ctOnes),a \ ret
  88. @: cp 2 \ jr nz,{1@}
  89. ld a,(ctTwos) \ inc a \ ld (ctTwos),a \ ret
  90. @: cp 3 \ jr nz,{1@}
  91. ld a,(ctThrees) \ inc a \ ld (ctThrees),a \ ret
  92. @: cp 4 \ jr nz,{1@}
  93. ld a,(ctFours) \ inc a \ ld (ctFours),a \ ret
  94. @: cp 5 \ jr nz,{1@}
  95. ld a,(ctFives) \ inc a \ ld (ctFives),a \ ret
  96. @: cp 6 \ ret nz
  97. ld a,(ctSixes) \ inc a \ ld (ctSixes),a \ ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement