mirror of
https://github.com/AntonioND/nitro-engine.git
synced 2025-06-18 16:45:33 -04:00
examples: Remove outdated examples
This commit is contained in:
parent
db8add4d7e
commit
238b930c7f
@ -1,5 +0,0 @@
|
||||
SUBDIRS:= `ls`
|
||||
all:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||
clean:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
@ -1,220 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
# DATA is a list of directories containing binary files embedded using bin2o
|
||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
||||
# NITRO is a directory that will be accessible via NitroFS
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(shell basename $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
INCLUDES := include
|
||||
DATA := data
|
||||
GRAPHICS :=
|
||||
AUDIO :=
|
||||
ICON :=
|
||||
|
||||
# specify a directory which contains the nitro filesystem
|
||||
# this is relative to the Makefile
|
||||
NITRO :=
|
||||
|
||||
# These set the information text in the nds file
|
||||
GAME_TITLE := Nitro Engine example
|
||||
GAME_SUBTITLE1 := built with devkitARM
|
||||
GAME_SUBTITLE2 := http://devitpro.org
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
||||
|
||||
CFLAGS := -g -Wall -O3\
|
||||
$(ARCH) $(INCLUDE) -DARM9
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project (order is important)
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lNE -lfat -lnds9
|
||||
|
||||
# automatigically add libraries for NitroFS
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
LIBS := -lfilesystem -lfat $(LIBS)
|
||||
endif
|
||||
# automagically add maxmod library
|
||||
ifneq ($(strip $(AUDIO)),)
|
||||
LIBS := -lmm9 $(LIBS)
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
# prepare NitroFS directory
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
||||
endif
|
||||
|
||||
# get audio list for maxmod
|
||||
ifneq ($(strip $(AUDIO)),)
|
||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
||||
|
||||
# place the soundbank file in NitroFS if using it
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
||||
|
||||
# otherwise, needs to be loaded from memory
|
||||
else
|
||||
export SOUNDBANK := soundbank.bin
|
||||
BINFILES += $(SOUNDBANK)
|
||||
endif
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
||||
|
||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.bmp)
|
||||
|
||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
||||
else
|
||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifeq ($(suffix $(ICON)), .grf)
|
||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
||||
else
|
||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
# source files depend on generated headers
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
# need to build soundbank first
|
||||
$(OFILES): $(SOUNDBANK)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# rule to build solution from music files
|
||||
#---------------------------------------------------------------------------------
|
||||
$(SOUNDBANK) : $(MODFILES)
|
||||
#---------------------------------------------------------------------------------
|
||||
mmutil $^ -d -o$@ -hsoundbank.h
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule creates assembly source files using grit
|
||||
# grit takes an image file and a .grit describing how the file is to be processed
|
||||
# add additional rules like this for each image extension
|
||||
# you use in the graphics folders
|
||||
#---------------------------------------------------------------------------------
|
||||
%.s %.h: %.png %.grit
|
||||
#---------------------------------------------------------------------------------
|
||||
grit $< -fts -o$*
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Convert non-GRF game icon to GRF if needed
|
||||
#---------------------------------------------------------------------------------
|
||||
$(GAME_ICON): $(notdir $(ICON))
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo convert $(notdir $<)
|
||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,239 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// Copyright (c) 2008, Ti-Ra-Nog
|
||||
// Copyright (c) 2008-2011, 2019, 2022 Antonio Niño Díaz
|
||||
//
|
||||
// This file is part of Nitro Engine
|
||||
|
||||
// Nitro Engine NDS Benchmark by Ti-Ra-Nog
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <NEMain.h>
|
||||
|
||||
#include "cube_bin.h"
|
||||
#include "model_bin.h"
|
||||
#include "texcube_bin.h"
|
||||
#include "texsphere_bin.h"
|
||||
|
||||
// Set the initial number of balls/spheres
|
||||
#define NUM_BALLS 50
|
||||
// Set the maxium number of balls/spheres
|
||||
#define MAX_NUM_BALLS 255
|
||||
// Set the minium number of balls/spheres
|
||||
#define MIN_NUM_BALLS 0
|
||||
|
||||
int NUM = NUM_BALLS;
|
||||
|
||||
NE_Camera *Camera;
|
||||
NE_Model *Sphere[MAX_NUM_BALLS], *Cube;
|
||||
NE_Material *Material, *Material2;
|
||||
|
||||
float mov;
|
||||
|
||||
typedef struct {
|
||||
float x,y,z;
|
||||
float vx,vy,vz;
|
||||
} ball_t;
|
||||
|
||||
ball_t Ball[MAX_NUM_BALLS];
|
||||
|
||||
void Draw3DScene(void)
|
||||
{
|
||||
scanKeys(); // Refresh keypad
|
||||
int keys = keysHeld(); // Keys continously pressed
|
||||
|
||||
mov += 0.5; // If B is pressed, increase camera rotation speed
|
||||
NE_CameraUse(Camera); //Use camera and draw all objects.
|
||||
|
||||
// Rotate the camara every frame if the B Button is pressed (slowly)
|
||||
if (!(keys & KEY_B))
|
||||
NE_ViewRotate(0, 0, mov);
|
||||
|
||||
// Draw the cube
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_NONE, 0);
|
||||
NE_ModelDraw(Cube);
|
||||
|
||||
// Draw every Sphere
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0);
|
||||
for (int i = 0; i < NUM; i++)
|
||||
NE_ModelDraw(Sphere[i]);
|
||||
|
||||
// Get some information AFTER drawing but BEFORE returning from the function
|
||||
printf("\x1b[0;0HPolygon RAM: %d \nVertex RAM: %d ",
|
||||
NE_GetPolygonCount(), NE_GetVertexCount());
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
irqEnable(IRQ_HBLANK);
|
||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
||||
|
||||
// Init Nitro Engine 3D rendering in one screen.
|
||||
NE_Init3D();
|
||||
// libnds uses VRAM_C for the text console, reserve A and B only
|
||||
NE_TextureSystemReset(0, 0, NE_VRAM_AB);
|
||||
// Init console in non-3D screen
|
||||
consoleDemoInit();
|
||||
|
||||
// Allocate objects
|
||||
Cube = NE_ModelCreate(NE_Static); // Cube model
|
||||
Material = NE_MaterialCreate(); // Material for the cube
|
||||
Material2 = NE_MaterialCreate(); // Material fot the spheres
|
||||
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++) // Create all spheres
|
||||
Sphere[i] = NE_ModelCreate(NE_Static);
|
||||
|
||||
// Create and setup camera
|
||||
Camera = NE_CameraCreate();
|
||||
NE_CameraSet(Camera,
|
||||
6, 6, 6,
|
||||
0, 0, 0,
|
||||
0, 1, 0);
|
||||
|
||||
// Load sphere texture to its material
|
||||
NE_MaterialTexLoad(Material2, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
(u8 *)texsphere_bin);
|
||||
|
||||
// Loop until it arrives to the max ball number
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
{
|
||||
//Load every sphere model
|
||||
NE_ModelLoadStaticMesh(Sphere[i], (u32 *)model_bin);
|
||||
// Set Material2 to every Sphere
|
||||
NE_ModelSetMaterial(Sphere[i],Material2);
|
||||
}
|
||||
|
||||
// Load cube texture to its material
|
||||
NE_MaterialTexLoad(Material, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
(u8 *)texcube_bin);
|
||||
// Load the cube mesh
|
||||
NE_ModelLoadStaticMesh(Cube, (u32*)cube_bin);
|
||||
// Set the cube material
|
||||
NE_ModelSetMaterial(Cube, Material);
|
||||
// Resize the cube (it's originally 7x7x7, now it's 21x21x21)
|
||||
NE_ModelScale(Cube, 3, 3, 3);
|
||||
|
||||
// Set up the white light
|
||||
NE_LightSet(0, NE_White, 0, 1, 0);
|
||||
|
||||
//Enable shading
|
||||
NE_ShadingEnable(true);
|
||||
|
||||
// Set cube coordinates to (0, 0, 0)
|
||||
NE_ModelSetCoord(Cube, 0, 0, 0);
|
||||
|
||||
// Set start coordinates/rotation for models using random formules...
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
{
|
||||
// Set the speed for each axis
|
||||
Ball[i].vx = (float)(1 + ((float)(rand() % 10) / 10)) / 10;
|
||||
Ball[i].vy = (float)(1 + ((float)(rand() % 10) / 10)) / 10;
|
||||
Ball[i].vz = (float)(1 + ((float)(rand() % 10) / 10)) / 10;
|
||||
|
||||
// Randomly invert the speeds
|
||||
if (rand() & 1)
|
||||
Ball[i].vx *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vy *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vz *= -1;
|
||||
}
|
||||
|
||||
// Initialize some variables
|
||||
int fpscount = 0;
|
||||
int oldsec = 0;
|
||||
int seconds = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// Time Variables/Structs
|
||||
time_t unixTime = time(NULL);
|
||||
struct tm* timeStruct = gmtime((const time_t *)&unixTime);
|
||||
seconds = timeStruct->tm_sec;
|
||||
|
||||
// Have we moved to a new second?
|
||||
if (seconds != oldsec)
|
||||
{
|
||||
oldsec = seconds; // old second = new second
|
||||
printf("\x1b[0;20HFPS: %d", fpscount);
|
||||
fpscount = 0; // Reset FPS count for next second
|
||||
}
|
||||
|
||||
// Get keys information
|
||||
scanKeys();
|
||||
uint32 keys = keysHeld(); // Keys Continously pressed
|
||||
uint32 keysd = keysDown(); // Keys NOW pressed (only this frame)
|
||||
|
||||
// Set the model rotation for every Sphere
|
||||
for (int i = 0; i < NUM; i++)
|
||||
NE_ModelRotate(Sphere[i], 25 / i, -25 / i, 25 / i);
|
||||
|
||||
// Calculate the model position for every model
|
||||
for (int i = 0; i < NUM; i++)
|
||||
{
|
||||
// If the ball crashes with one of the faces of the cube
|
||||
// invert the speed of the corresponding axis.
|
||||
if ((Ball[i].x >= 10.5) || (Ball[i].x <= -10.5))
|
||||
Ball[i].vx *= -1;
|
||||
if ((Ball[i].y >= 9.5) || (Ball[i].y <= -9.0))
|
||||
Ball[i].vy *= -1;
|
||||
if ((Ball[i].z >= 10.5) || (Ball[i].z <= -10.5))
|
||||
Ball[i].vz *= -1;
|
||||
|
||||
// Add speed to the position to calculate the new
|
||||
// position
|
||||
Ball[i].x += Ball[i].vx;
|
||||
Ball[i].y += Ball[i].vy;
|
||||
Ball[i].z += Ball[i].vz;
|
||||
|
||||
// Update position
|
||||
NE_ModelSetCoord(Sphere[i], Ball[i].x, Ball[i].y, Ball[i].z);
|
||||
}
|
||||
|
||||
// Set all balls to (0, 0, 0) position.
|
||||
if (keys & KEY_Y)
|
||||
{
|
||||
for (int i = 0; i < NUM; i++)
|
||||
{
|
||||
Ball[i].x = 0;
|
||||
Ball[i].y = 0;
|
||||
Ball[i].z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\x1b[3;0HPolygon count: %d ", NUM * 48);
|
||||
|
||||
printf("\x1b[6;0HUp: Increase Ball Number.");
|
||||
printf("\x1b[7;0HDown: Decrease Ball Number.");
|
||||
printf("\x1b[8;0HR: Increase Ball Number by one.");
|
||||
printf("\x1b[9;0HL: Decrease Ball Number by one.");
|
||||
printf("\x1b[10;0HB: Stop camera rotation.");
|
||||
printf("\x1b[11;0HY: Set all balls to 0 position.");
|
||||
|
||||
// Draw scene
|
||||
NE_Process(Draw3DScene);
|
||||
|
||||
// Press UP: Increase the balls number
|
||||
if ((keys & KEY_UP) && (NUM != MAX_NUM_BALLS))
|
||||
NUM++;
|
||||
// Press DOWN: Decrease the balls number
|
||||
if ((keys & KEY_DOWN) && (NUM != MIN_NUM_BALLS))
|
||||
NUM--;
|
||||
// Press R: Increase the balls number by one
|
||||
if ((keysd & KEY_R) && (NUM != MAX_NUM_BALLS))
|
||||
NUM++;
|
||||
// Press L: Decrease the balls number by one
|
||||
if ((keysd & KEY_L) && (NUM != MIN_NUM_BALLS))
|
||||
NUM--;
|
||||
|
||||
printf("\x1b[2;0HBalls Number: %d ", NUM);
|
||||
|
||||
// Wait for next frame
|
||||
NE_WaitForVBL(0);
|
||||
fpscount++; // Increase the fps count
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
# DATA is a list of directories containing binary files embedded using bin2o
|
||||
# GRAPHICS is a list of directories containing image files to be converted with grit
|
||||
# AUDIO is a list of directories containing audio to be converted by maxmod
|
||||
# ICON is the image used to create the game icon, leave blank to use default rule
|
||||
# NITRO is a directory that will be accessible via NitroFS
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(shell basename $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
INCLUDES := include
|
||||
DATA := data
|
||||
GRAPHICS :=
|
||||
AUDIO :=
|
||||
ICON :=
|
||||
|
||||
# specify a directory which contains the nitro filesystem
|
||||
# this is relative to the Makefile
|
||||
NITRO :=
|
||||
|
||||
# These set the information text in the nds file
|
||||
GAME_TITLE := Nitro Engine example
|
||||
GAME_SUBTITLE1 := built with devkitARM
|
||||
GAME_SUBTITLE2 := http://devitpro.org
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
|
||||
|
||||
CFLAGS := -g -Wall -O3\
|
||||
$(ARCH) $(INCLUDE) -DARM9
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project (order is important)
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lNE -lfat -lnds9
|
||||
|
||||
# automatigically add libraries for NitroFS
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
LIBS := -lfilesystem -lfat $(LIBS)
|
||||
endif
|
||||
# automagically add maxmod library
|
||||
ifneq ($(strip $(AUDIO)),)
|
||||
LIBS := -lmm9 $(LIBS)
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBNDS) $(PORTLIBS) $(DEVKITPRO)/nitro-engine
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
|
||||
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
# prepare NitroFS directory
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
export NITRO_FILES := $(CURDIR)/$(NITRO)
|
||||
endif
|
||||
|
||||
# get audio list for maxmod
|
||||
ifneq ($(strip $(AUDIO)),)
|
||||
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
|
||||
|
||||
# place the soundbank file in NitroFS if using it
|
||||
ifneq ($(strip $(NITRO)),)
|
||||
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
|
||||
|
||||
# otherwise, needs to be loaded from memory
|
||||
else
|
||||
export SOUNDBANK := soundbank.bin
|
||||
BINFILES += $(SOUNDBANK)
|
||||
endif
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
|
||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export OFILES := $(PNGFILES:.png=.o) $(OFILES_BIN) $(OFILES_SOURCES)
|
||||
|
||||
export HFILES := $(PNGFILES:.png=.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.bmp)
|
||||
|
||||
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
|
||||
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
|
||||
else
|
||||
ifneq (,$(findstring icon.bmp,$(icons)))
|
||||
export GAME_ICON := $(CURDIR)/icon.bmp
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifeq ($(suffix $(ICON)), .grf)
|
||||
export GAME_ICON := $(CURDIR)/$(ICON)
|
||||
else
|
||||
export GAME_ICON := $(CURDIR)/$(BUILD)/$(notdir $(basename $(ICON))).grf
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).nds: $(OUTPUT).elf $(GAME_ICON)
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
# source files depend on generated headers
|
||||
$(OFILES_SOURCES) : $(HFILES)
|
||||
|
||||
# need to build soundbank first
|
||||
$(OFILES): $(SOUNDBANK)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# rule to build solution from music files
|
||||
#---------------------------------------------------------------------------------
|
||||
$(SOUNDBANK) : $(MODFILES)
|
||||
#---------------------------------------------------------------------------------
|
||||
mmutil $^ -d -o$@ -hsoundbank.h
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule creates assembly source files using grit
|
||||
# grit takes an image file and a .grit describing how the file is to be processed
|
||||
# add additional rules like this for each image extension
|
||||
# you use in the graphics folders
|
||||
#---------------------------------------------------------------------------------
|
||||
%.s %.h: %.png %.grit
|
||||
#---------------------------------------------------------------------------------
|
||||
grit $< -fts -o$*
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Convert non-GRF game icon to GRF if needed
|
||||
#---------------------------------------------------------------------------------
|
||||
$(GAME_ICON): $(notdir $(ICON))
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo convert $(notdir $<)
|
||||
@grit $< -g -gt -gB4 -gT FF00FF -m! -p -pe 16 -fh! -ftr
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,32 +0,0 @@
|
||||
Nitro Engine POC 3D Test by Ti-Ra-Nog
|
||||
-------------------------------------
|
||||
|
||||
If you want to enable the FAT mesh and/or texture reading, first uncomment the
|
||||
line: "#define FAT_MESH_TEXT" and then compile it.
|
||||
|
||||
After you have the binary file with the FAT texture/mesh reading enabled, copy
|
||||
this files to the root of your card or put them in the same folder where the nds
|
||||
is for test it on an emulator (with fat support).
|
||||
|
||||
In orther to use the screenshot or "video" recording function you need to
|
||||
enable the FAT access to your card, if you have a new card reader for nds you
|
||||
may no need to patch it, but if you have an older one may you need to patch the
|
||||
binary file with DLDI patch for you card reader.
|
||||
|
||||
In the binary folder there are three files, one no patched binary and two
|
||||
patched for R4 and Super card SD.
|
||||
|
||||
For making screenshots you need to create the "/screen" folder in the root
|
||||
directory of your card and then the screens should be there.
|
||||
|
||||
The "video" recording function make one screenshot per VBL and save it in to the
|
||||
video flother that you need to create in the root of the memory (i whasn't able
|
||||
to create the directory if it doesn't exist). When you push the "R" button the
|
||||
ds will make one screnshot for every vbl and you'll see the screen blinking and
|
||||
making some strange with the scenes, don't worry, the screenshots will be ok.
|
||||
The video will be recorded to "/video/vid".
|
||||
|
||||
When you have finished the the "video" recording you'll need to make a animated
|
||||
gif or avi video with some software.
|
||||
|
||||
So, that's all, I think that you'll love this Engine :D
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,488 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// Copyright (c) 2008, Ti-Ra-Nog
|
||||
// Copyright (c) 2008-2011, 2019, 2022 Antonio Niño Díaz
|
||||
//
|
||||
// This file is part of Nitro Engine
|
||||
|
||||
// 3D Test by Ti-Ra-Nog
|
||||
|
||||
//#define FAT_MESH_TEXT
|
||||
|
||||
#include <NEMain.h>
|
||||
|
||||
//#include <sys/dir.h>
|
||||
#include <fat.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef FAT_MESH_TEXT
|
||||
#include "cube_bin.h"
|
||||
#include "sphere_bin.h"
|
||||
#include "texcube_bin.h"
|
||||
#include "texsphere_bin.h"
|
||||
#endif
|
||||
|
||||
// Set the initial number of balls/spheres
|
||||
#define NUM_BALLS 50
|
||||
// Set the initial number of balls/spheres for the second scene
|
||||
#define SCENE2_BALLS 10
|
||||
// Set the maxium number of balls/spheres
|
||||
#define MAX_NUM_BALLS 255
|
||||
// Set the minium number of balls/spheres
|
||||
#define MIN_NUM_BALLS 0
|
||||
|
||||
int NUM = NUM_BALLS;
|
||||
|
||||
NE_Camera *Camara, *Camara2, *Camara3, *Camara4;
|
||||
NE_Model *Sphere[MAX_NUM_BALLS], *Cube, *Cube2;
|
||||
NE_Material *Material;
|
||||
NE_Material *Material2;
|
||||
NE_Material *Material3;
|
||||
|
||||
bool camera_swap = false;
|
||||
|
||||
#define SUMX 3
|
||||
#define SUMY 1
|
||||
#define SUMZ 2
|
||||
|
||||
typedef struct {
|
||||
float x, y, z;
|
||||
float vx, vy, vz;
|
||||
} ball_t;
|
||||
|
||||
ball_t Ball[MAX_NUM_BALLS];
|
||||
|
||||
int posx = 0;
|
||||
int posy = 0;
|
||||
int posz = 0;
|
||||
int posx2 = 0;
|
||||
int posy2 = 0;
|
||||
int posz2 = 0;
|
||||
|
||||
void Draw3DScene(void)
|
||||
{
|
||||
if (camera_swap)
|
||||
NE_CameraUse(Camara);
|
||||
else
|
||||
NE_CameraUse(Camara2);
|
||||
|
||||
NE_ViewRotate(posx, posy, posz);
|
||||
|
||||
// Set the culling to none
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_NONE, 0);
|
||||
NE_ModelDraw(Cube);
|
||||
NE_ModelDraw(Cube2);
|
||||
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0);
|
||||
|
||||
// Draw all spheres
|
||||
for (int i = 0; i < SCENE2_BALLS; i++)
|
||||
NE_ModelDraw(Sphere[i]);
|
||||
|
||||
printf("\x1b[19;1HPolygon RAM1: %d \n Vertex RAM1: %d ",
|
||||
NE_GetPolygonCount(), NE_GetVertexCount());
|
||||
}
|
||||
|
||||
void Draw3DScene2(void)
|
||||
{
|
||||
if (camera_swap)
|
||||
NE_CameraUse(Camara2);
|
||||
else
|
||||
NE_CameraUse(Camara);
|
||||
|
||||
NE_ViewRotate(posx2, posy2, posz2);
|
||||
|
||||
// Set the culling to none
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_NONE, 0);
|
||||
NE_ModelDraw(Cube);
|
||||
NE_ModelDraw(Cube2);
|
||||
|
||||
NE_PolyFormat(31, 0, NE_LIGHT_ALL, NE_CULL_BACK, 0);
|
||||
|
||||
// Draw all spheres
|
||||
for (int i = SCENE2_BALLS; i < NUM; i++)
|
||||
NE_ModelDraw(Sphere[i]);
|
||||
|
||||
printf("\x1b[21;1HPolygon RAM2: %d \n Vertex RAM2: %d ",
|
||||
NE_GetPolygonCount(), NE_GetVertexCount());
|
||||
}
|
||||
|
||||
void dual(void)
|
||||
{
|
||||
char file[200];
|
||||
bool noise_effect = false;
|
||||
bool sine_effect = false;
|
||||
bool recording = false;
|
||||
bool auto_rotate = false;
|
||||
bool hide_text = false;
|
||||
|
||||
// Screenshot number count
|
||||
int nc = 0;
|
||||
int sc = 0;
|
||||
|
||||
// Allocate all needed objects
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
Sphere[i] = NE_ModelCreate(NE_Static);
|
||||
|
||||
Cube = NE_ModelCreate(NE_Static);
|
||||
Cube2 = NE_ModelCreate(NE_Static);
|
||||
Camara = NE_CameraCreate();
|
||||
Camara2 = NE_CameraCreate();
|
||||
Material = NE_MaterialCreate();
|
||||
Material2 = NE_MaterialCreate();
|
||||
|
||||
#ifdef FAT_MESH_TEXT
|
||||
NE_MaterialTexLoadFAT(Material, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
"texsphere.bin");
|
||||
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
{
|
||||
// Load sphere model. Note that this is just to test. This is a
|
||||
// really inefficient way to load the same model several times.
|
||||
// Ideally, you'd load it once and then create models by cloning
|
||||
// the first one.
|
||||
NE_ModelLoadStaticMeshFAT(Sphere[i], "sphere.bin");
|
||||
// Set Material to every Sphere
|
||||
NE_ModelSetMaterial(Sphere[i], Material);
|
||||
}
|
||||
|
||||
NE_MaterialTexLoadFAT(Material2, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
"texcube.bin");
|
||||
NE_ModelLoadStaticMeshFAT(Cube, "cube.bin");
|
||||
NE_ModelSetMaterial(Cube, Material2);
|
||||
|
||||
NE_ModelLoadStaticMeshFAT(Cube2, "cube.bin");
|
||||
NE_ModelSetMaterial(Cube2, Material2);
|
||||
#else
|
||||
NE_MaterialTexLoad(Material, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
(u8 *)texsphere_bin);
|
||||
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
{
|
||||
// Load sphere model
|
||||
NE_ModelLoadStaticMesh(Sphere[i], (u32 *)sphere_bin);
|
||||
// Set material to every sphere
|
||||
NE_ModelSetMaterial(Sphere[i], Material);
|
||||
}
|
||||
|
||||
NE_MaterialTexLoad(Material2, GL_RGB, 64, 64, TEXGEN_TEXCOORD,
|
||||
(u8 *)texcube_bin);
|
||||
NE_ModelLoadStaticMesh(Cube, (u32 *)cube_bin);
|
||||
NE_ModelSetMaterial(Cube, Material2);
|
||||
|
||||
NE_ModelLoadStaticMesh(Cube2, (u32 *)cube_bin);
|
||||
NE_ModelSetMaterial(Cube2, Material2);
|
||||
#endif
|
||||
|
||||
NE_ModelScale(Cube2, 3, 3, 3);
|
||||
|
||||
NE_LightSet(0, NE_White, 0, -1, 0);
|
||||
|
||||
if (camera_swap)
|
||||
{
|
||||
NE_CameraSet(Camara2,
|
||||
-6, 6, -6,
|
||||
0, 0, 0,
|
||||
0, 1, 0);
|
||||
NE_CameraSet(Camara,
|
||||
-2, 2, -2,
|
||||
0, 0, 0,
|
||||
0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
NE_CameraSet(Camara,
|
||||
-6, 6, -6,
|
||||
0, 0, 0,
|
||||
0, 1, 0);
|
||||
NE_CameraSet(Camara2,
|
||||
-2, 2, -2,
|
||||
0, 0, 0,
|
||||
0, 1, 0);
|
||||
}
|
||||
|
||||
NE_SetConsoleColor(NE_Red);
|
||||
|
||||
// Clear screen and move cursor to the top
|
||||
printf("\x1b[2J");
|
||||
|
||||
printf("\x1b[1;1HTi-Ra-Nog 3D Test\n =================");
|
||||
printf("\x1b[4;1HR: Save Video (So Sloooow).");
|
||||
printf("\x1b[5;1HL: Save screenshot.");
|
||||
printf("\x1b[6;1HA: Move camera (Held Button).");
|
||||
printf("\x1b[7;1HB: Sine Effect.");
|
||||
printf("\x1b[8;1HX: Noise Effect.");
|
||||
printf("\x1b[9;1HY: Show/hide the text.");
|
||||
printf("\x1b[10;1HStart: Move mesh (on/off).");
|
||||
printf("\x1b[11;1HSelect: LCD Swap.");
|
||||
printf("\x1b[12;1HUP: Scene mode 1.");
|
||||
printf("\x1b[13;1HDown: Scene mode 2.");
|
||||
printf("\x1b[23;8HPowered By Nitro Engine");
|
||||
|
||||
for (int i = 0; i < NUM; i++)
|
||||
NE_ModelScale(Sphere[i], 0.5, 0.5, 0.5);
|
||||
|
||||
// Set start coordinates/rotation for models using random formules...
|
||||
for (int i = 0; i < MAX_NUM_BALLS; i++)
|
||||
{
|
||||
// Set the absolute initial speed
|
||||
Ball[i].vx = (float)(1 + ((float)(rand() % 10) / 10)) / 30;
|
||||
Ball[i].vy = (float)(1 + ((float)(rand() % 10) / 10)) / 30;
|
||||
Ball[i].vz = (float)(1 + ((float)(rand() % 10) / 10)) / 30;
|
||||
|
||||
// Randomly invert the speed
|
||||
if (rand() & 1)
|
||||
Ball[i].vx *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vy *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vz *= -1;
|
||||
}
|
||||
|
||||
// Set start coordinates/rotation for models using random formules
|
||||
for (int i = MAX_NUM_BALLS; i < NUM; i++)
|
||||
{
|
||||
// Set the absolute initial speed
|
||||
Ball[i].vx = (float)(1 + ((float)(rand() % 10) / 10)) / 1;
|
||||
Ball[i].vy = (float)(1 + ((float)(rand() % 10) / 10)) / 1;
|
||||
Ball[i].vz = (float)(1 + ((float)(rand() % 10) / 10)) / 1;
|
||||
|
||||
// Randomly invert the speed
|
||||
if (rand() & 1)
|
||||
Ball[i].vx *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vy *= -1;
|
||||
if (rand() & 1)
|
||||
Ball[i].vz *= -1;
|
||||
}
|
||||
|
||||
// Initialize some variables
|
||||
int fpscount = 0;
|
||||
int oldsec = 0;
|
||||
int seconds = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// Time Variables/Structs
|
||||
time_t unixTime = time(NULL);
|
||||
struct tm* timeStruct = gmtime((const time_t *)&unixTime);
|
||||
seconds = timeStruct->tm_sec;
|
||||
|
||||
// Has the second changed?
|
||||
if (seconds != oldsec)
|
||||
{
|
||||
oldsec = seconds; // old second = new second
|
||||
printf("\x1b[1;24HFPS: %d", fpscount);
|
||||
fpscount = 0; // Reset FPS count for next second
|
||||
}
|
||||
|
||||
scanKeys();
|
||||
uint32 keysd = keysDown();
|
||||
uint32 keysh = keysHeld();
|
||||
|
||||
// Set rotation for every sphere
|
||||
for (int i = 0; i < NUM; i++)
|
||||
NE_ModelRotate(Sphere[i], 25 / i, -25 / i, 25 / i);
|
||||
|
||||
// Calculate the model position for every model based on its
|
||||
// current position and speed
|
||||
for (int i = 0; i < SCENE2_BALLS; i++)
|
||||
{
|
||||
// If the ball crashes with one of the faces of the cube
|
||||
// invert the speed of the corresponding axis.
|
||||
if ((Ball[i].x >= 2.5) || (Ball[i].x <= -2.5))
|
||||
Ball[i].vx *= -1;
|
||||
if ((Ball[i].y >= 2.5) || (Ball[i].y <= -2.5))
|
||||
Ball[i].vy *= -1;
|
||||
if ((Ball[i].z >= 2.5) || (Ball[i].z <= -2.5))
|
||||
Ball[i].vz *= -1;
|
||||
|
||||
// Add speed to the position to calculate the new
|
||||
// position
|
||||
Ball[i].x += Ball[i].vx;
|
||||
Ball[i].y += Ball[i].vy;
|
||||
Ball[i].z += Ball[i].vz;
|
||||
|
||||
// Update position
|
||||
NE_ModelSetCoord(Sphere[i], Ball[i].x, Ball[i].y, Ball[i].z);
|
||||
}
|
||||
|
||||
// Calculate the model position for every model based on its
|
||||
// current position and speed
|
||||
for (int i = SCENE2_BALLS; i < NUM; i++)
|
||||
{
|
||||
// If the ball crashes with one of the faces of the cube
|
||||
// invert the speed of the corresponding axis.
|
||||
if ((Ball[i].x >= 9.5) || (Ball[i].x <= -9.5))
|
||||
Ball[i].vx *= -1;
|
||||
if ((Ball[i].y >= 9.5) || (Ball[i].y <= -9.5))
|
||||
Ball[i].vy *= -1;
|
||||
if ((Ball[i].z >= 9.5) || (Ball[i].z <= -9.5))
|
||||
Ball[i].vz *= -1;
|
||||
|
||||
// Add speed to the position to calculate the new
|
||||
// position
|
||||
Ball[i].x += Ball[i].vx;
|
||||
Ball[i].y += Ball[i].vy;
|
||||
Ball[i].z += Ball[i].vz;
|
||||
|
||||
// Update position
|
||||
NE_ModelSetCoord(Sphere[i], Ball[i].x, Ball[i].y, Ball[i].z);
|
||||
}
|
||||
|
||||
if (keysd & KEY_UP)
|
||||
camera_swap = false;
|
||||
|
||||
if (keysd & KEY_DOWN)
|
||||
camera_swap = true;
|
||||
|
||||
if (keysh & KEY_A)
|
||||
{
|
||||
posx += SUMX;
|
||||
posy += SUMY;
|
||||
posz += SUMZ;
|
||||
|
||||
posx2 += SUMX;
|
||||
posy2 += SUMY;
|
||||
posz2 += SUMZ;
|
||||
}
|
||||
|
||||
NE_ProcessDual(Draw3DScene, Draw3DScene2);
|
||||
fpscount++;
|
||||
swiWaitForVBlank();
|
||||
|
||||
// If SELECT is pressed swap top and bottom screens
|
||||
if (keysd & KEY_SELECT)
|
||||
lcdSwap();
|
||||
|
||||
if (keysd & KEY_L)
|
||||
{
|
||||
// Generate file name
|
||||
sprintf(file, "screen/screenshot_%04d.bmp", sc);
|
||||
// Save the screenshot
|
||||
NE_ScreenshotBMP(file);
|
||||
// Increase the Screenshot number
|
||||
sc++;
|
||||
// Wait for next frame (this is necessary for not making
|
||||
// artifacts in the next screenshot)
|
||||
NE_WaitForVBL(0);
|
||||
}
|
||||
|
||||
if (keysd & KEY_START)
|
||||
{
|
||||
if (!auto_rotate)
|
||||
auto_rotate = true;
|
||||
else
|
||||
auto_rotate = false;
|
||||
}
|
||||
|
||||
if (auto_rotate)
|
||||
{
|
||||
posx += SUMX;
|
||||
posy += SUMY;
|
||||
posz += SUMZ;
|
||||
|
||||
posx2 += SUMX;
|
||||
posy2 += SUMY;
|
||||
posz2 += SUMZ;
|
||||
}
|
||||
|
||||
if (keysd & KEY_R)
|
||||
{
|
||||
if (!recording)
|
||||
recording = true;
|
||||
else
|
||||
recording = false;
|
||||
}
|
||||
|
||||
if (recording)
|
||||
{
|
||||
// Generate file name
|
||||
sprintf(file,"video/vid/video_%04d.bmp",nc);
|
||||
// Save the screenshot
|
||||
NE_ScreenshotBMP(file);
|
||||
// Increase the Screenshot number
|
||||
nc++;
|
||||
// Wait for next frame (this is needed for not making
|
||||
// artifacs in the next screenshot)
|
||||
NE_WaitForVBL(0);
|
||||
}
|
||||
|
||||
if (keysd & KEY_Y)
|
||||
{
|
||||
if (!hide_text)
|
||||
{
|
||||
hide_text = true;
|
||||
|
||||
// Clear screen and move cursor to the top
|
||||
printf("\x1b[2J");
|
||||
|
||||
printf("\x1b[1;1H"
|
||||
"Ti-Ra-Nog 3D Test\n"
|
||||
" =================");
|
||||
printf("\x1b[23;8HPowered By Nitro Engine");
|
||||
}
|
||||
else
|
||||
{
|
||||
hide_text = false;
|
||||
printf("\x1b[4;1HR: Save Video (So Sloooow).");
|
||||
printf("\x1b[5;1HL: Save screenshot.");
|
||||
printf("\x1b[6;1HA: Move camera (Held Button).");
|
||||
printf("\x1b[7;1HB: Sine Effect.");
|
||||
printf("\x1b[8;1HX: Noise Effect.");
|
||||
printf("\x1b[9;1HY: Show/hide the text.");
|
||||
printf("\x1b[10;1HStart: Move mesh (on/off).");
|
||||
printf("\x1b[11;1HSelect: LCD Swap.");
|
||||
printf("\x1b[12;1HUP: Scene mode 1.");
|
||||
printf("\x1b[13;1HDown: Scene mode 2.");
|
||||
}
|
||||
}
|
||||
|
||||
// If B is pressed use the sine effect. Stop if pressed again
|
||||
if (keysd & KEY_B)
|
||||
{
|
||||
if (!sine_effect)
|
||||
{
|
||||
sine_effect = true;
|
||||
NE_SpecialEffectSet(NE_SINE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sine_effect = false;
|
||||
NE_SpecialEffectSet(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (keysd & KEY_X)
|
||||
{
|
||||
if (!noise_effect)
|
||||
{
|
||||
noise_effect = true;
|
||||
NE_SpecialEffectSet(NE_NOISE);
|
||||
}
|
||||
else
|
||||
{
|
||||
noise_effect = false;
|
||||
NE_SpecialEffectSet(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
irqEnable(IRQ_HBLANK);
|
||||
irqSet(IRQ_VBLANK, NE_VBLFunc);
|
||||
irqSet(IRQ_HBLANK, NE_HBLFunc);
|
||||
|
||||
fatInitDefault();
|
||||
|
||||
NE_InitDual3D();
|
||||
NE_InitConsole();
|
||||
|
||||
NE_WaitForVBL(0);
|
||||
|
||||
dual();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user