So I'm revisiting some of my old projects to have a play and see if they can be shrunk a bit and maybe improved.
This one was posted on WOS in 2017 I think originally. Its a square reveal screen fade-in (for want of a catchier name!) that uses a 192 byte plasma field to take a screen stored in a buffer and send it to the display in an interesting way thus;
Many variations upon the exact pattern for how its revealed are possible just by manipulating the plasma data. Imagine the screen loading into the buffer, then call this routine to show it before then loading the code part for example.
Anyway, having played about with it a bit I've reduced the size to 68 bytes for the routine.
some of you might find a use for it perhaps. Source, commented as best I could here;
Screen stored at 49152
Plasma can be anywhere as long as its aligned to end on a 256 byte boundary, so 5b40, fa40 etc
or in reverse if you change the INC L to DEC L at the end of the routine.
As long as the plasma has good separation and has no more than about 20 active squares at any one frame, then it'll give a good smooth performance
The routine needs to be repeatedly CALLed, so could be run on interrupts or along with something else. Don't let it run on too far past the screen being fully displayed, or it will give odd effects as it tries to print it again.
Code: Select all
entry:
ld de,0d820h ;ATTRs start + 1 line (20h)
ld hl,0bf40h ;plasma table of 192 bytes address
mlp0:
ld a,(hl) ;get plasma cell byte
inc (hl) ;INC value in the plasma table
and 0f8h ;only the 0-7 portion on the plasma byte controls the fade-in
jr nz,nxt_block ;if not 0-7 then skip to next
push hl ;save the plasma table address
ld b,(hl) ;counter in B
ld h,a ;H=00
mask_l:
inc a ;set bit 0,A
rrca ;rotate into bit 7
rl h ;x2 +1
djnz mask_l ;loop
ld b,h ;B=left hand mask, copied to H as a counter/ map
ld c,a ;C=right hand mask
a2s_addr:
ld a,d ;use D to create the SCReen address Hi-byte from the ATTRs Hi byte
add a,a ;x2
add a,a ;x4
add a,a ;x8
ld l,a ;and put into L
push de ;save ATTRs address
a2s_a:
ld a,(de) ;get byte from SCReen buffer
a2s_b:
res 7,d ;remove 80h from D to point to actual SCReen
ld (de),a ;place byte
a2s_c:
ld d,l ;make DE buffer address
inc l ;next line down
mlp1:
ld a,(de) ;get SCReen buffer byte
and b ;mask
srl h ;uses mask bytes as a map of which lines to mask or ignore
jr c,a2s_b ;if a Carry occurs, then write a byte
nlu:
jr nz,a2s_c ;if no write, is the map=00 (finished)?
btm2top:
pop de ;ATTRs address restored into DE
ld h,c ;upper mask as counter map into H
ld a,e ;lo ATTRs byte
res 5,e ;RES to upper CHR line of the square
cp e ;test against A, is it the same or not?
jr nz,a2s_addr ;if not, then loop back to do the upper CHR square
left_swap:
ld h,b ;restore mask for lower into H
ld b,c ;swap masks (right into left)
xor 21h ;make the ATTRs address INC & lower CHR line
ld e,a ;
rra ;test BIT 0
jr c,a2s_addr ;if ='1' then loop again, if '0' then we're finished
;the plasma 2x2 square
pop hl ;restore plasma address into HL
nxt_block:
inc e ;next right
inc de ;next right and take care of D if it needs to INC
set 5,e
mlp3:
inc l ;next plasma byte
jr nz,mlp0 ;repeat
ret ;
https://dl.dropbox.com/s/9u3ooxgvwzll8j ... 1.tap?dl=1
A couple of example Plasmas
https://dl.dropbox.com/s/eqlensqp5s520q ... t.bin?dl=1
https://dl.dropbox.com/s/4rov6rn923ti3n ... t.bin?dl=1