#define CREDITS_PER_PAGE 10
/* Eingenommes Geld in Cent */
-extern unsigned long int money;
-extern unsigned long int items_sold;
+extern int32_t money;
+extern int32_t items_sold;
extern BYTE printer_port;
/* Datenstruktur der verkauften Einträge */
void cget_return(void);
uint8_t cget_nickname(char *buf, uint8_t len);
char retry_or_quit(void);
-char *format_euro(char *s, int maxlen, int cent);
+char *format_euro(char *s, int maxlen, int32_t cent);
void c128_perror(BYTE, char *);
extern BYTE _oserror;
#define VIDEOMODE (((*(BYTE *)0xD7) == 0x80) ? 80 : 40)
-/* "999,99€" */
-#define EUR_FORMAT "%3d,%02d" EURSYM
-#define EUR_FORMAT_MINLEN 7
+/* "-999,99€" */
+#define EUR_FORMAT "%3ld,%02lu" EURSYM
+#define EUR_FORMAT_MINLEN 8
/* because there is no macro expansion when stringifying, we need to use two
* levels of macros to stringify the value of a macro (for example
*/
unsigned char __fastcall__ _sysremove(const char *name);
-unsigned long int money = 0;
-unsigned long int items_sold = 0;
+int32_t money = 0;
+int32_t items_sold = 0;
BYTE printer_port = 4;
static bool items_exists = false;
static bool credits_exists = false;
cbm_load("items", (BYTE)8, &status);
for (c = 0; c < status.num_items; c++) {
items_sold += status.status[c].times_sold;
- money += (status.status[c].price * status.status[c].times_sold);
+ money += (((int32_t)status.status[c].price) *
+ ((int32_t)status.status[c].times_sold));
}
} else
memset(&status, 0, sizeof(struct status_array_t));
return *c;
}
-char *format_euro(char *s, int maxlen, int cent) {
- if (snprintf(s, maxlen, EUR_FORMAT, cent / 100, cent % 100) > maxlen)
+char *format_euro(char *s, int maxlen, int32_t cent) {
+ int32_t euros, cents;
+ euros = cent / 100;
+ cents = abs(cent % 100);
+ if (snprintf(s, maxlen, EUR_FORMAT, euros, cents) > maxlen)
return NULL;
return s;
}
clrscr();
if (format_euro(profit, sizeof(profit), money) == NULL) {
cprintf("Einnahme %ld konnte nicht umgerechnet werden\r\n", money);
- profit[0]='\0';
+ profit[0] = '\0';
}
textcolor(TC_CYAN);
cprintf("C128-Kassenprogramm (phil_fry, sECuRE, sur5r, mxf) " GV "\r\n");
* Prints a line and logs it to file. Every line can be at max 80 characters.
*
*/
-static void print_log(char *name, int item_price, int einheiten, char *nickname,
- char *rest) {
+static void print_log(char *name, int32_t item_price, int16_t einheiten,
+ char *nickname, char *rest) {
char *time = get_time();
uint8_t n;
char price[EUR_FORMAT_MINLEN + 1];
"%8s - "
/* Eintragname (= Getränk) -- 9-stellig + 3 */
"%-" xstr(MAX_ITEM_NAME_LENGTH) "s - "
- /* Preis (in Cents) -- 7-stellig + 3 */
+ /* Preis (in Cents) -- 8-stellig + 3 */
"%" xstr(EUR_FORMAT_MINLEN) "s - "
- /* restguthaben (7-stellig) + 3 */
+ /* restguthaben (8-stellig) + 3 */
"%" xstr(EUR_FORMAT_MINLEN) "s - "
/* Anzahl -- 2-stellig + 3 */
"%2d - "
}
/* dialog which is called for each bought item */
-static signed int buy(char *name, unsigned int price) {
+static signed int buy(char *name, int32_t price) {
BYTE matches = 0;
BYTE c, nickname_len;
- int einheiten;
+ int16_t einheiten;
char nickname[NICKNAME_MAX_LEN + 1];
char rest[EUR_FORMAT_MINLEN + 1];
struct credits_t *credit;
* to NULL if no such credit could be found */
credit = find_credit(nickname);
if (credit != NULL) {
- while ((signed int)credit->credit < ((signed int)price * einheiten)) {
+ while ((int32_t)credit->credit < (price * einheiten)) {
if (format_euro(rest, sizeof(rest), credit->credit) == NULL) {
cprintf("Preis %d konnte nicht umgerechnet werden\r\n",
credit->credit);