I'm struggling to understand a concept. I think I'd be able to code it, but I can't get my head around the idea... I want to use 2 bits to represent each tile of a static screen - there are 4 possible tile "types", 0-3. Each byte represents 4 tiles.
Column and row in x and y:
That gets me as far as being able to detect collisions (0 is passable, everything else is not), but how would I go about extracting the bits and ending up with a tile type from 0-3?
eg: $C0 = tiles 3, 0, 0, 0
Do I have to use a table to shift a varying number of places? That sounds like it might be slow...
Sorry if this doesn't make much sense, I'm tired. Any help would be much appreciated
Column and row in x and y:
Code:
txa
lsr
lsr
sta byte
txa
and #3
sta bit
tya
asl
adc byte
tax
lda map_data,x
sta byte
ldx bit
lda bit_table,x
and byte
...
bit_table:
.db $C0,$30,$0C,$03
lsr
lsr
sta byte
txa
and #3
sta bit
tya
asl
adc byte
tax
lda map_data,x
sta byte
ldx bit
lda bit_table,x
and byte
...
bit_table:
.db $C0,$30,$0C,$03
That gets me as far as being able to detect collisions (0 is passable, everything else is not), but how would I go about extracting the bits and ending up with a tile type from 0-3?
eg: $C0 = tiles 3, 0, 0, 0
Do I have to use a table to shift a varying number of places? That sounds like it might be slow...
Sorry if this doesn't make much sense, I'm tired. Any help would be much appreciated