Skip to content

Commit 8fff061

Browse files
authored
Merge pull request #648 from boriel/feature/make_scroll_to_use_scrbuffer
feat: make scroll to use the srcbuffer
2 parents 53e7aa8 + fac6141 commit 8fff061

4 files changed

Lines changed: 78 additions & 20 deletions

File tree

src/arch/zx48k/library/scroll.bas

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ sub fastcall ScrollRight(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
5858
LOCAL __PIXEL_ADDR
5959
__PIXEL_ADDR EQU 22ACh
6060
call __PIXEL_ADDR
61+
res 6, h ; Starts from 0
62+
ld bc, (SCREEN_ADDR)
63+
add hl, bc ; Now current offset
6164

6265
LOOP1:
6366
push hl
@@ -123,6 +126,9 @@ sub fastcall ScrollLeft(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
123126
LOCAL __PIXEL_ADDR
124127
__PIXEL_ADDR EQU 22ACh
125128
call __PIXEL_ADDR
129+
res 6, h ; Starts from 0
130+
ld bc, (SCREEN_ADDR)
131+
add hl, bc ; Now current offset
126132

127133
LOOP1:
128134
push hl
@@ -187,13 +193,18 @@ sub fastcall ScrollUp(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
187193
LOCAL __PIXEL_ADDR
188194
__PIXEL_ADDR EQU 22ACh
189195
call __PIXEL_ADDR
196+
res 6, h ; Starts from 0
197+
ld bc, (SCREEN_ADDR)
198+
add hl, bc ; Now current offset
190199

191200
ld a, d ; Num. of scan lines
192201
ld b, 0
193202
exx
194203
ld b, a ; Scan lines counter
195204
ex af, af' ; Recovers cols
196205
ld c, a
206+
jp LOOP_START
207+
197208
LOOP1:
198209
exx
199210
ld d, h
@@ -205,6 +216,8 @@ LOOP1:
205216
pop hl
206217
exx
207218
ld a, c ; Recovers C Cols
219+
LOCAL LOOP_START
220+
LOOP_START:
208221
djnz LOOP1
209222

210223
; Clears bottom line
@@ -265,13 +278,18 @@ sub fastcall ScrollDown(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
265278
LOCAL __PIXEL_ADDR
266279
__PIXEL_ADDR EQU 22ACh
267280
call __PIXEL_ADDR
281+
res 6, h ; Starts from 0
282+
ld bc, (SCREEN_ADDR)
283+
add hl, bc ; Now current offset
268284

269285
ld a, d ; Num. of scan lines
270286
ld b, 0
271287
exx
272288
ld b, a ; Scan lines counter
273289
ex af, af' ; Recovers cols
274290
ld c, a
291+
jp LOOP_START
292+
275293
LOOP1:
276294
exx
277295
ld d, h
@@ -283,6 +301,8 @@ LOOP1:
283301
pop hl
284302
exx
285303
ld a, c ; Recovers C Cols
304+
LOCAL LOOP_START
305+
LOOP_START:
286306
djnz LOOP1
287307

288308
; Clears top line
@@ -310,4 +330,4 @@ REM the following is required, because it defines screen start addr
310330
#require "SP/PixelUp.asm"
311331

312332

313-
#endif
333+
#endif

src/arch/zx48k/library/winscroll.bas

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ sub fastcall WinScrollRight(row as uByte, col as uByte, width as Ubyte, height a
4343
push bc
4444
ld a,b
4545
and 18h
46-
or 40h
4746
ld h,a
4847
ld a,b
4948
and 07h
@@ -56,6 +55,8 @@ sub fastcall WinScrollRight(row as uByte, col as uByte, width as Ubyte, height a
5655
add a,d
5756
dec a
5857
ld l,a ;HL=top-left window address in bitmap coord
58+
ld bc, (SCREEN_ADDR)
59+
add hl, bc
5960
ld b,e
6061

6162
BucleChars:
@@ -100,8 +101,9 @@ BucleScans:
100101
dec a
101102
ld l,a
102103
ld a,h
103-
add a,58h
104104
ld h,a ;HL=top-left window address in attr coord
105+
ld bc, (SCREEN_ATTR_ADDR)
106+
add hl, bc
105107
ld b,e
106108

107109
BucleAttrs:
@@ -155,7 +157,6 @@ sub fastcall WinScrollLeft(row as uByte, col as uByte, width as Ubyte, height as
155157
push bc
156158
ld a,b
157159
and 18h
158-
or 40h
159160
ld h,a
160161
ld a,b
161162
and 07h
@@ -166,6 +167,8 @@ sub fastcall WinScrollLeft(row as uByte, col as uByte, width as Ubyte, height as
166167
add a,a
167168
add a,c
168169
ld l,a ;HL=top-left window address in bitmap coord
170+
ld bc, (SCREEN_ADDR)
171+
add hl, bc
169172
ld b,e
170173

171174
BucleChars:
@@ -209,8 +212,9 @@ BucleScans:
209212
add a,c
210213
ld l,a
211214
ld a,h
212-
add a,58h
213215
ld h,a ;HL=top-left address in attr coords
216+
ld bc, (SCREEN_ATTR_ADDR)
217+
add hl, bc
214218
ld b,e
215219

216220
BucleAttrs:
@@ -266,7 +270,6 @@ sub fastcall WinScrollUp(row as uByte, col as uByte, width as Ubyte, height as U
266270

267271
ld a,b
268272
and 18h
269-
or 40h
270273
ld h,a
271274
ld a,b
272275
and 07h
@@ -277,6 +280,8 @@ sub fastcall WinScrollUp(row as uByte, col as uByte, width as Ubyte, height as U
277280
add a,a
278281
add a,c
279282
ld l,a ;HL=top-left window address in bitmap coord
283+
ld bc, (SCREEN_ADDR)
284+
add hl, bc
280285
ld a,e
281286
ld c, d ; c = width
282287
ld d, h
@@ -351,8 +356,9 @@ ScrollAttrs:
351356
add a,c
352357
ld l,a
353358
ld a,h
354-
add a,58h
355359
ld h,a ;HL=top-left address in attr coords
360+
ld bc, (SCREEN_ATTR_ADDR)
361+
add hl, bc
356362
ld b,e
357363
dec b
358364
ret z
@@ -414,7 +420,6 @@ sub fastcall WinScrollDown(row as uByte, col as uByte, width as Ubyte, height as
414420

415421
ld a,b
416422
and 18h
417-
or 40h
418423
ld h,a
419424
ld a,b
420425
and 07h
@@ -425,6 +430,8 @@ sub fastcall WinScrollDown(row as uByte, col as uByte, width as Ubyte, height as
425430
add a,a
426431
add a,c
427432
ld l,a ;HL=bottom-left window address in bitmap coord
433+
ld bc, (SCREEN_ADDR)
434+
add hl, bc
428435
ld a,e
429436
ld c, d ; c = width
430437
ld d, h
@@ -499,8 +506,9 @@ ScrollAttrs:
499506
add a,c
500507
ld l,a
501508
ld a,h
502-
add a,58h
503509
ld h,a ;HL=top-left address in attr coords
510+
ld bc, (SCREEN_ATTR_ADDR)
511+
add hl, bc
504512
ld b,e
505513
dec b
506514
ret z
@@ -533,6 +541,7 @@ REM the following is required, because it defines screen start addr
533541
#require "cls.asm"
534542
#require "SP/PixelDown.asm"
535543
#require "SP/PixelUp.asm"
544+
#require "sysvars.asm"
536545

537546

538-
#endif
547+
#endif

src/arch/zxnext/library/scroll.bas

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ sub fastcall ScrollRight(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
5858
LOCAL __PIXEL_ADDR
5959
__PIXEL_ADDR EQU 22ACh
6060
call __PIXEL_ADDR
61+
res 6, h ; Starts from 0
62+
ld bc, (SCREEN_ADDR)
63+
add hl, bc ; Now current offset
6164

6265
LOOP1:
6366
push hl
@@ -123,6 +126,9 @@ sub fastcall ScrollLeft(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
123126
LOCAL __PIXEL_ADDR
124127
__PIXEL_ADDR EQU 22ACh
125128
call __PIXEL_ADDR
129+
res 6, h ; Starts from 0
130+
ld bc, (SCREEN_ADDR)
131+
add hl, bc ; Now current offset
126132

127133
LOOP1:
128134
push hl
@@ -187,13 +193,18 @@ sub fastcall ScrollUp(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
187193
LOCAL __PIXEL_ADDR
188194
__PIXEL_ADDR EQU 22ACh
189195
call __PIXEL_ADDR
196+
res 6, h ; Starts from 0
197+
ld bc, (SCREEN_ADDR)
198+
add hl, bc ; Now current offset
190199

191200
ld a, d ; Num. of scan lines
192201
ld b, 0
193202
exx
194203
ld b, a ; Scan lines counter
195204
ex af, af' ; Recovers cols
196205
ld c, a
206+
jp LOOP_START
207+
197208
LOOP1:
198209
exx
199210
ld d, h
@@ -205,6 +216,8 @@ LOOP1:
205216
pop hl
206217
exx
207218
ld a, c ; Recovers C Cols
219+
LOCAL LOOP_START
220+
LOOP_START:
208221
djnz LOOP1
209222

210223
; Clears bottom line
@@ -265,13 +278,18 @@ sub fastcall ScrollDown(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
265278
LOCAL __PIXEL_ADDR
266279
__PIXEL_ADDR EQU 22ACh
267280
call __PIXEL_ADDR
281+
res 6, h ; Starts from 0
282+
ld bc, (SCREEN_ADDR)
283+
add hl, bc ; Now current offset
268284

269285
ld a, d ; Num. of scan lines
270286
ld b, 0
271287
exx
272288
ld b, a ; Scan lines counter
273289
ex af, af' ; Recovers cols
274290
ld c, a
291+
jp LOOP_START
292+
275293
LOOP1:
276294
exx
277295
ld d, h
@@ -283,6 +301,8 @@ LOOP1:
283301
pop hl
284302
exx
285303
ld a, c ; Recovers C Cols
304+
LOCAL LOOP_START
305+
LOOP_START:
286306
djnz LOOP1
287307

288308
; Clears top line
@@ -310,4 +330,4 @@ REM the following is required, because it defines screen start addr
310330
#require "SP/PixelUp.asm"
311331

312332

313-
#endif
333+
#endif

0 commit comments

Comments
 (0)