Rev 5232 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5232 | raandoom | 1 | #include "config.h" |
2 | |||
3 | #pragma pack(push,1) |
||
4 | |||
5 | typedef struct { |
||
6 | __u32 func; |
||
7 | __u32 l_off; |
||
8 | __u32 h_off_flags; |
||
9 | __u32 size; |
||
10 | char* data; |
||
11 | char null; |
||
12 | char* name; |
||
13 | } fs_info; |
||
14 | |||
15 | #pragma pack(pop) |
||
16 | |||
17 | char path[] = "/sys/games/2048.dat"; |
||
18 | |||
19 | __u32 config_load_highscore() |
||
20 | { |
||
21 | __u32 highscore = 0; |
||
22 | |||
23 | fs_info cfg = {0}; |
||
24 | cfg.func = 0; |
||
5238 | raandoom | 25 | cfg.size = sizeof(__u32); |
5232 | raandoom | 26 | cfg.data = (char*)&highscore; |
27 | cfg.name = path; |
||
28 | |||
29 | __u32 ret = 0; |
||
30 | __u32 rnum = 0; |
||
31 | |||
32 | __asm__ __volatile__("int $0x40":"=a"(ret),"=b"(rnum): |
||
33 | "a"(70), |
||
5238 | raandoom | 34 | "b"((__u32)(&cfg)): |
35 | "memory"); |
||
5232 | raandoom | 36 | |
37 | if (ret || (rnum != 4)) highscore = 0; |
||
38 | |||
39 | return highscore; |
||
40 | } |
||
41 | |||
42 | void config_save_highscore(__u32 score) |
||
43 | { |
||
44 | fs_info cfg = {0}; |
||
45 | cfg.func = 2; |
||
5238 | raandoom | 46 | cfg.size = sizeof(__u32); |
5232 | raandoom | 47 | cfg.data = (char*)&score; |
48 | cfg.name = path; |
||
49 | |||
50 | __u32 ret = 0; |
||
51 | __u32 wnum = 0; |
||
52 | |||
53 | __asm__ __volatile__("int $0x40":"=a"(ret),"=b"(wnum): |
||
54 | "a"(70), |
||
5238 | raandoom | 55 | "b"((__u32)(&cfg)): |
56 | "memory"); |
||
5232 | raandoom | 57 | } |