Minor code cleanup
This commit is contained in:
parent
51ac3e8f59
commit
0fea092675
|
@ -31,9 +31,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
|||
|
||||
private fun preprocess(lines: List<String>): List<String> {
|
||||
val pattern = Pattern.compile("^define\\s+(\\w+)\\s+(\\S+)", Pattern.CASE_INSENSITIVE)
|
||||
|
||||
val sanitizedLines = lines.map { sanitize(it) }
|
||||
|
||||
sanitizedLines
|
||||
.map { pattern.matcher(it) }
|
||||
.filter { it.find() }
|
||||
|
@ -316,7 +314,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
|||
val label = param.replace("^#[<>](\\w+)$".toRegex(), "$1")
|
||||
val hilo = param.replace("^#([<>]).*$".toRegex(), "$1")
|
||||
pushByte(opcode)
|
||||
val addr = labels.get(label)
|
||||
val addr = labels[label]
|
||||
if (addr != -1) {
|
||||
when (hilo) {
|
||||
">" -> {
|
||||
|
@ -375,7 +373,7 @@ class Assembler(private var memory: Memory, private val symbols: Symbols) {
|
|||
var parameter = param
|
||||
|
||||
if (parameter.matches("^\\w+$".toRegex())) {
|
||||
val lookupVal = symbols.get(parameter) // Substitute symbol by actual value, then proceed
|
||||
val lookupVal = symbols[parameter] // Substitute symbol by actual value, then proceed
|
||||
if (lookupVal != null) {
|
||||
parameter = lookupVal
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ open class Display(context: Context, attrs: AttributeSet) : View(context, attrs)
|
|||
private var listener: Callbacks? = null
|
||||
|
||||
fun setOnDisplayCallback(callback: Callbacks) {
|
||||
listener = callback;
|
||||
listener = callback
|
||||
}
|
||||
|
||||
open fun updatePixel(addr: Int, value: Int) {
|
||||
|
@ -37,8 +37,8 @@ open class Display(context: Context, attrs: AttributeSet) : View(context, attrs)
|
|||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
val pixelSizeX = getWidth() / numX
|
||||
val pixelSizeY = getHeight() / numX
|
||||
val pixelSizeX = width / numX
|
||||
val pixelSizeY = height / numX
|
||||
|
||||
matrix.forEachIndexed { i, _ ->
|
||||
matrix[i].forEachIndexed { j, _ ->
|
||||
|
|
|
@ -30,7 +30,6 @@ class Memory(private val display: Display) {
|
|||
var i = 0
|
||||
var n: Int
|
||||
val dump = StringBuilder()
|
||||
|
||||
while (i < length) {
|
||||
if (i.and(15) == 0) {
|
||||
if (i > 0) {
|
||||
|
|
|
@ -2,5 +2,4 @@ package android.emu6502.instructions
|
|||
|
||||
import java.util.*
|
||||
|
||||
class Symbols : HashMap<String, String>() {
|
||||
}
|
||||
class Symbols : HashMap<String, String>()
|
Loading…
Reference in New Issue