Thanks to Julio Marchi for this space in MSX All
Create animated displays for MSX screen 2 images.
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 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.
xxxx → Undefined address.
- → 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.
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 ; Start of dest. RAM to uncompress (pattern) 120 LD DE,&H9061 ; Start 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.
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.
Systems and Computing Engineer
Expert in Image Processing and Artificial Intelligence
© MarMSX 1999-2020