├── .gitignore
├── .gitmodules
├── CIE.cpp
├── CIE.h
├── COMPILE
├── COPYING
├── Contributing
├── Docs
├── Screenshots
│ ├── ImageToTilemap.png
│ └── doneImageImport.png
└── src
│ ├── SEGA_logo.png
│ └── sega.png
├── Makefile
├── Makefile.common
├── Makefile.objects
├── ManualSrc
├── Home-offline.tex
├── footer.tex
├── genManuals.py
├── genManuals_html.py
└── header.tex
├── NEUQUANT.H
├── NEUQUANT.cpp
├── README.md
├── RetroGraphicsToolkit.exe.7z
├── TMS9918.lua
├── astyle.sh
├── autogeneratedBindings
├── filereader_filereader.cpp
├── filereader_filereader.hpp
├── iqaLua.cpp
├── iqaLua.hpp
├── iqa_iqa_ms_ssim_args.cpp
├── iqa_iqa_ssim_args.cpp
├── level_levDat.cpp
├── level_levDat.h
├── level_levelInfo.cpp
├── level_levelInfo.h
├── level_levobjDat.cpp
├── level_levobjDat.h
├── undoLua.cpp
└── undoLua.h
├── callback_chunk.cpp
├── callback_chunk.h
├── callback_gui.cpp
├── callback_gui.h
├── callback_project.cpp
├── callback_project.h
├── callback_tilemap.cpp
├── callback_tilemap.h
├── callback_tiles.cpp
├── callback_tiles.h
├── callbacklua.cpp
├── callbacklua.h
├── callbacks.lua
├── callbacks_palette.cpp
├── callbacks_palette.h
├── callbacksprites.cpp
├── callbacksprites.h
├── callbacktilemaps.cpp
├── callbacktilemaps.h
├── cbHelper.cpp
├── cbHelper.h
├── classChunks.cpp
├── classChunks.h
├── classSprite.cpp
├── classSprite.h
├── classSprites.cpp
├── classSprites.h
├── class_global.cpp
├── class_global.h
├── class_tiles.cpp
├── class_tiles.h
├── classlevel.cpp
├── classlevel.h
├── classpalette.cpp
├── classpalette.h
├── classpalettebar.cpp
├── classpalettebar.h
├── classtilemap.cpp
├── classtilemap.h
├── classtilemaps.cpp
├── classtilemaps.h
├── color_compare.cpp
├── color_compare.h
├── color_convert.cpp
├── color_convert.h
├── compressionWrapper.cpp
├── compressionWrapper.h
├── config.lua
├── dither.cpp
├── dither.h
├── dub
├── dub.cpp
└── dub.h
├── errorMsg.cpp
├── errorMsg.h
├── examples
├── NES
│ └── asm
│ │ ├── build.sh
│ │ ├── logo.bin
│ │ └── main.asm
├── SG-1000
│ └── C
│ │ ├── Graphics II
│ │ ├── Makefile
│ │ ├── SGlib.c
│ │ ├── SGlib.h
│ │ ├── crt0_sg.rel
│ │ ├── image_source.txt
│ │ ├── main.c
│ │ ├── peep-rules.txt
│ │ ├── seljalandsfoss-1751463_1920.png
│ │ ├── waterfall_attrs.h
│ │ └── waterfall_tiles.h
│ │ ├── README
│ │ └── Text
│ │ ├── Makefile
│ │ ├── SGlib.c
│ │ ├── SGlib.h
│ │ ├── main.c
│ │ ├── text_mode.png
│ │ ├── text_mode.rgp
│ │ ├── text_mode_optimized.rgp
│ │ ├── tilemap.h
│ │ └── tiles.h
├── gameGear
│ └── C
│ │ ├── Makefile
│ │ ├── README
│ │ ├── main.c
│ │ ├── palette.h
│ │ ├── picture.rgp
│ │ ├── tilemap.h
│ │ └── tiles.h
├── genesis
│ ├── asm
│ │ ├── Assemble_instructions.txt
│ │ ├── Enigma.asm
│ │ ├── Kosinski.asm
│ │ ├── _inc
│ │ │ └── Kosinski_internal.asm
│ │ ├── build.sh
│ │ ├── main.asm
│ │ ├── tilemap.eni
│ │ └── tiles.kos
│ ├── bex
│ │ └── main.bex
│ ├── example.rgp
│ └── mappingDisplay
│ │ ├── Art-Sonic.bin
│ │ ├── DPLC-Sonic.bin
│ │ ├── Map-Sonic.bin
│ │ ├── Pal-Sonic.bin
│ │ ├── build.bat
│ │ ├── font8x8_basic.asm
│ │ └── main.asm
└── masterSystem
│ └── C
│ ├── Makefile
│ ├── README
│ ├── main.c
│ ├── palette.h
│ ├── picture.rgp
│ ├── tilemap.h
│ └── tiles.h
├── filemisc.cpp
├── filemisc.h
├── filereader.cpp
├── filereader.h
├── filereader.lua
├── gamedef.h
├── gui.cpp
├── gui.h
├── gui.lua
├── guidefs.h
├── headlessExamples
├── argparse.lua
└── imageConverter.lua
├── help-src.html
├── image.cpp
├── image.h
├── iqa
├── CHANGELOG.txt
├── Doxyfile
├── Makefile
├── README.txt
├── doc
│ ├── algorithms.h
│ ├── build.h
│ ├── footer.html
│ ├── mainpage.h
│ └── sample_code.h
├── include
│ ├── convolve.h
│ ├── decimate.h
│ ├── iqa.h
│ ├── iqa_os.h
│ ├── math_utils.h
│ └── ssim.h
├── iqa.sln
├── iqa.vcproj
├── resources
│ ├── iqa_logo.bmp
│ ├── iqa_logo.jpg
│ ├── mse_eq.jpg
│ └── psnr_eq.jpg
├── source
│ ├── convolve.c
│ ├── decimate.c
│ ├── math_utils.c
│ ├── ms_ssim.c
│ ├── mse.c
│ ├── psnr.c
│ └── ssim.c
└── test
│ ├── Makefile
│ ├── include
│ ├── bmp.h
│ ├── hptime.h
│ ├── test_convolve.h
│ ├── test_decimate.h
│ ├── test_ms_ssim.h
│ ├── test_mse.h
│ ├── test_psnr.h
│ └── test_ssim.h
│ ├── octave
│ ├── README.txt
│ ├── ms_ssim.m
│ ├── ssim_single.m
│ ├── test_convolve.m
│ ├── test_decimate.m
│ ├── test_ms_ssim.m
│ ├── test_mse.m
│ ├── test_psnr.m
│ └── test_ssim.m
│ ├── resources
│ ├── Courtright.bmp
│ ├── Courtright_Noise.bmp
│ ├── blur.bmp
│ ├── contrast.bmp
│ ├── einstein.bmp
│ ├── flipvertical.bmp
│ ├── impulse.bmp
│ ├── jpg.bmp
│ ├── meanshift.bmp
│ └── skate_480x360.bmp
│ ├── source
│ ├── bmp.c
│ ├── hptime.c
│ ├── main.c
│ ├── test_convolve.c
│ ├── test_decimate.c
│ ├── test_ms_ssim.c
│ ├── test_mse.c
│ ├── test_psnr.c
│ └── test_ssim.c
│ └── test.vcproj
├── level.lua
├── luaChunk.cpp
├── luaChunk.hpp
├── luaChunkEntry.cpp
├── luaChunkEntry.hpp
├── luaChunkRow.cpp
├── luaChunkRow.hpp
├── luaChunks.cpp
├── luaChunks.hpp
├── luaExamples
├── GUI
│ ├── beep.lua
│ ├── blankWindow.lua
│ ├── choice.lua
│ ├── color_chooser.lua
│ ├── dir_chooser.lua
│ ├── file_chooser.lua
│ ├── hello.lua
│ ├── input.lua
│ ├── windowDrawHandle.lua
│ └── yesno.lua
├── README
├── Sonic
│ └── Genesis
│ │ └── Sonic_One
│ │ ├── GHZ_Act_One.lua
│ │ └── LoadLevel.lua
├── changeProject.lua
├── dither.lua
├── importJJ2level.lua
├── palette
│ ├── paletteColorCount.lua
│ └── shifthue.lua
├── projectHave.lua
├── projects.lua
├── stringStore
│ └── hello.lua
├── tilemap
│ ├── allRGB.lua
│ ├── importBlocksFromDirectory.lua
│ ├── mandelbrotToTilemap.lua
│ ├── swapBlock.lua
│ └── tilemapGradient.lua
├── tiles
│ ├── appendTiles.lua
│ ├── lossyTileCluster.lua
│ ├── printFirstTile.lua
│ ├── tilestoGrayScale.lua
│ ├── truecolorTileBrigtness.lua
│ └── truecolorTileLabMult.lua
└── zlibVersion.lua
├── luaHelpers.cpp
├── luaHelpers.hpp
├── luaLevel.cpp
├── luaLevel.hpp
├── luaLevelLayer.cpp
├── luaLevelLayer.hpp
├── luaLevelLayerRow.cpp
├── luaLevelLayerRow.hpp
├── luaLevelLayers.cpp
├── luaLevelLayers.hpp
├── luaLevelObjects.cpp
├── luaLevelObjects.hpp
├── luaPalette.cpp
├── luaPalette.hpp
├── luaPaletteEntry.cpp
├── luaPaletteEntry.hpp
├── luaProject.cpp
├── luaProject.hpp
├── luaProjects.cpp
├── luaProjects.hpp
├── luaSprites.cpp
├── luaSprites.hpp
├── luaStringStore.cpp
├── luaStringStore.hpp
├── luaTile.cpp
├── luaTile.hpp
├── luaTilePixels.cpp
├── luaTilePixels.hpp
├── luaTilePixelsRow.cpp
├── luaTilePixelsRow.hpp
├── luaTileRGBA.cpp
├── luaTileRGBA.hpp
├── luaTileRGBApixel.cpp
├── luaTileRGBApixel.hpp
├── luaTileRGBArow.cpp
├── luaTileRGBArow.hpp
├── luaTilemap.cpp
├── luaTilemap.hpp
├── luaTilemapBlock.cpp
├── luaTilemapBlock.hpp
├── luaTilemapBlocks.cpp
├── luaTilemapBlocks.hpp
├── luaTilemapEntry.cpp
├── luaTilemapEntry.hpp
├── luaTilemapRow.cpp
├── luaTilemapRow.hpp
├── luaTilemaps.cpp
├── luaTilemaps.hpp
├── luaTiles.cpp
├── luaTiles.hpp
├── lua_zlib.h
├── luaconfig.cpp
├── luaconfig.h
├── luafltk.cpp
├── luafltk.hpp
├── luaposix_headers
└── posix.h
├── macros.h
├── main.cpp
├── make.clang
├── make.debug
├── make.debug.clang
├── make.win
├── make.win.debug
├── make.win.nolto
├── makeBindings
├── Documentation.txt
├── mkFLTKbind.lua
└── postProcessFL.py
├── makefile.profile
├── menu.lua
├── metasprites.cpp
├── metasprites.h
├── nearestColor.cpp
├── nearestColor.h
├── nespal.cpp
├── nespal.h
├── palette.cpp
├── palette.h
├── paletteValidation.lua
├── project.cpp
├── project.h
├── project.lua
├── quant.cpp
├── quant.h
├── runlua.cpp
├── runlua.h
├── savepng.cpp
├── savepng.h
├── spatial_color_quant.cpp
├── spatial_color_quant.h
├── system.cpp
├── system.h
├── system.lua
├── tilemap.cpp
├── tilemap.h
├── tiles.lua
├── tiles_io.cpp
├── tiles_io.h
├── undo.cpp
├── undo.h
├── windist.sh
├── windowinit.cpp
├── wu.c
├── wu.h
├── zlibwrapper.cpp
└── zlibwrapper.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 |
6 | # Compiled Dynamic libraries
7 | *.so
8 | *.dylib
9 |
10 | # Compiled Static libraries
11 | *.lai
12 | *.la
13 | *.a
14 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "mdcomp"]
2 | path = mdcomp
3 | url = https://github.com/flamewing/mdcomp
4 | [submodule "luaposix"]
5 | path = luaposix
6 | url = https://github.com/luaposix/luaposix
7 | [submodule "moonfltk"]
8 | path = moonfltk
9 | url = https://github.com/stetre/moonfltk
10 | [submodule "lua-zlib"]
11 | path = lua-zlib
12 | url = https://github.com/brimworks/lua-zlib
13 | [submodule "serpent"]
14 | path = serpent
15 | url = https://github.com/pkulchenko/serpent
16 | [submodule "lua-compat-5.3"]
17 | path = lua-compat-53
18 | url = https://github.com/keplerproject/lua-compat-5.3
19 | [submodule "Libunicows"]
20 | path = Libunicows
21 | url = https://github.com/ComputerNerd/Libunicows
22 |
--------------------------------------------------------------------------------
/CIE.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | void Rgb2Lab(double *L, double *a, double *b, double R, double G, double B);
4 | void Rgb2Lab255(double *L, double *a, double *b, unsigned r, unsigned g, unsigned bl);
5 | void Lab2Rgb(double *R, double *G, double *B, double L, double a, double b);
6 | void Lab2Rgb255(uint8_t*r, uint8_t *g, uint8_t *blue, double L, double a, double b);
7 | void Rgb2Lch(double *L, double *C, double *H, double R, double G, double B);
8 | void Rgb2Lch255(double *L, double *C, double *H, unsigned R, unsigned G, unsigned B);
9 | void Lch2Rgb(double *R, double *G, double *B, double L, double C, double H);
10 | void Lch2Rgb255(uint8_t*r, uint8_t *g, uint8_t *b, double L, double C, double H);
11 |
--------------------------------------------------------------------------------
/Contributing:
--------------------------------------------------------------------------------
1 | Especially given what can be accomplished via Lua scripting modifying Retro
2 | Graphics Toolkit to suite your needs or writing a Lua script to what you need
3 | to do is much faster and easier than writing your own tool. Why reinvent the
4 | wheel? Instead modify the wheel to suite your needs.
5 |
6 | These changes are very likely to benefit other people as well. It is very
7 | likely that after you make a change to Retro Graphics Toolkit or write a Lua
8 | script for it you will want to contribute your changes. Fortunately Github
9 | makes it very easy for you to contribute. All you need to do is fork the
10 | project and submit a pull request. If you do not like that approach you can
11 | also submit a patch.
12 |
13 | ==============================================================================
14 | FAQ
15 | ==============================================================================
16 |
17 | What if I cannot program but I sill want to help out?
18 | * Retro Graphics Toolkit is lacking in documentation. Any additional
19 | documentation helps.
20 | * If you do not like writing documentation but want to help
21 | out, you can file bug reports if you find any.
22 |
23 |
24 | What if I want to program something but I am not sure what?
25 | * Check the development roadmap Wiki page
26 | * If that does not work I have lots of ideas. I can easily give you one.
27 |
28 |
--------------------------------------------------------------------------------
/Docs/Screenshots/ImageToTilemap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/Docs/Screenshots/ImageToTilemap.png
--------------------------------------------------------------------------------
/Docs/Screenshots/doneImageImport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/Docs/Screenshots/doneImageImport.png
--------------------------------------------------------------------------------
/Docs/src/SEGA_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/Docs/src/SEGA_logo.png
--------------------------------------------------------------------------------
/Docs/src/sega.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/Docs/src/sega.png
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | CPPFLAGS=
2 | CC=gcc
3 | CXX=g++
4 |
5 | include Makefile.common
6 |
7 | CFLAGS += -march=native -flto=8 -fuse-linker-plugin -s -O3 -pipe -march=native -fomit-frame-pointer
8 | CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++14
9 | LDFLAGS := -flto=8 -O3 -march=native -fuse-linker-plugin -s -fno-rtti -std=gnu++14 -L/usr/lib/fltk/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -s -lluajit-5.1 -ldl
10 |
11 | EXECUTABLE := RetroGraphicsToolkit
12 |
13 | all: $(EXECUTABLE)
14 |
15 | $(EXECUTABLE): $(OBJECTS)
16 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
17 | .c.o:
18 | $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
19 | .cc.o:
20 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
21 | .cpp.o:
22 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
23 | clean:
24 | rm -f $(OBJECTS) $(EXECUTABLE)
25 |
--------------------------------------------------------------------------------
/Makefile.common:
--------------------------------------------------------------------------------
1 | # Gentoo fix needs include directory set to /usr/include/fltk/ or /usr/include/fltk-1/ for older versions of FLTK if you are using a different distribution then this may not apply to you.
2 | CFLAGS := -isystem /usr/include/fltk/ -Imdcomp/include/ -IautogeneratedBindings/ -Iluaposix/ext/include -Iluaposix_headers -Iiqa/include -I. -I/usr/include/luajit-2.1 -Ilua-compat-53/c-api -DCOMPAT53_PREFIX=luacompat -c
3 | BINDINGS := $(wildcard autogeneratedBindings/*.cpp) $(wildcard luaposix/ext/posix/*.c) $(wildcard luaposix/ext/posix/sys/*.c) \
4 | $(wildcard moonfltk/src/*.cc) $(wildcard moonfltk/src/*.c) $(wildcard iqa/source/*.c)
5 | BINDINGS := $(filter-out luaposix/ext/posix/posix.c, $(BINDINGS))
6 | BINDINGS := $(filter-out luaposix/ext/posix/stdio.c, $(BINDINGS))
7 | BINDINGS := $(filter-out moonfltk/src/open.c, $(BINDINGS))
8 | BINDINGS := $(filter-out moonfltk/src/compat-5.3.c, $(BINDINGS))
9 | BINDINGS := lua-zlib/lua_zlib.c $(BINDINGS)
10 | # BINDINGS := lua-compat-5.3/c-api/compat-5.3.c $(BINDINGS)
11 | CPPFLAGS += -DPACKAGE='"luaposix"' -DVERSION='"RGT"' -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DHAVE_NET_IF_H=1 -D_DEFAULT_SOURCE -DUSE_IMAGES=1
12 | include Makefile.objects
13 |
--------------------------------------------------------------------------------
/Makefile.objects:
--------------------------------------------------------------------------------
1 | MDCOMP_OBJECTS := mdcomp/src/lib/comper.o mdcomp/src/lib/enigma.o \
2 | mdcomp/src/lib/kosinski.o mdcomp/src/lib/nemesis.o mdcomp/src/lib/saxman.o
3 |
4 | BINDINGS := $(BINDINGS:.cpp=.o)
5 | BINDINGS := $(BINDINGS:.cc=.o)
6 |
7 | OBJECTS := project.o main.o callbacks_palette.o callback_tiles.o class_global.o \
8 | quant.o tilemap.o color_convert.o errorMsg.o classpalettebar.o dither.o \
9 | class_tiles.o $(MDCOMP_OBJECTS) spatial_color_quant.o NEUQUANT.o \
10 | classtilemap.o palette.o zlibwrapper.o color_compare.o windowinit.o \
11 | tiles_io.o savepng.o callback_project.o callback_tilemap.o callback_gui.o classChunks.o \
12 | compressionWrapper.o callback_chunk.o gui.o wu.o system.o filemisc.o \
13 | classSprite.o classSprites.o callbacksprites.o undo.o image.o classlevel.o \
14 | runlua.o luafltk.o luaHelpers.o luaProject.o luaProjects.o luaTiles.o \
15 | luaTile.o luaTilemaps.o luaTilemap.o luaTilemapRow.o luaTilemapBlocks.o luaTilemapBlock.o luaTilemapEntry.o \
16 | luaTileRGBA.o luaTileRGBArow.o luaTileRGBApixel.o luaPalette.o \
17 | luaPaletteEntry.o luaSprites.o nearestColor.o CIE.o classpalette.o \
18 | classtilemaps.o callbacktilemaps.o nespal.o filereader.o luaconfig.o \
19 | metasprites.o callbacklua.o dub/dub.o $(BINDINGS:.c=.o) cbHelper.o \
20 | luaChunks.o luaChunk.o luaChunkRow.o luaChunkEntry.o luaLevel.o luaLevelLayers.o \
21 | luaLevelLayer.o luaLevelLayerRow.o luaLevelObjects.o luaTilePixels.o luaTilePixelsRow.o \
22 | luaStringStore.o lua-compat-53/c-api/compat-5.3.o
23 |
24 |
--------------------------------------------------------------------------------
/ManualSrc/footer.tex:
--------------------------------------------------------------------------------
1 | \end{document}
2 |
--------------------------------------------------------------------------------
/ManualSrc/header.tex:
--------------------------------------------------------------------------------
1 | \documentclass[letterpaper,12pt,openany]{memoir}
2 | \usepackage[T1]{fontenc}
3 | \usepackage{lmodern}
4 | \usepackage{amssymb,amsmath}
5 | \usepackage{ifxetex,ifluatex}
6 | \usepackage{fixltx2e} % provides \textsubscript
7 | % use upquote if available, for straight quotes in verbatim environments
8 | \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
9 | \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
10 | \usepackage[utf8]{inputenc}
11 | \else % if luatex or xelatex
12 | \ifxetex
13 | \usepackage{mathspec}
14 | \usepackage{xltxtra,xunicode}
15 | \else
16 | \usepackage{fontspec}
17 | \fi
18 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
19 | \fi
20 | % use microtype if available
21 | \IfFileExists{microtype.sty}{\usepackage{microtype}}{}
22 | \usepackage{fullpage}
23 | \usepackage{listings}
24 | \usepackage{graphicx}
25 | % Redefine \includegraphics so that, unless explicit options are
26 | % given, the image width will not exceed the width of the page.
27 | % Images get their normal width if they fit onto the page, but
28 | % are scaled down if they would overflow the margins.
29 | \makeatletter
30 | \def\ScaleIfNeeded{%
31 | \ifdim\Gin@nat@width>\linewidth
32 | \linewidth
33 | \else
34 | \Gin@nat@width
35 | \fi
36 | }
37 | \makeatother
38 | \let\Oldincludegraphics\includegraphics
39 | {%
40 | \catcode`\@=11\relax%
41 | \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
42 | }%
43 | \ifxetex
44 | \usepackage[setpagesize=false, % page size defined by xetex
45 | unicode=false, % unicode breaks when used with xetex
46 | xetex]{hyperref}
47 | \else
48 | \usepackage[unicode=true]{hyperref}
49 | \fi
50 | \hypersetup{breaklinks=true,
51 | bookmarks=true,
52 | pdfauthor={},
53 | pdftitle={},
54 | colorlinks=true,
55 | citecolor=blue,
56 | urlcolor=blue,
57 | linkcolor=magenta,
58 | pdfborder={0 0 0}}
59 | \urlstyle{same} % don't use monospace font for urls
60 | \setlength{\parindent}{0pt}
61 | \setlength{\parskip}{6pt plus 2pt minus 1pt}
62 | \setlength{\emergencystretch}{3em} % prevent overfull lines
63 | \setcounter{secnumdepth}{0}
64 |
65 | \title{Retro Graphics Toolkit user's manual}
66 | \author{Sega16}
67 | \date{}
68 |
69 | \begin{document}
70 | \frontmatter
71 | \maketitle
72 | \newpage
73 | {
74 | \hypersetup{linkcolor=black}
75 | \setcounter{tocdepth}{3}
76 | \tableofcontents
77 | }
78 | {
79 | \hypersetup{linkcolor=black}
80 | \listoffigures
81 | \listoftables
82 | }
83 |
--------------------------------------------------------------------------------
/NEUQUANT.H:
--------------------------------------------------------------------------------
1 | /* NeuQuant Neural-Net Quantization Algorithm Interface
2 | * ----------------------------------------------------
3 | *
4 | * Copyright (c) 1994 Anthony Dekker
5 | *
6 | * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994.
7 | * See "Kohonen neural networks for optimal colour quantization"
8 | * in "Network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367.
9 | * for a discussion of the algorithm.
10 | * See also http://members.ozemail.com.au/~dekker/NEUQUANT.HTML
11 | *
12 | * Any party obtaining a copy of these files from the author, directly or
13 | * indirectly, is granted, free of charge, a full and unrestricted irrevocable,
14 | * world-wide, paid up, royalty-free, nonexclusive right and license to deal
15 | * in this software and documentation files (the "Software"), including without
16 | * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 | * and/or sell copies of the Software, and to permit persons who receive
18 | * copies from any such party to do so, with the only requirement being
19 | * that this copyright notice remain intact.
20 | */
21 |
22 |
23 | #include
24 |
25 |
26 | #define maxnetsize 256 /* number of colours used */
27 |
28 |
29 | /* For 256 colours, fixed arrays need 8kb, plus space for the image
30 | ---------------------------------------------------------------- */
31 |
32 |
33 | /* four primes near 500 - assume no image has a length so large */
34 | /* that it is divisible by all four primes */
35 | #define prime1 499
36 | #define prime2 491
37 | #define prime3 487
38 | #define prime4 503
39 |
40 | #define minpicturebytes (3*prime4) /* minimum size for input image */
41 |
42 |
43 | /* Program Skeleton
44 | ----------------
45 | [select samplefac in range 1..30]
46 | pic = (unsigned char*) malloc(3*width*height);
47 | [read image from input file into pic]
48 | initnet(pic,3*width*height,samplefac);
49 | learn();
50 | unbiasnet();
51 | [write output image header, using writecolourmap(f),
52 | possibly editing the loops in that function]
53 | inxbuild();
54 | [write output image using inxsearch(b,g,r)] */
55 | void NEU_wrapper(uint32_t w,uint32_t h,uint8_t * img_in,uint16_t colors_amount,uint8_t user_pal[3][256]);
56 |
--------------------------------------------------------------------------------
/RetroGraphicsToolkit.exe.7z:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/RetroGraphicsToolkit.exe.7z
--------------------------------------------------------------------------------
/astyle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | astyle --lineend=linux --pad-oper --indent=tab --remove-braces --pad-header --pad-comma --break-blocks --pad-oper --indent-switches *.cpp *.hpp *.c *.h autogeneratedBindings/*.cpp autogeneratedBindings/*.h
3 |
--------------------------------------------------------------------------------
/autogeneratedBindings/filereader_filereader.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | #pragma once
18 | int luaopen_filereader_filereader(lua_State *L);
19 |
--------------------------------------------------------------------------------
/autogeneratedBindings/iqaLua.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | #pragma once
18 | int luaopen_iqaLua(lua_State *L);
19 |
--------------------------------------------------------------------------------
/autogeneratedBindings/level_levDat.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2016)
16 | */
17 | #pragma once
18 | int luaopen_level_levDat(lua_State *L, struct levDat*d);
19 |
--------------------------------------------------------------------------------
/autogeneratedBindings/level_levelInfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2016)
16 | */
17 | #pragma once
18 | int luaopen_level_levelInfo(lua_State *L, struct levelInfo*i);
19 |
--------------------------------------------------------------------------------
/autogeneratedBindings/level_levobjDat.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2016)
16 | */
17 | #pragma once
18 | int luaopen_level_levobjDat(lua_State *L, struct levobjDat*d);
19 |
--------------------------------------------------------------------------------
/autogeneratedBindings/undoLua.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2016)
16 | */
17 | #pragma once
18 | int luaopen_undoLua(lua_State *L);
19 |
--------------------------------------------------------------------------------
/callback_chunk.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include
18 | #include
19 | extern uint32_t currentChunk;
20 | extern unsigned solidBits_G;
21 | extern bool tileEditModeChunk_G;
22 | extern unsigned ChunkOff[2];
23 | extern unsigned scrollChunks_G[2];
24 | extern uint_fast32_t editChunk_G[2];
25 | void setCurPlaneChunkCB(Fl_Widget*w, void*);
26 | void insertChunkCB(Fl_Widget*, void*);
27 | void delChunkAtCB(Fl_Widget*, void*);
28 | void appendChunkCB(Fl_Widget*o, void*);
29 | void saveChunkS1CB(Fl_Widget*o, void*);
30 | void resizeChunkCB(Fl_Widget*o, void*);
31 | void selBlockCB(Fl_Widget*, void*b);
32 | void solidCB(Fl_Widget*, void*s);
33 | void ImportS1CBChunks(Fl_Widget*, void*a);
34 | void currentChunkCB(Fl_Widget*, void*);
35 | void useBlocksCB(Fl_Widget*o, void*);
36 | void scrollChunkCB(Fl_Widget*, void*);
37 | void scrollChunkX(Fl_Widget*, void*);
38 | void scrollChunkY(Fl_Widget*, void*);
39 |
--------------------------------------------------------------------------------
/callback_gui.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "project.h"
4 | void setGameSysTMS9918(Project*prj, enum TMS9918SubSys subSysOld);
5 | void setSubditherSetting(Fl_Widget*w, void*);
6 | void redrawOnlyCB(Fl_Widget*, void*);
7 | void set_mode_tabs(Fl_Widget* o, void*);
8 | void showAbout(Fl_Widget*, void*);
9 | void set_game_system(Fl_Widget*, void* selection);
10 | void trueColTileToggle(Fl_Widget*, void*);
11 | void toggleRowSolo(Fl_Widget*, void*);
12 |
--------------------------------------------------------------------------------
/callback_project.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | void setSegaPalType(Fl_Widget*, void*x);
18 | void setNesTile(Fl_Widget*o, void*);
19 | void saveAllProjectsCB(Fl_Widget*, void*);
20 | void loadAllProjectsCB(Fl_Widget*, void*o);
21 | void haveCB(Fl_Widget*o, void*mask);
22 | void switchShareCB(Fl_Widget*o, void*mask);
23 | void shareProjectCB(Fl_Widget*o, void*mask);
24 | void loadProjectCB(Fl_Widget*, void*);
25 | void saveProjectCB(Fl_Widget*, void*);
26 | void switchProjectCB(Fl_Widget*o, void*);
27 | void appendProjectCB(Fl_Widget*, void*);
28 | void deleteProjectCB(Fl_Widget*, void*);
29 |
--------------------------------------------------------------------------------
/callback_tilemap.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | void pickExtAttrsCB(Fl_Widget*, void*);
18 | void setTmapOffsetCB(Fl_Widget*, void*);
19 | void resizeBlocksCB(Fl_Widget*o, void*);
20 | void blocksAmtCB(Fl_Widget*o, void*);
21 | void toggleBlocksCB(Fl_Widget*o, void*);
22 | void FixOutOfRangeCB(Fl_Widget*, void*);
23 | void callback_resize_map(Fl_Widget* o, void*);
24 | void set_grid(Fl_Widget*, void*);
25 | void set_grid_placer(Fl_Widget*, void*);
26 | void save_tilemap_as_image(Fl_Widget*, void*);
27 | void save_tilemap_as_colspace(Fl_Widget*, void*);
28 | void load_tile_map(Fl_Widget*, void*);
29 | void save_map(Fl_Widget*, void*);
30 | void fill_tile_map_with_tile(Fl_Widget*, void*);
31 | void dither_tilemap_as_imageCB(Fl_Widget*, void*);
32 | void load_image_to_tilemap_project_ptr(struct Project* cProject, const char*fname, bool over, bool tilesonly, bool append, unsigned currentPlane, bool undo = false);
33 | void load_image_to_tilemap(const char*fname, bool over, bool tilesonly, bool append);
34 | void load_image_to_tilemapCB(Fl_Widget*, void*o);
35 | void set_prioCB(Fl_Widget*, void*);
36 | void set_hflipCB(Fl_Widget*, void*);
37 | void set_vflipCB(Fl_Widget*, void*);
38 | void update_map_scroll_x(Fl_Widget*, void*);
39 | void update_map_scroll_y(Fl_Widget*, void*);
40 | void update_map_size(Fl_Widget*, void*);
41 | void tilemap_remove_callback(Fl_Widget*, void*);
42 | void shadow_highligh_findout(Fl_Widget*, void*);
43 | void tileDPicker(Fl_Widget*, void*);
44 |
--------------------------------------------------------------------------------
/callback_tiles.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | void tilesnewfilppedCB(Fl_Widget*, void*);
18 | void insertTileCB(Fl_Widget*, void*);
19 | void delete_tile_at_location(Fl_Widget*, void* row);
20 | void new_tile(Fl_Widget*, void*);
21 | void update_truecolor(Fl_Widget* o, void* v);
22 | void blank_tile(Fl_Widget*, void*);
23 | void update_offset_tile_edit(Fl_Widget*, void*);
24 | void set_tile_current(Fl_Widget* o, void*);
25 | void set_tile_currentTP(Fl_Widget* o, void*);
26 | void update_all_tiles(Fl_Widget*, void*);
27 | void remove_duplicate_truecolor(Fl_Widget*, void*);
28 | void remove_duplicate_tiles(Fl_Widget*, void*);
29 | void fill_tile(Fl_Widget* o, void*);
30 |
--------------------------------------------------------------------------------
/callbacklua.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include
18 | void appendLuaScript(Fl_Widget*, void*);
19 | void deleteLuaScript(Fl_Widget*, void*);
20 | void setNameLuaScript(Fl_Widget*, void*);
21 | void switchCurLuaScript(Fl_Widget*, void*);
22 | void runCurLuaScript(Fl_Widget*, void*);
23 |
--------------------------------------------------------------------------------
/callbacks_palette.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #if _WIN32
18 | #include
19 | #endif
20 | #include
21 | #pragma once
22 | void sortRowbyCB(Fl_Widget*, void*);
23 | void save_palette(Fl_Widget*, void* start_end);
24 | void update_palette(Fl_Widget* o, void* v);
25 | void loadPalette(Fl_Widget*, void* offset);
26 | void set_ditherAlg(Fl_Widget*, void* typeset);
27 | void set_tile_row(Fl_Widget*, void* row);
28 | void setPalType(Fl_Widget*, void*type);
29 | void pickNearAlg(Fl_Widget*, void*);
30 | void rgb_pal_to_entry(Fl_Widget*, void*);
31 | void entryToRgb(Fl_Widget*, void*);
32 | void clearPalette(Fl_Widget*, void*);
33 | void updateYselection(Fl_Widget*, void*);
34 | void setBGcolorTMS9918(Fl_Widget*, void*);
35 |
--------------------------------------------------------------------------------
/callbacksprites.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include "project.h"
18 | extern uint32_t curSprite;
19 | extern uint32_t curSpritegroup;
20 | extern uint32_t curSpritemeta;
21 | extern int32_t spriteEndDraw[2];
22 | extern bool centerSpriteDraw_G;
23 | void palRowstCB(Fl_Widget*, void*);
24 | void optimizeSpritesCB(Fl_Widget*, void*);
25 | void ditherSpriteAsImage(unsigned msprt, unsigned which, Project*prj);
26 | void ditherGroupAsImage(unsigned msprt, Project*prj);
27 | void ditherSpriteAsImageAllCB(Fl_Widget*, void*);
28 | void ditherSpriteAsImageCB(Fl_Widget*, void*);
29 | void setDrawSpriteCB(Fl_Widget*, void*m);
30 | void spriteSheetimportCB(Fl_Widget*o, void*);
31 | void exportSonicDPLCCB(Fl_Widget*o, void*t);
32 | void assignSpriteAllMetanameCB(Fl_Widget*o, void*);
33 | void assignSpritemetaNameCB(Fl_Widget*o, void*);
34 | void alignSpriteCB(Fl_Widget*, void*t);
35 | void importSonicDPLCCB(Fl_Widget*o, void*t);
36 | void spritePrioCB(Fl_Widget*, void*);
37 | void setoffspriteCB(Fl_Widget*o, void*y);
38 | void exportSonicMappingCB(Fl_Widget*o, void*);
39 | void importSonicMappingCB(Fl_Widget*o, void*);
40 | void assignSpritegroupnameCB(Fl_Widget*o, void*);
41 | void spriteHflipCB(Fl_Widget*, void*);
42 | void spriteVflipCB(Fl_Widget*, void*);
43 | void SpriteimportCB(Fl_Widget*, void*);
44 | void selSpriteCB(Fl_Widget*w, void*);
45 | void selspriteGroup(Fl_Widget*o, void*);
46 | void selspriteMeta(Fl_Widget*o, void*);
47 | void appendSpriteCB(Fl_Widget*, void*);
48 | void delSpriteCB(Fl_Widget*, void*);
49 | void setvalueSpriteCB(Fl_Widget*o, void*which);
50 |
--------------------------------------------------------------------------------
/callbacktilemaps.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | void setCurPlaneTilemaps(Fl_Widget*, void*val);
20 | void removeTilemapsPlane(Fl_Widget*, void*val);
21 | void updateNameTilemaps(Fl_Widget*w, void*);
22 | void updatePlaneTilemapMenu(uint32_t id, Fl_Choice*plM);
23 | void updatePlaneTilemapMenu(void);
24 | void addPlaneTilemap(Fl_Widget*, void*val);
25 |
--------------------------------------------------------------------------------
/cbHelper.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include "runlua.h"
18 | #include "cbHelper.h"
19 | #include
20 | extern "C" {
21 | #include "compat-5.3.h"
22 | }
23 |
24 | void luaWidgetCallbackHelper(Fl_Widget*, void*i) {
25 | struct cbInfo*c = (struct cbInfo*)i;
26 |
27 | if (c->cb) {
28 | if (lua_getglobal(c->L, c->cb) != LUA_TFUNCTION)
29 | throw std::invalid_argument("This is not a function.");
30 |
31 | lua_pushinteger(c->L, c->udat);
32 | runLuaFunc(c->L, 1, 0);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/cbHelper.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | struct cbInfo {
20 | char*cb;
21 | lua_State*L;
22 | lua_Integer udat;
23 | };
24 | void luaWidgetCallbackHelper(Fl_Widget*, void*i);
25 |
--------------------------------------------------------------------------------
/classSprite.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include "project.h"
19 | #include
20 | struct sprite {
21 | Project*prj;
22 | uint32_t w, h; //In tiles
23 | uint32_t starttile, palrow;
24 | uint32_t loadat;//Where the sprite will be loaded in game (useful for games that overwrite tiles in VRAM for animation purposes such as the Sonic series of games and many more.)
25 | int32_t offx, offy;
26 | bool hflip, vflip;
27 | bool prio;
28 | sprite(Project*prj);
29 | sprite(uint32_t wi, uint32_t hi, uint32_t palrowset, uint32_t settile, bool hf, bool vf, bool pri, uint32_t la, int32_t ox, int32_t oy, Project*prj);
30 | void draw(unsigned x, unsigned y, unsigned zoom);
31 | void toImage(uint8_t*img);
32 | };
33 |
--------------------------------------------------------------------------------
/classlevel.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | #include
20 |
21 | #include
22 | #include "project.h"
23 | struct __attribute__ ((__packed__)) levDat {
24 | uint32_t id, dat, xormask;
25 | int64_t extra;
26 | };
27 | struct __attribute__ ((__packed__)) levobjDat { //For sprite layout
28 | uint32_t x, y, prjid, metaid, groupid, dat, xormask;
29 | int64_t extra;
30 | };
31 | enum source {TILES, BLOCKS, CHUNKS};
32 | struct __attribute__ ((__packed__)) levelInfo {
33 | uint32_t w, h, nx, dx, ny, dy;
34 | int32_t repeatx, repeaty, src;
35 | int64_t extra;
36 | };
37 | struct level {
38 | Project*prj;
39 | uint32_t layeramt;
40 | std::vectorlvlI;//Allow different sized layers
41 | std::vector*>dat;
42 | std::vector*>odat;
43 | std::vectorlayernames;
44 | level(Project*prj);
45 | level(const level&o, Project*prj);
46 | void addLayer(unsigned at, bool after);
47 | void removeLayer(unsigned which);
48 | bool inRangeLayer(unsigned tst);
49 | struct levelInfo*getInfo(unsigned layer);
50 | void setInfo(unsigned layer, struct levelInfo i);
51 | struct levDat*getlevDat(unsigned layer, unsigned x, unsigned y);
52 | void setlevDat(unsigned layer, unsigned x, unsigned y, struct levDat d);
53 | struct levobjDat*getObjDat(unsigned layer, unsigned idx);
54 | void setlevObjDat(unsigned layer, unsigned idx, struct levobjDat d);
55 | void setlayeramt(unsigned amt, bool lastLayerDim);
56 | void resizeLayer(unsigned idx, unsigned nw, unsigned nh);
57 | void save(FILE*fp) const;
58 | void load(FILE*fp, uint32_t version);
59 | void subType(unsigned oid, unsigned nid, enum source s, int plane);
60 | };
61 |
--------------------------------------------------------------------------------
/classpalettebar.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #define TABS_WITH_PALETTE 4
19 | #include
20 |
21 | class paletteBar {
22 | private:
23 | gameSystemEnum sysCache;
24 | unsigned ox[TABS_WITH_PALETTE], oy[TABS_WITH_PALETTE];
25 | unsigned baseOffx[TABS_WITH_PALETTE], baseOffy[TABS_WITH_PALETTE];
26 | bool tiny[TABS_WITH_PALETTE];
27 | bool all[TABS_WITH_PALETTE];
28 | bool alt[TABS_WITH_PALETTE];
29 | public:
30 | Fl_Slider*slide[TABS_WITH_PALETTE][3];
31 | unsigned selRow[TABS_WITH_PALETTE];
32 | unsigned selBox[TABS_WITH_PALETTE];
33 | unsigned selBoxAlt[TABS_WITH_PALETTE];
34 | unsigned getEntry(unsigned tab)const;
35 | void addTab(unsigned tab, bool all = false, bool tiny = false, bool alt = false);
36 | void setSys(bool upSlide = true, bool force = false);
37 | void updateSize(unsigned tab);
38 | void updateSlider(unsigned tab);
39 | void updateSliders(void) {
40 | for (unsigned i = 0; i < TABS_WITH_PALETTE; ++i)
41 | updateSlider(i);
42 | }
43 | unsigned toTab(unsigned realtab);
44 | void changeRow(unsigned row, unsigned tab) {
45 | selRow[tab] = row;
46 | updateSlider(tab);
47 | }
48 | void checkBox(int x, int y, unsigned tab);
49 | void drawBoxes(unsigned tab);
50 | bool hasAltSelection();
51 | void updateColorSelectionTile(unsigned tile, unsigned tab);
52 | };
53 | extern paletteBar palBar;
54 |
--------------------------------------------------------------------------------
/classtilemaps.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #include "classtilemaps.h"
18 | tilemaps::tilemaps(Project*prj) {
19 | this->prj = prj;
20 | maps.emplace_back(prj);
21 | maps[0].planeName.assign("0");
22 | }
23 | tilemaps::tilemaps(const tilemaps&other, Project*prj) {
24 | this->prj = prj;
25 | unsigned cnt = other.maps.size();
26 | maps.reserve(cnt);
27 |
28 | for (unsigned i = 0; i < cnt; ++i)
29 | maps.emplace_back(other.maps[i], prj);
30 | }
31 | void tilemaps::setPlaneCnt(unsigned cnt) {
32 | unsigned oldCnt = maps.size();
33 |
34 | if (cnt > oldCnt) {
35 | maps.reserve(cnt);
36 |
37 | for (unsigned i = oldCnt; i < cnt; ++i) {
38 | char tmp[16];
39 | snprintf(tmp, 16, "%u", i);
40 | maps.emplace_back(tileMap(prj));
41 | maps[i].planeName.assign(tmp);
42 | }
43 | } else if (cnt < oldCnt) {
44 | for (int i = oldCnt; i > (int)cnt; --i)
45 | maps.pop_back();
46 | }
47 | }
48 |
49 | void tilemaps::changePrjPtr(Project*prj) {
50 | this->prj = prj;
51 |
52 | for (unsigned i = 0; i < maps.size(); ++i)
53 | maps[i].prj = prj;
54 | }
55 |
56 | void tilemaps::swapTile(unsigned oldTile, unsigned newTile) {
57 | for (unsigned i = 0; i < maps.size(); ++i)
58 | maps[i].swapTile(oldTile, newTile);
59 | }
60 |
61 | void tilemaps::fixPaletteRows(unsigned num, unsigned dom) {
62 | for (unsigned i = 0; i < maps.size(); ++i)
63 | maps[i].fixPaletteRows(num, dom);
64 | }
65 |
--------------------------------------------------------------------------------
/classtilemaps.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #pragma once
18 | #include "classtilemap.h"
19 | class tilemaps {
20 | public:
21 | Project*prj;
22 | std::vector maps;
23 | tilemaps(Project*prj);
24 | tilemaps(const tilemaps&other, Project*prj);
25 | void setPlaneCnt(unsigned cnt);
26 | void assignNum(unsigned i) {
27 | char tmp[16];
28 | snprintf(tmp, sizeof(tmp), "%u", i);
29 | maps[i].planeName.assign(tmp);
30 | }
31 | void removePlane(unsigned which) {
32 | maps.erase(maps.begin() + which);
33 | }
34 | void changePrjPtr(Project*prj);
35 | void swapTile(unsigned oldTile, unsigned newTile); // Used to make an update apply to all maps.
36 | void fixPaletteRows(unsigned num, unsigned dom);
37 | };
38 |
--------------------------------------------------------------------------------
/color_compare.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | enum nearestAlgs_t {aCiede2000, aWeighted, aEuclid, aCIE76};
4 | uint32_t ColourDistance(int r1, int g1, int b1, int r2, int g2, int b2);
5 | double ciede2000(double L1, double C1, double h1, double L2, double C2, double h2, double Kl, double Kc, double Kh);
6 | double ciede2000rgb(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2);
7 |
--------------------------------------------------------------------------------
/color_convert.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | //Color conversion functions should go here
18 | #pragma once
19 | #include
20 | #include "nespal.h"
21 | #include "project.h"
22 | extern uint8_t nespaltab[];
23 | extern uint8_t nespaltab_alt[];
24 | unsigned nearest_color_index(int val, unsigned startindex);
25 | unsigned nearest_color_index(int val);
26 | void rgbToHsl255(unsigned r, unsigned g, unsigned b, double * hh, double * ll, double * ss);
27 | void rgbToHsl(double r, double g, double b, double * hh, double * ll, double * ss);
28 | void hslToRgb(double hue, double s, double l, uint8_t&r, uint8_t&g, uint8_t&b);
29 | uint32_t count_colors(uint8_t * image_ptr, uint32_t w, uint32_t h, uint8_t *colors_found, bool useAlpha = false);
30 | void updateEmphasisCB(Fl_Widget*, void*);
31 | static inline uint32_t toNesRgb(uint8_t ri, uint8_t gi, uint8_t bi) {
32 | return nesPalToRgb(currentProject->pal->to_nes_color_rgb(ri, gi, bi));
33 | }
34 | void updateNesTab(unsigned emps, bool alt);
35 | static inline double pickIt(double h, double s, double l, unsigned type) {
36 | switch (type) {
37 | case 0:
38 | return h;
39 | break;
40 |
41 | case 1:
42 | return s;
43 | break;
44 |
45 | case 2:
46 | return l;
47 | break;
48 |
49 | default:
50 | return 0.;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/compressionWrapper.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | enum class CompressionType {Cancel = -1,
20 | Uncompressed = 0,
21 | Nemesis, Kosinski,
22 | Enigma, Saxman,
23 | Comper
24 | };
25 | const char*typeToText(CompressionType type);
26 | CompressionType compressionAsk(void);
27 | std::string decodeTypeStr(const char * filename, size_t &filesize, CompressionType type);
28 | void*decodeTypeRam(const uint8_t*dat, size_t inputSize, size_t &filesize, CompressionType type);
29 | void*decodeType(const char * filename, size_t &filesize, CompressionType type);
30 | void*encodeType(const void*in, size_t n, size_t&outSize, CompressionType type);
31 |
--------------------------------------------------------------------------------
/config.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | --]]
17 |
18 | --[[
19 | This file allows you control various aspects of Retro Graphics Toolkit.
20 | For purposes of organization files are separated and included in this main file.
21 | For example menu.lua allows you to edit the shortcut keys to various menu items.
22 |
23 | Warning: This file is executed very early. Before the project objects are ready.
24 | --]]
25 |
26 | serpent = require("serpent.src.serpent")
27 | -- You must install compat53 and bit32 to use luajit.
28 |
29 | -- There are a few ways to go about this. One is to install locally. This is helpful if these libraries cannot be installed with your package manager and you don't want to run as root.
30 | -- luarocks --local --lua-version 5.1 install compat53
31 | -- luarocks --local --lua-version 5.1 install bit32
32 | -- Then prior to running Retro Graphics Toolkit run
33 | -- eval $(luarocks --lua-version 5.1 path)
34 |
35 | require("compat53")
36 | bit32 = require('bit32')
37 |
38 |
39 | Fl.scheme('plastic')
40 | if is_headless == 0 then
41 | dofile "menu.lua"
42 | dofile "callbacks.lua"
43 | dofile "gui.lua"
44 | dofile "level.lua"
45 | end
46 | dofile "project.lua"
47 | dofile "system.lua"
48 | dofile "paletteValidation.lua"
49 | dofile "tiles.lua"
50 | dofile "TMS9918.lua"
51 | if is_headless == 0 then
52 | dofile "filereader.lua"
53 | end
54 | --print('Code will execute here after the window is created but before the GUI controls are added')
55 |
--------------------------------------------------------------------------------
/dither.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | void*ditherImage(uint8_t * image, uint32_t w, uint32_t h, bool useAlpha = false, bool colSpace = false, bool forceRow = false, unsigned forcedrow = 0, bool isChunk = false, uint32_t idChunk = 0, bool isSprite = false, bool toIndex = false, int forceAlg = -1, int forceTileIdx = -1);
20 |
--------------------------------------------------------------------------------
/errorMsg.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include
18 | #include "system.h"
19 |
20 | /*Some users may not be programmers and will not run a debugger these error messages should make it easier for them to convey a bug to me.
21 | All they have to do is copy and paste the error message*/
22 | void TODO_error(int line, const char * file, const char * function) {
23 | fl_alert("TODO error in file %s function %s line %d", file, function, line);
24 | }
25 | void malloc_error(int line, const char * file, const char * function, int bytes) {
26 | fl_alert("malloc error in file %s function %s line %d\nNumber of bytes attempted %d", file, function, line, bytes);
27 | }
28 | void realloc_error(int line, const char * file, const char * function, int bytes) {
29 | fl_alert("realloc error in file %s function %s line %d\nNumber of bytes attempted %d", file, function, line, bytes);
30 | }
31 | void default_trigger(int line, const char * file, const char * function) {
32 | /*!
33 | In a switch statement sometimes there should be no default action so this function gets called to display an error message upon reaching default.
34 | */
35 | fl_alert("Default triggered in file %s function %s line %d", file, function, line);
36 | }
37 | void notSupportedBySys(int line, const char * file, const char * function, enum gameSystemEnum gs) {
38 | fl_alert("Not implemented for game system %d in file %s function %s line %d", (int)gs, file, function, line);
39 | }
40 |
--------------------------------------------------------------------------------
/errorMsg.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include "system.h"
19 | void TODO_error(int line, const char * file, const char * function);
20 | void malloc_error(int line, const char * file, const char * function, int bytes);
21 | void realloc_error(int line, const char * file, const char * function, int bytes);
22 | void default_trigger(int line, const char * file, const char * function);
23 | void notSupportedBySys(int line, const char * file, const char * function, enum gameSystemEnum gs);
24 | #define show_TODO_error TODO_error(__LINE__,__FILE__,__FUNCTION__);
25 | #define show_malloc_error(bytes_error) malloc_error(__LINE__,__FILE__,__FUNCTION__,bytes_error);
26 | #define show_realloc_error(bytes_error) realloc_error(__LINE__,__FILE__,__FUNCTION__,bytes_error);
27 | #define show_default_error default_trigger(__LINE__,__FILE__,__FUNCTION__);
28 | #define showGameSysError(sys) notSupportedBySys(__LINE__,__FILE__,__FUNCTION__,sys);
29 |
--------------------------------------------------------------------------------
/examples/NES/asm/build.sh:
--------------------------------------------------------------------------------
1 | ./asm6 main.asm main.nes
2 |
--------------------------------------------------------------------------------
/examples/NES/asm/logo.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/NES/asm/logo.bin
--------------------------------------------------------------------------------
/examples/SG-1000/C/Graphics II/Makefile:
--------------------------------------------------------------------------------
1 | CC=sdcc
2 | SOURCE= main.c SGlib.c
3 | OBJECTS=$(SOURCE:.c=.rel)
4 | OUTPUT_BASE=main
5 | HEX=$(OUTPUT_BASE).ihx
6 | ROM=$(OUTPUT_BASE).sg
7 |
8 | all: $(SOURCE) $(OBJECTS) $(HEX) $(ROM)
9 |
10 | %.rel: %.c
11 | $(CC) -c -mz80 --peep-file peep-rules.txt -o $@ $<
12 | $(HEX): $(OBJECTS)
13 | $(CC) -o $(HEX) -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sg.rel $(OBJECTS)
14 | $(ROM): $(HEX)
15 | ./ihx2sms $(HEX) $(ROM)
16 | clean:
17 | rm -f $(OBJECTS) $(HEX) $(ROM)
18 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Graphics II/image_source.txt:
--------------------------------------------------------------------------------
1 | https://pixabay.com/photos/seljalandsfoss-waterfall-iceland-1751463/
2 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Graphics II/main.c:
--------------------------------------------------------------------------------
1 | #include "SGlib.h"
2 | #include "waterfall_tiles.h"
3 | #include "waterfall_attrs.h"
4 |
5 | void main(void) {
6 | // SG_displayOff();
7 | // Load the tiles and tilemap and then turn on the screen.
8 | SG_loadTilePatterns(tiles, 0, sizeof(tiles));
9 | SG_loadTileColours(extAttrsData, 0, sizeof(extAttrsData));
10 |
11 | SG_setNextTileatXY(0, 0);
12 | uint8_t i,j,t;
13 | t = 0;
14 | for (i = 0; i < 3; ++i) {
15 | j = 255;
16 | do {
17 | SG_setTile(t++);
18 | } while(j--);
19 | }
20 |
21 | SG_displayOn();
22 | for(;;);
23 | }
24 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Graphics II/peep-rules.txt:
--------------------------------------------------------------------------------
1 | replace restart {
2 | ld a,%1
3 | add a,#0xFF
4 | ld %1,a
5 | or a, a
6 | } by {
7 | dec %1
8 | } if notUsed('a')
9 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Graphics II/seljalandsfoss-1751463_1920.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/SG-1000/C/Graphics II/seljalandsfoss-1751463_1920.png
--------------------------------------------------------------------------------
/examples/SG-1000/C/README:
--------------------------------------------------------------------------------
1 | These examples use https://github.com/sverx/devkitSMS
2 |
3 | As of writing devkitSMS is setup to initialize the TMS9918 in mode 2. For the
4 | other modes a patched version is included to initialize the TMS9918 in the
5 | correct mode for each example.
6 |
7 | You will still need to copy peep-rules.txt and crt0_sg.rel to the project
8 | directory because these files are used unmodified.
9 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/Makefile:
--------------------------------------------------------------------------------
1 | CC=sdcc
2 | SOURCE= main.c SGlib.c
3 | OBJECTS=$(SOURCE:.c=.rel)
4 | OUTPUT_BASE=main
5 | HEX=$(OUTPUT_BASE).ihx
6 | ROM=$(OUTPUT_BASE).sg
7 |
8 | all: $(SOURCE) $(OBJECTS) $(HEX) $(ROM)
9 |
10 | %.rel: %.c
11 | $(CC) -c -mz80 --peep-file peep-rules.txt -o $@ $<
12 | $(HEX): $(OBJECTS)
13 | $(CC) -o $(HEX) -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sg.rel $(OBJECTS)
14 | $(ROM): $(HEX)
15 | ./ihx2sms $(HEX) $(ROM)
16 | clean:
17 | rm -f $(OBJECTS) $(HEX) $(ROM)
18 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/main.c:
--------------------------------------------------------------------------------
1 | #include "SGlib.h"
2 | #include "tiles.h"
3 | #include "tilemap.h"
4 |
5 | void main(void) {
6 | // Load the tiles and tilemap and then turn on the screen.
7 | SG_loadTilePatterns(tiles, 0, sizeof(tiles));
8 | SG_loadTileMap(0, 0, tilemap, sizeof(tilemap));
9 |
10 | SG_displayOn();
11 | for(;;);
12 | }
13 |
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/text_mode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/SG-1000/C/Text/text_mode.png
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/text_mode.rgp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/SG-1000/C/Text/text_mode.rgp
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/text_mode_optimized.rgp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/SG-1000/C/Text/text_mode_optimized.rgp
--------------------------------------------------------------------------------
/examples/SG-1000/C/Text/tilemap.h:
--------------------------------------------------------------------------------
1 | // Width 40 Height 24 Uncompressed
2 | #include
3 | static const uint8_t tilemap[]={
4 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
6 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,5,6,7,8,9,0,
7 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,11,0,0,0,0,0,0,0,0,0,0,0,12,0,0,
8 | 13,14,14,0,0,15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,18,19,0,0,0,0,0,0,
9 | 0,0,0,0,0,0,0,0,13,14,14,0,0,0,0,20,21,22,23,24,0,25,26,27,27,28,29,30,31,32,33,34,
10 | 14,35,36,37,0,0,0,0,0,0,0,0,0,0,0,0,13,14,14,0,0,0,38,39,40,0,41,14,42,0,43,44,
11 | 14,45,46,47,48,0,0,49,14,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,14,14,0,0,0,50,14,
12 | 51,3,52,53,54,0,0,55,56,14,57,58,0,0,0,49,14,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
13 | 13,14,14,0,0,0,59,14,60,0,0,0,61,0,0,62,63,64,14,65,0,0,0,49,14,9,0,0,0,0,0,0,
14 | 0,0,0,0,0,0,0,0,66,14,14,67,0,0,55,68,14,69,27,70,71,0,72,73,74,75,14,76,77,78,0,79,
15 | 14,80,81,82,0,0,0,0,0,0,0,0,0,0,0,83,84,84,84,84,85,0,0,0,86,84,87,88,0,89,84,84,
16 | 90,91,84,84,84,92,0,0,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
17 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
18 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
20 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
21 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,96,96,0,0,0,0,0,97,96,96,11,0,0,
22 | 0,0,0,0,0,0,0,0,0,0,0,98,99,100,101,0,0,0,0,0,0,0,0,0,0,0,102,14,14,103,0,0,
23 | 0,20,104,14,105,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,107,14,108,0,0,0,0,0,0,0,0,0,
24 | 0,0,38,109,14,110,78,0,0,111,112,14,108,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,113,14,108,0,
25 | 0,0,0,0,0,0,0,0,0,0,13,114,115,14,116,0,117,118,113,14,119,0,0,0,120,121,122,123,124,125,0,0,
26 | 0,126,127,128,129,14,108,0,0,130,131,132,133,134,135,0,0,0,113,108,136,14,137,138,139,140,113,14,141,0,0,142,
27 | 14,143,0,55,144,76,145,0,146,14,147,0,113,14,108,0,38,148,149,96,150,14,151,0,0,0,152,19,0,153,14,154,
28 | 155,0,13,14,156,0,0,157,14,108,0,0,158,14,9,0,159,14,160,0,113,14,108,0,161,14,162,84,84,84,163,0,
29 | 0,0,164,9,0,165,166,167,168,0,13,14,169,0,0,170,14,171,0,0,172,173,174,0,175,14,176,0,177,14,178,0,
30 | 179,166,180,181,0,182,183,0,0,184,148,185,186,0,187,188,0,38,189,14,76,190,0,0,191,192,193,194,195,196,0,0,
31 | 197,198,76,199,200,201,202,203,0,204,205,14,206,207,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
32 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
33 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
34 | };
35 |
--------------------------------------------------------------------------------
/examples/gameGear/C/Makefile:
--------------------------------------------------------------------------------
1 | CC=sdcc
2 | SOURCE= main.c
3 | OBJECTS=$(SOURCE:.c=.rel)
4 | OUTPUT_BASE=main
5 | HEX=$(OUTPUT_BASE).ihx
6 | ROM=$(OUTPUT_BASE).gg
7 |
8 | all: $(SOURCE) $(OBJECTS) $(HEX) $(ROM)
9 |
10 | %.rel: %.c
11 | $(CC) -c -mz80 --peep-file peep-rules.txt -DTARGET_GG -o $@ $<
12 | $(HEX): $(OBJECTS)
13 | $(CC) -o $(HEX) -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sms.rel $(OBJECTS) SMSlib_GG.lib
14 | $(ROM): $(HEX)
15 | ./ihx2sms $(HEX) $(ROM)
16 | clean:
17 | rm -f $(OBJECTS) $(HEX) $(ROM)
18 |
--------------------------------------------------------------------------------
/examples/gameGear/C/README:
--------------------------------------------------------------------------------
1 | This example uses https://github.com/sverx/devkitSMS. I decided not to include
2 | the library because it may be updated and I may not be aware of this. I do not
3 | want to host an old version of the library. To compile place crt0_sms.rel,
4 | SMSlib_GG.lib, SMSlib.h and peep-rules.txt in this folder, run make and it will
5 | compile provided that you have installed SDCC.
6 |
--------------------------------------------------------------------------------
/examples/gameGear/C/main.c:
--------------------------------------------------------------------------------
1 | #include "SMSlib.h"
2 | #include "palette.h"
3 | #include "tiles.h"
4 | #include "tilemap.h"
5 | void main(void){
6 | SMS_displayOn();
7 | GG_loadBGPalette(palDat);
8 | GG_loadSpritePalette(palDat+32);
9 | SMS_loadTiles(tileDat,0,sizeof(tileDat));
10 | SMS_loadTileMapArea((32-20)/2,(24-18)/2,mapDat,20,18);
11 | for(;;);
12 | }
13 |
--------------------------------------------------------------------------------
/examples/gameGear/C/palette.h:
--------------------------------------------------------------------------------
1 | // Colors 0-31
2 | static const unsigned char palDat[]={
3 | 0,0,17,1,34,2,51,3,68,4,85,5,102,6,119,7,136,8,153,9,170,10,187,11,204,12,221,13,238,14,255,15,
4 | 0,0,17,1,34,2,112,6,33,6,68,4,49,9,102,6,12,0,193,11,81,13,60,4,115,14,152,9,171,10,201,15
5 | };
6 |
--------------------------------------------------------------------------------
/examples/gameGear/C/picture.rgp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/gameGear/C/picture.rgp
--------------------------------------------------------------------------------
/examples/gameGear/C/tilemap.h:
--------------------------------------------------------------------------------
1 | // Width 20 Height 18 Uncompressed
2 | static const unsigned char mapDat[]={
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,0,0,0,
4 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,2,0,3,0,0,0,0,0,0,0,0,0,
6 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,5,0,6,0,
7 | 7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
8 | 15,0,16,0,17,0,18,0,19,8,20,8,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,
9 | 31,0,0,0,0,0,0,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,
10 | 44,0,45,0,46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,
11 | 60,0,61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,8,69,0,70,0,71,0,72,0,73,0,74,0,75,0,
12 | 76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,8,88,8,89,0,90,0,91,0,
13 | 92,0,93,0,94,0,95,0,96,0,97,0,98,0,99,0,100,0,101,0,102,0,103,0,104,0,105,0,106,0,107,0,
14 | 108,0,109,0,110,0,111,0,112,0,113,0,114,0,115,0,116,0,117,0,118,0,119,0,120,0,121,0,122,0,123,0,
15 | 124,0,105,0,125,0,126,0,127,0,128,0,129,0,130,0,131,0,132,0,133,0,134,0,135,0,136,0,137,0,138,0,
16 | 139,0,140,0,141,0,142,0,143,0,144,0,145,0,146,0,147,0,148,0,149,0,150,0,151,0,152,0,153,0,154,0,
17 | 155,0,156,0,157,0,158,0,159,0,160,0,161,0,162,0,163,0,164,0,165,0,166,0,167,0,168,0,169,0,170,0,
18 | 171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,181,0,182,0,183,0,184,0,185,0,186,0,
19 | 187,0,188,0,189,0,190,0,0,0,191,0,192,0,193,0,194,0,195,0,196,0,197,0,198,0,199,0,200,0,201,0,
20 | 202,0,203,0,204,0,205,0,206,0,207,0,208,0,209,0,0,0,0,0,0,0,0,0,0,0,0,0,210,0,211,0,
21 | 212,0,213,0,214,0,215,0,216,0,217,0,218,0,219,0,220,0,221,0,222,0,0,0,0,0,0,0,0,0,0,0,
22 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,223,0,224,0,225,0,226,0,227,0,228,0,229,0,230,0,0,0,
23 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
26 | };
27 |
--------------------------------------------------------------------------------
/examples/genesis/asm/Assemble_instructions.txt:
--------------------------------------------------------------------------------
1 | Build: https://github.com/Clownacy/as-sonic and put the binaries and *.msg files in a folder called AS.
2 |
3 | Then run build.sh to build the example.
4 |
--------------------------------------------------------------------------------
/examples/genesis/asm/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | AS/asl -xx -U main.asm
3 | AS/p2bin main.p main.bin
4 |
--------------------------------------------------------------------------------
/examples/genesis/asm/tilemap.eni:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/asm/tilemap.eni
--------------------------------------------------------------------------------
/examples/genesis/asm/tiles.kos:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/asm/tiles.kos
--------------------------------------------------------------------------------
/examples/genesis/example.rgp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/example.rgp
--------------------------------------------------------------------------------
/examples/genesis/mappingDisplay/Art-Sonic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/mappingDisplay/Art-Sonic.bin
--------------------------------------------------------------------------------
/examples/genesis/mappingDisplay/DPLC-Sonic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/mappingDisplay/DPLC-Sonic.bin
--------------------------------------------------------------------------------
/examples/genesis/mappingDisplay/Map-Sonic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/mappingDisplay/Map-Sonic.bin
--------------------------------------------------------------------------------
/examples/genesis/mappingDisplay/Pal-Sonic.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/genesis/mappingDisplay/Pal-Sonic.bin
--------------------------------------------------------------------------------
/examples/genesis/mappingDisplay/build.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | asm68k /o op+ /o os+ /o ow+ /o oz+ /o oaq+ /o osq+ /o omq+ /p /o ae- main.asm, main.bin>main_errors.txt, , main.ls
3 |
--------------------------------------------------------------------------------
/examples/masterSystem/C/Makefile:
--------------------------------------------------------------------------------
1 | CC=sdcc
2 | SOURCE= main.c
3 | OBJECTS=$(SOURCE:.c=.rel)
4 | OUTPUT_BASE=main
5 | HEX=$(OUTPUT_BASE).ihx
6 | ROM=$(OUTPUT_BASE).sms
7 |
8 | all: $(SOURCE) $(OBJECTS) $(HEX) $(ROM)
9 |
10 | %.rel: %.c
11 | $(CC) -c -mz80 --peep-file peep-rules.txt -o $@ $<
12 | $(HEX): $(OBJECTS)
13 | $(CC) -o $(HEX) -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sms.rel $(OBJECTS) SMSlib.lib
14 | $(ROM): $(HEX)
15 | ./ihx2sms $(HEX) $(ROM)
16 | clean:
17 | rm -f $(OBJECTS) $(HEX) $(ROM)
18 |
--------------------------------------------------------------------------------
/examples/masterSystem/C/README:
--------------------------------------------------------------------------------
1 | This example uses https://github.com/sverx/devkitSMS. I decided not to include
2 | the library because it may be updated and I may not be aware of this. I do not
3 | want to host an old version of the library. To compile place crt0_sms.rel,
4 | SMSlib.lib, SMSlib.h and peep-rules.txt in this folder, run make and it will
5 | compile provided that you have installed SDCC.
6 |
--------------------------------------------------------------------------------
/examples/masterSystem/C/main.c:
--------------------------------------------------------------------------------
1 | #include "SMSlib.h"
2 | #include "palette.h"
3 | #include "tiles.h"
4 | #include "tilemap.h"
5 | void main(void){
6 | SMS_displayOn();
7 | SMS_loadBGPalette(palDat);
8 | SMS_loadSpritePalette(palDat+16);
9 | SMS_loadTiles(tileDat,0,sizeof(tileDat));
10 | SMS_loadTileMap(0,0,mapDat,sizeof(mapDat));
11 | for(;;);
12 | }
13 |
--------------------------------------------------------------------------------
/examples/masterSystem/C/palette.h:
--------------------------------------------------------------------------------
1 | // Colors 0-31
2 | static const unsigned char palDat[]={
3 | 0,1,5,20,16,17,21,2,6,18,22,3,41,42,23,63,0,1,5,4,20,16,17,21,2,18,22,25,37,42,23,63
4 | };
5 |
--------------------------------------------------------------------------------
/examples/masterSystem/C/picture.rgp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/examples/masterSystem/C/picture.rgp
--------------------------------------------------------------------------------
/filemisc.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #pragma once
18 | #include
19 | #include
20 | #include
21 |
22 | enum class fileType_t {
23 | tCancel = -1,
24 | tBinary,
25 | tCheader,
26 | tASM,
27 | tBEX,
28 | };
29 | void saveStrifNot(FILE*fp, const char*str, const char*cmp);
30 | void fileToStr(FILE*fp, std::string&s, const char*defaultStr);
31 | int clipboardAsk(void);
32 | fileType_t askSaveType(bool save = true, fileType_t def = fileType_t::tBinary);
33 | bool saveBinAsText(const void * ptr, size_t sizeBin, FILE * fp, fileType_t type, const char*comment, const char*label, int bits, boost::endian::order endian);
34 |
--------------------------------------------------------------------------------
/filereader.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #include
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include "filemisc.h"
24 | #include "compressionWrapper.h"
25 | struct filereader {
26 | size_t amt, lenTotal;
27 | std::vectorlens;
28 | std::vectordat;
29 | std::vectornames;
30 | filereader(boost::endian::order endian, unsigned bytesPerElement, const char*title = nullptr, bool relptr = false, unsigned offbits = 16, bool be = true, const char * filename = nullptr, fileType_t forceType = fileType_t::tCancel, CompressionType compression = CompressionType::Cancel);
31 | unsigned selDat(void);
32 | ~filereader();
33 | };
34 |
--------------------------------------------------------------------------------
/gamedef.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | enum gameType_t {
3 | tSonic1,
4 | tSonic2,
5 | tSonic3,
6 | };
7 |
--------------------------------------------------------------------------------
/gui.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | --]]
17 | function setPalTypeCB(menuItm)
18 | local vStr = menuItm:value()
19 | local v = palTabSelLUT[vStr]
20 |
21 | local p = projects.current
22 | p:setPalType(v)
23 | p.palette:toRgbAll()
24 | rgt.damage()
25 | end
26 |
27 | spriteSizeTextToValueTable = nil
28 |
29 | function setSpriteSizeCB(unused)
30 | local p = projects.current
31 |
32 | local spriteSizeTxt = spriteSizeSel:value()
33 | local spriteSizeID = spriteSizeTextToValueTable[spriteSizeTxt]
34 |
35 | p:setSpriteSizeID(spriteSizeID)
36 | rgt.redraw()
37 | end
38 |
39 | function generateLutFromList(choiceList)
40 | local tmp = {}
41 | for i = 1, #choiceList do
42 | tmp[choiceList[i]] = i - 1
43 | end
44 | return tmp
45 | end
46 |
47 | function addItemsToChoice(menu, choiceList)
48 | for i = 1, #choiceList do
49 | local menuItemEscaped = choiceList[i]:gsub('/', '\\/')
50 | menu:add(menuItemEscaped)
51 | end
52 | end
53 |
54 | function tabConfig(tab)
55 | if tab == rgt.paletteTab then
56 | palTabSel = fltk.choice(336, 464, 128, 24, "Palette table selection")
57 | palTabSel:align(FL.ALIGN_TOP)
58 | palTabSel:callback(setPalTypeCB)
59 | palTabSelOptions = {"HardwareMan's measured values", 'round(255*v/7)', 'Steps of 36', 'Steps of 32'}
60 | palTabSelLUT = generateLutFromList(palTabSelOptions)
61 | addItemsToChoice(palTabSel, palTabSelOptions)
62 | palTabSel:labelsize(12)
63 |
64 |
65 | spriteSizeSel = fltk.choice(336, 464, 128, 24, "Sprite size")
66 | spriteSizeSel:align(FL.ALIGN_TOP)
67 | spriteSizeSel:callback(setSpriteSizeCB)
68 | spriteSizeSel:labelsize(12)
69 | spriteSizeSel:hide()
70 | elseif tab==rgt.levelTab then
71 | initLevelEditor()
72 | end
73 | end
74 |
--------------------------------------------------------------------------------
/guidefs.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #define default_map_off_x 256
19 | #define default_map_off_y 256
20 | #define defaultspritex 192
21 | #define defaultspritey 72
22 | #define tile_placer_tile_offset_x 88
23 | #define default_tile_placer_tile_offset_y 208
24 | #define tile_place_buttons_x_off 8
25 | #define palette_bar_offset_x 16
26 | #define default_palette_bar_offset_y 56
27 | #define palette_preview_box_x 408
28 | #define palette_preview_box_y 208
29 | #define default_tile_edit_offset_x 344
30 | #define default_tile_edit_truecolor_off_x 8
31 | #define default_tile_edit_truecolor_off_y 224
32 | #define default_tile_edit_offset_y 224
33 | #define true_color_box_size 48
34 | #define default_true_color_box_y 188
35 | #define default_true_color_box_x 732
36 | #define DefaultChunkX 208
37 | #define DefaultChunkY 80
38 |
39 | //These values below must correspond with array offsets for tabs
40 | #define pal_edit 0
41 | #define tile_edit 1
42 | #define tile_place 2
43 | #define chunkEditor 3
44 | #define spriteEditor 4
45 | #define levelEditor 5
46 | #define settingsTab 6
47 | #define luaTab 7
48 |
--------------------------------------------------------------------------------
/help-src.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Help Listing
4 |
5 |
6 | Help Listing
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/image.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #pragma once
18 | #include
19 |
20 | #include
21 |
22 | bool getMaskColorImg(Fl_Shared_Image*loaded_image, bool grayscale, unsigned*remap, uint8_t*palMap, uint8_t*mask, bool&alphaSel); //mask must pointer to an array or byte with atleast 1 byte for 1 bpp images or 3 bytes for 3 bpp and 4 bpp images returns true if ok false if cancel
23 | bool handle1byteImg(Fl_Shared_Image*loaded_image, unsigned*remap, unsigned*numcol = nullptr); //Returns true if grayscale false if gif
24 |
--------------------------------------------------------------------------------
/iqa/CHANGELOG.txt:
--------------------------------------------------------------------------------
1 | 2011-07-06 1.1.2 (rev 40)
2 |
3 | - Fixed MS-SSIM seg-fault issue when height greater than width (#3349231).
4 | - Fixed linker warnings on Windows debug builds.
5 |
6 | 2011-04-15 1.1.1 (rev 36)
7 |
8 | - Added 64-bit build configurations on Windows.
9 | - Fixed 64-bit rounding bug in tests (#3286061).
10 | - Fixed MS-SSIM buffer overflow bug for images that don't scale to an even
11 | multiple of 2 (#3288043). Added corresponding unit test.
12 |
13 | 2011-04-09 1.1.0 (rev 30)
14 |
15 | - Added MS-SSIM algorithm.
16 | - Added MS-SSIM* algorithm.
17 | - Fixed bug (#3269715) that caused SSIM to return inflated results when using
18 | custom SSIM arguments.
19 | - Fixed bug (#3269702) where the SSIM algorithm was returning NAN instead of
20 | INFINITY on error. Since NAN always fails comparisons (even with itself),
21 | there was no way for an application to determine if an error occurred.
22 | - Improved the performace of the decimate operation.
23 |
24 | 2011-04-01 1.0.0 (rev 12)
25 |
26 | - First release. Supports MSE, PSNR, and SSIM.
27 |
28 |
--------------------------------------------------------------------------------
/iqa/Makefile:
--------------------------------------------------------------------------------
1 | SRCDIR=./source
2 | SRC= \
3 | $(SRCDIR)/convolve.c \
4 | $(SRCDIR)/decimate.c \
5 | $(SRCDIR)/math_utils.c \
6 | $(SRCDIR)/mse.c \
7 | $(SRCDIR)/psnr.c \
8 | $(SRCDIR)/ssim.c \
9 | $(SRCDIR)/ms_ssim.c
10 |
11 | OBJ = $(SRC:.c=.o)
12 |
13 | INCLUDES = -I./include
14 | CC = gcc
15 |
16 | ifeq ($(RELEASE),1)
17 | OUTDIR=./build/release
18 | CFLAGS=-O2 -Wall
19 | else
20 | OUTDIR=./build/debug
21 | CFLAGS=-g -Wall
22 | endif
23 |
24 | OUT = $(OUTDIR)/libiqa.a
25 |
26 | .c.o:
27 | $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
28 |
29 | $(OUT): $(OBJ)
30 | mkdir -p $(OUTDIR)
31 | ar rcs $(OUT) $(OBJ)
32 | mv $(OBJ) $(OUTDIR)
33 |
34 | clean:
35 | rm -f $(OUTDIR)/*.o $(OUT) $(SRCDIR)/*.o
36 | cd test; $(MAKE) clean;
37 |
38 | .PHONY : test
39 | test:
40 | cd test; $(MAKE);
41 |
--------------------------------------------------------------------------------
/iqa/README.txt:
--------------------------------------------------------------------------------
1 | Doxygen documentation can be found at: https://web.archive.org/web/20150724084852/http://tdistler.com/iqa/
2 |
3 | BUILD:
4 |
5 | All build artifacts end up in build/, where is
6 | 'debug' or 'release'.
7 |
8 | Windows:
9 | - Open iqa.sln, select 'Debug' or 'Release', and build. The output is a
10 | static library 'iqa.lib'.
11 | - To run the tests under the debugger, first right-click the 'test' project,
12 | select Properties -> Configuration Properties -> Debugging and set
13 | 'Working Directory' to '$(OutDir)'. Then start the application.
14 |
15 | Linux:
16 | - Change directories into the root of the IQA branch you want to build.
17 | - Type `make` for a debug build, or `make RELEASE=1` for a release build.
18 | The output is a static library 'libiqa.a'.
19 | - Type `make test` (or `make test RELEASE=1`) to build the unit tests.
20 | - Type `make clean` (or `make clean RELEASE=1`) to delete all build
21 | artifacts.
22 | - To run the tests, `cd` to the build/ directory and type
23 | `./test`.
24 |
25 |
26 | USE:
27 |
28 | - Include 'iqa.h' in your source file.
29 | - Call iqa_* methods.
30 | - Link against the IQA library.
31 |
32 |
33 | HELP & SUPPORT:
34 |
35 | Further help can be found at: https://sourceforge.net/projects/iqa/support
36 |
37 |
--------------------------------------------------------------------------------
/iqa/doc/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Copyright (c) 2011 by Tom Distler
4 |
5 |
6 |
8 |
9 |
10 |
11 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/iqa/iqa.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iqa", "iqa.vcproj", "{3C7BB421-C147-4828-8EAE-53A5F1A0394A}"
5 | EndProject
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{CB10555C-6A76-4AD9-A5BA-2D2733115859}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A} = {3C7BB421-C147-4828-8EAE-53A5F1A0394A}
9 | EndProjectSection
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug|Win32 = Debug|Win32
14 | Debug|x64 = Debug|x64
15 | Release|Win32 = Release|Win32
16 | Release|x64 = Release|x64
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Debug|Win32.ActiveCfg = Debug|Win32
20 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Debug|Win32.Build.0 = Debug|Win32
21 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Debug|x64.ActiveCfg = Debug|x64
22 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Debug|x64.Build.0 = Debug|x64
23 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Release|Win32.ActiveCfg = Release|Win32
24 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Release|Win32.Build.0 = Release|Win32
25 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Release|x64.ActiveCfg = Release|x64
26 | {3C7BB421-C147-4828-8EAE-53A5F1A0394A}.Release|x64.Build.0 = Release|x64
27 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Debug|Win32.ActiveCfg = Debug|Win32
28 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Debug|Win32.Build.0 = Debug|Win32
29 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Debug|x64.ActiveCfg = Debug|x64
30 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Debug|x64.Build.0 = Debug|x64
31 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Release|Win32.ActiveCfg = Release|Win32
32 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Release|Win32.Build.0 = Release|Win32
33 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Release|x64.ActiveCfg = Release|x64
34 | {CB10555C-6A76-4AD9-A5BA-2D2733115859}.Release|x64.Build.0 = Release|x64
35 | EndGlobalSection
36 | GlobalSection(SolutionProperties) = preSolution
37 | HideSolutionNode = FALSE
38 | EndGlobalSection
39 | EndGlobal
40 |
--------------------------------------------------------------------------------
/iqa/resources/iqa_logo.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/resources/iqa_logo.bmp
--------------------------------------------------------------------------------
/iqa/resources/iqa_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/resources/iqa_logo.jpg
--------------------------------------------------------------------------------
/iqa/resources/mse_eq.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/resources/mse_eq.jpg
--------------------------------------------------------------------------------
/iqa/resources/psnr_eq.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/resources/psnr_eq.jpg
--------------------------------------------------------------------------------
/iqa/source/decimate.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #include "decimate.h"
35 | #include
36 |
37 | int _iqa_decimate(float *img, int w, int h, int factor, const struct _kernel *k, float *result, int *rw, int *rh)
38 | {
39 | int x,y;
40 | int sw = w/factor + (w&1);
41 | int sh = h/factor + (h&1);
42 | int dst_offset;
43 | float *dst=img;
44 |
45 | if (result)
46 | dst = result;
47 |
48 | /* Downsample */
49 | for (y=0; y
36 |
37 | /* PSNR(a,b) = 10*log10(L^2 / MSE(a,b)), where L=2^b - 1 (8bit = 255) */
38 | float iqa_psnr(const unsigned char *ref, const unsigned char *cmp, int w, int h, int stride)
39 | {
40 | const int L_sqd = 255 * 255;
41 | return (float)( 10.0 * log10( L_sqd / iqa_mse(ref,cmp,w,h,stride) ) );
42 | }
43 |
--------------------------------------------------------------------------------
/iqa/test/Makefile:
--------------------------------------------------------------------------------
1 | SRCDIR=./source
2 | SRC= \
3 | $(SRCDIR)/bmp.c \
4 | $(SRCDIR)/hptime.c \
5 | $(SRCDIR)/main.c \
6 | $(SRCDIR)/test_convolve.c \
7 | $(SRCDIR)/test_decimate.c \
8 | $(SRCDIR)/test_mse.c \
9 | $(SRCDIR)/test_psnr.c \
10 | $(SRCDIR)/test_ssim.c \
11 | $(SRCDIR)/test_ms_ssim.c
12 |
13 | OBJ = $(SRC:.c=.o)
14 |
15 | INCLUDES = -I./include -I../include
16 | CC = gcc
17 |
18 | ifeq ($(RELEASE),1)
19 | OUTDIR=../build/release
20 | CFLAGS=-O2 -Wall
21 | else
22 | OUTDIR=../build/debug
23 | CFLAGS=-g -Wall
24 | endif
25 |
26 | OUT = $(OUTDIR)/test
27 |
28 | LFLAGS=-L$(OUTDIR)
29 | LIBS=$(OUTDIR)/libiqa.a -lm -lrt
30 |
31 | .c.o:
32 | $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
33 |
34 | $(OUT): $(OBJ)
35 | mkdir -p $(OUTDIR)
36 | $(CC) $(INCLUDES) $(CFLAGS) $(LFLAGS) $^ $(LIBS) -o $@
37 | cp ./resources/*.bmp $(OUTDIR)
38 | mv $(OBJ) $(OUTDIR)
39 |
40 | clean:
41 | rm -f $(OUTDIR)/*.o $(OUT) $(SRCDIR)/*.o
42 | rm -f $(OUTDIR)/*.bmp
43 |
44 |
--------------------------------------------------------------------------------
/iqa/test/include/hptime.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _HPTIME_H_
35 | #define _HPTIME_H_
36 |
37 | /*
38 | * Returns the frequency of the high-performance clock.
39 | * The frequency doesn't vary over time, so it is safe to cache to this value.
40 | */
41 | unsigned long long hpt_get_frequency();
42 |
43 | /*
44 | * Returns the current clock value.
45 | */
46 | unsigned long long hpt_get_time();
47 |
48 | /*
49 | * Calculates the elapsed time.
50 | * @return The elapsed time in seconds.
51 | */
52 | double hpt_elapsed_time(const unsigned long long start, const unsigned long long end, const unsigned long long freq);
53 |
54 | #endif /*_HPTIME_H_*/
55 |
--------------------------------------------------------------------------------
/iqa/test/include/test_convolve.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_CONVOLVE_H_
35 | #define _TEST_CONVOLVE_H_
36 |
37 | int test_convolve();
38 |
39 | #endif /*_TEST_CONVOLVE_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/include/test_decimate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_DECIMATE_H_
35 | #define _TEST_DECIMATE_H_
36 |
37 | int test_decimate();
38 |
39 | #endif /*_TEST_DECIMATE_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/include/test_ms_ssim.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_MS_SSIM_H_
35 | #define _TEST_MS_SSIM_H_
36 |
37 | int test_ms_ssim();
38 |
39 | #endif /*_TEST_MS_SSIM_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/include/test_mse.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_MSE_H_
35 | #define _TEST_MSE_H_
36 |
37 | int test_mse();
38 |
39 | #endif /*_TEST_MSE_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/include/test_psnr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_PSNR_H_
35 | #define _TEST_PSNR_H_
36 |
37 | int test_psnr();
38 |
39 | #endif /*_TEST_PSNR_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/include/test_ssim.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef _TEST_SSIM_H_
35 | #define _TEST_SSIM_H_
36 |
37 | int test_ssim();
38 |
39 | #endif /*_TEST_SSIM_H_*/
40 |
--------------------------------------------------------------------------------
/iqa/test/octave/README.txt:
--------------------------------------------------------------------------------
1 | The correct unit test values are derived by recreating the image quality
2 | algorithms in Octave (the open-source equivalent of Matlab). To run the scripts
3 | yourself, make sure (1) to set the current directory in Octave to where the
4 | scripts are located, and (2) make sure the path to the test bitmaps in the
5 | 'resources' directory is in Octave's IMAGE_PATH (I do this by running Octave
6 | with the --image-path= argument).
7 | .
8 |
--------------------------------------------------------------------------------
/iqa/test/octave/test_convolve.m:
--------------------------------------------------------------------------------
1 | % This file is used to generate the correct output data for the iqa_convolve and
2 | % iqa_img_filter tests.
3 |
4 | img_1x1 = [128];
5 | img_2x2 = [255 0; 0 255];
6 | img_4x3 = [255 128 64 0; 128 64 0 255; 64 0 255 128];
7 | img_4x4 = [255 128 64 0; 128 64 0 255; 64 0 255 128; 0 255 128 64];
8 |
9 | kernel_1x1 = ones(1);
10 | kernel_2x2 = ones(2);
11 | kernel_3x3 = ones(3);
12 |
13 | % normalize
14 | kernel_2x2 = kernel_2x2/sum(kernel_2x2(:));
15 | kernel_3x3 = kernel_3x3/sum(kernel_3x3(:));
16 |
17 | disp("\n--- CONVOLVE ---");
18 | disp("\n1x1 image with 1x1 kernel:");
19 | filter2(kernel_1x1, img_1x1, 'valid')
20 |
21 | disp("\n2x2 image with 1x1 kernel:");
22 | filter2(kernel_1x1, img_2x2, 'valid')
23 |
24 | disp("\n2x2 image with 3x3 kernel:");
25 | filter2(kernel_3x3, img_2x2, 'valid')
26 |
27 | disp("\n4x3 image with 2x2 kernel:");
28 | filter2(kernel_2x2, img_4x3, 'valid')
29 |
30 | disp("\n4x4 image with 3x3 kernel:");
31 | filter2(kernel_3x3, img_4x4, 'valid')
32 |
33 |
34 | disp("\n--- IMG_FILTER ---");
35 | disp("\n1x1 image with 1x1 kernel:");
36 | imfilter(img_1x1, kernel_1x1, 'symmetric', 'same')
37 |
38 | disp("\n2x2 image with 1x1 kernel:");
39 | imfilter(img_2x2, kernel_1x1, 'symmetric', 'same')
40 |
41 | disp("\n4x3 image with 2x2 kernel:");
42 | imfilter(img_4x3, kernel_2x2, 'symmetric', 'same')
43 |
44 | disp("\n4x4 image with 3x3 kernel:");
45 | imfilter(img_4x4, kernel_3x3, 'symmetric', 'same')
46 |
--------------------------------------------------------------------------------
/iqa/test/octave/test_decimate.m:
--------------------------------------------------------------------------------
1 | % This file is used to generate the correct output data for the iqa_decimate
2 | % tests.
3 |
4 | img_4x4 = [255 128 64 0; 128 64 0 255; 64 0 255 128; 0 255 128 64];
5 | img_5x5 = [0 1 2 3 5; 73 79 83 89 97; 127 131 137 139 149; 179 181 191 193 197; 233 239 241 251 255];
6 |
7 | lpf_avg_2x2 = ones(2);
8 | lpf_gaussian_3x3 = [0.07511 0.12384 0.07511; 0.12384 0.20418 0.12384; 0.07511 0.12384 0.07511]; % normalized
9 |
10 | % normalize
11 | lpf_avg_2x2 = lpf_avg_2x2/sum(lpf_avg_2x2(:));
12 |
13 | disp("\n--- DECIMATE ---\n");
14 |
15 | lpf_avg_2x2
16 | lpf_gaussian_3x3
17 |
18 | img_4x4
19 |
20 | disp("\n4x4 image with linear 2x2 kernel and 2x factor:");
21 | img = imfilter(img_4x4, lpf_avg_2x2, 'symmetric', 'same');
22 | img(1:2:end,1:2:end)
23 |
24 | disp("\n4x4 image with gaussian 3x3 kernel and 2x factor:");
25 | img = imfilter(img_4x4, lpf_gaussian_3x3, 'symmetric', 'same');
26 | img(1:2:end,1:2:end)
27 |
28 | img_5x5
29 |
30 | disp("\n5x5 image with linear 2x2 kernel and 2x factor:");
31 | img = imfilter(img_5x5, lpf_avg_2x2, 'symmetric', 'same');
32 | img(1:2:end,1:2:end)
33 |
34 | disp("\n5x5 image with gaussian 3x3 kernel and 2x factor:");
35 | img = imfilter(img_5x5, lpf_gaussian_3x3, 'symmetric', 'same');
36 | img(1:2:end,1:2:end)
37 |
38 | disp("\n5x5 image with gaussian 3x3 kernel and 3x factor:");
39 | img = imfilter(img_5x5, lpf_gaussian_3x3, 'symmetric', 'same');
40 | img(1:3:end,1:3:end)
41 |
42 |
--------------------------------------------------------------------------------
/iqa/test/octave/test_mse.m:
--------------------------------------------------------------------------------
1 | % This file is used to generate the correct output data for the iqa_mse tests.
2 |
3 | img_1x1 = [128];
4 | img_2x2 = [0 128 192 255];
5 |
6 | function mse = _mse(img1, img2)
7 | mse = 0;
8 | for idx = 1:numel(img1)
9 | mse = mse + ((img1(idx) - img2(idx))^2);
10 | end
11 | mse = mse/numel(img1);
12 | endfunction
13 |
14 | img_1x1
15 | img_2x2
16 |
17 | disp("\n1x1 Identical:");
18 | _mse(img_1x1,img_1x1)
19 |
20 | disp("\n1x1 Different:");
21 | img_1x1_mod = img_1x1 + [8];
22 | _mse(img_1x1,img_1x1_mod)
23 |
24 | disp("\n2x2 Identical:");
25 | _mse(img_2x2,img_2x2)
26 |
27 | disp("\n2x2 Different:");
28 | img_2x2_mod = img_2x2;
29 | img_2x2_mod(3) -= 13;
30 | _mse(img_2x2,img_2x2_mod)
31 |
--------------------------------------------------------------------------------
/iqa/test/octave/test_psnr.m:
--------------------------------------------------------------------------------
1 | % This file is used to generate the correct output data for the iqa_psnr tests.
2 |
3 | img_1x1 = [128];
4 | img_2x2 = [0 128 192 255];
5 |
6 | function mse = _mse(img1, img2)
7 | mse = 0;
8 | for idx = 1:numel(img1)
9 | mse = mse + ((img1(idx) - img2(idx))^2);
10 | end
11 | mse = mse/numel(img1);
12 | endfunction
13 |
14 | function psnr = _psnr(img1, img2)
15 | L = 255;
16 | mse = _mse(img1,img2);
17 | psnr = 10 * log10( (L^2)/mse );
18 | endfunction
19 |
20 | img_1x1
21 | img_2x2
22 |
23 | disp("\n1x1 Identical:");
24 | _psnr(img_1x1,img_1x1)
25 |
26 | disp("\n1x1 Different:");
27 | img_1x1_mod = img_1x1 + [8];
28 | _psnr(img_1x1,img_1x1_mod)
29 |
30 | disp("\n2x2 Identical:");
31 | _psnr(img_2x2,img_2x2)
32 |
33 | disp("\n2x2 Different:");
34 | img_2x2_mod = img_2x2;
35 | img_2x2_mod(3) -= 19;
36 | _psnr(img_2x2,img_2x2_mod)
37 |
--------------------------------------------------------------------------------
/iqa/test/resources/Courtright.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/Courtright.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/Courtright_Noise.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/Courtright_Noise.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/blur.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/blur.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/contrast.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/contrast.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/einstein.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/einstein.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/flipvertical.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/flipvertical.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/impulse.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/impulse.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/jpg.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/jpg.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/meanshift.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/meanshift.bmp
--------------------------------------------------------------------------------
/iqa/test/resources/skate_480x360.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ComputerNerd/Retro-Graphics-Toolkit/fe668643721c763e76c756ed643d6d31c4bc527f/iqa/test/resources/skate_480x360.bmp
--------------------------------------------------------------------------------
/iqa/test/source/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011, Tom Distler (http://tdistler.com)
3 | * All rights reserved.
4 | *
5 | * The BSD License
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions are met:
9 | *
10 | * - Redistributions of source code must retain the above copyright notice,
11 | * this list of conditions and the following disclaimer.
12 | *
13 | * - Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | *
17 | * - Neither the name of the tdistler.com nor the names of its contributors may
18 | * be used to endorse or promote products derived from this software without
19 | * specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #include "test_convolve.h"
35 | #include "test_decimate.h"
36 | #include "test_mse.h"
37 | #include "test_psnr.h"
38 | #include "test_ssim.h"
39 | #include "test_ms_ssim.h"
40 | #include
41 |
42 | int main()
43 | {
44 | int failures=0;
45 |
46 | printf("\n");
47 | failures += test_convolve();
48 | failures += test_decimate();
49 | failures += test_mse();
50 | failures += test_psnr();
51 | failures += test_ssim();
52 | failures += test_ms_ssim();
53 |
54 | if (failures)
55 | printf("\n\nRESULT: *** FAIL (%i) ***\n\n", failures);
56 | else
57 | printf("\n\nRESULT: Success\n\n");
58 |
59 | return failures;
60 | }
61 |
--------------------------------------------------------------------------------
/luaChunk.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #ifndef LUA_CHUNK_HPP
18 | #define LUA_CHUNK_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Chunk(lua_State *L, size_t projectIDX, size_t chunkIDX);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaChunkEntry.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_CHUNK_ENTRY_HPP
18 | #define LUA_CHUNK_ENTRY_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_ChunkEntry(lua_State *L, size_t projectIDX, size_t chunkIDX, size_t columnIDX, size_t entryIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaChunkRow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #include "luaChunkRow.hpp"
18 | #include "luaChunkEntry.hpp"
19 | #include "luaHelpers.hpp"
20 | #include "project.h"
21 | #include "dub/dub.h"
22 | static int chunkRow__get_(lua_State *L) {
23 | int type = lua_type(L, 2);
24 |
25 | if (type == LUA_TNUMBER) {
26 | getIdxPtrChk
27 |
28 | int k = luaL_checkinteger(L, 2) - 1;
29 |
30 | if (k >= 0 && k < projects->at(idxPtr[0]).Chunk->wi) {
31 | luaopen_ChunkEntry(L, idxPtr[0], idxPtr[1], idxPtr[2], k);
32 | return 1;
33 | }
34 | }
35 |
36 | return 0;
37 | }
38 |
39 | static int chunkRow__len_(lua_State *L) {
40 | getProjectIDX
41 | lua_pushinteger(L, projects->at(projectIDX).Chunk->wi);
42 | return 1;
43 | }
44 |
45 | static int chunkRow___tostring(lua_State *L) {
46 | const size_t *idxPtr = (const size_t*)lua_touserdata(L, 1);
47 | lua_pushfstring(L, "Chunk row: %d from chunk: %d from project: %d", idxPtr[2], idxPtr[1], idxPtr[0]);
48 | return 1;
49 | }
50 |
51 | static const struct luaL_Reg chunkRow_member_methods[] = {
52 | { "__index", chunkRow__get_ },
53 | { "__len", chunkRow__len_ },
54 | { "__tostring", chunkRow___tostring },
55 | { "deleted", dub::isDeleted },
56 | { NULL, NULL},
57 | };
58 |
59 | int luaopen_ChunkRow(lua_State *L, size_t projectIDX, size_t chunkIDX, size_t rowIDX) {
60 | // Create the metatable which will contain all the member methods
61 | luaL_newmetatable(L, "chunkRow");
62 | //
63 |
64 | // register member methods
65 | dub::fregister(L, chunkRow_member_methods);
66 | dub::setup(L, "chunkRow");
67 | // setup meta-table
68 |
69 | size_t* idxUserData = (size_t*)lua_newuserdata(L, sizeof(size_t) * 3);
70 | idxUserData[0] = projectIDX;
71 | idxUserData[1] = chunkIDX;
72 | idxUserData[2] = rowIDX;
73 |
74 | luaL_getmetatable(L, "chunkRow");
75 | lua_setmetatable(L, -2);
76 | return 1;
77 | }
78 |
--------------------------------------------------------------------------------
/luaChunkRow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #ifndef LUA_CHUNK_COLUMN_HPP
18 | #define LUA_CHUNK_COLUMN_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_ChunkRow(lua_State *L, size_t projectIDX, size_t chunkIDX, size_t rowIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaChunks.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #ifndef LUA_CHUNKS_HPP
18 | #define LUA_CHUNKS_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Chunks(lua_State *L, unsigned idx);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaExamples/GUI/beep.lua:
--------------------------------------------------------------------------------
1 | fl.beep()
2 | fltk.alert("a beep has occurred")
3 |
--------------------------------------------------------------------------------
/luaExamples/GUI/blankWindow.lua:
--------------------------------------------------------------------------------
1 | -- How to create a simple window and wait for the window to exit.
2 | win=fltk.window(640,480)
3 | win:done()
4 | win:show()
5 | while win:shown() do
6 | Fl.wait()
7 | end
8 |
--------------------------------------------------------------------------------
/luaExamples/GUI/choice.lua:
--------------------------------------------------------------------------------
1 | -- fltk.choice allows up to three choices.
2 |
3 | local e = fltk.choice("Question", "You have no choice")
4 | fltk.message(e)
5 |
6 | e = fltk.choice("Question", "Zero", "One")
7 | fltk.message(e)
8 |
9 | e = fltk.choice("Question", "Zero", "One", "Two")
10 | fltk.message(e)
11 |
--------------------------------------------------------------------------------
/luaExamples/GUI/color_chooser.lua:
--------------------------------------------------------------------------------
1 | -- Note this function is a bit different than the standard fl_color_chooser function in the sense that instead of passing r,g,b by reference r,g,b are returned
2 | local ret,r,g,b=fl.color_chooser("Pick in rgb") -- mode is an optional parameter
3 | if ret~=0 then
4 | fltk.message(string.format("RGB values are: %d %d %d",math.floor(r * 255),math.floor(g * 255),math.floor(b * 255)))
5 | end
6 | ret,r,g,b=fl.color_chooser("Pick in hsv",3)
7 | if ret~=0 then
8 | fltk.message(string.format("Converted to RGB: %d %d %d",math.floor(r * 255),math.floor(g * 255),math.floor(b * 255)))
9 | end
10 | ret,r,g,b=fl.color_chooser("Pick a color",-1,1.0) -- You can also specify default values in r,g,b order there is no need to specify all three when doing so note that these can of course be changed by the user even when said channel has a default value.
11 | if ret~=0 then
12 | fltk.message(string.format("RGB values are: %d %d %d",math.floor(r * 255),math.floor(g * 255),math.floor(b * 255)))
13 | end
14 |
--------------------------------------------------------------------------------
/luaExamples/GUI/dir_chooser.lua:
--------------------------------------------------------------------------------
1 | local dir=fl.dir_chooser() -- The three parameters are optional
2 | if dir == nil or dir == '' then
3 | fltk.alert("No directory specified")
4 | else
5 | fltk.message(dir)
6 | end
7 |
--------------------------------------------------------------------------------
/luaExamples/GUI/file_chooser.lua:
--------------------------------------------------------------------------------
1 | local fname=fl.file_chooser("Save hello word to") -- All parameters are optional
2 | if not (fname == nil or fname == '') then
3 | local file=assert(io.open(fname,"w"))
4 | io.output(file)
5 | io.write("Hello world")
6 | io.close(file)
7 | end
8 |
--------------------------------------------------------------------------------
/luaExamples/GUI/hello.lua:
--------------------------------------------------------------------------------
1 | fltk.message("Hello world")
2 |
--------------------------------------------------------------------------------
/luaExamples/GUI/input.lua:
--------------------------------------------------------------------------------
1 | local s=fl.input() -- The two parameters are optional
2 | fltk.message("You entered:\n"..s)
3 |
--------------------------------------------------------------------------------
/luaExamples/GUI/windowDrawHandle.lua:
--------------------------------------------------------------------------------
1 | -- To allows for more control over a window, Lua functions can be called for draw and handle
2 |
3 | function MyWindow(w, h, label)
4 | local win = fltk.double_window_sub(w, h, label)
5 | win:override_handle(handle)
6 | win:override_draw(draw)
7 | return win
8 | end
9 |
10 | function draw(win)
11 | win:super_draw()
12 |
13 | local xPos = fltk.event_x()
14 | local yPos = fltk.event_y()
15 |
16 | fltk.color(0, 0, 255)
17 | fltk.circle(xPos, yPos, 25)
18 |
19 | local mouseXYstr = string.format("%d %d", xPos, yPos)
20 | fltk.font(win:labelfont(), win:labelsize())
21 | fltk.color(win:labelcolor())
22 | fltk.draw(mouseXYstr, 10, 10)
23 | end
24 | function handle(win, e)
25 | if e == 'move' then
26 | win:redraw()
27 | end
28 | return win:super_handle(e)
29 | end
30 | mywin = MyWindow(640, 480, "Window draw and handle demonstration.")
31 | mywin:done()
32 | mywin:show()
33 | while mywin:shown() do
34 | Fl.wait()
35 | end
36 |
--------------------------------------------------------------------------------
/luaExamples/GUI/yesno.lua:
--------------------------------------------------------------------------------
1 | local ret=fl.ask("Press yes or no")
2 | if ret then
3 | fltk.message("Yes")
4 | else
5 | fltk.message("No")
6 | end
7 |
--------------------------------------------------------------------------------
/luaExamples/README:
--------------------------------------------------------------------------------
1 | These examples are not met to endorse a particular coding style nor do I make
2 | any claims that these are the most optimal way to do a particular task.
3 |
4 | If you see a better way to do something please do report it in some way or
5 | another preferably with a patch.
6 |
--------------------------------------------------------------------------------
/luaExamples/Sonic/Genesis/Sonic_One/GHZ_Act_One.lua:
--------------------------------------------------------------------------------
1 | -- This is setup for the Github version.
2 | dofile "LoadLevel.lua"
3 | local dir = fl.dir_chooser()
4 | if not (dir == nil or dir == '') then
5 | loadPalette(dir, 'Green Hill Zone.bin')
6 | loadTilemap(dir, 'GHZ')
7 |
8 | loadTiles(dir, 'GHZ')
9 |
10 | loadTilesOffset(dir, 'GHZ Flower Large', math.floor(0x6B80 / 32), 'artunc')
11 | loadTilesOffset(dir, 'GHZ Flower Small', math.floor(0x6D80 / 32), 'artunc')
12 | loadTilesOffset(dir, 'GHZ Waterfall', math.floor(0x6F00 / 32), 'artunc')
13 |
14 |
15 | loadTilesOffset(dir, 'GHZ Flower Stalk', math.floor(0x6B00 / 32), 'artnem')
16 | loadTilesOffset(dir, 'GHZ Purple Rock', math.floor(0x7A00 / 32), 'artnem')
17 |
18 | loadChunks(dir, 'GHZ')
19 |
20 | loadS1layoutFname(dir .. '/levels/' .. 'ghzbg.bin')
21 | layerNameInput:value('Green Hill Zone background')
22 | setLayerName(nil)
23 |
24 | lvlappend(nil)
25 | lvlsetlayer(2)
26 | loadS1layoutFname(dir .. '/levels/' .. 'ghz1.bin')
27 | layerNameInput:value('Green Hill Zone Act 1 foreground')
28 | setLayerName(nil)
29 | end
30 |
--------------------------------------------------------------------------------
/luaExamples/changeProject.lua:
--------------------------------------------------------------------------------
1 | -- Changes the project based on ID.
2 | if #projects < 2 then
3 | fltk.alert('This example requires a minimum of two projects.')
4 | return
5 | else
6 | set=tonumber(fl.input(string.format("Current project ID is: %d\nEnter the project ID you want to switch to from [1,%d].",projects.currentIdx, #projects)))
7 | if set~=nil then
8 | if project.set(set)==true then
9 | fltk.alert(string.format("Project set to %d", projects.currentIdx))
10 | else
11 | fltk.alert(string.format("ID %d is out of bounds or is already set to %d", set, set))
12 | end
13 | end
14 | rgt.redraw()
15 | end
16 |
--------------------------------------------------------------------------------
/luaExamples/dither.lua:
--------------------------------------------------------------------------------
1 | local p = projects.current
2 | if p:have(project.mapMask+project.palMask) then
3 | local tilemap = p.tilemaps.current
4 | local tiles = p.tiles
5 | local img = tilemap:toImage(-1, true)
6 |
7 | rgt.ditherImage(img, tilemap.width * tiles.width, tilemap.hAll * tiles.height, 1)
8 | tilemap:imageToTiles(img, -1, true)
9 |
10 | rgt.redraw()
11 | else
12 | p:haveMessage(project.mapMask+project.palMask)
13 | end
14 |
--------------------------------------------------------------------------------
/luaExamples/palette/paletteColorCount.lua:
--------------------------------------------------------------------------------
1 | -- Shows how many colors are in the palette.
2 | local p = projects.current
3 | if p:have(project.palMask) then
4 | local pl = p.palette
5 | if pl.haveAlt == true then
6 | fltk.message(string.format("Main palette colors %u Alternative sprite palette colors %u total %u",pl.cnt,pl.cntAlt,pl.cntTotal))
7 | else
8 | fltk.message(string.format("Palette colors %u",#pl))
9 | end
10 | else
11 | project.haveMessage(project.palMask)
12 | end
13 |
--------------------------------------------------------------------------------
/luaExamples/projectHave.lua:
--------------------------------------------------------------------------------
1 | -- Displays what the project does or does not have.
2 | projects.current:haveMessage(project.allMask)
3 |
--------------------------------------------------------------------------------
/luaExamples/projects.lua:
--------------------------------------------------------------------------------
1 | -- Demonstrates the use of the projects table
2 | print(projects)
3 | print(projects[1])
4 | print(string.format('There are %d project(s)',#projects))
5 | print(string.format('Name of first project: %s',projects[1].name)) -- Lua starts its arrays with one.
6 |
--------------------------------------------------------------------------------
/luaExamples/stringStore/hello.lua:
--------------------------------------------------------------------------------
1 | -- Simple demonstration of the project string store.
2 | -- The project string store lets you store arbitrary strings in a project which will be saved and loaded as a part of the project.
3 |
4 | -- Create a blank project to avoid accidentally messing up the users project.
5 | project.append()
6 | project.set(#projects)
7 |
8 | local p = projects[#projects]
9 |
10 | -- The name is long in hopes to reduce the chance of accidentally overwriting someone's project.
11 | local projectFname = 'string-store-hello-project-file.rgp'
12 | local f = io.open(projectFname)
13 | if f == nil then
14 | -- The project doesn't exist. Add the test string to the project and save it.
15 | p.stringStore['hello'] = 'Hello world!'
16 | p:save(projectFname)
17 | fltk.message('The project has been saved as ' .. projectFname .. ' the next time you run this example the string will be loaded and displayed in a message dialog and the project will be erased.')
18 | else
19 | f:close()
20 | p:load(projectFname)
21 | os.remove(projectFname)
22 | fltk.message(p.stringStore.hello) -- Both types of indexing work.
23 | end
24 |
--------------------------------------------------------------------------------
/luaExamples/tilemap/allRGB.lua:
--------------------------------------------------------------------------------
1 | local p = projects.current
2 |
3 |
4 | if p:have(project.mapMask) then
5 | local tilemap = p.tilemaps.current
6 | tilemap:setBlocksEnabled(false)
7 |
8 | if p:have(projects.tileMask) then
9 | local tiles = p.tiles
10 |
11 | local imgSizePX = 4096 * 4096
12 | local tileSizePX = tiles.width * tiles.height
13 |
14 | -- Ensure that we can fit the image without padding.
15 | if 4096 % tiles.width ~= 0 then
16 | fltk.alert('tile width must be a multiple of 4096')
17 | return
18 | end
19 | if 4096 % tiles.height ~= 0 then
20 | fltk.alert('tile height must be a multiple of 4096')
21 | return
22 | end
23 | local tileWidth = math.floor(4096 / tiles.width)
24 | local tileHeight = math.floor(4096 / tiles.height)
25 | tilemap:resize(tileWidth, tileHeight)
26 |
27 | local nTiles = math.floor(imgSizePX / tileSizePX)
28 | tiles:setAmt(nTiles)
29 |
30 | -- Setup the tilemap.
31 | for j = 0, tileHeight - 1 do
32 | local row = tilemap[j + 1]
33 | for i = 1, tileWidth do
34 | row[i].tile = j * tileWidth + i
35 | end
36 | end
37 | else
38 | -- The tilemap is acting as a framebuffer.
39 | -- This feature is not yet implemented.
40 | tilemap:resize(4096, 4096)
41 | end
42 |
43 | -- Generate a 4096x4096 image.
44 | local img = {}
45 | local i
46 | local rgb = 0
47 | for i = 1, 4096 * 4096 * 3, 3 do
48 | img[i] = bit32.band(rgb, 255)
49 | img[i + 1] = bit32.band(bit32.rshift(rgb, 8), 255)
50 | img[i + 2] = bit32.band(bit32.rshift(rgb, 16), 255)
51 | rgb = rgb + 1
52 | end
53 | tilemap:imageToTiles(img, -1, false, true)
54 | else
55 | p:haveMessage(project.mapMask)
56 | end
57 |
58 |
--------------------------------------------------------------------------------
/luaExamples/tilemap/mandelbrotToTilemap.lua:
--------------------------------------------------------------------------------
1 | local function square(x)
2 | return x*x
3 | end
4 | local function manIt(c_r,c_i,maxit)
5 | --Based on my (Sega16's) Mandelbrot explorer https://github.com/ComputerNerd/Mandelbrot-Casio-Prizm-Explorer
6 | local ckr,cki;
7 | local p,ptot=0,8
8 | local z_r = c_r
9 | local z_i = c_i
10 | local zrsqr = (z_r * z_r)
11 | local zisqr = (z_i * z_i)
12 | local q=square(c_r-0.25)+square(c_i)
13 | if ((q*(q+(c_r-0.25)))) < (square(c_i)/4.) then
14 | return 0,0,0
15 | end
16 | repeat
17 | ckr = z_r
18 | cki = z_i
19 | ptot=ptot+ptot
20 | if ptot > maxit then
21 | ptot = maxit
22 | end
23 | while p 4. then
30 | local color = math.floor(p * 16777215 / maxit)
31 | return bit32.band(color, 255), bit32.band(bit32.rshift(color, 8), 255), bit32.band(bit32.rshift(color, 16), 255)
32 | end
33 | if (z_r == ckr) and (z_i == cki) then
34 | return 0,0,0
35 | end
36 | p=p+1
37 | end
38 | until ptot ~= maxit
39 | return 0,0,0
40 | end
41 |
42 | local p = projects.current
43 |
44 | if p:have(project.mapMask) then
45 | local maxit = tonumber(fl.input("Maximum iterations","16000"))
46 | if maxit ~= nil then
47 | local tilemap = p.tilemaps.current
48 | p.tiles:setAmt(tilemap.width * tilemap.height)
49 |
50 | for j = 0, tilemap.height - 1 do
51 | local row = tilemap[j + 1]
52 | for i = 1, tilemap.width do
53 | row[i].tile = j * tilemap.width + i
54 | end
55 | end
56 |
57 | local width = tilemap.width * p.tiles.width
58 | local height = tilemap.hAll * p.tiles.height
59 |
60 | -- [-2,1],[-1,1]
61 | local sx, sy = 3/width, 2/height
62 | local x, y
63 | y = -1
64 | local img = {}
65 | for i = 0,height - 1 do
66 | x = -2
67 | for j = 0, width * 3 - 1, 3 do
68 | local r,g,b = manIt(x, y, maxit)
69 | img[(i * width * 3) + j + 1] = r
70 | img[(i * width * 3) + j + 2] = g
71 | img[(i * width * 3) + j + 3] = b
72 | x = x + sx
73 | end
74 | y = y + sy
75 | end
76 | -- Paramaters: image, -1 for all rows, has alpha channel false for 3 bpp, true for 4 bpp, copy to true color tiles, convert
77 | tilemap:imageToTiles(img, -1, false, true)
78 | rgt.redraw()
79 | end
80 | else
81 | p:haveMessage(project.mapMask)
82 | end
83 |
--------------------------------------------------------------------------------
/luaExamples/tilemap/swapBlock.lua:
--------------------------------------------------------------------------------
1 | -- Swaps one block with another.
2 | -- Use case example: The first block is not blank there is a blank block somewhere in the middle.
3 |
4 | local p = projects.current
5 | if p:have(project.mapMask) then
6 | local firstBlock = fl.input('Counting from zero enter the first block.')
7 | if firstBlock == nil then
8 | return
9 | end
10 | local secondBlock = fl.input('Counting from zero enter the second block.')
11 | if secondBlock == nil then
12 | return
13 | end
14 |
15 | firstBlock = tonumber(firstBlock) + 1
16 | secondBlock = tonumber(secondBlock) + 1
17 |
18 | local tilemap = p.tilemaps.current
19 | local maxBlock = math.floor(tilemap.hAll / tilemap.height)
20 |
21 | if firstBlock < 0 or secondBlock < 0 then
22 | fltk.alert('Must be greater than or equal to zero.')
23 | return
24 | end
25 |
26 | if firstBlock >= maxBlock or secondBlock >= maxBlock then
27 | fltk.alert('Must be less than the number of blocks.')
28 | return
29 | end
30 |
31 | firstBlock = firstBlock * tilemap.width
32 | secondBlock = secondBlock * tilemap.width
33 | for y = 1, tilemap.height do
34 | for x = 1, tilemap.width do
35 | local tmp = tilemap[y + secondBlock][x].raw -- Use raw to ensure everything is copied.
36 | tilemap[y + secondBlock][x].raw = tilemap[y + firstBlock][x].raw
37 | tilemap[y + firstBlock][x].raw = tmp
38 | end
39 | end
40 | rgt.damage()
41 | else
42 | p:haveMessage(project.mapMask)
43 | end
44 |
--------------------------------------------------------------------------------
/luaExamples/tilemap/tilemapGradient.lua:
--------------------------------------------------------------------------------
1 | -- Sets all tiles to a gradient
2 | local p = projects.current
3 | if p:have(project.tilesMask+project.mapMask) then
4 | local tilemap = p.tilemaps.current
5 | local ret,r1,g1,b1=fl.color_chooser("First color")
6 | if ret~=0 then
7 | local ret,r2,g2,b2=fl.color_chooser("Second color")
8 | if ret~=0 then
9 | -- We need the same number of tiles as the tilemap height.
10 | p.tiles:setAmt(tilemap.height)
11 |
12 | -- Fill the tilemap.
13 | for j = 1, tilemap.height do
14 | for i = 1, tilemap.width do
15 | tilemap[j][i].tile = j -- CAUTION: in Lua arrays start with one.
16 | end
17 | end
18 |
19 | local rs,gs,bs
20 | if p:have(project.palMask) then
21 | local rt, gt, bt = r1, g1, b1
22 | local maxInRow = p.palette:maxInRow(0)
23 | rs = (r2 - r1) / maxInRow
24 | gs = (g2 - g1) / maxInRow
25 | bs = (b2 - b1) / maxInRow
26 | for i=1, maxInRow do
27 |
28 | local paletteEntry = p.palette[i]
29 | paletteEntry.r = math.floor(rt*255.) -- Must be an integer.
30 | paletteEntry.g = math.floor(gt*255.)
31 | paletteEntry.b = math.floor(bt*255.)
32 | paletteEntry:convertFromRGB() -- This must be called after setting .r, .g, .b
33 |
34 | rt = rt + rs
35 | gt = gt + gs
36 | bt = bt + bs
37 |
38 | end
39 | palette.fixSliders()
40 | end
41 |
42 | local tilemapHeightPixels = tilemap.hAll * p.tiles.height
43 | rs = (r2 - r1) / tilemapHeightPixels
44 | gs = (g2 - g1) / tilemapHeightPixels
45 | bs = (b2 - b1) / tilemapHeightPixels
46 |
47 | for t=1, #p.tiles do
48 | local tile = p.tiles[t]
49 | for i=1, p.tiles.height do
50 | local row = tile.rgba[i]
51 | for j=1, p.tiles.width do
52 | local pixel = row[j] -- We can access each value like an array or like a struct.
53 | pixel.r = math.floor(r1 * 255.)
54 | pixel.g = math.floor(g1 * 255.)
55 | pixel.b = math.floor(b1 * 255.)
56 | pixel.a = 255
57 | end
58 | r1 = r1 + rs
59 | g1 = g1 + gs
60 | b1 = b1 + bs
61 |
62 | end
63 | end
64 | end
65 | end
66 | else
67 | project.haveMessage(project.tilesMask+project.mapMask)
68 | end
69 |
--------------------------------------------------------------------------------
/luaExamples/tiles/appendTiles.lua:
--------------------------------------------------------------------------------
1 | local p = projects.current
2 | if p:have(project.tilesMask) then
3 | fltk.alert("Started with "..#p.tiles.." tile.")
4 | p.tiles:append(10) -- The parameter is optional and defaults to one
5 | fltk.alert("Now there are "..#p.tiles.." tiles.")
6 | else
7 | project.haveMessage(project.tilesMask)
8 | end
9 |
--------------------------------------------------------------------------------
/luaExamples/tiles/printFirstTile.lua:
--------------------------------------------------------------------------------
1 | local p = projects.current
2 | if p:have(project.tilesMask) then
3 | local pixels = p.tiles[1].pixels
4 | local zeroChar = string.byte('A')
5 | for y = 1, #pixels do
6 | local pixelRow = pixels[y]
7 | for x = 1, #pixelRow do
8 | io.write(string.char(zeroChar + pixelRow[x]))
9 | end
10 | io.write('\n')
11 | end
12 | else
13 | p:haveMessage(project.tilesMask)
14 | end
15 |
--------------------------------------------------------------------------------
/luaExamples/tiles/tilestoGrayScale.lua:
--------------------------------------------------------------------------------
1 | -- The project is for constants and static functions.
2 | -- The projects table is treated as an array.
3 | local p = projects.current
4 | if p:have(project.tilesMask) then
5 | --[[ Although as of the time of writing this comment Retro Graphics Toolkit uses only tiles that use a palette
6 | meaning that having tiles implies a palette this could change latter
7 | that is I add tiles that do not use a palette. This is why the check for having a palette is needed.--]]
8 | if p:have(project.palMask) then
9 | local index=1
10 | for gray=0,255,255/(p.palette:maxInRow(0)-1) do
11 | while p.palette[index].pType ~= 0 do
12 | index = index + 1;
13 | end
14 | local l = math.floor(gray)
15 | paletteEntry = p.palette[index]
16 | paletteEntry:setRGB(l, l, l)
17 | index = index + 1;
18 | end
19 | if p.palette.haveAlt == true then
20 | index=p.palette.cnt
21 | for gray=0,255,255/(p.palette:maxInRow(palette.rowCnt)-1) do
22 | while p.palette[index].pType ~= 0 do
23 | index = index + 1;
24 | end
25 | local l = math.floor(gray)
26 | paletteEntry = p.palette[index]
27 | paletteEntry:setRGB(l, l, l)
28 | index = index + 1;
29 | end
30 | end
31 | end
32 | for i=1, #p.tiles do
33 | local tile = p.tiles[i]
34 | for y=1, p.tiles.height do
35 | local row = tile.rgba[y]
36 | for x=1, p.tiles.width do
37 | local pixel = row[x]
38 | local gray = math.floor(0.2126 * pixel.r + 0.7152 * pixel.g + 0.0722 * pixel.b) -- BT.709
39 | pixel.r = gray
40 | pixel.g = gray
41 | pixel.b = gray
42 | end
43 | end
44 | end
45 | if p:have(project.mapMask) then
46 | -- Set all tiles to use row zero.
47 | local tilemap = p.tilemaps.current
48 | for j = 1, tilemap.hAll do
49 | for i = 1, tilemap.width do
50 | tilemap[j][i].row = 0
51 | end
52 | end
53 | tilemap:dither()
54 | end
55 | if p:have(project.spritesMask) then
56 | allMetaDither(nil)
57 | end
58 | if p:have(project.palMask) then
59 | palette.fixSliders() --calls redraw
60 | else
61 | rgt.redraw()
62 | end
63 | else
64 | p:haveMessage(project.tilesMask)
65 | end
66 |
--------------------------------------------------------------------------------
/luaExamples/tiles/truecolorTileBrigtness.lua:
--------------------------------------------------------------------------------
1 | -- Multiplies all pixels in all tiles by m
2 | local p = projects.current
3 | if p:have(project.tilesMask) then
4 | m=tonumber(fl.input("Enter a multiplier m>1 brightens m<1 darkens","1"))
5 | if m~=nil then
6 | for i=1, #p.tiles do
7 | local tile = p.tiles[i].rgba
8 | for y=1, p.tiles.height do
9 | local row = tile[y]
10 | for x=1, p.tiles.width do
11 | local pixel = row[x]
12 | pixel.r = math.floor(pixel.r * m)
13 | pixel.g = math.floor(pixel.g * m)
14 | pixel.b = math.floor(pixel.b * m)
15 | end
16 | end
17 | end
18 | rgt.redraw()
19 | end
20 | else
21 | p:haveMessage(project.tilesMask)
22 | end
23 |
--------------------------------------------------------------------------------
/luaExamples/tiles/truecolorTileLabMult.lua:
--------------------------------------------------------------------------------
1 | local p = projects.current
2 | if p:have(project.tilesMask) then
3 | local Lm = tonumber(fl.input("Enter L multiplier","1"))
4 | local am = tonumber(fl.input("Enter a multiplier","1"))
5 | local bm = tonumber(fl.input("Enter b multiplier","1"))
6 | if Lm~=nil and am~=nil and bm~=nil then
7 | for i=1, #p.tiles do
8 | local tile = p.tiles[i].rgba
9 | for y=1, p.tiles.height do
10 | local row = tile[y]
11 | for x=1, p.tiles.width do
12 | local pixel = row[x]
13 |
14 | local L, a, b = rgt.rgbToLab(pixel.r / 255., pixel.g / 255., pixel.b / 255.)
15 | r, g, bl = rgt.labToRgb(L * Lm, a * am, b * bm)
16 |
17 | pixel.r = math.floor(r * 255.)
18 | pixel.g = math.floor(g * 255.)
19 | pixel.b = math.floor(bl * 255.)
20 | end
21 | end
22 | end
23 | rgt.redraw()
24 | end
25 | else
26 | p:haveMessage(project.tilesMask)
27 | end
28 |
--------------------------------------------------------------------------------
/luaExamples/zlibVersion.lua:
--------------------------------------------------------------------------------
1 | -- Retro Graphics Toolkit is compiled with the Zlib Lua binding from https://github.com/brimworks/lua-zlib
2 | -- That is where you will find documentation for The Zlib binding.
3 | major, minor, patch = zlib.version()
4 | fltk.message(string.format('%d.%d.%d', major, minor, patch))
5 |
--------------------------------------------------------------------------------
/luaHelpers.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_HELPERS_HPP
18 | #define LUA_HELPERS_HPP
19 | #include
20 | #include
21 | #include "lua.hpp"
22 |
23 | #define arLen(ar) (sizeof(ar)/sizeof(ar[0]))
24 |
25 | struct keyPair {
26 | const char*key;
27 | unsigned pair;
28 | };
29 | struct keyPairi {
30 | const char*key;
31 | int pair;
32 | };
33 |
34 | void mkKeyunsigned(lua_State*L, const char*str, unsigned val);
35 | void mkKeyint(lua_State*L, const char*str, int val);
36 | void mkKeybool(lua_State*L, const char*str, bool val);
37 | size_t getSizeTUserData(lua_State*L);
38 | bool luaL_optboolean (lua_State *L, int narg, bool def);
39 | void fillucharFromTab(lua_State*L, unsigned index, unsigned len, unsigned sz, uint8_t*ptr);
40 | void outofBoundsAlert(const char*what, unsigned val);
41 | void noUserDataError();
42 | size_t luaStringToVector(lua_State*L, int index, std::vector&v, unsigned sizeReq, bool isExactSize, int inplaceIdx);
43 |
44 | #define checkAlreadyExists lua_getmetatable(L, 1); \
45 | lua_pushvalue(L, 2); \
46 | lua_rawget(L, -2); \
47 | if (!lua_isnil(L, -1)) { \
48 | return 1; \
49 | } else { \
50 | lua_pop(L, 2); \
51 | }
52 |
53 | #define getIdxPtrChk const size_t *idxPtr = (const size_t*)lua_touserdata(L, 1); \
54 | if(!idxPtr) { \
55 | noUserDataError(); \
56 | return 0; \
57 | }
58 |
59 | #define getProjectIDX getIdxPtrChk \
60 | const size_t projectIDX = *idxPtr;
61 |
62 | #define getProjectRef getProjectIDX \
63 | Project&prj = projects->at(projectIDX);
64 | #endif
65 |
--------------------------------------------------------------------------------
/luaLevel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #include "dub/dub.h"
18 | #include "luaHelpers.hpp"
19 | #include "project.h"
20 | #include "luaLevelLayers.hpp"
21 |
22 | static int lua_level_subType(lua_State*L) {
23 | getProjectIDX
24 | projects->at(projectIDX).lvl->subType(lua_tointeger(L, 2), lua_tointeger(L, 3), (enum source)lua_tointeger(L, 4), lua_tointeger(L, 5));
25 | return 0;
26 | }
27 |
28 | static int level__get_(lua_State *L) {
29 | checkAlreadyExists
30 |
31 | int type = lua_type(L, 2);
32 | getProjectIDX
33 |
34 | if (type == LUA_TSTRING) {
35 | const char* k = luaL_checkstring(L, 2);
36 |
37 | if (!strcmp("layers", k)) {
38 | luaopen_LevelLayers(L, projectIDX);
39 | return 1;
40 | }
41 | }
42 |
43 | return 0;
44 | }
45 |
46 | static int level___tostring(lua_State *L) {
47 | getProjectIDX
48 | lua_pushfstring(L, "level table: %p", projects->at(projectIDX).lvl);
49 | return 1;
50 | }
51 |
52 | static const struct luaL_Reg level_member_methods[] = {
53 | { "__index", level__get_ },
54 | { "__tostring", level___tostring },
55 | { "subType", lua_level_subType},
56 | { "deleted", dub::isDeleted },
57 | { NULL, NULL},
58 | };
59 |
60 | int luaopen_Level(lua_State *L, size_t projectIDX) {
61 | // Create the metatable which will contain all the member methods
62 | luaL_newmetatable(L, "level");
63 | //
64 |
65 | // register member methods
66 | dub::fregister(L, level_member_methods);
67 | dub::setup(L, "level");
68 | // setup meta-table
69 | size_t* idxUserData = (size_t*)lua_newuserdata(L, sizeof(size_t));
70 | luaL_getmetatable(L, "level");
71 | *idxUserData = projectIDX;
72 | lua_setmetatable(L, -2);
73 | return 1;
74 | }
75 |
--------------------------------------------------------------------------------
/luaLevel.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_LEVEL_HPP
18 | #define LUA_LEVEL_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_Level(lua_State *L, size_t projectIDX);
22 | #endif
23 |
24 |
25 |
--------------------------------------------------------------------------------
/luaLevelLayer.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_LEVELLAYER_HPP
18 | #define LUA_LEVELLAYER_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_LevelLayer(lua_State *L, size_t projectIDX, size_t layerIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaLevelLayerRow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_LEVELLAYER_ROW_HPP
18 | #define LUA_LEVELLAYER_ROW_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_LevelLayerRow(lua_State *L, size_t projectIDX, size_t levelLayerIDX, size_t rowIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaLevelLayers.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_LEVELLAYERS_HPP
18 | #define LUA_LEVELLAYERS_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_LevelLayers(lua_State *L, size_t projectIDX);
22 | #endif
23 |
--------------------------------------------------------------------------------
/luaLevelObjects.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_LEVELOBJECTS_HPP
18 | #define LUA_LEVELOBJECTS_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_LevelObjects(lua_State *L, size_t projectIDX, size_t layerIDX);
22 | #endif
23 |
--------------------------------------------------------------------------------
/luaPalette.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_PALETTE_HPP
18 | #define LUA_PALETTE_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Palette(lua_State *L, size_t projectIDX);
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/luaPaletteEntry.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_PALETTE_ENTRY_HPP
18 | #define LUA_PALETTE_ENTRY_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_PaletteEntry(lua_State *L, size_t projectIDX, size_t entryIDX);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaProject.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_PROJECT_HPP
18 | #define LUA_PROJECT_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_Project(lua_State *L, unsigned idx);
22 | #endif
23 |
--------------------------------------------------------------------------------
/luaProjects.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_PROJECTS_HPP
18 | #define LUA_PROJECTS_HPP
19 | #include "lua.hpp"
20 |
21 | void luaCreateProjectsTable(lua_State* L);
22 | #endif
23 |
--------------------------------------------------------------------------------
/luaSprites.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #ifndef LUA_SPRITES_HPP
18 | #define LUA_SPRITES_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_MetaSprites(lua_State *L, size_t projectIDX);
22 | #endif
23 |
--------------------------------------------------------------------------------
/luaStringStore.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | #ifndef LUA_STRINGSTORE_HPP
18 | #define LUA_STRINGSTORE_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_StringStore(lua_State *L, size_t projectIDX);
22 | #endif
23 |
24 |
25 |
--------------------------------------------------------------------------------
/luaTile.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILE_HPP
18 | #define LUA_TILE_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Tile(lua_State *L, size_t projectIDX, size_t tileIDX);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaTilePixels.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_TILE_PIXELS_HPP
18 | #define LUA_TILE_PIXELS_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TilePixels(lua_State *L, size_t projectIDX, size_t tileIDX);
23 | #endif
24 |
25 |
26 |
--------------------------------------------------------------------------------
/luaTilePixelsRow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | */
17 | #ifndef LUA_TILE_PIXELS_ROW_HPP
18 | #define LUA_TILE_PIXELS_ROW_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TilePixelsRow(lua_State *L, size_t projectIDX, size_t tileIDX, size_t yIDX);
23 | #endif
24 |
25 |
26 |
--------------------------------------------------------------------------------
/luaTileRGBA.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILE_RGBA_HPP
18 | #define LUA_TILE_RGBA_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TileRGBA(lua_State *L, size_t projectIDX, size_t tileIDX, size_t yIDX);
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/luaTileRGBApixel.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILE_RGBA_PIXEL_HPP
18 | #define LUA_TILE_RGBA_PIXEL_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TileRGBApixel(lua_State *L, size_t projectIDX, size_t tileIDX, size_t yIDX, size_t xIDX);
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/luaTileRGBArow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILE_RGBA_ROW_HPP
18 | #define LUA_TILE_RGBA_ROW_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TileRGBArow(lua_State *L, size_t projectIDX, size_t tileIDX);
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/luaTilemap.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILEMAP_HPP
18 | #define LUA_TILEMAP_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Tilemap(lua_State *L, size_t projectIDX, size_t tilemapIDX);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaTilemapBlock.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | #ifndef LUA_TILEMAP_BLOCK_HPP
18 | #define LUA_TILEMAP_BLOCK_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_TilemapBlock(lua_State *L, size_t projectIDX, size_t tilemapIDX, size_t blockIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaTilemapBlocks.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | #ifndef LUA_TILEMAP_BLOCKS_HPP
18 | #define LUA_TILEMAP_BLOCKS_HPP
19 | #include "lua.hpp"
20 |
21 | int luaopen_TilemapBlocks(lua_State *L, size_t projectIDX, size_t tilemapIDX);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaTilemapEntry.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILEMAP_ENTRY_HPP
18 | #define LUA_TILEMAP_ENTRY_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TilemapEntry(lua_State *L, size_t projectIDX, size_t tilemapIDX, size_t columnIDX, size_t entryIDX);
23 | #endif
24 |
25 |
26 |
--------------------------------------------------------------------------------
/luaTilemapRow.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILEMAP_COLUMN_HPP
18 | #define LUA_TILEMAP_COLUMN_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_TilemapRow(lua_State *L, size_t projectIDX, size_t tilemapIDX, size_t rowIDX);
23 | #endif
24 |
25 |
--------------------------------------------------------------------------------
/luaTilemaps.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILEMAPS_HPP
18 | #define LUA_TILEMAPS_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Tilemaps(lua_State *L, size_t projectIDX);
23 | #endif
24 |
--------------------------------------------------------------------------------
/luaTiles.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_TILES_HPP
18 | #define LUA_TILES_HPP
19 | #include "lua.hpp"
20 |
21 |
22 | int luaopen_Tiles(lua_State *L, unsigned idx);
23 | #endif
24 |
--------------------------------------------------------------------------------
/lua_zlib.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "lua.h"
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 | LUALIB_API int luaopen_zlib(lua_State * const L);
7 | #ifdef __cplusplus
8 | }
9 | #endif
10 |
--------------------------------------------------------------------------------
/luaconfig.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include "luaconfig.h"
18 | #include "runlua.h"
19 | lua_State*Lconf;
20 | void startLuaConf(const char*fname, bool isHeadless) {
21 | Lconf = createLuaState();
22 | lua_pushinteger(Lconf, (int)isHeadless);
23 | lua_setglobal(Lconf, "is_headless");
24 | runLua(Lconf, fname);
25 | }
26 |
--------------------------------------------------------------------------------
/luaconfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | #include "lauxlib.h"
20 | extern lua_State*Lconf;
21 | void startLuaConf(const char*fname, bool isHeadless);
22 |
--------------------------------------------------------------------------------
/luafltk.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #ifndef LUA_FLKT_HPP
18 | #define LUA_FLKT_HPP
19 | #include "lua.hpp"
20 |
21 | void createFLTKbindings(lua_State *L);
22 | #endif
23 |
24 |
--------------------------------------------------------------------------------
/luaposix_headers/posix.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | extern "C" {
3 | #endif
4 | int luaopen_posix_sys_time(lua_State *L);
5 | int luaopen_posix_sys_msg(lua_State *L);
6 | int luaopen_posix_sys_times(lua_State *L);
7 | int luaopen_posix_sys_resource(lua_State *L);
8 | int luaopen_posix_sys_utsname(lua_State *L);
9 | int luaopen_posix_sys_wait(lua_State *L);
10 | int luaopen_posix_sys_stat(lua_State *L);
11 | int luaopen_posix_sys_socket(lua_State *L);
12 | int luaopen_posix_sys_statvfs(lua_State *L);
13 | int luaopen_posix_grp(lua_State *L);
14 | int luaopen_posix_time(lua_State *L);
15 | int luaopen_posix_dirent(lua_State *L);
16 | int luaopen_posix_glob(lua_State *L);
17 | int luaopen_posix_syslog(lua_State *L);
18 | int luaopen_posix_stdlib(lua_State *L);
19 | int luaopen_posix_libgen(lua_State *L);
20 | int luaopen_posix_termio(lua_State *L);
21 | int luaopen_posix_ctype(lua_State *L);
22 | int luaopen_posix_fcntl(lua_State *L);
23 | int luaopen_posix_poll(lua_State *L);
24 | int luaopen_posix_unistd(lua_State *L);
25 | int luaopen_posix_signal(lua_State *L);
26 | int luaopen_posix_utime(lua_State *L);
27 | int luaopen_posix_pwd(lua_State *L);
28 | int luaopen_posix_errno(lua_State *L);
29 | int luaopen_posix_stdio(lua_State *L);
30 | int luaopen_posix_sched(lua_State *L);
31 | int luaopen_posix_fnmatch(lua_State *L);
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
--------------------------------------------------------------------------------
/macros.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #define likely(x) __builtin_expect((x),1)
19 | #define unlikely(x) __builtin_expect((x),0)
20 |
21 |
--------------------------------------------------------------------------------
/make.clang:
--------------------------------------------------------------------------------
1 | CPPFLAGS=
2 | CC=clang
3 | CXX=clang++
4 |
5 | include Makefile.common
6 |
7 | CFLAGS += -march=native -c -O3 -pipe -march=native -fomit-frame-pointer -flto
8 | CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++14
9 | LDFLAGS := -O3 -flto -march=native -fno-rtti -std=gnu++14 -L/usr/lib/fltk/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -s -Llua/src -llua -ldl
10 |
11 | EXECUTABLE := RetroGraphicsToolkit
12 |
13 | all: $(SOURCES) $(EXECUTABLE)
14 |
15 | $(EXECUTABLE): $(OBJECTS)
16 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
17 | .c.o:
18 | $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
19 | .cc.o:
20 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
21 | .cpp.o:
22 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
23 | clean:
24 | rm -f $(OBJECTS) $(EXECUTABLE)
25 |
--------------------------------------------------------------------------------
/make.debug:
--------------------------------------------------------------------------------
1 | CPPFLAGS=-MD -MP
2 | CC=gcc
3 | CXX=g++
4 |
5 | include Makefile.common
6 |
7 | CFLAGS += -Wall -Wextra -Wdouble-promotion -O0 -ggdb3 -Werror=implicit-function-declaration
8 | CXXFLAGS := $(CFLAGS) -fno-rtti -std=c++14
9 | LDFLAGS := -L/usr/lib/fltk/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -lluajit-5.1 -ldl
10 |
11 | EXECUTABLE := RetroGraphicsToolkit
12 | all: $(EXECUTABLE)
13 |
14 | $(EXECUTABLE): $(OBJECTS)
15 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
16 | .c.o:
17 | $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
18 | .cc.o:
19 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
20 | .cpp.o:
21 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
22 | clean:
23 | rm -f $(OBJECTS) $(OBJECTS:.o=.d) $(EXECUTABLE)
24 | -include $(OBJECTS:.o=.d)
25 |
--------------------------------------------------------------------------------
/make.debug.clang:
--------------------------------------------------------------------------------
1 | CPPFLAGS=-MD -MP
2 | CC=clang
3 | CXX=clang++
4 |
5 | include Makefile.common
6 |
7 | CFLAGS += -Wall -Wextra -O0 -ggdb3
8 | CXXFLAGS := $(CFLAGS) -std=gnu++14
9 | LDFLAGS := -L/usr/lib/fltk/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -Llua/src -llua -ldl
10 |
11 | EXECUTABLE=RetroGraphicsToolkit
12 | all: $(EXECUTABLE)
13 |
14 | $(EXECUTABLE): $(OBJECTS)
15 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
16 | .c.o:
17 | $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
18 | .cc.o:
19 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
20 | .cpp.o:
21 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
22 | clean:
23 | rm -f $(OBJECTS) $(OBJECTS:.o=.d) $(EXECUTABLE)
24 | -include $(OBJECTS:.o=.d)
25 |
--------------------------------------------------------------------------------
/make.win:
--------------------------------------------------------------------------------
1 | CPPFLAGS=-DPACKAGE='"luaposix"' -DVERSION='"RGT"' -DCOMPAT53_HAVE_STRERROR_R=0
2 | PREFIX=i586-w64-mingw32-
3 | CC=$(PREFIX)gcc
4 | CXX=$(PREFIX)g++
5 | STRIP=$(PREFIX)strip
6 |
7 | #to compile on windows you must compile FLTK
8 | #I compiled FLTK in a folder named fltk-1.3.5 which is in the Retro Graphics toolkit directory
9 | #if that is not the case for you edit the makefile changing paths
10 |
11 | CFLAGS=-Ifltk-1.3.5/ -IautogeneratedBindings/ -Iluaposix_headers -Iluaposix/ext/include -I. -Imdcomp/include -Iboost/ -Ifltk-1.3.5/zlib -I fltk-1.3.5/png -ILuaJIT-windows-build/src -Wall -Os -s -mwindows -fomit-frame-pointer -pipe -Wl,--gc-sections -m32 -Ilua-compat-53/c-api -Iiqa/include -flto -fuse-linker-plugin -flto-partition=none
12 | CXXFLAGS=$(CFLAGS) -std=gnu++14 -fno-rtti
13 | LDFLAGS=$(CFLAGS) -Wl,--as-needed -Lfltk-1.3.5/lib -s -static-libstdc++ -lm -lfltk_images -lfltk -lfltk_jpeg -lfltk_png -lfltk_z -mwindows -LLibunicows/lib/mingw32 -lunicows -lole32 -luuid -lcomctl32 -L. -llua51 -m32
14 |
15 | BINDINGS=$(wildcard autogeneratedBindings/*.cpp) luaposix/ext/posix/libgen.c luaposix/ext/posix/dirent.c $(wildcard moonfltk/src/*.cc) $(wildcard moonfltk/src/*.c) $(wildcard iqa/source/*.c) lua-zlib/lua_zlib.c
16 | include Makefile.objects
17 |
18 | EXECUTABLE=RetroGraphicsToolkit.exe
19 |
20 | all: $(EXECUTABLE)
21 |
22 | $(EXECUTABLE): $(OBJECTS)
23 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
24 | .c.o:
25 | $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
26 | .cc.o:
27 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
28 | .cpp.o:
29 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
30 | clean:
31 | rm -f $(OBJECTS) $(EXECUTABLE)
32 |
--------------------------------------------------------------------------------
/make.win.debug:
--------------------------------------------------------------------------------
1 | CPPFLAGS=-DPACKAGE='"luaposix"' -DVERSION='"RGT"' -DCOMPAT53_HAVE_STRERROR_R=0 -DWINVER=0x0400
2 | PREFIX=i686-w64-mingw32-
3 | CC=$(PREFIX)gcc
4 | CXX=$(PREFIX)g++
5 | STRIP=$(PREFIX)strip
6 |
7 | #to compile on windows you must compile FLTK
8 | #I compiled FLTK in a folder named fltk-1.3.5 which is in the Retro Graphics toolkit directory
9 | #if that is not the case for you edit the makefile changing paths
10 |
11 | CFLAGS=-Ifltk-1.3.5/ -IautogeneratedBindings/ -Iluaposix_headers -Iluaposix/ext/include -I. -Imdcomp/include -Iboost/ -Ifltk-1.3.5/zlib -I fltk-1.3.5/png -ILuaJIT-windows-build/src -Wall -Wextra -Og -mwindows -pipe -Wl,--gc-sections -m32 -Ilua-compat-53/c-api -Iiqa/include -ggdb3
12 | CXXFLAGS=$(CFLAGS) -std=gnu++14 -fno-rtti
13 | LDFLAGS=$(CFLAGS) -Wl,--as-needed -Lfltk-1.3.5/lib -static-libstdc++ -lm -lfltk_images -lfltk -lfltk_jpeg -lfltk_png -lfltk_z -mwindows -lole32 -luuid -lcomctl32 -L. -llua51 -m32
14 |
15 | BINDINGS=$(wildcard autogeneratedBindings/*.cpp) luaposix/ext/posix/libgen.c luaposix/ext/posix/dirent.c $(wildcard moonfltk/src/*.cc) $(wildcard moonfltk/src/*.c) $(wildcard iqa/source/*.c) lua-zlib/lua_zlib.c
16 | include Makefile.objects
17 |
18 | EXECUTABLE=RetroGraphicsToolkit.exe
19 |
20 | all: $(EXECUTABLE)
21 |
22 | $(EXECUTABLE): $(OBJECTS)
23 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
24 | .c.o:
25 | $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
26 | .cc.o:
27 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
28 | .cpp.o:
29 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
30 | clean:
31 | rm -f $(OBJECTS) $(EXECUTABLE)
32 |
--------------------------------------------------------------------------------
/make.win.nolto:
--------------------------------------------------------------------------------
1 | CPPFLAGS=-DPACKAGE='"luaposix"' -DVERSION='"RGT"' -DCOMPAT53_HAVE_STRERROR_R=0
2 | PREFIX=i686-w64-mingw32-
3 | CC=$(PREFIX)gcc
4 | CXX=$(PREFIX)g++
5 | STRIP=$(PREFIX)strip
6 |
7 | #to compile on windows you must compile FLTK
8 | #I compiled FLTK in a folder named fltk-1.3.5 which is in the Retro Graphics toolkit directory
9 | #if that is not the case for you edit the makefile changing paths
10 |
11 | CFLAGS=-Ifltk-1.3.5/ -IautogeneratedBindings/ -Iluaposix_headers -Iluaposix/ext/include -I. -Imdcomp/include -Iboost/ -Ifltk-1.3.5/zlib -I fltk-1.3.5/png -ILuaJIT-windows-build/src -Wall -Os -s -mwindows -fomit-frame-pointer -pipe -Wl,--gc-sections -m32 -Ilua-compat-53/c-api -Iiqa/include
12 | CXXFLAGS=$(CFLAGS) -std=gnu++14 -fno-rtti
13 | LDFLAGS=$(CFLAGS) -Wl,--as-needed -Lfltk-1.3.5/lib -s -static-libstdc++ -lm -lfltk_images -lfltk -lfltk_jpeg -lfltk_png -lfltk_z -mwindows -lole32 -luuid -lcomctl32 -L. -llua51 -m32
14 |
15 | BINDINGS=$(wildcard autogeneratedBindings/*.cpp) luaposix/ext/posix/libgen.c luaposix/ext/posix/dirent.c $(wildcard moonfltk/src/*.cc) $(wildcard moonfltk/src/*.c) $(wildcard iqa/source/*.c) lua-zlib/lua_zlib.c
16 | include Makefile.objects
17 |
18 | EXECUTABLE=RetroGraphicsToolkit.exe
19 |
20 | all: $(EXECUTABLE)
21 |
22 | $(EXECUTABLE): $(OBJECTS)
23 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
24 | .c.o:
25 | $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
26 | .cc.o:
27 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
28 | .cpp.o:
29 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
30 | clean:
31 | rm -f $(OBJECTS) $(EXECUTABLE)
32 |
--------------------------------------------------------------------------------
/makeBindings/Documentation.txt:
--------------------------------------------------------------------------------
1 | This details how the auto generated bindings were made.
2 |
3 | First setup dub with these instructions:
4 | git clone --depth 1 https://github.com/lubyk/dub
5 | cd dub
6 | luarocks --local make ./dub-2.2.5-1.rockspec
7 | eval $(luarocks path --bin)
8 | # In the Retro Graphics Toolkit directory
9 | cd makeBindings
10 | # If you try and build a binding for the entire FLTK library you will errors. Do this instead:
11 | mkdir -p FL
12 | cp ../fltk-1.3.4-2/FL/Fl_Shared_Image.H FL/
13 | lua mkFLTKbind.lua
14 | # Now post process the generated bindings.
15 | python3 postProcessFL.py
16 | After this add the *.cpp and *.h files to the autogeneratedBindings folder then modify the code using addlib.c and includes.h as a guide.
17 |
--------------------------------------------------------------------------------
/makeBindings/mkFLTKbind.lua:
--------------------------------------------------------------------------------
1 | local lub = require 'lub'
2 | local dub = require 'dub'
3 |
4 | local inspector = dub.Inspector {
5 | INPUT = {
6 | lub.path '|FL',
7 | },
8 | }
9 | local binder = dub.LuaBinder()
10 |
11 | binder:bind(inspector, {
12 | -- Mandatory library name. This is used as prefix for class types.
13 | lib_name = 'FLTK',
14 |
15 | output_directory = lub.path '|bind',
16 |
17 | -- Remove this part in included headers
18 | header_base = lub.path '|FL',
19 |
20 | -- Open the library with require 'xml.core' (not 'xml') because
21 | -- we want to add some more Lua methods inside 'xml.lua'.
22 | luaopen = 'FLTK',
23 | })
24 |
--------------------------------------------------------------------------------
/makefile.profile:
--------------------------------------------------------------------------------
1 | CPPFLAGS=
2 | CC=gcc
3 | CXX=g++
4 |
5 | include Makefile.common
6 |
7 | CFLAGS += -march=native -ggdb3 -pg -flto=8 -fuse-linker-plugin -O3 -pipe -march=native
8 | CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++14
9 | LDFLAGS := -flto=8 -O3 -march=native -fuse-linker-plugin -fno-rtti -std=gnu++14 -L/usr/lib/fltk/ -lfltk_images -lfltk -lpng -ljpeg -lXft -lXext -lXinerama -lX11 -lz -lluajit-5.1 -ldl
10 |
11 | EXECUTABLE := RetroGraphicsToolkit.profile
12 |
13 | all: $(EXECUTABLE)
14 |
15 | $(EXECUTABLE): $(OBJECTS)
16 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
17 | .c.o:
18 | $(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@
19 | .cc.o:
20 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
21 | .cpp.o:
22 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -o $@
23 | clean:
24 | rm -f $(OBJECTS) $(EXECUTABLE)
25 |
--------------------------------------------------------------------------------
/metasprites.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #include
18 |
19 | #include "metasprites.h"
20 |
21 | const char*defMDesc = "DefaultForAllMetasprites";
22 | metasprites::metasprites(Project*prj) {
23 | this->prj = prj;
24 | sps.emplace_back(sprites(prj));
25 | name.assign(defMDesc);
26 | }
27 | metasprites::metasprites(const metasprites&o, Project*prj) {
28 | this->prj = prj;
29 | sps = o.sps;
30 | }
31 | void metasprites::setPrjPtr(Project*prj) {
32 | this->prj = prj;
33 |
34 | for (unsigned i = 0; i < sps.size(); ++i)
35 | sps[i].setPrjPtr(prj);
36 | }
37 | void metasprites::save(FILE*fp) {
38 | if (strcmp(name.c_str(), defMDesc) != 0)
39 | fputs(name.c_str(), fp);
40 |
41 | fputc(0, fp);
42 | uint32_t amt = sps.size();
43 | fwrite(&amt, sizeof(uint32_t), 1, fp);
44 |
45 | for (uint32_t i = 0; i < amt; ++i)
46 | sps[i].save(fp);
47 | }
48 | void metasprites::load(FILE*fp, uint32_t version) {
49 | if (version >= 8) {
50 | char firstC = fgetc(fp);
51 |
52 | if (firstC) {
53 | name.clear();
54 |
55 | do {
56 | name.push_back(firstC);
57 | } while ((firstC = fgetc(fp)));
58 | } else
59 | name.assign(defMDesc);
60 |
61 | uint32_t amt;
62 | fread(&amt, sizeof(uint32_t), 1, fp);
63 | sps.clear();
64 | sps.resize(amt, sprites(prj));
65 |
66 | for (uint32_t i = 0; i < amt; ++i)
67 | sps[i].load(fp, version);
68 | } else {
69 | name.assign(defMDesc);
70 | sps.clear();
71 | sps.resize(1, sprites(prj));
72 | sps[0].load(fp, version);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/metasprites.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
16 | */
17 | #pragma once
18 | #include "project.h"
19 | #include "classSprites.h"
20 | struct metasprites {
21 | Project*prj;
22 | std::vectorsps;
23 | std::string name;
24 | metasprites(Project*prj);
25 | metasprites(const metasprites&o, Project*prj);
26 | void setPrjPtr(Project*prj);
27 | void load(FILE*fp, uint32_t version);
28 | void save(FILE*fp);
29 | };
30 |
--------------------------------------------------------------------------------
/nearestColor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | /*
3 | This file is part of Retro Graphics Toolkit
4 |
5 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or any later version.
8 |
9 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Retro Graphics Toolkit. If not, see .
16 | Copyright Sega16 (or whatever you wish to call me) (2012-2018)
17 | */
18 | #include
19 | unsigned find_near_color_from_row_rgb(unsigned row, int r, int g, int b, bool alt);
20 | unsigned find_near_color_from_row(unsigned row, int r, int g, int b, bool alt);
21 | unsigned chooseTwoColor(unsigned index0, unsigned index1, int rgoal, int ggoal, int bgoal);
22 | unsigned nearestOneChannel(int val, const uint8_t*pal, unsigned amt);
23 |
--------------------------------------------------------------------------------
/nespal.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | uint32_t nesPalToRgb(unsigned inputPal);
3 |
--------------------------------------------------------------------------------
/palette.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | extern const uint8_t palTabGameGear[];
19 | extern const uint8_t palTabMasterSystem[];
20 | extern const uint8_t*palTabPtr[];
21 | extern const uint8_t*palTab;
22 | extern const uint8_t palTabGenReal[];
23 | extern const uint8_t palTabGen255div7[];
24 | extern const uint8_t palTabGen36[];
25 | extern const uint8_t palTabGen32[];
26 | extern unsigned palTypeGen;
27 | void sortBy(unsigned type, bool perRow);
28 | void set_palette_type(void);
29 | void set_palette_type_force(unsigned type);
30 |
--------------------------------------------------------------------------------
/paletteValidation.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | --]]
17 |
18 | --[[
19 | This is used to validate if a raw palette value is valid. This is currently
20 | only used to restrict the use of value 13 on the NES.
21 | --]]
22 |
23 | function isRawPaletteValueValid(currentSystem, value)
24 | if currentSystem == project.NES then
25 | return value ~= 13
26 | else
27 | return true
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/project.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2019)
16 | --]]
17 | function switchProject()
18 | rgt.syncProject()
19 |
20 | local p = projects.current
21 |
22 | if is_headless == 0 then
23 | updateProjectGUI(p.gameSystem)
24 | if p.gameSystem == project.segaGenesis then
25 | palTabSel:value(palTabSelOptions[p:getPalType() + 1]) -- Ensure the right selection is made.
26 | end
27 | end
28 |
29 | if p:have(project.palMask) ~= false then
30 | if p.palette.fixedPalette == false then
31 | p.palette:toRgbAll()
32 | end
33 | end
34 |
35 | if is_headless == 0 then
36 | if p:have(project.levelMask) ~= false then
37 | layerSel:clear()
38 | local layers = p.level.layers
39 | for i=1, #layers do
40 | local layer = layers[i]
41 | layerSel:add(layer.name)
42 | end
43 | lvlsetlayer(1)
44 | local currentLayerName = layers[lvlCurLayer].name
45 | layerSel:value(currentLayerName)
46 | end
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/quant.h:
--------------------------------------------------------------------------------
1 | /* quantizer.h
2 |
3 | See quantizer.c for more information
4 | From http://www.gnu-darwin.org/www001/ports-1.5a-CURRENT/graphics/mtpaint/work/mtpaint-3.11/src/quantizer.c
5 | */
6 | #pragma once
7 |
8 | #include
9 |
10 | int dl1quant(unsigned char *inbuf, int width, int height,
11 | int quant_to, unsigned char userpal[3][256]);
12 |
13 | int dl3quant(unsigned char *inbuf, int width, int height, int quant_to, unsigned char userpal[3][256], bool showProgress, Fl_Progress *progress);
14 |
15 | int dl3floste(unsigned char *inbuf, unsigned char *outbuf, int width, int height,
16 | int quant_to, int dither, unsigned char userpal[3][256]);
17 |
--------------------------------------------------------------------------------
/runlua.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | #include
20 | #include "lua.hpp"
21 | #include
22 | void updateProjectTablesLua(lua_State*L);
23 | void runLuaFunc(lua_State*L, unsigned args, unsigned results);
24 | void runLua(lua_State*L, const char*str, bool isFile = true);
25 | lua_State*createLuaState(void);
26 | void runLuaCB(Fl_Widget*, void*);
27 | bool luaL_checkboolean(lua_State* L, int n);
28 | void registerProjectTables(lua_State*L);
29 | void setProjectConstants(lua_State*L);
30 | void tableToVector(lua_State*L, unsigned idx, std::vector&vu8);
31 | void runLuaCD(const char*fname);
32 |
--------------------------------------------------------------------------------
/savepng.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #include
18 | int savePNG(const char * fileName, uint32_t width, uint32_t height, void * ptr, uint8_t*pal = nullptr, unsigned pn = 0, bool hasAlpha = false);
19 |
--------------------------------------------------------------------------------
/spatial_color_quant.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | int scolorq_wrapper(uint8_t*in255, uint8_t*out, uint8_t user_pal[3][256], uint32_t width, uint32_t height, unsigned num_colors, double dithering_level = -1.0, uint8_t filter_size = 3);
3 |
--------------------------------------------------------------------------------
/system.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2016)
16 | --]]
17 |
18 | function updateProjectGUI(sys)
19 | if sys==project.segaGenesis then
20 | palTabSel:show()
21 | spriteSizeSel:hide()
22 | spriteSizeTextToValueTable = nil
23 | else
24 | palTabSel:hide()
25 | spriteSizeSel:show()
26 | spriteSizeSel:clear()
27 |
28 | local spriteSizeOptions = {'8x8 sprites'}
29 |
30 | if sys == project.NES then
31 | spriteSizeOptions[2] = '8x16 sprites'
32 | else
33 | spriteSizeOptions[2] = '16x16 sprites'
34 | end
35 |
36 | spriteSizeTextToValueTable = generateLutFromList(spriteSizeOptions)
37 | addItemsToChoice(spriteSizeSel, spriteSizeOptions)
38 |
39 | local p = projects.current
40 | local spriteSizeID = p:getSpriteSizeID()
41 |
42 | spriteSizeSel:value(spriteSizeOptions[spriteSizeID + 1])
43 | end
44 | end
45 |
46 | function switchSystemBefore(old,new)
47 | end
48 |
49 | function switchSystemAfter(old,new)
50 | if is_headless == 0 then
51 | updateProjectGUI(new)
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/tilemap.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | #pragma once
18 | #include
19 | struct settings { //TODO avoid hardcoding palette row amount
20 | bool sprite;//Are we generating the palette for a sprite
21 | unsigned off[MAX_ROWS_PALETTE];//Offsets for each row
22 | unsigned alg;//Which algorithm should be used
23 | bool ditherAfter;//After color quantization should the image be dithered
24 | bool entireRow;//If true dither entire tilemap at once or false dither each row separately
25 | unsigned colSpace;//Which colorspace should the image be quantized in
26 | unsigned perRow[MAX_ROWS_PALETTE];//How many colors will be generated per row
27 | bool useRow[MAX_ROWS_PALETTE];
28 | unsigned rowAuto;
29 | int rowAutoEx[2];
30 | };
31 | void sub_tile_map(uint32_t oldTile, uint32_t newTile, bool hflip = false, bool vflip = false);
32 | void generate_optimal_palette(Fl_Widget*, void * row);
33 | void generate_optimal_paletteapply(Fl_Widget*, void*s);
34 |
--------------------------------------------------------------------------------
/tiles_io.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2020)
16 | */
17 | void save_tiles(Fl_Widget*, void*);
18 | void load_truecolor_tiles(Fl_Widget*, void*);
19 | void save_tiles_truecolor(Fl_Widget*, void*);
20 |
--------------------------------------------------------------------------------
/windist.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Make a 7z archive for Windows users.
3 | i586-w64-mingw32-strip lua-5.1.5/src/*.exe RetroGraphicsToolkit.exe
4 | htmlmin help-src.html help.html
5 | rm -f RetroGraphicsToolkit.exe.7z
6 | mv serpent serpent-tmp
7 | mkdir serpent
8 | cp -r serpent-tmp/src serpent
9 | 7z a -t7z -m0=lzma -mx=9 -mlc=7 -mmc=1000000000 -mfb=273 -ms=on RetroGraphicsToolkit.exe.7z ./RetroGraphicsToolkit.exe ./lua51.dll ./bit32.dll ./string.dll ./table.dll ./utf8.dll ./lua-doc/ ./luajit-doc/ ./lua ./*.lua ./Contributing ./README.md luaExamples/ headlessExamples/ ./libgcc_s_dw2-1.dll ./Manual/ help.html ./luajit.exe ./serpent/ lua-5.1.5/src/lua51.dll lua-5.1.5/src/lua.exe lua-5.1.5/src/luac.exe
10 | rm -rf serpent
11 | mv serpent-tmp serpent
12 | # For testing in a virtual machine.
13 | #mkisofs -o RetroGraphicsToolkit.iso ./RetroGraphicsToolkit.exe.7z
14 |
--------------------------------------------------------------------------------
/wu.h:
--------------------------------------------------------------------------------
1 | // wu.h
2 | // See wu.c for details
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 | int wu_quant(unsigned char *inbuf, int width, int height, int quant_to, uint8_t pal[3][256]);
7 | #ifdef __cplusplus
8 | }
9 | #endif
10 |
--------------------------------------------------------------------------------
/zlibwrapper.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Retro Graphics Toolkit
3 |
4 | Retro Graphics Toolkit is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or any later version.
7 |
8 | Retro Graphics Toolkit is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with Retro Graphics Toolkit. If not, see .
15 | Copyright Sega16 (or whatever you wish to call me) (2012-2017)
16 | */
17 | bool decompressFromFile(void * ptr, int size, FILE * fi);
18 | bool compressToFile(void * ptr, int size, FILE * fo);
19 |
--------------------------------------------------------------------------------