I Still Aten't Ded
“Hope smiles from the threshold of the year to come, whispering ‘It will be happier.’”
— Alfred, Lord Tennyson
Well…
There are years and then there are those years. Let’s face it, 2020 was definitely a bit of a shocker. As with most people I’ve had more important things on my mind than hobbies. However, with the New Year I’ve decided to pick up where I left off. I think it’s probably good to have hobbies and keep your mind active.
After all, how much Judge Judy can one dwarf watch?
Composition
We’re going to start off the year with a baby step, but one that serves to demonstrate one of the things that’s going to make our lives easier.
Way back in October I wrote a clear screen component. And that’s good, that’s nice, but it leaves your cursor at the bottom of the screen. So let’s fix that.
First there’s a new component to move cursors around:
# Set hardware cursor position
#
# Notes:
# This can be set using the VGA registers directly but for now we'll use BIOS.
#
# Inputs:
# AL - Page number. We're using 80x25x16 so there are 8.
# DH - Row
# DL - Column
#
# Destroys:
# AH, BH
#-------------------------------------------------------------------------------
# First need to figure out which page we're on
20c0: cmp al, 08 3c 08
20c2: jg error 7f 09
# Use BIOS to set the position
20c4: mov bh, al 88 c7
20c6: mov ah, 02 b4 02
20c8: int 10 cd 10
20ca: clc f8
20cb: jmp end eb 01
error:
20cd: stc f9
end:
20ce: retf cb
No need to worry too much about how it’s achieving what it’s achieving, the BIOS can remain a black box for now.
We’ve also moved the clear screen component to 0x2080.
Now we use the two individual components to compose a third component with more functionality.
#-------------------------------------------------------------------------------
# Clear screen 0 and put cursor at 0,0
#
# Destroys:
# AX, BX, CX, ES, DI
#-------------------------------------------------------------------------------
2100: xor ax, ax 31 c0
2102: xor dx, dx 31 d2
2104: call 0000:2080 9a 80 20 00 00
2109: jc end 72 05
210b: call 0000:20c0 9a c0 20 00 00
end:
2110: retf cb
What this does is call the clear screen function, then call the set cursor function. The final result is to clear the screen and set the cursor at the top. This would be perfect if the Enbugger didn’t output an end of line when you return from the call, but that’s a problem for another day.
A quick review of the current memory map:
| Start | End | Component |
|---|---|---|
| 1000 | 11ff | Boot sector |
| 1200 | 13ff | Stack |
| 1400 | 1fff | Enbugger |
| 2000 | 204f | Save |
| 2050 | 207f | Load |
| 2080 | 20b7 | Clear Screen |
| 20c0 | 20ff | Move Cursor |
| 2100 | 213f | CLS |
Hopefully the future pattern is plain, i.e., components will get chunks of 64 bytes. I came up with that number after I wrote the load function, I guess I’ll move it sometime.
Micro-steps taken today, but I’m hoping to set aside some time each weekend to work on the project so updates should be weeks apart rather than months.
— Curufir