Merge pull request #217 from CTalkobt/main

Initial patch to add -tm=mega65 support
This commit is contained in:
drmortalwombat 2025-04-21 18:48:38 +02:00 committed by GitHub
commit 01d187cf83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 1 deletions

View File

@ -523,6 +523,12 @@ bool Compiler::GenerateCode(void)
{
switch (mTargetMachine)
{
case TMACH_MEGA65:
if (mCompilerOptions & COPT_NATIVE)
regionStartup = mLinker->AddRegion(identStartup, 0x2001, 0x2080);
else
regionStartup = mLinker->AddRegion(identStartup, 0x2001, 0x2100);
break;
case TMACH_C64:
case TMACH_X16:
if (mCompilerOptions & COPT_NATIVE)
@ -625,6 +631,9 @@ bool Compiler::GenerateCode(void)
{
switch (mTargetMachine)
{
case TMACH_MEGA65:
regionBytecode = mLinker->AddRegion(identBytecode, 0x2100, 0x2200);
break;
case TMACH_C64:
case TMACH_X16:
regionBytecode = mLinker->AddRegion(identBytecode, 0x0900, 0x0a00);
@ -686,6 +695,9 @@ bool Compiler::GenerateCode(void)
{
switch (mTargetMachine)
{
case TMACH_MEGA65:
regionMain = mLinker->AddRegion(identMain, 0x2300, 0xe000);
break;
case TMACH_C64:
regionMain = mLinker->AddRegion(identMain, 0x0a00, 0xa000);
break;
@ -737,6 +749,14 @@ bool Compiler::GenerateCode(void)
{
switch (mTargetMachine)
{
case TMACH_MEGA65:
// TODO: Disable M65 cartridges for now.
//
// if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16))
// regionMain = mLinker->AddRegion(identMain, 0x2666, 0xff00);
// else
regionMain = mLinker->AddRegion(identMain, 0x2080, 0xe000);
break;
case TMACH_C64:
if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16))

View File

@ -78,7 +78,8 @@ enum TargetMachine
TMACH_NES_MMC1,
TMACH_NES_MMC3,
TMACH_ATARI,
TMACH_X16
TMACH_X16,
TMACH_MEGA65
};

View File

@ -446,6 +446,12 @@ int main2(int argc, const char** argv)
compiler->mTargetMachine = TMACH_PLUS4;
compiler->AddDefine(Ident::Unique("__PLUS4__"), "1");
}
else if (!strcmp(targetMachine, "mega65"))
{
strcpy_s(basicStart, "0x2001");
compiler->mTargetMachine = TMACH_MEGA65;
compiler->AddDefine(Ident::Unique("__MEGA65__"), "1");
}
else if (!strcmp(targetMachine, "x16"))
{
strcpy_s(basicStart, "0x0801");