dma testing codes ('fox.bytes' comes from the assets dir)

This commit is contained in:
minjaesong
2021-10-16 15:53:16 +09:00
parent 96730145e7
commit 47736212d3
2 changed files with 40 additions and 0 deletions

20
assets/disk0/dmatest.js Normal file
View File

@@ -0,0 +1,20 @@
let len = 560*448
let pcnt = (system.maxmem() / len)|0
if (pcnt < 2) {
printerrln("Not enought RAM on the system to test!")
return
}
let c = 0
print("Rendering plane ")
for (c = 0; c < pcnt; c++) {
print(`${c} `)
for (let i = 0; i < len; i++) {
sys.poke(c*len + i, c * ((256/pcnt)|0) + 1)
}
}
println("Let's see how fast DMA really is!")
c = 0
while (1) {
dma.ramToFrame(len * c, 0, len)
c = (c + 1) % pcnt
}

20
assets/disk0/dmatest2.js Normal file
View File

@@ -0,0 +1,20 @@
con.clear()
com.sendMessage(0, 'CLOSE')
com.sendMessage(0, 'OPENR"fox.bytes"')
let status = com.getStatusCode(0)
if (0 == status) {
println("DMA reading from disk...")
let t1 = sys.nanoTime()
dma.comToRam(0, 0, 0, 560 * 448)
let t2 = sys.nanoTime()
println("DMA copying to the framebuffer...")
let t3 = sys.nanoTime()
dma.ramToFrame(0, 0, 560 * 448)
let t4 = sys.nanoTime()
println(`DMA disk-to-RAM time: ${(t2 - t1) / 1000000} ms`)
println(`DMA RAM-to-fbuf time: ${(t4 - t3) / 1000000} ms`)
}
else {
printerrln(`File 'fox.bytes' not found on the root of the disk: ${status}`)
}