(self, total_memory, reserved_memory, max_reclen, max_files, double)
Initialise memory.
Initialise memory.
Initialise memory .
def __init__(self, total_memory, reserved_memory, max_reclen, max_files, double):
        """Initialise memory."""
        # BASIC stack (determined by CLEAR)
        # Initially, the stack space should be set to 512 bytes,
        # or one-eighth of the available memory, whichever is smaller.
        self.stack_size = 512
        # total size of data segment (set by CLEAR)
        self.total_memory = total_memory
        # first field buffer address (workspace size; 3429 for gw-basic)
        self._field_mem_base = reserved_memory
        # file header (at head of field memory)
        file_header_size = 194
        # bytes distance between field buffers
        self._field_mem_offset = file_header_size + max_reclen
        # start of 1st field =3945, includes FCB & header header of 1st field
        self._field_mem_start = self._field_mem_base + self._field_mem_offset + file_header_size
        # data memory model: start of code section
        # code_start+1: offsets in files (4718 == 0x126e)
        self.code_start = self._field_mem_base + (max_files+1) * self._field_mem_offset
        # default sigils for names
        self.deftype = [values.SNG]*26
        # string space
        self.strings = values.StringSpace(self)
        # prepare string and number handler
        self.values = values.Values(self.strings, double)
        # scalar space
        self.scalars = scalars.Scalars(self, self.values)
        # array space
        self.arrays = arrays.Arrays(self, self.values)
        # temporary values
        self._stack = []
        # FIELD buffers
        self.max_files = max_files
        self.max_reclen = max_reclen
        # fields are indexed by BASIC file number, hence max_files+1
        # file 0 (program/system file) probably doesn't need a field
        self.fields = {
            _i + 1: Field(
                self.max_reclen, self._field_mem_start + _i * self._field_mem_offset, self
            )
            for _i in range(self.max_files)
        }
        # garbage collection switch
        self._allow_collect = True
def __init__ ( self , total_memory , reserved_memory , max_reclen , max_files , double ) : # BASIC stack (determined by CLEAR) # Initially, the stack space should be set to 512 bytes, # or one-eighth of the available memory, whichever is smaller. self . stack_size = 512 # total size of data segment (set by CLEAR) self . total_memory = total_memory # first field buffer address (workspace size; 3429 for gw-basic) self . _field_mem_base = reserved_memory # file header (at head of field memory) file_header_size = 194 # bytes distance between field buffers self . _field_mem_offset = file_header_size + max_reclen # start of 1st field =3945, includes FCB & header header of 1st field self . _field_mem_start = self . _field_mem_base + self . _field_mem_offset + file_header_size # data memory model: start of code section # code_start+1: offsets in files (4718 == 0x126e) self . code_start = self . _field_mem_base + ( max_files + 1 ) * self . _field_mem_offset # default sigils for names self . deftype = [ values . SNG ] * 26 # string space self . strings = values . StringSpace ( self ) # prepare string and number handler self . values = values . Values ( self . strings , double ) # scalar space self . scalars = scalars . Scalars ( self , self . values ) # array space self . arrays = arrays . Arrays ( self , self . values ) # temporary values self . _stack = [ ] # FIELD buffers self . max_files = max_files self . max_reclen = max_reclen # fields are indexed by BASIC file number, hence max_files+1 # file 0 (program/system file) probably doesn't need a field self . fields = { _i + 1 : Field ( self . max_reclen , self . _field_mem_start + _i * self . _field_mem_offset , self ) for _i in range ( self . max_files ) } # garbage collection switch self . _allow_collect = True