improve dumpvars output for zeropage variables

This commit is contained in:
Irmen de Jong 2025-02-03 22:36:58 +01:00
parent 06ca68a625
commit a940dc7d43
3 changed files with 32 additions and 25 deletions

View File

@ -272,33 +272,15 @@ class AsmGen6502Internal (
private fun dumpVariables() {
println("---- VARIABLES DUMP ----")
if(allocator.globalFloatConsts.isNotEmpty()) {
println("Floats:")
allocator.globalFloatConsts.forEach { (value, name) ->
println(" $name = $value")
}
}
if(symbolTable.allMemorySlabs.isNotEmpty()) {
println("Memory slabs:")
symbolTable.allMemorySlabs.sortedBy { it.name }.forEach { slab ->
println(" ${slab.name} ${slab.size} align ${slab.align}")
}
}
if(symbolTable.allMemMappedVariables.isNotEmpty()) {
println("Memory mapped:")
symbolTable.allMemMappedVariables
.sortedWith( compareBy( {it.address}, {it.scopedName} ))
.forEach { mvar ->
println(" ${'$'}${mvar.address.toString(16).padStart(4, '0')}\t${mvar.dt}\t${mvar.scopedName}")
}
}
if(allocator.zeropageVars.isNotEmpty()) {
println("ZeroPage:")
allocator.zeropageVars
.asSequence()
.sortedWith( compareBy( {it.value.address}, {it.key} ))
.forEach { (name, alloc) ->
println(" ${'$'}${alloc.address.toString(16).padStart(2, '0')}\t${alloc.dt}\t$name")
val allvars = allocator.zeropageVars.map { (name, alloc) -> Triple(name, alloc.address, alloc.dt) } + symbolTable.allMemMappedVariables.map { Triple(it.name, it.address, it.dt) }
allvars
.filter { it.second in 0u..255u }
.distinct()
.sortedWith( compareBy( {it.second}, {it.first} ))
.forEach {
println(" $${it.second.toString(16).padStart(2, '0')}\t${it.third}\t${it.first}")
}
}
if(symbolTable.allVariables.isNotEmpty()) {
@ -309,6 +291,26 @@ class AsmGen6502Internal (
println(" ${it.dt}\t${it.scopedName}\t")
}
}
if(allocator.globalFloatConsts.isNotEmpty()) {
println("Floats:")
allocator.globalFloatConsts.forEach { (value, name) ->
println(" $name = $value")
}
}
if(symbolTable.allMemMappedVariables.isNotEmpty()) {
println("Memory mapped:")
symbolTable.allMemMappedVariables
.sortedWith( compareBy( {it.address}, {it.scopedName} ))
.forEach { mvar ->
println(" $${mvar.address.toString(16).padStart(4, '0')}\t${mvar.dt}\t${mvar.scopedName}")
}
}
if(symbolTable.allMemorySlabs.isNotEmpty()) {
println("Memory slabs:")
symbolTable.allMemorySlabs.sortedBy { it.name }.forEach { slab ->
println(" ${slab.name} ${slab.size} align ${slab.align}")
}
}
println("---- VARIABLES DUMP END ----")
}

View File

@ -73,6 +73,8 @@ psg {
sub pulse_width(ubyte voice_num, ubyte pw) {
; -- Modifies the pulse width of this voice (when waveform=PULSE)
; voice_num = 0-15, pw = 0-63 where 0=narrow, 63=50%cycle so square wave.
; When Waveform is TRIANGLE or SAWTOOTH, it sets the XOR mode parameter instead.
; (see the Vera reference manual for the exact description of this)
cx16.vpoke_mask(1, $f9c3 + voice_num * 4, %11000000, pw)
}

View File

@ -11,6 +11,9 @@
; Returns the name of the selected file. If it is a directory instead, the name will start and end with a slash '/'.
; Works in PETSCII mode and in ISO mode as well (no case folding in ISO mode!)
; ZERO PAGE LOCATIONS USED: R0-R4 ($02-$0b), $7a-$7f (can be checked with -dumpvars)
; TODO joystick control? mouse control?
; TODO keyboard typing; jump to the first entry that starts with that character? (but 'q' for quit stops working then, plus scrolling with pageup/down is already pretty fast)