mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-06-28 00:16:08 +08:00
对FAT的支持
This commit is contained in:
@@ -17,6 +17,8 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
|
|||||||
void make_wtitle8(unsigned char *buf, int xsize, char *title, char act);
|
void make_wtitle8(unsigned char *buf, int xsize, char *title, char act);
|
||||||
void console_task(struct SHEET *sheet, unsigned int memtotal);
|
void console_task(struct SHEET *sheet, unsigned int memtotal);
|
||||||
int cons_newline(int cursor_y, struct SHEET *sheet);
|
int cons_newline(int cursor_y, struct SHEET *sheet);
|
||||||
|
void file_readfat(int *fat, unsigned char *img);
|
||||||
|
void file_loadfile(int clustno, int size, char *buf, int *fat, char *img);
|
||||||
|
|
||||||
#define KEYCMD_LED 0xed
|
#define KEYCMD_LED 0xed
|
||||||
|
|
||||||
@@ -388,11 +390,13 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
|
|||||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||||
int x, y;
|
int x, y;
|
||||||
struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600);
|
struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600);
|
||||||
|
int *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
|
||||||
|
|
||||||
fifo32_init(&task->fifo, 128, fifobuf, task);
|
fifo32_init(&task->fifo, 128, fifobuf, task);
|
||||||
timer = timer_alloc();
|
timer = timer_alloc();
|
||||||
timer_init(timer, &task->fifo, 1);
|
timer_init(timer, &task->fifo, 1);
|
||||||
timer_settime(timer, 50);
|
timer_settime(timer, 50);
|
||||||
|
file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
|
||||||
|
|
||||||
/*显示提示符*/
|
/*显示提示符*/
|
||||||
putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1);
|
putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1);
|
||||||
@@ -518,11 +522,12 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
|
|||||||
if (x < 224 && finfo[x].name[0] != 0x00) {
|
if (x < 224 && finfo[x].name[0] != 0x00) {
|
||||||
/*找到文件的情况*/
|
/*找到文件的情况*/
|
||||||
y = finfo[x].size;
|
y = finfo[x].size;
|
||||||
p = (char *) (finfo[x].clustno * 512 + 0x003e00 + ADR_DISKIMG);
|
p = (char *) memman_alloc_4k(memman, finfo[x].size);
|
||||||
|
file_loadfile(finfo[x].clustno, finfo[x].size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
|
||||||
cursor_x = 8;
|
cursor_x = 8;
|
||||||
for (x = 0; x < y; x++) {
|
for (y = 0; y < finfo[x].size; y++) {
|
||||||
/*逐字输出*/
|
/*逐字输出*/
|
||||||
s[0] = p[x];
|
s[0] = p[y];
|
||||||
s[1] = 0;
|
s[1] = 0;
|
||||||
if (s[0] == 0x09) { /*制表符*/
|
if (s[0] == 0x09) { /*制表符*/
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -550,6 +555,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
memman_free_4k(memman, (int) p, finfo[x].size);
|
||||||
} else {
|
} else {
|
||||||
/*没有找到文件的情况*/
|
/*没有找到文件的情况*/
|
||||||
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15);
|
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15);
|
||||||
@@ -607,3 +613,35 @@ int cons_newline(int cursor_y, struct SHEET *sheet)
|
|||||||
}
|
}
|
||||||
return cursor_y;
|
return cursor_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void file_readfat(int *fat, unsigned char *img)
|
||||||
|
/*将磁盘映像中的FAT解压缩 */
|
||||||
|
{
|
||||||
|
int i, j = 0;
|
||||||
|
for (i = 0; i < 2880; i += 2) {
|
||||||
|
fat[i + 0] = (img[j + 0] | img[j + 1] << 8) & 0xfff;
|
||||||
|
fat[i + 1] = (img[j + 1] >> 4 | img[j + 2] << 4) & 0xfff;
|
||||||
|
j += 3;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void file_loadfile(int clustno, int size, char *buf, int *fat, char *img)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (;;) {
|
||||||
|
if (size <= 512) {
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
buf[i] = img[clustno * 512 + i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (i = 0; i < 512; i++) {
|
||||||
|
buf[i] = img[clustno * 512 + i];
|
||||||
|
}
|
||||||
|
size -= 512;
|
||||||
|
buf += 512;
|
||||||
|
clustno = fat[clustno];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user