Homebrew Homebrew Development

  • Thread starter Thread starter aliak11
  • Start date Start date
  • Views Views 1,489,264
  • Replies Replies 6,048
  • Likes Likes 54
God I'm stupid... I just found a huge mistake, do you mind testing it again? It should (hopefully) become apparent what I changed.
ok so now it leaves a trail and bobs a bit higher/lower? I think? when holding A it bobs a tiny bit. There is still the glitchyness a bit and it also constantly flickers white. The black cubes are fine at the start but eventually they also flicker white. When the dot is hit with the cube it stops flickering and the dot/trail stops flickering and glitching.
 
ok so now it leaves a trail and bobs a bit higher/lower? I think? when holding A it bobs a tiny bit. There is still the glitchyness a bit and it also constantly flickers white. The black cubes are fine at the start but eventually they also flicker white. When the dot is hit with the cube it stops flickering and the dot/trail stops flickering and glitching.


I may (or may not) have found the flickering bug. Uploaded as always.
 

Attachments

ok so all the glitchyness is gone but the flickering has transferred to the whole screen, apart from that everything is good! Also a few things I forgot to mention is that during the straights of the bob the trail becomes joined circles (if that makes sense?) so you may or may not want to increase the frequency that the dot makes the trail or something? and there is like a line of pixels on the left side and the top where it keeps the last colour that was there. So when you go above the top it makes a little line of red/blue on the top and then on the left there is the leftovers of the wave or something. It's pretty much one pixel thick but its a thing!
As always I hope this was helpful :3
 
ok so all the glitchyness is gone but the flickering has transferred to the whole screen, apart from that everything is good! Also a few things I forgot to mention is that during the straights of the bob the trail becomes joined circles (if that makes sense?) so you may or may not want to increase the frequency that the dot makes the trail or something? and there is like a line of pixels on the left side and the top where it keeps the last colour that was there. So when you go above the top it makes a little line of red/blue on the top and then on the left there is the leftovers of the wave or something. It's pretty much one pixel thick but its a thing!
As always I hope this was helpful :3

It is supposed to be a continuous line, I guess it does not look like a single line, but many separate circles?
You are not supposed to take your wave off the screen but I put nothing in place to stop someone from doing it.

I don't know about the pixels and flickering the whole screen?! Could you try to explain that more?
 
It is supposed to be a continuous line, I guess it does not look like a single line, but many separate circles?
You are not supposed to take your wave off the screen but I put nothing in place to stop someone from doing it.

I don't know about the pixels and flickering the whole screen?! Could you try to explain that more?

Yeah it looks like many separate circles though they are attached to eachother.
ahk.

It doesn't happen that often but every now and then it just flickers once or twice, I can't find anything that it's related to on my part but the flickers are usually 1-3seconds apart from eachother (not including the two flickers that sometimes happens which are like half a second apart)
 
Well, I thought I was close to being done with the app I am working on, but for some odd reason, even this dumbed down code of what I want isn't working. Any ideas why?

Code:
#include <string.h>
#include <stdlib.h>
#include <3ds.h>
#include "PC3_bin.h"

int main() {
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    CSND_initialize(NULL);
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    
    u8 *PC3 = linearAlloc(PC3_bin_size);
    int a;
    for(a=0;a<PC3_bin_size;a++){
        memcpy(&PC3[a], &PC3_bin[a], 1);
    }
    
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
        
        u32 kDown = hidKeysDown();
        u32 kUp = hidKeysUp();
        
        touchPosition myTouchPosition;
        hidTouchRead(&myTouchPosition);
        u16 posX = myTouchPosition.px;
        u16 posY = myTouchPosition.py;
        
        if (kDown & KEY_START){
            break; // break in order to return to hbmenu
        }
        if((posX > 0 && posX <= 39) && (posY > 0 && posY <= 240)){
            CSND_playsound(0x8, CSND_LOOP_ENABLE, CSND_ENCODING_PCM16, 44100, (u32*)PC3, NULL, PC3_bin_size, 2, 0);
        }
        /*if(posX == -1){
            CSND_setchannel_playbackstate(0x8, 0);
            CSND_sharedmemtype0_cmdupdatestate(0);
        }*/
        
        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }
    
    CSND_shutdown();
    linearFree(PC3);
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
 
Someone knows how microphone works?

I tried to see the mic sample in libctru repo but when i use this function i get blank screen (like the while cycle never ends):
Code:
static int lua_regsound(lua_State *L)
{
    int argc = lua_gettop(L);
    if (argc != 1) return luaL_error(L, "wrong number of arguments");
    u32 mem_size = luaL_checkint(L, 1);
    u8* audiobuf = (u8*)linearAlloc(mem_size);
    u32 audiobuf_pos = 0;
    u32* sharedmem = (u32*)memalign(0x1000, mem_size + 4);
    MIC_Initialize(sharedmem, mem_size + 4, 0x40, 0, 3, 1, 1);
    MIC_SetRecording(1);
    while (audiobuf_pos <= mem_size){
    audiobuf_pos+= MIC_ReadAudioData(&audiobuf[audiobuf_pos], mem_size-audiobuf_pos, 1);
    }
    MIC_SetRecording(0);
    MIC_Shutdown();
    free(sharedmem);
    wav* wav_file = (wav*)malloc(sizeof(wav));
    wav_file->audiobuf = audiobuf;
    wav_file->size = mem_size;
    wav_file->samplerate = 16000;
    wav_file->isPlaying = false;
    wav_file->bytepersample = 2;
    lua_pushnumber(L,(u32)wav_file);
    return 1;
}
 
I don't know why but I've been having trouble with the framebuffer stuff. even doing something that once worked, isn't working, ever since I updated ctrulib.

On this code the screen is always flashing a yellow/white line on the left side that is about 40px big.

Code:
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <3ds.h>
#include "draw.h"

int main() {
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
    
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
        
        u32 kDown = hidKeysDown();
        u32 kUp = hidKeysUp();
        
        if (kDown & KEY_START){
            break; // break in order to return to hbmenu
        }
        
        u8* ft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
        memset(ft, 0, 240*400*3);
        memset(fb, 0, 240*320*3);
        
        drawFillRect(0, 0, 160, 120, 255, 0, 0, fb);
        drawFillRect(161, 0, 360, 120, 0, 255, 0, fb);
        drawFillRect(0, 121, 160, 240, 0, 0, 255, fb);
        drawFillRect(161, 121, 360, 240, 225, 225, 0, fb);
        
        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
 
I don't know why but I've been having trouble with the framebuffer stuff. even doing something that once worked, isn't working, ever since I updated ctrulib.

On this code the screen is always flashing a yellow/white line on the left side that is about 40px big.

Code:
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <3ds.h>
#include "draw.h"

int main() {
    // Initialize services
    srvInit();
    aptInit();
    hidInit(NULL);
    gfxInit();
    //gfxSet3D(true); // uncomment if using stereoscopic 3D
 
    // Main loop
    while (aptMainLoop())
    {
        gspWaitForVBlank();
        hidScanInput();
     
        u32 kDown = hidKeysDown();
        u32 kUp = hidKeysUp();
     
        if (kDown & KEY_START){
            break; // break in order to return to hbmenu
        }
     
        u8* ft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
        u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
        memset(ft, 0, 240*400*3);
        memset(fb, 0, 240*320*3);
     
        drawFillRect(0, 0, 160, 120, 255, 0, 0, fb);
        drawFillRect(161, 0, 360, 120, 0, 255, 0, fb);
        drawFillRect(0, 121, 160, 240, 0, 0, 255, fb);
        drawFillRect(161, 121, 360, 240, 225, 225, 0, fb);
     
        // Flush and swap framebuffers
        gfxFlushBuffers();
        gfxSwapBuffers();
    }
    // Exit services
    gfxExit();
    hidExit();
    aptExit();
    srvExit();
    return 0;
}
Why do you get the top fb but never use it?
 
I don't know why but I've been having trouble with the framebuffer stuff. even doing something that once worked, isn't working, ever since I updated ctrulib.

On this code the screen is always flashing a yellow/white line on the left side that is about 40px big.

Code:
..
 
        u8* fb = gfxGetFramebuffer(GFX_BOTTOM,GFX_LEFT, NULL, NULL);
..
        drawFillRect(161, 0, 360, 120, 0, 255, 0, fb);
..
        drawFillRect(161, 121,360, 240, 225, 225, 0, fb);
     
}

You should have a modded 3DS with wide 3D bottom screen :rofl2:

Just joking.

correct in
Code:
u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);

(probably has non effect, but keeps your code clean and readable)

and

Code:
drawFillRect(161, 0, 320, 120, 0, 255, 0, fb);
..
drawFillRect(161, 121,320, 240, 225, 225, 0, fb);

Let me give you a little suggestion :teach: :

Every coder makes such mistakes, but asking someone else to point and fix them doesen't make you learn.
Debugging skills are much valuable then coding ones. :grog:
 
You should have a modded 3DS with wide 3D bottom screen :rofl2:

Just joking.

correct in
Code:
u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);

(probably has non effect, but keeps your code clean and readable)

and

Code:
drawFillRect(161, 0, 320, 120, 0, 255, 0, fb);
..
drawFillRect(161, 121,320, 240, 225, 225, 0, fb);

Let me give you a little suggestion :teach: :

Every coder makes such mistakes, but asking someone else to point and fix them doesen't make you learn.
Debugging skills are much valuable then coding ones. :grog:
But debugging can get very frustrating if you just don't find the fault.
 
Can anyone by chance explain to me which of my functions has its coords back to front here?

I'm trying to grab an image from my buffer than display it, sounds simple enough, but the image is coming out wrong is I used non-square images. Part of the image is correct, but part of it repeats. Try something like grabImage(0,0,0,16,22);

Code:
u8* sprite[50];
 
u8 Color[3]; //(r,g,b)
 
void Plot(u8* dest,int x, int y, char r, char g, char b) {
    dest[3*(239-y+x*240)+2] = r; //red
dest[3*(239-y+x*240)+1] = g; //green
dest[3*(239-y+x*240)] = b; //blue
}
void Pick(u8* dest, int x, int y) {
    Color[0] = dest[3*(239-y+x*240)+2]; //red
Color[1] = dest[3*(239-y+x*240)+1]; //green
Color[2] = dest[3*(239-y+x*240)]; //blue
}
 
void grabImage(int spriteNum, int x1, int y1, int width, int height){
    sprite[spriteNum] = malloc((width*height*3)+2);
    sprite[spriteNum][0] = width;
    sprite[spriteNum][1] = height;
    int x,y;
    for(x=0; x<width; x++){
        for(y=0; y<height; y++){
            Pick(topbuf,x,y); // grab RGB pixel
            sprite[spriteNum][2+3*(y+x*width)] = Color[0];
            sprite[spriteNum][2+3*(y+x*width)+1] = Color[1];
            sprite[spriteNum][2+3*(y+x*width)+2] = Color[2];
        }
    }
}
 
void putImage(int spriteNum, int x1, int y1, bool screen){
    tflb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
    int width = sprite[spriteNum][0];
    int height = sprite[spriteNum][1];
    int x,y;
    u8 red,green,blue;
    if(screen == 0){
        for(x=0; x<width; x++){
            for(y=0; y<height; y++){
                red = sprite[spriteNum][2+3*(y+x*width)];
                green = sprite[spriteNum][2+3*(y+x*width)+1];
                blue = sprite[spriteNum][2+3*(y+x*width)+2];
                if(!(red == 255 && green ==0 && blue ==255)){
                    Plot(tflb, x+x1,y+y1,red,green,blue);
                }
            }
        }
    }
}
Thanks.
 
Can anyone by chance explain to me which of my functions has its coords back to front here?

I'm trying to grab an image from my buffer than display it, sounds simple enough, but the image is coming out wrong is I used non-square images. Part of the image is correct, but part of it repeats. Try something like grabImage(0,0,0,16,22);

..

Thanks.

Not
y+x*width

but
y*width+x

:ha:
 
hehe, thanks, for some reason I just couldn't see that :-)

Pay attention to the sprite width, that must be max 255 if you want to use the first byte of your u8 record array to store it's value.

With a screen width of 400 px you could be tempted to use larger sprites ;)
 
You should have a modded 3DS with wide 3D bottom screen :rofl2:

Just joking.

correct in
Code:
u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);

(probably has non effect, but keeps your code clean and readable)

and

Code:
drawFillRect(161, 0, 320, 120, 0, 255, 0, fb);
..
drawFillRect(161, 121,320, 240, 225, 225, 0, fb);

Let me give you a little suggestion :teach: :

Every coder makes such mistakes, but asking someone else to point and fix them doesen't make you learn.
Debugging skills are much valuable then coding ones. :grog:
I can't believe I didn't even notice those two things. I guess I was more tired than I thought :P
 
Pay attention to the sprite width, that must be max 255 if you want to use the first byte of your u8 record to store it's value.

With a screen width of 400 px you could be tempted to use larger sprites ;)


Nah, I'm oldskool, 16x16, maybe 32x32 is plenty for a character sprite :-)
 

Site & Scene News

Popular threads in this forum