Compare commits

...

18 Commits

77 changed files with 1256 additions and 1615 deletions

6
.gitignore vendored Executable file
View File

@ -0,0 +1,6 @@
*.bin
*.elf
*.mak
build-fx/*
build-fx/map
build-fx/src/main.o

0
1v13D.dlr Normal file → Executable file
View File

0
1v13D.dlw Normal file → Executable file
View File

BIN
1v13D.g1a Normal file → Executable file

Binary file not shown.

0
1v13D.g1w Normal file → Executable file
View File

0
AddinInfo.txt Normal file → Executable file
View File

0
Debug/Addin.mak Normal file → Executable file
View File

0
FXSH_Build.bat Normal file → Executable file
View File

BIN
INIT/CasioRAM.mem Normal file → Executable file

Binary file not shown.

0
INIT/CasioRAMCPU.mem Normal file → Executable file
View File

228
LICENSE Executable file
View File

@ -0,0 +1,228 @@
Creative Commons Attribution-NonCommercial 2.0 CREATIVE COMMONS CORPORATION
IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS
LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS
PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING
FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS
PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR
OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS
LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO
BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
a. "Collective Work" means a work, such as a periodical issue, anthology or
encyclopedia, in which the Work in its entirety in unmodified form, along
with a number of other contributions, constituting separate and independent
works in themselves, are assembled into a collective whole. A work that constitutes
a Collective Work will not be considered a Derivative Work (as defined below)
for the purposes of this License.
b. "Derivative Work" means a work based upon the Work or upon the Work and
other pre-existing works, such as a translation, musical arrangement, dramatization,
fictionalization, motion picture version, sound recording, art reproduction,
abridgment, condensation, or any other form in which the Work may be recast,
transformed, or adapted, except that a work that constitutes a Collective
Work will not be considered a Derivative Work for the purpose of this License.
For the avoidance of doubt, where the Work is a musical composition or sound
recording, the synchronization of the Work in timed-relation with a moving
image ("synching") will be considered a Derivative Work for the purpose of
this License.
c. "Licensor" means the individual or entity that offers the Work under the
terms of this License.
d. "Original Author" means the individual or entity who created the Work.
e. "Work" means the copyrightable work of authorship offered under the terms
of this License.
f. "You" means an individual or entity exercising rights under this License
who has not previously violated the terms of this License with respect to
the Work, or who has received express permission from the Licensor to exercise
rights under this License despite a previous violation.
2. Fair Use Rights. Nothing in this license is intended to reduce, limit,
or restrict any rights arising from fair use, first sale or other limitations
on the exclusive rights of the copyright owner under copyright law or other
applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor
hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for
the duration of the applicable copyright) license to exercise the rights in
the Work as stated below:
a. to reproduce the Work, to incorporate the Work into one or more Collective
Works, and to reproduce the Work as incorporated in the Collective Works;
b. to create and reproduce Derivative Works;
c. to distribute copies or phonorecords of, display publicly, perform publicly,
and perform publicly by means of a digital audio transmission the Work including
as incorporated in Collective Works;
d. to distribute copies or phonorecords of, display publicly, perform publicly,
and perform publicly by means of a digital audio transmission Derivative Works;
The above rights may be exercised in all media and formats whether now known
or hereafter devised. The above rights include the right to make such modifications
as are technically necessary to exercise the rights in other media and formats.
All rights not expressly granted by Licensor are hereby reserved, including
but not limited to the rights set forth in Sections 4(d) and 4(e).
4. Restrictions.The license granted in Section 3 above is expressly made subject
to and limited by the following restrictions:
a. You may distribute, publicly display, publicly perform, or publicly digitally
perform the Work only under the terms of this License, and You must include
a copy of, or the Uniform Resource Identifier for, this License with every
copy or phonorecord of the Work You distribute, publicly display, publicly
perform, or publicly digitally perform. You may not offer or impose any terms
on the Work that alter or restrict the terms of this License or the recipients'
exercise of the rights granted hereunder. You may not sublicense the Work.
You must keep intact all notices that refer to this License and to the disclaimer
of warranties. You may not distribute, publicly display, publicly perform,
or publicly digitally perform the Work with any technological measures that
control access or use of the Work in a manner inconsistent with the terms
of this License Agreement. The above applies to the Work as incorporated in
a Collective Work, but this does not require the Collective Work apart from
the Work itself to be made subject to the terms of this License. If You create
a Collective Work, upon notice from any Licensor You must, to the extent practicable,
remove from the Collective Work any reference to such Licensor or the Original
Author, as requested. If You create a Derivative Work, upon notice from any
Licensor You must, to the extent practicable, remove from the Derivative Work
any reference to such Licensor or the Original Author, as requested.
b. You may not exercise any of the rights granted to You in Section 3 above
in any manner that is primarily intended for or directed toward commercial
advantage or private monetary compensation. The exchange of the Work for other
copyrighted works by means of digital file-sharing or otherwise shall not
be considered to be intended for or directed toward commercial advantage or
private monetary compensation, provided there is no payment of any monetary
compensation in connection with the exchange of copyrighted works.
c. If you distribute, publicly display, publicly perform, or publicly digitally
perform the Work or any Derivative Works or Collective Works, You must keep
intact all copyright notices for the Work and give the Original Author credit
reasonable to the medium or means You are utilizing by conveying the name
(or pseudonym if applicable) of the Original Author if supplied; the title
of the Work if supplied; to the extent reasonably practicable, the Uniform
Resource Identifier, if any, that Licensor specifies to be associated with
the Work, unless such URI does not refer to the copyright notice or licensing
information for the Work; and in the case of a Derivative Work, a credit identifying
the use of the Work in the Derivative Work (e.g., "French translation of the
Work by Original Author," or "Screenplay based on original Work by Original
Author"). Such credit may be implemented in any reasonable manner; provided,
however, that in the case of a Derivative Work or Collective Work, at a minimum
such credit will appear where any other comparable authorship credit appears
and in a manner at least as prominent as such other comparable authorship
credit.
d. For the avoidance of doubt, where the Work is a musical composition:
i. Performance Royalties Under Blanket Licenses. Licensor reserves the exclusive
right to collect, whether individually or via a performance rights society
(e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital
performance (e.g. webcast) of the Work if that performance is primarily intended
for or directed toward commercial advantage or private monetary compensation.
ii. Mechanical Rights and Statutory Royalties. Licensor reserves the exclusive
right to collect, whether individually or via a music rights agency or designated
agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from
the Work ("cover version") and distribute, subject to the compulsory license
created by 17 USC Section 115 of the US Copyright Act (or the equivalent in
other jurisdictions), if Your distribution of such cover version is primarily
intended for or directed toward commercial advantage or private monetary compensation.
Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where
the Work is a sound recording, Licensor reserves the exclusive right to collect,
whether individually or via a performance-rights society (e.g. SoundExchange),
royalties for the public digital performance (e.g. webcast) of the Work, subject
to the compulsory license created by 17 USC Section 114 of the US Copyright
Act (or the equivalent in other jurisdictions), if Your public digital performance
is primarily intended for or directed toward commercial advantage or private
monetary compensation.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS
THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING
THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE
OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW,
IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS
LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY
OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate automatically
upon any breach by You of the terms of this License. Individuals or entities
who have received Derivative Works or Collective Works from You under this
License, however, will not have their licenses terminated provided such individuals
or entities remain in full compliance with those licenses. Sections 1, 2,
5, 6, 7, and 8 will survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work). Notwithstanding
the above, Licensor reserves the right to release the Work under different
license terms or to stop distributing the Work at any time; provided, however
that any such election will not serve to withdraw this License (or any other
license that has been, or is required to be, granted under the terms of this
License), and this License will continue in full force and effect unless terminated
as stated above.
8. Miscellaneous
a. Each time You distribute or publicly digitally perform the Work or a Collective
Work, the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You distribute or publicly digitally perform a Derivative Work,
Licensor offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under applicable
law, it shall not affect the validity or enforceability of the remainder of
the terms of this License, and without further action by the parties to this
agreement, such provision shall be reformed to the minimum extent necessary
to make such provision valid and enforceable.
d. No term or provision of this License shall be deemed waived and no breach
consented to unless such waiver or consent shall be in writing and signed
by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings, agreements
or representations with respect to the Work not specified here. Licensor shall
not be bound by any additional provisions that may appear in any communication
from You. This License may not be modified without the mutual written agreement
of the Licensor and You.
Creative Commons is not a party to this License, and makes no warranty whatsoever
in connection with the Work. Creative Commons will not be liable to You or
any party on any legal theory for any damages whatsoever, including without
limitation any general, special, incidental or consequential damages arising
in connection to this license. Notwithstanding the foregoing two (2) sentences,
if Creative Commons has expressly identified itself as the Licensor hereunder,
it shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the Work is
licensed under the CCPL, neither party will use the trademark "Creative Commons"
or any related trademark or logo of Creative Commons without the prior written
consent of Creative Commons. Any permitted use will be in compliance with
Creative Commons' then-current trademark usage guidelines, as may be published
on its website or otherwise made available upon request from time to time.
Creative Commons may be contacted at http://creativecommons.org/.

36
Makefile Normal file → Executable file
View File

@ -16,8 +16,8 @@ cf-fx := $(cf) -m3 -DFX9860G
cf-cg := $(cf) -m4-nofpu -DFXCG50
# Linker flags
lf-fx := $(LDFLAGS) -Tfx9860g.ld -lgint-fx -lgcc -Wl,-Map=build-fx/map
lf-cg := $(LDFLAGS) -Tfxcg50.ld -lgint-cg -lgcc -Wl,-Map=build-cg/map
lf-fx := -Tfx9860g.ld -lgint-fx $(LDFLAGS) -lgcc -Wl,-Map=build-fx/map
lf-cg := -Tfxcg50.ld -lgint-cg $(LDFLAGS) -lgcc -Wl,-Map=build-cg/map
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
cpflags := -R .bss -R .gint_bss
@ -38,10 +38,10 @@ target-fx := $(filename).g1a
target-cg := $(filename).g3a
# Source files
src := $(shell find src -name '*.c')
#assets-fx := $(shell find assets-fx/*/)
#assets-cg := $(shell find assets-cg/*/)
assets-fx := $(wildcard assets-fx/img/*) $(wildcard assets-fx/fonts/*)
src := $(wildcard src/*.[csS] src/*/*.[csS] src/*/*/*.[csS] \
src/*/*/*/*.[csS])
assets-fx := $(wildcard assets-fx/*/*)
assets-cg := $(wildcard assets-cg/*/*)
# Object files
obj-fx := $(src:%.c=build-fx/%.o) $(assets-fx:assets-fx/%=build-fx/assets/%.o)
@ -89,16 +89,28 @@ build-cg/%.o: %.c
@ mkdir -p $(dir $@)
sh4eb-elf-gcc -c $< -o $@ $(cf-cg) $(dflags)
# Assembler sources
build-fx/%.o: %.s
@ mkdir -p $(dir $@)
sh3eb-elf-gcc -c $< -o $@
build-fx/%.o: %.S
@ mkdir -p $(dir $@)
sh3eb-elf-gcc -c $< -o $@ $(sflags)
build-cg/%.o: %.s
@ mkdir -p $(dir $@)
sh4eb-elf-gcc -c $< -o $@
build-cg/%.o: %.S
@ mkdir -p $(dir $@)
sh4eb-elf-gcc -c $< -o $@ $(sflags)
# Images
build-fx/assets/img/%.o: assets-fx/img/%
@ mkdir -p $(dir $@)
fxconv -i $< -o $@ name:img_$(basename $*)
fxconv -i $< -o $@ --fx name:img_$(basename $*)
build-cg/assets/img/%.o: assets-cg/img/%
@ echo -ne "\e[31;1mWARNING: image conversion for fxcg50 is not "
@ echo -ne "supported yet\e[0m"
@ mkdir -p $(dir $@)
fxconv -i $< -o $@ name:img_$(basename $*)
fxconv -i $< -o $@ --cg name:img_$(basename $*)
# Fonts
build-fx/assets/fonts/%.o: assets-fx/fonts/%
@ -127,8 +139,8 @@ distclean: clean
install-fx: $(target-fx)
p7 send -f $<
install-cg: $(target-cg)
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 1; done
@ mount /dev/Prizm1
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 0.25; done
@ while ! mount /dev/Prizm1; do sleep 0.25; done
@ rm -f /mnt/prizm/$<
@ cp $< /mnt/prizm
@ umount /dev/Prizm1

0
README.md Normal file → Executable file
View File

0
assets-cg/icon-cg-sel.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

0
assets-cg/icon-cg-uns.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

0
assets-fx/fonts/FxEngine.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 812 B

0
assets-fx/icon-fx.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

0
assets-fx/img/fps.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

BIN
assets-fx/img/menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

0
build-fx/assets/fonts/FxEngine.png.o Normal file → Executable file
View File

0
build-fx/assets/img/fps.png.o Normal file → Executable file
View File

1415
build-fx/map Normal file → Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.

0
build-fx/src/FxEngine/FxEngine.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/FxEngine.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/coord.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/coord.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/face.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/face.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/functions.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/functions.o Normal file → Executable file
View File

View File

@ -0,0 +1,4 @@
build-fx/src/FxEngine/keyboard.o: src/FxEngine/keyboard.c \
src/FxEngine/keyboard.h
src/FxEngine/keyboard.h:

BIN
build-fx/src/FxEngine/keyboard.o Executable file

Binary file not shown.

View File

@ -0,0 +1,4 @@
build-fx/src/FxEngine/keyboard/keyboard.o: \
src/FxEngine/keyboard/keyboard.c src/FxEngine/keyboard/keyboard.h
src/FxEngine/keyboard/keyboard.h:

Binary file not shown.

0
build-fx/src/FxEngine/libprof.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/libprof.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/math/coord.d Normal file → Executable file
View File

View File

@ -0,0 +1 @@
build-fx/src/FxEngine/render/bitmap.o: src/FxEngine/render/bitmap.c

Binary file not shown.

View File

@ -0,0 +1,4 @@
build-fx/src/FxEngine/render/parameters.o: \
src/FxEngine/render/parameters.c src/FxEngine/render/parameters.h
src/FxEngine/render/parameters.h:

Binary file not shown.

View File

@ -0,0 +1,6 @@
build-fx/src/FxEngine/render/translate.o: src/FxEngine/render/translate.c \
src/FxEngine/render/translate.h src/FxEngine/render/parameters.h
src/FxEngine/render/translate.h:
src/FxEngine/render/parameters.h:

Binary file not shown.

View File

@ -0,0 +1,6 @@
build-fx/src/FxEngine/render/zbuffer.o: src/FxEngine/render/zbuffer.c \
src/FxEngine/render/zbuffer.h src/FxEngine/render/parameters.h
src/FxEngine/render/zbuffer.h:
src/FxEngine/render/parameters.h:

Binary file not shown.

0
build-fx/src/FxEngine/texture.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/texture.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/zbuffer.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/zbuffer.o Normal file → Executable file
View File

0
build-fx/src/FxEngine/zbuffer/zbuffer.d Normal file → Executable file
View File

0
build-fx/src/FxEngine/zbuffer/zbuffer.o Normal file → Executable file
View File

0
build-fx/src/controls.d Normal file → Executable file
View File

0
build-fx/src/controls.o Normal file → Executable file
View File

16
build-fx/src/main.d Normal file → Executable file
View File

@ -1,15 +1 @@
build-fx/src/main.o: src/main.c src/FxEngine/FxEngine.h \
src/FxEngine/coord.h src/FxEngine/zbuffer.h src/FxEngine/face.h \
src/FxEngine/FxEngine.h src/controls.h
src/FxEngine/FxEngine.h:
src/FxEngine/coord.h:
src/FxEngine/zbuffer.h:
src/FxEngine/face.h:
src/FxEngine/FxEngine.h:
src/controls.h:
build-fx/src/main.o: src/main.c

BIN
build-fx/src/main.o Normal file → Executable file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 743 B

After

Width:  |  Height:  |  Size: 743 B

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 913 B

0
pc/topic.txt → pc/v1/topic.txt Normal file → Executable file
View File

4
project.cfg Normal file → Executable file
View File

@ -16,7 +16,7 @@ ICON_CG_SEL = assets-cg/icon-cg-sel.png
# Additional compiler flags
CFLAGS = -std=c11 -Os
# Additional linker flags
LDFLAGS =
LDFLAGS = -lfxengine -llog-fx -lgint-fx -lprof
# FxEngine font
FONT.FxEngine.png = charset:print grid.size:3x5 grid.padding:1 proportional:true
# FONT.FxEngine.png = charset:print grid.size:3x5 grid.padding:1 proportional:true

View File

@ -1,124 +0,0 @@
#include "FxEngine.h"
FE_position FE_user = {0,0,0};
double FE_dh, FE_dv, FE_roulis;
static double px, py, pz; // instance flottante des coordonnées des joueurs
static uint32_t frame_interval = 0, frame_interval_min = 1000001, frame_interval_max = 1 ; // in milliseconds
static bool loaded_before = false;
static double dh_vel = 0.05;
static double dv_vel = 0.05;
static double roulis_vel = 0.05;
static void FE_move()
{
key_event_t event;
while (true)
{
event=pollevent();
if (event.type&KEYEV_DOWN)
{
if (event.key==KEY_LEFT)
FE_dh -= dh_vel;
if (event.key==KEY_RIGHT)
FE_dh += dh_vel;
if (event.key==KEY_UP)
FE_dv += dv_vel;
if (event.key==KEY_DOWN)
FE_dv -= dv_vel;
if (event.key==KEY_PLUS)
FE_roulis += roulis_vel;
FE_dh = FE_modulo_2pi(FE_dh);
FE_dv = FE_modulo_2pi(FE_dv);
FE_roulis = FE_modulo_2pi(FE_roulis);
if (event.key==KEY_8)
{
py += FE_cos(FE_dh);
px += FE_sin(FE_dh);
}
if (event.key==KEY_5)
{
py += FE_cos(FE_dh + pi);
px += FE_sin(FE_dh + pi);
}
if (event.key==KEY_4)
{
py += FE_cos(FE_dh - pi_sur2);
px += FE_sin(FE_dh - pi_sur2);
}
if (event.key==KEY_6)
{
py += FE_cos(FE_dh + pi_sur2);
px += FE_sin(FE_dh + pi_sur2);
}
}
if (event.type==KEYEV_NONE) // si tous les évènements ont été traités
break;
}
FE_user.x = px; // actualisation des coordonnées de position
FE_user.y = py;
FE_user.z = pz;
}
void FE_new_frame()
{
dupdate(); // fin du cycle précédent
// gestion du temps avec libprof
if (loaded_before)
{
prof_leave(0);
frame_interval = prof_time(0);
if (frame_interval<frame_interval_min)
frame_interval_min = frame_interval;
if (frame_interval>frame_interval_max)
frame_interval_max = frame_interval;
}
else
{
prof_init(1, 0);
loaded_before=true;
}
prof_clear(0);
prof_enter(0);
FE_zbuffer_clear();
//actualisation de la position, de la direction et des données liées
FE_move();
FE_set_matrice();
dclear(C_WHITE);
}
#define MICROSECOND 1000000
unsigned uint32_t FE_get_fps_current()
{
return MICROSECOND / frame_interval;
}
unsigned uint32_t FE_get_fps_min()
{
return MICROSECOND / frame_interval_max;
}
unsigned uint32_t FE_get_fps_max()
{
return MICROSECOND / frame_interval_min;
}
static char fps_history[15];
char* FE_get_fps_history()
{
sprintf(fps_history, "%d/%d/%d", FE_get_fps_min(), FE_get_fps_current(), FE_get_fps_max());
return fps_history;
}

View File

@ -1,62 +0,0 @@
#ifndef FENG_H
#define FENG_H
#include "coord.h"
#include "zbuffer.h"
#include <libprof.h>
#include <stdbool.h>
#include <gint/keyboard.h>
#include <gint/clock.h>
#include <gint/display.h>
/* Coordonnées de la caméra
on utilise des double pour la direction
et des int pour la position (bien qu'une copie flottante cachée existe)
*/
extern double FE_dh, FE_dv, FE_roulis;
extern FE_position FE_user;
/* FE_new_frame():
affiche l'image précedemment dessinée et lance un nouveau cycle de dessin
Dépend de :
"FxEngine.h"
FE_move()
"coord.h"
FE_set_matrice()
"zbuffer.h"
FE_zbuffer_clear()
<libprof.h>
prof_init()
prof_clear()
prof_enter()
prof_leave()
prof_time() */
void FE_new_frame(void); // calls move function
/* FE_get_fps_current():
obtient le nombre d'Images Par Seconde (IPS) calculé à partir du dernier cycle */
unsigned int FE_get_fps_current(void);
/* FE_get_fps_min():
obtient le nombre d'images par seconde le plus bas ayant existé depuis le démarrage du moteur 3d */
unsigned int FE_get_fps_min(void);
/* FE_get_fps_max():
obtient le nombre d'images par seconde le plus haut ayant existé depuis le démarrage du moteur 3d */
unsigned int FE_get_fps_max(void);
/* FE_get_fps_history():
renvoie, dans une version compactée, les nombres minimum, actuel et maximum d'images par seconde
Dépend de :
"FxEngine.h"
FE_get_fps_min()
FE_get_fps_max()
FE_get_fps_max()
<gint/std/stdio.h>
sprintf() */
char* FE_get_fps_history(void);
#endif

View File

@ -1,114 +0,0 @@
#include "coord.h"
const double FE_PI = 3.141592653589793238462643383279;
const double FE_2_PI = FE_PI * 2;
const double FE_PI_SUR_2 = FE_PI / 2;
static const int32_t precision=15; // précision (nombre obligatoirement impair) choisie de façon arbitraire
static double reducted_cos(const double a)
{
double u= 1.0;
const double a2 = a * a;
for(int32_t p = precision; p>=1; p -= 2)
u = 1 - a2 / (p * p + p) * u;
return u;
}
// return a with -pi<=a<pi
double FE_modulo_2pi(double a)
{
while (a<=-pi)
a += pi2;
while (a>pi)
a -= pi2;
return a;
}
static double cos_recursive(double angle)
{
if (angle<0)
return cos_recursive(-angle);
if (angle>=FE_PI_SUR_2)
return -reducted_cos(angle - pi);
return reducted_cos(angle); // OK
}
double FE_cos(double angle)
{
angle = FE_modulo_2pi(angle);
return cos_recursive(angle);
}
double FE_sin(double angle)
{
return FE_cos(angle - pi_sur2);
}
#define sgn(x) (x>=0?x:-x)
static double matrice[3][3]=
{
{0,0,0},
{0,0,0},
{0,0,0}
};
void FE_calc(FE_point* point)
{
static FE_position temp;
temp.x = point->real.x - FE_user.x;
temp.y = point->real.y - FE_user.y;
temp.z = point->real.z - FE_user.z;
point->rotated.x = (double)(matrice[0][0]*(double)temp.x + matrice[0][1]*(double)temp.y + matrice[0][2]*(double)temp.z);
point->rotated.z = (double)(matrice[1][0]*(double)temp.x + matrice[1][1]*(double)temp.y + matrice[1][2]*(double)temp.z);
point->rotated.y = (double)(matrice[2][0]*(double)temp.x + matrice[2][1]*(double)temp.y + matrice[2][2]*(double)temp.z);
//point->translated.x*=10;
//point->translated.y*=10;
point->rotated.x*=64;
point->rotated.y*=64;
point->translated.z=point->rotated.z;
if (point->translated.z>0)
{
point->translated.x=point->rotated.x/point->translated.z;
point->translated.y=point->rotated.y/point->translated.z;
}
else
{
point->translated.x=point->rotated.x*10000*sgn(point->translated.z);
point->translated.y=point->rotated.y*10000*sgn(point->translated.z);
}
(point->translated.x*1000)/point->translated.z;
(point->translated.y*1000)/point->translated.z;
point->translated.x+=63;
point->translated.y+=31;
}
// FIABLE
void FE_set_matrice(void)
{
const double A=FE_cos(FE_dv), B=FE_sin(FE_dv);
const double C=FE_cos(FE_roulis), D=FE_sin(FE_roulis);
const double E=FE_cos(FE_dh), F=FE_sin(FE_dh);
const double AD=A*D, BD=B*D;
matrice[0][0]=C*E;
matrice[0][1]=-C*F;
matrice[0][2]=D;
matrice[1][0]=BD*E+A*F;
matrice[1][1]=-BD*F+A*E;
matrice[1][2]=-B*C;
matrice[2][0]=-AD*E+B*F;
matrice[2][1]=AD*F+B*E;
matrice[2][2]=A*C;
}

View File

@ -1,61 +0,0 @@
#ifndef FE_COORD_H
#define FE_COORD_H
#include "FxEngine.h"
/* FE_position:
notion de point dans l'espace simple */
typedef struct FE_position FE_position;
struct FE_position
{int32_t x,y,z;};
/* FE_point:
notion de point dans l'espace destiné à etre utilisé dans l'affichage
Dépend de
"coord.h"
FE_position */
typedef struct FE_point FE_point;
struct FE_point
{FE_position real,translated,rotated};
/* FE_calc():
applique la matrice de rotation sur les coordonnées d'un point
Dépend de :
"coord.h"
FE_cos()
FE_sin()
FE_point */
void FE_calc(FE_point* point);
/* FE_set_matrice():
change la matrice de rotation pour le cycle à venir
Dépend de :
"coord.h"
FE_cos()
FE_sin() */
void FE_set_matrice(void);
/* constantes mathématiques */
extern const double FE_PI, FE_2_PI, FE_PI_SUR_2;
/* FE_modulo_2pi():
ramener la mesure d'un angle orienté à la valeur comprise entre 0 et 2 pi */
double FE_modulo_2pi(double a);
/* FE_cos():
implémentation du cosinus */
double FE_cos(double angle);
/* FE_sin():
implémentation du sinus
Dépend de :
"coord.h"
FE_cos() */
double FE_sin(const double angle);
#endif

View File

@ -1,135 +0,0 @@
#include "face.h"
#include "texture.h"
#include "zbuffer.h"
#include <stdbool.h>
#include <gint/display.h>
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define abs(x) (x>0?x:-x)
static bool sens_horaire(FE_face const * face)
{
int area = 0;
area+=face->s1->translated.x*face->s2->translated.y;
area-=face->s2->translated.x*face->s1->translated.y;
area+=face->s2->translated.x*face->s3->translated.y;
area-=face->s3->translated.x*face->s2->translated.y;
area+=face->s3->translated.x*face->s1->translated.y;
area-=face->s1->translated.x*face->s3->translated.y;
return (area < 0);
}
// gestion des lignes
typedef struct line line;
struct line
{
int x,y,z;
int dx,dy,dz;
bool no_line; // si les deux points sont confondus
};
static void set_line(line* segment,FE_point const * s1, FE_point const * s2)
{
segment->x=s1->translated.x;
segment->y=s1->translated.y;
segment->z=s1->translated.z;
segment->dx=s2->translated.x-s1->translated.x;
segment->dy=s2->translated.y-s1->translated.y;
segment->dz=s2->translated.z-s1->translated.z;
segment->no_line=(segment->dx==0&&segment->dy==0);
}
static bool get_x(int y, line const * segment, int * x)
{
y-=segment->y;
if (y<0 && segment->dy>0)
return false;
if (y>0 && segment->dy<0)
return false;
if (abs(y)>abs(segment->dy))
return false;
if (segment->dy!=0)
*x=segment->x+(y*segment->dx)/segment->dy;
else if (y==0)
*x=segment->x+segment->dx;
else
return false;
return true;
}
void FE_draw_face(FE_face const * face)
{
if (sens_horaire(face)!=face->visible)
return;
if (face->s1->translated.x<0 && face->s2->translated.x<0 && face->s3->translated.x<0)
return;
if (face->s1->translated.x>127 && face->s2->translated.x>127 && face->s3->translated.x>127)
return;
if (face->s1->translated.y<0 && face->s2->translated.y<0 && face->s3->translated.y<0)
return;
if (face->s1->translated.y>63 && face->s2->translated.y>63 && face->s3->translated.y>63)
return;
if (face->s1->translated.z<=0 && face->s2->translated.z<=0 && face->s3->translated.z<=0)
return;
line cotes[3];
set_line(&cotes[0],face->s1,face->s2);
set_line(&cotes[1],face->s1,face->s3);
set_line(&cotes[2],face->s2,face->s3);
if (cotes[0].no_line||cotes[1].no_line||cotes[2].no_line)
return;
const int ymin=max(min(face->s1->translated.y,min(face->s2->translated.y,face->s3->translated.y)),0);
const int ymax=min(max(face->s1->translated.y,max(face->s2->translated.y,face->s3->translated.y)),63);
const int xAB=face->s2->translated.x-face->s1->translated.x, yAB=face->s2->translated.y-face->s1->translated.y, zAB=face->s2->translated.z-face->s1->translated.z;
const int xAC=face->s3->translated.x-face->s1->translated.x, yAC=face->s3->translated.y-face->s1->translated.y, zAC=face->s3->translated.z-face->s1->translated.z;
const int diviseur_commun=(xAB*yAC-yAB*xAC); //(multiplier par 10000)
const int fact_1=(10000*yAC)/diviseur_commun, fact_2=(10000*xAC)/diviseur_commun;
const int fact_3=(10000*xAB)/diviseur_commun, fact_4=(10000*yAB)/diviseur_commun;
for (int y=ymin; y<=ymax; y++)
{
// détermination du xmin et du xmax de la ligne
int tx1,tx2;
for (int t=0;t<3;t++)
{if (get_x(y,&cotes[t],&tx1)) break;}
for (int t=0;t<3;t++)
{if (get_x(y,&cotes[t],&tx2)&&tx1!=tx2) break;}
const int txmin=max(min(tx1,tx2),0), txmax=min(max(tx1,tx2),127);
for (int x=txmin; x<=txmax; x++)
{
double vx, vy, z;
// calcul de vx, vy
vx=(xcalc*fact_1-ycalc*fact_2); // 0 <vx< 10_000
vy=(ycalc*fact_3-xcalc*fact_4); // idem
z=face->s1->translated.z + (vx*zAB+vy*zAC)/10000;
vx/=10000;
vy/=10000;
vx /= (double)face->s2->translated.z / ((1-vx) / face->s1->translated.z + vx / (double)face->s2->translated.z);
vy /= (double)face->s3->translated.z / ((1-vy) / face->s1->translated.z + vy / (double)face->s3->translated.z);
// Affichage du point
if (FE_zbuffer_set_dist(x,y,z))
dpixel(x, y, 3*FE_get_pixel(face->texturenum, 8*vx, 8*vy)); // 3* means cast to black and white, and vx,and vy casted between 0 and 7
}
}
// x=Det(AM,AC)/det(AB,AC)
// y=det(AM,AB)/det(AC,AB)
// x=(xAM*yAC-yAM*xAC)/(xAB*yAC-yAB*xAC)
// y=(xAM*yAB-yAM*xAB)/(xAC*yAB-yAC*xAB)
// soit diviseur_commun = (xAB*yAC-yAB*xAC)
// x=xAM*yAC/diviseur_commun-yAM*xAC/diviseur_commun
// y=yAM*xAB/diviseur_commun-xAM*yAB/diciseur_commun
}

View File

@ -1,17 +0,0 @@
#ifndef FE_FACE_H
#define FE_FACE_H
#include "coord.h"
#include "FxEngine.h"
typedef struct FE_face FE_face;
struct FE_face
{
FE_point *s1,*s2,*s3;
bool visible; // true => clockwised
int texturenum;
};
void FE_draw_face(FE_face const * face);
#endif

View File

@ -1,73 +0,0 @@
#include <gint/timer.h>
#include <gint/clock.h>
#include <gint/mpu/tmu.h>
#include <gint/std/stdlib.h>
#include <gint/hardware.h>
#include <libprof.h>
/* Recursion depth of each function currently being executed */
uint8_t *prof_rec = NULL;
/* Time that has elapsed within each function; the value for a given function
is only relevant when it is not executing, due to optimizations */
uint32_t *prof_elapsed = NULL;
/* Timer counter */
uint32_t volatile *prof_tcnt = NULL;
/* Timer ID */
static int prof_timer;
/* prof_init(): Initialize the profiler's data and timer */
int prof_init(int n, int timer)
{
if((unsigned)timer >= 3) return 1;
prof_rec = malloc(n * sizeof *prof_rec);
prof_elapsed = malloc(n * sizeof *prof_elapsed);
int status = timer_setup(timer, 0xffffffff, timer_Po_4, NULL, NULL);
if(!prof_rec || !prof_elapsed || status < 0)
{
prof_quit();
return 1;
}
/* Fix the configuration done by gint by disabling the interrupt */
if(isSH3())
{
SH7705_TMU.TMU[timer].TCR.UNIE = 0;
prof_tcnt = &SH7705_TMU.TMU[timer].TCNT;
}
else
{
SH7305_TMU.TMU[timer].TCR.UNIE = 0;
prof_tcnt = &SH7305_TMU.TMU[timer].TCNT;
}
timer_start(timer);
prof_timer = timer;
return 0;
}
/* prof_quit(): Free the profiler's data and timer */
void prof_quit(void)
{
timer_stop(prof_timer);
free(prof_rec);
free(prof_time);
}
//---
// Post-measurement analysis
//---
/* prof_time(): Time spent in a given context, in microseconds */
uint32_t prof_time(int ctx)
{
int Pphi = clock_freq()->Pphi_f;
uint64_t time = prof_elapsed[ctx];
return (time * 4 * 1000000) / Pphi;
}

View File

@ -1,75 +0,0 @@
//---
// libprof: A manual profiling library for gint
//---
#ifndef LIBPROF_LIBPROF
#define LIBPROF_LIBPROF
#include <stdint.h>
//---
// Initialization
//---
/* prof_init(): Initialize the profiler's data and timer
Initializes [prof_rec] and [prof_time] (see below) with enough elements to
hold all the context IDs. Context IDs should be numbered from 0 to [n-1];
due to speed requirements array bounds are not checked so be careful.
Also starts a timer to count time. The timer ID must be set to 0, 1 or 2 as
the standard TMU is the most tweakable and precise. libprof automatically
selects an accurate timer configuration.
@n Number of different contexts (functions) that will be measured
@timer Timer ID, see <gint/timer.h> to select one
Returns non-zero if a setup error occurs. */
int prof_init(int n, int timer);
/* prof_quit(): Free the profiler's data and timer */
void prof_quit(void);
//---
// Runtime time measurement
//---
/* Recursion depth of each function currently being executed */
extern uint8_t *prof_rec;
/* Time that has elapsed within each function; the value for a given function
is only relevant when it is not executing, due to optimizations */
extern uint32_t *prof_elapsed;
/* Timer counter */
extern uint32_t volatile *prof_tcnt;
/* prof_enter(): Start counting time for a function
This macro should be called at the start of the context scope. If the
function was already executing then the deepest instance in the stack is
used instead of creating a new counter. */
#define prof_enter(ctx) { \
if(!prof_rec[ctx]++) prof_elapsed[ctx] += *prof_tcnt; \
}
/* prof_leave(): Stop counting time for a function
This should be called at the end of the context scope; it only actually
stops if there is no deeper instance of the context in the stack. If there
are not as exactly as many prof_leave()'s as prof_enter()'s then the
resulting time measure will not be relevant at all. */
#define prof_leave(ctx) { \
if(!--prof_rec[ctx]) prof_elapsed[ctx] -= *prof_tcnt; \
}
/* prof_clear(): Clear a context's counter
This operation is defined only if the context is not being profiled. */
#define prof_clear(ctx) { \
prof_elapsed[ctx] = 0; \
}
//---
// Post-measurement analysis
//---
/* prof_time(): Time spent in a given context, in microseconds
Should only be called when the context is not currently executing. */
uint32_t prof_time(int ctx);
#endif /* LIBPROF_LIBPROF */

View File

@ -1,13 +0,0 @@
#include "texture.h"
unsigned char const FE_textures[3][8]=
{
{0,0,0,0,0,0,0,0}, // full white
{255,255,255,255,255,255,255,255}, // full black
{255,193,161,145,137,133,131,255} // borders and diagonal
};
bool FE_get_pixel(int num,int x, int y)
{
return ((1<<(7-x)) & (FE_textures[num][y]));
}

View File

@ -1,26 +0,0 @@
#ifndef FE_TEXTURE_H
#define FE_TEXTURE_H
#include <stdbool.h>
/** Header pour les textures de FxEngine
* format - textures monochromes au format 8x8 => stocké sur 8 unsigned char
* accès - une texture est définie par son numéro
* l'accès à un pixel se fait avec FE_get_pixel
**/
/** numéros d'accès des textures : **/
#define FE_T_BLANC 0
#define FE_T_NOIR 1
#define FE_T_CAISSE 2
/** tableau des textures : défini dans <texture.c> **/
extern unsigned char const FE_textures[][8];
/** FE_get_pixel - accès à un pixel individuel d'une texture
* x et y sont compris entre 0 et 7
* numéro de texture classique
* retourne la couleur sur un bit
**/
bool FE_get_pixel(int texture_num, int x, int y);
#endif

View File

@ -1,60 +0,0 @@
#include "zbuffer.h"
#include <stdbool.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
/** size_uint32
* taille du zbuffer exprimée en uint32_t
* utile pour l'effacement du zbuffer sur sh3
**/
static const int size_uint32 = FE_ZB_SIZE_X*FE_ZB_SIZE_X;
/** size_char
* taille du zbuffer exprimée en octets
* sera utile pour le DMA Controller
**/
static const int size_char = size_uint32*sizeof(uint32_t);
/** address
* addresse du zbuffer
**/
static uint32_t* address=0;
void FE_zbuffer_clear()
{
while (address==0)
{
address = malloc(size_octets);
if (address==0) // cas de figure où il n'y a plus assez de RAM
{
dclear(C_WHITE);
dtext(1, 1, "Not enough RAM...", C_BLACK, C_NONE);
}
}
// TODO déterminer le type d'effacement
// effacement fait par le CPU
uint32_t indice = 0;
for (indice = 0; indice < size_uint32; indice ++)
address[indice] = 3000;
// effacement fait par le DMA
// TODO
}
bool FE_zbuffer_set_dist(int x, int y, int dist)
{
x %= FE_ZB_SIZE_X;
y %= FE_ZB_SIZE_Y;
const int indice = x * 64 + y;
if (address[indice]>dist && dist>0)
{
address[indice] = dist;
return true;
}
else
return false;
}

View File

@ -1,22 +0,0 @@
#ifndef FE_ZBUFFER
#define FE_ZBUFFER
/** Taille du z_buffer **/
#define FE_ZB_SIZE_X 128
#define FE_ZB_SIZE_Y 64
/** FE_zbuffer_clear
* effacer le z buffer pour un nouveau cycle de dessin
* TODO : ajouter effacement avec le DMA Controller pour les modèles ayant un processeur SH4-A
**/
void FE_zbuffer_clear();
#include <stdbool.h>
/** FE_zbuffer_set_dist
* change la distance d'un pixel du zbuffer
* retourne true si il faut dessiner le pixel
* retourne false si le pixel est déjà existant
**/
bool FE_zbuffer_set_dist(int x, int y, int dist); // if you are allowed to draw the pixel on vram
#endif

View File

@ -1,25 +0,0 @@
#include "controls.h"
#include <gint/display.h>
#include <gint/std/stdlib.h>
#include <gint/std/stdio.h>
#include <stdbool.h>
#include "FxEngine/FxEngine.h"
void init_controls()
{
dfont(&font_FxEngine);
}
static bool fps_visibility;
static char fps[10];
void reload_fps_displaying()
{
sprintf(fps,"%d",FE_get_fps_current());
}
void display_fps(int x, int y)
{
dimage(x,y,&img_fps);
dtext(x+11, y+2, fps, C_BLACK, C_NONE);
}

View File

@ -1,11 +0,0 @@
#ifndef CONTROLS_H
#define CONTROLS_H
#include <gint/display.h>
extern font_t font_FxEngine;
extern image_t img_fps;
void init_controls();
void reload_fps_displaying();
void display_fps(int x, int y);
#endif

View File

@ -1,8 +0,0 @@
#ifndef CREDITS_H
#define CREDITS_H
#define AUTHOR "Milang"
#define NAME "1v1 3D"
#define VERSION "Alpha Build 1.00"
#endif

315
src/main.c Normal file → Executable file
View File

@ -1,38 +1,299 @@
#include <gint/display.h>
#include <gint/timer.h>
#include <gint/keyboard.h>
#include <liblog.h>
#include <fxengine/model/bitmap.h>
#include <fxengine/model/vertex.h>
#include <fxengine/model/triangle.h>
#include <fxengine/model/object.h>
#include <fxengine/renderlist.h>
#include <fxengine/fxengine.h>
int callback(void)
{
fe_callback_start();
fe_draw();
dupdate();
ll_send("Rendered Image\n");
key_event_t event = pollevent();
int state=0;
while (event.type!=KEYEV_NONE)
{
if (event.key == KEY_F1)
state = 1;
event=pollevent();
}
if (state)
{
timer_pause(1);
ll_pause();
timer_start(1);
}
fe_callback_end();
return 0;
}
int main(void)
{
dclear(C_WHITE);
uint32_t color[32] =
{
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111
};
fe_bitmap * bmp = fe_bitmap_new(32, 32, color, 0, 0, 0);
fe_vertex v[3]=
{
{30,-10,-10},
{30,10,10},
{30,-10,10}
};
fe_object obj;
fe_object_init(&obj);
fe_object_set_vertex(&obj, v, 3, 0);
fe_triangle t[1]=
{
fe_object_getvx(&obj,0),
fe_object_getvx(&obj,1),
fe_object_getvx(&obj,2),
bmp, bmp,
0
};
fe_object_set_faces(&obj, t, 1, 0);
// Add object to list
fe_renderlist_add(&obj);
// Launch game timer at 40 FPS max
timer_setup(1, timer_delay(0, 25 * 1000), 0, callback, 0);
timer_start(1);
// Launch 3D renderer
fe_load();
// Free Data
return;
}
/*
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/clock.h>
#include "FxEngine/FxEngine.h"
#include "FxEngine/face.h"
#include "controls.h"
#include <fxengine/camera.h>
#include <fxengine/object.h>
#include <fxengine/fxengine.h>
#include <liblog.h>
#include <fxengine.h>
int main(void)
{
init_controls();
dclear(C_WHITE);
FE_point point[4]={{{10,0,0},{0,0,0}},{{10,10,0},{0,0,0}},{{10,0,10},{0,0,0}},{{10,10,10},{0,0,0}}};
FE_face face={&point[0],&point[1],&point[2],1,2};
FE_face face2={&point[3],&point[1],&point[2],0,2};
ll_set_state(0);
ll_set_panic();
ll_send("Log Beginning\n");
dclear(C_WHITE);
uint32_t color[32] =
{
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111,
0b11111111111111111111111111111111
};
fe_texture_rich * bmp = fe_texture_new_rich(32, 32, color, 0, 0, 0);
fe_ivertex v[4]=
{
{
{30,-10,-10},
{0,0,0}
},
{
{30,10,10},
{0,0,0}
},
{
{30,-10,10},
{0,0,0}
}
};
while (1)
{
FE_new_frame();
reload_fps_displaying();
fe_triangle triangle =
{
{
fe_object_get_vertex(&object, 0),
fe_object_get_vertex(&object, 1),
fe_object_get_vertex(&object, 2),
bmp,
0,
0
}
};
for (int i=0;i<4;i++)
{
FE_calc(&point[i]);
if (point[i].translated.z>0)
{
dpixel(point[i].translated.x,point[i].translated.y,C_BLACK);
}
}
FE_draw_face(&face);
FE_draw_face(&face2);
display_fps(100,56);
}
getkey();
return 1;
}
fe_object object; fe_object_init(&object);
fe_object_set_points(&object, &v, 3, 0);
fe_triangle triangle =
{
{
fe_object_get_vertex(&object, 0),
fe_object_get_vertex(&object, 1),
fe_object_get_vertex(&object, 2),
bmp,
0,
0
}
};
fe_object_set_faces(&object, &triangle, 1, 0);
fe_camera cam = {{20,20,0},{20,20,0},0,0,0};
int fps;
while (1)
{
int state=1;
key_event_t event = pollevent();
while (event.type!=KEYEV_NONE)
{
//ll_log(str);
if (event.key == KEY_LEFT)
cam.dh -= 0.01;
if (event.key == KEY_RIGHT)
cam.dh += 0.01;
cam.dh = fe_modulo_2pi(cam.dh);
if (event.key == KEY_UP)
cam.dv += 0.01;
if (event.key == KEY_DOWN)
cam.dv -= 0.01;
cam.dv = fe_modulo_2pi(cam.dv);
if (event.key == KEY_8)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_sin(cam.dh));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_cos(cam.dh));
}
if (event.key == KEY_2)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_sin(cam.dh+pi));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_cos(cam.dh+pi));
}
if (event.key == KEY_6)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_sin(cam.dh+pi_sur_2));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_cos(cam.dh+pi_sur_2));
}
if (event.key == KEY_4)
{
cam.pos.x = cam.pos.x + (int32_t)(5*fe_sin(cam.dh-pi_sur_2));
cam.pos.y = cam.pos.y + (int32_t)(5*fe_cos(cam.dh-pi_sur_2));
}
cam.dv = fe_modulo_2pi(cam.dv);
if (event.key == KEY_MENU)
return;
if (event.key==KEY_F1 && event.type==KEYEV_DOWN)
{
ll_pause();
}
event=pollevent();
}
fe_view_set(&cam);
fe_object_display(&object);
char str[300];
sprintf(str, "\nCamera Settings :\n>> x %d; y %d; z %d;\n>> dh %d; dv %d;\n",
cam.pos.x,
cam.pos.y,
cam.pos.z,
(int)(cam.dh*180/pi),
(int)(cam.dv*180/pi)
);
ll_send(str);
sprintf(str,"FPS=%d",fps);
dtext(1,1,str,C_BLACK,C_NONE);
fps=fe_display(0);
}
return 1;
}
*/