diff --git a/Software/src/AppleIISd.h b/Software/src/AppleIISd.h index d0b1566..50e5fe8 100644 --- a/Software/src/AppleIISd.h +++ b/Software/src/AppleIISd.h @@ -4,6 +4,10 @@ typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned long uint32; +typedef unsigned char boolean; + +#define TRUE 1 +#define FALSE 0 #define SLOT_IO_START (uint8*)0xC080 #define SLOT_ROM_START (uint8*)0xC000 diff --git a/Software/src/Flasher.c b/Software/src/Flasher.c index bd208fe..62197b2 100644 --- a/Software/src/Flasher.c +++ b/Software/src/Flasher.c @@ -20,7 +20,7 @@ typedef enum const char state_char[STATE_LAST] = { '|', '/', '-', '\\' }; -void writeChip(const uint8* pSource, uint8* pDest, uint16 length); +boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length); void printStatus(uint8 percentage); // Binary can't be larger than 2k @@ -28,6 +28,7 @@ uint8 buffer[2048] = { 0 }; int main() { + int retval = 0; FILE* pFile; char slotNum; @@ -76,49 +77,68 @@ int main() // write to SLOTROM cprintf("\r\n\r\nFlashing SLOTROM: "); - writeChip(buffer, pSlotRom, 256); - - // write to EXTROM - cprintf("\r\nFlashing EXTROM: "); - writeChip(buffer + 256, pExtRom, fileSize - 256); + if(writeChip(buffer, pSlotRom, 256)) + { + // write to EXTROM + cprintf("\r\nFlashing EXTROM: "); + if(writeChip(buffer + 256, pExtRom, fileSize - 256)) + { + cprintf("\r\n\r\nFlashing finished!\n"); + } + else + { + retval = 1; + } + } + else + { + retval = 1; + } // disable write pAIISD->status.pgmen = 0; - cprintf("\r\n\r\nFlashing finished!\n"); } else { cprintf("\r\nWrong file size: %d\r\n", fileSize); - return 1; + retval = 1; } } else { cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME); - return 1; + retval = 1; } - return 0; // success + return retval; } -void writeChip(const uint8* pSource, uint8* pDest, uint16 length) +boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length) { uint32 i; + uint8 data = 0; + for(i=0; i