Author Topic: [Z80-Asm] Plasma  (Read 2666 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
[Z80-Asm] Plasma
« on: June 21, 2013, 05:48:39 pm »
Based on code that Matrefeytontias gave me, I put together a plasma program in assembly :) I am pleased with the speed, but it can be made a bit faster. First, I am using the OS bcall _GrBufCpy which is not that fast, and second, if I include a custom routine, it will be interleaved with the program so updating the LCD will cost almost no extra time. Using some mathy things and Wabbit's code counter, I estimate cutting out 167000 t-states every loop by ditching the OS routine and using an interleaved routine.
Anyways, here is what it looks like at 6MHz and the code I through together for this first version :)
Code: [Select]
#include    "ti83plus.inc"
#define     progStart   $9D95
.org        progStart-2
.db         $BB,$6D
MainLoop:
     .db 3Eh    ;start of ld a,*
smc_index:
     .db 0
     inc a
     and 1Fh
     ld (smc_index),a
     ld hl,LUT
     add a,l
     jr nc,$+3
     inc h
     ld l,a
     ld c,(hl)
     .db 16h     ;ld d,*
smc_yskew:
     .db 40
     call C_div_D
     ld a,c
; ld a,(hl)
; rlca \ rlca \ rlca \ and 7
     ld (smc_ycomponent),a

     ld a,(smc_index)
     add a,a
     .db $C6
smc_var1:
     .db 0
     and 31
     ld hl,LUT
     add a,l
     jr nc,$+3
     inc h
     ld l,a
     ld c,(hl)
     .db 16h     ;ld d,*
smc_xskew:
     .db 32
     call C_div_D
     ld a,c
; ld a,(hl)
; rlca \ rlca \ rlca \ and 7
     ld (smc_xcomponent),a
     ld ix,933Fh
     ld hl,0
while_y_lt_32:
     ld a,l
     .db $C6
smc_ycomponent:
     .db 0
     and 31
     ld de,LUT
     add a,e
     jr nc,$+3
     inc d
     ld e,a
     ld a,(de)
     ld (smc_m),a
while_x_lt_48:
     ld a,h
     .db $C6       ;add a,*
smc_xcomponent:
     .db 0
     and 31
     ld de,LUT
     add a,e
     jr nc,$+3
     inc d
     ld e,a
     ld a,(de)
     .db $C6
smc_m:
     .db 0
     ld b,0
     jr nc,$+3
     inc b
     ld c,a
     push bc
     ld de,(smc_ycomponent)
     ld a,(smc_xcomponent)
     add a,e
     add a,h
     add a,l
     ld c,a
     ld a,(smc_index)
     add a,c
     and 31
     ld de,LUT
     add a,e
     jr nc,$+3
     inc d
     ld e,a
     ld a,(de)
     pop bc
     add a,c
     jr nc,$+3
     inc b
     rr b \ rra
     rr b \ rra
     ld b,a          ;color
     ld a,h \ and 3
     jr nz,$+10
       inc ix
       ld (ix),a
       ld (ix+12),a
     rl (ix) \ rl (ix)
     rl (ix+12) \ rl (ix+12)
     ld a,b
     cp 144 \ jr nc,$+5
     inc (ix)
     cp 96 \ jr nc,$+8
     inc (ix+12)
     inc (ix+12)
     cp 48 \ jr nc,$+11
     inc (ix+12)
     inc (ix)
     inc (ix)
     inc h
     ld a,h
     cp 48
     jr nz,while_x_lt_48
     ld h,0
     ld de,12
     add ix,de
     inc l
     ld a,l
     cp 32
     jp nz,while_y_lt_32

     bcall(486Ah)
     bcall(4744h)
     cp 15
     ret z
     ld hl,(smc_xskew)
     ld de,(smc_yskew)
     ld bc,(smc_var1)
     cp 3
     jr nz,$+3
       inc l
     cp 2
     jr nz,$+3
       dec l
     cp 1
     jr nz,$+3
       inc e
     cp 4
     jr nz,$+3
       dec e
     cp 10
     jr nz,$+3
       inc c
     cp 11
     jr nz,$+3
       dec c
     ld a,c
     and 31
     ld (smc_var1),a
     ld a,e
     cp 64
     jr nc,$+5
       ld (smc_yskew),a
     ld a,l
     cp 64
     jr nc,$+5
       ld (smc_xskew),a
     jp MainLoop

LUT:
.db 255,254,246,234,219,199,177,153,128,103,79,57,37,22,10,2,0,2,10,22,37,57,79,103,128,153,177,199,219,234,246,254
C_Div_D:
;Inputs:
;     C is the numerator
;     D is the denominator
;Outputs:
;     A is the remainder
;     B is 0
;     C is the result of C/D
;     D,E,H,L are not changed
;

     xor a
     sla c
     rla
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     jr c,$+4
       inc c
       sub d
     sla c
     rla
     cp d
     ret c
     inc c
     sub d
     ret
Controls:
Arrows change the skew value. I actually have no idea what effect these have except that small number produce more noticeable effects. The upper limit is 63, I think the lower limit is 0 (which will result in dividing by 0).
+ and - change a value to, and I also don't know precisely how that value is changing things.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [Z80-Asm] Plasma
« Reply #1 on: June 21, 2013, 05:59:25 pm »
lol, it is far faster than the axe version, nice job :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Z80-Asm] Plasma
« Reply #2 on: June 21, 2013, 11:00:13 pm »
Looks very nice.

By the way, I wonder how cool would a racing or tunnel game be if the track was made of an animated plasma effect? Basically, the white would be black and the gray white, and you would have to stay inside the white area.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Z80-Asm] Plasma
« Reply #3 on: June 22, 2013, 11:08:54 am »
Cool, but the plasma looks weird IMO ...

lol, it is far faster than the axe version, nice job :D
Of course it is, since it's ASM :P

By the way, I wonder how cool would a racing or tunnel game be if the track was made of an animated plasma effect? Basically, the white would be black and the gray white, and you would have to stay inside the white area.
I don't really see how you could make a game out of a plasma ... excepting maybe a texture for a raycaster like I did with nRayC ???

Online DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Re: [Z80-Asm] Plasma
« Reply #4 on: June 22, 2013, 11:47:03 am »
It could maybe prove to be fun and challenging since you would have to dodge the road sides, but it would have to not move too fast so that winning the game is possible. :P

Offline utz

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 161
  • Rating: +28/-0
    • View Profile
    • official hp - music, demos, and more
Re: [Z80-Asm] Plasma
« Reply #5 on: June 22, 2013, 05:02:24 pm »
I'm with Matrefeytontias, looks kinda weird for plasma. But I'm too stupid to do any demoscene fx so I shouldn't talk :P

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: [Z80-Asm] Plasma
« Reply #6 on: June 23, 2013, 05:03:23 am »
Looks very nice.

By the way, I wonder how cool would a racing or tunnel game be if the track was made of an animated plasma effect? Basically, the white would be black and the gray white, and you would have to stay inside the white area.
mind=blowen
awesome idea coming up there

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!