(C) SKL-KEEPER aka Kolesnikov
__________________________________________
"Boot" - a look inside and
possibility of improvement.
In this my article, I want to touch
theme that have never touched, except for the ZX-Revue N: 5 /
1994, and even then very sparingly and only in passing
sovpadayusche with the named topic. There it was about
auto-BASIC-line of machine code. Here I want to dwell on the
theme of a broader, namely - a simple "boot", how does it work?
The easiest, in my opinion, is
two-sector system "boot", developed by ShiSoft in 1993. So that
a boot for sure there is a collection of any spektrumista. With
him and begin.
I think I figured out well enough with how well it works,
and what I hasten to share with colleagues. So ...
; Disassembler boot SHISOFT-1993 (one hour, Ty, who is thrown
into the address 50015 ; (# C35F) and it starts with the same).
; BASICe In the first line is: RANDOMIZE
; USR VAL "15619": REM: SAVE "boot" LINE
; VAL "2"
; Second line has: RANDOMIZE USR VAL
, "23923"
; LOADER represents the following:
; ORG 23923
;
; PUSH HL; Must
;; Keep on HL
;; Stack!
; LD HL, METKA; How to make.
; LD DE, 50015, where to move.
; LD BC, 556; How many bytes.
; LDIR; Transfer.
; JP 50015; Start program.
; METKA DEFS 556
And then, finally, himself disassembler boot'a:
ORG # C35F
BEGIN LD A, # 07
LD (# 5C09), A; Installation ve
; Quantities retarding
; Between the LCD on
; Zhatiem cells. and
; Autorepeat.
LD (# 5C0A), A; Ustan.perioda
, Auto-repeat.
; These settings are necessary for a more convenient, and Noah
of the keyboard. It should in our ; Case immediately respond! ..
CALL ATTR; Call n / prog.
; Ustan.attrib.
, And CLS.
XOR A
LD (VAR_1), A; Zeroing ne
; Variables.
LD (VAR_2), A
LD (NPROG), A
OUT (# FE), A; BORDER 0.
LD D, A; Nulev.dorozhka.
LD E, A; Nulev.sektor.
LD BC, # 0805; Read 8 sects.
LD HL, BUFER; Address buffer
; To read
; Directory of the drive.
CALL # 3D13
LD IX, BUFER; In the IX-top
; Buffer, where
; Hoditsya assume
; Culated directory
LD DE, BUFER + # 800; In DE-address will
; Schrieffer, where it will
; Directory BASIC
; Programs.
LAB_1 LD A, (IX + # 00); Address 1st prog
; FRAMEWORK in kata.
OR A
JR Z, TEXTP; If the 1st character
; File = 0, then
; More files
No, it's on
; Recent and go
, The label where
, Printed on
; Pis below eq
; Wound.
CP # 01
JR Z, LAB_2; If the 1st character
= 1, then it is erased
; Th file transfer
; Move on LAB_2.
LD A, (IX + # 08); In akkum. address
; File type.
CP "B"; This is BASIC?
JR Z, LAB_3; If so, ne
; Transition by tag
LAB_2 PUSH IX; N / program
POP HL; calculation of addresses
LD BC, # 0010; the transition to the next
ADD HL, BC; blowing titles.
PUSH HL
POP IX
JR LAB_1; loops.
LAB_3 PUSH IX; Sub
; Transfer of titles.
, Prog. in buffer
POP HL
LD BC, # 0008; length hazvaniya
- 8 bytes.
LDIR; moved it.
LD HL, NPROG; in cell NPROG
, Count the number of
; BASIC-files.
INC (HL); Adds
; Unit.
JR LAB_2; return to the
; Top.
; Sub-print labels at the bottom of the screen.
; "SHISOFT-93:
TEXTP LD (DE), A; in the battery
And now zero.
INC A; we add "1".
LD (# 5C3C), A; Set Zero.
; Bit of this system.
; Perem.oznachaet
; Conclusion to the case
; Zhebny screen.
LD A, # 16; Nachin.pechatat
RST # 10; AT ...
XOR A
RST # 10, 0, ...
LD A, # 09
RST # 10, 9 ...
LD B, # 0D; In the "B" - length
; Inscriptions.
LD DE, TEXT_; In DE-her address.
CYCL1 LD A, (DE); Take 1yu letter
RST # 10; to publish it.
INC DE; Go to the next
; Blowing letter.
DJNZ CYCL1; loops,
, Until all
; Publish it.
LD A, # 02; opens
CALL # 1601; screen channel
LD A, # 15; OVER ...
RST # 10
LD A, # 01; 1 ...
RST # 10
LD DE, BUFER + # 800, recorded in the DE
; Address of the buffer
, Where the
; BASIC-files.
LAB_4 LD C, # 03; three columns.
CYCL3 LD A, (DE)
OR A; not zero?
JR Z, LAB_6; If yes,
; Went to LAB_6
LD A, # 20; Space.
RST # 10, print ...
LD B, # 08; name length
; Program.
CYCL2 LD A, (DE); Print this
RST # 10; title.
INC DE
DJNZ CYCL2; Until Napa
; Chat.
LD A, # 20; Print gap
RST # 10
DEC C
JR NZ, CYCL3
LD A, # 0D; Code 13 - the end
RST # 10; line.
JR LAB_4; repeat again
LAB_5 LD A, (VAR_2)
CALL LAB_7
LAB_6 LD A, (VAR_1)
CALL LAB_7
JR KLAWA
LAB_7 LD B, # 00
CYCL4 CP # 03; three columns?
JR C, LAB_8; If less
; Went to LAB_8.
SUB # 03; Otherwise subtract
, Triple and 1
INC B; uvelich.reg. "B"
JR CYCL4; loops.
And A in the following sub productivity, reduces the
calculation of the location of printing: LAB_8 SLA A;
Arifm.sdvig
; Left.
LD C, A; Remember that in
; Case "C".
SLA A; Just a couple of times
SLA A; shift to the left.
ADD A, C; added to the
; The fact that the "C".
LD C, A
INC C
LD A, # 16; AT ...
RST # 10
LD A, B; calculated positions
RST # 10; print (columns
LD A, C; ka, string).
RST # 10
LD A, # 14; INVERSE ...
RST # 10
LD A, # 01; 1 ...
RST # 10
LD B, # 08; name length
CYCL5 LD A, # 20; Space
RST # 10; Print gap
DJNZ CYCL5
RET
; Sub poll the keyboard:
KLAWA LD A, (VAR_1); In these cells
LD (VAR_2), A;-data about the position
; Approximation cursor.
LD HL, # 5C3B; in HL-e ne
; Rem.FLAGS. 5th
; Bit it establishes
; Lebanon to
; Pressing any
; Simvol.klavishi
RES 5, (HL); Reset 5 bits.
HALT; wait sled.prer.
BIT 5, (HL); Test 5 bits
JR Z, KLAWA; If the fold. pressing
; There, the team of "pro
; Skakivaetsya.
LD A, (# 5C08); Writes in A with
; Derzhimoe LAST_K
CP # 0D; That ENTER?
JP Z, PUSK_; if not, coma.
; Slips.
SET 5, A; Set. 5 bits.
CP "6" is "6"?
JR Z, WLEWO
CP "7" is "7"?
JR Z, PRAWO
CP "8" is "8"?
JP Z, WNIZ_
CP "9"; This is a "9"?
JR Z, WWERX
CP # 30; is zero?
JP Z, PUSK_
CP # 6F; This is the letter "o"?
JP Z, WLEWO
CP # 70; This "p"?
JP Z, PRAWO
CP # 71; This "q"?
JP Z, WWERX
CP # 61; It's "a"?
JP Z, WNIZ_
CP # 20; This is the gap?
JP Z, BEGIN
CP # 63; This is the letter "c"?
JP Z, AGAIN
WLEWO LD HL, VAR_1
LD A, (HL)
OR A
JR Z, KLAWA
DEC (HL)
JP LAB_5
PRAW LD A, (NPROG)
DEC A
LD HL, VAR_1
CP (HL)
JP Z, KLAWA
INC (HL)
JP LAB_5
WWERX LD HL, VAR_1
LD A, (HL)
OR A
JP Z, KLAWA
DEC A
OR A
JP Z, KLAWA
DEC A
OR A
JP Z, KLAWA
DEC A
LD (HL), A
JP LAB_5
WNIZ_ LD A, (NPROG)
LD HL, VAR_1
CP (HL)
JP Z, KLAWA
DEC A
CP (HL)
JP Z, KLAWA
DEC A
CP (HL)
JP Z, KLAWA
DEC A
CP (HL)
JP Z, KLAWA
INC (HL)
INC (HL)
INC (HL)
JP LAB_5
; If you press ENTER, then after a small, shoy training run
selected prog; Rummy: PUSK_ LD A, # 15; OVER ...
RST # 10
XOR A; 0 ...
RST # 10
LD A, # 38, New Attributes
CALL ATTR
LD A, # 07; White BORDER.
OUT (# FE), A
LD A, (VAR_1); start calculation
; Rooms start.
; Program.
RLC A; Vrasch.vlevo without
RLC A; carry flag.
LD C, A
LD B, # 00
LD HL, BUFER + # 800
ADD HL, BC
ADD HL, BC
LD DE, # 5D4E; place in the 1st century
; Robe BASICa where
; Finds. name
; "Boot".
LD BC, # 0008; name length
LDIR; Transfer BASIC
;-Line.
LD A, # 3A; This is the colon.
LD (# 5D57), A; transfer it to the
; BASIC-line.
LD A, # F7; That - RUN.
LD (# 5D4C), A; transfer it to the
; 1yu BASIC-line
And instead of SAVE.
AGAIN XOR A; Zeroing Accum.
LD (# 5C42), A; have brought 0 ne
LD (# 5C44), A; belt, where
; Line number
; BASIC following.
; Operator and
; Number sled.vy
, Holds the operator
; Operator RASIC.
LD HL, # 0223, return change
LD (# 5C09), HL; nennye early
; Boot-and change
; Nye.
POP HL; Sohran.na stack
RET
ATTR LD (# 5C8D), A; Constant ATT
; Ributy.
LD (# 5C48), A; Attrib.sluzhebn.
; Screen.
CALL # 0D6B; CLS
RET
TEXT_ DEFB "1993 ShiSoft"
NPROG DEFB 0; Kolich.BASIC
; Programs.
VAR_1 DEFB 0
VAR_2 DEFB 0
BUFER DEFB 0; It begins
; Is directory
; Drive.
Well, to understand how it works.
I hope everyone all right?
We now turn to the second part of my story ...:-)
So, whether it has boot'a disadvantages? Yes, they can
always be found, it would be a desire :-) Well, for example,
why do we need to display himself "boot", if we can restart by
pressing the space bar? AND yet: there are programs, consisting
of two BASIC-loader. In this case, the second boot is not
needed, it will only make a mess, and it would be advisable not
to withdraw ...
Hence, the first task is: to include
in the program "boot" 'and filtering of all BASIC-files
beginning with a lowercase letter or with a space (this is just
in case). How to do it? Very simple: to include in the
disassembler following snippet:
...................
CP # 01
JR Z, LAB_2; If the 1st character
= 1, then it is erased
; Th file transfer
; Move on the L399.
CP ""; This is the gap?
JR Z, LAB_2; If so, re
; Progress on the label.
CP # 5B; if> = "Z", then
JR NC, LAB_2; transition, because
And after "Z" are
; Malenk.bukvy.
LD A, (IX + # 08); In akkum. address
; File type.
CP "B"; This is BASIC?
JR Z, LAB_3; If so, ne
...................
To include this snippet, I think
Did you understand (I specifically left two
stitch the top and bottom of the main program.
More ... Perhaps more to ubobno
Users will be if the font, which displays the names of
programs, will not standatnym Spectrum, and "pokrasivshe.
Please, here's another piece (the procedure formation of the
font I pulled out of the program MINIBOOT 3.0: Well, very much
like the font!):
.................
LD (# 5C0A), A
CALL ATTR; Call n / prog.
; Ustan.attrib.
, And CLS.
LD HL, 15360
LD DE, FONT
PUSH DE
LD (23606), DE
LD BC, 1024
LDIR
POP HL
LD BC, 128
LAB2 PUSH BC
INC HL
INC HL
INC HL
LD B, 3
LAB1 LD D, (HL)
LD A, D
RLA
OR D
LD (HL), A
INC HL
DJNZ LAB1
POP BC
DEC BC
INC HL
INC HL
LD A, B
OR C
JR NZ, LAB2
..............
Only we must not forget that when we chose the program and
press ENTER to run, you must return the value of CHARS
(In sub PUSK_):
.................
LD A, # 38
CALL ATTR
LD HL, 15360
LD (23606), HL
LD A, # 07
................
Well, the last one. As you know, in the described boot'e
control the cursor can be by right-Sinclair joystick and
buttons QAOP, SPACE. You can add a poll cursor keys (in a
subroutine with a nice name KLAWA). How do you can read in my
article about the poll Keyboard section for Dummies "DEJA
VU.