mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Remove previously deprecated features (#1777)
- Treating multi-unit strings as numbers - `rgbasm -Wnumeric-string` - `ldio [c], a` and `ldio a, [c]` (use `ldh`) - `ld [c], a` and `ld a, [c]` (use `ldh`) - `ldh [$xx], a` and `ldh a, [$xx]` (use `$FFxx`)
This commit is contained in:
@@ -155,39 +155,25 @@ std::optional<std::string> act_ReadFile(std::string const &name, uint32_t maxLen
|
||||
}
|
||||
|
||||
uint32_t act_CharToNum(std::string const &str) {
|
||||
if (std::vector<int32_t> output = charmap_Convert(str); output.size() == 1) {
|
||||
return static_cast<uint32_t>(output[0]);
|
||||
if (std::vector<int32_t> units = charmap_Convert(str); units.size() == 1) {
|
||||
// The string is a single character with a single unit value,
|
||||
// which can be used directly as a numeric character.
|
||||
return static_cast<uint32_t>(units[0]);
|
||||
} else {
|
||||
error("Character literals must be a single charmap unit");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t act_StringToNum(std::vector<int32_t> const &str) {
|
||||
uint32_t length = str.size();
|
||||
|
||||
if (length == 1) {
|
||||
// The string is a single character with a single value,
|
||||
uint32_t act_StringToNum(std::string const &str) {
|
||||
if (std::vector<int32_t> units = charmap_Convert(str); units.size() == 1) {
|
||||
// The string is a single character with a single unit value,
|
||||
// which can be used directly as a number.
|
||||
return static_cast<uint32_t>(str[0]);
|
||||
return static_cast<uint32_t>(units[0]);
|
||||
} else {
|
||||
error("Strings as numbers must be a single charmap unit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
warning(WARNING_OBSOLETE, "Treating multi-unit strings as numbers is deprecated");
|
||||
|
||||
for (int32_t v : str) {
|
||||
if (!checkNBit(v, 8, "All character units")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t r = 0;
|
||||
|
||||
for (uint32_t i = length < 4 ? 0 : length - 4; i < length; ++i) {
|
||||
r <<= 8;
|
||||
r |= static_cast<uint8_t>(str[i]);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static uint32_t adjustNegativeIndex(int32_t idx, size_t len, char const *functionName) {
|
||||
|
||||
@@ -69,7 +69,6 @@ static UpperMap<int> const keywordDict{
|
||||
{"LD", T_(SM83_LD) },
|
||||
{"LDI", T_(SM83_LDI) },
|
||||
{"LDD", T_(SM83_LDD) },
|
||||
{"LDIO", T_(SM83_LDH) },
|
||||
{"LDH", T_(SM83_LDH) },
|
||||
{"NOP", T_(SM83_NOP) },
|
||||
{"OR", T_(SM83_OR) },
|
||||
@@ -251,8 +250,6 @@ static UpperMap<int> const keywordDict{
|
||||
{"OPT", T_(POP_OPT) },
|
||||
};
|
||||
|
||||
static auto ldio = keywordDict.find("LDIO");
|
||||
|
||||
static LexerState *lexerState = nullptr;
|
||||
static LexerState *lexerStateEOL = nullptr;
|
||||
|
||||
@@ -1205,9 +1202,6 @@ static Token readIdentifier(char firstChar, bool raw) {
|
||||
// Attempt to check for a keyword if the identifier is not raw or a local label
|
||||
if (!raw && tokenType != T_(LOCAL)) {
|
||||
if (auto search = keywordDict.find(identifier); search != keywordDict.end()) {
|
||||
if (search == ldio) {
|
||||
warning(WARNING_OBSOLETE, "LDIO is deprecated; use LDH");
|
||||
}
|
||||
return Token(search->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ void opt_R(size_t maxRecursionDepth) {
|
||||
}
|
||||
|
||||
void opt_W(char const *flag) {
|
||||
if (warnings.processWarningFlag(flag) == "numeric-string") {
|
||||
warning(WARNING_OBSOLETE, "Warning flag \"numeric-string\" is deprecated");
|
||||
}
|
||||
warnings.processWarningFlag(flag);
|
||||
}
|
||||
|
||||
void opt_Parse(char const *s) {
|
||||
|
||||
@@ -1296,17 +1296,15 @@ relocexpr:
|
||||
$$ = std::move($1);
|
||||
}
|
||||
| string_literal {
|
||||
std::vector<int32_t> output = charmap_Convert($1);
|
||||
$$.makeNumber(act_StringToNum(output));
|
||||
$$.makeNumber(act_StringToNum($1));
|
||||
}
|
||||
| scoped_sym {
|
||||
$$ = handleSymbolByType(
|
||||
$1,
|
||||
[](Expression const &expr) { return expr; },
|
||||
[](std::string const &str) {
|
||||
std::vector<int32_t> output = charmap_Convert(str);
|
||||
Expression expr;
|
||||
expr.makeNumber(act_StringToNum(output));
|
||||
expr.makeNumber(act_StringToNum(str));
|
||||
return expr;
|
||||
}
|
||||
);
|
||||
@@ -2004,26 +2002,22 @@ sm83_ldd:
|
||||
|
||||
sm83_ldh:
|
||||
SM83_LDH MODE_A COMMA op_mem_ind {
|
||||
if ($4.makeCheckHRAM()) {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF"
|
||||
);
|
||||
}
|
||||
|
||||
$4.makeCheckHRAM();
|
||||
sect_ConstByte(0xF0);
|
||||
sect_RelByte($4, 1);
|
||||
if (!$4.isKnown()) {
|
||||
sect_RelByte($4, 1);
|
||||
} else {
|
||||
sect_ConstByte($4.value());
|
||||
}
|
||||
}
|
||||
| SM83_LDH op_mem_ind COMMA MODE_A {
|
||||
if ($2.makeCheckHRAM()) {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF"
|
||||
);
|
||||
}
|
||||
|
||||
$2.makeCheckHRAM();
|
||||
sect_ConstByte(0xE0);
|
||||
sect_RelByte($2, 1);
|
||||
if (!$2.isKnown()) {
|
||||
sect_RelByte($2, 1);
|
||||
} else {
|
||||
sect_ConstByte($2.value());
|
||||
}
|
||||
}
|
||||
| SM83_LDH MODE_A COMMA c_ind {
|
||||
sect_ConstByte(0xF2);
|
||||
@@ -2108,10 +2102,6 @@ sm83_ld_c_ind:
|
||||
SM83_LD ff00_c_ind COMMA MODE_A {
|
||||
sect_ConstByte(0xE2);
|
||||
}
|
||||
| SM83_LD c_ind COMMA MODE_A {
|
||||
warning(WARNING_OBSOLETE, "LD [C], A is deprecated; use LDH [C], A");
|
||||
sect_ConstByte(0xE2);
|
||||
}
|
||||
;
|
||||
|
||||
sm83_ld_rr:
|
||||
@@ -2145,10 +2135,6 @@ sm83_ld_a:
|
||||
| SM83_LD reg_a COMMA ff00_c_ind {
|
||||
sect_ConstByte(0xF2);
|
||||
}
|
||||
| SM83_LD reg_a COMMA c_ind {
|
||||
warning(WARNING_OBSOLETE, "LD A, [C] is deprecated; use LDH A, [C]");
|
||||
sect_ConstByte(0xF2);
|
||||
}
|
||||
| SM83_LD reg_a COMMA reg_rr {
|
||||
sect_ConstByte(0x0A | ($4 << 4));
|
||||
}
|
||||
|
||||
@@ -522,20 +522,16 @@ void Expression::makeBinaryOp(RPNCommand op, Expression &&src1, Expression const
|
||||
}
|
||||
}
|
||||
|
||||
bool Expression::makeCheckHRAM() {
|
||||
void Expression::makeCheckHRAM() {
|
||||
isSymbol = false;
|
||||
if (!isKnown()) {
|
||||
*reserveSpace(1) = RPN_HRAM;
|
||||
} else if (int32_t val = value(); val >= 0xFF00 && val <= 0xFFFF) {
|
||||
// That range is valid, but only keep the lower byte
|
||||
// That range is valid; only keep the lower byte
|
||||
data = val & 0xFF;
|
||||
} else if (val >= 0 && val <= 0xFF) {
|
||||
// That range is valid, but deprecated
|
||||
return true;
|
||||
} else {
|
||||
error("Source address $%" PRIx32 " not between $FF00 to $FFFF", val);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Expression::makeCheckRST() {
|
||||
|
||||
@@ -376,15 +376,9 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector<Symbol> const &fil
|
||||
|
||||
case RPN_HRAM:
|
||||
value = popRPN(patch);
|
||||
if (value < 0 || (value > 0xFF && value < 0xFF00) || value > 0xFFFF) {
|
||||
if (value < 0xFF00 || value > 0xFFFF) {
|
||||
firstErrorAt(patch, "Address $%" PRIx32 " for LDH is not in HRAM range", value);
|
||||
value = 0;
|
||||
} else if (value >= 0 && value <= 0xFF) {
|
||||
warningAt(
|
||||
patch,
|
||||
WARNING_OBSOLETE,
|
||||
"LDH is deprecated with values from $00 to $FF; use $FF00 to $FFFF"
|
||||
);
|
||||
}
|
||||
value &= 0xFF;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user