From 9a409ca34794dd80ace9f1a8653f1773b4b0c8c2 Mon Sep 17 00:00:00 2001 From: "ctalkobt@ctalkobt.net" Date: Mon, 21 Apr 2025 11:12:02 -0400 Subject: [PATCH] Initial patch to add -tm=mega65 support --- oscar64/Compiler.cpp | 20 ++++++++++++++++++++ oscar64/CompilerTypes.h | 3 ++- oscar64/oscar64.cpp | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/oscar64/Compiler.cpp b/oscar64/Compiler.cpp index 9820b48..175ee2b 100644 --- a/oscar64/Compiler.cpp +++ b/oscar64/Compiler.cpp @@ -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, 0xff00); + 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, 0xff00); + break; case TMACH_C64: if (mCompilerOptions & (COPT_TARGET_CRT8 | COPT_TARGET_CRT16)) diff --git a/oscar64/CompilerTypes.h b/oscar64/CompilerTypes.h index 8ea2d42..75dc289 100644 --- a/oscar64/CompilerTypes.h +++ b/oscar64/CompilerTypes.h @@ -78,7 +78,8 @@ enum TargetMachine TMACH_NES_MMC1, TMACH_NES_MMC3, TMACH_ATARI, - TMACH_X16 + TMACH_X16, + TMACH_MEGA65 }; diff --git a/oscar64/oscar64.cpp b/oscar64/oscar64.cpp index 2572998..e04cb60 100644 --- a/oscar64/oscar64.cpp +++ b/oscar64/oscar64.cpp @@ -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");