News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

BASIC programming tips

Started by arnoldemu, 14:23, 22 May 09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Manuel3D

thanks for your answer. I thought there might be a simple way that I didn't know about but I see that the solution is not easy. I have tried to put the image and call it from basic with a &call BB18 but as soon as I touch a letter on the keyboard the image disappears from the screen making its use impossible. I have seen on the internet that it can also be done using a library to program games from basic called 8BP. I have to find out more about the subject.


BSC

Let's see, if my memory still works well enough then this might do the trick if you have the image as a raw screen dump:

10 memory &3fff
20 load "[name of your image here]",&4000
30 for i=0 to 11:read k:poke &af00+i,k:next:end
40 data &21,0,&40,&11,0,&c0,1,&ff,&3f,&ed,&b0,&c9
50 call &af00

Then, after running the listing once, you can do GOTO 50 whenever you need to restore the image.
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

Manuel3D

#152
Your idea works. Now I will have to adapt the program a little to reduce the memory used since it had already reached a good size but I think it can work  thanks to your help.

:)

McArti0

BUT WHY ASM?  ;D   OUT &BC00,12:OUT &BD00,&10: POKE &b7c6,&40

Manuel3D. Have you read PM?

Maybe write this in a new topic.

You can use two screens to draw.
Visible when you set POKE b7c6,&C0
or invisible when you set POKE &b7c6,&40.
In this case you need to limit BASIC to 16kB by MEMORY &3FFF.
With these settings you can draw twice. Once you draw on the background in the visible part. Once on the invisible part where there is no background.
If you want to see the invisible screen, you do OUT &BC00,12:OUT &BD00,&10.
If you want to see the main screen again, you do OUT &BC00,12:OUT &BD00,&30
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Jean-Marie

You can use the firmware for this:
CALL &BC06,&40
then
CALL &BC06,&C0

Manuel3D

#155
Thank you McArti0 and Jean-Mary I will try this too.

Manuel3D

Quote from: Manuel3D on 21:02, 17 October 23Thank you McArti0 and Jean-Mary I will try this too.
Sorry because I'm also new to this forum and I'm not used to how it works yet. Now for example, I wanted to quote you and it didn't work out. On the other hand, I see that this page works very slowly for me and often hangs and loads automatically.

skylas

Hi all!

If i remember well there was a command in BASIC for screen shaking.
Do I remember correct? I could not find it although I looked at the manual
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET!, PENALTY KICKS!, CAPITAL QUIZ!, CAPITAL QUIZ 2! (Reverse edition), HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ), HEART CHASER 1,2,3!, BARBOUTI!, STROOPIE!, AMSTABOO!
TEXT ADVENTURES:
BUDRUMI!, ART WAR!, BATTLE OF LENINGRAD!, RODOLFO SKYLARRIENTE 1 and 2!


skylas

Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET!, PENALTY KICKS!, CAPITAL QUIZ!, CAPITAL QUIZ 2! (Reverse edition), HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ), HEART CHASER 1,2,3!, BARBOUTI!, STROOPIE!, AMSTABOO!
TEXT ADVENTURES:
BUDRUMI!, ART WAR!, BATTLE OF LENINGRAD!, RODOLFO SKYLARRIENTE 1 and 2!

BSC

Quote from: Manuel3D on 01:14, 17 October 23Your idea works. Now I will have to adapt the program a little to reduce the memory used since it had already reached a good size but I think it can work  thanks to your help.

:)
If you are short on memory, you can change that little listing so that the screen is loaded to &6000 instead of &4000. I guess you can figure out what you have to change by yourself. Homework time! :D
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

dodogildo

Here's a PDF of an ages old book with Peeks and Pokes and other tips on Basic. Still holds tons of useful information.
(PEEKS et POKES du CPC - 1985)
https://shorturl.at/pCIM9
M'enfin!

Manuel3D

Hola! Os dejo aquí enlace a un programa hecho en Basic por mi hace muchos años, a finales de los 80. Es el típico juego del Ahorcado. Está escrito todo en Basic y cuenta con más de 600 palabras para adivinar. Espero que alguno le sirva para pasar un rato entretenido. 
El Ahorcado para AMSTRAD CPC by manuel3d (itch.io)

Hello! I leave you here a link to a program made in Basic by me many years ago, at the end of the 80s. It is the typical Hangman game (in spanish language) . It is all written in Basic and has more than 600 words to guess. I hope some of it helps you have a fun time.

skylas

Quote from: Manuel3D on 12:31, 02 December 23Hola! Os dejo aquí enlace a un programa hecho en Basic por mi hace muchos años, a finales de los 80. Es el típico juego del Ahorcado. Está escrito todo en Basic y cuenta con más de 600 palabras para adivinar. Espero que alguno le sirva para pasar un rato entretenido.
El Ahorcado para AMSTRAD CPC by manuel3d (itch.io)

Hello! I leave you here a link to a program made in Basic by me many years ago, at the end of the 80s. It is the typical Hangman game (in spanish language) . It is all written in Basic and has more than 600 words to guess. I hope some of it helps you have a fun time.
really nice, although I dont know spanish! I tried it! congrats!!!
Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET!, PENALTY KICKS!, CAPITAL QUIZ!, CAPITAL QUIZ 2! (Reverse edition), HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ), HEART CHASER 1,2,3!, BARBOUTI!, STROOPIE!, AMSTABOO!
TEXT ADVENTURES:
BUDRUMI!, ART WAR!, BATTLE OF LENINGRAD!, RODOLFO SKYLARRIENTE 1 and 2!

skylas

#164
Quote from: Manuel3D on 23:46, 14 October 23explanation to my previous message.....
I am making a program in Basic Locomotive for Amstrad CPC to draw with the plot and draw commands in a simple way by moving the cursor around the screen. The fact is that if I want to copy a drawing that I like from the Internet, I have to print it, paste  on the Amstrad screen with tape and move the cursor to draw the lines necessary to convert that drawing to the lines format of the Amstrad Basic. .(it is a primitive method like when a child draws on a TV screen by sticking a piece of paper on the TV screen) It would be much easier if I converted that image to screen format with a program like CovImgcpc and loaded that image as the background of my Amstrad screen and I run the program over it and draw like someone who copies a drawing by pasting a piece of paper on the computer screen. I don't know if it is possible to do this in Amstrad Basic. I have tried and I can't, but I'm sure there is a way that I don't know about.
Not sure if I understood correctly what you want to do.

10 load"a.scr"
20 gosub 100
30 a$=inkey$
40 goto 30
100 draw whatever you want on the image
110 return
So your program will be on 100

Web: https://amstradsakis.blogspot.com
Twitter: https://twitter.com/AmstradSakis
My programs (only BASIC):
RETRO-LOADSHEET!, PENALTY KICKS!, CAPITAL QUIZ!, CAPITAL QUIZ 2! (Reverse edition), HEADS OR TAILS (ΚΟΡΩΝΑ/ΓΡΑΜΜΑΤΑ), HEART CHASER 1,2,3!, BARBOUTI!, STROOPIE!, AMSTABOO!
TEXT ADVENTURES:
BUDRUMI!, ART WAR!, BATTLE OF LENINGRAD!, RODOLFO SKYLARRIENTE 1 and 2!

mv

#165
Quote from: Manuel3D on 12:31, 02 December 23Hola! Os dejo aquí enlace a un programa hecho en Basic por mi hace muchos años, a finales de los 80. Es el típico juego del Ahorcado. Está escrito todo en Basic y cuenta con más de 600 palabras para adivinar. Espero que alguno le sirva para pasar un rato entretenido.
El Ahorcado para AMSTRAD CPC by manuel3d (itch.io)
Hello! I leave you here a link to a program made in Basic by me many years ago, at the end of the 80s. It is the typical Hangman game (in spanish language) . It is all written in Basic and has more than 600 words to guess. I hope some of it helps you have a fun time.
Nice program but I don't know Spanish either.
I tried it with CPCBasicTS and was wondering why all the text was flickering. I found an issue in my implementation while running the code...

35 MODE 2
45 INK 1,26:PEN 1:INK 2,2
46 BORDER 2:PAPER 2

PAPER 2 in line 46 is actually PAPER 0 since there are just 2 colors in MODE 2.


And it seems that there are some transfer/encoding issues in DATA lines. Some words contain "MERGE", which I think should be ñ (or n):
1130 DATA circunferencia,circulo,pestaMERGEa,windsurf,...
And in my attempts to get a fixed word, I replaced INT(624*RND)+1 with INT(624*1)+1 in line 550 and got the word "EL AHORCADO". After a few attempts to type in space, I realized that this is the title of the program. Yes, there is a small chance of getting the title if the RND is >= 0.999.

lmimmfn

Quote from: ZbyniuR on 11:15, 17 January 16Half of games on CPC is using narrow font 4x8 in 4 colors in MODE 0, quite often with horizontal stripes or antialiasing with pixels in different color on corners.
To do that just type  MODE 1:CALL &BD1C  of course you have to prepare right font because original it that case look terrible. :)
Similar way is possible to made 80 column with narrow font in MODE 1.
Just type  MODE 2:CALL &BD1C,1    Font for this mode have to be different than to previous mode. In character's matrix 8x8 left half defines color 1, right half defines color 2, like this: 11112222. If the same pixel is on, on both halves that mean color 3.

If both halves look exactly the same then  POKE 46895 change color of pen, but this is mask not color, so: 240=color1, 15=2, 255=3, 0=0. Others values makes vertical stripes. Next byte do it the same with PAPER. :)
I mean those POKEs work in 6128, cause in 464 this address is 45711.
If both halves look different proper value is 255 or just type PEN 3. Copy cursor work only in thats case.

In 40 column in MODE 0, font and colors are more complicated. In sign matrix  first half with first color and second are mixed like this: 11221122. PEN and PAPER from 0 to 3 you can change like in normal MODE 1. Others colors you can choose by POKE like above, but value for color 0 to 15 are: 0, 192, 12, 204, 48, 240, 60, 252, 3, 195, 15, 207, 51, 243, 63, 255. Others values makes vertical stripes. :)

To change between those 2 different narrow font 11112222 and 11221122 you have do with each byte of this font:
b=PEEK(a):POKE a,(b AND 195)+(b AND 48)/4+(b AND 12)*4

One more thing. If you planning use colorful font in graphics mode TAG as sprite, you have to move left-right by whole byte, or prepare least 2 version for mode 0 or least 4 version for mode 1. In other case will be look disaster. ;)

Try program NARROW.BAS  type CONT to look next trick. ;)  80IN3COL.BAS is funny too. Program 0.BAS can show fonts.
I remember back in the day when i had a lot of free time lol, i used to run Call in a for loop from around &BB00 up to see what would happen. It would crash the CPC and i would start again from where it crashed, anything interesting visually i would take note of and ended up with CALL &BD1C which would allow me to create 16 colour graphics with Symbol After.
Those were the days :)
6128 for the win!!!

Manuel3D

Hello!  I want to share with you a Basic Font Letter  made by me in Basic Locomotive many years ago. I leave you the link in case it may be useful to you. Link...  New Letter Font for AMSTRAD CPC by manuel3d (itch.io)

McArti0

change hardware video mode 0,1,2,3

dim m(1): rem optional
m(0)=-0.424773783:m(1)=-0.394236058

call @m(0),0

call @m(0),1

call @m(0),2

call @m(0),3
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

ZorrO

CPC+PSX 4ever

McArti0

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

ZorrO

Maybe on BBC, but it doesn't work on CPC.
CPC+PSX 4ever

McArti0

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

McArti0

#173
PRINT REM line as POINTER to STRING
1 REM First Line....................0123456789......................Const73chars
2 REM Second Line....................0123456789.....................Const73chars
10 t$=""
15 ln%=2:f%=1:l%=23:GOSUB 100:REM ln% - number rem Line, l% - length string, f% - first char.
20 end
100 a%=&176+&50*(ln%-1)+(f%-1):at%=@t$:POKE at%,l%:POKE at%+1,PEEK(@a%):POKE at%+2,PEEK(@a%+1):PRINT t$:RETURN
RUN
Second Line............
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Powered by SMFPacks Menu Editor Mod