diff --git a/src/arch/zx48k/library/point.bas b/src/arch/zx48k/library/point.bas index 142e328a6..0568de015 100644 --- a/src/arch/zx48k/library/point.bas +++ b/src/arch/zx48k/library/point.bas @@ -24,7 +24,7 @@ REM Avoid recursive / multiple inclusion ' Returns: ' 1 if point is plot 0 otherwise (byte) ' ---------------------------------------------------------------- -function point(x as ubyte, y as ubyte) as byte +function fastcall point(x as ubyte, y as ubyte) as byte asm PROC @@ -35,8 +35,22 @@ function point(x as ubyte, y as ubyte) as byte PIXEL_ADDR EQU (22AAh + 6) ; ROM addrs which calculate screen addr - ld b, (ix+7) - ld c, (ix+5) + pop hl + ex (sp), hl ; callee => put RET address back. H = y + ld b, h + ld c, a + +#ifdef SCREEN_Y_OFFSET + ld a, SCREEN_Y_OFFSET + add a, b + ld b, a +#endif + +#ifdef SCREEN_X_OFFSET + ld a, SCREEN_X_OFFSET + add a, c + ld c, a +#endif ld a, 191 ; Max y value sub b diff --git a/src/arch/zx48k/library/sinclair.bas b/src/arch/zx48k/library/sinclair.bas index 436a6eadf..1243fa801 100644 --- a/src/arch/zx48k/library/sinclair.bas +++ b/src/arch/zx48k/library/sinclair.bas @@ -16,11 +16,17 @@ REM Avoid recursive / multiple inclusion REM This library includes other classic Sinclair ZX Spectrum Routines +REM Shift the screen 16 pixels UP to match that of the original BASIC +REM ... unless the user has specified otherwise + +#ifndef SCREEN_Y_OFFSET +# define SCREEN_Y_OFFSET 16 +#endif + #include once #include once #include once - REM This is not the original Sinclair INPUT, but better than nothing #include once @@ -30,11 +36,4 @@ REM This needed to initialize USR "a" to a memory heap space REM Now updates UDG system var to new UDG memory zone POKE Uinteger 23675, allocate(21 * 8) : REM 8 bytes per UDG (21 total) -REM Shift the screen 16 pixels UP to match that of the original BASIC -REM ... unless the user has specified otherwise -#ifndef SCREEN_Y_OFFSET -# define SCREEN_Y_OFFSET 16 #endif - -#endif - diff --git a/src/arch/zxnext/library/point.bas b/src/arch/zxnext/library/point.bas index 142e328a6..0568de015 100644 --- a/src/arch/zxnext/library/point.bas +++ b/src/arch/zxnext/library/point.bas @@ -24,7 +24,7 @@ REM Avoid recursive / multiple inclusion ' Returns: ' 1 if point is plot 0 otherwise (byte) ' ---------------------------------------------------------------- -function point(x as ubyte, y as ubyte) as byte +function fastcall point(x as ubyte, y as ubyte) as byte asm PROC @@ -35,8 +35,22 @@ function point(x as ubyte, y as ubyte) as byte PIXEL_ADDR EQU (22AAh + 6) ; ROM addrs which calculate screen addr - ld b, (ix+7) - ld c, (ix+5) + pop hl + ex (sp), hl ; callee => put RET address back. H = y + ld b, h + ld c, a + +#ifdef SCREEN_Y_OFFSET + ld a, SCREEN_Y_OFFSET + add a, b + ld b, a +#endif + +#ifdef SCREEN_X_OFFSET + ld a, SCREEN_X_OFFSET + add a, c + ld c, a +#endif ld a, 191 ; Max y value sub b diff --git a/src/arch/zxnext/library/sinclair.bas b/src/arch/zxnext/library/sinclair.bas index 436a6eadf..1243fa801 100644 --- a/src/arch/zxnext/library/sinclair.bas +++ b/src/arch/zxnext/library/sinclair.bas @@ -16,11 +16,17 @@ REM Avoid recursive / multiple inclusion REM This library includes other classic Sinclair ZX Spectrum Routines +REM Shift the screen 16 pixels UP to match that of the original BASIC +REM ... unless the user has specified otherwise + +#ifndef SCREEN_Y_OFFSET +# define SCREEN_Y_OFFSET 16 +#endif + #include once #include once #include once - REM This is not the original Sinclair INPUT, but better than nothing #include once @@ -30,11 +36,4 @@ REM This needed to initialize USR "a" to a memory heap space REM Now updates UDG system var to new UDG memory zone POKE Uinteger 23675, allocate(21 * 8) : REM 8 bytes per UDG (21 total) -REM Shift the screen 16 pixels UP to match that of the original BASIC -REM ... unless the user has specified otherwise -#ifndef SCREEN_Y_OFFSET -# define SCREEN_Y_OFFSET 16 #endif - -#endif - diff --git a/tests/runtime/cases/point.bas b/tests/runtime/cases/point.bas new file mode 100644 index 000000000..0990ed6f9 --- /dev/null +++ b/tests/runtime/cases/point.bas @@ -0,0 +1,14 @@ +#include "lib/tst_framework.bas" + +INIT("Testing SCREEN X,Y coords shift") + +#define SCREEN_Y_OFFSET 96 +#define SCREEN_X_OFFSET 127 + +#include + +PLOT 0, 0 +PLOT -20, 20 +PRINT POINT(0, 0); " "; POINT(-20, 20); " "; POINT(20, -20); " "; POINT(-20, -20) + +FINISH diff --git a/tests/runtime/expected/point.tzx.scr b/tests/runtime/expected/point.tzx.scr new file mode 100644 index 000000000..b1ebb52c3 Binary files /dev/null and b/tests/runtime/expected/point.tzx.scr differ diff --git a/tests/runtime/run b/tests/runtime/run index c69dce830..e12760df7 100755 --- a/tests/runtime/run +++ b/tests/runtime/run @@ -1,9 +1,8 @@ -#!/bin/bash + # vim:et:ts=4: RUN=$(basename -s .bas $1) rm -f "$RUN.tzx" killall fuse 2>/dev/null ../../zxbc.py -TaB $1 --debug-memory || exit 1 -fuse --auto-load --speed=19000 "$RUN.tzx" & - +fuse --auto-load --speed=19000 --machine=plus2 "$RUN.tzx" &