2024-10-02 21:03:04 +02:00
; ( function ( ) { 'use strict' ; function aa ( a , b ) { function c ( C ) { C = C . toString ( 16 ) ; return "#" + "0" . repeat ( 6 - C . length ) + C } function d ( C , x , M , O ) { C . style . width = "" ; C . style . height = "" ; O && ( C . style . transform = "" ) ; var U = C . getBoundingClientRect ( ) ; O ? C . style . transform = ( 1 === x ? "" : " scaleX(" + x + ")" ) + ( 1 === M ? "" : " scaleY(" + M + ")" ) : ( 0 === x % 1 && 0 === M % 1 ? ( f . style . imageRendering = "crisp-edges" , f . style . imageRendering = "pixelated" , f . style [ "-ms-interpolation-mode" ] = "nearest-neighbor" ) : ( f . style . imageRendering = "" , f . style [ "-ms-interpolation-mode" ] = "" ) , O = window . devicePixelRatio ||
1 , 0 !== O % 1 && ( x /= O , M /= O ) ) ; 1 !== x && ( C . style . width = U . width * x + "px" ) ; 1 !== M && ( C . style . height = U . height * M + "px" ) } var e = a . container ; this . screen _fill _buffer = b ; console . assert ( e , "options.container must be provided" ) ; var f = e . getElementsByTagName ( "canvas" ) [ 0 ] , g = f . getContext ( "2d" , { alpha : ! 1 } ) , h = e . getElementsByTagName ( "div" ) [ 0 ] , l = document . createElement ( "div" ) , m , n , p = 1 , q = 1 , r = 1 , D , y = ! ! a . use _graphical _text , u , F , w , K = ! 1 , V = ! 1 ; b = new Uint16Array ( [ 8962 , 199 , 252 , 233 , 226 , 228 , 224 , 229 , 231 , 234 , 235 , 232 , 239 , 238 , 236 , 196 , 197 , 201 , 230 , 198 ,
244 , 246 , 242 , 251 , 249 , 255 , 214 , 220 , 162 , 163 , 165 , 8359 , 402 , 225 , 237 , 243 , 250 , 241 , 209 , 170 , 186 , 191 , 8976 , 172 , 189 , 188 , 161 , 171 , 187 , 9617 , 9618 , 9619 , 9474 , 9508 , 9569 , 9570 , 9558 , 9557 , 9571 , 9553 , 9559 , 9565 , 9564 , 9563 , 9488 , 9492 , 9524 , 9516 , 9500 , 9472 , 9532 , 9566 , 9567 , 9562 , 9556 , 9577 , 9574 , 9568 , 9552 , 9580 , 9575 , 9576 , 9572 , 9573 , 9561 , 9560 , 9554 , 9555 , 9579 , 9578 , 9496 , 9484 , 9608 , 9604 , 9612 , 9616 , 9600 , 945 , 223 , 915 , 960 , 931 , 963 , 181 , 964 , 934 , 920 , 937 , 948 , 8734 , 966 , 949 , 8745 , 8801 , 177 , 8805 , 8804 , 8992 , 8993 , 247 , 8776 , 176 , 8729 , 183 , 8730 , 8319 , 178 , 9632 , 160 ] ) ; e =
new Uint16Array ( [ 32 , 9786 , 9787 , 9829 , 9830 , 9827 , 9824 , 8226 , 9688 , 9675 , 9689 , 9794 , 9792 , 9834 , 9835 , 9788 , 9658 , 9668 , 8597 , 8252 , 182 , 167 , 9644 , 8616 , 8593 , 8595 , 8594 , 8592 , 8735 , 8596 , 9650 , 9660 ] ) ; for ( var Ka = [ ] , bb , na = 0 ; 256 > na ; na ++ ) bb = 126 < na ? b [ na - 127 ] : 32 > na ? e [ na ] : na , Ka [ na ] = String . fromCharCode ( bb ) ; g . imageSmoothingEnabled = ! 1 ; l . classList . add ( "cursor" ) ; l . style . position = "absolute" ; l . style . backgroundColor = "#ccc" ; l . style . width = "7px" ; l . style . display = "inline-block" ; h . style . display = "block" ; f . style . display = "none" ; this . init = function ( ) { this . set _mode ( y ) ;
y ? this . set _size _graphical ( 720 , 400 , 720 , 400 ) : this . set _size _text ( 80 , 25 ) ; this . timer ( ) } ; this . make _screenshot = function ( ) { const C = new Image ; if ( y ) C . src = f . toDataURL ( "image/png" ) ; else { const x = [ 9 , 16 ] , M = document . createElement ( "canvas" ) ; M . width = F * x [ 0 ] ; M . height = w * x [ 1 ] ; const O = M . getContext ( "2d" ) ; O . imageSmoothingEnabled = ! 1 ; O . font = window . getComputedStyle ( h ) . font ; O . textBaseline = "top" ; for ( let U = 0 ; U < w ; U ++ ) for ( let Y = 0 ; Y < F ; Y ++ ) { const ka = 4 * ( U * F + Y ) , Ga = u [ ka + 0 ] , Ha = u [ ka + 3 ] ; O . fillStyle = c ( u [ ka + 2 ] ) ; O . fillRect ( Y * x [ 0 ] , U * x [ 1 ] , x [ 0 ] ,
x [ 1 ] ) ; O . fillStyle = c ( Ha ) ; O . fillText ( Ka [ Ga ] , Y * x [ 0 ] , U * x [ 1 ] ) } "none" !== l . style . display && m < w && n < F && ( O . fillStyle = l . style . backgroundColor , O . fillRect ( n * x [ 0 ] , m * x [ 1 ] + parseInt ( l . style . marginTop , 10 ) , parseInt ( l . style . width , 10 ) , parseInt ( l . style . height , 10 ) ) ) ; C . src = M . toDataURL ( "image/png" ) } return C } ; this . put _char = function ( C , x , M , O , U , Y ) { x = 4 * ( C * F + x ) ; u [ x + 0 ] = M ; u [ x + 1 ] = O ; u [ x + 2 ] = U ; u [ x + 3 ] = Y ; D [ C ] = 1 } ; this . timer = function ( ) { K || requestAnimationFrame ( ( ) => y ? this . update _graphical ( ) : this . update _text ( ) ) } ; this . update _text = function ( ) { for ( var C =
0 ; C < w ; C ++ ) D [ C ] && ( this . text _update _row ( C ) , D [ C ] = 0 ) ; this . timer ( ) } ; this . update _graphical = function ( ) { V || this . screen _fill _buffer ( ) ; this . timer ( ) } ; this . destroy = function ( ) { K = ! 0 } ; this . pause = function ( ) { V = ! 0 ; l . classList . remove ( "blinking-cursor" ) } ; this . continue = function ( ) { V = ! 1 ; l . classList . add ( "blinking-cursor" ) } ; this . set _mode = function ( C ) { ( y = C ) ? ( h . style . display = "none" , f . style . display = "block" ) : ( h . style . display = "block" , f . style . display = "none" ) } ; this . clear _screen = function ( ) { g . fillStyle = "#000" ; g . fillRect ( 0 , 0 , f . width ,
f . height ) } ; this . set _size _text = function ( C , x ) { if ( C !== F || x !== w ) { D = new Int8Array ( x ) ; u = new Int32Array ( C * x * 4 ) ; F = C ; for ( w = x ; h . childNodes . length > x ; ) h . removeChild ( h . firstChild ) ; for ( ; h . childNodes . length < x ; ) h . appendChild ( document . createElement ( "div" ) ) ; for ( C = 0 ; C < x ; C ++ ) this . text _update _row ( C ) ; d ( h , p , q , ! 0 ) } } ; this . set _size _graphical = function ( C , x ) { f . style . display = "block" ; f . width = C ; f . height = x ; g . imageSmoothingEnabled = ! 1 ; r = ! a . disable _autoscale && 640 >= C && 2 * C < window . innerWidth * window . devicePixelRatio && 2 * x < window . innerHeight *
window . devicePixelRatio ? 2 : 1 ; d ( f , p * r , q * r , ! 1 ) } ; this . set _scale = function ( C , x ) { p = C ; q = x ; d ( h , p , q , ! 0 ) ; d ( f , p * r , q * r , ! 1 ) } ; this . set _scale ( p , q ) ; this . update _cursor _scanline = function ( C , x , M ) { M ? ( l . style . display = "inline" , l . style . height = x - C + "px" , l . style . marginTop = C + "px" ) : l . style . display = "none" } ; this . update _cursor = function ( C , x ) { if ( C !== m || x !== n ) C < w && ( D [ C ] = 1 ) , m < w && ( D [ m ] = 1 ) , m = C , n = x } ; this . text _update _row = function ( C ) { var x = 4 * C * F , M ; var O = h . childNodes [ C ] ; var U = document . createElement ( "div" ) ; for ( var Y = 0 ; Y < F ; ) { var ka = document . createElement ( "span" ) ;
var Ga = u [ x + 1 ] ; var Ha = u [ x + 2 ] ; var W = u [ x + 3 ] ; Ga && ka . classList . add ( "blink" ) ; ka . style . backgroundColor = c ( Ha ) ; ka . style . color = c ( W ) ; for ( M = "" ; Y < F && u [ x + 1 ] === Ga && u [ x + 2 ] === Ha && u [ x + 3 ] === W ; ) if ( M += Ka [ u [ x + 0 ] ] , Y ++ , x += 4 , C === m ) if ( Y === n ) break ; else if ( Y === n + 1 ) { l . style . backgroundColor = ka . style . color ; U . appendChild ( l ) ; break } ka . textContent = M ; U . appendChild ( ka ) } O . parentNode . replaceChild ( U , O ) } ; this . update _buffer = function ( C ) { for ( const x of C ) g . putImageData ( x . image _data , x . screen _x - x . buffer _x , x . screen _y - x . buffer _y , x . buffer _x , x . buffer _y ,
x . buffer _width , x . buffer _height ) } ; this . get _text _screen = function ( ) { for ( var C = [ ] , x = 0 ; x < w ; x ++ ) C . push ( this . get _text _row ( x ) ) ; return C } ; this . get _text _row = function ( C ) { let x = "" ; for ( let M = 0 ; M < F ; M ++ ) x += String . fromCharCode ( u [ 4 * ( C * F + M ) ] ) ; return x } ; this . init ( ) } ; const ba = [ "shared" , "exclusive" , "unlock" ] ;
function ca ( a , b , c ) { this . fs = a ; this . bus = c ; this . configspace _tagname = [ 104 , 111 , 115 , 116 , 57 , 112 ] ; this . configspace _taglen = this . configspace _tagname . length ; this . VERSION = "9P2000.L" ; this . msize = this . BLOCKSIZE = 8192 ; this . replybuffer = new Uint8Array ( 2 * this . msize ) ; this . replybuffersize = 0 ; this . fids = [ ] ; this . virtio = new k ( b , { name : "virtio-9p" , pci _id : 48 , device _id : 4169 , subsystem _device _id : 9 , common : { initial _port : 43008 , queues : [ { size _supported : 32 , notify _offset : 0 } ] , features : [ 0 , 32 , 29 , 28 ] , on _driver _ok : ( ) => { } } , notification : { initial _port : 43264 ,
single _handler : ! 1 , handlers : [ d => { if ( 0 === d ) { for ( ; this . virtqueue . has _request ( ) ; ) d = this . virtqueue . pop _request ( ) , this . ReceiveRequest ( d ) ; this . virtqueue . notify _me _after ( 0 ) } } ] } , isr _status : { initial _port : 42752 } , device _specific : { initial _port : 42496 , struct : [ { bytes : 2 , name : "mount tag length" , read : ( ) => this . configspace _taglen , write : ( ) => { } } ] . concat ( t . range ( 254 ) . map ( d => ( { bytes : 1 , name : "mount tag name " + d , read : ( ) => this . configspace _tagname [ d ] || 0 , write : ( ) => { } } ) ) ) } } ) ; this . virtqueue = this . virtio . queues [ 0 ] }
ca . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . configspace _tagname ; a [ 1 ] = this . configspace _taglen ; a [ 2 ] = this . virtio ; a [ 3 ] = this . VERSION ; a [ 4 ] = this . BLOCKSIZE ; a [ 5 ] = this . msize ; a [ 6 ] = this . replybuffer ; a [ 7 ] = this . replybuffersize ; a [ 8 ] = this . fids . map ( function ( b ) { return [ b . inodeid , b . type , b . uid , b . dbg _name ] } ) ; a [ 9 ] = this . fs ; return a } ;
ca . prototype . set _state = function ( a ) { this . configspace _tagname = a [ 0 ] ; this . configspace _taglen = a [ 1 ] ; this . virtio . set _state ( a [ 2 ] ) ; this . virtqueue = this . virtio . queues [ 0 ] ; this . VERSION = a [ 3 ] ; this . BLOCKSIZE = a [ 4 ] ; this . msize = a [ 5 ] ; this . replybuffer = a [ 6 ] ; this . replybuffersize = a [ 7 ] ; this . fids = a [ 8 ] . map ( function ( b ) { return { inodeid : b [ 0 ] , type : b [ 1 ] , uid : b [ 2 ] , dbg _name : b [ 3 ] } } ) ; this . fs . set _state ( a [ 9 ] ) } ; ca . prototype . Createfid = function ( a , b , c , d ) { return { inodeid : a , type : b , uid : c , dbg _name : d } } ;
ca . prototype . update _dbg _name = function ( a , b ) { for ( const c of this . fids ) c . inodeid === a && ( c . dbg _name = b ) } ; ca . prototype . reset = function ( ) { this . fids = [ ] ; this . virtio . reset ( ) } ; ca . prototype . BuildReply = function ( a , b , c ) { v . Marshall ( [ "w" , "b" , "h" ] , [ c + 7 , a + 1 , b ] , this . replybuffer , 0 ) ; c + 7 >= this . replybuffer . length && z . Debug ( "Error in 9p: payloadsize exceeds maximum length" ) ; this . replybuffersize = c + 7 } ; ca . prototype . SendError = function ( a , b , c ) { b = v . Marshall ( [ "w" ] , [ c ] , this . replybuffer , 7 ) ; this . BuildReply ( 6 , a , b ) } ;
ca . prototype . SendReply = function ( a ) { a . set _next _blob ( this . replybuffer . subarray ( 0 , this . replybuffersize ) ) ; this . virtqueue . push _reply ( a ) ; this . virtqueue . flush _replies ( ) } ;
ca . prototype . ReceiveRequest = async function ( a ) { var b = new Uint8Array ( a . length _readable ) ; a . get _next _blob ( b ) ; var c = { offset : 0 } , d = v . Unmarshall ( [ "w" , "b" , "h" ] , b , c ) , e = d [ 0 ] , f = d [ 1 ] , g = d [ 2 ] ; switch ( f ) { case 8 : e = this . fs . GetTotalSize ( ) ; b = this . fs . GetSpace ( ) ; d = [ 16914839 ] ; d [ 1 ] = this . BLOCKSIZE ; d [ 2 ] = Math . floor ( b / d [ 1 ] ) ; d [ 3 ] = d [ 2 ] - Math . floor ( e / d [ 1 ] ) ; d [ 4 ] = d [ 2 ] - Math . floor ( e / d [ 1 ] ) ; d [ 5 ] = this . fs . CountUsedInodes ( ) ; d [ 6 ] = this . fs . CountFreeInodes ( ) ; d [ 7 ] = 0 ; d [ 8 ] = 256 ; e = v . Marshall ( "wwddddddw" . split ( "" ) , d , this . replybuffer , 7 ) ; this . BuildReply ( f ,
g , e ) ; this . SendReply ( a ) ; break ; case 112 : case 12 : d = v . Unmarshall ( [ "w" , "w" ] , b , c ) ; var h = d [ 0 ] ; c = d [ 1 ] ; z . Debug ( "[open] fid=" + h + ", mode=" + c ) ; b = this . fids [ h ] . inodeid ; var l = this . fs . GetInode ( b ) ; z . Debug ( "file open " + this . fids [ h ] . dbg _name ) ; e = this . fs . OpenInode ( b , c ) ; this . fs . AddEvent ( this . fids [ h ] . inodeid , function ( ) { z . Debug ( "file opened " + this . fids [ h ] . dbg _name + " tag:" + g ) ; var q = [ ] ; q [ 0 ] = l . qid ; q [ 1 ] = this . msize - 24 ; v . Marshall ( [ "Q" , "w" ] , q , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 17 ) ; this . SendReply ( a ) } . bind ( this ) ) ; break ; case 70 : d =
v . Unmarshall ( [ "w" , "w" , "s" ] , b , c ) ; b = d [ 0 ] ; h = d [ 1 ] ; e = d [ 2 ] ; z . Debug ( "[link] dfid=" + b + ", name=" + e ) ; e = this . fs . Link ( this . fids [ b ] . inodeid , this . fids [ h ] . inodeid , e ) ; if ( 0 > e ) { this . SendError ( g , - 1 === e ? "Operation not permitted" : "Unknown error: " + - e , - e ) ; this . SendReply ( a ) ; break } this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 16 : d = v . Unmarshall ( [ "w" , "s" , "s" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; b = d [ 2 ] ; d = d [ 3 ] ; z . Debug ( "[symlink] fid=" + h + ", name=" + e + ", symgt=" + b + ", gid=" + d ) ; b = this . fs . CreateSymlink ( e , this . fids [ h ] . inodeid , b ) ; l = this . fs . GetInode ( b ) ;
l . uid = this . fids [ h ] . uid ; l . gid = d ; v . Marshall ( [ "Q" ] , [ l . qid ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 13 ) ; this . SendReply ( a ) ; break ; case 18 : d = v . Unmarshall ( "wswwww" . split ( "" ) , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; c = d [ 2 ] ; b = d [ 3 ] ; var m = d [ 4 ] ; d = d [ 5 ] ; z . Debug ( "[mknod] fid=" + h + ", name=" + e + ", major=" + b + ", minor=" + m ) ; b = this . fs . CreateNode ( e , this . fids [ h ] . inodeid , b , m ) ; l = this . fs . GetInode ( b ) ; l . mode = c ; l . uid = this . fids [ h ] . uid ; l . gid = d ; v . Marshall ( [ "Q" ] , [ l . qid ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 13 ) ; this . SendReply ( a ) ; break ; case 22 : d = v . Unmarshall ( [ "w" ] ,
b , c ) ; h = d [ 0 ] ; l = this . fs . GetInode ( this . fids [ h ] . inodeid ) ; z . Debug ( "[readlink] fid=" + h + " name=" + this . fids [ h ] . dbg _name + " target=" + l . symlink ) ; e = v . Marshall ( [ "s" ] , [ l . symlink ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , e ) ; this . SendReply ( a ) ; break ; case 72 : d = v . Unmarshall ( [ "w" , "s" , "w" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; c = d [ 2 ] ; d = d [ 3 ] ; z . Debug ( "[mkdir] fid=" + h + ", name=" + e + ", mode=" + c + ", gid=" + d ) ; b = this . fs . CreateDirectory ( e , this . fids [ h ] . inodeid ) ; l = this . fs . GetInode ( b ) ; l . mode = c | da ; l . uid = this . fids [ h ] . uid ; l . gid = d ; v . Marshall ( [ "Q" ] , [ l . qid ] ,
this . replybuffer , 7 ) ; this . BuildReply ( f , g , 13 ) ; this . SendReply ( a ) ; break ; case 14 : d = v . Unmarshall ( [ "w" , "s" , "w" , "w" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; b = d [ 2 ] ; c = d [ 3 ] ; d = d [ 4 ] ; this . bus . send ( "9p-create" , [ e , this . fids [ h ] . inodeid ] ) ; z . Debug ( "[create] fid=" + h + ", name=" + e + ", flags=" + b + ", mode=" + c + ", gid=" + d ) ; b = this . fs . CreateFile ( e , this . fids [ h ] . inodeid ) ; this . fids [ h ] . inodeid = b ; this . fids [ h ] . type = 1 ; this . fids [ h ] . dbg _name = e ; l = this . fs . GetInode ( b ) ; l . uid = this . fids [ h ] . uid ; l . gid = d ; l . mode = c | ea ; v . Marshall ( [ "Q" , "w" ] , [ l . qid , this . msize - 24 ] , this . replybuffer ,
7 ) ; this . BuildReply ( f , g , 17 ) ; this . SendReply ( a ) ; break ; case 52 : d = v . Unmarshall ( "wbwddws" . split ( "" ) , b , c ) ; h = d [ 0 ] ; b = d [ 2 ] ; e = 0 === d [ 4 ] ? Infinity : d [ 4 ] ; d = this . fs . DescribeLock ( d [ 1 ] , d [ 3 ] , e , d [ 5 ] , d [ 6 ] ) ; z . Debug ( "[lock] fid=" + h + ", type=" + ba [ d . type ] + ", start=" + d . start + ", length=" + d . length + ", proc_id=" + d . proc _id ) ; e = this . fs . Lock ( this . fids [ h ] . inodeid , d , b ) ; v . Marshall ( [ "b" ] , [ e ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 1 ) ; this . SendReply ( a ) ; break ; case 54 : d = v . Unmarshall ( "wbddws" . split ( "" ) , b , c ) ; h = d [ 0 ] ; e = 0 === d [ 3 ] ? Infinity : d [ 3 ] ;
d = this . fs . DescribeLock ( d [ 1 ] , d [ 2 ] , e , d [ 4 ] , d [ 5 ] ) ; z . Debug ( "[getlock] fid=" + h + ", type=" + ba [ d . type ] + ", start=" + d . start + ", length=" + d . length + ", proc_id=" + d . proc _id ) ; e = this . fs . GetLock ( this . fids [ h ] . inodeid , d ) ; e || ( e = d , e . type = 2 ) ; e = v . Marshall ( [ "b" , "d" , "d" , "w" , "s" ] , [ e . type , e . start , Infinity === e . length ? 0 : e . length , e . proc _id , e . client _id ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , e ) ; this . SendReply ( a ) ; break ; case 24 : d = v . Unmarshall ( [ "w" , "d" ] , b , c ) ; h = d [ 0 ] ; l = this . fs . GetInode ( this . fids [ h ] . inodeid ) ; z . Debug ( "[getattr]: fid=" +
h + " name=" + this . fids [ h ] . dbg _name + " request mask=" + d [ 1 ] ) ; if ( ! l || l . status === fa ) { z . Debug ( "getattr: unlinked" ) ; this . SendError ( g , "No such file or directory" , 2 ) ; this . SendReply ( a ) ; break } d [ 0 ] = d [ 1 ] ; d [ 1 ] = l . qid ; d [ 2 ] = l . mode ; d [ 3 ] = l . uid ; d [ 4 ] = l . gid ; d [ 5 ] = l . nlinks ; d [ 6 ] = l . major << 8 | l . minor ; d [ 7 ] = l . size ; d [ 8 ] = this . BLOCKSIZE ; d [ 9 ] = Math . floor ( l . size / 512 + 1 ) ; d [ 10 ] = l . atime ; d [ 11 ] = 0 ; d [ 12 ] = l . mtime ; d [ 13 ] = 0 ; d [ 14 ] = l . ctime ; d [ 15 ] = 0 ; d [ 16 ] = 0 ; d [ 17 ] = 0 ; d [ 18 ] = 0 ; d [ 19 ] = 0 ; v . Marshall ( "dQwwwddddddddddddddd" . split ( "" ) , d , this . replybuffer , 7 ) ; this . BuildReply ( f ,
g , 153 ) ; this . SendReply ( a ) ; break ; case 26 : d = v . Unmarshall ( "wwwwwddddd" . split ( "" ) , b , c ) ; h = d [ 0 ] ; l = this . fs . GetInode ( this . fids [ h ] . inodeid ) ; z . Debug ( "[setattr]: fid=" + h + " request mask=" + d [ 1 ] + " name=" + this . fids [ h ] . dbg _name ) ; d [ 1 ] & 1 && ( l . mode = d [ 2 ] ) ; d [ 1 ] & 2 && ( l . uid = d [ 3 ] ) ; d [ 1 ] & 4 && ( l . gid = d [ 4 ] ) ; d [ 1 ] & 16 && ( l . atime = Math . floor ( ( new Date ) . getTime ( ) / 1E3 ) ) ; d [ 1 ] & 32 && ( l . mtime = Math . floor ( ( new Date ) . getTime ( ) / 1E3 ) ) ; d [ 1 ] & 64 && ( l . ctime = Math . floor ( ( new Date ) . getTime ( ) / 1E3 ) ) ; d [ 1 ] & 128 && ( l . atime = d [ 6 ] ) ; d [ 1 ] & 256 && ( l . mtime = d [ 8 ] ) ; d [ 1 ] & 8 &&
await this . fs . ChangeSize ( this . fids [ h ] . inodeid , d [ 5 ] ) ; this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 50 : d = v . Unmarshall ( [ "w" , "d" ] , b , c ) ; h = d [ 0 ] ; this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 40 : case 116 : d = v . Unmarshall ( [ "w" , "d" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; m = d [ 2 ] ; l = this . fs . GetInode ( this . fids [ h ] . inodeid ) ; 40 === f && z . Debug ( "[treaddir]: fid=" + h + " offset=" + e + " count=" + m ) ; 116 === f && z . Debug ( "[read]: fid=" + h + " (" + this . fids [ h ] . dbg _name + ") offset=" + e + " count=" + m + " fidtype=" + this . fids [ h ] . type ) ; if ( ! l || l . status ===
fa ) { z . Debug ( "read/treaddir: unlinked" ) ; this . SendError ( g , "No such file or directory" , 2 ) ; this . SendReply ( a ) ; break } if ( 2 === this . fids [ h ] . type ) for ( l . caps . length < e + m && ( m = l . caps . length - e ) , d = 0 ; d < m ; d ++ ) this . replybuffer [ 11 + d ] = l . caps [ e + d ] ; else this . fs . OpenInode ( this . fids [ h ] . inodeid , void 0 ) , d = this . fids [ h ] . inodeid , m = Math . min ( m , this . replybuffer . length - 11 ) , l . size < e + m ? m = l . size - e : 40 === f && ( m = this . fs . RoundToDirentry ( d , e + m ) - e ) , e > l . size && ( m = 0 ) , this . bus . send ( "9p-read-start" , [ this . fids [ h ] . dbg _name ] ) , d = await this . fs . Read ( d ,
e , m ) , this . bus . send ( "9p-read-end" , [ this . fids [ h ] . dbg _name , m ] ) , d && this . replybuffer . set ( d , 11 ) ; v . Marshall ( [ "w" ] , [ m ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 4 + m ) ; this . SendReply ( a ) ; break ; case 118 : d = v . Unmarshall ( [ "w" , "d" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; m = d [ 2 ] ; d = this . fids [ h ] . dbg _name ; z . Debug ( "[write]: fid=" + h + " (" + d + ") offset=" + e + " count=" + m + " fidtype=" + this . fids [ h ] . type ) ; if ( 2 === this . fids [ h ] . type ) { this . SendError ( g , "Setxattr not supported" , 95 ) ; this . SendReply ( a ) ; break } else await this . fs . Write ( this . fids [ h ] . inodeid , e ,
m , b . subarray ( c . offset ) ) ; this . bus . send ( "9p-write-end" , [ d , m ] ) ; v . Marshall ( [ "w" ] , [ m ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 4 ) ; this . SendReply ( a ) ; break ; case 74 : d = v . Unmarshall ( [ "w" , "s" , "w" , "s" ] , b , c ) ; e = d [ 0 ] ; b = d [ 1 ] ; c = d [ 2 ] ; d = d [ 3 ] ; z . Debug ( "[renameat]: oldname=" + b + " newname=" + d ) ; e = await this . fs . Rename ( this . fids [ e ] . inodeid , b , this . fids [ c ] . inodeid , d ) ; if ( 0 > e ) { this . SendError ( g , - 2 === e ? "No such file or directory" : - 1 === e ? "Operation not permitted" : - 39 === e ? "Directory not empty" : "Unknown error: " + - e , - e ) ; this . SendReply ( a ) ;
break } this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 76 : d = v . Unmarshall ( [ "w" , "s" , "w" ] , b , c ) ; c = d [ 0 ] ; e = d [ 1 ] ; b = d [ 2 ] ; z . Debug ( "[unlink]: dirfd=" + c + " name=" + e + " flags=" + b ) ; h = this . fs . Search ( this . fids [ c ] . inodeid , e ) ; if ( - 1 === h ) { this . SendError ( g , "No such file or directory" , 2 ) ; this . SendReply ( a ) ; break } e = this . fs . Unlink ( this . fids [ c ] . inodeid , e ) ; if ( 0 > e ) { this . SendError ( g , - 39 === e ? "Directory not empty" : - 1 === e ? "Operation not permitted" : "Unknown error: " + - e , - e ) ; this . SendReply ( a ) ; break } this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ;
break ; case 100 : d = v . Unmarshall ( [ "w" , "s" ] , b , c ) ; z . Debug ( "[version]: msize=" + d [ 0 ] + " version=" + d [ 1 ] ) ; this . msize !== d [ 0 ] && ( this . msize = d [ 0 ] , this . replybuffer = new Uint8Array ( Math . min ( 16777216 , 2 * this . msize ) ) ) ; e = v . Marshall ( [ "w" , "s" ] , [ this . msize , this . VERSION ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , e ) ; this . SendReply ( a ) ; break ; case 104 : d = v . Unmarshall ( [ "w" , "w" , "s" , "s" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 4 ] ; z . Debug ( "[attach]: fid=" + h + " afid=" + A ( d [ 1 ] ) + " uname=" + d [ 2 ] + " aname=" + d [ 3 ] ) ; this . fids [ h ] = this . Createfid ( 0 , 1 , e , "" ) ; l = this . fs . GetInode ( this . fids [ h ] . inodeid ) ;
v . Marshall ( [ "Q" ] , [ l . qid ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , 13 ) ; this . SendReply ( a ) ; this . bus . send ( "9p-attach" ) ; break ; case 108 : d = v . Unmarshall ( [ "h" ] , b , c ) ; z . Debug ( "[flush] " + g ) ; this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 110 : d = v . Unmarshall ( [ "w" , "w" , "h" ] , b , c ) ; h = d [ 0 ] ; m = d [ 1 ] ; var n = d [ 2 ] ; z . Debug ( "[walk]: fid=" + d [ 0 ] + " nwfid=" + d [ 1 ] + " nwname=" + n ) ; if ( 0 === n ) { this . fids [ m ] = this . Createfid ( this . fids [ h ] . inodeid , 1 , this . fids [ h ] . uid , this . fids [ h ] . dbg _name ) ; v . Marshall ( [ "h" ] , [ 0 ] , this . replybuffer , 7 ) ; this . BuildReply ( f ,
g , 2 ) ; this . SendReply ( a ) ; break } e = [ ] ; for ( d = 0 ; d < n ; d ++ ) e . push ( "s" ) ; c = v . Unmarshall ( e , b , c ) ; b = this . fids [ h ] . inodeid ; e = 9 ; var p = 0 ; z . Debug ( "walk in dir " + this . fids [ h ] . dbg _name + " to: " + c . toString ( ) ) ; for ( d = 0 ; d < n ; d ++ ) { b = this . fs . Search ( b , c [ d ] ) ; if ( - 1 === b ) { z . Debug ( "Could not find: " + c [ d ] ) ; break } e += v . Marshall ( [ "Q" ] , [ this . fs . GetInode ( b ) . qid ] , this . replybuffer , e ) ; p ++ ; this . fids [ m ] = this . Createfid ( b , 1 , this . fids [ h ] . uid , c [ d ] ) } v . Marshall ( [ "h" ] , [ p ] , this . replybuffer , 7 ) ; this . BuildReply ( f , g , e - 7 ) ; this . SendReply ( a ) ; break ; case 120 : d =
v . Unmarshall ( [ "w" ] , b , c ) ; z . Debug ( "[clunk]: fid=" + d [ 0 ] ) ; this . fids [ d [ 0 ] ] && 0 <= this . fids [ d [ 0 ] ] . inodeid && ( await this . fs . CloseInode ( this . fids [ d [ 0 ] ] . inodeid ) , this . fids [ d [ 0 ] ] . inodeid = - 1 , this . fids [ d [ 0 ] ] . type = - 1 ) ; this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 32 : d = v . Unmarshall ( [ "w" , "s" , "d" , "w" ] , b , c ) ; h = d [ 0 ] ; e = d [ 1 ] ; c = d [ 2 ] ; b = d [ 3 ] ; z . Debug ( "[txattrcreate]: fid=" + h + " name=" + e + " attr_size=" + c + " flags=" + b ) ; this . fids [ h ] . type = 2 ; this . BuildReply ( f , g , 0 ) ; this . SendReply ( a ) ; break ; case 30 : d = v . Unmarshall ( [ "w" , "w" , "s" ] , b ,
c ) ; h = d [ 0 ] ; e = d [ 2 ] ; z . Debug ( "[xattrwalk]: fid=" + d [ 0 ] + " newfid=" + d [ 1 ] + " name=" + d [ 2 ] ) ; this . SendError ( g , "Setxattr not supported" , 95 ) ; this . SendReply ( a ) ; break ; default : z . Debug ( "Error in Virtio9p: Unknown id " + f + " received" ) , z . Abort ( ) } } ; function B ( a ) { this . ports = [ ] ; this . cpu = a ; for ( var b = 0 ; 65536 > b ; b ++ ) this . ports [ b ] = this . create _empty _entry ( ) ; var c = a . memory _size [ 0 ] ; for ( b = 0 ; b << 17 < c ; b ++ ) a . memory _map _read8 [ b ] = a . memory _map _write8 [ b ] = void 0 , a . memory _map _read32 [ b ] = a . memory _map _write32 [ b ] = void 0 ; this . mmap _register ( c , 4294967296 - c , function ( d ) { A ( d >>> 0 , 8 ) ; return 255 } , function ( d , e ) { A ( d >>> 0 , 8 ) ; A ( e , 2 ) } , function ( d ) { A ( d >>> 0 , 8 ) ; return - 1 } , function ( d , e ) { A ( d >>> 0 , 8 ) ; A ( e >>> 0 , 8 ) } ) }
2024-06-28 09:23:02 +02:00
B . prototype . create _empty _entry = function ( ) { return { read8 : this . empty _port _read8 , read16 : this . empty _port _read16 , read32 : this . empty _port _read32 , write8 : this . empty _port _write , write16 : this . empty _port _write , write32 : this . empty _port _write , device : void 0 } } ; B . prototype . empty _port _read8 = function ( ) { return 255 } ; B . prototype . empty _port _read16 = function ( ) { return 65535 } ; B . prototype . empty _port _read32 = function ( ) { return - 1 } ; B . prototype . empty _port _write = function ( ) { } ;
B . prototype . register _read = function ( a , b , c , d , e ) { c && ( this . ports [ a ] . read8 = c ) ; d && ( this . ports [ a ] . read16 = d ) ; e && ( this . ports [ a ] . read32 = e ) ; this . ports [ a ] . device = b } ; B . prototype . register _write = function ( a , b , c , d , e ) { c && ( this . ports [ a ] . write8 = c ) ; d && ( this . ports [ a ] . write16 = d ) ; e && ( this . ports [ a ] . write32 = e ) ; this . ports [ a ] . device = b } ;
2024-10-02 21:03:04 +02:00
B . prototype . register _read _consecutive = function ( a , b , c , d , e , f ) { function g ( ) { return c . call ( this ) | d . call ( this ) << 8 } function h ( ) { return e . call ( this ) | f . call ( this ) << 8 } function l ( ) { return c . call ( this ) | d . call ( this ) << 8 | e . call ( this ) << 16 | f . call ( this ) << 24 } e && f ? ( this . register _read ( a , b , c , g , l ) , this . register _read ( a + 1 , b , d ) , this . register _read ( a + 2 , b , e , h ) , this . register _read ( a + 3 , b , f ) ) : ( this . register _read ( a , b , c , g ) , this . register _read ( a + 1 , b , d ) ) } ;
B . prototype . register _write _consecutive = function ( a , b , c , d , e , f ) { function g ( m ) { c . call ( this , m & 255 ) ; d . call ( this , m >> 8 & 255 ) } function h ( m ) { e . call ( this , m & 255 ) ; f . call ( this , m >> 8 & 255 ) } function l ( m ) { c . call ( this , m & 255 ) ; d . call ( this , m >> 8 & 255 ) ; e . call ( this , m >> 16 & 255 ) ; f . call ( this , m >>> 24 ) } e && f ? ( this . register _write ( a , b , c , g , l ) , this . register _write ( a + 1 , b , d ) , this . register _write ( a + 2 , b , e , h ) , this . register _write ( a + 3 , b , f ) ) : ( this . register _write ( a , b , c , g ) , this . register _write ( a + 1 , b , d ) ) } ;
2024-06-28 09:23:02 +02:00
B . prototype . mmap _read32 _shim = function ( a ) { var b = this . cpu . memory _map _read8 [ a >>> 17 ] ; return b ( a ) | b ( a + 1 ) << 8 | b ( a + 2 ) << 16 | b ( a + 3 ) << 24 } ; B . prototype . mmap _write32 _shim = function ( a , b ) { var c = this . cpu . memory _map _write8 [ a >>> 17 ] ; c ( a , b & 255 ) ; c ( a + 1 , b >> 8 & 255 ) ; c ( a + 2 , b >> 16 & 255 ) ; c ( a + 3 , b >>> 24 ) } ;
2024-10-02 21:03:04 +02:00
B . prototype . mmap _register = function ( a , b , c , d , e , f ) { A ( a >>> 0 , 8 ) ; A ( b , 8 ) ; e || ( e = this . mmap _read32 _shim . bind ( this ) ) ; f || ( f = this . mmap _write32 _shim . bind ( this ) ) ; for ( a >>>= 17 ; 0 < b ; a ++ ) this . cpu . memory _map _read8 [ a ] = c , this . cpu . memory _map _write8 [ a ] = d , this . cpu . memory _map _read32 [ a ] = e , this . cpu . memory _map _write32 [ a ] = f , b -= 131072 } ; B . prototype . port _write8 = function ( a , b ) { var c = this . ports [ a ] ; c . write8 === this . empty _port _write && ( A ( a , 4 ) , A ( b , 2 ) , this . get _port _description ( a ) ) ; return c . write8 . call ( c . device , b ) } ;
2024-06-28 09:23:02 +02:00
B . prototype . port _write16 = function ( a , b ) { var c = this . ports [ a ] ; c . write16 === this . empty _port _write && ( A ( a , 4 ) , A ( b , 4 ) , this . get _port _description ( a ) ) ; return c . write16 . call ( c . device , b ) } ; B . prototype . port _write32 = function ( a , b ) { var c = this . ports [ a ] ; c . write32 === this . empty _port _write && ( A ( a , 4 ) , A ( b >>> 0 , 8 ) , this . get _port _description ( a ) ) ; return c . write32 . call ( c . device , b ) } ;
B . prototype . port _read8 = function ( a ) { var b = this . ports [ a ] ; b . read8 === this . empty _port _read8 && ( A ( a , 4 ) , this . get _port _description ( a ) ) ; b = b . read8 . call ( b . device ) ; A ( a ) ; return b } ; B . prototype . port _read16 = function ( a ) { var b = this . ports [ a ] ; b . read16 === this . empty _port _read16 && ( A ( a , 4 ) , this . get _port _description ( a ) ) ; b = b . read16 . call ( b . device ) ; A ( a ) ; return b } ; B . prototype . port _read32 = function ( a ) { var b = this . ports [ a ] ; b . read32 === this . empty _port _read32 && ( A ( a , 4 ) , this . get _port _description ( a ) ) ; return b . read32 . call ( b . device ) } ;
2024-10-02 21:03:04 +02:00
var ha = { 4 : "PORT_DMA_ADDR_2" , 5 : "PORT_DMA_CNT_2" , 10 : "PORT_DMA1_MASK_REG" , 11 : "PORT_DMA1_MODE_REG" , 12 : "PORT_DMA1_CLEAR_FF_REG" , 13 : "PORT_DMA1_MASTER_CLEAR" , 32 : "PORT_PIC1_CMD" , 33 : "PORT_PIC1_DATA" , 64 : "PORT_PIT_COUNTER0" , 65 : "PORT_PIT_COUNTER1" , 66 : "PORT_PIT_COUNTER2" , 67 : "PORT_PIT_MODE" , 96 : "PORT_PS2_DATA" , 97 : "PORT_PS2_CTRLB" , 100 : "PORT_PS2_STATUS" , 112 : "PORT_CMOS_INDEX" , 113 : "PORT_CMOS_DATA" , 128 : "PORT_DIAG" , 129 : "PORT_DMA_PAGE_2" , 146 : "PORT_A20" , 160 : "PORT_PIC2_CMD" , 161 : "PORT_PIC2_DATA" , 178 : "PORT_SMI_CMD" , 179 : "PORT_SMI_STATUS" ,
2024-06-28 09:23:02 +02:00
212 : "PORT_DMA2_MASK_REG" , 214 : "PORT_DMA2_MODE_REG" , 218 : "PORT_DMA2_MASTER_CLEAR" , 240 : "PORT_MATH_CLEAR" , 368 : "PORT_ATA2_CMD_BASE" , 496 : "PORT_ATA1_CMD_BASE" , 632 : "PORT_LPT2" , 744 : "PORT_SERIAL4" , 760 : "PORT_SERIAL2" , 884 : "PORT_ATA2_CTRL_BASE" , 888 : "PORT_LPT1" , 1E3 : "PORT_SERIAL3" , 1008 : "PORT_FD_BASE" , 1010 : "PORT_FD_DOR" , 1012 : "PORT_FD_STATUS" , 1013 : "PORT_FD_DATA" , 1014 : "PORT_HD_DATA" , 1015 : "PORT_FD_DIR" , 1016 : "PORT_SERIAL1" , 3320 : "PORT_PCI_CMD" , 3321 : "PORT_PCI_REBOOT" , 3324 : "PORT_PCI_DATA" , 1026 : "PORT_BIOS_DEBUG" , 1296 : "PORT_QEMU_CFG_CTL" ,
2024-10-02 21:03:04 +02:00
1297 : "PORT_QEMU_CFG_DATA" , 45056 : "PORT_ACPI_PM_BASE" , 45312 : "PORT_SMB_BASE" , 35072 : "PORT_BIOS_APM" } ; B . prototype . get _port _description = function ( a ) { return ha [ a ] ? " (" + ha [ a ] + ")" : "" } ; function E ( a , b ) { this . stopping = this . running = ! 1 ; this . idle = ! 0 ; this . tick _counter = 0 ; this . worker = null ; this . cpu = new G ( a , b , ( ) => { this . idle && this . next _tick ( 0 ) } ) ; this . bus = a ; this . register _yield ( ) } E . prototype . run = function ( ) { this . stopping = ! 1 ; this . running || ( this . running = ! 0 , this . bus . send ( "emulator-started" ) ) ; this . next _tick ( 0 ) } ; E . prototype . do _tick = function ( ) { if ( this . stopping || ! this . running ) this . stopping = this . running = ! 1 , this . bus . send ( "emulator-stopped" ) ; else { this . idle = ! 1 ; var a = this . cpu . main _loop ( ) ; this . next _tick ( a ) } } ;
E . prototype . next _tick = function ( a ) { const b = ++ this . tick _counter ; this . idle = ! 0 ; this . yield ( a , b ) } ; E . prototype . yield _callback = function ( a ) { a === this . tick _counter && this . do _tick ( ) } ; E . prototype . stop = function ( ) { this . running && ( this . stopping = ! 0 ) } ; E . prototype . destroy = function ( ) { this . unregister _yield ( ) } ; E . prototype . restart = function ( ) { this . cpu . reset _cpu ( ) ; this . cpu . load _bios ( ) } ; E . prototype . init = function ( a ) { this . cpu . init ( a , this . bus ) ; this . bus . send ( "emulator-ready" ) } ;
if ( "undefined" !== typeof process ) E . prototype . yield = function ( a , b ) { 1 > a ? global . setImmediate ( c => this . yield _callback ( c ) , b ) : setTimeout ( c => this . yield _callback ( c ) , a , b ) } , E . prototype . register _yield = function ( ) { } , E . prototype . unregister _yield = function ( ) { } ; else if ( "undefined" !== typeof Worker ) { function a ( ) { let b ; globalThis . onmessage = function ( c ) { const d = c . data . t ; b = b && clearTimeout ( b ) ; 1 > d ? postMessage ( c . data . tick ) : b = setTimeout ( ( ) => postMessage ( c . data . tick ) , d ) } } E . prototype . register _yield = function ( ) { const b = URL . createObjectURL ( new Blob ( [ "(" +
a . toString ( ) + ")()" ] , { type : "text/javascript" } ) ) ; this . worker = new Worker ( b ) ; this . worker . onmessage = c => this . yield _callback ( c . data ) ; URL . revokeObjectURL ( b ) } ; E . prototype . yield = function ( b , c ) { this . worker . postMessage ( { t : b , tick : c } ) } ; E . prototype . unregister _yield = function ( ) { this . worker && this . worker . terminate ( ) ; this . worker = null } } else E . prototype . yield = function ( a ) { setTimeout ( ( ) => { this . do _tick ( ) } , a ) } , E . prototype . register _yield = function ( ) { } , E . prototype . unregister _yield = function ( ) { } ; E . prototype . save _state = function ( ) { return this . cpu . save _state ( ) } ;
E . prototype . restore _state = function ( a ) { return this . cpu . restore _state ( a ) } ; if ( "object" === typeof performance && performance . now ) E . microtick = performance . now . bind ( performance ) ; else if ( "function" === typeof require ) { const { performance : a } = require ( "perf_hooks" ) ; E . microtick = a . now . bind ( a ) } else E . microtick = "object" === typeof process && process . hrtime ? function ( ) { var a = process . hrtime ( ) ; return 1E3 * a [ 0 ] + a [ 1 ] / 1E6 } : Date . now ; var H = H || { } ; H . exportSymbol = function ( ) { } ; H . exportProperty = function ( ) { } ; var t = t || { } ; t . pads = function ( a , b ) { return ( a || 0 === a ? a + "" : "" ) . padEnd ( b , " " ) } ; t . pad0 = function ( a , b ) { return ( a || 0 === a ? a + "" : "" ) . padStart ( b , "0" ) } ; t . zeros = function ( a ) { return Array ( a ) . fill ( 0 ) } ; t . range = function ( a ) { return Array . from ( Array ( a ) . keys ( ) ) } ;
t . view = function ( a , b , c , d ) { return new Proxy ( { } , { get : function ( e , f ) { e = new a ( b . buffer , c , d ) ; const g = e [ f ] ; if ( "function" === typeof g ) return g . bind ( e ) ; /^\d+$/ . test ( f ) ; return g } , set : function ( e , f , g ) { /^\d+$/ . test ( f ) ; ( new a ( b . buffer , c , d ) ) [ f ] = g ; return ! 0 } } ) } ; function A ( a , b ) { a = a ? a . toString ( 16 ) : "" ; return "0x" + t . pad0 ( a . toUpperCase ( ) , b || 1 ) }
if ( "undefined" !== typeof crypto && crypto . getRandomValues ) { const a = new Int32Array ( 1 ) ; t . get _rand _int = function ( ) { crypto . getRandomValues ( a ) ; return a [ 0 ] } } else if ( "undefined" !== typeof require ) { const a = require ( "crypto" ) ; t . get _rand _int = function ( ) { return a . randomBytes ( 4 ) . readInt32LE ( 0 ) } }
( function ( ) { if ( "function" === typeof Math . clz32 ) t . int _log2 = function ( d ) { return 31 - Math . clz32 ( d ) } ; else { for ( var a = new Int8Array ( 256 ) , b = 0 , c = - 2 ; 256 > b ; b ++ ) b & b - 1 || c ++ , a [ b ] = c ; t . int _log2 = function ( d ) { d >>>= 0 ; var e = d >>> 16 ; if ( e ) { var f = e >>> 8 ; return f ? 24 + a [ f ] : 16 + a [ e ] } return ( f = d >>> 8 ) ? 8 + a [ f ] : a [ d ] } } } ) ( ) ; t . round _up _to _next _power _of _2 = function ( a ) { return 1 >= a ? 1 : 1 << 1 + t . int _log2 ( a - 1 ) } ;
function ja ( a ) { var b = new Uint8Array ( a ) , c , d ; this . length = 0 ; this . push = function ( e ) { this . length !== a && this . length ++ ; b [ d ] = e ; d = d + 1 & a - 1 } ; this . shift = function ( ) { if ( this . length ) { var e = b [ c ] ; c = c + 1 & a - 1 ; this . length -- ; return e } return - 1 } ; this . peek = function ( ) { return this . length ? b [ c ] : - 1 } ; this . clear = function ( ) { this . length = d = c = 0 } ; this . clear ( ) } function la ( a ) { this . size = a ; this . data = new Float32Array ( a ) ; this . length = this . end = this . start = 0 }
la . prototype . push = function ( a ) { this . length === this . size ? this . start = this . start + 1 & this . size - 1 : this . length ++ ; this . data [ this . end ] = a ; this . end = this . end + 1 & this . size - 1 } ; la . prototype . shift = function ( ) { if ( this . length ) { var a = this . data [ this . start ] ; this . start = this . start + 1 & this . size - 1 ; this . length -- ; return a } } ;
la . prototype . shift _block = function ( a ) { var b = new Float32Array ( a ) ; a > this . length && ( a = this . length ) ; var c = this . start + a , d = this . data . subarray ( this . start , c ) ; b . set ( d ) ; c >= this . size && ( c -= this . size , b . set ( this . data . subarray ( 0 , c ) , d . length ) ) ; this . start = c ; this . length -= a ; return b } ; la . prototype . peek = function ( ) { if ( this . length ) return this . data [ this . start ] } ; la . prototype . clear = function ( ) { this . length = this . end = this . start = 0 } ;
t . Bitmap = function ( a ) { "number" === typeof a ? this . view = new Uint8Array ( a + 7 >> 3 ) : a instanceof ArrayBuffer && ( this . view = new Uint8Array ( a ) ) } ; t . Bitmap . prototype . set = function ( a , b ) { const c = a >> 3 ; a = 1 << ( a & 7 ) ; this . view [ c ] = b ? this . view [ c ] | a : this . view [ c ] & ~ a } ; t . Bitmap . prototype . get = function ( a ) { return this . view [ a >> 3 ] >> ( a & 7 ) & 1 } ; t . Bitmap . prototype . get _buffer = function ( ) { return this . view . buffer } ; t . load _file = "undefined" === typeof XMLHttpRequest ? ma : oa ;
function oa ( a , b , c ) { function d ( ) { const l = c || 0 ; setTimeout ( ( ) => { oa ( a , b , l + 1 ) } , 1E3 * ( [ 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 ] [ l ] || 34 ) ) } var e = new XMLHttpRequest ; e . open ( b . method || "get" , a , ! 0 ) ; e . responseType = b . as _json ? "json" : "arraybuffer" ; if ( b . headers ) for ( var f = Object . keys ( b . headers ) , g = 0 ; g < f . length ; g ++ ) { var h = f [ g ] ; e . setRequestHeader ( h , b . headers [ h ] ) } b . range && ( f = b . range . start , e . setRequestHeader ( "Range" , "bytes=" + f + "-" + ( f + b . range . length - 1 ) ) , e . setRequestHeader ( "X-Accept-Encoding" , "identity" ) , e . onreadystatechange = function ( ) { 200 === e . status &&
e . abort ( ) } ) ; e . onload = function ( ) { if ( 4 === e . readyState ) if ( 200 !== e . status && 206 !== e . status ) console . error ( "Loading the image " + a + " failed (status %d)" , e . status ) , 500 <= e . status && 600 > e . status && d ( ) ; else if ( e . response ) { if ( b . range ) { const l = e . getResponseHeader ( "Content-Encoding" ) ; l && "identity" !== l && console . error ( "Server sent Content-Encoding in response to ranged request" , { filename : a , enc : l } ) } b . done && b . done ( e . response , e ) } } ; e . onerror = function ( l ) { console . error ( "Loading the image " + a + " failed" , l ) ; d ( ) } ; b . progress &&
( e . onprogress = function ( l ) { b . progress ( l ) } ) ; e . send ( null ) } function ma ( a , b ) { const c = require ( "fs" ) ; b . range ? c . open ( a , "r" , ( d , e ) => { if ( d ) throw d ; d = b . range . length ; var f = Buffer . allocUnsafe ( d ) ; c . read ( e , f , 0 , d , b . range . start , g => { if ( g ) throw g ; b . done && b . done ( new Uint8Array ( f ) ) ; c . close ( e , h => { if ( h ) throw h ; } ) } ) } ) : c . readFile ( a , { encoding : b . as _json ? "utf-8" : null } , function ( d , e ) { d ? console . log ( "Could not read file:" , a , d ) : ( d = e , d = b . as _json ? JSON . parse ( d ) : ( new Uint8Array ( d ) ) . buffer , b . done ( d ) ) } ) }
t . read _sized _string _from _mem = function ( a , b , c ) { return String . fromCharCode ( ... ( new Uint8Array ( a . buffer , b >>> 0 , c >>> 0 ) ) ) } ; ( function ( ) { function a ( g ) { this . buffer = g ; this . byteLength = g . byteLength ; this . onprogress = this . onload = void 0 } function b ( g , h , l ) { this . filename = g ; this . byteLength = h ; this . block _cache = new Map ; this . block _cache _is _write = new Set ; this . fixed _chunk _size = l ; this . cache _reads = ! ! l ; this . onprogress = this . onload = void 0 } function c ( g , h , l , m , n ) { const p = g . match ( /\.[^\.]+(\.zst)?$/ ) ; this . extension = p ? p [ 0 ] : "" ; this . basename = g . substring ( 0 , g . length - this . extension . length ) ; this . is _zstd = this . extension . endsWith ( ".zst" ) ; this . basename . endsWith ( "/" ) ||
( this . basename += "-" ) ; this . block _cache = new Map ; this . block _cache _is _write = new Set ; this . byteLength = h ; this . fixed _chunk _size = l ; this . partfile _alt _format = ! ! m ; this . zstd _decompress = n ; this . cache _reads = ! ! l ; this . onprogress = this . onload = void 0 } function d ( g ) { this . file = g ; this . byteLength = g . size ; 1073741824 < g . size && console . warn ( "SyncFileBuffer: Allocating buffer of " + ( g . size >> 20 ) + " MB ..." ) ; this . buffer = new ArrayBuffer ( g . size ) ; this . onprogress = this . onload = void 0 } function e ( g ) { this . file = g ; this . byteLength = g . size ; this . block _cache =
new Map ; this . block _cache _is _write = new Set ; this . onprogress = this . onload = void 0 } t . SyncBuffer = a ; t . AsyncXHRBuffer = b ; t . AsyncXHRPartfileBuffer = c ; t . AsyncFileBuffer = e ; t . SyncFileBuffer = d ; t . buffer _from _object = function ( g , h ) { if ( g . buffer instanceof ArrayBuffer ) return new t . SyncBuffer ( g . buffer ) ; if ( "undefined" !== typeof File && g . buffer instanceof File ) return h = g . async , void 0 === h && ( h = 268435456 <= g . buffer . size ) , h ? new t . AsyncFileBuffer ( g . buffer ) : new t . SyncFileBuffer ( g . buffer ) ; if ( g . url ) return g . use _parts ? new t . AsyncXHRPartfileBuffer ( g . url ,
g . size , g . fixed _chunk _size , ! 1 , h ) : new t . AsyncXHRBuffer ( g . url , g . size , g . fixed _chunk _size ) } ; a . prototype . load = function ( ) { this . onload && this . onload ( { buffer : this . buffer } ) } ; a . prototype . get = function ( g , h , l ) { l ( new Uint8Array ( this . buffer , g , h ) ) } ; a . prototype . set = function ( g , h , l ) { ( new Uint8Array ( this . buffer , g , h . byteLength ) ) . set ( h ) ; l ( ) } ; a . prototype . get _buffer = function ( g ) { g ( this . buffer ) } ; a . prototype . get _state = function ( ) { const g = [ ] ; g [ 0 ] = this . byteLength ; g [ 1 ] = new Uint8Array ( this . buffer ) ; return g } ; a . prototype . set _state =
function ( g ) { this . byteLength = g [ 0 ] ; this . buffer = g [ 1 ] . slice ( ) . buffer } ; b . prototype . load = function ( ) { void 0 !== this . byteLength ? this . onload && this . onload ( Object . create ( null ) ) : f ( this . filename , ( g , h ) => { if ( g ) throw Error ( "Cannot use: " + this . filename + ". " + g ) ; this . byteLength = h ; this . onload && this . onload ( Object . create ( null ) ) } ) } ; b . prototype . get _from _cache = function ( g , h ) { var l = h / 256 ; g /= 256 ; for ( var m = 0 ; m < l ; m ++ ) if ( ! this . block _cache . get ( g + m ) ) return ; if ( 1 === l ) return this . block _cache . get ( g ) ; h = new Uint8Array ( h ) ; for ( m = 0 ; m < l ; m ++ ) h . set ( this . block _cache . get ( g +
m ) , 256 * m ) ; return h } ; b . prototype . get = function ( g , h , l ) { var m = this . get _from _cache ( g , h ) ; if ( m ) l ( m ) ; else { var n = g , p = h ; this . fixed _chunk _size && ( n = g - g % this . fixed _chunk _size , p = Math . ceil ( ( g - n + h ) / this . fixed _chunk _size ) * this . fixed _chunk _size ) ; t . load _file ( this . filename , { done : function ( q ) { q = new Uint8Array ( q ) ; this . handle _read ( n , p , q ) ; n === g && p === h ? l ( q ) : l ( q . subarray ( g - n , g - n + h ) ) } . bind ( this ) , range : { start : n , length : p } } ) } } ; b . prototype . set = function ( g , h , l ) { g /= 256 ; for ( var m = h . length / 256 , n = 0 ; n < m ; n ++ ) { var p = this . block _cache . get ( g +
n ) ; if ( void 0 === p ) p = h . slice ( 256 * n , 256 * ( n + 1 ) ) , this . block _cache . set ( g + n , p ) ; else { const q = h . subarray ( 256 * n , 256 * ( n + 1 ) ) ; p . set ( q ) } this . block _cache _is _write . add ( g + n ) } l ( ) } ; b . prototype . handle _read = function ( g , h , l ) { g /= 256 ; h /= 256 ; for ( var m = 0 ; m < h ; m ++ ) { const n = this . block _cache . get ( g + m ) ; n ? l . set ( n , 256 * m ) : this . cache _reads && this . block _cache . set ( g + m , l . slice ( 256 * m , 256 * ( m + 1 ) ) ) } } ; b . prototype . get _buffer = function ( g ) { g ( ) } ; b . prototype . get _state = function ( ) { const g = [ ] , h = [ ] ; for ( const [ l , m ] of this . block _cache ) isFinite ( l ) , this . block _cache _is _write . has ( l ) &&
h . push ( [ l , m ] ) ; g [ 0 ] = h ; return g } ; b . prototype . set _state = function ( g ) { g = g [ 0 ] ; this . block _cache . clear ( ) ; this . block _cache _is _write . clear ( ) ; for ( const [ h , l ] of g ) isFinite ( h ) , this . block _cache . set ( h , l ) , this . block _cache _is _write . add ( h ) } ; c . prototype . load = function ( ) { this . onload && this . onload ( Object . create ( null ) ) } ; c . prototype . get = function ( g , h , l ) { var m = this . get _from _cache ( g , h ) ; if ( m ) l ( m ) ; else if ( this . fixed _chunk _size ) { const p = Math . floor ( g / this . fixed _chunk _size ) , q = g - p * this . fixed _chunk _size , r = Math . ceil ( ( q + h ) / this . fixed _chunk _size ) ,
D = new Uint8Array ( r * this . fixed _chunk _size ) ; let y = 0 ; for ( let u = 0 ; u < r ; u ++ ) { var n = ( p + u ) * this . fixed _chunk _size ; m = this . partfile _alt _format ? this . basename + ( p + u + "" ) . padStart ( 8 , "0" ) + this . extension : this . basename + n + "-" + ( n + this . fixed _chunk _size ) + this . extension ; ( n = this . get _from _cache ( n , this . fixed _chunk _size ) ) ? ( D . set ( n , u * this . fixed _chunk _size ) , y ++ , y === r && l ( D . subarray ( q , q + h ) ) ) : t . load _file ( m , { done : async function ( F ) { F = new Uint8Array ( F ) ; this . is _zstd && ( F = await this . zstd _decompress ( this . fixed _chunk _size , F ) , F = new Uint8Array ( F ) ) ;
D . set ( F , u * this . fixed _chunk _size ) ; this . handle _read ( ( p + u ) * this . fixed _chunk _size , this . fixed _chunk _size | 0 , F ) ; y ++ ; y === r && l ( D . subarray ( q , q + h ) ) } . bind ( this ) } ) } } else t . load _file ( this . basename + g + "-" + ( g + h ) + this . extension , { done : function ( p ) { p = new Uint8Array ( p ) ; this . handle _read ( g , h , p ) ; l ( p ) } . bind ( this ) } ) } ; c . prototype . get _from _cache = b . prototype . get _from _cache ; c . prototype . set = b . prototype . set ; c . prototype . handle _read = b . prototype . handle _read ; c . prototype . get _state = b . prototype . get _state ; c . prototype . set _state = b . prototype . set _state ;
d . prototype . load = function ( ) { this . load _next ( 0 ) } ; d . prototype . load _next = function ( g ) { var h = new FileReader ; h . onload = function ( m ) { m = new Uint8Array ( m . target . result ) ; ( new Uint8Array ( this . buffer , g ) ) . set ( m ) ; this . load _next ( g + 4194304 ) } . bind ( this ) ; if ( this . onprogress ) this . onprogress ( { loaded : g , total : this . byteLength , lengthComputable : ! 0 } ) ; if ( g < this . byteLength ) { var l = this . file . slice ( g , Math . min ( g + 4194304 , this . byteLength ) ) ; h . readAsArrayBuffer ( l ) } else this . file = void 0 , this . onload && this . onload ( { buffer : this . buffer } ) } ; d . prototype . get =
a . prototype . get ; d . prototype . set = a . prototype . set ; d . prototype . get _buffer = a . prototype . get _buffer ; d . prototype . get _state = a . prototype . get _state ; d . prototype . set _state = a . prototype . set _state ; e . prototype . load = function ( ) { this . onload && this . onload ( Object . create ( null ) ) } ; e . prototype . get = function ( g , h , l ) { var m = this . get _from _cache ( g , h ) ; m ? l ( m ) : ( m = new FileReader , m . onload = function ( n ) { n = new Uint8Array ( n . target . result ) ; this . handle _read ( g , h , n ) ; l ( n ) } . bind ( this ) , m . readAsArrayBuffer ( this . file . slice ( g , g + h ) ) ) } ; e . prototype . get _from _cache =
b . prototype . get _from _cache ; e . prototype . set = b . prototype . set ; e . prototype . handle _read = b . prototype . handle _read ; e . prototype . get _state = b . prototype . get _state ; e . prototype . set _state = b . prototype . set _state ; e . prototype . get _buffer = function ( g ) { g ( ) } ; e . prototype . get _as _file = function ( g ) { for ( var h = [ ] , l = Array . from ( this . block _cache . keys ( ) ) . sort ( function ( r , D ) { return r - D } ) , m = 0 , n = 0 ; n < l . length ; n ++ ) { var p = l [ n ] , q = this . block _cache . get ( p ) ; p *= 256 ; p !== m && ( h . push ( this . file . slice ( m , p ) ) , m = p ) ; h . push ( q ) ; m += q . length } m !== this . file . size &&
h . push ( this . file . slice ( m ) ) ; return new File ( h , g ) } ; var f = "undefined" === typeof XMLHttpRequest ? function ( g , h ) { require ( "fs" ) . stat ( g , ( l , m ) => { l ? h ( l ) : h ( null , m . size ) } ) } : function ( g , h ) { t . load _file ( g , { done : ( l , m ) => { l = m . getResponseHeader ( "Content-Range" ) || "" ; ( m = l . match ( /\/(\d+)\s*$/ ) ) ? h ( null , + m [ 1 ] ) : h ( "`Range: bytes=...` header not supported (Got `" + l + "`)" ) } , headers : { Range : "bytes=0-0" , "X-Accept-Encoding" : "identity" } } ) } } ) ( ) ; function pa ( a , b , c , d , e , f ) { this . master = new I ( this , a , b , d , e , 0 , f ) ; this . slave = new I ( this , a , c , ! 1 , e , 1 , f ) ; this . current _interface = this . master ; this . cpu = a ; 0 === e ? ( this . ata _port = 496 , this . irq = 14 , this . pci _id = 240 ) : 1 === e && ( this . ata _port = 368 , this . irq = 15 , this . pci _id = 248 ) ; this . ata _port _high = this . ata _port | 516 ; this . master _port = 46080 ; this . pci _space = [ 134 , 128 , 16 , 112 , 5 , 0 , 160 , 2 , 0 , 128 , 1 , 1 , 0 , 0 , 0 , 0 , this . ata _port & 255 | 1 , this . ata _port >> 8 , 0 , 0 , this . ata _port _high & 255 | 1 , this . ata _port _high >> 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , this . master _port & 255 | 1 ,
2024-06-28 09:23:02 +02:00
this . master _port >> 8 , 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 , this . irq , 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 = [ { size : 8 } , { size : 4 } , void 0 , void 0 , { size : 16 } ] ; this . name = "ide" + e ; this . device _control = 2 ; a . io . register _read ( this . ata _port | 7 , this , function ( ) { this . cpu . device _lower _irq ( this . irq ) ; return this . read _status ( ) } ) ; a . io . register _read ( this . ata _port _high |
2 , this , this . read _status ) ; a . io . register _write ( this . ata _port _high | 2 , this , this . write _control ) ; a . io . register _read ( this . ata _port | 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 . ata _port | 1 , this , function ( ) { A ( this . current _interface . error & 255 ) ; return this . current _interface . error & 255 } ) ; a . io . register _read ( this . ata _port | 2 , this , function ( ) { A ( this . current _interface . bytecount &
255 ) ; return this . current _interface . bytecount & 255 } ) ; a . io . register _read ( this . ata _port | 3 , this , function ( ) { A ( this . current _interface . sector & 255 ) ; return this . current _interface . sector & 255 } ) ; a . io . register _read ( this . ata _port | 4 , this , function ( ) { A ( this . current _interface . cylinder _low & 255 ) ; return this . current _interface . cylinder _low & 255 } ) ; a . io . register _read ( this . ata _port | 5 , this , function ( ) { A ( this . current _interface . cylinder _high & 255 ) ; return this . current _interface . cylinder _high & 255 } ) ; a . io . register _read ( this . ata _port |
2024-10-02 21:03:04 +02:00
6 , this , function ( ) { return this . current _interface . drive _head & 255 } ) ; a . io . register _write ( this . ata _port | 0 , this , function ( g ) { this . current _interface . write _data _port8 ( g ) } , function ( g ) { this . current _interface . write _data _port16 ( g ) } , function ( g ) { this . current _interface . write _data _port32 ( g ) } ) ; a . io . register _write ( this . ata _port | 1 , this , function ( g ) { A ( g ) ; this . master . lba _count = ( this . master . lba _count << 8 | g ) & 65535 ; this . slave . lba _count = ( this . slave . lba _count << 8 | g ) & 65535 } ) ; a . io . register _write ( this . ata _port | 2 , this , function ( g ) { A ( g ) ;
this . master . bytecount = ( this . master . bytecount << 8 | g ) & 65535 ; this . slave . bytecount = ( this . slave . bytecount << 8 | g ) & 65535 } ) ; a . io . register _write ( this . ata _port | 3 , this , function ( g ) { A ( g ) ; this . master . sector = ( this . master . sector << 8 | g ) & 65535 ; this . slave . sector = ( this . slave . sector << 8 | g ) & 65535 } ) ; a . io . register _write ( this . ata _port | 4 , this , function ( g ) { A ( g ) ; this . master . cylinder _low = ( this . master . cylinder _low << 8 | g ) & 65535 ; this . slave . cylinder _low = ( this . slave . cylinder _low << 8 | g ) & 65535 } ) ; a . io . register _write ( this . ata _port | 5 , this , function ( g ) { A ( g ) ;
this . master . cylinder _high = ( this . master . cylinder _high << 8 | g ) & 65535 ; this . slave . cylinder _high = ( this . slave . cylinder _high << 8 | g ) & 65535 } ) ; a . io . register _write ( this . ata _port | 6 , this , function ( g ) { var h = g & 16 ; A ( g , 2 ) ; this . current _interface = h ? this . slave : this . master ; this . master . drive _head = g ; this . slave . drive _head = g ; this . master . is _lba = this . slave . is _lba = g >> 6 & 1 ; this . master . head = this . slave . head = g & 15 } ) ; this . dma _command = this . dma _status = this . prdt _addr = 0 ; a . io . register _write ( this . ata _port | 7 , this , function ( g ) { this . cpu . device _lower _irq ( this . irq ) ;
this . current _interface . ata _command ( g ) } ) ; a . io . register _read ( this . master _port | 4 , this , void 0 , void 0 , this . dma _read _addr ) ; a . io . register _write ( this . master _port | 4 , this , void 0 , void 0 , this . dma _set _addr ) ; a . io . register _read ( this . master _port , this , this . dma _read _command8 , void 0 , this . dma _read _command ) ; a . io . register _write ( this . master _port , this , this . dma _write _command8 , void 0 , this . dma _write _command ) ; a . io . register _read ( this . master _port | 2 , this , this . dma _read _status ) ; a . io . register _write ( this . master _port | 2 , this , this . dma _write _status ) ;
a . io . register _read ( this . master _port | 8 , this , function ( ) { return 0 } ) ; a . io . register _read ( this . master _port | 10 , this , function ( ) { return 0 } ) ; a . devices . pci . register _device ( this ) } pa . prototype . read _status = function ( ) { if ( this . current _interface . buffer ) { var a = this . current _interface . status ; A ( a , 2 ) ; return a } return 0 } ; pa . prototype . write _control = function ( a ) { A ( a , 2 ) ; a & 4 && ( this . cpu . device _lower _irq ( this . irq ) , this . master . device _reset ( ) , this . slave . device _reset ( ) ) ; this . device _control = a } ;
pa . prototype . dma _read _addr = function ( ) { A ( this . prdt _addr , 8 ) ; return this . prdt _addr } ; pa . prototype . dma _set _addr = function ( a ) { A ( a , 8 ) ; this . prdt _addr = a } ; pa . prototype . dma _read _status = function ( ) { A ( this . dma _status ) ; return this . dma _status } ; pa . prototype . dma _write _status = function ( a ) { A ( a ) ; this . dma _status &= ~ ( a & 6 ) } ; pa . prototype . dma _read _command = function ( ) { return this . dma _read _command8 ( ) | this . dma _read _status ( ) << 16 } ; pa . prototype . dma _read _command8 = function ( ) { A ( this . dma _command ) ; return this . dma _command } ;
pa . prototype . dma _write _command = function ( a ) { A ( a ) ; this . dma _write _command8 ( a & 255 ) ; this . dma _write _status ( a >> 16 & 255 ) } ;
pa . prototype . dma _write _command8 = function ( a ) { A ( a ) ; const b = this . dma _command ; this . dma _command = a & 9 ; if ( ( b & 1 ) !== ( a & 1 ) ) if ( 0 === ( a & 1 ) ) this . dma _status &= - 2 ; else switch ( this . dma _status |= 1 , this . current _interface . current _command ) { case 37 : case 200 : this . current _interface . do _ata _read _sectors _dma ( ) ; break ; case 202 : case 53 : this . current _interface . do _ata _write _sectors _dma ( ) ; break ; case 160 : this . current _interface . do _atapi _dma ( ) ; break ; default : A ( this . current _interface . current _command ) } } ;
pa . prototype . push _irq = function ( ) { 0 === ( this . device _control & 2 ) && ( this . dma _status |= 4 , this . cpu . device _raise _irq ( this . irq ) ) } ; pa . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . master ; a [ 1 ] = this . slave ; a [ 2 ] = this . ata _port ; a [ 3 ] = this . irq ; a [ 4 ] = this . pci _id ; a [ 5 ] = this . ata _port _high ; a [ 6 ] = this . master _port ; a [ 7 ] = this . name ; a [ 8 ] = this . device _control ; a [ 9 ] = this . prdt _addr ; a [ 10 ] = this . dma _status ; a [ 11 ] = this . current _interface === this . master ; a [ 12 ] = this . dma _command ; return a } ;
pa . prototype . set _state = function ( a ) { this . master . set _state ( a [ 0 ] ) ; this . slave . set _state ( a [ 1 ] ) ; this . ata _port = a [ 2 ] ; this . irq = a [ 3 ] ; this . pci _id = a [ 4 ] ; this . ata _port _high = a [ 5 ] ; this . master _port = a [ 6 ] ; this . name = a [ 7 ] ; this . device _control = a [ 8 ] ; this . prdt _addr = a [ 9 ] ; this . dma _status = a [ 10 ] ; this . current _interface = a [ 11 ] ? this . master : this . slave ; this . dma _command = a [ 12 ] } ;
function I ( a , b , c , d , e , f , g ) { this . device = a ; this . bus = g ; this . nr = e ; this . cpu = b ; this . buffer = c ; this . sector _size = d ? 2048 : 512 ; this . is _atapi = d ; this . cylinder _count = this . sectors _per _track = this . head _count = this . sector _count = 0 ; this . buffer && ( this . sector _count = this . buffer . byteLength / this . sector _size , this . sector _count !== ( this . sector _count | 0 ) && ( this . sector _count = Math . ceil ( this . sector _count ) ) , d ? ( this . head _count = 1 , this . sectors _per _track = 0 ) : ( this . head _count = 16 , this . sectors _per _track = 63 ) , this . cylinder _count = this . sector _count /
2024-06-28 09:23:02 +02:00
this . head _count / this . sectors _per _track , this . cylinder _count !== ( this . cylinder _count | 0 ) && ( this . cylinder _count = Math . floor ( this . cylinder _count ) ) , a = b . devices . rtc , a . cmos _write ( 57 , a . cmos _read ( 57 ) | 1 << 4 * this . nr ) , a . cmos _write ( 18 , a . cmos _read ( 18 ) & 15 | 240 ) , a . cmos _write ( 27 , this . cylinder _count & 255 ) , a . cmos _write ( 28 , this . cylinder _count >> 8 & 255 ) , a . cmos _write ( 29 , this . head _count & 255 ) , a . cmos _write ( 30 , 255 ) , a . cmos _write ( 31 , 255 ) , a . cmos _write ( 32 , 200 ) , a . cmos _write ( 33 , this . cylinder _count & 255 ) , a . cmos _write ( 34 , this . cylinder _count >>
2024-10-02 21:03:04 +02:00
8 & 255 ) , a . cmos _write ( 35 , this . sectors _per _track & 255 ) ) ; this . buffer = c ; this . drive _head = this . head = this . cylinder _high = this . cylinder _low = this . lba _count = this . sector = this . bytecount = this . is _lba = 0 ; this . status = 80 ; this . sectors _per _drq = 128 ; this . data _pointer = this . error = 0 ; this . data = new Uint8Array ( 65536 ) ; this . data16 = new Uint16Array ( this . data . buffer ) ; this . data32 = new Int32Array ( this . data . buffer ) ; this . data _end = this . data _length = 0 ; this . current _atapi _command = this . current _command = - 1 ; this . last _io _id = this . write _dest = 0 ; this . in _progress _io _ids =
new Set ; this . cancelled _io _ids = new Set ; Object . seal ( this ) } I . prototype . device _reset = function ( ) { this . is _atapi ? ( this . status = 0 , this . sector = this . error = this . bytecount = 1 , this . cylinder _low = 20 , this . cylinder _high = 235 ) : ( this . status = 81 , this . sector = this . error = this . bytecount = 1 , this . cylinder _high = this . cylinder _low = 0 ) ; this . cancel _io _operations ( ) } ; I . prototype . push _irq = function ( ) { this . device . push _irq ( ) } ;
I . prototype . ata _command = function ( a ) { A ( a ) ; if ( this . buffer ) switch ( this . current _command = a , this . error = 0 , a ) { case 8 : this . data _length = this . data _end = this . data _pointer = 0 ; this . device _reset ( ) ; this . push _irq ( ) ; break ; case 16 : this . status = 80 ; this . cylinder _low = 0 ; this . push _irq ( ) ; break ; case 248 : this . status = 80 ; a = this . sector _count - 1 ; this . sector = a & 255 ; this . cylinder _low = a >> 8 & 255 ; this . cylinder _high = a >> 16 & 255 ; this . drive _head = this . drive _head & 240 | a >> 24 & 15 ; this . push _irq ( ) ; break ; case 39 : this . status = 80 ; a = this . sector _count - 1 ; this . sector =
2024-06-28 09:23:02 +02:00
a & 255 ; this . cylinder _low = a >> 8 & 255 ; this . cylinder _high = a >> 16 & 255 ; this . sector |= a >> 24 << 8 & 65280 ; this . push _irq ( ) ; break ; case 32 : case 36 : case 41 : case 196 : this . ata _read _sectors ( a ) ; break ; case 48 : case 52 : case 57 : case 197 : this . ata _write _sectors ( a ) ; break ; case 144 : this . push _irq ( ) ; this . error = 257 ; this . status = 80 ; break ; case 145 : this . status = 80 ; this . push _irq ( ) ; break ; case 160 : this . is _atapi && ( this . status = 88 , this . data _allocate ( 12 ) , this . data _end = 12 , this . bytecount = 1 , this . push _irq ( ) ) ; break ; case 161 : this . is _atapi ? ( this . create _identify _packet ( ) ,
this . status = 88 , this . cylinder _low = 20 , this . cylinder _high = 235 ) : this . status = 65 ; this . push _irq ( ) ; break ; case 198 : A ( this . bytecount & 255 ) ; this . sectors _per _drq = this . bytecount & 255 ; this . status = 80 ; this . push _irq ( ) ; break ; case 37 : case 200 : this . ata _read _sectors _dma ( a ) ; break ; case 53 : case 202 : this . ata _write _sectors _dma ( a ) ; break ; case 64 : this . status = 80 ; this . push _irq ( ) ; break ; case 218 : this . status = 65 ; this . error = 4 ; this . push _irq ( ) ; break ; case 224 : this . status = 80 ; this . push _irq ( ) ; break ; case 225 : this . status = 80 ; this . push _irq ( ) ; break ;
case 231 : this . status = 80 ; this . push _irq ( ) ; break ; case 236 : if ( this . is _atapi ) { this . status = 65 ; this . error = 4 ; this . push _irq ( ) ; break } this . create _identify _packet ( ) ; this . status = 88 ; this . push _irq ( ) ; break ; case 234 : this . status = 80 ; this . push _irq ( ) ; break ; case 239 : A ( this . bytecount & 255 ) ; this . status = 80 ; this . push _irq ( ) ; break ; case 222 : this . status = 80 ; this . push _irq ( ) ; break ; case 245 : this . status = 80 ; this . push _irq ( ) ; break ; case 249 : this . status = 65 ; this . error = 4 ; break ; default : A ( a ) , this . status = 65 , this . error = 4 } else this . error = 4 , this . status =
65 , this . push _irq ( ) } ;
2024-10-02 21:03:04 +02:00
I . prototype . atapi _handle = function ( ) { A ( this . data [ 0 ] ) ; this . data _pointer = 0 ; this . current _atapi _command = this . data [ 0 ] ; switch ( this . current _atapi _command ) { case 0 : this . data _allocate ( 0 ) ; this . data _end = this . data _length ; this . status = 80 ; break ; case 3 : this . data _allocate ( this . data [ 4 ] ) ; this . data _end = this . data _length ; this . status = 88 ; this . data [ 0 ] = 240 ; this . data [ 2 ] = 5 ; this . data [ 7 ] = 8 ; break ; case 18 : var a = this . data [ 4 ] ; this . status = 88 ; A ( 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 ,
2024-06-28 09:23:02 +02:00
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 = 88 ; break ; case 30 : this . data _allocate ( 0 ) ; this . data _end = this . data _length ; this . status = 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 = 88 ; break ; case 40 : this . lba _count & 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 = 88 ; break ; case 67 : a = this . data [ 8 ] | this . data [ 7 ] << 8 ; var b = this . data [ 9 ] >> 6 ; this . data _allocate ( a ) ; this . data _end = this . data _length ; A ( b , 2 ) ; A ( this . data [ 6 ] ) ; 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 = 88 ; break ; case 70 : a =
this . data [ 8 ] | this . data [ 7 ] << 8 ; a = Math . min ( a , 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 ] = a - 4 & 255 ; this . data [ 6 ] = 8 ; this . data [ 10 ] = 3 ; this . status = 88 ; break ; case 81 : this . data _allocate ( 0 ) ; this . data _end = this . data _length ; this . status = 80 ; break ; case 82 : A ( this . data [ 0 ] ) ; this . status = 81 ; this . data _length = 0 ; this . error = 80 ; break ; case 90 : a = this . data [ 8 ] | this . data [ 7 ] << 8 ; b = this . data [ 2 ] ; A ( b ) ; 42 === b && this . data _allocate ( Math . min ( 30 ,
a ) ) ; this . data _end = this . data _length ; this . status = 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 = 88 ; break ; case 74 : this . status = 81 ; this . data _length = 0 ; this . error = 80 ; A ( this . data [ 0 ] ) ; break ; case 190 : A ( this . data [ 0 ] ) ; this . data _allocate ( 0 ) ; this . data _end = this . data _length ; this . status = 80 ; break ; default : this . status = 81 , this . data _length = 0 , this . error = 80 , A ( this . data [ 0 ] ) } this . bytecount = this . bytecount & - 8 | 2 ; 0 === ( this . status & 128 ) && this . push _irq ( ) ;
2024-10-02 21:03:04 +02:00
0 === ( this . status & 128 ) && 0 === this . data _length && ( this . bytecount |= 1 , this . status &= - 9 ) } ; I . prototype . do _write = function ( ) { this . status = 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 ) } ;
I . prototype . atapi _read = 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 ; qa ( "CD read lba=" + A ( b ) + " lbacount=" + A ( c ) + " bytecount=" + A ( d ) + " flags=" + A ( a ) , 32768 ) ; this . data _length = 0 ; var f = this . cylinder _high << 8 & 65280 | this . cylinder _low & 255 ; qa ( A ( this . cylinder _high , 2 ) + " " + A ( this . cylinder _low , 2 ) , 32768 ) ; this . cylinder _low = this . cylinder _high = 0 ; 65535 === f && f -- ; f > d && ( f = d ) ; e >= this . buffer . byteLength ? ( ra ( ! 1 , "CD read: Outside of disk end=" + A ( e + d ) + " size=" +
A ( this . buffer . byteLength ) , 32768 ) , this . status = 255 , this . push _irq ( ) ) : 0 === d ? ( this . status = 80 , this . data _pointer = 0 ) : ( d = Math . min ( d , this . buffer . byteLength - e ) , this . status = 208 , this . report _read _start ( ) , this . read _buffer ( e , d , g => { this . data _set ( g ) ; this . status = 88 ; this . bytecount = this . bytecount & - 8 | 2 ; this . push _irq ( ) ; this . data _end = f &= - 4 ; this . data _end > this . data _length && ( this . data _end = this . data _length ) ; this . cylinder _low = this . data _end & 255 ; this . cylinder _high = this . data _end >> 8 & 255 ; this . report _read _end ( d ) } ) ) } ;
I . 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 ; qa ( "CD read DMA lba=" + A ( b ) + " lbacount=" + A ( c ) + " bytecount=" + A ( d ) + " flags=" + A ( a ) , 32768 ) ; e >= this . buffer . byteLength ? ( ra ( ! 1 , "CD read: Outside of disk end=" + A ( e + d ) + " size=" + A ( this . buffer . byteLength ) , 32768 ) , this . status = 255 , this . push _irq ( ) ) : ( this . status = 208 , this . report _read _start ( ) , this . read _buffer ( e , d , f => { this . report _read _end ( d ) ; this . status = 88 ; this . bytecount = this . bytecount &
- 8 | 2 ; this . data _set ( f ) ; this . do _atapi _dma ( ) } ) ) } ;
I . prototype . do _atapi _dma = function ( ) { if ( 0 !== ( this . device . dma _status & 1 ) && 0 !== ( this . status & 8 ) ) { var a = this . device . 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 ) ; A ( d ) ; A ( e ) ; A ( this . data _length ) ; 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 ) { A ( b ) ; A ( this . data _length ) ; A ( this . current _command ) ; break } } while ( ! f ) ; this . status = 80 ; this . device . dma _status &= - 2 ; this . bytecount = this . bytecount &
- 8 | 3 ; this . push _irq ( ) } } ; I . prototype . read _data = function ( a ) { if ( this . data _pointer < this . data _end ) { A ( 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 ; 0 === ( this . data _pointer & ( 0 === ( this . data _end & 4095 ) ? 4095 : 255 ) ) && ( A ( this . data [ this . data _pointer ] , 2 ) , A ( this . data _pointer ) , A ( this . data _length ) ) ; this . data _pointer >= this . data _end && this . read _end ( ) ; return b } this . data _pointer += a ; return 0 } ;
I . prototype . read _end = function ( ) { A ( this . current _command ) ; A ( this . data _pointer ) ; A ( this . data _end ) ; A ( this . data _length ) ; if ( 160 === this . current _command ) if ( this . data _end === this . data _length ) this . status = 80 , this . bytecount = this . bytecount & - 8 | 3 , this . push _irq ( ) ; else { this . status = 88 ; this . bytecount = this . bytecount & - 8 | 2 ; this . push _irq ( ) ; var a = this . cylinder _high << 8 & 65280 | this . cylinder _low & 255 ; this . data _end + a > this . data _length ? ( this . cylinder _low = this . data _length - this . data _end & 255 , this . cylinder _high = this . data _length - this . data _end >>
2024-06-28 09:23:02 +02:00
8 & 255 , this . data _end = this . data _length ) : this . data _end += a ; A ( this . data _end ) } else this . error = 0 , this . data _pointer >= this . data _length ? this . status = 80 : ( a = 196 === this . current _command || 41 === this . current _command ? Math . min ( this . sectors _per _drq , ( this . data _length - this . data _end ) / 512 ) : 1 , this . ata _advance ( this . current _command , a ) , this . data _end += 512 * a , this . status = 88 , this . push _irq ( ) ) } ;
2024-10-02 21:03:04 +02:00
I . prototype . write _data _port = function ( a , b ) { if ( this . data _pointer >= this . data _end ) A ( a ) , A ( this . data _end ) , A ( this . data _pointer ) ; else { if ( 0 === ( this . data _pointer + b & ( 0 === ( this . data _end & 4095 ) ? 4095 : 255 ) ) || 20 > this . data _end ) A ( a >>> 0 ) , A ( this . data _end ) , A ( this . data _pointer ) ; 1 === b ? this . data [ this . data _pointer ++ ] = 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 ) ; this . data _pointer === this . data _end && this . write _end ( ) } } ;
I . prototype . write _data _port8 = function ( a ) { this . write _data _port ( a , 1 ) } ; I . prototype . write _data _port16 = function ( a ) { this . write _data _port ( a , 2 ) } ; I . prototype . write _data _port32 = function ( a ) { this . write _data _port ( a , 4 ) } ; I . prototype . write _end = function ( ) { 160 === this . current _command ? this . atapi _handle ( ) : ( A ( this . data _pointer ) , A ( this . data _length ) , this . data _pointer >= this . data _length ? this . do _write ( ) : ( A ( this . current _command ) , this . status = 88 , this . data _end += 512 , this . push _irq ( ) ) ) } ;
I . prototype . ata _advance = function ( a , b ) { this . bytecount -= b ; 36 === a || 41 === a || 52 === a || 57 === a || 37 === a || 53 === a ? ( a = b + this . get _lba48 ( ) , this . sector = a & 255 | a >> 16 & 65280 , this . cylinder _low = a >> 8 & 255 , this . cylinder _high = a >> 16 & 255 ) : this . is _lba ? ( a = b + this . get _lba28 ( ) , this . sector = a & 255 , this . cylinder _low = a >> 8 & 255 , this . cylinder _high = 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 . cylinder _low = b & 255 , this . cylinder _high = b >> 8 & 255 , this . head = ( a / this . sectors _per _track |
2024-06-28 09:23:02 +02:00
0 ) % this . head _count & 15 , this . sector = a % this . sectors _per _track + 1 & 255 , this . get _chs ( ) ) } ;
2024-10-02 21:03:04 +02:00
I . 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 , f = b * this . sector _size ; qa ( "ATA read cmd=" + A ( a ) + " mode=" + ( this . is _lba ? "lba" : "chs" ) + " lba=" + A ( b ) + " lbacount=" + A ( c ) + " bytecount=" + A ( e ) , 32768 ) ; f + e > this . buffer . byteLength ? ( this . status = 255 , this . push _irq ( ) ) : ( this . status = 192 , this . report _read _start ( ) , this . read _buffer ( f , e , g => { this . data _set ( g ) ; this . status = 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 ) } ) ) } ; I . prototype . ata _read _sectors _dma = function ( a ) { var b = 37 === a ; a = this . get _count ( b ) ; b = this . get _lba ( b ) ; var c = a * this . sector _size , d = b * this . sector _size ; A ( b ) ; A ( a ) ; A ( c ) ; d + c > this . buffer . byteLength ? ( this . status = 255 , this . push _irq ( ) ) : ( this . status = 88 , this . device . dma _status |= 1 ) } ;
I . 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 ; a *= this . sector _size ; this . report _read _start ( ) ; this . read _buffer ( a , c , d => { var e = this . device . prdt _addr , f = 0 ; do { var g = this . cpu . read32s ( e ) , h = this . cpu . read16 ( e + 4 ) , l = this . cpu . read8 ( e + 7 ) & 128 ; h || ( h = 65536 ) ; A ( g ) ; A ( h ) ; this . cpu . write _blob ( d . subarray ( f , f + h ) , g ) ; f += h ; e += 8 } while ( ! l ) ; this . ata _advance ( this . current _command , b ) ; this . status = 80 ; this . device . dma _status &= - 2 ; this . current _command =
- 1 ; this . push _irq ( ) ; this . report _read _end ( c ) } ) } ; I . 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 ; var d = c * this . sector _size , e = b * this . sector _size ; A ( b ) ; A ( c ) ; A ( d ) ; e + d > this . buffer . byteLength ? ( this . status = 255 , this . push _irq ( ) ) : ( this . status = 88 , this . data _allocate _noclear ( d ) , this . data _end = a ? 512 : Math . min ( d , 512 * this . sectors _per _drq ) , this . write _dest = e ) } ;
I . prototype . ata _write _sectors _dma = function ( a ) { var b = 53 === a ; a = this . get _count ( b ) ; b = this . get _lba ( b ) ; var c = a * this . sector _size , d = b * this . sector _size ; A ( b ) ; A ( a ) ; A ( c ) ; d + c > this . buffer . byteLength ? ( this . status = 255 , this . push _irq ( ) ) : ( this . status = 88 , this . device . dma _status |= 1 ) } ;
I . prototype . do _ata _write _sectors _dma = 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 . device . prdt _addr , e = 0 ; qa ( "prdt addr: " + A ( d , 8 ) , 32768 ) ; const f = new Uint8Array ( a ) ; do { var g = this . cpu . read32s ( d ) , h = this . cpu . read16 ( d + 4 ) , l = this . cpu . read8 ( d + 7 ) & 128 ; h || ( h = 65536 ) ; qa ( "dma write transfer dest=" + A ( g ) + " prd_count=" + A ( h ) , 32768 ) ; g = this . cpu . mem8 . subarray ( g , g + h ) ; f . set ( g , e ) ; e += h ; d += 8 } while ( ! l ) ; this . buffer . set ( c , f , ( ) => { this . ata _advance ( this . current _command ,
b ) ; this . status = 80 ; this . push _irq ( ) ; this . device . dma _status &= - 2 ; this . current _command = - 1 } ) ; this . report _write ( a ) } ; I . prototype . get _chs = function ( ) { return ( ( this . cylinder _low & 255 | this . cylinder _high << 8 & 65280 ) * this . head _count + this . head ) * this . sectors _per _track + ( this . sector & 255 ) - 1 } ; I . prototype . get _lba28 = function ( ) { return this . sector & 255 | this . cylinder _low << 8 & 65280 | this . cylinder _high << 16 & 16711680 | ( this . head & 15 ) << 24 } ;
I . prototype . get _lba48 = function ( ) { return ( this . sector & 255 | this . cylinder _low << 8 & 65280 | this . cylinder _high << 16 & 16711680 | this . sector >> 8 << 24 & 4278190080 ) >>> 0 } ; I . prototype . get _lba = function ( a ) { return a ? this . get _lba48 ( ) : this . is _lba ? this . get _lba28 ( ) : this . get _chs ( ) } ; I . prototype . get _count = function ( a ) { a ? ( a = this . bytecount , 0 === a && ( a = 65536 ) ) : ( a = this . bytecount & 255 , 0 === a && ( a = 256 ) ) ; return a } ;
I . prototype . create _identify _packet = function ( ) { if ( this . drive _head & 16 ) this . data _allocate ( 0 ) ; else { for ( var a = 0 ; 512 > a ; a ++ ) this . data [ a ] = 0 ; a = Math . min ( 16383 , this . cylinder _count ) ; this . data _set ( [ 64 , this . is _atapi ? 133 : 0 , a , a >> 8 , 0 , 0 , this . head _count , this . head _count >> 8 , this . sectors _per _track / 512 , this . sectors _per _track / 512 >> 8 , 0 , 2 , this . sectors _per _track , this . sectors _per _track >> 8 , 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 , 56 , 118 , 32 , 54 , 68 , 72 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 ,
2024-06-28 09:23:02 +02:00
32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 128 , 0 , 1 , 0 , 0 , 2 , 0 , 0 , 0 , 2 , 0 , 2 , 7 , 0 , a , a >> 8 , this . head _count , this . head _count >> 8 , 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 , 160 === this . current _command ? 0 : 7 , 160 === this . current _command ? 0 : 4 , 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 , 126 , 0 ,
2024-10-02 21:03:04 +02:00
0 , 0 , 0 , 0 , 0 , 116 , 0 , 64 , 0 , 64 , 0 , 116 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 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 ] ) ; this . data _end = this . data _length = 512 } } ; I . prototype . data _allocate = function ( a ) { this . data _allocate _noclear ( a ) ; for ( var b = 0 ; b < a + 3 >> 2 ; b ++ ) this . data32 [ b ] = 0 } ;
I . prototype . data _allocate _noclear = function ( a ) { this . data . length < a && ( this . data = new Uint8Array ( a + 3 & - 4 ) , this . data16 = new Uint16Array ( this . data . buffer ) , this . data32 = new Int32Array ( this . data . buffer ) ) ; this . data _length = a ; this . data _pointer = 0 } ; I . prototype . data _set = function ( a ) { this . data _allocate _noclear ( a . length ) ; this . data . set ( a ) } ; I . prototype . report _read _start = function ( ) { this . bus . send ( "ide-read-start" ) } ; I . prototype . report _read _end = function ( a ) { this . bus . send ( "ide-read-end" , [ this . nr , a , a / this . sector _size | 0 ] ) } ;
I . prototype . report _write = function ( a ) { this . bus . send ( "ide-write-end" , [ this . nr , a , a / this . sector _size | 0 ] ) } ; I . 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 => { this . cancelled _io _ids . delete ( d ) ? this . in _progress _io _ids . has ( d ) : ( this . in _progress _io _ids . delete ( d ) , c ( e ) ) } ) } ; I . 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 ( ) } ;
I . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . bytecount ; a [ 1 ] = this . cylinder _count ; a [ 2 ] = this . cylinder _high ; a [ 3 ] = this . cylinder _low ; a [ 4 ] = this . data _pointer ; a [ 5 ] = 0 ; a [ 6 ] = 0 ; a [ 7 ] = 0 ; a [ 8 ] = 0 ; a [ 9 ] = this . drive _head ; a [ 10 ] = this . error ; a [ 11 ] = this . head ; a [ 12 ] = this . head _count ; a [ 13 ] = this . is _atapi ; a [ 14 ] = this . is _lba ; a [ 15 ] = this . lba _count ; a [ 16 ] = this . data ; a [ 17 ] = this . data _length ; a [ 18 ] = this . sector ; 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 ; a [ 24 ] =
2024-06-28 09:23:02 +02:00
this . write _dest ; a [ 25 ] = this . current _command ; a [ 26 ] = this . data _end ; a [ 27 ] = this . current _atapi _command ; a [ 28 ] = this . buffer ; return a } ;
2024-10-02 21:03:04 +02:00
I . prototype . set _state = function ( a ) { this . bytecount = a [ 0 ] ; this . cylinder _count = a [ 1 ] ; this . cylinder _high = a [ 2 ] ; this . cylinder _low = a [ 3 ] ; this . data _pointer = a [ 4 ] ; this . drive _head = a [ 9 ] ; this . error = a [ 10 ] ; this . head = a [ 11 ] ; this . head _count = a [ 12 ] ; this . is _atapi = a [ 13 ] ; this . is _lba = a [ 14 ] ; this . lba _count = a [ 15 ] ; this . data = a [ 16 ] ; this . data _length = a [ 17 ] ; this . sector = 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 = 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 ] ) } ; function sa ( a ) { this . pci _addr = new Uint8Array ( 4 ) ; this . pci _value = new Uint8Array ( 4 ) ; this . pci _response = new Uint8Array ( 4 ) ; this . pci _status = new Uint8Array ( 4 ) ; this . pci _addr32 = new Int32Array ( this . pci _addr . buffer ) ; this . pci _value32 = new Int32Array ( this . pci _value . buffer ) ; this . pci _response32 = new Int32Array ( this . pci _response . buffer ) ; this . pci _status32 = new Int32Array ( this . pci _status . buffer ) ; this . device _spaces = [ ] ; this . devices = [ ] ; this . cpu = a ; for ( var b = 0 ; 256 > b ; b ++ ) this . device _spaces [ b ] = void 0 , this . devices [ b ] = void 0 ; this . io =
2024-06-28 09:23:02 +02:00
a . io ; a . io . register _write ( 3324 , this , function ( c ) { this . pci _write8 ( this . pci _addr32 [ 0 ] , c ) } , function ( c ) { this . pci _write16 ( this . pci _addr32 [ 0 ] , c ) } , function ( c ) { this . pci _write32 ( this . pci _addr32 [ 0 ] , c ) } ) ; a . io . register _write ( 3325 , this , function ( c ) { this . pci _write8 ( this . pci _addr32 [ 0 ] + 1 | 0 , c ) } ) ; a . io . register _write ( 3326 , this , function ( c ) { this . pci _write8 ( this . pci _addr32 [ 0 ] + 2 | 0 , c ) } , function ( c ) { this . pci _write16 ( this . pci _addr32 [ 0 ] + 2 | 0 , c ) } ) ; a . io . register _write ( 3327 , this , function ( c ) { this . pci _write8 ( this . pci _addr32 [ 0 ] + 3 | 0 , c ) } ) ;
a . io . register _read _consecutive ( 3324 , this , function ( ) { return this . pci _response [ 0 ] } , function ( ) { return this . pci _response [ 1 ] } , function ( ) { return this . pci _response [ 2 ] } , function ( ) { return this . pci _response [ 3 ] } ) ; a . io . register _read _consecutive ( 3320 , this , function ( ) { return this . pci _status [ 0 ] } , function ( ) { return this . pci _status [ 1 ] } , function ( ) { return this . pci _status [ 2 ] } , function ( ) { return this . pci _status [ 3 ] } ) ; a . io . register _write _consecutive ( 3320 , this , function ( c ) { this . pci _addr [ 0 ] = c & 252 } , function ( c ) { 2 === ( this . pci _addr [ 1 ] &
6 ) && 6 === ( c & 6 ) ? a . reboot _internal ( ) : this . pci _addr [ 1 ] = c } , function ( c ) { this . pci _addr [ 2 ] = c } , function ( c ) { this . pci _addr [ 3 ] = c ; this . pci _query ( ) } ) ; this . register _device ( { pci _id : 0 , pci _space : [ 134 , 128 , 55 , 18 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 6 , 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 , 16 , 0 , 0 , 0 , 0 , 0 , 0 ] , pci _bars : [ ] , name : "82441FX PMC" } ) ; this . isa _bridge = { pci _id : 8 , pci _space : [ 134 , 128 , 0 , 112 , 7 , 0 , 0 , 2 , 0 , 0 , 1 , 6 , 0 , 0 , 128 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
2024-10-02 21:03:04 +02:00
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 ] , pci _bars : [ ] , name : "82371SB PIIX3 ISA" } ; this . isa _bridge _space = this . register _device ( this . isa _bridge ) ; this . isa _bridge _space8 = new Uint8Array ( this . isa _bridge _space . buffer ) } sa . prototype . get _state = function ( ) { for ( var a = [ ] , b = 0 ; 256 > b ; b ++ ) a [ b ] = this . device _spaces [ b ] ; a [ 256 ] = this . pci _addr ; a [ 257 ] = this . pci _value ; a [ 258 ] = this . pci _response ; a [ 259 ] = this . pci _status ; return a } ;
sa . prototype . set _state = function ( a ) { for ( var b = 0 ; 256 > b ; b ++ ) { var c = this . devices [ b ] , d = a [ b ] ; if ( c && d ) { for ( var e = 0 ; e < c . pci _bars . length ; e ++ ) { var f = d [ 4 + e ] ; if ( f & 1 ) { var g = c . pci _bars [ e ] ; this . set _io _bars ( g , g . original _bar & 65534 , f & 65534 ) } } this . device _spaces [ b ] . set ( d ) } else d && A ( b , 2 ) } this . pci _addr . set ( a [ 256 ] ) ; this . pci _value . set ( a [ 257 ] ) ; this . pci _response . set ( a [ 258 ] ) ; this . pci _status . set ( a [ 259 ] ) } ;
sa . prototype . pci _query = function ( ) { var a = this . pci _addr [ 2 ] << 8 | this . pci _addr [ 1 ] , b = this . pci _addr [ 0 ] & 252 , c = a >> 3 & 31 ; var d = "query enabled=" + ( this . pci _addr [ 3 ] >> 7 ) + ( " bdf=" + A ( a , 4 ) ) ; d += " dev=" + A ( c , 2 ) ; d += " addr=" + A ( b , 2 ) ; a = this . device _spaces [ a ] ; void 0 !== a ? ( this . pci _status32 [ 0 ] = - 2147483648 , this . pci _response32 [ 0 ] = b < a . byteLength ? a [ b >> 2 ] : 0 , d += " " + A ( this . pci _addr32 [ 0 ] >>> 0 , 8 ) + " -> " + A ( this . pci _response32 [ 0 ] >>> 0 , 8 ) ) : ( this . pci _response32 [ 0 ] = - 1 , this . pci _status32 [ 0 ] = 0 ) } ;
sa . prototype . pci _write8 = function ( a , b ) { var c = a >> 8 & 65535 ; a &= 255 ; var d = new Uint8Array ( this . device _spaces [ c ] . buffer ) ; A ( a ) ; A ( c >> 3 , 2 ) ; A ( a , 4 ) ; A ( b , 2 ) ; d [ a ] = b } ; sa . prototype . pci _write16 = function ( a , b ) { var c = a >> 8 & 65535 ; a &= 255 ; var d = new Uint16Array ( this . device _spaces [ c ] . buffer ) ; 16 <= a && 44 > a ? A ( a ) : ( A ( a ) , A ( c >> 3 , 2 ) , A ( a , 4 ) , A ( b , 4 ) , d [ a >>> 1 ] = b ) } ;
sa . prototype . pci _write32 = function ( a , b ) { var c = a >> 8 & 65535 ; a &= 255 ; var d = this . device _spaces [ c ] , e = this . devices [ c ] ; if ( d ) if ( 16 <= a && 40 > a ) { e = e . pci _bars [ a - 16 >> 2 ] ; A ( b >>> 0 ) ; A ( c >> 3 , 2 ) ; if ( e ) { c = a >> 2 ; var f = d [ c ] & 1 ; - 1 === ( b | 3 | e . size - 1 ) ? ( b = ~ ( e . size - 1 ) | f , 0 === f && ( d [ c ] = b ) ) : 0 === f && ( d [ c ] = e . original _bar ) ; if ( 1 === f ) { f = d [ c ] & 65534 ; var g = b & 65534 ; A ( f >>> 0 , 8 ) ; A ( g >>> 0 , 8 ) ; this . set _io _bars ( e , f , g ) ; d [ c ] = b | 1 } } else d [ a >> 2 ] = 0 ; A ( d [ a >> 2 ] >>> 0 ) } else 48 === a ? ( A ( c >> 3 , 2 ) , A ( b >>> 0 , 8 ) , d [ a >> 2 ] = e . pci _rom _size ? - 1 === ( b | 2047 ) ? - e . pci _rom _size | 0 : e . pci _rom _address |
0 : 0 ) : 4 === a ? ( A ( c >> 3 , 2 ) , A ( a , 4 ) , A ( b >>> 0 , 8 ) ) : ( A ( c >> 3 , 2 ) , A ( a , 4 ) , A ( b >>> 0 , 8 ) , d [ a >>> 2 ] = b ) } ; sa . prototype . register _device = function ( a ) { var b = a . pci _id ; A ( b ) ; var c = new Int32Array ( 64 ) ; c . set ( new Int32Array ( ( new Uint8Array ( a . pci _space ) ) . buffer ) ) ; this . device _spaces [ b ] = c ; this . devices [ b ] = a ; b = c . slice ( 4 , 10 ) ; for ( var d = 0 ; d < a . pci _bars . length ; d ++ ) { var e = a . pci _bars [ d ] ; if ( e ) { var f = b [ d ] , g = f & 1 ; e . original _bar = f ; e . entries = [ ] ; if ( 0 !== g ) for ( f &= - 2 , g = 0 ; g < e . size ; g ++ ) e . entries [ g ] = this . io . ports [ f + g ] } } return c } ;
sa . prototype . set _io _bars = function ( a , b , c ) { var d = a . size ; A ( b ) ; A ( c ) ; for ( var e = this . io . ports , f = 0 ; f < d ; f ++ ) { var g = e [ b + f ] ; 4096 <= b + f && ( e [ b + f ] = this . io . create _empty _entry ( ) ) ; g . read8 === this . io . empty _port _read8 && g . read16 === this . io . empty _port _read16 && g . read32 === this . io . empty _port _read32 && g . write8 === this . io . empty _port _write && g . write16 === this . io . empty _port _write && g . write32 === this . io . empty _port _write && A ( b + f , 4 ) ; g = a . entries [ f ] ; var h = e [ c + f ] ; 4096 <= c + f && ( e [ c + f ] = g ) ; h . read8 !== this . io . empty _port _read8 && h . read16 !== this . io . empty _port _read16 &&
h . read32 !== this . io . empty _port _read32 && h . write8 !== this . io . empty _port _write && h . write16 !== this . io . empty _port _write && h . write32 !== this . io . empty _port _write || A ( c + f , 4 ) } } ; sa . prototype . raise _irq = function ( a ) { this . cpu . device _raise _irq ( this . isa _bridge _space8 [ 96 + ( ( this . device _spaces [ a ] [ 15 ] >> 8 & 255 ) - 1 + ( ( a >> 3 ) - 1 & 255 ) & 3 ) ] ) } ; sa . prototype . lower _irq = function ( a ) { this . cpu . device _lower _irq ( this . isa _bridge _space8 [ 96 + ( ( this . device _spaces [ a ] [ 15 ] >> 8 & 255 ) + ( a >> 3 & 255 ) - 2 & 3 ) ] ) } ; function J ( a , b ) { this . io = a . io ; this . cpu = a ; this . dma = a . devices . dma ; this . bytes _expecting = 0 ; this . receiving _command = new Uint8Array ( 10 ) ; this . receiving _index = 0 ; this . next _command = null ; this . response _data = new Uint8Array ( 10 ) ; this . last _head = this . last _cylinder = this . drive = this . status _reg2 = this . status _reg1 = this . status _reg0 = this . response _length = this . response _index = 0 ; this . last _sector = 1 ; this . dir = this . dor = 0 ; this . fdb _image = this . fda _image = null ; b ? this . set _fda ( b ) : ( this . eject _fda ( ) , this . cpu . devices . rtc . cmos _write ( 16 , 64 ) ) ;
2024-06-28 09:23:02 +02:00
this . io . register _read ( 1008 , this , this . port3F0 _read ) ; this . io . register _read ( 1010 , this , this . port3F2 _read ) ; this . io . register _read ( 1012 , this , this . port3F4 _read ) ; this . io . register _read ( 1013 , this , this . port3F5 _read ) ; this . io . register _read ( 1015 , this , this . port3F7 _read ) ; this . io . register _write ( 1010 , this , this . port3F2 _write ) ; this . io . register _write ( 1012 , this , this . port3F4 _write ) ; this . io . register _write ( 1013 , this , this . port3F5 _write ) }
2024-10-02 21:03:04 +02:00
J . prototype . eject _fda = function ( ) { this . fda _image = null ; this . number _of _cylinders = this . number _of _heads = this . sectors _per _track = 0 ; this . dir = 128 } ;
J . prototype . set _fda = function ( a ) { var b = { [ 163840 ] : { type : 1 , tracks : 40 , sectors : 8 , heads : 1 } , [ 184320 ] : { type : 1 , tracks : 40 , sectors : 9 , heads : 1 } , [ 204800 ] : { type : 1 , tracks : 40 , sectors : 10 , heads : 1 } , [ 327680 ] : { type : 1 , tracks : 40 , sectors : 8 , heads : 2 } , [ 368640 ] : { type : 1 , tracks : 40 , sectors : 9 , heads : 2 } , [ 409600 ] : { type : 1 , tracks : 40 , sectors : 10 , heads : 2 } , [ 737280 ] : { type : 3 , tracks : 80 , sectors : 9 , heads : 2 } , [ 1228800 ] : { type : 2 , tracks : 80 , sectors : 15 , heads : 2 } , [ 1474560 ] : { type : 4 , tracks : 80 , sectors : 18 , heads : 2 } , [ 1763328 ] : { type : 5 , tracks : 82 , sectors : 21 , heads : 2 } ,
[ 2949120 ] : { type : 5 , tracks : 80 , sectors : 36 , heads : 2 } , 512 : { type : 1 , tracks : 1 , sectors : 1 , heads : 1 } } ; let c = a . byteLength , d = b [ c ] ; d || ( c = 1474560 < a . byteLength ? 2949120 : 1474560 , d = b [ c ] , b = new Uint8Array ( c ) , b . set ( new Uint8Array ( a . buffer ) ) , a = new t . SyncBuffer ( b . buffer ) ) ; this . sectors _per _track = d . sectors ; this . number _of _heads = d . heads ; this . number _of _cylinders = d . tracks ; this . fda _image = a ; this . dir = 128 ; this . cpu . devices . rtc . cmos _write ( 16 , d . type << 4 ) } ;
J . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . bytes _expecting ; a [ 1 ] = this . receiving _command ; a [ 2 ] = this . receiving _index ; a [ 4 ] = this . response _data ; a [ 5 ] = this . response _index ; a [ 6 ] = this . response _length ; a [ 8 ] = this . status _reg0 ; a [ 9 ] = this . status _reg1 ; a [ 10 ] = this . status _reg2 ; a [ 11 ] = this . drive ; a [ 12 ] = this . last _cylinder ; a [ 13 ] = this . last _head ; a [ 14 ] = this . last _sector ; a [ 15 ] = this . dor ; a [ 16 ] = this . sectors _per _track ; a [ 17 ] = this . number _of _heads ; a [ 18 ] = this . number _of _cylinders ; return a } ;
J . prototype . set _state = function ( a ) { this . bytes _expecting = a [ 0 ] ; this . receiving _command = a [ 1 ] ; this . receiving _index = a [ 2 ] ; this . next _command = a [ 3 ] ; this . response _data = a [ 4 ] ; this . response _index = a [ 5 ] ; this . response _length = a [ 6 ] ; this . status _reg0 = a [ 8 ] ; this . status _reg1 = a [ 9 ] ; this . status _reg2 = a [ 10 ] ; this . drive = a [ 11 ] ; this . last _cylinder = a [ 12 ] ; this . last _head = a [ 13 ] ; this . last _sector = a [ 14 ] ; this . dor = a [ 15 ] ; this . sectors _per _track = a [ 16 ] ; this . number _of _heads = a [ 17 ] ; this . number _of _cylinders = a [ 18 ] } ; J . prototype . port3F0 _read = function ( ) { return 0 } ;
J . prototype . port3F4 _read = function ( ) { var a = 128 ; this . response _index < this . response _length && ( a |= 80 ) ; 0 === ( this . dor & 8 ) && ( a |= 32 ) ; return a } ; J . prototype . port3F7 _read = function ( ) { return this . dir } ; J . prototype . port3F5 _read = function ( ) { return this . response _index < this . response _length ? ( this . cpu . device _lower _irq ( 6 ) , this . response _data [ this . response _index ++ ] ) : 255 } ; J . prototype . port3F4 _write = function ( a ) { A ( a ) ; a & 128 && ( this . status _reg0 = 192 , this . cpu . device _raise _irq ( 6 ) ) } ;
J . prototype . port3F5 _write = function ( a ) { qa ( "3F5 write " + A ( a ) , 8192 ) ; if ( 0 < this . bytes _expecting ) this . receiving _command [ this . receiving _index ++ ] = a , this . bytes _expecting -- , 0 === this . bytes _expecting && this . next _command . call ( this , this . receiving _command ) ; else { switch ( a ) { case 3 : this . next _command = this . fix _drive _data ; this . bytes _expecting = 2 ; break ; case 19 : this . next _command = this . configure ; this . bytes _expecting = 3 ; break ; case 4 : this . next _command = this . check _drive _status ; this . bytes _expecting = 1 ; break ; case 5 : case 69 : case 197 : this . next _command =
function ( b ) { this . do _sector ( ! 0 , b ) } ; this . bytes _expecting = 8 ; break ; case 6 : case 70 : case 198 : case 230 : this . next _command = function ( b ) { this . do _sector ( ! 1 , b ) } ; this . bytes _expecting = 8 ; break ; case 7 : this . next _command = this . calibrate ; this . bytes _expecting = 1 ; break ; case 8 : this . check _interrupt _status ( ) ; break ; case 74 : this . next _command = this . read _sector _id ; this . bytes _expecting = 1 ; break ; case 15 : this . bytes _expecting = 2 ; this . next _command = this . seek ; break ; case 14 : case 16 : this . status _reg0 = 128 ; this . response _data [ 0 ] = this . status _reg0 ;
this . response _index = 0 ; this . response _length = 1 ; this . bytes _expecting = 0 ; break ; default : ra ( ! 1 , "Unimplemented floppy command call " + A ( a ) ) } this . receiving _index = 0 } } ; J . prototype . port3F2 _read = function ( ) { return this . dor } ; J . prototype . port3F2 _write = function ( a ) { 4 === ( a & 4 ) && 0 === ( this . dor & 4 ) && ( this . status _reg0 = 192 , this . cpu . device _raise _irq ( 6 ) ) ; A ( a >> 4 ) ; A ( a ) ; this . dor = a } ; J . prototype . check _drive _status = function ( ) { this . status _reg1 = this . fda _image ? 0 : 5 ; this . response _index = 0 ; this . response _length = 1 ; this . response _data [ 0 ] = 0 } ;
J . prototype . seek = function ( a ) { if ( 0 === ( a [ 0 ] & 3 ) ) { var b = a [ 1 ] ; a = a [ 0 ] >> 2 & 1 ; b !== this . last _cylinder && ( this . dir = 0 ) ; this . status _reg1 = this . fda _image ? 0 : 5 ; this . status _reg0 = 32 ; this . last _cylinder = b ; this . last _head = a } this . raise _irq ( ) } ; J . prototype . calibrate = function ( a ) { this . seek ( [ a [ 0 ] , 0 ] ) } ; J . prototype . check _interrupt _status = function ( ) { this . response _index = 0 ; this . response _length = 2 ; this . response _data [ 0 ] = this . status _reg0 ; this . response _data [ 1 ] = this . last _cylinder } ;
J . prototype . do _sector = function ( a , b ) { var c = b [ 2 ] , d = b [ 1 ] , e = b [ 3 ] , f = 128 << b [ 4 ] , g = b [ 5 ] - b [ 3 ] + 1 , h = ( ( c + this . number _of _heads * d ) * this . sectors _per _track + e - 1 ) * f ; A ( h ) ; A ( g * f ) ; this . fda _image ? ( this . status _reg1 = 0 , a ? this . dma . do _write ( this . fda _image , h , g * f , 2 , this . done . bind ( this , b , d , c , e ) ) : this . dma . do _read ( this . fda _image , h , g * f , 2 , this . done . bind ( this , b , d , c , e ) ) ) : this . status _reg1 = 5 } ;
J . prototype . done = function ( a , b , c , d , e ) { e || ( d ++ , d > this . sectors _per _track && ( d = 1 , c ++ , c >= this . number _of _heads && ( c = 0 , b ++ ) ) , b !== this . last _cylinder && ( this . dir = 0 ) , this . status _reg0 = 32 , this . last _cylinder = b , this . last _head = c , this . last _sector = d , this . response _index = 0 , this . response _length = 7 , this . response _data [ 0 ] = c << 2 | 32 , this . response _data [ 1 ] = 0 , this . response _data [ 2 ] = 0 , this . response _data [ 3 ] = b , this . response _data [ 4 ] = c , this . response _data [ 5 ] = d , this . response _data [ 6 ] = a [ 4 ] , this . raise _irq ( ) ) } ;
J . prototype . fix _drive _data = function ( a ) { a . slice ( 0 , this . bytes _expecting ) } ; J . prototype . configure = function ( a ) { a . slice ( 0 , this . bytes _expecting ) } ; J . prototype . read _sector _id = function ( ) { this . response _index = 0 ; this . response _length = 7 ; this . response _data [ 0 ] = 0 ; this . response _data [ 1 ] = 0 ; this . response _data [ 2 ] = 0 ; this . response _data [ 3 ] = 0 ; this . response _data [ 4 ] = 0 ; this . response _data [ 5 ] = 0 ; this . response _data [ 6 ] = 0 ; this . raise _irq ( ) } ; J . prototype . raise _irq = function ( ) { this . dor & 8 && this . cpu . device _raise _irq ( 6 ) } ; G . prototype . mmap _read8 = function ( a ) { return this . memory _map _read8 [ a >>> 17 ] ( a ) } ; G . prototype . mmap _write8 = function ( a , b ) { this . memory _map _write8 [ a >>> 17 ] ( a , b ) } ; G . prototype . mmap _read16 = function ( a ) { var b = this . memory _map _read8 [ a >>> 17 ] ; return b ( a ) | b ( a + 1 | 0 ) << 8 } ; G . prototype . mmap _write16 = function ( a , b ) { var c = this . memory _map _write8 [ a >>> 17 ] ; c ( a , b & 255 ) ; c ( a + 1 | 0 , b >> 8 ) } ; G . prototype . mmap _read32 = function ( a ) { return this . memory _map _read32 [ a >>> 17 ] ( a ) } ;
G . prototype . mmap _write32 = function ( a , b ) { this . memory _map _write32 [ a >>> 17 ] ( a , b ) } ; G . prototype . mmap _write64 = function ( a , b , c ) { var d = this . memory _map _write32 [ a >>> 17 ] ; d ( a , b ) ; d ( a + 4 , c ) } ; G . prototype . mmap _write128 = function ( a , b , c , d , e ) { var f = this . memory _map _write32 [ a >>> 17 ] ; f ( a , b ) ; f ( a + 4 , c ) ; f ( a + 8 , d ) ; f ( a + 12 , e ) } ; G . prototype . write _blob = function ( a , b ) { a . length && ( this . in _mapped _range ( b ) , this . in _mapped _range ( b + a . length - 1 ) , this . jit _dirty _cache ( b , b + a . length ) , this . mem8 . set ( a , b ) ) } ;
G . prototype . read _blob = function ( a , b ) { b && ( this . in _mapped _range ( a ) , this . in _mapped _range ( a + b - 1 ) ) ; return this . mem8 . subarray ( a , a + b ) } ; function L ( a ) { this . cpu = a ; this . channel _page = new Uint8Array ( 8 ) ; this . channel _pagehi = new Uint8Array ( 8 ) ; this . channel _addr = new Uint16Array ( 8 ) ; this . channel _addr _init = new Uint16Array ( 8 ) ; this . channel _count = new Uint16Array ( 8 ) ; this . channel _count _init = new Uint16Array ( 8 ) ; this . channel _mask = new Uint8Array ( 8 ) ; this . channel _mode = new Uint8Array ( 8 ) ; this . unmask _listeners = [ ] ; this . lsb _msb _flipflop = 0 ; a = a . io ; a . register _write ( 0 , this , this . port _addr _write . bind ( this , 0 ) ) ; a . register _write ( 2 , this , this . port _addr _write . bind ( this ,
2024-06-28 09:23:02 +02:00
1 ) ) ; a . register _write ( 4 , this , this . port _addr _write . bind ( this , 2 ) ) ; a . register _write ( 6 , this , this . port _addr _write . bind ( this , 3 ) ) ; a . register _write ( 1 , this , this . port _count _write . bind ( this , 0 ) ) ; a . register _write ( 3 , this , this . port _count _write . bind ( this , 1 ) ) ; a . register _write ( 5 , this , this . port _count _write . bind ( this , 2 ) ) ; a . register _write ( 7 , this , this . port _count _write . bind ( this , 3 ) ) ; a . register _read ( 0 , this , this . port _addr _read . bind ( this , 0 ) ) ; a . register _read ( 2 , this , this . port _addr _read . bind ( this , 1 ) ) ; a . register _read ( 4 , this , this . port _addr _read . bind ( this ,
2 ) ) ; a . register _read ( 6 , this , this . port _addr _read . bind ( this , 3 ) ) ; a . register _read ( 1 , this , this . port _count _read . bind ( this , 0 ) ) ; a . register _read ( 3 , this , this . port _count _read . bind ( this , 1 ) ) ; a . register _read ( 5 , this , this . port _count _read . bind ( this , 2 ) ) ; a . register _read ( 7 , this , this . port _count _read . bind ( this , 3 ) ) ; a . register _write ( 192 , this , this . port _addr _write . bind ( this , 4 ) ) ; a . register _write ( 196 , this , this . port _addr _write . bind ( this , 5 ) ) ; a . register _write ( 200 , this , this . port _addr _write . bind ( this , 6 ) ) ; a . register _write ( 204 , this ,
this . port _addr _write . bind ( this , 7 ) ) ; a . register _write ( 194 , this , this . port _count _write . bind ( this , 4 ) ) ; a . register _write ( 198 , this , this . port _count _write . bind ( this , 5 ) ) ; a . register _write ( 202 , this , this . port _count _write . bind ( this , 6 ) ) ; a . register _write ( 206 , this , this . port _count _write . bind ( this , 7 ) ) ; a . register _read ( 192 , this , this . port _addr _read . bind ( this , 4 ) ) ; a . register _read ( 196 , this , this . port _addr _read . bind ( this , 5 ) ) ; a . register _read ( 200 , this , this . port _addr _read . bind ( this , 6 ) ) ; a . register _read ( 204 , this , this . port _addr _read . bind ( this ,
7 ) ) ; a . register _read ( 194 , this , this . port _count _read . bind ( this , 4 ) ) ; a . register _read ( 198 , this , this . port _count _read . bind ( this , 5 ) ) ; a . register _read ( 202 , this , this . port _count _read . bind ( this , 6 ) ) ; a . register _read ( 206 , this , this . port _count _read . bind ( this , 7 ) ) ; a . register _write ( 135 , this , this . port _page _write . bind ( this , 0 ) ) ; a . register _write ( 131 , this , this . port _page _write . bind ( this , 1 ) ) ; a . register _write ( 129 , this , this . port _page _write . bind ( this , 2 ) ) ; a . register _write ( 130 , this , this . port _page _write . bind ( this , 3 ) ) ; a . register _write ( 143 ,
this , this . port _page _write . bind ( this , 4 ) ) ; a . register _write ( 139 , this , this . port _page _write . bind ( this , 5 ) ) ; a . register _write ( 137 , this , this . port _page _write . bind ( this , 6 ) ) ; a . register _write ( 138 , this , this . port _page _write . bind ( this , 7 ) ) ; a . register _read ( 135 , this , this . port _page _read . bind ( this , 0 ) ) ; a . register _read ( 131 , this , this . port _page _read . bind ( this , 1 ) ) ; a . register _read ( 129 , this , this . port _page _read . bind ( this , 2 ) ) ; a . register _read ( 130 , this , this . port _page _read . bind ( this , 3 ) ) ; a . register _read ( 143 , this , this . port _page _read . bind ( this ,
4 ) ) ; a . register _read ( 139 , this , this . port _page _read . bind ( this , 5 ) ) ; a . register _read ( 137 , this , this . port _page _read . bind ( this , 6 ) ) ; a . register _read ( 138 , this , this . port _page _read . bind ( this , 7 ) ) ; a . register _write ( 1159 , this , this . port _pagehi _write . bind ( this , 0 ) ) ; a . register _write ( 1155 , this , this . port _pagehi _write . bind ( this , 1 ) ) ; a . register _write ( 1153 , this , this . port _pagehi _write . bind ( this , 2 ) ) ; a . register _write ( 1154 , this , this . port _pagehi _write . bind ( this , 3 ) ) ; a . register _write ( 1163 , this , this . port _pagehi _write . bind ( this , 5 ) ) ;
a . register _write ( 1161 , this , this . port _pagehi _write . bind ( this , 6 ) ) ; a . register _write ( 1162 , this , this . port _pagehi _write . bind ( this , 7 ) ) ; a . register _read ( 1159 , this , this . port _pagehi _read . bind ( this , 0 ) ) ; a . register _read ( 1155 , this , this . port _pagehi _read . bind ( this , 1 ) ) ; a . register _read ( 1153 , this , this . port _pagehi _read . bind ( this , 2 ) ) ; a . register _read ( 1154 , this , this . port _pagehi _read . bind ( this , 3 ) ) ; a . register _read ( 1163 , this , this . port _pagehi _read . bind ( this , 5 ) ) ; a . register _read ( 1161 , this , this . port _pagehi _read . bind ( this , 6 ) ) ; a . register _read ( 1162 ,
this , this . port _pagehi _read . bind ( this , 7 ) ) ; a . register _write ( 10 , this , this . port _singlemask _write . bind ( this , 0 ) ) ; a . register _write ( 212 , this , this . port _singlemask _write . bind ( this , 4 ) ) ; a . register _write ( 15 , this , this . port _multimask _write . bind ( this , 0 ) ) ; a . register _write ( 222 , this , this . port _multimask _write . bind ( this , 4 ) ) ; a . register _read ( 15 , this , this . port _multimask _read . bind ( this , 0 ) ) ; a . register _read ( 222 , this , this . port _multimask _read . bind ( this , 4 ) ) ; a . register _write ( 11 , this , this . port _mode _write . bind ( this , 0 ) ) ; a . register _write ( 214 ,
this , this . port _mode _write . bind ( this , 4 ) ) ; a . register _write ( 12 , this , this . portC _write ) ; a . register _write ( 216 , this , this . portC _write ) } L . prototype . get _state = function ( ) { return [ this . channel _page , this . channel _pagehi , this . channel _addr , this . channel _addr _init , this . channel _count , this . channel _count _init , this . channel _mask , this . channel _mode , this . lsb _msb _flipflop ] } ;
L . prototype . set _state = function ( a ) { this . channel _page = a [ 0 ] ; this . channel _pagehi = a [ 1 ] ; this . channel _addr = a [ 2 ] ; this . channel _addr _init = a [ 3 ] ; this . channel _count = a [ 4 ] ; this . channel _count _init = a [ 5 ] ; this . channel _mask = a [ 6 ] ; this . channel _mode = a [ 7 ] ; this . lsb _msb _flipflop = a [ 8 ] } ; L . prototype . port _count _write = function ( a , b ) { A ( b ) ; this . channel _count [ a ] = this . flipflop _get ( this . channel _count [ a ] , b , ! 1 ) ; this . channel _count _init [ a ] = this . flipflop _get ( this . channel _count _init [ a ] , b , ! 0 ) } ;
L . prototype . port _count _read = function ( a ) { A ( this . channel _count [ a ] ) ; return this . flipflop _read ( this . channel _count [ a ] ) } ; L . prototype . port _addr _write = function ( a , b ) { A ( b ) ; this . channel _addr [ a ] = this . flipflop _get ( this . channel _addr [ a ] , b , ! 1 ) ; this . channel _addr _init [ a ] = this . flipflop _get ( this . channel _addr _init [ a ] , b , ! 0 ) } ; L . prototype . port _addr _read = function ( a ) { A ( this . channel _addr [ a ] ) ; return this . flipflop _read ( this . channel _addr [ a ] ) } ; L . prototype . port _pagehi _write = function ( a , b ) { A ( b ) ; this . channel _pagehi [ a ] = b } ;
L . prototype . port _pagehi _read = function ( a ) { return this . channel _pagehi [ a ] } ; L . prototype . port _page _write = function ( a , b ) { A ( b ) ; this . channel _page [ a ] = b } ; L . prototype . port _page _read = function ( a ) { return this . channel _page [ a ] } ; L . prototype . port _singlemask _write = function ( a , b ) { this . update _mask ( ( b & 3 ) + a , b & 4 ? 1 : 0 ) } ; L . prototype . port _multimask _write = function ( a , b ) { A ( b ) ; for ( var c = 0 ; 4 > c ; c ++ ) this . update _mask ( a + c , b & 1 << c ) } ;
L . prototype . port _multimask _read = function ( a ) { var b = 0 | this . channel _mask [ a + 0 ] ; b |= this . channel _mask [ a + 1 ] << 1 ; b |= this . channel _mask [ a + 2 ] << 2 ; b |= this . channel _mask [ a + 3 ] << 3 ; A ( b ) ; return b } ; L . prototype . port _mode _write = function ( a , b ) { a = ( b & 3 ) + a ; A ( b ) ; this . channel _mode [ a ] = b } ; L . prototype . portC _write = function ( ) { this . lsb _msb _flipflop = 0 } ; L . prototype . on _unmask = function ( a , b ) { this . unmask _listeners . push ( { fn : a , this _value : b } ) } ;
L . prototype . update _mask = function ( a , b ) { if ( this . channel _mask [ a ] !== b && ( this . channel _mask [ a ] = b , ! b ) ) for ( b = 0 ; b < this . unmask _listeners . length ; b ++ ) this . unmask _listeners [ b ] . fn . call ( this . unmask _listeners [ b ] . this _value , a ) } ;
2024-10-02 21:03:04 +02:00
L . prototype . do _read = function ( a , b , c , d , e ) { var f = this . count _get _8bit ( d ) , g = this . address _get _8bit ( d ) ; qa ( "to " + A ( g ) + " len " + A ( f ) , 16 ) ; c < f && qa ( "DMA should read more than provided: " + A ( c ) + " " + A ( f ) , 16 ) ; if ( b + f > a . byteLength ) e ( ! 0 ) ; else { var h = this . cpu ; this . channel _addr [ d ] += f ; a . get ( b , f , function ( l ) { h . write _blob ( l , g ) ; e ( ! 1 ) } ) } } ;
L . prototype . do _write = function ( a , b , c , d , e ) { var f = this . channel _count [ d ] + 1 & 65535 , g = 5 <= d ? 2 : 1 , h = f * g , l = this . address _get _8bit ( d ) , m = ! 1 , n = ! 1 , p = this . channel _mode [ d ] & 16 ; qa ( "to " + A ( l ) + " len " + A ( h ) , 16 ) ; c < h ? ( f = Math . floor ( c / g ) , h = f * g , m = ! 0 ) : c > h && ( n = ! 0 ) ; b + h > a . byteLength ? e ( ! 0 ) : ( this . channel _addr [ d ] += f , this . channel _count [ d ] -= f , ! m && p && ( this . channel _addr [ d ] = this . channel _addr _init [ d ] , this . channel _count [ d ] = this . channel _count _init [ d ] ) , a . set ( b , this . cpu . mem8 . subarray ( l , l + h ) , ( ) => { n && p ? this . do _write ( a , b + h , c - h , d , e ) : e ( ! 1 ) } ) ) } ;
L . prototype . address _get _8bit = function ( a ) { var b = this . channel _addr [ a ] ; 5 <= a && ( b <<= 1 ) ; b = b & 65535 | this . channel _page [ a ] << 16 ; return b |= this . channel _pagehi [ a ] << 24 } ; L . prototype . count _get _8bit = function ( a ) { var b = this . channel _count [ a ] + 1 ; 5 <= a && ( b *= 2 ) ; return b } ; L . prototype . flipflop _get = function ( a , b , c ) { c || ( this . lsb _msb _flipflop ^= 1 ) ; return this . lsb _msb _flipflop ? a & - 256 | b : a & - 65281 | b << 8 } ; L . prototype . flipflop _read = function ( a ) { return ( this . lsb _msb _flipflop ^= 1 ) ? a & 255 : a >> 8 & 255 } ; function ta ( a , b ) { this . cpu = a ; this . bus = b ; this . counter _start _time = new Float64Array ( 3 ) ; this . counter _start _value = new Uint16Array ( 3 ) ; this . counter _next _low = new Uint8Array ( 4 ) ; this . counter _enabled = new Uint8Array ( 4 ) ; this . counter _mode = new Uint8Array ( 4 ) ; this . counter _read _mode = new Uint8Array ( 4 ) ; this . counter _latch = new Uint8Array ( 4 ) ; this . counter _latch _value = new Uint16Array ( 3 ) ; this . counter _reload = new Uint16Array ( 3 ) ; a . io . register _read ( 97 , this , function ( ) { var c = E . microtick ( ) , d = 66.66666666666667 * c & 1 ; c = this . did _rollover ( 2 ,
2024-06-28 09:23:02 +02:00
c ) ; return d << 4 | c << 5 } ) ; a . io . register _write ( 97 , this , function ( c ) { c & 1 ? this . bus . send ( "pcspeaker-enable" ) : this . bus . send ( "pcspeaker-disable" ) } ) ; a . io . register _read ( 64 , this , function ( ) { return this . counter _read ( 0 ) } ) ; a . io . register _read ( 65 , this , function ( ) { return this . counter _read ( 1 ) } ) ; a . io . register _read ( 66 , this , function ( ) { return this . counter _read ( 2 ) } ) ; a . io . register _write ( 64 , this , function ( c ) { this . counter _write ( 0 , c ) } ) ; a . io . register _write ( 65 , this , function ( c ) { this . counter _write ( 1 , c ) } ) ; a . io . register _write ( 66 , this ,
2024-10-02 21:03:04 +02:00
function ( c ) { this . counter _write ( 2 , c ) ; this . bus . send ( "pcspeaker-update" , [ this . counter _mode [ 2 ] , this . counter _reload [ 2 ] ] ) } ) ; a . io . register _write ( 67 , this , this . port43 _write ) } ta . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . counter _next _low ; a [ 1 ] = this . counter _enabled ; a [ 2 ] = this . counter _mode ; a [ 3 ] = this . counter _read _mode ; a [ 4 ] = this . counter _latch ; a [ 5 ] = this . counter _latch _value ; a [ 6 ] = this . counter _reload ; a [ 7 ] = this . counter _start _time ; a [ 8 ] = this . counter _start _value ; return a } ;
ta . prototype . set _state = function ( a ) { this . counter _next _low = a [ 0 ] ; this . counter _enabled = a [ 1 ] ; this . counter _mode = a [ 2 ] ; this . counter _read _mode = a [ 3 ] ; this . counter _latch = a [ 4 ] ; this . counter _latch _value = a [ 5 ] ; this . counter _reload = a [ 6 ] ; this . counter _start _time = a [ 7 ] ; this . counter _start _value = a [ 8 ] } ;
ta . prototype . timer = function ( a , b ) { var c = 100 ; b || ( this . counter _enabled [ 0 ] && this . did _rollover ( 0 , a ) ? ( this . counter _start _value [ 0 ] = this . get _counter _value ( 0 , a ) , this . counter _start _time [ 0 ] = a , this . cpu . device _lower _irq ( 0 ) , this . cpu . device _raise _irq ( 0 ) , 0 === this . counter _mode [ 0 ] && ( this . counter _enabled [ 0 ] = 0 ) ) : this . cpu . device _lower _irq ( 0 ) , this . counter _enabled [ 0 ] && ( c = ( this . counter _start _value [ 0 ] - Math . floor ( 1193.1816666 * ( a - this . counter _start _time [ 0 ] ) ) ) / 1193.1816666 ) ) ; return c } ;
ta . prototype . get _counter _value = function ( a , b ) { if ( ! this . counter _enabled [ a ] ) return 0 ; b = this . counter _start _value [ a ] - Math . floor ( 1193.1816666 * ( b - this . counter _start _time [ a ] ) ) ; a = this . counter _reload [ a ] ; b >= a ? b %= a : 0 > b && ( b = b % a + a ) ; return b } ; ta . prototype . did _rollover = function ( a , b ) { b -= this . counter _start _time [ a ] ; return 0 > b ? ! 0 : this . counter _start _value [ a ] < Math . floor ( 1193.1816666 * b ) } ;
ta . prototype . counter _read = function ( a ) { var b = this . counter _latch [ a ] ; if ( b ) return this . counter _latch [ a ] -- , 2 === b ? this . counter _latch _value [ a ] & 255 : this . counter _latch _value [ a ] >> 8 ; b = this . counter _next _low [ a ] ; 3 === this . counter _mode [ a ] && ( this . counter _next _low [ a ] ^= 1 ) ; a = this . get _counter _value ( a , E . microtick ( ) ) ; return b ? a & 255 : a >> 8 } ;
ta . prototype . counter _write = function ( a , b ) { this . counter _reload [ a ] = this . counter _next _low [ a ] ? this . counter _reload [ a ] & - 256 | b : this . counter _reload [ a ] & 255 | b << 8 ; 3 === this . counter _read _mode [ a ] && this . counter _next _low [ a ] || ( this . counter _reload [ a ] || ( this . counter _reload [ a ] = 65535 ) , this . counter _start _value [ a ] = this . counter _reload [ a ] , this . counter _enabled [ a ] = ! 0 , this . counter _start _time [ a ] = E . microtick ( ) , A ( this . counter _reload [ a ] ) ) ; 3 === this . counter _read _mode [ a ] && ( this . counter _next _low [ a ] ^= 1 ) } ;
ta . prototype . port43 _write = function ( a ) { var b = a >> 1 & 7 , c = a >> 6 & 3 ; a = a >> 4 & 3 ; 3 !== c && ( 0 === a ? ( this . counter _latch [ c ] = 2 , b = this . get _counter _value ( c , E . microtick ( ) ) , this . counter _latch _value [ c ] = b ? b - 1 : 0 ) : ( 6 <= b && ( b &= - 5 ) , this . counter _next _low [ c ] = 1 === a ? 0 : 1 , 0 === c && this . cpu . device _lower _irq ( 0 ) , 0 !== b && 3 !== b && 2 !== b && A ( b ) , this . counter _mode [ c ] = b , this . counter _read _mode [ c ] = a , 2 === c && this . bus . send ( "pcspeaker-update" , [ this . counter _mode [ 2 ] , this . counter _reload [ 2 ] ] ) ) ) } ; ta . prototype . dump = function ( ) { } ; const ua = Uint32Array . from ( [ 655360 , 655360 , 720896 , 753664 ] ) , va = Uint32Array . from ( [ 131072 , 65536 , 32768 , 32768 ] ) ;
function N ( a , b , c , d , e ) { 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 = 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 = 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 : t . round _up _to _next _power _of _2 ( this . vga _memory _size ) ;
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 , 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 = 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 ;
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 , 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 , 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 , 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 ( ) { 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 ) ; 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 = t . view ( 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 , 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 , f => this . vga _memory _read ( f ) , ( f , g ) => this . vga _memory _write ( f , g ) ) ; e . use _graphical _text && ( this . graphical _text = new wa ( this ) ) ; a . devices . pci . register _device ( this ) }
N . prototype . grab _text _content = function ( a ) { var b = this . start _address << 1 ; const c = this . scan _line _to _screen _row ( this . line _compare ) , d = Math . max ( 0 , 2 * ( 2 * this . offset _register - this . max _cols ) ) , e = [ ] ; for ( var f = 0 ; f < this . max _rows ; f ++ ) { f === c && ( b = 0 ) ; let h = "" ; for ( var g = 0 ; g < this . max _cols ; g ++ , b += 2 ) h += String . fromCodePoint ( this . vga _memory [ b ] ) ; e . push ( a ? h : h . trimEnd ( ) ) ; b += d } return e } ;
N . 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 ; 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 ;
2024-06-28 09:23:02 +02:00
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 ; 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 ;
2024-10-02 21:03:04 +02:00
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 ; 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 ] = this . dac _mask ; a [ 63 ] = this . character _map _select ; return a } ;
N . 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 = a [ 14 ] ; this . svga _width = a [ 15 ] ; this . svga _height = a [ 16 ] ; this . crtc _mode = a [ 17 ] ; this . svga _enabled =
2024-06-28 09:23:02 +02:00
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 = a [ 34 ] ; this . miscellaneous _output _register = a [ 35 ] ; this . port _3DA _value = a [ 36 ] ; this . dispi _index =
2024-10-02 21:03:04 +02:00
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 = 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 . screen . set _mode ( this . graphical _mode || ! ! this . graphical _text ) ; this . graphical _mode ? ( this . screen _height = this . screen _width = 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 _size _text ( this . max _cols , this . max _rows ) , this . update _cursor _scanline ( ) , this . update _cursor ( ) ) ; this . complete _redraw ( ) } ;
N . prototype . vga _memory _read = function ( a ) { if ( this . svga _enabled ) return this . cpu . read8 ( ( a - 655360 | this . svga _bank _offset ) + 3758096384 | 0 ) ; var b = this . miscellaneous _graphics _register >> 2 & 3 ; a -= ua [ b ] ; if ( 0 > a || a >= va [ b ] ) return A ( a ) , 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 && ( 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 ] } ;
N . 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 -= ua [ c ] ; 0 > a || a >= va [ c ] ? ( A ( a ) , A ( b ) ) : this . graphical _mode ? this . vga _memory _write _graphical ( a , b ) : this . plane _write _bm & 3 ? this . vga _memory _write _text _mode ( a , b ) : this . plane2 [ a ] = b } } ;
N . 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 , 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 ] = g >> 24 & 255 ) ; a = this . vga _addr _to _pixel ( a ) ; this . partial _replot ( a , a + 7 ) } ; N . prototype . apply _feed = function ( a ) { return a | a << 8 | a << 16 | a << 24 } ;
N . 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 } ; N . prototype . apply _rotate = function ( a ) { return ( a | a << 8 ) >>> ( this . planar _rotate _reg & 7 ) & 255 } ; N . prototype . apply _setreset = function ( a , b ) { var c = this . apply _expand ( this . planar _setreset ) ; return ( a | b & c ) & ( ~ b | c ) } ; N . prototype . apply _logical = function ( a , b ) { switch ( this . planar _rotate _reg & 24 ) { case 8 : return a & b ; case 16 : return a | b ; case 24 : return a ^ b } return a } ; N . prototype . apply _bitmask = function ( a , b ) { return b & a | ~ b & this . latch _dword } ;
N . prototype . text _mode _redraw = function ( ) { if ( ! this . graphical _text ) { var 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 = c ? 7 : 15 , e = this . start _address << 1 ; for ( let f = 0 ; f < this . max _rows ; f ++ ) { f === a && ( e = 0 ) ; for ( let g = 0 ; g < this . max _cols ; g ++ ) { const h = this . vga _memory [ e ] , l = this . vga _memory [ e | 1 ] , m = c && l & 128 ; this . bus . send ( "screen-put-char" , [ f , g , h ] ) ; this . screen . put _char ( f , g , h , m , this . vga256 _palette [ this . dac _mask & this . dac _map [ l >> 4 & d ] ] , this . vga256 _palette [ this . dac _mask &
this . dac _map [ l & 15 ] ] ) ; e += 2 } e += b } } } ;
N . 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 = a >> 1 , d = ( e / c | 0 ) + this . scan _line _to _screen _row ( this . line _compare ) , c = e % 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 ; f = f ? 7 : 15 ; this . bus . send ( "screen-put-char" , [ d , c , b ] ) ; this . graphical _text ? this . graphical _text . invalidate _row ( d ) :
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 & this . dac _map [ e & 15 ] ] ) } } ;
N . 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 ) ; this . graphical _text ? this . graphical _text . set _cursor _pos ( b , a ) : this . screen . update _cursor ( b , a ) } ;
N . prototype . complete _redraw = function ( ) { this . graphical _mode ? this . svga _enabled ? this . cpu . svga _mark _dirty ( ) : ( this . diff _addr _min = 0 , this . diff _addr _max = 524288 ) : this . text _mode _redraw ( ) } ; N . prototype . complete _replot = function ( ) { this . graphical _mode && ! this . svga _enabled && ( this . diff _plot _min = 0 , this . diff _plot _max = 524288 , this . complete _redraw ( ) ) } ; N . 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 ) } ;
N . prototype . partial _replot = function ( a , b ) { a < this . diff _plot _min && ( this . diff _plot _min = a ) ; b > this . diff _plot _max && ( this . diff _plot _max = b ) ; this . partial _redraw ( a , b ) } ; N . 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 } ; N . prototype . destroy = function ( ) { } ; N . 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 } ;
N . prototype . vga _addr _shift _count = function ( ) { var a = 128 + ( ~ this . underline _location _register & this . crtc _mode & 64 ) ; a -= this . underline _location _register & 64 ; a -= this . attribute _mode & 64 ; return a >>> 6 } ;
N . 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 } ;
N . prototype . scan _line _to _screen _row = function ( a ) { this . max _scan _line & 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 } ; N . prototype . set _size _text = function ( a , b ) { this . max _cols = a ; this . max _rows = b ; this . bus . send ( "screen-set-size" , [ a , b , 0 ] ) ; this . graphical _text ? this . graphical _text . set _size ( b , a ) : this . screen . set _size _text ( a , b ) } ;
N . prototype . set _size _graphical = function ( a , b , c , d , e ) { 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 = 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 ] ) } } ;
N . prototype . update _vga _size = function ( ) { if ( ! this . svga _enabled ) { var a = Math . min ( 1 + this . horizontal _display _enable _end , this . horizontal _blank _start ) , 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 ; this . attribute _mode & 64 && ( a >>>= 1 , c >>>= 1 ) ; b = this . scan _line _to _screen _row ( b ) ; var d = va [ 0 ] ; const e = this . vga _bytes _per _line ( ) ; this . set _size _graphical ( a , b , c , e ? Math . ceil ( d / e ) : b , 8 ) ; this . update _vertical _retrace ( ) ; this . update _layers ( ) } else this . max _scan _line &
2024-06-28 09:23:02 +02:00
128 && ( b >>>= 1 ) , c = b / ( 1 + ( this . max _scan _line & 31 ) ) | 0 , a && c && this . set _size _text ( a , c ) } } ;
2024-10-02 21:03:04 +02:00
N . 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 ) ;
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 ,
buffer _height : f } ) } } ; N . 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 ( ) ) } ;
N . 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 ) ; const c = ! ( this . cursor _scanline _start & 32 ) && b < a ; this . graphical _text ? this . graphical _text . set _cursor _attr ( b , a , c ) : this . screen . update _cursor _scanline ( b , a , c ) } ;
N . prototype . port3C0 _write = function ( a ) { if ( - 1 === this . attribute _controller _index ) A ( a ) , this . attribute _controller _index = a & 31 , A ( this . attribute _controller _index ) , this . palette _source !== ( a & 32 ) && ( this . palette _source = a & 32 , this . update _layers ( ) ) ; else { if ( 16 > this . attribute _controller _index ) A ( this . attribute _controller _index ) , A ( a ) , this . dac _map [ this . attribute _controller _index ] = a , this . attribute _mode & 64 || this . complete _redraw ( ) ; else switch ( this . attribute _controller _index ) { case 16 : A ( a ) ; 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 || ! ! this . graphical _text ) ) ; ( b ^ a ) & 64 && this . complete _replot ( ) ; this . update _vga _size ( ) ; this . complete _redraw ( ) } break ; case 18 : A ( a ) ; this . color _plane _enable !== a && ( this . color _plane _enable = a , this . complete _redraw ( ) ) ; break ; case 19 : A ( a ) ; this . horizontal _panning !== a && ( this . horizontal _panning = a & 15 , this . update _layers ( ) ) ; break ; case 20 : A ( a ) ; this . color _select !==
a && ( this . color _select = a , this . complete _redraw ( ) ) ; break ; default : A ( this . attribute _controller _index ) , A ( a ) } this . attribute _controller _index = - 1 } } ; N . prototype . port3C0 _read = function ( ) { return ( this . attribute _controller _index | this . palette _source ) & 255 } ; N . prototype . port3C0 _read16 = function ( ) { return this . port3C0 _read ( ) | this . port3C1 _read ( ) << 8 & 65280 } ;
N . prototype . port3C1 _read = function ( ) { if ( 16 > this . attribute _controller _index ) return A ( this . attribute _controller _index ) , A ( this . dac _map [ this . attribute _controller _index ] ) , this . dac _map [ this . attribute _controller _index ] & 255 ; switch ( this . attribute _controller _index ) { case 16 : return A ( this . attribute _mode ) , this . attribute _mode ; case 18 : return A ( this . color _plane _enable ) , this . color _plane _enable ; case 19 : return A ( this . horizontal _panning ) , this . horizontal _panning ; case 20 : return A ( this . color _select ) , this . color _select ; default : A ( this . attribute _controller _index ) } return 255 } ;
N . prototype . port3C2 _write = function ( a ) { A ( a ) ; this . miscellaneous _output _register = a } ; N . prototype . port3C4 _write = function ( a ) { this . sequencer _index = a } ; N . prototype . port3C4 _read = function ( ) { return this . sequencer _index } ;
N . prototype . port3C5 _write = function ( a ) { switch ( this . sequencer _index ) { case 1 : A ( a ) ; var b = this . clocking _mode ; this . clocking _mode = a ; ( b ^ a ) & 32 && this . update _layers ( ) ; break ; case 2 : A ( a ) ; b = this . plane _write _bm ; this . plane _write _bm = a ; this . graphical _text && 15 !== b && b & 4 && ! ( this . plane _write _bm & 4 ) && this . graphical _text . invalidate _font _shape ( ) ; break ; case 3 : A ( a ) ; b = this . character _map _select ; this . character _map _select = a ; this . graphical _text && b !== this . character _map _select && this . graphical _text . set _character _map ( this . character _map _select ) ;
break ; case 4 : A ( a ) ; this . sequencer _memory _mode = a ; break ; default : A ( this . sequencer _index ) , A ( a ) } } ; N . prototype . port3C5 _read = function ( ) { A ( this . sequencer _index ) ; 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 ; case 6 : return 18 } return 0 } ; N . prototype . port3C6 _write = function ( a ) { this . dac _mask = a } ; N . prototype . port3C6 _read = function ( ) { return this . dac _mask } ;
N . prototype . port3C7 _write = function ( a ) { A ( a ) ; this . dac _color _index _read = 3 * a ; this . dac _state &= 0 } ; N . prototype . port3C7 _read = function ( ) { return this . dac _state } ; N . prototype . port3C8 _write = function ( a ) { this . dac _color _index _write = 3 * a ; this . dac _state |= 3 } ; N . prototype . port3C8 _read = function ( ) { return this . dac _color _index _write / 3 & 255 } ;
N . 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 , A ( b ) , A ( d ) ) ; this . vga256 _palette [ b ] !== d && ( this . vga256 _palette [ b ] = d , this . complete _redraw ( ) ) ; this . dac _color _index _write ++ } ;
N . prototype . port3C9 _read = function ( ) { var a = this . vga256 _palette [ this . dac _color _index _read / 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 } ; N . prototype . port3CC _read = function ( ) { return this . miscellaneous _output _register } ; N . prototype . port3CE _write = function ( a ) { this . graphics _index = a } ; N . prototype . port3CE _read = function ( ) { return this . graphics _index } ;
N . prototype . port3CF _write = function ( a ) { switch ( this . graphics _index ) { case 0 : this . planar _setreset = a ; A ( a ) ; break ; case 1 : this . planar _setreset _enable = a ; A ( a ) ; break ; case 2 : this . color _compare = a ; A ( a ) ; break ; case 3 : this . planar _rotate _reg = a ; A ( a ) ; break ; case 4 : this . plane _read = a ; A ( a ) ; break ; case 5 : var b = this . planar _mode ; this . planar _mode = a ; A ( a ) ; ( b ^ a ) & 96 && this . complete _replot ( ) ; break ; case 6 : A ( a ) ; this . miscellaneous _graphics _register !== a && ( this . miscellaneous _graphics _register = a , this . update _vga _size ( ) ) ; break ; case 7 : this . color _dont _care =
a ; A ( a ) ; break ; case 8 : this . planar _bitmap = a ; A ( a ) ; break ; default : A ( this . graphics _index ) , A ( a ) } } ; N . prototype . port3CF _read = function ( ) { A ( this . graphics _index ) ; 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 ; 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 } ;
N . prototype . port3D4 _write = function ( a ) { this . index _crtc = a } ; N . prototype . port3D4 _write16 = function ( a ) { this . port3D4 _write ( a & 255 ) ; this . port3D5 _write ( a >> 8 & 255 ) } ; N . prototype . port3D4 _read = function ( ) { return this . index _crtc } ;
N . prototype . port3D5 _write = function ( a ) { switch ( this . index _crtc ) { case 1 : A ( a ) ; this . horizontal _display _enable _end !== a && ( this . horizontal _display _enable _end = a , this . update _vga _size ( ) ) ; break ; case 2 : this . horizontal _blank _start !== a && ( this . horizontal _blank _start = a , this . update _vga _size ( ) ) ; break ; case 7 : A ( a ) ; var b = this . vertical _display _enable _end ; this . vertical _display _enable _end &= 255 ; this . vertical _display _enable _end = this . vertical _display _enable _end | a << 3 & 512 | a << 7 & 256 ; b !== this . vertical _display _enable _end && this . update _vga _size ( ) ;
this . line _compare = this . line _compare & 767 | a << 4 & 256 ; b = this . vertical _blank _start ; this . vertical _blank _start = this . vertical _blank _start & 767 | a << 5 & 256 ; b !== this . vertical _blank _start && this . update _vga _size ( ) ; this . update _layers ( ) ; break ; case 8 : A ( a ) ; this . preset _row _scan = a ; this . update _layers ( ) ; break ; case 9 : A ( a ) ; var c = this . max _scan _line ; this . max _scan _line = a ; this . line _compare = this . line _compare & 511 | a << 3 & 512 ; b = this . vertical _blank _start ; this . vertical _blank _start = this . vertical _blank _start & 511 | a << 4 & 512 ; ( ( c ^ this . max _scan _line ) &
159 || b !== this . vertical _blank _start ) && this . update _vga _size ( ) ; this . update _cursor _scanline ( ) ; this . update _layers ( ) ; break ; case 10 : A ( a ) ; this . cursor _scanline _start = a ; this . update _cursor _scanline ( ) ; break ; case 11 : A ( a ) ; this . cursor _scanline _end = a ; this . update _cursor _scanline ( ) ; break ; case 12 : ( this . start _address >> 8 & 255 ) !== a && ( this . start _address = this . start _address & 255 | a << 8 , this . update _layers ( ) , ~ this . crtc _mode & 3 && this . complete _replot ( ) ) ; A ( a ) ; A ( this . start _address , 4 ) ; break ; case 13 : ( this . start _address & 255 ) !== a && ( this . start _address =
this . start _address & 65280 | a , this . update _layers ( ) , ~ this . crtc _mode & 3 && this . complete _replot ( ) ) ; A ( a ) ; A ( this . start _address , 4 ) ; break ; case 14 : A ( a ) ; this . cursor _address = this . cursor _address & 255 | a << 8 ; this . update _cursor ( ) ; break ; case 15 : A ( a ) ; this . cursor _address = this . cursor _address & 65280 | a ; this . update _cursor ( ) ; break ; case 18 : A ( a ) ; ( this . vertical _display _enable _end & 255 ) !== a && ( this . vertical _display _enable _end = this . vertical _display _enable _end & 768 | a , this . update _vga _size ( ) ) ; break ; case 19 : A ( a ) ; this . offset _register !== a &&
( this . offset _register = a , this . update _vga _size ( ) , ~ this . crtc _mode & 3 && this . complete _replot ( ) ) ; break ; case 20 : A ( a ) ; this . underline _location _register !== a && ( b = this . underline _location _register , this . underline _location _register = a , this . update _vga _size ( ) , ( b ^ a ) & 64 && this . complete _replot ( ) ) ; break ; case 21 : A ( a ) ; ( this . vertical _blank _start & 255 ) !== a && ( this . vertical _blank _start = this . vertical _blank _start & 768 | a , this . update _vga _size ( ) ) ; break ; case 23 : A ( a ) ; this . crtc _mode !== a && ( b = this . crtc _mode , this . crtc _mode = a , this . update _vga _size ( ) ,
( b ^ a ) & 67 && this . complete _replot ( ) ) ; break ; case 24 : A ( a ) ; this . line _compare = this . line _compare & 768 | a ; this . update _layers ( ) ; break ; default : this . index _crtc < this . crtc . length && ( this . crtc [ this . index _crtc ] = a ) , A ( this . index _crtc ) , A ( a ) } } ; N . prototype . port3D5 _write16 = function ( a ) { A ( a , 4 ) ; this . port3D5 _write ( a & 255 ) } ;
N . prototype . port3D5 _read = function ( ) { A ( this . index _crtc ) ; switch ( this . index _crtc ) { case 1 : return this . horizontal _display _enable _end ; case 2 : return this . horizontal _blank _start ; case 7 : return this . vertical _display _enable _end >> 7 & 2 | this . vertical _blank _start >> 5 & 8 | this . line _compare >> 4 & 16 | this . vertical _display _enable _end >> 3 & 64 ; case 8 : return this . preset _row _scan ; case 9 : return this . max _scan _line ; case 10 : return this . cursor _scanline _start ; case 11 : return this . cursor _scanline _end ; case 12 : return this . start _address & 255 ;
case 13 : return this . start _address >> 8 ; case 14 : return this . cursor _address >> 8 ; case 15 : return this . cursor _address & 255 ; case 18 : return this . vertical _display _enable _end & 255 ; case 19 : return this . offset _register ; case 20 : return this . underline _location _register ; case 21 : return this . vertical _blank _start & 255 ; case 23 : return this . crtc _mode ; case 24 : return this . line _compare & 255 } return this . index _crtc < this . crtc . length ? this . crtc [ this . index _crtc ] : 0 } ; N . prototype . port3D5 _read16 = function ( ) { return this . port3D5 _read ( ) } ;
N . prototype . port3DA _read = function ( ) { var a = this . port _3DA _value ; this . graphical _mode ? ( this . port _3DA _value ^= 1 , this . port _3DA _value &= 1 ) : ( this . port _3DA _value & 1 && ( this . port _3DA _value ^= 8 ) , this . port _3DA _value ^= 1 ) ; this . attribute _controller _index = - 1 ; return a } ; N . prototype . port1CE _write = function ( a ) { this . dispi _index = a } ;
N . prototype . port1CF _write = function ( a ) { A ( this . dispi _index ) ; A ( a ) ; const b = this . svga _enabled ; switch ( this . dispi _index ) { case 0 : 45248 <= a && 45253 >= a ? this . svga _version = a : A ( a ) ; break ; case 1 : this . svga _width = a ; 2560 < this . svga _width && ( this . svga _width = 2560 ) ; break ; case 2 : this . svga _height = a ; 1600 < this . svga _height && ( this . svga _height = 1600 ) ; break ; case 3 : this . svga _bpp = a ; break ; case 4 : ( this . svga _enabled = 1 === ( a & 1 ) ) && 0 === ( a & 128 ) && this . svga _memory . fill ( 0 ) ; this . dispi _enable _value = a ; break ; case 5 : A ( a << 16 ) ; this . svga _bank _offset =
a << 16 ; break ; case 8 : A ( a ) ; this . svga _offset _x !== a && ( this . svga _offset _x = a , this . svga _offset = this . svga _offset _y * this . svga _width + this . svga _offset _x , this . complete _redraw ( ) ) ; break ; case 9 : A ( a * this . svga _width ) ; A ( a ) ; this . svga _offset _y !== a && ( this . svga _offset _y = a , this . svga _offset = this . svga _offset _y * this . svga _width + this . svga _offset _x , this . complete _redraw ( ) ) ; break ; default : A ( this . dispi _index ) } ! this . svga _enabled || this . svga _width && this . svga _height || ( this . svga _enabled = ! 1 ) ; this . svga _enabled && ! b && ( this . svga _offset _y = this . svga _offset _x =
this . svga _offset = 0 , this . graphical _mode = ! 0 , this . screen . set _mode ( this . graphical _mode ) , this . set _size _graphical ( this . svga _width , this . svga _height , this . svga _width , this . svga _height , this . svga _bpp ) ) ; this . svga _enabled || ( this . svga _bank _offset = 0 ) ; this . update _layers ( ) } ; N . prototype . port1CF _read = function ( ) { A ( this . dispi _index ) ; return this . svga _register _read ( this . dispi _index ) } ;
N . prototype . svga _register _read = function ( a ) { switch ( a ) { case 0 : return this . svga _version ; case 1 : return this . dispi _enable _value & 2 ? 2560 : this . svga _width ; case 2 : return this . dispi _enable _value & 2 ? 1600 : this . svga _height ; case 3 : return this . dispi _enable _value & 2 ? 32 : this . svga _bpp ; case 4 : return this . dispi _enable _value ; case 5 : return this . svga _bank _offset >>> 16 ; case 6 : return this . screen _width ? this . screen _width : 1 ; case 8 : return this . svga _offset _x ; case 9 : return this . svga _offset _y ; case 10 : return this . vga _memory _size / 65536 |
0 ; default : A ( this . dispi _index ) } return 255 } ;
N . prototype . vga _replot = function ( ) { for ( var a = this . diff _plot _min & - 16 , b = Math . min ( this . diff _plot _max | 15 , 524287 ) , c = this . vga _addr _shift _count ( ) , d = ~ this . crtc _mode & 3 , e = this . planar _mode & 96 , f = this . attribute _mode & 64 ; a <= b ; ) { var g = a >>> c ; if ( d ) { var h = a / this . virtual _width | 0 , l = a - this . virtual _width * h ; switch ( d ) { case 1 : g = ( h & 1 ) << 13 ; h >>>= 1 ; break ; case 2 : g = ( h & 1 ) << 14 ; h >>>= 1 ; break ; case 3 : g = ( h & 3 ) << 13 , h >>>= 2 } g |= ( h * this . virtual _width + l >>> c ) + this . start _address } h = this . plane0 [ g ] ; l = this . plane1 [ g ] ; var m = this . plane2 [ g ] , n = this . plane3 [ g ] ;
g = new Uint8Array ( 8 ) ; switch ( e ) { case 0 : h <<= 0 ; l <<= 1 ; m <<= 2 ; n <<= 3 ; for ( var p = 7 ; 0 <= p ; p -- ) g [ 7 - p ] = h >> p & 1 | l >> p & 2 | m >> p & 4 | n >> p & 8 ; break ; case 32 : g [ 0 ] = h >> 6 & 3 | m >> 4 & 12 ; g [ 1 ] = h >> 4 & 3 | m >> 2 & 12 ; g [ 2 ] = h >> 2 & 3 | m >> 0 & 12 ; g [ 3 ] = h >> 0 & 3 | m << 2 & 12 ; g [ 4 ] = l >> 6 & 3 | n >> 4 & 12 ; g [ 5 ] = l >> 4 & 3 | n >> 2 & 12 ; g [ 6 ] = l >> 2 & 3 | n >> 0 & 12 ; g [ 7 ] = l >> 0 & 3 | n << 2 & 12 ; break ; case 64 : case 96 : g [ 0 ] = h >> 4 & 15 , g [ 1 ] = h >> 0 & 15 , g [ 2 ] = l >> 4 & 15 , g [ 3 ] = l >> 0 & 15 , g [ 4 ] = m >> 4 & 15 , g [ 5 ] = m >> 0 & 15 , g [ 6 ] = n >> 4 & 15 , g [ 7 ] = n >> 0 & 15 } if ( f ) for ( h = p = 0 ; 4 > p ; p ++ , a ++ , h += 2 ) this . pixel _buffer [ a ] = g [ h ] << 4 | g [ h + 1 ] ; else for ( p = 0 ; 8 > p ; p ++ ,
a ++ ) this . pixel _buffer [ a ] = g [ p ] } } ;
N . prototype . vga _redraw = function ( ) { var a = this . diff _addr _min , b = Math . min ( this . diff _addr _max , 524287 ) ; const c = new Int32Array ( this . cpu . wasm _memory . buffer , this . dest _buffet _offset , this . virtual _width * this . virtual _height ) ; var d = 255 , e = 0 ; this . attribute _mode & 128 && ( d &= 207 , e |= this . color _select << 4 & 48 ) ; if ( this . attribute _mode & 64 ) for ( ; a <= b ; a ++ ) { var f = this . pixel _buffer [ a ] & d | e ; f = this . vga256 _palette [ f ] ; c [ a ] = f & 65280 | f << 16 | f >> 16 | 4278190080 } else for ( d &= 63 , e |= this . color _select << 4 & 192 ; a <= b ; a ++ ) f = this . dac _map [ this . pixel _buffer [ a ] &
this . color _plane _enable ] & d | e , f = this . vga256 _palette [ f ] , c [ a ] = f & 65280 | f << 16 | f >> 16 | 4278190080 } ;
N . prototype . screen _fill _buffer = function ( ) { if ( this . graphical _mode ) { if ( 0 === this . image _data . data . byteLength ) { var a = new Uint8ClampedArray ( this . cpu . wasm _memory . buffer , this . dest _buffet _offset , 4 * this . virtual _width * this . virtual _height ) ; this . image _data = new ImageData ( a , this . virtual _width , this . virtual _height ) ; this . update _layers ( ) } if ( this . svga _enabled ) { a = 0 ; let d = this . svga _height ; if ( 8 === this . svga _bpp ) { const e = new Int32Array ( this . cpu . wasm _memory . buffer , this . dest _buffet _offset , this . screen _width * this . screen _height ) ,
f = new Uint8Array ( this . cpu . wasm _memory . buffer , this . svga _memory . byteOffset , this . vga _memory _size ) ; for ( var b = 0 ; b < e . length ; b ++ ) { var c = this . vga256 _palette [ f [ b ] ] ; e [ b ] = c & 65280 | c << 16 | c >> 16 | 4278190080 } } else this . cpu . svga _fill _pixel _buffer ( this . svga _bpp , this . svga _offset ) , b = 15 === this . svga _bpp ? 2 : this . svga _bpp / 8 , a = ( ( this . cpu . svga _dirty _bitmap _min _offset [ 0 ] / b | 0 ) - this . svga _offset ) / this . svga _width | 0 , d = ( ( ( this . cpu . svga _dirty _bitmap _max _offset [ 0 ] / b | 0 ) - this . svga _offset ) / this . svga _width | 0 ) + 1 ; a < d && ( a = Math . max ( a , 0 ) , d = Math . min ( d ,
this . svga _height ) , this . screen . update _buffer ( [ { image _data : this . image _data , screen _x : 0 , screen _y : a , buffer _x : 0 , buffer _y : a , buffer _width : this . svga _width , buffer _height : d - a } ] ) ) } else this . vga _replot ( ) , this . vga _redraw ( ) , this . screen . update _buffer ( this . layers ) ; this . reset _diffs ( ) ; this . update _vertical _retrace ( ) } else this . graphical _text && ( a = this . graphical _text . render ( ) , this . screen . update _buffer ( [ { image _data : a , screen _x : 0 , screen _y : 0 , buffer _x : 0 , buffer _y : 0 , buffer _width : a . width , buffer _height : a . height } ] ) ) } ; function wa ( a ) { this . vga = a ; this . txt _width = 80 ; this . txt _height = 25 ; this . txt _dirty = 0 ; this . txt _row _dirty = new Uint8Array ( this . txt _height ) ; this . font _data _dirty = ! 1 ; this . font _width = 9 ; this . font _height = 16 ; this . font _lge = ! 1 ; this . font _bitmap = new Uint8ClampedArray ( 2048 * this . font _width * this . font _height ) ; this . font _blink _enabled = ! 1 ; this . font _index _B = this . font _index _A = 0 ; this . cursor _enabled _latch = this . cursor _attr _dirty = ! 1 ; this . cursor _bottom _latch = this . cursor _top _latch = 0 ; this . cursor _pos _dirty = ! 1 ; this . cursor _col _latch =
this . cursor _row _latch = 0 ; this . cursor _enabled = ! 1 ; this . vga _max _scan _line = this . vga _clocking _mode = this . vga _attribute _mode = this . cursor _bottom = this . cursor _top = this . cursor _col = this . cursor _row = 0 ; this . gfx _width = this . txt _width * this . font _width ; this . gfx _height = this . txt _height * this . font _height ; this . gfx _data = new Uint8ClampedArray ( this . gfx _width * this . gfx _height * 4 ) ; this . image _data = new ImageData ( this . gfx _data , this . gfx _width , this . gfx _height ) ; this . blink _visible = ! 1 ; this . frame _count = 0 }
wa . prototype . rebuild _font _bitmap = function ( a , b ) { const c = this . font _height , d = this . font _lge , e = this . vga . plane2 , f = new Uint8ClampedArray ( 2048 * this . font _width * c ) , g = 32 - c ; let h = 0 ; b = b ? function ( m ) { f [ h ++ ] = m ; f [ h ++ ] = m } : function ( m ) { f [ h ++ ] = m } ; let l = 0 ; for ( let m = 0 ; 8 > m ; ++ m ) for ( let n = 0 ; 256 > n ; ++ n , l += g ) for ( let p = 0 ; p < c ; ++ p ) { const q = e [ l ++ ] ; for ( let r = 128 ; 0 < r ; r >>= 1 ) b ( q & r ? 1 : 0 ) ; a && b ( d && 192 <= n && 223 >= n && q & 1 ? 1 : 0 ) } return f } ; wa . prototype . resize _canvas = function ( ) { this . txt _dirty = 1 ; this . txt _row _dirty . fill ( 1 ) } ;
wa . prototype . rebuild _image _data = function ( ) { const a = this . gfx _width * this . gfx _height * 4 , b = new Uint8ClampedArray ( a ) ; for ( let c = 3 ; c < a ; c += 4 ) b [ c ] = 255 ; this . gfx _data = b ; this . image _data = new ImageData ( this . gfx _data , this . gfx _width , this . gfx _height ) ; this . resize _canvas ( ) } ;
wa . prototype . mark _blinking _rows _dirty = function ( ) { const a = this . vga . vga _memory , b = this . txt _row _dirty , c = this . txt _width , d = this . txt _height , e = 2 * c , f = Math . max ( 0 , 2 * ( 2 * this . vga . offset _register - c ) ) , g = this . vga . scan _line _to _screen _row ( this . vga . line _compare ) ; let h , l , m = this . vga . start _address << 1 ; for ( h = 0 ; h < d ; ++ h , m += f ) if ( h === g && ( m = 0 ) , b [ h ] ) m += e ; else for ( l = 0 ; l < c ; ++ l , m += 2 ) if ( a [ m | 1 ] & 128 ) { b [ h ] = this . txt _dirty = 1 ; m += e - 2 * l ; break } } ;
wa . prototype . render _dirty _rows = function ( ) { var a = this . vga ; const b = a . vga _memory , c = this . txt _width , d = this . txt _height , e = this . txt _row _dirty , f = this . gfx _data , g = this . font _bitmap , h = this . font _width * this . font _height , l = 256 * this . font _index _A , m = 256 * this . font _index _B , n = l !== m ; var p = this . font _blink _enabled ; const q = this . cursor _enabled && ! 0 , r = this . cursor _top , D = this . cursor _bottom - r + 1 , y = a . scan _line _to _screen _row ( a . line _compare ) ; p = p ? 7 : 15 ; const u = new Int32Array ( 16 ) ; for ( var F = 0 ; 16 > F ; ++ F ) u [ F ] = a . vga256 _palette [ a . dac _mask & a . dac _map [ F ] ] ;
F = 2 * c ; const w = Math . max ( 0 , 2 * ( 2 * a . offset _register - c ) ) , K = 4 * this . font _width , V = 4 * this . gfx _width , Ka = V * this . font _height , bb = 4 * ( this . font _width - this . font _height * this . gfx _width ) , na = 4 * ( this . gfx _width - this . font _width ) , C = 4 * ( this . cursor _row * this . gfx _width * this . font _height + this . cursor _col * this . font _width ) ; let x , M , O = 0 , U = 0 , Y = 0 , ka = 0 , Ga = 0 , Ha = 0 , W , La , mb ; a = a . start _address << 1 ; for ( La = 0 ; La < d ; ++ La , a += w ) if ( La === y && ( a = 0 ) , e [ La ] ) for ( W = La * Ka , mb = 0 ; mb < c ; ++ mb , a += 2 , W += bb ) { var Ua = b [ a ] ; var Aa = b [ a | 1 ] ; var Va = n ? Aa & 8 ? l : m : l ; var ia = u [ Aa >>
4 & p ] ; Aa = u [ Aa & 15 ] ; M !== ia && ( M = ia , ka = M >> 16 , Ga = M >> 8 & 255 , Ha = M & 255 ) ; x !== Aa && ( x = Aa , O = x >> 16 , U = x >> 8 & 255 , Y = x & 255 ) ; ia = q && C === W ; Aa = ( Va + Ua ) * h ; for ( Ua = W + Ka ; W < Ua ; W += na ) for ( Va = W + K ; W < Va ; W += 4 ) g [ Aa ++ ] ? ( f [ W ] = O , f [ W + 1 ] = U , f [ W + 2 ] = Y ) : ( f [ W ] = ka , f [ W + 1 ] = Ga , f [ W + 2 ] = Ha ) ; if ( ia ) for ( ia = C + r * V , Ua = ia + D * V ; ia < Ua ; ia += na ) for ( Va = ia + K ; ia < Va ; ia += 4 ) f [ ia ] = O , f [ ia + 1 ] = U , f [ ia + 2 ] = Y } else a += F } ; wa . prototype . mark _dirty = function ( ) { this . txt _row _dirty . fill ( 1 ) ; this . txt _dirty = 1 } ;
wa . prototype . invalidate _row = function ( a ) { 0 <= a && a < this . txt _height && ( this . txt _row _dirty [ a ] = this . txt _dirty = 1 ) } ; wa . prototype . invalidate _font _shape = function ( ) { this . font _data _dirty = ! 0 } ;
wa . prototype . set _size = function ( a , b ) { 0 < a && 256 > a && 0 < b && 256 > b && ( this . txt _width = b , this . txt _height = a , this . gfx _width = this . txt _width * this . font _width , this . gfx _height = this . txt _height * this . font _height , this . txt _row _dirty = new Uint8Array ( this . txt _height ) , this . vga . screen . set _size _graphical ( this . gfx _width , this . gfx _height , this . gfx _width , this . gfx _height ) , this . mark _dirty ( ) , this . rebuild _image _data ( ) ) } ;
wa . prototype . set _character _map = function ( a ) { const b = [ 0 , 2 , 4 , 6 , 1 , 3 , 5 , 7 ] , c = b [ ( a & 12 ) >> 2 | ( a & 32 ) >> 3 ] ; a = b [ a & 3 | ( a & 16 ) >> 2 ] ; if ( this . font _index _A !== c || this . font _index _B !== a ) this . font _index _A = c , this . font _index _B = a , this . mark _dirty ( ) } ; wa . prototype . set _cursor _pos = function ( a , b ) { this . cursor _pos _dirty = ! 0 ; this . cursor _row _latch = a ; this . cursor _col _latch = b } ; wa . prototype . set _cursor _attr = function ( a , b , c ) { this . cursor _attr _dirty = ! 0 ; this . cursor _enabled _latch = ! ! c ; this . cursor _top _latch = a ; this . cursor _bottom _latch = b } ;
wa . prototype . render = function ( ) { this . frame _count = this . frame _count + 1 >>> 0 ; const a = this . vga . clocking _mode & 9 , b = this . vga . attribute _mode & 12 , c = this . vga . max _scan _line & 159 ; if ( this . font _data _dirty || this . vga _clocking _mode !== a || this . vga _attribute _mode !== b || this . vga _max _scan _line !== c ) { const d = ! ( a & 1 ) , e = ! ! ( a & 8 ) , f = ( d ? 9 : 8 ) * ( e ? 2 : 1 ) , g = ! ! ( b & 4 ) , h = ( c & 31 ) + 1 , l = this . font _data _dirty || this . font _lge !== g , m = this . font _width !== f || this . font _height !== h ; this . font _data _dirty = ! 1 ; this . font _width = f ; this . font _height = h ; this . font _blink _enabled =
! ! ( b & 8 ) ; this . font _lge = g ; this . vga _clocking _mode = a ; this . vga _attribute _mode = b ; this . vga _max _scan _line = c ; if ( l || m ) m && ( this . gfx _width = this . txt _width * this . font _width , this . gfx _height = this . txt _height * this . font _height , this . rebuild _image _data ( ) ) , this . font _bitmap = this . rebuild _font _bitmap ( d , e ) ; this . mark _dirty ( ) } this . cursor _pos _dirty && ( this . cursor _pos _dirty = ! 1 , this . cursor _row _latch = Math . min ( this . cursor _row _latch , this . txt _height - 1 ) , this . cursor _col _latch = Math . min ( this . cursor _col _latch , this . txt _width - 1 ) , this . cursor _row !==
this . cursor _row _latch || this . cursor _col !== this . cursor _col _latch ) && ( this . txt _row _dirty [ this . cursor _row ] = this . txt _row _dirty [ this . cursor _row _latch ] = this . txt _dirty = 1 , this . cursor _row = this . cursor _row _latch , this . cursor _col = this . cursor _col _latch ) ; this . cursor _attr _dirty && ( this . cursor _attr _dirty = ! 1 , this . cursor _enabled !== this . cursor _enabled _latch || this . cursor _top !== this . cursor _top _latch || this . cursor _bottom !== this . cursor _bottom _latch ) && ( this . cursor _enabled = this . cursor _enabled _latch , this . cursor _top = this . cursor _top _latch ,
this . cursor _bottom = this . cursor _bottom _latch , this . txt _row _dirty [ this . cursor _row ] = this . txt _dirty = 1 ) ; this . txt _dirty && ( this . render _dirty _rows ( ) , this . txt _dirty = 0 , this . txt _row _dirty . fill ( 0 ) ) ; return this . image _data } ; function xa ( a , b ) { this . cpu = a ; this . bus = b ; this . use _mouse = this . enable _mouse _stream = ! 1 ; this . have _mouse = ! 0 ; this . mouse _clicks = this . mouse _delta _y = this . mouse _delta _x = 0 ; this . have _keyboard = ! 0 ; this . next _read _resolution = this . next _read _rate = this . next _handle _scan _code _set = this . next _read _led = this . next _read _sample = this . next _is _mouse _command = this . enable _keyboard _stream = ! 1 ; this . kbd _buffer = new ja ( 1024 ) ; this . last _port60 _byte = 0 ; this . sample _rate = 100 ; this . mouse _id = this . mouse _detect _state = 0 ; this . mouse _reset _workaround = ! 1 ;
this . wheel _movement = 0 ; this . resolution = 4 ; this . scaling2 = ! 1 ; this . last _mouse _packet = - 1 ; this . mouse _buffer = new ja ( 1024 ) ; this . next _byte _is _aux = this . next _byte _is _ready = ! 1 ; this . bus . register ( "keyboard-code" , function ( c ) { this . kbd _send _code ( c ) } , this ) ; this . bus . register ( "mouse-click" , function ( c ) { this . mouse _send _click ( c [ 0 ] , c [ 1 ] , c [ 2 ] ) } , this ) ; this . bus . register ( "mouse-delta" , function ( c ) { this . mouse _send _delta ( c [ 0 ] , c [ 1 ] ) } , this ) ; this . bus . register ( "mouse-wheel" , function ( c ) { this . wheel _movement -= c [ 0 ] ; this . wheel _movement -=
2024-06-28 09:23:02 +02:00
2 * c [ 1 ] ; this . wheel _movement = Math . min ( 7 , Math . max ( - 8 , this . wheel _movement ) ) ; this . send _mouse _packet ( 0 , 0 ) } , this ) ; this . command _register = 5 ; this . controller _output _port = 0 ; this . read _controller _output _port = this . read _command _register = this . read _output _register = ! 1 ; a . io . register _read ( 96 , this , this . port60 _read ) ; a . io . register _read ( 100 , this , this . port64 _read ) ; a . io . register _write ( 96 , this , this . port60 _write ) ; a . io . register _write ( 100 , this , this . port64 _write ) }
2024-10-02 21:03:04 +02:00
xa . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . enable _mouse _stream ; a [ 1 ] = this . use _mouse ; a [ 2 ] = this . have _mouse ; a [ 3 ] = this . mouse _delta _x ; a [ 4 ] = this . mouse _delta _y ; a [ 5 ] = this . mouse _clicks ; a [ 6 ] = this . have _keyboard ; a [ 7 ] = this . enable _keyboard _stream ; a [ 8 ] = this . next _is _mouse _command ; a [ 9 ] = this . next _read _sample ; a [ 10 ] = this . next _read _led ; a [ 11 ] = this . next _handle _scan _code _set ; a [ 12 ] = this . next _read _rate ; a [ 13 ] = this . next _read _resolution ; a [ 15 ] = this . last _port60 _byte ; a [ 16 ] = this . sample _rate ; a [ 17 ] = this . resolution ; a [ 18 ] = this . scaling2 ;
2024-06-28 09:23:02 +02:00
a [ 20 ] = this . command _register ; a [ 21 ] = this . read _output _register ; a [ 22 ] = this . read _command _register ; a [ 23 ] = this . controller _output _port ; a [ 24 ] = this . read _controller _output _port ; a [ 25 ] = this . mouse _id ; a [ 26 ] = this . mouse _detect _state ; a [ 27 ] = this . mouse _reset _workaround ; return a } ;
2024-10-02 21:03:04 +02:00
xa . prototype . set _state = function ( a ) { this . enable _mouse _stream = a [ 0 ] ; this . use _mouse = a [ 1 ] ; this . have _mouse = a [ 2 ] ; this . mouse _delta _x = a [ 3 ] ; this . mouse _delta _y = a [ 4 ] ; this . mouse _clicks = a [ 5 ] ; this . have _keyboard = a [ 6 ] ; this . enable _keyboard _stream = a [ 7 ] ; this . next _is _mouse _command = a [ 8 ] ; this . next _read _sample = a [ 9 ] ; this . next _read _led = a [ 10 ] ; this . next _handle _scan _code _set = a [ 11 ] ; this . next _read _rate = a [ 12 ] ; this . next _read _resolution = a [ 13 ] ; this . last _port60 _byte = a [ 15 ] ; this . sample _rate = a [ 16 ] ; this . resolution = a [ 17 ] ; this . scaling2 = a [ 18 ] ;
2024-06-28 09:23:02 +02:00
this . command _register = a [ 20 ] ; this . read _output _register = a [ 21 ] ; this . read _command _register = a [ 22 ] ; this . controller _output _port = a [ 23 ] ; this . read _controller _output _port = a [ 24 ] ; this . mouse _id = a [ 25 ] || 0 ; this . mouse _detect _state = a [ 26 ] || 0 ; this . mouse _reset _workaround = a [ 27 ] || ! 1 ; this . next _byte _is _aux = this . next _byte _is _ready = ! 1 ; this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ; this . bus . send ( "mouse-enable" , this . use _mouse ) } ;
2024-10-02 21:03:04 +02:00
xa . prototype . raise _irq = function ( ) { this . next _byte _is _ready || ( this . kbd _buffer . length ? this . kbd _irq ( ) : this . mouse _buffer . length && this . mouse _irq ( ) ) } ; xa . prototype . mouse _irq = function ( ) { this . next _byte _is _aux = this . next _byte _is _ready = ! 0 ; this . command _register & 2 && ( this . cpu . device _lower _irq ( 12 ) , this . cpu . device _raise _irq ( 12 ) ) } ; xa . prototype . kbd _irq = function ( ) { this . next _byte _is _ready = ! 0 ; this . next _byte _is _aux = ! 1 ; this . command _register & 1 && ( this . cpu . device _lower _irq ( 1 ) , this . cpu . device _raise _irq ( 1 ) ) } ;
xa . prototype . kbd _send _code = function ( a ) { this . enable _keyboard _stream && ( A ( a ) , this . kbd _buffer . push ( a ) , this . raise _irq ( ) ) } ; xa . prototype . mouse _send _delta = function ( a , b ) { if ( this . have _mouse && this . use _mouse ) { var c = this . resolution * this . sample _rate / 80 ; this . mouse _delta _x += a * c ; this . mouse _delta _y += b * c ; this . enable _mouse _stream && ( a = this . mouse _delta _x | 0 , b = this . mouse _delta _y | 0 , a || b ) && ( Date . now ( ) , this . mouse _delta _x -= a , this . mouse _delta _y -= b , this . send _mouse _packet ( a , b ) ) } } ;
xa . prototype . mouse _send _click = function ( a , b , c ) { this . have _mouse && this . use _mouse && ( this . mouse _clicks = a | c << 1 | b << 2 , this . enable _mouse _stream && this . send _mouse _packet ( 0 , 0 ) ) } ;
xa . prototype . send _mouse _packet = function ( a , b ) { var c = ( 0 > b ) << 5 | ( 0 > a ) << 4 | 8 | this . mouse _clicks ; this . last _mouse _packet = Date . now ( ) ; this . mouse _buffer . push ( c ) ; this . mouse _buffer . push ( a ) ; this . mouse _buffer . push ( b ) ; 4 === this . mouse _id ? ( this . mouse _buffer . push ( 0 | this . wheel _movement & 15 ) , this . wheel _movement = 0 ) : 3 === this . mouse _id && ( this . mouse _buffer . push ( this . wheel _movement & 255 ) , this . wheel _movement = 0 ) ; this . raise _irq ( ) } ;
xa . prototype . apply _scaling2 = function ( a ) { var b = a >> 31 ; switch ( Math . abs ( a ) ) { case 0 : case 1 : case 3 : return a ; case 2 : return b ; case 4 : return 6 * b ; case 5 : return 9 * b ; default : return a << 1 } } ;
xa . prototype . port60 _read = function ( ) { this . next _byte _is _ready = ! 1 ; if ( ! this . kbd _buffer . length && ! this . mouse _buffer . length ) return this . last _port60 _byte ; this . next _byte _is _aux ? ( this . cpu . device _lower _irq ( 12 ) , this . last _port60 _byte = this . mouse _buffer . shift ( ) ) : ( this . cpu . device _lower _irq ( 1 ) , this . last _port60 _byte = this . kbd _buffer . shift ( ) ) ; A ( this . last _port60 _byte ) ; ( this . kbd _buffer . length || this . mouse _buffer . length ) && this . raise _irq ( ) ; return this . last _port60 _byte } ;
xa . prototype . port64 _read = function ( ) { var a = 16 ; this . next _byte _is _ready && ( a |= 1 ) ; this . next _byte _is _aux && ( a |= 32 ) ; A ( a ) ; return a } ;
xa . prototype . port60 _write = function ( a ) { A ( a ) ; if ( this . read _command _register ) this . command _register = a , this . read _command _register = ! 1 , A ( this . command _register ) ; else if ( this . read _output _register ) this . read _output _register = ! 1 , this . mouse _buffer . clear ( ) , this . mouse _buffer . push ( a ) , this . mouse _irq ( ) ; else if ( this . next _read _sample ) { this . next _read _sample = ! 1 ; this . mouse _buffer . clear ( ) ; this . mouse _buffer . push ( 250 ) ; this . sample _rate = a ; switch ( this . mouse _detect _state ) { case - 1 : 60 === a ? ( this . mouse _reset _workaround = ! 0 , this . mouse _detect _state =
2024-06-28 09:23:02 +02:00
0 ) : ( this . mouse _reset _workaround = ! 1 , this . mouse _detect _state = 200 === a ? 1 : 0 ) ; break ; case 0 : 200 === a && ( this . mouse _detect _state = 1 ) ; break ; case 1 : this . mouse _detect _state = 100 === a ? 2 : 200 === a ? 3 : 0 ; break ; case 2 : 80 === a && ( this . mouse _id = 3 ) ; this . mouse _detect _state = - 1 ; break ; case 3 : 80 === a && ( this . mouse _id = 4 ) , this . mouse _detect _state = - 1 } A ( a ) ; A ( this . mouse _id ) ; this . sample _rate || ( this . sample _rate = 100 ) ; this . mouse _irq ( ) } else if ( this . next _read _resolution ) this . next _read _resolution = ! 1 , this . mouse _buffer . clear ( ) , this . mouse _buffer . push ( 250 ) ,
this . resolution = 3 < a ? 4 : 1 << a , this . mouse _irq ( ) ; else if ( this . next _read _led ) this . next _read _led = ! 1 , this . kbd _buffer . push ( 250 ) , this . kbd _irq ( ) ; else if ( this . next _handle _scan _code _set ) this . next _handle _scan _code _set = ! 1 , this . kbd _buffer . push ( 250 ) , this . kbd _irq ( ) , a || this . kbd _buffer . push ( 1 ) ; else if ( this . next _read _rate ) this . next _read _rate = ! 1 , this . kbd _buffer . push ( 250 ) , this . kbd _irq ( ) ; else if ( this . next _is _mouse _command ) { if ( this . next _is _mouse _command = ! 1 , A ( a ) , this . have _mouse ) { this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ;
this . mouse _buffer . push ( 250 ) ; switch ( a ) { case 230 : this . scaling2 = ! 1 ; break ; case 231 : this . scaling2 = ! 0 ; break ; case 232 : this . next _read _resolution = ! 0 ; break ; case 233 : this . send _mouse _packet ( 0 , 0 ) ; break ; case 235 : this . send _mouse _packet ( 0 , 0 ) ; break ; case 242 : A ( this . mouse _id ) ; this . mouse _buffer . push ( this . mouse _id ) ; this . mouse _clicks = this . mouse _delta _x = this . mouse _delta _y = 0 ; this . raise _irq ( ) ; break ; case 243 : this . next _read _sample = ! 0 ; break ; case 244 : this . use _mouse = this . enable _mouse _stream = ! 0 ; this . bus . send ( "mouse-enable" , ! 0 ) ;
this . mouse _clicks = this . mouse _delta _x = this . mouse _delta _y = 0 ; break ; case 245 : this . enable _mouse _stream = ! 1 ; break ; case 246 : this . enable _mouse _stream = ! 1 ; this . sample _rate = 100 ; this . scaling2 = ! 1 ; this . resolution = 4 ; break ; case 255 : this . mouse _buffer . push ( 170 ) ; this . mouse _buffer . push ( 0 ) ; this . use _mouse = ! 0 ; this . bus . send ( "mouse-enable" , ! 0 ) ; this . enable _mouse _stream = ! 1 ; this . sample _rate = 100 ; this . scaling2 = ! 1 ; this . resolution = 4 ; this . mouse _reset _workaround || ( this . mouse _id = 0 ) ; this . mouse _clicks = this . mouse _delta _x = this . mouse _delta _y =
0 ; break ; default : A ( a ) } this . mouse _irq ( ) } } else if ( this . read _controller _output _port ) this . read _controller _output _port = ! 1 , this . controller _output _port = a ; else { A ( a ) ; this . mouse _buffer . clear ( ) ; this . kbd _buffer . clear ( ) ; this . kbd _buffer . push ( 250 ) ; switch ( a ) { case 237 : this . next _read _led = ! 0 ; break ; case 240 : this . next _handle _scan _code _set = ! 0 ; break ; case 242 : this . kbd _buffer . push ( 171 ) ; this . kbd _buffer . push ( 131 ) ; break ; case 243 : this . next _read _rate = ! 0 ; break ; case 244 : this . enable _keyboard _stream = ! 0 ; break ; case 245 : this . enable _keyboard _stream =
! 1 ; break ; case 246 : break ; case 255 : this . kbd _buffer . clear ( ) ; this . kbd _buffer . push ( 250 ) ; this . kbd _buffer . push ( 170 ) ; this . kbd _buffer . push ( 0 ) ; break ; default : A ( a ) } this . kbd _irq ( ) } } ;
2024-10-02 21:03:04 +02:00
xa . prototype . port64 _write = function ( a ) { A ( a ) ; switch ( a ) { case 32 : this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ; this . kbd _buffer . push ( this . command _register ) ; this . kbd _irq ( ) ; break ; case 96 : this . read _command _register = ! 0 ; break ; case 209 : this . read _controller _output _port = ! 0 ; break ; case 211 : this . read _output _register = ! 0 ; break ; case 212 : this . next _is _mouse _command = ! 0 ; break ; case 167 : this . command _register |= 32 ; break ; case 168 : this . command _register &= - 33 ; break ; case 169 : this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ;
this . kbd _buffer . push ( 0 ) ; this . kbd _irq ( ) ; break ; case 170 : this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ; this . kbd _buffer . push ( 85 ) ; this . kbd _irq ( ) ; break ; case 171 : this . kbd _buffer . clear ( ) ; this . mouse _buffer . clear ( ) ; this . kbd _buffer . push ( 0 ) ; this . kbd _irq ( ) ; break ; case 173 : this . command _register |= 16 ; break ; case 174 : this . command _register &= - 17 ; break ; case 254 : this . cpu . reboot _internal ( ) ; break ; default : A ( a ) } } ; function ya ( a ) { this . cpu = a ; this . cmos _index = 0 ; this . cmos _data = new Uint8Array ( 128 ) ; this . last _update = this . rtc _time = Date . now ( ) ; this . next _interrupt _alarm = this . next _interrupt = 0 ; this . periodic _interrupt = ! 1 ; this . periodic _interrupt _time = . 9765625 ; this . cmos _a = 38 ; this . cmos _b = 2 ; this . nmi _disabled = this . cmos _c = 0 ; a . io . register _write ( 112 , this , function ( b ) { this . cmos _index = b & 127 ; this . nmi _disabled = b >> 7 } ) ; a . io . register _write ( 113 , this , this . cmos _port _write ) ; a . io . register _read ( 113 , this , this . cmos _port _read ) }
ya . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . cmos _index ; a [ 1 ] = this . cmos _data ; a [ 2 ] = this . rtc _time ; a [ 3 ] = this . last _update ; a [ 4 ] = this . next _interrupt ; a [ 5 ] = this . next _interrupt _alarm ; a [ 6 ] = this . periodic _interrupt ; a [ 7 ] = this . periodic _interrupt _time ; a [ 8 ] = this . cmos _a ; a [ 9 ] = this . cmos _b ; a [ 10 ] = this . cmos _c ; a [ 11 ] = this . nmi _disabled ; return a } ;
ya . prototype . set _state = function ( a ) { this . cmos _index = a [ 0 ] ; this . cmos _data = a [ 1 ] ; this . rtc _time = a [ 2 ] ; this . last _update = a [ 3 ] ; this . next _interrupt = a [ 4 ] ; this . next _interrupt _alarm = a [ 5 ] ; this . periodic _interrupt = a [ 6 ] ; this . periodic _interrupt _time = a [ 7 ] ; this . cmos _a = a [ 8 ] ; this . cmos _b = a [ 9 ] ; this . cmos _c = a [ 10 ] ; this . nmi _disabled = a [ 11 ] } ;
ya . prototype . timer = function ( a ) { a = Date . now ( ) ; this . rtc _time += a - this . last _update ; this . last _update = a ; this . periodic _interrupt && this . next _interrupt < a ? ( this . cpu . device _raise _irq ( 8 ) , this . cmos _c |= 192 , this . next _interrupt += this . periodic _interrupt _time * Math . ceil ( ( a - this . next _interrupt ) / this . periodic _interrupt _time ) ) : this . next _interrupt _alarm && this . next _interrupt _alarm < a && ( this . cpu . device _raise _irq ( 8 ) , this . cmos _c |= 160 , this . next _interrupt _alarm = 0 ) ; let b = 100 ; this . periodic _interrupt && this . next _interrupt && ( b = Math . min ( b ,
Math . max ( 0 , this . next _interrupt - a ) ) ) ; this . next _interrupt _alarm && ( b = Math . min ( b , Math . max ( 0 , this . next _interrupt _alarm - a ) ) ) ; return b } ; ya . prototype . bcd _pack = function ( a ) { for ( var b = 0 , c = 0 , d ; a ; ) d = a % 10 , c |= d << 4 * b , b ++ , a = ( a - d ) / 10 ; return c } ; ya . prototype . bcd _unpack = function ( a ) { return ( a & 15 ) + 10 * ( a >> 4 & 15 ) } ; ya . prototype . encode _time = function ( a ) { return this . cmos _b & 4 ? a : this . bcd _pack ( a ) } ; ya . prototype . decode _time = function ( a ) { return this . cmos _b & 4 ? a : this . bcd _unpack ( a ) } ;
ya . prototype . cmos _port _read = function ( ) { var a = this . cmos _index ; switch ( a ) { case 0 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCSeconds ( ) ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCSeconds ( ) ) ; case 2 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCMinutes ( ) ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCMinutes ( ) ) ; case 4 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCHours ( ) ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCHours ( ) ) ; case 6 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCDay ( ) +
1 ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCDay ( ) + 1 ) ; case 7 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCDate ( ) ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCDate ( ) ) ; case 8 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCMonth ( ) + 1 ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCMonth ( ) + 1 ) ; case 9 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCFullYear ( ) % 100 ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCFullYear ( ) % 100 ) ; case 10 : return 999 <= E . microtick ( ) %
1E3 ? this . cmos _a | 128 : this . cmos _a ; case 11 : return this . cmos _b ; case 12 : return this . cpu . device _lower _irq ( 8 ) , a = this . cmos _c , this . cmos _c &= - 241 , a ; case 13 : return 0 ; case 50 : case 55 : return A ( this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCFullYear ( ) / 100 | 0 ) ) , this . encode _time ( ( new Date ( this . rtc _time ) ) . getUTCFullYear ( ) / 100 | 0 ) ; default : return A ( a ) , this . cmos _data [ this . cmos _index ] } } ;
ya . prototype . cmos _port _write = function ( a ) { switch ( this . cmos _index ) { case 10 : this . cmos _a = a & 127 ; this . periodic _interrupt _time = 1E3 / ( 32768 >> ( this . cmos _a & 15 ) - 1 ) ; A ( this . cmos _a , 2 ) ; break ; case 11 : this . cmos _b = a ; this . cmos _b & 64 && ( this . next _interrupt = Date . now ( ) ) ; if ( this . cmos _b & 32 ) { a = new Date ; const b = this . decode _time ( this . cmos _data [ 1 ] ) , c = this . decode _time ( this . cmos _data [ 3 ] ) , d = this . decode _time ( this . cmos _data [ 5 ] ) ; this . next _interrupt _alarm = + new Date ( Date . UTC ( a . getUTCFullYear ( ) , a . getUTCMonth ( ) , a . getUTCDate ( ) , d , c , b ) ) } A ( this . cmos _b ,
2 ) ; break ; case 1 : case 3 : case 5 : this . cmos _write ( this . cmos _index , a ) ; break ; default : A ( this . cmos _index ) , A ( a ) } this . periodic _interrupt = 64 === ( this . cmos _b & 64 ) && 0 < ( this . cmos _a & 15 ) } ; ya . prototype . cmos _read = function ( a ) { return this . cmos _data [ a ] } ; ya . prototype . cmos _write = function ( a , b ) { A ( a ) ; A ( b ) ; this . cmos _data [ a ] = b } ; function za ( a , b , c ) { this . bus = c ; this . cpu = a ; this . ints = 4 ; this . line _control = this . baud _rate = 0 ; this . lsr = 96 ; this . ier = this . fifo _control = 0 ; this . iir = 1 ; this . irq = this . scratch _register = this . modem _status = this . modem _control = 0 ; this . input = [ ] ; this . current _line = "" ; switch ( b ) { case 1016 : this . com = 0 ; this . irq = 4 ; break ; case 760 : this . com = 1 ; this . irq = 3 ; break ; case 1E3 : this . com = 2 ; this . irq = 4 ; break ; case 744 : this . irq = this . com = 3 ; break ; default : qa ( "Invalid serial port: " + A ( b ) , 16384 ) , this . com = 0 , this . irq = 4 } this . bus . register ( "serial" + this . com +
2024-06-28 09:23:02 +02:00
"-input" , function ( d ) { this . data _received ( d ) } , this ) ; this . bus . register ( "serial" + this . com + "-modem-status-input" , function ( d ) { this . set _modem _status ( d ) } , this ) ; this . bus . register ( "serial" + this . com + "-carrier-detect-input" , function ( d ) { this . set _modem _status ( d ? this . modem _status | 136 : this . modem _status & - 137 ) } , this ) ; this . bus . register ( "serial" + this . com + "-ring-indicator-input" , function ( d ) { this . set _modem _status ( d ? this . modem _status | 68 : this . modem _status & - 69 ) } , this ) ; this . bus . register ( "serial" + this . com + "-data-set-ready-input" ,
function ( d ) { this . set _modem _status ( d ? this . modem _status | 34 : this . modem _status & - 35 ) } , this ) ; this . bus . register ( "serial" + this . com + "-clear-to-send-input" , function ( d ) { this . set _modem _status ( d ? this . modem _status | 17 : this . modem _status & - 18 ) } , this ) ; a = a . io ; a . register _write ( b , this , function ( d ) { this . write _data ( d ) } , function ( d ) { this . write _data ( d & 255 ) ; this . write _data ( d >> 8 ) } ) ; a . register _write ( b | 1 , this , function ( d ) { this . line _control & 128 ? ( this . baud _rate = this . baud _rate & 255 | d << 8 , A ( this . baud _rate ) ) : ( 0 === ( this . ier & 2 ) && d & 2 && this . ThrowInterrupt ( 2 ) ,
2024-10-02 21:03:04 +02:00
this . ier = d & 15 , A ( d ) , this . CheckInterrupt ( ) ) } ) ; a . register _read ( b , this , function ( ) { if ( this . line _control & 128 ) return this . baud _rate & 255 ; let d = 0 ; 0 !== this . input . length && ( d = this . input . shift ( ) , A ( d ) ) ; 0 === this . input . length && ( this . lsr &= - 2 , this . ClearInterrupt ( 12 ) , this . ClearInterrupt ( 4 ) ) ; return d } ) ; a . register _read ( b | 1 , this , function ( ) { return this . line _control & 128 ? this . baud _rate >> 8 : this . ier & 15 } ) ; a . register _read ( b | 2 , this , function ( ) { var d = this . iir & 15 ; A ( this . iir ) ; 2 === this . iir && this . ClearInterrupt ( 2 ) ; this . fifo _control &
2024-06-28 09:23:02 +02:00
1 && ( d |= 192 ) ; return d } ) ; a . register _write ( b | 2 , this , function ( d ) { A ( d ) ; this . fifo _control = d } ) ; a . register _read ( b | 3 , this , function ( ) { A ( this . line _control ) ; return this . line _control } ) ; a . register _write ( b | 3 , this , function ( d ) { A ( d ) ; this . line _control = d } ) ; a . register _read ( b | 4 , this , function ( ) { return this . modem _control } ) ; a . register _write ( b | 4 , this , function ( d ) { A ( d ) ; this . modem _control = d } ) ; a . register _read ( b | 5 , this , function ( ) { A ( this . lsr ) ; return this . lsr } ) ; a . register _write ( b | 5 , this , function ( ) { } ) ; a . register _read ( b | 6 , this , function ( ) { A ( this . modem _status ) ;
2024-10-02 21:03:04 +02:00
return this . modem _status &= 240 } ) ; a . register _write ( b | 6 , this , function ( d ) { A ( d ) ; this . set _modem _status ( d ) } ) ; a . register _read ( b | 7 , this , function ( ) { return this . scratch _register } ) ; a . register _write ( b | 7 , this , function ( d ) { this . scratch _register = d } ) } za . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . ints ; a [ 1 ] = this . baud _rate ; a [ 2 ] = this . line _control ; a [ 3 ] = this . lsr ; a [ 4 ] = this . fifo _control ; a [ 5 ] = this . ier ; a [ 6 ] = this . iir ; a [ 7 ] = this . modem _control ; a [ 8 ] = this . modem _status ; a [ 9 ] = this . scratch _register ; a [ 10 ] = this . irq ; return a } ;
za . prototype . set _state = function ( a ) { this . ints = a [ 0 ] ; this . baud _rate = a [ 1 ] ; this . line _control = a [ 2 ] ; this . lsr = a [ 3 ] ; this . fifo _control = a [ 4 ] ; this . ier = a [ 5 ] ; this . iir = a [ 6 ] ; this . modem _control = a [ 7 ] ; this . modem _status = a [ 8 ] ; this . scratch _register = a [ 9 ] ; this . irq = a [ 10 ] } ;
za . prototype . CheckInterrupt = function ( ) { this . ints & 4096 && this . ier & 1 ? ( this . iir = 12 , this . cpu . device _raise _irq ( this . irq ) ) : this . ints & 16 && this . ier & 1 ? ( this . iir = 4 , this . cpu . device _raise _irq ( this . irq ) ) : this . ints & 4 && this . ier & 2 ? ( this . iir = 2 , this . cpu . device _raise _irq ( this . irq ) ) : this . ints & 1 && this . ier & 8 ? ( this . iir = 0 , this . cpu . device _raise _irq ( this . irq ) ) : ( this . iir = 1 , this . cpu . device _lower _irq ( this . irq ) ) } ; za . prototype . ThrowInterrupt = function ( a ) { this . ints |= 1 << a ; this . CheckInterrupt ( ) } ;
za . prototype . ClearInterrupt = function ( a ) { this . ints &= ~ ( 1 << a ) ; this . CheckInterrupt ( ) } ; za . prototype . data _received = function ( a ) { A ( a ) ; this . input . push ( a ) ; this . lsr |= 1 ; this . fifo _control & 1 ? this . ThrowInterrupt ( 12 ) : this . ThrowInterrupt ( 4 ) } ; za . prototype . write _data = function ( a ) { this . line _control & 128 ? this . baud _rate = this . baud _rate & - 256 | a : ( A ( a ) , this . ThrowInterrupt ( 2 ) , this . bus . send ( "serial" + this . com + "-output-byte" , a ) ) } ;
za . prototype . set _modem _status = function ( a ) { A ( a ) ; const b = this . modem _status & 15 ; let c = ( this . modem _status ^ a ) >> 4 ; this . modem _status = a ; this . modem _status = this . modem _status | c | b } ; function Ba ( a ) { this . cpu = a ; var b = a . io ; a . devices . pci . register _device ( { pci _id : 56 , pci _space : [ 134 , 128 , 19 , 113 , 7 , 0 , 128 , 2 , 8 , 0 , 128 , 6 , 0 , 0 , 128 , 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 , 9 , 1 , 0 , 0 ] , pci _bars : [ ] , name : "acpi" } ) ; this . timer _imprecision _offset = this . timer _last _value = 0 ; this . status = 1 ; this . pm1 _enable = this . pm1 _status = 0 ; this . last _timer = this . get _timer ( E . microtick ( ) ) ; this . gpe = new Uint8Array ( 4 ) ; b . register _read ( 45056 , this , void 0 , function ( ) { return this . pm1 _status } ) ;
b . register _write ( 45056 , this , void 0 , function ( c ) { A ( c , 4 ) ; this . pm1 _status &= ~ c } ) ; b . register _read ( 45058 , this , void 0 , function ( ) { return this . pm1 _enable } ) ; b . register _write ( 45058 , this , void 0 , function ( c ) { A ( c ) ; this . pm1 _enable = c } ) ; b . register _read ( 45060 , this , void 0 , function ( ) { return this . status } ) ; b . register _write ( 45060 , this , void 0 , function ( c ) { A ( c ) ; this . status = c } ) ; b . register _read ( 45064 , this , void 0 , void 0 , function ( ) { return this . get _timer ( E . microtick ( ) ) & 16777215 } ) ; b . register _read ( 45024 , this , function ( ) { return this . gpe [ 0 ] } ) ;
2024-06-28 09:23:02 +02:00
b . register _read ( 45025 , this , function ( ) { return this . gpe [ 1 ] } ) ; b . register _read ( 45026 , this , function ( ) { return this . gpe [ 2 ] } ) ; b . register _read ( 45027 , this , function ( ) { return this . gpe [ 3 ] } ) ; b . register _write ( 45024 , this , function ( c ) { A ( c ) ; this . gpe [ 0 ] = c } ) ; b . register _write ( 45025 , this , function ( c ) { A ( c ) ; this . gpe [ 1 ] = c } ) ; b . register _write ( 45026 , this , function ( c ) { A ( c ) ; this . gpe [ 2 ] = c } ) ; b . register _write ( 45027 , this , function ( c ) { A ( c ) ; this . gpe [ 3 ] = c } ) }
2024-10-02 21:03:04 +02:00
Ba . prototype . timer = function ( a ) { a = this . get _timer ( a ) ; var b = 0 !== ( ( a ^ this . last _timer ) & 8388608 ) ; this . pm1 _enable & 1 && b ? ( this . pm1 _status |= 1 , this . cpu . device _raise _irq ( 9 ) ) : this . cpu . device _lower _irq ( 9 ) ; this . last _timer = a ; return 100 } ;
Ba . prototype . get _timer = function ( a ) { a = Math . round ( 3579.545 * a ) ; a === this . timer _last _value ? 3579.545 > this . timer _imprecision _offset && this . timer _imprecision _offset ++ : this . timer _last _value + this . timer _imprecision _offset <= a && ( this . timer _imprecision _offset = 0 , this . timer _last _value = a ) ; return this . timer _last _value + this . timer _imprecision _offset } ; Ba . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . status ; a [ 1 ] = this . pm1 _status ; a [ 2 ] = this . pm1 _enable ; a [ 3 ] = this . gpe ; return a } ;
Ba . prototype . set _state = function ( a ) { this . status = a [ 0 ] ; this . pm1 _status = a [ 1 ] ; this . pm1 _enable = a [ 2 ] ; this . gpe = a [ 3 ] } ; function Ca ( a ) { this . cpu = a ; this . timer _divider = this . apic _id = 0 ; this . timer _divider _shift = 1 ; this . timer _current _count = this . timer _initial _count = 0 ; this . next _tick = E . microtick ( ) ; this . lvt _error = this . lvt _int1 = this . lvt _int0 = this . lvt _perf _counter = this . lvt _timer = 65536 ; this . icr1 = this . icr0 = this . tpr = 0 ; this . irr = new Int32Array ( 8 ) ; this . isr = new Int32Array ( 8 ) ; this . tmr = new Int32Array ( 8 ) ; this . spurious _vector = 254 ; this . destination _format = - 1 ; this . read _error = this . error = this . local _destination = 0 ; a . io . mmap _register ( 4276092928 , 1048576 ,
2024-06-28 09:23:02 +02:00
b => { A ( b >>> 0 ) ; var c = b & 3 ; return this . read32 ( b & - 4 ) >> 8 * c & 255 } , ( b , c ) => { A ( b ) ; A ( c ) } , b => this . read32 ( b ) , ( b , c ) => this . write32 ( b , c ) ) }
2024-10-02 21:03:04 +02:00
Ca . prototype . read32 = function ( a ) { a = a - 4276092928 | 0 ; switch ( a ) { case 32 : return this . apic _id ; case 48 : return 327700 ; case 128 : return this . tpr ; case 208 : return this . local _destination ; case 224 : return this . destination _format ; case 240 : return this . spurious _vector ; case 256 : case 272 : case 288 : case 304 : case 320 : case 336 : case 352 : case 368 : return a = a - 256 >> 4 , A ( this . isr [ a ] >>> 0 , 8 ) , this . isr [ a ] ; case 384 : case 400 : case 416 : case 432 : case 448 : case 464 : case 480 : case 496 : return a = a - 384 >> 4 , A ( this . tmr [ a ] >>> 0 , 8 ) , this . tmr [ a ] ; case 512 : case 528 : case 544 : case 560 : case 576 : case 592 : case 608 : case 624 : return a =
2024-06-28 09:23:02 +02:00
a - 512 >> 4 , A ( this . irr [ a ] >>> 0 , 8 ) , this . irr [ a ] ; case 640 : return A ( this . read _error >>> 0 , 8 ) , this . read _error ; case 768 : return this . icr0 ; case 784 : return this . icr1 ; case 800 : return this . lvt _timer ; case 832 : return this . lvt _perf _counter ; case 848 : return this . lvt _int0 ; case 864 : return this . lvt _int1 ; case 880 : return this . lvt _error ; case 992 : return this . timer _divider ; case 896 : return this . timer _initial _count ; case 912 : return A ( this . timer _current _count >>> 0 , 8 ) , this . timer _current _count ; default : return A ( a ) , 0 } } ;
2024-10-02 21:03:04 +02:00
Ca . prototype . write32 = function ( a , b ) { a = a - 4276092928 | 0 ; switch ( a ) { case 32 : A ( b >>> 8 , 8 ) ; this . apic _id = b ; break ; case 48 : A ( b >>> 0 , 8 ) ; break ; case 128 : this . tpr = b & 255 ; this . check _vector ( ) ; break ; case 176 : b = this . highest _isr ( ) ; - 1 !== b && ( this . register _clear _bit ( this . isr , b ) , this . register _get _bit ( this . tmr , b ) && this . cpu . devices . ioapic . remote _eoi ( b ) , this . check _vector ( ) ) ; break ; case 208 : A ( b >>> 0 , 8 ) ; this . local _destination = b & 4278190080 ; break ; case 224 : A ( b >>> 0 , 8 ) ; this . destination _format = b | 16777215 ; break ; case 240 : A ( b >>> 0 , 8 ) ; this . spurious _vector =
b ; break ; case 640 : A ( b >>> 0 , 8 ) ; this . read _error = this . error ; this . error = 0 ; break ; case 768 : a = b & 255 ; var c = b >> 8 & 7 , d = b >> 11 & 1 , e = b >> 15 & 1 , f = b >> 18 & 3 , g = this . icr1 >>> 24 ; A ( b , 8 ) ; A ( a , 2 ) ; this . icr0 = b & - 4097 ; 0 === f ? this . route ( a , c , e , g , d ) : 1 === f ? this . deliver ( a , 0 , e ) : 2 === f && this . deliver ( a , c , e ) ; break ; case 784 : A ( b >>> 0 , 8 ) ; this . icr1 = b ; break ; case 800 : A ( b >>> 0 , 8 ) ; this . lvt _timer = b ; break ; case 832 : A ( b >>> 0 , 8 ) ; this . lvt _perf _counter = b ; break ; case 848 : A ( b >>> 0 , 8 ) ; this . lvt _int0 = b ; break ; case 864 : A ( b >>> 0 , 8 ) ; this . lvt _int1 = b ; break ; case 880 : A ( b >>> 0 ,
8 ) ; this . lvt _error = b ; break ; case 992 : A ( b >>> 0 , 8 ) ; this . timer _divider = b ; b = b & 3 | ( b & 8 ) >> 1 ; this . timer _divider _shift = 7 === b ? 0 : b + 1 ; break ; case 896 : A ( b >>> 0 , 8 ) ; this . timer _initial _count = b >>> 0 ; this . timer _current _count = b >>> 0 ; this . next _tick = E . microtick ( ) ; this . timer _active = ! 0 ; break ; case 912 : A ( b >>> 0 , 8 ) ; break ; default : A ( a ) , A ( b >>> 0 , 8 ) } } ;
Ca . prototype . timer = function ( a ) { if ( 0 === this . timer _current _count ) return 100 ; const b = 1E6 / ( 1 << this . timer _divider _shift ) ; a = ( a - this . next _tick ) * b >>> 0 ; this . next _tick += a / b ; this . timer _current _count -= a ; 0 >= this . timer _current _count && ( a = this . lvt _timer & 393216 , 131072 === a ? ( this . timer _current _count %= this . timer _initial _count , 0 >= this . timer _current _count && ( this . timer _current _count += this . timer _initial _count ) , 0 === ( this . lvt _timer & 65536 ) && this . deliver ( this . lvt _timer & 255 , 0 , ! 1 ) ) : 0 === a && ( this . timer _current _count = 0 , 0 === ( this . lvt _timer &
65536 ) && this . deliver ( this . lvt _timer & 255 , 0 , ! 1 ) ) ) ; return Math . max ( 0 , this . timer _current _count / b ) } ; Ca . prototype . route = function ( a , b , c ) { this . deliver ( a , b , c ) } ; Ca . prototype . deliver = function ( a , b , c ) { 5 !== b && 4 !== b && ( this . register _get _bit ( this . irr , a ) ? A ( a , 2 ) : ( this . register _set _bit ( this . irr , a ) , c ? this . register _set _bit ( this . tmr , a ) : this . register _clear _bit ( this . tmr , a ) , this . check _vector ( ) ) ) } ; Ca . prototype . highest _irr = function ( ) { return this . register _get _highest _bit ( this . irr ) } ; Ca . prototype . highest _isr = function ( ) { return this . register _get _highest _bit ( this . isr ) } ;
Ca . prototype . check _vector = function ( ) { var a = this . highest _irr ( ) ; - 1 !== a && ( this . highest _isr ( ) >= a || ( a & 240 ) <= ( this . tpr & 240 ) || this . cpu . handle _irqs ( ) ) } ; Ca . prototype . acknowledge _irq = function ( ) { var a = this . highest _irr ( ) ; if ( - 1 === a || this . highest _isr ( ) >= a || ( a & 240 ) <= ( this . tpr & 240 ) ) return - 1 ; this . register _clear _bit ( this . irr , a ) ; this . register _set _bit ( this . isr , a ) ; this . check _vector ( ) ; return a } ;
Ca . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . apic _id ; a [ 1 ] = this . timer _divider ; a [ 2 ] = this . timer _divider _shift ; a [ 3 ] = this . timer _initial _count ; a [ 4 ] = this . timer _current _count ; a [ 5 ] = this . next _tick ; a [ 6 ] = this . lvt _timer ; a [ 7 ] = this . lvt _perf _counter ; a [ 8 ] = this . lvt _int0 ; a [ 9 ] = this . lvt _int1 ; a [ 10 ] = this . lvt _error ; a [ 11 ] = this . tpr ; a [ 12 ] = this . icr0 ; a [ 13 ] = this . icr1 ; a [ 14 ] = this . irr ; a [ 15 ] = this . isr ; a [ 16 ] = this . tmr ; a [ 17 ] = this . spurious _vector ; a [ 18 ] = this . destination _format ; a [ 19 ] = this . local _destination ; a [ 20 ] = this . error ; a [ 21 ] =
2024-06-28 09:23:02 +02:00
this . read _error ; return a } ;
2024-10-02 21:03:04 +02:00
Ca . prototype . set _state = function ( a ) { this . apic _id = a [ 0 ] ; this . timer _divider = a [ 1 ] ; this . timer _divider _shift = a [ 2 ] ; this . timer _initial _count = a [ 3 ] ; this . timer _current _count = a [ 4 ] ; this . next _tick = a [ 5 ] ; this . lvt _timer = a [ 6 ] ; this . lvt _perf _counter = a [ 7 ] ; this . lvt _int0 = a [ 8 ] ; this . lvt _int1 = a [ 9 ] ; this . lvt _error = a [ 10 ] ; this . tpr = a [ 11 ] ; this . icr0 = a [ 12 ] ; this . icr1 = a [ 13 ] ; this . irr = a [ 14 ] ; this . isr = a [ 15 ] ; this . tmr = a [ 16 ] ; this . spurious _vector = a [ 17 ] ; this . destination _format = a [ 18 ] ; this . local _destination = a [ 19 ] ; this . error = a [ 20 ] ; this . read _error =
a [ 21 ] } ; Ca . prototype . register _get _bit = function ( a , b ) { return a [ b >> 5 ] >> ( b & 31 ) & 1 } ; Ca . prototype . register _set _bit = function ( a , b ) { a [ b >> 5 ] |= 1 << ( b & 31 ) } ; Ca . prototype . register _clear _bit = function ( a , b ) { a [ b >> 5 ] &= ~ ( 1 << ( b & 31 ) ) } ; Ca . prototype . register _get _highest _bit = function ( a ) { for ( var b = 7 ; 0 <= b ; b -- ) { var c = a [ b ] ; if ( c ) return t . int _log2 ( c >>> 0 ) | b << 5 } return - 1 } ; function Da ( a ) { this . cpu = a ; this . ioredtbl _config = new Int32Array ( 24 ) ; this . ioredtbl _destination = new Int32Array ( 24 ) ; for ( var b = 0 ; b < this . ioredtbl _config . length ; b ++ ) this . ioredtbl _config [ b ] = 65536 ; this . irq _value = this . irr = this . ioapic _id = this . ioregsel = 0 ; a . io . mmap _register ( 4273995776 , 131072 , c => { c = c - 4273995776 | 0 ; if ( 16 <= c && 20 > c ) return c -= 16 , A ( this . ioregsel ) , this . read ( this . ioregsel ) >> 8 * c & 255 ; A ( c >>> 0 ) ; return 0 } , c => { A ( c >>> 0 ) } , c => { c = c - 4273995776 | 0 ; if ( 0 === c ) return this . ioregsel ; if ( 16 === c ) return this . read ( this . ioregsel ) ;
A ( c >>> 0 ) ; return 0 } , ( c , d ) => { c = c - 4273995776 | 0 ; 0 === c ? this . ioregsel = d : 16 === c ? this . write ( this . ioregsel , d ) : ( A ( c >>> 0 ) , A ( d >>> 0 , 8 ) ) } ) } Da . prototype . remote _eoi = function ( a ) { for ( var b = 0 ; 24 > b ; b ++ ) { var c = this . ioredtbl _config [ b ] ; ( c & 255 ) === a && c & 16384 && ( A ( b ) , this . ioredtbl _config [ b ] &= - 16385 , this . check _irq ( b ) ) } } ;
Da . prototype . check _irq = function ( a ) { var b = 1 << a ; if ( 0 !== ( this . irr & b ) ) { var c = this . ioredtbl _config [ a ] ; if ( 0 === ( c & 65536 ) ) { var d = c >> 8 & 7 , e = this . ioredtbl _destination [ a ] >>> 24 ; if ( 0 === ( c & 32768 ) ) this . irr &= ~ b ; else if ( this . ioredtbl _config [ a ] |= 16384 , c & 16384 ) return ; 0 !== d && 1 !== d || this . cpu . devices . apic . route ( c & 255 , d , 32768 === ( c & 32768 ) , e , c >> 11 & 1 ) ; this . ioredtbl _config [ a ] &= - 4097 } } } ;
Da . prototype . set _irq = function ( a ) { if ( ! ( 24 <= a ) ) { var b = 1 << a ; 0 === ( this . irq _value & b ) && ( this . irq _value |= b , 65536 !== ( this . ioredtbl _config [ a ] & 98304 ) && ( this . irr |= b , this . check _irq ( a ) ) ) } } ; Da . prototype . clear _irq = function ( a ) { if ( ! ( 24 <= a ) ) { var b = 1 << a ; ( this . irq _value & b ) === b && ( this . irq _value &= ~ b , this . ioredtbl _config [ a ] & 32768 && ( this . irr &= ~ b ) ) } } ;
Da . prototype . read = function ( a ) { if ( 0 === a ) return this . ioapic _id << 24 ; if ( 1 === a ) return 1507345 ; if ( 2 === a ) return this . ioapic _id << 24 ; if ( 16 <= a && 64 > a ) { var b = a - 16 >> 1 ; a = a & 1 ? this . ioredtbl _destination [ b ] : this . ioredtbl _config [ b ] ; A ( b ) ; A ( a , 8 ) ; return a } A ( a ) ; return 0 } ;
Da . prototype . write = function ( a , b ) { if ( 0 === a ) this . ioapic _id = b >>> 24 & 15 ; else if ( 1 !== a && 2 !== a ) if ( 16 <= a && 64 > a ) { var c = a - 16 >> 1 ; a & 1 ? ( this . ioredtbl _destination [ c ] = b & 4278190080 , A ( b >>> 0 , 8 ) , A ( c ) , A ( b >>> 24 , 2 ) ) : ( this . ioredtbl _config [ c ] = b & 110591 | this . ioredtbl _config [ c ] & - 110592 , a = b & 255 , A ( b >>> 0 , 8 ) , A ( c ) , A ( a , 2 ) , this . check _irq ( c ) ) } else A ( a ) , A ( b >>> 0 , 8 ) } ;
Da . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . ioredtbl _config ; a [ 1 ] = this . ioredtbl _destination ; a [ 2 ] = this . ioregsel ; a [ 3 ] = this . ioapic _id ; a [ 4 ] = this . irr ; a [ 5 ] = this . irq _value ; return a } ; Da . prototype . set _state = function ( a ) { this . ioredtbl _config = a [ 0 ] ; this . ioredtbl _destination = a [ 1 ] ; this . ioregsel = a [ 2 ] ; this . ioapic _id = a [ 3 ] ; this . irr = a [ 4 ] ; this . irq _value = a [ 5 ] } ; function Ea ( a ) { this . message = a } Ea . prototype = Error ( ) ; const Fa = { Uint8Array , Int8Array , Uint16Array , Int16Array , Uint32Array , Int32Array , Float32Array , Float64Array } ;
function Ia ( a , b ) { if ( "object" !== typeof a || null === a ) return a ; if ( a instanceof Array ) return a . map ( e => Ia ( e , b ) ) ; a . constructor === Object && console . log ( a ) ; if ( a . BYTES _PER _ELEMENT ) { var c = new Uint8Array ( a . buffer , a . byteOffset , a . length * a . BYTES _PER _ELEMENT ) ; return { _ _state _type _ _ : a . constructor . name . replace ( "bound " , "" ) , buffer _id : b . push ( c ) - 1 } } a = a . get _state ( ) ; c = [ ] ; for ( var d = 0 ; d < a . length ; d ++ ) c [ d ] = Ia ( a [ d ] , b ) ; return c }
function Ja ( a , b ) { if ( "object" !== typeof a || null === a ) return a ; if ( a instanceof Array ) { for ( let c = 0 ; c < a . length ; c ++ ) a [ c ] = Ja ( a [ c ] , b ) ; return a } return new Fa [ a . _ _state _type _ _ ] ( b [ a . buffer _id ] ) }
G . prototype . save _state = function ( ) { for ( var a = [ ] , b = Ia ( this , a ) , c = [ ] , d = 0 , e = 0 ; e < a . length ; e ++ ) { var f = a [ e ] . byteLength ; c [ e ] = { offset : d , length : f } ; d += f ; d = d + 3 & - 4 } e = JSON . stringify ( { buffer _infos : c , state : b } ) ; e = ( new TextEncoder ) . encode ( e ) ; b = 16 + e . length ; b = b + 3 & - 4 ; f = b + d ; d = new ArrayBuffer ( f ) ; var g = new Int32Array ( d , 0 , 4 ) ; ( new Uint8Array ( d , 16 , e . length ) ) . set ( e ) ; b = new Uint8Array ( d , b ) ; g [ 0 ] = - 2039052682 ; g [ 1 ] = 6 ; g [ 2 ] = f ; g [ 3 ] = e . length ; for ( e = 0 ; e < a . length ; e ++ ) b . set ( a [ e ] , c [ e ] . offset ) ; return d } ;
G . prototype . restore _state = function ( a ) { function b ( p , q ) { const r = p . length ; if ( 16 > r ) throw new Ea ( "Invalid length: " + r ) ; p = new Int32Array ( p . buffer , p . byteOffset , 4 ) ; if ( - 2039052682 !== p [ 0 ] ) throw new Ea ( "Invalid header: " + A ( p [ 0 ] >>> 0 ) ) ; if ( 6 !== p [ 1 ] ) throw new Ea ( "Version mismatch: dump=" + p [ 1 ] + " we=6" ) ; if ( q && p [ 2 ] !== r ) throw new Ea ( "Length doesn't match header: real=" + r + " header=" + p [ 2 ] ) ; return p [ 3 ] } function c ( p ) { p = ( new TextDecoder ) . decode ( p ) ; return JSON . parse ( p ) } a = new Uint8Array ( a ) ; if ( 4247762216 === ( new Uint32Array ( a . buffer ,
0 , 1 ) ) [ 0 ] ) { var d = this . zstd _create _ctx ( a . length ) ; ( new Uint8Array ( this . wasm _memory . buffer , this . zstd _get _src _ptr ( d ) , a . length ) ) . set ( a ) ; var e = this . zstd _read ( d , 16 ) , f = new Uint8Array ( this . wasm _memory . buffer , e , 16 ) , g = b ( f , ! 1 ) ; this . zstd _read _free ( e , 16 ) ; e = this . zstd _read ( d , g ) ; f = new Uint8Array ( this . wasm _memory . buffer , e , g ) ; f = c ( f ) ; this . zstd _read _free ( e , g ) ; e = f . state ; var h = f . buffer _infos ; f = [ ] ; g = 16 + g ; for ( var l of h ) { h = ( g + 3 & - 4 ) - g ; if ( 1048576 < l . length ) { var m = this . zstd _read ( d , h ) ; this . zstd _read _free ( m , h ) ; m = new Uint8Array ( l . length ) ;
f . push ( m . buffer ) ; for ( var n = 0 ; n < l . length ; ) { const p = Math . min ( l . length - n , 1048576 ) , q = this . zstd _read ( d , p ) ; m . set ( new Uint8Array ( this . wasm _memory . buffer , q , p ) , n ) ; this . zstd _read _free ( q , p ) ; n += p } } else m = this . zstd _read ( d , h + l . length ) , n = m + h , f . push ( this . wasm _memory . buffer . slice ( n , n + l . length ) ) , this . zstd _read _free ( m , h + l . length ) ; g += h + l . length } e = Ja ( e , f ) ; this . set _state ( e ) ; this . zstd _free _ctx ( d ) } else { d = b ( a , ! 0 ) ; if ( 0 > d || d + 12 >= a . length ) throw new Ea ( "Invalid info block length: " + d ) ; l = a . subarray ( 16 , 16 + d ) ; e = c ( l ) ; l = e . state ; e =
e . buffer _infos ; let p = 16 + d ; p = p + 3 & - 4 ; d = e . map ( q => { const r = p + q . offset ; return a . buffer . slice ( r , r + q . length ) } ) ; l = Ja ( l , d ) ; this . set _state ( l ) } } ; function Ma ( a , b , c ) { a [ 0 ] === b [ 0 ] && a [ 1 ] === b [ 1 ] && a [ 2 ] === b [ 2 ] && a [ 3 ] === b [ 3 ] && a [ 4 ] === b [ 4 ] && a [ 5 ] === b [ 5 ] && ( a [ 0 ] = c [ 0 ] , a [ 1 ] = c [ 1 ] , a [ 2 ] = c [ 2 ] , a [ 3 ] = c [ 3 ] , a [ 4 ] = c [ 4 ] , a [ 5 ] = c [ 5 ] ) ; a [ 6 ] === b [ 0 ] && a [ 7 ] === b [ 1 ] && a [ 8 ] === b [ 2 ] && a [ 9 ] === b [ 3 ] && a [ 10 ] === b [ 4 ] && a [ 11 ] === b [ 5 ] && ( a [ 6 ] = c [ 0 ] , a [ 7 ] = c [ 1 ] , a [ 8 ] = c [ 2 ] , a [ 9 ] = c [ 3 ] , a [ 10 ] = c [ 4 ] , a [ 11 ] = c [ 5 ] ) ; var d = a [ 12 ] << 8 | a [ 13 ] ; if ( 2048 === d ) { if ( a = a . subarray ( 14 ) , 4 === a [ 0 ] >> 4 && 17 === a [ 9 ] ) { a = a . subarray ( 20 ) ; d = a [ 0 ] << 8 | a [ 1 ] ; var e = a [ 2 ] << 8 | a [ 3 ] ; A ( a [ 6 ] << 8 | a [ 7 ] , 4 ) ; if ( 67 === d || 67 === e ) if ( d = a . subarray ( 8 ) , e = d [ 236 ] << 24 | d [ 237 ] <<
16 | d [ 238 ] << 8 | d [ 239 ] , 1669485411 !== e ) A ( e , 8 ) ; else for ( d [ 28 ] === b [ 0 ] && d [ 29 ] === b [ 1 ] && d [ 30 ] === b [ 2 ] && d [ 31 ] === b [ 3 ] && d [ 32 ] === b [ 4 ] && d [ 33 ] === b [ 5 ] && ( d [ 28 ] = c [ 0 ] , d [ 29 ] = c [ 1 ] , d [ 30 ] = c [ 2 ] , d [ 31 ] = c [ 3 ] , d [ 32 ] = c [ 4 ] , d [ 33 ] = c [ 5 ] , a [ 6 ] = a [ 7 ] = 0 ) , e = 240 ; e < d . length ; ) { const f = d [ e ++ ] ; if ( 255 === f ) break ; const g = d [ e ++ ] ; 61 === f && 1 === d [ e + 0 ] && d [ e + 1 ] === b [ 0 ] && d [ e + 2 ] === b [ 1 ] && d [ e + 3 ] === b [ 2 ] && d [ e + 4 ] === b [ 3 ] && d [ e + 5 ] === b [ 4 ] && d [ e + 6 ] === b [ 5 ] && ( d [ e + 1 ] = c [ 0 ] , d [ e + 2 ] = c [ 1 ] , d [ e + 3 ] = c [ 2 ] , d [ e + 4 ] = c [ 3 ] , d [ e + 5 ] = c [ 4 ] , d [ e + 6 ] = c [ 5 ] , a [ 6 ] = a [ 7 ] = 0 ) ; e += g } } } else 2054 === d && ( a =
a . subarray ( 14 ) , Na ( a . subarray ( 8 , 14 ) ) , Na ( a . subarray ( 18 , 24 ) ) , a [ 8 ] === b [ 0 ] && a [ 9 ] === b [ 1 ] && a [ 10 ] === b [ 2 ] && a [ 11 ] === b [ 3 ] && a [ 12 ] === b [ 4 ] && a [ 13 ] === b [ 5 ] && ( a [ 8 ] = c [ 0 ] , a [ 9 ] = c [ 1 ] , a [ 10 ] = c [ 2 ] , a [ 11 ] = c [ 3 ] , a [ 12 ] = c [ 4 ] , a [ 13 ] = c [ 5 ] ) ) } function Na ( a ) { return [ a [ 0 ] . toString ( 16 ) . padStart ( 2 , "0" ) , a [ 1 ] . toString ( 16 ) . padStart ( 2 , "0" ) , a [ 2 ] . toString ( 16 ) . padStart ( 2 , "0" ) , a [ 3 ] . toString ( 16 ) . padStart ( 2 , "0" ) , a [ 4 ] . toString ( 16 ) . padStart ( 2 , "0" ) , a [ 5 ] . toString ( 16 ) . padStart ( 2 , "0" ) ] . join ( ":" ) }
function Oa ( a , b , c , d , e ) { this . cpu = a ; this . pci = a . devices . pci ; this . id = e || 0 ; this . preserve _mac _from _state _image = c ; this . mac _address _translation = d ; this . bus = b ; this . bus . register ( "net" + this . id + "-receive" , function ( f ) { this . receive ( f ) } , this ) ; this . port = 768 + 256 * this . id ; this . name = "ne2k" ; this . pci _space = [ 236 , 16 , 41 , 128 , 3 , 1 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , this . port & 255 | 1 , this . port >> 8 , 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 , 244 , 26 , 0 , 17 , 0 , 0 , 184 , 254 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ] ; this . pci _id = ( 0 === this . id ? 5 : 7 + this . id ) << 3 ; this . pci _bars =
[ { size : 32 } ] ; this . imr = this . isr = 0 ; this . cr = 1 ; this . tpsr = this . tcnt = this . rcnt = this . dcfg = 0 ; this . memory = new Uint8Array ( 32768 ) ; this . txcr = this . rxcr = 0 ; this . tsr = 1 ; this . mac = new Uint8Array ( [ 0 , 34 , 21 , 255 * Math . random ( ) | 0 , 255 * Math . random ( ) | 0 , 255 * Math . random ( ) | 0 ] ) ; this . bus . send ( "net" + this . id + "-mac" , Na ( this . mac ) ) ; this . mar = Uint8Array . of ( 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ) ; this . mac _address _in _state = null ; for ( b = 0 ; 6 > b ; b ++ ) this . memory [ b << 1 ] = this . memory [ b << 1 | 1 ] = this . mac [ b ] ; this . memory [ 28 ] = this . memory [ 29 ] = 87 ; this . memory [ 30 ] = this . memory [ 31 ] =
87 ; qa ( "Mac: " + Na ( this . mac ) , 1048576 ) ; this . rsar = 0 ; this . pstart = 64 ; this . pstop = 128 ; this . boundary = this . curpg = 76 ; b = a . io ; b . register _read ( this . port | 0 , this , function ( ) { return this . cr } ) ; b . register _write ( this . port | 0 , this , function ( f ) { this . cr = f ; A ( f , 2 ) ; A ( this . txcr , 2 ) ; this . cr & 1 || ( f & 24 && 0 === this . rcnt && this . do _interrupt ( 64 ) , f & 4 && ( f = this . tpsr << 8 , f = this . memory . subarray ( f , f + this . tcnt ) , this . mac _address _in _state && ( f = new Uint8Array ( f ) , Ma ( f , this . mac _address _in _state , this . mac ) ) , this . bus . send ( "net" + this . id + "-send" , f ) , this . bus . send ( "eth-transmit-end" ,
[ f . length ] ) , this . cr &= - 5 , this . do _interrupt ( 2 ) , A ( f . byteLength ) ) ) } ) ; b . register _read ( this . port | 13 , this , function ( ) { return 1 === this . get _page ( ) ? this . mar [ 5 ] : 0 } ) ; b . register _read ( this . port | 14 , this , function ( ) { return 1 === this . get _page ( ) ? this . mar [ 6 ] : 0 } , function ( ) { this . get _page ( ) ; return 0 } ) ; b . register _read ( this . port | 15 , this , function ( ) { return 1 === this . get _page ( ) ? this . mar [ 7 ] : 0 } ) ; b . register _read ( this . port | 31 , this , function ( ) { this . get _page ( ) ; this . do _interrupt ( 128 ) ; return 0 } ) ; b . register _write ( this . port | 31 , this , function ( f ) { this . get _page ( ) ;
A ( f , 2 ) } ) ; b . register _read ( this . port | 1 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? this . pstart : 1 === f ? this . mac [ 0 ] : 2 === f ? this . pstart : 0 } ) ; b . register _write ( this . port | 1 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , this . pstart = f ) : 1 === g ? ( A ( f ) , this . mac [ 0 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 2 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? this . pstop : 1 === f ? this . mac [ 1 ] : 2 === f ? this . pstop : 0 } ) ; b . register _write ( this . port | 2 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , f > this . memory . length >>
8 && ( f = this . memory . length >> 8 , A ( f ) ) , this . pstop = f ) : 1 === g ? ( A ( f ) , this . mac [ 1 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 7 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? ( A ( this . isr , 2 ) , this . isr ) : 1 === f ? ( A ( this . curpg , 2 ) , this . curpg ) : 0 } ) ; b . register _write ( this . port | 7 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , this . isr &= ~ f , this . update _irq ( ) ) : 1 === g && ( A ( f , 2 ) , this . curpg = f ) } ) ; b . register _write ( this . port | 13 , this , function ( f ) { 0 === this . get _page ( ) && ( this . txcr = f ) ; A ( f , 2 ) } ) ; b . register _write ( this . port | 14 , this , function ( f ) { 0 ===
this . get _page ( ) ? ( A ( f , 2 ) , this . dcfg = f ) : A ( f , 2 ) } ) ; b . register _read ( this . port | 10 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? 80 : 1 === f ? this . mar [ 2 ] : 0 } ) ; b . register _write ( this . port | 10 , this , function ( f ) { 0 === this . get _page ( ) ? ( A ( f , 2 ) , this . rcnt = this . rcnt & 65280 | f & 255 ) : A ( f , 2 ) } ) ; b . register _read ( this . port | 11 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? 67 : 1 === f ? this . mar [ 3 ] : 0 } ) ; b . register _write ( this . port | 11 , this , function ( f ) { 0 === this . get _page ( ) ? ( A ( f , 2 ) , this . rcnt = this . rcnt & 255 | f << 8 & 65280 ) : A ( f , 2 ) } ) ; b . register _read ( this . port |
8 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? this . rsar & 255 : 1 === f ? this . mar [ 0 ] : 0 } ) ; b . register _write ( this . port | 8 , this , function ( f ) { 0 === this . get _page ( ) ? ( A ( f , 2 ) , this . rsar = this . rsar & 65280 | f & 255 ) : A ( f , 2 ) } ) ; b . register _read ( this . port | 9 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? this . rsar >> 8 & 255 : 1 === f ? this . mar [ 1 ] : 0 } ) ; b . register _write ( this . port | 9 , this , function ( f ) { 0 === this . get _page ( ) ? ( A ( f , 2 ) , this . rsar = this . rsar & 255 | f << 8 & 65280 ) : A ( f , 2 ) } ) ; b . register _write ( this . port | 15 , this , function ( f ) { 0 === this . get _page ( ) ?
( A ( f , 2 ) , A ( this . isr , 2 ) , this . imr = f , this . update _irq ( ) ) : A ( f , 2 ) } ) ; b . register _read ( this . port | 3 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? ( A ( this . boundary , 2 ) , this . boundary ) : 1 === f ? this . mac [ 2 ] : 0 } ) ; b . register _write ( this . port | 3 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , this . boundary = f ) : 1 === g ? ( A ( f ) , this . mac [ 2 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 4 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? this . tsr : 1 === f ? this . mac [ 3 ] : 0 } ) ; b . register _write ( this . port | 4 , this , function ( f ) { var g = this . get _page ( ) ;
0 === g ? ( A ( f , 2 ) , this . tpsr = f ) : 1 === g ? ( A ( f ) , this . mac [ 3 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 5 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? 0 : 1 === f ? this . mac [ 4 ] : 0 } ) ; b . register _write ( this . port | 5 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , this . tcnt = this . tcnt & - 256 | f ) : 1 === g ? ( A ( f ) , this . mac [ 4 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 6 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? 0 : 1 === f ? this . mac [ 5 ] : 0 } ) ; b . register _write ( this . port | 6 , this , function ( f ) { var g = this . get _page ( ) ; 0 === g ? ( A ( f , 2 ) , this . tcnt =
this . tcnt & 255 | f << 8 ) : 1 === g ? ( A ( f ) , this . mac [ 5 ] = f ) : A ( f ) } ) ; b . register _read ( this . port | 12 , this , function ( ) { var f = this . get _page ( ) ; return 0 === f ? 9 : 1 === f ? this . mar [ 4 ] : 0 } ) ; b . register _write ( this . port | 12 , this , function ( f ) { 0 === this . get _page ( ) ? ( A ( f , 2 ) , this . rxcr = f ) : A ( f ) } ) ; b . register _read ( this . port | 16 , this , this . data _port _read8 , this . data _port _read16 , this . data _port _read32 ) ; b . register _write ( this . port | 16 , this , this . data _port _write16 , this . data _port _write16 , this . data _port _write32 ) ; a . devices . pci . register _device ( this ) }
Oa . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . isr ; a [ 1 ] = this . imr ; a [ 2 ] = this . cr ; a [ 3 ] = this . dcfg ; a [ 4 ] = this . rcnt ; a [ 5 ] = this . tcnt ; a [ 6 ] = this . tpsr ; a [ 7 ] = this . rsar ; a [ 8 ] = this . pstart ; a [ 9 ] = this . curpg ; a [ 10 ] = this . boundary ; a [ 11 ] = this . pstop ; a [ 12 ] = this . rxcr ; a [ 13 ] = this . txcr ; a [ 14 ] = this . tsr ; a [ 15 ] = this . mac ; a [ 16 ] = this . memory ; return a } ;
Oa . prototype . set _state = function ( a ) { this . isr = a [ 0 ] ; this . imr = a [ 1 ] ; this . cr = a [ 2 ] ; this . dcfg = a [ 3 ] ; this . rcnt = a [ 4 ] ; this . tcnt = a [ 5 ] ; this . tpsr = a [ 6 ] ; this . rsar = a [ 7 ] ; this . pstart = a [ 8 ] ; this . curpg = a [ 9 ] ; this . boundary = a [ 10 ] ; this . pstop = a [ 11 ] ; this . rxcr = a [ 12 ] ; this . txcr = a [ 13 ] ; this . tsr = a [ 14 ] ; this . preserve _mac _from _state _image ? ( this . mac = a [ 15 ] , this . memory = a [ 16 ] ) : this . mac _address _translation && ( this . mac _address _in _state = a [ 15 ] , this . memory = a [ 16 ] , Na ( this . mac _address _in _state ) , Na ( this . mac ) ) ; this . bus . send ( "net" + this . id + "-mac" , Na ( this . mac ) ) } ;
Oa . prototype . do _interrupt = function ( a ) { A ( a , 2 ) ; this . isr |= a ; this . update _irq ( ) } ; Oa . prototype . update _irq = function ( ) { this . imr & this . isr ? this . pci . raise _irq ( this . pci _id ) : this . pci . lower _irq ( this . pci _id ) } ; Oa . prototype . data _port _write = function ( a ) { if ( 16 >= this . rsar || 16384 <= this . rsar && 32768 > this . rsar ) this . memory [ this . rsar ] = a ; this . rsar ++ ; this . rcnt -- ; this . rsar >= this . pstop << 8 && ( this . rsar += this . pstart - this . pstop << 8 ) ; 0 === this . rcnt && this . do _interrupt ( 64 ) } ;
Oa . prototype . data _port _write16 = function ( a ) { this . data _port _write ( a ) ; this . dcfg & 1 && this . data _port _write ( a >> 8 ) } ; Oa . prototype . data _port _write32 = function ( a ) { this . data _port _write ( a ) ; this . data _port _write ( a >> 8 ) ; this . data _port _write ( a >> 16 ) ; this . data _port _write ( a >> 24 ) } ; Oa . prototype . data _port _read = function ( ) { let a = 0 ; 32768 > this . rsar && ( a = this . memory [ this . rsar ] ) ; this . rsar ++ ; this . rcnt -- ; this . rsar >= this . pstop << 8 && ( this . rsar += this . pstart - this . pstop << 8 ) ; 0 === this . rcnt && this . do _interrupt ( 64 ) ; return a } ;
Oa . prototype . data _port _read8 = function ( ) { return this . data _port _read16 ( ) & 255 } ; Oa . prototype . data _port _read16 = function ( ) { return this . dcfg & 1 ? this . data _port _read ( ) | this . data _port _read ( ) << 8 : this . data _port _read ( ) } ; Oa . prototype . data _port _read32 = function ( ) { return this . data _port _read ( ) | this . data _port _read ( ) << 8 | this . data _port _read ( ) << 16 | this . data _port _read ( ) << 24 } ;
Oa . prototype . receive = function ( a ) { if ( ! ( this . cr & 1 ) && ( this . bus . send ( "eth-receive-end" , [ a . length ] ) , this . rxcr & 16 || this . rxcr & 4 && 255 === a [ 0 ] && 255 === a [ 1 ] && 255 === a [ 2 ] && 255 === a [ 3 ] && 255 === a [ 4 ] && 255 === a [ 5 ] || ! ( this . rxcr & 8 && 1 === ( a [ 0 ] & 1 ) || a [ 0 ] !== this . mac [ 0 ] || a [ 1 ] !== this . mac [ 1 ] || a [ 2 ] !== this . mac [ 2 ] || a [ 3 ] !== this . mac [ 3 ] || a [ 4 ] !== this . mac [ 4 ] || a [ 5 ] !== this . mac [ 5 ] ) ) ) { this . mac _address _in _state && ( a = new Uint8Array ( a ) , Ma ( a , this . mac , this . mac _address _in _state ) ) ; var b = this . curpg << 8 , c = Math . max ( 60 , a . length ) + 4 , d = b + 4 , e = this . curpg + 1 +
( c >> 8 ) , f = b + c , g = 1 + ( c >> 8 ) , h = this . boundary > this . curpg ? this . boundary - this . curpg : this . pstop - this . curpg + this . boundary - this . pstart ; h < g && 0 !== this . boundary ? ( A ( this . pstart ) , A ( this . pstop ) , A ( this . curpg ) , A ( g ) , A ( this . boundary ) , A ( h ) ) : ( f > this . pstop << 8 ? ( f = ( this . pstop << 8 ) - d , this . memory . set ( a . subarray ( 0 , f ) , d ) , this . memory . set ( a . subarray ( f ) , this . pstart << 8 ) , A ( f ) ) : ( this . memory . set ( a , d ) , 60 > a . length && this . memory . fill ( 0 , d + a . length , d + 60 ) ) , e >= this . pstop && ( e += this . pstart - this . pstop ) , this . memory [ b ] = 1 , this . memory [ b + 1 ] = e , this . memory [ b +
2 ] = c , this . memory [ b + 3 ] = c >> 8 , this . curpg = e , A ( b ) , A ( c ) , A ( e ) , this . do _interrupt ( 1 ) ) } } ; Oa . prototype . get _page = function ( ) { return this . cr >> 6 & 3 } ; var Pa = new Uint8Array ( 256 ) , Qa = [ ] , Ra = [ ] , Sa = [ ] , Ta = new Uint8Array ( 256 ) , Wa = [ ] ;
function P ( a , b ) { this . cpu = a ; this . bus = b ; this . write _buffer = new ja ( 64 ) ; this . read _buffer = new ja ( 64 ) ; this . mixer _current _address = this . command _size = this . command = this . read _buffer _lastvalue = 0 ; this . mixer _registers = new Uint8Array ( 256 ) ; this . mixer _reset ( ) ; this . dummy _speaker _enabled = ! 1 ; this . test _register = 0 ; this . dsp _signed = this . dsp _16bit = this . dsp _stereo = this . dsp _highspeed = ! 1 ; this . dac _buffers = [ new la ( 65536 ) , new la ( 65536 ) ] ; this . dma = a . devices . dma ; this . dma _channel = this . dma _irq = this . dma _bytes _block = this . dma _bytes _left =
this . dma _bytes _count = this . dma _sample _count = 0 ; this . dma _channel _8bit = 1 ; this . dma _channel _16bit = 5 ; this . dma _autoinit = ! 1 ; this . dma _buffer = new ArrayBuffer ( 65536 ) ; this . dma _buffer _int8 = new Int8Array ( this . dma _buffer ) ; this . dma _buffer _uint8 = new Uint8Array ( this . dma _buffer ) ; this . dma _buffer _int16 = new Int16Array ( this . dma _buffer ) ; this . dma _buffer _uint16 = new Uint16Array ( this . dma _buffer ) ; this . dma _syncbuffer = new t . SyncBuffer ( this . dma _buffer ) ; this . dma _paused = this . dma _waiting _transfer = ! 1 ; this . sampling _rate = 22050 ; b . send ( "dac-tell-sampling-rate" ,
this . sampling _rate ) ; this . bytes _per _sample = 1 ; this . e2 _value = 170 ; this . e2 _count = 0 ; this . asp _registers = new Uint8Array ( 256 ) ; this . mpu _read _buffer = new ja ( 64 ) ; this . fm _current _address1 = this . fm _current _address0 = this . mpu _read _buffer _lastvalue = 0 ; this . fm _waveform _select _enable = ! 1 ; this . irq = 5 ; this . irq _triggered = new Uint8Array ( 16 ) ; a . io . register _read _consecutive ( 544 , this , this . port2x0 _read , this . port2x1 _read , this . port2x2 _read , this . port2x3 _read ) ; a . io . register _read _consecutive ( 904 , this , this . port2x0 _read , this . port2x1 _read ) ;
2024-06-28 09:23:02 +02:00
a . io . register _read _consecutive ( 548 , this , this . port2x4 _read , this . port2x5 _read ) ; a . io . register _read ( 550 , this , this . port2x6 _read ) ; a . io . register _read ( 551 , this , this . port2x7 _read ) ; a . io . register _read ( 552 , this , this . port2x8 _read ) ; a . io . register _read ( 553 , this , this . port2x9 _read ) ; a . io . register _read ( 554 , this , this . port2xA _read ) ; a . io . register _read ( 555 , this , this . port2xB _read ) ; a . io . register _read ( 556 , this , this . port2xC _read ) ; a . io . register _read ( 557 , this , this . port2xD _read ) ; a . io . register _read _consecutive ( 558 , this , this . port2xE _read ,
this . port2xF _read ) ; a . io . register _write _consecutive ( 544 , this , this . port2x0 _write , this . port2x1 _write , this . port2x2 _write , this . port2x3 _write ) ; a . io . register _write _consecutive ( 904 , this , this . port2x0 _write , this . port2x1 _write ) ; a . io . register _write _consecutive ( 548 , this , this . port2x4 _write , this . port2x5 _write ) ; a . io . register _write ( 550 , this , this . port2x6 _write ) ; a . io . register _write ( 551 , this , this . port2x7 _write ) ; a . io . register _write _consecutive ( 552 , this , this . port2x8 _write , this . port2x9 _write ) ; a . io . register _write ( 554 , this ,
this . port2xA _write ) ; a . io . register _write ( 555 , this , this . port2xB _write ) ; a . io . register _write ( 556 , this , this . port2xC _write ) ; a . io . register _write ( 557 , this , this . port2xD _write ) ; a . io . register _write ( 558 , this , this . port2xE _write ) ; a . io . register _write ( 559 , this , this . port2xF _write ) ; a . io . register _read _consecutive ( 816 , this , this . port3x0 _read , this . port3x1 _read ) ; a . io . register _write _consecutive ( 816 , this , this . port3x0 _write , this . port3x1 _write ) ; this . dma . on _unmask ( this . dma _on _unmask , this ) ; b . register ( "dac-request-data" , function ( ) { this . dac _handle _request ( ) } ,
this ) ; b . register ( "speaker-has-initialized" , function ( ) { this . mixer _reset ( ) } , this ) ; b . send ( "speaker-confirm-initialized" ) ; this . dsp _reset ( ) }
2024-10-02 21:03:04 +02:00
P . prototype . dsp _reset = function ( ) { this . write _buffer . clear ( ) ; this . read _buffer . clear ( ) ; this . command _size = this . command = 0 ; this . dummy _speaker _enabled = ! 1 ; this . test _register = 0 ; this . dsp _signed = this . dsp _16bit = this . dsp _stereo = this . dsp _highspeed = ! 1 ; this . dac _buffers [ 0 ] . clear ( ) ; this . dac _buffers [ 1 ] . clear ( ) ; this . dma _channel = this . dma _irq = this . dma _bytes _block = this . dma _bytes _left = this . dma _bytes _count = this . dma _sample _count = 0 ; this . dma _autoinit = ! 1 ; this . dma _buffer _uint8 . fill ( 0 ) ; this . dma _paused = this . dma _waiting _transfer =
2024-06-28 09:23:02 +02:00
! 1 ; this . e2 _value = 170 ; this . e2 _count = 0 ; this . sampling _rate = 22050 ; this . bytes _per _sample = 1 ; this . lower _irq ( 1 ) ; this . irq _triggered . fill ( 0 ) ; this . asp _registers . fill ( 0 ) ; this . asp _registers [ 5 ] = 1 ; this . asp _registers [ 9 ] = 248 } ;
2024-10-02 21:03:04 +02:00
P . prototype . get _state = function ( ) { var a = [ ] ; a [ 2 ] = this . read _buffer _lastvalue ; a [ 3 ] = this . command ; a [ 4 ] = this . command _size ; a [ 5 ] = this . mixer _current _address ; a [ 6 ] = this . mixer _registers ; a [ 7 ] = this . dummy _speaker _enabled ; a [ 8 ] = this . test _register ; a [ 9 ] = this . dsp _highspeed ; a [ 10 ] = this . dsp _stereo ; a [ 11 ] = this . dsp _16bit ; a [ 12 ] = this . dsp _signed ; a [ 15 ] = this . dma _sample _count ; a [ 16 ] = this . dma _bytes _count ; a [ 17 ] = this . dma _bytes _left ; a [ 18 ] = this . dma _bytes _block ; a [ 19 ] = this . dma _irq ; a [ 20 ] = this . dma _channel ; a [ 21 ] = this . dma _channel _8bit ; a [ 22 ] =
2024-06-28 09:23:02 +02:00
this . dma _channel _16bit ; a [ 23 ] = this . dma _autoinit ; a [ 24 ] = this . dma _buffer _uint8 ; a [ 25 ] = this . dma _waiting _transfer ; a [ 26 ] = this . dma _paused ; a [ 27 ] = this . sampling _rate ; a [ 28 ] = this . bytes _per _sample ; a [ 29 ] = this . e2 _value ; a [ 30 ] = this . e2 _count ; a [ 31 ] = this . asp _registers ; a [ 33 ] = this . mpu _read _buffer _last _value ; a [ 34 ] = this . irq ; a [ 35 ] = this . irq _triggered ; return a } ;
2024-10-02 21:03:04 +02:00
P . prototype . set _state = function ( a ) { this . read _buffer _lastvalue = a [ 2 ] ; this . command = a [ 3 ] ; this . command _size = a [ 4 ] ; this . mixer _current _address = a [ 5 ] ; this . mixer _registers = a [ 6 ] ; this . mixer _full _update ( ) ; this . dummy _speaker _enabled = a [ 7 ] ; this . test _register = a [ 8 ] ; this . dsp _highspeed = a [ 9 ] ; this . dsp _stereo = a [ 10 ] ; this . dsp _16bit = a [ 11 ] ; this . dsp _signed = a [ 12 ] ; this . dma _sample _count = a [ 15 ] ; this . dma _bytes _count = a [ 16 ] ; this . dma _bytes _left = a [ 17 ] ; this . dma _bytes _block = a [ 18 ] ; this . dma _irq = a [ 19 ] ; this . dma _channel = a [ 20 ] ; this . dma _channel _8bit =
2024-06-28 09:23:02 +02:00
a [ 21 ] ; this . dma _channel _16bit = a [ 22 ] ; this . dma _autoinit = a [ 23 ] ; this . dma _buffer _uint8 = a [ 24 ] ; this . dma _waiting _transfer = a [ 25 ] ; this . dma _paused = a [ 26 ] ; this . sampling _rate = a [ 27 ] ; this . bytes _per _sample = a [ 28 ] ; this . e2 _value = a [ 29 ] ; this . e2 _count = a [ 30 ] ; this . asp _registers = a [ 31 ] ; this . mpu _read _buffer _last _value = a [ 33 ] ; this . irq = a [ 34 ] ; this . irq _triggered = a [ 35 ] ; this . dma _buffer = this . dma _buffer _uint8 . buffer ; this . dma _buffer _int8 = new Int8Array ( this . dma _buffer ) ; this . dma _buffer _int16 = new Int16Array ( this . dma _buffer ) ; this . dma _buffer _uint16 =
2024-10-02 21:03:04 +02:00
new Uint16Array ( this . dma _buffer ) ; this . dma _syncbuffer = new t . SyncBuffer ( this . dma _buffer ) ; this . dma _paused ? this . bus . send ( "dac-disable" ) : this . bus . send ( "dac-enable" ) } ; P . prototype . port2x0 _read = function ( ) { return 255 } ; P . prototype . port2x1 _read = function ( ) { return 255 } ; P . prototype . port2x2 _read = function ( ) { return 255 } ; P . prototype . port2x3 _read = function ( ) { return 255 } ; P . prototype . port2x4 _read = function ( ) { return this . mixer _current _address } ; P . prototype . port2x5 _read = function ( ) { return this . mixer _read ( this . mixer _current _address ) } ;
P . prototype . port2x6 _read = function ( ) { return 255 } ; P . prototype . port2x7 _read = function ( ) { return 255 } ; P . prototype . port2x8 _read = function ( ) { return 255 } ; P . prototype . port2x9 _read = function ( ) { return 255 } ; P . prototype . port2xA _read = function ( ) { this . read _buffer . length && ( this . read _buffer _lastvalue = this . read _buffer . shift ( ) ) ; A ( this . read _buffer _lastvalue ) ; String . fromCharCode ( this . read _buffer _lastvalue ) ; return this . read _buffer _lastvalue } ; P . prototype . port2xB _read = function ( ) { return 255 } ; P . prototype . port2xC _read = function ( ) { return 127 } ;
P . prototype . port2xD _read = function ( ) { return 255 } ; P . prototype . port2xE _read = function ( ) { this . irq _triggered [ 1 ] && this . lower _irq ( 1 ) ; return ( this . read _buffer . length && ! this . dsp _highspeed ) << 7 | 127 } ; P . prototype . port2xF _read = function ( ) { this . lower _irq ( 2 ) ; return 0 } ; P . prototype . port2x0 _write = function ( a ) { A ( a ) ; this . fm _current _address0 = 0 } ; P . prototype . port2x1 _write = function ( a ) { A ( a ) ; var b = Wa [ this . fm _current _address0 ] ; b || ( b = this . fm _default _write ) ; b . call ( this , a , 0 , this . fm _current _address0 ) } ;
P . prototype . port2x2 _write = function ( a ) { A ( a ) ; this . fm _current _address1 = 0 } ; P . prototype . port2x3 _write = function ( a ) { A ( a ) ; var b = Wa [ this . fm _current _address1 ] ; b || ( b = this . fm _default _write ) ; b . call ( this , a , 1 , this . fm _current _address1 ) } ; P . prototype . port2x4 _write = function ( a ) { A ( a ) ; this . mixer _current _address = a } ; P . prototype . port2x5 _write = function ( a ) { A ( a ) ; this . mixer _write ( this . mixer _current _address , a ) } ;
P . prototype . port2x6 _write = function ( a ) { A ( a ) ; this . dsp _highspeed ? this . dsp _highspeed = ! 1 : a && this . dsp _reset ( ) ; this . read _buffer . clear ( ) ; this . read _buffer . push ( 170 ) } ; P . prototype . port2x7 _write = function ( ) { } ; P . prototype . port2x8 _write = function ( ) { } ; P . prototype . port2x9 _write = function ( ) { } ; P . prototype . port2xA _write = function ( ) { } ; P . prototype . port2xB _write = function ( ) { } ;
P . prototype . port2xC _write = function ( a ) { 0 === this . command ? ( A ( a ) , this . command = a , this . write _buffer . clear ( ) , this . command _size = Pa [ a ] ) : ( A ( a ) , this . write _buffer . push ( a ) ) ; this . write _buffer . length >= this . command _size && this . command _do ( ) } ; P . prototype . port2xD _write = function ( ) { } ; P . prototype . port2xE _write = function ( ) { } ; P . prototype . port2xF _write = function ( ) { } ;
P . prototype . port3x0 _read = function ( ) { this . mpu _read _buffer . length && ( this . mpu _read _buffer _lastvalue = this . mpu _read _buffer . shift ( ) ) ; A ( this . mpu _read _buffer _lastvalue ) ; return this . mpu _read _buffer _lastvalue } ; P . prototype . port3x0 _write = function ( a ) { A ( a ) } ; P . prototype . port3x1 _read = function ( ) { return 0 | 128 * ! this . mpu _read _buffer . length } ; P . prototype . port3x1 _write = function ( a ) { A ( a ) ; 255 === a && ( this . mpu _read _buffer . clear ( ) , this . mpu _read _buffer . push ( 254 ) ) } ;
P . prototype . command _do = function ( ) { var a = Qa [ this . command ] ; a || ( a = this . dsp _default _handler ) ; a . call ( this ) ; this . command _size = this . command = 0 ; this . write _buffer . clear ( ) } ; P . prototype . dsp _default _handler = function ( ) { A ( this . command ) } ; function Q ( a , b , c ) { c || ( c = P . prototype . dsp _default _handler ) ; for ( var d = 0 ; d < a . length ; d ++ ) Pa [ a [ d ] ] = b , Qa [ a [ d ] ] = c } function Xa ( a ) { for ( var b = [ ] , c = 0 ; 16 > c ; c ++ ) b . push ( a + c ) ; return b } Q ( [ 14 ] , 2 , function ( ) { this . asp _registers [ this . write _buffer . shift ( ) ] = this . write _buffer . shift ( ) } ) ;
Q ( [ 15 ] , 1 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( this . asp _registers [ this . write _buffer . shift ( ) ] ) } ) ; Q ( [ 16 ] , 1 , function ( ) { var a = this . write _buffer . shift ( ) ; a = Ya ( a / 127.5 + - 1 , - 1 , 1 ) ; this . dac _buffers [ 0 ] . push ( a ) ; this . dac _buffers [ 1 ] . push ( a ) ; this . bus . send ( "dac-enable" ) } ) ; Q ( [ 20 , 21 ] , 2 , function ( ) { this . dma _irq = 1 ; this . dma _channel = this . dma _channel _8bit ; this . dsp _highspeed = this . dsp _16bit = this . dsp _signed = this . dma _autoinit = ! 1 ; this . dma _transfer _size _set ( ) ; this . dma _transfer _start ( ) } ) ; Q ( [ 22 ] , 2 ) ; Q ( [ 23 ] , 2 ) ;
Q ( [ 28 ] , 0 , function ( ) { this . dma _irq = 1 ; this . dma _channel = this . dma _channel _8bit ; this . dma _autoinit = ! 0 ; this . dsp _highspeed = this . dsp _16bit = this . dsp _signed = ! 1 ; this . dma _transfer _start ( ) } ) ; Q ( [ 31 ] , 0 ) ; Q ( [ 32 ] , 0 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( 127 ) } ) ; Q ( [ 36 ] , 2 ) ; Q ( [ 44 ] , 0 ) ; Q ( [ 48 ] , 0 ) ; Q ( [ 49 ] , 0 ) ; Q ( [ 52 ] , 0 ) ; Q ( [ 53 ] , 0 ) ; Q ( [ 54 ] , 0 ) ; Q ( [ 55 ] , 0 ) ; Q ( [ 56 ] , 0 ) ; Q ( [ 64 ] , 1 , function ( ) { this . sampling _rate _change ( 1E6 / ( 256 - this . write _buffer . shift ( ) ) / this . get _channel _count ( ) ) } ) ;
Q ( [ 65 , 66 ] , 2 , function ( ) { this . sampling _rate _change ( this . write _buffer . shift ( ) << 8 | this . write _buffer . shift ( ) ) } ) ; Q ( [ 72 ] , 2 , function ( ) { this . dma _transfer _size _set ( ) } ) ; Q ( [ 116 ] , 2 ) ; Q ( [ 117 ] , 2 ) ; Q ( [ 118 ] , 2 ) ; Q ( [ 119 ] , 2 ) ; Q ( [ 125 ] , 0 ) ; Q ( [ 127 ] , 0 ) ; Q ( [ 128 ] , 2 ) ; Q ( [ 144 ] , 0 , function ( ) { this . dma _irq = 1 ; this . dma _channel = this . dma _channel _8bit ; this . dma _autoinit = ! 0 ; this . dsp _signed = ! 1 ; this . dsp _highspeed = ! 0 ; this . dsp _16bit = ! 1 ; this . dma _transfer _start ( ) } ) ; Q ( [ 145 ] , 0 ) ; Q ( [ 152 ] , 0 ) ; Q ( [ 153 ] , 0 ) ; Q ( [ 160 ] , 0 ) ; Q ( [ 168 ] , 0 ) ;
Q ( Xa ( 176 ) , 3 , function ( ) { if ( this . command & 8 ) this . dsp _default _handler ( ) ; else { var a = this . write _buffer . shift ( ) ; this . dma _irq = 2 ; this . dma _channel = this . dma _channel _16bit ; this . dma _autoinit = ! ! ( this . command & 4 ) ; this . dsp _signed = ! ! ( a & 16 ) ; this . dsp _stereo = ! ! ( a & 32 ) ; this . dsp _16bit = ! 0 ; this . dma _transfer _size _set ( ) ; this . dma _transfer _start ( ) } } ) ;
Q ( Xa ( 192 ) , 3 , function ( ) { if ( this . command & 8 ) this . dsp _default _handler ( ) ; else { var a = this . write _buffer . shift ( ) ; this . dma _irq = 1 ; this . dma _channel = this . dma _channel _8bit ; this . dma _autoinit = ! ! ( this . command & 4 ) ; this . dsp _signed = ! ! ( a & 16 ) ; this . dsp _stereo = ! ! ( a & 32 ) ; this . dsp _16bit = ! 1 ; this . dma _transfer _size _set ( ) ; this . dma _transfer _start ( ) } } ) ; Q ( [ 208 ] , 0 , function ( ) { this . dma _paused = ! 0 ; this . bus . send ( "dac-disable" ) } ) ; Q ( [ 209 ] , 0 , function ( ) { this . dummy _speaker _enabled = ! 0 } ) ; Q ( [ 211 ] , 0 , function ( ) { this . dummy _speaker _enabled = ! 1 } ) ;
Q ( [ 212 ] , 0 , function ( ) { this . dma _paused = ! 1 ; this . bus . send ( "dac-enable" ) } ) ; Q ( [ 213 ] , 0 , function ( ) { this . dma _paused = ! 0 ; this . bus . send ( "dac-disable" ) } ) ; Q ( [ 214 ] , 0 , function ( ) { this . dma _paused = ! 1 ; this . bus . send ( "dac-enable" ) } ) ; Q ( [ 216 ] , 0 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( 255 * this . dummy _speaker _enabled ) } ) ; Q ( [ 217 , 218 ] , 0 , function ( ) { this . dma _autoinit = ! 1 } ) ; Q ( [ 224 ] , 1 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( ~ this . write _buffer . shift ( ) ) } ) ;
Q ( [ 225 ] , 0 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( 4 ) ; this . read _buffer . push ( 5 ) } ) ; Q ( [ 226 ] , 1 ) ; Q ( [ 227 ] , 0 , function ( ) { this . read _buffer . clear ( ) ; for ( var a = 0 ; 44 > a ; a ++ ) this . read _buffer . push ( "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992." . charCodeAt ( a ) ) ; this . read _buffer . push ( 0 ) } ) ; Q ( [ 228 ] , 1 , function ( ) { this . test _register = this . write _buffer . shift ( ) } ) ; Q ( [ 232 ] , 0 , function ( ) { this . read _buffer . clear ( ) ; this . read _buffer . push ( this . test _register ) } ) ; Q ( [ 242 , 243 ] , 0 , function ( ) { this . raise _irq ( ) } ) ; var Za = new Uint8Array ( 256 ) ;
Za [ 14 ] = 255 ; Za [ 15 ] = 7 ; Za [ 55 ] = 56 ; Q ( [ 249 ] , 1 , function ( ) { var a = this . write _buffer . shift ( ) ; this . read _buffer . clear ( ) ; this . read _buffer . push ( Za [ a ] ) } ) ; P . prototype . mixer _read = function ( a ) { var b = Ra [ a ] ; b ? b = b . call ( this ) : ( b = this . mixer _registers [ a ] , A ( a ) , A ( b ) ) ; return b } ; P . prototype . mixer _write = function ( a , b ) { var c = Sa [ a ] ; c ? c . call ( this , b ) : ( A ( a ) , A ( b ) ) } ; P . prototype . mixer _default _read = function ( ) { A ( this . mixer _current _address ) ; return this . mixer _registers [ this . mixer _current _address ] } ;
P . prototype . mixer _default _write = function ( a ) { A ( this . mixer _current _address ) ; A ( a ) ; this . mixer _registers [ this . mixer _current _address ] = a } ;
P . prototype . mixer _reset = function ( ) { this . mixer _registers [ 4 ] = 204 ; this . mixer _registers [ 34 ] = 204 ; this . mixer _registers [ 38 ] = 204 ; this . mixer _registers [ 40 ] = 0 ; this . mixer _registers [ 46 ] = 0 ; this . mixer _registers [ 10 ] = 0 ; this . mixer _registers [ 48 ] = 192 ; this . mixer _registers [ 49 ] = 192 ; this . mixer _registers [ 50 ] = 192 ; this . mixer _registers [ 51 ] = 192 ; this . mixer _registers [ 52 ] = 192 ; this . mixer _registers [ 53 ] = 192 ; this . mixer _registers [ 54 ] = 0 ; this . mixer _registers [ 55 ] = 0 ; this . mixer _registers [ 56 ] = 0 ; this . mixer _registers [ 57 ] = 0 ; this . mixer _registers [ 59 ] =
0 ; this . mixer _registers [ 60 ] = 31 ; this . mixer _registers [ 61 ] = 21 ; this . mixer _registers [ 62 ] = 11 ; this . mixer _registers [ 63 ] = 0 ; this . mixer _registers [ 64 ] = 0 ; this . mixer _registers [ 65 ] = 0 ; this . mixer _registers [ 66 ] = 0 ; this . mixer _registers [ 67 ] = 0 ; this . mixer _registers [ 68 ] = 128 ; this . mixer _registers [ 69 ] = 128 ; this . mixer _registers [ 70 ] = 128 ; this . mixer _registers [ 71 ] = 128 ; this . mixer _full _update ( ) } ; P . prototype . mixer _full _update = function ( ) { for ( var a = 1 ; a < this . mixer _registers . length ; a ++ ) Ta [ a ] || this . mixer _write ( a , this . mixer _registers [ a ] ) } ;
function $a ( a , b ) { b || ( b = P . prototype . mixer _default _read ) ; Ra [ a ] = b } function ab ( a , b ) { b || ( b = P . prototype . mixer _default _write ) ; Sa [ a ] = b } function cb ( a , b , c ) { Ta [ a ] = 1 ; Ra [ a ] = function ( ) { return this . mixer _registers [ b ] & 240 | this . mixer _registers [ c ] >>> 4 } ; Sa [ a ] = function ( d ) { this . mixer _registers [ a ] = d ; var e = d << 4 & 240 | this . mixer _registers [ c ] & 15 ; this . mixer _write ( b , d & 240 | this . mixer _registers [ b ] & 15 ) ; this . mixer _write ( c , e ) } }
function db ( a , b , c ) { Ra [ a ] = P . prototype . mixer _default _read ; Sa [ a ] = function ( d ) { this . mixer _registers [ a ] = d ; this . bus . send ( "mixer-volume" , [ b , c , ( d >>> 2 ) - 62 ] ) } } $a ( 0 , function ( ) { this . mixer _reset ( ) ; return 0 } ) ; ab ( 0 ) ; cb ( 4 , 50 , 51 ) ; cb ( 34 , 48 , 49 ) ; cb ( 38 , 52 , 53 ) ; cb ( 40 , 54 , 55 ) ; cb ( 46 , 56 , 57 ) ; db ( 48 , 0 , 0 ) ; db ( 49 , 0 , 1 ) ; db ( 50 , 2 , 0 ) ; db ( 51 , 2 , 1 ) ; $a ( 59 ) ; ab ( 59 , function ( a ) { this . mixer _registers [ 59 ] = a ; this . bus . send ( "mixer-volume" , [ 1 , 2 , 6 * ( a >>> 6 ) - 18 ] ) } ) ; $a ( 65 ) ;
ab ( 65 , function ( a ) { this . mixer _registers [ 65 ] = a ; this . bus . send ( "mixer-gain-left" , 6 * ( a >>> 6 ) ) } ) ; $a ( 66 ) ; ab ( 66 , function ( a ) { this . mixer _registers [ 66 ] = a ; this . bus . send ( "mixer-gain-right" , 6 * ( a >>> 6 ) ) } ) ; $a ( 68 ) ; ab ( 68 , function ( a ) { this . mixer _registers [ 68 ] = a ; a >>>= 3 ; this . bus . send ( "mixer-treble-left" , a - ( 16 > a ? 14 : 16 ) ) } ) ; $a ( 69 ) ; ab ( 69 , function ( a ) { this . mixer _registers [ 69 ] = a ; a >>>= 3 ; this . bus . send ( "mixer-treble-right" , a - ( 16 > a ? 14 : 16 ) ) } ) ; $a ( 70 ) ;
ab ( 70 , function ( a ) { this . mixer _registers [ 70 ] = a ; a >>>= 3 ; this . bus . send ( "mixer-bass-right" , a - ( 16 > a ? 14 : 16 ) ) } ) ; $a ( 71 ) ; ab ( 71 , function ( a ) { this . mixer _registers [ 71 ] = a ; a >>>= 3 ; this . bus . send ( "mixer-bass-right" , a - ( 16 > a ? 14 : 16 ) ) } ) ; $a ( 128 , function ( ) { switch ( this . irq ) { case 2 : return 1 ; case 5 : return 2 ; case 7 : return 4 ; case 10 : return 8 ; default : return 0 } } ) ; ab ( 128 , function ( a ) { a & 1 && ( this . irq = 2 ) ; a & 2 && ( this . irq = 5 ) ; a & 4 && ( this . irq = 7 ) ; a & 8 && ( this . irq = 10 ) } ) ;
$a ( 129 , function ( ) { var a = 0 ; switch ( this . dma _channel _8bit ) { case 0 : a |= 1 ; break ; case 1 : a |= 2 ; break ; case 3 : a |= 8 } switch ( this . dma _channel _16bit ) { case 5 : a |= 32 ; break ; case 6 : a |= 64 ; break ; case 7 : a |= 128 } return a } ) ; ab ( 129 , function ( a ) { a & 1 && ( this . dma _channel _8bit = 0 ) ; a & 2 && ( this . dma _channel _8bit = 1 ) ; a & 8 && ( this . dma _channel _8bit = 3 ) ; a & 32 && ( this . dma _channel _16bit = 5 ) ; a & 64 && ( this . dma _channel _16bit = 6 ) ; a & 128 && ( this . dma _channel _16bit = 7 ) } ) ; $a ( 130 , function ( ) { for ( var a = 32 , b = 0 ; 16 > b ; b ++ ) a |= b * this . irq _triggered [ b ] ; return a } ) ;
P . prototype . fm _default _write = function ( a , b , c ) { A ( c ) ; A ( a ) } ; function eb ( a , b ) { b || ( b = P . prototype . fm _default _write ) ; for ( var c = 0 ; c < a . length ; c ++ ) Wa [ a [ c ] ] = b } function fb ( a , b ) { for ( var c = [ ] ; a <= b ; a ++ ) c . push ( a ) ; return c } var R = new Uint8Array ( 32 ) ; R [ 0 ] = 0 ; R [ 1 ] = 1 ; R [ 2 ] = 2 ; R [ 3 ] = 3 ; R [ 4 ] = 4 ; R [ 5 ] = 5 ; R [ 8 ] = 6 ; R [ 9 ] = 7 ; R [ 10 ] = 8 ; R [ 11 ] = 9 ; R [ 12 ] = 10 ; R [ 13 ] = 11 ; R [ 16 ] = 12 ; R [ 17 ] = 13 ; R [ 18 ] = 14 ; R [ 19 ] = 15 ; R [ 20 ] = 16 ; R [ 21 ] = 17 ; eb ( [ 1 ] , function ( a , b ) { this . fm _waveform _select _enable [ b ] = a & 1 ; this . fm _update _waveforms ( ) } ) ; eb ( [ 2 ] ) ; eb ( [ 3 ] ) ; eb ( [ 4 ] , function ( ) { } ) ;
eb ( [ 5 ] , function ( a , b , c ) { 0 === b && this . fm _default _write ( a , b , c ) } ) ; eb ( [ 8 ] , function ( ) { } ) ; eb ( fb ( 32 , 53 ) , function ( ) { } ) ; eb ( fb ( 64 , 85 ) , function ( ) { } ) ; eb ( fb ( 96 , 117 ) , function ( ) { } ) ; eb ( fb ( 128 , 149 ) , function ( ) { } ) ; eb ( fb ( 160 , 168 ) , function ( ) { } ) ; eb ( fb ( 176 , 184 ) , function ( ) { } ) ; eb ( [ 189 ] , function ( ) { } ) ; eb ( fb ( 192 , 200 ) , function ( ) { } ) ; eb ( fb ( 224 , 245 ) , function ( ) { } ) ; P . prototype . fm _update _waveforms = function ( ) { } ; P . prototype . sampling _rate _change = function ( a ) { this . sampling _rate = a ; this . bus . send ( "dac-tell-sampling-rate" , a ) } ;
P . prototype . get _channel _count = function ( ) { return this . dsp _stereo ? 2 : 1 } ; P . prototype . dma _transfer _size _set = function ( ) { this . dma _sample _count = 1 + ( this . write _buffer . shift ( ) << 0 ) + ( this . write _buffer . shift ( ) << 8 ) } ;
P . prototype . dma _transfer _start = function ( ) { this . bytes _per _sample = 1 ; this . dsp _16bit && ( this . bytes _per _sample *= 2 ) ; this . dma _bytes _count = this . dma _sample _count * this . bytes _per _sample ; this . dma _bytes _block = 1024 * this . bytes _per _sample ; this . dma _bytes _block = Math . min ( Math . max ( this . dma _bytes _count >> 2 & - 4 , 32 ) , this . dma _bytes _block ) ; this . dma _waiting _transfer = ! 0 ; this . dma . channel _mask [ this . dma _channel ] || this . dma _on _unmask ( this . dma _channel ) } ;
P . prototype . dma _on _unmask = function ( a ) { a === this . dma _channel && this . dma _waiting _transfer && ( this . dma _waiting _transfer = ! 1 , this . dma _bytes _left = this . dma _bytes _count , this . dma _paused = ! 1 , this . bus . send ( "dac-enable" ) ) } ;
P . prototype . dma _transfer _next = function ( ) { var a = Math . min ( this . dma _bytes _left , this . dma _bytes _block ) , b = Math . floor ( a / this . bytes _per _sample ) ; this . dma . do _write ( this . dma _syncbuffer , 0 , a , this . dma _channel , c => { c || ( this . dma _to _dac ( b ) , this . dma _bytes _left -= a , this . dma _bytes _left || ( this . raise _irq ( this . dma _irq ) , this . dma _autoinit && ( this . dma _bytes _left = this . dma _bytes _count ) ) ) } ) } ;
P . prototype . dma _to _dac = function ( a ) { var b = this . dsp _16bit ? 32767.5 : 127.5 , c = this . dsp _signed ? 0 : - 1 , d = this . dsp _stereo ? 1 : 2 ; var e = this . dsp _16bit ? this . dsp _signed ? this . dma _buffer _int16 : this . dma _buffer _uint16 : this . dsp _signed ? this . dma _buffer _int8 : this . dma _buffer _uint8 ; for ( var f = 0 , g = 0 ; g < a ; g ++ ) for ( var h = Ya ( e [ g ] / b + c , - 1 , 1 ) , l = 0 ; l < d ; l ++ ) this . dac _buffers [ f ] . push ( h ) , f ^= 1 ; this . dac _send ( ) } ; P . prototype . dac _handle _request = function ( ) { ! this . dma _bytes _left || this . dma _paused ? this . dac _send ( ) : this . dma _transfer _next ( ) } ;
P . prototype . dac _send = function ( ) { if ( this . dac _buffers [ 0 ] . length ) { var a = this . dac _buffers [ 0 ] . shift _block ( this . dac _buffers [ 0 ] . length ) , b = this . dac _buffers [ 1 ] . shift _block ( this . dac _buffers [ 1 ] . length ) ; this . bus . send ( "dac-send-data" , [ a , b ] , [ a . buffer , b . buffer ] ) } } ; P . prototype . raise _irq = function ( a ) { this . irq _triggered [ a ] = 1 ; this . cpu . device _raise _irq ( this . irq ) } ; P . prototype . lower _irq = function ( a ) { this . irq _triggered [ a ] = 0 ; this . cpu . device _lower _irq ( this . irq ) } ; function Ya ( a , b , c ) { return ( a < b ) * b + ( a > c ) * c + ( b <= a && a <= c ) * a } ; function k ( a , b ) { this . cpu = a ; this . pci = a . devices . pci ; this . device _id = b . device _id ; this . pci _space = [ 244 , 26 , b . device _id & 255 , b . device _id >> 8 , 7 , 5 , 16 , 0 , 1 , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 1 , 168 , 0 , 0 , 0 , 16 , 191 , 254 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 244 , 26 , b . subsystem _device _id & 255 , b . subsystem _device _id >> 8 , 0 , 0 , 0 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 ] ; this . pci _space = this . pci _space . concat ( t . zeros ( 256 - this . pci _space . length ) ) ; this . pci _id = b . pci _id ; this . pci _bars = [ ] ; this . name = b . name ; this . driver _feature _select = this . device _feature _select = 0 ; this . device _feature =
new Uint32Array ( 4 ) ; this . driver _feature = new Uint32Array ( 4 ) ; for ( var c of b . common . features ) this . device _feature [ c >>> 5 ] |= 1 << ( c & 31 ) , this . driver _feature [ c >>> 5 ] |= 1 << ( c & 31 ) ; b . common . features . includes ( 32 ) ; this . features _ok = ! 0 ; this . device _status = 0 ; this . config _has _changed = ! 1 ; this . config _generation = 0 ; this . queues = [ ] ; for ( const d of b . common . queues ) this . queues . push ( new S ( a , this , d ) ) ; this . queue _select = 0 ; this . queue _selected = this . queues [ 0 ] ; this . isr _status = 0 ; c = [ ] ; c . push ( this . create _common _capability ( b . common ) ) ; c . push ( this . create _notification _capability ( b . notification ) ) ;
2024-06-28 09:23:02 +02:00
c . push ( this . create _isr _capability ( b . isr _status ) ) ; b . device _specific && c . push ( this . create _device _specific _capability ( b . device _specific ) ) ; this . init _capabilities ( c ) ; a . devices . pci . register _device ( this ) ; this . reset ( ) }
2024-10-02 21:03:04 +02:00
k . prototype . create _common _capability = function ( a ) { return { type : 1 , bar : 0 , port : a . initial _port , use _mmio : ! 1 , offset : 0 , extra : new Uint8Array ( 0 ) , struct : [ { bytes : 4 , name : "device_feature_select" , read : ( ) => this . device _feature _select , write : b => { this . device _feature _select = b } } , { bytes : 4 , name : "device_feature" , read : ( ) => this . device _feature [ this . device _feature _select ] || 0 , write : ( ) => { } } , { bytes : 4 , name : "driver_feature_select" , read : ( ) => this . driver _feature _select , write : b => { this . driver _feature _select = b } } , { bytes : 4 , name : "driver_feature" ,
2024-06-28 09:23:02 +02:00
read : ( ) => this . driver _feature [ this . driver _feature _select ] || 0 , write : b => { const c = this . device _feature [ this . driver _feature _select ] ; this . driver _feature _select < this . driver _feature . length && ( this . driver _feature [ this . driver _feature _select ] = b & c ) ; this . features _ok = this . features _ok && ! ( b & ~ c ) } } , { bytes : 2 , name : "msix_config" , read : ( ) => 65535 , write : ( ) => { } } , { bytes : 2 , name : "num_queues" , read : ( ) => this . queues . length , write : ( ) => { } } , { bytes : 1 , name : "device_status" , read : ( ) => this . device _status , write : b => { 0 === b && this . reset ( ) ; b & ~ this . device _status &
4 && this . device _status & 64 && this . notify _config _changes ( ) ; this . features _ok || ( b &= - 9 ) ; this . device _status = b ; if ( b & ~ this . device _status & 4 ) a . on _driver _ok ( ) } } , { bytes : 1 , name : "config_generation" , read : ( ) => this . config _generation , write : ( ) => { } } , { bytes : 2 , name : "queue_select" , read : ( ) => this . queue _select , write : b => { this . queue _select = b ; this . queue _selected = this . queue _select < this . queues . length ? this . queues [ this . queue _select ] : null } } , { bytes : 2 , name : "queue_size" , read : ( ) => this . queue _selected ? this . queue _selected . size : 0 , write : b =>
2024-10-02 21:03:04 +02:00
{ this . queue _selected && ( b & b - 1 && ( b = 1 << t . int _log2 ( b - 1 ) + 1 ) , b > this . queue _selected . size _supported && ( b = this . queue _selected . size _supported ) , this . queue _selected . set _size ( b ) ) } } , { bytes : 2 , name : "queue_msix_vector" , read : ( ) => 65535 , write : ( ) => { } } , { bytes : 2 , name : "queue_enable" , read : ( ) => this . queue _selected ? this . queue _selected . enabled | 0 : 0 , write : b => { this . queue _selected && 1 === b && this . queue _selected . is _configured ( ) && this . queue _selected . enable ( ) } } , { bytes : 2 , name : "queue_notify_off" , read : ( ) => this . queue _selected ? this . queue _selected . notify _offset :
2024-06-28 09:23:02 +02:00
0 , write : ( ) => { } } , { bytes : 4 , name : "queue_desc (low dword)" , read : ( ) => this . queue _selected ? this . queue _selected . desc _addr : 0 , write : b => { this . queue _selected && ( this . queue _selected . desc _addr = b ) } } , { bytes : 4 , name : "queue_desc (high dword)" , read : ( ) => 0 , write : ( ) => { } } , { bytes : 4 , name : "queue_avail (low dword)" , read : ( ) => this . queue _selected ? this . queue _selected . avail _addr : 0 , write : b => { this . queue _selected && ( this . queue _selected . avail _addr = b ) } } , { bytes : 4 , name : "queue_avail (high dword)" , read : ( ) => 0 , write : ( ) => { } } , { bytes : 4 , name : "queue_used (low dword)" ,
read : ( ) => this . queue _selected ? this . queue _selected . used _addr : 0 , write : b => { this . queue _selected && ( this . queue _selected . used _addr = b ) } } , { bytes : 4 , name : "queue_used (high dword)" , read : ( ) => 0 , write : ( ) => { } } ] } } ;
2024-10-02 21:03:04 +02:00
k . prototype . create _notification _capability = function ( a ) { const b = [ ] ; let c ; c = a . single _handler ? 0 : 2 ; for ( const [ d , e ] of a . handlers . entries ( ) ) b . push ( { bytes : 2 , name : "notify" + d , read : ( ) => 65535 , write : e || ( ( ) => { } ) } ) ; return { type : 2 , bar : 1 , port : a . initial _port , use _mmio : ! 1 , offset : 0 , extra : new Uint8Array ( [ c & 255 , c >> 8 & 255 , c >> 16 & 255 , c >> 24 ] ) , struct : b } } ;
k . prototype . create _isr _capability = function ( a ) { return { type : 3 , bar : 2 , port : a . initial _port , use _mmio : ! 1 , offset : 0 , extra : new Uint8Array ( 0 ) , struct : [ { bytes : 1 , name : "isr_status" , read : ( ) => { const b = this . isr _status ; this . lower _irq ( ) ; return b } , write : ( ) => { } } ] } } ; k . prototype . create _device _specific _capability = function ( a ) { return { type : 4 , bar : 3 , port : a . initial _port , use _mmio : ! 1 , offset : 0 , extra : new Uint8Array ( 0 ) , struct : a . struct } } ;
k . prototype . init _capabilities = function ( a ) { let b = this . pci _space [ 52 ] = 64 ; var c = b ; for ( const e of a ) { a = 16 + e . extra . length ; c = b ; b = c + a ; var d = e . struct . reduce ( ( f , g ) => f + g . bytes , 0 ) ; d += e . offset ; d = 16 > d ? 16 : 1 << t . int _log2 ( d - 1 ) + 1 ; this . pci _bars [ e . bar ] = { size : d } ; this . pci _space [ c ] = 9 ; this . pci _space [ c + 1 ] = b ; this . pci _space [ c + 2 ] = a ; this . pci _space [ c + 3 ] = e . type ; this . pci _space [ c + 4 ] = e . bar ; this . pci _space [ c + 5 ] = 0 ; this . pci _space [ c + 6 ] = 0 ; this . pci _space [ c + 7 ] = 0 ; this . pci _space [ c + 8 ] = e . offset & 255 ; this . pci _space [ c + 9 ] = e . offset >>> 8 & 255 ; this . pci _space [ c +
10 ] = e . offset >>> 16 & 255 ; this . pci _space [ c + 11 ] = e . offset >>> 24 ; this . pci _space [ c + 12 ] = d & 255 ; this . pci _space [ c + 13 ] = d >>> 8 & 255 ; this . pci _space [ c + 14 ] = d >>> 16 & 255 ; this . pci _space [ c + 15 ] = d >>> 24 ; for ( const [ f , g ] of e . extra . entries ( ) ) this . pci _space [ c + 16 + f ] = g ; c = 16 + 4 * e . bar ; this . pci _space [ c ] = e . port & 254 | ! e . use _mmio ; this . pci _space [ c + 1 ] = e . port >>> 8 & 255 ; this . pci _space [ c + 2 ] = e . port >>> 16 & 255 ; this . pci _space [ c + 3 ] = e . port >>> 24 & 255 ; c = e . port + e . offset ; for ( const f of e . struct ) { let g = f . read ; a = f . write ; if ( ! e . use _mmio ) { d = function ( l ) { return g ( l &
- 2 ) >> ( ( l & 1 ) << 3 ) & 255 } ; const h = function ( l ) { return g ( l & - 4 ) >> ( ( l & 3 ) << 3 ) & 255 } ; switch ( f . bytes ) { case 4 : this . cpu . io . register _read ( c , this , h , void 0 , g ) ; this . cpu . io . register _write ( c , this , void 0 , void 0 , a ) ; break ; case 2 : this . cpu . io . register _read ( c , this , d , g ) ; this . cpu . io . register _write ( c , this , void 0 , a ) ; break ; case 1 : this . cpu . io . register _read ( c , this , g ) , this . cpu . io . register _write ( c , this , a ) } } c += f . bytes } } this . pci _space [ b ] = 9 ; this . pci _space [ b + 1 ] = 0 ; this . pci _space [ b + 2 ] = 20 ; this . pci _space [ b + 3 ] = 5 ; this . pci _space [ b + 4 ] = 0 ; this . pci _space [ b +
2024-06-28 09:23:02 +02:00
5 ] = 0 ; this . pci _space [ b + 6 ] = 0 ; this . pci _space [ b + 7 ] = 0 ; this . pci _space [ b + 8 ] = 0 ; this . pci _space [ b + 9 ] = 0 ; this . pci _space [ b + 10 ] = 0 ; this . pci _space [ b + 11 ] = 0 ; this . pci _space [ b + 12 ] = 0 ; this . pci _space [ b + 13 ] = 0 ; this . pci _space [ b + 14 ] = 0 ; this . pci _space [ b + 15 ] = 0 ; this . pci _space [ b + 16 ] = 0 ; this . pci _space [ b + 17 ] = 0 ; this . pci _space [ b + 18 ] = 0 ; this . pci _space [ b + 19 ] = 0 } ;
2024-10-02 21:03:04 +02:00
k . prototype . get _state = function ( ) { let a = [ ] ; a [ 0 ] = this . device _feature _select ; a [ 1 ] = this . driver _feature _select ; a [ 2 ] = this . device _feature ; a [ 3 ] = this . driver _feature ; a [ 4 ] = this . features _ok ; a [ 5 ] = this . device _status ; a [ 6 ] = this . config _has _changed ; a [ 7 ] = this . config _generation ; a [ 8 ] = this . isr _status ; a [ 9 ] = this . queue _select ; return a = a . concat ( this . queues ) } ;
k . prototype . set _state = function ( a ) { this . device _feature _select = a [ 0 ] ; this . driver _feature _select = a [ 1 ] ; this . device _feature = a [ 2 ] ; this . driver _feature = a [ 3 ] ; this . features _ok = a [ 4 ] ; this . device _status = a [ 5 ] ; this . config _has _changed = a [ 6 ] ; this . config _generation = a [ 7 ] ; this . isr _status = a [ 8 ] ; this . queue _select = a [ 9 ] ; let b = 0 ; for ( const c of a . slice ( 10 ) ) this . queues [ b ] . set _state ( c ) , b ++ ; this . queue _selected = this . queues [ this . queue _select ] || null } ;
k . prototype . reset = function ( ) { this . driver _feature _select = this . device _feature _select = 0 ; this . driver _feature . set ( this . device _feature ) ; this . features _ok = ! 0 ; this . queue _select = this . device _status = 0 ; this . queue _selected = this . queues [ 0 ] ; for ( const a of this . queues ) a . reset ( ) ; this . config _has _changed = ! 1 ; this . config _generation = 0 ; this . lower _irq ( ) } ; k . prototype . notify _config _changes = function ( ) { this . config _has _changed = ! 0 ; this . device _status & 4 && this . raise _irq ( 2 ) } ;
k . prototype . update _config _generation = function ( ) { this . config _has _changed && ( this . config _generation ++ , this . config _generation &= 255 , this . config _has _changed = ! 1 ) } ; k . prototype . is _feature _negotiated = function ( a ) { return 0 < ( this . driver _feature [ a >>> 5 ] & 1 << ( a & 31 ) ) } ; k . prototype . needs _reset = function ( ) { this . device _status |= 64 ; this . device _status & 4 && this . notify _config _changes ( ) } ; k . prototype . raise _irq = function ( a ) { A ( a ) ; this . isr _status |= a ; this . pci . raise _irq ( this . pci _id ) } ;
k . prototype . lower _irq = function ( ) { this . isr _status = 0 ; this . pci . lower _irq ( this . pci _id ) } ; function S ( a , b , c ) { this . cpu = a ; this . virtio = b ; this . size _supported = this . size = c . size _supported ; this . mask = this . size - 1 ; this . enabled = ! 1 ; this . notify _offset = c . notify _offset ; this . num _staged _replies = this . used _addr = this . avail _last _idx = this . avail _addr = this . desc _addr = 0 ; this . reset ( ) }
S . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . size ; a [ 1 ] = this . size _supported ; a [ 2 ] = this . enabled ; a [ 3 ] = this . notify _offset ; a [ 4 ] = this . desc _addr ; a [ 5 ] = this . avail _addr ; a [ 6 ] = this . avail _last _idx ; a [ 7 ] = this . used _addr ; a [ 8 ] = this . num _staged _replies ; return a } ;
S . prototype . set _state = function ( a ) { this . size = a [ 0 ] ; this . size _supported = a [ 1 ] ; this . enabled = a [ 2 ] ; this . notify _offset = a [ 3 ] ; this . desc _addr = a [ 4 ] ; this . avail _addr = a [ 5 ] ; this . avail _last _idx = a [ 6 ] ; this . used _addr = a [ 7 ] ; this . num _staged _replies = a [ 8 ] ; this . mask = this . size - 1 } ; S . prototype . reset = function ( ) { this . enabled = ! 1 ; this . num _staged _replies = this . used _addr = this . avail _last _idx = this . avail _addr = this . desc _addr = 0 ; this . set _size ( this . size _supported ) } ;
S . prototype . is _configured = function ( ) { return this . desc _addr && this . avail _addr && this . used _addr } ; S . prototype . enable = function ( ) { this . is _configured ( ) ; this . enabled = ! 0 } ; S . prototype . set _size = function ( a ) { this . size = a ; this . mask = a - 1 } ; S . prototype . count _requests = function ( ) { return this . avail _get _idx ( ) - this . avail _last _idx & this . mask } ; S . prototype . has _request = function ( ) { return ( this . avail _get _idx ( ) & this . mask ) !== this . avail _last _idx } ;
S . prototype . pop _request = function ( ) { this . has _request ( ) ; var a = this . avail _get _entry ( this . avail _last _idx ) ; a = new gb ( this , a ) ; this . avail _last _idx = this . avail _last _idx + 1 & this . mask ; return a } ; S . prototype . push _reply = function ( a ) { const b = this . used _get _idx ( ) + this . num _staged _replies & this . mask ; this . used _set _entry ( b , a . head _idx , a . length _written ) ; this . num _staged _replies ++ } ;
S . prototype . flush _replies = function ( ) { if ( 0 !== this . num _staged _replies ) { var a = this . used _get _idx ( ) + this . num _staged _replies & 65535 ; this . used _set _idx ( a ) ; this . num _staged _replies = 0 ; this . virtio . is _feature _negotiated ( 29 ) ? ( this . avail _get _used _event ( ) , this . virtio . raise _irq ( 1 ) ) : ~ this . avail _get _flags ( ) & 1 && this . virtio . raise _irq ( 1 ) } } ; S . prototype . notify _me _after = function ( a ) { a = this . avail _get _idx ( ) + a & 65535 ; this . used _set _avail _event ( a ) } ;
S . prototype . get _descriptor = function ( a , b ) { return { addr _low : this . cpu . read32s ( a + 16 * b ) , addr _high : this . cpu . read32s ( a + 16 * b + 4 ) , len : this . cpu . read32s ( a + 16 * b + 8 ) , flags : this . cpu . read16 ( a + 16 * b + 12 ) , next : this . cpu . read16 ( a + 16 * b + 14 ) } } ; S . prototype . avail _get _flags = function ( ) { return this . cpu . read16 ( this . avail _addr ) } ; S . prototype . avail _get _idx = function ( ) { return this . cpu . read16 ( this . avail _addr + 2 ) } ; S . prototype . avail _get _entry = function ( a ) { return this . cpu . read16 ( this . avail _addr + 4 + 2 * a ) } ;
S . prototype . avail _get _used _event = function ( ) { return this . cpu . read16 ( this . avail _addr + 4 + 2 * this . size ) } ; S . prototype . used _get _flags = function ( ) { return this . cpu . read16 ( this . used _addr ) } ; S . prototype . used _set _flags = function ( a ) { this . cpu . write16 ( this . used _addr , a ) } ; S . prototype . used _get _idx = function ( ) { return this . cpu . read16 ( this . used _addr + 2 ) } ; S . prototype . used _set _idx = function ( a ) { this . cpu . write16 ( this . used _addr + 2 , a ) } ;
S . prototype . used _set _entry = function ( a , b , c ) { this . cpu . write32 ( this . used _addr + 4 + 8 * a , b ) ; this . cpu . write32 ( this . used _addr + 8 + 8 * a , c ) } ; S . prototype . used _set _avail _event = function ( a ) { this . cpu . write16 ( this . used _addr + 4 + 8 * this . size , a ) } ;
function gb ( a , b ) { this . cpu = a . cpu ; this . virtio = a . virtio ; this . head _idx = b ; this . read _buffers = [ ] ; this . length _readable = this . read _buffer _offset = this . read _buffer _idx = 0 ; this . write _buffers = [ ] ; this . length _writable = this . length _written = this . write _buffer _offset = this . write _buffer _idx = 0 ; let c = a . desc _addr , d = 0 , e = a . size , f = ! 1 ; const g = this . virtio . is _feature _negotiated ( 28 ) ; do { const h = a . get _descriptor ( c , b ) ; A ( h . addr _high , 8 ) ; A ( h . addr _low , 8 ) ; A ( h . len , 8 ) ; A ( h . flags , 4 ) ; A ( h . next , 4 ) ; if ( g && h . flags & 4 ) c = h . addr _low , d = b = 0 , e = h . len / 16 ; else { if ( h . flags &
2 ) f = ! 0 , this . write _buffers . push ( h ) , this . length _writable += h . len ; else { if ( f ) break ; this . read _buffers . push ( h ) ; this . length _readable += h . len } d ++ ; if ( d > e ) break ; if ( h . flags & 1 ) b = h . next ; else break } } while ( 1 ) }
gb . prototype . get _next _blob = function ( a ) { let b = 0 , c = a . length ; for ( ; c && this . read _buffer _idx !== this . read _buffers . length ; ) { var d = this . read _buffers [ this . read _buffer _idx ] ; const e = d . addr _low + this . read _buffer _offset ; d = d . len - this . read _buffer _offset ; d > c ? ( d = c , this . read _buffer _offset += c ) : ( this . read _buffer _idx ++ , this . read _buffer _offset = 0 ) ; a . set ( this . cpu . read _blob ( e , d ) , b ) ; b += d ; c -= d } return b } ;
gb . prototype . set _next _blob = function ( a ) { let b = 0 , c = a . length ; for ( ; c && this . write _buffer _idx !== this . write _buffers . length ; ) { var d = this . write _buffers [ this . write _buffer _idx ] ; const e = d . addr _low + this . write _buffer _offset ; d = d . len - this . write _buffer _offset ; d > c ? ( d = c , this . write _buffer _offset += c ) : ( this . write _buffer _idx ++ , this . write _buffer _offset = 0 ) ; this . cpu . write _blob ( a . subarray ( b , b + d ) , e ) ; b += d ; c -= d } this . length _written += b ; return b } ; function hb ( a , b ) { this . bus = b ; this . rows = 25 ; this . cols = 80 ; this . ports = 4 ; b = [ { size _supported : 16 , notify _offset : 0 } , { size _supported : 16 , notify _offset : 1 } , { size _supported : 16 , notify _offset : 2 } , { size _supported : 16 , notify _offset : 3 } ] ; for ( let c = 1 ; c < this . ports ; ++ c ) b . push ( { size _supported : 16 , notify _offset : 0 } ) , b . push ( { size _supported : 8 , notify _offset : 1 } ) ; this . virtio = new k ( a , { name : "virtio-console" , pci _id : 56 , device _id : 4163 , subsystem _device _id : 3 , common : { initial _port : 47104 , queues : b , features : [ 0 , 1 , 32 ] , on _driver _ok : ( ) => { } } , notification : { initial _port : 47360 ,
single _handler : ! 1 , handlers : [ c => { for ( c = this . virtio . queues [ c ] ; c . count _requests ( ) > c . size - 2 ; ) c . pop _request ( ) } , c => { const d = this . virtio . queues [ c ] , e = 3 < c ? c - 3 >> 1 : 0 ; for ( ; d . has _request ( ) ; ) { const f = d . pop _request ( ) , g = new Uint8Array ( f . length _readable ) ; f . get _next _blob ( g ) ; this . bus . send ( "virtio-console" + e + "-output-bytes" , g ) ; this . Ack ( c , f ) } } , c => { if ( 2 === c ) for ( c = this . virtio . queues [ c ] ; c . count _requests ( ) > c . size - 2 ; ) c . pop _request ( ) } , c => { if ( 3 === c ) for ( var d = this . virtio . queues [ c ] ; d . has _request ( ) ; ) { var e = d . pop _request ( ) , f = new Uint8Array ( e . length _readable ) ;
e . get _next _blob ( f ) ; var g = v . Unmarshall ( [ "w" , "h" , "h" ] , f , { offset : 0 } ) ; f = g [ 0 ] ; g = g [ 1 ] ; this . Ack ( c , e ) ; switch ( g ) { case 0 : for ( e = 0 ; e < this . ports ; ++ e ) this . SendEvent ( e , 1 , 0 ) ; break ; case 3 : this . Ack ( c , e ) ; this . SendEvent ( f , 4 , 1 ) ; this . SendName ( f , "virtio-" + f ) ; this . SendEvent ( f , 6 , 1 ) ; break ; case 6 : this . Ack ( c , e ) ; 0 === f && this . SendWindowSize ( f ) ; break ; default : return } } } ] } , isr _status : { initial _port : 46848 } , device _specific : { initial _port : 46592 , struct : [ { bytes : 2 , name : "cols" , read : ( ) => this . cols , write : ( ) => { } } , { bytes : 2 , name : "rows" , read : ( ) =>
this . rows , write : ( ) => { } } , { bytes : 4 , name : "max_nr_ports" , read : ( ) => this . ports , write : ( ) => { } } , { bytes : 4 , name : "emerg_wr" , read : ( ) => 0 , write : ( ) => { } } ] } } ) ; for ( let c = 0 ; c < this . ports ; ++ c ) { const d = 0 === c ? 0 : 2 * c + 2 ; this . bus . register ( "virtio-console" + c + "-input-bytes" , function ( e ) { var f = this . virtio . queues [ d ] ; f . has _request ( ) && ( f = f . pop _request ( ) , this . Send ( d , f , new Uint8Array ( e ) ) ) } , this ) ; this . bus . register ( "virtio-console" + c + "-resize" , function ( e ) { this . cols = e [ 0 ] ; this . rows = e [ 1 ] ; this . virtio . queues [ 2 ] . is _configured ( ) && this . virtio . queues [ 2 ] . has _request ( ) &&
this . SendWindowSize ( c ) } , this ) } } hb . prototype . SendWindowSize = function ( a ) { const b = this . virtio . queues [ 2 ] . pop _request ( ) , c = new Uint8Array ( 12 ) ; v . Marshall ( [ "w" , "h" , "h" , "h" , "h" ] , [ a , 5 , 0 , this . rows , this . cols ] , c , 0 ) ; this . Send ( 2 , b , c ) } ; hb . prototype . SendName = function ( a , b ) { const c = this . virtio . queues [ 2 ] . pop _request ( ) ; b = ( new TextEncoder ) . encode ( b ) ; const d = new Uint8Array ( 8 + b . length + 1 ) ; v . Marshall ( [ "w" , "h" , "h" ] , [ a , 7 , 1 ] , d , 0 ) ; for ( a = 0 ; a < b . length ; ++ a ) d [ a + 8 ] = b [ a ] ; d [ 8 + b . length ] = 0 ; this . Send ( 2 , c , d ) } ;
hb . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . virtio ; a [ 1 ] = this . rows ; a [ 2 ] = this . cols ; a [ 3 ] = this . ports ; return a } ; hb . prototype . set _state = function ( a ) { this . virtio . set _state ( a [ 0 ] ) ; this . rows = a [ 1 ] ; this . cols = a [ 2 ] ; this . ports = a [ 3 ] } ; hb . prototype . reset = function ( ) { this . virtio . reset ( ) } ; hb . prototype . SendEvent = function ( a , b , c ) { const d = this . virtio . queues [ 2 ] . pop _request ( ) , e = new Uint8Array ( 8 ) ; v . Marshall ( [ "w" , "h" , "h" ] , [ a , b , c ] , e , 0 ) ; this . Send ( 2 , d , e ) } ;
hb . prototype . Send = function ( a , b , c ) { b . set _next _blob ( c ) ; this . virtio . queues [ a ] . push _reply ( b ) ; this . virtio . queues [ a ] . flush _replies ( ) } ; hb . prototype . Ack = function ( a , b ) { b . set _next _blob ( new Uint8Array ( 0 ) ) ; this . virtio . queues [ a ] . push _reply ( b ) ; this . virtio . queues [ a ] . flush _replies ( ) } ; function ib ( 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 ( ) | 0 , 255 * Math . random ( ) | 0 ] ) ; this . bus . send ( "net" + this . id + "-mac" , Na ( this . mac ) ) ; b = [ ] ; for ( c = 0 ; c < this . pairs ; ++ c ) b . push ( { size _supported : 32 , notify _offset : 0 } ) , b . push ( { size _supported : 32 , notify _offset : 1 } ) ; b . push ( { size _supported : 16 , notify _offset : 2 } ) ; this . virtio = new k ( 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 => { d = this . virtio . queues [ d ] ; var e = d . avail _get _entry ( d . avail _last _idx ) ; e = new gb ( d , e ) ; d . avail _last _idx = d . avail _last _idx + 1 & d . mask ; this . virtio . queues [ 0 ] . push _reply ( e ) ; this . virtio . queues [ 0 ] . flush _replies ( ) } , d => { const e = this . virtio . queues [ d ] ; 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 ) for ( var e = this . virtio . queues [ d ] ; e . has _request ( ) ; ) { const f = e . pop _request ( ) , g = new Uint8Array ( f . length _readable ) ; f . get _next _blob ( g ) ; const h = v . Unmarshall ( [ "b" , "b" ] , g , { offset : 0 } ) ; switch ( h [ 0 ] << 8 | h [ 1 ] ) { case 1024 : v . Unmarshall ( [ "h" ] , g , { offset : 2 } ) ; this . Send ( d , f , new Uint8Array ( [ 0 ] ) ) ; break ; case 257 : this . mac = g . subarray ( 2 , 8 ) ; this . Send ( d ,
f , new Uint8Array ( [ 0 ] ) ) ; this . bus . send ( "net" + this . id + "-mac" , Na ( this . mac ) ) ; break ; default : this . Send ( d , f , 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_" + 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 ) , this . virtio . queues [ 0 ] . push _reply ( d ) , this . virtio . queues [ 0 ] . flush _replies ( ) ) : console . log ( "No buffer to write into!" ) } , this ) }
ib . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . virtio ; a [ 1 ] = this . id ; this . preserve _mac _from _state _image && ( this . mac = a [ 2 ] , this . bus . send ( "net" + this . id + "-mac" , Na ( this . mac ) ) ) ; return a } ; ib . prototype . set _state = function ( a ) { this . virtio . set _state ( a [ 0 ] ) } ; ib . prototype . reset = function ( ) { this . virtio . reset ( ) } ; ib . prototype . Send = function ( a , b , c ) { b . set _next _blob ( c ) ; this . virtio . queues [ a ] . push _reply ( b ) ; this . virtio . queues [ a ] . flush _replies ( ) } ; ib . prototype . Ack = function ( a , b ) { this . virtio . queues [ a ] . push _reply ( b ) ; this . virtio . queues [ a ] . flush _replies ( ) } ; var jb = { } ; function kb ( ) { this . listeners = { } ; this . pair = void 0 } kb . prototype . register = function ( a , b , c ) { var d = this . listeners [ a ] ; void 0 === d && ( d = this . listeners [ a ] = [ ] ) ; d . push ( { fn : b , this _value : c } ) } ; kb . prototype . unregister = function ( a , b ) { var c = this . listeners [ a ] ; void 0 !== c && ( this . listeners [ a ] = c . filter ( function ( d ) { return d . fn !== b } ) ) } ; kb . prototype . send = function ( a , b ) { if ( this . pair && ( a = this . pair . listeners [ a ] , void 0 !== a ) ) for ( var c = 0 ; c < a . length ; c ++ ) { var d = a [ c ] ; d . fn . call ( d . this _value , b ) } } ;
kb . prototype . send _async = function ( a , b ) { setTimeout ( this . send . bind ( this , a , b ) , 0 ) } ; jb . create = function ( ) { var a = new kb , b = new kb ; a . pair = b ; b . pair = a ; return [ a , b ] } ; function qa ( ) { } function ra ( ) { } ; function G ( a , b , c ) { this . stop _idling = c ; this . wm = b ; this . wasm _patch ( ) ; this . create _jit _imports ( ) ; this . wasm _memory = b = this . wm . exports . memory ; this . memory _size = t . view ( Uint32Array , b , 812 , 1 ) ; this . mem8 = new Uint8Array ( 0 ) ; this . mem32s = new Int32Array ( this . mem8 . buffer ) ; this . segment _is _null = t . view ( Uint8Array , b , 724 , 8 ) ; this . segment _offsets = t . view ( Int32Array , b , 736 , 8 ) ; this . segment _limits = t . view ( Uint32Array , b , 768 , 8 ) ; this . segment _access _bytes = t . view ( Uint8Array , b , 512 , 8 ) ; this . protected _mode = t . view ( Int32Array , b , 800 , 1 ) ; this . idtr _size =
t . view ( Int32Array , b , 564 , 1 ) ; this . idtr _offset = t . view ( Int32Array , b , 568 , 1 ) ; this . gdtr _size = t . view ( Int32Array , b , 572 , 1 ) ; this . gdtr _offset = t . view ( Int32Array , b , 576 , 1 ) ; this . tss _size _32 = t . view ( Int32Array , b , 1128 , 1 ) ; this . page _fault = t . view ( Uint32Array , b , 540 , 8 ) ; this . cr = t . view ( Int32Array , b , 580 , 8 ) ; this . cpl = t . view ( Uint8Array , b , 612 , 1 ) ; this . is _32 = t . view ( Int32Array , b , 804 , 1 ) ; this . stack _size _32 = t . view ( Int32Array , b , 808 , 1 ) ; this . in _hlt = t . view ( Uint8Array , b , 616 , 1 ) ; this . last _virt _eip = t . view ( Int32Array , b , 620 , 1 ) ; this . eip _phys = t . view ( Int32Array ,
b , 624 , 1 ) ; this . sysenter _cs = t . view ( Int32Array , b , 636 , 1 ) ; this . sysenter _esp = t . view ( Int32Array , b , 640 , 1 ) ; this . sysenter _eip = t . view ( Int32Array , b , 644 , 1 ) ; this . prefixes = t . view ( Int32Array , b , 648 , 1 ) ; this . flags = t . view ( Int32Array , b , 120 , 1 ) ; this . flags _changed = t . view ( Int32Array , b , 100 , 1 ) ; this . last _op _size = t . view ( Int32Array , b , 96 , 1 ) ; this . last _op1 = t . view ( Int32Array , b , 104 , 1 ) ; this . last _result = t . view ( Int32Array , b , 112 , 1 ) ; this . current _tsc = t . view ( Uint32Array , b , 960 , 2 ) ; this . devices = { } ; this . instruction _pointer = t . view ( Int32Array ,
b , 556 , 1 ) ; this . previous _ip = t . view ( Int32Array , b , 560 , 1 ) ; this . apic _enabled = t . view ( Uint8Array , b , 548 , 1 ) ; this . acpi _enabled = t . view ( Uint8Array , b , 552 , 1 ) ; this . memory _map _read8 = [ ] ; this . memory _map _write8 = [ ] ; this . memory _map _read32 = [ ] ; this . memory _map _write32 = [ ] ; this . bios = { main : null , vga : null } ; this . instruction _counter = t . view ( Uint32Array , b , 664 , 1 ) ; this . reg32 = t . view ( Int32Array , b , 64 , 8 ) ; this . fpu _st = t . view ( Int32Array , b , 1152 , 32 ) ; this . fpu _stack _empty = t . view ( Uint8Array , b , 816 , 1 ) ; this . fpu _stack _empty [ 0 ] = 255 ; this . fpu _stack _ptr =
t . view ( Uint8Array , b , 1032 , 1 ) ; this . fpu _stack _ptr [ 0 ] = 0 ; this . fpu _control _word = t . view ( Uint16Array , b , 1036 , 1 ) ; this . fpu _control _word [ 0 ] = 895 ; this . fpu _status _word = t . view ( Uint16Array , b , 1040 , 1 ) ; this . fpu _status _word [ 0 ] = 0 ; this . fpu _ip = t . view ( Int32Array , b , 1048 , 1 ) ; this . fpu _ip [ 0 ] = 0 ; this . fpu _ip _selector = t . view ( Int32Array , b , 1052 , 1 ) ; this . fpu _ip _selector [ 0 ] = 0 ; this . fpu _opcode = t . view ( Int32Array , b , 1044 , 1 ) ; this . fpu _opcode [ 0 ] = 0 ; this . fpu _dp = t . view ( Int32Array , b , 1056 , 1 ) ; this . fpu _dp [ 0 ] = 0 ; this . fpu _dp _selector = t . view ( Int32Array ,
b , 1060 , 1 ) ; this . fpu _dp _selector [ 0 ] = 0 ; this . reg _xmm32s = t . view ( Int32Array , b , 832 , 32 ) ; this . mxcsr = t . view ( Int32Array , b , 824 , 1 ) ; this . sreg = t . view ( Uint16Array , b , 668 , 8 ) ; this . dreg = t . view ( Int32Array , b , 684 , 8 ) ; this . reg _pdpte = t . view ( Int32Array , b , 968 , 8 ) ; this . svga _dirty _bitmap _min _offset = t . view ( Uint32Array , b , 716 , 1 ) ; this . svga _dirty _bitmap _max _offset = t . view ( Uint32Array , b , 720 , 1 ) ; this . fw _value = [ ] ; this . fw _pointer = 0 ; this . option _roms = [ ] ; this . io = void 0 ; this . bus = a ; this . set _tsc ( 0 , 0 ) ; this . debug _init ( ) }
G . prototype . clear _opstats = function ( ) { ( new Uint8Array ( this . wasm _memory . buffer , 32768 , 131072 ) ) . fill ( 0 ) ; this . wm . exports . profiler _init ( ) } ; G . prototype . create _jit _imports = function ( ) { const a = Object . create ( null ) ; a . m = this . wm . exports . memory ; for ( const b of Object . keys ( this . wm . exports ) ) b . startsWith ( "_" ) || b . startsWith ( "zstd" ) || b . endsWith ( "_js" ) || ( a [ b ] = this . wm . exports [ b ] ) ; this . jit _imports = a } ;
G . prototype . wasm _patch = function ( ) { const a = c => this . wm . exports [ c ] , b = c => { const d = a ( c ) ; console . assert ( d , "Missing import: " + c ) ; return d } ; this . reset _cpu = b ( "reset_cpu" ) ; this . getiopl = b ( "getiopl" ) ; this . get _eflags = b ( "get_eflags" ) ; this . handle _irqs = b ( "handle_irqs" ) ; this . main _loop = b ( "main_loop" ) ; this . set _jit _config = b ( "set_jit_config" ) ; this . read8 = b ( "read8" ) ; this . read16 = b ( "read16" ) ; this . read32s = b ( "read32s" ) ; this . write8 = b ( "write8" ) ; this . write16 = b ( "write16" ) ; this . write32 = b ( "write32" ) ; this . in _mapped _range = b ( "in_mapped_range" ) ;
2024-06-28 09:23:02 +02:00
this . fpu _load _tag _word = b ( "fpu_load_tag_word" ) ; this . fpu _load _status _word = b ( "fpu_load_status_word" ) ; this . fpu _get _sti _f64 = b ( "fpu_get_sti_f64" ) ; this . translate _address _system _read = b ( "translate_address_system_read_js" ) ; this . get _seg _cs = b ( "get_seg_cs" ) ; this . get _real _eip = b ( "get_real_eip" ) ; this . clear _tlb = b ( "clear_tlb" ) ; this . full _clear _tlb = b ( "full_clear_tlb" ) ; this . update _state _flags = b ( "update_state_flags" ) ; this . set _tsc = b ( "set_tsc" ) ; this . store _current _tsc = b ( "store_current_tsc" ) ; this . set _cpuid _level = b ( "set_cpuid_level" ) ;
this . pic _set _irq = b ( "pic_set_irq" ) ; this . pic _clear _irq = b ( "pic_clear_irq" ) ; this . jit _clear _cache = b ( "jit_clear_cache_js" ) ; this . jit _dirty _cache = b ( "jit_dirty_cache" ) ; this . codegen _finalize _finished = b ( "codegen_finalize_finished" ) ; this . allocate _memory = b ( "allocate_memory" ) ; this . zero _memory = b ( "zero_memory" ) ; this . svga _allocate _memory = b ( "svga_allocate_memory" ) ; this . svga _allocate _dest _buffer = b ( "svga_allocate_dest_buffer" ) ; this . svga _fill _pixel _buffer = b ( "svga_fill_pixel_buffer" ) ; this . svga _mark _dirty = b ( "svga_mark_dirty" ) ;
this . get _pic _addr _master = b ( "get_pic_addr_master" ) ; this . get _pic _addr _slave = b ( "get_pic_addr_slave" ) ; this . zstd _create _ctx = b ( "zstd_create_ctx" ) ; this . zstd _get _src _ptr = b ( "zstd_get_src_ptr" ) ; this . zstd _free _ctx = b ( "zstd_free_ctx" ) ; this . zstd _read = b ( "zstd_read" ) ; this . zstd _read _free = b ( "zstd_read_free" ) ; this . port20 _read = b ( "port20_read" ) ; this . port21 _read = b ( "port21_read" ) ; this . portA0 _read = b ( "portA0_read" ) ; this . portA1 _read = b ( "portA1_read" ) ; this . port20 _write = b ( "port20_write" ) ; this . port21 _write = b ( "port21_write" ) ; this . portA0 _write =
2024-10-02 21:03:04 +02:00
b ( "portA0_write" ) ; this . portA1 _write = b ( "portA1_write" ) ; this . port4D0 _read = b ( "port4D0_read" ) ; this . port4D1 _read = b ( "port4D1_read" ) ; this . port4D0 _write = b ( "port4D0_write" ) ; this . port4D1 _write = b ( "port4D1_write" ) } ; G . prototype . jit _force _generate = function ( a ) { this . jit _force _generate _unsafe && this . jit _force _generate _unsafe ( a ) } ; G . prototype . jit _clear _func = function ( a ) { this . wm . wasm _table . set ( a + 1024 , null ) } ; G . prototype . jit _clear _all _funcs = function ( ) { const a = this . wm . wasm _table ; for ( let b = 0 ; 900 > b ; b ++ ) a . set ( 1024 + b , null ) } ;
G . prototype . get _state = function ( ) { var a = [ ] ; a [ 0 ] = this . memory _size [ 0 ] ; a [ 1 ] = new Uint8Array ( [ ... this . segment _is _null , ... this . segment _access _bytes ] ) ; a [ 2 ] = this . segment _offsets ; a [ 3 ] = this . segment _limits ; a [ 4 ] = this . protected _mode [ 0 ] ; a [ 5 ] = this . idtr _offset [ 0 ] ; a [ 6 ] = this . idtr _size [ 0 ] ; a [ 7 ] = this . gdtr _offset [ 0 ] ; a [ 8 ] = this . gdtr _size [ 0 ] ; a [ 9 ] = this . page _fault [ 0 ] ; a [ 10 ] = this . cr ; a [ 11 ] = this . cpl [ 0 ] ; a [ 13 ] = this . is _32 [ 0 ] ; a [ 16 ] = this . stack _size _32 [ 0 ] ; a [ 17 ] = this . in _hlt [ 0 ] ; a [ 18 ] = this . last _virt _eip [ 0 ] ; a [ 19 ] = this . eip _phys [ 0 ] ; a [ 22 ] = this . sysenter _cs [ 0 ] ;
2024-06-28 09:23:02 +02:00
a [ 23 ] = this . sysenter _eip [ 0 ] ; a [ 24 ] = this . sysenter _esp [ 0 ] ; a [ 25 ] = this . prefixes [ 0 ] ; a [ 26 ] = this . flags [ 0 ] ; a [ 27 ] = this . flags _changed [ 0 ] ; a [ 28 ] = this . last _op1 [ 0 ] ; a [ 30 ] = this . last _op _size [ 0 ] ; a [ 37 ] = this . instruction _pointer [ 0 ] ; a [ 38 ] = this . previous _ip [ 0 ] ; a [ 39 ] = this . reg32 ; a [ 40 ] = this . sreg ; a [ 41 ] = this . dreg ; a [ 42 ] = this . reg _pdpte ; this . store _current _tsc ( ) ; a [ 43 ] = this . current _tsc ; a [ 45 ] = this . devices . virtio _9p ; a [ 46 ] = this . devices . apic ; a [ 47 ] = this . devices . rtc ; a [ 48 ] = this . devices . pci ; a [ 49 ] = this . devices . dma ; a [ 50 ] = this . devices . acpi ; a [ 52 ] =
this . devices . vga ; a [ 53 ] = this . devices . ps2 ; a [ 54 ] = this . devices . uart0 ; a [ 55 ] = this . devices . fdc ; a [ 56 ] = this . devices . cdrom ; a [ 57 ] = this . devices . hda ; a [ 58 ] = this . devices . pit ; a [ 59 ] = this . devices . net ; a [ 60 ] = this . get _state _pic ( ) ; a [ 61 ] = this . devices . sb16 ; a [ 62 ] = this . fw _value ; a [ 63 ] = this . devices . ioapic ; a [ 64 ] = this . tss _size _32 [ 0 ] ; a [ 66 ] = this . reg _xmm32s ; a [ 67 ] = this . fpu _st ; a [ 68 ] = this . fpu _stack _empty [ 0 ] ; a [ 69 ] = this . fpu _stack _ptr [ 0 ] ; a [ 70 ] = this . fpu _control _word [ 0 ] ; a [ 71 ] = this . fpu _ip [ 0 ] ; a [ 72 ] = this . fpu _ip _selector [ 0 ] ; a [ 73 ] = this . fpu _dp [ 0 ] ;
2024-10-02 21:03:04 +02:00
a [ 74 ] = this . fpu _dp _selector [ 0 ] ; a [ 75 ] = this . fpu _opcode [ 0 ] ; const { packed _memory : b , bitmap : c } = this . pack _memory ( ) ; a [ 77 ] = b ; a [ 78 ] = new Uint8Array ( c . get _buffer ( ) ) ; a [ 79 ] = this . devices . uart1 ; a [ 80 ] = this . devices . uart2 ; a [ 81 ] = this . devices . uart3 ; a [ 82 ] = this . devices . virtio _console ; a [ 83 ] = this . devices . virtio _net ; return a } ;
G . prototype . get _state _pic = function ( ) { const a = new Uint8Array ( this . wasm _memory . buffer , this . get _pic _addr _master ( ) , 13 ) , b = new Uint8Array ( this . wasm _memory . buffer , this . get _pic _addr _slave ( ) , 13 ) , c = [ ] , d = [ ] ; c [ 0 ] = a [ 0 ] ; c [ 1 ] = a [ 1 ] ; c [ 2 ] = a [ 2 ] ; c [ 3 ] = a [ 3 ] ; c [ 4 ] = a [ 4 ] ; c [ 5 ] = d ; c [ 6 ] = a [ 6 ] ; c [ 7 ] = a [ 7 ] ; c [ 8 ] = a [ 8 ] ; c [ 9 ] = a [ 9 ] ; c [ 10 ] = a [ 10 ] ; c [ 11 ] = a [ 11 ] ; c [ 12 ] = a [ 12 ] ; d [ 0 ] = b [ 0 ] ; d [ 1 ] = b [ 1 ] ; d [ 2 ] = b [ 2 ] ; d [ 3 ] = b [ 3 ] ; d [ 4 ] = b [ 4 ] ; d [ 5 ] = null ; d [ 6 ] = b [ 6 ] ; d [ 7 ] = b [ 7 ] ; d [ 8 ] = b [ 8 ] ; d [ 9 ] = b [ 9 ] ; d [ 10 ] = b [ 10 ] ; d [ 11 ] = b [ 11 ] ; d [ 12 ] = b [ 12 ] ; return c } ;
G . prototype . set _state = function ( a ) { this . memory _size [ 0 ] = a [ 0 ] ; this . mem8 . length !== this . memory _size [ 0 ] && console . warn ( "Note: Memory size mismatch. we=" + this . mem8 . length + " state=" + this . memory _size [ 0 ] ) ; 8 === a [ 1 ] . length ? ( this . segment _is _null . set ( a [ 1 ] ) , this . segment _access _bytes . fill ( 242 ) , this . segment _access _bytes [ 1 ] = 250 ) : 16 === a [ 1 ] . length && ( this . segment _is _null . set ( a [ 1 ] . subarray ( 0 , 8 ) ) , this . segment _access _bytes . set ( a [ 1 ] . subarray ( 8 , 16 ) ) ) ; this . segment _offsets . set ( a [ 2 ] ) ; this . segment _limits . set ( a [ 3 ] ) ; this . protected _mode [ 0 ] =
2024-06-28 09:23:02 +02:00
a [ 4 ] ; this . idtr _offset [ 0 ] = a [ 5 ] ; this . idtr _size [ 0 ] = a [ 6 ] ; this . gdtr _offset [ 0 ] = a [ 7 ] ; this . gdtr _size [ 0 ] = a [ 8 ] ; this . page _fault [ 0 ] = a [ 9 ] ; this . cr . set ( a [ 10 ] ) ; this . cpl [ 0 ] = a [ 11 ] ; this . is _32 [ 0 ] = a [ 13 ] ; this . stack _size _32 [ 0 ] = a [ 16 ] ; this . in _hlt [ 0 ] = a [ 17 ] ; this . last _virt _eip [ 0 ] = a [ 18 ] ; this . eip _phys [ 0 ] = a [ 19 ] ; this . sysenter _cs [ 0 ] = a [ 22 ] ; this . sysenter _eip [ 0 ] = a [ 23 ] ; this . sysenter _esp [ 0 ] = a [ 24 ] ; this . prefixes [ 0 ] = a [ 25 ] ; this . flags [ 0 ] = a [ 26 ] ; this . flags _changed [ 0 ] = a [ 27 ] ; this . last _op1 [ 0 ] = a [ 28 ] ; this . last _op _size [ 0 ] = a [ 30 ] ; this . instruction _pointer [ 0 ] =
a [ 37 ] ; this . previous _ip [ 0 ] = a [ 38 ] ; this . reg32 . set ( a [ 39 ] ) ; this . sreg . set ( a [ 40 ] ) ; this . dreg . set ( a [ 41 ] ) ; a [ 42 ] && this . reg _pdpte . set ( a [ 42 ] ) ; this . set _tsc ( a [ 43 ] [ 0 ] , a [ 43 ] [ 1 ] ) ; this . devices . virtio _9p && this . devices . virtio _9p . set _state ( a [ 45 ] ) ; this . devices . apic && this . devices . apic . set _state ( a [ 46 ] ) ; this . devices . rtc && this . devices . rtc . set _state ( a [ 47 ] ) ; this . devices . pci && this . devices . pci . set _state ( a [ 48 ] ) ; this . devices . dma && this . devices . dma . set _state ( a [ 49 ] ) ; this . devices . acpi && this . devices . acpi . set _state ( a [ 50 ] ) ; this . devices . vga &&
this . devices . vga . set _state ( a [ 52 ] ) ; this . devices . ps2 && this . devices . ps2 . set _state ( a [ 53 ] ) ; this . devices . uart0 && this . devices . uart0 . set _state ( a [ 54 ] ) ; this . devices . fdc && this . devices . fdc . set _state ( a [ 55 ] ) ; this . devices . cdrom && this . devices . cdrom . set _state ( a [ 56 ] ) ; this . devices . hda && this . devices . hda . set _state ( a [ 57 ] ) ; this . devices . pit && this . devices . pit . set _state ( a [ 58 ] ) ; this . devices . net && this . devices . net . set _state ( a [ 59 ] ) ; this . set _state _pic ( a [ 60 ] ) ; this . devices . sb16 && this . devices . sb16 . set _state ( a [ 61 ] ) ; this . devices . uart1 &&
2024-10-02 21:03:04 +02:00
this . devices . uart1 . set _state ( a [ 79 ] ) ; this . devices . uart2 && this . devices . uart2 . set _state ( a [ 80 ] ) ; this . devices . uart3 && this . devices . uart3 . set _state ( a [ 81 ] ) ; this . devices . virtio _console && this . devices . virtio _console . set _state ( a [ 82 ] ) ; this . devices . virtio _net && this . devices . virtio _net . set _state ( a [ 83 ] ) ; this . fw _value = a [ 62 ] ; this . devices . ioapic && this . devices . ioapic . set _state ( a [ 63 ] ) ; this . tss _size _32 [ 0 ] = a [ 64 ] ; this . reg _xmm32s . set ( a [ 66 ] ) ; this . fpu _st . set ( a [ 67 ] ) ; this . fpu _stack _empty [ 0 ] = a [ 68 ] ; this . fpu _stack _ptr [ 0 ] = a [ 69 ] ; this . fpu _control _word [ 0 ] =
a [ 70 ] ; this . fpu _ip [ 0 ] = a [ 71 ] ; this . fpu _ip _selector [ 0 ] = a [ 72 ] ; this . fpu _dp [ 0 ] = a [ 73 ] ; this . fpu _dp _selector [ 0 ] = a [ 74 ] ; this . fpu _opcode [ 0 ] = a [ 75 ] ; const b = new t . Bitmap ( a [ 78 ] . buffer ) ; this . unpack _memory ( b , a [ 77 ] ) ; this . update _state _flags ( ) ; this . full _clear _tlb ( ) ; this . jit _clear _cache ( ) } ;
G . prototype . set _state _pic = function ( a ) { const b = new Uint8Array ( this . wasm _memory . buffer , this . get _pic _addr _master ( ) , 13 ) , c = new Uint8Array ( this . wasm _memory . buffer , this . get _pic _addr _slave ( ) , 13 ) ; b [ 0 ] = a [ 0 ] ; b [ 1 ] = a [ 1 ] ; b [ 2 ] = a [ 2 ] ; b [ 3 ] = a [ 3 ] ; b [ 4 ] = a [ 4 ] ; const d = a [ 5 ] ; b [ 6 ] = a [ 6 ] ; b [ 7 ] = a [ 7 ] ; b [ 8 ] = a [ 8 ] ; b [ 9 ] = a [ 9 ] ; b [ 10 ] = a [ 10 ] ; b [ 11 ] = a [ 11 ] ; b [ 12 ] = a [ 12 ] ; c [ 0 ] = d [ 0 ] ; c [ 1 ] = d [ 1 ] ; c [ 2 ] = d [ 2 ] ; c [ 3 ] = d [ 3 ] ; c [ 4 ] = d [ 4 ] ; c [ 6 ] = d [ 6 ] ; c [ 7 ] = d [ 7 ] ; c [ 8 ] = d [ 8 ] ; c [ 9 ] = d [ 9 ] ; c [ 10 ] = d [ 10 ] ; c [ 11 ] = d [ 11 ] ; c [ 12 ] = d [ 12 ] } ;
G . prototype . pack _memory = function ( ) { var a = this . mem8 . length >> 12 , b = [ ] ; for ( var c = 0 ; c < a ; c ++ ) { var d = c << 12 ; d = this . mem32s . subarray ( d >> 2 , d + 4096 >> 2 ) ; let e = ! 0 ; for ( let f = 0 ; f < d . length ; f ++ ) if ( 0 !== d [ f ] ) { e = ! 1 ; break } e || b . push ( c ) } a = new t . Bitmap ( a ) ; c = new Uint8Array ( b . length << 12 ) ; for ( const [ e , f ] of b . entries ( ) ) a . set ( f , 1 ) , b = f << 12 , b = this . mem8 . subarray ( b , b + 4096 ) , c . set ( b , e << 12 ) ; return { bitmap : a , packed _memory : c } } ;
G . prototype . unpack _memory = function ( a , b ) { this . zero _memory ( this . memory _size [ 0 ] ) ; const c = this . memory _size [ 0 ] >> 12 ; let d = 0 ; for ( let f = 0 ; f < c ; f ++ ) if ( a . get ( f ) ) { var e = d << 12 ; e = b . subarray ( e , e + 4096 ) ; this . mem8 . set ( e , f << 12 ) ; d ++ } } ; G . prototype . reboot _internal = function ( ) { this . reset _cpu ( ) ; this . fw _value = [ ] ; this . devices . virtio _9p && this . devices . virtio _9p . reset ( ) ; this . devices . virtio _console && this . devices . virtio _console . reset ( ) ; this . devices . virtio _net && this . devices . virtio _net . reset ( ) ; this . load _bios ( ) } ;
G . prototype . reset _memory = function ( ) { this . mem8 . fill ( 0 ) } ; G . prototype . create _memory = function ( a , b ) { a < b ? a = b : 0 > ( a | 0 ) && ( a = Math . pow ( 2 , 31 ) - 131072 ) ; a = ( a - 1 | 131071 ) + 1 | 0 ; console . assert ( 0 === this . memory _size [ 0 ] , "Expected uninitialised memory" ) ; this . memory _size [ 0 ] = a ; b = this . allocate _memory ( a ) ; this . mem8 = t . view ( Uint8Array , this . wasm _memory , b , a ) ; this . mem32s = t . view ( Uint32Array , this . wasm _memory , b , a >> 2 ) } ;
G . prototype . init = function ( a , b ) { this . create _memory ( a . memory _size || 67108864 , a . initrd ? 67108864 : 1048576 ) ; a . disable _jit && this . set _jit _config ( 0 , 1 ) ; a . cpuid _level && this . set _cpuid _level ( a . cpuid _level ) ; this . acpi _enabled [ 0 ] = + a . acpi ; this . reset _cpu ( ) ; var c = new B ( this ) ; this . io = c ; this . bios . main = a . bios ; this . bios . vga = a . vga _bios ; this . load _bios ( ) ; if ( a . bzimage ) { const e = lb ( this . mem8 , a . bzimage , a . initrd , a . cmdline || "" ) ; e && this . option _roms . push ( e ) } c . register _read ( 179 , this , function ( ) { return 0 } ) ; var d = 0 ; c . register _read ( 146 ,
this , function ( ) { return d } ) ; c . register _write ( 146 , this , function ( e ) { d = e } ) ; c . register _read ( 1297 , this , function ( ) { return this . fw _pointer < this . fw _value . length ? this . fw _value [ this . fw _pointer ++ ] : 0 } ) ; c . register _write ( 1296 , this , void 0 , function ( e ) { function f ( l ) { return new Uint8Array ( Int32Array . of ( l ) . buffer ) } function g ( l ) { return l >> 8 | l << 8 & 65280 } function h ( l ) { return l << 24 | l << 8 & 16711680 | l >> 8 & 65280 | l >>> 24 } qa ( "bios config port, index=" + A ( e ) ) ; this . fw _pointer = 0 ; if ( 0 === e ) this . fw _value = f ( 1431127377 ) ; else if ( 1 === e ) this . fw _value =
f ( 0 ) ; else if ( 3 === e ) this . fw _value = f ( this . memory _size [ 0 ] ) ; else if ( 5 === e ) this . fw _value = f ( 1 ) ; else if ( 15 === e ) this . fw _value = f ( 1 ) ; else if ( 13 === e ) this . fw _value = new Uint8Array ( 16 ) ; else if ( 25 === e ) { e = new Int32Array ( 4 + 64 * this . option _roms . length ) ; const l = new Uint8Array ( e . buffer ) ; e [ 0 ] = h ( this . option _roms . length ) ; for ( let m = 0 ; m < this . option _roms . length ; m ++ ) { const { name : n , data : p } = this . option _roms [ m ] , q = 4 + 64 * m ; e [ q + 0 >> 2 ] = h ( p . length ) ; e [ q + 4 >> 2 ] = g ( 49152 + m ) ; for ( let r = 0 ; r < n . length ; r ++ ) l [ q + 8 + r ] = n . charCodeAt ( r ) } this . fw _value =
l } else 32768 <= e && 49152 > e ? this . fw _value = f ( 0 ) : 49152 <= e && e - 49152 < this . option _roms . length ? this . fw _value = this . option _roms [ e - 49152 ] . data : ( qa ( "Warning: Unimplemented fw index: " + A ( e ) ) , this . fw _value = f ( 0 ) ) } ) ; c . register _read ( 32 , this , this . port20 _read ) ; c . register _read ( 33 , this , this . port21 _read ) ; c . register _read ( 160 , this , this . portA0 _read ) ; c . register _read ( 161 , this , this . portA1 _read ) ; c . register _write ( 32 , this , this . port20 _write ) ; c . register _write ( 33 , this , this . port21 _write ) ; c . register _write ( 160 , this , this . portA0 _write ) ;
c . register _write ( 161 , this , this . portA1 _write ) ; c . register _read ( 1232 , this , this . port4D0 _read ) ; c . register _read ( 1233 , this , this . port4D1 _read ) ; c . register _write ( 1232 , this , this . port4D0 _write ) ; c . register _write ( 1233 , this , this . port4D1 _write ) ; this . devices = { } ; a . load _devices && ( this . devices . pci = new sa ( this ) , this . acpi _enabled [ 0 ] && ( this . devices . ioapic = new Da ( this ) , this . devices . apic = new Ca ( this ) , this . devices . acpi = new Ba ( this ) ) , this . devices . rtc = new ya ( this ) , this . fill _cmos ( this . devices . rtc , a ) , this . devices . dma = new L ( this ) ,
this . devices . vga = new N ( this , b , a . screen , a . vga _memory _size || 8388608 , a . screen _options || { } ) , this . devices . ps2 = new xa ( this , b ) , this . devices . uart0 = new za ( this , 1016 , b ) , a . uart1 && ( this . devices . uart1 = new za ( this , 760 , b ) ) , a . uart2 && ( this . devices . uart2 = new za ( this , 1E3 , b ) ) , a . uart3 && ( this . devices . uart3 = new za ( this , 744 , b ) ) , this . devices . fdc = new J ( this , a . fda , a . fdb ) , c = 0 , a . hda && ( this . devices . hda = new pa ( this , a . hda , a . hdb , ! 1 , c ++ , b ) ) , a . cdrom && ( this . devices . cdrom = new pa ( this , a . cdrom , void 0 , ! 0 , c ++ , b ) ) , this . devices . pit = new ta ( this ,
b ) , "ne2k" === a . net _device . type ? this . devices . net = new Oa ( this , b , a . preserve _mac _from _state _image , a . mac _address _translation ) : "virtio" === a . net _device . type && ( this . devices . virtio _net = new ib ( this , b , a . preserve _mac _from _state _image ) ) , a . fs9p && ( this . devices . virtio _9p = new ca ( a . fs9p , this , b ) ) , a . virtio _console && ( this . devices . virtio _console = new hb ( this , b ) ) , this . devices . sb16 = new P ( this , b ) ) ; a . multiboot && ( a = this . load _multiboot _option _rom ( a . multiboot , a . initrd , a . cmdline ) ) && ( this . bios . main ? this . option _roms . push ( a ) : this . reg32 [ 0 ] =
this . io . port _read32 ( 244 ) ) } ; G . prototype . load _multiboot = function ( a ) { this . load _multiboot _option _rom ( a , void 0 , "" ) && ( this . reg32 [ 0 ] = this . io . port _read32 ( 244 ) ) } ;
G . prototype . load _multiboot _option _rom = function ( a , b , c ) { if ( 8192 > a . byteLength ) { var d = new Int32Array ( 2048 ) ; ( new Uint8Array ( d . buffer ) ) . set ( new Uint8Array ( a ) ) } else d = new Int32Array ( a , 0 , 2048 ) ; for ( var e = 0 ; 8192 > e ; e += 4 ) { if ( 464367618 === d [ e >> 2 ] ) { var f = d [ e + 4 >> 2 ] ; if ( 464367618 + f + d [ e + 8 >> 2 ] | 0 ) continue } else continue ; qa ( "Multiboot magic found, flags: " + A ( f >>> 0 , 8 ) , 2 ) ; var g = this ; this . io . register _read ( 244 , this , function ( ) { return 0 } , function ( ) { return 0 } , function ( ) { var n = 31860 , p = 0 ; if ( c ) { p |= 4 ; g . write32 ( 31760 , n ) ; c += "\x00" ;
var q = ( new TextEncoder ) . encode ( c ) ; g . write _blob ( q , n ) ; n += q . length } if ( f & 2 ) { p |= 64 ; q = 0 ; g . write32 ( 31788 , 0 ) ; g . write32 ( 31792 , n ) ; var r = 0 ; var D = ! 1 ; for ( let u = 0 ; 4294967296 > u ; u += 131072 ) D && void 0 !== g . memory _map _read8 [ u >>> 17 ] ? ( g . write32 ( n , 20 ) , g . write32 ( n + 4 , r ) , g . write32 ( n + 8 , 0 ) , g . write32 ( n + 12 , u - r ) , g . write32 ( n + 16 , 0 ) , g . write32 ( n + 20 , 1 ) , n += 24 , q += 24 , D = ! 1 ) : D || void 0 !== g . memory _map _read8 [ u >>> 17 ] || ( r = u , D = ! 0 ) ; g . write32 ( 31788 , q ) } g . write32 ( 31744 , p ) ; q = p = 0 ; if ( f & 65536 ) { D = d [ e + 12 >> 2 ] ; p = d [ e + 16 >> 2 ] ; var y = d [ e + 20 >> 2 ] ; q = d [ e + 24 >> 2 ] ; r =
d [ e + 28 >> 2 ] ; A ( D , 8 ) ; A ( p , 8 ) ; A ( y , 8 ) ; A ( q , 8 ) ; A ( r , 8 ) ; D = new Uint8Array ( a , e - ( D - p ) , 0 === y ? void 0 : y - p ) ; g . write _blob ( D , p ) ; p = r | 0 ; q = Math . max ( y , q ) } else if ( 1179403647 === d [ 0 ] ) { r = new DataView ( a ) ; const [ u , F ] = nb ( r , ob ) ; console . assert ( 52 === F ) ; console . assert ( 1179403647 === u . magic , "Bad magic" ) ; console . assert ( 1 === u . class , "Unimplemented: 64 bit elf" ) ; console . assert ( 1 === u . data , "Unimplemented: big endian" ) ; console . assert ( 1 === u . version0 , "Bad version0" ) ; console . assert ( 2 === u . type , "Unimplemented type" ) ; console . assert ( 1 === u . version1 ,
"Bad version1" ) ; console . assert ( 52 === u . ehsize , "Bad header size" ) ; console . assert ( 32 === u . phentsize , "Bad program header size" ) ; console . assert ( 40 === u . shentsize , "Bad section header size" ) ; [ p ] = pb ( new DataView ( r . buffer , r . byteOffset + u . phoff , u . phentsize * u . phnum ) , qb , u . phnum ) ; pb ( new DataView ( r . buffer , r . byteOffset + u . shoff , u . shentsize * u . shnum ) , rb , u . shnum ) ; r = u ; D = p ; p = r . entry ; for ( y of D ) 0 !== y . type && ( 1 === y . type ? y . paddr + y . memsz < g . memory _size [ 0 ] ? ( y . filesz && ( D = new Uint8Array ( a , y . offset , y . filesz ) , g . write _blob ( D , y . paddr ) ) ,
q = Math . max ( q , y . paddr + y . memsz ) , p === r . entry && y . vaddr <= p && y . vaddr + y . memsz > p && ( p = p - y . vaddr + y . paddr ) ) : A ( y . paddr ) : 2 === y . type || 3 === y . type || 4 === y . type || 6 === y . type || 7 === y . type || 1685382480 === y . type || 1685382481 === y . type || 1685382482 === y . type || 1685382483 === y . type || A ( y . type ) ) } b && ( g . write32 ( 31764 , 1 ) , g . write32 ( 31768 , n ) , y = q , 0 !== ( y & 4095 ) && ( y = ( y & - 4096 ) + 4096 ) , q = y + b . byteLength , g . write32 ( n , y ) , g . write32 ( n + 4 , q ) , g . write32 ( n + 8 , 0 ) , g . write32 ( n + 12 , 0 ) , g . write _blob ( new Uint8Array ( b ) , y ) ) ; g . reg32 [ 3 ] = 31744 ; g . cr [ 0 ] = 1 ; g . protected _mode [ 0 ] =
1 ; g . flags [ 0 ] = 2 ; g . is _32 [ 0 ] = 1 ; g . stack _size _32 [ 0 ] = 1 ; for ( n = 0 ; 6 > n ; n ++ ) g . segment _is _null [ n ] = 0 , g . segment _offsets [ n ] = 0 , g . segment _limits [ n ] = 4294967295 , g . sreg [ n ] = 45058 ; g . instruction _pointer [ 0 ] = g . get _seg _cs ( ) + p | 0 ; g . update _state _flags ( ) ; g . debug . dump _state ( ) ; g . debug . dump _regs ( ) ; return 732803074 } ) ; this . io . register _write _consecutive ( 244 , this , function ( n ) { console . log ( "Test exited with code " + A ( n , 2 ) ) ; throw "HALT" ; } , function ( ) { } , function ( ) { } , function ( ) { } ) ; for ( let n = 0 ; 15 >= n ; n ++ ) { function p ( q ) { A ( n ) ; A ( q , 2 ) ; q ? this . device _raise _irq ( n ) :
this . device _lower _irq ( n ) } this . io . register _write ( 8192 + n , this , p , p , p ) } const l = new Uint8Array ( 512 ) ; ( new Uint16Array ( l . buffer ) ) [ 0 ] = 43605 ; l [ 2 ] = 1 ; var h = 3 ; l [ h ++ ] = 102 ; l [ h ++ ] = 229 ; l [ h ++ ] = 244 ; let m = l [ h ] = 0 ; for ( let n = 0 ; n < l . length ; n ++ ) m += l [ n ] ; l [ h ] = - m ; return { name : "genroms/multiboot.bin" , data : l } } } ;
G . prototype . fill _cmos = function ( a , b ) { var c = b . boot _order || 291 ; a . cmos _write ( 56 , 1 | c >> 4 & 240 ) ; a . cmos _write ( 61 , c & 255 ) ; a . cmos _write ( 21 , 128 ) ; a . cmos _write ( 22 , 2 ) ; c = 0 ; 1048576 <= this . memory _size [ 0 ] && ( c = this . memory _size [ 0 ] - 1048576 >> 10 , c = Math . min ( c , 65535 ) ) ; a . cmos _write ( 23 , c & 255 ) ; a . cmos _write ( 24 , c >> 8 & 255 ) ; a . cmos _write ( 48 , c & 255 ) ; a . cmos _write ( 49 , c >> 8 & 255 ) ; c = 0 ; 16777216 <= this . memory _size [ 0 ] && ( c = this . memory _size [ 0 ] - 16777216 >> 16 , c = Math . min ( c , 65535 ) ) ; a . cmos _write ( 52 , c & 255 ) ; a . cmos _write ( 53 , c >> 8 & 255 ) ; a . cmos _write ( 91 , 0 ) ; a . cmos _write ( 92 ,
2024-06-28 09:23:02 +02:00
0 ) ; a . cmos _write ( 93 , 0 ) ; a . cmos _write ( 20 , 47 ) ; a . cmos _write ( 95 , 0 ) ; b . fastboot && a . cmos _write ( 63 , 1 ) } ;
2024-10-02 21:03:04 +02:00
G . prototype . load _bios = function ( ) { var a = this . bios . main , b = this . bios . vga ; if ( a ) { var c = new Uint8Array ( a ) ; this . write _blob ( c , 1048576 - a . byteLength ) ; if ( b ) { var d = new Uint8Array ( b ) ; this . write _blob ( d , 786432 ) ; this . io . mmap _register ( 4272947200 , 1048576 , function ( e ) { e = e - 4272947200 | 0 ; return e < d . length ? d [ e ] : 0 } , function ( ) { } ) } this . io . mmap _register ( 4293918720 , 1048576 , function ( e ) { return this . mem8 [ e & 1048575 ] } . bind ( this ) , function ( e , f ) { this . mem8 [ e & 1048575 ] = f } . bind ( this ) ) } } ;
G . prototype . codegen _finalize = function ( a , b , c , d , e ) { const f = new Uint8Array ( this . wasm _memory . buffer , d >>> 0 , e >>> 0 ) ; WebAssembly . instantiate ( f , { e : this . jit _imports } ) . then ( g => { this . wm . wasm _table . set ( a + 1024 , g . instance . exports . f ) ; this . codegen _finalize _finished ( a , b , c ) ; this . test _hook _did _finalize _wasm && this . test _hook _did _finalize _wasm ( f ) } ) } ; G . prototype . log _uncompiled _code = function ( ) { } ; G . prototype . dump _function _code = function ( ) { } ;
G . prototype . run _hardware _timers = function ( a , b ) { const c = this . devices . pit . timer ( b , ! 1 ) , d = this . devices . rtc . timer ( b , ! 1 ) ; let e = 100 , f = 100 ; a && ( e = this . devices . acpi . timer ( b ) , f = this . devices . apic . timer ( b ) ) ; return Math . min ( c , d , e , f ) } ; G . prototype . device _raise _irq = function ( a ) { this . pic _set _irq ( a ) ; this . devices . ioapic && this . devices . ioapic . set _irq ( a ) } ; G . prototype . device _lower _irq = function ( a ) { this . pic _clear _irq ( a ) ; this . devices . ioapic && this . devices . ioapic . clear _irq ( a ) } ; G . prototype . debug _init = function ( ) { var a = this , b = { } ; this . debug = b ; b . init = function ( ) { } ; b . get _regs _short = function ( ) { } ; b . dump _regs = function ( ) { } ; b . get _state = function ( ) { } ; b . dump _state = function ( ) { } ; b . dump _stack = function ( ) { } ; b . dump _page _structures = function ( ) { if ( a . cr [ 4 ] & 32 ) for ( var f = 0 ; 4 > f ; f ++ ) a . read32s ( a . cr [ 3 ] + 8 * f ) } ; b . dump _gdt _ldt = function ( ) { } ; b . dump _idt = function ( ) { } ; b . get _memory _dump = function ( ) { } ; b . memory _hex _dump = function ( ) { } ; b . used _memory _dump = function ( ) { } ; b . debug _interrupt = function ( ) { } ; let c , d ; b . dump _code =
function ( f , g , h ) { if ( ! d ) { if ( void 0 === c && ( c = "function" === typeof require ? require ( "./capstone-x86.min.js" ) : window . cs , void 0 === c ) ) return ; d = [ new c . Capstone ( c . ARCH _X86 , c . MODE _16 ) , new c . Capstone ( c . ARCH _X86 , c . MODE _32 ) ] } try { d [ f ] . disasm ( g , h ) . forEach ( function ( l ) { qa ( A ( l . address >>> 0 ) + ": " + t . pads ( l . bytes . map ( m => A ( m , 2 ) . slice ( - 2 ) ) . join ( " " ) , 20 ) + " " + l . mnemonic + " " + l . op _str ) } ) } catch ( l ) { qa ( "Could not disassemble: " + Array . from ( g ) . map ( m => A ( m , 2 ) ) . join ( " " ) ) } } ; let e ; b . dump _wasm = function ( f ) { if ( void 0 === e && ( e = "function" ===
typeof require ? require ( "./libwabt.js" ) : new window . WabtModule , void 0 === e ) ) return ; f = f . slice ( ) ; try { var g = e . readWasm ( f , { readDebugNames : ! 1 } ) ; g . generateNames ( ) ; g . applyNames ( ) ; g . toText ( { foldExprs : ! 0 , inlineExport : ! 0 } ) } catch ( m ) { var h = new Blob ( [ f ] ) , l = document . createElement ( "a" ) ; l . download = "failed.wasm" ; l . href = window . URL . createObjectURL ( h ) ; l . dataset . downloadurl = [ "application/octet-stream" , l . download , l . href ] . join ( ":" ) ; l . click ( ) ; window . URL . revokeObjectURL ( l . src ) ; console . log ( m . toString ( ) ) } finally { g && g . destroy ( ) } } } ; const sb = DataView . prototype , tb = { size : 1 , get : sb . getUint8 , set : sb . setUint8 } , ub = { size : 2 , get : sb . getUint16 , set : sb . setUint16 } , T = { size : 4 , get : sb . getUint32 , set : sb . setUint32 } , ob = vb ( [ { magic : T } , { class : tb } , { data : tb } , { version0 : tb } , { osabi : tb } , { abiversion : tb } , { pad0 : function ( a ) { return { size : a , get : ( ) => - 1 } } ( 7 ) } , { type : ub } , { machine : ub } , { version1 : T } , { entry : T } , { phoff : T } , { shoff : T } , { flags : T } , { ehsize : ub } , { phentsize : ub } , { phnum : ub } , { shentsize : ub } , { shnum : ub } , { shstrndx : ub } ] ) ; console . assert ( 52 === ob . reduce ( ( a , b ) => a + b . size , 0 ) ) ;
const qb = vb ( [ { type : T } , { offset : T } , { vaddr : T } , { paddr : T } , { filesz : T } , { memsz : T } , { flags : T } , { align : T } ] ) ; console . assert ( 32 === qb . reduce ( ( a , b ) => a + b . size , 0 ) ) ; const rb = vb ( [ { name : T } , { type : T } , { flags : T } , { addr : T } , { offset : T } , { size : T } , { link : T } , { info : T } , { addralign : T } , { entsize : T } ] ) ; console . assert ( 40 === rb . reduce ( ( a , b ) => a + b . size , 0 ) ) ; function vb ( a ) { return a . map ( function ( b ) { var c = Object . keys ( b ) ; console . assert ( 1 === c . length ) ; c = c [ 0 ] ; b = b [ c ] ; console . assert ( 0 < b . size ) ; return { name : c , type : b , size : b . size , get : b . get , set : b . set } } ) }
function nb ( a , b ) { const c = { } ; let d = 0 ; for ( const e of b ) b = e . get . call ( a , d , ! 0 ) , console . assert ( void 0 === c [ e . name ] ) , c [ e . name ] = b , d += e . size ; return [ c , d ] } function pb ( a , b , c ) { const d = [ ] ; let e = 0 ; for ( var f = 0 ; f < c ; f ++ ) { const [ g , h ] = nb ( new DataView ( a . buffer , a . byteOffset + e , void 0 ) , b ) ; d . push ( g ) ; e += h } return [ d , e ] } ; function lb ( a , b , c , d ) { var e = new Uint8Array ( b ) ; const f = new Uint16Array ( b ) ; var g = new Uint32Array ( b ) , h = e [ 497 ] || 4 , l = f [ 255 ] ; if ( 43605 !== l ) A ( l ) ; else if ( l = f [ 257 ] | f [ 258 ] << 16 , 1400005704 !== l ) A ( l ) ; else { l = f [ 259 ] ; var m = e [ 529 ] , n = f [ 283 ] , p = g [ 139 ] , q = g [ 140 ] , r = e [ 565 ] , D = 518 <= l ? g [ 142 ] : 255 , y = g [ 146 ] , u = g [ 147 ] , F = g [ 150 ] , w = g [ 151 ] , K = g [ 152 ] ; A ( l ) ; A ( m ) ; A ( n ) ; A ( g [ 133 ] ) ; A ( p ) ; A ( q ) ; A ( r ) ; A ( D ) ; A ( y ) ; A ( u ) ; A ( w ) ; A ( F ) ; A ( K ) ; e [ 528 ] = 255 ; e [ 529 ] = m & - 97 | 128 ; f [ 274 ] = 56832 ; f [ 253 ] = 65535 ; A ( 56832 ) ; d += "\x00" ; A ( 581632 ) ; g [ 138 ] = 581632 ; for ( e = 0 ; e < d . length ; e ++ ) a [ 581632 +
e ] = d . charCodeAt ( e ) ; h = 512 * ( h + 1 ) ; A ( h ) ; d = new Uint8Array ( b , 0 , h ) ; b = new Uint8Array ( b , h ) ; e = h = 0 ; c && ( h = 67108864 , e = c . byteLength , a . set ( new Uint8Array ( c ) , h ) ) ; g [ 134 ] = h ; g [ 135 ] = e ; a . set ( d , 524288 ) ; a . set ( b , 1048576 ) ; a = new Uint8Array ( 512 ) ; ( new Uint16Array ( a . buffer ) ) [ 0 ] = 43605 ; a [ 2 ] = 1 ; c = 3 ; a [ c ++ ] = 250 ; a [ c ++ ] = 184 ; a [ c ++ ] = 32768 ; a [ c ++ ] = 128 ; a [ c ++ ] = 142 ; a [ c ++ ] = 192 ; a [ c ++ ] = 142 ; a [ c ++ ] = 216 ; a [ c ++ ] = 142 ; a [ c ++ ] = 224 ; a [ c ++ ] = 142 ; a [ c ++ ] = 232 ; a [ c ++ ] = 142 ; a [ c ++ ] = 208 ; a [ c ++ ] = 188 ; a [ c ++ ] = 57344 ; a [ c ++ ] = 224 ; a [ c ++ ] = 234 ; a [ c ++ ] = 0 ; a [ c ++ ] = 0 ; a [ c ++ ] = 32800 ; a [ c ++ ] =
128 ; g = a [ c ] = 0 ; for ( b = 0 ; b < a . length ; b ++ ) g += a [ b ] ; a [ c ] = - g ; return { name : "genroms/kernel.bin" , data : a } } } ; const wb = "undefined" !== typeof window && 0 <= window . navigator . platform . toString ( ) . toLowerCase ( ) . search ( "win" ) ;
function xb ( a ) { function b ( w ) { return w . shiftKey && w . ctrlKey && ( 73 === w . keyCode || 74 === w . keyCode || 75 === w . keyCode ) || ! r . emu _enabled ? ! 1 : w . target ? w . target . classList . contains ( "phone_keyboard" ) || "INPUT" !== w . target . nodeName && "TEXTAREA" !== w . target . nodeName : ! 0 } function c ( w ) { ! w . altKey && m [ 56 ] && h ( 56 , ! 1 ) ; return f ( w , ! 1 ) } function d ( w ) { ! w . altKey && m [ 56 ] && h ( 56 , ! 1 ) ; return f ( w , ! 0 ) } function e ( ) { for ( var w = Object . keys ( m ) , K , V = 0 ; V < w . length ; V ++ ) K = + w [ V ] , m [ K ] && h ( K , ! 1 ) ; m = { } } function f ( w , K ) { if ( r . bus && b ( w ) ) { w . preventDefault && w . preventDefault ( ) ;
if ( wb && ( n && ( clearTimeout ( q ) , w . getModifierState && w . getModifierState ( "AltGraph" ) && p === K && "ControlLeft" === n . code && "AltRight" === w . code || g ( n , p ) , n = null ) , "ControlLeft" === w . code ) ) return n = w , p = K , q = setTimeout ( ( ) => { g ( n , p ) ; n = null } , 10 ) , ! 1 ; g ( w , K ) ; return ! 1 } } function g ( w , K ) { a : { if ( void 0 !== w . code ) { var V = F [ w . code ] ; if ( void 0 !== V ) break a } V = D [ w . keyCode ] } V ? h ( V , K , w . repeat ) : console . log ( "Missing char in map: keyCode=" + ( w . keyCode || - 1 ) . toString ( 16 ) + " code=" + w . code ) } function h ( w , K , V ) { if ( K ) m [ w ] && ! V && h ( w , ! 1 ) ; else if ( ! m [ w ] ) return ;
( m [ w ] = K ) || ( w |= 128 ) ; 255 < w ? ( l ( w >> 8 ) , l ( w & 255 ) ) : l ( w ) } function l ( w ) { r . bus . send ( "keyboard-code" , w ) } var m = { } , n = null , p = ! 1 , q = 0 , r = this ; this . emu _enabled = ! 0 ; var D = new Uint16Array ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 14 , 15 , 0 , 0 , 0 , 28 , 0 , 0 , 42 , 29 , 56 , 0 , 58 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 57 , 57417 , 57425 , 57423 , 57415 , 57419 , 57416 , 57421 , 80 , 0 , 0 , 0 , 0 , 82 , 83 , 0 , 11 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 0 , 39 , 0 , 13 , 0 , 0 , 0 , 30 , 48 , 46 , 32 , 18 , 33 , 34 , 35 , 23 , 36 , 37 , 38 , 50 , 49 , 24 , 25 , 16 , 19 , 31 , 20 , 22 , 47 , 17 , 45 , 21 , 44 , 57435 , 57436 , 57437 , 0 , 0 , 82 , 79 , 80 , 81 , 75 , 76 , 77 , 71 , 72 , 73 , 0 , 0 , 0 , 0 , 0 , 0 , 59 , 60 , 61 , 62 , 63 , 64 ,
65 , 66 , 67 , 68 , 87 , 88 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 69 , 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 , 12 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 39 , 13 , 51 , 12 , 52 , 53 , 41 , 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 , 26 , 43 , 27 , 40 , 0 , 57435 , 57400 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) , y = { 8 : 8 , 10 : 13 , 32 : 32 , 39 : 222 , 44 : 188 , 45 : 189 , 46 : 190 , 47 : 191 , 48 : 48 , 49 : 49 , 50 : 50 , 51 : 51 , 52 : 52 , 53 : 53 , 54 : 54 , 55 : 55 , 56 : 56 , 57 : 57 , 59 : 186 , 61 : 187 , 91 : 219 , 92 : 220 , 93 : 221 , 96 : 192 , 97 : 65 , 98 : 66 , 99 : 67 , 100 : 68 , 101 : 69 , 102 : 70 , 103 : 71 , 104 : 72 , 105 : 73 , 106 : 74 , 107 : 75 ,
108 : 76 , 109 : 77 , 110 : 78 , 111 : 79 , 112 : 80 , 113 : 81 , 114 : 82 , 115 : 83 , 116 : 84 , 117 : 85 , 118 : 86 , 119 : 87 , 120 : 88 , 121 : 89 , 122 : 90 } , u = { 33 : 49 , 34 : 222 , 35 : 51 , 36 : 52 , 37 : 53 , 38 : 55 , 40 : 57 , 41 : 48 , 42 : 56 , 43 : 187 , 58 : 186 , 60 : 188 , 62 : 190 , 63 : 191 , 64 : 50 , 65 : 65 , 66 : 66 , 67 : 67 , 68 : 68 , 69 : 69 , 70 : 70 , 71 : 71 , 72 : 72 , 73 : 73 , 74 : 74 , 75 : 75 , 76 : 76 , 77 : 77 , 78 : 78 , 79 : 79 , 80 : 80 , 81 : 81 , 82 : 82 , 83 : 83 , 84 : 84 , 85 : 85 , 86 : 86 , 87 : 87 , 88 : 88 , 89 : 89 , 90 : 90 , 94 : 54 , 95 : 189 , 123 : 219 , 124 : 220 , 125 : 221 , 126 : 192 } , F = { Escape : 1 , Digit1 : 2 , Digit2 : 3 , Digit3 : 4 , Digit4 : 5 , Digit5 : 6 , Digit6 : 7 , Digit7 : 8 , Digit8 : 9 , Digit9 : 10 ,
Digit0 : 11 , Minus : 12 , Equal : 13 , Backspace : 14 , Tab : 15 , KeyQ : 16 , KeyW : 17 , KeyE : 18 , KeyR : 19 , KeyT : 20 , KeyY : 21 , KeyU : 22 , KeyI : 23 , KeyO : 24 , KeyP : 25 , BracketLeft : 26 , BracketRight : 27 , Enter : 28 , ControlLeft : 29 , KeyA : 30 , KeyS : 31 , KeyD : 32 , KeyF : 33 , KeyG : 34 , KeyH : 35 , KeyJ : 36 , KeyK : 37 , KeyL : 38 , Semicolon : 39 , Quote : 40 , Backquote : 41 , ShiftLeft : 42 , Backslash : 43 , KeyZ : 44 , KeyX : 45 , KeyC : 46 , KeyV : 47 , KeyB : 48 , KeyN : 49 , KeyM : 50 , Comma : 51 , Period : 52 , Slash : 53 , IntlRo : 53 , ShiftRight : 54 , NumpadMultiply : 55 , AltLeft : 56 , Space : 57 , CapsLock : 58 , F1 : 59 , F2 : 60 , F3 : 61 , F4 : 62 , F5 : 63 ,
F6 : 64 , F7 : 65 , F8 : 66 , F9 : 67 , F10 : 68 , NumLock : 69 , ScrollLock : 70 , Numpad7 : 71 , Numpad8 : 72 , Numpad9 : 73 , NumpadSubtract : 74 , Numpad4 : 75 , Numpad5 : 76 , Numpad6 : 77 , NumpadAdd : 78 , Numpad1 : 79 , Numpad2 : 80 , Numpad3 : 81 , Numpad0 : 82 , NumpadDecimal : 83 , IntlBackslash : 86 , F11 : 87 , F12 : 88 , NumpadEnter : 57372 , ControlRight : 57373 , NumpadDivide : 57397 , AltRight : 57400 , Home : 57415 , ArrowUp : 57416 , PageUp : 57417 , ArrowLeft : 57419 , ArrowRight : 57421 , End : 57423 , ArrowDown : 57424 , PageDown : 57425 , Insert : 57426 , Delete : 57427 , OSLeft : 57435 , OSRight : 57436 , ContextMenu : 57437 } ; this . bus =
a ; this . destroy = function ( ) { "undefined" !== typeof window && ( window . removeEventListener ( "keyup" , c , ! 1 ) , window . removeEventListener ( "keydown" , d , ! 1 ) , window . removeEventListener ( "blur" , e , ! 1 ) ) } ; this . init = function ( ) { "undefined" !== typeof window && ( this . destroy ( ) , window . addEventListener ( "keyup" , c , ! 1 ) , window . addEventListener ( "keydown" , d , ! 1 ) , window . addEventListener ( "blur" , e , ! 1 ) ) } ; this . init ( ) ; this . simulate _press = function ( w ) { w = { keyCode : w } ; f ( w , ! 0 ) ; f ( w , ! 1 ) } ; this . simulate _char = function ( w ) { var K = w . charCodeAt ( 0 ) ; K in y ? this . simulate _press ( y [ K ] ) :
K in u ? ( l ( 42 ) , this . simulate _press ( u [ K ] ) , l ( 170 ) ) : console . log ( "ascii -> keyCode not found: " , K , w ) } } ; function yb ( a , b ) { function c ( u ) { if ( ! y . enabled || ! y . emu _enabled ) return ! 1 ; var F = b || document . body , w ; if ( ! ( w = document . pointerLockElement ) ) a : { for ( u = u . target ; u . parentNode ; ) { if ( u === F ) { w = ! 0 ; break a } u = u . parentNode } w = ! 1 } return w } function d ( u ) { c ( u ) && ( u = u . changedTouches ) && u . length && ( u = u [ u . length - 1 ] , r = u . clientX , D = u . clientY ) } function e ( ) { if ( n || q || p ) y . bus . send ( "mouse-click" , [ ! 1 , ! 1 , ! 1 ] ) , n = q = p = ! 1 } function f ( u ) { if ( y . bus && c ( u ) && y . is _running ) { var F = 0 , w = 0 , K = u . changedTouches ; K ? K . length && ( K = K [ K . length - 1 ] , F = K . clientX - r , w = K . clientY -
D , r = K . clientX , D = K . clientY , u . preventDefault ( ) ) : "number" === typeof u . movementX ? ( F = u . movementX , w = u . movementY ) : "number" === typeof u . webkitMovementX ? ( F = u . webkitMovementX , w = u . webkitMovementY ) : "number" === typeof u . mozMovementX ? ( F = u . mozMovementX , w = u . mozMovementY ) : ( F = u . clientX - r , w = u . clientY - D , r = u . clientX , D = u . clientY ) ; y . bus . send ( "mouse-delta" , [ . 15 * F , - ( . 15 * w ) ] ) ; b && y . bus . send ( "mouse-absolute" , [ u . pageX - b . offsetLeft , u . pageY - b . offsetTop , b . offsetWidth , b . offsetHeight ] ) } } function g ( u ) { c ( u ) && l ( u , ! 0 ) } function h ( u ) { c ( u ) &&
l ( u , ! 1 ) } function l ( u , F ) { y . bus && ( 1 === u . which ? n = F : 2 === u . which ? q = F : 3 === u . which && ( p = F ) , y . bus . send ( "mouse-click" , [ n , q , p ] ) , u . preventDefault ( ) ) } function m ( u ) { if ( c ( u ) ) { var F = u . wheelDelta || - u . detail ; 0 > F ? F = - 1 : 0 < F && ( F = 1 ) ; y . bus . send ( "mouse-wheel" , [ F , 0 ] ) ; u . preventDefault ( ) } } var n = ! 1 , p = ! 1 , q = ! 1 , r = 0 , D = 0 , y = this ; this . enabled = ! 1 ; this . emu _enabled = ! 0 ; this . bus = a ; this . bus . register ( "mouse-enable" , function ( u ) { this . enabled = u } , this ) ; this . is _running = ! 1 ; this . bus . register ( "emulator-stopped" , function ( ) { this . is _running = ! 1 } , this ) ;
this . bus . register ( "emulator-started" , function ( ) { this . is _running = ! 0 } , this ) ; this . destroy = function ( ) { "undefined" !== typeof window && ( window . removeEventListener ( "touchstart" , d , ! 1 ) , window . removeEventListener ( "touchend" , e , ! 1 ) , window . removeEventListener ( "touchmove" , f , ! 1 ) , window . removeEventListener ( "mousemove" , f , ! 1 ) , window . removeEventListener ( "mousedown" , g , ! 1 ) , window . removeEventListener ( "mouseup" , h , ! 1 ) , window . removeEventListener ( "wheel" , m , { passive : ! 1 } ) ) } ; this . init = function ( ) { "undefined" !== typeof window && ( this . destroy ( ) ,
window . addEventListener ( "touchstart" , d , ! 1 ) , window . addEventListener ( "touchend" , e , ! 1 ) , window . addEventListener ( "touchmove" , f , ! 1 ) , window . addEventListener ( "mousemove" , f , ! 1 ) , window . addEventListener ( "mousedown" , g , ! 1 ) , window . addEventListener ( "mouseup" , h , ! 1 ) , window . addEventListener ( "wheel" , m , { passive : ! 1 } ) ) } ; this . init ( ) } ; function zb ( a ) { if ( "undefined" !== typeof window ) if ( window . AudioContext || window . webkitAudioContext ) { var b = window . AudioWorklet ? Ab : Bb ; this . bus = a ; this . audio _context = window . AudioContext ? new AudioContext : new webkitAudioContext ; this . mixer = new Cb ( a , this . audio _context ) ; this . pcspeaker = new Db ( a , this . audio _context , this . mixer ) ; this . dac = new b ( a , this . audio _context , this . mixer ) ; this . pcspeaker . start ( ) ; a . register ( "emulator-stopped" , function ( ) { this . audio _context . suspend ( ) } , this ) ; a . register ( "emulator-started" , function ( ) { this . audio _context . resume ( ) } ,
this ) ; a . register ( "speaker-confirm-initialized" , function ( ) { a . send ( "speaker-has-initialized" ) } , this ) ; a . send ( "speaker-has-initialized" ) } else console . warn ( "Web browser doesn't support Web Audio API" ) } zb . prototype . destroy = function ( ) { this . audio _context && this . audio _context . close ( ) ; this . audio _context = null ; this . dac && this . dac . node _processor && this . dac . node _processor . port . close ( ) ; this . dac = null } ;
function Cb ( a , b ) { function c ( d ) { return function ( e ) { d . gain . setValueAtTime ( e , this . audio _context . currentTime ) } } this . audio _context = b ; this . sources = new Map ; this . gain _right = this . gain _left = this . volume _right = this . volume _left = this . volume _both = 1 ; this . node _treble _left = this . audio _context . createBiquadFilter ( ) ; this . node _treble _right = this . audio _context . createBiquadFilter ( ) ; this . node _treble _left . type = "highshelf" ; this . node _treble _right . type = "highshelf" ; this . node _treble _left . frequency . setValueAtTime ( 2E3 , this . audio _context . currentTime ) ;
2024-06-28 09:23:02 +02:00
this . node _treble _right . frequency . setValueAtTime ( 2E3 , this . audio _context . currentTime ) ; this . node _bass _left = this . audio _context . createBiquadFilter ( ) ; this . node _bass _right = this . audio _context . createBiquadFilter ( ) ; this . node _bass _left . type = "lowshelf" ; this . node _bass _right . type = "lowshelf" ; this . node _bass _left . frequency . setValueAtTime ( 200 , this . audio _context . currentTime ) ; this . node _bass _right . frequency . setValueAtTime ( 200 , this . audio _context . currentTime ) ; this . node _gain _left = this . audio _context . createGain ( ) ; this . node _gain _right =
this . audio _context . createGain ( ) ; this . node _merger = this . audio _context . createChannelMerger ( 2 ) ; this . input _left = this . node _treble _left ; this . input _right = this . node _treble _right ; this . node _treble _left . connect ( this . node _bass _left ) ; this . node _bass _left . connect ( this . node _gain _left ) ; this . node _gain _left . connect ( this . node _merger , 0 , 0 ) ; this . node _treble _right . connect ( this . node _bass _right ) ; this . node _bass _right . connect ( this . node _gain _right ) ; this . node _gain _right . connect ( this . node _merger , 0 , 1 ) ; this . node _merger . connect ( this . audio _context . destination ) ;
2024-10-02 21:03:04 +02:00
a . register ( "mixer-connect" , function ( d ) { this . connect _source ( d [ 0 ] , d [ 1 ] ) } , this ) ; a . register ( "mixer-disconnect" , function ( d ) { this . disconnect _source ( d [ 0 ] , d [ 1 ] ) } , this ) ; a . register ( "mixer-volume" , function ( d ) { var e = d [ 0 ] , f = d [ 1 ] ; d = Math . pow ( 10 , d [ 2 ] / 20 ) ; e = 0 === e ? this : this . sources . get ( e ) ; void 0 === e || e . set _volume ( d , f ) } , this ) ; a . register ( "mixer-gain-left" , function ( d ) { this . gain _left = Math . pow ( 10 , d / 20 ) ; this . update ( ) } , this ) ; a . register ( "mixer-gain-right" , function ( d ) { this . gain _right = Math . pow ( 10 , d / 20 ) ; this . update ( ) } , this ) ;
a . register ( "mixer-treble-left" , c ( this . node _treble _left ) , this ) ; a . register ( "mixer-treble-right" , c ( this . node _treble _right ) , this ) ; a . register ( "mixer-bass-left" , c ( this . node _bass _left ) , this ) ; a . register ( "mixer-bass-right" , c ( this . node _bass _right ) , this ) } Cb . prototype . add _source = function ( a , b ) { a = new Eb ( this . audio _context , a , this . input _left , this . input _right ) ; this . sources . has ( b ) ; this . sources . set ( b , a ) ; return a } ; Cb . prototype . connect _source = function ( a , b ) { a = this . sources . get ( a ) ; void 0 === a || a . connect ( b ) } ;
Cb . prototype . disconnect _source = function ( a , b ) { a = this . sources . get ( a ) ; void 0 === a || a . disconnect ( b ) } ; Cb . prototype . set _volume = function ( a , b ) { void 0 === b && ( b = 2 ) ; switch ( b ) { case 0 : this . volume _left = a ; break ; case 1 : this . volume _right = a ; break ; case 2 : this . volume _both = a ; break ; default : return } this . update ( ) } ;
Cb . prototype . update = function ( ) { var a = this . volume _both * this . volume _right * this . gain _right ; this . node _gain _left . gain . setValueAtTime ( this . volume _both * this . volume _left * this . gain _left , this . audio _context . currentTime ) ; this . node _gain _right . gain . setValueAtTime ( a , this . audio _context . currentTime ) } ;
function Eb ( a , b , c , d ) { this . audio _context = a ; this . connected _right = this . connected _left = ! 0 ; this . volume _right = this . volume _left = this . volume _both = this . gain _hidden = 1 ; this . node _splitter = a . createChannelSplitter ( 2 ) ; this . node _gain _left = a . createGain ( ) ; this . node _gain _right = a . createGain ( ) ; b . connect ( this . node _splitter ) ; this . node _splitter . connect ( this . node _gain _left , 0 ) ; this . node _gain _left . connect ( c ) ; this . node _splitter . connect ( this . node _gain _right , 1 ) ; this . node _gain _right . connect ( d ) }
Eb . prototype . update = function ( ) { var a = this . connected _right * this . gain _hidden * this . volume _both * this . volume _right ; this . node _gain _left . gain . setValueAtTime ( this . connected _left * this . gain _hidden * this . volume _both * this . volume _left , this . audio _context . currentTime ) ; this . node _gain _right . gain . setValueAtTime ( a , this . audio _context . currentTime ) } ; Eb . prototype . connect = function ( a ) { var b = ! a || 2 === a ; if ( b || 0 === a ) this . connected _left = ! 0 ; if ( b || 1 === a ) this . connected _right = ! 0 ; this . update ( ) } ;
Eb . prototype . disconnect = function ( a ) { var b = ! a || 2 === a ; if ( b || 0 === a ) this . connected _left = ! 1 ; if ( b || 1 === a ) this . connected _right = ! 1 ; this . update ( ) } ; Eb . prototype . set _volume = function ( a , b ) { void 0 === b && ( b = 2 ) ; switch ( b ) { case 0 : this . volume _left = a ; break ; case 1 : this . volume _right = a ; break ; case 2 : this . volume _both = a ; break ; default : return } this . update ( ) } ; Eb . prototype . set _gain _hidden = function ( a ) { this . gain _hidden = a } ;
function Db ( a , b , c ) { this . node _oscillator = b . createOscillator ( ) ; this . node _oscillator . type = "square" ; this . node _oscillator . frequency . setValueAtTime ( 440 , b . currentTime ) ; this . mixer _connection = c . add _source ( this . node _oscillator , 1 ) ; this . mixer _connection . disconnect ( ) ; a . register ( "pcspeaker-enable" , function ( ) { c . connect _source ( 1 ) } , this ) ; a . register ( "pcspeaker-disable" , function ( ) { c . disconnect _source ( 1 ) } , this ) ; a . register ( "pcspeaker-update" , function ( d ) { var e = d [ 1 ] , f = 0 ; 3 === d [ 0 ] && ( f = Math . min ( 1193181.6665999999 / e , this . node _oscillator . frequency . maxValue ) ,
f = Math . max ( f , 0 ) ) ; this . node _oscillator . frequency . setValueAtTime ( f , b . currentTime ) } , this ) } Db . prototype . start = function ( ) { this . node _oscillator . start ( ) } ;
function Ab ( a , b , c ) { this . bus = a ; this . audio _context = b ; this . enabled = ! 1 ; this . sampling _rate = 48E3 ; b = function ( ) { function g ( m ) { if ( 0 === m ) return 1 ; m *= Math . PI ; return Math . sin ( m ) / m } function h ( ) { var m = Reflect . construct ( AudioWorkletProcessor , [ ] , h ) ; m . kernel _size = 3 ; m . queue _data = Array ( 1024 ) ; m . queue _start = 0 ; m . queue _end = 0 ; m . queue _length = 0 ; m . queue _size = m . queue _data . length ; m . queued _samples = 0 ; m . source _buffer _previous = l ; m . source _buffer _current = l ; m . source _samples _per _destination = 1 ; m . source _block _start = 0 ; m . source _time = 0 ; m . source _offset =
0 ; m . port . onmessage = n => { switch ( n . data . type ) { case "queue" : m . queue _push ( n . data . value ) ; break ; case "sampling-rate" : m . source _samples _per _destination = n . data . value / sampleRate } } ; return m } var l = [ new Float32Array ( 256 ) , new Float32Array ( 256 ) ] ; Reflect . setPrototypeOf ( h . prototype , AudioWorkletProcessor . prototype ) ; Reflect . setPrototypeOf ( h , AudioWorkletProcessor ) ; h . prototype . process = h . prototype . process = function ( m , n ) { for ( m = 0 ; m < n [ 0 ] [ 0 ] . length ; m ++ ) { for ( var p = 0 , q = 0 , r = this . source _offset + this . kernel _size , D = this . source _offset -
this . kernel _size + 1 ; D <= r ; D ++ ) { var y = this . source _block _start + D ; p += this . get _sample ( y , 0 ) * this . kernel ( this . source _time - D ) ; q += this . get _sample ( y , 1 ) * this . kernel ( this . source _time - D ) } if ( isNaN ( p ) || isNaN ( q ) ) p = q = 0 , this . dbg _log ( "ERROR: NaN values! Ignoring for now." ) ; n [ 0 ] [ 0 ] [ m ] = p ; n [ 0 ] [ 1 ] [ m ] = q ; this . source _time += this . source _samples _per _destination ; this . source _offset = Math . floor ( this . source _time ) } n = this . source _offset ; n += this . kernel _size + 2 ; this . source _time -= this . source _offset ; this . source _block _start += this . source _offset ;
this . source _offset = 0 ; this . ensure _enough _data ( n ) ; return ! 0 } ; h . prototype . kernel = function ( m ) { return g ( m ) * g ( m / this . kernel _size ) } ; h . prototype . get _sample = function ( m , n ) { return 0 > m ? ( m += this . source _buffer _previous [ 0 ] . length , this . source _buffer _previous [ n ] [ m ] ) : this . source _buffer _current [ n ] [ m ] } ; h . prototype . ensure _enough _data = function ( m ) { var n = this . source _buffer _current [ 0 ] . length ; n - this . source _block _start < m && ( this . prepare _next _buffer ( ) , this . source _block _start -= n ) } ; h . prototype . prepare _next _buffer = function ( ) { 256 >
2024-06-28 09:23:02 +02:00
this . queued _samples && this . queue _length && this . dbg _log ( "Not enough samples - should not happen during midway of playback" ) ; this . source _buffer _previous = this . source _buffer _current ; this . source _buffer _current = this . queue _shift ( ) ; var m = this . source _buffer _current [ 0 ] . length ; if ( 256 > m ) { for ( var n = this . queue _start , p = 0 ; 256 > m && p < this . queue _length ; ) m += this . queue _data [ n ] [ 0 ] . length , n = n + 1 & this . queue _size - 1 , p ++ ; m = Math . max ( m , 256 ) ; m = [ new Float32Array ( m ) , new Float32Array ( m ) ] ; m [ 0 ] . set ( this . source _buffer _current [ 0 ] ) ; m [ 1 ] . set ( this . source _buffer _current [ 1 ] ) ;
2024-10-02 21:03:04 +02:00
n = this . source _buffer _current [ 0 ] . length ; for ( var q = 0 ; q < p ; q ++ ) { var r = this . queue _shift ( ) ; m [ 0 ] . set ( r [ 0 ] , n ) ; m [ 1 ] . set ( r [ 1 ] , n ) ; n += r [ 0 ] . length } this . source _buffer _current = m } this . pump ( ) } ; h . prototype . pump = function ( ) { 1024 > this . queued _samples / this . source _samples _per _destination && this . port . postMessage ( { type : "pump" } ) } ; h . prototype . queue _push = function ( m ) { this . queue _length < this . queue _size && ( this . queue _data [ this . queue _end ] = m , this . queue _end = this . queue _end + 1 & this . queue _size - 1 , this . queue _length ++ , this . queued _samples += m [ 0 ] . length ,
this . pump ( ) ) } ; h . prototype . queue _shift = function ( ) { if ( ! this . queue _length ) return l ; var m = this . queue _data [ this . queue _start ] ; this . queue _data [ this . queue _start ] = null ; this . queue _start = this . queue _start + 1 & this . queue _size - 1 ; this . queue _length -- ; this . queued _samples -= m [ 0 ] . length ; return m } ; h . prototype . dbg _log = function ( ) { } ; registerProcessor ( "dac-processor" , h ) } . toString ( ) ; var d = b . indexOf ( "{" ) + 1 , e = b . lastIndexOf ( "}" ) ; b = b . substring ( d , e ) ; b = new Blob ( [ b ] , { type : "application/javascript" } ) ; var f = URL . createObjectURL ( b ) ; this . node _processor =
null ; this . node _output = this . audio _context . createGain ( ) ; this . audio _context . audioWorklet . addModule ( f ) . then ( ( ) => { URL . revokeObjectURL ( f ) ; this . node _processor = new AudioWorkletNode ( this . audio _context , "dac-processor" , { numberOfInputs : 0 , numberOfOutputs : 1 , outputChannelCount : [ 2 ] , parameterData : { } , processorOptions : { } } ) ; this . node _processor . port . postMessage ( { type : "sampling-rate" , value : this . sampling _rate } ) ; this . node _processor . port . onmessage = g => { switch ( g . data . type ) { case "pump" : this . pump ( ) } } ; this . node _processor . connect ( this . node _output ) } ) ;
this . mixer _connection = c . add _source ( this . node _output , 2 ) ; this . mixer _connection . set _gain _hidden ( 3 ) ; a . register ( "dac-send-data" , function ( g ) { this . queue ( g ) } , this ) ; a . register ( "dac-enable" , function ( ) { this . enabled = ! 0 } , this ) ; a . register ( "dac-disable" , function ( ) { this . enabled = ! 1 } , this ) ; a . register ( "dac-tell-sampling-rate" , function ( g ) { this . sampling _rate = g ; this . node _processor && this . node _processor . port . postMessage ( { type : "sampling-rate" , value : g } ) } , this ) }
Ab . prototype . queue = function ( a ) { this . node _processor && this . node _processor . port . postMessage ( { type : "queue" , value : a } , [ a [ 0 ] . buffer , a [ 1 ] . buffer ] ) } ; Ab . prototype . pump = function ( ) { this . enabled && this . bus . send ( "dac-request-data" ) } ;
function Bb ( a , b , c ) { this . bus = a ; this . audio _context = b ; this . enabled = ! 1 ; this . sampling _rate = 22050 ; this . buffered _time = 0 ; this . rate _ratio = 1 ; this . node _lowpass = this . audio _context . createBiquadFilter ( ) ; this . node _lowpass . type = "lowpass" ; this . node _output = this . node _lowpass ; this . mixer _connection = c . add _source ( this . node _output , 2 ) ; this . mixer _connection . set _gain _hidden ( 3 ) ; a . register ( "dac-send-data" , function ( d ) { this . queue ( d ) } , this ) ; a . register ( "dac-enable" , function ( ) { this . enabled = ! 0 ; this . pump ( ) } , this ) ; a . register ( "dac-disable" ,
2024-06-28 09:23:02 +02:00
function ( ) { this . enabled = ! 1 } , this ) ; a . register ( "dac-tell-sampling-rate" , function ( d ) { this . sampling _rate = d ; this . rate _ratio = Math . ceil ( 8E3 / d ) ; this . node _lowpass . frequency . setValueAtTime ( d / 2 , this . audio _context . currentTime ) } , this ) }
2024-10-02 21:03:04 +02:00
Bb . prototype . queue = function ( a ) { var b = a [ 0 ] . length , c = b / this . sampling _rate ; if ( 1 < this . rate _ratio ) { var d = this . audio _context . createBuffer ( 2 , b * this . rate _ratio , this . sampling _rate * this . rate _ratio ) ; for ( var e = d . getChannelData ( 0 ) , f = d . getChannelData ( 1 ) , g = 0 , h = 0 ; h < b ; h ++ ) for ( var l = 0 ; l < this . rate _ratio ; l ++ , g ++ ) e [ g ] = a [ 0 ] [ h ] , f [ g ] = a [ 1 ] [ h ] } else d = this . audio _context . createBuffer ( 2 , b , this . sampling _rate ) , d . copyToChannel ? ( d . copyToChannel ( a [ 0 ] , 0 ) , d . copyToChannel ( a [ 1 ] , 1 ) ) : ( d . getChannelData ( 0 ) . set ( a [ 0 ] ) , d . getChannelData ( 1 ) . set ( a [ 1 ] ) ) ;
a = this . audio _context . createBufferSource ( ) ; a . buffer = d ; a . connect ( this . node _lowpass ) ; a . addEventListener ( "ended" , this . pump . bind ( this ) ) ; d = this . audio _context . currentTime ; if ( this . buffered _time < d ) for ( this . buffered _time = d , d = . 2 - c , b = 0 ; b <= d ; ) b += c , this . buffered _time += c , setTimeout ( ( ) => this . pump ( ) , 1E3 * b ) ; a . start ( this . buffered _time ) ; this . buffered _time += c ; setTimeout ( ( ) => this . pump ( ) , 0 ) } ; Bb . prototype . pump = function ( ) { this . enabled && ( . 2 < this . buffered _time - this . audio _context . currentTime || this . bus . send ( "dac-request-data" ) ) } ; function Fb ( a , b ) { function c ( h ) { g . bus && g . enabled && ( g . send _char ( h . which ) , h . preventDefault ( ) ) } function d ( h ) { var l = h . which ; 8 === l ? ( g . send _char ( 127 ) , h . preventDefault ( ) ) : 9 === l && ( g . send _char ( 9 ) , h . preventDefault ( ) ) } function e ( h ) { if ( g . enabled ) { for ( var l = h . clipboardData . getData ( "text/plain" ) , m = 0 ; m < l . length ; m ++ ) g . send _char ( l . charCodeAt ( m ) ) ; h . preventDefault ( ) } } function f ( h ) { h . target !== a && a . blur ( ) } var g = this ; this . enabled = ! 0 ; this . bus = b ; this . text = "" ; this . text _new _line = ! 1 ; this . last _update = 0 ; this . bus . register ( "serial0-output-byte" ,
function ( h ) { h = String . fromCharCode ( h ) ; this . show _char ( h ) } , this ) ; this . destroy = function ( ) { a . removeEventListener ( "keypress" , c , ! 1 ) ; a . removeEventListener ( "keydown" , d , ! 1 ) ; a . removeEventListener ( "paste" , e , ! 1 ) ; window . removeEventListener ( "mousedown" , f , ! 1 ) } ; this . init = function ( ) { this . destroy ( ) ; a . style . display = "block" ; a . addEventListener ( "keypress" , c , ! 1 ) ; a . addEventListener ( "keydown" , d , ! 1 ) ; a . addEventListener ( "paste" , e , ! 1 ) ; window . addEventListener ( "mousedown" , f , ! 1 ) } ; this . init ( ) ; this . show _char = function ( h ) { "\b" === h ? ( this . text =
this . text . slice ( 0 , - 1 ) , this . update ( ) ) : "\r" !== h && ( this . text += h , "\n" === h && ( this . text _new _line = ! 0 ) , this . update ( ) ) } ; this . update = function ( ) { var h = Date . now ( ) , l = h - this . last _update ; 16 > l ? void 0 === this . update _timer && ( this . update _timer = setTimeout ( ( ) => { this . update _timer = void 0 ; this . last _update = Date . now ( ) ; this . render ( ) } , 16 - l ) ) : ( void 0 !== this . update _timer && ( clearTimeout ( this . update _timer ) , this . update _timer = void 0 ) , this . last _update = h , this . render ( ) ) } ; this . render = function ( ) { a . value = this . text ; this . text _new _line && ( this . text _new _line =
! 1 , a . scrollTop = 1E9 ) } ; this . send _char = function ( h ) { g . bus && g . bus . send ( "serial0-input" , h ) } }
function Gb ( a , b ) { this . element = a ; if ( window . Terminal ) { var c = this . term = new window . Terminal ( { logLevel : "off" } ) ; c . write ( "This is the serial console. Whatever you type or paste here will be sent to COM1" ) ; var d = c . onData ( function ( e ) { for ( let f = 0 ; f < e . length ; f ++ ) b . send ( "serial0-input" , e . charCodeAt ( f ) ) } ) ; b . register ( "serial0-output-byte" , function ( e ) { c . write ( Uint8Array . of ( e ) ) } , this ) ; this . destroy = function ( ) { d . dispose ( ) ; c . dispose ( ) } } } Gb . prototype . show = function ( ) { this . term && this . term . open ( this . element ) } ; function Hb ( a , b , c ) { this . bus = b ; this . socket = void 0 ; this . id = c || 0 ; this . send _queue = [ ] ; this . url = a ; this . reconnect _interval = 1E4 ; this . last _connect _attempt = Date . now ( ) - this . reconnect _interval ; this . send _queue _limit = 64 ; this . bus . register ( "net" + this . id + "-send" , function ( d ) { this . send ( d ) } , this ) } Hb . prototype . handle _message = function ( a ) { this . bus && this . bus . send ( "net" + this . id + "-receive" , new Uint8Array ( a . data ) ) } ; Hb . prototype . handle _close = function ( ) { this . connect ( ) ; setTimeout ( this . connect . bind ( this ) , this . reconnect _interval ) } ;
Hb . prototype . handle _open = function ( ) { for ( var a = 0 ; a < this . send _queue . length ; a ++ ) this . send ( this . send _queue [ a ] ) ; this . send _queue = [ ] } ; Hb . prototype . handle _error = function ( ) { } ; Hb . prototype . destroy = function ( ) { this . socket && this . socket . close ( ) } ;
Hb . prototype . connect = function ( ) { if ( "undefined" !== typeof WebSocket ) { if ( this . socket ) { var a = this . socket . readyState ; if ( 0 === a || 1 === a ) return } a = Date . now ( ) ; if ( ! ( this . last _connect _attempt + this . reconnect _interval > a ) ) { this . last _connect _attempt = Date . now ( ) ; try { this . socket = new WebSocket ( this . url ) } catch ( b ) { console . error ( b ) ; return } this . socket . binaryType = "arraybuffer" ; this . socket . onopen = this . handle _open . bind ( this ) ; this . socket . onmessage = this . handle _message . bind ( this ) ; this . socket . onclose = this . handle _close . bind ( this ) ;
this . socket . onerror = this . handle _error . bind ( this ) } } } ; Hb . prototype . send = function ( a ) { this . socket && 1 === this . socket . readyState ? this . socket . send ( a ) : ( this . send _queue . push ( a ) , this . send _queue . length > 2 * this . send _queue _limit && ( this . send _queue = this . send _queue . slice ( - this . send _queue _limit ) ) , this . connect ( ) ) } ; Hb . prototype . change _proxy = function ( a ) { this . url = a ; this . socket && ( this . socket . onclose = function ( ) { } , this . socket . onerror = function ( ) { } , this . socket . close ( ) , this . socket = void 0 ) } ; function X ( a ) { this . cpu _is _running = ! 1 ; this . cpu _exception _hook = function ( ) { } ; var b = jb . create ( ) ; this . bus = b [ 0 ] ; this . emulator _bus = b [ 1 ] ; var c , d ; const e = new WebAssembly . Table ( { element : "anyfunc" , initial : 1924 } ) ; b = { cpu _exception _hook : g => this . cpu _exception _hook ( g ) , run _hardware _timers : function ( g , h ) { return c . run _hardware _timers ( g , h ) } , cpu _event _halt : ( ) => { this . emulator _bus . send ( "cpu-event-halt" ) } , abort : function ( ) { } , microtick : E . microtick , get _rand _int : function ( ) { return t . get _rand _int ( ) } , apic _acknowledge _irq : function ( ) { return c . devices . apic . acknowledge _irq ( ) } ,
stop _idling : function ( ) { return c . stop _idling ( ) } , io _port _read8 : function ( g ) { return c . io . port _read8 ( g ) } , io _port _read16 : function ( g ) { return c . io . port _read16 ( g ) } , io _port _read32 : function ( g ) { return c . io . port _read32 ( g ) } , io _port _write8 : function ( g , h ) { c . io . port _write8 ( g , h ) } , io _port _write16 : function ( g , h ) { c . io . port _write16 ( g , h ) } , io _port _write32 : function ( g , h ) { c . io . port _write32 ( g , h ) } , mmap _read8 : function ( g ) { return c . mmap _read8 ( g ) } , mmap _read16 : function ( g ) { return c . mmap _read16 ( g ) } , mmap _read32 : function ( g ) { return c . mmap _read32 ( g ) } ,
mmap _write8 : function ( g , h ) { c . mmap _write8 ( g , h ) } , mmap _write16 : function ( g , h ) { c . mmap _write16 ( g , h ) } , mmap _write32 : function ( g , h ) { c . mmap _write32 ( g , h ) } , mmap _write64 : function ( g , h , l ) { c . mmap _write64 ( g , h , l ) } , mmap _write128 : function ( g , h , l , m , n ) { c . mmap _write128 ( g , h , l , m , n ) } , log _from _wasm : function ( g , h ) { t . read _sized _string _from _mem ( d , g , h ) } , console _log _from _wasm : function ( g , h ) { g = t . read _sized _string _from _mem ( d , g , h ) ; console . error ( g ) } , dbg _trace _from _wasm : function ( ) { } , codegen _finalize : ( g , h , l , m , n ) => { c . codegen _finalize ( g , h , l ,
m , n ) } , jit _clear _func : g => c . jit _clear _func ( g ) , jit _clear _all _funcs : ( ) => c . jit _clear _all _funcs ( ) , _ _indirect _function _table : e } ; let f = a . wasm _fn ; f || ( f = g => new Promise ( h => { let l = "v86.wasm" , m = "v86-fallback.wasm" ; if ( a . wasm _path ) { l = a . wasm _path ; const n = l . lastIndexOf ( "/" ) ; m = ( - 1 === n ? "" : l . substr ( 0 , n ) ) + "/" + m } else "undefined" === typeof window && "string" === typeof _ _dirname ? ( l = _ _dirname + "/" + l , m = _ _dirname + "/" + m ) : ( l = "build/" + l , m = "build/" + m ) ; t . load _file ( l , { done : async n => { try { const { instance : p } = await WebAssembly . instantiate ( n ,
g ) ; this . wasm _source = n ; h ( p . exports ) } catch ( p ) { t . load _file ( m , { done : async q => { const { instance : r } = await WebAssembly . instantiate ( q , g ) ; this . wasm _source = q ; h ( r . exports ) } } ) } } , progress : n => { this . emulator _bus . send ( "download-progress" , { file _index : 0 , file _count : 1 , file _name : l , lengthComputable : n . lengthComputable , total : n . total , loaded : n . loaded } ) } } ) } ) ) ; f ( { env : b } ) . then ( g => { d = g . memory ; g . rust _init ( ) ; g = this . v86 = new E ( this . emulator _bus , { exports : g , wasm _table : e } ) ; c = g . cpu ; this . continue _init ( g , a ) } ) ; this . zstd _worker = null ; this . zstd _worker _request _id =
2024-06-28 09:23:02 +02:00
0 }
2024-10-02 21:03:04 +02:00
X . prototype . continue _init = async function ( a , b ) { function c ( q , r ) { switch ( q ) { case "hda" : e . hda = this . disk _images . hda = r ; break ; case "hdb" : e . hdb = this . disk _images . hdb = r ; break ; case "cdrom" : e . cdrom = this . disk _images . cdrom = r ; break ; case "fda" : e . fda = this . disk _images . fda = r ; break ; case "fdb" : e . fdb = this . disk _images . fdb = r ; break ; case "multiboot" : e . multiboot = this . disk _images . multiboot = r . buffer ; break ; case "bzimage" : e . bzimage = this . disk _images . bzimage = r . buffer ; break ; case "initrd" : e . initrd = this . disk _images . initrd = r . buffer ; break ;
case "bios" : e . bios = r . buffer ; break ; case "vga_bios" : e . vga _bios = r . buffer ; break ; case "initial_state" : e . initial _state = r . buffer ; break ; case "fs9p_json" : e . fs9p _json = r } } async function d ( ) { if ( e . fs9p && e . fs9p _json && ! e . initial _state && ( e . fs9p . load _from _json ( e . fs9p _json ) , b . bzimage _initrd _from _filesystem ) ) { const { bzimage _path : q , initrd _path : r } = this . get _bzimage _initrd _from _filesystem ( e . fs9p ) , [ D , y ] = await Promise . all ( [ e . fs9p . read _file ( r ) , e . fs9p . read _file ( q ) ] ) ; c . call ( this , "initrd" , new t . SyncBuffer ( D . buffer ) ) ; c . call ( this ,
"bzimage" , new t . SyncBuffer ( y . buffer ) ) } this . serial _adapter && this . serial _adapter . show && this . serial _adapter . show ( ) ; this . v86 . init ( e ) ; e . initial _state && ( a . restore _state ( e . initial _state ) , e . initial _state = void 0 ) ; b . autostart && this . v86 . run ( ) ; this . emulator _bus . send ( "emulator-loaded" ) } this . bus . register ( "emulator-stopped" , function ( ) { this . cpu _is _running = ! 1 ; this . screen _adapter . pause ( ) } , this ) ; this . bus . register ( "emulator-started" , function ( ) { this . cpu _is _running = ! 0 ; this . screen _adapter . continue ( ) } , this ) ; var e = { } ; this . disk _images =
{ fda : void 0 , fdb : void 0 , hda : void 0 , hdb : void 0 , cdrom : void 0 } ; var f = b . boot _order ? b . boot _order : b . fda ? 801 : b . hda ? 786 : 291 ; e . acpi = b . acpi ; e . disable _jit = b . disable _jit ; e . load _devices = ! 0 ; e . memory _size = b . memory _size || 67108864 ; e . vga _memory _size = b . vga _memory _size || 8388608 ; e . boot _order = f ; e . fastboot = b . fastboot || ! 1 ; e . fda = void 0 ; e . fdb = void 0 ; e . uart1 = b . uart1 ; e . uart2 = b . uart2 ; e . uart3 = b . uart3 ; e . cmdline = b . cmdline ; e . preserve _mac _from _state _image = b . preserve _mac _from _state _image ; e . mac _address _translation = b . mac _address _translation ;
e . cpuid _level = b . cpuid _level ; e . virtio _console = b . virtio _console ; e . virtio _net = b . virtio _net ; e . screen _options = b . screen _options ; if ( f = b . network _relay _url || b . net _device && b . net _device . relay _url ) "fetch" === f ? this . network _adapter = new Ib ( this . bus ) : f . startsWith ( "wisp://" ) || f . startsWith ( "wisps://" ) ? this . network _adapter = new Jb ( f , this . bus , b ) : this . network _adapter = new Hb ( f , this . bus ) ; e . net _device = b . net _device || { type : "ne2k" } ; f = b . screen || { } ; b . screen _container && ( f . container = b . screen _container ) ; b . disable _keyboard || ( this . keyboard _adapter =
new xb ( this . bus ) ) ; b . disable _mouse || ( this . mouse _adapter = new yb ( this . bus , f . container ) ) ; this . screen _adapter = f . container ? new aa ( f , ( ) => this . v86 . cpu . devices . vga && this . v86 . cpu . devices . vga . screen _fill _buffer ( ) ) : new Kb ; e . screen = this . screen _adapter ; e . screen _options = f ; b . serial _container && ( this . serial _adapter = new Fb ( b . serial _container , this . bus ) ) ; b . serial _container _xtermjs && ( this . serial _adapter = new Gb ( b . serial _container _xtermjs , this . bus ) ) ; b . disable _speaker || ( this . speaker _adapter = new zb ( this . bus ) ) ; var g = [ ] ; f = ( q ,
r ) => { if ( r ) if ( r . get && r . set && r . load ) g . push ( { name : q , loadable : r } ) ; else { if ( "bios" === q || "vga_bios" === q || "initial_state" === q || "multiboot" === q || "bzimage" === q || "initrd" === q ) r . async = ! 1 ; if ( "fda" === q || "fdb" === q ) r . async = ! 1 ; r . url && ! r . async ? g . push ( { name : q , url : r . url , size : r . size } ) : g . push ( { name : q , loadable : t . buffer _from _object ( r , this . zstd _decompress _worker . bind ( this ) ) } ) } } ; b . state && console . warn ( "Warning: Unknown option 'state'. Did you mean 'initial_state'?" ) ; f ( "bios" , b . bios ) ; f ( "vga_bios" , b . vga _bios ) ; f ( "cdrom" , b . cdrom ) ;
f ( "hda" , b . hda ) ; f ( "hdb" , b . hdb ) ; f ( "fda" , b . fda ) ; f ( "fdb" , b . fdb ) ; f ( "initial_state" , b . initial _state ) ; f ( "multiboot" , b . multiboot ) ; f ( "bzimage" , b . bzimage ) ; f ( "initrd" , b . initrd ) ; if ( b . filesystem ) { f = b . filesystem . basefs ; var h = b . filesystem . baseurl ; let q = new Lb ; h && ( q = new Mb ( q , h ) ) ; e . fs9p = this . fs9p = new Z ( q ) ; if ( f ) { if ( "object" === typeof f ) { var l = f . size ; f = f . url } g . push ( { name : "fs9p_json" , url : f , size : l , as _json : ! 0 } ) } } var m = this , n = g . length , p = function ( q ) { if ( q === n ) setTimeout ( d . bind ( this ) , 0 ) ; else { var r = g [ q ] ; r . loadable ? ( r . loadable . onload =
function ( ) { c . call ( this , r . name , r . loadable ) ; p ( q + 1 ) } . bind ( this ) , r . loadable . load ( ) ) : t . load _file ( r . url , { done : function ( D ) { r . url . endsWith ( ".zst" ) && "initial_state" !== r . name && ( D = this . zstd _decompress ( r . size , new Uint8Array ( D ) ) ) ; c . call ( this , r . name , r . as _json ? D : new t . SyncBuffer ( D ) ) ; p ( q + 1 ) } . bind ( this ) , progress : function ( D ) { 200 === D . target . status ? m . emulator _bus . send ( "download-progress" , { file _index : q , file _count : n , file _name : r . url , lengthComputable : D . lengthComputable , total : D . total || r . size , loaded : D . loaded } ) : m . emulator _bus . send ( "download-error" ,
{ file _index : q , file _count : n , file _name : r . url , request : D . target } ) } , as _json : r . as _json } ) } } . bind ( this ) ; p ( 0 ) } ; X . prototype . zstd _decompress = function ( a , b ) { const c = this . v86 . cpu ; this . zstd _context = c . zstd _create _ctx ( b . length ) ; ( new Uint8Array ( c . wasm _memory . buffer ) ) . set ( b , c . zstd _get _src _ptr ( this . zstd _context ) ) ; b = c . zstd _read ( this . zstd _context , a ) ; const d = c . wasm _memory . buffer . slice ( b , b + a ) ; c . zstd _read _free ( b , a ) ; c . zstd _free _ctx ( this . zstd _context ) ; this . zstd _context = null ; return d } ;
X . prototype . zstd _decompress _worker = async function ( a , b ) { if ( ! this . zstd _worker ) { const c = URL . createObjectURL ( new Blob ( [ "(" + function ( ) { let d ; globalThis . onmessage = function ( e ) { if ( d ) { var { src : f , decompressed _size : g , id : h } = e . data ; e = d . exports ; var l = e . zstd _create _ctx ( f . length ) ; ( new Uint8Array ( e . memory . buffer ) ) . set ( f , e . zstd _get _src _ptr ( l ) ) ; var m = e . zstd _read ( l , g ) , n = e . memory . buffer . slice ( m , m + g ) ; e . zstd _read _free ( m , g ) ; e . zstd _free _ctx ( l ) ; postMessage ( { result : n , id : h } , [ n ] ) } else l = Object . fromEntries ( "cpu_exception_hook run_hardware_timers cpu_event_halt microtick get_rand_int apic_acknowledge_irq stop_idling io_port_read8 io_port_read16 io_port_read32 io_port_write8 io_port_write16 io_port_write32 mmap_read8 mmap_read16 mmap_read32 mmap_write8 mmap_write16 mmap_write32 mmap_write64 mmap_write128 codegen_finalize jit_clear_func jit_clear_all_funcs" . split ( " " ) . map ( p =>
[ p , ( ) => console . error ( "zstd worker unexpectedly called " + p ) ] ) ) , l . _ _indirect _function _table = new WebAssembly . Table ( { element : "anyfunc" , initial : 1024 } ) , l . abort = ( ) => { throw Error ( "zstd worker aborted" ) ; } , l . log _from _wasm = l . console _log _from _wasm = ( p , q ) => { console . log ( String . fromCharCode ( ... ( new Uint8Array ( d . exports . memory . buffer , p , q ) ) ) ) } , l . dbg _trace _from _wasm = ( ) => console . trace ( ) , d = new WebAssembly . Instance ( new WebAssembly . Module ( e . data ) , { env : l } ) } } . toString ( ) + ")()" ] , { type : "text/javascript" } ) ) ; this . zstd _worker =
new Worker ( c ) ; URL . revokeObjectURL ( c ) ; this . zstd _worker . postMessage ( this . wasm _source , [ this . wasm _source ] ) } return new Promise ( c => { const d = this . zstd _worker _request _id ++ , e = async f => { f . data . id === d && ( this . zstd _worker . removeEventListener ( "message" , e ) , c ( f . data . result ) ) } ; this . zstd _worker . addEventListener ( "message" , e ) ; this . zstd _worker . postMessage ( { src : b , decompressed _size : a , id : d } , [ b . buffer ] ) } ) } ;
X . prototype . get _bzimage _initrd _from _filesystem = function ( a ) { const b = ( a . read _dir ( "/" ) || [ ] ) . map ( e => "/" + e ) ; a = ( a . read _dir ( "/boot/" ) || [ ] ) . map ( e => "/boot/" + e ) ; let c , d ; for ( const e of [ ] . concat ( b , a ) ) { const f = /old/i . test ( e ) || /fallback/i . test ( e ) , g = /vmlinuz/i . test ( e ) || /bzimage/i . test ( e ) , h = /initrd/i . test ( e ) || /initramfs/i . test ( e ) ; ! g || d && f || ( d = e ) ; ! h || c && f || ( c = e ) } c && d || ( console . log ( "Failed to find bzimage or initrd in filesystem. Files:" ) , console . log ( b . join ( " " ) ) , console . log ( a . join ( " " ) ) ) ; return { initrd _path : c , bzimage _path : d } } ;
X . prototype . run = async function ( ) { this . v86 . run ( ) } ; H . exportProperty ( X . prototype , "run" , X . prototype . run ) ; X . prototype . stop = async function ( ) { this . cpu _is _running && await new Promise ( a => { const b = ( ) => { this . remove _listener ( "emulator-stopped" , b ) ; a ( ) } ; this . add _listener ( "emulator-stopped" , b ) ; this . v86 . stop ( ) } ) } ; H . exportProperty ( X . prototype , "stop" , X . prototype . stop ) ;
X . prototype . destroy = async function ( ) { await this . stop ( ) ; this . v86 . destroy ( ) ; this . keyboard _adapter && this . keyboard _adapter . destroy ( ) ; this . network _adapter && this . network _adapter . destroy ( ) ; this . mouse _adapter && this . mouse _adapter . destroy ( ) ; this . screen _adapter && this . screen _adapter . destroy ( ) ; this . serial _adapter && this . serial _adapter . destroy ( ) ; this . speaker _adapter && this . speaker _adapter . destroy ( ) } ; H . exportProperty ( X . prototype , "destroy" , X . prototype . destroy ) ; X . prototype . restart = function ( ) { this . v86 . restart ( ) } ;
H . exportProperty ( X . prototype , "restart" , X . prototype . restart ) ; X . prototype . add _listener = function ( a , b ) { this . bus . register ( a , b , this ) } ; H . exportProperty ( X . prototype , "add_listener" , X . prototype . add _listener ) ; X . prototype . remove _listener = function ( a , b ) { this . bus . unregister ( a , b ) } ; H . exportProperty ( X . prototype , "remove_listener" , X . prototype . remove _listener ) ; X . prototype . restore _state = async function ( a ) { this . v86 . restore _state ( a ) } ; H . exportProperty ( X . prototype , "restore_state" , X . prototype . restore _state ) ;
X . prototype . save _state = async function ( ) { return this . v86 . save _state ( ) } ; H . exportProperty ( X . prototype , "save_state" , X . prototype . save _state ) ; X . prototype . get _instruction _counter = function ( ) { return this . v86 ? this . v86 . cpu . instruction _counter [ 0 ] >>> 0 : 0 } ; H . exportProperty ( X . prototype , "get_instruction_counter" , X . prototype . get _instruction _counter ) ; X . prototype . is _running = function ( ) { return this . cpu _is _running } ; H . exportProperty ( X . prototype , "is_running" , X . prototype . is _running ) ;
X . prototype . set _fda = async function ( a ) { if ( a . url && ! a . async ) t . load _file ( a . url , { done : b => { this . v86 . cpu . devices . fdc . set _fda ( new t . SyncBuffer ( b ) ) } } ) ; else { const b = t . buffer _from _object ( a , this . zstd _decompress _worker . bind ( this ) ) ; b . onload = ( ) => { this . v86 . cpu . devices . fdc . set _fda ( b ) } ; await b . load ( ) } } ; H . exportProperty ( X . prototype , "set_fda" , X . prototype . set _fda ) ; X . prototype . eject _fda = function ( ) { this . v86 . cpu . devices . fdc . eject _fda ( ) } ; H . exportProperty ( X . prototype , "eject_fda" , X . prototype . eject _fda ) ;
X . prototype . keyboard _send _scancodes = function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) this . bus . send ( "keyboard-code" , a [ b ] ) } ; H . exportProperty ( X . prototype , "keyboard_send_scancodes" , X . prototype . keyboard _send _scancodes ) ; X . prototype . keyboard _send _keys = function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) this . keyboard _adapter . simulate _press ( a [ b ] ) } ; H . exportProperty ( X . prototype , "keyboard_send_keys" , X . prototype . keyboard _send _keys ) ; X . prototype . keyboard _send _text = function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) this . keyboard _adapter . simulate _char ( a [ b ] ) } ;
H . exportProperty ( X . prototype , "keyboard_send_text" , X . prototype . keyboard _send _text ) ; X . prototype . screen _make _screenshot = function ( ) { return this . screen _adapter ? this . screen _adapter . make _screenshot ( ) : null } ; H . exportProperty ( X . prototype , "screen_make_screenshot" , X . prototype . screen _make _screenshot ) ; X . prototype . screen _set _scale = function ( a , b ) { this . screen _adapter && this . screen _adapter . set _scale ( a , b ) } ; H . exportProperty ( X . prototype , "screen_set_scale" , X . prototype . screen _set _scale ) ;
X . prototype . screen _go _fullscreen = function ( ) { if ( this . screen _adapter ) { var a = document . getElementById ( "screen_container" ) ; if ( a ) { var b = a . requestFullScreen || a . webkitRequestFullscreen || a . mozRequestFullScreen || a . msRequestFullScreen ; b && ( b . call ( a ) , ( a = document . getElementsByClassName ( "phone_keyboard" ) [ 0 ] ) && a . focus ( ) ) ; try { navigator . keyboard . lock ( ) } catch ( c ) { } this . lock _mouse ( ) } } } ; H . exportProperty ( X . prototype , "screen_go_fullscreen" , X . prototype . screen _go _fullscreen ) ;
X . prototype . lock _mouse = function ( ) { var a = document . body , b = a . requestPointerLock || a . mozRequestPointerLock || a . webkitRequestPointerLock ; b && b . call ( a ) } ; H . exportProperty ( X . prototype , "lock_mouse" , X . prototype . lock _mouse ) ; X . prototype . mouse _set _status = function ( a ) { this . mouse _adapter && ( this . mouse _adapter . emu _enabled = a ) } ; X . prototype . keyboard _set _status = function ( a ) { this . keyboard _adapter && ( this . keyboard _adapter . emu _enabled = a ) } ; H . exportProperty ( X . prototype , "keyboard_set_status" , X . prototype . keyboard _set _status ) ;
X . prototype . serial0 _send = function ( a ) { for ( var b = 0 ; b < a . length ; b ++ ) this . bus . send ( "serial0-input" , a . charCodeAt ( b ) ) } ; H . exportProperty ( X . prototype , "serial0_send" , X . prototype . serial0 _send ) ; X . prototype . serial _send _bytes = function ( a , b ) { for ( var c = 0 ; c < b . length ; c ++ ) this . bus . send ( "serial" + a + "-input" , b [ c ] ) } ; H . exportProperty ( X . prototype , "serial_send_bytes" , X . prototype . serial _send _bytes ) ; X . prototype . serial _set _modem _status = function ( a , b ) { this . bus . send ( "serial" + a + "-modem-status-input" , b ) } ;
X . prototype . serial _set _carrier _detect = function ( a , b ) { this . bus . send ( "serial" + a + "-carrier-detect-input" , b ) } ; X . prototype . serial _set _ring _indicator = function ( a , b ) { this . bus . send ( "serial" + a + "-ring-indicator-input" , b ) } ; X . prototype . serial _set _data _set _ready = function ( a , b ) { this . bus . send ( "serial" + a + "-data-set-ready-input" , b ) } ; X . prototype . serial _set _clear _to _send = function ( a , b ) { this . bus . send ( "serial" + a + "-clear-to-send-input" , b ) } ;
X . prototype . mount _fs = async function ( a , b , c ) { var d = new Lb ; b && ( d = new Mb ( d , b ) ) ; d = new Z ( d , this . fs9p . qidcounter ) ; b && d . load _from _json ( c ) ; a = this . fs9p . Mount ( a , d ) ; if ( - 2 === a ) throw new Nb ; if ( - 17 === a ) throw new Ob ; if ( 0 > a ) throw Error ( "Failed to mount. Error number: " + - a ) ; } ; H . exportProperty ( X . prototype , "mount_fs" , X . prototype . mount _fs ) ; X . prototype . create _file = async function ( a , b ) { var c = this . fs9p ; if ( c ) { var d = a . split ( "/" ) ; d = d [ d . length - 1 ] ; a = c . SearchPath ( a ) . parentid ; if ( "" !== d && - 1 !== a ) await c . CreateBinaryFile ( d , a , b ) ; else return Promise . reject ( new Nb ) } } ;
H . exportProperty ( X . prototype , "create_file" , X . prototype . create _file ) ; X . prototype . read _file = async function ( a ) { var b = this . fs9p ; if ( b ) return ( a = await b . read _file ( a ) ) ? a : Promise . reject ( new Nb ) } ; H . exportProperty ( X . prototype , "read_file" , X . prototype . read _file ) ;
X . prototype . automatically = function ( a ) { const b = c => { const d = c [ 0 ] ; if ( d ) { var e = c . slice ( 1 ) ; d . sleep ? setTimeout ( ( ) => b ( e ) , 1E3 * d . sleep ) : d . vga _text ? this . wait _until _vga _screen _contains ( d . vga _text ) . then ( ( ) => b ( e ) ) : d . keyboard _send ? ( d . keyboard _send instanceof Array ? this . keyboard _send _scancodes ( d . keyboard _send ) : this . keyboard _send _text ( d . keyboard _send ) , b ( e ) ) : d . call && ( d . call ( ) , b ( e ) ) } } ; b ( a ) } ;
X . prototype . wait _until _vga _screen _contains = function ( a ) { return new Promise ( b => { function c ( g ) { return "string" === typeof a ? g . includes ( a ) : a . test ( g ) } function d ( g ) { [ g ] = g ; e . add ( g ) } for ( const g of this . screen _adapter . get _text _screen ( ) ) if ( c ( g ) ) { b ( ! 0 ) ; return } const e = new Set , f = ( ) => { for ( const g of e ) { const h = this . screen _adapter . get _text _row ( g ) ; if ( c ( h ) ) { this . remove _listener ( "screen-put-char" , d ) ; b ( ) ; return } } e . clear ( ) ; setTimeout ( f , 100 ) } ; f ( ) ; this . add _listener ( "screen-put-char" , d ) } ) } ;
X . prototype . read _memory = function ( a , b ) { return this . v86 . cpu . read _blob ( a , b ) } ; X . prototype . write _memory = function ( a , b ) { this . v86 . cpu . write _blob ( a , b ) } ; X . prototype . set _serial _container _xtermjs = function ( a ) { this . serial _adapter && this . serial _adapter . destroy && this . serial _adapter . destroy ( ) ; this . serial _adapter = new Gb ( a , this . bus ) ; this . serial _adapter . show ( ) } ; function Ob ( a ) { this . message = a || "File already exists" } Ob . prototype = Error . prototype ; function Nb ( a ) { this . message = a || "File not found" } Nb . prototype = Error . prototype ;
"undefined" !== typeof module && "undefined" !== typeof module . exports ? module . exports . V86 = X : "undefined" !== typeof window ? window . V86 = X : "function" === typeof importScripts && ( self . V86 = X ) ; var Pb = { Connector : function ( a ) { this . listeners = { } ; this . pair = a ; a . addEventListener ( "message" , function ( b ) { b = b . data ; for ( var c = this . listeners [ b [ 0 ] ] , d = 0 ; d < c . length ; d ++ ) { var e = c [ d ] ; e . fn . call ( e . this _value , b [ 1 ] ) } } . bind ( this ) , ! 1 ) } } ; Pb . Connector . prototype . register = function ( a , b , c ) { var d = this . listeners [ a ] ; void 0 === d && ( d = this . listeners [ a ] = [ ] ) ; d . push ( { fn : b , this _value : c } ) } ; Pb . Connector . prototype . send = function ( a , b , c ) { this . pair && this . pair . postMessage ( [ a , b ] , c ) } ; Pb . init = function ( a ) { return new Pb . Connector ( a ) } ; function Kb ( ) { var a , b = 0 , c = 0 ; this . put _char = function ( d , e , f ) { a [ d * b + e ] = f } ; this . destroy = function ( ) { } ; this . pause = function ( ) { } ; this . continue = function ( ) { } ; this . set _mode = function ( ) { } ; this . clear _screen = function ( ) { } ; this . set _size _text = function ( d , e ) { if ( d !== b || e !== c ) a = new Uint8Array ( d * e ) , b = d , c = e } ; this . set _size _graphical = function ( ) { } ; this . set _scale = function ( ) { } ; this . update _cursor _scanline = function ( ) { } ; this . update _cursor = function ( ) { } ; this . update _buffer = function ( ) { } ; this . get _text _screen = function ( ) { for ( var d = [ ] , e =
0 ; e < c ; e ++ ) d . push ( this . get _text _row ( e ) ) ; return d } ; this . get _text _row = function ( d ) { d *= b ; return String . fromCharCode . apply ( String , a . subarray ( d , d + b ) ) } ; this . set _size _text ( 80 , 25 ) } ; const Qb = ( new Date ( "1970-01-01T00:00:00Z" ) ) . getTime ( ) , Rb = ( new Date ( "1900-01-01T00:00:00Z" ) ) . getTime ( ) , Sb = Qb - Rb , Tb = Math . pow ( 2 , 32 ) , Ub = [ 118 , 56 , 54 ] ; function Vb ( a ) { return [ 0 , 1 , 2 , 3 , 4 , 5 ] . map ( b => a [ b ] . toString ( 16 ) ) . map ( b => 1 === b . length ? "0" + b : b ) . join ( ":" ) } function Wb ( a ) { return a [ 0 ] << 24 | a [ 1 ] << 16 | a [ 2 ] << 8 | a [ 3 ] }
function Xb ( a , b ) { let c = Date . now ( ) + Sb , d = c % 1E3 / 1E3 * Tb , e = { } ; e . eth = { ethertype : 2048 , src : b . router _mac , dest : a . eth . src } ; e . ipv4 = { proto : 17 , src : a . ipv4 . dest , dest : a . ipv4 . src } ; e . udp = { sport : 123 , dport : a . udp . sport } ; e . ntp = Object . assign ( { } , a . ntp ) ; e . ntp . flags = 36 ; e . ntp . poll = 10 ; e . ntp . ori _ts _i = a . ntp . trans _ts _i ; e . ntp . ori _ts _f = a . ntp . trans _ts _f ; e . ntp . rec _ts _i = c / 1E3 ; e . ntp . rec _ts _f = d ; e . ntp . trans _ts _i = c / 1E3 ; e . ntp . trans _ts _f = d ; e . ntp . stratum = 2 ; b . receive ( Yb ( e ) ) ; return ! 0 }
function Zb ( a , b ) { let c = { } ; c . eth = { ethertype : 2048 , src : b . router _mac , dest : a . eth . src } ; c . ipv4 = { proto : 17 , src : b . router _ip , dest : b . vm _ip } ; c . udp = { sport : 67 , dport : 68 } ; c . dhcp = { htype : 1 , hlen : 6 , hops : 0 , xid : a . dhcp . xid , secs : 0 , flags : 0 , ciaddr : 0 , yiaddr : Wb ( b . vm _ip ) , siaddr : Wb ( b . router _ip ) , giaddr : Wb ( b . router _ip ) , chaddr : a . dhcp . chaddr } ; let d = [ ] , e = a . dhcp . options . find ( function ( f ) { return 53 === f [ 0 ] } ) ; e && 3 === e [ 2 ] && ( a . dhcp . op = 3 ) ; 1 === a . dhcp . op && ( c . dhcp . op = 2 , d . push ( new Uint8Array ( [ 53 , 1 , 2 ] ) ) ) ; 3 === a . dhcp . op && ( c . dhcp . op = 2 , d . push ( new Uint8Array ( [ 53 ,
1 , 5 ] ) ) , d . push ( new Uint8Array ( [ 51 , 4 , 8 , 0 , 0 , 0 ] ) ) ) ; a = [ b . router _ip [ 0 ] , b . router _ip [ 1 ] , b . router _ip [ 2 ] , b . router _ip [ 3 ] ] ; d . push ( new Uint8Array ( [ 1 , 4 , 255 , 255 , 255 , 0 ] ) ) ; b . masquerade && ( d . push ( new Uint8Array ( [ 3 , 4 ] . concat ( a ) ) ) , d . push ( new Uint8Array ( [ 6 , 4 ] . concat ( a ) ) ) ) ; d . push ( new Uint8Array ( [ 54 , 4 ] . concat ( a ) ) ) ; d . push ( new Uint8Array ( [ 60 , 3 ] . concat ( Ub ) ) ) ; d . push ( new Uint8Array ( [ 255 , 0 ] ) ) ; c . dhcp . options = d ; b . receive ( Yb ( c ) ) }
function $b ( a , b ) { var c = ( new DataView ( a . buffer , a . byteOffset , a . byteLength ) ) . getUint16 ( 12 ) , d = { ethertype : c , dest : a . subarray ( 0 , 6 ) , dest _s : Vb ( a . subarray ( 0 , 6 ) ) , src : a . subarray ( 6 , 12 ) , src _s : Vb ( a . subarray ( 6 , 12 ) ) } ; b . eth = d ; a = a . subarray ( 14 , a . length ) ; if ( 2048 === c ) { var e = new DataView ( a . buffer , a . byteOffset , a . byteLength ) , f = a [ 0 ] >> 4 & 15 ; d = a [ 0 ] & 15 ; var g = e . getUint8 ( 1 ) , h = e . getUint16 ( 2 ) , l = e . getUint8 ( 8 ) ; c = e . getUint8 ( 9 ) ; e = e . getUint16 ( 10 ) ; f = { version : f , ihl : d , tos : g , len : h , ttl : l , proto : c , ip _checksum : e , src : a . subarray ( 12 , 16 ) , dest : a . subarray ( 16 ,
20 ) } ; b . ipv4 = f ; a = a . subarray ( 4 * d , h ) ; 1 === c && ( d = a , h = new DataView ( d . buffer , d . byteOffset , d . byteLength ) , d = { type : h . getUint8 ( 0 ) , code : h . getUint8 ( 1 ) , checksum : h . getUint16 ( 2 ) , data : d . subarray ( 4 ) } , b . icmp = d ) ; 6 === c && ( d = a , f = new DataView ( d . buffer , d . byteOffset , d . byteLength ) , h = { sport : f . getUint16 ( 0 ) , dport : f . getUint16 ( 2 ) , seq : f . getUint32 ( 4 ) , ackn : f . getUint32 ( 8 ) , doff : f . getUint8 ( 12 ) >> 4 , winsize : f . getUint16 ( 14 ) , checksum : f . getUint16 ( 16 ) , urgent : f . getUint16 ( 18 ) } , f = f . getUint8 ( 13 ) , h . fin = ! ! ( f & 1 ) , h . syn = ! ! ( f & 2 ) , h . rst = ! ! ( f & 4 ) , h . psh = ! ! ( f &
8 ) , h . ack = ! ! ( f & 16 ) , h . urg = ! ! ( f & 32 ) , h . ece = ! ! ( f & 64 ) , h . cwr = ! ! ( f & 128 ) , b . tcp = h , b . tcp _data = d . subarray ( 4 * h . doff ) ) ; if ( 17 === c ) { c = new DataView ( a . buffer , a . byteOffset , a . byteLength ) ; c = { sport : c . getUint16 ( 0 ) , dport : c . getUint16 ( 2 ) , len : c . getUint16 ( 4 ) , checksum : c . getUint16 ( 6 ) , data : a . subarray ( 8 ) , data _s : ( new TextDecoder ) . decode ( a . subarray ( 8 ) ) } ; if ( 67 === c . dport || 67 === c . sport ) { h = a . subarray ( 8 ) ; d = new DataView ( h . buffer , h . byteOffset , h . byteLength ) ; h . subarray ( 44 , 236 ) ; d = { op : d . getUint8 ( 0 ) , htype : d . getUint8 ( 1 ) , hlen : d . getUint8 ( 2 ) , hops : d . getUint8 ( 3 ) ,
xid : d . getUint32 ( 4 ) , secs : d . getUint16 ( 8 ) , flags : d . getUint16 ( 10 ) , ciaddr : d . getUint32 ( 12 ) , yiaddr : d . getUint32 ( 16 ) , siaddr : d . getUint32 ( 20 ) , giaddr : d . getUint32 ( 24 ) , chaddr : h . subarray ( 28 , 44 ) , magic : d . getUint32 ( 236 ) , options : [ ] } ; h = h . subarray ( 240 ) ; for ( f = 0 ; f < h . length ; ++ f ) g = f , 0 !== h [ f ] && ( ++ f , l = h [ f ] , f += l , d . options . push ( h . subarray ( g , g + l + 2 ) ) ) ; b . dhcp = d ; b . dhcp _options = d . options } 53 !== c . dport && 53 !== c . sport || ac ( a . subarray ( 8 ) , b ) ; 123 === c . dport && ( a = a . subarray ( 8 ) , a = new DataView ( a . buffer , a . byteOffset , a . byteLength ) , b . ntp = { flags : a . getUint8 ( 0 ) ,
stratum : a . getUint8 ( 1 ) , poll : a . getUint8 ( 2 ) , precision : a . getUint8 ( 3 ) , root _delay : a . getUint32 ( 4 ) , root _disp : a . getUint32 ( 8 ) , ref _id : a . getUint32 ( 12 ) , ref _ts _i : a . getUint32 ( 16 ) , ref _ts _f : a . getUint32 ( 20 ) , ori _ts _i : a . getUint32 ( 24 ) , ori _ts _f : a . getUint32 ( 28 ) , rec _ts _i : a . getUint32 ( 32 ) , rec _ts _f : a . getUint32 ( 36 ) , trans _ts _i : a . getUint32 ( 40 ) , trans _ts _f : a . getUint32 ( 44 ) } ) ; b . udp = c } } else 2054 === c ? ( c = new DataView ( a . buffer , a . byteOffset , a . byteLength ) , c = { htype : c . getUint16 ( 0 ) , ptype : c . getUint16 ( 2 ) , oper : c . getUint16 ( 6 ) , sha : a . subarray ( 8 ,
14 ) , spa : a . subarray ( 14 , 18 ) , tha : a . subarray ( 18 , 24 ) , tpa : a . subarray ( 24 , 28 ) } , b . arp = c ) : 34525 !== c && A ( c ) }
function ac ( a , b ) { function c ( ) { let m = [ ] , n ; do n = d . getUint8 ( h ) , m . push ( ( new TextDecoder ) . decode ( a . subarray ( h + 1 , h + 1 + n ) ) ) , h += n + 1 ; while ( 0 < n ) ; return m } let d = new DataView ( a . buffer , a . byteOffset , a . byteLength ) , e = { id : d . getUint16 ( 0 ) , flags : d . getUint16 ( 2 ) , questions : [ ] , answers : [ ] } ; var f = d . getUint16 ( 4 ) ; let g = d . getUint16 ( 6 ) ; d . getUint16 ( 8 ) ; d . getUint16 ( 10 ) ; let h = 12 ; for ( var l = 0 ; l < f ; l ++ ) e . questions . push ( { name : c ( ) , type : d . getInt16 ( h ) , class : d . getInt16 ( h + 2 ) } ) , h += 4 ; for ( f = 0 ; f < g ; f ++ ) { l = { name : c ( ) , type : d . getInt16 ( h ) , class : d . getUint16 ( h +
2 ) , ttl : d . getUint32 ( h + 4 ) } ; h += 8 ; let m = d . getUint16 ( h ) ; h += 2 ; l . data = a . subarray ( h , h + m ) ; h += m ; e . answers . push ( l ) } b . dns = e }
function Yb ( a ) { let b = new Uint8Array ( 1518 ) ; var c = new DataView ( b . buffer , b . byteOffset , b . byteLength ) ; c . setUint16 ( 12 , a . eth . ethertype ) ; for ( var d = 0 ; 6 > d ; ++ d ) c . setUint8 ( 0 + d , a . eth . dest [ d ] ) ; for ( d = 0 ; 6 > d ; ++ d ) c . setUint8 ( 6 + d , a . eth . src [ d ] ) ; c = 14 ; if ( a . arp ) { d = b . subarray ( 14 ) ; d = new DataView ( d . buffer , d . byteOffset , d . byteLength ) ; d . setUint16 ( 0 , a . arp . htype ) ; d . setUint16 ( 2 , a . arp . ptype ) ; d . setUint8 ( 4 , a . arp . sha . length ) ; d . setUint8 ( 5 , a . arp . spa . length ) ; d . setUint16 ( 6 , a . arp . oper ) ; for ( var e = 0 ; 6 > e ; ++ e ) d . setUint8 ( 8 + e , a . arp . sha [ e ] ) , d . setUint8 ( 18 +
e , a . arp . tha [ e ] ) ; for ( e = 0 ; 4 > e ; ++ e ) d . setUint8 ( 14 + e , a . arp . spa [ e ] ) , d . setUint8 ( 24 + e , a . arp . tpa [ e ] ) ; c += 28 } if ( a . ipv4 ) { e = b . subarray ( 14 ) ; d = new DataView ( e . buffer , e . byteOffset , e . byteLength ) ; var f = 20 ; if ( a . icmp ) { var g = e . subarray ( 20 ) ; g = new DataView ( g . buffer , g . byteOffset , g . byteLength ) ; g . setUint8 ( 0 , a . icmp . type ) ; g . setUint8 ( 1 , a . icmp . code ) ; g . setUint16 ( 2 , 0 ) ; for ( var h = 0 ; h < a . icmp . data . length ; ++ h ) g . setUint8 ( h + 4 , a . icmp . data [ h ] ) ; h = 0 ; for ( var l = 0 ; l < 4 + a . icmp . data . length ; l += 2 ) h += g . getUint16 ( l ) , 65535 < h && ( h = ( h & 65535 ) + 1 ) ; g . setUint16 ( 2 ,
h ^ 65535 ) ; f += 4 + a . icmp . data . length } if ( a . udp ) { h = e . subarray ( 20 ) ; g = new DataView ( h . buffer , h . byteOffset , h . byteLength ) ; if ( a . dhcp ) { var m = h . subarray ( 8 ) ; m = new DataView ( m . buffer , m . byteOffset , m . byteLength ) ; m . setUint8 ( 0 , a . dhcp . op ) ; m . setUint8 ( 1 , a . dhcp . htype ) ; m . setUint8 ( 2 , a . dhcp . hlen ) ; m . setUint8 ( 3 , a . dhcp . hops ) ; m . setUint32 ( 4 , a . dhcp . xid ) ; m . setUint16 ( 8 , a . dhcp . secs ) ; m . setUint16 ( 10 , a . dhcp . flags ) ; m . setUint32 ( 12 , a . dhcp . ciaddr ) ; m . setUint32 ( 16 , a . dhcp . yiaddr ) ; m . setUint32 ( 20 , a . dhcp . siaddr ) ; m . setUint32 ( 24 , a . dhcp . giaddr ) ; for ( var n =
0 ; n < a . dhcp . chaddr . length ; ++ n ) m . setUint8 ( 28 + n , a . dhcp . chaddr [ n ] ) ; m . setUint32 ( 236 , 1669485411 ) ; n = 240 ; for ( var p of a . dhcp . options ) for ( h = 0 ; h < p . length ; ++ h ) m . setUint8 ( n , p [ h ] ) , ++ n ; m = n } else if ( a . dns ) { p = h . subarray ( 8 ) ; p = new DataView ( p . buffer , p . byteOffset , p . byteLength ) ; p . setUint16 ( 0 , a . dns . id ) ; p . setUint16 ( 2 , a . dns . flags ) ; p . setUint16 ( 4 , a . dns . questions . length ) ; p . setUint16 ( 6 , a . dns . answers . length ) ; h = 12 ; for ( l = 0 ; l < a . dns . questions . length ; ++ l ) { var q = a . dns . questions [ l ] ; for ( n of q . name ) { p . setUint8 ( h , n . length ) ; h ++ ; for ( let r =
0 ; r < n . length ; ++ r ) p . setUint8 ( h , n . charCodeAt ( r ) ) , h ++ } p . setUint16 ( h , q . type ) ; h += 2 ; p . setUint16 ( h , q . class ) ; h += 2 } for ( l = 0 ; l < a . dns . answers . length ; ++ l ) { n = a . dns . answers [ l ] ; for ( m of n . name ) for ( p . setUint8 ( h , m . length ) , h ++ , q = 0 ; q < m . length ; ++ q ) p . setUint8 ( h , m . charCodeAt ( q ) ) , h ++ ; p . setUint16 ( h , n . type ) ; h += 2 ; p . setUint16 ( h , n . class ) ; h += 2 ; p . setUint32 ( h , n . ttl ) ; h += 4 ; p . setUint16 ( h , n . data . length ) ; h += 2 ; for ( q = 0 ; q < n . data . length ; ++ q ) p . setUint8 ( h + q , n . data [ q ] ) ; h += n . data . length } m = h } else if ( a . ntp ) m = h . subarray ( 8 ) , m = new DataView ( m . buffer ,
m . byteOffset , m . byteLength ) , m . setUint8 ( 0 , a . ntp . flags ) , m . setUint8 ( 1 , a . ntp . stratum ) , m . setUint8 ( 2 , a . ntp . poll ) , m . setUint8 ( 3 , a . ntp . precision ) , m . setUint32 ( 4 , a . ntp . root _delay ) , m . setUint32 ( 8 , a . ntp . root _disp ) , m . setUint32 ( 12 , a . ntp . ref _id ) , m . setUint32 ( 16 , a . ntp . ref _ts _i ) , m . setUint32 ( 20 , a . ntp . ref _ts _f ) , m . setUint32 ( 24 , a . ntp . ori _ts _i ) , m . setUint32 ( 28 , a . ntp . ori _ts _f ) , m . setUint32 ( 32 , a . ntp . rec _ts _i ) , m . setUint32 ( 36 , a . ntp . rec _ts _f ) , m . setUint32 ( 40 , a . ntp . trans _ts _i ) , m . setUint32 ( 44 , a . ntp . trans _ts _f ) , m = 48 ; else for ( n = a . udp . data ,
m = n . length , p = 0 ; p < n . length ; ++ p ) g . setUint8 ( 8 + p , n [ p ] ) ; g . setUint16 ( 0 , a . udp . sport ) ; g . setUint16 ( 2 , a . udp . dport ) ; g . setUint16 ( 4 , 8 + m ) ; g . setUint16 ( 6 , 0 ) ; f += 8 + m } if ( a . tcp ) { m = f ; e = e . subarray ( 20 ) ; e = new DataView ( e . buffer , e . byteOffset , e . byteLength ) ; n = 0 ; p = a . tcp ; p . fin && ( n |= 1 ) ; p . syn && ( n |= 2 ) ; p . rst && ( n |= 4 ) ; p . psh && ( n |= 8 ) ; p . ack && ( n |= 16 ) ; p . urg && ( n |= 32 ) ; p . ece && ( n |= 64 ) ; p . cwr && ( n |= 128 ) ; e . setUint16 ( 0 , p . sport ) ; e . setUint16 ( 2 , p . dport ) ; e . setUint32 ( 4 , p . seq ) ; e . setUint32 ( 8 , p . ackn ) ; e . setUint8 ( 12 , 80 ) ; e . setUint8 ( 13 , n ) ; e . setUint16 ( 14 , p . winsize ) ;
e . setUint16 ( 16 , 0 ) ; e . setUint16 ( 18 , p . urgent || 0 ) ; p = 20 + ( a . tcp _data ? a . tcp _data . length : 0 ) ; n = 0 ; f = new Uint8Array ( 12 ) ; f = new DataView ( f . buffer , f . byteOffset , f . byteLength ) ; for ( g = 0 ; 4 > g ; ++ g ) f . setUint8 ( g , a . ipv4 . src [ g ] ) , f . setUint8 ( 4 + g , a . ipv4 . dest [ g ] ) ; f . setUint8 ( 9 , 6 ) ; f . setUint16 ( 10 , p ) ; for ( p = 0 ; 6 > p ; ++ p ) n += f . getUint16 ( p << 1 ) , 65535 < n && ( n = ( n & 65535 ) + 1 ) ; for ( p = 0 ; 10 > p ; ++ p ) n += e . getUint16 ( p << 1 ) , 65535 < n && ( n = ( n & 65535 ) + 1 ) ; if ( a . tcp _data ) for ( p = 0 ; p < a . tcp _data . length ; p += 2 ) n += a . tcp _data [ p ] << 8 | a . tcp _data [ p + 1 ] , 65535 < n && ( n = ( n & 65535 ) + 1 ) ;
e . setUint16 ( 16 , n ^ 65535 ) ; f = m + 20 } if ( a . tcp _data ) { for ( e = 0 ; e < a . tcp _data . length ; ++ e ) d . setUint8 ( f + e , a . tcp _data [ e ] ) ; f += a . tcp _data . length } d . setUint8 ( 0 , 69 ) ; d . setUint8 ( 1 , a . ipv4 . tos || 0 ) ; d . setUint16 ( 2 , f ) ; d . setUint16 ( 4 , a . ipv4 . id || 0 ) ; d . setUint8 ( 6 , 64 ) ; d . setUint8 ( 8 , a . ipv4 . ttl || 32 ) ; d . setUint8 ( 9 , a . ipv4 . proto ) ; d . setUint16 ( 10 , 0 ) ; for ( e = 0 ; 4 > e ; ++ e ) d . setUint8 ( 12 + e , a . ipv4 . src [ e ] ) , d . setUint8 ( 16 + e , a . ipv4 . dest [ e ] ) ; a = 0 ; for ( e = 0 ; 10 > e ; ++ e ) a += d . getUint16 ( e << 1 ) , 65535 < a && ( a = ( a & 65535 ) + 1 ) ; d . setUint16 ( 10 , a ^ 65535 ) ; c += f } return b . subarray ( 0 ,
c ) } function bc ( a , b ) { let c = 49152 + Math . floor ( 1E3 * Math . random ( ) ) , d = [ b . vm _ip . join ( "." ) , a , b . router _ip . join ( "." ) , c ] . join ( ":" ) , e , f , g = new cc ; g . net = b ; g . on _data = function ( l ) { e && e . call ( h , l ) } ; g . on _connect = function ( ) { f && f . call ( h ) } ; g . tuple = d ; g . hsrc = b . router _mac ; g . psrc = b . router _ip ; g . sport = c ; g . hdest = b . vm _mac ; g . dport = a ; g . pdest = b . vm _ip ; b . tcp _conn [ d ] = g ; g . connect ( ) ; let h = { write : function ( l ) { g . write ( l ) } , on : function ( l , m ) { "data" === l && ( e = m ) ; "connect" === l && ( f = m ) } , close : function ( ) { g . close ( ) } } ; return h }
function cc ( ) { this . send _buffer = new Uint8Array ( [ ] ) ; this . seq _history = [ ] } cc . prototype . ipv4 _reply = function ( ) { let a = { } ; a . eth = { ethertype : 2048 , src : this . hsrc , dest : this . hdest } ; a . ipv4 = { proto : 6 , src : this . psrc , dest : this . pdest } ; a . tcp = { sport : this . sport , dport : this . dport , winsize : this . winsize , ackn : this . ack , seq : this . seq , ack : ! 0 } ; return a } ;
cc . prototype . connect = function ( ) { this . seq = 1338 ; this . ack = 1 ; this . start _seq = 0 ; this . winsize = 64240 ; this . state = "syn-sent" ; let a = this . ipv4 _reply ( ) ; a . ipv4 . id = 2345 ; a . tcp = { sport : this . sport , dport : this . dport , seq : 1337 , ackn : 0 , winsize : 0 , syn : ! 0 } ; this . net . receive ( Yb ( a ) ) } ;
cc . prototype . accept = function ( a ) { this . seq = 1338 ; this . ack = a . tcp . seq + 1 ; this . start _seq = a . tcp . seq ; this . hsrc = this . net . router _mac ; this . psrc = a . ipv4 . dest ; this . sport = a . tcp . dport ; this . hdest = a . eth . src ; this . dport = a . tcp . sport ; this . pdest = a . ipv4 . src ; this . winsize = a . tcp . winsize ; let b = this . ipv4 _reply ( ) ; b . tcp = { sport : this . sport , dport : this . dport , seq : 1337 , ackn : this . ack , winsize : a . tcp . winsize , syn : ! 0 , ack : ! 0 } ; this . net . receive ( Yb ( b ) ) } ;
cc . prototype . process = function ( a ) { if ( a . tcp . syn ) this . ack = a . tcp . seq + 1 , this . start _seq = a . tcp . seq , this . last _received _ackn = a . tcp . ackn , a = this . ipv4 _reply ( ) , this . net . receive ( Yb ( a ) ) , this . state = "established" , this . on _connect && this . on _connect . call ( this ) ; else if ( a . tcp . fin ) { this . ack !== a . tcp . seq && ++ this . ack ; var b = this . ipv4 _reply ( ) ; b . tcp = { sport : a . tcp . dport , dport : a . tcp . sport , seq : this . seq , ackn : this . ack , winsize : a . tcp . winsize , rst : ! 0 } ; delete this . net . tcp _conn [ this . tuple ] ; this . net . receive ( Yb ( b ) ) } else this . ack !== a . tcp . seq ?
( b = this . ipv4 _reply ( ) , b . tcp = { sport : a . tcp . dport , dport : a . tcp . sport , seq : this . seq , ackn : this . ack , winsize : a . tcp . winsize , ack : ! 0 } , this . net . receive ( Yb ( b ) ) ) : ( this . seq _history . push ( ` ${ a . tcp . seq - this . start _seq } : ${ a . tcp . seq + a . tcp _data . length - this . start _seq } ` ) , this . ack += a . tcp _data . length , 0 < a . tcp _data . length && ( b = this . ipv4 _reply ( ) , this . net . receive ( Yb ( b ) ) ) , void 0 === this . last _received _ackn && ( this . last _received _ackn = a . tcp . ackn ) , b = a . tcp . ackn - this . last _received _ackn , 0 < b && ( this . last _received _ackn = a . tcp . ackn , this . send _buffer =
this . send _buffer . subarray ( b ) , this . seq += b , this . pending = ! 1 ) , 0 > b || ( this . on _data ( a . tcp _data ) , this . pump ( ) ) ) } ; cc . prototype . write = function ( a ) { if ( 0 < this . send _buffer . length ) { let b = new Uint8Array ( this . send _buffer . byteLength + a . byteLength ) ; b . set ( this . send _buffer , 0 ) ; b . set ( a , this . send _buffer . byteLength ) ; this . send _buffer = b } else this . send _buffer = a ; this . pump ( ) } ; cc . prototype . close = function ( ) { this . state = "fin-wait-1" ; let a = this . ipv4 _reply ( ) ; a . tcp . fin = ! 0 ; this . net . receive ( Yb ( a ) ) ; this . pump ( ) } ;
cc . prototype . pump = function ( ) { if ( 0 < this . send _buffer . length && ! this . pending ) { let a = this . send _buffer . subarray ( 0 , 500 ) , b = this . ipv4 _reply ( ) ; this . pending = ! 0 ; 1 > this . send _buffer . length && ( b . tcp . fin = ! 0 ) ; b . tcp . psh = ! 0 ; b . tcp _data = a ; this . net . receive ( Yb ( b ) ) } } ;
function dc ( a , b ) { var c = Wb ( a . arp . tpa ) & 4294967040 ; let d = Wb ( b . router _ip ) & 4294967040 ; ! b . masquerade && c !== d || c === d && 99 < a . arp . tpa [ 3 ] || ( c = { } , c . eth = { ethertype : 2054 , src : b . router _mac , dest : a . eth . src } , c . arp = { htype : 1 , ptype : 2048 , oper : 2 , sha : b . router _mac , spa : a . arp . tpa , tha : a . eth . src , tpa : a . arp . spa } , b . receive ( Yb ( c ) ) ) }
function ec ( a , b ) { let c = { } ; c . eth = { ethertype : 2048 , src : b . router _mac , dest : a . eth . src } ; c . ipv4 = { proto : 17 , src : a . ipv4 . dest , dest : a . ipv4 . src } ; c . udp = { sport : a . udp . dport , dport : a . udp . sport , data : ( new TextEncoder ) . encode ( a . udp . data _s ) } ; b . receive ( Yb ( c ) ) } ; function Jb ( a , b , c ) { this . register _ws ( a ) ; this . last _stream = 1 ; this . connections = { 0 : { congestion : 0 } } ; this . congested _buffer = [ ] ; c = c || { } ; this . bus = b ; this . id = c . id || 0 ; this . router _mac = new Uint8Array ( ( c . router _mac || "52:54:0:1:2:3" ) . split ( ":" ) . map ( function ( d ) { return parseInt ( d , 16 ) } ) ) ; this . router _ip = new Uint8Array ( ( c . router _ip || "192.168.86.1" ) . split ( "." ) . map ( function ( d ) { return parseInt ( d , 10 ) } ) ) ; this . vm _ip = new Uint8Array ( ( c . vm _ip || "192.168.86.100" ) . split ( "." ) . map ( function ( d ) { return parseInt ( d , 10 ) } ) ) ; this . masquerade =
void 0 === c . masquerade || ! ! c . masquerade ; this . vm _mac = new Uint8Array ( 6 ) ; this . doh _server = c . doh _server || "cloudflare-dns.com" ; this . tcp _conn = { } ; this . bus . register ( "net" + this . id + "-mac" , function ( d ) { this . vm _mac = new Uint8Array ( d . split ( ":" ) . map ( function ( e ) { return parseInt ( e , 16 ) } ) ) } , this ) ; this . bus . register ( "net" + this . id + "-send" , function ( d ) { this . send ( d ) } , this ) }
Jb . prototype . register _ws = function ( a ) { this . wispws = new WebSocket ( a . replace ( "wisp://" , "ws://" ) . replace ( "wisps://" , "wss://" ) ) ; this . wispws . binaryType = "arraybuffer" ; this . wispws . onmessage = b => { this . process _incoming _wisp _frame ( new Uint8Array ( b . data ) ) } ; this . wispws . onclose = ( ) => { setTimeout ( ( ) => { this . register _ws ( a ) } , 1E4 ) } } ;
Jb . prototype . send _packet = function ( a , b , c ) { 0 < this . connections [ c ] . congestion ? ( "DATA" === b && this . connections [ c ] . congestion -- , this . wispws . send ( a ) ) : ( this . connections [ c ] . congested = ! 0 , this . congested _buffer . push ( { data : a , type : b } ) ) } ;
Jb . prototype . process _incoming _wisp _frame = function ( a ) { const b = new DataView ( a . buffer ) , c = b . getUint32 ( 1 , ! 0 ) ; switch ( a [ 0 ] ) { case 2 : if ( this . connections [ c ] ) this . connections [ c ] . data _callback ( a . slice ( 5 ) ) ; else throw Error ( "Got a DATA packet but stream not registered. ID: " + c ) ; break ; case 3 : this . connections [ c ] && ( this . connections [ c ] . congestion = b . getUint32 ( 5 , ! 0 ) ) ; if ( this . connections [ c ] . congested ) { for ( const d of this . congested _buffer ) this . send _packet ( d . data , d . type , c ) ; this . connections [ c ] . congested = ! 1 } break ; case 4 : this . connections [ c ] &&
this . connections [ c ] . close _callback ( b . getUint8 ( 5 ) ) , delete this . connections [ c ] } } ;
Jb . prototype . send _wisp _frame = function ( a ) { let b , c ; switch ( a . type ) { case "CONNECT" : const d = ( new TextEncoder ) . encode ( a . hostname ) ; b = new Uint8Array ( 8 + d . length ) ; c = new DataView ( b . buffer ) ; c . setUint8 ( 0 , 1 ) ; c . setUint32 ( 1 , a . stream _id , ! 0 ) ; c . setUint8 ( 5 , 1 ) ; c . setUint16 ( 6 , a . port , ! 0 ) ; b . set ( d , 8 ) ; this . connections [ a . stream _id ] = { data _callback : a . data _callback , close _callback : a . close _callback , congestion : this . connections [ 0 ] . congestion } ; break ; case "DATA" : b = new Uint8Array ( 5 + a . data . length ) ; c = new DataView ( b . buffer ) ; c . setUint8 ( 0 ,
2 ) ; c . setUint32 ( 1 , a . stream _id , ! 0 ) ; b . set ( a . data , 5 ) ; break ; case "CLOSE" : b = new Uint8Array ( 6 ) , c = new DataView ( b . buffer ) , c . setUint8 ( 0 , 4 ) , c . setUint32 ( 1 , a . stream _id , ! 0 ) , c . setUint8 ( 5 , a . reason ) } this . send _packet ( b , a . type , a . stream _id ) } ; Jb . prototype . destroy = function ( ) { this . wispws && ( this . wispws . onmessage = null , this . wispws . onclose = null , this . wispws . close ( ) , this . wispws = null ) } ;
Jb . prototype . send = function ( a ) { let b = { } ; $b ( a , b ) ; if ( b . tcp ) { a = { } ; a . eth = { ethertype : 2048 , src : this . router _mac , dest : b . eth . src } ; a . ipv4 = { proto : 6 , src : b . ipv4 . dest , dest : b . ipv4 . src } ; var c = [ b . ipv4 . src . join ( "." ) , b . tcp . sport , b . ipv4 . dest . join ( "." ) , b . tcp . dport ] . join ( ":" ) ; if ( b . tcp . syn ) { const d = new cc ; d . state = "syn-received" ; d . net = this ; d . tuple = c ; d . stream _id = this . last _stream ++ ; this . tcp _conn [ c ] = d ; d . on _data = e => { 0 !== e . length && this . send _wisp _frame ( { type : "DATA" , stream _id : d . stream _id , data : e } ) } ; this . send _wisp _frame ( { type : "CONNECT" ,
stream _id : d . stream _id , hostname : b . ipv4 . dest . join ( "." ) , port : b . tcp . dport , data _callback : e => { d . write ( e ) } , close _callback : ( ) => { d . close ( ) } } ) ; d . accept ( b ) ; return } if ( ! this . tcp _conn [ c ] ) { c = b . tcp . ackn ; if ( b . tcp . fin || b . tcp . syn ) c += 1 ; a . tcp = { sport : b . tcp . dport , dport : b . tcp . sport , seq : c , ackn : b . tcp . seq + ( b . tcp . syn ? 1 : 0 ) , winsize : b . tcp . winsize , rst : ! 0 , ack : b . tcp . syn } ; this . receive ( Yb ( a ) ) ; return } this . tcp _conn [ c ] . process ( b ) } b . arp && 1 === b . arp . oper && 2048 === b . arp . ptype && dc ( b , this ) ; b . dns && ( async ( ) => { let d = { } ; d . eth = { ethertype : 2048 , src : this . router _mac ,
dest : b . eth . src } ; d . ipv4 = { proto : 17 , src : this . router _ip , dest : b . ipv4 . src } ; d . udp = { sport : 53 , dport : b . udp . sport } ; const e = await ( await fetch ( ` https:// ${ this . doh _server } /dns-query ` , { method : "POST" , headers : [ [ "content-type" , "application/dns-message" ] ] , body : b . udp . data } ) ) . arrayBuffer ( ) ; d . udp . data = new Uint8Array ( e ) ; this . receive ( Yb ( d ) ) } ) ( ) ; b . ntp ? Xb ( b , this ) : b . dhcp ? Zb ( b , this ) : b . udp && 8 === b . udp . dport && ec ( b , this ) } ; Jb . prototype . receive = function ( a ) { this . bus . send ( "net" + this . id + "-receive" , new Uint8Array ( a ) ) } ; function Ib ( a , b ) { b = b || { } ; this . bus = a ; this . id = b . id || 0 ; this . router _mac = new Uint8Array ( ( b . router _mac || "52:54:0:1:2:3" ) . split ( ":" ) . map ( function ( c ) { return parseInt ( c , 16 ) } ) ) ; this . router _ip = new Uint8Array ( ( b . router _ip || "192.168.86.1" ) . split ( "." ) . map ( function ( c ) { return parseInt ( c , 10 ) } ) ) ; this . vm _ip = new Uint8Array ( ( b . vm _ip || "192.168.86.100" ) . split ( "." ) . map ( function ( c ) { return parseInt ( c , 10 ) } ) ) ; this . masquerade = void 0 === b . masquerade || ! ! b . masquerade ; this . vm _mac = new Uint8Array ( 6 ) ; this . tcp _conn = { } ; this . cors _proxy =
b . cors _proxy ; this . bus . register ( "net" + this . id + "-mac" , function ( c ) { this . vm _mac = new Uint8Array ( c . split ( ":" ) . map ( function ( d ) { return parseInt ( d , 16 ) } ) ) } , this ) ; this . bus . register ( "net" + this . id + "-send" , function ( c ) { this . send ( c ) } , this ) } Ib . prototype . destroy = function ( ) { } ; Ib . prototype . on _tcp _connection = function ( a , b , c ) { if ( 80 === b . tcp . dport ) { let d = new cc ; d . state = "syn-received" ; d . net = this ; d . on _data = fc ; d . tuple = c ; d . accept ( b ) ; a . tcp _conn [ c ] = d ; return ! 0 } return ! 1 } ;
async function fc ( a ) { if ( a && ( this . read = this . read || "" , ( this . read += ( new TextDecoder ) . decode ( a ) ) && - 1 !== this . read . indexOf ( "\r\n\r\n" ) ) ) { var b = this . read . indexOf ( "\r\n\r\n" ) ; a = this . read . substring ( 0 , b ) . split ( /\r\n/ ) ; b = this . read . substring ( b + 4 ) ; this . read = "" ; let c = a [ 0 ] . split ( " " ) , d ; d = /^https?:/ . test ( c [ 1 ] ) ? new URL ( c [ 1 ] ) : new URL ( "http://host" + c [ 1 ] ) ; "undefined" !== typeof window && "http:" === d . protocol && "https:" === window . location . protocol && ( d . protocol = "https:" ) ; let e = new Headers ; for ( let l = 1 ; l < a . length ; ++ l ) { let m = a [ l ] . split ( ": " ) ,
n = m [ 0 ] . toLowerCase ( ) , p = m [ 1 ] ; "host" === n ? d . host = p : 1 < n . length && e . set ( m [ 0 ] , p ) } this . name = d . href ; a = { method : c [ 0 ] , headers : e } ; - 1 !== [ "put" , "post" ] . indexOf ( a . method . toLowerCase ( ) ) && ( a . body = b ) ; const [ f , g ] = await this . net . fetch ( d . href , a ) , h = [ ` HTTP/1.1 ${ f . status } ${ f . statusText } ` , "connection: Closed" , "content-length: " + g . byteLength ] ; h . push ( "x-was-fetch-redirected: " + String ( f . redirected ) ) ; h . push ( "x-fetch-resp-url: " + String ( f . url ) ) ; f . headers . forEach ( function ( l , m ) { - 1 === [ "content-encoding" , "connection" , "content-length" ,
"transfer-encoding" ] . indexOf ( m . toLowerCase ( ) ) && h . push ( m + ": " + l ) } ) ; h . push ( "" ) ; h . push ( "" ) ; this . write ( ( new TextEncoder ) . encode ( h . join ( "\r\n" ) ) ) ; this . write ( new Uint8Array ( g ) ) } } Ib . prototype . fetch = async function ( a , b ) { this . cors _proxy && ( a = this . cors _proxy + encodeURIComponent ( a ) ) ; try { const c = await fetch ( a , b ) , d = await c . arrayBuffer ( ) ; return [ c , d ] } catch ( c ) { return console . warn ( "Fetch Failed: " + a + "\n" + c ) , b = new Headers , b . set ( "Content-Type" , "text/plain" ) , [ { status : 502 , statusText : "Fetch Error" , headers : b } , ( new TextEncoder ) . encode ( ` Fetch ${ a } failed: \n \n ${ c . stack } ` ) . buffer ] } } ;
Ib . prototype . send = function ( a ) { a : { let c = { } ; $b ( a , c ) ; if ( c . tcp ) { a = { } ; a . eth = { ethertype : 2048 , src : this . router _mac , dest : c . eth . src } ; a . ipv4 = { proto : 6 , src : c . ipv4 . dest , dest : c . ipv4 . src } ; var b = [ c . ipv4 . src . join ( "." ) , c . tcp . sport , c . ipv4 . dest . join ( "." ) , c . tcp . dport ] . join ( ":" ) ; if ( c . tcp . syn && this . on _tcp _connection ( this , c , b ) ) a = void 0 ; else if ( this . tcp _conn [ b ] ) this . tcp _conn [ b ] . process ( c ) , a = void 0 ; else { b = c . tcp . ackn ; if ( c . tcp . fin || c . tcp . syn ) b += 1 ; a . tcp = { sport : c . tcp . dport , dport : c . tcp . sport , seq : b , ackn : c . tcp . seq + ( c . tcp . syn ? 1 : 0 ) ,
winsize : c . tcp . winsize , rst : ! 0 , ack : c . tcp . syn } ; this . receive ( Yb ( a ) ) ; a = ! 0 } if ( a ) break a } c . arp && 1 === c . arp . oper && 2048 === c . arp . ptype && dc ( c , this ) ; if ( c . dns ) { a = { } ; a . eth = { ethertype : 2048 , src : this . router _mac , dest : c . eth . src } ; a . ipv4 = { proto : 17 , src : this . router _ip , dest : c . ipv4 . src } ; a . udp = { sport : 53 , dport : c . udp . sport } ; b = [ ] ; for ( let d = 0 ; d < c . dns . questions . length ; ++ d ) { let e = c . dns . questions [ d ] ; switch ( e . type ) { case 1 : b . push ( { name : e . name , type : e . type , class : e . class , ttl : 600 , data : [ 192 , 168 , 87 , 1 ] } ) } } a . dns = { id : c . dns . id , flags : 33152 , questions : c . dns . questions ,
answers : b } ; this . receive ( Yb ( a ) ) } else c . ntp && Xb ( c , this ) || ( c . icmp && 8 === c . icmp . type && ( a = { } , a . eth = { ethertype : 2048 , src : this . router _mac , dest : c . eth . src } , a . ipv4 = { proto : 1 , src : this . router _ip , dest : c . ipv4 . src } , a . icmp = { type : 0 , code : c . icmp . code , data : c . icmp . data } , this . receive ( Yb ( a ) ) ) , c . dhcp && Zb ( c , this ) || c . udp && 8 === c . udp . dport && ec ( c , this ) ) } } ; Ib . prototype . tcp _connect = function ( a ) { return bc ( a , this ) } ; Ib . prototype . receive = function ( a ) { this . bus . send ( "net" + this . id + "-receive" , new Uint8Array ( a ) ) } ;
"undefined" !== typeof module && "undefined" !== typeof module . exports && ( module . exports . FetchNetworkAdapter = Ib ) ; const gc = { stats _to _string : function ( a ) { return gc . print _misc _stats ( a ) + gc . print _instruction _counts ( a ) } , print _misc _stats : function ( a ) { let b = "" ; var c = "COMPILE COMPILE_SKIPPED_NO_NEW_ENTRY_POINTS COMPILE_WRONG_ADDRESS_SPACE COMPILE_CUT_OFF_AT_END_OF_PAGE COMPILE_WITH_LOOP_SAFETY COMPILE_PAGE COMPILE_PAGE/COMPILE COMPILE_BASIC_BLOCK COMPILE_DUPLICATED_BASIC_BLOCK COMPILE_WASM_BLOCK COMPILE_WASM_LOOP COMPILE_DISPATCHER COMPILE_ENTRY_POINT COMPILE_WASM_TOTAL_BYTES COMPILE_WASM_TOTAL_BYTES/COMPILE_PAGE RUN_INTERPRETED RUN_INTERPRETED_NEW_PAGE RUN_INTERPRETED_PAGE_HAS_CODE RUN_INTERPRETED_PAGE_HAS_ENTRY_AFTER_PAGE_WALK RUN_INTERPRETED_NEAR_END_OF_PAGE RUN_INTERPRETED_DIFFERENT_STATE RUN_INTERPRETED_DIFFERENT_STATE_CPL3 RUN_INTERPRETED_DIFFERENT_STATE_FLAT RUN_INTERPRETED_DIFFERENT_STATE_IS32 RUN_INTERPRETED_DIFFERENT_STATE_SS32 RUN_INTERPRETED_MISSED_COMPILED_ENTRY_RUN_INTERPRETED RUN_INTERPRETED_STEPS RUN_FROM_CACHE RUN_FROM_CACHE_STEPS RUN_FROM_CACHE_STEPS/RUN_FROM_CACHE RUN_FROM_CACHE_STEPS/RUN_INTERPRETED_STEPS DIRECT_EXIT INDIRECT_JUMP INDIRECT_JUMP_NO_ENTRY NORMAL_PAGE_CHANGE NORMAL_FALLTHRU NORMAL_FALLTHRU_WITH_TARGET_BLOCK NORMAL_BRANCH NORMAL_BRANCH_WITH_TARGET_BLOCK CONDITIONAL_JUMP CONDITIONAL_JUMP_PAGE_CHANGE CONDITIONAL_JUMP_EXIT CONDITIONAL_JUMP_FALLTHRU CONDITIONAL_JUMP_FALLTHRU_WITH_TARGET_BLOCK CONDITIONAL_JUMP_BRANCH CONDITIONAL_JUMP_BRANCH_WITH_TARGET_BLOCK DISPATCHER_SMALL DISPATCHER_LARGE LOOP LOOP_SAFETY CONDITION_OPTIMISED CONDITION_UNOPTIMISED CONDITION_UNOPTIMISED_PF CONDITION_UNOPTIMISED_UNHANDLED_L CONDITION_UNOPTIMISED_UNHANDLED_LE FAILED_PAGE_CHANGE SAFE_READ_FAST SAFE_READ_SLOW_PAGE_CROSSED SAFE_READ_SLOW_NOT_VALID SAFE_READ_SLOW_NOT_USER SAFE_READ_SLOW_IN_MAPPED_RANGE SAFE_WRITE_FAST SAFE_WRITE_SLOW_PAGE_CROSSED SAFE_WRITE_SLOW_NOT_VALID SAFE_WRITE_SLOW_NOT_USER SAFE_WRITE_SLOW_IN_MAPPED_RANGE SAFE_WRITE_SLOW_READ_ONLY SAFE_WRITE_SLOW_HAS_CODE SAFE_READ_WRITE_FAST SAFE_READ_WRITE_SLOW_PAGE_CROSSED SAFE_READ_WRITE_SLOW_NOT_VALID SAFE_READ_WRITE_SLOW_NOT_USER SAFE_READ_WRITE_SLOW_IN_MAPPED_RANGE SAFE_READ_WRITE_SLOW_READ_ONLY SAFE_READ_WRITE_SLOW_HAS_CODE PAGE_FAULT TLB_MISS MAIN_LOOP MAIN_LOOP_IDLE DO_MANY_CYCLES CYCLE_INTERNAL INVALIDATE_ALL_MODULES_NO_FREE_WASM_INDICES INVALIDATE_MODULE_WRITTEN_WHILE_COMPILED INVALIDATE_MODULE_UNUSED_AFTER_OVERWRITE INVALIDATE_MODULE_DIRTY_PAGE INVALIDATE_PAGE_HAD_CODE INVALIDATE_PAGE_HAD_ENTRY_POINTS DIRTY_PAGE_DID_NOT_HAVE_CODE RUN_FROM_CACHE_EXIT_SAME_PAGE RUN_FROM_CACHE_EXIT_NEAR_END_OF_PAGE RUN_FROM_CACHE_EXIT_DIFFERENT_PAGE CLEAR_TLB FULL_CLEAR_TLB TLB_FULL TLB_GLOBAL_FULL MODRM_SIMPLE_REG MODRM_SIMPLE_REG_WITH_OFFSET MODRM_SIMPLE_CONST_OFFSET MODRM_COMPLEX SEG_OFFSET_OPTIMISED SEG_OFFSET_NOT_OPTIMISED SEG_OFFSET_NOT_OPTIMISED_ES SEG_OFFSET_NOT_OPTIMISED_FS SEG_OFFSET_NOT_OPTIMISED_GS SEG_OFFSET_NOT_OPTIMISED_NOT_FLAT" . split ( " " ) ,
d = 0 ; const e = { } ; for ( let g = 0 ; g < c . length ; g ++ ) { const h = c [ g ] ; var f = void 0 ; if ( h . includes ( "/" ) ) { d ++ ; const [ l , m ] = h . split ( "/" ) ; f = e [ l ] / e [ m ] } else f = e [ h ] = a . wm . exports . profiler _stat _get ( g - d ) , f = 1E8 <= f ? Math . round ( f / 1E6 ) + "m" : 1E5 <= f ? Math . round ( f / 1E3 ) + "k" : f ; b += h + "=" + f + "\n" } b += "\n" ; c = a . wm . exports . get _valid _tlb _entries _count ( ) ; d = a . wm . exports . get _valid _global _tlb _entries _count ( ) ; b = b + ( "TLB_ENTRIES=" + c + " (" + d + " global, " + ( c - d ) + " non-global)\nWASM_TABLE_FREE=" ) + ( a . wm . exports . jit _get _wasm _table _index _free _list _count ( ) + "\n" ) ;
b += "JIT_CACHE_SIZE=" + a . wm . exports . jit _get _cache _size ( ) + "\n" ; b += "FLAT_SEGMENTS=" + a . wm . exports . has _flat _segmentation ( ) + "\n" ; b += "wasm memory size: " + ( a . wasm _memory . buffer . byteLength >> 20 ) + "m\n" ; b = b + "Config:\nJIT_DISABLED=" + ( a . wm . exports . get _jit _config ( 0 ) + "\n" ) ; b += "MAX_PAGES=" + a . wm . exports . get _jit _config ( 1 ) + "\n" ; b += "JIT_USE_LOOP_SAFETY=" + ! ! a . wm . exports . get _jit _config ( 2 ) + "\n" ; return b += "MAX_EXTRA_BASIC_BLOCKS=" + a . wm . exports . get _jit _config ( 3 ) + "\n" } , print _instruction _counts : function ( a ) { return [ gc . print _instruction _counts _offset ( a ,
! 1 , ! 1 , ! 1 , ! 1 ) , gc . print _instruction _counts _offset ( a , ! 0 , ! 1 , ! 1 , ! 1 ) , gc . print _instruction _counts _offset ( a , ! 1 , ! 0 , ! 1 , ! 1 ) , gc . print _instruction _counts _offset ( a , ! 1 , ! 1 , ! 0 , ! 1 ) , gc . print _instruction _counts _offset ( a , ! 1 , ! 1 , ! 1 , ! 0 ) ] . join ( "\n\n" ) } , print _instruction _counts _offset : function ( a , b , c , d , e ) { let f = "" ; var g = [ ] , h = b ? "compiled" : c ? "jit exit" : d ? "unguarded register" : e ? "wasm size" : "executed" ; for ( let n = 0 ; 256 > n ; n ++ ) for ( let p = 0 ; 8 > p ; p ++ ) for ( const q of [ ! 1 , ! 0 ] ) { var l = a . wm . exports . get _opstats _buffer ( b , c , d , e , n , ! 1 , q , p ) ; g . push ( { opcode : n ,
count : l , is _mem : q , fixed _g : p } ) ; l = a . wm . exports . get _opstats _buffer ( b , c , d , e , n , ! 0 , q , p ) ; g . push ( { opcode : 3840 | n , count : l , is _mem : q , fixed _g : p } ) } a = 0 ; b = new Set ( [ 38 , 46 , 54 , 62 , 100 , 101 , 102 , 103 , 240 , 242 , 243 ] ) ; for ( const { count : n , opcode : p } of g ) b . has ( p ) || ( a += n ) ; if ( 0 === a ) return "" ; c = new Uint32Array ( 256 ) ; b = new Uint32Array ( 256 ) ; for ( const { opcode : n , count : p } of g ) 3840 === ( n & 65280 ) ? b [ n & 255 ] += p : c [ n & 255 ] += p ; f = f + "------------------\nTotal: " + ( a + "\n" ) ; const m = 1E7 < a ? 1E3 : 1 ; d = Math . max . apply ( Math , g . map ( ( { count : n } ) => Math . round ( n / m ) ) ) ; d =
String ( d ) . length ; f += ` Instruction counts ${ h } (in ${ m } ): \n ` ; for ( e = 0 ; 256 > e ; e ++ ) f += e . toString ( 16 ) . padStart ( 2 , "0" ) + ":" + t . pads ( Math . round ( c [ e ] / m ) , d ) , f = 15 === e % 16 ? f + "\n" : f + " " ; f = f + "\n" + ` Instruction counts ${ h } (0f, in ${ m } ): \n ` ; for ( h = 0 ; 256 > h ; h ++ ) f += ( h & 255 ) . toString ( 16 ) . padStart ( 2 , "0" ) + ":" + t . pads ( Math . round ( b [ h ] / m ) , d ) , f = 15 === h % 16 ? f + "\n" : f + " " ; f += "\n" ; g = g . filter ( ( { count : n } ) => n ) . sort ( ( { count : n } , { count : p } ) => p - n ) ; for ( const { opcode : n , is _mem : p , fixed _g : q , count : r } of g . slice ( 0 , 200 ) ) g = n . toString ( 16 ) + "_" + q + ( p ? "_m" :
"_r" ) , f += g + ":" + ( r / a * 100 ) . toFixed ( 2 ) + " " ; return f + "\n" } } ; "undefined" !== typeof module && "undefined" !== typeof module . exports && ( module . exports . print _stats = gc ) ; function Lb ( ) { this . filedata = new Map } Lb . prototype . read = async function ( a , b , c ) { return ( a = this . filedata . get ( a ) ) ? a . subarray ( b , b + c ) : null } ; Lb . prototype . cache = async function ( a , b ) { this . filedata . set ( a , b ) } ; Lb . prototype . uncache = function ( a ) { this . filedata . delete ( a ) } ; function Mb ( a , b ) { b . endsWith ( "/" ) || ( b += "/" ) ; this . storage = a ; this . baseurl = b } Mb . prototype . load _from _server = function ( a ) { return new Promise ( b => { t . load _file ( this . baseurl + a , { done : async c => { c = new Uint8Array ( c ) ; await this . cache ( a , c ) ; b ( c ) } } ) } ) } ;
Mb . prototype . read = async function ( a , b , c ) { const d = await this . storage . read ( a , b , c ) ; return d ? d : ( await this . load _from _server ( a ) ) . subarray ( b , b + c ) } ; Mb . prototype . cache = async function ( a , b ) { return await this . storage . cache ( a , b ) } ; Mb . prototype . uncache = function ( a ) { this . storage . uncache ( a ) } ; var ea = 32768 , da = 16384 , fa = 4 ; function Z ( a , b ) { this . inodes = [ ] ; this . events = [ ] ; this . storage = a ; this . qidcounter = b || { last _qidnumber : 0 } ; this . inodedata = { } ; this . total _size = 274877906944 ; this . used _size = 0 ; this . mounts = [ ] ; this . CreateDirectory ( "" , - 1 ) } Z . prototype . get _state = function ( ) { let a = [ ] ; a [ 0 ] = this . inodes ; a [ 1 ] = this . qidcounter . last _qidnumber ; a [ 2 ] = [ ] ; for ( const [ b , c ] of Object . entries ( this . inodedata ) ) 0 === ( this . inodes [ b ] . mode & da ) && a [ 2 ] . push ( [ b , c ] ) ; a [ 3 ] = this . total _size ; a [ 4 ] = this . used _size ; return a = a . concat ( this . mounts ) } ;
Z . prototype . set _state = function ( a ) { this . inodes = a [ 0 ] . map ( b => { const c = new hc ( 0 ) ; c . set _state ( b ) ; return c } ) ; this . qidcounter . last _qidnumber = a [ 1 ] ; this . inodedata = { } ; for ( let [ b , c ] of a [ 2 ] ) c . buffer . byteLength !== c . byteLength && ( c = c . slice ( ) ) , this . inodedata [ b ] = c ; this . total _size = a [ 3 ] ; this . used _size = a [ 4 ] ; this . mounts = a . slice ( 5 ) } ; Z . prototype . AddEvent = function ( a , b ) { var c = this . inodes [ a ] ; 0 === c . status || 2 === c . status ? b ( ) : this . is _forwarder ( c ) ? this . follow _fs ( c ) . AddEvent ( c . foreign _id , b ) : this . events . push ( { id : a , OnEvent : b } ) } ;
Z . prototype . HandleEvent = function ( a ) { var b = this . inodes [ a ] ; this . is _forwarder ( b ) && this . follow _fs ( b ) . HandleEvent ( b . foreign _id ) ; b = [ ] ; for ( var c = 0 ; c < this . events . length ; c ++ ) this . events [ c ] . id === a ? this . events [ c ] . OnEvent ( ) : b . push ( this . events [ c ] ) ; this . events = b } ;
Z . prototype . load _from _json = function ( a ) { if ( 3 !== a . version ) throw "The filesystem JSON format has changed. Please update your fs2json (https://github.com/copy/fs2json) and recreate the filesystem JSON." ; var b = a . fsroot ; this . used _size = a . size ; for ( a = 0 ; a < b . length ; a ++ ) this . LoadRecursive ( b [ a ] , 0 ) } ;
Z . prototype . LoadRecursive = function ( a , b ) { var c = this . CreateInode ( ) ; const d = a [ 0 ] ; c . size = a [ 1 ] ; c . mtime = a [ 2 ] ; c . ctime = c . mtime ; c . atime = c . mtime ; c . mode = a [ 3 ] ; c . uid = a [ 4 ] ; c . gid = a [ 5 ] ; var e = c . mode & 61440 ; e === da ? ( this . PushInode ( c , b , d ) , this . LoadDir ( this . inodes . length - 1 , a [ 6 ] ) ) : e === ea ? ( c . status = 2 , c . sha256sum = a [ 6 ] , this . PushInode ( c , b , d ) ) : 40960 === e ? ( c . symlink = a [ 6 ] , this . PushInode ( c , b , d ) ) : 49152 !== e && A ( e ) } ; Z . prototype . LoadDir = function ( a , b ) { for ( var c = 0 ; c < b . length ; c ++ ) this . LoadRecursive ( b [ c ] , a ) } ;
2024-06-28 09:23:02 +02:00
Z . prototype . should _be _linked = function ( a ) { return ! this . is _forwarder ( a ) || 0 === a . foreign _id } ; Z . prototype . link _under _dir = function ( a , b , c ) { const d = this . inodes [ b ] , e = this . inodes [ a ] ; this . is _forwarder ( e ) ; this . IsDirectory ( a ) ; this . should _be _linked ( d ) ; e . direntries . has ( c ) ; e . direntries . set ( c , b ) ; d . nlinks ++ ; this . IsDirectory ( b ) && ( d . direntries . has ( ".." ) , d . direntries . has ( "." ) || d . nlinks ++ , d . direntries . set ( "." , b ) , d . direntries . set ( ".." , a ) , e . nlinks ++ ) } ;
Z . prototype . unlink _from _dir = function ( a , b ) { const c = this . Search ( a , b ) , d = this . inodes [ c ] , e = this . inodes [ a ] ; this . is _forwarder ( e ) ; this . IsDirectory ( a ) ; e . direntries . delete ( b ) && ( d . nlinks -- , this . IsDirectory ( c ) && ( d . direntries . get ( ".." ) , d . direntries . delete ( ".." ) , e . nlinks -- ) ) } ;
2024-10-02 21:03:04 +02:00
Z . prototype . PushInode = function ( a , b , c ) { - 1 !== b ? ( this . inodes . push ( a ) , a . fid = this . inodes . length - 1 , this . link _under _dir ( b , a . fid , c ) ) : 0 === this . inodes . length ? ( this . inodes . push ( a ) , a . direntries . set ( "." , 0 ) , a . direntries . set ( ".." , 0 ) , a . nlinks = 2 ) : ( z . Debug ( "Error in Filesystem: Pushed inode with name = " + c + " has no parent" ) , z . Abort ( ) ) } ;
function hc ( a ) { this . direntries = new Map ; this . minor = this . major = this . mtime = this . atime = this . ctime = this . fid = this . gid = this . uid = this . size = this . status = 0 ; this . symlink = "" ; this . mode = 493 ; this . qid = { type : 0 , version : 0 , path : a } ; this . caps = void 0 ; this . nlinks = 0 ; this . sha256sum = "" ; this . locks = [ ] ; this . foreign _id = this . mount _id = - 1 }
hc . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . mode ; a [ 1 ] = ( this . mode & 61440 ) === da ? [ ... this . direntries ] : ( this . mode & 61440 ) === ea ? this . sha256sum : 40960 === ( this . mode & 61440 ) ? this . symlink : 49152 === ( this . mode & 61440 ) ? [ this . minor , this . major ] : null ; a [ 2 ] = this . locks ; a [ 3 ] = this . status ; a [ 4 ] = this . size ; a [ 5 ] = this . uid ; a [ 6 ] = this . gid ; a [ 7 ] = this . fid ; a [ 8 ] = this . ctime ; a [ 9 ] = this . atime ; a [ 10 ] = this . mtime ; a [ 11 ] = this . qid . version ; a [ 12 ] = this . qid . path ; a [ 13 ] = this . nlinks ; return a } ;
hc . prototype . set _state = function ( a ) { this . mode = a [ 0 ] ; if ( ( this . mode & 61440 ) === da ) { this . direntries = new Map ; for ( const [ b , c ] of a [ 1 ] ) this . direntries . set ( b , c ) } else ( this . mode & 61440 ) === ea ? this . sha256sum = a [ 1 ] : 40960 === ( this . mode & 61440 ) ? this . symlink = a [ 1 ] : 49152 === ( this . mode & 61440 ) && ( [ this . minor , this . major ] = a [ 1 ] ) ; this . locks = [ ] ; for ( const b of a [ 2 ] ) { const c = new ic ; c . set _state ( b ) ; this . locks . push ( c ) } this . status = a [ 3 ] ; this . size = a [ 4 ] ; this . uid = a [ 5 ] ; this . gid = a [ 6 ] ; this . fid = a [ 7 ] ; this . ctime = a [ 8 ] ; this . atime = a [ 9 ] ; this . mtime = a [ 10 ] ;
2024-06-28 09:23:02 +02:00
this . qid . type = ( this . mode & 61440 ) >> 8 ; this . qid . version = a [ 11 ] ; this . qid . path = a [ 12 ] ; this . nlinks = a [ 13 ] } ;
2024-10-02 21:03:04 +02:00
Z . prototype . divert = function ( a , b ) { const c = this . Search ( a , b ) , d = this . inodes [ c ] , e = new hc ( - 1 ) ; this . IsDirectory ( c ) ; Object . assign ( e , d ) ; const f = this . inodes . length ; this . inodes . push ( e ) ; e . fid = f ; this . is _forwarder ( d ) && this . mounts [ d . mount _id ] . backtrack . set ( d . foreign _id , f ) ; this . should _be _linked ( d ) && ( this . unlink _from _dir ( a , b ) , this . link _under _dir ( a , f , b ) ) ; if ( this . IsDirectory ( c ) && ! this . is _forwarder ( d ) ) for ( const [ g , h ] of e . direntries ) "." !== g && ".." !== g && this . IsDirectory ( h ) && this . inodes [ h ] . direntries . set ( ".." , f ) ; this . inodedata [ f ] =
this . inodedata [ c ] ; delete this . inodedata [ c ] ; d . direntries = new Map ; d . nlinks = 0 ; return f } ; Z . prototype . copy _inode = function ( a , b ) { Object . assign ( b , a , { fid : b . fid , direntries : b . direntries , nlinks : b . nlinks } ) } ; Z . prototype . CreateInode = function ( ) { const a = Math . round ( Date . now ( ) / 1E3 ) , b = new hc ( ++ this . qidcounter . last _qidnumber ) ; b . atime = b . ctime = b . mtime = a ; return b } ;
Z . prototype . CreateDirectory = function ( a , b ) { var c = this . inodes [ b ] ; if ( 0 <= b && this . is _forwarder ( c ) ) return b = c . foreign _id , a = this . follow _fs ( c ) . CreateDirectory ( a , b ) , this . create _forwarder ( c . mount _id , a ) ; c = this . CreateInode ( ) ; c . mode = 511 | da ; 0 <= b && ( c . uid = this . inodes [ b ] . uid , c . gid = this . inodes [ b ] . gid , c . mode = this . inodes [ b ] . mode & 511 | da ) ; c . qid . type = da >> 8 ; this . PushInode ( c , b , a ) ; this . NotifyListeners ( this . inodes . length - 1 , "newdir" ) ; return this . inodes . length - 1 } ;
Z . prototype . CreateFile = function ( a , b ) { var c = this . inodes [ b ] ; if ( this . is _forwarder ( c ) ) return b = c . foreign _id , a = this . follow _fs ( c ) . CreateFile ( a , b ) , this . create _forwarder ( c . mount _id , a ) ; c = this . CreateInode ( ) ; c . uid = this . inodes [ b ] . uid ; c . gid = this . inodes [ b ] . gid ; c . qid . type = ea >> 8 ; c . mode = this . inodes [ b ] . mode & 438 | ea ; this . PushInode ( c , b , a ) ; this . NotifyListeners ( this . inodes . length - 1 , "newfile" ) ; return this . inodes . length - 1 } ;
2024-06-28 09:23:02 +02:00
Z . prototype . CreateNode = function ( a , b , c , d ) { var e = this . inodes [ b ] ; if ( this . is _forwarder ( e ) ) return b = e . foreign _id , a = this . follow _fs ( e ) . CreateNode ( a , b , c , d ) , this . create _forwarder ( e . mount _id , a ) ; e = this . CreateInode ( ) ; e . major = c ; e . minor = d ; e . uid = this . inodes [ b ] . uid ; e . gid = this . inodes [ b ] . gid ; e . qid . type = 192 ; e . mode = this . inodes [ b ] . mode & 438 ; this . PushInode ( e , b , a ) ; return this . inodes . length - 1 } ;
Z . prototype . CreateSymlink = function ( a , b , c ) { var d = this . inodes [ b ] ; if ( this . is _forwarder ( d ) ) return b = d . foreign _id , a = this . follow _fs ( d ) . CreateSymlink ( a , b , c ) , this . create _forwarder ( d . mount _id , a ) ; d = this . CreateInode ( ) ; d . uid = this . inodes [ b ] . uid ; d . gid = this . inodes [ b ] . gid ; d . qid . type = 160 ; d . symlink = c ; d . mode = 40960 ; this . PushInode ( d , b , a ) ; return this . inodes . length - 1 } ;
Z . prototype . CreateTextFile = async function ( a , b , c ) { var d = this . inodes [ b ] ; if ( this . is _forwarder ( d ) ) return b = d . foreign _id , c = await this . follow _fs ( d ) . CreateTextFile ( a , b , c ) , this . create _forwarder ( d . mount _id , c ) ; d = this . CreateFile ( a , b ) ; b = this . inodes [ d ] ; a = new Uint8Array ( c . length ) ; b . size = c . length ; for ( b = 0 ; b < c . length ; b ++ ) a [ b ] = c . charCodeAt ( b ) ; await this . set _data ( d , a ) ; return d } ;
Z . prototype . CreateBinaryFile = async function ( a , b , c ) { var d = this . inodes [ b ] ; if ( this . is _forwarder ( d ) ) return b = d . foreign _id , c = await this . follow _fs ( d ) . CreateBinaryFile ( a , b , c ) , this . create _forwarder ( d . mount _id , c ) ; d = this . CreateFile ( a , b ) ; a = this . inodes [ d ] ; b = new Uint8Array ( c . length ) ; b . set ( c ) ; await this . set _data ( d , b ) ; a . size = c . length ; return d } ;
2024-10-02 21:03:04 +02:00
Z . prototype . OpenInode = function ( a , b ) { var c = this . inodes [ a ] ; if ( this . is _forwarder ( c ) ) return this . follow _fs ( c ) . OpenInode ( c . foreign _id , b ) ; ( c . mode & 61440 ) === da && this . FillDirectory ( a ) ; return ! 0 } ; Z . prototype . CloseInode = async function ( a ) { var b = this . inodes [ a ] ; if ( this . is _forwarder ( b ) ) return await this . follow _fs ( b ) . CloseInode ( b . foreign _id ) ; 2 === b . status && this . storage . uncache ( b . sha256sum ) ; b . status === fa && ( b . status = - 1 , await this . DeleteData ( a ) ) } ;
Z . prototype . Rename = async function ( a , b , c , d ) { if ( a === c && b === d ) return 0 ; var e = this . Search ( a , b ) ; if ( - 1 === e ) return - 2 ; var f = this . GetFullPath ( a ) + "/" + b ; if ( - 1 !== this . Search ( c , d ) ) { var g = this . Unlink ( c , d ) ; if ( 0 > g ) return g } var h = this . inodes [ e ] , l = this . inodes [ a ] ; g = this . inodes [ c ] ; if ( this . is _forwarder ( l ) || this . is _forwarder ( g ) ) if ( this . is _forwarder ( l ) && l . mount _id === g . mount _id ) { if ( a = await this . follow _fs ( l ) . Rename ( l . foreign _id , b , g . foreign _id , d ) , 0 > a ) return a } else { if ( this . is _a _root ( e ) || ! this . IsDirectory ( e ) && 1 < this . GetInode ( e ) . nlinks ) return - 1 ;
l = this . divert ( a , b ) ; const m = this . GetInode ( e ) , n = await this . Read ( l , 0 , m . size ) ; this . is _forwarder ( g ) ? ( c = this . follow _fs ( g ) , d = this . IsDirectory ( l ) ? c . CreateDirectory ( d , g . foreign _id ) : c . CreateFile ( d , g . foreign _id ) , c = c . GetInode ( d ) , this . copy _inode ( m , c ) , this . set _forwarder ( e , g . mount _id , d ) ) : ( this . delete _forwarder ( h ) , this . copy _inode ( m , h ) , this . link _under _dir ( c , e , d ) ) ; await this . ChangeSize ( e , m . size ) ; n && n . length && await this . Write ( e , 0 , n . length , n ) ; if ( this . IsDirectory ( e ) ) for ( const p of this . GetChildren ( l ) ) if ( g = await this . Rename ( l ,
p , e , p ) , 0 > g ) return g ; await this . DeleteData ( l ) ; a = this . Unlink ( a , b ) ; if ( 0 > a ) return a } else this . unlink _from _dir ( a , b ) , this . link _under _dir ( c , e , d ) , h . qid . version ++ ; this . NotifyListeners ( e , "rename" , { oldpath : f } ) ; return 0 } ;
Z . prototype . Write = async function ( a , b , c , d ) { this . NotifyListeners ( a , "write" ) ; var e = this . inodes [ a ] ; if ( this . is _forwarder ( e ) ) a = e . foreign _id , await this . follow _fs ( e ) . Write ( a , b , c , d ) ; else { var f = await this . get _buffer ( a ) ; ! f || f . length < b + c ? ( await this . ChangeSize ( a , Math . floor ( 3 * ( b + c ) / 2 ) ) , e . size = b + c , f = await this . get _buffer ( a ) ) : e . size < b + c && ( e . size = b + c ) ; d && f . set ( d . subarray ( 0 , c ) , b ) ; await this . set _data ( a , f ) } } ;
2024-06-28 09:23:02 +02:00
Z . prototype . Read = async function ( a , b , c ) { const d = this . inodes [ a ] ; return this . is _forwarder ( d ) ? ( a = d . foreign _id , await this . follow _fs ( d ) . Read ( a , b , c ) ) : await this . get _data ( a , b , c ) } ; Z . prototype . Search = function ( a , b ) { a = this . inodes [ a ] ; if ( this . is _forwarder ( a ) ) { const c = a . foreign _id ; b = this . follow _fs ( a ) . Search ( c , b ) ; return - 1 === b ? - 1 : this . get _forwarder ( a . mount _id , b ) } b = a . direntries . get ( b ) ; return void 0 === b ? - 1 : b } ;
Z . prototype . CountUsedInodes = function ( ) { let a = this . inodes . length ; for ( const { fs : b , backtrack : c } of this . mounts ) a += b . CountUsedInodes ( ) , a -= c . size ; return a } ; Z . prototype . CountFreeInodes = function ( ) { let a = 1048576 ; for ( const { fs : b } of this . mounts ) a += b . CountFreeInodes ( ) ; return a } ; Z . prototype . GetTotalSize = function ( ) { let a = this . used _size ; for ( const { fs : b } of this . mounts ) a += b . GetTotalSize ( ) ; return a } ; Z . prototype . GetSpace = function ( ) { let a = this . total _size ; for ( const { fs : b } of this . mounts ) a += b . GetSpace ( ) ; return this . total _size } ;
2024-10-02 21:03:04 +02:00
Z . prototype . GetDirectoryName = function ( a ) { const b = this . inodes [ this . GetParent ( a ) ] ; if ( this . is _forwarder ( b ) ) return this . follow _fs ( b ) . GetDirectoryName ( this . inodes [ a ] . foreign _id ) ; if ( ! b ) return "" ; for ( const [ c , d ] of b . direntries ) if ( d === a ) return c ; return "" } ; Z . prototype . GetFullPath = function ( a ) { this . IsDirectory ( a ) ; for ( var b = "" ; 0 !== a ; ) b = "/" + this . GetDirectoryName ( a ) + b , a = this . GetParent ( a ) ; return b . substring ( 1 ) } ;
2024-06-28 09:23:02 +02:00
Z . prototype . Link = function ( a , b , c ) { if ( this . IsDirectory ( b ) ) return - 1 ; const d = this . inodes [ a ] , e = this . inodes [ b ] ; if ( this . is _forwarder ( d ) ) return this . is _forwarder ( e ) && e . mount _id === d . mount _id ? this . follow _fs ( d ) . Link ( d . foreign _id , e . foreign _id , c ) : - 1 ; if ( this . is _forwarder ( e ) ) return - 1 ; this . link _under _dir ( a , b , c ) ; return 0 } ;
2024-10-02 21:03:04 +02:00
Z . prototype . Unlink = function ( a , b ) { if ( "." === b || ".." === b ) return - 1 ; const c = this . Search ( a , b ) , d = this . inodes [ c ] , e = this . inodes [ a ] ; if ( this . is _forwarder ( e ) ) return this . is _forwarder ( d ) , a = e . foreign _id , this . follow _fs ( e ) . Unlink ( a , b ) ; if ( this . IsDirectory ( c ) && ! this . IsEmpty ( c ) ) return - 39 ; this . unlink _from _dir ( a , b ) ; 0 === d . nlinks && ( d . status = fa , this . NotifyListeners ( c , "delete" ) ) ; return 0 } ;
2024-06-28 09:23:02 +02:00
Z . prototype . DeleteData = async function ( a ) { const b = this . inodes [ a ] ; this . is _forwarder ( b ) ? await this . follow _fs ( b ) . DeleteData ( b . foreign _id ) : ( b . size = 0 , delete this . inodedata [ a ] ) } ; Z . prototype . get _buffer = async function ( a ) { const b = this . inodes [ a ] ; return this . inodedata [ a ] ? this . inodedata [ a ] : 2 === b . status ? await this . storage . read ( b . sha256sum , 0 , b . size ) : null } ;
Z . prototype . get _data = async function ( a , b , c ) { const d = this . inodes [ a ] ; return this . inodedata [ a ] ? this . inodedata [ a ] . subarray ( b , b + c ) : 2 === d . status ? await this . storage . read ( d . sha256sum , b , c ) : null } ; Z . prototype . set _data = async function ( a , b ) { this . inodedata [ a ] = b ; 2 === this . inodes [ a ] . status && ( this . inodes [ a ] . status = 0 , this . storage . uncache ( this . inodes [ a ] . sha256sum ) ) } ; Z . prototype . GetInode = function ( a ) { isNaN ( a ) ; a = this . inodes [ a ] ; return this . is _forwarder ( a ) ? this . follow _fs ( a ) . GetInode ( a . foreign _id ) : a } ;
2024-10-02 21:03:04 +02:00
Z . prototype . ChangeSize = async function ( a , b ) { var c = this . GetInode ( a ) , d = await this . get _data ( a , 0 , c . size ) ; if ( b !== c . size ) { var e = new Uint8Array ( b ) ; c . size = b ; d && e . set ( d . subarray ( 0 , Math . min ( d . length , c . size ) ) , 0 ) ; await this . set _data ( a , e ) } } ;
Z . prototype . SearchPath = function ( a ) { a = a . replace ( "//" , "/" ) ; a = a . split ( "/" ) ; 0 < a . length && 0 === a [ a . length - 1 ] . length && a . pop ( ) ; 0 < a . length && 0 === a [ 0 ] . length && a . shift ( ) ; const b = a . length ; var c = - 1 , d = 0 ; let e = null ; for ( var f = 0 ; f < b ; f ++ ) if ( c = d , d = this . Search ( c , a [ f ] ) , ! e && this . is _forwarder ( this . inodes [ c ] ) && ( e = "/" + a . slice ( f ) . join ( "/" ) ) , - 1 === d ) return f < b - 1 ? { id : - 1 , parentid : - 1 , name : a [ f ] , forward _path : e } : { id : - 1 , parentid : c , name : a [ f ] , forward _path : e } ; return { id : d , parentid : c , name : a [ f ] , forward _path : e } } ;
2024-06-28 09:23:02 +02:00
Z . prototype . GetRecursiveList = function ( a , b ) { if ( this . is _forwarder ( this . inodes [ a ] ) ) { const c = this . follow _fs ( this . inodes [ a ] ) , d = this . inodes [ a ] . mount _id , e = b . length ; c . GetRecursiveList ( this . inodes [ a ] . foreign _id , b ) ; for ( a = e ; a < b . length ; a ++ ) b [ a ] . parentid = this . get _forwarder ( d , b [ a ] . parentid ) } else for ( const [ c , d ] of this . inodes [ a ] . direntries ) "." !== c && ".." !== c && ( b . push ( { parentid : a , name : c } ) , this . IsDirectory ( d ) && this . GetRecursiveList ( d , b ) ) } ;
2024-10-02 21:03:04 +02:00
Z . prototype . RecursiveDelete = function ( a ) { var b = [ ] ; a = this . SearchPath ( a ) ; if ( - 1 !== a . id ) for ( this . GetRecursiveList ( a . id , b ) , a = b . length - 1 ; 0 <= a ; a -- ) this . Unlink ( b [ a ] . parentid , b [ a ] . name ) } ; Z . prototype . DeleteNode = function ( a ) { var b = this . SearchPath ( a ) ; - 1 !== b . id && ( ( this . inodes [ b . id ] . mode & 61440 ) === ea ? this . Unlink ( b . parentid , b . name ) : ( this . inodes [ b . id ] . mode & 61440 ) === da && ( this . RecursiveDelete ( a ) , this . Unlink ( b . parentid , b . name ) ) ) } ; Z . prototype . NotifyListeners = function ( ) { } ;
Z . prototype . Check = function ( ) { for ( var a = 1 ; a < this . inodes . length ; a ++ ) if ( - 1 !== this . inodes [ a ] . status ) { var b = this . GetInode ( a ) ; 0 > b . nlinks && z . Debug ( "Error in filesystem: negative nlinks=" + b . nlinks + " at id =" + a ) ; if ( this . IsDirectory ( a ) ) { b = this . GetInode ( a ) ; this . IsDirectory ( a ) && 0 > this . GetParent ( a ) && z . Debug ( "Error in filesystem: negative parent id " + a ) ; for ( const [ c , d ] of b . direntries ) { 0 === c . length && z . Debug ( "Error in filesystem: inode with no name and id " + d ) ; for ( const e of c ) 32 > e && z . Debug ( "Error in filesystem: Unallowed char in filename" ) } } } } ;
Z . prototype . FillDirectory = function ( a ) { var b = this . inodes [ a ] ; if ( this . is _forwarder ( b ) ) this . follow _fs ( b ) . FillDirectory ( b . foreign _id ) ; else { var c = 0 ; for ( const d of b . direntries . keys ( ) ) c += 24 + jc . encode ( d ) . length ; a = this . inodedata [ a ] = new Uint8Array ( c ) ; b . size = c ; c = 0 ; for ( const [ d , e ] of b . direntries ) b = this . GetInode ( e ) , c += v . Marshall ( [ "Q" , "d" , "b" , "s" ] , [ b . qid , c + 13 + 8 + 1 + 2 + jc . encode ( d ) . length , b . mode >> 12 , d ] , a , c ) } } ;
Z . prototype . RoundToDirentry = function ( a , b ) { a = this . inodedata [ a ] ; if ( b >= a . length ) return a . length ; let c = 0 ; for ( ; ; ) { const d = v . Unmarshall ( [ "Q" , "d" ] , a , { offset : c } ) [ 1 ] ; if ( d > b ) break ; c = d } return c } ; Z . prototype . IsDirectory = function ( a ) { a = this . inodes [ a ] ; return this . is _forwarder ( a ) ? this . follow _fs ( a ) . IsDirectory ( a . foreign _id ) : ( a . mode & 61440 ) === da } ;
2024-06-28 09:23:02 +02:00
Z . prototype . IsEmpty = function ( a ) { a = this . inodes [ a ] ; if ( this . is _forwarder ( a ) ) return this . follow _fs ( a ) . IsDirectory ( a . foreign _id ) ; for ( const b of a . direntries . keys ( ) ) if ( "." !== b && ".." !== b ) return ! 1 ; return ! 0 } ; Z . prototype . GetChildren = function ( a ) { this . IsDirectory ( a ) ; a = this . inodes [ a ] ; if ( this . is _forwarder ( a ) ) return this . follow _fs ( a ) . GetChildren ( a . foreign _id ) ; const b = [ ] ; for ( const c of a . direntries . keys ( ) ) "." !== c && ".." !== c && b . push ( c ) ; return b } ;
Z . prototype . GetParent = function ( a ) { this . IsDirectory ( a ) ; a = this . inodes [ a ] ; if ( this . should _be _linked ( a ) ) return a . direntries . get ( ".." ) ; const b = this . follow _fs ( a ) . GetParent ( a . foreign _id ) ; return this . get _forwarder ( a . mount _id , b ) } ;
2024-10-02 21:03:04 +02:00
Z . prototype . PrepareCAPs = function ( a ) { a = this . GetInode ( a ) ; if ( a . caps ) return a . caps . length ; a . caps = new Uint8Array ( 20 ) ; a . caps [ 0 ] = 0 ; a . caps [ 1 ] = 0 ; a . caps [ 2 ] = 0 ; a . caps [ 3 ] = 2 ; a . caps [ 4 ] = 255 ; a . caps [ 5 ] = 255 ; a . caps [ 6 ] = 255 ; a . caps [ 7 ] = 255 ; a . caps [ 8 ] = 255 ; a . caps [ 9 ] = 255 ; a . caps [ 10 ] = 255 ; a . caps [ 11 ] = 255 ; a . caps [ 12 ] = 63 ; a . caps [ 13 ] = 0 ; a . caps [ 14 ] = 0 ; a . caps [ 15 ] = 0 ; a . caps [ 16 ] = 63 ; a . caps [ 17 ] = 0 ; a . caps [ 18 ] = 0 ; a . caps [ 19 ] = 0 ; return a . caps . length } ; function kc ( a ) { this . fs = a ; this . backtrack = new Map }
kc . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . fs ; a [ 1 ] = [ ... this . backtrack ] ; return a } ; kc . prototype . set _state = function ( a ) { this . fs = a [ 0 ] ; this . backtrack = new Map ( a [ 1 ] ) } ; Z . prototype . set _forwarder = function ( a , b , c ) { const d = this . inodes [ a ] ; this . is _forwarder ( d ) && this . mounts [ d . mount _id ] . backtrack . delete ( d . foreign _id ) ; d . status = 5 ; d . mount _id = b ; d . foreign _id = c ; this . mounts [ b ] . backtrack . set ( c , a ) } ;
2024-06-28 09:23:02 +02:00
Z . prototype . create _forwarder = function ( a , b ) { const c = this . CreateInode ( ) , d = this . inodes . length ; this . inodes . push ( c ) ; c . fid = d ; this . set _forwarder ( d , a , b ) ; return d } ; Z . prototype . is _forwarder = function ( a ) { return 5 === a . status } ; Z . prototype . is _a _root = function ( a ) { return 0 === this . GetInode ( a ) . fid } ; Z . prototype . get _forwarder = function ( a , b ) { const c = this . mounts [ a ] . backtrack . get ( b ) ; return void 0 === c ? this . create _forwarder ( a , b ) : c } ; Z . prototype . delete _forwarder = function ( a ) { this . is _forwarder ( a ) ; a . status = - 1 ; this . mounts [ a . mount _id ] . backtrack . delete ( a . foreign _id ) } ;
2024-10-02 21:03:04 +02:00
Z . prototype . follow _fs = function ( a ) { const b = this . mounts [ a . mount _id ] ; this . is _forwarder ( a ) ; return b . fs } ; Z . prototype . Mount = function ( a , b ) { a = this . SearchPath ( a ) ; if ( - 1 === a . parentid ) return - 2 ; if ( - 1 !== a . id ) return - 17 ; if ( a . forward _path ) { var c = this . inodes [ a . parentid ] ; b = this . follow _fs ( c ) . Mount ( a . forward _path , b ) ; return 0 > b ? b : this . get _forwarder ( c . mount _id , b ) } c = this . mounts . length ; this . mounts . push ( new kc ( b ) ) ; b = this . create _forwarder ( c , 0 ) ; this . link _under _dir ( a . parentid , b , a . name ) ; return b } ;
function ic ( ) { this . type = 2 ; this . start = 0 ; this . length = Infinity ; this . proc _id = - 1 ; this . client _id = "" } ic . prototype . get _state = function ( ) { const a = [ ] ; a [ 0 ] = this . type ; a [ 1 ] = this . start ; a [ 2 ] = Infinity === this . length ? 0 : this . length ; a [ 3 ] = this . proc _id ; a [ 4 ] = this . client _id ; return a } ; ic . prototype . set _state = function ( a ) { this . type = a [ 0 ] ; this . start = a [ 1 ] ; this . length = 0 === a [ 2 ] ? Infinity : a [ 2 ] ; this . proc _id = a [ 3 ] ; this . client _id = a [ 4 ] } ; ic . prototype . clone = function ( ) { const a = new ic ; a . set _state ( this . get _state ( ) ) ; return a } ;
ic . prototype . conflicts _with = function ( a ) { return this . proc _id === a . proc _id && this . client _id === a . client _id || 2 === this . type || 2 === a . type || 1 !== this . type && 1 !== a . type || this . start + this . length <= a . start || a . start + a . length <= this . start ? ! 1 : ! 0 } ; ic . prototype . is _alike = function ( a ) { return a . proc _id === this . proc _id && a . client _id === this . client _id && a . type === this . type } ; ic . prototype . may _merge _after = function ( a ) { return this . is _alike ( a ) && a . start + a . length === this . start } ;
Z . prototype . DescribeLock = function ( a , b , c , d , e ) { const f = new ic ; f . type = a ; f . start = b ; f . length = c ; f . proc _id = d ; f . client _id = e ; return f } ; Z . prototype . GetLock = function ( a , b ) { a = this . inodes [ a ] ; if ( this . is _forwarder ( a ) ) { var c = a . foreign _id ; return this . follow _fs ( a ) . GetLock ( c , b ) } for ( c of a . locks ) if ( b . conflicts _with ( c ) ) return c . clone ( ) ; return null } ;
Z . prototype . Lock = function ( a , b , c ) { const d = this . inodes [ a ] ; if ( this . is _forwarder ( d ) ) return a = d . foreign _id , this . follow _fs ( d ) . Lock ( a , b , c ) ; b = b . clone ( ) ; if ( 2 !== b . type && this . GetLock ( a , b ) ) return 1 ; for ( c = 0 ; c < d . locks . length ; c ++ ) { a = d . locks [ c ] ; if ( a . start + a . length <= b . start ) continue ; if ( b . start + b . length <= a . start ) break ; if ( a . proc _id !== b . proc _id || a . client _id !== b . client _id ) { a . conflicts _with ( b ) ; continue } var e = b . start + b . length ; const f = b . start - a . start , g = a . start + a . length - e ; if ( 0 < f && 0 < g && a . type === b . type ) return 0 ; 0 < f && ( a . length =
f ) ; if ( 0 >= f && 0 < g ) a . start = e , a . length = g ; else if ( 0 < g ) { for ( ; c < d . locks . length && d . locks [ c ] . start < e ; ) c ++ ; d . locks . splice ( c , 0 , this . DescribeLock ( a . type , e , g , a . proc _id , a . client _id ) ) } else 0 >= f && ( d . locks . splice ( c , 1 ) , c -- ) } if ( 2 !== b . type ) { c = b ; a = ! 1 ; for ( e = 0 ; e < d . locks . length && ! ( c . may _merge _after ( d . locks [ e ] ) && ( d . locks [ e ] . length += b . length , c = d . locks [ e ] , a = ! 0 ) , b . start <= d . locks [ e ] . start ) ; e ++ ) ; a || ( d . locks . splice ( e , 0 , c ) , e ++ ) ; for ( ; e < d . locks . length ; e ++ ) if ( d . locks [ e ] . is _alike ( c ) ) { d . locks [ e ] . may _merge _after ( c ) && ( c . length += d . locks [ e ] . length ,
d . locks . splice ( e , 1 ) ) ; break } } return 0 } ; Z . prototype . read _dir = function ( a ) { a = this . SearchPath ( a ) ; if ( - 1 !== a . id ) return a = this . GetInode ( a . id ) , Array . from ( a . direntries . keys ( ) ) . filter ( b => "." !== b && ".." !== b ) } ; Z . prototype . read _file = function ( a ) { a = this . SearchPath ( a ) ; if ( - 1 === a . id ) return Promise . resolve ( null ) ; const b = this . GetInode ( a . id ) ; return this . Read ( a . id , 0 , b . size ) } ; var z = { Debug : function ( a ) { [ ] . slice . apply ( arguments ) . join ( " " ) } , Abort : function ( ) { } } ; var v = { } ; const lc = new TextDecoder , jc = new TextEncoder ;
v . Marshall = function ( a , b , c , d ) { for ( var e , f = 0 , g = 0 ; g < a . length ; g ++ ) switch ( e = b [ g ] , a [ g ] ) { case "w" : c [ d ++ ] = e & 255 ; c [ d ++ ] = e >> 8 & 255 ; c [ d ++ ] = e >> 16 & 255 ; c [ d ++ ] = e >> 24 & 255 ; f += 4 ; break ; case "d" : c [ d ++ ] = e & 255 ; c [ d ++ ] = e >> 8 & 255 ; c [ d ++ ] = e >> 16 & 255 ; c [ d ++ ] = e >> 24 & 255 ; c [ d ++ ] = 0 ; c [ d ++ ] = 0 ; c [ d ++ ] = 0 ; c [ d ++ ] = 0 ; f += 8 ; break ; case "h" : c [ d ++ ] = e & 255 ; c [ d ++ ] = e >> 8 ; f += 2 ; break ; case "b" : c [ d ++ ] = e ; f += 1 ; break ; case "s" : var h = d , l = 0 ; c [ d ++ ] = 0 ; c [ d ++ ] = 0 ; f += 2 ; e = jc . encode ( e ) ; f += e . byteLength ; l += e . byteLength ; c . set ( e , d ) ; d += e . byteLength ; c [ h + 0 ] = l & 255 ; c [ h + 1 ] = l >> 8 &
255 ; break ; case "Q" : v . Marshall ( [ "b" , "w" , "d" ] , [ e . type , e . version , e . path ] , c , d ) ; d += 13 ; f += 13 ; break ; default : z . Debug ( "Marshall: Unknown type=" + a [ g ] ) } return f } ;
v . Unmarshall = function ( a , b , c ) { let d = c . offset ; for ( var e = [ ] , f = 0 ; f < a . length ; f ++ ) switch ( a [ f ] ) { case "w" : var g = b [ d ++ ] ; g += b [ d ++ ] << 8 ; g += b [ d ++ ] << 16 ; g += b [ d ++ ] << 24 >>> 0 ; e . push ( g ) ; break ; case "d" : g = b [ d ++ ] ; g += b [ d ++ ] << 8 ; g += b [ d ++ ] << 16 ; g += b [ d ++ ] << 24 >>> 0 ; d += 4 ; e . push ( g ) ; break ; case "h" : g = b [ d ++ ] ; e . push ( g + ( b [ d ++ ] << 8 ) ) ; break ; case "b" : e . push ( b [ d ++ ] ) ; break ; case "s" : g = b [ d ++ ] ; g += b [ d ++ ] << 8 ; var h = b . slice ( d , d + g ) ; d += g ; e . push ( lc . decode ( h ) ) ; break ; case "Q" : c . offset = d ; g = v . Unmarshall ( [ "b" , "w" , "d" ] , b , c ) ; d = c . offset ; e . push ( { type : g [ 0 ] , version : g [ 1 ] ,
path : g [ 2 ] } ) ; break ; default : z . Debug ( "Error in Unmarshall: Unknown type=" + a [ f ] ) } c . offset = d ; return e } ; } ) . call ( this ) ;