SCREEN FX 2 by Damian Scattergood Damian Scattergood, the Z80 Project Leader of Emerald Software, nominated as Mr. Benevolence for three years in succession, was so impressed with my screen effects special a few months back (swell) that he decided to submit a compendium of routines himself. I was so impressed I printed them. Lines The Spectrum screen display is a complicated beast, using all manner of confusing and downright irritating structural nuances that can make it a major hurdle for a novice. I won't go into detaiLs but briefly there are 192 pixel lines, divided into three blocks of 64 lines, covering memory locations 16384 to 22527; the screen addresses go in batches of eight so that logically the address you want is never in the right place. Well, something like that anyway. These two routines are used to calculate the screen address of the next scan line up or down. You'll need an assembler to enter them in, and they'll go in any address. Next Line Down ;Execute this routine with HL ;pointing to the screen address ;and HL will return with the ;next line down NXTC ld a,h and 7 cp 7 jr z,LINEE inc h ret LINEE ld a,l and 224 cp 224 jr z,NCHAR ld de,1760 and a sbc hl,de ret NCHAR ld de,32 add hl,de ret Next Line Up LSTC ld a,h and 7 jr z,SALI dec h ret SALI ld a,l and 224 jr z,SASE ld de,1760 and a adc hl,de ret SASE ld de,32 and a sbc hl,de ret Nibbling The next program is one big demo, split up into five easily digestible parts. It combines the two previous/next scan-line routines into a mammoth scrolling demo, shifting windows all over the place, up, down, left and right! And to boot, it scrolls by four pixels (or "nibbles" if you want to be confused by jargon). Very useful for faster than fast scrolls. The Huge Demo ;This whopper (fnurk!) is the ;demo, using the previous two ;routines DEMO call FILL ld b,20 LOOP1 push bc ld hl,16384+15 ld bc,10c0h call SLEFT ld hl,16384+16 ld bc,10c0h call SRIGHT pop bc djnz LOOP1 ld b,20 LOOP2 push bc ld hl,16384 ld bc,6020h call SUP4 pop bc djnz LOOP2 ld b,20 LOOP3 push bc ld hl,20640 ld bc,6020h call SDOWN4 pop bc djnz LOOP3 ret This is the main stem of the program and addresses sub-routines with CALL statements (rather like GOSUBs in Basic). The register HL holds the top right screen address of the window to be scrolled, and BC holds the height and width of that window. FILL ld hl,16384 ld bc,6143 LOOP4 ld (hl),l inc hl dec bc ld a,b or c jr nz,LOOP4 ret So there's something there to scroll, this small routine simply fills the screen with garbage. Not just any old garbage though, strategic garbage. SLEFT push hl DEEP push bc xor a LOOP5 rld dec hl djnz LOOP5 pop bc pop hl call NXTC push hl dec c jr nz,DEEP pop hl ret This sub-routine shifts the contents of a window left by four pixels, using the specific instruction 'RLD'. SRIGHT push hl DEEP1 push bc xor a LOOP6 rrd inc hl djnz LOOP6 pop bc pop hl call NXTC push hl dec c jr nz,DEEP1 pop hl ret This similar sub-routine shifts the contents of the window right by four pixels, using the specific instruction 'RRD'. [This scrolls up, not down. JimG] SDOWN4 push hl call LSTC call LSTC call LSTC call LSTC ex de,hl pop hl ex de,hl LOOP7 push bc push de push hl ld b,0 ldir pop hl call LSTC pop de ex de,hl push de call LSTC pop de ex de,hl pop bc djnz LOOP7 ret The down scroll routine works in a different way. It calculates the address four bytes below and block moves everything in the window to that address, creating a "scrolling" illusion. [This scrolls down, not up. JimG] SUP4 push hl call NXTC call NXTC call NXTC call NXTC ex de,hl pop hl ex de,hl LOOP8 push bc push de push hl ld b,0 ldir pop hl call NXTC pop de ex de,hl push de call NXTC pop de ex de,hl pop bc djnz LOOP8 ret This up scroll routine is almost identical as the previous one, but calculates the address four bytes above instead.