Changes

Jump to: navigation, search

Speccy Port

3,175 bytes added, 13:29, 19 January 2020
/* Screen dimensions */
Consequences:
* The pixel data and colours are stored in a different way than the CPC, so some conversion must be done before the graphics can be used. Either the graphics are remade, or often converted through some automatic process.
* There is a trade off between mode 1, keeping the same resolution as the Spectrum but having only 4 colours, or using mode 0, with half the horizontal resolution but 16 colours. The choice depends on the detail required in the graphics.
The following sections describe possible ways to handle the graphics on the Amstrad.
=====Graphics with transparency=====
 
======Storage======
A common way to do this is on the Spectrum is to store 1 byte of mask, followed by 1 byte of pixel data, and to repeat this for the width of the sprite divided by 8. (Each byte representing a 8 pixel wide single line slice of the sprite).
If we consider a sprite which is 16x16. Each byte contains 8 pixels. For each line 2 bytes would be needed for pixel data and 2 bytes for mask. The total storage space required would be (2+2)*8 16 = 32 64 bytes.
If we consider mode 1 on the Amstrad, and we used the same representation, we could freely use 4 colours for the sprites. The Amstrad would also need 2 times the ram space to store the data, because in mode 1 there is half the number of pixels per byte.
So, each byte contains 4 pixels. For each line 4 bytes would be needed for pixel data and 4 for mask: (4+4)*8 16 = 64 128 bytes.
However, if we sacrifice 1 colour, so we have 1 pen which is fully transparent and 3 for opaque sprite colours then we don't need the mask to be stored this way. The mask is common for all sprites and we could store this as a single 256 byte array. We would still need 4 bytes for the pixel data but the result now is: 4*8 16 = 32 64 bytes. The same weight as the Spectrum.
Mode 2 is generally not used for games on the Amstrad because of it's lack of colour. The pixels in this mode are half as wide as the Spectrum's. If the Spectrum data was used directly, which it could be, then the sprites would be half the width of the Spectrum's. We would still be forced to store mask and pixels In this case the data storage is the same as on the Spectrum, and . If we wanted to maintain the same resolution we would need to double up each pixel, effectively magnifying it in the width by 2. The result would be twice the size of the Spectrum data.
If mode 0 is used, we could either store a mask and byte, as for the Spectrum, or more commonly we use pen 0 for full transparent and leave the other 15 pens to define the sprite. We could then use half the number of pixels horizontally and lower resolution too. Each byte now contains 2 pixels. The sprite is 8x16 now = (8/2)*16 = 64 bytes. So again twice This the same storage sizeas for mode 1. If the size of the sprites were too small, then we would need to increase the size and the storage space.
Therefore, depending on the representation, this would determine how much ram is consumed on the Amstrad.
The best it seems is choices are to go for mode 1, and use a common mask table, with 3 colours per sprite. The situation is different if you consider tilesOr use mode 0, here we don't need use a common masktable, with 15 colours per spriteFor the spectrum a 8x16 tile: (8/8)x16 = 16 In both cases we use 256 bytesmore than the Spectrum equivalent graphicsCPC mode 1: (8/4)x16 = 32 bytes CPC mode 0: (4/2)x16 = 32 bytes CPC mode 2: (8/8)x16 = 16 bytes 
So we show that some games could be recoloured and still use about the same amount of data as the Spectrum.
 
The above do not consider the size or speed of the code to clip or draw the sprite to the Amstrad's screen compared to the Spectrum code. The values above assume the Spectrum version is not storing pre-shifted sprites, or using a pre-shift table, and when drawing to pixel positions is shifting the pixel data during draw. The comparison becomes more complicated when these are involved.
Examples of games probably ported from the Spectrum (the use a Spectrum sized screen), in mode 1 and recoloured:
Examples of games where re colouring could have been done:
* [[Pacmania]]
 
=====Graphics without transparency=====
 
======Storage======
 
Tiles are often used to define background graphics. These are opaque and don't need masks. The benefit here is that on CPC we can use all the colours in the palette, so for mode 1, all 4 colours can be used and in mode 0 all 16 colours can be used.
 
However on CPC generally non-transparent graphics will often take more storage space:
 
For the spectrum a 8x16 tile: (8/8)x16 = 16 bytes.
 
CPC mode 0: (4/2)x16 = 32 bytes
 
CPC mode 1: (8/4)x16 = 32 bytes
 
CPC mode 2: (8/8)x16 = 16 bytes
 
In mode 0 and mode 1, the tiles on the CPC will take twice as much space compared to the Spectrum. This will impact the memory used and depending on the number of tiles this is a significant memory impact.
=====Real-Time Conversion of Spectrum graphics=====
A common way to get the Speccy game running on the CPC and using the same storage space for the graphics was to perform real-time conversion of from the Spectrum graphics.
* Graphics are stored on the Amstrad in the same format as on the Spectrum (2 colour, 1BPPwith sprites having masks)
* Amstrad's mode 1 is used to maintain the same pixel resolution.
* A routine function converts the graphics on-demand, while the game is running, into the form that is displayed for the screen.
Needless to say, this enabled the port without the use of additional graphics artists so . Therefore it was would be cheaper and easier if a programmer was tasked with making a conversion alone.
Disadvantages:
* This process takes a lot more CPU power compared to the Spectrum version, because in addition to drawing and erasing the sprites, the pixel data must also be converted at the same time.
* This resulted in a significantly slower game.
* Amstrad version had less colours (often as little as 2 colours)
Advantages:
* Pixel data took less RAM compared to storing than if it was stored in an Amstrad's mode 1 native form, so the game could run on a 64K Ram machine (CPC464 and CPC664, 464Plus).* If the colour attributes of the Spectrum were not simulated then the attribute data would not need to be stored for the CPC.
=====Mode 1 and screen dimensions=====
Amstrad's mode 1 is the closest mode which compares with the Spectrum's graphical abilities.
However, the CPC has a different "pixel clock" compared to the Spectrum. The CPC was designed for a 320x200 display instead of a 256x192 display and in fact the the pixels are smaller on the screen when you compare mode 1 (the closest equivalent on the CPC) to the Spectrum.
So when the screen is reprogrammed, you end up with a larger border on the CPC.
This (the larger border) led to the false argument that the CPC's resolution was inferior to the Spectrum one although the amount of pixels on the screen is EXACTLY the same.
 
=====Mode 0=====
 
When using mode 0, the screen can be reprogrammed to use the same sized screen as when using mode 1. However the resolution would be 128x192.
 
=====Screen dimensions=====
 
By setting CRTC register settings the Amstrad's screen dimensions can be reprogrammed to match the Spectrum's.
The normal values used are R1=32, R6=24.
There are advantages to reprogramming the screen dimension to match the Spectrum's.
* The gameplay is similar because the player sees the same amount of map and there are the same number of enemies and they move in the same way.
* Graphics/levels would not need to be designed for a wider screen (e.g. in mode 1, 320 compared to 256)* For a smaller screen less memory is used for the Amstradscreen (16KB vs 12K). The memory used by the screen is the same regardless of CPC mode used. Unused areas can be used to store graphics, code and music. For a 320x200 CPC screen normally takes 16Kat &c000, but when reduced in size it takes 12K.the unused areas are: c600-c7ff, ce00-cfff, d600-d7ff, de00-dfff, e600-e7ff, ee00-efff, f600-f7ff, fe00-ffff
=====Random numbers=====
Providing a game had to deal with 1bpp to 2 bpp conversion, Software Sprites and Scrolling and complicated gameplay, adding some Raster interrupt to the equation is a really bad move and a good way to waste even more CPU time.
 
==Amstrad interrupt positions==
 
The following image shows where the Amstrad's interrupt positions are located relative to the screen. Here the CRTC Register values used are R1=32, R2=42, R6=24 and R7=30 and the colours are changed at the start of the interrupt.
 
To have different positions vertically you can change the value of R7 (and if the monitor will accept it R5) to move the screen up and down.
For example Gryzor sets R7=29 to have a 1 char tall panel at the bottom in mode 1.
 
To change at later positions you can also use a software timing loop, or fill the time with other code to delay the colour change from a chosen interrupt position.
[[File:Interrupt_positions_spectrum_sized_screen.png|Screenshot of Amstrad interrupt positions showing where mode and colours can be changed quickly relative to pixel graphics. R1=32, R2=42, R6=24,R7=30]]
[[Category: Games| ]][[Category:Programming]][[Category:Games Programming]][[Category:CrossDev]][[Category:CPC History]][[Category:Non CPC Computers]]
2,541
edits