Language…
13 users online: acd13141,  AmperSam, Cristian Cardoso, fanfan21, Golden Yoshi, Green Jerry, JezJitzu, Josuke Yoshikage, Maw,  Nanako, Shomi, tOaO, yoshi9429 - Guests: 238 - Bots: 304
Users: 64,795 (2,377 active)
Latest user: mathew

Trouble with an angle subroutine.

So I have this subroutine I got from another sprite on this website. This one.https://www.smwcentral.net/?p=section&a=details&id=5748 But I have a problem with the subroutine I got from it. In one emulator that's a fusion of ZSNES and some other emulator It works as it should but in the other two emulators I have it only outputs 4 fucking directions!!!

I have no idea why the hell this shit is happening. here's the code if you guys were curious.
Code
GET_ANGLE:
	REP #$20
	LDY #$00
	LDA $02
	SEC
	SBC $06
	BPL GET_ANGLE2
	INY
	EOR #$FFFF
	INC A
GET_ANGLE2:
	STA $02
	LDA $00
	SEC
	SBC $04
	BPL GET_ANGLE3
	INY
	INY
	EOR #$FFFF
	INC A
GET_ANGLE3:
	STA $00
	STY $04
	BEQ GET_ANGLE7
	CMP #$0100
	XBA
	ROR A
	XBA
	TAY
	LDA $02
	BEQ GET_ANGLE9
	CMP #$0100
	XBA
	ROR A
	AND #$FF80
	STA $4204
	STY $4206
	LDA $4214
	LSR A
	LSR A
	LSR A
	LSR A
	CMP #$0100
	SEP #$20
	BCC GET_ANGLE4
	LDA #$FF
GET_ANGLE4:
	TAY
	LDA ATANTABLE,y
	LSR $04
	BCS GET_ANGLE5
	EOR #$FF
	INC A
	BEQ GET_ANGLE5
	INC $01
GET_ANGLE5:
	LSR $04
	BCS GET_ANGLE6
	EOR #$FF
	INC A
	BNE GET_ANGLE6
	INC $01
GET_ANGLE6:
	STA $00
	LDA #$FE
	TRB $01
	RTS

GET_ANGLE7:
	SEP #$20
	LDY #$00
	LSR $04
	BCS GET_ANGLE8
	INY
GET_ANGLE8:
	STY $01
	LDA #$80
	STA $00
	LDY #$FF
	RTS

GET_ANGLE9:
	SEP #$20
	STZ $00
	LDY #$00
	LDA $04
	AND #$02
	BNE GET_ANGLE10
	INY
GET_ANGLE10:
	STY $01
	LDY #$00
	RTS
I don't why it would work on one emulator but not the others but whatever..... If you guys could either fix it up or give me something new that would be great! Also the other emulators that it doesn't work on are BizHawk and the original ZSNES.


Code
	STA $4204
	STY $4206
	LDA $4214

It's this, probably. Division on a proper SNES CPU requires around 16 cycles to calculate between writing a divisor to $4206 and reading the result from $4214. Since there's no waiting being done here, accurate emulators won't have the proper calculation finished by the time $4214 is read.

Instead, your better bet is to use the built-in PIXI routines. The current version of PIXI already comes with two routines, CircleX and CircleY, that effectively give you the cosine/sine of a given angle (in the range of 0 to 1FF) scaled to a desired radius. You just call em like this:

Code
	REP #$20
	LDA #$0100	; angle (0 to 1FF)
	STA $04
	SEP #$20
	LDA #$20	; radius (in pixels)
	STA $06
	%CircleX()
	REP #$20
	LDA $07		; calculated X offset


Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer