Revision 55
Added by markw over 11 years ago
firmware/atari_drive_emulator.c | ||
---|---|---|
|
||
if (atr_header.wSecSize == 0x80)
|
||
{
|
||
if (atr_header.wPars>(720*128/16))
|
||
/* if (atr_header.wPars>(720*128/16))
|
||
printf("MD ");
|
||
else
|
||
printf("SD ");
|
||
printf("SD ");*/
|
||
}
|
||
else if (atr_header.wSecSize == 0x100)
|
||
{
|
||
... | ... | |
|
||
if (command.command == 0x57)
|
||
{
|
||
char buffer[256];
|
||
unsigned char buffer[256];
|
||
int read;
|
||
file_read(file,buffer,sectorSize,&read);
|
||
|
firmware/common/utils.c | ||
---|---|---|
#include "utils.h"
|
||
|
||
int strcmp(char const * a, char const * b)
|
||
{
|
||
while (*a || *b)
|
||
... | ... | |
return 0;
|
||
}
|
||
|
||
int stricmp(char const * a, char const * b)
|
||
{
|
||
char buffer[128];
|
||
char buffer2[128];
|
||
stricpy(&buffer[0],a);
|
||
stricpy(&buffer2[0],b);
|
||
return strcmp(&buffer[0],&buffer2[0]);
|
||
}
|
||
|
||
void strcpy(char * dest, char const * src)
|
||
{
|
||
while (*dest++=*src++);
|
firmware/common/utils.h | ||
---|---|---|
int strcmp(char const * a, char const * b);
|
||
int stricmp(char const * a, char const * b);
|
||
void strcpy(char * dest, char const * src);
|
||
void stricpy(char * dest, char const * src);
|
||
int strlen(char const * a);
|
firmware/fat/pff.c | ||
---|---|---|
|
||
#include "pff.h" /* Petit FatFs configurations and declarations */
|
||
#include "diskio.h" /* Declarations of low level disk I/O functions */
|
||
#include "printf.h"
|
||
//#include "printf.h"
|
||
|
||
|
||
|
firmware/fat/pff_file.c | ||
---|---|---|
#include "utils.h"
|
||
#include "diskio.h"
|
||
#include "simplefile.h"
|
||
#include "printf.h"
|
||
//#include "printf.h"
|
||
|
||
struct SimpleFile * openfile;
|
||
|
||
... | ... | |
WORD byteswritten_word;
|
||
FRESULT res;
|
||
|
||
printf("went\n");
|
||
//printf("went\n");
|
||
|
||
file_check_open(file);
|
||
|
||
... | ... | |
if (bytes_this_cycle>(512-pos))
|
||
bytes_this_cycle = 512-pos;
|
||
|
||
printf("file_write:%d/%d - %d/%d\n",sector,pos,bytes_this_cycle,bytes);
|
||
//printf("file_write:%d/%d - %d/%d\n",sector,pos,bytes_this_cycle,bytes);
|
||
|
||
if (sector != write_pending)
|
||
{
|
||
... | ... | |
char temp_buffer[1];
|
||
pf_read(&temp_buffer[0], 1, &byteswritten_word);
|
||
|
||
printf("Writing initial pos:%d\n",pos);
|
||
//printf("Writing initial pos:%d\n",pos);
|
||
|
||
// seek to the initial pos
|
||
fatfs.fptr = fptr + pos;
|
||
... | ... | |
}
|
||
*byteswritten = bytes;
|
||
|
||
printf("wend\n");
|
||
//printf("wend\n");
|
||
return translateStatus(res);
|
||
}
|
||
|
||
... | ... | |
{
|
||
if (write_pending >= 0)
|
||
{
|
||
printf("wflush\n");
|
||
//printf("wflush\n");
|
||
disk_writeflush();
|
||
write_pending = -1;
|
||
}
|
||
... | ... | |
int location = offsetFromStart>>9;
|
||
if (write_pending >=0 && write_pending != offsetFromStart)
|
||
{
|
||
printf("flush on seek\n");
|
||
//printf("flush on seek\n");
|
||
file_write_flush();
|
||
}
|
||
|
||
... | ... | |
|
||
file_write_flush();
|
||
|
||
printf("filename:%s dirname:%s ", filename,&dirname[0]);
|
||
//printf("filename:%s dirname:%s ", filename,&dirname[0]);
|
||
|
||
struct SimpleDirEntry * entry = dir_entries(&dirname[0]);
|
||
while (entry)
|
||
{
|
||
printf("%s ",entry->filename_ptr);
|
||
if (0==strcmp(filename,entry->filename_ptr))
|
||
//printf("%s ",entry->filename_ptr);
|
||
if (0==stricmp(filename,entry->filename_ptr))
|
||
{
|
||
return file_open_dir(entry, file);
|
||
}
|
||
... | ... | |
|
||
write_pending = -1;
|
||
|
||
printf("dir_init\n");
|
||
//printf("dir_init\n");
|
||
|
||
dir_cache = mem;
|
||
dir_cache_size = space;
|
||
|
||
printf("disk_init go\n");
|
||
//printf("disk_init go\n");
|
||
res = disk_initialize();
|
||
printf("disk_init done\n");
|
||
//printf("disk_init done\n");
|
||
if (res!=RES_OK) return translateDStatus(res);
|
||
|
||
printf("pf_mount\n");
|
||
//printf("pf_mount\n");
|
||
fres = pf_mount(&fatfs);
|
||
printf("pf_mount done\n");
|
||
//printf("pf_mount done\n");
|
||
|
||
return translateStatus(fres);
|
||
}
|
||
... | ... | |
|
||
file_write_flush();
|
||
|
||
printf("opendir ");
|
||
//printf("opendir ");
|
||
if (FR_OK != pf_opendir(&dir,dirPath))
|
||
{
|
||
printf("FAIL ");
|
||
//printf("FAIL ");
|
||
return 0;
|
||
}
|
||
printf("OK ");
|
||
//printf("OK ");
|
||
|
||
struct SimpleDirEntry * prev = (struct SimpleDirEntry *)dir_cache;
|
||
strcpy(prev->path,"..");
|
||
... | ... | |
}
|
||
else
|
||
{
|
||
//printf("OUT of room!\n");
|
||
break; // OUT OF ROOM!
|
||
}
|
||
|
||
... | ... | |
|
||
strcpy(&entry->lfn[0],&filinfo.lfname[0]);
|
||
|
||
// printf("%d %s %s\n",count++, filinfo.fname, filinfo.lfname);
|
||
//int count;
|
||
//printf("%d %s %s\n",count++, filinfo.fname, filinfo.lfname);
|
||
|
||
entry->next = 0;
|
||
|
||
... | ... | |
|
||
entry->next = 0;
|
||
|
||
/* struct SimpleDirEntry * begin = (struct SimpleDirEntry *) dir_cache;
|
||
count = 0;
|
||
/*struct SimpleDirEntry * begin = (struct SimpleDirEntry *) dir_cache;
|
||
int count = 0;
|
||
while (begin)
|
||
{
|
||
printf("%d %s\n",count++, begin->path);
|
firmware/fileselector.c | ||
---|---|---|
// TODO!
|
||
#define MAX_PATH_LENGTH (9*5 + 8+3+1 + 1)
|
||
|
||
int filter(struct SimpleDirEntry * entry)
|
||
int (* filter)(struct SimpleDirEntry * entry);
|
||
|
||
int filter_disks(struct SimpleDirEntry * entry)
|
||
{
|
||
if (dir_is_subdir(entry)) return 1;
|
||
char const * f = dir_filename(entry);
|
||
return (compare_ext(f,"ATR") || compare_ext(f,"XFD") || compare_ext(f,"XEX"));
|
||
}
|
||
|
||
int filter_roms(struct SimpleDirEntry * entry)
|
||
{
|
||
if (dir_is_subdir(entry)) return 1;
|
||
char const * f = dir_filename(entry);
|
||
return (compare_ext(f,"ROM"));
|
||
}
|
||
|
||
|
||
void file_selector(struct SimpleFile * file)
|
||
{
|
||
char dir[MAX_PATH_LENGTH] = "";
|
||
... | ... | |
++entries;
|
||
temp_entry = dir_next(temp_entry);
|
||
}
|
||
printf("Entries:%d\n",entries);
|
||
//printf("Entries:%d\n",entries);
|
||
|
||
// Selected item
|
||
int pos = 0;
|
||
... | ... | |
// output the new entries
|
||
int line;
|
||
debug_pos = 0;
|
||
int end = 21*40;
|
||
debug_adjust = 0;
|
||
printf("Choose ");
|
||
debug_adjust = 128;
|
||
printf("file");
|
||
debug_pos = 40;
|
||
int end = 22*40;
|
||
for (;;)
|
||
{
|
||
if (!render_entry) break;
|
||
... | ... | |
debug_pos = 40*23;
|
||
if (sel_entry)
|
||
{
|
||
printf("%s %s %d %d %d",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry), joy.x_, joy.y_, pos);
|
||
//printf("%s %s %d %d %d",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry), joy.x_, joy.y_, pos);
|
||
printf("%s %s",dir_is_subdir(sel_entry) ? "DIR":"", dir_filename(sel_entry));
|
||
}
|
||
}
|
||
|
firmware/fileselector.h | ||
---|---|---|
|
||
void file_selector(struct SimpleFile * file);
|
||
|
||
int filter_disks(struct SimpleDirEntry * entry);
|
||
int filter_roms(struct SimpleDirEntry * entry);
|
||
|
||
extern int (* filter)(struct SimpleDirEntry * entry);
|
||
|
firmware/freeze.c | ||
---|---|---|
}
|
||
|
||
//Clear, except dl (first 0x40 bytes)
|
||
for (i=0x9c40; i!=(0x9c40+1024); i++)
|
||
{
|
||
atari_base[i] = 0;
|
||
}
|
||
clearscreen();
|
||
|
||
// Put custom chips in a safe state
|
||
// write a display list at 9c00
|
||
char dl[] = {
|
||
0x70,0x70,0x70,
|
||
0x42,0x40,0x9c,
|
||
// write a display list at 0600
|
||
unsigned char dl[] = {
|
||
0x70,
|
||
0x70,
|
||
0x47,0x40,0x9c,
|
||
0x70,
|
||
0x42,0x68,0x9c,
|
||
0x2,0x2,0x2,0x2,0x2,
|
||
0x2,0x2,0x2,0x2,0x2,
|
||
0x2,0x2,0x2,0x2,0x2,
|
||
0x2,0x2,0x2,0x2,0x2,
|
||
0x2,0x2,0x2,
|
||
0x70,
|
||
0x41,0x00,0x9c
|
||
0x2,0x2,
|
||
0x41,0x00,0x06
|
||
};
|
||
int j = 0;
|
||
for (i=0x9c00; j!=sizeof(dl); ++i,++j)
|
||
for (i=0x0600; j!=sizeof(dl); ++i,++j)
|
||
{
|
||
atari_base[i] = dl[j];
|
||
}
|
||
|
||
// point antic at my display list
|
||
*atari_dlisth = 0x06;
|
||
*atari_dlistl = 0x00;
|
||
*atari_dlisth = 0x9c;
|
||
|
||
*atari_colbk = 0x00;
|
||
*atari_colpf1 = 0x0f;
|
||
*atari_colpf0 = 0x2f;
|
||
*atari_colpf1 = 0x3f;
|
||
*atari_colpf2 = 0x00;
|
||
*atari_colpf3 = 0x1f;
|
||
*atari_prior = 0x00;
|
||
*atari_chbase = 0xe0;
|
||
*atari_dmactl = 0x22;
|
firmware/main.c | ||
---|---|---|
// 0x410000-0x41FFFF (0xc10000 in zpu space) = directory cache - 64k
|
||
// 0x420000-0x43FFFF (0xc20000 in zpu space) = freeze backup
|
||
|
||
struct SimpleFile * files[4];
|
||
struct SimpleFile * files[5];
|
||
|
||
void loadrom(char const * path, int size, void * ram_address)
|
||
{
|
||
ram_address += 0x800000;
|
||
if (SimpleFile_OK == file_open_name(path, files[4]))
|
||
{
|
||
int read = 0;
|
||
file_read(files[4], ram_address, size, &read);
|
||
}
|
||
}
|
||
|
||
int main(void)
|
||
{
|
||
int i;
|
||
for (i=0; i!=4; ++i)
|
||
for (i=0; i!=5; ++i)
|
||
{
|
||
files[i] = (struct SimpleFile *)alloca(file_struct_size());
|
||
file_init(files[i]);
|
||
... | ... | |
baseaddr = (unsigned char volatile *)(40000 + atari_regbase);
|
||
set_reset_6502(1);
|
||
set_turbo_6502(1);
|
||
set_rom_select(1);
|
||
|
||
init_printf(0, char_out);
|
||
|
||
// TODO...
|
||
|
||
printf("Hello World\n I am an Atari!\n");
|
||
|
||
if (SimpleFile_OK == dir_init((void *)0xc10000, 65536))
|
||
{
|
||
printf("DIR init ok\n");
|
||
// printf("DIR init ok\n");
|
||
init_drive_emulator();
|
||
|
||
loadrom("xlorig.rom",0x4000, (void *)0x704000);
|
||
loadrom("xlhias.rom",0x4000, (void *)0x708000);
|
||
loadrom("ultimon.rom",0x4000, (void *)0x70c000);
|
||
loadrom("osbhias.rom",0x4000, (void *)0x710000);
|
||
loadrom("osborig.rom",0x2800, (void *)0x715800);
|
||
loadrom("osaorig.rom",0x2800, (void *)0x719800);
|
||
loadrom("ataribas.rom",0x2000,(void *)0x700000);
|
||
|
||
//ROM = xlorig.rom,0x4000, (void *)0x704000
|
||
//ROM = xlhias.rom,0x4000, (void *)0x708000
|
||
//ROM = ultimon.rom,0x4000, (void *)0x70c000
|
||
//ROM = osbhias.rom,0x4000, (void *)0x710000
|
||
//ROM = osborig.rom,0x2800, (void *)0x715800
|
||
//ROM = osaorig.rom,0x2800, (void *)0x719800
|
||
//
|
||
//ROM = ataribas.rom,0x2000,(void *)0x700000
|
||
|
||
//--SDRAM_BASIC_ROM_ADDR <= "111"&"000000" &"00000000000000";
|
||
//--SDRAM_OS_ROM_ADDR <= "111"&rom_select &"00000000000000";
|
||
reboot(1);
|
||
run_drive_emulator();
|
||
}
|
||
else
|
||
{
|
||
printf("DIR init failed\n");
|
||
//printf("DIR init failed\n");
|
||
}
|
||
reboot(1);
|
||
for (;;) actions();
|
||
... | ... | |
case 0:
|
||
return "64K";
|
||
case 1:
|
||
return "128";
|
||
return "128K";
|
||
case 2:
|
||
return "320K(Compy)";
|
||
case 3:
|
||
... | ... | |
}
|
||
}
|
||
|
||
void settings()
|
||
int settings()
|
||
{
|
||
struct joystick_status joy;
|
||
joy.x_ = joy.y_ = joy.fire_ = 0;
|
||
... | ... | |
{
|
||
// Render
|
||
clearscreen();
|
||
debug_pos = 20;
|
||
debug_pos = 0;
|
||
debug_adjust = 0;
|
||
printf("Settings");
|
||
printf("Se");
|
||
debug_adjust = 128;
|
||
printf("ttings");
|
||
debug_pos = 80;
|
||
debug_adjust = row==0 ? 128 : 0;
|
||
printf("Turbo:%dx", get_turbo_6502());
|
||
... | ... | |
debug_pos = temp+40;
|
||
}
|
||
|
||
debug_pos = 440;
|
||
debug_pos = 400;
|
||
debug_adjust = row==7 ? 128 : 0;
|
||
printf("Cartridge 8k simple");
|
||
|
||
debug_pos = 480;
|
||
debug_adjust = row==8 ? 128 : 0;
|
||
printf("Exit");
|
||
|
||
// Slow it down a bit
|
||
... | ... | |
|
||
row+=joy.y_;
|
||
if (row<0) row = 0;
|
||
if (row>7) row = 7;
|
||
if (row>8) row = 8;
|
||
switch (row)
|
||
{
|
||
case 0:
|
||
... | ... | |
{
|
||
int rom_select = get_rom_select();
|
||
rom_select+=joy.x_;
|
||
if (rom_select<0) rom_select = 0;
|
||
if (rom_select>7) rom_select = 7; // TODO
|
||
if (rom_select<1) rom_select = 1;
|
||
if (rom_select>6) rom_select = 6; // TODO
|
||
set_rom_select(rom_select);
|
||
}
|
||
break;
|
||
... | ... | |
if (joy.x_>0)
|
||
{
|
||
// Choose new disk
|
||
filter = filter_disks;
|
||
file_selector(files[row-3]);
|
||
set_drive_status(row-3,files[row-3]);
|
||
}
|
||
... | ... | |
}
|
||
break;
|
||
case 7:
|
||
{
|
||
if (joy.fire_)
|
||
{
|
||
filter = filter_roms;
|
||
file_selector(files[4]);
|
||
loadrom(file_name(files[4]),0x2000,(void *)0x700000);
|
||
return 1;
|
||
}
|
||
}
|
||
break;
|
||
case 8:
|
||
if (joy.fire_)
|
||
{
|
||
done = 1;
|
||
... | ... | |
break;
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
void actions()
|
||
... | ... | |
set_pause_6502(1);
|
||
freeze();
|
||
debug_pos = 0;
|
||
settings();
|
||
int do_reboot = settings();
|
||
debug_pos = -1;
|
||
restore();
|
||
set_pause_6502(0);
|
||
if (do_reboot)
|
||
reboot(1);
|
||
else
|
||
set_pause_6502(0);
|
||
}
|
||
else if (get_hotkey_fileselect())
|
||
{
|
||
set_pause_6502(1);
|
||
freeze();
|
||
filter = filter_disks;
|
||
file_selector(files[0]);
|
||
debug_pos = -1;
|
||
restore();
|
firmware/regs.c | ||
---|---|---|
unsigned char volatile * atari_colbk = (unsigned char *)(0xd01a + atari_regbase);
|
||
unsigned char volatile * atari_colpf1 = (unsigned char *)(0xd017 + atari_regbase);
|
||
unsigned char volatile * atari_colpf2 = (unsigned char *)(0xd018 + atari_regbase);
|
||
unsigned char volatile * atari_colpf3 = (unsigned char *)(0xd019 + atari_regbase);
|
||
unsigned char volatile * atari_colpf0 = (unsigned char *)(0xd016 + atari_regbase);
|
||
unsigned char volatile * atari_prior = (unsigned char *)(0xd01b + atari_regbase);
|
||
unsigned char volatile * atari_random = (unsigned char *)(0xd20a + atari_regbase);
|
||
unsigned char volatile * atari_porta = (unsigned char *)(0xd300 + atari_regbase);
|
firmware/regs.h | ||
---|---|---|
extern unsigned char volatile * atari_colbk;
|
||
extern unsigned char volatile * atari_colpf1;
|
||
extern unsigned char volatile * atari_colpf2;
|
||
extern unsigned char volatile * atari_colpf3;
|
||
extern unsigned char volatile * atari_colpf0;
|
||
extern unsigned char volatile * atari_prior;
|
||
extern unsigned char volatile * atari_random;
|
||
extern unsigned char volatile * atari_porta;
|
firmware/sd_direct/diskio_mmc.c | ||
---|---|---|
{
|
||
DSTATUS stat;
|
||
|
||
printf(" in init ");
|
||
//printf(" in init ");
|
||
n_actual_mmc_sector = 0xffffffff;
|
||
do
|
||
{
|
||
... | ... | |
}
|
||
while(mmcReset()); //dokud nenulove, tak smycka (return 0 => ok!)
|
||
|
||
printf(" setting freq ");
|
||
//printf(" setting freq ");
|
||
|
||
set_spi_clock_freq();
|
||
|
firmware/standalone_simple.ld | ||
---|---|---|
MEMORY
|
||
{
|
||
CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x04000 /* 16k */
|
||
RAM (rx) : ORIGIN = 0x0000f000, LENGTH = 0x500 /* 32 bytes */
|
||
RAM (rx) : ORIGIN = 0x0000f000, LENGTH = 0x600 /* 32 bytes */
|
||
}
|
||
|
||
|
firmware/test_file.c | ||
---|---|---|
putc(c, stderr);
|
||
}
|
||
|
||
struct SimpleFile * temp_file;
|
||
|
||
void loadrom(char const * path, int size, void * ram_address)
|
||
{
|
||
filter = 0;
|
||
fprintf(stderr,"loadrom:%s\n",path);
|
||
ram_address += 0x800000;
|
||
if (SimpleFile_OK == file_open_name(path, temp_file))
|
||
{
|
||
int read = 0;
|
||
//file_read(files[4], ram_address, size, &read);
|
||
printf("file_read:%s %x %x\n",file_name(temp_file), ram_address,size);
|
||
}
|
||
else
|
||
{
|
||
printf("FAILED\n");
|
||
}
|
||
}
|
||
|
||
int main(void)
|
||
{
|
||
init_printf(NULL, char_out);
|
||
|
||
char * mem = (char *)malloc(8192);
|
||
if (SimpleFile_OK != dir_init(mem, 8192))
|
||
char * mem = (char *)malloc(65536);
|
||
if (SimpleFile_OK != dir_init(mem, 65536))
|
||
{
|
||
fprintf(stderr,"Failed to open dir!");
|
||
return -1;
|
||
... | ... | |
}
|
||
|
||
|
||
/*
|
||
fprintf(stderr,"\n\n");
|
||
//enum SimpleFileStatus file_open_name(char const * path, struct SimpleFile * file);
|
||
//enum SimpleFileStatus file_open_dir(struct SimpleDirEntry * filename, struct SimpleFile * file);
|
||
... | ... | |
//file_write_flush(); // Done automatically on next read, or can be forced with this...
|
||
|
||
file_seek(file,512);
|
||
/* for (i=0;i!=130;++i)
|
||
{
|
||
char towrite[9];
|
||
sprintf(&towrite[0],"Mark:%03d",i);
|
||
fprintf(stderr,"Writing \"%s\"\n",towrite);
|
||
file_write(file,towrite,8,&written);
|
||
}*/
|
||
file_write(file,"Blah",4,&written);
|
||
// for (i=0;i!=130;++i)
|
||
// {
|
||
// char towrite[9];
|
||
// sprintf(&towrite[0],"Mark:%03d",i);
|
||
// fprintf(stderr,"Writing \"%s\"\n",towrite);
|
||
// file_write(file,towrite,8,&written);
|
||
// }
|
||
// file_write(file,"Blah",4,&written);
|
||
|
||
printf("\n*** WTF:%s - %s - %s\n",file_name(file), file_of("/WTF"),file_of("/BLAH/BOOP"));
|
||
|
||
... | ... | |
//fprintf(stderr,"%02x", buffer[i]);
|
||
fprintf(stderr,"%c", buffer[i]);
|
||
}
|
||
*/
|
||
|
||
file_selector(file);
|
||
temp_file = alloca(file_struct_size());
|
||
loadrom("ASTEROID.BIN",0x4000, (void *)0x704000);
|
||
loadrom("asteroid.bin",0x4000, (void *)0x704000);
|
||
loadrom("xlorig.rom",0x4000, (void *)0x704000);
|
||
loadrom("xlhias.rom",0x4000, (void *)0x708000);
|
||
loadrom("ultimon.rom",0x4000, (void *)0x70c000);
|
||
loadrom("osbhias.rom",0x4000, (void *)0x710000);
|
||
loadrom("osborig.rom",0x2800, (void *)0x715800);
|
||
loadrom("osaorig.rom",0x2800, (void *)0x719800);
|
||
loadrom("ataribas.rom",0x2000,(void *)0x700000);
|
||
|
||
//file_selector(file);
|
||
|
||
return 0;
|
||
}
|
||
|
Also available in: Unified diff
Add titles. Load rom from sd.