v86 0.5.244 → 0.5.246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/libv86-debug.js +12 -8
- package/build/libv86-debug.mjs +80 -80
- package/build/libv86.js +7 -7
- package/build/libv86.mjs +233 -232
- package/package.json +1 -1
package/build/libv86-debug.js
CHANGED
|
@@ -8208,8 +8208,8 @@ $FloppyDrive$$module$src$floppy$$.prototype.set_state = function($state$jscomp$4
|
|
|
8208
8208
|
};
|
|
8209
8209
|
const $ATA_CMD_NAME$$module$src$ide$$ = {[8]:"DEVICE RESET", [144]:"EXECUTE DEVICE DIAGNOSTIC", [231]:"FLUSH CACHE", [234]:"FLUSH CACHE EXT", [218]:"GET MEDIA STATUS", [236]:"IDENTIFY DEVICE", [161]:"IDENTIFY PACKET DEVICE", [225]:"IDLE IMMEDIATE", [145]:"INITIALIZE DEVICE PARAMETERS", [222]:"MEDIA LOCK", [0]:"NOP", [160]:"PACKET", [200]:"READ DMA", [37]:"READ DMA EXT", [41]:"READ MULTIPLE", [196]:"READ MULTIPLE EXT", [248]:"READ NATIVE MAX ADDRESS", [39]:"READ NATIVE MAX ADDRESS EXT", [32]:"READ SECTORS",
|
|
8210
8210
|
[36]:"READ SECTORS EXT", [64]:"READ VERIFY SECTORS", [245]:"SECURITY FREEZE LOCK", [239]:"SET FEATURES", [249]:"SET MAX", [198]:"SET MULTIPLE MODE", [224]:"STANDBY IMMEDIATE", [202]:"WRITE DMA", [53]:"WRITE DMA EXT", [57]:"WRITE MULTIPLE", [197]:"WRITE MULTIPLE EXT", [48]:"WRITE SECTORS", [52]:"WRITE SECTORS EXT", [16]:"<UNKNOWN 10h>", [240]:"<VENDOR-SPECIFIC F0h>", }, $ATAPI_CMD$$module$src$ide$$ = {[70]:{name:"GET CONFIGURATION", flags:0}, [74]:{name:"GET EVENT STATUS NOTIFICATION", flags:0}, [18]:{name:"INQUIRY",
|
|
8211
|
-
flags:0}, [189]:{name:"MECHANISM STATUS", flags:0}, [26]:{name:"MODE SENSE (6)", flags:0}, [90]:{name:"MODE SENSE (10)", flags:0}, [69]:{name:"PAUSE", flags:1}, [30]:{name:"PREVENT ALLOW MEDIUM REMOVAL", flags:0}, [40]:{name:"READ", flags:1}, [37]:{name:"READ CAPACITY", flags:1}, [190]:{name:"READ CD", flags:1}, [81]:{name:"READ DISK INFORMATION", flags:1}, [66]:{name:"READ SUBCHANNEL", flags:1}, [67]:{name:"READ TOC PMA ATIP", flags:1}, [82]:{name:"READ TRACK INFORMATION",
|
|
8212
|
-
flags:0}, [27]:{name:"START STOP UNIT", flags:0}, [0]:{name:"TEST UNIT READY", flags:1}, };
|
|
8211
|
+
flags:0}, [189]:{name:"MECHANISM STATUS", flags:0}, [26]:{name:"MODE SENSE (6)", flags:0}, [90]:{name:"MODE SENSE (10)", flags:0}, [69]:{name:"PAUSE", flags:1}, [30]:{name:"PREVENT ALLOW MEDIUM REMOVAL", flags:0}, [40]:{name:"READ (10)", flags:1}, [168]:{name:"READ (12)", flags:1}, [37]:{name:"READ CAPACITY", flags:1}, [190]:{name:"READ CD", flags:1}, [81]:{name:"READ DISK INFORMATION", flags:1}, [66]:{name:"READ SUBCHANNEL", flags:1}, [67]:{name:"READ TOC PMA ATIP", flags:1}, [82]:{name:"READ TRACK INFORMATION",
|
|
8212
|
+
flags:1}, [3]:{name:"REQUEST SENSE", flags:0}, [27]:{name:"START STOP UNIT", flags:0}, [0]:{name:"TEST UNIT READY", flags:1}, };
|
|
8213
8213
|
function $IDEController$$module$src$ide$$($cpu$jscomp$21$$, $bus$jscomp$22_has_primary$$, $command_base0_ide_config$$) {
|
|
8214
8214
|
this.cpu = $cpu$jscomp$21$$;
|
|
8215
8215
|
this.bus = $bus$jscomp$22_has_primary$$;
|
|
@@ -8691,6 +8691,7 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_handle = function() {
|
|
|
8691
8691
|
this.status_reg = 88;
|
|
8692
8692
|
break;
|
|
8693
8693
|
case 40:
|
|
8694
|
+
case 168:
|
|
8694
8695
|
$do_dbg_log$jscomp$1_result$jscomp$21$$ = !1;
|
|
8695
8696
|
this.features_reg & 1 ? this.atapi_read_dma(this.data) : this.atapi_read(this.data);
|
|
8696
8697
|
break;
|
|
@@ -8796,16 +8797,18 @@ $IDEInterface$$module$src$ide$$.prototype.do_write = function() {
|
|
|
8796
8797
|
});
|
|
8797
8798
|
this.report_write(this.data_length);
|
|
8798
8799
|
};
|
|
8799
|
-
$IDEInterface$$module$src$ide$$.prototype.atapi_read = function($cmd$jscomp$
|
|
8800
|
-
var $
|
|
8801
|
-
$cmd$jscomp$
|
|
8800
|
+
$IDEInterface$$module$src$ide$$.prototype.atapi_read = function($cmd$jscomp$2_count$jscomp$58$$) {
|
|
8801
|
+
var $lba_start$jscomp$30$$ = $cmd$jscomp$2_count$jscomp$58$$[2] << 24 | $cmd$jscomp$2_count$jscomp$58$$[3] << 16 | $cmd$jscomp$2_count$jscomp$58$$[4] << 8 | $cmd$jscomp$2_count$jscomp$58$$[5];
|
|
8802
|
+
$cmd$jscomp$2_count$jscomp$58$$ = 168 === $cmd$jscomp$2_count$jscomp$58$$[0] ? $cmd$jscomp$2_count$jscomp$58$$[6] << 24 | $cmd$jscomp$2_count$jscomp$58$$[7] << 16 | $cmd$jscomp$2_count$jscomp$58$$[8] << 8 | $cmd$jscomp$2_count$jscomp$58$$[9] : $cmd$jscomp$2_count$jscomp$58$$[7] << 8 | $cmd$jscomp$2_count$jscomp$58$$[8];
|
|
8803
|
+
var $byte_count$$ = ($cmd$jscomp$2_count$jscomp$58$$ >>> 0) * this.sector_size;
|
|
8804
|
+
$lba_start$jscomp$30$$ *= this.sector_size;
|
|
8802
8805
|
this.data_length = 0;
|
|
8803
8806
|
var $req_length$$ = this.lba_high_reg << 8 & 65280 | this.lba_mid_reg & 255;
|
|
8804
8807
|
this.lba_mid_reg = this.lba_high_reg = 0;
|
|
8805
8808
|
65535 === $req_length$$ && $req_length$$--;
|
|
8806
8809
|
$req_length$$ > $byte_count$$ && ($req_length$$ = $byte_count$$);
|
|
8807
|
-
this.buffer ? $
|
|
8808
|
-
this.
|
|
8810
|
+
this.buffer ? $lba_start$jscomp$30$$ >= this.buffer.byteLength ? ($dbg_assert$$module$src$log$$(!1, this.name + ": CD read: Outside of disk end=" + $h$$module$src$lib$$($lba_start$jscomp$30$$ + $byte_count$$) + " size=" + $h$$module$src$lib$$(this.buffer.byteLength), 32768), this.status_reg = 255, this.push_irq()) : 0 === $byte_count$$ ? (this.status_reg = 80, this.data_pointer = 0) : ($byte_count$$ = Math.min($byte_count$$, this.buffer.byteLength - $lba_start$jscomp$30$$), this.status_reg = 208,
|
|
8811
|
+
this.report_read_start(), this.read_buffer($lba_start$jscomp$30$$, $byte_count$$, $data$jscomp$198$$ => {
|
|
8809
8812
|
this.data_set($data$jscomp$198$$);
|
|
8810
8813
|
this.status_reg = 88;
|
|
8811
8814
|
this.sector_count_reg = this.sector_count_reg & -8 | 2;
|
|
@@ -8818,7 +8821,8 @@ $IDEInterface$$module$src$ide$$.prototype.atapi_read = function($cmd$jscomp$2_st
|
|
|
8818
8821
|
})) : ($dbg_assert$$module$src$log$$(!1, this.name + ": CD read: no buffer", 32768), this.status_reg = 255, this.error_reg = 65, this.push_irq());
|
|
8819
8822
|
};
|
|
8820
8823
|
$IDEInterface$$module$src$ide$$.prototype.atapi_read_dma = function($cmd$jscomp$3_flags$jscomp$12$$) {
|
|
8821
|
-
var $lba$jscomp$1$$ = $cmd$jscomp$3_flags$jscomp$12$$[2] << 24 | $cmd$jscomp$3_flags$jscomp$12$$[3] << 16 | $cmd$jscomp$3_flags$jscomp$12$$[4] << 8 | $cmd$jscomp$3_flags$jscomp$12$$[5], $count$jscomp$59$$ = $cmd$jscomp$3_flags$jscomp$12$$[7] << 8 | $cmd$jscomp$3_flags$jscomp$12$$[8];
|
|
8824
|
+
var $lba$jscomp$1$$ = $cmd$jscomp$3_flags$jscomp$12$$[2] << 24 | $cmd$jscomp$3_flags$jscomp$12$$[3] << 16 | $cmd$jscomp$3_flags$jscomp$12$$[4] << 8 | $cmd$jscomp$3_flags$jscomp$12$$[5], $count$jscomp$59$$ = 168 === $cmd$jscomp$3_flags$jscomp$12$$[0] ? $cmd$jscomp$3_flags$jscomp$12$$[6] << 24 | $cmd$jscomp$3_flags$jscomp$12$$[7] << 16 | $cmd$jscomp$3_flags$jscomp$12$$[8] << 8 | $cmd$jscomp$3_flags$jscomp$12$$[9] : $cmd$jscomp$3_flags$jscomp$12$$[7] << 8 | $cmd$jscomp$3_flags$jscomp$12$$[8];
|
|
8825
|
+
$count$jscomp$59$$ >>>= 0;
|
|
8822
8826
|
$cmd$jscomp$3_flags$jscomp$12$$ = $cmd$jscomp$3_flags$jscomp$12$$[1];
|
|
8823
8827
|
var $byte_count$jscomp$1$$ = $count$jscomp$59$$ * this.sector_size, $start$jscomp$31$$ = $lba$jscomp$1$$ * this.sector_size;
|
|
8824
8828
|
$dbg_log$$module$src$log$$(this.name + ": CD read DMA lba=" + $h$$module$src$lib$$($lba$jscomp$1$$) + " lbacount=" + $h$$module$src$lib$$($count$jscomp$59$$) + " bytecount=" + $h$$module$src$lib$$($byte_count$jscomp$1$$) + " flags=" + $h$$module$src$lib$$($cmd$jscomp$3_flags$jscomp$12$$), 32768);
|
package/build/libv86-debug.mjs
CHANGED
|
@@ -466,8 +466,8 @@ b,c){if(b>this.max_track||0!==a&&1===this.max_head)return B("WARNING: attempt to
|
|
|
466
466
|
2);return d};Qc.prototype.get_state=function(){const a=[];a[0]=this.drive_type;a[1]=this.max_track;a[2]=this.max_head;a[3]=this.max_sect;a[4]=this.curr_track;a[5]=this.curr_head;a[6]=this.curr_sect;a[7]=this.perpendicular;a[8]=this.read_only;a[9]=this.media_changed;a[10]=this.buffer?this.buffer.get_state():null;return a};Qc.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=a[2];this.max_sect=a[3];this.curr_track=a[4];this.curr_head=a[5];this.curr_sect=a[6];this.perpendicular=
|
|
467
467
|
a[7];this.read_only=a[8];this.media_changed=a[9];a[10]?(this.buffer||(this.buffer=new za(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const Sc={[8]:"DEVICE RESET",[144]:"EXECUTE DEVICE DIAGNOSTIC",[231]:"FLUSH CACHE",[234]:"FLUSH CACHE EXT",[218]:"GET MEDIA STATUS",[236]:"IDENTIFY DEVICE",[161]:"IDENTIFY PACKET DEVICE",[225]:"IDLE IMMEDIATE",[145]:"INITIALIZE DEVICE PARAMETERS",[222]:"MEDIA LOCK",[0]:"NOP",[160]:"PACKET",[200]:"READ DMA",[37]:"READ DMA EXT",[41]:"READ MULTIPLE",
|
|
468
468
|
[196]:"READ MULTIPLE EXT",[248]:"READ NATIVE MAX ADDRESS",[39]:"READ NATIVE MAX ADDRESS EXT",[32]:"READ SECTORS",[36]:"READ SECTORS EXT",[64]:"READ VERIFY SECTORS",[245]:"SECURITY FREEZE LOCK",[239]:"SET FEATURES",[249]:"SET MAX",[198]:"SET MULTIPLE MODE",[224]:"STANDBY IMMEDIATE",[202]:"WRITE DMA",[53]:"WRITE DMA EXT",[57]:"WRITE MULTIPLE",[197]:"WRITE MULTIPLE EXT",[48]:"WRITE SECTORS",[52]:"WRITE SECTORS EXT",[16]:"<UNKNOWN 10h>",[240]:"<VENDOR-SPECIFIC F0h>"},Tc={[70]:{name:"GET CONFIGURATION",
|
|
469
|
-
flags:0},[74]:{name:"GET EVENT STATUS NOTIFICATION",flags:0},[18]:{name:"INQUIRY",flags:0},[189]:{name:"MECHANISM STATUS",flags:0},[26]:{name:"MODE SENSE (6)",flags:0},[90]:{name:"MODE SENSE (10)",flags:0},[69]:{name:"PAUSE",flags:1},[30]:{name:"PREVENT ALLOW MEDIUM REMOVAL",flags:0},[40]:{name:"READ",flags:1},[37]:{name:"READ CAPACITY",flags:1},[190]:{name:"READ CD",flags:1},[81]:{name:"READ DISK INFORMATION",flags:1},[66]:{name:"READ SUBCHANNEL",flags:1},[67]:{name:"READ TOC PMA ATIP",
|
|
470
|
-
[82]:{name:"READ TRACK INFORMATION",flags:1},[3]:{name:"REQUEST SENSE",flags:0},[27]:{name:"START STOP UNIT",flags:0},[0]:{name:"TEST UNIT READY",flags:1}};function Uc(a,b,c){this.cpu=a;this.bus=b;this.secondary=this.primary=void 0;b=c&&c[0][0];const d=c&&c[1][0];if(b||d){b&&(this.primary=new Vc(this,0,c[0],496,1014,14));d&&(this.secondary=new Vc(this,1,c[1],368,886,15));c=b?this.primary.command_base:0;const e=b?this.primary.control_base:0,f=d?this.secondary.command_base:0,g=d?this.secondary.control_base:
|
|
469
|
+
flags:0},[74]:{name:"GET EVENT STATUS NOTIFICATION",flags:0},[18]:{name:"INQUIRY",flags:0},[189]:{name:"MECHANISM STATUS",flags:0},[26]:{name:"MODE SENSE (6)",flags:0},[90]:{name:"MODE SENSE (10)",flags:0},[69]:{name:"PAUSE",flags:1},[30]:{name:"PREVENT ALLOW MEDIUM REMOVAL",flags:0},[40]:{name:"READ (10)",flags:1},[168]:{name:"READ (12)",flags:1},[37]:{name:"READ CAPACITY",flags:1},[190]:{name:"READ CD",flags:1},[81]:{name:"READ DISK INFORMATION",flags:1},[66]:{name:"READ SUBCHANNEL",flags:1},[67]:{name:"READ TOC PMA ATIP",
|
|
470
|
+
flags:1},[82]:{name:"READ TRACK INFORMATION",flags:1},[3]:{name:"REQUEST SENSE",flags:0},[27]:{name:"START STOP UNIT",flags:0},[0]:{name:"TEST UNIT READY",flags:1}};function Uc(a,b,c){this.cpu=a;this.bus=b;this.secondary=this.primary=void 0;b=c&&c[0][0];const d=c&&c[1][0];if(b||d){b&&(this.primary=new Vc(this,0,c[0],496,1014,14));d&&(this.secondary=new Vc(this,1,c[1],368,886,15));c=b?this.primary.command_base:0;const e=b?this.primary.control_base:0,f=d?this.secondary.command_base:0,g=d?this.secondary.control_base:
|
|
471
471
|
0;this.name="ide";this.pci_id=240;this.pci_space=[134,128,16,112,5,0,160,2,0,128,1,1,0,0,0,0,c&255|1,c>>8,0,0,e&255|1,e>>8,0,0,f&255|1,f>>8,0,0,g&255|1,g>>8,0,0,1,180,0,0,0,0,0,0,0,0,0,0,67,16,212,130,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_bars=[b?{size:8}:void 0,b?{size:1}:void 0,d?{size:8}:void 0,d?{size:1}:
|
|
472
472
|
void 0,{size:16}];a.devices.pci.register_device(this)}Object.seal(this)}Uc.prototype.get_state=function(){const a=[];a[0]=this.primary;a[1]=this.secondary;return a};Uc.prototype.set_state=function(a){this.primary&&this.primary.set_state(a[0]);this.secondary&&this.secondary.set_state(a[1])};function Vc(a,b,c,d,e,f){this.controller=a;this.channel_nr=b;this.cpu=a.cpu;this.bus=a.bus;this.command_base=d;this.control_base=e;this.irq=f;this.name="ide"+b;d=c?c[0]:void 0;c=c?c[1]:void 0;this.master=new X(this,
|
|
473
473
|
0,d?.buffer,d?.is_cdrom);this.slave=new X(this,1,c?.buffer,c?.is_cdrom);this.current_interface=this.master;this.device_control_reg=2;this.dma_command=this.dma_status=this.prdt_addr=0;a=a.cpu;a.io.register_read(this.command_base|0,this,function(){return this.current_interface.read_data(1)},function(){return this.current_interface.read_data(2)},function(){return this.current_interface.read_data(4)});a.io.register_read(this.command_base|1,this,function(){return this.current_interface.error_reg&255});
|
|
@@ -496,89 +496,89 @@ break;case 231:this.status_reg=80;this.push_irq();break;case 234:this.status_reg
|
|
|
496
496
|
32768);this.ata_abort_command();break;default:l(!1,`${this.name}: error: unimplemented ATA command ${n(a)}: ABORT [${this.capture_regs()}]`,32768),this.ata_abort_command()}c&&(b=`[${b}] -> [${this.capture_regs()}]`,c=this.status_reg&1?this.error_reg&4?"ABORT":"ERROR":"OK",B(`${this.name}: ATA command ${Sc[a]} (${n(a)}): ${c} ${b}`,32768))}else B(`${this.name}: ATA command ${Sc[a]} (${n(a)}) ignored: no slave drive connected`,32768)};X.prototype.atapi_handle=function(){const a=this.data[0],b=Tc[a]?
|
|
497
497
|
Tc[a].name:"<undefined>";var c=Tc[a]?Tc[a].flags:0,d=this.capture_regs(),e=!0;let f;this.data_pointer=0;this.current_atapi_command=a;3!==a&&(this.atapi_add_sense=this.atapi_sense_key=0);if(!this.buffer&&c&1)this.atapi_check_condition_response(2,58),this.push_irq(),B(`${this.name}: ATAPI command ${b} (${n(a)}) without medium: ERROR [${d}]`,32768);else{switch(a){case 0:this.buffer?(this.data_allocate(0),this.data_end=this.data_length,this.status_reg=80):this.atapi_check_condition_response(2,58);break;
|
|
498
498
|
case 3:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;this.data[0]=240;this.data[2]=this.atapi_sense_key;this.data[7]=8;this.data[12]=this.atapi_add_sense;this.atapi_add_sense=this.atapi_sense_key=0;break;case 18:c=this.data[4];this.status_reg=88;f="lun="+n(this.data[1],2)+" length="+c;this.data.set([5,128,1,49,31,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79,77,32,67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,c);break;case 26:this.data_allocate(this.data[4]);
|
|
499
|
-
this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:c=this.sector_count-1;this.data_set(new Uint8Array([c>>24&255,c>>16&255,c>>8&255,c&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:e=!1;this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:c=this.data[8];f="length="+c;this.data_allocate(Math.min(8,
|
|
499
|
+
this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 37:c=this.sector_count-1;this.data_set(new Uint8Array([c>>24&255,c>>16&255,c>>8&255,c&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:case 168:e=!1;this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:c=this.data[8];f="length="+c;this.data_allocate(Math.min(8,
|
|
500
500
|
c));this.data_end=this.data_length;this.status_reg=88;break;case 67:c=this.data[8]|this.data[7]<<8;var g=this.data[9]>>6;f=`${n(g,2)} length=${c} ${!!(this.data[1]&2)} ${n(this.data[6])}`;this.data_allocate(c);this.data_end=this.data_length;0===g?(c=this.sector_count,this.data.set(new Uint8Array([0,18,1,1,0,20,1,0,0,0,0,0,0,22,170,0,c>>24,c>>16&255,c>>8&255,c&255]))):1===g?this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0])):l(!1,this.name+": error: unimplemented format: "+g);this.status_reg=
|
|
501
501
|
88;break;case 70:c=Math.min(this.data[8]|this.data[7]<<8,32);f="length="+c;this.data_allocate(c);this.data_end=this.data_length;this.data[0]=c-4>>24&255;this.data[1]=c-4>>16&255;this.data[2]=c-4>>8&255;this.data[3]=c-4&255;this.data[6]=8;this.data[10]=3;this.status_reg=88;break;case 81:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 82:f="unimplemented";this.atapi_check_condition_response(5,36);break;case 90:c=this.data[8]|this.data[7]<<8;g=this.data[2];f="page_code="+
|
|
502
502
|
n(g)+" length="+c;42===g&&this.data_allocate(Math.min(30,c));this.data_end=this.data_length;this.status_reg=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<8);this.data_end=this.data_length;this.data[5]=1;this.status_reg=88;break;case 27:c=this.data[4]&3;f=`Immed=${n(this.data[1]&1)} LoEj/Start=${n(c)}`;this.buffer&&2===c&&(f+=": disk ejected",this.medium_changed=!0,this.buffer=null);this.status_reg=80;this.data_allocate(0);this.data_end=this.data_length;break;case 69:case 74:f="unimplemented";
|
|
503
503
|
this.atapi_check_condition_response(5,36);break;case 190:f="unimplemented";this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;default:l(!1,`${this.name}: error: unimplemented ATAPI command ${n(this.data[0])}`,32768),this.atapi_check_condition_response(5,36)}this.sector_count_reg=this.sector_count_reg&-8|2;0===(this.status_reg&128)&&this.push_irq();0===(this.status_reg&128)&&0===this.data_length&&(this.sector_count_reg|=1,this.status_reg&=-9);e&&(d=`[${d}] -> [${this.capture_regs()}]`,
|
|
504
504
|
e=this.status_reg&1?this.error_reg&4?"ABORT":"ERROR":"OK",f=f?` ${f}:`:"",B(`${this.name}: ATAPI command ${b} (${n(a)}):${f} ${e} ${d}`,32768))}};X.prototype.atapi_check_condition_response=function(a,b){this.data_allocate(0);this.data_end=this.data_length;this.status_reg=65;this.error_reg=a<<4;this.sector_count_reg=this.sector_count_reg&-8|3;this.atapi_sense_key=a;this.atapi_add_sense=b};X.prototype.do_write=function(){this.status_reg=80;l(this.data_length<=this.data.length);var a=this.data.subarray(0,
|
|
505
|
-
this.data_length);l(0===this.data_length%512);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)};X.prototype.atapi_read=function(a){var b=
|
|
506
|
-
(l(!1,this.name+": CD read: Outside of disk end="+n(
|
|
507
|
-
255;this.lba_high_reg=this.data_end>>8&255;this.report_read_end(
|
|
508
|
-
n(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):(this.status_reg=208,this.report_read_start(),this.read_buffer(e,d,f=>{B(this.name+": atapi_read_dma: Data arrived",32768);this.report_read_end(d);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.data_set(f);this.do_atapi_dma()}))};X.prototype.do_atapi_dma=function(){if(0===(this.channel.dma_status&
|
|
509
|
-
32768);else{var a=this.channel.prdt_addr,b=0,c=this.data;do{var d=this.cpu.read32s(a),e=this.cpu.read16(a+4),f=this.cpu.read8(a+7)&128;e||(e=65536);this.cpu.write_blob(c.subarray(b,Math.min(b+e,this.data_length)),d);b+=e;a+=8;if(b>=this.data_length&&!f)break}while(!f);this.status_reg=80;this.channel.dma_status&=-2;this.sector_count_reg=this.sector_count_reg&-8|3;this.push_irq()}};
|
|
510
|
-
a,n(this.data_pointer)+" "+a);var b=1===a?this.data[this.data_pointer]:2===a?this.data16[this.data_pointer>>>1]:this.data32[this.data_pointer>>>2];this.data_pointer+=a;this.data_pointer>=this.data_end&&this.read_end();return b}this.data_pointer+=a;return 0};X.prototype.read_end=function(){if(160===this.current_command)if(this.data_end===this.data_length)this.status_reg=
|
|
511
|
-
|
|
512
|
-
36===this.current_command),a=1),this.ata_advance(this.current_command,a),this.data_end+=512*a,this.status_reg=88,this.push_irq())};X.prototype.write_data_port=function(a,b){l(0===this.data_pointer%b);this.data_pointer>=this.data_end?B(this.name+": redundant write to data port: "+n(a)+" count="+n(this.data_end)+" cur="+n(this.data_pointer),32768):(1===b?this.data[this.data_pointer++]=
|
|
513
|
-
4),l(this.data_pointer<=this.data_end),this.data_pointer===this.data_end&&this.write_end())};X.prototype.write_data_port8=function(a){this.write_data_port(a,1)};X.prototype.write_data_port16=function(a){this.write_data_port(a,2)};X.prototype.write_data_port32=function(a){this.write_data_port(a,4)};X.prototype.write_end=function(){160===this.current_command?this.atapi_handle():
|
|
514
|
-
"Unexpected command: "+n(this.current_command)),this.status_reg=88,this.data_end+=512,this.push_irq())};X.prototype.ata_advance=function(a,b){this.sector_count_reg-=b;36===a||41===a||37===a||52===a||57===a||53===a?(a=b+this.get_lba48(),this.lba_low_reg=a&255|a>>16&65280,this.lba_mid_reg=a>>8&255,this.lba_high_reg=a>>16&255):this.is_lba?(a=b+this.get_lba28(),this.lba_low_reg=
|
|
515
|
-
this.sectors_per_track)|0,this.lba_mid_reg=b&255,this.lba_high_reg=b>>8&255,this.head=(a/this.sectors_per_track|0)%this.head_count&15,this.lba_low_reg=a%this.sectors_per_track+1&255,l(a===this.get_chs()))};X.prototype.ata_read_sectors=function(a){var b=36===a||41===a,c=this.get_count(b);b=this.get_lba(b);var d=32===a||36===a,e=c*this.sector_size;b*=this.sector_size;b+
|
|
516
|
-
192,this.report_read_start(),this.read_buffer(b,e,f=>{this.data_set(f);this.status_reg=88;this.data_end=d?512:Math.min(e,512*this.sectors_per_drq);this.ata_advance(a,d?1:Math.min(c,this.sectors_per_track));this.push_irq();this.report_read_end(e)}))};X.prototype.ata_read_sectors_dma=function(a){a=37===a;var b=this.get_count(a);this.get_lba(a)*this.sector_size+b*this.sector_size>
|
|
517
|
-
88,this.channel.dma_status|=1)};X.prototype.do_ata_read_sectors_dma=function(){var a=37===this.current_command,b=this.get_count(a);a=this.get_lba(a);var c=b*this.sector_size,d=a*this.sector_size;l(a<this.buffer.byteLength);this.report_read_start();var e=this.channel.prdt_addr;this.read_buffer(d,c,f=>{var g=this.channel.prdt_addr,k=0;l(e===g);do{var m=this.cpu.read32s(g),
|
|
518
|
-
c);this.ata_advance(this.current_command,b);this.status_reg=80;this.channel.dma_status&=-2;this.current_command=-1;this.report_read_end(c);this.push_irq()})};X.prototype.ata_write_sectors=function(a){var b=52===a||57===a,c=this.get_count(b);b=this.get_lba(b);a=48===a||52===a;c*=this.sector_size;b*=this.sector_size;b+c>this.buffer.byteLength?(l(!1,this.name+": ATA write: Outside of disk",
|
|
519
|
-
Math.min(c,512*this.sectors_per_drq),this.write_dest=b)};X.prototype.ata_write_sectors_dma=function(a){a=53===a;var b=this.get_count(a);this.get_lba(a)*this.sector_size+b*this.sector_size>this.buffer.byteLength?(l(!1,this.name+": ATA DMA write: Outside of disk",32768),this.status_reg=255,this.push_irq()):(this.status_reg=88,this.channel.dma_status|=1)};X.prototype.do_ata_write_sectors_dma=
|
|
520
|
-
var d=this.channel.prdt_addr,e=0;const f=new Uint8Array(a);do{var g=this.cpu.read32s(d),k=this.cpu.read16(d+4),m=this.cpu.read8(d+7)&128;k||(k=65536,B(this.name+": DMA: prd count was 0",32768));g=this.cpu.mem8.subarray(g,g+k);l(g.length===k);f.set(g,e);e+=k;d+=8}while(!m);l(e===f.length);this.buffer.set(c,f,()=>{this.ata_advance(this.current_command,b);this.status_reg=80;this.push_irq();
|
|
521
|
-
255|this.lba_high_reg<<8&65280)*this.head_count+this.head)*this.sectors_per_track+(this.lba_low_reg&255)-1};X.prototype.get_lba28=function(){return this.lba_low_reg&255|this.lba_mid_reg<<8&65280|this.lba_high_reg<<16&16711680|(this.head&15)<<24};X.prototype.get_lba48=function(){return(this.lba_low_reg&255|this.lba_mid_reg<<8&65280|this.lba_high_reg<<16&16711680|this.lba_low_reg>>
|
|
522
|
-
X.prototype.get_count=function(a){a?(a=this.sector_count_reg,0===a&&(a=65536)):(a=this.sector_count_reg&255,0===a&&(a=256));return a};X.prototype.create_identify_packet=function(){const a=Math.min(16383,this.cylinder_count),b=(g,k,m,p)=>{k<<=1;var q=m<<1;m=k+q;g.fill(32,k,q);for(q=0;q<p.length&&k<m;q++)q&1?(g[k]=p.charCodeAt(q),k+=2):g[k+1]=p.charCodeAt(q)},c=this.is_atapi?
|
|
523
|
-
this.data_set([c&255,c>>8&255,a&255,a>>8&255,0,0,this.head_count&255,this.head_count>>8&255,this.sectors_per_track/512&255,this.sectors_per_track/512>>8&255,0,2,this.sectors_per_track&255,this.sectors_per_track>>8&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
524
|
-
255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,d&255,d>>8&255,0,0,30,0,30,0,30,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,e&255,e>>8&255,f&255,f>>8&255,0,64,e&255,e>>8&255,f&255,f>>8&255,0,64,0,0,0,0,0,0,0,0,0,0,
|
|
525
|
-
10,10,`8086-86${this.channel_nr}${this.interface_nr}`);b(this.data,23,4,"1.00");b(this.data,27,20,this.is_atapi?"v86 ATAPI CD-ROM":"v86 ATA HD");this.data_end=this.data_length=512};X.prototype.data_allocate=function(a){this.data_allocate_noclear(a);this.data32.fill(0,0,a+3>>2)};X.prototype.data_allocate_noclear=function(a){this.data.length<a&&(this.data=new Uint8Array(a+
|
|
526
|
-
0};X.prototype.data_set=function(a){this.data_allocate_noclear(a.length);this.data.set(a)};X.prototype.report_read_start=function(){this.bus.send("ide-read-start")};X.prototype.report_read_end=function(a){this.bus.send("ide-read-end",[this.channel_nr,a,a/this.sector_size|0])};X.prototype.report_write=function(a){this.bus.send("ide-write-end",[this.channel_nr,a,a/this.sector_size|
|
|
527
|
-
b,e=>{if(this.cancelled_io_ids.delete(d))l(!this.in_progress_io_ids.has(d));else{var f=this.in_progress_io_ids.delete(d);l(f);c(e)}})};X.prototype.cancel_io_operations=function(){for(const a of this.in_progress_io_ids)this.cancelled_io_ids.add(a);this.in_progress_io_ids.clear()};X.prototype.get_state=function(){var a=[];a[0]=this.sector_count_reg;a[1]=this.cylinder_count;a[2]=this.lba_high_reg;
|
|
528
|
-
a[11]=this.head;a[12]=this.head_count;a[13]=this.is_atapi;a[14]=this.is_lba;a[15]=this.features_reg;a[16]=this.data;a[17]=this.data_length;a[18]=this.lba_low_reg;a[19]=this.sector_count;a[20]=this.sector_size;a[21]=this.sectors_per_drq;a[22]=this.sectors_per_track;a[23]=this.status_reg;a[24]=this.write_dest;a[25]=this.current_command;a[26]=this.data_end;a[27]=this.current_atapi_command;
|
|
529
|
-
this.lba_high_reg=a[2];this.lba_mid_reg=a[3];this.data_pointer=a[4];this.device_reg=a[9];this.error_reg=a[10];this.head=a[11];this.head_count=a[12];this.is_atapi=a[13];this.is_lba=a[14];this.features_reg=a[15];this.data=a[16];this.data_length=a[17];this.lba_low_reg=a[18];this.sector_count=a[19];this.sector_size=a[20];this.sectors_per_drq=a[21];this.sectors_per_track=a[22];this.status_reg=
|
|
530
|
-
new Uint16Array(this.data.buffer);this.data32=new Int32Array(this.data.buffer);this.buffer&&this.buffer.set_state(a[28]);this.drive_connected=this.is_atapi||this.buffer;this.medium_changed=!1};function Wc(a,b,c){this.bus=b;this.id=a.devices.net?1:0;this.status=this.pairs=1;this.preserve_mac_from_state_image=c;this.mac=new Uint8Array([0,34,21,255*Math.random()|0,255*Math.random()|
|
|
531
|
-
notify_offset:0}),b.push({size_supported:1024,notify_offset:1});b.push({size_supported:16,notify_offset:2});this.virtio=new Ec(a,{name:"virtio-net",pci_id:80,device_id:4161,subsystem_device_id:1,common:{initial_port:51200,queues:b,features:[5,16,22,3,17,23,32],on_driver_ok:()=>{}},notification:{initial_port:51456,single_handler:!1,handlers:[()=>{},d=>{const e=this.virtio.queues[d];
|
|
532
|
-
this.id+"-send",g.subarray(12));this.bus.send("eth-transmit-end",[g.length-12]);this.virtio.queues[d].push_reply(f)}this.virtio.queues[d].flush_replies()},d=>{if(d!==2*this.pairs)l(!1,"VirtioNet Notified for wrong queue: "+d+" (expected queue_id of 3)");else for(var e=this.virtio.queues[d];e.has_request();){const k=e.pop_request();var f=new Uint8Array(k.length_readable);k.get_next_blob(f);
|
|
533
|
-
this.Send(d,k,new Uint8Array([0]));break;case 257:this.mac=f.subarray(2,8);this.Send(d,k,new Uint8Array([0]));this.bus.send("net"+this.id+"-mac",Bc(this.mac));break;default:l(!1," VirtioNet received unknown command: "+m+":"+g);this.Send(d,k,new Uint8Array([1]));return}}}]},isr_status:{initial_port:50944},device_specific:{initial_port:50688,struct:[0,1,2,3,4,5].map((d,e)=>({bytes:1,name:"mac_"+
|
|
534
|
-
{bytes:2,name:"max_pairs",read:()=>this.pairs,write:()=>{}},{bytes:2,name:"mtu",read:()=>1500,write:()=>{}}])}});this.bus.register("net"+this.id+"-receive",d=>{this.bus.send("eth-receive-end",[d.length]);const e=new Uint8Array(12+d.byteLength);(new DataView(e.buffer,e.byteOffset,e.byteLength)).setInt16(10,1);e.set(d,12);d=this.virtio.queues[0];d.has_request()?(d=d.pop_request(),d.set_next_blob(e),
|
|
535
|
-
this)}Wc.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.id;a[2]=this.mac;return a};Wc.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.id=a[1];this.preserve_mac_from_state_image&&(this.mac=a[2],this.bus.send("net"+this.id+"-mac",Bc(this.mac)))};Wc.prototype.reset=function(){this.virtio.reset()};Wc.prototype.Send=function(a,b,c){b.set_next_blob(c);
|
|
536
|
-
this.virtio.queues[a].flush_replies()};const Xc=Uint32Array.from([655360,655360,720896,753664]),Yc=Uint32Array.from([131072,65536,32768,32768]);function Y(a,b,c,d){this.cpu=a;this.bus=b;this.screen=c;this.vga_memory_size=d;this.cursor_address=0;this.cursor_scanline_start=14;this.cursor_scanline_end=15;this.max_cols=80;this.max_rows=25;this.virtual_height=this.virtual_width=
|
|
537
|
-
this.line_compare=this.offset_register=this.preset_row_scan=this.underline_location_register=this.vertical_blank_start=this.vertical_display_enable_end=this.horizontal_blank_start=this.horizontal_display_enable_end=this.crtc_mode=0;this.graphical_mode=!1;this.vga256_palette=new Int32Array(256);this.latch_dword=0;this.svga_version=45253;this.svga_height=this.svga_width=
|
|
538
|
-
void 0===this.vga_memory_size||262144>this.vga_memory_size?262144:268435456<this.vga_memory_size?268435456:ma(this.vga_memory_size);B("effective vga memory size: "+this.vga_memory_size,256);this.pci_space=[52,18,17,17,3,1,0,0,0,0,0,3,0,0,0,0,8,14680064,57344,224,0,0,0,0,0,0,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,0,17,0,0,190,254,0,0,0,0,0,0,0,0,0,0,0,
|
|
539
|
-
this.dac_color_index_read=this.dac_color_index_write=this.index_crtc=0;this.dac_mask=255;this.dac_map=new Uint8Array(16);this.attribute_controller_index=-1;this.palette_source=32;this.color_select=this.horizontal_panning=this.color_plane_enable=this.attribute_mode=0;this.sequencer_index=-1;this.plane_write_bm=15;this.clocking_mode=this.sequencer_memory_mode=
|
|
540
|
-
this.color_dont_care=this.color_compare=this.miscellaneous_graphics_register=this.planar_setreset_enable=this.planar_setreset=0;this.port_3DA_value=this.miscellaneous_output_register=255;this.font_page_ab_enabled=!1;b=a.io;b.register_write(960,this,this.port3C0_write);b.register_read(960,this,this.port3C0_read,this.port3C0_read16);b.register_read(961,
|
|
541
|
-
this,this.
|
|
542
|
-
|
|
543
|
-
b.register_read(948,this,this.port3D4_read);b.register_read(949,this,this.port3D5_read,this.port3D5_read16);b.register_read(970,this,function(){B("3CA read",256);return 0});b.register_read(986,this,this.port3DA_read);b.register_read(954,this,this.port3DA_read);this.dispi_index=-1;this.dispi_enable_value=0;b.register_write(462,this,void 0,this.port1CE_write);
|
|
544
|
-
0;this.svga_memory=h(Uint8Array,a.wasm_memory,c,this.vga_memory_size);this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0;this.image_data=null;this.vga_memory=new Uint8Array(262144);this.plane0=new Uint8Array(this.vga_memory.buffer,0,65536);this.plane1=new Uint8Array(this.vga_memory.buffer,
|
|
545
|
-
this.pixel_buffer=new Uint8Array(524288);b.mmap_register(655360,131072,e=>this.vga_memory_read(e),(e,f)=>this.vga_memory_write(e,f));a.devices.pci.register_device(this)}Y.prototype.get_state=function(){var a=[];a[0]=this.vga_memory_size;a[1]=this.cursor_address;a[2]=this.cursor_scanline_start;a[3]=this.cursor_scanline_end;a[4]=this.max_cols;a[5]=this.max_rows;
|
|
546
|
-
a[
|
|
547
|
-
this.
|
|
548
|
-
a[
|
|
549
|
-
a[1];this.cursor_scanline_start=a[2];this.cursor_scanline_end=a[3];this.max_cols=a[4];this.max_rows=a[5];a[6]&&this.vga_memory.set(a[6]);this.dac_state=a[7];this.start_address=a[8];this.graphical_mode=a[9];this.vga256_palette=a[10];this.latch_dword=a[11];this.color_compare=a[12];this.color_dont_care=a[13];this.miscellaneous_graphics_register=
|
|
550
|
-
a[
|
|
551
|
-
a[
|
|
552
|
-
a[58];this.clocking_mode=a[59];this.line_compare=a[60];a[61]&&this.pixel_buffer.set(a[61]);this.dac_mask=void 0===a[62]?255:a[62];this.character_map_select=void 0===a[63]?0:a[63];this.font_page_ab_enabled=void 0===a[64]?0:a[64];this.screen.set_mode(this.graphical_mode);this.graphical_mode?(this.screen_height=this.screen_width=
|
|
553
|
-
this.complete_replot())):(this.set_font_bitmap(!0),this.set_size_text(this.max_cols,this.max_rows),this.set_font_page(),this.update_cursor_scanline(),this.update_cursor());this.complete_redraw()};Y.prototype.vga_memory_read=function(a){if(this.svga_enabled)return this.cpu.read8((a-655360|this.svga_bank_offset)+
|
|
554
|
-
this.plane1[a]<<8;this.latch_dword|=this.plane2[a]<<16;this.latch_dword|=this.plane3[a]<<24;if(this.planar_mode&8)return b=255,this.color_dont_care&1&&(b&=this.plane0[a]^~(this.color_compare&1?255:0)),this.color_dont_care&2&&(b&=this.plane1[a]^~(this.color_compare&2?255:0)),this.color_dont_care&4&&
|
|
555
|
-
|
|
556
|
-
b)}};Y.prototype.vga_memory_write_graphical=function(a,b){var c=this.planar_mode&3,d=this.apply_feed(this.planar_bitmap),e=this.apply_expand(this.planar_setreset),f=this.apply_expand(this.planar_setreset_enable);switch(c){case 0:b=this.apply_rotate(b);var g=this.apply_feed(b);g=this.apply_setreset(g,f);g=this.apply_logical(g,
|
|
557
|
-
d);break;case 3:b=this.apply_rotate(b),d&=this.apply_feed(b),g=this.apply_bitmask(e,d)}b=15;switch(this.sequencer_memory_mode&12){case 0:b=5<<(a&1);a&=-2;break;case 8:case 12:b=1<<(a&3),a&=-4}b&=this.plane_write_bm;b&1&&(this.plane0[a]=g>>0&255);b&2&&(this.plane1[a]=g>>8&255);b&4&&(this.plane2[a]=g>>16&255);b&8&&(this.plane3[a]=
|
|
558
|
-
1?255:0)|(a&2?255:0)<<8|(a&4?255:0)<<16|(a&8?255:0)<<24};Y.prototype.apply_rotate=function(a){return(a|a<<8)>>>(this.planar_rotate_reg&7)&255};Y.prototype.apply_setreset=function(a,b){var c=this.apply_expand(this.planar_setreset);return(a|b&c)&(~b|c)};Y.prototype.apply_logical=function(a,b){switch(this.planar_rotate_reg&24){case 8:return a&
|
|
559
|
-
this.scan_line_to_screen_row(this.line_compare),b=Math.max(0,2*(2*this.offset_register-this.max_cols)),c=this.attribute_mode&8,d=this.font_page_ab_enabled?7:15,e=c?7:15,f=this.screen.FLAG_BLINKING,g=this.screen.FLAG_FONT_PAGE_B;let k=this.start_address<<1;for(let m=0;m<this.max_rows;m++){m===a&&(k=0);for(let p=0;p<this.max_cols;p++){const q=
|
|
560
|
-
p,q,v,this.vga256_palette[this.dac_mask&this.dac_map[r>>4&e]],this.vga256_palette[this.dac_mask&this.dac_map[r&d]]);k+=2}k+=b}};Y.prototype.vga_memory_write_text_mode=function(a,b){this.vga_memory[a]=b;var c=Math.max(this.max_cols,2*this.offset_register);let d;if(a>>1>=this.start_address){var e=(a>>1)-this.start_address;d=e/c|0;c=e%c}else e=
|
|
561
|
-
e=this.vga_memory[a|1];var f=this.attribute_mode&8;a=(f&&e&128?this.screen.FLAG_BLINKING:0)|(!this.font_page_ab_enabled||e&8?0:this.screen.FLAG_FONT_PAGE_B);var g=this.font_page_ab_enabled?7:15;f=f?7:15;this.bus.send("screen-put-char",[d,c,b]);this.screen.put_char(d,c,b,a,this.vga256_palette[this.dac_mask&this.dac_map[e>>4&f]],this.vga256_palette[this.dac_mask&
|
|
562
|
-
this.start_address?(b=(this.cursor_address-this.start_address)/a|0,a=(this.cursor_address-this.start_address)%a):(b=(this.cursor_address/a|0)+this.scan_line_to_screen_row(this.line_compare),a=this.cursor_address%a);l(0<=b&&0<=a);this.screen.update_cursor(b,a)};Y.prototype.complete_redraw=function(){B("complete redraw",256);this.graphical_mode?this.svga_enabled?
|
|
563
|
-
256);this.graphical_mode&&!this.svga_enabled&&(this.diff_plot_min=0,this.diff_plot_max=524288,this.complete_redraw())};Y.prototype.partial_redraw=function(a,b){a<this.diff_addr_min&&(this.diff_addr_min=a);b>this.diff_addr_max&&(this.diff_addr_max=b)};Y.prototype.partial_replot=function(a,b){a<this.diff_plot_min&&(this.diff_plot_min=a);b>this.diff_plot_max&&
|
|
564
|
-
0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0};Y.prototype.destroy=function(){};Y.prototype.vga_bytes_per_line=function(){var a=this.offset_register<<2;this.underline_location_register&64?a<<=1:this.crtc_mode&64&&(a>>>=1);return a};Y.prototype.vga_addr_shift_count=function(){var a=128+(~this.underline_location_register&this.crtc_mode&64);a-=
|
|
565
|
-
if(~this.crtc_mode&3){var c=a-this.start_address;c&=this.crtc_mode<<13|-24577;c<<=b;var d=c/this.virtual_width|0;c%=this.virtual_width;switch(this.crtc_mode&3){case 2:d=d<<1|a>>13&1;break;case 1:d=d<<1|a>>14&1;break;case 0:d=d<<2|a>>13&3}return d*this.virtual_width+c+(this.start_address<<b)}return a<<b};Y.prototype.scan_line_to_screen_row=function(a){this.max_scan_line&
|
|
566
|
-
function(a,b){l(!this.graphical_mode);this.max_cols=a;this.max_rows=b;this.screen.set_size_text(a,b);this.bus.send("screen-set-size",[a,b,0])};Y.prototype.set_size_graphical=function(a,b,c,d,e){l(this.graphical_mode);c=Math.max(c,1);d=Math.max(d,1);if(this.screen_width!==a||this.screen_height!==b||this.virtual_width!==c||this.virtual_height!==d){this.screen_width=
|
|
567
|
-
0;this.dest_buffet_offset=g;this.image_data=new ImageData(new Uint8ClampedArray(this.cpu.wasm_memory.buffer,g,4*f),c,d);this.cpu.svga_mark_dirty()}this.screen.set_size_graphical(a,b,c,d);this.bus.send("screen-set-size",[a,b,e])}};Y.prototype.update_vga_size=function(){if(!this.svga_enabled){var a=Math.min(1+this.horizontal_display_enable_end,this.horizontal_blank_start),
|
|
568
|
-
4,d=4;this.attribute_mode&64?(a>>>=1,c>>>=1,d=8):this.attribute_mode&2&&(d=1);b=this.scan_line_to_screen_row(b);var e=Yc[0];const f=this.vga_bytes_per_line();this.set_size_graphical(a,b,c,f?Math.ceil(e/f):b,d);this.update_vertical_retrace();this.update_layers()}else this.max_scan_line&128&&(b>>>=1),c=b/(1+(this.max_scan_line&31))|0,a&&c&&this.set_size_text(a,c)}};
|
|
569
|
-
this.screen_width)if(!this.palette_source||this.clocking_mode&32)this.layers=[],this.screen.clear_screen();else{var a=this.start_address_latched,b=this.horizontal_panning;this.attribute_mode&64&&(b>>>=1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+this.line_compare);
|
|
570
|
-
g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,
|
|
571
|
-
this.start_address&&(this.start_address_latched=this.start_address,this.update_layers())};Y.prototype.update_cursor_scanline=function(){var a=this.max_scan_line&31;const b=Math.min(a,this.cursor_scanline_start&31);a=Math.min(a,this.cursor_scanline_end&31);this.screen.update_cursor_scanline(b,a,!(this.cursor_scanline_start&32)&&b<a)};Y.prototype.port3C0_write=function(a){if(-1===this.attribute_controller_index)B("attribute controller index register: "+
|
|
572
|
-
B("attribute actual index: "+n(this.attribute_controller_index),256),this.palette_source!==(a&32)&&(this.palette_source=a&32,this.update_layers());else{if(16>this.attribute_controller_index)B("internal palette: "+n(this.attribute_controller_index)+" -> "+n(a),256),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:B("3C0 / attribute mode control: "+n(a),256);
|
|
573
|
-
this.attribute_mode=a;const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:B("3C0 / color plane enable: "+n(a),256);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:B("3C0 / horizontal panning: "+n(a),256);this.horizontal_panning!==
|
|
574
|
-
this.update_layers());break;case 20:B("3C0 / color select: "+n(a),256);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:B("3C0 / attribute controller write "+n(this.attribute_controller_index)+": "+n(a),256)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){B("3C0 read",256);return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){B("3C0 read16",256);return this.port3C0_read()|
|
|
575
|
-
8&65280};Y.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return B("3C1 / internal palette read: "+n(this.attribute_controller_index)+" -> "+n(this.dac_map[this.attribute_controller_index]),256),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return B("3C1 / attribute mode read: "+n(this.attribute_mode),256),this.attribute_mode;case 18:return B("3C1 / color plane enable read: "+n(this.color_plane_enable),
|
|
576
|
-
case 19:return B("3C1 / horizontal panning read: "+n(this.horizontal_panning),256),this.horizontal_panning;case 20:return B("3C1 / color select read: "+n(this.color_select),256),this.color_select;default:B("3C1 / attribute controller read "+n(this.attribute_controller_index),256)}return 255};Y.prototype.port3C2_write=function(a){B("3C2 / miscellaneous output register = "+n(a),256);this.miscellaneous_output_register=a};Y.prototype.port3C4_write=function(a){this.sequencer_index=
|
|
577
|
-
function(){return this.sequencer_index};Y.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:B("clocking mode: "+n(a),256);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();this.set_font_bitmap(!1);break;case 2:B("plane write mask: "+n(a),256);b=this.plane_write_bm;this.plane_write_bm=a;this.graphical_mode||!(b&4)||this.plane_write_bm&4||this.set_font_bitmap(!0);break;case 3:B("character map select: "+n(a),256);b=this.character_map_select;
|
|
578
|
-
a;this.graphical_mode||b===a||this.set_font_page();break;case 4:B("sequencer memory mode: "+n(a),256);this.sequencer_memory_mode=a;break;default:B("3C5 / sequencer write "+n(this.sequencer_index)+": "+n(a),256)}};Y.prototype.port3C5_read=function(){B("3C5 / sequencer read "+n(this.sequencer_index),256);switch(this.sequencer_index){case 1:return this.clocking_mode;case 2:return this.plane_write_bm;case 3:return this.character_map_select;case 4:return this.sequencer_memory_mode;
|
|
579
|
-
Y.prototype.port3C6_write=function(a){this.dac_mask!==a&&(this.dac_mask=a,this.complete_redraw())};Y.prototype.port3C6_read=function(){return this.dac_mask};Y.prototype.port3C7_write=function(a){B("3C7 write: "+n(a),256);this.dac_color_index_read=3*a;this.dac_state&=0};Y.prototype.port3C7_read=function(){return this.dac_state};Y.prototype.port3C8_write=function(a){this.dac_color_index_write=3*a;this.dac_state|=3};Y.prototype.port3C8_read=function(){return this.dac_color_index_write/
|
|
580
|
-
function(a){var b=this.dac_color_index_write/3|0,c=this.dac_color_index_write%3,d=this.vga256_palette[b];if(0===(this.dispi_enable_value&32)){a&=63;const e=a&1;a=a<<2|e<<1|e}0===c?d=d&-16711681|a<<16:1===c?d=d&-65281|a<<8:(d=d&-256|a,B("dac set color, index="+n(b)+" value="+n(d),256));this.vga256_palette[b]!==d&&(this.vga256_palette[b]=d,this.complete_redraw());this.dac_color_index_write++};Y.prototype.port3C9_read=function(){B("3C9 read",256);var a=this.vga256_palette[this.dac_color_index_read/
|
|
581
|
-
0]>>8*(2-this.dac_color_index_read%3)&255;this.dac_color_index_read++;return this.dispi_enable_value&32?a:a>>2};Y.prototype.port3CC_read=function(){B("3CC read",256);return this.miscellaneous_output_register};Y.prototype.port3CE_write=function(a){this.graphics_index=a};Y.prototype.port3CE_read=function(){return this.graphics_index};Y.prototype.port3CF_write=function(a){switch(this.graphics_index){case 0:this.planar_setreset=a;B("plane set/reset: "+n(a),256);break;case 1:this.planar_setreset_enable=
|
|
505
|
+
this.data_length);l(0===this.data_length%512);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)};X.prototype.atapi_read=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5];a=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];var c=(a>>>0)*this.sector_size;b*=this.sector_size;this.data_length=0;var d=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.lba_mid_reg=this.lba_high_reg=0;65535===
|
|
506
|
+
d&&d--;d>c&&(d=c);this.buffer?b>=this.buffer.byteLength?(l(!1,this.name+": CD read: Outside of disk end="+n(b+c)+" size="+n(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):0===c?(this.status_reg=80,this.data_pointer=0):(c=Math.min(c,this.buffer.byteLength-b),this.status_reg=208,this.report_read_start(),this.read_buffer(b,c,e=>{this.data_set(e);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.push_irq();this.data_end=d&=-4;this.data_end>this.data_length&&
|
|
507
|
+
(this.data_end=this.data_length);this.lba_mid_reg=this.data_end&255;this.lba_high_reg=this.data_end>>8&255;this.report_read_end(c)})):(l(!1,this.name+": CD read: no buffer",32768),this.status_reg=255,this.error_reg=65,this.push_irq())};X.prototype.atapi_read_dma=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];c>>>=0;a=a[1];var d=c*this.sector_size,e=b*this.sector_size;B(this.name+": CD read DMA lba="+n(b)+" lbacount="+n(c)+" bytecount="+n(d)+
|
|
508
|
+
" flags="+n(a),32768);e>=this.buffer.byteLength?(l(!1,this.name+": CD read: Outside of disk end="+n(e+d)+" size="+n(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):(this.status_reg=208,this.report_read_start(),this.read_buffer(e,d,f=>{B(this.name+": atapi_read_dma: Data arrived",32768);this.report_read_end(d);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.data_set(f);this.do_atapi_dma()}))};X.prototype.do_atapi_dma=function(){if(0===(this.channel.dma_status&
|
|
509
|
+
1))B(this.name+": do_atapi_dma: Status not set",32768);else if(0===(this.status_reg&8))B(this.name+": do_atapi_dma: DRQ not set",32768);else{var a=this.channel.prdt_addr,b=0,c=this.data;do{var d=this.cpu.read32s(a),e=this.cpu.read16(a+4),f=this.cpu.read8(a+7)&128;e||(e=65536);this.cpu.write_blob(c.subarray(b,Math.min(b+e,this.data_length)),d);b+=e;a+=8;if(b>=this.data_length&&!f)break}while(!f);this.status_reg=80;this.channel.dma_status&=-2;this.sector_count_reg=this.sector_count_reg&-8|3;this.push_irq()}};
|
|
510
|
+
X.prototype.read_data=function(a){if(this.data_pointer<this.data_end){l(this.data_pointer+a-1<this.data_end);l(0===this.data_pointer%a,n(this.data_pointer)+" "+a);var b=1===a?this.data[this.data_pointer]:2===a?this.data16[this.data_pointer>>>1]:this.data32[this.data_pointer>>>2];this.data_pointer+=a;this.data_pointer>=this.data_end&&this.read_end();return b}this.data_pointer+=a;return 0};X.prototype.read_end=function(){if(160===this.current_command)if(this.data_end===this.data_length)this.status_reg=
|
|
511
|
+
80,this.sector_count_reg=this.sector_count_reg&-8|3,this.push_irq();else{this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.push_irq();var a=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.data_end+a>this.data_length?(this.lba_mid_reg=this.data_length-this.data_end&255,this.lba_high_reg=this.data_length-this.data_end>>8&255,this.data_end=this.data_length):this.data_end+=a}else this.error_reg=0,this.data_pointer>=this.data_length?this.status_reg=80:(41===this.current_command||
|
|
512
|
+
196===this.current_command?(a=Math.min(this.sectors_per_drq,(this.data_length-this.data_end)/512),l(0===a%1)):(l(32===this.current_command||36===this.current_command),a=1),this.ata_advance(this.current_command,a),this.data_end+=512*a,this.status_reg=88,this.push_irq())};X.prototype.write_data_port=function(a,b){l(0===this.data_pointer%b);this.data_pointer>=this.data_end?B(this.name+": redundant write to data port: "+n(a)+" count="+n(this.data_end)+" cur="+n(this.data_pointer),32768):(1===b?this.data[this.data_pointer++]=
|
|
513
|
+
a:2===b?(this.data16[this.data_pointer>>>1]=a,this.data_pointer+=2):(this.data32[this.data_pointer>>>2]=a,this.data_pointer+=4),l(this.data_pointer<=this.data_end),this.data_pointer===this.data_end&&this.write_end())};X.prototype.write_data_port8=function(a){this.write_data_port(a,1)};X.prototype.write_data_port16=function(a){this.write_data_port(a,2)};X.prototype.write_data_port32=function(a){this.write_data_port(a,4)};X.prototype.write_end=function(){160===this.current_command?this.atapi_handle():
|
|
514
|
+
this.data_pointer>=this.data_length?this.do_write():(l(48===this.current_command||52===this.current_command||197===this.current_command,"Unexpected command: "+n(this.current_command)),this.status_reg=88,this.data_end+=512,this.push_irq())};X.prototype.ata_advance=function(a,b){this.sector_count_reg-=b;36===a||41===a||37===a||52===a||57===a||53===a?(a=b+this.get_lba48(),this.lba_low_reg=a&255|a>>16&65280,this.lba_mid_reg=a>>8&255,this.lba_high_reg=a>>16&255):this.is_lba?(a=b+this.get_lba28(),this.lba_low_reg=
|
|
515
|
+
a&255,this.lba_mid_reg=a>>8&255,this.lba_high_reg=a>>16&255,this.head=this.head&-16|a&15):(a=b+this.get_chs(),b=a/(this.head_count*this.sectors_per_track)|0,this.lba_mid_reg=b&255,this.lba_high_reg=b>>8&255,this.head=(a/this.sectors_per_track|0)%this.head_count&15,this.lba_low_reg=a%this.sectors_per_track+1&255,l(a===this.get_chs()))};X.prototype.ata_read_sectors=function(a){var b=36===a||41===a,c=this.get_count(b);b=this.get_lba(b);var d=32===a||36===a,e=c*this.sector_size;b*=this.sector_size;b+
|
|
516
|
+
e>this.buffer.byteLength?(l(!1,this.name+": ATA read: Outside of disk",32768),this.status_reg=255,this.push_irq()):(this.status_reg=192,this.report_read_start(),this.read_buffer(b,e,f=>{this.data_set(f);this.status_reg=88;this.data_end=d?512:Math.min(e,512*this.sectors_per_drq);this.ata_advance(a,d?1:Math.min(c,this.sectors_per_track));this.push_irq();this.report_read_end(e)}))};X.prototype.ata_read_sectors_dma=function(a){a=37===a;var b=this.get_count(a);this.get_lba(a)*this.sector_size+b*this.sector_size>
|
|
517
|
+
this.buffer.byteLength?(l(!1,this.name+": ATA read: Outside of disk",32768),this.status_reg=255,this.push_irq()):(this.status_reg=88,this.channel.dma_status|=1)};X.prototype.do_ata_read_sectors_dma=function(){var a=37===this.current_command,b=this.get_count(a);a=this.get_lba(a);var c=b*this.sector_size,d=a*this.sector_size;l(a<this.buffer.byteLength);this.report_read_start();var e=this.channel.prdt_addr;this.read_buffer(d,c,f=>{var g=this.channel.prdt_addr,k=0;l(e===g);do{var m=this.cpu.read32s(g),
|
|
518
|
+
p=this.cpu.read16(g+4),q=this.cpu.read8(g+7)&128;p||(p=65536);this.cpu.write_blob(f.subarray(k,k+p),m);k+=p;g+=8}while(!q);l(k===c);this.ata_advance(this.current_command,b);this.status_reg=80;this.channel.dma_status&=-2;this.current_command=-1;this.report_read_end(c);this.push_irq()})};X.prototype.ata_write_sectors=function(a){var b=52===a||57===a,c=this.get_count(b);b=this.get_lba(b);a=48===a||52===a;c*=this.sector_size;b*=this.sector_size;b+c>this.buffer.byteLength?(l(!1,this.name+": ATA write: Outside of disk",
|
|
519
|
+
32768),this.status_reg=255,this.push_irq()):(this.status_reg=88,this.data_allocate_noclear(c),this.data_end=a?512:Math.min(c,512*this.sectors_per_drq),this.write_dest=b)};X.prototype.ata_write_sectors_dma=function(a){a=53===a;var b=this.get_count(a);this.get_lba(a)*this.sector_size+b*this.sector_size>this.buffer.byteLength?(l(!1,this.name+": ATA DMA write: Outside of disk",32768),this.status_reg=255,this.push_irq()):(this.status_reg=88,this.channel.dma_status|=1)};X.prototype.do_ata_write_sectors_dma=
|
|
520
|
+
function(){var a=53===this.current_command,b=this.get_count(a),c=this.get_lba(a);a=b*this.sector_size;c*=this.sector_size;var d=this.channel.prdt_addr,e=0;const f=new Uint8Array(a);do{var g=this.cpu.read32s(d),k=this.cpu.read16(d+4),m=this.cpu.read8(d+7)&128;k||(k=65536,B(this.name+": DMA: prd count was 0",32768));g=this.cpu.mem8.subarray(g,g+k);l(g.length===k);f.set(g,e);e+=k;d+=8}while(!m);l(e===f.length);this.buffer.set(c,f,()=>{this.ata_advance(this.current_command,b);this.status_reg=80;this.push_irq();
|
|
521
|
+
this.channel.dma_status&=-2;this.current_command=-1});this.report_write(a)};X.prototype.get_chs=function(){return((this.lba_mid_reg&255|this.lba_high_reg<<8&65280)*this.head_count+this.head)*this.sectors_per_track+(this.lba_low_reg&255)-1};X.prototype.get_lba28=function(){return this.lba_low_reg&255|this.lba_mid_reg<<8&65280|this.lba_high_reg<<16&16711680|(this.head&15)<<24};X.prototype.get_lba48=function(){return(this.lba_low_reg&255|this.lba_mid_reg<<8&65280|this.lba_high_reg<<16&16711680|this.lba_low_reg>>
|
|
522
|
+
8<<24&4278190080)>>>0};X.prototype.get_lba=function(a){return a?this.get_lba48():this.is_lba?this.get_lba28():this.get_chs()};X.prototype.get_count=function(a){a?(a=this.sector_count_reg,0===a&&(a=65536)):(a=this.sector_count_reg&255,0===a&&(a=256));return a};X.prototype.create_identify_packet=function(){const a=Math.min(16383,this.cylinder_count),b=(g,k,m,p)=>{k<<=1;var q=m<<1;m=k+q;g.fill(32,k,q);for(q=0;q<p.length&&k<m;q++)q&1?(g[k]=p.charCodeAt(q),k+=2):g[k+1]=p.charCodeAt(q)},c=this.is_atapi?
|
|
523
|
+
34112:64,d=160===this.current_command?0:1031,e=this.is_atapi?16928:16384,f=this.is_atapi?20480:29696;this.data.fill(0,0,512);this.data_set([c&255,c>>8&255,a&255,a>>8&255,0,0,this.head_count&255,this.head_count>>8&255,this.sectors_per_track/512&255,this.sectors_per_track/512>>8&255,0,2,this.sectors_per_track&255,this.sectors_per_track>>8&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
524
|
+
0,128,0,1,0,0,2,0,0,0,2,0,2,7,0,a&255,a>>8&255,this.head_count&255,this.head_count>>8&255,this.sectors_per_track,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,d&255,d>>8&255,0,0,30,0,30,0,30,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,e&255,e>>8&255,f&255,f>>8&255,0,64,e&255,e>>8&255,f&255,f>>8&255,0,64,0,0,0,0,0,0,0,0,0,0,
|
|
525
|
+
1,96,0,0,0,0,0,0,0,0,0,0,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255]);b(this.data,10,10,`8086-86${this.channel_nr}${this.interface_nr}`);b(this.data,23,4,"1.00");b(this.data,27,20,this.is_atapi?"v86 ATAPI CD-ROM":"v86 ATA HD");this.data_end=this.data_length=512};X.prototype.data_allocate=function(a){this.data_allocate_noclear(a);this.data32.fill(0,0,a+3>>2)};X.prototype.data_allocate_noclear=function(a){this.data.length<a&&(this.data=new Uint8Array(a+
|
|
526
|
+
3&-4),this.data16=new Uint16Array(this.data.buffer),this.data32=new Int32Array(this.data.buffer));this.data_length=a;this.data_pointer=0};X.prototype.data_set=function(a){this.data_allocate_noclear(a.length);this.data.set(a)};X.prototype.report_read_start=function(){this.bus.send("ide-read-start")};X.prototype.report_read_end=function(a){this.bus.send("ide-read-end",[this.channel_nr,a,a/this.sector_size|0])};X.prototype.report_write=function(a){this.bus.send("ide-write-end",[this.channel_nr,a,a/this.sector_size|
|
|
527
|
+
0])};X.prototype.read_buffer=function(a,b,c){const d=this.last_io_id++;this.in_progress_io_ids.add(d);this.buffer.get(a,b,e=>{if(this.cancelled_io_ids.delete(d))l(!this.in_progress_io_ids.has(d));else{var f=this.in_progress_io_ids.delete(d);l(f);c(e)}})};X.prototype.cancel_io_operations=function(){for(const a of this.in_progress_io_ids)this.cancelled_io_ids.add(a);this.in_progress_io_ids.clear()};X.prototype.get_state=function(){var a=[];a[0]=this.sector_count_reg;a[1]=this.cylinder_count;a[2]=this.lba_high_reg;
|
|
528
|
+
a[3]=this.lba_mid_reg;a[4]=this.data_pointer;a[5]=0;a[6]=0;a[7]=0;a[8]=0;a[9]=this.device_reg;a[10]=this.error_reg;a[11]=this.head;a[12]=this.head_count;a[13]=this.is_atapi;a[14]=this.is_lba;a[15]=this.features_reg;a[16]=this.data;a[17]=this.data_length;a[18]=this.lba_low_reg;a[19]=this.sector_count;a[20]=this.sector_size;a[21]=this.sectors_per_drq;a[22]=this.sectors_per_track;a[23]=this.status_reg;a[24]=this.write_dest;a[25]=this.current_command;a[26]=this.data_end;a[27]=this.current_atapi_command;
|
|
529
|
+
a[28]=this.buffer;return a};X.prototype.set_state=function(a){this.sector_count_reg=a[0];this.cylinder_count=a[1];this.lba_high_reg=a[2];this.lba_mid_reg=a[3];this.data_pointer=a[4];this.device_reg=a[9];this.error_reg=a[10];this.head=a[11];this.head_count=a[12];this.is_atapi=a[13];this.is_lba=a[14];this.features_reg=a[15];this.data=a[16];this.data_length=a[17];this.lba_low_reg=a[18];this.sector_count=a[19];this.sector_size=a[20];this.sectors_per_drq=a[21];this.sectors_per_track=a[22];this.status_reg=
|
|
530
|
+
a[23];this.write_dest=a[24];this.current_command=a[25];this.data_end=a[26];this.current_atapi_command=a[27];this.data16=new Uint16Array(this.data.buffer);this.data32=new Int32Array(this.data.buffer);this.buffer&&this.buffer.set_state(a[28]);this.drive_connected=this.is_atapi||this.buffer;this.medium_changed=!1};function Wc(a,b,c){this.bus=b;this.id=a.devices.net?1:0;this.status=this.pairs=1;this.preserve_mac_from_state_image=c;this.mac=new Uint8Array([0,34,21,255*Math.random()|0,255*Math.random()|
|
|
531
|
+
0,255*Math.random()|0]);this.bus.send("net"+this.id+"-mac",Bc(this.mac));b=[];for(c=0;c<this.pairs;++c)b.push({size_supported:1024,notify_offset:0}),b.push({size_supported:1024,notify_offset:1});b.push({size_supported:16,notify_offset:2});this.virtio=new Ec(a,{name:"virtio-net",pci_id:80,device_id:4161,subsystem_device_id:1,common:{initial_port:51200,queues:b,features:[5,16,22,3,17,23,32],on_driver_ok:()=>{}},notification:{initial_port:51456,single_handler:!1,handlers:[()=>{},d=>{const e=this.virtio.queues[d];
|
|
532
|
+
for(;e.has_request();){const f=e.pop_request(),g=new Uint8Array(f.length_readable);f.get_next_blob(g);this.bus.send("net"+this.id+"-send",g.subarray(12));this.bus.send("eth-transmit-end",[g.length-12]);this.virtio.queues[d].push_reply(f)}this.virtio.queues[d].flush_replies()},d=>{if(d!==2*this.pairs)l(!1,"VirtioNet Notified for wrong queue: "+d+" (expected queue_id of 3)");else for(var e=this.virtio.queues[d];e.has_request();){const k=e.pop_request();var f=new Uint8Array(k.length_readable);k.get_next_blob(f);
|
|
533
|
+
var g=K(["b","b"],f,{offset:0});const m=g[0];g=g[1];switch(m<<8|g){case 1024:f=K(["h"],f,{offset:2});l(1===f[0]);this.Send(d,k,new Uint8Array([0]));break;case 257:this.mac=f.subarray(2,8);this.Send(d,k,new Uint8Array([0]));this.bus.send("net"+this.id+"-mac",Bc(this.mac));break;default:l(!1," VirtioNet received unknown command: "+m+":"+g);this.Send(d,k,new Uint8Array([1]));return}}}]},isr_status:{initial_port:50944},device_specific:{initial_port:50688,struct:[0,1,2,3,4,5].map((d,e)=>({bytes:1,name:"mac_"+
|
|
534
|
+
e,read:()=>this.mac[e],write:()=>{}})).concat([{bytes:2,name:"status",read:()=>this.status,write:()=>{}},{bytes:2,name:"max_pairs",read:()=>this.pairs,write:()=>{}},{bytes:2,name:"mtu",read:()=>1500,write:()=>{}}])}});this.bus.register("net"+this.id+"-receive",d=>{this.bus.send("eth-receive-end",[d.length]);const e=new Uint8Array(12+d.byteLength);(new DataView(e.buffer,e.byteOffset,e.byteLength)).setInt16(10,1);e.set(d,12);d=this.virtio.queues[0];d.has_request()?(d=d.pop_request(),d.set_next_blob(e),
|
|
535
|
+
this.virtio.queues[0].push_reply(d),this.virtio.queues[0].flush_replies()):console.log("No buffer to write into!")},this)}Wc.prototype.get_state=function(){const a=[];a[0]=this.virtio;a[1]=this.id;a[2]=this.mac;return a};Wc.prototype.set_state=function(a){this.virtio.set_state(a[0]);this.id=a[1];this.preserve_mac_from_state_image&&(this.mac=a[2],this.bus.send("net"+this.id+"-mac",Bc(this.mac)))};Wc.prototype.reset=function(){this.virtio.reset()};Wc.prototype.Send=function(a,b,c){b.set_next_blob(c);
|
|
536
|
+
this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};Wc.prototype.Ack=function(a,b){this.virtio.queues[a].push_reply(b);this.virtio.queues[a].flush_replies()};const Xc=Uint32Array.from([655360,655360,720896,753664]),Yc=Uint32Array.from([131072,65536,32768,32768]);function Y(a,b,c,d){this.cpu=a;this.bus=b;this.screen=c;this.vga_memory_size=d;this.cursor_address=0;this.cursor_scanline_start=14;this.cursor_scanline_end=15;this.max_cols=80;this.max_rows=25;this.virtual_height=this.virtual_width=
|
|
537
|
+
this.screen_height=this.screen_width=0;this.layers=[];this.start_address_latched=this.start_address=0;this.crtc=new Uint8Array(25);this.line_compare=this.offset_register=this.preset_row_scan=this.underline_location_register=this.vertical_blank_start=this.vertical_display_enable_end=this.horizontal_blank_start=this.horizontal_display_enable_end=this.crtc_mode=0;this.graphical_mode=!1;this.vga256_palette=new Int32Array(256);this.latch_dword=0;this.svga_version=45253;this.svga_height=this.svga_width=
|
|
538
|
+
0;this.svga_enabled=!1;this.svga_bpp=32;this.svga_offset_y=this.svga_offset_x=this.svga_offset=this.svga_bank_offset=0;this.vga_memory_size=void 0===this.vga_memory_size||262144>this.vga_memory_size?262144:268435456<this.vga_memory_size?268435456:ma(this.vga_memory_size);B("effective vga memory size: "+this.vga_memory_size,256);this.pci_space=[52,18,17,17,3,1,0,0,0,0,0,3,0,0,0,0,8,14680064,57344,224,0,0,0,0,0,0,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,0,17,0,0,190,254,0,0,0,0,0,0,0,0,0,0,0,
|
|
539
|
+
0];this.pci_id=144;this.pci_bars=[{size:this.vga_memory_size}];this.pci_rom_size=65536;this.pci_rom_address=4272947200;this.name="vga";this.dac_state=this.dac_color_index_read=this.dac_color_index_write=this.index_crtc=0;this.dac_mask=255;this.dac_map=new Uint8Array(16);this.attribute_controller_index=-1;this.palette_source=32;this.color_select=this.horizontal_panning=this.color_plane_enable=this.attribute_mode=0;this.sequencer_index=-1;this.plane_write_bm=15;this.clocking_mode=this.sequencer_memory_mode=
|
|
540
|
+
0;this.graphics_index=-1;this.planar_rotate_reg=this.planar_mode=this.plane_read=this.character_map_select=0;this.planar_bitmap=255;this.max_scan_line=this.color_dont_care=this.color_compare=this.miscellaneous_graphics_register=this.planar_setreset_enable=this.planar_setreset=0;this.port_3DA_value=this.miscellaneous_output_register=255;this.font_page_ab_enabled=!1;b=a.io;b.register_write(960,this,this.port3C0_write);b.register_read(960,this,this.port3C0_read,this.port3C0_read16);b.register_read(961,
|
|
541
|
+
this,this.port3C1_read);b.register_write(962,this,this.port3C2_write);b.register_write_consecutive(964,this,this.port3C4_write,this.port3C5_write);b.register_read(964,this,this.port3C4_read);b.register_read(965,this,this.port3C5_read);b.register_write_consecutive(974,this,this.port3CE_write,this.port3CF_write);b.register_read(974,this,this.port3CE_read);b.register_read(975,this,this.port3CF_read);b.register_read(966,this,this.port3C6_read);b.register_write(966,this,this.port3C6_write);b.register_write(967,
|
|
542
|
+
this,this.port3C7_write);b.register_read(967,this,this.port3C7_read);b.register_write(968,this,this.port3C8_write);b.register_read(968,this,this.port3C8_read);b.register_write(969,this,this.port3C9_write);b.register_read(969,this,this.port3C9_read);b.register_read(972,this,this.port3CC_read);b.register_write(980,this,this.port3D4_write,this.port3D4_write16);b.register_write(981,this,this.port3D5_write,this.port3D5_write16);b.register_read(980,this,this.port3D4_read);b.register_read(981,this,this.port3D5_read,
|
|
543
|
+
this.port3D5_read16);b.register_write(948,this,this.port3D4_write,this.port3D4_write16);b.register_write(949,this,this.port3D5_write,this.port3D5_write16);b.register_read(948,this,this.port3D4_read);b.register_read(949,this,this.port3D5_read,this.port3D5_read16);b.register_read(970,this,function(){B("3CA read",256);return 0});b.register_read(986,this,this.port3DA_read);b.register_read(954,this,this.port3DA_read);this.dispi_index=-1;this.dispi_enable_value=0;b.register_write(462,this,void 0,this.port1CE_write);
|
|
544
|
+
b.register_write(463,this,void 0,this.port1CF_write);b.register_read(463,this,void 0,this.port1CF_read);c=a.svga_allocate_memory(this.vga_memory_size)>>>0;this.svga_memory=h(Uint8Array,a.wasm_memory,c,this.vga_memory_size);this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0;this.image_data=null;this.vga_memory=new Uint8Array(262144);this.plane0=new Uint8Array(this.vga_memory.buffer,0,65536);this.plane1=new Uint8Array(this.vga_memory.buffer,
|
|
545
|
+
65536,65536);this.plane2=new Uint8Array(this.vga_memory.buffer,131072,65536);this.plane3=new Uint8Array(this.vga_memory.buffer,196608,65536);this.pixel_buffer=new Uint8Array(524288);b.mmap_register(655360,131072,e=>this.vga_memory_read(e),(e,f)=>this.vga_memory_write(e,f));a.devices.pci.register_device(this)}Y.prototype.get_state=function(){var a=[];a[0]=this.vga_memory_size;a[1]=this.cursor_address;a[2]=this.cursor_scanline_start;a[3]=this.cursor_scanline_end;a[4]=this.max_cols;a[5]=this.max_rows;
|
|
546
|
+
a[6]=this.vga_memory;a[7]=this.dac_state;a[8]=this.start_address;a[9]=this.graphical_mode;a[10]=this.vga256_palette;a[11]=this.latch_dword;a[12]=this.color_compare;a[13]=this.color_dont_care;a[14]=this.miscellaneous_graphics_register;a[15]=this.svga_width;a[16]=this.svga_height;a[17]=this.crtc_mode;a[18]=this.svga_enabled;a[19]=this.svga_bpp;a[20]=this.svga_bank_offset;a[21]=this.svga_offset;a[22]=this.index_crtc;a[23]=this.dac_color_index_write;a[24]=this.dac_color_index_read;a[25]=this.dac_map;
|
|
547
|
+
a[26]=this.sequencer_index;a[27]=this.plane_write_bm;a[28]=this.sequencer_memory_mode;a[29]=this.graphics_index;a[30]=this.plane_read;a[31]=this.planar_mode;a[32]=this.planar_rotate_reg;a[33]=this.planar_bitmap;a[34]=this.max_scan_line;a[35]=this.miscellaneous_output_register;a[36]=this.port_3DA_value;a[37]=this.dispi_index;a[38]=this.dispi_enable_value;a[39]=this.svga_memory;a[41]=this.attribute_controller_index;a[42]=this.offset_register;a[43]=this.planar_setreset;a[44]=this.planar_setreset_enable;
|
|
548
|
+
a[45]=this.start_address_latched;a[46]=this.crtc;a[47]=this.horizontal_display_enable_end;a[48]=this.horizontal_blank_start;a[49]=this.vertical_display_enable_end;a[50]=this.vertical_blank_start;a[51]=this.underline_location_register;a[52]=this.preset_row_scan;a[53]=this.offset_register;a[54]=this.palette_source;a[55]=this.attribute_mode;a[56]=this.color_plane_enable;a[57]=this.horizontal_panning;a[58]=this.color_select;a[59]=this.clocking_mode;a[60]=this.line_compare;a[61]=this.pixel_buffer;a[62]=
|
|
549
|
+
this.dac_mask;a[63]=this.character_map_select;a[64]=this.font_page_ab_enabled;return a};Y.prototype.set_state=function(a){this.vga_memory_size=a[0];this.cursor_address=a[1];this.cursor_scanline_start=a[2];this.cursor_scanline_end=a[3];this.max_cols=a[4];this.max_rows=a[5];a[6]&&this.vga_memory.set(a[6]);this.dac_state=a[7];this.start_address=a[8];this.graphical_mode=a[9];this.vga256_palette=a[10];this.latch_dword=a[11];this.color_compare=a[12];this.color_dont_care=a[13];this.miscellaneous_graphics_register=
|
|
550
|
+
a[14];this.svga_width=a[15];this.svga_height=a[16];this.crtc_mode=a[17];this.svga_enabled=a[18];this.svga_bpp=a[19];this.svga_bank_offset=a[20];this.svga_offset=a[21];this.index_crtc=a[22];this.dac_color_index_write=a[23];this.dac_color_index_read=a[24];this.dac_map=a[25];this.sequencer_index=a[26];this.plane_write_bm=a[27];this.sequencer_memory_mode=a[28];this.graphics_index=a[29];this.plane_read=a[30];this.planar_mode=a[31];this.planar_rotate_reg=a[32];this.planar_bitmap=a[33];this.max_scan_line=
|
|
551
|
+
a[34];this.miscellaneous_output_register=a[35];this.port_3DA_value=a[36];this.dispi_index=a[37];this.dispi_enable_value=a[38];this.svga_memory.set(a[39]);this.attribute_controller_index=a[41];this.offset_register=a[42];this.planar_setreset=a[43];this.planar_setreset_enable=a[44];this.start_address_latched=a[45];this.crtc.set(a[46]);this.horizontal_display_enable_end=a[47];this.horizontal_blank_start=a[48];this.vertical_display_enable_end=a[49];this.vertical_blank_start=a[50];this.underline_location_register=
|
|
552
|
+
a[51];this.preset_row_scan=a[52];this.offset_register=a[53];this.palette_source=a[54];this.attribute_mode=a[55];this.color_plane_enable=a[56];this.horizontal_panning=a[57];this.color_select=a[58];this.clocking_mode=a[59];this.line_compare=a[60];a[61]&&this.pixel_buffer.set(a[61]);this.dac_mask=void 0===a[62]?255:a[62];this.character_map_select=void 0===a[63]?0:a[63];this.font_page_ab_enabled=void 0===a[64]?0:a[64];this.screen.set_mode(this.graphical_mode);this.graphical_mode?(this.screen_height=this.screen_width=
|
|
553
|
+
0,this.svga_enabled?(this.set_size_graphical(this.svga_width,this.svga_height,this.svga_width,this.svga_height,this.svga_bpp),this.update_layers()):(this.update_vga_size(),this.update_layers(),this.complete_replot())):(this.set_font_bitmap(!0),this.set_size_text(this.max_cols,this.max_rows),this.set_font_page(),this.update_cursor_scanline(),this.update_cursor());this.complete_redraw()};Y.prototype.vga_memory_read=function(a){if(this.svga_enabled)return this.cpu.read8((a-655360|this.svga_bank_offset)+
|
|
554
|
+
3758096384|0);var b=this.miscellaneous_graphics_register>>2&3;a-=Xc[b];if(0>a||a>=Yc[b])return B("vga read outside memory space: addr:"+n(a>>>0),256),0;this.latch_dword=this.plane0[a];this.latch_dword|=this.plane1[a]<<8;this.latch_dword|=this.plane2[a]<<16;this.latch_dword|=this.plane3[a]<<24;if(this.planar_mode&8)return b=255,this.color_dont_care&1&&(b&=this.plane0[a]^~(this.color_compare&1?255:0)),this.color_dont_care&2&&(b&=this.plane1[a]^~(this.color_compare&2?255:0)),this.color_dont_care&4&&
|
|
555
|
+
(b&=this.plane2[a]^~(this.color_compare&4?255:0)),this.color_dont_care&8&&(b&=this.plane3[a]^~(this.color_compare&8?255:0)),b;b=this.plane_read;this.graphical_mode?this.sequencer_memory_mode&8?(b=a&3,a&=-4):this.planar_mode&16&&(b=a&1,a&=-2):b&=3;return this.vga_memory[b<<16|a]};Y.prototype.vga_memory_write=function(a,b){if(this.svga_enabled)this.cpu.write8((a-655360|this.svga_bank_offset)+3758096384|0,b);else{var c=this.miscellaneous_graphics_register>>2&3;a-=Xc[c];0>a||a>=Yc[c]?B("vga write outside memory space: addr:"+
|
|
556
|
+
n(a>>>0)+", value:"+n(b),256):this.graphical_mode?this.vga_memory_write_graphical(a,b):this.plane_write_bm&3?this.vga_memory_write_text_mode(a,b):this.plane_write_bm&4&&(this.plane2[a]=b)}};Y.prototype.vga_memory_write_graphical=function(a,b){var c=this.planar_mode&3,d=this.apply_feed(this.planar_bitmap),e=this.apply_expand(this.planar_setreset),f=this.apply_expand(this.planar_setreset_enable);switch(c){case 0:b=this.apply_rotate(b);var g=this.apply_feed(b);g=this.apply_setreset(g,f);g=this.apply_logical(g,
|
|
557
|
+
this.latch_dword);g=this.apply_bitmask(g,d);break;case 1:g=this.latch_dword;break;case 2:g=this.apply_expand(b);g=this.apply_logical(g,this.latch_dword);g=this.apply_bitmask(g,d);break;case 3:b=this.apply_rotate(b),d&=this.apply_feed(b),g=this.apply_bitmask(e,d)}b=15;switch(this.sequencer_memory_mode&12){case 0:b=5<<(a&1);a&=-2;break;case 8:case 12:b=1<<(a&3),a&=-4}b&=this.plane_write_bm;b&1&&(this.plane0[a]=g>>0&255);b&2&&(this.plane1[a]=g>>8&255);b&4&&(this.plane2[a]=g>>16&255);b&8&&(this.plane3[a]=
|
|
558
|
+
g>>24&255);a=this.vga_addr_to_pixel(a);this.partial_replot(a,a+7)};Y.prototype.apply_feed=function(a){return a|a<<8|a<<16|a<<24};Y.prototype.apply_expand=function(a){return(a&1?255:0)|(a&2?255:0)<<8|(a&4?255:0)<<16|(a&8?255:0)<<24};Y.prototype.apply_rotate=function(a){return(a|a<<8)>>>(this.planar_rotate_reg&7)&255};Y.prototype.apply_setreset=function(a,b){var c=this.apply_expand(this.planar_setreset);return(a|b&c)&(~b|c)};Y.prototype.apply_logical=function(a,b){switch(this.planar_rotate_reg&24){case 8:return a&
|
|
559
|
+
b;case 16:return a|b;case 24:return a^b}return a};Y.prototype.apply_bitmask=function(a,b){return b&a|~b&this.latch_dword};Y.prototype.text_mode_redraw=function(){const a=this.scan_line_to_screen_row(this.line_compare),b=Math.max(0,2*(2*this.offset_register-this.max_cols)),c=this.attribute_mode&8,d=this.font_page_ab_enabled?7:15,e=c?7:15,f=this.screen.FLAG_BLINKING,g=this.screen.FLAG_FONT_PAGE_B;let k=this.start_address<<1;for(let m=0;m<this.max_rows;m++){m===a&&(k=0);for(let p=0;p<this.max_cols;p++){const q=
|
|
560
|
+
this.vga_memory[k],r=this.vga_memory[k|1],v=(c&&r&128?f:0)|(!this.font_page_ab_enabled||r&8?0:g);this.bus.send("screen-put-char",[m,p,q]);this.screen.put_char(m,p,q,v,this.vga256_palette[this.dac_mask&this.dac_map[r>>4&e]],this.vga256_palette[this.dac_mask&this.dac_map[r&d]]);k+=2}k+=b}};Y.prototype.vga_memory_write_text_mode=function(a,b){this.vga_memory[a]=b;var c=Math.max(this.max_cols,2*this.offset_register);let d;if(a>>1>=this.start_address){var e=(a>>1)-this.start_address;d=e/c|0;c=e%c}else e=
|
|
561
|
+
a>>1,d=(e/c|0)+this.scan_line_to_screen_row(this.line_compare),c=e%c;l(0<=d&&0<=c);if(!(c>=this.max_cols||d>=this.max_rows)){a&1?(e=b,b=this.vga_memory[a&-2]):e=this.vga_memory[a|1];var f=this.attribute_mode&8;a=(f&&e&128?this.screen.FLAG_BLINKING:0)|(!this.font_page_ab_enabled||e&8?0:this.screen.FLAG_FONT_PAGE_B);var g=this.font_page_ab_enabled?7:15;f=f?7:15;this.bus.send("screen-put-char",[d,c,b]);this.screen.put_char(d,c,b,a,this.vga256_palette[this.dac_mask&this.dac_map[e>>4&f]],this.vga256_palette[this.dac_mask&
|
|
562
|
+
this.dac_map[e&g]])}};Y.prototype.update_cursor=function(){var a=Math.max(this.max_cols,2*this.offset_register);let b;this.cursor_address>=this.start_address?(b=(this.cursor_address-this.start_address)/a|0,a=(this.cursor_address-this.start_address)%a):(b=(this.cursor_address/a|0)+this.scan_line_to_screen_row(this.line_compare),a=this.cursor_address%a);l(0<=b&&0<=a);this.screen.update_cursor(b,a)};Y.prototype.complete_redraw=function(){B("complete redraw",256);this.graphical_mode?this.svga_enabled?
|
|
563
|
+
this.cpu.svga_mark_dirty():(this.diff_addr_min=0,this.diff_addr_max=524288):this.text_mode_redraw()};Y.prototype.complete_replot=function(){B("complete replot",256);this.graphical_mode&&!this.svga_enabled&&(this.diff_plot_min=0,this.diff_plot_max=524288,this.complete_redraw())};Y.prototype.partial_redraw=function(a,b){a<this.diff_addr_min&&(this.diff_addr_min=a);b>this.diff_addr_max&&(this.diff_addr_max=b)};Y.prototype.partial_replot=function(a,b){a<this.diff_plot_min&&(this.diff_plot_min=a);b>this.diff_plot_max&&
|
|
564
|
+
(this.diff_plot_max=b);this.partial_redraw(a,b)};Y.prototype.reset_diffs=function(){this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0};Y.prototype.destroy=function(){};Y.prototype.vga_bytes_per_line=function(){var a=this.offset_register<<2;this.underline_location_register&64?a<<=1:this.crtc_mode&64&&(a>>>=1);return a};Y.prototype.vga_addr_shift_count=function(){var a=128+(~this.underline_location_register&this.crtc_mode&64);a-=
|
|
565
|
+
this.underline_location_register&64;a-=this.attribute_mode&64;return a>>>6};Y.prototype.vga_addr_to_pixel=function(a){var b=this.vga_addr_shift_count();if(~this.crtc_mode&3){var c=a-this.start_address;c&=this.crtc_mode<<13|-24577;c<<=b;var d=c/this.virtual_width|0;c%=this.virtual_width;switch(this.crtc_mode&3){case 2:d=d<<1|a>>13&1;break;case 1:d=d<<1|a>>14&1;break;case 0:d=d<<2|a>>13&3}return d*this.virtual_width+c+(this.start_address<<b)}return a<<b};Y.prototype.scan_line_to_screen_row=function(a){this.max_scan_line&
|
|
566
|
+
128&&(a>>>=1);a=Math.ceil(a/(1+(this.max_scan_line&31)));this.crtc_mode&1||(a<<=1);this.crtc_mode&2||(a<<=1);return a};Y.prototype.set_size_text=function(a,b){l(!this.graphical_mode);this.max_cols=a;this.max_rows=b;this.screen.set_size_text(a,b);this.bus.send("screen-set-size",[a,b,0])};Y.prototype.set_size_graphical=function(a,b,c,d,e){l(this.graphical_mode);c=Math.max(c,1);d=Math.max(d,1);if(this.screen_width!==a||this.screen_height!==b||this.virtual_width!==c||this.virtual_height!==d){this.screen_width=
|
|
567
|
+
a;this.screen_height=b;this.virtual_width=c;this.virtual_height=d;if("undefined"!==typeof ImageData){const f=c*d,g=this.cpu.svga_allocate_dest_buffer(f)>>>0;this.dest_buffet_offset=g;this.image_data=new ImageData(new Uint8ClampedArray(this.cpu.wasm_memory.buffer,g,4*f),c,d);this.cpu.svga_mark_dirty()}this.screen.set_size_graphical(a,b,c,d);this.bus.send("screen-set-size",[a,b,e])}};Y.prototype.update_vga_size=function(){if(!this.svga_enabled){var a=Math.min(1+this.horizontal_display_enable_end,this.horizontal_blank_start),
|
|
568
|
+
b=Math.min(1+this.vertical_display_enable_end,this.vertical_blank_start);if(a&&b)if(this.graphical_mode){a<<=3;var c=this.offset_register<<4,d=4;this.attribute_mode&64?(a>>>=1,c>>>=1,d=8):this.attribute_mode&2&&(d=1);b=this.scan_line_to_screen_row(b);var e=Yc[0];const f=this.vga_bytes_per_line();this.set_size_graphical(a,b,c,f?Math.ceil(e/f):b,d);this.update_vertical_retrace();this.update_layers()}else this.max_scan_line&128&&(b>>>=1),c=b/(1+(this.max_scan_line&31))|0,a&&c&&this.set_size_text(a,c)}};
|
|
569
|
+
Y.prototype.update_layers=function(){this.graphical_mode||this.text_mode_redraw();if(this.svga_enabled)this.layers=[];else if(this.virtual_width&&this.screen_width)if(!this.palette_source||this.clocking_mode&32)this.layers=[],this.screen.clear_screen();else{var a=this.start_address_latched,b=this.horizontal_panning;this.attribute_mode&64&&(b>>>=1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+this.line_compare);
|
|
570
|
+
d=Math.min(d,this.screen_height);var f=this.screen_height-d;this.layers=[];e=-e;for(var g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:0,buffer_x:0,buffer_y:a+g,buffer_width:this.virtual_width,buffer_height:d});a=0;this.attribute_mode&32||(a=this.vga_addr_to_pixel(c)+b);e=-a;for(g=0;e<this.screen_width;e+=this.virtual_width,g++)this.layers.push({image_data:this.image_data,screen_x:e,screen_y:d,buffer_x:0,buffer_y:g,buffer_width:this.virtual_width,
|
|
571
|
+
buffer_height:f})}};Y.prototype.update_vertical_retrace=function(){this.port_3DA_value|=8;this.start_address_latched!==this.start_address&&(this.start_address_latched=this.start_address,this.update_layers())};Y.prototype.update_cursor_scanline=function(){var a=this.max_scan_line&31;const b=Math.min(a,this.cursor_scanline_start&31);a=Math.min(a,this.cursor_scanline_end&31);this.screen.update_cursor_scanline(b,a,!(this.cursor_scanline_start&32)&&b<a)};Y.prototype.port3C0_write=function(a){if(-1===this.attribute_controller_index)B("attribute controller index register: "+
|
|
572
|
+
n(a),256),this.attribute_controller_index=a&31,B("attribute actual index: "+n(this.attribute_controller_index),256),this.palette_source!==(a&32)&&(this.palette_source=a&32,this.update_layers());else{if(16>this.attribute_controller_index)B("internal palette: "+n(this.attribute_controller_index)+" -> "+n(a),256),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:B("3C0 / attribute mode control: "+n(a),256);
|
|
573
|
+
if(this.attribute_mode!==a){var b=this.attribute_mode;this.attribute_mode=a;const c=0!==(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.screen.set_mode(this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw();this.set_font_bitmap(!1)}break;case 18:B("3C0 / color plane enable: "+n(a),256);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:B("3C0 / horizontal panning: "+n(a),256);this.horizontal_panning!==
|
|
574
|
+
a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:B("3C0 / color select: "+n(a),256);this.color_select!==a&&(this.color_select=a,this.complete_redraw());break;default:B("3C0 / attribute controller write "+n(this.attribute_controller_index)+": "+n(a),256)}this.attribute_controller_index=-1}};Y.prototype.port3C0_read=function(){B("3C0 read",256);return(this.attribute_controller_index|this.palette_source)&255};Y.prototype.port3C0_read16=function(){B("3C0 read16",256);return this.port3C0_read()|
|
|
575
|
+
this.port3C1_read()<<8&65280};Y.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return B("3C1 / internal palette read: "+n(this.attribute_controller_index)+" -> "+n(this.dac_map[this.attribute_controller_index]),256),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return B("3C1 / attribute mode read: "+n(this.attribute_mode),256),this.attribute_mode;case 18:return B("3C1 / color plane enable read: "+n(this.color_plane_enable),
|
|
576
|
+
256),this.color_plane_enable;case 19:return B("3C1 / horizontal panning read: "+n(this.horizontal_panning),256),this.horizontal_panning;case 20:return B("3C1 / color select read: "+n(this.color_select),256),this.color_select;default:B("3C1 / attribute controller read "+n(this.attribute_controller_index),256)}return 255};Y.prototype.port3C2_write=function(a){B("3C2 / miscellaneous output register = "+n(a),256);this.miscellaneous_output_register=a};Y.prototype.port3C4_write=function(a){this.sequencer_index=
|
|
577
|
+
a};Y.prototype.port3C4_read=function(){return this.sequencer_index};Y.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:B("clocking mode: "+n(a),256);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();this.set_font_bitmap(!1);break;case 2:B("plane write mask: "+n(a),256);b=this.plane_write_bm;this.plane_write_bm=a;this.graphical_mode||!(b&4)||this.plane_write_bm&4||this.set_font_bitmap(!0);break;case 3:B("character map select: "+n(a),256);b=this.character_map_select;
|
|
578
|
+
this.character_map_select=a;this.graphical_mode||b===a||this.set_font_page();break;case 4:B("sequencer memory mode: "+n(a),256);this.sequencer_memory_mode=a;break;default:B("3C5 / sequencer write "+n(this.sequencer_index)+": "+n(a),256)}};Y.prototype.port3C5_read=function(){B("3C5 / sequencer read "+n(this.sequencer_index),256);switch(this.sequencer_index){case 1:return this.clocking_mode;case 2:return this.plane_write_bm;case 3:return this.character_map_select;case 4:return this.sequencer_memory_mode;
|
|
579
|
+
case 6:return 18}return 0};Y.prototype.port3C6_write=function(a){this.dac_mask!==a&&(this.dac_mask=a,this.complete_redraw())};Y.prototype.port3C6_read=function(){return this.dac_mask};Y.prototype.port3C7_write=function(a){B("3C7 write: "+n(a),256);this.dac_color_index_read=3*a;this.dac_state&=0};Y.prototype.port3C7_read=function(){return this.dac_state};Y.prototype.port3C8_write=function(a){this.dac_color_index_write=3*a;this.dac_state|=3};Y.prototype.port3C8_read=function(){return this.dac_color_index_write/
|
|
580
|
+
3&255};Y.prototype.port3C9_write=function(a){var b=this.dac_color_index_write/3|0,c=this.dac_color_index_write%3,d=this.vga256_palette[b];if(0===(this.dispi_enable_value&32)){a&=63;const e=a&1;a=a<<2|e<<1|e}0===c?d=d&-16711681|a<<16:1===c?d=d&-65281|a<<8:(d=d&-256|a,B("dac set color, index="+n(b)+" value="+n(d),256));this.vga256_palette[b]!==d&&(this.vga256_palette[b]=d,this.complete_redraw());this.dac_color_index_write++};Y.prototype.port3C9_read=function(){B("3C9 read",256);var a=this.vga256_palette[this.dac_color_index_read/
|
|
581
|
+
3|0]>>8*(2-this.dac_color_index_read%3)&255;this.dac_color_index_read++;return this.dispi_enable_value&32?a:a>>2};Y.prototype.port3CC_read=function(){B("3CC read",256);return this.miscellaneous_output_register};Y.prototype.port3CE_write=function(a){this.graphics_index=a};Y.prototype.port3CE_read=function(){return this.graphics_index};Y.prototype.port3CF_write=function(a){switch(this.graphics_index){case 0:this.planar_setreset=a;B("plane set/reset: "+n(a),256);break;case 1:this.planar_setreset_enable=
|
|
582
582
|
a;B("plane set/reset enable: "+n(a),256);break;case 2:this.color_compare=a;B("color compare: "+n(a),256);break;case 3:this.planar_rotate_reg=a;B("plane rotate: "+n(a),256);break;case 4:this.plane_read=a;B("plane read: "+n(a),256);break;case 5:var b=this.planar_mode;this.planar_mode=a;B("planar mode: "+n(a),256);(b^a)&96&&this.complete_replot();break;case 6:B("miscellaneous graphics register: "+n(a),256);this.miscellaneous_graphics_register!==a&&(this.miscellaneous_graphics_register=a,this.update_vga_size());
|
|
583
583
|
break;case 7:this.color_dont_care=a;B("color don't care: "+n(a),256);break;case 8:this.planar_bitmap=a;B("planar bitmap: "+n(a),256);break;default:B("3CF / graphics write "+n(this.graphics_index)+": "+n(a),256)}};Y.prototype.port3CF_read=function(){B("3CF / graphics read "+n(this.graphics_index),256);switch(this.graphics_index){case 0:return this.planar_setreset;case 1:return this.planar_setreset_enable;case 2:return this.color_compare;case 3:return this.planar_rotate_reg;case 4:return this.plane_read;
|
|
584
584
|
case 5:return this.planar_mode;case 6:return this.miscellaneous_graphics_register;case 7:return this.color_dont_care;case 8:return this.planar_bitmap}return 0};Y.prototype.port3D4_write=function(a){B("3D4 / crtc index: "+a,256);this.index_crtc=a};Y.prototype.port3D4_write16=function(a){this.port3D4_write(a&255);this.port3D5_write(a>>8&255)};Y.prototype.port3D4_read=function(){B("3D4 read / crtc index: "+this.index_crtc,256);return this.index_crtc};Y.prototype.port3D5_write=function(a){switch(this.index_crtc){case 1:B("3D5 / hdisp enable end write: "+
|
package/build/libv86.js
CHANGED
|
@@ -458,8 +458,8 @@ Lc.prototype.get_buffer=function(){return this.buffer?this.buffer.buffer:null};L
|
|
|
458
458
|
Lc.prototype.find_disk_format=function(a,b){const c=0===b,d=a.byteLength;let e=-1,f=-1,g=-1,h=-1,l=-1;for(let m=0;m<Mc.length;m++){const n=Mc[m],p=n.sectors*n.tracks*n.heads*512;if(d===p)if(c||n.drive_type===b){e=m;break}else c||Kc[n.drive_type]!==Kc[b]?g=-1===g?m:g:f=-1===f?m:f;else d<p&&(-1===l||p<l)&&(h=m,l=p)}return-1!==e?[a,Mc[e]]:-1!==f?[a,Mc[f]]:-1!==g?[a,Mc[g]]:-1!==h?(b=new Uint8Array(l),b.set(new Uint8Array(a.buffer)),[new A(b.buffer),Mc[h]]):[null,null]};
|
|
459
459
|
Lc.prototype.seek=function(a,b,c){if(b>this.max_track||0!==a&&1===this.max_head)return 2;if(c>this.max_sect)return 3;let d=0;const e=this.chs2lba(this.curr_track,this.curr_head,this.curr_sect),f=this.chs2lba(b,a,c);e!==f&&(this.curr_track!==b&&(this.buffer&&(this.media_changed=!1),d=1),this.curr_head=a,this.curr_track=b,this.curr_sect=c);this.buffer||(d=2);return d};
|
|
460
460
|
Lc.prototype.get_state=function(){const a=[];a[0]=this.drive_type;a[1]=this.max_track;a[2]=this.max_head;a[3]=this.max_sect;a[4]=this.curr_track;a[5]=this.curr_head;a[6]=this.curr_sect;a[7]=this.perpendicular;a[8]=this.read_only;a[9]=this.media_changed;a[10]=this.buffer?this.buffer.get_state():null;return a};
|
|
461
|
-
Lc.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=a[2];this.max_sect=a[3];this.curr_track=a[4];this.curr_head=a[5];this.curr_sect=a[6];this.perpendicular=a[7];this.read_only=a[8];this.media_changed=a[9];a[10]?(this.buffer||(this.buffer=new A(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const Nc={[70]:{name:"GET CONFIGURATION",flags:0},[74]:{name:"GET EVENT STATUS NOTIFICATION",flags:0},[18]:{name:"INQUIRY",flags:0},[189]:{name:"MECHANISM STATUS",flags:0},[26]:{name:"MODE SENSE (6)",flags:0},[90]:{name:"MODE SENSE (10)",flags:0},[69]:{name:"PAUSE",flags:1},[30]:{name:"PREVENT ALLOW MEDIUM REMOVAL",flags:0},[40]:{name:"READ",flags:1},[
|
|
462
|
-
[67]:{name:"READ TOC PMA ATIP",flags:1},[82]:{name:"READ TRACK INFORMATION",flags:1},[3]:{name:"REQUEST SENSE",flags:0},[27]:{name:"START STOP UNIT",flags:0},[0]:{name:"TEST UNIT READY",flags:1}};
|
|
461
|
+
Lc.prototype.set_state=function(a){this.drive_type=a[0];this.max_track=a[1];this.max_head=a[2];this.max_sect=a[3];this.curr_track=a[4];this.curr_head=a[5];this.curr_sect=a[6];this.perpendicular=a[7];this.read_only=a[8];this.media_changed=a[9];a[10]?(this.buffer||(this.buffer=new A(new ArrayBuffer(0))),this.buffer.set_state(a[10])):this.buffer=null};const Nc={[70]:{name:"GET CONFIGURATION",flags:0},[74]:{name:"GET EVENT STATUS NOTIFICATION",flags:0},[18]:{name:"INQUIRY",flags:0},[189]:{name:"MECHANISM STATUS",flags:0},[26]:{name:"MODE SENSE (6)",flags:0},[90]:{name:"MODE SENSE (10)",flags:0},[69]:{name:"PAUSE",flags:1},[30]:{name:"PREVENT ALLOW MEDIUM REMOVAL",flags:0},[40]:{name:"READ (10)",flags:1},[168]:{name:"READ (12)",flags:1},[37]:{name:"READ CAPACITY",flags:1},[190]:{name:"READ CD",flags:1},[81]:{name:"READ DISK INFORMATION",flags:1},
|
|
462
|
+
[66]:{name:"READ SUBCHANNEL",flags:1},[67]:{name:"READ TOC PMA ATIP",flags:1},[82]:{name:"READ TRACK INFORMATION",flags:1},[3]:{name:"REQUEST SENSE",flags:0},[27]:{name:"START STOP UNIT",flags:0},[0]:{name:"TEST UNIT READY",flags:1}};
|
|
463
463
|
function Oc(a,b,c){this.cpu=a;this.bus=b;this.secondary=this.primary=void 0;b=c&&c[0][0];const d=c&&c[1][0];if(b||d){b&&(this.primary=new Pc(this,0,c[0],496,1014,14));d&&(this.secondary=new Pc(this,1,c[1],368,886,15));c=b?this.primary.command_base:0;const e=b?this.primary.control_base:0,f=d?this.secondary.command_base:0,g=d?this.secondary.control_base:0;this.name="ide";this.pci_id=240;this.pci_space=[134,128,16,112,5,0,160,2,0,128,1,1,0,0,0,0,c&255|1,c>>8,0,0,e&255|1,e>>8,0,0,f&255|1,f>>8,0,0,g&255|
|
|
464
464
|
1,g>>8,0,0,1,180,0,0,0,0,0,0,0,0,0,0,67,16,212,130,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_bars=[b?{size:8}:void 0,b?{size:1}:void 0,d?{size:8}:void 0,d?{size:1}:void 0,{size:16}];a.devices.pci.register_device(this)}Object.seal(this)}
|
|
465
465
|
Oc.prototype.get_state=function(){const a=[];a[0]=this.primary;a[1]=this.secondary;return a};Oc.prototype.set_state=function(a){this.primary&&this.primary.set_state(a[0]);this.secondary&&this.secondary.set_state(a[1])};
|
|
@@ -490,16 +490,16 @@ break;case 225:this.status_reg=80;this.push_irq();break;case 231:this.status_reg
|
|
|
490
490
|
break;case 0:this.ata_abort_command();break;case 240:z(a);this.capture_regs();this.ata_abort_command();break;default:z(a),this.capture_regs(),this.ata_abort_command()}else z(a)};
|
|
491
491
|
W.prototype.atapi_handle=function(){var a=this.data[0],b=Nc[a]?Nc[a].flags:0;this.data_pointer=0;this.current_atapi_command=a;3!==a&&(this.atapi_add_sense=this.atapi_sense_key=0);if(!this.buffer&&b&1)this.atapi_check_condition_response(2,58),this.push_irq();else{switch(a){case 0:this.buffer?(this.data_allocate(0),this.data_end=this.data_length,this.status_reg=80):this.atapi_check_condition_response(2,58);break;case 3:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=
|
|
492
492
|
88;this.data[0]=240;this.data[2]=this.atapi_sense_key;this.data[7]=8;this.data[12]=this.atapi_add_sense;this.atapi_add_sense=this.atapi_sense_key=0;break;case 18:a=this.data[4];this.status_reg=88;z(this.data[1],2);this.data.set([5,128,1,49,31,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79,77,32,67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,a);break;case 26:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status_reg=88;break;case 30:this.data_allocate(0);
|
|
493
|
-
this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status_reg=88;break;case 67:a=this.data[8]|this.data[7]<<
|
|
493
|
+
this.data_end=this.data_length;this.status_reg=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status_reg=88;break;case 40:case 168:this.features_reg&1?this.atapi_read_dma(this.data):this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status_reg=88;break;case 67:a=this.data[8]|this.data[7]<<
|
|
494
494
|
8;b=this.data[9]>>6;z(b,2);z(this.data[6]);this.data_allocate(a);this.data_end=this.data_length;0===b?(a=this.sector_count,this.data.set(new Uint8Array([0,18,1,1,0,20,1,0,0,0,0,0,0,22,170,0,a>>24,a>>16&255,a>>8&255,a&255]))):1===b&&this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0]));this.status_reg=88;break;case 70:a=Math.min(this.data[8]|this.data[7]<<8,32);this.data_allocate(a);this.data_end=this.data_length;this.data[0]=a-4>>24&255;this.data[1]=a-4>>16&255;this.data[2]=a-4>>8&255;this.data[3]=
|
|
495
495
|
a-4&255;this.data[6]=8;this.data[10]=3;this.status_reg=88;break;case 81:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;case 82:this.atapi_check_condition_response(5,36);break;case 90:a=this.data[8]|this.data[7]<<8;b=this.data[2];z(b);42===b&&this.data_allocate(Math.min(30,a));this.data_end=this.data_length;this.status_reg=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<8);this.data_end=this.data_length;this.data[5]=1;this.status_reg=88;break;case 27:a=
|
|
496
496
|
this.data[4]&3;z(this.data[1]&1);z(a);this.buffer&&2===a&&(this.medium_changed=!0,this.buffer=null);this.status_reg=80;this.data_allocate(0);this.data_end=this.data_length;break;case 69:case 74:this.atapi_check_condition_response(5,36);break;case 190:this.data_allocate(0);this.data_end=this.data_length;this.status_reg=80;break;default:z(this.data[0]),this.atapi_check_condition_response(5,36)}this.sector_count_reg=this.sector_count_reg&-8|2;0===(this.status_reg&128)&&this.push_irq();0===(this.status_reg&
|
|
497
497
|
128)&&0===this.data_length&&(this.sector_count_reg|=1,this.status_reg&=-9)}};W.prototype.atapi_check_condition_response=function(a,b){this.data_allocate(0);this.data_end=this.data_length;this.status_reg=65;this.error_reg=a<<4;this.sector_count_reg=this.sector_count_reg&-8|3;this.atapi_sense_key=a;this.atapi_add_sense=b};
|
|
498
498
|
W.prototype.do_write=function(){this.status_reg=80;var a=this.data.subarray(0,this.data_length);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)};
|
|
499
|
-
W.prototype.atapi_read=function(a){var b=
|
|
500
|
-
|
|
501
|
-
W.prototype.atapi_read_dma=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=a[7]<<8|a[8];a=a[1];var d=c*this.sector_size,e=b*this.sector_size;ra(this.name+": CD read DMA lba="+z(b)+" lbacount="+z(c)+" bytecount="+z(d)+" flags="+z(a),32768);e>=this.buffer.byteLength?(sa(!1,this.name+": CD read: Outside of disk end="+z(e+d)+" size="+z(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):(this.status_reg=208,this.report_read_start(),
|
|
502
|
-
this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.data_set(f);this.do_atapi_dma()}))};
|
|
499
|
+
W.prototype.atapi_read=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5];a=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];var c=(a>>>0)*this.sector_size;b*=this.sector_size;this.data_length=0;var d=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.lba_mid_reg=this.lba_high_reg=0;65535===d&&d--;d>c&&(d=c);this.buffer?b>=this.buffer.byteLength?(sa(!1,this.name+": CD read: Outside of disk end="+z(b+c)+" size="+z(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):0===c?(this.status_reg=
|
|
500
|
+
80,this.data_pointer=0):(c=Math.min(c,this.buffer.byteLength-b),this.status_reg=208,this.report_read_start(),this.read_buffer(b,c,e=>{this.data_set(e);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.push_irq();this.data_end=d&=-4;this.data_end>this.data_length&&(this.data_end=this.data_length);this.lba_mid_reg=this.data_end&255;this.lba_high_reg=this.data_end>>8&255;this.report_read_end(c)})):(this.status_reg=255,this.error_reg=65,this.push_irq())};
|
|
501
|
+
W.prototype.atapi_read_dma=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=168===a[0]?a[6]<<24|a[7]<<16|a[8]<<8|a[9]:a[7]<<8|a[8];c>>>=0;a=a[1];var d=c*this.sector_size,e=b*this.sector_size;ra(this.name+": CD read DMA lba="+z(b)+" lbacount="+z(c)+" bytecount="+z(d)+" flags="+z(a),32768);e>=this.buffer.byteLength?(sa(!1,this.name+": CD read: Outside of disk end="+z(e+d)+" size="+z(this.buffer.byteLength),32768),this.status_reg=255,this.push_irq()):(this.status_reg=208,this.report_read_start(),
|
|
502
|
+
this.read_buffer(e,d,f=>{this.report_read_end(d);this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.data_set(f);this.do_atapi_dma()}))};
|
|
503
503
|
W.prototype.do_atapi_dma=function(){if(0!==(this.channel.dma_status&1)&&0!==(this.status_reg&8)){var a=this.channel.prdt_addr,b=0,c=this.data;do{var d=this.cpu.read32s(a),e=this.cpu.read16(a+4),f=this.cpu.read8(a+7)&128;e||(e=65536);this.cpu.write_blob(c.subarray(b,Math.min(b+e,this.data_length)),d);b+=e;a+=8;if(b>=this.data_length&&!f)break}while(!f);this.status_reg=80;this.channel.dma_status&=-2;this.sector_count_reg=this.sector_count_reg&-8|3;this.push_irq()}};
|
|
504
504
|
W.prototype.read_data=function(a){if(this.data_pointer<this.data_end){z(this.data_pointer);var b=1===a?this.data[this.data_pointer]:2===a?this.data16[this.data_pointer>>>1]:this.data32[this.data_pointer>>>2];this.data_pointer+=a;this.data_pointer>=this.data_end&&this.read_end();return b}this.data_pointer+=a;return 0};
|
|
505
505
|
W.prototype.read_end=function(){if(160===this.current_command)if(this.data_end===this.data_length)this.status_reg=80,this.sector_count_reg=this.sector_count_reg&-8|3,this.push_irq();else{this.status_reg=88;this.sector_count_reg=this.sector_count_reg&-8|2;this.push_irq();var a=this.lba_high_reg<<8&65280|this.lba_mid_reg&255;this.data_end+a>this.data_length?(this.lba_mid_reg=this.data_length-this.data_end&255,this.lba_high_reg=this.data_length-this.data_end>>8&255,this.data_end=this.data_length):this.data_end+=
|