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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -303,6 +303,12 @@ int main2(int argc, const char** argv)
compiler->mTargetMachine = TMACH_C128B;
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"))
{
strcpy_s(basicStart, "0x1001");