]> git.sur5r.net Git - c128-kasse/blob - config.c
use #define REAL_DATA to read from disk
[c128-kasse] / config.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include "general.h"
5 #include "config.h"
6
7 unsigned long int money = 0;
8 unsigned long int num_items = 0;
9 uc num_credit_items = 0;
10 unsigned long int items_sold = 0;
11 struct status_t status[MAX_ITEMS+1];
12 struct credits_t credits[MAX_CREDIT_ITEMS+1];
13
14 #ifdef REAL_DATA
15 void load_config();
16
17 void load_items(){
18         FILE* f;
19         char line[80];
20         char * sep;
21         f = fopen("items", "r");
22         for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) {
23                 fgets(line, 79, f);
24                 sep = strchr(line, '=');
25                 strncpy(status[num_items].item_name, line, sep-line);
26                 status[num_items].price = atoi(sep+1);
27                 status[num_items].times_sold = 0; 
28         }
29         
30 }
31
32 void load_state(){
33         status[0].times_sold=23;        
34         status[1].times_sold=42;        
35 }
36 void save_state(){}
37
38 void load_config() {
39 }
40
41 #else
42
43 void load_items() {
44         uc c;
45         num_items=2;
46         strcpy(status[0].item_name, "cola");
47         status[0].price = 230;
48         status[0].times_sold = 0;
49         strcpy(status[1].item_name, "mate");
50         status[1].price = 150;
51         status[1].times_sold = 0;
52
53 }
54
55 void load_state() {
56         status[0].times_sold=23;        
57         status[1].times_sold=42;        
58 }
59
60 void load_credits() {
61 }
62
63 void save_state() {
64 }
65
66 void save_credits() {}
67 #endif