ca65 goodies

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ca65 goodies

Post by rainwarrior »

I don't have a solution for the string problem (TBH if it was something I needed I'd probably just write a substring directive into ca65 and submit a pull request to make it a standard feature), but here's a ca65 goodie I find useful for when I'm trying to write timed branches:

Code: Select all

.macro assert_branch_page label_
	.assert >(label_) = >*, error, "Page crossing detected!"
.endmacro

test:
	beq :+
	assert_branch_page :+ ; .assert will happen if this would cross a page
		nop
	:
	rts
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: ca65 goodies

Post by tokumaru »

thefox wrote:Maybe new builtin functions (e.g., .strleft, .strright and .strmid) should be added to complement .left, .right and .mid.
That sure would be nice.
The macro you gave might expand to quite inefficient code (not exactly sure when ca65 evaluates certain parts of it).
Yeah, that's why I was wondering if anyone had thought of a better way to do this.
Post Reply