Skip to content

Commit 70dfbca

Browse files
committed
Add WindowsScrollUP library
1 parent 225b7fd commit 70dfbca

1 file changed

Lines changed: 162 additions & 0 deletions

File tree

docs/library/windowscrollup.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#WindowScrollUp
2+
3+
# BLWindowScrollUp.bas
4+
5+
This subroutine specified rectangle of screen and scrolls it 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 area
8+
and other information elsewhere - e.g. graphic adventures.
9+
10+
```
11+
SUB BLWindowScrollUp(X as uByte, Y as uByte, Width as uByte, Height as uByte)
12+
ASM
13+
;Routine for printing and scrolling text in any
14+
;window, anywhere on the screen.
15+
16+
;Main scrolling routine
17+
BLWindowScrollUp:
18+
EX AF, AF'
19+
LD A,(IX+11) ;(ROWS) Store # of Lines in A'
20+
EX AF,AF'
21+
22+
LD HL,BLWindowScrollUpScreenTable ;Start of address table
23+
LD C,(IX+7) ;(Y) Move the "pointer" to the
24+
LD B,0 ;appropriate position in the table
25+
ADD HL,BC ;and store it in (BLWindowScrollPOINT)
26+
ADD HL,BC
27+
LD (BLWindowScrollUpPOINT),HL ;Pointer position stored
28+
BLWindowScrollUpLOOP:
29+
30+
LD HL,(BLWindowScrollUpPOINT)
31+
LD E,(HL)
32+
INC HL
33+
LD D,(HL)
34+
35+
;Address of start of screen line now in DE
36+
LD A,(IX+5) ;(X)
37+
ADD A,E
38+
LD E,A
39+
40+
;Address of left-hand side of window now in DE
41+
EX AF,AF'
42+
DEC A
43+
JP Z,BLWindowScrollUpBLANK ;Quit this loop if we have
44+
EX AF,AF'
45+
INC HL ;Move the pointer to the next item
46+
LD (BLWindowScrollUpPOINT),HL ;in the table. Save position
47+
LD C,(HL)
48+
INC HL
49+
LD B,(HL) ;Start of next line down in BC
50+
LD L,(IX+5) ; (X)
51+
LD H,0
52+
ADD HL,BC
53+
;HL now points to the screen address 8 pixels below
54+
;the one held in DE
55+
LD B,8 ;8 pixel lines to be transferred
56+
;Now move 8 pixel lines up the screen by 8 pixels
57+
58+
BLWindowScrollUpTRANS:
59+
LD A,B ; Save B
60+
LD C,(IX+9) ;(Cols)
61+
LD B,0
62+
PUSH HL
63+
PUSH DE ;Save all registers
64+
LDIR ;Transfer the line of pixels
65+
POP DE
66+
POP HL
67+
68+
;Move HL and DE down one pixel
69+
INC D
70+
INC H
71+
72+
LD B,A ; Recover B
73+
74+
DJNZ BLWindowScrollUpTRANS
75+
;One line of characters has now been transferred
76+
77+
JP BLWindowScrollUpLOOP ;Back for next line of characters
78+
79+
;Scrolling finished. Now erase last character line
80+
BLWindowScrollUpBLANK:
81+
LD C,8
82+
LD L,(IX+9) ; (COLS)
83+
BLWindowScrollUpLOOP2:
84+
85+
PUSH DE
86+
LD B,L ;(IX+11) - Cols
87+
XOR A
88+
BLWindowScrollUpLOOP3:
89+
LD (DE),A
90+
INC E
91+
DJNZ BLWindowScrollUpLOOP3
92+
POP DE
93+
INC D
94+
DEC C
95+
JR NZ, BLWindowScrollUpLOOP2
96+
97+
;DJNZ BLWindowScrollUpLOOP2
98+
JP BLWindowScrollEnd
99+
100+
BLWindowScrollUpPOINT: DEFW 0
101+
102+
BLWindowScrollUpScreenTable:
103+
DEFW 16384
104+
DEFW 16416
105+
DEFW 16448
106+
DEFW 16480
107+
DEFW 16512
108+
DEFW 16544
109+
DEFW 16576
110+
DEFW 16608
111+
DEFW 18432
112+
DEFW 18464
113+
DEFW 18496
114+
DEFW 18528
115+
DEFW 18560
116+
DEFW 18592
117+
DEFW 18624
118+
DEFW 18656
119+
DEFW 20480
120+
DEFW 20512
121+
DEFW 20544
122+
DEFW 20576
123+
DEFW 20608
124+
DEFW 20640
125+
DEFW 20672
126+
DEFW 20704
127+
128+
BLWindowScrollEnd:
129+
END ASM
130+
END SUB
131+
```
132+
133+
## Usage
134+
```
135+
BLWindowScrollUp(TopLeftXCoordinate, TopLeftYCoordinate, WidthInCharacters, HeightInCharacters)
136+
```
137+
138+
The parameters are the X,Y print coordinates of the Top Left corner, width in characters, and height in characters.
139+
140+
Example in use:
141+
142+
```
143+
REM Quick routine to fill the screen with crap so we can demonstrate scrolling.
144+
SUB fillRubbish()
145+
ASM
146+
LD DE,16384
147+
LD HL,0
148+
LD BC,6144
149+
LDIR
150+
END ASM
151+
END SUB
152+
153+
fillRubbish() ' Fill the screen with stuff.
154+
155+
'actual use demo here:
156+
157+
FOR n=1 to 10
158+
BLWindowScrollUp(3,3,8,15)
159+
BLWindowScrollUp(28,10,3,8)
160+
PAUSE 10
161+
NEXT n
162+
```

0 commit comments

Comments
 (0)