-
Notifications
You must be signed in to change notification settings - Fork 817
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
Improvements thanks to upcoming rgbds versions #686
Comments
Well, considering hacks could choose to put anything there but 0 should be the default value for the header (as RGBFIX just patches over instead of overwriting the whole region), that'd be one of the places where |
2-arg |
User-defined functions are under development, which will allow replacing the coord macros:
Old:
New:
If a ternary operator is added later, then
|
Be careful, as the changelog states:
(Emphasis added.) The syntax change is to get rid of the newbie trap that is "column 1", and it hasn't been deprecated as a courtesy due to the wide usage; but you're still strongly advised to prepare for an eventual deprecation. |
|
|
This issue I presume is meant to be a tracker for RGBDS updates and the syntax that goes along with them for pokecrystal adoption |
MACRO maskbits
; masks just enough bits to cover values 0 to \1 - 1
; \2 is an optional shift amount
; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001)
; and "maskbits 3, 2" becomes "and %00001100" (since "maskbits 3" becomes %00000011)
; example usage in rejection sampling:
; .loop
; call Random
; maskbits 26
; cp 26
; jr nc, .loop
assert 0 < (\1) && (\1) <= $100, "bitmask must be 8-bit"
- DEF x = 1
- rept 8
- if x + 1 < (\1)
- DEF x = (x << 1) | 1
- endc
- endr
+ DEF x = (1 << BITWIDTH((\1) - 1)) - 1
+ if !x
+ DEF x = 1
+ endc
if _NARG == 2
and x << (\2)
else
and x
endc
ENDM (I can't wait for user-defined functions, so we can just declare |
We could also just hard-code that formula every time, e.g.: ; maskbits BATTLETOWER_NUM_UNIQUE_TRAINERS
and (1 << BITWIDTH(BATTLETOWER_NUM_UNIQUE_TRAINERS - 1)) - 1
; maskbits NUM_DIRECTIONS, 2
and ((1 << BITWIDTH(NUM_DIRECTIONS - 1)) - 1) << 2 That would be comparable to how we currently repeat the formula for "number of bits in a byte": DEF BASE_TMHM rb (NUM_TM_HM + 7) / 8
for n, (NUM_TM_HM + 7) / 8
MACRO flag_array
ds ((\1) + 7) / 8
ENDM But I think that's a significantly simpler case. (And even then I'd use a |
Features we should use as of rgbds 0.9.0:
CHARMAP
can map characters to sequences of multiple 32-bit values (might be useful to replace always-together sequences of character bytes).
(period) which expands to the current global label scope (useful in macros/asserts.asm)BITWIDTH
andTZCOUNT
functions (useful in some calculations, e.g.maskbits
)EXPORT DEF
defines and exports a numeric symbol in a single linePUSHC name
acts likePUSHC
followed bySETCHARMAP name
PUSHS ...
acts likePUSHS
followed bySECTION ...
PUSHO ...
acts likePUSHO
followed byOPT ...
rgbgfx -X
and-Y
(can replacetools/gfx --remove-xflip
and--remove-yflip
)rgbfix -m MBC3+TIMER+RAM+BATTERY
instead of-m $10
Features to consider using:
%11_10_01_00
or9_999_999
)Features we should avoid (for simplicity and consistency):
/* block comments */
"""multi-line strings"""
#"raw strings"
that don't process any escapes#raw
identifiers that can have the same names as reserved keywords::
to separate multiple instructions on one line0x
,0b
, and0o
prefixes for hex, binary, and octal numbers (just use$
,%
, and&
)DS ALIGN
(use explicitDS number
)Features we should use that don't exist yet:
rgbgfx --background
(can replacetools/gfx --remove-whitespace
)&&
/||
instead of some nestedif
sThe text was updated successfully, but these errors were encountered: