Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val zxBytes = z80File.readBytes()
- val fileInfoLength = 16
- var startDisk = 0
- var basicStart = 0u
- var basicLength = 0u
- while (true) {
- val headline = ByteArray(fileInfoLength)
- System.arraycopy(zxBytes, startDisk, headline, 0, fileInfoLength)
- // System.arraycopy(array,0,array1,9,10)
- // копирование 10 элементов из массива array, начиная с позиции 0,
- // в массив array1, начиная с позиции 9
- startDisk += fileInfoLength
- if (headline[0].toInt() == 0) return
- val text = StringBuilder()
- // headline.copyOfRange(0, 7).forEach { text.append(it.toChar()) }
- val expansion = headline[8].toChar()
- text.append("File name: ").apply {
- headline.copyOfRange(0, 7).forEach { text.append(it.toChar()) }
- }.append(".").append(expansion)
- .append(" | Start: ")
- .append("track: ")
- .append(headline[15].toUByte())
- .append(", sector: ")
- .append(headline[14].toUByte())
- .append(" | Length: ")
- .append(headline[10].toUByte() * 256u + headline[11].toUByte())
- .append(" bytes. ")
- println(text)
- if (expansion == 'B') {
- basicStart = (headline[15] * 4096 + headline[14] * 256).toUInt()
- basicLength = headline[10].toUByte() * 256u + headline[11].toUByte()
- // basicLength = 256u
- val basicCode = zxBytes
- .copyOfRange(basicStart.toInt(), (basicStart + basicLength).toInt())
- basicCode.forEachIndexed { id: Int, byte: Byte ->
- if (id % 16 == 0) println()
- print("${byte.toUByte()}, ")
- }
- println()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment