Skip to content

Initial XZZ .pcb file support #309

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slimeinacloak
Copy link

Basic file format support for XinZhiZao's .pcb format
Also I have added a comment data type to the pin struct which is used to display diode readings when hovering

Notes on the format:

  • All their files are flat so flipping the board does not work and there isnt a clean way to unmirror the files
  • Part details are included in some files but I haven't fully decoded those sections so that information is not displayed at the moment

Copy link
Member

@piernov piernov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.
I wrote some comments in relation with some parts of the code.

Additionally, please fix the indentation. OpenBoardView's code base uses a single tab for each indent level, as configured by the EditorConfig file. There is also a clang-format configuration to fix the styling automatically, but please double check its effect on the code.

For the FZ format, we had decided not to include the decryption key in the source code due to possible intellectual property infringement (see previous legal issues regarding keys in the multimedia and video game copy protection world), and once it is included in the Git history, it cannot be removed easily. To stay consistent, we would need to do the same here.

#include <cstdio> // For fprintf
#include <cstdint> // For uint64_t
#include <iostream>
#include <iomanip>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up redundant/unnecessary includes.

};

static unsigned char hexconv[256]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary backslashes.

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the above arrays should be const.
Also could be a better idea to use std::array for static bound checks/iterator.

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
};

uint64_t XZZPCBFile::des(uint64_t input, uint64_t key, char mode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reference the original source of this implementation and make sure the license is compatible since this is not original work.
Alternatively, it might be a better idea to use a widely available and portable cryptographic library with a compatible license instead, if there is no deviation from the standard algorithm.

return inv_init_perm_res;
}

void XZZPCBFile::des_decrypt(std::vector<char> &buf) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be commented and clarified, as the string manipulation happening there is surprising and almost looks like obfuscated code.

}

pins.push_back(pin);
pin = blank_pin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can assign {} instead of having to declare blank_pin.

}
default:
if (sub_type_identifier != 0x00) {
printf("Unknown sub block type: 0x%02X at %d in %s\n", sub_type_identifier, current_pointer, part_name.c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use SDL_Log… to log messages to the console (without aborting file loading, otherwise ENSURE_OR_FAIL should be used).

pin.pos.y = static_cast<double>(y_origin) / 10000;
if (net_dict.find(net_index) != net_dict.end()) {
if (net_dict[net_index] == "UNCONNECTED" || net_dict[net_index] == "NC") {
pin.net = strdup(""); // As the part already gets the kPinTypeTestPad type if "UNCONNECTED" is used type will be changed to kPinTypeNotConnected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for strdup() since it is a constant.

}
}

char XZZPCBFile::read_utf8_char(char c) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code?

}
}

std::string XZZPCBFile::read_cb2312_string(const std::string &str) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it GB2312? Maybe it's possible to use std::codecvt to convert properly?

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

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy