unsigned long int money = 0;
unsigned long int num_items = 0;
-uc num_credit_items = 0;
+BYTE num_credit_items = 0;
unsigned long int items_sold = 0;
+BYTE printer_port = 4;
struct status_t status[MAX_ITEMS+1];
struct credits_t credits[MAX_CREDIT_ITEMS+1];
#ifdef REAL_DATA
void load_config();
-
void load_items(){
FILE* f;
char line[80];
}
-/**
- * must be called after load_items()
- */
void load_state(){
- FILE* f;
- char line[80];
- char * sep;
- char i, j;
- f = fopen("state", "r");
- if (f==NULL){
- printf("cannot open state\n");
- return;
- }
- while (!feof(f)) {
- fgets(line, 79, f);
- sep = strchr(line, '=');
- *(line + (sep-line)) = 0;
- for (i=0; i< MAX_ITEMS; i++) {
- if (strcmp(line, status[i].item_name)==0) {
- status[i].times_sold = atoi(sep+1);
- break;
- }
- }
- }
+ status[0].times_sold=23;
+ status[1].times_sold=42;
}
void save_state(){}
}
void load_items() {
- uc c;
+ BYTE c;
num_items=2;
strcpy(status[0].item_name, "cola");
status[0].price = 230;
#include <conio.h>
#include <stdlib.h>
#include <string.h>
+#include <cbm.h>
#include "general.h"
#include "config.h"
// drucker 4 oder 5
// graphic 4,0,10
-
+char print_buffer[81];
/* Hauptbildschirm ausgeben */
void print_screen() {
- uc i = 0;
+ BYTE i = 0;
clrscr();
printf("C128-Kassenprogramm\n\n");
printf("Eingenommen: %ld Cents, Verkauft: %ld Flaschen, Drucken: %s\n\n", money, items_sold, (printing == 1 ? "ein" : "aus"));
}
/* Druckt eine entsprechende Zeile aus */
-void print_log(uc n, int einheiten, char *nickname) {
+void print_log(BYTE n, int einheiten, char *nickname) {
+ BYTE c;
/* Format:
Transaction-ID (Anzahl verkaufter Einträge, inklusive des zu druckenden!)
Uhrzeit (TODO)
Anzahl
Nickname (falls es vom Guthaben abgezogen wird)
*/
- printf("[%d] UHRZEIT - %s - %d - %d - an %s\n", items_sold, status[n].item_name, status[n].price, einheiten, (nickname != NULL ? nickname : "Unbekannt"));
+ sprintf(print_buffer, "[%d] UHRZEIT - %s - %d - %d - an %s\r\n", items_sold, status[n].item_name, status[n].price, einheiten, (nickname != NULL ? nickname : "Unbekannt"));
+ c = cbm_open(4, 4, 0, NULL);
+ if (c != 0) {
+ c128_perror(c, "cbm_open(printer)");
+ save_state();
+ exit(1);
+ }
+ c = cbm_write(4, print_buffer, strlen(print_buffer));
+ if (c != strlen(print_buffer)) {
+ c128_perror(c, "write(printer)");
+ save_state();
+ exit(1);
+ }
+ cbm_close(4);
}
/* Dialog, der einen durch's Abrechnen der Einträge führt */
-void buy(uc n) {
+void buy(BYTE n) {
int negative = 1;
char entered[5] = {'1', 0, 0, 0, 0};
- uc i = 0, matches = 0;
- uc c, nickname_len, single_match;
+ BYTE i = 0, matches = 0;
+ BYTE c, nickname_len, single_match;
int einheiten;
char *nickname;
if (status[n].item_name == NULL)
}
int main() {
- static uc c;
+ static BYTE c;
/* Konfigurationsdatei laden */
load_config();
/* Einträge (=Getränke) laden */