Ned – Project Update #1
One of the ambitions I have for the ZX Spectrum Next after I’ve finished the Lords of Midnight port is to provide a complete development environment on the Next itself. Currently, I have to write code on a PC, assemble and test it using Mike Dailly’s wonderful snasm and Cspect tools, and then copy a .sna file to an SD card, physically take that to my Next, remount the card (via the browser) and run it. I have a FlashAir SD card, so in theory I can just copy the files from my PC over the network to the card plugged into my Next. In practice, the damn thing never works.
Well this is tedious.
So I decided that I would embark on writing a set of tools that allow me to only require a Next to do development. I could write Z80 code on paper, hand-assemble it, then pull out my favourite hex-editor and type code in. Not only is that even more tedious but this would require BASIC taking up a load of memory while I program.
The first tool I require is a text editor. I mentioned this idea to the Next team, it got a good response and I was told I should use the new tilemap video mode to implement a 80×32 text screen. I decided I would like to write an editor similar to vi in that it has a mode for entering text (insert mode), and a mode for doing manipulations on it (normal mode). For those that are not familar with vi and its modes, having two modes of use is useful for a machine that doesn’t have a full keyboard that we’re used to on PCs.
Of course, I will not be porting vi as it would take too much effort and I would like to end up with a tool that works with NextZXOS with the final result being a dot command. So the whole tool needs to fit in 8K preferably. But I will be taking some inspiration from it and borrowing some of its commands. I will also make it a little simpler for first users too. For example, and this will only be understood by vi users, I would have insert mode the default mode for new files, and normal mode for already existing files that are opened. These means you can create a new file and start typing immediately. I will also add simple keystrokes to save and quit too.
So today I started coding. I wanted to get the tilemap system worked out and the palette, then try printing some text. I borrowed a font from David Saphier and quickly got this running:
![](https://scontent.fykz1-1.fna.fbcdn.net/v/t1.15752-9/60348718_1963095153795826_6494147055865298944_n.png?_nc_cat=104&_nc_ht=scontent.fykz1-1.fna&oh=19a9069af7b78257e7b231e3e746a0b4&oe=5D6B6A79)
Now I wanted to try and support different colours. Because of the way the tilemap attributes system worked, I could only do 16 combinations of paper and ink colours. I could have one combination for normal text, another for the cursor, another for some rudimentary syntax highlighting and so on. After coding this, I got this slightly more interesting screen:
![](https://scontent.fykz1-1.fna.fbcdn.net/v/t1.15752-9/60710191_1992553117516168_3761598088016297984_n.png?_nc_cat=104&_nc_ht=scontent.fykz1-1.fna&oh=fdd03d2c547b61349901a8abda45657e&oe=5D6FF5B9)
For the technical of you, I arranged the memory layout so that code would lie between $8000 and $9fff, editor state at $7000, and the text buffer from $c000 onwards. This allows for a 16K text buffer. This will be ample for a working towards a first version of the editor. After this decision was made, I embedded a test text file into the memory at $c000 onwards and set about writing the routines to draw the file on the screen. I have written it so it can handle scrolling in all four directions. By the end of the day I had something on my screen:
![](https://scontent.fykz1-1.fna.fbcdn.net/v/t1.15752-9/60230986_2163966837248492_7166248148505985024_n.png?_nc_cat=107&_nc_ht=scontent.fykz1-1.fna&oh=2869bf6d9fa6087cdb99e96428da6649&oe=5D63450F)
Of course, I have no code to interpret keyboard commands and allow me to scroll around the file. So my next milestone is to do just that: implement keyboard routines (there’s a reason I am not using the ROM routines and I will discuss that another time); implement a cursor; and allow the cursor to move around the file. I hope to support the four cursor directions, page up, page down, home & end for both lines and files, as well as jump through words.
Finally, I decided to see how it looked on my own ZX Spectrum Next:
![](https://scontent.fykz1-1.fna.fbcdn.net/v/t1.15752-9/s2048x2048/60392699_296203261287884_5957521060080386048_n.jpg?_nc_cat=108&_nc_ht=scontent.fykz1-1.fna&oh=a8f03ea4f9256a01ca9d6ad4bb2b8f6e&oe=5D6CE2C2)
Just seeing this on real hardware has motivated me more to complete this. For any old Amiga programmers, perhaps you might understand when I say that this gave me HiSoft DevPac3 vibe!
Fantastic Work there Matt. You are making some real headway. I am so looking forward to this. Being able to Dev in Assembler properly on the Next is very exciting indeed. If you need any testing done I’ll willing help anyway I can. For me this is THE most important missing link for the Next.
I might take you up on that!
You can always use me as a beta tester too!
Like you, the current method of programming and getting it on the next is far too tedious for a lazy git like me, so to program on the fly will win me over 🙂
Just like old times, eh?