I was doing some work today to try and get the Z3Randomizer ASM code assembling in Asar, instead of Xkas, and one problem I found particularly vexing was this line, specifically: https://github.com/KatDevsGames/z3rando ... g.asm#L265
Asar attempts to do a lot of work to try and suss out if 16-bit jumps to labels are valid, in particular by seeing if the bank of the target label is in the same bank as the current pc being written to. In this case, though, the code is loading data from a label, and the databank should already be set up by the program, and that db does match where the label lives in, so theoretically it's doable, but Asar won’t treat the label as a 16-bit value. Instead, it just claims it does not know how to compile a LDA abs,Y instruction with a 24-bit absolute value.
On Xkas, I'm told that the top 8 bits are just thrown out, and the label is just converted into its 16-bit value - and Asar's emulation of xkas does incorporate this behaviour. However, it seems Asar is at a point where xkas emulation is becoming very unreliable, for example, I was getting more compiler errors - kind of similar to this - by enabling xkas emulation, than by living without it.
So, this problem was mildly vexing to me: is there some obscure behaviour in Asar where I can declare "Only get the lower 16-bits of this label, I know what I'm doing!" or something? I was able to get around this with a small change to Asar's logic, at least, by checking if you're doing some very specific math (see here) but if this isn't actually an issue with Asar, and there is a workaround I'm unaware of, then of course such a change shouldn't go into the trunk, y'know?
Code:
DialogItemReceive:
BCS .noMessage ; if doubling the item value overflowed it must be a rando item
CPY #$98 : !BLT + ;if the item is $4C or greater it must be a rando item
.noMessage
LDA.w #$FFFF
BRA .done
+
LDA Ancilla_ReceiveItem_item_messages, Y ; <--- this line specifically
.done
CMP.w #$FFFF
RTL
BCS .noMessage ; if doubling the item value overflowed it must be a rando item
CPY #$98 : !BLT + ;if the item is $4C or greater it must be a rando item
.noMessage
LDA.w #$FFFF
BRA .done
+
LDA Ancilla_ReceiveItem_item_messages, Y ; <--- this line specifically
.done
CMP.w #$FFFF
RTL
Asar attempts to do a lot of work to try and suss out if 16-bit jumps to labels are valid, in particular by seeing if the bank of the target label is in the same bank as the current pc being written to. In this case, though, the code is loading data from a label, and the databank should already be set up by the program, and that db does match where the label lives in, so theoretically it's doable, but Asar won’t treat the label as a 16-bit value. Instead, it just claims it does not know how to compile a LDA abs,Y instruction with a 24-bit absolute value.
On Xkas, I'm told that the top 8 bits are just thrown out, and the label is just converted into its 16-bit value - and Asar's emulation of xkas does incorporate this behaviour. However, it seems Asar is at a point where xkas emulation is becoming very unreliable, for example, I was getting more compiler errors - kind of similar to this - by enabling xkas emulation, than by living without it.
So, this problem was mildly vexing to me: is there some obscure behaviour in Asar where I can declare "Only get the lower 16-bits of this label, I know what I'm doing!" or something? I was able to get around this with a small change to Asar's logic, at least, by checking if you're doing some very specific math (see here) but if this isn't actually an issue with Asar, and there is a workaround I'm unaware of, then of course such a change shouldn't go into the trunk, y'know?