badge lookin' good

This commit is contained in:
Kit Swinton 2024-02-23 18:01:35 +11:00
parent aab92e09bc
commit 0b84e4d121
22 changed files with 3096 additions and 3024 deletions

View File

@ -51,7 +51,7 @@ 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 -lnflib
LIBS := -lNE -lnflib
# automatigically add libraries for NitroFS
ifneq ($(strip $(NITRO)),)
@ -62,6 +62,8 @@ ifneq ($(strip $(AUDIO)),)
LIBS := -lmm9 $(LIBS)
endif
LIBS := $(LIBS) -lnds9
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib

View File

@ -40,3 +40,20 @@ for file in *.bin; do
done
mv *.img nitrofiles/bmp
# Badge Graphic: bg tile system
mkdir nitrofiles/bg
$GRIT \
$ASSETS/badge_01.jpg -ftb -fh! -gTFF00FF -gt -gB8 -mR8 -mLs
for file in *.bin; do
mv -- "$file" "${file%.bin}"
done
mv *.pal *.img *.map nitrofiles/bg
# Copy fonts
mkdir nitrofiles/fnt
cp $ASSETS/fonts/* nitrofiles/fnt

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 24 KiB

BIN
assets/badge_02.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because it is too large Load Diff

BIN
assets/fonts/default.fnt Normal file

Binary file not shown.

BIN
assets/fonts/default.pal Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 50 KiB

BIN
nitrofiles/bg/badge_01.img Normal file

Binary file not shown.

BIN
nitrofiles/bg/badge_01.map Normal file

Binary file not shown.

BIN
nitrofiles/bg/badge_01.pal Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
nitrofiles/fnt/default.fnt Normal file

Binary file not shown.

BIN
nitrofiles/fnt/default.pal Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -8,9 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <nds.h>
#include <filesystem.h>
#include <nds.h>
#include <NEMain.h>
#include <nf_lib.h>
@ -30,32 +29,19 @@ void Draw3DScene(void)
void WaitLoop(void)
{
while(1)
{
swiWaitForVBlank();
scanKeys();
if (keysHeld() & KEY_START)
return;
}
}
int main(void)
void LoadAndSetupGraphics3D(void)
{
irqEnable(IRQ_HBLANK);
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_HBLANK, NE_HBLFunc);
// When using nflib for the 2D sub screen engine, banks C and H are used for
// backgrounds and banks D and I are used for sprites. Nitro Engine only
// uses bank E for palettes, so the only thing we need to do is to tell
// Nitro Engine to only use banks A and B and leave C and D unused.
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();
if (!nitroFSInit(NULL))
{
printf("nitroFSInit failed.\nPress START to exit");
WaitLoop();
return 0;
}
// Allocate space for objects...
Model = NE_ModelCreate(NE_Animated);
@ -63,70 +49,137 @@ int main(void)
Material = NE_MaterialCreate();
Animation = NE_AnimationCreate();
// Setup camera
NE_CameraSet(Camera,
3, 3, -1,
0, 2, 0,
0, 1, 0);
// Load assets form the filesystem
if (NE_ModelLoadDSMFAT(Model, "chibi_kp.dsm") == 0)
{
consoleDemoInit();
printf("Couldn't load model...");
WaitLoop();
return 0;
}
if (NE_AnimationLoadFAT(Animation, "chibi_kp_idle.dsa") == 0)
{
consoleDemoInit();
printf("Couldn't load animation...");
WaitLoop();
return 0;
}
if (NE_MaterialTexLoadFAT(Material, NE_A1RGB5, 256, 256, NE_TEXGEN_TEXCOORD,
"texture.img.bin") == 0)
{
consoleDemoInit();
printf("Couldn't load texture...");
WaitLoop();
return 0;
}
// Assign material to the model
NE_ModelSetMaterial(Model, Material);
// Assign animation to the model and start it
NE_ModelSetAnimation(Model, Animation);
NE_ModelAnimStart(Model, NE_ANIM_LOOP, floattof32(0.1));
// setup light
NE_LightSet(0, NE_White, 0, -1, -1);
NE_ClearColorSet(NE_Black, 31, 63);
// setup background color
NE_ClearColorSet(RGB15(10, 0, 17), 31, 63);
printf("\x1b[0;0HPad: Rotate\nSTART: Exit");
// Setup camera
NE_CameraSet(Camera,
6, 1.5, -1,
0, 0, 0,
0, 0, -1);
NE_SetFov(30);
}
void LoadAndSetupGraphics2D(void)
{
// Initialize sub 2D engine
NF_Set2D(1, 0);
// Initialize tiled backgrounds and text systems for the 2D sub engine
// (using VRAM C & D)
NF_InitTiledBgBuffers();
NF_InitTiledBgSys(1);
NF_InitTextSys(1);
// load assets from filesystem to RAM
NF_LoadTiledBg("bg/badge_01", "capa_0", 2048, 256);
NF_LoadTextFont("fnt/default", "normal", 256, 256, 0);
// Create tiled background
NF_CreateTiledBg(1, 1, "capa_0");
// Create text layer
NF_CreateTextLayer(1, 0, 0, "normal");
}
int main(void)
{
// Initialize nitrof before doing anything else
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("Starting nitroFS...\n");
if(!nitroFSInit(NULL))
{
printf("Failed to start nitroFS\n");
printf("Press START to exit\n");
while (1)
{
NE_WaitForVBL(NE_UPDATE_ANIMATIONS);
{
swiWaitForVBlank();
scanKeys();
if (keysHeld() & KEY_START)
return -1;
}
}
swiWaitForVBlank();
// Set the root folder to the nitroFS filesystem
NF_SetRootFolder("NITROFS");
//setup interrupt
irqEnable(IRQ_HBLANK);
irqSet(IRQ_VBLANK, NE_VBLFunc);
irqSet(IRQ_HBLANK, NE_HBLFunc);
// load and setup graphics
LoadAndSetupGraphics3D();
LoadAndSetupGraphics2D();
// print instructions:
//NF_WriteText(1, 0, 1, 1, "PAD: Rotate Model");
//NF_WriteText(1, 0, 1, 2, "START: Exit");
//NF_UpdateTextLayers();
while (1)
{
NE_WaitForVBL(NE_UPDATE_ANIMATIONS);
//rotate model:
NE_ModelRotate(Model, 0, 1, 0);
scanKeys();
uint32_t keys = keysHeld();
if (keys & KEY_START)
break;
if (keys & KEY_RIGHT)
NE_ModelRotate(Model, 0, 2, 0);
if (keys & KEY_LEFT)
NE_ModelRotate(Model, 0, -2, 0);
if (keys & KEY_UP)
NE_ModelRotate(Model, 0, 0, 2);
if (keys & KEY_DOWN)
NE_ModelRotate(Model, 0, 0, -2);
scanKeys();
uint32_t keys = keysHeld();
// Draw scene...
NE_Process(Draw3DScene);
}
if (keys & KEY_START)
break;
if (keys & KEY_RIGHT)
NE_ModelRotate(Model, 0, 2, 0);
if (keys & KEY_LEFT)
NE_ModelRotate(Model, 0, -4, 0);
if (keys & KEY_UP)
NE_ModelRotate(Model, 0, 0, 2);
if (keys & KEY_DOWN)
NE_ModelRotate(Model, 0, 0, -2);
// Draw scene...
NE_Process(Draw3DScene);
}
return 0;
return 0;
}