I tried adding another sprite and im running out of vram, should i optimize my background more?Do you ask how I manage a project? I'm using code::blocks IDE. I used this tutorial:
https://whatroidoes.wordpress.com/2...itpro-with-codeblocks-and-debug-with-insight/
However if project grows a bit it likes to crash, but that don't bother me much.
Maybe I'm using less stable version. Some scripts can share same variables so sometimes you need to add "extern" to be declared as something global to both (however is better to avoid if possible) or include the file that defines some functions to the other one that is using them.
View attachment 388259
How does MKDS and other games have the big side bars for like multiplayer and stuffhere are possible sprite sizes supported by 2D engine
https://libnds.devkitpro.org/sprite_8h.html#a1b3e231e628b18808e49a2f94c96b1ea
I tried to place anyway a redcar from examples, I thought it may create a virtual ones, but nothing shows up, so I guess big sprites belongs to 3dsprites library of nflib, seems as completely different things.
Also how do you refrence scripts inside of other scripts because your last explanation was very vague, i was asking how to actually trigger another script from inside another one. kind of like a chainSometimes games use one of three background layers (one layer is background, second is midleground for paralax effect or game characters, and on top things like status bar or text window, etc. belongs to foreground) and sometimes big side bars are combined from many sprites. (if we talk about 2D engine) On that many sprites in example can be printed text font in text window. (in fact they are used as another one layer). There wasn't any improvement in sprite size comparing to previous generation GBA, but that's how it is. Backgrounds as independent instances are acting like sprites for each other, also you can use one of background as a big sprite.
C:/STIDS/source/main.c: In function 'main':
C:/STIDS/source/main.c:161:13: warning: implicit declaration of function 'MultiplayerMatch' [-Wimplicit-function-declaration]
161 | MultiplayerMatch();
| ^~~~~~~~~~~~~~~~
multiplayermatch.c
linking STIDS.elf
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.1.0/../../../../arm-none-eabi/bin/ld.exe: multiplayermatch.o: in function `Vblank':
C:/STIDS/source/multiplayermatch.c:19: multiple definition of `Vblank'; main.o:C:/STIDS/source/main.c:40: first defined here
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.1.0/../../../../arm-none-eabi/bin/ld.exe: multiplayermatch.o: in function `main':
C:/STIDS/source/multiplayermatch.c:24: multiple definition of `main'; main.o:C:/STIDS/source/main.c:44: first defined here
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.1.0/../../../../arm-none-eabi/bin/ld.exe: multiplayermatch.o:C:/STIDS/source/multiplayermatch.c:14: multiple definition of `frame'; main.o:C:/STIDS/source/main.c:8: first defined here
C:/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.1.0/../../../../arm-none-eabi/bin/ld.exe: main.o: in function `main':
C:/STIDS/source/main.c:161: undefined reference to `MultiplayerMatch'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/c/STIDS/Makefile:56: /c/STIDS/STIDS.elf] Error 1
make: *** [Makefile:164: build] Error 2
#include <nds.h>
#include <maxmod9.h>
#include <nf_lib.h>
#include <stdio.h>
#include "soundbank.h"
#include "soundbank_bin.h"
volatile int frame = 0;
void Initialize()
{
NF_SetRootFolder("NITROFS");
NF_Set2D(0, 0);
NF_Set2D(1, 0);
NF_InitSpriteSys(1);
NF_SpriteOamSet(1);
NF_InitTiledBgBuffers();
NF_InitTiledBgSys(0);
NF_InitTiledBgSys(1);
NF_InitSpriteBuffers();
NF_InitSpriteSys(0);
NF_LoadSpriteGfx("ui/birdekek", 0, 64, 64);
NF_LoadSpritePal("ui/birdekek", 0);
NF_LoadTiledBg("maps/mainscreen", "main_bg", 256, 256);
NF_LoadTiledBg("maps/bottomscreen", "bottom_bg", 256, 256);
NF_LoadTiledBg("maps/msc", "bottom_select", 256, 256);
NF_LoadTiledBg("maps/mscoff", "bottom_select_two", 256, 256);
NF_LoadTiledBg("maps/mscon", "bottom_select_one", 256, 256);
NF_VramSpriteGfx(0, 0, 0, false);
NF_VramSpritePal(0, 0, 0);
}
void Vblank()
{
frame++;
}
int main(int argc, char** argv)
{
mmInitDefaultMem((mm_addr)soundbank_bin);
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
Initialize();
consoleClear();
NF_CreateSprite(0, 0, 0, 0, 96, 32);
mmLoadEffect(SFX_BIRDEKEK);
mmLoadEffect(SFX_SELECT);
mmEffect(SFX_BIRDEKEK);
for (int i = 0; i < 120; i++)
{
NF_SpriteOamSet(0);
swiWaitForVBlank();
oamUpdate(&oamMain);
}
setBrightness(0, 0);
NF_DeleteSprite(0, 0);
mmLoad(MOD_MAINTHEME);
mmStart(MOD_MAINTHEME, MM_PLAY_LOOP);
NF_CreateTiledBg(0, 3, "main_bg");
NF_CreateTiledBg(1, 3, "bottom_bg");
NF_CreateTiledBg(1, 1, "bottom_select");
u8 r, g, b;
s16 cR, cG, cB;
u8 speed = 0;
u16 n = 0;
int selection = 0;
int keys;
NF_FreeSpriteGfx(0, 0);
NF_UnloadSpritePal(0);
speed = 0;
for (int i = 0; i < 8; i++) { // Loop from 0 to 255 for smooth transition
for (n = 0; n < 256; n++) {
NF_BgGetPalColor(0, 3, n, &r, &g, &b);
cR = r;
cG = g;
cB = b;
cR += 25;
cG += 25;
cB += 25;
// Decrease the color components
cR--;
if (cR < 0) cR = 0;
cG--;
if (cG < 0) cG = 0;
cB--;
if (cB < 0) cB = 0;
// Update palette color
NF_BgEditPalColor(0, 3, n, cR, cG, cB);
}
NF_BgUpdatePalette(0, 3); // Update the palette
speed++;
if (speed > 1) { // Adjust this value to control the speed of the transition
speed = 0;
}
NF_SpriteOamSet(0);
NF_SpriteOamSet(1);
swiWaitForVBlank(); // Wait for vertical blank
oamUpdate(&oamMain);
oamUpdate(&oamSub);
}
while (1)
{
scanKeys();
keys = keysDown();
if (keys & KEY_DOWN) {
if (selection < 2) {
selection++;
mmEffect(SFX_SELECT);
}
}
if (keys & KEY_UP) {
if (selection > 1) {
selection--;
mmEffect(SFX_SELECT);
}
}
if (selection == 1) {
NF_DeleteTiledBg(1, 1);
NF_CreateTiledBg(1, 1, "bottom_select_one");
}
if (selection == 2) {
NF_DeleteTiledBg(1, 1);
NF_CreateTiledBg(1, 1, "bottom_select_two");
}
if(keys & KEY_A & (selection == 1)) {
MultiplayerMatch();
return 0;
}
swiWaitForVBlank();
}
return 0;
}
#include <nds.h>
#include <stdio.h>
volatile int frame = 0;
//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
frame++;
}
//---------------------------------------------------------------------------------
int main(void) {
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
iprintf("Hee-eee");
while (1) {
swiWaitForVBlank();
}
return 0;
}
#ifndef __MULTIPLAYERMENU_H__
#define __MULTIPLAYERMENU_H__
void MultiplayerMatch();
#endif // __MULTIPLAYERMENU_H__
if(keys & KEY_A & (selection == 1)) {
MultiplayerMatch();
return 0;
}
ok, i fixed those issues, but the games just crashing nowlet's say better solution here will be function like void multiplayer() instead of main() (as this one exsists already) doing some things like main loop is doing.
#include <nds.h>
#include <stdio.h>
void MultiplayerMatch() {
iprintf("Printed\n");
}
#include <nds.h>
#include <maxmod9.h>
#include <nf_lib.h>
#include <stdio.h>
#include "soundbank.h"
#include "multiplayermenu.h"
#include "soundbank_bin.h"
volatile int frame = 0;
void Initialize()
{
NF_SetRootFolder("NITROFS");
NF_Set2D(0, 0);
NF_Set2D(1, 0);
NF_InitSpriteSys(1);
NF_SpriteOamSet(1);
NF_InitTiledBgBuffers();
NF_InitTiledBgSys(0);
NF_InitTiledBgSys(1);
NF_InitSpriteBuffers();
NF_InitSpriteSys(0);
NF_LoadSpriteGfx("ui/birdekek", 0, 64, 64);
NF_LoadSpritePal("ui/birdekek", 0);
NF_LoadTiledBg("maps/mainscreen", "main_bg", 256, 256);
NF_LoadTiledBg("maps/bottomscreen", "bottom_bg", 256, 256);
NF_LoadTiledBg("maps/msc", "bottom_select", 256, 256);
NF_LoadTiledBg("maps/mscoff", "bottom_select_two", 256, 256);
NF_LoadTiledBg("maps/mscon", "bottom_select_one", 256, 256);
NF_VramSpriteGfx(0, 0, 0, false);
NF_VramSpritePal(0, 0, 0);
}
void Vblank()
{
frame++;
}
int main(int argc, char** argv)
{
mmInitDefaultMem((mm_addr)soundbank_bin);
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
Initialize();
consoleClear();
NF_CreateSprite(0, 0, 0, 0, 96, 32);
mmLoadEffect(SFX_BIRDEKEK);
mmLoadEffect(SFX_SELECT);
mmEffect(SFX_BIRDEKEK);
for (int i = 0; i < 120; i++)
{
NF_SpriteOamSet(0);
swiWaitForVBlank();
oamUpdate(&oamMain);
}
setBrightness(0, 0);
NF_DeleteSprite(0, 0);
mmLoad(MOD_MAINTHEME);
mmStart(MOD_MAINTHEME, MM_PLAY_LOOP);
NF_CreateTiledBg(0, 3, "main_bg");
NF_CreateTiledBg(1, 3, "bottom_bg");
NF_CreateTiledBg(1, 1, "bottom_select");
u8 r, g, b;
s16 cR, cG, cB;
u8 speed = 0;
u16 n = 0;
int selection = 0;
int keys;
NF_FreeSpriteGfx(0, 0);
NF_UnloadSpritePal(0);
speed = 0;
for (int i = 0; i < 8; i++) { // Loop from 0 to 255 for smooth transition
for (n = 0; n < 256; n++) {
NF_BgGetPalColor(0, 3, n, &r, &g, &b);
cR = r;
cG = g;
cB = b;
cR += 25;
cG += 25;
cB += 25;
// Decrease the color components
cR--;
if (cR < 0) cR = 0;
cG--;
if (cG < 0) cG = 0;
cB--;
if (cB < 0) cB = 0;
// Update palette color
NF_BgEditPalColor(0, 3, n, cR, cG, cB);
}
NF_BgUpdatePalette(0, 3); // Update the palette
speed++;
if (speed > 1) { // Adjust this value to control the speed of the transition
speed = 0;
}
NF_SpriteOamSet(0);
NF_SpriteOamSet(1);
swiWaitForVBlank(); // Wait for vertical blank
oamUpdate(&oamMain);
oamUpdate(&oamSub);
}
while (1)
{
scanKeys();
keys = keysDown();
if (keys & KEY_DOWN) {
if (selection < 2) {
selection++;
mmEffect(SFX_SELECT);
}
}
if (keys & KEY_UP) {
if (selection > 1) {
selection--;
mmEffect(SFX_SELECT);
}
}
if (selection == 1) {
NF_DeleteTiledBg(1, 1);
NF_CreateTiledBg(1, 1, "bottom_select_one");
}
if (selection == 2) {
NF_DeleteTiledBg(1, 1);
NF_CreateTiledBg(1, 1, "bottom_select_two");
}
if(keys & KEY_A & (selection == 1)) {
Multiplayer();
return 0;
}
swiWaitForVBlank();
}
return 0;
}
void Multiplayer()
{
MultiplayerMatch();
}
#include <nds.h>
#include <stdio.h>
void MultiplayerMatch();
#include "multiplayer.h"
void MultiplayerMatch() {
iprintf("Printed\n");
}
did all of that but its still crashingNot sure what kind of errors but it is required to add every definitions before main() function or at least declarations.
so void Multiplayer() should be moved up.
also multiplayer.h:
multiplayer.cpp:C++:#include <nds.h> #include <stdio.h> void MultiplayerMatch();
C++:#include "multiplayer.h" void MultiplayerMatch() { iprintf("Printed\n"); }