News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Alternative way of compressing data: CHALLENGE # 1

Started by frktons, September 01, 2010, 10:31:34 PM

Previous topic - Next topic

mineiro

I think while I'm trying this one to write direct in video memory, so, can be a buffer to, but in XP don't worked fine. I'm reading your code now, and I see a diferent idea of yours and mine.
I know you say it is not optimized; in your "TextToDisplay" I removed the spaces and fill it with code, the rest you know, high bit of strings are zeroed. Nice this challenge Sr, I enjoyed much try do it, but console in win32 to me is a new concept.
regards.

frktons

Quote from: mineiro on September 03, 2010, 10:45:43 AM
I think while I'm trying this one to write direct in video memory, so, can be a buffer to, but in XP don't worked fine. I'm reading your code now, and I see a diferent idea of yours and mine.
I know you say it is not optimized; in your "TextToDisplay" I removed the spaces and fill it with code, the rest you know, high bit of strings are zeroed. Nice this challenge Sr, I enjoyed much try do it, but console in win32 to me is a new concept.
regards.

Take your time mineiro, this challenge is just started, I haven't seen jet any working code that does
what the challenge requires. I suppose it'll take quite a while. I'am going  myself to take quite a while to
accomplish the task. It is just a spare time hobby. During the next weeks we'll see what shows up.  :U

Frank
Mind is like a parachute. You know what to do in order to use it :-)

frktons

The prototype is now complete.  :U

Time to start to clean up the CODE, eliminate the redundant instructions
and translate it into MASM32.

Anyone working on the CHALLENGE?
Let me know.  :P

Mind is like a parachute. You know what to do in order to use it :-)

frktons

#18
A couple of routines are ready, the one that sets the color attribute and
the one that Draws the Boxes inside the buffer.

There is already a lot of optimizing to do for size reduction.
These are the new routines:

; -------------------------------------------------------------------------
; The buffer is filled before displaying it
;--------------------------------------------------------------------------

BuildConsole PROC 

    CALL SetBufferColor

    INVOKE BuildBox, 1, 3
    INVOKE BuildBox, 4, 25

    ret
   
BuildConsole ENDP

; -------------------------------------------------------------------------
; Fill the buffer with a box of 80 characters starting at line requested
; till the number of line passed as II parameter
;--------------------------------------------------------------------------

BuildBox PROC Row1:DWORD, Row2:DWORD


    mov  eax,  Row1
    sub  eax,  1
    imul eax,  320
    mov  edx, eax

    lea  eax, ConsoleScreen
    add  eax, edx


    movzx ebx, byte ptr [TopLeft]
    mov   byte ptr [eax],bl

    add  eax, 4

    mov  ecx, 78

    movzx ebx, byte ptr [HorizLine]

    mov  bl,  HorizLine
   
FillBoxLine1:

    mov  byte ptr [eax], bl
    add  eax,   4
    dec  ecx
    jnz  FillBoxLine1

    movzx ebx, byte ptr [TopRight]

    mov  byte ptr [eax], bl
    add  eax,   4

    mov  ecx, Row2
    sub  ecx, Row1
    dec  ecx
    movzx ebx, byte ptr [VerticLine]

FillBorder:


    mov   byte ptr [eax], bl

    add  eax,   4
    mov  edx,   4
    imul edx,  78

    add  eax, edx
    mov  byte ptr [eax], bl
    add  eax,   4   
    dec  ecx
    jnz  FillBorder

    movzx ebx,byte ptr [BottomLeft]
    mov   byte ptr [eax], bl

    add  eax,   4

    mov  ecx, 78

    movzx ebx, byte ptr [HorizLine]

FillBoxLine2:

    mov  byte ptr [eax], bl
    add  eax,   4
    dec  ecx
    jnz  FillBoxLine2

    movzx ebx, byte ptr [BottomRight]
    mov   byte ptr [eax], bl


    ret


BuildBox ENDP

; -------------------------------------------------------------------------
; The buffer is initialized with main color attribute Bright Yellow on Blue
;--------------------------------------------------------------------------

SetBufferColor PROC 

    push edi

    mov edi, offset ConsoleScreen
    mov eax, 201E2020H
    mov ecx, 2000
    rep stosd
   
    pop edi

    ret
   
SetBufferColor ENDP

; -------------------------------------------------------------------------


and attached the stage 0.1 of the program that displays the two boxes
with the chosen color [Bright Yellow on Dark Blue].

Any suggestion to reduce the size?

At the moment the program takes 3,584 bytes versus the 3,584 bytes of
the original one. Replacing the proc that read the external file with these
has taken 0 bytes of size increment.  :P

Because I don't see many alternative posted by more expert asm programmers
let's use my beginner version in order to optimize it for size reduction.

Frank
Mind is like a parachute. You know what to do in order to use it :-)

frktons

Just a quick update of the 100:1 compression task.

I added the routine to print the Screen Title with enhanced colors.

The EXE is still the same size as the version with the external file.
No trick whatsoever. Just MS ML/LINK version 10 as always.

At the moment there are serious reasons to think I'm going to demonstrate
that Fourieru [If I correctly remember his nick-name] was right at least
for some specific cases.

Attached the slightly updated version, sorry I was away from my pc or any
pc whatsoever.  :P

And moreover, considering nobody dared to show up with an original idea
for compressing data through code, I'm going to win the challenge as well  :dance:

Frank
Mind is like a parachute. You know what to do in order to use it :-)

frktons

And here we are, the complete first draft of the ASCII program, version 0.3,
that has the same size 3.584 bytes than the original one, and displays the
extended ASCII chart without the use of the 8.000 bytes external file.

So apparentely we have reduced the size of the file to zero byte  :P

Of course it is not true, but it is impressive nevertheless.  :U

This is not optimized for reducing the size to the limits, but it gives a first
idea that sometime code can replace data in a very effective way.

Frank
Mind is like a parachute. You know what to do in order to use it :-)

Magnum

Nice work Frank.

I been looking for a popup ASCII chart as well.

Have a great day,
                         Andy

frktons

Quote from: Magnum on September 13, 2010, 02:17:01 PM
Nice work Frank.

I been looking for a popup ASCII chart as well.

You can use the routines that build the buffer and after display it at will
with WriteConsoleOutput.
Just allocate a buffer of 2000 CHAR_INFO, fill it with the routines, and it is
there whenever you need it, ready to pop.

Frank
Mind is like a parachute. You know what to do in order to use it :-)