06 September 2019, 19:35 | #1 | |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,376
|
Pacman - the Amiga conversion from the arcade game
Asman asked me to post info on that, since it was discussed on other threads.
So my project was to create a 1:1 port of Pacman which plays the same and all, at 50pfs, on amiga, reusing the work of the zx spectrum program which uses the arcade version. As someone (mcgeezer) suggested, it should be possible to port the Z80 code to 68000 with a converter. I found one, and compiled it and all (it was ooold), but there were a LOT of issues with the convert (I think it works well for SMALL programs that don't use low level asm things, like compressors, etc...) It also has other limitations, the worst one is: it can only run from 0 to $8000 (it uses address registers in signed 16 bit mode) Quote:
So I'm giving that solution up after a few days. So now you know: it's not easy (I can share more details, the convert is far from perfect and a lot of other things are missing (I could have used a small converted example too..., even if MOTOROLA wrote it!) BUT, what would be almost as efficient would be to run a Z80 emulator designed for 68000 and do the rest exactly the same way. Can someone point me to some Z80 emulator with asm source code? |
|
06 September 2019, 20:18 | #2 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,679
|
@jotd:
http://aminet.net/package/misc/emu/amitrs80 is open source and has a Z80 core written in assembler. |
06 September 2019, 20:55 | #3 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
@jotd
Look here https://github.com/shaunlebron/pacma...isasm/bart.asm In ancient times I also thought about perfect pacman port. And I thought about converter from Z80 --> mc68000. Of course I did nothing - just disasm some block of code and I stuck with z80 code. Lets focus on simple z80 routine. (Code taken from bart.asm) Code:
; ( rst 8 - Fill (HL)...(HL+B) with Accumulator ) [0x8] 8 0x77 LD (HL), A ; Load location (HL) with Accumulator [0x9] 9 0x23 INC HL ; Increment register pair HL [0xa] 10 0x10 DJNZ N fc ; Decrement B and jump relative 0xfc (-4) if B!=0 [0xc] 12 0xc9 RET ; Return Code:
label08: move.b D0,(a3) ;label08: 0x77 -> ld (hl),a addq.w #1,a3 ; 0x23 -> inc hl dbf d1,label08 ; 0x10 0xfc -> djnz label08 rts ; 0xc9 -> ret Of course its only idea. So first question which comes to my mind is about best usage of 68k registers for z80 register (mapping). How it usually done ? edit: changed addq.b --> addq.w. Thanks to hitchhikr. Last edited by Asman; 06 September 2019 at 23:03. |
06 September 2019, 21:25 | #4 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,213
|
Well... of course, BC, DE and HL can be used as address registers, but also the 8 bit components B,C,D,E,H,L are also data registers... so you can't really map 1 to 1 to 68k instructions... but I am sure that there is some efficient way of doing it
possibly to use memory locations to hold the 8 bit data regs, and pull from memory a 16 bit value into a 68k address register ? |
06 September 2019, 21:59 | #5 | |
Amiga user
Join Date: Nov 2008
Location: Sofia / Bulgaria
Posts: 472
|
Quote:
Wzonka-Lad http://aminet.net/package/misc/emu/wlz80core - Emulates the slightly different GameBoy's Z80. Very well commented code for each instruction. AmiMSX - http://aminet.net/misc/emu/AmiMSX_asm.lha Comments in Spanish. The Z80 emulation core is also used for AmiMasterGear, AmiGameBoy Spectrum http://aminet.net/misc/emu/spectrum-1.7_src.lha and http://aminet.net/misc/emu/spectrum-1.8wip_src.lha - Another Sinclair ZX Spectrum Emulator with source. CBSpeccy - Russian Sinclair and clones emulator http://aminet.net/misc/emu/CBSpeccy_v027.lha - comments in English. Speccylator - http://aminet.net/package/misc/emu/Speccylator-src - works on plain 68000 and is fast. |
|
06 September 2019, 22:07 | #6 |
Registered User
Join Date: Jun 2008
Location: somewhere else
Posts: 524
|
Code:
addq.b #1,a3 |
06 September 2019, 22:17 | #7 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
Have you talked to this person? http://www.nickmarentes.com/ProjectArchive/pacman.html
|
06 September 2019, 22:34 | #8 |
Registered User
Join Date: Sep 2004
Location: Brasil
Age: 49
Posts: 181
|
Something like DanScott says, you can put the z80 registers in memory and use an address register for offsets.
Or you can put them in the 68000 registers, something like this: Code:
F/F' -> D3 (Z80 Flag register) | 2 * 8 bits A/A' -> D4 (Z80 Accumulator) | 2 * 8 bits BC/BC' -> D5 | 2 * 16 bits DE/DE' -> D6 | 2 * 16 bits HL/HL' -> D7 | 2 * 16 bits IX -> A3 (Index registers are usually used as pointers) 16 bits IY -> A4 (Index registers are usually used as pointers) 16 bits PC -> A5 (Z80 PC) 16 bits SP -> A6 (Z80 Stack) 16 bits The Spectrum emulator from Peter McGavin, than drHirudo posted, it has a nice interface for using. Includes a function that you call and say how many z80 instructions you want to execute... although you will need to modify a few specific instructions (OUT, IN and HALT mainly) because they are specialized to do zx spectrum things. Although i would not discard the source code conversion yet. In the atari 800 world, that approach has made possible a few zx games conversions with great success (a lot of those conversion look faster in Atari 800 than in the original ZX). They pass the z80 disassembly source through a c tool that generated the 6502 source that can be assembled later + a few routines that "emulate" the most complex z80 instructions (LDIR, ...) and specific atari code for handling input, graphics, ... You can get more information about this approach here. |
06 September 2019, 22:52 | #9 | |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 829
|
Quote:
It seems that my z80 knowldege is too limited. edit: I changed my previous post. Last edited by Asman; 06 September 2019 at 23:04. |
|
06 September 2019, 23:52 | #10 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,376
|
Really I'm not going to write a Z80 to 68000 converter myself. Too much debugging if something doesn't work. The emulation looks the sanest issue ATM, and probably not so slow.
What would be great would be automatic Z80 to 68000 conversion, with a post-processing that checks if condition flags are needed, and discards them if it isn't, all those asm optimizations that maybe vasm can do The converter I have does this Code:
Dedicated register usage is as follows: D0 - Z80 A register and A' register D1 - Z80 flag register and flag' register D4 - constant $0F (condition code X bit mask) D5 - constant $10 (condition code X bit mask) D6 - IX D7 - IY A1 - pointer to B and BC on stack A2 - pointer to C on stack A3 - pointer to D and DE on stack A4 - pointer to E on stack A5 - pointer to L on stack A6 - Z80 SP register A7 - pointer to H and HL on stack |
07 September 2019, 03:28 | #11 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 854
|
Sounds like what you need is an optimizing assembler. Or perhaps an "assembler compiler" would be closer to the mark. Something that can analyze code flow between entry points and discard dead statements.
Then all you need is to replace Z80 instructions with 68K macros and let the compiler chew on it. I worked a lot on a 6502 emulator (the original Xformer from the ST), optimizing register and memory layout. Some of the saddest about it was looking at all the code for tracking status bits that you just _had_ to update for every opcode. Sending static ROM-able code through a converter should cut down the resulting size by a lot if you can drop the un-needed stuff. Why don't we have assemblers that can spot dead code? Last edited by NorthWay; 07 September 2019 at 19:47. |
07 September 2019, 05:42 | #12 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
It's a shame this seems to be a commercial product, might have been something that coul d have been worth looking at.
z80 -> C -> 68k http://www.mpsinc.com/z80.html |
07 September 2019, 06:44 | #13 |
Registered User
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
|
Would be better to do Ms. Pac Man. A far better game, in my opinion.
|
07 September 2019, 09:31 | #14 |
Inviyya Dude!
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,798
|
|
07 September 2019, 10:17 | #15 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,376
|
z80 -> C that's something that can be done. I've already done 6502 -> C -> 68000/x86/nintendo ds myself for my oric ports and it works.
But I know 6502 and the target very well, and I borrowed stuff from a 6502 emu for tough things like condition codes etc... Not the case with Z80. I may not be the adequate person for this project... Yesterday I tried to recompile MAME (0.35b12, with amiga parts) with gcc 6. Succeeded building & linking it. Running: lockup right at start software failure ... damn it's never easy. That gave me the opportunity to look at how it was done, and video refresh (the main culprit of the slowdowns on amiga) seems to use "dirty" areas & asm c2p (that I had to build with vasm -Faout so gcc could understand it). So it's not doing a full screen refresh already. I hoped we could speed this up... maybe the CPU parts with gcc 6. Well, maybe I'll debug it... maybe I'll drop it. |
07 September 2019, 11:02 | #16 |
Registered User
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
|
No, I don't have one. It's just a better game.
Edit: The C64 already has a great conversion. I have the original Atarisoft cart. Last edited by Hewitson; 07 September 2019 at 11:26. |
07 September 2019, 12:28 | #17 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,376
|
the most viable option is always to find the functional code (ghosts moves, speeds) and recreate everything from scratch using the same settings & A.I. Of course using the same gfx as well! Not very difficult for a game like Pacman (but still, work).
Already done this with Bagman and it works great. Debugging in MAME helps a lot. |
07 September 2019, 13:39 | #18 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,097
|
https://www.gamasutra.com/view/featu...ier.php?page=3
This documents PacMan in excruciating detail. A friend of mine used it to implement a full PacMan in BASIC and it's a stunningly realistic simulation of the arcade. The first two pages are just historical information - game mechanics starts at the URL above. |
09 September 2019, 17:28 | #19 | |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,468
|
Quote:
https://www.vintageisthenewold.com/a...trs-80-coco-3/ It includes the SW which he used for the conversion https://nowhereman999.wordpress.com/...-6809-program/ There is a 25 post blog which is quite interesting. |
|
10 September 2019, 01:09 | #20 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,357
|
Oh, I must have thought there was only one Coco 3 port.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Worst Arcade Conversion | Hewitson | Nostalgia & memories | 57 | 09 April 2019 12:51 |
Arcade / Console --> Amiga conversion discussions | dlfrsilver | Coders. General | 587 | 04 September 2018 17:11 |
Pacman / Gridrunner crossover game | pickaweapon | Looking for a game name ? | 4 | 02 July 2012 23:41 |
Landover's Amiga Arcade Conversion Contest | Frog | News | 1 | 28 January 2005 23:41 |
Old Atari ST ? Game...not sure if there was an Amiga conversion.. | HCF | Looking for a game name ? | 14 | 17 October 2004 17:43 |
|
|