How To Test the screen memory...(The DF_CC Vs D_FILE)

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

How To Test the screen memory...(The DF_CC Vs D_FILE)

Post by XavSnap »

Hi,

There's not functions to get a byte from the screen memory on the Zx81.
You had to define an array and get the mirrored value in it.
I code an example where the ZX81 Basic don't use a mirrored value.
I tryed to optimize the code to speed up our lazy Basic Rom.
In the first example, i use the Rom pointer refreshed by the PRINT AT command.
The DF_CC is set while a "AT y,x" Rom call.
It retrieve the memory pointer at D_File+( 33*Y+X ).
The secound program retrive this value, using the D_File address.
Have Fun.
Note: "((" "+(USR 743))(TO 1))" equal the Fast command.
You had to add and display a blank space to avoid to print the BC call back.
PRINT "***";USR 743;"***"
> ***12763***
PRINT "***";(" "+(USR 743)));"***"
> *** 12763***
PRINT "***";(" "+(USR 743))(TO 1));"***"
> *** ***
But, A "1 FAST" take only 6 Bytes ...
a (" "+(USR 743))(TO 1)) take 30 Bytes !

Code: Select all

1 REM EXEMPLE 1 - DF/CC
2 PRINT AT 5,4;((" "+(USR 743))(TO 1));"LLLLLLLLLLLLLLL"
3 FOR A=1 TO 15
4 PRINT  TAB 5;"L             L"
5 PRINT AT 5+A,6+INT(RND*13);(STR$ A AND A<8)
6 NEXT A
7 PRINT AT 20,5;"LLLLLLLLLLLLLLL"
8 SLOW
9 PRINT AT 2,1;"1234567"
10 LET X=15
20 LET Y=15
30 LET A=X
40 LET B=Y
45 LET X=A-(INKEY$="7")+(INKEY$="6")
48 LET Y=B-(INKEY$="5")+(INKEY$="8")
50 PRINT AT X,Y;
60 IF PEEK(PEEK 16398+256*PEEK 16399) THEN GOTO 100
65 PRINT "O";AT A,B;" "
80 GOTO 30
100 LET C$=CHR$ PEEK(PEEK 16398+256*PEEK 16399)
110 IF C$="L" THEN GOTO 45
120 IF C$>"0" AND C$<"8" THEN PRINT AT 2,VAL C$;CHR$ (CODE C$+128)
130 PRINT AT X,Y;
199 GOTO 65

Code: Select all

1 REM EXEMPLE 2 - D/FILE
2 PRINT AT 5,4;((" "+(USR 743))(TO 1));"LLLLLLLLLLLLLLL"
3 FOR A=1 TO 15
4 PRINT  TAB 5;"L             L"
5 PRINT AT 5+A,6+INT(RND*13);(STR$ A AND A<8)
6 NEXT A
7 PRINT AT 20,5;"LLLLLLLLLLLLLLL"
8 SLOW
9 PRINT AT 2,1;"1234567"
10 LET X=15
20 LET Y=15
30 LET DF=PEEK 16396+(256*PEEK 16397)+Y*33+X+1
42 REM
45 LET DFB=DF-(INKEY$="7")*33+(INKEY$="6")*33-(INKEY$="5")+(INKEY$="8")
50 REM
60 IF PEEK(DFB) THEN GOTO 100
61 POKE DF,0
62 POKE DFB,CODE "O"
65 LET DF=DFB
80 GOTO 45
100 LET C$=CHR$ PEEK DFB
110 IF C$="L" THEN GOTO 45
120 IF C$>"0" AND C$<"8" THEN PRINT AT 2,VAL C$;CHR$ (CODE C$+128)
199 GOTO 61
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: How To Test the screen memory...(The DF_CC Vs D_FILE)

Post by Shaun_B »

I've noticed this example but it doesn't seem to like line 2 - it's calling the FAST routine, so I took it out and did this instead:

Code: Select all

2 PRINT USR 743;USR 2602;AT 0,0;" ";AT 5,4;"LLLLLLLLLLLLLLL"
Regards,

Shaun.
gozzo
Posts: 452
Joined: Fri Jul 08, 2011 8:52 pm

Re: How To Test the screen memory...(The DF_CC Vs D_FILE)

Post by gozzo »

I'm not surprised it didn't like line 2, you were trying to add a numeric value returned by the USR call to a string, without converting it, or converting the string to a number or character code!!! And why call the FAST routine by a USR instead of FAST directly?
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: How To Test the screen memory...(The DF_CC Vs D_FILE)

Post by Shaun_B »

gozzo wrote:I'm not surprised it didn't like line 2, you were trying to add a numeric value returned by the USR call to a string, without converting it, or converting the string to a number or character code!!! And why call the FAST routine by a USR instead of FAST directly?
It seems that nobody tested the listings until I did or the issue would have been picked up quicker. As for calling ROM functions in a PRINT statement, the only reason really is to produce fewer lines of BASIC; I don't suppose it's any quicker. My personal preference is usually for fewer lines where possible.

Here's my version of this listing (does more or less the same thing):

Code: Select all

  1 PRINT AT 20,5;"LLLLLLLLLLLLLLL";AT 5,5;"LLLLLLLLLLLLLLL"
  2 FOR I=1 TO 14
  3 PRINT TAB 5;"L             L"
  4 PRINT AT 5+I,6+INT (RND*13);(STR$ INT (RND*10))
  5 NEXT I
  6 PRINT AT 2,1;"0123456789"
  7 LET X=15
  8 LET Y=X
  9 LET D=PEEK 16396+(256*PEEK 16397)+Y*33+X+1
 10 LET M=D-(INKEY$="7")*33+(INKEY$="6")*33-(INKEY$="5")+(INKEY$="8")
 11 IF PEEK M THEN GOTO 100
 12 POKE D,0
 13 POKE M,CODE "O"
 14 LET D=M
 15 GOTO 10
100 LET C$=CHR$ PEEK M
101 IF C$="L" THEN GOTO 10
102 IF C$>="0" AND C$<="9" THEN PRINT AT 2,VAL C$+1;CHR$ (CODE C$+128)
103 GOTO 12
Regards,

Shaun.
poglad
Posts: 133
Joined: Mon Mar 24, 2014 3:11 pm
Location: Aberdeen, Scotland

Re: How To Test the screen memory...(The DF_CC Vs D_FILE)

Post by poglad »

I don't feel that the obfuscated style of coding really shows the ZX81 at its best, but to each their own!
Post Reply