Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
4klang-linux
Commits
7d5e1b9b
Commit
7d5e1b9b
authored
Jul 28, 2019
by
PoroCYon
Browse files
[v2] option to use the asm or C++ (with patches) backend
parent
6497bd16
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitmodules
View file @
7d5e1b9b
...
...
@@ -4,3 +4,6 @@
[submodule "oidos/oidos"]
path = oidos/oidos
url = https://gitlab.com/PoroCYon/oidos.git
[submodule "v2/v2m-player"]
path = v2/v2m-player
url = https://github.com/jgilje/v2m-player
v2/Makefile
View file @
7d5e1b9b
# C++ version is more stable, but might be larger
USE_CXX_VERSION
?=
1
# you most likely want this
USE_RONAN
?=
1
NASM
?=
nasm
default
:
all
...
...
@@ -6,21 +11,65 @@ default: all
%/
:
mkdir
-p
"
$@
"
v2m-player/README.md
:
@
>
&2
echo
"
\`
v2m-player' submodule not initialized. Please run the following command:"
@
>
&2
echo
" git submodule update --init --recursive"
@
false
fr_public/README.md
:
@
>
&2
echo
"
\`
fr_public' submodule not initialized. Please run the following command:"
@
>
&2
echo
" git submodule update --init --recursive"
@
false
CFLAGS
:=
-m32
ASFLAGS
:=
-felf32
ifeq
($(USE_CXX_VERSION),0)
CFLAGS
+=
-I
libv2/
else
CFLAGS
+=
-I
v2m-player/src/
-DUSE_CXX_VERSION
endif
ifneq
($(USE_RONAN),0)
CFLAGS
+=
-DRONAN
ASFLAGS
+=
-DRONAN
endif
CFLAGS
+=
-g
-ffunction-sections
-fdata-sections
ASFLAGS
+=
-g
obj/lplayer.o
:
src/lplayer.cpp obj/
$(CXX)
-g
-m32
-o
"
$@
"
-c
"
$<
"
-I
libv2
obj/v2mplayer.o
:
libv2/v2mplayer.cpp obj/
$(CXX)
-g
-m32
-o
"
$@
"
-c
"
$<
"
-I
libv2
obj/synth.o
:
libv2/synth.asm obj/
$(NASM)
-g
-f
elf32
-o
"
$@
"
"
$<
"
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/v2mplayer.o
:
libv2/v2mplayer.cpp obj/ fr_public/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/synth.o
:
libv2/synth.asm obj/ fr_public/README.md
$(NASM)
$(ASFLAGS)
-o
"
$@
"
"
$<
"
obj/pv2mconv.o
:
v2m-player/src/v2mconv.cpp obj/ v2m-player/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/pv2mplayer.o
:
v2m-player/src/v2mplayer.cpp obj/ v2m-player/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/pronan.o
:
v2m-player/src/ronan.cpp obj/ v2m-player/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/psynth_core.o
:
v2m-player/src/synth_core.cpp obj/ v2m-player/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/psounddef.o
:
v2m-player/src/sounddef.cpp obj/ v2m-player/README.md
$(CXX)
$(CFLAGS)
-o
"
$@
"
-c
"
$<
"
obj/v2m-%.asm
:
mus/%.v2m obj/
printf
"global theTune
\n
theTune:
\n
incbin
\"
%s
\"\n
"
"
$<
"
>
"
$@
"
printf
"[section .data.theTune]
\n
"
>
"
$@
"
printf
"global theTune
\n
theTune:
\n\t
incbin
\"
%s
\"\n
"
"
$<
"
>>
"
$@
"
printf
"global theTune_size
\n
theTune_size:
\n\t
dd
\$
$
- theTune
\n
"
>>
"
$@
"
obj/v2m-%.o
:
obj/v2m-%.asm
$(NASM)
-g
-f
elf32
-o
"
$@
"
"
$<
"
ifeq
($(USE_CXX_VERSION),0)
bin/lplayer-%
:
obj/lplayer.o obj/synth.o obj/v2mplayer.o obj/v2m-%.o bin/
$(CXX)
-g
-m32
-o
"
$@
"
$(
filter-out
bin/,
$^
)
else
bin/lplayer-%
:
obj/lplayer.o obj/psynth_core.o obj/pv2mconv.o obj/pv2mplayer.o
\
obj/pronan.o obj/psounddef.o obj/v2m-%.o bin/
endif
$(CXX)
-Wl
,--gc-sections
$(CFLAGS)
-o
"
$@
"
$(
filter-out
bin/,
$^
)
all
:
$(patsubst mus/%.v2m
,
bin/lplayer-%
,
$(wildcard mus/*.v2m))
echo
$^
...
...
v2/src/lplayer.cpp
View file @
7d5e1b9b
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define AUTOCONVERT
#include "v2mplayer.h"
#include "synth.h"
/*#include "libv2.h"*/
#ifdef AUTOCONVERT
#include "v2mconv.h"
#endif
#ifdef USE_CXX_VERSION
#include "sounddef.h"
#endif
// automatically convert the module to the newest format version
extern
"C"
const
uint8_t
theTune
[];
extern
"C"
const
size_t
theTune_size
;
#define BUFFERLEN (8192)
/* arbitrary */
static
V2MPlayer
player
;
static
sF32
output_buffer
[
BUFFERLEN
*
8
];
static
float
output_buffer
[
BUFFERLEN
*
8
];
#ifdef AUTOCONVERT
static
uint8_t
*
check_and_convert
(
const
uint8_t
*
tune
,
size_t
len
)
{
if
(
tune
[
2
]
!=
0
||
tune
[
3
]
!=
0
)
{
fprintf
(
stderr
,
"Invalid input file
\n
"
);
return
NULL
;
}
int
v
=
CheckV2MVersion
(
tune
,
len
);
if
(
v
<
0
)
{
fprintf
(
stderr
,
"Invalid input file (version not recognised)
\n
"
);
return
NULL
;
}
uint8_t
*
theTune2
;
int
len2
;
ConvertV2M
(
tune
,
len
,
&
theTune2
,
&
len2
);
return
theTune2
;
}
#endif
int
main
()
{
#ifdef USE_CXX_VERSION
sdInit
();
#endif
#ifdef AUTOCONVERT
uint8_t
*
theTune2
=
check_and_convert
(
theTune
,
theTune_size
);
if
(
!
theTune2
)
return
1
;
#else
const
uint8_t
*
theTune2
=
theTune
;
#endif
player
.
Init
();
player
.
Open
(
theTune
);
player
.
Open
(
theTune
2
);
player
.
Play
();
...
...
@@ -29,8 +70,9 @@ int main() {
* works around it. ¯\_(ツ)_/¯
* If you have a better fix, please tell me.
*/
player
.
Render
(
output_buffer
,
64
,
sFALSE
);
write
(
STDOUT_FILENO
,
output_buffer
,
64
*
sizeof
(
sF32
)
*
2
/*stereo*/
);
const
size_t
samples
=
64
;
player
.
Render
(
output_buffer
,
samples
,
false
);
write
(
STDOUT_FILENO
,
output_buffer
,
samples
*
sizeof
(
float
)
*
2
/*stereo*/
);
}
player
.
Close
();
...
...
v2m-player
@
9be97c86
Subproject commit 9be97c86de948a4cde313fdc178013f665af6326
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment