Inferno #08
30 ноября 2005

Softinka - ZX Spectrum emulator for ZX Spectrum.

<b>Softinka</b> - ZX Spectrum emulator for ZX Spectrum.
          ZXZXEmul

   Continuing the theme of jokes published in
ACNews # 29 (in fact, the idea is even older)
I decided to write an emulator for ZX Spectrum
ZX Spectrum. Nothing is impossible here not to
method is also not unusual. Su
Tee, the emulator replaces the slow trass
defocusing, which happens in the debugger, and he
may become the core of the debugger (finite
but not in its present form, which is too
focused on speed). This is
the importance of convenience - the ROM can be substituted
its firmware, and memory allocation can be
take all of the other model computer.
And you can, say, to emulate a mouse when it is
absence. Another useful feature of the emu
oscillator, achievable in conventional debuggers that
lko at pereshivanii ROM (not a trace
believe t.k.gonyat complicated program, has
yuschuyu user interface, under the Trues
defocusing is impossible) - breakpoint can
but lay in a single byte. In this case, the stack
program does not deteriorate (this is not achievable
model in conventional debuggers).


   The emulator is written as follows.


   First debug command system for
16k RAM and ROM available. (This mode is useful
the fact that the emulation is not necessary to switch
page.) Teams are selected on the table
(For each command code - address podprog
FRAMEWORK), with a pointer to the current coma
NDU is stored in the DE. Basic set of registration
moat conveniently stored in an alternative
set, and the main A, BC, HL leave for
various vychisleniy.Mozhno would again
revenge in the registers and emulated SP, but
payoff is likely to be very small. But
highly simplifies the use of IX
as the current index register. (Not
current index register must lie
somewhere in the variable in memory, as well as
alternative set of registers.)

   Teams with prefixes are painted in a separable
lnyh tables. When changing the current index
Nogo prefix index registers are exchanged
are (IX <-> memory). This ubilos two hares:
IY can take under something useful, needed
just one set vypolnyalok index to
commands.


   Emulator, of course, is not the first time
work, although it was written in only two
day, using a macro (to a
chance to quickly replace the entire program
buggy piece, if it is found).

   You have to debug it.

   Simulate a reset. We see that it does not work
melts. Come on firmware ROM step by step
stopping Unreal Speccy conditional point
kami stop (pc == nnnn)''(de == mmmm), where
nnnn - start address vybiralki team, and
mmmm - the address in ROM, on which we want
ostanovitsya.Ostanoviv, debit registers.
Start the second instance, and Unreal Speccy
See what at this point in the real ROM
sequence should be registry.Parallelno
study the route by which our emulator
performs ROM (write down all the addresses branching
leniya). If we see that our emulator went
not where it should (and where necessary, we still
shows the second copy of Unreal Speccy), then
this is the case when it is necessary to check
registers. At the same time check the simulated
system variables.


   To reach the message "Sinclair Re
search Ltd ", in our emulator is not even well
zhno emulate emulates preryvaniya.Odnako
vat break one way or another need.

   For a start has been made "honest" emu
triangulation IM1 (so far without IM2) this ful
lneniem each team obrabotchika.Do WMOs
yes to the handler (ie, to emulate the RST
# 38) to do two things: check
emulated trigger interrupt enable
(At the same time dropping it) and finish the emulation
current emulated komandy.Dlya to
complete emulation of the current emulated to
Mande, we simply put the interception at the beginning
vybiralki team.

   Later, the interrupt handler was compli
Nene: appeared IM2, as was done for IM1
opportunity rather than "fair" under emulation
conclude the call now # 38. That there
tively quickly. Of course, before such
challenge is checked to see if I IY, and if not
there, then you need to "honestly" to emulate bugs
emulated by the program:)


   Memory Limit (16k instead of 48k) to
locally made easy: forbidden entry
cells above # 7fff.


   In the end (on the fifth day) emulation
16k earned, and emulated BASIC
it became possible to execute the statements.

   The next step - 48k. They required
macros were working with memory. Emulator
 Need memory operations:

  1. taking command code or parameter
 team;

   2. entry into the virtual memory;

  3. reading from the virtual memory;
and others listed - osnovnye.Virtualnoe
RAM is placed in the top pages of memory
TUE.

   Wrote these macros, I got perturbed
zhnost arrange to intercept the output on screen
wounds: if emulated pg5 lies not in the real
Noah pg5 (it switches to the source -
try), then the write command on the screen can
zhno forward and back and back, and
on the real screen, you can write is not always
but on some condition (for example, I Rea
calized clipping the right side of the screen -
it can accommodate, say, any integral
indicator of).

   After debugging 48k (at the same time was otrabo
tana opportunity to change the firmware ROM), I ne
reshel to 128k. The difference here is not so
principle, as between 16k and 48k. Just
need to add processing OUT (# fd) and implements
formalize the emulator relevant variables
mennuyu. More precisely, we need two variables: what
page of RAM is included in terms of the emu
liruemoy program and what is actually
should be included when working with addresses
> = # C000.

   For debugging 128 BASIC should be realized
vat and switching pages Rom. I'm at the same time
implemented and the possibility of switching
pages in windows # 4000 and # 8000, for the future
ATM emulation. This necessitated a change
LD A, constant in LD A, (variable) and right
kticheski not slow emulation.


   48 BASIC worked, despite the fact that
Some commands emulate irregular
but. Drove 128 BASIC, as well as Mr Gluk
Reset Service, I have tested other
komandy.Ne tested were nedokume
ntirovannye team with an indexed register
addressed, but I do not realize.


   Note that when the
128 BASIC should not work out in the
TR-DOS by # 3dxx! Otherwise not consider calcium
kulyator 128 BASIC! I found it not once,
as on my real pentagon # 3dxx pa
boat, and when the 128 BASIC. Point
She, # 3dxx me in this case includes
0-th page ROM, where Gluk Service. But ca
ICDO 128 BASIC in ROM, I do not have, instead of
he Quick Commander.


   The emulator has turned a cumbersome
size because I wanted to find a ceiling
speed. To trace the real problem
All macros work with the memory should have been
drive into the routines, and many vypolnyalki
Commands should be combined. However,
ceiling, I do not dostig.Pri this method (for
a successive execution of commands without the din
nomic recompilation and without prediction
the following commands) brake in selecting a page
(Commands, data, stack) could be strongly
reduce, if not make DE point
the virtual memory address of the program, and
to the real address (# c000-# ffff), guaranteed
rovav while that in the beginning to vybiralki
Manda is included page commands. For
then I realized the box margins (0 = one hundred
ry mode, 1 = new), wrote a new kernel
emulation, and made different macros return
vypolnyalok from different teams (the easy way out,
output with the inclusion of pages of commands output
recalculation of the virtual to the real and DE
etc.). In the form, as I realized,
has not bypassed when the program
crosses the boundary of the windows memory. But to circumvent
it can be. Unfortunately, the treatment margins = 1
Even in this simplified form, I have not
able to debug - maybe you have the floor
chitsya?

   There is another option to accelerate the choice of
commands - copy from a page of commands
just a lot of bytes and then execute commands
at the bottom of memory. Of course, you need a lot
checks.


   As usual, I had lost in his broken
GOVERNMENTAL pieces of paper recording measurements of time to
the first method (margins = 0, which work
em) for the second (margins = 1, which is not
works). Gain in speed in the new
method (when performing the reset procedure)
If I remember correctly, somewhere in 25%.
Of course, the fastest mode - this is 16k.


   Emulation # 3d13 was not enough
to earn the disc program. Widi
model, it is necessary to support some other point.
Mr Gluk Reset Service sees the directory, but not
can run beysiki.Vprochem, diskdoktor
work.


   I have not done a single control button
emulator, simply noted in a handler
interrupt the place where should be checked
knopki.Rekomenduyu use a combination of
SS / Enter, give it to the menu, including
options which (dumps, loading / unloading
snapshots, debugger, etc.) should be
is as follows: "to pass the program on an emulated
zhatie SS / Enter for 10 interrupts.



   Sources are in the appendix. They consider
read the compilation to Pentagon 512/1M
(Itself an emulator also designed to work on
Pentagon 512/1M). You will be easy to use
rule under a different model of memory.

Alone C




Other articles:

Inferno - The authors of the magazine.

Inferno - Entered from the editor.

Inferno - Errors in the previous numbers.

Inferno - On the shell.

Iron - CD-ROM - a device and Tricks connection.

For Coderz - CD video on the ZX. How to write a video player with CD-ROM.

Softinka - Technical Reference disk system DISCiPLE / + D.

For Coderz - Small programmers' tricks.

Mathematics - The history of the solution of Fermat's theorem.

Gameland - Game Shestnashki.

Softinka - a description and history of the program to work with hard disk HDDoctor v0.9.

Secrets - The X button in different applications: Wolfenstein'2004, IG # 5, ACEdit, DNA OS, Wild Disk Copier.

Softinka - Improved graphics converter Gigascreen.

Sound - tube amplifier. Stereo lampochnik 2x5 Tues of old TVs.

Iron - Overview of cassette players.

Inferno - Letters to the Editor.

Gamedev - The history of the game Pang.

Gamedev - Tips for writing an arcade game.

Advertising - Ads by Roman Chuunin.

Advertising - Ads by Alexei Zhabina.

Advertising - Ads by V. Bogdanovich.

Interview - Interview with Nikolay Rodionov, author of popular books for the ZX Spectrum

For Coderz - The calculation of trigonometric and algebraic functions in a high-level languages.

DIY - scheme of 16-color video mode v1.1 for the Pentagon.

Iron - Description of Products K555TL2.

For Coderz - Programming device sound generation Turbo Sound.

Softinka - 384x304 viewer. program allows you to view color pictures, is larger than the screen.

Softinka - ZX Spectrum emulator for ZX Spectrum.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Brest news - Who does what and who lives as breathing.
Through the Looking Glass - aliens - who are they?
Intro - Yesterday in Moscow the FunTop'98.

В этот день...   23 November