Add c128e target machine

This commit is contained in:
drmortalwombat 2024-01-06 09:09:52 +01:00
parent a7d7db37df
commit 1c1d7fefaa
8 changed files with 49 additions and 13 deletions

View File

@ -1 +1,8 @@
#include "mmu.h" #include "mmu.h"
inline char mmu_set(char cr)
{
char pcr = mmu.cr;
mmu.cr = cr;
return pcr;
}

View File

@ -39,6 +39,8 @@ __asm dswap
sta 0xff01 sta 0xff01
} }
#pragma code(code) #pragma code(code)
#elif defined(__C128B__) || defined(__C128E__)
#define dswap 0xff5f
#elif defined(__PLUS4__) #elif defined(__PLUS4__)
#pragma code(lowcode) #pragma code(lowcode)
__asm bsout __asm bsout
@ -100,7 +102,7 @@ __asm bsinit
#define bsinit 0xff81 #define bsinit 0xff81
#endif #endif
#if defined(__C128__) #if defined(__C128__) || defined(__C128B__) || defined(__C128E__)
void dispmode40col(void) void dispmode40col(void)
{ {
if (*(volatile char *)0xd7 >= 128) if (*(volatile char *)0xd7 >= 128)

View File

@ -18,7 +18,7 @@ extern IOCharMap giocharmap;
void iocharmap(IOCharMap chmap); void iocharmap(IOCharMap chmap);
#if defined(__C128__) #if defined(__C128__) || defined(__C128B__) || defined(__C128E__)
void dispmode40col(void); void dispmode40col(void);
void dispmode80col(void); void dispmode80col(void);
#endif #endif

View File

@ -211,6 +211,9 @@ w0:
#if defined(__C128__) #if defined(__C128__)
sta 0xff01 sta 0xff01
#elif defined(__C128E__)
lda #$0e
sta 0xff00
#elif defined(__PLUS4__) #elif defined(__PLUS4__)
lda #<p4irq lda #<p4irq
sta $fffe sta $fffe

View File

@ -604,36 +604,36 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print)
si.precision = i; si.precision = i;
} }
if (c == 'd') if (c == 'd' || c == p'd')
{ {
bi = nformi(&si, bp, *fps++, true); bi = nformi(&si, bp, *fps++, true);
} }
else if (c == 'u') else if (c == 'u' || c == p'u')
{ {
bi = nformi(&si, bp, *fps++, false); bi = nformi(&si, bp, *fps++, false);
} }
else if (c == 'x') else if (c == 'x' || c == p'x')
{ {
si.base = 16; si.base = 16;
bi = nformi(&si, bp, *fps++, false); bi = nformi(&si, bp, *fps++, false);
} }
#ifndef NOLONG #ifndef NOLONG
else if (c == 'l') else if (c == 'l' || c == p'l')
{ {
long l = *(long *)fps; long l = *(long *)fps;
fps ++; fps ++;
fps ++; fps ++;
c = *p++; c = *p++;
if (c == 'd') if (c == 'd' || c == p'd')
{ {
bi = nforml(&si, bp, l, true); bi = nforml(&si, bp, l, true);
} }
else if (c == 'u') else if (c == 'u' || c == p'u')
{ {
bi = nforml(&si, bp, l, false); bi = nforml(&si, bp, l, false);
} }
else if (c == 'x') else if (c == 'x' || c == p'x')
{ {
si.base = 16; si.base = 16;
bi = nforml(&si, bp, l, false); bi = nforml(&si, bp, l, false);
@ -641,14 +641,14 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print)
} }
#endif #endif
#ifndef NOFLOAT #ifndef NOFLOAT
else if (c == 'f' || c == 'g' || c == 'e') else if (c == 'f' || c == 'g' || c == 'e' || c == p'f' || c == p'g' || c == p'e')
{ {
bi = nformf(&si, bp, *(float *)fps, c); bi = nformf(&si, bp, *(float *)fps, c);
fps ++; fps ++;
fps ++; fps ++;
} }
#endif #endif
else if (c == 's') else if (c == 's' || c == p's')
{ {
char * sp = (char *)*fps++; char * sp = (char *)*fps++;
@ -694,7 +694,7 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print)
} }
} }
} }
else if (c == 'c') else if (c == 'c' || c == p'c')
{ {
bp[bi++] = *fps++; bp[bi++] = *fps++;
} }
@ -856,7 +856,7 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
} }
} }
if (fc == 'l') if (fc == 'l' || fc == p'l')
{ {
islong = true; islong = true;
fc = *fmt++; fc = *fmt++;
@ -871,11 +871,15 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
break; break;
case 'x': case 'x':
case p'x':
base = 16; base = 16;
case 'u': case 'u':
case p'u':
issigned = false; issigned = false;
case 'i': case 'i':
case 'd': case 'd':
case p'i':
case p'd':
{ {
bool sign = false; bool sign = false;
if (cs == '-') if (cs == '-')
@ -956,6 +960,9 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
case 'f': case 'f':
case 'e': case 'e':
case 'g': case 'g':
case p'f':
case p'e':
case p'g':
{ {
bool sign = false; bool sign = false;
if (cs == '-') if (cs == '-')
@ -1062,6 +1069,7 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
} break; } break;
#endif #endif
case 's': case 's':
case p's':
{ {
char * pch = (char *)*params; char * pch = (char *)*params;
while (width > 0 && cs > 0 && !isspace(cs)) while (width > 0 && cs > 0 && !isspace(cs))
@ -1104,6 +1112,7 @@ int fpscanf(const char * fmt, int (* ffunc)(void * p), void * fparam, void ** pa
} break; } break;
case 'c': case 'c':
case p'c':
{ {
char * pch = (char *)*params; char * pch = (char *)*params;
if (!ignore) if (!ignore)

View File

@ -542,6 +542,7 @@ bool Compiler::GenerateCode(void)
regionLowcode->mSections.Push(mCompilationUnits->mSectionLowCode); regionLowcode->mSections.Push(mCompilationUnits->mSectionLowCode);
break; break;
case TMACH_C128B: case TMACH_C128B:
case TMACH_C128E:
if (mCompilerOptions & COPT_NATIVE) if (mCompilerOptions & COPT_NATIVE)
regionStartup = mLinker->AddRegion(identStartup, 0x1c01, 0x1c80); regionStartup = mLinker->AddRegion(identStartup, 0x1c01, 0x1c80);
else else
@ -628,6 +629,7 @@ bool Compiler::GenerateCode(void)
break; break;
case TMACH_C128: case TMACH_C128:
case TMACH_C128B: case TMACH_C128B:
case TMACH_C128E:
regionBytecode = mLinker->AddRegion(identBytecode, 0x1d00, 0x1e00); regionBytecode = mLinker->AddRegion(identBytecode, 0x1d00, 0x1e00);
break; break;
case TMACH_PLUS4: case TMACH_PLUS4:
@ -692,6 +694,9 @@ bool Compiler::GenerateCode(void)
case TMACH_C128B: case TMACH_C128B:
regionMain = mLinker->AddRegion(identMain, 0x1e00, 0x4000); regionMain = mLinker->AddRegion(identMain, 0x1e00, 0x4000);
break; break;
case TMACH_C128E:
regionMain = mLinker->AddRegion(identMain, 0x1e00, 0xc000);
break;
case TMACH_PLUS4: case TMACH_PLUS4:
regionMain = mLinker->AddRegion(identMain, 0x1200, 0xfc00); regionMain = mLinker->AddRegion(identMain, 0x1200, 0xfc00);
break; break;
@ -744,6 +749,9 @@ bool Compiler::GenerateCode(void)
case TMACH_C128B: case TMACH_C128B:
regionMain = mLinker->AddRegion(identMain, 0x1c80, 0x4000); regionMain = mLinker->AddRegion(identMain, 0x1c80, 0x4000);
break; break;
case TMACH_C128E:
regionMain = mLinker->AddRegion(identMain, 0x1c80, 0xc000);
break;
case TMACH_PLUS4: case TMACH_PLUS4:
regionMain = mLinker->AddRegion(identMain, 0x1100, 0xfc00); regionMain = mLinker->AddRegion(identMain, 0x1100, 0xfc00);
break; break;

View File

@ -61,6 +61,7 @@ enum TargetMachine
TMACH_VIC20_24K, TMACH_VIC20_24K,
TMACH_C128, TMACH_C128,
TMACH_C128B, TMACH_C128B,
TMACH_C128E,
TMACH_PET_8K, TMACH_PET_8K,
TMACH_PET_16K, TMACH_PET_16K,
TMACH_PET_32K, TMACH_PET_32K,

View File

@ -303,6 +303,12 @@ int main2(int argc, const char** argv)
compiler->mTargetMachine = TMACH_C128B; compiler->mTargetMachine = TMACH_C128B;
compiler->AddDefine(Ident::Unique("__C128B__"), "1"); compiler->AddDefine(Ident::Unique("__C128B__"), "1");
} }
else if (!strcmp(targetMachine, "c128e"))
{
strcpy_s(basicStart, "0x1c01");
compiler->mTargetMachine = TMACH_C128E;
compiler->AddDefine(Ident::Unique("__C128E__"), "1");
}
else if (!strcmp(targetMachine, "vic20")) else if (!strcmp(targetMachine, "vic20"))
{ {
strcpy_s(basicStart, "0x1001"); strcpy_s(basicStart, "0x1001");