<commit_before>/*global define*/

define( [

    'virtjs'

], function ( Virtjs ) {

    return Virtjs.ClassUtil.extend( {

        initialize : function ( engine ) {

            this._engine = engine;

            this._engine._options.data.on( 'requestSave', function ( ) {

                if ( ! this._storageName )
                    return ;

                this._engine._options.data.save( this._storageName, {
                    ram : this._engine.environment.mbc3Ram.buffer
                } );

            }.bind( this ) );

        },

        setup : function ( ) {

            this._storageName = this._engine.environment.ident ? this._engine.environment.ident + '.' : '';
            this._storageName += 'cartridge';

            var saved = this._engine._options.data.restore( this._storageName ) || { };

            this._engine.environment.mbc3Mode = 0x00;
            this._engine.environment.mbc3RamFeature = false;

            this._engine.environment.mbc3Ram = new Uint8Array( saved.ram || new ArrayBuffer( 0x8000 ) );
            this._engine.environment.mbc3Rtc = new Uint8Array( 5 );
            this._engine.environment.mbc3Latch = new Uint8Array( 1 );

            this._engine.environment.mbc3RomBank = 0x01;
            this._engine.environment.mbc3RamBank = 0x00;

            this._romBanks = [ ];
            for ( var romBank = 0; romBank * 0x4000 < this._engine.environment.rom.buffer.byteLength; ++ romBank )
                this._romBanks[ romBank ] = new Uint8Array( this._engine.environment.rom.buffer, romBank * 0x4000, 0x4000 );

            this._ramBanks = [ ];
            for ( var ramBank = 0; ramBank * 0x2000 < this._engine.environment.mbc3Ram.buffer.byteLength; ++ ramBank )
                this._ramBanks[ ramBank ] = new Uint8Array( this._engine.environment.mbc3Ram.buffer, ramBank * 0x2000, 0x2000 );

            this._romBank00 = this._romBanks[ 0x00 ];
            this._romBankNN = null;
            this._ramBankNN = null;

            this._rebank( );<commit_msg>Makes 'data' device optional<commit_after>/*global define*/

define( [

    'virtjs'

], function ( Virtjs ) {

    return Virtjs.ClassUtil.extend( {

        initialize : function ( engine ) {

            this._engine = engine;

            if ( this._engine._options.data ) {
                this._engine._options.data.on( 'requestSave', function ( ) {

                    if ( ! this._storageName )
                        return ;

                    this._engine._options.data.save( this._storageName, {
                        ram : this._engine.environment.mbc3Ram.buffer
                    } );

                }.bind( this ) );
            }

        },

        setup : function ( ) {

            this._storageName = this._engine.environment.ident ? this._engine.environment.ident + '.' : '';
            this._storageName += 'cartridge';

            var saved = this._engine._options.data
                ? this._engine._options.data.restore( this._storageName ) || { }
                : { };

            this._engine.environment.mbc3Mode = 0x00;
            this._engine.environment.mbc3RamFeature = false;

            this._engine.environment.mbc3Ram = new Uint8Array( saved.ram || new ArrayBuffer( 0x8000 ) );
            this._engine.environment.mbc3Rtc = new Uint8Array( 5 );
            this._engine.environment.mbc3Latch = new Uint8Array( 1 );

            this._engine.environment.mbc3RomBank = 0x01;
            this._engine.environment.mbc3RamBank = 0x00;

            this._romBanks = [ ];
            for ( var romBank = 0; romBank * 0x4000 < this._engine.environment.rom.buffer.byteLength; ++ romBank )
                this._romBanks[ romBank ] = new Uint8Array( this._engine.environment.rom.buffer, romBank * 0x4000, 0x4000 );

            this._ramBanks = [ ];
            for ( var ramBank = 0; ramBank * 0x2000 < this._engine.environment.mbc3Ram.buffer.byteLength; ++ ramBank )
                this._ramBanks[ ramBank ] = new Uint8Array( this._engine.environment.mbc3Ram.buffer, ramBank * 0x2000, 0x2000 );

            this._romBank00 = this._romBanks[ 0x00 ];
            this._romBankNN = null;
            this._ramBankNN = null;

            this._rebank( );
{'fraction_non_alphanumeric': 0.11494796594134342, 'fraction_numerical': 0.03216650898770104, 'mean_word_length': 1.8401611820013433, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016453', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1188, 'n_words': 208}