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

PICT: simplify skipping of reserved opcodes #1

Open
Kristine1975 opened this issue Aug 17, 2022 · 0 comments
Open

PICT: simplify skipping of reserved opcodes #1

Kristine1975 opened this issue Aug 17, 2022 · 0 comments

Comments

@Kristine1975
Copy link
Owner

There are various if (opcode <= 0x...) checks to skip unknown/reserved opcodes:

} else if (opcode <= 0x01FF) { // args: 2
this->pict_skip_2(r, opcode);
} else if (opcode <= 0x02FE) { // args: 4
r.go(r.where() + 4);
} else if (opcode == 0x02FF) { // args: 2
// nop (essentially) because we look ahead in the 0011 implementation
} else if (opcode <= 0x0BFF) { // args: 22
r.go(r.where() + 22);
} else if (opcode == 0x0C00) { // args: header
// Currently we don't do anything with the data in this subheader, so just
// check that its version makes sense and then ignore it
PictSubheader h = r.get<PictSubheader>();
if ((h.v2.version != -1) && (h.v2e.version != -2)) {
throw runtime_error(string_printf("subheader has incorrect version (%08X or %04hX)",
h.v2.version.load(), h.v2e.version.load()));
}
} else if (opcode <= 0x7EFF) { // args: 24
r.go(r.where() + 24);
} else if (opcode <= 0x7FFF) { // args: 254
r.go(r.where() + 254);

According to IM Imaging with Quickdraw - Appendix A this code could be simplified:

Note: For opcodes $0100-$7FFF, the amount of data for opcode $nnXX = 2 times nn bytes.

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