Skip to content

Commit

Permalink
fix: button item misalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Aug 20, 2023
1 parent 9ca4eb0 commit bc9f8ab
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/new_subscr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
struct SubscrPage;
struct PACKFILE;

#define NEG_OR_MASK(v,mask) (v < 0 ? v : (v&mask))

//Old subscreen stuff
struct subscreen_object
{
Expand Down
67 changes: 33 additions & 34 deletions src/zc/hero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,34 +187,34 @@ int32_t refreshActiveShield()
int32_t id = -1;
if(DrunkcBbtn())
{
itemdata const& dat = itemsbuf[Bwpn&0xFFF];
itemdata const& dat = itemsbuf[NEG_OR_MASK(Bwpn,0xFFF)];
if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
{
id = Bwpn&0xFFF;
id = NEG_OR_MASK(Bwpn,0xFFF);
}
}
if(id < 0 && DrunkcAbtn())
{
itemdata const& dat = itemsbuf[Awpn&0xFFF];
itemdata const& dat = itemsbuf[NEG_OR_MASK(Awpn,0xFFF)];
if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
{
id = Awpn&0xFFF;
id = NEG_OR_MASK(Awpn,0xFFF);
}
}
if(id < 0 && DrunkcEx1btn())
{
itemdata const& dat = itemsbuf[Xwpn&0xFFF];
itemdata const& dat = itemsbuf[NEG_OR_MASK(Xwpn,0xFFF)];
if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
{
id = Xwpn&0xFFF;
id = NEG_OR_MASK(Xwpn,0xFFF);
}
}
if(id < 0 && DrunkcEx2btn())
{
itemdata const& dat = itemsbuf[Ywpn&0xFFF];
itemdata const& dat = itemsbuf[NEG_OR_MASK(Ywpn,0xFFF)];
if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
{
id = Ywpn&0xFFF;
id = NEG_OR_MASK(Ywpn,0xFFF);
}
}
if(!usingActiveShield(id))
Expand Down Expand Up @@ -10150,7 +10150,7 @@ void HeroClass::deselectbombs(int32_t super)
return;
int32_t temp = pg->move_legacy(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Bwpn = pg->get_item_pos(temp);
directItemB = directItem;
directItemB = NEG_OR_MASK(Bwpn,0xFFF);
game->bwpn = temp;
}

Expand All @@ -10160,7 +10160,7 @@ void HeroClass::deselectbombs(int32_t super)
return;
int32_t temp = pg->move_legacy(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Xwpn = pg->get_item_pos(temp);
directItemX = directItem;
directItemX = NEG_OR_MASK(Xwpn,0xFFF);
game->xwpn = temp;
}
else if (getItemFamily(itemsbuf,Ywpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
Expand All @@ -10169,7 +10169,7 @@ void HeroClass::deselectbombs(int32_t super)
return;
int32_t temp = pg->move_legacy(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
Ywpn = pg->get_item_pos(temp);
directItemY = directItem;
directItemY = NEG_OR_MASK(Ywpn,0xFFF);
game->ywpn = temp;
}
else
Expand All @@ -10178,7 +10178,7 @@ void HeroClass::deselectbombs(int32_t super)
return;
int32_t temp = pg->move_legacy(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Awpn = pg->get_item_pos(temp);
directItemA = directItem;
directItemA = NEG_OR_MASK(Awpn,0xFFF);
game->awpn = temp;
}
}
Expand Down Expand Up @@ -13803,29 +13803,29 @@ void HeroClass::moveheroOld()
if(DrunkrBbtn())
{
btnwpn=getItemFamily(itemsbuf,Bwpn);
dowpn = Bwpn&0xFFF;
dowpn = NEG_OR_MASK(Bwpn,0xFFF);
directWpn = directItemB;
}
else if(DrunkrAbtn())
{
btnwpn=getItemFamily(itemsbuf,Awpn);
dowpn = Awpn&0xFFF;
dowpn = NEG_OR_MASK(Awpn,0xFFF);
directWpn = directItemA;
}
else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
{
btnwpn=getItemFamily(itemsbuf,Xwpn);
dowpn = Xwpn&0xFFF;
dowpn = NEG_OR_MASK(Xwpn,0xFFF);
directWpn = directItemX;
}
else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
{
btnwpn=getItemFamily(itemsbuf,Ywpn);
dowpn = Ywpn&0xFFF;
dowpn = NEG_OR_MASK(Ywpn,0xFFF);
directWpn = directItemY;
}

if(directWpn > 255) directWpn = 0;
if(directWpn >= MAXITEMS) directWpn = -1;

// The Quick Sword only allows repeated sword or wand swings.
if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
Expand Down Expand Up @@ -17797,25 +17797,25 @@ bool HeroClass::premove()
if(DrunkrBbtn())
{
btnwpn=getItemFamily(itemsbuf,Bwpn);
dowpn = Bwpn&0xFFF;
dowpn = NEG_OR_MASK(Bwpn,0xFFF);
directWpn = directItemB;
}
else if(DrunkrAbtn())
{
btnwpn=getItemFamily(itemsbuf,Awpn);
dowpn = Awpn&0xFFF;
dowpn = NEG_OR_MASK(Awpn,0xFFF);
directWpn = directItemA;
}
else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
{
btnwpn=getItemFamily(itemsbuf,Xwpn);
dowpn = Xwpn&0xFFF;
dowpn = NEG_OR_MASK(Xwpn,0xFFF);
directWpn = directItemX;
}
else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
{
btnwpn=getItemFamily(itemsbuf,Ywpn);
dowpn = Ywpn&0xFFF;
dowpn = NEG_OR_MASK(Ywpn,0xFFF);
directWpn = directItemY;
}

Expand Down Expand Up @@ -28533,10 +28533,10 @@ int32_t getRocsPressed()

bool isItmPressed(int32_t itmid)
{
if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
if(itmid==(NEG_OR_MASK(Bwpn,0xFFF)) && DrunkcBbtn()) return true;
if(itmid==(NEG_OR_MASK(Awpn,0xFFF)) && DrunkcAbtn()) return true;
if(itmid==(NEG_OR_MASK(Xwpn,0xFFF)) && DrunkcEx1btn()) return true;
if(itmid==(NEG_OR_MASK(Ywpn,0xFFF)) && DrunkcEx2btn()) return true;
return false;
}

Expand All @@ -28549,10 +28549,9 @@ void selectNextAWpn(int32_t type)
SubscrPage* pg = new_subscreen_active->get_page(game->awpnpg);
if(!pg)
return;

int32_t ret = pg->move_legacy(type, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Awpn = pg->get_item_pos(ret);
directItemA = directItem;
directItemA = NEG_OR_MASK(Awpn,0xFFF);
game->awpn = ret;
}

Expand All @@ -28565,7 +28564,7 @@ void selectNextBWpn(int32_t type)
return;
int32_t ret = pg->move_legacy(type, game->bwpn, game->awpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Bwpn = pg->get_item_pos(ret);
directItemB = directItem;
directItemB = NEG_OR_MASK(Bwpn,0xFFF);
game->bwpn = ret;
}

Expand All @@ -28579,7 +28578,7 @@ void selectNextXWpn(int32_t type)
return;
int32_t ret = pg->move_legacy(type, game->xwpn, game->awpn, game->bwpn, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
Xwpn = pg->get_item_pos(ret);
directItemX = directItem;
directItemX = NEG_OR_MASK(Xwpn,0xFFF);
game->xwpn = ret;
}

Expand All @@ -28593,7 +28592,7 @@ void selectNextYWpn(int32_t type)
return;
int32_t ret = pg->move_legacy(type, game->ywpn, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
Ywpn = pg->get_item_pos(ret);
directItemY = directItem;
directItemY = NEG_OR_MASK(Ywpn,0xFFF);
game->ywpn = ret;
}

Expand All @@ -28615,7 +28614,7 @@ void verifyAWpn()
return;
game->awpn = pg->move_legacy(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
Awpn = pg->get_item_pos(game->awpn);
directItemA = directItem;
directItemA = NEG_OR_MASK(Awpn,0xFFF);
}
}

Expand All @@ -28630,7 +28629,7 @@ void verifyBWpn()
return;
game->bwpn = pg->move_legacy(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
Bwpn = pg->get_item_pos(game->bwpn);
directItemB = directItem;
directItemB = NEG_OR_MASK(Bwpn,0xFFF);
}

void verifyXWpn()
Expand All @@ -28646,7 +28645,7 @@ void verifyXWpn()
game->xwpn = pg->move_legacy(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
else game->xwpn = -1;
Xwpn = pg->get_item_pos(game->xwpn);
directItemX = directItem;
directItemX = NEG_OR_MASK(Xwpn,0xFFF);
}

void verifyYWpn()
Expand All @@ -28662,7 +28661,7 @@ void verifyYWpn()
game->ywpn = pg->move_legacy(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
else game->ywpn = -1;
Ywpn = pg->get_item_pos(game->ywpn);
directItemY = directItem;
directItemY = NEG_OR_MASK(Ywpn,0xFFF);
}

void verifyBothWeapons()
Expand Down
8 changes: 4 additions & 4 deletions src/zc/zc_subscr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void dosubscr()

game->bwpn = pg.cursor_pos;
game->bwpnpg = new_subscreen_active->curpage;
directItemB = directItem;
directItemB = eqwpn;
}
else if(use_a && rAbtn())
{
Expand Down Expand Up @@ -252,7 +252,7 @@ void dosubscr()
game->awpn = pg.cursor_pos;
game->awpnpg = new_subscreen_active->curpage;
game->forced_awpn = -1; //clear forced if the item is selected using the actual subscreen
directItemA = directItem;
directItemA = eqwpn;
}
else if(use_x && rEx1btn())
{
Expand Down Expand Up @@ -284,7 +284,7 @@ void dosubscr()
game->xwpn = pg.cursor_pos;
game->xwpnpg = new_subscreen_active->curpage;
game->forced_xwpn = -1; //clear forced if the item is selected using the actual subscreen
directItemX = directItem;
directItemX = eqwpn;
}
else if(use_y && rEx2btn())
{
Expand Down Expand Up @@ -316,7 +316,7 @@ void dosubscr()
game->ywpn = pg.cursor_pos;
game->ywpnpg = new_subscreen_active->curpage;
game->forced_ywpn = -1; //clear forced if the item is selected using the actual subscreen
directItemY = directItem;
directItemY = eqwpn;
}
}
}
Expand Down

0 comments on commit bc9f8ab

Please sign in to comment.