-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbattmem.c
69 lines (57 loc) · 1.77 KB
/
battmem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifdef DEBUG_DEVICE
#define USE_SERIAL_OUTPUT
#endif
#include "port.h"
#include "printf.h"
#include <stdlib.h>
#include <stdio.h>
#include <resources/battmem.h>
#include <pragmas/exec_pragmas.h>
#include <clib/battmem_protos.h>
#include <pragmas/battmem_pragmas.h>
#include "device.h"
#include "attach.h"
#include "battmem.h"
struct Library *BattMemBase;
int Load_BattMem(void)
{
UBYTE cdrom_boot = 0,
ignore_last = 0;
BattMemBase = OpenResource(BATTMEMNAME);
if (!BattMemBase)
return 0;
ObtainBattSemaphore();
printf("Retrieving settings from BattMem\n");
ReadBattMem(&cdrom_boot,
BATTMEM_A4091_CDROM_BOOT_ADDR,
BATTMEM_A4091_CDROM_BOOT_LEN);
ReadBattMem(&ignore_last,
BATTMEM_A4091_IGNORE_LAST_ADDR,
BATTMEM_A4091_IGNORE_LAST_LEN);
// CDROM_BOOT defaults to on, hence invert it
asave->cdrom_boot = !cdrom_boot;
asave->ignore_last = ignore_last;
printf(" cdrom_boot: %s\n", asave->cdrom_boot?"on":"off");
printf(" ignore_last: %s\n", asave->ignore_last?"on":"off");
ReleaseBattSemaphore();
return 1;
}
int Save_BattMem(void)
{
UBYTE cdrom_boot = !asave->cdrom_boot,
ignore_last = asave->ignore_last;
if (!BattMemBase)
return 0;
ObtainBattSemaphore();
printf("Storing settings to BattMem\n");
printf(" cdrom_boot: %s\n", asave->cdrom_boot?"on":"off");
printf(" ignore_last: %s\n", asave->ignore_last?"on":"off");
WriteBattMem(&cdrom_boot,
BATTMEM_A4091_CDROM_BOOT_ADDR,
BATTMEM_A4091_CDROM_BOOT_LEN);
WriteBattMem(&ignore_last,
BATTMEM_A4091_IGNORE_LAST_ADDR,
BATTMEM_A4091_IGNORE_LAST_LEN);
ReleaseBattSemaphore();
return 1;
}