Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FarCall bugs #3

Open
dannye opened this issue Jan 6, 2019 · 0 comments
Open

FarCall bugs #3

dannye opened this issue Jan 6, 2019 · 0 comments

Comments

@dannye
Copy link

dannye commented Jan 6, 2019

In this snippet from rst.asm:

FarCall_:
	ld  [wFarCallHold + 0], a
	put [wFarCallHold + 1], h
	put [wFarCallHold + 2], l

	[ ... ]

	ld hl, wFarCallHold + 1
	ld a, [hli]
	ld h, [hl]
	ld l, a

This ends up swapping h and l
Could just put l before h

Also, at the end, this bit attempts to save the potential return value in a and/or f while pulling the rom bank off the stack, but leaves a hole in the stack:

	push af

	add sp, 2
	pop af ; hROMBank
	add sp, -4
	rst Bankswitch

	pop af
	ret

It needs an extra add sp, 2 at the end:

	push af

	add sp, 2
	pop af ; hROMBank
	add sp, -4
	rst Bankswitch

	pop af
	add sp, 2
	ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant