A86: Re: WTF is wrong with this routine?


[Prev][Next][Index][Thread]

A86: Re: WTF is wrong with this routine?




>It doesn't work right!  help me!?


I dont know but my god that is a slow way to multiply HL by 128. I mean,
cant you replace this:

 ld  h,0     ;hl = yCoord
 add  hl,hl    ;*2
 add  hl,hl    ;*4
 add  hl,hl    ;*8
 add  hl,hl    ;*16 - Each row is 16 bytes long
 add  hl,hl    ;*32
 add  hl,hl    ;*64
 add  hl,hl    ;*128 - Skip 8 rows for each sprite

with this (33 clocks I believe):

xor a             ; Clear A
ld h, a           ; Clear H
ld h, l            ; Multiply by 256
srl h             ; Divide by 2
adc a, 0      ; Add carry to A
ld l, a           ; Put it in L

It should work - or something similar. But each add hl, hl takes 11 clock
cycles and that right there is 77 clocks plus the ld h, 0
which is another 7 clocks

So why doesnt your routine work? I have no idea what you are trying to do
and you conviently failed to mention that. It appears
to be some aligned sprite routine I guess, are you trying to make an RPG or
something?

Later,
    Matt