mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 15:04:03 +09:00
artificial delay on the http modem
This commit is contained in:
@@ -318,13 +318,22 @@ MMIO
|
|||||||
framebuffer scroll X
|
framebuffer scroll X
|
||||||
16..17 RW
|
16..17 RW
|
||||||
framebuffer scroll Y
|
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
|
1024..2047 RW
|
||||||
horizontal scroll offset for scanlines
|
horizontal scroll offset for scanlines
|
||||||
2048..4095 RW
|
2048..4095 RW
|
||||||
!!NEW!! Font ROM Mapping Area
|
!!NEW!! Font ROM Mapping Area
|
||||||
Format is always 8x16 pixels, 1bpp ROM format (so that it would be YY_CHR-Compatible)
|
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)
|
(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
|
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
|
Even in the text mode framebuffer is still being drawn onto the screen, and the texts are drawn on top of it
|
||||||
|
|||||||
@@ -15,9 +15,12 @@ import java.net.URL
|
|||||||
*
|
*
|
||||||
* Note that there is no double-slash after the protocol (or scheme)
|
* 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.
|
* 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
|
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
|
// check the http connection before we do anything to the fs
|
||||||
httpIn = BufferedInputStream(URL(cnxUrl).openStream())
|
httpIn = BufferedInputStream(URL(cnxUrl).openStream())
|
||||||
messageComposeBuffer.reset()
|
messageComposeBuffer.reset()
|
||||||
bufferedOut = BufferedOutputStream(messageComposeBuffer, 1024)
|
bufferedOut = BufferedOutputStream(messageComposeBuffer, artificialDelayBlockSize)
|
||||||
val data = ByteArray(1024)
|
val data = ByteArray(artificialDelayBlockSize)
|
||||||
var fileComplete = false
|
var fileComplete = false
|
||||||
var count = 0
|
var count = 0
|
||||||
while (!fileComplete) {
|
while (!fileComplete) {
|
||||||
count = httpIn.read(data, 0, 1024)
|
count = httpIn.read(data, 0, artificialDelayBlockSize)
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
fileComplete = true
|
fileComplete = true
|
||||||
} else {
|
} else {
|
||||||
bufferedOut.write(data, 0, count)
|
bufferedOut.write(data, 0, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (artificialDelayWaitTime >= 0) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(artificialDelayWaitTime.toLong())
|
||||||
|
}
|
||||||
|
catch (e: InterruptedException) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
statusCode = TestDiskDrive.STATE_CODE_STANDBY
|
statusCode = TestDiskDrive.STATE_CODE_STANDBY
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user