Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BartmanAbyss committed Feb 9, 2023
2 parents 282dc28 + 8332e00 commit ce0d0c5
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 39 deletions.
Binary file modified bin/darwin/fs-uae/fs-uae
Binary file not shown.
Binary file modified bin/darwin/fs-uae/fs-uae.dat
Binary file not shown.
Binary file modified bin/linux/fs-uae/fs-uae
Binary file not shown.
Binary file modified bin/linux/fs-uae/fs-uae.dat
Binary file not shown.
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,20 @@
"1M",
"1.8M"
]
},
"ntsc": {
"type": "boolean",
"description": "NTSC mode",
"default": false
},
"emuargs": {
"type": "array",
"items": {
"type": "string",
"title": "argument"
},
"description": "Addtional CLI arguments for emulator",
"default": []
}
}
}
Expand Down
49 changes: 26 additions & 23 deletions src/amigaDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
chipmem?: string; // '256k', '512k', '1m', '1.5m' or '2m'
fastmem?: string; // '0', '64k', '128k', '256k', '512k', '1M', '2M', '4M', '8M'
slowmem?: string; // '0', '512k', '1M', '1.8M'
ntsc?: boolean; // NTSC mode
emuargs?: string[]; // Additional CLI arguments for emulator
}

class ExtendedVariable {
Expand Down Expand Up @@ -187,12 +189,8 @@ export class AmigaDebugSession extends LoggingDebugSession {
return out;
};

const configExt = isWin ? "uae" : "fs-uae";
const defaultPath = path.join(binPath, "default." + configExt);
const defaultPath = path.join(binPath, "default.uae");
let config = new Map<string, string>();
try {
config = parseCfg(fs.readFileSync(defaultPath, 'utf-8'));
} catch(e) { /**/ }

const exePath = path.dirname(args.program);
const exeName = path.basename(args.program) + ".exe";
Expand All @@ -211,6 +209,10 @@ export class AmigaDebugSession extends LoggingDebugSession {
if (isWin) {
// WinUAE:

try {
config = parseCfg(fs.readFileSync(defaultPath, 'utf-8'));
} catch(e) { /**/ }

// mandatory
config.set('use_gui', 'no');
config.set('win32.start_not_captured', 'yes');
Expand Down Expand Up @@ -279,6 +281,8 @@ export class AmigaDebugSession extends LoggingDebugSession {
// debugging options
config.set('debugging_features', 'gdbserver');
config.set('debugging_trigger', debugTrigger);
// video
config.set('ntsc', args.ntsc ? 'true' : 'false');

// safety
config.delete('statefile');
Expand Down Expand Up @@ -356,6 +360,13 @@ export class AmigaDebugSession extends LoggingDebugSession {
default:
config.delete('bogomem_size');
}

try {
fs.writeFileSync(defaultPath, stringifyCfg(config));
} catch(e) {
this.sendErrorResponse(response, 103, `Unable to write emulator config ${defaultPath}.`);
return;
}
} else {
// FS-UAE:
switch(machine) {
Expand All @@ -381,11 +392,11 @@ export class AmigaDebugSession extends LoggingDebugSession {
config.set('remote_debugger', "20");
config.set('remote_debugger_port', "2345");
config.set('remote_debugger_trigger', debugTrigger);
// video
config.set('ntsc_mode', args.ntsc ? '1' : '0');

if(args.kickstart !== undefined) {
config.set('kickstart_file', args.kickstart);
} else {
config.delete('kickstart_file');
}
// args.cpuboard: no FS-UAE equivalent?

Expand All @@ -406,8 +417,6 @@ export class AmigaDebugSession extends LoggingDebugSession {
case '2m':
config.set('chip_memory', '2048');
break;
default:
config.delete('chip_memory');
}
switch(args.fastmem?.toLowerCase()) {
case '0k':
Expand Down Expand Up @@ -441,8 +450,6 @@ export class AmigaDebugSession extends LoggingDebugSession {
case '8m':
config.set('fast_memory', '8192');
break;
default:
config.delete('fast_memory');
}
switch(args.slowmem?.toLowerCase()) {
case '0k':
Expand All @@ -459,24 +466,21 @@ export class AmigaDebugSession extends LoggingDebugSession {
case '1.8m':
config.set('slow_memory', '1792');
break;
default:
config.delete('slow_memory');
}
}

try {
fs.writeFileSync(defaultPath, stringifyCfg(config));
} catch(e) {
this.sendErrorResponse(response, 103, `Unable to write emulator config ${defaultPath}.`);
return;
}

// all WinUAE options now in config file
const emuPath = isWin
? path.join(binPath, "winuae-gdb.exe")
: path.join(binPath, "fs-uae", "fs-uae");

const emuArgs = isWin ? [ '-portable' ] : [ defaultPath ];
const emuArgs = [
...(isWin
// all WinUAE options now in config file
? [ '-portable' ]
// FS-UAE options as args
: [...config].map(([k, v]) => `--${k}=${v}`)),
...args.emuargs
];

// defaults - from package.json
if(args.endcli === undefined)
Expand Down Expand Up @@ -542,7 +546,6 @@ export class AmigaDebugSession extends LoggingDebugSession {
const env = {
...process.env,
LD_LIBRARY_PATH: ".", // Allow Linux fs-uae to find bundled .so files
DYLD_FALLBACK_LIBRARY_PATH: ".", // Allow Mac fs-uae to find bundled .dylib files
};
emu = childProcess.spawn(emuPath, emuArgs, { stdio: 'ignore', detached: true, env, cwd });
//emu.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
Expand Down
41 changes: 25 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ class AmigaDebugExtension {
context.subscriptions.push(
// text editors
vscode.workspace.registerTextDocumentContentProvider('disassembly', new DisassemblyContentProvider()),
vscode.workspace.onDidOpenTextDocument(({ languageId }) => {
if (languageId === 'm68k') {
const workspaceFolder = vscode.workspace.workspaceFolders[0].uri.fsPath;
const jsonPath = path.join(workspaceFolder, ".vscode", "amiga.json");
if (fs.existsSync(jsonPath)) {
return this.configureM68k();
}
}
}),

// commands
vscode.commands.registerCommand('amiga.registers.selectedNode', this.registersSelectedNode.bind(this)),
Expand Down Expand Up @@ -216,24 +225,24 @@ class AmigaDebugExtension {
if (process.platform !== "win32") {
await this.setPermissions();
}
}

if (vscode.extensions.getExtension('gigabates.m68k-lsp')) {
const config = vscode.workspace.getConfiguration();
// Ensure m68k.includePaths contains the bundled system includes dir
const sysIncDir = path.join("opt", "m68k-amiga-elf", "sys-include");
const sysIncPath = path.join(this.binPath, sysIncDir);
const currentIncludePaths: string[] = config.get('m68k.includePaths');
if (!currentIncludePaths.includes(sysIncPath)) {
await config.update("m68k.includePaths", [
// Remove any old paths to sys-include:
// The location may change between environments and extension versions
...currentIncludePaths.filter((inc) => !inc.endsWith(sysIncDir)),
// Add new sys-include path
sysIncPath,
]);
}
await config.update("m68k.vasm.provideDiagnostics", false);
private async configureM68k() {
const config = vscode.workspace.getConfiguration();
// Ensure m68k.includePaths contains the bundled system includes dir
const sysIncDir = path.join("opt", "m68k-amiga-elf", "sys-include");
const sysIncPath = path.join(this.binPath, sysIncDir);
const currentIncludePaths: string[] = config.get('m68k.includePaths');
if (!currentIncludePaths.includes(sysIncPath)) {
await config.update("m68k.includePaths", [
// Remove any old paths to sys-include:
// The location may change between environments and extension versions
...currentIncludePaths.filter((inc) => !inc.endsWith(sysIncDir)),
// Add new sys-include path
sysIncPath,
]);
}
await config.update("m68k.vasm.provideDiagnostics", false);
}

public async dispose() {
Expand Down

0 comments on commit ce0d0c5

Please sign in to comment.