News:

11 March 2016 - Forum Rules

Main Menu

Stupid issues with VB.NET

Started by InfamousKnight, November 29, 2012, 05:23:26 PM

Previous topic - Next topic

Garoth Moulinoski

Quote from: BRPXQZME on December 04, 2012, 06:36:08 AM
Nah, I found it readable enough as long as you're up to speed on some fairly well known DOS conventions and understand the algorithms involved. Could maybe be more consistent with indentation or whatever.

Ah, I'm not. Going through it once more (to demonstrate some more consistent indentation), I noticed a few instructions I remember from my ASM class (Whoa, you get to use sub! I used to have to make the number I wanted to negate by a negative number and then use add; i.e. I wanted to do 2 - 1, I'd have to two's complement 1 and then do 2 + -1. That was for the LC3). I don't do any ASM as you could probably have noticed.

Quote from: BRPXQZME on December 04, 2012, 06:36:08 AM
Readability is mostly a concern for maintainability. The constraints of the problem don't have much to do with that!

Spoiler

;**********************************************************
;
; FlOWER256(Updated with displacement and a nice palette)
; Morphing tunnel of the overused XOR texture. :*)
; Another 256 Byte demo by
; Relsoft (Richard Eric M. Lope BSN RN)
; http://rel.betterwebber.com
; Assemble with FASM (FlatAssembler.net)
;
;**********************************************************

diameter = 32
diamxscale = (64 * diameter)
scx = 160
scy = 100


org 100h

;*****************************************************************
;*****************************************************************
;*****************************************************************

push word 0a000h ;word
pop es ;byte

mov   al, 13h ; mode 13h
int   10h ; we are now in 320x200x256
mov dx, 03c8h ;palette write register
xor ax, ax
mov word[fold_off],ax
out dx, al
mov cx, 20
inc dx

genpal:
out dx, al
xchg al, ah
out dx, al
xor ax, cx
xchg al, ah
out dx, al
inc al
jnz genpal
main_loop:
inc word [si] ;si = frame counter
;flower
;fold_off += 0.2
fld [c_fold_off]
fadd dword[fold_off]
fstp dword[fold_off]
;fold_scale = 0.5 * sin(frame / 40)
fild word [si] ;st0 = frame; st1 = 0.3
mov ax, 90
mov bx, bp
mov word [bx], ax
fidiv word [bx]

fstp dword [bx]
fld dword [bx]
fsincos
fmul [c_fold_scale]
fstp dword[fold_scale]

;displacement
mov word[bx], ax
fimul word[bx]
fistp word[cenx]
add word[cenx], scx
fld dword[fold_scale]
fimul word[bx]
fistp word[ceny]
add word[ceny], scy

;===========tunnel
mov dx,200
xor di, di
tunnel_yloop:
mov cx,320
tunnel_xloop:
;bx = word pointer
;bp = dword ptr
;atan2
fninit ;call this to ditch the st pops
mov bx, bp
mov ax, [ceny]
mov word [bx], ax
sub [bx], dx
fild word [bx] ;st0 = dy
mov ax, [cenx]
mov word [bx], ax
sub [bx], cx
fild word [bx] ;st0 = dx, st1 = dy

fpatan ;st0 = atan(dy/dx) = atan(st1/st0)
;flower
;xdist = xdist * ((sin(fold_off + fold_num * angle) * fold_scale)+1)
fstp dword [bx]
fld dword [bx] ;restore
fld dword [bx]
fimul [fold_num]
fadd dword[fold_off]
fsin
fmul dword[fold_scale]
mov word [bx], 1
fiadd word [bx]
fstp dword [bp] ;real_var =((sin(fold_off + fold_num * angle) * fold_scale)+1)

fmul [c_scale] ;atan(st0))*256/pi
fistp word [bx] ;short_var = scaledpi
mov gs,[bx]
mov ax, [cenx]
sub ax, cx ;cmx
mov [bx], ax
fild word [bx] ;st0 = cmx
fmul st0, st0 ;cmx * cmx
mov ax, [ceny]
sub ax, dx
mov [bx], ax
fild word [bx] ;st0 = cmy st1 = cmx*cmx
fmul st0, st0 ;cmy * cmy
fadd st0, st1 ;st0 cmx^2 + cmy^2
fsqrt ;sqrt st0
fmul dword [bp]
mov word [bx], diamxscale ;st0 = diamxscale st1 = sqrt(dist)
fidivr word [bx] ;st0 = diamxscale / dist
fistp word [bx]
mov ax, word [bx]
add ax, word [si]
mov bx, gs
add bx, word [si]
xor ax, bx
stosb
dec cx
jnz tunnel_xloop
dec dx
jnz tunnel_yloop
mov dx,3dah
vsync:
in al,dx
and al,8
jz vsync

in al,60h
dec al
jnz main_loop

ret

fold_num dw  5
c_fold_off dd  0.2
c_fold_scale dd  0.35
c_scale dd  40.74
fold_scale dd  ?
fold_off dd  ?
cenx dw  ?
ceny dw  ?
[close]

I feel a bit nasty over lines
mov word [bx], diamxscale ;st0 = diamxscale st1 = sqrt(dist)
fidivr word [bx] ;st0 = diamxscale / dist


Their comments don't align to the others. I could have added an extra tab space to the previous comments though. I started off putting four spaces instead of tabs, but then I realized each one of those spaces is information. So I figured tab spaces, although a little more dangerous/annoying to use in certain situations, was a harmless thing here.

I don't claim that it's that much better though, but at least indentations are more consistent. I would have added carriage returns before every label, but *shrug* I'd also have been a carriage return before(/after) those "comment only lines", but again *shrug*
Who will quote me next?
Disclaimer: If it sounds wrong, I may have been posting while asleep.