diff --git a/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm b/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm index d238a424d..21f9a4afc 100644 --- a/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm +++ b/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm @@ -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 @@ -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 \ No newline at end of file +#include once diff --git a/src/arch/zx48k/library-asm/SP/PixelDown.asm b/src/arch/zx48k/library-asm/SP/PixelDown.asm index 1b8522d08..3b5aaf62e 100644 --- a/src/arch/zx48k/library-asm/SP/PixelDown.asm +++ b/src/arch/zx48k/library-asm/SP/PixelDown.asm @@ -17,12 +17,18 @@ 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 @@ -30,17 +36,22 @@ SP.PixelDown: 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 \ No newline at end of file diff --git a/src/arch/zx48k/library-asm/SP/PixelLeft.asm b/src/arch/zx48k/library-asm/SP/PixelLeft.asm index f8a97f8c5..20be4e294 100644 --- a/src/arch/zx48k/library-asm/SP/PixelLeft.asm +++ b/src/arch/zx48k/library-asm/SP/PixelLeft.asm @@ -20,8 +20,17 @@ 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 @@ -29,7 +38,15 @@ SP.PixelLeft: 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 diff --git a/src/arch/zx48k/library-asm/SP/PixelRight.asm b/src/arch/zx48k/library-asm/SP/PixelRight.asm index c1e929619..5c0688e93 100644 --- a/src/arch/zx48k/library-asm/SP/PixelRight.asm +++ b/src/arch/zx48k/library-asm/SP/PixelRight.asm @@ -21,8 +21,17 @@ 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 @@ -30,7 +39,15 @@ SP.PixelRight: 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 diff --git a/src/arch/zx48k/library-asm/SP/PixelUp.asm b/src/arch/zx48k/library-asm/SP/PixelUp.asm index 0e353eab2..1657f9571 100644 --- a/src/arch/zx48k/library-asm/SP/PixelUp.asm +++ b/src/arch/zx48k/library-asm/SP/PixelUp.asm @@ -16,12 +16,20 @@ 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 @@ -29,17 +37,20 @@ SP.PixelUp: 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 diff --git a/src/arch/zx48k/library-asm/draw.asm b/src/arch/zx48k/library-asm/draw.asm index ea886171d..aea5b49a1 100644 --- a/src/arch/zx48k/library-asm/draw.asm +++ b/src/arch/zx48k/library-asm/draw.asm @@ -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 @@ -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 diff --git a/src/arch/zx48k/library-asm/draw3.asm b/src/arch/zx48k/library-asm/draw3.asm index 511be8f15..956acffb8 100644 --- a/src/arch/zx48k/library-asm/draw3.asm +++ b/src/arch/zx48k/library-asm/draw3.asm @@ -11,6 +11,7 @@ #include once #include once #include once +#include once ; Ripped from the ZX Spectrum ROM @@ -20,7 +21,6 @@ DRAW3: PROC LOCAL STACK_TO_BC LOCAL STACK_TO_A - LOCAL COORDS LOCAL L2477 LOCAL L2420 LOCAL L2439 @@ -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 @@ -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. @@ -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 @@ -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) @@ -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. @@ -456,7 +458,8 @@ 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. @@ -464,7 +467,7 @@ L245F: RST 28H ;; FP-CALC tx, ty, ax, ay. ; 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. @@ -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 diff --git a/src/arch/zx48k/library-asm/set_pixel_addr_attr.asm b/src/arch/zx48k/library-asm/set_pixel_addr_attr.asm index 0e95a4f94..383d027da 100644 --- a/src/arch/zx48k/library-asm/set_pixel_addr_attr.asm +++ b/src/arch/zx48k/library-asm/set_pixel_addr_attr.asm @@ -6,13 +6,16 @@ push namespace core ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca rrca and 3 - ld h, a + ld de, (SCREEN_ATTR_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 diff --git a/src/arch/zx48k/library/SP/Fill.bas b/src/arch/zx48k/library/SP/Fill.bas index 584f2d18e..ab1a4ea39 100644 --- a/src/arch/zx48k/library/SP/Fill.bas +++ b/src/arch/zx48k/library/SP/Fill.bas @@ -112,7 +112,6 @@ SPPFill: dec bc ; we will start with one struct in the queue push bc ; save max stack depth variable - ld a,h call SPGetScrnAddr ; de = screen address, b = pixel byte ex de,hl ; hl = screen address diff --git a/src/arch/zxnext/library-asm/SP/GetScrnAddr.asm b/src/arch/zxnext/library-asm/SP/GetScrnAddr.asm index d238a424d..21f9a4afc 100644 --- a/src/arch/zxnext/library-asm/SP/GetScrnAddr.asm +++ b/src/arch/zxnext/library-asm/SP/GetScrnAddr.asm @@ -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 @@ -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 \ No newline at end of file +#include once diff --git a/src/arch/zxnext/library-asm/SP/PixelDown.asm b/src/arch/zxnext/library-asm/SP/PixelDown.asm index 1b8522d08..3b5aaf62e 100644 --- a/src/arch/zxnext/library-asm/SP/PixelDown.asm +++ b/src/arch/zxnext/library-asm/SP/PixelDown.asm @@ -17,12 +17,18 @@ 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 @@ -30,17 +36,22 @@ SP.PixelDown: 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 \ No newline at end of file diff --git a/src/arch/zxnext/library-asm/SP/PixelLeft.asm b/src/arch/zxnext/library-asm/SP/PixelLeft.asm index f8a97f8c5..20be4e294 100644 --- a/src/arch/zxnext/library-asm/SP/PixelLeft.asm +++ b/src/arch/zxnext/library-asm/SP/PixelLeft.asm @@ -20,8 +20,17 @@ 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 @@ -29,7 +38,15 @@ SP.PixelLeft: 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 diff --git a/src/arch/zxnext/library-asm/SP/PixelRight.asm b/src/arch/zxnext/library-asm/SP/PixelRight.asm index c1e929619..5c0688e93 100644 --- a/src/arch/zxnext/library-asm/SP/PixelRight.asm +++ b/src/arch/zxnext/library-asm/SP/PixelRight.asm @@ -21,8 +21,17 @@ 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 @@ -30,7 +39,15 @@ SP.PixelRight: 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 diff --git a/src/arch/zxnext/library-asm/SP/PixelUp.asm b/src/arch/zxnext/library-asm/SP/PixelUp.asm index 0e353eab2..1657f9571 100644 --- a/src/arch/zxnext/library-asm/SP/PixelUp.asm +++ b/src/arch/zxnext/library-asm/SP/PixelUp.asm @@ -16,12 +16,20 @@ 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 @@ -29,17 +37,20 @@ SP.PixelUp: 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 diff --git a/src/arch/zxnext/library-asm/cls.asm b/src/arch/zxnext/library-asm/cls.asm index 7f9e773ec..21aab73c8 100644 --- a/src/arch/zxnext/library-asm/cls.asm +++ b/src/arch/zxnext/library-asm/cls.asm @@ -1,6 +1,5 @@ ;; Clears the user screen (24 rows) -#include once #include once push namespace core diff --git a/src/arch/zxnext/library-asm/draw.asm b/src/arch/zxnext/library-asm/draw.asm index ea886171d..aea5b49a1 100644 --- a/src/arch/zxnext/library-asm/draw.asm +++ b/src/arch/zxnext/library-asm/draw.asm @@ -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 @@ -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 diff --git a/src/arch/zxnext/library-asm/draw3.asm b/src/arch/zxnext/library-asm/draw3.asm index 511be8f15..956acffb8 100644 --- a/src/arch/zxnext/library-asm/draw3.asm +++ b/src/arch/zxnext/library-asm/draw3.asm @@ -11,6 +11,7 @@ #include once #include once #include once +#include once ; Ripped from the ZX Spectrum ROM @@ -20,7 +21,6 @@ DRAW3: PROC LOCAL STACK_TO_BC LOCAL STACK_TO_A - LOCAL COORDS LOCAL L2477 LOCAL L2420 LOCAL L2439 @@ -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 @@ -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. @@ -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 @@ -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) @@ -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. @@ -456,7 +458,8 @@ 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. @@ -464,7 +467,7 @@ L245F: RST 28H ;; FP-CALC tx, ty, ax, ay. ; 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. @@ -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 diff --git a/src/arch/zxnext/library-asm/modf.asm b/src/arch/zxnext/library-asm/modf.asm index 7ff2b2e94..d37965eb7 100644 --- a/src/arch/zxnext/library-asm/modf.asm +++ b/src/arch/zxnext/library-asm/modf.asm @@ -19,9 +19,9 @@ __MODF: ; MODULO rst 28h defb 01h ; EXCHANGE defb 32h ; MOD + defb 02h ; Discard (POP) defb 38h; ; END CALC jp __FPSTACK_POP pop namespace - diff --git a/src/arch/zxnext/library-asm/set_pixel_addr_attr.asm b/src/arch/zxnext/library-asm/set_pixel_addr_attr.asm index 0e95a4f94..383d027da 100644 --- a/src/arch/zxnext/library-asm/set_pixel_addr_attr.asm +++ b/src/arch/zxnext/library-asm/set_pixel_addr_attr.asm @@ -6,13 +6,16 @@ push namespace core ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca rrca and 3 - ld h, a + ld de, (SCREEN_ATTR_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 diff --git a/src/arch/zxnext/library-asm/strarraycpy.asm b/src/arch/zxnext/library-asm/strarraycpy.asm index 6ed8d80f0..aafc51426 100644 --- a/src/arch/zxnext/library-asm/strarraycpy.asm +++ b/src/arch/zxnext/library-asm/strarraycpy.asm @@ -19,7 +19,7 @@ STR_ARRAYCOPY: pop hl ; ret address pop bc ; num of elements pop de ; source array + offset to the 1st elem. - ex (sp), hl ; Calle -> hl = destiny array + offset to the 1st elem. + ex (sp), hl ; Callee -> hl = destiny array + offset to the 1st elem. ; FASTCALL ENTRY @@ -66,5 +66,3 @@ LOOP: ENDP pop namespace - - diff --git a/src/arch/zxnext/library/SP/Fill.bas b/src/arch/zxnext/library/SP/Fill.bas index 584f2d18e..3c979aee7 100644 --- a/src/arch/zxnext/library/SP/Fill.bas +++ b/src/arch/zxnext/library/SP/Fill.bas @@ -112,15 +112,9 @@ SPPFill: dec bc ; we will start with one struct in the queue push bc ; save max stack depth variable - ld a,h call SPGetScrnAddr ; de = screen address, b = pixel byte ex de,hl ; hl = screen address -; ld b, h -; ld c, l -; call 22B0h ; Uses ROM Pixel ADDR -; ld b, a - call bytefill ; b = fill byte jr c, viable pop bc diff --git a/tests/functional/zx48k/circle.asm b/tests/functional/zx48k/circle.asm index 7ab026e2c..bc174c562 100644 --- a/tests/functional/zx48k/circle.asm +++ b/tests/functional/zx48k/circle.asm @@ -292,6 +292,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca diff --git a/tests/functional/zx48k/draw.asm b/tests/functional/zx48k/draw.asm index 70c5724c2..9b95506c4 100644 --- a/tests/functional/zx48k/draw.asm +++ b/tests/functional/zx48k/draw.asm @@ -288,6 +288,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca @@ -316,12 +319,17 @@ SET_PIXEL_ADDR_ATTR: ; used : AF, HL 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 @@ -329,18 +337,20 @@ SP.PixelDown: 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 #line 15 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelUp.asm" @@ -359,12 +369,17 @@ SP.PixelDown: ; used : AF, HL 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 @@ -372,18 +387,17 @@ SP.PixelUp: 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 #line 16 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelLeft.asm" @@ -405,8 +419,14 @@ SP.PixelUp: ; used : AF, HL 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 @@ -414,7 +434,13 @@ SP.PixelLeft: 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 #line 17 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelRight.asm" @@ -436,8 +462,14 @@ SP.PixelLeft: ; used : AF, HL 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 @@ -445,7 +477,13 @@ SP.PixelRight: 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 #line 18 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" ;; DRAW PROCEDURE @@ -518,6 +556,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 inc b @@ -528,12 +567,14 @@ __PIXEL_MASK: rra 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 ld a, e sub c ; dx = X2 - X1 diff --git a/tests/functional/zx48k/draw3.asm b/tests/functional/zx48k/draw3.asm index 0226d2e1c..828939c1e 100644 --- a/tests/functional/zx48k/draw3.asm +++ b/tests/functional/zx48k/draw3.asm @@ -328,6 +328,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca @@ -459,12 +462,17 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ; used : AF, HL 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 @@ -472,18 +480,20 @@ SP.PixelDown: 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 #line 15 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelUp.asm" @@ -502,12 +512,17 @@ SP.PixelDown: ; used : AF, HL 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 @@ -515,18 +530,17 @@ SP.PixelUp: 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 #line 16 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelLeft.asm" @@ -548,8 +562,14 @@ SP.PixelUp: ; used : AF, HL 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 @@ -557,7 +577,13 @@ SP.PixelLeft: 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 #line 17 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelRight.asm" @@ -579,8 +605,14 @@ SP.PixelLeft: ; used : AF, HL 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 @@ -588,7 +620,13 @@ SP.PixelRight: 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 #line 18 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" ;; DRAW PROCEDURE @@ -661,6 +699,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 inc b @@ -671,12 +710,14 @@ __PIXEL_MASK: rra 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 ld a, e sub c ; dx = X2 - X1 @@ -856,7 +897,6 @@ DRAW3: PROC LOCAL STACK_TO_BC LOCAL STACK_TO_A - LOCAL COORDS LOCAL L2477 LOCAL L2420 LOCAL L2439 @@ -865,7 +905,6 @@ DRAW3: LOCAL L2D28 LOCAL SUM_C, SUM_B L2D28 EQU 02D28h - COORDS EQU 5C7Dh STACK_TO_BC EQU 2307h STACK_TO_A EQU 2314h exx @@ -1043,7 +1082,7 @@ L23C1: CALL 247Dh ; routine CD-PRMS1 CP $81 ; Compare to that for 1 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. PUSH BC ; Restore line counter to the machine stack. ; The parameters of the DRAW command were relative and they are now converted @@ -1083,7 +1122,8 @@ L23C1: CALL 247Dh ; routine CD-PRMS1 ; be set and the loop is always entered. The first test is superfluous and ; 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 JP L2439 ; forward to ARC-START ; -------------- @@ -1113,7 +1153,8 @@ L2420: DEC B ; decrement the arc count (4,8,12,16...). ; the last point plotted that are required to get to the current point and ; 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) @@ -1150,7 +1191,8 @@ L2425: RST 28H ;; FP-CALC ; coordinates required by the DRAW routine. ; 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. RST 28H ;; FP-CALC ax, ay. DEFB $C0 ;;st-mem-0 ax, ay. @@ -1195,20 +1237,21 @@ L2439: PUSH BC ; Preserve the arc counter on the machine stack. ; The moving absolute values of x and y are no longer required and they ; 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. DEFB $03 ;;subtract ty, rx. ; Next calculate the relative y coordinate to the end-point. 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 DEFB $03 ;;subtract rx, ry. diff --git a/tests/functional/zx48k/inktemp.asm b/tests/functional/zx48k/inktemp.asm index 98e8b78a1..81fc2e765 100644 --- a/tests/functional/zx48k/inktemp.asm +++ b/tests/functional/zx48k/inktemp.asm @@ -248,6 +248,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca @@ -543,12 +546,17 @@ __REFRESH_TMP: ; used : AF, HL 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 @@ -556,18 +564,20 @@ SP.PixelDown: 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 #line 15 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelUp.asm" @@ -586,12 +596,17 @@ SP.PixelDown: ; used : AF, HL 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 @@ -599,18 +614,17 @@ SP.PixelUp: 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 #line 16 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelLeft.asm" @@ -632,8 +646,14 @@ SP.PixelUp: ; used : AF, HL 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 @@ -641,7 +661,13 @@ SP.PixelLeft: 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 #line 17 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelRight.asm" @@ -663,8 +689,14 @@ SP.PixelLeft: ; used : AF, HL 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 @@ -672,7 +704,13 @@ SP.PixelRight: 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 #line 18 "/zxbasic/src/arch/zx48k/library-asm/draw.asm" ;; DRAW PROCEDURE @@ -745,6 +783,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 inc b @@ -755,12 +794,14 @@ __PIXEL_MASK: rra 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 ld a, e sub c ; dx = X2 - X1 diff --git a/tests/functional/zx48k/plot.asm b/tests/functional/zx48k/plot.asm index 604241d90..9f105ed12 100644 --- a/tests/functional/zx48k/plot.asm +++ b/tests/functional/zx48k/plot.asm @@ -390,6 +390,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca diff --git a/tests/functional/zx48k/spfill.asm b/tests/functional/zx48k/spfill.asm index 7da992acf..c1a2797e5 100644 --- a/tests/functional/zx48k/spfill.asm +++ b/tests/functional/zx48k/spfill.asm @@ -86,7 +86,6 @@ SPPFill: push de dec bc push bc - ld a,h call SPGetScrnAddr ex de,hl call bytefill @@ -386,7 +385,7 @@ SPPFill_end: LD IX,(SPPFill_IXBuffer) ENDP pop namespace -#line 542 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 541 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" _SPFill__leave: ret .LABEL.__LABEL0: @@ -443,7 +442,7 @@ SP.CharLeft: ; ccf ; ret ; ENDIF -#line 550 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 549 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/CharRight.asm" ; ; CharRight @@ -489,29 +488,28 @@ SP.CharRight: ; ccf ; ret ; ENDIF -#line 551 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 550 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm" ; ; GetScrnAddr ; 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 @@ -539,56 +537,40 @@ 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 -#line 552 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sysvars.asm" + ;; ----------------------------------------------------------------------- + ;; ZX Basic System Vars + ;; Some of them will be mapped over Sinclair ROM ones for compatibility + ;; ----------------------------------------------------------------------- + push namespace core +SCREEN_ADDR: DW 16384 ; Screen address (can be pointed to other place to use a screen buffer) +SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.) + ; These are mapped onto ZX Spectrum ROM VARS + CHARS EQU 23606 ; Pointer to ROM/RAM Charset + TVFLAGS EQU 23612 ; TV Flags + UDG EQU 23675 ; Pointer to UDG Charset + COORDS EQU 23677 ; Last PLOT coordinates + FLAGS2 EQU 23681 ; + ECHO_E EQU 23682 ; + DFCC EQU 23684 ; Next screen addr for PRINT + DFCCL EQU 23686 ; Next screen attr for PRINT + S_POSN EQU 23688 + ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands + ATTR_T EQU 23695 ; temporary ATTRIBUTES + P_FLAG EQU 23697 ; + MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars + SCR_COLS EQU 33 ; Screen with in columns + 1 + SCR_ROWS EQU 24 ; Screen height in rows + SCR_SIZE EQU (SCR_ROWS << 8) + SCR_COLS + pop namespace +#line 63 "/zxbasic/src/arch/zx48k/library-asm/SP/GetScrnAddr.asm" +#line 551 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelDown.asm" ; ; PixelDown @@ -606,12 +588,17 @@ norotate: ; used : AF, HL 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 @@ -619,20 +606,22 @@ SP.PixelDown: 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 -#line 553 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 552 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/SP/PixelUp.asm" ; ; PixelUp @@ -649,12 +638,17 @@ SP.PixelDown: ; used : AF, HL 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 @@ -662,20 +656,19 @@ SP.PixelUp: 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 -#line 554 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 553 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/circle.asm" ; Bresenham's like circle algorithm ; best known as Middle Point Circle drawing algorithm @@ -721,33 +714,6 @@ __STOP: ; X in top of the stack #line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" -#line 1 "/zxbasic/src/arch/zx48k/library-asm/sysvars.asm" - ;; ----------------------------------------------------------------------- - ;; ZX Basic System Vars - ;; Some of them will be mapped over Sinclair ROM ones for compatibility - ;; ----------------------------------------------------------------------- - push namespace core -SCREEN_ADDR: DW 16384 ; Screen address (can be pointed to other place to use a screen buffer) -SCREEN_ATTR_ADDR: DW 22528 ; Screen attribute address (ditto.) - ; These are mapped onto ZX Spectrum ROM VARS - CHARS EQU 23606 ; Pointer to ROM/RAM Charset - TVFLAGS EQU 23612 ; TV Flags - UDG EQU 23675 ; Pointer to UDG Charset - COORDS EQU 23677 ; Last PLOT coordinates - FLAGS2 EQU 23681 ; - ECHO_E EQU 23682 ; - DFCC EQU 23684 ; Next screen addr for PRINT - DFCCL EQU 23686 ; Next screen attr for PRINT - S_POSN EQU 23688 - ATTR_P EQU 23693 ; Current Permanent ATTRS set with INK, PAPER, etc commands - ATTR_T EQU 23695 ; temporary ATTRIBUTES - P_FLAG EQU 23697 ; - MEM0 EQU 23698 ; Temporary memory buffer used by ROM chars - SCR_COLS EQU 33 ; Screen with in columns + 1 - SCR_ROWS EQU 24 ; Screen height in rows - SCR_SIZE EQU (SCR_ROWS << 8) + SCR_COLS - pop namespace -#line 2 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" #line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: @@ -864,6 +830,9 @@ __OUT_OF_SCREEN_ERR: ; HL contains the address in RAM for a given pixel (not a coordinate) SET_PIXEL_ADDR_ATTR: ;; gets ATTR position with offset given in SCREEN_ADDR + ld de, (SCREEN_ADDR) + or a + sbc hl, de ld a, h rrca rrca @@ -1104,7 +1073,7 @@ __CIRCLE_PLOT: ret ENDP pop namespace -#line 555 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 554 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ;; Clears the user screen (24 rows) push namespace core @@ -1135,7 +1104,7 @@ CLS: ret ENDP pop namespace -#line 556 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 555 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" #line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" push namespace core @@ -1166,7 +1135,7 @@ __REFRESH_TMP: ret ENDP pop namespace -#line 557 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 556 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/pause.asm" ; The PAUSE statement (Calling the ROM) push namespace core @@ -1175,7 +1144,7 @@ __PAUSE: ld c, l jp 1F3Dh ; PAUSE_1 pop namespace -#line 558 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 557 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" #line 1 "/zxbasic/src/arch/zx48k/library-asm/usr_str.asm" ; This function just returns the address of the UDG of the given str. ; If the str is EMPTY or not a letter, 0 is returned and ERR_NR set @@ -1499,5 +1468,5 @@ USR_ERROR: ret ENDP pop namespace -#line 559 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" +#line 558 "/zxbasic/src/arch/zx48k/library/SP/Fill.bas" END