News:

Function Finder  Find all the functions within source code files

Main Menu

2 Colour Image RLE compressed

Started by kevin, February 24, 2010, 06:21:34 AM

Previous topic - Next topic

kevin

 2 Colour Image RLE compressed

 This is really a string thrashing exercise converted into a demo of sorts.  The demo simply displays an image that fades it in and out.  The Image is stored in STRING form though, which is decoded each frame.  The goal here was to thrash the guts out of the PB string engine.    Happily runs over a 100fps for the entire task.


 PB 1.64K/ PBFX V1.76 version (or above)

PlayBASIC Code: [Select]
 Packed$=""
Packed$+="RRRRRRRRRRRS226lRS223uRS220FRS219JRS217MRS216PRS214VRS205aS8eS6ORS205aS8eS6PRS204cS8fS7QRS204aS8fS7TRS203aS9fS7URS205bS7fS7URS20"
Packed$+="4aS8eS7URS204aS2aS6fS7VRS203aS3aS6eS7WRS205aS8dS6WRS204aS2aS7dS6WRS207aS6cS6XRS206bS7cS5-45:RS205aS2aS11-45:RS207bS11-45:RS206cS"
Packed$+="11FS29qRS204aS3cS9-47:RS208eS6ES28dS5pRS207JS45aS2iRS208iS11nS15aS2aS18iRS207aS2gS8aS3aS2gS35fRS205aS2bS3cS4cS4aS26kS12aS2eRS206"
Packed$+="cS4cS4cS28cS4qRS79aS126dS6bS3cS27bS3bS3pRS77eS128dS6aS4bS24cS4aS3pRS77fS129bS5bS4bS22cS4bS3cS4oRS76eS6bS123aS2aS4aS24aS2bS3aS3bS"
Packed$+="3pRS75eS6cS152aS2bS3fS7bS3aS5hRS75iS157aS2aS3dS5aS10iRS74eS6eS136bS17aS2bS18gRS73lS143cS14aS2aS12bS3aS2aS4fRS72nS144dS23kS15eRS7"
Packed$+="1pS146dS19bS3mS15dRS71fS7jS140dS17aS3nS17dRS70tS148cS15aS3pS19dRS69wS150cS8bS7aS2cS5lS14dRS69tS19cS131dS8aS9bS6kS13dRS65aS3AS151"
Packed$+="dS7bS8dS9dS5eS8cRS67BS153dS6bS7aS2cS7kS14cRS63aS4CS153dS6bS6aS2aS2bS5kS16bRS61bS5DS154dS6cS6aS2bS3nS19dRS60bS5ES155dS6cS5aS2bS3p"
Packed$+="S17aS4bRS59cS5GS157cS5cS6bS3eS6kS16cRS58cS5HS158cS5dS5aS2eS6lS14aS4bRS58bS4IS160cS5cS5bS3bS3hS9bS3aS2aS5bRS58aS3aS2HS159cS5cS5aS"
Packed$+="2bS3aS2bS3cS4bS3aS3aS5bRS57bS4KS162bS4eS6bS3dS5cS4bS3aS3bS5cRS60jS11xS152cS5dS7cS4cS4cS4aS2cS7bRS61dS5bS3fS7aS2aS2cS4gS8bS131cS6"
Packed$+="eS9cS4bS4aS2cS7bS3aS7aRS61bS4aS7aS11aS5fS136cS5fS7aS2aS3bS5dS8aS2cS8dRS61cS29dS134cS7gS8aS4gS12cS8bS3bRS60cS32bS132dS8pS21eS10bS"
Packed$+="4aRS60cS33aS131dS10aS2jS16aS2dS8bS4bRS60cS33aS132cS13aS3aS10gS11aS3cRS58dS36aS131dS23aS2gS11bS4cRS56fS169dS22kS14aS4cRS56dS5aS16"
Packed$+="4dS19mS18aS2cRS57eS169dS9aS4aS3bS3kS16aS3dRS58aS2bS30aS136eS11aS2aS2bS3mS17aS3cRS58dS168gS10aS3aS2aS2nS18aS3cRS57dS169hS12aS2bS3"
Packed$+="mS18aS2cRS57dS113aS56jS11dS5oS19aS2cRS57cS4aS22fS86cS58HS33bS3bRS56eS10hS16hS86dS58HS36bRS58cS10fS15hS84fS10bS50GS33aRS59bS6aS2e"
Packed$+="S6aS10fS7aS77gS10cS50GS32bRS58bS6aS4cS4bS11hS81kS14cS48HS33bRS58cS5aS2aS3fS15gS77aS3lS15cS49FS32aRS59aS6bS4fS13hS78aS2nS17bS48GS"
Packed$+="32bRS58cS6cS5fS13gS76uS21bS47GS32bRS58bS6cS5fS12gS76vS23bS46GS32bRS58cS5aS2bS5gS9gS13bS61bS3wS24bS46GS32bRS58bS4aS2dS8lS19cS61DS"
Packed$+="28bS46FS31cRS58cS5eS10hS9aS9bS59FS30bS45GS32cRS58bS6dS26cS9aS50GS31bS45GS32cRS58cS5fS24fS11aS50aS2FS31aS2aS41HS32cRS58cS5gS9bS3a"
Packed$+="S10gS13bS51HS31cS43HS33cRS58cS5hS10dS5aS3lS17aS49IS34bS3aS38IS34aS2bRS58cS5iS11tS23bS50aS2HS31cS4aS37IS34bS3aRS59bS3lS13qS22aS49"
Packed$+="aS2IS33bS3aS36KS35bS3bRS58cS5GS33bS51aS2HS31cS4aS35KS36bS3aRS58dS5FS34aS49aS3HS32bS4aS33LS37bS3aRS58dS5GS33aS52wS22aS3fS7cS4aS33"
Packed$+="LS37bS3aS2aRS59cS4FS33aS53uS25dS6dS36MS38bS4aRS58dS5GS33aS52tS19aS10aS3cS35kS12aS2xS25aS3aRS59cS4FS32aS52bS3oS29eS35iS10aS6wS23b"
Packed$+="S5aRS58JS37aS51bS4mS29dS6aS30eS6aS8wS24aS4aRS59JS35bS51cS5lS31cS35aS10bS3xS24aS4aRS60HS35aS50cS5kS20aS2aS2bS7cS42aS3FS30aRS60HS3"
Packed$+="4aS51bS5cS5bS3aS11aS2aS2aS2bS6bS42aS4DS30aRS60gS8wS25aS52aS2aS4bS6aS9aS2aS2aS2aS2bS4aS2aS2bS41aS5CS27aS2aRS59hS12tS22aS52aS2aS4b"
Packed$+="S14aS4aS2aS2dS6bS3bS41aS4CS29bRS59gS10vS23aS53aS6aS13aS3aS2aS2eS7fS50BS26aS3aRS57aS2fS9aS3qS76aS4aS12aS3aS2aS2fS8eS45aS4CS28bRS5"
Packed$+="8gS12uS92aS6aS2aS9eS44aS5cS4dS5nS17aS2aRS58fS11aS2qS101aS2bS4eS49aS10nS18bRS59fS9aS2qS94bS5gS8gS52aS2bS3aS4lS16cRS59cS4aS6aS2qS7"
Packed$+="7bS6aS5hS9fS10eS47aS2jS11lS16cRS67aS3qS77cS6aS5aS2mS15aS2gS47CS30bRS63aS2aS3tS19aS60cS7aS7jS13bS3fS10aS33GS33cS5aRS63dS6tS78cS6a"
Packed$+="S11aS8dS5gS10aS33aS2aS2CS28dS6bRS63cS4aS2aS2pS76cS5aS2aS5aS12eS6fS9aS36aS8aS2qS20dS6bRS63aS2bS3aS2pS77cS7cS8aS6aS2fS7eS55pS19dS7"
Packed$+="cRS64bS3aS2qS78dS7cS4aS8jS11eS9aS46pS20cS6cRS64eS6oS77cS7fS7aS3lS13eS8aS44aS2pS21cS5dRS60aS3xS73aS3aS2aS6cS6kS12kS12eS8aS37dS5vS"
Packed$+="24dS7cRS60BS72aS3aS6aS6aS2bS4AS24eS7aS38BS29dS6dRS60aS2AS68aS4aS4aS2aS8bS5FS69bS3wS25aS2bS5dRS59fS11aS2kS59aS5aS11aS3aS3FS71wS25"
Packed$+="aS2aS2bS4dRS58aS3aS14iS58aS2aS3aS11bS3GS73aS2tS21aS3cS6dRS57aS11aS2aS2aS2aS3eS6aS67bS3ES73tS24aS2bS4dRS64qS18aS68bS3ES72uS24aS2a"
Packed$+="S2aS3eRS62wS89aS2ES71aS2qS24aS2bS4dRS61uS20aS69eS6AS69qS25aS2aS3eRS59aS2fS7gS8fS72gS9aS2vS65aS2pS25bS4eRS59eS8aS10dS70hS11aS2tS6"
Packed$+="6oS24bS5dRS58cS18eS71hS12uS64bS3nS26aS2fRS76dS71gS10aS2uS65oS25aS5eRS75eS72gS11aS2qS69gS8bS13aS4dS5aRS62aS2aS2aS9eS73eS9aS2tS72c"
Packed$+="S4cS18fRS59kS16dS74bS8aS2qS74dS20fRS60lS14eS81bS3aS2pS92fRS58nS16dS79xS99eS6aRS59mS14eS80gS8nS91dS5aRS58uS94AS99dS5bRS57vS96wS98"
Packed$+="gRS56aS2tS94xS98hRS57aS2qS89bS4xS96iRS56aS2qS88aS2aS16jS85iRS56aS2bS3nS83aS11aS2aS2aS2bS3iS84hS9aRS57bS3nS89BS99fS7bRS59hS9dS80B"
Packed$+="S99aS2dS5cRS58aS2fS7dS5aS74aS2aS2iS10lS88iRS58aS3cS4aS2bS4aS75aS7bS3aS3mS89dS5cRS59aS5aS2bS4aS5aS70aS13mS90iRS65bS4aS6aS79aS2oS9"
Packed$+="3gRS64bS10aS77uS98fS7aRS73cS7aS70tS99cS4cRS72cS8cS70pS100eRS71dS8dS71oS100eRS69fS9eS69aS2mS101dS5aRS68fS10fS70aS2aS2gS18aS81dRS6"
Packed$+="5aS2aS2fS8gS84bS8aS82cRS64aS5eS8gS83cS7aS2bS82cRS65aS3eS8gS8aS73eS9aS2cS84bRS63aS4aS2dS7iS79gS10aS2aS2bS83bRS65aS3aS2bS6iS78aS2e"
Packed$+="S8aS2eS87aRS67aS8iS75aS2aS2gS11fS88aRS69aS5iS10aS65aS5aS2aS2bS6gRS68aS6kS74aS4aS5cS6aS2fRS73lS78aS4aS8hRS72lS82aS7jRS71nS79aS10j"
Packed$+="RS71mS88lRS70nS87mRS69nS15aS72nRS68pS86pRS68pS87oRS69nS87mRS70mS87lRS70lS13aS75aS2iRS70mS89iRS71jS11aS78gRS71iS10aS80eS6aRS72jS8"
Packed$+="9dS5aRS72iS90bS3aRS73gS90bRS73fS7aS84aRS73gRS74dS5aRS74eRS75cRS75bRS75bRS75aRRRRRRRR"


StartTime=Timer()

Angle#=180

Do
Cls 0

; Check how much time has past
TimePast#=Timer()-StartTime

; calc the frames past since it started at a virtual 60fps
FramesPast#=TimePast#/(1000/60.0)

; mult the frames past by the speed this object is fading
Angle#=FramesPast#*0.5

; Use the angle as to control the brightness of the thing we're
; drawing. In this case, depacking the RLE image from Strings :)
Level#=100+Cosradius(180+Angle#,100)

;Decompress the string of RLE spans that mmake up this 2 colour image
Decompress(Packed$,RgbFade($ffffff,Level#))

; draw the fps()
ink $ffffff
print Fps()
Sync
loop




Function Decompress(R$,ThisColour)

// Build Chr codes$
For lp =asc("a") to asc("x")
ChrCODE$+=Chr$(lp)
next
ChrCODE$+=upper$(ChrCODE$)
ChrCode$=replace$(ChrCode$,"RS","")

// Replace the chr codes with the values
For lp=len(ChrCOde$) to 1 step -1
tag$="-"+str$(lp)+":"
R$=replace$(R$,mid$(chrcode$,lp),tag$,yes,false)
next


// Decode RLE (Run Lenght)
Lockbuffer
For pos=1 to Len(R$)
ThisChr=mid(r$,pos)

; Start of Row
if ThisChr=asc("R")
; reset Pen
Xpos=0
Ypos++
Continue
endif

; Decode Span
if ThisChr=asc("S")

Pos2=Pos+1
EndPos=INstring(R$,":",POs2)
Span$=Mid$(R$,Pos2,Endpos-Pos2)

MidPos=INstring(Span$,"-",1)

XPos =Xpos+val(CutRight$(Span$,MidPos))
RunLength=(val(CutLeft$(Span$,MidPos)))

Linec Xpos,Ypos,Xpos+RunLength,Ypos,ThisColour

pos=endPos
Continue
endif

Next
unlockbuffer

EndFunction







PB1.63 (learning Edition)
PlayBASIC Code: [Select]
 Packed$=Packed$+"RRRRRRRRRRRS226lRS223uRS220FRS219JRS217MRS216PRS214VRS205aS8eS6ORS205aS8eS6PRS204cS8fS7QRS204aS8fS7TRS203aS9fS7URS205bS7fS7URS20"
Packed$=Packed$+"4aS8eS7URS204aS2aS6fS7VRS203aS3aS6eS7WRS205aS8dS6WRS204aS2aS7dS6WRS207aS6cS6XRS206bS7cS5-45:RS205aS2aS11-45:RS207bS11-45:RS206cS"
Packed$=Packed$+"11FS29qRS204aS3cS9-47:RS208eS6ES28dS5pRS207JS45aS2iRS208iS11nS15aS2aS18iRS207aS2gS8aS3aS2gS35fRS205aS2bS3cS4cS4aS26kS12aS2eRS206"
Packed$=Packed$+"cS4cS4cS28cS4qRS79aS126dS6bS3cS27bS3bS3pRS77eS128dS6aS4bS24cS4aS3pRS77fS129bS5bS4bS22cS4bS3cS4oRS76eS6bS123aS2aS4aS24aS2bS3aS3bS"
Packed$=Packed$+"3pRS75eS6cS152aS2bS3fS7bS3aS5hRS75iS157aS2aS3dS5aS10iRS74eS6eS136bS17aS2bS18gRS73lS143cS14aS2aS12bS3aS2aS4fRS72nS144dS23kS15eRS7"
Packed$=Packed$+"1pS146dS19bS3mS15dRS71fS7jS140dS17aS3nS17dRS70tS148cS15aS3pS19dRS69wS150cS8bS7aS2cS5lS14dRS69tS19cS131dS8aS9bS6kS13dRS65aS3AS151"
Packed$=Packed$+"dS7bS8dS9dS5eS8cRS67BS153dS6bS7aS2cS7kS14cRS63aS4CS153dS6bS6aS2aS2bS5kS16bRS61bS5DS154dS6cS6aS2bS3nS19dRS60bS5ES155dS6cS5aS2bS3p"
Packed$=Packed$+"S17aS4bRS59cS5GS157cS5cS6bS3eS6kS16cRS58cS5HS158cS5dS5aS2eS6lS14aS4bRS58bS4IS160cS5cS5bS3bS3hS9bS3aS2aS5bRS58aS3aS2HS159cS5cS5aS"
Packed$=Packed$+"2bS3aS2bS3cS4bS3aS3aS5bRS57bS4KS162bS4eS6bS3dS5cS4bS3aS3bS5cRS60jS11xS152cS5dS7cS4cS4cS4aS2cS7bRS61dS5bS3fS7aS2aS2cS4gS8bS131cS6"
Packed$=Packed$+"eS9cS4bS4aS2cS7bS3aS7aRS61bS4aS7aS11aS5fS136cS5fS7aS2aS3bS5dS8aS2cS8dRS61cS29dS134cS7gS8aS4gS12cS8bS3bRS60cS32bS132dS8pS21eS10bS"
Packed$=Packed$+"4aRS60cS33aS131dS10aS2jS16aS2dS8bS4bRS60cS33aS132cS13aS3aS10gS11aS3cRS58dS36aS131dS23aS2gS11bS4cRS56fS169dS22kS14aS4cRS56dS5aS16"
Packed$=Packed$+"4dS19mS18aS2cRS57eS169dS9aS4aS3bS3kS16aS3dRS58aS2bS30aS136eS11aS2aS2bS3mS17aS3cRS58dS168gS10aS3aS2aS2nS18aS3cRS57dS169hS12aS2bS3"
Packed$=Packed$+"mS18aS2cRS57dS113aS56jS11dS5oS19aS2cRS57cS4aS22fS86cS58HS33bS3bRS56eS10hS16hS86dS58HS36bRS58cS10fS15hS84fS10bS50GS33aRS59bS6aS2e"
Packed$=Packed$+"S6aS10fS7aS77gS10cS50GS32bRS58bS6aS4cS4bS11hS81kS14cS48HS33bRS58cS5aS2aS3fS15gS77aS3lS15cS49FS32aRS59aS6bS4fS13hS78aS2nS17bS48GS"
Packed$=Packed$+"32bRS58cS6cS5fS13gS76uS21bS47GS32bRS58bS6cS5fS12gS76vS23bS46GS32bRS58cS5aS2bS5gS9gS13bS61bS3wS24bS46GS32bRS58bS4aS2dS8lS19cS61DS"
Packed$=Packed$+"28bS46FS31cRS58cS5eS10hS9aS9bS59FS30bS45GS32cRS58bS6dS26cS9aS50GS31bS45GS32cRS58cS5fS24fS11aS50aS2FS31aS2aS41HS32cRS58cS5gS9bS3a"
Packed$=Packed$+"S10gS13bS51HS31cS43HS33cRS58cS5hS10dS5aS3lS17aS49IS34bS3aS38IS34aS2bRS58cS5iS11tS23bS50aS2HS31cS4aS37IS34bS3aRS59bS3lS13qS22aS49"
Packed$=Packed$+"aS2IS33bS3aS36KS35bS3bRS58cS5GS33bS51aS2HS31cS4aS35KS36bS3aRS58dS5FS34aS49aS3HS32bS4aS33LS37bS3aRS58dS5GS33aS52wS22aS3fS7cS4aS33"
Packed$=Packed$+"LS37bS3aS2aRS59cS4FS33aS53uS25dS6dS36MS38bS4aRS58dS5GS33aS52tS19aS10aS3cS35kS12aS2xS25aS3aRS59cS4FS32aS52bS3oS29eS35iS10aS6wS23b"
Packed$=Packed$+"S5aRS58JS37aS51bS4mS29dS6aS30eS6aS8wS24aS4aRS59JS35bS51cS5lS31cS35aS10bS3xS24aS4aRS60HS35aS50cS5kS20aS2aS2bS7cS42aS3FS30aRS60HS3"
Packed$=Packed$+"4aS51bS5cS5bS3aS11aS2aS2aS2bS6bS42aS4DS30aRS60gS8wS25aS52aS2aS4bS6aS9aS2aS2aS2aS2bS4aS2aS2bS41aS5CS27aS2aRS59hS12tS22aS52aS2aS4b"
Packed$=Packed$+"S14aS4aS2aS2dS6bS3bS41aS4CS29bRS59gS10vS23aS53aS6aS13aS3aS2aS2eS7fS50BS26aS3aRS57aS2fS9aS3qS76aS4aS12aS3aS2aS2fS8eS45aS4CS28bRS5"
Packed$=Packed$+"8gS12uS92aS6aS2aS9eS44aS5cS4dS5nS17aS2aRS58fS11aS2qS101aS2bS4eS49aS10nS18bRS59fS9aS2qS94bS5gS8gS52aS2bS3aS4lS16cRS59cS4aS6aS2qS7"
Packed$=Packed$+"7bS6aS5hS9fS10eS47aS2jS11lS16cRS67aS3qS77cS6aS5aS2mS15aS2gS47CS30bRS63aS2aS3tS19aS60cS7aS7jS13bS3fS10aS33GS33cS5aRS63dS6tS78cS6a"
Packed$=Packed$+"S11aS8dS5gS10aS33aS2aS2CS28dS6bRS63cS4aS2aS2pS76cS5aS2aS5aS12eS6fS9aS36aS8aS2qS20dS6bRS63aS2bS3aS2pS77cS7cS8aS6aS2fS7eS55pS19dS7"
Packed$=Packed$+"cRS64bS3aS2qS78dS7cS4aS8jS11eS9aS46pS20cS6cRS64eS6oS77cS7fS7aS3lS13eS8aS44aS2pS21cS5dRS60aS3xS73aS3aS2aS6cS6kS12kS12eS8aS37dS5vS"
Packed$=Packed$+"24dS7cRS60BS72aS3aS6aS6aS2bS4AS24eS7aS38BS29dS6dRS60aS2AS68aS4aS4aS2aS8bS5FS69bS3wS25aS2bS5dRS59fS11aS2kS59aS5aS11aS3aS3FS71wS25"
Packed$=Packed$+"aS2aS2bS4dRS58aS3aS14iS58aS2aS3aS11bS3GS73aS2tS21aS3cS6dRS57aS11aS2aS2aS2aS3eS6aS67bS3ES73tS24aS2bS4dRS64qS18aS68bS3ES72uS24aS2a"
Packed$=Packed$+"S2aS3eRS62wS89aS2ES71aS2qS24aS2bS4dRS61uS20aS69eS6AS69qS25aS2aS3eRS59aS2fS7gS8fS72gS9aS2vS65aS2pS25bS4eRS59eS8aS10dS70hS11aS2tS6"
Packed$=Packed$+"6oS24bS5dRS58cS18eS71hS12uS64bS3nS26aS2fRS76dS71gS10aS2uS65oS25aS5eRS75eS72gS11aS2qS69gS8bS13aS4dS5aRS62aS2aS2aS9eS73eS9aS2tS72c"
Packed$=Packed$+"S4cS18fRS59kS16dS74bS8aS2qS74dS20fRS60lS14eS81bS3aS2pS92fRS58nS16dS79xS99eS6aRS59mS14eS80gS8nS91dS5aRS58uS94AS99dS5bRS57vS96wS98"
Packed$=Packed$+"gRS56aS2tS94xS98hRS57aS2qS89bS4xS96iRS56aS2qS88aS2aS16jS85iRS56aS2bS3nS83aS11aS2aS2aS2bS3iS84hS9aRS57bS3nS89BS99fS7bRS59hS9dS80B"
Packed$=Packed$+"S99aS2dS5cRS58aS2fS7dS5aS74aS2aS2iS10lS88iRS58aS3cS4aS2bS4aS75aS7bS3aS3mS89dS5cRS59aS5aS2bS4aS5aS70aS13mS90iRS65bS4aS6aS79aS2oS9"
Packed$=Packed$+"3gRS64bS10aS77uS98fS7aRS73cS7aS70tS99cS4cRS72cS8cS70pS100eRS71dS8dS71oS100eRS69fS9eS69aS2mS101dS5aRS68fS10fS70aS2aS2gS18aS81dRS6"
Packed$=Packed$+"5aS2aS2fS8gS84bS8aS82cRS64aS5eS8gS83cS7aS2bS82cRS65aS3eS8gS8aS73eS9aS2cS84bRS63aS4aS2dS7iS79gS10aS2aS2bS83bRS65aS3aS2bS6iS78aS2e"
Packed$=Packed$+"S8aS2eS87aRS67aS8iS75aS2aS2gS11fS88aRS69aS5iS10aS65aS5aS2aS2bS6gRS68aS6kS74aS4aS5cS6aS2fRS73lS78aS4aS8hRS72lS82aS7jRS71nS79aS10j"
Packed$=Packed$+"RS71mS88lRS70nS87mRS69nS15aS72nRS68pS86pRS68pS87oRS69nS87mRS70mS87lRS70lS13aS75aS2iRS70mS89iRS71jS11aS78gRS71iS10aS80eS6aRS72jS8"
Packed$=Packed$+"9dS5aRS72iS90bS3aRS73gS90bRS73fS7aS84aRS73gRS74dS5aRS74eRS75cRS75bRS75bRS75aRRRRRRRR"


StartTime=Timer()

Angle#=180

Do
Cls 0

; Check how much time has past
TimePast#=Timer()-StartTime

; calc the frames past since it started at a virtual 60fps
FramesPast#=TimePast#/(1000/60.0)

; mult the frames past by the speed this object is fading
Angle#=FramesPast#*0.5

; Use the angle as to control the brightness of the thing we're
; drawing. In this case, depacking the RLE image from Strings :)
Level#=100+Cosradius(180+Angle#,100)

;Decompress the string of RLE spans that mmake up this 2 colour image
Decompress(Packed$,RgbFade($ffffff,Level#))

; draw the fps()
ink $ffffff
print Fps()

Sync
loop




Function Decompress(R$,ThisColour)

// Build Chr codes$
For lp =asc("a") to asc("x")
ChrCODE$=ChrCODE$+Chr$(lp)
next
ChrCode$=ChrCode$+upper$(ChrCODE$)
ChrCode$=replace$(chrCode$,"RS","",1,false,false)

// Replace the chr codes with the values
For lp=len(ChrCOde$) to 1 step -1
tag$="-"+str$(lp)+":"
R$=replace$(R$,mid$(chrcode$,lp,1),tag$,yes,false,false)
next


// Decode RLE (Run Lenght)
Lockbuffer
For pos=1 to Len(R$)
ThisChr=mid(r$,pos)

; Start of Row
if ThisChr=asc("R")
; reset Pen
Xpos=0
inc Ypos
Continue
endif

; Decode Span
if ThisChr=asc("S")

Pos2=Pos+1
EndPos=INstring(R$,":",POs2,false)
Span$=Mid$(R$,Pos2,Endpos-Pos2)

MidPos=INstring(Span$,"-",1,false)

XPos =Xpos+val(CutRight$(Span$,MidPos))
RunLength=(val(CutLeft$(Span$,MidPos)))

Linec Xpos,Ypos,Xpos+RunLength,Ypos,ThisColour

pos=endPos
Continue
endif

Next
unlockbuffer

EndFunction