Login
Back to forumReply to this topicGo to last reply

Posted By

Andrea
on 2020-08-04
15:37:46
 Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello to all user's PLUS4 WORLD,

Here uder I have put a basic list for C= Commodore 16, but when I do RUN, the
programm does not work, I think that it have need of memory with CLR, and
perharps of the POKE, that I not know. Can you help me, please??

10 SCNCLR:REM PULISCE SCHERMO
20 COLOR0,1:REM COLORE SFONDO
30 COLOR4,1:REM COLORE BORDO
40 COLOR1,15:REM COLORE TESTO
50 GOSUB470
60 X=5:Y=10
70 C=3:L=4
80 REM C=COLORE CARATTERE
90 REM L=LUMINANZA COLORE
100 PRINT"score"
110 PRINT"{home}{down}";SC
120 REM METTE OGGETTI
130 FORC=1TO20
140 XD=INT(RND(5)*40+1)
150 YD=INT(RND(8)*20+1)
160 POKE3072+XD+40*YD,1
170 POKE2048+XD+40*YD,09+7*16
180 NEXTC
190 POKE3072+X+40*Y,0
200 POKE2048+X+40*Y,C+L*16
210 GETKEYK$
220 IFK$="Z"THENGOSUB300:X=X-1
230 IFK$="X"THENGOSUB340:X=X+1
240 IFK$="K"THENGOSUB380:Y=Y-1
250 IFK$="M"THENGOSUB420:Y=Y+1
260 IFK$=CHR$(27)THENEND
270 POKE3072+X+40*Y,0
280 POKE2048+X+40*Y,C+L*16
290 GOTO210
300 XC=X:YC=Y:XC=XC-1
305 IFX<1THENX=X+1:RETURN210
310 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:PRINT"{home}
{down}";SC
320 POKE3072+X+40*Y,32
330 RETURN
340 XC=X:YC=Y:XC=XC+1
345 IFX>1THENX=X-1:RETURN210
350 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:PRINT"{home}
{down}";SC
360 POKE3072+X+40*Y,32
370 RETURN
380 XC=X:YC=Y:YC=YC-1
385 IFY<1THENY=Y+1:RETURN210
390 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:PRINT"{home}
{down}";SC
400 POKE3072+X+40*Y,32
410 RETURN
420 XC=X:YC=Y:YC=YC+1
425 IFY>39THENY=Y+1:RETURN210
430 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:PRINT"{home}
{down}";SC
440 POKE3072+X+40*Y,32
450 RETURN
460 REM DEFINIZIONE CARATTERE PETSCII
470 RESTORE550
480 FORA=832TO849
490 READB:POKEA,B:NEXTA:SYS832
500 RESTORE570:FORA=14336TO14336+39
510 READB:POKEA,B:NEXTA
520 POKE65298,PEEK(65298)AND251
530 POKE65299,PEEK(65299)AND30OR56
540 RETURN
550 DATA 162,0,189,0,208,157,0,56,189,0
560 DATA 209,157,0,57,202,208,241,96
570 DATA 28,28,8,62,93,28,20,54
580 DATA 126,60,126,126,255,255,255,126
590 DATA 60,66,165,153,153,165,66,60
600 DATA 0,56,124,254,254,124,56,16
610 DATA 60,126,219,255,126,102,60,0


I wait your good news
Best Regards
Andre Gasparrini from Italy

Posted By

George
on 2020-08-04
16:13:37
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

I am not sure, but this {home} {down} are not ment to be written like this out, but this could be actual keystrokes on the c16 when typing the listing....

Posted By

Andrea
on 2020-08-04
16:29:52
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello,

I have tried to do this:

POKE55,240:POKE56,55:CLR

it could to be do well??

Posted By

Mad
on 2020-08-04
16:43:18
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

I just tried to import it into Yape.

It produced error at all lines with
PRINT"stuff";SC
when replacing it with
PRINT"stuff"SC
the error is gone. So removing the semicolon helps (but a "stuff",SC also does work)

then it does print the score. I am no Basic crack at all, just tried to import the lines.. Perhaps that ; is only a problem on my machine..
Btw. In Yape a right mouse click can paste the whole file from the clipboard.

EDIT: George has a working listing.. Seems like the ";" is a different character in yours and in Georges listing :)

Posted By

George
on 2020-08-04
16:56:25
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hi Andrea,

use CBM prg Studio: http://www.ajordison.co.uk/

10 SCNCLR:REM PULISCE SCHERMO
20 COLOR0,1:REM COLORE SFONDO
30 COLOR4,1:REM COLORE BORDO
40 COLOR1,15:REM COLORE TESTO
50 GOSUB470
60 X=5:Y=10
70 C=3:L=4
80 REM C=COLORE CARATTERE
90 REM L=LUMINANZA COLORE
100 PRINT"score"
110 char,0,1,str$(sc)
120 REM METTE OGGETTI
130 FORC=1TO20
140 XD=INT(RND(5)*40+1)
150 YD=INT(RND(8)*20+1)
160 POKE3072+XD+40*YD,1
170 POKE2048+XD+40*YD,09+7*16
180 NEXTC
190 POKE3072+X+40*Y,0
200 POKE2048+X+40*Y,C+L*16
210 GETKEYK$
220 IFK$="Z"THENGOSUB300:X=X-1
230 IFK$="X"THENGOSUB340:X=X+1
240 IFK$="K"THENGOSUB380:Y=Y-1
250 IFK$="M"THENGOSUB420:Y=Y+1
260 IFK$=CHR$(27)THENEND
270 POKE3072+X+40*Y,0
280 POKE2048+X+40*Y,C+L*16
290 GOTO210
300 XC=X:YC=Y:XC=XC-1
305 IFX<1THENX=X+1:RETURN210
310 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:char,0,1,str$(sc)
320 POKE3072+X+40*Y,32
330 RETURN
340 XC=X:YC=Y:XC=XC+1
345 IFX>1THENX=X-1:RETURN210
350 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:char,0,1,str$(sc)
360 POKE3072+X+40*Y,32
370 RETURN
380 XC=X:YC=Y:YC=YC-1
385 IFY<1THENY=Y+1:RETURN210
390 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:char,0,1,str$(sc)
400 POKE3072+X+40*Y,32
410 RETURN
420 XC=X:YC=Y:YC=YC+1
425 IFY>39THENY=Y+1:RETURN210
430 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:char,0,1,str$(sc)
440 POKE3072+X+40*Y,32
450 RETURN
460 REM DEFINIZIONE CARATTERE PETSCII
470 RESTORE550
480 FORA=832TO849
490 READB:POKEA,B:NEXTA:SYS832
500 RESTORE570:FORA=14336TO14336+39
510 READB:POKEA,B:NEXTA
520 POKE65298,PEEK(65298)AND251
530 POKE65299,PEEK(65299)AND30OR56
540 RETURN
550 DATA 162,0,189,0,208,157,0,56,189,0
560 DATA 209,157,0,57,202,208,241,96
570 DATA 28,28,8,62,93,28,20,54
580 DATA 126,60,126,126,255,255,255,126
590 DATA 60,66,165,153,153,165,66,60
600 DATA 0,56,124,254,254,124,56,16
610 DATA 60,126,219,255,126,102,60,0

Edit: Lines 310, 350, 390, 430 were briken to the next line. If you just copy& paste Adreas code, the emulator assumes a commando instead of a codeline (no linenumber in front)

edit 2: Replace
PRINT"{home}{down}";SC
wirh
char,0,1,str$(sc)

Posted By

Verona
on 2020-08-04
17:24:02
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

The new code. And yes, {home} means the home button pressed in " mode.

I made some improvements in the subroutines, and added some basic time counting function.

10 SCNCLR:REM PULISCE SCHERMO
20 COLOR0,1:REM COLORE SFONDO
30 COLOR4,1:REM COLORE BORDO
40 COLOR1,15:REM COLORE TESTO
50 GOSUB470
60 X=5:Y=10
70 C=3:L=4
80 REM C=COLORE CARATTERE
90 REM L=LUMINANZA COLORE
100 PRINT"score"
110 PRINT"{home}{down}";SC
120 REM METTE OGGETTI
130 FORCC=1TO20
140 XD=INT(RND(5)*38+1)
150 YD=INT(RND(8)*20+1)
160 POKE3072+XD+40*YD,1
170 POKE2048+XD+40*YD,09+7*16
180 NEXTCC:TK=0
190 POKE3072+X+40*Y,0
200 POKE2048+X+40*Y,C+L*16
210 GETK$:TK=TK+1
220 IFK$="z"THENGOSUB300
230 IFK$="x"THENGOSUB340
240 IFK$="k"THENGOSUB380
250 IFK$="m"THENGOSUB420
260 IFK$=CHR$(27)THENEND
265 IFCO=20THENPRINT"{home}end score: time:";TK;"{home}{down}";SC:END
270 POKE3072+X+40*Y,0
280 POKE2048+X+40*Y,C+L*16
290 GOTO210
300 IFX<2THENRETURN210
305 X=X-1
310 IFPEEK(3072+X+40*Y)=1THENSC=SC+100:PRINT"{home}{down}";SC:CO=CO+1
320 POKE3072+X+1+40*Y,32
330 RETURN
340 IFX>38THENRETURN210
345 X=X+1
350 IFPEEK(3072+X+40*Y)=1THENSC=SC+100:PRINT"{home}{down}";SC:CO=CO+1
360 POKE3072+X-1+40*Y,32
370 RETURN
380 IFY<3THENRETURN210
385 Y=Y-1
390 IFPEEK(3072+X+40*Y)=1THENSC=SC+100:PRINT"{home}{down}";SC:CO=CO+1
400 POKE3072+X+40*(Y+1),32
410 RETURN
420 IFY>23THENRETURN210
425 Y=Y+1
430 IFPEEK(3072+X+40*Y)=1THENSC=SC+100:PRINT"{home}{down}";SC:CO=CO+1
440 POKE3072+X+40*(Y-1),32
450 RETURN
460 REM DEFINIZIONE CARATTERE PETSCII
470 RESTORE550
480 FORA=832TO849
490 READB:POKEA,B:NEXTA:SYS832
500 RESTORE570:FORA=14336TO14336+39
510 READB:POKEA,B:NEXTA
520 POKE65298,PEEK(65298)AND251
530 POKE65299,PEEK(65299)AND30OR56
540 RETURN
550 DATA 162,0,189,0,208,157,0,56,189,0
560 DATA 209,157,0,57,202,208,241,96
570 DATA 28,28,8,62,93,28,20,54
580 DATA 126,60,126,126,255,255,255,126
590 DATA 60,66,165,153,153,165,66,60
600 DATA 0,56,124,254,254,124,56,16
610 DATA 60,126,219,255,126,102,60,0

Posted By

Andrea
on 2020-08-05
01:09:15
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello to all Users's plus4,

I have fixed lines with CHAR,0,1,STR$(SC) and add line 20 for INIT RAM MAPPER,
but I don't know if I well done.

The line 20 need for do space in RAM for numerical variables in theory.
Correct me if I'm wrong.

10 REM INIT RAM MAPPER
20 POKE55,240:POKE56,55:CLR
30 SCNCLR:REM PULISCE SCHERMO
40 COLOR0,1:REM COLORE SFONDO
50 COLOR4,1:REM COLORE BORDO
60 COLOR1,15:REM COLORE TESTO
70 GOSUB530
80 X=5:Y=10
90 C=3:L=4:SC=0
100 REM C=COLORE CARATTERE
110 REM L=LUMINANZA COLORE
120 PRINT"SCORE"
130 CHAR,0,1,STR$(SC)
140 REM METTE OGGETTI
150 FORC=1TO20
160 XD=INT(RND(5)*40+1)
170 YD=INT(RND(8)*20+1)
180 POKE3072+XD+40*YD,1
190 POKE2048+XD+40*YD,09+7*16
200 NEXTC
210 POKE3072+X+40*Y,0
220 POKE2048+X+40*Y,C+L*16
230 GETKEYK$
240 IFK$="Z"THENGOSUB320:X=X-1
250 IFK$="X"THENGOSUB370:X=X+1
260 IFK$="K"THENGOSUB420:Y=Y-1
270 IFK$="M"THENGOSUB470:Y=Y+1
280 IFK$=CHR$(27)THENEND
290 POKE3072+X+40*Y,0
300 POKE2048+X+40*Y,C+L*16
310 GOTO230
320 XC=X:YC=Y:XC=XC-1
330 IFX<1THENX=X+1:RETURN210
340 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:CHAR,0,1,STR$(SC)
350 POKE3072+X+40*Y,32
360 RETURN
370 XC=X:YC=Y:XC=XC+1
380 IFX>38THENX=X-1:RETURN210
390 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:CHAR,0,1,STR$(SC)
400 POKE3072+X+40*Y,32
410 RETURN
420 XC=X:YC=Y:YC=YC-1
430 IFY<3THENY=Y+1:RETURN210
440 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:CHAR,0,1,STR$(SC)
450 POKE3072+X+40*Y,32
460 RETURN
470 XC=X:YC=Y:YC=YC+1
480 IFY>23THENY=Y-1:RETURN210
490 IFPEEK(3072+XC+40*YC)=1THENSC=SC+100:CHAR,0,1,STR$(SC)
500 POKE3072+X+40*Y,32
510 RETURN
520 REM DEFINIZIONE CARATTERE PETSCII
530 RESTORE610
540 FORA=832TO849
550 READB:POKEA,B:NEXTA:SYS832
560 RESTORE630:FORA=14336TO14336+39
570 READB:POKEA,B:NEXTA
580 POKE65298,PEEK(65298)AND251
590 POKE65299,PEEK(65299)AND30OR56
600 RETURN
610 DATA 162,0,189,0,208,157,0,56,189,0
620 DATA 209,157,0,57,202,208,241,96
630 DATA 28,28,8,62,93,28,20,54
640 DATA 126,60,126,126,255,255,255,126
650 DATA 60,66,165,153,153,165,66,60
660 DATA 0,56,124,254,254,124,56,16
670 DATA 60,126,219,255,126,102,60,0

Posted By

Csabo
on 2020-08-05
08:57:33
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Heh, I got this in an email this morning, fixed it and replied... Only to find out the forum has already fixed it as well happy

Posted By

Andrea
on 2020-08-05
09:25:46
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Can I to use those pokes and. CLR for have more memory at the variables numeric in RAM ??

POKE55,240:POKE56,55:CLR

Posted By

Verona
on 2020-08-05
10:22:42
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

If you need, then use the FRE(0) command in the code, it deploys a garbage collection and free some RAM.
I used it repeatedly in the Evader (Kerülő) and it worked.

Like this:

230 FRE(0):GETK$

Posted By

Andrea
on 2020-08-05
12:25:27
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello Verona,

Are you from Verona city italy?

I need not to see memory free RAM wth command FRE(0), then know already, but I need
of set to have more memory on numeric variables.

I hope there is some expert user:

POKE55,240:POKE56,55:CLR

Posted By

Verona
on 2020-08-06
00:24:02
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

No, I am a Hungarian. happy But I liked that word. (And name. And I like the Italian culture.)

That pair of command is set $37F0 to the top of memory used by BASIC. ( Default is $4000, so actually, that will do no good. ) The STREND pointer is at POKE49 and POKE50 it is also the free memory's start adress, and here's the string memory's bottom (FRETOP) at POKE 51-52, variable's start address is at POKE 45-46.

Maybe it helps. But nowadays I am only coding in assembly. Much better.

FRE(0) is triggering garbage collection, this frees some unused RAM. It's not equals with PRINT FRE(0)!!! If you use variables with much calculations, you need this!

Likely, if you take out all of the FRE(0) commands from my BASIC game, Kerülő (Evader), the game will crash after a while. With that, it works, I didn't use POKEs, like these.

Dont use that POKEs of yours on a C16, rather integrate just this into your code and try it.

230 FRE(0):GETK$

Posted By

Andrea
on 2020-08-06
12:25:57
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello Verona,

Okey, I will use this:

230 FRE(0):GETK$

Therefore I can to use of the POKES with address: POKE51,byte:POKE52,byte and
POKE45,byte:POKE46,byte for expansion memory mapper variables numeric?
if I will use very variables numeric ??

See you later and thank you very much
(^_^)
Andrea

Posted By

Andrea
on 2020-08-06
12:34:29
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Hello Verona,

Listen!!!:

I tried to do 230 FRE(0):GETK$ but not work!! The BASIC C=16 he gives me ERROR !!
To this point, what type of POKE I must put? Or It has need of a routine in code machine??

See you later & Thank again
(^_^)
Andrea

Posted By

Verona
on 2020-08-07
05:51:11
 Re: Problem to the BASIC listing, probably putting memory space to numeric variables with CLR

Try this:

POKE51,240:POKE52,55:POKE55,240:POKE56,55:CLR

This sets the free memory's top to $37F0 as well.

Here's the working prg:

https://drive.google.com/file/d/1-A50bTxmFqVE01ZeGPPI80x8TtCyjtW9/view?usp=sharing



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024