#include "Score.h" #include "util.h" void Score_init(Score *self) { * (word *) self->digits = 0; } __gcccall void Score_addPoint(Score *self) { if (Score_isWinningScore(self)) return; byte *p = self->digits; if (p[1] == 9) { p[1] = 0; ++p[0]; } else ++p[1]; } __gcccall BOOL asm Score_isWinningScore(const Score *self) { #if 0 /* Original C code. */ const byte *p = self->digits; return p[0] == WINNING_SCORE / 10 && p[1] == WINNING_SCORE % 10; #else asm { ; X is 'self' b/c __gcccall. ldb ,x ; digits[0], i.e., tens cmpb #WINNING_SCORE/10 bne @no ldb 1,x ; digits[1], i.e., units cmpb #WINNING_SCORE%10 bne @no ldb #1 ; return TRUE rts @no clrb ; return FALSE } #endif }