base:sprite_x-coordinate_calculus
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:sprite_x-coordinate_calculus [2015-04-17 04:34] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Signed Sprite X-Coordinate calculus: by delta table ===== | ||
+ | |||
+ | This piece of code adds a signed byte (from the delta table) to an unsigned byte (the sprite x-coordinate) and returns a unsigned 9-bit number, storing the lower 8-bits on the sprite x-coordinate register and 9th bit on the sprite x-coordinate MSB register. | ||
+ | |||
+ | < | ||
+ | ;Calc new sprite 0 X-coordinate by delta table | ||
+ | ;by The_WOZ/ | ||
+ | |||
+ | ; XDELTA = delta table for X | ||
+ | ; y register = XDELTA index | ||
+ | clc | ||
+ | clv | ||
+ | lda $D000 | ||
+ | bmi .pxa0 | ||
+ | adc XDELTA, | ||
+ | sta $D000 | ||
+ | bpl .cnt | ||
+ | bvs .cnt | ||
+ | lda # | ||
+ | and $D010 | ||
+ | jmp .pxm0 | ||
+ | .pxa0 | ||
+ | adc XDELTA, | ||
+ | sta $D000 | ||
+ | bvs .cnt | ||
+ | bcc .cnt | ||
+ | bmi .cnt | ||
+ | lda # | ||
+ | ora $D010 | ||
+ | .pxm0 sta $D010 | ||
+ | |||
+ | .cnt ;--- Rest of the program --- | ||
+ | |||
+ | ; X Delta table, ACME format | ||
+ | XDELTA !byte 5,6,5,6,5,6 | ||
+ | !byte 5,5,5,5,5,4 | ||
+ | !byte 4,4,4,4,3,4 | ||
+ | !byte 3,2,3,2,2,2 | ||
+ | !byte 1,1,1,1,0,0 | ||
+ | !byte 0, | ||
+ | !byte -1, | ||
+ | !byte -2, | ||
+ | !byte -2, | ||
+ | !byte -2, | ||
+ | !byte -1, | ||
+ | !byte 0,1,0,1,1,1 | ||
+ | !byte 1,2,1,2,2,1 | ||
+ | !byte 2,2,2,1,2,2 | ||
+ | !byte 2,2,1,2,2,1 | ||
+ | !byte 1,1,1,1,1,0 | ||
+ | !byte 0, | ||
+ | !byte -1, | ||
+ | !byte -2, | ||
+ | !byte -4, | ||
+ | !byte -5, | ||
+ | !byte -6, | ||
+ | !byte -5, | ||
+ | !byte -5, | ||
+ | !byte -3, | ||
+ | !byte -2, | ||
+ | !byte 0,0,0,0,0,1 | ||
+ | !byte 1,1,1,1,1,2 | ||
+ | !byte 2,1,2,2,2,2 | ||
+ | !byte 1,2,2,2,1,2 | ||
+ | !byte 2,1,2,1,1,1 | ||
+ | !byte 1,0,1,0,1,0 | ||
+ | !byte 0, | ||
+ | !byte -1, | ||
+ | !byte -2, | ||
+ | !byte -2, | ||
+ | !byte -2, | ||
+ | !byte -1, | ||
+ | !byte 1,1,1,1,2,2 | ||
+ | !byte 2,3,2,3,4,3 | ||
+ | !byte 4,4,4,4,4,5 | ||
+ | !byte 5,5,5,5,6,5 | ||
+ | !byte 6,5,6,6 | ||
+ | |||
+ | </ | ||
base/sprite_x-coordinate_calculus.txt · Last modified: 2015-04-17 04:34 by 127.0.0.1