Skip to content

Commit

Permalink
Many changes. New path handling separates data from writable stuff etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
sasq64 committed Jul 31, 2014
1 parent 60330c7 commit d11eed0
Show file tree
Hide file tree
Showing 30 changed files with 402 additions and 246 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ sc68.cfg
index.dat
*.sublime-*
.tags*
lua/*.lua
android/
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ CFLAGS += -g -O2 -Wall -I$(CPP_MODS) -Wno-switch
#CFLAGS += -O2
SRCDIR := src/
#LDFLAGS += -pg
USE_CCACHE := 1
USE_CLANG := 1
#USE_CCACHE := 1
#USE_CLANG := 1

RUN_ARGS := -d

Expand Down Expand Up @@ -41,6 +41,8 @@ include $(CPP_MODS)/musicplayer/plugins/UADEPlugin/module.mk

include $(CPP_MODS)/crypto/module.mk

#APP_DIR := /usr/share/chipmachine
#USER_DIR := chipmachine

TARGET := chipmachine
LOCAL_FILES += main.cpp ChipMachine.cpp ChipMachine_config.cpp ChipMachine_keys.cpp MusicDatabase.cpp PlaylistDatabase.cpp SearchIndex.cpp MusicPlayerList.cpp MusicPlayer.cpp TelnetInterface.cpp
Expand All @@ -52,15 +54,16 @@ include $(CPP_MODS)/build.mk
pkg:
rm -rf debian-pkg/*
mkdir -p debian-pkg/$(TARGET)/DEBIAN
mkdir -p debian-pkg/$(TARGET)/opt/chipmachine
mkdir -p debian-pkg/$(TARGET)/usr/share/chipmachine
mkdir -p debian-pkg/$(TARGET)/usr/bin
cp extra/dpkg.control debian-pkg/$(TARGET)/DEBIAN/control
cp MANUAL.md debian-pkg/$(TARGET)/opt/chipmachine
cp -a data debian-pkg/$(TARGET)/opt/chipmachine
rm -f debian-pkg/$(TARGET)/opt/chipmachine/data/*.dfield
cp -a lua debian-pkg/$(TARGET)/opt/chipmachine
rm -f debian-pkg/$(TARGET)/opt/chipmachine/lua/*~ debian-pkg/$(TARGET)/opt/chipmachine/lua/*.lua
cp chipmachine debian-pkg/$(TARGET)/opt/chipmachine
arm-linux-gnueabihf-strip debian-pkg/$(TARGET)/opt/chipmachine/chipmachine
cp extra/cm debian-pkg/$(TARGET)/usr/bin/chipmachine
(cd debian-pkg ; dpkg-deb --build $(TARGET))
cp MANUAL.md debian-pkg/$(TARGET)/usr/share/chipmachine
cp -a data debian-pkg/$(TARGET)/usr/share/chipmachine
rm -f debian-pkg/$(TARGET)/usr/share/chipmachine/data/*.dfield
cp -a lua debian-pkg/$(TARGET)/usr/share/chipmachine
rm -f debian-pkg/$(TARGET)/usr/share/chipmachine/lua/*~
cp chipmachine debian-pkg/$(TARGET)/usr/bin
$(PREFIX)strip debian-pkg/$(TARGET)/usr/bin/chipmachine
#cp extra/cm debian-pkg/$(TARGET)/usr/bin/chipmachine
chmod -R g-w debian-pkg
(cd debian-pkg ; fakeroot dpkg-deb --build $(TARGET))
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ All required packages (hopefully);
For UADE support;

# git clone --depth 1 https://github.com/heikkiorsila/bencode-tools
# cd bencode-tools ; ./configure ; make ; sudo make-install ; cd ..
# cd bencode-tools ; ./configure ; make ; sudo make install ; cd ..
# git clone --depth 1 git://zakalwe.fi/uade
# cd uade ; ./configure --prefix=/usr ; make -j8 ; sudo make-install ; cd ..
# cd uade ; ./configure --prefix=/usr ; make -j8 ; sudo make install ; cd ..

Chipmachine binary;

Expand Down
17 changes: 17 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@

* No STIL info when using online
* Network threads stops quitting

application dir
cache dir
user dir

* /usr/share/chipmachine as maindir
* ~/.chipmachine as writable dir for
_files/
generated/<shaders>
index.dat
*.db

lua



Read DB into source_list.txt file
Make spcsets and hvsc work online out of the box
Expand Down
Empty file modified data/rsnsets.dat
100755 → 100644
Empty file.
Empty file modified data/topaz.ttf
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion extra/cm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
cd /opt/chipmachine
./chipmachine
./chipmachine "$@"

8 changes: 4 additions & 4 deletions extra/dpkg.control
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Package: chipmachine
Version: 1.0-alpha1
Section: user/extras
Version: 1.0-beta
Section: contrib/sound
Priority: extra
Architecture: armhf
Depends:
Architecture: amd64
Depends: libglfw2
Installed-Size:
Maintainer: Jonas Minnberg <[email protected]>
Description: Scene/Retro Music Player
File renamed without changes.
Empty file removed lua/formats.lua.orig
Empty file.
95 changes: 95 additions & 0 deletions lua/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
------
-- Lua settings
------

HD = false
if Config.screen_width >= 800 then
HD = true
end

GSCALE = 1.0

if Config.screen_width >= 1280 then
GSCALE = 2.0
end
-- print('HD',Config.screen_width,Config.screen_height,HD)

X0 = 80
Y0 = 54
X1 = 636
Y1 = 520


if HD then
X0 = 10
Y0 = 10
X1 = Config.screen_width-10
Y1 = Config.screen_height-10
end

background = 0x808080
--Config.screen_height / 576

if true then
TEXT_COLOR = 0xffe0e080
DIGITS_COLOR = 0xff70b050
SEARCH_COLOR = 0xffaaaaff
else
TEXT_COLOR = 0xff000000
DIGITS_COLOR = 0xff202080
RESULT_COLOR = 0xff202040
SEARCH_COLOR = 0xffffaaaa
FORMAT_COLOR = 0xffffffaa
SPECTRUM_COLOR0 = 0xff000000
SPECTRUM_COLOR1 = 0xff404040
Settings.background = 0x888888
Settings.stars = 0
end

Settings.top_left = { X0, Y0 }
Settings.down_right = { X1, Y1 }


scale = 3.0 * GSCALE
Settings.main_title = { X0, Y0, scale, TEXT_COLOR }
Settings.main_composer = { X0, Y0+25*scale, scale*0.6, TEXT_COLOR }
Settings.main_format = { X0, Y0+42*scale, scale*0.25, TEXT_COLOR }


SY = Settings.main_format[2] + 32 * GSCALE
Settings.song_field = { X0, SY, GSCALE, DIGITS_COLOR }
Settings.time_field = { X0 + 130 * GSCALE, SY, GSCALE, DIGITS_COLOR }
Settings.length_field = { X0 + 220 * GSCALE, SY, GSCALE, DIGITS_COLOR }

Settings.xinfo_field = { X0 - 4, SY + 35 * GSCALE, GSCALE * 0.75, 0xffffffff }

if HD then
Settings.scroll = { Y1 - 200, 3.0, 4, "data/Bello.otf" }
Settings.spectrum = { X0, Y1, 32, 24.0, SPECTRUM_COLOR0, SPECTRUM_COLOR1 }
else
Settings.scroll = { Y1 - 100, 2.0, 4, "data/Bello.otf" }
Settings.spectrum = { X0-50, Y1+40, 26, 16.0, SPECTRUM_COLOR0, SPECTRUM_COLOR1 }
end

x = Config.screen_width - 300 * GSCALE
y = Settings.scroll[1] - 80 * GSCALE

scale = 1.2 * GSCALE
Settings.next_field = { x, y-14, 0.5, 0xff444477 }
Settings.next_title = { x, y, scale, TEXT_COLOR }
Settings.next_composer = { x, y+26*scale, scale*0.6, TEXT_COLOR }
Settings.next_format = { x, y+44*scale, scale*0.3, TEXT_COLOR }

scale = 80.0
Settings.prev_title = { -3200, Y0, scale, 0 }
Settings.prev_composer = { -3200, Y0+25*scale, scale*0.6, 0 }
Settings.prev_format = { -3200, Y0+45*scale, scale*0.3, 0 }

Settings.search_field = { X0, Y0, 1.0, SEARCH_COLOR, FORMAT_COLOR }

Settings.result_field = { X0, Y0+30, 0.8, RESULT_COLOR }
Settings.result_lines = (Y1-Y0)/23

Settings.font = "data/Neutra.otf"
------
-- print("Lua parsing done")
Empty file removed lua/init.lua.orig
Empty file.
8 changes: 5 additions & 3 deletions lua/screen.lua.orig → lua/screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

GSCALE = 1.0

if SCREEN_WIDTH >= 1280 then
if SCREEN_HEIGHT >= 800 then
GSCALE = 2.0
end
-- print('HD',SCREEN_WIDTH,SCREEN_HEIGHT,HD)
Expand Down Expand Up @@ -68,6 +68,9 @@ Settings.length_field = { X0 + 220 * GSCALE, SY, GSCALE, DIGITS_COLOR }

Settings.xinfo_field = { X0 - 4, SY + 35 * GSCALE, GSCALE * 0.75, 0xffffffff }

Settings.favicon = { X0 + 330 * GSCALE, SY - GSCALE*25, 8*8 * GSCALE, 8*6 * GSCALE }


if HD then
Settings.scroll = { Y1 - 200, 3.0, 4, "data/Bello.otf" }
Settings.spectrum = { X0, Y1, 32, 24.0, SPECTRUM_COLOR0, SPECTRUM_COLOR1 }
Expand All @@ -86,8 +89,7 @@ Settings.next_title = { x, y, scale, TEXT_COLOR }
Settings.next_composer = { x, y+26*scale, scale*0.6, TEXT_COLOR }
Settings.next_format = { x, y+44*scale, scale*0.3, TEXT_COLOR }

y = Settings.scroll[1] - 100 * GSCALE
Settings.favicon = { X0, y, 16*8 * GSCALE, 16*6 * GSCALE }
y = Settings.scroll[1] - 70 * GSCALE

scale = 80.0
Settings.exit_title = { -3200, Y0, scale, 0 }
Expand Down
41 changes: 34 additions & 7 deletions src/ChipMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,27 @@ const vector<uint32_t> heart = { 0,Z,Z,0,Z,Z,0,0,
0,Z,Z,Z,Z,Z,0,0,
0,0,Z,Z,Z,0,0,0,
0,0,0,Z,0,0,0,0 };

#undef Z
#define Z 0xff44cccc
const vector<uint32_t> net = { 0,0,Z,Z,Z,0,0,0,
0,0,Z,0,Z,0,0,0,
Z,Z,Z,0,Z,0,Z,Z,
0,0,0,0,Z,0,Z,0,
0,0,0,0,Z,Z,Z,0 };
#undef Z


ChipMachine::ChipMachine() : currentScreen(0), eq(SpectrumAnalyzer::eq_slots), starEffect(screen), scrollEffect(screen), songList(this, Rectangle(tv0.x, tv0.y + 28, screen.width() - tv0.x, tv1.y - tv0.y - 28), 20) {

PlaylistDatabase::getInstance();

auto path = current_exe_path() + ":" + File::getAppDir();
LOGD("####### Finding font");
File ff = File::findFile(path, "data/Bello.otf");
scrollEffect.set("font", ff.getName());


#ifdef ENABLE_TELNET
telnet = make_unique<TelnetInterface>(*this);
telnet->start();
Expand Down Expand Up @@ -73,6 +87,12 @@ ChipMachine::ChipMachine() : currentScreen(0), eq(SpectrumAnalyzer::eq_slots), s
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

bm = image::bitmap(8, 5, &net[0]);
netTexture = Texture(bm);
glBindTexture(GL_TEXTURE_2D, netTexture.id());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

// SEARCHSCREEN

iquery = MusicDatabase::getInstance().createQuery();
Expand Down Expand Up @@ -132,13 +152,16 @@ void ChipMachine::initLua() {
setVariable(name, index, val);
});

File f { "lua/db.lua" };
auto path = File::getUserDir() + ":" + current_exe_path() + ":" + File::getAppDir();
File f = File::findFile(path, "lua/db.lua");

/*{ "lua/db.lua" };
if(!f.exists()) {
f.copyFrom("lua/db.lua.orig");
f.close();
}
}*/

lua.loadFile("lua/db.lua");
lua.loadFile(f.getName());
lua.load(R"(
for a,b in pairs(DB) do
if type(b) == 'table' then
Expand All @@ -152,16 +175,17 @@ void ChipMachine::initLua() {
)");
MusicDatabase::getInstance().generateIndex();

File f2 { "lua/screen.lua" };
File f2 = File::findFile(path, "lua/screen.lua");
/*File f2 { "lua/screen.lua" };
if(!f2.exists()) {
f2.copyFrom("lua/screen.lua.orig");
f2.close();
}
}*/

lua.set_global("SCREEN_WIDTH", screen.width());
lua.set_global("SCREEN_HEIGHT", screen.height());

Resources::getInstance().load<string>("lua/screen.lua", [=](shared_ptr<string> contents) {
Resources::getInstance().load<string>(f2.getName() /*"lua/screen.lua" */, [=](shared_ptr<string> contents) {
lua.load(*contents, "lua/screen.lua");
lua.load(R"(
for a,b in pairs(Settings) do
Expand Down Expand Up @@ -271,7 +295,7 @@ void ChipMachine::update() {
}
}

auto tune = player.getTune();
int tune = player.getTune();
if(currentTune != tune) {
songField->add = 0.0;
make_tween().sine().to(songField->add, 1.0).seconds(0.5);
Expand Down Expand Up @@ -372,6 +396,9 @@ void ChipMachine::render(uint32_t delta) {
songList.render();
}

if(WebRPC::inProgress() > 0 || WebGetter::inProgress() > 0) {
screen.draw(netTexture, 2, 2, 8*3, 5*3, nullptr);
}

renderSet.render(delta);

Expand Down
Loading

0 comments on commit d11eed0

Please sign in to comment.