PacMan hardware

Discussion about other targets
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

In my information such examples do not exist.

https://www.walkofmind.com/programming/pie/hardware.htm

To refer to variable locations you might, in example, use our sccz80 slang:

char spr0_x @0x5060;

or, you could define a structure

Remember that the graphics are in a ROM chip, you'll display PACMAN characters unless you won't encode a new rom
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Fri Oct 14, 2022 10:54 pm In my information such examples do not exist.

https://www.walkofmind.com/programming/pie/hardware.htm

To refer to variable locations you might, in example, use our sccz80 slang:

char spr0_x @0x5060;

or, you could define a structure

Remember that the graphics are in a ROM chip, you'll display PACMAN characters unless you won't encode a new rom
I declared spr0_x as a global variable:

Code: Select all

char spr0_x @0x5060;

void main()
{
int i;

	SetupLevel(); /* Display the first level */

	spr0_x=112;
	/* Loop keyhandler till you finished the game */
	while (CheckNotFinished())
	  Gamekeys();
}
But, after I checked the 5060 register through the MAME debugger, all registers till 5070 turned out to be filled by FF value.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

I'm not sure those value can be read back
https://github.com/mamedev/mame/blob/ab ... .cpp#L1027

MAME sources include interesting comments, too

https://github.com/mamedev/mame/blob/ab ... an.cpp#L45
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

What is the best way to set the sprite ID bits in the 4FF0h register?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

Just guessing, because I never did sprite stuff with pacman: what about #defining constants for the bits and using the | OR operator ?

https://stackoverflow.com/questions/293 ... -constants
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

That's how the main function looks now:

Code: Select all

#define spr0 @0x4FF0|0xFC

char spr0_x @0x5060;

void main()
{
int i;

	SetupLevel(); /* Display the first level */

	spr0=0x2c;
	spr0_x=112;
	/* Loop keyhandler till you finished the game */
	while (CheckNotFinished())
	  Gamekeys();
}
But every time I try to build a new code, compiler gives me such error:

Code: Select all

C:\Users\user\Downloads\z88dk\examples\pacman>make
zcc  +pacman -vn -c dstar.c
dstar.c:71:3: error: Invalid expression
dstar.c:71:4: fatal error: Expected ';'
Compilation aborted
make: *** [Makefile:37: dstar.o] Error 1
The most funny thing here is that symbols of 71st line before fifth is occupied with an indent.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

It must be the '@' hack.
Please try compiling it with a normal 'char' declaration, if it works, please try by inserting it back with the address in decimal.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Sun Oct 16, 2022 10:56 am It must be the '@' hack.
Please try compiling it with a normal 'char' declaration, if it works, please try by inserting it back with the address in decimal.

Code: Select all

char spr0 @0x4FF0|0xFC;

char spr0_x @0x5060;

void main()
{
int i;

	SetupLevel(); /* Display the first level */

	spr0=0x2c;
	spr0_x=112;
	/* Loop keyhandler till you finished the game */
	while (CheckNotFinished())
	  Gamekeys();
}
No any sprites are shown.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

so, I suppose you solved the compile error.
That bitwise expression seems strange to me:

char spr0 @0x4FF0|0xFC;

what are you willing to do?
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Sun Oct 16, 2022 9:33 pm so, I suppose you solved the compile error.
That bitwise expression seems strange to me:

char spr0 @0x4FF0|0xFC;

what are you willing to do?
To insert a 2c value to the 2-7 bits. FC is a 11111100 number represented in the hex form.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

char spr0 @0x4FF0;

spr0=0x2c|0x...

You have no way to touch only some bit.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Mon Oct 17, 2022 3:20 pm char spr0 @0x4FF0;

spr0=0x2c|0x...

You have no way to touch only some bit.
Still there no any visible sprites anyway.
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: PacMan hardware

Post by jorgegv »

Shouldn't that be this?

char spr0 @0x4FF0;

spr0 |= 0x2c;
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

You can't do that, because it is not a memory address but a write only mapped port. You can't predict the value you will get, so you'll just add dirt to your values.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Tue Oct 18, 2022 5:51 pm You can't do that, because it is not a memory address but a write only mapped port. You can't predict the value you will get, so you'll just add dirt to your values.
So what should I do then?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

I think the only way is to always write all the bits.
If you wish to keep the previous value, you could store a copy in a variable.

unsigned char spr0 @0x4FF0;
unsigned char spr0_save=0;

spr0_save|=0x02c;
spr0=spr0_save;



spr0=0x2c|0x...
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

Code: Select all

unsigned char spr0 @0x4FF0;
unsigned char spr0_save=0;

char spr0_x @0x5060;

void main()
{
int i;

	SetupLevel(); /* Display the first level */

	spr0_save|=0x02c;
	spr0=spr0_save;
	
	spr0=0x2c|0xfc;
	spr0_x=112;
	/* Loop keyhandler till you finished the game */
	while (CheckNotFinished())
	  Gamekeys();
}
It doesn't work again. Maybe, it should to put

Code: Select all

spr0_save|=0x02c;
spr0=spr0_save;
to the functions with an infinite loop?
Post Reply