#define GENERAL_H_
#include <peekpoke.h>
+#include "vdc_patch_charset.h"
typedef unsigned char BYTE;
typedef enum {
#define VIDEOMODE (((*(BYTE *)0xD7) == 0x80) ? 80 : 40)
+#define EUR_FORMAT "%3d,%02d" EURSYM
+#define EUR_FORMAT_MINLEN (sizeof("999,99" EURSYM) + 1)
+
/* 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
* MAX_ITEM_NAME_LENGTH) */
static void credit_print_screen(void) {
BYTE i, pages;
- char buffer[10];
+ char buffer[EUR_FORMAT_MINLEN];
clrscr();
cprintf("credit_manager (phil_fry, sECuRE, sur5r) v:" GV "\r\n\r\n");
}
char *format_euro(char *s, int maxlen, int cent) {
- if (snprintf(s, maxlen, "%3d,%02d" EURSYM, cent / 100, cent % 100) > maxlen)
+ if (snprintf(s, maxlen, EUR_FORMAT, cent / 100, cent % 100) > maxlen)
return NULL;
return s;
}
static void itemz_print_screen(void) {
BYTE i;
- char buffer[10];
+ char buffer[EUR_FORMAT_MINLEN];
clrscr();
cprintf("itemz (phil_fry, sECuRE, sur5r, mxf) v:" GV "\r\n\r\n");
cprintf("Datei: ITEMS\r\n\r\n");
for (i = 0; i < max(status.num_items, 15); i++) {
- if (format_euro(buffer, 10, status.status[i].price) != buffer) {
+ if (format_euro(buffer, sizeof(buffer), status.status[i].price) != buffer) {
cprintf("Error: Could not format price %d\r\n", status.status[i].price);
exit(1);
}
// graphic 4,0,10
void print_item(BYTE i) {
- char profit[10];
+ char profit[EUR_FORMAT_MINLEN];
if (format_euro(profit, sizeof(profit), status.status[i].price) == NULL) {
cprintf("Preis %ld konnte nicht umgerechnet werden\r\n",
status.status[i].price);
static void print_screen(void) {
BYTE i = 0;
char *time = get_time();
- char profit[10];
+ char profit[EUR_FORMAT_MINLEN];
clrscr();
if (format_euro(profit, sizeof(profit), money) == NULL) {
cprintf("Einnahme %ld konnte nicht umgerechnet werden\r\n", money);
static void print_log(char *name, int item_price, int einheiten, char *nickname,
char *rest) {
char *time = get_time();
- char price[10];
+ char price[EUR_FORMAT_MINLEN];
/* Format:
Transaction-ID (Anzahl verkaufter Einträge, inklusive des zu druckenden!)
-- 6-stellig
BYTE c, nickname_len;
int einheiten;
char nickname[NICKNAME_MAX_LEN + 1];
- char rest[10];
+ char rest[EUR_FORMAT_MINLEN];
struct credits_t *credit;
memset(nickname, '\0', sizeof(nickname));
if (einheiten > 100 || einheiten < -100 || einheiten == 0) {
cprintf("\r\nEinheit nicht in [-100, 100] oder 0, Abbruch, dr" uUML "cke "
"RETURN...\r\n");
- cgetc();
+ cget_return();
return 1;
}