2019-08-19 17:42:32 +00:00
|
|
|
|
2020-07-14 02:14:47 +00:00
|
|
|
import { C64_WASMMachine } from "../machine/c64";
|
2023-11-16 19:40:23 +00:00
|
|
|
import { Platform, Base6502MachinePlatform, getToolForFilename_6502, getOpcodeMetadata_6502, Preset } from "../common/baseplatform";
|
2019-10-26 01:55:50 +00:00
|
|
|
import { PLATFORMS } from "../common/emu";
|
2021-08-06 00:16:13 +00:00
|
|
|
import { BaseMAME6502Platform } from "../common/mameplatform";
|
2019-08-19 17:42:32 +00:00
|
|
|
|
2023-11-16 19:40:23 +00:00
|
|
|
const C64_PRESETS : Preset[] = [
|
|
|
|
{id:'helloc.c', name:'Hello World', category:'C'},
|
2023-11-14 16:52:33 +00:00
|
|
|
{id:'screen_ram.c', name:'Screen RAM'},
|
2022-08-11 20:27:20 +00:00
|
|
|
{id:'joymove.c', name:'Sprite Movement'},
|
|
|
|
{id:'sprite_collision.c', name:'Sprite Collision'},
|
|
|
|
{id:'scroll1.c', name:'Scrolling (Single Buffer)'},
|
2023-11-09 18:54:58 +00:00
|
|
|
{id:'test_display_list.c', name:'Display List / Raster IRQ'},
|
|
|
|
{id:'scrolling_text.c', name:'Big Scrolling Text'},
|
|
|
|
{id:'side_scroller.c', name:'Side-Scrolling Game'},
|
2022-08-11 20:27:20 +00:00
|
|
|
{id:'scroll2.c', name:'Scrolling (Double Buffer)'},
|
|
|
|
{id:'scroll3.c', name:'Scrolling (Multidirectional)'},
|
|
|
|
{id:'scroll4.c', name:'Scrolling (Color RAM Buffering)'},
|
|
|
|
{id:'scroll5.c', name:'Scrolling (Camera Following)'},
|
2023-11-09 18:54:58 +00:00
|
|
|
{id:'scrollingmap1.c', name:'Scrolling Tile Map'},
|
2022-08-11 20:27:20 +00:00
|
|
|
{id:'fullscrollgame.c', name:'Full-Scrolling Game'},
|
2022-08-23 17:48:39 +00:00
|
|
|
{id:'test_multiplex.c', name:'Sprite Retriggering'},
|
|
|
|
{id:'test_multispritelib.c', name:'Sprite Multiplexing Library'},
|
|
|
|
{id:'mcbitmap.c', name:'Multicolor Bitmap Mode'},
|
2023-11-02 22:03:40 +00:00
|
|
|
{id:'testlz4.c', name:'LZ4 Bitmap Compression'},
|
2022-08-11 20:27:20 +00:00
|
|
|
//{id:'mandel.c', name:'Mandelbrot Fractal'},
|
|
|
|
{id:'musicplayer.c', name:'Music Player'},
|
2022-08-23 17:48:39 +00:00
|
|
|
//{id:'sidtune.dasm', name:'Tiny SID Tune (ASM)'},
|
2022-08-11 20:27:20 +00:00
|
|
|
{id:'siddemo.c', name:'SID Player Demo'},
|
|
|
|
{id:'climber.c', name:'Climber Game'},
|
2023-11-09 18:54:58 +00:00
|
|
|
{id:'test_border_sprites.c', name:'Sprites in the Borders'},
|
|
|
|
{id:'sprite_stretch.c', name:'Sprite Stretching'},
|
|
|
|
{id:'plasma.c', name:'Plasma Demo'},
|
2023-11-14 16:52:33 +00:00
|
|
|
{id:'siegegame.c', name:'Siege Game'},
|
|
|
|
{id:'23matches.c', name:'23 Matches'},
|
|
|
|
{id:'tgidemo.c', name:'TGI Graphics Demo'},
|
|
|
|
{id:'upandaway.c', name:'Up, Up and Away'},
|
2023-11-16 19:40:23 +00:00
|
|
|
{id:'hello.dasm', name:'Hello World (DASM)', category:'Assembly Language'},
|
|
|
|
{id:'hello.dasm', name:'Hello World (ACME)'},
|
2023-11-02 13:17:15 +00:00
|
|
|
{id:'hello.wiz', name:'Hello Wiz (Wiz)'},
|
2019-08-19 17:42:32 +00:00
|
|
|
];
|
|
|
|
|
2019-12-18 01:30:42 +00:00
|
|
|
const C64_MEMORY_MAP = { main:[
|
|
|
|
{name:'6510 Registers',start:0x0, size:0x2,type:'io'},
|
2022-07-19 19:53:26 +00:00
|
|
|
{name:'BIOS Reserved', start:0x200, size:0xa7},
|
|
|
|
{name:'Default Screen RAM', start:0x400, size:1024,type:'ram'},
|
2020-02-04 17:58:46 +00:00
|
|
|
//{name:'RAM', start:0x2, size:0x7ffe,type:'ram'},
|
2019-12-18 01:30:42 +00:00
|
|
|
{name:'Cartridge ROM',start:0x8000,size:0x2000,type:'rom'},
|
|
|
|
{name:'BASIC ROM', start:0xa000,size:0x2000,type:'rom'},
|
2022-07-19 19:53:26 +00:00
|
|
|
{name:'Upper RAM', start:0xc000,size:0x1000,type:'ram'},
|
|
|
|
{name:'Character ROM',start:0xd000,size:0x1000,type:'rom'},
|
2019-12-18 01:30:42 +00:00
|
|
|
{name:'VIC-II I/O', start:0xd000,size:0x0400,type:'io'},
|
2020-05-25 18:04:04 +00:00
|
|
|
{name:'SID', start:0xd400,size:0x0400,type:'io'},
|
2019-12-18 01:30:42 +00:00
|
|
|
{name:'Color RAM', start:0xd800,size:0x0400,type:'io'},
|
|
|
|
{name:'CIA 1', start:0xdc00,size:0x0100,type:'io'},
|
|
|
|
{name:'CIA 2', start:0xdd00,size:0x0100,type:'io'},
|
2020-05-25 18:04:04 +00:00
|
|
|
{name:'I/O 1', start:0xde00,size:0x0100,type:'io'},
|
|
|
|
{name:'I/O 2', start:0xdf00,size:0x0100,type:'io'},
|
2019-12-18 01:30:42 +00:00
|
|
|
{name:'KERNAL ROM', start:0xe000,size:0x2000,type:'rom'},
|
|
|
|
] }
|
|
|
|
|
2020-05-25 18:04:04 +00:00
|
|
|
// WASM C64 platform
|
2020-01-06 18:16:00 +00:00
|
|
|
class C64WASMPlatform extends Base6502MachinePlatform<C64_WASMMachine> implements Platform {
|
2019-12-18 01:30:42 +00:00
|
|
|
|
2020-01-06 18:16:00 +00:00
|
|
|
newMachine() { return new C64_WASMMachine('c64'); }
|
2019-12-18 01:30:42 +00:00
|
|
|
|
|
|
|
getPresets() { return C64_PRESETS; }
|
|
|
|
getDefaultExtension() { return ".c"; };
|
|
|
|
readAddress(a) { return this.machine.readConst(a); }
|
|
|
|
getMemoryMap() { return C64_MEMORY_MAP; }
|
2022-09-15 17:05:54 +00:00
|
|
|
showHelp() { return "https://8bitworkshop.com/docs/platforms/c64/" }
|
2020-07-11 14:51:26 +00:00
|
|
|
getROMExtension(rom:Uint8Array) {
|
|
|
|
/*
|
|
|
|
if (rom && rom[0] == 0x00 && rom[1] == 0x80 && rom[2+4] == 0xc3 && rom[2+5] == 0xc2) return ".crt";
|
|
|
|
*/
|
|
|
|
if (rom && rom[0] == 0x01 && rom[1] == 0x08) return ".prg";
|
|
|
|
else return ".bin";
|
|
|
|
}
|
2019-12-18 01:30:42 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 02:03:54 +00:00
|
|
|
// C64 MAME platform
|
2021-07-31 14:52:25 +00:00
|
|
|
abstract class C64MAMEPlatform extends BaseMAME6502Platform {
|
2021-07-15 02:03:54 +00:00
|
|
|
getPresets() { return C64_PRESETS; }
|
|
|
|
getToolForFilename = getToolForFilename_6502;
|
|
|
|
getOpcodeMetadata = getOpcodeMetadata_6502;
|
|
|
|
getDefaultExtension() { return ".c"; }
|
|
|
|
loadROM(title, data) {
|
|
|
|
if (!this.started) {
|
|
|
|
this.startModule(this.mainElement, {
|
2021-07-31 14:52:25 +00:00
|
|
|
jsfile:'mame8bitpc.js',
|
2021-07-15 02:03:54 +00:00
|
|
|
biosfile:'c64.zip',
|
|
|
|
cfgfile:'c64.cfg',
|
|
|
|
driver:'c64',
|
2021-07-31 14:52:25 +00:00
|
|
|
width:418,
|
|
|
|
height:235,
|
|
|
|
romfn:'/emulator/image.crt',
|
2021-07-15 02:03:54 +00:00
|
|
|
romdata:new Uint8Array(data),
|
2021-07-31 14:52:25 +00:00
|
|
|
romsize:0x10000,
|
|
|
|
extraargs: ['-autoboot_delay','5','-autoboot_command','load "$",8,1\n'],
|
2021-07-15 02:03:54 +00:00
|
|
|
preInit:function(_self) {
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.loadROMFile(data);
|
2021-07-31 14:52:25 +00:00
|
|
|
this.loadRegion(":quickload", data);
|
|
|
|
var result = this.luacall(`image:load("/emulator/image.prg")`)
|
|
|
|
console.log('load rom', result);
|
|
|
|
//this.loadRegion(":exp:standard", data);
|
2021-07-15 02:03:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
getMemoryMap() { return C64_MEMORY_MAP; }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-21 18:10:08 +00:00
|
|
|
PLATFORMS['c64'] = C64WASMPlatform;
|
2019-12-18 01:30:42 +00:00
|
|
|
PLATFORMS['c64.wasm'] = C64WASMPlatform;
|
2021-07-15 02:03:54 +00:00
|
|
|
PLATFORMS['c64.mame'] = C64MAMEPlatform;
|