Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request boriel-basic#648 from boriel/feature/make_scroll_t…
Browse files Browse the repository at this point in the history
…o_use_scrbuffer

feat: make scroll to use the srcbuffer
  • Loading branch information
boriel committed Jan 15, 2023
2 parents 53e7aa8 + fac6141 commit 8fff061
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 20 deletions.
22 changes: 21 additions & 1 deletion src/arch/zx48k/library/scroll.bas
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ sub fastcall ScrollRight(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

LOOP1:
push hl
Expand Down Expand Up @@ -123,6 +126,9 @@ sub fastcall ScrollLeft(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

LOOP1:
push hl
Expand Down Expand Up @@ -187,13 +193,18 @@ sub fastcall ScrollUp(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

ld a, d ; Num. of scan lines
ld b, 0
exx
ld b, a ; Scan lines counter
ex af, af' ; Recovers cols
ld c, a
jp LOOP_START

LOOP1:
exx
ld d, h
Expand All @@ -205,6 +216,8 @@ LOOP1:
pop hl
exx
ld a, c ; Recovers C Cols
LOCAL LOOP_START
LOOP_START:
djnz LOOP1

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

ld a, d ; Num. of scan lines
ld b, 0
exx
ld b, a ; Scan lines counter
ex af, af' ; Recovers cols
ld c, a
jp LOOP_START

LOOP1:
exx
ld d, h
Expand All @@ -283,6 +301,8 @@ LOOP1:
pop hl
exx
ld a, c ; Recovers C Cols
LOCAL LOOP_START
LOOP_START:
djnz LOOP1

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


#endif
#endif
27 changes: 18 additions & 9 deletions src/arch/zx48k/library/winscroll.bas
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ sub fastcall WinScrollRight(row as uByte, col as uByte, width as Ubyte, height a
push bc
ld a,b
and 18h
or 40h
ld h,a
ld a,b
and 07h
Expand All @@ -56,6 +55,8 @@ sub fastcall WinScrollRight(row as uByte, col as uByte, width as Ubyte, height a
add a,d
dec a
ld l,a ;HL=top-left window address in bitmap coord
ld bc, (SCREEN_ADDR)
add hl, bc
ld b,e

BucleChars:
Expand Down Expand Up @@ -100,8 +101,9 @@ BucleScans:
dec a
ld l,a
ld a,h
add a,58h
ld h,a ;HL=top-left window address in attr coord
ld bc, (SCREEN_ATTR_ADDR)
add hl, bc
ld b,e

BucleAttrs:
Expand Down Expand Up @@ -155,7 +157,6 @@ sub fastcall WinScrollLeft(row as uByte, col as uByte, width as Ubyte, height as
push bc
ld a,b
and 18h
or 40h
ld h,a
ld a,b
and 07h
Expand All @@ -166,6 +167,8 @@ sub fastcall WinScrollLeft(row as uByte, col as uByte, width as Ubyte, height as
add a,a
add a,c
ld l,a ;HL=top-left window address in bitmap coord
ld bc, (SCREEN_ADDR)
add hl, bc
ld b,e

BucleChars:
Expand Down Expand Up @@ -209,8 +212,9 @@ BucleScans:
add a,c
ld l,a
ld a,h
add a,58h
ld h,a ;HL=top-left address in attr coords
ld bc, (SCREEN_ATTR_ADDR)
add hl, bc
ld b,e

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

ld a,b
and 18h
or 40h
ld h,a
ld a,b
and 07h
Expand All @@ -277,6 +280,8 @@ sub fastcall WinScrollUp(row as uByte, col as uByte, width as Ubyte, height as U
add a,a
add a,c
ld l,a ;HL=top-left window address in bitmap coord
ld bc, (SCREEN_ADDR)
add hl, bc
ld a,e
ld c, d ; c = width
ld d, h
Expand Down Expand Up @@ -351,8 +356,9 @@ ScrollAttrs:
add a,c
ld l,a
ld a,h
add a,58h
ld h,a ;HL=top-left address in attr coords
ld bc, (SCREEN_ATTR_ADDR)
add hl, bc
ld b,e
dec b
ret z
Expand Down Expand Up @@ -414,7 +420,6 @@ sub fastcall WinScrollDown(row as uByte, col as uByte, width as Ubyte, height as

ld a,b
and 18h
or 40h
ld h,a
ld a,b
and 07h
Expand All @@ -425,6 +430,8 @@ sub fastcall WinScrollDown(row as uByte, col as uByte, width as Ubyte, height as
add a,a
add a,c
ld l,a ;HL=bottom-left window address in bitmap coord
ld bc, (SCREEN_ADDR)
add hl, bc
ld a,e
ld c, d ; c = width
ld d, h
Expand Down Expand Up @@ -499,8 +506,9 @@ ScrollAttrs:
add a,c
ld l,a
ld a,h
add a,58h
ld h,a ;HL=top-left address in attr coords
ld bc, (SCREEN_ATTR_ADDR)
add hl, bc
ld b,e
dec b
ret z
Expand Down Expand Up @@ -533,6 +541,7 @@ REM the following is required, because it defines screen start addr
#require "cls.asm"
#require "SP/PixelDown.asm"
#require "SP/PixelUp.asm"
#require "sysvars.asm"


#endif
#endif
22 changes: 21 additions & 1 deletion src/arch/zxnext/library/scroll.bas
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ sub fastcall ScrollRight(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

LOOP1:
push hl
Expand Down Expand Up @@ -123,6 +126,9 @@ sub fastcall ScrollLeft(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

LOOP1:
push hl
Expand Down Expand Up @@ -187,13 +193,18 @@ sub fastcall ScrollUp(x1 as uByte, y1 as uByte, x2 as Ubyte, y2 as Ubyte)
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0
ld bc, (SCREEN_ADDR)
add hl, bc ; Now current offset

ld a, d ; Num. of scan lines
ld b, 0
exx
ld b, a ; Scan lines counter
ex af, af' ; Recovers cols
ld c, a
jp LOOP_START

LOOP1:
exx
ld d, h
Expand All @@ -205,6 +216,8 @@ LOOP1:
pop hl
exx
ld a, c ; Recovers C Cols
LOCAL LOOP_START
LOOP_START:
djnz LOOP1

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

ld a, d ; Num. of scan lines
ld b, 0
exx
ld b, a ; Scan lines counter
ex af, af' ; Recovers cols
ld c, a
jp LOOP_START

LOOP1:
exx
ld d, h
Expand All @@ -283,6 +301,8 @@ LOOP1:
pop hl
exx
ld a, c ; Recovers C Cols
LOCAL LOOP_START
LOOP_START:
djnz LOOP1

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


#endif
#endif

0 comments on commit 8fff061

Please sign in to comment.