HuC treats all array access as far data, even though ram is near data (and so is the constant back). I mean, the far data access routine needs to be redone - but there's no reason why the compiler couldn't test to see if the array is near.
Here's some work arounds:
for( x=0;x<90;x++)
{
var3++;
bg_clr_l[x]=var3;
bg_clr_h[x]=var3>>8;
}
for( x=0;x<90;x++)
{
var3++;
#asm
ldx _x
lda _var3
sta _bg_clr_l,x
lda _var3+1
sta _bg_clr_h,x
#endasm
}
/* Or for a WORD size array were the array length is less than 128 words */
some_array[x]=var3;
#asm
lda _x
asl a
tax
lda _var3
sta _some_array,x
lda _var3+1
inx
sta _some_array,x
#endasm
/* Or for a WORD size array were the array length is less than 256 words */
some_array[x]=var3;
#asm
lda _x
bmi LL01
asl a
tax
lda _var3
sta _some_array,x
lda _var3+1
inx
sta _some_array,x
bra .out01
LL01:
asl a
tax
lda _var3
sta _some_array+$100,x
lda _var3+1
inx
sta _some_array+$100,x
out01:
#endasm
You can setup ASM macros to make it look cleaner (and not have to worry about keep track of "labels"). Not only is the ASM examples like incredibly faster, they as much shorter too. The code HuC generates to access arrays is pretty bloated. Just make sure to keep those the INDEX variable as a global. If it's not, you can pass it to a global before using the ASM examples.