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.
44 lines
599 B
C
44 lines
599 B
C
#include <stdint.h>
|
|
#include <conio.h>
|
|
#include <string.h>
|
|
|
|
#include "board_io.h"
|
|
#include "uart.h"
|
|
#include "mapper.h"
|
|
#include "sd_card.h"
|
|
#include "fat.h"
|
|
#include "o65.h"
|
|
#include "exec.h"
|
|
|
|
uint8_t buf[512];
|
|
|
|
int main() {
|
|
int i;
|
|
uint16_t rca;
|
|
|
|
clrscr();
|
|
cprintf("Hello, world!\n");
|
|
|
|
for (i = 0; i < 16; i++){
|
|
//cprintf("Mapping %1xxxx to %2xxxx\n", i, i);
|
|
mapper_write(i, i);
|
|
}
|
|
|
|
cprintf("Enabling Mapper\n");
|
|
mapper_enable(1);
|
|
|
|
sd_init();
|
|
|
|
rca = sd_get_rca();
|
|
cprintf("rca: %x\n", rca);
|
|
|
|
sd_select_card(rca);
|
|
|
|
fat_init();
|
|
exec("/test.o65");
|
|
|
|
cprintf("Done!\n");
|
|
|
|
return 0;
|
|
}
|