It’s been a while… I finally completed my first program in assembly. Well, sort of. Bob, from Bob’s 8-bit blog, decided to translate a program from Basic to Assembly. I ended up modifying it to add levels and a timer. Here it is:
Our next challenge is to pause our ‘fill the screen’ program (see this post) and wait for a key to be pressed to return to the BASIC.
Adding the following lines before the ret code will do the job:
waitforkey: ld a,0 in a, (254) cpl and %00011111 jp z, waitforkey
[Inspired by this article on Bob’s 8-bit blog]
This was going to be a short post: the ZX81 does not allow for the screen border to be colored.
But I decided that this would be a good opportunity to put all the things we’ve learned so far together, and draw a frame around our display zone.
At this stage, you understood that the ZX81 does not have colors. Only a 21 lines by 32 characters screen, each character filled with a value representing either graphics or letters, digits, or symbols.
So, what if we wanted to fill the screen with, say, black characters? We could try expand our original program like this:
ld HL, (D_FILE) ld a, 0x80 ; 0x80 is the value for the black square character INC HL ; skip the first 0x76 ld (HL), a INC HL LD (HL), a ... LD (HL), a ; the ld inc sequence is repeated INC HL ; 32 times for line one INC HL ; skip 0x76 at the end of the line LD (HL),a
Pretty fastidious right… We know we have 32 characters to fill per line, skip the 0x76 end of line, and repeat for 24 lines. Let’s use loops!
Continue reading “Filling the screen with colors”
In our previous post, we managed to display a black square at the top of the screen with the following assembly lines:
ld HL, (D_FILE) ld a, 0x80 inc HL ld (HL), a RET
Let’s look at it line by line.
Continue reading “Let there be color – explanation”
Misleading title! There is no color on a ZX81, except for black, white and grey… More on this in the next post.
Our first ZX81 program will draw a black square at the top left of the screen. Open your editor, and create a new file – call it zx81001.asm. Now type the following lines:
ld HL, (D_FILE) ld a, 128 inc HL ld (HL), a RET
Save your file, and compile it with pasmo:
pasmo -v zx81001.asm zx81001.p
The -v option stands for verbose and will give you additional information when things go wrong.
Now, execute your program with the emulator:
If all goes well, you should see a black square at the top left of your screen!
Last year, I started to learn ZX81 assembly language programming. I was a teenager in 1982, when I got my first computer, a ZX81 with 16K extension memory (the original machine comes with 1K, 1024 bytes!). At that time, I was really a novice in computers, and assembly language seemed unreachable to me. In the course of 2016, I cam across games developed in assembly language by Bob, from Bob’s stuff. I was so impressed by what Bob managed to produce out of this little black box, extending its limits beyond what I thought was possible. This gave me the motivation to start learning Z80 assembly language. I’m still very much a beginner in a learning curve. Recently, Bob started a blog, teaching Z80 assembly language on the Spectrum. I’ve read a few articles already, and decided to adapt them to the ZX81. This will be the content of upcoming blog posts on this site.
Those of you who have been learning a computer language will recognize the title of this post. Traditionnally, the very first program you write consists in outputting the sentence “Hello World” on the screen. So, this post is a tribute to that little tradition.
I would like this blog to be a place where I can gather all my notes on things I like. This goes from gardening, to cooking, , programming, reading, watching movies, and many more topics that come and go as I move forward in life.
So, welcome to my world, and please feel free to comment, protest, encourage, speak out loud.