News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Ant Attack Sinclair Zx Spectrum Emulator for Amstrad CPC 6128

Started by 40Crisis, 22:33, 23 January 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

40Crisis

You can download here the first release of Ant Attack Sinclair Zx Spectrum 48k
Emulator for Amstrad 6128(+) CPC range.

Ant Attack is a game for Sinclair Zx Spectrum 48K made by Sandy White and
Angela Sutherland and released in 1983 by QUICKSILVA.

This game is the first 3D isometric game released for the Zx Spectrum and one
of the first isometric game released for computers.

It's also a non-sexist game as you can choose for character boy or girl.
Some people considered it to be the very beginnings of the survival horror genre.

Zx Spectrum game is necessary to run the emulator but is not provided.

Please read the "Ant_Attack_Sinclair_Zx_Spectrum_Emulator_For_Amstrad_CPC_6128(+).txt"
file for details on how to use the emulator.

Enjoy.  ;)

Gryzor

Oh wow, this is extremely interesting!!!


Is the game really not available for legal downloading? Maybe you could give a MD5 for the TZX so we know we have the correct one...

40Crisis

MD5 for the TZX file is the following:
298f4013df217 *AntAttack.tzx



MacDeath

Damn, another speccy port... yet I wasn't aware SIM Ant was ported on speccy.
:laugh:

TFM

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: MacDeath on 00:43, 24 January 14
Damn, another speccy port... yet I wasn't aware SIM Ant was ported on speccy.
:laugh:
Yes true, but this is a different approach. Here the game is not allowed for distribution, so the code loads up the existing game and patches it to work on cpc.
So what you then release is the patch and not the game.

It's up to the person who wants to use the patch to find the game.

I started on the same idea with atic atac, but as of yet I didn't complete this patch.

it's a good achievement because you must identify the areas of data to patch, then implement a way to load the original code and patch it.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Quote from: 40Crisis on 22:51, 23 January 14
MD5 for the TZX file is the following:
298f4013df217 *AntAttack.tzx
@40Crisis: What is the speed on CPC compared to Spectrum?
Are you converting graphics each time they are drawn, or are you converting them once and using this converted result?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Sykobee (Briggsy)

This would look great with some proper MODE 1 graphics - but I guess that would require some insane patching deep into the graphics rendering routines!


Nice game though, large map.

MacDeath

QuoteIt's up to the person who wants to use the patch to find the game.
yeay just like the PacMan emulator.

TFM

BTW... If somebody would send me a DSK which I can just start - I wouldn't mind. ;)


I can start the Speccy emulator, and then? I don't know how to program that machine, every key makes a command, but I can't even take a look at the disc. Strange new world.

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: TFM on 18:04, 24 January 14
BTW... If somebody would send me a DSK which I can just start - I wouldn't mind. ;)


I can start the Speccy emulator, and then? I don't know how to program that machine, every key makes a command, but I can't even take a look at the disc. Strange new world.
Oh it actually boots into speccy basic?

I see...

hmmm.. my atic atac hack doesn't do that, runs and looks like a normal cpc program.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

McKlain


40Crisis

Quote from: arnoldemu on 10:39, 24 January 14
@40Crisis: What is the speed on CPC compared to Spectrum?
Are you converting graphics each time they are drawn, or are you converting them once and using this converted result?


Zx spectrum version renders the 3d display zone in a linear buffer of 116 lines 32 bytes long,
then this buffer is transfered to zx spectrum video memory line by line 30 bytes per line
copied with ldir instruction.

The display for this buffer is most of the time in black and white colors but the white color
can be changed to other color in specific occasions (ammno shoots, end of rescue ).
Only text messages can have multiple colors on ant attack spectrum. They are added by calling the basic
rom which writes directly in video ram.

So the graphics stay all the time monochromatics in the working buffer.

The graphics being monochromatics, to render this on the cpc I just have to convert
8 pixels on one byte on the spectrum into two bytes on the cpc at the cpc format
with minimal instructions unrolled for the whole line to
avoid looping. I use the stack to get data from the zx spectrum buffer.

I wrote a first version that was like this:


        push    ix
        ld    ixh,116                      ; 116 lines to copy   
        ld (save_sp),sp
        ld  sp,$A181                    ; zx source buffer
        ld  de,$E042                    ; dest cpc video memory
        ld  c,$0F                           ; mask
trans1:       
        ld     b,$F0
trans:   
        ; !!!! missing in this listing unroll 14 times the following block !!!!!
       
        pop    hl
        ld     a,l
        and     b
        ld     (de),a
        inc    e
        ld    a,l
        add    a,a
        add    a,a
        add    a,a
        add    a,a
        ld    (de),a
        inc    e
        ld     a,h
        and     b
        ld     (de),a
        inc    e
        ld    a,h
        add    a,a
        add    a,a
        add    a,a
        add    a,a
        ld    (de),a
        inc    e
       
       
        pop    hl
        ld     a,l
        and     b
        ld     (de),a
        inc    e
        ld    a,l
        add    a,a
        add    a,a
        add    a,a
        add    a,a
        ld    (de),a
        inc    e
        ld     a,h
        and     b
        ld     (de),a
        inc    e
        ld    a,h
        add    a,a
        add    a,a
        add    a,a
        add    a,a
        ld    (de),a
       
        pop     hl
               
        ld    hl,2048-59
        add    hl,de
        jr    nc,no_overflow
        ld    de,$C000+64
        add    hl,de
no_overflow:
        ex    de,hl           
        dec    ixh
        jp    nz,trans1
        ld sp,(save_sp)
        pop    ix   
        ret

save_sp:     .dw 0
   



Then I found an optimisation (4 add a,a instructions replaced with an and instruction) by
duplicating the black color, using only 3 colors for the display.
Pen 0 is white pen 1 is black pen 2 is black.

It looks now like this:

        push    ix
        ld    ixh,116         ; 116 lines to copy   
        ld (save_sp),sp
        ld  sp,$A181        ; zx source buffer
        ld  de,$E042        ; dest cpc video memory
        ld  bc,$F00F         ; mask for left/right pixels on cpc
       
trans1:
        ; !!!! missing in this listing unroll 14 times the following block !!!!!
       
        pop hl
        ld  a,l
        and b
        ld (de),a
        inc e
        ld a,l
        and c
        ld (de),a
        inc e
        ld  a,h
        and b
        ld (de),a
        inc e
        ld a,h
        and c
        ld (de),a
        inc e
       
       
        pop hl
        ld  a,l
        and b
        ld (de),a
        inc e
        ld a,l
        and c
        ld (de),a
        inc e
        ld  a,h
        and b
        ld (de),a
        inc e
        ld a,h
        and c
        ld (de),a
       
        pop     hl
               
        ld    hl,2048-59
        add    hl,de
        jr    nc,no_overflow
        ld    de,$C000+64
        add    hl,de
no_overflow:
        ex    de,hl
       
        dec    ixh
        jp    nz,trans1
        ld sp,(save_sp)
        pop    ix   
        ret
   
save_sp:     .dw 0


In zx Spectrum emulator Fuse I measured 100074 Tstates to transfer whole buffer.
1 Tstate = 1 / 3500000 s

In Cpc emulator Arnold  I measured 42102 Nops to transfer whole buffer.
1 Nops = 1 / 1000000 s


If I'm right Zx spectrum display routine is 0.042102/0.028592 = 1.47 faster than cpc display

Xyphoe

Hi guys and 40Crisis - I have done a video of this! Review and longplay :)


[AMSTRAD CPC] Ant Attack - Longplay & Review! (Spectrum classic emulated on the CPC!!)

Thank you again 40Crisis, I think this is BRILLIANT work.


40Crisis

Quote from: Xyphoe on 16:19, 08 March 14
Hi guys and 40Crisis - I have done a video of this! Review and longplay :)


[AMSTRAD CPC] Ant Attack - Longplay & Review! (Spectrum classic emulated on the CPC!!)

Thank you again 40Crisis, I think this is BRILLIANT work.

Many thanks for this nice video  :)

It's always nice to see people appreciating your work.
It's sometimes a hard work making all behave on the cpc as close as it does in the original zx spectrum game, but finally you manage to do it.

sigh

@40Crisis

This is amazing. I would never of thought that emulating another home computer on the CPC would of been possible.
A few questions:

1) Does the CPC have to be 128kb to emulate a 48kb machine?
2) Does the emulator work with RAM expansions?
3) If the RAM expansion is 256kb could it also emulate a 128kb machine?
4) Does the CPC also emulate the beeper or would it disregard that sound?
5) Are there speed differences between an original spectrum game and the emulated version on a CPC?

Great work and it would be interesting to see other games emulated.

This has me wondering if the CPC could emulate an MSX 1.....


mahlemiut

Quote from: sigh on 03:41, 09 March 14This has me wondering if the CPC could emulate an MSX 1.....

The Aleste 520EX does this to some extent, with a little hardware help, although VDP emulation is done in software.
- Barry Rodewald

40Crisis

Quote from: sigh on 03:41, 09 March 14
@40Crisis

This is amazing. I would never of thought that emulating another home computer on the CPC would of been possible.
A few questions:

1) Does the CPC have to be 128kb to emulate a 48kb machine?
2) Does the emulator work with RAM expansions?
3) If the RAM expansion is 256kb could it also emulate a 128kb machine?
4) Does the CPC also emulate the beeper or would it disregard that sound?
5) Are there speed differences between an original spectrum game and the emulated version on a CPC?

Great work and it would be interesting to see other games emulated.

This has me wondering if the CPC could emulate an MSX 1.....

First of all, my zx spectrum rom emulation is partial, and at the moment
only emulates the features needed by zx basic parts from the supported zx games.
For instance, Maziacs doesn't have zx basic graphics functions emulation, because it doesn't use it.
For Ant Attack I only need to add the circle basic function emulation.

A complete zx spectrum basic emulator is available: ZXM. It only emulates zx basic programs in black and white
output. It has less memory than a real 48k Spectrum because the emulation code is for 64K CPC.
It's a nice piece of software and this is one of the program that convinced me it's was possible
to emulate a 48K spectrum on a CPC.

1)

It depends on the zx spectrum program you want to emulate.
The two games emulators I wrote for CPC ( Maziacs and Ant Attack ) uses zx basic and assembly.
Zx basic use means that you need to have 16 KB zx spectrum rom loaded in memory at location 0.
Then you need to had emulation code (about 6 KB) plus 16K CPC screen memory (which can be optimized if necessary to 12288 bytes by tweeking
CRTC registers to have linear screen memory).


For example my first emulator for zx maziacs fits in 64K CPC memory because the zx game
doesn't use full 48K ram available on speccy.

Ant Attack emulator didn't fit in 64k because it makes use of full 48K Ram. Only the zx spectrum display memory
(6912 bytes) was available. I use it to put emulation code. So I need 16K extra memory for CPC screen.



2)

I think it should if expansion uses standard memory bank addressing.


3)

Yes, it's perfectly possible if the emulator supports it, which is not the case

4)

The zx spectrum beeper sound is emulating at runtime (no sound records) in a very similar way to the zx.

5)

Most of zx spectrum machine code runs unchanged on the CPC. Only parts contening I/O need to be emulated
(graphics output, controls input and sound output).

When possible, I tried to write code as fast as possible on the CPC to get close to spectrum speed.
The main problem is the graphics, On the CPC you have to read/write twice memory compared to speccy graphic memory.
The zx spectrum beeper sound could be also CPU intensive to emulate but wastes nearly the same as it does on a speccy.

Maziacs emulated on CPC is as fast as on the zx. Luckily the zx game waits about 60% of the available CPU time to slow it down.
This is probably because zx graphic display is very fast. Graphics background of the maze, covering nearly full screen, are displayed using zx graphics attributes (on byte write =
64 pixels displayed). This was hard to emulate on the CPC but I could do it displaying tiles using the stack.

Ant Attack emulator is a bit slower due to optimisation I explained above in this topics.


Regarding MSX emulation:

MSX has a hardware graphic chip for displaying sprites that CPC lacks.
Sound chip is the same that the CPC one.
Emulation is probably possible but will be probably much slower.

VincentGR

That is great, thank you!!!
I hope we see an Ikari Warriors port  ;D although there are to much happening on screen in this game  :'(


Gryzor


Powered by SMFPacks Menu Editor Mod