Author Topic: Matrix digital rain  (Read 745 times)

0 Members and 1 Guest are viewing this topic.

Offline cpc4eva

  • 464 Plus
  • *****
  • Posts: 473
  • Country: au
  • Liked: 144
  • Likes Given: 147
Matrix digital rain
« on: 08:24, 04 October 15 »
just came across a post in fb showing that a guy has coded the digital rain from the matrix movie for his speccy.

there is also a video of it on youtube looks cool enough.

wondering if anyone has done this on a CPC ?  would it be the same code as the speccy for a CPC version ?

i reckon this would look really cool on a cpc especially in demos :)


the links with the speccy code and youtube vid are here -

Retro Programming: The Matrix Digital Rain for the ZX Spectrum

The Matrix Digital Rain on the Sinclair ZX Spectrum - YouTube


speccy Matrix digital rain code
========================

org 08000h

; black border / black attributes

        xor a
        out (0FEh),a
        ld hl,05AFFh
attr:   ld (hl),a
        dec hl
        bit 2,h
        jr z,attr

; fill screen with random characters

        ld e,a
fillscr:ld d,040h
fill:   call rndchar
        ld a,d
        cp 058h
        jr nz,fill
        inc e
        jr nz,fillscr

; digital rain loop

frame:  ld b,06h
        halt
column: push bc

; randomize one character

        call random
        and 018h
        jr z,docol
        add a,038h
        ld d,a
        call random
        ld e,a
        call rndchar

; select a random column

docol:  call random
        and 01Fh
        ld l,a
        ld h,058h

; ~1% chance black -> white

        ld a,(hl)
        or a
        ld bc,0247h
        jr z,check

; white -> bright green

white:  cp c
        ld c,044h
        jr z,movecol

; bright green -> green

        cp c
        ld c,04h
        jr z,movecol

; ~6% chance green -> black

        ld bc,0F00h
check:  call random
        cp b
        jr c,movecol
        ld c,(hl)

; move column down

movecol:ld de,020h
        ld b,018h
down:   ld a,(hl)
        ld (hl),c
        ld c,a
        add hl,de
        djnz down
        pop bc
        djnz column

; test for keypress

        ld bc,07FFEh
        in a,(c)
        rrca
        jr c,frame
        ret

; display a random glyph

rndchar:call random
crange: sub 05Fh
        jr nc,crange
        add a,a
        ld l,a
        ld h,0
        add hl,hl
        add hl,hl
        ld bc,(05C36h)
        add hl,bc
        ld b,8
char:   ld a,(hl)
        ld (de),a
        inc d
        inc hl
        djnz char
        ret

; get a byte from the ROM

random: push hl
        ld hl,(seed)
        inc hl
        ld a,h
        and 01Fh
        ld h,a
        ld (seed),hl
        ld a,(hl)
        pop hl
        ret

seed:

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 16.582
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3812
  • Likes Given: 6829
Re: Matrix digital rain
« Reply #1 on: 20:16, 10 October 15 »
Here's the vid (you got to use the YouTube button:


[youtube]https://www.youtube.com/watch?v=ehM2FiLmAVE[/youtube]


Shame it's not higher resolution but indeed I'd love to see it on a CPC!

Offline cpc4eva

  • 464 Plus
  • *****
  • Posts: 473
  • Country: au
  • Liked: 144
  • Likes Given: 147
Re: Matrix digital rain
« Reply #2 on: 23:44, 10 October 15 »
just been watching the original digital rain from the matrix movie, the speccy digital rain has more blank space in comparison