So, for objects I want to move at a fractional speed on every nmi, something like 0.5 or 1.25 pixels every time an nmi runs, I'm currently using a second byte where I'm only using bit 6 and 7.
I've been messing around with Easy6502 trying to get something working, but I've been running into issues.
here's the code I've been using on Easy6502:
I think I'm just going about this the wrong way. Does anyone have any suggestions?
Thanks
I've been messing around with Easy6502 trying to get something working, but I've been running into issues.
here's the code I've been using on Easy6502:
Code:
; set up all of the variables
; the floating point portion will only be 2 bits
; this will support 1/4 parts
lda #$3
sta subtract_float
lda #5
sta whole_number
sta starting_whole_number
lda #2
sta float_number
sta starting_float_number
; before storing this number in
; the float_number variable I'm going to
; shift it over 6 bits
asl
asl
asl
asl
asl
asl
sta float_number_shifted
lda subtract_float
; 6 shifts to use bits 7 and 6
clc
asl
asl
asl
asl
asl
asl
; if the carry is clear the shifts didn't
; overflow
bcc skip_dec_1
; if the carry flag was set dec
; the whole number
dec whole_number
jmp skip_dec_whole_2
skip_dec_1:
sec
sbc float_number
; if the carry is clear we must dec the
; whole number
bcs skip_dec_whole_2
dec whole_number
skip_dec_whole_2:
lsr
lsr
lsr
lsr
lsr
lsr
sta float_number
jmp end
starting_whole_number:
nop
starting_float_number:
nop
float_number_shifted:
nop
whole_number:
nop
float_number:
nop
subtract_float:
nop
end:
; the floating point portion will only be 2 bits
; this will support 1/4 parts
lda #$3
sta subtract_float
lda #5
sta whole_number
sta starting_whole_number
lda #2
sta float_number
sta starting_float_number
; before storing this number in
; the float_number variable I'm going to
; shift it over 6 bits
asl
asl
asl
asl
asl
asl
sta float_number_shifted
lda subtract_float
; 6 shifts to use bits 7 and 6
clc
asl
asl
asl
asl
asl
asl
; if the carry is clear the shifts didn't
; overflow
bcc skip_dec_1
; if the carry flag was set dec
; the whole number
dec whole_number
jmp skip_dec_whole_2
skip_dec_1:
sec
sbc float_number
; if the carry is clear we must dec the
; whole number
bcs skip_dec_whole_2
dec whole_number
skip_dec_whole_2:
lsr
lsr
lsr
lsr
lsr
lsr
sta float_number
jmp end
starting_whole_number:
nop
starting_float_number:
nop
float_number_shifted:
nop
whole_number:
nop
float_number:
nop
subtract_float:
nop
end:
I think I'm just going about this the wrong way. Does anyone have any suggestions?
Thanks