Page 6 of 7

Re: Useless CFW for the Retrostone (1)

Posted: Fri 18 Oct 2019 01:20
by romanaFive
Here's the source. I forgot where I got it from; it was a pain to find and get the buttons working
on RS-97.

All the files needed to run the game is in squashfs-root.

I'm not sure how to proceed with your instructions:

Maybe look in dingoo.c? I didn't see any calls of SDL_Flip. A screen (pScreen) is created with SDL_SetVideoMode in this file, but nothing is ever done with it. Maybe something else involving dzzFlip() and dingoo_screen and dingoo_screen15?

Well, thanks for looking into it.

http://ceratoph.freeshell.org/retrostone/Nethack.zip

Re: Useless CFW for the Retrostone (1)

Posted: Fri 18 Oct 2019 11:39
by gameblabla
Ok so i looked into it and its not using SDL but directly to the framebuffer (/dev/fb0) and using eudev.
I could convert it to use SDL but i think you are better off looking for a version that uses SDL instead, that would make it much easier for me to port.

Re: Useless CFW for the Retrostone (1)

Posted: Fri 18 Oct 2019 17:01
by romanaFive
Err, I looked at it again and I noticed there was an unused sdl.c file among the source files. I deleted dingoo.c from the Makefile and added sdl.c.

I got the screnn working!

The keys work but aren't exactly right: the top button (blue) is B, I think. Also the game tries (and fails) to save to the (readonly) CWD . Someplace in this mess, there must be a way to save to HOME, as that's what nethack originally did until someone ported it to handhelds. Err, where is HOME on Useless?

It looked like it was converting from 16 to 32-bit in sdl.c, so I just commented that converty stuff and applied your instructions:

Code: Select all

static void *InitScreenSDL()
{
        SDL_Init(SDL_INIT_VIDEO);
        rl_screen = SDL_SetVideoMode(0, 0, 16, SDL_HWSURFACE);
        // pScreen = SDL_SetVideoMode(320, 240,32, SDL_SWSURFACE);
        pScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 240, 16, 0,0,0,0);
        memset(g_usScreen, 0, sizeof(g_usScreen));
        return g_usScreen;
}

static void *FlipScreenSDL()
{
        unsigned long ul, r, g, b;
        unsigned short us;
        //unsigned long *ptr = (unsigned long *) pScreen->pixels;
        unsigned short *ptr = (unsigned short *) pScreen->pixels;
        int x, y;

        for(y = 0; y < 240; y++)
        {
                for(x = 0; x < 320; x++)
                {
                        us = g_usScreen[y * 320 + x];
                        // Not really understanding what went on here:
        /*              r = (us >> 11) & 0x1F;   // (us / 2048 ) * 31
                        g = (us >> 5) & 0x3F;     // (us / 63 ) * 63
                        b = us & 0x1F;                // us / 31
                        ul = ((r * 8) << 16) + ((g * 4) << 8) + (b * 8); 
                        ptr[y * (pScreen->pitch / 4) + x] = ul;
        */
        		// Well, if 32bpp has pitch/4, 16bpp should have pitch/2 ?
                        ptr[y * (pScreen->pitch / 2) + x] = us;}
        }
        // SDL_UpdateRect(pScreen, 0, 0, 320, 240);
        SDL_SoftStretch(pScreen, NULL, rl_screen, NULL);
        SDL_Flip(rl_screen);
        return g_usScreen;
}


I updated source linked code above.

Re: Useless CFW for the Retrostone (1)

Posted: Fri 18 Oct 2019 22:01
by gameblabla
romanaFive wrote: Fri 18 Oct 2019 17:01 Err, I looked at it again and I noticed there was an unused sdl.c file among the source files. I deleted dingoo.c from the Makefile and added sdl.c.
I'm surprised to have missed that file lol... Nice
The keys work but aren't exactly right: the top button (blue) is B, I think. Also the game tries (and fails) to save to the (readonly) CWD . Someplace in this mess, there must be a way to save to HOME, as that's what nethack originally did until someone ported it to handhelds. Err, where is HOME on Useless?
You should not care where HOME is located, as the HOME environment variable is properly exported.
Instead what you should do is something like this

Code: Select all

char gamepath[512];
snprintf(gamepath, sizeof(gamepath), "%s/.nethack", getenv("HOME"));
Use getenv("HOME") to obtain the HOME directory of Useless : it will still work in case the home location gets changed and that's how all ports should be done.

Btw, here's the key mapping :
A - SDLK_LCTRL
B - SDLK_LALT
X - SDLK_LSHIFT
Y - SDLK_SPACE

L - SDLK_TAB
R - SDLK_BACKSPACE
L2 - SDLK_3
R2 - SDLK_END

See my code for reference :
https://github.com/retrostone-dev/build ... nts.c#L355

Re: Useless CFW for the Retrostone (1)

Posted: Sun 20 Oct 2019 00:39
by romanaFive
Actually using getenv() to read HOME environment variable isn't the problem. Nethack is also trying to create lock files in $CWD. Some kind of save backup scheme in case of nethack crashing, I think. I tried changing the save to /home/useless. It saves, but then when you restart the game, you discover the lock file(s) were not created and then you are dead.

Code: Select all

Cannot create file 1lock.0 for level 0 (errno 30)
It is sooo much easier to just leave nethack in a folder and launch it with Explorer, than put it in an opk and figure out how it is nameing these locks in files.c. Is it possible to put a gmenu launcher icon for a binary located somewhere in /home/useless instead of in an opk?

Anyway, Nethack runs (saves and loads) fine from Explorer in a folder. Since this game is not exactly brilliant quality, I'm gonna leave it here. I did manage to get the buttons right. However, picking help on the menu will seg. fault and any new progress since the last save will be lost.

I also got Last Mission, Boulder, and Dingux Commander working using your instructions. Thanks again. This is much easier than the nebulous, convoluted Debian mess of retroarch + retropie!

The final Nethack mess and the other opks are in

http://ceratoph.freeshell.org/retrostone

All opks include source code.

Re: Useless CFW for the Retrostone (1)

Posted: Mon 21 Oct 2019 17:16
by gameblabla
romanaFive wrote: Sun 20 Oct 2019 00:39 Actually using getenv() to read HOME environment variable isn't the problem. Nethack is also trying to create lock files in $CWD. Some kind of save backup scheme in case of nethack crashing, I think. I tried changing the save to /home/useless. It saves, but then when you restart the game, you discover the lock file(s) were not created and then you are dead.

Code: Select all

Cannot create file 1lock.0 for level 0 (errno 30)
That lock issue could easily be fixed : just remove the related code so it ignores it.
It's really not necessary at all.

Btw, your link isn't working.

Re: Useless CFW for the Retrostone (1)

Posted: Tue 22 Oct 2019 17:03
by romanaFive
Those files called nlock.m (where n,m are ints ) are written by create_levelfile(). A new one is written each time you descend a level. I think they might be involved in creating the save file, too.

It looks like a tangled mess in files.c and save.c. I'm not seeing any easy quick way, like disabling a particular function. If you already have it all figured out what can be disabled, please explain.

Sorry about the typo in the url: retrogame <-----> retrostone.

Re: Useless CFW for the Retrostone (1)

Posted: Thu 13 Feb 2020 22:25
by jimfaker
Hi! great, I use it and it works great, but the FCEUX works way too slow, what can I do to make it work at normal speed?

thanks again for your hard work :)

Re: Useless CFW for the Retrostone (1)

Posted: Tue 25 Feb 2020 21:42
by gameblabla
jimfaker wrote: Thu 13 Feb 2020 22:25 Hi! great, I use it and it works great, but the FCEUX works way too slow, what can I do to make it work at normal speed?

thanks again for your hard work :)
Slow ? Could be due to the sound rate not being set at 48000 or similar... Or are you playing PAL games on it ?
I do admit, some minor updates happened since then so i should update my emulators again. (notably VBA Next, SMS Plus GX and Handy)

Re: Useless CFW for the Retrostone (1)

Posted: Tue 3 Mar 2020 19:44
by jimfaker
gameblabla wrote: Tue 25 Feb 2020 21:42
jimfaker wrote: Thu 13 Feb 2020 22:25 Hi! great, I use it and it works great, but the FCEUX works way too slow, what can I do to make it work at normal speed?

thanks again for your hard work :)
Slow ? Could be due to the sound rate not being set at 48000 or similar... Or are you playing PAL games on it ?
I do admit, some minor updates happened since then so i should update my emulators again. (notably VBA Next, SMS Plus GX and Handy)
Yes I tried from USA, EU and JAP and all of them play slow, the fps counter goes at 24 fps. I tried every config with the sound rate and nothing.

Also, I'm wondering, for the PSX emulator, is there a possibility to put it the pcsx.cfg a combination of buttons like "Select" + "R2" to pop up the menu? And not like right now, R2, that it is impossible to use that button for any game? Or maybe the button up on the side of the retrostone? :)