Compare commits

...

152 Commits

Author SHA1 Message Date
c6fdf19055 [nostalgia/studio] Bump version to d2025.02.1
All checks were successful
Build / build (push) Successful in 1m28s
2025-03-24 20:51:02 -05:00
ed5f424eb0 [keel] Add missing new line to log message
All checks were successful
Build / build (push) Successful in 1m28s
2025-03-24 20:44:33 -05:00
a44c5acc4b [studio] Fix closing tab with unsaved changes 2025-03-24 20:43:34 -05:00
13e256b3a9 [nostalgia/studio] Update version to d2025.02.0
All checks were successful
Build / build (push) Successful in 1m28s
2025-02-25 20:15:07 -06:00
6bd74611cd [nostalgia] Update release notes
All checks were successful
Build / build (push) Successful in 1m28s
2025-02-25 20:02:52 -06:00
c3f9cf9a64 [studio] Fix New Project opening project, disable New if no project open
Some checks failed
Build / build (push) Has been cancelled
2025-02-25 20:01:33 -06:00
646ab1283f [nostalgia/gfx] Cleanup
All checks were successful
Build / build (push) Successful in 1m26s
2025-02-24 21:45:45 -06:00
74cf055610 [nostalgia] Cleanup
All checks were successful
Build / build (push) Successful in 1m32s
2025-02-24 19:43:10 -06:00
0d8ba1b154 [nostalgia/gfx] Cleanup formatting mistake
All checks were successful
Build / build (push) Successful in 1m26s
2025-02-23 23:21:59 -06:00
20edbb7f38 [buildcore] Map aarch64 to arm64
All checks were successful
Build / build (push) Successful in 1m27s
2025-02-23 01:00:12 -06:00
6febc7cc73 [nostalgia] Fix build
All checks were successful
Build / build (push) Successful in 1m32s
2025-02-23 00:51:30 -06:00
b94d6b5061 [nostalgia] Remove scene package, finish stubbing out sound
Some checks failed
Build / build (push) Failing after 21s
2025-02-23 00:49:58 -06:00
b3952cabbc [nostalgia] Add build upload step to CI
All checks were successful
Build / build (push) Successful in 1m39s
2025-02-22 21:30:35 -06:00
2ffc11b04e Merge commit 'e723ead864edb4bc160e4d69713309174ad9e82e'
All checks were successful
Build / build (push) Successful in 1m34s
2025-02-22 20:55:17 -06:00
96cace2cbb [studio] Cleanup 2025-02-22 19:51:55 -06:00
472f5702bd [nostalgia/gfx/studio/tilesheet] Change max export scale to 135
All checks were successful
Build / build (push) Successful in 1m32s
2025-02-22 15:31:39 -06:00
c0ac4345d3 [studio] Cleanup
All checks were successful
Build / build (push) Successful in 1m30s
2025-02-22 15:16:26 -06:00
fbebf4ef83 [nostalgia/gfx/studio/tilesheet] Fix export for 4bpp images
All checks were successful
Build / build (push) Successful in 1m27s
2025-02-22 00:58:12 -06:00
20513f7749 [nostalgia/sample_project] Add type descriptors 2025-02-21 00:41:04 -06:00
25a7873ea2 [nostalgia,studio] Fix crash that occurred when navigating to file that is not already open
All checks were successful
Build / build (push) Successful in 1m32s
2025-02-20 23:57:02 -06:00
d0a32e247e [ox/std] Add Vector::remove
All checks were successful
Build / build (push) Successful in 1m42s
2025-02-20 23:34:36 -06:00
03d4a5736e [nostalgia,studio] Add ability to navigate from tile sheet to palette color
All checks were successful
Build / build (push) Successful in 1m52s
2025-02-20 23:30:50 -06:00
a2e41e6527 Merge commit '4e94c925686cdda4b1ac777045dd7a17c7dc0329'
All checks were successful
Build / build (push) Successful in 1m38s
2025-02-20 20:11:03 -06:00
40a7caff90 [ox/std] Make bounds checking its own option enable-able in release builds 2025-02-20 20:05:07 -06:00
26fc5565e8 [nostalgia/gfx] Make dangling reference warning suppressions check for GCC 13
All checks were successful
Build / build (push) Successful in 1m30s
2025-02-20 19:40:08 -06:00
388541ce32 [nostalgia/player] Cleanup
All checks were successful
Build / build (push) Successful in 1m24s
2025-02-20 00:01:29 -06:00
6c194667b9 [nostalgia] Fix NostalgiaGfx lib name, stub out sound package
All checks were successful
Build / build (push) Successful in 1m27s
2025-02-19 22:19:16 -06:00
62d0579f40 [ox/fs] Restructure stat error handling to make easier to debug
All checks were successful
Build / build (push) Successful in 1m25s
2025-02-19 21:47:47 -06:00
202595b2a6 [keel] Fix loading assets by path 2025-02-19 21:47:00 -06:00
cb21ff3f04 Merge commit 'a6b9657268eb3fe139b0c22df27c2cb2efc0013c' 2025-02-19 00:34:26 -06:00
2a8e3c2dc4 [nostalgia/gfx] Remove unnecessary cast
All checks were successful
Build / build (push) Successful in 1m26s
2025-02-18 23:01:15 -06:00
998066d377 [ox/std] Add comparison functions
All checks were successful
Build / build (push) Successful in 1m24s
2025-02-18 21:46:41 -06:00
fefb876fe7 [nostalgia/gfx] Add checks for GCC version for warning suppression
All checks were successful
Build / build (push) Successful in 1m24s
2025-02-18 20:33:29 -06:00
5979e9885e [jsoncpp] Up required CMake version 2025-02-18 20:26:47 -06:00
a17abe4639 [nfde] Up required CMake version 2025-02-18 20:26:47 -06:00
d62f913855 [nostalgia/gfx] Suppress some superfluous warnings
Some checks failed
Build / build (push) Failing after 1m9s
2025-02-18 20:22:56 -06:00
12bb7475fc [nostalgia/gfx/studio/tilesheet] Adjust pixel line size on Windows
All checks were successful
Build / build (push) Successful in 1m25s
2025-02-18 20:19:51 -06:00
df2c7e2b67 [nostalgia] Update release notes
All checks were successful
Build / build (push) Successful in 1m26s
2025-02-08 18:10:49 -06:00
713aec887b [buildcore] Change mypy invokation
All checks were successful
Build / build (push) Successful in 1m28s
2025-02-07 20:38:44 -06:00
3089cd7afc Change builder type to olympic
Some checks failed
Build / build (push) Has been cancelled
2025-02-07 20:34:22 -06:00
00638bc812 [nostalgia/gfx/studio/tilesheet] Mark DrawCommands as obsolete if no changes
All checks were successful
Build / build (push) Successful in 3m37s
2025-02-05 20:26:47 -06:00
e002109829 [studio] Make undo/redo skip over obsolete commands 2025-02-05 20:26:03 -06:00
b4798fd2ab [nostalgia/gfx/studio/tilesheet] Make rotate only available for square subsheets or selections
All checks were successful
Build / build (push) Successful in 3m39s
2025-02-05 01:54:41 -06:00
3c804bf62a [studio] Give MakeCopy popup an error message for files that already exist
All checks were successful
Build / build (push) Successful in 3m36s
2025-02-03 23:30:07 -06:00
d39d552bd9 [nostalgia/studio] Update icon to higher resolution 2025-02-03 23:29:26 -06:00
b7202a2b0d [nostalgia/player] Disable Keel mods on GBA
All checks were successful
Build / build (push) Successful in 3m34s
2025-02-03 22:48:07 -06:00
4e27a4c1f5 [nostalgia/core/studio/tilesheet] Fix palette path display update
All checks were successful
Build / build (push) Successful in 3m37s
2025-02-03 22:43:20 -06:00
4ef31762d0 [nostalgia/core/studio/tilesheet] Cleanup 2025-02-03 22:43:02 -06:00
8b22a8f339 [keel] Make buildUuidMap only read the first 40 bytes of each file 2025-02-03 20:29:06 -06:00
d45ff05bcd [ox/fs] Add new partial file read functions 2025-02-03 20:28:25 -06:00
671dd86206 [keel,studio] Add Make Copy option to ProjectExplorer
All checks were successful
Build / build (push) Successful in 3m46s
2025-02-03 02:01:40 -06:00
0abadc1850 [studio] Fix QuestionPopup to only emit a response when there is a response
All checks were successful
Build / build (push) Successful in 3m36s
2025-02-03 00:35:37 -06:00
4e068d628c [studio] Fix misrender flash on tab close 2025-02-03 00:19:14 -06:00
4461f99fa4 [studio] Add Ctrl-W shortcut for closing active tab
All checks were successful
Build / build (push) Successful in 3m36s
2025-02-02 23:13:15 -06:00
cd1f4bdaa3 [studio] Add confirmation for closing file with unsaved changes 2025-02-02 23:07:59 -06:00
4728699585 [studio] Add combobox that will take string views
All checks were successful
Build / build (push) Successful in 3m47s
2025-02-02 20:46:08 -06:00
105a1e5559 [nostalgia/core/studio/tilesheet] Rework operation ctrls into a dropbox
Some checks failed
Build / build (push) Failing after 1m1s
2025-02-02 20:43:01 -06:00
1bc18e34a8 [nostalgia/core/studio/tilesheet] Add ability to rotate a selection 2025-02-02 20:22:20 -06:00
fb8d295fcb [nostalgia/core/studio/tilesheet] Add rotate functionality 2025-02-02 14:46:21 -06:00
8459d3baea Merge commit 'c42adc290cd8a27d01bb6d9877032dd2c963a4b7' 2025-02-01 22:55:46 -06:00
804d78e116 [nostalgia/gfx/studio] Cleanup
All checks were successful
Build / build (push) Successful in 3m32s
2025-02-01 15:14:24 -06:00
5351e9aa0a [nostalgia/core/studio/tilesheet] Add line drawing tool
All checks were successful
Build / build (push) Successful in 3m36s
2025-02-01 14:14:09 -06:00
b5954f15c5 [studio] Restore context menu for root dir, but exclude Delete
All checks were successful
Build / build (push) Successful in 3m33s
2025-01-29 18:47:48 -06:00
5dce9dd377 [studio] Suppress context menu for root dir in ProjectExplorer
All checks were successful
Build / build (push) Successful in 3m32s
2025-01-28 01:27:51 -06:00
0570f76236 [ox/fs] Fix PassThroughFS::stripSlash
All checks were successful
Build / build (push) Successful in 3m32s
2025-01-28 01:18:44 -06:00
e22b658a67 [studio] Fix isParentOf check in Project to ensure child dir path ends with /
Some checks failed
Build / build (push) Has been cancelled
2025-01-28 01:04:17 -06:00
56b9cb6ebf [studio] Fix file explorer to treat empty directories as directories
All checks were successful
Build / build (push) Successful in 3m32s
2025-01-27 23:31:58 -06:00
eaa9a2415e [keel] Make reloadAsset check if file is loaded 2025-01-27 21:59:57 -06:00
95256a9a0d [studio] Make rename file give error message if the file already exists
All checks were successful
Build / build (push) Successful in 3m32s
2025-01-27 00:54:58 -06:00
2286238abc [studio] Make rename file accept input upon pressing Enter if text input is focused
All checks were successful
Build / build (push) Successful in 3m36s
2025-01-27 00:33:14 -06:00
13f0bf57e4 [studio] Make deleting a file close tabs associated with it 2025-01-27 00:30:27 -06:00
8eb1ac215b [studio] Fix not to try moving a parent directory to its child
All checks were successful
Build / build (push) Successful in 3m34s
2025-01-27 00:10:25 -06:00
e132f2fd1b [studio] Make file move do nothing if the file already exists 2025-01-26 23:59:13 -06:00
12f6b22c8b [nostalgia/gfx/studio/palette] Cleanup 2025-01-26 23:35:03 -06:00
6c858e0c4e [nostalgia/gfx/studio/tilesheet] UI cleanup
All checks were successful
Build / build (push) Successful in 3m35s
2025-01-26 22:30:39 -06:00
c6b58f7c63 [nostalgia] Update release notes
All checks were successful
Build / build (push) Successful in 3m35s
2025-01-26 22:16:04 -06:00
a22aafaf96 [nostalgia/gfx/studio/palette] Add ability to reorder Palette pages 2025-01-26 22:12:57 -06:00
6298ac3a21 [nostalgia] Update release notes
All checks were successful
Build / build (push) Successful in 3m28s
2025-01-26 20:58:22 -06:00
cd63afacfe [studio] Remove Ctrl-0 tab shortcut 2025-01-26 20:53:47 -06:00
2859183742 [nostalgia/gfx/studio/tilesheet] Add the ability to move subsheets 2025-01-26 20:46:15 -06:00
8d04af691e Merge commit 'ab760b064fd6a302bad13274e0e02b2b2c957b67' 2025-01-26 15:42:50 -06:00
055165974e [nostalgia/sample_project] Update test assets 2025-01-26 15:41:40 -06:00
be51838775 [nostalgia/gfx/studio/tilesheet] Add flip x and flip y functionality
All checks were successful
Build / build (push) Successful in 3m33s
2025-01-26 15:41:13 -06:00
1207dadee8 [studio] Add ability to move directories
All checks were successful
Build / build (push) Successful in 3m29s
2025-01-26 09:38:27 -06:00
109e1898cc [studio] Add ability to drag files between directories
All checks were successful
Build / build (push) Successful in 3m29s
2025-01-26 02:03:54 -06:00
a24bf7ffb9 [studio] Fix config to update when open file name changes 2025-01-26 01:01:48 -06:00
046834c2b9 [studio,nostalgia] Update tab name when corresponding file's name changes
All checks were successful
Build / build (push) Successful in 3m30s
2025-01-26 00:52:11 -06:00
f840240aac [nostalgia/gfx/studio/tilesheeteditor] Rework system for tracking current palette path
All checks were successful
Build / build (push) Successful in 3m29s
2025-01-25 22:59:51 -06:00
cfa91d3d39 [keel,studio] Add ability to rename files 2025-01-25 22:59:01 -06:00
f7a7a66a6a [ox/event] Add Signal::connectionCnt 2025-01-25 22:58:18 -06:00
5145595d57 [ox/std] Fix HashMap collision handling 2025-01-25 22:16:42 -06:00
f01d303381 [ox/std] Fix UPtr compare with nullptr 2025-01-25 20:13:47 -06:00
098c8cb844 [nostalgia/gfx/studio] Make move color commands affect all pages
All checks were successful
Build / build (push) Successful in 3m25s
2025-01-24 23:46:26 -06:00
04ad0f0264 [studio] Add drag/drop functions that use model TypeName for name
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-24 23:26:30 -06:00
695e7a4561 [nostalgia/gfx/studio/paletteeditor] Change move color mechanism to use drag/drop
Some checks failed
Build / build (push) Failing after 54s
2025-01-24 23:19:45 -06:00
7d53028faf [studio] Cleanup 2025-01-24 00:21:28 -06:00
6c34198f58 Merge commit '897a59cdad66e593fd45eece9414d8414fa7f1ae' 2025-01-23 23:51:13 -06:00
7e3e046109 [ox/model] Fix possible infinite recursion
All checks were successful
Build / build (push) Successful in 3m26s
2025-01-23 23:48:40 -06:00
f63c58169f [studio] Add filepickerpopup.hpp to studio.hpp 2025-01-23 22:19:59 -06:00
e40b11246d [nostalgia/gfx/studio/paletteeditor] Fix num key shortcuts to ignore if ctrl is down
All checks were successful
Build / build (push) Successful in 3m25s
2025-01-23 21:56:47 -06:00
161194c8b2 [nostalgia/gfx/studio/tilesheeteditor] Add FilePicker to for choosing a Palette
All checks were successful
Build / build (push) Successful in 3m25s
2025-01-23 21:24:10 -06:00
48603ea2c5 [studio] Make tabs not draw while closing 2025-01-23 21:24:10 -06:00
e2f2a17315 [studio] Add FilePickerPopup 2025-01-23 21:24:10 -06:00
e8a0ce88c5 Merge commit 'dff9f81e073bb994d5ce96a6eaa1bfa547f1fdf4'
Some checks are pending
Build / build (push) Waiting to run
2025-01-23 21:21:58 -06:00
82e2ea747f [studio] Fix NewMenu to track prev stage correctly when going back two stages 2025-01-23 21:13:58 -06:00
ff666eda9b [studio] Make NewMenu default Name field to focus when it appears
All checks were successful
Build / build (push) Successful in 3m30s
2025-01-23 00:55:10 -06:00
0d8b82ba49 [studio] Cleanup
All checks were successful
Build / build (push) Successful in 3m10s
2025-01-23 00:32:03 -06:00
5598dfdd87 [nostalgia/player] Update hardcoded tilesheet refs to new file ext
All checks were successful
Build / build (push) Successful in 3m16s
2025-01-23 00:19:35 -06:00
6ef462adcc [keel] Add clearer Error handling 2025-01-23 00:15:55 -06:00
9511cb5719 [studio] Fix prev tracking
All checks were successful
Build / build (push) Successful in 3m16s
2025-01-22 23:37:44 -06:00
1cc1d561e2 [studio] Add a file explorer to NewMenu to choose where new files go
All checks were successful
Build / build (push) Successful in 4m16s
2025-01-22 23:11:08 -06:00
d15a0df7da [studio] Make reusable FileTreeModel 2025-01-22 01:04:25 -06:00
e1282b6bae [studio] Fix build
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-22 00:58:43 -06:00
5fe7c14ccb [nostalgia/sample_project] Rename TileSheet files using new file ext
Some checks failed
Build / build (push) Failing after 52s
2025-01-21 23:40:19 -06:00
42165ba2d6 [nostalgia/gfx] Change default file extension for TileSheets to nts 2025-01-21 23:35:55 -06:00
1af4da43ad [nostalgia] Update release notes
All checks were successful
Build / build (push) Successful in 3m22s
2025-01-21 22:56:59 -06:00
4fa879a09e [nostalgia/sample_project] Update NS_Logo.ng to final TileSheetV5 format
Some checks failed
Build / build (push) Has been cancelled
2025-01-21 22:54:27 -06:00
fd8f1a29c6 [nostalgia] Add release notes document
All checks were successful
Build / build (push) Successful in 3m24s
2025-01-21 22:45:55 -06:00
9fda2763ba [nostalgia/gfx] Make TileSheetV5::defaultPalette a string instead of FileAddress 2025-01-21 22:44:55 -06:00
cda23ac4af [ox/std] Change ox::String::operator[](size_t) const return a reference 2025-01-21 22:43:57 -06:00
c36b244dd3 [nostalgia/gfx] Cleanup, add PaletteV5, restore mistakenly removed function 2025-01-21 22:17:13 -06:00
335d278f5e [ox/oc] Fix integer read for signed/unsigned 2025-01-21 22:15:36 -06:00
f987b02c65 [nostalgia/gfx] Move to TileSheetV5
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-21 02:21:01 -06:00
3c056276c1 [turbine,nostalgia] Cleanup 2025-01-20 23:19:07 -06:00
87e2fdefcf [ox/std] Make UAnyPtr uncopyable 2025-01-20 20:42:00 -06:00
672b92b363 [nostalgia/gfx/studio] Remove accidental version tag in default Palette
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-20 03:13:01 -06:00
762a6517b2 [nostalgia] Rename core to gfx 2025-01-20 03:11:35 -06:00
d141154a45 Merge commit '38777cfac8868b3628332090260710d5ac26aba0'
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-20 02:15:45 -06:00
6170647c0c [nostalgia,studio] Proper fix for input filtering 2025-01-20 02:10:48 -06:00
48e45c7dd6 [studio] Cleanup 2025-01-20 01:34:00 -06:00
5d3d9229b7 [nostalgia/core/studio/paletteeditor] Ignore keyboard input when popup is open 2025-01-20 01:33:23 -06:00
d54e93d836 [studio] Cleanup 2025-01-20 00:16:16 -06:00
830f8fe3e4 [studio,nostalgia/core/studio] Give default Palette created studio a default page
All checks were successful
Build / build (push) Successful in 3m23s
2025-01-19 20:53:27 -06:00
7b638538aa Merge commit '8e0b6ffbabb10f8a6e9ad7e9f07e0ba1d039a02e' 2025-01-19 20:18:56 -06:00
2016f6e605 [studio] Fix DeleteConfirmation 'No' option to not delete file
All checks were successful
Build / build (push) Successful in 3m22s
2025-01-19 20:17:35 -06:00
240effd305 Merge commit '7e20f7200963cd0b22f84cc46e10db12b6c13806' 2025-01-19 19:04:24 -06:00
6bc629e02c [nostalgia/core/studio/tilesheeteditor] Replace Palette combobox with a readonly text input
All checks were successful
Build / build (push) Successful in 3m21s
2025-01-19 19:02:44 -06:00
f6f2acd67b [nostalgia/core/studio/tilesheeteditor] Add back file type check for palette drop 2025-01-19 18:21:50 -06:00
0146d38405 [nostalgia/core/studio/tilesheeteditor] Manually merge in changes that were lost in conflict
All checks were successful
Build / build (push) Successful in 3m19s
2025-01-19 18:18:52 -06:00
75d8e7bb89 [nostalgia/core/studio/paletteeditor] Fix crash that occurs when removing last color 2025-01-19 17:56:21 -06:00
6b53eaf6b1 [ox/std] Fix string append issues
All checks were successful
Build / build (push) Successful in 3m22s
2025-01-19 16:51:05 -06:00
16c32273ac [nostalgia/core/studio/tilesheeteditor] Fix palette drop target to only take palettes 2025-01-19 16:49:31 -06:00
1567a6e29d [applib] Fix build 2025-01-19 14:32:08 -06:00
89d543bcbc Merge commit '7b7d59cf63d77cf7ab6daf6ed7122eef97954555' 2025-01-19 13:39:31 -06:00
d68e64931b [nostalgia/core/studio/tilesheeteditor] Add support for dragging palette to palette selector
All checks were successful
Build / build (push) Successful in 3m22s
2025-01-19 11:41:48 -06:00
1cbc576286 [studio] Complete drag/drop support for files 2025-01-19 11:41:08 -06:00
500b93562c [studio] Make new dir window OK on Enter key
All checks were successful
Build / build (push) Successful in 3m17s
2025-01-19 09:33:17 -06:00
800ca85176 [ox/std] Fix possible error that occurs with appending on boundary of small string size
All checks were successful
Build / build (push) Successful in 3m20s
2025-01-19 09:26:06 -06:00
cc466a9f1d [studio] Add support for adding and deleting directories 2025-01-19 09:06:16 -06:00
9d1155843e [nostalgia] Rename player from 'nostalgia' to 'Nostalgia'
All checks were successful
Build / build (push) Successful in 3m24s
2025-01-19 01:48:53 -06:00
a2139c09b2 [studio] Cleanup unused member 2025-01-19 01:44:26 -06:00
a3e5f27ab8 [ox/std] Fix Mac build 2025-01-19 01:43:38 -06:00
235 changed files with 5889 additions and 2041 deletions

View File

@ -4,7 +4,7 @@ on: [push]
jobs:
build:
runs-on: nostalgia
runs-on: olympic
steps:
- name: Check out repository code
uses: actions/checkout@v3
@ -17,3 +17,10 @@ jobs:
- run: make purge configure-release
- run: make build
- run: make test
- run: make install
- run: mv dist/linux-x86_64-release nostalgia-linux-x86_64
- run: tar cf nostalgia-linux-x86_64.tar nostalgia-linux-x86_64
- uses: actions/upload-artifact@v3
with:
name: nostalgia-linux-x86_64
path: nostalgia-linux-x86_64.tar

View File

@ -5,14 +5,13 @@ BUILDCORE_PATH=deps/buildcore
include ${BUILDCORE_PATH}/base.mk
ifeq ($(BC_VAR_OS),darwin)
PROJECT_PLAYER=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME}.app/Contents/MacOS/${BC_VAR_PROJECT_NAME}
NOSTALGIA_STUDIO=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}Studio.app/Contents/MacOS/${BC_VAR_PROJECT_NAME_CAP}Studio
PROJECT_STUDIO=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}Studio.app/Contents/MacOS/${BC_VAR_PROJECT_NAME_CAP}Studio
MGBA=/Applications/mGBA.app/Contents/MacOS/mGBA
else
PROJECT_PLAYER=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME}
NOSTALGIA_STUDIO=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}Studio
PROJECT_STUDIO=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}Studio
MGBA=mgba-qt
endif
PROJECT_PLAYER=./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME_CAP}
.PHONY: pkg-gba
pkg-gba: build
@ -20,13 +19,13 @@ pkg-gba: build
.PHONY: build-player
build-player:
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} ${BC_VAR_PROJECT_NAME}
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} ${BC_VAR_PROJECT_NAME_CAP}
.PHONY: run
run: build-player
${PROJECT_PLAYER} sample_project
.PHONY: run-studio
run-studio: build
${NOSTALGIA_STUDIO}
${PROJECT_STUDIO}
.PHONY: gba-run
gba-run: pkg-gba
${MGBA} ${BC_VAR_PROJECT_NAME}.gba
@ -35,7 +34,7 @@ debug: build
${BC_CMD_HOST_DEBUGGER} ./build/${BC_VAR_CURRENT_BUILD}/bin/${BC_VAR_PROJECT_NAME} sample_project
.PHONY: debug-studio
debug-studio: build
${BC_CMD_HOST_DEBUGGER} ${NOSTALGIA_STUDIO}
${BC_CMD_HOST_DEBUGGER} ${PROJECT_STUDIO}
.PHONY: configure-gba
configure-gba:

View File

@ -93,7 +93,7 @@ purge:
${BC_CMD_RM_RF} compile_commands.json
.PHONY: test
test: build
${BC_CMD_ENVRUN} mypy ${BC_VAR_SCRIPTS}
${BC_CMD_ENVRUN} ${BC_CMD_PY3} -m mypy ${BC_VAR_SCRIPTS}
${BC_CMD_CMAKE_BUILD} ${BC_VAR_BUILD_PATH} test
.PHONY: test-verbose
test-verbose: build

30
deps/buildcore/scripts/file-to-cpp.py vendored Executable file
View File

@ -0,0 +1,30 @@
#! /usr/bin/env python3
#
# Copyright 2016 - 2025 gary@drinkingtea.net
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import argparse
import sys
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument('--file', help='path to file')
parser.add_argument('--out-cpp', help='path to output cpp file')
parser.add_argument('--out-hpp', help='path to output hpp file')
parser.add_argument('--namespace', help='path to output hpp file')
args = parser.parse_args()
return 0
if __name__ == '__main__':
try:
err = main()
sys.exit(err)
except KeyboardInterrupt:
sys.exit(1)

View File

@ -35,4 +35,6 @@ def get_arch() -> str:
arch = platform.machine().lower()
if arch == 'amd64':
arch = 'x86_64'
elif arch == 'aarch64':
arch = 'arm64'
return arch

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.19)
project(nativefiledialog-extended VERSION 1.1.1)
set(nfd_ROOT_PROJECT OFF)

View File

@ -12,7 +12,7 @@
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
# continue to generate policy warnings "CMake Warning (dev)...Policy CMP0XXX is not set:"
#
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.8.0")
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.13.2")
set(JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION "3.13.2")
cmake_minimum_required(VERSION ${JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION})
if("${CMAKE_VERSION}" VERSION_LESS "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION}")

View File

@ -143,6 +143,11 @@ class Signal {
Error disconnectObject(const void *receiver) const noexcept;
[[nodiscard]]
size_t connectionCnt() const noexcept {
return m_slots.size();
}
void emit(Args... args) const;
Error emitCheckError(Args... args) const noexcept;
@ -319,6 +324,11 @@ class Signal<Error(Args...)> {
Error disconnectObject(const void *receiver) const noexcept;
[[nodiscard]]
size_t connectionCnt() const noexcept {
return m_slots.size();
}
void emit(Args... args) const noexcept;
Error emitCheckError(Args... args) const noexcept;

View File

@ -37,6 +37,30 @@ Error FileSystem::read(const FileAddress &addr, void *buffer, std::size_t size)
}
}
Result<Buffer> FileSystem::read(FileAddress const &addr, size_t const size) noexcept {
Result<Buffer> out;
out.value.resize(size);
switch (addr.type()) {
case FileAddressType::Inode:
OX_RETURN_ERROR(readFileInode(addr.getInode().value, out.value.data(), size));
break;
case FileAddressType::ConstPath:
case FileAddressType::Path:
OX_RETURN_ERROR(readFilePath(StringView{addr.getPath().value}, out.value.data(), size));
break;
default:
return ox::Error{1};
}
return out;
}
Result<Buffer> FileSystem::read(StringViewCR path, size_t const size) noexcept {
Result<Buffer> out;
out.value.resize(size);
OX_RETURN_ERROR(readFilePath(path, out.value.data(), size));
return out;
}
Result<Buffer> FileSystem::read(const FileAddress &addr) noexcept {
OX_REQUIRE(s, stat(addr));
Buffer buff(static_cast<std::size_t>(s.size));
@ -51,18 +75,33 @@ Result<Buffer> FileSystem::read(StringViewCR path) noexcept {
return buff;
}
Error FileSystem::read(const FileAddress &addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept {
Error FileSystem::read(
FileAddress const &addr,
std::size_t const readStart,
std::size_t const readSize,
void *buffer,
std::size_t *size) noexcept {
switch (addr.type()) {
case FileAddressType::Inode:
return read(addr.getInode().value, readStart, readSize, buffer, size);
return readFileInodeRange(addr.getInode().value, readStart, readSize, buffer, size);
case FileAddressType::ConstPath:
case FileAddressType::Path:
return ox::Error(2, "Unsupported for path lookups");
return readFilePathRange(addr.getPath().value, readStart, readSize, buffer, size);
default:
return ox::Error(1);
}
}
Result<size_t> FileSystem::read(
StringViewCR path,
std::size_t const readStart,
std::size_t const readSize,
Span<char> buff) noexcept {
size_t szOut{buff.size()};
OX_RETURN_ERROR(readFilePathRange(path, readStart, readSize, buff.data(), &szOut));
return szOut;
}
Error FileSystem::write(const FileAddress &addr, const void *buffer, uint64_t size, FileType fileType) noexcept {
switch (addr.type()) {
case FileAddressType::Inode:

View File

@ -41,6 +41,10 @@ class FileSystem {
Error read(const FileAddress &addr, void *buffer, std::size_t size) noexcept;
Result<Buffer> read(FileAddress const &addr, size_t size) noexcept;
Result<Buffer> read(StringViewCR path, size_t size) noexcept;
Result<Buffer> read(const FileAddress &addr) noexcept;
Result<Buffer> read(StringViewCR path) noexcept;
@ -53,7 +57,24 @@ class FileSystem {
return readFileInode(inode, buffer, buffSize);
}
Error read(const FileAddress &addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept;
Error read(
FileAddress const &addr,
size_t readStart,
size_t readSize,
void *buffer,
size_t *size) noexcept;
/**
*
* @param path
* @param readStart
* @param readSize
* @param buffer
* @param size
* @return error or number of bytes read
*/
Result<size_t> read(
StringViewCR path, size_t readStart, size_t readSize, ox::Span<char> buff) noexcept;
virtual Result<Vector<String>> ls(StringViewCR dir) const noexcept = 0;
@ -140,7 +161,10 @@ class FileSystem {
virtual Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept = 0;
virtual Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept = 0;
virtual Error readFilePathRange(
StringViewCR path, size_t readStart, size_t readSize, void *buffer, size_t *buffSize) noexcept = 0;
virtual Error readFileInodeRange(uint64_t inode, size_t readStart, size_t readSize, void *buffer, size_t *size) noexcept = 0;
virtual Error removePath(StringViewCR path, bool recursive) noexcept = 0;
@ -211,6 +235,9 @@ class FileSystemTemplate: public MemFS {
Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept override;
Error readFilePathRange(
StringViewCR path, size_t readStart, size_t readSize, void *buffer, size_t *buffSize) noexcept override;
Error removePath(StringViewCR path, bool recursive) noexcept override;
Result<const char*> directAccessInode(uint64_t) const noexcept override;
@ -358,6 +385,13 @@ Error FileSystemTemplate<FileStore, Directory>::readFileInodeRange(uint64_t inod
return m_fs.read(inode, readStart, readSize, reinterpret_cast<uint8_t*>(buffer), size);
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::readFilePathRange(
StringViewCR path, size_t readStart, size_t readSize, void *buffer, size_t *buffSize) noexcept {
OX_REQUIRE(s, stat(path));
return readFileInodeRange(s.inode, readStart, readSize, buffer, buffSize);
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::removePath(StringViewCR path, bool recursive) noexcept {
OX_REQUIRE(fd, fileSystemData());

View File

@ -93,7 +93,9 @@ Result<FileStat> PassThroughFS::statPath(StringViewCR path) const noexcept {
oxTracef("ox.fs.PassThroughFS.statInode", "{} {}", ec.message(), path);
const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec);
oxTracef("ox.fs.PassThroughFS.statInode.size", "{} {}", path, size);
OX_RETURN_ERROR(ox::Error(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: stat failed"));
if (auto err = ec.value()) {
return ox::Error{static_cast<ox::ErrorCode>(err), "PassThroughFS: stat failed"};
}
return FileStat{0, 0, size, type};
}
@ -154,6 +156,25 @@ Error PassThroughFS::readFileInode(uint64_t, void*, std::size_t) noexcept {
return ox::Error(1, "readFileInode(uint64_t, void*, std::size_t) is not supported by PassThroughFS");
}
Error PassThroughFS::readFilePathRange(
StringViewCR path, size_t const readStart, size_t readSize, void *buffer, size_t *buffSize) noexcept {
try {
std::ifstream file(m_path / stripSlash(path), std::ios::binary | std::ios::ate);
auto const size = static_cast<size_t>(file.tellg());
readSize = ox::min(readSize, size);
file.seekg(static_cast<off_t>(readStart), std::ios::beg);
if (readSize > *buffSize) {
oxTracef("ox.fs.PassThroughFS.read.error", "Read failed: Buffer too small: {}", path);
return ox::Error{1};
}
file.read(static_cast<char*>(buffer), static_cast<std::streamsize>(readSize));
return {};
} catch (std::fstream::failure const &f) {
oxTracef("ox.fs.PassThroughFS.read.error", "Read of {} failed: {}", path, f.what());
return ox::Error{2};
}
}
Error PassThroughFS::readFileInodeRange(uint64_t, std::size_t, std::size_t, void*, std::size_t*) noexcept {
// unsupported
return ox::Error(1, "read(uint64_t, std::size_t, std::size_t, void*, std::size_t*) is not supported by PassThroughFS");
@ -185,8 +206,7 @@ Error PassThroughFS::writeFileInode(uint64_t, const void*, uint64_t, FileType) n
}
std::string_view PassThroughFS::stripSlash(StringView path) noexcept {
const auto pathLen = ox::strlen(path);
for (auto i = 0u; i < pathLen && path[0] == '/'; i++) {
for (auto i = 0u; i < path.len() && path[0] == '/'; i++) {
path = substr(path, 1);
}
return {path.data(), path.bytes()};

View File

@ -71,6 +71,9 @@ class PassThroughFS: public FileSystem {
Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept override;
Error readFilePathRange(
StringViewCR path, size_t readStart, size_t readSize, void *buffer, size_t *buffSize) noexcept override;
Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept override;
Error removePath(StringViewCR path, bool recursive) noexcept override;

View File

@ -58,7 +58,11 @@ class TypeStore {
if (!std::is_constant_evaluated()) {
OX_REQUIRE_M(dt, loadDescriptor(typeId));
for (auto &f : dt->fieldList) {
OX_RETURN_ERROR(this->getLoad(f.typeId).moveTo(f.type));
if (typeId == f.typeId) {
f.type = dt.get();
} else {
OX_RETURN_ERROR(this->getLoad(f.typeId).moveTo(f.type));
}
}
auto &out = m_cache[typeId];
out = std::move(dt);

View File

@ -144,7 +144,11 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept {
if (jv.empty()) {
*val = 0;
} else if (rightType) {
*val = static_cast<T>(jv.asUInt());
if constexpr(ox::is_signed_v<T>) {
*val = static_cast<T>(jv.asInt64());
} else {
*val = static_cast<T>(jv.asUInt64());
}
} else {
err = ox::Error(1, "Type mismatch");
}
@ -172,7 +176,8 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept {
err = ox::Error(1, "Type mismatch");
}
}
} catch (Json::LogicError const&) {
} catch (Json::LogicError const&e) {
oxDebugf("JSON error: {}", e.what());
err = ox::Error(1, "error reading JSON data");
}
++m_fieldIt;

View File

@ -58,13 +58,13 @@ class AnyPtrT {
template<typename T>
constexpr AnyPtrT(T *ptr) noexcept {
if (std::is_constant_evaluated()) {
m_wrapPtr = new Wrap(ptr);
m_wrapPtr = new Wrap<T>(ptr);
} else {
m_wrapPtr = new(m_wrapData.data()) Wrap(ptr);
m_wrapPtr = new(m_wrapData.data()) Wrap<T>(ptr);
}
}
constexpr AnyPtrT(AnyPtrT const&other) noexcept {
constexpr AnyPtrT(AnyPtrT const&other) noexcept requires(!unique) {
if (other) {
m_wrapPtr = other.m_wrapPtr->copyTo(m_wrapData);
}
@ -104,11 +104,9 @@ class AnyPtrT {
return *this;
}
constexpr AnyPtrT &operator=(AnyPtrT const&ptr) noexcept {
constexpr AnyPtrT &operator=(AnyPtrT const&ptr) noexcept requires(!unique) {
if (this != &ptr) {
if constexpr(unique) {
free();
} else if (std::is_constant_evaluated()) {
if (std::is_constant_evaluated()) {
ox::safeDelete(m_wrapPtr);
}
if (ptr) {

View File

@ -181,13 +181,13 @@ constexpr Array<T, ArraySize> &Array<T, ArraySize>::operator=(Array &&other) noe
template<typename T, std::size_t ArraySize>
constexpr T &Array<T, ArraySize>::operator[](std::size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
return m_items[i];
}
template<typename T, std::size_t ArraySize>
constexpr const T &Array<T, ArraySize>::operator[](std::size_t i) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
return m_items[i];
}

View File

@ -41,6 +41,12 @@ constexpr auto Debug = true;
constexpr auto Debug = false;
#endif
#if defined(OX_CHECK_BOUNDS)
constexpr auto CheckBounds = true;
#else
constexpr auto CheckBounds = Debug;
#endif
#if defined(NDEBUG)
constexpr auto NDebug = true;
#else

View File

@ -330,4 +330,17 @@ constexpr void primitiveAssert(char const*file, int line, bool pass, char const*
}
}
constexpr void boundsCheck(
char const*file,
int const line,
size_t const i,
size_t const sz,
char const*msg) noexcept {
if constexpr(defines::CheckBounds) {
if (i >= sz) [[unlikely]] {
panic(file, line, msg, ox::Error{1});
}
}
}
}

View File

@ -11,6 +11,7 @@
#include "algorithm.hpp"
#include "hash.hpp"
#include "ignore.hpp"
#include "optional.hpp"
#include "stringview.hpp"
#include "strops.hpp"
#include "vector.hpp"
@ -26,11 +27,12 @@ class HashMap {
private:
struct Pair {
UPtr<Pair> next;
K key = {};
T value{};
};
Vector<K> m_keys;
Vector<Pair*> m_pairs;
Vector<UPtr<Pair>> m_pairs;
public:
explicit constexpr HashMap(std::size_t size = 127);
@ -73,10 +75,10 @@ class HashMap {
constexpr void expand();
template<typename KK>
constexpr Pair *const&access(Vector<Pair*> const&pairs, KK const&key) const;
constexpr UPtr<Pair> const &access(Vector<UPtr<Pair>> const &pairs, KK const &key) const;
template<typename KK>
constexpr Pair *&access(Vector<Pair*> &pairs, KK const&key);
constexpr UPtr<Pair> &access(Vector<UPtr<Pair>> &pairs, KK const &key);
};
@ -85,14 +87,13 @@ constexpr HashMap<K, T>::HashMap(std::size_t size): m_pairs(size) {
}
template<typename K, typename T>
constexpr HashMap<K, T>::HashMap(HashMap<K, T> const&other) {
m_pairs = other.m_pairs;
constexpr HashMap<K, T>::HashMap(HashMap const &other) {
operator=(other);
}
template<typename K, typename T>
constexpr HashMap<K, T>::HashMap(HashMap<K, T> &&other) noexcept {
m_keys = std::move(other.m_keys);
m_pairs = std::move(other.m_pairs);
constexpr HashMap<K, T>::HashMap(HashMap &&other) noexcept {
operator=(std::move(other));
}
template<typename K, typename T>
@ -101,7 +102,7 @@ constexpr HashMap<K, T>::~HashMap() {
}
template<typename K, typename T>
constexpr bool HashMap<K, T>::operator==(HashMap const&other) const {
constexpr bool HashMap<K, T>::operator==(HashMap const &other) const {
if (m_keys != other.m_keys) {
return false;
}
@ -115,19 +116,25 @@ constexpr bool HashMap<K, T>::operator==(HashMap const&other) const {
}
template<typename K, typename T>
constexpr HashMap<K, T> &HashMap<K, T>::operator=(HashMap<K, T> const&other) {
constexpr HashMap<K, T> &HashMap<K, T>::operator=(HashMap const &other) {
if (this != &other) {
clear();
m_keys = other.m_keys;
m_pairs = other.m_pairs;
m_pairs.resize(other.m_pairs.size());
for (auto const&k : m_keys) {
auto const &src = access(other.m_pairs, k);
auto &dst = access(m_pairs, k);
dst = ox::make_unique<Pair>();
dst->key = src->key;
dst->value = src->value;
}
}
return *this;
}
template<typename K, typename T>
constexpr HashMap<K, T> &HashMap<K, T>::operator=(HashMap<K, T> &&other) noexcept {
constexpr HashMap<K, T> &HashMap<K, T>::operator=(HashMap &&other) noexcept {
if (this != &other) {
clear();
m_keys = std::move(other.m_keys);
m_pairs = std::move(other.m_pairs);
}
@ -135,60 +142,52 @@ constexpr HashMap<K, T> &HashMap<K, T>::operator=(HashMap<K, T> &&other) noexcep
}
template<typename K, typename T>
constexpr T &HashMap<K, T>::operator[](MaybeView_t<K> const&k) {
auto p = &access(m_pairs, k);
constexpr T &HashMap<K, T>::operator[](MaybeView_t<K> const &key) {
auto p = &access(m_pairs, key);
if (*p == nullptr) {
if (static_cast<double>(m_pairs.size()) * 0.7 <
static_cast<double>(m_keys.size())) {
expand();
p = &access(m_pairs, k);
p = &access(m_pairs, key);
}
*p = new Pair;
(*p)->key = k;
m_keys.emplace_back(k);
*p = ox::make_unique<Pair>();
(*p)->key = key;
m_keys.emplace_back(key);
}
return (*p)->value;
}
template<typename K, typename T>
constexpr Result<T*> HashMap<K, T>::at(MaybeView_t<K> const&k) noexcept {
auto p = access(m_pairs, k);
constexpr Result<T*> HashMap<K, T>::at(MaybeView_t<K> const &key) noexcept {
auto &p = access(m_pairs, key);
if (!p) {
return {nullptr, ox::Error(1, "value not found for given key")};
return ox::Error{1, "value not found for given key"};
}
return &p->value;
}
template<typename K, typename T>
constexpr Result<const T*> HashMap<K, T>::at(MaybeView_t<K> const&k) const noexcept {
auto p = access(m_pairs, k);
constexpr Result<const T*> HashMap<K, T>::at(MaybeView_t<K> const &key) const noexcept {
auto &p = access(m_pairs, key);
if (!p) {
return {nullptr, ox::Error(1, "value not found for given key")};
return ox::Error{1, "value not found for given key"};
}
return &p->value;
}
template<typename K, typename T>
constexpr void HashMap<K, T>::erase(MaybeView_t<K> const&k) {
if (!contains(k)) {
constexpr void HashMap<K, T>::erase(MaybeView_t<K> const &key) {
if (!contains(key)) {
return;
}
auto h = ox::hash<MaybeView_t<K>>{}(k) % m_pairs.size();
while (true) {
const auto &p = m_pairs[h];
if (p == nullptr || p->key == k) {
std::ignore = m_pairs.erase(h);
break;
} else {
h = ox::hash<MaybeView_t<K>>{}(k) % m_pairs.size();
}
}
std::ignore = m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), k));
auto &c = access(m_pairs, key);
c = std::move(c->next);
std::ignore = m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), key));
}
template<typename K, typename T>
constexpr bool HashMap<K, T>::contains(MaybeView_t<K> const&k) const noexcept {
return access(m_pairs, k) != nullptr;
constexpr bool HashMap<K, T>::contains(MaybeView_t<K> const &key) const noexcept {
return access(m_pairs, key).get() != nullptr;
}
template<typename K, typename T>
@ -204,27 +203,26 @@ constexpr Vector<K> const&HashMap<K, T>::keys() const noexcept {
template<typename K, typename T>
constexpr Vector<T> HashMap<K, T>::values() const noexcept {
Vector<T> out;
out.reserve(m_pairs.size());
for (auto const&p : m_pairs) {
out.emplace_back(p->value);
out.reserve(m_keys.size());
for (auto const &p : m_pairs) {
if (out) {
out.emplace_back(p->value);
}
}
return out;
}
template<typename K, typename T>
constexpr void HashMap<K, T>::clear() {
for (std::size_t i = 0; i < m_pairs.size(); i++) {
delete m_pairs[i];
}
m_pairs.clear();
m_pairs.resize(127);
}
template<typename K, typename T>
constexpr void HashMap<K, T>::expand() {
Vector<Pair*> r(m_pairs.size() * 2);
Vector<UPtr<Pair>> r{m_pairs.size() * 2};
for (std::size_t i = 0; i < m_keys.size(); ++i) {
auto const&k = m_keys[i];
auto const &k = m_keys[i];
access(r, k) = std::move(access(m_pairs, k));
}
m_pairs = std::move(r);
@ -232,29 +230,39 @@ constexpr void HashMap<K, T>::expand() {
template<typename K, typename T>
template<typename KK>
constexpr typename HashMap<K, T>::Pair *const&HashMap<K, T>::access(Vector<Pair*> const&pairs, KK const&k) const {
auto h = static_cast<std::size_t>(ox::hash<KK>{}(k) % pairs.size());
constexpr UPtr<typename HashMap<K, T>::Pair> const &HashMap<K, T>::access(
Vector<UPtr<Pair>> const& pairs,
KK const &key) const {
auto const h = static_cast<std::size_t>(ox::hash<KK>{}(key) % pairs.size());
auto const &p = *pairs.at(h).unwrap();
if (p == nullptr || p->key == key) {
return p;
}
auto c = &p->next;
while (true) {
auto const&p = *pairs.at(h).unwrap();
if (p == nullptr || p->key == k) {
return p;
} else {
h = (h + 1) % pairs.size();
if (*c == nullptr || (*c)->key == key) {
return *c;
}
c = &(*c)->next;
}
}
template<typename K, typename T>
template<typename KK>
constexpr typename HashMap<K, T>::Pair *&HashMap<K, T>::access(Vector<Pair*> &pairs, KK const&k) {
auto h = static_cast<std::size_t>(ox::hash<KK>{}(k) % pairs.size());
constexpr UPtr<typename HashMap<K, T>::Pair> &HashMap<K, T>::access(
Vector<UPtr<Pair>> &pairs,
KK const &key) {
auto const h = static_cast<std::size_t>(ox::hash<KK>{}(key) % pairs.size());
auto &p = *pairs.at(h).unwrap();
if (p == nullptr || p->key == key) {
return p;
}
auto c = &p->next;
while (true) {
auto &p = *pairs.at(h).unwrap();
if (p == nullptr || p->key == k) {
return p;
} else {
h = (h + 1) % pairs.size();
if (*c == nullptr || (*c)->key == key) {
return *c;
}
c = &(*c)->next;
}
}

View File

@ -133,17 +133,17 @@ struct SpanIterator {
}
constexpr PtrType operator->() const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
return &m_t[m_offset];
}
constexpr RefType operator*() const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
return m_t[m_offset];
}
constexpr RefType operator[](std::size_t s) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, s < m_max, "SpanIterator access overflow");
boundsCheck(__FILE__, __LINE__, s, m_max, "SpanIterator access overflow");
return m_t[s];
}

View File

@ -260,12 +260,12 @@ constexpr bool operator==(const UniquePtr<T> &p1, const UniquePtr<T> &p2) noexce
template<typename T>
constexpr bool operator==(const UniquePtr<T> &p1, std::nullptr_t) noexcept {
return p1.get();
return p1.get() == nullptr;
}
template<typename T>
constexpr bool operator==(std::nullptr_t, const UniquePtr<T> &p2) noexcept {
return p2.get();
return p2.get() == nullptr;
}

View File

@ -129,22 +129,22 @@ class Span {
}
constexpr T &operator[](std::size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
return m_items[i];
}
constexpr T const&operator[](std::size_t i) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
return m_items[i];
}
constexpr Span operator+(size_t i) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
return {m_items + i, m_size - i};
}
constexpr Span operator+=(size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
m_items += i;
m_size -= i;
return *this;

View File

@ -171,7 +171,7 @@ class BasicString {
constexpr bool operator>=(BasicString const&other) const noexcept;
constexpr char operator[](std::size_t i) const noexcept;
constexpr char const&operator[](std::size_t i) const noexcept;
constexpr char &operator[](std::size_t i) noexcept;
@ -392,7 +392,7 @@ template<std::size_t SmallStringSize_v>
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(const char *str) const noexcept {
const std::size_t strLen = ox::strlen(str);
const auto currentLen = len();
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
BasicString<SmallStringSize_v> cpy;
cpy.m_buff.resize(m_buff.size() + strLen);
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
ox::listcpy(&cpy.m_buff[currentLen], str, strLen);
@ -425,7 +425,8 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
cpy.m_buff.resize(m_buff.size() + strLen);
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen + 1);
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen);
cpy.m_buff[cpy.m_buff.size() - 1] = 0;
return cpy;
}
@ -436,7 +437,8 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
cpy.m_buff.resize(m_buff.size() + strLen);
ox::listcpy(&cpy.m_buff[0], m_buff.data(), currentLen);
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen + 1);
ox::listcpy(&cpy.m_buff[currentLen], src.data(), strLen);
cpy.m_buff[cpy.m_buff.size() - 1] = 0;
return cpy;
}
@ -488,7 +490,7 @@ constexpr bool BasicString<SmallStringSize_v>::operator>=(BasicString const&othe
}
template<std::size_t SmallStringSize_v>
constexpr char BasicString<SmallStringSize_v>::operator[](std::size_t i) const noexcept {
constexpr char const&BasicString<SmallStringSize_v>::operator[](std::size_t i) const noexcept {
return m_buff[i];
}

View File

@ -328,6 +328,16 @@ OX_CLANG_NOWARN_END
si["aoeu"] = 100;
oxAssert(si["asdf"] == 42, "asdf != 42");
oxAssert(si["aoeu"] == 100, "aoeu != 100");
si.erase("asdf");
oxAssert(!si.contains("asdf"), "wrongly contains asdf");
oxAssert(si.contains("aoeu"), "does not contains aoeu");
oxAssert(!si.at("asdf").ok(), "asdf != 0");
oxExpect(si["asdf"], 0);
oxAssert(si["aoeu"] == 100, "aoeu != 100");
auto si2 = si;
oxDebugf("{}", si2["asdf"]);
oxExpect(si2["asdf"], 0);
oxAssert(si2["aoeu"] == 100, "aoeu != 100");
ox::HashMap<int, int> ii;
ii[4] = 42;
ii[5] = 100;

View File

@ -27,6 +27,48 @@ constexpr void swap(T &a, T &b) noexcept {
b = std::move(temp);
}
template<typename T, typename U>
constexpr bool cmp_equal(T const t, U const u) noexcept {
if constexpr(ox::is_signed_v<T> == ox::is_signed_v<U>) {
return t == u;
} else if constexpr(ox::is_signed_v<T>) {
return ox::Signed<T>{t} == u;
} else {
return t == ox::Signed<U>{u};
}
}
template<typename T, typename U>
constexpr bool cmp_less(T const t, U const u) noexcept {
if constexpr(ox::is_signed_v<T> == ox::is_signed_v<U>) {
return t < u;
} else if constexpr(ox::is_signed_v<T>) {
return ox::Signed<T>{t} < u;
} else {
return t < ox::Signed<U>{u};
}
}
template<typename T, typename U>
constexpr bool cmp_not_equal(T const t, U const u) noexcept {
return !std::cmp_equal(t, u);
}
template<typename T, typename U>
constexpr bool cmp_greater(T const t, U const u) noexcept {
return std::cmp_less(u, t);
}
template<typename T, typename U>
constexpr bool cmp_less_equal(T const t, U const u) noexcept {
return !std::cmp_less(u, t);
}
template<typename T, typename U>
constexpr bool cmp_greater_equal(T const t, U const u) noexcept {
return !std::cmp_less(t, u);
}
}
#endif

View File

@ -311,6 +311,8 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
*/
constexpr Error unordered_erase(std::size_t pos) noexcept(useNoexcept);
constexpr Error remove(T const &val);
constexpr void reserve(std::size_t cap) noexcept(useNoexcept);
constexpr void shrink_to_fit() noexcept(useNoexcept);
@ -427,13 +429,13 @@ constexpr Vector<T, SmallVectorSize, Allocator> &Vector<T, SmallVectorSize, Allo
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
return m_items[i];
}
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
return m_items[i];
}
@ -659,6 +661,17 @@ constexpr Error Vector<T, SmallVectorSize, Allocator>::unordered_erase(std::size
return ox::Error(0);
}
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr ox::Error Vector<T, SmallVectorSize, Allocator>::remove(T const &val) {
for (size_t i{}; auto const &v : *this) {
if (v == val) {
return erase(i).error;
}
++i;
}
return ox::Error{1, "element not found"};
}
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr void Vector<T, SmallVectorSize, Allocator>::reserve(std::size_t cap) noexcept(useNoexcept) {
if (cap <= m_cap) {

23
release-notes.md Normal file
View File

@ -0,0 +1,23 @@
# d2025.02
* Rename core namespace to gfx.
* Add PaletteV5 to accommodate namespace change.
* Add TileSheetV5. TileSheetV5 retains the bpp field for the sake of
CompactTileSheet, but always store it pixel as 8 bpp for itself.
* Add ability to move subsheets in the subsheet tree.
* Add Flip X and Flip Y functionality to TileSheet Editor.
* Add rotate functionality to TileSheet Editor.
* Add draw line tool to TileSheet editor
* Replace file picker combo boxes with a browse button and file picker, and
support for dragging files from the project explorer.
* Add ability to jump to a color in a Palette by double clicking on the
color from the TileSheet editor
* Add ability to create directories.
* Add ability to add files to specific directories.
* Add ability to delete files from the project explorer.
* Ctrl-<num key> keyboard shortcuts for jumping between tabs.
* Fix Palette Editor to ignore keyboard input when popups are open.
* Palette Editor move color mechanism now uses drag and drop.
* Add ability to reorder Palette pages.
* Add warning for closing a tab with unsaved changes.
* Add ability to close a tab with Ctrl/Cmd-W

View File

@ -0,0 +1,23 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "pages",
"subscriptLevels" : 2,
"subscriptStack" :
[
{
"subscriptType" : 4
},
{
"subscriptType" : 4
}
],
"typeId" : "B.uint16;0"
}
],
"preloadable" : true,
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactPalette",
"typeVersion" : 1
}

View File

@ -0,0 +1,28 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "bpp",
"typeId" : "B.int8;0"
},
{
"fieldName" : "defaultPalette",
"typeId" : "net.drinkingtea.ox.FileAddress;1"
},
{
"fieldName" : "pixels",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "B.uint8;0"
}
],
"preloadable" : true,
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactTileSheet",
"typeVersion" : 1
}

View File

@ -0,0 +1,23 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "name",
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
},
{
"fieldName" : "colors",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "net.drinkingtea.nostalgia.gfx.PaletteColor;2"
}
],
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage",
"typeVersion" : 2
}

View File

@ -0,0 +1,31 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "colorNames",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
},
{
"fieldName" : "pages",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage;2"
}
],
"preloadable" : true,
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette",
"typeVersion" : 5
}

View File

@ -0,0 +1,24 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "r",
"typeId" : "B.uint8;0"
},
{
"fieldName" : "g",
"typeId" : "B.uint8;0"
},
{
"fieldName" : "b",
"typeId" : "B.uint8;0"
},
{
"fieldName" : "a",
"typeId" : "B.uint8;0"
}
],
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.PaletteColor",
"typeVersion" : 2
}

View File

@ -0,0 +1,46 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "id",
"typeId" : "B.int32;0"
},
{
"fieldName" : "name",
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
},
{
"fieldName" : "rows",
"typeId" : "B.int32;0"
},
{
"fieldName" : "columns",
"typeId" : "B.int32;0"
},
{
"fieldName" : "subsheets",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
},
{
"fieldName" : "pixels",
"subscriptLevels" : 1,
"subscriptStack" :
[
{
"subscriptType" : 4
}
],
"typeId" : "B.uint8;0"
}
],
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet",
"typeVersion" : 5
}

View File

@ -0,0 +1,24 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"fieldList" :
[
{
"fieldName" : "bpp",
"typeId" : "B.int8;0"
},
{
"fieldName" : "idIt",
"typeId" : "B.int32;0"
},
{
"fieldName" : "defaultPalette",
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
},
{
"fieldName" : "subsheet",
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
}
],
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet",
"typeVersion" : 5
}

View File

@ -1 +1,28 @@
K1;0f75977f-1c52-45f8-9793-52ea2dc200a0;M2;net.drinkingtea.nostalgia.core.Palette;1;<03><><07><>
K1;0f75977f-1c52-45f8-9793-52ea2dc200a0;O1;net.drinkingtea.nostalgia.gfx.Palette;5;{
"colorNames" :
[
"Color 1",
"Color 2"
],
"pages" :
[
{
"colors" :
[
{
"a" : 1,
"b" : 31,
"g" : 31,
"r" : 31
},
{
"a" : 1,
"b" : 22,
"g" : 22,
"r" : 22
}
],
"name" : "Page 1"
}
]
}

View File

@ -1 +1,36 @@
K1;c79f21e2-f74f-4ad9-90ed-32b0ef7da6ed;M2;net.drinkingtea.nostalgia.core.Palette;1;P<>{<03><>C<>
K1;c79f21e2-f74f-4ad9-90ed-32b0ef7da6ed;O1;net.drinkingtea.nostalgia.gfx.Palette;5;{
"colorNames" :
[
"Color 1",
"Color 2",
"Color 3",
"Color 4"
],
"pages" :
[
{
"colors" :
[
{
"b" : 5
},
{
"b" : 22,
"g" : 22,
"r" : 22
},
{
"b" : 27,
"g" : 27,
"r" : 27
},
{
"b" : 20,
"g" : 8,
"r" : 8
}
],
"name" : "Page 1"
}
]
}

Binary file not shown.

View File

@ -0,0 +1,352 @@
K1;5667c759-7ba1-470a-8860-72f0720dc58c;O1;net.drinkingtea.nostalgia.gfx.TileSheet;5;{
"bpp" : 4,
"defaultPalette" : "uuid://14fc3dd8-42ff-4bf9-81f1-a010cc5ac251",
"idIt" : 7,
"subsheet" :
{
"columns" : -1,
"name" : "Root",
"rows" : -1,
"subsheets" :
[
{
"columns" : 1,
"id" : 5,
"name" : "Blank",
"pixels" :
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"rows" : 1
},
{
"columns" : 2,
"id" : 6,
"name" : "Dirt",
"pixels" :
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"rows" : 2
}
]
}
}

Binary file not shown.

View File

@ -0,0 +1,591 @@
K1;896a7d25-9dc2-46a0-b4da-c6923b6da01b;O1;net.drinkingtea.nostalgia.gfx.TileSheet;5;{
"bpp" : 4,
"defaultPalette" : "uuid://c79f21e2-f74f-4ad9-90ed-32b0ef7da6ed",
"idIt" : 2,
"subsheet" :
{
"columns" : 3,
"id" : 1,
"name" : "Root",
"pixels" :
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
1,
1,
0,
0,
0,
0,
1,
1,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"rows" : 3
}
}

Binary file not shown.

View File

@ -0,0 +1,591 @@
K1;f551fb8b-0e9f-45fc-8106-b98b7fd18ff5;O1;net.drinkingtea.nostalgia.gfx.TileSheet;5;{
"bpp" : 4,
"defaultPalette" : "uuid://c79f21e2-f74f-4ad9-90ed-32b0ef7da6ed",
"idIt" : 2,
"subsheet" :
{
"columns" : 3,
"id" : 1,
"name" : "Root",
"pixels" :
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
3,
3,
3,
0,
0,
0,
3,
3,
3,
2,
3,
3,
0,
0,
3,
3,
2,
3,
3,
3,
0,
0,
0,
3,
3,
3,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"rows" : 3
}
}

Binary file not shown.

View File

@ -1,7 +1,7 @@
# module dir list
add_subdirectory(core)
add_subdirectory(scene)
add_subdirectory(gfx)
add_subdirectory(sound)
# module libraries
@ -13,8 +13,8 @@ add_library(
target_link_libraries(
NostalgiaKeelModules PUBLIC
Keel
NostalgiaCore-Keel
NostalgiaScene-Keel
NostalgiaGfx-Keel
NostalgiaSound-Keel
)
install(
FILES
@ -32,8 +32,8 @@ if(NOSTALGIA_BUILD_STUDIO)
target_link_libraries(
NostalgiaStudioModules PUBLIC
StudioAppLib
NostalgiaCore-Studio-ImGui
NostalgiaScene-Studio
NostalgiaGfx-Studio-ImGui
NostalgiaSound-Studio-ImGui
)
install(
FILES

View File

@ -1,18 +0,0 @@
target_sources(
NostalgiaCore-Studio PRIVATE
commands/addcolorcommand.cpp
commands/addpagecommand.cpp
commands/applycolorallpagescommand.cpp
commands/duplicatepagecommand.cpp
commands/movecolorcommand.cpp
commands/removecolorcommand.cpp
commands/removepagecommand.cpp
commands/renamepagecommand.cpp
commands/updatecolorcommand.cpp
commands/updatecolorinfocommand.cpp
)
target_sources(
NostalgiaCore-Studio-ImGui PRIVATE
paletteeditor-imgui.cpp
)

View File

@ -1,83 +0,0 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "drawcommand.hpp"
namespace nostalgia::core {
DrawCommand::DrawCommand(
TileSheet &img,
TileSheet::SubSheetIdx subSheetIdx,
std::size_t idx,
int palIdx) noexcept:
m_img(img),
m_subSheetIdx(std::move(subSheetIdx)),
m_palIdx(palIdx) {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(subsheet, m_img.bpp, idx));
}
DrawCommand::DrawCommand(
TileSheet &img,
TileSheet::SubSheetIdx subSheetIdx,
ox::Vector<std::size_t> const&idxList,
int palIdx) noexcept:
m_img(img),
m_subSheetIdx(std::move(subSheetIdx)),
m_palIdx(palIdx) {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
for (auto const idx : idxList) {
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(subsheet, m_img.bpp, idx));
}
}
bool DrawCommand::append(std::size_t idx) noexcept {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
if (m_changes.back().value->idx != idx && getPixel(subsheet, m_img.bpp, idx) != m_palIdx) {
// duplicate entries are bad
auto existing = ox::find_if(m_changes.cbegin(), m_changes.cend(), [idx](auto const&c) {
return c.idx == idx;
});
if (existing == m_changes.cend()) {
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(subsheet, m_img.bpp, idx));
setPixel(subsheet, m_img.bpp, idx, static_cast<uint8_t>(m_palIdx));
return true;
}
}
return false;
}
bool DrawCommand::append(ox::Vector<std::size_t> const&idxList) noexcept {
auto out = false;
for (auto idx : idxList) {
out = append(idx) || out;
}
return out;
}
ox::Error DrawCommand::redo() noexcept {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
for (auto const&c : m_changes) {
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(m_palIdx));
}
return {};
}
ox::Error DrawCommand::undo() noexcept {
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
for (auto const&c : m_changes) {
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.oldPalIdx));
}
return {};
}
int DrawCommand::commandId() const noexcept {
return static_cast<int>(CommandId::Draw);
}
TileSheet::SubSheetIdx const&DrawCommand::subsheetIdx() const noexcept {
return m_subSheetIdx;
}
}

View File

@ -1,11 +0,0 @@
add_executable(
NostalgiaCoreTest
tests.cpp
)
target_link_libraries(
NostalgiaCoreTest
NostalgiaCore
)
add_test("[NostalgiaCore] readWriteTileSheet" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NostalgiaCoreTest readWriteTileSheet)

View File

@ -7,12 +7,12 @@
#include <ox/std/math.hpp>
#include <ox/std/types.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
using Color16 = uint16_t;
/**
* Nostalgia Core logically uses 16 bit colors, but must translate that to 32
* Nostalgia logically uses 16 bit colors, but must translate that to 32
* bit colors in some implementations.
*/
using Color32 = uint32_t;
@ -154,7 +154,7 @@ static_assert(color16(16, 32, 8) == 9200);
[[nodiscard]]
constexpr Color16 applySelectionColor(Color16 const color) noexcept {
namespace core = nostalgia::core;
namespace core = nostalgia::gfx;
auto const r = core::red16(color) / 2;
auto const g = (core::green16(color) + 20) / 2;
auto const b = (core::blue16(color) + 31) / 2;

View File

@ -6,13 +6,14 @@
#include <ox/std/stringliteral.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
constexpr auto TileWidth = 8;
constexpr auto TileHeight = 8;
constexpr auto PixelsPerTile = TileWidth * TileHeight;
constexpr ox::StringLiteral FileExt_ng("ng");
constexpr ox::StringLiteral FileExt_nts("nts");
constexpr ox::StringLiteral FileExt_npal("npal");
}

View File

@ -4,24 +4,19 @@
#pragma once
#include <ox/fs/fs.hpp>
#include <ox/model/desctypes.hpp>
#include <ox/std/buffer.hpp>
#include <ox/std/size.hpp>
#include <ox/std/memory.hpp>
#include <turbine/context.hpp>
#include "initparams.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
class Context;
void safeDelete(Context *ctx) noexcept;
using ContextUPtr = ox::UPtr<Context>;
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const&params = {}) noexcept;
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const&params = {}) noexcept;
keel::Context &keelCtx(Context &ctx) noexcept;

View File

@ -13,10 +13,10 @@
#include "palette.hpp"
#include "tilesheet.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
struct Sprite {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Sprite";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.Sprite";
static constexpr auto TypeVersion = 1;
bool enabled = false;
int x = 0;
@ -46,7 +46,7 @@ OX_MODEL_BEGIN(Sprite)
OX_MODEL_END()
struct BgTile {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.BgTile";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.BgTile";
static constexpr auto TypeVersion = 1;
unsigned tileIdx = 0;
unsigned palBank = 0;
@ -62,7 +62,7 @@ OX_MODEL_BEGIN(BgTile)
OX_MODEL_END()
struct TileSheetSetEntrySection {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntrySection";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntrySection";
static constexpr auto TypeVersion = 1;
int32_t begin = 0;
int32_t tiles = 0;
@ -78,7 +78,7 @@ OX_MODEL_BEGIN(TileSheetSetEntrySection)
OX_MODEL_END()
struct TileSheetSetEntry {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntry";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntry";
static constexpr auto TypeVersion = 1;
ox::FileAddress tilesheet;
ox::Vector<TileSheetSetEntrySection> sections;
@ -90,7 +90,7 @@ OX_MODEL_BEGIN(TileSheetSetEntry)
OX_MODEL_END()
struct TileSheetSet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSet";
static constexpr auto TypeVersion = 1;
static constexpr auto Preloadable = true;
int32_t bpp = 0;
@ -242,15 +242,15 @@ void puts(Context &ctx, int column, int row, ox::StringViewCR str) noexcept;
}
namespace nostalgia::core::gl {
namespace nostalgia::gfx::gl {
constexpr ox::CStringView GlslVersion = "#version 330";
[[nodiscard]]
ox::Size drawSize(int scale = 5) noexcept;
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept;
void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept;
void draw(core::Context&, int scale = 5) noexcept;
void draw(gfx::Context&, int scale = 5) noexcept;
}

View File

@ -6,7 +6,7 @@
#include <ox/std/types.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
struct InitParams {
bool glInstallDrawer = true;

View File

@ -6,7 +6,7 @@
#include <keel/module.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
const keel::Module *keelModule() noexcept;

View File

@ -11,7 +11,7 @@
#include "color.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
struct PaletteColorV1 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.PaletteColor";
@ -33,7 +33,31 @@ OX_MODEL_BEGIN(PaletteColorV1)
OX_MODEL_FIELD(a)
OX_MODEL_END()
using PaletteColor = PaletteColorV1;
struct PaletteColorV2 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.PaletteColor";
static constexpr auto TypeVersion = 2;
uint8_t r{}, g{}, b{}, a{};
constexpr PaletteColorV2() noexcept = default;
constexpr PaletteColorV2(Color16 const c) noexcept:
r{red16(c)},
g{green16(c)},
b{blue16(c)},
a{alpha16(c)} {}
constexpr PaletteColorV2(uint8_t const r, uint8_t const g, uint8_t const b, uint8_t const a) noexcept:
r{r}, g{g}, b{b}, a{a} {}
constexpr operator Color16() const noexcept { return color16(r, g, b, a); }
};
OX_MODEL_BEGIN(PaletteColorV2)
OX_MODEL_FIELD(r)
OX_MODEL_FIELD(g)
OX_MODEL_FIELD(b)
OX_MODEL_FIELD(a)
OX_MODEL_END()
using PaletteColor = PaletteColorV2;
struct PalettePageV1 {
@ -58,7 +82,31 @@ OX_MODEL_BEGIN(PalettePageV1)
OX_MODEL_FIELD(colors)
OX_MODEL_END()
using PalettePage = PalettePageV1;
struct PalettePageV2 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.Palette.PalettePage";
static constexpr auto TypeVersion = 2;
ox::String name;
ox::Vector<PaletteColorV2> colors;
constexpr PalettePageV2() noexcept = default;
constexpr PalettePageV2(ox::StringParam pName, ox::Vector<PaletteColorV2> pColors) noexcept:
name(std::move(pName)), colors(std::move(pColors)) {}
constexpr PalettePageV2(ox::StringParam pName, ox::Vector<Color16> const&pColors) noexcept:
name(std::move(pName)) {
colors.reserve(pColors.size());
for (auto const c : pColors) {
colors.emplace_back(c);
}
}
};
OX_MODEL_BEGIN(PalettePageV2)
OX_MODEL_FIELD(name)
OX_MODEL_FIELD(colors)
OX_MODEL_END()
using PalettePage = PalettePageV2;
struct NostalgiaPalette {
@ -166,11 +214,41 @@ constexpr ox::Error repair(PaletteV4 &p) noexcept {
}
using Palette = PaletteV4;
struct PaletteV5 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.Palette";
static constexpr auto TypeVersion = 5;
static constexpr auto Preloadable = true;
ox::Vector<ox::String> colorNames;
ox::Vector<PalettePageV2> pages;
};
OX_MODEL_BEGIN(PaletteV5)
OX_MODEL_FIELD(colorNames)
OX_MODEL_FIELD(pages)
OX_MODEL_END()
[[nodiscard]]
constexpr bool valid(PaletteV5 const&p) noexcept {
auto const colors = p.colorNames.size();
return ox::all_of(p.pages.begin(), p.pages.end(), [colors](PalettePageV2 const&page) {
return page.colors.size() == colors;
});
}
constexpr ox::Error repair(PaletteV5 &p) noexcept {
auto const colors = p.colorNames.size();
for (auto &page : p.pages) {
page.colors.resize(colors);
}
return {};
}
using Palette = PaletteV5;
struct CompactPaletteV1 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactPalette";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.CompactPalette";
static constexpr auto TypeVersion = 1;
static constexpr auto Preloadable = true;
ox::Vector<ox::Vector<Color16>> pages{};
@ -207,7 +285,7 @@ using CompactPalette = CompactPaletteV1;
[[nodiscard]]
constexpr Color16 color(Palette const&pal, size_t page, size_t idx) noexcept {
constexpr Color16 color(Palette const&pal, size_t const page, size_t const idx) noexcept {
if (page < pal.pages.size() && idx < pal.pages[page].colors.size()) [[likely]] {
return pal.pages[page].colors[idx];
}
@ -215,7 +293,7 @@ constexpr Color16 color(Palette const&pal, size_t page, size_t idx) noexcept {
}
[[nodiscard]]
constexpr Color16 color(CompactPalette const&pal, size_t page, size_t idx) noexcept {
constexpr Color16 color(CompactPalette const&pal, size_t const page, size_t const idx) noexcept {
if (page < pal.pages.size() && idx < pal.pages[page].size()) [[likely]] {
return pal.pages[page][idx];
}
@ -223,37 +301,37 @@ constexpr Color16 color(CompactPalette const&pal, size_t page, size_t idx) noexc
}
[[nodiscard]]
constexpr Color16 color(Palette const&pal, size_t idx) noexcept {
constexpr Color16 color(Palette const&pal, size_t const idx) noexcept {
return color(pal, 0, idx);
}
[[nodiscard]]
constexpr Color16 color(CompactPalette const&pal, size_t idx) noexcept {
constexpr Color16 color(CompactPalette const&pal, size_t const idx) noexcept {
return color(pal, 0, idx);
}
[[nodiscard]]
constexpr auto &colors(Palette &pal, size_t page = 0) noexcept {
constexpr auto &colors(Palette &pal, size_t const page = 0) noexcept {
return pal.pages[page].colors;
}
[[nodiscard]]
constexpr auto &colors(CompactPalette &pal, size_t page = 0) noexcept {
constexpr auto &colors(CompactPalette &pal, size_t const page = 0) noexcept {
return pal.pages[page];
}
[[nodiscard]]
constexpr auto &colors(Palette const&pal, size_t page = 0) noexcept {
constexpr auto &colors(Palette const&pal, size_t const page = 0) noexcept {
return pal.pages[page];
}
[[nodiscard]]
constexpr auto &colors(CompactPalette const&pal, size_t page = 0) noexcept {
constexpr auto &colors(CompactPalette const&pal, size_t const page = 0) noexcept {
return pal.pages[page];
}
[[nodiscard]]
constexpr size_t colorCnt(Palette const&pal, size_t page = 0) noexcept {
constexpr size_t colorCnt(Palette const&pal, size_t const page = 0) noexcept {
if (page < pal.pages.size()) [[likely]] {
return pal.pages[page].colors.size();
}
@ -261,7 +339,7 @@ constexpr size_t colorCnt(Palette const&pal, size_t page = 0) noexcept {
}
[[nodiscard]]
constexpr size_t colorCnt(CompactPalette const&pal, size_t page = 0) noexcept {
constexpr size_t colorCnt(CompactPalette const&pal, size_t const page = 0) noexcept {
if (page < pal.pages.size()) [[likely]] {
return pal.pages[page].size();
}

View File

@ -8,7 +8,7 @@
#include "consts.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
[[nodiscard]]
constexpr std::size_t ptToIdx(int x, int y, int c, int scale = 1) noexcept {

View File

@ -6,7 +6,7 @@
#include <studio/studio.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
const studio::Module *studioModule() noexcept;

View File

@ -5,35 +5,16 @@
#pragma once
#include <ox/fs/fs.hpp>
#include <ox/std/array.hpp>
#include <ox/std/point.hpp>
#include <ox/std/size.hpp>
#include <ox/std/span.hpp>
#include <ox/std/types.hpp>
#include <ox/model/def.hpp>
#include <nostalgia/core/ptidxconv.hpp>
#include <nostalgia/gfx/ptidxconv.hpp>
#include "palette.hpp"
namespace nostalgia::core {
struct SubSheetTemplate {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.SubSheetTemplate";
static constexpr auto TypeVersion = 1;
ox::String name;
int32_t width{};
int32_t height{};
ox::Vector<SubSheetTemplate> subsheets;
};
OX_MODEL_BEGIN(SubSheetTemplate)
OX_MODEL_FIELD(name)
OX_MODEL_FIELD(width)
OX_MODEL_FIELD(height)
OX_MODEL_FIELD(subsheets)
OX_MODEL_END()
namespace nostalgia::gfx {
// Predecessor to TileSheet, kept for backward compatibility
struct TileSheetV1 {
@ -54,7 +35,7 @@ constexpr bool valid(TileSheetV1 const&ts) noexcept {
return (ts.bpp == 4 || ts.bpp == 8) && ts.pixels.size() == bytes;
}
constexpr ox::Error repair(TileSheetV1 &ts, int bpp) noexcept {
constexpr ox::Error repair(TileSheetV1 &ts, int const bpp) noexcept {
auto const bytes = static_cast<size_t>(ts.columns * ts.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
ts.pixels.resize(bytes);
return {};
@ -103,7 +84,7 @@ constexpr bool valid(TileSheetV2 const&ts) noexcept {
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
}
constexpr void repair(TileSheetV2::SubSheet &ss, int bpp) noexcept {
constexpr void repair(TileSheetV2::SubSheet &ss, int const bpp) noexcept {
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
ss.pixels.resize(bytes);
for (auto &s : ss.subsheets) {
@ -173,7 +154,7 @@ constexpr bool valid(TileSheetV3 const&ts) noexcept {
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
}
constexpr void repair(TileSheetV3::SubSheet &ss, int bpp) noexcept {
constexpr void repair(TileSheetV3::SubSheet &ss, int const bpp) noexcept {
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
ss.pixels.resize(bytes);
for (auto &s : ss.subsheets) {
@ -267,7 +248,7 @@ constexpr bool valid(TileSheetV4 const&ts) noexcept {
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet, ts.bpp);
}
constexpr void repair(TileSheetV4::SubSheet &ss, int bpp) noexcept {
constexpr void repair(TileSheetV4::SubSheet &ss, int const bpp) noexcept {
if (ss.subsheets.empty()) {
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) / (bpp == 4 ? 2 : 1);
ss.pixels.resize(bytes);
@ -290,7 +271,109 @@ constexpr ox::Error repair(TileSheetV4 &ts) noexcept {
}
using TileSheet = TileSheetV4;
struct TileSheetV5 {
using SubSheetIdx = ox::Vector<uint32_t, 4>;
struct SubSheet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet";
static constexpr auto TypeVersion = 5;
SubSheetId id = 0;
ox::String name;
int columns = 0;
int rows = 0;
ox::Vector<SubSheet> subsheets;
ox::Vector<uint8_t> pixels;
constexpr SubSheet() noexcept = default;
SubSheet(
SubSheetId const pId,
ox::StringParam pName,
int const pColumns,
int const pRows) noexcept:
id(pId),
name(std::move(pName)),
columns(pColumns),
rows(pRows),
pixels(static_cast<std::size_t>(columns * rows * PixelsPerTile)) {
}
SubSheet(
SubSheetId const pId,
ox::StringParam pName,
int const pColumns,
int const pRows,
ox::Vector<uint8_t> pPixels) noexcept:
id(pId),
name(std::move(pName)),
columns(pColumns),
rows(pRows),
pixels(std::move(pPixels)) {
}
/**
*
* @return the dimensional size of the SubSheet (e.g. width * height)
*/
[[nodiscard]]
constexpr std::size_t size() const noexcept {
return static_cast<std::size_t>(columns) * static_cast<std::size_t>(rows);
}
};
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheet";
static constexpr auto TypeVersion = 5;
/**
* bpp is unused for TileSheet, but it does get used in CompactTileSheet.
* All pixel in TileSheet are 8 bpp, regardless of what the bpp field says.
*/
int8_t bpp = 4;
SubSheetId idIt = 0;
ox::String defaultPalette;
SubSheet subsheet{0, "Root", 1, 1};
};
[[nodiscard]]
constexpr bool valid(TileSheetV5::SubSheet const&ss) noexcept {
if (ss.subsheets.empty()) {
return static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile) == ss.pixels.size();
} else {
return ss.pixels.empty() && ox::all_of(ss.subsheets.begin(), ss.subsheets.end(),
[](TileSheetV5::SubSheet const&s) {
return valid(s);
});
}
}
[[nodiscard]]
constexpr bool valid(TileSheetV5 const&ts) noexcept {
return (ts.bpp == 4 || ts.bpp == 8) && valid(ts.subsheet);
}
constexpr void repair(TileSheetV5::SubSheet &ss) noexcept {
if (ss.subsheets.empty()) {
auto const bytes = static_cast<size_t>(ss.columns * ss.rows * PixelsPerTile);
ss.pixels.resize(bytes);
} else {
ss.pixels.clear();
ss.columns = -1;
ss.rows = -1;
}
for (auto &s : ss.subsheets) {
repair(s);
}
}
constexpr ox::Error repair(TileSheetV5 &ts) noexcept {
if (ts.bpp != 4 && ts.bpp != 8) {
return ox::Error{1, "Unable to repair TileSheet"};
}
repair(ts.subsheet);
return {};
}
using TileSheet = TileSheetV5;
[[nodiscard]]
std::size_t idx(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept;
@ -305,97 +388,66 @@ TileSheet::SubSheet const*getSubsheet(TileSheet const&ts, SubSheetId id) noexcep
ox::Optional<size_t> getTileIdx(TileSheet const&ts, SubSheetId id) noexcept;
[[nodiscard]]
uint8_t getPixel4Bpp(TileSheet::SubSheet const&ss, std::size_t idx) noexcept;
uint8_t getPixel(TileSheet::SubSheet const&ss, std::size_t idx) noexcept;
[[nodiscard]]
uint8_t getPixel8Bpp(TileSheet::SubSheet const&ss, std::size_t idx) noexcept;
uint8_t getPixel(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept;
[[nodiscard]]
uint8_t getPixel(TileSheet::SubSheet const&ss, int8_t pBpp, std::size_t idx) noexcept;
void setPixel(TileSheet::SubSheet &ss, ox::Point const&pt, uint8_t palIdx) noexcept;
[[nodiscard]]
uint8_t getPixel4Bpp(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept;
ox::Error setPixelCount(TileSheet::SubSheet &ss, std::size_t cnt) noexcept;
[[nodiscard]]
uint8_t getPixel8Bpp(TileSheet::SubSheet const&ss, ox::Point const&pt) noexcept;
void flipX(TileSheet::SubSheet &ss, ox::Point const &a, ox::Point const &b) noexcept;
[[nodiscard]]
uint8_t getPixel(TileSheet::SubSheet const&ss, int8_t pBpp, ox::Point const&pt) noexcept;
constexpr void walkPixels(TileSheet::SubSheet const&ss, int8_t pBpp, auto callback) noexcept {
if (pBpp == 4) {
const auto pixelCnt = ox::min<std::size_t>(
static_cast<std::size_t>(ss.columns * ss.rows * PixelsPerTile) / 2,
ss.pixels.size());
//oxAssert(pixels.size() == pixelCnt, "Pixel count does not match rows and columns");
for (std::size_t i = 0; i < pixelCnt; ++i) {
const auto colorIdx1 = static_cast<uint8_t>(ss.pixels[i] & 0xF);
const auto colorIdx2 = static_cast<uint8_t>(ss.pixels[i] >> 4);
callback(i * 2 + 0, colorIdx1);
callback(i * 2 + 1, colorIdx2);
}
} else {
const auto pixelCnt = ox::min<std::size_t>(
static_cast<std::size_t>(ss.columns * ss.rows * PixelsPerTile),
ss.pixels.size());
for (std::size_t i = 0; i < pixelCnt; ++i) {
const auto p = ss.pixels[i];
callback(i, p);
}
}
}
void setPixel(TileSheet::SubSheet &ss, int8_t pBpp, uint64_t idx, uint8_t palIdx) noexcept;
void setPixel(TileSheet::SubSheet &ss, int8_t pBpp, ox::Point const&pt, uint8_t palIdx) noexcept;
ox::Error setPixelCount(TileSheet::SubSheet &ss, int8_t pBpp, std::size_t cnt) noexcept;
void flipY(TileSheet::SubSheet &ss, ox::Point const &a, ox::Point const &b) noexcept;
/**
* Gets a count of the pixels in this sheet, and not that of its children.
* @param pBpp bits per pixel, need for knowing how to count the pixels
* @return a count of the pixels in this sheet
*/
[[nodiscard]]
unsigned pixelCnt(TileSheet::SubSheet const&ss, int8_t pBpp) noexcept;
unsigned pixelCnt(TileSheet::SubSheet const&ss) noexcept;
/**
*
* @param ss
* @param pBpp
* @param sz size of Subsheet in tiles (not pixels)
*/
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, int8_t pBpp, ox::Size const&sz) noexcept;
ox::Error resizeSubsheet(TileSheet::SubSheet &ss, ox::Size const&sz) noexcept;
/**
* validateSubSheetIdx takes a SubSheetIdx and moves the index to the
* preceding or parent sheet if the current corresponding sheet does
* not exist.
* @param ts
* @param idx SubSheetIdx to validate and correct
* @return a valid version of idx
*/
[[nodiscard]]
TileSheet::SubSheetIdx validateSubSheetIdx(TileSheet const&ts, TileSheet::SubSheetIdx idx) noexcept;
[[nodiscard]]
TileSheet::SubSheet const&getSubSheet(
TileSheet::SubSheetIdx const&idx,
std::size_t idxIt,
TileSheet::SubSheet const&pSubsheet) noexcept;
[[nodiscard]]
TileSheet::SubSheet &getSubSheet(
TileSheet::SubSheetIdx const&idx,
ox::SpanView<uint32_t> const&idx,
std::size_t idxIt,
TileSheet::SubSheet &pSubsheet) noexcept;
#if defined(__GNUC__) && __GNUC__ >= 13
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
[[nodiscard]]
TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, TileSheet::SubSheetIdx const&idx) noexcept;
TileSheet::SubSheet const&getSubSheet(TileSheet const&ts, ox::SpanView<uint32_t> const &idx) noexcept;
[[nodiscard]]
TileSheet::SubSheet &getSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept;
TileSheet::SubSheet &getSubSheet(TileSheet &ts, ox::SpanView<uint32_t> const &idx) noexcept;
#if defined(__GNUC__) && __GNUC__ >= 13
#pragma GCC diagnostic pop
#endif
ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept;
ox::Error addSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const &idx) noexcept;
ox::Error insertSubSheet(TileSheet &ts, ox::SpanView<uint32_t> const &idx, TileSheet::SubSheet ss) noexcept;
ox::Error rmSubSheet(
TileSheet &ts,
@ -406,13 +458,7 @@ ox::Error rmSubSheet(
ox::Error rmSubSheet(TileSheet &ts, TileSheet::SubSheetIdx const&idx) noexcept;
[[nodiscard]]
uint8_t getPixel4Bpp(
TileSheet const&ts,
ox::Point const&pt,
TileSheet::SubSheetIdx const&subsheetIdx) noexcept;
[[nodiscard]]
uint8_t getPixel8Bpp(
uint8_t getPixel(
TileSheet const&ts,
ox::Point const&pt,
TileSheet::SubSheetIdx const&subsheetIdx) noexcept;
@ -432,7 +478,7 @@ ox::Vector<uint8_t> pixels(TileSheet &ts) noexcept;
struct CompactTileSheetV1 {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.CompactTileSheet";
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.CompactTileSheet";
static constexpr auto TypeVersion = 1;
static constexpr auto Preloadable = true;
int8_t bpp = 0;
@ -522,6 +568,22 @@ OX_MODEL_BEGIN(TileSheetV4)
OX_MODEL_FIELD(subsheet)
OX_MODEL_END()
OX_MODEL_BEGIN(TileSheetV5::SubSheet)
OX_MODEL_FIELD(id)
OX_MODEL_FIELD(name)
OX_MODEL_FIELD(rows)
OX_MODEL_FIELD(columns)
OX_MODEL_FIELD(subsheets)
OX_MODEL_FIELD(pixels)
OX_MODEL_END()
OX_MODEL_BEGIN(TileSheetV5)
OX_MODEL_FIELD(bpp)
OX_MODEL_FIELD(idIt)
OX_MODEL_FIELD(defaultPalette)
OX_MODEL_FIELD(subsheet)
OX_MODEL_END()
OX_MODEL_BEGIN(CompactTileSheetV1)
OX_MODEL_FIELD(bpp)
OX_MODEL_FIELD(defaultPalette)

View File

@ -1,5 +1,5 @@
add_library(
NostalgiaCore
NostalgiaGfx
gfx.cpp
tilesheet.cpp
)
@ -10,12 +10,12 @@ if(NOT BUILDCORE_TARGET STREQUAL "gba")
endif()
target_include_directories(
NostalgiaCore PUBLIC
NostalgiaGfx PUBLIC
../include
)
target_link_libraries(
NostalgiaCore PUBLIC
NostalgiaGfx PUBLIC
Turbine
)
@ -26,7 +26,7 @@ endif()
install(
TARGETS
NostalgiaCore
NostalgiaGfx
DESTINATION
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib

View File

@ -1,15 +1,15 @@
add_library(
NostalgiaCore-GBA OBJECT
NostalgiaGfx-GBA OBJECT
context.cpp
gfx.cpp
panic.cpp
)
target_include_directories(
NostalgiaCore-GBA PUBLIC
NostalgiaGfx-GBA PUBLIC
../../include
)
target_link_libraries(
NostalgiaCore-GBA PUBLIC
NostalgiaGfx-GBA PUBLIC
TeaGBA
Keel
Turbine
@ -17,5 +17,5 @@ target_link_libraries(
if(BUILDCORE_TARGET STREQUAL "gba")
set_source_files_properties(gfx.cpp PROPERTIES COMPILE_FLAGS -marm)
target_link_libraries(NostalgiaCore PUBLIC NostalgiaCore-GBA)
target_link_libraries(NostalgiaGfx PUBLIC NostalgiaGfx-GBA)
endif()

View File

@ -4,11 +4,11 @@
#include <turbine/turbine.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/gfx/gfx.hpp>
#include "context.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
void safeDelete(Context *ctx) noexcept {
delete ctx;
@ -19,10 +19,10 @@ Context::Context(turbine::Context &tctx) noexcept: turbineCtx(tctx) {
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const&params) noexcept {
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const&params) noexcept {
auto ctx = ox::make_unique<Context>(tctx);
OX_RETURN_ERROR(initGfx(*ctx, params));
return ContextUPtr(std::move(ctx));
return ox::UPtr<Context>(std::move(ctx));
}
keel::Context &keelCtx(Context &ctx) noexcept {
@ -33,4 +33,4 @@ turbine::Context &turbineCtx(Context &ctx) noexcept {
return ctx.turbineCtx;
}
}
}

View File

@ -4,9 +4,9 @@
#pragma once
#include <nostalgia/core/context.hpp>
#include <nostalgia/gfx/context.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
struct BgCbbData {
unsigned bpp = 4;

View File

@ -11,15 +11,15 @@
#include <keel/keel.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include <nostalgia/gfx/context.hpp>
#include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/gfx/tilesheet.hpp>
#include "context.hpp"
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
namespace nostalgia::core {
namespace nostalgia::gfx {
static constexpr auto SpriteCount = 128;

View File

@ -4,8 +4,8 @@
#pragma once
#include <nostalgia/core/context.hpp>
#include <nostalgia/gfx/context.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
}

View File

@ -12,7 +12,7 @@
#include <teagba/addresses.hpp>
#include <teagba/bios.hpp>
#include <nostalgia/core/core.hpp>
#include <nostalgia/gfx/core.hpp>
#include "gfx.hpp"
@ -22,7 +22,7 @@
namespace ox {
using namespace nostalgia::core;
using namespace nostalgia::gfx;
void panic(const char *file, int line, const char *panicMsg, ox::Error const&err) noexcept {
// reset heap to make sure we have enough memory to allocate context data

View File

@ -3,9 +3,9 @@
*/
#include <keel/media.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/gfx/gfx.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
constexpr auto GbaTileColumns = 32;
constexpr auto GbaTileRows = 32;

View File

@ -1,18 +1,18 @@
add_library(
NostalgiaCore-Keel
NostalgiaGfx-Keel
keelmodule.cpp
typeconv.cpp
)
target_link_libraries(
NostalgiaCore-Keel PUBLIC
NostalgiaGfx-Keel PUBLIC
Keel
NostalgiaCore
NostalgiaGfx
)
install(
TARGETS
NostalgiaCore-Keel
NostalgiaGfx-Keel
DESTINATION
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib

View File

@ -4,15 +4,14 @@
#include <ox/model/model.hpp>
#include <keel/asset.hpp>
#include <keel/module.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include <nostalgia/gfx/palette.hpp>
#include <nostalgia/gfx/tilesheet.hpp>
#include "typeconv.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
static class: public keel::Module {
private:
@ -20,16 +19,18 @@ static class: public keel::Module {
PaletteV1ToPaletteV2Converter m_paletteV1ToPaletteV2Converter;
PaletteV2ToPaletteV3Converter m_paletteV2ToPaletteV3Converter;
PaletteV3ToPaletteV4Converter m_paletteV3ToPaletteV4Converter;
PaletteV4ToPaletteV5Converter m_paletteV4ToPaletteV5Converter;
PaletteToCompactPaletteConverter m_paletteToCompactPaletteConverter;
TileSheetV1ToTileSheetV2Converter m_tileSheetV1ToTileSheetV2Converter;
TileSheetV2ToTileSheetV3Converter m_tileSheetV2ToTileSheetV3Converter;
TileSheetV3ToTileSheetV4Converter m_tileSheetV3ToTileSheetV4Converter;
TileSheetV4ToTileSheetV5Converter m_tileSheetV4ToTileSheetV5Converter;
TileSheetToCompactTileSheetConverter m_tileSheetToCompactTileSheetConverter;
public:
[[nodiscard]]
ox::String id() const noexcept override {
return ox::String("net.drinkingtea.nostalgia.core");
return ox::String{"net.drinkingtea.nostalgia.gfx"};
}
[[nodiscard]]
@ -39,11 +40,13 @@ static class: public keel::Module {
keel::generateTypeDesc<TileSheetV2>,
keel::generateTypeDesc<TileSheetV3>,
keel::generateTypeDesc<TileSheetV4>,
keel::generateTypeDesc<TileSheetV5>,
keel::generateTypeDesc<CompactTileSheetV1>,
keel::generateTypeDesc<PaletteV1>,
keel::generateTypeDesc<PaletteV2>,
keel::generateTypeDesc<PaletteV3>,
keel::generateTypeDesc<PaletteV4>,
keel::generateTypeDesc<PaletteV5>,
keel::generateTypeDesc<CompactPaletteV1>,
};
}
@ -55,10 +58,12 @@ static class: public keel::Module {
&m_paletteV1ToPaletteV2Converter,
&m_paletteV2ToPaletteV3Converter,
&m_paletteV3ToPaletteV4Converter,
&m_paletteV4ToPaletteV5Converter,
&m_paletteToCompactPaletteConverter,
&m_tileSheetV1ToTileSheetV2Converter,
&m_tileSheetV2ToTileSheetV3Converter,
&m_tileSheetV3ToTileSheetV4Converter,
&m_tileSheetV4ToTileSheetV5Converter,
&m_tileSheetToCompactTileSheetConverter,
};
}
@ -71,7 +76,8 @@ static class: public keel::Module {
if (typeId == ox::ModelTypeId_v<TileSheetV1> ||
typeId == ox::ModelTypeId_v<TileSheetV2> ||
typeId == ox::ModelTypeId_v<TileSheetV3> ||
typeId == ox::ModelTypeId_v<TileSheetV4>) {
typeId == ox::ModelTypeId_v<TileSheetV4> ||
typeId == ox::ModelTypeId_v<TileSheetV5>) {
OX_RETURN_ERROR(keel::convertBuffToBuff<CompactTileSheet>(
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
return true;
@ -83,7 +89,8 @@ static class: public keel::Module {
typeId == ox::ModelTypeId_v<PaletteV1> ||
typeId == ox::ModelTypeId_v<PaletteV2> ||
typeId == ox::ModelTypeId_v<PaletteV3> ||
typeId == ox::ModelTypeId_v<PaletteV4>) {
typeId == ox::ModelTypeId_v<PaletteV4> ||
typeId == ox::ModelTypeId_v<PaletteV5>) {
OX_RETURN_ERROR(keel::convertBuffToBuff<CompactPalette>(
ctx, buff, ox::ClawFormat::Metal).moveTo(buff));
return true;
@ -92,6 +99,7 @@ static class: public keel::Module {
},
};
}
} const mod;
keel::Module const*keelModule() noexcept {

View File

@ -4,7 +4,7 @@
#include "typeconv.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
ox::Error NostalgiaPaletteToPaletteV1Converter::convert(
keel::Context&,
@ -52,6 +52,26 @@ ox::Error PaletteV3ToPaletteV4Converter::convert(
return {};
}
ox::Error PaletteV4ToPaletteV5Converter::convert(
keel::Context&,
PaletteV4 &src,
PaletteV5 &dst) const noexcept {
dst.colorNames = std::move(src.colorNames);
dst.pages.reserve(src.pages.size());
for (auto &s : src.pages) {
ox::Vector<PaletteColorV2> colors;
colors.reserve(s.colors.size());
for (auto const&c : s.colors) {
colors.emplace_back(c.r, c.g, c.b, c.a);
}
dst.pages.emplace_back(PalettePageV2{
std::move(s.name),
std::move(colors),
});
}
return {};
}
ox::Error PaletteToCompactPaletteConverter::convert(
keel::Context&,
Palette &src,
@ -133,12 +153,50 @@ ox::Error TileSheetV3ToTileSheetV4Converter::convert(
return {};
}
void TileSheetV4ToTileSheetV5Converter::convertSubsheet(
int const bpp,
TileSheetV4::SubSheet &src,
TileSheetV5::SubSheet &dst) noexcept {
dst.id = src.id;
dst.name = std::move(src.name);
dst.columns = src.columns;
dst.rows = src.rows;
if (bpp == 4) {
dst.pixels.reserve(2 * src.pixels.size());
dst.pixels.resize(0);
for (auto const p : src.pixels) {
dst.pixels.emplace_back(static_cast<uint8_t>(p & 0xf));
dst.pixels.emplace_back(static_cast<uint8_t>(p >> 4));
}
oxAssert(dst.pixels.size() == src.pixels.size() * 2, "mismatch");
} else {
dst.pixels = std::move(src.pixels);
}
dst.subsheets.resize(src.subsheets.size());
for (auto i = 0u; i < src.subsheets.size(); ++i) {
convertSubsheet(bpp, src.subsheets[i], dst.subsheets[i]);
}
}
ox::Error TileSheetV4ToTileSheetV5Converter::convert(
keel::Context&,
TileSheetV4 &src,
TileSheetV5 &dst) const noexcept {
dst.bpp = src.bpp;
dst.idIt = src.idIt;
OX_RETURN_ERROR(src.defaultPalette.getPath().moveTo(dst.defaultPalette));
convertSubsheet(dst.bpp, src.subsheet, dst.subsheet);
return {};
}
ox::Error TileSheetToCompactTileSheetConverter::convert(
keel::Context&,
TileSheet &src,
CompactTileSheet &dst) const noexcept {
dst.bpp = src.bpp;
dst.defaultPalette = std::move(src.defaultPalette);
dst.defaultPalette = ox::FileAddress{src.defaultPalette};
dst.pixels = pixels(src);
return {};
}

View File

@ -8,11 +8,11 @@
#include <keel/typeconv.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include <nostalgia/gfx/context.hpp>
#include <nostalgia/gfx/palette.hpp>
#include <nostalgia/gfx/tilesheet.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
// Type converters
@ -21,15 +21,19 @@ class NostalgiaPaletteToPaletteV1Converter: public keel::Converter<NostalgiaPale
};
class PaletteV1ToPaletteV2Converter: public keel::Converter<PaletteV1, PaletteV2> {
ox::Error convert(keel::Context&, PaletteV1 &src, PaletteV2 &dst) const noexcept final;
ox::Error convert(keel::Context&, PaletteV1 &src, PaletteV2 &dst) const noexcept final;
};
class PaletteV2ToPaletteV3Converter: public keel::Converter<PaletteV2, PaletteV3> {
ox::Error convert(keel::Context&, PaletteV2 &src, PaletteV3 &dst) const noexcept final;
ox::Error convert(keel::Context&, PaletteV2 &src, PaletteV3 &dst) const noexcept final;
};
class PaletteV3ToPaletteV4Converter: public keel::Converter<PaletteV3, PaletteV4> {
ox::Error convert(keel::Context&, PaletteV3 &src, PaletteV4 &dst) const noexcept final;
ox::Error convert(keel::Context&, PaletteV3 &src, PaletteV4 &dst) const noexcept final;
};
class PaletteV4ToPaletteV5Converter: public keel::Converter<PaletteV4, PaletteV5> {
ox::Error convert(keel::Context&, PaletteV4 &src, PaletteV5 &dst) const noexcept final;
};
class PaletteToCompactPaletteConverter: public keel::Converter<Palette, CompactPalette> {
@ -56,6 +60,14 @@ class TileSheetV3ToTileSheetV4Converter: public keel::Converter<TileSheetV3, Til
ox::Error convert(keel::Context&, TileSheetV3 &src, TileSheetV4 &dst) const noexcept final;
};
class TileSheetV4ToTileSheetV5Converter final: public keel::Converter<TileSheetV4, TileSheetV5> {
static void convertSubsheet(
int bpp,
TileSheetV4::SubSheet &src,
TileSheetV5::SubSheet &dst) noexcept;
ox::Error convert(keel::Context&, TileSheetV4 &src, TileSheetV5 &dst) const noexcept override;
};
class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
ox::Error convert(keel::Context&, TileSheet &src, CompactTileSheet &dst) const noexcept final;
};

View File

@ -1,9 +1,9 @@
target_sources(
NostalgiaCore PRIVATE
NostalgiaGfx PRIVATE
context.cpp
gfx.cpp
)
target_link_libraries(
NostalgiaCore PUBLIC
NostalgiaGfx PUBLIC
GlUtils
)

View File

@ -5,7 +5,7 @@
#include "context.hpp"
#include "gfx.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
void safeDelete(Context *ctx) noexcept {
delete ctx;
@ -23,10 +23,10 @@ Context::~Context() noexcept {
shutdownGfx(*this);
}
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const&params) noexcept {
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const&params) noexcept {
auto ctx = ox::make_unique<Context>(tctx, params);
OX_RETURN_ERROR(initGfx(*ctx, params));
return ContextUPtr(ctx.release());
return ox::UPtr<Context>(ctx.release());
}
keel::Context &keelCtx(Context &ctx) noexcept {

View File

@ -8,12 +8,12 @@
#include <glutils/glutils.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/gfx/context.hpp>
#include "gfx.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
class Context {

View File

@ -10,15 +10,15 @@
#include <glutils/glutils.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/core/tilesheet.hpp>
#include <nostalgia/gfx/context.hpp>
#include <nostalgia/gfx/gfx.hpp>
#include <nostalgia/gfx/palette.hpp>
#include <nostalgia/gfx/tilesheet.hpp>
#include "context.hpp"
#include "gfx.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
namespace renderer {
@ -28,7 +28,7 @@ static constexpr auto PriorityScale = 0.01f;
Drawer::Drawer(Context &ctx) noexcept: m_ctx(ctx) {}
void Drawer::draw(turbine::Context &tctx) noexcept {
core::gl::draw(m_ctx, turbine::getScreenSize(tctx));
gfx::gl::draw(m_ctx, turbine::getScreenSize(tctx));
}
static constexpr ox::CStringView bgvshadTmpl = R"glsl(
@ -449,7 +449,7 @@ static void setSprite(
++i;
};
if (!s.flipX) {
for (auto yIt = 0; yIt < static_cast<int>(dim.y); ++yIt) {
for (auto yIt = 0u; yIt < dim.y; ++yIt) {
for (auto xIt = 0u; xIt < dim.x; ++xIt) {
set(static_cast<int>(xIt), static_cast<int>(yIt), s.enabled);
}
@ -650,7 +650,7 @@ ox::Error loadSpriteTileSheet(
CompactTileSheet const&ts,
bool loadDefaultPalette) noexcept {
OX_REQUIRE(tsd, normalizeTileSheet(ts));
oxTracef("nostalgia.core.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height);
oxTracef("nostalgia.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height);
ctx.spriteBlocks.tex = renderer::createTexture(tsd.width, tsd.height, tsd.pixels.data());
if (loadDefaultPalette) {
OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette));
@ -673,7 +673,7 @@ void setBgTile(
int row,
BgTile const&tile) noexcept {
oxTracef(
"nostalgia.core.gfx.setBgTile",
"nostalgia.gfx.setBgTile",
"bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}",
bgIdx, column, row, tile.tileIdx, tile.palBank);
const auto z = static_cast<uint_t>(bgIdx);
@ -768,7 +768,7 @@ ox::Size drawSize(int scale) noexcept {
return {240 * scale, 160 * scale};
}
void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
void draw(gfx::Context &ctx, ox::Size const&renderSz) noexcept {
glViewport(0, 0, renderSz.width, renderSz.height);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
@ -783,7 +783,7 @@ void draw(core::Context &ctx, ox::Size const&renderSz) noexcept {
glDisable(GL_BLEND);
}
void draw(core::Context &ctx, int scale) noexcept {
void draw(gfx::Context &ctx, int scale) noexcept {
draw(ctx, drawSize(scale));
}

View File

@ -10,9 +10,9 @@
#include <glutils/glutils.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/gfx/context.hpp>
namespace nostalgia::core::renderer {
namespace nostalgia::gfx::renderer {
constexpr uint64_t TileRows = 128;
constexpr uint64_t TileColumns = 128;
@ -59,7 +59,7 @@ class Drawer: public turbine::gl::Drawer {
}
namespace nostalgia::core {
namespace nostalgia::gfx {
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
void shutdownGfx(Context &ctx) noexcept;
}

View File

@ -1,25 +1,25 @@
add_library(NostalgiaCore-Studio)
add_library(NostalgiaGfx-Studio)
add_library(
NostalgiaCore-Studio-ImGui
NostalgiaGfx-Studio-ImGui
studiomodule.cpp
)
target_link_libraries(
NostalgiaCore-Studio PUBLIC
NostalgiaCore
NostalgiaGfx-Studio PUBLIC
NostalgiaGfx
Studio
)
target_link_libraries(
NostalgiaCore-Studio-ImGui PUBLIC
NostalgiaCore-Studio
NostalgiaGfx-Studio-ImGui PUBLIC
NostalgiaGfx-Studio
)
install(
TARGETS
NostalgiaCore-Studio-ImGui
NostalgiaCore-Studio
NostalgiaGfx-Studio-ImGui
NostalgiaGfx-Studio
LIBRARY DESTINATION
${NOSTALGIA_DIST_MODULE}
)

View File

@ -0,0 +1,6 @@
target_sources(
NostalgiaGfx-Studio-ImGui PRIVATE
paletteeditor-imgui.cpp
)
add_subdirectory(commands)

View File

@ -0,0 +1,15 @@
target_sources(
NostalgiaGfx-Studio PRIVATE
addcolorcommand.cpp
addpagecommand.cpp
applycolorallpagescommand.cpp
duplicatepagecommand.cpp
movecolorcommand.cpp
movepagecommand.cpp
removecolorcommand.cpp
removepagecommand.cpp
renamepagecommand.cpp
updatecolorcommand.cpp
updatecolorinfocommand.cpp
)

View File

@ -5,7 +5,7 @@
#include "commands.hpp"
#include "addcolorcommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
AddColorCommand::AddColorCommand(Palette &pal, Color16 const color, size_t const idx) noexcept:
m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class AddColorCommand: public studio::UndoCommand {
private:

View File

@ -6,7 +6,7 @@
#include "addpagecommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
AddPageCommand::AddPageCommand(Palette &pal) noexcept:
m_pal(pal) {}

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class AddPageCommand: public studio::UndoCommand {
private:

View File

@ -5,7 +5,7 @@
#include "commands.hpp"
#include "applycolorallpagescommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
ApplyColorAllPagesCommand::ApplyColorAllPagesCommand(Palette &pal, size_t const page, size_t const idx):
m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class ApplyColorAllPagesCommand: public studio::UndoCommand {
private:

View File

@ -4,7 +4,7 @@
#pragma once
namespace nostalgia::core {
namespace nostalgia::gfx {
enum class PaletteEditorCommandId {
ApplyColorAllPages,
@ -12,6 +12,7 @@ enum class PaletteEditorCommandId {
AddPage,
DuplicatePage,
RemovePage,
MovePage,
AddColor,
RemoveColor,
UpdateColorInfo,

View File

@ -6,7 +6,7 @@
#include "duplicatepagecommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
DuplicatePageCommand::DuplicatePageCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept:
m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class DuplicatePageCommand: public studio::UndoCommand {
private:

View File

@ -6,12 +6,13 @@
#include "movecolorcommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
MoveColorCommand::MoveColorCommand(
Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept:
Palette &pal,
size_t const srcIdx,
size_t const dstIdx) noexcept:
m_pal(pal),
m_page(page),
m_srcIdx(srcIdx),
m_dstIdx(dstIdx) {}
@ -29,10 +30,18 @@ ox::Error MoveColorCommand::undo() noexcept {
return {};
}
void MoveColorCommand::moveColor(size_t srcIdx, size_t dstIdx) noexcept {
auto const c = color(m_pal, m_page, srcIdx);
std::ignore = colors(m_pal, m_page).erase(srcIdx);
colors(m_pal, m_page).emplace(dstIdx, c);
void MoveColorCommand::moveColor(
size_t const srcIdx, size_t const dstIdx) noexcept {
for (size_t page{}; page < m_pal.pages.size(); ++page) {
auto const c = color(m_pal, page, srcIdx);
std::ignore = colors(m_pal, page).erase(srcIdx);
colors(m_pal, page).emplace(dstIdx, c);
}
{
auto name = std::move(m_pal.colorNames[srcIdx]);
std::ignore = m_pal.colorNames.erase(srcIdx);
m_pal.colorNames.emplace(dstIdx, std::move(name));
}
}
}

View File

@ -6,19 +6,18 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class MoveColorCommand: public studio::UndoCommand {
private:
Palette &m_pal;
size_t const m_page = 0;
std::size_t const m_srcIdx = 0;
std::size_t const m_dstIdx = 0;
public:
MoveColorCommand(Palette &pal, size_t page, size_t srcIdx, size_t dstIdx) noexcept;
MoveColorCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept;
~MoveColorCommand() noexcept override = default;

View File

@ -0,0 +1,40 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "commands.hpp"
#include "movepagecommand.hpp"
namespace nostalgia::gfx {
MovePageCommand::MovePageCommand(
Palette &pal,
size_t const srcIdx,
size_t const dstIdx) noexcept:
m_pal(pal),
m_srcIdx(srcIdx),
m_dstIdx(dstIdx) {}
int MovePageCommand::commandId() const noexcept {
return static_cast<int>(PaletteEditorCommandId::MovePage);
}
ox::Error MovePageCommand::redo() noexcept {
movePage(m_srcIdx, m_dstIdx);
return {};
}
ox::Error MovePageCommand::undo() noexcept {
movePage(m_dstIdx, m_srcIdx);
return {};
}
void MovePageCommand::movePage(
size_t const srcIdx, size_t const dstIdx) noexcept {
auto page = std::move(m_pal.pages[srcIdx]);
std::ignore = m_pal.pages.erase(srcIdx);
m_pal.pages.emplace(dstIdx, std::move(page));
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <studio/studio.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::gfx {
class MovePageCommand: public studio::UndoCommand {
private:
Palette &m_pal;
std::size_t const m_srcIdx = 0;
std::size_t const m_dstIdx = 0;
public:
MovePageCommand(Palette &pal, size_t srcIdx, size_t dstIdx) noexcept;
~MovePageCommand() noexcept override = default;
[[nodiscard]]
int commandId() const noexcept override;
ox::Error redo() noexcept override;
ox::Error undo() noexcept override;
private:
void movePage(size_t srcIdx, size_t dstIdx) noexcept;
};
}

View File

@ -5,7 +5,7 @@
#include "commands.hpp"
#include "removecolorcommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
RemoveColorCommand::RemoveColorCommand(Palette &pal, size_t const idx) noexcept:
m_pal(pal),

View File

@ -6,9 +6,9 @@
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
#include <nostalgia/gfx/palette.hpp>
namespace nostalgia::core {
namespace nostalgia::gfx {
class RemoveColorCommand: public studio::UndoCommand {
private:

View File

@ -6,7 +6,7 @@
#include "removepagecommand.hpp"
namespace nostalgia::core {
namespace nostalgia::gfx {
RemovePageCommand::RemovePageCommand(Palette &pal, size_t idx) noexcept:
m_pal(pal),

Some files were not shown because too many files have changed in this diff Show More