Qbasicnews.com
December 08, 2019, 05:30:39 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Who's up for a real challenge?  (Read 17594 times)
Blitz
I hold this place together
*****
Posts: 853



WWW
« on: April 13, 2003, 09:50:01 AM »

Code the fastest transparent blitter you can for a 486. You're not restricted to any rules or languages. Do it as you please. It will run on a 486 DX4 100 mhz with 33 mhz bus. The video chip is an old cirrius logic on a 16 bit, 8 mhz (?) ISA bus.

The following tests will be performed.
Sprite to vram, aligned
Sprite to sram, aligned
Sprite to vram, unaligned
Sprite to sram, unaligned

The code has to be in by 18-04-2003 (friday). My mail is blitz_dotnet@hotmail.com
Logged

oship me and i will give you lots of guurrls and beeea
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #1 on: April 13, 2003, 09:54:38 AM »

Oh yeah, the arguments are passed basic style.

Blit ( seg dst as any, byval x as integer, y as integer, seg src as any )
Blit ( byval dst as long, byval x as integer, y as integer, seg src as any )

Where dst is pointer to 64000 bytes, either vram or a backbuffer. And src is qb style sprite where first byte 0-1 is width*8 and byte 2-3 is height.

The transparent color is 0.
Logged

oship me and i will give you lots of guurrls and beeea
Kackurot
Member
*
Posts: 68



WWW
« Reply #2 on: April 13, 2003, 04:37:53 PM »

Can RLE be used? compiled?
Logged

he Legend Continues..........
Pick up DBZ budaki today!!! ;-)
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #3 on: April 13, 2003, 05:58:50 PM »

no
Logged

oship me and i will give you lots of guurrls and beeea
toonski84
__/--\__
*****
Posts: 2567



« Reply #4 on: April 14, 2003, 03:26:52 AM »

this isnt just a made-up contest so you can enter ugl and win, is it blitzachinchilla? Wink
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #5 on: April 14, 2003, 06:36:56 AM »

heh, no. I don't have to cheat to win. Not that i'm saying that i'm going to win. But i trust my skills.
Logged

oship me and i will give you lots of guurrls and beeea
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #6 on: April 16, 2003, 02:17:45 AM »

Does it have clipping?
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #7 on: April 16, 2003, 06:17:14 AM »

Yes, but if you don't want to. It doesn't matter, clipping doesn't affect speed at all.
Logged

oship me and i will give you lots of guurrls and beeea
Fling-master
I hold this place together
*****
Posts: 866



WWW
« Reply #8 on: April 17, 2003, 11:13:58 PM »

Depends how you implement it... if done correctly, then no. But if done the "lazy" way (which IMO is the hard way) then it does affect speed.

... hrm... yet again I'm posting useless garbage... meh.
Logged
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #9 on: April 17, 2003, 11:45:37 PM »

It's pretty obvious to me that clipping is done at object level. If you're not doing it at object level then you still have allot to learn and challenges isn't really what they should be doing now is it?
Logged

oship me and i will give you lots of guurrls and beeea
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #10 on: April 18, 2003, 06:42:28 PM »

The contest is over, noone enterd. You guys suck. Tongue
Logged

oship me and i will give you lots of guurrls and beeea
Ninkazu
Been there, done that
*****
Posts: 1169



WWW
« Reply #11 on: April 18, 2003, 06:45:53 PM »

Quote from: "Blitz"
The contest is over, noone enterd. You guys suck. Tongue


BAHAHA! :lol:
Logged

am an asshole. Get used to it.
Fling-master
I hold this place together
*****
Posts: 866



WWW
« Reply #12 on: April 19, 2003, 11:25:05 AM »

:rotfl:
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #13 on: April 21, 2003, 01:49:15 AM »

Cya tomorrow. I'll post something...  Just that I was on vacation for a little R&R. :*)
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #14 on: April 22, 2003, 02:47:28 AM »

Here:

Notes. Your BX indexing technique is slow. ;*) as compared to a di/si inc.

PutF uses your BX indexing technique and PutF2 uses the standard Inc Si/Di.

Code:

MODEL MEDIUM,BASIC
.STACK 30H
.386
.CODE

;SUB RelPutF(BYVAL DESTSEG%,BYVAL X%,BYVAL Y%,BYVAL SPRITESEGMENT%,BYVAL SPRITEOFFSET%)
;STACK
;DEST SEG       =14
;X              =12  
;Y              =10
;SPRITESEGMENT  =8
;SPRITOFFSET    =6
;RET SEG        =4
;RET OFF        =2
;BP             =0
;ds             =-2     ;REAL WIDTH
;320-WIDTH      =-4     ;FOR SPEEDIER LOOP NO SUB

;DS:SI                  =SPRITE SEG:SPRITE OFF
;ES:DI                  =DEST SEG:DEST OFF

align 2

PUBLIC RelPutF
RelPutF PROC

PUSH BP
mov bp,sp
sub sp,4

mov [bp-2],ds                   ;save ds

mov es,[bp+14]                  ;layer

mov ds,[bp+8]                   ;spr seg
mov si,[bp+6]                   ;spr off

mov dx,[si]                     ;wid
mov ax,[si+2]                   ;height

add si,4

shr dx,3                        ;wid\8

                                ;calc offset

mov cx,[bp+10]                  ;y
xchg ch,cl                      ;Y*256
mov di,cx                       ;save
shr di,2                        ;Y*64
add di,cx                       ;Y*64+Y*256=320
add di,[bp+12]                  ;Offset=Y*320+X

;notes:
;Al = Hieght
;dx = Wid
;bx = free
;cx = free

mov cx,320
sub cx,dx
mov [bp-4],cx                   ;save to stack

Yloop:
    xor bx,bx
    mov cx,dx                   ;save wid

Xloop:

    mov ah,[si+bx]
    or ah,ah

    jz skip
        mov es:[di+bx],ah
    skip:

    inc bx
    dec cx

jnz Xloop

    add si,bx
    add bx,[bp-4]
    add di,bx
    dec al
jnz Yloop

mov ds,[bp-2]
ADD SP,4
POP BP                          ;RESTORE BP

RET 10

RelPutF ENDP

END    





Here's the one which is faster:

Code:


MODEL MEDIUM,BASIC
.STACK 30H
.386
.CODE

;SUB RelPutF2(BYVAL DESTSEG%,BYVAL X%,BYVAL Y%,BYVAL SPRITESEGMENT%,BYVAL SPRITEOFFSET%)
;STACK
;DEST SEG       =14
;X              =12  
;Y              =10
;SPRITESEGMENT  =8
;SPRITOFFSET    =6
;RET SEG        =4
;RET OFF        =2
;BP             =0
;ds             =-2     ;REAL WIDTH
;320-WIDTH      =-4     ;FOR SPEEDIER LOOP NO SUB

;DS:SI                  =SPRITE SEG:SPRITE OFF
;ES:DI                  =DEST SEG:DEST OFF

align 2

PUBLIC RelPutF2
RelPutF2 PROC

PUSH BP
mov bp,sp
sub sp,4

mov [bp-2],ds                   ;save ds

mov es,[bp+14]                  ;layer

mov ds,[bp+8]                   ;spr seg
mov si,[bp+6]                   ;spr off

mov dx,[si]                     ;wid
mov bx,[si+2]                   ;height

add si,4

shr dx,3                        ;wid\8

                                ;calc offset

mov cx,[bp+10]                  ;y
xchg ch,cl                      ;Y*256
mov di,cx                       ;save
shr di,2                        ;Y*64
add di,cx                       ;Y*64+Y*256=320
add di,[bp+12]                  ;Offset=Y*320+X

;notes:
;Ax = free
;dx = Wid
;bx = Height
;cx = free

mov cx,320
sub cx,dx
mov [bp-4],cx                   ;save to stack

Yloop:
    mov cx,dx                   ;save wid

Xloop:

    mov al,[si]
    inc si

    or al,al
    jz skip
        mov es:[di],al
    skip:

    inc di
    dec cx

jnz Xloop
    add di,[bp-4]
    dec bx
jnz Yloop

mov ds,[bp-2]
ADD SP,4
POP BP                          ;RESTORE BP

RET 10

RelPutF2 ENDP

END




To test:

Code:


DECLARE SUB RelPutF (BYVAL DESTSEG%, BYVAL X%, BYVAL Y%, BYVAL SPRITESEGMENT%, BYVAL SPRITEOFFSET%)
DECLARE SUB RelPutF2 (BYVAL DESTSEG%, BYVAL X%, BYVAL Y%, BYVAL SPRITESEGMENT%, BYVAL SPRITEOFFSET%)

DEFINT A-Z

DIM Vpage(31999) AS INTEGER

'Test Vars
DIM PutTestMem  AS SINGLE
DIM PutTestMem2 AS SINGLE
DIM PutTestVid  AS SINGLE
DIM PutTestVid2 AS SINGLE


CLS
SCREEN 13
W = 15
H = 15



Layer = VARSEG(Vpage(0))
Size = ((W + 1) * (H + 1) + 4) \ 2
DIM Array(Size) AS INTEGER
FOR I = 0 TO H
  FOR J = 0 TO W
        PSET (J, I), (I OR J) + 150
  NEXT
NEXT

GET (0, 0)-(W, H), Array

SprSeg = VARSEG(Array(0))
SprOff = VARPTR(Array(0))
TIMER ON
    T# = TIMER
    FOR n& = 1 TO 500000
      RelPutF Layer, 100, 100, SprSeg, SprOff
    NEXT
    PutTestMem = n& / (TIMER - T#)

    T# = TIMER
    FOR n& = 1 TO 500000
      RelPutF2 Layer, 100, 100, SprSeg, SprOff
    NEXT
    PutTestMem2 = n& / (TIMER - T#)

    'VIDEO
    T# = TIMER
    FOR n& = 1 TO 500000
      RelPutF &HA000, 100, 100, SprSeg, SprOff
    NEXT
    PutTestVid = n& / (TIMER - T#)

    T# = TIMER
    FOR n& = 1 TO 500000
      RelPutF2 &HA000, 100, 100, SprSeg, SprOff
    NEXT
    PutTestVid2 = n& / (TIMER - T#)


    CLS
    SCREEN 0
    WIDTH 80

    PRINT STR$(PutTestMem) + " For PutF aka [Si/di+bx] trick (Base mem)"
    PRINT STR$(PutTestMem2) + " For PutF2 aka inc si/di (Base mem)"
    PRINT STR$(PutTestVid) + " For PutF aka [Si/di+bx] trick  (Video mem)"
    PRINT STR$(PutTestVid2) + " For PutF2 aka inc si/di (Video mem)"

    C$ = INPUT$(1)

CLS
SCREEN 0
END

Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!