diff --git a/Binary/Flasher.bin b/Binary/Flasher.bin index 980f2d8..39b852a 100644 Binary files a/Binary/Flasher.bin and b/Binary/Flasher.bin differ diff --git a/Binary/Flasher.dsk b/Binary/Flasher.dsk index d9324df..2079618 100644 Binary files a/Binary/Flasher.dsk and b/Binary/Flasher.dsk differ diff --git a/Software/Flasher.bin b/Software/Flasher.bin new file mode 100644 index 0000000..fc5a0a3 Binary files /dev/null and b/Software/Flasher.bin differ diff --git a/Software/Flasher.dsk b/Software/Flasher.dsk new file mode 100644 index 0000000..69b2d62 Binary files /dev/null and b/Software/Flasher.dsk differ diff --git a/Software/make_image.sh b/Software/make_image.sh new file mode 100755 index 0000000..a777fcd --- /dev/null +++ b/Software/make_image.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +make clean +make +java -jar AppleCommander-ac-1.5.0.jar -d flasher.dsk flasher +java -jar AppleCommander-ac-1.5.0.jar -as flasher.dsk flasher < flasher.bin diff --git a/Software/src/AppleIISd.h b/Software/src/AppleIISd.h index 50e5fe8..31a0025 100644 --- a/Software/src/AppleIISd.h +++ b/Software/src/AppleIISd.h @@ -6,16 +6,20 @@ typedef unsigned short uint16; typedef unsigned long uint32; typedef unsigned char boolean; +#ifndef TRUE #define TRUE 1 +#endif +#ifndef FALSE #define FALSE 0 +#endif -#define SLOT_IO_START (uint8*)0xC080 -#define SLOT_ROM_START (uint8*)0xC000 -#define EXT_ROM_START (uint8*)0xC800 +#define SLOT_IO_START (volatile uint8*)0xC080 +#define SLOT_ROM_START (volatile uint8*)0xC000 +#define EXT_ROM_START (volatile uint8*)0xC800 -#define CFFF (uint8*)0xCFFF +#define CFFF (volatile uint8*)0xCFFF -typedef struct +typedef volatile struct { // data register // +0 @@ -40,12 +44,9 @@ typedef struct uint8 status; } status; - // clock divisor register + // clock divisor register, unused // +2 - union - { - unsigned clkDiv : 2; - }; + uint8 clkDiv; // slave select and card state register // +3 @@ -56,8 +57,8 @@ typedef struct unsigned slaveSel : 1; unsigned : 3; unsigned sdhc : 1; - unsigned wp : 1; - unsigned card : 1; + const unsigned wp : 1; + const unsigned card : 1; unsigned inited : 1; }; diff --git a/Software/src/Flasher.c b/Software/src/Flasher.c index 4bf1e5c..718ffd7 100644 --- a/Software/src/Flasher.c +++ b/Software/src/Flasher.c @@ -5,6 +5,8 @@ #include #include +// Binary can't be larger than 2k +#define BUFFER_SIZE 2048 #define BIN_FILE_NAME "AppleIISd.bin" typedef enum @@ -14,17 +16,16 @@ typedef enum STATE_2, // hyphen STATE_3, // backslash - STATE_LAST // don't use + STATE_LAST // don't use } STATE_CURSOR_T; const char state_char[STATE_LAST] = { '|', '/', '-', '\\' }; +uint8 buffer[BUFFER_SIZE] = { 0 }; -boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length); +boolean writeChip(const uint8* pSource, volatile uint8* pDest, uint16 length); void printStatus(uint8 percentage); -// Binary can't be larger than 2k -uint8 buffer[2048] = { 0 }; int main() { @@ -35,8 +36,7 @@ int main() uint16 fileSize = 0; APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START; - uint8* pSlotRom = SLOT_ROM_START; - uint8* pExtRom = EXT_ROM_START; + volatile uint8* pSlotRom = SLOT_ROM_START; videomode(VIDEOMODE_40COL); clrscr(); @@ -76,7 +76,7 @@ int main() if(erase) { // buffer is already filled with 0 - fileSize = 2048; + fileSize = BUFFER_SIZE; } else { @@ -89,7 +89,7 @@ int main() fclose(pFile); pFile = NULL; - if(fileSize != 2048) + if(fileSize != BUFFER_SIZE) { cprintf("\r\nWrong file size: %d\r\n", fileSize); } @@ -101,7 +101,7 @@ int main() } } - if(fileSize == 2048) + if(fileSize == BUFFER_SIZE) { // enable write pAIISD->status.pgmen = 1; @@ -115,7 +115,7 @@ int main() { // write to EXTROM cprintf("\r\nFlashing EXTROM: "); - if(writeChip(buffer + 256, pExtRom, fileSize - 256)) + if(writeChip(buffer + 256, EXT_ROM_START, fileSize - 256)) { cprintf("\r\n\r\nFlashing finished!\n"); retval = 0; @@ -130,12 +130,11 @@ int main() return retval; } -boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length) +boolean writeChip(const uint8* pSource, volatile uint8* pDest, uint16 length) { uint32 i; - uint8 data = 0; - uint8 readData; - volatile uint8* pDestination = pDest; + volatile uint8 data = 0; + volatile uint8 readData; for(i=0; i