diff --git a/CMake/ctr/devkitarm-libctru.cmake b/CMake/ctr/devkitarm-libctru.cmake index 6bf7e05b..33f0e490 100644 --- a/CMake/ctr/devkitarm-libctru.cmake +++ b/CMake/ctr/devkitarm-libctru.cmake @@ -44,7 +44,7 @@ set(CMAKE_OBJCOPY "${TOOLCHAIN_PREFIX}objcopy${TOOLCHAIN_SUFFIX}" CACHE INTERNAL set(CMAKE_SIZE_UTIL "${TOOLCHAIN_PREFIX}size${TOOLCHAIN_SUFFIX}" CACHE INTERNAL "") set(3DS ON) -add_definitions(-D__3DS__ -D_3DS) # _3DS is used and expected by the devkit SDL headers. +add_definitions(-D__3DS__ -D_3DS -DALTERNATIVE_CONTROLS) # _3DS is used and expected by the devkit SDL headers. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") diff --git a/CMake/ctr/n3ds_defs.cmake b/CMake/ctr/n3ds_defs.cmake index 6b2d6e57..8ccf4021 100644 --- a/CMake/ctr/n3ds_defs.cmake +++ b/CMake/ctr/n3ds_defs.cmake @@ -1,6 +1,6 @@ set(NONET ON) set(USE_SDL1 ON) -set(SDL1_VIDEO_MODE_FLAGS SDL_SWSURFACE|SDL_CONSOLEBOTTOM) +set(SDL1_VIDEO_MODE_FLAGS SDL_SWSURFACE|SDL_DUALSCR|SDL_FITHEIGHT) set(PREFILL_PLAYER_NAME ON) set(HAS_KBCTRL 1) set(KBCTRL_BUTTON_DPAD_LEFT SDLK_LEFT) @@ -16,3 +16,5 @@ set(KBCTRL_BUTTON_LEFTSHOULDER SDLK_l) set(KBCTRL_BUTTON_START SDLK_RETURN) set(KBCTRL_BUTTON_BACK SDLK_ESCAPE) set(KBCTRL_MODIFIER_KEY SDLK_END) +set(JOY_AXIS_LEFTX 0) +set(JOY_AXIS_LEFTY 1) diff --git a/Source/automap.cpp b/Source/automap.cpp index 3aab8941..b3a14ed2 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -195,11 +195,11 @@ void DrawAutomap() mapy = MapY - 1; if (cells & 1) { - sx = 384 - AutoMapPosBits * ((cells - 1) >> 1); - sy = 336 - AutoMapXPos * ((cells + 1) >> 1); + sx = 384 + SPANEL_X - SCREEN_X - AutoMapPosBits * ((cells - 1) >> 1); + sy = 336 + SPANEL_Y - SCREEN_Y - AutoMapXPos * ((cells + 1) >> 1); } else { - sx = 384 - AutoMapPosBits * (cells >> 1) + AutoMapXPos; - sy = 336 - AutoMapXPos * (cells >> 1) - AutoMapYPos; + sx = 384 + SPANEL_X - SCREEN_X - AutoMapPosBits * (cells >> 1) + AutoMapXPos; + sy = 336 + SPANEL_Y - SCREEN_Y - AutoMapXPos * (cells >> 1) - AutoMapYPos; } if (ViewX & 1) { sx -= AutoMapYPos; @@ -214,9 +214,17 @@ void DrawAutomap() sy += AutoMapScale * ScrollInfo._syoff / 100 >> 1; if (invflag || sbookflag) { sx -= 160; +#ifdef __3DS__ + } else { + ClearScreenBufferPortion(RIGHT_PANEL_X - SCREEN_X, SPANEL_Y - SCREEN_Y, SPANEL_WIDTH, SPANEL_HEIGHT); +#endif } if (chrflag || questlog) { sx += 160; +#ifdef __3DS__ + } else { + ClearScreenBufferPortion(SPANEL_X - SCREEN_X, SPANEL_Y - SCREEN_Y, SPANEL_WIDTH, SPANEL_HEIGHT); +#endif } for (i = 0; i <= cells + 1; i++) { @@ -458,6 +466,10 @@ void DrawAutomapPlr() if (chrflag || questlog) x += 160; y -= AMPlayerX; +#ifdef __3DS__ + x += SPANEL_X - SCREEN_X; + y += SPANEL_Y - SCREEN_Y; +#endif switch (plr[myplr]._pdir) { case DIR_N: @@ -542,6 +554,11 @@ WORD GetAutomapType(int x, int y, BOOL view) return rv; } +void print_automape_str(int x, int y, char *str, int color) +{ + PrintGameStr(x + SPANEL_X - SCREEN_X, y + SPANEL_Y - SCREEN_Y, str, color); +} + void DrawAutomapGame() { char desc[256]; @@ -549,19 +566,19 @@ void DrawAutomapGame() if (gbMaxPlayers > 1) { strcat(strcpy(desc, "game: "), szPlayerName); - PrintGameStr(8, 20, desc, COL_GOLD); + print_automape_str(8, 20, desc, COL_GOLD); nextline = 35; if (szPlayerDescript[0]) { strcat(strcpy(desc, "password: "), szPlayerDescript); - PrintGameStr(8, 35, desc, COL_GOLD); + print_automape_str(8, 35, desc, COL_GOLD); nextline = 50; } } if (setlevel) - PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); + print_automape_str(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); else if (currlevel) { sprintf(desc, "Level: %i", currlevel); - PrintGameStr(8, nextline, desc, COL_GOLD); + print_automape_str(8, nextline, desc, COL_GOLD); } } diff --git a/Source/control.cpp b/Source/control.cpp index 2b623776..30f83cd6 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -136,10 +136,10 @@ char *PanBtnStr[8] = { "Player Attack" }; RECT32 ChrBtnsRect[4] = { - { 137, 138, 41, 22 }, - { 137, 166, 41, 22 }, - { 137, 195, 41, 22 }, - { 137, 223, 41, 22 } + { 137 + SPANEL_X - SCREEN_X, 138 + SPANEL_Y - SCREEN_Y, 41, 22 }, + { 137 + SPANEL_X - SCREEN_X, 166 + SPANEL_Y - SCREEN_Y, 41, 22 }, + { 137 + SPANEL_X - SCREEN_X, 195 + SPANEL_Y - SCREEN_Y, 41, 22 }, + { 137 + SPANEL_X - SCREEN_X, 223 + SPANEL_Y - SCREEN_Y, 41, 22 } }; int SpellPages[6][7] = { @@ -1262,7 +1262,7 @@ void DrawChr() char chrstr[64]; int pc, mindam, maxdam; - CelDraw(SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); + CelDraw(SPANEL_X, 351 + SPANEL_Y, pChrPanel, 1, SPANEL_WIDTH); ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, COL_WHITE); if (plr[myplr]._pClass == PC_WARRIOR) { @@ -1435,13 +1435,13 @@ void DrawChr() ADD_PlrStringXY(95, 266, 126, chrstr, COL_RED); pc = plr[myplr]._pClass; if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR]) - CelDraw(137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); + CelDraw(137 + SPANEL_X, 159 + SPANEL_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); if (plr[myplr]._pBaseMag < MaxStats[pc][ATTRIB_MAG]) - CelDraw(137 + SCREEN_X, 187 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); + CelDraw(137 + SPANEL_X, 187 + SPANEL_Y, pChrButtons, chrbtn[ATTRIB_MAG] + 4, 41); if (plr[myplr]._pBaseDex < MaxStats[pc][ATTRIB_DEX]) - CelDraw(137 + SCREEN_X, 216 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); + CelDraw(137 + SPANEL_X, 216 + SPANEL_Y, pChrButtons, chrbtn[ATTRIB_DEX] + 6, 41); if (plr[myplr]._pBaseVit < MaxStats[pc][ATTRIB_VIT]) - CelDraw(137 + SCREEN_X, 244 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); + CelDraw(137 + SPANEL_X, 244 + SPANEL_Y, pChrButtons, chrbtn[ATTRIB_VIT] + 8, 41); } col = plr[myplr]._pMaxHP <= plr[myplr]._pMaxHPBase ? COL_WHITE : COL_BLUE; @@ -1477,8 +1477,8 @@ void MY_PlrStringXY(int x, int y, int endX, char *pszStr, char col, int base) char *tmp; int sx, sy, screen_x, line, widthOffset; - sx = x + SCREEN_X; - sy = y + SCREEN_Y; + sx = x + SPANEL_X; + sy = y + SPANEL_Y; widthOffset = endX - x + 1; line = 0; screen_x = 0; @@ -1522,7 +1522,7 @@ void DrawLevelUpIcon() if (!stextflag) { nCel = lvlbtndown ? 3 : 2; ADD_PlrStringXY(PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE); - CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41); + CelDraw(PANEL_X + 40, SCREEN_Y + VIEWPORT_HEIGHT - 17, pChrButtons, nCel, 41); } } @@ -1606,8 +1606,10 @@ void DrawDurIcon() if (!chrflag && !questlog || !invflag && !sbookflag) { x1 = 592 + PANEL_X; +#ifndef __3DS__ if (invflag || sbookflag) x1 = 272 + PANEL_X; +#endif p = &plr[myplr]; x2 = DrawDurIcon4Item(&p->InvBody[INVLOC_HEAD], x1, 4); x3 = DrawDurIcon4Item(&p->InvBody[INVLOC_CHEST], x2, 3); @@ -1647,7 +1649,7 @@ int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) } if (pItem->_iDurability > 2) c += 8; - CelDraw(x, -17 + PANEL_Y, pDurIcons, c, 32); + CelDraw(x, SCREEN_Y + VIEWPORT_HEIGHT - 17, pDurIcons, c, 32); return x - 40; } @@ -1716,8 +1718,8 @@ void DrawSpellBook() char st; unsigned __int64 spl; - CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pSpellBkCel, 1, SPANEL_WIDTH); - CelDraw(RIGHT_PANEL_X + 76 * sbooktab + 7, 348 + SCREEN_Y, pSBkBtnCel, sbooktab + 1, 76); + CelDraw(RIGHT_PANEL_X, 351 + SPANEL_Y, pSpellBkCel, 1, SPANEL_WIDTH); + CelDraw(RIGHT_PANEL_X + 76 * sbooktab + 7, 348 + SPANEL_Y, pSBkBtnCel, sbooktab + 1, 76); spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells; @@ -1727,10 +1729,10 @@ void DrawSpellBook() if (sn != -1 && spl & (__int64)1 << (sn - 1)) { st = GetSBookTrans(sn, TRUE); SetSpellTrans(st); - DrawSpellCel(RIGHT_PANEL + 75, yp, pSBkIconCels, SpellITbl[sn], 37); + DrawSpellCel(RIGHT_PANEL_X - SCREEN_X + 75, yp + SPANEL_Y - SCREEN_Y, pSBkIconCels, SpellITbl[sn], 37); if (sn == plr[myplr]._pRSpell && st == plr[myplr]._pRSplType) { SetSpellTrans(RSPLTYPE_SKILL); - DrawSpellCel(RIGHT_PANEL + 75, yp, pSBkIconCels, 43, 37); + DrawSpellCel(RIGHT_PANEL_X - SCREEN_X + 75, yp + SPANEL_Y - SCREEN_Y, pSBkIconCels, 43, 37); } PrintSBookStr(10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE); switch (GetSBookTrans(sn, FALSE)) { @@ -1775,7 +1777,7 @@ void PrintSBookStr(int x, int y, BOOL cjustflag, char *pszStr, char col) char *tmp; int screen_x, line, sx; - sx = x + RIGHT_PANEL + 120; + sx = x + RIGHT_PANEL_X - SCREEN_X + 120; line = 0; if (cjustflag) { screen_x = 0; @@ -1794,7 +1796,7 @@ void PrintSBookStr(int x, int y, BOOL cjustflag, char *pszStr, char col) line += fontkern[c] + 1; if (c) { if (line <= 222) - CPrintString(sx, y, c, col); + CPrintString(sx, y + SPANEL_Y - SCREEN_Y, c, col); } sx += fontkern[c] + 1; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e8a51787..67170c2d 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -313,6 +313,8 @@ void diablo_parse_flags(char *args) int i; #endif + EnableFrameCount(); + while (*args != '\0') { while (isspace(*args)) { args++; diff --git a/Source/inv.cpp b/Source/inv.cpp index dbe7754a..243c9ae2 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -10,71 +10,71 @@ int sgdwLastTime; // check name const InvXY InvRect[73] = { // clang-format off // X, Y - { RIGHT_PANEL + 132, 31 }, // helmet - { RIGHT_PANEL + 160, 31 }, // helmet - { RIGHT_PANEL + 132, 59 }, // helmet - { RIGHT_PANEL + 160, 59 }, // helmet - { RIGHT_PANEL + 45, 205 }, // left ring - { RIGHT_PANEL + 247, 205 }, // right ring - { RIGHT_PANEL + 204, 59 }, // amulet - { RIGHT_PANEL + 17, 104 }, // left hand - { RIGHT_PANEL + 46, 104 }, // left hand - { RIGHT_PANEL + 17, 132 }, // left hand - { RIGHT_PANEL + 46, 132 }, // left hand - { RIGHT_PANEL + 17, 160 }, // left hand - { RIGHT_PANEL + 46, 160 }, // left hand - { RIGHT_PANEL + 247, 104 }, // right hand - { RIGHT_PANEL + 276, 104 }, // right hand - { RIGHT_PANEL + 247, 132 }, // right hand - { RIGHT_PANEL + 276, 132 }, // right hand - { RIGHT_PANEL + 247, 160 }, // right hand - { RIGHT_PANEL + 276, 160 }, // right hand - { RIGHT_PANEL + 132, 104 }, // chest - { RIGHT_PANEL + 160, 104 }, // chest - { RIGHT_PANEL + 132, 132 }, // chest - { RIGHT_PANEL + 160, 132 }, // chest - { RIGHT_PANEL + 132, 160 }, // chest - { RIGHT_PANEL + 160, 160 }, // chest - { RIGHT_PANEL + 17, 250 }, // inv row 1 - { RIGHT_PANEL + 46, 250 }, // inv row 1 - { RIGHT_PANEL + 74, 250 }, // inv row 1 - { RIGHT_PANEL + 103, 250 }, // inv row 1 - { RIGHT_PANEL + 131, 250 }, // inv row 1 - { RIGHT_PANEL + 160, 250 }, // inv row 1 - { RIGHT_PANEL + 189, 250 }, // inv row 1 - { RIGHT_PANEL + 218, 250 }, // inv row 1 - { RIGHT_PANEL + 247, 250 }, // inv row 1 - { RIGHT_PANEL + 276, 250 }, // inv row 1 - { RIGHT_PANEL + 17, 279 }, // inv row 2 - { RIGHT_PANEL + 46, 279 }, // inv row 2 - { RIGHT_PANEL + 74, 279 }, // inv row 2 - { RIGHT_PANEL + 103, 279 }, // inv row 2 - { RIGHT_PANEL + 131, 279 }, // inv row 2 - { RIGHT_PANEL + 160, 279 }, // inv row 2 - { RIGHT_PANEL + 189, 279 }, // inv row 2 - { RIGHT_PANEL + 218, 279 }, // inv row 2 - { RIGHT_PANEL + 247, 279 }, // inv row 2 - { RIGHT_PANEL + 276, 279 }, // inv row 2 - { RIGHT_PANEL + 17, 308 }, // inv row 3 - { RIGHT_PANEL + 46, 308 }, // inv row 3 - { RIGHT_PANEL + 74, 308 }, // inv row 3 - { RIGHT_PANEL + 103, 308 }, // inv row 3 - { RIGHT_PANEL + 131, 308 }, // inv row 3 - { RIGHT_PANEL + 160, 308 }, // inv row 3 - { RIGHT_PANEL + 189, 308 }, // inv row 3 - { RIGHT_PANEL + 218, 308 }, // inv row 3 - { RIGHT_PANEL + 247, 308 }, // inv row 3 - { RIGHT_PANEL + 276, 308 }, // inv row 3 - { RIGHT_PANEL + 17, 336 }, // inv row 4 - { RIGHT_PANEL + 46, 336 }, // inv row 4 - { RIGHT_PANEL + 74, 336 }, // inv row 4 - { RIGHT_PANEL + 103, 336 }, // inv row 4 - { RIGHT_PANEL + 131, 336 }, // inv row 4 - { RIGHT_PANEL + 160, 336 }, // inv row 4 - { RIGHT_PANEL + 189, 336 }, // inv row 4 - { RIGHT_PANEL + 218, 336 }, // inv row 4 - { RIGHT_PANEL + 247, 336 }, // inv row 4 - { RIGHT_PANEL + 276, 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 132, SPANEL_Y - SCREEN_Y + 31 }, // helmet + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 31 }, // helmet + { RIGHT_PANEL_X - SCREEN_X + 132, SPANEL_Y - SCREEN_Y + 59 }, // helmet + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 59 }, // helmet + { RIGHT_PANEL_X - SCREEN_X + 45, SPANEL_Y - SCREEN_Y + 205 }, // left ring + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 205 }, // right ring + { RIGHT_PANEL_X - SCREEN_X + 204, SPANEL_Y - SCREEN_Y + 59 }, // amulet + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 104 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 104 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 132 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 132 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 160 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 160 }, // left hand + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 104 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 104 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 132 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 132 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 160 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 160 }, // right hand + { RIGHT_PANEL_X - SCREEN_X + 132, SPANEL_Y - SCREEN_Y + 104 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 104 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 132, SPANEL_Y - SCREEN_Y + 132 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 132 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 132, SPANEL_Y - SCREEN_Y + 160 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 160 }, // chest + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 74, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 103, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 131, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 189, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 218, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 250 }, // inv row 1 + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 74, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 103, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 131, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 189, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 218, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 279 }, // inv row 2 + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 74, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 103, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 131, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 189, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 218, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 308 }, // inv row 3 + { RIGHT_PANEL_X - SCREEN_X + 17, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 46, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 74, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 103, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 131, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 160, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 189, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 218, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 247, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 + { RIGHT_PANEL_X - SCREEN_X + 276, SPANEL_Y - SCREEN_Y + 336 }, // inv row 4 { PANEL_LEFT + 205, PANEL_TOP + 33 }, // belt { PANEL_LEFT + 234, PANEL_TOP + 33 }, // belt { PANEL_LEFT + 263, PANEL_TOP + 33 }, // belt @@ -141,10 +141,10 @@ void DrawInv() BOOL invtest[NUM_INV_GRID_ELEM]; int frame, frame_width, colour, screen_x, screen_y, i, j, ii; - CelDraw(RIGHT_PANEL_X, 351 + SCREEN_Y, pInvCels, 1, SPANEL_WIDTH); + CelDraw(RIGHT_PANEL_X, 351 + SPANEL_Y, pInvCels, 1, SPANEL_WIDTH); if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 133, 59 + SPANEL_Y, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -157,18 +157,18 @@ void DrawInv() if (!plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { colour = ICOL_RED; } - CelBlitOutline(colour, RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutline(colour, RIGHT_PANEL_X + 133, 59 + SPANEL_Y, pCursCels, frame, frame_width); } if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { - CelClippedDraw(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDraw(RIGHT_PANEL_X + 133, 59 + SPANEL_Y, pCursCels, frame, frame_width); } else { - CelDrawLightRed(RIGHT_PANEL_X + 133, 59 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRed(RIGHT_PANEL_X + 133, 59 + SPANEL_Y, pCursCels, frame, frame_width, 1); } } if (plr[myplr].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 48, 205 + SPANEL_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -181,18 +181,18 @@ void DrawInv() if (!plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { colour = ICOL_RED; } - CelBlitOutline(colour, RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutline(colour, RIGHT_PANEL_X + 48, 205 + SPANEL_Y, pCursCels, frame, frame_width); } if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { - CelClippedDraw(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDraw(RIGHT_PANEL_X + 48, 205 + SPANEL_Y, pCursCels, frame, frame_width); } else { - CelDrawLightRed(RIGHT_PANEL_X + 48, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRed(RIGHT_PANEL_X + 48, 205 + SPANEL_Y, pCursCels, frame, frame_width, 1); } } if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 249, 205 + SPANEL_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -205,18 +205,18 @@ void DrawInv() if (!plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { colour = ICOL_RED; } - CelBlitOutline(colour, RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutline(colour, RIGHT_PANEL_X + 249, 205 + SPANEL_Y, pCursCels, frame, frame_width); } if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { - CelClippedDraw(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDraw(RIGHT_PANEL_X + 249, 205 + SPANEL_Y, pCursCels, frame, frame_width); } else { - CelDrawLightRed(RIGHT_PANEL_X + 249, 205 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRed(RIGHT_PANEL_X + 249, 205 + SPANEL_Y, pCursCels, frame, frame_width, 1); } } if (plr[myplr].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 205, 60 + SPANEL_Y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -229,24 +229,24 @@ void DrawInv() if (!plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { colour = ICOL_RED; } - CelBlitOutline(colour, RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutline(colour, RIGHT_PANEL_X + 205, 60 + SPANEL_Y, pCursCels, frame, frame_width); } if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { - CelClippedDraw(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDraw(RIGHT_PANEL_X + 205, 60 + SPANEL_Y, pCursCels, frame, frame_width); } else { - CelDrawLightRed(RIGHT_PANEL_X + 205, 60 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRed(RIGHT_PANEL_X + 205, 60 + SPANEL_Y, pCursCels, frame, frame_width, 1); } } if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 17, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 17, 160 + SPANEL_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; // calc item offsets for weapons smaller than 2x3 slots screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 31) : (RIGHT_PANEL_X + 17); - screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? (160 + SCREEN_Y) : (146 + SCREEN_Y); + screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? (160 + SPANEL_Y) : (146 + SPANEL_Y); if (pcursinvitem == INVITEM_HAND_LEFT) { colour = ICOL_WHITE; @@ -266,27 +266,27 @@ void DrawInv() } if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { - InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SPANEL_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); light_table_index = 0; cel_transparency_active = 1; CelClippedBlitLightTrans( frame_width == INV_SLOT_SIZE_PX - ? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)] - : &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)], + ? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SPANEL_Y)] + : &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SPANEL_Y)], pCursCels, frame, frame_width); cel_transparency_active = 0; } } if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SPANEL_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; // calc item offsets for weapons smaller than 2x3 slots screen_x = frame_width == INV_SLOT_SIZE_PX ? (RIGHT_PANEL_X + 261) : (RIGHT_PANEL_X + 249); - screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? (160 + SCREEN_Y) : (146 + SCREEN_Y); + screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? (160 + SPANEL_Y) : (146 + SPANEL_Y); if (pcursinvitem == INVITEM_HAND_RIGHT) { colour = ICOL_WHITE; @@ -307,7 +307,7 @@ void DrawInv() } if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE) { - InvDrawSlotBack(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); + InvDrawSlotBack(RIGHT_PANEL_X + 133, 160 + SPANEL_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX); frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + CURSOR_FIRSTITEM; frame_width = InvItemWidth[frame]; @@ -320,13 +320,13 @@ void DrawInv() if (!plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { colour = ICOL_RED; } - CelBlitOutline(colour, RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width); + CelBlitOutline(colour, RIGHT_PANEL_X + 133, 160 + SPANEL_Y, pCursCels, frame, frame_width); } if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { - CelClippedDraw(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width); + CelClippedDraw(RIGHT_PANEL_X + 133, 160 + SPANEL_Y, pCursCels, frame, frame_width); } else { - CelDrawLightRed(RIGHT_PANEL_X + 133, 160 + SCREEN_Y, pCursCels, frame, frame_width, 1); + CelDrawLightRed(RIGHT_PANEL_X + 133, 160 + SPANEL_Y, pCursCels, frame, frame_width, 1); } } diff --git a/Source/quests.cpp b/Source/quests.cpp index 1e93af29..fd665150 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -702,8 +702,8 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) int len, width, i, k, sx, sy; BYTE c; - sx = x + 96; - sy = y * 12 + 204; + sx = x + 96 + SPANEL_X - SCREEN_X; + sy = y * 12 + 204 + SPANEL_Y - SCREEN_Y; len = strlen(str); k = 0; if (cjustflag) { @@ -715,7 +715,7 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) sx += k; } if (qline == y) { - CelDraw(cjustflag ? x + k + 76 : x + 76, sy + 1, pSPentSpn2Cels, PentSpn2Frame, 12); + CelDraw((cjustflag ? x + k + 76 : x + 76) + SPANEL_X - SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Frame, 12); } for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; @@ -726,7 +726,7 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) sx += fontkern[c] + 1; } if (qline == y) { - CelDraw(cjustflag ? x + k + 100 : 340 - x, sy + 1, pSPentSpn2Cels, PentSpn2Frame, 12); + CelDraw((cjustflag ? x + k + 100 : 340 - x) + SPANEL_X - SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Frame, 12); } } @@ -734,8 +734,8 @@ void DrawQuestLog() { int y, i; + CelDraw(SPANEL_X, SPANEL_Y + 351, pQLogCel, 1, SPANEL_WIDTH); PrintQLString(0, 2, TRUE, "Quest Log", 3); - CelDraw(SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH); y = qtopline; for (i = 0; i < numqlines; i++) { PrintQLString(0, y, TRUE, questlist[qlist[i]]._qlstr, 0); diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 5ff42a45..e29ccf50 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -875,9 +875,15 @@ static void DrawGame(int x, int y) void DrawView(int StartX, int StartY) { DrawGame(StartX, StartY); +#ifndef __3DS__ if (automapflag) { DrawAutomap(); } +#else + + DrawAutomap(); + +#endif if (stextflag && !qtextflag) DrawSText(); if (invflag) { @@ -893,8 +899,12 @@ void DrawView(int StartX, int StartY) } else if (questlog) { DrawQuestLog(); } +#ifndef __3DS__ if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag && (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) { +#else + if (plr[myplr]._pStatPts != 0) { +#endif DrawLevelUpIcon(); } if (uitemflag) { @@ -930,9 +940,9 @@ void DrawView(int StartX, int StartY) } /** - * @brief Render the whole screen black + * @brief Render a portion of the screen black */ -void ClearScreenBuffer() +void ClearScreenBufferPortion(int x, int y, int w, int h) { lock_buf(3); @@ -941,15 +951,23 @@ void ClearScreenBuffer() int i; BYTE *dst; - dst = &gpBuffer[SCREENXY(0, 0)]; + dst = &gpBuffer[SCREENXY(x, y)]; - for (i = 0; i < SCREEN_HEIGHT; i++, dst += BUFFER_WIDTH) { - memset(dst, 0, SCREEN_WIDTH); + for (i = 0; i < h; i++, dst += BUFFER_WIDTH) { + memset(dst, 0, w); } unlock_buf(3); } +/** + * @brief Render the whole screen black + */ +void ClearScreenBuffer() +{ + ClearScreenBufferPortion(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); +} + #ifdef _DEBUG /** * @brief Scroll the screen when mouse is close to the edge diff --git a/Source/scrollrt.h b/Source/scrollrt.h index e3fd649c..448f0a7e 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -16,6 +16,7 @@ void ClearCursor(); void DrawMissile(int x, int y, int sx, int sy, BOOL pre); void DrawDeadPlayer(int x, int y, int sx, int sy); void DrawView(int StartX, int StartY); +void ClearScreenBufferPortion(int x, int y, int w, int h); void ClearScreenBuffer(); #ifdef _DEBUG void ScrollView(); diff --git a/SourceX/controls/game_controls.cpp b/SourceX/controls/game_controls.cpp index 8ca22d4d..54e8ed18 100644 --- a/SourceX/controls/game_controls.cpp +++ b/SourceX/controls/game_controls.cpp @@ -22,10 +22,9 @@ DWORD translate_controller_button_to_key(ControllerButton controller_button) return sgpCurrentMenu || stextflag || questlog ? DVL_VK_RETURN : DVL_VK_SPACE; case ControllerButton::BUTTON_Y: // Top button return DVL_VK_RETURN; +#ifndef ALTERNATIVE_CONTROLS case ControllerButton::BUTTON_LEFTSTICK: return DVL_VK_TAB; // Map - case ControllerButton::BUTTON_START: - return DVL_VK_ESCAPE; case ControllerButton::BUTTON_BACK: return 'Q'; // Quest log case ControllerButton::BUTTON_DPAD_LEFT: @@ -36,6 +35,15 @@ DWORD translate_controller_button_to_key(ControllerButton controller_button) return DVL_VK_UP; case ControllerButton::BUTTON_DPAD_DOWN: return DVL_VK_DOWN; +#else + case ControllerButton::BUTTON_DPAD_UP: + if (!(invflag || questlog || sbookflag || chrflag || spselflag)) + return 'Q'; // Quest log + return 0; + case ControllerButton::BUTTON_BACK: +#endif + case ControllerButton::BUTTON_START: + return DVL_VK_ESCAPE; default: return 0; } @@ -49,6 +57,7 @@ bool GetGameAction(const SDL_Event &event, GameAction *action) switch (ctrl_event.button) { case ControllerButton::IGNORE: return true; +#ifndef ALTERNATIVE_CONTROLS case ControllerButton::AXIS_TRIGGERLEFT: // ZL (aka L2) if (!ctrl_event.up) *action = GameAction(GameActionType::USE_HEALTH_POTION); @@ -100,6 +109,86 @@ bool GetGameAction(const SDL_Event &event, GameAction *action) case ControllerButton::BUTTON_RIGHTSTICK: *action = GameActionSendMouseClick { GameActionSendMouseClick::LEFT, ctrl_event.up }; return true; +#else + case ControllerButton::AXIS_TRIGGERLEFT: // ZL (aka L2) + if (!ctrl_event.up) + *action = GameAction(GameActionType::USE_HEALTH_POTION); + return true; + case ControllerButton::AXIS_TRIGGERRIGHT: // ZR (aka R2) + if (!ctrl_event.up) + *action = GameAction(GameActionType::USE_MANA_POTION); + return true; + case ControllerButton::BUTTON_B: // Right button + if (InGameMenu()) + break; // Map to keyboard key + if (!ctrl_event.up) + *action = GameAction(GameActionType::PRIMARY_ACTION); + return true; + case ControllerButton::BUTTON_Y: // Top button + if (InGameMenu()) + break; // Map to keyboard key + if (!ctrl_event.up) + *action = GameAction(GameActionType::SECONDARY_ACTION); + return true; + case ControllerButton::BUTTON_X: // Left button + if (InGameMenu()) + break; // Map to keyboard key + if (!ctrl_event.up) + *action = GameAction(GameActionType::CAST_SPELL); + return true; + case ControllerButton::BUTTON_A: // Bottom button + if (InGameMenu()) + break; // Map to keyboard key + if (questlog) + return true; + if (invflag) + *action = GameAction(GameActionType::TOGGLE_INVENTORY); + else if (sbookflag) + *action = GameAction(GameActionType::TOGGLE_SPELL_BOOK); + else if (chrflag) + *action = GameAction(GameActionType::TOGGLE_CHARACTER_INFO); + else if (!ctrl_event.up) + *action = GameAction(GameActionType::TOGGLE_QUICK_SPELL_MENU); + return true; + case ControllerButton::BUTTON_LEFTSHOULDER: + if (!ctrl_event.up) + *action = GameAction(GameActionType::USE_HEALTH_POTION); + return true; + case ControllerButton::BUTTON_RIGHTSHOULDER: + if (!ctrl_event.up) + *action = GameAction(GameActionType::USE_MANA_POTION); + return true; + case ControllerButton::BUTTON_DPAD_UP: + if (InGameMenu()) + break; // Map to keyboard key + if (invflag || questlog || sbookflag || chrflag || spselflag) + return true; + break; + case ControllerButton::BUTTON_DPAD_DOWN: + if (InGameMenu()) + break; // Map to keyboard key + if (invflag || questlog || sbookflag || chrflag || spselflag) + return true; + if (!stextflag || !ctrl_event.up) + *action = GameAction(GameActionType::TOGGLE_SPELL_BOOK); + return true; + case ControllerButton::BUTTON_DPAD_LEFT: + if (InGameMenu()) + break; // Map to keyboard key + if (invflag || questlog || sbookflag || chrflag || spselflag) + return true; + if (!stextflag || !ctrl_event.up) + *action = GameAction(GameActionType::TOGGLE_CHARACTER_INFO); + return true; + case ControllerButton::BUTTON_DPAD_RIGHT: + if (InGameMenu()) + break; // Map to keyboard key + if (invflag || questlog || sbookflag || chrflag || spselflag) + return true; + if (!stextflag || !ctrl_event.up) + *action = GameAction(GameActionType::TOGGLE_INVENTORY); + return true; +#endif default: break; } diff --git a/SourceX/controls/game_controls.h b/SourceX/controls/game_controls.h index bcad974f..3aca189d 100644 --- a/SourceX/controls/game_controls.h +++ b/SourceX/controls/game_controls.h @@ -16,6 +16,7 @@ enum class GameActionType { TOGGLE_QUICK_SPELL_MENU, SEND_KEY, SEND_MOUSE_CLICK, + TOGGLE_SPELL_BOOK, }; struct GameActionSendKey { diff --git a/SourceX/controls/plrctrls.cpp b/SourceX/controls/plrctrls.cpp index 58101d21..c0eaea01 100644 --- a/SourceX/controls/plrctrls.cpp +++ b/SourceX/controls/plrctrls.cpp @@ -549,6 +549,76 @@ void HotSpellMove(MoveDirection dir) } } +void SpellBookMove(MoveDirection dir) +{ + int x = 0; + int y = 0; + + DWORD ticks = GetTickCount(); + if (ticks - invmove < repeatRate) { + return; + } + invmove = ticks; + + for (int r = 0; r < speedspellcount; r++) { // speedbook cells are 56x56 + // our 3 rows by y axis + if (speedspellscoords[r].y == 307) + hsr[0]++; + if (speedspellscoords[r].y == 251) + hsr[1]++; + if (speedspellscoords[r].y == 195) + hsr[2]++; + if (MouseX >= speedspellscoords[r].x - 28 && MouseX < speedspellscoords[r].x + (28) && MouseY >= speedspellscoords[r].y - (28) && MouseY < speedspellscoords[r].y + 28) { + spbslot = r; + //sprintf(tempstr, "IN HOT SPELL CELL NUM:%i", r); + //NetSendCmdString(1 << myplr, tempstr); + } + } + + if (dir.y == MoveDirectionY::UP) { + if (speedspellscoords[spbslot].y == 307 && hsr[1] > 0) { // we're in row 1, check if row 2 has spells + if (HSExists(MouseX, 251)) { + x = MouseX; + y = 251; + } + } else if (speedspellscoords[spbslot].y == 251 && hsr[2] > 0) { // we're in row 2, check if row 3 has spells + if (HSExists(MouseX, 195)) { + x = MouseX; + y = 195; + } + } + } else if (dir.y == MoveDirectionY::DOWN) { + if (speedspellscoords[spbslot].y == 251) { // we're in row 2 + if (HSExists(MouseX, 307)) { + x = MouseX; + y = 307; + } + } else if (speedspellscoords[spbslot].y == 195) { // we're in row 3 + if (HSExists(MouseX, 251)) { + x = MouseX; + y = 251; + } + } + } + if (dir.x == MoveDirectionX::LEFT) { + if (spbslot >= speedspellcount - 1) + return; + spbslot++; + x = speedspellscoords[spbslot].x; + y = speedspellscoords[spbslot].y; + } else if (dir.x == MoveDirectionX::RIGHT) { + if (spbslot <= 0) + return; + spbslot--; + x = speedspellscoords[spbslot].x; + y = speedspellscoords[spbslot].y; + } + + if (x > 0 && y > 0) { + SetCursorPos(x, y); + } +} + static const _walk_path kMoveToWalkDir[3][3] = { // NONE UP DOWN { WALK_NONE, WALK_N, WALK_S }, // NONE @@ -592,6 +662,8 @@ void Movement() AttrIncBtnSnap(move_dir.y); } else if (spselflag) { HotSpellMove(move_dir); + } else if (sbookflag) { + SpellBookMove(move_dir); } else { WalkInDir(move_dir); } diff --git a/SourceX/main.cpp b/SourceX/main.cpp index d53d776f..6258cb8d 100644 --- a/SourceX/main.cpp +++ b/SourceX/main.cpp @@ -34,8 +34,6 @@ int main(int argc, char **argv) #if defined(__3DS__) bool isN3DS; - APT_CheckNew3DS(&isN3DS); - if(isN3DS) osSetSpeedupEnable(true); romfsInit(); diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index f47e565a..2f2f37a2 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -121,7 +121,7 @@ WINBOOL DeleteFileA(LPCSTR lpFileName) bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) { #if defined(__3DS__) - if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO) <= -1) { + if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) <= -1) { #else if (SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) <= -1) { #endif @@ -145,8 +145,10 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) #ifdef USE_SDL1 int flags = SDL1_VIDEO_MODE_FLAGS | SDL_HWPALETTE; +#ifndef __3DS__ if (fullscreen) flags |= SDL_FULLSCREEN; +#endif SDL_WM_SetCaption(lpWindowName, WINDOW_ICON_NAME); #ifndef RETROFW SDL_SetVideoMode(nWidth, nHeight, SDL1_VIDEO_MODE_BPP, flags); diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index 47214577..381bd045 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -241,6 +241,7 @@ static int translate_sdl_key(SDL_Keysym key) } } + namespace { WPARAM keystate_for_mouse(WPARAM ret) @@ -437,7 +438,7 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter questlog = false; spselflag = false; FocusOnCharInfo(); - } + } break; case GameActionType::TOGGLE_INVENTORY: invflag = !invflag; @@ -449,6 +450,15 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter BlurInventory(); } break; + case GameActionType::TOGGLE_SPELL_BOOK: + sbookflag = !sbookflag; + if (sbookflag) { + invflag = false; + spselflag = false; + BlurInventory(); + //FocusOnSpellBook(); + } + break; case GameActionType::SEND_KEY: lpMsg->message = action.send_key.up ? DVL_WM_KEYUP : DVL_WM_KEYDOWN; lpMsg->wParam = action.send_key.vk_code; diff --git a/defs.h b/defs.h index 03fcadee..31141b31 100644 --- a/defs.h +++ b/defs.h @@ -91,8 +91,8 @@ #define PAL16_RED 224 #define PAL16_GRAY 240 -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 960 #define ZOOM_WIDTH 384 #define ZOOM_HEIGHT 224 @@ -120,22 +120,24 @@ #define PANEL_WIDTH 640 #define PANEL_HEIGHT 128 -#define PANEL_TOP (SCREEN_HEIGHT - PANEL_HEIGHT) +#define PANEL_TOP SCREEN_HEIGHT - PANEL_HEIGHT #define PANEL_LEFT (SCREEN_WIDTH - PANEL_WIDTH) / 2 #define PANEL_X (SCREEN_X + PANEL_LEFT) #define PANEL_Y (SCREEN_Y + PANEL_TOP) -#define SPANEL_WIDTH 320 -#define SPANEL_HEIGHT 352 -#define PANELS_COVER (SCREEN_WIDTH <= PANEL_WIDTH && SCREEN_HEIGHT <= SPANEL_HEIGHT + PANEL_HEIGHT) +#define SPANEL_WIDTH 320 +#define SPANEL_HEIGHT 352 +#define SPANEL_Y SCREEN_Y + 480 +#define SPANEL_X PANEL_X +#define PANELS_COVER FALSE -#define RIGHT_PANEL (SCREEN_WIDTH - SPANEL_WIDTH) -#define RIGHT_PANEL_X (SCREEN_X + RIGHT_PANEL) +#define RIGHT_PANEL (PANEL_WIDTH - SPANEL_WIDTH) +#define RIGHT_PANEL_X (SPANEL_X + RIGHT_PANEL) #if SCREEN_WIDTH <= PANEL_WIDTH -#define VIEWPORT_HEIGHT (SCREEN_HEIGHT - PANEL_HEIGHT) +#define VIEWPORT_HEIGHT (SCREEN_HEIGHT / 2) #else -#define VIEWPORT_HEIGHT SCREEN_HEIGHT +#define VIEWPORT_HEIGHT (SCREEN_HEIGHT / 2) #endif #define DIALOG_TOP ((SCREEN_HEIGHT - PANEL_HEIGHT) / 2 - 18)