GP2X Jabber's Log-fire


BradN posted on Oct 22 2006 at 09:42 AM said:
Mr.Jabberwocky posted on Oct 18 2006 at 07:29 AM said:
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.

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.


Simple example:

Code:
// Pointers to Magic-Eyes hardware registers:
volatile unsigned short *hardware_regs16;
volatile unsigned int *hardware_regs32;

// Map it:
	int devmem_fd;

		/* Allow access to MMSP2 hardware registers:
		 */
		if ( (devmem_fd=open("/dev/mem", O_RDWR)) == 0 ) {
				fprintf(stderr, "Could not open /dev/mem,"
				 " are you sure you're root?\n");

				return 1;
		}
		if ( (hardware_regs32=mmap(0, 0x10000, 3, 1, devmem_fd, 0xC0000000))
		  == MAP_FAILED ) {
				fprintf(stderr, "Call to mmap failed, are you sure"
				 " you're root?\n");

				return 1;
		}

	hardware_regs16 = (unsigned short*) hardware_regs32;

// Write to hardware registers (set to 8 bit color depth):
	hardware_regs16[0x28DA>>1] = 0x02AB;	// 8bbp
	hardware_regs16[0x290C>>1] = 320;	// width;

Most of the Magic-Eyes hardware registers are 16 bit, so if we map a C pointer to the base of the hardware registers at 0xC0000000 (using mmap), we want to easily say which register we want to set. The easiest way is to index that pointer is to use the [n] notation.

So, to set the hardware register 0xC0000002AB, I've mapped hardware_regs32 and hardware_regs16 to point to 0xC00000000 in memory. If I add a displacement to hardware_regs16, then I can assume that hardware_regs16 points to the real address of 0xC0000000, and my index (in the []) points to the offset from that base. So, it's indexed from 0, so adding an offset of 0x02AB will offset 0xC0000000 by 0x02AB bytes!

But! No it won't, because an unsigned short is a 16 bit data type, so it will index from 0xC000000 by TWICE that amount! Remember in C an index is an offset multipled by the size of the variable data type. So char mystring[10] is &mystring+10, but unsigned short myint[10] is actually &myint+(10*2), as the unsigned short is two bytes long.

So we need to divide our pointers offset by the number of bytes the data type uses. So for hardware_regs16 we divide by 2 (or use a logical shift of 1), for hardware_regs32 we divide by four (or use a logical shift of 2). So that's what the >>2 is for!

Hope this helps, I'm not that good at explaining things!
 
Last edited by a moderator:
Welcome to the board.

Thank you very much for the information. This has been my only attempt at a GP2X game and is a rather simple little game. The Knight Lore comment was a joke - although I would love to give it a go. I think it may be a little beyond my abilities.

Perhaps I should hold a poll :

Should Jabber make a complete dick of himself and try to recreate Knight Lore Y/N

Now you have been so kind as to provide these links I feel obliged to at least give it some serious thought. It could be a couple of years in the making though.

Although the original Spectrum tape image is not available officially I remember having no trouble finding it last time I looked. I lost my hard disc a while back so I don't have it now - in fact a quick google for knightlore.tap while writing this has found it.

I guess I better go and install an emu and see if it works- any recommendations ? M.E.S.S. sounds cool.

Thanks for the info on the hardware registers. I have yet to really understand it - I'm a bit dense.

*** EDIT - having read it a second time your explanation is clear - thank you, I now understand ***

Is there a simpler explanation of the device than their data sheet ? I have looked at that and it is way over my head.

I need a nice little manual written in plain English explaining in simple terms and pictures how the thing is laid out.

Are the registers always at 0xC0000000 or is that implemented by the manufacturer of the device it is used in ? Having learned that the registers are at that address how do we know what they are ?

I have specifically looked for this information in the data sheet but it is like an alien language to me.

I have also looked for other material but with no luck. Can you recommend anything ? Please.
 
Mr.Jabberwocky posted on Oct 23 2006 at 12:15 AM said:
Thank you very much for the information. This has been my only attempt at a GP2X game and is a rather simple little game. The Knight Lore comment was a joke - although I would love to give it a go. I think it may be a little beyond my abilities.

Perhaps I should hold a poll :

Should Jabber make a complete dick of himself and try to recreate Knight Lore Y/N

Now you have been so kind as to provide these links I feel obliged to at least give it some serious thought. It could be a couple of years in the making though.

Don't worry, I had the details in a file so I just cut&pasted it!

You could do an 'Atic Atac' clone, that would be much easier to implement:

http://www.icefear.com/dataformats/aticatac/index.html
http://www.icefear.com/downloads/files/sprites.zip

I guess I better go and install an emu and see if it works- any recommendations ? M.E.S.S. sounds cool.

One of the GP2x Spectrum emulators I tried is really good, but my GP2x has decided to fry the SD card (again) so can't tell you which one... :angry:

Is there a simpler explanation of the device than their data sheet ? I have looked at that and it is way over my head.

I need a nice little manual written in plain English explaining in simple terms and pictures how the thing is laid out.

Are the registers always at 0xC0000000 or is that implemented by the manufacturer of the device it is used in ? Having learned that the registers are at that address how do we know what they are ?

I have specifically looked for this information in the data sheet but it is like an alien language to me.

I have also looked for other material but with no luck. Can you recommend anything ? Please.

I think the Magic-Eyes documentation is the only source for details of the hardware registers. It's the only one I've found so far...

SDL is probably the best way to go. It's my personal choice anyway! :D
 
Last edited by a moderator:
Id rather see a head over heels conversion isntead of knightlore ;) probably just as hard to implement tho...

jabber, you could try a conversion of a dual screen game like green house, use triggers to flip between screen...
 
YakumoFuji posted on Oct 23 2006 at 04:47 PM said:
Id rather see a head over heels conversion isntead of knightlore ;) probably just as hard to implement tho...

jabber, you could try a conversion of a dual screen game like green house, use triggers to flip between screen...
I would like to see Head over Heels too. :) It has some 300 rooms as opposed to around 128 so it would be a much bigger job. Has anyone come across the sprites for it ?

I am going to see if I can knock together something that will generate an isometric, room by room play area. If I succeed it could be used for either I guess. How about remaking Atic Atac as an isometric game ?
 
Last edited by a moderator:
I have the Head over Heels Pc remake (and Atic Atac). Awsome. Double our screen res tho'.

Thanks for the sprite ripping tip. Due to a natural flair for idleness I was hoping someone had already made them available, but it is good to know I can do it myself (if I have to). It might be fun just to play with.
 
Hello there... 'Mr.Jabberwocky'...

I've just tried this game and found it great. Very entertaining and I like the new colour mode.

I'm a developer working in VB.Net and Coldfusion. I've just got my dev environment setup with Codeblocks (GP2X) and I’ve just started my own project which is a remake of "Monaco GP (1979) with a few twists" think the dates correct :) .

Anyway I found this a very useful log of you're development and it will certainly help me with my project.


All the best...
 
twojame said:
Hello there... 'Mr.Jabberwocky'...
Hi twojame

Thanks for the compliment. I feel particularly honoured since it has prompted only your second post in almost two years of membership :)

Monaco GP looks good. A little more involved than Game & Watch :lol:

Best of luck - let us know how it is coming along.
 
Last edited by a moderator:
Mr.Jabberwocky said:
twojame said:
Hello there... 'Mr.Jabberwocky'...
Hi twojame

Thanks for the compliment. I feel particularly honoured since it has prompted only your second post in almost two years of membership :)

Monaco GP looks good. A little more involved than Game & Watch :lol:

Best of luck - let us know how it is coming along.


Hi there

Yes I’ve been monitoring and reading these forums for quite some time, but I’ve only just got my GP2x and I love this thing. I just found you're game to be particually effective and it impressed me no end.

My coding background is almost entirely in Vb.NET/VB6 so I’m very excited about working with the GP2x and the C++ language. Although the language barrier is still proving to be difficult for me.

I've found you're blog and the demo app to be invaluable in helping me get started. Once I get my demo of Monaco GP up and running them I’ll post it and hopefully it will help other first time GP2x dev's like me. At the moment i'm looking into how I will do the engine that draws the actual road in 2d.


Rgds...
 
Last edited by a moderator:
DJ Amireh said:
Hello Mr.Jabberman, could you post your source code? I would like to study it ;)
You are obviously insane so I have uploaded it to the archives for you.

If you can work out whats going on let me know, I can't make head nor tail of it.

I suppose you want a link as well.
 
Last edited by a moderator:
Back
Top