Dark Bit Factory & Gravity
PROGRAMMING => Other languages => ASM => Topic started by: Stonemonkey on September 24, 2007
-
Just trying to see if I can do anything with 32 bytes and have this so far:
org 100h
mov al,13h
int 10h
mov ax,0a000h
mov ds,ax
draw_loop:
mov bx,cx
mov [bx],dl
add dl,bh ;version 1
or bl,bh
;add dl,bl ;version 2
mov [bx],dh
loop draw_loop
inc dx
in al,60h
dec al
jnz draw_loop
mov ah,4ch
int 21h
anyone else come up with anything?
-
32 bytes?!
Yeah, easy I think...
*twiddles fasm for about an hour*
;-------------------------------------------------------------------------------------------
; 32 bytes?!
;
; A red screen by Shockwave!! Wow! I am so sad!!!!
;
;-------------------------------------------------------------------------------------------
org 100h
mov ax,13h
int 10h
push 0a000h
pop es
main:
xor di,di
mov cx,64000
loopy:
mov byte [es:di],4
inc di
loop loopy
in al,60h
dec al
jnz main
mov ax, 4c00h
int 21h
Well it assembles to 32 bytes with fasm.... Unfortunately it just draws a red screen :)
I need more practice!
-
*twiddles fasm for about an hour*
I think we share the same technique.
came up with 2 things though and put them together. And you've just saved me a byte!
-
Congratulations on saving the byte! I struggled for ages just trying to get something to fit into 32bytes!
-
how you can save a couple of bytes too:
org 100h
mov al,13h ;load into al (a bit dirty as it assumes ah is clear)
int 10h
push 0a000h ;cheers shockwave, saved me a byte here
pop ds
draw_loop:
mov bx,cx
mov [bx],dl
;add dl,bh ;version 1
or bl,bh
add dl,bl ;version 2
mov [bx],dh
loop draw_loop
inc dx
in al,60h
dec al
jnz draw_loop
mov ah,4ch ;al is clear since it's the exit condition so only need to load into ah
int 21h
-
Hehe, what are you going to do with those 3 bytes?!
-
I was already doing that so still at 31 bytes atm :(
-
Well, this is 23 bytes but you will have to alt+tab out of it.
This is accepted practice in 32 byte intros though :)
org 100h
mov al,13h ;load into al (a bit dirty as it assumes ah is clear)
int 10h
push 0a000h ;cheers shockwave, saved me a byte here
pop ds
draw_loop:
mov bx,cx
mov [bx],dl
add dl,bh ;version 1
or bl,bh
mov [bx],dh
loop draw_loop
inc dx
jmp draw_loop
-
Ah right, thanks. Had thought about that but didn't know it was acceptable.
-
Accepted but you get more respect for including escape checks :D
I got TV static in 20b
org 100h
init:les si,[bx] ; ES = 0A000h [video buffer]
mov al,13h ; 320 x 200 pixels 256 colours
int 10h
main:xchg ax,di ; draw to random pixels in the buffer
xor ax,cx ; play around with the value
xchg al,ah ; randomise buffer access
stosb ; write pixel to buffer
loop main
exit:in ax,60h ; get keyboard state
dec ax ; try to set value to zero
jnz main ; was it esc key?
ret ; if so exit
oh and guys drop this :
mov ah,4ch
int 21h
and use this instead :
ret
-
Nice one rain_storm, I can use LDS si,[bx] too and now down to 26 bytes.
-
Exactly since the contents of [bx] is 0A000h at least with modern versions of DOS I wonder what else can be done to bring down the size
-
Here's a an except from the Hugi size coding competition rules about startup registers. I really respect this competition and they know what they're talking about.
You may assume that
... the registers have these values (all in hex):
(xx - means an unknown value which MUST NOT be assumed)
EAX = xxxx****
AL = 00 if first FCB has valid drive letter, FF if not
AH = 00 if second FCB has valid drive letter, FF if not
EBX = xxxx****
BL = 00 if first FCB has valid drive letter, FF if not
BH = 00 if second FCB has valid drive letter, FF if not
ECX = xxxx00FF
EDX = xxxxxxxx
DX = CS = DS = ES = SS = xxxx, 0080 <= DX <=9000.
ESI = xxxx0100
EDI = xxxxFFFE
EBP = xxxx09xx
ESP = xxxxFFFE
EIP = xxxx0100
EFLAGS (binary) = xxxxxxxx xxxxxxxx xxxxx01x xx0x0x1x
i.e.
DF = 0
IF = 1
other flags = x
WORD [FFFE] = 0000
Layout of PSP: see [Memory Layout]
... that the program is not loaded high.
... that DPMI services are available.
... FCB functions can be used to access files whose name is given in 8.3
format.
You must NOT assume that
... the FPU state is defined; you have to use FINIT to initialize it
before using it.
http://www.hugi.scene.org/compo/ (http://www.hugi.scene.org/compo/)
Not sure about the FCB stuff - I think that means that both AX and BX will == 0.
Jim
-
Cool Jim, thanks.
-
Thats useful information thanks Jim
I dont think I will be putting much faith in unitialised registers anymore
-
Here's a simple xor texture in 30 bytes, it could be smaller I guess :)
;---------------------------------------------------------------
;
; Simple XOR texture - by rbraz 2007
;
;---------------------------------------------------------------
org 0x100
mov al,0x13
int 0x10
push 0xa000
pop es
Main:
mov dx, 199
y:
mov cx, 320
x:
mov ax, dx
xor ax, cx
stosb
loop x
dec dx
jnz y
key:
in ax,0x60
dec ax
jnz key
ret
-
Nice static Rainstorm, and cheers Rbraz for the Xor!
Taking Rain storms tip I had a little bit more space so made this..
It doesn't look like anything though! Just a corrupted moving thing.
;-------------------------------------------------------------------------------------------
; 32 bytes.
;
; Fucked up effect by Shockwave!! Wow! I am so sad!!!!
;
;-------------------------------------------------------------------------------------------
org 100h
mov ax,13h
int 10h
push 0a000h
pop es
main:
xor di,di
mov cx,64000
loopy:
mov byte [es:di],al
inc di
xchg ax,di
inc ah
xchg al,ah
loop loopy
in al,60h
dec al
jnz main
ret
-
Nice one but there is still some more bytes to come off that
mov ax,13h
that requires 2 bytes to hold the value 0013h since its a dword but 13h will fit into 1 byte
assuming AH = 00 this is 1 byte smaller but still does the same job
mov al,13h
Now I managed to get a lot of triangles drawn in just 21 bytes I think I will expand apon this one 11 bytes is plenty of room to dress it up a bit
org 100h
les si,[bx]
mov al,13h
int 10h
main:xchg ax,di
stosb
xor ax,cx
and al,ah
loop main
exit:in al,60h
dec al
jnz main
ret
-
Managed to mask the background colour and have the triangle thing moving (slowly)
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 al,080h ;mask background colour value
mov [bx], al ;plot background pixel
add dl,bh ;alter colour value for next background pixel
or bl,bh ;alter pixel address for foreground
add bl,dh ;scroll the foreground add bx,ax / add bl,dh
mov [bx],bh ;plot foreground pixel
loop draw_loop
inc dx ;adjust for background colour cycling and for foreground scrolling
in al,60h
dec al
jnz draw_loop
ret
-
That looks sweet the lower tris almost look like reflections in water :D good work getting those two effects working side by side
I put in a v-sync and cycle through the colours my last 32b is almost complete but I think Im gonna have to cut out the escape check to fit in some more
Edit :
preaty much done with this its got better colours which scroll instead of cycle but it came ot the cost of the esc check
org 100h
init:les si,[bx] ; ES = 0A000h [video buffer]
mov dx,03DAh ; DX = v-sync port address
mov al,13h
int 10h
main:in al,dx ; wait for vertical
test al,8 ; retrace
jz main
draw:and al,bh ; this piece of code ...
xchg ah,al ; ... scrolls the colour
xor ax,cx ; this piece of code ...
and al,ah ; ......................
xchg ax,di ; ......................
add al,bl ; ... generates the tris
stosb
loop draw
inc bx ; seed the colour value
jmp main
-
Cheers, thought about the reflections on water thing: (requires a bit of imagination)
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
-
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.
-
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.
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.
-
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.
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
-
thats great! it should be released :)
-
;D
-
Congratulations on your plaudits :)
-
Thanks, i'm thinking about some of the larger categories now but that stuff could be really tricky to work on.
-
Heres a 16 byte effect (has no escape check)
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
-
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.
-
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
-
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!
-
Good stuff rain.
-
any chance of a .com file for those of us without the right assembler? I want to see your 16 byter!
-
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
-
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.
-
Very clever stuff, and welldone.
-
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?
-
Yep. Use dosbox.. I will grab a screen for you give me a few minutes.
-
Here's Ripple :)
-
Thanks I will submit these now
Edit:
Added to Intro Inherno
http://www.intro-inferno.com/production.php?id=5820
and pouet
http://www.pouet.net/prod.php?which=32442
now lets see how it fares out
-
Nice 16 byters! I think you will get a rough time on Pouet rain_storm :-(. You've done 3 things Pouet users flame:
1. Used a download location that needs a login
2. Made a duplicate of an earlier product (nearly), see http://www.pouet.net/prod.php?which=4766
3. Had the sheer cheek to do a tiny intro
Good luck though.
Chris
-
I was logged, in it worked for me when I tested it I never realised. Now that comment makes sense
Jesus the only thing different is that mine doesnt scroll.
Well there aint much I can do bout that now
-
I added a fixed link in the prod for you and asked for the link in the topic to be changed.
Give it time and be happy that you are annoying some very arrogant people and pleasing plenty of others :)
Keep the faith mate!
-
Thanks Shocky, and thanks for the kick in the but that made me do it in the first place
-
Once you have experienced the abuse of Pouet v/s one of your own products a few times it gets quite addictive somehow :)
-
Hooah! Kick ass rain_storm, these are awesome 16 byters.
Good luck at the Pouet (the useless fuckers). I'm definately impressed.
-
There are quite a lot of nice people at Pouet too btw :)
-
Don't undermine my gross over generalisation. ;)
But for reference my comment was only in support of rain_storm.
-
:)