From 51021b5a67ab658ae9cec8695c9862479e0404d8 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 3 Sep 2018 09:37:17 -0400 Subject: [PATCH] started on astrocade commercial version --- src/platform/astrocade.ts | 71 ++++++++++++++++++++++++++++----------- src/worker/workermain.js | 17 +++++++--- 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/platform/astrocade.ts b/src/platform/astrocade.ts index b76c1956..b9d4f6e3 100644 --- a/src/platform/astrocade.ts +++ b/src/platform/astrocade.ts @@ -51,14 +51,15 @@ const ASTROCADE_KEYCODE_MAP = makeKeycodeMap([ [Keys.VK_E, 0x17, 0x20], ]); -const _BallyAstrocadePlatform = function(mainElement) { +const _BallyAstrocadePlatform = function(mainElement, arcade) { var cpu, ram, membus, iobus, rom, bios; var video, timer, pixels; var audio, psg; //var watchdog_counter; - const swidth = 160; - const sheight = 102; + const swidth = arcade ? 320 : 160; + const sheight = arcade ? 204 : 102; + const swbytes = Math.floor(swidth / 4); const cpuFrequency = 1789000; const cpuCyclesPerLine = cpuFrequency/(60*sheight); const INITIAL_WATCHDOG = 256; @@ -87,7 +88,7 @@ const _BallyAstrocadePlatform = function(mainElement) { ram.mem[a] = v; var ofs = a*4+3; // 4 pixels per byte for (var i=0; i<4; i++) { - var lr = ((a % 0x28) >= (horcb & 0x3f)) ? 0 : 4; + var lr = ((a % swbytes) >= (horcb & 0x3f)) ? 0 : 4; pixels[ofs--] = palette[lr + (v & 3)]; v >>= 2; } @@ -170,30 +171,49 @@ const _BallyAstrocadePlatform = function(mainElement) { } start = function() { - ram = new RAM(0x2000); + ram = new RAM(arcade ? 0x5000 : 0x1000); var lzgrom = window['ASTROCADE_LZGROM']; if (lzgrom) bios = new lzgmini().decode(stringToByteArray(atob(lzgrom))); else bios = padBytes([0xf3, 0x31, 0x00, 0x50, 0x21, 0x05, 0x20, 0x7e, 0x23, 0x66, 0x6f, 0xe9], 0x2000); // SP=$5000, jump to ($2005) - membus = { - read: newAddressDecoder([ - [0x0000, 0x1fff, 0x1fff, function(a) { return bios ? bios[a] : 0; }], - [0x2000, 0x3fff, 0x1fff, function(a) { return rom ? rom[a] : 0; }], - [0x4000, 0x4fff, 0xfff, function(a) { return ram.mem[a]; }], - ]), - write: newAddressDecoder([ - [0x4000, 0x4fff, 0xfff, ramwrite], - [0x0000, 0x3fff, 0x3fff, magicwrite], - ]), - isContended: function() { return false; }, - }; + if (!arcade) { + // game console + membus = { + read: newAddressDecoder([ + [0x0000, 0x1fff, 0x1fff, function(a) { return bios[a]; }], + [0x2000, 0x3fff, 0x1fff, function(a) { return rom ? rom[a] : 0; }], + [0x4000, 0x4fff, 0xfff, function(a) { return ram.mem[a]; }], + ]), + write: newAddressDecoder([ + [0x4000, 0x4fff, 0xfff, ramwrite], + [0x0000, 0x3fff, 0x3fff, magicwrite], + ]), + isContended: function() { return false; }, + }; + } else { + // arcade game + membus = { + read: newAddressDecoder([ + [0x4000, 0x7fff, 0x3fff, function(a) { return ram.mem[a]; }], // screen RAM + [0xd000, 0xdfff, 0xfff, function(a) { return ram.mem[a+0x4000]; }], // static RAM + [0x0000, 0xafff, 0xffff, function(a) { return rom ? rom[a] : 0; }], // ROM (0-3fff,8000-afff) + ]), + write: newAddressDecoder([ + [0x4000, 0x7fff, 0x3fff, ramwrite], + [0xd000, 0xdfff, 0xfff, function(a,v) { ramwrite(a+0x4000, v); } ], // static RAM + [0x0000, 0x3fff, 0x3fff, magicwrite], + ]), + isContended: function() { return false; }, + }; + } iobus = { read: function(addr) { addr &= 0x1f; var rtn = inputs[addr]; if (addr == 8) inputs[addr] = 0; + // $10 = watchdog return rtn; }, write: function(addr, val) { @@ -216,7 +236,7 @@ const _BallyAstrocadePlatform = function(mainElement) { refreshall(); break; case 0xa: // VERBL (vertical blank) - verbl = val >> 1; + verbl = arcade ? val : val >> 1; refreshall(); break; case 0xb: // OTIR (set palette) @@ -233,7 +253,7 @@ const _BallyAstrocadePlatform = function(mainElement) { inmod = val; break; case 0xf: // INLIN (interrupt line) - inlin = val >> 1; + inlin = arcade ? val : val >> 1; break; case 0x10: case 0x11: @@ -296,7 +316,7 @@ const _BallyAstrocadePlatform = function(mainElement) { } loadROM(title, data) { - rom = padBytes(data, 0x2000); + rom = padBytes(data, arcade ? 0xb000 : 0x2000); this.reset(); } @@ -396,9 +416,20 @@ class AstrocadeAudio extends AY38910_Audio { } } +const _BallyArcadePlatform = function(mainElement) { + this.__proto__ = new (_BallyAstrocadePlatform as any)(mainElement, true); + // TODO: inputs[0x13] = 0xfe; // dip switch on arcade + // TODO: arcade controls, bit blit + var _in = this.saveControlsState(); + _in.in[0x10] = 0xff; // switches + _in.in[0x13] = 0xfe; // dip switches + this.loadControlsState(_in); +} + ///// PLATFORMS['astrocade'] = _BallyAstrocadePlatform; +PLATFORMS['astrocade-arcade'] = _BallyArcadePlatform; //http://glankonian.com/~lance/astrocade_palette.html var ASTROCADE_PALETTE = [0x000000,0x242424,0x484848,0x6D6D6D,0x919191,0xB6B6B6,0xDADADA,0xFFFFFF,0x2500BB,0x4900E0,0x6E11FF,0x9235FF,0xB75AFF,0xDB7EFF,0xFFA3FF,0xFFC7FF,0x4900B0,0x6D00D5,0x9201F9,0xB625FF,0xDA4AFF,0xFF6EFF,0xFF92FF,0xFFB7FF,0x6A009F,0x8E00C3,0xB300E7,0xD718FF,0xFB3CFF,0xFF61FF,0xFF85FF,0xFFA9FF,0x870087,0xAB00AB,0xD000D0,0xF40EF4,0xFF32FF,0xFF56FF,0xFF7BFF,0xFF9FFF,0x9F006A,0xC3008E,0xE700B3,0xFF07D7,0xFF2CFB,0xFF50FF,0xFF74FF,0xFF99FF,0xB00049,0xD5006D,0xF90092,0xFF05B6,0xFF29DA,0xFF4DFF,0xFF72FF,0xFF96FF,0xBB0025,0xE00049,0xFF006E,0xFF0692,0xFF2AB7,0xFF4FDB,0xFF73FF,0xFF98FF,0xBF0000,0xE30024,0xFF0048,0xFF0B6D,0xFF3091,0xFF54B6,0xFF79DA,0xFF9DFF,0xBB0000,0xE00000,0xFF0023,0xFF1447,0xFF396C,0xFF5D90,0xFF82B5,0xFFA6D9,0xB00000,0xD50000,0xF90000,0xFF2124,0xFF4548,0xFF6A6C,0xFF8E91,0xFFB3B5,0x9F0000,0xC30000,0xE70C00,0xFF3003,0xFF5527,0xFF794B,0xFF9E70,0xFFC294,0x870000,0xAB0000,0xD01E00,0xF44200,0xFF670A,0xFF8B2E,0xFFAF53,0xFFD477,0x6A0000,0x8E0D00,0xB33100,0xD75600,0xFB7A00,0xFF9E17,0xFFC33B,0xFFE75F,0x490000,0x6D2100,0x924500,0xB66A00,0xDA8E00,0xFFB305,0xFFD729,0xFFFC4E,0x251100,0x493500,0x6E5A00,0x927E00,0xB7A300,0xDBC700,0xFFEB1E,0xFFFF43,0x002500,0x244900,0x486D00,0x6D9200,0x91B600,0xB6DB00,0xDAFF1B,0xFFFF3F,0x003700,0x005B00,0x238000,0x47A400,0x6CC900,0x90ED00,0xB5FF1E,0xD9FF43,0x004700,0x006C00,0x009000,0x24B400,0x48D900,0x6CFD05,0x91FF29,0xB5FF4E,0x005500,0x007900,0x009D00,0x03C200,0x27E600,0x4BFF17,0x70FF3B,0x94FF5F,0x005F00,0x008300,0x00A800,0x00CC00,0x0AF00A,0x2EFF2E,0x53FF53,0x77FF77,0x006500,0x008A00,0x00AE00,0x00D203,0x00F727,0x17FF4B,0x3BFF70,0x5FFF94,0x006800,0x008C00,0x00B100,0x00D524,0x00F948,0x05FF6C,0x29FF91,0x4EFFB5,0x006600,0x008B00,0x00AF23,0x00D447,0x00F86C,0x00FF90,0x1EFFB5,0x43FFD9,0x006100,0x008524,0x00AA48,0x00CE6D,0x00F391,0x00FFB6,0x1BFFDA,0x3FFFFE,0x005825,0x007C49,0x00A16E,0x00C592,0x00EAB7,0x00FFDB,0x1EFFFF,0x43FFFF,0x004B49,0x00706D,0x009492,0x00B9B6,0x00DDDA,0x05FFFF,0x29FFFF,0x4EFFFF,0x003C6A,0x00608E,0x0085B3,0x00A9D7,0x00CEFB,0x17F2FF,0x3BFFFF,0x5FFFFF,0x002A87,0x004FAB,0x0073D0,0x0097F4,0x0ABCFF,0x2EE0FF,0x53FFFF,0x77FFFF,0x00179F,0x003BC3,0x0060E7,0x0384FF,0x27A8FF,0x4BCDFF,0x70F1FF,0x94FFFF,0x0002B0,0x0027D5,0x004BF9,0x2470FF,0x4894FF,0x6CB9FF,0x91DDFF,0xB5FFFF,0x0000BB,0x0013E0,0x2337FF,0x475BFF,0x6C80FF,0x90A4FF,0xB5C9FF,0xD9EDFF]; diff --git a/src/worker/workermain.js b/src/worker/workermain.js index ff746d73..4993645c 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -153,10 +153,17 @@ var PLATFORM_PARAMS = { }, 'astrocade': { code_start: 0x2000, - rom_size: 0x2000, + rom_size: 0x2000, data_start: 0x4e10, - data_size: 0x1f0, - stack_end: 0x5000, + data_size: 0x1f0, + stack_end: 0x5000, + }, + 'astrocade-arcade': { + code_start: 0x0000, + rom_size: 0x4000, + data_start: 0x7de0, + data_size: 0x220, + stack_end: 0x8000, }, }; @@ -1390,7 +1397,7 @@ error1.asm(11): warning: 'foobar' treated as label (instruction typo?) var FS = ZMAC['FS']; populateFiles(step, FS); // TODO: don't know why CIM (hexary) doesn't work - execMain(step, ZMAC, ['-z', '--oo', 'lst,hex', step.path]); + execMain(step, ZMAC, ['-z', '-c', '--oo', 'lst,hex', step.path]); if (errors.length) { return {errors:errors}; } @@ -1401,7 +1408,7 @@ error1.asm(11): warning: 'foobar' treated as label (instruction typo?) if (!anyTargetChanged(step, [hexpath, lstpath])) return; // 230: 1739+7+x 017A 1600 L017A: LD D,00h - var lines = parseListing(lstout, /\s*(\d+):\s*([0-9+]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 3, 4); + var lines = parseListing(lstout, /\s*(\d+):\s*([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3); var listings = {}; listings[lstpath] = {lines:lines}; // parse symbol table