Thanks to Julio Marchi for this space in MSX All
 



  1. Introduction
  Probably you have already seen a type of MSX 1 image which could be loaded on the screen using some animation, as seen on the logo above.
  The brazilian program Graphos III, a MSX 1 graphic editor, included an option to add animations to the images. Using the "display" option on the main menu, the user had four different animations: direct load, horizontal stripes, from left to right and random display.
  In fact, this type of screen is an executable program which includes the image. This executable is responsible for loading the image on the screen and perform the animation. So, the animated images must be loaded using the Basic command "bload" followed by the option ",r" instead of ",s", used on dump images.
  The "Screen 2 Show" project aims at developing display codes for MSX 1 screen 2 images. Futhermore, it compresses the image using RLE algorithm.
  This project is now aggregated to MSX Viewer 5.0 project and it takes all the advantages from this image convertion tool.

  Available displays

Display Description
  Load the image directly.
  Load the image from top to bottom.
  Load the image from left to right.
  Load the image on diagonal.
  Load the image from ouside to inside by snail shape.
  Load the image from ouside to inside by frames.


  2. The Screen 2 Show Project
  The Screen 2 Show project involves both MSX and PC computers. At the MSX side, aims at developing display algorithms in Assembly. At the PC side, aims at developing tools to help on adding the display code to images converted to MSX.
  Currently, this project works only with MSX 1 screen 2 format. Thus, it is extensible to other screen formats.


  How the program works

        File                      RAM                  RAM                  VRAM

 10 SCREEN 2                9000 | MMMPPP |      4000 | PPPPPP |      0000 | PPPPPP |
 20 BLOAD"TELA.SCR",R  ->   .... | CCDD   |  ->  .... |        |  ->  .... |        |
 30 GOTO 30                 FFFF |        |      5800 | CCCCCC |      2000 | CCCCCC |

  The first action is to load the program into the RAM, starting at the address &H9000. It is divided into:

  • The main program (marked as a green "M")
  • The compacted image (marked as a blue "P" and a red "C")
  • The display program (marked as cyan "D")

  The main program extract the compressed image into the RAM region starting at address &H4000. The extraction could be permormed directly to the VRAM, but it should increase considerably the complexity of the display algorithms.
  Once extracted the image, the main program calls the display program. This is responsible for copying data from RAM to VRAM. The resulting animation is due to the way the data is copied to the VRAM.


  File layout

Part MSX Address
Header 9000
Main code 900B
RLE compressed picture 9061
Display code xxxx

  xxxx → Undefined address.


  Header description

MSX Address Value Description
- FE  MSX Binary file ID
- 00  Program beggining
- 90  Program beggining (9000)
- xx  End of File
- xx  End of file
- 0B  Exec beggining
- 90  Exec beggining (900B)
9000 xx  Size of compressed image (pat)
9001 xx  Size of compressed image (pat)
9002 xx  Size of compressed image (col)
9003 xx  Size of compressed image (col)
9004 xx  Type of display:
 00 - Direct
 01 - Top to bottom
 02 - Left to right
 03 - Diagonal
 04 - Snail in
 05 - Frame
9005 4D  "M"
9006 61  "a"
9007 72  "r"
9008 4D  "M"
9009 53  "S"
900A 58  "X"

  - → Not used address.
  xx → Undefined value.



  Image compress method

  Image compress method used is simply RLE (Run Length) which works as follows:

  Suppose an string "AAABCCCDDD"

  Each sequence of the same data is counted, resulting on a pair of byte:

  - total (max=255)
  - value of repeated byte 

  At the end of the file, a byte valued as 0 is introduced to indicate the end of data.
  According to that, the original string becomes to: 3A 1B 2C 3D 0

  On the MSX 1 screen 2 pictures, first we compact pattern image area from 0000H to 1800H (VRAM). Then, we do the same to color area from 2000H to 3800H.


  Main code

   10 		ORG  &HC000
   20 		CALL &H72		; INIGRP (Screen 2)
   30 		IN   A,(&HA8)		; *
   40 		CALL PG2		; * Adjust slots to RAM RAM RAM xxx
   50 		OUT  (&HA8),A		; *
   60 		LD   A,(&HFFFF)		; %
   70 		CPL 			; % 
   80 		LD   (&H8FFF),A		; % Adjust page 2 subslot to RAM
   90 		CALL PG2		; %
  100 		LD   (&HFFFF),A		; %
  110 		LD   HL,&H4000		; Beggining of destination RAM to uncompress (pattern)
  120 		LD   DE,&H9061		; Beggining of compressed data
  130 		CALL LE1		; Call uncompress routine
  140 		INC  DE			; Increments compress data pointer (color)
  150 		CALL LE1		; Call uncompress routine
  160 		CALL TELA		; Call routine to copy RAM to VRAM
  170 		IN   A,(&HA8)		; *
  180 		LD   B,A		; *
  190 		LD   A,&HF0		; * Returns original configurations
  200 		AND  A			; *
  210 		OUT  (&HA8),A		; *
  220 		LD   A,(&H8FFF)		; % Returns original configurations
  230 		LD   (&HFFFF),A		; %
  240 		RET 			; END
  250 PG2:	LD   B,A		; *
  260 		LD   A,&B11110011	; *
  270 		AND  B			; *
  280 		LD   B,A		; *
  290 		LD   A,&B00110000	; * Copy routine: xx AA xx xx -> xx AA AA xx
  300 		AND  B			; *
  310 		SRA  A			; *
  320 		SRA  A			; *
  330 		ADD  A,B		; *
  340 		RET 			; *
  350 LE1:	LD   A,(DE)		; %
  360 		OR   0			; %
  370 		JP   Z,FIM		; %
  380 		LD   B,A		; %
  390 		INC  DE			; % Uncompresses data. Found 0 items, ends.
  400 		LD   A,(DE)		; %
  410 		INC  DE			; %
  420 LI1:	LD   (HL),A		; %
  430 		INC  HL			; %
  440 		DJNZ LI1		; %
  450 		JP   LE1		; %
  460 FIM:	RET 			; %

  The main code must be compiled to the memory, starting at the RAM address &H900B.


  Display codes

  470 TELA:	LD   BC,&H1800		; $
  480 		LD   DE,0		; $
  490 		LD   HL,&H4000		; $
  500 		CALL &H5C		; $ Particular routine to display screen
  510 		LD   BC,&H1800		; $ In this case, copies direct
  520 		LD   DE,&H2000		; $
  530 		LD   HL,&H5800		; $
  540 		CALL &H5C		; $
  550 		RET 			; $

  The display code must be compiled to the memory, starting at the RAM address imediately after the compressed image. In this case, the position depends on the size of the compressed data.
  The main program should be fixed on the line 160, changing "TELA" to the display code starting address.

  Display codes
  Support: Screen 2 Achitecture (portuguese)


  3. The Program
  The following prototype works only in Windows. Nevertheless, this project was incorporated by the MSX Viewer 5 project which may work in Windows, Linux and MAC.




LOAD - Load "MarMSX SCR" picture format.
SAVE - Save picture to "MarMSX SCR" format.
COPY - Exports image to clipboad.
PASTE - Imports image from PC clipboard.

EXHIBITION - Type of display:
+ Direct - Direct apearance.
+ Top-Down - From top to down.
+ Left-Right - From left to right.
+ diagonal - Diagonal.
+ Snail In - Espiral to inside.
+ Frame In - Frame to inside.

To load SCR screen format:
On any screen (0 ou 1) type:
bload "picture.scr",r
Where picture is the name of the one to be loaded.

Download:
scr2show1.zip - 175 Kb - PC SCR picture generator (Windows 9x).
pack.zip - 32 Kb - Pack containing sources and demo pics.


Marcelo Teixeira Silveira
Systems and Computing Engineer - UERJ
Computing Engeneer Master (M.Sc.) - UERJ

MarMSX 1999-2017