Author Topic: Plasma effect  (Read 3683 times)

0 Members and 1 Guest are viewing this topic.

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1161
  • Likes Given: 1931
Plasma effect
« on: 07:04, 07 January 17 »
From the BASIC source I had of a Graphical plasma, I've used that to collect the colour data from it and have used my assembly plot routine to quickly draw it in (takes about 30 seconds), the compromise is it's using 32k. Once the drawing is complete I'm using Assembly to rotate the colour palette through a Loop, you can press Space to exit the program.


[attachimg=1]


Code: [Select]

org &1000


xor a ;; Setup data for Screen Mode
call &bc0e ;; Set Screen Mode 0


call setup_inks ;; Setup inks for image
call draw_image

.colour_cycle
call &bb09
cp &20
jp z,exit
ld a,4
ld bc,&0909
call &bc32
call &bd19
ld a,3
ld bc,&1a1a
call &bc32
call &bd19
ld a,2
ld bc,&0606
call &bc32
call &bd19
ld a,1
ld bc,&0303
call &bc32
call &bd19
ld a,4
ld bc,&0303
call &bc32
call &bd19
ld a,3
ld bc,&0909
call &bc32
call &bd19
ld a,2
ld bc,&1a1a
call &bc32
call &bd19
ld a,1
ld bc,&0606
call &bc32
call &bd19
ld a,4
ld bc,&0606
call &bc32
call &bd19
ld a,3
ld bc,&0303
call &bc32
call &bd19
ld a,2
ld bc,&0909
call &bc32
call &bd19
ld a,1
ld bc,&1a1a
call &bc32
call &bd19
ld a,4
ld bc,&1a1a
call &bc32
call &bd19
ld a,3
ld bc,&0606
call &bc32
call &bd19
ld a,2
ld bc,&0303
call &bc32
call &bd19
ld a,1
ld bc,&0909
call &bc32
call &bd19
jp colour_cycle


.exit ret


.draw_image
ld hl,&2000 ;; Address of Data Colour
ld (addrcolour),hl ;; Place this into Address Colour
.loop
ld hl,(addrcolour) ;; Place Contents of Address Colour into HL
ld a,(hl) ;; Put Contents of HL into A
cp 0
jr z,iszero


  call &bbde ;; GRA SET PEN - A = Pen Colour


ld de,(xpos) ;; XPOS data into DE
ld hl,(ypos) ;; YPOS data into HL
call &bbea ;; GRA ABSOLUTE PLOT


.iszero
  ld hl,(addrcolour) ;; Take address of address colour
  inc hl ;; Increment it by 1
  ld (addrcolour),hl ;; Put this value into Address Colour


ld hl,(xpos) ;; Obtain Contents of XPOS
ld bc,0004 ;;
add hl,bc ;; Add 4 to xpos
ld (xpos),hl ;; Place next value into XPOS

ld a,(fcount) ;; First Counter Position into A
inc a ;; Increment this
ld (fcount),a ;; Put New Value into First Count Position
ld b,a ;; Put this value into B


ld a,(xlcount) ;; Place First Counter Marker into A


cp b ;; Has value of B reached A value
jr nz,loop ;; If No Loop back, otherwise continue


ld a,(fcount) ;; At this stage fcount equals 8
xor a ;; This will make it 0 again
ld (fcount),a ;; And put that value into fcount


ld hl,(ypos) ;; value of YPOS goes into HL
dec hl ;; value of YPOS is decreased
dec hl ;; Twice (100..98..96..94..etc)
ld (ypos),hl ;; And put that value into YPOS.


ld hl,&0000 ;; HL = 0
ld (xpos),hl ;; Return xpos to 0


ld a,(scount) ;; Second counter goes into A
inc a ;; Increase it.
ld (scount),a ;; Place back into Second Counter
ld b,a ;; Put value of Second counter into B


ld a,(ylcount) ;; Place Y-counting position into A


cp b ;; Compare A to value of B
jr nz,loop ;; If reached exit, otherwise return

ld a,0 ;; \
ld hl,fcount ;; \\
ld (hl),a ;; Returns loop values back to 0
ld hl,scount ;; //
ld (hl),a ;; /

ld hl,398 ;; Return the value of ypos
ld (ypos),hl ;; back to it's original place.


ret ;; Program exits here.


.setup_inks
ld bc,&0202
call &bc38
ld hl,colours
ld a,0
.inks_loop
ld c,(hl)
ld b,c
push af
push hl
call &bc32
pop hl
pop af
inc hl
inc a
cp 5
jr c,inks_loop
  ret ;; Return to Main Loop Routine.

.fcount defb 0
.scount defb 0
.xlcount
defb 161 ;; Number of times to loop across.
.ylcount
defb 200 ;; Number of times to loop down
.xpos defw 0 ;; Left Position the image
.ypos defw 398 ;; Bottom Position of the image.
.colours
defb 2,9,3,6,26
.addrcolour
  defw 0 ;; This points to the address position
;; within the data colour.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline Overflow

  • Supporter
  • CPC664
  • *
  • Posts: 60
  • Country: fr
  • Liked: 177
  • Likes Given: 107
Re: Plasma effect
« Reply #1 on: 11:25, 07 January 17 »
Nice start! I suggest you try with 15 cycling-colors i.e. full mode 0.

---

I do LOVE color-cycling, such as in Backtro 2nd part.
OK it's smoother - since seveval (3) screens are flipped:
before cycling colors, switching to a screen with shapes moved by 1/3rd cycle then 2/3rd cycle.

Quite old but I remember this old thread you might find interesting
(we may also discuss more about it - just ask).
Attached "temp2.dsk" on 128KB machine only:
RUN"GEN-FX is a Basic program which draws 4 screens and save them "0.BIN" to "3.BIN"
RUN"FX 1st uses PROG.BIN to put all system in extra 64KB RAM.
This allows the 4 screens to be loaded each into one of the 4*16KB VRAM
Then Basic is used to switch screens and cycle colors for a smooth effect.

Well, quite static in that screenshot. ;)
 

« Last Edit: 13:11, 07 January 17 by Overflow »
Unregistered from CPCwiki forum.

Offline Bytebreaker

  • CPC664
  • ***
  • Posts: 66
  • Country: de
  • Liked: 84
  • Likes Given: 77
Re: Plasma effect
« Reply #2 on: 00:21, 08 January 17 »
Great stuff!


Is the Basic code for the plasma still available so it could be posted here?

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.939
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1161
  • Likes Given: 1931
Re: Plasma effect
« Reply #3 on: 01:17, 08 January 17 »
Sure, unfortunately I didn't save the original and I haven't tested this, but I think this was how the original looked:


Code: [Select]

10 MEMORY &1FFF : MODE 0
20 INK 0,0 : INK 1,9 : INK 2,3 : INK 3,6 : INK 4,26
30 XDELT = 0.125
40 YDELT = 0.1
50 Y = 10
60 I% = 0
70 WHILE I% < 200
80 X = -10
90 J% = 0
100 WHILE J% < 160
110  R1 = SQR(((X-1)*(X-1))+((Y-1)*(Y-1)))
120  R2 = SQR(((X+1)*(X+1))+((Y+1)*(Y+1)))
130  Z = COS(R1)+COS(R2)
150  IF (Z > 0) AND (Z < 0.5) THEN POKE &2000+J%+(I%*161),&1
160  IF (Z > 0.5) AND (Z < 1) THEN POKE &2000+J%+(I%*161),&2
170  IF (Z > 1) AND (Z < 1.5) THEN POKE &2000+J%+(I%*161),&3
180  IF (Z > 1.5) AND (Z < 2) THEN POKE &2000+J%+(I%*161),&4
190 X = X + XDELT
200 J% = J% + 1
210 WEND
220 Y = Y - YDELT
230 I% = I% + 1
240 WEND
250 SAVE"PLASMA.PAL",B,&2000,&7E68



If you play around with the XDELT & YDELT variables, you can get different angles of the effect.


I'll leave it up to others if you want to add more colours to the effect, perhaps working in quarters instead of halves will allow up to 10 colours.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 650
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 652
  • Likes Given: 379
Re: Plasma effect
« Reply #4 on: 19:48, 14 January 17 »
Nice!

A little speedup to the ASM-Player: run"plasma2

(around 5 sek to draw)