Commit 00a69c8f authored by Florian Ernst's avatar Florian Ernst

New upstream version 8.1.0

parent 74e37670
/*
* @(#)Abacus.c
*
* Copyright 1994 - 2016 David A. Bagley, bagleyd AT verizon.net
* Copyright 1994 - 2017 David A. Bagley, bagleyd AT verizon.net
*
* All rights reserved.
*
......@@ -29,7 +29,7 @@ static Boolean deleteSpecialRail(AbacusWidget w,
#ifdef WINVER
#ifndef SCRIPTFILE
#define SCRIPTFILE "Abacus.les"
#define SCRIPTFILE "abacus.xml"
#endif
#ifndef INIFILE
......@@ -123,6 +123,10 @@ static void moveAbacusLeft(AbacusWidget w,
static void moveAbacusRight(AbacusWidget w,
XEvent *event, char **args, int nArgs);
/* 0x1B escape, 0x20 = space,
0x2C = comma, 0x2E = period,
0x3E greater than, 0x3C = less than */
static char translations[] =
"<KeyPress>q: Quit()\n\
Ctrl<KeyPress>C: Quit()\n\
......@@ -1313,7 +1317,7 @@ checkBeads(AbacusWidget w)
}
if (w->abacus.decks[TOP].factor < 1 ||
w->abacus.decks[TOP].factor > w->abacus.base) {
intCat(&buf1, "Factor of Top Beads out of bounds, use 1..",
intCat(&buf1, "Factor of Top Beads out of bounds, use 1 to ",
w->abacus.base);
DISPLAY_WARNING(buf1);
free(buf1);
......@@ -1323,7 +1327,7 @@ checkBeads(AbacusWidget w)
w->abacus.decks[BOTTOM].factor >
w->abacus.base) {
intCat(&buf1,
"Factor of Bottom Beads out of bounds, use 1..",
"Factor of Bottom Beads out of bounds, use 1 to ",
w->abacus.base);
DISPLAY_WARNING(buf1);
free(buf1);
......@@ -1332,7 +1336,7 @@ checkBeads(AbacusWidget w)
}
if (w->abacus.decks[TOP].number < 0 ||
w->abacus.decks[TOP].number > w->abacus.base) {
intCat(&buf1, "Number of Top Beads out of bounds, use 1..",
intCat(&buf1, "Number of Top Beads out of bounds, use 1 to ",
w->abacus.base);
DISPLAY_WARNING(buf1);
free(buf1);
......@@ -1340,7 +1344,7 @@ checkBeads(AbacusWidget w)
}
if (w->abacus.decks[BOTTOM].number < 0 ||
w->abacus.decks[BOTTOM].number > w->abacus.base) {
intCat(&buf1, "Number of Bottom Beads out of bounds, use 1..",
intCat(&buf1, "Number of Bottom Beads out of bounds, use 1 to ",
w->abacus.base);
DISPLAY_WARNING(buf1);
free(buf1);
......@@ -1376,7 +1380,7 @@ checkMove(AbacusWidget w)
if (w->abacus.deck < 0 || w->abacus.deck > 2) {
intCat(&buf1, "Corrupted deck input value ", w->abacus.deck);
stringCat(&buf2, buf1, " out of bounds, use 0..2, ignoring");
stringCat(&buf2, buf1, " out of bounds, use 0 to 2, ignoring");
free(buf1);
DISPLAY_WARNING(buf2);
free(buf2);
......@@ -1401,7 +1405,7 @@ checkMove(AbacusWidget w)
free(buf1);
intCat(&buf1, buf2, -w->abacus.decimalPosition);
free(buf2);
stringCat(&buf2, buf1, "..");
stringCat(&buf2, buf1, " to ");
free(buf1);
intCat(&buf1, buf2, w->abacus.rails -
w->abacus.decimalPosition);
......@@ -1420,16 +1424,22 @@ checkMove(AbacusWidget w)
w->abacus.number > deck_position)) {
intCat(&buf1, "Corrupted number for input value ",
w->abacus.number);
stringCat(&buf2, buf1, " out of bounds, use ");
free(buf1);
intCat(&buf1, buf2, -deck_number + deck_position);
free(buf2);
stringCat(&buf2, buf1, "..");
if (deck_number == 0) {
stringCat(&buf2, buf1, " out of bounds, use only 0 for deck.");
} else {
stringCat(&buf2, buf1, " out of bounds, use ");
intCat(&buf1, buf2, deck_position);
free(buf1);
intCat(&buf1, buf2, -deck_number + deck_position);
free(buf2);
stringCat(&buf2, buf1, " to ");
free(buf1);
intCat(&buf1, buf2, deck_position);
stringCat(&buf2, buf1, " for deck.");
}
free(buf1);
intCat(&buf1, buf2, deck_position);
DISPLAY_WARNING(buf2);
free(buf2);
DISPLAY_WARNING(buf1);
free(buf1);
return False;
}
if (!w->abacus.decks[w->abacus.deck].orientation &&
......@@ -1437,16 +1447,24 @@ checkMove(AbacusWidget w)
w->abacus.number > deck_number - deck_position)) {
intCat(&buf1, "Corrupted number for input value ",
w->abacus.number);
stringCat(&buf2, buf1, " out of bounds, use ");
free(buf1);
intCat(&buf1, buf2, -deck_position);
free(buf2);
stringCat(&buf2, buf1, "..");
if (deck_number == 0) {
stringCat(&buf2, buf1, " out of bounds, use only 0 for deck.");
free(buf1);
DISPLAY_WARNING(buf2);
free(buf2);
} else {
stringCat(&buf2, buf1, " out of bounds, use ");
free(buf1);
intCat(&buf1, buf2, -deck_position);
free(buf2);
stringCat(&buf2, buf1, " to ");
free(buf1);
intCat(&buf1, buf2, deck_number - deck_position);
stringCat(&buf2, buf1, " for deck.");
}
free(buf1);
intCat(&buf1, buf2, deck_number - deck_position);
DISPLAY_WARNING(buf2);
free(buf2);
DISPLAY_WARNING(buf1);
free(buf1);
return False;
}
return True;
......@@ -1757,13 +1775,17 @@ setResultRegister(AbacusWidget w, int deck, int rail, int number)
#if DEBUG
(void) printf("setResultRegister: buffer %s\n", buffer);
#endif
if (w->abacus.script) {
if (w->abacus.script && (deck != 0 || number != 0)) {
#ifdef WINVER
(void) fprintf(w->abacus.fp, "%d %d %d %d 4\n",
(void) fprintf(w->abacus.fp, " <move>\n");
(void) fprintf(w->abacus.fp, " <code>%d %d %d %d 4</code>\n",
PRIMARY, deck,
rail - w->abacus.decimalPosition, number);
(void) fprintf(w->abacus.fp,
"Lesson\n\n\nPress Space-bar to Continue\n");
(void) fprintf(w->abacus.fp, " <text>\n");
(void) fprintf(w->abacus.fp, " Lesson\n\n\n");
(void) fprintf(w->abacus.fp, " Press Space-bar to Continue\n");
(void) fprintf(w->abacus.fp, " </text>\n");
(void) fprintf(w->abacus.fp, " </move>\n");
#else
setAbacusMove(w, ACTION_SCRIPT,
w->abacus.aux, deck,
......@@ -3440,7 +3462,7 @@ placeCounters(AbacusWidget w, int deck, int rail, int number)
drawCounters(w, deck, rail, newNumber, True, False);
#ifdef USE_SOUND
if (number != 0 && w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
if (number < 0) {
......@@ -3468,7 +3490,7 @@ removeAllCounters(AbacusWidget w, int deck, int rail)
drawCounters(w, deck, rail, number, False, False);
#ifdef USE_SOUND
if (number != 0 && w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
subBead(w, number * getFactor(w, deck, rail), rail);
......@@ -3532,7 +3554,7 @@ moveUp(AbacusWidget w, const int deck, const int rail, const int j,
}
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
if (checkSubdeck(w, 3) && rail == w->abacus.decimalPosition - 2) {
......@@ -3605,7 +3627,7 @@ moveDown(AbacusWidget w, const int deck, const int rail, const int j,
}
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
if (checkSubdeck(w, 3) && rail == w->abacus.decimalPosition - 2) {
......@@ -3796,7 +3818,7 @@ moveCounters(AbacusWidget w) {
setResultRegister(w, w->abacus.currentDeck, w->abacus.currentRail, counters);
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
return True;
......@@ -4029,7 +4051,7 @@ moveBeadsByPos(AbacusWidget w, const int deck, const int rail, const int pos,
setResultRegister(w, deck, rail, number - bead);
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) BUMPSOUND);
playSound(BUMPSOUND);
}
#endif
} else {
......@@ -4577,7 +4599,7 @@ setDecimal(AbacusWidget w, int newRail)
setResultRegister(w, 0, w->abacus.decimalPosition, 0);
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) MOVESOUND);
playSound(MOVESOUND);
}
#endif
}
......@@ -5291,7 +5313,7 @@ reformatRails(AbacusWidget w)
}
#ifdef USE_SOUND
if (w->abacus.sound) {
playSound((char *) DRIPSOUND);
playSound(DRIPSOUND);
}
#endif
(void) strcpy(buffer, w->abacus.digits);
......@@ -5324,12 +5346,13 @@ static void
formatRails(AbacusWidget w)
{
Boolean other = False;
if (w->abacus.mode < CHINESE || w->abacus.mode >= GENERIC) {
if (w->abacus.mode >= GENERIC) {
w->abacus.mode = CHINESE;
if (w->abacus.demo)
other = True;
} else
} else {
w->abacus.mode = (w->abacus.mode + 1) % MAX_FORMATS;
}
/*if (w->abacus.demo && w->abacus.mode == GENERIC) {
w->abacus.mode = CHINESE;
}*/
......@@ -6726,6 +6749,7 @@ selectAbacus(AbacusWidget w
clearAbacusDemo(w);
#endif
w->abacus.currentDeck = IGNORE_DECK;
w->abacus.currentPosition = ACTION_IGNORE;
return;
}
int offset = (w->abacus.mode == MEDIEVAL) ?
......
......@@ -334,9 +334,9 @@ typedef struct {
#define CHINESE 0
#define JAPANESE 1
#define KOREAN 2
#define ROMAN 3
#define RUSSIAN 4
#define DANISH 5
#define RUSSIAN 3
#define DANISH 4
#define ROMAN 5
#define MEDIEVAL 6
#define GENERIC 7
#define MAX_FORMATS 7
......
/*
* @(#)AbacusC.c
*
* Copyright 1992 - 2016 David A. Bagley, bagleyd AT verizon.net
* Copyright 1992 - 2017 David A. Bagley, bagleyd AT verizon.net
*
* All rights reserved.
*
......@@ -1089,7 +1089,7 @@ inputNumeric(char input)
}
void
convertStringToAbacus(AbacusWidget w, char *string, int aux)
convertStringToAbacus(AbacusWidget w, const char *string, int aux)
{
int decimal = 0;
int num, factor, i, sign = 0, len = (int) strlen(string);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* @(#)AbacusP.h
*
* Copyright 1994 - 2016 David A. Bagley, bagleyd AT verizon.net
* Copyright 1994 - 2017 David A. Bagley, bagleyd AT verizon.net
*
* Abacus demo and neat pointers from
* Copyright 1991 - 1998 Luis Fernandes, elf AT ee.ryerson.ca
......@@ -95,7 +95,7 @@ extern void showNextAbacusDemo(AbacusWidget w);
extern void showRepeatAbacusDemo(AbacusWidget w);
extern void showJumpAbacusDemo(AbacusWidget w);
extern void showMoreAbacusDemo(AbacusWidget w);
extern void showChapterAbacusDemo(AbacusWidget w, int chapt);
extern void showChapterAbacusDemo(AbacusWidget w, unsigned int chapt);
#else
extern Pixel darker(AbacusWidget w, Pixel pixel);
......@@ -134,6 +134,9 @@ extern AbacusClassRec abacusClassRec;
#ifndef DRIPSOUND
#define DRIPSOUND "drip"
#endif
#ifndef XML_FILE
#define XML_FILE "abacusDemo.xml"
#endif
#define MAX_DECKS 2
#define PLACE_SETTING 2
......@@ -212,7 +215,8 @@ typedef struct _AbacusPart {
int subdeck, subbead, subbase;
int shiftPercent, shiftAnomaly, shiftAnomalySq;
int groupSize, anomaly, anomalySq;
int delay, numSlices, mode, submode, colorScheme, railIndex;
unsigned int mode;
int delay, numSlices, submode, colorScheme, railIndex;
int leftAuxRails, rightAuxRails;
int aux, deck, rail, number;
Position middleBarHeight, middleBarPositionY, railWidth;
......@@ -261,12 +265,11 @@ typedef struct _AbacusPart {
} AbacusPart;
typedef struct _AbacusDemoPart {
int chapterCount;
int lessons[CHAPTERS], lessonLength, lessonCount;
unsigned int bookCount, chapterCount, lessonCount, moveCount;
int aux, deck, rail, number, lines;
int fontHeight;
FILE *fp;
Boolean chapter, query, started, framed;
Boolean book, chapter, query, started, framed;
GC foregroundGC;
#ifdef WINVER
char path[STRING_SIZE];
......@@ -285,6 +288,54 @@ typedef struct _AbacusRec {
AbacusDemoPart abacusDemo;
} AbacusRec;
struct moveType {
char *code;
unsigned int lines;
char **lineText;
};
struct lessonType {
char *name;
unsigned int moves;
struct moveType *move;
};
struct chapterType {
char *name;
unsigned int lessons;
struct lessonType *lesson;
};
struct editionType {
char *version;
unsigned int chapters;
struct chapterType *chapter;
};
struct bookType {
char *name;
char *author;
unsigned int editions;
struct editionType *edition;
};
struct libraryType {
unsigned int books;
struct bookType *book;
};
struct libraryType abacusLibrary;
extern unsigned int getFallbackBooks(void);
extern unsigned int getFallbackEditions(void);
extern unsigned int getFallbackChapters(void);
extern unsigned int getFallbackLessons(unsigned int chapter);
extern unsigned int getFallbackMoves(unsigned int edition, unsigned int chapter, unsigned int lesson);
extern const char *bookTextFallback[1][LINES];
extern const char *chapterTextFallback[1][5][LINES];
extern const char *lessonTextFallback[1][4][5][2][41][LINES + 1];
extern void setAbacus(AbacusWidget w, int reason);
extern void setAbacusDemo(AbacusWidget w, int reason);
extern void setAbacusMove(AbacusWidget w, int reason, int aux,
......@@ -328,7 +379,7 @@ extern int rootInt(int i, int n);
extern void clearRails(AbacusWidget w);
extern void addBackAnomaly(char * buf, int anomaly, int shift, int base);
extern void zeroFractionalPart(char * buf);
extern void convertStringToAbacus(AbacusWidget w, char *string, int aux);
extern void convertStringToAbacus(AbacusWidget w, const char *string, int aux);
extern double convertToDecimal(int base, char *inputString);
extern void convertFromInteger(char *outputString, int base, int x);
extern void convertFromDouble(char *outputString, int base, double x);
......@@ -339,4 +390,6 @@ extern void drawTeachText(const char* line, int i);
extern void clearAuxRails(AbacusWidget w, int aux);
#endif
extern void readParseFile(const char * fileName);
#endif /* _AbacusP_h */
/*
* @(#)AbacusT.c
*
* Copyright 2009 - 2013 David A. Bagley, bagleyd AT verizon.net
* Copyright 2009 - 2017 David A. Bagley, bagleyd AT verizon.net
*
* All rights reserved.
*
......@@ -338,9 +338,9 @@ static void testTable()
#endif
/* Feeback lines to user */
static void drawLineText(AbacusWidget w, char* line, int i)
{
#ifdef WINVER
static void drawLineText(AbacusWidget w, const char* line, int i)
{
#ifdef DEMO_FRAMED
(void) SetTextColor(w->core.hDC, w->abacusDemo.foregroundGC);
(void) SetBkMode(w->core.hDC, TRANSPARENT);
......@@ -353,11 +353,14 @@ static void drawLineText(AbacusWidget w, char* line, int i)
return;
}
drawTeachText(line, i);
}
#endif
#else
static void drawLineText(AbacusWidget w, char* line, int i)
{
setAbacusText(w, ACTION_TEACH_LINE, line, i);
#endif
}
#endif
/* Position of decimal point in string */
static int getDecimalStringPosition(char * string)
......@@ -2319,8 +2322,8 @@ void teachStep(AbacusWidget w, char * buffer, int aux)
#ifdef OLD_DEBUG
testTable();
#endif
drawLineText(w, (char *) TEACH_STRING0, 0);
drawLineText(w, (char *) TEACH_STRING1, 1);
drawLineText(w, TEACH_STRING0, 0);
drawLineText(w, TEACH_STRING1, 1);
(void) sprintf(buffer3, "(addition order will be: %s; multiplicand order will be %s)",
((w->abacus.rightToLeftAdd) ? "right to left" : "left to right"),
((w->abacus.rightToLeftMult) ? "right to left" : "left to right"));
......@@ -2385,9 +2388,9 @@ void teachStep(AbacusWidget w, char * buffer, int aux)
if (w->abacus.op == '+' || w->abacus.op == '-') {
convertStringToAbacus(w, w->abacus.aString, aux);
if (w->abacus.leftAux != NULL)
convertStringToAbacus(w, (char *) ZERO_STRING, 1);
convertStringToAbacus(w, ZERO_STRING, 1);
if (w->abacus.rightAux != NULL)
convertStringToAbacus(w, (char *) ZERO_STRING, 2);
convertStringToAbacus(w, ZERO_STRING, 2);
a = convertToDecimal(base, w->abacus.aString);
b = convertToDecimal(base, w->abacus.bString);
if (w->abacus.op == '-' && b > a) {
......@@ -2416,7 +2419,7 @@ void teachStep(AbacusWidget w, char * buffer, int aux)
} else if (w->abacus.op == '*') {
if (strlen(w->abacus.aString) == 0)
return;
convertStringToAbacus(w, (char *) ZERO_STRING, 0);
convertStringToAbacus(w, ZERO_STRING, 0);
if (w->abacus.leftAux != NULL)
convertStringToAbacus(w, w->abacus.aString, 1);
a = convertToDecimal(base, w->abacus.aString);
......@@ -2451,7 +2454,7 @@ void teachStep(AbacusWidget w, char * buffer, int aux)
} else if (w->abacus.op == '/') {
if (strlen(w->abacus.aString) == 0)
return;
convertStringToAbacus(w, (char *) ZERO_STRING, 2);
convertStringToAbacus(w, ZERO_STRING, 2);
convertStringToAbacus(w, w->abacus.aString, 0);
a = convertToDecimal(base, w->abacus.aString);
if (w->abacus.rightAux != NULL)
......@@ -2503,9 +2506,9 @@ void teachStep(AbacusWidget w, char * buffer, int aux)
stringGroup(w->abacus.intGroup, group, w->abacus.op);
convertStringToAbacus(w, w->abacus.aString, aux);
if (w->abacus.leftAux != NULL)
convertStringToAbacus(w, (char *) ZERO_STRING, 1);
convertStringToAbacus(w, ZERO_STRING, 1);
if (w->abacus.rightAux != NULL)
convertStringToAbacus(w, (char *) ZERO_STRING, 2);
convertStringToAbacus(w, ZERO_STRING, 2);
a = convertToDecimal(base, w->abacus.aString);
(void) sprintf(buffer1, "%s root of %s, grouping digits yields (%s)",
((w->abacus.op == 'v') ? "Square" : "Cube"),
......
Copyright 1994 - 2016 David A. Bagley, bagleyd AT verizon.net
Copyright 1994 - 2017 David A. Bagley, bagleyd AT verizon.net
All Rights Reserved
......
[Jul 17, 2017] V8.1.0:
Removed the lesson files and now use same abacusDemo.xml in Java port.
Added fallback code to use a static demo if can not read XML demo file.
Windows version always uses fallback, some issue with libxml2-2.dll
at runtime.
Added another book from Abacus Guide. Only first few chapters and
examples so far. (Not available in fallback mode.)
Updated sound configuration for X version. Uses a simple included
script play.sh, that is now used by default.
[Sep 03, 2016] V8.0.8:
Updates to Roman display.
Old website http://www.tux.org/~bagleyd died, shifted code base to new
......
......@@ -37,7 +37,7 @@ Basic Installation
make
Then run "wabacus". Your on your own on installing the wabacus.ini
file and Abacus?.les files.
and abacusDemo.xml files.
Windows users only:
xabacus.htm is included. Most of the features are in wabacus with the
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@
NAME=abacus
GROUP=x${NAME}
if test "$1" == ""; then
VERSION=`sed 's/^.*"\(.*\)"/\1/' ./version.h`
VERSION=`grep VERSION ./version.h | sed 's/^.*"\(.*\)"/\1/'`
RELEASE=1
else
VERSION=$1
......@@ -35,7 +35,7 @@ RELEASE=${RELEASE}
CATEGORY=\"${CATEGORY}\"
SUMMARY=\"${SUMMARY}\"
DESCRIPTION=\"${DESCRIPTION}\"
#REQUIRES=\"libaudiofile1 libesd0 libX11_6 libXm4 libXpm4 libXt6\"
#REQUIRES=\"libxml2 libaudiofile1 libesd0 libX11_6 libXm4 libXpm4 libXt6\"
# source and patch files
SRC_URI=\"${SRC_URI}\"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _version_h
#define _version_h
#define VERSION "8.0.8"
#define VERSION "8.1.0"
#endif /* _version_h */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment