From e9d4219d7b691e01df9f50b128f6de56fa82d57a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 22 Aug 2015 13:36:42 -0700 Subject: [PATCH 1/3] GBA Video: Start on the scanline BIOS finishes on if no BIOS is loaded --- CHANGES | 1 + src/gba/video.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 20b1f3885..f1f42f4a3 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Bugfixes: - Qt: Fix install path of XDG desktop file with DESTDIR - Qt: Fix drag and drop on Windows - Qt: Reenable double buffering, as disabling it broke some Windows configs + - GBA Video: Start on the scanline BIOS finishes on if no BIOS is loaded Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/gba/video.c b/src/gba/video.c index fef6e1b54..c70e47a38 100644 --- a/src/gba/video.c +++ b/src/gba/video.c @@ -62,7 +62,13 @@ void GBAVideoInit(struct GBAVideo* video) { } void GBAVideoReset(struct GBAVideo* video) { - video->vcount = VIDEO_VERTICAL_TOTAL_PIXELS - 1; + if (video->p->memory.fullBios) { + video->vcount = 0; + } else { + // TODO: Verify exact scanline hardware + video->vcount = 0x7E; + } + video->p->memory.io[REG_VCOUNT >> 1] = video->vcount; video->lastHblank = 0; video->nextHblank = VIDEO_HDRAW_LENGTH; From 6ea0db2ccd53cdf677d71050f6c6514e4b97e510 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 22 Aug 2015 23:20:21 -0700 Subject: [PATCH 2/3] GUI: Upstream cross-platform GUI code --- CMakeLists.txt | 1 + res/font.png | Bin 0 -> 5383 bytes src/util/gui.h | 35 ++++++++++ src/util/gui/file-select.c | 128 +++++++++++++++++++++++++++++++++++++ src/util/gui/file-select.h | 13 ++++ src/util/gui/font.h | 25 ++++++++ 6 files changed, 202 insertions(+) create mode 100644 res/font.png create mode 100644 src/util/gui.h create mode 100644 src/util/gui/file-select.c create mode 100644 src/util/gui/file-select.h create mode 100644 src/util/gui/font.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f97de096..9197ebc7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c) file(GLOB GBA_CHEATS_SRC ${CMAKE_SOURCE_DIR}/src/gba/cheats/*.c) file(GLOB GBA_RR_SRC ${CMAKE_SOURCE_DIR}/src/gba/rr/*.c) file(GLOB GBA_SV_SRC ${CMAKE_SOURCE_DIR}/src/gba/supervisor/*.c) +file(GLOB GUI_SRC ${CMAKE_SOURCE_DIR}/src/gui/*.c) file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cSs]) file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/*.c) file(GLOB SIO_SRC ${CMAKE_SOURCE_DIR}/src/gba/sio/lockstep.c) diff --git a/res/font.png b/res/font.png new file mode 100644 index 0000000000000000000000000000000000000000..73b9893c564395a0318693a381cdc5ee3dba44a5 GIT binary patch literal 5383 zcmeHJQC;7 z&{M|R+HR0t*F^aLmfYM-;cy5_(EE`w!dAG5cDn*kiZ31R}ERVSxah%x$>d`BtE0tXR+ z)9RD_M2i4H4JZU8C=~$;YB-48Ol~6}9}ln@u(w+S^aTJLo{-H60Fir{6^H|vr?S!D z5IXL`)h%A6w?bt;2=y4Ur7T=vxSv9g~PASz;a{>V`u!)HvGw-k_?PF>QTU^_0 z1;KXzEIN@;G4kb;K>)~4rn#H;kSeT6%;GKEmzh6W0NrvlVgv>x($Y8ghjnK>qfe$%*HGwNWidLeI`_tgp{J?NlMC1#5jMDo@U0mb0&sUfDu^{;+ap3CC1~^#TBn8$8;6@e+U#&fzN~zPE?aYxR6C0O6?l-U|S%R5%4;{k6~@0sv6S59Rx+ z$Z*>BkiQk5vF+Y`8}XHmM1&G&XS))G647%6qqohYiZCVKsG+Y+d^V6@3QS_H2F_6_ zo@9dU#y`pAJj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Y5j)4%|Jue{gdlw>$!v3mUzUIr%T1 zeZKl>Cm}Wyx;dozNnTGr+#e}8xGmtpim*^<%`igUsp%&1_cV= zM3gnX1NkN1>z`j>Evi1+mWamCzXa$J=V0m^;5@+Cc}d1Ke%1T5aTrRlRmj3K1xlKr z^6&K!`j*NS(yA|;kWt#?zPo?qGH~Oc6S8aTuFTsq#6rmUl^5L)%hWd zh?77$w!OIlA~K)|udVkp?PeJ2sKK{^S#LddZh-B-_j=CuBsuSgDPAbfa(b;#48UiW z+N-Nr6!rofHtl9M<>kIRxQ!J1KQ%Opvk|fK*E|sBl+aeL^%L!~QutbM$V#18@Ah(U zzH5BW<3uPvMC!@qy zQ2Q2Ec2u{LBzyyWW7OW%|704(g;RDke_z77wP+|(Iy|=}VyzCEU)grI!G4X<<*Fv@ zE^K9xM}H5raZWxHz_R}_k{^JK#*SJBw!~hTV;57$y2oSBx%nv>v4YZWlei!CY{c65 zPkN|!hZ!Vey zmR=h%Kxoa*LtrVA+vhk5$jm@^_g}dS+M^VXh}=>~>nwC_FyG6LY}`&QoskHM;Fj!; zH4S=1khkBIIr=t%@amNKRVL9#eae=W!%;<3j1!zRpcaCzB5j}IB( za_a7?WXXM-;L+z-`>%Wmaw$uMlo!EUABPO68vQ0a~x> zu8C=ILt_F)SoE=YyT{e*VE*j25U*f`!M0qM(Qf^JpF`q5;47$J4FGv*J2CI=~>WKOpmeS6s7I=*aTDmp*Sa;RRtD~!B>YTAa}k% zALaWM&9}b22>)P2`LwJKu97!oyCWD{{XA=OmmI&i;?K=TlKMV)%at5}m4i};u|eC< uJg_GpImDJ&BJzI{cwj+u^lvZEMgR}IEL%*Z`JKZA08Le0l`18hu>S!2ey`yG literal 0 HcmV?d00001 diff --git a/src/util/gui.h b/src/util/gui.h new file mode 100644 index 000000000..d8b2bb058 --- /dev/null +++ b/src/util/gui.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GUI_H +#define GUI_H + +#include "util/common.h" + +struct GUIFont; + +enum GUIInput { + GUI_INPUT_NONE = -1, + GUI_INPUT_SELECT = 0, + GUI_INPUT_BACK, + GUI_INPUT_CANCEL, + + GUI_INPUT_UP, + GUI_INPUT_DOWN, + GUI_INPUT_LEFT, + GUI_INPUT_RIGHT, +}; + +struct GUIParams { + int width; + int height; + const struct GUIFont* font; + + void (*drawStart)(void); + void (*drawEnd)(void); + int (*pollInput)(void); +}; + +#endif diff --git a/src/util/gui/file-select.c b/src/util/gui/file-select.c new file mode 100644 index 000000000..05a0fbb67 --- /dev/null +++ b/src/util/gui/file-select.c @@ -0,0 +1,128 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "file-select.h" + +#include "util/gui/font.h" +#include "util/vector.h" +#include "util/vfs.h" + +DECLARE_VECTOR(FileList, char*); +DEFINE_VECTOR(FileList, char*); + +void _cleanFiles(struct FileList* currentFiles) { + size_t size = FileListSize(currentFiles); + size_t i; + for (i = 0; i < size; ++i) { + free(*FileListGetPointer(currentFiles, i)); + } + FileListClear(currentFiles); +} + +void _upDirectory(char* currentPath) { + char* end = strrchr(currentPath, '/'); + if (!end) { + return; + } + end[0] = '\0'; + if (end[1]) { + return; + } + // TODO: What if there was a trailing slash? +} + +bool _refreshDirectory(const char* currentPath, struct FileList* currentFiles) { + _cleanFiles(currentFiles); + + struct VDir* dir = VDirOpen(currentPath); + if (!dir) { + return false; + } + struct VDirEntry* de; + while ((de = dir->listNext(dir))) { + if (de->name(de)[0] == '.') { + continue; + } + *FileListAppend(currentFiles) = strdup(de->name(de)); + } + dir->close(dir); + return true; +} + +bool selectFile(const struct GUIParams* params, const char* basePath, char* outPath, size_t outLen, const char* suffix) { + char currentPath[256]; + strncpy(currentPath, basePath, sizeof(currentPath)); + int oldInput = -1; + size_t fileIndex = 0; + size_t start = 0; + + struct FileList currentFiles; + FileListInit(¤tFiles, 0); + _refreshDirectory(currentPath, ¤tFiles); + + while (true) { + int input = params->pollInput(); + int newInput = input & (oldInput ^ input); + oldInput = input; + + if (newInput & (1 << GUI_INPUT_UP) && fileIndex > 0) { + --fileIndex; + } + if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) { + ++fileIndex; + } + if (fileIndex < start) { + start = fileIndex; + } + while ((fileIndex - start + 4) * GUIFontHeight(params->font) > params->height) { + ++start; + } + if (newInput & (1 << GUI_INPUT_CANCEL)) { + _cleanFiles(¤tFiles); + FileListDeinit(¤tFiles); + return false; + } + if (newInput & (1 << GUI_INPUT_SELECT)) { + snprintf(currentPath, sizeof(currentPath), "%s%c%s", currentPath, '/', *FileListGetPointer(¤tFiles, fileIndex)); + if (!_refreshDirectory(currentPath, ¤tFiles)) { + strncpy(outPath, currentPath, outLen); + return true; + } + fileIndex = 0; + } + if (newInput & (1 << GUI_INPUT_BACK)) { + if (strncmp(currentPath, basePath, sizeof(currentPath)) == 0) { + _cleanFiles(¤tFiles); + FileListDeinit(¤tFiles); + return false; + } + _upDirectory(currentPath); + _refreshDirectory(currentPath, ¤tFiles); + fileIndex = 0; + } + + params->drawStart(); + int y = GUIFontHeight(params->font); + GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, 0xFFFFFFFF, "Current directory: %s", currentPath); + y += 2 * GUIFontHeight(params->font); + size_t i; + for (i = start; i < FileListSize(¤tFiles); ++i) { + int color = 0xE0A0A0A0; + char bullet = ' '; + if (i == fileIndex) { + color = 0xFFFFFFFF; + bullet = '>'; + } + GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, color, "%c %s", bullet, *FileListGetPointer(¤tFiles, i)); + y += GUIFontHeight(params->font); + if (y + GUIFontHeight(params->font) > params->height) { + break; + } + } + y += GUIFontHeight(params->font) * 2; + + params->drawEnd(); + } +} diff --git a/src/util/gui/file-select.h b/src/util/gui/file-select.h new file mode 100644 index 000000000..c96f821c0 --- /dev/null +++ b/src/util/gui/file-select.h @@ -0,0 +1,13 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GUI_FILE_CHOOSER_H +#define GUI_FILE_CHOOSER_H + +#include "util/gui.h" + +bool selectFile(const struct GUIParams*, const char* basePath, char* outPath, size_t outLen, const char* suffix); + +#endif diff --git a/src/util/gui/font.h b/src/util/gui/font.h new file mode 100644 index 000000000..4120814c2 --- /dev/null +++ b/src/util/gui/font.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GUI_FONT_H +#define GUI_FONT_H + +#include "util/common.h" + +struct GUIFont; +struct GUIFont* GUIFontCreate(void); +void GUIFontDestroy(struct GUIFont*); + +enum GUITextAlignment { + GUI_TEXT_LEFT = 0, + GUI_TEXT_CENTER, + GUI_TEXT_RIGHT +}; + +int GUIFontHeight(const struct GUIFont*); + +void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUITextAlignment, uint32_t color, const char* text, ...); + +#endif From d8caa280b137a6f2a1f9acd29fce447a33228296 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 23 Aug 2015 00:57:22 -0700 Subject: [PATCH 3/3] GUI: Add lowercase and font metrics --- res/font.png | Bin 5383 -> 5639 bytes src/util/gui/font-metrics.c | 137 ++++++++++++++++++++++++++++++++++++ src/util/gui/font-metrics.h | 13 ++++ src/util/gui/font.h | 11 +++ 4 files changed, 161 insertions(+) create mode 100644 src/util/gui/font-metrics.c create mode 100644 src/util/gui/font-metrics.h diff --git a/res/font.png b/res/font.png index 73b9893c564395a0318693a381cdc5ee3dba44a5..70adb6bd1e3613db5471e72ebda85ed78020b917 100644 GIT binary patch delta 2117 zcmV-L2)g%&Du*nv+6{jQ7fD1xRCwC#Tv?LbFbD<4_dhb^!%K??LUOx1snp0-(}}Fb z(i0#yn}vS&_1o9K09XJl02TlXfCaz;U;(fISO6>l761!?1;7Ge0k8mA04x9&01JQx zzye?aumD&9EC3b&3xEZ{Z@9LPjH3T9nA^mXl!)Z`b=9vj8?k>imD2uuG#40NsC#2j z{i!{ZiUOF3?E1f5zpq=bvNACdtDGfLA=0aXGSPmo?eC_;UT{^##}TL@k=67x4y^&kK(QE^M^ zj-Hmqd?k^mkmr9Ka87TV*%47cMc)5_jO}d9Oh$hFVfXD00gD&1>P5{np}YoFP)W|IuiqW~+n$ov^_>`2%#vS!mnAFO|0LQ&(fDy3x8-ijo}hwJI= z>lcwJ`PcGoK~@@0p<9OV#LgmQ2NIn9*YSTe(Fs4 zNoK`02b`qLO$WA1B9QH{vR&}9b$F$HWLs;atzq_5YFy*xm()ItKcZm%b6Y^)emJje z@ddyFU^#z8q7c(qM0-7!o%Nq+??Q9+nNUS37o}cp8c0uQZ;jgVQq{pc$NJD7R6_=Z z6x)yL#Y21ZI>8&`m)d8bFi|&_8-Htb zb+7HCX`moGv_xM*8K$M+0;$F)5+Hdjd+i%33=w~@X8i3M!MOW$BGT5tHxI|Pe(n3L zG@%M9Yy}+xT8w6iN1-*$+VM96ZFRzDB?pfn=G?kOP)7LnZpLSO6JLId{yQg|rvatQ z<+q*d7ae&d1a>p1KG9u|8q`of$0zn2OJR-mX8X52cT`&KqOxyP(o_^ZCq;RWu(3Q4?2T!M$5nyUL z&t|j9c=|zm35pL4)*>KxTzo(Ll3oEpMnKs~Ou>_%DX)+14g3kC_813<9t*aNmSO6@4z`!4%QLjqv`(TYpUe15|`}~7+KEAuCe}DunQJee*h^0*V1DfJ- zymak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pWc=+^)bwngmLH(;dSZTnMfiF70hBx8{@(n6ZK@xX`TnUrR>=TMbGQ8q z6#{{Yde0wF`vmLqujB_Tn&W?Qen8B@ogdJ~Py^5aGysqA2mD@sK=^@!_mqMk%@1JA z!vqMh7`OY`{D3@Iy8eG9s^85IxN~vfVlV*wR(`7$k^8*&5#bn+9ni|_D z7mJ7Zaxdw_em}2dnbqqL2B)m~{+~Mxy2)6-{5=5sJwFtJ xAwR" + { 10, 11, { 2, 3, 3, 3 }}, // 0x3F "?" + { 10, 11, { 2, 3, 3, 3 }}, // 0x40 "@" + { 10, 11, { 2, 3, 3, 3 }}, // 0x41 "A" + { 10, 11, { 2, 3, 3, 3 }}, // 0x42 "B" + { 10, 11, { 2, 3, 3, 3 }}, // 0x43 "C" + { 10, 11, { 2, 3, 3, 3 }}, // 0x44 "D" + { 10, 11, { 2, 3, 3, 3 }}, // 0x45 "E" + { 10, 11, { 2, 3, 3, 3 }}, // 0x46 "F" + { 10, 11, { 2, 3, 3, 3 }}, // 0x47 "G" + { 10, 11, { 2, 3, 3, 3 }}, // 0x48 "H" + { 6, 11, { 2, 5, 3, 5 }}, // 0x49 "I" + { 7, 11, { 2, 5, 3, 4 }}, // 0x4A "J" + { 9, 11, { 2, 3, 3, 4 }}, // 0x4B "K" + { 8, 11, { 2, 4, 3, 4 }}, // 0x4C "L" + { 11, 11, { 2, 3, 3, 2 }}, // 0x4D "M" + { 10, 11, { 2, 3, 3, 3 }}, // 0x4E "N" + { 10, 11, { 2, 3, 3, 3 }}, // 0x4F "O" + { 10, 11, { 2, 3, 3, 3 }}, // 0x50 "P" + { 10, 11, { 2, 3, 3, 3 }}, // 0x51 "Q" + { 10, 11, { 2, 3, 3, 3 }}, // 0x52 "R" + { 10, 11, { 2, 3, 3, 3 }}, // 0x53 "S" + { 10, 11, { 2, 3, 3, 3 }}, // 0x54 "T" + { 10, 11, { 2, 3, 3, 3 }}, // 0x55 "U" + { 10, 11, { 2, 3, 3, 3 }}, // 0x56 "V" + { 11, 11, { 2, 3, 3, 2 }}, // 0x57 "W" + { 10, 11, { 2, 3, 3, 3 }}, // 0x58 "X" + { 10, 11, { 2, 3, 3, 3 }}, // 0x59 "Y" + { 10, 11, { 2, 3, 3, 3 }}, // 0x5A "Z" + { 6, 11, { 2, 5, 3, 5 }}, // 0x5B "[" + { 8, 11, { 2, 4, 3, 4 }}, // 0x5C "\" + { 6, 11, { 2, 5, 3, 5 }}, // 0x5D "]" + { 8, 7, { 2, 4, 7, 4 }}, // 0x5E "^" + { 10, 3, { 10, 3, 3, 3 }}, // 0x5F "_" + { 6, 5, { 8, 6, 3, 4 }}, // 0x60 "`" + { 8, 7, { 6, 4, 3, 4 }}, // 0x61 "a" + { 8, 11, { 2, 4, 3, 4 }}, // 0x62 "b" + { 8, 7, { 6, 4, 3, 4 }}, // 0x63 "c" + { 8, 11, { 2, 4, 3, 4 }}, // 0x64 "d" + { 8, 7, { 6, 4, 3, 4 }}, // 0x65 "e" + { 7, 11, { 2, 5, 3, 4 }}, // 0x66 "f" + { 8, 9, { 6, 4, 1, 4 }}, // 0x67 "g" + { 8, 11, { 2, 4, 3, 4 }}, // 0x68 "h" + { 6, 11, { 2, 5, 3, 5 }}, // 0x69 "i" + { 7, 13, { 2, 5, 1, 4 }}, // 0x6A "j" + { 8, 11, { 2, 4, 3, 4 }}, // 0x6B "k" + { 5, 11, { 2, 5, 3, 6 }}, // 0x6C "l" + { 10, 7, { 6, 2, 3, 2 }}, // 0x6D "m" + { 8, 7, { 6, 4, 3, 4 }}, // 0x6E "n" + { 8, 7, { 6, 4, 3, 4 }}, // 0x6F "o" + { 8, 9, { 6, 4, 1, 4 }}, // 0x70 "p" + { 8, 9, { 6, 4, 1, 4 }}, // 0x71 "q" + { 8, 7, { 6, 4, 3, 4 }}, // 0x72 "r" + { 8, 7, { 6, 4, 3, 4 }}, // 0x73 "s" + { 8, 9, { 4, 4, 3, 4 }}, // 0x74 "t" + { 8, 7, { 6, 4, 3, 4 }}, // 0x75 "u" + { 8, 7, { 6, 4, 3, 4 }}, // 0x76 "v" + { 9, 7, { 6, 4, 3, 3 }}, // 0x77 "w" + { 8, 7, { 6, 4, 3, 4 }}, // 0x78 "x" + { 8, 9, { 6, 4, 1, 4 }}, // 0x79 "y" + { 8, 7, { 6, 4, 3, 4 }}, // 0x7A "z" + { 7, 11, { 2, 5, 3, 4 }}, // 0x7B "{" + { 4, 11, { 2, 6, 3, 6 }}, // 0x7C "|" + { 7, 11, { 2, 4, 3, 5 }}, // 0x7D "}" + { 10, 5, { 5, 3, 6, 3 }}, // 0x7E "}" + { 0, 0, { 0, 0, 0, 0 }}, // 0x7F +}; diff --git a/src/util/gui/font-metrics.h b/src/util/gui/font-metrics.h new file mode 100644 index 000000000..6ea1542a5 --- /dev/null +++ b/src/util/gui/font-metrics.h @@ -0,0 +1,13 @@ +/* Copyright (c) 2013-2015 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef DEFAULT_FONT_METRICS_H +#define DEFAULT_FONT_METRICS_H + +#include "util/gui/font.h" + +extern struct GUIFontGlyphMetric defaultFontMetrics[]; + +#endif diff --git a/src/util/gui/font.h b/src/util/gui/font.h index 4120814c2..3679687fe 100644 --- a/src/util/gui/font.h +++ b/src/util/gui/font.h @@ -18,6 +18,17 @@ enum GUITextAlignment { GUI_TEXT_RIGHT }; +struct GUIFontGlyphMetric { + int width; + int height; + struct { + int top; + int right; + int bottom; + int left; + } padding; +}; + int GUIFontHeight(const struct GUIFont*); void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUITextAlignment, uint32_t color, const char* text, ...);