Jump to content
IGNORED

New game port WIP: Pentagram


mariuszw

Recommended Posts

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.net/users/nwalker/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.

pg.obx

post-42656-0-42109700-1451516616_thumb.png

post-42656-0-58338300-1451516624_thumb.png

post-42656-0-62811300-1451516630_thumb.png

post-42656-0-98108900-1451516637_thumb.png

pg_disassembly.txt

pg.asm

spectrum.asm

z80.asm

pentagram_atari.asm

  • Like 23
Link to comment
Share on other sites

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 :)

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)...

 

post-7778-0-80248100-1451555109_thumb.png

test.xex

Edited by Irgendwer
  • Like 2
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...