Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

zomg! Code!

Sign in to follow this  


So, if you remember, a while ago I was waffling about memory management on the GP2x and how if you wanted to use the higher memory and trampled all over the area which the hardware decoder controlling code sits you wont be able to play back video without first restarting.

Before my machine blew up I made a post on the GP32x.com message board asking about some details todo with the higher memory and the conclusion which was reached was the only way todo it was to make a copy of the code area and reload it before the program quits.

So, today I finally got off my arse and openned my IDE for the first time in weeks and wrote a couple of lines of code;

unsigned long memptr = open("/dev/mem", O_RDWR);
unsigned long * decoderram = (unsigned long *)mmap(0, 0x1000000-0x4B000*8-0x4000, PROT_READ|PROT_WRITE, MAP_SHARED, memptr, 0x03000000);
unsigned long * backupram = (unsigned long *)malloc(0x100000);

This basically maps the higher ram into the programs address space, creates a buffer and then copies 1meg of ram from the higher memory to the backup buffer (this value is arbitary right now, a proper metric could be worked out later).

Then, before the program quits you simply copy the buffer back again. A quick test shows that this infact works perfectly, although it does cost 1meg of ram. However, I dont see this being a huge problem. When programs run they have alot of ram to play with anyways and the idea behind this system is that all large resouces should end up in the higher 32meg of ram anyways, so losing one meg of the lower 32meg shouldnt phase things too much.

So, I need to intergrate this into my memory manager and update it so instead of having 2 frames it has 4 to work with, one of which being the frame for storing program information in.

In other news, I've placed an order for Game Programming Gems 6, its got some stuff on Multi-threading in games and co-routines with Lua, which on its own should be intresting (and maybe even helpfull for my degree, heh) and there is some other stuff I'm sure I'll read as well. Down side is Amazon say it'll be a few weeks before its dispatched... suckage [sad]
Sign in to follow this  

1 Comment

Recommended Comments

There are some good articles in GPGems 6. I had mine preordered!

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!