I've developed a really good technique for extracting the differences between images and only recording that changed data (so the packing is more efficient). The previous packed images for the Asteroid GIF resulted in a 28.5K tape file.
Code: Select all
@ECHO OFF
:: Full Screen Asteroid2
:: Enable variable changes within FOR loops
SETLOCAL EnableDelayedExpansion
SET MAINPATH=%OSDK%\LUNARCOM\
SET IMAGEPATH=VIDEO\ASTEROID2\
:: For Main Program
DEL %IMAGEPATH%\*.PNG
convert %IMAGEPATH%\ASTEROID2.gif -coalesce -resize 198x155 -ordered-dither o2x2,6 %IMAGEPATH%\ASTEROID2%%02d.PNG
:: Change directory to the IMAGEPATH
CD "%IMAGEPATH%"
:: set DUMMY file name (for when the 1st PNG is processed)
SET OLDFILE="DUMMY"
:: Read all PNG files in the IMAGEPATH dir (PNG's created from above IM convert cmd)
FOR %%a IN (*.PNG) DO (
:: The first file needs to be processed differently
IF !OLDFILE! == "DUMMY" (
%OSDK%\bin\pictconv -f0 -d0 -o2 %%a chunk.hir
%OSDK%\bin\FilePack -p chunk.hir chunk.pak
%OSDK%\bin\Bin2Txt -s1 -f2 chunk.pak %MAINPATH%\%%~na.s _%%~na
) ELSE (
:: Create MASK of changes (the current %a file compared to OLDFILE)
compare -metric AE -fuzz 20%% !OLDFILE! "%%a" -compose Src -highlight-color White -lowlight-color Black %%~na_Mask.png
:: Use MASK to extract only the changed pixels from original image
convert %%a %%~na_Mask.png -alpha Off -compose CopyOpacity -composite %%~na_X.png
:: Add Black Backround (remove the transparency)
convert %%~na_X.png -background Black -flatten %%~na_X.png
:: use OSDK to produce final, compressed .s files
%OSDK%\bin\pictconv -f0 -d0 -o2 %%~na_X.png chunk.hir
%OSDK%\bin\FilePack -p chunk.hir chunk.pak
%OSDK%\bin\Bin2Txt -s1 -f2 chunk.pak %MAINPATH%\%%~na.s _%%~na
)
:: Set OLDFILE to be the current file (next file is compared with this one)
SET OLDFILE="%%a"
)
pause
What this bat file does is this:
Take the GIF file and extract all the images as resized, dithered PNG's.
File 1 is processed normally (no changes, we want the whole image)
File 2 is compared to File 1
File 3 is compared to File 2 and so on...
In each comparison we create a MASK file (of ALL the pixels that have changed)
So we have say: FILE2-Original.PNG and FILE2-Mask.PNG
We then use the MASK file on the original which yields ONLY the interesting data FILE-X.PNG.
FILE-X.PNG is turned into Oric data using the usual Pictconv, FilePack and Bin2Txt.
This means MUCH smaller .s files and hence much smaller program. Down to 21.4K!
For playback (within the Oric) we have to be a bit careful.
File 1 has to be displayed as is (the whole file)...that works OK.
File 2 and subsequent files only need to have the data that has changed to be printed. If we print the whole file it will overwrite the original data with BLACK. And this is where the fun starts and I am stuck...
Here's the business end (the code that prints each byte on screen)
Code: Select all
_BytePrint
.(
; load next byte
lda (tmp0),y
; compare with existing screen location (if same data then skip)
cmp (tmp1),y
beq skip
; if new data is blank then old data must be retained (skip)
cmp #64
beq skip
; else data is different so print it
sta (tmp1),y
skip
iny
rts
.)
Original Frame
- Frame 01 (original) from GIF
- ASTEROID201.PNG (2.5 KiB) Viewed 21531 times
The Mask of FILE 01 ( when compared to FILE 00) - note the area of space VACATED by the asteroid
- The mask (contains ALL pixels that have changed...including BLANK ones)
- ASTEROID201_Mask.png (971 Bytes) Viewed 21531 times
The final differences between 01 and 00 (ONLY the "interesting" pixels that have changed)
- Final file (only interesting pixels)
- ASTEROID201_X.png (1.01 KiB) Viewed 21531 times
Oh balls I've just answered my own question...
This can't work as it is working at a PIXEL level. On the oric we have to work in 6 pixel chunks so data is getting lost which is corrupting the playback...AAAAAAAAAAAARRRGGGHHH!!!!!!
So CLOSE I can taste it....I'd thought the ASM was wrong (it might be!) but that ain't the problem...