Clears ram | doesn't clear the ram |
Code: [Select] ld hl, (screenx) | Code: [Select] ld hl, (screenx) |
SubFP:
or a
sbc hl, de
MulFP:
;Multiplies 2 16bit fixed-point numbers
;IN: de, bc
;OUT: de * bc in hl
;DESTROYS: af, bc, de, hl
bit 7, d
jr nz, _MulFP_FirstNeg
bit 7, b
jr nz, _MulFP_AnsNeg
jr z, _MulFP_AnsPos
_MulFP_FirstNeg:
bit 7, b
jr nz, _MulFP_AnsPos
_MulFP_AnsNeg:
ld a, 1
push af
jr _MulFP_Cont
_MulFP_AnsPos:
ld a, 0
push af
_MulFP_Cont:
bit 7, b
jr z, _MulFP_BCPos
call NegBC
_MulFP_BCPos:
bit 7, d
jr z, _MulFP_DEPos
call NegDE
_MulFP_DEPos:
call Mul16
ld l, h
ld h, e
pop af
cp 1
call z, NegHL
ret
and it uses the Mul16 routine which looks like this:Mul16: ; This routine performs the operation DEHL=BC*DE
ld hl,0
ld a,16
Mul16Loop:
add hl,hl
rl e
rl d
jp nc,NoMul16
add hl,bc
jp nc,NoMul16
inc de
NoMul16:
dec a
jp nz,Mul16Loop
ret
NegHL:
xor a
sub l
ld l,a
sbc a,a
sub h
ld h,a
ret
NegBC:
xor a
sub c
ld c,a
sbc a,a
sub b
ld b,a
ret
NegDE:
xor a
sub e
ld e,a
sbc a,a
sub d
ld d,a
ret
0A18 is part of the OS, you want to try to figure out where execution leaves your code. Your code will be in the $9D95 - ~$B000 range depending on program size.Do you mean this could be a bug in latenite?
I put together everything you have posted so far and it ran fine. So I'm really not sure what isn't working right. It might not even be related to the code you posted.
I remember one time when I was working on Pyoro I had the weirdest bug that seemingly occurred at random and couldn't be traced back anywhere. It took me a week to find but eventually, I found it and fixed it. I had forgotten to back up the ix register during my interrupt routine. If you're using custom interrupts, make sure the routine is working right.I don't use custom interrupts. I turn interupts off at the beginning of my program, and turn them back on at the end of my program. I never had problems with this, so I don't see why it would give problems now.
Another thought, is your program nearing 8kb in size? Any code larger than that will cause a crash due to execution protection on the last page. Try replacing the commented out part in your example with nops instead of the loads, I bet it has something to do with program size rather than the particular instructions.
Also, where are screenx and screeny? You're not writing over any OS variables right?
Do you still have problems with that ERR:BREAK?Nope, That's all solved now.