Compare commits

..

19 Commits

Author SHA1 Message Date
milang 308cb408a2 correct zbuffer clearing ( thanks @lephenixnoir) 2019-08-19 12:58:50 +02:00
Milang 4ccf324e48 rename some static variables 2019-08-19 12:10:06 +02:00
Milang 891921fd39 f*ck dma again 2019-08-17 20:07:59 +02:00
Milang 42cd1bb580 f*ck dma 2019-08-17 20:07:04 +02:00
Milang a8360f10dc dma again (I hate it) 2019-08-17 19:59:56 +02:00
Milang 869a762637 align zbuffer on 32Bytes blocks 2019-08-17 19:48:41 +02:00
Milang 45ec1a4a35 correct bug in DMA using
-> copied value was not set on 32 bytes, but on 4 bytes
2019-08-17 19:37:27 +02:00
Milang 94b7f6e7c6 still debugging direct memory access controller (I gonna suicide) 2019-08-17 19:25:16 +02:00
Milang e9c5f9935d debugging DMA 2019-08-17 19:13:28 +02:00
Milang 5b99d60eff align the buffer 2 2019-08-17 18:25:30 +02:00
Milang bfe73f1886 align the buffer 2019-08-17 18:23:41 +02:00
Milang 6f36dd1966 test to align zbuffer on 32 2019-08-17 18:14:36 +02:00
Milang d9abe48615 DMA, finished ? 2019-08-17 17:57:44 +02:00
Milang 3b62636d30 potatoes 2019-08-17 17:50:53 +02:00
Milang 84d31c7783 add DMA >> experimental 2019-08-17 17:47:05 +02:00
Milang 9900f70201 inchallah ça passe 2019-08-17 17:28:27 +02:00
milang d45020336e continue to remake rendering 2019-08-17 14:42:59 +02:00
milang e4f86a3c3e implementing texture rendering 2019-08-17 14:30:18 +02:00
milang 263e8543c6 changing triangle rendering 2019-08-17 14:09:45 +02:00
78 changed files with 1453 additions and 1187 deletions

6
.gitignore vendored
View File

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

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

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

BIN
1v13D.g1a Executable file → Normal file

Binary file not shown.

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

0
AddinInfo.txt Executable file → Normal file
View File

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

0
FXSH_Build.bat Executable file → Normal file
View File

BIN
INIT/CasioRAM.mem Executable file → Normal file

Binary file not shown.

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

228
LICENSE
View File

@ -1,228 +0,0 @@
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 Executable file → Normal file
View File

@ -16,8 +16,8 @@ cf-fx := $(cf) -m3 -DFX9860G
cf-cg := $(cf) -m4-nofpu -DFXCG50
# Linker flags
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
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
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 := $(wildcard src/*.[csS] src/*/*.[csS] src/*/*/*.[csS] \
src/*/*/*/*.[csS])
assets-fx := $(wildcard assets-fx/*/*)
assets-cg := $(wildcard assets-cg/*/*)
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/*)
# Object files
obj-fx := $(src:%.c=build-fx/%.o) $(assets-fx:assets-fx/%=build-fx/assets/%.o)
@ -89,28 +89,16 @@ 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 $@ --fx name:img_$(basename $*)
fxconv -i $< -o $@ 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 $@ --cg name:img_$(basename $*)
fxconv -i $< -o $@ name:img_$(basename $*)
# Fonts
build-fx/assets/fonts/%.o: assets-fx/fonts/%
@ -139,8 +127,8 @@ distclean: clean
install-fx: $(target-fx)
p7 send -f $<
install-cg: $(target-cg)
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 0.25; done
@ while ! mount /dev/Prizm1; do sleep 0.25; done
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 1; done
@ mount /dev/Prizm1
@ rm -f /mnt/prizm/$<
@ cp $< /mnt/prizm
@ umount /dev/Prizm1

0
README.md Executable file → Normal file
View File

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

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

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

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

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

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 812 B

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

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 245 B

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

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

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

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

1160
build-fx/map Executable file → Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

BIN
build-fx/src/1v13D.elf Executable file

Binary file not shown.

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

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

Binary file not shown.

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

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

Binary file not shown.

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

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

Binary file not shown.

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

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

View File

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

Binary file not shown.

View File

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

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

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

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

View File

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

View File

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

View File

@ -1,6 +0,0 @@
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:

View File

@ -1,6 +0,0 @@
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:

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

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

Binary file not shown.

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

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

Binary file not shown.

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

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

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

@ -1,5 +1,6 @@
build-fx/src/controls.o: src/controls.c src/controls.h \
src/FxEngine/FxEngine.h src/FxEngine/coord.h src/FxEngine/zbuffer.h
src/FxEngine/FxEngine.h src/FxEngine/coord.h src/FxEngine/FxEngine.h \
src/FxEngine/zbuffer.h
src/controls.h:
@ -7,4 +8,6 @@ src/FxEngine/FxEngine.h:
src/FxEngine/coord.h:
src/FxEngine/FxEngine.h:
src/FxEngine/zbuffer.h:

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

Binary file not shown.

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

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

BIN
build-fx/src/main.o Executable file → Normal 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/v1/topic.txt → pc/topic.txt Executable file → Normal file
View File

4
project.cfg Executable file → Normal 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 = -lfxengine -llog-fx -lgint-fx -lprof
LDFLAGS =
# 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

124
src/FxEngine/FxEngine.c Normal file
View File

@ -0,0 +1,124 @@
#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 + FE_PI);
px += FE_sin(FE_dh + FE_PI);
}
if (event.key==KEY_4)
{
py += FE_cos(FE_dh - FE_PI_SUR_2);
px += FE_sin(FE_dh - FE_PI_SUR_2);
}
if (event.key==KEY_6)
{
py += FE_cos(FE_dh + FE_PI_SUR_2);
px += FE_sin(FE_dh + FE_PI_SUR_2);
}
}
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
uint32_t FE_get_fps_current()
{
return MICROSECOND / frame_interval;
}
uint32_t FE_get_fps_min()
{
return MICROSECOND / frame_interval_max;
}
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;
}

63
src/FxEngine/FxEngine.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef FENG_H
#define FENG_H
#include <stdint.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 */
uint32_t 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 */
uint32_t 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 */
uint32_t 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

114
src/FxEngine/coord.c Normal file
View File

@ -0,0 +1,114 @@
#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<=-FE_PI)
a += FE_2_PI;
while (a>FE_PI)
a -= FE_2_PI;
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 - FE_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 - FE_PI_SUR_2);
}
#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;
}

61
src/FxEngine/coord.h Normal file
View File

@ -0,0 +1,61 @@
#ifndef FE_COORD_H
#define FE_COORD_H
/* FE_position:
notion de point dans l'espace simple */
typedef struct FE_position FE_position;
struct FE_position
{int 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};
#include "FxEngine.h"
/* 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

154
src/FxEngine/face.c Normal file
View File

@ -0,0 +1,154 @@
#include "face.h"
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define abs(x) (x>0?x:-x)
#include <stdbool.h>
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;
}
#include "texture.h"
#include "zbuffer.h"
#include <gint/display.h>
void FE_draw_face(FE_face const * face)
{
// élimination des faces cachées
if (sens_horaire(face)!=face->visible)
return;
// cas particuliers où la face n'est pas dans l'écran
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;
// cas où un côté est nul
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 int32_t y1 = max(min(face->s1->translated.y, min(face->s2->translated.y, face->s3->translated.y)), 0);
const int32_t y2 = min(max(face->s1->translated.y, max(face->s2->translated.y, face->s3->translated.y)), 63);
// ressources pour déformer les textures
const int32_t 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 int32_t 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 int32_t diviseur_commun=(xAB*yAC-yAB*xAC);
const int fact_1=(1024*yAC)/diviseur_commun, fact_2=(1024*xAC)/diviseur_commun;
const int fact_3=(1024*xAB)/diviseur_commun, fact_4=(1024*yAB)/diviseur_commun;
for (int y=y1; y<=y2; 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++)
{
// vx et vy coordonnées transformées pour l'accès à la texture
// z distance du point visible (distance non transformée)
int32_t vx, vy, z;
// calcul de vx, vy
const int32_t xcalc = x-face->s1->translated.x, ycalc = y-face->s1->translated.y;
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)/1024; // calcul de z non corrigé >> fonctionnel
if (z>0)
{
vx = (8 * vx * face->s1->translated.z)
/
(1024 * face->s1->translated.z + (1024 - vx) * face->s2->translated.z);
vy = (8 * vy * face->s1->translated.z)
/
(1024 * face->s1->translated.z + (1024 - vy) * face->s3->translated.z);
// Affichage du point
if (FE_zbuffer_set_dist(x,y,z))
dpixel(x, y, 3*FE_get_pixel(face->texturenum, vx, 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
}

16
src/FxEngine/face.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef FE_FACE_H
#define FE_FACE_H
#include "coord.h"
#include <stdbool.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

73
src/FxEngine/libprof.c Normal file
View File

@ -0,0 +1,73 @@
#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;
}

75
src/FxEngine/libprof.h Normal file
View File

@ -0,0 +1,75 @@
//---
// 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 */

13
src/FxEngine/texture.c Normal file
View File

@ -0,0 +1,13 @@
#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]));
}

26
src/FxEngine/texture.h Normal file
View File

@ -0,0 +1,26 @@
#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

66
src/FxEngine/zbuffer.c Normal file
View File

@ -0,0 +1,66 @@
#include "zbuffer.h"
#include <stdint.h>
#include <stdbool.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
#include <gint/dma.h>
#include <gint/hardware.h>
/* size_uint32
taille du zbuffer exprimée en uint32_t
utile pour l'effacement du zbuffer sur sh3 */
static const uint32_t size_int32 = FE_ZB_SIZE_X*FE_ZB_SIZE_Y;
/* size_char
taille du zbuffer exprimée en octets
utile pour malloc */
static const uint32_t size_char = size_int32*sizeof(int32_t);
/* size_char
taille du zbuffer exprimée en octets
utile pour le DMA */
static const uint32_t size_blocks = size_char/32;
// buffer situe a la fin de la RAM
static const int32_t *address = (void *)0x88080000 - size_char;
#include <gint/defs/attributes.h>
GALIGNED(32) GSECTION(".rodata") static const int32_t clearval[8]={3000,3000,3000,3000,3000,3000,3000,3000};
void FE_zbuffer_clear()
{
if (isSH3())
{ // effacement CPU
uint_fast16_t indice;
for (indice = 0; indice < size_int32; indice ++)
address[indice] = clearval[0];
}
else
{ // effacement DMA
dma_transfer(0, DMA_32B, size_blocks, &clearval, DMA_FIXED, address, DMA_INC);
}
}
void FE_start_rendering()
{
if (!isSH3())
dma_transfer_wait(0);
}
bool FE_zbuffer_set_dist(int32_t x, int32_t y, int32_t dist)
{
x %= FE_ZB_SIZE_X;
y %= FE_ZB_SIZE_Y;
const uint32_t indice = x * 64 + y;
if (address[indice]>dist && dist>0)
{
address[indice] = dist;
return true;
}
else
return false;
}

28
src/FxEngine/zbuffer.h Normal file
View File

@ -0,0 +1,28 @@
#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>
#include <stdint.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(int32_t x, int32_t y, int32_t dist); // if you are allowed to draw the pixel on vram
/* FE_zbuffer_set_dist
doit être appelée avant l'affichage
attend la fin du transfert dma effaçant le zbuffer
**/
void FE_start_rendering();
#endif

25
src/controls.c Normal file
View File

@ -0,0 +1,25 @@
#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);
}

11
src/controls.h Normal file
View File

@ -0,0 +1,11 @@
#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

8
src/credits.h Normal file
View File

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

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

@ -1,299 +1,38 @@
#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)
{
ll_set_state(0);
ll_set_panic();
ll_send("Log Beginning\n");
init_controls();
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}
}
};
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};
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 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)
FE_new_frame();
reload_fps_displaying();
display_fps(100,56);
for (int i=0;i<4;i++)
{
//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)
FE_calc(&point[i]);
if (point[i].translated.z>0)
{
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));
dpixel(point[i].translated.x,point[i].translated.y,C_BLACK);
}
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;
}
*/
FE_start_rendering();
FE_draw_face(&face);
FE_draw_face(&face2);
}
getkey();
return 1;
}