mirror of
https://github.com/Smallhacker/disbrowser.git
synced 2025-01-14 01:29:58 +00:00
Fixed pointer table commenting
This commit is contained in:
parent
1c71788f01
commit
3322f2460f
@ -2,7 +2,6 @@ package com.smallhacker.disbrowser
|
||||
|
||||
import com.smallhacker.disbrowser.asm.*
|
||||
import com.smallhacker.disbrowser.game.Game
|
||||
import com.smallhacker.disbrowser.game.GameData
|
||||
|
||||
class Grid {
|
||||
private val arrowCells = HashMap<Pair<Int, Int>, HtmlNode?>()
|
||||
@ -61,18 +60,19 @@ class Grid {
|
||||
}
|
||||
|
||||
fun add(ins: CodeUnit, game: Game, disassembly: Disassembly) {
|
||||
val presentedAddress = ins.presentedAddress
|
||||
val sortedAddress = ins.sortedAddress
|
||||
val indicativeAddress = ins.indicativeAddress
|
||||
val gameData = game.gameData
|
||||
|
||||
if (nextAddress != null) {
|
||||
if (presentedAddress != nextAddress) {
|
||||
if (sortedAddress != nextAddress) {
|
||||
addDummy()
|
||||
}
|
||||
}
|
||||
nextAddress = ins.nextPresentedAddress
|
||||
nextAddress = ins.nextSortedAddress
|
||||
|
||||
val y = (height++)
|
||||
addresses[presentedAddress] = y
|
||||
addresses[sortedAddress] = y
|
||||
|
||||
val (address, bytes, label, primaryMnemonic, secondaryMnemonic, suffix, operands, state, comment, labelAddress)
|
||||
= ins.print(gameData)
|
||||
@ -80,7 +80,7 @@ class Grid {
|
||||
add(y, ins.address,
|
||||
text(address ?: ""),
|
||||
text(bytes),
|
||||
editableField(game, presentedAddress, "label", label),
|
||||
editableField(game, indicativeAddress, "label", label),
|
||||
fragment {
|
||||
if (secondaryMnemonic == null) {
|
||||
text(primaryMnemonic)
|
||||
@ -113,7 +113,7 @@ class Grid {
|
||||
}
|
||||
},
|
||||
text(state ?: ""),
|
||||
editableField(game, presentedAddress, "comment", comment)
|
||||
editableField(game, indicativeAddress, "comment", comment)
|
||||
)
|
||||
|
||||
if (ins.opcode.continuation == Continuation.NO) {
|
||||
|
@ -48,10 +48,10 @@ object Service {
|
||||
grid.add(it, game, disassembly)
|
||||
}
|
||||
disassembly.asSequence()
|
||||
.mapNotNull {
|
||||
it.linkedState
|
||||
.mapNotNull {ins ->
|
||||
ins.linkedState
|
||||
?.let { link ->
|
||||
it.presentedAddress to link.address
|
||||
ins.sortedAddress to link.address
|
||||
}
|
||||
}
|
||||
.sortedBy { it.first distanceTo it.second }
|
||||
|
@ -6,8 +6,9 @@ import com.smallhacker.disbrowser.util.*
|
||||
interface CodeUnit {
|
||||
val address: SnesAddress?
|
||||
val relativeAddress: SnesAddress
|
||||
val presentedAddress: SnesAddress
|
||||
val nextPresentedAddress: SnesAddress
|
||||
val indicativeAddress: SnesAddress
|
||||
val sortedAddress: SnesAddress
|
||||
val nextSortedAddress: SnesAddress
|
||||
|
||||
val linkedState: State?
|
||||
val preState: State?
|
||||
@ -55,13 +56,14 @@ interface CodeUnit {
|
||||
class DataBlock(
|
||||
override val opcode: Opcode,
|
||||
override val bytes: ValidMemorySpace,
|
||||
override val presentedAddress: SnesAddress,
|
||||
override val indicativeAddress: SnesAddress,
|
||||
override val sortedAddress: SnesAddress,
|
||||
override val relativeAddress: SnesAddress,
|
||||
override val linkedState: State?,
|
||||
override val memory: SnesMemory
|
||||
) : CodeUnit {
|
||||
override val nextPresentedAddress: SnesAddress
|
||||
get() = presentedAddress + operandLength.toInt()
|
||||
override val nextSortedAddress: SnesAddress
|
||||
get() = sortedAddress + operandLength.toInt()
|
||||
override val operandLength get() = bytes.size
|
||||
|
||||
override val address: SnesAddress? = null
|
||||
@ -73,9 +75,10 @@ class DataBlock(
|
||||
class Instruction(override val bytes: ValidMemorySpace, override val opcode: Opcode, override val preState: State) : CodeUnit {
|
||||
override val memory = preState.memory
|
||||
override val address: SnesAddress get() = preState.address
|
||||
override val indicativeAddress get() = address
|
||||
override val relativeAddress get() = address
|
||||
override val presentedAddress get() = address
|
||||
override val nextPresentedAddress get() = postState.address
|
||||
override val sortedAddress get() = address
|
||||
override val nextSortedAddress get() = postState.address
|
||||
|
||||
override val postState = opcode.mutate(this)
|
||||
.mutateAddress { it + bytes.size.toInt() }
|
||||
@ -136,8 +139,8 @@ fun CodeUnit.print(gameData: GameData? = null): PrintedCodeUnit {
|
||||
}
|
||||
|
||||
val state = postState?.toString()
|
||||
val label = address?.let { gameData?.get(it)?.label }
|
||||
val comment = address?.let { gameData?.get(it)?.comment }
|
||||
val label = gameData?.get(indicativeAddress)?.label
|
||||
val comment = gameData?.get(indicativeAddress)?.comment
|
||||
val formattedAddress = address?.toFormattedString()
|
||||
val bytes = bytesToString()
|
||||
|
||||
|
@ -78,7 +78,7 @@ object Disassembler {
|
||||
}
|
||||
|
||||
val instructionList = instructions
|
||||
.sortedBy { it.presentedAddress }
|
||||
.sortedBy { it.sortedAddress }
|
||||
.toList()
|
||||
|
||||
return Disassembly(instructionList)
|
||||
|
@ -104,6 +104,7 @@ class JmpIndirectLongInterleavedTable @JsonCreator constructor(
|
||||
DataBlock(
|
||||
Opcode.CODE_POINTER_LONG,
|
||||
table.range(offset, 3u),
|
||||
start + offset.toInt(),
|
||||
jumpInstruction.postState.address + offset.toInt(),
|
||||
jumpInstruction.relativeAddress,
|
||||
jumpInstruction.opcode.mutate(jumpInstruction)
|
||||
|
Loading…
x
Reference in New Issue
Block a user