Corrosion. Posted May 26, 2008 Share Posted May 26, 2008 Hello, I'm working on creating a psp magazine viewer for the Sony PSP. I'm writing it in sdlbasic because the interperater was just released on the psp. The problem is on the psp once it gets to page 9 the psp freezes and crashes. It works during computer testing, my guess is that I don't have enough memory on my psp. I was thinking to use a memory bank but seeing as this is my first time coding I have no idea and the forums for sdlbasic are not very active. Can you guys help me? Here is my source: ' sdlBasic PSP 0.5 ' ' Name: PSPMag ' Purpose: To view psp magazines without using the image viewer ' Author: PSPHeaven/Acer5050 http://pspheaven.net webmaster@pspheaven.net ' Licence: LGPL ' '----------------------------------------------------------------------------------------------------------------------------------------------------------------- prints("PSPHeaven's Magazine Viewer") prints("Created In SDLBasic") prints("Alpha 0.1") prints("PSPHeaven.Net") prints("Will Automaticaly Exit At End") prints("Just as a test this has XMag #1 Included") prints("Press [X] To start and to goto the next page") waitkey(k_return) cls image1=loadimage("media/001.jpg") pastebob(0,0,image1) waitkey(k_return) cls image2=loadimage("media/002.jpg") pastebob(0,0,image2) waitkey(k_return) cls image3=loadimage("media/003.jpg") pastebob(0,0,image3) waitkey(k_return) cls image4=loadimage("media/004.jpg") pastebob(0,0,image4) waitkey(k_return) cls image5=loadimage("media/005.jpg") pastebob(0,0,image5) waitkey(k_return) cls image6=loadimage("media/006.jpg") pastebob(0,0,image6) waitkey(k_return) cls image7=loadimage("media/007.jpg") pastebob(0,0,image7) waitkey(k_return) cls image8=loadimage("media/008.jpg") pastebob(0,0,image8) waitkey(k_return) cls image9=loadimage("media/009.jpg") pastebob(0,0,image9) waitkey(k_return) cls image10=loadimage("media/010.jpg") pastebob(0,0,image10) waitkey(k_return) cls image11=loadimage("media/011.jpg") pastebob(0,0,image11) waitkey(k_return) cls image12=loadimage("media/012.jpg") pastebob(0,0,image12) waitkey(k_return) cls image13=loadimage("media/013.jpg") pastebob(0,0,image13) waitkey(k_return) cls image14=loadimage("media/014.jpg") pastebob(0,0,image14) waitkey(k_return) cls image15=loadimage("media/015.jpg") pastebob(0,0,image15) waitkey(k_return) cls image16=loadimage("media/016.jpg") pastebob(0,0,image16) waitkey(k_return) cls image17=loadimage("media/017.jpg") pastebob(0,0,image17) waitkey(k_return) cls image18=loadimage("media/018.jpg") pastebob(0,0,image18) waitkey(k_return) cls image19=loadimage("media/019.jpg") pastebob(0,0,image19) waitkey(k_return) cls image20=loadimage("media/020.jpg") pastebob(0,0,image20) waitkey(k_return) cls image21=loadimage("media/021.jpg") pastebob(0,0,image21) waitkey(k_return) cls image22=loadimage("media/022.jpg") pastebob(0,0,image22) waitkey(k_return) cls image23=loadimage("media/023.jpg") pastebob(0,0,image23) waitkey(k_return) cls image24=loadimage("media/024.jpg") pastebob(0,0,image24) waitkey(k_return) cls image25=loadimage("media/025.jpg") pastebob(0,0,image25) waitkey(k_return) cls image26=loadimage("media/026.jpg") pastebob(0,0,image26) waitkey(k_return) cls image27=loadimage("media/027.jpg") pastebob(0,0,image27) waitkey(k_return) cls image28=loadimage("media/028.jpg") pastebob(0,0,image28) waitkey(k_return) image29=loadimage("media/029.jpg") pastebob(0,0,image29) waitkey(k_return) Quote Link to comment Share on other sites More sharing options...
moonlit Posted May 26, 2008 Share Posted May 26, 2008 Try unloading the images when you switch to another. It'll be slightly slower because each page will be opened on the fly, but it'll solve memory issues. Also, you might wanna add a function to turn the page back too. Actually, looking at the source, you could probably do this: image1=loadimage("media/001.jpg") pastebob(0,0,image1) waitkey(k_return) cls image1=loadimage("media/002.jpg") pastebob(0,0,image1) waitkey(k_return) cls image1=loadimage("media/003.jpg") pastebob(0,0,image1) waitkey(k_return) cls (...and so on) If you can use variables in the file names you could skip the numbers in the code altogether and just increase or decrease the number stored in a variable, this way you don't have to hardcode every possibly page. You could then add 000.jpg and [lastpage+1].jpg as front and back pages saying you're at the start/end of the magazine, and to either flip forward (if it's the first page) or back (if it's the last page) and to flip forward on the last page to quit. It'd be more efficient it terms of code length too. Perhaps something like: pagenum=0 'Start with the first page, 'probably the front cover. '---------------------------------------------------------- Start of loop. cls 'Clear the screen. pageimg=loadimage("media/"&pagenum&".jpg") 'Copy the page you're on to the buffer. pastebob(0,0,pageimg) 'Display the image. waitkey(k_return) 'Wait for the button press. 'Modify this to check which 'button if you want to be able 'to turn forward and back. pagenum=pagenum+1 'Turn the page forward. Will 'need to be -1 if turning 'the page back. '---------------------------------------------------------- End of loop, check the user 'didn't go past the last page, 'if they did, quit. If they 'didn't, loop back to cls. I don't know the language so you'll have to fine tune that, but it's probably a better way to carry out the task in hand. The example I gave there would use filenames without leading zeros, you could fix that with some simple formatting of the numbers, and the forward/back page turning will have to check for the appropriate button press and increase or decrease pagenum accordingly. Shouldn't be that hard though. Quote Link to comment Share on other sites More sharing options...
moonlit Posted May 26, 2008 Share Posted May 26, 2008 pagenum=1 drawpage(pagenum) do if bjoy(0) then pagenum=pagenum-1 drawpage(pagenum) elseif bjoy(1) pagenum=pagenum+1 drawpage(pagenum) elseif bjoy(2) end endif loop sub drawpage(page) cls if fileexists("media/"&page&".jpg") then pageimg=loadimage("media/"&page&".jpg") pastebob(0,0,pageimg) else end endif end sub Should be a complete and functioning program. Not sure how the PSP handles button input, but it's easy enough to modify the input sections for whatever kind of input you need. I'd comment it but I'm pissed off with the code tags and formatting, so I won't. It's not hard to read though. Files should be named without leading zeros. Joystick button 1 turns the page back, button 2 turns forward and button 3 quits. Quote Link to comment Share on other sites More sharing options...
Corrosion. Posted May 26, 2008 Author Share Posted May 26, 2008 Thanks for your help :) I still seem to be getting crashes though at the same spot. But I can definetly use that to cleanup the code and get a back button in, thanks again. :) btw how'd u figure out who i wuz? oh i kno :) lol my domain..... Yeh I decided to get a new acct....... Trying not to ask to many questions and kinda start over..... :) Quote Link to comment Share on other sites More sharing options...
digip Posted May 27, 2008 Share Posted May 27, 2008 Thanks for your help :) I still seem to be getting crashes though at the same spot. But I can definetly use that to cleanup the code and get a back button in, thanks again. :) btw how'd u figure out who i wuz? oh i kno :) lol my domain..... Yeh I decided to get a new acct....... Trying not to ask to many questions and kinda start over..... :) Have you tried using all but that one image. Maybe it can't read the image, or it is corrupt to the PSP standards of what it can read. Skip that image or leave it out all together and see what happens. Quote Link to comment Share on other sites More sharing options...
Corrosion. Posted May 27, 2008 Author Share Posted May 27, 2008 Have you tried using all but that one image. Maybe it can't read the image, or it is corrupt to the PSP standards of what it can read. Skip that image or leave it out all together and see what happens. I got some help from the developer of the port :) Now I just need to make it close the app once it runs out of images instead of crashing, lol :) i=1 while 1 cls if (i<10) then image=loadimage("media/00" & i &".jpg",0) else image=loadimage("media/0" & i &".jpg",0) end if pastebob(0,0,image) waitkey if key(K_down) then i=i+1 end if if key(K_up) then i=i-1 end if end while Quote Link to comment Share on other sites More sharing options...
moonlit Posted May 27, 2008 Share Posted May 27, 2008 I got some help from the developer of the port :) Now I just need to make it close the app once it runs out of images instead of crashing, lol :) I showed you that in my rewrite above, use "if fileexists" to see if there's another page after the one you're looking at. If not, quit. Edit: ...and excuse my saying so, but I much prefer my version of the program, I feel it's much cleaner. Still, whatever works. Quote Link to comment Share on other sites More sharing options...
Corrosion. Posted May 27, 2008 Author Share Posted May 27, 2008 I was unable to run your version :/ anyway thanks for your help I still found it useful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.