artificial delay on the http modem

This commit is contained in:
minjaesong
2022-11-29 21:59:05 +09:00
parent 239196d654
commit 6291d6df8b
2 changed files with 24 additions and 5 deletions

View File

@@ -318,13 +318,22 @@ MMIO
framebuffer scroll X
16..17 RW
framebuffer scroll Y
18 RO
Busy flags
1: Codec in-use
2: Draw Instructions being decoded
19 RO
Write non-zero value to initiate the Draw Instruction decoding
20..21 RO
Program Counter for the Draw Instruction decoding
1024..2047 RW
horizontal scroll offset for scanlines
2048..4095 RW
!!NEW!! Font ROM Mapping Area
Format is always 8x16 pixels, 1bpp ROM format (so that it would be YY_CHR-Compatible)
(designer's note: it's still useful to divide the char rom to two halves, lower half being characters ROM and upper half being symbols ROM)
65536..131071 RW
Draw Instructions
Text-mode-font-ROM is immutable and does not belong to VRAM
Even in the text mode framebuffer is still being drawn onto the screen, and the texts are drawn on top of it

View File

@@ -15,9 +15,12 @@ import java.net.URL
*
* Note that there is no double-slash after the protocol (or scheme)
*
* @param artificialDelayBlockSize How many bytes should be retrieved in a single block-read
* @param artificialDelayWaitTime Delay in milliseconds between the block-reads. Put non-negative value to NOT introduce a delay.
*
* Created by minjaesong on 2022-09-22.
*/
class HttpModem(private val vm: VM) : BlockTransferInterface(false, true) {
class HttpModem(private val vm: VM, private val artificialDelayBlockSize: Int = 1024, private val artificialDelayWaitTime: Int = -1) : BlockTransferInterface(false, true) {
private val DBGPRN = true
@@ -134,17 +137,24 @@ class HttpModem(private val vm: VM) : BlockTransferInterface(false, true) {
// check the http connection before we do anything to the fs
httpIn = BufferedInputStream(URL(cnxUrl).openStream())
messageComposeBuffer.reset()
bufferedOut = BufferedOutputStream(messageComposeBuffer, 1024)
val data = ByteArray(1024)
bufferedOut = BufferedOutputStream(messageComposeBuffer, artificialDelayBlockSize)
val data = ByteArray(artificialDelayBlockSize)
var fileComplete = false
var count = 0
while (!fileComplete) {
count = httpIn.read(data, 0, 1024)
count = httpIn.read(data, 0, artificialDelayBlockSize)
if (count <= 0) {
fileComplete = true
} else {
bufferedOut.write(data, 0, count)
}
if (artificialDelayWaitTime >= 0) {
try {
Thread.sleep(artificialDelayWaitTime.toLong())
}
catch (e: InterruptedException) {}
}
}
statusCode = TestDiskDrive.STATE_CODE_STANDBY
}