Update atapio.cpp to use new rather than dumb_alloc, add file_size
This commit is contained in:
parent
ed67adc9c9
commit
15ca13a985
@ -21,10 +21,10 @@ uint16_t sectorsPerFAT;
|
|||||||
|
|
||||||
|
|
||||||
void init_atapio() {
|
void init_atapio() {
|
||||||
rootDirEntries = (uint8_t*)dumb_alloc(8192);
|
rootDirEntries = new uint8_t[8192];
|
||||||
FAT1 = (uint16_t*)dumb_alloc(512 * 34);
|
FAT1 = (uint16_t*)(new uint8_t[512 * 34]);
|
||||||
|
|
||||||
uint32_t boot_sector = (uint32_t)dumb_alloc(4096);
|
uint32_t boot_sector = new uint32_t[1024];
|
||||||
read_sectors(0, 1, (uint8_t*)boot_sector);
|
read_sectors(0, 1, (uint8_t*)boot_sector);
|
||||||
|
|
||||||
countReserved = *((uint16_t*)(boot_sector + 0x0e));
|
countReserved = *((uint16_t*)(boot_sector + 0x0e));
|
||||||
@ -126,3 +126,14 @@ void load_file(char* filename, uint8_t* destination) {
|
|||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t file_size(char* filename) {
|
||||||
|
for (int i=0; i<countRDEs; i++) {
|
||||||
|
bool found = strcmp(rootDirEntries+(i*32), filename, 11);
|
||||||
|
if (found) {
|
||||||
|
uint32_t* correctEntry = (uint32_t*)(rootDirEntries+(i*32));
|
||||||
|
return correctEntry[7];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "allocate.h"
|
#include "allocate.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
void init_atapio();
|
void init_atapio();
|
||||||
void read_sector(uint32_t address, uint8_t* buffer);
|
void read_sector(uint32_t address, uint8_t* buffer);
|
||||||
@ -14,4 +15,6 @@ void read_sectors(uint32_t address, int count, uint8_t* buffer);
|
|||||||
uint16_t file_exists(char* filename);
|
uint16_t file_exists(char* filename);
|
||||||
void load_file(char* filename, uint8_t* location);
|
void load_file(char* filename, uint8_t* location);
|
||||||
|
|
||||||
|
uint32_t file_size(char* filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user