title: MSX Video access method
text: # MSX Video access method
  
  The ColecoVision, SG-1000, CreatiVision, and first-generation MSX computers use the TMS9918A Video Display processor (VDP), which has its own 16 KiB of video memory that was not shared with main memory. Compared to the unified system and video memory used by other 8-bit computers of the time, such as the Apple II, ZX Spectrum, and Commodore 64, separate memory has the advantage of freeing up of the Z80 processor's 64 KiB address space for main RAM, and the VDP does not need to steal CPU cycles to access video memory. The disadvantage is that the program has to use the CPU's dedicated I/O instructions to command the VDP to manipulate the contents of the video RAM. This not only slows down video access but also makes the porting of games from unified-memory platforms more difficult. Attempts of porting ZX Spectrum games (in the UK, the system most similar to the MSX) were often thwarted by this difference. Also, programmers had to learn to optimally use the more advanced capabilities of the VDP.
  
  The TMS9918A's method of accessing the video RAM is slower than direct access, as used in unified-memory computers, because accessing video memory involved first outputting the low- then the hi-byte of the (14-bit) video memory address to I/O port $99, then one or more bytes of 8-bit data to port $98. After each write, the memory pointer advances to the next address, so consecutive addresses can be written to with repeated OUT instructions to $98. Z80 had as fast OTIR/OTDR block instructions which could be used instead of LDIR/LDDR, still, allowed VRAM access rate was restricted unless during vertical blanking.
  
  However, because of the screen layout, (which was top-down for each character of 8 lines then advancing to the next character) this was difficult to use for programmers who tried to convert existing software originally written for a system that had another arrangement of the screen layout. So when trying to use the TMS9918A high resolution mode video memory in the conventional way this method of indirect-access could be far slower than in 8-bit computers with unified memory, like any other piece of RAM. Consequently, machines using this VDP could be inefficient at certain graphical tasks, such as scrolling games, which entailed moving the entire background memory. Instead of being able to use the Z80's efficient and fast block move instructions they had to write elaborate routines that first read bytes from video memory into system memory, and then back to another location in video memory, all one byte at a time.
  
  To increase the speed to an acceptable level the programmers then often limited the scrolling to 8-pixel steps, which looked primitive in comparison to the 1 or 2 pixel scrolling steps available to the ZX Spectrum or Commodore 64 machines (although the Commodore 64 also used 8-pixel steps it had a fine-scroll register which could compensate for this, the MSX-1 did not).
  
  The TMS9918A did have several features to make up for this shortfall, for example a programmable character set which allowed indirection, (to greatly increase scrolling because only the character table had to be moved, instead of the pixel data) and by having 32 hardware sprites. These sprites however were more limited than those in (for example) the Atari-8-bit systems. Because in their highest resolution they were only 16x16 pixels in a single-color (with transparency). A bigger drawback though was that in reality only scan line segments from a maximum of 4 sprites could simultaneously be displayed on any one picture scan line. Attempting to place a 5-th sprites scan line segment on the same scan line as the four others would result in flickering or missing scan line segments. Still, with care multiple multi-color sprites could be created this way, as many Japanese games prove. The ZX Spectrum did not have sprites, but when porting games it was often too much trouble to re-write the game structure to take advantage of the sprites. So most often they were simply ignored when porting games.
  
  There were tricks available to circumvent the scrolling and other speed related problems by using clever programming techniques and video chip capabilities that were not available in the ZX Spectrum, such as using an undocumented text mode that supported multiple colors. In addition, by using the built in re-programmable fonts, it was possible to combine high resolution graphics with faster scrolling while also being able to use sprites. This method was widely used by Japanese programmers writing native software, but rarely by British programmers who were porting Spectrum software.
  
  Most of the video problems described above, especially sprite limits and scrolling, were fixed with the newer MSX-2 video chips. However, by that time 16 bit systems like the Amiga and Atari ST had started to dominate the market.
  
  