Remove channel objects
This commit is contained in:
parent
54fbc5c66a
commit
4244e295eb
31
src/dma.js
31
src/dma.js
|
@ -9,12 +9,8 @@ function DMA(dev)
|
|||
/** @const */
|
||||
this.memory = dev.memory;
|
||||
|
||||
this.channels = [
|
||||
{ address: 0, count: 0 },
|
||||
{ address: 0, count: 0 },
|
||||
{ address: 0, count: 0 },
|
||||
{ address: 0, count: 0 }
|
||||
];
|
||||
this.channel_addr = new Int32Array(4);
|
||||
this.channel_count = new Int32Array(4);
|
||||
|
||||
this.lsb_msb_flipflop = 0;
|
||||
|
||||
|
@ -42,11 +38,11 @@ DMA.prototype.port_write = function(port, data_byte)
|
|||
|
||||
if(port & 1)
|
||||
{
|
||||
this.channels[channel].count = this.flipflop_get(this.channels[channel].count, data_byte);
|
||||
this.channel_count[channel] = this.flipflop_get(this.channel_count[channel], data_byte);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channels[channel].address = this.flipflop_get(this.channels[channel].address, data_byte);
|
||||
this.channel_addr[channel] = this.flipflop_get(this.channel_addr[channel], data_byte);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -59,12 +55,12 @@ DMA.prototype.port_read = function(port)
|
|||
|
||||
if(port & 1)
|
||||
{
|
||||
return this.channels[channel].count;
|
||||
return this.channel_count[channel];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bug?
|
||||
return this.channels[channel].address;
|
||||
return this.channel_addr[channel];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -90,14 +86,14 @@ DMA.prototype.portC_write = function(data_byte)
|
|||
|
||||
DMA.prototype.port81_write = function(data_byte)
|
||||
{
|
||||
this.channels[2].address = this.channels[2].address & 0xFFFF | data_byte << 16;
|
||||
this.channel_addr[2] = this.channel_addr[2] & 0xFFFF | data_byte << 16;
|
||||
}
|
||||
|
||||
// read data, write to memory
|
||||
DMA.prototype.do_read = function(buffer, start, len, channel, fn)
|
||||
{
|
||||
var read_count = this.channels[channel].count + 1,
|
||||
addr = this.channels[channel].address;
|
||||
var read_count = this.channel_count[channel] + 1,
|
||||
addr = this.channel_addr[channel];
|
||||
|
||||
dbg_log("DMA write channel " + channel, LOG_DMA);
|
||||
dbg_log("to " + h(addr) + " len " + h(read_count), LOG_DMA);
|
||||
|
@ -115,7 +111,7 @@ DMA.prototype.do_read = function(buffer, start, len, channel, fn)
|
|||
else
|
||||
{
|
||||
var memory = this.memory;
|
||||
this.channels[channel].address += read_count;
|
||||
this.channel_addr[channel] += read_count;
|
||||
|
||||
buffer.get(start, read_count, function(data)
|
||||
{
|
||||
|
@ -128,12 +124,11 @@ DMA.prototype.do_read = function(buffer, start, len, channel, fn)
|
|||
// write data, read memory
|
||||
DMA.prototype.do_write = function(buffer, start, len, channel, fn)
|
||||
{
|
||||
var read_count = this.channels[channel].count,
|
||||
addr = this.channels[channel].address;
|
||||
var read_count = this.channel_count[channel],
|
||||
addr = this.channel_addr[channel];
|
||||
|
||||
dbg_log("DMA write channel " + channel, LOG_DMA);
|
||||
dbg_log("to " + h(addr) + " len " + h(read_count), LOG_DMA);
|
||||
//dbg_log(this.channels[channel], LOG_DMA);
|
||||
|
||||
if(len < read_count)
|
||||
{
|
||||
|
@ -147,7 +142,7 @@ DMA.prototype.do_write = function(buffer, start, len, channel, fn)
|
|||
}
|
||||
else
|
||||
{
|
||||
this.channels[channel].address += read_count;
|
||||
this.channel_addr[channel] += read_count;
|
||||
|
||||
buffer.set(start,
|
||||
new Uint8Array(this.memory.buffer, addr, read_count + 1),
|
||||
|
|
Loading…
Reference in a new issue