Hacking Batterycheck - PSP

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
A few weeks ago I opened a thread about a remake for an old PC game in the Wii section and I am hoping it's OK to open a second related thread for the PSP version here. To give you PSP homebrewers an idea of what Batterycheck is about in case you did not read or follow the Wii section here is a little story:

Back in 1998 there was a campaign to promote recycling batteries in the Netherlands and part of that was a PC game on CD-ROM you could get if you brought 15 batteries in for recycling. It was based on the same engine as Jazz Jackrabbit 2 and therefore uses the same file formats for the Tileset, Levels and Sprites. About 10 years ago the game was released as Freeware by the publisher but they removed it after a while. After some digging I found one of the companies that worked on the game and I contacted them. The game is licensed as Creative Commons but I need to ask them which specific version. I did get permission to share their download page where the game is listed but they warned about it getting removed in the future. I posted the link and instructions to download in my other thread (here)


With that introduction out of the way I want to talk about the PSP specific version in here. I have installed PSPDEV inside a docker container and with after a bit of trial and error I got it to compile some 'hello world' example I found on a wikibook tutorial. When I finally figured out which files were needed I got it running in the ppsspp emulator. When I tried to integrate my own code which is mostly C++ so many errors were generated that I had no idea what was wrong until I saw it tried to compile my source with GCC instead of G++! Coming from Devkitpro where things feel a little more smooth this feels like a huge step back to be honest. I also don't like that all the object files are all over the place next to the source files while I am used to those being in a ./build/ directory.

I am still very new to the PSP Homebrew, PSPDEV and docker but I was hoping some of you might give me a few pointers on how to fix the Makefile. I have added a few minimal things from the Devkitpro Makefile to detect the .cpp sourcefiles and here is what I have now:
Code:
TARGET    = batterycheck_psp
BUILD     = build
SOURCES   = source
INCLUDES  = ../../include

INCDIR    = $(INCLUDES)
CFLAGS    = -G0 -Wall -O2
CXXFLAGS  = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS   = $(CFLAGS)

CPPFILES  = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cpp))
#CPPFILES = $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
OBJS      = $(CPPFILES:.cpp=.o)

LIBDIR    =
LDFLAGS   =
LIBS      = -lm

BUILD_PRX = 1

EXTRA_TARGETS   = EBOOT.PBP
PSP_EBOOT_TITLE = Batterycheck - PSP

PSPSDK   = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

I am going to try a few more things myself but any help is much appreciated.
 
Last edited by Archerite, , Reason: No more need for that big block of code in the first post.

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
I saw that I had not included the 'Lets play video' as I did in the other threads...so here is a Let's Play video in English and they play through the entire game to the end boss..so it has some spoilers ;)

Just to be clear this video is NOT of my version of the game engine.

Aside from my issues with the Makefile I tried to figure out how to initialize the GU and draw some graphics! It looks to be a little more work than on other platforms even with the pspgu.h having similar calls to opengl, the biggest thing missing are vertex functions. Need to build a displaylist manually I guess from the examples I saw.

I'll figure it out at some point but for now I just stick with text mode for a while to see if I can load thing in memory like the level and collision map. This can easily work in a text mode ASCII art style :D...already made my earliest rotating 'sprites' demo in this mode work, really just * characters rotating over a few text lines.

EDIT:
I have made some progress on the PSP but not really enough for a new post. After reading countless tutorials and examples and I could upgrade the rotating text asterisks into actual colored "squares" drawn as a triangle strip. From what I could find out the PSP or the GU interface library does not support drawing QUADS like I am used too on the other systems. I could post a screenshot but it's just eight colored squares on a black screen really. Next step is adding textured "quads" and fixing the build system, since it still does not work how I want to but at least it works. :D

When I get to sharing a demo or preview...what do I share? The .prx or EBOOT.PBP?
 
Last edited by Archerite,

niuus

Well-Known Member
Member
Joined
Mar 4, 2016
Messages
2,023
Trophies
1
XP
4,456
Country
Venezuela
EDIT:
I have made some progress on the PSP but not really enough for a new post. After reading countless tutorials and examples and I could upgrade the rotating text asterisks into actual colored "squares" drawn as a triangle strip. From what I could find out the PSP or the GU interface library does not support drawing QUADS like I am used too on the other systems. I could post a screenshot but it's just eight colored squares on a black screen really. Next step is adding textured "quads" and fixing the build system, since it still does not work how I want to but at least it works. :D

When I get to sharing a demo or preview...what do I share? The .prx or EBOOT.PBP?
EBOOT! :yaypsp:
But you could also make both available for the final release.

Will test on a PSP 3k, as well as Adrenaline on a PSTV.
 
Last edited by niuus,
  • Like
Reactions: Archerite

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
EBOOT! :yaypsp:
But you could also make both available for the final release.

Will test on a PSP 3k, as well as Adrenaline on a PSTV.
I already thought that was the one I had to provide, but yeah both are available after the build so why not give then both. Thanks for the tip ;)

This port is further along than the PlayStation 2 but both are a low priority for the moment as I am rewriting a few core components and cleaning up some of the mess. When that is done I might take a look at fixing the Makefile again so it behaves more like devkitpro and not put the .o files everywhere.

Would be great if you could test it when it gets out though...eventually:D
 

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
I have made an attempt to work around the Makefile issues and found an acceptable solution for now by using rsync on my source files and copy them into the PSP build folder so the docker image can access those files instead! Since my game engine is written in C++ I had to modify a couple of things here and there to get it to compile....and it builds without errors...but for whatever reason ppsspp crashes without an error and the real hardware freezes. It looks like C++ is not very well supported by PSPSDK or I am just doing something wrong.

I found the exact line it fails on with using printf's but without an actual error I have no clue on what it could be. Posting C++ code is does not allow to highlight a line so in plain text this is my code.

//------------------------------------------------------------------------------
void jzGPU_startFrame() {
//------------------------------------------------------------------------------

sceGuStart(GU_DIRECT,list);

sceGuClearColor(0);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);

sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumOrtho(0, 480, 272, 0, -1, 1);

sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();

sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();

ScePspFVector3 pos = {0.0f, 0.0f, 0.0f};

//sceGumTranslate(&pos);
//sceGumRotateZ(val*0.03f);
}

When using the C libraries this works but when including -lstdc++ I need to disable the C library to get rid of a bunch of missing functions. This is probably a hint to whats wrong now that I think of it ;)..anyway the red line is where it crashes. Without it there is obviously no display but I do get debug output in the "draw-frame" loop so the rest seems to work fine!

So it's not much but at least there is a tiny little bit of progress for the PSP. :D
 

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
After much consideration I have decided that the PSP port will be postponed for a long while. I am not saying the PSP port will never happen as it's just some stupid compiler issues that need to be resolved!
I have spend far too much time on trying to make it work on the PSP than adding actual features to the GameEngine that are far more useful.

In the mean time you could follow the overall progress in one of the following threads:
Wii version - kind of the main thread
3DS version

I will post here again when I continue for the PSP platform and hope there is still interest in a few months.
 

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Wow, this thread has past 1000 views so it looks like there might be enough interest in the PSP version to get back on it after all. I have almost finished writing an installer that unpacks the gamefiles directly from the batterycheck.zip file on the console itself, and since that is a text only app right now it might just work on the PSP. Not useful if the main game won't run yet I know but it will allow me to figure things out on the PSP a little easier I think.

Thanks for the motivation ;)
 
Last edited by Archerite,

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
While I have not done much the last few months with the PSP port there is finally some progress to report:
ppsspp-batterycheck---getting-there.jpeg

This is a screenshot of the PPSSPP emulator that shows my code is actually running and the level is loaded. Using the debug mini-map I could actually play the level a bit since I know it very well by now. The weird part is that I can't seem to get the camera to move and it's stuck at position 0,0 in the top left corner. I had to draw the mini map at these fixed coordinates to even see something at all...but at least it's something.

More than on the actual hardware because for whatever reason it just shows a black screen for a few seconds and then shutsdown the PSP. I am using a lot of large temporary buffers and I suspect it's running out of it. When I have some more time for testing I will try disabling some of it to see if that makes a difference.
 
  • Like
Reactions: Alexander1970

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Just wanted to share the progress for those interested in a PSP port of this game (and eventually Jazz Jackrabit 2) what I got working so far:

I have put a little more effort into it and after a lot of testing the camera is moving with the 'player'...which is still just a simple rectangle. Getting the textures loaded is going to take a bit more time...again...but it's finally looking like the PSP port is going to happen!

Because the music library libmikmod is already available for the PSP I had thought it would be easy to add sound, but a bug in the PSPSDK version during compilation prevents it from working. I had to download the source and compile it myself and then include that into my build! This took a few more hours to figure out but PPSSPP now has the background music and sound effect working! And while I had it working on hardware before adding the sound....it does not work anymore!! Just a black screen and it shuts off!!! I did found out that the PSP does this when the 'application gives an exception' and crashes, so at least I know it crashes just not why!!

The main reason for me to want the PSP port is that the PPSSPP emulator runs so smooth on android and my phone. The memorystick emulation is just a folder on the SD card which makes it easy to access the game files. For the Wii version I can use Dolphin with an SD.raw image which works, but adding or changing files is a lot more work!

That's it for now ;)
 
Last edited by Archerite,

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Hello. :)

Sorry about your troubles.
I come here because of tried your w.i.p Wii Port and i love it.:yay:

Keep it up,take your time and hangi n there.:yaypsp:
Thank you for your great work.
I am glad you are enjoying the Wii version even though it's far from complete. I have a few other things planned for the next few weeks but in time I will get back into making it work on the PSP.

Thanks for your support. :D
 
  • Like
Reactions: Alexander1970

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Over a year has past since my last post in this thread....and actually all batterycheck related development was on-hold for a couple of months. On my blog I have been talking about an attempt to port the game engine to the GBA -> DS -> DSi and various reasons for why the first two are giving problems. It's mostly related to the resolution and graphics capabilities of the systems. I do have it partially working on the DSi even on hardware....with textures even!! And that made me feel bad about this PSP port....:blush:

A few weeks ago I have put in a couple of hours to fix all issues with the exisitng ports for Linux, Wii, 3DS and ofcourse PSP!! Since once again many things were broken or caused crashes here and there. :lol: This has resulted in making the PSP version compile again and working in PPSSPP v1.10 on Ubuntu 18.04.....but unfortunately it still crashes on hardware. This is what it looks like in the emulator though:

upload_2020-7-25_10-54-43.png

It plays smooth as butter and since I know the start of the level extremely well by now I can even play it quite far. Even when every single texture is substituted by a semi-transparent rectangle :D Before even considering releasing a preview of this PSP version it needs to work on my real PSP3004 first. And then I really need it to use textures instead of this blue rectangle substitute ofcourse :lol:

But since development on the DSi version seems to progress quite well until I ran out of VRAM with these big textures.....I might as well spend a little more time digging into how to make it work on the PSP and have it run on hardware again. I do only have a single PSP though and can't test it on any other model to rule out something wrong with my mod...that I need to re-run every reboot!

The game might not be working yet but I could focus on getting the installer ready to run on the PSP. This allows you to just place the downloaded ZIP on the MS and it will unpack the gamefiles directly on the PSP itself...without requiring any PC to extract them. This works well on the other systems and I see no reason it can't be done on the PSP too. :D

Sorry for the long post but I had a lot to say ;)
 

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
This is finally looking like it's actually going to work :D

upload_2020-7-25_17-55-46.png

Not tested on hardware just yet but at least in PPSSPP the textured graphics are actually working now! The only reason I do not have the other graphics enabled yet is that they are currently to big for what the PSP can handle. The limit is 512x512 pixels and the tileset, player and level objects are all 1024x1024 since I do not have this limitation for the other platforms.....except the DSi which has the same issue actually.

It has taken me almost all day to figure out that my texture coordinates where in the wrong order :angry:....for whatever reason I just started to move the vertex positions and BAM! They showed up on screen!! Well...they were skewed and drawn in the wrong orientation...but they were drawn in the correct colors and positions! There is still a lot of work to make this port work correctly and I still need to test it on hardware but at least it's working in the emulator!

Rewriting my texture generation is going to take a little while but it looks like the PSP is finally getting the preview version in a couple of weeks :D
 

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Just a little update to show the progress on the PSP port:

After figuring out how to use PSP Link I could debug my game and see what was making it crash! I still don't know how to really use GDB properly but at least I could see my debug messages to figure things out :D (see my blog post for more info on that)

It now runs on hardware without crashing immediately but there are many things that need to be fixed before a preview for the PSP is released. There are a lot of graphical glitches and slowdowns that might be caused by my textures being too large or something else that is configured in the wrong way. I still consider it progress as the game is now running on real hardware and I was able to take a screenshot using PSP Link (cool feature!!) and for completeness also took a picture of the device running the game :wink:

psp-batcheck-running-on-hardware.png psp-batterycheck-running-device.jpg

Because the PSP hardware has some restrictions on texture resolutions I need to rewrite the tile drawing routines to work around it! I wrote about the issue and a possible solution on my blog a couple of days ago here. In short I need to use multiple smaller textures and keep an array that maps the TileID's with the texture to use and the location within that texture. The good thing is that I can reuse this solution for the DSi since it has similar restrictions on the texture sizes. The PSP port is already ahead of the DSi since it has working background music thanks to libmikmod, and it has the player sprites already! :D

While testing and debugging these issues I left my PSP connected to the PC over night....and that seems to have broken my battery! :cry: It won't power on without the charger connected and it turns off immediately when I unplug it! I have not tested it with a multi-meter yet to see if it gives any voltage but the PSP Shell "power" command says 0v and extremely weird temperature values. Maybe it was running from the battery all the time and I was thinking it ran of USB power. And now it drained to far for the charger to fix it. :(

I have no other PSP (yet) to test the battery or charge circuit. I am glad it does still work while connected to the charger so at least the console it self is not broken, so I can still run test builds on it :wink: It does take the "portable" out of the PlayStation Portable quite a bit though :sad:

No matter how much I really want the tile's to work on the PSP, I have no idea how much time it's going to take so no promises. :D
 
  • Like
Reactions: Alexander1970

Archerite

Well-Known Member
OP
Member
GBAtemp Patron
Joined
Sep 16, 2018
Messages
209
Trophies
1
Age
41
XP
2,488
Country
Netherlands
Almost a month has past since the last update here :shy:....been busy with the PlayStation 2 port and changing other things to speed the rendering up quite a bit. What I did test recently was if these new changes would make it run any faster on my android phone using the PPSSPP emulator. And at first it was not fast at all so I went digging in the settings and found the CPU core was set to interpreter instead of the Dynarec(JIT) !!!!! That explains why it was running so slow...I feel like an idiot:shy:

I do remember why I had changed it though. When first trying my game on the PPSSPP emulator on my phone it kept crashing a lot and the "interpreter" is supposed to sacrifice speed for accuracy right, so I was hoping that would make it at least run or something. And then completely forgot to check that setting after improving my game so it could run on real hardware! :lol: Setting it to the correct option using the Dynarec (JIT) CPU core makes it run as smooth as it runs on nearly all other platforms I would say. ;)

The only thing that is really missing for the PSP is still the rendering of tiles! I have made some changes that might help in doing it differently on the PSP but it still does not work. Every time I enable the "new method" I only get a blank screen! The good thing though is other improvements seem to be working fine for the PSP, even when I was a little worried it might hurt performance a little to use multiple textures like I am doing. On the other hand.....I guess other games that play in 3D need to swap out textures a lot more than I need to. I have less than 10 of them at the moment :D

Anyway...that's about all I can say for now.
 
  • Like
Reactions: Alexander1970

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-