Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 9 additions & 57 deletions src/arch/zx48k/library-asm/SP/GetScrnAddr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@
; Alvin Albrecht 2002
;

;INCLUDE "SPconfig.def"
;XLIB SPGetScrnAddr

; Get Screen Address
;
; Computes the screen address given a valid pixel coordinate.
; (0,0) is located at the top left corner of the screen.
;
; enter: a = h = y coord
; enter: h = y coord
; l = x coord
; In hi-res mode, Carry is most significant bit of x coord (0..511 pixels)
; exit : de = screen address, b = pixel mask
; uses : af, b, de, hl

;IF !DISP_HIRES

push namespace core
PROC
LOCAL rotloop, norotate

SPGetScrnAddr:
ld a,h
and $07
or $40
ld d,a
ld a,h
rra
Expand Down Expand Up @@ -54,57 +51,12 @@ norotate:
and $e0
or l
ld e,a
ld hl, (SCREEN_ADDR)
add hl, de
ex de, hl
ret

ENDP
pop namespace


;ELSE
;
;.SPGetScrnAddr
; ld b,0
; ld d,b
; rr l
; rl b
; srl l
; rl b
; srl l
; rl b
; srl l
; jr nc, notodd
; ld d,$20
;
;.notodd
; ld a,b
; or a
; ld a,$80
; jr z, norotate
;
;.rotloop
; rra
; djnz rotloop

;.norotate
; ld b,a
; ld a,h
; and $07
; or $40
; or d
; ld d,a
; ld a,h
; rra
; rra
; rra
; and $18
; or d
; ld d,a
;
; ld a,h
; rla
; rla
; and $e0
; or l
; ld e,a
; ret

;ENDIF
#include once <sysvars.asm>
31 changes: 21 additions & 10 deletions src/arch/zx48k/library-asm/SP/PixelDown.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,41 @@
push namespace core

SP.PixelDown:
PROC
LOCAL leave

push de
ld de, (SCREEN_ADDR)
or a
sbc hl, de
inc h
ld a,h
and $07
ret nz
ex af, af' ; Sets carry on F'
scf ; which flags ATTR must be updated
jr nz, leave
scf ; Sets carry on F', which flags ATTR must be updated
ex af, af'
ld a,h
sub $08
ld h,a
ld a,l
add a,$20
ld l,a
ret nc
jr nc, leave
ld a,h
add a,$08
ld h,a
;IF DISP_HIRES
; and $18
; cp $18
;ELSE
cp $58
;ENDIF
cp $19 ; carry = 0 => Out of screen
jr c, leave ; returns if out of screen
ccf
pop de
ret

leave:
add hl, de ; This always sets Carry = 0
pop de
ret

ENDP
pop namespace

#include once <sysvars.asm>
19 changes: 18 additions & 1 deletion src/arch/zx48k/library-asm/SP/PixelLeft.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,33 @@
push namespace core

SP.PixelLeft:
PROC

LOCAL leave

push de
ld de, (SCREEN_ADDR)
or a
sbc hl, de ; This always sets Carry = 0

rlca ; Sets new pixel bit 1 to the right
ret nc
jr nc, leave
ex af, af' ; Signal in C' we've moved off current ATTR cell
ld a,l
dec a
ld l,a
cp 32 ; Carry if in screen
ccf
ld a, 1

leave: ; Sets screen offset back again
push af
add hl, de
pop af
pop de
ret

ENDP
pop namespace

#include once <sysvars.asm>
19 changes: 18 additions & 1 deletion src/arch/zx48k/library-asm/SP/PixelRight.asm
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,33 @@
push namespace core

SP.PixelRight:
PROC

LOCAL leave

push de
ld de, (SCREEN_ADDR)
or a
sbc hl, de ; This always sets Carry = 0

rrca ; Sets new pixel bit 1 to the right
ret nc
jr nc, leave
ex af, af' ; Signal in C' we've moved off current ATTR cell
ld a, l
inc a
ld l, a
cp 32 ; Carry if IN screen
ccf
ld a, 80h

leave: ; Sets screen offset back again
push af
add hl, de
pop af
pop de
ret

ENDP
pop namespace

#include once <sysvars.asm>
33 changes: 22 additions & 11 deletions src/arch/zx48k/library-asm/SP/PixelUp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,41 @@
push namespace core

SP.PixelUp:
PROC

LOCAL leave

push de
ld de, (SCREEN_ADDR)
or a
sbc hl, de

ld a,h
dec h
and $07
ret nz
ex af, af'
scf
jr nz, leave
scf ; sets C' to 1 (ATTR update needed)
ex af, af'
ld a,$08
add a,h
ld h,a
ld a,l
sub $20
ld l,a
ret nc
jr nc, leave
ld a,h
sub $08
ld h,a
;IF DISP_HIRES
; and $18
; cp $18
; ccf
;ELSE
cp $40
;ENDIF

leave:
push af
add hl, de
pop af
pop de
ret

ENDP

pop namespace

#include once <sysvars.asm>
6 changes: 5 additions & 1 deletion src/arch/zx48k/library-asm/draw.asm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ __DRAW_START:
LOCAL __PIXEL_ADDR
__PIXEL_ADDR EQU 22ACh
call __PIXEL_ADDR
res 6, h ; Starts from 0 offset

;; Now gets pixel mask in A register
ld b, a
Expand All @@ -112,12 +113,15 @@ __PIXEL_MASK:
djnz __PIXEL_MASK

ld b, d ; Restores B' from D'
ld de, (SCREEN_ADDR)
add hl, de
pop de ; D'E' = y2, x2
exx ; At this point: D'E' = y2,x2 coords
; B'C' = y1, y1 coords
; H'L' = Screen Address of pixel

ex af, af' ; Saves A reg for later
; A' = Pixel mask
; H'L' = Screen Address of pixel

ld bc, (COORDS) ; B,C = y1, x1

Expand Down
21 changes: 12 additions & 9 deletions src/arch/zx48k/library-asm/draw3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include once <plot.asm>
#include once <stackf.asm>
#include once <draw.asm>
#include once <sysvars.asm>

; Ripped from the ZX Spectrum ROM

Expand All @@ -20,7 +21,6 @@ DRAW3:
PROC
LOCAL STACK_TO_BC
LOCAL STACK_TO_A
LOCAL COORDS
LOCAL L2477
LOCAL L2420
LOCAL L2439
Expand All @@ -30,7 +30,6 @@ DRAW3:
LOCAL SUM_C, SUM_B

L2D28 EQU 02D28h
COORDS EQU 5C7Dh
STACK_TO_BC EQU 2307h
STACK_TO_A EQU 2314h

Expand Down Expand Up @@ -262,7 +261,7 @@ L23C1: CALL 247Dh ; routine CD-PRMS1
POP BC ; Balance the machine stack

JP C,L2477 ; forward, if the coordinates of first line
; don't add up to more than 1, to LINE-DRAW
; don't add up to more than 1, to LINE-DRAW

; Continue when the arc will have a discernable shape.

Expand Down Expand Up @@ -319,7 +318,8 @@ L23C1: CALL 247Dh ; routine CD-PRMS1
; the jump will always be made to ARC-START.

;; DRW-STEPS
L2420: DEC B ; decrement the arc count (4,8,12,16...).
L2420:
DEC B ; decrement the arc count (4,8,12,16...).

;JR Z,L245F ; forward, if zero (not possible), to ARC-END

Expand Down Expand Up @@ -353,7 +353,8 @@ L2420: DEC B ; decrement the arc count (4,8,12,16...).
; the formula returns the next relative coordinates to use.

;; ARC-LOOP
L2425: RST 28H ;; FP-CALC
L2425:
RST 28H ;; FP-CALC
DEFB $E1 ;;get-mem-1 rx.
DEFB $31 ;;duplicate rx, rx.
DEFB $E3 ;;get-mem-3 cos(a)
Expand Down Expand Up @@ -394,7 +395,8 @@ L2425: RST 28H ;; FP-CALC
; The mid entry point.

;; ARC-START
L2439: PUSH BC ; Preserve the arc counter on the machine stack.
L2439:
PUSH BC ; Preserve the arc counter on the machine stack.

; Store the absolute ay in temporary variable mem-0 for the moment.

Expand Down Expand Up @@ -456,15 +458,16 @@ L2439: PUSH BC ; Preserve the arc counter on the machine stack.
; can be deleted to expose the closing coordinates.

;; ARC-END
L245F: RST 28H ;; FP-CALC tx, ty, ax, ay.
L245F:
RST 28H ;; FP-CALC tx, ty, ax, ay.
DEFB $02 ;;delete tx, ty, ax.
DEFB $02 ;;delete tx, ty.
DEFB $01 ;;exchange ty, tx.
DEFB $38 ;;end-calc ty, tx.

; First calculate the relative x coordinate to the end-point.

LD A,($5C7D) ; COORDS-x
LD A,(COORDS) ; COORDS-x
CALL L2D28 ; routine STACK-A

RST 28H ;; FP-CALC ty, tx, coords_x.
Expand All @@ -475,7 +478,7 @@ L245F: RST 28H ;; FP-CALC tx, ty, ax, ay.
DEFB $01 ;;exchange rx, ty.
DEFB $38 ;;end-calc rx, ty.

LD A,($5C7E) ; COORDS-y
LD A,(COORDS + 1) ; COORDS-y
CALL L2D28 ; routine STACK-A

RST 28H ;; FP-CALC rx, ty, coords_y
Expand Down
Loading