This shows you the differences between two versions of the page.
— |
base:rather_small_and_rather_fast_screen_offset_component_splitter [2015-04-17 04:33] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | ; in: 10-bit value in hi.A | ||
+ | ; out: x=input % 40 | ||
+ | ; y=input / 40 | ||
+ | ; a=clobbered | ||
+ | ; | ||
+ | .proc splitOffset | ||
+ | sta sm2+1 | ||
+ | lsr HI | ||
+ | ror | ||
+ | lsr HI | ||
+ | ror | ||
+ | lsr HI | ||
+ | ror | ||
+ | lsr HI | ||
+ | ror | ||
+ | lsr HI | ||
+ | ror | ||
+ | | ||
+ | ldy divtab, | ||
+ | tya | ||
+ | asl | ||
+ | asl | ||
+ | | ||
+ | sta sm1+1 | ||
+ | asl | ||
+ | | ||
+ | clc | ||
+ | sm1: adc #$00 ;< | ||
+ | sec | ||
+ | sm2: sbc #$00 ;< | ||
+ | eor #$ff ;< | ||
+ | | ||
+ | | ||
+ | cpx #40 ;due to x/40 != int(x/ | ||
+ | bcc :+ | ||
+ | txa | ||
+ | .byte $cb,40 ;axs/sbx #40 | ||
+ | iny | ||
+ | : | ||
+ | rts | ||
+ | divtab: | ||
+ | .endproc | ||
+ | </ |