Skip to content

Commit

Permalink
Add support for the partial palette on the lives remaining screen.
Browse files Browse the repository at this point in the history
1. Allow short palettes.
2. Add the title screen sprite palette.
  • Loading branch information
Chris Frantz committed Sep 6, 2020
1 parent ee1e31c commit bb42176
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tools/mxe
gtm/*
lemmy/*
init.z2edit
hidden/*
3 changes: 3 additions & 0 deletions content/palettes.textpb
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ palettes {
palette { name: "Background" address: { bank: 5 address: 0xaf40 } }
palette { name: "Sprites" address: { bank: 5 address: 0xaf50 } }
palette { name: "Select Screen" address: { bank: 5 address: 0xbbf8 } }
palette { name: "Select Sprites" address: { bank: 5 address: 0xbc08 } }
palette { name: "Lives Screen" address: { bank:-1 address: 0xc44c } length: 4 }
palette { name: "Lives (sprites)" address: { bank:-1 address: 0xc453 } length: 4 }
}
9 changes: 6 additions & 3 deletions imwidget/palette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ bool PaletteEditor::Draw() {
} else {
ImGui::Text("%20s", p.name().c_str());
}
for(int i=0; i<16; i++, id++) {
int len = p.length() ? p.length() : 16;
for(int i=0; i<len; i++, id++) {
ImGui::SameLine();
if ((i % 4) == 0) {
ImGui::Text(" ");
Expand Down Expand Up @@ -102,7 +103,8 @@ void PaletteEditor::Load() {

for(const auto& p: ri.palettes(grpsel_).palette()) {
Unpacked elem;
for(int i=0; i<16; i++) {
int len = p.length() ? p.length() : 16;
for(int i=0; i<len; i++) {
elem.color[i] = mapper_->Read(p.address(), i);
}
data_.push_back(elem);
Expand All @@ -114,7 +116,8 @@ void PaletteEditor::Save() {
int j = 0;
const auto& ri = ConfigLoader<RomInfo>::GetConfig();
for(const auto& p: ri.palettes(grpsel_).palette()) {
for(int i=0; !p.hidden() && i<16; i++) {
int len = p.length() ? p.length() : 16;
for(int i=0; !p.hidden() && i<len; i++) {
mapper_->Write(p.address(), i, data_[j].color[i]);
if (i==0 && p.magic_bg().address() != 0) {
mapper_->Write(p.magic_bg(), 0, data_[j].color[i]);
Expand Down
3 changes: 3 additions & 0 deletions proto/rominfo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ message Palette {
Address address = 2;
bool hidden = 3;
Address magic_bg = 4;
// The length defaults to 16, but there are a few shortened
// tables in the ROM.
int32 length = 5;
}

message PaletteGroup {
Expand Down

0 comments on commit bb42176

Please sign in to comment.