OXYGENHUB
◆ main enhanced-x16-emulator / src / sdcard.h
1.3 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
1
// Commander X16 Emulator
2
// Copyright (c) 2019 Michael Steil
3
// All rights reserved. License: 2-clause BSD
4
#ifndef _SD_CARD_H_
5
#define _SD_CARD_H_
6
#include <inttypes.h>
7
#include <stdbool.h>
8
#include <SDL.h>
9
10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
14
extern bool sdcard_attached;
15
void sdcard_set_path(char const *path);
16
bool sdcard_path_is_set();
17
void sdcard_attach();
18
void sdcard_detach();
19
20
const char *sdcard_get_path(void);
21
22
// Rebuild the FAT index over the attached image, discarding the old one.
23
// Returns false when nothing is attached or the image is not indexable.
24
bool sdcard_reindex(void);
25
26
void sdcard_select(bool select);
27
uint8_t sdcard_handle(uint8_t inbyte);
28
29
typedef struct {
30
	bool        attached;
31
	bool        selected;
32
	const char *image_path;           // "" when none
33
	int64_t     image_size;           // -1 when not attached
34
	uint8_t     last_cmd;             // command number (0-63)
35
	bool        last_cmd_is_acmd;
36
	uint32_t    last_lba;
37
	bool        is_idle;
38
	bool        is_initialized;
39
	bool        ongoing_multiblock_read;
40
	int         response_length;
41
	int         response_counter;
42
	// Session counters:
43
	uint64_t    blocks_read;
44
	uint64_t    blocks_written;
45
	uint64_t    bytes_read;
46
	uint64_t    bytes_written;
47
	uint32_t    commands;
48
} sdcard_debug_state_t;
49
50
void sdcard_debug_get_state(sdcard_debug_state_t *out);
51
52
#ifdef __cplusplus
53
}
54
#endif
55
56
#endif