Move code out of main and into their own files

All of the SD card commands are moved into their own file, with
functions sd_init, sd_get_rca, sd_select_card, sd_get_status, and
sd_readblock.

The FAT functions are movied into fat.c and give functions fat_init and
fat_read. Note that the filename is ignored for now, it always reads the
first file in the root directory.

The loading of o65 files is done in o65.c, and executing is done in
exec.c

This cleans up the main file signifigantly and leaves the project open
to expansion.
This commit is contained in:
Byron Lathi
2022-04-16 20:52:50 -05:00
parent c02d03bd99
commit f1e71a9461
9 changed files with 293 additions and 292 deletions

View File

@@ -3,6 +3,8 @@
#include <stdint.h>
extern uint8_t fat_buf[];
typedef struct {
uint16_t bytes_per_sector;
uint8_t sectors_per_cluster;
@@ -39,6 +41,34 @@ typedef struct {
uint8_t filesystem_type[8];
} ebpb_t;
typedef struct {
uint16_t bytes_per_sector;
uint8_t sectors_per_cluster;
uint16_t reserved_sectors;
uint8_t fat_count;
uint16_t max_dir_entries;
uint16_t total_sector_count;
uint8_t media_descriptor;
uint16_t sectors_per_fat_16;
uint16_t sectors_per_track;
uint16_t head_count;
uint32_t hidden_sector_count;
uint32_t logical_sector_count;
uint32_t sectors_per_fat_32;
uint16_t extended_flags;
uint16_t version;
uint32_t root_cluster;
uint16_t system_information;
uint16_t backup_boot_sector;
uint8_t reserved[12];
uint8_t drive_num;
uint8_t reserved2;
uint8_t extended_signature;
uint32_t volume_id;
uint8_t partition_label[11];
uint8_t filesystem_type[8];
} full_bpb_t;
typedef struct {
uint32_t sig;
uint8_t reserved[480];
@@ -74,4 +104,8 @@ typedef struct {
uint32_t file_size;
} dos_dentry_t;
void fat_print_pbp_info(ebpb_t* epbp);
void fat_init();
void fat_read(char* filename, void* buf);
#endif