First flasher version, untested
This commit is contained in:
parent
781d283c3c
commit
5ba4e08c84
|
@ -19,6 +19,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Flasher.c" />
|
<ClCompile Include="src\Flasher.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\AppleIISd.h" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{B2CF2E9D-62A7-4A68-9477-9B15A8707E78}</ProjectGuid>
|
<ProjectGuid>{B2CF2E9D-62A7-4A68-9477-9B15A8707E78}</ProjectGuid>
|
||||||
<Keyword>MakeFileProj</Keyword>
|
<Keyword>MakeFileProj</Keyword>
|
||||||
|
|
|
@ -9,4 +9,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Flasher.c" />
|
<ClCompile Include="src\Flasher.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\AppleIISd.h" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,62 @@
|
||||||
|
#ifndef APPLE_II_SD_H
|
||||||
|
#define APPLE_II_SD_H
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
#define SLOT_IO_START (byte*)0xC080
|
||||||
|
#define SLOT_ROM_START (byte*)0xC000
|
||||||
|
#define EXT_ROM_START (byte*)0xC800
|
||||||
|
|
||||||
|
#define CFFF (byte*)0xCFFF
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// data register
|
||||||
|
// +0
|
||||||
|
byte data;
|
||||||
|
|
||||||
|
// status register
|
||||||
|
// +1
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned pgmen : 1;
|
||||||
|
unsigned : 1;
|
||||||
|
unsigned ece : 1;
|
||||||
|
unsigned : 1;
|
||||||
|
unsigned frx : 1;
|
||||||
|
const unsigned bsy : 1;
|
||||||
|
unsigned : 1;
|
||||||
|
const unsigned tc : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
byte status;
|
||||||
|
} status;
|
||||||
|
|
||||||
|
// clock divisor register
|
||||||
|
// +2
|
||||||
|
union
|
||||||
|
{
|
||||||
|
unsigned clkDiv : 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
// slave select and card state register
|
||||||
|
// +3
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned slaveSel : 1;
|
||||||
|
unsigned : 3;
|
||||||
|
unsigned sdhc : 1;
|
||||||
|
unsigned wp : 1;
|
||||||
|
unsigned card : 1;
|
||||||
|
unsigned inited : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
byte ss_card;
|
||||||
|
} ss_card;
|
||||||
|
} APPLE_II_SD_T;
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,18 +1,38 @@
|
||||||
|
#include "AppleIISd.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <apple2enh.h>
|
#include <apple2enh.h>
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
STATE_0 = 0x7C, // pipe
|
||||||
|
STATE_1 = 0x2F, // slash
|
||||||
|
STATE_2 = 0x2D, // hyphen
|
||||||
|
STATE_3 = 0x5C, // backslash
|
||||||
|
|
||||||
|
STATE_LAST // don't use
|
||||||
|
} STATE_CURSOR_T;
|
||||||
|
|
||||||
|
|
||||||
|
void writeChip(const byte* pSource, byte* pDest, unsigned length);
|
||||||
|
void printStatus(byte percentage);
|
||||||
|
|
||||||
|
// Binary can't be larger than 2k
|
||||||
|
byte buffer[2048] = { 0 };
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Binary can't be larger than 2k
|
|
||||||
char buffer[2048];
|
|
||||||
char* pBuf = buffer;
|
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
size_t fileSize;
|
|
||||||
char slotNum;
|
char slotNum;
|
||||||
|
|
||||||
|
APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START;
|
||||||
|
byte* pSlotRom = SLOT_ROM_START;
|
||||||
|
byte* pExtRom = EXT_ROM_START;
|
||||||
|
|
||||||
videomode(VIDEOMODE_80COL);
|
videomode(VIDEOMODE_80COL);
|
||||||
|
clrscr();
|
||||||
cprintf("AppleIISd firmware flasher\r");
|
cprintf("AppleIISd firmware flasher\r");
|
||||||
cprintf("(c) 2019 Florian Reitz\r\r");
|
cprintf("(c) 2019 Florian Reitz\r\r");
|
||||||
|
|
||||||
|
@ -29,23 +49,40 @@ int main()
|
||||||
return 1; // failure
|
return 1; // failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((byte*)pAIISD) += slotNum << 4;
|
||||||
|
pSlotRom += slotNum << 8;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
pFile = fopen("AppleIISd.bin", "rb");
|
pFile = fopen("AppleIISd.bin", "rb");
|
||||||
if(pFile)
|
if(pFile)
|
||||||
{
|
{
|
||||||
// read buffer
|
// read buffer
|
||||||
fileSize = fread(buffer, sizeof(buffer), 1, pFile);
|
unsigned fileSize = fread(buffer, sizeof(buffer), 1, pFile);
|
||||||
|
|
||||||
// enable write
|
// enable write
|
||||||
|
pAIISD->status.pgmen = 1;
|
||||||
|
|
||||||
// clear 0xCFFF
|
// clear 0xCFFF
|
||||||
*((char*)0xCFFF) = 0;
|
*CFFF = 0;
|
||||||
|
|
||||||
// write to SLOTROM
|
// write to SLOTROM
|
||||||
|
cprintf("\r\rFlashing SLOTROM: ");
|
||||||
|
writeChip(buffer, pSlotRom, 256);
|
||||||
|
|
||||||
// write to EXTROM
|
// write to EXTROM
|
||||||
|
cprintf("\r\rFlashing EXTROM: ");
|
||||||
|
writeChip(buffer + 256, pExtRom, fileSize - 256);
|
||||||
|
|
||||||
|
// zero rest of chip
|
||||||
|
if(fileSize < 2048)
|
||||||
|
{
|
||||||
|
cprintf("\r\rErase rest of chip: ");
|
||||||
|
writeChip(NULL, pExtRom + fileSize, 2048 - fileSize);
|
||||||
|
}
|
||||||
|
|
||||||
// disable write
|
// disable write
|
||||||
|
pAIISD->status.pgmen = 0;
|
||||||
|
cprintf("\r\r Flashing finished!\r");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -56,4 +93,37 @@ int main()
|
||||||
return 0; // success
|
return 0; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeChip(const byte* pSource, byte* pDest, unsigned length)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
for(i=0; i<length; i++)
|
||||||
|
{
|
||||||
|
if(pSource)
|
||||||
|
{
|
||||||
|
*pDest = pSource[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// erase if no source
|
||||||
|
*pDest = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printStatus(i * 100 / length);
|
||||||
|
pDest++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printStatus(byte percentage)
|
||||||
|
{
|
||||||
|
static STATE_CURSOR_T state = STATE_0;
|
||||||
|
|
||||||
|
byte x = wherex();
|
||||||
|
cprintf("% 2hhu %c", percentage, (char)state);
|
||||||
|
gotox(x);
|
||||||
|
|
||||||
|
state++;
|
||||||
|
if(state == STATE_LAST)
|
||||||
|
{
|
||||||
|
state = STATE_0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue