GP2X Jabber's Log-fire

Discussion in 'General Discussions' started by Mr.Jabberwocky, Sep 21, 2006.

  1. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    Thanks for the valued feedback. If your missus's friend has an original silver model and still has the packaging in good condition, I have seen people selling them for £750.00.
    Since this is 'a how not to guide' I would like to claim that the fact it hangs was intentional. Sadly, this is actually a real bug that I have looked into. It does not happen on my GP2X - but then I may be the only one still running the original firmware. I had forgotten to clear away all my toys before closing down, so there were a couple of buffers that had not been cleared up.
    I am not sure that this is the solution to the problem as I can just about make out the 4-screen effect as it closes down. Does SDL always do this when it closes down, or am I inadvertently writing all over the lcd control registers ? (Unlikely since I am only stringing together a bunch of SDL functions).

    Luckily I put a version number on the front screen. I did not consider that it might be useful and was done more as a joke. It is actually the phone number for the sex-chat line 'Really Rude Girls Behaving Badly' (as I am sure many of you will have recognised).

    However, it will be useful to distinguish one release from another.

    Sadly what I lack in devving skills I also lack in writing ability, but I am pleased you have found it interesting. Thank you.
     
    Last edited by a moderator: Feb 5, 2016
  2. garengarch

    garengarch Member

    Joined:
    Oct 1, 2005
    Messages:
    178
    Location:
    N.Scotland.
    thanks for brightening my day :)

    "Luckily I put a version number on the front screen. I did not consider that it might be useful and was done more as a joke. It is actually the phone number for the sex-chat line 'Really Rude Girls Behaving Badly' (as I am sure many of you will have recognised)."
     
  3. BenScar

    BenScar What does this do again?

    Joined:
    Jan 4, 2006
    Messages:
    435
    Location:
    UK, Near London, somewhere...
    /me shouts "get your coat love we're off to see that friend of yours!" :)
    Are they really that popular?
    Might have to see what's in the attic, can't have thrown everything away!

    *grin* It was intentional, I'll believe that :)

    If you're clearing out the buffers and closing it all down I can't think what you're doing wrong! Time to show off your source code ;-)

    I thought that version number was familiar (found it very funny when I saw it :) )
    Tracking different versions is good fun...

    Your writing skills have taken you this far, can't be all that bad. Same goes for you deving skills, think I may have lost the 2x for a while again while the wife plays your creation to date :)
    I've not attempted sound yet, so your attempts (and success) have started me thinking about what I can use it for now!
     
    Last edited by a moderator: Feb 5, 2016
  4. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    I am sorry, I was not clear. There are actually a couple of buffers that I am not releasing in the version you have. Is that enough to kill linux ? As I said it never happens on my GP2X - but I am running on a totally unmodified, as it came out the box, 'first edition'.

    This should be another golden rule for the 'how not to handbook'. Always ensure you are devving on an obsolete version of the hardware/OS. (An added bonus is if the sound only works 50% of the time.) That way way you are almost guaranteed to be unable to reproduce any reported bugs.

    I will try and update it on ED's site later today and would be grateful if you could tell me if it fixes the 'hanging on exit' feature.
    I am glad she is enjoying it. What is her best score ? Does she want to be the 'official' tester ?

    I think this game is better suited to girls. There is no killing stuff - you are trying to save instead of destroy and you need to keep track of several jumpers at once - something the female brain is far better adapted to.
     
    Last edited by a moderator: Feb 5, 2016
  5. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    There are still a few more things to be implemented - Game B for instance. However, I have updated the file in the archive to include all the latest bugs, so please upgrade to version 0.9.0.8.1.4.1.0.9.5.0. and let me know if you find any of them.

    I would really be interested to know if it still crashes on exit.
     
  6. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    I overlooked mentioning that the second release currently in EvilDragon's archive has the option to switch between black and white and colour. This can be done at any time by pressing the select button.

    Download version 0.9.0.8.1.4.1.0.9.5.0.

    jabberm.jpg
    jabberc.jpg
    If someone could let me know if it still locks up on the latest firmware when exitng I would appreciate it. I should upgrade to the latest firmware but I don't want to do that until I have finished this. Knowing my luck I will probably brick it and I would like to have got this out of the way first.
     
  7. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    I have not really run into any serious problems writing this except for this crashing on exit issue. The only idea I have at the moment is that the SDL example code I have been using to aid my learning explicitly avoids calling the SDL_Quit function for the GP2X build. So I assumed there was a reason and did not call it. Looking around everyone else seems to call it so I have added it in.

    I am non the wiser as it has never crashed on my 'version one firmware' and it still does not. This suggests to me that the first firmware is more robust than the latest and everyone should go back to using it. Since this is unlikely to happen I am going to have to downgrade my firmware to the latest release, as I really don't want keep putting out versions and hoping for some kind soul to test it for me.

    I would like to thank Mr2X for responding to my request to advise if the problem still persisted in the current download.

    I would also like to thank whoever gave this work an exceedingly generous rating of 6. That has made my morning and has boosted my flagging enthusiasm.

    I'm beginning to think I do not have the stamina or attention span for this devving lark - all credit to those who spend months working on something.
     
  8. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    I have always been so disappointed with the GP2X display. For that reason it is only now that I have gotten around to using it much. I actually had to remove a layer of dust from it three weeks ago when I started this.

    Well I have just finished updating the firmware to version 2.00. (from version 1).

    I have never had a problem with USB like so many seem to. In fact I never use a card reader to transfer stuff - always USB. So I checked that out and it still works fine. No problem. It would irritate me if I had to use a reader.

    The ability to move around the menu icons instead of having to access them serially is a vast improvement. Also having the SD selected as the first item in lists is good.

    I have not checked out the players /reader/viewer yet.

    Not forgetting the boot up time (shame about the sound sample).

    But the best thing is the display. It is like having a different machine. The picture is rock steady, the colours are bright, it does not look washed out at high clock speeds.

    It is friggin' brilliant. I am so happy.

    Of course the down-side is that this damn program crashes the machine when I exit it now. However, I have discovered that if I remove all references to SDL_Mixer (losing the sound) it returns to the menu no problem. Still no real idea what the problem is though.

    I'm off to play with my NEW GP2X.
     
  9. YakumoFuji

    YakumoFuji Member

    Joined:
    Sep 30, 2005
    Messages:
    189
    remember to free up your mixing samples and close the mixer properly.
     
  10. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    Thank you, but I have checked and re-checked that aspect as it seemed the most likely cause.

    I am totally baffled. I commented out all the references to the sound mixer and it stopped hanging the system on exit. I then put back just the calls to open and close it. The issue returned. I noticed that I had left the sample size in the Mix_OpenAudio() call at 1024 when I had been experimenting so I set it back to 512. The issue cleared up ! No way I said, and put it back to 1024. The problem did not return. I added back all the sound calls (except I initially missed the Mix_FreeChunk() calls) and it still did not hang on exit. I added the Mix_FreeChunk() calls back in and the problem seems to have gone.

    Against all common sense it seems that the act of editing the Mix_OpenAudio line has corrected the issue. I have undone all the changes I made and saved the edited file as it was, for comparison. The Mix_OpenAudio() call is exactly the same now as it originally was.

    As I said I am baffled. I don't understand it and that is bad but it has already cost me an evening's development time. For the moment I will press on and maybe investigate further when I have put in the remaining features.

    If it ain't broke don't fix it.
     
    Last edited by a moderator: Feb 5, 2016
  11. YakumoFuji

    YakumoFuji Member

    Joined:
    Sep 30, 2005
    Messages:
    189
    maybe a stray pointer or something. valgrind is your friend here... build it on linux and play it (it is after all just sdl) (abstract gp2x button pushes out...) and valgrind it...
     
  12. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    Thanks for the suggestion. I installed linux once and ended up with a corrupted unusable partition and have been too wary to give it another go since. So for the moment I am a non-l33t windows pussy.

    I did intend to ignore the mystery of the' lock up on exit' since it has (almost) gone away, but it irked me so much I have done a bit of experimenting.

    Although it now returns to the launcher on exit more often than not, I found that it will sometimes still hang. Occasionally it will not produce any sound during the game after which it always seems to hang on exit. ( I AM checking the return of the open mixer call ).

    By checking after each of the SDL_free closing down calls I found that it was always the Mix_CloseAudio() function that never returned.

    So there you have it - the SDL_mixer lib is at fault, not me. (This is possibly the golden rule in the 'how not to program' handbook. Always blame the hardware, O/S or tools (anything will do) for your bugs.)

    Of course this does not help me, just makes feel less bad. The fact it was written by someone clever who knew what they were doing whereas I am noodling about with stuff I barely understand, counts against this theory a bit.

    I then remembered that in the wiki the suggestions for the linker parameters are presented with a 'this seems to work' type of approach.

    I had opted for the following suggestion by a careful analysis of the upper surface of a flipped coin:

    I have messed around with these options and tried various combinations and have ended up with the following :

    Using this order of parameters I have yet to have it hang up on me again after a fair bit of testing. I am not going to claim it is fixed until I have tested it a lot more, but I am hopeful.
     
    Last edited by a moderator: Feb 5, 2016
  13. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    So - after vigorous testing, it proved that my last desperate attempt to fix 'THE BUG' was a load of hogwash. Although it appeared to have done the trick, after adding the Game B control stuff the exit issue came back with a vengeance. The problem is that it does not happen on a consistent basis. One time the program exits, the next time it crashes like an Al-Qaida trained pilot.

    Still seeking to lay the blame elsewhere I picked through the tangled mess that I have woven and spotted an early addition that I had lifted out of the wiki. I had thought that since the real G&W devices probably ran at around 1-3.5MHz I should make some attempt at saving power and set the clockspeed nice and low.

    In the Wiki it has this :
    Code:
    void SetClock(unsigned int MHZ)
    {
    #ifdef GP2X
      unsigned int v;
      unsigned int mdiv,pdiv=3,scale=0;
      MHZ*=1000000;
      mdiv=(MHZ*pdiv)/SYS_CLK_FREQ;
    
      mdiv=((mdiv-8)<<8) & 0xff00;
      pdiv=((pdiv-2)<<2) & 0xfc;
      scale&=3;
      v = mdiv | pdiv | scale;
      
      unsigned int l = memregs32[0x808>>2];// Get interupt flags
      memregs32[0x808>>2] = 0xFF8FFFE7;   //Turn off interrupts
      memregs16[0x910>>1]=v;			  //Set frequentie
      while(memregs16[0x0902>>1] & 1);	//Wait for the frequentie to be ajused
      memregs32[0x808>>2] = l;			//Turn on interrupts
    #endif
    }
    
    This looked like just what I needed. Unfortunately, although everyone and his anorak probably knows what SYS_CLK_FREQ and memregs refer to, I don't. So I searched around and found other sources defining these names and hoped they would be the same as this code required. It built and it ran so I forgot about it, believing it was doing the job.

    At any rate, I have removed it, and have not had 'THE BUG' reoccur since. But of course the last attempt seemed to have worked initially.....

    Has anyone got the required definitions for the wiki function, please ?
     
  14. Daid

    Daid Member

    Joined:
    Jun 13, 2006
    Messages:
    267
    Location:
    Netherlands
    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <fcntl.h>
    #ifdef WIN32
    #else
    #include <sys/mman.h>
    #include <linux/fb.h>
    #include <unistd.h>
    #include <stropts.h>
    
    int memfd;
    
    volatile unsigned long *memregs32;
    volatile unsigned short *memregs16;
    
    unsigned char initphys (void)
    {
    	memfd = open("/dev/mem", O_RDWR);
    	if (memfd == -1)
    	{
    		printf ("Open failed for /dev/mem\n");
    		return 0;
    	}
    
    	memregs32 = (unsigned long*) mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xc0000000);
    	
    	if (memregs32 == (unsigned long *)0xFFFFFFFF) return 0;
    	memregs16 = (unsigned short *)memregs32;
    
    	return 1;
    }
    
    void closephys (void)
    {
    	close (memfd);
    }
    #endif
    
    #define SYS_CLK_FREQ 7372800
    
    void SetClock(unsigned int MHZ)
    {
    #ifdef WIN32
    #else
    	if (!initphys()) return;
    	
      unsigned int v;
      unsigned int mdiv,pdiv=3,scale=0;
      MHZ*=1000000;
      mdiv=(MHZ*pdiv)/SYS_CLK_FREQ;
    
      mdiv=((mdiv-8)<<8) & 0xff00;
      pdiv=((pdiv-2)<<2) & 0xfc;
      scale&=3;
      v = mdiv | pdiv | scale;
      
    	unsigned int l = memregs32[0x808>>2];// Get interupt flags
      memregs32[0x808>>2] = 0xFF8FFFE7;   //Turn off interrupts
      memregs16[0x910>>1]=v;			  //Set frequentie
      while(memregs16[0x0902>>1] & 1);	//Wait for the frequentie to be ajused
      memregs32[0x808>>2] = l;			//Turn on interrupts
    
    	closephys();
    #endif
    }
    
    unsigned int GetClock()
    {
    #ifdef WIN32
      return 303;
    #else
    	if (!initphys()) return 0;
    	
      unsigned int i;
      unsigned int reg,mdiv,pdiv,scale;
    
      reg = memregs16[0x912>>1];
      mdiv = ((reg & 0xff00) >> 8) + 8;
      pdiv = ((reg & 0xfc) >> 2) + 2;
      scale = reg & 3;
      
      i = (memregs16[0x91c>>1] & 7)+1;
    
    	closephys();
    
      return ((SYS_CLK_FREQ * mdiv) / (pdiv << scale)) / i;
    #endif
    }
    
     
    Last edited by a moderator: Feb 5, 2016
  15. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    Thanks Daid. Without the dodgy method of clock setting the problem seems to have gone away.

    I have not had a chance to try this yet but will give it a go as soon as I get a chance.

    This needs to be put in the wiki as the current entry is incomplete and virtually useless to someone like me.

    Currently the program plays Game A and B. It just needs a High Score table and some sort of user interface. I am hoping to have it run a demo mode with the options overlaid but I still need to implement some sort of text functionality.

    Thank goodness it is almost finished.
     
    Last edited by a moderator: Feb 5, 2016
  16. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    I have had a go with these functions but the results are the same. The code is using exactly the same values I had before so that is no surprise.

    This has wasted so much time.

    I have found this thread where jrd had exactly this same issues, but using rlyeh's mini lib. Unfortunately there is no posted conclusion / solution.

    He is also using a different value for SYSTEM_CLOCK !!!??? I am beginning to think this clock setting lark has not been fully cracked yet.

    Looking at the SetClock function makes me wonder. What exactly is going on with the variable unsigned int scale ?

    Set it to 0 - OK. We got 0.
    And it with 3 - OK. We still got 0.
    Or 0 into something - OK. Complete waste of time, surely ?

    Another reason I am doubtful of this code is that I tried to record the initial clockspeed and reinstate it on exit. It seemed to me that calling GetClock() on entry, storing it, and using the returned value with SetClock() on exit, would be the way forward. This results in an effect similar to old TV's that are not tuned into a signal - looks like a snowstorm.

    Can anyone explain to me what is going on in this kind of reference -> memregs32[0x808>>2] ?

    Presumably is does not convert to memregs32[0x202] or it would be written that way. The only thing I can think is that it is referring to the top 16 bits of ( memregs32 + 0x808 ). Is that correct ?

    I am giving up on setting the clock speed - it has caused me enough grief and delay.
     
    Last edited by a moderator: Feb 5, 2016
  17. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    How has it taken a month to put this simple little thing together !?

    It is finished in my opinion and will be available soon. I have spent the last couple of days testing it. The locking up on exit issue has gone since removing the clock speed code calls. That is a big mystery to me still - why did it not kill version 1.00 firmware ?

    I see Guyfawkes has put an up to date SDL archive into Evil Dragon's archive. I have no idea what SDL libraries I have been using - they are just what was installed when following the wiki guide for setting up codeblocks. Having a way to get the latest versions is such a good idea.
    Unstickying this thread and replacing it with a reference to the SDL archive would be a much better use of the 'Sticky' feature. I shall be referring to his guide (another invaluable contribution) and installing them later.

    Thanks to Guyfawkes and EvilDragon for all they do for the community and to Hando for giving us a home. And of course to everyone else who has done so much to make the GP2X accessible to us. Without their hard work dummies like me would be totally lost - (although some probably wish I still was).

    This has been quite a fun experience for me and I would recommend anyone to have a go. I must have learnt something doing this, even if it is just how to look up sdl functions using Google.

    I hope this has inspired others to have a go. Installing codeblocks was a breeze and it seems to be a mighty fine IDE. There is a load of information on C and SDL out there and there is always gp32x.de if you have a question. So lets fill ED's archives with homebrew - yay!

    COMING SOON - How not to remake Knight Lore on the GP2X.
     
    Last edited by a moderator: Jan 2, 2016
  18. Mr.Jabberwocky

    Mr.Jabberwocky Bloke with a brick on his head

    Joined:
    Sep 27, 2005
    Messages:
    402
    FIRE - Final release now available * FREE*


    1 building, 1 mission, some little stick figures and an ambulance - which has a light.

    It's taken about a month but finally the full game is here, an exclusive & updated version of Fire has arrived on the GP2X.

    The Nintendo Game & Watch smash hit Fire has limped onto the GP2X with some serious flames. (Well a bit of smoke actually).

    jabberbc.gif

    Updated for the GP2X with all new graphics, and a high score table - creating an awesome 80's handheld game which will quite literally make your fingers ache.

    It's time for Fire - the reason the GP2X has a delete function.

     
  19. BradN

    BradN Member

    Joined:
    Jun 22, 2003
    Messages:
    577
    I think it's referring to a register number 0x808 according to the documentation, but due to how the logic is connected to the address bus, it probably requires shifting the relative address right by 2 bits. memregs32[] is just a reference to the memory mapped registers, and the index gets added to it.

    Just to totally confuse you, ponder this bit of C trivia... array[index] and index[array] are identical functionally.
     
    Last edited by a moderator: Feb 5, 2016
  20. frutbunn

    frutbunn Member

    Joined:
    Aug 30, 2006
    Messages:
    215
    Location:
    The East Wing
    Jabberwocky,

    I was going to write a Knight Lore game a few months ago but don't have the time now... I did however find the following useful resources on the net:


    Image of every single room in Knight Lore:
    http://www.btinternet.com/~fishyfish/images/KnightLore.png

    Data formats (includes background graphics):
    http://www.icefear.com/dataformats/knightlore/index.html

    The sprite-sheet:
    http://www.icefear.com/downloads/files/sprites.zip

    Knight Lore walk through on Google Video:
    http://video.google.com/videoplay?docid=-7...p;q=knight+lore


    The original Spectrum tape image is not available (thanks Rare...), but the BBC Micro version is available (maybe its development was contracted out?).

    May save you some searching time!


    PS: This is my first post on GP32x, so hello everyone!
     
    Last edited by a moderator: Feb 5, 2016

Share This Page

Loading...