mirror of
https://github.com/freitz85/AppleIISd.git
synced 2024-06-09 22:29:43 +00:00
Fixes for console output
This commit is contained in:
parent
62443e8b18
commit
88b075357a
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
typedef unsigned int uint32;
|
typedef unsigned long uint32;
|
||||||
|
|
||||||
#define SLOT_IO_START (uint8*)0xC080
|
#define SLOT_IO_START (uint8*)0xC080
|
||||||
#define SLOT_ROM_START (uint8*)0xC000
|
#define SLOT_ROM_START (uint8*)0xC000
|
||||||
|
|
|
@ -5,16 +5,19 @@
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <apple2enh.h>
|
#include <apple2enh.h>
|
||||||
|
|
||||||
|
#define BIN_FILE_NAME "AppleIISd.bin"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
STATE_0 = 0x7C, // pipe
|
STATE_0, // pipe
|
||||||
STATE_1 = 0x2F, // slash
|
STATE_1, // slash
|
||||||
STATE_2 = 0x2D, // hyphen
|
STATE_2, // hyphen
|
||||||
STATE_3 = 0x5C, // backslash
|
STATE_3, // backslash
|
||||||
|
|
||||||
STATE_LAST // don't use
|
STATE_LAST // don't use
|
||||||
} STATE_CURSOR_T;
|
} STATE_CURSOR_T;
|
||||||
|
|
||||||
|
const char state_char[STATE_LAST] = { '|', '/', '-', '\\' };
|
||||||
|
|
||||||
|
|
||||||
void writeChip(const uint8* pSource, uint8* pDest, uint16 length);
|
void writeChip(const uint8* pSource, uint8* pDest, uint16 length);
|
||||||
|
@ -34,19 +37,20 @@ int main()
|
||||||
|
|
||||||
videomode(VIDEOMODE_80COL);
|
videomode(VIDEOMODE_80COL);
|
||||||
clrscr();
|
clrscr();
|
||||||
cprintf("AppleIISd firmware flasher\r");
|
cprintf("AppleIISd firmware flasher\r\n");
|
||||||
cprintf("(c) 2019 Florian Reitz\r\r");
|
cprintf("(c) 2019 Florian Reitz\r\n\r\n");
|
||||||
|
|
||||||
// ask for slot
|
// ask for slot
|
||||||
cursor(1); // enable blinking cursor
|
cursor(1); // enable blinking cursor
|
||||||
cprintf("Slot number (1-7): ");
|
cprintf("Slot number (1-7): ");
|
||||||
slotNum = cgetc();
|
cscanf("%c", &slotNum);
|
||||||
|
slotNum -= 0x30;
|
||||||
cursor(0); // disable blinking cursor
|
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))
|
||||||
{
|
{
|
||||||
cprintf("Invalid slot number!");
|
cprintf("\r\nInvalid slot number!");
|
||||||
return 1; // failure
|
return 1; // failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +58,7 @@ int main()
|
||||||
pSlotRom += slotNum << 8;
|
pSlotRom += slotNum << 8;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
pFile = fopen("AppleIISd.bin", "rb");
|
pFile = fopen(BIN_FILE_NAME, "rb");
|
||||||
if(pFile)
|
if(pFile)
|
||||||
{
|
{
|
||||||
// read buffer
|
// read buffer
|
||||||
|
@ -71,15 +75,16 @@ int main()
|
||||||
*CFFF = 0;
|
*CFFF = 0;
|
||||||
|
|
||||||
// write to SLOTROM
|
// write to SLOTROM
|
||||||
cprintf("\r\rFlashing SLOTROM: ");
|
cprintf("\r\n\r\nFlashing SLOTROM: ");
|
||||||
writeChip(buffer, pSlotRom, 256);
|
writeChip(buffer, pSlotRom, 256);
|
||||||
|
|
||||||
// write to EXTROM
|
// write to EXTROM
|
||||||
cprintf("\r\rFlashing EXTROM: ");
|
cprintf("\r\nFlashing EXTROM: ");
|
||||||
writeChip(buffer + 256, pExtRom, fileSize - 256);
|
writeChip(buffer + 256, pExtRom, fileSize - 256);
|
||||||
|
|
||||||
// zero rest of chip
|
// disable write
|
||||||
if(fileSize < 2048)
|
pAIISD->status.pgmen = 0;
|
||||||
|
cprintf("\r\n\r\nFlashing finished!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -89,7 +94,7 @@ int main()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cprintf("Can't open binary file: %d\r", errno);
|
cprintf("\r\nCan't open %s file\r\n", BIN_FILE_NAME);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +116,7 @@ void writeChip(const uint8* pSource, uint8* pDest, uint16 length)
|
||||||
*pDest = 0;
|
*pDest = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printStatus(i * 100 / length);
|
printStatus((i * 100u / length) + 1);
|
||||||
pDest++;
|
pDest++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,11 +125,17 @@ void printStatus(uint8 percentage)
|
||||||
{
|
{
|
||||||
static STATE_CURSOR_T state = STATE_0;
|
static STATE_CURSOR_T state = STATE_0;
|
||||||
uint8 wait = 0;
|
uint8 wait = 0;
|
||||||
|
|
||||||
uint8 x = wherex();
|
uint8 x = wherex();
|
||||||
cprintf("% 2hhu %c", percentage, (char)state);
|
char cState = (percentage < 100) ? state_char[state] : ' ';
|
||||||
|
|
||||||
|
cprintf("% 2hhu%% %c", percentage, cState);
|
||||||
gotox(x);
|
gotox(x);
|
||||||
|
|
||||||
|
while(wait < 0xff)
|
||||||
|
{
|
||||||
|
wait++;
|
||||||
|
}
|
||||||
|
|
||||||
state++;
|
state++;
|
||||||
if(state == STATE_LAST)
|
if(state == STATE_LAST)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user