--------------------------------------------
- Emu71 filelist		18/04/2023 -
--------------------------------------------

- CHECKBOX.BMP

checkbox bitmap for debugger

- COLOR.H

color definitions used in debugger

- CURSOR.C

Function CreateHandCursor(), GUI hand cursor for Win9x/Me/NT 4.0 OS

- DBGTOOL.BMP

toolbar of debugger

- DEBUGGER.C
- DEBUGGER.H

debugger implementation

- DISASM.C

Function disassemble(), the 1LK7 disassembler, the opcodes of the "level 2"
instructions (1LR2) are remarked

- DISMEM.C

Function SetMemMapType(), set the new memory mapping mode for debug view

Function GetMemMapType(), get the current memory mapping mode

Function GetMemDataSize(), get current memory mapping size

Function GetMemNib(), get nibble from current memory mapping

Function GetMemPeek(), get data from current memory mapping

- DISPLAY.C

Function UpdateContrast(), copy the display background to hBmpBkDC and create
the drawing brush for pixel switched on depending of the display contrast
setting

Function SetLcdColor(), save the Color definitions of the KML script section LCD

Function GetSizeLcdBitmap(), return the current size of the display area without
annunciators

Function CreateLcdBitmap(), create the display drawing resources

Function DestroyLcdBitmap(), destroy the display drawing resources

Function CreateMainBitmap(), create a DC of the KML background bitmap

Function DestroyMainBitmap(), delete DC of the KML background bitmap

Function WritePixelZoom4(), pixel draw when KML Zoom factor is 4

Function WritePixelZoom3(), pixel draw when KML Zoom factor is 3

Function WritePixelZoom2(), pixel draw when KML Zoom factor is 2

Function WritePixelZoom1(), pixel draw when KML Zoom factor is 1

Function WritePixelDWORD(), pixel draw when KML Zoom factor is a multiple of 4

Function WritePixelWORD(), pixel draw when KML Zoom factor is a multiple of 2

Function WritePixelBYTE(), pixel draw when KML Zoom factor is a multiple of 1

Function WriteDisplayCol(), draw a display column

Function UpdateMainDisplay(), dot matrix main display drawing routine

Function UpdateAnnunciators(), scan the state of all annunciators and redraw
them

Function LcdProc(), callback function of multimedia timer to redraw the dot
matrix part of the main display

Function StartDisplay(), starts the multimedia timer to redraw the dot matrix
display part

Function StopDisplay(), stops the multimedia timer redrawing the dot matrix
display part

Function ResizeWindow(), adjust the background window size

- E71files.txt

this file

- EMU42.ICO

the Emu42 program icon

- EMU71.C

Function SetWindowTitle(), writes new window title

Function ForceForegroundWindow(), force my windows into foreground

Function UpdateWindowBars(), helper function to switch title and menu bar
on/off

Function CopyItemsToClipboard(), save selected Listbox Items to Clipboard

Function SettingsProc(), message handler of the modal "Settings" dialog

Function SaveChanges(), helper function for saving the state file

Function OnCreate(), implementation for WM_CREATE message (called when main
window is created)

Function OnDestroy(), implementation for WM_DESTROY message (called when main
window is destroyed)

Function OnPaint(), implementation for WM_PAINT message (called when main
window must be redrawed)

Function OnInitMenu(), update the state of main menu items (grayed / enabled)

Function OnFileNew(), implementation for ID_FILE_NEW message "File/New..."

Function OnFileOpen(), implementation for ID_FILE_OPEN message "File/Open..."

Function OnFileMruOpen(), implementation for ID_FILE_MRU_FILE1 message
"File/MRU entry"

Function OnFileSave(), implementation for ID_FILE_SAVE message "File/Save"

Function OnFileSaveAs(), implementation for ID_FILE_SAVEAS message "File/Save
As..."

Function OnFileClose(), implementation for ID_FILE_CLOSE message "File/Close"

Function OnFileExit(), implementation for ID_FILE_EXIT or WM_SYS_CLOSE message
"File/Exit"

Function OnViewCopy(), implementation for ID_VIEW_COPY message "Edit/Copy
Screen"

Function OnViewReset(), implementation for ID_VIEW_RESET message
"Edit/Reset Calculator"

Function OnViewSettings(), implementation for ID_VIEW_SETTINGS message
"File/Settings"

Function OnViewScript(), implementation for ID_VIEW_SCRIPT message
"View/Change KML Script..."

Function OnBackupSave(), implementation for ID_BACKUP_SAVE message
"Edit/Backup/Save"

Function OnBackupRestore(), implementation for ID_BACKUP_RESTORE message
"Edit/Backup/Restore"

Function OnBackupDelete(), implementation for ID_BACKUP_DELETE message
"Edit/Backup/Delete"

Function Disasm(), message handler of the modal "Disassembler" dialog

Function About(), message handler of the modal "About" dialog

Function OnToolDisasm(),  implementation for ID_TOOL_DISASM message
"Tools/Disassembler..."

Function OnTopics(), implementation for ID_HELP_TOPICS message
"Help/Help Topics"

Function OnAbout(), implementation for ID_ABOUT message
"Help/About Emu71..."

Function OnContextMenu(), implementation for the context menu message

Function OnNcHitTest(), implementation for the mouse hit message

Function OnLButtonDown(), implementation for button down message

Function OnLButtonUp(), implementation for button up message

Function OnMouseMove(), implementation for mouse moving message

Function OnNcMouseMove(), implementation for mouse moving message

Function OnKeyDown(), implementation for key down message

Function OnKeyUp(), implementation for key up message

Function MainWndProc(), message handler for main window

Function WinMain(), the main program entry

- EMU71.DSP
- EMU71.DSW

the makefile

- EMU71.H

the central header file for the global stuff:
global definitions, declaration of global variables und functions

- EMU71.ICO

the HP71B program icon

- EMU71.RC

the windows resource file

EMU71.XML

the resource for enabling the WinXP dialog style

- ENGINE.C

Function SaveInstrAddr(), save last instruction in circular instruction buffer

Function Debugger(), the debugger part for the CPU emulation loop checking
breakpoints, ...

Function SuspendDebugger(), suspends the debugger control stuff

Function ResumeDebugger(), resume the debugger control stuff

Function AdjustSpeed(), slow down emulated CPU speed to "real" speed

Function InitAdjustSpeed(), init references for CPU slow down

Function AdjKeySpeed(), slow down key repeat

Function SetSpeed(), set emulation speed (real / fast)

Function WaitForSleepState(), wait for cpu SHUTDN then sleep state

Function SwitchToState(), function called by the windows message thread to
change the state of the CPU emulation worker thread

Function WorkerThread(), the CPU emulation worker thread

- FETCH.C

the Saturn opcode dispatcher

Function EvalOpcode(), decode 1LK7 opcodes, the opcodes of the "level 2"
instructions (1LR2) are remarked

- FILES.C

Function SetWindowLocation(), move main window to a given position

Function GetCutPathName(), cut a full path filename to a shorter readable
form, used in the MRU list or as title for windows

Function SetWindowPathTitle(), writes a cut filename as main windows title

Function MapFile(), generic file mapping, if the file contain packed data,
unpack it

Function UnmapFile(), free the memory of the mapped file

Function Checksum(), calculate the checksum of the ROM section

Function CorrectChecksum(), correct the checksum of the ROM section

Function RebuildRomChecksum(), rebuild the checksum of all four ROM sections

Function Asc2Nib(), convert ASCII 0-9, A-F to value

Function PatchRom(), reads a patch file and patch the calculator at the
given addresses, finally correct the ROM checksums

Function CrcRom(), calculate fingerprint of ROM (a WORD checksum)

Function MapRom(), load the ROM file into memory and on a packed ROM unpack
it

Function UnmapRom(), free the memory allocated with MapRom()

Function IsDataPacked(), check if data area contain packed data (2 nibbles
per byte)

Function CalcWarmstart(), if calculator ROM enabled do a warmstart else a
coldstart

Function ResetPortModule(), delete a single module in a port line

Function ResetPortData(), universal function to delete a port line

Function ResetDocument(), reset document (state file data)

Function NewDocument(), create a new document (state file data)

Function OpenDocument(), open an existing document (state file data)

Function SaveDocument(), save the current document (state file data)

Function SaveDocumentAs(), save the current document (state file data) in
a new/given file

Function SaveBackup(), make a backup of the current document data

Function RestoreBackup(), restore a backup of document data

Function ResetBackup(), delete the backup document data

Function InitializeOFN(), helper function to initialize a file dialog box

Function GetOpenFilename(), dialog to open a document file

Function GetSaveAsFilename(), dialog to save a document file

Function LoadIconFromFile(), load icons from file and activate them

Function LoadIconDefault(), activate the window class default icons

Function DibNumColors(), calculate the number of colors inside the Device
Independent Bitmap

Function CreateBIPalette(), create a color palette of the bitmap for non
true color output devices

Function DecodeBmp(), load and decode a BMP file image

Function ReadGifByte(), read a byte from a GIF file

Function ReadGifWord(), read a word from a GIF file

Function DecodeGif(), load and decode a GIF file image

Function DecodePng(), wrapper for decoding a PNG file image

Function LoadBitmapFile(), load and decode a BMP, GIF or PNG background image

Function AbsColorCmp(), Abs summation color compare with tolerance

Function LabColorCmp(), CIE L*a*b color compare with tolerance

Function EncodeColorBits(), returning bitfield position encoded color bits

Function CreateRgnFromBitmap(), create region for transparent color handling

- HPIL.C
- HPIL.H

This module emulates the HPIL mailbox interface and the I/O processor

Function InitIoMem(), basic initialization of I/O processor memory

Function ResetHpilData(), resetting parts of the the I/O processor memory

Function CreateHpilThread(), create the two worker threads for data receive and
I/O processor

Function DestroyHpilThread(), destroy the two worker threads for data receive
and I/O processor

Function IoThread(), the I/O processor worker thread

Function AllocHpilMem(), create an instance of a HPIL mailbox

Function IsModuleHpilMem(), check if CPU address handled this module

Function ConfigHpilMem(), configure module (CONFIG)

Function UncnfgHpilMem(), unconfigure module (UNCNFG)

Function ResetHpilMem(), reset module (RESET)

Function C_Eq_IdHpilMem(), fetch ID (C=ID)

Function WriteIOHpilMem(), write data to the HPIL mailbox

Function ReadIOHpilMem(), read data frim the HPIL mailbox

Function DetachHpilMem(), remove the HPIL mailbox from the HP71B port and free
the memory of the instance

Function AttachHpilMem(), attach an instance of a HPIL mailbox to one external
HP71B port

HPILBUF.C

This module implements the HPIL I/O input/output buffer handling.

!!! no further documentation at the moment !!!

HPILCMD.C

This module implements the HPIL I/O processor command set.

!!! no further documentation at the moment !!!

HPILDEV.C

This module implements the HPIL device mode (incomplete)

!!! no further documentation at the moment !!!

- IO.H

address and bit definitions of the HP71B

- KEYBOARD.C

Function Keyboard_GetIR(), keyboard function return the "IN" line content of
all "OUT" rows

Function ScanKeyboard(), update the CPU "IN" register called from various
opcodes affecting this register or from the windows message thread detected
a state change of the calculator keyboard

Function KeyboardEvent(), called from the windows message thread detected
a state change of the calculator keyboard

- KEYMACRO.C

Helper functions for "Tools/Macro/..." menu items

Function InitializeOFN(), helper function to initialize a file dialog box

Function EventThread(), worker thread playing recorded keys

Function KeyMacroRecord(), recording calculator keyboard changes

Function OnToolMacroNew(), implementation for ID_TOOL_MACRO_RECORD message
"Tools/Macro/Record..." for recording a keyboard macro

Function OnToolMacroPlay(), implementation for ID_TOOL_MACRO_PLAY message
"Tools/Macro/Play..." for play keyboard macro

Function OnToolMacroStop(), implementation for ID_TOOL_MACRO_STOP message
"Tools/Macro/Stop" for stop recording/playing of keyboard macro

Function SliderEnable(), activate/deactivate slider in Macro Settings dialog

Function MacroProc(), message handler of the modal "Macro Settings" dialog

Function OnToolMacroSettings(), implementation for ID_TOOL_MACRO_SETTINGS
message "Tools/Macro/Settings..."

KML.C
KML.H

the KML script parser which is almost identical to all other emulators. It's
not absolutely necessary to understand this section to understand the hardware
emulation as a whole. This part is quite huge I'll try to make a description
later.

I only want to mention Function KillKML() which is called when a Document file
is closed. This is a good place to preset global variables to there default
state at startup.

LODEPNG.C
LODEPNG.H

external module decoding PNG images

MOPS.C

Function NextUncfg(), scan through all 1LG8 main memory chips and return TRUE,
the 4K hybrid and the 1LG8 chip no. of the next unconfigured module or if
all modules are configured the function return FALSE.

Table RMap[], this is the MMU read page table for the covered port technology.
The module with the highest priority fills the page table entry with a memory
address pointing to the reserved memory of the resouce. If the page table
entry is NULL there's no module configured to this address range.

Table WMap[], this is the MMU write page table for the covered port technology.
The module with the highest priority fills the page table entry with a memory
address pointing to the reserved memory of the resouce. If the page table
entry is NULL there's no module configured to this address range.

With this two tables I control also if the memory is RAM or ROM. In the RAM
case, the table entry is filled in both RMap[] and WMap[] tables, if the
module is a ROM, only the RMap[] table entry is filled, the RMap[] table entry
is still NULL.

Function MapDDC(), map one hard configured 1LF3 chip into the MMU tables

Function MapIRam(), map one soft configured 1LG8 chip into the MMU tables

Function MapROM(), map the hard configured 1LG7 ROM chip into the MMU tables

Function Map(), remap all memory modules in the given address range. Modules
configured first have the lower priority than the one behind. In my case,
!!I don't know the priority of the real machine!!, the ROM has the lowerst
priority, than the 1LF3 chips and finally with the highest priority the 1LG8
chips, with the last chip has the highest one.

Function MountPorts(), mount all port modules to the Saturn bus

Function DismountPorts(), dismount all port modules from the Saturn bus

Function IoModuleId(), returns the I/O module ID for the given module size in
nibbles

Function MemModuleId(), returns the RAM module ID for the given module size in
nibbles

Function Config(), implementation of the Saturn CONFIG opcode

Function Uncnfg(), implementation of the Saturn UNCNFG opcode

Function Reset(), implementation of the Saturn RESET opcode

Function C_Eq_Id(), implementation of the Saturn C=ID opcode

Function SREQ(), general function to capture the service requests from the
modules (this function was necessary to synchronize the main CPU with the
HP-IL I/O CPU)

Function CpuReset(), emulates a CPU hardware reset. Problem on the HP71B, a
restart of the HP71B firmware at address 00000 cause a "Memory Lost"

Function GetPortModule(), get port module descriptor which is mapping the
given CPU address

Function MapData(), return the module which is mapped to the given address

Function NreadEx(), read or peek data from mapped calculator memory. The
difference between "peek" and "read" is, that "peek" don't update any data
in the IORam section. In Emu71 the only difference at the moment is updating
the battery state when using "read"

Function Npeek(), wrapper for peeking data from mapped calculator memory

Function Nrad(), wrapper for reading data from mapped calculator memory

Function Nwrite(), write data into mapped calculator memory

Function Read5(), peek packed 5 nibble data from calculator memory

Function Read2(), peek packed 2 nibble data from calculator memory

Function Write5(), write packed 5 nibble data to calculator memory

Function Write2(), write packed 2 nibble data to calculator memory

Function ChangeBit(), thread safe set/clear bit in a byte

Function UpdateBatState(), update the LBI and VLBI bits of the DD1CTL register

Function UpdateSreq(), update the service request register for timer service
POLL

Function TAcc(), checking timer access for CPU speed measurement behaviour

Function ReadIO(), read IO registers of the given 1LF3 chip

Function WriteIO(), write IO registers to the given 1LF3 chip

- MRU.C

MRU (Most Recent Used) file utilities.

Function GetMenuPosForId(), look for menu position of the given ID_FILE_MRU_...
item

Function MruInit(), initialize the MRU system, the argument are the number of
MRU slots to handle

Function MruCleanup(), free the MRU system initialized with MruInit()

Function MruAdd(), add a string to the MRU list

Function MruRemove(), remove the string at the given index position from the
MRU list

Function MruMoveTop(), move the string at the given index position to the top
of the MRU list

Function MruEntries(), return the number of actual MRU entries

Function MruID(), return index position for given MRU string (filename)

Function MruFilename(), return the MRU string (filename) of the given index
position

Function MruUpdateMenu(), update the windows menu system with the actual
content of my MRU table

Function MruWriteList(), write the actual MRU list content to the windows
registry

Function MruReadList(), fill the MRU list content with data from the windows
registry

- OPCODES.C
- OPCODES.H

the Saturn opcode implementations

- OPS.H

Saturn helper functions mostly used by OPCODES.C

- PCH.C
- PCH.H

Precompiled headers to reduce compiler turnaround time.

- PNGCRC.C

Function lodepng_crc32(), calculate CRC used by PNG decoder

- PORTCFG.C

Function CfgModule(), search for the not applied module in the daisy chain

Function LoadCurrPortConfig(), load current port config data from main
program into settings area

Function SaveCurrPortConfig(), save port config data from settings area to
main program

Function Cleanup(), free all port config data memory

Function ShowPortConfig(), show modules in the given daisy chain

Function OnAddPort(), add a port setting to the the daisy chain

Function DelPort(), delete all port config data from the given port

Function DelPortCfg(), delete the not applied module from the given port

Function ApplyPort(), message handler of the "Apply" button, save current
not applied module to port config data area

Function GetOpenImageFile(), basic implementation for the "File open" dialog

Function GetSaveImageFile(), basic implementation for the "File Save As" dialog

Function OnBrowse(), message handler of the "Browse" button, open "File open"
dialog and update filename window

Function OnPortCfgDataLoad(), implementation for ID_PORTCFG_DATA_LOAD message
called by the context menu

Function OnPortCfgDataSave(), implementation for ID_PORTCFG_DATA_SAVE message
called by the context menu

Function OnPortCfgTcpIpSettings(), implementation for ID_PORTCFG_TCPIP_SETTINGS
message called by the context menu

Function OnContextMenu(), implementation for WM_CONTEXTMENU message (called
on context menu request)

Function TcpIpSettingsProc(), message handler of the modal
"HP-IL Interface Setup" dialog

Function OnEditTcpIpSettings(), implementation for the
"HP-IL Interface Setup" dialog called over button or context menu

Function PortSettingsProc(), message handler of the modal
"Port Configuration" dialog

Function OnEditPortConfig(), implementation for ID_EDIT_PORTCONFIG message
"Edit/Port configuration..."

PORTMEM.C
PORTMEM.H

This module is the constructor for the port interface callback functions.

Function IsModuleMem(), CPU address is not handled by this module

Function MapMem(), no pages to map into the Saturn address area

Function ConfigMem(), module not configured (CONFIG)

Function UncnfgMem(), module not unconfigured (UNCNFG)

Function SReqMem(), service request of module

Function ResetMem(), nothing to reset (RESET)

Function C_Eq_IdMem(), module is configured (C=ID)

Function AllocPortMem(), allocate memory for port interface and preset
some methods that may not be overloaded

- RESOURCE.H

the resource definitions for the windows resource file.

- SATMEM.C
- SATMEM.H

This module supports the handling of external RAM and ROM chips.

Function AllocSaturnMem(), create an instance of an external memory module

Function IsModuleSaturnMem(), check if CPU address handled this module

Function MapSaturnMem(), map pages into the Saturn address area

Function ConfigSaturnMem(), configure module (CONFIG)

Function UncnfgSaturnMem(), unconfigure module (UNCNFG)

Function ResetSaturnMem(), reset module (RESET)

Function C_Eq_IdSaturnMem(), fetch ID (C=ID)

Function DetachSaturnMem(), remove the external memory module from the HP71B
port and free the memory of the instance

Function AttachSaturnMem(), attach the instance of an external memory module
to one external HP71B port

- SETTINGS.C

saving and loading the general emulator settings. This data can be saved in

%windir%\Emu71.ini

or in the registry under

"HKCU\Software\Emu71"

the switch is controlled by the define REGISTRY. In the makefile REGISTRY is
defined so Emu71 save the data under "HKCU\Software\Emu71". With the
additional definition REGISTRYKEY in the makefile a different HKCU can be
defined without changing the source code.

In this discription I skip the section of the "Low level subroutines"
which read or write the settings to the choosen place

Function ReadSettings(), read most of the emulator settings into global
variables

Function WriteSettings(), write most of the general settings

Function ReadLastDocument(), reading the "LastDocument" setting

Function WriteLastDocument(), writing the "LastDocument" setting

The following general access functions are mainly used by the MRU module.
Normally the program parts should not modifiy the registry directly over
general access functions. They normally should load and save there global
variables over the ReadSettings() and WriteSettings() functions.

Function ReadSettingsString(), read a string from registry/ini file

Function WriteSettingsString(), write a string to the registry/ini file

Function ReadSettingsInt(), read an integer from registry/ini file

Function WriteSettingsInt(), write an integer to the registry/ini file

Function DelSettingsKey(), delete an entry in the registry/ini file

- SNDDEF.H

definitions for the DirectSound interface.

- SNDENUM.C

Function DirectSoundPrivateCreate(), create a IKsPropertySet interface

Function GetInfoFromDSoundGUID(), get the device information about a
DirectSound GUID

Function DSEnumProc(), callback function for DirectSoundEnumerate()

Function SetSoundDeviceList(), set list field for sound device combo box

- SOUND.C

native beeper support.

Function SoundWndProc(), sound message handler thread

Function CreateWaveThread(), create the sound message handler thread

Function DestroyWaveThread(), destroy the sound message handler thread

Function AddSoundBuf(), add sample buffer to tail of sample job list

Function GetSoundBuf(), remove sample buffer from head of sample job list

Function GetSoundBufSize(), number of sample buffers in sample job list

Function AllocSample(), allocate new sample buffer and add the buffer to the
tail of the sample job list

Function AddSamples(), write samples to sample buffer

Function FlushSample(), write sample buffer from head of sample job list to
waveform-audio output device and delete the sample buffer control from head of
sample job list

Function SoundAvailable(), checks if waveform-audio output device is available

Function SoundGetDeviceID(), get the device ID of the current waveform-audio
output device

Function SoundOpen(), open waveform-audio output device

Function SoundClose(), purge the sample job list, discard pending wave headers
and close waveform-audio output device

Function WaveLevel(), calculate the wave level from the beeper bit state

Function SoundOut(), beeper emulation main entry decoding the change of beeper
OUT bits, filling the sample buffers and starting the wave output

Function SoundBeep(), simple beeper implementation with frequency and duration
argument

- STACK.C

implementation of "Edit/Copy Stack" and "Edit/Paste Stack".

Function GetSystemFlag(), read if system flag is set or cleared

Function DspRedraw(), redraw the content of the display buffer

Function OnStackCopy(), copy the content of the display buffer to the clipboard

Function OnStackPaste(), paste the content of the clipboard to the display
buffer. In calculation mode this fail, because the input interpreter is
missing.

- SYMBFILE.C

translate an address to a symbol name.

Function GetHash(), get a hash of the address for the entry in the linked
list table.

Function GetBigEndian(), read a number saved in big endian format

Function RplTableEmpty(), check if entry table is empty

Function RplLoadTable(), append entry table saved in Saturn3 object format
to the current linked list table (entry point table compiled with sasm -N
with sasm version v3.x)

Function RplDeleteTable(), delete the linked list entry table

Function RplGetName(), return name for given entry address

Function RplGetAddr(), return entry address for given name

- TCPIP.C
- TCPIP.H

This module implements a TCP/IP client and server for the virtual HPIL loop.

Function TcpSendFrame(PTCPIP p, WORD wFrame), send HPIL frame over TCP/IP

Function ThreadTcpIpServer(), the TCP/IP server thread receiving virtual
IL frames

Function StartServer(), initialize the IPv4 socket

Function StopServer(), shutdown the TCP/IP server thread

Function TcpInit(PTCPIP p), init variables of a TCP/IP instance

Function TcpCreateSvr(PTCPIP p), create a TCP/IP server instance

Function TcpCloseSvr(PTCPIP p), close and delete the TCP/IP server instance

Function HpilController(), send and receive a IL frame as controller over
the loop

Function HpilDevice(), receive IL frame as device, eval it, and send it to
the next device

- TIMER.C

Function SetHPTime(), poke the current time into the =NEXTIRQ calculator
memory address, that DATE and TIME return the current time at startup

Function TimeProc(), callback function of multimedia timer to update the
timer value in all three 1LF3 chips

Function StartTimers(), starts the multimedia timer to update the timer
registers

Function StopTimers(), stops the multimedia timer to update the timer
registers

- TYPES.H

the CHIPSET structure holding the CPU state and the content of the internal
RAMs

one remark to the following structure:

// RAM Chip
typedef struct
{
    BYTE  Ram[4*2048];	// user RAM (4 modules with 2K nibble)
    WORD  Base[4];	// base address of module
    BOOL  bCfg[4];	// module configuration flag
} C1LG8;

normally something like

// RAM Chip
typedef struct
{
    BYTE  Ram[2048];	// user RAM (2K nibble)
    WORD  Base;		// base address of module
    BOOL  bCfg;		// module configuration flag
} C1LG8SGLE;

typedef struct
{
    C1LG8SGLE chip[4];	// 4 internal modules
} C1LG8;

would be more readable. The 2nd construct has the disadvantage that
the internal memory isn't allocated as a single block.

Every emulator has the sentence

- executing an opcode over a MMU boundary will fail

in the PROBLEMS.TXT file. In Emu42 and Emu48 this isn't critical.
Because what means this sentence?

Normally memory for a module is allocated as a single block. So the RMap table
in Emu71 may look like this

RMap[20] = 0x000FCA00
RMap[21] = 0x000FCB00
RMap[22] = 0x000FCC00
RMap[23] = 0x000FCD00

Every table entry points to different addresses in the same linear memory
block. So it doesn't matter if you read 16 bytes from 0x000FCBFD. To be
correct you normally have to read 3 bytes 0x000FCBFD, 0x000FCBFE and
0x000FCBFF from page 21 and the next 13 bytes from address pointed my page 22.

Let us expand the example above, at page 24 begin a new memory module, so the
RMap may look like this

RMap[20] = 0x000FCA00
RMap[21] = 0x000FCB00
RMap[22] = 0x000FCC00
RMap[23] = 0x000FCD00
RMap[24] = 0x000B7100
RMap[25] = 0x000B7200

in this case reading 16 byte from 0x000FCDFD will fail. But the Saturn opcode
decoder exacly access the memory like this for speed reasons. Addressing an
opcode nibble over page and offset address is too slow or much slower than the
current solution.

On the other hand in Emu71 the internal RAM is allocated in different blocks
which build a linear address area in the calculator memory view. This already
happend in Emu28 with the memory in the Master and in the Slave chip. When
now an opcode begin at the end of a memory allocation, the continue is in a
different memory alloaction.

Why is this isn't relevant for example for the HP48SX. In the HP48SX this
situation would mean, the opcode may begin at the end of the internal 32KB RAM
and continue in the Port1 memory. Maybe this already be happen, if the Port1
memory is merged to the internal RAM?

To solve this all versions of the emulators have a modified FASTPTR()
implementaion in OPS.H. Before the function return the linear address area,
it checks if the opcode is at the end of the page and the memory address of the
next page points to the same allocated memory block. If not, the data is copied
to a linear address area and decoded from there. From this aspect it's useful
to have large allocated memory blocks.
