Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Shockwave on September 04, 2008

Title: Reduced Res - Not entered.
Post by: Shockwave on September 04, 2008
Please do use this for reference only, I am not really proud of it which is why I put it in the bin :D

It was my first attempt for the reduced res comp.

Code: [Select]
'
' Reduced Resolution Competition!
' By Shockwave
'-------------------------------------------------------------------------------

'   INCLUDES;

    #INCLUDE "TINYPTC_EXT.BI"
    #INCLUDE "WINDOWS.BI"
   
    OPTION STATIC
    OPTION EXPLICIT

'   RESOLUTION VARIABLES;

    DIM SHARED AS UINTEGER BXRES,BYRES,PIXSIZE,XRES,YRES,PIXSIZY,MDS,MDF
   
'   COLOUR PALETTE HERE;

    DIM SHARED C_PALETTE(3) AS UINTEGER=> {&H000000,&H335577,&H77AACC,&HDDFFFF}

'   RESOLUTION SETTINGS;
    MDS=0
    XRES=640
    YRES=480

    BXRES=160
    BYRES=120
   
    PIXSIZE=4
    PIXSIZY=4

'   SUBROUTINES;
   
    DECLARE SUB UPDATE_SCREEN()
    DECLARE SUB VERTICAL_BARS()
    DECLARE SUB DRAW_VBAR(BYVAL XP AS INTEGER , BYVAL YP AS INTEGER)
    DECLARE SUB PLASMA()
   
    DIM SHARED AS UINTEGER FRBUFFER ( BXRES * BYRES )
    DIM SHARED AS UINTEGER BUFFER      ( XRES  * YRES  )
   
    PTC_ALLOWCLOSE(0)
    PTC_SETDIALOG(1,"Reduced Resolution"+CHR$(13)+"FULL SCREEN?",0,0)               
    IF (PTC_OPEN("Reduced Res",XRES,YRES)=0) THEN
    END-1
    END IF
   
'-------------------------------------------------------------------------------   

WHILE(GETASYNCKEYSTATE(VK_ESCAPE)<> -32767 AND PTC_GETLEFTBUTTON = FALSE)
    PLASMA()
    VERTICAL_BARS()
    UPDATE_SCREEN()
    PTC_UPDATE@BUFFER(0) 
   
WEND
END

'-------------------------------------------------------------------------------

SUB PLASMA()
DIM AS INTEGER X,Y,C

FOR Y=0 TO BYRES-1
    FOR X=0 TO BXRES-1
        C=2+2*SIN(((X XOR Y)+TIMER*65)/15)-1
    FRBUFFER(X+(Y*BXRES))=C
    NEXT
NEXT

END SUB


SUB VERTICAL_BARS()
DIM L AS INTEGER

    FOR L= 50 TO 120 STEP 2
        DRAW_VBAR(70+(30*SIN((L+TIMER*34)/13))-(30*COS((L+TIMER*14)/13)),L)
        DRAW_VBAR(70+(30*COS((L+TIMER*43)/23))-(30*SIN((L+TIMER*23)/13)),L+1)
       
    NEXT

END SUB

SUB DRAW_VBAR(BYVAL XP AS INTEGER , BYVAL YP AS INTEGER)
DIM AS INTEGER X,Y,C,XXP,MD,CUNT

FOR X=0 TO 10       
   
    SELECT CASE X
    CASE 0,10
        C=0
        CUNT=1
    CASE 1,9       
        C=0
        CUNT=0
    CASE 2,8
        C=1
        CUNT=1
    CASE 3,7       
        C=2
        CUNT=0       
    CASE 4,6       
        C=2
        CUNT=1               
    CASE ELSE
        CUNT=0
        MDS=0
        C=3
    END SELECT
    XXP=X+XP
    MD=MDS
    FOR Y=YP TO BYRES-1     
            IF CUNT=1 THEN
            MD=MD+1   
            IF MD>1 THEN MD=0
            END IF
       
            FRBUFFER((Y*BXRES)+XXP)=C+MD
    NEXT
   
NEXT

END SUB


'-------------------------------------------------------------------------------
' EXPAND SCREEN DISPLAY AND ERASE FRAMEBUFFER
'-------------------------------------------------------------------------------

SUB UPDATE_SCREEN()
DIM AS INTEGER XL,YL,I,TC,SLICE
DIM PP1 AS UINTEGER PTR
DIM PP2 AS UINTEGER PTR

FOR YL=0 TO BYRES-1
   
    FOR I=0 TO PIXSIZY-1
       
        pp1=@BUFFER(((YL*PIXSIZY)+I)*XRES)
        PP2=@FRBUFFER(YL*BXRES)
       
        FOR XL=0 TO BXRES-1
   
        TC=C_PALETTE(*PP2)       
        SLICE=PIXSIZE
       
            asm
                mov eax,dword ptr[TC]
                mov ecx, [slice]
                mov edi, [PP1]
                rep stosd
            end asm   
       

        PP1+=4
        PP2+=1
    NEXT
     
    NEXT

NEXT
FOR YL=0 TO BYRES-1
    PP1=@FRBUFFER(YL*BXRES)
    FOR XL=0 TO BXRES-1
        *PP1=0
        PP1+=1
    NEXT
NEXT
END SUB
Title: Re: Reduced Res - Not entered.
Post by: Xalthorn on September 04, 2008
I like the colour choice, but it doesn't seem to flow very smoothly.  I think it's the background that throws it out for me.
Title: Re: Reduced Res - Not entered.
Post by: Clyde on September 04, 2008
In hind sight as im an oldskool & C64 fan, its pretty good stuff mate, I like your vertical rasters.
Title: Re: Reduced Res - Not entered.
Post by: Shockwave on September 04, 2008
Thanks guys, it didn't really light my fire though so in the bin it went :) Along with most of the other stuff I start ;)
Title: Re: Reduced Res - Not entered.
Post by: Xalthorn on September 04, 2008
I had a fair few of those, bright lights of inspiration that never really worked for me and got binned.
Title: Re: Reduced Res - Not entered.
Post by: DrewPee on September 04, 2008
I love your variable names!!! LOL!

I love the vertical bars - that effect is fantastic - I agree with Xalthorn though the background . . . not sure about that?

Thanks for the code though Shockwave! :)

DrewPee
Title: Re: Reduced Res - Not entered.
Post by: Wombat on September 04, 2008
Code: [Select]
CASE ELSE
        CUNT=0

Interesting choice of variable name  :2funny:
Title: Re: Reduced Res - Not entered.
Post by: Shockwave on September 04, 2008
 :-[

Really fucking sorry for the variable names ;) What can I say?

I may have been drinking when I wrote it.  :diablo: