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
20 changes: 17 additions & 3 deletions src/arch/zx48k/library/point.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions src/arch/zx48k/library/sinclair.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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 <attr.bas>
#include once <point.bas>
#include once <screen.bas>


REM This is not the original Sinclair INPUT, but better than nothing
#include once <input.bas>

Expand All @@ -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

20 changes: 17 additions & 3 deletions src/arch/zxnext/library/point.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions src/arch/zxnext/library/sinclair.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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 <attr.bas>
#include once <point.bas>
#include once <screen.bas>


REM This is not the original Sinclair INPUT, but better than nothing
#include once <input.bas>

Expand All @@ -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

14 changes: 14 additions & 0 deletions tests/runtime/cases/point.bas
Original file line number Diff line number Diff line change
@@ -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 <point.bas>

PLOT 0, 0
PLOT -20, 20
PRINT POINT(0, 0); " "; POINT(-20, 20); " "; POINT(20, -20); " "; POINT(-20, -20)

FINISH
Binary file added tests/runtime/expected/point.tzx.scr
Binary file not shown.
5 changes: 2 additions & 3 deletions tests/runtime/run
Original file line number Diff line number Diff line change
@@ -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" &