absolute begginer
-
- Posts: 9
- Joined: Fri Jun 03, 2016 6:09 pm
absolute begginer
Hi, My names Tom. I've been trying to get started with programming games for the spectrum. I have the book'Spectrum machine language for the absolute beginner which seems to be be pretty great although its obviously not very helpful with the ins and outs of cross assembling and emulators.
My aim is to get familiar enough with the basics to start the tutorial 'How To Write ZX Spectrum Games' by Jonathan Cauldwell, the creator of DIZZY!!! My favorite game when I was little.
https://chuntey.wordpress.com/2012/12/1 ... chapter-1/
I'm having some frustrating problems getting my code to run on an emulator tho and I will post something about it in the dev forum.
Cheers!
My aim is to get familiar enough with the basics to start the tutorial 'How To Write ZX Spectrum Games' by Jonathan Cauldwell, the creator of DIZZY!!! My favorite game when I was little.
https://chuntey.wordpress.com/2012/12/1 ... chapter-1/
I'm having some frustrating problems getting my code to run on an emulator tho and I will post something about it in the dev forum.
Cheers!
Re: absolute begginer
Hello,
You can either use the assembler in ZX Spin or create your code in a disassembler.
The BIN-files, the binary compiled code from crossassemblers, can be inserted by file insert and then load the binaries on the addresses you compiled them.
Make sure the memory is accessable and will not override the current stack.
Then start your code with a randomize usr start command.
You can either use the assembler in ZX Spin or create your code in a disassembler.
The BIN-files, the binary compiled code from crossassemblers, can be inserted by file insert and then load the binaries on the addresses you compiled them.
Make sure the memory is accessable and will not override the current stack.
Then start your code with a randomize usr start command.
-
- Posts: 9
- Joined: Fri Jun 03, 2016 6:09 pm
Re: absolute begginer
Hi Dr beep, thanks for replying,
I didn't understand quite a lot of what you just said I'm afraid! Like what you mean by:-
1. insert by file insert
2. load binaries on addresses you compiled them
3. mem is accessable??
4. and why would it override the stack?
meanwhile I have setup using pasmo to cross assemble and spectaculator to run. I can get a .bin to run ok but the program doesn't run as expected from a .tap file, more details here.
viewtopic.php?f=14&t=1949&p=20177#p20177
I didn't understand quite a lot of what you just said I'm afraid! Like what you mean by:-
1. insert by file insert
2. load binaries on addresses you compiled them
3. mem is accessable??
4. and why would it override the stack?
meanwhile I have setup using pasmo to cross assemble and spectaculator to run. I can get a .bin to run ok but the program doesn't run as expected from a .tap file, more details here.
viewtopic.php?f=14&t=1949&p=20177#p20177
Re: absolute begginer
You need to start the code after loading.minimaltom wrote:Hi Dr beep, thanks for replying,
I didn't understand quite a lot of what you just said I'm afraid! Like what you mean by:-
1. insert by file insert
2. load binaries on addresses you compiled them
3. mem is accessable??
4. and why would it override the stack?
meanwhile I have setup using pasmo to cross assemble and spectaculator to run. I can get a .bin to run ok but the program doesn't run as expected from a .tap file, more details here.
viewtopic.php?f=14&t=1949&p=20177#p20177
It is now loaded at 30000 and further, nothing more.
Start the code with RANDOMIZE USR 30000 or PRINT USR 30000
The USR-function will make the BASIC start the Machinecode at 30000.
When your stackpointer is set at an address which is overloaded then the return address is corrupted after loading, making a return impossible.
30000 is often free. The BASIC is too small to reach 30000 and in 16K the Stackpointer is around 32000. On 48K the stackpointer is around 65000.
-
- Posts: 9
- Joined: Fri Jun 03, 2016 6:09 pm
Re: absolute begginer
Thanks I understand a bit better now,
Did you mean its loaded at 32000 by the way because my program starts with 'org 32000' (only because thats what I saw in a tutorial but I understand from what you said that the basic code is in the first 30000 bytes or so)
After loading the .tap, when I type PRINT USR 32000 I get '2 variable not found, 0:1' and I have no idea what that means yet.
I can't even type randomize, when I hold the caps shift key it still types RUN first before it types an R'
Is there a way of having it play the program automatically? And why randomize anyway?
Did you mean its loaded at 32000 by the way because my program starts with 'org 32000' (only because thats what I saw in a tutorial but I understand from what you said that the basic code is in the first 30000 bytes or so)
After loading the .tap, when I type PRINT USR 32000 I get '2 variable not found, 0:1' and I have no idea what that means yet.
I can't even type randomize, when I hold the caps shift key it still types RUN first before it types an R'
Is there a way of having it play the program automatically? And why randomize anyway?
Re: absolute begginer
The function USR must be chained to a command. That can be done by RANDOMIZE, but also by PRINT or LET and many more.minimaltom wrote:Thanks I understand a bit better now,
Did you mean its loaded at 32000 by the way because my program starts with 'org 32000' (only because thats what I saw in a tutorial but I understand from what you said that the basic code is in the first 30000 bytes or so)
After loading the .tap, when I type PRINT USR 32000 I get '2 variable not found, 0:1' and I have no idea what that means yet.
I can't even type randomize, when I hold the caps shift key it still types RUN first before it types an R'
Is there a way of having it play the program automatically? And why randomize anyway?
That is because the ZX Spectrum uses keywords in BASIC?
Start the game by pressing T when you see the K cursor.
THen shift and symbolshift (on emulator shift and alt) and you get E cursor. Then press L for USR
Finally enter the number and press ENTER.
Take a look on the HELP of the emulator for the keyboard layout.
Re: absolute begginer
Dr Beep was not too clear about why you cannot simply type RANDOMISE letter by letter...
The ZX80, ZX81 and ZX Spectrum (well the 16K/48K ones) use a system of keywords for entry of commands. This was to reduce the typing required.
When you look at their keyboards, each letter key has some words printed around them.
The ZX Spectrum has keywords printed in WHITE, RED and GREEN.
The white keywords are the main keyword for that key - obtained when the cursor shows as K
The ZX80 and ZX81 keywords are also like this.
Once you have entered a keyword (eg the RANDOMISE keyword, obtained by pressing the T key), the cursor changes and you can then use the letter keys as individual letters to enter the name of a variable (for example).
At this point, you can also press SHIFT (or Symbol Shift on the Spectrum) and the key to enter a symbol (eg quote marks), or for the upper case letter (not on the ZX80 / ZX81 which do not support upper and lower case).
On the Spectrum, you can also press the Shift + Symbol Shift button to enter Extended mode (the cursor changes to an E), which allows you to access the keyword which appears below the letter key. If you keep the SHIFT key pressed down when you press the letter, then the keyword which appears above the letter key will be entered (I think that is the correct way round!)
Hopefully that makes it a bit clearer
The ZX80, ZX81 and ZX Spectrum (well the 16K/48K ones) use a system of keywords for entry of commands. This was to reduce the typing required.
When you look at their keyboards, each letter key has some words printed around them.
The ZX Spectrum has keywords printed in WHITE, RED and GREEN.
The white keywords are the main keyword for that key - obtained when the cursor shows as K
The ZX80 and ZX81 keywords are also like this.
Once you have entered a keyword (eg the RANDOMISE keyword, obtained by pressing the T key), the cursor changes and you can then use the letter keys as individual letters to enter the name of a variable (for example).
At this point, you can also press SHIFT (or Symbol Shift on the Spectrum) and the key to enter a symbol (eg quote marks), or for the upper case letter (not on the ZX80 / ZX81 which do not support upper and lower case).
On the Spectrum, you can also press the Shift + Symbol Shift button to enter Extended mode (the cursor changes to an E), which allows you to access the keyword which appears below the letter key. If you keep the SHIFT key pressed down when you press the letter, then the keyword which appears above the letter key will be entered (I think that is the correct way round!)
Hopefully that makes it a bit clearer
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
-
- Posts: 9
- Joined: Fri Jun 03, 2016 6:09 pm
Re: absolute begginer
Thank you both, I now have it running properly! I will have to read the spectrum BASIC manual alongside the assembly book I think but now I can have a bit more fun.
Re: absolute begginer
Glad to help
If your first experience is an emulator, it is hard to get used to the way that the keyboard works on these computers...
If your first experience is an emulator, it is hard to get used to the way that the keyboard works on these computers...
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
- 1024MAK
- Posts: 5103
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: absolute begginer
Welcome on board Tom!
It is easier to understand how the key word system works on a real rubber key ZX Spectrum, as the different Commands, Functions and symbols are colour coded on the keyboard.
RANDOMIZE USR n
Where RANDOMIZE is a command, it is used to seed the random number generator (so just sets some of the system variables). Not because people want to do this, but because it has no other affect, so is nice and safe and simple when coupled to the next bit...
USR n causes BASIC to pass control to a machine language routine at address n. Should the machine language routine return to BASIC (a machine language "ret" instruction), the number in a register pair (different between ZX81 and ZX Spectrum - see the manual) is returned to BASIC as a value. As USR n is a function, the value is passed to the RANDOMIZE command, which uses the number as a seed.
So the whole line is just a "simple" way to get BASIC to run machine code with the minimum disruption to both BASIC and memory
Mark
It is easier to understand how the key word system works on a real rubber key ZX Spectrum, as the different Commands, Functions and symbols are colour coded on the keyboard.
RANDOMIZE USR n
Where RANDOMIZE is a command, it is used to seed the random number generator (so just sets some of the system variables). Not because people want to do this, but because it has no other affect, so is nice and safe and simple when coupled to the next bit...
USR n causes BASIC to pass control to a machine language routine at address n. Should the machine language routine return to BASIC (a machine language "ret" instruction), the number in a register pair (different between ZX81 and ZX Spectrum - see the manual) is returned to BASIC as a value. As USR n is a function, the value is passed to the RANDOMIZE command, which uses the number as a seed.
So the whole line is just a "simple" way to get BASIC to run machine code with the minimum disruption to both BASIC and memory
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer later in the year.