Advertisement
AnthonyCagliano

Untitled

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