13/10/2019

The CPC has hardware scroll!

If you don't understand spanish, you can jump the rest of this paragraph... los demás, espero que me podais disculpar por usar inglés en este artículo, ya que va en contra del espíritu del blog, pero creí que era una buena forma de mostrar mi punto de vista sobre un asunto que ha saltado en el foro inglés. Principalmente para no enmierdar más el hilo sobre el Pinball Dreams, es curioso que siempre ocurren estas cosas con lanzamientos españoles, llamadme mal pensado y lo que queráis :P De todas formas, ésta es una de esas batallas con las que nos solemos enfrentar bastante a menudo, pero bueno es lo que pasa con el personal que no tiene NPI y pretende sentar cátedra sobre asuntos que desconoce en ciertos canales de vídeo que parecen "impedir la rectificación", si, si, Evaristo... de todas formas prometo que no será divertido, ni tendrá fotos que hagan todo más ameno :P... varios días después... en fin, fue un error escribir este artículo en inglés porque los asnos para lo que esto fue escrito simplemente lo ignoraron y siguieron erre que erre, por lo menos fue divertido de escribir y recibir el feedback de Axelay... quizás la única persona con la que no tiene sentido hablar de este tema, ya que lo domina perfectamente, como no ha dejado de demostrar con sus juegos... de todas formas, hacía tiempo que no hablabamos y pudimos discutir de temas serios como el Masterchef Australia.

The first question to answer is about what is an scroll routine. Well, an scroll routine can be split in two basic task:

  1. Shift every pixel in the screen in the way of the scroll (every pixel needs to go up or down, left or right).
  2. Filling with data the new columns or rows that are entering in the screen.

The most expensive task is the first one by a lot. And even, if we have specialized hardware for helping to the cpu with the second task, for example a blitter or another DMA copy method. This is not a hardware scroll for me, but every scroll routine needs to fill the new rows and columns.

In my opinion, a hardware scroll is when we have extra hardware that helps the cpu with the first task, the real expensive one.

That extra hardware can be an specific IC or combination of ICs in an official or unofficial way that let you do one of those two things:

Of course, we can find lucky systems where we are assisted in both things like the Amiga, CPC+ or C64 with the nice VSP trick.

One important note, in systems where you can only change in steps of video page accuracy, the only thing that you can make is a double buffer (change video pages), but the two scroll task need to be fully made with the CPU (shift the pixels and write new data). Even if you have a tile system as in the case of the msx1, where you could have pre-rotated tiles in RAM; at the end of the day, it is the cpu the one making the expensive task of copying/replacing new tiles in the tilemap or directly over the tile bank. That means those systems are making a software scroll.

In short, the CPC has hardware scroll because there is extra hardware, the CRTC, helping to the z80 in the first task (shifting the pixels in the screen). Sure, that there is systems better equipped for doing this first task with better accuracy (pixel or even smaller steps), in a more direct way (with specific registers for choosing the specific smooth scroll rate) or even able to clip the screen view (hiding the rightmost column), ... ; but that it doesn't mean than the CPC lacks of hardware scroll.

Now, we could discuss why there is so few CPC games making hardware scroll, the easy answer is that this technique is not easy or that is undocumented. But I am going to try to break those myths.

Every CPC user has made a hardware scroll since the moment that he/she has used the cursor keys for putting the text cursor in the vertical screen limits for moving the screen up or down; or every time that we have listed a basic program that uses more than 25 lines; or when everybody has written and run the typical:

10 PRINT "SyX is the best!":GOTO 10

The meaning of this is that the original OS developers, Locomotive, always knew about the hardware scroll feature of the CRTC. But this wasn't a secret that Locomotive used as an advantage over the rest of developers, not at all.

In the official Amstrad CPC Firmware books (Soft 158 or Soft 968), you can read in the Screen or the Machine Pack chapters about how you can move the screen address (up, down, left and right), and this feature is used by the Text VDU for rolling the screen.

And because that there is a few firmware calls that can be used for making a hardware scroll, the two more important in the Screen system are SCR SET BASE (#BC08) and SCR SET OFFSET (#BC05). Although at the end, those firmware calls are redirected to a more general firmware call from the Machine Pack, the function MC SCREEN OFFSET (#BD1F), function that is so well documented as the rest of the firmware.

This routine let you use and learn about making coarse hardware scroll in the CPC.

In short, we should consider official and well documented the use of coarse hardware scroll in the CPC.

Sure, nobody making games used the firmware, that it should be the new excuse, no? But that is not true at all, the first CPC games made use of the firmware for a lot of things and a few ones even used the firmware for making scroll.

And when the system was better known, in the same way that developers, that accessed directly to the hardware, were inspired by the MC WAIT FLYBACK (#BD19) firmware call for making their own wait for the vertical blank routine; then in theory they should have researched those firmware routines for making hardware scroll.

With respect to the matter of making smooth hardware scroll in the CPC, we know that is possible, hard, but possible. Kudos for Rhino and his clever idea of applying the RVI technique for making the vertical smooth scroll in Pinball Dreams and kudos again for making available an example source for everybody can use that technique in new projects.

But during the CPC commercial era (1984-1994), those hard CRTC tricks were secrets used for game developers to get advantage over their rivals... it is a shame that they were not shared between professional CPC developers, because the technical quality of the CPC games would have been increased a lot... but now, we are here for showing the real limits of the CPC thanks to those advanced programming techniques.

And of course, it didn't help that it was easier and faster to port the logic from the speccy that making an exclusive CPC game logic. Specially when the only way of achieving those nice and smooth hardware scrollers during this era, required CRTC datasheets, machines with enough CRTCs and time for testing. Those resources were not available or achievable for every developer during those years.

The only other machine with a similar CRTC configuration was the BBC, but the different cpu made not possible to share logic between those two systems.

In consequence, we should say that smooth hardware scroll in the CPC was not documented or unofficial, but possible.

Along the commercial life of our machine, I have found 95 games using hardware scroll, that amount must be even less than 1% of the total of CPC games launched, but I though that we could make a graphic with the evolution of CPC games using hardware scroll and the kind of scroll (Vertical, Horizontal or Multidirectional):

There is a few important things in this graphic, the first two CPC multidirectional scroll are the spanish games Fred (Roland on the Ropes) and La Pulga (Roland in the Caves) from 1984. Those two games are important for a lot of reasons, mainly because they helped to make possible the creation of Amstrad España.

As we can see, Multidirectional and Horizontal coarse scroll were techniques known since the beginning of the CPC.

With respect to Vertical coarse scroll, I originally thought that there was not examples of it. But lucky for me, Axelay wrote me about the helicopter level in Assault on port Stanley by Shirekilo from 1985, you can test this level by pressing space during the game. This level is making its scroll using the firmware call MC SCREEN OFFSET (and aside of that, it uses double buffer and the graphics are offset by half of a character). Really interesting discovering, because we have the proof that since the beginning every idea about using hardware scroll for the CPC was tested, hehehe.

Two years later, in 1987, Mission Genocide was launched, making this game the first one using vertical smooth hardware scroll and after this event, every CPC game using vertical scroll took "inspiration" in how Mission Genocide did first.

With respect to the first smooth horizontal scroll in the CPC, that it should be the 1989 release of Skate Wars by Ubi Soft; but Axelay make me remember that the correct answer should be Out of this World by Reaktor in 1987 (Thanks again mate!).

This fact makes this year, 1987, a very important one, because this year was when the secrets of smooth hardware scroll in the CPC were unveiled. It doesn't mean that the techniques used by those games were the only way of getting smooth scroll in CPC games, but certainly this was the moment that should be used as the reference point to finish every talk about "CPC games can not scroll fast and smooth" myth... although not everybody got the memo, because nowadays we can continue read about how the CPC can not scroll at all.

Another thing that we have always read is about how making smooth vertical scroll in CPC is easier than horizontal ones, although the number of games using vertical scroll is considerable less. Another fun thing is that this year, 2019, are going to be launched 3 (+ 1/2 ;)) games using smooth vertical scroll, that is half of all CPC games using this kind of the scroll during its commercial life.

Great times for CPC games using hardware scroll! :)

Great times for the CPC! :)


-*-