Thanks to Julio Marchi for this space in MSX All
 


  Introduction

  Some day you should have loaded a MSX 1 screen 2 picture using ",R" on the final. But, aren't screens loaded with ",S" on the final? Yes, but this way simply copies the image file to VRAM, through ROM routines. Anything after file header is treated as screen data. Even if  image has a code before it, the code will be shown as a great "artistic" image.
  To solve this problem, we can load image as if it were a binary file. To perform this, we must include an assemby code to load image into VRAM. In adicction, if we can control image RAM to VRAM transfer, we can compress it! Plus, we can control how image appears on screen, I mean, some known transiction effects can be added.


  Image compress method

  Image compress method used is simply RLE (Run Length) where works this way:

  According to a normal string, e.g.: AAABCCCDDD,

  Uninterrupted sequences of data are counted, forming a pair of byte where:

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

  In the end we signalize 0 to indicate the end of compressed data. So, the original string becomes to: 3A1B2C3D0

  On MSX 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.


  MarMSX SCR file division

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


  Header
 
MSX Address Value Meaning
x FE  MSX Binary file ID.
x 00  Program beggining.
x 90  Program beggining (9000)
x xx  EOF.
x xx  EOF.
x 0B  Exec beggining.
x 90  Exec beggining. (900B)
9000 xx  Size of compressed image.(pad)
9001 xx  Size of compressed image.(pad)
9002 xx  Size of compressed image.(cor)
9003 xx  Size of compressed image.(cor)
9004 xx  Type of display.
9005 4D  "M"
9006 61  "a"
9007 72  "r"
9008 4D  "M"
9009 53  "S"
900A 58  "X"


  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,&H9005		; 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 			; %
  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 			; $

  Screen display

  Link to display sources - MAKE YOUR OWN DISPLAY!
  Screen 2 Achitecture


  Program




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-2005