diff --git a/.liccor b/.liccor index 98d91f8b..f6c86a64 100644 --- a/.liccor +++ b/.liccor @@ -1,4 +1,4 @@ -Copyright 2016 gtalent2@gmail.com +Copyright 2016-2017 gtalent2@gmail.com This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/Makefile b/Makefile index c0daaf31..a7a02661 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,14 @@ install: clean: ${ENV_RUN} make -j -C build ARGS="clean" HOST_ENV=${HOST_ENV} purge: - ${ENV_RUN} rm -rf $(shell find build -mindepth 1 -maxdepth 1 -type d) + ${ENV_RUN} rm -rf $$(find build -mindepth 1 -maxdepth 1 -type d) test: ${ENV_RUN} make -j -C build ARGS="test" HOST_ENV=${HOST_ENV} run: make - ./build/current/src/wombat/wombat -debug + ./build/current/src/player/nostalgia -debug +gba-run: make + ${ENV_RUN} mgba-qt build/current/src/player/nostalgia.bin gdb: make gdb ./build/current/src/wombat/wombat @@ -28,7 +30,13 @@ devenv: docker pull ${DEVENV_IMAGE} docker run -d -v $(shell pwd):/usr/src/project \ -e LOCAL_USER_ID=$(shell id -u ${USER}) \ - --restart=always --name ${DEVENV} \ + -e DISPLAY=$(DISPLAY) \ + -e QT_AUTO_SCREEN_SCALE_FACTOR=1 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -v /run/dbus/:/run/dbus/ \ + -v /dev/shm:/dev/shm \ + --restart=always \ + --name ${DEVENV} \ -t ${DEVENV_IMAGE} bash devenv-destroy: docker rm -f ${DEVENV} diff --git a/scripts/newcpp b/scripts/newcpp index c9ef12ab..fabe54bd 100755 --- a/scripts/newcpp +++ b/scripts/newcpp @@ -7,9 +7,8 @@ if len(sys.argv) < 3: pkg = sys.argv[1] name = sys.argv[2] -ifdef = "WOMBAT_%s_%s_HPP" % (pkg.upper(), name.upper()) namespace = "namespace wombat {\nnamespace %s {\n\n}\n}" % pkg -hpp = "#ifndef %s\n#define %s\n\n%s\n\n#endif" % (ifdef, ifdef, namespace) +hpp = "#pragma once\n" cpp = "#include \"%s.hpp\"\n\n%s" % (name, namespace) open("src/%s/%s.hpp" % (pkg, name), "w").write(hpp) diff --git a/src/common/bounds.cpp b/src/common/bounds.cpp index 40f81bc4..9d5f8b25 100644 --- a/src/common/bounds.cpp +++ b/src/common/bounds.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/common/bounds.hpp b/src/common/bounds.hpp index b5aa4a99..f92119bc 100644 --- a/src/common/bounds.hpp +++ b/src/common/bounds.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/common/common.hpp b/src/common/common.hpp index ae6d6a24..64c796dd 100644 --- a/src/common/common.hpp +++ b/src/common/common.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,6 @@ #define NOSTALGIA_COMMON_COMMON_HPP #include "bounds.hpp" -#include "flyweight.hpp" #include "point.hpp" #endif diff --git a/src/common/point.cpp b/src/common/point.cpp index e6444ad4..6750562f 100644 --- a/src/common/point.cpp +++ b/src/common/point.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/common/point.hpp b/src/common/point.hpp index 34152979..63206382 100644 --- a/src/common/point.hpp +++ b/src/common/point.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 5556055d..be819546 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -5,6 +5,7 @@ if(WOMBAT_BUILD_TYPE STREQUAL "GBA") set( CPP gba/gfx.cpp + gba/dirt.s ) elseif(WOMBAT_BUILD_TYPE STREQUAL "Native") endif() @@ -16,6 +17,8 @@ add_library(NostalgiaCore install( FILES + core.hpp + gfx.hpp DESTINATION include/nostalgia/core ) diff --git a/src/core/core.cpp b/src/core/core.cpp index 426b5b76..0f987afb 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,7 +12,7 @@ namespace nostalgia { namespace core { ox::std::Error init() { - auto err = initGfx(); + auto err = initGfx(); return err; } diff --git a/src/core/core.hpp b/src/core/core.hpp index dff50a2f..782ee384 100644 --- a/src/core/core.hpp +++ b/src/core/core.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/core/gba/dirt.h b/src/core/gba/dirt.h new file mode 100644 index 00000000..910f543f --- /dev/null +++ b/src/core/gba/dirt.h @@ -0,0 +1,35 @@ +/* + * Copyright 2016-2017 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +//{{BLOCK(dirt) + +//====================================================================== +// +// dirt, 80x72@4, +// + palette 256 entries, not compressed +// + 90 tiles not compressed +// Total size: 512 + 2880 = 3392 +// +// Time-stamp: 2016-07-06, 22:51:35 +// Exported by Cearn's GBA Image Transmogrifier, v0.8.12 +// ( http://www.coranac.com/projects/#grit ) +// +//====================================================================== + +#ifndef GRIT_DIRT_H +#define GRIT_DIRT_H + +#define dirtTilesLen 2880 +extern const unsigned int dirtTiles[720]; + +#define dirtPalLen 512 +extern const unsigned short dirtPal[256]; + +#endif // GRIT_DIRT_H + +//}}BLOCK(dirt) diff --git a/src/core/gba/dirt.s b/src/core/gba/dirt.s new file mode 100644 index 00000000..8c10a4a9 --- /dev/null +++ b/src/core/gba/dirt.s @@ -0,0 +1,165 @@ + +@{{BLOCK(dirt) + +@======================================================================= +@ +@ dirt, 80x72@4, +@ + palette 256 entries, not compressed +@ + 90 tiles not compressed +@ Total size: 512 + 2880 = 3392 +@ +@ Time-stamp: 2016-07-06, 22:51:35 +@ Exported by Cearn's GBA Image Transmogrifier, v0.8.12 +@ ( http://www.coranac.com/projects/#grit ) +@ +@======================================================================= + + .section .rodata + .align 2 + .global dirtTiles @ 2880 unsigned chars + .hidden dirtTiles +dirtTiles: + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x23324444,0x31134444,0x31134444,0x23324444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x24444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444233 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x32444444,0x13444444,0x13444444,0x32444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444423,0x44444431,0x44444431,0x44444423,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x34444444,0x34444444,0x24444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444311,0x44444311,0x44444233,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x32444444,0x13444444,0x13444444,0x32444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444423,0x44444431,0x44444431,0x44444423,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x33244444,0x11344444,0x11344444,0x33244444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444442,0x44444443,0x44444443,0x44444442,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44233244,0x44311344 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x42332444,0x43113444,0x43113444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44311344,0x44233244,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x42332444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44442332,0x44443113,0x44443113,0x44442332,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x33244444,0x11344444,0x11344444,0x33244444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444442,0x44444443,0x44444443,0x44444442,0x44444444,0x44444444,0x44444444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x42332444,0x43113444,0x43113444,0x42332444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x23324444,0x31134444,0x31134444,0x23324444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x42332444,0x43113444,0x43113444,0x42332444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + + .word 0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x44444444,0x00000000,0x00000000 + .word 0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000444,0x00000000,0x00000000 + + .section .rodata + .align 2 + .global dirtPal @ 512 unsigned chars + .hidden dirtPal +dirtPal: + .hword 0x0000,0x5EF7,0x7BDE,0x739C,0x7FFF,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + .hword 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 + +@}}BLOCK(dirt) diff --git a/src/core/gba/gfx.cpp b/src/core/gba/gfx.cpp index dde0d58a..303decfb 100644 --- a/src/core/gba/gfx.cpp +++ b/src/core/gba/gfx.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,17 +8,46 @@ #include #include "registers.hpp" +#include "dirt.h" namespace nostalgia { namespace core { +using namespace ox::std; + +typedef struct { uint32_t data[8]; } Tile, Tile4; +// d-tile: double-sized tile (8bpp) +typedef struct { uint32_t data[16]; } Tile8; +// tile block: 32x16 tiles, 16x16 d-tiles +typedef struct { unsigned short data[256]; } Pallete; +typedef Tile CharBlock[512]; +typedef Tile8 CharBlock8[256]; + +#define TILE_ADDR ((CharBlock*) 0x06000000) +#define TILE8_ADDR ((CharBlock8*) 0x06000000) + +#define PALLETE_BG ((unsigned short*) 0x05000000) +#define PALLETE_SPRITE ((unsigned short*) 0x05000200) + +typedef uint16_t BgMapTile[1024]; +#define BG_MAP ((BgMapTile*) 0x06000000) + ox::std::Error initGfx() { /* Sprite Mode ----\ */ /* ---\| */ - /* Background 2 -\|| */ + /* Background 0 -\|| */ /* Objects -----\||| */ /* |||| */ - REG_DISPCNT = 0x1400; + REG_DISPCNT = 0x1100; + + TILE_ADDR[0][1] = *(Tile*) dirtTiles; + + for (auto i = 0; i < (dirtPalLen / 2); i++) { + PALLETE_BG[i] = dirtPal[i]; + } + + BG_MAP[28][52] = 1; + REG_BG0CNT = (28 << 8) | 1; return 0; } diff --git a/src/core/gba/registers.hpp b/src/core/gba/registers.hpp index 50810f89..bd089048 100644 --- a/src/core/gba/registers.hpp +++ b/src/core/gba/registers.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,4 +10,25 @@ #define REG_DISPCNT *((volatile unsigned int*) 0x04000000) +///////////////////////////////////////////////////////////////// +// background registers + +// control registers +#define REG_BG0CNT *((volatile unsigned int*) 0x04000008) +#define REG_BG1CNT *((volatile unsigned int*) 0x0400000a) +#define REG_BG2CNT *((volatile unsigned int*) 0x0400000c) +#define REG_BG3CNT *((volatile unsigned int*) 0x0400000e) + +// horizontal scrolling registers +#define REG_BG0HOFS *((volatile unsigned int*) 0x04000010) +#define REG_BG1HOFS *((volatile unsigned int*) 0x04000014) +#define REG_BG2HOFS *((volatile unsigned int*) 0x04000018) +#define REG_BG3HOFS *((volatile unsigned int*) 0x0400001a) + +// vertical scrolling registers +#define REG_BG0VOFS *((volatile unsigned int*) 0x04000012) +#define REG_BG1VOFS *((volatile unsigned int*) 0x04000016) +#define REG_BG2VOFS *((volatile unsigned int*) 0x0400001a) +#define REG_BG3VOFS *((volatile unsigned int*) 0x0400001c) + #endif diff --git a/src/core/gfx.hpp b/src/core/gfx.hpp index 5f733579..0165855f 100644 --- a/src/core/gfx.hpp +++ b/src/core/gfx.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/player/main.cpp b/src/player/main.cpp index 62f8e15f..e3de04af 100644 --- a/src/player/main.cpp +++ b/src/player/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 gtalent2@gmail.com + * Copyright 2016-2017 gtalent2@gmail.com * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,10 +12,5 @@ using namespace nostalgia; int main() { core::init(); - - ((unsigned short*)0x06000000)[120+80*240] = 0x001F; - ((unsigned short*)0x06000000)[136+80*240] = 0x03E0; - ((unsigned short*)0x06000000)[120+96*240] = 0x7C00; - return 0; }