English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   How to do AGA copperbars in Blitz using display library (https://eab.abime.net/showthread.php?t=69550)

Coagulus 09 June 2013 11:57

How to do AGA copperbars in Blitz using display library
 
Hi,

I know it's very old hat but I'm retro through and through :). Anyone know if it's possible to do the classic bouncing AGA copper bars in Blitz using the display library?

Coagulus

Coagulus 02 November 2013 19:03

Well, I decided to play with the Displayrainbow command and bars can be done. The code is not the best I'm sure, but it produces AGA bars!

Code:

; AGA copperbars by Coagulus

InitPalette 0,256

BitMap 0,320,256,8

For a=0 To 255
  AGAPalRGB 0,a,0,0,0
Next

Dim bar(32)
Dim bary(3) ; 1-red 2-green 3-blue
Dim baryt(3)
Dim barydir(3)

For a=1 To 16
  bar(a-1)=(a*16)-1
Next
For a=16 To 1 Step -1
  bar(15+(17-a))=(a*16)-1
Next

baryt(0)=-3
baryt(2)=3
barydir(0)=1
barydir(1)=1
barydir(2)=1

VWait 150

BLITZ

SpriteMode 2

InitCopList 0,34,256,$10000|$08|$10|$400,8,256,-4

CreateDisplay 0

DisplayPalette 0,0

Cls 0

Repeat
  DisplayBitMap 0,0
  DisplayRainbow 0,0,0

  For a=0 To 255
    AGAPalRGB 0,a,0,0,0 ; blank the palette
  Next

  For a=0 To 2
    bary(a)=bary(a)+baryt(a)
    baryt(a)=baryt(a)+barydir(a)
    If Abs(baryt(a))=13 Then barydir(a)=0-barydir(a)
  Next

  For a=0 To 31
      AGAPalRGB 0,32+a+bary(0),bar(a),0,0
  Next
  For a=0 To 31
      AGAPalRGB 0,32+a+bary(1),0,bar(a),0
  Next
  For a=0 To 31
      AGAPalRGB 0,32+a+bary(2),0,0,bar(a)
  Next

  VWait
Until Joyb(0) OR Joyb(1)

End


Cylon 11 January 2015 21:39

(dig out)

I hope you use Newtypes for this kind of stuff nowadays? It looks a little bit Amos-like to me....

Coagulus 13 January 2015 00:02

Haha, I have been known to use them. I'm afraid my code hasn't changed much since the zx spectrum!

Cylon 01 February 2015 02:38

Quote:

Originally Posted by Coagulus (Post 996958)
Haha, I have been known to use them. I'm afraid my code hasn't changed much since the zx spectrum!

Well, you should consider upgrading your mind!:laughing

Adding only 4 bytes to your src makes a big speedup:

Code:

For a=0 To 31
      AGAPalRGB 0,32+a+bary(0),bar(a),0,0
  ;Next
  ;For a=0 To 31
      AGAPalRGB 0,32+a+bary(1),0,bar(a),0
  ;Next
  ;For a=0 To 31
      AGAPalRGB 0,32+a+bary(2),0,0,bar(a)
  Next

also,

Code:

DisplayBitMap 0,0
Repeat
  ;DisplayBitMap 0,0
  DisplayRainbow 0,0,0

  ;For a=0 To 255
  ; AGAPalRGB 0,a,0,0,0 ; blank the palette
  ;Next
  InitPalette 0,256  ;< this is an ASM routine inside the blitzlib! trust me: it is faster!

  For a=0 To 2
    bary(a)=bary(a)+baryt(a)
    baryt(a)=baryt(a)+barydir(a)
    If Abs(baryt(a))=13 Then barydir(a)=0-barydir(a)
  Next

And, while setting up the bars:
this
Code:

For a=1 To 16
  bar(a-1)=(a*16)-1
Next
For a=16 To 1 Step -1
  bar(15+(17-a))=(a*16)-1
Next

becomes
Code:

;we try to create bars of 32pixl height:
;the saturation value should spread from 0to255 (AGA),
;the bar appears to be 3d-like.

For a=0 To 15
  bar(a)  = (a*16)      ;we donot reach 255 here...
  bar(a+15)= ((16-a)*16)
Next

Isn't that nice? :):spin

Cylon 01 February 2015 03:32

AGA Copper Bars by Coagulus
 
2 Attachment(s)
So, my edits would lead to this:
Code:

; AGA copperbars by Coagulus (EAB)
; modified by Cylon (EAB)

DEFTYPE.w

InitPalette 0,256

BitMap 0,320,256,1  ;just 1 bplane needed! saves chipmem!

Dim bar(32)    ;saturation value (0-255) of bar y line
Dim bary(3)    ; 1-red 2-green 3-blue
Dim baryt(3)
Dim barydir(3)

;we create bars of 32pixl height:
For a=0 To 15
  bar(a)  = (a*16)
  bar(a+15)= ((16-a)*16)
Next

baryt(0)=-3
baryt(2)=3
barydir(0)=1
barydir(1)=1
barydir(2)=1

VWait 100    ;two seconds is enough before takin' the machine over

BLITZ

;SpriteMode 2 ;not needed.

;1bitplane 24bit(256,256,256) aga coplist
;again: we use the copper only, so 1 bplane is enough.
InitCopList 0,34,256,$10000|$01|$10|$400,8,1,-4
CreateDisplay 0

DisplayPalette 0,0
DisplayBitMap 0,0

Repeat
  VWait
  DisplayRainbow 0,0,0

  InitPalette0,256

  For a=0 To 2
    bary(a) +baryt(a)
    baryt(a)+barydir(a)
    If Abs(baryt(a)) = 13 Then barydir(a)=0-barydir(a)
  Next

  For a=0 To 31
      AGAPalRGB 0,32+a+bary(0),bar(a),0,0
      AGAPalRGB 0,32+a+bary(1),0,bar(a),0
      AGAPalRGB 0,32+a+bary(2),0,0,bar(a)
  Next

Until Joyb(0) OR Joyb(1)

End

CloseEd

Try it, please.:)
Next, we make it newtype style...maybe;)

Coagulus 01 February 2015 17:13

That's cool, far more efficient! :bowdown

nirvan75 22 January 2016 15:38

Hello guys,

what about an OCS/ECS version of the above example? ;)

Cylon 24 January 2016 22:47

1 Attachment(s)
Quote:

Originally Posted by nirvan75 (Post 1064689)
Hello guys,

what about an OCS/ECS version of the above example? ;)

That is easy to adapt, why didn't you try it for yourself?:laughing

Code:

; AGA copperbars by Coagulus (EAB)
; modified by Cylon (EAB)
; chg: added ecs support ( quick and dirty :P  )

DEFTYPE.w

InitPalette 0,256

BitMap 0,320,256,1  ;just 1 bplane needed! saves chipmem!

Dim bar(32)    ;saturation value (0-255) of bar y line
Dim bary(3)    ; 1-red 2-green 3-blue
Dim baryt(3)
Dim barydir(3)

;we create bars of 32pixl height:

If CheckAGA Then fact.w=16 Else fact.w=1

For a=0 To 15
  bar(a)  = (a*fact)
  bar(a+15)= ((16-a)*fact)
Next

baryt(0)=-3
baryt(2)=3
barydir(0)=1
barydir(1)=1
barydir(2)=1

VWait 100    ;two seconds is enough before takin' the machine over

BLITZ

;SpriteMode 2 ;not needed.

;1bitplane 24bit(256,256,256) aga coplist
;again: we use the copper only, so 1 bplane is enough.
InitCopList 0,34,256,$10000|$01|$10|$400,8,1,-4
CreateDisplay 0

DisplayPalette 0,0
DisplayBitMap 0,0

Repeat
  VWait
  DisplayRainbow 0,0,0

  InitPalette0,256    ;256 cols eq 256 lines vertical

  For a=0 To 2
    bary(a) +baryt(a)
    baryt(a)+barydir(a)
    If QAbs(baryt(a)) = 13 Then barydir(a)=0-barydir(a)
  Next

  If CheckAGA
    For a=0 To 31
      AGAPalRGB 0,32+a+bary(0),bar(a),0,0
      AGAPalRGB 0,32+a+bary(1),0,bar(a),0
      AGAPalRGB 0,32+a+bary(2),0,0,bar(a)
    Next
  Else
    For a=0 To 31
      PalRGB 0,32+a+bary(0),bar(a),0,0
      PalRGB 0,32+a+bary(1),0,bar(a),0
      PalRGB 0,32+a+bary(2),0,0,bar(a)
    Next
  EndIf

Until Joyb(0) OR Joyb(1)

QAMIGA
VWait50

End

 CloseEd
;eof

Note: if you don't have the CheckAGA command than make it a variable like:
Code:

CheckAGA=1
;)

nirvan75 25 January 2016 15:53

so noobs like me can learn from the masters :P
thanks!


All times are GMT +2. The time now is 14:56.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.12173 seconds with 11 queries