diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b diff --git a/annotated.html b/annotated.html new file mode 100644 index 00000000..bf6932bd --- /dev/null +++ b/annotated.html @@ -0,0 +1,111 @@ + + + + + + + +maug: Data Structures + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Data Structures
+
+
+
Here are the data structures with brief descriptions:
+ + + + + + + + + + + + + + + + + + + + + + + + + +
 CMAUG_FMT_SPEC
 CMTILEMAP
 CMTILEMAP_CPROPCustom property key-value storage type
 CMTILEMAP_CPROP_VALData store for MTILEMAP_CPROP::value
 CMTILEMAP_LAYER
 CMTILEMAP_PARSER
 CMTILEMAP_TILE_DEF
 CRETROCON
 CRETROFLAT_ARGSStruct containing configuration values for a RetroFlat program
 CRETROFLAT_BITMAPPlatform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine if a valid bitmap is loaded
 CRETROFLAT_INPUTStruct passed to retroflat_poll_input() to hold return data
 CRETROFLAT_STATEGlobal singleton containing state for the current platform
 CRETROGLU_FACE
 CRETROGLU_MATERIAL
 CRETROGLU_OBJ
 CRETROGLU_PARSERAs retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information
 CRETROGLU_PROJ_ARGS
 CRETROGLU_SPRITE
 CRETROGLU_TILE
 CRETROGLU_VERTEX
 CRETROGLU_VTEXTURE
 CRETROGUI
 CRETROGUI_CTL
 CRETROGUI_CTL_BASEFields common to ALL RETROGUI_CTL types
+
+
+ + + + diff --git a/bc_s.png b/bc_s.png new file mode 100644 index 00000000..224b29aa Binary files /dev/null and b/bc_s.png differ diff --git a/bc_sd.png b/bc_sd.png new file mode 100644 index 00000000..31ca888d Binary files /dev/null and b/bc_sd.png differ diff --git a/classes.html b/classes.html new file mode 100644 index 00000000..b77c9645 --- /dev/null +++ b/classes.html @@ -0,0 +1,92 @@ + + + + + + + +maug: Data Structure Index + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Data Structure Index
+
+
+
M | R
+
+
+
M
+
MAUG_FMT_SPEC
MTILEMAP
MTILEMAP_CPROP
MTILEMAP_CPROP_VAL
MTILEMAP_LAYER
MTILEMAP_PARSER
MTILEMAP_TILE_DEF
+
+
R
+
RETROCON
RETROFLAT_ARGS
RETROFLAT_BITMAP
RETROFLAT_INPUT
RETROFLAT_STATE
RETROGLU_FACE
RETROGLU_MATERIAL
RETROGLU_OBJ
RETROGLU_PARSER
RETROGLU_PROJ_ARGS
RETROGLU_SPRITE
RETROGLU_TILE
RETROGLU_VERTEX
RETROGLU_VTEXTURE
RETROGUI
RETROGUI_CTL
RETROGUI_CTL_BASE
+
+
+ + + + diff --git a/closed.png b/closed.png new file mode 100644 index 00000000..98cc2c90 Binary files /dev/null and b/closed.png differ diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html new file mode 100644 index 00000000..509ca560 --- /dev/null +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -0,0 +1,116 @@ + + + + + + + +maug: src Directory Reference + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
src Directory Reference
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Files

 marge.h
 
 merror.h
 
 mmem.h
 
 mtilemap.h
 
 retrocon.h
 
 retroflt.h
 Abstraction layer header for retro systems.
 
 retrofp.h
 Contains functions and macros for working with fixed-point numbers.
 
 retroglu.h
 Library of tools for working with RetroFlat and OpenGL.
 
 retrogui.h
 
 retrosft.h
 
 uprintf.h
 
+
+ + + + diff --git a/doc.svg b/doc.svg new file mode 100644 index 00000000..0b928a53 --- /dev/null +++ b/doc.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/docd.svg b/docd.svg new file mode 100644 index 00000000..ac18b275 --- /dev/null +++ b/docd.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/doxstyle.css b/doxstyle.css new file mode 100644 index 00000000..48d9c780 --- /dev/null +++ b/doxstyle.css @@ -0,0 +1,70 @@ + +body { + background: black; + color: white; +} + +blockquote { + background: #111111 !important; + color: white !important; +} + +pre { + background: #111111 !important; + color: white !important; +} + +.header { + background: black !important; +} + +a, a:visited { + color: cyan !important; +} + +h2 { + color: magenta !important; +} + +.sm-dox, .sm-dox ul, .sm-dox ul a, .navpath ul { + background: black !important; + border: white 1px solid; +} + +tr.even { + background: transparent !important; +} + +tr { +} + +.doxtable th { + background: cyan !important; + color: black !important; +} + +.memberdecls td { + background: transparent !important; +} + +.mdescRight, .memproto, .memdoc, .memtitle { + background: black !important; +} + +.memname { + color: white !important; +} + +.paramname { + color: magenta !important; +} + +.mdescRight { + color: white !important; +} + +.doxtable td { + background: transparent !important; + border: 1px solid cyan !important; +} + diff --git a/doxygen.css b/doxygen.css new file mode 100644 index 00000000..6d7ea725 --- /dev/null +++ b/doxygen.css @@ -0,0 +1,1999 @@ +/* The standard CSS for doxygen 1.9.7*/ + +html { +/* page base colors */ +--page-background-color: white; +--page-foreground-color: black; +--page-link-color: #3D578C; +--page-visited-link-color: #4665A2; + +/* index */ +--index-odd-item-bg-color: #F8F9FC; +--index-even-item-bg-color: white; +--index-header-color: black; +--index-separator-color: #A0A0A0; + +/* header */ +--header-background-color: #F9FAFC; +--header-separator-color: #C4CFE5; +--header-gradient-image: url('nav_h.png'); +--group-header-separator-color: #879ECB; +--group-header-color: #354C7B; +--inherit-header-color: gray; + +--footer-foreground-color: #2A3D61; +--footer-logo-width: 104px; +--citation-label-color: #334975; +--glow-color: cyan; + +--title-background-color: white; +--title-separator-color: #5373B4; +--directory-separator-color: #9CAFD4; +--separator-color: #4A6AAA; + +--blockquote-background-color: #F7F8FB; +--blockquote-border-color: #9CAFD4; + +--scrollbar-thumb-color: #9CAFD4; +--scrollbar-background-color: #F9FAFC; + +--icon-background-color: #728DC1; +--icon-foreground-color: white; +--icon-doc-image: url('doc.svg'); +--icon-folder-open-image: url('folderopen.svg'); +--icon-folder-closed-image: url('folderclosed.svg'); + +/* brief member declaration list */ +--memdecl-background-color: #F9FAFC; +--memdecl-separator-color: #DEE4F0; +--memdecl-foreground-color: #555; +--memdecl-template-color: #4665A2; + +/* detailed member list */ +--memdef-border-color: #A8B8D9; +--memdef-title-background-color: #E2E8F2; +--memdef-title-gradient-image: url('nav_f.png'); +--memdef-proto-background-color: #DFE5F1; +--memdef-proto-text-color: #253555; +--memdef-proto-text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); +--memdef-doc-background-color: white; +--memdef-param-name-color: #602020; +--memdef-template-color: #4665A2; + +/* tables */ +--table-cell-border-color: #2D4068; +--table-header-background-color: #374F7F; +--table-header-foreground-color: #FFFFFF; + +/* labels */ +--label-background-color: #728DC1; +--label-left-top-border-color: #5373B4; +--label-right-bottom-border-color: #C4CFE5; +--label-foreground-color: white; + +/** navigation bar/tree/menu */ +--nav-background-color: #F9FAFC; +--nav-foreground-color: #364D7C; +--nav-gradient-image: url('tab_b.png'); +--nav-gradient-hover-image: url('tab_h.png'); +--nav-gradient-active-image: url('tab_a.png'); +--nav-gradient-active-image-parent: url("../tab_a.png"); +--nav-separator-image: url('tab_s.png'); +--nav-breadcrumb-image: url('bc_s.png'); +--nav-breadcrumb-border-color: #C2CDE4; +--nav-splitbar-image: url('splitbar.png'); +--nav-font-size-level1: 13px; +--nav-font-size-level2: 10px; +--nav-font-size-level3: 9px; +--nav-text-normal-color: #283A5D; +--nav-text-hover-color: white; +--nav-text-active-color: white; +--nav-text-normal-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); +--nav-text-hover-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +--nav-text-active-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +--nav-menu-button-color: #364D7C; +--nav-menu-background-color: white; +--nav-menu-foreground-color: #555555; +--nav-menu-toggle-color: rgba(255, 255, 255, 0.5); +--nav-arrow-color: #9CAFD4; +--nav-arrow-selected-color: #9CAFD4; + +/* table of contents */ +--toc-background-color: #F4F6FA; +--toc-border-color: #D8DFEE; +--toc-header-color: #4665A2; +--toc-down-arrow-image: url("data:image/svg+xml;utf8,&%238595;"); + +/** search field */ +--search-background-color: white; +--search-foreground-color: #909090; +--search-magnification-image: url('mag.svg'); +--search-magnification-select-image: url('mag_sel.svg'); +--search-active-color: black; +--search-filter-background-color: #F9FAFC; +--search-filter-foreground-color: black; +--search-filter-border-color: #90A5CE; +--search-filter-highlight-text-color: white; +--search-filter-highlight-bg-color: #3D578C; +--search-results-foreground-color: #425E97; +--search-results-background-color: #EEF1F7; +--search-results-border-color: black; +--search-box-shadow: inset 0.5px 0.5px 3px 0px #555; + +/** code fragments */ +--code-keyword-color: #008000; +--code-type-keyword-color: #604020; +--code-flow-keyword-color: #E08000; +--code-comment-color: #800000; +--code-preprocessor-color: #806020; +--code-string-literal-color: #002080; +--code-char-literal-color: #008080; +--code-xml-cdata-color: black; +--code-vhdl-digit-color: #FF00FF; +--code-vhdl-char-color: #000000; +--code-vhdl-keyword-color: #700070; +--code-vhdl-logic-color: #FF0000; +--code-link-color: #4665A2; +--code-external-link-color: #4665A2; +--fragment-foreground-color: black; +--fragment-background-color: #FBFCFD; +--fragment-border-color: #C4CFE5; +--fragment-lineno-border-color: #00FF00; +--fragment-lineno-background-color: #E8E8E8; +--fragment-lineno-foreground-color: black; +--fragment-lineno-link-fg-color: #4665A2; +--fragment-lineno-link-bg-color: #D8D8D8; +--fragment-lineno-link-hover-fg-color: #4665A2; +--fragment-lineno-link-hover-bg-color: #C8C8C8; +--tooltip-foreground-color: black; +--tooltip-background-color: white; +--tooltip-border-color: gray; +--tooltip-doc-color: grey; +--tooltip-declaration-color: #006318; +--tooltip-link-color: #4665A2; +--tooltip-shadow: 1px 1px 7px gray; + +/** font-family */ +--font-family-normal: Roboto,sans-serif; +--font-family-monospace: 'JetBrains Mono',Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace,fixed; +--font-family-nav: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; +--font-family-title: Tahoma,Arial,sans-serif; +--font-family-toc: Verdana,'DejaVu Sans',Geneva,sans-serif; +--font-family-search: Arial,Verdana,sans-serif; +--font-family-icon: Arial,Helvetica; +--font-family-tooltip: Roboto,sans-serif; + +} + +@media (prefers-color-scheme: dark) { + html:not(.dark-mode) { + color-scheme: dark; + +/* page base colors */ +--page-background-color: black; +--page-foreground-color: #C9D1D9; +--page-link-color: #90A5CE; +--page-visited-link-color: #A3B4D7; + +/* index */ +--index-odd-item-bg-color: #0B101A; +--index-even-item-bg-color: black; +--index-header-color: #C4CFE5; +--index-separator-color: #334975; + +/* header */ +--header-background-color: #070B11; +--header-separator-color: #141C2E; +--header-gradient-image: url('nav_hd.png'); +--group-header-separator-color: #283A5D; +--group-header-color: #90A5CE; +--inherit-header-color: #A0A0A0; + +--footer-foreground-color: #5B7AB7; +--footer-logo-width: 60px; +--citation-label-color: #90A5CE; +--glow-color: cyan; + +--title-background-color: #090D16; +--title-separator-color: #354C79; +--directory-separator-color: #283A5D; +--separator-color: #283A5D; + +--blockquote-background-color: #101826; +--blockquote-border-color: #283A5D; + +--scrollbar-thumb-color: #283A5D; +--scrollbar-background-color: #070B11; + +--icon-background-color: #334975; +--icon-foreground-color: #C4CFE5; +--icon-doc-image: url('docd.svg'); +--icon-folder-open-image: url('folderopend.svg'); +--icon-folder-closed-image: url('folderclosedd.svg'); + +/* brief member declaration list */ +--memdecl-background-color: #0B101A; +--memdecl-separator-color: #2C3F65; +--memdecl-foreground-color: #BBB; +--memdecl-template-color: #7C95C6; + +/* detailed member list */ +--memdef-border-color: #233250; +--memdef-title-background-color: #1B2840; +--memdef-title-gradient-image: url('nav_fd.png'); +--memdef-proto-background-color: #19243A; +--memdef-proto-text-color: #9DB0D4; +--memdef-proto-text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.9); +--memdef-doc-background-color: black; +--memdef-param-name-color: #D28757; +--memdef-template-color: #7C95C6; + +/* tables */ +--table-cell-border-color: #283A5D; +--table-header-background-color: #283A5D; +--table-header-foreground-color: #C4CFE5; + +/* labels */ +--label-background-color: #354C7B; +--label-left-top-border-color: #4665A2; +--label-right-bottom-border-color: #283A5D; +--label-foreground-color: #CCCCCC; + +/** navigation bar/tree/menu */ +--nav-background-color: #101826; +--nav-foreground-color: #364D7C; +--nav-gradient-image: url('tab_bd.png'); +--nav-gradient-hover-image: url('tab_hd.png'); +--nav-gradient-active-image: url('tab_ad.png'); +--nav-gradient-active-image-parent: url("../tab_ad.png"); +--nav-separator-image: url('tab_sd.png'); +--nav-breadcrumb-image: url('bc_sd.png'); +--nav-breadcrumb-border-color: #2A3D61; +--nav-splitbar-image: url('splitbard.png'); +--nav-font-size-level1: 13px; +--nav-font-size-level2: 10px; +--nav-font-size-level3: 9px; +--nav-text-normal-color: #B6C4DF; +--nav-text-hover-color: #DCE2EF; +--nav-text-active-color: #DCE2EF; +--nav-text-normal-shadow: 0px 1px 1px black; +--nav-text-hover-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +--nav-text-active-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +--nav-menu-button-color: #B6C4DF; +--nav-menu-background-color: #05070C; +--nav-menu-foreground-color: #BBBBBB; +--nav-menu-toggle-color: rgba(255, 255, 255, 0.2); +--nav-arrow-color: #334975; +--nav-arrow-selected-color: #90A5CE; + +/* table of contents */ +--toc-background-color: #151E30; +--toc-border-color: #202E4A; +--toc-header-color: #A3B4D7; +--toc-down-arrow-image: url("data:image/svg+xml;utf8,&%238595;"); + +/** search field */ +--search-background-color: black; +--search-foreground-color: #C5C5C5; +--search-magnification-image: url('mag_d.svg'); +--search-magnification-select-image: url('mag_seld.svg'); +--search-active-color: #C5C5C5; +--search-filter-background-color: #101826; +--search-filter-foreground-color: #90A5CE; +--search-filter-border-color: #7C95C6; +--search-filter-highlight-text-color: #BCC9E2; +--search-filter-highlight-bg-color: #283A5D; +--search-results-background-color: #101826; +--search-results-foreground-color: #90A5CE; +--search-results-border-color: #7C95C6; +--search-box-shadow: inset 0.5px 0.5px 3px 0px #2F436C; + +/** code fragments */ +--code-keyword-color: #CC99CD; +--code-type-keyword-color: #AB99CD; +--code-flow-keyword-color: #E08000; +--code-comment-color: #717790; +--code-preprocessor-color: #65CABE; +--code-string-literal-color: #7EC699; +--code-char-literal-color: #00E0F0; +--code-xml-cdata-color: #C9D1D9; +--code-vhdl-digit-color: #FF00FF; +--code-vhdl-char-color: #000000; +--code-vhdl-keyword-color: #700070; +--code-vhdl-logic-color: #FF0000; +--code-link-color: #79C0FF; +--code-external-link-color: #79C0FF; +--fragment-foreground-color: #C9D1D9; +--fragment-background-color: black; +--fragment-border-color: #30363D; +--fragment-lineno-border-color: #30363D; +--fragment-lineno-background-color: black; +--fragment-lineno-foreground-color: #6E7681; +--fragment-lineno-link-fg-color: #6E7681; +--fragment-lineno-link-bg-color: #303030; +--fragment-lineno-link-hover-fg-color: #8E96A1; +--fragment-lineno-link-hover-bg-color: #505050; +--tooltip-foreground-color: #C9D1D9; +--tooltip-background-color: #202020; +--tooltip-border-color: #C9D1D9; +--tooltip-doc-color: #D9E1E9; +--tooltip-declaration-color: #20C348; +--tooltip-link-color: #79C0FF; +--tooltip-shadow: none; + +/** font-family */ +--font-family-normal: Roboto,sans-serif; +--font-family-monospace: 'JetBrains Mono',Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace,fixed; +--font-family-nav: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; +--font-family-title: Tahoma,Arial,sans-serif; +--font-family-toc: Verdana,'DejaVu Sans',Geneva,sans-serif; +--font-family-search: Arial,Verdana,sans-serif; +--font-family-icon: Arial,Helvetica; +--font-family-tooltip: Roboto,sans-serif; + +}} +body { + background-color: var(--page-background-color); + color: var(--page-foreground-color); +} + +body, table, div, p, dl { + font-weight: 400; + font-size: 14px; + font-family: var(--font-family-normal); + line-height: 22px; +} + +/* @group Heading Levels */ + +.title { + font-weight: 400; + font-size: 14px; + font-family: var(--font-family-normal); + line-height: 28px; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h1.groupheader { + font-size: 150%; +} + +h2.groupheader { + border-bottom: 1px solid var(--group-header-separator-color); + color: var(--group-header-color); + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px var(--glow-color); +} + +dt { + font-weight: bold; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +th p.starttd, th p.intertd, th p.endtd { + font-size: 100%; + font-weight: 700; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +p.interli { +} + +p.interdd { +} + +p.intertd { +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.navtab { + padding-right: 15px; + text-align: right; + line-height: 110%; +} + +div.navtab table { + border-spacing: 0; +} + +td.navtab { + padding-right: 6px; + padding-left: 6px; +} + +td.navtabHL { + background-image: var(--nav-gradient-active-image); + background-repeat:repeat-x; + padding-right: 6px; + padding-left: 6px; +} + +td.navtabHL a, td.navtabHL a:visited { + color: var(--nav-text-hover-color); + text-shadow: var(--nav-text-hover-shadow); +} + +a.navtab { + font-weight: bold; +} + +div.qindex{ + text-align: center; + width: 100%; + line-height: 140%; + font-size: 130%; + color: var(--index-separator-color); +} + +dt.alphachar{ + font-size: 180%; + font-weight: bold; +} + +.alphachar a{ + color: var(--index-header-color); +} + +.alphachar a:hover, .alphachar a:visited{ + text-decoration: none; +} + +.classindex dl { + padding: 25px; + column-count:1 +} + +.classindex dd { + display:inline-block; + margin-left: 50px; + width: 90%; + line-height: 1.15em; +} + +.classindex dl.even { + background-color: var(--index-even-item-bg-color); +} + +.classindex dl.odd { + background-color: var(--index-odd-item-bg-color); +} + +@media(min-width: 1120px) { + .classindex dl { + column-count:2 + } +} + +@media(min-width: 1320px) { + .classindex dl { + column-count:3 + } +} + + +/* @group Link Styling */ + +a { + color: var(--page-link-color); + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: var(--page-visited-link-color); +} + +a:hover { + text-decoration: underline; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: var(--code-link-color); +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: var(--code-external-link-color); +} + +a.code.hl_class { /* style for links to class names in code snippets */ } +a.code.hl_struct { /* style for links to struct names in code snippets */ } +a.code.hl_union { /* style for links to union names in code snippets */ } +a.code.hl_interface { /* style for links to interface names in code snippets */ } +a.code.hl_protocol { /* style for links to protocol names in code snippets */ } +a.code.hl_category { /* style for links to category names in code snippets */ } +a.code.hl_exception { /* style for links to exception names in code snippets */ } +a.code.hl_service { /* style for links to service names in code snippets */ } +a.code.hl_singleton { /* style for links to singleton names in code snippets */ } +a.code.hl_concept { /* style for links to concept names in code snippets */ } +a.code.hl_namespace { /* style for links to namespace names in code snippets */ } +a.code.hl_package { /* style for links to package names in code snippets */ } +a.code.hl_define { /* style for links to macro names in code snippets */ } +a.code.hl_function { /* style for links to function names in code snippets */ } +a.code.hl_variable { /* style for links to variable names in code snippets */ } +a.code.hl_typedef { /* style for links to typedef names in code snippets */ } +a.code.hl_enumvalue { /* style for links to enum value names in code snippets */ } +a.code.hl_enumeration { /* style for links to enumeration names in code snippets */ } +a.code.hl_signal { /* style for links to Qt signal names in code snippets */ } +a.code.hl_slot { /* style for links to Qt slot names in code snippets */ } +a.code.hl_friend { /* style for links to friend names in code snippets */ } +a.code.hl_dcop { /* style for links to KDE3 DCOP names in code snippets */ } +a.code.hl_property { /* style for links to property names in code snippets */ } +a.code.hl_event { /* style for links to event names in code snippets */ } +a.code.hl_sequence { /* style for links to sequence names in code snippets */ } +a.code.hl_dictionary { /* style for links to dictionary names in code snippets */ } + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +ul { + overflow: visible; +} + +ul.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; + column-count: 3; + list-style-type: none; +} + +#side-nav ul { + overflow: visible; /* reset ul rule for scroll bar in GENERATE_TREEVIEW window */ +} + +#main-nav ul { + overflow: visible; /* reset ul rule for the navigation bar drop down lists */ +} + +.fragment { + text-align: left; + direction: ltr; + overflow-x: auto; /*Fixed: fragment lines overlap floating elements*/ + overflow-y: hidden; +} + +pre.fragment { + border: 1px solid var(--fragment-border-color); + background-color: var(--fragment-background-color); + color: var(--fragment-foreground-color); + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: var(--font-family-monospace); + font-size: 105%; +} + +div.fragment { + padding: 0 0 1px 0; /*Fixed: last line underline overlap border*/ + margin: 4px 8px 4px 2px; + color: var(--fragment-foreground-color); + background-color: var(--fragment-background-color); + border: 1px solid var(--fragment-border-color); +} + +div.line { + font-family: var(--font-family-monospace); + font-size: 13px; + min-height: 13px; + line-height: 1.2; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line:after { + content:"\000A"; + white-space: pre; +} + +div.line.glow { + background-color: var(--glow-color); + box-shadow: 0 0 10px var(--glow-color); +} + + +span.lineno { + padding-right: 4px; + margin-right: 9px; + text-align: right; + border-right: 2px solid var(--fragment-lineno-border-color); + color: var(--fragment-lineno-foreground-color); + background-color: var(--fragment-lineno-background-color); + white-space: pre; +} +span.lineno a, span.lineno a:visited { + color: var(--fragment-lineno-link-fg-color); + background-color: var(--fragment-lineno-link-bg-color); +} + +span.lineno a:hover { + color: var(--fragment-lineno-link-hover-fg-color); + background-color: var(--fragment-lineno-link-hover-bg-color); +} + +.lineno { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +div.classindex ul { + list-style: none; + padding-left: 0; +} + +div.classindex span.ai { + display: inline-block; +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + color: var(--page-foreground-color); + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +p.formulaDsp { + text-align: center; +} + +img.dark-mode-visible { + display: none; +} +img.light-mode-visible { + display: none; +} + +img.formulaDsp { + +} + +img.formulaInl, img.inline { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; + width: var(--footer-logo-width); +} + +.compoundTemplParams { + color: var(--memdecl-template-color); + font-size: 80%; + line-height: 120%; +} + +/* @group Code Colorization */ + +span.keyword { + color: var(--code-keyword-color); +} + +span.keywordtype { + color: var(--code-type-keyword-color); +} + +span.keywordflow { + color: var(--code-flow-keyword-color); +} + +span.comment { + color: var(--code-comment-color); +} + +span.preprocessor { + color: var(--code-preprocessor-color); +} + +span.stringliteral { + color: var(--code-string-literal-color); +} + +span.charliteral { + color: var(--code-char-literal-color); +} + +span.xmlcdata { + color: var(--code-xml-cdata-color); +} + +span.vhdldigit { + color: var(--code-vhdl-digit-color); +} + +span.vhdlchar { + color: var(--code-vhdl-char-color); +} + +span.vhdlkeyword { + color: var(--code-vhdl-keyword-color); +} + +span.vhdllogic { + color: var(--code-vhdl-logic-color); +} + +blockquote { + background-color: var(--blockquote-background-color); + border-left: 2px solid var(--blockquote-border-color); + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid var(--table-cell-border-color); +} + +th.dirtab { + background-color: var(--table-header-background-color); + color: var(--table-header-foreground-color); + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid var(--separator-color); +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: var(--glow-color); + box-shadow: 0 0 15px var(--glow-color); +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: var(--memdecl-background-color); + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: var(--memdecl-foreground-color); +} + +.memSeparator { + border-bottom: 1px solid var(--memdecl-separator-color); + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight, .memTemplItemRight { + width: 100%; +} + +.memTemplParams { + color: var(--memdecl-template-color); + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtitle { + padding: 8px; + border-top: 1px solid var(--memdef-border-color); + border-left: 1px solid var(--memdef-border-color); + border-right: 1px solid var(--memdef-border-color); + border-top-right-radius: 4px; + border-top-left-radius: 4px; + margin-bottom: -1px; + background-image: var(--memdef-title-gradient-image); + background-repeat: repeat-x; + background-color: var(--memdef-title-background-color); + line-height: 1.25; + font-weight: 300; + float:left; +} + +.permalink +{ + font-size: 65%; + display: inline-block; + vertical-align: middle; +} + +.memtemplate { + font-size: 80%; + color: var(--memdef-template-color); + font-weight: normal; + margin-left: 9px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px var(--glow-color); +} + +.memname { + font-weight: 400; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid var(--memdef-border-color); + border-left: 1px solid var(--memdef-border-color); + border-right: 1px solid var(--memdef-border-color); + padding: 6px 0px 6px 0px; + color: var(--memdef-proto-text-color); + font-weight: bold; + text-shadow: var(--memdef-proto-text-shadow); + background-color: var(--memdef-proto-background-color); + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; +} + +.overload { + font-family: var(--font-family-monospace); + font-size: 65%; +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid var(--memdef-border-color); + border-left: 1px solid var(--memdef-border-color); + border-right: 1px solid var(--memdef-border-color); + padding: 6px 10px 2px 10px; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: var(--memdef-doc-background-color); + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: var(--memdef-param-name-color); + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype, .tparams .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir, .tparams .paramdir { + font-family: var(--font-family-monospace); + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: var(--label-background-color); + border-top:1px solid var(--label-left-top-border-color); + border-left:1px solid var(--label-left-top-border-color); + border-right:1px solid var(--label-right-bottom-border-color); + border-bottom:1px solid var(--label-right-bottom-border-color); + text-shadow: none; + color: var(--label-foreground-color); + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid var(--directory-separator-color); + border-bottom: 1px solid var(--directory-separator-color); + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.odd { + padding-left: 6px; + background-color: var(--index-odd-item-bg-color); +} + +.directory tr.even { + padding-left: 6px; + background-color: var(--index-even-item-bg-color); +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: var(--page-link-color); +} + +.arrow { + color: var(--nav-arrow-color); + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: var(--font-family-icon); + line-height: normal; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: var(--icon-background-color); + color: var(--icon-foreground-color); + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:var(--icon-folder-open-image); + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:var(--icon-folder-closed-image); + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:var(--icon-doc-image); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: var(--footer-foreground-color); +} + +table.doxtable caption { + caption-side: top; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid var(--table-cell-border-color); + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: var(--table-header-background-color); + color: var(--table-header-foreground-color); + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + margin-bottom: 10px; + border: 1px solid var(--memdef-border-color); + border-spacing: 0px; + border-radius: 4px; + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid var(--memdef-border-color); + border-bottom: 1px solid var(--memdef-border-color); + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid var(--memdef-border-color); +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image: var(--memdef-title-gradient-image); + background-repeat:repeat-x; + background-color: var(--memdef-title-background-color); + font-size: 90%; + color: var(--memdef-proto-text-color); + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + font-weight: 400; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid var(--memdef-border-color); +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: var(--nav-gradient-image); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image: var(--nav-gradient-image); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:var(--nav-text-normal-color); + border:solid 1px var(--nav-breadcrumb-border-color); + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:var(--nav-breadcrumb-image); + background-repeat:no-repeat; + background-position:right; + color: var(--nav-foreground-color); +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: var(--nav-text-normal-color); + font-family: var(--font-family-nav); + text-shadow: var(--nav-text-normal-shadow); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color: var(--nav-text-hover-color); + text-shadow: var(--nav-text-hover-shadow); +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color: var(--footer-foreground-color); + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +table.classindex +{ + margin: 10px; + white-space: nowrap; + margin-left: 3%; + margin-right: 3%; + width: 94%; + border: 0; + border-spacing: 0; + padding: 0; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image: var(--header-gradient-image); + background-repeat:repeat-x; + background-color: var(--header-background-color); + margin: 0px; + border-bottom: 1px solid var(--header-separator-color); +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +.PageDocRTL-title div.headertitle { + text-align: right; + direction: rtl; +} + +dl { + padding: 0 0 0 0; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug, dl.examples */ +dl.section { + margin-left: 0px; + padding-left: 0px; +} + +dl.note { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00D000; +} + +dl.deprecated { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #505050; +} + +dl.todo { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00C0E0; +} + +dl.test { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #3030E0; +} + +dl.bug { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectrow +{ + height: 56px; +} + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectalign +{ + vertical-align: middle; + padding-left: 0.5em; +} + +#projectname +{ + font-size: 200%; + font-family: var(--font-family-title); + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font-size: 90%; + font-family: var(--font-family-title); + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font-size: 50%; + font-family: 50% var(--font-family-title); + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid var(--title-separator-color); + background-color: var(--title-background-color); +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.plantumlgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:var(--citation-label-color); + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; + text-align:right; + width:52px; +} + +dl.citelist dd { + margin:2px 0 2px 72px; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: var(--toc-background-color); + border: 1px solid var(--toc-border-color); + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 8px 10px 10px; + width: 200px; +} + +div.toc li { + background: var(--toc-down-arrow-image) no-repeat scroll 0 5px transparent; + font: 10px/1.2 var(--font-family-toc); + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px/1.2 var(--font-family-toc); + color: var(--toc-header-color); + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 15px; +} + +div.toc li.level4 { + margin-left: 15px; +} + +span.emoji { + /* font family used at the site: https://unicode.org/emoji/charts/full-emoji-list.html + * font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", Times, Symbola, Aegyptus, Code2000, Code2001, Code2002, Musica, serif, LastResort; + */ +} + +span.obfuscator { + display: none; +} + +.inherit_header { + font-weight: bold; + color: var(--inherit-header-color); + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + /*white-space: nowrap;*/ + color: var(--tooltip-foreground-color); + background-color: var(--tooltip-background-color); + border: 1px solid var(--tooltip-border-color); + border-radius: 4px 4px 4px 4px; + box-shadow: var(--tooltip-shadow); + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: var(--tooltip-doc-color); + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip a { + color: var(--tooltip-link-color); +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: var(--tooltip-declaration-color); +} + +#powerTip div { + margin: 0px; + padding: 0px; + font-size: 12px; + font-family: var(--font-family-tooltip); + line-height: 16px; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: var(--tooltip-background-color); + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before, #powerTip.ne:before, #powerTip.nw:before { + border-top-color: var(--tooltip-border-color); + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: var(--tooltip-background-color); + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: var(--tooltip-border-color); + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: var(--tooltip-border-color); + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: var(--tooltip-border-color); + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: var(--tooltip-border-color); + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: var(--tooltip-border-color); + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + +/* @group Markdown */ + +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid var(--table-cell-border-color); + padding: 3px 7px 2px; +} + +table.markdownTable tr { +} + +th.markdownTableHeadLeft, th.markdownTableHeadRight, th.markdownTableHeadCenter, th.markdownTableHeadNone { + background-color: var(--table-header-background-color); + color: var(--table-header-foreground-color); + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft, td.markdownTableBodyLeft { + text-align: left +} + +th.markdownTableHeadRight, td.markdownTableBodyRight { + text-align: right +} + +th.markdownTableHeadCenter, td.markdownTableBodyCenter { + text-align: center +} + +tt, code, kbd, samp +{ + display: inline-block; +} +/* @end */ + +u { + text-decoration: underline; +} + +details>summary { + list-style-type: none; +} + +details > summary::-webkit-details-marker { + display: none; +} + +details>summary::before { + content: "\25ba"; + padding-right:4px; + font-size: 80%; +} + +details[open]>summary::before { + content: "\25bc"; + padding-right:4px; + font-size: 80%; +} + diff --git a/doxygen.svg b/doxygen.svg new file mode 100644 index 00000000..79a76354 --- /dev/null +++ b/doxygen.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dynsections.js b/dynsections.js new file mode 100644 index 00000000..f579fbf3 --- /dev/null +++ b/dynsections.js @@ -0,0 +1,123 @@ +/* + @licstart The following is the entire license notice for the JavaScript code in this file. + + The MIT License (MIT) + + Copyright (C) 1997-2020 by Dimitri van Heesch + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file + */ +function toggleVisibility(linkObj) +{ + var base = $(linkObj).attr('id'); + var summary = $('#'+base+'-summary'); + var content = $('#'+base+'-content'); + var trigger = $('#'+base+'-trigger'); + var src=$(trigger).attr('src'); + if (content.is(':visible')===true) { + content.hide(); + summary.show(); + $(linkObj).addClass('closed').removeClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); + } else { + content.show(); + summary.hide(); + $(linkObj).removeClass('closed').addClass('opened'); + $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); + } + return false; +} + +function updateStripes() +{ + $('table.directory tr'). + removeClass('even').filter(':visible:even').addClass('even'); + $('table.directory tr'). + removeClass('odd').filter(':visible:odd').addClass('odd'); +} + +function toggleLevel(level) +{ + $('table.directory tr').each(function() { + var l = this.id.split('_').length-1; + var i = $('#img'+this.id.substring(3)); + var a = $('#arr'+this.id.substring(3)); + if (l + + + + + + +maug: File List + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
File List
+
+
+
Here is a list of all documented files with brief descriptions:
+
[detail level 12]
+ + + + + + + + + + + + +
  src
 marge.h
 merror.h
 mmem.h
 mtilemap.h
 retrocon.h
 retroflt.hAbstraction layer header for retro systems
 retrofp.hContains functions and macros for working with fixed-point numbers
 retroglu.hLibrary of tools for working with RetroFlat and OpenGL
 retrogui.h
 retrosft.h
 uprintf.h
+
+
+ + + + diff --git a/folderclosed.svg b/folderclosed.svg new file mode 100644 index 00000000..b04bed2e --- /dev/null +++ b/folderclosed.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/folderclosedd.svg b/folderclosedd.svg new file mode 100644 index 00000000..52f0166a --- /dev/null +++ b/folderclosedd.svg @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/folderopen.svg b/folderopen.svg new file mode 100644 index 00000000..f6896dd2 --- /dev/null +++ b/folderopen.svg @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/folderopend.svg b/folderopend.svg new file mode 100644 index 00000000..2d1f06e7 --- /dev/null +++ b/folderopend.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/functions.html b/functions.html new file mode 100644 index 00000000..fa4f76b8 --- /dev/null +++ b/functions.html @@ -0,0 +1,104 @@ + + + + + + + +maug: Data Fields + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented struct and union fields with links to the struct/union documentation for each field:
+
+ + + + diff --git a/functions_func.html b/functions_func.html new file mode 100644 index 00000000..fd6fac5a --- /dev/null +++ b/functions_func.html @@ -0,0 +1,84 @@ + + + + + + + +maug: Data Fields - Functions + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented functions with links to the struct/union documentation for each field:
+
+ + + + diff --git a/functions_vars.html b/functions_vars.html new file mode 100644 index 00000000..db4f26e1 --- /dev/null +++ b/functions_vars.html @@ -0,0 +1,102 @@ + + + + + + + +maug: Data Fields - Variables + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented variables with links to the struct/union documentation for each field:
+
+ + + + diff --git a/globals.html b/globals.html new file mode 100644 index 00000000..02fbf8b7 --- /dev/null +++ b/globals.html @@ -0,0 +1,160 @@ + + + + + + + +maug: Globals + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:
+ +

- m -

+ + +

- n -

+ + +

- r -

+
+ + + + diff --git a/globals_defs.html b/globals_defs.html new file mode 100644 index 00000000..b1e36cb4 --- /dev/null +++ b/globals_defs.html @@ -0,0 +1,134 @@ + + + + + + + +maug: Globals + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented macros with links to the documentation:
+ +

- m -

+ + +

- n -

+ + +

- r -

+
+ + + + diff --git a/globals_func.html b/globals_func.html new file mode 100644 index 00000000..938bb366 --- /dev/null +++ b/globals_func.html @@ -0,0 +1,102 @@ + + + + + + + +maug: Globals + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented functions with links to the documentation:
+
+ + + + diff --git a/globals_type.html b/globals_type.html new file mode 100644 index 00000000..60aa91be --- /dev/null +++ b/globals_type.html @@ -0,0 +1,88 @@ + + + + + + + +maug: Globals + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Here is a list of all documented typedefs with links to the documentation:
+
+ + + + diff --git a/graph_legend.html b/graph_legend.html new file mode 100644 index 00000000..76420634 --- /dev/null +++ b/graph_legend.html @@ -0,0 +1,143 @@ + + + + + + + +maug: Graph Legend + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Graph Legend
+
+
+

This page explains how to interpret the graphs that are generated by doxygen.

+

Consider the following example:

/*! Invisible class because of truncation */
+
class Invisible { };
+
+
/*! Truncated class, inheritance relation is hidden */
+
class Truncated : public Invisible { };
+
+
/* Class not documented with doxygen comments */
+
class Undocumented { };
+
+
/*! Class that is inherited using public inheritance */
+
class PublicBase : public Truncated { };
+
+
/*! A template class */
+
template<class T> class Templ { };
+
+
/*! Class that is inherited using protected inheritance */
+
class ProtectedBase { };
+
+
/*! Class that is inherited using private inheritance */
+
class PrivateBase { };
+
+
/*! Class that is used by the Inherited class */
+
class Used { };
+
+
/*! Super class that inherits a number of other classes */
+
class Inherited : public PublicBase,
+
protected ProtectedBase,
+
private PrivateBase,
+
public Undocumented,
+
public Templ<int>
+
{
+
private:
+
Used *m_usedClass;
+
};
+

This will result in the following graph:

+

The boxes in the above graph have the following meaning:

+ +

The arrows have the following meaning:

+ +
+ + + + diff --git a/graph_legend.md5 b/graph_legend.md5 new file mode 100644 index 00000000..da515da9 --- /dev/null +++ b/graph_legend.md5 @@ -0,0 +1 @@ +f74606a252eb303675caf37987d0b7af \ No newline at end of file diff --git a/graph_legend.png b/graph_legend.png new file mode 100644 index 00000000..d9ec1c0a Binary files /dev/null and b/graph_legend.png differ diff --git a/group__maug__cli.html b/group__maug__cli.html new file mode 100644 index 00000000..9841a735 --- /dev/null +++ b/group__maug__cli.html @@ -0,0 +1,202 @@ + + + + + + + +maug: Command Line API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Command Line API
+
+
+ +

Tools for parsing command line arguments. +More...

+ + + + + + + + + + + + + + + + +

+Macros

+#define MAUG_CLI_SIGIL_SZ   1
 
+#define MAUG_CLI_SIGIL   "-"
 Default flag to prepend to CLI arguments. Is "/" on Windows/DOS and "-" on other platforms. Can be overridden with a -D flag or define.
 
+#define MAUG_CLI_ARG_LIST_SZ_MAX   50
 
+#define MAUG_CLI_ARG_HELP_SZ_MAX   255
 
+#define MAUG_CLI_ARG_SZ_MAX   50
 
+#define MAUG_CLI(f)    f( MAUG_CLI_SIGIL "h", 3, "Display help and exit.", maug_cli_h, NULL )
 Default CLI arguments for all RetroFlat programs.
 
+ + + +

+Typedefs

+typedef MERROR_RETVAL(* maug_cli_cb) (const char *arg, void *data)
 
+ + + + + + +

+Functions

+int maug_parse_args (int argc, char *argv[])
 
MERROR_RETVAL maug_add_arg (const char *arg, int arg_sz, const char *help, int help_sz, maug_cli_cb arg_cb, maug_cli_cb def_cb, void *data)
 Add a command-line argument to the built-in parser.
 
+

Detailed Description

+

Tools for parsing command line arguments.

+

Function Documentation

+ +

◆ maug_add_arg()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MERROR_RETVAL maug_add_arg (const char * arg,
int arg_sz,
const char * help,
int help_sz,
maug_cli_cb arg_cb,
maug_cli_cb def_cb,
void * data 
)
+
+ +

Add a command-line argument to the built-in parser.

+
Parameters
+ + + + + + +
argString containing the argument to look for.
arg_szLength of arg in chars or 0 to autodetect.
helpHelp text for the arg when -h is invoked.
help_szLength of help in chars or 0 to autodetect.
arg_cbmaug_cli_cb to invoke when arg is found.
+
+
+ +
+
+
+ + + + diff --git a/group__maug__console.html b/group__maug__console.html new file mode 100644 index 00000000..ca11324f --- /dev/null +++ b/group__maug__console.html @@ -0,0 +1,155 @@ + + + + + + + +maug: In-Situ Console API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
In-Situ Console API
+
+
+ + + + +

+Data Structures

struct  RETROCON
 
+ + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROCON_SBUFFER_SZ_MAX   4096
 
+#define RETROCON_SBUFFER_LINES_MAX   30
 
+#define RETROCON_LBUFFER_SZ_MAX   256
 
+#define RETROCON_ACTIVE_KEY   RETROFLAT_KEY_GRAVE
 
+#define RETROCON_CB_NAME_SZ_MAX   32
 
+#define RETROCON_CB_SZ_MAX   128
 
+#define RETROCON_WIN_H   110
 
+#define RETROCON_DEBOUNCE_WAIT   3
 
+#define RETROCON_FLAG_ACTIVE   0x01
 
+ + + +

+Typedefs

+typedef MERROR_RETVAL(* retrocon_cb) (struct RETROCON *con, const char *line, size_t line_sz, void *data)
 
+ + + + + + + + + + + + + + + +

+Functions

+MERROR_RETVAL retrocon_init (struct RETROCON *con)
 
+MERROR_RETVAL retrocon_add_command (struct RETROCON *con, const char *cmd, retrocon_cb cb, void *cb_data)
 
+MERROR_RETVAL retrocon_display (struct RETROCON *con, struct RETROFLAT_BITMAP *display)
 
+void retrocon_print_line (struct RETROCON *con, const char *line)
 
+MERROR_RETVAL retrocon_exec_line (struct RETROCON *con, const char *line, size_t line_sz)
 
+int retrocon_debounce (struct RETROCON *con, int c)
 
+MERROR_RETVAL retrocon_input (struct RETROCON *con, int *p_c, struct RETROFLAT_INPUT *input_evt)
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__error.html b/group__maug__error.html new file mode 100644 index 00000000..44d7cb3a --- /dev/null +++ b/group__maug__error.html @@ -0,0 +1,290 @@ + + + + + + + +maug: Error Handling API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Error Handling API
+
+
+
+Collaboration diagram for Error Handling API:
+
+
+ + + + +
+ + + + +

+Modules

 Return Values
 
+ + + +

+Files

file  merror.h
 
+ + + + + + + + + + + + + + + + + + + +

+Macros

#define maug_cleanup_if_null_msg(type, ptr, err, msg)
 
+#define maug_cleanup_if_null(type, ptr, err)    maug_cleanup_if_null_msg( type, ptr, err, "failed to allocate " #ptr "!" )
 
+#define maug_cleanup_if_null_alloc(type, ptr)    maug_cleanup_if_null_msg( type, ptr, MERROR_ALLOC, "failed to allocate " #ptr "!" )
 
+#define maug_cleanup_if_null_file(ptr)    maug_cleanup_if_null_msg( FILE*, ptr, MERROR_FILE, "failed to open FILE!" )
 
#define maug_cleanup_if_not_ok()
 
#define maug_cleanup_if_lt(a, b, fmt, err)
 
+#define maug_cleanup_if_lt_overflow(a, b)    maug_cleanup_if_lt( a, b, SIZE_T_FMT, MERROR_OVERFLOW )
 
#define maug_cleanup_if_ge(a, b, fmt, err)
 
+#define maug_cleanup_if_ge_overflow(a, b)    maug_cleanup_if_ge( a, (size_t)(b), SIZE_T_FMT, MERROR_OVERFLOW )
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ maug_cleanup_if_ge

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_cleanup_if_ge( a,
 b,
 fmt,
 err 
)
+
+Value:
if( (a) >= (b) ) { \
+
error_printf( fmt " is greater or equal to " fmt "!", a, b ); \
+
retval = err; \
+
goto cleanup; \
+
}
+
+
+
+ +

◆ maug_cleanup_if_lt

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_cleanup_if_lt( a,
 b,
 fmt,
 err 
)
+
+Value:
if( (a) < (b) ) { \
+
error_printf( fmt " is less than " fmt "!", a, b ); \
+
retval = err; \
+
goto cleanup; \
+
}
+
+
+
+ +

◆ maug_cleanup_if_not_ok

+ +
+
+ + + + + + + +
#define maug_cleanup_if_not_ok()
+
+Value:
if( MERROR_OK != retval ) { \
+
goto cleanup; \
+
}
+
+
+
+ +

◆ maug_cleanup_if_null_msg

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_cleanup_if_null_msg( type,
 ptr,
 err,
 msg 
)
+
+Value:
if( (type)NULL == ptr ) { \
+
error_printf( msg ); \
+
retval = err; \
+
goto cleanup; \
+
}
+
+
+
+
+ + + + diff --git a/group__maug__error.map b/group__maug__error.map new file mode 100644 index 00000000..c5f78773 --- /dev/null +++ b/group__maug__error.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__error.md5 b/group__maug__error.md5 new file mode 100644 index 00000000..8b065fa3 --- /dev/null +++ b/group__maug__error.md5 @@ -0,0 +1 @@ +49cca93c06e1464f5c803fa2573c30ac \ No newline at end of file diff --git a/group__maug__error.png b/group__maug__error.png new file mode 100644 index 00000000..f08743f7 Binary files /dev/null and b/group__maug__error.png differ diff --git a/group__maug__error__retvals.html b/group__maug__error__retvals.html new file mode 100644 index 00000000..9db568cc --- /dev/null +++ b/group__maug__error__retvals.html @@ -0,0 +1,131 @@ + + + + + + + +maug: Return Values + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Return Values
+
+
+
+Collaboration diagram for Return Values:
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + +

+Macros

+#define MERROR_OK   0x00
 
+#define MERROR_MARGE   0x01
 
+#define MERROR_ALLOC   0x02
 
+#define MERROR_OVERFLOW   0x04
 
+#define MERROR_FILE   0x08
 
+#define MERROR_USR   0x0f
 
+#define MERROR_PARSE   0x10
 
+#define MERROR_GUI   0x20
 
+ + + + +

+Typedefs

+typedef int MERROR_RETVAL
 Return type indicating function returns a value from this list.
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__error__retvals.map b/group__maug__error__retvals.map new file mode 100644 index 00000000..e9c50fba --- /dev/null +++ b/group__maug__error__retvals.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__error__retvals.md5 b/group__maug__error__retvals.md5 new file mode 100644 index 00000000..d2d947e9 --- /dev/null +++ b/group__maug__error__retvals.md5 @@ -0,0 +1 @@ +af9e58a2fbc9bffc06373315124f46d4 \ No newline at end of file diff --git a/group__maug__error__retvals.png b/group__maug__error__retvals.png new file mode 100644 index 00000000..5f97b986 Binary files /dev/null and b/group__maug__error__retvals.png differ diff --git a/group__maug__mem.html b/group__maug__mem.html new file mode 100644 index 00000000..1b13b227 --- /dev/null +++ b/group__maug__mem.html @@ -0,0 +1,203 @@ + + + + + + + +maug: Memory Management API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Memory Management API
+
+
+ + + + +

+Files

file  mmem.h
 
+ + + + + + + + + + + + + + + +

+Macros

+#define maug_malloc(nmemb, sz)   malloc( sz * nmemb )
 
#define maug_mrealloc(handle, nmemb, sz)   realloc( handle, (sz) * (nmemb) )
 
+#define maug_mzero(ptr, sz)   memset( ptr, '\0', sz )
 
+#define maug_mfree(handle)   free( handle ); handle = NULL;
 
+#define maug_mlock(handle, ptr)   ptr = handle; handle = NULL;
 
+#define maug_munlock(handle, ptr)   handle = ptr; ptr = NULL;
 
#define maug_mrealloc_test(new_handle, handle, nmemb, sz)
 
+ + + +

+Typedefs

+typedef void * MAUG_MHANDLE
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ maug_mrealloc

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_mrealloc( handle,
 nmemb,
 sz 
)   realloc( handle, (sz) * (nmemb) )
+
+

\warn This does not test that reallocation was successful! Use maug_mrealloc_test() for that.

+ +
+
+ +

◆ maug_mrealloc_test

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_mrealloc_test( new_handle,
 handle,
 nmemb,
 sz 
)
+
+Value:
maug_cleanup_if_lt_overflow( (sz) * (nmemb), sz ); \
+
new_handle = maug_mrealloc( handle, nmemb, sz ); \
+
maug_cleanup_if_null_alloc( MAUG_MHANDLE, new_handle ); \
+
handle = new_handle;
+
#define maug_mrealloc(handle, nmemb, sz)
Definition mmem.h:27
+
+
+
+
+ + + + diff --git a/group__maug__retroflt.html b/group__maug__retroflt.html new file mode 100644 index 00000000..6a37fa56 --- /dev/null +++ b/group__maug__retroflt.html @@ -0,0 +1,544 @@ + + + + + + + +maug: RetroFlat API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat API
+
+
+ +

Abstraction layer header for retro systems. +More...

+
+Collaboration diagram for RetroFlat API:
+
+
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Modules

 RetroFlat Example
 An extremely simple single-file annotated example program written with the RetroFlat API.
 
 RetroFlat Compilation
 Makefile examples and compiler considerations for using RetroFlat.
 
 RetroFlat Colors
 Color definitions RetroFlat is aware of, for use with the RetroFlat Drawing API.
 
 RetroFlat API Return Values
 Standardized return values from RetroFlat API functions.
 
 RetroFlat Drawing API
 Functions for drawing primitives on-screen.
 
 Global Flags
 Flags that may be present on RETROFLAT_STATE::retroflat_flags.
 
 RetroFlat Config API
 Tools for loading and saving config data between sessions.
 
 RetroFlat Message API
 
 RetroFlat VDP API
 Video Display Processor tools for modifying display output.
 
 RetroFlat Bitmap API
 Tools for loading bitmaps from disk and drawing them on-screen.
 
 RetroFlat Input API
 Functions and constants for polling and interpreting user input.
 
+ + + + +

+Files

file  retroflt.h
 Abstraction layer header for retro systems.
 
+ + + + + + + +

+Data Structures

struct  RETROFLAT_ARGS
 Struct containing configuration values for a RetroFlat program. More...
 
struct  RETROFLAT_STATE
 Global singleton containing state for the current platform. More...
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define bmp_read_uint32(b)   (*((uint32_t*)(b)))
 
+#define RETROFLAT_GL_Z   -0.001
 
#define retroflat_on_resize(w, h)
 
+#define retroflat_screen_w()
 Get the current screen width in pixels.
 
+#define retroflat_screen_h()
 Get the current screen height in pixels.
 
+#define retroflat_screen_buffer()   (&(g_retroflat_state->buffer))
 Get the direct screen buffer or the VDP buffer if a VDP is loaded.
 
#define retroflat_quit(retval_in)
 This should be called in order to quit a program using RetroFlat.
 
#define retroflat_opengl_push(x, y, x_f, y_f, aspect_f)
 
#define retroflat_opengl_whf(w, h, w_f, h_f, aspect_f)
 
#define retroflat_opengl_pop()
 
+#define RETROFLAT_COLOR_TABLE_CONSTS(idx, name_l, name_u, r, g, b)    extern MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u;
 
+ + + + +

+Typedefs

+typedef void(* retroflat_loop_iter) (void *data)
 Prototype for the main loop function passed to retroflat_loop().
 
+ + + + + + + + + + + + + + + + + + + +

+Functions

+MERROR_RETVAL retroflat_loop (retroflat_loop_iter iter, void *data)
 This should be called once in the main body of the program in order to enter the main loop. The main loop will continuously call loop_iter with data as an argument until retroflat_quit() is called.
 
void retroflat_message (uint8_t flags, const char *title, const char *format,...)
 Display a message in a dialog box and/or on stderr.
 
MERROR_RETVAL retroflat_init (int argc, char *argv[], struct RETROFLAT_ARGS *args)
 Initialize RetroFlat and its underlying layers. This should be called once at the beginning of the program and should quit if the return value indicates any failures.
 
void retroflat_shutdown (int retval)
 Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the program, after retroflat_loop().
 
+void retroflat_set_title (const char *format,...)
 
+uint32_t retroflat_get_ms ()
 
+uint32_t retroflat_get_rand ()
 
+ + + + + +

+Variables

+MAUG_CONST char * gc_retroflat_color_names []
 
+struct RETROFLAT_STATEg_retroflat_state
 
+

Detailed Description

+

Abstraction layer header for retro systems.

+

Macro Definition Documentation

+ +

◆ retroflat_on_resize

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define retroflat_on_resize( w,
 
)
+
+Value:
g_retroflat_state->screen_w = w; \
+
g_retroflat_state->screen_h = h;
+
+
+
+ +

◆ retroflat_opengl_pop

+ +
+
+ + + + + + + +
#define retroflat_opengl_pop()
+
+Value:
/* Restore modelview. */ \
+
glPopMatrix(); \
+
glMatrixMode( GL_MODELVIEW );
+
+
+
+ +

◆ retroflat_opengl_push

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define retroflat_opengl_push( x,
 y,
 x_f,
 y_f,
 aspect_f 
)
+
+Value:
/* Switch to projection setup. */ \
+
glMatrixMode( GL_PROJECTION ); \
+
glPushMatrix(); \
+
/* Lighting makes overlay text hard to see. */ \
+
glDisable( GL_LIGHTING ); \
+
/* Use ortho for overlay. */ \
+
glLoadIdentity(); \
+
aspect_f = (float)retroflat_screen_w() / (float)retroflat_screen_h(); \
+
glOrtho( -1.0f * aspect_f, aspect_f, -1.0f, 1.0f, 0, 10.0f ); \
+
/* -1 to 1 is 2! */ \
+
aspect_f *= 2.0f; \
+
/* Assuming width > height for aspect ratio. */ \
+
x_f = ((x) * aspect_f / retroflat_screen_w()) - (aspect_f / 2); \
+
/* Vertical coords also need to be inverted because OpenGL. */ \
+
y_f = 1.0f - ((y) * 2.0f / retroflat_screen_h()); \
+
#define retroflat_screen_h()
Get the current screen height in pixels.
Definition retroflt.h:1627
+
#define retroflat_screen_w()
Get the current screen width in pixels.
Definition retroflt.h:1624
+
+
+
+ +

◆ retroflat_opengl_whf

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define retroflat_opengl_whf( w,
 h,
 w_f,
 h_f,
 aspect_f 
)
+
+Value:
w_f = ((w) * aspect_f / retroflat_screen_w()); \
+
h_f = ((h) * 2.0f / retroflat_screen_h());
+
+
+
+ +

◆ retroflat_quit

+ +
+
+ + + + + + + + +
#define retroflat_quit( retval_in)
+
+ +

This should be called in order to quit a program using RetroFlat.

+
Parameters
+ + +
retvalThe return value to pass back to the operating system.
+
+
+ +
+
+

Function Documentation

+ +

◆ retroflat_init()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
MERROR_RETVAL retroflat_init (int argc,
char * argv[],
struct RETROFLAT_ARGSargs 
)
+
+ +

Initialize RetroFlat and its underlying layers. This should be called once at the beginning of the program and should quit if the return value indicates any failures.

+
Returns
RETROFLAT_OK if there were no problems or other RetroFlat API Return Values if there were.
+ +
+
+ +

◆ retroflat_message()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_message (uint8_t flags,
const char * title,
const char * format,
 ... 
)
+
+ +

Display a message in a dialog box and/or on stderr.

+
Parameters
+ + + +
titleA string with the title to use for a dialog box.
formatA format string to be passed to vsnprintf().
+
+
+
Todo:
This should display a dialog box on every platform if possible.
+ +
+
+ +

◆ retroflat_shutdown()

+ +
+
+ + + + + + + + +
void retroflat_shutdown (int retval)
+
+ +

Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the program, after retroflat_loop().

+
Parameters
+ + +
retvalReturn value from retroflat_init(), so we know what layers are in what state.
+
+
+ +
+
+
+ + + + diff --git a/group__maug__retroflt.map b/group__maug__retroflt.map new file mode 100644 index 00000000..7c341a92 --- /dev/null +++ b/group__maug__retroflt.map @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/group__maug__retroflt.md5 b/group__maug__retroflt.md5 new file mode 100644 index 00000000..5b490707 --- /dev/null +++ b/group__maug__retroflt.md5 @@ -0,0 +1 @@ +410c865cdcb9a7848e623072ee11a672 \ No newline at end of file diff --git a/group__maug__retroflt.png b/group__maug__retroflt.png new file mode 100644 index 00000000..1fd6f619 Binary files /dev/null and b/group__maug__retroflt.png differ diff --git a/group__maug__retroflt__bitmap.html b/group__maug__retroflt__bitmap.html new file mode 100644 index 00000000..ee4c24dc --- /dev/null +++ b/group__maug__retroflt__bitmap.html @@ -0,0 +1,310 @@ + + + + + + + +maug: RetroFlat Bitmap API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Bitmap API
+
+
+ +

Tools for loading bitmaps from disk and drawing them on-screen. +More...

+
+Collaboration diagram for RetroFlat Bitmap API:
+
+
+ + + + +
+ + + + + +

+Data Structures

struct  RETROFLAT_BITMAP
 Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine if a valid bitmap is loaded. More...
 
+ + + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROFLAT_FLAGS_SCREEN_LOCK   0x02
 
+#define RETROFLAT_BITMAP_EXT   "bmp"
 The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap(). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_OPENGL_BPP   32
 
+#define RETROFLAT_TXP_R   0x00
 Compiler-define-overridable constant indicating the Red value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_TXP_G   0x00
 Compiler-define-overridable constant indicating the Green value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_TXP_B   0x00
 Compiler-define-overridable constant indicating the Blue value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
 
+#define retroflat_bitmap_ok(bitmap)   (NULL != (bitmap)->b)
 Check to see if a bitmap is loaded.
 
+ + + + + + + + + + + + + + + +

+Functions

MERROR_RETVAL retroflat_load_bitmap (const char *filename, struct RETROFLAT_BITMAP *bmp_out)
 Load a bitmap into the given RETROFLAT_BITMAP structure if it is available. Bitmaps are subject to the limitations enumerated in RetroFlat Bitmap API.
 
+MERROR_RETVAL retroflat_create_bitmap (size_t w, size_t h, struct RETROFLAT_BITMAP *bmp_out, uint8_t flags)
 
+MERROR_RETVAL retroflat_load_xpm (const char *filename, struct RETROFLAT_BITMAP *bmp_out)
 Load a compiled-in XPM image into an API-specific bitmap context. \warn The XPM must have been generated from a bitmap using the rather restrictive RetroFlat Bitmap API rules.
 
void retroflat_destroy_bitmap (struct RETROFLAT_BITMAP *bitmap)
 Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on the stack).
 
void retroflat_blit_bitmap (struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, int s_x, int s_y, int d_x, int d_y, int w, int h)
 Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP.
 
+

Detailed Description

+

Tools for loading bitmaps from disk and drawing them on-screen.

+

Bitmaps handled by retroflat are subject to certain constraints, due to the limitations of the underyling layers:

+ +

RETROFLAT_BITMAP structs loaded with retroflat_load_bitmap() should later be freed using retroflat_destroy_bitmap().

+

Locking from the RetroFlat Drawing API also applies here. Please see that page for more information on retroflat_draw_lock() and retroflat_draw_release().

+
Warning
The screen MUST be locked by calling retroflat_draw_lock() with NULL before it is drawn to, and released with retroflat_draw_release() when drawing is finished before the retroflat_loop_iter() ends!
+

Function Documentation

+ +

◆ retroflat_blit_bitmap()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_blit_bitmap (struct RETROFLAT_BITMAPtarget,
struct RETROFLAT_BITMAPsrc,
int s_x,
int s_y,
int d_x,
int d_y,
int w,
int h 
)
+
+ +

Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP.

+
Parameters
+ + + + + + + + + +
targetPointer to the RETROFLAT_BITMAP to blit src onto.
srcPointer to the RETROFLAT_BITMAP to blit onto target.
s_xLeft X coordinate to blit starting from on the source bitmap.
s_yTop Y coordinate to blit starting from on the source bitmap.
d_xLeft X coordinate to blit to on the target bitmap.
d_yTop Y coordinate to blit to on the target bitmap.
wPixel width of the region to blit.
hPixel height of the region to blit.
+
+
+
Todo:
Currently s_x, s_y, w, and h are not functional on all platforms!
+ +
+
+ +

◆ retroflat_destroy_bitmap()

+ +
+
+ + + + + + + + +
void retroflat_destroy_bitmap (struct RETROFLAT_BITMAPbitmap)
+
+ +

Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on the stack).

+
Parameters
+ + +
bitmapPointer to the RETROFLAT_BITMAP to unload.
+
+
+ +
+
+ +

◆ retroflat_load_bitmap()

+ +
+
+ + + + + + + + + + + + + + + + + + +
MERROR_RETVAL retroflat_load_bitmap (const char * filename,
struct RETROFLAT_BITMAPbmp_out 
)
+
+ +

Load a bitmap into the given RETROFLAT_BITMAP structure if it is available. Bitmaps are subject to the limitations enumerated in RetroFlat Bitmap API.

+
Parameters
+ + + +
filenameFilename of the bitmap under RETROFLAT_ARGS::assets_path with no separator, ".", or RETROFLAT_BITMAP_EXT.
bmp_outPointer to a RETROFLAT_BITMAP to load the bitmap into.
+
+
+
Returns
RETROFLAT_OK if the bitmap was loaded or RETROFLAT_ERROR_TIMER if there was a problem (e.g. the bitmap was not found).
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__bitmap.map b/group__maug__retroflt__bitmap.map new file mode 100644 index 00000000..5d4fc694 --- /dev/null +++ b/group__maug__retroflt__bitmap.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__bitmap.md5 b/group__maug__retroflt__bitmap.md5 new file mode 100644 index 00000000..1176ba3a --- /dev/null +++ b/group__maug__retroflt__bitmap.md5 @@ -0,0 +1 @@ +081c8dcbadcf7bfb4c7565a2550d789d \ No newline at end of file diff --git a/group__maug__retroflt__bitmap.png b/group__maug__retroflt__bitmap.png new file mode 100644 index 00000000..ecf6051a Binary files /dev/null and b/group__maug__retroflt__bitmap.png differ diff --git a/group__maug__retroflt__color.html b/group__maug__retroflt__color.html new file mode 100644 index 00000000..3c11c1e4 --- /dev/null +++ b/group__maug__retroflt__color.html @@ -0,0 +1,206 @@ + + + + + + + +maug: RetroFlat Colors + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ + +
+
+ +

Color definitions RetroFlat is aware of, for use with the RetroFlat Drawing API. +More...

+
+Collaboration diagram for RetroFlat Colors:
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

#define RETROFLAT_COLOR_TABLE(f)
 
+#define RETROFLAT_COLOR_NULL   (-1)
 
+#define RETROFLAT_COLORS_SZ   16
 
+#define RETROFLAT_COLOR_BLACK   0
 
+#define RETROFLAT_COLOR_DARKBLUE   1
 
+#define RETROFLAT_COLOR_DARKGREEN   2
 
+#define RETROFLAT_COLOR_TEAL   3
 
+#define RETROFLAT_COLOR_DARKRED   4
 
+#define RETROFLAT_COLOR_VIOLET   5
 
+#define RETROFLAT_COLOR_BROWN   6
 
+#define RETROFLAT_COLOR_GRAY   7
 
+#define RETROFLAT_COLOR_DARKGRAY   8
 
+#define RETROFLAT_COLOR_BLUE   9
 
+#define RETROFLAT_COLOR_GREEN   10
 
+#define RETROFLAT_COLOR_CYAN   11
 
+#define RETROFLAT_COLOR_RED   12
 
+#define RETROFLAT_COLOR_MAGENTA   13
 
+#define RETROFLAT_COLOR_YELLOW   14
 
+#define RETROFLAT_COLOR_WHITE   15
 
+ + + + + +

+Typedefs

+typedef int8_t RETROFLAT_COLOR
 
+typedef int RETROFLAT_COLOR_DEF
 
+

Detailed Description

+

Color definitions RetroFlat is aware of, for use with the RetroFlat Drawing API.

+

The precise type and values of these constants vary by platform.

+

Macro Definition Documentation

+ +

◆ RETROFLAT_COLOR_TABLE

+ +
+
+ + + + + + + + +
#define RETROFLAT_COLOR_TABLE( f)
+
+Value:
f( 0, black, BLACK, 0, 0, 0 ) \
+
f( 1, darkblue, DARKBLUE, 0, 0, 170 ) \
+
f( 2, darkgreen, DARKGREEN, 0, 170, 0 ) \
+
f( 3, teal, TEAL, 0, 170, 170 ) \
+
f( 4, darkred, DARKRED, 170, 0, 0 ) \
+
f( 5, violet, VIOLET, 170, 0, 170 ) \
+
f( 6, brown, BROWN, 170, 85, 0 ) \
+
f( 7, gray, GRAY, 170, 170, 170 ) \
+
f( 8, darkgray, DARKGRAY, 85, 85, 85 ) \
+
f( 9, blue, BLUE, 85, 85, 255 ) \
+
f( 10, green, GREEN, 85, 255, 85 ) \
+
f( 11, cyan, CYAN, 85, 255, 255 ) \
+
f( 12, red, RED, 255, 85, 85 ) \
+
f( 13, magenta, MAGENTA, 255, 85, 255 ) \
+
f( 14, yellow, YELLOW, 255, 255, 85 ) \
+
f( 15, white, WHITE, 255, 255, 255 )
+
+
+
+
+ + + + diff --git a/group__maug__retroflt__color.map b/group__maug__retroflt__color.map new file mode 100644 index 00000000..95590f23 --- /dev/null +++ b/group__maug__retroflt__color.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__retroflt__color.md5 b/group__maug__retroflt__color.md5 new file mode 100644 index 00000000..14169e49 --- /dev/null +++ b/group__maug__retroflt__color.md5 @@ -0,0 +1 @@ +9313ca6bba6ae8ec2087e31069dc0a18 \ No newline at end of file diff --git a/group__maug__retroflt__color.png b/group__maug__retroflt__color.png new file mode 100644 index 00000000..04f4d515 Binary files /dev/null and b/group__maug__retroflt__color.png differ diff --git a/group__maug__retroflt__compiling.html b/group__maug__retroflt__compiling.html new file mode 100644 index 00000000..a08e9343 --- /dev/null +++ b/group__maug__retroflt__compiling.html @@ -0,0 +1,279 @@ + + + + + + + +maug: RetroFlat Compilation + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Compilation
+
+
+ +

Makefile examples and compiler considerations for using RetroFlat. +More...

+
+Collaboration diagram for RetroFlat Compilation:
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

#define RETROFLAT_FPS   30
 Target Frames Per Second.
 
+#define retroflat_fps_next()   (1000 / RETROFLAT_FPS)
 
+#define RETROFLAT_WINDOW_CLASS   "RetroFlatWindowClass"
 Unique window class to use on some platforms (e.g. Win32). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_WIN_GFX_TIMER_ID   6001
 Unique ID for the timer that execute graphics ticks in Win16/Win32. Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_MSG_MAX   4096
 Maximum number of characters possible in a message using retroflat_message(). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_PATH_MAX   256
 Maximum size allocated for asset paths.
 
+#define RETROFLAT_TITLE_MAX   255
 
#define RETROFLAT_VDP_ARGS_SZ_MAX   255
 
+#define RETROFLAT_PATH_SEP   '/'
 The valid path separator on the target platform.
 
+#define RETROFLAT_ASSETS_PATH_MAX   (RETROFLAT_PATH_MAX / 2)
 Maximum size of the assets path, to allow room for appending.
 
+#define NDS_OAM_ACTIVE   &oamMain
 Active sprite engine screen on Nintendo DS.
 
+#define NDS_SPRITES_ACTIVE   24
 Maximum number of sprites active on-screen on Nintendo DS.
 
+#define RETROFLAT_CONFIG_LN_SZ_MAX   255
 
+#define RETROFLAT_CONFIG_EXT   ".ini"
 
+#define RETROFLAT_BMP_COLORS_SZ_MAX   256
 
+

Detailed Description

+

Makefile examples and compiler considerations for using RetroFlat.

+ + +

RetroFlat Compiler Definitions

Certain options can be configured when a RetroFlat program is compiled by passing definitions with the compiler using the -D flag, or by #define-ing them before retroflt.h is included in the source files.

OS Selection Definitions

+These are mutually exclusive. It's best to specify them, in case RetroFlat can't figure it out from the compiler options. + + + + + + + + +
Define Description
RETROFLAT_OS_WIN Specify that the program will run on Windows.
RETROFLAT_OS_DOS Specify that the program will run on DOS.
RETROFLAT_OS_UNIX Specify that the program will run on UNIX/Linux.
+

API/Library Selection Definitions

+These are mutually exclusive. + + + + + + + + + + + + +
Define Description
RETROFLAT_API_ALLEGRO Specify that the program will link Allegro.
RETROFLAT_API_SDL1 Specify that the program will link SDL 1.2.
RETROFLAT_API_SDL2 Specify that the program will link SDL 2.
RETROFLAT_API_WIN16 Specify that the program will use Win 3.1x API.
RETROFLAT_API_WIN32 Specify that the program will use Win32/NT API.
+

Option Definitions

+These are NOT mutually exclusive. + + + + + + + + + + + + + + +
Define Description
RETROFLAT_MOUSE Force-enable mouse on broken APIs (DANGEROUS!)
RETROFLAT_TXP_R Specify R component of bitmap transparent color.
RETROFLAT_TXP_G Specify G component of bitmap transparent color.
RETROFLAT_TXP_B Specify B component of bitmap transparent color.
RETROFLAT_BITMAP_EXT Specify file extension for bitmap assets.
RETROFLAT_RESIZABLE Allow resizing the RetroFlat window.
+
+ +

RetroFlat Project Makefiles

Win16 (OpenWatcom)

+Compiling projects for Win16 requires the OpenWatcom compiler from https://github.com/open-watcom/open-watcom-v2. Other compilers may work, but this is the only one that has been tested. No other specific libraries are required. The Windows API is used directly.Outlined below is a basic GNU Makefile for using OpenWatcom to cross-compile a Win16 application under GNU/Linux. This Makefile assumes the following variable definitions from the environment:
    +
  • $WATCOM should be set to the path where the OpenWatcom compiler has been extracted, containing the binw, binl, h, and lib386 directories (among others).
  • +
  • $PATH should contain $WATCOM/bin, so that the wcc386 and accompanying tools below can be executed.
  • +
+For an example of the main.c file, please see RetroFlat Example.The Makefile is as follows:

  # A list of C files included in the project. These must be provided
+  # by you. In this example, our program only has one file.
+  EXAMPLE_C_FILES := main.c
+
+  # A basic set of defines to instruct RetroFlat to use The Win16 API on
+  # the (target) Windows OS.
+  DEFINES := -DRETROFLAT_OS_WIN -DRETROFLAT_API_WIN16
+
+  # Including the defines above, these flags will be passed to the C
+  # compiler in the rules, below. The -i flags specify that we want
+  # to include the Windows headers from OpenWatcom, as well as the
+  # RetroFlat header directory located in ./maug/src. The
+  # -bt=windows flag specifies that we want to compile code for Win16.
+  CFLAGS := $(DEFINES) -bt=windows -i$(WATCOM)/h/win -imaug/src
+
+  # The only mandatory linker flag for our example is -l=win386, which
+  # instructs the Watcom linker to target the win386 32-bit Windows
+  # extender, which we will include with our executable below. This
+  # allows our program to run on Windows 3.x without us having to
+  # observe 16-bit memory constraints or deal with LocalHeaps or
+  # handle locking.
+  LDFLAGS := -l=win386
+
+  # This rule handles compiling all object files requested by the next
+  # rule from their respective C code files.
+  %.o: %.c
+     wcc386 $(CFLAGS) -fo=$@ $(<:%.c=%)
+
+  # This rule builds the intermediate LE executable to which the win386
+  # extender will be prepended. The -fe flag specifies the name of the
+  # executable to create.
+  examplew.rex: $(subst .c,.o,$(EXAMPLE_C_FILES))
+     wcl386 $(LDFLAGS) -fe=$@ $^
+
+  # This rule builds the final executable, by prepending the win386
+  # extender located in the OpenWatcom installation directory to the
+  # Intermediate file created in the previous rule.
+  examplew.exe: examplew.rex
+     wbind $< -s $(WATCOM)/binw/win386.ext -R $@
+

Macro Definition Documentation

+ +

◆ RETROFLAT_FPS

+ +
+
+ + + + +
#define RETROFLAT_FPS   30
+
+ +

Target Frames Per Second.

+
Todo:
FPS currently has no effect in Allegro.
+ +
+
+ +

◆ RETROFLAT_VDP_ARGS_SZ_MAX

+ +
+
+ + + + +
#define RETROFLAT_VDP_ARGS_SZ_MAX   255
+
+

\warn Changing this may break binary compatibility!

+ +
+
+
+ + + + diff --git a/group__maug__retroflt__compiling.map b/group__maug__retroflt__compiling.map new file mode 100644 index 00000000..5f16192c --- /dev/null +++ b/group__maug__retroflt__compiling.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__compiling.md5 b/group__maug__retroflt__compiling.md5 new file mode 100644 index 00000000..1ae7fad7 --- /dev/null +++ b/group__maug__retroflt__compiling.md5 @@ -0,0 +1 @@ +a02e13c29d727eead6f92acb184fa509 \ No newline at end of file diff --git a/group__maug__retroflt__compiling.png b/group__maug__retroflt__compiling.png new file mode 100644 index 00000000..673f3d47 Binary files /dev/null and b/group__maug__retroflt__compiling.png differ diff --git a/group__maug__retroflt__config.html b/group__maug__retroflt__config.html new file mode 100644 index 00000000..2d501420 --- /dev/null +++ b/group__maug__retroflt__config.html @@ -0,0 +1,324 @@ + + + + + + + +maug: RetroFlat Config API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Config API
+
+
+ +

Tools for loading and saving config data between sessions. +More...

+
+Collaboration diagram for RetroFlat Config API:
+
+
+ + + + + + +
+ + + + + + + +

+Modules

 RetroFlat Config Buffer Types
 
 RetroFlat Config Flags
 Flags for the flags parameter of retroflat_config_open().
 
+ + + + +

+Typedefs

typedef FILE * RETROFLAT_CONFIG
 A configuration object to use with the RetroFlat Config API.
 
+ + + + + + + + + + + + +

+Functions

MERROR_RETVAL retroflat_config_open (RETROFLAT_CONFIG *config, uint8_t flags)
 Open a configuration file/registry/SRAM/etc handle.
 
+void retroflat_config_close (RETROFLAT_CONFIG *config)
 
size_t retroflat_config_write (RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer, size_t buffer_sz_max)
 Write the contents of a buffer to a config object.
 
size_t retroflat_config_read (RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer_out, size_t buffer_out_sz_max, const void *default_out, size_t default_out_sz)
 Write the contents of a buffer to a config object.
 
+

Detailed Description

+

Tools for loading and saving config data between sessions.

+

Typedef Documentation

+ +

◆ RETROFLAT_CONFIG

+ +
+
+ + + + +
typedef FILE* RETROFLAT_CONFIG
+
+ +

A configuration object to use with the RetroFlat Config API.

+

This is a file by default, but may be different things (e.g. a registry key or battery-backed SRAM block) on different platforms.

+ +
+
+

Function Documentation

+ +

◆ retroflat_config_open()

+ +
+
+ + + + + + + + + + + + + + + + + + +
MERROR_RETVAL retroflat_config_open (RETROFLAT_CONFIGconfig,
uint8_t flags 
)
+
+ +

Open a configuration file/registry/SRAM/etc handle.

+
Parameters
+ + +
flagsRetroFlat Config Flags to open config with.
+
+
+ +
+
+ +

◆ retroflat_config_read()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
size_t retroflat_config_read (RETROFLAT_CONFIGconfig,
const char * sect_name,
const char * key_name,
uint8_t buffer_type,
void * buffer_out,
size_t buffer_out_sz_max,
const void * default_out,
size_t default_out_sz 
)
+
+ +

Write the contents of a buffer to a config object.

+
Warning
The config object must have been opened with the RETROFLAT_CONFIG_FLAG_W flag disabled!
+
Parameters
+ + + +
buffer_typeRetroFlat Config Buffer Types of the buffer provided.
buffer_out_sz_maxSize of the buffer provided in bytes.
+
+
+ +
+
+ +

◆ retroflat_config_write()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
size_t retroflat_config_write (RETROFLAT_CONFIGconfig,
const char * sect_name,
const char * key_name,
uint8_t buffer_type,
void * buffer,
size_t buffer_sz_max 
)
+
+ +

Write the contents of a buffer to a config object.

+
Warning
The config object must have been opened with the RETROFLAT_CONFIG_FLAG_W flag enabled!
+
Parameters
+ + + +
buffer_typeRetroFlat Config Buffer Types of the buffer provided.
buffer_sz_maxSize of the buffer provided in bytes.
+
+
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__config.map b/group__maug__retroflt__config.map new file mode 100644 index 00000000..9006b74c --- /dev/null +++ b/group__maug__retroflt__config.map @@ -0,0 +1,6 @@ + + + + + + diff --git a/group__maug__retroflt__config.md5 b/group__maug__retroflt__config.md5 new file mode 100644 index 00000000..046176f7 --- /dev/null +++ b/group__maug__retroflt__config.md5 @@ -0,0 +1 @@ +75860e0c5c6ea1128a45a9ce3918d37e \ No newline at end of file diff --git a/group__maug__retroflt__config.png b/group__maug__retroflt__config.png new file mode 100644 index 00000000..9a200dd6 Binary files /dev/null and b/group__maug__retroflt__config.png differ diff --git a/group__maug__retroflt__config__btypes.html b/group__maug__retroflt__config__btypes.html new file mode 100644 index 00000000..5104a8f9 --- /dev/null +++ b/group__maug__retroflt__config__btypes.html @@ -0,0 +1,111 @@ + + + + + + + +maug: RetroFlat Config Buffer Types + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Config Buffer Types
+
+
+
+Collaboration diagram for RetroFlat Config Buffer Types:
+
+
+ + + + +
+ + + + + + + + + + +

+Macros

+#define RETROFLAT_BUFFER_INT   0x00
 
+#define RETROFLAT_BUFFER_STRING   0x01
 
+#define RETROFLAT_BUFFER_FLOAT   0x02
 
+#define RETROFLAT_BUFFER_BOOL   0x04
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__retroflt__config__btypes.map b/group__maug__retroflt__config__btypes.map new file mode 100644 index 00000000..a5962a6d --- /dev/null +++ b/group__maug__retroflt__config__btypes.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__config__btypes.md5 b/group__maug__retroflt__config__btypes.md5 new file mode 100644 index 00000000..b018c6b0 --- /dev/null +++ b/group__maug__retroflt__config__btypes.md5 @@ -0,0 +1 @@ +00b07ef46d1f66368b9328df26af16e5 \ No newline at end of file diff --git a/group__maug__retroflt__config__btypes.png b/group__maug__retroflt__config__btypes.png new file mode 100644 index 00000000..24a62680 Binary files /dev/null and b/group__maug__retroflt__config__btypes.png differ diff --git a/group__maug__retroflt__config__flags.html b/group__maug__retroflt__config__flags.html new file mode 100644 index 00000000..336862a3 --- /dev/null +++ b/group__maug__retroflt__config__flags.html @@ -0,0 +1,129 @@ + + + + + + + +maug: RetroFlat Config Flags + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Config Flags
+
+
+ +

Flags for the flags parameter of retroflat_config_open(). +More...

+
+Collaboration diagram for RetroFlat Config Flags:
+
+
+ + + + +
+ + + + + + + + +

+Macros

#define RETROFLAT_CONFIG_FLAG_W   0x01
 Flag indicating config object should be opened for WRITING only.
 
+#define RETROFLAT_CONFIG_FLAG_BIN   0x02
 Flag indicating config object holds BINARY data.
 
+

Detailed Description

+

Flags for the flags parameter of retroflat_config_open().

+

Macro Definition Documentation

+ +

◆ RETROFLAT_CONFIG_FLAG_W

+ +
+
+ + + + +
#define RETROFLAT_CONFIG_FLAG_W   0x01
+
+ +

Flag indicating config object should be opened for WRITING only.

+

If this is not specified, the buffer will only be opened for READING.

+

These modes are mutually exclusive! A config object must be closed and reopened to switch between READING and WRITING!

+ +
+
+
+ + + + diff --git a/group__maug__retroflt__config__flags.map b/group__maug__retroflt__config__flags.map new file mode 100644 index 00000000..a4180dcb --- /dev/null +++ b/group__maug__retroflt__config__flags.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__config__flags.md5 b/group__maug__retroflt__config__flags.md5 new file mode 100644 index 00000000..881728b8 --- /dev/null +++ b/group__maug__retroflt__config__flags.md5 @@ -0,0 +1 @@ +b7dec93bc64770fd4b0d32d632595e4a \ No newline at end of file diff --git a/group__maug__retroflt__config__flags.png b/group__maug__retroflt__config__flags.png new file mode 100644 index 00000000..0cfadb67 Binary files /dev/null and b/group__maug__retroflt__config__flags.png differ diff --git a/group__maug__retroflt__drawing.html b/group__maug__retroflt__drawing.html new file mode 100644 index 00000000..d8550338 --- /dev/null +++ b/group__maug__retroflt__drawing.html @@ -0,0 +1,571 @@ + + + + + + + +maug: RetroFlat Drawing API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Drawing API
+
+
+ +

Functions for drawing primitives on-screen. +More...

+
+Collaboration diagram for RetroFlat Drawing API:
+
+
+ + + + + +
+ + + + + +

+Modules

 RetroFlat Colors
 Color definitions RetroFlat is aware of, for use with the RetroFlat Drawing API.
 
+ + + + + + + + + + + + + + + +

+Macros

+#define RETROFLAT_FLAGS_FILL   0x01
 Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
 
+#define RETROFLAT_FLAGS_OPAQUE   0x01
 Flag for retroflat_create_bitmap() to create a bitmap without transparency.
 
#define RETROFLAT_FLAGS_SCREEN_BUFFER   0x80
 Flag for retroflat_create_bitmap() to create a WinG-backed bitmap.
 
+#define RETROFLAT_LINE_THICKNESS   1
 Line drawing thickness (only works on some platforms). Is a RetroFlat Compiler Definitions.
 
+#define RETROFLAT_PI   3.14159
 
+ + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

MERROR_RETVAL retroflat_draw_lock (struct RETROFLAT_BITMAP *bmp)
 Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly, but performance should improve if done before a batch of drawing operations.
 
+MERROR_RETVAL retroflat_draw_release (struct RETROFLAT_BITMAP *bmp)
 
+void retroflat_px (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, uint8_t flags)
 
void retroflat_rect (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
 Draw a rectangle onto the target RETROFLAT_BITMAP.
 
void retroflat_ellipse (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
 Draw an ellipse onto the target RETROFLAT_BITMAP.
 
void retroflat_line (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
 Draw a straight line onto the target RETROFLAT_BITMAP.
 
+void retroflat_cursor (struct RETROFLAT_BITMAP *target, uint8_t flags)
 
void retroflat_string_sz (struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, size_t *w_out, size_t *h_out, uint8_t flags)
 Get the size in pixels of a text string when drawn with a given font by retroflat_string().
 
void retroflat_string (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int x_orig, int y_orig, uint8_t flags)
 Draw a text string at the specified location in the specified font and color on the target RETROFLAT_BITMAP.
 
+

Detailed Description

+

Functions for drawing primitives on-screen.

+
Warning
Drawing functions should not be used outside of the context of the main loop, as the platform may not have fully initialized the drawing window until the main loop is called for the first time!
+

Macro Definition Documentation

+ +

◆ RETROFLAT_FLAGS_SCREEN_BUFFER

+ +
+
+ + + + +
#define RETROFLAT_FLAGS_SCREEN_BUFFER   0x80
+
+ +

Flag for retroflat_create_bitmap() to create a WinG-backed bitmap.

+

Also may be present in RETROFLAT_BITMAP::flags to indicate that a bitmap is screen-backed.

+ +
+
+

Function Documentation

+ +

◆ retroflat_draw_lock()

+ +
+
+ + + + + + + + +
MERROR_RETVAL retroflat_draw_lock (struct RETROFLAT_BITMAPbmp)
+
+ +

Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly, but performance should improve if done before a batch of drawing operations.

+
Parameters
+ + +
bmpPointer to a RETROFLAT_BITMAP struct to lock. If this is NULL, try to lock the screen.
+
+
+
Returns
RETROFLAT_OK if lock was successful or RetroFlat API Return Values otherwise.
+ +
+
+ +

◆ retroflat_ellipse()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_ellipse (struct RETROFLAT_BITMAPtarget,
const RETROFLAT_COLOR color,
int x,
int y,
int w,
int h,
uint8_t flags 
)
+
+ +

Draw an ellipse onto the target RETROFLAT_BITMAP.

+
Parameters
+ + + + + + +
targetPointer to the RETROFLAT_BITMAP to draw onto, or NULL to draw to the screen buffer.
colorRetroFlat Colors in which to draw.
xLeft X coordinate in pixels at which to draw on the target bitmap.
yTop Y coordinate in pixels at which to draw on the target bitmap.
flagsFlags to control drawing. The following flags apply: RETROFLAT_FLAGS_FILL
+
+
+ +
+
+ +

◆ retroflat_line()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_line (struct RETROFLAT_BITMAPtarget,
const RETROFLAT_COLOR color,
int x1,
int y1,
int x2,
int y2,
uint8_t flags 
)
+
+ +

Draw a straight line onto the target RETROFLAT_BITMAP.

+
Parameters
+ + + + + + + + +
targetPointer to the RETROFLAT_BITMAP to draw onto, or NULL to draw to the screen buffer.
x1Left X coordinate of the line to draw on the target bitmap.
y1Top Y coordinate of the line to draw on the target bitmap.
x2Right X coordinate of the line to draw on the target bitmap.
y2Bottom Y coordinate of the line to draw on the target bitmap.
colorRetroFlat Colors in which to draw.
flagsFlags to control drawing. No flags currently apply.
+
+
+ +
+
+ +

◆ retroflat_rect()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_rect (struct RETROFLAT_BITMAPtarget,
const RETROFLAT_COLOR color,
int x,
int y,
int w,
int h,
uint8_t flags 
)
+
+ +

Draw a rectangle onto the target RETROFLAT_BITMAP.

+
Parameters
+ + + + + + +
targetPointer to the RETROFLAT_BITMAP to draw onto, or NULL to draw to the screen buffer.
colorRetroFlat Colors in which to draw.
xLeft X coordinate in pixels at which to draw on the target bitmap.
yTop Y coordinate in pixels at which to draw on the target bitmap.
flagsFlags to control drawing. The following flags apply: RETROFLAT_FLAGS_FILL
+
+
+ +
+
+ +

◆ retroflat_string()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_string (struct RETROFLAT_BITMAPtarget,
const RETROFLAT_COLOR color,
const char * str,
int str_sz,
const char * font_str,
int x_orig,
int y_orig,
uint8_t flags 
)
+
+ +

Draw a text string at the specified location in the specified font and color on the target RETROFLAT_BITMAP.

+
Warning
Font specifications for font_str may vary by platform, so be sure to test with #ifdefs for each!
+
Parameters
+ + + + + + + + + +
targetPointer to the RETROFLAT_BITMAP to draw onto, or NULL to draw to the screen buffer.
colorRetroFlat Colors in which to draw.
strThe text string to draw to the target bitmap.
str_szLength of the string to draw in characters.
font_strName of the font in which to draw the string.
x_origLeft X coordinate in pixels at which to draw on the target bitmap.
y_origTop Y coordinate in pixels at which to draw on the target bitmap.
flagsFlags to control drawing. No flags currently apply.
+
+
+ +
+
+ +

◆ retroflat_string_sz()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroflat_string_sz (struct RETROFLAT_BITMAPtarget,
const char * str,
size_t str_sz,
const char * font_str,
size_t * w_out,
size_t * h_out,
uint8_t flags 
)
+
+ +

Get the size in pixels of a text string when drawn with a given font by retroflat_string().

+
Warning
Font specifications for font_str may vary by platform, so be sure to test with #ifdefs for each!
+
Parameters
+ + + + + + + +
targetPointer to the RETROFLAT_BITMAP on which drawing is planned.
strThe text string to get the size of.
str_szLength of the string to get the size of in characters.
font_strName of the font in which to size the string.
w_outPointer to an int in which to store the string width in pixels.
h_outPointer to an int in which to store the string height in pixels.
+
+
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__drawing.map b/group__maug__retroflt__drawing.map new file mode 100644 index 00000000..0ba42003 --- /dev/null +++ b/group__maug__retroflt__drawing.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__retroflt__drawing.md5 b/group__maug__retroflt__drawing.md5 new file mode 100644 index 00000000..7ed0c611 --- /dev/null +++ b/group__maug__retroflt__drawing.md5 @@ -0,0 +1 @@ +a0ef89a1f1e9c331dc414cf82c193c65 \ No newline at end of file diff --git a/group__maug__retroflt__drawing.png b/group__maug__retroflt__drawing.png new file mode 100644 index 00000000..312cdd3a Binary files /dev/null and b/group__maug__retroflt__drawing.png differ diff --git a/group__maug__retroflt__example.html b/group__maug__retroflt__example.html new file mode 100644 index 00000000..a1182d66 --- /dev/null +++ b/group__maug__retroflt__example.html @@ -0,0 +1,192 @@ + + + + + + + +maug: RetroFlat Example + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
RetroFlat Example
+
+
+ +

An extremely simple single-file annotated example program written with the RetroFlat API. +

+
+Collaboration diagram for RetroFlat Example:
+
+
+ + + + +
+

An extremely simple single-file annotated example program written with the RetroFlat API.

+ + +

maug_retroflt_example_page

This is a brief example program written for the RetroFlat API.This can be compiled using the Makefiles from RetroFlat Compilation.
  / * RETROFLT_C must be defined before including retroflt.h ONLY
+    * in one project file! It must be defined once, and only once,
+    * project-wide! The C file where it is defined is where all the
+    * RetroFlat functions will be placed.
+    * /
+  #define RETROFLT_C
+  #include <retroflt.h>
+
+  / * An example struct containing data fields to be retained between
+    * loop iterations below.
+    * /
+  struct EXAMPLE_DATA {
+     int example;
+  };
+
+  / * This is the loop iteration which will be repeatedly called
+    * by retroflat_loop() below, until retroflat_quit() is called.
+    * /
+  void example_loop( struct EXAMPLE_DATA* data ) {
+     struct RETROFLAT_INPUT input_evt;
+     int input = 0;
+
+     / * Start loop. * /
+     input = retroflat_poll_input( &input_evt );
+
+     switch( input ) {
+     case RETROFLAT_MOUSE_B_LEFT:
+        / * Left mouse button was clicked, do something! * /
+        break;
+
+     case RETROFLAT_KEY_Q:
+        / * Q key was pressed, so quit! * /
+        retroflat_quit( 0 );
+        break;
+     }
+
+     / *  === Drawing === * /
+
+     / * Lock the screen (NULL) for drawing. * /
+     retroflat_draw_lock( NULL );
+
+     / * Clear the screen by drawing a big gray rectangle to NULL. * /
+     retroflat_rect(
+        NULL, RETROFLAT_COLOR_GRAY, 0, 0,
+        retroflat_screen_w(), retroflat_screen_h(),
+        RETROFLAT_FLAGS_FILL );
+
+     / * Release the screen (NULL) from drawing. * /
+     retroflat_draw_release( NULL );
+  }
+
+  int main( int argc, char* argv[] ) {
+     int retval = 0;
+     struct EXAMPLE_DATA data;
+     struct RETROFLAT_ARGS args;
+
+     / * Setup the args to retroflat_init() below to create a window 
+       * titled "Example Program", 320x200 pixels large, and load
+       * bitmaps from the "assets" subdirectory next to the executable.
+       * /
+     args.screen_w = 320;
+     args.screen_h = 200;
+     args.title = "Example Program";
+     args.assets_path = "assets";
+
+     / * Zero out the data holder. * /
+     memset( &data, '\0', sizeof( struct EXAMPLE_DATA ) );
+
+     / * === Setup === * /
+     / * Call the init with the args struct created above. * /
+     retval = retroflat_init( argc, argv, &args );
+
+     / * Make sure setup completed successfully! * /
+     if( RETROFLAT_OK != retval ) {
+        goto cleanup;
+     }
+
+     / * === Main Loop === * /
+     / * Call example_loop( data ) repeatedly, until it calls
+       * retroflat_quit().
+       * /
+     retroflat_loop( (retroflat_loop_iter)example_loop, &data );
+
+  cleanup:
+
+     / * This must be called at the end of the program! * /
+     retroflat_shutdown( retval );
+
+     return retval;
+  }
+  / * This should ALWAYS be included after main(), no matter what
+    * platform your program is intended for.
+    * /
+  END_OF_MAIN()
+
+ + + + diff --git a/group__maug__retroflt__example.map b/group__maug__retroflt__example.map new file mode 100644 index 00000000..86310c13 --- /dev/null +++ b/group__maug__retroflt__example.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__example.md5 b/group__maug__retroflt__example.md5 new file mode 100644 index 00000000..0e5fd670 --- /dev/null +++ b/group__maug__retroflt__example.md5 @@ -0,0 +1 @@ +ffce6aa9c3bbc7d387de54a73c449463 \ No newline at end of file diff --git a/group__maug__retroflt__example.png b/group__maug__retroflt__example.png new file mode 100644 index 00000000..cd5e2903 Binary files /dev/null and b/group__maug__retroflt__example.png differ diff --git a/group__maug__retroflt__flags.html b/group__maug__retroflt__flags.html new file mode 100644 index 00000000..ded9bd5e --- /dev/null +++ b/group__maug__retroflt__flags.html @@ -0,0 +1,184 @@ + + + + + + + +maug: Global Flags + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Global Flags
+
+
+ +

Flags that may be present on RETROFLAT_STATE::retroflat_flags. +More...

+
+Collaboration diagram for Global Flags:
+
+
+ + + + +
+ + + + + + + + + + + + + + +

+Macros

#define RETROFLAT_FLAGS_RUNNING   0x01
 Flag indicating that retroflat_loop() should continue executing.
 
#define RETROFLAT_FLAGS_UNLOCK_FPS   0x02
 Flag indicating FPS should not be capped.
 
#define RETROFLAT_FLAGS_KEY_REPEAT   0x04
 Flag indicating keyboard repeat is enabled.
 
#define RETROFLAT_FLAGS_SCREENSAVER   0x08
 Flag indicating the current application is running as a screensaver.
 
+

Detailed Description

+

Flags that may be present on RETROFLAT_STATE::retroflat_flags.

+

Macro Definition Documentation

+ +

◆ RETROFLAT_FLAGS_KEY_REPEAT

+ +
+
+ + + + +
#define RETROFLAT_FLAGS_KEY_REPEAT   0x04
+
+ +

Flag indicating keyboard repeat is enabled.

+
Warning
This flag should only be set inside retroflat!
+ +
+
+ +

◆ RETROFLAT_FLAGS_RUNNING

+ +
+
+ + + + +
#define RETROFLAT_FLAGS_RUNNING   0x01
+
+ +

Flag indicating that retroflat_loop() should continue executing.

+
Warning
This flag is not used on all platforms! It should only be removed using retroflat_quit().
+ +
+
+ +

◆ RETROFLAT_FLAGS_SCREENSAVER

+ +
+
+ + + + +
#define RETROFLAT_FLAGS_SCREENSAVER   0x08
+
+ +

Flag indicating the current application is running as a screensaver.

+
Warning
This flag should only be set inside retroflat!
+ +
+
+ +

◆ RETROFLAT_FLAGS_UNLOCK_FPS

+ +
+
+ + + + +
#define RETROFLAT_FLAGS_UNLOCK_FPS   0x02
+
+ +

Flag indicating FPS should not be capped.

+
Warning
This flag should only be set inside retroflat!
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__flags.map b/group__maug__retroflt__flags.map new file mode 100644 index 00000000..f1ccb252 --- /dev/null +++ b/group__maug__retroflt__flags.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__flags.md5 b/group__maug__retroflt__flags.md5 new file mode 100644 index 00000000..0d42a942 --- /dev/null +++ b/group__maug__retroflt__flags.md5 @@ -0,0 +1 @@ +15a6e84850bd1c6d7f572d3b3bee4ce8 \ No newline at end of file diff --git a/group__maug__retroflt__flags.png b/group__maug__retroflt__flags.png new file mode 100644 index 00000000..33f1d78e Binary files /dev/null and b/group__maug__retroflt__flags.png differ diff --git a/group__maug__retroflt__input.html b/group__maug__retroflt__input.html new file mode 100644 index 00000000..2b06b6dd --- /dev/null +++ b/group__maug__retroflt__input.html @@ -0,0 +1,279 @@ + + + + + + + +maug: RetroFlat Input API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Input API
+
+
+ +

Functions and constants for polling and interpreting user input. +More...

+
+Collaboration diagram for RetroFlat Input API:
+
+
+ + + + + +
+ + + + + +

+Modules

 RetroFlat Key Definitions
 Keyboard and mouse controls RetroFlat is aware of, for use within the RetroFlat Input API.
 
+ + + + +

+Data Structures

struct  RETROFLAT_INPUT
 Struct passed to retroflat_poll_input() to hold return data. More...
 
+ + + + + + + + + + + + + + + +

+Macros

#define retroflat_buffer_bksp(buffer, buffer_cur, buffer_sz)
 Remove a character from a text buffer before cursor position.
 
#define retroflat_buffer_insert(c, buffer, buffer_cur, buffer_sz, buffer_mx)
 Insert a character into a text buffer at cursor position.
 
+#define RETROFLAT_INPUT_MOD_SHIFT   0x01
 
+#define RETROFLAT_INPUT_MOD_ALT   0x02
 
+#define RETROFLAT_INPUT_MOD_CTRL   0x04
 
+#define RETROFLAT_INPUT_FORCE_UPPER   0x08
 
+ + + + +

+Functions

int retroflat_poll_input (struct RETROFLAT_INPUT *input)
 Poll input devices (keyboard/mouse) and return the latest event.
 
+

Detailed Description

+

Functions and constants for polling and interpreting user input.

+

Macro Definition Documentation

+ +

◆ retroflat_buffer_bksp

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define retroflat_buffer_bksp( buffer,
 buffer_cur,
 buffer_sz 
)
+
+Value:
if( 0 < buffer_cur ) { \
+
if( buffer_cur < buffer_sz ) { \
+
memmove( \
+
&(buffer[(buffer_cur) - 1]), \
+
&(buffer[buffer_cur]), \
+
(buffer_sz) - (buffer_cur) ); \
+
} \
+
buffer_cur--; \
+
buffer_sz--; \
+
buffer[buffer_sz] = '\0'; \
+
}
+
+

Remove a character from a text buffer before cursor position.

+ +
+
+ +

◆ retroflat_buffer_insert

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define retroflat_buffer_insert( c,
 buffer,
 buffer_cur,
 buffer_sz,
 buffer_mx 
)
+
+Value:
if( buffer_sz + 1 < buffer_mx ) { \
+
if( buffer_cur < buffer_sz ) { \
+
memmove( \
+
&(buffer[(buffer_cur) + 1]), \
+
&(buffer[buffer_cur]), \
+
(buffer_sz) - (buffer_cur) ); \
+
} \
+
buffer[buffer_cur] = c; \
+
buffer_cur++; \
+
buffer_sz++; \
+
buffer[buffer_sz] = '\0'; \
+
}
+
+

Insert a character into a text buffer at cursor position.

+ +
+
+

Function Documentation

+ +

◆ retroflat_poll_input()

+ +
+
+ + + + + + + + +
int retroflat_poll_input (struct RETROFLAT_INPUTinput)
+
+ +

Poll input devices (keyboard/mouse) and return the latest event.

+
Parameters
+ + +
inputPointer to a RETROFLAT_INPUT struct to store extended info.
+
+
+
Returns
A symbol from RetroFlat Key Definitions.
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__input.map b/group__maug__retroflt__input.map new file mode 100644 index 00000000..feb6a92d --- /dev/null +++ b/group__maug__retroflt__input.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__retroflt__input.md5 b/group__maug__retroflt__input.md5 new file mode 100644 index 00000000..229c85f3 --- /dev/null +++ b/group__maug__retroflt__input.md5 @@ -0,0 +1 @@ +29ceb240f59f3f158e89e04bbde386de \ No newline at end of file diff --git a/group__maug__retroflt__input.png b/group__maug__retroflt__input.png new file mode 100644 index 00000000..22fc9fc5 Binary files /dev/null and b/group__maug__retroflt__input.png differ diff --git a/group__maug__retroflt__keydefs.html b/group__maug__retroflt__keydefs.html new file mode 100644 index 00000000..1dd4d6d5 --- /dev/null +++ b/group__maug__retroflt__keydefs.html @@ -0,0 +1,248 @@ + + + + + + + +maug: RetroFlat Key Definitions + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Key Definitions
+
+
+ +

Keyboard and mouse controls RetroFlat is aware of, for use within the RetroFlat Input API. +More...

+
+Collaboration diagram for RetroFlat Key Definitions:
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROFLAT_KEY_UP   0
 
+#define RETROFLAT_KEY_DOWN   0
 
+#define RETROFLAT_KEY_RIGHT   0
 
+#define RETROFLAT_KEY_LEFT   0
 
+#define RETROFLAT_KEY_A   0x41
 
+#define RETROFLAT_KEY_B   0x42
 
+#define RETROFLAT_KEY_C   0x43
 
+#define RETROFLAT_KEY_D   0x44
 
+#define RETROFLAT_KEY_E   0x45
 
+#define RETROFLAT_KEY_F   0x46
 
+#define RETROFLAT_KEY_G   0x47
 
+#define RETROFLAT_KEY_H   0x48
 
+#define RETROFLAT_KEY_I   0x49
 
+#define RETROFLAT_KEY_J   0x4a
 
+#define RETROFLAT_KEY_K   0x4b
 
+#define RETROFLAT_KEY_L   0x4c
 
+#define RETROFLAT_KEY_M   0x4d
 
+#define RETROFLAT_KEY_N   0x4e
 
+#define RETROFLAT_KEY_O   0x4f
 
+#define RETROFLAT_KEY_P   0x50
 
+#define RETROFLAT_KEY_Q   0x51
 
+#define RETROFLAT_KEY_R   0x52
 
+#define RETROFLAT_KEY_S   0x53
 
+#define RETROFLAT_KEY_T   0x54
 
+#define RETROFLAT_KEY_U   0x55
 
+#define RETROFLAT_KEY_V   0x56
 
+#define RETROFLAT_KEY_W   0x57
 
+#define RETROFLAT_KEY_X   0x58
 
+#define RETROFLAT_KEY_Y   0x59
 
+#define RETROFLAT_KEY_Z   0x60
 
+#define RETROFLAT_KEY_0   0x30
 
+#define RETROFLAT_KEY_1   0x31
 
+#define RETROFLAT_KEY_2   0x32
 
+#define RETROFLAT_KEY_3   0x33
 
+#define RETROFLAT_KEY_4   0x34
 
+#define RETROFLAT_KEY_5   0x35
 
+#define RETROFLAT_KEY_6   0x36
 
+#define RETROFLAT_KEY_7   0x37
 
+#define RETROFLAT_KEY_8   0x38
 
+#define RETROFLAT_KEY_9   0x39
 
+#define RETROFLAT_KEY_TAB   0
 
+#define RETROFLAT_KEY_SPACE   0
 
+#define RETROFLAT_KEY_ESC   0
 
+#define RETROFLAT_KEY_ENTER   0
 
+#define RETROFLAT_KEY_HOME   0
 
+#define RETROFLAT_KEY_END   0
 
+#define RETROFLAT_MOUSE_B_LEFT   0
 
+#define RETROFLAT_MOUSE_B_RIGHT   0
 
+

Detailed Description

+

Keyboard and mouse controls RetroFlat is aware of, for use within the RetroFlat Input API.

+

The precise type and values of these constants vary by platform.

+
+ + + + diff --git a/group__maug__retroflt__keydefs.map b/group__maug__retroflt__keydefs.map new file mode 100644 index 00000000..ed06ad4b --- /dev/null +++ b/group__maug__retroflt__keydefs.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__keydefs.md5 b/group__maug__retroflt__keydefs.md5 new file mode 100644 index 00000000..80c89a8e --- /dev/null +++ b/group__maug__retroflt__keydefs.md5 @@ -0,0 +1 @@ +100d556cf04979cc3e815863fa2f0bab \ No newline at end of file diff --git a/group__maug__retroflt__keydefs.png b/group__maug__retroflt__keydefs.png new file mode 100644 index 00000000..a3cff0a7 Binary files /dev/null and b/group__maug__retroflt__keydefs.png differ diff --git a/group__maug__retroflt__msg__api.html b/group__maug__retroflt__msg__api.html new file mode 100644 index 00000000..4805ecfe --- /dev/null +++ b/group__maug__retroflt__msg__api.html @@ -0,0 +1,111 @@ + + + + + + + +maug: RetroFlat Message API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat Message API
+
+
+
+Collaboration diagram for RetroFlat Message API:
+
+
+ + + + +
+ + + + + + + + + + +

+Macros

+#define RETROFLAT_MSG_FLAG_TYPE_MASK   0x07
 
+#define RETROFLAT_MSG_FLAG_ERROR   0x01
 
+#define RETROFLAT_MSG_FLAG_INFO   0x02
 
+#define RETROFLAT_MSG_FLAG_WARNING   0x04
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__retroflt__msg__api.map b/group__maug__retroflt__msg__api.map new file mode 100644 index 00000000..2085daa7 --- /dev/null +++ b/group__maug__retroflt__msg__api.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__msg__api.md5 b/group__maug__retroflt__msg__api.md5 new file mode 100644 index 00000000..8eba6dd7 --- /dev/null +++ b/group__maug__retroflt__msg__api.md5 @@ -0,0 +1 @@ +daf57abaafe7a7b21f32e1b7f1a02ebc \ No newline at end of file diff --git a/group__maug__retroflt__msg__api.png b/group__maug__retroflt__msg__api.png new file mode 100644 index 00000000..69a84d02 Binary files /dev/null and b/group__maug__retroflt__msg__api.png differ diff --git a/group__maug__retroflt__retval.html b/group__maug__retroflt__retval.html new file mode 100644 index 00000000..116d5872 --- /dev/null +++ b/group__maug__retroflt__retval.html @@ -0,0 +1,123 @@ + + + + + + + +maug: RetroFlat API Return Values + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat API Return Values
+
+
+ +

Standardized return values from RetroFlat API functions. +More...

+
+Collaboration diagram for RetroFlat API Return Values:
+
+
+ + + + +
+ + + + + + + + + + + + + + + + +

+Macros

+#define RETROFLAT_OK   0x00
 Certain functions return this when there was no problem.
 
+#define RETROFLAT_ERROR_ENGINE   0x01
 
+#define RETROFLAT_ERROR_GRAPHICS   0x02
 
+#define RETROFLAT_ERROR_MOUSE   0x04
 
+#define RETROFLAT_ERROR_BITMAP   0x08
 Returned if there is a problem loading or locking a RETROFLAT_BITMAP struct.
 
+#define RETROFLAT_ERROR_TIMER   0x0f
 
+

Detailed Description

+

Standardized return values from RetroFlat API functions.

+
+ + + + diff --git a/group__maug__retroflt__retval.map b/group__maug__retroflt__retval.map new file mode 100644 index 00000000..e1224d00 --- /dev/null +++ b/group__maug__retroflt__retval.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__retval.md5 b/group__maug__retroflt__retval.md5 new file mode 100644 index 00000000..eeb599e8 --- /dev/null +++ b/group__maug__retroflt__retval.md5 @@ -0,0 +1 @@ +9ed33f0dfbd6efe455242e483f11297a \ No newline at end of file diff --git a/group__maug__retroflt__retval.png b/group__maug__retroflt__retval.png new file mode 100644 index 00000000..f2cd1275 Binary files /dev/null and b/group__maug__retroflt__retval.png differ diff --git a/group__maug__retroflt__vdp.html b/group__maug__retroflt__vdp.html new file mode 100644 index 00000000..c431e2de --- /dev/null +++ b/group__maug__retroflt__vdp.html @@ -0,0 +1,160 @@ + + + + + + + +maug: RetroFlat VDP API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroFlat VDP API
+
+
+ +

Video Display Processor tools for modifying display output. +More...

+
+Collaboration diagram for RetroFlat VDP API:
+
+
+ + + + +
+ + + + + +

+Macros

#define RETROFLAT_VDP_FLAG_PXLOCK   0x01
 Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame before passing it (almost always true!)
 
+ + + + +

+Typedefs

typedef MERROR_RETVAL(* retroflat_vdp_proc_t) (struct RETROFLAT_STATE *)
 VDP function called from the VDP library.
 
+

Detailed Description

+

Video Display Processor tools for modifying display output.

+

The VDP system allows for a plugin to post-process frames in programs that use RetroFlat. The VDP is provided with a bitmap of every frame in RETROFLAT_STATE::vdp_buffer which it processes and outputs to RETROFLAT_STATE::buffer.

+

Macro Definition Documentation

+ +

◆ RETROFLAT_VDP_FLAG_PXLOCK

+ +
+
+ + + + +
#define RETROFLAT_VDP_FLAG_PXLOCK   0x01
+
+ +

Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame before passing it (almost always true!)

+

This should be set by the VDP during its initialization.

+ +
+
+

Typedef Documentation

+ +

◆ retroflat_vdp_proc_t

+ +
+
+ + + + +
typedef MERROR_RETVAL(* retroflat_vdp_proc_t) (struct RETROFLAT_STATE *)
+
+ +

VDP function called from the VDP library.

+

The VDP plugin should export three functions with this signature:

+ + + + + + + + + +
Function Name Called From
retroflat_vdp_init() retroflat_init()
retroflat_vdp_flip() retroflat_draw_release() on screen buffer
retroflat_vdp_shutdown retroflat_shutdown()
+ +
+
+
+ + + + diff --git a/group__maug__retroflt__vdp.map b/group__maug__retroflt__vdp.map new file mode 100644 index 00000000..084488b8 --- /dev/null +++ b/group__maug__retroflt__vdp.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroflt__vdp.md5 b/group__maug__retroflt__vdp.md5 new file mode 100644 index 00000000..9b431099 --- /dev/null +++ b/group__maug__retroflt__vdp.md5 @@ -0,0 +1 @@ +4cf07cfcc5781078809cdbe549a4b326 \ No newline at end of file diff --git a/group__maug__retroflt__vdp.png b/group__maug__retroflt__vdp.png new file mode 100644 index 00000000..692eff8d Binary files /dev/null and b/group__maug__retroflt__vdp.png differ diff --git a/group__maug__retrofp.html b/group__maug__retrofp.html new file mode 100644 index 00000000..20bef4b3 --- /dev/null +++ b/group__maug__retrofp.html @@ -0,0 +1,125 @@ + + + + + + + +maug: Maug Retro Fixed Point + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Maug Retro Fixed Point
+
+
+ + + + + +

+Files

file  retrofp.h
 Contains functions and macros for working with fixed-point numbers.
 
+ + + + + + + + +

+Macros

+#define RETROFP_PI   (3141)
 Fixed-point representation of Pi (3.141).
 
+#define retrofp_sin(num, mult)   retrofp_lut( g_retrofp_sin, num, mult )
 
+#define retrofp_cos(num, mult)   retrofp_lut( g_retrofp_cos, num, mult )
 
+ + + + +

+Functions

+int16_t retrofp_lut (const int16_t *lut, int16_t num, int16_t mult)
 Given a lookup table, return the corresponding value after trimming precision and making sure number is valid.
 
+ + + + + +

+Variables

+MAUG_CONST int16_t g_retrofp_cos []
 
+MAUG_CONST int16_t g_retrofp_sin []
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__retroglu.html b/group__maug__retroglu.html new file mode 100644 index 00000000..dddf942c --- /dev/null +++ b/group__maug__retroglu.html @@ -0,0 +1,287 @@ + + + + + + + +maug: RetroGLU API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGLU API
+
+
+ +

Library of tools for working with RetroFlat and OpenGL. +More...

+
+Collaboration diagram for RetroGLU API:
+
+
+ + + + + +
+ + + + + + +

+Modules

 RetroGLU OBJ Parser
 
 RetroGLU Sprites
 
+ + + + +

+Files

file  retroglu.h
 Library of tools for working with RetroFlat and OpenGL.
 
+ + + + + + + + + + + + + +

+Data Structures

struct  RETROGLU_VERTEX
 
struct  RETROGLU_VTEXTURE
 
struct  RETROGLU_MATERIAL
 
struct  RETROGLU_FACE
 
struct  RETROGLU_OBJ
 
struct  RETROGLU_PROJ_ARGS
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROGLU_PARSER_ERROR   -1
 
+#define RETROGLU_PARSER_TOKEN_SZ_MAX   32
 
+#define RETROGLU_TRACE_LVL   0
 
+#define RETROGLU_SPRITE_TEX_FRAMES_SZ   10
 
+#define RETROGLU_FLAGS_INIT_VERTICES   0x01
 
+#define glShininessf(side, light, f)   glMaterialf( side, light, f )
 
+#define RETROGLU_FACE_VERTICES_SZ_MAX   3
 
+#define RETROGLU_MATERIAL_NAME_SZ_MAX   32
 
+#define RETROGLU_MATERIAL_LIB_SZ_MAX   32
 
+#define RETROGLU_VERTICES_SZ_MAX   1024
 
+#define RETROGLU_FACES_SZ_MAX   1024
 
+#define RETROGLU_MATERIALS_SZ_MAX   1024
 
+#define RETROGLU_PROJ_ORTHO   0
 
+#define RETROGLU_PROJ_FRUSTUM   1
 
+#define retroglu_tex_px_x_to_f(px, sprite)    ((px) * 1.0 / sprite->texture.tex.w)
 
+#define retroglu_tex_px_y_to_f(px, sprite)    ((px) * 1.0 / sprite->texture.tex.h)
 
+#define retroglu_scr_px_x_to_f(px)    (float)(((px) * 1.0 / (retroflat_screen_w() / 2)) - 1.0)
 
+#define retroglu_scr_px_y_to_f(py)    (float)(((py) * 1.0 / (retroflat_screen_h() / 2)) - 1.0)
 
#define retroglu_set_sprite_tex(sprite, texture_id, bmp_w, bmp_h)
 
+#define retroglu_set_sprite_color(sprite, color_in)    memcpy( (sprite)->color, (color_in), 3 * sizeof( float ) )
 
+#define RETROFLAT_COLOR_TABLE_GL(idx, name_l, name_u, r, g, b)    extern MAUG_CONST float RETROGLU_COLOR_ ## name_u[];
 
+ + + +

+Typedefs

+typedef float RETROGLU_COLOR[4]
 
+ + + + + + + + + + + + + + + + + + + + + + + +

+Functions

+MERROR_RETVAL retroglu_load_tex_bmp (const char *filename, uint32_t *p_texture_id, uint32_t *p_bmp_w, uint32_t *p_bmp_h)
 
+int retroglu_load_tex_bmp_data (const uint8_t *bmp_buf, uint32_t bmp_buf_sz, uint32_t *p_texture_id, uint32_t *p_bmp_w, uint32_t *p_bmp_h)
 
+void retroglu_draw_poly (struct RETROGLU_OBJ *obj)
 
+void retroglu_set_tile_clip (struct RETROGLU_TILE *tile, uint32_t px, uint32_t py, uint32_t pw, uint32_t ph, uint8_t flags)
 
+void retroglu_set_sprite_clip (struct RETROGLU_SPRITE *sprite, uint32_t front_px, uint32_t front_py, uint32_t back_px, uint32_t back_py, uint32_t pw, uint32_t ph, uint8_t flags)
 
+void retroglu_set_sprite_pos (struct RETROGLU_SPRITE *sprite, uint32_t px, uint32_t py)
 
+void retroglu_tsrot_sprite (struct RETROGLU_SPRITE *sprite)
 
+void retroglu_draw_sprite (struct RETROGLU_SPRITE *sprite)
 
+void retroglu_free_sprite (struct RETROGLU_SPRITE *sprite)
 
+MERROR_RETVAL retroglu_init_glyph_tex ()
 
+void retroglu_string (float x, float y, float z, const RETROGLU_COLOR color, const char *str, int str_sz, const char *font_str, uint8_t flags)
 
+

Detailed Description

+

Library of tools for working with RetroFlat and OpenGL.

+

Macro Definition Documentation

+ +

◆ retroglu_set_sprite_tex

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define retroglu_set_sprite_tex( sprite,
 texture_id,
 bmp_w,
 bmp_h 
)
+
+Value:
sprite->texture_id = texture_id; \
+
sprite->texture_w = bmp_w; \
+
sprite->texture_h = bmp_h; \
+
sprite->scale_x = 1.0f; \
+
sprite->scale_y = 1.0f;
+
+
+
+
+ + + + diff --git a/group__maug__retroglu.map b/group__maug__retroglu.map new file mode 100644 index 00000000..20c5ab3b --- /dev/null +++ b/group__maug__retroglu.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__retroglu.md5 b/group__maug__retroglu.md5 new file mode 100644 index 00000000..2a3f41df --- /dev/null +++ b/group__maug__retroglu.md5 @@ -0,0 +1 @@ +e92e0ea99ad0a0ad7fd287cfc6dfc52c \ No newline at end of file diff --git a/group__maug__retroglu.png b/group__maug__retroglu.png new file mode 100644 index 00000000..861ca72c Binary files /dev/null and b/group__maug__retroglu.png differ diff --git a/group__maug__retroglu__obj__fsm.html b/group__maug__retroglu__obj__fsm.html new file mode 100644 index 00000000..33e112c9 --- /dev/null +++ b/group__maug__retroglu__obj__fsm.html @@ -0,0 +1,312 @@ + + + + + + + +maug: RetroGLU OBJ Parser + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGLU OBJ Parser
+
+
+
+Collaboration diagram for RetroGLU OBJ Parser:
+
+
+ + + + + +
+ + + + +

+Modules

 RetroGLU OBJ Parser States
 
+ + + + +

+Data Structures

struct  RETROGLU_PARSER
 As retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information. More...
 
+ + + + + + + +

+Macros

#define retroglu_parser_state(parser, new_state)
 Change the parser state.
 
#define RETROGLU_OBJ_TOKENS(f)
 Table of OBJ file tokens understood by the parser.
 
+ + + + + + +

+Typedefs

+typedef int(* retroglu_mtl_cb) (const char *filename, struct RETROGLU_PARSER *parser, void *data)
 Callback to execute when its associate in RETROGLU_OBJ_TOKENS is found in an OBJ file.
 
+typedef int(* retroglu_token_cb) (struct RETROGLU_PARSER *parser)
 
+ + + + + + + + + + + + + +

+Functions

+void retroglu_init_scene (uint8_t flags)
 
+void retroglu_init_projection (struct RETROGLU_PROJ_ARGS *args)
 
+MERROR_RETVAL retroglu_parse_obj_file (const char *filename, struct RETROGLU_PARSER *parser, struct RETROGLU_OBJ *obj)
 
void retroglu_parse_init (struct RETROGLU_PARSER *parser, struct RETROGLU_OBJ *obj, retroglu_mtl_cb load_mtl, void *load_mtl_data)
 Initialize a RETROGLU_PARSER.
 
MERROR_RETVAL retroglu_parse_obj_c (struct RETROGLU_PARSER *parser, unsigned char c)
 Parse OBJ data into a parser, one character at a time.
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ RETROGLU_OBJ_TOKENS

+ +
+
+ + + + + + + + +
#define RETROGLU_OBJ_TOKENS( f)
+
+Value:
f( "v", retroglu_token_vertice ) \
+
f( "vn", retroglu_token_vnormal ) \
+
f( "f", retroglu_token_face ) \
+
f( "usemtl", retroglu_token_usemtl ) \
+
f( "newmtl", retroglu_token_newmtl ) \
+
f( "mtllib", retroglu_token_mtllib ) \
+
f( "Kd", retroglu_token_kd ) \
+
f( "Ka", retroglu_token_ka ) \
+
f( "Ks", retroglu_token_ks ) \
+
f( "Ke", retroglu_token_ks ) \
+
f( "Ns", retroglu_token_ns )
+
+

Table of OBJ file tokens understood by the parser.

+ +
+
+ +

◆ retroglu_parser_state

+ +
+
+ + + + + + + + + + + + + + + + + + +
#define retroglu_parser_state( parser,
 new_state 
)
+
+Value:
debug_printf( \
+
RETROGLU_TRACE_LVL, "changing parser to state: %d\n", new_state ); \
+
(parser)->state = new_state;
+
+

Change the parser state.

+
Parameters
+ + + +
Pointerto the RETROGLU_PARSER to modify.
new_stateRetroGLU OBJ Parser States to set the parser to.
+
+
+ +
+
+

Function Documentation

+ +

◆ retroglu_parse_init()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void retroglu_parse_init (struct RETROGLU_PARSERparser,
struct RETROGLU_OBJobj,
retroglu_mtl_cb load_mtl,
void * load_mtl_data 
)
+
+related
+
+ +

Initialize a RETROGLU_PARSER.

+
Warning
This should be run before retroglu_parse_obj_c() is called on the parser!
+ +
+
+ +

◆ retroglu_parse_obj_c()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
MERROR_RETVAL retroglu_parse_obj_c (struct RETROGLU_PARSERparser,
unsigned char c 
)
+
+related
+
+ +

Parse OBJ data into a parser, one character at a time.

+

Generally, this should loop over a character array loaded from an OBJ file.

+ +
+
+
+ + + + diff --git a/group__maug__retroglu__obj__fsm.map b/group__maug__retroglu__obj__fsm.map new file mode 100644 index 00000000..e57d6cfa --- /dev/null +++ b/group__maug__retroglu__obj__fsm.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__retroglu__obj__fsm.md5 b/group__maug__retroglu__obj__fsm.md5 new file mode 100644 index 00000000..6694bdfa --- /dev/null +++ b/group__maug__retroglu__obj__fsm.md5 @@ -0,0 +1 @@ +c9e3260cc6ffbb8342f15c4edc496a9f \ No newline at end of file diff --git a/group__maug__retroglu__obj__fsm.png b/group__maug__retroglu__obj__fsm.png new file mode 100644 index 00000000..cfff1b3b Binary files /dev/null and b/group__maug__retroglu__obj__fsm.png differ diff --git a/group__maug__retroglu__obj__fsm__states.html b/group__maug__retroglu__obj__fsm__states.html new file mode 100644 index 00000000..cce24124 --- /dev/null +++ b/group__maug__retroglu__obj__fsm__states.html @@ -0,0 +1,201 @@ + + + + + + + +maug: RetroGLU OBJ Parser States + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGLU OBJ Parser States
+
+
+
+Collaboration diagram for RetroGLU OBJ Parser States:
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROGLU_PARSER_STATE_NONE   0
 
+#define RETROGLU_PARSER_STATE_VERTEX_X   1
 
+#define RETROGLU_PARSER_STATE_VERTEX_Y   2
 
+#define RETROGLU_PARSER_STATE_VERTEX_Z   3
 
+#define RETROGLU_PARSER_STATE_COMMENT   4
 
+#define RETROGLU_PARSER_STATE_FACE_TOKEN   5
 
+#define RETROGLU_PARSER_STATE_FACE_VERTEX   6
 
+#define RETROGLU_PARSER_STATE_FACE_TEXTURE   7
 
+#define RETROGLU_PARSER_STATE_FACE_NORMAL   8
 
+#define RETROGLU_PARSER_STATE_FACE_MATERIAL   9
 
+#define RETROGLU_PARSER_STATE_MATERIAL_NAME   10
 
+#define RETROGLU_PARSER_STATE_MATERIAL_AMB   11
 
+#define RETROGLU_PARSER_STATE_MATERIAL_DIF   12
 
+#define RETROGLU_PARSER_STATE_MATERIAL_SPEC   13
 
+#define RETROGLU_PARSER_STATE_MATERIAL_LIB   14
 
+#define RETROGLU_PARSER_STATE_MTL_KD_R   15
 
+#define RETROGLU_PARSER_STATE_MTL_KD_G   16
 
+#define RETROGLU_PARSER_STATE_MTL_KD_B   17
 
+#define RETROGLU_PARSER_STATE_VNORMAL_X   18
 
+#define RETROGLU_PARSER_STATE_VNORMAL_Y   19
 
+#define RETROGLU_PARSER_STATE_VNORMAL_Z   20
 
+#define RETROGLU_PARSER_STATE_VTEXTURE_X   21
 
+#define RETROGLU_PARSER_STATE_VTEXTURE_Y   22
 
+#define RETROGLU_PARSER_STATE_VTEXTURE_Z   23
 
+#define RETROGLU_PARSER_STATE_MTL_KA_R   24
 
+#define RETROGLU_PARSER_STATE_MTL_KA_G   25
 
+#define RETROGLU_PARSER_STATE_MTL_KA_B   26
 
+#define RETROGLU_PARSER_STATE_MTL_KS_R   27
 
+#define RETROGLU_PARSER_STATE_MTL_KS_G   28
 
+#define RETROGLU_PARSER_STATE_MTL_KS_B   29
 
+#define RETROGLU_PARSER_STATE_MTL_KE_R   30
 
+#define RETROGLU_PARSER_STATE_MTL_KE_G   31
 
+#define RETROGLU_PARSER_STATE_MTL_KE_B   32
 
+#define RETROGLU_PARSER_STATE_MTL_NS   33
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__retroglu__obj__fsm__states.map b/group__maug__retroglu__obj__fsm__states.map new file mode 100644 index 00000000..0ef61f3c --- /dev/null +++ b/group__maug__retroglu__obj__fsm__states.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroglu__obj__fsm__states.md5 b/group__maug__retroglu__obj__fsm__states.md5 new file mode 100644 index 00000000..733cc6c5 --- /dev/null +++ b/group__maug__retroglu__obj__fsm__states.md5 @@ -0,0 +1 @@ +c5f3633b7ea68c8a6adf8276985f1b94 \ No newline at end of file diff --git a/group__maug__retroglu__obj__fsm__states.png b/group__maug__retroglu__obj__fsm__states.png new file mode 100644 index 00000000..46060b01 Binary files /dev/null and b/group__maug__retroglu__obj__fsm__states.png differ diff --git a/group__maug__retroglu__sprite.html b/group__maug__retroglu__sprite.html new file mode 100644 index 00000000..b8a8a6fa --- /dev/null +++ b/group__maug__retroglu__sprite.html @@ -0,0 +1,113 @@ + + + + + + + +maug: RetroGLU Sprites + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGLU Sprites
+
+
+
+Collaboration diagram for RetroGLU Sprites:
+
+
+ + + + +
+ + + + + + +

+Data Structures

struct  RETROGLU_SPRITE
 
struct  RETROGLU_TILE
 
+ + + + + +

+Macros

+#define RETROGLU_SPRITE_X   0
 
+#define RETROGLU_SPRITE_Y   1
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__retroglu__sprite.map b/group__maug__retroglu__sprite.map new file mode 100644 index 00000000..ed5d5aa2 --- /dev/null +++ b/group__maug__retroglu__sprite.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retroglu__sprite.md5 b/group__maug__retroglu__sprite.md5 new file mode 100644 index 00000000..7408809e --- /dev/null +++ b/group__maug__retroglu__sprite.md5 @@ -0,0 +1 @@ +e0cadcd0f94a95933e69ab7c86182b90 \ No newline at end of file diff --git a/group__maug__retroglu__sprite.png b/group__maug__retroglu__sprite.png new file mode 100644 index 00000000..7f82234b Binary files /dev/null and b/group__maug__retroglu__sprite.png differ diff --git a/group__maug__retrogui.html b/group__maug__retrogui.html new file mode 100644 index 00000000..8156b1c6 --- /dev/null +++ b/group__maug__retrogui.html @@ -0,0 +1,282 @@ + + + + + + + +maug: RetroGUI API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGUI API
+
+
+
+Collaboration diagram for RetroGUI API:
+
+
+ + + + +
+ + + + +

+Modules

 RetroGUI Controls
 
+ + + +

+Files

file  retrogui.h
 
+ + + +

+Data Structures

struct  RETROGUI
 
+ + + + + + + + + + + + + + + + + + + + +

+Macros

+#define RETROGUI_FLAGS_DIRTY   0x01
 RETROGUI::flags indicating controls should be redrawn.
 
+#define RETROGUI_CTL_TEXT_SZ_MAX   128
 
+#define RETROGUI_CTL_SZ_MAX_INIT   10
 
+#define RETROGUI_PADDING   5
 
+#define RETROGUI_BTN_LBL_SZ_MAX   64
 
#define retrogui_lock(gui)
 
#define retrogui_unlock(gui)
 
+#define RETROGUI_IDC_NONE   0
 
+#define RETROGUI_CTL_TABLE_CONSTS(idx, c_name, c_fields)    extern MAUG_CONST uint8_t RETROGUI_CTL_TYPE_ ## c_name;
 
+ + + + + + +

+Typedefs

+typedef size_t RETROGUI_IDC
 Unique identifying constant number for controls.
 
+typedef void(* retrogui_xy_cb) (size_t *x, size_t *y, void *data)
 
+ + + + + + + + + + + + + + + + + + + + +

+Functions

+MERROR_RETVAL retrogui_push_listbox_item (struct RETROGUI *gui, RETROGUI_IDC idc, const char *item, size_t item_sz)
 
+union RETROGUI_CTLretrogui_get_ctl_by_idc (struct RETROGUI *gui, size_t idc)
 
RETROGUI_IDC retrogui_poll_ctls (struct RETROGUI *gui, int *p_input, struct RETROFLAT_INPUT *input_evt)
 Poll for the last clicked control and maintain listboxes and menus.
 
+void retrogui_redraw_ctls (struct RETROGUI *gui)
 
+MERROR_RETVAL retrogui_push_ctl (struct RETROGUI *gui, union RETROGUI_CTL *ctl)
 
+MERROR_RETVAL retrogui_get_ctl_text (struct RETROGUI *gui, RETROGUI_IDC idc, char *buffer, size_t buffer_sz)
 
+size_t retrogui_get_ctl_sel_idx (struct RETROGUI *gui, size_t idc)
 
+MERROR_RETVAL retrogui_init_ctl (union RETROGUI_CTL *ctl, uint8_t type, size_t idc)
 
+MERROR_RETVAL retrogui_init (struct RETROGUI *gui)
 
+ + + +

+Variables

+MAUG_CONST char * gc_retrogui_ctl_names []
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ retrogui_lock

+ +
+
+ + + + + + + + +
#define retrogui_lock( gui)
+
+Value:
if( NULL == (gui)->ctls ) { \
+
maug_mlock( (gui)->ctls_h, (gui)->ctls ); \
+
maug_cleanup_if_null_alloc( union RETROGUI_CTL*, (gui)->ctls ); \
+
}
+
Definition retrogui.h:106
+
+
+
+ +

◆ retrogui_unlock

+ +
+
+ + + + + + + + +
#define retrogui_unlock( gui)
+
+Value:
if( NULL != (gui)->ctls ) { \
+
maug_munlock( (gui)->ctls_h, (gui)->ctls ); \
+
}
+
+
+
+

Function Documentation

+ +

◆ retrogui_poll_ctls()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
RETROGUI_IDC retrogui_poll_ctls (struct RETROGUIgui,
int * p_input,
struct RETROFLAT_INPUTinput_evt 
)
+
+ +

Poll for the last clicked control and maintain listboxes and menus.

+
Parameters
+ + + +
inputInput integer returned from retroflat_poll_input().
input_evtRETROFLAT_INPUT initialized by retroflat_poll_input().
+
+
+
Returns
IDC of clicked control or RETROGUI_IDC_NONE if none clicked since last poll.
+ +
+
+
+ + + + diff --git a/group__maug__retrogui.map b/group__maug__retrogui.map new file mode 100644 index 00000000..1329c7bf --- /dev/null +++ b/group__maug__retrogui.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retrogui.md5 b/group__maug__retrogui.md5 new file mode 100644 index 00000000..1f3bc70e --- /dev/null +++ b/group__maug__retrogui.md5 @@ -0,0 +1 @@ +651ab8089badcae87c52b4aa07ae4c2c \ No newline at end of file diff --git a/group__maug__retrogui.png b/group__maug__retrogui.png new file mode 100644 index 00000000..7eb24db9 Binary files /dev/null and b/group__maug__retrogui.png differ diff --git a/group__maug__retrogui__ctl.html b/group__maug__retrogui__ctl.html new file mode 100644 index 00000000..f65f9c55 --- /dev/null +++ b/group__maug__retrogui__ctl.html @@ -0,0 +1,185 @@ + + + + + + + +maug: RetroGUI Controls + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
RetroGUI Controls
+
+
+
+Collaboration diagram for RetroGUI Controls:
+
+
+ + + + +
+ + + + + + + +

+Data Structures

struct  RETROGUI_CTL_BASE
 Fields common to ALL RETROGUI_CTL types. More...
 
union  RETROGUI_CTL
 
+ + + + + + + + + + +

+Macros

#define RETROGUI_CTL_TABLE(f)
 Table defining all control types and their specific fields in RETROGUI_CTL.
 
#define RETROGUI_CTL_TABLE_FIELDS(idx, c_name, c_fields)
 Creates the corresponding RETROGUI_* structs from RETROGUI_CTL_TABLE that populate union RETROGUI_CTL.
 
+#define RETROGUI_CTL_TABLE_TYPES(idx, c_name, c_fields)    struct RETROGUI_CTL_ ## c_name c_name;
 Adds the structs created by RETROGUI_CTL_TABLE_FIELDS to union RETROGUI_CTL.
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ RETROGUI_CTL_TABLE

+ +
+
+ + + + + + + + +
#define RETROGUI_CTL_TABLE( f)
+
+Value:
f( 0, NONE, void* none; ) \
+
f( 1, LISTBOX, MAUG_MHANDLE list_h; char* list; size_t list_sz; size_t list_sz_max; size_t sel_idx; ) \
+
f( 2, BUTTON, char label[RETROGUI_BTN_LBL_SZ_MAX]; ) \
+
f( 3, TEXTBOX, MAUG_MHANDLE text_h; char* text; size_t text_sz; size_t text_sz_max; size_t text_cur; )
+
+

Table defining all control types and their specific fields in RETROGUI_CTL.

+

All entries in this table have corresponding retrogui_redraw_*, retrogui_poll_*, retrogui_init_*, and retrogui_push_* functions which are called internally from retrogui_redraw_ctls(), retrogui_poll_ctls(), retrogui_init_ctl(), and retrogui_push_ctl(), respectively.

+ +
+
+ +

◆ RETROGUI_CTL_TABLE_FIELDS

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
#define RETROGUI_CTL_TABLE_FIELDS( idx,
 c_name,
 c_fields 
)
+
+Value:
struct RETROGUI_CTL_ ## c_name { \
+
struct RETROGUI_CTL_BASE base; \
+
c_fields \
+
};
+
Fields common to ALL RETROGUI_CTL types.
Definition retrogui.h:73
+
+

Creates the corresponding RETROGUI_* structs from RETROGUI_CTL_TABLE that populate union RETROGUI_CTL.

+ +
+
+
+ + + + diff --git a/group__maug__retrogui__ctl.map b/group__maug__retrogui__ctl.map new file mode 100644 index 00000000..67df4c31 --- /dev/null +++ b/group__maug__retrogui__ctl.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__retrogui__ctl.md5 b/group__maug__retrogui__ctl.md5 new file mode 100644 index 00000000..4c028930 --- /dev/null +++ b/group__maug__retrogui__ctl.md5 @@ -0,0 +1 @@ +8e4a58263a55c09a13513e894718b1c9 \ No newline at end of file diff --git a/group__maug__retrogui__ctl.png b/group__maug__retrogui__ctl.png new file mode 100644 index 00000000..73661ebf Binary files /dev/null and b/group__maug__retrogui__ctl.png differ diff --git a/group__maug__tilemap.html b/group__maug__tilemap.html new file mode 100644 index 00000000..89cfd843 --- /dev/null +++ b/group__maug__tilemap.html @@ -0,0 +1,166 @@ + + + + + + + +maug: Tilemap API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Tilemap API
+
+
+ +

Functions and structures for working with tilemaps/grids. +More...

+
+Collaboration diagram for Tilemap API:
+
+
+ + + + + +
+ + + + + + +

+Modules

 Tilemap Tile Definitions
 
 Tilemap Parser
 
+ + + +

+Files

file  mtilemap.h
 
+ + + + + +

+Data Structures

struct  MTILEMAP_LAYER
 
struct  MTILEMAP
 
+ + + + + + + + + + + + + + + + + +

+Macros

+#define MTILEMAP_NAME_SZ_MAX   10
 
+#define MTILEMAP_TOKEN_SZ_MAX   4096
 
+#define MTILEMAP_TILES_SZ_INIT   10
 
+#define MTILEMAP_TILESET_IMAGE_STR_SZ_MAX   48
 
+#define MTILEMAP_TILE_SCALE   1.0f
 
+#define MTILEMAP_CPROP_STR_SZ_MAX   32
 
+#define MTILEMAP_TRACE_LVL   0
 
+#define MTILEMAP_FLAG_ACTIVE   0x1
 
+ + + + + + + + + +

+Functions

+MERROR_RETVAL mtilemap_alloc_tile_defs (struct MTILEMAP *t, size_t ndefs)
 
+MERROR_RETVAL mtilemap_alloc_layers (struct MTILEMAP *t, size_t ndefs)
 
+MERROR_RETVAL mtilemap_alloc_tiles (struct MTILEMAP_LAYER *layer, size_t ndefs)
 
+MERROR_RETVAL mtilemap_free (struct MTILEMAP *t)
 
+

Detailed Description

+

Functions and structures for working with tilemaps/grids.

+
+ + + + diff --git a/group__maug__tilemap.map b/group__maug__tilemap.map new file mode 100644 index 00000000..b0774723 --- /dev/null +++ b/group__maug__tilemap.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__tilemap.md5 b/group__maug__tilemap.md5 new file mode 100644 index 00000000..0cbcdd8e --- /dev/null +++ b/group__maug__tilemap.md5 @@ -0,0 +1 @@ +550663330525d2d41cfb24181506dbc7 \ No newline at end of file diff --git a/group__maug__tilemap.png b/group__maug__tilemap.png new file mode 100644 index 00000000..777b644d Binary files /dev/null and b/group__maug__tilemap.png differ diff --git a/group__maug__tilemap__defs.html b/group__maug__tilemap__defs.html new file mode 100644 index 00000000..aca88d65 --- /dev/null +++ b/group__maug__tilemap__defs.html @@ -0,0 +1,114 @@ + + + + + + + +maug: Tilemap Tile Definitions + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Tilemap Tile Definitions
+
+
+
+Collaboration diagram for Tilemap Tile Definitions:
+
+
+ + + + + +
+ + + + +

+Modules

 Tilemap Custom Property Types
 
+ + + + + + + + + +

+Data Structures

union  MTILEMAP_CPROP_VAL
 Data store for MTILEMAP_CPROP::value. More...
 
struct  MTILEMAP_CPROP
 Custom property key-value storage type. More...
 
struct  MTILEMAP_TILE_DEF
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__tilemap__defs.map b/group__maug__tilemap__defs.map new file mode 100644 index 00000000..72adf67b --- /dev/null +++ b/group__maug__tilemap__defs.map @@ -0,0 +1,5 @@ + + + + + diff --git a/group__maug__tilemap__defs.md5 b/group__maug__tilemap__defs.md5 new file mode 100644 index 00000000..3e83c6b8 --- /dev/null +++ b/group__maug__tilemap__defs.md5 @@ -0,0 +1 @@ +0770ecc384cc84903c87c954e8105532 \ No newline at end of file diff --git a/group__maug__tilemap__defs.png b/group__maug__tilemap__defs.png new file mode 100644 index 00000000..4008f3b4 Binary files /dev/null and b/group__maug__tilemap__defs.png differ diff --git a/group__maug__tilemap__defs__types.html b/group__maug__tilemap__defs__types.html new file mode 100644 index 00000000..36bea9c1 --- /dev/null +++ b/group__maug__tilemap__defs__types.html @@ -0,0 +1,114 @@ + + + + + + + +maug: Tilemap Custom Property Types + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Tilemap Custom Property Types
+
+
+
+Collaboration diagram for Tilemap Custom Property Types:
+
+
+ + + + +
+ + + + + + + + + + + + +

+Macros

+#define MTILEMAP_CPROP_TYPE_NONE   0
 
+#define MTILEMAP_CPROP_TYPE_INT   1
 
+#define MTILEMAP_CPROP_TYPE_FLOAT   2
 
+#define MTILEMAP_CPROP_TYPE_STR   3
 
+#define MTILEMAP_CPROP_TYPE_BOOL   4
 
+

Detailed Description

+
+ + + + diff --git a/group__maug__tilemap__defs__types.map b/group__maug__tilemap__defs__types.map new file mode 100644 index 00000000..41730db8 --- /dev/null +++ b/group__maug__tilemap__defs__types.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__tilemap__defs__types.md5 b/group__maug__tilemap__defs__types.md5 new file mode 100644 index 00000000..609f87e0 --- /dev/null +++ b/group__maug__tilemap__defs__types.md5 @@ -0,0 +1 @@ +a1404e46cd081016474da3987aff8e9b \ No newline at end of file diff --git a/group__maug__tilemap__defs__types.png b/group__maug__tilemap__defs__types.png new file mode 100644 index 00000000..1b8a4063 Binary files /dev/null and b/group__maug__tilemap__defs__types.png differ diff --git a/group__maug__tilemap__parser.html b/group__maug__tilemap__parser.html new file mode 100644 index 00000000..d013bb79 --- /dev/null +++ b/group__maug__tilemap__parser.html @@ -0,0 +1,186 @@ + + + + + + + +maug: Tilemap Parser + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Tilemap Parser
+
+
+
+Collaboration diagram for Tilemap Parser:
+
+
+ + + + +
+ + + + +

+Data Structures

struct  MTILEMAP_PARSER
 
+ + + + + +

+Macros

#define MTILEMAP_PARSER_PSTATE_TABLE(f)
 
#define MTILEMAP_PARSER_MSTATE_TABLE(f)
 
+ + + +

+Typedefs

+typedef MERROR_RETVAL(* mtilemap_tj_parse_cb) (const char *filename, struct MTILEMAP *t)
 
+ + + + + +

+Functions

+MERROR_RETVAL mtilemap_parse_json_c (struct MTILEMAP_PARSER *parser, char c)
 
+MERROR_RETVAL mtilemap_parse_json_file (const char *filename, struct MTILEMAP *m)
 
+

Detailed Description

+

Macro Definition Documentation

+ +

◆ MTILEMAP_PARSER_MSTATE_TABLE

+ +
+
+ + + + + + + + +
#define MTILEMAP_PARSER_MSTATE_TABLE( f)
+
+Value:
f( MTILEMAP_MSTATE_NONE, 0, "", 0 ) \
+
f( MTILEMAP_MSTATE_HEIGHT, 1, "height", 0 ) \
+
f( MTILEMAP_MSTATE_WIDTH, 2, "width", 0 ) \
+
f( MTILEMAP_MSTATE_LAYERS, 3, "layers", 0 ) \
+
f( MTILEMAP_MSTATE_LAYER_DATA, 4, "data", 3 /* MSTATE_LAYERS */ ) \
+
f( MTILEMAP_MSTATE_LAYER_NAME, 5, "name", 3 /* MSTATE_LAYERS */ ) \
+
f( MTILEMAP_MSTATE_TILES, 6, "tiles", 0 ) \
+
f( MTILEMAP_MSTATE_TILES_ID, 7, "id", 6 /* MSTATE_TILES */ ) \
+
f( MTILEMAP_MSTATE_TILES_IMAGE, 8, "image", 6 /* MSTATE_TILES */ ) \
+
f( MTILEMAP_MSTATE_TILESETS, 9, "tilesets", 0 ) \
+
f( MTILEMAP_MSTATE_TILESETS_SRC, 10, "source", 9 /* MSTATE_TILESETS */ ) \
+
f( MTILEMAP_MSTATE_TILESETS_FGID,11, "firstgid",9 /* MSTATE_TILESETS */ ) \
+
f( MTILEMAP_MSTATE_TILESETS_PROP,12, "firstgid",9 /* MSTATE_TILESETS */ ) \
+
f( MTILEMAP_MSTATE_GRID, 13, "grid", 0 ) \
+
f( MTILEMAP_MSTATE_TILES_PROP, 14, "properties",6 /* MSTATE_TILES */ ) \
+
f( MTILEMAP_MSTATE_TILES_PROP_N, 15, "name",14 /* M_TILES_PROP */ ) \
+
f( MTILEMAP_MSTATE_TILES_PROP_T, 16, "type",14 /* M_TILES_PROP */ ) \
+
f( MTILEMAP_MSTATE_TILES_PROP_V, 17, "value",14 /* M_TILES_PROP */ ) \
+
+
+
+ +

◆ MTILEMAP_PARSER_PSTATE_TABLE

+ +
+
+ + + + + + + + +
#define MTILEMAP_PARSER_PSTATE_TABLE( f)
+
+Value:
f( MTILEMAP_PSTATE_NONE, 0 ) \
+
f( MTILEMAP_PSTATE_OBJECT_KEY, 1 ) \
+
f( MTILEMAP_PSTATE_OBJECT_VAL, 2 ) \
+
f( MTILEMAP_PSTATE_STRING, 3 ) \
+
f( MTILEMAP_PSTATE_LIST, 4 )
+
+
+
+
+ + + + diff --git a/group__maug__tilemap__parser.map b/group__maug__tilemap__parser.map new file mode 100644 index 00000000..a1cbd124 --- /dev/null +++ b/group__maug__tilemap__parser.map @@ -0,0 +1,4 @@ + + + + diff --git a/group__maug__tilemap__parser.md5 b/group__maug__tilemap__parser.md5 new file mode 100644 index 00000000..fdf3a8d3 --- /dev/null +++ b/group__maug__tilemap__parser.md5 @@ -0,0 +1 @@ +9863d5d6481108bff43068172fb4113a \ No newline at end of file diff --git a/group__maug__tilemap__parser.png b/group__maug__tilemap__parser.png new file mode 100644 index 00000000..26fda471 Binary files /dev/null and b/group__maug__tilemap__parser.png differ diff --git a/group__maug__uprintf.html b/group__maug__uprintf.html new file mode 100644 index 00000000..5585ccaf --- /dev/null +++ b/group__maug__uprintf.html @@ -0,0 +1,397 @@ + + + + + + + +maug: Micro-PrintF API + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Micro-PrintF API
+
+
+ +

Independently-implemented printf API for old compilers. +More...

+ + + + +

+Files

file  uprintf.h
 
+ + + +

+Data Structures

union  MAUG_FMT_SPEC
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Macros

+#define NEWLINE_STR   "\n"
 
+#define UPRINTF_BUFFER_SZ_MAX   1024
 
+#define platform_file   FILE*
 
+#define platform_fprintf   fprintf
 
+#define platform_vfprintf   vfprintf
 
+#define platform_fopen   fopen
 
+#define platform_fflush   fflush
 
+#define platform_fclose   fclose
 
+#define LOG_ERR_TARGET   stderr
 
+#define LOG_STD_TARGET   stdout
 
+#define SIZE_T_FMT   "%u"
 
+#define SSIZE_T_FMT   "%d"
 
+#define DEBUG_THRESHOLD   1
 
+#define debug_printf(...)
 
+#define error_printf(...)
 
+#define size_printf(...)
 
+#define size_multi_printf(...)
 
+#define logging_init()
 
+#define logging_shutdown()
 
#define maug_bufcat(c, buf, buf_idx, buf_sz, cleanup)
 
#define maug_bufpad(pad_c, pad_sz, i, buf, buf_idx, buf_sz, cleanup)
 
#define maug_xtoa(num, base, rem, dest, dest_idx, digits, digits_done, pad)
 
+ + + + + + + + + + + + + + + + + +

+Functions

+int maug_digits (long int num, int base)
 
+int maug_zdigits (size_t num, int base)
 
+int maug_itoa (long int num, char *dest, int dest_sz, int base)
 
+int maug_utoa (uint32_t num, char *dest, int dest_sz, int base)
 
+int maug_ztoa (size_t num, char *dest, int dest_sz, int base)
 
+void maug_vsnprintf (char *buffer, int buffer_sz, const char *fmt, va_list vargs)
 
+void maug_snprintf (char *buffer, int buffer_sz, const char *fmt,...)
 
+void maug_printf (const char *fmt,...)
 
+ + + +

+Variables

+uint32_t g_maug_printf_line
 
+

Detailed Description

+

Independently-implemented printf API for old compilers.

+

Macro Definition Documentation

+ +

◆ maug_bufcat

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_bufcat( c,
 buf,
 buf_idx,
 buf_sz,
 cleanup 
)
+
+Value:
buf[buf_idx++] = c; \
+
if( buf_idx >= buf_sz ) { goto cleanup; }
+
+
+
+ +

◆ maug_bufpad

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_bufpad( pad_c,
 pad_sz,
 i,
 buf,
 buf_idx,
 buf_sz,
 cleanup 
)
+
+Value:
i = 0; \
+
while( i < pad_sz ) { \
+
maug_bufcat( pad_c, buffer, buffer_idx, buffer_sz, cleanup ); \
+
i++; \
+
}
+
+
+
+ +

◆ maug_xtoa

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#define maug_xtoa( num,
 base,
 rem,
 dest,
 dest_idx,
 digits,
 digits_done,
 pad 
)
+
+Value:
dest_idx += digits; \
+
while( 0 != num ) { \
+
/* Get the 1's place. */ \
+
rem = num % base; \
+
dest[--dest_idx] = (9 < rem) ? \
+
/* > 10, so it's a letter. */ \
+
(rem - 10) + 'a' : \
+
/* < 10, so it's a number. */ \
+
rem + '0'; \
+
/* Move the next place value into range. */ \
+
num /= base; \
+
digits_done++; \
+
} \
+
while( digits_done < digits ) { \
+
dest[--dest_idx] = '0'; \
+
digits_done++; \
+
}
+
+
+
+
+ + + + diff --git a/index.html b/index.html new file mode 100644 index 00000000..917d890d --- /dev/null +++ b/index.html @@ -0,0 +1,161 @@ + + + + + + + +maug: maug + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
maug
+
+
+

Augmented minimal standard library for C89 and legacy compilers.

+

The API is currently in flux and is not yet completely final!

+

Current maug-based projects may be found under The maug topic on GitHub!

+

Design Constraints

+

Maug has the following design goals and constraints:

+
    +
  • Must work in C89 compilers. C99-like features like stdint or snprintf are available by internal implementation.
  • +
  • Memory allocation uses a flat model (calloc/free), with no handle management.
  • +
  • Standard library calls are allowed, so long as they are universally available even in very old C89 compilers.
  • +
+

Roadmap

+
    +
  • Rename Retroflat functions with maug_ to create a coherent namespace.
  • +
  • Clearly enumerate which headers rely on which to create modular hierarchy.
  • +
  • Solidify API.
  • +
  • Setup Makefile to compile .solib/.dll/.ovl dynamic libs.
  • +
+

Modules

+

Makefiles

+

Inside of the make subdirectory are a number of Makefiles that can be included from a project's Makefile in order to more conveniently build assets.

+

retroflt

+

#include <retroflt.h>

+

RetroFlat is a rough, quick-and-dirty compatibility layer for making graphical programs that work on Win16 (32-bit via OpenWatcom's Win386), MS-DOS (32-bit via DOS/32a or DOS4GW via Allegro), and possibly other platforms in the future.

+

This documentation is also available at https://indigoparadox.github.io/maug/group__maug__retroflt.html.

+

mtypes

+

#include <mtypes.h>

+

Rough common approximation of types for interoperability between our projects.

+

Includes common types from stdint.h, guaranteed to be of the named size:

+
    +
  • int8_t
  • +
  • uint8_t
  • +
  • int16_t
  • +
  • uint16_t
  • +
  • int32_t
  • +
  • uint32_t
  • +
+

When using this header, do not include stdint.h. This header will include it if the current platform supports it. Otherwise, it will improvise.

+

uprintf

+

#include <uprintf.h>

+

An augmented printf for tracing, debugging, and error reporting.

+

To use, include uprintf.h and call logging\_init() in program startup.

+

Be sure to call logging\_shutdown() on program cleanup.

+

Logging can then be performed by calling:

+
    +
  • debug\_printf( lvl, format, ... ) - Prints debug message.
      +
    • lvl - Immediacy level of debug message. See DEBUG_THRESHOLD below.
    • +
    • format - printf()-style format string.
    • +
    • ... - Variable arguments to format.
    • +
    +
  • +
  • error\_printf( format, ... ) - Prints to stderr.
      +
    • format - printf()-style format string.
    • +
    • ... - Variable arguments to format.
    • +
    +
  • +
+

uprintf's behavior can be modified by defining the following before inclusion:

+ + + + + + + + + + + + + + + + + + + +
Define Description
platform_file Type to use instead of stdlib's FILE for log ptr.
platform_fopen Function to use instead of fopen() to create a log ptr.
platform_fclose Function to close log ptr.
platform_fflush Function to flush log ptr to buffer.
platform_fprintf Function to print to log ptr with a format string.
DEBUG_THRESHOLD debug_printf() w/ this or higher lvl will be displayed.
DEBUG_LOG If defined, debug will be output to LOG_FILE_NAME.
ANCIENT_C Use static functions where vararg macros unsupported.
+
+
+ + + + diff --git a/jquery.js b/jquery.js new file mode 100644 index 00000000..1dffb65b --- /dev/null +++ b/jquery.js @@ -0,0 +1,34 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=y(e||this.defaultElement||this)[0],this.element=y(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=y(),this.hoverable=y(),this.focusable=y(),this.classesElementLookup={},e!==this&&(y.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=y(e.style?e.ownerDocument:e.document||e),this.window=y(this.document[0].defaultView||this.document[0].parentWindow)),this.options=y.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:y.noop,_create:y.noop,_init:y.noop,destroy:function(){var i=this;this._destroy(),y.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:y.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return y.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=y.widget.extend({},this.options[t]),n=0;n
"),i=e.children()[0];return y("body").append(e),t=i.offsetWidth,e.css("overflow","scroll"),t===(i=i.offsetWidth)&&(i=e[0].clientWidth),e.remove(),s=t-i},getScrollInfo:function(t){var e=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),i=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),e="scroll"===e||"auto"===e&&t.widthx(D(s),D(n))?o.important="horizontal":o.important="vertical",p.using.call(this,t,o)}),h.offset(y.extend(l,{using:t}))})},y.ui.position={fit:{left:function(t,e){var i=e.within,s=i.isWindow?i.scrollLeft:i.offset.left,n=i.width,o=t.left-e.collisionPosition.marginLeft,h=s-o,a=o+e.collisionWidth-n-s;e.collisionWidth>n?0n?0=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),y.ui.plugin={add:function(t,e,i){var s,n=y.ui[t].prototype;for(s in i)n.plugins[s]=n.plugins[s]||[],n.plugins[s].push([e,i[s]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;n").css({overflow:"hidden",position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,t={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(t),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(t),this._proportionallyResize()),this._setupHandles(),e.autoHide&&y(this.element).on("mouseenter",function(){e.disabled||(i._removeClass("ui-resizable-autohide"),i._handles.show())}).on("mouseleave",function(){e.disabled||i.resizing||(i._addClass("ui-resizable-autohide"),i._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy(),this._addedHandles.remove();function t(t){y(t).removeData("resizable").removeData("ui-resizable").off(".resizable")}var e;return this.elementIsWrapper&&(t(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;case"aspectRatio":this._aspectRatio=!!e}},_setupHandles:function(){var t,e,i,s,n,o=this.options,h=this;if(this.handles=o.handles||(y(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=y(),this._addedHandles=y(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),i=this.handles.split(","),this.handles={},e=0;e"),this._addClass(n,"ui-resizable-handle "+s),n.css({zIndex:o.zIndex}),this.handles[t]=".ui-resizable-"+t,this.element.children(this.handles[t]).length||(this.element.append(n),this._addedHandles=this._addedHandles.add(n));this._renderAxis=function(t){var e,i,s;for(e in t=t||this.element,this.handles)this.handles[e].constructor===String?this.handles[e]=this.element.children(this.handles[e]).first().show():(this.handles[e].jquery||this.handles[e].nodeType)&&(this.handles[e]=y(this.handles[e]),this._on(this.handles[e],{mousedown:h._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(i=y(this.handles[e],this.element),s=/sw|ne|nw|se|n|s/.test(e)?i.outerHeight():i.outerWidth(),i=["padding",/ne|nw|n/.test(e)?"Top":/se|sw|s/.test(e)?"Bottom":/^e$/.test(e)?"Right":"Left"].join(""),t.css(i,s),this._proportionallyResize()),this._handles=this._handles.add(this.handles[e])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){h.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),h.axis=n&&n[1]?n[1]:"se")}),o.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._addedHandles.remove()},_mouseCapture:function(t){var e,i,s=!1;for(e in this.handles)(i=y(this.handles[e])[0])!==t.target&&!y.contains(i,t.target)||(s=!0);return!this.options.disabled&&s},_mouseStart:function(t){var e,i,s=this.options,n=this.element;return this.resizing=!0,this._renderProxy(),e=this._num(this.helper.css("left")),i=this._num(this.helper.css("top")),s.containment&&(e+=y(s.containment).scrollLeft()||0,i+=y(s.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:e,top:i},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:n.width(),height:n.height()},this.originalSize=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()},this.sizeDiff={width:n.outerWidth()-n.width(),height:n.outerHeight()-n.height()},this.originalPosition={left:e,top:i},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof s.aspectRatio?s.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=y(".ui-resizable-"+this.axis).css("cursor"),y("body").css("cursor","auto"===s?this.axis+"-resize":s),this._addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var e=this.originalMousePosition,i=this.axis,s=t.pageX-e.left||0,e=t.pageY-e.top||0,i=this._change[i];return this._updatePrevProperties(),i&&(e=i.apply(this,[t,s,e]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(e=this._updateRatio(e,t)),e=this._respectSize(e,t),this._updateCache(e),this._propagate("resize",t),e=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),y.isEmptyObject(e)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges())),!1},_mouseStop:function(t){this.resizing=!1;var e,i,s,n=this.options,o=this;return this._helper&&(s=(e=(i=this._proportionallyResizeElements).length&&/textarea/i.test(i[0].nodeName))&&this._hasScroll(i[0],"left")?0:o.sizeDiff.height,i=e?0:o.sizeDiff.width,e={width:o.helper.width()-i,height:o.helper.height()-s},i=parseFloat(o.element.css("left"))+(o.position.left-o.originalPosition.left)||null,s=parseFloat(o.element.css("top"))+(o.position.top-o.originalPosition.top)||null,n.animate||this.element.css(y.extend(e,{top:s,left:i})),o.helper.height(o.size.height),o.helper.width(o.size.width),this._helper&&!n.animate&&this._proportionallyResize()),y("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s=this.options,n={minWidth:this._isNumber(s.minWidth)?s.minWidth:0,maxWidth:this._isNumber(s.maxWidth)?s.maxWidth:1/0,minHeight:this._isNumber(s.minHeight)?s.minHeight:0,maxHeight:this._isNumber(s.maxHeight)?s.maxHeight:1/0};(this._aspectRatio||t)&&(e=n.minHeight*this.aspectRatio,i=n.minWidth/this.aspectRatio,s=n.maxHeight*this.aspectRatio,t=n.maxWidth/this.aspectRatio,e>n.minWidth&&(n.minWidth=e),i>n.minHeight&&(n.minHeight=i),st.width,h=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,a=this.originalPosition.left+this.originalSize.width,r=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),i=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),h&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=a-e.minWidth),s&&l&&(t.left=a-e.maxWidth),h&&i&&(t.top=r-e.minHeight),n&&i&&(t.top=r-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];e<4;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;e").css({overflow:"hidden"}),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++e.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize;return{left:this.originalPosition.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize;return{top:this.originalPosition.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(t,e,i){return y.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},sw:function(t,e,i){return y.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,e,i]))},ne:function(t,e,i){return y.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},nw:function(t,e,i){return y.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,e,i]))}},_propagate:function(t,e){y.ui.plugin.call(this,t,[e,this.ui()]),"resize"!==t&&this._trigger(t,e,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),y.ui.plugin.add("resizable","animate",{stop:function(e){var i=y(this).resizable("instance"),t=i.options,s=i._proportionallyResizeElements,n=s.length&&/textarea/i.test(s[0].nodeName),o=n&&i._hasScroll(s[0],"left")?0:i.sizeDiff.height,h=n?0:i.sizeDiff.width,n={width:i.size.width-h,height:i.size.height-o},h=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,o=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(y.extend(n,o&&h?{top:o,left:h}:{}),{duration:t.animateDuration,easing:t.animateEasing,step:function(){var t={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};s&&s.length&&y(s[0]).css({width:t.width,height:t.height}),i._updateCache(t),i._propagate("resize",e)}})}}),y.ui.plugin.add("resizable","containment",{start:function(){var i,s,n=y(this).resizable("instance"),t=n.options,e=n.element,o=t.containment,h=o instanceof y?o.get(0):/parent/.test(o)?e.parent().get(0):o;h&&(n.containerElement=y(h),/document/.test(o)||o===document?(n.containerOffset={left:0,top:0},n.containerPosition={left:0,top:0},n.parentData={element:y(document),left:0,top:0,width:y(document).width(),height:y(document).height()||document.body.parentNode.scrollHeight}):(i=y(h),s=[],y(["Top","Right","Left","Bottom"]).each(function(t,e){s[t]=n._num(i.css("padding"+e))}),n.containerOffset=i.offset(),n.containerPosition=i.position(),n.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},t=n.containerOffset,e=n.containerSize.height,o=n.containerSize.width,o=n._hasScroll(h,"left")?h.scrollWidth:o,e=n._hasScroll(h)?h.scrollHeight:e,n.parentData={element:h,left:t.left,top:t.top,width:o,height:e}))},resize:function(t){var e=y(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.position,o=e._aspectRatio||t.shiftKey,h={top:0,left:0},a=e.containerElement,t=!0;a[0]!==document&&/static/.test(a.css("position"))&&(h=s),n.left<(e._helper?s.left:0)&&(e.size.width=e.size.width+(e._helper?e.position.left-s.left:e.position.left-h.left),o&&(e.size.height=e.size.width/e.aspectRatio,t=!1),e.position.left=i.helper?s.left:0),n.top<(e._helper?s.top:0)&&(e.size.height=e.size.height+(e._helper?e.position.top-s.top:e.position.top),o&&(e.size.width=e.size.height*e.aspectRatio,t=!1),e.position.top=e._helper?s.top:0),i=e.containerElement.get(0)===e.element.parent().get(0),n=/relative|absolute/.test(e.containerElement.css("position")),i&&n?(e.offset.left=e.parentData.left+e.position.left,e.offset.top=e.parentData.top+e.position.top):(e.offset.left=e.element.offset().left,e.offset.top=e.element.offset().top),n=Math.abs(e.sizeDiff.width+(e._helper?e.offset.left-h.left:e.offset.left-s.left)),s=Math.abs(e.sizeDiff.height+(e._helper?e.offset.top-h.top:e.offset.top-s.top)),n+e.size.width>=e.parentData.width&&(e.size.width=e.parentData.width-n,o&&(e.size.height=e.size.width/e.aspectRatio,t=!1)),s+e.size.height>=e.parentData.height&&(e.size.height=e.parentData.height-s,o&&(e.size.width=e.size.height*e.aspectRatio,t=!1)),t||(e.position.left=e.prevPosition.left,e.position.top=e.prevPosition.top,e.size.width=e.prevSize.width,e.size.height=e.prevSize.height)},stop:function(){var t=y(this).resizable("instance"),e=t.options,i=t.containerOffset,s=t.containerPosition,n=t.containerElement,o=y(t.helper),h=o.offset(),a=o.outerWidth()-t.sizeDiff.width,o=o.outerHeight()-t.sizeDiff.height;t._helper&&!e.animate&&/relative/.test(n.css("position"))&&y(this).css({left:h.left-s.left-i.left,width:a,height:o}),t._helper&&!e.animate&&/static/.test(n.css("position"))&&y(this).css({left:h.left-s.left-i.left,width:a,height:o})}}),y.ui.plugin.add("resizable","alsoResize",{start:function(){var t=y(this).resizable("instance").options;y(t.alsoResize).each(function(){var t=y(this);t.data("ui-resizable-alsoresize",{width:parseFloat(t.width()),height:parseFloat(t.height()),left:parseFloat(t.css("left")),top:parseFloat(t.css("top"))})})},resize:function(t,i){var e=y(this).resizable("instance"),s=e.options,n=e.originalSize,o=e.originalPosition,h={height:e.size.height-n.height||0,width:e.size.width-n.width||0,top:e.position.top-o.top||0,left:e.position.left-o.left||0};y(s.alsoResize).each(function(){var t=y(this),s=y(this).data("ui-resizable-alsoresize"),n={},e=t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];y.each(e,function(t,e){var i=(s[e]||0)+(h[e]||0);i&&0<=i&&(n[e]=i||null)}),t.css(n)})},stop:function(){y(this).removeData("ui-resizable-alsoresize")}}),y.ui.plugin.add("resizable","ghost",{start:function(){var t=y(this).resizable("instance"),e=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:e.height,width:e.width,margin:0,left:0,top:0}),t._addClass(t.ghost,"ui-resizable-ghost"),!1!==y.uiBackCompat&&"string"==typeof t.options.ghost&&t.ghost.addClass(this.options.ghost),t.ghost.appendTo(t.helper)},resize:function(){var t=y(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=y(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),y.ui.plugin.add("resizable","grid",{resize:function(){var t,e=y(this).resizable("instance"),i=e.options,s=e.size,n=e.originalSize,o=e.originalPosition,h=e.axis,a="number"==typeof i.grid?[i.grid,i.grid]:i.grid,r=a[0]||1,l=a[1]||1,u=Math.round((s.width-n.width)/r)*r,p=Math.round((s.height-n.height)/l)*l,d=n.width+u,c=n.height+p,f=i.maxWidth&&i.maxWidthd,s=i.minHeight&&i.minHeight>c;i.grid=a,m&&(d+=r),s&&(c+=l),f&&(d-=r),g&&(c-=l),/^(se|s|e)$/.test(h)?(e.size.width=d,e.size.height=c):/^(ne)$/.test(h)?(e.size.width=d,e.size.height=c,e.position.top=o.top-p):/^(sw)$/.test(h)?(e.size.width=d,e.size.height=c,e.position.left=o.left-u):((c-l<=0||d-r<=0)&&(t=e._getPaddingPlusBorderDimensions(this)),0=f[g]?0:Math.min(f[g],n));!a&&1-1){targetElements.on(evt+EVENT_NAMESPACE,function elementToggle(event){$.powerTip.toggle(this,event)})}else{targetElements.on(evt+EVENT_NAMESPACE,function elementOpen(event){$.powerTip.show(this,event)})}});$.each(options.closeEvents,function(idx,evt){if($.inArray(evt,options.openEvents)<0){targetElements.on(evt+EVENT_NAMESPACE,function elementClose(event){$.powerTip.hide(this,!isMouseEvent(event))})}});targetElements.on("keydown"+EVENT_NAMESPACE,function elementKeyDown(event){if(event.keyCode===27){$.powerTip.hide(this,true)}})}return targetElements};$.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:false,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:false,offset:10,mouseOnToPopup:false,manual:false,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]};$.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]};$.powerTip={show:function apiShowTip(element,event){if(isMouseEvent(event)){trackMouse(event);session.previousX=event.pageX;session.previousY=event.pageY;$(element).data(DATA_DISPLAYCONTROLLER).show()}else{$(element).first().data(DATA_DISPLAYCONTROLLER).show(true,true)}return element},reposition:function apiResetPosition(element){$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();return element},hide:function apiCloseTip(element,immediate){var displayController;immediate=element?immediate:true;if(element){displayController=$(element).first().data(DATA_DISPLAYCONTROLLER)}else if(session.activeHover){displayController=session.activeHover.data(DATA_DISPLAYCONTROLLER)}if(displayController){displayController.hide(immediate)}return element},toggle:function apiToggle(element,event){if(session.activeHover&&session.activeHover.is(element)){$.powerTip.hide(element,!isMouseEvent(event))}else{$.powerTip.show(element,event)}return element}};$.powerTip.showTip=$.powerTip.show;$.powerTip.closeTip=$.powerTip.hide;function CSSCoordinates(){var me=this;me.top="auto";me.left="auto";me.right="auto";me.bottom="auto";me.set=function(property,value){if($.isNumeric(value)){me[property]=Math.round(value)}}}function DisplayController(element,options,tipController){var hoverTimer=null,myCloseDelay=null;function openTooltip(immediate,forceOpen){cancelTimer();if(!element.data(DATA_HASACTIVEHOVER)){if(!immediate){session.tipOpenImminent=true;hoverTimer=setTimeout(function intentDelay(){hoverTimer=null;checkForIntent()},options.intentPollInterval)}else{if(forceOpen){element.data(DATA_FORCEDOPEN,true)}closeAnyDelayed();tipController.showTip(element)}}else{cancelClose()}}function closeTooltip(disableDelay){if(myCloseDelay){myCloseDelay=session.closeDelayTimeout=clearTimeout(myCloseDelay);session.delayInProgress=false}cancelTimer();session.tipOpenImminent=false;if(element.data(DATA_HASACTIVEHOVER)){element.data(DATA_FORCEDOPEN,false);if(!disableDelay){session.delayInProgress=true;session.closeDelayTimeout=setTimeout(function closeDelay(){session.closeDelayTimeout=null;tipController.hideTip(element);session.delayInProgress=false;myCloseDelay=null},options.closeDelay);myCloseDelay=session.closeDelayTimeout}else{tipController.hideTip(element)}}}function checkForIntent(){var xDifference=Math.abs(session.previousX-session.currentX),yDifference=Math.abs(session.previousY-session.currentY),totalDifference=xDifference+yDifference;if(totalDifference",{id:options.popupId});if($body.length===0){$body=$("body")}$body.append(tipElement);session.tooltips=session.tooltips?session.tooltips.add(tipElement):tipElement}if(options.followMouse){if(!tipElement.data(DATA_HASMOUSEMOVE)){$document.on("mousemove"+EVENT_NAMESPACE,positionTipOnCursor);$window.on("scroll"+EVENT_NAMESPACE,positionTipOnCursor);tipElement.data(DATA_HASMOUSEMOVE,true)}}function beginShowTip(element){element.data(DATA_HASACTIVEHOVER,true);tipElement.queue(function queueTipInit(next){showTip(element);next()})}function showTip(element){var tipContent;if(!element.data(DATA_HASACTIVEHOVER)){return}if(session.isTipOpen){if(!session.isClosing){hideTip(session.activeHover)}tipElement.delay(100).queue(function queueTipAgain(next){showTip(element);next()});return}element.trigger("powerTipPreRender");tipContent=getTooltipContent(element);if(tipContent){tipElement.empty().append(tipContent)}else{return}element.trigger("powerTipRender");session.activeHover=element;session.isTipOpen=true;tipElement.data(DATA_MOUSEONTOTIP,options.mouseOnToPopup);tipElement.addClass(options.popupClass);if(!options.followMouse||element.data(DATA_FORCEDOPEN)){positionTipOnElement(element);session.isFixedTipOpen=true}else{positionTipOnCursor()}if(!element.data(DATA_FORCEDOPEN)&&!options.followMouse){$document.on("click"+EVENT_NAMESPACE,function documentClick(event){var target=event.target;if(target!==element[0]){if(options.mouseOnToPopup){if(target!==tipElement[0]&&!$.contains(tipElement[0],target)){$.powerTip.hide()}}else{$.powerTip.hide()}}})}if(options.mouseOnToPopup&&!options.manual){tipElement.on("mouseenter"+EVENT_NAMESPACE,function tipMouseEnter(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).cancel()}});tipElement.on("mouseleave"+EVENT_NAMESPACE,function tipMouseLeave(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).hide()}})}tipElement.fadeIn(options.fadeInTime,function fadeInCallback(){if(!session.desyncTimeout){session.desyncTimeout=setInterval(closeDesyncedTip,500)}element.trigger("powerTipOpen")})}function hideTip(element){session.isClosing=true;session.isTipOpen=false;session.desyncTimeout=clearInterval(session.desyncTimeout);element.data(DATA_HASACTIVEHOVER,false);element.data(DATA_FORCEDOPEN,false);$document.off("click"+EVENT_NAMESPACE);tipElement.off(EVENT_NAMESPACE);tipElement.fadeOut(options.fadeOutTime,function fadeOutCallback(){var coords=new CSSCoordinates;session.activeHover=null;session.isClosing=false;session.isFixedTipOpen=false;tipElement.removeClass();coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);tipElement.css(coords);element.trigger("powerTipClose")})}function positionTipOnCursor(){var tipWidth,tipHeight,coords,collisions,collisionCount;if(!session.isFixedTipOpen&&(session.isTipOpen||session.tipOpenImminent&&tipElement.data(DATA_HASMOUSEMOVE))){tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=new CSSCoordinates;coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);collisions=getViewportCollisions(coords,tipWidth,tipHeight);if(collisions!==Collision.none){collisionCount=countFlags(collisions);if(collisionCount===1){if(collisions===Collision.right){coords.set("left",session.scrollLeft+session.windowWidth-tipWidth)}else if(collisions===Collision.bottom){coords.set("top",session.scrollTop+session.windowHeight-tipHeight)}}else{coords.set("left",session.currentX-tipWidth-options.offset);coords.set("top",session.currentY-tipHeight-options.offset)}}tipElement.css(coords)}}function positionTipOnElement(element){var priorityList,finalPlacement;if(options.smartPlacement||options.followMouse&&element.data(DATA_FORCEDOPEN)){priorityList=$.fn.powerTip.smartPlacementLists[options.placement];$.each(priorityList,function(idx,pos){var collisions=getViewportCollisions(placeTooltip(element,pos),tipElement.outerWidth(),tipElement.outerHeight());finalPlacement=pos;return collisions!==Collision.none})}else{placeTooltip(element,options.placement);finalPlacement=options.placement}tipElement.removeClass("w nw sw e ne se n s w se-alt sw-alt ne-alt nw-alt");tipElement.addClass(finalPlacement)}function placeTooltip(element,placement){var iterationCount=0,tipWidth,tipHeight,coords=new CSSCoordinates;coords.set("top",0);coords.set("left",0);tipElement.css(coords);do{tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=placementCalculator.compute(element,placement,tipWidth,tipHeight,options.offset);tipElement.css(coords)}while(++iterationCount<=5&&(tipWidth!==tipElement.outerWidth()||tipHeight!==tipElement.outerHeight()));return coords}function closeDesyncedTip(){var isDesynced=false,hasDesyncableCloseEvent=$.grep(["mouseleave","mouseout","blur","focusout"],function(eventType){return $.inArray(eventType,options.closeEvents)!==-1}).length>0;if(session.isTipOpen&&!session.isClosing&&!session.delayInProgress&&hasDesyncableCloseEvent){if(session.activeHover.data(DATA_HASACTIVEHOVER)===false||session.activeHover.is(":disabled")){isDesynced=true}else if(!isMouseOver(session.activeHover)&&!session.activeHover.is(":focus")&&!session.activeHover.data(DATA_FORCEDOPEN)){if(tipElement.data(DATA_MOUSEONTOTIP)){if(!isMouseOver(tipElement)){isDesynced=true}}else{isDesynced=true}}if(isDesynced){hideTip(session.activeHover)}}}this.showTip=beginShowTip;this.hideTip=hideTip;this.resetPosition=positionTipOnElement}function isSvgElement(element){return Boolean(window.SVGElement&&element[0]instanceof SVGElement)}function isMouseEvent(event){return Boolean(event&&$.inArray(event.type,MOUSE_EVENTS)>-1&&typeof event.pageX==="number")}function initTracking(){if(!session.mouseTrackingActive){session.mouseTrackingActive=true;getViewportDimensions();$(getViewportDimensions);$document.on("mousemove"+EVENT_NAMESPACE,trackMouse);$window.on("resize"+EVENT_NAMESPACE,trackResize);$window.on("scroll"+EVENT_NAMESPACE,trackScroll)}}function getViewportDimensions(){session.scrollLeft=$window.scrollLeft();session.scrollTop=$window.scrollTop();session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackResize(){session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackScroll(){var x=$window.scrollLeft(),y=$window.scrollTop();if(x!==session.scrollLeft){session.currentX+=x-session.scrollLeft;session.scrollLeft=x}if(y!==session.scrollTop){session.currentY+=y-session.scrollTop;session.scrollTop=y}}function trackMouse(event){session.currentX=event.pageX;session.currentY=event.pageY}function isMouseOver(element){var elementPosition=element.offset(),elementBox=element[0].getBoundingClientRect(),elementWidth=elementBox.right-elementBox.left,elementHeight=elementBox.bottom-elementBox.top;return session.currentX>=elementPosition.left&&session.currentX<=elementPosition.left+elementWidth&&session.currentY>=elementPosition.top&&session.currentY<=elementPosition.top+elementHeight}function getTooltipContent(element){var tipText=element.data(DATA_POWERTIP),tipObject=element.data(DATA_POWERTIPJQ),tipTarget=element.data(DATA_POWERTIPTARGET),targetElement,content;if(tipText){if($.isFunction(tipText)){tipText=tipText.call(element[0])}content=tipText}else if(tipObject){if($.isFunction(tipObject)){tipObject=tipObject.call(element[0])}if(tipObject.length>0){content=tipObject.clone(true,true)}}else if(tipTarget){targetElement=$("#"+tipTarget);if(targetElement.length>0){content=targetElement.html()}}return content}function getViewportCollisions(coords,elementWidth,elementHeight){var viewportTop=session.scrollTop,viewportLeft=session.scrollLeft,viewportBottom=viewportTop+session.windowHeight,viewportRight=viewportLeft+session.windowWidth,collisions=Collision.none;if(coords.topviewportBottom||Math.abs(coords.bottom-session.windowHeight)>viewportBottom){collisions|=Collision.bottom}if(coords.leftviewportRight){collisions|=Collision.left}if(coords.left+elementWidth>viewportRight||coords.right1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);/*! SmartMenus jQuery Plugin - v1.1.0 - September 17, 2017 + * http://www.smartmenus.org/ + * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function($){function initMouseDetection(t){var e=".smartmenus_mouse";if(mouseDetectionEnabled||t)mouseDetectionEnabled&&t&&($(document).off(e),mouseDetectionEnabled=!1);else{var i=!0,s=null,o={mousemove:function(t){var e={x:t.pageX,y:t.pageY,timeStamp:(new Date).getTime()};if(s){var o=Math.abs(s.x-e.x),a=Math.abs(s.y-e.y);if((o>0||a>0)&&2>=o&&2>=a&&300>=e.timeStamp-s.timeStamp&&(mouse=!0,i)){var n=$(t.target).closest("a");n.is("a")&&$.each(menuTrees,function(){return $.contains(this.$root[0],n[0])?(this.itemEnter({currentTarget:n[0]}),!1):void 0}),i=!1}}s=e}};o[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut"]=function(t){isTouchEvent(t.originalEvent)&&(mouse=!1)},$(document).on(getEventsNS(o,e)),mouseDetectionEnabled=!0}}function isTouchEvent(t){return!/^(4|mouse)$/.test(t.pointerType)}function getEventsNS(t,e){e||(e="");var i={};for(var s in t)i[s.split(" ").join(e+" ")+e]=t[s];return i}var menuTrees=[],mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(t){clearTimeout(t)},canAnimate=!!$.fn.animate;return $.SmartMenus=function(t,e){this.$root=$(t),this.opts=e,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in t.style||"webkitPerspective"in t.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(t){var e=this;if(!t){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var i=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).on(getEventsNS({"mouseover focusin":$.proxy(this.rootOver,this),"mouseout focusout":$.proxy(this.rootOut,this),keydown:$.proxy(this.rootKeyDown,this)},i)).on(getEventsNS({mouseenter:$.proxy(this.itemEnter,this),mouseleave:$.proxy(this.itemLeave,this),mousedown:$.proxy(this.itemDown,this),focus:$.proxy(this.itemFocus,this),blur:$.proxy(this.itemBlur,this),click:$.proxy(this.itemClick,this)},i),"a"),i+=this.rootId,this.opts.hideOnClick&&$(document).on(getEventsNS({touchstart:$.proxy(this.docTouchStart,this),touchmove:$.proxy(this.docTouchMove,this),touchend:$.proxy(this.docTouchEnd,this),click:$.proxy(this.docClick,this)},i)),$(window).on(getEventsNS({"resize orientationchange":$.proxy(this.winResize,this)},i)),this.opts.subIndicators&&(this.$subArrow=$("").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){e.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var s=/(index|default)\.[^#\?\/]*/i,o=/#.*/,a=window.location.href.replace(s,""),n=a.replace(o,"");this.$root.find("a").each(function(){var t=this.href.replace(s,""),i=$(this);(t==a||t==n)&&(i.addClass("current"),e.opts.markCurrentTree&&i.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(t){if(!t){var e=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").off(e),e+=this.rootId,$(document).off(e),$(window).off(e),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var i=this;this.$root.find("ul").each(function(){var t=$(this);t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.dataSM("shown-before")&&((i.opts.subMenusMinWidth||i.opts.subMenusMaxWidth)&&t.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(t.attr("id")||"").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-expanded"),this.$root.find("a.has-submenu").each(function(){var t=$(this);0==t.attr("id").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeClass("has-submenu").removeDataSM("sub").removeAttr("aria-haspopup").removeAttr("aria-controls").removeAttr("aria-expanded").closest("li").removeDataSM("sub"),this.opts.subIndicators&&this.$root.find("span.sub-arrow").remove(),this.opts.markCurrentItem&&this.$root.find("a.current").removeClass("current"),t||(this.$root=null,this.$firstLink=null,this.$firstSub=null,this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),menuTrees.splice($.inArray(this,menuTrees),1))},disable:function(t){if(!this.disabled){if(this.menuHideAll(),!t&&!this.opts.isPopup&&this.$root.is(":visible")){var e=this.$root.offset();this.$disableOverlay=$('
').css({position:"absolute",top:e.top,left:e.left,width:this.$root.outerWidth(),height:this.$root.outerHeight(),zIndex:this.getStartZIndex(!0),opacity:0}).appendTo(document.body)}this.disabled=!0}},docClick:function(t){return this.$touchScrollingSub?(this.$touchScrollingSub=null,void 0):((this.visibleSubMenus.length&&!$.contains(this.$root[0],t.target)||$(t.target).closest("a").length)&&this.menuHideAll(),void 0)},docTouchEnd:function(){if(this.lastTouch){if(!(!this.visibleSubMenus.length||void 0!==this.lastTouch.x2&&this.lastTouch.x1!=this.lastTouch.x2||void 0!==this.lastTouch.y2&&this.lastTouch.y1!=this.lastTouch.y2||this.lastTouch.target&&$.contains(this.$root[0],this.lastTouch.target))){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var t=this;this.hideTimeout=setTimeout(function(){t.menuHideAll()},350)}this.lastTouch=null}},docTouchMove:function(t){if(this.lastTouch){var e=t.originalEvent.touches[0];this.lastTouch.x2=e.pageX,this.lastTouch.y2=e.pageY}},docTouchStart:function(t){var e=t.originalEvent.touches[0];this.lastTouch={x1:e.pageX,y1:e.pageY,target:e.target}},enable:function(){this.disabled&&(this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),this.disabled=!1)},getClosestMenu:function(t){for(var e=$(t).closest("ul");e.dataSM("in-mega");)e=e.parent().closest("ul");return e[0]||null},getHeight:function(t){return this.getOffset(t,!0)},getOffset:function(t,e){var i;"none"==t.css("display")&&(i={position:t[0].style.position,visibility:t[0].style.visibility},t.css({position:"absolute",visibility:"hidden"}).show());var s=t[0].getBoundingClientRect&&t[0].getBoundingClientRect(),o=s&&(e?s.height||s.bottom-s.top:s.width||s.right-s.left);return o||0===o||(o=e?t[0].offsetHeight:t[0].offsetWidth),i&&t.hide().css(i),o},getStartZIndex:function(t){var e=parseInt(this[t?"$root":"$firstSub"].css("z-index"));return!t&&isNaN(e)&&(e=parseInt(this.$root.css("z-index"))),isNaN(e)?1:e},getTouchPoint:function(t){return t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t},getViewport:function(t){var e=t?"Height":"Width",i=document.documentElement["client"+e],s=window["inner"+e];return s&&(i=Math.min(i,s)),i},getViewportHeight:function(){return this.getViewport(!0)},getViewportWidth:function(){return this.getViewport()},getWidth:function(t){return this.getOffset(t)},handleEvents:function(){return!this.disabled&&this.isCSSOn()},handleItemEvents:function(t){return this.handleEvents()&&!this.isLinkInMegaMenu(t)},isCollapsible:function(){return"static"==this.$firstSub.css("position")},isCSSOn:function(){return"inline"!=this.$firstLink.css("display")},isFixed:function(){var t="fixed"==this.$root.css("position");return t||this.$root.parentsUntil("body").each(function(){return"fixed"==$(this).css("position")?(t=!0,!1):void 0}),t},isLinkInMegaMenu:function(t){return $(this.getClosestMenu(t[0])).hasClass("mega-menu")},isTouchMode:function(){return!mouse||this.opts.noMouseOver||this.isCollapsible()},itemActivate:function(t,e){var i=t.closest("ul"),s=i.dataSM("level");if(s>1&&(!this.activatedItems[s-2]||this.activatedItems[s-2][0]!=i.dataSM("parent-a")[0])){var o=this;$(i.parentsUntil("[data-smartmenus-id]","ul").get().reverse()).add(i).each(function(){o.itemActivate($(this).dataSM("parent-a"))})}if((!this.isCollapsible()||e)&&this.menuHideSubMenus(this.activatedItems[s-1]&&this.activatedItems[s-1][0]==t[0]?s:s-1),this.activatedItems[s-1]=t,this.$root.triggerHandler("activate.smapi",t[0])!==!1){var a=t.dataSM("sub");a&&(this.isTouchMode()||!this.opts.showOnClick||this.clickActivated)&&this.menuShow(a)}},itemBlur:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&this.$root.triggerHandler("blur.smapi",e[0])},itemClick:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(this.$touchScrollingSub&&this.$touchScrollingSub[0]==e.closest("ul")[0])return this.$touchScrollingSub=null,t.stopPropagation(),!1;if(this.$root.triggerHandler("click.smapi",e[0])===!1)return!1;var i=$(t.target).is(".sub-arrow"),s=e.dataSM("sub"),o=s?2==s.dataSM("level"):!1,a=this.isCollapsible(),n=/toggle$/.test(this.opts.collapsibleBehavior),r=/link$/.test(this.opts.collapsibleBehavior),h=/^accordion/.test(this.opts.collapsibleBehavior);if(s&&!s.is(":visible")){if((!r||!a||i)&&(this.opts.showOnClick&&o&&(this.clickActivated=!0),this.itemActivate(e,h),s.is(":visible")))return this.focusActivated=!0,!1}else if(a&&(n||i))return this.itemActivate(e,h),this.menuHide(s),n&&(this.focusActivated=!1),!1;return this.opts.showOnClick&&o||e.hasClass("disabled")||this.$root.triggerHandler("select.smapi",e[0])===!1?!1:void 0}},itemDown:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&e.dataSM("mousedown",!0)},itemEnter:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(!this.isTouchMode()){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);var i=this;this.showTimeout=setTimeout(function(){i.itemActivate(e)},this.opts.showOnClick&&1==e.closest("ul").dataSM("level")?1:this.opts.showTimeout)}this.$root.triggerHandler("mouseenter.smapi",e[0])}},itemFocus:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(!this.focusActivated||this.isTouchMode()&&e.dataSM("mousedown")||this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0]==e[0]||this.itemActivate(e,!0),this.$root.triggerHandler("focus.smapi",e[0]))},itemLeave:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(this.isTouchMode()||(e[0].blur(),this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0)),e.removeDataSM("mousedown"),this.$root.triggerHandler("mouseleave.smapi",e[0]))},menuHide:function(t){if(this.$root.triggerHandler("beforehide.smapi",t[0])!==!1&&(canAnimate&&t.stop(!0,!0),"none"!=t.css("display"))){var e=function(){t.css("z-index","")};this.isCollapsible()?canAnimate&&this.opts.collapsibleHideFunction?this.opts.collapsibleHideFunction.call(this,t,e):t.hide(this.opts.collapsibleHideDuration,e):canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,t,e):t.hide(this.opts.hideDuration,e),t.dataSM("scroll")&&(this.menuScrollStop(t),t.css({"touch-action":"","-ms-touch-action":"","-webkit-transform":"",transform:""}).off(".smartmenus_scroll").removeDataSM("scroll").dataSM("scroll-arrows").hide()),t.dataSM("parent-a").removeClass("highlighted").attr("aria-expanded","false"),t.attr({"aria-expanded":"false","aria-hidden":"true"});var i=t.dataSM("level");this.activatedItems.splice(i-1,1),this.visibleSubMenus.splice($.inArray(t,this.visibleSubMenus),1),this.$root.triggerHandler("hide.smapi",t[0])}},menuHideAll:function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);for(var t=this.opts.isPopup?1:0,e=this.visibleSubMenus.length-1;e>=t;e--)this.menuHide(this.visibleSubMenus[e]);this.opts.isPopup&&(canAnimate&&this.$root.stop(!0,!0),this.$root.is(":visible")&&(canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,this.$root):this.$root.hide(this.opts.hideDuration))),this.activatedItems=[],this.visibleSubMenus=[],this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.$root.triggerHandler("hideAll.smapi")},menuHideSubMenus:function(t){for(var e=this.activatedItems.length-1;e>=t;e--){var i=this.activatedItems[e].dataSM("sub");i&&this.menuHide(i)}},menuInit:function(t){if(!t.dataSM("in-mega")){t.hasClass("mega-menu")&&t.find("ul").dataSM("in-mega",!0);for(var e=2,i=t[0];(i=i.parentNode.parentNode)!=this.$root[0];)e++;var s=t.prevAll("a").eq(-1);s.length||(s=t.prevAll().find("a").eq(-1)),s.addClass("has-submenu").dataSM("sub",t),t.dataSM("parent-a",s).dataSM("level",e).parent().dataSM("sub",t);var o=s.attr("id")||this.accessIdPrefix+ ++this.idInc,a=t.attr("id")||this.accessIdPrefix+ ++this.idInc;s.attr({id:o,"aria-haspopup":"true","aria-controls":a,"aria-expanded":"false"}),t.attr({id:a,role:"group","aria-hidden":"true","aria-labelledby":o,"aria-expanded":"false"}),this.opts.subIndicators&&s[this.opts.subIndicatorsPos](this.$subArrow.clone())}},menuPosition:function(t){var e,i,s=t.dataSM("parent-a"),o=s.closest("li"),a=o.parent(),n=t.dataSM("level"),r=this.getWidth(t),h=this.getHeight(t),u=s.offset(),l=u.left,c=u.top,d=this.getWidth(s),m=this.getHeight(s),p=$(window),f=p.scrollLeft(),v=p.scrollTop(),b=this.getViewportWidth(),S=this.getViewportHeight(),g=a.parent().is("[data-sm-horizontal-sub]")||2==n&&!a.hasClass("sm-vertical"),M=this.opts.rightToLeftSubMenus&&!o.is("[data-sm-reverse]")||!this.opts.rightToLeftSubMenus&&o.is("[data-sm-reverse]"),w=2==n?this.opts.mainMenuSubOffsetX:this.opts.subMenusSubOffsetX,T=2==n?this.opts.mainMenuSubOffsetY:this.opts.subMenusSubOffsetY;if(g?(e=M?d-r-w:w,i=this.opts.bottomToTopSubMenus?-h-T:m+T):(e=M?w-r:d-w,i=this.opts.bottomToTopSubMenus?m-T-h:T),this.opts.keepInViewport){var y=l+e,I=c+i;if(M&&f>y?e=g?f-y+e:d-w:!M&&y+r>f+b&&(e=g?f+b-r-y+e:w-r),g||(S>h&&I+h>v+S?i+=v+S-h-I:(h>=S||v>I)&&(i+=v-I)),g&&(I+h>v+S+.49||v>I)||!g&&h>S+.49){var x=this;t.dataSM("scroll-arrows")||t.dataSM("scroll-arrows",$([$('')[0],$('')[0]]).on({mouseenter:function(){t.dataSM("scroll").up=$(this).hasClass("scroll-up"),x.menuScroll(t)},mouseleave:function(e){x.menuScrollStop(t),x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(t){t.preventDefault()}}).insertAfter(t));var A=".smartmenus_scroll";if(t.dataSM("scroll",{y:this.cssTransforms3d?0:i-m,step:1,itemH:m,subH:h,arrowDownH:this.getHeight(t.dataSM("scroll-arrows").eq(1))}).on(getEventsNS({mouseover:function(e){x.menuScrollOver(t,e)},mouseout:function(e){x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(e){x.menuScrollMousewheel(t,e)}},A)).dataSM("scroll-arrows").css({top:"auto",left:"0",marginLeft:e+(parseInt(t.css("border-left-width"))||0),width:r-(parseInt(t.css("border-left-width"))||0)-(parseInt(t.css("border-right-width"))||0),zIndex:t.css("z-index")}).eq(g&&this.opts.bottomToTopSubMenus?0:1).show(),this.isFixed()){var C={};C[touchEvents?"touchstart touchmove touchend":"pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp"]=function(e){x.menuScrollTouch(t,e)},t.css({"touch-action":"none","-ms-touch-action":"none"}).on(getEventsNS(C,A))}}}t.css({top:"auto",left:"0",marginLeft:e,marginTop:i-m})},menuScroll:function(t,e,i){var s,o=t.dataSM("scroll"),a=t.dataSM("scroll-arrows"),n=o.up?o.upEnd:o.downEnd;if(!e&&o.momentum){if(o.momentum*=.92,s=o.momentum,.5>s)return this.menuScrollStop(t),void 0}else s=i||(e||!this.opts.scrollAccelerate?this.opts.scrollStep:Math.floor(o.step));var r=t.dataSM("level");if(this.activatedItems[r-1]&&this.activatedItems[r-1].dataSM("sub")&&this.activatedItems[r-1].dataSM("sub").is(":visible")&&this.menuHideSubMenus(r-1),o.y=o.up&&o.y>=n||!o.up&&n>=o.y?o.y:Math.abs(n-o.y)>s?o.y+(o.up?s:-s):n,t.css(this.cssTransforms3d?{"-webkit-transform":"translate3d(0, "+o.y+"px, 0)",transform:"translate3d(0, "+o.y+"px, 0)"}:{marginTop:o.y}),mouse&&(o.up&&o.y>o.downEnd||!o.up&&o.y0;t.dataSM("scroll-arrows").eq(i?0:1).is(":visible")&&(t.dataSM("scroll").up=i,this.menuScroll(t,!0))}e.preventDefault()},menuScrollOut:function(t,e){mouse&&(/^scroll-(up|down)/.test((e.relatedTarget||"").className)||(t[0]==e.relatedTarget||$.contains(t[0],e.relatedTarget))&&this.getClosestMenu(e.relatedTarget)==t[0]||t.dataSM("scroll-arrows").css("visibility","hidden"))},menuScrollOver:function(t,e){if(mouse&&!/^scroll-(up|down)/.test(e.target.className)&&this.getClosestMenu(e.target)==t[0]){this.menuScrollRefreshData(t);var i=t.dataSM("scroll"),s=$(window).scrollTop()-t.dataSM("parent-a").offset().top-i.itemH;t.dataSM("scroll-arrows").eq(0).css("margin-top",s).end().eq(1).css("margin-top",s+this.getViewportHeight()-i.arrowDownH).end().css("visibility","visible")}},menuScrollRefreshData:function(t){var e=t.dataSM("scroll"),i=$(window).scrollTop()-t.dataSM("parent-a").offset().top-e.itemH;this.cssTransforms3d&&(i=-(parseFloat(t.css("margin-top"))-i)),$.extend(e,{upEnd:i,downEnd:i+this.getViewportHeight()-e.subH})},menuScrollStop:function(t){return this.scrollTimeout?(cancelAnimationFrame(this.scrollTimeout),this.scrollTimeout=0,t.dataSM("scroll").step=1,!0):void 0},menuScrollTouch:function(t,e){if(e=e.originalEvent,isTouchEvent(e)){var i=this.getTouchPoint(e);if(this.getClosestMenu(i.target)==t[0]){var s=t.dataSM("scroll");if(/(start|down)$/i.test(e.type))this.menuScrollStop(t)?(e.preventDefault(),this.$touchScrollingSub=t):this.$touchScrollingSub=null,this.menuScrollRefreshData(t),$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp});else if(/move$/i.test(e.type)){var o=void 0!==s.touchY?s.touchY:s.touchStartY;if(void 0!==o&&o!=i.pageY){this.$touchScrollingSub=t;var a=i.pageY>o;void 0!==s.up&&s.up!=a&&$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp}),$.extend(s,{up:a,touchY:i.pageY}),this.menuScroll(t,!0,Math.abs(i.pageY-o))}e.preventDefault()}else void 0!==s.touchY&&((s.momentum=15*Math.pow(Math.abs(i.pageY-s.touchStartY)/(e.timeStamp-s.touchStartTime),2))&&(this.menuScrollStop(t),this.menuScroll(t),e.preventDefault()),delete s.touchY)}}},menuShow:function(t){if((t.dataSM("beforefirstshowfired")||(t.dataSM("beforefirstshowfired",!0),this.$root.triggerHandler("beforefirstshow.smapi",t[0])!==!1))&&this.$root.triggerHandler("beforeshow.smapi",t[0])!==!1&&(t.dataSM("shown-before",!0),canAnimate&&t.stop(!0,!0),!t.is(":visible"))){var e=t.dataSM("parent-a"),i=this.isCollapsible();if((this.opts.keepHighlighted||i)&&e.addClass("highlighted"),i)t.removeClass("sm-nowrap").css({zIndex:"",width:"auto",minWidth:"",maxWidth:"",top:"",left:"",marginLeft:"",marginTop:""});else{if(t.css("z-index",this.zIndexInc=(this.zIndexInc||this.getStartZIndex())+1),(this.opts.subMenusMinWidth||this.opts.subMenusMaxWidth)&&(t.css({width:"auto",minWidth:"",maxWidth:""}).addClass("sm-nowrap"),this.opts.subMenusMinWidth&&t.css("min-width",this.opts.subMenusMinWidth),this.opts.subMenusMaxWidth)){var s=this.getWidth(t);t.css("max-width",this.opts.subMenusMaxWidth),s>this.getWidth(t)&&t.removeClass("sm-nowrap").css("width",this.opts.subMenusMaxWidth)}this.menuPosition(t)}var o=function(){t.css("overflow","")};i?canAnimate&&this.opts.collapsibleShowFunction?this.opts.collapsibleShowFunction.call(this,t,o):t.show(this.opts.collapsibleShowDuration,o):canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,t,o):t.show(this.opts.showDuration,o),e.attr("aria-expanded","true"),t.attr({"aria-expanded":"true","aria-hidden":"false"}),this.visibleSubMenus.push(t),this.$root.triggerHandler("show.smapi",t[0])}},popupHide:function(t){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},t?1:this.opts.hideTimeout)},popupShow:function(t,e){if(!this.opts.isPopup)return alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.'),void 0;if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),this.$root.dataSM("shown-before",!0),canAnimate&&this.$root.stop(!0,!0),!this.$root.is(":visible")){this.$root.css({left:t,top:e});var i=this,s=function(){i.$root.css("overflow","")};canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,this.$root,s):this.$root.show(this.opts.showDuration,s),this.visibleSubMenus[0]=this.$root}},refresh:function(){this.destroy(!0),this.init(!0)},rootKeyDown:function(t){if(this.handleEvents())switch(t.keyCode){case 27:var e=this.activatedItems[0];if(e){this.menuHideAll(),e[0].focus();var i=e.dataSM("sub");i&&this.menuHide(i)}break;case 32:var s=$(t.target);if(s.is("a")&&this.handleItemEvents(s)){var i=s.dataSM("sub");i&&!i.is(":visible")&&(this.itemClick({currentTarget:t.target}),t.preventDefault())}}},rootOut:function(t){if(this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),!this.opts.showOnClick||!this.opts.hideOnClick)){var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},this.opts.hideTimeout)}},rootOver:function(t){this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0)},winResize:function(t){if(this.handleEvents()){if(!("onorientationchange"in window)||"orientationchange"==t.type){var e=this.isCollapsible();this.wasCollapsible&&e||(this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0].blur(),this.menuHideAll()),this.wasCollapsible=e}}else if(this.$disableOverlay){var i=this.$root.offset();this.$disableOverlay.css({top:i.top,left:i.left,width:this.$root.outerWidth(),height:this.$root.outerHeight()})}}}}),$.fn.dataSM=function(t,e){return e?this.data(t+"_smartmenus",e):this.data(t+"_smartmenus")},$.fn.removeDataSM=function(t){return this.removeData(t+"_smartmenus")},$.fn.smartmenus=function(options){if("string"==typeof options){var args=arguments,method=options;return Array.prototype.shift.call(args),this.each(function(){var t=$(this).data("smartmenus");t&&t[method]&&t[method].apply(t,args)})}return this.each(function(){var dataOpts=$(this).data("sm-options")||null;if(dataOpts)try{dataOpts=eval("("+dataOpts+")")}catch(e){dataOpts=null,alert('ERROR\n\nSmartMenus jQuery init:\nInvalid "data-sm-options" attribute value syntax.')}new $.SmartMenus(this,$.extend({},$.fn.smartmenus.defaults,options,dataOpts))})},$.fn.smartmenus.defaults={isPopup:!1,mainMenuSubOffsetX:0,mainMenuSubOffsetY:0,subMenusSubOffsetX:0,subMenusSubOffsetY:0,subMenusMinWidth:"10em",subMenusMaxWidth:"20em",subIndicators:!0,subIndicatorsPos:"append",subIndicatorsText:"",scrollStep:30,scrollAccelerate:!0,showTimeout:250,hideTimeout:500,showDuration:0,showFunction:null,hideDuration:0,hideFunction:function(t,e){t.fadeOut(200,e)},collapsibleShowDuration:0,collapsibleShowFunction:function(t,e){t.slideDown(200,e)},collapsibleHideDuration:0,collapsibleHideFunction:function(t,e){t.slideUp(200,e)},showOnClick:!1,hideOnClick:!0,noMouseOver:!1,keepInViewport:!0,keepHighlighted:!0,markCurrentItem:!1,markCurrentTree:!0,rightToLeftSubMenus:!1,bottomToTopSubMenus:!1,collapsibleBehavior:"default"},$}); \ No newline at end of file diff --git a/marge_8h_source.html b/marge_8h_source.html new file mode 100644 index 00000000..45c3011c --- /dev/null +++ b/marge_8h_source.html @@ -0,0 +1,351 @@ + + + + + + + +maug: marge.h Source File + + + + + + + + + + +
+
+ + + + + + +
+
maug +
+
Quick and dirty C mini-augmentation library.
+
+
+ + + + + + + + +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ + +
+
+
marge.h
+
+
+
1
+
2#ifndef MARGE_H
+
3#define MARGE_H
+
4
+
5/* For strlen, strncpy */
+
6#include <string.h>
+
7
+
8#include <merror.h>
+
9
+
16/*
+
17 * | ::MAUG_CLI_SIGIL | Specify the sigil prepended to command-line args. |
+
18 * | MAUG_NO_CLI_SZ | Disable ::MAUG_CLI_SZ command-line args. |
+
19 */
+
20
+
21#ifndef MAUG_CLI_SIGIL_SZ
+
22# define MAUG_CLI_SIGIL_SZ 1
+
23#endif /* !MAUG_CLI_SIGIL_SZ */
+
24
+
25#if !defined( MAUG_CLI_SIGIL ) && defined( MAUG_OS_WIN )
+
26# define MAUG_CLI_SIGIL "/"
+
27#elif !defined( MAUG_CLI_SIGIL ) && defined( MAUG_OS_DOS )
+
28# define MAUG_CLI_SIGIL "/"
+
29#elif !defined( MAUG_CLI_SIGIL )
+
34# define MAUG_CLI_SIGIL "-"
+
35#endif /* !MAUG_CLI_SIGIL */
+
36
+
37
+
38#ifndef MAUG_CLI_ARG_LIST_SZ_MAX
+
39# define MAUG_CLI_ARG_LIST_SZ_MAX 50
+
40#endif /* !MAUG_CLI_ARG_LIST_SZ_MAX */
+
41
+
42#ifndef MAUG_CLI_ARG_HELP_SZ_MAX
+
43# define MAUG_CLI_ARG_HELP_SZ_MAX 255
+
44#endif /* !MAUG_CLI_ARG_HELP_SZ_MAX */
+
45
+
46#ifndef MAUG_CLI_ARG_SZ_MAX
+
47# define MAUG_CLI_ARG_SZ_MAX 50
+
48#endif /* !MAUG_CLI_ARG_SZ_MAX */
+
49
+
50typedef MERROR_RETVAL (*maug_cli_cb)( const char* arg, void* data );
+
51
+
53#define MAUG_CLI( f ) \
+
54 f( MAUG_CLI_SIGIL "h", 3, "Display help and exit.", maug_cli_h, NULL )
+
55
+
56int maug_parse_args( int argc, char* argv[] );
+
57
+ +
67 const char* arg, int arg_sz, const char* help, int help_sz,
+
68 maug_cli_cb arg_cb, maug_cli_cb def_cb, void* data );
+
69
+
70#ifdef MARGE_C
+
71
+
72/* == Global Tables == */
+
73
+
74#define MAUG_CLI_ARG_ARG( arg, arg_sz, help, arg_callback, def_callback ) \
+
75 arg,
+
76
+
77static char g_maug_cli_args[MAUG_CLI_ARG_LIST_SZ_MAX][MAUG_CLI_ARG_SZ_MAX] = {
+
78 MAUG_CLI( MAUG_CLI_ARG_ARG )
+
79 ""
+
80};
+
81
+
82#define MAUG_CLI_ARG_SZ( arg, arg_sz, help, arg_callback, def_callback ) \
+
83 arg_sz,
+
84
+
85static int g_maug_cli_arg_sz[MAUG_CLI_ARG_LIST_SZ_MAX] = {
+
86 MAUG_CLI( MAUG_CLI_ARG_SZ )
+
87 0
+
88};
+
89
+
90#define MAUG_CLI_ARG_HELP( arg, arg_sz, help, arg_callback, def_callback ) \
+
91 help,
+
92
+
93static char g_maug_cli_arg_help[MAUG_CLI_ARG_LIST_SZ_MAX][MAUG_CLI_ARG_HELP_SZ_MAX] = {
+
94 MAUG_CLI( MAUG_CLI_ARG_HELP )
+
95 ""
+
96};
+
97
+
98#define MAUG_CLI_ARG_DATA( arg, arg_sz, help, arg_callback, def_callback ) NULL,
+
99static void* g_maug_cli_data[MAUG_CLI_ARG_LIST_SZ_MAX] = {
+
100 MAUG_CLI( MAUG_CLI_ARG_DATA )
+
101 NULL
+
102};
+
103
+
104#define MAUG_CLI_ARG_CALLED( arg, arg_sz, help, arg_callback, def_callback ) 0,
+
105static int g_maug_cli_arg_called[MAUG_CLI_ARG_LIST_SZ_MAX] = {
+
106 MAUG_CLI( MAUG_CLI_ARG_CALLED )
+
107 0
+
108};
+
109
+
110/* == Function Definitions = = */
+
111
+
112static int maug_cli_h( const char* arg, void* args ) {
+
113 int i = 0;
+
114
+
115 fprintf( stderr, "usage:\n\n" );
+
116
+
117 /* Display help for all available options. */
+
118 while( '\0' != g_maug_cli_args[i][0] ) {
+
119 fprintf( stderr, "\t%s\t%s\n", g_maug_cli_args[i],
+
120 g_maug_cli_arg_help[i] );
+
121 i++;
+
122 }
+
123
+
124 fprintf( stderr, "\n" );
+
125
+
126 /* TODO: Coherent error code. */
+
127 return -1;
+
128}
+
129
+
130/* === */
+
131
+
132/* Define these below the built-in callbacks, above. */
+
133#define MAUG_CLI_ARG_CB( arg, arg_sz, help, arg_callback, def_callback ) \
+
134 arg_callback,
+
135
+
136maug_cli_cb g_maug_cli_arg_callbacks[MAUG_CLI_ARG_LIST_SZ_MAX] = {
+
137 MAUG_CLI( MAUG_CLI_ARG_CB )
+
138 NULL
+
139};
+
140
+
141#define MAUG_CLI_DEF_CB( arg, arg_sz, help, arg_callback, def_callback ) \
+
142 def_callback,
+
143
+
144maug_cli_cb g_maug_cli_def_callbacks[MAUG_CLI_ARG_LIST_SZ_MAX] = {
+
145 MAUG_CLI( MAUG_CLI_DEF_CB )
+
146 NULL
+
147};
+
148
+
149int maug_parse_args( int argc, char* argv[] ) {
+
150 int arg_i = 0,
+
151 const_i = 0,
+
152 last_i = 0,
+
153 retval = 0;
+
154
+
155 for( arg_i = 1 ; argc > arg_i ; arg_i++ ) {
+
156 debug_printf( 1, "found arg: %s", argv[arg_i] );
+
157 const_i = 0;
+
158 while( '\0' != g_maug_cli_args[const_i][0] ) {
+
159 if( 0 == strncmp(
+
160 g_maug_cli_args[const_i],
+
161 argv[arg_i],
+
162 g_maug_cli_arg_sz[const_i]
+
163 ) ) {
+
164 /* Save this matched index for the next pass. */
+
165 last_i = const_i;
+
166
+
167 /* Increment called count and run the callback. */
+
168 g_maug_cli_arg_called[const_i]++;
+
169 retval = g_maug_cli_arg_callbacks[const_i]( argv[arg_i],
+
170 g_maug_cli_data[const_i] );
+
171 if( MERROR_OK != retval ) {
+
172 goto cleanup;
+
173 }
+
174
+
175 /* We found a match, so go to the next arg. */
+
176 break;
+
177 }
+
178 const_i++;
+
179 }
+
180
+
181 if( '\0' == g_maug_cli_args[const_i][0] ) {
+
182 /* No valid arg was found, so we must be passing data to the last one!
+
183 */
+
184 g_maug_cli_arg_called[last_i]++;
+
185 retval = g_maug_cli_arg_callbacks[last_i]( argv[arg_i],
+
186 g_maug_cli_data[last_i] );
+
187 if( MERROR_OK != retval ) {
+
188 goto cleanup;
+
189 }
+
190 }
+
191 }
+
192
+
193 /* TODO: Run default callbacks for any args not called. */
+
194 const_i = 0;
+
195 while( '\0' != g_maug_cli_args[const_i][0] ) {
+
196 if(
+
197 0 == g_maug_cli_arg_called[const_i] &&
+
198 NULL != g_maug_cli_def_callbacks[const_i]
+
199 ) {
+
200 debug_printf( 1, "calling default arg for uncalled \"%s\"...",
+
201 g_maug_cli_args[const_i] );
+
202 retval =
+
203 g_maug_cli_def_callbacks[const_i]( "", g_maug_cli_data[const_i] );
+
204 if( MERROR_OK != retval ) {
+
205 goto cleanup;
+
206 }
+
207 }
+
208 const_i++;
+
209 }
+
210
+
211cleanup:
+
212
+
213 return retval;
+
214}
+
215
+
216/* === */
+
217
+ +
219 const char* arg, int arg_sz, const char* help, int help_sz,
+
220 maug_cli_cb arg_cb, maug_cli_cb def_cb, void* data
+
221) {
+
222 int slot_idx = 0;
+
223
+
224 /* Find empty arg slot. */
+
225 while(
+
226 '\0' != g_maug_cli_args[slot_idx][0] &&
+
227 MAUG_CLI_ARG_LIST_SZ_MAX > slot_idx
+
228 ) {
+
229 slot_idx++;
+
230 }
+
231
+
232 /* TODO: Check for duplicate arg. */
+
233
+
234 /* Sanity checking and sizing. */
+
235 if( MAUG_CLI_ARG_LIST_SZ_MAX <= slot_idx ) {
+
236 return MERROR_MARGE;
+
237 }
+
238
+
239 if( 0 >= arg_sz ) {
+
240 arg_sz = strlen( arg );
+
241 }
+
242 assert( arg_sz < MAUG_CLI_ARG_SZ_MAX );
+
243
+
244 if( 0 >= help_sz ) {
+
245 help_sz = strlen( help );
+
246 }
+
247 assert( help_sz < MAUG_CLI_ARG_HELP_SZ_MAX );
+
248
+
249 /* Add arg to arrays. */
+
250
+
251 strncpy( g_maug_cli_args[slot_idx], arg, arg_sz );
+
252 g_maug_cli_args[slot_idx + 1][0] = '\0';
+
253
+
254 strncpy( g_maug_cli_arg_help[slot_idx], help, help_sz );
+
255 g_maug_cli_arg_help[slot_idx + 1][0] = '\0';
+
256
+
257 g_maug_cli_arg_sz[slot_idx] = arg_sz;
+
258 g_maug_cli_arg_sz[slot_idx + 1] = 0;
+
259
+
260 g_maug_cli_arg_callbacks[slot_idx] = arg_cb;
+
261 g_maug_cli_arg_callbacks[slot_idx + 1] = NULL;
+
262
+
263 g_maug_cli_def_callbacks[slot_idx] = def_cb;
+
264 g_maug_cli_def_callbacks[slot_idx + 1] = NULL;
+
265
+
266 g_maug_cli_arg_called[slot_idx] = 0;
+
267 g_maug_cli_arg_called[slot_idx + 1] = 0;
+
268
+
269 g_maug_cli_data[slot_idx] = data;
+
270 g_maug_cli_data[slot_idx + 1] = NULL;
+
271
+
272 return MERROR_OK;
+
273}
+
274
+
275#endif /* MARGE_C */
+
276 /* maug_cli */
+
278
+
279#endif /* MARGE_H */
+
280
+
#define MAUG_CLI(f)
Default CLI arguments for all RetroFlat programs.
Definition marge.h:53
+
MERROR_RETVAL maug_add_arg(const char *arg, int arg_sz, const char *help, int help_sz, maug_cli_cb arg_cb, maug_cli_cb def_cb, void *data)
Add a command-line argument to the built-in parser.
+
int MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition merror.h:19
+ +
+ + + + diff --git a/menu.js b/menu.js new file mode 100644 index 00000000..b0b26936 --- /dev/null +++ b/menu.js @@ -0,0 +1,136 @@ +/* + @licstart The following is the entire license notice for the JavaScript code in this file. + + The MIT License (MIT) + + Copyright (C) 1997-2020 by Dimitri van Heesch + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file + */ +function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { + function makeTree(data,relPath) { + var result=''; + if ('children' in data) { + result+='
    '; + for (var i in data.children) { + var url; + var link; + link = data.children[i].url; + if (link.substring(0,1)=='^') { + url = link.substring(1); + } else { + url = relPath+link; + } + result+='
  • '+ + data.children[i].text+''+ + makeTree(data.children[i],relPath)+'
  • '; + } + result+='
'; + } + return result; + } + var searchBoxHtml; + if (searchEnabled) { + if (serverSide) { + searchBoxHtml='
'+ + '
'+ + '
 '+ + ''+ + '
'+ + '
'+ + '
'+ + '
'; + } else { + searchBoxHtml='
'+ + ''+ + ' '+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
'; + } + } + + $('#main-nav').before('
'+ + ''+ + ''+ + '
'); + $('#main-nav').append(makeTree(menudata,relPath)); + $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); + if (searchBoxHtml) { + $('#main-menu').append('
  • '); + } + var $mainMenuState = $('#main-menu-state'); + var prevWidth = 0; + if ($mainMenuState.length) { + function initResizableIfExists() { + if (typeof initResizable==='function') initResizable(); + } + // animate mobile menu + $mainMenuState.change(function(e) { + var $menu = $('#main-menu'); + var options = { duration: 250, step: initResizableIfExists }; + if (this.checked) { + options['complete'] = function() { $menu.css('display', 'block') }; + $menu.hide().slideDown(options); + } else { + options['complete'] = function() { $menu.css('display', 'none') }; + $menu.show().slideUp(options); + } + }); + // set default menu visibility + function resetState() { + var $menu = $('#main-menu'); + var $mainMenuState = $('#main-menu-state'); + var newWidth = $(window).outerWidth(); + if (newWidth!=prevWidth) { + if ($(window).outerWidth()<768) { + $mainMenuState.prop('checked',false); $menu.hide(); + $('#searchBoxPos1').html(searchBoxHtml); + $('#searchBoxPos2').hide(); + } else { + $menu.show(); + $('#searchBoxPos1').empty(); + $('#searchBoxPos2').html(searchBoxHtml); + $('#searchBoxPos2').show(); + } + if (typeof searchBox!=='undefined') { + searchBox.CloseResultsWindow(); + } + prevWidth = newWidth; + } + } + $(window).ready(function() { resetState(); initResizableIfExists(); }); + $(window).resize(resetState); + } + $('#main-menu').smartmenus(); +} +/* @license-end */ diff --git a/menudata.js b/menudata.js new file mode 100644 index 00000000..4706491f --- /dev/null +++ b/menudata.js @@ -0,0 +1,48 @@ +/* + @licstart The following is the entire license notice for the JavaScript code in this file. + + The MIT License (MIT) + + Copyright (C) 1997-2020 by Dimitri van Heesch + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file +*/ +var menudata={children:[ +{text:"Main Page",url:"index.html"}, +{text:"Related Pages",url:"pages.html"}, +{text:"Modules",url:"modules.html"}, +{text:"Data Structures",url:"annotated.html",children:[ +{text:"Data Structures",url:"annotated.html"}, +{text:"Data Structure Index",url:"classes.html"}, +{text:"Data Fields",url:"functions.html",children:[ +{text:"All",url:"functions.html"}, +{text:"Functions",url:"functions_func.html"}, +{text:"Variables",url:"functions_vars.html"}]}]}, +{text:"Files",url:"files.html",children:[ +{text:"File List",url:"files.html"}, +{text:"Globals",url:"globals.html",children:[ +{text:"All",url:"globals.html",children:[ +{text:"m",url:"globals.html#index_m"}, +{text:"n",url:"globals.html#index_n"}, +{text:"r",url:"globals.html#index_r"}]}, +{text:"Functions",url:"globals_func.html"}, +{text:"Typedefs",url:"globals_type.html"}, +{text:"Macros",url:"globals_defs.html",children:[ +{text:"m",url:"globals_defs.html#index_m"}, +{text:"n",url:"globals_defs.html#index_n"}, +{text:"r",url:"globals_defs.html#index_r"}]}]}]}]} diff --git a/merror_8h.html b/merror_8h.html new file mode 100644 index 00000000..f90dcf9e --- /dev/null +++ b/merror_8h.html @@ -0,0 +1,162 @@ + + + + + + + +maug: merror.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    merror.h File Reference
    +
    +
    +
    +This graph shows which files directly or indirectly include this file:
    +
    +
    + + + + + + + +
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    +#define MERROR_OK   0x00
     
    +#define MERROR_MARGE   0x01
     
    +#define MERROR_ALLOC   0x02
     
    +#define MERROR_OVERFLOW   0x04
     
    +#define MERROR_FILE   0x08
     
    +#define MERROR_USR   0x0f
     
    +#define MERROR_PARSE   0x10
     
    +#define MERROR_GUI   0x20
     
    #define maug_cleanup_if_null_msg(type, ptr, err, msg)
     
    +#define maug_cleanup_if_null(type, ptr, err)    maug_cleanup_if_null_msg( type, ptr, err, "failed to allocate " #ptr "!" )
     
    +#define maug_cleanup_if_null_alloc(type, ptr)    maug_cleanup_if_null_msg( type, ptr, MERROR_ALLOC, "failed to allocate " #ptr "!" )
     
    +#define maug_cleanup_if_null_file(ptr)    maug_cleanup_if_null_msg( FILE*, ptr, MERROR_FILE, "failed to open FILE!" )
     
    #define maug_cleanup_if_not_ok()
     
    #define maug_cleanup_if_lt(a, b, fmt, err)
     
    +#define maug_cleanup_if_lt_overflow(a, b)    maug_cleanup_if_lt( a, b, SIZE_T_FMT, MERROR_OVERFLOW )
     
    #define maug_cleanup_if_ge(a, b, fmt, err)
     
    +#define maug_cleanup_if_ge_overflow(a, b)    maug_cleanup_if_ge( a, (size_t)(b), SIZE_T_FMT, MERROR_OVERFLOW )
     
    + + + + +

    +Typedefs

    +typedef int MERROR_RETVAL
     Return type indicating function returns a value from this list.
     
    +
    + + + + diff --git a/merror_8h__dep__incl.map b/merror_8h__dep__incl.map new file mode 100644 index 00000000..92446b3f --- /dev/null +++ b/merror_8h__dep__incl.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/merror_8h__dep__incl.md5 b/merror_8h__dep__incl.md5 new file mode 100644 index 00000000..fec3c950 --- /dev/null +++ b/merror_8h__dep__incl.md5 @@ -0,0 +1 @@ +ba5d3ab3e4ae45e26c4452fd6f2e9cba \ No newline at end of file diff --git a/merror_8h__dep__incl.png b/merror_8h__dep__incl.png new file mode 100644 index 00000000..c3b83b98 Binary files /dev/null and b/merror_8h__dep__incl.png differ diff --git a/merror_8h_source.html b/merror_8h_source.html new file mode 100644 index 00000000..5706f01a --- /dev/null +++ b/merror_8h_source.html @@ -0,0 +1,155 @@ + + + + + + + +maug: merror.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    merror.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef MERROR_H
    +
    3#define MERROR_H
    +
    4
    +
    19typedef int MERROR_RETVAL;
    +
    20
    +
    21#define MERROR_OK 0x00
    +
    22
    +
    23#define MERROR_MARGE 0x01
    +
    24
    +
    25#define MERROR_ALLOC 0x02
    +
    26
    +
    27#define MERROR_OVERFLOW 0x04
    +
    28
    +
    29#define MERROR_FILE 0x08
    +
    30
    +
    31#define MERROR_USR 0x0f
    +
    32
    +
    33#define MERROR_PARSE 0x10
    +
    34
    +
    35#define MERROR_GUI 0x20
    +
    36 /* maug_error_retvals */
    +
    38
    +
    39#define maug_cleanup_if_null_msg( type, ptr, err, msg ) \
    +
    40 if( (type)NULL == ptr ) { \
    +
    41 error_printf( msg ); \
    +
    42 retval = err; \
    +
    43 goto cleanup; \
    +
    44 }
    +
    45
    +
    46#define maug_cleanup_if_null( type, ptr, err ) \
    +
    47 maug_cleanup_if_null_msg( type, ptr, err, "failed to allocate " #ptr "!" )
    +
    48
    +
    49#define maug_cleanup_if_null_alloc( type, ptr ) \
    +
    50 maug_cleanup_if_null_msg( type, ptr, MERROR_ALLOC, "failed to allocate " #ptr "!" )
    +
    51
    +
    52#define maug_cleanup_if_null_file( ptr ) \
    +
    53 maug_cleanup_if_null_msg( FILE*, ptr, MERROR_FILE, "failed to open FILE!" )
    +
    54
    +
    55#define maug_cleanup_if_not_ok() \
    +
    56 if( MERROR_OK != retval ) { \
    +
    57 goto cleanup; \
    +
    58 }
    +
    59
    +
    60#define maug_cleanup_if_lt( a, b, fmt, err ) \
    +
    61 if( (a) < (b) ) { \
    +
    62 error_printf( fmt " is less than " fmt "!", a, b ); \
    +
    63 retval = err; \
    +
    64 goto cleanup; \
    +
    65 }
    +
    66
    +
    67#define maug_cleanup_if_lt_overflow( a, b ) \
    +
    68 maug_cleanup_if_lt( a, b, SIZE_T_FMT, MERROR_OVERFLOW )
    +
    69
    +
    70#define maug_cleanup_if_ge( a, b, fmt, err ) \
    +
    71 if( (a) >= (b) ) { \
    +
    72 error_printf( fmt " is greater or equal to " fmt "!", a, b ); \
    +
    73 retval = err; \
    +
    74 goto cleanup; \
    +
    75 }
    +
    76
    +
    77#define maug_cleanup_if_ge_overflow( a, b ) \
    +
    78 maug_cleanup_if_ge( a, (size_t)(b), SIZE_T_FMT, MERROR_OVERFLOW )
    +
    79 /* maug_error */
    +
    81
    +
    82#endif /* MERROR_H */
    +
    83
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    + + + + diff --git a/mmem_8h.html b/mmem_8h.html new file mode 100644 index 00000000..4cc0fdf5 --- /dev/null +++ b/mmem_8h.html @@ -0,0 +1,132 @@ + + + + + + + +maug: mmem.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    mmem.h File Reference
    +
    +
    +
    #include <stdlib.h>
    +
    +Include dependency graph for mmem.h:
    +
    +
    + + + + + +
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + +

    +Macros

    +#define maug_malloc(nmemb, sz)   malloc( sz * nmemb )
     
    #define maug_mrealloc(handle, nmemb, sz)   realloc( handle, (sz) * (nmemb) )
     
    +#define maug_mzero(ptr, sz)   memset( ptr, '\0', sz )
     
    +#define maug_mfree(handle)   free( handle ); handle = NULL;
     
    +#define maug_mlock(handle, ptr)   ptr = handle; handle = NULL;
     
    +#define maug_munlock(handle, ptr)   handle = ptr; ptr = NULL;
     
    #define maug_mrealloc_test(new_handle, handle, nmemb, sz)
     
    + + + +

    +Typedefs

    +typedef void * MAUG_MHANDLE
     
    +
    + + + + diff --git a/mmem_8h__incl.map b/mmem_8h__incl.map new file mode 100644 index 00000000..d6d0cb98 --- /dev/null +++ b/mmem_8h__incl.map @@ -0,0 +1,5 @@ + + + + + diff --git a/mmem_8h__incl.md5 b/mmem_8h__incl.md5 new file mode 100644 index 00000000..e2ad9d49 --- /dev/null +++ b/mmem_8h__incl.md5 @@ -0,0 +1 @@ +89d3351e1249431ee676ca62c37a40f2 \ No newline at end of file diff --git a/mmem_8h__incl.png b/mmem_8h__incl.png new file mode 100644 index 00000000..997a7148 Binary files /dev/null and b/mmem_8h__incl.png differ diff --git a/mmem_8h_source.html b/mmem_8h_source.html new file mode 100644 index 00000000..0202d0c2 --- /dev/null +++ b/mmem_8h_source.html @@ -0,0 +1,124 @@ + + + + + + + +maug: mmem.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    mmem.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef MMEM_H
    +
    3#define MMEM_H
    +
    4
    +
    11#if defined( MAUG_OS_PALM )
    +
    12
    +
    13/* TODO */
    +
    14
    +
    15#else
    +
    16
    +
    17# include <stdlib.h> /* For *alloc() */
    +
    18
    +
    19typedef void* MAUG_MHANDLE;
    +
    20
    +
    21#define maug_malloc( nmemb, sz ) malloc( sz * nmemb )
    +
    22
    +
    27#define maug_mrealloc( handle, nmemb, sz ) realloc( handle, (sz) * (nmemb) )
    +
    28
    +
    29#define maug_mzero( ptr, sz ) memset( ptr, '\0', sz )
    +
    30
    +
    31#define maug_mfree( handle ) free( handle ); handle = NULL;
    +
    32
    +
    33#define maug_mlock( handle, ptr ) ptr = handle; handle = NULL;
    +
    34
    +
    35#define maug_munlock( handle, ptr ) handle = ptr; ptr = NULL;
    +
    36
    +
    37#endif
    +
    38
    +
    39#define maug_mrealloc_test( new_handle, handle, nmemb, sz ) \
    +
    40 maug_cleanup_if_lt_overflow( (sz) * (nmemb), sz ); \
    +
    41 new_handle = maug_mrealloc( handle, nmemb, sz ); \
    +
    42 maug_cleanup_if_null_alloc( MAUG_MHANDLE, new_handle ); \
    +
    43 handle = new_handle;
    +
    44 /* maug_mem */
    +
    46
    +
    47#endif /* !MMEM_H */
    +
    48
    +
    + + + + diff --git a/modules.html b/modules.html new file mode 100644 index 00000000..9fae1868 --- /dev/null +++ b/modules.html @@ -0,0 +1,120 @@ + + + + + + + +maug: Modules + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + +
    + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    Modules
    +
    +
    +
    Here is a list of all modules:
    +
    [detail level 123]
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     RetroFlat APIAbstraction layer header for retro systems
     RetroFlat ExampleAn extremely simple single-file annotated example program written with the RetroFlat API
     RetroFlat CompilationMakefile examples and compiler considerations for using RetroFlat
     RetroFlat ColorsColor definitions RetroFlat is aware of, for use with the RetroFlat Drawing API
     RetroFlat API Return ValuesStandardized return values from RetroFlat API functions
     RetroFlat Drawing APIFunctions for drawing primitives on-screen
     RetroFlat ColorsColor definitions RetroFlat is aware of, for use with the RetroFlat Drawing API
     Global FlagsFlags that may be present on RETROFLAT_STATE::retroflat_flags
     RetroFlat Config APITools for loading and saving config data between sessions
     RetroFlat Config Buffer Types
     RetroFlat Config FlagsFlags for the flags parameter of retroflat_config_open()
     RetroFlat Message API
     RetroFlat VDP APIVideo Display Processor tools for modifying display output
     RetroFlat Bitmap APITools for loading bitmaps from disk and drawing them on-screen
     RetroFlat Input APIFunctions and constants for polling and interpreting user input
     RetroFlat Key DefinitionsKeyboard and mouse controls RetroFlat is aware of, for use within the RetroFlat Input API
     RetroGLU APILibrary of tools for working with RetroFlat and OpenGL
     RetroGLU OBJ Parser
     RetroGLU OBJ Parser States
     RetroGLU Sprites
     RetroGUI API
     RetroGUI Controls
     Maug Retro Fixed Point
     In-Situ Console API
     Command Line APITools for parsing command line arguments
     Error Handling API
     Return Values
     Micro-PrintF APIIndependently-implemented printf API for old compilers
     Memory Management API
     Tilemap APIFunctions and structures for working with tilemaps/grids
     Tilemap Tile Definitions
     Tilemap Custom Property Types
     Tilemap Parser
    +
    +
    + + + + diff --git a/mtilemap_8h.html b/mtilemap_8h.html new file mode 100644 index 00000000..99b91466 --- /dev/null +++ b/mtilemap_8h.html @@ -0,0 +1,196 @@ + + + + + + + +maug: mtilemap.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    mtilemap.h File Reference
    +
    +
    +
    #include <mparser.h>
    +
    +Include dependency graph for mtilemap.h:
    +
    +
    + + + + + +
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + +

    +Data Structures

    union  MTILEMAP_CPROP_VAL
     Data store for MTILEMAP_CPROP::value. More...
     
    struct  MTILEMAP_CPROP
     Custom property key-value storage type. More...
     
    struct  MTILEMAP_TILE_DEF
     
    struct  MTILEMAP_LAYER
     
    struct  MTILEMAP
     
    struct  MTILEMAP_PARSER
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    +#define MTILEMAP_NAME_SZ_MAX   10
     
    +#define MTILEMAP_TOKEN_SZ_MAX   4096
     
    +#define MTILEMAP_TILES_SZ_INIT   10
     
    +#define MTILEMAP_TILESET_IMAGE_STR_SZ_MAX   48
     
    +#define MTILEMAP_TILE_SCALE   1.0f
     
    +#define MTILEMAP_CPROP_STR_SZ_MAX   32
     
    +#define MTILEMAP_TRACE_LVL   0
     
    +#define MTILEMAP_FLAG_ACTIVE   0x1
     
    +#define MTILEMAP_CPROP_TYPE_NONE   0
     
    +#define MTILEMAP_CPROP_TYPE_INT   1
     
    +#define MTILEMAP_CPROP_TYPE_FLOAT   2
     
    +#define MTILEMAP_CPROP_TYPE_STR   3
     
    +#define MTILEMAP_CPROP_TYPE_BOOL   4
     
    #define MTILEMAP_PARSER_PSTATE_TABLE(f)
     
    #define MTILEMAP_PARSER_MSTATE_TABLE(f)
     
    + + + +

    +Typedefs

    +typedef MERROR_RETVAL(* mtilemap_tj_parse_cb) (const char *filename, struct MTILEMAP *t)
     
    + + + + + + + + + + + + + +

    +Functions

    +MERROR_RETVAL mtilemap_parse_json_c (struct MTILEMAP_PARSER *parser, char c)
     
    +MERROR_RETVAL mtilemap_parse_json_file (const char *filename, struct MTILEMAP *m)
     
    +MERROR_RETVAL mtilemap_alloc_tile_defs (struct MTILEMAP *t, size_t ndefs)
     
    +MERROR_RETVAL mtilemap_alloc_layers (struct MTILEMAP *t, size_t ndefs)
     
    +MERROR_RETVAL mtilemap_alloc_tiles (struct MTILEMAP_LAYER *layer, size_t ndefs)
     
    +MERROR_RETVAL mtilemap_free (struct MTILEMAP *t)
     
    +
    + + + + diff --git a/mtilemap_8h__incl.map b/mtilemap_8h__incl.map new file mode 100644 index 00000000..7ab86a74 --- /dev/null +++ b/mtilemap_8h__incl.map @@ -0,0 +1,5 @@ + + + + + diff --git a/mtilemap_8h__incl.md5 b/mtilemap_8h__incl.md5 new file mode 100644 index 00000000..e7aadf89 --- /dev/null +++ b/mtilemap_8h__incl.md5 @@ -0,0 +1 @@ +fa8c93d6ed713170f76d820830a9fbd2 \ No newline at end of file diff --git a/mtilemap_8h__incl.png b/mtilemap_8h__incl.png new file mode 100644 index 00000000..4b981c48 Binary files /dev/null and b/mtilemap_8h__incl.png differ diff --git a/mtilemap_8h_source.html b/mtilemap_8h_source.html new file mode 100644 index 00000000..c19cd596 --- /dev/null +++ b/mtilemap_8h_source.html @@ -0,0 +1,1056 @@ + + + + + + + +maug: mtilemap.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    mtilemap.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef MTILEMAP_H
    +
    3#define MTILEMAP_H
    +
    4
    +
    5#include <mparser.h>
    +
    6
    +
    14#ifndef MTILEMAP_NAME_SZ_MAX
    +
    15# define MTILEMAP_NAME_SZ_MAX 10
    +
    16#endif /* !MTILEMAP_NAME_SZ_MAX */
    +
    17
    +
    18#ifndef MTILEMAP_TOKEN_SZ_MAX
    +
    19# define MTILEMAP_TOKEN_SZ_MAX 4096
    +
    20#endif /* !MTILEMAP_TOKEN_SZ_MAX */
    +
    21
    +
    22#ifndef MTILEMAP_TILES_SZ_INIT
    +
    23# define MTILEMAP_TILES_SZ_INIT 10
    +
    24#endif /* !MTILEMAP_TILES_SZ_INIT */
    +
    25
    +
    26#ifndef MTILEMAP_TILESET_IMAGE_STR_SZ_MAX
    +
    27# define MTILEMAP_TILESET_IMAGE_STR_SZ_MAX 48
    +
    28#endif /* !MTILEMAP_TILESET_IMAGE_STR_SZ_MAX */
    +
    29
    +
    30#ifndef MTILEMAP_TILE_SCALE
    +
    31# define MTILEMAP_TILE_SCALE 1.0f
    +
    32#endif /* !MTILEMAP_TILE_SCALE */
    +
    33
    +
    34#ifndef MTILEMAP_CPROP_STR_SZ_MAX
    +
    35# define MTILEMAP_CPROP_STR_SZ_MAX 32
    +
    36#endif /* !MTILEMAP_CPROP_STR_SZ_MAX */
    +
    37
    +
    38#ifndef MTILEMAP_TRACE_LVL
    +
    39# define MTILEMAP_TRACE_LVL 0
    +
    40#endif /* !MTILEMAP_TRACE_LVL */
    +
    41
    +
    42#define MTILEMAP_FLAG_ACTIVE 0x1
    +
    43
    +
    54#define MTILEMAP_CPROP_TYPE_NONE 0
    +
    55#define MTILEMAP_CPROP_TYPE_INT 1
    +
    56#define MTILEMAP_CPROP_TYPE_FLOAT 2
    +
    57#define MTILEMAP_CPROP_TYPE_STR 3
    +
    58#define MTILEMAP_CPROP_TYPE_BOOL 4
    +
    59 /* maug_tilemap_defs_types */
    +
    61
    + +
    64 uint32_t u32;
    +
    65 int32_t i32;
    +
    66 float f32;
    +
    67 char str[MTILEMAP_CPROP_STR_SZ_MAX];
    +
    68 uint8_t bool;
    +
    69};
    +
    70
    + +
    74 uint8_t type;
    +
    75 char key[MTILEMAP_CPROP_STR_SZ_MAX];
    +
    76 union MTILEMAP_CPROP_VAL value;
    +
    77};
    +
    78
    + +
    80 uint8_t flags;
    +
    81#ifdef MAUG_NO_MMEM
    +
    82 struct MTILEMAP_CPROP* cprops;
    +
    83#else
    +
    84 MAUG_MHANDLE cprops;
    +
    85#endif /* MAUG_NO_MMEM */
    +
    86 size_t cprops_sz;
    +
    87 char image_path[MTILEMAP_TILESET_IMAGE_STR_SZ_MAX];
    +
    88};
    +
    89 /* maug_tilemap_defs */
    +
    91
    + +
    93#ifdef MAUG_NO_MMEM
    +
    94 size_t* tiles;
    +
    95#else
    +
    96 MAUG_MHANDLE tiles;
    +
    97#endif /* MAUG_NO_MMEM */
    +
    98 size_t tiles_sz;
    +
    99 size_t tiles_sz_max;
    +
    100};
    +
    101
    +
    102struct MTILEMAP {
    +
    103 char name[MTILEMAP_NAME_SZ_MAX];
    +
    104#ifdef MAUG_NO_MMEM
    +
    105 struct MTILEMAP_CPROP* cprops;
    +
    106 struct MTILEMAP_TILE_DEF* tile_defs;
    +
    107 struct MTILEMAP_LAYER* layers;
    +
    108#else
    +
    109 MAUG_MHANDLE cprops;
    +
    110 MAUG_MHANDLE tile_defs;
    +
    111 MAUG_MHANDLE layers;
    +
    112#endif /* MAUG_NO_MMEM */
    +
    113 size_t tile_defs_sz;
    +
    114 size_t cprops_sz;
    +
    115 size_t layers_sz;
    +
    116 size_t tileset_fgid;
    +
    117 uint8_t tiles_h;
    +
    118 uint8_t tiles_w;
    +
    119};
    +
    120
    +
    126typedef MERROR_RETVAL
    +
    127(*mtilemap_tj_parse_cb)( const char* filename, struct MTILEMAP* t );
    +
    128
    + +
    130 uint8_t pstate[MPARSER_STACK_SZ_MAX];
    +
    131 size_t pstate_sz;
    +
    132 uint8_t mstate;
    +
    133 uint8_t mstate_prev;
    +
    134 size_t i;
    +
    135 char token[MTILEMAP_TOKEN_SZ_MAX];
    +
    136 size_t token_sz;
    +
    137 size_t tileset_id_cur;
    +
    138 struct MTILEMAP* t;
    +
    139 mtilemap_tj_parse_cb tj_parse_cb;
    +
    140};
    +
    141
    +
    142#define MTILEMAP_PARSER_PSTATE_TABLE( f ) \
    +
    143 f( MTILEMAP_PSTATE_NONE, 0 ) \
    +
    144 f( MTILEMAP_PSTATE_OBJECT_KEY, 1 ) \
    +
    145 f( MTILEMAP_PSTATE_OBJECT_VAL, 2 ) \
    +
    146 f( MTILEMAP_PSTATE_STRING, 3 ) \
    +
    147 f( MTILEMAP_PSTATE_LIST, 4 )
    +
    148
    +
    149#define MTILEMAP_PARSER_MSTATE_TABLE( f ) \
    +
    150 f( MTILEMAP_MSTATE_NONE, 0, "", 0 ) \
    +
    151 f( MTILEMAP_MSTATE_HEIGHT, 1, "height", 0 ) \
    +
    152 f( MTILEMAP_MSTATE_WIDTH, 2, "width", 0 ) \
    +
    153 f( MTILEMAP_MSTATE_LAYERS, 3, "layers", 0 ) \
    +
    154 f( MTILEMAP_MSTATE_LAYER_DATA, 4, "data", 3 /* MSTATE_LAYERS */ ) \
    +
    155 f( MTILEMAP_MSTATE_LAYER_NAME, 5, "name", 3 /* MSTATE_LAYERS */ ) \
    +
    156 f( MTILEMAP_MSTATE_TILES, 6, "tiles", 0 ) \
    +
    157 f( MTILEMAP_MSTATE_TILES_ID, 7, "id", 6 /* MSTATE_TILES */ ) \
    +
    158 f( MTILEMAP_MSTATE_TILES_IMAGE, 8, "image", 6 /* MSTATE_TILES */ ) \
    +
    159 f( MTILEMAP_MSTATE_TILESETS, 9, "tilesets", 0 ) \
    +
    160 f( MTILEMAP_MSTATE_TILESETS_SRC, 10, "source", 9 /* MSTATE_TILESETS */ ) \
    +
    161 f( MTILEMAP_MSTATE_TILESETS_FGID,11, "firstgid",9 /* MSTATE_TILESETS */ ) \
    +
    162 f( MTILEMAP_MSTATE_TILESETS_PROP,12, "firstgid",9 /* MSTATE_TILESETS */ ) \
    +
    163 f( MTILEMAP_MSTATE_GRID, 13, "grid", 0 ) \
    +
    164 f( MTILEMAP_MSTATE_TILES_PROP, 14, "properties",6 /* MSTATE_TILES */ ) \
    +
    165 f( MTILEMAP_MSTATE_TILES_PROP_N, 15, "name",14 /* M_TILES_PROP */ ) \
    +
    166 f( MTILEMAP_MSTATE_TILES_PROP_T, 16, "type",14 /* M_TILES_PROP */ ) \
    +
    167 f( MTILEMAP_MSTATE_TILES_PROP_V, 17, "value",14 /* M_TILES_PROP */ ) \
    +
    168
    + +
    170mtilemap_parse_json_c( struct MTILEMAP_PARSER* parser, char c );
    +
    171
    + +
    173mtilemap_parse_json_file( const char* filename, struct MTILEMAP* m );
    +
    174 /* maug_tilemap_parser */
    +
    176
    + +
    178mtilemap_alloc_tile_defs( struct MTILEMAP* t, size_t ndefs );
    +
    179
    + +
    181mtilemap_alloc_layers( struct MTILEMAP* t, size_t ndefs );
    +
    182
    + +
    184mtilemap_alloc_tiles( struct MTILEMAP_LAYER* layer, size_t ndefs );
    +
    185
    + +
    187mtilemap_free( struct MTILEMAP* t );
    +
    188
    +
    189#ifdef MTILEMAP_C
    +
    190
    +
    191# include <stdio.h>
    +
    192
    +
    193# include <mparser.h>
    +
    194
    +
    195/* TODO: Function names should be verb_noun! */
    +
    196
    +
    197#define mtilemap_parser_pstate( parser ) \
    +
    198 (parser->pstate_sz > 0 ? \
    +
    199 parser->pstate[parser->pstate_sz - 1] : MTILEMAP_PSTATE_NONE)
    +
    200
    +
    201#define mtilemap_parser_pstate_push( parser, new_pstate ) \
    +
    202 mparser_pstate_push( mtilemap, parser, new_pstate )
    +
    203
    +
    204#define mtilemap_parser_pstate_pop( parser ) \
    +
    205 mparser_pstate_pop( mtilemap, parser )
    +
    206
    +
    207#define mtilemap_parser_invalid_c( parser, c, retval ) \
    +
    208 mparser_invalid_c( mtilemap, parser, c, retval )
    +
    209
    +
    210#define mtilemap_parser_reset_token( parser ) \
    +
    211 mparser_reset_token( mtilemap, parser )
    +
    212
    +
    213#define mtilemap_parser_append_token( parser, c ) \
    +
    214 mparser_append_token( mtilemap, parser, c, MTILEMAP_TOKEN_SZ_MAX )
    +
    215
    +
    216MTILEMAP_PARSER_PSTATE_TABLE( MPARSER_PSTATE_TABLE_CONST )
    +
    217
    +
    218static MAUG_CONST char* gc_mtilemap_pstate_names[] = {
    +
    219 MTILEMAP_PARSER_PSTATE_TABLE( MPARSER_PSTATE_TABLE_NAME )
    +
    220 ""
    +
    221};
    +
    222
    +
    223/* TODO: Better swap logic. */
    +
    224#define mtilemap_parser_mstate( parser, new_mstate ) \
    +
    225 if( new_mstate != parser->mstate_prev ) { \
    +
    226 parser->mstate_prev = parser->mstate; \
    +
    227 } \
    +
    228 parser->mstate = new_mstate; \
    +
    229 debug_printf( \
    +
    230 MTILEMAP_TRACE_LVL, "parser mstate: %s (prev: %s)", \
    +
    231 gc_mtilemap_mstate_names[parser->mstate], \
    +
    232 gc_mtilemap_mstate_names[parser->mstate_prev] );
    +
    233
    +
    234# define MTILEMAP_PARSER_MSTATE_TABLE_CONST( name, idx, token, parent ) \
    +
    235 static MAUG_CONST uint8_t name = idx;
    +
    236
    +
    237MTILEMAP_PARSER_MSTATE_TABLE( MTILEMAP_PARSER_MSTATE_TABLE_CONST )
    +
    238
    +
    239# define MTILEMAP_PARSER_MSTATE_TABLE_NAME( name, idx, token, parent ) \
    +
    240 #name,
    +
    241
    +
    242static MAUG_CONST char* gc_mtilemap_mstate_names[] = {
    +
    243 MTILEMAP_PARSER_MSTATE_TABLE( MTILEMAP_PARSER_MSTATE_TABLE_NAME )
    +
    244 ""
    +
    245};
    +
    246
    +
    247# define MTILEMAP_PARSER_MSTATE_TABLE_TOKEN( name, idx, token, parent ) \
    +
    248 token,
    +
    249
    +
    250static MAUG_CONST char* gc_mtilemap_mstate_tokens[] = {
    +
    251 MTILEMAP_PARSER_MSTATE_TABLE( MTILEMAP_PARSER_MSTATE_TABLE_TOKEN )
    +
    252 ""
    +
    253};
    +
    254
    +
    255# define MTILEMAP_PARSER_MSTATE_TABLE_PARENT( name, idx, token, parent ) \
    +
    256 parent,
    +
    257
    +
    258static MAUG_CONST uint8_t gc_mtilemap_mstate_parents[] = {
    +
    259 MTILEMAP_PARSER_MSTATE_TABLE( MTILEMAP_PARSER_MSTATE_TABLE_PARENT )
    +
    260 0
    +
    261};
    +
    262
    +
    263/* === */
    +
    264
    +
    265MERROR_RETVAL mtilemap_parser_tile_set_cprop_name(
    +
    266 size_t tile_idx, struct MTILEMAP_TILE_DEF* tile_def, const char* name
    +
    267) {
    +
    268 MAUG_MHANDLE cprops_new_h = (MAUG_MHANDLE)NULL;
    +
    269 struct MTILEMAP_CPROP* cprops = NULL;
    +
    270 MERROR_RETVAL retval = MERROR_OK;
    +
    271
    +
    272 /* Allocate new cprop, as name is assumed to always be the first field. */
    +
    273 if( 0 == tile_def->cprops_sz ) {
    +
    274 assert( (MAUG_MHANDLE)NULL == tile_def->cprops );
    +
    275 tile_def->cprops = maug_malloc( 1, sizeof( struct MTILEMAP_CPROP ) );
    +
    276 maug_cleanup_if_null_alloc( MAUG_MHANDLE, tile_def->cprops );
    +
    277
    +
    278 /* Lock and zero. */
    +
    279 maug_mlock( tile_def->cprops, cprops );
    +
    280 maug_cleanup_if_null_alloc( struct MTILEMAP_CPROP*, cprops );
    +
    281 maug_mzero( cprops, sizeof( struct MTILEMAP_CPROP ) );
    +
    282
    +
    283 } else {
    +
    284 maug_mrealloc_test(
    +
    285 cprops_new_h, tile_def->cprops,
    +
    286 tile_def->cprops_sz + 1, sizeof( struct MTILEMAP_CPROP ) );
    +
    287
    +
    288 /* Lock and zero newly allocated part. */
    +
    289 maug_mlock( tile_def->cprops, cprops );
    +
    290 maug_cleanup_if_null_alloc( struct MTILEMAP_CPROP*, cprops );
    +
    291 maug_mzero(
    +
    292 &(cprops[tile_def->cprops_sz]), sizeof( struct MTILEMAP_CPROP ) );
    +
    293 }
    +
    294
    +
    295 strncpy(
    +
    296 cprops[tile_def->cprops_sz].key,
    +
    297 name,
    +
    298 MTILEMAP_CPROP_STR_SZ_MAX );
    +
    299
    +
    300 debug_printf( MTILEMAP_TRACE_LVL,
    +
    301 "set tile #" SIZE_T_FMT " cprop #" SIZE_T_FMT " key: %s",
    +
    302 tile_idx, tile_def->cprops_sz, cprops[tile_def->cprops_sz].key );
    +
    303
    +
    304 tile_def->cprops_sz++;
    +
    305
    +
    306cleanup:
    +
    307
    +
    308 if( NULL != cprops ) {
    +
    309 maug_munlock( tile_def->cprops, cprops );
    +
    310 }
    +
    311
    +
    312 return retval;
    +
    313}
    +
    314
    +
    315MERROR_RETVAL mtilemap_parser_tile_set_cprop_type(
    +
    316 struct MTILEMAP_TILE_DEF* tile_def, const char* type
    +
    317) {
    +
    318 MERROR_RETVAL retval = MERROR_OK;
    +
    319 struct MTILEMAP_CPROP* cprops = NULL;
    +
    320
    +
    321 maug_mlock( tile_def->cprops, cprops );
    +
    322 maug_cleanup_if_null_alloc( struct MTILEMAP_CPROP*, cprops );
    +
    323
    +
    324 /* Parse type. */
    +
    325 if( 0 == strncmp( type, "int", 3 ) ) {
    +
    326 cprops[tile_def->cprops_sz - 1].type = MTILEMAP_CPROP_TYPE_INT;
    +
    327
    +
    328 } else if( 0 == strncmp( type, "float", 5 ) ) {
    +
    329 cprops[tile_def->cprops_sz - 1].type = MTILEMAP_CPROP_TYPE_FLOAT;
    +
    330
    +
    331 } else if( 0 == strncmp( type, "str", 3 ) ) {
    +
    332 cprops[tile_def->cprops_sz - 1].type = MTILEMAP_CPROP_TYPE_STR;
    +
    333
    +
    334 } else if( 0 == strncmp( type, "bool", 4 ) ) {
    +
    335 cprops[tile_def->cprops_sz - 1].type = MTILEMAP_CPROP_TYPE_BOOL;
    +
    336
    +
    337 }
    +
    338
    +
    339 debug_printf( MTILEMAP_TRACE_LVL, "set cprop #" SIZE_T_FMT " type: %d",
    +
    340 tile_def->cprops_sz - 1,
    +
    341 cprops[tile_def->cprops_sz - 1].type );
    +
    342
    +
    343cleanup:
    +
    344
    +
    345 if( NULL != cprops ) {
    +
    346 maug_munlock( tile_def->cprops, cprops );
    +
    347 }
    +
    348
    +
    349 return retval;
    +
    350}
    +
    351
    +
    352MERROR_RETVAL mtilemap_parser_tile_set_cprop_value(
    +
    353 struct MTILEMAP_TILE_DEF* tile_def, const char* val
    +
    354) {
    +
    355 MERROR_RETVAL retval = MERROR_OK;
    +
    356 struct MTILEMAP_CPROP* cprops = NULL;
    +
    357
    +
    358 maug_mlock( tile_def->cprops, cprops );
    +
    359 maug_cleanup_if_null_alloc( struct MTILEMAP_CPROP*, cprops );
    +
    360
    +
    361 /* TODO: Parse value. */
    +
    362 switch( cprops[tile_def->cprops_sz - 1].type ) {
    +
    363 case MTILEMAP_CPROP_TYPE_INT:
    +
    364 cprops[tile_def->cprops_sz - 1].value.i32 = atoi( val );
    +
    365 debug_printf( MTILEMAP_TRACE_LVL, "set cprop #" SIZE_T_FMT " value: %d",
    +
    366 tile_def->cprops_sz - 1,
    +
    367 cprops[tile_def->cprops_sz - 1].value.i32 );
    +
    368 break;
    +
    369
    +
    370 case MTILEMAP_CPROP_TYPE_FLOAT:
    +
    371 cprops[tile_def->cprops_sz - 1].value.f32 = atof( val );
    +
    372 debug_printf( MTILEMAP_TRACE_LVL, "set cprop #" SIZE_T_FMT " value: %f",
    +
    373 tile_def->cprops_sz - 1,
    +
    374 cprops[tile_def->cprops_sz - 1].value.f32 );
    +
    375 break;
    +
    376
    +
    377 case MTILEMAP_CPROP_TYPE_STR:
    +
    378 strncpy(
    +
    379 cprops[tile_def->cprops_sz - 1].value.str,
    +
    380 val,
    +
    381 MTILEMAP_CPROP_STR_SZ_MAX );
    +
    382 debug_printf( MTILEMAP_TRACE_LVL, "set cprop #" SIZE_T_FMT " value: %s",
    +
    383 tile_def->cprops_sz - 1,
    +
    384 cprops[tile_def->cprops_sz - 1].value.str );
    +
    385 break;
    +
    386
    +
    387 case MTILEMAP_CPROP_TYPE_BOOL:
    +
    388 cprops[tile_def->cprops_sz - 1].value.bool =
    +
    389 (0 == strncmp( "true", val, 4 ) ? 1 : 0);
    +
    390 debug_printf( MTILEMAP_TRACE_LVL, "set cprop #" SIZE_T_FMT " value: %s",
    +
    391 tile_def->cprops_sz - 1,
    +
    392 cprops[tile_def->cprops_sz - 1].value.bool ? "true" : "false" );
    +
    393 break;
    +
    394
    +
    395 default:
    +
    396 error_printf( "invalid cprop value!" );
    +
    397 retval = 1;
    +
    398 break;
    +
    399 }
    +
    400
    +
    401cleanup:
    +
    402
    +
    403 if( NULL != cprops ) {
    +
    404 maug_munlock( tile_def->cprops, cprops );
    +
    405 }
    +
    406
    +
    407 return retval;
    +
    408}
    +
    409
    +
    410MERROR_RETVAL mtilemap_parser_parse_token( struct MTILEMAP_PARSER* parser ) {
    +
    411 size_t j = 1;
    +
    412 MERROR_RETVAL retval = MERROR_OK;
    +
    413 struct MTILEMAP_TILE_DEF* tile_defs = NULL;
    +
    414 struct MTILEMAP_LAYER* layers = NULL;
    +
    415 struct MTILEMAP_LAYER* tiles_layer = NULL;
    +
    416 size_t* tiles = NULL;
    +
    417
    +
    418 if( 0 < parser->t->tile_defs_sz ) {
    +
    419 maug_mlock( parser->t->tile_defs, tile_defs );
    +
    420 maug_cleanup_if_null_alloc( struct MTILEMAP_TILE_DEF*, tile_defs );
    +
    421 }
    +
    422
    +
    423 if( MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser ) ) {
    +
    424
    +
    425 if( MTILEMAP_MSTATE_LAYER_DATA == parser->mstate ) {
    +
    426
    +
    427 maug_mlock( parser->t->layers, layers );
    +
    428 maug_cleanup_if_null_alloc( struct MTILEMAP_LAYER*, layers );
    +
    429 tiles_layer = &(layers[parser->t->layers_sz - 1]);
    +
    430
    +
    431 if( tiles_layer->tiles_sz + 1 >= tiles_layer->tiles_sz_max ) {
    +
    432 retval = mtilemap_alloc_tiles(
    +
    433 tiles_layer,
    +
    434 0 == tiles_layer->tiles_sz_max ? MTILEMAP_TILES_SZ_INIT :
    +
    435 tiles_layer->tiles_sz_max * 2 );
    +
    436 maug_cleanup_if_not_ok();
    +
    437 }
    +
    438
    +
    439 maug_mlock( tiles_layer->tiles, tiles );
    +
    440 maug_cleanup_if_null_alloc( size_t*, tiles );
    +
    441
    +
    442 /* Parse tilemap tile. */
    +
    443 tiles[tiles_layer->tiles_sz] = atoi( parser->token );
    +
    444 tiles_layer->tiles_sz++;
    +
    445
    +
    446 }
    +
    447 goto cleanup;
    +
    448
    +
    449 } else if(
    +
    450 MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser )
    +
    451 ) {
    +
    452 if( MTILEMAP_MSTATE_TILESETS_FGID == parser->mstate ) {
    +
    453 parser->t->tileset_fgid = atoi( parser->token );
    +
    454 debug_printf( MTILEMAP_TRACE_LVL, "tileset FGID set to: " SIZE_T_FMT,
    +
    455 parser->t->tileset_fgid );
    +
    456 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILESETS );
    +
    457
    +
    458 } else if( MTILEMAP_MSTATE_TILESETS_SRC == parser->mstate ) {
    +
    459 debug_printf( MTILEMAP_TRACE_LVL, "parsing %s...", parser->token );
    +
    460 parser->tj_parse_cb( parser->token, parser->t );
    +
    461 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILESETS );
    +
    462
    +
    463 } else if( MTILEMAP_MSTATE_TILES_ID == parser->mstate ) {
    +
    464 /* Parse tile ID. */
    +
    465 parser->tileset_id_cur = atoi( parser->token );
    +
    466 debug_printf(
    +
    467 MTILEMAP_TRACE_LVL,
    +
    468 "select tile ID: " SIZE_T_FMT, parser->tileset_id_cur );
    +
    469 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES );
    +
    470
    +
    471 /* Make sure tile ID is available. */
    +
    472 if( parser->tileset_id_cur >= parser->t->tile_defs_sz ) {
    +
    473 maug_munlock( parser->t->tile_defs, tile_defs );
    +
    474 retval = mtilemap_alloc_tile_defs(
    +
    475 parser->t, parser->tileset_id_cur + 1 );
    +
    476 maug_cleanup_if_not_ok();
    +
    477 }
    +
    478
    +
    479 } else if( MTILEMAP_MSTATE_TILES_IMAGE == parser->mstate ) {
    +
    480 debug_printf(
    +
    481 MTILEMAP_TRACE_LVL, "setting tile ID " SIZE_T_FMT "...",
    +
    482 parser->tileset_id_cur );
    +
    483
    +
    484 /* Parse tile image. */
    +
    485 strncpy(
    +
    486 tile_defs[parser->tileset_id_cur].image_path,
    +
    487 parser->token,
    +
    488 MTILEMAP_TILESET_IMAGE_STR_SZ_MAX );
    +
    489
    +
    490 debug_printf(
    +
    491 MTILEMAP_TRACE_LVL, "set tile ID " SIZE_T_FMT " to: %s",
    +
    492 parser->tileset_id_cur,
    +
    493 tile_defs[parser->tileset_id_cur].image_path );
    +
    494 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES );
    +
    495
    +
    496 } else if( MTILEMAP_MSTATE_TILES_PROP == parser->mstate ) {
    +
    497 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES );
    +
    498
    +
    499 } else if( MTILEMAP_MSTATE_TILES_PROP_N == parser->mstate ) {
    +
    500 retval = mtilemap_parser_tile_set_cprop_name(
    +
    501 parser->tileset_id_cur,
    +
    502 &(tile_defs[parser->tileset_id_cur]), parser->token );
    +
    503 maug_cleanup_if_not_ok();
    +
    504 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES_PROP );
    +
    505
    +
    506 } else if( MTILEMAP_MSTATE_TILES_PROP_T == parser->mstate ) {
    +
    507 retval = mtilemap_parser_tile_set_cprop_type(
    +
    508 &(tile_defs[parser->tileset_id_cur]), parser->token );
    +
    509 maug_cleanup_if_not_ok();
    +
    510 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES_PROP );
    +
    511
    +
    512 } else if( MTILEMAP_MSTATE_TILES_PROP_V == parser->mstate ) {
    +
    513 retval = mtilemap_parser_tile_set_cprop_value(
    +
    514 &(tile_defs[parser->tileset_id_cur]), parser->token );
    +
    515 maug_cleanup_if_not_ok();
    +
    516 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_TILES_PROP );
    +
    517
    +
    518 } else if( MTILEMAP_MSTATE_HEIGHT == parser->mstate ) {
    +
    519 parser->t->tiles_h = atoi( parser->token );
    +
    520 debug_printf(
    +
    521 MTILEMAP_TRACE_LVL, "tilemap height: %d", parser->t->tiles_h );
    +
    522 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_NONE );
    +
    523
    +
    524 } else if( MTILEMAP_MSTATE_WIDTH == parser->mstate ) {
    +
    525 parser->t->tiles_w = atoi( parser->token );
    +
    526 debug_printf(
    +
    527 MTILEMAP_TRACE_LVL, "tilemap width: %d", parser->t->tiles_h );
    +
    528 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_NONE );
    +
    529
    +
    530 } else if( MTILEMAP_MSTATE_LAYER_NAME == parser->mstate ) {
    +
    531 /* TODO: Store */
    +
    532 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_LAYERS );
    +
    533
    +
    534 } else if( MTILEMAP_MSTATE_GRID == parser->mstate ) {
    +
    535 /* This only has an mstate to differentiate its height/width children
    +
    536 * from those in the tileset root.
    +
    537 */
    +
    538 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_NONE );
    +
    539
    +
    540 }
    +
    541 goto cleanup;
    +
    542 }
    +
    543
    +
    544 /* Figure out what the key is for. */
    +
    545 while( '\0' != gc_mtilemap_mstate_tokens[j][0] ) {
    +
    546 if(
    +
    547 /* This state can only be
    +
    548 * reached THROUGH that parent state. This allows us to have
    +
    549 * keys with the same name but different parents!
    +
    550 */
    +
    551 parser->mstate == gc_mtilemap_mstate_parents[j] &&
    +
    552 /* Make sure tokens match. */
    +
    553 strlen( gc_mtilemap_mstate_tokens[j] ) == parser->token_sz &&
    +
    554 0 == strncmp(
    +
    555 parser->token, gc_mtilemap_mstate_tokens[j], parser->token_sz
    +
    556 )
    +
    557 ) {
    +
    558 /* Found it! */
    +
    559 mtilemap_parser_mstate( parser, j );
    +
    560 break;
    +
    561 }
    +
    562 j++;
    +
    563 }
    +
    564
    +
    565 /* Special prep work. */
    +
    566
    +
    567 if( MTILEMAP_MSTATE_LAYER_DATA == parser->mstate ) {
    +
    568
    +
    569 if( NULL != layers ) {
    +
    570 maug_munlock( parser->t->layers, layers );
    +
    571 maug_cleanup_if_null_alloc(
    +
    572 struct MTILEMAP_LAYER*, parser->t->layers );
    +
    573 }
    +
    574
    +
    575 retval = mtilemap_alloc_layers( parser->t, parser->t->layers_sz + 1 );
    +
    576 maug_cleanup_if_not_ok();
    +
    577 }
    +
    578
    +
    579cleanup:
    +
    580
    +
    581 if( NULL != tile_defs ) {
    +
    582 maug_munlock( parser->t->tile_defs, tile_defs );
    +
    583 }
    +
    584
    +
    585 if( NULL != tiles ) {
    +
    586 maug_munlock( layers[parser->t->layers_sz - 1].tiles, tiles );
    +
    587 }
    +
    588
    +
    589 if( NULL != layers ) {
    +
    590 maug_munlock( parser->t->layers, layers );
    +
    591 }
    +
    592
    +
    593 return retval;
    +
    594}
    +
    595
    +
    596/* === */
    +
    597
    + +
    599mtilemap_parse_json_c( struct MTILEMAP_PARSER* parser, char c ) {
    +
    600 MERROR_RETVAL retval = MERROR_OK;
    +
    601
    +
    602 /* debug_printf( MTILEMAP_TRACE_LVL, "c: %c", c ); */
    +
    603
    +
    604 switch( c ) {
    +
    605 case '\r':
    +
    606 case '\n':
    +
    607 case '\t':
    +
    608 case ' ':
    +
    609 if( MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser ) ) {
    +
    610 mtilemap_parser_append_token( parser, c );
    +
    611 }
    +
    612 break;
    +
    613
    +
    614 case '{':
    +
    615 if(
    +
    616 MTILEMAP_PSTATE_NONE == mtilemap_parser_pstate( parser ) ||
    +
    617 MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser ) ||
    +
    618 MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser )
    +
    619 ) {
    +
    620 mtilemap_parser_pstate_push( parser, MTILEMAP_PSTATE_OBJECT_KEY );
    +
    621 mtilemap_parser_reset_token( parser );
    +
    622
    +
    623 } else if( MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser ) ) {
    +
    624 mtilemap_parser_append_token( parser, c );
    +
    625
    +
    626 } else {
    +
    627 mtilemap_parser_invalid_c( parser, c, retval );
    +
    628 }
    +
    629 break;
    +
    630
    +
    631 case '}':
    +
    632 if( MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser ) ) {
    +
    633 retval = mtilemap_parser_parse_token( parser );
    +
    634 maug_cleanup_if_not_ok();
    +
    635 mtilemap_parser_pstate_pop( parser );
    +
    636 mtilemap_parser_pstate_pop( parser ); /* Pop key */
    +
    637 mtilemap_parser_reset_token( parser );
    +
    638
    +
    639 } else if(
    +
    640 MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser )
    +
    641 ) {
    +
    642 mtilemap_parser_append_token( parser, c );
    +
    643
    +
    644 } else {
    +
    645 mtilemap_parser_invalid_c( parser, c, retval );
    +
    646 }
    +
    647 break;
    +
    648
    +
    649 case '[':
    +
    650 if(
    +
    651 MTILEMAP_PSTATE_NONE == mtilemap_parser_pstate( parser ) ||
    +
    652 MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser ) ||
    +
    653 MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser )
    +
    654 ) {
    +
    655 mtilemap_parser_pstate_push( parser, MTILEMAP_PSTATE_LIST );
    +
    656 mtilemap_parser_reset_token( parser );
    +
    657
    +
    658 } else if(
    +
    659 MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser )
    +
    660 ) {
    +
    661 mtilemap_parser_append_token( parser, c );
    +
    662
    +
    663 } else {
    +
    664 mtilemap_parser_invalid_c( parser, c, retval );
    +
    665 }
    +
    666 break;
    +
    667
    +
    668 case ']':
    +
    669 if( MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser ) ) {
    +
    670 retval = mtilemap_parser_parse_token( parser );
    +
    671 maug_cleanup_if_not_ok();
    +
    672 mtilemap_parser_pstate_pop( parser );
    +
    673 mtilemap_parser_reset_token( parser );
    +
    674
    +
    675 if( MTILEMAP_MSTATE_LAYER_DATA == parser->mstate ) {
    +
    676 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_LAYERS );
    +
    677
    +
    678 } else if( MTILEMAP_MSTATE_LAYERS == parser->mstate ) {
    +
    679 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_NONE );
    +
    680
    +
    681 } else if( MTILEMAP_MSTATE_TILESETS == parser->mstate ) {
    +
    682 mtilemap_parser_mstate( parser, MTILEMAP_MSTATE_NONE );
    +
    683
    +
    684 }
    +
    685
    +
    686 } else if(
    +
    687 MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser )
    +
    688 ) {
    +
    689 mtilemap_parser_append_token( parser, c );
    +
    690
    +
    691 } else {
    +
    692 mtilemap_parser_invalid_c( parser, c, retval );
    +
    693 }
    +
    694 break;
    +
    695
    +
    696 case '"':
    +
    697 if(
    +
    698 MTILEMAP_PSTATE_OBJECT_KEY == mtilemap_parser_pstate( parser ) ||
    +
    699 MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser ) ||
    +
    700 MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser )
    +
    701 ) {
    +
    702 mtilemap_parser_pstate_push( parser, MTILEMAP_PSTATE_STRING );
    +
    703
    +
    704 } else if( MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser ) ) {
    +
    705 debug_printf( MTILEMAP_TRACE_LVL, "finished string: %s", parser->token );
    +
    706 mtilemap_parser_pstate_pop( parser );
    +
    707
    +
    708 } else {
    +
    709 mtilemap_parser_invalid_c( parser, c, retval );
    +
    710 }
    +
    711 break;
    +
    712
    +
    713 case ',':
    +
    714 if( MTILEMAP_PSTATE_OBJECT_VAL == mtilemap_parser_pstate( parser ) ) {
    +
    715 retval = mtilemap_parser_parse_token( parser );
    +
    716 maug_cleanup_if_not_ok();
    +
    717 mtilemap_parser_pstate_pop( parser );
    +
    718 mtilemap_parser_pstate_pop( parser ); /* Pop key */
    +
    719 mtilemap_parser_pstate_push( parser, MTILEMAP_PSTATE_OBJECT_KEY );
    +
    720 mtilemap_parser_reset_token( parser );
    +
    721
    +
    722 } else if( MTILEMAP_PSTATE_LIST == mtilemap_parser_pstate( parser ) ) {
    +
    723 retval = mtilemap_parser_parse_token( parser );
    +
    724 maug_cleanup_if_not_ok();
    +
    725 mtilemap_parser_reset_token( parser );
    +
    726
    +
    727 } else if(
    +
    728 MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser )
    +
    729 ) {
    +
    730 mtilemap_parser_append_token( parser, c );
    +
    731
    +
    732 } else {
    +
    733 mtilemap_parser_invalid_c( parser, c, retval );
    +
    734 }
    +
    735 break;
    +
    736
    +
    737 case ':':
    +
    738 if( MTILEMAP_PSTATE_OBJECT_KEY == mtilemap_parser_pstate( parser ) ) {
    +
    739 retval = mtilemap_parser_parse_token( parser );
    +
    740 maug_cleanup_if_not_ok();
    +
    741 mtilemap_parser_pstate_push( parser, MTILEMAP_PSTATE_OBJECT_VAL );
    +
    742 mtilemap_parser_reset_token( parser );
    +
    743
    +
    744 } else if(
    +
    745 MTILEMAP_PSTATE_STRING == mtilemap_parser_pstate( parser )
    +
    746 ) {
    +
    747 mtilemap_parser_append_token( parser, c );
    +
    748
    +
    749 } else {
    +
    750 mtilemap_parser_invalid_c( parser, c, retval );
    +
    751 }
    +
    752 break;
    +
    753
    +
    754 default:
    +
    755 mtilemap_parser_append_token( parser, c );
    +
    756 break;
    +
    757 }
    +
    758
    +
    759cleanup:
    +
    760
    +
    761 return retval;
    +
    762}
    +
    763
    +
    764/* === */
    +
    765
    + +
    767mtilemap_parse_json_file( const char* filename, struct MTILEMAP* t ) {
    +
    768 MERROR_RETVAL retval = MERROR_OK;
    +
    769 MAUG_MHANDLE parser_h = (MAUG_MHANDLE)NULL;
    +
    770 struct MTILEMAP_PARSER* parser = NULL;
    +
    771 char filename_path[RETROFLAT_PATH_MAX];
    +
    772
    +
    773 /* Initialize parser. */
    +
    774 parser_h = maug_malloc( 1, sizeof( struct MTILEMAP_PARSER ) );
    +
    775 maug_cleanup_if_null_alloc( MAUG_MHANDLE, parser_h );
    +
    776
    +
    777 maug_mlock( parser_h, parser );
    +
    778 maug_cleanup_if_null_alloc( struct MTILEMAP_PARSER*, parser );
    +
    779 maug_mzero( parser, sizeof( struct MTILEMAP_PARSER ) );
    +
    780
    +
    781 parser->t = t;
    +
    782 parser->tj_parse_cb = mtilemap_parse_json_file;
    +
    783
    +
    784 /* Setup filename path. */
    +
    785 memset( filename_path, '\0', RETROFLAT_PATH_MAX );
    +
    786 /* TODO: Configurable path. */
    +
    787 maug_snprintf( filename_path, RETROFLAT_PATH_MAX, "mapsrc/%s", filename );
    +
    788
    +
    789 retval = mparser_file(
    +
    790 filename_path, parser, (mparser_cb)mtilemap_parse_json_c );
    +
    791 maug_cleanup_if_not_ok();
    +
    792
    +
    793cleanup:
    +
    794
    +
    795 if( NULL != parser ) {
    +
    796 maug_munlock( parser_h, parser );
    +
    797 }
    +
    798
    +
    799 if( NULL != parser_h ) {
    +
    800 maug_mfree( parser_h );
    +
    801 }
    +
    802
    +
    803 return retval;
    +
    804}
    +
    805
    +
    806/* === */
    +
    807
    +
    808MERROR_RETVAL mtilemap_alloc_tile_defs( struct MTILEMAP* t, size_t ndefs ) {
    +
    809 MERROR_RETVAL retval = MERROR_OK;
    +
    810 struct MTILEMAP_TILE_DEF* tile_defs_new_h = NULL;
    +
    811 struct MTILEMAP_TILE_DEF* tile_defs = NULL;
    +
    812 size_t zero_sz = 0;
    +
    813
    +
    814 if( 0 == t->tile_defs_sz ) {
    +
    815 debug_printf( MTILEMAP_TRACE_LVL,
    +
    816 "allocating " SIZE_T_FMT " tile_defs...", ndefs );
    +
    817 t->tile_defs = maug_malloc( ndefs, sizeof( struct MTILEMAP_TILE_DEF ) );
    +
    818 maug_cleanup_if_null_alloc( MAUG_MHANDLE, t->tile_defs );
    +
    819
    +
    820 } else {
    +
    821 debug_printf( MTILEMAP_TRACE_LVL,
    +
    822 "reallocating " SIZE_T_FMT " tile_defs...", ndefs );
    +
    823 maug_mrealloc_test(
    +
    824 tile_defs_new_h, t->tile_defs,
    +
    825 ndefs, sizeof( struct MTILEMAP_TILE_DEF ) );
    +
    826
    +
    827 }
    +
    828
    +
    829 /* Zero new allocs. */
    +
    830 maug_mlock( t->tile_defs, tile_defs );
    +
    831 maug_cleanup_if_null_alloc( struct MTILEMAP_TILE_DEF*, tile_defs );
    +
    832 zero_sz = ndefs - t->tile_defs_sz;
    +
    833 debug_printf( MTILEMAP_TRACE_LVL,
    +
    834 "zeroing " SIZE_T_FMT " new defs...", zero_sz );
    +
    835 maug_mzero(
    +
    836 &(tile_defs[t->tile_defs_sz]),
    +
    837 zero_sz * sizeof( struct MTILEMAP_TILE_DEF ) );
    +
    838
    +
    839 /* Set new sz. */
    +
    840 t->tile_defs_sz = ndefs;
    +
    841
    +
    842cleanup:
    +
    843
    +
    844 if( NULL != tile_defs ) {
    +
    845 maug_munlock( t->tile_defs, tile_defs );
    +
    846 }
    +
    847
    +
    848 return retval;
    +
    849}
    +
    850
    +
    851/* === */
    +
    852
    +
    853MERROR_RETVAL mtilemap_alloc_layers( struct MTILEMAP* t, size_t ndefs ) {
    +
    854 struct MTILEMAP_LAYER* layers = NULL;
    +
    855 MERROR_RETVAL retval = MERROR_OK;
    +
    856 size_t zero_sz = 0;
    +
    857 MAUG_MHANDLE layers_new_h = NULL;
    +
    858
    +
    859 /* TODO: Use layers_sz_max */
    +
    860
    +
    861 if( 0 == t->layers_sz ) {
    +
    862 debug_printf( MTILEMAP_TRACE_LVL,
    +
    863 "alloc for layer #" SIZE_T_FMT " (" SIZE_T_FMT " bytes)...",
    +
    864 ndefs, sizeof( struct MTILEMAP_LAYER ) );
    +
    865 t->layers = maug_malloc( ndefs, sizeof( struct MTILEMAP_LAYER ) );
    +
    866 maug_cleanup_if_null_alloc( MAUG_MHANDLE, t->layers );
    +
    867
    +
    868 } else {
    +
    869 debug_printf( MTILEMAP_TRACE_LVL,
    +
    870 "realloc for layer #" SIZE_T_FMT " (" SIZE_T_FMT " bytes)...",
    +
    871 ndefs, sizeof( struct MTILEMAP_LAYER ) );
    +
    872 maug_mrealloc_test(
    +
    873 layers_new_h, t->layers, ndefs, sizeof( struct MTILEMAP_LAYER ) );
    +
    874 }
    +
    875
    +
    876 /* Zero new allocs. */
    +
    877 maug_mlock( t->layers, layers );
    +
    878 maug_cleanup_if_null_alloc( struct MTILEMAP_LAYER*, layers );
    +
    879 zero_sz = ndefs - t->layers_sz;
    +
    880 debug_printf( MTILEMAP_TRACE_LVL,
    +
    881 "zeroing " SIZE_T_FMT " new layers...", zero_sz );
    +
    882 maug_mzero(
    +
    883 &(layers[t->layers_sz]),
    +
    884 zero_sz * sizeof( struct MTILEMAP_LAYER ) );
    +
    885
    +
    886 t->layers_sz++;
    +
    887
    +
    888cleanup:
    +
    889
    +
    890 if( NULL != layers ) {
    +
    891 maug_munlock( t->layers, layers );
    +
    892 }
    +
    893
    +
    894 return retval;
    +
    895}
    +
    896
    +
    897/* === */
    +
    898
    +
    899MERROR_RETVAL mtilemap_alloc_tiles(
    +
    900 struct MTILEMAP_LAYER* layer, size_t ndefs
    +
    901) {
    +
    902 MERROR_RETVAL retval = MERROR_OK;
    +
    903 size_t zero_sz = 0;
    +
    904 size_t* tiles = NULL;
    +
    905 MAUG_MHANDLE tiles_new_h = NULL;
    +
    906
    +
    907 if( 0 == layer->tiles_sz_max ) {
    +
    908 debug_printf( MTILEMAP_TRACE_LVL,
    +
    909 "allocating %d tiles...",
    +
    910 MTILEMAP_TILES_SZ_INIT );
    +
    911 layer->tiles = maug_malloc( ndefs, sizeof( size_t ) );
    +
    912 maug_cleanup_if_null_alloc( size_t*, layer->tiles );
    +
    913
    +
    914 } else {
    +
    915 /* Double tiles size if more space needed. */
    +
    916 debug_printf( MTILEMAP_TRACE_LVL,
    +
    917 "reallocating " SIZE_T_FMT " tiles...", ndefs );
    +
    918 maug_mrealloc_test(
    +
    919 tiles_new_h, layer->tiles, ndefs, sizeof( size_t ) );
    +
    920 }
    +
    921
    +
    922 /* Zero new allocs. */
    +
    923 maug_mlock( layer->tiles, tiles );
    +
    924 maug_cleanup_if_null_alloc( size_t*, tiles );
    +
    925 zero_sz = ndefs - layer->tiles_sz_max;
    +
    926 debug_printf( MTILEMAP_TRACE_LVL,
    +
    927 "zeroing " SIZE_T_FMT " new tiles...", zero_sz );
    +
    928 maug_mzero( &(tiles[layer->tiles_sz]), zero_sz * sizeof( size_t ) );
    +
    929
    +
    930 layer->tiles_sz_max = ndefs;
    +
    931
    +
    932cleanup:
    +
    933
    +
    934 if( NULL != tiles ) {
    +
    935 maug_munlock( layer->tiles, tiles );
    +
    936 }
    +
    937
    +
    938 return retval;
    +
    939}
    +
    940
    +
    941/* === */
    +
    942
    +
    943MERROR_RETVAL mtilemap_free( struct MTILEMAP* t ) {
    +
    944 size_t i = 0;
    +
    945 struct MTILEMAP_TILE_DEF* tile_defs = NULL;
    +
    946 struct MTILEMAP_LAYER* layers = NULL;
    +
    947 MERROR_RETVAL retval = MERROR_OK;
    +
    948
    +
    949 maug_mlock( t->tile_defs, tile_defs );
    +
    950 if( NULL == tile_defs ) {
    +
    951 goto free_layers;
    +
    952 }
    +
    953
    +
    954 for( i = 0 ; t->tile_defs_sz > i ; i++ ) {
    +
    955 if( NULL != tile_defs[i].cprops ) {
    +
    956 maug_mfree( tile_defs[i].cprops );
    +
    957 tile_defs[i].cprops_sz = 0;
    +
    958 }
    +
    959 }
    +
    960
    +
    961 maug_munlock( t->tile_defs, tile_defs );
    +
    962 maug_mfree( t->tile_defs );
    +
    963
    +
    964free_layers:
    +
    965
    +
    966 maug_mlock( t->layers, layers );
    +
    967 maug_cleanup_if_null_alloc( struct MTILEMAP_LAYER*, layers );
    +
    968
    +
    969 for( i = 0 ; t->layers_sz > i ; i++ ) {
    +
    970 if( NULL != layers[i].tiles ) {
    +
    971 maug_mfree( layers[i].tiles );
    +
    972 layers[i].tiles_sz = 0;
    +
    973 }
    +
    974 }
    +
    975
    +
    976 maug_munlock( t->layers, layers );
    +
    977 maug_mfree( t->layers );
    +
    978
    +
    979cleanup:
    +
    980
    +
    981 return retval;
    +
    982}
    +
    983
    +
    984#endif /* MTILEMAP_C */
    +
    985 /* maug_tilemap */
    +
    987
    +
    988#endif /* !MTILEMAP_H */
    +
    989
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    #define RETROFLAT_PATH_MAX
    Maximum size allocated for asset paths.
    Definition retroflt.h:624
    +
    Custom property key-value storage type.
    Definition mtilemap.h:72
    +
    uint8_t type
    Tilemap Custom Property Types for MTILEMAP_CPROP::value.
    Definition mtilemap.h:74
    +
    Definition mtilemap.h:92
    +
    Definition mtilemap.h:129
    +
    Definition mtilemap.h:79
    +
    Definition mtilemap.h:102
    +
    Data store for MTILEMAP_CPROP::value.
    Definition mtilemap.h:63
    +
    + + + + diff --git a/nav_f.png b/nav_f.png new file mode 100644 index 00000000..72a58a52 Binary files /dev/null and b/nav_f.png differ diff --git a/nav_fd.png b/nav_fd.png new file mode 100644 index 00000000..032fbdd4 Binary files /dev/null and b/nav_fd.png differ diff --git a/nav_g.png b/nav_g.png new file mode 100644 index 00000000..2093a237 Binary files /dev/null and b/nav_g.png differ diff --git a/nav_h.png b/nav_h.png new file mode 100644 index 00000000..33389b10 Binary files /dev/null and b/nav_h.png differ diff --git a/nav_hd.png b/nav_hd.png new file mode 100644 index 00000000..de80f18a Binary files /dev/null and b/nav_hd.png differ diff --git a/open.png b/open.png new file mode 100644 index 00000000..30f75c7e Binary files /dev/null and b/open.png differ diff --git a/pages.html b/pages.html new file mode 100644 index 00000000..f7b2a7fe --- /dev/null +++ b/pages.html @@ -0,0 +1,88 @@ + + + + + + + +maug: Related Pages + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + +
    + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    Related Pages
    +
    +
    +
    Here is a list of all related documentation pages:
    + + +
     Todo List
    +
    +
    + + + + diff --git a/retrocon_8h_source.html b/retrocon_8h_source.html new file mode 100644 index 00000000..372b8da1 --- /dev/null +++ b/retrocon_8h_source.html @@ -0,0 +1,437 @@ + + + + + + + +maug: retrocon.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retrocon.h
    +
    +
    +
    1
    +
    2#ifndef RETROCON_H
    +
    3#define RETROCON_H
    +
    4
    +
    10#ifndef RETROCON_SBUFFER_SZ_MAX
    +
    11# define RETROCON_SBUFFER_SZ_MAX 4096
    +
    12#endif /* !RETROCON_SBUFFER_SZ_MAX */
    +
    13
    +
    14#ifndef RETROCON_SBUFFER_LINES_MAX
    +
    15# define RETROCON_SBUFFER_LINES_MAX 30
    +
    16#endif /* !RETROCON_SBUFFER_LINES_MAX */
    +
    17
    +
    18#ifndef RETROCON_LBUFFER_SZ_MAX
    +
    19# define RETROCON_LBUFFER_SZ_MAX 256
    +
    20#endif /* !RETROCON_LBUFFER_SZ_MAX */
    +
    21
    +
    22#ifndef RETROCON_ACTIVE_KEY
    +
    23# define RETROCON_ACTIVE_KEY RETROFLAT_KEY_GRAVE
    +
    24#endif /* !RETROCON_ACTIVE_KEY */
    +
    25
    +
    26#ifndef RETROCON_CB_NAME_SZ_MAX
    +
    27# define RETROCON_CB_NAME_SZ_MAX 32
    +
    28#endif /* !RETROCON_CB_NAME_SZ_MAX */
    +
    29
    +
    30#ifndef RETROCON_CB_SZ_MAX
    +
    31# define RETROCON_CB_SZ_MAX 128
    +
    32#endif /* !RETROCON_CB_SZ_MAX */
    +
    33
    +
    34#ifndef RETROCON_WIN_H
    +
    35# define RETROCON_WIN_H 110
    +
    36#endif /* !RETROCON_WIN_H */
    +
    37
    +
    38#define RETROCON_DEBOUNCE_WAIT 3
    +
    39
    +
    40#define RETROCON_FLAG_ACTIVE 0x01
    +
    41
    +
    42struct RETROCON;
    +
    43
    +
    44typedef MERROR_RETVAL (*retrocon_cb)(
    +
    45 struct RETROCON* con, const char* line, size_t line_sz, void* data );
    +
    46
    +
    47struct RETROCON {
    +
    48 uint8_t flags;
    +
    49 int input_prev;
    +
    50 int debounce_wait;
    +
    51 char sbuffer[RETROCON_SBUFFER_SZ_MAX + 1];
    +
    52 size_t sbuffer_sz;
    +
    53 size_t sbuffer_lines[RETROCON_SBUFFER_LINES_MAX];
    +
    54 size_t sbuffer_lines_sz;
    +
    55 char lbuffer[RETROCON_LBUFFER_SZ_MAX + 1];
    +
    56 size_t lbuffer_sz;
    +
    57 void* callback_data[RETROCON_CB_SZ_MAX];
    +
    58 char callback_names[RETROCON_CB_SZ_MAX][RETROCON_CB_NAME_SZ_MAX + 1];
    +
    59 retrocon_cb callbacks[RETROCON_CB_SZ_MAX];
    +
    60 size_t callbacks_sz;
    +
    61 RETROFLAT_COLOR lbuffer_color;
    +
    62 RETROFLAT_COLOR sbuffer_color;
    +
    63 RETROFLAT_COLOR bg_color;
    +
    64};
    +
    65
    +
    66MERROR_RETVAL retrocon_init( struct RETROCON* con );
    +
    67
    +
    68MERROR_RETVAL retrocon_add_command(
    +
    69 struct RETROCON* con, const char* cmd, retrocon_cb cb, void* cb_data );
    +
    70
    +
    71MERROR_RETVAL retrocon_display(
    +
    72 struct RETROCON* con, struct RETROFLAT_BITMAP* display );
    +
    73
    +
    74void retrocon_print_line( struct RETROCON* con, const char* line );
    +
    75
    +
    76MERROR_RETVAL retrocon_exec_line(
    +
    77 struct RETROCON* con, const char* line, size_t line_sz );
    +
    78
    +
    79int retrocon_debounce( struct RETROCON* con, int c );
    +
    80
    +
    81MERROR_RETVAL retrocon_input(
    +
    82 struct RETROCON* con, int* p_c, struct RETROFLAT_INPUT* input_evt );
    +
    83
    +
    84#ifdef RETROCON_C
    +
    85
    +
    86static MERROR_RETVAL retrocon_cmd_print(
    +
    87 struct RETROCON* con, const char* line, size_t line_sz, void* data
    +
    88) {
    +
    89 MERROR_RETVAL retval = MERROR_OK;
    +
    90 char* print_line = NULL;
    +
    91
    +
    92 print_line = strchr( line, ' ' );
    +
    93 if( NULL == print_line ) {
    +
    94 /* Not technically an error. */
    +
    95 goto cleanup;
    +
    96 }
    +
    97
    +
    98 /* Skip space. */
    +
    99 print_line++;
    +
    100
    +
    101 retrocon_print_line( con, print_line );
    +
    102
    +
    103cleanup:
    +
    104
    +
    105 return retval;
    +
    106}
    +
    107
    +
    108static MERROR_RETVAL retrocon_cmd_quit(
    +
    109 struct RETROCON* con, const char* line, size_t line_sz, void* data
    +
    110) {
    +
    111 MERROR_RETVAL retval = MERROR_OK;
    +
    112
    +
    113 retroflat_quit( 0 );
    +
    114
    +
    115 return retval;
    +
    116}
    +
    117
    +
    118MERROR_RETVAL retrocon_init( struct RETROCON* con ) {
    +
    119 MERROR_RETVAL retval = MERROR_OK;
    +
    120
    +
    121 con->sbuffer_color = RETROFLAT_COLOR_DARKBLUE;
    +
    122 con->lbuffer_color = RETROFLAT_COLOR_BLACK;
    +
    123 con->bg_color = RETROFLAT_COLOR_WHITE;
    +
    124
    +
    125 retval = retrocon_add_command( con, "PRINT", retrocon_cmd_print, NULL );
    +
    126 retval = retrocon_add_command( con, "QUIT", retrocon_cmd_quit, NULL );
    +
    127
    +
    128 return retval;
    +
    129}
    +
    130
    +
    131MERROR_RETVAL retrocon_add_command(
    +
    132 struct RETROCON* con, const char* cmd, retrocon_cb cb, void* cb_data
    +
    133) {
    +
    134 MERROR_RETVAL retval = MERROR_OK;
    +
    135
    +
    136 maug_cleanup_if_ge_overflow( con->callbacks_sz + 1, RETROCON_CB_SZ_MAX );
    +
    137
    +
    138 strncpy(
    +
    139 con->callback_names[con->callbacks_sz], cmd, RETROCON_CB_NAME_SZ_MAX );
    +
    140
    +
    141 con->callbacks[con->callbacks_sz] = cb;
    +
    142
    +
    143 con->callback_data[con->callbacks_sz] = cb_data;
    +
    144
    +
    145 con->callbacks_sz++;
    +
    146
    +
    147cleanup:
    +
    148
    +
    149 return retval;
    +
    150}
    +
    151
    +
    152MERROR_RETVAL retrocon_display(
    +
    153 struct RETROCON* con, struct RETROFLAT_BITMAP* display
    +
    154) {
    +
    155 MERROR_RETVAL retval = MERROR_OK;
    +
    156 size_t i = 0,
    +
    157 line_sz = 0;
    +
    158
    +
    159 if( RETROCON_FLAG_ACTIVE != (RETROCON_FLAG_ACTIVE & con->flags) ) {
    +
    160 goto cleanup;
    +
    161 }
    +
    162
    +
    163 if( (RETROFLAT_COLOR)0 == con->bg_color ) {
    +
    164 error_printf( "colors not set!" );
    +
    165 goto cleanup;
    +
    166 }
    +
    167
    + +
    169 NULL, con->bg_color, 10, 10,
    +
    170 300, RETROCON_WIN_H, RETROFLAT_FLAGS_FILL );
    +
    171
    + +
    173 NULL, con->lbuffer_color, con->lbuffer, -1, NULL,
    +
    174 15, 15, 0 );
    +
    175
    +
    176 /* Draw each line, one by one. */
    +
    177 for( i = 0 ; con->sbuffer_lines_sz > i ; i++ ) {
    +
    178 if( i + 1 < con->sbuffer_lines_sz ) {
    +
    179 line_sz = con->sbuffer_lines[i + 1] - con->sbuffer_lines[i];
    +
    180 } else {
    +
    181 line_sz = -1;
    +
    182 }
    +
    183
    + +
    185 NULL, con->sbuffer_color,
    +
    186 &(con->sbuffer[con->sbuffer_lines[i]]), line_sz, NULL,
    +
    187 15, 25 + (i * 10), 0 );
    +
    188 }
    +
    189
    +
    190cleanup:
    +
    191
    +
    192 return retval;
    +
    193}
    +
    194
    +
    195void retrocon_print_line( struct RETROCON* con, const char* line ) {
    +
    196 size_t line_sz = 0;
    +
    197 size_t i = 0;
    +
    198
    +
    199 line_sz = strlen( line );
    +
    200 if( line_sz + con->sbuffer_sz >= RETROCON_SBUFFER_SZ_MAX ) {
    +
    201 /* TODO: Handle line overflow better? (i.e. scroll) */
    +
    202 con->sbuffer_sz = 0;
    +
    203 con->sbuffer[con->sbuffer_sz] = '\0';
    +
    204 con->sbuffer_lines_sz = 0;
    +
    205 }
    +
    206
    +
    207 assert( line_sz < RETROCON_SBUFFER_SZ_MAX );
    +
    208
    +
    209 /* Create line pointer for display function. */
    +
    210 con->sbuffer_lines[con->sbuffer_lines_sz++] = con->sbuffer_sz;
    +
    211
    +
    212 /* Copy line to buffer and terminate with newline. */
    +
    213 for( i = 0 ; line_sz > i ; i++ ) {
    +
    214 con->sbuffer[con->sbuffer_sz + i] = line[i];
    +
    215 }
    +
    216
    +
    217 con->sbuffer[con->sbuffer_sz + line_sz] = '\0';
    +
    218
    +
    219 debug_printf( 1, "println: %s (at " SIZE_T_FMT " chars)",
    +
    220 &(con->sbuffer[con->sbuffer_sz]),
    +
    221 con->sbuffer_lines[con->sbuffer_lines_sz - 1] );
    +
    222
    +
    223 con->sbuffer_sz += line_sz;
    +
    224}
    +
    225
    +
    226MERROR_RETVAL retrocon_exec_line(
    +
    227 struct RETROCON* con, const char* line, size_t line_sz
    +
    228) {
    +
    229 MERROR_RETVAL retval = MERROR_OK;
    +
    230 size_t i = 0;
    +
    231
    +
    232 /* Find callback with name starting line. */
    +
    233 for( i = 0 ; con->callbacks_sz > i ; i++ ) {
    +
    234 if(
    +
    235 0 == strncmp(
    +
    236 /* TODO: Compare up to first space in line. */
    +
    237 con->callback_names[i], line, strlen( con->callback_names[i] ) )
    +
    238 ) {
    +
    239 retval = con->callbacks[i](
    +
    240 con, line, line_sz, con->callback_data[i] );
    +
    241 goto cleanup;
    +
    242 }
    +
    243 }
    +
    244
    +
    245 retrocon_print_line( con, "COMMAND NOT FOUND!" );
    +
    246
    +
    247cleanup:
    +
    248
    +
    249 return retval;
    +
    250}
    +
    251
    +
    252int retrocon_debounce( struct RETROCON* con, int c ) {
    +
    253 if( 0 == c ) {
    +
    254 return 0;
    +
    255 }
    +
    256
    +
    257 /* Debounce/disallow repeat even if it's allowed outside. */
    +
    258 if( con->input_prev == c && 0 < con->debounce_wait ) {
    +
    259 con->debounce_wait--;
    +
    260 debug_printf( 0, "dbwait (%d)", con->debounce_wait );
    +
    261 return 0;
    +
    262 } else {
    +
    263 con->input_prev = c;
    +
    264 con->debounce_wait = RETROCON_DEBOUNCE_WAIT;
    +
    265 debug_printf( 0, "new prev: %c", c );
    +
    266 }
    +
    267
    +
    268 return c;
    +
    269}
    +
    270
    +
    271MERROR_RETVAL retrocon_input(
    +
    272 struct RETROCON* con, int* p_c, struct RETROFLAT_INPUT* input_evt
    +
    273) {
    +
    274 MERROR_RETVAL retval = MERROR_OK;
    +
    275 int c = 0;
    +
    276
    +
    277 /* TODO: Use new retroflat_buffer_* macros! */
    +
    278
    +
    279 /* Put keycode on retrocon track. Clear pass-track if console active. */
    +
    280 c = *p_c;
    +
    281 if( RETROCON_FLAG_ACTIVE == (RETROCON_FLAG_ACTIVE & con->flags) ) {
    +
    282 *p_c = 0;
    +
    283 }
    +
    284
    +
    285 /* Debounce retrocon track only! */
    +
    286 if( !retrocon_debounce( con, c ) ) {
    +
    287 goto cleanup;
    +
    288 }
    +
    289
    +
    290 /* Process input. */
    +
    291 switch( c ) {
    +
    292 case RETROCON_ACTIVE_KEY:
    +
    293 if( RETROCON_FLAG_ACTIVE == (RETROCON_FLAG_ACTIVE & con->flags) ) {
    +
    294 con->flags &= ~RETROCON_FLAG_ACTIVE;
    +
    295 } else {
    +
    296 con->flags |= RETROCON_FLAG_ACTIVE;
    +
    297 }
    +
    298 break;
    +
    299
    +
    300 case 0:
    +
    301 break;
    +
    302
    +
    303 case 0x08:
    +
    304 /* Backspace. */
    +
    305 if( 0 < con->lbuffer_sz ) {
    +
    306 con->lbuffer_sz--;
    +
    307 con->lbuffer[con->lbuffer_sz] = '\0';
    +
    308 }
    +
    309 break;
    +
    310
    +
    311 case '\r':
    +
    312 case '\n':
    +
    313 if( 0 == con->lbuffer_sz ) {
    +
    314 /* Do nothing if line is empty. */
    +
    315 break;
    +
    316 }
    +
    317
    +
    318 /* Execute/reset line. */
    +
    319 retval = retrocon_exec_line( con, con->lbuffer, con->lbuffer_sz );
    +
    320 con->lbuffer_sz = 0;
    +
    321 con->lbuffer[con->lbuffer_sz] = '\0';
    +
    322 break;
    +
    323
    +
    324 default:
    +
    325 c = retroflat_vk_to_ascii(
    +
    326 c, input_evt->key_flags | RETROFLAT_INPUT_FORCE_UPPER );
    +
    327 if(
    +
    328 /* Active and printable chars get added to line buffer. */
    +
    329 RETROCON_FLAG_ACTIVE == (RETROCON_FLAG_ACTIVE & con->flags) &&
    +
    330 0 < c
    +
    331 ) {
    +
    332 con->lbuffer[con->lbuffer_sz++] = c;
    +
    333 con->lbuffer[con->lbuffer_sz] = '\0';
    +
    334 }
    +
    335 break;
    +
    336 }
    +
    337
    +
    338cleanup:
    +
    339
    +
    340 return retval;
    +
    341}
    +
    342
    +
    343#endif /* RETROCON_C */
    +
    344 /* maug_console */
    +
    346
    +
    347#endif /* !RETROCON_H */
    +
    348
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    void retroflat_string(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int x_orig, int y_orig, uint8_t flags)
    Draw a text string at the specified location in the specified font and color on the target RETROFLAT_...
    +
    void retroflat_rect(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
    Draw a rectangle onto the target RETROFLAT_BITMAP.
    +
    #define RETROFLAT_FLAGS_FILL
    Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
    Definition retroflt.h:334
    +
    #define retroflat_quit(retval_in)
    This should be called in order to quit a program using RetroFlat.
    Definition retroflt.h:1636
    +
    Definition retrocon.h:47
    +
    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
    Definition retroflt.h:1610
    +
    Struct passed to retroflat_poll_input() to hold return data.
    Definition retroflt.h:749
    +
    + + + + diff --git a/retroflt_8h.html b/retroflt_8h.html new file mode 100644 index 00000000..60879aa9 --- /dev/null +++ b/retroflt_8h.html @@ -0,0 +1,675 @@ + + + + + + + +maug: retroflt.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    retroflt.h File Reference
    +
    +
    + +

    Abstraction layer header for retro systems. +More...

    +
    #include <mtypes.h>
    +#include <stdarg.h>
    +#include <marge.h>
    +#include <uprintf.h>
    +
    +Include dependency graph for retroflt.h:
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    +

    Go to the source code of this file.

    + + + + + + + + + + + + + + +

    +Data Structures

    struct  RETROFLAT_INPUT
     Struct passed to retroflat_poll_input() to hold return data. More...
     
    struct  RETROFLAT_BITMAP
     Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine if a valid bitmap is loaded. More...
     
    struct  RETROFLAT_ARGS
     Struct containing configuration values for a RetroFlat program. More...
     
    struct  RETROFLAT_STATE
     Global singleton containing state for the current platform. More...
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    #define RETROFLAT_COLOR_TABLE(f)
     
    +#define RETROFLAT_COLOR_NULL   (-1)
     
    +#define RETROFLAT_COLORS_SZ   16
     
    +#define RETROFLAT_OK   0x00
     Certain functions return this when there was no problem.
     
    +#define RETROFLAT_ERROR_ENGINE   0x01
     
    +#define RETROFLAT_ERROR_GRAPHICS   0x02
     
    +#define RETROFLAT_ERROR_MOUSE   0x04
     
    +#define RETROFLAT_ERROR_BITMAP   0x08
     Returned if there is a problem loading or locking a RETROFLAT_BITMAP struct.
     
    +#define RETROFLAT_ERROR_TIMER   0x0f
     
    +#define bmp_read_uint32(b)   (*((uint32_t*)(b)))
     
    +#define RETROFLAT_FLAGS_FILL   0x01
     Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
     
    +#define RETROFLAT_FLAGS_OPAQUE   0x01
     Flag for retroflat_create_bitmap() to create a bitmap without transparency.
     
    #define RETROFLAT_FLAGS_SCREEN_BUFFER   0x80
     Flag for retroflat_create_bitmap() to create a WinG-backed bitmap.
     
    #define RETROFLAT_FLAGS_RUNNING   0x01
     Flag indicating that retroflat_loop() should continue executing.
     
    #define RETROFLAT_FLAGS_UNLOCK_FPS   0x02
     Flag indicating FPS should not be capped.
     
    #define RETROFLAT_FLAGS_KEY_REPEAT   0x04
     Flag indicating keyboard repeat is enabled.
     
    #define RETROFLAT_FLAGS_SCREENSAVER   0x08
     Flag indicating the current application is running as a screensaver.
     
    +#define RETROFLAT_BUFFER_INT   0x00
     
    +#define RETROFLAT_BUFFER_STRING   0x01
     
    +#define RETROFLAT_BUFFER_FLOAT   0x02
     
    +#define RETROFLAT_BUFFER_BOOL   0x04
     
    #define RETROFLAT_CONFIG_FLAG_W   0x01
     Flag indicating config object should be opened for WRITING only.
     
    +#define RETROFLAT_CONFIG_FLAG_BIN   0x02
     Flag indicating config object holds BINARY data.
     
    +#define RETROFLAT_MSG_FLAG_TYPE_MASK   0x07
     
    +#define RETROFLAT_MSG_FLAG_ERROR   0x01
     
    +#define RETROFLAT_MSG_FLAG_INFO   0x02
     
    +#define RETROFLAT_MSG_FLAG_WARNING   0x04
     
    #define RETROFLAT_VDP_FLAG_PXLOCK   0x01
     Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame before passing it (almost always true!)
     
    +#define RETROFLAT_FLAGS_SCREEN_LOCK   0x02
     
    +#define RETROFLAT_BITMAP_EXT   "bmp"
     The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap(). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_OPENGL_BPP   32
     
    +#define RETROFLAT_TXP_R   0x00
     Compiler-define-overridable constant indicating the Red value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_TXP_G   0x00
     Compiler-define-overridable constant indicating the Green value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_TXP_B   0x00
     Compiler-define-overridable constant indicating the Blue value of the transparency color on platforms that support it (mainly Win16/SDL). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_GL_Z   -0.001
     
    #define retroflat_on_resize(w, h)
     
    +#define RETROFLAT_LINE_THICKNESS   1
     Line drawing thickness (only works on some platforms). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_PI   3.14159
     
    #define RETROFLAT_FPS   30
     Target Frames Per Second.
     
    +#define retroflat_fps_next()   (1000 / RETROFLAT_FPS)
     
    +#define RETROFLAT_WINDOW_CLASS   "RetroFlatWindowClass"
     Unique window class to use on some platforms (e.g. Win32). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_WIN_GFX_TIMER_ID   6001
     Unique ID for the timer that execute graphics ticks in Win16/Win32. Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_MSG_MAX   4096
     Maximum number of characters possible in a message using retroflat_message(). Is a RetroFlat Compiler Definitions.
     
    +#define RETROFLAT_PATH_MAX   256
     Maximum size allocated for asset paths.
     
    +#define RETROFLAT_TITLE_MAX   255
     
    #define RETROFLAT_VDP_ARGS_SZ_MAX   255
     
    +#define RETROFLAT_PATH_SEP   '/'
     The valid path separator on the target platform.
     
    +#define RETROFLAT_ASSETS_PATH_MAX   (RETROFLAT_PATH_MAX / 2)
     Maximum size of the assets path, to allow room for appending.
     
    +#define NDS_OAM_ACTIVE   &oamMain
     Active sprite engine screen on Nintendo DS.
     
    +#define NDS_SPRITES_ACTIVE   24
     Maximum number of sprites active on-screen on Nintendo DS.
     
    +#define RETROFLAT_CONFIG_LN_SZ_MAX   255
     
    +#define RETROFLAT_CONFIG_EXT   ".ini"
     
    +#define RETROFLAT_BMP_COLORS_SZ_MAX   256
     
    #define retroflat_buffer_bksp(buffer, buffer_cur, buffer_sz)
     Remove a character from a text buffer before cursor position.
     
    #define retroflat_buffer_insert(c, buffer, buffer_cur, buffer_sz, buffer_mx)
     Insert a character into a text buffer at cursor position.
     
    +#define RETROFLAT_INPUT_MOD_SHIFT   0x01
     
    +#define RETROFLAT_INPUT_MOD_ALT   0x02
     
    +#define RETROFLAT_INPUT_MOD_CTRL   0x04
     
    +#define RETROFLAT_INPUT_FORCE_UPPER   0x08
     
    +#define retroflat_bitmap_ok(bitmap)   (NULL != (bitmap)->b)
     Check to see if a bitmap is loaded.
     
    +#define retroflat_screen_w()
     Get the current screen width in pixels.
     
    +#define retroflat_screen_h()
     Get the current screen height in pixels.
     
    +#define retroflat_screen_buffer()   (&(g_retroflat_state->buffer))
     Get the direct screen buffer or the VDP buffer if a VDP is loaded.
     
    #define retroflat_quit(retval_in)
     This should be called in order to quit a program using RetroFlat.
     
    +#define RETROFLAT_COLOR_BLACK   0
     
    +#define RETROFLAT_COLOR_DARKBLUE   1
     
    +#define RETROFLAT_COLOR_DARKGREEN   2
     
    +#define RETROFLAT_COLOR_TEAL   3
     
    +#define RETROFLAT_COLOR_DARKRED   4
     
    +#define RETROFLAT_COLOR_VIOLET   5
     
    +#define RETROFLAT_COLOR_BROWN   6
     
    +#define RETROFLAT_COLOR_GRAY   7
     
    +#define RETROFLAT_COLOR_DARKGRAY   8
     
    +#define RETROFLAT_COLOR_BLUE   9
     
    +#define RETROFLAT_COLOR_GREEN   10
     
    +#define RETROFLAT_COLOR_CYAN   11
     
    +#define RETROFLAT_COLOR_RED   12
     
    +#define RETROFLAT_COLOR_MAGENTA   13
     
    +#define RETROFLAT_COLOR_YELLOW   14
     
    +#define RETROFLAT_COLOR_WHITE   15
     
    +#define RETROFLAT_KEY_UP   0
     
    +#define RETROFLAT_KEY_DOWN   0
     
    +#define RETROFLAT_KEY_RIGHT   0
     
    +#define RETROFLAT_KEY_LEFT   0
     
    +#define RETROFLAT_KEY_A   0x41
     
    +#define RETROFLAT_KEY_B   0x42
     
    +#define RETROFLAT_KEY_C   0x43
     
    +#define RETROFLAT_KEY_D   0x44
     
    +#define RETROFLAT_KEY_E   0x45
     
    +#define RETROFLAT_KEY_F   0x46
     
    +#define RETROFLAT_KEY_G   0x47
     
    +#define RETROFLAT_KEY_H   0x48
     
    +#define RETROFLAT_KEY_I   0x49
     
    +#define RETROFLAT_KEY_J   0x4a
     
    +#define RETROFLAT_KEY_K   0x4b
     
    +#define RETROFLAT_KEY_L   0x4c
     
    +#define RETROFLAT_KEY_M   0x4d
     
    +#define RETROFLAT_KEY_N   0x4e
     
    +#define RETROFLAT_KEY_O   0x4f
     
    +#define RETROFLAT_KEY_P   0x50
     
    +#define RETROFLAT_KEY_Q   0x51
     
    +#define RETROFLAT_KEY_R   0x52
     
    +#define RETROFLAT_KEY_S   0x53
     
    +#define RETROFLAT_KEY_T   0x54
     
    +#define RETROFLAT_KEY_U   0x55
     
    +#define RETROFLAT_KEY_V   0x56
     
    +#define RETROFLAT_KEY_W   0x57
     
    +#define RETROFLAT_KEY_X   0x58
     
    +#define RETROFLAT_KEY_Y   0x59
     
    +#define RETROFLAT_KEY_Z   0x60
     
    +#define RETROFLAT_KEY_0   0x30
     
    +#define RETROFLAT_KEY_1   0x31
     
    +#define RETROFLAT_KEY_2   0x32
     
    +#define RETROFLAT_KEY_3   0x33
     
    +#define RETROFLAT_KEY_4   0x34
     
    +#define RETROFLAT_KEY_5   0x35
     
    +#define RETROFLAT_KEY_6   0x36
     
    +#define RETROFLAT_KEY_7   0x37
     
    +#define RETROFLAT_KEY_8   0x38
     
    +#define RETROFLAT_KEY_9   0x39
     
    +#define RETROFLAT_KEY_TAB   0
     
    +#define RETROFLAT_KEY_SPACE   0
     
    +#define RETROFLAT_KEY_ESC   0
     
    +#define RETROFLAT_KEY_ENTER   0
     
    +#define RETROFLAT_KEY_HOME   0
     
    +#define RETROFLAT_KEY_END   0
     
    +#define RETROFLAT_MOUSE_B_LEFT   0
     
    +#define RETROFLAT_MOUSE_B_RIGHT   0
     
    #define retroflat_opengl_push(x, y, x_f, y_f, aspect_f)
     
    #define retroflat_opengl_whf(w, h, w_f, h_f, aspect_f)
     
    #define retroflat_opengl_pop()
     
    +#define RETROFLAT_COLOR_TABLE_CONSTS(idx, name_l, name_u, r, g, b)    extern MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u;
     
    + + + + + + + + + + + + + + +

    +Typedefs

    +typedef int8_t RETROFLAT_COLOR
     
    typedef MERROR_RETVAL(* retroflat_vdp_proc_t) (struct RETROFLAT_STATE *)
     VDP function called from the VDP library.
     
    +typedef void(* retroflat_loop_iter) (void *data)
     Prototype for the main loop function passed to retroflat_loop().
     
    typedef FILE * RETROFLAT_CONFIG
     A configuration object to use with the RetroFlat Config API.
     
    +typedef int RETROFLAT_COLOR_DEF
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    +MERROR_RETVAL retroflat_loop (retroflat_loop_iter iter, void *data)
     This should be called once in the main body of the program in order to enter the main loop. The main loop will continuously call loop_iter with data as an argument until retroflat_quit() is called.
     
    void retroflat_message (uint8_t flags, const char *title, const char *format,...)
     Display a message in a dialog box and/or on stderr.
     
    MERROR_RETVAL retroflat_init (int argc, char *argv[], struct RETROFLAT_ARGS *args)
     Initialize RetroFlat and its underlying layers. This should be called once at the beginning of the program and should quit if the return value indicates any failures.
     
    void retroflat_shutdown (int retval)
     Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the program, after retroflat_loop().
     
    +void retroflat_set_title (const char *format,...)
     
    +uint32_t retroflat_get_ms ()
     
    +uint32_t retroflat_get_rand ()
     
    MERROR_RETVAL retroflat_load_bitmap (const char *filename, struct RETROFLAT_BITMAP *bmp_out)
     Load a bitmap into the given RETROFLAT_BITMAP structure if it is available. Bitmaps are subject to the limitations enumerated in RetroFlat Bitmap API.
     
    +MERROR_RETVAL retroflat_create_bitmap (size_t w, size_t h, struct RETROFLAT_BITMAP *bmp_out, uint8_t flags)
     
    +MERROR_RETVAL retroflat_load_xpm (const char *filename, struct RETROFLAT_BITMAP *bmp_out)
     Load a compiled-in XPM image into an API-specific bitmap context. \warn The XPM must have been generated from a bitmap using the rather restrictive RetroFlat Bitmap API rules.
     
    void retroflat_destroy_bitmap (struct RETROFLAT_BITMAP *bitmap)
     Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on the stack).
     
    void retroflat_blit_bitmap (struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, int s_x, int s_y, int d_x, int d_y, int w, int h)
     Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP.
     
    MERROR_RETVAL retroflat_draw_lock (struct RETROFLAT_BITMAP *bmp)
     Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly, but performance should improve if done before a batch of drawing operations.
     
    +MERROR_RETVAL retroflat_draw_release (struct RETROFLAT_BITMAP *bmp)
     
    +void retroflat_px (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, uint8_t flags)
     
    void retroflat_rect (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
     Draw a rectangle onto the target RETROFLAT_BITMAP.
     
    void retroflat_ellipse (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
     Draw an ellipse onto the target RETROFLAT_BITMAP.
     
    void retroflat_line (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
     Draw a straight line onto the target RETROFLAT_BITMAP.
     
    +void retroflat_cursor (struct RETROFLAT_BITMAP *target, uint8_t flags)
     
    void retroflat_string_sz (struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, size_t *w_out, size_t *h_out, uint8_t flags)
     Get the size in pixels of a text string when drawn with a given font by retroflat_string().
     
    void retroflat_string (struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int x_orig, int y_orig, uint8_t flags)
     Draw a text string at the specified location in the specified font and color on the target RETROFLAT_BITMAP.
     
    int retroflat_poll_input (struct RETROFLAT_INPUT *input)
     Poll input devices (keyboard/mouse) and return the latest event.
     
    MERROR_RETVAL retroflat_config_open (RETROFLAT_CONFIG *config, uint8_t flags)
     Open a configuration file/registry/SRAM/etc handle.
     
    +void retroflat_config_close (RETROFLAT_CONFIG *config)
     
    size_t retroflat_config_write (RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer, size_t buffer_sz_max)
     Write the contents of a buffer to a config object.
     
    size_t retroflat_config_read (RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer_out, size_t buffer_out_sz_max, const void *default_out, size_t default_out_sz)
     Write the contents of a buffer to a config object.
     
    + + + + + +

    +Variables

    +MAUG_CONST char * gc_retroflat_color_names []
     
    +struct RETROFLAT_STATEg_retroflat_state
     
    +

    Detailed Description

    +

    Abstraction layer header for retro systems.

    +

    RetroFlat is a compatibility layer for making graphical programs that work on Win16 (32-bit via OpenWatcom's Win386), MS-DOS (32-bit via DOS/32a or DOS4GW via Allegro), and possibly other platforms in the future.

    +

    To use, define RETROFLT_C before including this header from your main.c.

    +

    You may include this header in other .c files, as well, but RETROFLT_C should ONLY be declared ONCE in the entire program.

    +
    + + + + diff --git a/retroflt_8h__incl.map b/retroflt_8h__incl.map new file mode 100644 index 00000000..74d2dab3 --- /dev/null +++ b/retroflt_8h__incl.map @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/retroflt_8h__incl.md5 b/retroflt_8h__incl.md5 new file mode 100644 index 00000000..260d31f5 --- /dev/null +++ b/retroflt_8h__incl.md5 @@ -0,0 +1 @@ +c0c833296036b6bfb17318dd4e615609 \ No newline at end of file diff --git a/retroflt_8h__incl.png b/retroflt_8h__incl.png new file mode 100644 index 00000000..75a80d2b Binary files /dev/null and b/retroflt_8h__incl.png differ diff --git a/retroflt_8h_source.html b/retroflt_8h_source.html new file mode 100644 index 00000000..d198a2fb --- /dev/null +++ b/retroflt_8h_source.html @@ -0,0 +1,5615 @@ + + + + + + + +maug: retroflt.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retroflt.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef RETROFLT_H
    +
    3#define RETROFLT_H
    +
    4
    +
    5#include <mtypes.h>
    +
    6
    +
    248/* === Generic Includes and Defines === */
    +
    249
    +
    250#include <stdarg.h>
    +
    251
    +
    252#include <marge.h>
    +
    253
    +
    254#ifdef RETROFLAT_API_WINCE
    +
    255/* WinCE is very similar to Win32, so we'll mostly use that with some exceptions below. */
    +
    256# define RETROFLAT_API_WIN32
    +
    257#endif /* RETROFLAT_API_WINCE */
    +
    258
    +
    264#define RETROFLAT_COLOR_TABLE( f ) \
    +
    265 f( 0, black, BLACK, 0, 0, 0 ) \
    +
    266 f( 1, darkblue, DARKBLUE, 0, 0, 170 ) \
    +
    267 f( 2, darkgreen, DARKGREEN, 0, 170, 0 ) \
    +
    268 f( 3, teal, TEAL, 0, 170, 170 ) \
    +
    269 f( 4, darkred, DARKRED, 170, 0, 0 ) \
    +
    270 f( 5, violet, VIOLET, 170, 0, 170 ) \
    +
    271 f( 6, brown, BROWN, 170, 85, 0 ) \
    +
    272 f( 7, gray, GRAY, 170, 170, 170 ) \
    +
    273 f( 8, darkgray, DARKGRAY, 85, 85, 85 ) \
    +
    274 f( 9, blue, BLUE, 85, 85, 255 ) \
    +
    275 f( 10, green, GREEN, 85, 255, 85 ) \
    +
    276 f( 11, cyan, CYAN, 85, 255, 255 ) \
    +
    277 f( 12, red, RED, 255, 85, 85 ) \
    +
    278 f( 13, magenta, MAGENTA, 255, 85, 255 ) \
    +
    279 f( 14, yellow, YELLOW, 255, 255, 85 ) \
    +
    280 f( 15, white, WHITE, 255, 255, 255 )
    +
    281
    +
    282typedef int8_t RETROFLAT_COLOR;
    +
    283
    +
    284# define RETROFLAT_COLOR_NULL (-1)
    +
    285
    +
    286#ifndef RETROFLAT_COLORS_SZ
    +
    287# define RETROFLAT_COLORS_SZ 16
    +
    288#endif /* !RETROFLAT_COLORS_SZ */
    +
    289
    +
    292/* TODO: Mouse is broken under DOS/Allegro. */
    +
    293#if defined( RETROFLAT_OS_UNIX ) || defined( RETROFLAT_OS_WIN )
    +
    294#define RETROFLAT_MOUSE
    +
    295#endif /* RETROFLAT_OS_WIN || RETROFLAT_OS_WIN */
    +
    296
    +
    304#define RETROFLAT_OK 0x00
    +
    305#define RETROFLAT_ERROR_ENGINE 0x01
    +
    306#define RETROFLAT_ERROR_GRAPHICS 0x02
    +
    307#define RETROFLAT_ERROR_MOUSE 0x04
    +
    308
    +
    313#define RETROFLAT_ERROR_BITMAP 0x08
    +
    314#define RETROFLAT_ERROR_TIMER 0x0f
    +
    315 /* maug_retroflt_retval */
    +
    317
    +
    318#define bmp_read_uint32( b ) (*((uint32_t*)(b)))
    +
    319
    +
    334#define RETROFLAT_FLAGS_FILL 0x01
    +
    335
    +
    340#define RETROFLAT_FLAGS_OPAQUE 0x01
    +
    341
    +
    348#define RETROFLAT_FLAGS_SCREEN_BUFFER 0x80
    +
    349 /* maug_retroflt_drawing */
    +
    351
    +
    363#define RETROFLAT_FLAGS_RUNNING 0x01
    +
    364
    +
    369#define RETROFLAT_FLAGS_UNLOCK_FPS 0x02
    +
    370
    +
    375#define RETROFLAT_FLAGS_KEY_REPEAT 0x04
    +
    376
    +
    381#define RETROFLAT_FLAGS_SCREENSAVER 0x08
    +
    382 /* maug_retroflt_flags */
    +
    384
    +
    395#define RETROFLAT_BUFFER_INT 0x00
    +
    396
    +
    397#define RETROFLAT_BUFFER_STRING 0x01
    +
    398
    +
    399#define RETROFLAT_BUFFER_FLOAT 0x02
    +
    400
    +
    401#define RETROFLAT_BUFFER_BOOL 0x04
    +
    402 /* maug_retroflt_config_btypes */
    +
    404
    +
    419#define RETROFLAT_CONFIG_FLAG_W 0x01
    +
    420
    +
    424#define RETROFLAT_CONFIG_FLAG_BIN 0x02
    +
    425 /* maug_retroflt_config_flags */
    +
    427 /* maug_retroflt_config */
    +
    429
    +
    435#define RETROFLAT_MSG_FLAG_TYPE_MASK 0x07
    +
    436
    +
    437#define RETROFLAT_MSG_FLAG_ERROR 0x01
    +
    438
    +
    439#define RETROFLAT_MSG_FLAG_INFO 0x02
    +
    440
    +
    441#define RETROFLAT_MSG_FLAG_WARNING 0x04
    +
    442 /* maug_retroflt_msg_flags */
    +
    444
    +
    445struct RETROFLAT_STATE;
    +
    446
    +
    466#define RETROFLAT_VDP_FLAG_PXLOCK 0x01
    +
    467
    + +
    480 /* maug_retroflt_vdp */
    +
    482
    +
    512#define RETROFLAT_FLAGS_LOCK 0x01
    +
    513
    +
    514#define RETROFLAT_FLAGS_SCREEN_LOCK 0x02
    +
    515
    +
    520#ifndef RETROFLAT_BITMAP_EXT
    +
    521# define RETROFLAT_BITMAP_EXT "bmp"
    +
    522#endif /* !RETROFLAT_BITMAP_EXT */
    +
    523
    +
    524#ifndef RETROFLAT_OPENGL_BPP
    +
    525# define RETROFLAT_OPENGL_BPP 32
    +
    526#endif /* !RETROFLAT_OPENGL_BPP */
    +
    527
    +
    528/* Transparency background color: black by default, to match Allegro. */
    +
    529#ifndef RETROFLAT_TXP_R
    +
    535# define RETROFLAT_TXP_R 0x00
    +
    536#endif /* !RETROFLAT_TXP_R */
    +
    537
    +
    538#ifndef RETROFLAT_TXP_G
    +
    544# define RETROFLAT_TXP_G 0x00
    +
    545#endif /* !RETROFLAT_TXP_G */
    +
    546
    +
    547#ifndef RETROFLAT_TXP_B
    +
    553# define RETROFLAT_TXP_B 0x00
    +
    554#endif /* !RETROFLAT_TXP_B */
    +
    555 /* maug_retroflt_bitmap */
    +
    557
    +
    558#ifndef RETROFLAT_GL_Z
    +
    559# define RETROFLAT_GL_Z -0.001
    +
    560#endif /* !RETROFLAT_GL_Z */
    +
    561
    +
    562#define retroflat_on_resize( w, h ) \
    +
    563 g_retroflat_state->screen_w = w; \
    +
    564 g_retroflat_state->screen_h = h;
    +
    565
    +
    571#ifndef RETROFLAT_LINE_THICKNESS
    +
    576# define RETROFLAT_LINE_THICKNESS 1
    +
    577#endif /* !RETROFLAT_LINE_THICKNESS */
    +
    578
    +
    579#define RETROFLAT_PI 3.14159
    +
    580 /* maug_retroflt_drawing */
    +
    582
    +
    588#ifndef RETROFLAT_FPS
    +
    593# define RETROFLAT_FPS 30
    +
    594#endif /* !RETROFLAT_FPS */
    +
    595
    +
    596#define retroflat_fps_next() (1000 / RETROFLAT_FPS)
    +
    597
    +
    598#ifndef RETROFLAT_WINDOW_CLASS
    +
    603# define RETROFLAT_WINDOW_CLASS "RetroFlatWindowClass"
    +
    604#endif /* !RETROFLAT_WINDOW_CLASS */
    +
    605
    +
    606#ifndef RETROFLAT_WIN_GFX_TIMER_ID
    +
    611# define RETROFLAT_WIN_GFX_TIMER_ID 6001
    +
    612#endif /* !RETROFLAT_WIN_GFX_TIMER_ID */
    +
    613
    +
    614#ifndef RETROFLAT_MSG_MAX
    +
    619# define RETROFLAT_MSG_MAX 4096
    +
    620#endif /* !RETROFLAT_MSG_MAX */
    +
    621
    +
    622#ifndef RETROFLAT_PATH_MAX
    +
    624# define RETROFLAT_PATH_MAX 256
    +
    625#endif /* !RETROFLAT_PATH_MAX */
    +
    626
    +
    627#ifndef RETROFLAT_TITLE_MAX
    +
    628# define RETROFLAT_TITLE_MAX 255
    +
    629#endif /* !RETROFLAT_TITLE_MAX */
    +
    630
    +
    631#ifndef RETROFLAT_VDP_ARGS_SZ_MAX
    +
    635# define RETROFLAT_VDP_ARGS_SZ_MAX 255
    +
    636#endif /* !RETROFLAT_VDP_ARGS_SZ_MAX */
    +
    637
    +
    638#if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    639# if !defined( RETROFLAT_WIN_STYLE )
    +
    640# if defined( RETROFLAT_API_WINCE )
    +
    641# define RETROFLAT_WIN_STYLE (WS_VISIBLE)
    +
    642# else
    +
    643# define RETROFLAT_WIN_STYLE (WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME)
    +
    644# endif /* RETROFLAT_API_WINCE */
    +
    645# endif /* !RETROFLAT_WIN_STYLE */
    +
    646#endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    647
    +
    648#if defined( RETROFLAT_API_SDL2 )
    +
    649# if defined( RETROFLAT_RESIZABLE )
    +
    650# define RETROFLAT_WIN_FLAGS SDL_WINDOW_RESIZABLE
    +
    651# else
    +
    652# define RETROFLAT_WIN_FLAGS 0
    +
    653# endif /* RETROFLAT_RESIZABLE */
    +
    654#endif /* RETROFLAT_API_SDL2 */
    +
    655
    +
    656#if defined( RETROFLAT_API_SDL1 )
    +
    657# define RETROFLAT_SDL_CC_FLAGS (SDL_RLEACCEL | SDL_SRCCOLORKEY)
    +
    658#elif defined( RETROFLAT_API_SDL2 )
    +
    659# define RETROFLAT_SDL_CC_FLAGS (SDL_TRUE)
    +
    660#endif /* RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 */
    +
    661
    +
    662#ifdef RETROFLAT_OS_DOS
    +
    663# define RETROFLAT_PATH_SEP '\\'
    +
    664#else
    +
    666# define RETROFLAT_PATH_SEP '/'
    +
    667#endif /* RETROFLAT_OS_DOS */
    +
    668
    +
    670#define RETROFLAT_ASSETS_PATH_MAX (RETROFLAT_PATH_MAX / 2)
    +
    671
    +
    672#ifndef NDS_OAM_ACTIVE
    +
    674# define NDS_OAM_ACTIVE &oamMain
    +
    675#endif /* !NDS_OAM_ACTIVE */
    +
    676
    +
    677#ifndef NDS_SPRITES_ACTIVE
    +
    679# define NDS_SPRITES_ACTIVE 24
    +
    680#endif /* !NDS_SPRITES_ACTIVE */
    +
    681
    +
    682#ifndef RETROFLAT_CONFIG_LN_SZ_MAX
    +
    683# define RETROFLAT_CONFIG_LN_SZ_MAX 255
    +
    684#endif /* !RETROFLAT_CONFIG_LN_SZ_MAX */
    +
    685
    +
    686#ifndef RETROFLAT_CONFIG_EXT
    +
    687# define RETROFLAT_CONFIG_EXT ".ini"
    +
    688#endif /* !RETROFLAT_CONFIG_EXT */
    +
    689
    +
    690#ifndef RETROFLAT_BMP_COLORS_SZ_MAX
    +
    691# define RETROFLAT_BMP_COLORS_SZ_MAX 256
    +
    692#endif /* !RETROFLAT_BMP_COLORS_SZ_MAX */
    +
    693 /* maug_retroflt_compiling */
    +
    695
    +
    699typedef void (*retroflat_loop_iter)(void* data);
    +
    700
    +
    710#define retroflat_buffer_bksp( buffer, buffer_cur, buffer_sz ) \
    +
    711 if( 0 < buffer_cur ) { \
    +
    712 if( buffer_cur < buffer_sz ) { \
    +
    713 memmove( \
    +
    714 &(buffer[(buffer_cur) - 1]), \
    +
    715 &(buffer[buffer_cur]), \
    +
    716 (buffer_sz) - (buffer_cur) ); \
    +
    717 } \
    +
    718 buffer_cur--; \
    +
    719 buffer_sz--; \
    +
    720 buffer[buffer_sz] = '\0'; \
    +
    721 }
    +
    722
    +
    726#define retroflat_buffer_insert( c, buffer, buffer_cur, buffer_sz, buffer_mx ) \
    +
    727 if( buffer_sz + 1 < buffer_mx ) { \
    +
    728 if( buffer_cur < buffer_sz ) { \
    +
    729 memmove( \
    +
    730 &(buffer[(buffer_cur) + 1]), \
    +
    731 &(buffer[buffer_cur]), \
    +
    732 (buffer_sz) - (buffer_cur) ); \
    +
    733 } \
    +
    734 buffer[buffer_cur] = c; \
    +
    735 buffer_cur++; \
    +
    736 buffer_sz++; \
    +
    737 buffer[buffer_sz] = '\0'; \
    +
    738 }
    +
    739
    +
    740#define RETROFLAT_INPUT_MOD_SHIFT 0x01
    +
    741
    +
    742#define RETROFLAT_INPUT_MOD_ALT 0x02
    +
    743
    +
    744#define RETROFLAT_INPUT_MOD_CTRL 0x04
    +
    745
    +
    746#define RETROFLAT_INPUT_FORCE_UPPER 0x08
    +
    747
    + + + +
    760 uint8_t key_flags;
    +
    761};
    +
    762 /* maug_retroflt_input */
    +
    764
    +
    765#ifdef RETROFLAT_OPENGL
    +
    766struct RETROFLAT_GLTEX {
    +
    767 MAUG_MHANDLE bytes_h;
    +
    768 uint8_t* bytes;
    +
    769 uint32_t bpp;
    +
    770 uint32_t sz;
    +
    771 uint8_t* px;
    +
    772 uint32_t id;
    +
    773 size_t w;
    +
    774 size_t h;
    +
    775};
    +
    776#endif /* RETROFLAT_OPENGL */
    +
    777
    +
    778/* === Platform-Specific Includes and Defines === */
    +
    779
    +
    780#if defined( RETROFLAT_API_ALLEGRO )
    +
    781
    +
    782# ifdef RETROFLAT_OPENGL
    +
    783# error "opengl support not implemented for allegro"
    +
    784# endif /* RETROFLAT_OPENGL */
    +
    785
    +
    786/* == Allegro == */
    +
    787
    +
    788# include <allegro.h>
    +
    789
    +
    790# ifdef RETROFLAT_OS_DOS
    +
    791# include <dos.h>
    +
    792# include <conio.h>
    +
    793# endif /* RETROFLAT_OS_DOS */
    +
    794
    +
    795#include <time.h> /* For srand() */
    +
    796
    +
    797# ifndef RETROFLAT_CONFIG_USE_FILE
    +
    798# define RETROFLAT_CONFIG_USE_FILE
    +
    799# endif /* !RETROFLAT_CONFIG_USE_FILE */
    +
    800
    +
    801typedef FILE* RETROFLAT_CONFIG;
    +
    802
    +
    803struct RETROFLAT_BITMAP {
    +
    804 size_t sz;
    +
    805 uint8_t flags;
    +
    806 BITMAP* b;
    +
    807};
    +
    808
    +
    809typedef int RETROFLAT_COLOR_DEF;
    +
    810
    +
    811# define retroflat_bitmap_ok( bitmap ) (NULL != (bitmap)->b)
    +
    812# define retroflat_bitmap_locked( bmp ) (0)
    +
    813# ifdef RETROFLAT_OPENGL
    +
    814# define retroflat_bitmap_w( bmp ) ((bmp)->tex.w)
    +
    815# define retroflat_bitmap_h( bmp ) ((bmp)->tex.h)
    +
    816# else
    +
    817# define retroflat_bitmap_w( bmp ) ((bmp)->w)
    +
    818# define retroflat_bitmap_h( bmp ) ((bmp)->h)
    +
    819# endif /* RETROFLAT_OPENGL */
    +
    820# define retroflat_screen_w() SCREEN_W
    +
    821# define retroflat_screen_h() SCREEN_H
    +
    822# define retroflat_screen_buffer() (&(g_retroflat_state->buffer))
    +
    823# define retroflat_px_lock( bmp )
    +
    824# define retroflat_px_release( bmp )
    +
    825
    +
    826# define retroflat_quit( retval_in ) \
    +
    827 g_retroflat_state->retroflat_flags &= ~RETROFLAT_FLAGS_RUNNING; \
    +
    828 g_retroflat_state->retval = retval_in;
    +
    829
    +
    830# define RETROFLAT_MOUSE_B_LEFT -1
    +
    831# define RETROFLAT_MOUSE_B_RIGHT -2
    +
    832
    +
    833# define RETROFLAT_KEY_UP KEY_UP
    +
    834# define RETROFLAT_KEY_DOWN KEY_DOWN
    +
    835# define RETROFLAT_KEY_RIGHT KEY_RIGHT
    +
    836# define RETROFLAT_KEY_LEFT KEY_LEFT
    +
    837# define RETROFLAT_KEY_A KEY_A
    +
    838# define RETROFLAT_KEY_B KEY_B
    +
    839# define RETROFLAT_KEY_C KEY_C
    +
    840# define RETROFLAT_KEY_D KEY_D
    +
    841# define RETROFLAT_KEY_E KEY_E
    +
    842# define RETROFLAT_KEY_F KEY_F
    +
    843# define RETROFLAT_KEY_G KEY_G
    +
    844# define RETROFLAT_KEY_H KEY_H
    +
    845# define RETROFLAT_KEY_I KEY_I
    +
    846# define RETROFLAT_KEY_J KEY_J
    +
    847# define RETROFLAT_KEY_K KEY_K
    +
    848# define RETROFLAT_KEY_L KEY_L
    +
    849# define RETROFLAT_KEY_M KEY_M
    +
    850# define RETROFLAT_KEY_N KEY_N
    +
    851# define RETROFLAT_KEY_O KEY_O
    +
    852# define RETROFLAT_KEY_P KEY_P
    +
    853# define RETROFLAT_KEY_Q KEY_Q
    +
    854# define RETROFLAT_KEY_R KEY_R
    +
    855# define RETROFLAT_KEY_S KEY_S
    +
    856# define RETROFLAT_KEY_T KEY_T
    +
    857# define RETROFLAT_KEY_U KEY_U
    +
    858# define RETROFLAT_KEY_V KEY_V
    +
    859# define RETROFLAT_KEY_W KEY_W
    +
    860# define RETROFLAT_KEY_X KEY_X
    +
    861# define RETROFLAT_KEY_Y KEY_Y
    +
    862# define RETROFLAT_KEY_Z KEY_Z
    +
    863# define RETROFLAT_KEY_0 KEY_0
    +
    864# define RETROFLAT_KEY_1 KEY_1
    +
    865# define RETROFLAT_KEY_2 KEY_2
    +
    866# define RETROFLAT_KEY_3 KEY_3
    +
    867# define RETROFLAT_KEY_4 KEY_4
    +
    868# define RETROFLAT_KEY_5 KEY_5
    +
    869# define RETROFLAT_KEY_6 KEY_6
    +
    870# define RETROFLAT_KEY_7 KEY_7
    +
    871# define RETROFLAT_KEY_8 KEY_8
    +
    872# define RETROFLAT_KEY_9 KEY_9
    +
    873# define RETROFLAT_KEY_TAB KEY_TAB
    +
    874# define RETROFLAT_KEY_SPACE KEY_SPACE
    +
    875# define RETROFLAT_KEY_ESC KEY_ESC
    +
    876# define RETROFLAT_KEY_ENTER KEY_ENTER
    +
    877# define RETROFLAT_KEY_HOME KEY_HOME
    +
    878# define RETROFLAT_KEY_END KEY_END
    +
    879# define RETROFLAT_KEY_DELETE KEY_DEL
    +
    880# define RETROFLAT_KEY_PGUP KEY_PGUP
    +
    881# define RETROFLAT_KEY_PGDN KEY_PGDN
    +
    882# define RETROFLAT_KEY_GRAVE KEY_BACKQUOTE
    +
    883# define RETROFLAT_KEY_BKSP KEY_BACKSPACE
    +
    884# define RETROFLAT_KEY_SLASH KEY_SLASH
    +
    885# define RETROFLAT_KEY_SEMICOLON KEY_SEMICOLON
    +
    886# define RETROFLAT_KEY_PERIOD KEY_STOP
    +
    887# define RETROFLAT_KEY_COMMA KEY_COMMA
    +
    888# define RETROFLAT_KEY_EQUALS KEY_EQUALS
    +
    889# define RETROFLAT_KEY_DASH KEY_MINUS
    +
    890
    +
    891#elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    892
    +
    893# if defined( RETROFLAT_API_SDL2 ) && defined( RETROFLAT_OPENGL )
    +
    894# error "opengl support not implemented for SDL 2"
    +
    895# endif /* RETROFLAT_API_SDL2 && RETROFLAT_OPENGL */
    +
    896
    +
    897# include <time.h> /* For srand() */
    +
    898
    +
    899# if defined( RETROFLAT_OS_WASM )
    +
    900# include <emscripten.h>
    +
    901# endif /* RETROFLAT_OS_WASM */
    +
    902
    +
    903# ifndef RETROFLAT_CONFIG_USE_FILE
    +
    904# define RETROFLAT_CONFIG_USE_FILE
    +
    905# endif /* !RETROFLAT_CONFIG_USE_FILE */
    +
    906
    +
    907# include <SDL.h>
    +
    908
    +
    909# if !defined( RETROFLAT_SOFT_SHAPES ) && !defined( RETROFLAT_OPENGL )
    +
    910# define RETROFLAT_SOFT_SHAPES
    +
    911# endif /* !RETROFLAT_SOFT_SHAPES */
    +
    912
    +
    913typedef FILE* RETROFLAT_CONFIG;
    +
    914
    +
    915struct RETROFLAT_BITMAP {
    +
    916 size_t sz;
    +
    917 uint8_t flags;
    +
    918 SDL_Surface* surface;
    +
    919# ifdef RETROFLAT_API_SDL1
    +
    920 /* SDL1 autolock counter. */
    +
    921 ssize_t autolock_refs;
    +
    922# else
    +
    923 /* SDL2 texture pointers. */
    +
    924 SDL_Texture* texture;
    +
    925 SDL_Renderer* renderer;
    +
    926# endif /* RETROFLAT_API_SDL1 */
    +
    927# ifdef RETROFLAT_OPENGL
    +
    928 struct RETROFLAT_GLTEX tex;
    +
    929# endif /* RETROFLAT_OPENGL */
    +
    930};
    +
    931
    +
    932# define RETROFLAT_KEY_UP SDLK_UP
    +
    933# define RETROFLAT_KEY_DOWN SDLK_DOWN
    +
    934# define RETROFLAT_KEY_RIGHT SDLK_RIGHT
    +
    935# define RETROFLAT_KEY_LEFT SDLK_LEFT
    +
    936# define RETROFLAT_KEY_A SDLK_a
    +
    937# define RETROFLAT_KEY_B SDLK_b
    +
    938# define RETROFLAT_KEY_C SDLK_c
    +
    939# define RETROFLAT_KEY_D SDLK_d
    +
    940# define RETROFLAT_KEY_E SDLK_e
    +
    941# define RETROFLAT_KEY_F SDLK_f
    +
    942# define RETROFLAT_KEY_G SDLK_g
    +
    943# define RETROFLAT_KEY_H SDLK_h
    +
    944# define RETROFLAT_KEY_I SDLK_i
    +
    945# define RETROFLAT_KEY_J SDLK_j
    +
    946# define RETROFLAT_KEY_K SDLK_k
    +
    947# define RETROFLAT_KEY_L SDLK_l
    +
    948# define RETROFLAT_KEY_M SDLK_m
    +
    949# define RETROFLAT_KEY_N SDLK_n
    +
    950# define RETROFLAT_KEY_O SDLK_o
    +
    951# define RETROFLAT_KEY_P SDLK_p
    +
    952# define RETROFLAT_KEY_Q SDLK_q
    +
    953# define RETROFLAT_KEY_R SDLK_r
    +
    954# define RETROFLAT_KEY_S SDLK_s
    +
    955# define RETROFLAT_KEY_T SDLK_t
    +
    956# define RETROFLAT_KEY_U SDLK_u
    +
    957# define RETROFLAT_KEY_V SDLK_v
    +
    958# define RETROFLAT_KEY_W SDLK_w
    +
    959# define RETROFLAT_KEY_X SDLK_x
    +
    960# define RETROFLAT_KEY_Y SDLK_y
    +
    961# define RETROFLAT_KEY_Z SDLK_z
    +
    962# define RETROFLAT_KEY_0 SDLK_0
    +
    963# define RETROFLAT_KEY_1 SDLK_1
    +
    964# define RETROFLAT_KEY_2 SDLK_2
    +
    965# define RETROFLAT_KEY_3 SDLK_3
    +
    966# define RETROFLAT_KEY_4 SDLK_4
    +
    967# define RETROFLAT_KEY_5 SDLK_5
    +
    968# define RETROFLAT_KEY_6 SDLK_6
    +
    969# define RETROFLAT_KEY_7 SDLK_7
    +
    970# define RETROFLAT_KEY_8 SDLK_8
    +
    971# define RETROFLAT_KEY_9 SDLK_9
    +
    972# define RETROFLAT_KEY_TAB SDLK_TAB
    +
    973# define RETROFLAT_KEY_SPACE SDLK_SPACE
    +
    974# define RETROFLAT_KEY_ESC SDLK_ESCAPE
    +
    975# define RETROFLAT_KEY_ENTER SDLK_RETURN
    +
    976# define RETROFLAT_KEY_HOME SDLK_HOME
    +
    977# define RETROFLAT_KEY_END SDLK_END
    +
    978# define RETROFLAT_KEY_DELETE SDLK_DELETE
    +
    979# define RETROFLAT_KEY_PGUP SDLK_PAGEUP
    +
    980# define RETROFLAT_KEY_PGDN SDLK_PAGEDOWN
    +
    981# define RETROFLAT_KEY_GRAVE SDLK_BACKQUOTE
    +
    982# define RETROFLAT_KEY_SLASH SDLK_SLASH
    +
    983# define RETROFLAT_KEY_BKSP SDLK_BACKSPACE
    +
    984# define RETROFLAT_KEY_SEMICOLON SDLK_SEMICOLON
    +
    985# define RETROFLAT_KEY_PERIOD SDLK_PERIOD
    +
    986# define RETROFLAT_KEY_COMMA SDLK_COMMA
    +
    987# define RETROFLAT_KEY_EQUALS SDLK_EQUALS
    +
    988# define RETROFLAT_KEY_DASH SDLK_MINUS
    +
    989
    +
    990# define RETROFLAT_MOUSE_B_LEFT -1
    +
    991# define RETROFLAT_MOUSE_B_RIGHT -2
    +
    992
    +
    993# define retroflat_bitmap_ok( bitmap ) (NULL != (bitmap)->surface)
    +
    994# ifdef RETROFLAT_OPENGL
    +
    995# define retroflat_bitmap_w( bmp ) ((bmp)->tex.w)
    +
    996# define retroflat_bitmap_h( bmp ) ((bmp)->tex.h)
    +
    997# else
    +
    998# define retroflat_bitmap_w( bmp ) ((bmp)->surface->w)
    +
    999# define retroflat_bitmap_h( bmp ) ((bmp)->surface->h)
    +
    1000# endif /* RETROFLAT_OPENGL */
    +
    1001# ifdef RETROFLAT_API_SDL1
    +
    1002# define retroflat_bitmap_locked( bmp ) \
    +
    1003 (RETROFLAT_FLAGS_LOCK == (RETROFLAT_FLAGS_LOCK & (bmp)->flags))
    +
    1004# else
    +
    1005# define retroflat_bitmap_locked( bmp ) (NULL != (bmp)->renderer)
    +
    1006# endif
    +
    1007# define retroflat_screen_w() (g_retroflat_state->screen_v_w)
    +
    1008# define retroflat_screen_h() (g_retroflat_state->screen_v_h)
    +
    1009# define retroflat_screen_buffer() \
    +
    1010 (NULL == g_retroflat_state->vdp_buffer ? \
    +
    1011 &(g_retroflat_state->buffer) : g_retroflat_state->vdp_buffer)
    +
    1012
    +
    1013# if defined( RETROFLAT_API_SDL1 ) && !defined( RETROFLAT_OPENGL )
    +
    1014/* Special pixel lock JUST for SDL1 surfaces. */
    +
    1015# define retroflat_px_lock( bmp ) \
    +
    1016 assert( NULL != bmp ); \
    +
    1017 (bmp)->autolock_refs++; \
    +
    1018 SDL_LockSurface( (bmp)->surface );
    +
    1019# define retroflat_px_release( bmp ) \
    +
    1020 assert( NULL != bmp ); \
    +
    1021 assert( 0 < (bmp)->autolock_refs ); \
    +
    1022 (bmp)->autolock_refs--; \
    +
    1023 SDL_UnlockSurface( (bmp)->surface );
    +
    1024# else
    +
    1025/* Pixel lock above does not apply to SDL2 surfaces or bitmap textures. */
    +
    1026# define retroflat_px_lock( bmp )
    +
    1027# define retroflat_px_release( bmp )
    +
    1028# endif
    +
    1029
    +
    1030# define retroflat_quit( retval_in ) \
    +
    1031 g_retroflat_state->retroflat_flags &= ~RETROFLAT_FLAGS_RUNNING; \
    +
    1032 g_retroflat_state->retval = retval_in;
    +
    1033
    +
    1034# define END_OF_MAIN()
    +
    1035
    +
    1036 /* SDL Icon */
    +
    1037# if defined( RETROFLT_C ) && defined( RETROFLAT_SDL_ICO )
    +
    1038# include <sdl_ico.h>
    +
    1039# endif /* RETROFLT_C && RETROFLAT_SDL_ICO */
    +
    1040
    +
    1041 /* SDL Colors */
    +
    1042# ifdef RETROFLAT_OPENGL
    +
    1043typedef float MAUG_CONST* RETROFLAT_COLOR_DEF;
    +
    1044#else
    +
    1045typedef SDL_Color RETROFLAT_COLOR_DEF;
    +
    1046# endif /* RETROFLAT_OPENGL */
    +
    1047
    +
    1048#elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    1049
    +
    1050/* == Win16/Win32 == */
    +
    1051
    +
    1052# if defined( RETROFLAT_API_WIN16 ) && defined( RETROFLAT_OPENGL )
    +
    1053# error "opengl support not implemented for win16"
    +
    1054# endif /* RETROFLAT_API_SDL2 && RETROFLAT_OPENGL */
    +
    1055
    +
    1056#ifndef MAUG_WINDOWS_H
    +
    1057# include <windows.h>
    +
    1058# define MAUG_WINDOWS_H
    +
    1059#endif /* !MAUG_WINDOWS_H */
    +
    1060
    +
    1061# include <mmsystem.h>
    +
    1062
    +
    1063# ifndef RETROFLAT_API_WINCE
    +
    1064# include <time.h> /* For srand() */
    +
    1065# endif /* !RETROFLAT_API_WINCE */
    +
    1066
    +
    1067# ifdef RETROFLAT_WING
    +
    1068
    +
    1069# if defined( RETROFLAT_API_WIN32 )
    +
    1070# define WINGAPI WINAPI
    +
    1071# else
    +
    1072# define WINGAPI WINAPI _loadds
    +
    1073# endif
    +
    1074
    +
    1075# define RETROFLAT_WING_LLTABLE( f ) \
    +
    1076 f( HDC, WinGCreateDC, 1001 ) \
    +
    1077 f( BOOL, WinGRecommendDIBFormat, 1002 ) \
    +
    1078 f( HBITMAP, WinGCreateBitmap, 1003 ) \
    +
    1079 f( BOOL, WinGStretchBlt, 1009 )
    +
    1080
    +
    1081typedef HDC (WINGAPI *WinGCreateDC_t)();
    +
    1082typedef BOOL (WINGAPI *WinGRecommendDIBFormat_t)( BITMAPINFO FAR* );
    +
    1083typedef HBITMAP (WINGAPI *WinGCreateBitmap_t)(
    +
    1084 HDC, BITMAPINFO const FAR*, void FAR* FAR* );
    +
    1085typedef BOOL (WINGAPI *WinGStretchBlt_t)(
    +
    1086 HDC, int, int, int, int, HDC, int, int, int, int );
    +
    1087
    +
    1088# define RETROFLAT_WING_LLTABLE_STRUCT_MEMBERS( retval, proc, ord ) \
    +
    1089 proc ## _t proc;
    +
    1090
    +
    1091struct RETROFLAT_WING_MODULE {
    +
    1092 HMODULE module;
    +
    1093 uint8_t success;
    +
    1094 RETROFLAT_WING_LLTABLE( RETROFLAT_WING_LLTABLE_STRUCT_MEMBERS )
    +
    1095};
    +
    1096# endif /* RETROFLAT_WING */
    +
    1097
    +
    1098struct RETROFLAT_BMI {
    +
    1099 BITMAPINFOHEADER header;
    +
    1100 RGBQUAD colors[RETROFLAT_BMP_COLORS_SZ_MAX];
    +
    1101};
    +
    1102
    +
    1103# ifdef RETROFLAT_API_WIN32
    +
    1104typedef HKEY RETROFLAT_CONFIG;
    +
    1105# else
    +
    1106typedef int RETROFLAT_CONFIG;
    +
    1107# endif /* RETROFLAT_API_WIN32 */
    +
    1108
    +
    1109struct RETROFLAT_BITMAP {
    +
    1110 size_t sz;
    +
    1111 uint8_t flags;
    +
    1112 HBITMAP b;
    +
    1113 HBITMAP mask;
    +
    1114 HDC hdc_b;
    +
    1115 HDC hdc_mask;
    +
    1116 HBITMAP old_hbm_b;
    +
    1117 HBITMAP old_hbm_mask;
    +
    1118# ifdef RETROFLAT_API_WIN16
    +
    1119 uint8_t far* bits;
    +
    1120# else
    +
    1121 uint8_t* bits;
    +
    1122# endif /* RETROFLAT_API_WIN16 */
    +
    1123 ssize_t autolock_refs;
    +
    1124# ifdef RETROFLAT_OPENGL
    +
    1125 struct RETROFLAT_GLTEX tex;
    +
    1126# endif /* RETROFLAT_OPENGL */
    +
    1127 struct RETROFLAT_BMI bmi;
    +
    1128};
    +
    1129
    +
    1130/* TODO: Remove this in favor of mmem.h. */
    +
    1131# if defined( RETROFLAT_C ) && defined( RETROFLAT_API_WINCE )
    +
    1132void* calloc( size_t n, size_t s ) {
    +
    1133 void* out = NULL;
    +
    1134
    +
    1135 out = malloc( n * s );
    +
    1136 memset( out, '\0', n * s );
    +
    1137
    +
    1138 return out;
    +
    1139}
    +
    1140# endif /* RETROFLAT_API_WINCE */
    +
    1141
    +
    1142# ifdef RETROFLAT_OPENGL
    +
    1143
    +
    1144typedef float MAUG_CONST* RETROFLAT_COLOR_DEF;
    +
    1145
    +
    1146# else
    +
    1147
    +
    1148/* Use Windoes API and generate brushes/pens for GDI. */
    +
    1149
    +
    1150typedef COLORREF RETROFLAT_COLOR_DEF;
    +
    1151
    +
    1152/* === Setup Brush Cache === */
    +
    1153
    +
    1154/* This will be initialized in setup, so just preserve the number. */
    +
    1155# define RETROFLAT_COLOR_TABLE_WIN_BRUSH( idx, name_l, name_u, r, g, b ) \
    +
    1156 (HBRUSH)NULL,
    +
    1157
    +
    1158# define RETROFLAT_COLOR_TABLE_WIN_BRSET( idx, name_l, name_u, r, g, b ) \
    +
    1159 gc_retroflat_win_brushes[idx] = CreateSolidBrush( RGB( r, g, b ) );
    +
    1160
    +
    1161# define RETROFLAT_COLOR_TABLE_WIN_BRRM( idx, name_l, name_u, r, g, b ) \
    +
    1162 if( (HBRUSH)NULL != gc_retroflat_win_brushes[idx] ) { \
    +
    1163 DeleteObject( gc_retroflat_win_brushes[idx] ); \
    +
    1164 gc_retroflat_win_brushes[idx] = (HBRUSH)NULL; \
    +
    1165 }
    +
    1166
    +
    1167/* === End Setup Brush Cache === */
    +
    1168
    +
    1169/* === Setup Pen Cache === */
    +
    1170
    +
    1171# define RETROFLAT_COLOR_TABLE_WIN_PENS( idx, name_l, name_u, r, g, b ) \
    +
    1172 (HPEN)NULL,
    +
    1173
    +
    1174# define RETROFLAT_COLOR_TABLE_WIN_PNSET( idx, name_l, name_u, r, g, b ) \
    +
    1175 gc_retroflat_win_pens[idx] = CreatePen( \
    +
    1176 PS_SOLID, RETROFLAT_LINE_THICKNESS, RGB( r, g, b ) );
    +
    1177
    +
    1178# define RETROFLAT_COLOR_TABLE_WIN_PENRM( idx, name_l, name_u, r, g, b ) \
    +
    1179 if( (HPEN)NULL != gc_retroflat_win_pens[idx] ) { \
    +
    1180 DeleteObject( gc_retroflat_win_pens[idx] ); \
    +
    1181 gc_retroflat_win_pens[idx] = (HPEN)NULL; \
    +
    1182 }
    +
    1183
    +
    1184/* === End Setup Pen Cache === */
    +
    1185
    +
    1186# ifdef RETROFLT_C
    +
    1187
    +
    1188HBRUSH gc_retroflat_win_brushes[] = {
    +
    1189 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_BRUSH )
    +
    1190};
    +
    1191
    +
    1192static HPEN gc_retroflat_win_pens[] = {
    +
    1193 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_PENS )
    +
    1194};
    +
    1195
    +
    1196# else
    +
    1197
    +
    1198extern HBRUSH gc_retroflat_win_brushes[];
    +
    1199
    +
    1200# endif /* RETROFLT_C */
    +
    1201
    +
    1202/* Create a brush and set it to the target HDC. */
    +
    1203# define retroflat_win_setup_brush( old_brush, target, color, flags ) \
    +
    1204 if( RETROFLAT_FLAGS_FILL != (RETROFLAT_FLAGS_FILL & flags) ) { \
    +
    1205 old_brush = \
    +
    1206 SelectObject( target->hdc_b, GetStockObject( NULL_BRUSH ) ); \
    +
    1207 } else { \
    +
    1208 old_brush = SelectObject( \
    +
    1209 target->hdc_b, gc_retroflat_win_brushes[color] ); \
    +
    1210 }
    +
    1211
    +
    1212/* Create a pen and set it to the target HDC. */
    +
    1213# define retroflat_win_setup_pen( old_pen, target, color, flags ) \
    +
    1214 old_pen = \
    +
    1215 SelectObject( target->hdc_b, gc_retroflat_win_pens[color] );
    +
    1216
    +
    1217# define retroflat_win_cleanup_brush( old_brush, target ) \
    +
    1218 if( (HBRUSH)NULL != old_brush ) { \
    +
    1219 SelectObject( target->hdc_b, old_brush ); \
    +
    1220 }
    +
    1221
    +
    1222# define retroflat_win_cleanup_pen( old_pen, target ) \
    +
    1223 if( (HPEN)NULL != old_pen ) { \
    +
    1224 SelectObject( target->hdc_b, old_pen ); \
    +
    1225 }
    +
    1226
    +
    1227#endif /* RETROFLAT_OPENGL */
    +
    1228
    +
    1229/* TODO: This is a parallel bitmap system... maybe move OPENGL stuff into its
    +
    1230 * own header that takes over graphics stuff in OPENGL mode? */
    +
    1231# ifdef RETROFLAT_OPENGL
    +
    1232# define retroflat_bitmap_w( bmp ) ((bmp)->tex.w)
    +
    1233# define retroflat_bitmap_h( bmp ) ((bmp)->tex.h)
    +
    1234# define retroflat_bitmap_locked( bmp ) (NULL != (bmp)->tex.bytes)
    +
    1235# else
    +
    1236# define retroflat_bitmap_w( bmp ) ((bmp)->bmi.header.biWidth)
    +
    1237# define retroflat_bitmap_h( bmp ) ((bmp)->bmi.header.biHeight)
    +
    1238# define retroflat_bitmap_locked( bmp ) ((HDC)NULL != (bmp)->hdc_b)
    +
    1239# endif /* RETROFLAT_OPENGL */
    +
    1240/* TODO: Adapt this for the OPENGL test above? */
    +
    1241# define retroflat_bitmap_ok( bitmap ) ((HBITMAP)NULL != (bitmap)->b)
    +
    1242
    +
    1243# ifdef RETROFLAT_VDP
    +
    1244
    +
    1245/* TODO: Check alloc! */
    +
    1246# define retroflat_px_lock( bmp ) \
    +
    1247 assert( NULL != (bmp)->hdc_b ); \
    +
    1248 /* Confirm header info. */ \
    +
    1249 (bmp)->autolock_refs++; \
    +
    1250 if( \
    +
    1251 1 == (bmp)->autolock_refs && \
    +
    1252 RETROFLAT_FLAGS_SCREEN_BUFFER != \
    +
    1253 (RETROFLAT_FLAGS_SCREEN_BUFFER & (bmp)->flags) \
    +
    1254 ) { \
    +
    1255 /* GetDIBits( g_retroflat_state->hdc_win, (bmp)->b, 0, 0, NULL, \
    +
    1256 (BITMAPINFO*)&((bmp)->bmi), DIB_RGB_COLORS ); */ \
    +
    1257 assert( NULL == (bmp)->bits ); \
    +
    1258 assert( (bmp)->bmi.header.biBitCount == 32 ); \
    +
    1259 assert( (bmp)->bmi.header.biWidth > 0 ); \
    +
    1260 assert( (bmp)->bmi.header.biHeight > 0 ); \
    +
    1261 assert( (bmp)->bmi.header.biSizeImage == \
    +
    1262 (bmp)->bmi.header.biWidth * (bmp)->bmi.header.biHeight * 4 ); \
    +
    1263 (bmp)->bits = VirtualAlloc( \
    +
    1264 0, (bmp)->bmi.header.biSizeImage, \
    +
    1265 MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE ); \
    +
    1266 assert( NULL != (bmp)->bits ); \
    +
    1267 GetDIBits( (bmp)->hdc_b, (bmp)->b, 0, (bmp)->bmi.header.biHeight, \
    +
    1268 (bmp)->bits, (BITMAPINFO*)&((bmp)->bmi), DIB_RGB_COLORS ); \
    +
    1269 }
    +
    1270
    +
    1271# define retroflat_px_release( bmp ) \
    +
    1272 assert( 0 < (bmp)->autolock_refs ); \
    +
    1273 (bmp)->autolock_refs--; \
    +
    1274 if( \
    +
    1275 0 == (bmp)->autolock_refs && \
    +
    1276 RETROFLAT_FLAGS_SCREEN_BUFFER != \
    +
    1277 (RETROFLAT_FLAGS_SCREEN_BUFFER & (bmp)->flags) \
    +
    1278 ) { \
    +
    1279 /* TODO: Causes alpha blending in mdemos? */ \
    +
    1280 if( \
    +
    1281 SetDIBits( g_retroflat_state->hdc_win, (bmp)->b, 0, \
    +
    1282 (bmp)->bmi.header.biHeight, (bmp)->bits, \
    +
    1283 (BITMAPINFO*)&((bmp)->bmi), DIB_RGB_COLORS ) < \
    +
    1284 (bmp)->bmi.header.biHeight \
    +
    1285 ) { \
    +
    1286 error_printf( "SetDIBits failed!" ); \
    +
    1287 } \
    +
    1288 VirtualFree( (bmp)->bits, 0, MEM_RELEASE ); \
    +
    1289 (bmp)->bits = NULL; \
    +
    1290 }
    +
    1291
    +
    1292# else
    +
    1293
    +
    1294# define retroflat_px_lock( bmp )
    +
    1295# define retroflat_px_release( bmp )
    +
    1296
    +
    1297# endif /* RETROFLAT_VDP */
    +
    1298
    +
    1299# define retroflat_screen_w() (g_retroflat_state->screen_v_w)
    +
    1300# define retroflat_screen_h() (g_retroflat_state->screen_v_h)
    +
    1301# define retroflat_screen_buffer() \
    +
    1302 (NULL == g_retroflat_state->vdp_buffer ? \
    +
    1303 &(g_retroflat_state->buffer) : g_retroflat_state->vdp_buffer)
    +
    1304# define retroflat_quit( retval_in ) PostQuitMessage( retval_in );
    +
    1305
    +
    1306# define retroflat_bmp_int( type, buf, offset ) *((type*)&(buf[offset]))
    +
    1307
    +
    1308# ifndef VK_OEM_2
    +
    1309# define VK_OEM_2 0xbf
    +
    1310# endif /* !VK_OEM_2 */
    +
    1311
    +
    1312# ifndef VK_OEM_3
    +
    1313# define VK_OEM_3 0xc0
    +
    1314# endif /* !VK_OEM_3 */
    +
    1315
    +
    1316# define RETROFLAT_KEY_GRAVE VK_OEM_3
    +
    1317# define RETROFLAT_KEY_SLASH VK_OEM_2
    +
    1318# define RETROFLAT_KEY_UP VK_UP
    +
    1319# define RETROFLAT_KEY_DOWN VK_DOWN
    +
    1320# define RETROFLAT_KEY_RIGHT VK_RIGHT
    +
    1321# define RETROFLAT_KEY_LEFT VK_LEFT
    +
    1322# define RETROFLAT_KEY_BKSP VK_BACK
    +
    1323# define RETROFLAT_KEY_A 0x41
    +
    1324# define RETROFLAT_KEY_B 0x42
    +
    1325# define RETROFLAT_KEY_C 0x43
    +
    1326# define RETROFLAT_KEY_D 0x44
    +
    1327# define RETROFLAT_KEY_E 0x45
    +
    1328# define RETROFLAT_KEY_F 0x46
    +
    1329# define RETROFLAT_KEY_G 0x47
    +
    1330# define RETROFLAT_KEY_H 0x48
    +
    1331# define RETROFLAT_KEY_I 0x49
    +
    1332# define RETROFLAT_KEY_J 0x4a
    +
    1333# define RETROFLAT_KEY_K 0x4b
    +
    1334# define RETROFLAT_KEY_L 0x4c
    +
    1335# define RETROFLAT_KEY_M 0x4d
    +
    1336# define RETROFLAT_KEY_N 0x4e
    +
    1337# define RETROFLAT_KEY_O 0x4f
    +
    1338# define RETROFLAT_KEY_P 0x50
    +
    1339# define RETROFLAT_KEY_Q 0x51
    +
    1340# define RETROFLAT_KEY_R 0x52
    +
    1341# define RETROFLAT_KEY_S 0x53
    +
    1342# define RETROFLAT_KEY_T 0x54
    +
    1343# define RETROFLAT_KEY_U 0x55
    +
    1344# define RETROFLAT_KEY_V 0x56
    +
    1345# define RETROFLAT_KEY_W 0x57
    +
    1346# define RETROFLAT_KEY_X 0x58
    +
    1347# define RETROFLAT_KEY_Y 0x59
    +
    1348# define RETROFLAT_KEY_Z 0x60
    +
    1349# define RETROFLAT_KEY_0 0x30
    +
    1350# define RETROFLAT_KEY_1 0x31
    +
    1351# define RETROFLAT_KEY_2 0x32
    +
    1352# define RETROFLAT_KEY_3 0x33
    +
    1353# define RETROFLAT_KEY_4 0x34
    +
    1354# define RETROFLAT_KEY_5 0x35
    +
    1355# define RETROFLAT_KEY_6 0x36
    +
    1356# define RETROFLAT_KEY_7 0x37
    +
    1357# define RETROFLAT_KEY_8 0x38
    +
    1358# define RETROFLAT_KEY_9 0x39
    +
    1359# define RETROFLAT_KEY_TAB VK_TAB
    +
    1360# define RETROFLAT_KEY_SPACE VK_SPACE
    +
    1361# define RETROFLAT_KEY_ESC VK_ESCAPE
    +
    1362# define RETROFLAT_KEY_ENTER VK_RETURN
    +
    1363# define RETROFLAT_KEY_HOME VK_HOME
    +
    1364# define RETROFLAT_KEY_END VK_END
    +
    1365# define RETROFLAT_KEY_DELETE VK_DELETE
    +
    1366# define RETROFLAT_KEY_PGUP VK_PRIOR
    +
    1367# define RETROFLAT_KEY_PGDN VK_NEXT
    +
    1368# define RETROFLAT_KEY_SEMICOLON ';'
    +
    1369# define RETROFLAT_KEY_PERIOD '.'
    +
    1370# define RETROFLAT_KEY_COMMA ','
    +
    1371# define RETROFLAT_KEY_EQUALS '='
    +
    1372# define RETROFLAT_KEY_DASH '-'
    +
    1373
    +
    1374# define RETROFLAT_MOUSE_B_LEFT VK_LBUTTON
    +
    1375# define RETROFLAT_MOUSE_B_RIGHT VK_RBUTTON
    +
    1376
    +
    1377/* Set the calling convention for WinMain, depending on Win16/Win32. */
    +
    1378# if defined( RETROFLAT_API_WIN16 )
    +
    1379# define WINXAPI PASCAL
    +
    1380# elif defined( RETROFLAT_API_WIN32 )
    +
    1381# define WINXAPI WINAPI
    +
    1382# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    1383
    +
    1384/* TODO: Verify this on multi-monitor Win32 systems. */
    +
    1385#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
    +
    1386#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
    +
    1387
    +
    1388#define main( argc, argv ) retroflat_main( argc, argv )
    +
    1389
    +
    1390/* Improvise a rough WinMain to call main(). */
    +
    1391#define END_OF_MAIN() \
    +
    1392 int WINXAPI WinMain( \
    +
    1393 HINSTANCE hInstance, HINSTANCE hPrevInstance, \
    +
    1394 LPSTR lpCmdLine, int nCmdShow \
    +
    1395 ) { \
    +
    1396 LPSTR* rf_argv = NULL; \
    +
    1397 int rf_argc = 0; \
    +
    1398 int retval = 0; \
    +
    1399 g_retroflat_instance = hInstance; \
    +
    1400 g_retroflat_cmd_show = nCmdShow; \
    +
    1401 rf_argv = retroflat_win_cli( lpCmdLine, &rf_argc ); \
    +
    1402 retval = retroflat_main( rf_argc, rf_argv ); \
    +
    1403 free( rf_argv ); \
    +
    1404 return retval; \
    +
    1405 }
    +
    1406
    +
    1407/* Convenience macro for auto-locking inside of draw functions. */
    +
    1408/* TODO: Use maug_cleanup and assume retval. */
    +
    1409#define retroflat_internal_autolock_bitmap( bmp, lock_auto ) \
    +
    1410 if( !retroflat_bitmap_locked( bmp ) ) { \
    +
    1411 retval = retroflat_draw_lock( bmp ); \
    +
    1412 maug_cleanup_if_not_ok(); \
    +
    1413 lock_auto = 1; \
    +
    1414 }
    +
    1415
    +
    1416#elif defined( RETROFLAT_API_LIBNDS )
    +
    1417
    +
    1418/* == Nintendo DS == */
    +
    1419
    +
    1420# include <nds.h>
    +
    1421
    +
    1422/* NDS doesn't have primitives. */
    +
    1423# ifndef RETROFLAT_SOFT_SHAPES
    +
    1424# define RETROFLAT_SOFT_SHAPES
    +
    1425# endif /* !RETROFLAT_SOFT_SHAPES */
    +
    1426
    +
    1427# define BG_TILE_W_PX 8
    +
    1428# define BG_TILE_H_PX 8
    +
    1429# define BG_W_TILES 32
    +
    1430
    +
    1431typedef void* RETROFLAT_CONFIG;
    +
    1432
    +
    1433struct RETROFLAT_BITMAP {
    +
    1434 size_t sz;
    +
    1435 uint8_t flags;
    +
    1436 uint16_t* b;
    +
    1437# ifdef RETROFLAT_OPENGL
    +
    1438 struct RETROFLAT_GLTEX tex;
    +
    1439 ssize_t w;
    +
    1440 ssize_t h;
    +
    1441# endif /* RETROFLAT_OPENGL */
    +
    1442};
    +
    1443
    +
    1444typedef int RETROFLAT_COLOR_DEF;
    +
    1445
    +
    1446# ifdef RETROFLAT_NDS_WASD
    +
    1447# define RETROFLAT_KEY_A KEY_LEFT
    +
    1448# define RETROFLAT_KEY_D KEY_RIGHT
    +
    1449# define RETROFLAT_KEY_W KEY_UP
    +
    1450# define RETROFLAT_KEY_S KEY_DOWN
    +
    1451# else
    +
    1452# define RETROFLAT_KEY_LEFT KEY_LEFT
    +
    1453# define RETROFLAT_KEY_RIGHT KEY_RIGHT
    +
    1454# define RETROFLAT_KEY_UP KEY_UP
    +
    1455# define RETROFLAT_KEY_DOWN KEY_DOWN
    +
    1456# endif /* RETROFLAT_NDS_WASD */
    +
    1457# define RETROFLAT_KEY_ENTER KEY_START
    +
    1458# define RETROFLAT_KEY_SPACE KEY_A
    +
    1459# define RETROFLAT_KEY_ESC KEY_B
    +
    1460# define RETROFLAT_MOUSE_B_LEFT (-1)
    +
    1461# define RETROFLAT_MOUSE_B_RIGHT (-2)
    +
    1462
    +
    1463/* TODO */
    +
    1464# define retroflat_bitmap_locked( bmp ) (0)
    +
    1465# define retroflat_px_lock( bmp )
    +
    1466# define retroflat_px_release( bmp )
    +
    1467
    +
    1468# define retroflat_screen_w() (256)
    +
    1469# define retroflat_screen_h() (192)
    +
    1470# define retroflat_screen_buffer() (&(g_retroflat_state->buffer))
    +
    1471
    +
    1472# define END_OF_MAIN()
    +
    1473
    +
    1474/* TODO? */
    +
    1475# define retroflat_quit( retval_in )
    +
    1476# define retroflat_bitmap_w( bmp ) (0)
    +
    1477# define retroflat_bitmap_h( bmp ) (0)
    +
    1478# define retroflat_bitmap_ok( bitmap ) (0)
    +
    1479
    +
    1480#elif defined( RETROFLAT_API_GLUT )
    +
    1481
    +
    1482#ifndef RETROFLAT_OPENGL
    +
    1483# error "RETROFLAT_API_GLUT specified without RETROFLAT_OPENGL!"
    +
    1484# define RETROFLAT_OPENGL
    +
    1485#endif /* !RETROFLAT_OPENGL */
    +
    1486
    +
    1487#include <GL/glut.h>
    +
    1488
    +
    1489# ifndef RETROFLAT_CONFIG_USE_FILE
    +
    1490# define RETROFLAT_CONFIG_USE_FILE
    +
    1491# endif /* !RETROFLAT_CONFIG_USE_FILE */
    +
    1492
    +
    1493typedef FILE* RETROFLAT_CONFIG;
    +
    1494
    +
    1495typedef float MAUG_CONST* RETROFLAT_COLOR_DEF;
    +
    1496
    +
    1497struct RETROFLAT_BITMAP {
    +
    1498 size_t sz;
    +
    1499 uint8_t flags;
    +
    1500 struct RETROFLAT_GLTEX tex;
    +
    1501 ssize_t w;
    +
    1502 ssize_t h;
    +
    1503};
    +
    1504
    +
    1505# define retroflat_bitmap_ok( bitmap ) (NULL != (bitmap)->b)
    +
    1506# define retroflat_bitmap_locked( bmp ) 0
    +
    1507/* TODO */
    +
    1508# define retroflat_bitmap_w( bmp ) (0)
    +
    1509# define retroflat_bitmap_h( bmp ) (0)
    +
    1510
    +
    1512# define retroflat_px_lock( bmp )
    +
    1513# define retroflat_px_release( bmp )
    +
    1514# define retroflat_screen_w() (g_retroflat_state->screen_v_w)
    +
    1515# define retroflat_screen_h() (g_retroflat_state->screen_v_h)
    +
    1516# define retroflat_screen_buffer() (&(g_retroflat_state->buffer))
    +
    1517# define retroflat_quit( retval_in ) glutDestroyWindow( glutGetWindow() )
    +
    1518# define END_OF_MAIN()
    +
    1519
    +
    1520# define GLUT_SPECIAL_KEY_OFFSET 0x80
    +
    1521
    +
    1522# define RETROFLAT_KEY_UP (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_UP)
    +
    1523# define RETROFLAT_KEY_DOWN (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_DOWN)
    +
    1524# define RETROFLAT_KEY_RIGHT (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_RIGHT)
    +
    1525# define RETROFLAT_KEY_LEFT (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_LEFT)
    +
    1526# define RETROFLAT_KEY_HOME (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_HOME)
    +
    1527# define RETROFLAT_KEY_END (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_END)
    +
    1528# define RETROFLAT_KEY_PGUP (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_PAGE_UP)
    +
    1529# define RETROFLAT_KEY_PGDN \
    +
    1530 (GLUT_SPECIAL_KEY_OFFSET + GLUT_KEY_PAGE_DOWN)
    +
    1531# define RETROFLAT_KEY_DELETE 0x7f
    +
    1532# define RETROFLAT_KEY_ESC 0x1b
    +
    1533# define RETROFLAT_KEY_ENTER 0x0d
    +
    1534# define RETROFLAT_KEY_TAB '\t'
    +
    1535# define RETROFLAT_KEY_SPACE ' '
    +
    1536# define RETROFLAT_KEY_GRAVE '`'
    +
    1537# define RETROFLAT_KEY_SLASH '/'
    +
    1538# define RETROFLAT_KEY_BKSP 0x08
    +
    1539# define RETROFLAT_KEY_SEMICOLON ';'
    +
    1540# define RETROFLAT_KEY_PERIOD '.'
    +
    1541# define RETROFLAT_KEY_COMMA ','
    +
    1542# define RETROFLAT_KEY_EQUALS '='
    +
    1543# define RETROFLAT_KEY_DASH '-'
    +
    1544# define RETROFLAT_KEY_A 'a'
    +
    1545# define RETROFLAT_KEY_B 'b'
    +
    1546# define RETROFLAT_KEY_C 'c'
    +
    1547# define RETROFLAT_KEY_D 'd'
    +
    1548# define RETROFLAT_KEY_E 'e'
    +
    1549# define RETROFLAT_KEY_F 'f'
    +
    1550# define RETROFLAT_KEY_G 'g'
    +
    1551# define RETROFLAT_KEY_H 'h'
    +
    1552# define RETROFLAT_KEY_I 'i'
    +
    1553# define RETROFLAT_KEY_J 'j'
    +
    1554# define RETROFLAT_KEY_K 'k'
    +
    1555# define RETROFLAT_KEY_L 'l'
    +
    1556# define RETROFLAT_KEY_M 'm'
    +
    1557# define RETROFLAT_KEY_N 'n'
    +
    1558# define RETROFLAT_KEY_O 'o'
    +
    1559# define RETROFLAT_KEY_P 'p'
    +
    1560# define RETROFLAT_KEY_Q 'q'
    +
    1561# define RETROFLAT_KEY_R 'r'
    +
    1562# define RETROFLAT_KEY_S 's'
    +
    1563# define RETROFLAT_KEY_T 't'
    +
    1564# define RETROFLAT_KEY_U 'u'
    +
    1565# define RETROFLAT_KEY_V 'v'
    +
    1566# define RETROFLAT_KEY_W 'w'
    +
    1567# define RETROFLAT_KEY_X 'x'
    +
    1568# define RETROFLAT_KEY_Y 'y'
    +
    1569# define RETROFLAT_KEY_Z 'z'
    +
    1570# define RETROFLAT_KEY_0 '0'
    +
    1571# define RETROFLAT_KEY_1 '1'
    +
    1572# define RETROFLAT_KEY_2 '2'
    +
    1573# define RETROFLAT_KEY_3 '3'
    +
    1574# define RETROFLAT_KEY_4 '4'
    +
    1575# define RETROFLAT_KEY_5 '5'
    +
    1576# define RETROFLAT_KEY_6 '6'
    +
    1577# define RETROFLAT_KEY_7 '7'
    +
    1578# define RETROFLAT_KEY_8 '8'
    +
    1579# define RETROFLAT_KEY_9 '9'
    +
    1580
    +
    1581#else
    +
    1582# warning "not implemented"
    +
    1583
    +
    1595typedef FILE* RETROFLAT_CONFIG;
    +
    1596 /* maug_retroflt_config */
    +
    1598
    + +
    1612 size_t sz;
    +
    1614 uint8_t flags;
    +
    1615 struct RETROFLAT_GLTEX tex;
    +
    1616};
    +
    1617
    +
    1619# define retroflat_bitmap_ok( bitmap ) (NULL != (bitmap)->b)
    +
    1620 /* maug_retroflt_bitmap */
    +
    1622
    +
    1624# define retroflat_screen_w()
    +
    1625
    +
    1627# define retroflat_screen_h()
    +
    1628
    +
    1630# define retroflat_screen_buffer() (&(g_retroflat_state->buffer))
    +
    1631
    +
    1636# define retroflat_quit( retval_in )
    +
    1637
    +
    1651typedef int RETROFLAT_COLOR_DEF;
    +
    1652
    +
    1653# define RETROFLAT_COLOR_BLACK 0
    +
    1654# define RETROFLAT_COLOR_DARKBLUE 1
    +
    1655# define RETROFLAT_COLOR_DARKGREEN 2
    +
    1656# define RETROFLAT_COLOR_TEAL 3
    +
    1657# define RETROFLAT_COLOR_DARKRED 4
    +
    1658# define RETROFLAT_COLOR_VIOLET 5
    +
    1659# define RETROFLAT_COLOR_BROWN 6
    +
    1660# define RETROFLAT_COLOR_GRAY 7
    +
    1661# define RETROFLAT_COLOR_DARKGRAY 8
    +
    1662# define RETROFLAT_COLOR_BLUE 9
    +
    1663# define RETROFLAT_COLOR_GREEN 10
    +
    1664# define RETROFLAT_COLOR_CYAN 11
    +
    1665# define RETROFLAT_COLOR_RED 12
    +
    1666# define RETROFLAT_COLOR_MAGENTA 13
    +
    1667# define RETROFLAT_COLOR_YELLOW 14
    +
    1668# define RETROFLAT_COLOR_WHITE 15
    +
    1669 /* maug_retroflt_color */
    +
    1671 /* maug_retroflt_drawing */
    +
    1673
    +
    1687# define RETROFLAT_KEY_UP 0
    +
    1688# define RETROFLAT_KEY_DOWN 0
    +
    1689# define RETROFLAT_KEY_RIGHT 0
    +
    1690# define RETROFLAT_KEY_LEFT 0
    +
    1691# define RETROFLAT_KEY_A 0x41
    +
    1692# define RETROFLAT_KEY_B 0x42
    +
    1693# define RETROFLAT_KEY_C 0x43
    +
    1694# define RETROFLAT_KEY_D 0x44
    +
    1695# define RETROFLAT_KEY_E 0x45
    +
    1696# define RETROFLAT_KEY_F 0x46
    +
    1697# define RETROFLAT_KEY_G 0x47
    +
    1698# define RETROFLAT_KEY_H 0x48
    +
    1699# define RETROFLAT_KEY_I 0x49
    +
    1700# define RETROFLAT_KEY_J 0x4a
    +
    1701# define RETROFLAT_KEY_K 0x4b
    +
    1702# define RETROFLAT_KEY_L 0x4c
    +
    1703# define RETROFLAT_KEY_M 0x4d
    +
    1704# define RETROFLAT_KEY_N 0x4e
    +
    1705# define RETROFLAT_KEY_O 0x4f
    +
    1706# define RETROFLAT_KEY_P 0x50
    +
    1707# define RETROFLAT_KEY_Q 0x51
    +
    1708# define RETROFLAT_KEY_R 0x52
    +
    1709# define RETROFLAT_KEY_S 0x53
    +
    1710# define RETROFLAT_KEY_T 0x54
    +
    1711# define RETROFLAT_KEY_U 0x55
    +
    1712# define RETROFLAT_KEY_V 0x56
    +
    1713# define RETROFLAT_KEY_W 0x57
    +
    1714# define RETROFLAT_KEY_X 0x58
    +
    1715# define RETROFLAT_KEY_Y 0x59
    +
    1716# define RETROFLAT_KEY_Z 0x60
    +
    1717# define RETROFLAT_KEY_0 0x30
    +
    1718# define RETROFLAT_KEY_1 0x31
    +
    1719# define RETROFLAT_KEY_2 0x32
    +
    1720# define RETROFLAT_KEY_3 0x33
    +
    1721# define RETROFLAT_KEY_4 0x34
    +
    1722# define RETROFLAT_KEY_5 0x35
    +
    1723# define RETROFLAT_KEY_6 0x36
    +
    1724# define RETROFLAT_KEY_7 0x37
    +
    1725# define RETROFLAT_KEY_8 0x38
    +
    1726# define RETROFLAT_KEY_9 0x39
    +
    1727# define RETROFLAT_KEY_TAB 0
    +
    1728# define RETROFLAT_KEY_SPACE 0
    +
    1729# define RETROFLAT_KEY_ESC 0
    +
    1730# define RETROFLAT_KEY_ENTER 0
    +
    1731# define RETROFLAT_KEY_HOME 0
    +
    1732# define RETROFLAT_KEY_END 0
    +
    1733
    +
    1734# define RETROFLAT_MOUSE_B_LEFT 0
    +
    1735# define RETROFLAT_MOUSE_B_RIGHT 0
    +
    1736 /* maug_retroflt_keydefs */
    +
    1738 /* maug_retroflt_input */
    +
    1740
    +
    1741#endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    1742
    +
    1743/* OpenGL can be called from several different APIs. */
    +
    1744# if defined( RETROFLAT_OPENGL ) && !defined( RETROFLAT_API_LIBNDS )
    +
    1745# include <GL/gl.h>
    +
    1746# include <GL/glu.h>
    +
    1747# endif /* RETROFLAT_OPENGL */
    +
    1748
    +
    1749/* === Structures === */
    +
    1750
    + +
    1757 char* title;
    + + + +
    1764 uint8_t flags;
    + +
    1767};
    +
    1768
    + +
    1771 void* loop_data;
    +
    1772 MERROR_RETVAL retval;
    + +
    1775 char config_path[RETROFLAT_PATH_MAX + 1];
    +
    1776 char assets_path[RETROFLAT_ASSETS_PATH_MAX + 1];
    +
    1778 RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ];
    + +
    1781
    + +
    1787#ifdef RETROFLAT_OS_WIN
    +
    1788 HMODULE vdp_exe;
    +
    1789#else
    +
    1791 void* vdp_exe;
    +
    1792#endif /* RETROFLAT_OS_WIN */
    + + +
    1798 uint8_t vdp_flags;
    +
    1799
    +
    1800 /* These are used by VDP so should be standardized/not put in plat-spec! */
    +
    1801 int screen_v_w;
    +
    1802 int screen_v_h;
    +
    1803 int screen_w;
    +
    1804 int screen_h;
    +
    1805
    +
    1806 /* TODO: Put these in a platform-specific struct of some kind to maintain
    +
    1807 * consistent state struct size for VDP?
    +
    1808 */
    +
    1809
    +
    1810#if defined( RETROFLAT_OPENGL )
    +
    1811 uint8_t tex_palette[RETROFLAT_COLORS_SZ][3];
    +
    1812#endif /* RETROFLAT_OPENGL */
    +
    1813
    +
    1814#if defined( RETROFLAT_API_ALLEGRO )
    +
    1815
    +
    1816# ifdef RETROFLAT_OS_DOS
    +
    1817 unsigned int last_mouse;
    +
    1818 unsigned int last_mouse_x;
    +
    1819 unsigned int last_mouse_y;
    +
    1820# endif /* RETROFLAT_OS_DOS */
    +
    1821 unsigned int close_button;
    +
    1822 unsigned long ms;
    +
    1823
    +
    1824#elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    1825
    +
    1826# ifndef RETROFLAT_API_SDL1
    +
    1827 SDL_Window* window;
    +
    1828# endif /* !RETROFLAT_API_SDL1 */
    +
    1829 int mouse_state;
    +
    1830
    +
    1831#elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    1832
    +
    1833 HWND window;
    +
    1834 int16_t last_idc; /* Last clicked button. */
    +
    1835# ifdef RETROFLAT_SCREENSAVER
    +
    1836 HWND parent;
    +
    1837# endif /* RETROFLAT_SCREENSAVER */
    +
    1838 MSG msg;
    +
    1839 HDC hdc_win;
    +
    1840# ifdef RETROFLAT_OPENGL
    +
    1841 HGLRC hrc_win;
    +
    1842# endif /* RETROFLAT_OPENGL */
    +
    1843 int msg_retval;
    +
    1844 uint8_t last_key;
    +
    1845 uint8_t vk_mods;
    +
    1846 unsigned int last_mouse;
    +
    1847 unsigned int last_mouse_x;
    +
    1848 unsigned int last_mouse_y;
    +
    1849 retroflat_loop_iter loop_iter;
    +
    1850
    +
    1851#elif defined( RETROFLAT_API_LIBNDS )
    +
    1852
    +
    1853 uint16_t* sprite_frames[NDS_SPRITES_ACTIVE];
    +
    1854 int bg_id;
    +
    1855 uint8_t bg_bmp_changed;
    +
    1856 uint8_t window_bmp_changed;
    +
    1857 int window_id;
    +
    1858 int px_id;
    +
    1859 uint16_t bg_tiles[1024];
    +
    1860 uint16_t window_tiles[1024];
    +
    1861
    +
    1862# elif defined( RETROFLAT_API_GLUT )
    +
    1863
    +
    1864 size_t retroflat_next;
    +
    1865 retroflat_loop_iter loop_iter;
    +
    1866 int16_t retroflat_last_key;
    +
    1867
    +
    1868# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    1869
    +
    1870};
    +
    1871
    +
    1872/* === Translation Module === */
    +
    1873
    +
    1874/* Declare the prototypes so that internal functions can call each other. */
    +
    1875
    + +
    1882
    + +
    1890 uint8_t flags, const char* title, const char* format, ... );
    +
    1891
    +
    1899MERROR_RETVAL retroflat_init( int argc, char* argv[], struct RETROFLAT_ARGS* args );
    +
    1900
    +
    1907void retroflat_shutdown( int retval );
    +
    1908
    +
    1909# ifdef RETROFLAT_VDP
    +
    1910MERROR_RETVAL retroflat_vdp_call( const char* proc_name );
    +
    1911# endif /* RETROFLAT_VDP */
    +
    1912
    +
    1913void retroflat_set_title( const char* format, ... );
    +
    1914
    +
    1915uint32_t retroflat_get_ms();
    +
    1916
    +
    1917uint32_t retroflat_get_rand();
    +
    1918
    +
    1919#define retroflat_opengl_push( x, y, x_f, y_f, aspect_f ) \
    +
    1920 /* Switch to projection setup. */ \
    +
    1921 glMatrixMode( GL_PROJECTION ); \
    +
    1922 glPushMatrix(); \
    +
    1923 /* Lighting makes overlay text hard to see. */ \
    +
    1924 glDisable( GL_LIGHTING ); \
    +
    1925 /* Use ortho for overlay. */ \
    +
    1926 glLoadIdentity(); \
    +
    1927 aspect_f = (float)retroflat_screen_w() / (float)retroflat_screen_h(); \
    +
    1928 glOrtho( -1.0f * aspect_f, aspect_f, -1.0f, 1.0f, 0, 10.0f ); \
    +
    1929 /* -1 to 1 is 2! */ \
    +
    1930 aspect_f *= 2.0f; \
    +
    1931 /* Assuming width > height for aspect ratio. */ \
    +
    1932 x_f = ((x) * aspect_f / retroflat_screen_w()) - (aspect_f / 2); \
    +
    1933 /* Vertical coords also need to be inverted because OpenGL. */ \
    +
    1934 y_f = 1.0f - ((y) * 2.0f / retroflat_screen_h()); \
    +
    1935
    +
    1936#define retroflat_opengl_whf( w, h, w_f, h_f, aspect_f ) \
    +
    1937 w_f = ((w) * aspect_f / retroflat_screen_w()); \
    +
    1938 h_f = ((h) * 2.0f / retroflat_screen_h());
    +
    1939
    +
    1940#define retroflat_opengl_pop() \
    +
    1941 /* Restore modelview. */ \
    +
    1942 glPopMatrix(); \
    +
    1943 glMatrixMode( GL_MODELVIEW );
    +
    1944
    + +
    1961 const char* filename, struct RETROFLAT_BITMAP* bmp_out );
    +
    1962
    +
    1963MERROR_RETVAL retroflat_create_bitmap(
    +
    1964 size_t w, size_t h, struct RETROFLAT_BITMAP* bmp_out, uint8_t flags );
    +
    1965
    +
    1966#if defined( RETROFLAT_XPM ) || defined( DOCUMENTATION )
    +
    1967
    + +
    1974 const char* filename, struct RETROFLAT_BITMAP* bmp_out );
    +
    1975
    +
    1976#endif /* RETROFLAT_XPM || defined( DOCUMENTATION ) */
    +
    1977
    + +
    1984
    + +
    1999 struct RETROFLAT_BITMAP* target, struct RETROFLAT_BITMAP* src,
    +
    2000 int s_x, int s_y, int d_x, int d_y, int w, int h );
    +
    2001 /* maug_retroflt_bitmap */
    +
    2003
    + +
    2019
    +
    2020MERROR_RETVAL retroflat_draw_release( struct RETROFLAT_BITMAP* bmp );
    +
    2021
    +
    2022void retroflat_px(
    +
    2023 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    2024 int x, int y, uint8_t flags );
    +
    2025
    + +
    2037 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    2038 int x, int y, int w, int h, uint8_t flags );
    +
    2039
    + +
    2051 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    2052 int x, int y, int w, int h, uint8_t flags );
    +
    2053
    + +
    2066 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    2067 int x1, int y1, int x2, int y2, uint8_t flags );
    +
    2068
    +
    2069void retroflat_cursor( struct RETROFLAT_BITMAP* target, uint8_t flags );
    +
    2070
    + +
    2084 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
    +
    2085 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags );
    +
    2086
    + +
    2105 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    2106 const char* str, int str_sz, const char* font_str, int x_orig, int y_orig,
    +
    2107 uint8_t flags );
    +
    2108 /* maug_retroflt_bitmap */
    +
    2110
    + +
    2122 /* maug_retroflt_input */
    +
    2124
    + +
    2136
    +
    2137void retroflat_config_close( RETROFLAT_CONFIG* config );
    +
    2138
    + +
    2147 RETROFLAT_CONFIG* config,
    +
    2148 const char* sect_name, const char* key_name, uint8_t buffer_type,
    +
    2149 void* buffer, size_t buffer_sz_max );
    +
    2150
    + +
    2159 RETROFLAT_CONFIG* config,
    +
    2160 const char* sect_name, const char* key_name, uint8_t buffer_type,
    +
    2161 void* buffer_out, size_t buffer_out_sz_max,
    +
    2162 const void* default_out, size_t default_out_sz );
    +
    2163 /* maug_retroflt_config */
    +
    2165
    +
    2166#ifdef RETROFLT_C
    +
    2167
    +
    2168MAUG_MHANDLE g_retroflat_state_h = (MAUG_MHANDLE)NULL;
    +
    2169struct RETROFLAT_STATE* g_retroflat_state = NULL;
    +
    2170
    +
    2171#define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b ) \
    +
    2172 MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u = idx;
    +
    2173
    +
    2174RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_CONSTS )
    +
    2175
    +
    2176#define RETROFLAT_COLOR_TABLE_NAMES( idx, name_l, name_u, r, g, b ) \
    +
    2177 #name_u,
    +
    2178
    +
    2179MAUG_CONST char* gc_retroflat_color_names[] = {
    +
    2180 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_NAMES )
    +
    2181};
    +
    2182
    +
    2183# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2184/* For now, these are set by WinMain(), so they need to be outside of the
    +
    2185 * state that's zeroed on init()!
    +
    2186 */
    +
    2187HINSTANCE g_retroflat_instance;
    +
    2188int g_retroflat_cmd_show;
    +
    2189
    +
    2190# ifdef RETROFLAT_WING
    +
    2191struct RETROFLAT_WING_MODULE g_w;
    +
    2192# endif /* RETROFLAT_WING */
    +
    2193# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    2194
    +
    2195# include <stdio.h>
    +
    2196# include <stdlib.h>
    +
    2197# include <string.h>
    +
    2198
    +
    2199/* Callback table is down below, after the statically-defined callbacks. */
    +
    2200
    +
    2201/* === Function Definitions === */
    +
    2202
    +
    2203# if defined( RETROFLAT_SOFT_SHAPES ) && !defined( MAUG_NO_AUTO_C )
    +
    2204# define RETROFP_C
    +
    2205# include <retrofp.h>
    +
    2206# define RETROSFT_C
    +
    2207# include <retrosft.h>
    +
    2208# endif /* RETROFLAT_SOFT_SHAPES */
    +
    2209
    +
    2210# if defined( RETROFLAT_OPENGL ) && !defined( MAUG_NO_AUTO_C )
    +
    2211# define RETROGLU_C
    +
    2212# include <retroglu.h>
    +
    2213# define RETROFP_C
    +
    2214# include <retrofp.h>
    +
    2215# define RETROSFT_C
    +
    2216# include <retrosft.h>
    +
    2217# endif /* RETROFLAT_OPENGL */
    +
    2218
    +
    2219# if defined( RETROFLAT_VDP ) && defined( RETROFLAT_OS_UNIX )
    +
    2220# include <dlfcn.h>
    +
    2221# endif
    +
    2222
    +
    2223# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2224
    +
    2225static LRESULT CALLBACK WndProc(
    +
    2226 HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
    +
    2227) {
    +
    2228 PAINTSTRUCT ps;
    +
    2229# ifndef RETROFLAT_OPENGL
    +
    2230 HDC hdc_paint = (HDC)NULL;
    +
    2231# endif /* !RETROFLAT_OPENGL */
    +
    2232# if defined( RETROFLAT_OPENGL )
    +
    2233 int pixel_fmt_int = 0;
    +
    2234 static PIXELFORMATDESCRIPTOR pixel_fmt = {
    +
    2235 sizeof( PIXELFORMATDESCRIPTOR ),
    +
    2236 1,
    +
    2237 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
    +
    2238 PFD_TYPE_RGBA,
    +
    2239 RETROFLAT_OPENGL_BPP,
    +
    2240 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    +
    2241 16,
    +
    2242 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
    +
    2243 };
    +
    2244# endif /* RETROFLAT_OPENGL */
    +
    2245
    +
    2246 switch( message ) {
    +
    2247 case WM_CREATE:
    +
    2248
    +
    2249 g_retroflat_state->hdc_win = GetDC( hWnd );
    +
    2250
    +
    2251# if defined( RETROFLAT_OPENGL )
    +
    2252
    +
    2253 pixel_fmt_int =
    +
    2254 ChoosePixelFormat( g_retroflat_state->hdc_win, &pixel_fmt );
    +
    2255 SetPixelFormat(
    +
    2256 g_retroflat_state->hdc_win, pixel_fmt_int, &pixel_fmt );
    +
    2257
    +
    2258 debug_printf( 1, "setting up OpenGL context..." );
    +
    2259
    +
    2260 g_retroflat_state->hrc_win =
    +
    2261 wglCreateContext( g_retroflat_state->hdc_win );
    +
    2262 if(
    +
    2263 FALSE == wglMakeCurrent( g_retroflat_state->hdc_win,
    +
    2264 g_retroflat_state->hrc_win )
    +
    2265 ) {
    +
    2266 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2267 "Error", "Error creating OpenGL context: %d",
    +
    2268 GetLastError() );
    +
    2269 }
    +
    2270
    +
    2271# else
    +
    2272
    +
    2273 /* Setup the screen buffer. */
    +
    2274 if( !retroflat_bitmap_ok( &(g_retroflat_state->buffer) ) ) {
    +
    2275 debug_printf( 1, "retroflat: creating window buffer (%d x %d)...",
    +
    2276 g_retroflat_state->screen_w, g_retroflat_state->screen_h );
    +
    2277 /* Do this in its own function so a one-time setup isn't using stack
    +
    2278 * in our WndProc!
    +
    2279 */
    +
    2280 retroflat_create_bitmap(
    +
    2281 g_retroflat_state->screen_w,
    +
    2282 g_retroflat_state->screen_h,
    +
    2283 &(g_retroflat_state->buffer),
    + +
    2285 if( (HDC)NULL == g_retroflat_state->buffer.hdc_b ) {
    +
    2286 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2287 "Error", "Could not determine buffer device context!" );
    +
    2288 g_retroflat_state->retval = RETROFLAT_ERROR_GRAPHICS;
    +
    2289 retroflat_quit( g_retroflat_state->retval );
    +
    2290 break;
    +
    2291 }
    +
    2292
    +
    2293 }
    +
    2294 if( !retroflat_bitmap_ok( &(g_retroflat_state->buffer) ) ) {
    +
    2295 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2296 "Error", "Could not create screen buffer!" );
    +
    2297 g_retroflat_state->retval = RETROFLAT_ERROR_GRAPHICS;
    +
    2298 retroflat_quit( g_retroflat_state->retval );
    +
    2299 break;
    +
    2300 }
    +
    2301
    +
    2302# endif /* RETROFLAT_OPENGL */
    +
    2303 break;
    +
    2304
    +
    2305 case WM_CLOSE:
    +
    2306# if defined( RETROFLAT_OPENGL )
    +
    2307 wglMakeCurrent( g_retroflat_state->hdc_win, NULL );
    +
    2308 wglDeleteContext( g_retroflat_state->hrc_win );
    +
    2309# endif /* RETROFLAT_OPENGL */
    +
    2310
    +
    2311 /* Quit on window close. */
    +
    2312 retroflat_quit( 0 );
    +
    2313 break;
    +
    2314
    +
    2315# if !defined( RETROFLAT_OPENGL )
    +
    2316 case WM_PAINT:
    +
    2317
    +
    2318 if( !retroflat_bitmap_ok( &(g_retroflat_state->buffer) ) ) {
    +
    2319 error_printf( "screen buffer not ready!" );
    +
    2320 break;
    +
    2321 }
    +
    2322
    +
    2323 /* Create HDC for window to blit to. */
    +
    2324 /* maug_mzero( &ps, sizeof( PAINTSTRUCT ) ); */
    +
    2325 hdc_paint = BeginPaint( hWnd, &ps );
    +
    2326 if( (HDC)NULL == hdc_paint ) {
    +
    2327 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2328 "Error", "Could not determine window device context!" );
    +
    2329 g_retroflat_state->retval = RETROFLAT_ERROR_GRAPHICS;
    +
    2330 retroflat_quit( g_retroflat_state->retval );
    +
    2331 break;
    +
    2332 }
    +
    2333
    +
    2334# if defined( RETROFLAT_VDP )
    +
    2335 retroflat_vdp_call( "retroflat_vdp_flip" );
    +
    2336# endif /* RETROFLAT_VDP */
    +
    2337
    +
    2338# ifdef RETROFLAT_WING
    +
    2339 if( (WinGStretchBlt_t)NULL != g_w.WinGStretchBlt ) {
    +
    2340 g_w.WinGStretchBlt(
    +
    2341 hdc_paint,
    +
    2342 0, 0,
    +
    2343 g_retroflat_state->screen_w, g_retroflat_state->screen_h,
    +
    2344 g_retroflat_state->buffer.hdc_b,
    +
    2345 0, 0,
    +
    2346 g_retroflat_state->screen_w,
    +
    2347 g_retroflat_state->screen_h
    +
    2348 );
    +
    2349# ifdef RETROFLAT_API_WIN32
    +
    2350 GdiFlush();
    +
    2351# endif /* RETROFLAT_API_WIN32 */
    +
    2352 } else {
    +
    2353# endif /* RETROFLAT_WING */
    +
    2354 StretchBlt(
    +
    2355 hdc_paint,
    +
    2356 0, 0,
    +
    2357 g_retroflat_state->screen_w, g_retroflat_state->screen_h,
    +
    2358 g_retroflat_state->buffer.hdc_b,
    +
    2359 0, 0,
    +
    2360 g_retroflat_state->screen_w,
    +
    2361 g_retroflat_state->screen_h,
    +
    2362 SRCCOPY
    +
    2363 );
    +
    2364# ifdef RETROFLAT_WING
    +
    2365 }
    +
    2366# endif /* RETROFLAT_WING */
    +
    2367
    +
    2368 DeleteDC( hdc_paint );
    +
    2369 EndPaint( hWnd, &ps );
    +
    2370 break;
    +
    2371
    +
    2372# endif /* !RETROFLAT_OPENGL */
    +
    2373
    +
    2374 case WM_ERASEBKGND:
    +
    2375 return 1;
    +
    2376
    +
    2377 case WM_KEYDOWN:
    +
    2378 switch( wParam ) {
    +
    2379 case VK_SHIFT:
    +
    2380 g_retroflat_state->vk_mods |= RETROFLAT_INPUT_MOD_SHIFT;
    +
    2381 break;
    +
    2382
    +
    2383 case VK_CONTROL:
    +
    2384 g_retroflat_state->vk_mods |= RETROFLAT_INPUT_MOD_CTRL;
    +
    2385 break;
    +
    2386
    +
    2387 /* TODO: Alt? */
    +
    2388
    +
    2389 default:
    +
    2390 g_retroflat_state->last_key = wParam;
    +
    2391 break;
    +
    2392 }
    +
    2393 break;
    +
    2394
    +
    2395 case WM_KEYUP:
    +
    2396 switch( wParam ) {
    +
    2397 case VK_SHIFT:
    +
    2398 g_retroflat_state->vk_mods &= ~RETROFLAT_INPUT_MOD_SHIFT;
    +
    2399 break;
    +
    2400
    +
    2401 case VK_CONTROL:
    +
    2402 g_retroflat_state->vk_mods |= RETROFLAT_INPUT_MOD_CTRL;
    +
    2403 break;
    +
    2404
    +
    2405 /* TODO: Alt? */
    +
    2406
    +
    2407 }
    +
    2408 break;
    +
    2409
    +
    2410 case WM_LBUTTONDOWN:
    +
    2411 case WM_RBUTTONDOWN:
    +
    2412 g_retroflat_state->last_mouse = wParam;
    +
    2413 g_retroflat_state->last_mouse_x = GET_X_LPARAM( lParam );
    +
    2414 g_retroflat_state->last_mouse_y = GET_Y_LPARAM( lParam );
    +
    2415 break;
    +
    2416
    +
    2417 case WM_DESTROY:
    +
    2418 if( retroflat_bitmap_ok( &(g_retroflat_state->buffer) ) ) {
    +
    2419 DeleteObject( g_retroflat_state->buffer.b );
    +
    2420 }
    +
    2421 PostQuitMessage( 0 );
    +
    2422 break;
    +
    2423
    +
    2424 case WM_SIZE:
    +
    2425 retroflat_on_resize( LOWORD( lParam ), HIWORD( lParam ) );
    +
    2426 break;
    +
    2427
    +
    2428 case WM_TIMER:
    +
    2429 if(
    +
    2430# ifdef RETROFLAT_OPENGL
    +
    2431 (HGLRC)NULL == g_retroflat_state->hrc_win ||
    +
    2432# else
    +
    2433 !retroflat_bitmap_ok( &(g_retroflat_state->buffer) ) ||
    +
    2434# endif /* !RETROFLAT_OPENGL */
    +
    2435 hWnd != g_retroflat_state->window ||
    +
    2436 NULL == g_retroflat_state->loop_iter
    +
    2437 ) {
    +
    2438 /* Timer message was called prematurely. */
    +
    2439 break;
    +
    2440 }
    +
    2441
    +
    2442 g_retroflat_state->loop_iter( g_retroflat_state->loop_data );
    +
    2443 break;
    +
    2444
    +
    2445 case WM_COMMAND:
    +
    2446 g_retroflat_state->last_idc = LOWORD( wParam );
    +
    2447 break;
    +
    2448
    +
    2449 default:
    +
    2450 return DefWindowProc( hWnd, message, wParam, lParam );
    +
    2451 }
    +
    2452
    +
    2453 return 0;
    +
    2454}
    +
    2455
    +
    2456LPSTR* retroflat_win_cli( LPSTR cmd_line, int* argc_out ) {
    +
    2457 LPSTR* argv_out = NULL;
    +
    2458 int i = 0,
    +
    2459 arg_iter = 0,
    +
    2460 arg_start = 0,
    +
    2461 arg_idx = 0,
    +
    2462 arg_longest = 10; /* Program name. */
    +
    2463 MERROR_RETVAL retval = MERROR_OK;
    +
    2464
    +
    2465 /* This uses calloc() to simplify things, since this works on Windows, the
    +
    2466 * only platform where this routine is used, anyway. */
    +
    2467
    +
    2468 debug_printf( 1, "retroflat: win cli: %s", cmd_line );
    +
    2469
    +
    2470 /* Get the number of args. */
    +
    2471 *argc_out = 1; /* Program name. */
    +
    2472 for( i = 0 ; '\0' != cmd_line[i - 1] ; i++ ) {
    +
    2473 if( ' ' != cmd_line[i] && '\0' != cmd_line[i] ) {
    +
    2474 arg_iter++;
    +
    2475 } else if( 0 < i ) {
    +
    2476 (*argc_out)++;
    +
    2477 if( arg_iter > arg_longest ) {
    +
    2478 /* This is the new longest arg. */
    +
    2479 arg_longest = arg_iter;
    +
    2480 }
    +
    2481 arg_iter = 0;
    +
    2482 }
    +
    2483 }
    +
    2484
    +
    2485 argv_out = calloc( *argc_out, sizeof( char* ) );
    +
    2486 maug_cleanup_if_null_alloc( char**, argv_out );
    +
    2487
    +
    2488 /* NULL program name. */
    +
    2489 argv_out[0] = calloc( 1, sizeof( char ) );
    +
    2490 maug_cleanup_if_null_alloc( char*, argv_out[0] );
    +
    2491
    +
    2492 /* Copy args into array. */
    +
    2493 arg_idx = 1;
    +
    2494 for( i = 0 ; '\0' != cmd_line[i - 1] ; i++ ) {
    +
    2495 if( ' ' != cmd_line[i] && '\0' != cmd_line[i] ) {
    +
    2496 /* If this isn't a WS char, it's an arg. */
    +
    2497 if( 0 < i && ' ' == cmd_line[i - 1] ) {
    +
    2498 /* If this is first non-WS char, it's start of a new arg. */
    +
    2499 arg_start = i;
    +
    2500 arg_iter = 0;
    +
    2501 }
    +
    2502 arg_iter++;
    +
    2503 continue;
    +
    2504 }
    +
    2505
    +
    2506 if( 0 < i && ' ' != cmd_line[i - 1] ) {
    +
    2507 /* If this is first WS char, it's the end of an arg. */
    +
    2508 assert( NULL == argv_out[arg_idx] );
    +
    2509 argv_out[arg_idx] = calloc( arg_iter + 1, sizeof( char ) );
    +
    2510 maug_cleanup_if_null_alloc( char*, argv_out[arg_idx] );
    +
    2511 strncpy( argv_out[arg_idx], &(cmd_line[arg_start]), arg_iter );
    +
    2512 arg_idx++; /* Start next arg. */
    +
    2513 arg_iter = 0; /* New arg is 0 long. */
    +
    2514 arg_start = i; /* New arg starts here (maybe). */
    +
    2515 }
    +
    2516 }
    +
    2517
    +
    2518cleanup:
    +
    2519
    +
    2520 if( MERROR_OK != retval && NULL != argv_out ) {
    +
    2521 for( i = 0 ; *argc_out > i ; i++ ) {
    +
    2522 free( argv_out[i] );
    +
    2523 argv_out[i] = NULL;
    +
    2524 }
    +
    2525 free( argv_out );
    +
    2526 argv_out = NULL;
    +
    2527 }
    +
    2528
    +
    2529 return argv_out;
    +
    2530}
    +
    2531
    +
    2532# elif defined( RETROFLAT_API_GLUT )
    +
    2533
    +
    2534#ifdef RETROFLAT_OS_OS2
    +
    2535void APIENTRY
    +
    2536#else
    +
    2537void
    +
    2538#endif /* RETROFLAT_OS_OS2 */
    +
    2539retroflat_glut_display( void ) {
    +
    2540 if( NULL != g_retroflat_state->loop_iter ) {
    +
    2541 g_retroflat_state->loop_iter( g_retroflat_state->loop_data );
    +
    2542 }
    +
    2543}
    +
    2544
    +
    2545#ifdef RETROFLAT_OS_OS2
    +
    2546void APIENTRY
    +
    2547#else
    +
    2548void
    +
    2549#endif /* RETROFLAT_OS_OS2 */
    +
    2550retroflat_glut_idle( void ) {
    +
    2551 uint32_t now = 0;
    +
    2552
    +
    2553 now = retroflat_get_ms();
    +
    2554 if(
    + +
    2556 (RETROFLAT_FLAGS_UNLOCK_FPS & g_retroflat_state->retroflat_flags) &&
    +
    2557 now < g_retroflat_state->retroflat_next
    +
    2558 ) {
    +
    2559 return;
    +
    2560 }
    +
    2561
    +
    2562 glutPostRedisplay();
    +
    2563
    +
    2564 if( now + retroflat_fps_next() > now ) {
    +
    2565 g_retroflat_state->retroflat_next = now + retroflat_fps_next();
    +
    2566 } else {
    +
    2567 /* Rollover protection. */
    +
    2568 g_retroflat_state->retroflat_next = 0;
    +
    2569 }
    +
    2570}
    +
    2571
    +
    2572#ifdef RETROFLAT_OS_OS2
    +
    2573void APIENTRY
    +
    2574#else
    +
    2575void
    +
    2576#endif /* RETROFLAT_OS_OS2 */
    +
    2577retroflat_glut_key( unsigned char key, int x, int y ) {
    +
    2578 g_retroflat_state->retroflat_last_key = key;
    +
    2579}
    +
    2580
    +
    2581# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    2582
    +
    2583/* Still inside RETROFLT_C! */
    +
    2584
    +
    2585/* === */
    +
    2586
    +
    2587int retroflat_loop( retroflat_loop_iter loop_iter, void* data ) {
    +
    2588
    +
    2589# if defined( RETROFLAT_OS_WASM )
    +
    2590
    +
    2591 emscripten_cancel_main_loop();
    +
    2592 emscripten_set_main_loop_arg( loop_iter, data, 0, 0 );
    +
    2593
    +
    2594# elif defined( RETROFLAT_API_ALLEGRO ) || \
    +
    2595 defined( RETROFLAT_API_SDL1 ) || \
    +
    2596 defined( RETROFLAT_API_SDL2 ) || \
    +
    2597 defined( RETROFLAT_API_LIBNDS )
    +
    2598
    +
    2599 uint32_t next = 0,
    +
    2600 now = 0;
    +
    2601
    +
    2602 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_RUNNING;
    +
    2603 do {
    +
    2604 if(
    + +
    2606 (RETROFLAT_FLAGS_UNLOCK_FPS & g_retroflat_state->retroflat_flags) &&
    +
    2607 retroflat_get_ms() < next
    +
    2608 ) {
    +
    2609 /* Sleep/low power for a bid. */
    +
    2610# ifdef RETROFLAT_API_LIBNDS
    +
    2611 swiWaitForVBlank();
    +
    2612# endif /* RETROFLAT_API_LIBNDS */
    +
    2613 continue;
    +
    2614 }
    +
    2615 loop_iter( data );
    +
    2616 now = retroflat_get_ms();
    +
    2617 if( now + retroflat_fps_next() > now ) {
    +
    2618 next = now + retroflat_fps_next();
    +
    2619 } else {
    +
    2620 /* Rollover protection. */
    +
    2621 next = 0;
    +
    2622 }
    +
    2623 } while(
    + +
    2625 );
    +
    2626
    +
    2627# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2628
    +
    2629 /* Set these to be called from WndProc later. */
    +
    2630 g_retroflat_state->loop_iter = (retroflat_loop_iter)loop_iter;
    +
    2631 g_retroflat_state->loop_data = (void*)data;
    +
    2632
    +
    2633 /* Handle Windows messages until quit. */
    +
    2634 do {
    +
    2635 g_retroflat_state->msg_retval =
    +
    2636 GetMessage( &(g_retroflat_state->msg), 0, 0, 0 );
    +
    2637 TranslateMessage( &(g_retroflat_state->msg) );
    +
    2638 DispatchMessage( &(g_retroflat_state->msg) );
    +
    2639 } while( 0 < g_retroflat_state->msg_retval );
    +
    2640
    +
    2641# elif defined( RETROFLAT_API_GLUT )
    +
    2642
    +
    2643 g_retroflat_state->loop_iter = (retroflat_loop_iter)loop_iter;
    +
    2644 g_retroflat_state->loop_data = (void*)data;
    +
    2645 glutMainLoop();
    +
    2646
    +
    2647# else
    +
    2648# warning "loop not implemented"
    +
    2649# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    2650
    +
    2651 /* This should be set by retroflat_quit(). */
    +
    2652 return g_retroflat_state->retval;
    +
    2653}
    +
    2654
    +
    2655/* === */
    +
    2656
    +
    2657char retroflat_vk_to_ascii( int k, uint8_t flags ) {
    +
    2658 char c = 0;
    +
    2659 char offset_lower = 0;
    +
    2660
    +
    2661 if( RETROFLAT_INPUT_MOD_SHIFT != (RETROFLAT_INPUT_MOD_SHIFT & flags) ) {
    +
    2662 /* Shift is *not* being held down. */
    +
    2663
    +
    2664 if( RETROFLAT_KEY_A <= k && RETROFLAT_KEY_Z >= k ) {
    +
    2665 if(
    +
    2666 RETROFLAT_INPUT_FORCE_UPPER !=
    +
    2667 (RETROFLAT_INPUT_FORCE_UPPER & flags)
    +
    2668 ) {
    +
    2669 /* Key is alphabetical and we're not forcing uppercase. */
    +
    2670 offset_lower = 0x20;
    +
    2671 }
    +
    2672 } else {
    +
    2673 offset_lower = 1;
    +
    2674 }
    +
    2675 }
    +
    2676
    +
    2677 switch( k ) {
    +
    2678 case RETROFLAT_KEY_A: c = 0x41 + offset_lower; break;
    +
    2679 case RETROFLAT_KEY_B: c = 0x42 + offset_lower; break;
    +
    2680 case RETROFLAT_KEY_C: c = 0x43 + offset_lower; break;
    +
    2681 case RETROFLAT_KEY_D: c = 0x44 + offset_lower; break;
    +
    2682 case RETROFLAT_KEY_E: c = 0x45 + offset_lower; break;
    +
    2683 case RETROFLAT_KEY_F: c = 0x46 + offset_lower; break;
    +
    2684 case RETROFLAT_KEY_G: c = 0x47 + offset_lower; break;
    +
    2685 case RETROFLAT_KEY_H: c = 0x48 + offset_lower; break;
    +
    2686 case RETROFLAT_KEY_I: c = 0x49 + offset_lower; break;
    +
    2687 case RETROFLAT_KEY_J: c = 0x4a + offset_lower; break;
    +
    2688 case RETROFLAT_KEY_K: c = 0x4b + offset_lower; break;
    +
    2689 case RETROFLAT_KEY_L: c = 0x4c + offset_lower; break;
    +
    2690 case RETROFLAT_KEY_M: c = 0x4d + offset_lower; break;
    +
    2691 case RETROFLAT_KEY_N: c = 0x4e + offset_lower; break;
    +
    2692 case RETROFLAT_KEY_O: c = 0x4f + offset_lower; break;
    +
    2693 case RETROFLAT_KEY_P: c = 0x50 + offset_lower; break;
    +
    2694 case RETROFLAT_KEY_Q: c = 0x51 + offset_lower; break;
    +
    2695 case RETROFLAT_KEY_R: c = 0x52 + offset_lower; break;
    +
    2696 case RETROFLAT_KEY_S: c = 0x53 + offset_lower; break;
    +
    2697 case RETROFLAT_KEY_T: c = 0x54 + offset_lower; break;
    +
    2698 case RETROFLAT_KEY_U: c = 0x55 + offset_lower; break;
    +
    2699 case RETROFLAT_KEY_V: c = 0x56 + offset_lower; break;
    +
    2700 case RETROFLAT_KEY_W: c = 0x57 + offset_lower; break;
    +
    2701 case RETROFLAT_KEY_X: c = 0x58 + offset_lower; break;
    +
    2702 case RETROFLAT_KEY_Y: c = 0x59 + offset_lower; break;
    +
    2703 case RETROFLAT_KEY_Z: c = 0x60 + offset_lower; break;
    +
    2704 case RETROFLAT_KEY_0: c = 0x30 + offset_lower; break;
    +
    2705 case RETROFLAT_KEY_1: c = offset_lower ? 0x31 : '!'; break;
    +
    2706 case RETROFLAT_KEY_2: c = 0x32; break;
    +
    2707 case RETROFLAT_KEY_3: c = 0x33; break;
    +
    2708 case RETROFLAT_KEY_4: c = 0x34; break;
    +
    2709 case RETROFLAT_KEY_5: c = 0x35; break;
    +
    2710 case RETROFLAT_KEY_6: c = 0x36; break;
    +
    2711 case RETROFLAT_KEY_7: c = 0x37; break;
    +
    2712 case RETROFLAT_KEY_8: c = 0x38; break;
    +
    2713 case RETROFLAT_KEY_9: c = 0x39; break;
    +
    2714 case RETROFLAT_KEY_SPACE: c = ' '; break;
    +
    2715 case RETROFLAT_KEY_BKSP: c = 0x08; break;
    +
    2716 case RETROFLAT_KEY_ENTER: c = '\n'; break;
    +
    2717 case RETROFLAT_KEY_SEMICOLON: c = offset_lower ? ';' : ':'; break;
    +
    2718 case RETROFLAT_KEY_DASH: c = offset_lower ? '-' : '_'; break;
    +
    2719 case RETROFLAT_KEY_SLASH: c = offset_lower ? '/' : '?'; break;
    +
    2720 case RETROFLAT_KEY_PERIOD: c = offset_lower ? '.' : '>'; break;
    +
    2721 case RETROFLAT_KEY_COMMA: c = offset_lower ? ',' : '<'; break;
    +
    2722 }
    +
    2723
    +
    2724 return c;
    +
    2725}
    +
    2726
    +
    2727/* === */
    +
    2728
    + +
    2730 uint8_t flags, const char* title, const char* format, ...
    +
    2731) {
    +
    2732 char msg_out[RETROFLAT_MSG_MAX + 1];
    +
    2733 va_list vargs;
    +
    2734# ifdef RETROFLAT_API_SDL2
    +
    2735 uint32_t sdl_msg_flags = 0;
    +
    2736# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2737 uint32_t win_msg_flags = 0;
    +
    2738# endif
    +
    2739
    +
    2740 memset( msg_out, '\0', RETROFLAT_MSG_MAX + 1 );
    +
    2741 va_start( vargs, format );
    +
    2742 maug_vsnprintf( msg_out, RETROFLAT_MSG_MAX, format, vargs );
    +
    2743
    +
    2744# if defined( RETROFLAT_API_ALLEGRO )
    +
    2745 allegro_message( "%s", msg_out );
    +
    2746# elif defined( RETROFLAT_API_SDL1 )
    +
    2747 /* TODO: Use a dialog box? */
    +
    2748 error_printf( "%s", msg_out );
    +
    2749# elif defined( RETROFLAT_API_SDL2 )
    +
    2750 switch( (flags & RETROFLAT_MSG_FLAG_TYPE_MASK) ) {
    +
    2751 case RETROFLAT_MSG_FLAG_ERROR:
    +
    2752 sdl_msg_flags = SDL_MESSAGEBOX_ERROR;
    +
    2753 break;
    +
    2754
    +
    2755 case RETROFLAT_MSG_FLAG_INFO:
    +
    2756 sdl_msg_flags = SDL_MESSAGEBOX_INFORMATION;
    +
    2757 break;
    +
    2758
    +
    2759 case RETROFLAT_MSG_FLAG_WARNING:
    +
    2760 sdl_msg_flags = SDL_MESSAGEBOX_WARNING;
    +
    2761 break;
    +
    2762 }
    +
    2763
    +
    2764 SDL_ShowSimpleMessageBox(
    +
    2765 sdl_msg_flags, title, msg_out, g_retroflat_state->window );
    +
    2766# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2767 switch( (flags & RETROFLAT_MSG_FLAG_TYPE_MASK) ) {
    +
    2768 case RETROFLAT_MSG_FLAG_ERROR:
    +
    2769 win_msg_flags |= MB_ICONSTOP;
    +
    2770 break;
    +
    2771
    +
    2772 case RETROFLAT_MSG_FLAG_INFO:
    +
    2773 win_msg_flags |= MB_ICONINFORMATION;
    +
    2774 break;
    +
    2775
    +
    2776 case RETROFLAT_MSG_FLAG_WARNING:
    +
    2777 win_msg_flags |= MB_ICONEXCLAMATION;
    +
    2778 break;
    +
    2779 }
    +
    2780
    +
    2781 MessageBox( g_retroflat_state->window, msg_out, title, win_msg_flags );
    +
    2782# elif defined( RETROFLAT_API_GLUT )
    +
    2783 /* TODO: Use a dialog box? */
    +
    2784 error_printf( "%s", msg_out );
    +
    2785# else
    +
    2786# warning "not implemented"
    +
    2787# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    2788
    +
    2789 va_end( vargs );
    +
    2790}
    +
    2791
    +
    2792# ifdef RETROFLAT_SCREENSAVER
    +
    2793
    +
    2794/* Windows screensaver (.scr) command-line arguments. */
    +
    2795
    +
    2796static int retroflat_cli_p( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2797 if( 0 == strncmp( MAUG_CLI_SIGIL "p", arg, MAUG_CLI_SIGIL_SZ + 2 ) ) {
    +
    2798 /* The next arg must be the new var. */
    +
    2799 } else {
    +
    2800 g_retroflat_state->parent = (HWND)atoi( arg );
    +
    2801 }
    +
    2802 return RETROFLAT_OK;
    +
    2803}
    +
    2804
    +
    2805static int retroflat_cli_s( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2806 debug_printf( 3, "using screensaver mode..." );
    +
    2807 args->flags |= RETROFLAT_FLAGS_SCREENSAVER;
    +
    2808 return RETROFLAT_OK;
    +
    2809}
    +
    2810
    +
    2811# endif /* RETROFLAT_SCREENSAVER */
    +
    2812
    +
    2813# ifndef RETROFLAT_NO_CLI_SZ
    +
    2814
    +
    2815static int retroflat_cli_rfw( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2816 if( 0 == strncmp( MAUG_CLI_SIGIL "rfx", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
    +
    2817 /* The next arg must be the new var. */
    +
    2818 } else {
    +
    2819 args->screen_w = atoi( arg );
    +
    2820 }
    +
    2821 return RETROFLAT_OK;
    +
    2822}
    +
    2823
    +
    2824static int retroflat_cli_rfw_def( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2825 if( 0 == args->screen_w ) {
    +
    2826 args->screen_w = 320;
    +
    2827 }
    +
    2828 return RETROFLAT_OK;
    +
    2829}
    +
    2830
    +
    2831static int retroflat_cli_rfh( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2832 if( 0 == strncmp( MAUG_CLI_SIGIL "rfy", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
    +
    2833 /* The next arg must be the new var. */
    +
    2834 } else {
    +
    2835 args->screen_h = atoi( arg );
    +
    2836 }
    +
    2837 return RETROFLAT_OK;
    +
    2838}
    +
    2839
    +
    2840static int retroflat_cli_rfh_def( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2841 if( 0 == args->screen_h ) {
    +
    2842 args->screen_h = 200;
    +
    2843 }
    +
    2844 return RETROFLAT_OK;
    +
    2845}
    +
    2846
    +
    2847# endif /* !RETROFLAT_NO_CLI_SZ */
    +
    2848
    +
    2849# ifndef MAUG_NO_CONFIG
    +
    2850
    +
    2851static int retroflat_cli_c( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2852 if( 0 == strncmp( MAUG_CLI_SIGIL "rfc", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
    +
    2853 /* The next arg must be the new var. */
    +
    2854 } else {
    +
    2855 debug_printf( 1, "setting config path to: %s", arg );
    +
    2856 strncpy( g_retroflat_state->config_path, arg, RETROFLAT_PATH_MAX );
    +
    2857 }
    +
    2858 return RETROFLAT_OK;
    +
    2859}
    +
    2860
    +
    2861static int retroflat_cli_c_def( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2862 memset( g_retroflat_state->config_path, '\0', RETROFLAT_PATH_MAX + 1 );
    +
    2863
    +
    2864 if( NULL != args->config_path ) {
    +
    2865 debug_printf( 1, "setting config path to: %s", args->config_path );
    +
    2866 strncpy(
    +
    2867 g_retroflat_state->config_path,
    + +
    2869 } else {
    +
    2870 debug_printf( 1, "setting config path to: %s%s",
    +
    2871 args->title, RETROFLAT_CONFIG_EXT );
    +
    2872 strncpy(
    +
    2873 g_retroflat_state->config_path, args->title, RETROFLAT_PATH_MAX );
    +
    2874 strncat(
    +
    2875 g_retroflat_state->config_path,
    +
    2876 RETROFLAT_CONFIG_EXT, RETROFLAT_PATH_MAX );
    +
    2877 }
    +
    2878
    +
    2879 return RETROFLAT_OK;
    +
    2880}
    +
    2881
    +
    2882# endif /* !MAUG_CLI_SIGIL_SZ */
    +
    2883
    +
    2884# ifdef RETROFLAT_VDP
    +
    2885static int retroflat_cli_vdp( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2886 if( 0 == strncmp( MAUG_CLI_SIGIL "vdp", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
    +
    2887 /* Next arg is VDP args str. */
    +
    2888 } else {
    +
    2889 strncpy( g_retroflat_state->vdp_args, arg, RETROFLAT_VDP_ARGS_SZ_MAX );
    +
    2890 debug_printf( 1, "VDP args: %s", g_retroflat_state->vdp_args );
    +
    2891 }
    +
    2892 return RETROFLAT_OK;
    +
    2893}
    +
    2894# endif /* RETROFLAT_VDP */
    +
    2895
    +
    2896static int retroflat_cli_u( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2897 if( 0 == strncmp( MAUG_CLI_SIGIL "rfu", arg, MAUG_CLI_SIGIL_SZ + 4 ) ) {
    +
    2898 debug_printf( 1, "unlocking FPS..." );
    +
    2899 args->flags |= RETROFLAT_FLAGS_UNLOCK_FPS;
    +
    2900 }
    +
    2901 return RETROFLAT_OK;
    +
    2902}
    +
    2903
    +
    2904static int retroflat_cli_u_def( const char* arg, struct RETROFLAT_ARGS* args ) {
    +
    2905 args->flags &= ~RETROFLAT_FLAGS_UNLOCK_FPS;
    +
    2906 return RETROFLAT_OK;
    +
    2907}
    +
    2908
    +
    2909/* === */
    +
    2910
    +
    2911# ifdef RETROFLAT_API_ALLEGRO
    +
    2912
    +
    2913/* Allegro-specific callbacks for init, below. */
    +
    2914
    +
    2915void retroflat_on_ms_tick() {
    +
    2916 if( NULL == g_retroflat_state ) {
    +
    2917 debug_printf( 1, "no state!" );
    +
    2918 } else {
    +
    2919 g_retroflat_state->ms++;
    +
    2920 }
    +
    2921}
    +
    2922
    +
    2923void retroflat_on_close_button() {
    +
    2924 g_retroflat_state->close_button = 1;
    +
    2925}
    +
    2926END_OF_FUNCTION( retroflat_on_close_button )
    +
    2927
    +
    2928# endif /* RETROFLAT_API_ALLEGRO */
    +
    2929
    +
    2930/* === */
    +
    2931
    +
    2932/* Still inside RETROFLT_C! */
    +
    2933
    +
    2934int retroflat_init( int argc, char* argv[], struct RETROFLAT_ARGS* args ) {
    +
    2935
    +
    2936 /* = Begin Init = */
    +
    2937
    +
    2938 int retval = 0;
    +
    2939# if defined( RETROFLAT_API_ALLEGRO ) && defined( RETROFLAT_OS_DOS )
    +
    2940# if 0
    +
    2941 union REGS regs;
    +
    2942 struct SREGS sregs;
    +
    2943# endif
    +
    2944# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    2945 WNDCLASS wc = { 0 };
    +
    2946 RECT wr = { 0, 0, 0, 0 };
    +
    2947 DWORD window_style = RETROFLAT_WIN_STYLE;
    +
    2948 DWORD window_style_ex = 0;
    +
    2949 int wx = CW_USEDEFAULT,
    +
    2950 wy = CW_USEDEFAULT;
    +
    2951# elif defined( RETROFLAT_API_SDL1 )
    +
    2952 const SDL_VideoInfo* info = NULL;
    +
    2953# if defined( RETROFLAT_OPENGL )
    +
    2954 int gl_retval = 0,
    +
    2955 gl_depth = 16;
    +
    2956# endif /* RETROFLAT_OPENGL */
    +
    2957# elif defined( RETROFLAT_API_LIBNDS )
    +
    2958 int i = 0;
    +
    2959# elif defined( RETROFLAT_API_GLUT )
    +
    2960 unsigned int glut_init_flags = 0;
    +
    2961# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    2962
    +
    2963# if defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    2964# if defined( RETROFLAT_SDL_ICO )
    +
    2965 SDL_Surface* icon = NULL;
    +
    2966# endif /* RETROFLAT_SDL_ICO */
    +
    2967# endif /* RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 */
    +
    2968
    +
    2969 debug_printf( 1, "retroflat: initializing..." );
    +
    2970
    +
    2971 /* System sanity checks. */
    +
    2972 assert( 4 == sizeof( uint32_t ) );
    +
    2973 assert( 4 == sizeof( int32_t ) );
    +
    2974 assert( 2 == sizeof( uint16_t ) );
    +
    2975 assert( 2 == sizeof( int16_t ) );
    +
    2976 assert( 1 == sizeof( uint8_t ) );
    +
    2977 assert( 1 == sizeof( int8_t ) );
    +
    2978 assert( NULL != args );
    +
    2979
    +
    2980 debug_printf( 1, "retroflat: allocating state (" SIZE_T_FMT " bytes",
    +
    2981 sizeof( struct RETROFLAT_STATE ) );
    +
    2982
    +
    2983 g_retroflat_state_h = maug_malloc( 1, sizeof( struct RETROFLAT_STATE ) );
    +
    2984 if( (MAUG_MHANDLE)NULL == g_retroflat_state_h ) {
    +
    2985 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2986 "Error", "Could not allocate global state!" );
    +
    2987 retval = MERROR_ALLOC;
    +
    2988 goto cleanup;
    +
    2989 }
    +
    2990
    +
    2991 maug_mlock( g_retroflat_state_h, g_retroflat_state );
    +
    2992 if( (MAUG_MHANDLE)NULL == g_retroflat_state ) {
    +
    2993 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    2994 "Error", "Could not lock global state!" );
    +
    2995 retval = MERROR_ALLOC;
    +
    2996 goto cleanup;
    +
    2997 }
    +
    2998 maug_mzero( g_retroflat_state, sizeof( struct RETROFLAT_STATE ) );
    +
    2999
    +
    3000 debug_printf( 1, "retroflat: parsing args..." );
    +
    3001
    +
    3002 /* All platforms: add command-line args based on compile definitons. */
    +
    3003
    +
    3004# ifdef RETROFLAT_SCREENSAVER
    +
    3005 maug_add_arg( MAUG_CLI_SIGIL "p", MAUG_CLI_SIGIL_SZ + 2,
    +
    3006 "Preview screensaver", 0, (maug_cli_cb)retroflat_cli_p, NULL, args );
    +
    3007 maug_add_arg( MAUG_CLI_SIGIL "s", MAUG_CLI_SIGIL_SZ + 2,
    +
    3008 "Launch screensaver", 0, (maug_cli_cb)retroflat_cli_s, NULL, args );
    +
    3009# endif /* RETROFLAT_SCREENSAVER */
    +
    3010
    +
    3011# ifndef RETROFLAT_NO_CLI_SZ
    +
    3012 maug_add_arg( MAUG_CLI_SIGIL "rfw", MAUG_CLI_SIGIL_SZ + 4,
    +
    3013 "Set the screen width.", 0,
    +
    3014 (maug_cli_cb)retroflat_cli_rfw,
    +
    3015 (maug_cli_cb)retroflat_cli_rfw_def, args );
    +
    3016 maug_add_arg( MAUG_CLI_SIGIL "rfh", MAUG_CLI_SIGIL_SZ + 4,
    +
    3017 "Set the screen height.", 0,
    +
    3018 (maug_cli_cb)retroflat_cli_rfh,
    +
    3019 (maug_cli_cb)retroflat_cli_rfh_def, args );
    +
    3020# endif /* !RETROFLAT_NO_CLI_SZ */
    +
    3021
    +
    3022# ifdef RETROFLAT_VDP
    +
    3023 maug_add_arg( MAUG_CLI_SIGIL "vdp", MAUG_CLI_SIGIL_SZ + 4,
    +
    3024 "Pass a string of args to the VDP.", 0,
    +
    3025 (maug_cli_cb)retroflat_cli_vdp, NULL, args );
    +
    3026# endif /* RETROFLAT_VDP */
    +
    3027
    +
    3028# ifndef MAUG_NO_CONFIG
    +
    3029 maug_add_arg( MAUG_CLI_SIGIL "rfc", MAUG_CLI_SIGIL_SZ + 4,
    +
    3030 "Set the config path.", 0,
    +
    3031 (maug_cli_cb)retroflat_cli_c, (maug_cli_cb)retroflat_cli_c_def, args );
    +
    3032# endif /* !MAUG_NO_CONFIG */
    +
    3033
    +
    3034 maug_add_arg( MAUG_CLI_SIGIL "rfu", MAUG_CLI_SIGIL_SZ + 4,
    +
    3035 "Unlock FPS.", 0,
    +
    3036 (maug_cli_cb)retroflat_cli_u, (maug_cli_cb)retroflat_cli_u_def, args );
    +
    3037
    +
    3038 /* Parse command line args. */
    +
    3039 retval = maug_parse_args( argc, argv );
    +
    3040 if( RETROFLAT_OK != retval ) {
    +
    3041 goto cleanup;
    +
    3042 }
    +
    3043
    +
    3044 if(
    + +
    3046 ) {
    +
    3047 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_UNLOCK_FPS;
    +
    3048 }
    +
    3049
    +
    3050 debug_printf( 1, "retroflat: setting config..." );
    +
    3051
    +
    3052 /* Set the assets path. */
    +
    3053 memset( g_retroflat_state->assets_path, '\0', RETROFLAT_ASSETS_PATH_MAX );
    +
    3054 if( NULL != args->assets_path ) {
    +
    3055 strncpy( g_retroflat_state->assets_path,
    + +
    3057 }
    +
    3058
    +
    3059# if defined( RETROFLAT_SCREENSAVER )
    +
    3060 if(
    + +
    3062 (RETROFLAT_FLAGS_SCREENSAVER & args->flags)
    +
    3063 ) {
    +
    3064 g_retroflat_state->retroflat_flags |= RETROFLAT_FLAGS_SCREENSAVER;
    +
    3065 }
    +
    3066# endif /* RETROFLAT_SCREENSAVER */
    +
    3067
    +
    3068 /* Setup intended screen size.
    +
    3069 * These may be forced/modified by the platform-specific section below!
    +
    3070 */
    +
    3071 /* TODO: Handle window resizing someday! */
    +
    3072 g_retroflat_state->screen_v_w = args->screen_w;
    +
    3073 g_retroflat_state->screen_v_h = args->screen_h;
    +
    3074 g_retroflat_state->screen_w = args->screen_w;
    +
    3075 g_retroflat_state->screen_h = args->screen_h;
    +
    3076
    +
    3077# ifdef RETROFLAT_OPENGL
    +
    3078 debug_printf( 1, "setting up texture palette..." );
    +
    3079# define RETROFLAT_COLOR_TABLE_TEX( idx, name_l, name_u, r, g, b ) \
    +
    3080 g_retroflat_state->tex_palette[idx][0] = r; \
    +
    3081 g_retroflat_state->tex_palette[idx][1] = g; \
    +
    3082 g_retroflat_state->tex_palette[idx][2] = b;
    +
    3083 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_TEX )
    +
    3084# endif /* RETROFLAT_OPENGL */
    +
    3085
    +
    3086# ifdef RETROFLAT_API_ALLEGRO
    +
    3087
    +
    3088 /* == Allegro == */
    +
    3089
    +
    3090 srand( time( NULL ) );
    +
    3091
    +
    3092 if( allegro_init() ) {
    +
    3093 allegro_message( "could not setup allegro!" );
    +
    3094 retval = RETROFLAT_ERROR_ENGINE;
    +
    3095 goto cleanup;
    +
    3096 }
    +
    3097
    +
    3098 install_keyboard();
    +
    3099# if !defined( RETROFLAT_OS_DOS )
    +
    3100 /* XXX: Broken in DOS. */
    +
    3101 install_timer();
    +
    3102 install_int( retroflat_on_ms_tick, 1 );
    +
    3103# endif /* RETROFLAT_OS_DOS */
    +
    3104
    +
    3105# ifdef RETROFLAT_OS_DOS
    +
    3106 /* Don't try windowed mode in DOS. */
    +
    3107 if(
    +
    3108 set_gfx_mode( GFX_AUTODETECT, args->screen_w, args->screen_h, 0, 0 )
    +
    3109 ) {
    +
    3110# else
    +
    3111 if(
    +
    3112 set_gfx_mode(
    +
    3113 GFX_AUTODETECT_WINDOWED, args->screen_w, args->screen_h, 0, 0 )
    +
    3114 ) {
    +
    3115# endif /* RETROFLAT_OS_DOS */
    +
    3116
    +
    3117 allegro_message( "could not setup graphics!" );
    +
    3118 retval = RETROFLAT_ERROR_GRAPHICS;
    +
    3119 goto cleanup;
    +
    3120 }
    +
    3121
    +
    3122# define RETROFLAT_COLOR_TABLE_ALLEGRO_INIT( i, name_l, name_u, r, g, b ) \
    +
    3123 g_retroflat_state->palette[i] = makecol( r, g, b );
    +
    3124
    +
    3125 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_ALLEGRO_INIT )
    +
    3126
    +
    3127 LOCK_FUNCTION( retroflat_on_close_button );
    +
    3128 set_close_button_callback( retroflat_on_close_button );
    +
    3129
    +
    3130# ifndef RETROFLAT_OS_DOS
    +
    3131 if( NULL != args->title ) {
    +
    3132 retroflat_set_title( args->title );
    +
    3133 }
    +
    3134
    +
    3135 /* XXX: Broken in DOS. */
    +
    3136 if( 0 > install_mouse() ) {
    +
    3137 allegro_message( "could not setup mouse!" );
    +
    3138 retval = RETROFLAT_ERROR_MOUSE;
    +
    3139 goto cleanup;
    +
    3140 }
    +
    3141# endif /* !RETROFLAT_OS_DOS */
    +
    3142
    +
    3143# ifdef RETROFLAT_OS_DOS
    +
    3144# if 0
    +
    3145 regs.w.ax = 0x9;
    +
    3146 regs.w.bx = 0x0;
    +
    3147 regs.w.cx = 0x0;
    +
    3148 regs.x.edx = FP_OFF( g_retroflat_state->mouse_cursor );
    +
    3149 sregs.es = FP_SEG( g_retroflat_state->mouse_cursor );
    +
    3150 int386x( 0x33, &regs, &regs, &sregs );
    +
    3151# endif
    +
    3152# endif /* RETROFLAT_OS_DOS */
    +
    3153
    +
    3154 g_retroflat_state->buffer.b =
    +
    3155 create_bitmap( args->screen_w, args->screen_h );
    +
    3156 maug_cleanup_if_null(
    +
    3157 BITMAP*, g_retroflat_state->buffer.b, RETROFLAT_ERROR_GRAPHICS );
    +
    3158
    +
    3159# elif defined( RETROFLAT_API_SDL1 )
    +
    3160
    +
    3161 /* == SDL1 == */
    +
    3162
    +
    3163 srand( time( NULL ) );
    +
    3164
    +
    3165 if( SDL_Init( SDL_INIT_VIDEO ) ) {
    +
    3166 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3167 "Error", "Error initializing SDL: %s", SDL_GetError() );
    +
    3168 retval = RETROFLAT_ERROR_ENGINE;
    +
    3169 goto cleanup;
    +
    3170 }
    +
    3171
    +
    3172 info = SDL_GetVideoInfo();
    +
    3173 maug_cleanup_if_null_alloc( SDL_VideoInfo*, info );
    +
    3174
    +
    3175 /* Setup color palettes. */
    +
    3176# ifdef RETROFLAT_OPENGL
    +
    3177# define RETROFLAT_COLOR_TABLE_SDL( idx, name_l, name_u, r, g, b ) \
    +
    3178 g_retroflat_state->palette[idx] = RETROGLU_COLOR_ ## name_u;
    +
    3179# else
    +
    3180# define RETROFLAT_COLOR_TABLE_SDL( idx, name_l, name_u, rd, gd, bd ) \
    +
    3181 g_retroflat_state->palette[idx].r = rd; \
    +
    3182 g_retroflat_state->palette[idx].g = gd; \
    +
    3183 g_retroflat_state->palette[idx].b = bd;
    +
    3184# endif /* RETROFLAT_OPENGL */
    +
    3185 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_SDL )
    +
    3186
    +
    3187# ifdef RETROFLAT_OPENGL
    +
    3188 if(
    + +
    3190 ) {
    +
    3191 SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
    +
    3192 }
    +
    3193 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
    +
    3194 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
    +
    3195 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
    +
    3196 do {
    +
    3197 /* Retry with smaller depth buffers if this fails. */
    +
    3198 gl_retval = SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, gl_depth );
    +
    3199 if( gl_retval ) {
    +
    3200 error_printf( "unable to set depth buffer to %d!", gl_depth );
    +
    3201 gl_depth -= 4;
    +
    3202 }
    +
    3203 } while( gl_retval );
    +
    3204 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
    +
    3205# endif /* RETROFLAT_OPENGL */
    +
    3206
    +
    3207 if( NULL != args->title ) {
    +
    3208 retroflat_set_title( args->title );
    +
    3209 }
    +
    3210
    +
    3211# ifdef RETROFLAT_SDL_ICO
    +
    3212 debug_printf( 1, "setting SDL window icon..." );
    +
    3213 icon = SDL_LoadBMP_RW(
    +
    3214 SDL_RWFromConstMem( obj_ico_sdl_ico_bmp,
    +
    3215 obj_ico_sdl_ico_bmp_len ), 1 );
    +
    3216 maug_cleanup_if_null( SDL_Surface*, icon, RETROFLAT_ERROR_BITMAP );
    +
    3217 SDL_WM_SetIcon( icon, 0 ); /* TODO: Constant mask. */
    +
    3218# endif /* RETROFLAT_SDL_ICO */
    +
    3219
    +
    3220 g_retroflat_state->buffer.surface = SDL_SetVideoMode(
    +
    3221 args->screen_w, args->screen_h, info->vfmt->BitsPerPixel,
    +
    3222 SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_ANYFORMAT
    +
    3223# ifdef RETROFLAT_OPENGL
    +
    3224 | SDL_OPENGL
    +
    3225# endif /* RETROFLAT_OPENGL */
    +
    3226 );
    +
    3227 maug_cleanup_if_null(
    +
    3228 SDL_Surface*, g_retroflat_state->buffer.surface,
    +
    3229 RETROFLAT_ERROR_GRAPHICS );
    +
    3230
    +
    3231 /* Setup key repeat. */
    +
    3232 if(
    + +
    3234 ) {
    +
    3235 if( 0 != SDL_EnableKeyRepeat(
    +
    3236 1, SDL_DEFAULT_REPEAT_INTERVAL
    +
    3237 ) ) {
    +
    3238 error_printf( "could not enable key repeat!" );
    +
    3239 } else {
    +
    3240 debug_printf( 3, "key repeat enabled" );
    +
    3241 }
    +
    3242 }
    +
    3243
    +
    3244# elif defined( RETROFLAT_API_SDL2 )
    +
    3245
    +
    3246 /* == SDL2 == */
    +
    3247
    +
    3248 srand( time( NULL ) );
    +
    3249
    +
    3250 if( SDL_Init( SDL_INIT_VIDEO ) ) {
    +
    3251 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3252 "Error", "Error initializing SDL: %s", SDL_GetError() );
    +
    3253 retval = RETROFLAT_ERROR_ENGINE;
    +
    3254 goto cleanup;
    +
    3255 }
    +
    3256
    +
    3257 /* Setup color palettes. */
    +
    3258# ifdef RETROFLAT_OPENGL
    +
    3259# define RETROFLAT_COLOR_TABLE_SDL( idx, name_l, name_u, r, g, b ) \
    +
    3260 g_retroflat_state->palette[idx] = RETROGLU_COLOR_ ## name_u;
    +
    3261# else
    +
    3262# define RETROFLAT_COLOR_TABLE_SDL( idx, name_l, name_u, rd, gd, bd ) \
    +
    3263 g_retroflat_state->palette[idx].r = rd; \
    +
    3264 g_retroflat_state->palette[idx].g = gd; \
    +
    3265 g_retroflat_state->palette[idx].b = bd;
    +
    3266# endif /* RETROFLAT_OPENGL */
    +
    3267 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_SDL )
    +
    3268
    +
    3269 /* Create the main window. */
    +
    3270 g_retroflat_state->window = SDL_CreateWindow( args->title,
    +
    3271 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
    +
    3272 args->screen_w, args->screen_h, RETROFLAT_WIN_FLAGS );
    +
    3273 maug_cleanup_if_null( SDL_Window*, g_retroflat_state->window, RETROFLAT_ERROR_GRAPHICS );
    +
    3274
    +
    3275 /* Create the main renderer. */
    +
    3276 g_retroflat_state->buffer.renderer = SDL_CreateRenderer(
    +
    3277 g_retroflat_state->window, -1,
    +
    3278 SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE );
    +
    3279 maug_cleanup_if_null(
    +
    3280 SDL_Renderer*, g_retroflat_state->buffer.renderer,
    +
    3281 RETROFLAT_ERROR_GRAPHICS );
    +
    3282
    +
    3283 /* Create the buffer texture. */
    +
    3284 g_retroflat_state->buffer.texture =
    +
    3285 SDL_CreateTexture( g_retroflat_state->buffer.renderer,
    +
    3286 SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET,
    +
    3287 g_retroflat_state->screen_w, g_retroflat_state->screen_h );
    +
    3288
    +
    3289# ifdef RETROFLAT_SDL_ICO
    +
    3290 debug_printf( 1, "setting SDL window icon..." );
    +
    3291 icon = SDL_LoadBMP_RW(
    +
    3292 SDL_RWFromConstMem( obj_ico_sdl_ico_bmp,
    +
    3293 obj_ico_sdl_ico_bmp_len ), 1 );
    +
    3294 maug_cleanup_if_null( SDL_Surface*, icon, RETROFLAT_ERROR_BITMAP );
    +
    3295 SDL_SetWindowIcon( g_retroflat_state->window, icon );
    +
    3296# endif /* RETROFLAT_SDL_ICO */
    +
    3297
    +
    3298# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    3299
    +
    3300 /* == Win16/Win32 == */
    +
    3301
    +
    3302# ifdef RETROFLAT_API_WINCE
    +
    3303 srand( GetTickCount() );
    +
    3304# else
    +
    3305 srand( time( NULL ) );
    +
    3306# endif /* RETROFLAT_API_WINCE */
    +
    3307
    +
    3308 /* Setup color palettes. */
    +
    3309 /* TODO: For WinG, try to make the indexes match system palette? */
    +
    3310# ifdef RETROFLAT_OPENGL
    +
    3311# define RETROFLAT_COLOR_TABLE_WIN( idx, name_l, name_u, r, g, b ) \
    +
    3312 g_retroflat_state->palette[idx] = RETROGLU_COLOR_ ## name_u;
    +
    3313# else
    +
    3314# define RETROFLAT_COLOR_TABLE_WIN( idx, name_l, name_u, r, g, b ) \
    +
    3315 g_retroflat_state->palette[idx] = RGB( r, g, b );
    +
    3316# endif /* RETROFLAT_OPENGL */
    +
    3317
    +
    3318 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN )
    +
    3319
    +
    3320# ifdef RETROFLAT_WING
    +
    3321 debug_printf( 3, "attempting to link WinG..." );
    +
    3322 /* Dynamically load the WinG procedures. */
    +
    3323# ifdef RETROFLAT_API_WIN32
    +
    3324 g_w.module = LoadLibrary( "wing32.dll" );
    +
    3325 if( (HMODULE)NULL == g_w.module ) {
    +
    3326# elif defined( RETROFLAT_API_WIN16 )
    +
    3327 g_w.module = LoadLibrary( "wing.dll" );
    +
    3328 if( HINSTANCE_ERROR == g_w.module ) {
    +
    3329# endif
    +
    3330 g_w.success = 0;
    +
    3331 } else {
    +
    3332 g_w.success = 1;
    +
    3333
    +
    3334# ifdef RETROFLAT_API_WIN32
    +
    3335# define RETROFLAT_WING_LLTABLE_LOAD_PROC( retval, proc, ord ) \
    +
    3336 g_w.proc = (proc ## _t)GetProcAddress( g_w.module, #proc ); \
    +
    3337 if( (proc ## _t)NULL == g_w.proc ) { \
    +
    3338 g_w.success = 0; \
    +
    3339 }
    +
    3340# elif defined( RETROFLAT_API_WIN16 )
    +
    3341# define RETROFLAT_WING_LLTABLE_LOAD_PROC( retval, proc, ord ) \
    +
    3342 g_w.proc = (proc ## _t)GetProcAddress( \
    +
    3343 g_w.module, MAKEINTRESOURCE( ord ) ); \
    +
    3344 if( (proc ## _t)NULL == g_w.proc ) { \
    +
    3345 retroflat_message( \
    +
    3346 RETROFLAT_MSG_FLAG_ERROR, "Error", \
    +
    3347 "Unable to link WinG proc: %s", #proc ); \
    +
    3348 g_w.success = 0; \
    +
    3349 }
    +
    3350# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    3351
    +
    3352 RETROFLAT_WING_LLTABLE( RETROFLAT_WING_LLTABLE_LOAD_PROC )
    +
    3353
    +
    3354 }
    +
    3355
    +
    3356 if( !g_w.success ) {
    +
    3357 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3358 "Error", "Unable to link WinG!" );
    +
    3359 }
    +
    3360# endif /* RETROFLAT_WING */
    +
    3361
    +
    3362 debug_printf( 1, "retroflat: creating window class..." );
    +
    3363
    +
    3364 /* Get the *real* size of the window, including titlebar. */
    +
    3365 wr.right = g_retroflat_state->screen_v_w;
    +
    3366 wr.bottom = g_retroflat_state->screen_v_h;
    +
    3367# ifndef RETROFLAT_API_WINCE
    +
    3368 AdjustWindowRect( &wr, RETROFLAT_WIN_STYLE, FALSE );
    +
    3369# endif /* !RETROFLAT_API_WINCE */
    +
    3370
    +
    3371 memset(
    +
    3372 &(g_retroflat_state->buffer), '\0', sizeof( struct RETROFLAT_BITMAP ) );
    +
    3373 memset( &wc, '\0', sizeof( WNDCLASS ) );
    +
    3374
    +
    3375 wc.lpfnWndProc = (WNDPROC)&WndProc;
    +
    3376 wc.hInstance = g_retroflat_instance;
    +
    3377# ifdef RETROFLAT_ICO_RES_ID
    +
    3378 wc.hIcon = LoadIcon(
    +
    3379 g_retroflat_instance, MAKEINTRESOURCE( RETROFLAT_ICO_RES_ID ) );
    +
    3380# endif /* RETROFLAT_ICO_RES_ID */
    +
    3381 wc.hCursor = LoadCursor( 0, IDC_ARROW );
    +
    3382 wc.hbrBackground = (HBRUSH)( COLOR_BTNFACE + 1 );
    +
    3383 /* wc.lpszMenuName = MAKEINTRESOURCE( IDR_MAINMENU ); */
    +
    3384 wc.lpszClassName = RETROFLAT_WINDOW_CLASS;
    +
    3385
    +
    3386 if( !RegisterClass( &wc ) ) {
    +
    3387 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3388 "Error", "Could not register window class!" );
    +
    3389 goto cleanup;
    +
    3390 }
    +
    3391
    +
    3392 debug_printf( 1, "retroflat: creating window..." );
    +
    3393
    +
    3394# ifdef RETROFLAT_SCREENSAVER
    +
    3395 if( (HWND)0 != g_retroflat_state->parent ) {
    +
    3396 /* Shrink the child window into the parent. */
    +
    3397 debug_printf( 1, "retroflat: using window parent: " UPRINTF_U32,
    +
    3398 g_retroflat_state->parent );
    +
    3399 window_style = WS_CHILD;
    +
    3400 GetClientRect( g_retroflat_state->parent, &wr );
    +
    3401 } else if(
    + +
    3403 (RETROFLAT_FLAGS_SCREENSAVER & g_retroflat_state->retroflat_flags)
    +
    3404 ) {
    +
    3405 /* Make window fullscreen and on top. */
    +
    3406 window_style_ex = WS_EX_TOPMOST;
    +
    3407 window_style = WS_POPUP | WS_VISIBLE;
    +
    3408 wx = 0;
    +
    3409 wy = 0;
    +
    3410 wr.left = 0;
    +
    3411 wr.top = 0;
    +
    3412 wr.right = GetSystemMetrics( SM_CXSCREEN );
    +
    3413 wr.bottom = GetSystemMetrics( SM_CYSCREEN );
    +
    3414 }
    +
    3415# endif /* RETROFLAT_SCREENSAVER */
    +
    3416
    +
    3417 g_retroflat_state->window = CreateWindowEx(
    +
    3418 window_style_ex, RETROFLAT_WINDOW_CLASS, args->title,
    +
    3419 window_style,
    +
    3420# ifdef RETROFLAT_API_WINCE
    +
    3421 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
    +
    3422# else
    +
    3423 wx, wy,
    +
    3424 wr.right - wr.left, wr.bottom - wr.top,
    +
    3425# endif /* RETROFLAT_API_WINCE */
    +
    3426# ifdef RETROFLAT_SCREENSAVER
    +
    3427 g_retroflat_state->parent
    +
    3428# else
    +
    3429 0
    +
    3430# endif /* RETROFLAT_SCREENSAVER */
    +
    3431 , 0, g_retroflat_instance, 0
    +
    3432 );
    +
    3433
    +
    3434# ifdef RETROFLAT_API_WINCE
    +
    3435 /* Force screen size. */
    +
    3436 GetClientRect( g_retroflat_state->window, &wr );
    +
    3437 g_retroflat_state->screen_v_w = wr.right - wr.left;
    +
    3438 g_retroflat_state->screen_v_h = wr.bottom - wr.top;
    +
    3439# endif /* RETROFLAT_API_WINCE */
    +
    3440
    +
    3441 if( !g_retroflat_state->window ) {
    +
    3442 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3443 "Error", "Could not create window!" );
    +
    3444 retval = RETROFLAT_ERROR_GRAPHICS;
    +
    3445 goto cleanup;
    +
    3446 }
    +
    3447
    +
    3448 maug_cleanup_if_null_alloc( HWND, g_retroflat_state->window );
    +
    3449
    +
    3450 debug_printf( 1, "setting up graphics timer every %d ms...",
    +
    3451 (int)(1000 / RETROFLAT_FPS) );
    +
    3452 if( !SetTimer(
    +
    3453 g_retroflat_state->window, RETROFLAT_WIN_GFX_TIMER_ID, (int)(1000 / RETROFLAT_FPS), NULL )
    +
    3454 ) {
    +
    3455 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    3456 "Error", "Could not create graphics timer!" );
    +
    3457 retval = RETROFLAT_ERROR_TIMER;
    +
    3458 goto cleanup;
    +
    3459 }
    +
    3460
    +
    3461#ifndef RETROFLAT_OPENGL
    +
    3462 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_BRSET )
    +
    3463 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_PNSET )
    +
    3464#endif /* !RETROFLAT_OPENGL */
    +
    3465
    +
    3466 ShowWindow( g_retroflat_state->window, g_retroflat_cmd_show );
    +
    3467
    +
    3468# elif defined( RETROFLAT_API_LIBNDS )
    +
    3469
    +
    3470 /* == Nintendo DS == */
    +
    3471
    +
    3472 /* Setup color constants. */
    +
    3473# define RETROFLAT_COLOR_TABLE_NDS_RGBS_INIT( idx, name_l, name_u, r, g, b ) \
    +
    3474 g_retroflat_state->palette[idx] = ARGB16( 1, r, g, b );
    +
    3475 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_NDS_RGBS_INIT )
    +
    3476
    +
    3477 /* Force screen size. */
    +
    3478 args->screen_w = 256;
    +
    3479 args->screen_h = 192;
    +
    3480
    +
    3481 powerOn( POWER_ALL );
    +
    3482
    +
    3483# ifdef RETROFLAT_OPENGL
    +
    3484
    +
    3485 debug_printf( 3, "setting up GL subsystem..." );
    +
    3486
    +
    3487 videoSetMode( MODE_0_3D );
    +
    3488
    +
    3489 vramSetBankA( VRAM_A_TEXTURE );
    +
    3490
    +
    3491 glInit();
    +
    3492
    +
    3493 /* TODO: Setup NDS 3D engine! */
    +
    3494
    +
    3495# else
    +
    3496 videoSetMode( MODE_5_2D );
    +
    3497 videoSetModeSub( MODE_0_2D );
    +
    3498
    +
    3499 /* Setup the upper screen for background and sprites. */
    +
    3500 vramSetBankA( VRAM_A_MAIN_BG );
    +
    3501 vramSetBankB( VRAM_B_MAIN_SPRITE );
    +
    3502
    +
    3503 /* Setup the lower screen for background and sprites. */
    +
    3504 vramSetBankC( VRAM_C_MAIN_BG );
    +
    3505 vramSetBankD( VRAM_D_SUB_SPRITE );
    +
    3506
    +
    3507 bgExtPaletteEnable();
    +
    3508
    +
    3509 /* Setup the background engine. */
    +
    3510
    +
    3511 /* Put map at base 2, but stow tiles up after the bitmap BG at base 7. */
    +
    3512 g_retroflat_state->bg_id = bgInit( 0, BgType_Text8bpp, BgSize_T_256x256, 2, 7 );
    +
    3513 dmaFillWords( 0, g_retroflat_state->bg_tiles, sizeof( g_retroflat_state->bg_tiles ) );
    +
    3514 bgSetPriority( g_retroflat_state->bg_id, 2 );
    +
    3515
    +
    3516 /* Put map at base 3, and tiles at base 0. */
    +
    3517 g_retroflat_state->window_id = bgInit( 1, BgType_Text8bpp, BgSize_T_256x256, 3, 0 );
    +
    3518 dmaFillWords( 0, g_retroflat_state->window_tiles, sizeof( g_retroflat_state->window_tiles ) );
    +
    3519 bgSetPriority( g_retroflat_state->window_id, 1 );
    +
    3520
    +
    3521 /* Put bitmap BG at base 1, leaving map-addressable space at base 0. */
    +
    3522 g_retroflat_state->px_id = bgInit( 2, BgType_Bmp16, BgSize_B16_256x256, 1, 0 );
    +
    3523 bgSetPriority( g_retroflat_state->px_id, 0 );
    +
    3524
    +
    3525 /* Setup the sprite engines. */
    +
    3526 oamInit( NDS_OAM_ACTIVE, SpriteMapping_1D_128, 0 );
    +
    3527
    +
    3528 /* Allocate sprite frame memory. */
    +
    3529 for( i = 0 ; NDS_SPRITES_ACTIVE > i ; i++ ) {
    +
    3530 g_retroflat_state->sprite_frames[i] = oamAllocateGfx(
    +
    3531 NDS_OAM_ACTIVE, SpriteSize_16x16, SpriteColorFormat_256Color );
    +
    3532 }
    +
    3533
    +
    3534# endif /* RETROFLAT_OPENGL */
    +
    3535
    +
    3536 /* Setup the timer. */
    +
    3537 TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1024;
    +
    3538 TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE;
    +
    3539
    +
    3540# elif defined( RETROFLAT_API_GLUT )
    +
    3541
    +
    3542 /* == GLUT == */
    +
    3543
    +
    3544# define RETROFLAT_COLOR_TABLE_GLUT( idx, name_l, name_u, rd, gd, bd ) \
    +
    3545 g_retroflat_state->palette[idx] = RETROGLU_COLOR_ ## name_u;
    +
    3546
    +
    3547 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_GLUT )
    +
    3548
    +
    3549 glutInit( &argc, argv );
    +
    3550 glut_init_flags = GLUT_DEPTH | GLUT_RGBA;
    +
    3551 if(
    + +
    3553 ) {
    +
    3554 glut_init_flags |= GLUT_DOUBLE;
    +
    3555 }
    +
    3556 glutInitDisplayMode( glut_init_flags );
    +
    3557 glutInitWindowSize(
    +
    3558 g_retroflat_state->screen_v_w, g_retroflat_state->screen_v_h );
    +
    3559 glutCreateWindow( args->title );
    +
    3560 glutIdleFunc( retroflat_glut_idle );
    +
    3561 glutDisplayFunc( retroflat_glut_display );
    +
    3562 glutKeyboardFunc( retroflat_glut_key );
    +
    3563
    +
    3564# else
    +
    3565# warning "init not implemented"
    +
    3566# endif /* RETROFLAT_API_ALLEGRO */
    +
    3567
    +
    3568# if defined( RETROFLAT_SOFT_SHAPES )
    +
    3569 retval = retrosoft_init();
    +
    3570 maug_cleanup_if_not_ok();
    +
    3571# endif /* RETROFLAT_SOFT_SHAPES */
    +
    3572
    +
    3573# if defined( RETROFLAT_OPENGL )
    +
    3574 retval = retrosoft_init();
    +
    3575 maug_cleanup_if_not_ok();
    +
    3576 retval = retroglu_init_glyph_tex();
    +
    3577 maug_cleanup_if_not_ok();
    +
    3578# endif /* RETROFLAT_OPENGL */
    +
    3579
    +
    3580# ifdef RETROFLAT_VDP
    +
    3581# if defined( RETROFLAT_OS_UNIX )
    +
    3582 g_retroflat_state->vdp_exe = dlopen(
    +
    3583# ifdef RETROFLAT_API_SDL1
    +
    3584 "./rvdpsdl1.so",
    +
    3585# elif defined( RETROFLAT_API_SDL2 )
    +
    3586 "./rvdpsdl2.so",
    +
    3587# else
    +
    3588# error "rvdp .so undefined!"
    +
    3589# endif
    +
    3590 RTLD_LAZY );
    +
    3591# elif defined( RETROFLAT_OS_WIN )
    +
    3592 g_retroflat_state->vdp_exe = LoadLibrary(
    +
    3593# ifdef RETROFLAT_API_SDL1
    +
    3594 "./rvdpsdl1.dll"
    +
    3595# elif defined( RETROFLAT_API_SDL2 )
    +
    3596 "./rvdpsdl2.dll"
    +
    3597# elif defined( RETROFLAT_API_WIN32 )
    +
    3598 "./rvdpnt.dll"
    +
    3599# else
    +
    3600# error "rvdp .so undefined!"
    +
    3601# endif
    +
    3602 );
    +
    3603# else
    +
    3604# error "dlopen undefined!"
    +
    3605# endif /* RETROFLAT_OS_UNIX */
    +
    3606
    +
    3607 if( !(g_retroflat_state->vdp_exe) ) {
    +
    3608 error_printf( "not loading VDP" );
    +
    3609 /* Skip creating the buffer or trying to run the init proc. */
    +
    3610 goto skip_vdp;
    +
    3611 }
    +
    3612
    +
    3613 /* Create intermediary screen buffer. */
    +
    3614 debug_printf( 1, "creating VDP buffer, %d x %d",
    +
    3615 g_retroflat_state->screen_v_w, g_retroflat_state->screen_v_h );
    +
    3616 g_retroflat_state->vdp_buffer =
    +
    3617 calloc( 1, sizeof( struct RETROFLAT_BITMAP ) );
    +
    3618 maug_cleanup_if_null_alloc(
    +
    3619 struct RETROFLAT_BITMAP*, g_retroflat_state->vdp_buffer );
    +
    3620 retval = retroflat_create_bitmap(
    +
    3621 g_retroflat_state->screen_v_w, g_retroflat_state->screen_v_h,
    +
    3622 g_retroflat_state->vdp_buffer, RETROFLAT_FLAGS_OPAQUE );
    +
    3623 maug_cleanup_if_not_ok();
    +
    3624
    +
    3625 debug_printf( 1, "initializing VDP..." );
    +
    3626 retval = retroflat_vdp_call( "retroflat_vdp_init" );
    +
    3627
    +
    3628skip_vdp:
    +
    3629
    +
    3630# endif /* RETROFLAT_VDP */
    +
    3631
    +
    3632cleanup:
    +
    3633
    +
    3634 return retval;
    +
    3635}
    +
    3636
    +
    3637/* === */
    +
    3638
    +
    3639void retroflat_shutdown( int retval ) {
    +
    3640
    +
    3641# if defined( RETROFLAT_VDP )
    +
    3642 if( NULL != g_retroflat_state->vdp_exe ) {
    +
    3643 retroflat_vdp_call( "retroflat_vdp_shutdown" );
    +
    3644# ifdef RETROFLAT_OS_UNIX
    +
    3645 dlclose( g_retroflat_state->vdp_exe );
    +
    3646# elif defined( RETROFLAT_OS_WIN )
    +
    3647 FreeLibrary( g_retroflat_state->vdp_exe );
    +
    3648# else
    +
    3649# error "dlclose undefined!"
    +
    3650# endif /* RETROFLAT_OS_UNIX || RETROFLAT_OS_WIN */
    +
    3651 }
    +
    3652
    +
    3653 if( NULL != g_retroflat_state->vdp_buffer ) {
    +
    3654 retroflat_destroy_bitmap( g_retroflat_state->vdp_buffer );
    +
    3655 free( g_retroflat_state->vdp_buffer );
    +
    3656 }
    +
    3657# endif /* RETROFLAT_VDP */
    +
    3658
    +
    3659# if defined( RETROFLAT_SOFT_SHAPES )
    +
    3660 retrosoft_shutdown();
    +
    3661# endif /* RETROFLAT_SOFT_SHAPES */
    +
    3662
    +
    3663# if defined( RETROFLAT_OS_WASM )
    +
    3664 /* Do nothing, start the main loop later. */
    +
    3665 return;
    +
    3666# elif defined( RETROFLAT_API_ALLEGRO )
    +
    3667
    +
    3668# ifdef RETROFLAT_VDP
    +
    3669 /* TODO: Destroy the VDP buffer! */
    +
    3670# endif /* RETROFLAT_VDP */
    +
    3671
    +
    3672 /* == Allegro == */
    +
    3673
    +
    3674 if( RETROFLAT_ERROR_ENGINE != retval ) {
    +
    3675 clear_keybuf();
    +
    3676 }
    +
    3677
    +
    3678 retroflat_destroy_bitmap( &(g_retroflat_state->buffer) );
    +
    3679
    +
    3680# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    3681
    +
    3682 /* == SDL == */
    +
    3683
    +
    3684# ifndef RETROFLAT_API_SDL1
    +
    3685 SDL_DestroyWindow( g_retroflat_state->window );
    +
    3686# endif /* !RETROFLAT_API_SDL1 */
    +
    3687
    +
    3688 SDL_Quit();
    +
    3689
    +
    3690# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    3691
    +
    3692 /* TODO: Windows shutdown? */
    +
    3693
    +
    3694 if( (HDC)NULL != g_retroflat_state->buffer.hdc_b ) {
    +
    3695 /* Return the default object into the HDC. */
    +
    3696 SelectObject(
    +
    3697 g_retroflat_state->buffer.hdc_b,
    +
    3698 g_retroflat_state->buffer.old_hbm_b );
    +
    3699 DeleteDC( g_retroflat_state->buffer.hdc_b );
    +
    3700 g_retroflat_state->buffer.hdc_b = (HDC)NULL;
    +
    3701
    +
    3702 /* Destroy buffer bitmap! */
    +
    3703 retroflat_destroy_bitmap( &(g_retroflat_state->buffer) );
    +
    3704 }
    +
    3705
    +
    3706# ifndef RETROFLAT_OPENGL
    +
    3707 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_BRRM )
    +
    3708 RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_WIN_PENRM )
    +
    3709# endif /* !RETROFLAT_OPENGL */
    +
    3710
    +
    3711# ifdef RETROFLAT_WING
    +
    3712 if( (HMODULE)NULL != g_w.module ) {
    +
    3713 FreeLibrary( g_w.module );
    +
    3714 }
    +
    3715# endif /* RETROFLAT_WING */
    +
    3716
    +
    3717 if( (HDC)NULL != g_retroflat_state->hdc_win ) {
    +
    3718 ReleaseDC( g_retroflat_state->window, g_retroflat_state->hdc_win );
    +
    3719 }
    +
    3720
    +
    3721# elif defined( RETROFLAT_API_GLUT )
    +
    3722
    +
    3723 /* TODO */
    +
    3724
    +
    3725# else
    +
    3726# warning "shutdown not implemented"
    +
    3727# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 */
    +
    3728
    +
    3729 maug_munlock( g_retroflat_state_h, g_retroflat_state );
    +
    3730 maug_mfree( g_retroflat_state );
    +
    3731
    +
    3732}
    +
    3733
    +
    3734/* === */
    +
    3735
    +
    3736# ifdef RETROFLAT_VDP
    +
    3737
    +
    3738MERROR_RETVAL retroflat_vdp_call( const char* proc_name ) {
    +
    3739 MERROR_RETVAL retval = MERROR_OK;
    + +
    3741# ifdef RETROFLAT_OS_WIN
    +
    3742 char proc_name_ex[256];
    +
    3743# endif /* RETROFLAT_OS_WIN */
    +
    3744
    +
    3745 if( NULL == g_retroflat_state->vdp_exe ) {
    +
    3746 goto cleanup;
    +
    3747 }
    +
    3748
    +
    3749# ifdef RETROFLAT_OS_UNIX
    +
    3750 vdp_proc = dlsym( g_retroflat_state->vdp_exe, proc_name );
    +
    3751# elif defined( RETROFLAT_OS_WIN )
    +
    3752 /* Append a _ to the proc_name because Watcom? Windows? */
    +
    3753 maug_snprintf( proc_name_ex, 255, "%s_", proc_name );
    +
    3754 vdp_proc = (retroflat_vdp_proc_t)GetProcAddress(
    +
    3755 g_retroflat_state->vdp_exe, proc_name_ex );
    +
    3756# else
    +
    3757# error "dlsym undefined!"
    +
    3758# endif
    +
    3759 if( (retroflat_vdp_proc_t)NULL == vdp_proc ) {
    +
    3760 goto cleanup;
    +
    3761 }
    +
    3762
    +
    3763# ifdef RETROFLAT_OS_WIN
    +
    3764 retroflat_draw_lock( g_retroflat_state->vdp_buffer );
    +
    3765# endif /* RETROFLAT_OS_WIN */
    +
    3766
    +
    3767 if(
    +
    3768 /* Don't pxlock before init can set the flag! */
    +
    3769 0 == strcmp( "retroflat_vdp_flip", proc_name ) &&
    + +
    3771 (RETROFLAT_VDP_FLAG_PXLOCK & g_retroflat_state->vdp_flags)
    +
    3772 ) {
    +
    3773 retroflat_px_lock( &(g_retroflat_state->buffer) );
    +
    3774 retroflat_px_lock( g_retroflat_state->vdp_buffer );
    +
    3775 }
    +
    3776
    +
    3777 retval = vdp_proc( g_retroflat_state );
    +
    3778
    +
    3779 if(
    +
    3780 0 == strcmp( "retroflat_vdp_flip", proc_name ) &&
    + +
    3782 (RETROFLAT_VDP_FLAG_PXLOCK & g_retroflat_state->vdp_flags)
    +
    3783 ) {
    +
    3784 retroflat_px_release( &(g_retroflat_state->buffer) );
    +
    3785 retroflat_px_release( g_retroflat_state->vdp_buffer );
    +
    3786 }
    +
    3787
    +
    3788# ifdef RETROFLAT_OS_WIN
    +
    3789 retroflat_draw_release( g_retroflat_state->vdp_buffer );
    +
    3790# endif /* RETROFLAT_OS_WIN */
    +
    3791
    +
    3792cleanup:
    +
    3793 return retval;
    +
    3794}
    +
    3795
    +
    3796# endif /* RETROFLAT_VDP */
    +
    3797
    +
    3798/* === */
    +
    3799
    +
    3800void retroflat_set_title( const char* format, ... ) {
    +
    3801 char title[RETROFLAT_TITLE_MAX + 1];
    +
    3802 va_list vargs;
    +
    3803
    +
    3804 /* Build the title. */
    +
    3805 va_start( vargs, format );
    +
    3806 memset( title, '\0', RETROFLAT_TITLE_MAX + 1 );
    +
    3807 maug_vsnprintf( title, RETROFLAT_TITLE_MAX, format, vargs );
    +
    3808
    +
    3809#if defined( RETROFLAT_API_ALLEGRO )
    +
    3810 set_window_title( title );
    +
    3811#elif defined( RETROFLAT_API_SDL1 )
    +
    3812 SDL_WM_SetCaption( title, NULL );
    +
    3813#elif defined( RETROFLAT_API_SDL2 )
    +
    3814 SDL_SetWindowTitle( g_retroflat_state->window, title );
    +
    3815#elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    3816 SetWindowText( g_retroflat_state->window, title );
    +
    3817#elif defined( RETROFLAT_API_LIBNDS )
    +
    3818 /* Do nothing. */
    +
    3819#elif defined( RETROFLAT_API_GLUT )
    +
    3820 glutSetWindowTitle( title );
    +
    3821#else
    +
    3822# warning "set title implemented"
    +
    3823# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL */
    +
    3824
    +
    3825 va_end( vargs );
    +
    3826}
    +
    3827
    +
    3828/* === */
    +
    3829
    +
    3830uint32_t retroflat_get_ms() {
    +
    3831# if defined( RETROFLAT_API_ALLEGRO )
    +
    3832
    +
    3833 /* == Allegro == */
    +
    3834
    +
    3835 return g_retroflat_state->ms;
    +
    3836
    +
    3837# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    3838
    +
    3839 /* == SDL == */
    +
    3840
    +
    3841 return SDL_GetTicks();
    +
    3842
    +
    3843# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    3844
    +
    3845 return timeGetTime();
    +
    3846
    +
    3847# elif defined( RETROFLAT_API_LIBNDS )
    +
    3848
    +
    3849 /* == libNDS == */
    +
    3850
    +
    3851 return ((TIMER1_DATA * (1 << 16)) + TIMER0_DATA) / 32;
    +
    3852
    +
    3853# elif defined( RETROFLAT_API_GLUT )
    +
    3854
    +
    3855 /* == GLUT == */
    +
    3856
    +
    3857 return glutGet( GLUT_ELAPSED_TIME );
    +
    3858
    +
    3859# else
    +
    3860# warning "get_ms not implemented"
    +
    3861# endif /* RETROFLAT_API_* */
    +
    3862}
    +
    3863
    +
    3864/* === */
    +
    3865
    +
    3866uint32_t retroflat_get_rand() {
    +
    3867 return rand();
    +
    3868}
    +
    3869
    +
    3870/* === */
    +
    3871
    +
    3872int retroflat_draw_lock( struct RETROFLAT_BITMAP* bmp ) {
    +
    3873 int retval = RETROFLAT_OK;
    +
    3874
    +
    3875# if defined( RETROFLAT_OPENGL )
    +
    3876
    +
    3877 if(
    +
    3878 NULL != bmp &&
    +
    3879 &(g_retroflat_state->buffer) != bmp &&
    +
    3880 (MAUG_MHANDLE)NULL != bmp->tex.bytes_h
    +
    3881 ) {
    +
    3882 bmp->flags |= RETROFLAT_FLAGS_LOCK;
    +
    3883 maug_mlock( bmp->tex.bytes_h, bmp->tex.bytes );
    +
    3884 }
    +
    3885
    +
    3886# elif defined( RETROFLAT_API_ALLEGRO )
    +
    3887
    +
    3888 /* == Allegro == */
    +
    3889
    +
    3890 if( NULL != bmp ) {
    +
    3891 /* Normal bitmaps don't need to be locked in allegro. */
    +
    3892 goto cleanup;
    +
    3893 }
    +
    3894
    +
    3895 /* Lock screen for drawing if bmp is NULL. */
    +
    3896
    +
    3897# ifdef RETROFLAT_MOUSE
    +
    3898 /* XXX: Broken in DOS. */
    +
    3899 show_mouse( NULL ); /* Disable mouse before drawing. */
    +
    3900# endif
    +
    3901 acquire_screen();
    +
    3902
    +
    3903cleanup:
    +
    3904
    +
    3905# elif defined( RETROFLAT_API_SDL1 )
    +
    3906
    +
    3907 /* == SDL1 == */
    +
    3908
    +
    3909 /* SDL locking semantics are the opposite of every other platform. See
    +
    3910 * retroflat_px_lock() for a proxy to SDL_LockSurface().
    +
    3911 */
    +
    3912
    +
    3913 if( NULL == bmp || &(g_retroflat_state->buffer) == bmp ) {
    +
    3914 /* Special case: Attempting to lock the screen. */
    +
    3915 bmp = &(g_retroflat_state->buffer);
    +
    3916
    +
    3917 if(
    +
    3918 RETROFLAT_FLAGS_SCREEN_LOCK !=
    +
    3919 (RETROFLAT_FLAGS_SCREEN_LOCK & bmp->flags)
    +
    3920 ) {
    +
    3921 /* Do a perfunctory "screen lock" since programs are supposed to
    +
    3922 * lock the screen before doing any drawing.
    +
    3923 */
    +
    3924 bmp->flags |= RETROFLAT_FLAGS_SCREEN_LOCK;
    +
    3925
    +
    3926 } else {
    +
    3927 /* We actually want to lock the buffer for pixel manipulation. */
    +
    3928 assert( 0 == (RETROFLAT_FLAGS_LOCK & bmp->flags) );
    +
    3929 bmp->flags |= RETROFLAT_FLAGS_LOCK;
    +
    3930 }
    +
    3931
    +
    3932 } else {
    +
    3933 /* Locking a bitmap for pixel drawing. */
    +
    3934 assert( 0 == (RETROFLAT_FLAGS_LOCK & bmp->flags) );
    +
    3935 bmp->flags |= RETROFLAT_FLAGS_LOCK;
    +
    3936 }
    +
    3937
    +
    3938# elif defined( RETROFLAT_API_SDL2 )
    +
    3939
    +
    3940 /* == SDL2 == */
    +
    3941
    +
    3942 if(
    +
    3943 NULL == bmp
    +
    3944# ifdef RETROFLAT_VDP
    +
    3945 && NULL == g_retroflat_state->vdp_buffer
    +
    3946# endif /* RETROFLAT_VDP */
    +
    3947 ) {
    +
    3948
    +
    3949 /* Target is the screen buffer. */
    +
    3950 SDL_SetRenderTarget(
    +
    3951 g_retroflat_state->buffer.renderer,
    +
    3952 g_retroflat_state->buffer.texture );
    +
    3953
    +
    3954 goto cleanup;
    +
    3955
    +
    3956# ifdef RETROFLAT_VDP
    +
    3957 } else if( NULL == bmp && NULL != g_retroflat_state->vdp_buffer ) {
    +
    3958 /* Lock the VDP buffer for drawing. */
    +
    3959 bmp = g_retroflat_state->vdp_buffer;
    +
    3960# endif /* RETROFLAT_VDP */
    +
    3961 }
    +
    3962
    +
    3963 assert( NULL == bmp->renderer );
    +
    3964 assert( NULL != bmp->surface );
    +
    3965 bmp->renderer = SDL_CreateSoftwareRenderer( bmp->surface );
    +
    3966
    +
    3967cleanup:
    +
    3968
    +
    3969# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    3970
    +
    3971 /* == Win16/Win32 == */
    +
    3972
    +
    3973 if( NULL == bmp ) {
    +
    3974# ifdef RETROFLAT_VDP
    +
    3975 if( NULL != g_retroflat_state->vdp_buffer ) {
    +
    3976 bmp = g_retroflat_state->vdp_buffer;
    +
    3977 } else {
    +
    3978# endif
    +
    3979
    +
    3980 /* TODO: Reconcile with VDP! */
    +
    3981 /* The HDC should be created already by WndProc. */
    +
    3982 assert( (HDC)NULL != g_retroflat_state->buffer.hdc_b );
    +
    3983 goto cleanup;
    +
    3984
    +
    3985# ifdef RETROFLAT_VDP
    +
    3986 }
    +
    3987# endif /* RETROFLAT_VDP */
    +
    3988 }
    +
    3989
    +
    3990 /* Sanity check. */
    +
    3991 assert( (HBITMAP)NULL != bmp->b );
    +
    3992 assert( (HDC)NULL == bmp->hdc_b );
    +
    3993
    +
    3994 /* Create HDC for source bitmap compatible with the buffer. */
    +
    3995 bmp->hdc_b = CreateCompatibleDC( (HDC)NULL );
    +
    3996 maug_cleanup_if_null( HDC, bmp->hdc_b, RETROFLAT_ERROR_BITMAP );
    +
    3997
    +
    3998 if( (HBITMAP)NULL != bmp->mask ) {
    +
    3999 /* Create HDC for source mask compatible with the buffer. */
    +
    4000 bmp->hdc_mask = CreateCompatibleDC( (HDC)NULL );
    +
    4001 maug_cleanup_if_null( HDC, bmp->hdc_mask, RETROFLAT_ERROR_BITMAP );
    +
    4002 }
    +
    4003
    +
    4004 /* Select bitmaps into their HDCs. */
    +
    4005 bmp->old_hbm_b = SelectObject( bmp->hdc_b, bmp->b );
    +
    4006 if( (HBITMAP)NULL != bmp->mask ) {
    +
    4007 bmp->old_hbm_mask = SelectObject( bmp->hdc_mask, bmp->mask );
    +
    4008 }
    +
    4009
    +
    4010cleanup:
    +
    4011
    +
    4012# else
    +
    4013# warning "draw lock not implemented"
    +
    4014# endif /* RETROFLAT_API_ALLEGRO */
    +
    4015
    +
    4016 return retval;
    +
    4017}
    +
    4018
    +
    4019/* === */
    +
    4020
    +
    4021MERROR_RETVAL retroflat_draw_release( struct RETROFLAT_BITMAP* bmp ) {
    +
    4022 MERROR_RETVAL retval = MERROR_OK;
    +
    4023
    +
    4024# ifdef RETROFLAT_OPENGL
    +
    4025 if( NULL == bmp || &(g_retroflat_state->buffer) == bmp ) {
    +
    4026 /* Flush GL buffer and swap screen buffers. */
    +
    4027 glFlush();
    +
    4028
    +
    4029# if defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    4030 SDL_GL_SwapBuffers();
    +
    4031# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4032 SwapBuffers( g_retroflat_state->hdc_win );
    +
    4033# elif defined( RETROFLAT_API_GLUT )
    +
    4034 glutSwapBuffers();
    +
    4035# endif
    +
    4036 } else if( retroflat_bitmap_locked( bmp ) ) {
    +
    4037 bmp->flags &= ~RETROFLAT_FLAGS_LOCK;
    +
    4038#ifndef RETROGLU_NO_TEXTURES
    +
    4039 assert( 0 < bmp->tex.id );
    +
    4040 assert( NULL != bmp->tex.bytes );
    +
    4041
    +
    4042 /* Update stored texture if it exists. */
    +
    4043 glBindTexture( GL_TEXTURE_2D, bmp->tex.id );
    +
    4044 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, bmp->tex.w, bmp->tex.h, 0,
    +
    4045 GL_RGBA, GL_UNSIGNED_BYTE, bmp->tex.bytes );
    +
    4046#endif /* !RETROGLU_NO_TEXTURES */
    +
    4047
    +
    4048 /* Unlock texture bitmap. */
    +
    4049 maug_munlock( bmp->tex.bytes_h, bmp->tex.bytes );
    +
    4050 }
    +
    4051
    +
    4052# elif defined( RETROFLAT_API_ALLEGRO )
    +
    4053
    +
    4054 /* == Allegro == */
    +
    4055
    +
    4056 if( NULL != bmp ) {
    +
    4057 /* Don't need to lock bitmaps in Allegro. */
    +
    4058 goto cleanup;
    +
    4059 }
    +
    4060
    +
    4061 /* Flip the buffer. */
    +
    4062 blit( g_retroflat_state->buffer.b, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H );
    +
    4063
    +
    4064 /* Release the screen. */
    +
    4065 release_screen();
    +
    4066# ifdef RETROFLAT_MOUSE
    +
    4067 /* XXX: Broken in DOS. */
    +
    4068 show_mouse( screen ); /* Enable mouse after drawing. */
    +
    4069# endif /* RETROFLAT_MOUSE */
    +
    4070 vsync();
    +
    4071
    +
    4072cleanup:
    +
    4073# elif defined( RETROFLAT_API_SDL1 )
    +
    4074
    +
    4075 /* == SDL1 == */
    +
    4076
    +
    4077 if( NULL == bmp || &(g_retroflat_state->buffer) == bmp ) {
    +
    4078 /* Special case: Attempting to release the (real, non-VDP) screen. */
    +
    4079 bmp = &(g_retroflat_state->buffer);
    +
    4080
    +
    4081 if(
    +
    4082 RETROFLAT_FLAGS_LOCK == (RETROFLAT_FLAGS_LOCK & bmp->flags)
    +
    4083 ) {
    +
    4084 /* The screen was locked for pixel manipulation. */
    +
    4085 bmp->flags &= ~RETROFLAT_FLAGS_LOCK;
    +
    4086 SDL_UnlockSurface( bmp->surface );
    +
    4087
    +
    4088 } else {
    +
    4089 assert(
    +
    4090 RETROFLAT_FLAGS_SCREEN_LOCK ==
    +
    4091 (RETROFLAT_FLAGS_SCREEN_LOCK & bmp->flags) );
    +
    4092 bmp->flags &= ~RETROFLAT_FLAGS_SCREEN_LOCK;
    +
    4093
    +
    4094# if defined( RETROFLAT_VDP )
    +
    4095 retroflat_vdp_call( "retroflat_vdp_flip" );
    +
    4096# endif /* RETROFLAT_VDP */
    +
    4097
    +
    4098 SDL_Flip( bmp->surface );
    +
    4099 }
    +
    4100
    +
    4101 } else {
    +
    4102 /* Releasing a bitmap. */
    +
    4103 assert( RETROFLAT_FLAGS_LOCK == (RETROFLAT_FLAGS_LOCK & bmp->flags) );
    +
    4104 bmp->flags &= ~RETROFLAT_FLAGS_LOCK;
    +
    4105 SDL_UnlockSurface( bmp->surface );
    +
    4106 }
    +
    4107
    +
    4108# elif defined( RETROFLAT_API_SDL2 )
    +
    4109
    +
    4110 /* == SDL2 == */
    +
    4111
    +
    4112 if(
    +
    4113 NULL == bmp
    +
    4114# ifdef RETROFLAT_VDP
    +
    4115 && NULL == g_retroflat_state->vdp_buffer
    +
    4116# endif /* RETROFLAT_VDP */
    +
    4117 ) {
    +
    4118 /* Flip the screen. */
    +
    4119 SDL_SetRenderTarget( g_retroflat_state->buffer.renderer, NULL );
    +
    4120 SDL_RenderCopyEx(
    +
    4121 g_retroflat_state->buffer.renderer,
    +
    4122 g_retroflat_state->buffer.texture, NULL, NULL, 0, NULL, 0 );
    +
    4123 SDL_RenderPresent( g_retroflat_state->buffer.renderer );
    +
    4124
    +
    4125 goto cleanup;
    +
    4126
    +
    4127# ifdef RETROFLAT_VDP
    +
    4128 } else if( NULL == bmp && NULL != g_retroflat_state->vdp_buffer ) {
    +
    4129 bmp = g_retroflat_state->vdp_buffer;
    +
    4130# endif /* RETROFLAT_VDP */
    +
    4131 }
    +
    4132
    +
    4133 /* It's a bitmap. */
    +
    4134
    +
    4135 /* Scrap the software renderer. */
    +
    4136 SDL_RenderPresent( bmp->renderer );
    +
    4137 SDL_DestroyRenderer( bmp->renderer );
    +
    4138 bmp->renderer = NULL;
    +
    4139
    +
    4140 /* Scrap the old texture and recreate it from the updated surface. */
    +
    4141 /* The renderer should be a software renderer pointing to the surface,
    +
    4142 * created in retroflat_lock() above.
    +
    4143 */
    +
    4144 assert( NULL != bmp->texture );
    +
    4145 SDL_DestroyTexture( bmp->texture );
    +
    4146 bmp->texture = SDL_CreateTextureFromSurface(
    +
    4147 g_retroflat_state->buffer.renderer, bmp->surface );
    +
    4148 maug_cleanup_if_null(
    +
    4149 SDL_Texture*, bmp->texture, RETROFLAT_ERROR_BITMAP );
    +
    4150
    +
    4151cleanup:
    +
    4152# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4153
    +
    4154 /* == Win16/Win32 == */
    +
    4155
    +
    4156 if( NULL == bmp ) {
    +
    4157 /* Trigger a screen refresh if this was a screen lock. */
    +
    4158 if( (HWND)NULL != g_retroflat_state->window ) {
    +
    4159 InvalidateRect( g_retroflat_state->window, 0, TRUE );
    +
    4160 }
    +
    4161
    +
    4162# ifdef RETROFLAT_VDP
    +
    4163 if( NULL != g_retroflat_state->vdp_buffer ) {
    +
    4164 bmp = g_retroflat_state->vdp_buffer;
    +
    4165 } else {
    +
    4166# endif
    +
    4167
    +
    4168 /* TODO: Reconcile with VDP! */
    +
    4169 goto cleanup;
    +
    4170
    +
    4171# ifdef RETROFLAT_VDP
    +
    4172 }
    +
    4173# endif
    +
    4174 }
    +
    4175
    +
    4176 /* Unlock the bitmap. */
    +
    4177 if( (HDC)NULL != bmp->hdc_b ) {
    +
    4178 SelectObject( bmp->hdc_b, bmp->old_hbm_b );
    +
    4179 DeleteDC( bmp->hdc_b );
    +
    4180 bmp->hdc_b = (HDC)NULL;
    +
    4181 bmp->old_hbm_b = (HBITMAP)NULL;
    +
    4182 }
    +
    4183
    +
    4184 /* Unlock the mask. */
    +
    4185 if( (HDC)NULL != bmp->hdc_mask ) {
    +
    4186 SelectObject( bmp->hdc_mask, bmp->old_hbm_mask );
    +
    4187 DeleteDC( bmp->hdc_mask );
    +
    4188 bmp->hdc_mask = (HDC)NULL;
    +
    4189 bmp->old_hbm_mask = (HBITMAP)NULL;
    +
    4190 }
    +
    4191
    +
    4192cleanup:
    +
    4193
    +
    4194# else
    +
    4195# warning "draw release not implemented"
    +
    4196# endif /* RETROFLAT_API_ALLEGRO */
    +
    4197
    +
    4198 return retval;
    +
    4199}
    +
    4200
    +
    4201/* === */
    +
    4202
    +
    4203#if defined( RETROFLAT_API_WIN16 ) || defined (RETROFLAT_API_WIN32 )
    +
    4204
    +
    4205static int retroflat_bitmap_win_transparency(
    +
    4206 struct RETROFLAT_BITMAP* bmp_out, int w, int h
    +
    4207) {
    +
    4208 int retval = RETROFLAT_OK;
    +
    4209 unsigned long txp_color = 0;
    +
    4210
    +
    4211 /* Setup bitmap transparency mask. */
    +
    4212 bmp_out->mask = CreateBitmap( w, h, 1, 1, NULL );
    +
    4213 maug_cleanup_if_null( HBITMAP, bmp_out->mask, RETROFLAT_ERROR_BITMAP );
    +
    4214
    +
    4215 retval = retroflat_draw_lock( bmp_out );
    +
    4216 maug_cleanup_if_not_ok();
    +
    4217
    +
    4218 /* Convert the color key into bitmap format. */
    +
    4219 txp_color |= (RETROFLAT_TXP_B & 0xff);
    +
    4220 txp_color <<= 8;
    +
    4221 txp_color |= (RETROFLAT_TXP_G & 0xff);
    +
    4222 txp_color <<= 8;
    +
    4223 txp_color |= (RETROFLAT_TXP_R & 0xff);
    +
    4224 SetBkColor( bmp_out->hdc_b, txp_color );
    +
    4225
    +
    4226 /* Create the mask from the color key. */
    +
    4227 BitBlt(
    +
    4228 bmp_out->hdc_mask, 0, 0, w, h, bmp_out->hdc_b, 0, 0, SRCCOPY );
    +
    4229 BitBlt(
    +
    4230 bmp_out->hdc_b, 0, 0, w, h, bmp_out->hdc_mask, 0, 0, SRCINVERT );
    +
    4231
    +
    4232cleanup:
    +
    4233
    +
    4234 if( RETROFLAT_OK == retval ) {
    +
    4235 retroflat_draw_release( bmp_out );
    +
    4236 }
    +
    4237
    +
    4238 return retval;
    +
    4239}
    +
    4240
    +
    4241#endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4242
    + +
    4244 const char* filename, struct RETROFLAT_BITMAP* bmp_out
    +
    4245) {
    +
    4246 char filename_path[RETROFLAT_PATH_MAX + 1];
    +
    4247 int retval = MERROR_OK;
    +
    4248# if defined( RETROFLAT_OPENGL )
    +
    4249 FILE* bmp_file = NULL;
    +
    4250 uint8_t* bmp_buffer = NULL;
    +
    4251 size_t bmp_buffer_sz = 0,
    +
    4252 bmp_buffer_read = 0;
    +
    4253 MAUG_MHANDLE bmp_buffer_h = (MAUG_MHANDLE)NULL;
    +
    4254 uint32_t bmp_offset = 0;
    +
    4255 size_t i = 0;
    +
    4256# elif defined( RETROFLAT_API_SDL1 )
    +
    4257 SDL_Surface* tmp_surface = NULL;
    +
    4258# elif defined( RETROFLAT_API_WIN16 ) || defined (RETROFLAT_API_WIN32 )
    +
    4259# if defined( RETROFLAT_API_WIN16 )
    +
    4260 char* buf = NULL;
    +
    4261 FILE* bmp_file = NULL;
    +
    4262 long int i, x, y, w, h, colors, offset, sz, read;
    +
    4263# elif defined( RETROFLAT_API_WIN32 )
    +
    4264 BITMAP bm;
    +
    4265# endif /* RETROFLAT_API_WIN32 */
    +
    4266# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4267
    +
    4268 assert( NULL != bmp_out );
    +
    4269
    +
    4270 maug_mzero( bmp_out, sizeof( struct RETROFLAT_BITMAP ) );
    +
    4271
    +
    4272 /* Build the path to the bitmap. */
    +
    4273 memset( filename_path, '\0', RETROFLAT_PATH_MAX + 1 );
    +
    4274 maug_snprintf( filename_path, RETROFLAT_PATH_MAX, "%s%c%s.%s",
    +
    4275 g_retroflat_state->assets_path, RETROFLAT_PATH_SEP,
    +
    4276 filename, RETROFLAT_BITMAP_EXT );
    +
    4277
    +
    4278 debug_printf( 1, "retroflat: loading bitmap: %s", filename_path );
    +
    4279
    +
    4280# ifdef RETROFLAT_OPENGL
    +
    4281
    +
    4282 /* TODO: Create new RGBA texture. */
    +
    4283
    +
    4284 bmp_file = fopen( filename_path, "rb" );
    +
    4285 maug_cleanup_if_null_alloc( FILE*, bmp_file );
    +
    4286
    +
    4287 fseek( bmp_file, 0, SEEK_END );
    +
    4288 bmp_buffer_sz = ftell( bmp_file );
    +
    4289 fseek( bmp_file, 0, SEEK_SET );
    +
    4290
    +
    4291 bmp_buffer_h = maug_malloc( bmp_buffer_sz, 1 );
    +
    4292 maug_cleanup_if_null_alloc( MAUG_MHANDLE, bmp_buffer_h );
    +
    4293
    +
    4294 maug_mlock( bmp_buffer_h, bmp_buffer );
    +
    4295 maug_cleanup_if_null_alloc( uint8_t*, bmp_buffer );
    +
    4296
    +
    4297 bmp_buffer_read = fread( bmp_buffer, 1, bmp_buffer_sz, bmp_file );
    +
    4298 if( bmp_buffer_read < bmp_buffer_sz ) {
    +
    4299 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4300 "Error", "Could not read bitmap file!" );
    +
    4301 retval = MERROR_FILE;
    +
    4302 goto cleanup;
    +
    4303 }
    +
    4304
    +
    4305 /* Offsets hardcoded based on windows bitmap. */
    +
    4306
    +
    4307 /* TODO: Support other bitmap formats? */
    +
    4308 if( 40 != bmp_read_uint32( &(bmp_buffer[0x0e]) ) ) {
    +
    4309 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    4310 "Unable to determine texture bitmap format: %d", bmp_buffer[0x0e] );
    +
    4311 retval = RETROFLAT_ERROR_BITMAP;
    +
    4312 goto cleanup;
    +
    4313 }
    +
    4314
    +
    4315 /* TODO: Setup bitmap header. */
    +
    4316 bmp_offset = bmp_read_uint32( &(bmp_buffer[0x0a]) );
    +
    4317 bmp_out->tex.sz = bmp_buffer_sz - bmp_offset;
    +
    4318 bmp_out->tex.w = bmp_read_uint32( &(bmp_buffer[0x12]) );
    +
    4319 bmp_out->tex.h = bmp_read_uint32( &(bmp_buffer[0x16]) );
    +
    4320 bmp_out->tex.bpp = bmp_read_uint32( &(bmp_buffer[0x1c]) );
    +
    4321 if( 24 != bmp_out->tex.bpp ) {
    +
    4322 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4323 "Error", "Invalid texture bitmap depth: %d",
    +
    4324 bmp_out->tex.bpp );
    +
    4325 retval = RETROFLAT_ERROR_BITMAP;
    +
    4326 goto cleanup;
    +
    4327 }
    +
    4328
    +
    4329 /* Allocate buffer for unpacking. */
    +
    4330 debug_printf( 0, "creating bitmap: " SIZE_T_FMT " x " SIZE_T_FMT,
    +
    4331 bmp_out->tex.w, bmp_out->tex.h );
    +
    4332 bmp_out->tex.bytes_h = maug_malloc( bmp_out->tex.w * bmp_out->tex.h, 4 );
    +
    4333 maug_cleanup_if_null_alloc( MAUG_MHANDLE, bmp_out->tex.bytes_h );
    +
    4334
    +
    4335 maug_mlock( bmp_out->tex.bytes_h, bmp_out->tex.bytes );
    +
    4336 maug_cleanup_if_null_alloc( uint8_t*, bmp_out->tex.bytes );
    +
    4337
    +
    4338 /* Unpack bitmap BGR into BGRA with color key. */
    +
    4339 for( i = 0 ; bmp_out->tex.sz / 3 > i ; i++ ) {
    +
    4340 bmp_out->tex.bytes[i * 4] = bmp_buffer[bmp_offset + (i * 3) + 2];
    +
    4341 bmp_out->tex.bytes[(i * 4) + 1] = bmp_buffer[bmp_offset + (i * 3) + 1];
    +
    4342 bmp_out->tex.bytes[(i * 4) + 2] = bmp_buffer[bmp_offset + (i * 3)];
    +
    4343 if(
    +
    4344 RETROFLAT_TXP_R == bmp_buffer[bmp_offset + (i * 3) + 2] &&
    +
    4345 RETROFLAT_TXP_G == bmp_buffer[bmp_offset + (i * 3) + 1] &&
    +
    4346 RETROFLAT_TXP_B == bmp_buffer[bmp_offset + (i * 3)]
    +
    4347 ) {
    +
    4348 /* Transparent pixel found. */
    +
    4349 bmp_out->tex.bytes[(i * 4) + 3] = 0x00;
    +
    4350 } else {
    +
    4351 bmp_out->tex.bytes[(i * 4) + 3] = 0xff;
    +
    4352 }
    +
    4353 }
    +
    4354
    +
    4355#ifndef RETROGLU_NO_TEXTURES
    +
    4356 glGenTextures( 1, (GLuint*)&(bmp_out->tex.id) );
    +
    4357 glBindTexture( GL_TEXTURE_2D, bmp_out->tex.id );
    +
    4358 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, bmp_out->tex.w, bmp_out->tex.h, 0,
    +
    4359 GL_RGBA, GL_UNSIGNED_BYTE, bmp_out->tex.bytes );
    +
    4360#endif /* !RETROGLU_NO_TEXTURES */
    +
    4361
    +
    4362cleanup:
    +
    4363
    +
    4364 if( NULL != bmp_out->tex.bytes ) {
    +
    4365 maug_munlock( bmp_out->tex.bytes_h, bmp_out->tex.bytes );
    +
    4366 }
    +
    4367
    +
    4368 if( NULL != bmp_buffer ) {
    +
    4369 maug_munlock( bmp_buffer_h, bmp_buffer );
    +
    4370 }
    +
    4371
    +
    4372 if( (MAUG_MHANDLE)NULL != bmp_buffer_h ) {
    +
    4373 maug_mfree( bmp_buffer_h );
    +
    4374 }
    +
    4375
    +
    4376 if( NULL != bmp_file ) {
    +
    4377 fclose( bmp_file );
    +
    4378 }
    +
    4379
    +
    4380# elif defined( RETROFLAT_API_ALLEGRO )
    +
    4381
    +
    4382 /* == Allegro == */
    +
    4383
    +
    4384 bmp_out->b = load_bitmap( filename_path, NULL );
    +
    4385
    +
    4386 /* TODO: maug_cleanup_if_null()? */
    +
    4387 if( NULL == bmp_out->b ) {
    +
    4388 allegro_message( "unable to load %s", filename_path );
    +
    4389 retval = RETROFLAT_ERROR_BITMAP;
    +
    4390 }
    +
    4391
    +
    4392# elif defined( RETROFLAT_API_SDL1 )
    +
    4393
    +
    4394 /* == SDL1 == */
    +
    4395
    +
    4396 tmp_surface = SDL_LoadBMP( filename_path ); /* Free stream on close. */
    +
    4397 /* TODO: maug_cleanup_if_null()? */
    +
    4398 if( NULL == tmp_surface ) {
    +
    4399 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4400 "Error", "SDL unable to load bitmap: %s", SDL_GetError() );
    +
    4401 retval = 0;
    +
    4402 goto cleanup;
    +
    4403 }
    +
    4404
    +
    4405 debug_printf( 1, "loaded bitmap: %d x %d", tmp_surface->w, tmp_surface->h );
    +
    4406
    +
    4407 bmp_out->surface = SDL_DisplayFormat( tmp_surface );
    +
    4408 if( NULL == bmp_out->surface ) {
    +
    4409 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4410 "Error", "SDL unable to load bitmap: %s", SDL_GetError() );
    +
    4411 retval = RETROFLAT_ERROR_BITMAP;
    +
    4412 goto cleanup;
    +
    4413 }
    +
    4414
    +
    4415 debug_printf( 1, "converted bitmap: %d x %d",
    +
    4416 bmp_out->surface->w, bmp_out->surface->h );
    +
    4417
    +
    4418 SDL_SetColorKey( bmp_out->surface, RETROFLAT_SDL_CC_FLAGS,
    +
    4419 SDL_MapRGB( bmp_out->surface->format,
    + +
    4421
    +
    4422cleanup:
    +
    4423
    +
    4424 if( NULL != tmp_surface ) {
    +
    4425 SDL_FreeSurface( tmp_surface );
    +
    4426 }
    +
    4427
    +
    4428# elif defined( RETROFLAT_API_SDL2 )
    +
    4429
    +
    4430 /* == SDL2 == */
    +
    4431
    +
    4432 bmp_out->renderer = NULL;
    +
    4433
    +
    4434 bmp_out->surface = SDL_LoadBMP( filename_path );
    +
    4435
    +
    4436 /* TODO: maug_cleanup_if_null()? */
    +
    4437 if( NULL == bmp_out->surface ) {
    +
    4438 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4439 "Error", "SDL unable to load bitmap: %s", SDL_GetError() );
    +
    4440 retval = RETROFLAT_ERROR_BITMAP;
    +
    4441 goto cleanup;
    +
    4442 }
    +
    4443
    +
    4444 SDL_SetColorKey( bmp_out->surface, RETROFLAT_SDL_CC_FLAGS,
    +
    4445 SDL_MapRGB( bmp_out->surface->format,
    + +
    4447
    +
    4448 bmp_out->texture = SDL_CreateTextureFromSurface(
    +
    4449 g_retroflat_state->buffer.renderer, bmp_out->surface );
    +
    4450 /* TODO: maug_cleanup_if_null()? */
    +
    4451 if( NULL == bmp_out->texture ) {
    +
    4452 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4453 "Error", "SDL unable to create texture: %s", SDL_GetError() );
    +
    4454 retval = RETROFLAT_ERROR_BITMAP;
    +
    4455 if( NULL != bmp_out->surface ) {
    +
    4456 SDL_FreeSurface( bmp_out->surface );
    +
    4457 bmp_out->surface = NULL;
    +
    4458 }
    +
    4459 goto cleanup;
    +
    4460 }
    +
    4461
    +
    4462cleanup:
    +
    4463
    +
    4464# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4465
    +
    4466# if defined( RETROFLAT_API_WIN16 )
    +
    4467
    +
    4468 /* Win16 has a bunch of extra involved steps for getting a bitmap from
    +
    4469 * disk. These cause a crash in Win32.
    +
    4470 */
    +
    4471
    +
    4472 /* == Win16 == */
    +
    4473
    +
    4474 /* Load the bitmap file from disk. */
    +
    4475 bmp_file = fopen( filename_path, "rb" );
    +
    4476 maug_cleanup_if_null_file( bmp_file );
    +
    4477 fseek( bmp_file, 0, SEEK_END );
    +
    4478 sz = ftell( bmp_file );
    +
    4479 fseek( bmp_file, 0, SEEK_SET );
    +
    4480
    +
    4481 buf = calloc( sz, 1 );
    +
    4482 maug_cleanup_if_null_alloc( char*, buf );
    +
    4483
    +
    4484 read = fread( buf, 1, sz, bmp_file );
    +
    4485 assert( read == sz );
    +
    4486
    +
    4487 offset = retroflat_bmp_int( unsigned long, buf, 10 );
    +
    4488 colors = retroflat_bmp_int( int, buf, 46 );
    +
    4489
    +
    4490 /* Avoid a color overflow. */
    +
    4491 if(
    +
    4492 sizeof( BITMAPFILEHEADER ) +
    +
    4493 sizeof( BITMAPINFOHEADER ) +
    +
    4494 (colors * sizeof( RGBQUAD )) > sz
    +
    4495 ) {
    +
    4496 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4497 "Error",
    +
    4498 "Attempted to load bitmap with too many colors!" );
    +
    4499 retval = MERROR_FILE;
    +
    4500 goto cleanup;
    +
    4501 }
    +
    4502
    +
    4503 memcpy( &(bmp_out->bmi),
    +
    4504 &(buf[sizeof( BITMAPFILEHEADER )]),
    +
    4505 /* SetDIBits needs the color palette! */
    +
    4506 sizeof( BITMAPINFOHEADER ) + (colors * sizeof( RGBQUAD )) );
    +
    4507
    +
    4508 /* This never gets the height right? */
    +
    4509 debug_printf( 1, "bitmap w: %08x, h: %08x, colors: %d",
    +
    4510 bmp_out->bmi.header.biWidth, bmp_out->bmi.header.biHeight, colors );
    +
    4511
    +
    4512 assert( 0 < bmp_out->bmi.header.biWidth );
    +
    4513 assert( 0 < bmp_out->bmi.header.biHeight );
    +
    4514 assert( 0 == bmp_out->bmi.header.biWidth % 8 );
    +
    4515 assert( 0 == bmp_out->bmi.header.biHeight % 8 );
    +
    4516
    +
    4517 bmp_out->b = CreateCompatibleBitmap( g_retroflat_state->hdc_win,
    +
    4518 bmp_out->bmi.header.biWidth, bmp_out->bmi.header.biHeight );
    +
    4519 maug_cleanup_if_null( HBITMAP, bmp_out->b, RETROFLAT_ERROR_BITMAP );
    +
    4520
    +
    4521 /* Turn the bits into a bitmap. */
    +
    4522 SetDIBits( g_retroflat_state->hdc_win, bmp_out->b, 0,
    +
    4523 bmp_out->bmi.header.biHeight, &(buf[offset]),
    +
    4524 (BITMAPINFO*)&(bmp_out->bmi),
    +
    4525 DIB_RGB_COLORS );
    +
    4526
    +
    4527 retval = retroflat_bitmap_win_transparency( bmp_out,
    +
    4528 bmp_out->bmi.header.biWidth, bmp_out->bmi.header.biHeight );
    +
    4529
    +
    4530# else
    +
    4531
    +
    4532 /* Win32 greatly simplifies the loading portion. */
    +
    4533
    +
    4534 /* == Win32 == */
    +
    4535
    +
    4536# ifdef RETROFLAT_API_WINCE
    +
    4537 bmp_out->b = SHLoadDIBitmap( filename_path );
    +
    4538# else
    +
    4539 bmp_out->b = LoadImage(
    +
    4540 NULL, filename_path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
    +
    4541# endif /* RETROFLAT_API_WINCE */
    +
    4542 maug_cleanup_if_null_msg(
    +
    4543 HBITMAP, bmp_out->b, MERROR_FILE, "failed to open FILE!" )
    +
    4544
    +
    4545 GetObject( bmp_out->b, sizeof( BITMAP ), &bm );
    +
    4546
    +
    4547 bmp_out->bmi.header.biSize = sizeof( BITMAPINFOHEADER );
    +
    4548 bmp_out->bmi.header.biCompression = BI_RGB;
    +
    4549 bmp_out->bmi.header.biWidth = bm.bmWidth;
    +
    4550 bmp_out->bmi.header.biHeight = bm.bmHeight;
    +
    4551 bmp_out->bmi.header.biPlanes = bm.bmPlanes;
    +
    4552 bmp_out->bmi.header.biBitCount = bm.bmBitsPixel;
    +
    4553 bmp_out->bmi.header.biSizeImage =
    +
    4554 bmp_out->bmi.header.biWidth *
    +
    4555 bmp_out->bmi.header.biHeight *
    +
    4556 (bm.bmBitsPixel / sizeof( uint8_t ));
    +
    4557
    +
    4558 /*
    +
    4559 GetDIBits( g_retroflat_state->hdc_win, bmp_out->b, 0, 0, NULL,
    +
    4560 (BITMAPINFO*)&(bmp_out->bmi), DIB_RGB_COLORS );
    +
    4561
    +
    4562 assert( 1 == bmp_out->bmi.header.biPlanes );
    +
    4563 assert( bmp_out->w == bmp_out->bmi.header.biWidth );
    +
    4564 assert( bmp_out->h == bmp_out->bmi.header.biHeight );
    +
    4565 */
    +
    4566
    +
    4567 retval = retroflat_bitmap_win_transparency(
    +
    4568 bmp_out, bm.bmWidth, bm.bmHeight );
    +
    4569
    +
    4570# endif /* RETROFLAT_API_WIN16 */
    +
    4571
    +
    4572 /* The transparency portion is the same for Win32 and Win16. */
    +
    4573
    +
    4574cleanup:
    +
    4575
    +
    4576# ifdef RETROFLAT_API_WIN16
    +
    4577 if( NULL != buf ) {
    +
    4578 free( buf );
    +
    4579 }
    +
    4580
    +
    4581 if( NULL != bmp_file ) {
    +
    4582 fclose( bmp_file );
    +
    4583 }
    +
    4584
    +
    4585# endif /* RETROFLAT_API_WIN16 */
    +
    4586
    +
    4587# else
    +
    4588# warning "load bitmap not implemented"
    +
    4589# endif /* RETROFLAT_API_ALLEGRO */
    +
    4590
    +
    4591 return retval;
    +
    4592}
    +
    4593
    +
    4594/* === */
    +
    4595
    +
    4596MERROR_RETVAL retroflat_create_bitmap(
    +
    4597 size_t w, size_t h, struct RETROFLAT_BITMAP* bmp_out, uint8_t flags
    +
    4598) {
    +
    4599 MERROR_RETVAL retval = MERROR_OK;
    +
    4600# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4601 int i = 0;
    +
    4602 PALETTEENTRY palette[RETROFLAT_BMP_COLORS_SZ_MAX];
    +
    4603# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4604
    +
    4605 maug_mzero( bmp_out, sizeof( struct RETROFLAT_BITMAP ) );
    +
    4606
    +
    4607 bmp_out->sz = sizeof( struct RETROFLAT_BITMAP );
    +
    4608
    +
    4609# if defined( RETROFLAT_OPENGL )
    +
    4610
    +
    4611 bmp_out->tex.w = w;
    +
    4612 bmp_out->tex.h = h;
    +
    4613 /* TODO: Overflow checking. */
    +
    4614 debug_printf( 0, "creating bitmap: " SIZE_T_FMT " x " SIZE_T_FMT,
    +
    4615 bmp_out->tex.w, bmp_out->tex.h );
    +
    4616 bmp_out->tex.bytes_h = maug_malloc( bmp_out->tex.w * bmp_out->tex.h, 4 );
    +
    4617 maug_cleanup_if_null_alloc( MAUG_MHANDLE, bmp_out->tex.bytes_h );
    +
    4618
    +
    4619 maug_mlock( bmp_out->tex.bytes_h, bmp_out->tex.bytes );
    +
    4620 maug_cleanup_if_null_alloc( uint8_t*, bmp_out->tex.bytes );
    +
    4621
    +
    4622 /* TODO: Overflow checking. */
    +
    4623 maug_mzero(
    +
    4624 bmp_out->tex.bytes,
    +
    4625 bmp_out->tex.w * bmp_out->tex.h * sizeof( uint32_t ) );
    +
    4626
    +
    4627# ifndef RETROGLU_NO_TEXTURES
    +
    4628 glGenTextures( 1, (GLuint*)&(bmp_out->tex.id) );
    +
    4629# endif /* !RETROGLU_NO_TEXTURES */
    +
    4630
    +
    4631cleanup:
    +
    4632 if( NULL != bmp_out->tex.bytes ) {
    +
    4633 maug_munlock( bmp_out->tex.bytes_h, bmp_out->tex.bytes );
    +
    4634 }
    +
    4635# elif defined( RETROFLAT_API_ALLEGRO )
    +
    4636
    +
    4637 /* == Allegro == */
    +
    4638
    +
    4639 bmp_out->b = create_bitmap( w, h );
    +
    4640 maug_cleanup_if_null( BITMAP*, bmp_out->b, RETROFLAT_ERROR_BITMAP );
    +
    4641 clear_bitmap( bmp_out->b );
    +
    4642
    +
    4643cleanup:
    +
    4644# elif defined( RETROFLAT_API_SDL1 )
    +
    4645
    +
    4646 /* == SDL1 == */
    +
    4647
    +
    4648 bmp_out->surface = SDL_CreateRGBSurface( 0, w, h,
    +
    4649 32, 0, 0, 0, 0 );
    +
    4650 maug_cleanup_if_null(
    +
    4651 SDL_Surface*, bmp_out->surface, RETROFLAT_ERROR_BITMAP );
    + +
    4653 SDL_SetColorKey( bmp_out->surface, RETROFLAT_SDL_CC_FLAGS,
    +
    4654 SDL_MapRGB( bmp_out->surface->format,
    + +
    4656 }
    +
    4657
    +
    4658cleanup:
    +
    4659# elif defined( RETROFLAT_API_SDL2 )
    +
    4660
    +
    4661 /* == SDL2 == */
    +
    4662
    +
    4663 /* TODO: Handle opaque flag. */
    +
    4664
    +
    4665 /* Create surface. */
    +
    4666 bmp_out->surface = SDL_CreateRGBSurface( 0, w, h,
    +
    4667 /* TODO: Are these masks right? */
    +
    4668 32, 0, 0, 0, 0 );
    +
    4669 maug_cleanup_if_null(
    +
    4670 SDL_Surface*, bmp_out->surface, RETROFLAT_ERROR_BITMAP );
    +
    4671 SDL_SetColorKey( bmp_out->surface, RETROFLAT_SDL_CC_FLAGS,
    +
    4672 SDL_MapRGB( bmp_out->surface->format,
    + +
    4674
    +
    4675 /* Convert new surface to texture. */
    +
    4676 bmp_out->texture = SDL_CreateTextureFromSurface(
    +
    4677 g_retroflat_state->buffer.renderer, bmp_out->surface );
    +
    4678 maug_cleanup_if_null(
    +
    4679 SDL_Texture*, bmp_out->texture, RETROFLAT_ERROR_BITMAP );
    +
    4680
    +
    4681cleanup:
    +
    4682# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4683
    +
    4684 /* == Win16 / Win32 == */
    +
    4685
    +
    4686 /* TODO: Handle opaque flag. */
    +
    4687 bmp_out->mask = (HBITMAP)NULL;
    +
    4688
    +
    4689# ifdef RETROFLAT_WING
    +
    4690 /* Put this first because WinGRecommendDIBFormat sets some header props. */
    +
    4691 if(
    + + +
    4694 (WinGCreateDC_t)NULL != g_w.WinGCreateDC &&
    +
    4695 (WinGRecommendDIBFormat_t)NULL != g_w.WinGRecommendDIBFormat
    +
    4696 ) {
    +
    4697 bmp_out->hdc_b = g_w.WinGCreateDC();
    +
    4698
    +
    4699 if( !g_w.WinGRecommendDIBFormat( (BITMAPINFO far*)&(bmp_out->bmi) ) ) {
    +
    4700 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    4701 "Error", "Could not determine recommended format!" );
    +
    4702 retval = RETROFLAT_ERROR_GRAPHICS;
    +
    4703 goto cleanup;
    +
    4704 }
    +
    4705 }
    +
    4706# endif /* RETROFLAT_WING */
    +
    4707
    +
    4708 debug_printf( 0, "creating bitmap..." );
    +
    4709
    +
    4710 bmp_out->bmi.header.biSize = sizeof( BITMAPINFOHEADER );
    +
    4711 bmp_out->bmi.header.biPlanes = 1;
    +
    4712 bmp_out->bmi.header.biCompression = BI_RGB;
    +
    4713 bmp_out->bmi.header.biWidth = w;
    +
    4714# ifdef RETROFLAT_WING
    +
    4715 bmp_out->bmi.header.biHeight *= h;
    +
    4716# else
    +
    4717 bmp_out->bmi.header.biHeight = h;
    +
    4718# endif /* RETROFLAT_WING */
    +
    4719 bmp_out->bmi.header.biBitCount = 32;
    +
    4720 bmp_out->bmi.header.biSizeImage = w * h * 4;
    +
    4721
    +
    4722 GetSystemPaletteEntries(
    +
    4723 g_retroflat_state->hdc_win, 0, RETROFLAT_BMP_COLORS_SZ_MAX, palette );
    +
    4724 for( i = 0 ; RETROFLAT_BMP_COLORS_SZ_MAX > i ; i++ ) {
    +
    4725 bmp_out->bmi.colors[i].rgbRed = palette[i].peRed;
    +
    4726 bmp_out->bmi.colors[i].rgbGreen = palette[i].peGreen;
    +
    4727 bmp_out->bmi.colors[i].rgbBlue = palette[i].peBlue;
    +
    4728 bmp_out->bmi.colors[i].rgbReserved = 0;
    +
    4729 }
    +
    4730
    +
    4731# ifdef RETROFLAT_WING
    +
    4732 /* Now try to create the WinG bitmap using the header we've built. */
    +
    4733 if(
    + + +
    4736 (WinGCreateBitmap_t)NULL != g_w.WinGCreateBitmap
    +
    4737 ) {
    +
    4738 /* Setup an optimal WinG hardware screen buffer bitmap. */
    +
    4739 debug_printf( 1, "creating WinG-backed bitmap..." );
    +
    4740
    + +
    4742 bmp_out->b = g_w.WinGCreateBitmap(
    +
    4743 bmp_out->hdc_b,
    +
    4744 (BITMAPINFO far*)(&bmp_out->bmi),
    +
    4745 (void far*)&(bmp_out->bits) );
    +
    4746
    +
    4747 debug_printf( 1, "WinG bitmap bits: %p", bmp_out->bits );
    +
    4748
    +
    4749 } else {
    +
    4750# endif /* RETROFLAT_WING */
    +
    4751
    +
    4752 bmp_out->b = CreateCompatibleBitmap( g_retroflat_state->hdc_win, w, h );
    +
    4753 maug_cleanup_if_null( HBITMAP, bmp_out->b, RETROFLAT_ERROR_BITMAP );
    +
    4754
    +
    4755 if(
    + +
    4757 ) {
    +
    4758 debug_printf( 1, "creating screen device context..." );
    +
    4759 bmp_out->hdc_b = CreateCompatibleDC( g_retroflat_state->hdc_win );
    +
    4760 bmp_out->old_hbm_b = SelectObject( bmp_out->hdc_b, bmp_out->b );
    +
    4761 }
    +
    4762
    +
    4763# ifdef RETROFLAT_WING
    +
    4764 }
    +
    4765# endif /* RETROFLAT_WING */
    +
    4766
    +
    4767cleanup:
    +
    4768
    +
    4769# else
    +
    4770# warning "create bitmap not implemented"
    +
    4771# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4772
    +
    4773 return retval;
    +
    4774}
    +
    4775
    +
    4776/* === */
    +
    4777
    +
    4778#ifdef RETROFLAT_XPM
    +
    4779
    + +
    4781 const char* filename, struct RETROFLAT_BITMAP* bmp_out
    +
    4782) {
    +
    4783 MERROR_RETVAL retval = MERROR_OK;
    +
    4784 RETROFLAT_COLOR color;
    +
    4785 int xpm_idx = 0,
    +
    4786 x = 0,
    +
    4787 y = 0,
    +
    4788 bmp_w = 0,
    +
    4789 bmp_h = 0,
    +
    4790 bmp_colors,
    +
    4791 bmp_bypp;
    +
    4792
    +
    4793 /* Hunt for the requested XPM in the compiled directory. */
    +
    4794 while( '\0' != gc_xpm_filenames[xpm_idx][0] ) {
    +
    4795 if( 0 == strcmp( filename, gc_xpm_filenames[xpm_idx] ) ) {
    +
    4796 goto xpm_found;
    +
    4797 }
    +
    4798 xpm_idx++;
    +
    4799 }
    +
    4800
    +
    4801 retval = RETROFLAT_ERROR_BITMAP;
    +
    4802 goto cleanup;
    +
    4803
    +
    4804xpm_found:
    +
    4805
    +
    4806 debug_printf( 2, "found xpm: %s", gc_xpm_filenames[xpm_idx] );
    +
    4807
    +
    4808 /* Load XPM and draw it to a new bitmap. */
    +
    4809
    +
    4810 sscanf( gc_xpm_data[xpm_idx][0], "%d %d %d %d",
    +
    4811 &bmp_w, &bmp_h, &bmp_colors, &bmp_bypp );
    +
    4812
    +
    4813 assert( 16 == bmp_colors );
    +
    4814 assert( 1 == bmp_bypp );
    +
    4815
    +
    4816 retval = retroflat_create_bitmap( bmp_w, bmp_h, bmp_out, 0 );
    +
    4817 if( MERROR_OK != retval ) {
    +
    4818 goto cleanup;
    +
    4819 }
    +
    4820
    +
    4821 debug_printf( 1, "created empty canvas: %dx%d", bmp_w, bmp_h );
    +
    4822
    +
    4823 /* Draw XPM pixels to canvas. */
    +
    4824
    +
    4825 /* Normally draw lock is called from the main loop, but we're making an
    +
    4826 * off-screen bitmap, here!
    +
    4827 */
    +
    4828 retroflat_draw_lock( bmp_out );
    +
    4829 retroflat_px_lock( bmp_out );
    +
    4830
    +
    4831 for( y = 0 ; bmp_h > y ; y++ ) {
    +
    4832 for( x = 0 ; bmp_w > x ; x++ ) {
    +
    4833 switch( gc_xpm_data[xpm_idx][17 + y][x] ) {
    +
    4834 case ' ':
    +
    4835 /* Transparent. */
    +
    4836 continue;
    +
    4837 case '.':
    +
    4838 color = RETROFLAT_COLOR_DARKBLUE;
    +
    4839 break;
    +
    4840 case 'X':
    +
    4841 color = RETROFLAT_COLOR_DARKGREEN;
    +
    4842 break;
    +
    4843 case 'o':
    +
    4844 color = RETROFLAT_COLOR_TEAL;
    +
    4845 break;
    +
    4846 case 'O':
    +
    4847 color = RETROFLAT_COLOR_DARKRED;
    +
    4848 break;
    +
    4849 case '+':
    +
    4850 color = RETROFLAT_COLOR_VIOLET;
    +
    4851 break;
    +
    4852 case '@':
    +
    4853 color = RETROFLAT_COLOR_BROWN;
    +
    4854 break;
    +
    4855 case '#':
    +
    4856 color = RETROFLAT_COLOR_GRAY;
    +
    4857 break;
    +
    4858 case '$':
    +
    4859 color = RETROFLAT_COLOR_DARKGRAY;
    +
    4860 break;
    +
    4861 case '%':
    +
    4862 color = RETROFLAT_COLOR_BLUE;
    +
    4863 break;
    +
    4864 case '&':
    +
    4865 color = RETROFLAT_COLOR_GREEN;
    +
    4866 break;
    +
    4867 case '*':
    +
    4868 color = RETROFLAT_COLOR_CYAN;
    +
    4869 break;
    +
    4870 case '=':
    +
    4871 color = RETROFLAT_COLOR_RED;
    +
    4872 break;
    +
    4873 case '-':
    +
    4874 color = RETROFLAT_COLOR_MAGENTA;
    +
    4875 break;
    +
    4876 case ';':
    +
    4877 color = RETROFLAT_COLOR_YELLOW;
    +
    4878 break;
    +
    4879 case ':':
    +
    4880 color = RETROFLAT_COLOR_WHITE;
    +
    4881 break;
    +
    4882 }
    +
    4883
    +
    4884 retroflat_px( bmp_out, color, x, y, 0 );
    +
    4885 }
    +
    4886 }
    +
    4887
    +
    4888 retroflat_px_release( bmp_out );
    +
    4889 retroflat_draw_release( bmp_out );
    +
    4890
    +
    4891cleanup:
    +
    4892 return retval;
    +
    4893}
    +
    4894
    +
    4895/* === */
    +
    4896
    +
    4897#endif /* RETROFLAT_XPM */
    +
    4898
    +
    4899void retroflat_destroy_bitmap( struct RETROFLAT_BITMAP* bmp ) {
    +
    4900
    +
    4901# if defined( RETROFLAT_OPENGL )
    +
    4902
    +
    4903 if( NULL != bmp->tex.bytes_h ) {
    +
    4904 if( NULL != bmp->tex.bytes ) {
    +
    4905 maug_munlock( bmp->tex.bytes_h, bmp->tex.bytes );
    +
    4906 }
    +
    4907
    +
    4908 maug_mfree( bmp->tex.bytes_h );
    +
    4909 }
    +
    4910
    +
    4911# elif defined( RETROFLAT_API_ALLEGRO )
    +
    4912
    +
    4913 /* == Allegro == */
    +
    4914
    +
    4915 if( NULL == bmp->b ) {
    +
    4916 return;
    +
    4917 }
    +
    4918
    +
    4919 destroy_bitmap( bmp->b );
    +
    4920 bmp->b = NULL;
    +
    4921
    +
    4922# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    4923
    +
    4924 assert( NULL != bmp );
    +
    4925 assert( NULL != bmp->surface );
    +
    4926
    +
    4927# ifndef RETROFLAT_API_SDL1
    +
    4928 assert( NULL != bmp->texture );
    +
    4929
    +
    4930 SDL_DestroyTexture( bmp->texture );
    +
    4931 bmp->texture = NULL;
    +
    4932# endif /* !RETROFLAT_API_SDL1 */
    +
    4933
    +
    4934 SDL_FreeSurface( bmp->surface );
    +
    4935 bmp->surface = NULL;
    +
    4936
    +
    4937# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4938
    +
    4939 /* == Win16 == */
    +
    4940
    +
    4941 if( NULL != bmp->old_hbm_b ) {
    +
    4942 SelectObject( bmp->hdc_b, bmp->old_hbm_b );
    +
    4943 bmp->old_hbm_b = NULL;
    +
    4944 bmp->old_hbm_b = (HBITMAP)NULL;
    +
    4945 }
    +
    4946
    +
    4947 if( (HBITMAP)NULL != bmp->b ) {
    +
    4948 DeleteObject( bmp->b );
    +
    4949 bmp->b = (HBITMAP)NULL;
    +
    4950 }
    +
    4951
    +
    4952 if( (HBITMAP)NULL != bmp->mask ) {
    +
    4953 DeleteObject( bmp->mask );
    +
    4954 bmp->mask = (HBITMAP)NULL;
    +
    4955 }
    +
    4956
    +
    4957# else
    +
    4958# warning "destroy bitmap not implemented"
    +
    4959# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4960}
    +
    4961
    +
    4962/* === */
    +
    4963
    + +
    4965 struct RETROFLAT_BITMAP* target, struct RETROFLAT_BITMAP* src,
    +
    4966 int s_x, int s_y, int d_x, int d_y, int w, int h
    +
    4967) {
    +
    4968# if defined( RETROFLAT_OPENGL )
    +
    4969 size_t y_iter = 0;
    +
    4970# elif defined( RETROFLAT_API_SDL1 ) && !defined( RETROFLAT_OPENGL )
    +
    4971 MERROR_RETVAL retval = MERROR_OK;
    +
    4972 SDL_Rect src_rect;
    +
    4973 SDL_Rect dest_rect;
    +
    4974# elif defined( RETROFLAT_API_SDL2 )
    +
    4975 MERROR_RETVAL retval = MERROR_OK;
    +
    4976 SDL_Rect src_rect = { s_x, s_y, w, h };
    +
    4977 SDL_Rect dest_rect = { d_x, d_y, w, h };
    +
    4978# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    4979 MERROR_RETVAL retval = MERROR_OK;
    +
    4980 int locked_src_internal = 0;
    +
    4981 int locked_target_internal = 0;
    +
    4982# endif /* RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    4983
    +
    4984# ifndef RETROFLAT_OPENGL
    +
    4985 if( NULL == target ) {
    +
    4986 target = retroflat_screen_buffer();
    +
    4987 }
    +
    4988# endif /* RETROFLAT_OPENGL */
    +
    4989
    +
    4990 assert( NULL != src );
    +
    4991
    +
    4992# if defined( RETROFLAT_OPENGL )
    +
    4993
    +
    4994 if( NULL == target || retroflat_screen_buffer() == target ) {
    +
    4995 /* TODO: Create ortho sprite on screen. */
    +
    4996
    +
    4997 } else {
    +
    4998 /* Blit to texture. */
    +
    4999
    +
    5000 assert( NULL != target->tex.bytes );
    +
    5001
    +
    5002 /* TODO: Some kind of source-autolock? */
    +
    5003 assert( !retroflat_bitmap_locked( src ) );
    +
    5004 maug_mlock( src->tex.bytes_h, src->tex.bytes );
    +
    5005 for( y_iter = 0 ; h > y_iter ; y_iter++ ) {
    +
    5006 /* TODO: Handle transparency! */
    +
    5007 memcpy(
    +
    5008 &(target->tex.bytes[(((y_iter * target->tex.w) + d_x) * 4)]),
    +
    5009 &(src->tex.bytes[(((y_iter * src->tex.w) + s_x) * 4)]),
    +
    5010 w * 4 );
    +
    5011 }
    +
    5012 maug_munlock( src->tex.bytes_h, src->tex.bytes );
    +
    5013
    +
    5014 }
    +
    5015
    +
    5016# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5017
    +
    5018 /* == Allegro == */
    +
    5019
    +
    5020 assert( NULL != target->b );
    +
    5021 assert( NULL != src->b );
    +
    5022
    +
    5023 if(
    +
    5024 0 == s_x && 0 == s_y &&
    +
    5025 ((-1 == w && -1 == h ) || (src->b->w == w && src->b->h == h))
    +
    5026 ) {
    +
    5027 draw_sprite( target->b, src->b, d_x, d_y );
    +
    5028 } else {
    +
    5029 /* Handle partial blit. */
    +
    5030 blit( src->b, target->b, s_x, s_y, d_x, d_y, w, h );
    +
    5031 }
    +
    5032
    +
    5033# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    5034
    +
    5035 /* == SDL == */
    +
    5036
    +
    5037 src_rect.x = s_x;
    +
    5038 src_rect.y = s_y;
    +
    5039 src_rect.w = w;
    +
    5040 src_rect.h = h;
    +
    5041 dest_rect.x = d_x;
    +
    5042 dest_rect.y = d_y;
    +
    5043 dest_rect.w = w;
    +
    5044 dest_rect.h = h;
    +
    5045
    +
    5046# ifdef RETROFLAT_API_SDL1
    +
    5047 assert( 0 == src->autolock_refs );
    +
    5048 assert( 0 == target->autolock_refs );
    +
    5049 retval =
    +
    5050 SDL_BlitSurface( src->surface, &src_rect, target->surface, &dest_rect );
    +
    5051 if( 0 != retval ) {
    +
    5052 error_printf( "could not blit surface: %s", SDL_GetError() );
    +
    5053 }
    +
    5054# else
    +
    5055
    +
    5056 assert( retroflat_bitmap_locked( target ) );
    +
    5057 retval = SDL_RenderCopy(
    +
    5058 target->renderer, src->texture, &src_rect, &dest_rect );
    +
    5059 if( 0 != retval ) {
    +
    5060 error_printf( "could not blit surface: %s", SDL_GetError() );
    +
    5061 }
    +
    5062
    +
    5063# endif /* !RETROFLAT_API_SDL1 */
    +
    5064
    +
    5065# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5066
    +
    5067 /* == Win16/Win32 == */
    +
    5068
    +
    5069 assert( (HBITMAP)NULL != target->b );
    +
    5070 assert( (HBITMAP)NULL != src->b );
    +
    5071
    +
    5072 retroflat_internal_autolock_bitmap( src, locked_src_internal );
    +
    5073 assert( retroflat_bitmap_locked( target ) );
    +
    5074
    +
    5075 if( (HBITMAP)NULL != src->mask ) {
    +
    5076 /* Use mask to blit transparency. */
    +
    5077 BitBlt(
    +
    5078 target->hdc_b, d_x, d_y, w, h, src->hdc_mask, s_x, s_y, SRCAND );
    +
    5079 }
    +
    5080
    +
    5081 /* Do actual blit. */
    +
    5082 BitBlt(
    +
    5083 target->hdc_b, d_x, d_y, w, h, src->hdc_b, s_x, s_y, SRCPAINT );
    +
    5084
    +
    5085cleanup:
    +
    5086
    +
    5087 if( locked_src_internal ) {
    +
    5088 retroflat_draw_release( src );
    +
    5089 }
    +
    5090
    +
    5091# else
    +
    5092# warning "blit bitmap not implemented"
    +
    5093# endif /* RETROFLAT_API_ALLEGRO */
    +
    5094 return;
    +
    5095}
    +
    5096
    +
    5097/* === */
    +
    5098
    +
    5099void retroflat_px(
    +
    5100 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color_idx,
    +
    5101 int x, int y, uint8_t flags
    +
    5102) {
    +
    5103# if defined( RETROFLAT_OPENGL )
    +
    5104# elif defined( RETROFLAT_API_SDL1 )
    +
    5105 int offset = 0;
    +
    5106 uint8_t* px_1 = NULL;
    +
    5107 uint16_t* px_2 = NULL;
    +
    5108 uint32_t* px_4 = NULL;
    +
    5109 RETROFLAT_COLOR_DEF* color = &(g_retroflat_state->palette[color_idx]);
    +
    5110# elif defined( RETROFLAT_API_SDL2 )
    +
    5111 RETROFLAT_COLOR_DEF* color = &(g_retroflat_state->palette[color_idx]);
    +
    5112# endif /* RETROFLAT_API_SDL1 */
    +
    5113
    +
    5114 if( RETROFLAT_COLOR_NULL == color_idx ) {
    +
    5115 return;
    +
    5116 }
    +
    5117
    +
    5118 if( NULL == target ) {
    +
    5119 target = retroflat_screen_buffer();
    +
    5120 }
    +
    5121
    +
    5122 if(
    +
    5123 x < 0 || x >= retroflat_screen_w() ||
    +
    5124 y < 0 || y >= retroflat_screen_h()
    +
    5125 ) {
    +
    5126 return;
    +
    5127 }
    +
    5128
    +
    5129# if defined( RETROFLAT_OPENGL )
    +
    5130
    +
    5131 assert( NULL != target->tex.bytes );
    +
    5132 assert( retroflat_bitmap_locked( target ) );
    +
    5133
    +
    5134 target->tex.bytes[(((y * target->tex.w) + x) * 4) + 0] =
    +
    5135 g_retroflat_state->tex_palette[color_idx][0];
    +
    5136 target->tex.bytes[(((y * target->tex.w) + x) * 4) + 1] =
    +
    5137 g_retroflat_state->tex_palette[color_idx][1];
    +
    5138 target->tex.bytes[(((y * target->tex.w) + x) * 4) + 2] =
    +
    5139 g_retroflat_state->tex_palette[color_idx][2];
    +
    5140 target->tex.bytes[(((y * target->tex.w) + x) * 4) + 3] = 0xff;
    +
    5141
    +
    5142# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5143
    +
    5144 /* == Allegro == */
    +
    5145
    +
    5146 putpixel( target->b, x, y, g_retroflat_state->palette[color_idx] );
    +
    5147
    +
    5148# elif defined( RETROFLAT_API_SDL1 )
    +
    5149
    +
    5150 /* == SDL1 == */
    +
    5151
    +
    5152 retroflat_px_lock( target );
    +
    5153
    +
    5154 assert( 0 < target->autolock_refs );
    +
    5155
    +
    5156 offset = (y * target->surface->pitch) +
    +
    5157 (x * target->surface->format->BytesPerPixel);
    +
    5158
    +
    5159 switch( target->surface->format->BytesPerPixel ) {
    +
    5160 case 4:
    +
    5161 px_4 = (uint32_t*)&(((uint8_t*)(target->surface->pixels))[offset]);
    +
    5162 *px_4 =
    +
    5163 SDL_MapRGB( target->surface->format, color->r, color->g, color->b );
    +
    5164 break;
    +
    5165
    +
    5166 case 2:
    +
    5167 px_2 = (uint16_t*)&(((uint8_t*)(target->surface->pixels))[offset]);
    +
    5168 *px_2 =
    +
    5169 SDL_MapRGB( target->surface->format, color->r, color->g, color->b );
    +
    5170 break;
    +
    5171
    +
    5172 case 1:
    +
    5173 px_1 = (uint8_t*)&(((uint8_t*)(target->surface->pixels))[offset]);
    +
    5174 *px_1 =
    +
    5175 SDL_MapRGB( target->surface->format, color->r, color->g, color->b );
    +
    5176 break;
    +
    5177 }
    +
    5178
    +
    5179 retroflat_px_release( target );
    +
    5180
    +
    5181# elif defined( RETROFLAT_API_SDL2 )
    +
    5182
    +
    5183 /* == SDL2 == */
    +
    5184
    +
    5185 assert( retroflat_bitmap_locked( target ) );
    +
    5186
    +
    5187 SDL_SetRenderDrawColor(
    +
    5188 target->renderer, color->r, color->g, color->b, 255 );
    +
    5189 SDL_RenderDrawPoint( target->renderer, x, y );
    +
    5190
    +
    5191# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5192
    +
    5193 /* == Win16/Win32 == */
    +
    5194
    +
    5195 assert( retroflat_bitmap_locked( target ) );
    +
    5196
    +
    5197# ifdef RETROFLAT_WING
    +
    5198 if( NULL != target->bits ) {
    +
    5199 /* Modify target bits directly (faster) if available! */
    +
    5200 /* WinG bitmaps are 8-bit palettized, so use the index directly. */
    +
    5201 if( 0 > target->h ) {
    +
    5202 target->bits[((target->h - 1 - y) * target->tex.w) + x] =
    +
    5203 color_idx;
    +
    5204 } else {
    +
    5205 target->bits[(y * target->tex.w) + x] =
    +
    5206 color_idx;
    +
    5207 }
    +
    5208 } else {
    +
    5209 /* Use slow Windows GDI. */
    +
    5210 SetPixel( target->hdc_b, x, y,
    +
    5211 g_retroflat_state->palette[color_idx] );
    +
    5212 }
    +
    5213# else
    +
    5214 SetPixel( target->hdc_b, x, y,
    +
    5215 g_retroflat_state->palette[color_idx] );
    +
    5216# endif /* RETROFLAT_WING */
    +
    5217
    +
    5218# elif defined( RETROFLAT_API_LIBNDS )
    +
    5219
    +
    5220 /* == Nintendo DS == */
    +
    5221
    +
    5222 uint16_t* px_ptr = NULL;
    +
    5223
    +
    5224 px_ptr = bgGetGfxPtr( g_retroflat_state->px_id );
    +
    5225 px_ptr[(y * 256) + x] = g_retroflat_state->palette[color_idx];
    +
    5226
    +
    5227# else
    +
    5228# warning "px not implemented"
    +
    5229# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5230
    +
    5231}
    +
    5232
    +
    5233/* === */
    +
    5234
    +
    5235void retroflat_rect(
    +
    5236 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color_idx,
    +
    5237 int x, int y, int w, int h, uint8_t flags
    +
    5238) {
    +
    5239#if defined( RETROFLAT_OPENGL )
    +
    5240 float aspect_ratio = 0,
    +
    5241 screen_x = 0,
    +
    5242 screen_y = 0,
    +
    5243 screen_w = 0,
    +
    5244 screen_h = 0;
    +
    5245#elif defined( RETROFLAT_API_SDL2 )
    +
    5246#elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5247 MERROR_RETVAL retval = MERROR_OK;
    +
    5248 HBRUSH old_brush = (HBRUSH)NULL;
    +
    5249 int locked_target_internal = 0;
    +
    5250 HPEN old_pen = (HPEN)NULL;
    +
    5251#endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5252
    +
    5253 if( RETROFLAT_COLOR_NULL == color_idx ) {
    +
    5254 return;
    +
    5255 }
    +
    5256
    +
    5257# ifndef RETROFLAT_OPENGL
    +
    5258 if( NULL == target ) {
    +
    5259 target = retroflat_screen_buffer();
    +
    5260 }
    +
    5261# endif /* !RETROFLAT_OPENGL */
    +
    5262
    +
    5263# if defined( RETROFLAT_OPENGL )
    +
    5264
    +
    5265 if( NULL == target || retroflat_screen_buffer() == target ) {
    +
    5266 /* Draw directly to the screen. */
    +
    5267
    +
    5268 retroflat_opengl_push( x, y, screen_x, screen_y, aspect_ratio );
    +
    5269 retroflat_opengl_whf( w, h, screen_w, screen_h, aspect_ratio );
    +
    5270
    +
    5271 glBegin( GL_TRIANGLES );
    +
    5272 glColor3fv( g_retroflat_state->palette[color_idx] );
    +
    5273 glVertex3f( screen_x, screen_y, RETROFLAT_GL_Z );
    +
    5274 glVertex3f( screen_x, screen_y - screen_h, RETROFLAT_GL_Z );
    +
    5275 glVertex3f( screen_x + screen_w, screen_y - screen_h, RETROFLAT_GL_Z );
    +
    5276
    +
    5277 glVertex3f( screen_x + screen_w, screen_y - screen_h, RETROFLAT_GL_Z );
    +
    5278 glVertex3f( screen_x + screen_w, screen_y, RETROFLAT_GL_Z );
    +
    5279 glVertex3f( screen_x, screen_y, RETROFLAT_GL_Z );
    +
    5280 glEnd();
    +
    5281
    +
    5282 retroflat_opengl_pop();
    +
    5283 } else {
    +
    5284 retrosoft_rect( target, color_idx, x, y, w, h, flags );
    +
    5285 }
    +
    5286
    +
    5287# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5288
    +
    5289 retrosoft_rect( target, color_idx, x, y, w, h, flags );
    +
    5290
    +
    5291# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5292
    +
    5293 /* == Allegro == */
    +
    5294
    +
    5295 assert( NULL != target->b );
    + +
    5297 rectfill( target->b, x, y, x + w, y + h,
    +
    5298 g_retroflat_state->palette[color_idx] );
    +
    5299 } else {
    +
    5300 rect( target->b, x, y, x + w, y + h,
    +
    5301 g_retroflat_state->palette[color_idx] );
    +
    5302 }
    +
    5303
    +
    5304# elif defined( RETROFLAT_API_SDL2 )
    +
    5305
    +
    5306 assert( retroflat_bitmap_locked( target ) );
    +
    5307
    +
    5308 area.x = x;
    +
    5309 area.y = y;
    +
    5310 area.w = w;
    +
    5311 area.h = h;
    +
    5312
    +
    5313 SDL_SetRenderDrawColor(
    +
    5314 target->renderer, color->r, color->g, color->b, 255 );
    +
    5315
    + +
    5317 SDL_RenderFillRect( target->renderer, &area );
    +
    5318 } else {
    +
    5319 SDL_RenderDrawRect( target->renderer, &area );
    +
    5320 }
    +
    5321
    +
    5322# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5323
    +
    5324 /* == Win16/Win32 == */
    +
    5325
    +
    5326 assert( (HBITMAP)NULL != target->b );
    +
    5327
    +
    5328 assert( retroflat_bitmap_locked( target ) );
    +
    5329
    +
    5330 retroflat_win_setup_brush( old_brush, target, color_idx, flags );
    +
    5331 retroflat_win_setup_pen( old_pen, target, color_idx, flags );
    +
    5332
    +
    5333 Rectangle( target->hdc_b, x, y, x + w, y + h );
    +
    5334
    +
    5335cleanup:
    +
    5336
    +
    5337 retroflat_win_cleanup_brush( old_brush, target )
    +
    5338 retroflat_win_cleanup_pen( old_pen, target )
    +
    5339
    +
    5340# else
    +
    5341# warning "rect not implemented"
    +
    5342# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5343}
    +
    5344
    +
    5345/* === */
    +
    5346
    +
    5347void retroflat_line(
    +
    5348 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color_idx,
    +
    5349 int x1, int y1, int x2, int y2, uint8_t flags
    +
    5350) {
    +
    5351# if defined( RETROFLAT_OPENGL )
    +
    5352# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5353# elif defined( RETROFLAT_API_SDL2 )
    +
    5354 MERROR_RETVAL retval = MERROR_OK;
    +
    5355 int locked_target_internal = 0;
    +
    5356 RETROFLAT_COLOR_DEF color = g_retroflat_state->palette[color_idx];
    +
    5357# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5358 HPEN pen = (HPEN)NULL;
    +
    5359 HPEN old_pen = (HPEN)NULL;
    +
    5360 POINT points[2];
    +
    5361 MERROR_RETVAL retval = MERROR_OK;
    +
    5362 int locked_target_internal = 0;
    +
    5363# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5364
    +
    5365 if( RETROFLAT_COLOR_NULL == color_idx ) {
    +
    5366 return;
    +
    5367 }
    +
    5368
    +
    5369# ifndef RETROFLAT_OPENGL
    +
    5370 if( NULL == target ) {
    +
    5371 target = retroflat_screen_buffer();
    +
    5372 }
    +
    5373# endif /* !RETROFLAT_OPENGL */
    +
    5374
    +
    5375# if defined( RETROFLAT_OPENGL )
    +
    5376
    +
    5377 if( NULL == target || retroflat_screen_buffer() == target ) {
    +
    5378 /* TODO: Draw line in ortho. */
    +
    5379 } else {
    +
    5380 retrosoft_line( target, color_idx, x1, y1, x2, y2, flags );
    +
    5381 }
    +
    5382
    +
    5383# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5384
    +
    5385 retrosoft_line( target, color_idx, x1, y1, x2, y2, flags );
    +
    5386
    +
    5387# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5388
    +
    5389 /* == Allegro == */
    +
    5390
    +
    5391 assert( NULL != target->b );
    +
    5392 line( target->b, x1, y1, x2, y2, color_idx );
    +
    5393
    +
    5394# elif defined( RETROFLAT_API_SDL2 )
    +
    5395
    +
    5396 /* == SDL2 == */
    +
    5397
    +
    5398 assert( retroflat_bitmap_locked( target );
    +
    5399
    +
    5400 SDL_SetRenderDrawColor(
    +
    5401 target->renderer, color->r, color->g, color->b, 255 );
    +
    5402 SDL_RenderDrawLine( target->renderer, x1, y1, x2, y2 );
    +
    5403
    +
    5404# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5405
    +
    5406 /* == Win16/Win32 == */
    +
    5407
    +
    5408 assert( NULL != target->b );
    +
    5409
    +
    5410 assert( retroflat_bitmap_locked( target ) );
    +
    5411
    +
    5412 retroflat_win_setup_pen( old_pen, target, color_idx, flags );
    +
    5413
    +
    5414 /* Create the line points. */
    +
    5415 points[0].x = x1;
    +
    5416 points[0].y = y1;
    +
    5417 points[1].x = x2;
    +
    5418 points[1].y = y2;
    +
    5419
    +
    5420 Polyline( target->hdc_b, points, 2 );
    +
    5421
    +
    5422cleanup:
    +
    5423
    +
    5424 if( (HPEN)NULL != pen ) {
    +
    5425 SelectObject( target->hdc_b, old_pen );
    +
    5426 DeleteObject( pen );
    +
    5427 }
    +
    5428
    +
    5429# else
    +
    5430# warning "line not implemented"
    +
    5431# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5432}
    +
    5433
    +
    5434/* === */
    +
    5435
    + +
    5437 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    5438 int x, int y, int w, int h, uint8_t flags
    +
    5439) {
    +
    5440# if defined( RETROFLAT_OPENGL )
    +
    5441# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5442# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5443 HPEN old_pen = (HPEN)NULL;
    +
    5444 HBRUSH old_brush = (HBRUSH)NULL;
    +
    5445 MERROR_RETVAL retval = MERROR_OK;
    +
    5446 int locked_target_internal = 0;
    +
    5447# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5448
    +
    5449 if( RETROFLAT_COLOR_NULL == color ) {
    +
    5450 return;
    +
    5451 }
    +
    5452
    +
    5453# ifndef RETROFLAT_OPENGL
    +
    5454 if( NULL == target ) {
    +
    5455 target = retroflat_screen_buffer();
    +
    5456 }
    +
    5457# endif /* !RETROFLAT_OPENGL */
    +
    5458
    +
    5459# if defined( RETROFLAT_OPENGL )
    +
    5460
    +
    5461 if( NULL == target || retroflat_screen_buffer() == target ) {
    +
    5462 /* TODO: Draw ellipse in ortho. */
    +
    5463 } else {
    +
    5464 retrosoft_ellipse( target, color, x, y, w, h, flags );
    +
    5465 }
    +
    5466
    +
    5467# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5468
    +
    5469 retrosoft_ellipse( target, color, x, y, w, h, flags );
    +
    5470
    +
    5471# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5472
    +
    5473 /* == Allegro == */
    +
    5474
    +
    5475 assert( NULL != target->b );
    +
    5476
    + +
    5478 ellipsefill( target->b, x + (w / 2), y + (h / 2), w / 2, h / 2, color );
    +
    5479 } else {
    +
    5480 ellipse( target->b, x + (w / 2), y + (h / 2), w / 2, h / 2, color );
    +
    5481 }
    +
    5482
    +
    5483# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5484
    +
    5485 /* == Win16/Win32 == */
    +
    5486
    +
    5487 assert( NULL != target->b );
    +
    5488 assert( retroflat_bitmap_locked( target ) );
    +
    5489
    +
    5490 retroflat_win_setup_brush( old_brush, target, color, flags );
    +
    5491 retroflat_win_setup_pen( old_pen, target, color, flags );
    +
    5492
    +
    5493 Ellipse( target->hdc_b, x, y, x + w, y + h );
    +
    5494
    +
    5495cleanup:
    +
    5496
    +
    5497 retroflat_win_cleanup_brush( old_brush, target )
    +
    5498 retroflat_win_cleanup_pen( old_pen, target )
    +
    5499
    +
    5500# else
    +
    5501# warning "ellipse not implemented"
    +
    5502# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5503}
    +
    5504
    +
    5505/* === */
    +
    5506
    +
    5507void retroflat_cursor( struct RETROFLAT_BITMAP* target, uint8_t flags ) {
    +
    5508#if 0
    +
    5509 char mouse_str[11] = "";
    +
    5510
    +
    5511 maug_snprintf(
    +
    5512 mouse_str, 10, "%02d, %02d", g_retroflat_state->last_mouse_x, g_retroflat_state->last_mouse_y );
    +
    5513
    + +
    5515 target, RETROFLAT_COLOR_BLACK,
    +
    5516 mouse_str, 10, NULL, 0, 0, 0 );
    + +
    5518 target, RETROFLAT_COLOR_BLACK,
    +
    5519 g_retroflat_state->last_mouse_x - 5, g_retroflat_state->last_mouse_y - 5, 10, 10, 0 );
    +
    5520#endif
    +
    5521}
    +
    5522
    +
    5523/* === */
    +
    5524
    +
    5525# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5526
    +
    5527# define retroflat_win_create_font( flags, font_str ) \
    +
    5528 CreateFont( 10, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, \
    +
    5529 DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, \
    +
    5530 DEFAULT_QUALITY, DEFAULT_PITCH, \
    +
    5531 (NULL == font_str || '\0' == font_str[0] ? "Arial" : font_str) );
    +
    5532
    +
    5533# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5534
    + +
    5536 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
    +
    5537 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags
    +
    5538) {
    +
    5539# if defined( RETROFLAT_OPENGL )
    +
    5540# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5541# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5542 FONT* font_data = NULL;
    +
    5543 int font_loaded = 0;
    +
    5544# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5545 MERROR_RETVAL retval = MERROR_OK;
    +
    5546 int locked_target_internal = 0;
    +
    5547 SIZE sz;
    +
    5548 HFONT font;
    +
    5549 HFONT old_font;
    +
    5550# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5551
    +
    5552 if( NULL == target ) {
    +
    5553 target = retroflat_screen_buffer();
    +
    5554 }
    +
    5555
    +
    5556# if defined( RETROFLAT_OPENGL )
    +
    5557
    +
    5558 retrosoft_string_sz( target, str, str_sz, font_str, w_out, h_out, flags );
    +
    5559
    +
    5560# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5561
    +
    5562 retrosoft_string_sz( target, str, str_sz, font_str, w_out, h_out, flags );
    +
    5563
    +
    5564# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5565
    +
    5566 /* == Allegro == */
    +
    5567
    +
    5568 if( NULL == font_str || '\0' == font_str[0] ) {
    +
    5569 font_data = font;
    +
    5570 } else {
    +
    5571 /* TODO: Cache loaded fonts for later use. */
    +
    5572 font_data = load_font( font_str, NULL, NULL );
    +
    5573 }
    +
    5574 if( NULL == font_data ) {
    +
    5575 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    5576 "Error", "Unable to load font: %s", font_str );
    +
    5577 goto cleanup;
    +
    5578 }
    +
    5579
    +
    5580 *w_out = text_length( font_data, str );
    +
    5581 *h_out = text_height( font_data );
    +
    5582
    +
    5583cleanup:
    +
    5584
    +
    5585 if( font_loaded && NULL != font_data ) {
    +
    5586 destroy_font( font_data );
    +
    5587 }
    +
    5588
    +
    5589# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5590
    +
    5591 /* == Win16/Win32 == */
    +
    5592
    +
    5593 assert( NULL != target->b );
    +
    5594 assert( retroflat_bitmap_locked( target ) );
    +
    5595
    +
    5596 font = retroflat_win_create_font( flags, font_str );
    +
    5597 old_font = SelectObject( target->hdc_b, font );
    +
    5598
    +
    5599 GetTextExtentPoint( target->hdc_b, str, str_sz, &sz );
    +
    5600 *w_out = sz.cx;
    +
    5601 *h_out = sz.cy;
    +
    5602
    +
    5603cleanup:
    +
    5604
    +
    5605 SelectObject( target->hdc_b, old_font );
    +
    5606
    +
    5607# else
    +
    5608# warning "string sz not implemented"
    +
    5609# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5610}
    +
    5611
    +
    5612/* === */
    +
    5613
    +
    5614void retroflat_string(
    +
    5615 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color,
    +
    5616 const char* str, int str_sz, const char* font_str, int x_orig, int y_orig,
    +
    5617 uint8_t flags
    +
    5618) {
    +
    5619# if defined( RETROFLAT_OPENGL )
    +
    5620 float aspect_ratio = 0,
    +
    5621 screen_x = 0,
    +
    5622 screen_y = 0;
    +
    5623# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5624# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5625 FONT* font_data = NULL;
    +
    5626 int font_loaded = 0;
    +
    5627# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5628 MERROR_RETVAL retval = MERROR_OK;
    +
    5629 int locked_target_internal = 0;
    +
    5630 RECT rect;
    +
    5631 SIZE sz;
    +
    5632 HFONT font;
    +
    5633 HFONT old_font;
    +
    5634# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5635
    +
    5636 if( RETROFLAT_COLOR_NULL == color ) {
    +
    5637 return;
    +
    5638 }
    +
    5639
    +
    5640# if !defined( RETROFLAT_OPENGL )
    +
    5641 if( NULL == target ) {
    +
    5642 target = retroflat_screen_buffer();
    +
    5643 }
    +
    5644# endif /* !RETROFLAT_OPENGL */
    +
    5645
    +
    5646 if( 0 == str_sz ) {
    +
    5647 str_sz = strlen( str );
    +
    5648 }
    +
    5649
    +
    5650# if defined( RETROFLAT_OPENGL )
    +
    5651
    +
    5652 if( NULL == target || retroflat_screen_buffer() == target ) {
    +
    5653 retroflat_opengl_push( x_orig, y_orig, screen_x, screen_y, aspect_ratio );
    +
    5654
    +
    5655 retroglu_string(
    +
    5656 screen_x, screen_y, 0,
    +
    5657 g_retroflat_state->palette[color], str, str_sz, font_str, flags );
    +
    5658
    +
    5659 retroflat_opengl_pop();
    +
    5660 } else {
    +
    5661 retrosoft_string(
    +
    5662 target, color, str, str_sz, font_str, x_orig, y_orig, flags );
    +
    5663 }
    +
    5664
    +
    5665# elif defined( RETROFLAT_SOFT_SHAPES )
    +
    5666
    +
    5667 retrosoft_string(
    +
    5668 target, color, str, str_sz, font_str, x_orig, y_orig, flags );
    +
    5669
    +
    5670# elif defined( RETROFLAT_API_ALLEGRO )
    +
    5671
    +
    5672 /* == Allegro == */
    +
    5673
    +
    5674 if( NULL == font_str || '\0' == font_str[0] ) {
    +
    5675 font_data = font;
    +
    5676 } else {
    +
    5677 /* TODO: Cache loaded fonts for later use. */
    +
    5678 font_data = load_font( font_str, NULL, NULL );
    +
    5679 }
    +
    5680 if( NULL == font_data ) {
    +
    5681 retroflat_message( RETROFLAT_MSG_FLAG_ERROR,
    +
    5682 "Error", "Unable to load font: %s", font_str );
    +
    5683 goto cleanup;
    +
    5684 }
    +
    5685
    +
    5686 textout_ex( target->b, font_data, str, x_orig, y_orig, color, -1 );
    +
    5687
    +
    5688cleanup:
    +
    5689 if( font_loaded && NULL != font_data ) {
    +
    5690 destroy_font( font_data );
    +
    5691 }
    +
    5692
    +
    5693# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5694
    +
    5695 /* == Win16/Win32 == */
    +
    5696
    +
    5697 assert( NULL != target->b );
    +
    5698
    +
    5699 assert( retroflat_bitmap_locked( target ) );
    +
    5700
    +
    5701 /* DrawText will draw gibberish even if the string is null-terminated! */
    +
    5702 str_sz = strlen( str );
    +
    5703
    +
    5704 memset( &sz, '\0', sizeof( SIZE ) );
    +
    5705
    +
    5706 font = retroflat_win_create_font( flags, font_str );
    +
    5707 old_font = SelectObject( target->hdc_b, font );
    +
    5708
    +
    5709 GetTextExtentPoint( target->hdc_b, str, str_sz, &sz );
    +
    5710 rect.left = x_orig;
    +
    5711 rect.top = y_orig;
    +
    5712 rect.right = (x_orig + sz.cx);
    +
    5713 rect.bottom = (y_orig + sz.cy);
    +
    5714
    +
    5715 SetTextColor( target->hdc_b, g_retroflat_state->palette[color] );
    +
    5716 SetBkMode( target->hdc_b, TRANSPARENT );
    +
    5717
    +
    5718 DrawText( target->hdc_b, str, str_sz, &rect, 0 );
    +
    5719
    +
    5720cleanup:
    +
    5721
    +
    5722 SelectObject( target->hdc_b, old_font );
    +
    5723
    +
    5724 SetBkMode( target->hdc_b, OPAQUE );
    +
    5725 SetTextColor( target->hdc_b,
    +
    5726 g_retroflat_state->palette[RETROFLAT_COLOR_BLACK] );
    +
    5727
    +
    5728# else
    +
    5729# warning "string not implemented"
    +
    5730# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5731}
    +
    5732
    +
    5733/* === */
    +
    5734
    +
    5735int retroflat_poll_input( struct RETROFLAT_INPUT* input ) {
    +
    5736# if defined( RETROFLAT_API_ALLEGRO ) && defined( RETROFLAT_OS_DOS )
    +
    5737 union REGS inregs;
    +
    5738 union REGS outregs;
    +
    5739# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    5740 int eres = 0;
    +
    5741 SDL_Event event;
    +
    5742# endif /* RETROFLAT_API_ALLEGRO && RETROFLAT_OS_DOS */
    +
    5743 int key_out = 0;
    +
    5744
    +
    5745 assert( NULL != input );
    +
    5746
    +
    5747 input->key_flags = 0;
    +
    5748
    +
    5749# ifdef RETROFLAT_API_ALLEGRO
    +
    5750
    +
    5751 /* == Allegro == */
    +
    5752
    +
    5753 if( g_retroflat_state->close_button ) {
    +
    5754 retroflat_quit( 0 );
    +
    5755 return 0;
    +
    5756 }
    +
    5757
    +
    5758# ifdef RETROFLAT_OS_DOS
    +
    5759
    +
    5760 /* Poll the mouse. */
    +
    5761 inregs.w.ax = 3;
    +
    5762 int386( 0x33, &inregs, &outregs );
    +
    5763
    +
    5764 if(
    +
    5765 1 == outregs.x.ebx && /* Left button clicked. */
    +
    5766 outregs.w.cx != g_retroflat_state->last_mouse_x &&
    +
    5767 outregs.w.dx != g_retroflat_state->last_mouse_y
    +
    5768 ) {
    +
    5769 input->mouse_x = outregs.w.cx;
    +
    5770 input->mouse_y = outregs.w.dx;
    +
    5771
    +
    5772 /* Prevent repeated clicks. */
    +
    5773 g_retroflat_state->last_mouse_x = input->mouse_x;
    +
    5774 g_retroflat_state->last_mouse_y = input->mouse_y;
    +
    5775
    +
    5776 return RETROFLAT_MOUSE_B_LEFT;
    +
    5777 } else {
    +
    5778 g_retroflat_state->last_mouse_x = outregs.w.cx;
    +
    5779 g_retroflat_state->last_mouse_y = outregs.w.dx;
    +
    5780 }
    +
    5781
    +
    5782# else
    +
    5783 /* Allegro mouse is broken in DOS. */
    +
    5784 poll_mouse();
    +
    5785 if( mouse_b & 0x01 ) {
    +
    5786 input->mouse_x = mouse_x;
    +
    5787 input->mouse_y = mouse_y;
    +
    5788 return RETROFLAT_MOUSE_B_LEFT;
    +
    5789 } else if( mouse_b & 0x02 ) {
    +
    5790 input->mouse_x = mouse_x;
    +
    5791 input->mouse_y = mouse_y;
    +
    5792 return RETROFLAT_MOUSE_B_RIGHT;
    +
    5793 }
    +
    5794# endif /* RETROFLAT_OS_DOS */
    +
    5795
    +
    5796 poll_keyboard();
    +
    5797 if( keypressed() ) {
    +
    5798 /* TODO: ??? */
    +
    5799 if( KB_SHIFT_FLAG == (KB_SHIFT_FLAG & key_shifts) ) {
    +
    5800 input->key_flags |= RETROFLAT_INPUT_MOD_SHIFT;
    +
    5801 }
    +
    5802
    +
    5803 if( KB_CTRL_FLAG == (KB_CTRL_FLAG & key_shifts) ) {
    +
    5804 input->key_flags |= RETROFLAT_INPUT_MOD_CTRL;
    +
    5805 }
    +
    5806
    +
    5807 if( KB_ALT_FLAG == (KB_ALT_FLAG & key_shifts) ) {
    +
    5808 input->key_flags |= RETROFLAT_INPUT_MOD_ALT;
    +
    5809 }
    +
    5810
    +
    5811 return (readkey() >> 8);
    +
    5812 }
    +
    5813
    +
    5814# elif defined( RETROFLAT_API_SDL1 ) || defined( RETROFLAT_API_SDL2 )
    +
    5815
    +
    5816 /* == SDL == */
    +
    5817
    +
    5818 SDL_PollEvent( &event );
    +
    5819
    +
    5820 if( SDL_QUIT == event.type ) {
    +
    5821 /* Handle SDL window close. */
    +
    5822 retroflat_quit( 0 );
    +
    5823
    +
    5824 } else if( SDL_KEYDOWN == event.type ) {
    +
    5825 key_out = event.key.keysym.sym;
    +
    5826
    +
    5827 if(
    +
    5828 KMOD_RSHIFT == (KMOD_RSHIFT & event.key.keysym.mod) ||
    +
    5829 KMOD_LSHIFT == (KMOD_LSHIFT & event.key.keysym.mod)
    +
    5830 ) {
    +
    5831 input->key_flags |= RETROFLAT_INPUT_MOD_SHIFT;
    +
    5832 }
    +
    5833
    +
    5834 if( KMOD_CTRL == (KMOD_CTRL & event.key.keysym.mod) ) {
    +
    5835 input->key_flags |= RETROFLAT_INPUT_MOD_CTRL;
    +
    5836 }
    +
    5837
    +
    5838 if( KMOD_ALT == (KMOD_ALT & event.key.keysym.mod) ) {
    +
    5839 input->key_flags |= RETROFLAT_INPUT_MOD_ALT;
    +
    5840 }
    +
    5841
    +
    5842 /* Flush key buffer to improve responsiveness. */
    +
    5843 if(
    + +
    5845 (RETROFLAT_FLAGS_KEY_REPEAT & g_retroflat_state->retroflat_flags)
    +
    5846 ) {
    +
    5847 while( (eres = SDL_PollEvent( &event )) );
    +
    5848 }
    +
    5849
    +
    5850 } else if( SDL_MOUSEBUTTONUP == event.type ) {
    +
    5851 /* Stop dragging. */
    +
    5852 g_retroflat_state->mouse_state = 0;
    +
    5853
    +
    5854 } else if( 0 != g_retroflat_state->mouse_state ) {
    +
    5855
    +
    5856 /* Update coordinates and keep dragging. */
    +
    5857
    +
    5858 SDL_GetMouseState( &(input->mouse_x), &(input->mouse_y) );
    +
    5859 key_out = g_retroflat_state->mouse_state;
    +
    5860
    +
    5861 } else if( SDL_MOUSEBUTTONDOWN == event.type ) {
    +
    5862
    +
    5863 /* Begin dragging. */
    +
    5864
    +
    5865 input->mouse_x = event.button.x;
    +
    5866 input->mouse_y = event.button.y;
    +
    5867
    +
    5868 /* Differentiate which button was clicked. */
    +
    5869 if( SDL_BUTTON_LEFT == event.button.button ) {
    +
    5870 key_out = RETROFLAT_MOUSE_B_LEFT;
    +
    5871 g_retroflat_state->mouse_state = RETROFLAT_MOUSE_B_LEFT;
    +
    5872 } else if( SDL_BUTTON_RIGHT == event.button.button ) {
    +
    5873 key_out = RETROFLAT_MOUSE_B_RIGHT;
    +
    5874 g_retroflat_state->mouse_state = RETROFLAT_MOUSE_B_RIGHT;
    +
    5875 }
    +
    5876
    +
    5877 /* Flush key buffer to improve responsiveness. */
    +
    5878 /*while( (eres = SDL_PollEvent( &event )) );*/
    +
    5879
    +
    5880# if !defined( RETROFLAT_API_SDL1 )
    +
    5881 } else if( SDL_WINDOWEVENT == event.type ) {
    +
    5882 switch( event.window.event ) {
    +
    5883 case SDL_WINDOWEVENT_RESIZED:
    +
    5884 retroflat_on_resize( event.window.data1, event.window.data2 );
    +
    5885 }
    +
    5886# endif /* !RETROFLAT_API_SDL1 */
    +
    5887 }
    +
    5888
    +
    5889# elif defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    5890
    +
    5891 /* == Win16/Win32 == */
    +
    5892
    +
    5893 if( g_retroflat_state->last_key ) {
    +
    5894 /* Return g_retroflat_state->last_key, which is set in WndProc when a keypress msg is
    +
    5895 * received.
    +
    5896 */
    +
    5897 key_out = g_retroflat_state->last_key;
    +
    5898 input->key_flags = g_retroflat_state->vk_mods;
    +
    5899
    +
    5900 /* Reset pressed key. */
    +
    5901 g_retroflat_state->last_key = 0;
    +
    5902
    +
    5903 } else if( g_retroflat_state->last_mouse ) {
    +
    5904 if( MK_LBUTTON == (MK_LBUTTON & g_retroflat_state->last_mouse) ) {
    +
    5905 input->mouse_x = g_retroflat_state->last_mouse_x;
    +
    5906 input->mouse_y = g_retroflat_state->last_mouse_y;
    +
    5907 key_out = RETROFLAT_MOUSE_B_LEFT;
    +
    5908 } else if( MK_RBUTTON == (MK_RBUTTON & g_retroflat_state->last_mouse) ) {
    +
    5909 input->mouse_x = g_retroflat_state->last_mouse_x;
    +
    5910 input->mouse_y = g_retroflat_state->last_mouse_y;
    +
    5911 key_out = RETROFLAT_MOUSE_B_RIGHT;
    +
    5912 }
    +
    5913 g_retroflat_state->last_mouse = 0;
    +
    5914 g_retroflat_state->last_mouse_x = 0;
    +
    5915 g_retroflat_state->last_mouse_y = 0;
    +
    5916 }
    +
    5917
    +
    5918# ifdef RETROFLAT_SCREENSAVER
    +
    5919 if(
    + +
    5921 (RETROFLAT_FLAGS_SCREENSAVER & g_retroflat_state->retroflat_flags))
    +
    5922 && 0 != key_out
    +
    5923 ) {
    +
    5924 /* retroflat_quit( 0 ); */
    +
    5925 }
    +
    5926# endif /* RETROFLAT_SCREENSAVER */
    +
    5927
    +
    5928# elif defined( RETROFLAT_API_GLUT )
    +
    5929
    +
    5930 key_out = g_retroflat_state->retroflat_last_key;
    +
    5931 g_retroflat_state->retroflat_last_key = 0;
    +
    5932
    +
    5933# else
    +
    5934# warning "poll input not implemented"
    +
    5935# endif /* RETROFLAT_API_ALLEGRO || RETROFLAT_API_SDL1 || RETROFLAT_API_SDL2 || RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    5936
    +
    5937 return key_out;
    +
    5938}
    +
    5939
    +
    5940/* === */
    +
    5941
    +
    5942MERROR_RETVAL retroflat_config_open( RETROFLAT_CONFIG* config, uint8_t flags ) {
    +
    5943 MERROR_RETVAL retval = MERROR_OK;
    +
    5944
    +
    5945# if defined( RETROFLAT_CONFIG_USE_FILE )
    +
    5946 char flag_buffer[3] = { '\0', '\0', '\0' };
    +
    5947
    + +
    5949 flag_buffer[0] = 'w';
    +
    5950 } else {
    +
    5951 flag_buffer[0] = 'r';
    +
    5952 }
    +
    5953
    + +
    5955 flag_buffer[1] = 'b';
    +
    5956 }
    +
    5957
    +
    5958 debug_printf( 1, "opening config file %s with mode [%s]...",
    +
    5959 g_retroflat_state->config_path, flag_buffer );
    +
    5960
    +
    5961 *config = fopen( g_retroflat_state->config_path, flag_buffer );
    +
    5962 maug_cleanup_if_null( RETROFLAT_CONFIG, *config, MERROR_FILE );
    +
    5963
    +
    5964cleanup:
    +
    5965# elif defined( RETROFLAT_API_WIN16 )
    +
    5966
    +
    5967 /* == Win16 (.ini file) == */
    +
    5968
    +
    5969 /* TODO */
    +
    5970
    +
    5971# elif defined( RETROFLAT_API_WIN32 )
    +
    5972
    +
    5973 /* == Win32 (Registry) == */
    +
    5974
    +
    5975 char key_path[RETROFLAT_PATH_MAX + 1] = "SOFTWARE\\";
    +
    5976
    +
    5977 /* TODO */
    +
    5978 strncat( key_path, "RetroFlat", RETROFLAT_PATH_MAX );
    +
    5979
    +
    5980 /* TODO */
    +
    5981 if( ERROR_SUCCESS != RegOpenKey(
    +
    5982 HKEY_CURRENT_USER,
    +
    5983 key_path,
    +
    5984 (HKEY*)config
    +
    5985 ) ) {
    +
    5986 retval = MERROR_FILE;
    +
    5987 }
    +
    5988
    +
    5989# else
    +
    5990# warning "config close not implemented"
    +
    5991# endif
    +
    5992
    +
    5993 return retval;
    +
    5994}
    +
    5995
    +
    5996/* === */
    +
    5997
    +
    5998void retroflat_config_close( RETROFLAT_CONFIG* config ) {
    +
    5999
    +
    6000# if defined( RETROFLAT_CONFIG_USE_FILE )
    +
    6001
    +
    6002 debug_printf( 1, "closing config file..." );
    +
    6003 fclose( *config );
    +
    6004 *config = NULL;
    +
    6005
    +
    6006# elif defined( RETROFLAT_API_WIN16 )
    +
    6007
    +
    6008 /* TODO */
    +
    6009
    +
    6010# elif defined( RETROFLAT_API_WIN32 )
    +
    6011
    +
    6012 /* == Win32 (Registry) == */
    +
    6013
    +
    6014 /* TODO */
    +
    6015
    +
    6016# else
    +
    6017# warning "config close not implemented"
    +
    6018# endif
    +
    6019
    +
    6020}
    +
    6021
    +
    6022/* === */
    +
    6023
    +
    6024#ifdef RETROFLAT_CONFIG_USE_FILE
    +
    6025
    +
    6031static char* retroflat_config_tok_sect(
    +
    6032 char* line, size_t line_sz, const char* sect_name, size_t* sect_match
    +
    6033) {
    +
    6034
    +
    6035 /* Section check. */
    +
    6036 if( '[' == line[0] ) {
    +
    6037 *sect_match = strncmp( sect_name, &(line[1]), line_sz - 2 );
    +
    6038 if( 0 == *sect_match ) {
    +
    6039 /* TODO: Tokenize at closing bracket. */
    +
    6040 line[line_sz - 1] = '\0';
    +
    6041 debug_printf( 1, "found section: %s", &(line[1]) );
    +
    6042 }
    +
    6043 return line;
    +
    6044 }
    +
    6045
    +
    6046 return NULL;
    +
    6047}
    +
    6048
    +
    6049#endif /* RETROFLAT_CONFIG_USE_FILE */
    +
    6050
    +
    6051/* === */
    +
    6052
    + +
    6054 RETROFLAT_CONFIG* config,
    +
    6055 const char* sect_name, const char* key_name, uint8_t buffer_type,
    +
    6056 void* buffer, size_t buffer_sz_max
    +
    6057) {
    +
    6058 size_t retval = 0;
    +
    6059
    +
    6060
    +
    6061 return retval;
    +
    6062}
    +
    6063
    +
    6064/* === */
    +
    6065
    + +
    6067 RETROFLAT_CONFIG* config,
    +
    6068 const char* sect_name, const char* key_name, uint8_t buffer_type,
    +
    6069 void* buffer_out, size_t buffer_out_sz_max,
    +
    6070 const void* default_out, size_t default_out_sz
    +
    6071) {
    +
    6072 size_t retval = 0;
    +
    6073# if defined( RETROFLAT_CONFIG_USE_FILE )
    +
    6074 char line[RETROFLAT_CONFIG_LN_SZ_MAX + 1];
    +
    6075 char* line_val = NULL;
    +
    6076 size_t line_sz = 0;
    +
    6077 size_t sect_match = 1;
    +
    6078# endif /* RETROFLAT_API_WIN32 */
    +
    6079
    +
    6080# if defined( RETROFLAT_CONFIG_USE_FILE )
    +
    6081
    +
    6082 /* == SDL / Allegro == */
    +
    6083
    +
    6084 while( fgets( line, RETROFLAT_CONFIG_LN_SZ_MAX, *config ) ) {
    +
    6085 /* Size check. */
    +
    6086 line_sz = strlen( line );
    +
    6087 if( 1 >= line_sz || RETROFLAT_CONFIG_LN_SZ_MAX <= line_sz ) {
    +
    6088 error_printf( "invalid line sz: " SIZE_T_FMT, line_sz );
    +
    6089 continue;
    +
    6090 }
    +
    6091
    +
    6092 /* Strip off trailing newline. */
    +
    6093 if( '\n' == line[line_sz - 1] || '\r' == line[line_sz - 1] ) {
    +
    6094 debug_printf( 1, "stripping newline!" );
    +
    6095 line_sz--;
    +
    6096 line[line_sz] = '\0'; /* NULL goes after strlen() finishes! */
    +
    6097 }
    +
    6098
    +
    6099 /* Section check. */
    +
    6100 if(
    +
    6101 retroflat_config_tok_sect( line, line_sz, sect_name, &sect_match )
    +
    6102 ) {
    +
    6103 continue;
    +
    6104 }
    +
    6105
    +
    6106 /* Split up key/value pair. */
    +
    6107 line_val = strchr( line, '=' );
    +
    6108 if( NULL == line_val || line_val == line ) {
    +
    6109 error_printf( "invalid line: %s", line );
    +
    6110 continue;
    +
    6111 }
    +
    6112
    +
    6113 /* Terminate key. */
    +
    6114 line_val[0] = '\0';
    +
    6115 line_val++;
    +
    6116
    +
    6117 if( 0 == sect_match && 0 == strcmp( key_name, line ) ) {
    +
    6118 debug_printf( 1, "found %s: %s", line, line_val );
    +
    6119
    +
    6120 switch( buffer_type ) {
    +
    6121 case RETROFLAT_BUFFER_INT:
    +
    6122 *((int*)buffer_out) = atoi( line_val );
    +
    6123 goto cleanup;
    +
    6124
    +
    6125 case RETROFLAT_BUFFER_FLOAT:
    +
    6126 *((float*)buffer_out) = atof( line_val );
    +
    6127 goto cleanup;
    +
    6128
    +
    6129 case RETROFLAT_BUFFER_STRING:
    +
    6130 strncpy( (char*)buffer_out, line_val, buffer_out_sz_max );
    +
    6131 goto cleanup;
    +
    6132
    +
    6133 case RETROFLAT_BUFFER_BOOL:
    +
    6134 /* TODO */
    +
    6135 goto cleanup;
    +
    6136 }
    +
    6137 }
    +
    6138 }
    +
    6139
    +
    6140cleanup:
    +
    6141
    +
    6142 fseek( *config, 0, SEEK_SET );
    +
    6143
    +
    6144# elif defined( RETROFLAT_API_WIN16 )
    +
    6145
    +
    6146 /* == Win16 (.ini file) == */
    +
    6147
    +
    6148/* XXX
    +
    6149 retval = GetPrivateProfileString(
    +
    6150 sect_name, key_name, default_out, buffer_out, buffer_out_sz_max,
    +
    6151 g_retroflat_state->config_path ); */
    +
    6152
    +
    6153# elif defined( RETROFLAT_API_WIN32 )
    +
    6154
    +
    6155 /* == Win32 (Registry) == */
    +
    6156
    +
    6157 /* TODO */
    +
    6158
    +
    6159# else
    +
    6160# warning "config read not implemented"
    +
    6161# endif
    +
    6162
    +
    6163 return retval;
    +
    6164}
    +
    6165
    +
    6166#elif !defined( RETROVDP_C ) /* End of RETROFLT_C */
    +
    6167
    +
    6168#define RETROFLAT_COLOR_TABLE_CONSTS( idx, name_l, name_u, r, g, b ) \
    +
    6169 extern MAUG_CONST RETROFLAT_COLOR RETROFLAT_COLOR_ ## name_u;
    +
    6170
    +
    6171RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_CONSTS )
    +
    6172
    +
    6173extern MAUG_CONST char* gc_retroflat_color_names[];
    +
    6174
    +
    6175 extern struct RETROFLAT_STATE* g_retroflat_state;
    +
    6176# if defined( RETROFLAT_API_WIN16 ) || defined( RETROFLAT_API_WIN32 )
    +
    6177 extern HINSTANCE g_retroflat_instance;
    +
    6178 extern int g_retroflat_cmd_show;
    +
    6179# endif /* RETROFLAT_API_WIN16 || RETROFLAT_API_WIN32 */
    +
    6180
    +
    6181# include <uprintf.h>
    +
    6182
    +
    6183# if defined( RETROFLAT_SOFT_SHAPES ) && !defined( MAUG_NO_AUTO_C )
    +
    6184# include <retrofp.h>
    +
    6185# include <retrosft.h>
    +
    6186# endif /* RETROFLAT_SOFT_SHAPES */
    +
    6187
    +
    6188# if defined( RETROFLAT_OPENGL ) && !defined( MAUG_NO_AUTO_C )
    +
    6189# include <retroglu.h>
    +
    6190# include <retrofp.h>
    +
    6191# include <retrosft.h>
    +
    6192# endif /* RETROFLAT_OPENGL */
    +
    6193
    +
    6194#endif /* RETROFLT_C */
    +
    6195
    +
    6196#ifdef RETROVDP_C
    +
    6197
    +
    6198/* Declarations for VDP sources. */
    +
    6199
    +
    6200#endif /* RETROVDP_C */
    +
    6201 /* maug_retroflt */
    +
    6203
    +
    6204#endif /* RETROFLT_H */
    +
    6205
    +
    MERROR_RETVAL maug_add_arg(const char *arg, int arg_sz, const char *help, int help_sz, maug_cli_cb arg_cb, maug_cli_cb def_cb, void *data)
    Add a command-line argument to the built-in parser.
    +
    #define MAUG_CLI_SIGIL
    Default flag to prepend to CLI arguments. Is "/" on Windows/DOS and "-" on other platforms....
    Definition marge.h:34
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    #define RETROFLAT_BITMAP_EXT
    The filename suffix to be appended with a "." to filenames passed to retroflat_load_bitmap()....
    Definition retroflt.h:521
    +
    #define RETROFLAT_TXP_G
    Compiler-define-overridable constant indicating the Green value of the transparency color on platform...
    Definition retroflt.h:544
    +
    void retroflat_blit_bitmap(struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, int s_x, int s_y, int d_x, int d_y, int w, int h)
    Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP.
    +
    MERROR_RETVAL retroflat_load_bitmap(const char *filename, struct RETROFLAT_BITMAP *bmp_out)
    Load a bitmap into the given RETROFLAT_BITMAP structure if it is available. Bitmaps are subject to th...
    +
    MERROR_RETVAL retroflat_load_xpm(const char *filename, struct RETROFLAT_BITMAP *bmp_out)
    Load a compiled-in XPM image into an API-specific bitmap context. \warn The XPM must have been genera...
    +
    void retroflat_destroy_bitmap(struct RETROFLAT_BITMAP *bitmap)
    Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on th...
    +
    #define RETROFLAT_TXP_B
    Compiler-define-overridable constant indicating the Blue value of the transparency color on platforms...
    Definition retroflt.h:553
    +
    #define retroflat_bitmap_ok(bitmap)
    Check to see if a bitmap is loaded.
    Definition retroflt.h:1619
    +
    #define RETROFLAT_TXP_R
    Compiler-define-overridable constant indicating the Red value of the transparency color on platforms ...
    Definition retroflt.h:535
    +
    #define RETROFLAT_WIN_GFX_TIMER_ID
    Unique ID for the timer that execute graphics ticks in Win16/Win32. Is a RetroFlat Compiler Definitio...
    Definition retroflt.h:611
    +
    #define NDS_SPRITES_ACTIVE
    Maximum number of sprites active on-screen on Nintendo DS.
    Definition retroflt.h:679
    +
    #define RETROFLAT_VDP_ARGS_SZ_MAX
    Definition retroflt.h:635
    +
    #define RETROFLAT_MSG_MAX
    Maximum number of characters possible in a message using retroflat_message(). Is a RetroFlat Compiler...
    Definition retroflt.h:619
    +
    #define RETROFLAT_WINDOW_CLASS
    Unique window class to use on some platforms (e.g. Win32). Is a RetroFlat Compiler Definitions.
    Definition retroflt.h:603
    +
    #define RETROFLAT_FPS
    Target Frames Per Second.
    Definition retroflt.h:593
    +
    #define RETROFLAT_ASSETS_PATH_MAX
    Maximum size of the assets path, to allow room for appending.
    Definition retroflt.h:670
    +
    #define NDS_OAM_ACTIVE
    Active sprite engine screen on Nintendo DS.
    Definition retroflt.h:674
    +
    #define RETROFLAT_PATH_MAX
    Maximum size allocated for asset paths.
    Definition retroflt.h:624
    +
    #define RETROFLAT_PATH_SEP
    The valid path separator on the target platform.
    Definition retroflt.h:666
    +
    #define RETROFLAT_CONFIG_FLAG_W
    Flag indicating config object should be opened for WRITING only.
    Definition retroflt.h:419
    +
    #define RETROFLAT_CONFIG_FLAG_BIN
    Flag indicating config object holds BINARY data.
    Definition retroflt.h:424
    +
    FILE * RETROFLAT_CONFIG
    A configuration object to use with the RetroFlat Config API.
    Definition retroflt.h:1595
    +
    size_t retroflat_config_write(RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer, size_t buffer_sz_max)
    Write the contents of a buffer to a config object.
    +
    size_t retroflat_config_read(RETROFLAT_CONFIG *config, const char *sect_name, const char *key_name, uint8_t buffer_type, void *buffer_out, size_t buffer_out_sz_max, const void *default_out, size_t default_out_sz)
    Write the contents of a buffer to a config object.
    +
    MERROR_RETVAL retroflat_config_open(RETROFLAT_CONFIG *config, uint8_t flags)
    Open a configuration file/registry/SRAM/etc handle.
    +
    #define RETROFLAT_FLAGS_OPAQUE
    Flag for retroflat_create_bitmap() to create a bitmap without transparency.
    Definition retroflt.h:340
    +
    void retroflat_string(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int x_orig, int y_orig, uint8_t flags)
    Draw a text string at the specified location in the specified font and color on the target RETROFLAT_...
    +
    void retroflat_ellipse(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
    Draw an ellipse onto the target RETROFLAT_BITMAP.
    +
    MERROR_RETVAL retroflat_draw_lock(struct RETROFLAT_BITMAP *bmp)
    Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly,...
    +
    void retroflat_string_sz(struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, size_t *w_out, size_t *h_out, uint8_t flags)
    Get the size in pixels of a text string when drawn with a given font by retroflat_string().
    +
    void retroflat_line(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
    Draw a straight line onto the target RETROFLAT_BITMAP.
    +
    void retroflat_rect(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
    Draw a rectangle onto the target RETROFLAT_BITMAP.
    +
    #define RETROFLAT_FLAGS_FILL
    Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
    Definition retroflt.h:334
    +
    #define RETROFLAT_FLAGS_SCREEN_BUFFER
    Flag for retroflat_create_bitmap() to create a WinG-backed bitmap.
    Definition retroflt.h:348
    +
    #define RETROFLAT_FLAGS_SCREENSAVER
    Flag indicating the current application is running as a screensaver.
    Definition retroflt.h:381
    +
    #define RETROFLAT_FLAGS_UNLOCK_FPS
    Flag indicating FPS should not be capped.
    Definition retroflt.h:369
    +
    #define RETROFLAT_FLAGS_RUNNING
    Flag indicating that retroflat_loop() should continue executing.
    Definition retroflt.h:363
    +
    #define RETROFLAT_FLAGS_KEY_REPEAT
    Flag indicating keyboard repeat is enabled.
    Definition retroflt.h:375
    +
    int retroflat_poll_input(struct RETROFLAT_INPUT *input)
    Poll input devices (keyboard/mouse) and return the latest event.
    +
    #define RETROFLAT_OK
    Certain functions return this when there was no problem.
    Definition retroflt.h:304
    +
    #define RETROFLAT_ERROR_BITMAP
    Returned if there is a problem loading or locking a RETROFLAT_BITMAP struct.
    Definition retroflt.h:313
    +
    MERROR_RETVAL(* retroflat_vdp_proc_t)(struct RETROFLAT_STATE *)
    VDP function called from the VDP library.
    Definition retroflt.h:479
    +
    #define RETROFLAT_VDP_FLAG_PXLOCK
    Flag for RETROFLAT_STATE::vdp_flags indicating the VDP requires RetroFlat to pixel-lock the frame bef...
    Definition retroflt.h:466
    +
    void retroflat_shutdown(int retval)
    Deinitialize RetroFlat and its underlying layers. This should be called once at the end of the progra...
    +
    #define retroflat_screen_h()
    Get the current screen height in pixels.
    Definition retroflt.h:1627
    +
    #define retroflat_quit(retval_in)
    This should be called in order to quit a program using RetroFlat.
    Definition retroflt.h:1636
    +
    #define retroflat_screen_buffer()
    Get the direct screen buffer or the VDP buffer if a VDP is loaded.
    Definition retroflt.h:1630
    +
    void(* retroflat_loop_iter)(void *data)
    Prototype for the main loop function passed to retroflat_loop().
    Definition retroflt.h:699
    +
    MERROR_RETVAL retroflat_loop(retroflat_loop_iter iter, void *data)
    This should be called once in the main body of the program in order to enter the main loop....
    +
    void retroflat_message(uint8_t flags, const char *title, const char *format,...)
    Display a message in a dialog box and/or on stderr.
    +
    #define retroflat_screen_w()
    Get the current screen width in pixels.
    Definition retroflt.h:1624
    +
    MERROR_RETVAL retroflat_init(int argc, char *argv[], struct RETROFLAT_ARGS *args)
    Initialize RetroFlat and its underlying layers. This should be called once at the beginning of the pr...
    +
    Contains functions and macros for working with fixed-point numbers.
    +
    Library of tools for working with RetroFlat and OpenGL.
    +
    Struct containing configuration values for a RetroFlat program.
    Definition retroflt.h:1752
    +
    char * config_path
    Relative path of local config file (if not using registry).
    Definition retroflt.h:1766
    +
    char * assets_path
    Relative path under which bitmap assets are stored.
    Definition retroflt.h:1763
    +
    int screen_w
    Desired screen or window width in pixels.
    Definition retroflt.h:1759
    +
    int screen_h
    Desired screen or window height in pixels.
    Definition retroflt.h:1761
    +
    char * title
    Title to set for the main program Window if applicable on the target platform.
    Definition retroflt.h:1757
    +
    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
    Definition retroflt.h:1610
    +
    size_t sz
    Size of the bitmap structure, used to check VDP compatibility.
    Definition retroflt.h:1612
    +
    uint8_t flags
    Platform-specific bitmap flags.
    Definition retroflt.h:1614
    +
    Struct passed to retroflat_poll_input() to hold return data.
    Definition retroflt.h:749
    +
    int mouse_y
    Y-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
    Definition retroflt.h:759
    +
    int mouse_x
    X-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
    Definition retroflt.h:754
    +
    Global singleton containing state for the current platform.
    Definition retroflt.h:1770
    +
    char vdp_args[RETROFLAT_VDP_ARGS_SZ_MAX]
    CLI args passed with -vdp to the RetroFlat VDP API.
    Definition retroflt.h:1796
    +
    uint8_t vdp_flags
    Flags set by the RetroFlat VDP API.
    Definition retroflt.h:1798
    +
    uint8_t retroflat_flags
    Global Flags indicating current system status.
    Definition retroflt.h:1774
    +
    struct RETROFLAT_BITMAP * vdp_buffer
    A buffer assembled and passed to the VDP for its use, or NULL if no VDP is loaded.
    Definition retroflt.h:1786
    +
    struct RETROFLAT_BITMAP buffer
    Off-screen buffer bitmap.
    Definition retroflt.h:1780
    +
    void * vdp_exe
    A handle for the loaded VDP module.
    Definition retroflt.h:1791
    +
    RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ]
    Index of available colors, initialized on platform init.
    Definition retroflt.h:1778
    +
    void * vdp_data
    Pointer to data defined by the VDP for its use.
    Definition retroflt.h:1794
    + +
    + + + + diff --git a/retrofp_8h.html b/retrofp_8h.html new file mode 100644 index 00000000..31031f86 --- /dev/null +++ b/retrofp_8h.html @@ -0,0 +1,129 @@ + + + + + + + +maug: retrofp.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    retrofp.h File Reference
    +
    +
    + +

    Contains functions and macros for working with fixed-point numbers. +More...

    + +

    Go to the source code of this file.

    + + + + + + + + + +

    +Macros

    +#define RETROFP_PI   (3141)
     Fixed-point representation of Pi (3.141).
     
    +#define retrofp_sin(num, mult)   retrofp_lut( g_retrofp_sin, num, mult )
     
    +#define retrofp_cos(num, mult)   retrofp_lut( g_retrofp_cos, num, mult )
     
    + + + + +

    +Functions

    +int16_t retrofp_lut (const int16_t *lut, int16_t num, int16_t mult)
     Given a lookup table, return the corresponding value after trimming precision and making sure number is valid.
     
    + + + + + +

    +Variables

    +MAUG_CONST int16_t g_retrofp_cos []
     
    +MAUG_CONST int16_t g_retrofp_sin []
     
    +

    Detailed Description

    +

    Contains functions and macros for working with fixed-point numbers.

    +

    Maug retro fixed point numbers are rounded to 3 decimal places (e.g. RETROFP_PI).

    +
    + + + + diff --git a/retrofp_8h_source.html b/retrofp_8h_source.html new file mode 100644 index 00000000..b04e7a44 --- /dev/null +++ b/retrofp_8h_source.html @@ -0,0 +1,276 @@ + + + + + + + +maug: retrofp.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retrofp.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef RETROFP_H
    +
    3#define RETROFP_H
    +
    4
    +
    17#define RETROFP_PI (3141)
    +
    18
    +
    23int16_t retrofp_lut( const int16_t* lut, int16_t num, int16_t mult );
    +
    24
    +
    25#define retrofp_sin( num, mult ) retrofp_lut( g_retrofp_sin, num, mult )
    +
    26
    +
    27#define retrofp_cos( num, mult ) retrofp_lut( g_retrofp_cos, num, mult )
    +
    28
    +
    29#ifdef RETROFP_C
    +
    30
    +
    31MAUG_CONST int16_t g_retrofp_cos[] = {
    +
    32 1000,
    +
    33 995,
    +
    34 980,
    +
    35 955,
    +
    36 921,
    +
    37 877,
    +
    38 825,
    +
    39 764,
    +
    40 696,
    +
    41 621,
    +
    42 540,
    +
    43 453,
    +
    44 362,
    +
    45 267,
    +
    46 169,
    +
    47 70,
    +
    48 -29,
    +
    49 -128,
    +
    50 -227,
    +
    51 -323,
    +
    52 -416,
    +
    53 -504,
    +
    54 -588,
    +
    55 -666,
    +
    56 -737,
    +
    57 -801,
    +
    58 -856,
    +
    59 -904,
    +
    60 -942,
    +
    61 -970,
    +
    62 -989,
    +
    63 -999,
    +
    64 -998,
    +
    65 -987,
    +
    66 -966,
    +
    67 -936,
    +
    68 -896,
    +
    69 -848,
    +
    70 -790,
    +
    71 -725,
    +
    72 -653,
    +
    73 -574,
    +
    74 -490,
    +
    75 -400,
    +
    76 -307,
    +
    77 -210,
    +
    78 -112,
    +
    79 -12,
    +
    80 87,
    +
    81 186,
    +
    82 283,
    +
    83 377,
    +
    84 468,
    +
    85 554,
    +
    86 634,
    +
    87 708,
    +
    88 775,
    +
    89 834,
    +
    90 885,
    +
    91 927,
    +
    92 960,
    +
    93 983,
    +
    94 996,
    +
    95};
    +
    96
    +
    97MAUG_CONST int16_t g_retrofp_sin[] = {
    +
    98 0,
    +
    99 99,
    +
    100 198,
    +
    101 295,
    +
    102 389,
    +
    103 479,
    +
    104 564,
    +
    105 644,
    +
    106 717,
    +
    107 783,
    +
    108 841,
    +
    109 891,
    +
    110 932,
    +
    111 963,
    +
    112 985,
    +
    113 997,
    +
    114 999,
    +
    115 991,
    +
    116 973,
    +
    117 946,
    +
    118 909,
    +
    119 863,
    +
    120 808,
    +
    121 745,
    +
    122 675,
    +
    123 598,
    +
    124 515,
    +
    125 427,
    +
    126 334,
    +
    127 239,
    +
    128 141,
    +
    129 41,
    +
    130 -58,
    +
    131 -157,
    +
    132 -255,
    +
    133 -350,
    +
    134 -442,
    +
    135 -529,
    +
    136 -611,
    +
    137 -687,
    +
    138 -756,
    +
    139 -818,
    +
    140 -871,
    +
    141 -916,
    +
    142 -951,
    +
    143 -977,
    +
    144 -993,
    +
    145 -999,
    +
    146 -996,
    +
    147 -982,
    +
    148 -958,
    +
    149 -925,
    +
    150 -883,
    +
    151 -832,
    +
    152 -772,
    +
    153 -705,
    +
    154 -631,
    +
    155 -550,
    +
    156 -464,
    +
    157 -373,
    +
    158 -279,
    +
    159 -182,
    +
    160 -83,
    +
    161};
    +
    162
    +
    163int16_t retrofp_lut( const int16_t* lut, int16_t num, int16_t mult ) {
    +
    164 int16_t cos_out;
    +
    165 uint8_t neg = 0;
    +
    166
    +
    167 /* Can't take an index of a negative number, so hold on to neg for later. */
    +
    168 if( num < 0 ) {
    +
    169 neg = 1;
    +
    170 num *= -1;
    +
    171 }
    +
    172
    +
    173 /* cos/sin repeat after every 2PI. */
    +
    174 if( num >= (2 * RETROFP_PI) ) {
    +
    175 num -= (2 * RETROFP_PI);
    +
    176 }
    +
    177
    +
    178 /* Remove num precision to get index. */
    +
    179 num /= 100;
    +
    180 cos_out = lut[num];
    +
    181
    +
    182 /* Multiply by multiplier before removing precision. */
    +
    183 cos_out *= mult;
    +
    184 cos_out /= 1000;
    +
    185
    +
    186 /* Restore neg taken earlier. */
    +
    187 if( neg ) {
    +
    188 cos_out *= -1;
    +
    189 }
    +
    190
    +
    191 return (int16_t)cos_out;
    +
    192}
    +
    193
    +
    194#else
    +
    195
    +
    196extern MAUG_CONST int16_t g_retrofp_cos[];
    +
    197extern MAUG_CONST int16_t g_retrofp_sin[];
    +
    198
    +
    199#endif /* RETROFP_C */
    +
    200 /* maug_retrofp */
    +
    202
    +
    203#endif /* !RETROFP_H */
    +
    204
    +
    int16_t retrofp_lut(const int16_t *lut, int16_t num, int16_t mult)
    Given a lookup table, return the corresponding value after trimming precision and making sure number ...
    +
    #define RETROFP_PI
    Fixed-point representation of Pi (3.141).
    Definition retrofp.h:17
    +
    + + + + diff --git a/retroglu_8h.html b/retroglu_8h.html new file mode 100644 index 00000000..55ce0393 --- /dev/null +++ b/retroglu_8h.html @@ -0,0 +1,362 @@ + + + + + + + +maug: retroglu.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    retroglu.h File Reference
    +
    +
    + +

    Library of tools for working with RetroFlat and OpenGL. +More...

    + +

    Go to the source code of this file.

    + + + + + + + + + + + + + + + + + + + + + +

    +Data Structures

    struct  RETROGLU_VERTEX
     
    struct  RETROGLU_VTEXTURE
     
    struct  RETROGLU_MATERIAL
     
    struct  RETROGLU_FACE
     
    struct  RETROGLU_OBJ
     
    struct  RETROGLU_SPRITE
     
    struct  RETROGLU_TILE
     
    struct  RETROGLU_PROJ_ARGS
     
    struct  RETROGLU_PARSER
     As retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information. More...
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    +#define MAUG_CONST   const
     
    +#define RETROGLU_PARSER_ERROR   -1
     
    +#define RETROGLU_PARSER_TOKEN_SZ_MAX   32
     
    +#define RETROGLU_TRACE_LVL   0
     
    +#define RETROGLU_SPRITE_TEX_FRAMES_SZ   10
     
    +#define RETROGLU_FLAGS_INIT_VERTICES   0x01
     
    +#define glShininessf(side, light, f)   glMaterialf( side, light, f )
     
    +#define RETROGLU_PARSER_STATE_NONE   0
     
    +#define RETROGLU_PARSER_STATE_VERTEX_X   1
     
    +#define RETROGLU_PARSER_STATE_VERTEX_Y   2
     
    +#define RETROGLU_PARSER_STATE_VERTEX_Z   3
     
    +#define RETROGLU_PARSER_STATE_COMMENT   4
     
    +#define RETROGLU_PARSER_STATE_FACE_TOKEN   5
     
    +#define RETROGLU_PARSER_STATE_FACE_VERTEX   6
     
    +#define RETROGLU_PARSER_STATE_FACE_TEXTURE   7
     
    +#define RETROGLU_PARSER_STATE_FACE_NORMAL   8
     
    +#define RETROGLU_PARSER_STATE_FACE_MATERIAL   9
     
    +#define RETROGLU_PARSER_STATE_MATERIAL_NAME   10
     
    +#define RETROGLU_PARSER_STATE_MATERIAL_AMB   11
     
    +#define RETROGLU_PARSER_STATE_MATERIAL_DIF   12
     
    +#define RETROGLU_PARSER_STATE_MATERIAL_SPEC   13
     
    +#define RETROGLU_PARSER_STATE_MATERIAL_LIB   14
     
    +#define RETROGLU_PARSER_STATE_MTL_KD_R   15
     
    +#define RETROGLU_PARSER_STATE_MTL_KD_G   16
     
    +#define RETROGLU_PARSER_STATE_MTL_KD_B   17
     
    +#define RETROGLU_PARSER_STATE_VNORMAL_X   18
     
    +#define RETROGLU_PARSER_STATE_VNORMAL_Y   19
     
    +#define RETROGLU_PARSER_STATE_VNORMAL_Z   20
     
    +#define RETROGLU_PARSER_STATE_VTEXTURE_X   21
     
    +#define RETROGLU_PARSER_STATE_VTEXTURE_Y   22
     
    +#define RETROGLU_PARSER_STATE_VTEXTURE_Z   23
     
    +#define RETROGLU_PARSER_STATE_MTL_KA_R   24
     
    +#define RETROGLU_PARSER_STATE_MTL_KA_G   25
     
    +#define RETROGLU_PARSER_STATE_MTL_KA_B   26
     
    +#define RETROGLU_PARSER_STATE_MTL_KS_R   27
     
    +#define RETROGLU_PARSER_STATE_MTL_KS_G   28
     
    +#define RETROGLU_PARSER_STATE_MTL_KS_B   29
     
    +#define RETROGLU_PARSER_STATE_MTL_KE_R   30
     
    +#define RETROGLU_PARSER_STATE_MTL_KE_G   31
     
    +#define RETROGLU_PARSER_STATE_MTL_KE_B   32
     
    +#define RETROGLU_PARSER_STATE_MTL_NS   33
     
    +#define RETROGLU_FACE_VERTICES_SZ_MAX   3
     
    +#define RETROGLU_MATERIAL_NAME_SZ_MAX   32
     
    +#define RETROGLU_MATERIAL_LIB_SZ_MAX   32
     
    +#define RETROGLU_VERTICES_SZ_MAX   1024
     
    +#define RETROGLU_FACES_SZ_MAX   1024
     
    +#define RETROGLU_MATERIALS_SZ_MAX   1024
     
    +#define RETROGLU_SPRITE_X   0
     
    +#define RETROGLU_SPRITE_Y   1
     
    +#define RETROGLU_PROJ_ORTHO   0
     
    +#define RETROGLU_PROJ_FRUSTUM   1
     
    +#define retroglu_tex_px_x_to_f(px, sprite)    ((px) * 1.0 / sprite->texture.tex.w)
     
    +#define retroglu_tex_px_y_to_f(px, sprite)    ((px) * 1.0 / sprite->texture.tex.h)
     
    +#define retroglu_scr_px_x_to_f(px)    (float)(((px) * 1.0 / (retroflat_screen_w() / 2)) - 1.0)
     
    +#define retroglu_scr_px_y_to_f(py)    (float)(((py) * 1.0 / (retroflat_screen_h() / 2)) - 1.0)
     
    #define retroglu_set_sprite_tex(sprite, texture_id, bmp_w, bmp_h)
     
    +#define retroglu_set_sprite_color(sprite, color_in)    memcpy( (sprite)->color, (color_in), 3 * sizeof( float ) )
     
    #define retroglu_parser_state(parser, new_state)
     Change the parser state.
     
    #define RETROGLU_OBJ_TOKENS(f)
     Table of OBJ file tokens understood by the parser.
     
    +#define RETROFLAT_COLOR_TABLE_GL(idx, name_l, name_u, r, g, b)    extern MAUG_CONST float RETROGLU_COLOR_ ## name_u[];
     
    + + + + + + + + +

    +Typedefs

    +typedef float RETROGLU_COLOR[4]
     
    +typedef int(* retroglu_mtl_cb) (const char *filename, struct RETROGLU_PARSER *parser, void *data)
     Callback to execute when its associate in RETROGLU_OBJ_TOKENS is found in an OBJ file.
     
    +typedef int(* retroglu_token_cb) (struct RETROGLU_PARSER *parser)
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Functions

    +void retroglu_init_scene (uint8_t flags)
     
    +void retroglu_init_projection (struct RETROGLU_PROJ_ARGS *args)
     
    +MERROR_RETVAL retroglu_parse_obj_file (const char *filename, struct RETROGLU_PARSER *parser, struct RETROGLU_OBJ *obj)
     
    +MERROR_RETVAL retroglu_load_tex_bmp (const char *filename, uint32_t *p_texture_id, uint32_t *p_bmp_w, uint32_t *p_bmp_h)
     
    +int retroglu_load_tex_bmp_data (const uint8_t *bmp_buf, uint32_t bmp_buf_sz, uint32_t *p_texture_id, uint32_t *p_bmp_w, uint32_t *p_bmp_h)
     
    +void retroglu_draw_poly (struct RETROGLU_OBJ *obj)
     
    +void retroglu_set_tile_clip (struct RETROGLU_TILE *tile, uint32_t px, uint32_t py, uint32_t pw, uint32_t ph, uint8_t flags)
     
    +void retroglu_set_sprite_clip (struct RETROGLU_SPRITE *sprite, uint32_t front_px, uint32_t front_py, uint32_t back_px, uint32_t back_py, uint32_t pw, uint32_t ph, uint8_t flags)
     
    +void retroglu_set_sprite_pos (struct RETROGLU_SPRITE *sprite, uint32_t px, uint32_t py)
     
    +void retroglu_tsrot_sprite (struct RETROGLU_SPRITE *sprite)
     
    +void retroglu_draw_sprite (struct RETROGLU_SPRITE *sprite)
     
    +void retroglu_free_sprite (struct RETROGLU_SPRITE *sprite)
     
    +MERROR_RETVAL retroglu_init_glyph_tex ()
     
    +void retroglu_string (float x, float y, float z, const RETROGLU_COLOR color, const char *str, int str_sz, const char *font_str, uint8_t flags)
     
    +

    Detailed Description

    +

    Library of tools for working with RetroFlat and OpenGL.

    +
    + + + + diff --git a/retroglu_8h_source.html b/retroglu_8h_source.html new file mode 100644 index 00000000..e17426ef --- /dev/null +++ b/retroglu_8h_source.html @@ -0,0 +1,1431 @@ + + + + + + + +maug: retroglu.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retroglu.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef RETROGLU_H
    +
    3#define RETROGLU_H
    +
    4
    +
    5/* TODO */
    +
    6#ifndef MAUG_CONST
    +
    7# define MAUG_CONST const
    +
    8#endif /* !MAUG_CONST */
    +
    9
    +
    19#define RETROGLU_PARSER_ERROR -1
    +
    20
    +
    21#ifndef RETROGLU_PARSER_TOKEN_SZ_MAX
    +
    22# define RETROGLU_PARSER_TOKEN_SZ_MAX 32
    +
    23#endif /* !RETROGLU_PARSER_TOKEN_SZ_MAX */
    +
    24
    +
    25#ifndef RETROGLU_TRACE_LVL
    +
    26# define RETROGLU_TRACE_LVL 0
    +
    27#endif /* !RETROGLU_TRACE_LVL */
    +
    28
    +
    29#ifndef RETROGLU_SPRITE_TEX_FRAMES_SZ
    +
    30# define RETROGLU_SPRITE_TEX_FRAMES_SZ 10
    +
    31#endif /* !RETROGLU_SPRITE_TEX_FRAMES_SZ */
    +
    32
    +
    33#define RETROGLU_FLAGS_INIT_VERTICES 0x01
    +
    34
    +
    35#ifdef MAUG_OS_NDS
    +
    36typedef int GLint;
    +
    37# define RETROGLU_NO_TEXTURES
    +
    38# define glPopMatrix() glPopMatrix( 1 )
    +
    39# define glFlush() glFlush( 0 )
    +
    40# define glPolygonMode( sides, mode )
    +
    41# define glClear( bits )
    +
    42# define glTexCoord2fv( arr )
    +
    43# define glMaterialfv( side, light, rgb ) \
    +
    44 glMaterialf( light, RGB15( (int)rgb[0], (int)rgb[1], (int)rgb[2] ) )
    +
    45# define glShininessf( side, light, f ) glMaterialf( light, f )
    +
    46# define glColor3fv( rgb ) glColor3f( rgb[0], rgb[1], rgb[2] )
    +
    47# define glVertex2fv( xy ) glVertex3f( xy[0], xy[1], 0 )
    +
    48#else
    +
    49# define glShininessf( side, light, f ) glMaterialf( side, light, f )
    +
    50#endif /* MAUG_OS_NDS */
    +
    51
    +
    62#define RETROGLU_PARSER_STATE_NONE 0
    +
    63#define RETROGLU_PARSER_STATE_VERTEX_X 1
    +
    64#define RETROGLU_PARSER_STATE_VERTEX_Y 2
    +
    65#define RETROGLU_PARSER_STATE_VERTEX_Z 3
    +
    66#define RETROGLU_PARSER_STATE_COMMENT 4
    +
    67#define RETROGLU_PARSER_STATE_FACE_TOKEN 5
    +
    68#define RETROGLU_PARSER_STATE_FACE_VERTEX 6
    +
    69#define RETROGLU_PARSER_STATE_FACE_TEXTURE 7
    +
    70#define RETROGLU_PARSER_STATE_FACE_NORMAL 8
    +
    71#define RETROGLU_PARSER_STATE_FACE_MATERIAL 9
    +
    72#define RETROGLU_PARSER_STATE_MATERIAL_NAME 10
    +
    73#define RETROGLU_PARSER_STATE_MATERIAL_AMB 11
    +
    74#define RETROGLU_PARSER_STATE_MATERIAL_DIF 12
    +
    75#define RETROGLU_PARSER_STATE_MATERIAL_SPEC 13
    +
    76#define RETROGLU_PARSER_STATE_MATERIAL_LIB 14
    +
    77#define RETROGLU_PARSER_STATE_MTL_KD_R 15
    +
    78#define RETROGLU_PARSER_STATE_MTL_KD_G 16
    +
    79#define RETROGLU_PARSER_STATE_MTL_KD_B 17
    +
    80#define RETROGLU_PARSER_STATE_VNORMAL_X 18
    +
    81#define RETROGLU_PARSER_STATE_VNORMAL_Y 19
    +
    82#define RETROGLU_PARSER_STATE_VNORMAL_Z 20
    +
    83#define RETROGLU_PARSER_STATE_VTEXTURE_X 21
    +
    84#define RETROGLU_PARSER_STATE_VTEXTURE_Y 22
    +
    85#define RETROGLU_PARSER_STATE_VTEXTURE_Z 23
    +
    86#define RETROGLU_PARSER_STATE_MTL_KA_R 24
    +
    87#define RETROGLU_PARSER_STATE_MTL_KA_G 25
    +
    88#define RETROGLU_PARSER_STATE_MTL_KA_B 26
    +
    89#define RETROGLU_PARSER_STATE_MTL_KS_R 27
    +
    90#define RETROGLU_PARSER_STATE_MTL_KS_G 28
    +
    91#define RETROGLU_PARSER_STATE_MTL_KS_B 29
    +
    92#define RETROGLU_PARSER_STATE_MTL_KE_R 30
    +
    93#define RETROGLU_PARSER_STATE_MTL_KE_G 31
    +
    94#define RETROGLU_PARSER_STATE_MTL_KE_B 32
    +
    95#define RETROGLU_PARSER_STATE_MTL_NS 33
    +
    96 /* maug_retroglu_obj_fsm_states */
    +
    98 /* maug_retroglu_obj_fsm */
    +
    100
    +
    101#ifndef RETROGLU_FACE_VERTICES_SZ_MAX
    +
    102# define RETROGLU_FACE_VERTICES_SZ_MAX 3
    +
    103#endif /* !RETROGLU_FACE_VERTICES_SZ_MAX */
    +
    104
    +
    105#ifndef RETROGLU_MATERIAL_NAME_SZ_MAX
    +
    106# define RETROGLU_MATERIAL_NAME_SZ_MAX 32
    +
    107#endif /* !RETROGLU_MATERIAL_NAME_SZ_MAX */
    +
    108
    +
    109#ifndef RETROGLU_MATERIAL_LIB_SZ_MAX
    +
    110# define RETROGLU_MATERIAL_LIB_SZ_MAX 32
    +
    111#endif /* !RETROGLU_MATERIAL_LIB_SZ_MAX */
    +
    112
    +
    113typedef float RETROGLU_COLOR[4];
    +
    114
    + +
    116 float x;
    +
    117 float y;
    +
    118 float z;
    +
    119};
    +
    120
    + +
    122 float u;
    +
    123 float v;
    +
    124};
    +
    125
    + +
    127 float ambient[4];
    +
    128 float diffuse[4];
    +
    129 float specular[4];
    +
    130 float emissive[4];
    +
    131 float specular_exp;
    +
    132 char name[RETROGLU_MATERIAL_NAME_SZ_MAX];
    +
    133};
    +
    134
    + +
    142 uint16_t vertex_idxs[RETROGLU_FACE_VERTICES_SZ_MAX];
    +
    143 uint16_t vnormal_idxs[RETROGLU_FACE_VERTICES_SZ_MAX];
    +
    144 uint16_t vtexture_idxs[RETROGLU_FACE_VERTICES_SZ_MAX];
    +
    145 uint16_t vertex_idxs_sz;
    +
    146 uint16_t material_idx;
    +
    147};
    +
    148
    +
    149#define RETROGLU_VERTICES_SZ_MAX 1024
    +
    150#define RETROGLU_FACES_SZ_MAX 1024
    +
    151#define RETROGLU_MATERIALS_SZ_MAX 1024
    +
    152
    + +
    154 uint8_t flags;
    +
    155 struct RETROGLU_VERTEX vertices[RETROGLU_VERTICES_SZ_MAX];
    +
    156 uint16_t vertices_sz;
    +
    157 struct RETROGLU_VERTEX vnormals[RETROGLU_VERTICES_SZ_MAX];
    +
    158 uint16_t vnormals_sz;
    +
    159 struct RETROGLU_VTEXTURE vtextures[RETROGLU_VERTICES_SZ_MAX];
    +
    160 uint16_t vtextures_sz;
    +
    165 struct RETROGLU_FACE faces[RETROGLU_FACES_SZ_MAX];
    +
    166 uint16_t faces_sz;
    +
    167 struct RETROGLU_MATERIAL materials[RETROGLU_MATERIALS_SZ_MAX];
    +
    168 uint16_t materials_sz;
    +
    169};
    +
    170
    +
    176#define RETROGLU_SPRITE_X 0
    +
    177#define RETROGLU_SPRITE_Y 1
    +
    178
    + +
    180 float vertices_front[6][2];
    +
    181 float vtexture_front[6][2];
    +
    182 float vertices_back[6][2];
    +
    183 float vtexture_back[6][2];
    +
    184 float translate_x;
    +
    185 float translate_y;
    +
    186 float scale_x;
    +
    187 float scale_y;
    +
    188 int rotate_y;
    +
    189 RETROGLU_COLOR color;
    +
    190 struct RETROFLAT_BITMAP texture;
    +
    191};
    +
    192
    + +
    194 float vertices[6][2];
    +
    195 float vtexture[6][2];
    +
    196 int rotate_x;
    +
    197 struct RETROFLAT_BITMAP texture;
    +
    198};
    +
    199
    +
    200 /* maug_retroglu_sprite */
    +
    202
    +
    203#define RETROGLU_PROJ_ORTHO 0
    +
    204#define RETROGLU_PROJ_FRUSTUM 1
    +
    205
    + +
    207 uint8_t proj;
    +
    208 float rzoom;
    +
    209 float near_plane;
    +
    210 float far_plane;
    +
    211};
    +
    212
    +
    213#define retroglu_tex_px_x_to_f( px, sprite ) \
    +
    214 ((px) * 1.0 / sprite->texture.tex.w)
    +
    215#define retroglu_tex_px_y_to_f( px, sprite ) \
    +
    216 ((px) * 1.0 / sprite->texture.tex.h)
    +
    217
    +
    218#define retroglu_scr_px_x_to_f( px ) \
    +
    219 (float)(((px) * 1.0 / (retroflat_screen_w() / 2)) - 1.0)
    +
    220#define retroglu_scr_px_y_to_f( py ) \
    +
    221 (float)(((py) * 1.0 / (retroflat_screen_h() / 2)) - 1.0)
    +
    222
    +
    223#define retroglu_set_sprite_tex( sprite, texture_id, bmp_w, bmp_h ) \
    +
    224 sprite->texture_id = texture_id; \
    +
    225 sprite->texture_w = bmp_w; \
    +
    226 sprite->texture_h = bmp_h; \
    +
    227 sprite->scale_x = 1.0f; \
    +
    228 sprite->scale_y = 1.0f;
    +
    229
    +
    230#define retroglu_set_sprite_color( sprite, color_in ) \
    +
    231 memcpy( (sprite)->color, (color_in), 3 * sizeof( float ) )
    +
    232
    +
    243#define retroglu_parser_state( parser, new_state ) \
    +
    244 debug_printf( \
    +
    245 RETROGLU_TRACE_LVL, "changing parser to state: %d\n", new_state ); \
    +
    246 (parser)->state = new_state;
    +
    247
    +
    251#define RETROGLU_OBJ_TOKENS( f ) \
    +
    252 f( "v", retroglu_token_vertice ) \
    +
    253 f( "vn", retroglu_token_vnormal ) \
    +
    254 f( "f", retroglu_token_face ) \
    +
    255 f( "usemtl", retroglu_token_usemtl ) \
    +
    256 f( "newmtl", retroglu_token_newmtl ) \
    +
    257 f( "mtllib", retroglu_token_mtllib ) \
    +
    258 f( "Kd", retroglu_token_kd ) \
    +
    259 f( "Ka", retroglu_token_ka ) \
    +
    260 f( "Ks", retroglu_token_ks ) \
    +
    261 f( "Ke", retroglu_token_ks ) \
    +
    262 f( "Ns", retroglu_token_ns )
    +
    263
    +
    264struct RETROGLU_PARSER;
    +
    265
    +
    270typedef int (*retroglu_mtl_cb)(
    +
    271 const char* filename, struct RETROGLU_PARSER* parser, void* data );
    +
    272
    + +
    278 struct RETROGLU_OBJ* obj;
    +
    279 int state;
    +
    280 int material_idx;
    +
    281 char token[RETROGLU_PARSER_TOKEN_SZ_MAX];
    +
    282 int token_sz;
    +
    283 retroglu_mtl_cb load_mtl;
    +
    284 void* load_mtl_data;
    +
    285};
    +
    286
    +
    287typedef int (*retroglu_token_cb)( struct RETROGLU_PARSER* parser );
    +
    288
    +
    289void retroglu_init_scene( uint8_t flags );
    +
    290void retroglu_init_projection( struct RETROGLU_PROJ_ARGS* args );
    +
    291
    + +
    299 struct RETROGLU_PARSER* parser, struct RETROGLU_OBJ* obj,
    +
    300 retroglu_mtl_cb load_mtl, void* load_mtl_data
    +
    301);
    +
    302
    + +
    310retroglu_parse_obj_c( struct RETROGLU_PARSER* parser, unsigned char c );
    +
    311
    +
    312MERROR_RETVAL retroglu_parse_obj_file(
    +
    313 const char* filename, struct RETROGLU_PARSER* parser,
    +
    314 struct RETROGLU_OBJ* obj );
    +
    315 /* maug_retroglu_obj_fsm */
    +
    317
    +
    318MERROR_RETVAL retroglu_load_tex_bmp(
    +
    319 const char* filename, uint32_t* p_texture_id,
    +
    320 uint32_t* p_bmp_w, uint32_t* p_bmp_h );
    +
    321
    +
    322int retroglu_load_tex_bmp_data(
    +
    323 const uint8_t* bmp_buf, uint32_t bmp_buf_sz, uint32_t* p_texture_id,
    +
    324 uint32_t* p_bmp_w, uint32_t* p_bmp_h );
    +
    325
    +
    326void retroglu_draw_poly( struct RETROGLU_OBJ* obj );
    +
    327
    +
    328void retroglu_set_tile_clip(
    +
    329 struct RETROGLU_TILE* tile,
    +
    330 uint32_t px, uint32_t py, uint32_t pw, uint32_t ph, uint8_t flags );
    +
    331
    +
    332void retroglu_set_sprite_clip(
    +
    333 struct RETROGLU_SPRITE* sprite,
    +
    334 uint32_t front_px, uint32_t front_py, uint32_t back_px, uint32_t back_py,
    +
    335 uint32_t pw, uint32_t ph, uint8_t flags );
    +
    336
    +
    337void retroglu_set_sprite_pos(
    +
    338 struct RETROGLU_SPRITE* sprite, uint32_t px, uint32_t py );
    +
    339
    +
    340void retroglu_tsrot_sprite( struct RETROGLU_SPRITE* sprite );
    +
    341
    +
    342void retroglu_draw_sprite( struct RETROGLU_SPRITE* sprite );
    +
    343
    +
    344void retroglu_free_sprite( struct RETROGLU_SPRITE* sprite );
    +
    345
    +
    346MERROR_RETVAL retroglu_init_glyph_tex();
    +
    347
    +
    348void retroglu_string(
    +
    349 float x, float y, float z, const RETROGLU_COLOR color,
    +
    350 const char* str, int str_sz, const char* font_str, uint8_t flags );
    +
    351
    +
    352#ifdef RETROGLU_C
    +
    353
    +
    354# define RETROFLAT_COLOR_TABLE_GL( idx, name_l, name_u, r, g, b ) \
    +
    355 MAUG_CONST float RETROGLU_COLOR_ ## name_u[] = { \
    +
    356 (float)((float)r * 1.0f / 255.0f), \
    +
    357 (float)((float)g * 1.0f / 255.0f), \
    +
    358 (float)((float)b * 1.0f / 255.0f) };
    +
    359
    +
    360RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_GL )
    +
    361
    +
    362# define RETROGLU_OBJ_TOKEN_STRINGS( token, callback ) token,
    +
    363
    +
    364int retroglu_token_vertice( struct RETROGLU_PARSER* parser ) {
    +
    365 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_VERTEX_X );
    +
    366 return RETROFLAT_OK;
    +
    367}
    +
    368
    +
    369int retroglu_token_vnormal( struct RETROGLU_PARSER* parser ) {
    +
    370 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_VNORMAL_X );
    +
    371 return RETROFLAT_OK;
    +
    372}
    +
    373
    +
    374int retroglu_token_face( struct RETROGLU_PARSER* parser ) {
    +
    375 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_FACE_VERTEX );
    +
    376 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz = 0;
    +
    377 return RETROFLAT_OK;
    +
    378}
    +
    379
    +
    380int retroglu_token_usemtl( struct RETROGLU_PARSER* parser ) {
    +
    381 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_FACE_MATERIAL );
    +
    382 return RETROFLAT_OK;
    +
    383}
    +
    384
    +
    385int retroglu_token_newmtl( struct RETROGLU_PARSER* parser ) {
    +
    386 /* Set default lighting alpha to non-transparent. */
    +
    387 parser->obj->materials[parser->obj->materials_sz].ambient[3] = 1.0f;
    +
    388 parser->obj->materials[parser->obj->materials_sz].diffuse[3] = 1.0f;
    +
    389 parser->obj->materials[parser->obj->materials_sz].specular[3] = 1.0f;
    +
    390 parser->obj->materials[parser->obj->materials_sz].emissive[3] = 1.0f;
    +
    391 parser->obj->materials[parser->obj->materials_sz].specular_exp = 0;
    +
    392 parser->obj->materials_sz++;
    +
    393 assert( parser->obj->materials_sz <= RETROGLU_MATERIALS_SZ_MAX );
    +
    394 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MATERIAL_NAME );
    +
    395 return RETROFLAT_OK;
    +
    396}
    +
    397
    +
    398int retroglu_token_mtllib( struct RETROGLU_PARSER* parser ) {
    +
    399 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MATERIAL_LIB );
    +
    400 return RETROFLAT_OK;
    +
    401}
    +
    402
    +
    403int retroglu_token_kd( struct RETROGLU_PARSER* parser ) {
    +
    404 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MTL_KD_R );
    +
    405 return RETROFLAT_OK;
    +
    406}
    +
    407
    +
    408int retroglu_token_ka( struct RETROGLU_PARSER* parser ) {
    +
    409 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MTL_KA_R );
    +
    410 return RETROFLAT_OK;
    +
    411}
    +
    412
    +
    413int retroglu_token_ks( struct RETROGLU_PARSER* parser ) {
    +
    414 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MTL_KS_R );
    +
    415 return RETROFLAT_OK;
    +
    416}
    +
    417
    +
    418int retroglu_token_ke( struct RETROGLU_PARSER* parser ) {
    +
    419 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MTL_KE_R );
    +
    420 return RETROFLAT_OK;
    +
    421}
    +
    422
    +
    423int retroglu_token_ns( struct RETROGLU_PARSER* parser ) {
    +
    424 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_MTL_NS );
    +
    425 return RETROFLAT_OK;
    +
    426}
    +
    427
    +
    428char* g_retroglu_token_strings[] = {
    +
    429 RETROGLU_OBJ_TOKENS( RETROGLU_OBJ_TOKEN_STRINGS )
    +
    430 ""
    +
    431};
    +
    432
    +
    433# define RETROGLU_OBJ_TOKEN_CALLBACKS( token, callback ) callback,
    +
    434
    +
    435retroglu_token_cb g_retroglu_token_callbacks[] = {
    +
    436 RETROGLU_OBJ_TOKENS( RETROGLU_OBJ_TOKEN_CALLBACKS )
    +
    437 NULL
    +
    438};
    +
    439
    +
    440void retroglu_init_scene( uint8_t flags ) {
    +
    441 debug_printf( RETROGLU_TRACE_LVL, "initializing..." );
    +
    442
    +
    443#ifdef MAUG_OS_NDS
    +
    444 glMaterialShinyness();
    +
    445 glPolyFmt( POLY_ALPHA( 15 ) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 );
    +
    446#else
    +
    447 glEnable( GL_CULL_FACE );
    +
    448 glShadeModel( GL_SMOOTH );
    +
    449
    +
    450 /* Setup texture transparency. */
    +
    451 glEnable( GL_TEXTURE_2D );
    +
    452 glEnable( GL_BLEND );
    +
    453 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    +
    454
    +
    455 /* Setup depth buffer so triangles in back are hidden. */
    +
    456 glEnable( GL_DEPTH_TEST );
    +
    457 glDepthMask( GL_TRUE );
    +
    458 glDepthFunc( GL_LESS );
    +
    459 glDepthRange( 0.0f, 1.0f );
    +
    460#endif /* !MAUG_OS_NDS */
    +
    461}
    +
    462
    +
    463void retroglu_init_projection( struct RETROGLU_PROJ_ARGS* args ) {
    +
    464 float aspect_ratio = 0;
    +
    465
    +
    466 /* Setup projection. */
    +
    467#ifdef MAUG_OS_NDS
    +
    468 glViewport( 0, 0, 255, 191 );
    +
    469#else
    +
    470 glViewport(
    +
    471 0, 0, (uint32_t)retroflat_screen_w(), (uint32_t)retroflat_screen_h() );
    +
    472#endif
    +
    473 aspect_ratio = (float)retroflat_screen_w() / (float)retroflat_screen_h();
    +
    474
    +
    475 /* Switch to projection matrix for setup. */
    +
    476 glMatrixMode( GL_PROJECTION );
    +
    477
    +
    478 /* Zero everything out. */
    +
    479 glLoadIdentity();
    +
    480
    +
    481 /* Near plane can't be zero for frustum! */
    +
    482 assert( 0 != args->near_plane );
    +
    483
    +
    484 switch( args->proj ) {
    +
    485 case RETROGLU_PROJ_FRUSTUM:
    +
    486 /* This is really tweaky, and when it breaks, polygons seem to get drawn
    +
    487 * out of order? Still experimenting/researching. */
    +
    488 debug_printf( RETROGLU_TRACE_LVL, "aspect ratio: %f", aspect_ratio );
    +
    489 glFrustum(
    +
    490 /* The smaller these are, the closer it lets us get to the camera? */
    +
    491 -1.0f * args->rzoom * aspect_ratio, args->rzoom * aspect_ratio,
    +
    492 -1.0f * args->rzoom, args->rzoom,
    +
    493 args->near_plane, args->far_plane );
    +
    494 break;
    +
    495
    +
    496 case RETROGLU_PROJ_ORTHO:
    +
    497 /* This is much simpler/more forgiving than frustum. */
    +
    498 glOrtho(
    +
    499 -1.0f * args->rzoom * aspect_ratio,
    +
    500 args->rzoom * aspect_ratio,
    +
    501 -1.0f * args->rzoom, args->rzoom,
    +
    502 args->near_plane, args->far_plane );
    +
    503 break;
    +
    504 }
    +
    505
    +
    506 /* Revert to model matrix for later instructions (out of this scope). */
    +
    507 glMatrixMode( GL_MODELVIEW );
    +
    508}
    +
    509
    + +
    511 struct RETROGLU_PARSER* parser, struct RETROGLU_OBJ* obj,
    +
    512 retroglu_mtl_cb load_mtl, void* load_mtl_data
    +
    513) {
    +
    514 parser->load_mtl = load_mtl;
    +
    515 parser->load_mtl_data = load_mtl_data;
    +
    516 parser->obj = obj;
    +
    517 assert( NULL != parser->obj );
    +
    518 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    519 parser->token_sz = 0;
    +
    520}
    +
    521
    +
    522#define RETROGLU_TOKENS_VF( f ) \
    +
    523 f( "X", VERTEX_X, vertices, vertices_sz, x, VERTEX_Y ) \
    +
    524 f( "Y", VERTEX_Y, vertices, vertices_sz, y, VERTEX_Z ) \
    +
    525 f( "Z", VERTEX_Z, vertices, vertices_sz, z, NONE ) \
    +
    526 f( "normal X", VNORMAL_X, vnormals, vnormals_sz, x, VNORMAL_Y ) \
    +
    527 f( "normal Y", VNORMAL_Y, vnormals, vnormals_sz, y, VNORMAL_Z ) \
    +
    528 f( "normal Z", VNORMAL_Z, vnormals, vnormals_sz, z, NONE ) \
    +
    529 f( "mtl Kd R", MTL_KD_R, materials, materials_sz-1, diffuse[0], MTL_KD_G ) \
    +
    530 f( "mtl Kd G", MTL_KD_G, materials, materials_sz-1, diffuse[1], MTL_KD_B ) \
    +
    531 f( "mtl Kd B", MTL_KD_B, materials, materials_sz-1, diffuse[2], NONE ) \
    +
    532 f( "mtl Ka R", MTL_KA_R, materials, materials_sz-1, ambient[0], MTL_KA_G ) \
    +
    533 f( "mtl Ka G", MTL_KA_G, materials, materials_sz-1, ambient[1], MTL_KA_B ) \
    +
    534 f( "mtl Ka B", MTL_KA_B, materials, materials_sz-1, ambient[2], NONE ) \
    +
    535 f( "mtl Ks R", MTL_KS_R, materials, materials_sz-1, specular[0], MTL_KS_G ) \
    +
    536 f( "mtl Ks G", MTL_KS_G, materials, materials_sz-1, specular[1], MTL_KS_B ) \
    +
    537 f( "mtl Ks B", MTL_KS_B, materials, materials_sz-1, specular[2], NONE ) \
    +
    538 f( "mtl Ke R", MTL_KE_R, materials, materials_sz-1, emissive[0], MTL_KE_G ) \
    +
    539 f( "mtl Ke G", MTL_KE_G, materials, materials_sz-1, emissive[1], MTL_KE_B ) \
    +
    540 f( "mtl Ke B", MTL_KE_B, materials, materials_sz-1, emissive[2], NONE ) \
    +
    541 f( "mtl Ns", MTL_NS, materials, materials_sz-1, specular_exp, NONE )
    +
    542
    +
    543#define RETROGLU_TOKEN_PARSE_VF( desc, cond, array, sz, val, state_next ) \
    +
    544 } else if( RETROGLU_PARSER_STATE_ ## cond == parser->state ) { \
    +
    545 parser->obj->array[parser->obj->sz].val = strtod( parser->token, NULL ); \
    +
    546 debug_printf( RETROGLU_TRACE_LVL, "vertex %d " desc ": %f\n", \
    +
    547 parser->obj->sz, parser->obj->array[parser->obj->sz].val ); \
    +
    548 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_ ## state_next );
    +
    549
    + +
    551retroglu_parse_token( struct RETROGLU_PARSER* parser ) {
    +
    552 int i = 0;
    + +
    554
    +
    555 if( 0 == parser->token_sz ) {
    +
    556 /* Empty token. */
    +
    557 goto cleanup;
    +
    558 }
    +
    559
    +
    560 /* NULL-terminate token. */
    +
    561 parser->token[parser->token_sz] = '\0';
    +
    562
    +
    563 debug_printf( RETROGLU_TRACE_LVL, "token: %s\n", parser->token );
    +
    564
    +
    565 if( RETROGLU_PARSER_STATE_MATERIAL_LIB == parser->state ) {
    +
    566
    +
    567 debug_printf(
    +
    568 RETROGLU_TRACE_LVL, "parsing material lib: %s\n", parser->token );
    +
    569 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    570 assert( NULL != parser->load_mtl );
    +
    571 return parser->load_mtl( parser->token, parser, parser->load_mtl_data );
    +
    572
    +
    573 RETROGLU_TOKENS_VF( RETROGLU_TOKEN_PARSE_VF )
    +
    574
    +
    575 /* TODO: Handle W. */
    +
    576
    +
    577 } else if( RETROGLU_PARSER_STATE_FACE_VERTEX == parser->state ) {
    +
    578 /* Parsing face vertex index. */
    +
    579 parser->obj->faces[parser->obj->faces_sz].vertex_idxs[
    +
    580 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] =
    +
    581 atoi( parser->token );
    +
    582
    +
    583 debug_printf( RETROGLU_TRACE_LVL, "face %d, vertex %d: %d\n",
    +
    584 parser->obj->faces_sz, parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz,
    +
    585 parser->obj->faces[parser->obj->faces_sz].vertex_idxs[
    +
    586 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] );
    +
    587
    +
    588 /* The new state is set in the parser below, as it could become
    +
    589 * RETROGLU_PARSER_STATE_FACE_NORMAL or RETROGLU_PARSER_STATE_NONE,
    +
    590 * depending on whether it's a whitespace/newline/slash after.
    +
    591 * Same for index incr.
    +
    592 */
    +
    593
    +
    594 } else if( RETROGLU_PARSER_STATE_FACE_NORMAL == parser->state ) {
    +
    595
    +
    596 /* Parsing face normal index. */
    +
    597 parser->obj->faces[parser->obj->faces_sz].vnormal_idxs[
    +
    598 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] =
    +
    599 atoi( parser->token );
    +
    600
    +
    601 debug_printf( RETROGLU_TRACE_LVL, "face %d, normal %d: %d\n",
    +
    602 parser->obj->faces_sz, parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz,
    +
    603 parser->obj->faces[parser->obj->faces_sz].vnormal_idxs[
    +
    604 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] );
    +
    605
    +
    606 /* The new state is set in the parser below, as it could become
    +
    607 * RETROGLU_PARSER_STATE_FACE_NORMAL or RETROGLU_PARSER_STATE_NONE,
    +
    608 * depending on whether it's a whitespace/newline/slash after.
    +
    609 * Same for index incr.
    +
    610 */
    +
    611
    +
    612 } else if( RETROGLU_PARSER_STATE_FACE_TEXTURE == parser->state ) {
    +
    613
    +
    614 /* Parsing face texture index. */
    +
    615 parser->obj->faces[parser->obj->faces_sz].vtexture_idxs[
    +
    616 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] =
    +
    617 atoi( parser->token );
    +
    618
    +
    619 debug_printf( RETROGLU_TRACE_LVL, "face %d, texture %d: %d\n",
    +
    620 parser->obj->faces_sz, parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz,
    +
    621 parser->obj->faces[parser->obj->faces_sz].vtexture_idxs[
    +
    622 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz] );
    +
    623
    +
    624 /* The new state is set in the parser below, as it could become
    +
    625 * RETROGLU_PARSER_STATE_FACE_NORMAL or RETROGLU_PARSER_STATE_NONE,
    +
    626 * depending on whether it's a whitespace/newline/slash after.
    +
    627 * Same for index incr.
    +
    628 */
    +
    629
    +
    630
    +
    631 } else if( RETROGLU_PARSER_STATE_FACE_MATERIAL == parser->state ) {
    +
    632
    +
    633 /* Find the material index and assign it to the parser. */
    +
    634 for( i = 0 ; parser->obj->materials_sz > i ; i++ ) {
    +
    635 debug_printf(
    +
    636 RETROGLU_TRACE_LVL,
    +
    637 "%s vs %s\n", parser->obj->materials[i].name, parser->token );
    +
    638 if( 0 == strncmp(
    +
    639 parser->obj->materials[i].name, parser->token,
    +
    640 RETROGLU_MATERIAL_NAME_SZ_MAX
    +
    641 ) ) {
    +
    642 debug_printf( RETROGLU_TRACE_LVL, "using material: \"%s\" (%d)\n",
    +
    643 parser->obj->materials[i].name, i );
    +
    644 parser->material_idx = i;
    +
    645 break;
    +
    646 }
    +
    647 }
    +
    648 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    649
    +
    650 } else if( RETROGLU_PARSER_STATE_MATERIAL_NAME == parser->state ) {
    +
    651
    +
    652 debug_printf(
    +
    653 RETROGLU_TRACE_LVL, "adding material: \"%s\" at idx: %d\n",
    +
    654 parser->token, parser->obj->materials_sz - 1 );
    +
    655 strncpy(
    +
    656 parser->obj->materials[parser->obj->materials_sz - 1].name,
    +
    657 parser->token,
    +
    658 RETROGLU_MATERIAL_NAME_SZ_MAX );
    +
    659 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    660
    +
    661 } else {
    +
    662 /* Check against generic tokens. */
    +
    663 while( '\0' != g_retroglu_token_strings[i][0] ) {
    +
    664 if(
    +
    665 parser->token_sz == strlen( g_retroglu_token_strings[i] ) &&
    +
    666 0 == strncmp(
    +
    667 parser->token, g_retroglu_token_strings[i], parser->token_sz )
    +
    668 ) {
    +
    669 retval = g_retroglu_token_callbacks[i]( parser );
    +
    670 goto cleanup;
    +
    671 }
    +
    672 i++;
    +
    673 }
    +
    674 }
    +
    675
    +
    676cleanup:
    +
    677
    +
    678 /* Reset token. */
    +
    679 parser->token_sz = 0;
    +
    680
    +
    681 return retval;
    +
    682}
    +
    683
    + +
    685retroglu_append_token( struct RETROGLU_PARSER* parser, unsigned char c ) {
    +
    686 parser->token[parser->token_sz++] = c;
    +
    687
    +
    688 /* Protect against token overflow. */
    +
    689 if( parser->token_sz >= RETROGLU_PARSER_TOKEN_SZ_MAX ) {
    +
    690 debug_printf( RETROGLU_TRACE_LVL, "token out of bounds!\n" );
    +
    691 return RETROGLU_PARSER_ERROR;
    +
    692 }
    +
    693
    +
    694 return RETROFLAT_OK;
    +
    695}
    +
    696
    + +
    698retroglu_parse_obj_c( struct RETROGLU_PARSER* parser, unsigned char c ) {
    + +
    700
    +
    701 if(
    +
    702 RETROGLU_PARSER_STATE_COMMENT == parser->state && '\r' != c && '\n' != c
    +
    703 ) {
    +
    704 /* We're inside of a comment. */
    +
    705 return RETROFLAT_OK;
    +
    706 }
    +
    707
    +
    708 switch( c ) {
    +
    709 case '#':
    +
    710 /* Start of a comment. */
    +
    711 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_COMMENT );
    +
    712 break;
    +
    713
    +
    714 case '\r':
    +
    715 case '\n':
    +
    716 /* New line! End of a comment or token. */
    +
    717 if( RETROGLU_PARSER_STATE_COMMENT == parser->state ) {
    +
    718 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    719 return RETROFLAT_OK;
    +
    720
    +
    721 } else if(
    +
    722 RETROGLU_PARSER_STATE_FACE_VERTEX == parser->state ||
    +
    723 RETROGLU_PARSER_STATE_FACE_TEXTURE == parser->state ||
    +
    724 RETROGLU_PARSER_STATE_FACE_NORMAL == parser->state
    +
    725 ) {
    +
    726 /* End of face. */
    +
    727 retval = retroglu_parse_token( parser );
    +
    728 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_NONE );
    +
    729
    +
    730 /* Use current parser material. */
    +
    731 parser->obj->faces[parser->obj->faces_sz].material_idx =
    +
    732 parser->material_idx;
    +
    733
    +
    734 /* Move to next face. */
    +
    735 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz++;
    +
    736 parser->obj->faces_sz++; /* Newline means this face is done. */
    +
    737 assert( parser->obj->faces_sz <= RETROGLU_FACES_SZ_MAX );
    +
    738 return retval;
    +
    739
    +
    740 } else if( RETROGLU_PARSER_STATE_VNORMAL_Z == parser->state ) {
    +
    741
    +
    742 retval = retroglu_parse_token( parser );
    +
    743 /* End of vertex. */
    +
    744 parser->obj->vnormals_sz++;
    +
    745 assert( parser->obj->vnormals_sz <= RETROGLU_VERTICES_SZ_MAX );
    +
    746 return retval;
    +
    747
    +
    748 } else if( RETROGLU_PARSER_STATE_VERTEX_Z == parser->state ) {
    +
    749
    +
    750 retval = retroglu_parse_token( parser );
    +
    751 /* End of vertex. */
    +
    752 parser->obj->vertices_sz++;
    +
    753 assert( parser->obj->vertices_sz <= RETROGLU_VERTICES_SZ_MAX );
    +
    754 return retval;
    +
    755
    +
    756 } else {
    +
    757 return retroglu_parse_token( parser );
    +
    758 }
    +
    759
    +
    760 case '\t':
    +
    761 case ' ':
    +
    762 /* Whitespace. Inside of a comment or time for a new token. */
    +
    763 if( RETROGLU_PARSER_STATE_COMMENT == parser->state ) {
    +
    764 /* Do nothing on spaces in comments. */
    +
    765 return RETROFLAT_OK;
    +
    766
    +
    767 } else if(
    +
    768 RETROGLU_PARSER_STATE_FACE_VERTEX == parser->state ||
    +
    769 RETROGLU_PARSER_STATE_FACE_TEXTURE == parser->state ||
    +
    770 RETROGLU_PARSER_STATE_FACE_NORMAL == parser->state
    +
    771 ) {
    +
    772 /* A space means we're moving on to the next vertex! */
    +
    773 retval = retroglu_parse_token( parser );
    +
    774 parser->obj->faces[parser->obj->faces_sz].vertex_idxs_sz++;
    +
    775 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_FACE_VERTEX );
    +
    776 return retval;
    +
    777
    +
    778 } else if( RETROGLU_PARSER_STATE_VNORMAL_Z == parser->state ) {
    +
    779
    +
    780 retval = retroglu_parse_token( parser );
    +
    781 /* End of vertex. */
    +
    782 parser->obj->vnormals_sz++;
    +
    783 assert( parser->obj->vnormals_sz <= RETROGLU_VERTICES_SZ_MAX );
    +
    784 return retval;
    +
    785
    +
    786 } else if( RETROGLU_PARSER_STATE_VERTEX_Z == parser->state ) {
    +
    787
    +
    788 retval = retroglu_parse_token( parser );
    +
    789 /* End of vertex. */
    +
    790 parser->obj->vertices_sz++;
    +
    791 assert( parser->obj->vertices_sz <= RETROGLU_VERTICES_SZ_MAX );
    +
    792 return retval;
    +
    793
    +
    794 } else if( RETROGLU_PARSER_STATE_MTL_KD_B == parser->state ) {
    +
    795 retval = retroglu_parse_token( parser );
    +
    796 /* This tuple has a space after blue, so maybe alpha? */
    +
    797 /* TODO: Set alpha state. */
    +
    798 return retval;
    +
    799
    +
    800 } else {
    +
    801 return retroglu_parse_token( parser );
    +
    802 }
    +
    803
    +
    804 case '/':
    +
    805 if( RETROGLU_PARSER_STATE_FACE_VERTEX == parser->state ) {
    +
    806 retval = retroglu_parse_token( parser );
    +
    807 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_FACE_TEXTURE );
    +
    808 return retval;
    +
    809
    +
    810 } else if( RETROGLU_PARSER_STATE_FACE_TEXTURE == parser->state ) {
    +
    811 retval = retroglu_parse_token( parser );
    +
    812 retroglu_parser_state( parser, RETROGLU_PARSER_STATE_FACE_NORMAL );
    +
    813 return retval;
    +
    814 }
    +
    815
    +
    816 /* v/vt/vn/??? */
    +
    817 assert( RETROGLU_PARSER_STATE_FACE_NORMAL != parser->state );
    +
    818
    +
    819 /* If not part of a face, fall through to default append. */
    +
    820 return retroglu_append_token( parser, c );
    +
    821
    +
    822 default:
    +
    823 return retroglu_append_token( parser, c );
    +
    824 }
    +
    825
    +
    826 return RETROFLAT_OK;
    +
    827}
    +
    828
    +
    829MERROR_RETVAL retroglu_parse_obj_file(
    +
    830 const char* filename, struct RETROGLU_PARSER* parser,
    +
    831 struct RETROGLU_OBJ* obj
    +
    832) {
    +
    833 FILE* obj_file = NULL;
    +
    834 uint32_t i = 0; /* Index in file buffer, so long. */
    +
    835 size_t obj_read = 0;
    +
    836 int auto_parser = 0; /* Did we provision parser? */
    +
    837 uint8_t* obj_buf = NULL;
    +
    838 size_t obj_buf_sz = 0;
    +
    839 char filename_path[RETROFLAT_PATH_MAX + 1];
    +
    840 MERROR_RETVAL retval = MERROR_OK;
    +
    841
    +
    842 if( NULL == parser ) {
    +
    843 parser = calloc( 1, sizeof( struct RETROGLU_PARSER ) );
    +
    844 assert( NULL != parser );
    +
    845 auto_parser = 1;
    +
    846 }
    +
    847
    +
    848 /* Build the path to the obj. */
    +
    849 memset( filename_path, '\0', RETROFLAT_PATH_MAX + 1 );
    +
    850 maug_snprintf( filename_path, RETROFLAT_PATH_MAX, "%s%c%s",
    +
    851 g_retroflat_state->assets_path, RETROFLAT_PATH_SEP, filename );
    +
    852
    +
    853 /* Open the file and allocate the buffer. */
    +
    854 debug_printf( RETROGLU_TRACE_LVL, "opening %s...", filename_path );
    +
    855 obj_file = fopen( filename_path, "r" );
    +
    856 assert( NULL != obj_file );
    +
    857 fseek( obj_file, 0, SEEK_END );
    +
    858 obj_buf_sz = ftell( obj_file );
    +
    859 fseek( obj_file, 0, SEEK_SET );
    +
    860 debug_printf(
    +
    861 RETROGLU_TRACE_LVL,
    +
    862 "opened %s, " SIZE_T_FMT " bytes", filename_path, obj_buf_sz );
    +
    863 obj_buf = calloc( 1, obj_buf_sz );
    +
    864 assert( NULL != obj_buf );
    +
    865 obj_read = fread( obj_buf, 1, obj_buf_sz, obj_file );
    +
    866 debug_printf( RETROGLU_TRACE_LVL, "read " SIZE_T_FMT " bytes", obj_read );
    +
    867 assert( obj_read == obj_buf_sz );
    +
    868 fclose( obj_file );
    +
    869
    + +
    871 parser, obj, (retroglu_mtl_cb)retroglu_parse_obj_file, obj );
    +
    872
    +
    873 /* Parse the obj, byte by byte. */
    +
    874 for( i = 0 ; obj_buf_sz > i ; i++ ) {
    +
    875 retval = retroglu_parse_obj_c( parser, obj_buf[i] );
    +
    876 assert( 0 <= retval );
    +
    877 }
    +
    878 free( obj_buf );
    +
    879 obj_buf = NULL;
    +
    880 obj_buf_sz = 0;
    +
    881
    +
    882 if( auto_parser ) {
    +
    883 free( parser );
    +
    884 parser = NULL;
    +
    885 }
    +
    886
    +
    887 debug_printf(
    +
    888 RETROGLU_TRACE_LVL,
    +
    889 "parsed %s, " UPRINTF_U32 " vertices, " UPRINTF_U32 " materials",
    +
    890 filename_path, obj->vertices_sz, obj->materials_sz );
    +
    891
    +
    892 return retval;
    +
    893}
    +
    894
    +
    895void retroglu_draw_poly( struct RETROGLU_OBJ* obj ) {
    +
    896 int i = 0;
    +
    897 int j = 0;
    +
    898
    +
    899 glBegin( GL_TRIANGLES );
    +
    900 for( i = 0 ; obj->faces_sz > i ; i++ ) {
    +
    901
    +
    902 /* TODO: Handle material on NDS. */
    +
    903 glMaterialfv( GL_FRONT, GL_DIFFUSE,
    +
    904 obj->materials[obj->faces[i].material_idx].diffuse );
    +
    905 /*
    +
    906 glMaterialfv( GL_FRONT, GL_AMBIENT,
    +
    907 obj->materials[faces[i].material_idx].ambient );
    +
    908 */
    +
    909 glMaterialfv( GL_FRONT, GL_SPECULAR,
    +
    910 obj->materials[obj->faces[i].material_idx].specular );
    +
    911 glMaterialfv( GL_FRONT, GL_EMISSION,
    +
    912 obj->materials[obj->faces[i].material_idx].emissive );
    +
    913
    +
    914 glColor3fv( obj->materials[obj->faces[i].material_idx].diffuse );
    +
    915
    +
    916 /* Use a specific macro here that can be overridden for e.g. the NDS. */
    +
    917 glShininessf( GL_FRONT, GL_SHININESS,
    +
    918 obj->materials[obj->faces[i].material_idx].specular_exp );
    +
    919
    +
    920 for( j = 0 ; obj->faces[i].vertex_idxs_sz > j ; j++ ) {
    +
    921 assert( 0 < obj->faces[i].vertex_idxs[j] );
    +
    922 assert( 3 == obj->faces[i].vertex_idxs_sz );
    +
    923
    +
    924 glNormal3f(
    +
    925 obj->vnormals[obj->faces[i].vnormal_idxs[j] - 1].x,
    +
    926 obj->vnormals[obj->faces[i].vnormal_idxs[j] - 1].y,
    +
    927 obj->vnormals[obj->faces[i].vnormal_idxs[j] - 1].z );
    +
    928
    +
    929 glVertex3f(
    +
    930 obj->vertices[obj->faces[i].vertex_idxs[j] - 1].x,
    +
    931 obj->vertices[obj->faces[i].vertex_idxs[j] - 1].y,
    +
    932 obj->vertices[obj->faces[i].vertex_idxs[j] - 1].z );
    +
    933 }
    +
    934
    +
    935 }
    +
    936 glEnd();
    +
    937}
    +
    938
    +
    939void retroglu_set_tile_clip(
    +
    940 struct RETROGLU_TILE* tile,
    +
    941 uint32_t px, uint32_t py, uint32_t pw, uint32_t ph, uint8_t flags
    +
    942) {
    +
    943 /* Set vertices in terms of half the clip size so that rotation is around
    +
    944 * the midpoint of the sprite, not the side!
    +
    945 */
    +
    946 float clip_tex_x = 0, /* Front tex X */
    +
    947 clip_tex_y = 0, /* Front tex Y */
    +
    948 clip_tex_w = 0,
    +
    949 clip_tex_h = 0;
    +
    950
    +
    951 /* Setup texture tilesheet. */
    +
    952
    +
    953 clip_tex_x = retroglu_tex_px_x_to_f( px, tile );
    +
    954 clip_tex_y = retroglu_tex_px_y_to_f( py, tile );
    +
    955 clip_tex_w = retroglu_tex_px_x_to_f( pw, tile );
    +
    956 clip_tex_h = retroglu_tex_px_y_to_f( ph, tile );
    +
    957
    +
    958 /* == Front Face Textures == */
    +
    959
    +
    960 /* Lower Left */
    +
    961 tile->vtexture[0][RETROGLU_SPRITE_X] = clip_tex_x;
    +
    962 tile->vtexture[0][RETROGLU_SPRITE_Y] = clip_tex_y;
    +
    963
    +
    964 /* Lower Right */
    +
    965 tile->vtexture[1][RETROGLU_SPRITE_X] = clip_tex_x + clip_tex_w;
    +
    966 tile->vtexture[1][RETROGLU_SPRITE_Y] = clip_tex_y;
    +
    967
    +
    968 /* Upper Right */
    +
    969 tile->vtexture[2][RETROGLU_SPRITE_X] = clip_tex_x + clip_tex_w;
    +
    970 tile->vtexture[2][RETROGLU_SPRITE_Y] = clip_tex_y + clip_tex_h;
    +
    971
    +
    972 /* Upper Right */
    +
    973 tile->vtexture[3][RETROGLU_SPRITE_X] = clip_tex_x + clip_tex_w;
    +
    974 tile->vtexture[3][RETROGLU_SPRITE_Y] = clip_tex_y + clip_tex_h;
    +
    975
    +
    976 /* Upper Left */
    +
    977 tile->vtexture[4][RETROGLU_SPRITE_X] = clip_tex_x;
    +
    978 tile->vtexture[4][RETROGLU_SPRITE_Y] = clip_tex_y + clip_tex_h;
    +
    979
    +
    980 /* Lower Left */
    +
    981 tile->vtexture[5][RETROGLU_SPRITE_X] = clip_tex_x;
    +
    982 tile->vtexture[5][RETROGLU_SPRITE_Y] = clip_tex_y;
    +
    983
    +
    984 if(
    +
    985 RETROGLU_FLAGS_INIT_VERTICES != (RETROGLU_FLAGS_INIT_VERTICES & flags)
    +
    986 ) {
    +
    987 return;
    +
    988 }
    +
    989
    +
    990 /* == Front Face Vertices == */
    +
    991
    +
    992 /* Lower-Left */
    +
    993 tile->vertices[0][RETROGLU_SPRITE_X] = -1;
    +
    994 tile->vertices[0][RETROGLU_SPRITE_Y] = -1;
    +
    995
    +
    996 /* Lower-Right */
    +
    997 tile->vertices[1][RETROGLU_SPRITE_X] = 1;
    +
    998 tile->vertices[1][RETROGLU_SPRITE_Y] = -1;
    +
    999
    +
    1000 /* Upper-Right */
    +
    1001 tile->vertices[2][RETROGLU_SPRITE_X] = 1;
    +
    1002 tile->vertices[2][RETROGLU_SPRITE_Y] = 1;
    +
    1003
    +
    1004 /* Upper-Right */
    +
    1005 tile->vertices[3][RETROGLU_SPRITE_X] = 1;
    +
    1006 tile->vertices[3][RETROGLU_SPRITE_Y] = 1;
    +
    1007
    +
    1008 /* Upper-Left */
    +
    1009 tile->vertices[4][RETROGLU_SPRITE_X] = -1;
    +
    1010 tile->vertices[4][RETROGLU_SPRITE_Y] = 1;
    +
    1011
    +
    1012 /* Lower-Left */
    +
    1013 tile->vertices[5][RETROGLU_SPRITE_X] = -1;
    +
    1014 tile->vertices[5][RETROGLU_SPRITE_Y] = -1;
    +
    1015}
    +
    1016
    +
    1017void retroglu_set_sprite_clip(
    +
    1018 struct RETROGLU_SPRITE* sprite,
    +
    1019 uint32_t front_px, uint32_t front_py, uint32_t back_px, uint32_t back_py,
    +
    1020 uint32_t pw, uint32_t ph, uint8_t flags
    +
    1021) {
    +
    1022 /* Set vertices in terms of half the clip size so that rotation is around
    +
    1023 * the midpoint of the sprite, not the side!
    +
    1024 */
    +
    1025 float clip_tex_fx = 0, /* Front tex X */
    +
    1026 clip_tex_fy = 0, /* Front tex Y */
    +
    1027 clip_tex_bx = 0, /* Back tex X */
    +
    1028 clip_tex_by = 0, /* Back tex Y */
    +
    1029 clip_tex_w = 0,
    +
    1030 clip_tex_h = 0;
    +
    1031
    +
    1032 /* Setup texture spritesheet. */
    +
    1033
    +
    1034 clip_tex_fx = retroglu_tex_px_x_to_f( front_px, sprite );
    +
    1035 clip_tex_fy = retroglu_tex_px_y_to_f( front_py, sprite );
    +
    1036 clip_tex_bx = retroglu_tex_px_x_to_f( back_px, sprite );
    +
    1037 clip_tex_by = retroglu_tex_px_y_to_f( back_py, sprite );
    +
    1038 clip_tex_w = retroglu_tex_px_x_to_f( pw, sprite );
    +
    1039 clip_tex_h = retroglu_tex_px_y_to_f( ph, sprite );
    +
    1040
    +
    1041 /* == Front Face Textures == */
    +
    1042
    +
    1043 /* Lower Left */
    +
    1044 sprite->vtexture_front[0][RETROGLU_SPRITE_X] = clip_tex_fx;
    +
    1045 sprite->vtexture_front[0][RETROGLU_SPRITE_Y] = clip_tex_fy;
    +
    1046
    +
    1047 /* Lower Right */
    +
    1048 sprite->vtexture_front[1][RETROGLU_SPRITE_X] = clip_tex_fx + clip_tex_w;
    +
    1049 sprite->vtexture_front[1][RETROGLU_SPRITE_Y] = clip_tex_fy;
    +
    1050
    +
    1051 /* Upper Right */
    +
    1052 sprite->vtexture_front[2][RETROGLU_SPRITE_X] = clip_tex_fx + clip_tex_w;
    +
    1053 sprite->vtexture_front[2][RETROGLU_SPRITE_Y] = clip_tex_fy + clip_tex_h;
    +
    1054
    +
    1055 /* Upper Right */
    +
    1056 sprite->vtexture_front[3][RETROGLU_SPRITE_X] = clip_tex_fx + clip_tex_w;
    +
    1057 sprite->vtexture_front[3][RETROGLU_SPRITE_Y] = clip_tex_fy + clip_tex_h;
    +
    1058
    +
    1059 /* Upper Left */
    +
    1060 sprite->vtexture_front[4][RETROGLU_SPRITE_X] = clip_tex_fx;
    +
    1061 sprite->vtexture_front[4][RETROGLU_SPRITE_Y] = clip_tex_fy + clip_tex_h;
    +
    1062
    +
    1063 /* Lower Left */
    +
    1064 sprite->vtexture_front[5][RETROGLU_SPRITE_X] = clip_tex_fx;
    +
    1065 sprite->vtexture_front[5][RETROGLU_SPRITE_Y] = clip_tex_fy;
    +
    1066
    +
    1067 /* == Back face Textures == */
    +
    1068
    +
    1069 /* Lower Left */
    +
    1070 sprite->vtexture_back[0][RETROGLU_SPRITE_X] = clip_tex_bx;
    +
    1071 sprite->vtexture_back[0][RETROGLU_SPRITE_Y] = clip_tex_by;
    +
    1072
    +
    1073 /* Lower Right */
    +
    1074 sprite->vtexture_back[1][RETROGLU_SPRITE_X] = clip_tex_bx + clip_tex_w;
    +
    1075 sprite->vtexture_back[1][RETROGLU_SPRITE_Y] = clip_tex_by;
    +
    1076
    +
    1077 /* Upper Right */
    +
    1078 sprite->vtexture_back[2][RETROGLU_SPRITE_X] = clip_tex_bx + clip_tex_w;
    +
    1079 sprite->vtexture_back[2][RETROGLU_SPRITE_Y] = clip_tex_by + clip_tex_h;
    +
    1080
    +
    1081 /* Upper Right */
    +
    1082 sprite->vtexture_back[3][RETROGLU_SPRITE_X] = clip_tex_bx + clip_tex_w;
    +
    1083 sprite->vtexture_back[3][RETROGLU_SPRITE_Y] = clip_tex_by + clip_tex_h;
    +
    1084
    +
    1085 /* Upper Left */
    +
    1086 sprite->vtexture_back[4][RETROGLU_SPRITE_X] = clip_tex_bx;
    +
    1087 sprite->vtexture_back[4][RETROGLU_SPRITE_Y] = clip_tex_by + clip_tex_h;
    +
    1088
    +
    1089 /* Lower Left */
    +
    1090 sprite->vtexture_back[5][RETROGLU_SPRITE_X] = clip_tex_bx;
    +
    1091 sprite->vtexture_back[5][RETROGLU_SPRITE_Y] = clip_tex_by;
    +
    1092
    +
    1093 if(
    +
    1094 RETROGLU_FLAGS_INIT_VERTICES != (RETROGLU_FLAGS_INIT_VERTICES & flags)
    +
    1095 ) {
    +
    1096 return;
    +
    1097 }
    +
    1098
    +
    1099 /* == Front Face Vertices == */
    +
    1100
    +
    1101 /* Lower-Left */
    +
    1102 sprite->vertices_front[0][RETROGLU_SPRITE_X] = -1;
    +
    1103 sprite->vertices_front[0][RETROGLU_SPRITE_Y] = -1;
    +
    1104
    +
    1105 /* Lower-Right */
    +
    1106 sprite->vertices_front[1][RETROGLU_SPRITE_X] = 1;
    +
    1107 sprite->vertices_front[1][RETROGLU_SPRITE_Y] = -1;
    +
    1108
    +
    1109 /* Upper-Right */
    +
    1110 sprite->vertices_front[2][RETROGLU_SPRITE_X] = 1;
    +
    1111 sprite->vertices_front[2][RETROGLU_SPRITE_Y] = 1;
    +
    1112
    +
    1113 /* Upper-Right */
    +
    1114 sprite->vertices_front[3][RETROGLU_SPRITE_X] = 1;
    +
    1115 sprite->vertices_front[3][RETROGLU_SPRITE_Y] = 1;
    +
    1116
    +
    1117 /* Upper-Left */
    +
    1118 sprite->vertices_front[4][RETROGLU_SPRITE_X] = -1;
    +
    1119 sprite->vertices_front[4][RETROGLU_SPRITE_Y] = 1;
    +
    1120
    +
    1121 /* Lower-Left */
    +
    1122 sprite->vertices_front[5][RETROGLU_SPRITE_X] = -1;
    +
    1123 sprite->vertices_front[5][RETROGLU_SPRITE_Y] = -1;
    +
    1124
    +
    1125 /* == Back Face Vertices == */
    +
    1126
    +
    1127 /* Lower-Right */
    +
    1128 sprite->vertices_back[0][RETROGLU_SPRITE_X] = 1;
    +
    1129 sprite->vertices_back[0][RETROGLU_SPRITE_Y] = -1;
    +
    1130
    +
    1131 /* Lower-Left */
    +
    1132 sprite->vertices_back[1][RETROGLU_SPRITE_X] = -1;
    +
    1133 sprite->vertices_back[1][RETROGLU_SPRITE_Y] = -1;
    +
    1134
    +
    1135 /* Upper-Left */
    +
    1136 sprite->vertices_back[2][RETROGLU_SPRITE_X] = -1;
    +
    1137 sprite->vertices_back[2][RETROGLU_SPRITE_Y] = 1;
    +
    1138
    +
    1139 /* Upper-Left */
    +
    1140 sprite->vertices_back[3][RETROGLU_SPRITE_X] = -1;
    +
    1141 sprite->vertices_back[3][RETROGLU_SPRITE_Y] = 1;
    +
    1142
    +
    1143 /* Upper-Right */
    +
    1144 sprite->vertices_back[4][RETROGLU_SPRITE_X] = 1;
    +
    1145 sprite->vertices_back[4][RETROGLU_SPRITE_Y] = 1;
    +
    1146
    +
    1147 /* Lower-Right */
    +
    1148 sprite->vertices_back[5][RETROGLU_SPRITE_X] = 1;
    +
    1149 sprite->vertices_back[5][RETROGLU_SPRITE_Y] = -1;
    +
    1150}
    +
    1151
    +
    1152void retroglu_set_sprite_pos(
    +
    1153 struct RETROGLU_SPRITE* sprite, uint32_t px, uint32_t py
    +
    1154) {
    +
    1155 sprite->translate_x = retroglu_scr_px_x_to_f( px );
    +
    1156 sprite->translate_y = retroglu_scr_px_y_to_f( py );
    +
    1157}
    +
    1158
    +
    1159void retroglu_tsrot_sprite( struct RETROGLU_SPRITE* sprite ) {
    +
    1160 /* Set the matrix to translate/rotate/scale based on sprite props. */
    +
    1161 glTranslatef( sprite->translate_x, sprite->translate_y, 0 );
    +
    1162 glScalef( sprite->scale_x, sprite->scale_y, 1.0f );
    +
    1163 glRotatef( sprite->rotate_y, 0.0f, 1.0f, 0.0f );
    +
    1164}
    +
    1165
    +
    1166void retroglu_draw_sprite( struct RETROGLU_SPRITE* sprite ) {
    +
    1167 int i = 0;
    +
    1168#ifdef RETROGLU_NO_TEXTURES
    +
    1169 MERROR_RETVAL retval = MERROR_OK;
    +
    1170#endif /* RETROGLU_NO_TEXTURES */
    +
    1171
    +
    1172 glColor3fv( sprite->color );
    +
    1173
    +
    1174#ifndef RETROGLU_NO_TEXTURES
    +
    1175 glBindTexture( GL_TEXTURE_2D, sprite->texture.tex.id );
    +
    1176#else
    +
    1177 maug_mlock( sprite->texture.tex.bytes_h, sprite->texture.tex.bytes );
    +
    1178 maug_cleanup_if_null_alloc( uint8_t*, sprite->texture.tex.bytes );
    +
    1179 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
    +
    1180 sprite->texture.tex.w, sprite->texture.tex.h, 0,
    +
    1181 GL_RGBA, GL_UNSIGNED_BYTE,
    +
    1182 sprite->texture.tex.bytes );
    +
    1183#endif /* !RETROGLU_NO_TEXTURES */
    +
    1184#ifndef MAUG_OS_NDS
    +
    1185 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    +
    1186 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    +
    1187 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    +
    1188#endif /* !MAUG_OS_NDS */
    +
    1189
    +
    1190 glBegin( GL_TRIANGLES );
    +
    1191
    +
    1192 for( i = 0 ; 6 > i ; i++ ) {
    +
    1193 glTexCoord2fv( sprite->vtexture_front[i] );
    +
    1194 glVertex2fv( sprite->vertices_front[i] );
    +
    1195 }
    +
    1196
    +
    1197 for( i = 0 ; 6 > i ; i++ ) {
    +
    1198 glTexCoord2fv( sprite->vtexture_back[i] );
    +
    1199 glVertex2fv( sprite->vertices_back[i] );
    +
    1200 }
    +
    1201
    +
    1202 glEnd();
    +
    1203
    +
    1204#ifndef RETROGLU_NO_TEXTURES
    +
    1205 glBindTexture( GL_TEXTURE_2D, 0 );
    +
    1206#else
    +
    1207cleanup:
    +
    1208 if( NULL != sprite->texture.tex.bytes ) {
    +
    1209 maug_munlock( sprite->texture.tex.bytes_h, sprite->texture.tex.bytes );
    +
    1210 }
    +
    1211#endif /* !RETROGLU_NO_TEXTURES */
    +
    1212}
    +
    1213
    +
    1214void retroglu_free_sprite( struct RETROGLU_SPRITE* sprite ) {
    +
    1215 if( NULL != sprite->texture.tex.bytes_h ) {
    +
    1216 if( NULL != sprite->texture.tex.bytes ) {
    +
    1217 maug_munlock( sprite->texture.tex.bytes_h, sprite->texture.tex.bytes );
    +
    1218 }
    +
    1219
    +
    1220 maug_mfree( sprite->texture.tex.bytes_h );
    +
    1221 }
    +
    1222}
    +
    1223
    +
    1224/* === */
    +
    1225
    +
    1226# include "mfont8x8.h"
    +
    1227
    +
    1228static
    +
    1229uint32_t g_retroglu_font_tex[RETROSOFT_SETS_COUNT][RETROSOFT_GLYPHS_COUNT];
    +
    1230
    +
    1231MERROR_RETVAL retroglu_load_glyph( size_t set_idx, size_t glyph_idx ) {
    +
    1232 MERROR_RETVAL retval = MERROR_OK;
    +
    1233
    +
    1234 uint8_t* bmp_px = NULL;
    +
    1235 int16_t i = 0,
    +
    1236 x = 0,
    +
    1237 y = 0;
    +
    1238 const char* glyph_dots = gc_font8x8[set_idx][glyph_idx];
    +
    1239
    +
    1240 /* Allocate temporary buffer for drawing. */
    +
    1241 bmp_px = calloc( RETROSOFT_GLYPH_W_SZ * RETROSOFT_GLYPH_H_SZ, 4 );
    +
    1242 maug_cleanup_if_null_alloc( uint8_t*, bmp_px );
    +
    1243 assert( NULL != bmp_px );
    +
    1244
    +
    1245 /* Draw font to texture. */
    +
    1246 for( y = 0 ; RETROSOFT_GLYPH_H_SZ > y ; y++ ) {
    +
    1247 for( x = 0 ; RETROSOFT_GLYPH_W_SZ > x ; x++ ) {
    +
    1248 i = ((RETROSOFT_GLYPH_H_SZ - y - 1) * RETROSOFT_GLYPH_W_SZ) + x;
    +
    1249 assert( i < RETROSOFT_GLYPH_W_SZ * RETROSOFT_GLYPH_H_SZ * 4 );
    +
    1250
    +
    1251 if( 1 == ((glyph_dots[y] >> x) & 0x01) ) {
    +
    1252 bmp_px[i * 4] = 0xff;
    +
    1253 bmp_px[(i * 4) + 1] = 0xff;
    +
    1254 bmp_px[(i * 4) + 2] = 0xff;
    +
    1255 bmp_px[(i * 4) + 3] = 0xff;
    +
    1256 }
    +
    1257 }
    +
    1258 }
    +
    1259
    +
    1260#ifndef RETROGLU_NO_TEXTURES
    +
    1261 assert( 0 == g_retroglu_font_tex[set_idx][glyph_idx] );
    +
    1262 glGenTextures( 1, (GLuint*)&(g_retroglu_font_tex[set_idx][glyph_idx]) );
    +
    1263 assert( 0 < g_retroglu_font_tex[set_idx][glyph_idx] );
    +
    1264 glBindTexture( GL_TEXTURE_2D, g_retroglu_font_tex[set_idx][glyph_idx] );
    +
    1265#endif /* !RETROGLU_NO_TEXTURES */
    +
    1266 /* glPixelStorei( GL_UNPACK_ALIGNMENT, 4 ); */
    +
    1267 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
    +
    1268 RETROSOFT_GLYPH_W_SZ, RETROSOFT_GLYPH_H_SZ, 0,
    +
    1269 GL_RGBA, GL_UNSIGNED_BYTE, bmp_px );
    +
    1270
    +
    1271cleanup:
    +
    1272
    +
    1273 if( NULL != bmp_px ) {
    +
    1274 free( bmp_px );
    +
    1275 }
    +
    1276
    +
    1277 return retval;
    +
    1278}
    +
    1279
    +
    1280/* === */
    +
    1281
    +
    1282MERROR_RETVAL retroglu_init_glyph_tex() {
    +
    1283 MERROR_RETVAL retval = MERROR_OK;
    +
    1284
    +
    1285#ifndef RETROGLU_NO_TEXTURES
    +
    1286 size_t i = 0,
    +
    1287 j = 0;
    +
    1288
    +
    1289 /* Only precache textures we we support glBindTexture(). Otherwise, we'll
    +
    1290 * have to forcibly load them as we use them later on. */
    +
    1291
    +
    1292 debug_printf( RETROGLU_TRACE_LVL, "loading glyph textures..." );
    +
    1293
    +
    1294 for( i = 0 ; RETROSOFT_SETS_COUNT > i ; i++ ) {
    +
    1295 for( j = 0 ; RETROSOFT_GLYPHS_COUNT > j ; j++ ) {
    +
    1296 retval = retroglu_load_glyph( i, j );
    +
    1297 maug_cleanup_if_not_ok();
    +
    1298 }
    +
    1299 }
    +
    1300#endif /* !RETROGLU_NO_TEXTURES */
    +
    1301
    +
    1302cleanup:
    +
    1303
    +
    1304 /* TODO: Destroy loaded textures if failure. */
    +
    1305
    +
    1306 return retval;
    +
    1307}
    +
    1308
    +
    1309/* === */
    +
    1310
    +
    1311#define RETROGLU_FONT_W 0.05f
    +
    1312
    +
    1313void retroglu_string(
    +
    1314 float x, float y, float z, const RETROGLU_COLOR color,
    +
    1315 const char* str, int str_sz, const char* font_str, uint8_t flags
    +
    1316) {
    +
    1317 size_t i = 0;
    +
    1318#ifdef RETROGLU_NO_TEXTURES
    +
    1319 MERROR_RETVAL retval = MERROR_OK;
    +
    1320#endif /* RETROGLU_NO_TEXTURES */
    +
    1321
    +
    1322 if( str_sz <= 0 ) {
    +
    1323 str_sz = strlen( str );
    +
    1324 }
    +
    1325
    +
    1326 for( i = 0 ; str_sz > i ; i++ ) {
    +
    1327 /* Stop drawing on NULL. */
    +
    1328 if( '\0' == str[i] ) {
    +
    1329 break;
    +
    1330 }
    +
    1331
    +
    1332 glColor3fv( color );
    +
    1333
    +
    1334#ifdef RETROGLU_NO_TEXTURES
    +
    1335 retval = retroglu_load_glyph( 0, str[i] - ' ' );
    +
    1336 maug_cleanup_if_not_ok();
    +
    1337#else
    +
    1338 glBindTexture( GL_TEXTURE_2D, g_retroglu_font_tex[0][str[i] - ' '] );
    +
    1339#endif /* RETROGLU_NO_TEXTURES */
    +
    1340 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    +
    1341 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    +
    1342 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    +
    1343
    +
    1344 glBegin( GL_TRIANGLES );
    +
    1345
    +
    1346 glTexCoord2f( 0, 0 );
    +
    1347 glVertex3f( x + (RETROGLU_FONT_W * i), y, z );
    +
    1348 glTexCoord2f( 1, 0 );
    +
    1349 glVertex3f( x + (RETROGLU_FONT_W * i) + RETROGLU_FONT_W, y, z );
    +
    1350 glTexCoord2f( 1, 1 );
    +
    1351 glVertex3f(
    +
    1352 x + (RETROGLU_FONT_W * i) + RETROGLU_FONT_W,
    +
    1353 y + RETROGLU_FONT_W, z );
    +
    1354
    +
    1355 glTexCoord2f( 1, 1 );
    +
    1356 glVertex3f(
    +
    1357 x + (RETROGLU_FONT_W * i) + RETROGLU_FONT_W,
    +
    1358 y + RETROGLU_FONT_W, z );
    +
    1359 glTexCoord2f( 0, 1 );
    +
    1360 glVertex3f( x + (RETROGLU_FONT_W * i), y + RETROGLU_FONT_W, z );
    +
    1361 glTexCoord2f( 0, 0 );
    +
    1362 glVertex3f( x + (RETROGLU_FONT_W * i), y, z );
    +
    1363
    +
    1364 glEnd();
    +
    1365
    +
    1366#ifdef RETROGLU_NO_TEXTURES
    +
    1367 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,
    +
    1368 0, 0, 0,
    +
    1369 GL_RGBA, GL_UNSIGNED_BYTE, NULL );
    +
    1370#else
    +
    1371 glBindTexture( GL_TEXTURE_2D, 0 );
    +
    1372#endif /* !RETROGLU_NO_TEXTURES */
    +
    1373 }
    +
    1374
    +
    1375#ifdef RETROGLU_NO_TEXTURES
    +
    1376cleanup:
    +
    1377 return;
    +
    1378#endif /* RETROGLU_NO_TEXTURES */
    +
    1379}
    +
    1380
    +
    1381#else
    +
    1382
    +
    1383# define RETROFLAT_COLOR_TABLE_GL( idx, name_l, name_u, r, g, b ) \
    +
    1384 extern MAUG_CONST float RETROGLU_COLOR_ ## name_u[];
    +
    1385
    +
    1386RETROFLAT_COLOR_TABLE( RETROFLAT_COLOR_TABLE_GL )
    +
    1387
    +
    1388#endif /* RETROGLU_C */
    +
    1389 /* maug_retroglu */
    +
    1391
    +
    1392#endif /* !RETROGLU_H */
    +
    1393
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    #define RETROFLAT_PATH_MAX
    Maximum size allocated for asset paths.
    Definition retroflt.h:624
    +
    #define RETROFLAT_PATH_SEP
    The valid path separator on the target platform.
    Definition retroflt.h:666
    +
    #define RETROFLAT_OK
    Certain functions return this when there was no problem.
    Definition retroflt.h:304
    +
    #define retroflat_screen_h()
    Get the current screen height in pixels.
    Definition retroflt.h:1627
    +
    #define retroflat_screen_w()
    Get the current screen width in pixels.
    Definition retroflt.h:1624
    +
    void retroglu_parse_init(struct RETROGLU_PARSER *parser, struct RETROGLU_OBJ *obj, retroglu_mtl_cb load_mtl, void *load_mtl_data)
    Initialize a RETROGLU_PARSER.
    +
    #define retroglu_parser_state(parser, new_state)
    Change the parser state.
    Definition retroglu.h:243
    +
    MERROR_RETVAL retroglu_parse_obj_c(struct RETROGLU_PARSER *parser, unsigned char c)
    Parse OBJ data into a parser, one character at a time.
    +
    int(* retroglu_mtl_cb)(const char *filename, struct RETROGLU_PARSER *parser, void *data)
    Callback to execute when its associate in RETROGLU_OBJ_TOKENS is found in an OBJ file.
    Definition retroglu.h:270
    +
    #define RETROGLU_OBJ_TOKENS(f)
    Table of OBJ file tokens understood by the parser.
    Definition retroglu.h:251
    +
    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
    Definition retroflt.h:1610
    +
    Definition retroglu.h:135
    +
    uint16_t vertex_idxs[RETROGLU_FACE_VERTICES_SZ_MAX]
    List of vertex indices from the associated RETROGLU_PARSER::vertices.
    Definition retroglu.h:142
    +
    Definition retroglu.h:126
    +
    Definition retroglu.h:153
    +
    struct RETROGLU_FACE faces[RETROGLU_FACES_SZ_MAX]
    List of faces from an OBJ file. Faces comprise a list of polygons denoted by index of the vertices in...
    Definition retroglu.h:165
    +
    As retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information.
    Definition retroglu.h:277
    +
    Definition retroglu.h:206
    +
    Definition retroglu.h:179
    +
    Definition retroglu.h:193
    +
    Definition retroglu.h:115
    +
    Definition retroglu.h:121
    +
    + + + + diff --git a/retrogui_8h.html b/retrogui_8h.html new file mode 100644 index 00000000..f859f548 --- /dev/null +++ b/retrogui_8h.html @@ -0,0 +1,191 @@ + + + + + + + +maug: retrogui.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    retrogui.h File Reference
    +
    +
    + +

    Go to the source code of this file.

    + + + + + + + + + +

    +Data Structures

    struct  RETROGUI_CTL_BASE
     Fields common to ALL RETROGUI_CTL types. More...
     
    union  RETROGUI_CTL
     
    struct  RETROGUI
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    +#define RETROGUI_FLAGS_DIRTY   0x01
     RETROGUI::flags indicating controls should be redrawn.
     
    +#define RETROGUI_CTL_TEXT_SZ_MAX   128
     
    +#define RETROGUI_CTL_SZ_MAX_INIT   10
     
    +#define RETROGUI_PADDING   5
     
    +#define RETROGUI_BTN_LBL_SZ_MAX   64
     
    #define retrogui_lock(gui)
     
    #define retrogui_unlock(gui)
     
    +#define RETROGUI_IDC_NONE   0
     
    #define RETROGUI_CTL_TABLE(f)
     Table defining all control types and their specific fields in RETROGUI_CTL.
     
    #define RETROGUI_CTL_TABLE_FIELDS(idx, c_name, c_fields)
     Creates the corresponding RETROGUI_* structs from RETROGUI_CTL_TABLE that populate union RETROGUI_CTL.
     
    +#define RETROGUI_CTL_TABLE_TYPES(idx, c_name, c_fields)    struct RETROGUI_CTL_ ## c_name c_name;
     Adds the structs created by RETROGUI_CTL_TABLE_FIELDS to union RETROGUI_CTL.
     
    +#define RETROGUI_CTL_TABLE_CONSTS(idx, c_name, c_fields)    extern MAUG_CONST uint8_t RETROGUI_CTL_TYPE_ ## c_name;
     
    + + + + + + +

    +Typedefs

    +typedef size_t RETROGUI_IDC
     Unique identifying constant number for controls.
     
    +typedef void(* retrogui_xy_cb) (size_t *x, size_t *y, void *data)
     
    + + + + + + + + + + + + + + + + + + + + +

    +Functions

    +MERROR_RETVAL retrogui_push_listbox_item (struct RETROGUI *gui, RETROGUI_IDC idc, const char *item, size_t item_sz)
     
    +union RETROGUI_CTLretrogui_get_ctl_by_idc (struct RETROGUI *gui, size_t idc)
     
    RETROGUI_IDC retrogui_poll_ctls (struct RETROGUI *gui, int *p_input, struct RETROFLAT_INPUT *input_evt)
     Poll for the last clicked control and maintain listboxes and menus.
     
    +void retrogui_redraw_ctls (struct RETROGUI *gui)
     
    +MERROR_RETVAL retrogui_push_ctl (struct RETROGUI *gui, union RETROGUI_CTL *ctl)
     
    +MERROR_RETVAL retrogui_get_ctl_text (struct RETROGUI *gui, RETROGUI_IDC idc, char *buffer, size_t buffer_sz)
     
    +size_t retrogui_get_ctl_sel_idx (struct RETROGUI *gui, size_t idc)
     
    +MERROR_RETVAL retrogui_init_ctl (union RETROGUI_CTL *ctl, uint8_t type, size_t idc)
     
    +MERROR_RETVAL retrogui_init (struct RETROGUI *gui)
     
    + + + +

    +Variables

    +MAUG_CONST char * gc_retrogui_ctl_names []
     
    +
    + + + + diff --git a/retrogui_8h_source.html b/retrogui_8h_source.html new file mode 100644 index 00000000..61f14602 --- /dev/null +++ b/retrogui_8h_source.html @@ -0,0 +1,1153 @@ + + + + + + + +maug: retrogui.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retrogui.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef RETROGUI_H
    +
    3#define RETROGUI_H
    +
    4
    +
    11/* TODO: Implement dirty flag! */
    +
    12
    +
    14#define RETROGUI_FLAGS_DIRTY 0x01
    +
    15
    +
    16#ifndef RETROGUI_CTL_TEXT_SZ_MAX
    +
    17# define RETROGUI_CTL_TEXT_SZ_MAX 128
    +
    18#endif /* !RETROGUI_CTL_TEXT_SZ_MAX */
    +
    19
    +
    20#ifndef RETROGUI_CTL_SZ_MAX_INIT
    +
    21# define RETROGUI_CTL_SZ_MAX_INIT 10
    +
    22#endif /* !RETROGUI_CTL_SZ_MAX_INIT */
    +
    23
    +
    24#ifndef RETROGUI_PADDING
    +
    25# define RETROGUI_PADDING 5
    +
    26#endif /* !RETROGUI_PADDING */
    +
    27
    +
    28#ifndef RETROGUI_BTN_LBL_SZ_MAX
    +
    29# define RETROGUI_BTN_LBL_SZ_MAX 64
    +
    30#endif /* !RETROGUI_BTN_LBL_SZ_MAX */
    +
    31
    +
    32#define retrogui_lock( gui ) \
    +
    33 if( NULL == (gui)->ctls ) { \
    +
    34 maug_mlock( (gui)->ctls_h, (gui)->ctls ); \
    +
    35 maug_cleanup_if_null_alloc( union RETROGUI_CTL*, (gui)->ctls ); \
    +
    36 }
    +
    37
    +
    38#define retrogui_unlock( gui ) \
    +
    39 if( NULL != (gui)->ctls ) { \
    +
    40 maug_munlock( (gui)->ctls_h, (gui)->ctls ); \
    +
    41 }
    +
    42
    +
    44typedef size_t RETROGUI_IDC;
    +
    45
    +
    46#define RETROGUI_IDC_NONE 0
    +
    47
    +
    62#define RETROGUI_CTL_TABLE( f ) \
    +
    63 f( 0, NONE, void* none; ) \
    +
    64 f( 1, LISTBOX, MAUG_MHANDLE list_h; char* list; size_t list_sz; size_t list_sz_max; size_t sel_idx; ) \
    +
    65 f( 2, BUTTON, char label[RETROGUI_BTN_LBL_SZ_MAX]; ) \
    +
    66 f( 3, TEXTBOX, MAUG_MHANDLE text_h; char* text; size_t text_sz; size_t text_sz_max; size_t text_cur; )
    +
    67
    +
    68#if 0
    +
    69 f( 4, SCROLLBAR, size_t min; size_t max; size_t value; )
    +
    70#endif
    +
    71
    + +
    74 uint8_t type;
    +
    75 RETROGUI_IDC idc;
    +
    76 size_t x;
    +
    77 size_t y;
    +
    78 size_t w;
    +
    79 size_t h;
    +
    80 RETROFLAT_COLOR bg_color;
    +
    81 RETROFLAT_COLOR fg_color;
    +
    82#if defined( RETROGUI_NATIVE_WIN )
    +
    83 HWND hwnd;
    +
    84#endif
    +
    85};
    +
    86
    +
    91#define RETROGUI_CTL_TABLE_FIELDS( idx, c_name, c_fields ) \
    +
    92 struct RETROGUI_CTL_ ## c_name { \
    +
    93 struct RETROGUI_CTL_BASE base; \
    +
    94 c_fields \
    +
    95 };
    +
    96
    + +
    98
    +
    99
    +
    103#define RETROGUI_CTL_TABLE_TYPES( idx, c_name, c_fields ) \
    +
    104 struct RETROGUI_CTL_ ## c_name c_name;
    +
    105
    + +
    107 struct RETROGUI_CTL_BASE base;
    + +
    109};
    +
    110 /* maug_retrogui_ctl */
    +
    112
    +
    113typedef void (*retrogui_xy_cb)( size_t* x, size_t* y, void* data );
    +
    114
    +
    115struct RETROGUI {
    +
    116 uint8_t flags;
    +
    117 RETROGUI_IDC idc_prev;
    +
    118 MAUG_MHANDLE ctls_h;
    +
    119 union RETROGUI_CTL* ctls;
    +
    120 size_t ctls_sz;
    +
    121 size_t ctls_sz_max;
    +
    122 RETROGUI_IDC focus;
    +
    123 struct RETROFLAT_BITMAP* draw_bmp;
    +
    124 retrogui_xy_cb draw_xy;
    +
    125 void* draw_xy_data;
    +
    126};
    +
    127
    +
    128MERROR_RETVAL retrogui_push_listbox_item(
    +
    129 struct RETROGUI* gui, RETROGUI_IDC idc, const char* item, size_t item_sz );
    +
    130
    +
    131union RETROGUI_CTL* retrogui_get_ctl_by_idc( struct RETROGUI* gui, size_t idc );
    +
    132
    + +
    142 struct RETROGUI* gui, int* p_input, struct RETROFLAT_INPUT* input_evt );
    +
    143
    +
    144void retrogui_redraw_ctls( struct RETROGUI* gui );
    +
    145
    +
    146MERROR_RETVAL retrogui_push_ctl(
    +
    147 struct RETROGUI* gui, union RETROGUI_CTL* ctl );
    +
    148
    +
    149MERROR_RETVAL retrogui_get_ctl_text(
    +
    150 struct RETROGUI* gui, RETROGUI_IDC idc, char* buffer, size_t buffer_sz );
    +
    151
    +
    152size_t retrogui_get_ctl_sel_idx( struct RETROGUI* gui, size_t idc );
    +
    153
    +
    154MERROR_RETVAL retrogui_init_ctl(
    +
    155 union RETROGUI_CTL* ctl, uint8_t type, size_t idc );
    +
    156
    +
    157MERROR_RETVAL retrogui_init( struct RETROGUI* gui );
    +
    158
    +
    159#ifdef RETROGUI_C
    +
    160
    +
    161#define RETROGUI_CTL_TABLE_CONSTS( idx, c_name, c_fields ) \
    +
    162 MAUG_CONST uint8_t RETROGUI_CTL_TYPE_ ## c_name = idx;
    +
    163
    +
    164RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_CONSTS )
    +
    165
    +
    166#define RETROGUI_CTL_TABLE_NAMES( idx, c_name, f_fields ) \
    +
    167 #c_name,
    +
    168
    +
    169MAUG_CONST char* gc_retrogui_ctl_names[] = {
    +
    170 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_NAMES )
    +
    171 ""
    +
    172};
    +
    173
    +
    174/* === Control: NONE === */
    +
    175
    +
    176static RETROGUI_IDC retrogui_click_NONE(
    +
    177 struct RETROGUI* gui,
    +
    178 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    179) {
    +
    180 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    181
    +
    182 return idc_out;
    +
    183}
    +
    184
    +
    185static RETROGUI_IDC retrogui_key_NONE(
    +
    186 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    187) {
    +
    188 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    189
    +
    190 return idc_out;
    +
    191}
    +
    192
    +
    193void retrogui_redraw_NONE( struct RETROGUI* gui, union RETROGUI_CTL* ctl ) {
    +
    194}
    +
    195
    +
    196static MERROR_RETVAL retrogui_push_NONE( union RETROGUI_CTL* ctl ) {
    +
    197 MERROR_RETVAL retval = MERROR_GUI;
    +
    198
    +
    199 return retval;
    +
    200}
    +
    201
    +
    202static void retrogui_free_NONE( union RETROGUI_CTL* ctl ) {
    +
    203}
    +
    204
    +
    205static MERROR_RETVAL retrogui_init_NONE( union RETROGUI_CTL* ctl ) {
    +
    206 MERROR_RETVAL retval = MERROR_GUI;
    +
    207
    +
    208 return retval;
    +
    209}
    +
    210
    +
    211/* === Control: LISTBOX === */
    +
    212
    +
    213static RETROGUI_IDC retrogui_click_LISTBOX(
    +
    214 struct RETROGUI* gui,
    +
    215 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    216) {
    +
    217 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    218 size_t i = 0,
    +
    219 j = 0,
    +
    220 w = 0,
    +
    221 h = 0;
    +
    222
    +
    223# if defined( RETROGUI_NATIVE_WIN )
    +
    224 /* Do nothing. */
    +
    225# else
    +
    226
    +
    227 assert( NULL == ctl->LISTBOX.list );
    +
    228 maug_mlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    229
    +
    230 /* Figure out the item clicked. */
    +
    231 while( i < ctl->LISTBOX.list_sz ) {
    + +
    233 gui->draw_bmp, &(ctl->LISTBOX.list[i]), 0, NULL, &w, &h, 0 );
    +
    234
    +
    235 if(
    +
    236 input_evt->mouse_y <
    +
    237 ctl->base.y + ((j + 1) * (h + RETROGUI_PADDING))
    +
    238 ) {
    +
    239 ctl->LISTBOX.sel_idx = j;
    +
    240 break;
    +
    241 }
    +
    242
    +
    243 /* Try next variable-length string. */
    +
    244 i += strlen( &(ctl->LISTBOX.list[i]) ) + 1;
    +
    245 assert( i <= ctl->LISTBOX.list_sz );
    +
    246 j++;
    +
    247 }
    +
    248
    +
    249 if( NULL != ctl->LISTBOX.list ) {
    +
    250 maug_munlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    251 }
    +
    252
    +
    253#endif
    +
    254
    +
    255 return idc_out;
    +
    256}
    +
    257
    +
    258static RETROGUI_IDC retrogui_key_LISTBOX(
    +
    259 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    260) {
    +
    261 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    262
    +
    263 /* TODO: Move up or down to next/prev item. */
    +
    264
    +
    265 return idc_out;
    +
    266}
    +
    267
    +
    268static void retrogui_redraw_LISTBOX(
    +
    269 struct RETROGUI* gui, union RETROGUI_CTL* ctl
    +
    270) {
    +
    271 size_t i = 0,
    +
    272 j = 0,
    +
    273 w = 0,
    +
    274 h = 0;
    +
    275
    +
    276 assert( NULL == ctl->LISTBOX.list );
    +
    277
    +
    278# if defined( RETROGUI_NATIVE_WIN )
    +
    279 /* TODO: InvalidateRect()? */
    +
    280# else
    +
    281
    +
    282 maug_mlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    283 if( NULL == ctl->LISTBOX.list ) {
    +
    284 goto cleanup;
    +
    285 }
    +
    286
    +
    287 retroflat_rect( NULL, ctl->base.bg_color, ctl->base.x, ctl->base.y,
    +
    288 ctl->base.w, ctl->base.h, RETROFLAT_FLAGS_FILL );
    +
    289
    +
    290 /* Parse out variable-length strings. */
    +
    291 while( i < ctl->LISTBOX.list_sz ) {
    + +
    293 gui->draw_bmp, &(ctl->LISTBOX.list[i]), 0, NULL, &w, &h, 0 );
    +
    294 if( j == ctl->LISTBOX.sel_idx ) {
    +
    295 /* TODO: Configurable selection colors. */
    +
    296 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_BLUE,
    +
    297 ctl->base.x, ctl->base.y + (j * (h + RETROGUI_PADDING)),
    +
    298 ctl->base.w, h, RETROFLAT_FLAGS_FILL );
    +
    299
    +
    300 }
    + +
    302 gui->draw_bmp, ctl->base.fg_color, &(ctl->LISTBOX.list[i]), 0, NULL,
    +
    303 ctl->base.x, ctl->base.y + (j * (h + RETROGUI_PADDING)), 0 );
    +
    304
    +
    305 /* Move to next variable-length string. */
    +
    306 i += strlen( &(ctl->LISTBOX.list[i]) ) + 1;
    +
    307 assert( i <= ctl->LISTBOX.list_sz );
    +
    308 j++;
    +
    309 }
    +
    310
    +
    311cleanup:
    +
    312
    +
    313 if( NULL != ctl->LISTBOX.list ) {
    +
    314 maug_munlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    315 }
    +
    316
    +
    317# endif
    +
    318
    +
    319}
    +
    320
    +
    321MERROR_RETVAL retrogui_select_listbox_item(
    +
    322 union RETROGUI_CTL* ctl, size_t item_idx
    +
    323) {
    +
    324 MERROR_RETVAL retval = MERROR_OK;
    +
    325
    +
    326# if defined( RETROGUI_NATIVE_WIN )
    +
    327
    +
    328 /* Select sel_idx. */
    +
    329 SendMessage( ctl->base.hwnd, LB_SETCURSEL, item_idx, 0 );
    +
    330
    +
    331# else
    +
    332
    +
    333 ctl->LISTBOX.sel_idx = item_idx;
    +
    334
    +
    335# endif
    +
    336
    +
    337 return retval;
    +
    338}
    +
    339
    +
    340MERROR_RETVAL retrogui_push_listbox_item(
    +
    341 struct RETROGUI* gui, RETROGUI_IDC idc, const char* item, size_t item_sz
    +
    342) {
    +
    343 MERROR_RETVAL retval = MERROR_OK;
    +
    344 union RETROGUI_CTL* ctl = NULL;
    +
    345 MAUG_MHANDLE listbox_h_new = (MAUG_MHANDLE)NULL;
    +
    346
    +
    347 retrogui_lock( gui );
    +
    348
    +
    349 debug_printf( 1, "pushing item \"%s\" to listbox " SIZE_T_FMT "...",
    +
    350 item, idc );
    +
    351
    +
    352 ctl = retrogui_get_ctl_by_idc( gui, idc );
    +
    353 if( NULL == ctl ) {
    +
    354 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    355 "Adding item \"%s\" failed: Control missing!", item );
    +
    356 retval = MERROR_GUI;
    +
    357 goto cleanup;
    +
    358 }
    +
    359
    +
    360# if defined( RETROGUI_NATIVE_WIN )
    +
    361
    +
    362 SendMessage( ctl->LISTBOX.base.hwnd, LB_ADDSTRING, 0, (LPARAM)item );
    +
    363
    +
    364# else
    +
    365
    +
    366 if( 0 == ctl->LISTBOX.list_sz ) {
    +
    367 ctl->LISTBOX.list_h = maug_malloc( 255, sizeof( char ) );
    +
    368 maug_cleanup_if_null_alloc( MAUG_MHANDLE, ctl->LISTBOX.list_h );
    +
    369 ctl->LISTBOX.list_sz_max = 255;
    +
    370 }
    +
    371
    +
    372 if( NULL != ctl->LISTBOX.list ) {
    +
    373 maug_munlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    374 }
    +
    375
    +
    376 while( ctl->LISTBOX.list_sz + item_sz + 1 >= ctl->LISTBOX.list_sz_max ) {
    +
    377 debug_printf( 1, "resizing listbox items to " SIZE_T_FMT "...",
    +
    378 ctl->LISTBOX.list_sz );
    +
    379 maug_mrealloc_test(
    +
    380 listbox_h_new, ctl->LISTBOX.list_h,
    +
    381 ctl->LISTBOX.list_sz_max * 2, sizeof( char ) );
    +
    382 ctl->LISTBOX.list_sz_max *= 2;
    +
    383 }
    +
    384
    +
    385 maug_mlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    386 maug_cleanup_if_null_alloc( char*, ctl->LISTBOX.list );
    +
    387
    +
    388 strncpy( &(ctl->LISTBOX.list[ctl->LISTBOX.list_sz]), item, item_sz );
    +
    389 ctl->LISTBOX.list[ctl->LISTBOX.list_sz + item_sz] = '\0';
    +
    390 ctl->LISTBOX.list_sz += item_sz + 1;
    +
    391
    +
    392#endif
    +
    393
    +
    394cleanup:
    +
    395
    +
    396 if( NULL != ctl->LISTBOX.list ) {
    +
    397 maug_munlock( ctl->LISTBOX.list_h, ctl->LISTBOX.list );
    +
    398 }
    +
    399
    +
    400 return retval;
    +
    401}
    +
    402
    +
    403static MERROR_RETVAL retrogui_push_LISTBOX( union RETROGUI_CTL* ctl ) {
    +
    404 MERROR_RETVAL retval = MERROR_OK;
    +
    405
    +
    406# if defined( RETROGUI_NATIVE_WIN )
    +
    407
    +
    408 ctl->base.hwnd = CreateWindow(
    +
    409 "LISTBOX", NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD,
    +
    410 ctl->base.x, ctl->base.y, ctl->base.w, ctl->base.h,
    +
    411 g_retroflat_state->window, (HMENU)(ctl->base.idc),
    +
    412 g_retroflat_instance, NULL );
    +
    413 debug_printf( 1, "listbox hwnd: %p", ctl->LISTBOX.base.hwnd );
    +
    414 if( (HWND)NULL == ctl->base.hwnd ) {
    +
    415 error_printf( "could not create listbox" );
    +
    416 retval = MERROR_GUI;
    +
    417 goto cleanup;
    +
    418 }
    +
    419
    +
    420cleanup:
    +
    421
    +
    422# else
    +
    423
    +
    424 /* TODO? */
    +
    425
    +
    426# endif
    +
    427
    +
    428 return retval;
    +
    429}
    +
    430
    +
    431static void retrogui_free_LISTBOX( union RETROGUI_CTL* ctl ) {
    +
    432 assert( NULL == ctl->LISTBOX.list );
    +
    433 maug_mfree( ctl->LISTBOX.list_h );
    +
    434}
    +
    435
    +
    436static MERROR_RETVAL retrogui_init_LISTBOX( union RETROGUI_CTL* ctl ) {
    +
    437 MERROR_RETVAL retval = MERROR_OK;
    +
    438
    +
    439 debug_printf( 1, "initializing listbox " SIZE_T_FMT "...", ctl->base.idc );
    +
    440
    +
    441 ctl->base.fg_color = RETROFLAT_COLOR_BLACK;
    +
    442 ctl->base.bg_color = RETROFLAT_COLOR_WHITE;
    +
    443
    +
    444 return retval;
    +
    445}
    +
    446
    +
    447/* === Control: BUTTON === */
    +
    448
    +
    449static RETROGUI_IDC retrogui_click_BUTTON(
    +
    450 struct RETROGUI* gui,
    +
    451 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    452) {
    +
    453 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    454
    +
    455 /* Set the last button clicked. */
    +
    456 idc_out = ctl->base.idc;
    +
    457
    +
    458 return idc_out;
    +
    459}
    +
    460
    +
    461static RETROGUI_IDC retrogui_key_BUTTON(
    +
    462 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    463) {
    +
    464 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    465
    +
    466 /* Set the last button clicked. */
    +
    467 /* TODO: Only set out on ENTER/SPACE. */
    +
    468 /* idc_out = ctl->base.idc; */
    +
    469
    +
    470 return idc_out;
    +
    471}
    +
    472
    +
    473static void retrogui_redraw_BUTTON(
    +
    474 struct RETROGUI* gui, union RETROGUI_CTL* ctl
    +
    475) {
    +
    476 size_t w = 0,
    +
    477 h = 0;
    +
    478
    +
    479 retroflat_rect( gui->draw_bmp, ctl->base.bg_color, ctl->base.x, ctl->base.y,
    +
    480 ctl->base.w, ctl->base.h, RETROFLAT_FLAGS_FILL );
    +
    481
    +
    482 /* TODO: Draw outlines for outset/inset depending on idc_prev. */
    +
    483
    +
    484 retroflat_string_sz( gui->draw_bmp, ctl->BUTTON.label, 0, NULL, &w, &h, 0 );
    +
    485
    + +
    487 gui->draw_bmp, ctl->base.fg_color, ctl->BUTTON.label, 0, NULL,
    +
    488 ctl->base.x + ((ctl->base.w / 2) - (w / 2)),
    +
    489 ctl->base.y + ((ctl->base.h / 2) - (h / 2)), 0 );
    +
    490}
    +
    491
    +
    492static MERROR_RETVAL retrogui_push_BUTTON( union RETROGUI_CTL* ctl ) {
    +
    493 MERROR_RETVAL retval = MERROR_OK;
    +
    494
    +
    495# if defined( RETROGUI_NATIVE_WIN )
    +
    496
    +
    497 ctl->base.hwnd = CreateWindow(
    +
    498 "BUTTON", ctl->BUTTON.label, WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
    +
    499 ctl->base.x, ctl->base.y, ctl->base.w, ctl->base.h,
    +
    500 g_retroflat_state->window, (HMENU)(ctl->base.idc),
    +
    501 g_retroflat_instance, NULL );
    +
    502 if( (HWND)NULL == ctl->base.hwnd ) {
    +
    503 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    504 "Could not create button " SIZE_T_FMT ": %s",
    +
    505 ctl->base.idc, ctl->BUTTON.label );
    +
    506 retval = MERROR_GUI;
    +
    507 goto cleanup;
    +
    508 }
    +
    509
    +
    510cleanup:
    +
    511
    +
    512# endif
    +
    513
    +
    514 return retval;
    +
    515}
    +
    516
    +
    517static void retrogui_free_BUTTON( union RETROGUI_CTL* ctl ) {
    +
    518}
    +
    519
    +
    520static MERROR_RETVAL retrogui_init_BUTTON( union RETROGUI_CTL* ctl ) {
    +
    521 MERROR_RETVAL retval = MERROR_OK;
    +
    522
    +
    523 debug_printf( 1, "initializing button " SIZE_T_FMT "...", ctl->base.idc );
    +
    524
    +
    525 ctl->base.fg_color = RETROFLAT_COLOR_BLACK;
    +
    526 ctl->base.bg_color = RETROFLAT_COLOR_GRAY;
    +
    527
    +
    528 return retval;
    +
    529}
    +
    530
    +
    531/* === Control: TEXTBOX === */
    +
    532
    +
    533static RETROGUI_IDC retrogui_click_TEXTBOX(
    +
    534 struct RETROGUI* gui,
    +
    535 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    536) {
    +
    537 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    538
    +
    539 return idc_out;
    +
    540}
    +
    541
    +
    542static RETROGUI_IDC retrogui_key_TEXTBOX(
    +
    543 union RETROGUI_CTL* ctl, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    544) {
    +
    545 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    546 char c = '\0';
    +
    547
    +
    548# if defined( RETROGUI_NATIVE_WIN )
    +
    549 /* Do nothing. */
    +
    550# else
    +
    551
    +
    552 c = retroflat_vk_to_ascii( *p_input, input_evt->key_flags );
    +
    553
    +
    554 /* Ignore non-printable characters. */
    +
    555 if(
    +
    556 0 == c &&
    +
    557 RETROFLAT_KEY_RIGHT != *p_input &&
    +
    558 RETROFLAT_KEY_LEFT != *p_input
    +
    559 ) {
    +
    560 goto cleanup;
    +
    561 }
    +
    562
    +
    563 /* Lock text field. */
    +
    564 assert( NULL == ctl->TEXTBOX.text );
    +
    565 assert( (MAUG_MHANDLE)NULL != ctl->TEXTBOX.text_h );
    +
    566 maug_mlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    567 if( NULL == ctl->TEXTBOX.text ) {
    +
    568 error_printf( "could not lock TEXTBOX text handle!" );
    +
    569 goto cleanup;
    +
    570 }
    +
    571
    +
    572 switch( *p_input ) {
    +
    573 case RETROFLAT_KEY_BKSP:
    + +
    575 ctl->TEXTBOX.text, ctl->TEXTBOX.text_cur, ctl->TEXTBOX.text_sz )
    +
    576 break;
    +
    577
    +
    578 case RETROFLAT_KEY_ENTER:
    +
    579 idc_out = ctl->base.idc;
    +
    580 break;
    +
    581
    +
    582 case RETROFLAT_KEY_LEFT:
    +
    583 if( 0 < ctl->TEXTBOX.text_cur ) {
    +
    584 ctl->TEXTBOX.text_cur--;
    +
    585 }
    +
    586 break;
    +
    587
    +
    588 case RETROFLAT_KEY_RIGHT:
    +
    589 if( ctl->TEXTBOX.text_sz > ctl->TEXTBOX.text_cur ) {
    +
    590 ctl->TEXTBOX.text_cur++;
    +
    591 }
    +
    592 break;
    +
    593
    +
    594 default:
    +
    595 assert( ctl->TEXTBOX.text_sz < ctl->TEXTBOX.text_sz_max );
    + +
    597 ctl->TEXTBOX.text,
    +
    598 ctl->TEXTBOX.text_cur,
    +
    599 ctl->TEXTBOX.text_sz,
    +
    600 ctl->TEXTBOX.text_sz_max );
    +
    601 break;
    +
    602 }
    +
    603
    +
    604 /* TODO: Remove input from queue? */
    +
    605
    +
    606cleanup:
    +
    607
    +
    608 if( NULL != ctl->TEXTBOX.text ) {
    +
    609 maug_munlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    610 }
    +
    611
    +
    612# endif
    +
    613
    +
    614 return idc_out;
    +
    615}
    +
    616
    +
    617static void retrogui_redraw_TEXTBOX(
    +
    618 struct RETROGUI* gui, union RETROGUI_CTL* ctl
    +
    619) {
    +
    620
    +
    621# if defined( RETROGUI_NATIVE_WIN )
    +
    622 /* Do nothing. */
    +
    623# else
    +
    624
    +
    625 retroflat_rect( gui->draw_bmp, ctl->base.bg_color, ctl->base.x, ctl->base.y,
    +
    626 ctl->base.w, ctl->base.h, RETROFLAT_FLAGS_FILL );
    +
    627
    +
    628
    +
    629 /* Draw chiselled inset border. */
    +
    630
    +
    631 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_BLACK,
    +
    632 ctl->base.x, ctl->base.y, ctl->base.w, 2,
    + +
    634
    +
    635 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_BLACK,
    +
    636 ctl->base.x, ctl->base.y, 2, ctl->base.h,
    + +
    638
    +
    639 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_DARKGRAY,
    +
    640 ctl->base.x, ctl->base.y + ctl->base.h - 1,
    +
    641 ctl->base.w, 2,
    + +
    643
    +
    644 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_DARKGRAY,
    +
    645 ctl->base.x + ctl->base.w - 1, ctl->base.y, 2, ctl->base.h,
    + +
    647
    +
    648 /* Draw text. */
    +
    649
    +
    650 assert( NULL == ctl->TEXTBOX.text );
    +
    651 maug_mlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    652 if( NULL == ctl->TEXTBOX.text ) {
    +
    653 goto cleanup;
    +
    654 }
    +
    655
    + +
    657 gui->draw_bmp, ctl->base.fg_color, ctl->TEXTBOX.text, 0, NULL,
    +
    658 ctl->base.x + RETROGUI_PADDING,
    +
    659 ctl->base.y + RETROGUI_PADDING, 0 );
    +
    660
    +
    661cleanup:
    +
    662
    +
    663 if( NULL != ctl->TEXTBOX.text ) {
    +
    664 maug_munlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    665 }
    +
    666
    +
    667 /* TODO: Get cursor color from GUI. */
    +
    668 retroflat_rect( gui->draw_bmp, RETROFLAT_COLOR_BLUE,
    +
    669 ctl->base.x + RETROGUI_PADDING + (8 * ctl->TEXTBOX.text_cur),
    +
    670 ctl->base.y + RETROGUI_PADDING,
    +
    671 8, 8,
    +
    672 /* Draw blinking cursor. */
    +
    673 gui->focus == ctl->base.idc && retroflat_get_ms() % 30 > 15
    +
    674 ? RETROFLAT_FLAGS_FILL : 0 );
    +
    675
    +
    676# endif
    +
    677
    +
    678 return;
    +
    679}
    +
    680
    +
    681static MERROR_RETVAL retrogui_push_TEXTBOX( union RETROGUI_CTL* ctl ) {
    +
    682 MERROR_RETVAL retval = MERROR_OK;
    +
    683
    +
    684# if defined( RETROGUI_NATIVE_WIN )
    +
    685
    +
    686 ctl->base.hwnd = CreateWindow(
    +
    687 "EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER,
    +
    688 ctl->base.x, ctl->base.y, ctl->base.w, ctl->base.h,
    +
    689 g_retroflat_state->window, (HMENU)(ctl->base.idc),
    +
    690 g_retroflat_instance, NULL );
    +
    691 if( (HWND)NULL == ctl->base.hwnd ) {
    +
    692 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    693 "Could not create textbox: " SIZE_T_FMT, ctl->base.idc );
    +
    694 retval = MERROR_GUI;
    +
    695 goto cleanup;
    +
    696 }
    +
    697
    +
    698# else
    +
    699
    +
    700 debug_printf( 1, "clearing textbox " SIZE_T_FMT " buffer...",
    +
    701 ctl->base.idc );
    +
    702 assert( NULL == ctl->TEXTBOX.text_h );
    +
    703 ctl->TEXTBOX.text_h = maug_malloc( RETROGUI_CTL_TEXT_SZ_MAX, 1 );
    +
    704 maug_cleanup_if_null_alloc( MAUG_MHANDLE, ctl->TEXTBOX.text_h );
    +
    705 ctl->TEXTBOX.text_sz_max = RETROGUI_CTL_TEXT_SZ_MAX;
    +
    706
    +
    707 maug_mlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    708 maug_cleanup_if_null_alloc( char*, ctl->TEXTBOX.text );
    +
    709 debug_printf( 1, "clearing textbox " SIZE_T_FMT " buffer...",
    +
    710 ctl->base.idc );
    +
    711 maug_mzero( ctl->TEXTBOX.text, RETROGUI_CTL_TEXT_SZ_MAX );
    +
    712 maug_munlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    713
    +
    714# endif
    +
    715
    +
    716cleanup:
    +
    717
    +
    718 return retval;
    +
    719}
    +
    720
    +
    721static void retrogui_free_TEXTBOX( union RETROGUI_CTL* ctl ) {
    +
    722 if( NULL != ctl->TEXTBOX.text_h ) {
    +
    723 maug_mfree( ctl->TEXTBOX.text_h );
    +
    724 }
    +
    725}
    +
    726
    +
    727static MERROR_RETVAL retrogui_init_TEXTBOX( union RETROGUI_CTL* ctl ) {
    +
    728 MERROR_RETVAL retval = MERROR_OK;
    +
    729
    +
    730 debug_printf( 1, "initializing textbox " SIZE_T_FMT "...", ctl->base.idc );
    +
    731
    +
    732 ctl->base.fg_color = RETROFLAT_COLOR_BLACK;
    +
    733 ctl->base.bg_color = RETROFLAT_COLOR_WHITE;
    +
    734
    +
    735 return retval;
    +
    736}
    +
    737
    +
    738/* === Generic Functions === */
    +
    739
    +
    740union RETROGUI_CTL* retrogui_get_ctl_by_idc(
    +
    741 struct RETROGUI* gui, size_t idc
    +
    742) {
    +
    743 size_t i = 0;
    +
    744 union RETROGUI_CTL* ctl = NULL;
    +
    745
    +
    746 for( i = 0 ; gui->ctls_sz > i ; i++ ) {
    +
    747 if( idc == gui->ctls[i].base.idc ) {
    +
    748 ctl = &(gui->ctls[i]);
    +
    749 break;
    +
    750 }
    +
    751 }
    +
    752
    +
    753 if( NULL == ctl ) {
    +
    754 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    755 "Could not find GUI item: " SIZE_T_FMT, idc );
    +
    756 }
    +
    757
    +
    758 return ctl;
    +
    759}
    +
    760
    + +
    762 struct RETROGUI* gui, int* p_input, struct RETROFLAT_INPUT* input_evt
    +
    763) {
    +
    764 size_t i = 0,
    +
    765 mouse_x = 0,
    +
    766 mouse_y = 0;
    +
    767 RETROGUI_IDC idc_out = RETROGUI_IDC_NONE;
    +
    768 union RETROGUI_CTL* ctl = NULL;
    +
    769
    +
    770 assert( NULL != gui->ctls );
    +
    771
    +
    772# if defined( RETROGUI_NATIVE_WIN )
    +
    773
    +
    774 if( 0 == g_retroflat_state->last_idc ) {
    +
    775 /* No WM_COMMAND to process. */
    +
    776 goto cleanup;
    +
    777 }
    +
    778
    +
    779 ctl = retrogui_get_ctl_by_idc( gui, g_retroflat_state->last_idc );
    +
    780 g_retroflat_state->last_idc = 0;
    +
    781 if( NULL == ctl ) {
    +
    782 debug_printf( 1, "invalid IDC: " SIZE_T_FMT, gui->focus );
    +
    783 }
    +
    784
    +
    785 if( RETROGUI_CTL_TYPE_TEXTBOX == ctl->base.type ) {
    +
    786 if( SendMessage( ctl->base.hwnd, EM_GETMODIFY, 0, 0 ) ) {
    +
    787 SendMessage( ctl->base.hwnd, EM_SETMODIFY, 0, 0 );
    +
    788 debug_printf( 1, "mod: %d",
    +
    789 SendMessage( ctl->base.hwnd, EM_GETMODIFY, 0, 0 ) );
    +
    790 }
    +
    791 }
    +
    792
    +
    793# else
    +
    794
    +
    795 /* Use our cross-platform controls. */
    +
    796
    +
    797 #define RETROGUI_CTL_TABLE_CLICK( idx, c_name, c_fields ) \
    +
    798 } else if( RETROGUI_CTL_TYPE_ ## c_name == gui->ctls[i].base.type ) { \
    +
    799 idc_out = \
    +
    800 retrogui_click_ ## c_name( gui, &(gui->ctls[i]), p_input, input_evt );
    +
    801
    +
    802 #define RETROGUI_CTL_TABLE_KEY( idx, c_name, c_fields ) \
    +
    803 } else if( RETROGUI_CTL_TYPE_ ## c_name == ctl->base.type ) { \
    +
    804 idc_out = retrogui_key_ ## c_name( ctl, p_input, input_evt );
    +
    805
    +
    806 if( 0 == *p_input ) {
    +
    807 goto reset_debounce;
    +
    808
    +
    809 } else if(
    +
    810 RETROFLAT_MOUSE_B_LEFT == *p_input ||
    +
    811 RETROFLAT_MOUSE_B_RIGHT == *p_input
    +
    812 ) {
    +
    813 /* Remove all focus before testing if a new control has focus. */
    +
    814 gui->focus = RETROGUI_IDC_NONE;
    +
    815
    +
    816 mouse_x = input_evt->mouse_x;
    +
    817 mouse_y = input_evt->mouse_y;
    +
    818
    +
    819 if( NULL != gui->draw_xy ) {
    +
    820 gui->draw_xy( &mouse_x, &mouse_y, gui->draw_xy_data );
    +
    821 }
    +
    822
    +
    823 for( i = 0 ; gui->ctls_sz > i ; i++ ) {
    +
    824 if(
    +
    825 mouse_x < gui->ctls[i].base.x ||
    +
    826 mouse_y < gui->ctls[i].base.y ||
    +
    827 mouse_x > gui->ctls[i].base.x + gui->ctls[i].base.w ||
    +
    828 mouse_y > gui->ctls[i].base.y + gui->ctls[i].base.h
    +
    829 ) {
    +
    830 continue;
    +
    831 }
    +
    832
    +
    833 if( gui->idc_prev == gui->ctls[i].base.idc ) {
    +
    834 /* No repeated clicks! */
    +
    835 /* TODO: Allow exceptions for e.g. scrollbars. */
    +
    836 idc_out = RETROGUI_IDC_NONE;
    +
    837 goto cleanup;
    +
    838 }
    +
    839
    +
    840 gui->idc_prev = gui->ctls[i].base.idc;
    +
    841
    +
    842 gui->focus = gui->ctls[i].base.idc;
    +
    843
    +
    844 if( 0 ) {
    +
    845 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_CLICK )
    +
    846 }
    +
    847 break;
    +
    848 }
    +
    849
    +
    850 } else {
    +
    851
    +
    852 if( RETROGUI_IDC_NONE == gui->focus ) {
    +
    853 goto reset_debounce;
    +
    854 }
    +
    855
    +
    856 /* Send keystrokes to control that has focus. */
    +
    857
    +
    858 ctl = retrogui_get_ctl_by_idc( gui, gui->focus );
    +
    859 if( NULL == ctl ) {
    +
    860 debug_printf( 1, "invalid IDC: " SIZE_T_FMT, gui->focus );
    +
    861 goto reset_debounce;
    +
    862 }
    +
    863
    +
    864 if( 0 ) {
    +
    865 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_KEY )
    +
    866 }
    +
    867 }
    +
    868
    +
    869reset_debounce:
    +
    870
    +
    871 /* Reset repeat detector. */
    +
    872 gui->idc_prev = RETROGUI_IDC_NONE;
    +
    873
    +
    874# endif
    +
    875
    +
    876cleanup:
    +
    877
    +
    878 return idc_out;
    +
    879}
    +
    880
    +
    881void retrogui_redraw_ctls( struct RETROGUI* gui ) {
    +
    882 size_t i = 0;
    +
    883
    +
    884 assert( NULL != gui->ctls );
    +
    885
    +
    886 #define RETROGUI_CTL_TABLE_REDRAW( idx, c_name, c_fields ) \
    +
    887 } else if( RETROGUI_CTL_TYPE_ ## c_name == gui->ctls[i].base.type ) { \
    +
    888 retrogui_redraw_ ## c_name( gui, &(gui->ctls[i]) ); \
    +
    889
    +
    890 for( i = 0 ; gui->ctls_sz > i ; i++ ) {
    +
    891 if( 0 ) {
    +
    892 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_REDRAW )
    +
    893 }
    +
    894 }
    +
    895}
    +
    896
    +
    897MERROR_RETVAL retrogui_push_ctl(
    +
    898 struct RETROGUI* gui, union RETROGUI_CTL* ctl
    +
    899) {
    +
    900 MERROR_RETVAL retval = MERROR_OK;
    +
    901
    +
    902 assert( NULL != gui->ctls );
    +
    903
    +
    904 /* TODO: Hunt for control IDC and fail if duplicate found! */
    +
    905
    +
    906 /* TODO: Grow controls if needed. */
    +
    907 assert( gui->ctls_sz + 1 < gui->ctls_sz_max );
    +
    908
    +
    909 if( RETROFLAT_COLOR_NULL == ctl->base.bg_color ) {
    +
    910 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    911 "Invalid background color specified for control " SIZE_T_FMT "!",
    +
    912 ctl->base.idc );
    +
    913 retval = MERROR_GUI;
    +
    914 goto cleanup;
    +
    915
    +
    916 }
    +
    917
    +
    918 if( RETROFLAT_COLOR_NULL == ctl->base.fg_color ) {
    +
    919 retroflat_message( RETROFLAT_MSG_FLAG_ERROR, "Error",
    +
    920 "Invalid foreground color specified for control " SIZE_T_FMT "!",
    +
    921 ctl->base.idc );
    +
    922 retval = MERROR_GUI;
    +
    923 goto cleanup;
    +
    924 }
    +
    925
    +
    926 debug_printf( 1, "pushing %s " SIZE_T_FMT " to slot " SIZE_T_FMT "...",
    +
    927 gc_retrogui_ctl_names[ctl->base.type], ctl->base.idc, gui->ctls_sz );
    +
    928
    +
    929 memcpy(
    +
    930 &(gui->ctls[gui->ctls_sz]),
    +
    931 ctl,
    +
    932 sizeof( union RETROGUI_CTL ) );
    +
    933 gui->ctls_sz++;
    +
    934
    +
    935 #define RETROGUI_CTL_TABLE_PUSH( idx, c_name, c_fields ) \
    +
    936 } else if( RETROGUI_CTL_TYPE_ ## c_name == ctl->base.type ) { \
    +
    937 retval = retrogui_push_ ## c_name( &(gui->ctls[gui->ctls_sz - 1]) ); \
    +
    938 maug_cleanup_if_not_ok();
    +
    939
    +
    940 if( 0 ) {
    +
    941 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_PUSH )
    +
    942 }
    +
    943
    +
    944cleanup:
    +
    945
    +
    946 return retval;
    +
    947}
    +
    948
    +
    949MERROR_RETVAL retrogui_get_ctl_text(
    +
    950 struct RETROGUI* gui, RETROGUI_IDC idc, char* buffer, size_t buffer_sz
    +
    951) {
    +
    952 MERROR_RETVAL retval = MERROR_OK;
    +
    953 union RETROGUI_CTL* ctl = NULL;
    +
    954
    +
    955 ctl = retrogui_get_ctl_by_idc( gui, idc );
    +
    956 if( NULL == ctl ) {
    +
    957 goto cleanup;
    +
    958 }
    +
    959
    +
    960 if( RETROGUI_CTL_TYPE_TEXTBOX == ctl->base.type ) {
    +
    961# if defined( RETROGUI_NATIVE_WIN )
    +
    962 /* TODO */
    +
    963#else
    +
    964 maug_mlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    965 maug_cleanup_if_null_alloc( char*, ctl->TEXTBOX.text );
    +
    966
    +
    967 strncpy( buffer, ctl->TEXTBOX.text, buffer_sz );
    +
    968# endif
    +
    969 }
    +
    970
    +
    971cleanup:
    +
    972
    +
    973 if( RETROGUI_CTL_TYPE_TEXTBOX == ctl->base.type ) {
    +
    974 if( NULL != ctl->TEXTBOX.text ) {
    +
    975 maug_munlock( ctl->TEXTBOX.text_h, ctl->TEXTBOX.text );
    +
    976 }
    +
    977 }
    +
    978
    +
    979 return retval;
    +
    980}
    +
    981
    +
    982size_t retrogui_get_ctl_sel_idx( struct RETROGUI* gui, RETROGUI_IDC idc ) {
    +
    983 size_t idx = -1;
    +
    984 union RETROGUI_CTL* ctl = NULL;
    +
    985
    +
    986 ctl = retrogui_get_ctl_by_idc( gui, idc );
    +
    987 if( NULL == ctl ) {
    +
    988 goto cleanup;
    +
    989 }
    +
    990
    +
    991 assert( RETROGUI_CTL_TYPE_LISTBOX == ctl->base.type );
    +
    992
    +
    993# if defined( RETROGUI_NATIVE_WIN )
    +
    994 idx = SendMessage( ctl->base.hwnd, LB_GETCARETINDEX, 0, 0 );
    +
    995# else
    +
    996 idx = ctl->LISTBOX.sel_idx;
    +
    997# endif
    +
    998
    +
    999cleanup:
    +
    1000
    +
    1001 return idx;
    +
    1002}
    +
    1003
    +
    1004MERROR_RETVAL retrogui_init_ctl(
    +
    1005 union RETROGUI_CTL* ctl, uint8_t type, size_t idc
    +
    1006) {
    +
    1007 MERROR_RETVAL retval = MERROR_OK;
    +
    1008
    +
    1009 debug_printf( 1, "initializing control base " SIZE_T_FMT "...", idc );
    +
    1010
    +
    1011 maug_mzero( ctl, sizeof( union RETROGUI_CTL ) );
    +
    1012
    +
    1013 ctl->base.type = type;
    +
    1014 ctl->base.idc = idc;
    +
    1015 ctl->base.fg_color = RETROFLAT_COLOR_NULL;
    +
    1016 ctl->base.bg_color = RETROFLAT_COLOR_NULL;
    +
    1017
    +
    1018 #define RETROGUI_CTL_TABLE_INITS( idx, c_name, c_fields ) \
    +
    1019 } else if( RETROGUI_CTL_TYPE_ ## c_name == ctl->base.type ) { \
    +
    1020 retrogui_init_ ## c_name( ctl );
    +
    1021
    +
    1022 if( 0 ) {
    +
    1023 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_INITS )
    +
    1024 }
    +
    1025
    +
    1026 return retval;
    +
    1027}
    +
    1028
    +
    1029void retrogui_free( struct RETROGUI* gui ) {
    +
    1030 size_t i = 0;
    +
    1031
    +
    1032 if( NULL == gui->ctls && (MAUG_MHANDLE)NULL != gui->ctls_h ) {
    +
    1033 maug_mlock( gui->ctls_h, gui->ctls );
    +
    1034 if( NULL == gui->ctls ) {
    +
    1035 goto cleanup;
    +
    1036 }
    +
    1037 }
    +
    1038
    +
    1039 #define RETROGUI_CTL_TABLE_FREE( idx, c_name, c_fields ) \
    +
    1040 } else if( RETROGUI_CTL_TYPE_ ## c_name == gui->ctls[i].base.type ) { \
    +
    1041 retrogui_free_ ## c_name( &(gui->ctls[i]) );
    +
    1042
    +
    1043 for( i = 0 ; gui->ctls_sz > i ; i++ ) {
    +
    1044 if( 0 ) {
    +
    1045 RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_FREE )
    +
    1046 }
    +
    1047 }
    +
    1048
    +
    1049 maug_munlock( gui->ctls_h, gui->ctls );
    +
    1050
    +
    1051cleanup:
    +
    1052
    +
    1053 maug_mfree( gui->ctls_h );
    +
    1054
    +
    1055}
    +
    1056
    +
    1057MERROR_RETVAL retrogui_init( struct RETROGUI* gui ) {
    +
    1058 MERROR_RETVAL retval = MERROR_OK;
    +
    1059
    +
    1060 maug_mzero( gui, sizeof( struct RETROGUI ) );
    +
    1061
    +
    1062 gui->ctls_h = maug_malloc(
    +
    1063 RETROGUI_CTL_SZ_MAX_INIT, sizeof( struct RETROGUI ) );
    +
    1064 maug_cleanup_if_null_alloc( MAUG_MHANDLE, gui );
    +
    1065 gui->ctls_sz_max = RETROGUI_CTL_SZ_MAX_INIT;
    +
    1066
    +
    1067cleanup:
    +
    1068
    +
    1069 return retval;
    +
    1070}
    +
    1071
    +
    1072#else
    +
    1073
    +
    1074#define RETROGUI_CTL_TABLE_CONSTS( idx, c_name, c_fields ) \
    +
    1075 extern MAUG_CONST uint8_t RETROGUI_CTL_TYPE_ ## c_name;
    +
    1076
    +
    1077RETROGUI_CTL_TABLE( RETROGUI_CTL_TABLE_CONSTS )
    +
    1078
    +
    1079extern MAUG_CONST char* gc_retrogui_ctl_names[];
    +
    1080
    +
    1081#endif /* RETROGUI_C */
    +
    1082 /* maug_retrogui */
    +
    1084
    +
    1085#endif /* !RETROGUI_H */
    +
    1086
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    void retroflat_string(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, const char *str, int str_sz, const char *font_str, int x_orig, int y_orig, uint8_t flags)
    Draw a text string at the specified location in the specified font and color on the target RETROFLAT_...
    +
    void retroflat_string_sz(struct RETROFLAT_BITMAP *target, const char *str, size_t str_sz, const char *font_str, size_t *w_out, size_t *h_out, uint8_t flags)
    Get the size in pixels of a text string when drawn with a given font by retroflat_string().
    +
    void retroflat_rect(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x, int y, int w, int h, uint8_t flags)
    Draw a rectangle onto the target RETROFLAT_BITMAP.
    +
    #define RETROFLAT_FLAGS_FILL
    Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
    Definition retroflt.h:334
    +
    #define retroflat_buffer_insert(c, buffer, buffer_cur, buffer_sz, buffer_mx)
    Insert a character into a text buffer at cursor position.
    Definition retroflt.h:726
    +
    #define retroflat_buffer_bksp(buffer, buffer_cur, buffer_sz)
    Remove a character from a text buffer before cursor position.
    Definition retroflt.h:710
    +
    void retroflat_message(uint8_t flags, const char *title, const char *format,...)
    Display a message in a dialog box and/or on stderr.
    +
    #define RETROGUI_CTL_TABLE_FIELDS(idx, c_name, c_fields)
    Creates the corresponding RETROGUI_* structs from RETROGUI_CTL_TABLE that populate union RETROGUI_CTL...
    Definition retrogui.h:91
    +
    #define RETROGUI_CTL_TABLE(f)
    Table defining all control types and their specific fields in RETROGUI_CTL.
    Definition retrogui.h:62
    +
    #define RETROGUI_CTL_TABLE_TYPES(idx, c_name, c_fields)
    Adds the structs created by RETROGUI_CTL_TABLE_FIELDS to union RETROGUI_CTL.
    Definition retrogui.h:103
    +
    size_t RETROGUI_IDC
    Unique identifying constant number for controls.
    Definition retrogui.h:44
    +
    RETROGUI_IDC retrogui_poll_ctls(struct RETROGUI *gui, int *p_input, struct RETROFLAT_INPUT *input_evt)
    Poll for the last clicked control and maintain listboxes and menus.
    +
    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
    Definition retroflt.h:1610
    +
    Struct passed to retroflat_poll_input() to hold return data.
    Definition retroflt.h:749
    +
    int mouse_y
    Y-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
    Definition retroflt.h:759
    +
    int mouse_x
    X-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
    Definition retroflt.h:754
    +
    Fields common to ALL RETROGUI_CTL types.
    Definition retrogui.h:73
    +
    Definition retrogui.h:115
    +
    Definition retrogui.h:106
    +
    + + + + diff --git a/retrosft_8h_source.html b/retrosft_8h_source.html new file mode 100644 index 00000000..cbf23207 --- /dev/null +++ b/retrosft_8h_source.html @@ -0,0 +1,472 @@ + + + + + + + +maug: retrosft.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    retrosft.h
    +
    +
    +
    1
    +
    2#ifndef RETROSFT_H
    +
    3#define RETROSFT_H
    +
    4
    +
    5MERROR_RETVAL retrosoft_load_glyph(
    +
    6 RETROFLAT_COLOR color,
    +
    7 size_t set_idx, size_t glyph_idx, struct RETROFLAT_BITMAP* bmp );
    +
    8
    +
    9MERROR_RETVAL retrosoft_init();
    +
    10
    +
    11void retrosoft_shutdown();
    +
    12
    +
    13void retrosoft_line(
    +
    14 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    15 int x1, int y1, int x2, int y2, uint8_t flags );
    +
    16
    +
    17void retrosoft_rect(
    +
    18 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color_idx,
    +
    19 int x, int y, int w, int h, uint8_t flags );
    +
    20
    +
    21void retrosoft_ellipse(
    +
    22 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    23 int x, int y, int w, int h, uint8_t flags );
    +
    24
    +
    25void retrosoft_ellipse(
    +
    26 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    27 int x, int y, int w, int h, uint8_t flags );
    +
    28
    +
    29void retrosoft_string_sz(
    +
    30 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
    +
    31 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags );
    +
    32
    +
    33void retrosoft_string(
    +
    34 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    35 const char* str, size_t str_sz, const char* font_str, int x_orig, int y_orig,
    +
    36 uint8_t flags );
    +
    37
    +
    38#ifdef RETROSFT_C
    +
    39
    +
    40# include "mfont8x8.h"
    +
    41
    +
    42/* TODO: Create another depth for each color. */
    +
    43static struct RETROFLAT_BITMAP
    +
    44gc_font_bmps[RETROFLAT_COLORS_SZ][RETROSOFT_SETS_COUNT][RETROSOFT_GLYPHS_COUNT];
    +
    45
    +
    46/* === */
    +
    47
    +
    48MERROR_RETVAL retrosoft_load_glyph(
    +
    49 RETROFLAT_COLOR color,
    +
    50 size_t set_idx, size_t glyph_idx, struct RETROFLAT_BITMAP* bmp
    +
    51) {
    +
    52 MERROR_RETVAL retval = MERROR_OK;
    +
    53 int x = 0,
    +
    54 y = 0;
    +
    55 const char* glyph_dots = gc_font8x8[set_idx][glyph_idx];
    +
    56
    +
    57 /* Create a transparent bitmap to draw on. */
    +
    58 retval = retroflat_create_bitmap(
    +
    59 RETROSOFT_GLYPH_W_SZ, RETROSOFT_GLYPH_H_SZ, bmp, 0 );
    +
    60 maug_cleanup_if_not_ok();
    +
    61
    +
    62 /* Normally draw lock is called from the main loop, but we're making an
    +
    63 * off-screen bitmap, here!
    +
    64 */
    + +
    66 retroflat_px_lock( bmp );
    +
    67
    +
    68 /* Draw the glyph onto the bitmap. */
    +
    69 for( y = 0 ; RETROSOFT_GLYPH_H_SZ > y ; y++ ) {
    +
    70 for( x = 0 ; RETROSOFT_GLYPH_W_SZ > x ; x++ ) {
    +
    71 if( 1 == ((glyph_dots[y] >> x) & 0x01) ) {
    +
    72 retroflat_px( bmp, color, x, y, 0 );
    +
    73 }
    +
    74 }
    +
    75 }
    +
    76
    +
    77 retroflat_px_release( bmp );
    +
    78 retroflat_draw_release( bmp );
    +
    79
    +
    80 /*
    +
    81 retroflat_rect(
    +
    82 bmp, RETROFLAT_COLOR_RED, 0, 0,
    +
    83 RETROSOFT_GLYPH_W_SZ, RETROSOFT_GLYPH_H_SZ, RETROFLAT_FLAGS_FILL );
    +
    84 */
    +
    85
    +
    86cleanup:
    +
    87
    +
    88 return retval;
    +
    89}
    +
    90
    +
    91/* === */
    +
    92
    +
    93MERROR_RETVAL retrosoft_init() {
    +
    94 MERROR_RETVAL retval = MERROR_OK;
    +
    95 size_t i = 0,
    +
    96 j = 0;
    +
    97 RETROFLAT_COLOR h = RETROFLAT_COLOR_WHITE;
    +
    98
    +
    99#ifdef RETROSOFT_PRELOAD_COLORS
    +
    100 for( h = 0 ; RETROFLAT_COLORS_SZ > h ; h++ ) {
    +
    101 debug_printf( 0, "loading glyphs in %s...", gc_retroflat_color_names[h] );
    +
    102#endif /* RETROSOFT_PRELOAD_COLORS */
    +
    103 for( i = 0 ; RETROSOFT_SETS_COUNT > i ; i++ ) {
    +
    104 for( j = 0 ; RETROSOFT_GLYPHS_COUNT > j ; j++ ) {
    +
    105 debug_printf( 0, "loading glyph " SIZE_T_FMT "...", j );
    +
    106 retval = retrosoft_load_glyph( h, i, j, &(gc_font_bmps[h][i][j]) );
    +
    107 maug_cleanup_if_not_ok();
    +
    108 }
    +
    109 }
    +
    110#ifdef RETROSOFT_PRELOAD_COLORS
    +
    111 }
    +
    112#endif /* RETROSOFT_PRELOAD_COLORS */
    +
    113
    +
    114cleanup:
    +
    115
    +
    116 /* TODO: Unload loaded bitmaps if retval not OK. */
    +
    117
    +
    118 return retval;
    +
    119}
    +
    120
    +
    121/* === */
    +
    122
    +
    123void retrosoft_shutdown() {
    +
    124 size_t i = 0,
    +
    125 j = 0;
    +
    126 RETROFLAT_COLOR h = RETROFLAT_COLOR_WHITE;
    +
    127
    +
    128#ifdef RETROSOFT_PRELOAD_COLORS
    +
    129 for( h = 0 ; RETROFLAT_COLORS_SZ > h ; h++ ) {
    +
    130#endif /* RETROSOFT_PRELOAD_COLORS */
    +
    131 for( i = 0 ; RETROSOFT_SETS_COUNT > i ; i++ ) {
    +
    132 for( j = 0 ; RETROSOFT_GLYPHS_COUNT > j ; j++ ) {
    +
    133 retroflat_destroy_bitmap( &(gc_font_bmps[h][i][j]) );
    +
    134 }
    +
    135 }
    +
    136#ifdef RETROSOFT_PRELOAD_COLORS
    +
    137 }
    +
    138#endif /* RETROSOFT_PRELOAD_COLORS */
    +
    139}
    +
    140
    +
    141/* === */
    +
    142
    +
    143void retrosoft_line(
    +
    144 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    145 int x1, int y1, int x2, int y2, uint8_t flags
    +
    146) {
    +
    147 #define RETROFLAT_LINE_X 0
    +
    148 #define RETROFLAT_LINE_Y 1
    +
    149
    +
    150 uint8_t for_axis = 0,
    +
    151 off_axis = 0;
    +
    152 int16_t dist[2],
    +
    153 start[2],
    +
    154 end[2],
    +
    155 iter[2],
    +
    156 inc = 1,
    +
    157 delta = 0;
    +
    158
    +
    159 /* TODO: Handle thickness. */
    +
    160
    +
    161 retroflat_px_lock( target );
    +
    162
    +
    163 /* Figure out strategy based on line slope. */
    +
    164 if( abs( y2 - y1 ) < abs( x2 - x1 ) ) {
    +
    165 if( x1 > x2 ) {
    +
    166 start[RETROFLAT_LINE_X] = x2;
    +
    167 start[RETROFLAT_LINE_Y] = y2;
    +
    168 end[RETROFLAT_LINE_X] = x1;
    +
    169 end[RETROFLAT_LINE_Y] = y1;
    +
    170 for_axis = RETROFLAT_LINE_X;
    +
    171 } else {
    +
    172 start[RETROFLAT_LINE_X] = x1;
    +
    173 start[RETROFLAT_LINE_Y] = y1;
    +
    174 end[RETROFLAT_LINE_X] = x2;
    +
    175 end[RETROFLAT_LINE_Y] = y2;
    +
    176 for_axis = RETROFLAT_LINE_X;
    +
    177 }
    +
    178 } else {
    +
    179 if( y2 < y1 ) {
    +
    180 start[RETROFLAT_LINE_X] = x2;
    +
    181 start[RETROFLAT_LINE_Y] = y2;
    +
    182 end[RETROFLAT_LINE_X] = x1;
    +
    183 end[RETROFLAT_LINE_Y] = y1;
    +
    184 for_axis = RETROFLAT_LINE_Y;
    +
    185 } else {
    +
    186 start[RETROFLAT_LINE_X] = x1;
    +
    187 start[RETROFLAT_LINE_Y] = y1;
    +
    188 end[RETROFLAT_LINE_X] = x2;
    +
    189 end[RETROFLAT_LINE_Y] = y2;
    +
    190 for_axis = RETROFLAT_LINE_Y;
    +
    191 }
    +
    192 }
    +
    193
    +
    194 /* C89 requires const initializers, so do math down here. */
    +
    195 off_axis = 1 - for_axis;
    +
    196 iter[RETROFLAT_LINE_X] = start[RETROFLAT_LINE_X];
    +
    197 iter[RETROFLAT_LINE_Y] = start[RETROFLAT_LINE_Y];
    +
    198 dist[RETROFLAT_LINE_X] = end[RETROFLAT_LINE_X] - start[RETROFLAT_LINE_X];
    +
    199 dist[RETROFLAT_LINE_Y] = end[RETROFLAT_LINE_Y] - start[RETROFLAT_LINE_Y];
    +
    200
    +
    201 /* Adjust delta/slope for off-axis. */
    +
    202 delta = (2 * dist[off_axis]) - dist[for_axis];
    +
    203 if( 0 > dist[off_axis] ) {
    +
    204 inc = -1;
    +
    205 dist[off_axis] *= -1;
    +
    206 }
    +
    207
    +
    208 for(
    +
    209 iter[for_axis] = start[for_axis] ;
    +
    210 end[for_axis] > iter[for_axis] ;
    +
    211 iter[for_axis]++
    +
    212 ) {
    +
    213 retroflat_px(
    +
    214 target, color, iter[RETROFLAT_LINE_X], iter[RETROFLAT_LINE_Y], 0 );
    +
    215
    +
    216 /* Increment off-axis based on for-axis. */
    +
    217 if( 0 < delta ) {
    +
    218 iter[off_axis] += inc;
    +
    219 delta += (2 * (dist[off_axis] - dist[for_axis]));
    +
    220 } else {
    +
    221 delta += (2 * dist[off_axis]);
    +
    222 }
    +
    223 }
    +
    224
    +
    225 retroflat_px_release( target );
    +
    226}
    +
    227
    +
    228/* === */
    +
    229
    +
    230void retrosoft_rect(
    +
    231 struct RETROFLAT_BITMAP* target, const RETROFLAT_COLOR color_idx,
    +
    232 int x, int y, int w, int h, uint8_t flags
    +
    233) {
    +
    234 size_t x_iter = 0,
    +
    235 y_iter = 0;
    +
    236
    +
    237 retroflat_px_lock( target );
    +
    238
    + +
    240
    +
    241 for( y_iter = y ; y_iter < y + h ; y_iter++ ) {
    +
    242 for( x_iter = x ; x_iter < x + w ; x_iter++ ) {
    +
    243 /* TODO: Optimize filling 4-byte sequences! */
    +
    244 retroflat_px( target, color_idx, x_iter, y_iter, 0 );
    +
    245 }
    +
    246 }
    +
    247
    +
    248 } else {
    +
    249
    +
    250 retrosoft_line( target, color_idx, x, y, x + w, y, 0 );
    +
    251
    +
    252 retrosoft_line( target, color_idx, x + w, y, x + w, y + h, 0 );
    +
    253
    +
    254 retrosoft_line( target, color_idx, x + w, y + h, x, y + h, 0 );
    +
    255
    +
    256 retrosoft_line( target, color_idx, x, y + h, x, y, 0 );
    +
    257
    +
    258 }
    +
    259
    +
    260 retroflat_px_release( target );
    +
    261}
    +
    262
    +
    263/* === */
    +
    264
    +
    265void retrosoft_ellipse(
    +
    266 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    267 int x, int y, int w, int h, uint8_t flags
    +
    268) {
    +
    269 int32_t i = 0,
    +
    270 i_prev = 0;
    +
    271 int16_t px_x1 = 0,
    +
    272 px_y1 = 0,
    +
    273 px_x2 = 0,
    +
    274 px_y2 = 0;
    +
    275
    +
    276 /* TODO: Switch to Bresenham algorithm. */
    +
    277
    +
    278 /* TODO: Filled ellipse. */
    +
    279
    +
    280 retroflat_px_lock( target );
    +
    281
    +
    282 /* For the soft_lut, input numbers are * 1000... so 0.1 becomes 100. */
    +
    283 for( i = 100 ; 2 * RETROFP_PI + 100 > i ; i += 100 ) {
    +
    284 i_prev = i - 100;
    +
    285
    +
    286 px_x1 = x + (w / 2) + retrofp_cos( i_prev, w / 2 );
    +
    287 px_y1 = y + (h / 2) + retrofp_sin( i_prev, h / 2 );
    +
    288 px_x2 = x + (w / 2) + retrofp_cos( i, w / 2 );
    +
    289 px_y2 = y + (h / 2) + retrofp_sin( i, h / 2 );
    +
    290
    +
    291 assert( 0 <= px_x1 );
    +
    292 assert( 0 <= px_y1 );
    +
    293
    +
    294 retroflat_line( target, color, px_x1, px_y1, px_x2, px_y2, 0 );
    +
    295 }
    +
    296
    +
    297 retroflat_px_release( target );
    +
    298}
    +
    299
    +
    300/* === */
    +
    301
    +
    302void retrosoft_string_sz(
    +
    303 struct RETROFLAT_BITMAP* target, const char* str, size_t str_sz,
    +
    304 const char* font_str, size_t* w_out, size_t* h_out, uint8_t flags
    +
    305) {
    +
    306 /* TODO: Put a little more effort into sizing. */
    +
    307 if( 0 == str_sz ) {
    +
    308 str_sz = strlen( str );
    +
    309 }
    +
    310
    +
    311 *w_out = RETROSOFT_GLYPH_W_SZ * str_sz;
    +
    312 *h_out = RETROSOFT_GLYPH_H_SZ;
    +
    313}
    +
    314
    +
    315/* === */
    +
    316
    +
    317void retrosoft_string(
    +
    318 struct RETROFLAT_BITMAP* target, RETROFLAT_COLOR color,
    +
    319 const char* str, size_t str_sz, const char* font_str, int x_orig, int y_orig,
    +
    320 uint8_t flags
    +
    321) {
    +
    322 size_t i = 0,
    +
    323 glyph_idx = 0;
    +
    324 int x = x_orig;
    +
    325
    +
    326 if( 0 == str_sz ) {
    +
    327 str_sz = strlen( str );
    +
    328 }
    +
    329
    +
    330 for( i = 0 ; str_sz > i ; i++ ) {
    +
    331 /* Terminate prematurely at null. */
    +
    332 if( '\0' == str[i] ) {
    +
    333 break;
    +
    334 }
    +
    335
    +
    336 /* Fonts start at character after space. */
    +
    337 glyph_idx = str[i] - ' ';
    +
    338
    +
    339#if defined( RETROFLAT_API_SDL2 ) && !defined( RETROSOFT_PRELOAD_COLORS )
    +
    340 /* If we're not caching the colors, use SDL2 features if available to
    +
    341 * tint the glyph before blitting it. */
    +
    342 SDL_SetSurfaceColorMod(
    +
    343 gc_font_bmps[RETROFLAT_COLOR_WHITE][0][glyph_idx].surface,
    +
    344 g_retroflat_state->palette[color].r,
    +
    345 g_retroflat_state->palette[color].g,
    +
    346 g_retroflat_state->palette[color].b );
    +
    347 SDL_DestroyTexture(
    +
    348 gc_font_bmps[RETROFLAT_COLOR_WHITE][0][glyph_idx].texture );
    +
    349 gc_font_bmps[RETROFLAT_COLOR_WHITE][0][glyph_idx].texture =
    +
    350 SDL_CreateTextureFromSurface(
    +
    351 g_retroflat_state->buffer.renderer,
    +
    352 gc_font_bmps[RETROFLAT_COLOR_WHITE][0][glyph_idx].surface );
    +
    353#endif /* RETROFLAT_API_SDL2 && !RETROSOFT_PRELOAD_COLORS */
    +
    354
    + +
    356 target, &(gc_font_bmps[
    +
    357#ifdef RETROSOFT_PRELOAD_COLORS
    +
    358 color
    +
    359#else
    +
    360 RETROFLAT_COLOR_WHITE
    +
    361#endif /* !RETROSOFT_PRELOAD_COLORS */
    +
    362 ][0][glyph_idx]), 0, 0, x, y_orig,
    +
    363 RETROSOFT_GLYPH_W_SZ, RETROSOFT_GLYPH_H_SZ );
    +
    364
    +
    365 x += 8;
    +
    366 }
    +
    367}
    +
    368
    +
    369#else
    +
    370
    +
    371#endif /* RETROSFT_C */
    +
    372
    +
    373#endif /* !RETROSFT_H */
    +
    374
    +
    int MERROR_RETVAL
    Return type indicating function returns a value from this list.
    Definition merror.h:19
    +
    void retroflat_blit_bitmap(struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, int s_x, int s_y, int d_x, int d_y, int w, int h)
    Blit the contents of a RETROFLAT_BITMAP onto another RETROFLAT_BITMAP.
    +
    void retroflat_destroy_bitmap(struct RETROFLAT_BITMAP *bitmap)
    Unload a bitmap from a RETROFLAT_BITMAP struct. The struct, itself, is not freed (in case it is on th...
    +
    MERROR_RETVAL retroflat_draw_lock(struct RETROFLAT_BITMAP *bmp)
    Lock a bitmap for drawing. This will be done automatically if necessary and not called explicitly,...
    +
    void retroflat_line(struct RETROFLAT_BITMAP *target, const RETROFLAT_COLOR color, int x1, int y1, int x2, int y2, uint8_t flags)
    Draw a straight line onto the target RETROFLAT_BITMAP.
    +
    #define RETROFLAT_FLAGS_FILL
    Flag for retroflat_rect() or retroflat_ellipse(), indicating drawn shape should be filled.
    Definition retroflt.h:334
    +
    #define RETROFP_PI
    Fixed-point representation of Pi (3.141).
    Definition retrofp.h:17
    +
    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine...
    Definition retroflt.h:1610
    +
    uint8_t flags
    Platform-specific bitmap flags.
    Definition retroflt.h:1614
    +
    struct RETROFLAT_BITMAP buffer
    Off-screen buffer bitmap.
    Definition retroflt.h:1780
    +
    RETROFLAT_COLOR_DEF palette[RETROFLAT_COLORS_SZ]
    Index of available colors, initialized on platform init.
    Definition retroflt.h:1778
    +
    + + + + diff --git a/search/all_0.js b/search/all_0.js new file mode 100644 index 00000000..5e2c3b60 --- /dev/null +++ b/search/all_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['assets_5fpath_0',['assets_path',['../structRETROFLAT__ARGS.html#a16f4ac31022d90753e2e4b36bfa48dae',1,'RETROFLAT_ARGS']]] +]; diff --git a/search/all_1.js b/search/all_1.js new file mode 100644 index 00000000..40fa60ba --- /dev/null +++ b/search/all_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['buffer_0',['buffer',['../structRETROFLAT__STATE.html#a940f28bcdcbe48c35d52d901f8787c50',1,'RETROFLAT_STATE']]] +]; diff --git a/search/all_2.js b/search/all_2.js new file mode 100644 index 00000000..46e753db --- /dev/null +++ b/search/all_2.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['command_20line_20api_0',['Command Line API',['../group__maug__cli.html',1,'']]], + ['config_5fpath_1',['config_path',['../structRETROFLAT__ARGS.html#a1364997cebaa4deb17008e4d9a5d0627',1,'RETROFLAT_ARGS']]] +]; diff --git a/search/all_3.js b/search/all_3.js new file mode 100644 index 00000000..eaa9d92b --- /dev/null +++ b/search/all_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['error_20handling_20api_0',['Error Handling API',['../group__maug__error.html',1,'']]] +]; diff --git a/search/all_4.js b/search/all_4.js new file mode 100644 index 00000000..c6c51f11 --- /dev/null +++ b/search/all_4.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['faces_0',['faces',['../structRETROGLU__OBJ.html#adcfa0dba8302d4609221cd41c5ab8ae7',1,'RETROGLU_OBJ']]], + ['flags_1',['flags',['../structRETROFLAT__BITMAP.html#a6759d6aada5884b51abccf1c9f337078',1,'RETROFLAT_BITMAP']]] +]; diff --git a/search/all_5.js b/search/all_5.js new file mode 100644 index 00000000..491e281d --- /dev/null +++ b/search/all_5.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['global_20flags_0',['Global Flags',['../group__maug__retroflt__flags.html',1,'']]] +]; diff --git a/search/all_6.js b/search/all_6.js new file mode 100644 index 00000000..f2b1fbe7 --- /dev/null +++ b/search/all_6.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['in_2dsitu_20console_20api_0',['In-Situ Console API',['../group__maug__console.html',1,'']]] +]; diff --git a/search/all_7.js b/search/all_7.js new file mode 100644 index 00000000..7b3c1158 --- /dev/null +++ b/search/all_7.js @@ -0,0 +1,25 @@ +var searchData= +[ + ['maug_0',['maug',['../index.html',1,'']]], + ['maug_20retro_20fixed_20point_1',['Maug Retro Fixed Point',['../group__maug__retrofp.html',1,'']]], + ['maug_5fadd_5farg_2',['maug_add_arg',['../group__maug__cli.html#gaa01f6f484f91a815d5776e1b3e88a9db',1,'marge.h']]], + ['maug_5fcli_3',['MAUG_CLI',['../group__maug__cli.html#ga4d54f8a556f4f65df9acb948114ea3f6',1,'marge.h']]], + ['maug_5fcli_5fsigil_4',['MAUG_CLI_SIGIL',['../group__maug__cli.html#gaee9fe9a3cb3f9578249273228cf09ecc',1,'marge.h']]], + ['maug_5ffmt_5fspec_5',['MAUG_FMT_SPEC',['../unionMAUG__FMT__SPEC.html',1,'']]], + ['maug_5fmrealloc_6',['maug_mrealloc',['../group__maug__mem.html#gab7446d8c4aa42d963b300e6b26546fdd',1,'mmem.h']]], + ['maug_5fretroflt_5fexample_5fpage_7',['maug_retroflt_example_page',['../group__maug__retroflt__example.html',1,'']]], + ['memory_20management_20api_8',['Memory Management API',['../group__maug__mem.html',1,'']]], + ['merror_2eh_9',['merror.h',['../merror_8h.html',1,'']]], + ['merror_5fretval_10',['MERROR_RETVAL',['../group__maug__error__retvals.html#ga0feaaadb840388d32d203f4d6d8f417b',1,'merror.h']]], + ['micro_2dprintf_20api_11',['Micro-PrintF API',['../group__maug__uprintf.html',1,'']]], + ['mmem_2eh_12',['mmem.h',['../mmem_8h.html',1,'']]], + ['mouse_5fx_13',['mouse_x',['../structRETROFLAT__INPUT.html#a7d220a4e990ee0d42ceb8d81660fee56',1,'RETROFLAT_INPUT']]], + ['mouse_5fy_14',['mouse_y',['../structRETROFLAT__INPUT.html#a3a213c1aaccd66fdc090dedc2bf92547',1,'RETROFLAT_INPUT']]], + ['mtilemap_15',['MTILEMAP',['../structMTILEMAP.html',1,'']]], + ['mtilemap_2eh_16',['mtilemap.h',['../mtilemap_8h.html',1,'']]], + ['mtilemap_5fcprop_17',['MTILEMAP_CPROP',['../structMTILEMAP__CPROP.html',1,'']]], + ['mtilemap_5fcprop_5fval_18',['MTILEMAP_CPROP_VAL',['../unionMTILEMAP__CPROP__VAL.html',1,'']]], + ['mtilemap_5flayer_19',['MTILEMAP_LAYER',['../structMTILEMAP__LAYER.html',1,'']]], + ['mtilemap_5fparser_20',['MTILEMAP_PARSER',['../structMTILEMAP__PARSER.html',1,'']]], + ['mtilemap_5ftile_5fdef_21',['MTILEMAP_TILE_DEF',['../structMTILEMAP__TILE__DEF.html',1,'']]] +]; diff --git a/search/all_8.js b/search/all_8.js new file mode 100644 index 00000000..bd49c30e --- /dev/null +++ b/search/all_8.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['nds_5foam_5factive_0',['NDS_OAM_ACTIVE',['../group__maug__retroflt__compiling.html#gab8293dce63e63b1b696862f1aa194c55',1,'retroflt.h']]], + ['nds_5fsprites_5factive_1',['NDS_SPRITES_ACTIVE',['../group__maug__retroflt__compiling.html#ga45f0101388c5e8d42c5929cb08eda7a6',1,'retroflt.h']]] +]; diff --git a/search/all_9.js b/search/all_9.js new file mode 100644 index 00000000..72961e4c --- /dev/null +++ b/search/all_9.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['palette_0',['palette',['../structRETROFLAT__STATE.html#aa9147fb4bf03e4d17dbb6c4157211862',1,'RETROFLAT_STATE']]] +]; diff --git a/search/all_a.js b/search/all_a.js new file mode 100644 index 00000000..62a6c377 --- /dev/null +++ b/search/all_a.js @@ -0,0 +1,114 @@ +var searchData= +[ + ['retrocon_0',['RETROCON',['../structRETROCON.html',1,'']]], + ['retroflat_20api_1',['RetroFlat API',['../group__maug__retroflt.html',1,'']]], + ['retroflat_20api_20return_20values_2',['RetroFlat API Return Values',['../group__maug__retroflt__retval.html',1,'']]], + ['retroflat_20bitmap_20api_3',['RetroFlat Bitmap API',['../group__maug__retroflt__bitmap.html',1,'']]], + ['retroflat_20colors_4',['RetroFlat Colors',['../group__maug__retroflt__color.html',1,'']]], + ['retroflat_20compilation_5',['RetroFlat Compilation',['../group__maug__retroflt__compiling.html',1,'']]], + ['retroflat_20compiler_20definitions_6',['RetroFlat Compiler Definitions',['../group__maug__retroflt__compiling.html',1,'']]], + ['retroflat_20config_20api_7',['RetroFlat Config API',['../group__maug__retroflt__config.html',1,'']]], + ['retroflat_20config_20buffer_20types_8',['RetroFlat Config Buffer Types',['../group__maug__retroflt__config__btypes.html',1,'']]], + ['retroflat_20config_20flags_9',['RetroFlat Config Flags',['../group__maug__retroflt__config__flags.html',1,'']]], + ['retroflat_20drawing_20api_10',['RetroFlat Drawing API',['../group__maug__retroflt__drawing.html',1,'']]], + ['retroflat_20example_11',['RetroFlat Example',['../group__maug__retroflt__example.html',1,'']]], + ['retroflat_20input_20api_12',['RetroFlat Input API',['../group__maug__retroflt__input.html',1,'']]], + ['retroflat_20key_20definitions_13',['RetroFlat Key Definitions',['../group__maug__retroflt__keydefs.html',1,'']]], + ['retroflat_20message_20api_14',['RetroFlat Message API',['../group__maug__retroflt__msg__api.html',1,'']]], + ['retroflat_20project_20makefiles_15',['RetroFlat Project Makefiles',['../group__maug__retroflt__compiling.html',1,'']]], + ['retroflat_20vdp_20api_16',['RetroFlat VDP API',['../group__maug__retroflt__vdp.html',1,'']]], + ['retroflat_5fargs_17',['RETROFLAT_ARGS',['../structRETROFLAT__ARGS.html',1,'']]], + ['retroflat_5fassets_5fpath_5fmax_18',['RETROFLAT_ASSETS_PATH_MAX',['../group__maug__retroflt__compiling.html#ga96145c651f78202c11af0d0a46e7e0d3',1,'retroflt.h']]], + ['retroflat_5fbitmap_19',['RETROFLAT_BITMAP',['../structRETROFLAT__BITMAP.html',1,'']]], + ['retroflat_5fbitmap_5fext_20',['RETROFLAT_BITMAP_EXT',['../group__maug__retroflt__bitmap.html#ga01ab983271322476f577e166c9e2ef23',1,'retroflt.h']]], + ['retroflat_5fbitmap_5fok_21',['retroflat_bitmap_ok',['../group__maug__retroflt__bitmap.html#gac186ac5bd220b956357a037e981d2afc',1,'retroflt.h']]], + ['retroflat_5fblit_5fbitmap_22',['retroflat_blit_bitmap',['../group__maug__retroflt__bitmap.html#ga18048b592b7df467cf50f38a11934846',1,'retroflt.h']]], + ['retroflat_5fbuffer_5fbksp_23',['retroflat_buffer_bksp',['../group__maug__retroflt__input.html#ga846438a73de18eec54ef2e7f8a69f771',1,'retroflt.h']]], + ['retroflat_5fbuffer_5finsert_24',['retroflat_buffer_insert',['../group__maug__retroflt__input.html#ga5a2fcfef94c1074d7402a0862d836e08',1,'retroflt.h']]], + ['retroflat_5fconfig_25',['RETROFLAT_CONFIG',['../group__maug__retroflt__config.html#ga2179341f1318f7d4680a2961cc09c6e6',1,'retroflt.h']]], + ['retroflat_5fconfig_5fflag_5fbin_26',['RETROFLAT_CONFIG_FLAG_BIN',['../group__maug__retroflt__config__flags.html#ga7825e9eb9da2e5685a98ec69af315db5',1,'retroflt.h']]], + ['retroflat_5fconfig_5fflag_5fw_27',['RETROFLAT_CONFIG_FLAG_W',['../group__maug__retroflt__config__flags.html#ga221dffff15d1359c5d0e9ef42162af9e',1,'retroflt.h']]], + ['retroflat_5fconfig_5fopen_28',['retroflat_config_open',['../group__maug__retroflt__config.html#gafe8b210ba090d19b772837e479ddc1de',1,'retroflt.h']]], + ['retroflat_5fconfig_5fread_29',['retroflat_config_read',['../group__maug__retroflt__config.html#gada2b16f53ba3a18018513710526b064d',1,'retroflt.h']]], + ['retroflat_5fconfig_5fwrite_30',['retroflat_config_write',['../group__maug__retroflt__config.html#gac3a7b80f3b166d02c3d8791ca0bdec32',1,'retroflt.h']]], + ['retroflat_5fdestroy_5fbitmap_31',['retroflat_destroy_bitmap',['../group__maug__retroflt__bitmap.html#gaa52e04cfe54ba6ea1985c8dfc2dccbbe',1,'retroflt.h']]], + ['retroflat_5fdraw_5flock_32',['retroflat_draw_lock',['../group__maug__retroflt__drawing.html#ga78766b119670a0ceb6fd84ec6c4cb52d',1,'retroflt.h']]], + ['retroflat_5fellipse_33',['retroflat_ellipse',['../group__maug__retroflt__drawing.html#ga5758dd9dc0e4cf408d8e957ab909f463',1,'retroflt.h']]], + ['retroflat_5ferror_5fbitmap_34',['RETROFLAT_ERROR_BITMAP',['../group__maug__retroflt__retval.html#gaa1bde95ee44dcf6883dc70b9e8e52088',1,'retroflt.h']]], + ['retroflat_5fflags_35',['retroflat_flags',['../structRETROFLAT__STATE.html#a3bd7778cbc80a7807ce47767d0d52289',1,'RETROFLAT_STATE']]], + ['retroflat_5fflags_5ffill_36',['RETROFLAT_FLAGS_FILL',['../group__maug__retroflt__drawing.html#gad545331d61095df978213f1285ec1d64',1,'retroflt.h']]], + ['retroflat_5fflags_5fkey_5frepeat_37',['RETROFLAT_FLAGS_KEY_REPEAT',['../group__maug__retroflt__flags.html#gafc12f18f1e586526fe6608fb3e292ef8',1,'retroflt.h']]], + ['retroflat_5fflags_5fopaque_38',['RETROFLAT_FLAGS_OPAQUE',['../group__maug__retroflt__drawing.html#ga35e38063df298bfa2552f58b580b027f',1,'retroflt.h']]], + ['retroflat_5fflags_5frunning_39',['RETROFLAT_FLAGS_RUNNING',['../group__maug__retroflt__flags.html#gad0ea2a78b6a6fda15cfe101005e5ff2e',1,'retroflt.h']]], + ['retroflat_5fflags_5fscreen_5fbuffer_40',['RETROFLAT_FLAGS_SCREEN_BUFFER',['../group__maug__retroflt__drawing.html#gadef5b619c4f3c9a99c665e74cb86f43b',1,'retroflt.h']]], + ['retroflat_5fflags_5fscreensaver_41',['RETROFLAT_FLAGS_SCREENSAVER',['../group__maug__retroflt__flags.html#ga0317bb9f6c90b276f909678caef9aeeb',1,'retroflt.h']]], + ['retroflat_5fflags_5funlock_5ffps_42',['RETROFLAT_FLAGS_UNLOCK_FPS',['../group__maug__retroflt__flags.html#ga3de3558eb684a4168f6bb313d1b05375',1,'retroflt.h']]], + ['retroflat_5ffps_43',['RETROFLAT_FPS',['../group__maug__retroflt__compiling.html#ga8b2233a41d03a2444621a8b8788c6c16',1,'retroflt.h']]], + ['retroflat_5finit_44',['retroflat_init',['../group__maug__retroflt.html#gac5511e72055cff916e5f494f8d6fd5f5',1,'retroflt.h']]], + ['retroflat_5finput_45',['RETROFLAT_INPUT',['../structRETROFLAT__INPUT.html',1,'']]], + ['retroflat_5fline_46',['retroflat_line',['../group__maug__retroflt__drawing.html#ga94215d4b78f83ef27b2a23a20d5e4c1b',1,'retroflt.h']]], + ['retroflat_5fline_5fthickness_47',['RETROFLAT_LINE_THICKNESS',['../group__maug__retroflt__drawing.html#ga109f1a69c0cd8f4ce8f5ba5cca10b80d',1,'retroflt.h']]], + ['retroflat_5fload_5fbitmap_48',['retroflat_load_bitmap',['../group__maug__retroflt__bitmap.html#ga219fc3c808677d7a2c6d8f1cdffcb018',1,'retroflt.h']]], + ['retroflat_5fload_5fxpm_49',['retroflat_load_xpm',['../group__maug__retroflt__bitmap.html#ga832f81c679afe41afbaa2dfbef54ccac',1,'retroflt.h']]], + ['retroflat_5floop_50',['retroflat_loop',['../group__maug__retroflt.html#gaa75816b7e11fe21cc98d9181773f4091',1,'retroflt.h']]], + ['retroflat_5floop_5fiter_51',['retroflat_loop_iter',['../group__maug__retroflt.html#ga7f16b39955b5f77e5535e2198e9e0faa',1,'retroflt.h']]], + ['retroflat_5fmessage_52',['retroflat_message',['../group__maug__retroflt.html#gab2d5a69aa8e2f401b8d38b62dc11c674',1,'retroflt.h']]], + ['retroflat_5fmsg_5fmax_53',['RETROFLAT_MSG_MAX',['../group__maug__retroflt__compiling.html#ga772947dbdd87d20dff6043e6d4007dea',1,'retroflt.h']]], + ['retroflat_5fok_54',['RETROFLAT_OK',['../group__maug__retroflt__retval.html#ga55abadeca55977b642ab9010e4e6fc76',1,'retroflt.h']]], + ['retroflat_5fpath_5fmax_55',['RETROFLAT_PATH_MAX',['../group__maug__retroflt__compiling.html#gad072a3180e7d50481e2f39babb9077b4',1,'retroflt.h']]], + ['retroflat_5fpath_5fsep_56',['RETROFLAT_PATH_SEP',['../group__maug__retroflt__compiling.html#gafc62d3bd105fa19582ade03d97dc606a',1,'retroflt.h']]], + ['retroflat_5fpoll_5finput_57',['retroflat_poll_input',['../group__maug__retroflt__input.html#gaa161b1370181194684dd3ce17fddda8f',1,'retroflt.h']]], + ['retroflat_5fquit_58',['retroflat_quit',['../group__maug__retroflt.html#ga4e588e9b7626bb8ae7e3ce50e6f6ff94',1,'retroflt.h']]], + ['retroflat_5frect_59',['retroflat_rect',['../group__maug__retroflt__drawing.html#gac90f837c23e5c86ad4e95194e93abf3b',1,'retroflt.h']]], + ['retroflat_5fscreen_5fbuffer_60',['retroflat_screen_buffer',['../group__maug__retroflt.html#ga5b8ae4b55653cffa196778a9e467ff71',1,'retroflt.h']]], + ['retroflat_5fscreen_5fh_61',['retroflat_screen_h',['../group__maug__retroflt.html#ga2570fa6b56eb033b40e51f9dd7c522cc',1,'retroflt.h']]], + ['retroflat_5fscreen_5fw_62',['retroflat_screen_w',['../group__maug__retroflt.html#gabc0ba97788cdb8fd3d1a651776fad028',1,'retroflt.h']]], + ['retroflat_5fshutdown_63',['retroflat_shutdown',['../group__maug__retroflt.html#ga1f9b2b82622f45623739891838904c24',1,'retroflt.h']]], + ['retroflat_5fstate_64',['RETROFLAT_STATE',['../structRETROFLAT__STATE.html',1,'']]], + ['retroflat_5fstring_65',['retroflat_string',['../group__maug__retroflt__drawing.html#ga505c2e292a90dbe628955cfc52387ba4',1,'retroflt.h']]], + ['retroflat_5fstring_5fsz_66',['retroflat_string_sz',['../group__maug__retroflt__drawing.html#ga7edf53d278ef709ca5d3ec3e054070e8',1,'retroflt.h']]], + ['retroflat_5ftxp_5fb_67',['RETROFLAT_TXP_B',['../group__maug__retroflt__bitmap.html#gab5d43506739bd0b166fc32358d39e359',1,'retroflt.h']]], + ['retroflat_5ftxp_5fg_68',['RETROFLAT_TXP_G',['../group__maug__retroflt__bitmap.html#ga0a14b581204c9b3f6a06bcba588d6727',1,'retroflt.h']]], + ['retroflat_5ftxp_5fr_69',['RETROFLAT_TXP_R',['../group__maug__retroflt__bitmap.html#gaeb61b7d84a676502e1758bffc92b8a9e',1,'retroflt.h']]], + ['retroflat_5fvdp_5fargs_5fsz_5fmax_70',['RETROFLAT_VDP_ARGS_SZ_MAX',['../group__maug__retroflt__compiling.html#ga6930d8c4d64485eefcdf16130d1302b9',1,'retroflt.h']]], + ['retroflat_5fvdp_5fflag_5fpxlock_71',['RETROFLAT_VDP_FLAG_PXLOCK',['../group__maug__retroflt__vdp.html#gaf6ed7032fdee9a785610b6c0419d75da',1,'retroflt.h']]], + ['retroflat_5fvdp_5fproc_5ft_72',['retroflat_vdp_proc_t',['../group__maug__retroflt__vdp.html#gac542ec7b64f30a2d19bdbbbc7ef0aaa3',1,'retroflt.h']]], + ['retroflat_5fwin_5fgfx_5ftimer_5fid_73',['RETROFLAT_WIN_GFX_TIMER_ID',['../group__maug__retroflt__compiling.html#ga254acbe8890129104aabbebe8d8cbbdc',1,'retroflt.h']]], + ['retroflat_5fwindow_5fclass_74',['RETROFLAT_WINDOW_CLASS',['../group__maug__retroflt__compiling.html#ga784d1bd93d86f7dde45c07aa3067584c',1,'retroflt.h']]], + ['retroflt_2eh_75',['retroflt.h',['../retroflt_8h.html',1,'']]], + ['retrofp_2eh_76',['retrofp.h',['../retrofp_8h.html',1,'']]], + ['retrofp_5flut_77',['retrofp_lut',['../group__maug__retrofp.html#ga122fe477c1cead708158b81aae69aae8',1,'retrofp.h']]], + ['retrofp_5fpi_78',['RETROFP_PI',['../group__maug__retrofp.html#ga8c4600c661c79d7f31e5375ce606c51c',1,'retrofp.h']]], + ['retroglu_20api_79',['RetroGLU API',['../group__maug__retroglu.html',1,'']]], + ['retroglu_20obj_20parser_80',['RetroGLU OBJ Parser',['../group__maug__retroglu__obj__fsm.html',1,'']]], + ['retroglu_20obj_20parser_20states_81',['RetroGLU OBJ Parser States',['../group__maug__retroglu__obj__fsm__states.html',1,'']]], + ['retroglu_20sprites_82',['RetroGLU Sprites',['../group__maug__retroglu__sprite.html',1,'']]], + ['retroglu_2eh_83',['retroglu.h',['../retroglu_8h.html',1,'']]], + ['retroglu_5fface_84',['RETROGLU_FACE',['../structRETROGLU__FACE.html',1,'']]], + ['retroglu_5fmaterial_85',['RETROGLU_MATERIAL',['../structRETROGLU__MATERIAL.html',1,'']]], + ['retroglu_5fmtl_5fcb_86',['retroglu_mtl_cb',['../group__maug__retroglu__obj__fsm.html#gac3fbadc0d5212c1d69830e5a387875cd',1,'retroglu.h']]], + ['retroglu_5fobj_87',['RETROGLU_OBJ',['../structRETROGLU__OBJ.html',1,'']]], + ['retroglu_5fobj_5ftokens_88',['RETROGLU_OBJ_TOKENS',['../group__maug__retroglu__obj__fsm.html#gae2b6f15fcc47afe2ee485f1d95911a6c',1,'retroglu.h']]], + ['retroglu_5fparse_5finit_89',['retroglu_parse_init',['../group__maug__retroglu__obj__fsm.html#ga1eea89882f6c548411ddbbfa11187d27',1,'RETROGLU_PARSER']]], + ['retroglu_5fparse_5fobj_5fc_90',['retroglu_parse_obj_c',['../group__maug__retroglu__obj__fsm.html#ga5198ebd5a2c5c8210f6feee3db63cb06',1,'RETROGLU_PARSER']]], + ['retroglu_5fparser_91',['RETROGLU_PARSER',['../structRETROGLU__PARSER.html',1,'']]], + ['retroglu_5fparser_5fstate_92',['retroglu_parser_state',['../group__maug__retroglu__obj__fsm.html#ga3f52a16418ba7581219ca6adf9680794',1,'retroglu.h']]], + ['retroglu_5fproj_5fargs_93',['RETROGLU_PROJ_ARGS',['../structRETROGLU__PROJ__ARGS.html',1,'']]], + ['retroglu_5fsprite_94',['RETROGLU_SPRITE',['../structRETROGLU__SPRITE.html',1,'']]], + ['retroglu_5ftile_95',['RETROGLU_TILE',['../structRETROGLU__TILE.html',1,'']]], + ['retroglu_5fvertex_96',['RETROGLU_VERTEX',['../structRETROGLU__VERTEX.html',1,'']]], + ['retroglu_5fvtexture_97',['RETROGLU_VTEXTURE',['../structRETROGLU__VTEXTURE.html',1,'']]], + ['retrogui_98',['RETROGUI',['../structRETROGUI.html',1,'']]], + ['retrogui_20api_99',['RetroGUI API',['../group__maug__retrogui.html',1,'']]], + ['retrogui_20controls_100',['RetroGUI Controls',['../group__maug__retrogui__ctl.html',1,'']]], + ['retrogui_2eh_101',['retrogui.h',['../retrogui_8h.html',1,'']]], + ['retrogui_5fctl_102',['RETROGUI_CTL',['../unionRETROGUI__CTL.html',1,'']]], + ['retrogui_5fctl_5fbase_103',['RETROGUI_CTL_BASE',['../structRETROGUI__CTL__BASE.html',1,'']]], + ['retrogui_5fctl_5ftable_104',['RETROGUI_CTL_TABLE',['../group__maug__retrogui__ctl.html#ga951c36a0e2f67d88cf7d0d1bd1a94b19',1,'retrogui.h']]], + ['retrogui_5fctl_5ftable_5ffields_105',['RETROGUI_CTL_TABLE_FIELDS',['../group__maug__retrogui__ctl.html#ga35333592fffe3d008ddf81628f6cb99e',1,'retrogui.h']]], + ['retrogui_5fctl_5ftable_5ftypes_106',['RETROGUI_CTL_TABLE_TYPES',['../group__maug__retrogui__ctl.html#gac65a09732f82d950d2366b7d3878f570',1,'retrogui.h']]], + ['retrogui_5fflags_5fdirty_107',['RETROGUI_FLAGS_DIRTY',['../group__maug__retrogui.html#ga15a4e92c3002b66ab24f29f5c6fc00ab',1,'retrogui.h']]], + ['retrogui_5fidc_108',['RETROGUI_IDC',['../group__maug__retrogui.html#ga824281a18362aabc8d033ddb9f9f9466',1,'retrogui.h']]], + ['retrogui_5fpoll_5fctls_109',['retrogui_poll_ctls',['../group__maug__retrogui.html#ga872afcc0cb497867318111d25100e98a',1,'retrogui.h']]], + ['return_20values_110',['Return Values',['../group__maug__error__retvals.html',1,'']]] +]; diff --git a/search/all_b.js b/search/all_b.js new file mode 100644 index 00000000..fbbe0d43 --- /dev/null +++ b/search/all_b.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['screen_5fh_0',['screen_h',['../structRETROFLAT__ARGS.html#a7407aaec24ac0b212ce12d92858ccc59',1,'RETROFLAT_ARGS']]], + ['screen_5fw_1',['screen_w',['../structRETROFLAT__ARGS.html#a42d9ce1abcd8638d1c4baf0a8b521bce',1,'RETROFLAT_ARGS']]], + ['sz_2',['sz',['../structRETROFLAT__BITMAP.html#a2b124a9c36380fc83e4767fe7c101427',1,'RETROFLAT_BITMAP']]] +]; diff --git a/search/all_c.js b/search/all_c.js new file mode 100644 index 00000000..20e0b0a3 --- /dev/null +++ b/search/all_c.js @@ -0,0 +1,10 @@ +var searchData= +[ + ['tilemap_20api_0',['Tilemap API',['../group__maug__tilemap.html',1,'']]], + ['tilemap_20custom_20property_20types_1',['Tilemap Custom Property Types',['../group__maug__tilemap__defs__types.html',1,'']]], + ['tilemap_20parser_2',['Tilemap Parser',['../group__maug__tilemap__parser.html',1,'']]], + ['tilemap_20tile_20definitions_3',['Tilemap Tile Definitions',['../group__maug__tilemap__defs.html',1,'']]], + ['title_4',['title',['../structRETROFLAT__ARGS.html#acb6002e986f780884beb1cf4b2cb5fae',1,'RETROFLAT_ARGS']]], + ['todo_20list_5',['Todo List',['../todo.html',1,'']]], + ['type_6',['type',['../structMTILEMAP__CPROP.html#a1f34313b0c8778a26866e90c1d1dc9e6',1,'MTILEMAP_CPROP']]] +]; diff --git a/search/all_d.js b/search/all_d.js new file mode 100644 index 00000000..bfdf0fd6 --- /dev/null +++ b/search/all_d.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['uprintf_2eh_0',['uprintf.h',['../uprintf_8h.html',1,'']]] +]; diff --git a/search/all_e.js b/search/all_e.js new file mode 100644 index 00000000..46fe4799 --- /dev/null +++ b/search/all_e.js @@ -0,0 +1,9 @@ +var searchData= +[ + ['vdp_5fargs_0',['vdp_args',['../structRETROFLAT__STATE.html#a108b28801a42fcdb599c2ea988e49bae',1,'RETROFLAT_STATE']]], + ['vdp_5fbuffer_1',['vdp_buffer',['../structRETROFLAT__STATE.html#a51ad861621dc8943ce8ac367aa867425',1,'RETROFLAT_STATE']]], + ['vdp_5fdata_2',['vdp_data',['../structRETROFLAT__STATE.html#ab5ac6383fb2ff36b7de0fc022b5d28f6',1,'RETROFLAT_STATE']]], + ['vdp_5fexe_3',['vdp_exe',['../structRETROFLAT__STATE.html#a9e6a7cd482da7e462e6ba8cb284ef748',1,'RETROFLAT_STATE']]], + ['vdp_5fflags_4',['vdp_flags',['../structRETROFLAT__STATE.html#a1e51cc69dac620c280420a0b0cfc339d',1,'RETROFLAT_STATE']]], + ['vertex_5fidxs_5',['vertex_idxs',['../structRETROGLU__FACE.html#a54f3000f977482234642639a252bd574',1,'RETROGLU_FACE']]] +]; diff --git a/search/classes_0.js b/search/classes_0.js new file mode 100644 index 00000000..e7725960 --- /dev/null +++ b/search/classes_0.js @@ -0,0 +1,10 @@ +var searchData= +[ + ['maug_5ffmt_5fspec_0',['MAUG_FMT_SPEC',['../unionMAUG__FMT__SPEC.html',1,'']]], + ['mtilemap_1',['MTILEMAP',['../structMTILEMAP.html',1,'']]], + ['mtilemap_5fcprop_2',['MTILEMAP_CPROP',['../structMTILEMAP__CPROP.html',1,'']]], + ['mtilemap_5fcprop_5fval_3',['MTILEMAP_CPROP_VAL',['../unionMTILEMAP__CPROP__VAL.html',1,'']]], + ['mtilemap_5flayer_4',['MTILEMAP_LAYER',['../structMTILEMAP__LAYER.html',1,'']]], + ['mtilemap_5fparser_5',['MTILEMAP_PARSER',['../structMTILEMAP__PARSER.html',1,'']]], + ['mtilemap_5ftile_5fdef_6',['MTILEMAP_TILE_DEF',['../structMTILEMAP__TILE__DEF.html',1,'']]] +]; diff --git a/search/classes_1.js b/search/classes_1.js new file mode 100644 index 00000000..213dcac4 --- /dev/null +++ b/search/classes_1.js @@ -0,0 +1,20 @@ +var searchData= +[ + ['retrocon_0',['RETROCON',['../structRETROCON.html',1,'']]], + ['retroflat_5fargs_1',['RETROFLAT_ARGS',['../structRETROFLAT__ARGS.html',1,'']]], + ['retroflat_5fbitmap_2',['RETROFLAT_BITMAP',['../structRETROFLAT__BITMAP.html',1,'']]], + ['retroflat_5finput_3',['RETROFLAT_INPUT',['../structRETROFLAT__INPUT.html',1,'']]], + ['retroflat_5fstate_4',['RETROFLAT_STATE',['../structRETROFLAT__STATE.html',1,'']]], + ['retroglu_5fface_5',['RETROGLU_FACE',['../structRETROGLU__FACE.html',1,'']]], + ['retroglu_5fmaterial_6',['RETROGLU_MATERIAL',['../structRETROGLU__MATERIAL.html',1,'']]], + ['retroglu_5fobj_7',['RETROGLU_OBJ',['../structRETROGLU__OBJ.html',1,'']]], + ['retroglu_5fparser_8',['RETROGLU_PARSER',['../structRETROGLU__PARSER.html',1,'']]], + ['retroglu_5fproj_5fargs_9',['RETROGLU_PROJ_ARGS',['../structRETROGLU__PROJ__ARGS.html',1,'']]], + ['retroglu_5fsprite_10',['RETROGLU_SPRITE',['../structRETROGLU__SPRITE.html',1,'']]], + ['retroglu_5ftile_11',['RETROGLU_TILE',['../structRETROGLU__TILE.html',1,'']]], + ['retroglu_5fvertex_12',['RETROGLU_VERTEX',['../structRETROGLU__VERTEX.html',1,'']]], + ['retroglu_5fvtexture_13',['RETROGLU_VTEXTURE',['../structRETROGLU__VTEXTURE.html',1,'']]], + ['retrogui_14',['RETROGUI',['../structRETROGUI.html',1,'']]], + ['retrogui_5fctl_15',['RETROGUI_CTL',['../unionRETROGUI__CTL.html',1,'']]], + ['retrogui_5fctl_5fbase_16',['RETROGUI_CTL_BASE',['../structRETROGUI__CTL__BASE.html',1,'']]] +]; diff --git a/search/close.svg b/search/close.svg new file mode 100644 index 00000000..337d6cc1 --- /dev/null +++ b/search/close.svg @@ -0,0 +1,18 @@ + + + + + + diff --git a/search/files_0.js b/search/files_0.js new file mode 100644 index 00000000..e1ca9411 --- /dev/null +++ b/search/files_0.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['merror_2eh_0',['merror.h',['../merror_8h.html',1,'']]], + ['mmem_2eh_1',['mmem.h',['../mmem_8h.html',1,'']]], + ['mtilemap_2eh_2',['mtilemap.h',['../mtilemap_8h.html',1,'']]] +]; diff --git a/search/files_1.js b/search/files_1.js new file mode 100644 index 00000000..a1c97531 --- /dev/null +++ b/search/files_1.js @@ -0,0 +1,7 @@ +var searchData= +[ + ['retroflt_2eh_0',['retroflt.h',['../retroflt_8h.html',1,'']]], + ['retrofp_2eh_1',['retrofp.h',['../retrofp_8h.html',1,'']]], + ['retroglu_2eh_2',['retroglu.h',['../retroglu_8h.html',1,'']]], + ['retrogui_2eh_3',['retrogui.h',['../retrogui_8h.html',1,'']]] +]; diff --git a/search/files_2.js b/search/files_2.js new file mode 100644 index 00000000..bfdf0fd6 --- /dev/null +++ b/search/files_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['uprintf_2eh_0',['uprintf.h',['../uprintf_8h.html',1,'']]] +]; diff --git a/search/functions_0.js b/search/functions_0.js new file mode 100644 index 00000000..951c91cf --- /dev/null +++ b/search/functions_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['maug_5fadd_5farg_0',['maug_add_arg',['../group__maug__cli.html#gaa01f6f484f91a815d5776e1b3e88a9db',1,'marge.h']]] +]; diff --git a/search/functions_1.js b/search/functions_1.js new file mode 100644 index 00000000..bb9e0839 --- /dev/null +++ b/search/functions_1.js @@ -0,0 +1,25 @@ +var searchData= +[ + ['retroflat_5fblit_5fbitmap_0',['retroflat_blit_bitmap',['../group__maug__retroflt__bitmap.html#ga18048b592b7df467cf50f38a11934846',1,'retroflt.h']]], + ['retroflat_5fconfig_5fopen_1',['retroflat_config_open',['../group__maug__retroflt__config.html#gafe8b210ba090d19b772837e479ddc1de',1,'retroflt.h']]], + ['retroflat_5fconfig_5fread_2',['retroflat_config_read',['../group__maug__retroflt__config.html#gada2b16f53ba3a18018513710526b064d',1,'retroflt.h']]], + ['retroflat_5fconfig_5fwrite_3',['retroflat_config_write',['../group__maug__retroflt__config.html#gac3a7b80f3b166d02c3d8791ca0bdec32',1,'retroflt.h']]], + ['retroflat_5fdestroy_5fbitmap_4',['retroflat_destroy_bitmap',['../group__maug__retroflt__bitmap.html#gaa52e04cfe54ba6ea1985c8dfc2dccbbe',1,'retroflt.h']]], + ['retroflat_5fdraw_5flock_5',['retroflat_draw_lock',['../group__maug__retroflt__drawing.html#ga78766b119670a0ceb6fd84ec6c4cb52d',1,'retroflt.h']]], + ['retroflat_5fellipse_6',['retroflat_ellipse',['../group__maug__retroflt__drawing.html#ga5758dd9dc0e4cf408d8e957ab909f463',1,'retroflt.h']]], + ['retroflat_5finit_7',['retroflat_init',['../group__maug__retroflt.html#gac5511e72055cff916e5f494f8d6fd5f5',1,'retroflt.h']]], + ['retroflat_5fline_8',['retroflat_line',['../group__maug__retroflt__drawing.html#ga94215d4b78f83ef27b2a23a20d5e4c1b',1,'retroflt.h']]], + ['retroflat_5fload_5fbitmap_9',['retroflat_load_bitmap',['../group__maug__retroflt__bitmap.html#ga219fc3c808677d7a2c6d8f1cdffcb018',1,'retroflt.h']]], + ['retroflat_5fload_5fxpm_10',['retroflat_load_xpm',['../group__maug__retroflt__bitmap.html#ga832f81c679afe41afbaa2dfbef54ccac',1,'retroflt.h']]], + ['retroflat_5floop_11',['retroflat_loop',['../group__maug__retroflt.html#gaa75816b7e11fe21cc98d9181773f4091',1,'retroflt.h']]], + ['retroflat_5fmessage_12',['retroflat_message',['../group__maug__retroflt.html#gab2d5a69aa8e2f401b8d38b62dc11c674',1,'retroflt.h']]], + ['retroflat_5fpoll_5finput_13',['retroflat_poll_input',['../group__maug__retroflt__input.html#gaa161b1370181194684dd3ce17fddda8f',1,'retroflt.h']]], + ['retroflat_5frect_14',['retroflat_rect',['../group__maug__retroflt__drawing.html#gac90f837c23e5c86ad4e95194e93abf3b',1,'retroflt.h']]], + ['retroflat_5fshutdown_15',['retroflat_shutdown',['../group__maug__retroflt.html#ga1f9b2b82622f45623739891838904c24',1,'retroflt.h']]], + ['retroflat_5fstring_16',['retroflat_string',['../group__maug__retroflt__drawing.html#ga505c2e292a90dbe628955cfc52387ba4',1,'retroflt.h']]], + ['retroflat_5fstring_5fsz_17',['retroflat_string_sz',['../group__maug__retroflt__drawing.html#ga7edf53d278ef709ca5d3ec3e054070e8',1,'retroflt.h']]], + ['retrofp_5flut_18',['retrofp_lut',['../group__maug__retrofp.html#ga122fe477c1cead708158b81aae69aae8',1,'retrofp.h']]], + ['retroglu_5fparse_5finit_19',['retroglu_parse_init',['../group__maug__retroglu__obj__fsm.html#ga1eea89882f6c548411ddbbfa11187d27',1,'RETROGLU_PARSER']]], + ['retroglu_5fparse_5fobj_5fc_20',['retroglu_parse_obj_c',['../group__maug__retroglu__obj__fsm.html#ga5198ebd5a2c5c8210f6feee3db63cb06',1,'RETROGLU_PARSER']]], + ['retrogui_5fpoll_5fctls_21',['retrogui_poll_ctls',['../group__maug__retrogui.html#ga872afcc0cb497867318111d25100e98a',1,'retrogui.h']]] +]; diff --git a/search/groups_0.js b/search/groups_0.js new file mode 100644 index 00000000..e57e7a84 --- /dev/null +++ b/search/groups_0.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['command_20line_20api_0',['Command Line API',['../group__maug__cli.html',1,'']]] +]; diff --git a/search/groups_1.js b/search/groups_1.js new file mode 100644 index 00000000..eaa9d92b --- /dev/null +++ b/search/groups_1.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['error_20handling_20api_0',['Error Handling API',['../group__maug__error.html',1,'']]] +]; diff --git a/search/groups_2.js b/search/groups_2.js new file mode 100644 index 00000000..491e281d --- /dev/null +++ b/search/groups_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['global_20flags_0',['Global Flags',['../group__maug__retroflt__flags.html',1,'']]] +]; diff --git a/search/groups_3.js b/search/groups_3.js new file mode 100644 index 00000000..f2b1fbe7 --- /dev/null +++ b/search/groups_3.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['in_2dsitu_20console_20api_0',['In-Situ Console API',['../group__maug__console.html',1,'']]] +]; diff --git a/search/groups_4.js b/search/groups_4.js new file mode 100644 index 00000000..a3da967f --- /dev/null +++ b/search/groups_4.js @@ -0,0 +1,6 @@ +var searchData= +[ + ['maug_20retro_20fixed_20point_0',['Maug Retro Fixed Point',['../group__maug__retrofp.html',1,'']]], + ['memory_20management_20api_1',['Memory Management API',['../group__maug__mem.html',1,'']]], + ['micro_2dprintf_20api_2',['Micro-PrintF API',['../group__maug__uprintf.html',1,'']]] +]; diff --git a/search/groups_5.js b/search/groups_5.js new file mode 100644 index 00000000..6f54bc69 --- /dev/null +++ b/search/groups_5.js @@ -0,0 +1,24 @@ +var searchData= +[ + ['retroflat_20api_0',['RetroFlat API',['../group__maug__retroflt.html',1,'']]], + ['retroflat_20api_20return_20values_1',['RetroFlat API Return Values',['../group__maug__retroflt__retval.html',1,'']]], + ['retroflat_20bitmap_20api_2',['RetroFlat Bitmap API',['../group__maug__retroflt__bitmap.html',1,'']]], + ['retroflat_20colors_3',['RetroFlat Colors',['../group__maug__retroflt__color.html',1,'']]], + ['retroflat_20compilation_4',['RetroFlat Compilation',['../group__maug__retroflt__compiling.html',1,'']]], + ['retroflat_20config_20api_5',['RetroFlat Config API',['../group__maug__retroflt__config.html',1,'']]], + ['retroflat_20config_20buffer_20types_6',['RetroFlat Config Buffer Types',['../group__maug__retroflt__config__btypes.html',1,'']]], + ['retroflat_20config_20flags_7',['RetroFlat Config Flags',['../group__maug__retroflt__config__flags.html',1,'']]], + ['retroflat_20drawing_20api_8',['RetroFlat Drawing API',['../group__maug__retroflt__drawing.html',1,'']]], + ['retroflat_20example_9',['RetroFlat Example',['../group__maug__retroflt__example.html',1,'']]], + ['retroflat_20input_20api_10',['RetroFlat Input API',['../group__maug__retroflt__input.html',1,'']]], + ['retroflat_20key_20definitions_11',['RetroFlat Key Definitions',['../group__maug__retroflt__keydefs.html',1,'']]], + ['retroflat_20message_20api_12',['RetroFlat Message API',['../group__maug__retroflt__msg__api.html',1,'']]], + ['retroflat_20vdp_20api_13',['RetroFlat VDP API',['../group__maug__retroflt__vdp.html',1,'']]], + ['retroglu_20api_14',['RetroGLU API',['../group__maug__retroglu.html',1,'']]], + ['retroglu_20obj_20parser_15',['RetroGLU OBJ Parser',['../group__maug__retroglu__obj__fsm.html',1,'']]], + ['retroglu_20obj_20parser_20states_16',['RetroGLU OBJ Parser States',['../group__maug__retroglu__obj__fsm__states.html',1,'']]], + ['retroglu_20sprites_17',['RetroGLU Sprites',['../group__maug__retroglu__sprite.html',1,'']]], + ['retrogui_20api_18',['RetroGUI API',['../group__maug__retrogui.html',1,'']]], + ['retrogui_20controls_19',['RetroGUI Controls',['../group__maug__retrogui__ctl.html',1,'']]], + ['return_20values_20',['Return Values',['../group__maug__error__retvals.html',1,'']]] +]; diff --git a/search/groups_6.js b/search/groups_6.js new file mode 100644 index 00000000..eba34181 --- /dev/null +++ b/search/groups_6.js @@ -0,0 +1,7 @@ +var searchData= +[ + ['tilemap_20api_0',['Tilemap API',['../group__maug__tilemap.html',1,'']]], + ['tilemap_20custom_20property_20types_1',['Tilemap Custom Property Types',['../group__maug__tilemap__defs__types.html',1,'']]], + ['tilemap_20parser_2',['Tilemap Parser',['../group__maug__tilemap__parser.html',1,'']]], + ['tilemap_20tile_20definitions_3',['Tilemap Tile Definitions',['../group__maug__tilemap__defs.html',1,'']]] +]; diff --git a/search/mag.svg b/search/mag.svg new file mode 100644 index 00000000..ffb6cf0d --- /dev/null +++ b/search/mag.svg @@ -0,0 +1,24 @@ + + + + + + + diff --git a/search/mag_d.svg b/search/mag_d.svg new file mode 100644 index 00000000..4122773f --- /dev/null +++ b/search/mag_d.svg @@ -0,0 +1,24 @@ + + + + + + + diff --git a/search/mag_sel.svg b/search/mag_sel.svg new file mode 100644 index 00000000..553dba87 --- /dev/null +++ b/search/mag_sel.svg @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/search/mag_seld.svg b/search/mag_seld.svg new file mode 100644 index 00000000..c906f84c --- /dev/null +++ b/search/mag_seld.svg @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/search/pages_0.js b/search/pages_0.js new file mode 100644 index 00000000..1bd6ba85 --- /dev/null +++ b/search/pages_0.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['maug_0',['maug',['../index.html',1,'']]], + ['maug_5fretroflt_5fexample_5fpage_1',['maug_retroflt_example_page',['../group__maug__retroflt__example.html',1,'']]] +]; diff --git a/search/pages_1.js b/search/pages_1.js new file mode 100644 index 00000000..6a2cf24d --- /dev/null +++ b/search/pages_1.js @@ -0,0 +1,5 @@ +var searchData= +[ + ['retroflat_20compiler_20definitions_0',['RetroFlat Compiler Definitions',['../group__maug__retroflt__compiling.html',1,'']]], + ['retroflat_20project_20makefiles_1',['RetroFlat Project Makefiles',['../group__maug__retroflt__compiling.html',1,'']]] +]; diff --git a/search/pages_2.js b/search/pages_2.js new file mode 100644 index 00000000..83220efb --- /dev/null +++ b/search/pages_2.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['todo_20list_0',['Todo List',['../todo.html',1,'']]] +]; diff --git a/search/search.css b/search/search.css new file mode 100644 index 00000000..19f76f9d --- /dev/null +++ b/search/search.css @@ -0,0 +1,291 @@ +/*---------------- Search Box positioning */ + +#main-menu > li:last-child { + /* This
  • object is the parent of the search bar */ + display: flex; + justify-content: center; + align-items: center; + height: 36px; + margin-right: 1em; +} + +/*---------------- Search box styling */ + +.SRPage * { + font-weight: normal; + line-height: normal; +} + +dark-mode-toggle { + margin-left: 5px; + display: flex; + float: right; +} + +#MSearchBox { + display: inline-block; + white-space : nowrap; + background: var(--search-background-color); + border-radius: 0.65em; + box-shadow: var(--search-box-shadow); + z-index: 102; +} + +#MSearchBox .left { + display: inline-block; + vertical-align: middle; + height: 1.4em; +} + +#MSearchSelect { + display: inline-block; + vertical-align: middle; + width: 20px; + height: 19px; + background-image: var(--search-magnification-select-image); + margin: 0 0 0 0.3em; + padding: 0; +} + +#MSearchSelectExt { + display: inline-block; + vertical-align: middle; + width: 10px; + height: 19px; + background-image: var(--search-magnification-image); + margin: 0 0 0 0.5em; + padding: 0; +} + + +#MSearchField { + display: inline-block; + vertical-align: middle; + width: 7.5em; + height: 19px; + margin: 0 0.15em; + padding: 0; + line-height: 1em; + border:none; + color: var(--search-foreground-color); + outline: none; + font-family: var(--font-family-search); + -webkit-border-radius: 0px; + border-radius: 0px; + background: none; +} + +@media(hover: none) { + /* to avoid zooming on iOS */ + #MSearchField { + font-size: 16px; + } +} + +#MSearchBox .right { + display: inline-block; + vertical-align: middle; + width: 1.4em; + height: 1.4em; +} + +#MSearchClose { + display: none; + font-size: inherit; + background : none; + border: none; + margin: 0; + padding: 0; + outline: none; + +} + +#MSearchCloseImg { + padding: 0.3em; + margin: 0; +} + +.MSearchBoxActive #MSearchField { + color: var(--search-active-color); +} + + + +/*---------------- Search filter selection */ + +#MSearchSelectWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid var(--search-filter-border-color); + background-color: var(--search-filter-background-color); + z-index: 10001; + padding-top: 4px; + padding-bottom: 4px; + -moz-border-radius: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +.SelectItem { + font: 8pt var(--font-family-search); + padding-left: 2px; + padding-right: 12px; + border: 0px; +} + +span.SelectionMark { + margin-right: 4px; + font-family: var(--font-family-monospace); + outline-style: none; + text-decoration: none; +} + +a.SelectItem { + display: block; + outline-style: none; + color: var(--search-filter-foreground-color); + text-decoration: none; + padding-left: 6px; + padding-right: 12px; +} + +a.SelectItem:focus, +a.SelectItem:active { + color: var(--search-filter-foreground-color); + outline-style: none; + text-decoration: none; +} + +a.SelectItem:hover { + color: var(--search-filter-highlight-text-color); + background-color: var(--search-filter-highlight-bg-color); + outline-style: none; + text-decoration: none; + cursor: pointer; + display: block; +} + +/*---------------- Search results window */ + +iframe#MSearchResults { + /*width: 60ex;*/ + height: 15em; +} + +#MSearchResultsWindow { + display: none; + position: absolute; + left: 0; top: 0; + border: 1px solid var(--search-results-border-color); + background-color: var(--search-results-background-color); + z-index:10000; + width: 300px; + height: 400px; + overflow: auto; +} + +/* ----------------------------------- */ + + +#SRIndex { + clear:both; +} + +.SREntry { + font-size: 10pt; + padding-left: 1ex; +} + +.SRPage .SREntry { + font-size: 8pt; + padding: 1px 5px; +} + +div.SRPage { + margin: 5px 2px; + background-color: var(--search-results-background-color); +} + +.SRChildren { + padding-left: 3ex; padding-bottom: .5em +} + +.SRPage .SRChildren { + display: none; +} + +.SRSymbol { + font-weight: bold; + color: var(--search-results-foreground-color); + font-family: var(--font-family-search); + text-decoration: none; + outline: none; +} + +a.SRScope { + display: block; + color: var(--search-results-foreground-color); + font-family: var(--font-family-search); + font-size: 8pt; + text-decoration: none; + outline: none; +} + +a.SRSymbol:focus, a.SRSymbol:active, +a.SRScope:focus, a.SRScope:active { + text-decoration: underline; +} + +span.SRScope { + padding-left: 4px; + font-family: var(--font-family-search); +} + +.SRPage .SRStatus { + padding: 2px 5px; + font-size: 8pt; + font-style: italic; + font-family: var(--font-family-search); +} + +.SRResult { + display: none; +} + +div.searchresults { + margin-left: 10px; + margin-right: 10px; +} + +/*---------------- External search page results */ + +.pages b { + color: white; + padding: 5px 5px 3px 5px; + background-image: var(--nav-gradient-active-image-parent); + background-repeat: repeat-x; + text-shadow: 0 1px 1px #000000; +} + +.pages { + line-height: 17px; + margin-left: 4px; + text-decoration: none; +} + +.hl { + font-weight: bold; +} + +#searchresults { + margin-bottom: 20px; +} + +.searchpages { + margin-top: 10px; +} + diff --git a/search/search.js b/search/search.js new file mode 100644 index 00000000..9b7a52a1 --- /dev/null +++ b/search/search.js @@ -0,0 +1,820 @@ +/* + @licstart The following is the entire license notice for the JavaScript code in this file. + + The MIT License (MIT) + + Copyright (C) 1997-2020 by Dimitri van Heesch + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file + */ +function convertToId(search) +{ + var result = ''; + for (i=0;i do a search + { + this.Search(); + } + } + + this.OnSearchSelectKey = function(evt) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==40 && this.searchIndex0) // Up + { + this.searchIndex--; + this.OnSelectItem(this.searchIndex); + } + else if (e.keyCode==13 || e.keyCode==27) + { + this.OnSelectItem(this.searchIndex); + this.CloseSelectionWindow(); + this.DOMSearchField().focus(); + } + return false; + } + + // --------- Actions + + // Closes the results window. + this.CloseResultsWindow = function() + { + this.DOMPopupSearchResultsWindow().style.display = 'none'; + this.DOMSearchClose().style.display = 'none'; + this.Activate(false); + } + + this.CloseSelectionWindow = function() + { + this.DOMSearchSelectWindow().style.display = 'none'; + } + + // Performs a search. + this.Search = function() + { + this.keyTimeout = 0; + + // strip leading whitespace + var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); + + var code = searchValue.toLowerCase().charCodeAt(0); + var idxChar = searchValue.substr(0, 1).toLowerCase(); + if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair + { + idxChar = searchValue.substr(0, 2); + } + + var jsFile; + + var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar); + if (idx!=-1) + { + var hexCode=idx.toString(16); + jsFile = this.resultsPath + indexSectionNames[this.searchIndex] + '_' + hexCode + '.js'; + } + + var loadJS = function(url, impl, loc){ + var scriptTag = document.createElement('script'); + scriptTag.src = url; + scriptTag.onload = impl; + scriptTag.onreadystatechange = impl; + loc.appendChild(scriptTag); + } + + var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); + var domSearchBox = this.DOMSearchBox(); + var domPopupSearchResults = this.DOMPopupSearchResults(); + var domSearchClose = this.DOMSearchClose(); + var resultsPath = this.resultsPath; + + var handleResults = function() { + document.getElementById("Loading").style.display="none"; + if (typeof searchData !== 'undefined') { + createResults(resultsPath); + document.getElementById("NoMatches").style.display="none"; + } + + if (idx!=-1) { + searchResults.Search(searchValue); + } else { // no file with search results => force empty search results + searchResults.Search('===='); + } + + if (domPopupSearchResultsWindow.style.display!='block') + { + domSearchClose.style.display = 'inline-block'; + var left = getXPos(domSearchBox) + 150; + var top = getYPos(domSearchBox) + 20; + domPopupSearchResultsWindow.style.display = 'block'; + left -= domPopupSearchResults.offsetWidth; + var maxWidth = document.body.clientWidth; + var maxHeight = document.body.clientHeight; + var width = 300; + if (left<10) left=10; + if (width+left+8>maxWidth) width=maxWidth-left-8; + var height = 400; + if (height+top+8>maxHeight) height=maxHeight-top-8; + domPopupSearchResultsWindow.style.top = top + 'px'; + domPopupSearchResultsWindow.style.left = left + 'px'; + domPopupSearchResultsWindow.style.width = width + 'px'; + domPopupSearchResultsWindow.style.height = height + 'px'; + } + } + + if (jsFile) { + loadJS(jsFile, handleResults, this.DOMPopupSearchResultsWindow()); + } else { + handleResults(); + } + + this.lastSearchValue = searchValue; + } + + // -------- Activation Functions + + // Activates or deactivates the search panel, resetting things to + // their default values if necessary. + this.Activate = function(isActive) + { + if (isActive || // open it + this.DOMPopupSearchResultsWindow().style.display == 'block' + ) + { + this.DOMSearchBox().className = 'MSearchBoxActive'; + this.searchActive = true; + } + else if (!isActive) // directly remove the panel + { + this.DOMSearchBox().className = 'MSearchBoxInactive'; + this.searchActive = false; + this.lastSearchValue = '' + this.lastResultsPage = ''; + this.DOMSearchField().value = ''; + } + } +} + +// ----------------------------------------------------------------------- + +// The class that handles everything on the search results page. +function SearchResults(name) +{ + // The number of matches from the last run of . + this.lastMatchCount = 0; + this.lastKey = 0; + this.repeatOn = false; + + // Toggles the visibility of the passed element ID. + this.FindChildElement = function(id) + { + var parentElement = document.getElementById(id); + var element = parentElement.firstChild; + + while (element && element!=parentElement) + { + if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren') + { + return element; + } + + if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes()) + { + element = element.firstChild; + } + else if (element.nextSibling) + { + element = element.nextSibling; + } + else + { + do + { + element = element.parentNode; + } + while (element && element!=parentElement && !element.nextSibling); + + if (element && element!=parentElement) + { + element = element.nextSibling; + } + } + } + } + + this.Toggle = function(id) + { + var element = this.FindChildElement(id); + if (element) + { + if (element.style.display == 'block') + { + element.style.display = 'none'; + } + else + { + element.style.display = 'block'; + } + } + } + + // Searches for the passed string. If there is no parameter, + // it takes it from the URL query. + // + // Always returns true, since other documents may try to call it + // and that may or may not be possible. + this.Search = function(search) + { + if (!search) // get search word from URL + { + search = window.location.search; + search = search.substring(1); // Remove the leading '?' + search = unescape(search); + } + + search = search.replace(/^ +/, ""); // strip leading spaces + search = search.replace(/ +$/, ""); // strip trailing spaces + search = search.toLowerCase(); + search = convertToId(search); + + var resultRows = document.getElementsByTagName("div"); + var matches = 0; + + var i = 0; + while (i < resultRows.length) + { + var row = resultRows.item(i); + if (row.className == "SRResult") + { + var rowMatchName = row.id.toLowerCase(); + rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' + + if (search.length<=rowMatchName.length && + rowMatchName.substr(0, search.length)==search) + { + row.style.display = 'block'; + matches++; + } + else + { + row.style.display = 'none'; + } + } + i++; + } + document.getElementById("Searching").style.display='none'; + if (matches == 0) // no results + { + document.getElementById("NoMatches").style.display='block'; + } + else // at least one result + { + document.getElementById("NoMatches").style.display='none'; + } + this.lastMatchCount = matches; + return true; + } + + // return the first item with index index or higher that is visible + this.NavNext = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index++; + } + return focusItem; + } + + this.NavPrev = function(index) + { + var focusItem; + while (1) + { + var focusName = 'Item'+index; + focusItem = document.getElementById(focusName); + if (focusItem && focusItem.parentNode.parentNode.style.display=='block') + { + break; + } + else if (!focusItem) // last element + { + break; + } + focusItem=null; + index--; + } + return focusItem; + } + + this.ProcessKeys = function(e) + { + if (e.type == "keydown") + { + this.repeatOn = false; + this.lastKey = e.keyCode; + } + else if (e.type == "keypress") + { + if (!this.repeatOn) + { + if (this.lastKey) this.repeatOn = true; + return false; // ignore first keypress after keydown + } + } + else if (e.type == "keyup") + { + this.lastKey = 0; + this.repeatOn = false; + } + return this.lastKey!=0; + } + + this.Nav = function(evt,itemIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + var newIndex = itemIndex-1; + var focusItem = this.NavPrev(newIndex); + if (focusItem) + { + var child = this.FindChildElement(focusItem.parentNode.parentNode.id); + if (child && child.style.display == 'block') // children visible + { + var n=0; + var tmpElem; + while (1) // search for last child + { + tmpElem = document.getElementById('Item'+newIndex+'_c'+n); + if (tmpElem) + { + focusItem = tmpElem; + } + else // found it! + { + break; + } + n++; + } + } + } + if (focusItem) + { + focusItem.focus(); + } + else // return focus to search field + { + document.getElementById("MSearchField").focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = itemIndex+1; + var focusItem; + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem && elem.style.display == 'block') // children visible + { + focusItem = document.getElementById('Item'+itemIndex+'_c0'); + } + if (!focusItem) focusItem = this.NavNext(newIndex); + if (focusItem) focusItem.focus(); + } + else if (this.lastKey==39) // Right + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'block'; + } + else if (this.lastKey==37) // Left + { + var item = document.getElementById('Item'+itemIndex); + var elem = this.FindChildElement(item.parentNode.parentNode.id); + if (elem) elem.style.display = 'none'; + } + else if (this.lastKey==27) // Escape + { + searchBox.CloseResultsWindow(); + document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } + + this.NavChild = function(evt,itemIndex,childIndex) + { + var e = (evt) ? evt : window.event; // for IE + if (e.keyCode==13) return true; + if (!this.ProcessKeys(e)) return false; + + if (this.lastKey==38) // Up + { + if (childIndex>0) + { + var newIndex = childIndex-1; + document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); + } + else // already at first child, jump to parent + { + document.getElementById('Item'+itemIndex).focus(); + } + } + else if (this.lastKey==40) // Down + { + var newIndex = childIndex+1; + var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); + if (!elem) // last child, jump to parent next parent + { + elem = this.NavNext(itemIndex+1); + } + if (elem) + { + elem.focus(); + } + } + else if (this.lastKey==27) // Escape + { + searchBox.CloseResultsWindow(); + document.getElementById("MSearchField").focus(); + } + else if (this.lastKey==13) // Enter + { + return true; + } + return false; + } +} + +function setKeyActions(elem,action) +{ + elem.setAttribute('onkeydown',action); + elem.setAttribute('onkeypress',action); + elem.setAttribute('onkeyup',action); +} + +function setClassAttr(elem,attr) +{ + elem.setAttribute('class',attr); + elem.setAttribute('className',attr); +} + +function createResults(resultsPath) +{ + var results = document.getElementById("SRResults"); + results.innerHTML = ''; + for (var e=0; e + + + + + + +maug: MTILEMAP Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP Struct Reference
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +char name [MTILEMAP_NAME_SZ_MAX]
     
    +MAUG_MHANDLE cprops
     
    +MAUG_MHANDLE tile_defs
     
    +MAUG_MHANDLE layers
     
    +size_t tile_defs_sz
     
    +size_t cprops_sz
     
    +size_t layers_sz
     
    +size_t tileset_fgid
     
    +uint8_t tiles_h
     
    +uint8_t tiles_w
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structMTILEMAP__CPROP.html b/structMTILEMAP__CPROP.html new file mode 100644 index 00000000..75c990a3 --- /dev/null +++ b/structMTILEMAP__CPROP.html @@ -0,0 +1,119 @@ + + + + + + + +maug: MTILEMAP_CPROP Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP_CPROP Struct Reference
    +
    +
    + +

    Custom property key-value storage type. + More...

    + +

    #include <mtilemap.h>

    +
    +Collaboration diagram for MTILEMAP_CPROP:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + + + + + + +

    +Data Fields

    +uint8_t type
     Tilemap Custom Property Types for MTILEMAP_CPROP::value.
     
    +char key [MTILEMAP_CPROP_STR_SZ_MAX]
     
    +union MTILEMAP_CPROP_VAL value
     
    +

    Detailed Description

    +

    Custom property key-value storage type.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structMTILEMAP__CPROP__coll__graph.map b/structMTILEMAP__CPROP__coll__graph.map new file mode 100644 index 00000000..9756eef6 --- /dev/null +++ b/structMTILEMAP__CPROP__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/structMTILEMAP__CPROP__coll__graph.md5 b/structMTILEMAP__CPROP__coll__graph.md5 new file mode 100644 index 00000000..5eccd47d --- /dev/null +++ b/structMTILEMAP__CPROP__coll__graph.md5 @@ -0,0 +1 @@ +6531e90e79f5505f5660749e79cabe23 \ No newline at end of file diff --git a/structMTILEMAP__CPROP__coll__graph.png b/structMTILEMAP__CPROP__coll__graph.png new file mode 100644 index 00000000..60441fdb Binary files /dev/null and b/structMTILEMAP__CPROP__coll__graph.png differ diff --git a/structMTILEMAP__LAYER.html b/structMTILEMAP__LAYER.html new file mode 100644 index 00000000..bebec8f6 --- /dev/null +++ b/structMTILEMAP__LAYER.html @@ -0,0 +1,101 @@ + + + + + + + +maug: MTILEMAP_LAYER Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP_LAYER Struct Reference
    +
    +
    + + + + + + + + +

    +Data Fields

    +MAUG_MHANDLE tiles
     
    +size_t tiles_sz
     
    +size_t tiles_sz_max
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structMTILEMAP__PARSER.html b/structMTILEMAP__PARSER.html new file mode 100644 index 00000000..e80aa298 --- /dev/null +++ b/structMTILEMAP__PARSER.html @@ -0,0 +1,132 @@ + + + + + + + +maug: MTILEMAP_PARSER Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP_PARSER Struct Reference
    +
    +
    +
    +Collaboration diagram for MTILEMAP_PARSER:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +uint8_t pstate [MPARSER_STACK_SZ_MAX]
     
    +size_t pstate_sz
     
    +uint8_t mstate
     
    +uint8_t mstate_prev
     
    +size_t i
     
    +char token [MTILEMAP_TOKEN_SZ_MAX]
     
    +size_t token_sz
     
    +size_t tileset_id_cur
     
    +struct MTILEMAPt
     
    +mtilemap_tj_parse_cb tj_parse_cb
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structMTILEMAP__PARSER__coll__graph.map b/structMTILEMAP__PARSER__coll__graph.map new file mode 100644 index 00000000..51d06358 --- /dev/null +++ b/structMTILEMAP__PARSER__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/structMTILEMAP__PARSER__coll__graph.md5 b/structMTILEMAP__PARSER__coll__graph.md5 new file mode 100644 index 00000000..05c06958 --- /dev/null +++ b/structMTILEMAP__PARSER__coll__graph.md5 @@ -0,0 +1 @@ +e19ae93ea1b10ec15389df9b01286b39 \ No newline at end of file diff --git a/structMTILEMAP__PARSER__coll__graph.png b/structMTILEMAP__PARSER__coll__graph.png new file mode 100644 index 00000000..d3d98c24 Binary files /dev/null and b/structMTILEMAP__PARSER__coll__graph.png differ diff --git a/structMTILEMAP__TILE__DEF.html b/structMTILEMAP__TILE__DEF.html new file mode 100644 index 00000000..2f3e2f2a --- /dev/null +++ b/structMTILEMAP__TILE__DEF.html @@ -0,0 +1,104 @@ + + + + + + + +maug: MTILEMAP_TILE_DEF Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP_TILE_DEF Struct Reference
    +
    +
    + + + + + + + + + + +

    +Data Fields

    +uint8_t flags
     
    +MAUG_MHANDLE cprops
     
    +size_t cprops_sz
     
    +char image_path [MTILEMAP_TILESET_IMAGE_STR_SZ_MAX]
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROCON.html b/structRETROCON.html new file mode 100644 index 00000000..99f793f3 --- /dev/null +++ b/structRETROCON.html @@ -0,0 +1,149 @@ + + + + + + + +maug: RETROCON Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROCON Struct Reference
    +
    +
    +
    +Collaboration diagram for RETROCON:
    +
    +
    Collaboration graph
    + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +uint8_t flags
     
    +int input_prev
     
    +int debounce_wait
     
    +char sbuffer [RETROCON_SBUFFER_SZ_MAX+1]
     
    +size_t sbuffer_sz
     
    +size_t sbuffer_lines [RETROCON_SBUFFER_LINES_MAX]
     
    +size_t sbuffer_lines_sz
     
    +char lbuffer [RETROCON_LBUFFER_SZ_MAX+1]
     
    +size_t lbuffer_sz
     
    +void * callback_data [RETROCON_CB_SZ_MAX]
     
    +char callback_names [RETROCON_CB_SZ_MAX][RETROCON_CB_NAME_SZ_MAX+1]
     
    +retrocon_cb callbacks [RETROCON_CB_SZ_MAX]
     
    +size_t callbacks_sz
     
    +RETROFLAT_COLOR lbuffer_color
     
    +RETROFLAT_COLOR sbuffer_color
     
    +RETROFLAT_COLOR bg_color
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROCON__coll__graph.map b/structRETROCON__coll__graph.map new file mode 100644 index 00000000..ed0f1013 --- /dev/null +++ b/structRETROCON__coll__graph.map @@ -0,0 +1,4 @@ + + + + diff --git a/structRETROCON__coll__graph.md5 b/structRETROCON__coll__graph.md5 new file mode 100644 index 00000000..79e399fd --- /dev/null +++ b/structRETROCON__coll__graph.md5 @@ -0,0 +1 @@ +88ee59c09e4b9f12ae076c2489fbce58 \ No newline at end of file diff --git a/structRETROCON__coll__graph.png b/structRETROCON__coll__graph.png new file mode 100644 index 00000000..edef7895 Binary files /dev/null and b/structRETROCON__coll__graph.png differ diff --git a/structRETROFLAT__ARGS.html b/structRETROFLAT__ARGS.html new file mode 100644 index 00000000..cd763de9 --- /dev/null +++ b/structRETROFLAT__ARGS.html @@ -0,0 +1,122 @@ + + + + + + + +maug: RETROFLAT_ARGS Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROFLAT_ARGS Struct Reference
    +
    +
    + +

    Struct containing configuration values for a RetroFlat program. + More...

    + +

    #include <retroflt.h>

    + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +char * title
     Title to set for the main program Window if applicable on the target platform.
     
    +int screen_w
     Desired screen or window width in pixels.
     
    +int screen_h
     Desired screen or window height in pixels.
     
    +char * assets_path
     Relative path under which bitmap assets are stored.
     
    +uint8_t flags
     
    +char * config_path
     Relative path of local config file (if not using registry).
     
    +

    Detailed Description

    +

    Struct containing configuration values for a RetroFlat program.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROFLAT__BITMAP.html b/structRETROFLAT__BITMAP.html new file mode 100644 index 00000000..23e71c80 --- /dev/null +++ b/structRETROFLAT__BITMAP.html @@ -0,0 +1,120 @@ + + + + + + + +maug: RETROFLAT_BITMAP Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROFLAT_BITMAP Struct Reference
    +
    +
    + +

    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine if a valid bitmap is loaded. + More...

    + +

    #include <retroflt.h>

    + + + + + + + + + + +

    +Data Fields

    +size_t sz
     Size of the bitmap structure, used to check VDP compatibility.
     
    +uint8_t flags
     Platform-specific bitmap flags.
     
    +struct RETROFLAT_GLTEX tex
     
    + + + + +

    +Related Symbols

    (Note that these are not member symbols.)

    +
    +#define RETROFLAT_FLAGS_LOCK   0x01
     
    +

    Detailed Description

    +

    Platform-specific bitmap structure. retroflat_bitmap_ok() can be used on a pointer to it to determine if a valid bitmap is loaded.

    +

    Please see the RetroFlat Bitmap API for more information.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROFLAT__INPUT.html b/structRETROFLAT__INPUT.html new file mode 100644 index 00000000..f067eaeb --- /dev/null +++ b/structRETROFLAT__INPUT.html @@ -0,0 +1,110 @@ + + + + + + + +maug: RETROFLAT_INPUT Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROFLAT_INPUT Struct Reference
    +
    +
    + +

    Struct passed to retroflat_poll_input() to hold return data. + More...

    + +

    #include <retroflt.h>

    + + + + + + + + + + +

    +Data Fields

    +int mouse_x
     X-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
     
    +int mouse_y
     Y-coordinate of the mouse pointer in pixels if the returned event is a mouse click.
     
    +uint8_t key_flags
     
    +

    Detailed Description

    +

    Struct passed to retroflat_poll_input() to hold return data.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROFLAT__STATE.html b/structRETROFLAT__STATE.html new file mode 100644 index 00000000..a977288d --- /dev/null +++ b/structRETROFLAT__STATE.html @@ -0,0 +1,165 @@ + + + + + + + +maug: RETROFLAT_STATE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROFLAT_STATE Struct Reference
    +
    +
    + +

    Global singleton containing state for the current platform. + More...

    + +

    #include <retroflt.h>

    +
    +Collaboration diagram for RETROFLAT_STATE:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +void * loop_data
     
    +MERROR_RETVAL retval
     
    +uint8_t retroflat_flags
     Global Flags indicating current system status.
     
    +char config_path [RETROFLAT_PATH_MAX+1]
     
    +char assets_path [RETROFLAT_ASSETS_PATH_MAX+1]
     
    +RETROFLAT_COLOR_DEF palette [RETROFLAT_COLORS_SZ]
     Index of available colors, initialized on platform init.
     
    +struct RETROFLAT_BITMAP buffer
     Off-screen buffer bitmap.
     
    +struct RETROFLAT_BITMAPvdp_buffer
     A buffer assembled and passed to the VDP for its use, or NULL if no VDP is loaded.
     
    +void * vdp_exe
     A handle for the loaded VDP module.
     
    +void * vdp_data
     Pointer to data defined by the VDP for its use.
     
    +char vdp_args [RETROFLAT_VDP_ARGS_SZ_MAX]
     CLI args passed with -vdp to the RetroFlat VDP API.
     
    +uint8_t vdp_flags
     Flags set by the RetroFlat VDP API.
     
    +int screen_v_w
     
    +int screen_v_h
     
    +int screen_w
     
    +int screen_h
     
    +

    Detailed Description

    +

    Global singleton containing state for the current platform.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROFLAT__STATE__coll__graph.map b/structRETROFLAT__STATE__coll__graph.map new file mode 100644 index 00000000..c5675c46 --- /dev/null +++ b/structRETROFLAT__STATE__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/structRETROFLAT__STATE__coll__graph.md5 b/structRETROFLAT__STATE__coll__graph.md5 new file mode 100644 index 00000000..23984b22 --- /dev/null +++ b/structRETROFLAT__STATE__coll__graph.md5 @@ -0,0 +1 @@ +94d15ea91c519057c462a5e05461f928 \ No newline at end of file diff --git a/structRETROFLAT__STATE__coll__graph.png b/structRETROFLAT__STATE__coll__graph.png new file mode 100644 index 00000000..1960c04f Binary files /dev/null and b/structRETROFLAT__STATE__coll__graph.png differ diff --git a/structRETROGLU__FACE.html b/structRETROGLU__FACE.html new file mode 100644 index 00000000..7f20625c --- /dev/null +++ b/structRETROGLU__FACE.html @@ -0,0 +1,125 @@ + + + + + + + +maug: RETROGLU_FACE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_FACE Struct Reference
    +
    +
    + + + + + + + + + + + + + +

    +Data Fields

    uint16_t vertex_idxs [RETROGLU_FACE_VERTICES_SZ_MAX]
     List of vertex indices from the associated RETROGLU_PARSER::vertices.
     
    +uint16_t vnormal_idxs [RETROGLU_FACE_VERTICES_SZ_MAX]
     
    +uint16_t vtexture_idxs [RETROGLU_FACE_VERTICES_SZ_MAX]
     
    +uint16_t vertex_idxs_sz
     
    +uint16_t material_idx
     
    +

    Field Documentation

    + +

    ◆ vertex_idxs

    + +
    +
    + + + + +
    uint16_t RETROGLU_FACE::vertex_idxs[RETROGLU_FACE_VERTICES_SZ_MAX]
    +
    + +

    List of vertex indices from the associated RETROGLU_PARSER::vertices.

    +

    The size of this array is fixed to simplify allocation of arrays.

    + +
    +
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__MATERIAL.html b/structRETROGLU__MATERIAL.html new file mode 100644 index 00000000..4a802af3 --- /dev/null +++ b/structRETROGLU__MATERIAL.html @@ -0,0 +1,110 @@ + + + + + + + +maug: RETROGLU_MATERIAL Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_MATERIAL Struct Reference
    +
    +
    + + + + + + + + + + + + + + +

    +Data Fields

    +float ambient [4]
     
    +float diffuse [4]
     
    +float specular [4]
     
    +float emissive [4]
     
    +float specular_exp
     
    +char name [RETROGLU_MATERIAL_NAME_SZ_MAX]
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__OBJ.html b/structRETROGLU__OBJ.html new file mode 100644 index 00000000..9e4057da --- /dev/null +++ b/structRETROGLU__OBJ.html @@ -0,0 +1,142 @@ + + + + + + + +maug: RETROGLU_OBJ Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_OBJ Struct Reference
    +
    +
    +
    +Collaboration diagram for RETROGLU_OBJ:
    +
    +
    Collaboration graph
    + + + + + + + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +uint8_t flags
     
    +struct RETROGLU_VERTEX vertices [RETROGLU_VERTICES_SZ_MAX]
     
    +uint16_t vertices_sz
     
    +struct RETROGLU_VERTEX vnormals [RETROGLU_VERTICES_SZ_MAX]
     
    +uint16_t vnormals_sz
     
    +struct RETROGLU_VTEXTURE vtextures [RETROGLU_VERTICES_SZ_MAX]
     
    +uint16_t vtextures_sz
     
    +struct RETROGLU_FACE faces [RETROGLU_FACES_SZ_MAX]
     List of faces from an OBJ file. Faces comprise a list of polygons denoted by index of the vertices in RETROGLU_PARSER::vertices.
     
    +uint16_t faces_sz
     
    +struct RETROGLU_MATERIAL materials [RETROGLU_MATERIALS_SZ_MAX]
     
    +uint16_t materials_sz
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__OBJ__coll__graph.map b/structRETROGLU__OBJ__coll__graph.map new file mode 100644 index 00000000..ecfec575 --- /dev/null +++ b/structRETROGLU__OBJ__coll__graph.map @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/structRETROGLU__OBJ__coll__graph.md5 b/structRETROGLU__OBJ__coll__graph.md5 new file mode 100644 index 00000000..63997848 --- /dev/null +++ b/structRETROGLU__OBJ__coll__graph.md5 @@ -0,0 +1 @@ +e53e4d10b6aa44d9e944a842ec4a8863 \ No newline at end of file diff --git a/structRETROGLU__OBJ__coll__graph.png b/structRETROGLU__OBJ__coll__graph.png new file mode 100644 index 00000000..a9b6d0f3 Binary files /dev/null and b/structRETROGLU__OBJ__coll__graph.png differ diff --git a/structRETROGLU__PARSER.html b/structRETROGLU__PARSER.html new file mode 100644 index 00000000..982834a1 --- /dev/null +++ b/structRETROGLU__PARSER.html @@ -0,0 +1,151 @@ + + + + + + + +maug: RETROGLU_PARSER Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_PARSER Struct Reference
    +
    +
    + +

    As retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information. + More...

    + +

    #include <retroglu.h>

    +
    +Collaboration diagram for RETROGLU_PARSER:
    +
    +
    Collaboration graph
    + + + + + + + + + + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + +

    +Data Fields

    +struct RETROGLU_OBJobj
     
    +int state
     
    +int material_idx
     
    +char token [RETROGLU_PARSER_TOKEN_SZ_MAX]
     
    +int token_sz
     
    +retroglu_mtl_cb load_mtl
     
    +void * load_mtl_data
     
    + + + + + + + + +

    +Related Symbols

    (Note that these are not member symbols.)

    +
    void retroglu_parse_init (struct RETROGLU_PARSER *parser, struct RETROGLU_OBJ *obj, retroglu_mtl_cb load_mtl, void *load_mtl_data)
     Initialize a RETROGLU_PARSER.
     
    MERROR_RETVAL retroglu_parse_obj_c (struct RETROGLU_PARSER *parser, unsigned char c)
     Parse OBJ data into a parser, one character at a time.
     
    +

    Detailed Description

    +

    As retroglu_parse_obj_c() parses OBJ data, it populates this struct with object information.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__PARSER__coll__graph.map b/structRETROGLU__PARSER__coll__graph.map new file mode 100644 index 00000000..cd9c142c --- /dev/null +++ b/structRETROGLU__PARSER__coll__graph.map @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/structRETROGLU__PARSER__coll__graph.md5 b/structRETROGLU__PARSER__coll__graph.md5 new file mode 100644 index 00000000..080d2186 --- /dev/null +++ b/structRETROGLU__PARSER__coll__graph.md5 @@ -0,0 +1 @@ +5dc3db168eedbeb67c324a825960aabe \ No newline at end of file diff --git a/structRETROGLU__PARSER__coll__graph.png b/structRETROGLU__PARSER__coll__graph.png new file mode 100644 index 00000000..e9608a2c Binary files /dev/null and b/structRETROGLU__PARSER__coll__graph.png differ diff --git a/structRETROGLU__PROJ__ARGS.html b/structRETROGLU__PROJ__ARGS.html new file mode 100644 index 00000000..f5ea30c0 --- /dev/null +++ b/structRETROGLU__PROJ__ARGS.html @@ -0,0 +1,104 @@ + + + + + + + +maug: RETROGLU_PROJ_ARGS Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_PROJ_ARGS Struct Reference
    +
    +
    + + + + + + + + + + +

    +Data Fields

    +uint8_t proj
     
    +float rzoom
     
    +float near_plane
     
    +float far_plane
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__SPRITE.html b/structRETROGLU__SPRITE.html new file mode 100644 index 00000000..5d649afb --- /dev/null +++ b/structRETROGLU__SPRITE.html @@ -0,0 +1,135 @@ + + + + + + + +maug: RETROGLU_SPRITE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_SPRITE Struct Reference
    +
    +
    +
    +Collaboration diagram for RETROGLU_SPRITE:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +float vertices_front [6][2]
     
    +float vtexture_front [6][2]
     
    +float vertices_back [6][2]
     
    +float vtexture_back [6][2]
     
    +float translate_x
     
    +float translate_y
     
    +float scale_x
     
    +float scale_y
     
    +int rotate_y
     
    +RETROGLU_COLOR color
     
    +struct RETROFLAT_BITMAP texture
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__SPRITE__coll__graph.map b/structRETROGLU__SPRITE__coll__graph.map new file mode 100644 index 00000000..1c8454e1 --- /dev/null +++ b/structRETROGLU__SPRITE__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/structRETROGLU__SPRITE__coll__graph.md5 b/structRETROGLU__SPRITE__coll__graph.md5 new file mode 100644 index 00000000..f043e17f --- /dev/null +++ b/structRETROGLU__SPRITE__coll__graph.md5 @@ -0,0 +1 @@ +25a58d4b9b8d09a2bdc0c60c7e8eb816 \ No newline at end of file diff --git a/structRETROGLU__SPRITE__coll__graph.png b/structRETROGLU__SPRITE__coll__graph.png new file mode 100644 index 00000000..44272f13 Binary files /dev/null and b/structRETROGLU__SPRITE__coll__graph.png differ diff --git a/structRETROGLU__TILE.html b/structRETROGLU__TILE.html new file mode 100644 index 00000000..1fc825a8 --- /dev/null +++ b/structRETROGLU__TILE.html @@ -0,0 +1,114 @@ + + + + + + + +maug: RETROGLU_TILE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_TILE Struct Reference
    +
    +
    +
    +Collaboration diagram for RETROGLU_TILE:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + + + + + + + +

    +Data Fields

    +float vertices [6][2]
     
    +float vtexture [6][2]
     
    +int rotate_x
     
    +struct RETROFLAT_BITMAP texture
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__TILE__coll__graph.map b/structRETROGLU__TILE__coll__graph.map new file mode 100644 index 00000000..30bd89bc --- /dev/null +++ b/structRETROGLU__TILE__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/structRETROGLU__TILE__coll__graph.md5 b/structRETROGLU__TILE__coll__graph.md5 new file mode 100644 index 00000000..4d8c2150 --- /dev/null +++ b/structRETROGLU__TILE__coll__graph.md5 @@ -0,0 +1 @@ +630b520669c2ba5dcd0928ebef874620 \ No newline at end of file diff --git a/structRETROGLU__TILE__coll__graph.png b/structRETROGLU__TILE__coll__graph.png new file mode 100644 index 00000000..a1fbb1af Binary files /dev/null and b/structRETROGLU__TILE__coll__graph.png differ diff --git a/structRETROGLU__VERTEX.html b/structRETROGLU__VERTEX.html new file mode 100644 index 00000000..aae020d2 --- /dev/null +++ b/structRETROGLU__VERTEX.html @@ -0,0 +1,101 @@ + + + + + + + +maug: RETROGLU_VERTEX Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_VERTEX Struct Reference
    +
    +
    + + + + + + + + +

    +Data Fields

    +float x
     
    +float y
     
    +float z
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGLU__VTEXTURE.html b/structRETROGLU__VTEXTURE.html new file mode 100644 index 00000000..62e75342 --- /dev/null +++ b/structRETROGLU__VTEXTURE.html @@ -0,0 +1,98 @@ + + + + + + + +maug: RETROGLU_VTEXTURE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGLU_VTEXTURE Struct Reference
    +
    +
    + + + + + + +

    +Data Fields

    +float u
     
    +float v
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGUI.html b/structRETROGUI.html new file mode 100644 index 00000000..4bc9fc54 --- /dev/null +++ b/structRETROGUI.html @@ -0,0 +1,136 @@ + + + + + + + +maug: RETROGUI Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGUI Struct Reference
    +
    +
    +
    +Collaboration diagram for RETROGUI:
    +
    +
    Collaboration graph
    + + + + + + + + + +
    [legend]
    + + + + + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +uint8_t flags
     
    +RETROGUI_IDC idc_prev
     
    +MAUG_MHANDLE ctls_h
     
    +union RETROGUI_CTLctls
     
    +size_t ctls_sz
     
    +size_t ctls_sz_max
     
    +RETROGUI_IDC focus
     
    +struct RETROFLAT_BITMAPdraw_bmp
     
    +retrogui_xy_cb draw_xy
     
    +void * draw_xy_data
     
    +
    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGUI__CTL__BASE.html b/structRETROGUI__CTL__BASE.html new file mode 100644 index 00000000..6b384432 --- /dev/null +++ b/structRETROGUI__CTL__BASE.html @@ -0,0 +1,123 @@ + + + + + + + +maug: RETROGUI_CTL_BASE Struct Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGUI_CTL_BASE Struct Reference
    +
    +
    + +

    Fields common to ALL RETROGUI_CTL types. + More...

    + +

    #include <retrogui.h>

    + + + + + + + + + + + + + + + + + + +

    +Data Fields

    +uint8_t type
     
    +RETROGUI_IDC idc
     
    +size_t x
     
    +size_t y
     
    +size_t w
     
    +size_t h
     
    +RETROFLAT_COLOR bg_color
     
    +RETROFLAT_COLOR fg_color
     
    +

    Detailed Description

    +

    Fields common to ALL RETROGUI_CTL types.

    +

    The documentation for this struct was generated from the following file: +
    + + + + diff --git a/structRETROGUI__coll__graph.map b/structRETROGUI__coll__graph.map new file mode 100644 index 00000000..7314373c --- /dev/null +++ b/structRETROGUI__coll__graph.map @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/structRETROGUI__coll__graph.md5 b/structRETROGUI__coll__graph.md5 new file mode 100644 index 00000000..a1ccc727 --- /dev/null +++ b/structRETROGUI__coll__graph.md5 @@ -0,0 +1 @@ +00fa4b4ce16e1266fe72e8f107ded324 \ No newline at end of file diff --git a/structRETROGUI__coll__graph.png b/structRETROGUI__coll__graph.png new file mode 100644 index 00000000..b4016685 Binary files /dev/null and b/structRETROGUI__coll__graph.png differ diff --git a/sync_off.png b/sync_off.png new file mode 100644 index 00000000..3b443fc6 Binary files /dev/null and b/sync_off.png differ diff --git a/sync_on.png b/sync_on.png new file mode 100644 index 00000000..e08320fb Binary files /dev/null and b/sync_on.png differ diff --git a/tab_a.png b/tab_a.png new file mode 100644 index 00000000..3b725c41 Binary files /dev/null and b/tab_a.png differ diff --git a/tab_ad.png b/tab_ad.png new file mode 100644 index 00000000..e34850ac Binary files /dev/null and b/tab_ad.png differ diff --git a/tab_b.png b/tab_b.png new file mode 100644 index 00000000..e2b4a863 Binary files /dev/null and b/tab_b.png differ diff --git a/tab_bd.png b/tab_bd.png new file mode 100644 index 00000000..91c25249 Binary files /dev/null and b/tab_bd.png differ diff --git a/tab_h.png b/tab_h.png new file mode 100644 index 00000000..fd5cb705 Binary files /dev/null and b/tab_h.png differ diff --git a/tab_hd.png b/tab_hd.png new file mode 100644 index 00000000..2489273d Binary files /dev/null and b/tab_hd.png differ diff --git a/tab_s.png b/tab_s.png new file mode 100644 index 00000000..ab478c95 Binary files /dev/null and b/tab_s.png differ diff --git a/tab_sd.png b/tab_sd.png new file mode 100644 index 00000000..757a565c Binary files /dev/null and b/tab_sd.png differ diff --git a/tabs.css b/tabs.css new file mode 100644 index 00000000..71c8a470 --- /dev/null +++ b/tabs.css @@ -0,0 +1 @@ +.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.main-menu-btn{position:relative;display:inline-block;width:36px;height:36px;text-indent:36px;margin-left:8px;white-space:nowrap;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.main-menu-btn-icon,.main-menu-btn-icon:before,.main-menu-btn-icon:after{position:absolute;top:50%;left:2px;height:2px;width:24px;background:var(--nav-menu-button-color);-webkit-transition:all .25s;transition:all .25s}.main-menu-btn-icon:before{content:'';top:-7px;left:0}.main-menu-btn-icon:after{content:'';top:7px;left:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon{height:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:before{top:0;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:after{top:0;-webkit-transform:rotate(45deg);transform:rotate(45deg)}#main-menu-state{position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(1px,1px,1px,1px)}#main-menu-state:not(:checked) ~ #main-menu{display:none}#main-menu-state:checked ~ #main-menu{display:block}@media(min-width:768px){.main-menu-btn{position:absolute;top:-99999px}#main-menu-state:not(:checked) ~ #main-menu{display:block}}.sm-dox{background-image:var(--nav-gradient-image)}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:var(--font-family-nav);font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:var(--nav-text-normal-shadow);color:var(--nav-text-normal-color);outline:0}.sm-dox a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:var(--nav-menu-toggle-color);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a span.sub-arrow:before{display:block;content:'+'}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:var(--nav-menu-background-color)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:var(--nav-menu-background-color);background-image:none}.sm-dox ul a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:var(--nav-gradient-image);line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:var(--nav-text-normal-color) transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:var(--nav-separator-image);background-repeat:no-repeat;background-position:right;-moz-border-radius:0 !important;-webkit-border-radius:0;border-radius:0 !important}.sm-dox a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox a:hover span.sub-arrow{border-color:var(--nav-text-hover-color) transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent var(--nav-menu-background-color) transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:var(--nav-menu-background-color);-moz-border-radius:5px !important;-webkit-border-radius:5px;border-radius:5px !important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent var(--nav-menu-foreground-color);border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:var(--nav-menu-foreground-color);background-image:none;border:0 !important;color:var(--nav-menu-foreground-color);background-image:none}.sm-dox ul a:hover{background-image:var(--nav-gradient-active-image);background-repeat:repeat-x;color:var(--nav-text-hover-color);text-shadow:var(--nav-text-hover-shadow)}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent var(--nav-text-hover-color)}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:var(--nav-menu-background-color);height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent var(--nav-menu-foreground-color) transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:var(--nav-menu-foreground-color) transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:var(--nav-gradient-image)}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:var(--nav-menu-background-color)}} \ No newline at end of file diff --git a/todo.html b/todo.html new file mode 100644 index 00000000..05a8c253 --- /dev/null +++ b/todo.html @@ -0,0 +1,92 @@ + + + + + + + +maug: Todo List + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    +
    Todo List
    +
    +
    +
    +
    Global retroflat_blit_bitmap (struct RETROFLAT_BITMAP *target, struct RETROFLAT_BITMAP *src, int s_x, int s_y, int d_x, int d_y, int w, int h)
    +
    Currently s_x, s_y, w, and h are not functional on all platforms!
    +
    Global RETROFLAT_FPS
    +
    FPS currently has no effect in Allegro.
    +
    Global retroflat_message (uint8_t flags, const char *title, const char *format,...)
    +
    This should display a dialog box on every platform if possible.
    +
    +
    +
    + + + + diff --git a/unionMAUG__FMT__SPEC.html b/unionMAUG__FMT__SPEC.html new file mode 100644 index 00000000..6a5b93f8 --- /dev/null +++ b/unionMAUG__FMT__SPEC.html @@ -0,0 +1,110 @@ + + + + + + + +maug: MAUG_FMT_SPEC Union Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MAUG_FMT_SPEC Union Reference
    +
    +
    + + + + + + + + + + + + + + +

    +Data Fields

    +long int d
     
    +uint32_t u
     
    +char c
     
    +void * p
     
    +char * s
     
    +size_t z
     
    +
    The documentation for this union was generated from the following file: +
    + + + + diff --git a/unionMTILEMAP__CPROP__VAL.html b/unionMTILEMAP__CPROP__VAL.html new file mode 100644 index 00000000..b2fad42e --- /dev/null +++ b/unionMTILEMAP__CPROP__VAL.html @@ -0,0 +1,114 @@ + + + + + + + +maug: MTILEMAP_CPROP_VAL Union Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    MTILEMAP_CPROP_VAL Union Reference
    +
    +
    + +

    Data store for MTILEMAP_CPROP::value. + More...

    + +

    #include <mtilemap.h>

    + + + + + + + + + + + + +

    +Data Fields

    +uint32_t u32
     
    +int32_t i32
     
    +float f32
     
    +char str [MTILEMAP_CPROP_STR_SZ_MAX]
     
    +uint8_t bool
     
    +

    Detailed Description

    +

    Data store for MTILEMAP_CPROP::value.

    +

    The documentation for this union was generated from the following file: +
    + + + + diff --git a/unionRETROGUI__CTL.html b/unionRETROGUI__CTL.html new file mode 100644 index 00000000..27685b16 --- /dev/null +++ b/unionRETROGUI__CTL.html @@ -0,0 +1,105 @@ + + + + + + + +maug: RETROGUI_CTL Union Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + +
    +
    + +
    RETROGUI_CTL Union Reference
    +
    +
    +
    +Collaboration diagram for RETROGUI_CTL:
    +
    +
    Collaboration graph
    + + + + + +
    [legend]
    + + + + +

    +Data Fields

    +struct RETROGUI_CTL_BASE base
     
    +
    The documentation for this union was generated from the following file: +
    + + + + diff --git a/unionRETROGUI__CTL__coll__graph.map b/unionRETROGUI__CTL__coll__graph.map new file mode 100644 index 00000000..643792ff --- /dev/null +++ b/unionRETROGUI__CTL__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/unionRETROGUI__CTL__coll__graph.md5 b/unionRETROGUI__CTL__coll__graph.md5 new file mode 100644 index 00000000..152a8ca3 --- /dev/null +++ b/unionRETROGUI__CTL__coll__graph.md5 @@ -0,0 +1 @@ +955b15e28b511eece0135c29875cc1e8 \ No newline at end of file diff --git a/unionRETROGUI__CTL__coll__graph.png b/unionRETROGUI__CTL__coll__graph.png new file mode 100644 index 00000000..2607cb1a Binary files /dev/null and b/unionRETROGUI__CTL__coll__graph.png differ diff --git a/uprintf_8h.html b/uprintf_8h.html new file mode 100644 index 00000000..602dcb03 --- /dev/null +++ b/uprintf_8h.html @@ -0,0 +1,229 @@ + + + + + + + +maug: uprintf.h File Reference + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    + +
    uprintf.h File Reference
    +
    +
    +
    #include <mtypes.h>
    +#include <stdio.h>
    +#include <stdarg.h>
    +#include <mlegacy.h>
    +
    +Include dependency graph for uprintf.h:
    +
    +
    + + + + + + + + + + + +
    +
    +This graph shows which files directly or indirectly include this file:
    +
    +
    + + + + + +
    +
    +

    Go to the source code of this file.

    + + + + +

    +Data Structures

    union  MAUG_FMT_SPEC
     
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +Macros

    +#define NEWLINE_STR   "\n"
     
    +#define UPRINTF_BUFFER_SZ_MAX   1024
     
    +#define platform_file   FILE*
     
    +#define platform_fprintf   fprintf
     
    +#define platform_vfprintf   vfprintf
     
    +#define platform_fopen   fopen
     
    +#define platform_fflush   fflush
     
    +#define platform_fclose   fclose
     
    +#define LOG_ERR_TARGET   stderr
     
    +#define LOG_STD_TARGET   stdout
     
    +#define SIZE_T_FMT   "%u"
     
    +#define SSIZE_T_FMT   "%d"
     
    +#define DEBUG_THRESHOLD   1
     
    +#define debug_printf(...)
     
    +#define error_printf(...)
     
    +#define size_printf(...)
     
    +#define size_multi_printf(...)
     
    +#define logging_init()
     
    +#define logging_shutdown()
     
    #define maug_bufcat(c, buf, buf_idx, buf_sz, cleanup)
     
    #define maug_bufpad(pad_c, pad_sz, i, buf, buf_idx, buf_sz, cleanup)
     
    #define maug_xtoa(num, base, rem, dest, dest_idx, digits, digits_done, pad)
     
    + + + + + + + + + + + + + + + + + +

    +Functions

    +int maug_digits (long int num, int base)
     
    +int maug_zdigits (size_t num, int base)
     
    +int maug_itoa (long int num, char *dest, int dest_sz, int base)
     
    +int maug_utoa (uint32_t num, char *dest, int dest_sz, int base)
     
    +int maug_ztoa (size_t num, char *dest, int dest_sz, int base)
     
    +void maug_vsnprintf (char *buffer, int buffer_sz, const char *fmt, va_list vargs)
     
    +void maug_snprintf (char *buffer, int buffer_sz, const char *fmt,...)
     
    +void maug_printf (const char *fmt,...)
     
    + + + +

    +Variables

    +uint32_t g_maug_printf_line
     
    +
    + + + + diff --git a/uprintf_8h__dep__incl.map b/uprintf_8h__dep__incl.map new file mode 100644 index 00000000..ace8dde7 --- /dev/null +++ b/uprintf_8h__dep__incl.map @@ -0,0 +1,5 @@ + + + + + diff --git a/uprintf_8h__dep__incl.md5 b/uprintf_8h__dep__incl.md5 new file mode 100644 index 00000000..013577ad --- /dev/null +++ b/uprintf_8h__dep__incl.md5 @@ -0,0 +1 @@ +ace40642652c5ed6154c08e7835fc7b0 \ No newline at end of file diff --git a/uprintf_8h__dep__incl.png b/uprintf_8h__dep__incl.png new file mode 100644 index 00000000..98d5fbee Binary files /dev/null and b/uprintf_8h__dep__incl.png differ diff --git a/uprintf_8h__incl.map b/uprintf_8h__incl.map new file mode 100644 index 00000000..6e8637cd --- /dev/null +++ b/uprintf_8h__incl.map @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/uprintf_8h__incl.md5 b/uprintf_8h__incl.md5 new file mode 100644 index 00000000..cde4790d --- /dev/null +++ b/uprintf_8h__incl.md5 @@ -0,0 +1 @@ +fd737c927886bc7464508b7ffaaf7d2e \ No newline at end of file diff --git a/uprintf_8h__incl.png b/uprintf_8h__incl.png new file mode 100644 index 00000000..293a1357 Binary files /dev/null and b/uprintf_8h__incl.png differ diff --git a/uprintf_8h_source.html b/uprintf_8h_source.html new file mode 100644 index 00000000..ec3a838b --- /dev/null +++ b/uprintf_8h_source.html @@ -0,0 +1,717 @@ + + + + + + + +maug: uprintf.h Source File + + + + + + + + + + +
    +
    + + + + + + +
    +
    maug +
    +
    Quick and dirty C mini-augmentation library.
    +
    +
    + + + + + + + + +
    +
    + + +
    +
    +
    +
    +
    +
    Loading...
    +
    Searching...
    +
    No Matches
    +
    +
    +
    +
    + + +
    +
    +
    uprintf.h
    +
    +
    +Go to the documentation of this file.
    1
    +
    2#ifndef UPRINTF_H
    +
    3#define UPRINTF_H
    +
    4
    +
    5#include <mtypes.h>
    +
    6
    +
    7#include <stdio.h>
    +
    8#include <stdarg.h>
    +
    9
    +
    10#ifndef MAUG_NO_LEGACY
    +
    11# include <mlegacy.h>
    +
    12#endif /* !MAUG_NO_LEGACY */
    +
    13
    +
    24/* == Autodetection == */
    +
    25
    +
    26#ifndef UPRINTF_S32
    +
    27# if __LONG_WIDTH__ == 32 || defined( __WATCOMC__ ) || defined( __BORLANDC__ )
    +
    28# define UPRINTF_S32 "%ld"
    +
    29# elif __LONG_WIDTH__ == 64
    +
    30# define UPRINTF_S32 "%d"
    +
    31# endif /* __LONG_WIDTH__ */
    +
    32#endif /* !UPRINTF_S32 */
    +
    33
    +
    34#ifndef UPRINTF_U32
    +
    35# if __LONG_WIDTH__ == 32 || defined( __WATCOMC__ ) || defined( __BORLANDC__ )
    +
    36# define UPRINTF_U32 "%lu"
    +
    37# elif __LONG_WIDTH__ == 64
    +
    38# define UPRINTF_U32 "%u"
    +
    39# endif /* __LONG_WIDTH__ */
    +
    40#endif /* !UPRINTF_U32 */
    +
    41
    +
    42#ifndef NEWLINE_STR
    +
    43/* TODO: Autodetect. */
    +
    44#define NEWLINE_STR "\n"
    +
    45#endif /* !NEWLINE_STR */
    +
    46
    +
    47/* == Manual Config == */
    +
    48
    +
    49#ifndef UPRINTF_BUFFER_SZ_MAX
    +
    50# define UPRINTF_BUFFER_SZ_MAX 1024
    +
    51#endif /* !UPRINTF_BUFFER_SZ_MAX */
    +
    52
    +
    53#ifndef platform_file
    +
    54# define platform_file FILE*
    +
    55#endif /* !platform_file */
    +
    56
    +
    57#ifndef platform_fprintf
    +
    58# define platform_fprintf fprintf
    +
    59#endif /* !platform_fprintf */
    +
    60
    +
    61#ifndef platform_vfprintf
    +
    62# define platform_vfprintf vfprintf
    +
    63#endif /* !platform_vfprintf */
    +
    64
    +
    65#ifndef platform_fopen
    +
    66# define platform_fopen fopen
    +
    67#endif /* !platform_fopen */
    +
    68
    +
    69#ifndef platform_fflush
    +
    70# define platform_fflush fflush
    +
    71#endif /* !platform_fflush */
    +
    72
    +
    73#ifndef platform_fclose
    +
    74# define platform_fclose fclose
    +
    75#endif /* !platform_fclose */
    +
    76
    +
    77#ifdef LOG_TO_FILE
    +
    78# ifndef UPRINTF_LOG
    +
    79# define UPRINTF_LOG
    +
    80# endif /* !UPRINTF_LOG */
    +
    81# define LOG_ERR_TARGET g_log_file
    +
    82# define LOG_STD_TARGET g_log_file
    +
    83#else
    +
    84# define LOG_ERR_TARGET stderr
    +
    85# define LOG_STD_TARGET stdout
    +
    86#endif /* LOG_TO_FILE */
    +
    87
    +
    88#ifdef __GNUC__
    +
    89# ifdef _WIN64 /* __SIZE_WIDTH__ == 64 */
    +
    90# define SIZE_T_FMT "%I64u"
    +
    91# define SSIZE_T_FMT "%I64d"
    +
    92# else
    +
    93# define SIZE_T_FMT "%lu"
    +
    94# define SSIZE_T_FMT "%ld"
    +
    95# endif /* __LONG_WIDTH__ */
    +
    96#else
    +
    97# define SIZE_T_FMT "%u"
    +
    98# define SSIZE_T_FMT "%d"
    +
    99#endif /* __GNUC__ */
    +
    100
    +
    101#if !defined( DEBUG_THRESHOLD )
    +
    102# define DEBUG_THRESHOLD 1
    +
    103#endif /* !DEBUG_THRESHOLD */
    +
    104
    + +
    106 long int d;
    +
    107 uint32_t u;
    +
    108 char c;
    +
    109 void* p;
    +
    110 char* s;
    +
    111#ifndef UPRINTF_NO_SIZET
    +
    112 size_t z;
    +
    113#endif /* !UPRINTF_NO_SIZET */
    +
    114};
    +
    115
    +
    116#if defined( MAUG_OS_NDS )
    +
    117
    +
    118/* TODO: Figure out a way to get the calling line number for a function. */
    +
    119
    +
    120static void debug_printf( int level, const char* fmt, ... ) {
    +
    121 va_list argp;
    +
    122 char buffer[UPRINTF_BUFFER_SZ_MAX + 1];
    +
    123
    +
    124 if( level >= DEBUG_THRESHOLD ) {
    +
    125 va_start( argp, fmt );
    +
    126 vsnprintf( buffer, UPRINTF_BUFFER_SZ_MAX, fmt, argp );
    +
    127 va_end( argp );
    +
    128 nocashMessage( buffer );
    +
    129 nocashMessage( "\n" );
    +
    130 }
    +
    131}
    +
    132
    +
    133static void error_printf( const char* fmt, ... ) {
    +
    134 va_list argp;
    +
    135 char buffer[UPRINTF_BUFFER_SZ_MAX + 1];
    +
    136
    +
    137 va_start( argp, fmt );
    +
    138 vsnprintf( buffer, UPRINTF_BUFFER_SZ_MAX, fmt, argp );
    +
    139 va_end( argp );
    +
    140
    +
    141 nocashMessage( buffer );
    +
    142 nocashMessage( "\n" );
    +
    143}
    +
    144
    +
    145/* ! */
    +
    146#elif defined( UPRINTF_ANCIENT_C )
    +
    147/* ! */
    +
    148
    +
    149/* TODO: Figure out a way to get the calling line number for a function. */
    +
    150
    +
    151static void debug_printf( int level, const char* fmt, ... ) {
    +
    152 va_list argp;
    +
    153
    +
    154 if( level >= DEBUG_THRESHOLD ) {
    +
    155 va_start( argp, fmt );
    +
    156 vprintf( fmt, argp );
    +
    157 va_end( argp );
    +
    158 printf( "\n" );
    +
    159 }
    +
    160}
    +
    161
    +
    162static void error_printf( const char* fmt, ... ) {
    +
    163 va_list argp;
    +
    164
    +
    165 va_start( argp, fmt );
    +
    166 vprintf( fmt, argp );
    +
    167 va_end( argp );
    +
    168 printf( "\n" );
    +
    169}
    +
    170
    +
    171# define size_printf( lvl, name, sz ) debug_printf( lvl, name " size is " SIZE_T_FMT " bytes", (sz) );
    +
    172
    +
    173# define size_multi_printf( lvl, name, sz, max ) debug_printf( lvl, "single " name " size is " SIZE_T_FMT " bytes, " name " array size is " SIZE_T_FMT " bytes", (sz), ((sz) * (max)) );
    +
    174
    +
    175/* ! */
    +
    176#elif defined( UPRINTF_LOG )
    +
    177/* ! */
    +
    178
    +
    179# ifdef NO_DEBUG_LINE_NUMBER
    +
    180# define LINE_NUMBER() 0
    +
    181# else
    +
    182# define LINE_NUMBER() __LINE__
    +
    183# endif
    +
    184
    +
    185# define internal_debug_printf( lvl, ... ) if( NULL != LOG_ERR_TARGET && lvl >= DEBUG_THRESHOLD ) { platform_fprintf( LOG_STD_TARGET, "(%d) " __FILE__ ": %d: ", lvl, LINE_NUMBER() ); platform_fprintf( LOG_STD_TARGET, __VA_ARGS__ ); platform_fprintf( LOG_STD_TARGET, NEWLINE_STR ); platform_fflush( LOG_STD_TARGET ); }
    +
    186
    +
    187# define internal_error_printf( ... ) if( NULL != LOG_ERR_TARGET ) { platform_fprintf( LOG_ERR_TARGET, "(E) " __FILE__ ": %d: ", LINE_NUMBER() ); platform_fprintf( LOG_ERR_TARGET, __VA_ARGS__ ); platform_fprintf( LOG_ERR_TARGET, NEWLINE_STR ); platform_fflush( LOG_ERR_TARGET ); }
    +
    188
    +
    189# define debug_printf( lvl, ... ) internal_debug_printf( lvl, __VA_ARGS__ )
    +
    190
    +
    191# define error_printf( ... ) internal_error_printf( __VA_ARGS__ )
    +
    192
    +
    193# define size_printf( lvl, name, sz ) internal_debug_printf( lvl, name " size is " SIZE_T_FMT " bytes", (sz) );
    +
    194
    +
    195# define size_multi_printf( lvl, name, sz, max ) internal_debug_printf( lvl, "single " name " size is " SIZE_T_FMT " bytes, " name " array size is " SIZE_T_FMT " bytes", (sz), ((sz) * (max)) );
    +
    196
    +
    197/* ! */
    +
    198#else /* !UPRINTF_LOG, !UPRINTF_ANCIENT_C */
    +
    199/* ! */
    +
    200
    +
    201/* TODO: Stub these without vargarg macros. */
    +
    202
    +
    203# define debug_printf( ... )
    +
    204# define error_printf( ... )
    +
    205# define size_printf( ... )
    +
    206# define size_multi_printf( ... )
    +
    207
    +
    208/* ! */
    +
    209#endif /* UPRINTF_LOG, UPRINTF_ANCIENT_C */
    +
    210/* ! */
    +
    211
    +
    212#ifdef LOG_TO_FILE
    +
    213
    +
    214# define logging_init() g_log_file = platform_fopen( LOG_FILE_NAME, "w" );
    +
    215# define logging_shutdown() platform_fclose( g_log_file );
    +
    216
    +
    217# if defined( MAIN_C ) || defined( UPRINTF_C )
    +
    218platform_file g_log_file = NULL;
    +
    219# else
    +
    220extern platform_file g_log_file;
    +
    221# endif /* MAIN_C || UPRINTF_C */
    +
    222
    +
    223#else
    +
    224
    +
    225# define logging_init()
    +
    226# define logging_shutdown()
    +
    227
    +
    228#endif /* LOG_TO_FILE */
    +
    229
    +
    230#define maug_bufcat( c, buf, buf_idx, buf_sz, cleanup ) \
    +
    231 buf[buf_idx++] = c; \
    +
    232 if( buf_idx >= buf_sz ) { goto cleanup; }
    +
    233
    +
    234#define maug_bufpad( pad_c, pad_sz, i, buf, buf_idx, buf_sz, cleanup ) \
    +
    235 i = 0; \
    +
    236 while( i < pad_sz ) { \
    +
    237 maug_bufcat( pad_c, buffer, buffer_idx, buffer_sz, cleanup ); \
    +
    238 i++; \
    +
    239 }
    +
    240
    +
    241int maug_digits( long int num, int base );
    +
    242
    +
    243#ifndef UPRINTF_NO_SIZET
    +
    244int maug_zdigits( size_t num, int base );
    +
    245#endif /* !UPRINTF_NO_SIZET */
    +
    246
    +
    247#define maug_xtoa( num, base, rem, dest, dest_idx, digits, digits_done, pad ) \
    +
    248 dest_idx += digits; \
    +
    249 while( 0 != num ) { \
    +
    250 /* Get the 1's place. */ \
    +
    251 rem = num % base; \
    +
    252 dest[--dest_idx] = (9 < rem) ? \
    +
    253 /* > 10, so it's a letter. */ \
    +
    254 (rem - 10) + 'a' : \
    +
    255 /* < 10, so it's a number. */ \
    +
    256 rem + '0'; \
    +
    257 /* Move the next place value into range. */ \
    +
    258 num /= base; \
    +
    259 digits_done++; \
    +
    260 } \
    +
    261 while( digits_done < digits ) { \
    +
    262 dest[--dest_idx] = '0'; \
    +
    263 digits_done++; \
    +
    264 }
    +
    265
    +
    266int maug_itoa( long int num, char* dest, int dest_sz, int base );
    +
    267
    +
    268int maug_utoa( uint32_t num, char* dest, int dest_sz, int base );
    +
    269
    +
    270#ifndef UPRINTF_NO_SIZET
    +
    271int maug_ztoa( size_t num, char* dest, int dest_sz, int base );
    +
    272#endif /* !UPRINTF_NO_SIZET */
    +
    273
    +
    274void maug_vsnprintf(
    +
    275 char* buffer, int buffer_sz, const char* fmt, va_list vargs );
    +
    276
    +
    277void maug_snprintf( char* buffer, int buffer_sz, const char* fmt, ... );
    +
    278
    +
    279void maug_printf( const char* fmt, ... );
    +
    280
    +
    281#ifdef UPRINTF_C
    +
    282
    +
    283uint32_t g_maug_printf_line = 0;
    +
    284int g_maug_uprintf_threshold = DEBUG_THRESHOLD;
    +
    285
    +
    286int maug_digits( long int num, int base ) {
    +
    287 int digits = 0;
    +
    288 int negative = 0;
    +
    289
    +
    290 if( 0 > num ) {
    +
    291 num *= -1;
    +
    292 negative = 1;
    +
    293 }
    +
    294
    +
    295 while( 0 < num ) {
    +
    296 num /= base;
    +
    297 digits++;
    +
    298 }
    +
    299
    +
    300 if( 0 == digits ) {
    +
    301 digits = 1; /* 0 */
    +
    302 }
    +
    303
    +
    304 if( negative ) {
    +
    305 digits++; /* - symbol */
    +
    306 }
    +
    307
    +
    308 return digits;
    +
    309}
    +
    310
    +
    311/* === */
    +
    312
    +
    313#ifndef UPRINTF_NO_SIZET
    +
    314int maug_zdigits( size_t num, int base ) {
    +
    315 int digits = 0;
    +
    316 int negative = 0;
    +
    317
    +
    318 while( 0 < num ) {
    +
    319 num /= base;
    +
    320 digits++;
    +
    321 }
    +
    322
    +
    323 if( 0 == digits ) {
    +
    324 digits = 1; /* 0 */
    +
    325 }
    +
    326
    +
    327 if( negative ) {
    +
    328 digits++; /* - symbol */
    +
    329 }
    +
    330
    +
    331 return digits;
    +
    332}
    +
    333#endif /* !UPRINTF_NO_SIZET */
    +
    334
    +
    335/* === */
    +
    336
    +
    337int maug_itoa( long int num, char* dest, int dest_sz, int base ) {
    +
    338 long int rem;
    +
    339 int digits;
    +
    340 int digits_done = 0;
    +
    341 int dest_idx = 0;
    +
    342 int negative = 0;
    +
    343
    +
    344 digits = maug_digits( num, base );
    +
    345 assert( (0 == num && 1 == digits) || (0 != num && 0 < digits) );
    +
    346 assert( digits < dest_sz );
    +
    347
    +
    348 /* Handle 0 explicitly, otherwise empty string is printed for 0. */
    +
    349 if( 0 == num ) {
    +
    350 dest[0] = '0';
    +
    351 digits_done++;
    +
    352 } else if( 0 > num ) {
    +
    353 num *= -1;
    +
    354 negative = 1;
    +
    355 }
    +
    356
    +
    357 maug_xtoa( num, base, rem, dest, dest_idx, digits, digits_done, pad );
    +
    358
    +
    359 if( negative ) {
    +
    360 dest[dest_idx] = '-';
    +
    361 }
    +
    362 dest[digits] = '\0';
    +
    363
    +
    364 return digits;
    +
    365}
    +
    366
    +
    367/* === */
    +
    368
    +
    369/* TODO: Seems to force 16-bit in Borland... why? */
    +
    370int maug_utoa( uint32_t num, char* dest, int dest_sz, int base ) {
    +
    371 uint32_t rem;
    +
    372 int digits;
    +
    373 int digits_done = 0;
    +
    374 int dest_idx = 0;
    +
    375
    +
    376 digits = maug_digits( num, base );
    +
    377 assert( (0 == num && 1 == digits) || (0 != num && 0 < digits) );
    +
    378 assert( digits < dest_sz );
    +
    379
    +
    380 /* Handle 0 explicitly, otherwise empty string is printed for 0. */
    +
    381 if( 0 == num ) {
    +
    382 dest[0] = '0';
    +
    383 digits_done++;
    +
    384 }
    +
    385
    +
    386 maug_xtoa( num, base, rem, dest, dest_idx, digits, digits_done, pad );
    +
    387 dest[digits] = '\0';
    +
    388
    +
    389 return digits;
    +
    390}
    +
    391
    +
    392/* === */
    +
    393
    +
    394#ifndef UPRINTF_NO_SIZET
    +
    395int maug_ztoa( size_t num, char* dest, int dest_sz, int base ) {
    +
    396 size_t rem;
    +
    397 int digits;
    +
    398 int digits_done = 0;
    +
    399 int dest_idx = 0;
    +
    400
    +
    401 digits = maug_zdigits( num, base );
    +
    402 assert( (0 == num && 1 == digits) || (0 != num && 0 < digits) );
    +
    403 assert( digits < dest_sz );
    +
    404
    +
    405 /* Handle 0 explicitly, otherwise empty string is printed for 0. */
    +
    406 if( 0 == num ) {
    +
    407 dest[0] = '0';
    +
    408 digits_done++;
    +
    409 }
    +
    410
    +
    411 maug_xtoa( num, base, rem, dest, dest_idx, digits, digits_done, pad );
    +
    412 dest[digits] = '\0';
    +
    413
    +
    414 return digits;
    +
    415}
    +
    416#endif /* !UPRINTF_NO_SIZET */
    +
    417
    +
    418/* === */
    +
    419
    +
    420void maug_vsnprintf(
    +
    421 char* buffer, int buffer_sz, const char* fmt, va_list vargs
    +
    422) {
    +
    423 int i = 0, j = 0;
    +
    424 char last = '\0';
    +
    425 union MAUG_FMT_SPEC spec;
    +
    426 int pad_len = 0;
    +
    427 char c;
    +
    428 char pad_char = ' ';
    +
    429 int buffer_idx = 0;
    +
    430 int spec_is_long = 0;
    +
    431
    +
    432 for( i = 0 ; '\0' != fmt[i] ; i++ ) {
    +
    433 c = fmt[i]; /* Separate so we can play tricks below. */
    +
    434
    +
    435 if( '%' == last ) {
    +
    436 /* Conversion specifier encountered. */
    +
    437 switch( fmt[i] ) {
    +
    438 case 'l':
    +
    439 spec_is_long = 1;
    +
    440 /* Skip resetting the last char. */
    +
    441 continue;
    +
    442
    +
    443 case 's':
    +
    444 spec.s = va_arg( vargs, char* );
    +
    445
    +
    446 /* Print string. */
    +
    447 j = 0;
    +
    448 while( '\0' != spec.s[j] ) {
    +
    449 maug_bufcat( spec.s[j++], buffer, buffer_idx,
    +
    450 buffer_sz, cleanup );
    +
    451 }
    +
    452 break;
    +
    453
    +
    454 case 'u':
    +
    455 if( spec_is_long ) {
    +
    456 spec.u = va_arg( vargs, uint32_t );
    +
    457 } else {
    +
    458 spec.u = va_arg( vargs, unsigned int );
    +
    459 }
    +
    460
    +
    461 /* Print padding. */
    +
    462 pad_len -= maug_digits( spec.d, 10 );
    +
    463 maug_bufpad( pad_char, pad_len, j,
    +
    464 buffer, buffer_idx, buffer_sz, cleanup );
    +
    465
    +
    466 /* Print number. */
    +
    467 buffer_idx += maug_utoa(
    +
    468 spec.d, &(buffer[buffer_idx]), buffer_sz - buffer_idx, 10 );
    +
    469 break;
    +
    470
    +
    471 case 'd':
    +
    472 if( spec_is_long ) {
    +
    473 spec.d = va_arg( vargs, long int );
    +
    474 } else {
    +
    475 spec.d = va_arg( vargs, int );
    +
    476 }
    +
    477
    +
    478 /* Print padding. */
    +
    479 pad_len -= maug_digits( spec.d, 10 );
    +
    480 maug_bufpad( pad_char, pad_len, j,
    +
    481 buffer, buffer_idx, buffer_sz, cleanup );
    +
    482
    +
    483 /* Print number. */
    +
    484 buffer_idx += maug_itoa(
    +
    485 spec.d, &(buffer[buffer_idx]), buffer_sz - buffer_idx, 10 );
    +
    486 break;
    +
    487
    +
    488#ifndef UPRINTF_NO_SIZET
    +
    489 case 'z':
    +
    490 spec.z = va_arg( vargs, size_t );
    +
    491
    +
    492 /* Print padding. */
    +
    493 pad_len -= maug_zdigits( spec.z, 10 );
    +
    494 maug_bufpad( pad_char, pad_len, j,
    +
    495 buffer, buffer_idx, buffer_sz, cleanup );
    +
    496
    +
    497 /* Print number. */
    +
    498 buffer_idx += maug_ztoa(
    +
    499 spec.z, &(buffer[buffer_idx]), buffer_sz - buffer_idx, 10 );
    +
    500 break;
    +
    501#endif /* !UPRINTF_NO_SIZET */
    +
    502
    +
    503 case 'x':
    +
    504 spec.d = va_arg( vargs, int );
    +
    505
    +
    506 /* Print padding. */
    +
    507 pad_len -= maug_digits( spec.d, 16 );
    +
    508 maug_bufpad( pad_char, pad_len, j,
    +
    509 buffer, buffer_idx, buffer_sz, cleanup );
    +
    510
    +
    511 /* Print number. */
    +
    512 buffer_idx += maug_utoa(
    +
    513 spec.d, &(buffer[buffer_idx]), buffer_sz - buffer_idx, 16 );
    +
    514 break;
    +
    515
    +
    516 case 'c':
    +
    517 spec.c = va_arg( vargs, int );
    +
    518
    +
    519 /* Print padding. */
    +
    520 pad_len -= 1;
    +
    521 maug_bufpad( pad_char, pad_len, j,
    +
    522 buffer, buffer_idx, buffer_sz, cleanup );
    +
    523
    +
    524 /* Print char. */
    +
    525 maug_bufcat( spec.c, buffer, buffer_idx,
    +
    526 buffer_sz, cleanup );
    +
    527 break;
    +
    528
    +
    529 case '%':
    +
    530 /* Literal % */
    +
    531 last = '\0';
    +
    532 maug_bufcat( '%', buffer, buffer_idx, buffer_sz, cleanup );
    +
    533 break;
    +
    534
    +
    535 case '0':
    +
    536 /* If we haven't started counting padding with a non-zero number,
    +
    537 * this must be a 0-padding signifier.
    +
    538 */
    +
    539 if( 0 >= pad_len ) {
    +
    540 pad_char = '0';
    +
    541 c = '%';
    +
    542 break;
    +
    543 }
    +
    544 /* If we've already started parsing padding count digits, then
    +
    545 * fall through below as a regular number.
    +
    546 */
    +
    547 case '1':
    +
    548 case '2':
    +
    549 case '3':
    +
    550 case '4':
    +
    551 case '5':
    +
    552 case '6':
    +
    553 case '7':
    +
    554 case '8':
    +
    555 case '9':
    +
    556 /* Handle multi-digit qty padding. */
    +
    557 pad_len *= 10;
    +
    558 pad_len += (c - '0'); /* Convert from char to int. */
    +
    559 c = '%';
    +
    560 break;
    +
    561 }
    +
    562 } else if( '%' != c ) {
    +
    563 pad_char = ' '; /* Reset padding. */
    +
    564 pad_len = 0; /* Reset padding. */
    +
    565 spec_is_long = 0;
    +
    566
    +
    567 /* Print non-escape characters verbatim. */
    +
    568 maug_bufcat( c, buffer, buffer_idx,
    +
    569 buffer_sz, cleanup );
    +
    570 }
    +
    571
    +
    572 last = c;
    +
    573 }
    +
    574
    +
    575cleanup:
    +
    576 return;
    +
    577}
    +
    578
    +
    579/* === */
    +
    580
    +
    581void maug_snprintf( char* buffer, int buffer_sz, const char* fmt, ... ) {
    +
    582 va_list vargs;
    +
    583
    +
    584 va_start( vargs, fmt );
    +
    585 maug_vsnprintf( buffer, buffer_sz, fmt, vargs );
    +
    586 va_end( vargs );
    +
    587}
    +
    588
    +
    589/* === */
    +
    590
    +
    591void maug_printf( const char* fmt, ... ) {
    +
    592 char buffer[UPRINTF_BUFFER_SZ_MAX];
    +
    593 va_list vargs;
    +
    594
    +
    595 va_start( vargs, fmt );
    +
    596 maug_vsnprintf( buffer, UPRINTF_BUFFER_SZ_MAX, fmt, vargs );
    +
    597 va_end( vargs );
    +
    598
    +
    599 /* TODO */
    +
    600}
    +
    601
    +
    602/* === */
    +
    603
    +
    604void maug_debug_printf(
    +
    605 FILE* out, uint8_t flags, const char* src_name, size_t line, int16_t lvl,
    +
    606 const char* fmt, ...
    +
    607) {
    +
    608 va_list vargs;
    +
    609
    +
    610 if( NULL == out ) {
    +
    611#ifdef MAUG_LOG_FILE
    +
    612 out = g_log_file;
    +
    613#else
    +
    614 out = stdout;
    +
    615#endif /* MAUG_LOG_FILE */
    +
    616 }
    +
    617
    +
    618 if( lvl >= g_maug_uprintf_threshold ) {
    +
    619 platform_fprintf( out, "(%d) %s : " SIZE_T_FMT ": ",
    +
    620 lvl, src_name, line );
    +
    621
    +
    622 va_start( vargs, fmt );
    +
    623 platform_vfprintf( out, fmt, vargs );
    +
    624 va_end( vargs );
    +
    625
    +
    626 platform_fprintf( out, NEWLINE_STR );
    +
    627 platform_fflush( out );
    +
    628 }
    +
    629}
    +
    630
    +
    631#else
    +
    632
    +
    633extern uint32_t g_maug_printf_line;
    +
    634
    +
    635#endif /* UPRINTF_C */
    +
    636 /* maug_uprintf */
    +
    638
    +
    639#endif /* !UPRINTF_H */
    +
    640
    +
    Definition uprintf.h:105
    +
    + + + +