Structure and organization ramdisk
Real commander, in
(C) Pawel / RS
Starting with version 1.8 in the Real commander,
the opportunity to work with the resident
RamDisk'om, this article is intended for developers wishing to
make a software system to support its programs. Ram Disk in RC
is different from the existing standard for Honey Commander'u
greater reliability (system path is stored in the last bank)
and ease of use (There are no tables of banks in the system
sector).
Format ramdisk is no different from
conventional TR-DOS. In the latest available bank kept the
first 4 tracks, the following 4 tracks are stored by the bank
below, and etc. To determine whether the memory Ram
Disk'a checked identification code
Tr-Dos at # C0E7 last pot
if he is 16, then RamDisk present.
After this it is necessary to determine the number of banks
used for this purpose, standard information on the Tr-Dos
diskette to the address # C0E1 need to read two bytes of the
parameters of the first free track / sector. The parameter path
is multiplied by 16 and add the parameter sector. The result
obtained with the parameter add free sectors at # C0E5 and
divided into 64, as a result we get the number of employees of
banks. Below is the procedure for determine the presence and
quantity of RamDisk'a used by his bank.
TESTRD LD A, (PAGE); all banks
CP 7
RET C; out if 128k
DEC A
CALL ONPAGE; choice posl.banka
LD A, (# C8E7)
CP 1916
RET NZ; exit if not found
LD HL, (# C8E1)
LD DE, (# C8E5)
LD A, H
LD H, 0
ADD HL, DE
EX DE, HL
CALL RLENF9
LD B, 6
XOR A
TESTRD2 RR H
RR L
RRA
DJNZ TESTRD2
AND A
RET NZ
LD A, (PAGE)
SUB L
LD (RPAGE), A
; In RPAGE write what is available
; Banks open RamDisk'om
RET
Multiply. A by 16 and add. DE.
RLENF9 RLCA: RLCA
RLCA: RLCA
LD L, A
AND 15
LD H, A
LD A, L
AND% 11110000
LD L, A
ADD HL, DE
RET
There is certainly a caveat, if the RC limit memory use
256kb and open resident RamDisk, then this specific protsedurka
did not identify because he will not start with the last memory
bank. In most cases, the restriction memory in the RC need for
hardware RamDisk ' s, users are hardly become
use the software.
Now we give an example of how a disk
driver to organize work with RamDisk'om.
In this example uses a simplified treatment of errors # 3D13
without request RIA (Retry, Abort, Ignore), in such a
situation, the driver will simply return an error code.
TRDOS DEC C
JR NZ, TRD0
PUSH HL
CP 4
LD HL, # 3D13
JR NZ, TRDS
PUSH AF
LD A, (PAGE)
LD C, A
LD A, (RPAGE)
CP C
JR Z, TRD1; error
; RamDisk is not open
POP AF
LD C, 0
LD HL, RW
TRDS LD (ERR-2), HL
POP HL
TRD0 INC C
PUSH HL
LD HL, 0
LD (23823), HL
LD HL, (23613)
LD (ERR +1), HL
LD HL, ERR
EX (SP), HL
LD (23613), SP
EX AF, AF '
XOR A
LD (23570), A
EX AF, AF '
JP 15635
ERR LD HL, 0
LD (23613), HL
LD A, 6
LD (23570), A
LD A, (23823)
AND A
RET Z
TRD1; an error message
RET
Now when you select the drive "E" through
this driver instead of # 3D13 procedure will be connected RW,
providing read / recording RamDisk'e. It should be noted that in
your program should be stored in TKARD
Number of current logical bank.
; RAM DISK: read / write sector
; HL-address DE-dor/sek, C = 5 Thu, = 6 listings.
RW DEC C
JR NZ, RW0A
LD A, 4
LD (23798), A
RET
RW0A INC C
RW0 LD (23796), DE
LD A, B
AND A
JR Z, RW0C
PUSH BC
PUSH HL
CALL RW0S
EX DE, HL
POP HL
POP BC
AND A
JR NZ, RW0B
INC H
DEC B
JR RW0
RW0C EI
RET
RW0B; Issue posts
, "The track does not exist"
POP HL
LD A, 20
RET
RW0S LD A, C
PUSH AF
LD A, (PAGE)
DEC A
LD C, A
LD A, D
RW1 SUB 4
JR C, RW2
DEC C
LD B, A
LD A, (RPAGE)
DEC A
CP C
LD A, B
JR NZ, RW1
POP AF
LD A, 20
RET
RW2 ADD A, 4
RLCA: RLCA: RLCA: RLCA
ADD A, E
ADD A, # C0
LD E, 0
LD D, A
POP AF
CP 5
JP Z, RDM
JP WRM
RW4 LD HL, (23796)
INC L
LD A, L
CP 1916
JR NZ, RW5
INC H
LD L, 0
RW5 LD (23796), HL
XOR A
RET
Reading from a bank in C at a DE, and
entry into the current bank address in HL.
RDM PUSH HL
PUSH DE
LD A, C
CALL ONPAGE
POP HL
LD DE, RSCT
LD BC, 256
PUSH DE
PUSH BC
LDIR
LD A, (TKARD)
CALL ONPAGE
POP BC
POP HL
POP DE
LDIR
JP RW4
reading from the current bank at the HL
and write to the bank C at a DE.
WRM PUSH DE
LD A, C
LD DE, RSCT
LD BC, 256
PUSH DE
PUSH BC
LDIR
CALL ONPAGE
POP BC
POP HL
POP DE
LDIR
LD A, (TKARD)
CALL ONPAGE
JP RW4
Oh, and for the complete set of us now
only the driver memory. Published
below the driver differs from the published
at Echo 5 Improve memory tests understands more types of
extensions. To test the configuration of your computer, call
subroutine START, it initializes the carry over TYPE (type of
computer) and PAGE (the number of available banks, First Bank -
0 Last TYPE-1). After testing the configuration, all that comes
after the START You can overwrite. Now the above procedure
TESTRD can determine the presence of memory ramdisk. To test
whether the system RamDisk compare variables
PAGE and RPAGE, if they are equal then the ramdisk
No, otherwise RPAGE points to the first bank
occupied by RamDisk, all the banks below are available for use
by the program.
logical choice of the bank of the register A
ONPAGE PUSH BC
PUSH HL
LD C, A
LD B, 0
LD HL, TABL_PG
ADD HL, BC
LD A, (HL)
POP HL
POP BC
choice of physical bank of the register A
EX_RAM DI
PUSH HL
PUSH AF
PUSH BC
LD HL, TYPE
BIT 1, (HL)
JR NZ, ZS256
BIT 2, (HL)
JR NZ, PROFI
BIT 3, (HL)
JR NZ, TURBO_2
BIT 4, (HL)
JR NZ, ATM1
BIT 0, (HL)
JR NZ, SPECCY
BIT 7, (HL)
JR NZ, SPECCY
JR TDK
TURBO_2 PUSH AF
PUSH IX
AND # 38
CPL
LD BC, # FFF7
CALL OUTC_A
POP IX
POP AF
JP SPECCY
ATM1 LD BC, # FDFD
PUSH AF
RRCA
RRCA
RRCA
AND 7
JR HOME
PROFI LD BC, # DFFD
PUSH AF
RRCA
RRCA
RRCA
AND 7
JR HOME
ZS256 PUSH AF
LD B, A
AND% 00001000
RLCA
LD C, A
LD A, B
AND% 00110000
RLCA
RLCA
ADD A, C
LD BC, # 1FFD
HOME OUT (C), A
POP AF
SPECCY LD B, A
AND 24
RLCA
RLCA
RLCA
LD C, A
LD A, B
AND 7
ADD A, C
OR 16
LD BC, # 7FFD
OUT (C), A
NOP
TDK POP BC
POP AF
POP HL
RET
OUTC_A LD IX, 10835
PUSH IX
JP 15663
; RSCT - a temporary 64-byte buffer for
; Table banks are also used
; Ramdisk driver (256 bytes).
RSCT EQU 23296
LENTABL EQU 62; maks.kolich.bankov
DB 0
TABL_PG DS LENTABL +1
TYPE DB 0; type of computer
PAGE DB 0; all available banks
variables RPAGE and TKARD reserved
for Ram Disk'a
RPAGE DB 0; all available banks
; In a system with Ram Disk'om
TKARD DB 0; Current Bank
START CALL TEST
LD A, (8)
CP # 2A
JR Z, START1
LD C, 8; on Scorpion'e succeeded
CALL DEBUG; us to the 8 th bank
variable initialization Ram Disk'a
START1 LD A, (PAGE)
LD (RPAGE), A
RET
testing the computer's configuration
TEST CALL TABINIT
DI
LD A, (# 08)
CP # C3
JR NZ, ITURBO
LD HL, TYPE
SET 7, (HL)
ITURBO LD HL, (1111)
LD BC, # FFF7
LD A,% 00011111
CALL OUTC_A
LD DE, (# C000 +1111)
AND A
SBC HL, DE
LD BC, # FFF7
LD A, 255
CALL OUTC_A
JR NZ, IDFFD
LD HL, TYPE
SET 3, (HL)
JR I7FFD
MM_ATM DB # DB, # 1F, # C9
IDFFD LD DE, # 0007
LD BC, # DFFD
CALL TSTB
JR NZ, I1FFD
LD HL, TYPE
SET 2, (HL)
JR I7FFD
I1FFD LD DE, # 0010
LD B, # 1F
CALL TSTB
JR NZ, IFDFD
LD HL, TYPE
SET 1, (HL)
JR I7FFD
IFDFD LD B, C
LD D, # 11
CALL TSTB
JR NZ, I7FFD
LD HL, TYPE
SET 4, (HL)
I7FFD LD B, # 7F
CALL TSTB
JR NZ, SIZED
LD HL, TYPE
SET 0, (HL)
SIZED CALL VIRT
LD A, (PAGE)
CP 8
JR C, ENDING
LD HL, TYPE
LD A, (HL)
DEC A
JR NZ, ENDING
SET 5, (HL)
ENDING XOR A
CALL EX_RAM
EI
RET
TSTB LD IX, # FFFF
OUT (C), E
CALL TSTB1
LD L, (IX)
LD (IX), E
OUT (C), D
CALL TSTB1
LD H, (IX)
LD (IX), D
OUT (C), E
CALL TSTB1
LD A, (IX)
CP E
LD (IX), L
OUT (C), D
PUSH AF
CALL TSTB1
POP AF
LD (IX), H
RET
TSTB1 LD A, B
CP # 7F
RET Z
PUSH BC
LD B, # 7F
LD A, # 10
OUT (C), A
POP BC
RET
VIRT LD IX, # C000
LD HL, RSCT +63
LD B, 64
V_R11 LD A, B
DEC A
CALL EX_RAM
LD C, (IX +0)
LD (HL), C
LD (IX +0), A
DEC HL
DJNZ V_R11
PUSH AF
LD A, LENTABL-1
LD (PAGE), A
POP AF
LD DE, TABL_PG
V_R20 LD A, (DE)
CP # FF
JR Z, V_R30
CALL EX_RAM
CP (IX +0)
JR Z, V_R22
PUSH DE
LD HL, TABL_PG + LENTABL
AND A
SBC HL, DE
PUSH HL
POP BC
PUSH DE
POP HL
INC HL
LDIR
PUSH HL
LD HL, PAGE
DEC (HL)
POP HL
POP DE
DEC DE
V_R22 INC DE
JR V_R20
V_R30 LD B, 64
LD HL, RSCT
V_R31 LD A, 64
SUB B
CALL EX_RAM
LD A, (HL)
LD (IX +0), A
INC HL
DJNZ V_R31
RET
DEBUG PUSH DE
POP HL
NO_PG1 DEC DE
LD A, (DE)
CP # FF
JR Z, NO_PG2
CP C
JR NZ, NO_PG1
SBC HL, DE
PUSH HL
POP BC
PUSH DE
POP HL
INC HL
LDIR
PUSH HL
LD HL, PAGE
DEC (HL)
POP HL
DEC HL
DEC HL
NO_PG2 EX DE, HL
RET
initialization table banks are excluded
Banks 2,5.
TABINIT LD HL, TABL_PG-1
LD (HL), 255
INC HL
XOR A
TABI1 LD (HL), A
TABI2 INC A
CP 2
JR Z, TABI2
CP 5
JR Z, TABI2
INC HL
CP LENTABL +1
JR NZ, TABI1
LD (HL), 255
LD HL, RSCT
PUSH HL
POP DE
INC DE
LD BC, 63
LD (HL), B
LDIR
INC B
LD (TYPE), BC
RET