SCREEN COMPRESS

by Luca Rasca



The only listing I received was this assembly listing, so rather than

work it out as a hex dump (argh! all those swirling bytes!), I am

setting this month's challenge to improve the screen packing of this

routine. You can write your own one from scratch if you want. Send

these and any other brilliant programs and routines to: Program

Pitstop, Your Sinclair, 14 Rathbone Place, London W1P 1DE. That's it!

See you soon!



Screen Compress

Here is a fairly simple screen compression sub-routine from Luca

Rasca. It scans through your screen and stores a compressed version at

50000. It does this by taking note of all the zeros and recording how

many it finds. Since it scans across the screen it doesn't find 255s

which are frequently as common as zeros. But here it is:



Assembly Listing

0000            00000  ;Screen Compress

0000            00000  ;by Luca Rasca

0000            00000  ;from Your Sinclair, Feb'88

0000            00000  ;

0000            00000  ;I added the FINISH step to

0000            00000  ;load BC with the end address,

0000            00000  ;so that USR 65200-50000 will

0000            00000  ;give the compressed screen

0000            00000  ;length.               [JimG]

0000            00000         org  65200

FEB0 210040     00000  COMP   ld   hl,16384

FEB3 1150C3     00000         ld   de,50000

FEB6 7E         00000  LOOP1  ld   a,(hl)

FEB7 A7         00000         and  a

FEB8 12         00000         ld   (de),a

FEB9 280A       00000         jr   z,ZERO

FEBB 23         00000         inc  hl

FEBC 13         00000  CONT   inc  de

FEBD 3E5B       00000         ld   a,91

FEBF BC         00000         cp   h

FEC0 20F4       00000         jr   nz,LOOP1

FEC2 42         00000  FINISH ld   b,d

FEC3 4B         00000         ld   c,e

FEC4 C9         00000         ret

FEC5 4F         00000  ZERO   ld   c,a

FEC6 13         00000         inc  de

FEC7 23         00000  LOOP2  inc  hl

FEC8 3E5B       00000         ld   a,91

FECA BC         00000         cp   h

FECB 79         00000         ld   a,c

FECC 12         00000         ld   (de),a

FECD 28F3       00000         jr   z,FINISH

FECF AF         00000         xor  a

FED0 BE         00000         cp   (hl)

FED1 20E9       00000         jr   nz,CONT

FED3 0C         00000         inc  c

FED4 20F1       00000         jr   nz,LOOP2

FED6 18E4       00000         jr   CONT

FED8            00000  ;

FED8            00000         org  65248

FEE0 F3         00000  EXPAND di

FEE1 110040     00000         ld   de,16384

FEE4 2150C3     00000         ld   hl,50000

FEE7 7E         00000  LOOP3  ld   a,(hl)

FEE8 A7         00000         and  a

FEE9 12         00000         ld   (de),a

FEEA 2009       00000         jr   nz,RICONT

FEEC 23         00000         inc  hl

FEED 46         00000         ld   b,(hl)

FEEE B8         00000         cp   b

FEEF 2804       00000         jr   z,RICONT

FEF1 13         00000  LOOP4  inc  de

FEF2 12         00000         ld   (de),a

FEF3 10FC       00000         djnz LOOP4

FEF5 13         00000  RICONT inc  de

FEF6 23         00000         inc  hl

FEF7 3E5B       00000         ld   a,91

FEF9 BA         00000         cp   d

FEFA 20EB       00000         jr   nz,LOOP3

FEFC FB         00000         ei

FEFD C9         00000         ret

