Changes

Jump to: navigation, search

Speccy Port

56 bytes removed, 15:10, 2 April 2023
/* Consequences of a Spectrum Port */
http://scratchpad.wikia.com/wiki/ZX_Spectrum_technical_information
==Consequences of a Spectrum Port==
===Input===
The Spectrum has more joystick standards than the CPC, however reading the keyboard and joysticks and handling the input on the Spectrum is much simpler, takes less code and takes less CPU time than on the Amstrad.
On the Amstrad it is best to read the keyboard and joystick in one pass and store the data into a buffer which can then be queried later. Then read from this buffer when you need to check the inputs.
===Disc Loading===
The Spectrum +3's disc interface had a design that was close to the Amstrad CPC6128's. This meant that disc loading software that used the disc interface directly could be modified easily to be used on the CPC. There are disc versions of the Alkatraz, Hexagon and Speedlock loaders common to both the CPC and Spectrum.
The good thing is that both shared good disc interfaces, so a disc loading system on the Spectrum, if ported to the CPC would not be a bad thing.
===Tape Loading===
Both the Spectrum and Amstrad had a similar method for loading or saving on cassette. For both it is CPU intensive and for both the method of representing the 1 or 0 bits is the same.
* Aliens (UK version, original release).
===Colours===
The Spectrum palette (15 colours, bright at bottom):
* Recolour the graphics using the Amstrad's palette to improve the look.
===Colour Clash from the Cell based colouring===
The cell based colouring used on the Spectrum has its disadvantages. [[image:clash.png|right|thumb|Colour clashing in Knight Tyme. Observe the appearance of the character sprite as it merges with the background. (Background colours have priority here in this game.)]]
* [[Deflektor]] (main play area has one set of colours, status panel has another set)
====Advantages of the cell based colouring====
The Spectrum's cell based colouring has advantages.
===== Conveying state on a HUD =====
The state of a game play element on the HUD can be coloured accordingly. e.g. a bomb that is about to explode could change colour from white to red.
* If you have enough free palette entries, e.g. mode 0, then you can change the colour for the pen used to display the item in the palette. This is quick. However if you are using mode 1, then the number of palette entries is much more limited and you should draw the bomb in a different way. The consequence of this is that you may need to store additional graphics for this and it will take much longer to update the HUD than on the Spectrum.
===== General colouring =====
Since the background and foreground colour can be defined per cell then you can use all the Palette of the Spectrum at once.
* If you are using mode 1 then you will see less colour. You can set the colour palette for multiple regions on the screen, or you can use the 4 colour palette more creatively.
====Sound====
There is 1 sound source on 48K spectrums: its beeper, and 2 sources of sound on 128K spectrums: beeper and AY.
* Super Hang On
====Graphics====
The Spectrum's graphics use 1 bit per pixel to define them. Each byte defines 8 pixels. The colour of each pixel is then defined by the attribute system.
The following sections describe possible ways to handle the graphics on the Amstrad.
====Techniques used for Graphics====
=====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).
* [[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.
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 from the Spectrum graphics.
Advantages:
* Pixel data took less RAM than if it  ====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. Using mode 0 has additional impact on the gameplay and game logic:- there are fewer pixels horizontally therefore both tiles and sprites are described by fewer pixels in width (although pixels are wider). Then any calculations that use pixel coordinates will need to be adjusted. This includes positioning sprites on the screen, sprite to sprite collision, converting sprite pixel coordinates to a tile map location, converting sprite pixel coordinates to a collision map location, determining if a sprite is moving off the right side of the screen.  If the original sprites were square on the Spectrum (e.g. 16x16), then with mode 0 they are 8x16, and we may need additional code for these calculations to handle that. - movement per pixel will be faster horizontally than vertically. We can accept that, or if movement is meant to be the same in all directions then sprites may need to move faster vertically to ensure the movement is consistent. This then has an impact on gameplay because sprites will take less time to move over the screen and any time based goals may need to be adjusted to compensate and make the game goals consistent. Using mode 1 is the route to a quicker port because there are less changes to the game code. was stored in an Amstrad 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=====
Amstrad's mode 1 is the closest mode which compares with the Spectrum's graphical abilities.
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. Using mode 0 has additional impact on the gameplay and game logic:- there are fewer pixels horizontally therefore both tiles and sprites are described by fewer pixels in width (although pixels are wider). Then any calculations that use pixel coordinates will need to be adjusted. This includes positioning sprites on the screen, sprite to sprite collision, converting sprite pixel coordinates to a tile map location, converting sprite pixel coordinates to a collision map location, determining if a sprite is moving off the right side of the screen.  If the original sprites were square on the Spectrum (e.g. 16x16), then with mode 0 they are 8x16, and we may need additional code for these calculations to handle that. - movement per pixel will be faster horizontally than vertically. We can accept that, or if movement is meant to be the same in all directions then sprites may need to move faster vertically to ensure the movement is consistent. This then has an impact on gameplay because sprites will take less time to move over the screen and any time based goals may need to be adjusted to compensate and make the game goals consistent. Using mode 1 is the route to a quicker port because there are less changes to the game code. =====Screen dimensions=====
By setting CRTC register settings the Amstrad's screen dimensions can be reprogrammed to match the Spectrum's.
* For a smaller screen less memory is used for the screen (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 CPC screen at &c000, the unused areas are: c600-c7ff, ce00-cfff, d600-d7ff, de00-dfff, e600-e7ff, ee00-efff, f600-f7ff, fe00-ffff
=====Random numbers=====
Sometimes Spectrum games generate random numbers by reading from the Spectrum's ROM which is always readable in the memory range &0000-&3fff.
Where possible the Spectrum and Amstrad versions should use the same random number generation based on a stored seed.
=====Double buffering=====
TODO:
=====Memory arrangement=====
Spectrum game's often use the memory from &5500-&ffff.
On the other hand, as mentioned before, those games weren't always bad. Games with no need of scrolling and with re-coded graphics could actually be good.
 
=Investigation into a Speccy Port=
2,562
edits