@@ -52,26 +52,26 @@ function makeOffsetTable({ read, write }) {
5252 return ( size = constants . dc . w , { items } = { } ) => [
5353 ( { getCursor } ) => ( { ref } ) => {
5454 const cursor = getCursor ( ) ;
55- if ( ! ref . global . a ) {
56- ref . global . a = 0x7FFF ;
55+ if ( ! ref . global . ptr ) {
56+ ref . global . ptr = 0x7FFF ;
5757 }
5858 const headers = [ ] ;
59- for ( let i = cursor ; i < 1e5 && i < ref . global . a ; i = getCursor ( ) ) {
59+ // we keep searching for headers until either;
60+ // - cursor reaches a header pointer value
61+ // - items is exceeded
62+ for ( let i = cursor ; i < 1e5 && i < ref . global . ptr ; i = getCursor ( ) ) {
6063 const header = ( read ( size ) & 0x7FFF ) + cursor ;
6164 headers . push ( header ) ;
6265 logger ( '= HEADER =' , header ) ;
63- // logger(a, header < a, header, cursor);
64- if ( header < ref . global . a && ! ( header === 0 ) ) {
65- ref . global . a = header ;
66+ if ( header < ref . global . ptr && ! ( header === 0 ) ) {
67+ ref . global . ptr = header ;
6668 }
67- // logger('HEADER LIMIT', i, a, cursor, a - cursor);
6869 if ( items && headers . length >= items ) break ;
6970 }
7071 if ( ! ref . global . firstHeader ) {
7172 ref . global . firstHeader = true ;
7273 ref . global . cleanup . push ( ( { sprites } ) => {
7374 sprites . splice ( 0 , sprites . length ) ;
74- // sprites.push([]);
7575 } ) ;
7676 }
7777 ref . global . cleanup . push ( ( { sprites, spritesAddr } ) => {
0 commit comments