Duke3D For PSP Slim

Discussion in 'Articles' started by x3sphere, May 24, 2008.

  1. x3sphere

    x3sphere Administrator Staff Member Enforcer Team


    Homebrew developer Wally today sent over an updated build of the Duke Nukem 3D PSP port originally written by MrPeanut, complete with support for Slim units. Since various individuals assisted him in the creation of the release, the author would like to send thanks to the following developers:[blockquote2]* MrPeanut - Gave me a hand while still learning
    * HardHat - Always ready to help
    * InsertWittyName - For the quick stress free advice[/blockquote2]As with previous builds, a shareware or retail version of the DUKE3D.GRP data file is required to play. The file itself should be placed inside of the Duke3D folder contained in the archive below.

    Download Duke3D For PSP Slim
  2. Chilly Willy

    Chilly Willy Contributor

    Hmm... not bad, but it still has the audio sample rate bug, and crashes when you try to exit.
  3. Wally1

    Wally1 New Member

    Yeah, i'm still yet to learn how to do that yet Chilly Willy :p

    Noob I am yes!

    People should expect some more releases here in the future!

  4. Wally1

    Wally1 New Member

    I'd like to acknowledge the following:

    stereomike made the original PSP port, MrPeanut followed it up. My bad.

    Also Chilly Willy, MrPeanut said that there is an app which he has made that fixes the audio sample bug. Its avaliable here

  5. Chilly Willy

    Chilly Willy Contributor

    Hey Wally! Good to see you here. If you post the source, maybe I can help with the audio bug. I don't see why you should have to use a Windows app to resample the sound. There are ways to change the PSP's sample rate. You could also resample the audio on the fly if needed. :)
  6. wally

    wally Developer

    <p>the source is avaliable at
  7. Chilly Willy

    Chilly Willy Contributor

    Cool. I'll start looking into the sound.

    EDIT: Just to be certain - there's three source folders in the arc... which one are you building from?
  8. wally

    wally Developer

    <p>Heh, i said exactly the same to Mr Peanut.</p>
    <p>the correct makefile is located in jfduke3d_psp_mrp_98</p>
    <p>All the other folders are just linked somehow (Don't ask)</p>
  9. wally

    wally Developer

    <p>OH and don't forget about Basilisk 2 xD</p>
  10. fungusinmymilk

    fungusinmymilk New Member

    Duke Nukem 3d is one of my most favourite games.

    very much looking forward to a stable port on the psp!

    thanks for picking up the project guys :smile:
  11. Chilly Willy

    Chilly Willy Contributor

    Okay folks, try this out... just drop it in place of the EBOOT.PBP you already use.


    It fixes the audio pitch problem for me. The source of the trouble is actually SDL - SDL has the ability to convert samples from one format and rate into another, and Duke3D uses that. The problem is in SDL_audiocvt.c:

    		/* We may need a slow conversion here to finish up */
    		if ( (lo_rate/100) != (hi_rate/100) ) {
    #if 1
    			/* The problem with this is that if the input buffer is
    			   say 1K, and the conversion rate is say 1.1, then the
    			   output buffer is 1.1K, which may not be an acceptable
    			   buffer size for the audio driver (not a power of 2)
    			/* For now, punt and hope the rate distortion isn't great.
    			if ( src_rate < dst_rate ) {
    				cvt->rate_incr = (double)lo_rate/hi_rate;
    				cvt->len_mult *= 2;
    				cvt->len_ratio /= cvt->rate_incr;
    			} else {
    				cvt->rate_incr = (double)hi_rate/lo_rate;
    				cvt->len_ratio *= cvt->rate_incr;
    			cvt->filters[cvt->filter_index++] = SDL_RateSLOW;
    Notice that the "slow" conversion isn't enabled. SDL by default only does conversions by powers of two. If the difference in the sample rate of the sample and the audio playback rate isn't a power of two, SDL only scales is to the closest power of two. That's why the Duke3D sounds are all off. If you change that "#if 1" to "#if 0", the sounds will be fine. My executable is compiled with the SDL compiled that way.

    One point: this isn't a fast conversion. Duke3D waits until a sound needs to be played the first time before doing the conversion. This means there's a brief pause right as the sound effect is used (or not so brief for some of Duke's one-liners). I'll probably try adding code to force all the sound effects to be converted right at the start of the level or something.

    Note that this version also exits to the XMB, and allows you to exit via the Home button as well.
  12. Chilly Willy

    Chilly Willy Contributor

    Okay, here's test 2.


    I expanded the heap to 16 MB. The earlier value (10 MB) caused sounds to not be played, especially when the music was playing. I suppose it ran out of heap space for the sounds.

    I also set the optimization level to 1. The code base for this is pretty lousy - if you set the optimization level higher than 1, it crashes. Even at O0, it still had a tendency to crash after using the menu, or restarting a level. I suppose someone needs to make a conversion of EDuke32 instead of old JFDuke code. Oh well.

    EDIT: Here's the source for test 2.
  13. wally

    wally Developer

    <p>Good on ya chilly willy :)</p>
    <p>I'll test when i get home.</p>
  14. Chilly Willy

    Chilly Willy Contributor

    The only files that were changed were:
    sdlayer.c - altered heap size, fixed callbacks, and added callback setup to main
    game.c - added sceKernelExitGame() right before ShutDown()
    Makefile - some changes to get it to compile with the latest toolchain/sdk in linux

    And of course, I changed SDL_audiocvt.c as mentioned previously.
  15. midnitdragoon

    midnitdragoon New Member

    i registered just so i can post on this topic. I love Duke Nukem 3D and i love you for undertaking this project so well!!!! Thank you! Quick question how do i enable music? trying to get it to work but dunno where to start arrrgh
  16. midnitdragoon

    midnitdragoon New Member

    ok i tried this new version and its a little skippy dunno why. other than that no crash when trying to exit =D. anyone know how to add music?

    ok i read above and realize why it skips hehe!
  17. Chilly Willy

    Chilly Willy Contributor

    Download the timidity instruments from here (Warning! 14MB file):

    Put the timidity directory that is inside that arc into the Duke3D directory on your PSP. Then put this file (inside the attached zip) in the Duke3D directory as well.

    Haven't had the chance to look into preloading the sounds yet. Maybe this weekend.

    Attached Files:

  18. midnitdragoon

    midnitdragoon New Member

    oooo ok very i got that to work thanks Willy!! Well i played through the first level fust fine. Now when getting to second level loading it went to "Generating Music Data... Wait, Please." and just frose there. Dont know what thats about hehe. Well anyways gonna keep trying other duke levels and let you know whats up =D

    Edit- Ok i tried episode 2 and got passed the first level. When it got to the loading screen for the second level it froze and shut of my psp at the "Generating music data..." screen.
  19. Chilly Willy

    Chilly Willy Contributor

    Thanks for the report... I'll look into that. Might be an issue with how the current code releases the memory for the old score, or how it deals with the temporary file generated.
  20. Chilly Willy

    Chilly Willy Contributor

    Okay, as far as I can tell, the problem with the music going from level 1 to level 2 is the fault of timidity. Timidity is used by SDL_mixer to play the MIDI scores, but when timidity is converting the score, if it runs out of memory, it tries to exit the program instead of simply not playing the music. Go fig. Anywho, trying to exit on Duke3D blows up, which is why it hangs when it tries to convert the score for level 2. I haven't figured out a way to limit the memory or flush the memory in use (sound effects). So music is a no-go at the moment. :(

    On the plus side, this test version has the speed bumped to 333MHz, which makes the sound effects conversion less noticeable, and the game a bit smoother. I also added TV support to SDL, so now you can play Duke3D on the TV on the Slim. When you start the app, hold down the TRIANGLE button. You'll get a set of message dialogs asking about what video settings you want SDL to use. If you don't have a Slim, don't have the dvemgr.prx, or don't have a cable, it only asks if you wish to make the display wide screen (480x272) or not (364x272) on the LCD. That's good if you want to play Duke3D in the original aspect ratio.

    If you have a Slim, the dvemgr.prx, and a cable, then you get asked if you wish to use the TV output, if you wish to do interlaced output (if you have the component cable - composite is ALWAYS interlaced), if your TV is 16 : 9 (HDTV), and if you wish to make the display widescreen. Just try a few different settings to see how it works. It writes this data to a prefs file so that the next time you run the app, it'll use those same settings (unless you hold TRI again).

    So here's test 4: http://www.mediafire.com/download.php?mvzzye0amqi

Share This Page