drawing a chess board

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

drawing a chess board

Post by MrPixel »

so, i'm looking through one of the zx spectrum manuals (graciously given by one of the admins) and was wondering how to draw a chess board, as far as plotting and drawing. i have the rest done from the baseline program:

Code: Select all

30 READ a: POKE USR p$+f,a
40 NEXT f
50 NEXT n
100 REM bishop
110 DATA “b”,0,d, BIN 00101000, BIN 01000100
120 DATA BIN 01101100,c,b,0
130 REM king
140 DATA “k”,0,d,c,d
150 DATA c, BIN 01000100,c,0
160 REM rook
170 DATA “r”,0, BIN 01010100,b.c
180 DATA c,b,b,0
190 REM queen
200 DATA “q”,0, BIN 01010100, BIN 00101800,d
210 DATA BIN 01101100,b,b,0
220 REM pawn
230 DATA “p”,0,0,d,c
240 DATA c,d,b,0
250 REM knight
260 DATA”n” 0,d,c BIN 01111000 ,
270 DATA BIN 00011000,c,b,0
280 DATA”n”0,d,c BIN  01111000 
but where would the coordinates be for plot and draw :?:
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: drawing a chess board

Post by Nomad »

Hey fella, I don't want to spoil the learning experience for you. You will get a lot from this if you push through and do it yourself.

A pointer though.. Think about using for next loops to create your drawing. Look at the graphics characters you have for free... I can think of two that would make excellent board.

Think about how the UDGs look with different INKs and PAPER values. Experiment and have fun.

Think about the size of UDG, that will give you the number you need to figure the total size of the board..

If you find that the drawing routine is taking to long at getting you down. Look up SCREEN$ in the manual. Figure out how to load a SCREEN$ file.

You work through all this, you will be in a very good place to design your own graphics in BASIC for any project you want to tackle with UDGs, that are not animated.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: drawing a chess board

Post by MrPixel »

how would i map the pieces to the board? i want the player to use WASD or JKLI to move.

just use the cursor keys to pick a piece and use either of the keys to move
Ralf
Rick Dangerous
Posts: 2282
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: drawing a chess board

Post by Ralf »

how would i map the pieces to the board?
If we speak about Basic then just keep them in a table. DIM instruction would be useful, check it.
For example you can use small letters for white pieces and big letters for black pieces. Or use different number values. Or some other completely new notation invented by yourself.

Very general advice - in games you usually have visible things on screen but also some invisible structures in memory used for game logic. So you probably need

- board data,
- cursor X and Y position,
- some mode variable: are you before or after selecting a piece
- X and Y of selected piece

To read keyobard use can use INKEY$ command in Basic.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: drawing a chess board

Post by PeterJ »

There is a good routine on page 117 of the BASIC manual I sent you to print them.on screen. Read the full chapter first though, and if possible the whole book. It's a wonderful introduction to BASIC on the Spectrum
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: drawing a chess board

Post by MrPixel »

can you post an example? my knowledge of BASIC is very limited (i teach atari BASIC at my day program, so could you post an atari version as well?)

thanks in advance
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: drawing a chess board

Post by PeterJ »

Hi, that routine I mentioned above will print the chessboard for you.
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: drawing a chess board

Post by MrPixel »

is there a way to copy and paste?

in fuse
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Re: drawing a chess board

Post by MonkZy »

Fuse does not have a copy/paste option for the BASIC editors being emulated as far as I know. There are other options for editing BASIC routines.

Google search "bas2tap". With bas2tap you can convert a BASIC listing written in any kind of text editor (saved as ASCII or plain text) into a .TAP file to run on Fuse. You must use all uppercase letters for command key words and put spaces in commands such as GO SUB, but all in all it does a great job. Bas2tap is written in C so is very easy to compile, but if you prefer a pre-compiled binary you can also find these via google.
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Re: drawing a chess board

Post by MonkZy »

I also forgot to mention Fuse can dump a BASIC listing to a text file. If you enable ZX Printer and Printer Emulation, LLIST will make Fuse create a text file of the listing. You may have to edit/examine .fuserc (or the relevant config file) to set/determine where the file gets dumped. You also get a .pbm of the original dot matrix output, which is nice.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: drawing a chess board

Post by Nomad »

MrPixel wrote: Wed Apr 04, 2018 10:21 pm is there a way to copy and paste?

in fuse
It might seem pointless, but you need to actually type the listings for this information to be retained. In an ideal situation you would write your own notes long hand re-contextualizing the information to let you retain the information. This is a basic study skill.

You can't just copy and paste information and expect to retain it in any kind of meaningful way.

Think about how type-in magazines evolved. They started off being very simple basic listings but fast forward a few years and its pages of hex/basic hybrids. :lol: Do you think that the readers would have progressed to that level with passively copying and pasting the information?
No they grew through active learning.

When you think about it - all these tasks that people do. They in themselves in most cases are of very little value except what they can teach you. So when you choose to make your own applications/games you can apply the information that you learned.

So if you short change yourself in this stage - it impacts everything that comes after.

It's my theory that this is why the understanding that the majority of programmers has gone down instead of up.

Lol I get the feeling you are thinking that not copy pasting everything is some sort of flat earth theory. Look its not just me, google Leerteorie/Learning theory if you want to look it up. :lol:

A bunch of different theories exist but for the most part the modern ones agree on the basics (that active learning is better than passive).

I don't know how badly education has declined in the last 20 odd years but I can't believe that people are just copy/pasting from wikipedia/W3 school to graduate.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: drawing a chess board

Post by PeterJ »

Fully agree with [mention]Nomad[/mention]. When I was younger and learnt from type-ins in magazines I would spend hours typing in listings in front of the TV. Often their would be bugs you would need to fix, or waiting until the next month's issue for the resolution.

There are utilities as others have said like bas2tap which make things easier by converting a text file to a .tap file.
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: drawing a chess board

Post by RMartins »

Do read the ZX Spectrum BASIC Manual.
It's a very good resource, unlike what you get nowadays.

Technical books, were usually very well written, in the old days.

I still keep some Hard-Copies of DOS and GW-BASIC manuals/books, just because of there quality content.
Ralf
Rick Dangerous
Posts: 2282
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: drawing a chess board

Post by Ralf »

Often their would be bugs you would need to fix
Yes, I have a feeling they were often unable to print a single listing without some bugs.

And you could introduce a lot of bugs yourself by being not careful enough and typing in something different from the listing.

And if the bugs were in assembler, your computer usually hanged or crashed and resetted and all your work was lost.

Good (or rather actually bad :lol: ) old days.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: drawing a chess board

Post by Alessandro »

Why people still bother with the old and limited bas2tap when there is that wonderful ZX-Editor tool... Use it and stick to it, that's what I say 8-)
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: drawing a chess board

Post by Nomad »

Type-ins/listings In a really bizarre way they were unintentionally brilliant teaching tools. They are like an intellectual puzzle to the reader to get it to work if they have the skills. Deeply frustrating. I think it had to happen at a time when there were less distractions or things to take up a young persons time. My memories of the 80s were it was an incredibly boring time to be a child unless you were born into privilege. :lol: Stuff like listings magazines, game books they all filled a void of boredom. Not sure if they even have an appeal today.

By having errors in the listing because of transcription errors from the printers, errors in design or errors introduced by the consumer.

The act of analysis, the expermentation and correction/finding a solution to the problem. What that taught built so many skills.

:lol: But for every listing I fixed, there were two that I couldn't and I had to leave in frustration not sure if it was the listing that was at fault, my copying of the listing or just a bizarre conception problem in the program itself. You would usually type in a listing that looked interesting or did something that was beyond the current ability level. There were times I typed in stuff I had no idea how it worked. :lol:

Not a perfect method, but for every failure there was a success that made the consumer better. And some could argue that even in the failures it taught a kind of mental resilience that promoted Stoicism. :lol:
MrPixel
Microbot
Posts: 170
Joined: Sat Mar 24, 2018 7:42 pm

Re: drawing a chess board

Post by MrPixel »

the problem is the speed of emulators. the zx81 for instance, is where copy paste is appealing
User avatar
RMartins
Manic Miner
Posts: 776
Joined: Thu Nov 16, 2017 3:26 pm

Re: drawing a chess board

Post by RMartins »

Nomad wrote: Thu Apr 05, 2018 11:15 am ...
Deeply frustrating. I think it had to happen at a time when there were less distractions or things to take up a young persons time. My memories of the 80s were it was an incredibly boring time to be a child unless you were born into privilege. :lol: Stuff like listings magazines, game books they all filled a void of boredom. Not sure if they even have an appeal today.
...
I never had this feeling of boredom.
We played a lot on the street with friends or riding a bike or whatever.
If we did not have anything to do we would invent crazy stuff, like catching small lizards, make some ramps to jump with our bikes, race with ball bearing go karts we built , use or build a slingshot to go bird hunting, play soccer on the street or any other crazy ideas we would come up with.

I wish I had today the free time I had back then ;)

Edit:
Home made ball bearing go karts ( a.k.a. "carrinhos de esferas" in Portuguese).
https://www.google.pt/search?q=carrinho ... 33&bih=295
Post Reply