View Single Post
Old 26 April 2021, 14:26   #3
lmimmfn
Registered User
 
Join Date: May 2018
Location: Ireland
Posts: 684
Not to take away from the awesome work done by the batman group but some of the effects are relatively simple to achieve on the CPC

e.g. the scoreboard is mode 1 and the main playing area is mode 0. This mode change is quite simple to achieve along with colour changes.

The CPC has interrupts which are triggered every 300th of a second and obviously the screen refresh is 50Hz so updated every 50th of a second. This provides 6 interruptable positions on the screen for which the mode can change or the colours can change. Scroll down here to the section "Secrets of the CPC screen" https://www.chibiakumas.com/z80/platform5.php#LessonP41 which shows these 6 positions.
To do mode/colour changes outside of these 6 positions requires use of CPU NOP's( can have code but tricky ) as the CPU needs to execute the operation at the exact time that the line is drawn.

Overscan is very easy to setup on the CPC, you just change the CRTC registers for the screen size, it does consume a lot of memory though. The same page linked above shows how to create an overscan screen by reconfiguring the CRTC registers.

Most CPC games used awful software scroll, this consumes a lot of CPU copying the data and running the game logic also, that is why many CPC games seem slow/clunky.

However the CPC's CRT does actually provide a hardware scroll mechanism, the firmware even has 8 pixel horizontal/vertical scrolling in it, but looks awful, you see that in Roland on the Ropes and some other earlier software.

The screen can be scrolled vertically per pixel(this is what is used in Pinball Dreams). Horizontal scrolling isn't per pixel though, its 2 mode 0 pixels, 4 mode 1 pixels and I think 8 mode 2 pixels(never tried it in mode 2 but would expect that).
The Batman Group demo of Mario shows per pixel scrolling, however its achieved as far as i remember reading by offsetting the tile pixels and redrawing the screen and hardware scrolling after 4 pixels in mode 1. This type of storing offset gfx data is what the ST also used for scrolling.

However hardware scrolling the screen with the CRTC means all the screen co-ordinates also change, e.g. if vertical scrolling the initial top left location lets call it coordinates 0,0 will scroll down the screen to sprite updates need to recalculate all the new positions based on the scroll.

What is a little trickier to achieve is hardware scrolling a portion of the screen while another part remains static as in Pinball Dreams where the score is static and the play area scrolls. This is achieved with a CPC technique called "rupture" and its effectively reprogramming the screen layout of the CRTC as the beam moves down the screen.

The rupture effect is also shown on the same page i linked above, i still haven't got my head fully around it especially when combined with scrolling. I have several docs on it but still a bit puzzled, its trickier mainly because there's 1000's of ways to get it wrong, timing is critical and you cant see visually if its just something that needs to be tuned slightly as the screen will be all over the shop

The threads on the CPC wiki provide a lot of the assembly code for smooth vertical and horizontal coding.

There's some other funky effects like a mode 3 effect which effectively provides 2 bitplanes. This means the sprites can be wiped without affecting the background, however this limits colours to 4 colours for sprites and 4 for the scrolling playfield. This effect is used in Mission Genocide.

Basically using the hardware for most of the effects free's up the CPU for actual gameplay and is why newer titles are a lot smoother than most of the shovelware the CPC got back in the day.

I think its wonderful today that all these techniques and information on them is available to anyone. Back in the day even getting a Z80 book was difficult and affording an assembler was another issue. I loved programming in basic on the CPC back in the day but love messing about with Z80 on it nowadays.
lmimmfn is offline  
 
Page generated in 0.04722 seconds with 11 queries