"DevkitPro -> libnds" or "how to create my own game?".

AKOTb

Member
OP
Newcomer
Joined
May 10, 2022
Messages
14
Trophies
0
Age
37
Location
Home
XP
48
Country
Russia

NotImpLife​

The problem is that I have a 32 bit operating system installed on my laptop. And I don't really want to update it to 64 bit yet. Because of this, I do not install the latest version of DevkitPro. I'll try a later version of devkit pro with support for 32-bit systems. Thank you!
 
  • Like
Reactions: NotImpLife

NotImpLife

Active Member
Newcomer
Joined
Mar 9, 2021
Messages
40
Trophies
0
Website
github.com
XP
482
Country
Romania

NotImpLife​

The problem is that I have a 32 bit operating system installed on my laptop. And I don't really want to update it to 64 bit yet. Because of this, I do not install the latest version of DevkitPro. I'll try a later version of devkit pro with support for 32-bit systems. Thank you!
I see. Sorry I couldn't help more. There would be also an option to install a linux virtual machine and run devkitPro from there "natively", but I suppose it's a bit too far-fethced. Setting the environment sometimes might prove to be the greatest struggle in programming. Please keep us updated and hope you solve the problem as soon as possible. ^ _ ^
 

AKOTb

Member
OP
Newcomer
Joined
May 10, 2022
Messages
14
Trophies
0
Age
37
Location
Home
XP
48
Country
Russia
Friends, I have made some progress in this matter. It turns out that if you run the main msys.bat file from the msys folder, and run the command in it,
Code:
cd C:\devkitPro\examples\nds\hello_world
make -f Makefile
then the project builds successfully!

1652273645931.png



The resulting file runs successfully in the emulator. My experiments have shown that in order to set up the transfer from the default makefile not to make.exe, but to msys.bat, I need to change one line in the makefile that is in the project.

1652273900811.png


Code:
@[ -d $@ ] || mkdir -p $@
    @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

But I don't have enough experience how to change this line to make it work.
Maybe you guys can tell me how to change this line?
 

AKOTb

Member
OP
Newcomer
Joined
May 10, 2022
Messages
14
Trophies
0
Age
37
Location
Home
XP
48
Country
Russia
Friends, I do not stop experimenting with this library, and here is the latest news.
It is convenient for me to develop on my old laptop, but it does not support 64-bit systems, and I prepare the development environment specifically for a weak machine.
You need to install devkitProUpdater-1.6.0.exe. But after launching this program, you will find that it can no longer download anything from the Internet (and without it, it is useless). However, we can trick her a little. To do this, we will download from the Internet everything that it had to download, and put them together in one folder. I ran the installer every time I got the message "can't download file 'filename'" and looked for that file.
Thanks to the wonderful resource "wii.leseratte10.de/devkitPro/" you can find almost any file from the devkitPro build that previously existed. And from there we need to collect the following set:
default_arm7-0.7.3.tar.bz2
dswifi-0.4.2.tar.bz2
libfat-nds-1.1.2.tar.bz2
libfilesystem-0.9.13.tar.bz2
libnds-1.7.1.tar.bz2
maxmod-nds-1.0.10.tar.bz2
nds-examples-20170915.tar.bz2
devkitARM_r47-win32.exe
devkitProUpdater-1.6.0.exe
msys-1.0.17-1.exe
All these files are in this resource, I downloaded them and can post them here on the forum if I understand how to place an archive of about 40mb here :-).

1652351759239.png


Next, we put all these files in one folder and run the installation of devkitProUpdater-1.6.0.exe, where we should select the following checkboxes:
1652351880001.png

press no

1652351954948.png

keep files

and select checkboxes: devkitARM inside of it -> libnds, libfat nds, dswifi, maxmod, default arm 7, libfilesystem, nds examaples. So you should get 9 ticks.

The installation will pass without errors and upon completion, we should check (or set) the environment variables in Windows. Do as I showed in the screenshot, this is important.

1652354319323.png


That's it, now we go to the folder with examples, find our example Hello_world and create a file MAKEF.bat in the folder with the example, you can use this file to build and other projects in the future. Inside the file we write: make -f Makefile.
1652354374245.png

When you run this file, our project will be assembled and we will get our self-written game.
I hope my experience is useful to you. Now I can start writing my game. Thanks to NotImpLife, I don't even have to write anything, he already wrote everything in message #7. Thank you friend!). In the next post I will try to describe how the launch of my first game went.
 

AKOTb

Member
OP
Newcomer
Joined
May 10, 2022
Messages
14
Trophies
0
Age
37
Location
Home
XP
48
Country
Russia
And again I'm at an impasse. I try to follow the instructions posted by NotImpLife in post #7. I found a folder where i can convert images

1652383536340.png


I put my image in gfx folder.

1652383766896.png


Then I run my bat file, and a new build folder appears, in which the required files are located.

1652383879649.png


And also two files with the game appear (but sometimes they do not appear, I still do not understand what it depends on).
1652384012618.png


If I run the game in the emulator, it starts and shows my image.

1652383978144.png


And now I'm finalizing my hello_world, and inserting an image there:

C++:
#include <nds.h>
#include "cat.h"
#include <stdio.h>

int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);

volatile int frame = 0;

//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
    frame++;
}
    
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
    touchPosition touchXY;

    irqSet(IRQ_VBLANK, Vblank);

    consoleDemoInit();

    iprintf("      Hello DS dev'rs\n");
    iprintf("     \x1b[32mwww.devkitpro.org\n");
    iprintf("   \x1b[32;1mwww.drunkencoders.com\x1b[39m");
 
    while(1) {
    
        swiWaitForVBlank();
        dmaCopy(catBitmap, bgGetGfxPtr(bg3), 256*192);
        dmaCopy(catPal, BG_PALETTE, 256*sizeof(u16));
        scanKeys();
        int keys = keysDown();
        if (keys & KEY_START) break;

        touchRead(&touchXY);

        // print at using ansi escape sequence \x1b[line;columnH
        iprintf("\x1b[10;0HFrame = %d",frame);
        iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px);
        iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py);       
    
    }

    return 0;
}

1652384355533.png


And when I try to build the project, the system gives the following error:

1652384252667.png


What am I doing wrong?
 
Last edited by AKOTb,

NotImpLife

Active Member
Newcomer
Joined
Mar 9, 2021
Messages
40
Trophies
0
Website
github.com
XP
482
Country
Romania
What am I doing wrong?
The hello_world Makefile does not have any option for graphics conversion. Maybe copy-pasting the Makefile from 256colors example into the hello_world example will work for you.

You roughly need these lines in your makefile in order to make it compile graphics:
Makefile:
BUILD        :=    build
SOURCES        :=    source
DATA        := 
INCLUDES    :=    include
GRAPHICS    :=    gfx # name of the folder with images


export VPATH    :=    $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
                    $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
                    $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))


BINFILES    :=    $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

PNGFILES    :=    $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))



#---------------------------------------------------------------------------------
%.s %.h    : %.png %.grit
#---------------------------------------------------------------------------------
    grit $< -fts -o$*
But the safest is to get an already working makefile and just adjusting the GRAPHICS directory.
 
  • Like
Reactions: AKOTb

Deleted member 591971

Well-Known Member
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
ok i see that you have problably already fixed your issue but yeah.
you want to use something like NFlib/libGL2D, it is easier to use than libnds.

To install devkitpro on 32 bit systems you need to install the latest msys2 32 bit release (32 bit got discontinued), find a way to somehow get pacman to install the dkp packages (https://devkitpro.org/wiki/devkitPro_pacman) and put in the enviroment variables needed for compiling.

now if you still want to use libnds for some reason (i am not going to put code) you need to configure grit, the makefile and on the main.c file dmaCopy the bitmap and the Palette, if you are a begineer then you problably have no idea of what i am saying. Basically just copy paste the Makefile from the 256_color_bmp example, put your graphics on the gfx folder and create a file with the same name as the image with the .grit extension, just put in the flags needed or just copypaste the content from the .grit file of the example. Put in the source from the 256_color_bmp example and then you can call it a day.
 
  • Like
Reactions: AKOTb

Deleted member 591971

Well-Known Member
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
I see. Sorry I couldn't help more. There would be also an option to install a linux virtual machine and run devkitPro from there "natively", but I suppose it's a bit too far-fethced. Setting the environment sometimes might prove to be the greatest struggle in programming. Please keep us updated and hope you solve the problem as soon as possible. ^ _ ^
linux is only able to run on 64 bit system tho
 

AKOTb

Member
OP
Newcomer
Joined
May 10, 2022
Messages
14
Trophies
0
Age
37
Location
Home
XP
48
Country
Russia
Friends, I have a problem again, and I'm here again.
It would seem that this is the simplest game, in any programming language it takes 15 minutes to do, but not here. I wondered how to display text in the game in another language. The Devkitpro library offers an interesting solution, to draw a font in the form of a picture, which is a column filled with characters.
1652681770860.png

Next, the built-in library will cut the picture into characters and display them on the screen. But the catch is that I will have to type this text in English letters. A program written in this way is difficult to read. If I don't find another solution, then I'll do it,
1652681931884.png

but I decided to write here first.
Perhaps there is some way to edit the library files to use a different font, so that I can directly insert text in a different font into iprintf("here") and display it later on the screen? Do you have any ideas?
 

Deleted member 591971

Well-Known Member
Member
Joined
Apr 10, 2022
Messages
216
Trophies
0
XP
922
Friends, I have a problem again, and I'm here again.
It would seem that this is the simplest game, in any programming language it takes 15 minutes to do, but not here. I wondered how to display text in the game in another language. The Devkitpro library offers an interesting solution, to draw a font in the form of a picture, which is a column filled with characters.
View attachment 310179
Next, the built-in library will cut the picture into characters and display them on the screen. But the catch is that I will have to type this text in English letters. A program written in this way is difficult to read. If I don't find another solution, then I'll do it,
View attachment 310180
but I decided to write here first.
Perhaps there is some way to edit the library files to use a different font, so that I can directly insert text in a different font into iprintf("here") and display it later on the screen? Do you have any ideas?
take a look at this libnds example https://github.com/devkitPro/nds-examples/blob/master/Graphics/Printing/custom_font/source/main.c

I tried it with a bg but it gave me corrupted graphics, i just do not have a brain
 

ivodesmedt

Member
Newcomer
Joined
Aug 28, 2022
Messages
7
Trophies
0
Age
24
Location
Belgium
XP
43
Country
Belgium
I am having trouble with perspective in libnds. If this is not the right place to ask this type of question, please tell me.
What I am trying to do is make something like a third person game. Basically a character that moves and a camera that moves around the player but is always at a constant distance from the character.
Thus far, I have two cubes (one is the moveable character, the other is for perspective) and every frame I am displaying the distance from the camera to the character on the lower screen. It is mostly constant, but it does not seem that way when the character cube moves.
Also, when an object is placed beyond z = 7.5 or behind z = -7.5 , it appears behind (respectiveley in front of) the camera. Only I have set the clipping distance to 30. This is as if the world ended there, so the engine just renders the object on the other side of the 'world'.
Has anyone had similar experiences or can anyone help? I have included the .nds-file as well as the source code (with Dutch commentary, sorry)
Thanks in advance

Edit: I forgot to mention you can move the cube with the arrows and change the perspective with the stylus
Edit: Solved
 
Last edited by ivodesmedt,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    rvtr @ rvtr: Spam bots again.