forked from Apple-2-HW/AppleIISd
Erase added to flasher
This commit is contained in:
parent
320602e692
commit
93b8d73490
Binary file not shown.
Binary file not shown.
@ -11,8 +11,8 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\AppleIISd.bin.map" />
|
|
||||||
<None Include="..\README.md" />
|
<None Include="..\README.md" />
|
||||||
|
<None Include="AppleIISd.bin.map" />
|
||||||
<None Include="makefile" />
|
<None Include="makefile" />
|
||||||
<None Include="Makefile.options" />
|
<None Include="Makefile.options" />
|
||||||
<None Include="obj\AppleIISd.lst" />
|
<None Include="obj\AppleIISd.lst" />
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</None>
|
</None>
|
||||||
<None Include="Makefile.options" />
|
<None Include="Makefile.options" />
|
||||||
<None Include="..\README.md" />
|
<None Include="..\README.md" />
|
||||||
<None Include="..\AppleIISd.bin.map" />
|
<None Include="AppleIISd.bin.map" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="src">
|
<Filter Include="src">
|
||||||
|
@ -28,9 +28,11 @@ uint8 buffer[2048] = { 0 };
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 1;
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
char slotNum;
|
char slotNum;
|
||||||
|
boolean erase = FALSE;
|
||||||
|
uint16 fileSize = 0;
|
||||||
|
|
||||||
APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START;
|
APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START;
|
||||||
uint8* pSlotRom = SLOT_ROM_START;
|
uint8* pSlotRom = SLOT_ROM_START;
|
||||||
@ -39,7 +41,7 @@ int main()
|
|||||||
videomode(VIDEOMODE_40COL);
|
videomode(VIDEOMODE_40COL);
|
||||||
clrscr();
|
clrscr();
|
||||||
cprintf("AppleIISd firmware flasher\r\n");
|
cprintf("AppleIISd firmware flasher\r\n");
|
||||||
cprintf("(c) 2019 Florian Reitz\r\n\r\n");
|
cprintf("(c) 2019-2020 Florian Reitz\r\n\r\n");
|
||||||
|
|
||||||
// ask for slot
|
// ask for slot
|
||||||
cursor(1); // enable blinking cursor
|
cursor(1); // enable blinking cursor
|
||||||
@ -48,6 +50,18 @@ int main()
|
|||||||
slotNum -= 0x30;
|
slotNum -= 0x30;
|
||||||
cursor(0); // disable blinking cursor
|
cursor(0); // disable blinking cursor
|
||||||
|
|
||||||
|
if(slotNum == 0)
|
||||||
|
{
|
||||||
|
// erase device
|
||||||
|
erase = TRUE;
|
||||||
|
// ask for slot
|
||||||
|
cursor(1); // enable blinking cursor
|
||||||
|
cprintf("Erase device in slot number (1-7): ");
|
||||||
|
cscanf("%c", &slotNum);
|
||||||
|
slotNum -= 0x30;
|
||||||
|
cursor(0); // disable blinking cursor
|
||||||
|
}
|
||||||
|
|
||||||
// check if slot is valid
|
// check if slot is valid
|
||||||
if((slotNum < 1) || (slotNum > 7))
|
if((slotNum < 1) || (slotNum > 7))
|
||||||
{
|
{
|
||||||
@ -59,15 +73,34 @@ int main()
|
|||||||
((uint8*)pAIISD) += slotNum << 4;
|
((uint8*)pAIISD) += slotNum << 4;
|
||||||
pSlotRom += slotNum << 8;
|
pSlotRom += slotNum << 8;
|
||||||
|
|
||||||
|
if(erase)
|
||||||
|
{
|
||||||
|
// buffer is already filled with 0
|
||||||
|
fileSize = 2048;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// open file
|
// open file
|
||||||
pFile = fopen(BIN_FILE_NAME, "rb");
|
pFile = fopen(BIN_FILE_NAME, "rb");
|
||||||
if(pFile)
|
if(pFile)
|
||||||
{
|
{
|
||||||
// read buffer
|
// read buffer
|
||||||
uint16 fileSize = fread(buffer, 1, sizeof(buffer), pFile);
|
fileSize = fread(buffer, 1, sizeof(buffer), pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
pFile = NULL;
|
pFile = NULL;
|
||||||
|
|
||||||
|
if(fileSize != 2048)
|
||||||
|
{
|
||||||
|
cprintf("\r\nWrong file size: %d\r\n", fileSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME);
|
||||||
|
fileSize = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(fileSize == 2048)
|
if(fileSize == 2048)
|
||||||
{
|
{
|
||||||
// enable write
|
// enable write
|
||||||
@ -85,31 +118,13 @@ int main()
|
|||||||
if(writeChip(buffer + 256, pExtRom, fileSize - 256))
|
if(writeChip(buffer + 256, pExtRom, fileSize - 256))
|
||||||
{
|
{
|
||||||
cprintf("\r\n\r\nFlashing finished!\n");
|
cprintf("\r\n\r\nFlashing finished!\n");
|
||||||
|
retval = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
retval = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retval = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable write
|
// disable write
|
||||||
pAIISD->status.pgmen = 0;
|
pAIISD->status.pgmen = 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
cprintf("\r\nWrong file size: %d\r\n", fileSize);
|
|
||||||
retval = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME);
|
|
||||||
retval = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cgetc();
|
cgetc();
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user