Useless CFW for the Retrostone (1)

Present yourself, make suggestions, tell what you think of the project, ask your general questions
User avatar
romanaFive
Posts: 10
Joined: Sun 13 Oct 2019 15:48
Location: Stupidville, Florida

Re: Useless CFW for the Retrostone (1)

Post by romanaFive » Fri 18 Oct 2019 01:20

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

User avatar
gameblabla
Posts: 31
Joined: Sun 7 Apr 2019 10:02

Re: Useless CFW for the Retrostone (1)

Post by gameblabla » Fri 18 Oct 2019 11:39

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.

User avatar
romanaFive
Posts: 10
Joined: Sun 13 Oct 2019 15:48
Location: Stupidville, Florida

Re: Useless CFW for the Retrostone (1)

Post by romanaFive » 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 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.

User avatar
gameblabla
Posts: 31
Joined: Sun 7 Apr 2019 10:02

Re: Useless CFW for the Retrostone (1)

Post by gameblabla » Fri 18 Oct 2019 22:01

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

User avatar
romanaFive
Posts: 10
Joined: Sun 13 Oct 2019 15:48
Location: Stupidville, Florida

Re: Useless CFW for the Retrostone (1)

Post by romanaFive » 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)
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.
Last edited by romanaFive on Mon 21 Oct 2019 18:39, edited 1 time in total.

User avatar
gameblabla
Posts: 31
Joined: Sun 7 Apr 2019 10:02

Re: Useless CFW for the Retrostone (1)

Post by gameblabla » Mon 21 Oct 2019 17:16

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.

User avatar
romanaFive
Posts: 10
Joined: Sun 13 Oct 2019 15:48
Location: Stupidville, Florida

Re: Useless CFW for the Retrostone (1)

Post by romanaFive » Tue 22 Oct 2019 17:03

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.

Post Reply