Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- calcScore:
- ld hl,dieValues-1
- call getDieValue
- call getDieValue
- call getDieValue
- call getDieValue
- call getDieValue
- ; now we test the combo that is active. Score is either returned, or 0.
- ld a,(selectedCombo)
- or a \ jr z,isThreeOnes
- cp threeTwos \ jr z,isThreeTwos
- cp threeThrees \ jr z,isThreeThrees
- cp threeFours \ jr z,isThreeFours
- cp threeFives \ jr z,isThreeFives
- cp threeSixes \ jr z,isThreeSixes
- cp threeOfaKind \ jr z,isThreeOfaKind
- cp fourOfaKind \ jr z,isFourOfaKind
- cp fullHouse \ jr z,isFullHouse
- cp smStraight \ jr z,isSmStraight
- cp lgStraight \ jr z,isLgStraight
- cp chance \ jr z,isChance
- cp yatzee \ jr z,isYatzee
- showScore:
- ; render the possible score for this combo
- ret
- isThreeOnes:
- ld a,(ctOnes)
- jr showScore
- isThreeTwos:
- ld a,(ctTwos)
- rla
- jr showScore
- isThreeThrees:
- ld a,(ctThrees)
- ld b,a \ rla \ add a,b
- jr showScore
- isThreeFours:
- ld a,(ctFours)
- rla \ rla
- jr showScore
- isThreeFives:
- ld a,(ctFives)
- ld b,a \ rla \ rla \ add a,b
- jr showScore
- isThreeSixes:
- ld a,(ctSixes)
- rla \ rla \ rla
- jr showScore
- isThreeOfaKind:
- ld a,2 \ jr {1@}
- isFourOfaKind:
- ld a,3
- @: ld hl,ctOnes-1
- call checkQty
- checkQty:
- inc hl \ ld b,a \ ld a,(hl)
- cp b \
- isChance:
- call sumtheDie
- jr showScore
- sumtheDie:
- ld hl,0 \ push ix \ dec ix \ ld b,5
- @: inc ix
- push bc \ ld b,0
- ld a,(iy) \ ld c,a \ add hl,bc
- pop bc \ djnz {-1@}
- pop ix \ ld a,l
- getDieValue:
- inc hl
- ld a,(hl) \ and %01111111 ; reset high byte in A, not in memory
- cp 1 \ jr nz,{1@}
- ld a,(ctOnes) \ inc a \ ld (ctOnes),a \ ret
- @: cp 2 \ jr nz,{1@}
- ld a,(ctTwos) \ inc a \ ld (ctTwos),a \ ret
- @: cp 3 \ jr nz,{1@}
- ld a,(ctThrees) \ inc a \ ld (ctThrees),a \ ret
- @: cp 4 \ jr nz,{1@}
- ld a,(ctFours) \ inc a \ ld (ctFours),a \ ret
- @: cp 5 \ jr nz,{1@}
- ld a,(ctFives) \ inc a \ ld (ctFives),a \ ret
- @: cp 6 \ ret nz
- ld a,(ctSixes) \ inc a \ ld (ctSixes),a \ ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement