Original author: Pierre Sarrazin. Preserve upstream GPLv3-or-later and file-specific notices. Source: http://sarrazip.com/dev/coco-planes-0.1.0.tar.gz Archive SHA-256: 29191e6ba225965caa637ee726e1189639dc7fcdf2b68310fb93fbffd56c9c52
52 lines
967 B
C
52 lines
967 B
C
#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
|
|
}
|