From 6291d6df8b3f97db489f750a30c23fd137a7e5aa Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 29 Nov 2022 21:59:05 +0900 Subject: [PATCH] artificial delay on the http modem --- terranmon.txt | 11 ++++++++++- .../net/torvald/tsvm/peripheral/HttpModem.kt | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/terranmon.txt b/terranmon.txt index c32b571..7bfa81b 100644 --- a/terranmon.txt +++ b/terranmon.txt @@ -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 diff --git a/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt b/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt index 8906bef..d9abc53 100644 --- a/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt +++ b/tsvm_core/src/net/torvald/tsvm/peripheral/HttpModem.kt @@ -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 }