|
| 1 | +#WindowAttrScrollUp |
| 2 | + |
| 3 | +# BLAttrWindowScrollUp.bas |
| 4 | + |
| 5 | +This subroutine specified rectangle of screen and scrolls up just the colour attributes up by a character. |
| 6 | +You might be able to use it for games (though there are probably faster scrolly routines for that); |
| 7 | +but the aim here is to be able to scroll up part of the screen, so that you can split between text on a rectangle |
| 8 | +area and other information elsewhere - e.g. graphic adventures. |
| 9 | +This then is an addendum for [windowScrollUP.bas](windowscrollup.md), and can be called with it - |
| 10 | +probably less useful in its own right. Note that it leaves the last line attributes untouched - |
| 11 | +it can't know inherently what colour to paint this section. |
| 12 | + |
| 13 | +``` |
| 14 | +SUB BLAttrWindowScrollUp (X AS UBYTE, Y AS UBYTE, Width AS UBYTE, Height AS UBYTE) |
| 15 | +REM Routine, acting as a pair to BLWindowScrollUp.bas that moves the attributes up - and leaves the last ATTR line untouched (no way) |
| 16 | +ASM |
| 17 | + LD H,58h ; $5800 = 22528 = Attr start |
| 18 | + LD L,(IX+5) ; HL now contains correct column, but top row. |
| 19 | + |
| 20 | + LD A,(IX+7) ; Y |
| 21 | + CP 8 |
| 22 | + JR C, BLAttrWindowScrollUpGotRightThird |
| 23 | + INC H |
| 24 | + CP 16 |
| 25 | + JR C, BLAttrWindowScrollUpGotRightThird |
| 26 | + INC H |
| 27 | + BLAttrWindowScrollUpGotRightThird: |
| 28 | + AND 7 |
| 29 | + RRCA |
| 30 | + RRCA |
| 31 | + RRCA ; Three right rotates - same as 5 left rotates = A=A*32 |
| 32 | + ADD A,L |
| 33 | + LD L,A ; HL now points to correct row, top left corner. |
| 34 | + |
| 35 | + LD D,H |
| 36 | + LD E,L ; Copy HL to DE |
| 37 | + |
| 38 | + LD BC,32 |
| 39 | + ADD HL,BC ; Point HL at one row down. |
| 40 | + LD C,(IX+9) ; width |
| 41 | + LD B,(IX+11) ; Height |
| 42 | + DEC B ; (We don't scroll past the end) |
| 43 | + |
| 44 | + BLAttrWindowScrollUpHeightLoop: |
| 45 | + PUSH BC ; Save our width and height |
| 46 | + PUSH HL |
| 47 | + LD B,0 |
| 48 | + |
| 49 | + BLAttrWindowScrollUpWidthLoop: |
| 50 | + LDIR ; A one instruction width loop :P |
| 51 | + |
| 52 | + POP DE ; Last run's source is now our destination |
| 53 | + LD H,D |
| 54 | + LD L,E ; Copy into HL |
| 55 | + LD BC,32 |
| 56 | + ADD HL,BC ; Move HL down one row |
| 57 | + |
| 58 | + |
| 59 | + POP BC ; get our counters back |
| 60 | + DJNZ BLAttrWindowScrollUpHeightLoop ; Dec height, and if we haven't run out of rows, go do another one. |
| 61 | +END ASM |
| 62 | +END SUB |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | +## Usage |
| 67 | +``` |
| 68 | +BLAttrWindowScrollUp(TopLeftXCoordinate, TopLeftYCoordinate, WidthInCharacters, HeightInCharacters) |
| 69 | +``` |
| 70 | + |
| 71 | +The parameters are the X,Y print coordinates of the Top Left corner, width in characters, and height in characters. |
| 72 | + |
| 73 | +Example of use: |
| 74 | + |
| 75 | +``` |
| 76 | +REM Put something on screen: |
| 77 | +
|
| 78 | +FOR n=1 to 12 |
| 79 | +PRINT INK RND *7; PAPER RND * 7; "01234567890123456789012345678901"; |
| 80 | +PRINT INK RND *7; PAPER RND * 7; "0ABCDEFGHI0KLMNOPQRS0UVWXYZABC0D"; |
| 81 | +NEXT n |
| 82 | +
|
| 83 | +REM Scroll it slowly: |
| 84 | +FOR n=1 TO 10 |
| 85 | +BLAttrWindowScrollUp (3,3,8,15) |
| 86 | +BLAttrWindowScrollUp (28,10,3,8) |
| 87 | +PAUSE 100 |
| 88 | +NEXT n |
| 89 | +``` |
0 commit comments