ACagliano wrote:
ah ok. I might use the 16-bit Galois FFSR bc the effect is closer to what I want to do. And for the lighter effect, do as you say.
Now, is there a way to basically set in the program whether to apply static, apply dark static, or apply light static, so that when the interrupt fires, it will do only what it is supposed to?
If the grayscale routine separates the current input bytes from the buffers into two different registers (like how E:SoR does), then doing this should be pretty trivial, with the only real variations being which byte goes where.
For light: LSFR -> light ; 0 -> dark
For dark: 0 -> light ; LFSR -> dark
For regular: LFSR -> light ; LFSR -> dark.
The actual logic on how to do it is up to you, tho if you want a hint or possible suggestions, here's a relevent snippet from E:SoR that does color layer effects, among other things, right in the LCD routine via jp (ix) and copying the routines to RAM:
Code:
DGC2MASK1 equ %10110110
DGC2MASK1E equ %0110110111011011
DGC2MASK2 equ %01101101
DGC2MASK2E equ %1101101110110110
DGC2MASK3 equ %11011011
DGC2MASK3E equ %1011011001101101
DGC1INIT:
bit dotilemap,(iy+sysflags)
jp nz,DGC1TILE
ld bc,DGC2MASK1+(256*64) ;10 10
ld hl,DGC2MASK1E ;10 20
jp DGC2CONT ;10 30
DGC2INIT:
xor a
ld hl,movetrack ;10 42
ld (hl),a
inc (hl) ;07 66
ld L,a ;04 70
ld h,$8A ;07 77
ld a,(hl) ;07 84
ld L,$00 ;07 91
rra \ rr L ;12 103
rra \ rr L ;12 115
or %11000000 ;07 122
ld h,a ;04 126
ex de,hl ;04 130
ld bc,DGC2MASK2+(256*64) ;10 10
ld hl,DGC2MASK2E ;10 20
jp DGC2CONT ;10 30
DGC3INIT:
ld hl,gamecount \ inc (hl)
or a
ld hl,movetrack ;10 42
ld a,(hl) ;07 59
inc (hl) ;07 66
ld L,a ;04 70
ld h,$8A ;07 77
ld a,(hl) ;07 84
ld L,$00 ;07 91
rra \ rr L ;12 103
rra \ rr L ;12 115
or %11000000 ;07 122
ld h,a ;04 126
ex de,hl ;04 130
ld bc,DGC2MASK3+(256*64) ;10 10
ld hl,DGC2MASK3E ;10 20
jp DGC2CONT ;10 30
DGC2CONT:
; xor a
; ld (moving),a ;dummied out for now
; ld (screenfx),a ;dummied for now
push bc ;11 41
exx ;HL out of our way now. ;04 45
ld a,(screenfx) ;13 58
add a,a ;x2 ;04 62
ld L,a ;x2sav ;04 66
add a,a ;x4 ;04 70
add a,L ;x6 ;04 74
ld hl,ScrnFXTbl01 ;10 84
ld c,a ;04 88
ld b,0 ;07 95
add hl,bc ;11 106
push hl ;save 1st copy loc ;11 117
ld a,(myflags+travelflags) ;13 130
rlca ;04 134
and %00000100 ;airshipflag ;07 141
ld L,a ;04 145
ex af,af' ;04 149
ld a,$80 ;07 156
out (10h),a ;11 167
ex af,af' ;04 4
ld a,(movedir) ;13 17
add a,L ;04 21
ld L,a ;x1sav ;04 29
add a,a ;x2 ;04 25
add a,a ;x4 ;04 33
add a,L ;x5 ;04 37
ld c,a ;04 41
ld hl,ScrnFXTbl03 ;10 51
add hl,bc ;11 62
ex (sp),hl ;1st copy loc ;11 73
ld bc,6 ;10 83
ld de,ramseg4 ;10 93
ldir ;.. OVER
ld hl,ScrnFXTbl02
ld bc,5
ldir
pop hl ;holds ScrnFXTbl3+nn
ld bc,5
ldir
ld bc,6
ld hl,ScrnFXTbl04
ldir
pop bc
ld a,$20
ld hl,$8000
ld ix,ramseg4
;HL=bufferaddress DE=temp B=loopcount C=temp
;HL'=mask C'=mask B'=unused DE'=(when rotating) pointer to tiles to rotate
DGC2ML:
out (10h),a ;11 11
ex af,af' ;04 15
DGC21L: ;--
ld e,(hl) ;07 07 22
inc L ;04 11 26
ld d,(hl) ;07 18 33
inc HL ;06 24 39
jp (ix) ;08 32 47
DGC2ILB: ;94 126 141
ld a,c ;04 130 145
xor e ;04 134 149
and d ;04 138 153
xor e ;04 142 157
out (11h),a ;11 153 168
djnz DGC21L ;13 166 24
exx ;04 28
ex de,hl ;04 32
ld hl,movetrack ;10 42
ld a,(hl) ;07 59
inc (hl) ;07 66
ld L,a ;04 70
ld h,$8A ;07 77
ld a,(hl) ;07 84
ld L,$00 ;07 91
rra \ rr L ;12 103
rra \ rr L ;12 115
or %11000000 ;07 122
ld h,a ;04 126
ex de,hl ;04 130
ld a,c ;04 134
ld c,l ;04 138
ld l,h ;04 142
ld h,a ;04 146
exx ;04 150
ex af,af' ;04 154
inc a ;04 158
ld b,64 ;07 165
cp $20+12 ;07 172
jr nz,DGC2ML ;12 184
ld hl,movetrack
dec (hl)
ret
ScrnFXTbl01: ;routinejump, effects.
;E -> C dg
;D -> E lg
;[0] None [1] 1Light [2] 2Light [3] 3Light [4] 1Dark
;[5] 2Dark [6] 3Dark [7] InvertAll [8] InvertGrey [9] DivCol
;[A] MonoChrome [B] UnknownSwap
;EFFECT none
ld c,e \ ld e,d \ nop
nop \ nop \ nop
;EFFECT one lighter
ld a,e \ and d \ ld c,a
xor e \ ld e,a \ nop
;EFFECT two lighter
ld a,e \ and d \ ld e,a
xor a \ ld c,a \ nop
;EFFECT all lighter
xor a \ ld c,a \ ld e,a
nop \ nop \ nop
;EFFECT one darker
ld a,e \ or d \ ld c,a
xor e \ cpl \ ld e,a
;EFFECT two darker
ld a,e \ or d \ ld e,a
cpl \ or e \ ld c,a
;EFFECT all darker
xor a \ cpl \ ld c,a
ld e,a \ nop \ nop
;EFFECT invert all
ld a,e \ cpl \ ld c,a
ld a,d \ cpl \ ld e,a
;EFFECT invert gray
ld c,d \ nop \ nop
nop \ nop \ nop
;EFFECT diverge
ld c,e \ ld a,e \ cpl
ld e,a \ nop \ nop
;EFFECT monocrhome
ld c,e \ nop \ nop
nop \ nop \ nop
;EFFECT unkown
ld c,d \ ld a,d \ cpl
ld e,a \ nop \ nop
ScrnFXTbl02: ;5 bytes
exx
ld a,h
ld h,c
ld c,L
ld L,a
ScrnFXTbl03: ;entries are 5 bytes wide. Each takes 28ccs.
inc sp \ dec sp \ inc sp \ dec sp \ nop
ld a,(de) \ rlca \ nop \ ld (de),a \ inc de
ld a,(de) \ rrca \ nop \ ld (de),a \ inc de
inc sp \ dec sp \ inc sp \ dec sp \ nop
inc sp \ dec sp \ inc sp \ dec sp \ nop
ld a,(de) \ rlca \ rlca \ ld (de),a \ inc de
ld a,(de) \ rrca \ rrca \ ld (de),a \ inc de
inc sp \ dec sp \ inc sp \ dec sp \ nop
ScrnFXTbl04: ;6 bytes
ld a,c
exx
ld d,a
jp DGC2ILB
Important note: Do NOT attempt to use this routine verbatim. It does things only insane people do under conditions that only insane people would run it under.