flat assembler
Message board for the users of flat assembler.
Index
> Main > why is not working this code? |
Author |
|
Miguel 11 Apr 2004, 22:24
;Hello ;This code is working for others FASM´s versions , except 1.52 ;Why not???? ;tube.asm org 100h use16 SCREEN = 160 PIXBUF = 204h mov al,13h int 10h push word 0A000h pop es mov ax,cs add ah,10h mov fs,ax xor cx,cx PAL1: mov dx,3C8h mov ax,cx out dx,al inc dx sar al,1 js PAL2 out dx,al mul al shr ax,6 out dx,al PAL2: mov al,0 out dx,al jns PAL3 sub al,cl shr al,1 out dx,al shr al,1 out dx,al PAL3: mov bx,cx mov [fs:bx],bl loop PAL1 TEX: mov bx,cx add ax,cx rol ax,cl mov dh,al sar dh,5 adc dl,dh adc dl,[fs:bx+255] shr dl,1 mov [fs:bx],dl not bh mov [fs:bx],dl loop TEX fninit fldz MAIN: add bh,8 mov di,PIXBUF fadd dword [ di-PIXBUF+TEXUV-4] push di mov dx,-80 TUBEY: mov bp,-160 TUBEX: mov si,TEXUV fild word [ si-TEXUV+EYE] mov [si],bp fild word [si] mov [si],dx fild word [si] mov cl,2 ROTATE: fld st3 fsincos fld st2 fmul st0,st1 fld st4 fmul st0,st3 fsubp st1,st0 fxch st3 fmulp st2,st0 fmulp st3,st0 faddp st2,st0 fxch st2 loop ROTATE fld st1 fmul st0,st0 fld st1 fmul st0,st0 faddp st1,st0 fsqrt fdivp st3,st0 fpatan fimul word [si-4] fistp word [si] fimul word [si-4] fistp word [si+1] mov si,[si] lea ax,[bx+si] add al,ah and al,64 mov al,-5 jz STORE shl si,2 lea ax,[bx+si] sub al,ah mov al,-16 jns STORE shl si,1 mov al,-48 STORE: add al,[fs:bx+si] add [di],al inc di inc bp cmp bp,160 EYE = $-2 jnz TUBEX inc dx cmp dx, 80 jnz TUBEY pop si mov di,(100-SCREEN/2)*320 mov ch,(SCREEN/2)*320/256 rep movsw mov ch,SCREEN*320/256 BLUR: dec si sar byte [si],2 loop BLUR in al,60h cbw dec ax jnz near MAIN mov al,03h int 10h db 41,0,0C3h,3Ch TEXUV db "by BAZE ,fasm by miguel" ;in the zip files other code that are working
_________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||||||||||
11 Apr 2004, 22:24 |
|
Miguel 11 Apr 2004, 22:27
...others codes that are working..
_________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||||||||||
11 Apr 2004, 22:27 |
|
Miguel 12 Apr 2004, 00:34
no Octavio ! ...the code compile with fasm 151, 149..etc without changes... is the code of Menuet´s file Tube.asm and not compile with fasm 152...yes with the others ....i think ..is a problem of fasm 152.... saludos noi!! _________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||
12 Apr 2004, 00:34 |
|
comrade 12 Apr 2004, 02:08
STORE has become reserved keyword in FASM 1.52, you cannot use it for labels.
This will work (I simply renamed STORE to STOR): Code: ;tube.asm org 100h use16 SCREEN = 160 PIXBUF = 204h mov al,13h int 10h push word 0A000h pop es mov ax,cs add ah,10h mov fs,ax xor cx,cx PAL1: mov dx,3C8h mov ax,cx out dx,al inc dx sar al,1 js PAL2 out dx,al mul al shr ax,6 out dx,al PAL2: mov al,0 out dx,al jns PAL3 sub al,cl shr al,1 out dx,al shr al,1 out dx,al PAL3: mov bx,cx mov [fs:bx],bl loop PAL1 TEX: mov bx,cx add ax,cx rol ax,cl mov dh,al sar dh,5 adc dl,dh adc dl,[fs:bx+255] shr dl,1 mov [fs:bx],dl not bh mov [fs:bx],dl loop TEX fninit fldz MAIN: add bh,8 mov di,PIXBUF fadd dword [ di-PIXBUF+TEXUV-4] push di mov dx,-80 TUBEY: mov bp,-160 TUBEX: mov si,TEXUV fild word [ si-TEXUV+EYE] mov [si],bp fild word [si] mov [si],dx fild word [si] mov cl,2 ROTATE: fld st3 fsincos fld st2 fmul st0,st1 fld st4 fmul st0,st3 fsubp st1,st0 fxch st3 fmulp st2,st0 fmulp st3,st0 faddp st2,st0 fxch st2 loop ROTATE fld st1 fmul st0,st0 fld st1 fmul st0,st0 faddp st1,st0 fsqrt fdivp st3,st0 fpatan fimul word [si-4] fistp word [si] fimul word [si-4] fistp word [si+1] mov si,[si] lea ax,[bx+si] add al,ah and al,64 mov al,-5 jz STOR shl si,2 lea ax,[bx+si] sub al,ah mov al,-16 jns STOR shl si,1 mov al,-48 STOR: add al,[fs:bx+si] add [di],al inc di inc bp cmp bp,160 EYE = $-2 jnz TUBEX inc dx cmp dx, 80 jnz TUBEY pop si mov di,(100-SCREEN/2)*320 mov ch,(SCREEN/2)*320/256 rep movsw mov ch,SCREEN*320/256 BLUR: dec si sar byte [si],2 loop BLUR in al,60h cbw dec ax jnz near MAIN mov al,03h int 10h db 41,0,0C3h,3Ch TEXUV db "by BAZE ,fasm by miguel" |
|||
12 Apr 2004, 02:08 |
|
Miguel 12 Apr 2004, 23:15
ohhh!!
yes,yes!! thank you! _________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||
12 Apr 2004, 23:15 |
|
Madis731 13 Apr 2004, 19:55
I you programmed all of these then...RE$P€CT
anyone else doing 3D-cubes in stunning 256Bytes??? Sad that D3D and OGL take about 2k on initing the screen:P |
|||
13 Apr 2004, 19:55 |
|
Intrinsic 14 Apr 2004, 20:05
No he didn't do this ;p Baze/3SC did.
The 3Ch at the end controls the speed of the camera movement, it is VERY sensitive and setting it too high will result in garbage 1k OGL and DX is possible: http://members.lycos.co.uk/intrinsic27/1k-DirectX-LightStorm.rar http://members.lycos.co.uk/intrinsic27/1k-OpenGL-Boulder.rar 4K DX http://members.lycos.co.uk/intrinsic27/mandal-ts4k0a04.zip |
|||
14 Apr 2004, 20:05 |
|
Madis731 14 Apr 2004, 22:43
OK
I see that you are very clever: can't call DX from a com application so you build yourself an exe which you can execute from your com:D I wouldn't have ever thought of that... |
|||
14 Apr 2004, 22:43 |
|
Miguel 15 Apr 2004, 23:09
; Hello people! ; Madis731 many thanks by to believe during one moments that i´m a big programmer...but not ; ... I´m a newbie , i´m know nothing of programming, I´m learning programming asm in my little ; free time( in the night, when all is sleeping) for fun ....because i like it ........ ;.....and for that,i get all the source code that see and ... ;I study it....modify...mix...test..cut...paste ...convert to fasm... and others ocurrences.. ; I always learn something..... ; Shaded donut in 256 bytes F_65536 = 4f800000h F_256 = 48800000h F_1 = 3f800000h F_OO256 = 37800000h F_OO65536 = 2f800000h F_PI = 40490fdbh F_TWOPI = 40c90fdbh F_EXPFACTOR = 00800000h DONUTRESA = 6 ; log2 of "number of vertices per ring" DONUTRESB = 8 ; log2 of "number of rings" DONUTSTEPSA = (1 SHL DONUTRESA) DONUTSTEPSB = (1 SHL DONUTRESB) use16 ORG 100h start: mov al,13h ; Set graphics mode (320x200x256) int 10h ; Set palette (greyscale, 64 entries) xchg ax,bx mov dx,3c8h out dx,al inc dx @@col: out dx,al out dx,al out dx,al inc al jnz @@col @@main: mov dx,cs ; Setup extrasegs add dh,10h mov es,dx ; 1) Screenbuffer add dh,10h mov fs,dx ; 2) Zbuffer mov bx, bss ; ax ? , bx bss ,cx 0 ,dx ?,si ? ,di ?,bp 0 ; Update rotation fld dword [bx+rot-bss] ; oldrot fadd dword [bx+rot+4-bss] ; rot fst dword [bx+rot-bss] ; rot fsincos ; rotcos rotsin fstp dword [bx+rotcos-bss] ; rotsin fst dword [bx+rotsin-bss] ; rotsin ; Draw Donut ; rotsin is used as initial value for b, as b's starting value ; doesn't matter as long as it goes from x to x+2*PI ; b mov dx,DONUTSTEPSB @@b: fld st0 ; b b fsincos ; cosb sinb b fstp dword [bx+cosb-bss] ; sinb b fst dword [bx+sinb-bss] ; sinb b ; sinb is used as initial value for a, as a's starting value ; doesn't matter as long as it goes from x to x+2*PI ; a b mov cl,DONUTSTEPSA @@a: call calcpoint ; Calculate one vertex/normal pair lodsw ; Fetch y xchg di,ax imul di,320 lodsw ; Fetch x add di,ax add di,100*320+160 ; Center of screen dec si lodsw ; Fetch z * 256 + junk mov al,byte [donutnormal+5] ; Fetch colour add ax,0800ah ; Apply bias to z & colour call dot2x2 ; Buffer/draw 2x2 pixel block fadd dword [bx+donutinca-bss] ; a b loop @@a fstp st0 ; b fadd dword [bx+donutincb-bss] ; b dec dx jnz @@b fstp st0 ; Copy screenbuffer to gfxmem, and clear screenbuffer & zbuffer push ds push es pop ds push 0a000h pop es mov di,si ; Go through whole segment, no @@copyclr: ; matter where we begin movsb mov [si-1],dl mov [fs:si],dl loop @@copyclr pop ds mov ah,1 ; Check for keypress int 16h jz @@main mov ax,3 ; Restore textmode int 10h ret ; Exit program ; Draw 2x2 zbuffered pixels in al colour , ah zbuffer value , es:di pixel dot2x2: call @@y ; Two lines add di,319 @@y: call @@x ; Two pixels per line inc di @@x: cmp ah,[fs:di] ; Zcompare jb @@npixel1 ; Hidden? if not, draw to buffers mov [fs:di],ah stosb dec di @@npixel1: ret ; Calculate one vertex + corresponding normal ; in bx bss ; out si donutvertex calcpoint: mov si, donutscalevertex call @@calcvtx ; First gen vertex, then gen normal @@calcvtx: fld st0 ; a a b fsincos ; cosa sina a b fmul dword [si] ; x0 sina a b fadd dword [si+4] ; x1 sina a b fld st0 ; x1 x1 sina a b fmul dword [bx+sinb-bss] ; z2 x1 sina a b fxch st1 ; x1 z2 sina a b fmul dword [bx+cosb-bss] ; x2 z2 sina a b fxch st2 ; sina z2 x2 a b fmul dword [si] ; y0 z2 x2 a b call rot2d ; z3 y3 x2 a b fxch st2 ; x2 y3 z3 a b call rot2d ; y4 x4 z3 a b fistp word [si+16+2] ; x4 z3 a b fistp word [si+16] ; z3 a b fistp word [si+16+4] ; a b add si,8 ret ; Standard 2d rotation ; in bx bss ; st0 x0 ; st1 y0 ; out st0 y ; st1 x rot2d: ; x0 y0 fld st1 ; y0 x0 y0 fmul dword [bx+rotcos-bss] ; cos*y0 x0 y0 fld st1 ; x0 cos*y0 x0 y0 fmul dword [bx+rotcos-bss] ; cos*x0 cos*y0 x0 y0 fld dword [bx+rotsin-bss] ; sin cos*x0 cos*y0 x0 y0 fmul st3,st0 ; sin cos*x0 cos*y0 sin*x0 y0 fmulp st4,st0 ; cos*x0 cos*y0 sin*x0 sin*y0 fsubrp st3,st0 ; cos*y0 sin*x0 cos*x0-sin*y0 faddp st1,st0 ; sin*x0+cos*y0 cos*x0-sin*y0 ret donutinca dd F_TWOPI - (F_EXPFACTOR * DONUTRESA) rot dd 0 ; Rotation angle rotinc dd F_TWOPI - (F_EXPFACTOR * 6) ; Rotation speed donutscalevertex dd F_1 + (F_EXPFACTOR * 4) ; Donut ring radius dd F_1 + (F_EXPFACTOR * 5) ; Donut radius donutscalenormal dd F_1 + F_EXPFACTOR * 14 - 300000h ; Normal-length donutincb dd F_TWOPI - (F_EXPFACTOR * DONUTRESB) ; Almost 0.0 donutvertex dw ?,?,?,? ; Vertex/normal pair generated donutnormal dw ?,?,?,? ; by calcpoint bss: rotcos dd ? ; Temporaries used in rotsin dd ? ; donut generation cosb dd ? sinb dd ? ;Hey! Intrinsic ,where is the source of thah 1K DX prog....will be very interesting for us, ;will learning much things... ;The Dx.com start in this way: ;============================================================================ ; start: ; mov cx,400h ;bytes to copy ,1024 ; mov si,500h ; mov di,0F99h ; mov bx,8000h ; ; std ;direction flag to 1,dec di and si ; rep movsd ;dd´s from ss:si to es:di? ; ; cld ;??I´m confuse,direction flag to 0, inc di si ; xchg si,di ; sub si,0FFE7h ; push di ; jmp 0F19h ; 0F19------------- add bx,bx xchg ax,bx movsb ; jnz 0F58 ret jmp 0F19H ; lodsw jb sigue ........... ; adc ax,ax sigue: .......... ; ============================================================================= ; What´s doing that......???.....After the .com file turn on a Portable Executable ; =============================>>>>>>> ..it´s in the attachment ;Questions: ;how decompress in memory? ;What functions from msdos .com allow to run the hidden PE? exec? ;will to be able to run others ..( ring 0 code,..kernel mode drivers...etc) ? ;I´m going to think in thats questions.............. ;greetings all forum..!!
_________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||||||||||
15 Apr 2004, 23:09 |
|
aaro 16 Apr 2004, 01:35
Miguel please put code tags([code][/code]) around your code, it'll be much more readable.
|
|||
16 Apr 2004, 01:35 |
|
madmatt 17 Apr 2004, 00:23
Hello, Who wrote these examples? Are there any more? These are very nice and have to be the tiniest graphics demos I've ever seen! And very well done demos as well. By the way you can also get demos (mostly DirextX, if not all) at scene.org and of course they are quite a bit larger.
|
|||
17 Apr 2004, 00:23 |
|
Miguel 18 Apr 2004, 23:38
Hello
; I don´t know who wrotes these examples.They are in olds cd´s, from PC spain´s magazines, ; www.256b.com is a good place... ; from the net and cd´s from friends collectors of software ;anothers two examples: ; a galaxia use16 ORG 100h max = 4096 maxZ = 5000 Start: mov di,vars mov ch,60 rep stosw mov al,13h int 10h pal: mov al,cl mov dx,3c8h out dx,al inc dx cmp al,64 jb b64_1 mov al,63 b64_1: out dx,al mov al,cl shr al,1 out dx,al out dx,al loop pal main: push 8000h pop ES mov si,max migu: mov ax,[Z+si] cmp ax,maxZ-(maxZ/4) jg NewStar cmp ax,2 jg Zok NewStar: mov ax,bp mov [X+si],ax imul ax,8405h inc ax mov bp,ax shr ax,6 sub ax,400 mov [Y+si],ax mov [Z+si],maxZ-(maxZ/2) Zok: mov ax,[X+si] movsx dx,ah shl ax,8 mov cx,[Z+si] idiv cx add ax,320/2 cmp ax,320-1 jge NewStar cmp ax,1 jle NewStar mov di,ax mov ax,[Y+si] movsx dx,ah shl ax,8 idiv cx add ax,200/2 imul ax,320 add di,ax mov al,127 stosb mov ax,[X+si] cmp ax,00 jge .add neg ax shr ax,6 add [Y+si],ax jmp .notadd .add: shr ax,6 sub [Y+si],ax .notadd: add [Z+si],ax mov ax,[Y+si] sar ax,3 add [X+si],ax .NextStar: dec si dec si jnz migu push DS push ES pop DS xor di,di xor cx,cx .blur: movzx ax,[DS:di] movzx dx,[DS:di+1] add ax,dx mov dl,[DS:di-320] add ax,dx mov dl,[DS:di+321] add ax,dx shr ax,2 cmp al,0 je .skip dec ax .skip: stosb loop .blur push 0a000h pop ES mov si,di mov ch,81h rep movsw pop DS mov dx,3dah .vrt: in al,dx test al,8 jz .vrt in al,60h dec ax jnz main endprog: mov al,3 int 10h ret LABEL vars X rw max Y rw max Z rw max ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;a 256 tunnel use16 org 100h ; sinetable used for the twirling sinetab equ 64010 tt1 = 64570 tt2 = 64575 ; misc tunnel position values aa1 = 64590 aa2 = 64591 aa3 = 64592 aa4 = 64593 mov ah,080h mov ds,ax mov ah,0a0h mov es,ax ; setting mode13 mov ax,13h int 10h ; clear the copro before creating sinetable and setting the palette finit mov cx,256 mov di,sinetab fldz mov dx,3c8h xor ax,ax out dx,al inc dx sinpal_loop: fld st0 fsin fimul word [cs:fme] fiadd word [cs:fme] fistp dword [di] fadd dword [cs:fadda] mov al,ah shr al,2 out dx,al out dx,al xor al,al out dx,al inc ah inc di loop sinpal_loop ; create the LUT for the tunnel ; lut setup: ; 320x100 with ; 2 bytes.. first = angle(0>_x>_255), second = Z of tunnel ; this tunnel uses polar cords.. ; so the precalc is simply ; beware of pseudo code..! ; angle=atan(x/y) ; distZ=3000/sqrt(x^2 + y^2) ; you might be wondering how the Z stuff works.. ; if you remember the old projection formula ; u=x/z where u is screen X and x and z is the 3D coords ; if we rewrite this we get that ; z=x/u ; so 3000 is the radius of our tunnel, u is in our case the distance from the ; center of the screen and then Z is resolved mov cx,32000 mov bx,320 xor di,di tunnel_precalc: mov ax,cx add ax,319 xor dx,dx div bx sub dx,160 sub ax,50 mov [tt1],ax mov [tt2],dx fild word [tt1] fild word [tt2] fpatan fmul dword [cs:fma] fistp word [di] inc di fild word [tt1] fimul word [tt1] fild word [tt2] fimul word [tt2] faddp st1,st0 fsqrt fidivr word [cs:fp] fistp word [di] inc di loop tunnel_precalc main: add byte[aa4],2 dec byte[aa3] inc byte[aa1] inc byte[aa2] mov di,0 call dotun call dotun ; check the last pressed key in al,60h dec al ; scancode for ESC = 1.. 1-1 = 0 .. if this is true then exit jnz main ; set mode 3(text) mov ax,3 int 10h ; and exit ret ; painting code.. ; distorts the angle depending on the sinetable and the distance.. dotun: mov cx,32000 mov si,0 inner: xor bh,bh mov bl,[si+1] add bl,[aa3] mov al,[bx+sinetab] mov bl,[si+1] add bl,[aa4] add al,[bx+sinetab] mov bl,[si] add bl,al add bl,[aa2] and bl,0f0h mov al,bl inc si mov bl,[si] add bl,[aa1] inc si and bl,0f0h xor al,bl stosb loop inner ret fp dw 3000 fme dw 30 fadda dd 0.024543692 fma dd 40.74366543 _________________ Hola,Hello...my english is not good..but.. we understand us..... |
|||
18 Apr 2004, 23:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.