-
Notifications
You must be signed in to change notification settings - Fork 0
/
eeprom.h
63 lines (49 loc) · 2.08 KB
/
eeprom.h
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
/*
* Dragon - EEPROM score storage
* Copyright (C) 2016 Sandor Zsuga (Jubatian)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
** Supports saving / loading game scores from / to EEPROM, automatically
** handling Uzebox error conditions in a sane manner.
**
** The score data is as follows:
**
** There are 3 high score entries, each entry taking 10 6 bit characters (only
** low 6 bits of the bytes are filled, see text.h for layout) and 2 bytes of
** high score value. So it totals 36 bytes (but due to the compression of the
** text part it fits in the 30 + 2 byte EEPROM block).
**
** The EEPROM block ID is 0xF0AD (For FoaD: Flight of a Dragon), stored in
** Little Endian format in the EEPROM itself (as the Uzebox kernel does this).
*/
#ifndef EEPROM_H
#define EEPROM_H
#include "types.h"
/*
** Loads EEPROM score data to target address. If it doesn't exist, default
** scores are created. 36 bytes of RAM is required for it at addr, tadd is
** used for temporary storage, 32 bytes (can not overlap with addr).
*/
void eeprom_load(uint16 addr, uint16 tadd);
/*
** Saves EEPROM score data from source address (36 bytes at addr), tadd is
** used for temporary storage, 32 bytes (can not overlap with addr). Note
** that it disables Mode 74 for the save (to prevent resets), re-enabling it
** upon return. The state of the frame is not reliable this case (a reset
** might happen any time), so only an M74_Halt() should follow this.
*/
void eeprom_save(uint16 addr, uint16 tadd);
#endif