Posts: 3,343
Threads: 83
Joined: Mar 2003
What do you mean slow? In my linux partition uncompiled it did 388 FPS :o
I'll review it later. But yes, it does beat whitetiger's quite easily. And it may be a winner currently too.
Posts: 1,166
Threads: 62
Joined: Apr 2003
Quote:And it may be a winner currently too.
Heh, that's easy saying it's the only one other than ick fart... I mean whitefart... I MEAN WHITETIGER
am an asshole. Get used to it.
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:oracle Wrote:And it may be a winner currently too.
Heh, that's easy saying it's the only one other than ick fart... I mean whitefart... I MEAN WHITETIGER hey
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Posts: 1,166
Threads: 62
Joined: Apr 2003
Is ANYONE going to enter this thing, or is it just me and the... half?
am an asshole. Get used to it.
Posts: 3,343
Threads: 83
Joined: Mar 2003
I also have one other entry not displayed currently. It's the fastest by a long way but not very pretty.
Posts: 3,343
Threads: 83
Joined: Mar 2003
I have now reviewed your program, Ninkazu.
http://qbnz.com/pages/challenges/current.html
If you want to improve it, you may, and I'll give you a recount.
Posts: 1,166
Threads: 62
Joined: Apr 2003
Ok, I'll add a bar and maybe fix up the colors
am an asshole. Get used to it.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Excellent. Though it's a little unfair on Neo... he's away on holiday at the mo... but all the same, do yours up and you'll easily win.
Posts: 1,166
Threads: 62
Joined: Apr 2003
Code: DEFINT A-Z
'$STATIC
DECLARE SUB InitLoad ()
DECLARE SUB LoadStuff ()
DECLARE SUB LoadDone ()
DECLARE SUB FlatTri (x1%, y1%, x2%, y2%, x3%, y3%, col%)
DECLARE SUB nPrint (xx%, yy%, Text$, col%)
'$DYNAMIC
DIM SHARED buffer(32001)
'$STATIC
TYPE tritype
x1 AS INTEGER
y1 AS INTEGER
x2 AS INTEGER
y2 AS INTEGER
x3 AS INTEGER
y3 AS INTEGER
END TYPE
DIM SHARED lutsegy(199) AS LONG, tris AS tritype, fps$
DIM SHARED c!(359), s!(359)
DIM SHARED ang(2), xc(2), yc(2), ccc, ccinc, frames&, t#, percent
CONST pi180 = 3.141592654# / 180
CONST PI = 3.14151693#
InitLoad
DO: LOOP UNTIL LEN(INKEY$)
SUB FlatTri (x1%, y1%, x2%, y2%, x3%, y3%, c%)
DIM addr AS LONG
'BLine x1%, y1%, x2%, y2%, C% ' triangle outline
'BLine x2%, y2%, x3%, y3%, C% '
'BLine x3%, y3%, x1%, y1%, C% '
IF y2 > y3 THEN SWAP x2, x3: SWAP y2, y3
IF y1 > y2 THEN SWAP x1, x2: SWAP y1, y2
IF y2 > y3 THEN SWAP x2, x3: SWAP y2, y3
IF y1 <> y3 THEN
IF x2 > x1 AND x2 > x3 THEN
s = 1
ELSEIF x2 < x1 AND x2 < x3 THEN
s = -1
ELSE
s = SGN((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1))
END IF
END IF
IF s < 0 THEN
tl = x2 - x1: tr = x3 - x1
dyl = y2 - y1: dyr = y3 - y1
ELSE
tl = x3 - x1: tr = x2 - x1
dyl = y3 - y1: dyr = y2 - y1
END IF
dxl = ABS(tl): sxl = SGN(tl): el = 0
dxr = ABS(tr): sxr = SGN(tr): er = 0
xx = x1
xxx = x1
FOR scanline = y1 TO y3
IF scanline = y2 THEN
IF s < 0 THEN
dyl = y3 - y2: IF dyl = 0 THEN EXIT SUB
tl = x3 - x2
dxl = ABS(tl): sxl = SGN(tl): xx = x2
ELSE
dyr = y3 - y2: IF dyr = 0 THEN EXIT SUB
tr = x3 - x2
dxr = ABS(tr): sxr = SGN(tr): xxx = x2
END IF
END IF
addr = lutsegy(scanline)
FOR X = xx TO xxx
POKE addr + X, c% + (scanline - y1)
NEXT
WHILE el < 0: el = el + dyl: xx = xx + sxl: WEND
el = el - dxl
WHILE er < 0: er = er + dyr: xxx = xxx + sxr: WEND
er = er - dxr
NEXT scanline
END SUB
SUB InitLoad
FOR n& = 0 TO 199
lutsegy(n&) = n& * 320 + 4
NEXT
FOR I = 0 TO 359
A! = I * PI / 180
c!(I) = COS(A!)
s!(I) = SIN(A!)
NEXT I
ang(0) = 0
ang(1) = 90
ang(2) = 270
xc(0) = 159: yc(0) = 89
xc(1) = 139: yc(1) = 109
xc(2) = 179: yc(2) = 109
tris.x1 = 0: tris.y1 = 0
tris.x2 = -10: tris.y2 = 20
tris.x3 = 10: tris.y3 = 20
ccc = 2
ccinc = 1
SCREEN 13
FOR I = 0 TO 255
OUT &H3C8, I
OUT &H3C9, (I \ 4)
OUT &H3C9, (I \ 4) * .3
OUT &H3C9, (I \ 4) * .1
NEXT I
buffer(0) = 2560: buffer(1) = 200
DEF SEG = VARSEG(buffer(0))
t# = TIMER
WHILE percent < 101
'load all that shi...stuff here and process the percent
'Buuuuut, I'll just fake the percent
REDIM buffer(32001): buffer(0) = 2560: buffer(1) = 200
LoadStuff
IF blorg = 10 THEN percent = percent + 1
blorg = blorg + 1: IF blorg > 10 THEN blorg = 0
WEND
ttmp# = TIMER
fps$ = STR$(INT(frames& / (TIMER - t#)))
LoadDone
DO: LOOP UNTIL LEN(INKEY$)
END SUB
SUB LoadDone
DIM pal(255, 2)
FOR n = 0 TO 63
OUT &H3C7, n
pal(n, 0) = INP(&H3C9)
pal(n, 1) = INP(&H3C9)
pal(n, 2) = INP(&H3C9)
NEXT
DIM addr1 AS LONG, addr2 AS LONG
FOR y = 0 TO 50
FOR yy = 198 TO 0 STEP -1
FOR xx = 0 TO 319
addr1 = lutsegy(RND * 198) + xx
addr2 = addr1 + 320
c = PEEK(addr1)
POKE addr2, c
NEXT
NEXT
PUT (0, 0), buffer, PSET
FOR ll = 0 TO 255
OUT &H3C7, ll
r = INP(&H3C9) - 1: IF r < 0 THEN r = 0
g = INP(&H3C9) - 1: IF g < 0 THEN g = 0
b = INP(&H3C9) - 1: IF b < 0 THEN b = 0
OUT &H3C8, ll
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
NEXT
FOR killpal = 0 TO 255
OUT &H3C8, killpal
OUT &H3C9, 0
OUT &H3C9, 0
OUT &H3C9, 0
pal(killpal, 0) = (killpal \ 4) - 63
pal(killpal, 1) = ((killpal \ 4) * .3) - 63
pal(killpal, 2) = ((killpal \ 4) * .1) - 63
NEXT
REDIM buffer(32001)
buffer(0) = 2560: buffer(1) = 200
FlatTri tris.x1 + 159, tris.y1 + 89, tris.x2 + 159, tris.y2 + 89, tris.x3 + 159, tris.y3 + 89, 40
FlatTri tris.x1 + 149, tris.y1 + 109, tris.x2 + 149, tris.y2 + 109, tris.x3 + 149, tris.y3 + 109, 40
FlatTri tris.x1 + 169, tris.y1 + 109, tris.x2 + 169, tris.y2 + 109, tris.x3 + 169, tris.y3 + 109, 40
nPrint 125, 20, fps$ + " FPS", 40
nPrint 110, 5, "Loading Complete", 40
PUT (0, 0), buffer, PSET
FOR n = 0 TO 63
FOR m = 0 TO 255
pal(m, 0) = pal(m, 0) + 1
pal(m, 1) = pal(m, 1) + 1
pal(m, 2) = pal(m, 2) + 1
r = pal(m, 0): IF r < 0 THEN r = 0
g = pal(m, 1): IF g < 0 THEN g = 0
b = pal(m, 2): IF b < 0 THEN b = 0
OUT &H3C8, m
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
NEXT
WAIT &H3DA, 8
NEXT
END SUB
SUB LoadStuff
STATIC kl
nPrint 125, 5, "Loading...", 120
nPrint 140, 20, STR$(percent) + "%", 120
FOR X = 0 TO 2
tx2 = tris.x2 * c!(ang(X))
ty2 = tris.y2 * s!(ang(X))
tx3 = tris.x3 * c!(ang(X))
ty3 = tris.y3 * s!(ang(X))
FlatTri 159, 99, tx2 + xc(X), ty2 + yc(X), tx3 + xc(X), ty3 + yc(X), ccc
NEXT
FOR okydoky = 40 TO (280 * (percent / 100))
IF okydoky > 160 THEN cbar = 280 - okydoky ELSE cbar = okydoky - 40
POKE okydoky + lutsegy(189), cbar
NEXT
FOR X = 0 TO 2
ang(X) = ang(X) + 1
IF ang(X) > 359 THEN ang(X) = ang(X) - 360
NEXT
PUT (0, 0), buffer, PSET
frames& = frames& + 1
IF kl = 10 THEN ccc = ccc + ccinc
kl = kl + 1: IF kl > 10 THEN kl = 0
IF ccc > 62 OR ccc < 1 THEN ccinc = -ccinc
END SUB
SUB nPrint (xx%, yy%, Text$, col%)
X% = xx%
y% = yy%
FOR I% = 0 TO LEN(Text$) - 1
X% = X% + 8
Offset% = 8 * ASC(MID$(Text$, I% + 1, 1)) + 14
FOR j% = 0 TO 7
DEF SEG = &HFFA6
Bit% = PEEK(Offset% + j%)
DEF SEG = VARSEG(buffer(0))
IF Bit% AND 1 THEN POKE X% + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 2 THEN POKE X% - 1 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 4 THEN POKE X% - 2 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 8 THEN POKE X% - 3 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 16 THEN POKE X% - 4 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 32 THEN POKE X% - 5 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 64 THEN POKE X% - 6 + lutsegy(y% + j%), col% + (j% * 3)
IF Bit% AND 128 THEN POKE X% - 7 + lutsegy(y% + j%), col% + (j% * 3)
NEXT j%
NEXT I%
END SUB
Hmmm, now to decide if I want a gold statue or marble statue created in my honor.....
j/k I suck
am an asshole. Get used to it.
|