Jump to content

Photo

New game port WIP: Pentagram


47 replies to this topic

#1 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • 175 posts

Posted Wed Dec 30, 2015 5:31 PM

Hi,

 

Here is new game port I have been working on last few weeks: Pentagram. For those who doesn't know this game, Pentagram is final game in Sabreman saga, and it is a sequel to well known Knight Lore.

 

To play the game, use Altirra emulator and run pg.obx. On the title screen, press 1 to play with keyboard and press 2 to play with (emulated) Kempston joystick. Then press 0 to start the game. Other input means (Cursor Joystick and Interface II) are not emulated.

 

Game was ported from Spectrum. For the purpose of porting, I have developed simple static recompiler which takes Spectrum Z80 code and produces equivalent 6502 code. Created code is slow and unoptimized, but it is mostly working correctly. Recompiler is not designed to produce 100% correct 6502 code, but instead it can detect several situations which require manual intervention, like A register being read by Z80 instruction and not set by previous instruction. Also, I have developed a tool to verify correctness of the code. It runs both Spectrum and Atari versions in parallel using Z80 and 6502 emulators and compares memory accesses (read and writes) of both versions and reports differences. It skips all opcode reads (as these are obviously different) and for memory reads it checks if given address from Z80 version is properly mapped to 6502 version.

 

Game is slower at this moment as Spectrum version, but it is almost not optimized, so this is expected at this point. Hopefully it can be brought to better speeds later. Game is also not much tested, so there may be some gameplay issues.

 

For those interested in development, I included source code:

- pg_disassembly.txt: Pentagram disassembly found here: http://retrospec.sgn...lker/filmation/

- z80.asm: defines and routines used by Z80 recompiler

- spectrum.asm: defines and routines used to emulate Spectrum I/O on Atari (at this moment screen, keyboard, joystick and buzzer are emulated, colours are not)

- pentagram_atari.asm: Atari 6502 code of Pentagram

- pg.asm: main asm file, assemble it with MADS to create game executable

 

Main routines in the game (which needs optimizing) are:

- PrintSprite, which renders the sprite, applying rotation if necessary

- LB58A, which render game objects and renders them when necessary

Feel free to send me your better optimized versions of these routines.

 

Happy New Year 2016!

 

Mariusz.

Attached Thumbnails

  • pg01.png
  • pg02.png
  • pg03.png
  • pg04.png

Attached Files



#2 pirx OFFLINE  

pirx

    Moonsweeper

  • 457 posts
  • Location:Poland

Posted Wed Dec 30, 2015 5:57 PM

it was my dream in the nineties, i have even coined a name "emuler"  (emulator + compilator) and we (our5oft) purchased zx spectrum to give it a go. too difficult it was, all i did was a routine checking where is all accessible z80 code. the rest seemed too difficult at the time. great to see it is possible after all :)



#3 Tezz ONLINE  

Tezz

    River Patroller

  • 2,412 posts
  • Location:Manchester, England

Posted Wed Dec 30, 2015 6:19 PM

Hats off Mariusz, that's excellent! :thumbsup: Recompiling z80 was on my list of wip projects.


Edited by Tezz, Wed Dec 30, 2015 6:23 PM.


#4 snicklin OFFLINE  

snicklin

    River Patroller

  • 2,209 posts
  • Location:Australia

Posted Wed Dec 30, 2015 6:55 PM

Are you using the MADS optimisation options on the command line? Or do you want better code first before using these?



#5 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,484 posts
  • Location:Germany

Posted Wed Dec 30, 2015 7:41 PM

Cool! Maybe a collaboration with XXL (http://atariage.com/.../user/9219-xxl/) makes sense? AFAIK he has a similar process to convert Z80 code...

 

Next target: Z80 Game-Boy ports... ;)

 

GBTest.png

Attached Files


Edited by Irgendwer, Wed Dec 30, 2015 7:42 PM.


#6 snicklin OFFLINE  

snicklin

    River Patroller

  • 2,209 posts
  • Location:Australia

Posted Wed Dec 30, 2015 8:33 PM

Mariuszw, I like the game. Is anyone else having issues starting the game, I have to hold down '0' for a long time and then press it a few times for the game to start. I think that it may be due to non-optimisation at the moment.

 

Once the game starts, it seems like a game I'm going to like a lot. As a request though, can you change the direction controls? Like Tezz did with Chimera+, is it possible that you don't have to rotate your character to move? Just move the joystick in the direction that you want to go?

 

As a question for all, as for the Gameboy ports request, what has held up GB ports in the past? Is it due to the games tending to be quite big and not fitting in 64K? Or is it because it has a tiling system built into the GB which needs emulating? Or some other reason? I'd love to see more GB games on the Atari.



#7 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • Topic Starter
  • 175 posts

Posted Thu Dec 31, 2015 2:03 AM

Are you using the MADS optimisation options on the command line? Or do you want better code first before using these?

 

Not sure what you mean by MADS optimisation options? I haven't found any. Please let me know what they are.



#8 xxl OFFLINE  

xxl

    Stargunner

  • 1,132 posts
  • Location:Rabka-Zdrój /Poland

Posted Thu Dec 31, 2015 2:08 AM

WOW!

 

Pentagram! Thanks.

 

nice :-)



#9 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • Topic Starter
  • 175 posts

Posted Thu Dec 31, 2015 2:10 AM

Cool! Maybe a collaboration with XXL (http://atariage.com/.../user/9219-xxl/) makes sense? AFAIK he has a similar process to convert Z80 code...

 

Next target: Z80 Game-Boy ports... ;)

 

attachicon.gifGBTest.png

 

Faster CPU (than ZX Spectrum), 40 hardware sprites, full tilemap. Atari can't do that :(



#10 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • Topic Starter
  • 175 posts

Posted Thu Dec 31, 2015 2:13 AM

Mariuszw, I like the game. Is anyone else having issues starting the game, I have to hold down '0' for a long time and then press it a few times for the game to start. I think that it may be due to non-optimisation at the moment.

 

Once the game starts, it seems like a game I'm going to like a lot. As a request though, can you change the direction controls? Like Tezz did with Chimera+, is it possible that you don't have to rotate your character to move? Just move the joystick in the direction that you want to go?

 

As a question for all, as for the Gameboy ports request, what has held up GB ports in the past? Is it due to the games tending to be quite big and not fitting in 64K? Or is it because it has a tiling system built into the GB which needs emulating? Or some other reason? I'd love to see more GB games on the Atari.

 

You need to press '0' and wait a little bit- if you have speaker, you will hear music which plays at that time, when music ends, game starts.

 

Control scheme is a little weird, but hero can shoot (fire) and jump (joystick down). Not sure how to handle these on joystick without direction controls.

 

Gameboy: too much hardware inside (see my previous post).


Edited by mariuszw, Thu Dec 31, 2015 2:14 AM.


#11 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,484 posts
  • Location:Germany

Posted Thu Dec 31, 2015 3:34 AM

Faster CPU (than ZX Spectrum), 40 hardware sprites, full tilemap. Atari can't do that :(

 

<20% more speed isn't something that would break game play - and games run from ROM, so that some SMC magic could speed things up a little bit...

I know, the hardest part would be "emulation" of tile map and sprites, but it sounds also like an interesting technical challenge... (even if the result could be more or less a slide show...)

 

Edit: Atari would also be a bit faster in the depicted mode (compared to Spectrum "emulation"), because screen DMA is reduced in every third scan line (second mode line)...

 

test.png

Attached Files

  • Attached File  test.xex   5.92KB   205 downloads

Edited by Irgendwer, Thu Dec 31, 2015 3:51 AM.


#12 Mclaneinc ONLINE  

Mclaneinc

    Retro Madman

  • 6,684 posts
  • Location:Northolt, UK

Posted Thu Dec 31, 2015 4:59 AM

Thank you Marius...Another great looking port..



#13 Irgendwer OFFLINE  

Irgendwer

    Stargunner

  • 1,484 posts
  • Location:Germany

Posted Thu Dec 31, 2015 8:49 AM

Had a quick look into the code.

"EXX" seems to be kind of bottle-neck (I'm sure you know that already). Does a macro expansion really violates the memory footprint? (16 occurrences)

12 saved cycles (jst/rts) isn't that bad...

 

This looks suspicious too:

               jsr exx ; EXX                ; couldn't this be changed to simply jump after @@43 ?
@@43    jsr exx ; EXX

 

 

Edit: Single expansion at $6925 (@@43) for EXX saves one %


Edited by Irgendwer, Thu Dec 31, 2015 9:34 AM.


#14 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • Topic Starter
  • 175 posts

Posted Thu Dec 31, 2015 10:13 AM

Had a quick look into the code.

"EXX" seems to be kind of bottle-neck (I'm sure you know that already). Does a macro expansion really violates the memory footprint? (16 occurrences)

12 saved cycles (jst/rts) isn't that bad...

 

This looks suspicious too:

               jsr exx ; EXX                ; couldn't this be changed to simply jump after @@43 ?
@@43    jsr exx ; EXX

 

 

Edit: Single expansion at $6925 (@@43) for EXX saves one %

 

EXX is most expensive Z80 instruction to run on 6502 :) My idea is to remove these completely, and instead emit code which operates on shadow Z80 registers directly, for example following Z80 code:

 

;@@43    EXX
;B361:   LD   C,(HL)
;B362:   LD   A,(BC)
;B363:   LD   E,A
;B364:   INC  HL
;B365:   LD   C,(HL)
;B366:   LD   A,(BC)
;B367:   LD   D,A
;B368:   INC  HL
;B369:   PUSH DE
;B36A:   EXX

 

could be recompiled to:

 

 

@@43   ; jsr exx ; EXX
        ldy #$00 ; LD   C,(HL)
        lda (z80_hlp),y
        sta z80_cp
        ldy #$00 ; LD   A,(BC)
        lda (z80_bcp),y
        sta z80_ep ; LD   E,A
        inc z80_lp ; INC  HL
        bne *+4
        inc z80_hp
        ldy #$00 ; LD   C,(HL)
        lda (z80_hlp),y
        sta z80_cp
        ldy #$00 ; LD   A,(BC)
        lda (z80_bcp),y
        sta z80_dp; LD   D,A
        inc z80_l ; INC  HL
        bne *+4
        inc z80_hp
        lda z80_ep ; PUSH DE
        pha
        lda z80_dp
        pha
        ; jsr exx ; EXX

 

The code you mentioned (around @@43) takes care of flipping the sprites (if necessary). They use interesting trick: when they find they need to flip the sprite, they flip it and save back to memory in the same place. As with next frame sprite is probably still flipped, they save cost of flipping on next frame.



#15 popmilo OFFLINE  

popmilo

    Stargunner

  • 1,578 posts
  • Location:Senta, Srbija

Posted Thu Dec 31, 2015 1:10 PM

Super cool present for new year! THANKS Marius!!!

 

Your coding skills seem to be better every day... Who knows what else you have to release and are just teasing us ;)

 

Target Renegade.. Midnight Resistance...Silkworm.... Uhhhh.... So much possibility :D



#16 mariuszw OFFLINE  

mariuszw

    Chopper Commander

  • Topic Starter
  • 175 posts

Posted Thu Dec 31, 2015 1:21 PM

To tell you the truth, one of my favourite games in 80s was Gunfright ;)

Btw: can anybody recommend good Spectrum Z80 disassembler?

I also need mapping between Spectrum and Atari colors. Then Pentagram may get some colors.

#17 CharlieChaplin OFFLINE  

CharlieChaplin

    River Patroller

  • 3,127 posts

Posted Fri Jan 1, 2016 7:34 PM

Hmmm,

 

the XEX loads under emulation, but it does not load from an ATR with DOS, gamedos or bootloader - most likely due to a segment that uses memory $0800-0CAC. Maybe it is possible to relocate that segment somewhere else or just raise the memory from e.g. $0800-Axxx to $1000-Bxxx ?!?


Edited by CharlieChaplin, Fri Jan 1, 2016 7:35 PM.


#18 snicklin OFFLINE  

snicklin

    River Patroller

  • 2,209 posts
  • Location:Australia

Posted Fri Jan 1, 2016 11:00 PM

 

You need to press '0' and wait a little bit- if you have speaker, you will hear music which plays at that time, when music ends, game starts.

 

Control scheme is a little weird, but hero can shoot (fire) and jump (joystick down). Not sure how to handle these on joystick without direction controls.

 

Gameboy: too much hardware inside (see my previous post).

 

Now that makes more sense, I didn't have my speaker on previously.

 

The first improvement to the game might be to either remove the music or make it so that it can be interrupted.

 

As for the control scheme, how about 2 different selectable options?

1) Controls as they are now (useful for those without a keyboard).

2) Directional controls, fire button to jump and space bar to fire.

 

I know that the controls as they are do wind some people up. Head over Heels is an example of a game with good controls.

 

Super work by the way - as always.



#19 Heaven/TQA OFFLINE  

Heaven/TQA

    Quadrunner

  • 11,255 posts
  • Location:Baden-Württemberg, Germany

Posted Sat Jan 2, 2016 12:45 AM

Charlie.... Put it on an dos disk with xboot header and rename it to autorun? Xboot by xxl can load from $800...

#20 Heaven/TQA OFFLINE  

Heaven/TQA

    Quadrunner

  • 11,255 posts
  • Location:Baden-Württemberg, Germany

Posted Sat Jan 2, 2016 12:46 AM

I mean xboot as boot loader.

#21 +Adam+ OFFLINE  

+Adam+

    Moonsweeper

  • 488 posts

Posted Wed Jan 6, 2016 2:21 PM

Hi, you can download a newer version of Pentagram from AtariOnline.pl: link  :)

More details in this article.

 

PentagramWIP_0.png PentagramWIP_2.png



#22 snicklin OFFLINE  

snicklin

    River Patroller

  • 2,209 posts
  • Location:Australia

Posted Wed Jan 6, 2016 8:28 PM

I've found a map online. I can't say whether this version is faithful to the original map, but can only presume so.

 

https://s-media-cach...1f9d97b918d.jpg



#23 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 4,251 posts
  • Location:Lisbon - Portugal

Posted Wed Jan 6, 2016 10:26 PM

Hi, here's the real for sure, _3 and _4 .png: http://worldofspectr....cgi?id=0009389

Edited by José Pereira, Wed Jan 6, 2016 10:38 PM.


#24 José Pereira OFFLINE  

José Pereira

    River Patroller

  • 4,251 posts
  • Location:Lisbon - Portugal

Posted Wed Jan 6, 2016 10:26 PM

DEL.

Edited by José Pereira, Wed Jan 6, 2016 10:28 PM.


#25 cpt ron OFFLINE  

cpt ron

    Combat Commando

  • 3 posts

Posted Fri Jan 8, 2016 6:34 PM

o5x7ba.png

Attached Files






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users