mirror of
https://github.com/love2d/love-android.git
synced 2026-08-21 21:15:34 +02:00
added dependencies and build files (loosely inspired by Sebastian Dorda's love-native-android)
This commit is contained in:
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,10 @@
|
||||
******************* Thu Sep 13 15:28:01 CEST 2001 ********************
|
||||
|
||||
* new option -S to play on start console only.
|
||||
* new option -c to play animationon any fb console
|
||||
* split fbmngplay to several files.
|
||||
|
||||
******************* Wed Sep 12 14:51:44 CEST 2001 ********************
|
||||
|
||||
* new option -p for dynamic positioning of the mng animation in the
|
||||
upper right corner.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
SHELL = /bin/sh
|
||||
CC = gcc
|
||||
|
||||
SOURCES = fbmngplay.c
|
||||
PROGRAMS = fbmngplay fbmngplay.static
|
||||
OBJECTS = fbmngplay.o messages.o mng.o console.o
|
||||
|
||||
LDFLAGS = -L/usr/lib
|
||||
LIBSS = /usr/lib/libmng-mini.a /usr/lib/libz.a -lm
|
||||
LIBSD = -lmng -lz -lm
|
||||
|
||||
CFLAGS = -Os -Wall -Wmissing-prototypes -Wstrict-prototypes -D_REENTRANT
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
LINKS = $(CC) $(CFLAGS) $(LDFLAGS) -static -o $@
|
||||
LINKD = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
all: $(PROGRAMS)
|
||||
strip -s $(PROGRAMS)
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .o .s
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean:
|
||||
-rm -f *.o core
|
||||
clean: mostlyclean
|
||||
-rm -f fbmngplay fbmngplay.static
|
||||
|
||||
fbmngplay: $(OBJECTS)
|
||||
@rm -f fbmngplay
|
||||
$(LINKD) $(LDFLAGS) $(OBJECTS) $(LIBSD)
|
||||
fbmngplay.static: $(OBJECTS)
|
||||
@rm -f fbmngplay.static
|
||||
$(LINKS) $(LDFLAGS) $(OBJECTS) $(LIBSS)
|
||||
|
||||
.PHONY: mostlyclean clean fbmngplay fbmngplay.static all
|
||||
@@ -0,0 +1,30 @@
|
||||
* fbmngplay *
|
||||
|
||||
a simple fbcon based mng player
|
||||
|
||||
This is a simple example program, using the kernel framebuffer device
|
||||
to display mng animation decoded by the new libmng implementation.
|
||||
|
||||
This player is based on the SDL version included in the libmng package
|
||||
from Ralph Giles <giles@ashlu.bc.ca>. The code's fairly rough at this
|
||||
point, but there was no example player for *nix in the distribution.
|
||||
Patches welcome, of course.
|
||||
|
||||
On a unix-like system, the build instructions are simple:
|
||||
|
||||
(install and/or build the mng library from libmng.com)
|
||||
make
|
||||
make install
|
||||
|
||||
To use the player:
|
||||
|
||||
fbmngplay <filename>.mng <filename>.mng ...
|
||||
|
||||
To stop looping animations, press CTRL C or send a TERM or INT signal.
|
||||
|
||||
See the options with
|
||||
fbmngplay -h
|
||||
|
||||
---
|
||||
Stefan Reinauer, <stepan@suse.de>
|
||||
$Date: 2002/09/26 18:09:36 $
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
|
||||
This file is based on getfd.c from the kbd package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/vt.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "console.h"
|
||||
|
||||
int start_console = 0;
|
||||
|
||||
/*
|
||||
* getfd.c
|
||||
*
|
||||
* Get an fd for use with kbd/console ioctls.
|
||||
* We try several things because opening /dev/console will fail
|
||||
* if someone else used X (which does a chown on /dev/console).
|
||||
*/
|
||||
|
||||
static int
|
||||
is_a_console(const int fd) {
|
||||
char arg;
|
||||
|
||||
arg = 0;
|
||||
return (ioctl(fd, KDGKBTYPE, &arg) == 0
|
||||
&& ((arg == KB_101) || (arg == KB_84)));
|
||||
}
|
||||
|
||||
static int
|
||||
open_a_console(const char * const fnam) {
|
||||
int fd;
|
||||
|
||||
fd = open(fnam, O_RDONLY);
|
||||
if (fd < 0 && errno == EACCES)
|
||||
fd = open(fnam, O_WRONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
if (!is_a_console(fd)) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int getfd (const char * const nm) {
|
||||
int fd;
|
||||
|
||||
if (nm) {
|
||||
fd = open_a_console(nm);
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
} else {
|
||||
fd = open_a_console("/dev/tty");
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
|
||||
fd = open_a_console("/dev/tty0");
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
|
||||
fd = open_a_console("/dev/console");
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
|
||||
for (fd = 0; fd < 3; fd++)
|
||||
if (is_a_console(fd))
|
||||
return fd;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"Couldnt get a file descriptor referring to the console\n");
|
||||
exit(1); /* total failure */
|
||||
}
|
||||
|
||||
int fd;
|
||||
int current_console(void)
|
||||
{
|
||||
struct vt_stat vtstat;
|
||||
if (ioctl(fd, VT_GETSTATE, &vtstat)) {
|
||||
fprintf(stderr,"fbmngplay: VT_GETSTATE\n");
|
||||
exit(1);
|
||||
}
|
||||
return vtstat.v_active;
|
||||
|
||||
}
|
||||
|
||||
void init_consoles(void)
|
||||
{
|
||||
// get current tty
|
||||
fd = getfd(0);
|
||||
start_console=current_console();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#ifndef __CONSOLES_H
|
||||
#define __CONSOLES_H
|
||||
|
||||
extern int getfd(const char* const);
|
||||
extern void init_consoles(void);
|
||||
extern int current_console(void);
|
||||
extern int start_console;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fb.h>
|
||||
|
||||
#include "fbmngplay.h"
|
||||
#include "messages.h"
|
||||
#include "console.h"
|
||||
#include "mng.h"
|
||||
|
||||
volatile int run = 1;
|
||||
int verbose = 0;
|
||||
int buffered = 0;
|
||||
int dynpos = 0;
|
||||
int waitsignal = 0;
|
||||
int delta = 16;
|
||||
int sconly=0;
|
||||
|
||||
void sigint_handler(int signal);
|
||||
void sigterm_handler(int signal);
|
||||
void sigusr1_handler(int signal);
|
||||
|
||||
void sigint_handler(int signal)
|
||||
{
|
||||
run = 2;
|
||||
}
|
||||
|
||||
void sigterm_handler(int signal)
|
||||
{
|
||||
restore_area();
|
||||
run = 0;
|
||||
}
|
||||
|
||||
void sigusr1_handler(int signal)
|
||||
{
|
||||
run = 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fbdev,c,option_index;
|
||||
unsigned int alpha;
|
||||
struct fb_var_screeninfo var;
|
||||
|
||||
/* Check which console we're running on */
|
||||
init_consoles();
|
||||
|
||||
/* allocate our stream data structure */
|
||||
mng = (mngstuff *) calloc(1, sizeof(*mng));
|
||||
if (mng == NULL) {
|
||||
fprintf(stderr, "could not allocate stream structure.\n");
|
||||
exit(0);
|
||||
}
|
||||
alpha = 100;
|
||||
mng->alpha = 100;
|
||||
mng->fbx = 15;
|
||||
mng->fby = 15;
|
||||
mng->background = NULL;
|
||||
|
||||
while (1) {
|
||||
static struct option long_options[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
{"verbose", 0, 0, 'v'},
|
||||
{"alpha", 1, 0, 'a'},
|
||||
{"buffered", 0, 0, 'b'},
|
||||
{"signal", 0, 0, 's'},
|
||||
{"delta", 0, 0, 'd'},
|
||||
{"position", 0, 0, 'p'},
|
||||
{"version", 0, 0, 'V'},
|
||||
{"start-console",0,0,'S'},
|
||||
{"console",1,0,'c'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "a:x:y:bh?vsd:pVSc:",
|
||||
long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'a':
|
||||
alpha = atoi(optarg);
|
||||
if (alpha > 100)
|
||||
alpha = 100;
|
||||
mng->alpha = alpha;
|
||||
break;
|
||||
case 'x':
|
||||
mng->fbx = atoi(optarg);
|
||||
break;
|
||||
case 'y':
|
||||
mng->fby = atoi(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
delta = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 's':
|
||||
waitsignal = 1;
|
||||
break;
|
||||
case 'b':
|
||||
buffered = 1;
|
||||
break;
|
||||
case 'p':
|
||||
dynpos = 1;
|
||||
break;
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
case 'c':
|
||||
start_console=atoi(optarg);
|
||||
case 'S':
|
||||
sconly=1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc) {
|
||||
printf("Which files do you want to play?\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//init_consoles();
|
||||
|
||||
/* Initialize framebuffer */
|
||||
fbdev = open("/dev/fb0", O_RDWR);
|
||||
if (fbdev < 0) {
|
||||
fprintf(stderr, "error while opening framebuffer.\n");
|
||||
exit(fbdev);
|
||||
}
|
||||
|
||||
ioctl(fbdev, FBIOGET_VSCREENINFO, &var);
|
||||
mng->fbwidth = var.xres;
|
||||
mng->fbheight = var.yres;
|
||||
mng->fbbpp = var.bits_per_pixel;
|
||||
|
||||
mng->display =
|
||||
mmap(NULL, var.xres * var.yres * (var.bits_per_pixel >> 3),
|
||||
PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, 0);
|
||||
|
||||
/* arrange to call the shutdown routine before we exit */
|
||||
atexit(&cleanup);
|
||||
|
||||
while (optind < argc) {
|
||||
// leftover arguements are filenames.
|
||||
mng->filename = argv[optind++];
|
||||
|
||||
/* set up the mng decoder for our stream */
|
||||
mng->mng = mng_initialize(mng, mngalloc, mngfree, MNG_NULL);
|
||||
if (mng->mng == MNG_NULL) {
|
||||
fprintf(stderr, "could not initialize libmng.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* set the callbacks */
|
||||
mng_setcb_errorproc(mng->mng, mngerror);
|
||||
mng_setcb_openstream(mng->mng, mngopenstream);
|
||||
mng_setcb_closestream(mng->mng, mngclosestream);
|
||||
mng_setcb_readdata(mng->mng, mngreadstream);
|
||||
mng_setcb_gettickcount(mng->mng, mnggetticks);
|
||||
mng_setcb_settimer(mng->mng, mngsettimer);
|
||||
mng_setcb_processheader(mng->mng, mngprocessheader);
|
||||
mng_setcb_getcanvasline(mng->mng, mnggetcanvasline);
|
||||
mng_setcb_refresh(mng->mng, mngrefresh);
|
||||
/* FIXME: should check for errors here */
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
signal(SIGTERM, sigterm_handler);
|
||||
|
||||
mng_readdisplay(mng->mng);
|
||||
|
||||
/* loop though the frames */
|
||||
while (mng->delay && run) {
|
||||
mdelay(mng->delay);
|
||||
mng->delay = 0;
|
||||
mng_display_resume(mng->mng);
|
||||
if (run == 2) {
|
||||
if (mng->alpha == 0)
|
||||
run = 0;
|
||||
mng->alpha -= delta;
|
||||
if (mng->alpha < 0)
|
||||
mng->alpha = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (waitsignal && optind < argc) {
|
||||
signal(SIGUSR1, sigusr1_handler);
|
||||
run = 1;
|
||||
while (run) {
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
|
||||
memset(mng->copybuffer, 0,
|
||||
4 * mng->width * mng->height);
|
||||
run = 1;
|
||||
mng->alpha = alpha;
|
||||
if (optind == argc) { /* last file */
|
||||
restore_area();
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup and quit */
|
||||
return mngquit(mng->mng);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#ifndef __FBMNGPLAY_H
|
||||
#define __FBMNGPLAY_H
|
||||
|
||||
#include <libmng.h>
|
||||
|
||||
#define FBMNGPLAY_VERSION "0.3"
|
||||
|
||||
/* structure for keeping track of our mng stream inside the callbacks */
|
||||
typedef struct {
|
||||
FILE *file; /* pointer to the file we're decoding */
|
||||
char *filename; /* pointer to the file's path/name */
|
||||
mng_uint32 delay; /* ticks to wait before resuming decode */
|
||||
unsigned char *display; /* pointer to display */
|
||||
unsigned char *copybuffer;
|
||||
unsigned char *background;
|
||||
mng_handle mng; /* mng handle */
|
||||
int width, height;
|
||||
int fbwidth, fbheight, fbbpp;
|
||||
int fbx, fby;
|
||||
int alpha;
|
||||
} mngstuff;
|
||||
|
||||
extern volatile int run;
|
||||
extern int verbose;
|
||||
extern int buffered;
|
||||
extern int dynpos;
|
||||
extern int waitsignal;
|
||||
extern int delta;
|
||||
extern int sconly;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fbmngplay.h"
|
||||
#include "messages.h"
|
||||
|
||||
void usage(char *name)
|
||||
{
|
||||
fprintf(stderr, "\nusage: %s [ -x <val> ] [ -y <val> ] [ -a <val> ] [-b] [-v]"
|
||||
" [-s] [file.mng [file.mng [...]]]\n", name);
|
||||
fprintf(stderr, "\n -x: x coordinate\n");
|
||||
fprintf(stderr, " -y: y coordinate\n");
|
||||
fprintf(stderr, " -a, --alpha: default alpha channel 1..100\n");
|
||||
fprintf(stderr, " -v, --verbose: verbose mode\n");
|
||||
fprintf(stderr, " -b, --buffered: buffered mode\n");
|
||||
fprintf(stderr, " -s, --signal: wait for SIGUSR1 between animations\n");
|
||||
fprintf(stderr, " -p, --position: dynamically select position\n");
|
||||
fprintf(stderr, " -V, --version: show version and exit\n");
|
||||
fprintf(stderr, " -?, -h, --help: print this help.\n\n");
|
||||
fprintf(stderr, " -S --start-console: only output animation on console it was started on.\n");
|
||||
}
|
||||
|
||||
void version(void)
|
||||
{
|
||||
fprintf(stderr, "fbmngplay v%s, Copyright (C) 2001 Stefan Reinauer\n",FBMNGPLAY_VERSION);
|
||||
fprintf(stderr, "fbmngplay comes with ABSOLUTELY NO WARRANTY;\n");
|
||||
fprintf(stderr,"This is free software, and you are welcome to redistribute it\n");
|
||||
fprintf(stderr,"under certain conditions; Check the GPL for details.\n");
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#ifndef __MESSAGES_H
|
||||
#define __MESSAGES_H
|
||||
|
||||
extern void usage(char *name);
|
||||
extern void version(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,398 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <linux/vt.h>
|
||||
|
||||
#include "fbmngplay.h"
|
||||
#include "console.h"
|
||||
#include "mng.h"
|
||||
|
||||
mngstuff *mng;
|
||||
unsigned char *bufferstream;
|
||||
unsigned long bufferpos = 0, buffersize = 0;
|
||||
|
||||
inline void mdelay(unsigned long msec)
|
||||
{
|
||||
usleep(msec * 1000);
|
||||
}
|
||||
|
||||
/* callbacks for the mng decoder */
|
||||
|
||||
/* memory allocation; data must be zeroed */
|
||||
mng_ptr mngalloc(mng_uint32 size)
|
||||
{
|
||||
return (mng_ptr) calloc(1, size);
|
||||
}
|
||||
|
||||
/* memory deallocation */
|
||||
void mngfree(mng_ptr p, mng_uint32 size)
|
||||
{
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
|
||||
mng_bool mngopenstream(mng_handle mng)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
/* look up our stream struct */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
/* open the file */
|
||||
mymng->file = fopen(mymng->filename, "rb");
|
||||
if (mymng->file == NULL) {
|
||||
fprintf(stderr, "unable to open '%s'\n", mymng->filename);
|
||||
run = 0;
|
||||
return MNG_FALSE;
|
||||
}
|
||||
|
||||
if (buffered) {
|
||||
unsigned long len;
|
||||
fseek(mymng->file, 0, SEEK_END);
|
||||
len = ftell(mymng->file);
|
||||
rewind(mymng->file);
|
||||
bufferstream = malloc(len);
|
||||
if (!bufferstream) {
|
||||
/* Not enough memory for buffers
|
||||
* -> we go back to unbuffered mode
|
||||
*/
|
||||
printf("Reverted to non buffered mode.\n");
|
||||
buffered = 0;
|
||||
return MNG_TRUE;
|
||||
}
|
||||
buffersize = len;
|
||||
fread(bufferstream, 1, len, mymng->file);
|
||||
bufferpos = 0;
|
||||
fclose(mymng->file);
|
||||
mymng->file = NULL;
|
||||
}
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
mng_bool mngclosestream(mng_handle mng)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
/* look up our stream struct */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
/* close the file */
|
||||
if (mymng->file)
|
||||
fclose(mymng->file);
|
||||
mymng->file = NULL; /* for safety */
|
||||
|
||||
if (bufferstream) {
|
||||
free(bufferstream);
|
||||
bufferstream = 0;
|
||||
buffersize = 0;
|
||||
bufferpos = 0;
|
||||
}
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
/* feed data to the decoder */
|
||||
mng_bool mngreadstream(mng_handle mng, mng_ptr buffer,
|
||||
mng_uint32 size, mng_uint32 * bytesread)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
/* look up our stream struct */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
if (!buffered) {
|
||||
/* read the requested amount of data from the file */
|
||||
*bytesread = fread(buffer, 1, size, mymng->file);
|
||||
} else {
|
||||
*bytesread = (buffersize - bufferpos) <
|
||||
size ? (buffersize - bufferpos) : size;
|
||||
memcpy(buffer, bufferstream + bufferpos, *bytesread);
|
||||
bufferpos += (*bytesread);
|
||||
}
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
/* the header's been read. set up the display stuff */
|
||||
mng_bool mngprocessheader(mng_handle mng,
|
||||
mng_uint32 width, mng_uint32 height)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
unsigned char *copybuffer, *background;
|
||||
unsigned char *src;
|
||||
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
mymng->width = width;
|
||||
mymng->height = height;
|
||||
|
||||
if (dynpos) {
|
||||
mymng->fbx = (mymng->fbwidth)-width-15;
|
||||
switch (mymng->fbheight) {
|
||||
case 768:
|
||||
mymng->fby = 15;
|
||||
break;
|
||||
case 1024:
|
||||
mymng->fby = 30;
|
||||
break;
|
||||
default:
|
||||
mymng->fby = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
copybuffer = (unsigned char *) malloc(width * height * 4);
|
||||
if (copybuffer == NULL) {
|
||||
fprintf(stderr, "could not allocate copy buffer.\n");
|
||||
exit(0);
|
||||
}
|
||||
mymng->copybuffer = copybuffer;
|
||||
|
||||
if (!mymng->background) {
|
||||
background =
|
||||
(unsigned char *) malloc(width * height *
|
||||
(mymng->fbbpp >> 3));
|
||||
if (background == NULL) {
|
||||
fprintf(stderr,
|
||||
"could not allocate background buffer.\n");
|
||||
exit(0);
|
||||
}
|
||||
mymng->background = background;
|
||||
|
||||
src = mymng->display + (mymng->fbwidth * mymng->fby +
|
||||
mymng->fbx) * (mymng->fbbpp >> 3);
|
||||
|
||||
while (height--) {
|
||||
memcpy(background, src,
|
||||
width * (mymng->fbbpp >> 3));
|
||||
background += width * (mymng->fbbpp >> 3);
|
||||
src += mymng->fbwidth * (mymng->fbbpp >> 3);
|
||||
}
|
||||
}
|
||||
/* tell the mng decoder about our bit-depth choice */
|
||||
/* FIXME: this works on intel. is it correct in general? */
|
||||
mng_set_canvasstyle(mng, MNG_CANVAS_BGRA8);
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
/* return a row pointer for the decoder to fill */
|
||||
mng_ptr mnggetcanvasline(mng_handle mng, mng_uint32 line)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
mng_ptr row;
|
||||
|
||||
/* dereference our structure */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
/* we assume any necessary locking has happened
|
||||
outside, in the frame level code */
|
||||
row = mymng->copybuffer + mymng->width * 4 * line;
|
||||
|
||||
return (row);
|
||||
}
|
||||
|
||||
/* timer */
|
||||
mng_uint32 mnggetticks(mng_handle mng)
|
||||
{
|
||||
mng_uint32 ticks;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
gettimeofday(&tv, &tz);
|
||||
ticks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
||||
|
||||
return (ticks);
|
||||
}
|
||||
|
||||
static inline void copyline(unsigned char *dest, unsigned char *src,
|
||||
unsigned char *background, mngstuff * mymng)
|
||||
{
|
||||
// BGRA8
|
||||
unsigned int i = mymng->width;
|
||||
unsigned int fr, fg, fb, br, bg, bb, r, g, b, a;
|
||||
unsigned short output, input;
|
||||
|
||||
while (i--) {
|
||||
fb = *src++;
|
||||
fg = *src++;
|
||||
fr = *src++;
|
||||
|
||||
a = *src++;
|
||||
a = a * mymng->alpha / 100;
|
||||
switch (mymng->fbbpp) {
|
||||
case 16:
|
||||
input = *((unsigned short *) background)++;
|
||||
br = (input >> 8) & 0xf8;
|
||||
bg = (input >> 3) & 0xfc;
|
||||
bb = input << 3 & 0xff;
|
||||
break;
|
||||
case 24:
|
||||
bb = *background++;
|
||||
bg = *background++;
|
||||
br = *background++;
|
||||
break;
|
||||
case 32:
|
||||
bb = *background++;
|
||||
bg = *background++;
|
||||
br = *background++;
|
||||
background++;
|
||||
break;
|
||||
default:
|
||||
br = 0;
|
||||
bg = 0;
|
||||
bb = 0;
|
||||
printf("depth not supported.\n");
|
||||
run = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
r = ((fr * a) + (br * (0x100 - a))) >> 8;
|
||||
g = ((fg * a) + (bg * (0x100 - a))) >> 8;
|
||||
b = ((fb * a) + (bb * (0x100 - a))) >> 8;
|
||||
|
||||
switch (mymng->fbbpp) {
|
||||
case 16:
|
||||
// dumb 24->16 bit conversion.
|
||||
r >>= 3;
|
||||
g >>= 2;
|
||||
b >>= 3;
|
||||
|
||||
output = (r << 11) | (g << 5) | b;
|
||||
*((unsigned short *) dest)++ = output;
|
||||
break;
|
||||
case 24:
|
||||
*dest++ = b;
|
||||
*dest++ = g;
|
||||
*dest++ = r;
|
||||
break;
|
||||
case 32:
|
||||
*dest++ = b;
|
||||
*dest++ = g;
|
||||
*dest++ = r;
|
||||
dest++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mng_bool mngrefresh(mng_handle mng, mng_uint32 x, mng_uint32 y,
|
||||
mng_uint32 w, mng_uint32 h)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
unsigned char *dest, *src, *background;
|
||||
|
||||
if (sconly && current_console()!=start_console)
|
||||
return MNG_TRUE;
|
||||
|
||||
/* dereference our structure */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
dest = mymng->display + ((mymng->fby * mymng->fbwidth + mymng->fbx)
|
||||
* (mymng->fbbpp >> 3));
|
||||
src = mymng->copybuffer;
|
||||
background = mymng->background;
|
||||
/* refresh the screen with the new frame */
|
||||
while (h-- > 0) {
|
||||
copyline(dest, src, background, mymng);
|
||||
dest += mymng->fbwidth * (mymng->fbbpp >> 3);
|
||||
background += mymng->width * (mymng->fbbpp >> 3);
|
||||
src += 4 * mymng->width; // 4 bytes per pixel due to RGBA
|
||||
}
|
||||
|
||||
// remove traces
|
||||
memset(mymng->copybuffer, 0, 4 * mymng->width * mymng->height);
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
/* interframe delay callback */
|
||||
mng_bool mngsettimer(mng_handle mng, mng_uint32 msecs)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
/* look up our stream struct */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
/* set the timer for when the decoder wants to be woken */
|
||||
mymng->delay = msecs;
|
||||
|
||||
return MNG_TRUE;
|
||||
}
|
||||
|
||||
mng_bool mngerror(mng_handle mng, mng_int32 code, mng_int8 severity,
|
||||
mng_chunkid chunktype, mng_uint32 chunkseq,
|
||||
mng_int32 extra1, mng_int32 extra2, mng_pchar text)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
char chunk[5];
|
||||
|
||||
/* dereference our data so we can get the filename */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
/* pull out the chuck type as a string */
|
||||
// FIXME: does this assume unsigned char?
|
||||
chunk[0] = (char) ((chunktype >> 24) & 0xFF);
|
||||
chunk[1] = (char) ((chunktype >> 16) & 0xFF);
|
||||
chunk[2] = (char) ((chunktype >> 8) & 0xFF);
|
||||
chunk[3] = (char) ((chunktype) & 0xFF);
|
||||
chunk[4] = '\0';
|
||||
|
||||
/* output the error */
|
||||
fprintf(stderr, "error playing '%s' chunk %s (%d):\n",
|
||||
mymng->filename, chunk, chunkseq);
|
||||
fprintf(stderr, "%s\n", text);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mngquit(mng_handle mng)
|
||||
{
|
||||
mngstuff *mymng;
|
||||
|
||||
/* dereference our data so we can free it */
|
||||
mymng = (mngstuff *) mng_get_userdata(mng);
|
||||
|
||||
/* cleanup. this will call mymngclosestream */
|
||||
mng_cleanup(&mng);
|
||||
|
||||
/* free our data */
|
||||
free(mymng);
|
||||
/* quit */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void cleanup(void)
|
||||
{
|
||||
mngquit(mng->mng);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void restore_area(void)
|
||||
{
|
||||
int height, width;
|
||||
unsigned char *dest, *background;
|
||||
|
||||
if (sconly && current_console()!=start_console)
|
||||
return;
|
||||
|
||||
background = mng->background;
|
||||
height = mng->height;
|
||||
width = mng->width;
|
||||
dest = mng->display + (mng->fbwidth * mng->fby +
|
||||
mng->fbx) * (mng->fbbpp >> 3);
|
||||
while (height--) {
|
||||
memcpy(dest, background, width * (mng->fbbpp >> 3));
|
||||
background += width * (mng->fbbpp >> 3);
|
||||
dest += mng->fbwidth * (mng->fbbpp >> 3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
fbmngplay - fb console MNG player.
|
||||
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
|
||||
|
||||
This program is based on mngplay, part of libmng, written and (C) by
|
||||
Ralph Giles <giles :at: ashlu.bc.ca>
|
||||
|
||||
This program my be redistributed under the terms of the
|
||||
GNU General Public Licence, version 2, or at your preference,
|
||||
any later version.
|
||||
*/
|
||||
|
||||
#ifndef __HOOKS_H
|
||||
#define __HOOKS_H
|
||||
|
||||
#include "fbmngplay.h"
|
||||
|
||||
extern mngstuff *mng;
|
||||
|
||||
extern inline void mdelay(unsigned long msec);
|
||||
extern mng_ptr mngalloc(mng_uint32 size);
|
||||
extern void mngfree(mng_ptr p, mng_uint32 size);
|
||||
extern mng_bool mngopenstream(mng_handle mng);
|
||||
extern mng_bool mngclosestream(mng_handle mng);
|
||||
extern mng_bool mngreadstream( mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uint32 * bytesread);
|
||||
extern mng_bool mngprocessheader( mng_handle mng, mng_uint32 width, mng_uint32 height);
|
||||
extern mng_ptr mnggetcanvasline(mng_handle mng, mng_uint32 line);
|
||||
extern mng_uint32 mnggetticks(mng_handle mng);
|
||||
extern mng_bool mngrefresh(mng_handle mng, mng_uint32 x, mng_uint32 y, mng_uint32 w, mng_uint32 h);
|
||||
extern mng_bool mngsettimer(mng_handle mng, mng_uint32 msecs);
|
||||
extern mng_bool mngerror(mng_handle mng, mng_int32 code, mng_int8 severity,
|
||||
mng_chunkid chunktype, mng_uint32 chunkseq,
|
||||
mng_int32 extra1, mng_int32 extra2, mng_pchar text);
|
||||
extern int mngquit(mng_handle mng);
|
||||
extern void cleanup(void);
|
||||
extern void restore_area(void);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user