PacMan hardware

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

PacMan hardware

Post by stefano »

Robert from the MAME team asked me to build a copy of the TETRIS game created by for the PACMAN hardware.
I had to slightly adapt the build and configuration scripts to match the z88dk and MAME projects evolution, so here are the fix steps:

- get the current/latest z88dk nightly build

- get the tetris sources and unzip it somewhere: http://forum.gadgetfactory.net/index.ph ... acman-r30/

- get "srec" and install it (or just put srec_cat in a valid path executable position, it can be just the "tetris" folder if you are using windows.. http://srecord.sourceforge.net/windows.html)

- the PACMAN (puckman) roms slightly changed in MESS so it is preferrable to use the "puckmod" game: create an empty folder into the "tetris" one and rename it to "puckmod" (you can get rid of "puckman"). Some of them will be rewritten during the build process.

- get the "puckmod" roms and put a copy in the new folder

- run the following updated makefile (it will use the new z88dk configuration for the pacman HW and skip the local one):

Code: Select all

CC=zcc
LINK=z80asm
SREC_CAT=srec_cat
MAME=/c/z80/mess/mame

C_FILES=main.c game.c sound.c
OBJECT_FILES=$(C_FILES:%.c=src/%.o)

MAME_DIR=puckmod
MAME_FILES=namcopac.6e  namcopac.6f namcopac.6h  npacmod.6j

test: $(MAME_FILES:%=$(MAME_DIR)/%)
        $(MAME) $(MAME_DIR)

clean:
        rm -f $(MAME_FILES:%=$(MAME_DIR)/%)
        rm -f rom.o src/*.o
        rm -f zcc_opt.def

$(MAME_DIR)/namcopac.6e: rom.o
        $(SREC_CAT) $< -binary -crop 0x0000 0x1000 -fill 0x00 0x0000 0x1000 -offset 0x0000 -o $@ -binary
$(MAME_DIR)/namcopac.6f: rom.o
        $(SREC_CAT) $< -binary -crop 0x1000 0x2000 -fill 0x00 0x1000 0x2000 -offset -0x1000 -o $@ -binary
$(MAME_DIR)/namcopac.6h: rom.o
        $(SREC_CAT) $< -binary -crop 0x2000 0x3000 -fill 0x00 0x2000 0x3000 -offset -0x2000 -o $@ -binary
$(MAME_DIR)/npacmod.6j: rom.o
        $(SREC_CAT) $< -binary -crop 0x3000 0x4000 -fill 0x00 0x3000 0x4000 -offset -0x3000 -o $@ -binary

rom.o: $(OBJECT_FILES)
        $(CC) +pacman $(OBJECT_FILES) -o $@

src/%.o: src/%.asm
        $(CC) +pacman -defvars=0x4c00 -c $<

src/%.o: src/%.c
        $(CC) +pacman -c $<
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I slightly changed the PacMan port to permit the classic programs to be built without having to provide support code for the Interrupts.

Code: Select all

CC=zcc
SREC_CAT=srec_cat
MAME=/c/mame/mame

C_FILES=main.c game.c sound.c
OBJECT_FILES=$(C_FILES:%.c=src/%.o)

MAME_DIR=puckmod
MAME_FILES=namcopac.6e  namcopac.6f namcopac.6h  npacmod.6j

test: $(MAME_FILES:%=$(MAME_DIR)/%)
        $(MAME) $(MAME_DIR)

clean:
        rm -f $(MAME_FILES:%=$(MAME_DIR)/%)
        rm -f rom.o src/*.o
        rm -f zcc_opt.def

$(MAME_DIR)/namcopac.6e: rom.o
        $(SREC_CAT) $< -binary -crop 0x0000 0x1000 -fill 0x00 0x0000 0x1000 -offset 0x0000 -o $@ -binary
$(MAME_DIR)/namcopac.6f: rom.o
        $(SREC_CAT) $< -binary -crop 0x1000 0x2000 -fill 0x00 0x1000 0x2000 -offset -0x1000 -o $@ -binary
$(MAME_DIR)/namcopac.6h: rom.o
        $(SREC_CAT) $< -binary -crop 0x2000 0x3000 -fill 0x00 0x2000 0x3000 -offset -0x2000 -o $@ -binary
$(MAME_DIR)/npacmod.6j: rom.o
        $(SREC_CAT) $< -binary -crop 0x3000 0x4000 -fill 0x00 0x3000 0x4000 -offset -0x3000 -o $@ -binary

rom.o: $(OBJECT_FILES)
        $(CC) +pacman $(OBJECT_FILES) -o $@

src/%.o: src/%.asm
        $(CC) +pacman -startup=2 -c $<

src/%.o: src/%.c
        $(CC) +pacman -c $<
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

What is a fastest and easiest way to edit the MAME games database for Pac-Man HW developers?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

in the past the "puckmod" trick, I'm not 100% sure it still works.
I think tha MAME requires the exact ROM set and often is restricted to the exact checksum, I don't know whether this restriction could be skipped without rebuilding MAME.
The only suggestion I have is to avoid the zip archives and to create a folder under roms

EDIT:
developing an accurate game would probably require a bit of customization, you could provide your custom character ROM, etc..
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

Do you have a full MSYS set with all necessary packages installed beforehand and MAME sources, whose buildability is tested and proved already? I have tormented so much, when tried to build the custom MAME build by myself!
Last edited by VasiliyFamiliya on Wed Oct 05, 2022 3:55 am, edited 1 time in total.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

The MAME/MESS team provides it in a monolithic bundle, there's no need to feed a virgin MSYS with the extra libraries.
I don't fully understand the MAME build refusing different ROM sets and.. not providing the "official' ones :)
Probably any older MAME suffices, if you can't find a way to fit your custom ROMs
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Tue Oct 04, 2022 4:12 pm in the past the "puckmod" trick, I'm not 100% sure it still works.
It doesn't work anymore. After I swapped the maincpu puckmod roms and launched with a latest official MAME release through the command prompt, all I saw was an empty black screen.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

I wonder if it is MAME or a regression in z88dk.
Are you keeping part of the original ROMs for the graphics etc?
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Wed Oct 05, 2022 4:11 pm I wonder if it is MAME or a regression in z88dk.
Are you keeping part of the original ROMs for the graphics etc?
All rest ROMs are taken from the non-merged puckmod MAME rom archive.

Maybe, the specific version of MAME, where Pac-Man HW roms database not hardcoded into pacman.cpp driver but stored in the external .xml software list file, like in case with Neo-Geo, would be able to become the way out.
Last edited by VasiliyFamiliya on Thu Oct 06, 2022 3:10 am, edited 1 time in total.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

The reason for me asking is that MAME usually quits when the checksum is restricted and unmatched.
I did not expect a blank screen.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Thu Oct 06, 2022 5:27 pm The reason for me asking is that MAME usually quits when the checksum is restricted and unmatched.
I did not expect a blank screen.
Неre is puckmod archive I tested.
You do not have the required permissions to view the files attached to this post.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

Sorry, I chose a wrong format. Here is the ZIP.
You do not have the required permissions to view the files attached to this post.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

C:\z80\mess>mame puckmod
namcopac.6e WRONG CHECKSUMS:
EXPECTED: CRC(fee263b3) SHA1(87117ba5082cd7a615b4ec7c02dd819003fbd669)
FOUND: CRC(52d84c65) SHA1(d3dc9069176526656cf9d17f89aaf79e15fe985f)
namcopac.6f WRONG CHECKSUMS:
EXPECTED: CRC(39d1fc83) SHA1(326dbbf94c6fa2e96613dedb53702f8832b47d59)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
namcopac.6h WRONG CHECKSUMS:
EXPECTED: CRC(02083b03) SHA1(7e1945f6eb51f2e51806d0439f975f7a2889b9b8)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
npacmod.6j WRONG CHECKSUMS:
EXPECTED: CRC(7d98d5f5) SHA1(39939bcd6fb785d0d06fd29f0287158ab1267dfc)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
WARNING: the machine might not run correctly.
Average speed: 100.00% (18 seconds)

.. then MAME starts as you described, with a blank screen.

It is the ROMset, I hope I understood correctly. You should spot the older versions of the 'PUCKMAN' or other 'PUCKMOD' releases and be sure that the normal PACMAN games runs. Then you can overwrite the 4 main program files with the z88dk ones.

EDIT:
I just understood what you are asking for !!
Yes, something goes wrong, if we try to build the provided example, it will crash on MAME !
It is z88dk, a bit of investigation is required, now.. :(
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Sat Oct 08, 2022 9:29 am C:\z80\mess>mame puckmod
namcopac.6e WRONG CHECKSUMS:
EXPECTED: CRC(fee263b3) SHA1(87117ba5082cd7a615b4ec7c02dd819003fbd669)
FOUND: CRC(52d84c65) SHA1(d3dc9069176526656cf9d17f89aaf79e15fe985f)
namcopac.6f WRONG CHECKSUMS:
EXPECTED: CRC(39d1fc83) SHA1(326dbbf94c6fa2e96613dedb53702f8832b47d59)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
namcopac.6h WRONG CHECKSUMS:
EXPECTED: CRC(02083b03) SHA1(7e1945f6eb51f2e51806d0439f975f7a2889b9b8)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
npacmod.6j WRONG CHECKSUMS:
EXPECTED: CRC(7d98d5f5) SHA1(39939bcd6fb785d0d06fd29f0287158ab1267dfc)
FOUND: CRC(f154670a) SHA1(e0c66649d1434eca3435033a32634cb90cef0f31)
WARNING: the machine might not run correctly.
Average speed: 100.00% (18 seconds)

.. then MAME starts as you described, with a blank screen.

It is the ROMset, I hope I understood correctly. You should spot the older versions of the 'PUCKMAN' or other 'PUCKMOD' releases and be sure that the normal PACMAN games runs. Then you can overwrite the 4 main program files with the z88dk ones.

EDIT:
I just understood what you are asking for !!
Yes, something goes wrong, if we try to build the provided example, it will crash on MAME !
It is z88dk, a bit of investigation is required, now.. :(
Just in case, I must tell that built program was a dstar, and compilation was held through the latest official Windows release.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

I think I found what's going on, something changed on MAME quite recently.
My post above is still valid if you're using MAME 0.194.

MAME 0.208 still works, but the ROM files need to be given different names and put in a ROM folder named "pacmod"

pacmanh.6e
pacman.6f
pacmanh.6h
pacmanh.6j
pacmanh.5e

On the latest MAME versions, as you correctly pointed out, the z88dk programs are stuck forever, no matter which PACMAN release you try to hack.
At a first glance on the debugger (mame - debug ) it looks like the interrupt is entered continously, not permitting the program to run.


EDIT:
This change could be a good starting point to investigate
https://github.com/mamedev/mame/commit/ ... eb0e86f40c
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Mon Oct 10, 2022 8:34 am I think I found what's going on, something changed on MAME quite recently.
My post above is still valid if you're using MAME 0.194.

MAME 0.208 still works, but the ROM files need to be given different names and put in a ROM folder named "pacmod"

pacmanh.6e
pacman.6f
pacmanh.6h
pacmanh.6j
pacmanh.5e

On the latest MAME versions, as you correctly pointed out, the z88dk programs are stuck forever, no matter which PACMAN release you try to hack.
At a first glance on the debugger (mame - debug ) it looks like the interrupt is entered continously, not permitting the program to run.


EDIT:
This change could be a good starting point to investigate
https://github.com/mamedev/mame/commit/ ... eb0e86f40c
Then I'll be wait till the pacman.cpp code changes, which would return a bootability to homebrew products.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

I tend to blame MAME indeed, my feeling is that the interrupt frequency is somewhat wrong.
On my side, I chose the IM1 interrupt mode which PACMAN did not use, I'll try IM2.
I have a way to fix the example by simply disabling the interrupts and forcing the watchdog reset in the game loop.. but looks like a regression to me.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Mon Oct 10, 2022 5:38 pm On my side, I chose the IM1 interrupt mode which PACMAN did not use, I'll try IM2.
I have a way to fix the example by simply disabling the interrupts and forcing the watchdog reset in the game loop.. but looks like a regression to me.
I think, it's worth at least to try the options you listed, and, in the case of success, it's would be possible to care about replacement with a more progressive measures.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

Yup. I just tried the IM2 mode, but the problem persists, the ISR is called again as soon as it enables the interrupts and exits.

Disabling the interrupts is very simple, you could edit:
lib/targets/pacman/classic/pacman_crt0.asm and comment out the EI instruction:
; ei ; enable processor interrupts

The ISR will be called once only.

If you try to run the demo program after that change, you'll notice that you can do only one move in the game, then the watchdog will reset it.

To fix that, it is simply a matter of adding here and there in dstar.c the following lines:

#asm
ei
#endasm

It will indirectly kick in the ISR code, which knows what to do with the watchdog.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Tue Oct 11, 2022 11:06 am
To fix that, it is simply a matter of adding here and there in dstar.c the following lines:

#asm
ei
#endasm

It will indirectly kick in the ISR code, which knows what to do with the watchdog.
What places of the code have I to put it in?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

My quick win:

Code: Select all

    /* Decompress Level into the Board */
	for (x=0; x!=36; x++)
	{
#asm
ei
#endasm

(...)



/* Check if a Level is (not) finished:
 * There are 144 squares in each Level
 *
 * Note the use of != instead of < or <=
 *  - this is faster to execute on the Z80!
 */
char CheckNotFinished(void)
{
	char *ptr;
	int i;
	
#asm
ei
#endasm




(...)

#asm
ei
#endasm
		/* for (p=0; p<800; p++); */
		csleep(5);

#asm
ei
#endasm


VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Tue Oct 11, 2022 1:10 pm My quick win:

Code: Select all

    /* Decompress Level into the Board */
	for (x=0; x!=36; x++)
	{
#asm
ei
#endasm

(...)



/* Check if a Level is (not) finished:
 * There are 144 squares in each Level
 *
 * Note the use of != instead of < or <=
 *  - this is faster to execute on the Z80!
 */
char CheckNotFinished(void)
{
	char *ptr;
	int i;
	
#asm
ei
#endasm




(...)

#asm
ei
#endasm
		/* for (p=0; p<800; p++); */
		csleep(5);

#asm
ei
#endasm


Thank you! Now, as I'm going to create a Zelda/Gauntlet-like game, I need to change the movenent system from discrete to per-pixel.
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

Oh, by the way - does dstar program utilize any Pac-Man hardware sprites?
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: PacMan hardware

Post by stefano »

No
VasiliyFamiliya
Member
Posts: 22
Joined: Tue Oct 04, 2022 4:25 am

Re: PacMan hardware

Post by VasiliyFamiliya »

stefano wrote: Thu Oct 13, 2022 2:32 pmNo
Then please, send me some demo piece of code of interaction with hardware sprites.
Post Reply