mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-04 06:28:28 +08:00
Fixed bugs in assembler.
This commit is contained in:
parent
8895579d18
commit
a1cec18636
@ -109,7 +109,16 @@ Features that are in ***bold italics*** are planned and not yet implemented.
|
||||
|
||||
## Bugs
|
||||
|
||||
- [3D View](#3d-view): Random Type Box 1 and Fixed Type Box objects aren't rendered correctly
|
||||
- [3D View](#3d-view): Some objects are only partially loaded (they consist of several seperate models)
|
||||
- Forest Switch
|
||||
- Laser Fence
|
||||
- Forest Laser
|
||||
- Switch (none door)
|
||||
- Energy Barrier
|
||||
- [Script Object Code](#script-object-code): Make sure data segments are referenced by an instruction with an offset before the segment's offset
|
||||
- [Script Object Code](#script-object-code): Detect code that is both unused and incorrect and reinterpret it as data (this avoids loading and then saving the quest incorrectly)
|
||||
- [Area Selection](#area-selection): Lost heart breaker/phantasmal world 4 overwrite area 16 to have both towers
|
||||
- [Area Selection](#area-selection): Show areas that are referenced from .dat but not from script (test with Point of Disaster (709))
|
||||
- [Load Quest](#load-quest): Can't parse quest 4
|
||||
- [Load Quest](#load-quest): Can't parse quest 125 White Day
|
||||
|
@ -317,8 +317,8 @@ export class AssemblyLexer {
|
||||
|
||||
private tokenize_string(): StringToken | UnterminatedStringToken {
|
||||
const col = this.col;
|
||||
this.mark();
|
||||
this.skip();
|
||||
this.mark(); // Mark after opening quote.
|
||||
let prev_was_bs = false;
|
||||
let terminated = false;
|
||||
|
||||
@ -342,23 +342,17 @@ export class AssemblyLexer {
|
||||
}
|
||||
|
||||
let value: string;
|
||||
let len: number;
|
||||
|
||||
// Don't include quote in value.
|
||||
if (terminated) {
|
||||
this.back();
|
||||
value = this.slice();
|
||||
len = this.marked_len() + 2;
|
||||
this.skip();
|
||||
value = JSON.parse(this.slice());
|
||||
} else {
|
||||
value = this.slice();
|
||||
len = this.marked_len() + 1;
|
||||
value = JSON.parse(this.slice() + '"');
|
||||
}
|
||||
|
||||
return {
|
||||
type: terminated ? TokenType.String : TokenType.UnterminatedString,
|
||||
col,
|
||||
len,
|
||||
len: this.marked_len(),
|
||||
value,
|
||||
};
|
||||
}
|
||||
|
@ -462,25 +462,29 @@ class Assembler {
|
||||
case Type.U8:
|
||||
case Type.U8Var:
|
||||
match = true;
|
||||
this.verify_uint(1, token, args);
|
||||
this.parse_uint(1, token, args);
|
||||
break;
|
||||
case Type.U16:
|
||||
case Type.ILabel:
|
||||
case Type.ILabelVar:
|
||||
case Type.DLabel:
|
||||
match = true;
|
||||
this.verify_uint(2, token, args);
|
||||
this.parse_uint(2, token, args);
|
||||
break;
|
||||
case Type.U32:
|
||||
match = true;
|
||||
this.verify_uint(4, token, args);
|
||||
this.parse_uint(4, token, args);
|
||||
break;
|
||||
case Type.I32:
|
||||
match = true;
|
||||
this.verify_sint(4, token, args);
|
||||
this.parse_sint(4, token, args);
|
||||
break;
|
||||
case Type.F32:
|
||||
match = true;
|
||||
args.push({
|
||||
value: token.value,
|
||||
size: 4,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
match = false;
|
||||
@ -489,13 +493,29 @@ class Assembler {
|
||||
break;
|
||||
case TokenType.Float:
|
||||
match = param.type === Type.F32;
|
||||
|
||||
if (match) {
|
||||
args.push({
|
||||
value: token.value,
|
||||
size: 4,
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case TokenType.Register:
|
||||
match = param.type === Type.Register;
|
||||
this.verify_register(token, args);
|
||||
this.parse_register(token, args);
|
||||
break;
|
||||
case TokenType.String:
|
||||
match = param.type === Type.String;
|
||||
|
||||
if (match) {
|
||||
args.push({
|
||||
value: token.value,
|
||||
size: 2 * token.value.length + 2,
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
match = false;
|
||||
@ -556,7 +576,7 @@ class Assembler {
|
||||
return semi_valid;
|
||||
}
|
||||
|
||||
private verify_uint(size: number, { col, len, value }: IntToken, args: Arg[]): void {
|
||||
private parse_uint(size: number, { col, len, value }: IntToken, args: Arg[]): void {
|
||||
const bit_size = 8 * size;
|
||||
const max_value = Math.pow(2, bit_size) - 1;
|
||||
|
||||
@ -572,15 +592,15 @@ class Assembler {
|
||||
length: len,
|
||||
message: `Unsigned ${bit_size}-bit integer can't be greater than ${max_value}.`,
|
||||
});
|
||||
} else {
|
||||
args.push({
|
||||
value,
|
||||
size,
|
||||
});
|
||||
}
|
||||
|
||||
args.push({
|
||||
value,
|
||||
size,
|
||||
});
|
||||
}
|
||||
|
||||
private verify_sint(size: number, { col, len, value }: IntToken, args: Arg[]): void {
|
||||
private parse_sint(size: number, { col, len, value }: IntToken, args: Arg[]): void {
|
||||
const bit_size = 8 * size;
|
||||
const min_value = -Math.pow(2, bit_size - 1);
|
||||
const max_value = Math.pow(2, bit_size - 1) - 1;
|
||||
@ -597,27 +617,27 @@ class Assembler {
|
||||
length: len,
|
||||
message: `Signed ${bit_size}-bit integer can't be greater than ${max_value}.`,
|
||||
});
|
||||
} else {
|
||||
args.push({
|
||||
value,
|
||||
size,
|
||||
});
|
||||
}
|
||||
|
||||
args.push({
|
||||
value,
|
||||
size,
|
||||
});
|
||||
}
|
||||
|
||||
private verify_register({ col, len, value }: RegisterToken, args: Arg[]): void {
|
||||
private parse_register({ col, len, value }: RegisterToken, args: Arg[]): void {
|
||||
if (value > 255) {
|
||||
this.add_error({
|
||||
col,
|
||||
length: len,
|
||||
message: `Invalid register reference, expected r0-r255.`,
|
||||
});
|
||||
} else {
|
||||
args.push({
|
||||
value,
|
||||
size: 1,
|
||||
});
|
||||
}
|
||||
|
||||
args.push({
|
||||
value,
|
||||
size: 1,
|
||||
});
|
||||
}
|
||||
|
||||
private parse_bytes(first_token: IntToken): void {
|
||||
|
@ -22,7 +22,6 @@ export class Toolbar extends Component {
|
||||
overlay={
|
||||
<Menu onClick={this.new_quest}>
|
||||
<Menu.Item key={Episode[Episode.I]}>Episode I</Menu.Item>
|
||||
<Menu.Item key={Episode[Episode.IV]}>Episode IV</Menu.Item>
|
||||
</Menu>
|
||||
}
|
||||
trigger={["click"]}
|
||||
|
Loading…
Reference in New Issue
Block a user