vic dual ay8910 tester

This commit is contained in:
Steven Hugg 2017-02-18 17:50:51 -05:00
parent 5caf7e1b96
commit ad36052afb
5 changed files with 163 additions and 46 deletions

View File

@ -194,7 +194,7 @@ canvas.pixelated {
<!--<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][</a></li>-->
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080 B&amp;W</a></li>
<li><a class="dropdown-item" href="?platform=vicdual" id="item_platform_vicdual">VIC Dual</a></li>
<li><a class="dropdown-item" href="?platform=galaxian" id="item_platform_galaxian">Galaxian/Scramble</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Scramble</a></li>
<li><a class="dropdown-item" href="?platform=vector-z80color" id="item_platform_vector_z80color">Atari Color Vector (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=williams" id="item_platform_williams">Williams (Z80)</a></li>
</ul>

View File

@ -9,27 +9,39 @@ __sfr __at (0x1) input1;
__sfr __at (0x2) input2;
__sfr __at (0x3) input3;
__sfr __at (0x1) audreg;
__sfr __at (0x2) auddata;
__sfr __at (0x1) ay8910_reg;
__sfr __at (0x2) ay8910_data;
__sfr __at (0x40) palette;
byte __at (0xc000) cellram[32][32];
byte __at (0xc800) tileram[256][8];
byte __at (0xe000) cellram[32][32];
byte __at (0xe800) tileram[256][8];
#define FIRE1 0x10
#define LEFT1 0x20
#define RIGHT1 0x40
#define LEFT1 !(input1 & 0x10)
#define RIGHT1 !(input1 & 0x20)
#define UP1 !(input1 & 0x40)
#define DOWN1 !(input1 & 0x80)
#define FIRE1 !(input2 & 0x20)
void main();
// start routine @ 0x0
void start() {
__asm
LD SP,#0xc800
; set up stack pointer, interrupt flag
LD SP,#0xE800
DI
; copy initialized data
LD BC, #l__INITIALIZER
LD A, B
LD DE, #s__INITIALIZED
LD HL, #s__INITIALIZER
LDIR
__endasm;
main();
}
////////
#define LOCHAR 0x0
#define HICHAR 0xff
@ -49,23 +61,117 @@ void putstring(byte attr, byte x, byte y, const char* string) {
}
}
const char BOX_CHARS[8] = { 218, 191, 192, 217, 196, 196, 179, 179 };
void draw_box(byte x, byte y, byte x2, byte y2, const char* chars) {
byte x1 = x;
putchar(chars[2], x, y);
putchar(chars[3], x2, y);
putchar(chars[0], x, y2);
putchar(chars[1], x2, y2);
while (++x < x2) {
putchar(chars[5], x, y);
putchar(chars[4], x, y2);
}
while (++y < y2) {
putchar(chars[6], x1, y);
putchar(chars[7], x2, y);
}
}
static byte palbank = 0;
void main() {
short i;
memcpy(tileram, font8x8, sizeof(font8x8));
for (i=0; i<32; i++) {
putchar(CHAR('*'),0,i);
putchar(CHAR('^'),i,0);
putchar(0x4,27,i);
putchar(0xf8,i,31);
}
putstring(0x0, 2, 25, "HELLO THERE");
for (i=0; i<0x1000; i++) {
//audreg = auddata = i;
// cellram[i&0x3ff] += i;
//tileram[i&0x7ff] += i;
}
//palette = palbank++;
main();
inline void set8910(byte reg, byte data) {
ay8910_reg = reg;
ay8910_data = data;
}
const char* const AY8910REGNAMES[14] = {
"PITCH A LO", "PITCH A HI",
"PITCH B LO", "PITCH B HI",
"PITCH C LO", "PITCH C HI",
"NOISE PERI",
"DISABLE",
"ENV-VOL A",
"ENV-VOL B",
"ENV-VOL C",
"ENV PERI LO",
"ENV PERI HI",
"ENV SHAPE"
};
const char* const AY8910MASKS[14] = {
"11111111", " 1111",
"11111111", " 1111",
"11111111", " 1111",
" 11111",
" cbaCBA",
" E11111", " E11111", " E11111",
"11111111", " 1111",
" CALH"
};
char is_control_active() {
return (LEFT1 || RIGHT1 || UP1 || DOWN1 || FIRE1);
}
void ay8910test() {
byte i,j,y;
byte curreg=0,curbit=0;
byte ay8910regs[16];
memset(ay8910regs, 0, sizeof(ay8910regs));
ay8910regs[7] = 0x3f;
while (1) {
for (i=0; i<=13; i++) {
const char* mask = AY8910MASKS[i];
y = 29-i*2;
if (i<10) {
putchar(CHAR(i+'0'), 3, y);
} else {
putchar(CHAR('1'), 2, y);
putchar(CHAR(i+'0'-10), 3, y);
}
for (j=0; j<8; j++) {
char ch = mask[j];
byte bit = (ay8910regs[i] & (128>>j)) != 0;
if (!bit) {
if (ch == '1')
ch = '0';
else if (ch != ' ')
ch = '.';
}
putchar(ch, 6+j, y);
}
putstring(0, 16, y, AY8910REGNAMES[i]);
set8910(i, ay8910regs[i]);
}
y = 29-curreg*2;
j = 6+curbit;
putchar(175, 1, y);
putchar(194, j, y-1);
putchar(193, j, y+1);
while (is_control_active()) ;
while (!is_control_active()) ;
putchar(CHAR(' '), 1, y);
putchar(CHAR(' '), j, y-1);
putchar(CHAR(' '), j, y+1);
if (LEFT1) curbit--;
if (RIGHT1) curbit++;
curbit &= 7;
if (UP1) curreg--;
if (DOWN1) curreg++;
curreg &= 15;
if (FIRE1) {
ay8910regs[curreg] ^= (128>>curbit);
while (FIRE1) ;
}
}
}
void main() {
palette = 2;
memcpy(tileram, font8x8, sizeof(font8x8));
memset(cellram, CHAR(' '), sizeof(cellram));
draw_box(0,0,27,31,BOX_CHARS);
ay8910test();
}

View File

@ -1,7 +1,7 @@
"use strict";
var VICDUAL_PRESETS = [
{id:'vic1.c', name:'Graphics Test'},
{id:'soundtest.c', name:'Sound Tester'},
];
var VicDualPlatform = function(mainElement) {
@ -39,10 +39,10 @@ var VicDualPlatform = function(mainElement) {
7,3,1,3,6,3,2,6,
7,0,0,0,0,0,0,0,
0,1,2,3,4,5,6,7,
4,5,6,7,0,0,0,0,
0,0,0,0,4,5,6,7,
1,2,4,7,0,0,0,0,
0,0,0,0,1,2,4,7,
0,0,0,0,0,0,0,0,
7,7,7,7,3,3,3,3,
0,0,0,0,0,0,0,0,
7,7,7,7,7,7,7,7,
];
// videoram 0xc000-0xc3ff
@ -69,9 +69,12 @@ var VicDualPlatform = function(mainElement) {
}
var CARNIVAL_KEYCODE_MAP = makeKeycodeMap([
[Keys.VK_SPACE, 2, -0x20], // P1
[Keys.VK_SPACE, 2, -0x20],
[Keys.VK_SHIFT, 2, -0x40],
[Keys.VK_LEFT, 1, -0x10],
[Keys.VK_RIGHT, 1, -0x20],
[Keys.VK_UP, 1, -0x40],
[Keys.VK_DOWN, 1, -0x80],
[Keys.VK_1, 2, -0x10],
[Keys.VK_2, 3, -0x20],
[Keys.VK_5, 3, 0x8],
@ -98,7 +101,7 @@ var VicDualPlatform = function(mainElement) {
return inputs[addr&3];
},
write: function(addr, val) {
if (addr & 0x1) { psg.selectRegister(val); }; // audio 1
if (addr & 0x1) { psg.selectRegister(val & 0xf); }; // audio 1
if (addr & 0x2) { psg.setData(val); }; // audio 2
if (addr & 0x8) { }; // coin status
if (addr & 0x40) { palbank = val & 3; }; // palette

View File

@ -67,8 +67,8 @@ var FileStore = function(storage, prefix) {
return files;
}
this.deleteFile = function(name) {
storage.removeItem(name);
storage.removeItem('local/' + name);
storage.removeItem(prefix + name);
storage.removeItem(prefix + 'local/' + name);
}
}
@ -531,17 +531,21 @@ function getCurrentLine() {
return editor.getCursor().line+1;
}
function getDisasmViewPC() {
var line = disasmview.getCursor().line;
if (line) {
var toks = disasmview.getLine(line).split(/\s+/);
if (toks) {
return parseInt(toks[0], 16);
}
}
}
function getCurrentPC() {
var line = getCurrentLine();
var pc = sourcefile.line2offset[line];
if (!(pc >= 0)) {
line = disasmview.getCursor().line;
if (line) {
var toks = disasmview.getLine(line).split(/\s+/);
if (toks) {
pc = parseInt(toks[0], 16);
}
}
return getDisasmViewPC();
}
return pc;
}
@ -774,10 +778,11 @@ function updateDisassembly() {
var pc = state.c.PC;
if (assemblyfile && assemblyfile.text) {
disasmview.setValue(assemblyfile.text);
if (platform.getDebugCallback()) {
var lineno = assemblyfile.findLineForOffset(pc);
var findPC = platform.getDebugCallback() ? pc : getCurrentPC();
if (findPC) {
var lineno = assemblyfile.findLineForOffset(findPC);
if (lineno) {
disasmview.setCursor(lineno-1, 0);
if (platform.getDebugCallback()) disasmview.setCursor(lineno-1, 0);
jumpToLine(disasmview, lineno-1);
}
}

View File

@ -10,7 +10,7 @@ var PLATFORM_PARAMS = {
'vicdual': {
code_start: 0x0,
code_size: 0x4000,
data_start: 0xc400,
data_start: 0xe400,
data_size: 0x400,
},
'galaxian': {
@ -654,6 +654,7 @@ function compileSDCC(code, platform) {
'--c1mode', // '--debug',
//'-S', 'main.c',
//'--asm=z80asm',
'--less-pedantic',
'--fomit-frame-pointer', '--opt-code-speed',
'-o', 'main.asm']);
/*
@ -669,6 +670,8 @@ function compileSDCC(code, platform) {
}
try {
var asmout = FS.readFile("main.asm", {encoding:'utf8'});
asmout = " .area _HOME\n .area _CODE\n .area _INITIALIZER\n .area _DATA\n .area _INITIALIZED\n .area _BSEG\n .area _BSS\n .area _HEAP\n" + asmout;
//asmout = asmout.replace(".area _INITIALIZER",".area _CODE");
} catch (e) {
msvc_errors.push({line:1, msg:e+""});
return {errors:msvc_errors};