Author Topic: 32 byte  (Read 16824 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #20 on: September 25, 2007 »
Cheers, thought about the reflections on water thing: (requires a bit of imagination)

Code: [Select]
org  100h
mov al,13h
int 10h
lds  si,[bx]
draw_loop:
                mov bx,cx     ;copy background pixel address, going to be altered later for foreground pixel address



                mov ax,dx     ;copy background colour value

and ch,80h   ;mask the sign of the address
and al,ch    ;mask background colour with it
mov ch,bh    ;restore original pixel address

;                and al,080h    ;mask background colour value
                mov [bx], al  ;plot background pixel

                add dl,bh     ;alter colour value for next background pixel       add dl,bh =moving  /    add dl,bl =squiggles

                or bl,bh      ;alter pixel address for foreground
                add bl,dh     ;scroll the foreground                    add bx,ax =vertical  /   add bl,dh =horizontal

                mov [bx],bh   ;plot foreground pixel                    mov [bx],dh =multicolour /  mov [bx],bh =chaging colour

        loop draw_loop

        inc dx    ;adjust for background colour cycling and for foreground scrolling

;jmp draw_loop
        in al,60h
        dec al
        jnz draw_loop
ret               

it compiles to 37 bytes but if you take out the ESC test and put in the JMP it's 32
« Last Edit: September 25, 2007 by Stonemonkey »

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: 32 byte
« Reply #21 on: September 25, 2007 »
Cant see anything that can be improved on, thats looking about finish Stonemonkey

Here's a good article on size optimisations written by Adok for Hugi issue 11 (June 1998)
admittedly its old but for tiny DOS code like this it still holds true.

http://www.hugi.scene.org/fate.php?page=hugi11

I'v noticed in this thread that there isnt one sign of an array, variable or any other data item bar the native registers, Yet we still manage to pull off effects. I have seen this spilling over into my basic programming too. I will now happily calculate something on the spot rather than precalculating and trying to manage all the unneccassary extra arrays.

Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #22 on: September 25, 2007 »
I think it's finished now, the foreground thing is a bit more stable. Just a pity I couldn't get it upside down on the bottom half of the screen.

Code: [Select]
org  100h
mov al,13h
int 10h
lds  si,[bx]
draw_loop:
                mov bx,cx     ;copy background pixel address, going to be altered later for foreground pixel address

                mov ax,dx     ;copy background colour value to be masked

                and ch,80h   ;mask to get the sign bit of the address  (bottom half of screen)
                and al,ch    ;mask background colour with it (black if top half)


                mov [bx], al  ;plot background pixel

                add dl,bh     ;alter colour value for next background pixel

                and bl,bh     ;get address for foreground pixel

                add bl,dh     ;scroll the foreground
                mov [bx],bh   ;plot foreground pixel
                mov ch,bh    ;restore original pixel address
        loop draw_loop

        inc dx    ;adjust for background colour cycling and for foreground scrolling

jmp draw_loop
;        in al,60h
;        dec al
;        jnz draw_loop
;ret                     

It just loops so ALT-ENTER or whatever to get out of it or change the end of the code to test for esc.
« Last Edit: September 25, 2007 by Stonemonkey »

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #23 on: September 26, 2007 »
Quote
Just a pity I couldn't get it upside down on the bottom half of the screen.

Done it  ;D     compiles to 32 bytes if it loops forever.

Code: [Select]
org  100h
mov al,13h
int 10h
lds  si,[bx]

draw_loop:
                mov bx,cx     ;copy background pixel address, going to be altered later for foreground pixel address

                test dl,ch    ;if the result of   and dl,ch    leaves the high bit set then
                sets [bx]     ;set pixel bits else clear pixel bits
                sub dl,bh     ;alter colour value for next background pixel

                or bh,bl      ;get address for foreground pixel

                jns nr        ;is the pixel to be a reflection? (uses high bit result of previous OR to decide)
                    shr bh,1    ;half the height (+clear high bit so when it's inverted it's on the bottom half of the screen)
                    neg bh      ;invert height
nr:
                add bl,dh     ;scroll the foreground
                mov [bx],dl   ;plot foreground pixel

        loop draw_loop

        inc dx                ;adjust for background colour cycling and for foreground scrolling

;jmp draw_loop
        in al,60h
        dec al
        jnz draw_loop
ret                      
« Last Edit: September 26, 2007 by Stonemonkey »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #24 on: September 26, 2007 »
thats great! it should be released :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #25 on: September 26, 2007 »
 ;D

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #26 on: September 26, 2007 »
Congratulations on your plaudits :)

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #27 on: September 26, 2007 »
Thanks, i'm thinking about some of the larger categories now but that stuff could be really tricky to work on.

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: 32 byte
« Reply #28 on: October 02, 2007 »
Heres a 16 byte effect (has no escape check)
Code: [Select]
org  100h
les  si,[bx]
mov  al, 13h
int  10h
main:inc  ax
     dec  di
draw:adc  ax,di
     cmc
     stosb
     loop draw
     jmp  main

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #29 on: October 02, 2007 »
Whoa! That's really nice for 16 bytes Rainstorm! :D
It would be worth getting some more 16 byte effects down and releasing them :) You'd get a thumb up from me.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: 32 byte
« Reply #30 on: October 02, 2007 »
I would definately release some over at intro inferno that place is the new 256b.com I dont think I would ever put tiny code on pouet I dont want to feed the animals

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #31 on: October 02, 2007 »
I would definately release some over at intro inferno that place is the new 256b.com I dont think I would ever put tiny code on pouet I dont want to feed the animals

You have a point... .  .   But I feel compelled to release over there sometimes anyway.

A collection of about 4 nice small 16 byte intros would interest a lot of people though.. Definately worth doing!

Shockwave ^ Codigos
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: 32 byte
« Reply #32 on: October 02, 2007 »
Good stuff rain.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: 32 byte
« Reply #33 on: October 03, 2007 »
any chance of a .com file for those of us without the right assembler? I want to see your 16 byter!
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: 32 byte
« Reply #34 on: October 03, 2007 »
Of course how silly of me. Here are a few sub 16 byte intros. The one named waves is the last one I posted and its been tweaked to produce two more similar (but nicer) effects. I also threw in an 11 byte demo just for good measure =D
« Last Edit: October 04, 2007 by rain_storm »

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #35 on: October 03, 2007 »
They are the nicest patterns I have seen in < 16b!

By the way, your 11 byte scroll is fantastic!

I'd be really honoured if you released these at Pouet and Intro-Inferno with a www.dbfinteractive.com tag in the info! I know you don't like Pouet but I have a feeling that these would be popular.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: 32 byte
« Reply #36 on: October 03, 2007 »
Very clever stuff, and welldone.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: 32 byte
« Reply #37 on: October 03, 2007 »
Anyone know of any screen capture software that works in mode 13h (print screen doesnt work here)
Or could someone do a screen capture of these for me?

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #38 on: October 03, 2007 »
Yep. Use dosbox.. I will grab a screen for you give me a few minutes.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 32 byte
« Reply #39 on: October 03, 2007 »
Here's Ripple :)
Shockwave ^ Codigos
Challenge Trophies Won: